bonsaif-ui 0.1.139 → 0.1.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- (function(F,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],s):(F=typeof globalThis<"u"?globalThis:F||self,s(F.BonsaifUI={},F.React,F.jsxRuntime,F.ReactIconsHi2,F.ReactDOM,F.Recharts,F.OverlayScrollbarsGlobal,F.Sonner,F.OverlayScrollbarsReact,F.ReactDayPicker,F.ReactDayPickerStyles,F.ReactIconsFi))})(this,(function(F,s,t,j,pt,Me,Ha,Ia,es,Ba,Wm,tc){"use strict";"use client";function Qt(...e){return e.filter(Boolean).join(" ")}function rc({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Qt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function ts({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,b]=s.useState(!1),f=l||m||e.trim().length>0,g=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",p=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=u.current)==null||v.focus())},[o]);const S=()=>{var v;b(!0),(v=u.current)==null||v.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?p:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),S())},children:[t.jsx(j.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${g} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${f?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:f?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:v=>{b(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{b(!1),v.currentTarget.style.borderColor="var(--border)",v.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const rs=s.createContext({});let ns=0;const as="bonsaif-ui:hide-tooltips";function Sn(e=700){ns=Date.now()+e}function nc(){return Date.now()>ns}function En(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function ac(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 Ft({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:b="div"}){const f=s.useRef(null),g=s.useRef(null),p=s.useRef(null),S=s.useRef(!1),[v,C]=s.useState(null),[T,E]=s.useState("");s.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(G=>{const U=G.getAttribute("title");U&&(G.getAttribute("aria-label")||G.setAttribute("aria-label",U),G.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(G=>G.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const D=g.current;if(!D)return;const G=12,U=14,ae=D.getBoundingClientRect(),Q=window.innerWidth-ae.width-G,R=window.innerHeight-ae.height-G;let V=v.mouseX+U,Y=v.mouseY+U,ue,L;if(!o&&f.current){const B=f.current.getBoundingClientRect(),ce=B.left+B.width/2,H=B.top+B.height/2;l==="top"?(V=ce-ae.width/2,Y=B.top-ae.height-U,L=ae.height-1):l==="left"?(V=B.left-ae.width-U,Y=H-ae.height/2,ue=ae.width-1):l==="right"?(V=B.right+U,Y=H-ae.height/2,ue=-7):(V=ce-ae.width/2,Y=B.bottom+U,L=-7)}if(o&&(V>Q&&(V=v.mouseX-ae.width-U),Y>R&&(Y=v.mouseY-ae.height-U)),V=Math.min(Math.max(G,V),Math.max(G,Q)),Y=Math.min(Math.max(G,Y),Math.max(G,R)),!o&&f.current){const B=f.current.getBoundingClientRect(),ce=B.left+B.width/2,H=B.top+B.height/2;l==="top"||l==="bottom"?ue=Math.min(Math.max(14,ce-V),ae.width-14):L=Math.min(Math.max(14,H-Y),ae.height-14)}(Math.abs(V-v.x)>.5||Math.abs(Y-v.y)>.5||ue!==v.arrowX||L!==v.arrowY)&&C(B=>B&&{...B,x:V,y:Y,arrowX:ue,arrowY:L})},[o,l,v]);const O=()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},N=(D,G)=>{if(!nc()||S.current)return;const U=f.current;if(U&&!En(U)){if(n){const ae=ac(U);if(!ae)return;E(ae)}!n&&!r||C({mouseX:D,mouseY:G,x:D+14,y:G+14})}},x=()=>{const D=f.current;if(!D)return;const G=D.getBoundingClientRect();N(G.left+G.width/2,G.bottom)},M=()=>{O(),C(null)},w=()=>{if(!a){M();return}O(),p.current=window.setTimeout(()=>C(null),120)},P=()=>{Sn(),S.current=!0,M()},X=()=>{S.current=!1};s.useEffect(()=>{if(!v)return;if(En(f.current)){C(null);return}const D=()=>C(null),G=()=>{Sn(),S.current=!0,C(null)};document.addEventListener("pointerdown",G,!0),document.addEventListener("click",G,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const U=new MutationObserver(()=>{En(f.current)&&C(null)});return U.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("click",G,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),U.disconnect()}},[v]),s.useEffect(()=>{const D=()=>Sn(),G=()=>{Sn(),S.current=!0,C(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(as,G),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(as,G)}},[]);const K=n?T:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{O(),X(),o?N(D.clientX,D.clientY):x()},onMouseMove:D=>{v&&o&&N(D.clientX,D.clientY)},onMouseDown:P,onClick:P,onMouseLeave:()=>{X(),w()},onFocus:x,onBlur:M,children:e}),v&&K&&!En(f.current)?pt.createPortal(t.jsxs("div",{ref:g,role:"tooltip",className:d,onMouseEnter:a?O:void 0,onMouseLeave:a?w:void 0,style:{position:"fixed",top:v.y,left:v.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...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:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),K]}),document.body):null]})}function os(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const oc="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",sc={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"},lc="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",ic={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"},cc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},dc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Fa(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Fa).join(" ").trim():s.isValidElement(e)?Fa(e.props.children):""}function uc(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ge({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:b,...f}){const g=s.useContext(rs),p=l??g.iconOnly??e==="icon",S=g.compact??!1,v=g.headerAction??!1,C=v&&r==="md"?"sm":S&&!v&&r==="md"?"xs":r,T=e==="icon"||p,E=v&&T,O=Fa(d),N=o??f.title??f["aria-label"]??(p?O:void 0),x=N?void 0:f.title,M=f["aria-label"]??(typeof N=="string"?N:O||void 0),w=n?null:a??(p?uc(d):null),P=t.jsxs("button",{...f,title:x,"aria-label":M,"data-variant":e,"data-size":C,"data-icon":T?"true":void 0,disabled:m||n,className:`${oc} ${E?lc:sc[e]} ${T?cc[C]:ic[C]} ${S&&!T?"px-2.5":""} ${u}`,style:{...dc[e],height:os(i),padding:os(c),...b,...v&&!T?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...E?{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"}):w,!p&&d]});return N?t.jsx(Ft,{as:"span",content:N,className:"inline-flex shrink-0",children:P}):P}const gt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Cn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=o?"px-2 py-2":"px-3 py-2.5",u=o?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:gt})]}),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:gt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...gt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,g)=>t.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...gt,width:`${46+(b*13+g*11)%42}%`,minWidth:28}})},`c-${b}-${g}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:gt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:gt})]})]})}function fc({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 bc({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 ss({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(Cn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(mc,{rows:i});if(e==="cards")return t.jsx(hc,{rows:i});const m=o||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(bc,{logoSrc:a,logoAlt:m}):null,t.jsx(fc,{size:b?"md":"sm"}),t.jsxs("div",{className:b?"space-y-1.5":"",children:[t.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f})}function mc({rows:e}){return t.jsx(Cn,{rows:e,columns:7})}function hc({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:gt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:gt})]},n))})}function ls(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 is(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function pc(e){return[e.label,ls(e.service),e.description,e.service].filter(Boolean).join(" ")}function gc(e){return typeof e=="function"?e:e.default}function vc(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(Ge,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function yc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:p,emptyState:S,loadingState:v,errorState:C=vc,renderTabLabel:T,searchableTabs:E="auto",tabsSearchThreshold:O=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:x,onTabsSearchChange:M,emptySearchState:w,showTabCount:P=!0,className:X="",parentClassName:K="",contentClassName:D="",tabsClassName:G=""}){var Se;const U=s.useMemo(()=>l.filter(ne=>!ne.hidden&&((b==null?void 0:b(ne,o))??!0)),[b,o,l]),ae=(Se=U.find(ne=>!ne.disabled))==null?void 0:Se.service,[Q,R]=s.useState(u??ae??""),[V,Y]=s.useState({}),[ue,L]=s.useState({}),[B,ce]=s.useState(""),[H,oe]=s.useState(!1),k=s.useRef(ue),te=s.useRef(0),z=x??B,I=is(z),de=E===!0||E==="auto"&&U.length>=O,re=de&&z.trim().length>0,q=s.useMemo(()=>I?U.filter(ne=>is(pc(ne)).includes(I)):U,[I,U]),y=d??Q,$=U.find(ne=>ne.service===y)??U.find(ne=>!ne.disabled);s.useEffect(()=>{!$&&ae&&R(ae)},[ae,$]),s.useEffect(()=>{k.current=ue},[ue]);const ee=ne=>{ne.disabled||(d||R(ne.service),m==null||m(ne.service,ne))},fe=ne=>{x===void 0&&ce(ne),M==null||M(ne)},ie=(ne,Le)=>{const Oe=q.filter(je=>!je.disabled),Ve=Oe.findIndex(je=>je.service===Le.service);Ve<0||((ne.key==="ArrowRight"||ne.key==="ArrowDown")&&(ne.preventDefault(),ee(Oe[(Ve+1)%Oe.length])),(ne.key==="ArrowLeft"||ne.key==="ArrowUp")&&(ne.preventDefault(),ee(Oe[(Ve-1+Oe.length)%Oe.length])),ne.key==="Home"&&(ne.preventDefault(),ee(Oe[0])),ne.key==="End"&&(ne.preventDefault(),ee(Oe[Oe.length-1])))},he=s.useCallback(()=>{if(!$)return;const ne=$.service,Le=k.current[ne];if(Le!=null&&Le.loading||Le!=null&&Le.component&&f)return;const Oe=(i==null?void 0:i[ne])??c;if(!Oe){L(je=>({...je,[ne]:{loading:!1,error:new Error(`No module loader found for service "${ne}".`)}}));return}const Ve=++te.current;L(je=>({...je,[ne]:{...je[ne],loading:!0,error:void 0}})),Oe($,o).then(je=>{if(Ve!==te.current&&!f)return;const Be=gc(je);L(et=>({...et,[ne]:{component:Be,loading:!1}}))}).catch(je=>{const Be=je instanceof Error?je:new Error(String(je));L(et=>({...et,[ne]:{...et[ne],loading:!1,error:Be}}))})},[o,f,c,i,$]);s.useEffect(he,[he]);const Te=$?V[$.service]??null:null,De=$?ue[$.service]:void 0,ft=De==null?void 0:De.component,Ct=ne=>{$&&Y(Le=>({...Le,[$.service]:ne}))},nt=()=>{$&&Y(ne=>({...ne,[$.service]:null}))},st={context:o,parent:a,links:l,visibleLinks:U,filteredLinks:q,selectedLink:$,selectedService:$==null?void 0:$.service,activeItemId:Te,tabsSearch:z,onSelectService:ee,onOpenDetail:Ct,onBackToList:nt},le=n?n(st):r?t.jsx(r,{...st}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${X}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${K}`,children:le}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(g||p||de||P)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[g&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:g}),p&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:p})]}),(de||P)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[P&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[q.length," / ",U.length]}),de&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${H?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!H,children:t.jsx(ts,{value:z,onChange:fe,placeholder:N,className:"w-full",autoFocus:H,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:H?0:-1})}),t.jsx("button",{type:"button","aria-label":H?"Cerrar busqueda":"Buscar tabs","aria-expanded":H,onClick:()=>{H&&z&&fe(""),oe(ne=>!ne)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${H||re?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:H||re?t.jsx(j.HiXMark,{className:"h-4 w-4"}):t.jsx(j.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":g??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${G}`,children:q.length>0?q.map(ne=>{const Le=ne.service===($==null?void 0:$.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Le,disabled:ne.disabled,onClick:()=>ee(ne),onKeyDown:Oe=>ie(Oe,ne),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Le?"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(ne,Le):t.jsxs(t.Fragment,{children:[ne.icon,t.jsx("span",{children:ne.label??ls(ne.service)}),ne.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ne.badge})]})},ne.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:w??"No hay modulos que coincidan con la busqueda."})}),($==null?void 0:$.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:$.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!$&&(S??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."})),$&&(De==null?void 0:De.loading)&&(v??t.jsx(ss,{title:"Cargando modulo..."})),$&&(De==null?void 0:De.error)&&C(De.error,he),$&&ft&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(ft,{context:o,parent:a,link:$,activeItemId:Te,onOpenDetail:Ct,onBackToList:nt})]})]})]})}const xc={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(j.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(j.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(j.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(j.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(j.HiInformationCircle,{className:"h-5 w-5"})}};function wc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=xc[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(Ge,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]})}const cs=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Nc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],kc=["lu","ma","mi","ju","vi","sá","do"],ds=6;function Pa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Sc(){const e=new Date;return Pa(e.getFullYear(),e.getMonth()+1,e.getDate())}function us(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function Ec(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=us(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${cs[n-1]} ${r}`}function Cc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=Sc(),c=us(e||l),d=a==="popover",[u,m]=s.useState(!1),b=s.useRef(null),[f,g]=s.useState({horizontal:"left",vertical:"bottom"}),[p,S]=s.useState(c.year),[v,C]=s.useState(c.month),[T,E]=s.useState("days"),O=16,[N,x]=s.useState(0),M=p-7+N,w=Array.from({length:O},(R,V)=>M+V);s.useEffect(()=>{if(!d||!u||!b.current)return;const R=b.current.getBoundingClientRect(),V=8,Y=280,ue=340,L=R.left+Y>window.innerWidth-V,B=R.right-Y>=V,ce=R.bottom+8+ue>window.innerHeight-V,H=R.top-8-ue>=V;g({horizontal:L&&B?"right":"left",vertical:ce&&H?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function R(Y){b.current&&(b.current.contains(Y.target)||m(!1))}function V(Y){Y.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",V)}},[d,u]);function P(){v===1?(S(R=>R-1),C(12)):C(R=>R-1)}function X(){v===12?(S(R=>R+1),C(1)):C(R=>R+1)}const K=(new Date(p,v-1,1).getDay()+6)%7,D=new Date(p,v,0).getDate(),G=[...Array(K).fill(null),...Array.from({length:D},(R,V)=>V+1)];for(;G.length<ds*7;)G.push(null);const U=G.slice(0,ds*7);function ae(R){const V=Pa(p,v,R);n&&V<n||(r(V),d&&m(!1))}const Q=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:T==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:P,"aria-label":"Mes anterior",children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{E("years"),x(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[cs[v-1]," ",p]}),t.jsx(j.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:X,"aria-label":"Mes siguiente",children:t.jsx(j.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(R=>R-O),"aria-label":"Años anteriores",children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>E("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[w[0]," – ",w[w.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(R=>R+O),"aria-label":"Años siguientes",children:t.jsx(j.HiChevronRight,{size:16})})]})}),T==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Nc.map((R,V)=>{const Y=V+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${Y?" is-active":""}`,onClick:()=>C(V+1),children:R},R)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:w.map(R=>{const V=R===p,Y=R===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${V?" is-active":""}${Y&&!V?" is-today":""}`,onClick:()=>{S(R),E("days")},children:R},R)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:kc.map(R=>t.jsx("div",{className:"bonsaif-multi-weekday",children:R},R))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:U.map((R,V)=>{if(R===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},V);const Y=Pa(p,v,R),ue=Y===e,L=Y===l,B=!!(n&&Y<n);return t.jsx("div",{className:`bonsaif-multi-day${ue?" bonsaif-multi-day-selected":""}${L?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ue,onClick:()=>!B&&ae(R),children:R})},V)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(R=>!R),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(j.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:Ec(e)})]}),t.jsx(j.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:Q})]}):Q}function Vt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Ft,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function _a(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function za(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Mc(e,r){if(!r.trim())return!0;const n=za(r);return za(e.label).includes(n)||!!(e.sublabel&&za(e.sublabel).includes(n))}function ur({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:b,dropdownMinWidth:f,height:g=40,padding:p="0 10px",searchable:S=!0,minOptionsForSearch:v=6}){const[C,T]=s.useState(!1),[E,O]=s.useState(""),[N,x]=s.useState(-1),[M,w]=s.useState(!1),[P,X]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),U=s.useRef(null),ae=S&&n.length>=v,Q=n.find(z=>z.value===e)??null,R=l==="ghost",V=a==="error"?"var(--danger)":C?"var(--primary)":"var(--border)",Y=ae&&E.trim()?n.filter(z=>Mc(z,E)):n,ue=s.useCallback(()=>{const z=K.current;if(!z)return;const I=z.getBoundingClientRect(),de=ae?272:212,re=window.innerHeight-I.bottom,q=re<de&&I.top>re;X({position:"fixed",left:I.left,top:q?void 0:I.bottom+4,bottom:q?window.innerHeight-I.top+4:void 0,width:I.width,minWidth:_a(f),zIndex:9999})},[f,ae]);s.useEffect(()=>w(!0),[]),s.useEffect(()=>{if(!C)return;function z(I){var re,q;const de=I.target;!((re=K.current)!=null&&re.contains(de))&&!((q=D.current)!=null&&q.contains(de))&&(T(!1),O(""))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[C]),s.useEffect(()=>{C&&(x(-1),ue(),ae&&setTimeout(()=>{var z;return(z=G.current)==null?void 0:z.focus()},0))},[C,ae,ue]),s.useEffect(()=>{if(C)return window.addEventListener("resize",ue),window.addEventListener("scroll",ue,!0),()=>{window.removeEventListener("resize",ue),window.removeEventListener("scroll",ue,!0)}},[C,ue]),s.useEffect(()=>{if(N<0||!U.current)return;const z=U.current.children[N];z==null||z.scrollIntoView({block:"nearest"})},[N]);const L=s.useCallback(z=>{r(z),T(!1),O("")},[r]),B=s.useRef(C);B.current=C;const ce=s.useRef(Y);ce.current=Y;const H=s.useRef(N);H.current=N;const oe=s.useRef(d);oe.current=d;const k=s.useRef(L);k.current=L,s.useEffect(()=>{function z(I){var y,$;const de=document.activeElement,re=((y=K.current)==null?void 0:y.contains(de))??!1,q=(($=D.current)==null?void 0:$.contains(de))??!1;if(!(!re&&!q)){if(!B.current){(I.key==="Enter"||I.key===" "||I.key==="ArrowDown")&&(I.preventDefault(),T(!0));return}switch(I.key){case"ArrowDown":I.preventDefault(),x(ee=>Math.min(ee+1,ce.current.length-1));break;case"ArrowUp":I.preventDefault(),x(ee=>Math.max(ee-1,oe.current?-1:0));break;case"Enter":{I.preventDefault();const ee=H.current,fe=ce.current;ee===-1&&oe.current?k.current(""):fe[ee]&&!fe[ee].disabled&&k.current(fe[ee].value);break}case"Escape":I.preventDefault(),I.stopPropagation(),T(!1),O("");break}}}return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const te=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...P,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ae&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:E,onChange:z=>{O(z.target.value),x(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),E&&t.jsx("button",{type:"button",onMouseDown:z=>{z.preventDefault(),O("")},children:t.jsx(j.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:U,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ae?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:z=>{z.preventDefault(),L("")},onMouseEnter:()=>x(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:N===-1&&!E.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),Y.map((z,I)=>{const re=I===N,q=z.value===e;return t.jsxs("li",{role:"option","aria-selected":q,onMouseDown:y=>{y.preventDefault(),z.disabled||L(z.value)},onMouseEnter:()=>!z.disabled&&x(I),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:re?"var(--bg-hover)":q?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:z.disabled?"var(--text-muted)":"var(--text-main)",cursor:z.disabled?"not-allowed":"pointer",boxShadow:q?"inset 2px 0 0 var(--primary)":void 0},children:[z.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:z.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:z.label}),z.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:z.sublabel})]}),z.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:z.badge})]},z.value)}),Y.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:K,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&T(z=>!z),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:_a(g),padding:_a(p),background:R?"transparent":"var(--bg-input)",color:Q?"var(--text-main)":"var(--text-muted)",border:R?"1px solid transparent":`1px solid ${V}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,"aria-label":o,children:[(Q==null?void 0:Q.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:Q.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:Q?t.jsxs(t.Fragment,{children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:Q.label}),i&&Q.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:Q.sublabel})]}):t.jsx(Vt,{className:"min-w-0 flex-1",children:c})}),Q&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:z=>{z.preventDefault(),z.stopPropagation(),L("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"w-3 h-3"})}):t.jsx(j.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&M&&pt.createPortal(te,document.body)]})}const Tc={sm:"h-4 w-4",md:"h-5 w-5"};function $c(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Mn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=s.useRef(null);return s.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,$c(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${Tc[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(j.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})]})]})}),fs=32767;function Tn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=fs?r:`${r.slice(0,fs-1)}…`}const $n=[25,50,100,200,500];let At={dataTable:{pageSizeOptions:[...$n]}};function Ac(){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 Wa(){const e=At.dataTable.preferencesEndpoint,r=Ac();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Lc(e){if(!Array.isArray(e))return[...$n];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:[...$n]}function bs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Dc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=bs(e.dataTable.preferencesEndpoint);At={...At,dataTable:{...At.dataTable,pageSizeOptions:Lc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??At.dataTable.preferencesEndpoint}}}function Oc(){return{dataTable:{pageSizeOptions:[...At.dataTable.pageSizeOptions]}}}function Jr(){return[...At.dataTable.pageSizeOptions]}function Hc(){At={dataTable:{pageSizeOptions:[...$n]}}}function Ic(e){At={...At,dataTable:{...At.dataTable,preferencesEndpoint:bs(e)}}}const An=[{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"}],Bc=An.map(e=>({value:e.value,label:e.label})),Fc=12,Pc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ms={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},_c="bonsaif-ui:datatable:",zc="[&_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",Wc=[],jc=52;function Yt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function hs(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 ps(e){return`${_c}${e}`}function Ln(e){try{const r=window.localStorage.getItem(ps(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function qc(e,r){try{window.localStorage.setItem(ps(e),JSON.stringify(r))}catch{}}function Uc(e,r){if(e===!0)return{...ms};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ms};const n={...Pc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function gs(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function ja(e,r,n){return typeof e!="number"||e<=0?n:nn(r).includes(e)?e:n}function Rr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function en(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=o.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function tn(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(An.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 xt(e,r){if(fr(e))return jc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Vc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function fr(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function qa(e){return e.sticky===!0}function vs(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Dn(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function Jt(e,r){const n=r.filter(qa).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 Yc(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 Rt(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 Xc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function Sr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Sr).join(" ").trim():s.isValidElement(e)?Sr(e.props.children):""}function On(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?Xc(n):Sr(n).trim()}function rn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Er(e,r){const n=rn(e),a=rn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function nn(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Jr()}function Kc(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=An.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return Er(e,a)>0;case"greaterThanOrEqual":return Er(e,a)>=0;case"lessThan":return Er(e,a)<0;case"lessThanOrEqual":return Er(e,a)<=0;case"between":return Er(e,a)>=0&&Er(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:rn(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(rn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=rn(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ys({children:e,className:r="",style:n}){return t.jsx(Ft,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function Ua({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:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:g,expandOnRowClick:p=!1,selected:S,onToggleOne:v,onToggleAll:C,getRowSelectable:T,highlightSelected:E=!0,rowClassName:O,getRowCategory:N,stickyHeader:x=!0,pageSize:M=25,pageSizeOptions:w,pageSizeSelectWidth:P=62,pageSizeSelectHeight:X=30,pageSizeSelectPadding:K="0 7px",totalRows:D,page:G,onPageChange:U,onPageSizeChange:ae,storageKey:Q,stickyFirstColumn:R=!1,bottomOffset:V=0,compact:Y=!0,restrictHeight:ue=!0,maxHeight:L,minTableWidth:B,enableColumnVisibility:ce=!0,enableColumnFilters:H=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:k=Wc,onHiddenColumnKeysChange:te,columnVisibilityLabel:z="Columnas",enableBql:I=!1,bqlValue:de,defaultBqlValue:re="",onBqlChange:q,bqlDescription:y="Filtra registros con Bonsaif Query Language",bqlPlaceholder:$=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:ee=[],bqlExamples:fe=[],bqlSuggestions:ie=[],bqlActiveFilters:he,bqlError:Te,onQueryChange:De,persistState:ft,onPreferencesReady:Ct,enableExport:nt=!1,exportFilename:st="datos",onExportCsv:le,onExportPdf:Se}){var Ri;const ne=Uc(ft,Q),Le=Object.values(ne).some(Boolean),Oe=e.map(h=>h.key).join(","),Ve=k.join(","),je=s.useRef(e),Be=s.useRef(k);je.current=e,Be.current=k;const[et,ot]=s.useState(!Q||!Le),Ht=s.useRef(null),be=s.useRef(!Q),ge=s.useRef(!1),He=s.useRef(Ct);He.current=Ct;const We=s.useRef(!Q||!Le?Q??"__none__":null),Fe=oe!==void 0,[bt,ct]=s.useState(()=>Rt(k,e)),qe=Rt(Fe?oe:bt,e),[Ye,dt]=s.useState(!1),[mt,mr]=s.useState("filter"),[ut,ze]=s.useState(null),[vn,ba]=s.useState(""),[ht,Mt]=s.useState({}),[Tt,or]=s.useState({}),jr=b!==void 0,[W,Z]=s.useState(f),me=de!==void 0,[pe,Ee]=s.useState(re),ye=me?de:pe,[Pe,Ie]=s.useState(ye),[Ze,Qe]=s.useState(!1),[sr,vt]=s.useState(!1),[Kt,It]=s.useState(!1),[lr,Gt]=s.useState([]),qr=s.useRef(null),hr=s.useRef(null),jt=s.useRef(q);jt.current=q;const ma=s.useRef(M);ma.current=M;const ha=s.useRef(w);ha.current=w;const rm=Array.isArray(w)?w.join(","):"",Bo=s.useRef(null),ki=s.useRef(null),Fo=s.useRef(null),Si=s.useRef(0),[nm,am]=s.useState({}),[om,sm]=s.useState({}),[yn,pa]=s.useState(!1),Po=s.useRef(null),ga=s.useRef(null),[lm,im]=s.useState({}),Ei=s.useRef(null),va=s.useRef(null),[_o,Ci]=s.useState(r.length>0||a||c===!1),Mi=(h,A)=>50+(h*17+A*13+7)%40,ir=s.useRef(null),[cm,dm]=s.useState(void 0),[Ti,um]=s.useState(0),[fm,bm]=s.useState(!1);s.useEffect(()=>{function h(){bm(window.innerWidth<640)}if(!ue||L!==void 0)return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h);const J=M!==!1?48:0,_=12;function se(){if(h(),!ir.current)return;const ve=ir.current.getBoundingClientRect().top;dm(Math.max(120,window.innerHeight-ve-J-_-V))}return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[a,M,V,ue,L]);const $i=ue?L??cm:void 0;s.useEffect(()=>{const h=ir.current;if(!h)return;const A=()=>um(h.clientWidth);if(A(),typeof ResizeObserver>"u")return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A);const J=new ResizeObserver(A);return J.observe(h),()=>J.disconnect()},[a,et,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){Ci(!0);return}if(_o)return;const h=window.setTimeout(()=>{Ci(!0)},c);return()=>window.clearTimeout(h)},[r.length,c,_o,a]);const[Ur,Vr]=s.useState(()=>Jt(e.map(h=>h.key),e)),[pr,Yr]=s.useState(()=>Object.fromEntries(e.map(h=>[h.key,xt(h,Yt(h.width))]))),[Je,gr]=s.useState(null),[mm,ya]=s.useState(1),[xa,wa]=s.useState(M===!1?0:M);s.useEffect(()=>{var Ae;const h=je.current,A=Be.current,J=h.map(ke=>ke.key),_=new Set(J),se=()=>{var ke;ge.current||(ge.current=!0,(ke=He.current)==null||ke.call(He))};if(!Q||!Le){ne.layout&&Vr(Jt(J,h)),Fe||ct(Rt(A,h)),be.current=!1,ot(!0),se();return}let ve=!1;const Ce=We.current===Q;Ce||(be.current=!1,ot(!1),ge.current=!1);const $e=Ln(Q);if(hs($e)&&!Ce){const ke=$e,we=nn(ha.current??Jr()),Ne=ma.current,xr=Ne===!1?0:Ne,dr=ne.layout?ke==null?void 0:ke.columnOrder:void 0,wr=Array.isArray(dr)?dr.filter(Xe=>J.includes(Xe)):[],Nr=Jt(wr.length>0?Dn(wr,J):J,h),kr=Object.fromEntries(h.map(Xe=>[Xe.key,xt(Xe,Yt(Xe.width))])),Gr=ne.layout?(ke==null?void 0:ke.columnWidths)??{}:{},kn=Object.fromEntries(h.map(Xe=>[Xe.key,xt(Xe,Gr[Xe.key]??kr[Xe.key])])),Zr=Rt(ne.layout?(ke==null?void 0:ke.hiddenColumnKeys)??A:A,h);if(ne.layout&&(Vr(Nr),Yr(kn)),Fe||ct(Zr),ne.filters&&(Mt(en(ke==null?void 0:ke.filters,_)),or(tn(ke==null?void 0:ke.conditionFilters,_))),ne.sort){const Xe=Rr(ke==null?void 0:ke.sort)?ke.sort:null;gr(Xe&&_.has(Xe.key)?Xe:null)}if(ne.bql){if(qr.current!==Q){qr.current=Q;const Xe=typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:re;me?(Ae=jt.current)==null||Ae.call(jt,Xe):Ee(Xe)}Gt(Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory.filter(Xe=>typeof Xe=="string"):[])}ne.pagination&&hr.current!==Q&&(hr.current=Q,wa(ja(ke==null?void 0:ke.pageSize,we,xr))),We.current=Q,ot(!0),se()}const yt=`${Wa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(Q)}`,rt=new AbortController,xe=window.setTimeout(()=>rt.abort(),2500);return fetch(yt,{cache:"no-store",signal:rt.signal}).then(ke=>ke.ok?ke.json():null).then(ke=>{var ec;if(ve)return;const we=Ln(Q),Ne=gs(hs(ke==null?void 0:ke.settings)?ke==null?void 0:ke.settings:null,we),xr=nn(ha.current??Jr()),dr=ma.current,wr=dr===!1?0:dr,Nr=ne.layout?Ne==null?void 0:Ne.columnOrder:void 0,kr=Array.isArray(Nr)?Nr.filter(at=>J.includes(at)):[],Gr=Jt(kr.length>0?Dn(kr,J):J,h),kn=Object.fromEntries(h.map(at=>[at.key,xt(at,Yt(at.width))])),Zr=ne.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},Xe=Object.fromEntries(h.map(at=>[at.key,xt(at,Zr[at.key]??kn[at.key])])),Qr=Rt(ne.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??A:A,h);if(ne.layout&&(Vr(Gr),Yr(Xe)),Fe||ct(Qr),ne.filters&&(Mt(en(Ne==null?void 0:Ne.filters,_)),or(tn(Ne==null?void 0:Ne.conditionFilters,_))),ne.sort){const at=Rr(Ne==null?void 0:Ne.sort)?Ne.sort:null;gr(at&&_.has(at.key)?at:null)}if(ne.bql){if(qr.current!==Q){qr.current=Q;const at=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:re;me?(ec=jt.current)==null||ec.call(jt,at):Ee(at)}Gt(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(at=>typeof at=="string"):[])}let Re;ne.pagination&&(Re=ja(Ne==null?void 0:Ne.pageSize,xr,wr),hr.current!==Q&&(hr.current=Q,wa(Re))),Ht.current=JSON.stringify({columnOrder:Gr,columnWidths:Xe,hiddenColumnKeys:Qr,filters:en(Ne==null?void 0:Ne.filters,_),conditionFilters:tn(Ne==null?void 0:Ne.conditionFilters,_),sort:Rr(Ne==null?void 0:Ne.sort)?Ne.sort:null,bql:typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:"",bqlHistory:Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory:[],pageSize:ne.pagination&&dr!==!1?Re:void 0}),be.current=!0}).catch(()=>{var ke;if(!ve){const we=Ln(Q),Ne=nn(ha.current??Jr()),xr=ma.current,dr=xr===!1?0:xr,wr=ne.layout?we==null?void 0:we.columnOrder:void 0,Nr=Array.isArray(wr)?wr.filter(Re=>J.includes(Re)):[],kr=Jt(Nr.length>0?Dn(Nr,J):J,h),Gr=Object.fromEntries(h.map(Re=>[Re.key,xt(Re,Yt(Re.width))])),kn=ne.layout?(we==null?void 0:we.columnWidths)??{}:{},Zr=Object.fromEntries(h.map(Re=>[Re.key,xt(Re,kn[Re.key]??Gr[Re.key])]));ne.layout&&(Vr(kr),Yr(Zr));const Xe=Rt(ne.layout?(we==null?void 0:we.hiddenColumnKeys)??A:A,h);if(Fe||ct(Xe),ne.filters&&(Mt(en(we==null?void 0:we.filters,_)),or(tn(we==null?void 0:we.conditionFilters,_))),ne.sort){const Re=Rr(we==null?void 0:we.sort)?we.sort:null;gr(Re&&_.has(Re.key)?Re:null)}if(ne.bql){if(qr.current!==Q){qr.current=Q;const Re=typeof(we==null?void 0:we.bql)=="string"?we.bql:re;me?(ke=jt.current)==null||ke.call(jt,Re):Ee(Re)}Gt(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(Re=>typeof Re=="string"):[])}let Qr;ne.pagination&&(Qr=ja(we==null?void 0:we.pageSize,Ne,dr),hr.current!==Q&&(hr.current=Q,wa(Qr))),Ht.current=JSON.stringify({columnOrder:kr,columnWidths:Zr,hiddenColumnKeys:Xe,filters:en(we==null?void 0:we.filters,_),conditionFilters:tn(we==null?void 0:we.conditionFilters,_),sort:Rr(we==null?void 0:we.sort)?we.sort:null,bql:typeof(we==null?void 0:we.bql)=="string"?we.bql:"",bqlHistory:Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory:[],pageSize:ne.pagination&&xr!==!1?Qr:void 0}),be.current=!0}}).finally(()=>{window.clearTimeout(xe),ve||(We.current=Q,ot(!0),se())}),()=>{ve=!0,rt.abort(),window.clearTimeout(xe)}},[Q,Le,Oe,Ve,Fe,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination,me,re,rm]),s.useEffect(()=>{if(!Q||!et||!Le||!be.current)return;const h={};ne.layout&&(h.columnOrder=Ur,h.columnWidths=pr,h.hiddenColumnKeys=qe),ne.filters&&(h.filters=ht,h.conditionFilters=Tt),ne.sort&&(h.sort=Je),ne.bql&&(h.bql=ye,h.bqlHistory=lr),ne.pagination&&M!==!1&&(h.pageSize=xa);const A=Ln(Q),J=gs(A,h),_=JSON.stringify(J);if(_===Ht.current)return;qc(Q,J),Ht.current=_;const se=window.setTimeout(()=>{const ve=Wa()??"/api/user/preferences/datatables";fetch(ve,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:Q,settings:J})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(se)},[Ur,pr,qe,ht,Tt,Je,ye,lr,xa,M,Q,et,Le,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination]),s.useEffect(()=>{Vr(h=>{const A=e.map(J=>J.key);return Jt(Dn(h,A),e)})},[Oe,e]);const Ai=Jt(Ur,e).map(h=>e.find(A=>A.key===h)).filter(h=>!!h),$t=Ai.filter(h=>!qe.includes(h.key)),Li=e.some(qa),hm=Object.keys(ht).length,pm=Object.keys(Tt).length,zo=hm+pm;function Di(h){const A=new Set;return r.reduce((J,_)=>{const se=On(h,_);return!se||A.has(se)||(A.add(se),J.push({value:se,label:se})),J},[])}function gm(){const h=e.find(A=>A.key===ut);return h?Di(h):[]}function vm(h){return!!(H&&!fr(h)&&(h.filterValue||h.sortKey||Di(h).length>0))}function Oi(h,A){Mt(J=>{const _={...J};return _[h]=A,_})}function ym(h,A,J,_){const se=ht[h]??[],ve=_?se:J.filter($e=>$e!==A),Ce=_?se.includes(A)?se.filter($e=>$e!==A):[...se,A]:ve;Ce.length===J.length?Wo(h):Oi(h,Ce)}function Wo(h){Mt(A=>{const J={...A};return delete J[h],J})}function Na(h,A){or(J=>{const _={...J};return A?_[h]=A:delete _[h],_})}function Hi(h){Na(h,null)}function xm(){Mt({}),or({})}function wm(h){me||Ee(h),q==null||q(h)}function Ii(h){const A=h.trim();Ie(A),(q==null?void 0:q(A))!==!1&&(me||Ee(A),Qe(!1),vt(!1),It(!1),A&&Gt(_=>[A,..._.filter(se=>se!==A)].slice(0,Fc)))}function Bi(){Ie(""),wm(""),Qe(!1),vt(!1),It(!1)}function jo(h,A){Ie(h),A&&(A.style.height="auto",A.style.height=`${Math.min(A.scrollHeight,180)}px`)}function ka(h){const A=h.trim();if(!A)return;Si.current=Date.now()+500;const J=Pe.replace(/\s+$/u,""),_=J.length===0?A:J.split(`
3
- `).map(se=>se.trim()).includes(A)?J:`${J}
4
- ${A}`;jo(_,Fo.current??void 0),requestAnimationFrame(()=>{const se=Fo.current;if(!se)return;se.focus();const ve=se.value.length;se.setSelectionRange(ve,ve),jo(se.value,se)})}s.useEffect(()=>{Ie(ye)},[ye]);const Sa=s.useCallback(()=>{const h=Bo.current;if(!h)return;const A=h.getBoundingClientRect(),J=12,_=8,se=Math.min(780,Math.max(320,window.innerWidth-32)),ve=Math.max(J,window.innerWidth-se-J),Ce=Math.min(Math.max(J,A.left),ve),$e=A.bottom+_,Ue=window.innerHeight-A.top+_,Ke=window.innerHeight-$e-J,yt=A.top-J-_,rt=Ke<280&&yt>Ke,xe=Math.max(240,rt?yt:Ke);am({position:"fixed",zIndex:1e4,left:Ce,top:rt?void 0:$e,bottom:rt?Ue:void 0,width:se,maxWidth:"calc(100vw - 24px)",maxHeight:xe,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ze)return;function h(_){var ve,Ce;if(Date.now()<Si.current)return;const se=_.target;(ve=Bo.current)!=null&&ve.contains(se)||(Ce=ki.current)!=null&&Ce.contains(se)||(Qe(!1),vt(!1),It(!1))}function A(_){_.key==="Escape"&&(Qe(!1),vt(!1),It(!1))}function J(){Sa()}return Sa(),document.addEventListener("mousedown",h),window.addEventListener("keydown",A),window.addEventListener("resize",J),window.addEventListener("scroll",J,!0),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",A),window.removeEventListener("resize",J),window.removeEventListener("scroll",J,!0)}},[Ze,Sa]);function Fi(h){const A=Rt(h,e);Fe||ct(A),te==null||te(A)}function Nm(h){Fi(qe.includes(h)?qe.filter(A=>A!==h):[...qe,h])}function km(){Fi([])}const qo=s.useCallback((h=va.current)=>{if(!h)return;const A=h.getBoundingClientRect(),J=Math.min(292,Math.max(240,window.innerWidth-16)),_=Math.max(8,window.innerWidth-J-8),se=Math.min(Math.max(8,A.right-J),_),ve=window.innerHeight-A.bottom,Ce=A.bottom+6,$e=window.innerHeight-A.top+6,Ke=ve<360&&A.top>ve?void 0:Ce,yt=Ke===void 0?$e:void 0,rt=Math.max(220,Ke===void 0?A.top-16:window.innerHeight-Ce-8),xe={position:"fixed",zIndex:9999,left:se,top:Ke,bottom:yt,width:J,maxWidth:"calc(100vw - 16px)",maxHeight:rt,"--dt-column-menu-max-height":`${rt}px`};sm(xe)},[]);function Pi(h,A,J=null){h.preventDefault(),h.stopPropagation();const _=va.current===h.currentTarget&&mt===A&&ut===J;if(Ye&&_){dt(!1),ze(null);return}va.current=h.currentTarget,mr(A),ze(J),ba(""),qo(h.currentTarget),dt(!0)}function Sm(h){if(fr(h))return;const A=ir.current;if(!A)return;const _=Array.from(A.querySelectorAll("[data-dt-column-key]")).filter(se=>se.dataset.dtColumnKey===h.key).reduce((se,ve)=>{const Ce=ve.querySelector("[data-dt-autofit-content]"),$e=Ce?Ce.scrollWidth:Math.max(ve.scrollWidth,ve.offsetWidth);return Math.max(se,Math.ceil($e+Vc(ve)))},0);_<=0||Yr(se=>({...se,[h.key]:xt(h,_+12)}))}s.useEffect(()=>{Yr(h=>{const A=Object.fromEntries(e.map(J=>[J.key,xt(J,Yt(J.width))]));return Object.fromEntries(e.map(J=>[J.key,xt(J,h[J.key]??A[J.key])]))})},[Oe,e]),s.useEffect(()=>{Fe||ct(h=>Rt(h,e))},[Oe,e,Fe]),s.useEffect(()=>{function h(_){var Ce,$e;const se=_.target,ve=_.target;ve!=null&&ve.closest("[data-bonsaif-select-dropdown='true']")||!((Ce=Ei.current)!=null&&Ce.contains(se))&&!(($e=va.current)!=null&&$e.contains(se))&&(dt(!1),ze(null))}function A(_){_.key==="Escape"&&(dt(!1),ze(null))}function J(){qo()}return Ye&&(document.addEventListener("mousedown",h),window.addEventListener("keydown",A),window.addEventListener("resize",J),window.addEventListener("scroll",J,!0)),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",A),window.removeEventListener("resize",J),window.removeEventListener("scroll",J,!0)}},[Ye,qo]);const xn=s.useRef(null);s.useEffect(()=>{function h(J){const _=xn.current;if(!_)return;const se=J.clientX-_.startX,ve=e.find(Ce=>Ce.key===_.colKey);ve&&Yr(Ce=>({...Ce,[_.colKey]:xt(ve,_.startWidth+se)}))}function A(){xn.current&&(xn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",h),document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",A)}},[e]);const wn=s.useRef(null),[_i,Uo]=s.useState(null);function Em(h,A){const J=e.find(_=>_.key===h);if(!J||!vs(J)){A.preventDefault();return}wn.current=Ur.indexOf(h),A.dataTransfer.effectAllowed="move"}function Cm(h,A){A.preventDefault(),A.dataTransfer.dropEffect="move";const J=Ur.indexOf(h);_i!==J&&Uo(J)}function Mm(h,A){A.preventDefault();const J=wn.current,_=Ur.indexOf(h);J!==null&&J!==_&&Vr(se=>{const ve=[...se],[Ce]=ve.splice(J,1);return ve.splice(_,0,Ce),Jt(ve,e)}),wn.current=null,Uo(null)}function Tm(){wn.current=null,Uo(null)}function $m(h){h.sortKey&&gr(A=>(A==null?void 0:A.key)===h.key?{key:h.key,dir:A.dir==="asc"?"desc":"asc"}:{key:h.key,dir:"asc"})}s.useEffect(()=>{ya(1)},[r]),s.useEffect(()=>{ya(1)},[Tt,ht]);const qt=!!(U&&ae),cr=M!==!1,Vo=s.useMemo(()=>nn(w??Jr()),[w]),it=qt?G??1:mm,zi=cr&&xa<1?typeof M=="number"&&M>0?M:Vo[0]??25:xa,Ut=qt||cr?zi:r.length,Bt=!!S&&!!v&&!!C,Yo=s.useMemo(()=>T?r.filter(h=>T(h)):r,[r,T]),Xr=!!u,Wi=s.useMemo(()=>new Set(jr?Array.from(b??[]):W),[jr,b,W]),Am=(Xr?40:0)+(Bt?40:0),Xo=!fm&&(Li||R),Ea=(()=>{if(!Xo)return{};let h=Am;const A={};return $t.forEach((J,_)=>{(qa(J)||!Li&&R&&_===0)&&(A[J.key]=h,h+=pr[J.key]??xt(J,Yt(J.width)))}),A})(),Ko=Object.keys(Ea),Go=Ko.length>0?Ko[Ko.length-1]:null,ji=Bt&&Yo.length>0&&Yo.every(h=>S.has(n(h))),Lm=Bt&&S.size>0&&Yo.some(h=>S.has(n(h)))&&!ji,Ca=s.useMemo(()=>{if(qt)return r;const h=Object.entries(ht),A=Object.entries(Tt);return h.length===0&&A.length===0?r:r.filter(J=>h.every(([_,se])=>{const ve=e.find(Ce=>Ce.key===_);return ve?se.includes(On(ve,J)):!0})&&A.every(([_,se])=>{const ve=e.find($e=>$e.key===_);if(!ve)return!0;const Ce=r.map($e=>On(ve,$e));return Kc(On(ve,J),se,Ce)}))},[Tt,ht,e,r,qt]),vr=s.useMemo(()=>{if(!Je)return Ca;const h=e.find(A=>A.key===Je.key&&A.sortKey);return h!=null&&h.sortKey?[...Ca].sort((A,J)=>{const _=A[h.sortKey],se=J[h.sortKey],ve=_===se?0:_==null?1:se==null||_<se?-1:1;return Je.dir==="asc"?ve:-ve}):Ca},[Ca,Je,e]),qi=s.useMemo(()=>{if(qt||!cr)return vr;const h=(it-1)*Ut;return vr.slice(h,h+Ut)},[vr,qt,cr,it,Ut]),Zt=qt?D??r.length:vr.length,Zo=cr?Math.max(1,Math.ceil(Zt/Ut)):1,Dm=Math.min(...Vo),Om=cr&&(Zt>Ut||Zt>Dm),Hm=cr?(it-1)*Ut+1:1,Im=cr?Math.min(it*Ut,Zt):Zt;function Qo(h){if(a)return;const A=Math.max(1,Math.min(h,Zo));qt?U(A):ya(A)}function Bm(h){a||(Q&&(hr.current=Q),wa(h),qt?(ae(h),U(1)):(ya(1),ae==null||ae(h)))}function Ui(h){const A=new Set(Wi);A.has(h)?A.delete(h):A.add(h);const J=Array.from(A);jr||Z(J),g==null||g(J)}s.useEffect(()=>{De==null||De({bql:ye,filters:ht,conditionFilters:Tt,sort:Je,page:it,pageSize:Ut,hiddenColumnKeys:qe})},[ye,ht,Tt,Je,it,Ut,qe,De]);const Vi=h=>h==="center"?"justify-center text-center":h==="right"?"justify-end text-right":"justify-start text-left",Fm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Jo="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%)",_e="color-mix(in srgb, var(--border) 62%, var(--bg-card))",yr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ma=`inset 0 0 0 1px ${_e}`,Yi=$t.reduce((h,A)=>h+(pr[A.key]??Yt(A.width)),(Xr?40:0)+(Bt?40:0)),Xi=typeof B=="number"?B:typeof B=="string"?Number(((Ri=B.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ri[1])??NaN):NaN,Nn=Number.isFinite(Xi)?Math.max(Yi,Xi,Ti):Math.max(Yi,Ti),Ta=B??Nn,Kr=`${Xr?"40px ":""}${Bt?"40px ":""}${$t.map(h=>`${pr[h.key]??Yt(h.width)}px`).join(" ")}`;s.useEffect(()=>{Je&&qe.includes(Je.key)&&gr(null)},[qe,Je]);function Ki(h){return h?typeof h=="string"?{key:h,label:h}:h:null}const $a=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,background:Jo,borderBottom:`1px solid ${yr}`},children:[Xr&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`}}),Bt&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Xo?{position:"sticky",left:0,zIndex:12,background:Jo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`},children:t.jsx(Mn,{size:"sm",checked:ji,indeterminate:Lm,onChange:C,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),$t.map((h,A)=>{const J=(Je==null?void 0:Je.key)===h.key,_=!!h.sortKey,se=fr(h),ve=Ea[h.key],Ce=ve!==void 0,$e=h.key===Go,Ue=vs(h),Ke=_i===A,rt=(pr[h.key]??Yt(h.width))<120,xe=Object.prototype.hasOwnProperty.call(ht,h.key)||Object.prototype.hasOwnProperty.call(Tt,h.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":h.key,className:`group select-none ${rt?"text-left":Vi(h.align)}`,style:{...Ce?{position:"sticky",left:ve,zIndex:12,background:Jo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${yr}`:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${_e}`}:{position:"relative",borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`},color:J?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ke?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:se?Y?"7px 6px":"9px 8px":Y?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ae=>{(Ue||wn.current!==null)&&Cm(h.key,Ae)},onDrop:Ae=>Mm(h.key,Ae),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${se?"justify-center":rt?"justify-start":h.align==="center"?"justify-center":h.align==="right"?"justify-end":"justify-start"}`,children:[Ue?t.jsx("span",{draggable:!0,onDragStart:Ae=>{Ae.stopPropagation(),Em(h.key,Ae)},onDragEnd:Ae=>{Ae.stopPropagation(),Tm()},onClick:Ae=>Ae.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${Ke?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,se?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(j.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(ys,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${Y?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:h.header})})}),_&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(h.header)}`,title:"Ordenar",onClick:Ae=>{Ae.stopPropagation(),$m(h)},"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 ${J?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:J?Je.dir==="asc"?t.jsx(j.HiChevronUp,{className:"h-3 w-3"}):t.jsx(j.HiChevronDown,{className:"h-3 w-3"}):t.jsx(j.HiChevronUpDown,{className:"h-3 w-3"})}),H&&!se&&vm(h)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&ut===h.key,"aria-label":`Filtrar ${String(h.header)}`,title:"Filtrar",onClick:Ae=>Pi(Ae,"filter",h.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 ${Ye&&mt==="filter"&&ut===h.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":xe?"text-[var(--primary)] opacity-100":""}`,children:xe?t.jsx(j.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(j.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!se&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),xn.current={colKey:h.key,startX:Ae.clientX,startWidth:pr[h.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),xn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Sm(h)},onClick:Ae=>Ae.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},h.key)})]}),Aa=()=>{if(!Ye||typeof document>"u"||mt==="visibility"&&!ce||mt==="filter"&&!H)return null;const h=e.find(xe=>xe.key===ut),A=gm(),J=h?Object.prototype.hasOwnProperty.call(ht,h.key):!1,_=h?Tt[h.key]:void 0,se=An.find(xe=>xe.value===(_==null?void 0:_.operator)),ve=h?ht[h.key]??[]:[],Ce=vn.trim().toLowerCase(),$e=Ce?A.filter(xe=>xe.label.toLowerCase().includes(Ce)):A,Ue=h&&A.length>0&&(!J||ve.length===A.length),Ke=h&&J&&ve.length>0&&ve.length<A.length,yt=qe.length,rt=()=>{h&&(Wo(h.key),Hi(h.key))};return pt.createPortal(t.jsx("div",{ref:Ei,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...om,borderColor:"var(--border)",background:"var(--bg-card)"},children:mt==="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:yt>0?`${$t.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:km,disabled:yt===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:Ai.map(xe=>{const Ae=!qe.includes(xe.key),we=!(xe.hideable!==!1)||Ae&&$t.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,disabled:we,onClick:()=>Nm(xe.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.header})]},xe.key)})})]}):h?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 ",h.header]}),t.jsx("button",{type:"button",onClick:rt,disabled:!J&&!_,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"})]}),h.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:()=>gr({key:h.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(j.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Je==null?void 0:Je.key)===h.key&&Je.dir==="asc"&&t.jsx(j.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>gr({key:h.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(j.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Je==null?void 0:Je.key)===h.key&&Je.dir==="desc"&&t.jsx(j.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(ur,{value:(_==null?void 0:_.operator)??"",onChange:xe=>{if(!xe){Hi(h.key);return}Na(h.key,{operator:xe,value:(_==null?void 0:_.value)??"",valueTo:(_==null?void 0:_.valueTo)??""})},options:Bc,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"}),(se==null?void 0:se.valueMode)!=="none"?t.jsx("input",{value:(_==null?void 0:_.value)??"",onChange:xe=>{_&&Na(h.key,{..._,value:xe.target.value})},disabled:!_,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"})]}),(se==null?void 0:se.valueMode)==="between"&&t.jsx("input",{value:(_==null?void 0:_.valueTo)??"",onChange:xe=>{_&&Na(h.key,{..._,valueTo:xe.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:vn,onChange:xe=>ba(xe.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ke?"mixed":!!Ue,onClick:()=>{h&&(Ue&&!J?Oi(h.key,[]):Wo(h.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:Ue||Ke?"var(--primary)":"var(--border)",background:Ue||Ke?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ke&&t.jsx(j.HiMinus,{className:"h-3 w-3"}),Ue&&!Ke&&t.jsx(j.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(xe=>{const Ae=!J||ve.includes(xe.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,onClick:()=>ym(h.key,xe.value,A.map(ke=>ke.value),J),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.label})]},xe.value)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!yn)return;function h(A){Po.current&&!Po.current.contains(A.target)&&ga.current&&!ga.current.contains(A.target)&&pa(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[yn]);function Gi(h,A){if(h.filterValue){const J=h.filterValue(A);return J==null||J===""?"":Tn(J)}return Tn(Sr(h.cell(A)))}function Zi(h){return`"${Tn(h).replace(/"/g,'""')}"`}function La(h){return Tn(h).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Qi(){return qt&&Zt>vr.length&&Ia.toast.warning(`Exportando ${vr.length.toLocaleString("es-MX")} de ${Zt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),vr}function Pm(){const h=$t.filter(Ue=>!fr(Ue)),A=Qi(),J=h.map(Ue=>Zi(Sr(Ue.header))).join(","),_=A.map(Ue=>h.map(Ke=>Zi(Gi(Ke,Ue))).join(",")).join(`
5
- `),se=`${J}
6
- ${_}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createObjectURL(ve),$e=document.createElement("a");$e.href=Ce,$e.download=`${st}.csv`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Ce)}function _m(){const h=$t.filter($e=>!fr($e)),A=Qi(),J=h.map($e=>La(Sr($e.header))),se=A.map($e=>h.map(Ue=>La(Gi(Ue,$e)))).map($e=>`<tr>${$e.map(Ue=>`<td>${Ue}</td>`).join("")}</tr>`).join(""),ve=`<!DOCTYPE html>
1
+ (function(F,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],s):(F=typeof globalThis<"u"?globalThis:F||self,s(F.BonsaifUI={},F.React,F.jsxRuntime,F.ReactIconsHi2,F.ReactDOM,F.Recharts,F.OverlayScrollbarsGlobal,F.Sonner,F.OverlayScrollbarsReact,F.ReactDayPicker,F.ReactDayPickerStyles,F.ReactIconsFi))})(this,(function(F,s,t,W,pt,Me,Ha,Ia,es,Ba,Wm,tc){"use strict";"use client";function Qt(...e){return e.filter(Boolean).join(" ")}function rc({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Qt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function ts({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,b]=s.useState(!1),f=l||m||e.trim().length>0,p=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",g=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=u.current)==null||v.focus())},[o]);const k=()=>{var v;b(!0),(v=u.current)==null||v.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?g:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),k())},children:[t.jsx(W.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${p} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${f?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:f?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:v=>{b(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{b(!1),v.currentTarget.style.borderColor="var(--border)",v.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const rs=s.createContext({});let ns=0;const as="bonsaif-ui:hide-tooltips";function Sn(e=700){ns=Date.now()+e}function nc(){return Date.now()>ns}function En(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function ac(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 Ft({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:b="div"}){const f=s.useRef(null),p=s.useRef(null),g=s.useRef(null),k=s.useRef(!1),[v,A]=s.useState(null),[E,M]=s.useState("");s.useEffect(()=>{const O=f.current;O&&(O.querySelectorAll("[title]").forEach(K=>{const q=K.getAttribute("title");q&&(K.getAttribute("aria-label")||K.setAttribute("aria-label",q),K.removeAttribute("title"))}),O.querySelectorAll("svg title").forEach(K=>K.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const O=p.current;if(!O)return;const K=12,q=14,le=O.getBoundingClientRect(),J=window.innerWidth-le.width-K,G=window.innerHeight-le.height-K;let U=v.mouseX+q,Y=v.mouseY+q,ue,L;if(!o&&f.current){const B=f.current.getBoundingClientRect(),de=B.left+B.width/2,I=B.top+B.height/2;l==="top"?(U=de-le.width/2,Y=B.top-le.height-q,L=le.height-1):l==="left"?(U=B.left-le.width-q,Y=I-le.height/2,ue=le.width-1):l==="right"?(U=B.right+q,Y=I-le.height/2,ue=-7):(U=de-le.width/2,Y=B.bottom+q,L=-7)}if(o&&(U>J&&(U=v.mouseX-le.width-q),Y>G&&(Y=v.mouseY-le.height-q)),U=Math.min(Math.max(K,U),Math.max(K,J)),Y=Math.min(Math.max(K,Y),Math.max(K,G)),!o&&f.current){const B=f.current.getBoundingClientRect(),de=B.left+B.width/2,I=B.top+B.height/2;l==="top"||l==="bottom"?ue=Math.min(Math.max(14,de-U),le.width-14):L=Math.min(Math.max(14,I-Y),le.height-14)}(Math.abs(U-v.x)>.5||Math.abs(Y-v.y)>.5||ue!==v.arrowX||L!==v.arrowY)&&A(B=>B&&{...B,x:U,y:Y,arrowX:ue,arrowY:L})},[o,l,v]);const H=()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},S=(O,K)=>{if(!nc()||k.current)return;const q=f.current;if(q&&!En(q)){if(n){const le=ac(q);if(!le)return;M(le)}!n&&!r||A({mouseX:O,mouseY:K,x:O+14,y:K+14})}},x=()=>{const O=f.current;if(!O)return;const K=O.getBoundingClientRect();S(K.left+K.width/2,K.bottom)},C=()=>{H(),A(null)},w=()=>{if(!a){C();return}H(),g.current=window.setTimeout(()=>A(null),120)},P=()=>{Sn(),k.current=!0,C()},V=()=>{k.current=!1};s.useEffect(()=>{if(!v)return;if(En(f.current)){A(null);return}const O=()=>A(null),K=()=>{Sn(),k.current=!0,A(null)};document.addEventListener("pointerdown",K,!0),document.addEventListener("click",K,!0),document.addEventListener("scroll",O,!0),window.addEventListener("blur",O),document.addEventListener("visibilitychange",O),document.addEventListener("keydown",O,!0);const q=new MutationObserver(()=>{En(f.current)&&A(null)});return q.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("click",K,!0),document.removeEventListener("scroll",O,!0),window.removeEventListener("blur",O),document.removeEventListener("visibilitychange",O),document.removeEventListener("keydown",O,!0),q.disconnect()}},[v]),s.useEffect(()=>{const O=()=>Sn(),K=()=>{Sn(),k.current=!0,A(null)};return document.addEventListener("pointerdown",O,!0),document.addEventListener("click",O,!0),document.addEventListener("keydown",O,!0),window.addEventListener(as,K),()=>{document.removeEventListener("pointerdown",O,!0),document.removeEventListener("click",O,!0),document.removeEventListener("keydown",O,!0),window.removeEventListener(as,K)}},[]);const X=n?E:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:O=>{f.current=O},className:c,style:u,onMouseEnter:O=>{H(),V(),o?S(O.clientX,O.clientY):x()},onMouseMove:O=>{v&&o&&S(O.clientX,O.clientY)},onMouseDown:P,onClick:P,onMouseLeave:()=>{V(),w()},onFocus:x,onBlur:C,children:e}),v&&X&&!En(f.current)?pt.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:d,onMouseEnter:a?H:void 0,onMouseLeave:a?w:void 0,style:{position:"fixed",top:v.y,left:v.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...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:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),X]}),document.body):null]})}function os(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const oc="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",sc={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"},lc="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",ic={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"},cc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},dc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Fa(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Fa).join(" ").trim():s.isValidElement(e)?Fa(e.props.children):""}function uc(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ge({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:b,...f}){const p=s.useContext(rs),g=l??p.iconOnly??e==="icon",k=p.compact??!1,v=p.headerAction??!1,A=v&&r==="md"?"sm":k&&!v&&r==="md"?"xs":r,E=e==="icon"||g,M=v&&E,H=Fa(d),S=o??f.title??f["aria-label"]??(g?H:void 0),x=S?void 0:f.title,C=f["aria-label"]??(typeof S=="string"?S:H||void 0),w=n?null:a??(g?uc(d):null),P=t.jsxs("button",{...f,title:x,"aria-label":C,"data-variant":e,"data-size":A,"data-icon":E?"true":void 0,disabled:m||n,className:`${oc} ${M?lc:sc[e]} ${E?cc[A]:ic[A]} ${k&&!E?"px-2.5":""} ${u}`,style:{...dc[e],height:os(i),padding:os(c),...b,...v&&!E?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...M?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):w,!g&&d]});return S?t.jsx(Ft,{as:"span",content:S,className:"inline-flex shrink-0",children:P}):P}const gt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Cn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=o?"px-2 py-2":"px-3 py-2.5",u=o?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:gt})]}),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:gt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...gt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,p)=>t.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...gt,width:`${46+(b*13+p*11)%42}%`,minWidth:28}})},`c-${b}-${p}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:gt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:gt})]})]})}function fc({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 bc({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 ss({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(Cn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(mc,{rows:i});if(e==="cards")return t.jsx(hc,{rows:i});const m=o||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(bc,{logoSrc:a,logoAlt:m}):null,t.jsx(fc,{size:b?"md":"sm"}),t.jsxs("div",{className:b?"space-y-1.5":"",children:[t.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f})}function mc({rows:e}){return t.jsx(Cn,{rows:e,columns:7})}function hc({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:gt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:gt})]},n))})}function ls(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 is(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function pc(e){return[e.label,ls(e.service),e.description,e.service].filter(Boolean).join(" ")}function gc(e){return typeof e=="function"?e:e.default}function vc(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(Ge,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function yc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:p,subtitle:g,emptyState:k,loadingState:v,errorState:A=vc,renderTabLabel:E,searchableTabs:M="auto",tabsSearchThreshold:H=6,tabsSearchPlaceholder:S="Buscar modulo...",tabsSearchValue:x,onTabsSearchChange:C,emptySearchState:w,showTabCount:P=!0,className:V="",parentClassName:X="",contentClassName:O="",tabsClassName:K=""}){var Se;const q=s.useMemo(()=>l.filter(re=>!re.hidden&&((b==null?void 0:b(re,o))??!0)),[b,o,l]),le=(Se=q.find(re=>!re.disabled))==null?void 0:Se.service,[J,G]=s.useState(u??le??""),[U,Y]=s.useState({}),[ue,L]=s.useState({}),[B,de]=s.useState(""),[I,oe]=s.useState(!1),N=s.useRef(ue),R=s.useRef(0),ae=x??B,$=is(ae),ne=M===!0||M==="auto"&&q.length>=H,te=ne&&ae.trim().length>0,j=s.useMemo(()=>$?q.filter(re=>is(pc(re)).includes($)):q,[$,q]),y=d??J,T=q.find(re=>re.service===y)??q.find(re=>!re.disabled);s.useEffect(()=>{!T&&le&&G(le)},[le,T]),s.useEffect(()=>{N.current=ue},[ue]);const ee=re=>{re.disabled||(d||G(re.service),m==null||m(re.service,re))},fe=re=>{x===void 0&&de(re),C==null||C(re)},ie=(re,Le)=>{const Oe=j.filter(je=>!je.disabled),Ve=Oe.findIndex(je=>je.service===Le.service);Ve<0||((re.key==="ArrowRight"||re.key==="ArrowDown")&&(re.preventDefault(),ee(Oe[(Ve+1)%Oe.length])),(re.key==="ArrowLeft"||re.key==="ArrowUp")&&(re.preventDefault(),ee(Oe[(Ve-1+Oe.length)%Oe.length])),re.key==="Home"&&(re.preventDefault(),ee(Oe[0])),re.key==="End"&&(re.preventDefault(),ee(Oe[Oe.length-1])))},he=s.useCallback(()=>{if(!T)return;const re=T.service,Le=N.current[re];if(Le!=null&&Le.loading||Le!=null&&Le.component&&f)return;const Oe=(i==null?void 0:i[re])??c;if(!Oe){L(je=>({...je,[re]:{loading:!1,error:new Error(`No module loader found for service "${re}".`)}}));return}const Ve=++R.current;L(je=>({...je,[re]:{...je[re],loading:!0,error:void 0}})),Oe(T,o).then(je=>{if(Ve!==R.current&&!f)return;const Be=gc(je);L(et=>({...et,[re]:{component:Be,loading:!1}}))}).catch(je=>{const Be=je instanceof Error?je:new Error(String(je));L(et=>({...et,[re]:{...et[re],loading:!1,error:Be}}))})},[o,f,c,i,T]);s.useEffect(he,[he]);const Te=T?U[T.service]??null:null,De=T?ue[T.service]:void 0,ft=De==null?void 0:De.component,Ct=re=>{T&&Y(Le=>({...Le,[T.service]:re}))},nt=()=>{T&&Y(re=>({...re,[T.service]:null}))},st={context:o,parent:a,links:l,visibleLinks:q,filteredLinks:j,selectedLink:T,selectedService:T==null?void 0:T.service,activeItemId:Te,tabsSearch:ae,onSelectService:ee,onOpenDetail:Ct,onBackToList:nt},ce=n?n(st):r?t.jsx(r,{...st}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${V}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${X}`,children:ce}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${O}`,children:[(p||g||ne||P)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[p&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),g&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:g})]}),(ne||P)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[P&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[j.length," / ",q.length]}),ne&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${I?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!I,children:t.jsx(ts,{value:ae,onChange:fe,placeholder:S,className:"w-full",autoFocus:I,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:I?0:-1})}),t.jsx("button",{type:"button","aria-label":I?"Cerrar busqueda":"Buscar tabs","aria-expanded":I,onClick:()=>{I&&ae&&fe(""),oe(re=>!re)},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 ${I||te?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:I||te?t.jsx(W.HiXMark,{className:"h-4 w-4"}):t.jsx(W.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":p??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${K}`,children:j.length>0?j.map(re=>{const Le=re.service===(T==null?void 0:T.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Le,disabled:re.disabled,onClick:()=>ee(re),onKeyDown:Oe=>ie(Oe,re),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 ${Le?"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:E?E(re,Le):t.jsxs(t.Fragment,{children:[re.icon,t.jsx("span",{children:re.label??ls(re.service)}),re.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:re.badge})]})},re.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:w??"No hay modulos que coincidan con la busqueda."})}),(T==null?void 0:T.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:T.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!T&&(k??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),T&&(De==null?void 0:De.loading)&&(v??t.jsx(ss,{title:"Cargando modulo..."})),T&&(De==null?void 0:De.error)&&A(De.error,he),T&&ft&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(ft,{context:o,parent:a,link:T,activeItemId:Te,onOpenDetail:Ct,onBackToList:nt})]})]})]})}const xc={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(W.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(W.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})}};function wc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=xc[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(Ge,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]})}const cs=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Nc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],kc=["lu","ma","mi","ju","vi","sá","do"],ds=6;function Pa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Sc(){const e=new Date;return Pa(e.getFullYear(),e.getMonth()+1,e.getDate())}function us(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function Ec(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=us(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${cs[n-1]} ${r}`}function Cc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=Sc(),c=us(e||l),d=a==="popover",[u,m]=s.useState(!1),b=s.useRef(null),[f,p]=s.useState({horizontal:"left",vertical:"bottom"}),[g,k]=s.useState(c.year),[v,A]=s.useState(c.month),[E,M]=s.useState("days"),H=16,[S,x]=s.useState(0),C=g-7+S,w=Array.from({length:H},(G,U)=>C+U);s.useEffect(()=>{if(!d||!u||!b.current)return;const G=b.current.getBoundingClientRect(),U=8,Y=280,ue=340,L=G.left+Y>window.innerWidth-U,B=G.right-Y>=U,de=G.bottom+8+ue>window.innerHeight-U,I=G.top-8-ue>=U;p({horizontal:L&&B?"right":"left",vertical:de&&I?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function G(Y){b.current&&(b.current.contains(Y.target)||m(!1))}function U(Y){Y.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",G),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",U)}},[d,u]);function P(){v===1?(k(G=>G-1),A(12)):A(G=>G-1)}function V(){v===12?(k(G=>G+1),A(1)):A(G=>G+1)}const X=(new Date(g,v-1,1).getDay()+6)%7,O=new Date(g,v,0).getDate(),K=[...Array(X).fill(null),...Array.from({length:O},(G,U)=>U+1)];for(;K.length<ds*7;)K.push(null);const q=K.slice(0,ds*7);function le(G){const U=Pa(g,v,G);n&&U<n||(r(U),d&&m(!1))}const J=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:E==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:P,"aria-label":"Mes anterior",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{M("years"),x(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[cs[v-1]," ",g]}),t.jsx(W.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:V,"aria-label":"Mes siguiente",children:t.jsx(W.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(G=>G-H),"aria-label":"Años anteriores",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>M("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[w[0]," – ",w[w.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(G=>G+H),"aria-label":"Años siguientes",children:t.jsx(W.HiChevronRight,{size:16})})]})}),E==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Nc.map((G,U)=>{const Y=U+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${Y?" is-active":""}`,onClick:()=>A(U+1),children:G},G)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:w.map(G=>{const U=G===g,Y=G===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${U?" is-active":""}${Y&&!U?" is-today":""}`,onClick:()=>{k(G),M("days")},children:G},G)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:kc.map(G=>t.jsx("div",{className:"bonsaif-multi-weekday",children:G},G))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:q.map((G,U)=>{if(G===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},U);const Y=Pa(g,v,G),ue=Y===e,L=Y===l,B=!!(n&&Y<n);return t.jsx("div",{className:`bonsaif-multi-day${ue?" bonsaif-multi-day-selected":""}${L?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ue,onClick:()=>!B&&le(G),children:G})},U)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(G=>!G),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(W.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:Ec(e)})]}),t.jsx(W.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:J})]}):J}function Vt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Ft,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function _a(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function za(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Mc(e,r){if(!r.trim())return!0;const n=za(r);return za(e.label).includes(n)||!!(e.sublabel&&za(e.sublabel).includes(n))}function ur({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:b,dropdownMinWidth:f,dropdownZIndex:p=9999,height:g=40,padding:k="0 10px",searchable:v=!0,minOptionsForSearch:A=6}){const[E,M]=s.useState(!1),[H,S]=s.useState(""),[x,C]=s.useState(-1),[w,P]=s.useState(!1),[V,X]=s.useState({}),O=s.useRef(null),K=s.useRef(null),q=s.useRef(null),le=s.useRef(null),J=v&&n.length>=A,G=n.find($=>$.value===e)??null,U=l==="ghost",Y=a==="error"?"var(--danger)":E?"var(--primary)":"var(--border)",ue=J&&H.trim()?n.filter($=>Mc($,H)):n,L=s.useCallback(()=>{const $=O.current;if(!$)return;const ne=$.getBoundingClientRect(),te=J?272:212,j=window.innerHeight-ne.bottom,y=j<te&&ne.top>j;X({position:"fixed",left:ne.left,top:y?void 0:ne.bottom+4,bottom:y?window.innerHeight-ne.top+4:void 0,width:ne.width,minWidth:_a(f),zIndex:p})},[f,p,J]);s.useEffect(()=>P(!0),[]),s.useEffect(()=>{if(!E)return;function $(ne){var j,y;const te=ne.target;!((j=O.current)!=null&&j.contains(te))&&!((y=K.current)!=null&&y.contains(te))&&(M(!1),S(""))}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[E]),s.useEffect(()=>{E&&(C(-1),L(),J&&setTimeout(()=>{var $;return($=q.current)==null?void 0:$.focus()},0))},[E,J,L]),s.useEffect(()=>{if(E)return window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[E,L]),s.useEffect(()=>{if(x<0||!le.current)return;const $=le.current.children[x];$==null||$.scrollIntoView({block:"nearest"})},[x]);const B=s.useCallback($=>{r($),M(!1),S("")},[r]),de=s.useRef(E);de.current=E;const I=s.useRef(ue);I.current=ue;const oe=s.useRef(x);oe.current=x;const N=s.useRef(d);N.current=d;const R=s.useRef(B);R.current=B,s.useEffect(()=>{function $(ne){var T,ee;const te=document.activeElement,j=((T=O.current)==null?void 0:T.contains(te))??!1,y=((ee=K.current)==null?void 0:ee.contains(te))??!1;if(!(!j&&!y)){if(!de.current){(ne.key==="Enter"||ne.key===" "||ne.key==="ArrowDown")&&(ne.preventDefault(),M(!0));return}switch(ne.key){case"ArrowDown":ne.preventDefault(),C(fe=>Math.min(fe+1,I.current.length-1));break;case"ArrowUp":ne.preventDefault(),C(fe=>Math.max(fe-1,N.current?-1:0));break;case"Enter":{ne.preventDefault();const fe=oe.current,ie=I.current;fe===-1&&N.current?R.current(""):ie[fe]&&!ie[fe].disabled&&R.current(ie[fe].value);break}case"Escape":ne.preventDefault(),ne.stopPropagation(),M(!1),S("");break}}}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[]);const ae=t.jsxs("div",{ref:K,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...V,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[J&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:q,value:H,onChange:$=>{S($.target.value),C(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),H&&t.jsx("button",{type:"button",onMouseDown:$=>{$.preventDefault(),S("")},children:t.jsx(W.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:le,role:"listbox",className:"overflow-y-auto",style:{maxHeight:J?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:$=>{$.preventDefault(),B("")},onMouseEnter:()=>C(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:x===-1&&!H.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),ue.map(($,ne)=>{const j=ne===x,y=$.value===e;return t.jsxs("li",{role:"option","aria-selected":y,onMouseDown:T=>{T.preventDefault(),$.disabled||B($.value)},onMouseEnter:()=>!$.disabled&&C(ne),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:j?"var(--bg-hover)":y?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:$.disabled?"var(--text-muted)":"var(--text-main)",cursor:$.disabled?"not-allowed":"pointer",boxShadow:y?"inset 2px 0 0 var(--primary)":void 0},children:[$.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:$.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:$.label}),$.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:$.sublabel})]}),$.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:$.badge})]},$.value)}),ue.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:O,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&M($=>!$),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:_a(g),padding:_a(k),background:U?"transparent":"var(--bg-input)",color:G?"var(--text-main)":"var(--text-muted)",border:U?"1px solid transparent":`1px solid ${Y}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":E,"aria-label":o,children:[(G==null?void 0:G.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:G.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:G?t.jsxs(t.Fragment,{children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:G.label}),i&&G.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:G.sublabel})]}):t.jsx(Vt,{className:"min-w-0 flex-1",children:c})}),G&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:$=>{$.preventDefault(),$.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(W.HiXMark,{className:"w-3 h-3"})}):t.jsx(W.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:E?"rotate(180deg)":"rotate(0deg)"}})]}),E&&w&&pt.createPortal(ae,document.body)]})}const Tc={sm:"h-4 w-4",md:"h-5 w-5"};function $c(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Mn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=s.useRef(null);return s.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,$c(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${Tc[o]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${i}`}),t.jsx(W.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})}),fs=32767;function Tn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=fs?r:`${r.slice(0,fs-1)}…`}const $n=[25,50,100,200,500];let At={dataTable:{pageSizeOptions:[...$n]}};function Ac(){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 Wa(){const e=At.dataTable.preferencesEndpoint,r=Ac();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Lc(e){if(!Array.isArray(e))return[...$n];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:[...$n]}function bs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Dc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=bs(e.dataTable.preferencesEndpoint);At={...At,dataTable:{...At.dataTable,pageSizeOptions:Lc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??At.dataTable.preferencesEndpoint}}}function Oc(){return{dataTable:{pageSizeOptions:[...At.dataTable.pageSizeOptions]}}}function Jr(){return[...At.dataTable.pageSizeOptions]}function Hc(){At={dataTable:{pageSizeOptions:[...$n]}}}function Ic(e){At={...At,dataTable:{...At.dataTable,preferencesEndpoint:bs(e)}}}const An=[{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"}],Bc=An.map(e=>({value:e.value,label:e.label})),Fc=12,Pc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ms={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},_c="bonsaif-ui:datatable:",zc="[&_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",Wc=[],jc=52;function Yt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function hs(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 ps(e){return`${_c}${e}`}function Ln(e){try{const r=window.localStorage.getItem(ps(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function qc(e,r){try{window.localStorage.setItem(ps(e),JSON.stringify(r))}catch{}}function Uc(e,r){if(e===!0)return{...ms};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ms};const n={...Pc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function gs(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function ja(e,r,n){return typeof e!="number"||e<=0?n:nn(r).includes(e)?e:n}function Rr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function en(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=o.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function tn(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(An.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 xt(e,r){if(fr(e))return jc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Vc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function fr(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function qa(e){return e.sticky===!0}function vs(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Dn(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function Jt(e,r){const n=r.filter(qa).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 Yc(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 Rt(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 Xc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function Sr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Sr).join(" ").trim():s.isValidElement(e)?Sr(e.props.children):""}function On(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?Xc(n):Sr(n).trim()}function rn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Er(e,r){const n=rn(e),a=rn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function nn(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Jr()}function Kc(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=An.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return Er(e,a)>0;case"greaterThanOrEqual":return Er(e,a)>=0;case"lessThan":return Er(e,a)<0;case"lessThanOrEqual":return Er(e,a)<=0;case"between":return Er(e,a)>=0&&Er(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:rn(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(rn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=rn(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ys({children:e,className:r="",style:n}){return t.jsx(Ft,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function Ua({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:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:p,expandOnRowClick:g=!1,selected:k,onToggleOne:v,onToggleAll:A,getRowSelectable:E,highlightSelected:M=!0,rowClassName:H,getRowCategory:S,stickyHeader:x=!0,pageSize:C=25,pageSizeOptions:w,pageSizeSelectWidth:P=62,pageSizeSelectHeight:V=30,pageSizeSelectPadding:X="0 7px",totalRows:O,page:K,onPageChange:q,onPageSizeChange:le,storageKey:J,stickyFirstColumn:G=!1,bottomOffset:U=0,compact:Y=!0,restrictHeight:ue=!0,maxHeight:L,minTableWidth:B,enableColumnVisibility:de=!0,enableColumnFilters:I=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:N=Wc,onHiddenColumnKeysChange:R,columnVisibilityLabel:ae="Columnas",enableBql:$=!1,bqlValue:ne,defaultBqlValue:te="",onBqlChange:j,bqlDescription:y="Filtra registros con Bonsaif Query Language",bqlPlaceholder:T=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:ee=[],bqlExamples:fe=[],bqlSuggestions:ie=[],bqlActiveFilters:he,bqlError:Te,onQueryChange:De,persistState:ft,onPreferencesReady:Ct,enableExport:nt=!1,exportFilename:st="datos",onExportCsv:ce,onExportPdf:Se}){var Ri;const re=Uc(ft,J),Le=Object.values(re).some(Boolean),Oe=e.map(h=>h.key).join(","),Ve=N.join(","),je=s.useRef(e),Be=s.useRef(N);je.current=e,Be.current=N;const[et,ot]=s.useState(!J||!Le),Ht=s.useRef(null),be=s.useRef(!J),ge=s.useRef(!1),He=s.useRef(Ct);He.current=Ct;const We=s.useRef(!J||!Le?J??"__none__":null),Fe=oe!==void 0,[bt,ct]=s.useState(()=>Rt(N,e)),qe=Rt(Fe?oe:bt,e),[Ye,dt]=s.useState(!1),[mt,mr]=s.useState("filter"),[ut,ze]=s.useState(null),[vn,ba]=s.useState(""),[ht,Mt]=s.useState({}),[Tt,or]=s.useState({}),jr=b!==void 0,[z,Z]=s.useState(f),me=ne!==void 0,[pe,Ee]=s.useState(te),ye=me?ne:pe,[Pe,Ie]=s.useState(ye),[Ze,Qe]=s.useState(!1),[sr,vt]=s.useState(!1),[Kt,It]=s.useState(!1),[lr,Gt]=s.useState([]),qr=s.useRef(null),hr=s.useRef(null),jt=s.useRef(j);jt.current=j;const ma=s.useRef(C);ma.current=C;const ha=s.useRef(w);ha.current=w;const rm=Array.isArray(w)?w.join(","):"",Bo=s.useRef(null),ki=s.useRef(null),Fo=s.useRef(null),Si=s.useRef(0),[nm,am]=s.useState({}),[om,sm]=s.useState({}),[yn,pa]=s.useState(!1),Po=s.useRef(null),ga=s.useRef(null),[lm,im]=s.useState({}),Ei=s.useRef(null),va=s.useRef(null),[_o,Ci]=s.useState(r.length>0||a||c===!1),Mi=(h,D)=>50+(h*17+D*13+7)%40,ir=s.useRef(null),[cm,dm]=s.useState(void 0),[Ti,um]=s.useState(0),[fm,bm]=s.useState(!1);s.useEffect(()=>{function h(){bm(window.innerWidth<640)}if(!ue||L!==void 0)return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h);const Q=C!==!1?48:0,_=12;function se(){if(h(),!ir.current)return;const ve=ir.current.getBoundingClientRect().top;dm(Math.max(120,window.innerHeight-ve-Q-_-U))}return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[a,C,U,ue,L]);const $i=ue?L??cm:void 0;s.useEffect(()=>{const h=ir.current;if(!h)return;const D=()=>um(h.clientWidth);if(D(),typeof ResizeObserver>"u")return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D);const Q=new ResizeObserver(D);return Q.observe(h),()=>Q.disconnect()},[a,et,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){Ci(!0);return}if(_o)return;const h=window.setTimeout(()=>{Ci(!0)},c);return()=>window.clearTimeout(h)},[r.length,c,_o,a]);const[Ur,Vr]=s.useState(()=>Jt(e.map(h=>h.key),e)),[pr,Yr]=s.useState(()=>Object.fromEntries(e.map(h=>[h.key,xt(h,Yt(h.width))]))),[Je,gr]=s.useState(null),[mm,ya]=s.useState(1),[xa,wa]=s.useState(C===!1?0:C);s.useEffect(()=>{var Ae;const h=je.current,D=Be.current,Q=h.map(ke=>ke.key),_=new Set(Q),se=()=>{var ke;ge.current||(ge.current=!0,(ke=He.current)==null||ke.call(He))};if(!J||!Le){re.layout&&Vr(Jt(Q,h)),Fe||ct(Rt(D,h)),be.current=!1,ot(!0),se();return}let ve=!1;const Ce=We.current===J;Ce||(be.current=!1,ot(!1),ge.current=!1);const $e=Ln(J);if(hs($e)&&!Ce){const ke=$e,we=nn(ha.current??Jr()),Ne=ma.current,xr=Ne===!1?0:Ne,dr=re.layout?ke==null?void 0:ke.columnOrder:void 0,wr=Array.isArray(dr)?dr.filter(Xe=>Q.includes(Xe)):[],Nr=Jt(wr.length>0?Dn(wr,Q):Q,h),kr=Object.fromEntries(h.map(Xe=>[Xe.key,xt(Xe,Yt(Xe.width))])),Gr=re.layout?(ke==null?void 0:ke.columnWidths)??{}:{},kn=Object.fromEntries(h.map(Xe=>[Xe.key,xt(Xe,Gr[Xe.key]??kr[Xe.key])])),Zr=Rt(re.layout?(ke==null?void 0:ke.hiddenColumnKeys)??D:D,h);if(re.layout&&(Vr(Nr),Yr(kn)),Fe||ct(Zr),re.filters&&(Mt(en(ke==null?void 0:ke.filters,_)),or(tn(ke==null?void 0:ke.conditionFilters,_))),re.sort){const Xe=Rr(ke==null?void 0:ke.sort)?ke.sort:null;gr(Xe&&_.has(Xe.key)?Xe:null)}if(re.bql){if(qr.current!==J){qr.current=J;const Xe=typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:te;me?(Ae=jt.current)==null||Ae.call(jt,Xe):Ee(Xe)}Gt(Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory.filter(Xe=>typeof Xe=="string"):[])}re.pagination&&hr.current!==J&&(hr.current=J,wa(ja(ke==null?void 0:ke.pageSize,we,xr))),We.current=J,ot(!0),se()}const yt=`${Wa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(J)}`,rt=new AbortController,xe=window.setTimeout(()=>rt.abort(),2500);return fetch(yt,{cache:"no-store",signal:rt.signal}).then(ke=>ke.ok?ke.json():null).then(ke=>{var ec;if(ve)return;const we=Ln(J),Ne=gs(hs(ke==null?void 0:ke.settings)?ke==null?void 0:ke.settings:null,we),xr=nn(ha.current??Jr()),dr=ma.current,wr=dr===!1?0:dr,Nr=re.layout?Ne==null?void 0:Ne.columnOrder:void 0,kr=Array.isArray(Nr)?Nr.filter(at=>Q.includes(at)):[],Gr=Jt(kr.length>0?Dn(kr,Q):Q,h),kn=Object.fromEntries(h.map(at=>[at.key,xt(at,Yt(at.width))])),Zr=re.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},Xe=Object.fromEntries(h.map(at=>[at.key,xt(at,Zr[at.key]??kn[at.key])])),Qr=Rt(re.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??D:D,h);if(re.layout&&(Vr(Gr),Yr(Xe)),Fe||ct(Qr),re.filters&&(Mt(en(Ne==null?void 0:Ne.filters,_)),or(tn(Ne==null?void 0:Ne.conditionFilters,_))),re.sort){const at=Rr(Ne==null?void 0:Ne.sort)?Ne.sort:null;gr(at&&_.has(at.key)?at:null)}if(re.bql){if(qr.current!==J){qr.current=J;const at=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:te;me?(ec=jt.current)==null||ec.call(jt,at):Ee(at)}Gt(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(at=>typeof at=="string"):[])}let Re;re.pagination&&(Re=ja(Ne==null?void 0:Ne.pageSize,xr,wr),hr.current!==J&&(hr.current=J,wa(Re))),Ht.current=JSON.stringify({columnOrder:Gr,columnWidths:Xe,hiddenColumnKeys:Qr,filters:en(Ne==null?void 0:Ne.filters,_),conditionFilters:tn(Ne==null?void 0:Ne.conditionFilters,_),sort:Rr(Ne==null?void 0:Ne.sort)?Ne.sort:null,bql:typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:"",bqlHistory:Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory:[],pageSize:re.pagination&&dr!==!1?Re:void 0}),be.current=!0}).catch(()=>{var ke;if(!ve){const we=Ln(J),Ne=nn(ha.current??Jr()),xr=ma.current,dr=xr===!1?0:xr,wr=re.layout?we==null?void 0:we.columnOrder:void 0,Nr=Array.isArray(wr)?wr.filter(Re=>Q.includes(Re)):[],kr=Jt(Nr.length>0?Dn(Nr,Q):Q,h),Gr=Object.fromEntries(h.map(Re=>[Re.key,xt(Re,Yt(Re.width))])),kn=re.layout?(we==null?void 0:we.columnWidths)??{}:{},Zr=Object.fromEntries(h.map(Re=>[Re.key,xt(Re,kn[Re.key]??Gr[Re.key])]));re.layout&&(Vr(kr),Yr(Zr));const Xe=Rt(re.layout?(we==null?void 0:we.hiddenColumnKeys)??D:D,h);if(Fe||ct(Xe),re.filters&&(Mt(en(we==null?void 0:we.filters,_)),or(tn(we==null?void 0:we.conditionFilters,_))),re.sort){const Re=Rr(we==null?void 0:we.sort)?we.sort:null;gr(Re&&_.has(Re.key)?Re:null)}if(re.bql){if(qr.current!==J){qr.current=J;const Re=typeof(we==null?void 0:we.bql)=="string"?we.bql:te;me?(ke=jt.current)==null||ke.call(jt,Re):Ee(Re)}Gt(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(Re=>typeof Re=="string"):[])}let Qr;re.pagination&&(Qr=ja(we==null?void 0:we.pageSize,Ne,dr),hr.current!==J&&(hr.current=J,wa(Qr))),Ht.current=JSON.stringify({columnOrder:kr,columnWidths:Zr,hiddenColumnKeys:Xe,filters:en(we==null?void 0:we.filters,_),conditionFilters:tn(we==null?void 0:we.conditionFilters,_),sort:Rr(we==null?void 0:we.sort)?we.sort:null,bql:typeof(we==null?void 0:we.bql)=="string"?we.bql:"",bqlHistory:Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory:[],pageSize:re.pagination&&xr!==!1?Qr:void 0}),be.current=!0}}).finally(()=>{window.clearTimeout(xe),ve||(We.current=J,ot(!0),se())}),()=>{ve=!0,rt.abort(),window.clearTimeout(xe)}},[J,Le,Oe,Ve,Fe,re.layout,re.filters,re.sort,re.bql,re.pagination,me,te,rm]),s.useEffect(()=>{if(!J||!et||!Le||!be.current)return;const h={};re.layout&&(h.columnOrder=Ur,h.columnWidths=pr,h.hiddenColumnKeys=qe),re.filters&&(h.filters=ht,h.conditionFilters=Tt),re.sort&&(h.sort=Je),re.bql&&(h.bql=ye,h.bqlHistory=lr),re.pagination&&C!==!1&&(h.pageSize=xa);const D=Ln(J),Q=gs(D,h),_=JSON.stringify(Q);if(_===Ht.current)return;qc(J,Q),Ht.current=_;const se=window.setTimeout(()=>{const ve=Wa()??"/api/user/preferences/datatables";fetch(ve,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:J,settings:Q})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(se)},[Ur,pr,qe,ht,Tt,Je,ye,lr,xa,C,J,et,Le,re.layout,re.filters,re.sort,re.bql,re.pagination]),s.useEffect(()=>{Vr(h=>{const D=e.map(Q=>Q.key);return Jt(Dn(h,D),e)})},[Oe,e]);const Ai=Jt(Ur,e).map(h=>e.find(D=>D.key===h)).filter(h=>!!h),$t=Ai.filter(h=>!qe.includes(h.key)),Li=e.some(qa),hm=Object.keys(ht).length,pm=Object.keys(Tt).length,zo=hm+pm;function Di(h){const D=new Set;return r.reduce((Q,_)=>{const se=On(h,_);return!se||D.has(se)||(D.add(se),Q.push({value:se,label:se})),Q},[])}function gm(){const h=e.find(D=>D.key===ut);return h?Di(h):[]}function vm(h){return!!(I&&!fr(h)&&(h.filterValue||h.sortKey||Di(h).length>0))}function Oi(h,D){Mt(Q=>{const _={...Q};return _[h]=D,_})}function ym(h,D,Q,_){const se=ht[h]??[],ve=_?se:Q.filter($e=>$e!==D),Ce=_?se.includes(D)?se.filter($e=>$e!==D):[...se,D]:ve;Ce.length===Q.length?Wo(h):Oi(h,Ce)}function Wo(h){Mt(D=>{const Q={...D};return delete Q[h],Q})}function Na(h,D){or(Q=>{const _={...Q};return D?_[h]=D:delete _[h],_})}function Hi(h){Na(h,null)}function xm(){Mt({}),or({})}function wm(h){me||Ee(h),j==null||j(h)}function Ii(h){const D=h.trim();Ie(D),(j==null?void 0:j(D))!==!1&&(me||Ee(D),Qe(!1),vt(!1),It(!1),D&&Gt(_=>[D,..._.filter(se=>se!==D)].slice(0,Fc)))}function Bi(){Ie(""),wm(""),Qe(!1),vt(!1),It(!1)}function jo(h,D){Ie(h),D&&(D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,180)}px`)}function ka(h){const D=h.trim();if(!D)return;Si.current=Date.now()+500;const Q=Pe.replace(/\s+$/u,""),_=Q.length===0?D:Q.split(`
3
+ `).map(se=>se.trim()).includes(D)?Q:`${Q}
4
+ ${D}`;jo(_,Fo.current??void 0),requestAnimationFrame(()=>{const se=Fo.current;if(!se)return;se.focus();const ve=se.value.length;se.setSelectionRange(ve,ve),jo(se.value,se)})}s.useEffect(()=>{Ie(ye)},[ye]);const Sa=s.useCallback(()=>{const h=Bo.current;if(!h)return;const D=h.getBoundingClientRect(),Q=12,_=8,se=Math.min(780,Math.max(320,window.innerWidth-32)),ve=Math.max(Q,window.innerWidth-se-Q),Ce=Math.min(Math.max(Q,D.left),ve),$e=D.bottom+_,Ue=window.innerHeight-D.top+_,Ke=window.innerHeight-$e-Q,yt=D.top-Q-_,rt=Ke<280&&yt>Ke,xe=Math.max(240,rt?yt:Ke);am({position:"fixed",zIndex:1e4,left:Ce,top:rt?void 0:$e,bottom:rt?Ue:void 0,width:se,maxWidth:"calc(100vw - 24px)",maxHeight:xe,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ze)return;function h(_){var ve,Ce;if(Date.now()<Si.current)return;const se=_.target;(ve=Bo.current)!=null&&ve.contains(se)||(Ce=ki.current)!=null&&Ce.contains(se)||(Qe(!1),vt(!1),It(!1))}function D(_){_.key==="Escape"&&(Qe(!1),vt(!1),It(!1))}function Q(){Sa()}return Sa(),document.addEventListener("mousedown",h),window.addEventListener("keydown",D),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",D),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ze,Sa]);function Fi(h){const D=Rt(h,e);Fe||ct(D),R==null||R(D)}function Nm(h){Fi(qe.includes(h)?qe.filter(D=>D!==h):[...qe,h])}function km(){Fi([])}const qo=s.useCallback((h=va.current)=>{if(!h)return;const D=h.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),_=Math.max(8,window.innerWidth-Q-8),se=Math.min(Math.max(8,D.right-Q),_),ve=window.innerHeight-D.bottom,Ce=D.bottom+6,$e=window.innerHeight-D.top+6,Ke=ve<360&&D.top>ve?void 0:Ce,yt=Ke===void 0?$e:void 0,rt=Math.max(220,Ke===void 0?D.top-16:window.innerHeight-Ce-8),xe={position:"fixed",zIndex:9999,left:se,top:Ke,bottom:yt,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:rt,"--dt-column-menu-max-height":`${rt}px`};sm(xe)},[]);function Pi(h,D,Q=null){h.preventDefault(),h.stopPropagation();const _=va.current===h.currentTarget&&mt===D&&ut===Q;if(Ye&&_){dt(!1),ze(null);return}va.current=h.currentTarget,mr(D),ze(Q),ba(""),qo(h.currentTarget),dt(!0)}function Sm(h){if(fr(h))return;const D=ir.current;if(!D)return;const _=Array.from(D.querySelectorAll("[data-dt-column-key]")).filter(se=>se.dataset.dtColumnKey===h.key).reduce((se,ve)=>{const Ce=ve.querySelector("[data-dt-autofit-content]"),$e=Ce?Ce.scrollWidth:Math.max(ve.scrollWidth,ve.offsetWidth);return Math.max(se,Math.ceil($e+Vc(ve)))},0);_<=0||Yr(se=>({...se,[h.key]:xt(h,_+12)}))}s.useEffect(()=>{Yr(h=>{const D=Object.fromEntries(e.map(Q=>[Q.key,xt(Q,Yt(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,xt(Q,h[Q.key]??D[Q.key])]))})},[Oe,e]),s.useEffect(()=>{Fe||ct(h=>Rt(h,e))},[Oe,e,Fe]),s.useEffect(()=>{function h(_){var Ce,$e;const se=_.target,ve=_.target;ve!=null&&ve.closest("[data-bonsaif-select-dropdown='true']")||!((Ce=Ei.current)!=null&&Ce.contains(se))&&!(($e=va.current)!=null&&$e.contains(se))&&(dt(!1),ze(null))}function D(_){_.key==="Escape"&&(dt(!1),ze(null))}function Q(){qo()}return Ye&&(document.addEventListener("mousedown",h),window.addEventListener("keydown",D),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",D),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ye,qo]);const xn=s.useRef(null);s.useEffect(()=>{function h(Q){const _=xn.current;if(!_)return;const se=Q.clientX-_.startX,ve=e.find(Ce=>Ce.key===_.colKey);ve&&Yr(Ce=>({...Ce,[_.colKey]:xt(ve,_.startWidth+se)}))}function D(){xn.current&&(xn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",h),document.addEventListener("pointerup",D),()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",D)}},[e]);const wn=s.useRef(null),[_i,Uo]=s.useState(null);function Em(h,D){const Q=e.find(_=>_.key===h);if(!Q||!vs(Q)){D.preventDefault();return}wn.current=Ur.indexOf(h),D.dataTransfer.effectAllowed="move"}function Cm(h,D){D.preventDefault(),D.dataTransfer.dropEffect="move";const Q=Ur.indexOf(h);_i!==Q&&Uo(Q)}function Mm(h,D){D.preventDefault();const Q=wn.current,_=Ur.indexOf(h);Q!==null&&Q!==_&&Vr(se=>{const ve=[...se],[Ce]=ve.splice(Q,1);return ve.splice(_,0,Ce),Jt(ve,e)}),wn.current=null,Uo(null)}function Tm(){wn.current=null,Uo(null)}function $m(h){h.sortKey&&gr(D=>(D==null?void 0:D.key)===h.key?{key:h.key,dir:D.dir==="asc"?"desc":"asc"}:{key:h.key,dir:"asc"})}s.useEffect(()=>{ya(1)},[r]),s.useEffect(()=>{ya(1)},[Tt,ht]);const qt=!!(q&&le),cr=C!==!1,Vo=s.useMemo(()=>nn(w??Jr()),[w]),it=qt?K??1:mm,zi=cr&&xa<1?typeof C=="number"&&C>0?C:Vo[0]??25:xa,Ut=qt||cr?zi:r.length,Bt=!!k&&!!v&&!!A,Yo=s.useMemo(()=>E?r.filter(h=>E(h)):r,[r,E]),Xr=!!u,Wi=s.useMemo(()=>new Set(jr?Array.from(b??[]):z),[jr,b,z]),Am=(Xr?40:0)+(Bt?40:0),Xo=!fm&&(Li||G),Ea=(()=>{if(!Xo)return{};let h=Am;const D={};return $t.forEach((Q,_)=>{(qa(Q)||!Li&&G&&_===0)&&(D[Q.key]=h,h+=pr[Q.key]??xt(Q,Yt(Q.width)))}),D})(),Ko=Object.keys(Ea),Go=Ko.length>0?Ko[Ko.length-1]:null,ji=Bt&&Yo.length>0&&Yo.every(h=>k.has(n(h))),Lm=Bt&&k.size>0&&Yo.some(h=>k.has(n(h)))&&!ji,Ca=s.useMemo(()=>{if(qt)return r;const h=Object.entries(ht),D=Object.entries(Tt);return h.length===0&&D.length===0?r:r.filter(Q=>h.every(([_,se])=>{const ve=e.find(Ce=>Ce.key===_);return ve?se.includes(On(ve,Q)):!0})&&D.every(([_,se])=>{const ve=e.find($e=>$e.key===_);if(!ve)return!0;const Ce=r.map($e=>On(ve,$e));return Kc(On(ve,Q),se,Ce)}))},[Tt,ht,e,r,qt]),vr=s.useMemo(()=>{if(!Je)return Ca;const h=e.find(D=>D.key===Je.key&&D.sortKey);return h!=null&&h.sortKey?[...Ca].sort((D,Q)=>{const _=D[h.sortKey],se=Q[h.sortKey],ve=_===se?0:_==null?1:se==null||_<se?-1:1;return Je.dir==="asc"?ve:-ve}):Ca},[Ca,Je,e]),qi=s.useMemo(()=>{if(qt||!cr)return vr;const h=(it-1)*Ut;return vr.slice(h,h+Ut)},[vr,qt,cr,it,Ut]),Zt=qt?O??r.length:vr.length,Zo=cr?Math.max(1,Math.ceil(Zt/Ut)):1,Dm=Math.min(...Vo),Om=cr&&(Zt>Ut||Zt>Dm),Hm=cr?(it-1)*Ut+1:1,Im=cr?Math.min(it*Ut,Zt):Zt;function Qo(h){if(a)return;const D=Math.max(1,Math.min(h,Zo));qt?q(D):ya(D)}function Bm(h){a||(J&&(hr.current=J),wa(h),qt?(le(h),q(1)):(ya(1),le==null||le(h)))}function Ui(h){const D=new Set(Wi);D.has(h)?D.delete(h):D.add(h);const Q=Array.from(D);jr||Z(Q),p==null||p(Q)}s.useEffect(()=>{De==null||De({bql:ye,filters:ht,conditionFilters:Tt,sort:Je,page:it,pageSize:Ut,hiddenColumnKeys:qe})},[ye,ht,Tt,Je,it,Ut,qe,De]);const Vi=h=>h==="center"?"justify-center text-center":h==="right"?"justify-end text-right":"justify-start text-left",Fm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Jo="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%)",_e="color-mix(in srgb, var(--border) 62%, var(--bg-card))",yr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ma=`inset 0 0 0 1px ${_e}`,Yi=$t.reduce((h,D)=>h+(pr[D.key]??Yt(D.width)),(Xr?40:0)+(Bt?40:0)),Xi=typeof B=="number"?B:typeof B=="string"?Number(((Ri=B.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ri[1])??NaN):NaN,Nn=Number.isFinite(Xi)?Math.max(Yi,Xi,Ti):Math.max(Yi,Ti),Ta=B??Nn,Kr=`${Xr?"40px ":""}${Bt?"40px ":""}${$t.map(h=>`${pr[h.key]??Yt(h.width)}px`).join(" ")}`;s.useEffect(()=>{Je&&qe.includes(Je.key)&&gr(null)},[qe,Je]);function Ki(h){return h?typeof h=="string"?{key:h,label:h}:h:null}const $a=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,background:Jo,borderBottom:`1px solid ${yr}`},children:[Xr&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`}}),Bt&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Xo?{position:"sticky",left:0,zIndex:12,background:Jo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`},children:t.jsx(Mn,{size:"sm",checked:ji,indeterminate:Lm,onChange:A,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),$t.map((h,D)=>{const Q=(Je==null?void 0:Je.key)===h.key,_=!!h.sortKey,se=fr(h),ve=Ea[h.key],Ce=ve!==void 0,$e=h.key===Go,Ue=vs(h),Ke=_i===D,rt=(pr[h.key]??Yt(h.width))<120,xe=Object.prototype.hasOwnProperty.call(ht,h.key)||Object.prototype.hasOwnProperty.call(Tt,h.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":h.key,className:`group select-none ${rt?"text-left":Vi(h.align)}`,style:{...Ce?{position:"sticky",left:ve,zIndex:12,background:Jo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${yr}`:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${_e}`}:{position:"relative",borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ke?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:se?Y?"7px 6px":"9px 8px":Y?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ae=>{(Ue||wn.current!==null)&&Cm(h.key,Ae)},onDrop:Ae=>Mm(h.key,Ae),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${se?"justify-center":rt?"justify-start":h.align==="center"?"justify-center":h.align==="right"?"justify-end":"justify-start"}`,children:[Ue?t.jsx("span",{draggable:!0,onDragStart:Ae=>{Ae.stopPropagation(),Em(h.key,Ae)},onDragEnd:Ae=>{Ae.stopPropagation(),Tm()},onClick:Ae=>Ae.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${Ke?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,se?t.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:t.jsx(W.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(ys,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${Y?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:h.header})})}),_&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(h.header)}`,title:"Ordenar",onClick:Ae=>{Ae.stopPropagation(),$m(h)},"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?Je.dir==="asc"?t.jsx(W.HiChevronUp,{className:"h-3 w-3"}):t.jsx(W.HiChevronDown,{className:"h-3 w-3"}):t.jsx(W.HiChevronUpDown,{className:"h-3 w-3"})}),I&&!se&&vm(h)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&ut===h.key,"aria-label":`Filtrar ${String(h.header)}`,title:"Filtrar",onClick:Ae=>Pi(Ae,"filter",h.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 ${Ye&&mt==="filter"&&ut===h.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":xe?"text-[var(--primary)] opacity-100":""}`,children:xe?t.jsx(W.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(W.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!se&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),xn.current={colKey:h.key,startX:Ae.clientX,startWidth:pr[h.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),xn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Sm(h)},onClick:Ae=>Ae.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},h.key)})]}),Aa=()=>{if(!Ye||typeof document>"u"||mt==="visibility"&&!de||mt==="filter"&&!I)return null;const h=e.find(xe=>xe.key===ut),D=gm(),Q=h?Object.prototype.hasOwnProperty.call(ht,h.key):!1,_=h?Tt[h.key]:void 0,se=An.find(xe=>xe.value===(_==null?void 0:_.operator)),ve=h?ht[h.key]??[]:[],Ce=vn.trim().toLowerCase(),$e=Ce?D.filter(xe=>xe.label.toLowerCase().includes(Ce)):D,Ue=h&&D.length>0&&(!Q||ve.length===D.length),Ke=h&&Q&&ve.length>0&&ve.length<D.length,yt=qe.length,rt=()=>{h&&(Wo(h.key),Hi(h.key))};return pt.createPortal(t.jsx("div",{ref:Ei,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...om,borderColor:"var(--border)",background:"var(--bg-card)"},children:mt==="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:yt>0?`${$t.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:km,disabled:yt===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:Ai.map(xe=>{const Ae=!qe.includes(xe.key),we=!(xe.hideable!==!1)||Ae&&$t.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,disabled:we,onClick:()=>Nm(xe.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.header})]},xe.key)})})]}):h?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 ",h.header]}),t.jsx("button",{type:"button",onClick:rt,disabled:!Q&&!_,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"})]}),h.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:()=>gr({key:h.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(W.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Je==null?void 0:Je.key)===h.key&&Je.dir==="asc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>gr({key:h.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(W.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Je==null?void 0:Je.key)===h.key&&Je.dir==="desc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(ur,{value:(_==null?void 0:_.operator)??"",onChange:xe=>{if(!xe){Hi(h.key);return}Na(h.key,{operator:xe,value:(_==null?void 0:_.value)??"",valueTo:(_==null?void 0:_.valueTo)??""})},options:Bc,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"}),(se==null?void 0:se.valueMode)!=="none"?t.jsx("input",{value:(_==null?void 0:_.value)??"",onChange:xe=>{_&&Na(h.key,{..._,value:xe.target.value})},disabled:!_,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"})]}),(se==null?void 0:se.valueMode)==="between"&&t.jsx("input",{value:(_==null?void 0:_.valueTo)??"",onChange:xe=>{_&&Na(h.key,{..._,valueTo:xe.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:vn,onChange:xe=>ba(xe.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ke?"mixed":!!Ue,onClick:()=>{h&&(Ue&&!Q?Oi(h.key,[]):Wo(h.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:Ue||Ke?"var(--primary)":"var(--border)",background:Ue||Ke?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ke&&t.jsx(W.HiMinus,{className:"h-3 w-3"}),Ue&&!Ke&&t.jsx(W.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(xe=>{const Ae=!Q||ve.includes(xe.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,onClick:()=>ym(h.key,xe.value,D.map(ke=>ke.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:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.label})]},xe.value)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!yn)return;function h(D){Po.current&&!Po.current.contains(D.target)&&ga.current&&!ga.current.contains(D.target)&&pa(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[yn]);function Gi(h,D){if(h.filterValue){const Q=h.filterValue(D);return Q==null||Q===""?"":Tn(Q)}return Tn(Sr(h.cell(D)))}function Zi(h){return`"${Tn(h).replace(/"/g,'""')}"`}function La(h){return Tn(h).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Qi(){return qt&&Zt>vr.length&&Ia.toast.warning(`Exportando ${vr.length.toLocaleString("es-MX")} de ${Zt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),vr}function Pm(){const h=$t.filter(Ue=>!fr(Ue)),D=Qi(),Q=h.map(Ue=>Zi(Sr(Ue.header))).join(","),_=D.map(Ue=>h.map(Ke=>Zi(Gi(Ke,Ue))).join(",")).join(`
5
+ `),se=`${Q}
6
+ ${_}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createObjectURL(ve),$e=document.createElement("a");$e.href=Ce,$e.download=`${st}.csv`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Ce)}function _m(){const h=$t.filter($e=>!fr($e)),D=Qi(),Q=h.map($e=>La(Sr($e.header))),se=D.map($e=>h.map(Ue=>La(Gi(Ue,$e)))).map($e=>`<tr>${$e.map(Ue=>`<td>${Ue}</td>`).join("")}</tr>`).join(""),ve=`<!DOCTYPE html>
7
7
  <html lang="es"><head><meta charset="utf-8"><title>${La(st)}</title>
8
8
  <style>
9
9
  body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
@@ -16,23 +16,23 @@ ${_}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
16
16
  @media print{body{margin:0}@page{margin:1cm}}
17
17
  </style></head><body>
18
18
  <h3>${La(st)}</h3>
19
- <p>${A.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
- <table><thead><tr>${J.map($e=>`<th>${$e}</th>`).join("")}</tr></thead>
19
+ <p>${D.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
+ <table><thead><tr>${Q.map($e=>`<th>${$e}</th>`).join("")}</tr></thead>
21
21
  <tbody>${se}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,Ce=window.open("","_blank");Ce&&(Ce.document.write(ve),Ce.document.close())}const Da=()=>!nt||!yn?null:pt.createPortal(t.jsxs("div",{ref:Po,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...lm,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(le?await le():Pm(),pa(!1)))()},children:[t.jsx(j.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(Se?await Se():_m(),pa(!1)))()},children:[t.jsx(j.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Oa=()=>{const h=I&&ye.trim().length>0,A=he!=null&&he.length?he:h?[{key:"bql",label:"BQL",value:ye}]:[],J=ie.filter(_=>{const se=_.trim();return se?!new Set(Pe.split(`
24
- `).map(Ce=>Ce.trim()).filter(Boolean)).has(se):!1}).slice(0,8);return!ce&&zo===0&&!I&&!nt?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[zo>0&&t.jsxs("button",{type:"button",onClick:xm,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(j.HiXMark,{className:"h-3.5 w-3.5"}),zo," filtros"]}),I&&t.jsxs("div",{ref:Bo,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ze){Qe(!1);return}Sa(),Qe(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:Ze?"var(--primary)":h?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||h?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[t.jsx(j.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",h&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:y}),A.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[A.slice(0,3).map(_=>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:[_.label,":"]}),t.jsx("span",{className:"truncate",children:_.value})]},_.key)),A.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",A.length-3]})]}),h&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Bi,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(j.HiXMark,{className:"h-4 w-4"})}),Ze&&pt.createPortal(t.jsxs("div",{ref:ki,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...nm,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:[ee.map(_=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_.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:[_.icon,_.label]},_.label)),fe.length>0&&t.jsxs("button",{type:"button",onClick:()=>vt(_=>!_),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":sr,children:[t.jsx(j.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),lr.length>0&&t.jsxs("button",{type:"button",onClick:()=>It(_=>!_),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":Kt,children:[t.jsx(j.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Te?"var(--danger)":h?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Fo,value:Pe,rows:3,onChange:_=>jo(_.target.value,_.target),onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Ii(Pe)),_.key==="Escape"&&Qe(!1)},placeholder:$,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"}}),J.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:J.map(_=>t.jsx("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_)},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:_},_))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Te?"var(--danger)":"var(--text-muted)"},children:Te??(h?`${A.length||1} filtro${(A.length||1)===1?"":"s"} activo${(A.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),A.map(_=>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:[_.label,":"]}),t.jsx("span",{className:"truncate",children:_.value})]},_.key))]}),Kt&&lr.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(j.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Gt([]),It(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(j.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),lr.map(_=>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:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:_})}),t.jsx("button",{type:"button",onClick:()=>Gt(se=>se.filter(ve=>ve!==_)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"})})]},_))]}),sr&&fe.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:fe.map(_=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_.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:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:_.bql}),_.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:_.description})]},_.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[h&&t.jsxs("button",{type:"button",onClick:Bi,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(j.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ii(Pe),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(j.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),nt&&t.jsx("button",{ref:ga,type:"button","aria-haspopup":"menu","aria-expanded":yn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var se;const _=(se=ga.current)==null?void 0:se.getBoundingClientRect();_&&im({top:_.bottom+4,right:window.innerWidth-_.right}),pa(ve=>!ve)},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)] ${yn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiArrowDownTray,{className:"h-4 w-4"})}),ce&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&mt==="visibility","aria-label":z,title:z,onClick:_=>Pi(_,"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)] ${Ye&&mt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ji=()=>{if(!Om)return null;const h=Yc(it,Zo);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${Y?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Zt===0?"0 filas":`${Hm}–${Im} de ${Zt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(ur,{value:String(Ut),onChange:A=>Bm(Number(A)),options:Vo.map(A=>({value:String(A),label:String(A)})),placeholder:"Filas",searchable:!1,disabled:a,height:X,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:P}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||it<=1,onClick:()=>Qo(it-1),onMouseEnter:A=>{A.currentTarget.disabled||(A.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",A.currentTarget.style.color="var(--primary)")},onMouseLeave:A=>{A.currentTarget.style.background="transparent",A.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(j.HiChevronLeft,{className:"h-3.5 w-3.5"})}),h.map((A,J)=>A==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${J}`):t.jsx("button",{disabled:a,onClick:()=>Qo(A),onMouseEnter:_=>{_.currentTarget.disabled||A===it||(_.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",_.currentTarget.style.color="var(--primary)")},onMouseLeave:_=>{_.currentTarget.style.background=A===it?"var(--primary)":"transparent",_.currentTarget.style.color=A===it?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:A===it?"var(--primary)":"transparent",color:A===it?"var(--primary-fg)":"var(--text-muted)"},children:A},A)),t.jsx("button",{disabled:a||it>=Zo,onClick:()=>Qo(it+1),onMouseEnter:A=>{A.currentTarget.disabled||(A.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",A.currentTarget.style.color="var(--primary)")},onMouseLeave:A=>{A.currentTarget.style.background="transparent",A.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(j.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},zm=()=>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:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((h,A)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${_e}`},children:[Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},"select-cell"),$t.map((J,_)=>t.jsx("div",{role:"cell",className:Y?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Mi(A,_)}%`,minWidth:32}})},J.key))]},A))})]})})]}),Ro="min-w-0 max-w-full overflow-hidden";return Q&&Le&&!et?t.jsx(Cn,{rows:o,columns:Math.max(4,$t.length||7)}):!a&&r.length===0&&!_o?zm():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:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx(es.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:$i,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((h,A)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${_e}`},children:[Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},"select-cell"),$t.map((J,_)=>{const se=Ea[J.key],ve=se!==void 0,Ce=J.key===Go;return t.jsx("div",{role:"cell","data-dt-column-key":J.key,className:Y?"px-2 py-1.5":"px-3 py-2",style:ve?{position:"sticky",left:se,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${_e}`:`inset 0 -1px 0 ${_e}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Mi(A,_)}%`,minWidth:32}})},J.key)})]},A))})]})})}),Ji()]}):!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:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()})})}),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:_e,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(j.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:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx(es.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:$i,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:qi.map((h,A)=>{const J=n(h),_=Ki(N==null?void 0:N(h)),se=A>0?Ki(N==null?void 0:N(qi[A-1])):null,ve=_&&_.key!==(se==null?void 0:se.key),Ce=Bt&&S.has(J),$e=Bt&&(!T||T(h)),Ue=Xr?(m==null?void 0:m(h))??!0:!1,Ke=Ue&&Wi.has(J),yt=!!d||p&&Ue,rt=Ce&&E?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":A%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[ve&&t.jsx("div",{role:"row",className:`grid ${_.className??""}`,style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},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:_.label}),_.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:_.description})]})})})}),t.jsxs("div",{role:"row",onClick:yt?xe=>{const Ae=xe.target;if(!(Ae!=null&&Ae.closest('[data-dt-disable-row-click="true"]'))){if(p&&Ue){Ui(J);return}d==null||d(h)}}:void 0,className:`grid transition-colors ${yt?"cursor-pointer":""} ${O?O(h):""}`,style:{gridTemplateColumns:Kr,"--dt-row-bg":rt,"--dt-sticky-bg":rt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${_e}`},onMouseEnter:xe=>{Ce||(xe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),xe.currentTarget.style.setProperty("--dt-sticky-bg",Fm))},onMouseLeave:xe=>{xe.currentTarget.style.setProperty("--dt-row-bg",rt),xe.currentTarget.style.setProperty("--dt-sticky-bg",rt)},children:[Xr&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},"data-dt-disable-row-click":"true",children:Ue&&t.jsx("button",{type:"button","aria-label":Ke?"Contraer fila":"Desplegar fila","aria-expanded":Ke,onClick:xe=>{xe.stopPropagation(),Ui(J)},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:Ke?t.jsx(j.HiChevronDown,{className:"h-4 w-4"}):t.jsx(j.HiChevronRight,{className:"h-4 w-4"})})}),Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Xo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},onClick:xe=>{xe.stopPropagation(),$e&&v(J)},children:t.jsx(Mn,{size:"sm",checked:Ce,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:xe=>xe.stopPropagation(),onChange:()=>{$e&&v(J)}})}),$t.map(xe=>{const Ae=Ea[xe.key],ke=Ae!==void 0,we=xe.key===Go,Ne=fr(xe);return t.jsx("div",{role:"cell","data-dt-column-key":xe.key,"data-dt-disable-row-click":xe.disableRowClick||Ne?"true":void 0,className:`${Ne?"px-2 py-1.5 justify-center text-center":`${Y?"px-2 py-1.5":"px-3 py-2"} ${Vi(xe.align)}`} flex min-w-0 items-center ${zc} ${xe.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...ke?{position:"sticky",left:Ae,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${_e}`:`inset 0 -1px 0 ${_e}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},children:t.jsx(ys,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:xe.cell(h)})})},xe.key)})]}),Ke&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${_e}`},children:u(h)})})]},J)})})]})})}),Ji()]})}const Gc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Hn({title:e="Sin resultados",description:r,icon:n=t.jsx(j.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 ${Gc[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||o)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}function Pt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function xs(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function Cr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function er(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function ws(e){const r=Cr(e),n=(r.getDay()+6)%7;return er(r,-n)}function Va(e){const r=ws(e);return Array.from({length:7},(n,a)=>er(r,a))}function Ns(e){const r=e.getDay();return r===0||r===6}function In(e){return e.filter(r=>!Ns(r))}function ks(e){return In(Va(e))}function Zc(e){const r=Cr(e),n=r.getDay();return n===6?er(r,-1):n===0?er(r,-2):r}function Ya(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=ws(r);return Array.from({length:42},(a,o)=>er(n,o))}function Xa(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Ss(e){return Xa(e).map(In)}function Qc(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function tr(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=xs(n.start);if(!a)return null;const o=xs(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function Es(e,r){const n={};for(const a of e){const o=tr(a,r);if(!o)continue;let l=Cr(o.start);const i=Cr(o.end);for(;l.getTime()<=i.getTime();){const c=Pt(l);n[c]||(n[c]=[]),n[c].push(a),l=er(l,1)}}return n}function Ka(e,r,n){if(r.length===0)return[];const a=Cr(r[0]),o=Cr(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const m=tr(d,n),b=tr(u,n),f=(m==null?void 0:m.start.getTime())??0,g=(b==null?void 0:b.start.getTime())??0;return f-g||d.title.localeCompare(u.title)});for(const d of c){const u=tr(d,n);if(!u||!Qc(u.start,u.end,a,o))continue;const m=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((m.getTime()-a.getTime())/864e5)),g=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),p=Math.max(1,g-f+1);let S=l.findIndex(v=>v<f);S<0?(S=l.length,l.push(f+p-1)):l[S]=f+p-1,i.push({item:d,lane:S,colStart:f,colSpan:p})}return i}function Lt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Jc(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Rc(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Cs(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ms(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?er(e,n*7):er(e,n)}const ed=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],Ts=["Lun","Mar","Mié","Jue","Vie"];function td({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=tr(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Ft,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function rd({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=tr(e),l=o?`${Lt(o.start)} → ${Lt(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function nd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=tr(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function $s({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function As({value:e,options:r,onChange:n}){return t.jsx("div",{className:"inline-flex overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:r.map((a,o)=>{const l=e===a.value;return t.jsxs("button",{type:"button",onClick:()=>n(a.value),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold transition-colors",style:{background:l?"var(--primary)":"var(--bg-card)",color:l?"var(--primary-fg, #fff)":"var(--text-secondary)",borderRight:o<r.length-1?"1px solid var(--border)":void 0},children:[a.icon,a.label]},a.value)})})}function ad({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:m,hideWeekends:b=!1,renderToolbarExtra:f,renderPill:g,renderDayCard:p,renderWeekBar:S,tableColumns:v,tableProps:C,onItemClick:T,onDayClick:E,loading:O=!1,emptyTitle:N="Sin eventos",emptyDescription:x="No hay eventos para los filtros seleccionados.",legend:M,legendInteractive:w=!0,activeLegendKeys:P,defaultActiveLegendKeys:X,onActiveLegendKeysChange:K,getItemLegendKey:D,overloadLabel:G="Sobrecarga de eventos",notice:U,showOverload:ae=!0,layout:Q="span",className:R="",showToolbar:V=!0}){const Y=m??(b?[...Ts]:[...ed]),ue=b?5:7,L=b?"grid grid-cols-5":"grid grid-cols-7",B=s.useMemo(()=>(M??[]).map(le=>le.label),[M]),[ce,H]=s.useState(()=>X??B),oe=s.useMemo(()=>P??(B.length>0?ce:[]),[P,B.length,ce]),k=s.useMemo(()=>new Set(oe),[oe]),te=le=>{P===void 0&&H(le),K==null||K(le)},z=le=>{w&&(k.has(le)?te(oe.filter(Se=>Se!==le)):te([...oe,le]))},I=s.useMemo(()=>{if(!w||B.length===0)return e;const le=new Set(B);return e.filter(Se=>{const ne=(D==null?void 0:D(Se))??Se.status;return!ne||!le.has(ne)?!0:k.has(ne)})},[e,w,B,k,D]),de=s.useMemo(()=>Es(I,c),[I,c]),re=s.useMemo(()=>{const le=Ya(r);return b?In(le):le},[r,b]),q=s.useMemo(()=>{const le=Ya(r);return b?Ss(le):Xa(le)},[r,b]),y=s.useMemo(()=>b?ks(r):Va(r),[r,b]),$=Pt(r),ee=de[$]??[],fe=s.useMemo(()=>Ka(I,y,c),[I,y,c]),ie=s.useMemo(()=>fe.length===0?1:Math.max(...fe.map(le=>le.lane))+1,[fe]),he=s.useMemo(()=>q.map(le=>{const Se=Ka(I,le,c),ne=Se.length===0?0:Math.max(...Se.map(Le=>Le.lane))+1;return{days:le,bars:Se,laneCount:ne}}),[q,I,c]),Te=36,De=38,ft=s.useMemo(()=>{const le=l==="month"?re:l==="week"?y:[r],Se=[];for(const ne of le){const Le=Pt(ne),Oe=de[Le]??[];Oe.length>=u&&Se.push([ne,Oe])}return Se},[l,re,y,r,de,u]),Ct=l==="month"?Jc(r):l==="week"?`${Lt(y[0])} – ${Lt(y[6])}`:Rc(r),nt=s.useMemo(()=>[{key:"title",header:"Título",cell:le=>le.title},{key:"status",header:"Estado",cell:le=>le.status??"—"},{key:"range",header:"Rango",cell:le=>{const Se=tr(le,c);return Se?`${Lt(Se.start)} → ${Lt(Se.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:le=>le.subtitle??"—"}],[c]),st=le=>{if(n(le),E){E(le);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${R}`.trim(),children:[V?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":"Anterior",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ms(r,l,-1)),children:t.jsx(j.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:Ct}),t.jsx("button",{type:"button","aria-label":"Siguiente",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ms(r,l,1)),children:t.jsx(j.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f,t.jsx(As,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(j.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(j.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(As,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,M&&M.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:w?"group":void 0,"aria-label":w?"Filtrar por estado":void 0,children:M.map(le=>{const Se=k.has(le.label);return w?t.jsxs("button",{type:"button","aria-pressed":Se,onClick:()=>z(le.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Se?"var(--text-main)":"var(--text-muted)",background:Se?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Se?`1px solid color-mix(in srgb, ${le.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Se?1:.45},title:Se?`Ocultar “${le.label}”`:`Mostrar “${le.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:le.color,boxShadow:Se?`0 0 0 2px color-mix(in srgb, ${le.color} 25%, transparent)`:void 0},"aria-hidden":!0}),le.label]},le.label):t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:le.color},"aria-hidden":!0}),le.label]},le.label)})}):null,a==="calendar"&&U&&U.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:U.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[U.label,":"]})," ",U.items.join(", ")]}):a==="calendar"&&ae&&ft.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[G,":"]})," ",ft.map(([le,Se])=>`${Lt(le)} (${Se.length})`).join(", ")]}):null,a==="table"?O||I.length>0?t.jsx(Ua,{columns:v??nt,data:I,getRowId:le=>le.id,loading:O,skeletonRows:8,emptyIcon:t.jsx(j.HiCalendarDays,{className:"h-10 w-10"}),emptyText:x,onRowClick:T,pageSize:25,compact:!0,...C}):t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:N,description:x}):null,a==="calendar"&&l==="month"&&Q==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:L,style:{borderBottom:"1px solid var(--border)"},children:Y.map(le=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:le},le))}),t.jsx("div",{className:L,children:re.map(le=>{const Se=Pt(le),ne=de[Se]??[],Le=le.getMonth()!==r.getMonth(),Oe=Math.max(0,ne.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${le.getDate()}`,onClick:()=>st(le),onKeyDown:Ve=>{(Ve.key==="Enter"||Ve.key===" ")&&(Ve.preventDefault(),st(le))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Le?"var(--text-muted)":"var(--text-main)"},children:le.getDate()}),ne.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ne.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[ne.slice(0,d).map(Ve=>t.jsx($s,{item:Ve,day:le,renderPill:g,onClick:()=>T==null?void 0:T(Ve)},Ve.id)),Oe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Oe," más"]}):null]})]},Se)})})]}):null,a==="calendar"&&l==="month"&&Q==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:L,style:{borderBottom:"1px solid var(--border)"},children:Y.map(le=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:le},le))}),he.map(({days:le,bars:Se,laneCount:ne},Le)=>{const Oe=Math.min(ne,d),Ve=Math.max(0,ne-d),je=Te+Math.max(1,Oe)*De+(Ve>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:je,borderBottom:Le<he.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:L,style:{minHeight:je},children:le.map(Be=>{const et=Pt(Be),ot=de[et]??[],Ht=Be.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Be.getDate()}`,onClick:()=>st(Be),onKeyDown:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),st(Be))},className:"cursor-pointer p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",minHeight:je},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Ht?"var(--text-muted)":"var(--text-main)"},children:Be.getDate()}),ot.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ot.length}):null]})},et)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:Te,bottom:4},children:[Se.filter(Be=>Be.lane<d).map(Be=>{const et={left:`calc(${Be.colStart/ue*100}% + 4px)`,width:`calc(${Be.colSpan/ue*100}% - 8px)`,top:2+Be.lane*De,height:De-6,pointerEvents:"auto"};return g?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:g(Be.item,{day:le[Be.colStart]})})},`${Be.item.id}-${Be.colStart}-${Le}`):S?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:S(Be.item)})},`${Be.item.id}-${Be.colStart}-${Le}`):t.jsx(td,{item:Be.item,style:et,onClick:()=>T==null?void 0:T(Be.item)},`${Be.item.id}-${Be.colStart}-${Le}`)}),Ve>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+Oe*De,color:"var(--text-muted)"},children:["+",Ve," más"]}):null]})]},`week-${Le}-${Pt(le[0])}`)})]}):null,a==="calendar"&&l==="week"&&Q==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:L,children:y.map(le=>{const Se=Pt(le),ne=de[Se]??[],Le=Math.max(0,ne.length-d);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>st(le),children:[Cs(le),t.jsx("span",{className:"mt-1 block text-sm",children:le.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[ne.slice(0,d).map(Oe=>t.jsx($s,{item:Oe,day:le,renderPill:g,onClick:()=>T==null?void 0:T(Oe)},Oe.id)),Le>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Le," más"]}):null]})]},Se)})})}):null,a==="calendar"&&l==="week"&&Q==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${L} border-b`,style:{borderColor:"var(--border)"},children:y.map(le=>t.jsx("button",{type:"button",className:"px-3 py-2 text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)",borderRight:"1px solid var(--border)"},onClick:()=>st(le),children:Cs(le)},Pt(le)))}),t.jsxs("div",{className:`relative ${L}`,style:{minHeight:Math.max(220,ie*56+24)},children:[y.map(le=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Pt(le)}`)),fe.map(le=>{const Se={left:`calc(${le.colStart/ue*100}% + 4px)`,width:`calc(${le.colSpan/ue*100}% - 8px)`,top:12+le.lane*56,height:48};return S?t.jsx("div",{className:"absolute overflow-hidden",style:Se,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:S(le.item)})},`${le.item.id}-${le.colStart}`):t.jsx(nd,{item:le.item,style:Se,onClick:()=>T==null?void 0:T(le.item)},`${le.item.id}-${le.colStart}`)}),fe.length===0&&!O?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:x}):null]})]}):null,a==="calendar"&&l==="day"?ee.length>0||O?t.jsxs("div",{className:"space-y-3",children:[O&&ee.length===0?t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,ee.map(le=>p?t.jsx("div",{children:p(le)},le.id):t.jsx(rd,{item:le,onClick:()=>T==null?void 0:T(le)},le.id))]}):t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:N,description:x}):null]})}function Ls(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 od(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Ls(e)}function sd(e){return typeof e=="function"?e():e}function Ga({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(j.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(j.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:g,type:p="button",...S}){const[v,C]=s.useState(!1),T=s.useRef(null);s.useEffect(()=>()=>{T.current&&window.clearTimeout(T.current)},[]);function E(N){C(!0),d==null||d(N),T.current&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{C(!1),T.current=null},r)}async function O(N){var M;if(c&&N.stopPropagation(),g==null||g(N),N.defaultPrevented)return;const x=sd(e);if(x)try{await od(x),E(x)}catch(w){try{Ls(x),E(x)}catch(P){u==null||u(P,x);return}(M=navigator.clipboard)!=null&&M.writeText||u==null||u(w,x)}}return t.jsxs("button",{...S,type:p,onClick:O,title:v?a:n,"aria-label":S["aria-label"]??(v?a:n),"data-copied":v?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:v?"scale(1.15)":"scale(1)"},children:v?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??f:f})]})}function ld({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(Ga,{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 Bn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function id({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(j.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:Bn(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:Bn(o),padding:Bn(l)}})]})}function cd({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((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[o&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Bn(d)},children:o}),t.jsx(ur,{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 dd={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Fn=180,ud="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Za({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:b=!0,closeOnEscape:f=!0,showCloseButton:g=!0,placement:p="center",bodyClassName:S="px-6 py-5",panelClassName:v="",backdropClassName:C=ud,contentClassName:T="p-4",ariaLabel:E,frameless:O=!1,disabled:N=!1}){const[x,M]=s.useState(!1),[w,P]=s.useState(!1),X=s.useRef(null);if(s.useEffect(()=>(e?(X.current&&clearTimeout(X.current),M(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),X.current=setTimeout(()=>M(!1),Fn+40)),()=>{X.current&&clearTimeout(X.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const Q=R=>{R.key==="Escape"&&r()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[f,r,e]),!x)return null;const K=n||a||o||l||g,D=u??dd[d],G=p==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",U=p==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ae=w?"translateY(0) scale(1)":p==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return pt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":E??n,className:`fixed inset-0 flex ${G} ${T}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${C}`,onClick:b?r:void 0,style:{opacity:w?1:0,transition:`opacity ${Fn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${O?"shadow-none":"shadow-2xl"} ${U} ${v}`,style:{maxWidth:D,background:O?"transparent":"var(--bg-card)",border:O?"none":"1px solid var(--border)",opacity:w?1:0,transform:ae,transition:`opacity ${Fn}ms ease, transform ${Fn}ms ease`},onClick:Q=>Q.stopPropagation(),children:[N&&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)"}}),K&&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,g&&t.jsx(Ge,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${S}`,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 fd={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 bd({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=fd[l];return t.jsx(Za,{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(Ge,{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(j.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(j.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(Ge,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ge,{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 md(e){return e?typeof e=="function"?e():e:""}function hd(e){return/^https?:\/\//i.test(e)}function Ds(e,r){try{return new URL(e,r).toString()}catch{return e}}function pd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||hd(l))return l;const i=md(n);return i?Ds(l,i):a&&typeof window<"u"?Ds(l,window.location.origin):l}function gd({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(j.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Ga,{...c,value:()=>pd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const vd={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 yd(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=vd[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 xd=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function wd({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return s.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>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&&!xd.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 Nd({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(ur,{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 kd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Qa={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Sd({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[b,f]=s.useState(null),g=s.useRef(null);g.current=b;const[p,S]=s.useState({}),[v,C]=s.useState(null),T=s.useRef(null);T.current=v;const[E,O]=s.useState({}),[N,x]=s.useState({}),M=s.useRef(new Set),w=s.useRef(null);s.useEffect(()=>{var B;const L=document.activeElement;(!L||L===document.body)&&((B=w.current)==null||B.focus({preventScroll:!0}))},[]);const P=e.map(L=>{var B,ce,H;return`${L.key}:${((H=(ce=(B=L.editable)==null?void 0:B.select)==null?void 0:ce.options)==null?void 0:H.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(L=>{var H,oe;const B=(oe=(H=L.editable)==null?void 0:H.select)==null?void 0:oe.options;if(!B)return;const ce=E[L.key];(!M.current.has(L.key)||(ce==null?void 0:ce.length)===0&&B.length>0)&&(M.current.add(L.key),O(k=>({...k,[L.key]:B})))})},[P]);const X=s.useCallback(async(L,B)=>{if(M.current.has(L))return;M.current.add(L);const{url:ce,fetchOptions:H}=B.select??{};if(!(!ce&&!H)){x(oe=>({...oe,[L]:!0}));try{let oe=[];if(H)oe=await H();else if(ce){const k=await fetch(ce);if(!k.ok)throw new Error("fetch failed");oe=await k.json()}O(k=>({...k,[L]:oe}))}catch{O(oe=>({...oe,[L]:[]}))}finally{x(oe=>({...oe,[L]:!1}))}}},[]),K=s.useRef(i);K.current=i;const D=s.useRef(a);D.current=a;const G=s.useRef(n);G.current=n;const U=s.useRef(e);U.current=e;const ae=s.useRef(o);ae.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const L=e.find(B=>B.selectable!==!1);L&&f({rowId:n(r[0]),colKey:L.key})}},[]),s.useEffect(()=>{if(!b)return;const L=w.current;if(!L)return;const B=L.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!B)return;const ce=L.querySelector('[role="rowgroup"]');B.style.scrollMarginTop=`${(ce==null?void 0:ce.offsetHeight)??0}px`;const H=L.querySelector('[role="row"]');let oe=0;H&&H.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(k=>{k.style.position==="sticky"&&k.style.left!==""&&(oe=Math.max(oe,parseFloat(k.style.left)+k.offsetWidth))}),B.style.scrollMarginLeft=`${oe}px`,B.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const Q=s.useCallback(L=>{var oe;const B=U.current,ce=new Set,H=[];(oe=w.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(k=>{const te=k.dataset.cellId.split(":")[0];ce.has(te)||(ce.add(te),H.push(te))}),f(k=>{if(!k)return k;const te=B.findIndex(re=>re.key===k.colKey),z=H.indexOf(k.rowId);let I=te,de=z;if(L==="up")de=Math.max(0,z-1);else if(L==="down")de=Math.min(H.length-1,z+1);else if(L==="left"){let re=te-1;for(;re>=0&&B[re].selectable===!1;)re--;re>=0&&(I=re)}else if(L==="right"){let re=te+1;for(;re<B.length&&B[re].selectable===!1;)re++;re<B.length&&(I=re)}return I===te&&de===z?k:{rowId:H[de],colKey:B[I].key}})},[]),R=s.useCallback((L=!0)=>{const B=d.current;m(null),B&&f(B),L&&setTimeout(()=>{var ce;return(ce=w.current)==null?void 0:ce.focus({preventScroll:!0})},0)},[]),V=s.useCallback(async(L,B,ce)=>{var ie;const H=U.current.find(he=>he.key===B);if(!(H!=null&&H.editable))return;const{field:oe,type:k,mask:te,validate:z}=H.editable,I=k==="number"?ce===""?null:Number(ce):ce;if(te){const he=yd(ce,te);if(he){S(Te=>({...Te,[`${L}:${B}`]:he}));return}}if(z){const he=z(I);if(he){S(Te=>({...Te,[`${L}:${B}`]:he}));return}}const de=G.current,re=K.current.find(he=>de(he)===L);if(!re)return;const q=re[oe];m(null),S(he=>{const Te={...he};return delete Te[`${L}:${B}`],Te});const y=K.current,$=y.findIndex(he=>de(he)===L),ee=y[Math.min(y.length-1,$+1)];if(f({rowId:de(ee),colKey:B}),setTimeout(()=>{var Te,De;const he=document.activeElement;(!he||he===document.body||(Te=w.current)!=null&&Te.contains(he))&&((De=w.current)==null||De.focus({preventScroll:!0}))},0),String(q??"")===String(I??""))return;const fe={...re,[oe]:I};c(he=>he.map(Te=>de(Te)===L?fe:Te)),C({rowId:L,colKey:B});try{await((ie=D.current)==null?void 0:ie.call(D,{row:re,rowId:L,field:oe,oldValue:q,newValue:I}))}catch{c(he=>he.map(Te=>de(Te)===L?re:Te)),S(he=>({...he,[`${L}:${B}`]:"Error al guardar. Intenta de nuevo."}))}finally{C(null)}},[]),Y=s.useCallback(L=>{if(T.current){L.preventDefault();return}if(d.current)return;const B=g.current;if(!(!B||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(L.key)))switch(L.preventDefault(),L.key){case"ArrowUp":Q("up");break;case"ArrowDown":Q("down");break;case"ArrowLeft":Q("left");break;case"ArrowRight":Q("right");break;case"Tab":Q(L.shiftKey?"left":"right");break;case"Enter":{const H=U.current.find(oe=>oe.key===B.colKey);H!=null&&H.editable&&!ae.current?(m(B),H.editable.type==="select"&&!M.current.has(B.colKey)&&X(B.colKey,H.editable)):Q("down");break}}},[Q,X]),ue=s.useMemo(()=>e.map(L=>{if(!L.editable||o){const ce={...L};if(delete ce.editable,delete ce.selectable,L.selectable===!1)return{...ce,disableRowClick:!0};const H=ce.cell;return{...ce,className:`relative ${ce.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const k=n(oe),te=(b==null?void 0:b.rowId)===k&&(b==null?void 0:b.colKey)===L.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${k}:${L.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var z;T.current||(f({rowId:k,colKey:L.key}),(z=w.current)==null||z.focus({preventScroll:!0}))}}),te&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Qa}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:H(oe)})]})}}}const B=L.editable;return{...L,className:`relative ${L.className??""}`.trim(),disableRowClick:!0,cell:ce=>{const H=n(ce),oe=L.key,k=(u==null?void 0:u.rowId)===H&&(u==null?void 0:u.colKey)===oe,te=(b==null?void 0:b.rowId)===H&&(b==null?void 0:b.colKey)===oe,z=p[`${H}:${oe}`],I=(v==null?void 0:v.rowId)===H&&(v==null?void 0:v.colKey)===oe,de=ce[B.field],re=String(de??""),q=()=>{var $;T.current||(f({rowId:H,colKey:oe}),m({rowId:H,colKey:oe}),($=w.current)==null||$.focus({preventScroll:!0}),B.type==="select"&&!M.current.has(oe)&&X(oe,B))};if(k){const $=B.type==="select"?t.jsx(Nd,{initialValue:re,options:E[oe]??[],loading:N[oe]??!1,onCommit:ee=>V(H,oe,ee),onCancel:R}):t.jsx(wd,{initialValue:re,type:B.type??"text",mask:B.mask,onCommit:ee=>V(H,oe,ee),onCancel:R});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:kd,onClick:ee=>ee.stopPropagation(),children:$})}const y=L.cell(ce);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${H}:${oe}`,className:`peer absolute inset-0 z-10 ${I?"cursor-wait":"cursor-pointer"}`,onClick:q}),te&&!I&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Qa}),I&&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:Qa,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:z?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(j.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:z})]}):t.jsx("span",{className:"truncate",children:y})}),!I&&t.jsx(j.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,u,b,v,p,E,N,n,V,R,X]);return t.jsx("div",{ref:w,tabIndex:0,onKeyDown:Y,onBlur:L=>{var B;(B=w.current)!=null&&B.contains(L.relatedTarget)||setTimeout(()=>{var H,oe;const ce=document.activeElement;ce&&((H=ce.closest)!=null&&H.call(ce,"[data-bonsaif-select-dropdown]"))||(oe=w.current)!=null&&oe.contains(ce)||R(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(Ua,{...l,columns:ue,data:i,getRowId:n})})}function lt(e){if(e)return new Date(`${e}T12:00:00`)}function Dt(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 Mr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Os(e){return e.map(r=>lt(r)).filter(r=>!!r)}function Ed(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Dt));return Array.from(r).sort()}function Ja(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Hs(e){const r=lt(e);if(!r)return e;const n=Ja(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 Ra={weekend:{dayOfWeek:[0,6]}},eo={weekend:"bonsaif-weekend"};function to({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 Cd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Md={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Td({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?Cd:null,...o?Md:null,...l?{fontWeight:800}:null,...n.style}})}function $d({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:lt(e),to:lt(r)},f=lt(a),[g,p]=s.useState(()=>lt(o||e)??new Date);s.useEffect(()=>{const E=lt(o||e);E&&p(E)},[o,e]);const S=s.useMemo(()=>{if(l<=1)return Mr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const E=new Date(g.getFullYear(),g.getMonth()+l-1,1),O=g.getFullYear()===E.getFullYear(),N=new Intl.DateTimeFormat("es-MX",{month:"short",...O?{}:{year:"numeric"}}).format(g),x=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(E);return`${Mr(N)} – ${Mr(x)}`},[g,l]);function v(){p(new Date(g.getFullYear(),g.getMonth()-1,1))}function C(){p(new Date(g.getFullYear(),g.getMonth()+1,1))}const T=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:v,children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:S}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:C,children:t.jsx(j.HiChevronRight,{size:16})})]}),t.jsx(Ba.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:p,onSelect:E=>{const O=E!=null&&E.from?Dt(E.from):e,N=E!=null&&E.to?Dt(E.to):"";n({startDate:O,endDate:N})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ra,modifiersClassNames:eo,components:{DayButton:Td,Weekday:to},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:E=>`${Mr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(E))} ${E.getFullYear()}`,formatWeekdayName:Ja}})]}),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 Is({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 Bs(e,r){const n=lt(e),a=lt(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(Dt(c)),c.setDate(c.getDate()+1);return i}function Fs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,o=new Date(e);return o.setHours(12,0,0,0),o.setDate(o.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(o);return c.setDate(o.getDate()+i),c})}function an(e,r,n){const a=new Set(e);for(const o of r)n==="add"?a.add(o):n==="remove"||a.has(o)?a.delete(o):a.add(o);return Array.from(a).sort()}function Ad(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Ld(e,r,n){return!!(r&&e<r||n&&e>n)}function Ps({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),m=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(N=>{let x=N;if(c){const M=b.current.filter(P=>!P.startsWith(c)),w=N.filter(P=>P.startsWith(c));x=[...M,...w].sort()}r==null||r(Ad(x,l))},[l,r,c]),g=s.useCallback((N,x=!1)=>Ld(N,a,o)?!0:!(!(i!=null&&i(N))||x&&b.current.includes(N)),[i,o,a]),p=s.useCallback(N=>N.filter(x=>!g(x)),[g]),S=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const N=()=>S();return window.addEventListener("pointerup",N),window.addEventListener("pointercancel",N),()=>{window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",N)}},[S]);const v=s.useCallback((N,x,M,w)=>{const P=p(Bs(N,x));f(M==="add"?an(w,P,"add"):an(w,P,"remove"))},[f,p]),C=s.useCallback((N,x)=>{if(n||x.button!==0)return;const M=Dt(N);if(g(M,!0)||x.shiftKey)return;m.current=!0;const w=[...b.current],P=w.includes(M)?"remove":"add";P==="add"&&g(M)||(u.current={active:!0,mode:P,anchor:M,latest:M,baseline:w},d.current=M,v(M,M,P,w),x.preventDefault())},[v,n,g]),T=s.useCallback(N=>{const x=u.current;if(!(x!=null&&x.active)||n)return;const M=Dt(N);x.mode==="add"&&g(M)||x.latest!==M&&(x.latest=M,v(x.anchor,M,x.mode,x.baseline))},[v,n,g]),E=s.useCallback((N,x)=>{if(n)return;const M=Dt(N);if(!g(M,!0)){if(m.current&&!x.shiftKey){m.current=!1,x.preventDefault(),x.stopPropagation();return}if(m.current=!1,x.shiftKey&&d.current){x.preventDefault(),x.stopPropagation();const w=p(Bs(d.current,M));f(an(b.current,w,"add"));return}!b.current.includes(M)&&g(M)||(d.current=M,f(an(b.current,[M],"toggle")))}},[f,n,p,g]),O=s.useCallback(N=>{if(n)return;const x=p(Ed(N));if(!x.length)return;const M=x.every(w=>b.current.includes(w));f(an(b.current,x,M?"remove":"add")),d.current=x[0]??d.current},[f,n,p]);return{onDayPointerDown:C,onDayPointerEnter:T,onDayClick:E,toggleWeek:O,endDrag:S}}function on(e){return Fs(e,1)[0]}function _s(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Dd({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:g=!1}){const p=s.useMemo(()=>Os(e),[e]),S=s.useMemo(()=>new Set(e),[e]),v=lt(n),C=lt(a),[T,E]=s.useState(()=>lt(l||e[0])??new Date),[O,N]=s.useState(()=>on(lt(l||e[0])??new Date)),[x,M]=s.useState(u),w=d??x;function P(L){d===void 0&&M(L),m==null||m(L)}s.useEffect(()=>{const L=lt(l);L&&(E(L),N(on(L)))},[l]);const{onDayPointerDown:X,onDayPointerEnter:K,onDayClick:D,toggleWeek:G}=Ps({value:e,onChange:r,disabled:g,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),U=s.useMemo(()=>{if(g)return!0;const L=[];return v&&L.push({before:v}),C&&L.push({after:C}),o&&L.push(B=>o(Dt(B))),L.length>0?L:void 0},[g,o,C,v]),ae=s.useCallback(L=>t.jsx(Is,{...L,className:`bonsaif-multi-day-btn ${L.className??""}`,onDayPointerDown:X,onDayPointerEnter:K,onDayClickSelect:D}),[D,X,K]),Q=s.useMemo(()=>Fs(O,1),[O]),R=Q[6],V=w==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(Q[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(R)}`:Mr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(T));function Y(){if(w==="week"){const L=_s(O,-7);N(on(L)),E(L);return}E(new Date(T.getFullYear(),T.getMonth()-1,1))}function ue(){if(w==="week"){const L=_s(O,7);N(on(L)),E(L);return}E(new Date(T.getFullYear(),T.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":w==="month",className:`bonsaif-cal-view-btn${w==="month"?" is-active":""}`,disabled:g,onClick:()=>{P("month"),E(O)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":w==="week",className:`bonsaif-cal-view-btn${w==="week"?" is-active":""}`,disabled:g,onClick:()=>{P("week"),N(on(T))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana anterior":"Mes anterior",disabled:g,onClick:Y,children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:V}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana siguiente":"Mes siguiente",disabled:g,onClick:ue,children:t.jsx(j.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&w==="month"?" · Semana (nº)":"",w==="week"?" · Botón semana completa":""]}),w==="month"?t.jsx(Ba.DayPicker,{mode:"multiple",required:!1,selected:p,month:T,onMonthChange:E,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(L,B)=>{G(B)},disabled:U,className:"bonsaif-multi-daypicker",modifiers:Ra,modifiersClassNames:eo,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:ae,Weekday:to},formatters:{formatWeekdayName:Ja}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:Q.map(L=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(L)},`h-${Dt(L)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:Q.map(L=>{const B=Dt(L),ce=S.has(B),H=g||(n?B<n:!1)||(a?B>a:!1)||!!(o!=null&&o(B)),oe=B===Dt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${H?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:H,"aria-pressed":ce,onPointerDown:k=>X(L,k),onPointerEnter:()=>K(L),onClick:k=>D(L,k),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:L.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(L)})]})},B)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:g,onClick:()=>G(Q),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(L=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:g,onClick:()=>r==null?void 0:r(e.filter(B=>B!==L)),title:`Quitar ${L}`,children:[Hs(L),t.jsx("span",{"aria-hidden":!0,children:"×"})]},L))})]})}):null]})}const Od=Array.from({length:12},(e,r)=>r);function Hd({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 b=s.useMemo(()=>Os(e),[e]),f=lt(o),g=lt(l),p=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[S,v]=s.useState(p);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function C(w){v(w),a==null||a(w)}const{onDayPointerDown:T,onDayPointerEnter:E,onDayClick:O}=Ps({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${S}-`}),N=s.useCallback(w=>t.jsx(Is,{...w,className:`bonsaif-year-day-btn ${w.className??""}`,onDayPointerDown:T,onDayPointerEnter:E,onDayClickSelect:O}),[O,T,E]),x=b.filter(w=>w.getFullYear()===S),M=u?!0:[...f?[{before:f}]:[],...g?[{after:g}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>C(S-1),children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:S}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>C(S+1),children:t.jsx(j.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:Od.map(w=>{const P=new Date(S,w,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Mr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(P))}),t.jsx(Ba.DayPicker,{mode:"multiple",required:!1,selected:x,month:P,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:M,className:"bonsaif-year-month-picker",modifiers:Ra,modifiersClassNames:eo,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:N,Weekday:to},formatters:{formatWeekdayName:X=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(X)}})]},`${S}-${w}`)})})]}),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"," ·"," ",S]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(w=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(P=>P!==w)),title:`Quitar ${w}`,children:[Hs(w),t.jsx("span",{"aria-hidden":!0,children:"×"})]},w))})]})}):null]})}const Id="bonsaif-ui:hide-tooltips";function zs(){window.dispatchEvent(new CustomEvent(Id))}function Bd(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Fd({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,b]=s.useState(!1),[f,g]=s.useState({}),p=s.useRef(null),S=s.useRef(null),v=s.useCallback(N=>{u(N),c==null||c(N)},[c]),C=s.useCallback(()=>{const N=p.current;if(!N)return;const x=N.getBoundingClientRect(),M=typeof a=="number"?a:x.width,w=typeof a=="number"?a:Math.max(x.width,180),P=n==="end"?Math.max(8,x.right-w):Math.min(x.left,window.innerWidth-w-8),X=window.innerHeight-x.bottom,K=X<240&&x.top>X?void 0:x.bottom+6,D=K===void 0?window.innerHeight-x.top+6:void 0;g({position:"fixed",zIndex:9999,left:P,top:K,bottom:D,width:Bd(typeof a=="number"?M:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;C();const N=M=>{var P,X;const w=M.target;!((P=p.current)!=null&&P.contains(w))&&!((X=S.current)!=null&&X.contains(w))&&v(!1)},x=M=>{M.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",x),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",x),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[d,v,C]);const T=N=>{o||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),v(!d))},E=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(zs(),v(!d))}}):e,O=d?t.jsx("div",{ref:S,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(N=>t.jsxs("div",{children:[N.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:N.disabled,onClick:()=>{var x;N.disabled||(zs(),(x=N.onSelect)==null||x.call(N),v(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:N.danger?"var(--danger)":"var(--text-main)"},children:[N.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:N.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:N.label}),N.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:N.description})]})]})]},N.id))}):null;return t.jsxs("span",{ref:p,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:[E,m&&O?pt.createPortal(O,document.body):null]})}const Pd=180,Ws="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function _d({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:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:p="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:S="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:C,disabled:T=!1,disabledMessage:E,children:O}){const[N,x]=s.useState(!1),[M,w]=s.useState(!1),[P,X]=s.useState(!1),K=s.useCallback(()=>{w(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>X(!0))})},[]),D=s.useCallback(()=>{X(!1),window.setTimeout(()=>w(!1),Pd)},[]),G=T||c,U=s.useCallback(()=>{if(!G){if(f){K();return}r()}},[G,f,r,K]),ae=s.useCallback(()=>{X(!1),w(!1),C==null||C(),r()},[r,C]);if(s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(X(!1),w(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const R=V=>{if(V.key==="Escape"&&!G){if(M){D();return}U()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[D,G,M,e,U]),!N)return null;const Q=E!==void 0?E:c?"Guardando…":null;return pt.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${Ws}`,onClick:U}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ge,{variant:"icon",onClick:U,title:"Cerrar",disabled:G,children:t.jsx(j.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(Ge,{variant:"secondary",size:"sm",onClick:U,disabled:G,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ge,{variant:"primary",size:"sm",icon:t.jsx(tc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||G,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:O}),G&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:Q?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:Q})]}):null})]}),M&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":g,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Ws} transition-opacity duration-200 ease-out ${P?"opacity-100":"opacity-0"}`,onClick:D}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${P?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ge,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":v,children:t.jsx(j.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(j.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:p}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ge,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Ge,{variant:"secondary",onClick:ae,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:S})]})]})]})]}),document.body)}const zd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Wd=/^\+?[0-9\s().-]+$/,jd=7,qd=15;function _t(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 ro(e){return _t(e)?!1:zd.test(String(e))}function no(e){if(_t(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Wd.test(r)&&n.length>=jd&&n.length<=qd}function Ud(e="Este campo es requerido."){return r=>_t(r)?e:void 0}function Vd(e="Ingresa un correo valido."){return r=>_t(r)||ro(r)?void 0:e}function Yd(e="Ingresa un telefono valido."){return r=>_t(r)||no(r)?void 0:e}function Xd(e,r){return n=>_t(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Kd(e,r){return n=>_t(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function Gd(e,r){return n=>{if(_t(n))return;const a=js(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Zd(e,r){return n=>{if(_t(n))return;const a=js(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Qd(e,r="El formato no es valido."){return n=>_t(n)||e.test(String(n))?void 0:r}function Jd(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 qs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Us=s.createContext&&s.createContext(qs),Rd=["attr","size","title"];function eu(e,r){if(e==null)return{};var n,a,o=tu(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 tu(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function Pn(){return Pn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Pn.apply(null,arguments)}function Vs(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 _n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Vs(Object(n),!0).forEach(function(a){ru(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function ru(e,r,n){return(r=nu(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function nu(e){var r=au(e,"string");return typeof r=="symbol"?r:r+""}function au(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 Ys(e){return e&&e.map((r,n)=>s.createElement(r.tag,_n({key:n},r.attr),Ys(r.child)))}function ao(e){return r=>s.createElement(ou,Pn({attr:_n({},e.attr)},r),Ys(e.child))}function ou(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=eu(e,Rd),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Pn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:_n(_n({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 Us!==void 0?s.createElement(Us.Consumer,null,n=>r(n)):r(qs)}function Xs(e){return ao({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 su(e){return ao({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 lu(e){return ao({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 Tr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Ft,{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(j.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function $r({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function zn({className:e="",...r}){return t.jsx("input",{...r,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function oo({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:b="",required:f,...g}){const[p,S]=s.useState(()=>!!g.autoFocus),[v,C]=s.useState(!1),T=g.type==="password"&&u,E=T&&v?"text":g.type,O=!!o,N=O&&l!=="tooltip",x=O&&l!=="inline",M=!!n&&a==="tooltip"&&!N,w=m?f:void 0,P=O?"border-[var(--danger)] focus:border-[var(--danger)]":"",X=x?T?"pr-20":"pr-10":T?"pr-10":"",K=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,D=p||K,G={top:D?7:12,color:p?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},U=Y=>{var ue;S(!0),(ue=g.onFocus)==null||ue.call(g,Y)},ae=Y=>{var ue;S(!1),(ue=g.onBlur)==null||ue.call(g,Y)},Q=T?t.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>C(Y=>!Y),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(su,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(lu,{className:"h-[18px] w-[18px]"})})]}):null,R=x?t.jsx(Ft,{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: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(Xs,{className:"h-[18px] w-[18px]"})})}):null,V=t.jsx($r,{error:N?o:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...g,type:E,required:w,placeholder:" ","aria-invalid":O||g["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${X} ${P} ${b}`,onFocus:U,onBlur:ae}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:G,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:D?7:12},children:c}),R,Q]}),V]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),M?t.jsx(Tr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),T?t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...g,type:E,required:w,"aria-invalid":O||g["aria-invalid"],className:`w-full ${X} ${P} ${b}`,onFocus:U,onBlur:ae}),R,Q]}):t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...g,required:w,"aria-invalid":O||g["aria-invalid"],className:`w-full ${X} ${P} ${b}`}),R]}),V]})}function Ks(e){return e==null?"":String(e)}function iu({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,b]=s.useState(()=>Ks(c)),f=i!==void 0?Ks(i):m,g=n&&f.length>0&&!ro(f)?a:void 0,p=S=>{i===void 0&&b(S.currentTarget.value),d==null||d(S)};return t.jsx(oo,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:o,onChange:p})}const cu={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function du(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 Gs(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 uu(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function fu({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:b=!1,showFileList:f=!0,clearable:g=!0,browseLabel:p="Buscar archivos",dropLabel:S="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:C="o haz click para buscarlos en tu equipo",selectedLabel:T="Archivos seleccionados",size:E="md",containerClassName:O="",dropzoneClassName:N="",fileListClassName:x="",className:M="",id:w,accept:P,disabled:X,required:K,...D}){const G=s.useId(),U=w??G,ae=s.useRef(null),[Q,R]=s.useState(!1),[V,Y]=s.useState(i),ue=l??V,L=!!a,B=!!r&&n==="tooltip"&&!L,ce=g&&ue.length>0&&!X,H=($,ee)=>{l===void 0&&Y($),c==null||c($,ee)},oe=($,ee)=>{const fe=$.filter(De=>Gs(De,P)),ie=$.filter(De=>!Gs(De,P)),he=b?[...ue,...fe]:fe,Te=uu(he,u,m);ie.length>0&&(d==null||d(ie)),H(Te,ee)},k=()=>{var $;X||($=ae.current)==null||$.click()},te=$=>{oe(Array.from($.target.files??[]),$),$.target.value=""},z=$=>{$.preventDefault(),X||R(!0)},I=$=>{$.currentTarget.contains($.relatedTarget)||R(!1)},de=$=>{$.preventDefault(),R(!1),!X&&oe(Array.from($.dataTransfer.files),$)},re=$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),k())},q=$=>{H(ue.filter((ee,fe)=>fe!==$))},y=()=>{H([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${O}`,children:[(e||o||B)&&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}),K&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),B?t.jsx(Tr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:ae,id:U,type:"file",accept:P,multiple:u,disabled:X,required:K&&ue.length===0,"aria-invalid":L||D["aria-invalid"],className:"sr-only",onChange:te}),t.jsxs("div",{role:"button",tabIndex:X?-1:0,"aria-controls":U,"aria-disabled":X||void 0,"aria-invalid":L||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)] ${cu[E]} ${Q?"border-[var(--primary)] bg-[var(--bg-input)]":L?"border-[var(--danger)]":"border-[var(--border)]"} ${X?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${N} ${M}`,onClick:k,onDragOver:z,onDragLeave:I,onDrop:de,onKeyDown:re,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(j.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:Q?S:v}),C&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:C})]}),p&&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:p})]}),f&&ue.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${x}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:T}),ce&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:y,children:t.jsx(j.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ue.map(($,ee)=>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(j.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:$.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:du($.size)})]}),!X&&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 ${$.name}`,onClick:()=>q(ee),children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]},`${$.name}-${$.lastModified}-${ee}`))})]}),t.jsx($r,{error:a,helperText:r,helperDisplay:n})]})}const bu=[{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 mu({fields:e,title:r="Layout",fieldTypes:n=bu,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=s.useState(()=>e.map(E=>({key:!1,type:"",...E}))),[f,g]=s.useState(""),[p,S]=s.useState(""),v=s.useCallback((E,O)=>{b(N=>{const x=N.map((M,w)=>w===E?{...M,...O}:M);return u==null||u(x),x})},[u]),C=s.useCallback(()=>{d==null||d(m)},[m,d]),T=s.useCallback(()=>{var x;const E=f.trim();if(!E){S("Ingresa un nombre de campo.");return}if(m.some(M=>M.name.toLowerCase()===E.toLowerCase())){S("Ese campo ya existe en el arreglo.");return}const N={name:E,key:!1,type:((x=n[0])==null?void 0:x.value)??""};b(M=>{const w=[...M,N];return u==null||u(w),w}),g(""),S("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((E,O)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:E.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Mn,{size:"sm",checked:E.key??!1,onChange:N=>v(O,{key:N.target.checked}),"aria-label":`${E.name} es clave`})}),t.jsx(ur,{value:E.type??"",onChange:N=>v(O,{type:N}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${E.name}`})]},E.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:f,onChange:E=>{g(E.currentTarget.value),p&&S("")},onKeyDown:E=>{E.key==="Enter"&&(E.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"}),t.jsx(Ge,{variant:"secondary",onClick:T,height:36,padding:"0 12px",children:i})]}),p&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:p})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ge,{variant:"primary",onClick:C,disabled:c,loading:c,children:a})})]})})]})}function Wn({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(Tr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx($r,{error:o,helperText:n,helperDisplay:a})]})}function hu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Zs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=hu(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 Ot=260,Ar=420,so=380,zt="cubic-bezier(0.22, 1, 0.36, 1)",pu="cubic-bezier(0.16, 1, 0.3, 1)",lo="cubic-bezier(0.22, 1, 0.36, 1)",gu="cubic-bezier(0.22, 1, 0.36, 1)",vu=8,yu=1,xu=1.25,io={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},wu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",co=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function Nu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Qs(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 Lr({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:{...io,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=wu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(io.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 Js({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=vu,minZoom:c=yu,zoomStep:d=xu,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:p=!0,zIndex:S=1100,ariaLabel:v="Visor de imagen"}){const[C,T]=s.useState(!1),[E,O]=s.useState(!1),[N,x]=s.useState(a??0),[M,w]=s.useState(1),[P,X]=s.useState({x:0,y:0}),[K,D]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[G,U]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ae,Q]=s.useState(!1),R=s.useRef(null),V=s.useRef(null),Y=s.useRef(null),ue=s.useRef(null),L=s.useRef(null),B=s.useRef(!1),ce=s.useRef(!1),H=s.useRef(null),oe=s.useRef(null),k=s.useRef(null),te=s.useRef(null),z=s.useRef(null),I=s.useRef(a??0),de=a??N,re=n.length===0?0:sn(de,0,Math.max(0,n.length-1)),q=n[re],y=n.length>1,$=Math.max(c,i),ee=p&&y,fe=s.useCallback(be=>{if(n.length===0)return;const ge=n.length-1,He=g?(be%n.length+n.length)%n.length:sn(be,0,ge);a===void 0&&x(He),o==null||o(He)},[a,g,o,n.length]),ie=s.useCallback(()=>{w(1),X({x:0,y:0})},[]),he=s.useCallback((be,ge)=>{if(ge<=c+.001)return{x:0,y:0};const He=te.current,We=z.current;if(!He||!We)return be;const Fe=He.getBoundingClientRect(),bt=We.offsetWidth*ge,ct=We.offsetHeight*ge,qe=Math.max(0,(bt-Fe.width)/2+Fe.width*.15),Ye=Math.max(0,(ct-Fe.height)/2+Fe.height*.15);return{x:sn(be.x,-qe,qe),y:sn(be.y,-Ye,Ye)}},[c]),Te=s.useCallback(()=>{T(!1),U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ue.current=null,L.current=null,B.current=!1,ce.current=!1,H.current&&(clearTimeout(H.current),H.current=null)},[]),De=s.useCallback(()=>{if(B.current)return;B.current=!0,O(!1),ie();const be=ue.current,ge=be!=null&&L.current!=null&&L.current===re;if(be&&ge){Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{const He=z.current;if(!He){Y.current=null,R.current&&clearTimeout(R.current),R.current=setTimeout(Te,Ot+40);return}const We=He.getBoundingClientRect(),Fe=Qs(be,We);U({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),Y.current=requestAnimationFrame(()=>{U({enabled:!0,dx:Fe.dx,dy:Fe.dy,scale:Fe.scale,animate:!0}),Y.current=null})})}),R.current&&clearTimeout(R.current),R.current=setTimeout(Te,Ar+80);return}U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),R.current&&clearTimeout(R.current),R.current=setTimeout(Te,Ot+40)},[Te,ie,re]);s.useEffect(()=>(e?(R.current&&clearTimeout(R.current),H.current&&(clearTimeout(H.current),H.current=null),B.current=!1,ce.current=!1,ue.current=Nu(l),L.current=ue.current!=null?a??N:null,T(!0),O(!1),ue.current?U({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(L.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{O(!0),U({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):C&&De(),()=>{R.current&&clearTimeout(R.current),Y.current!=null&&cancelAnimationFrame(Y.current)}),[e]);const ft=s.useCallback(()=>{if(!e||B.current||ce.current)return;const be=ue.current,ge=z.current;if(!be||!ge){be||(O(!0),ce.current=!0);return}const He=ge.getBoundingClientRect();if(He.width<2||He.height<2)return;ce.current=!0;const We=Qs(be,He);U({enabled:!0,dx:We.dx,dy:We.dy,scale:We.scale,animate:!1}),Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{U({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),O(!0),Y.current=null,H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),H.current=null},Ar+20)})})},[e]);s.useLayoutEffect(()=>{!C||!e||!ue.current||ce.current||ft()},[C,e,ft]),s.useEffect(()=>{!e||B.current||L.current!=null&&L.current!==re&&U(be=>be.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:be)},[e,re]),s.useEffect(()=>{if(!e)return;const be=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=be}},[e]),s.useEffect(()=>{e&&ie()},[e,re,ie]),s.useEffect(()=>{a!==void 0&&x(a)},[a]),s.useEffect(()=>{if(!e){I.current=re,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const be=I.current;if(be===re)return;I.current=re;const ge=n.length;let He=1;if(ge>1){const We=(be+1)%ge===re,Fe=(be-1+ge)%ge===re;Fe&&!We?He=-1:We&&!Fe?He=1:He=re>be?1:-1}return V.current!=null&&(cancelAnimationFrame(V.current),V.current=null),D({opacity:0,x:He*56,scale:.94,blur:8,animate:!1}),V.current=requestAnimationFrame(()=>{V.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),V.current=null})}),()=>{V.current!=null&&(cancelAnimationFrame(V.current),V.current=null)}},[e,re,n.length]);const Ct=M<=c+.001&&Math.abs(P.x)<.5&&Math.abs(P.y)<.5,nt=s.useCallback((be,ge,He)=>{w(We=>{const Fe=sn(be,c,$);if(Math.abs(Fe-We)<1e-4)return We;const bt=Fe/We,ct=Fe<We;return Fe<=c+.001?(X({x:0,y:0}),c):(X(qe=>{let Ye=qe;if(typeof ge=="number"&&typeof He=="number"&&te.current&&!ct){const dt=te.current.getBoundingClientRect(),mt=ge-dt.left-dt.width/2,mr=He-dt.top-dt.height/2;Ye={x:mt-(mt-qe.x)*bt,y:mr-(mr-qe.y)*bt}}else if(ct){Ye={x:qe.x*bt,y:qe.y*bt};const dt=Math.min(1,(We-Fe)/Math.max(.01,We-c));Ye={x:Ye.x*(1-dt*.65),y:Ye.y*(1-dt*.65)}}else Ye={x:qe.x*bt,y:qe.y*bt};return he(Ye,Fe)}),Fe)})},[he,c,$]),st=s.useCallback(()=>{nt(M*d)},[nt,M,d]),le=s.useCallback(()=>{const be=Math.max(c,M/d);if(be<=c+.001){ie();return}w(be),X({x:0,y:0})},[c,ie,M,d]);s.useEffect(()=>{if(!e)return;const be=ge=>{if(ge.key==="Escape"&&m){ge.preventDefault(),r();return}ge.key==="ArrowLeft"&&y?(ge.preventDefault(),fe(re-1)):ge.key==="ArrowRight"&&y?(ge.preventDefault(),fe(re+1)):ge.key==="+"||ge.key==="="?(ge.preventDefault(),nt(M*d)):ge.key==="-"||ge.key==="_"?(ge.preventDefault(),le()):ge.key==="0"&&(ge.preventDefault(),ie())};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[nt,m,y,r,e,ie,re,M,fe,le,d]);const Se=be=>{be.preventDefault();const ge=be.deltaY>0?1/d:d;nt(M*ge,be.clientX,be.clientY)},ne=be=>{M<=c+.001||(be.currentTarget.setPointerCapture(be.pointerId),Q(!0),oe.current={pointerId:be.pointerId,startX:be.clientX,startY:be.clientY,originX:P.x,originY:P.y})},Le=be=>{const ge=oe.current;!ge||ge.pointerId!==be.pointerId||X(he({x:ge.originX+(be.clientX-ge.startX),y:ge.originY+(be.clientY-ge.startY)},M))},Oe=be=>{var ge;((ge=oe.current)==null?void 0:ge.pointerId)===be.pointerId&&(oe.current=null,Q(!1))},Ve=be=>{if(be.stopPropagation(),M>c+.05){ie();return}nt(Math.min($,3),be.clientX,be.clientY)},je=be=>{if(be.touches.length!==2)return;Q(!0);const[ge,He]=[be.touches[0],be.touches[1]],We=Math.hypot(ge.clientX-He.clientX,ge.clientY-He.clientY);k.current={distance:We,scale:M}},Be=be=>{if(be.touches.length!==2||!k.current)return;be.preventDefault();const[ge,He]=[be.touches[0],be.touches[1]],We=Math.hypot(ge.clientX-He.clientX,ge.clientY-He.clientY),Fe=(ge.clientX+He.clientX)/2,bt=(ge.clientY+He.clientY)/2,ct=k.current.scale*(We/Math.max(1,k.current.distance));nt(ct,Fe,bt)},et=()=>{k.current=null,Q(!1)};if(!C||!q)return null;const ot=G.enabled,Ht=G.animate?`transform ${Ar}ms ${gu}`:"none";return pt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:S},role:"dialog","aria-modal":"true","aria-label":v,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:E?1:0,transition:`opacity ${ot?Ar:Ot}ms ${zt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:te,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:ee?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:ot||E?1:0,transform:ot||E?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:ot?"none":`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},onClick:be=>{be.target===be.currentTarget&&u&&r()},onWheel:Se,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:G.enabled?`translate3d(${G.dx}px, ${G.dy}px, 0) scale(${G.scale})`:void 0,transformOrigin:"center center",transition:G.enabled?Ht:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:K.opacity,filter:K.blur?`blur(${K.blur}px)`:"blur(0px)",transform:`translate3d(${K.x}px, 0, 0) scale(${K.scale})`,transition:K.animate?[`opacity ${so}ms ${lo}`,`transform ${so}ms ${lo}`,`filter ${so}ms ${lo}`].join(", "):"none"},children:t.jsx("div",{ref:z,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:M>c+.001?"grab":"zoom-in",transform:`translate3d(${P.x}px, ${P.y}px, 0) scale(${M})`,transformOrigin:"center center",transition:ae?"none":`transform 220ms ${pu}`},onClick:be=>be.stopPropagation(),onDoubleClick:Ve,onPointerDown:ne,onPointerMove:Le,onPointerUp:Oe,onPointerCancel:Oe,onTouchStart:je,onTouchMove:Be,onTouchEnd:et,children:t.jsx("img",{src:q.src,alt:q.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:co,imageRendering:M>2.5?"pixelated":"auto"},onLoad:()=>{ft()}},q.src+String(re))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:E?1:0,transform:E?"translateY(0)":"translateY(-6px)",transition:`opacity ${ot?Ar:Ot}ms ${zt}, transform ${ot?Ar:Ot}ms ${zt}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:io,children:[re+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(Lr,{label:"Alejar",onClick:le,disabled:M<=c+.001,children:t.jsx(j.HiMinus,{className:"h-5 w-5"})}),t.jsx(Lr,{label:"Restablecer tamaño",onClick:ie,disabled:Ct,children:t.jsx(j.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Lr,{label:"Acercar",onClick:st,disabled:M>=$-.001,children:t.jsx(j.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Lr,{label:"Cerrar",onClick:r,children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]})]}),y?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:E?1:0,transform:E?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},children:t.jsx(Lr,{label:"Anterior",size:"lg",onClick:()=>fe(re-1),disabled:!g&&re<=0,children:t.jsx(j.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:E?1:0,transform:E?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},children:t.jsx(Lr,{label:"Siguiente",size:"lg",onClick:()=>fe(re+1),disabled:!g&&re>=n.length-1,children:t.jsx(j.HiChevronRight,{className:"h-6 w-6"})})})]}):null,ee?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((be,ge)=>{const He=ge===re;return t.jsx("button",{type:"button",role:"tab","aria-selected":He,"aria-label":be.alt||`Imagen ${ge+1}`,onClick:We=>{We.stopPropagation(),fe(ge)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:co,opacity:He?1:.42,transition:`opacity 180ms ${zt}`},children:t.jsx("img",{src:be.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:co}})},`${be.src}-${ge}`)})})}):null]})]}),document.body)}function ku({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(0),[f,g]=s.useState([]),[p,S]=s.useState(null),v=s.useCallback((T,E,O)=>{g(T),S(O??null),b(E),u(!0)},[]),C=s.useCallback(T=>{Zs(T,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:C,children:e}),t.jsx(Js,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:p,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Rs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function el(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function uo(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Su(e,r){if(!r)return!0;const n=uo(r);return uo(e.label).includes(n)||!!(e.sublabel&&uo(e.sublabel).includes(n))}function Eu({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:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:g=!0,emptyText:p="Sin resultados",clearLabel:S="Limpiar seleccion",pruneMissingValues:v=!0}){const[C,T]=s.useState(!1),[E,O]=s.useState(""),[N,x]=s.useState(0),[M,w]=s.useState(!1),[P,X]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),U=s.useRef(null),ae=u&&n.length>=m,Q=s.useMemo(()=>new Set(e),[e]),R=s.useMemo(()=>{const y=new Map;for(const $ of n)y.set($.value,$);return y},[n]),V=s.useMemo(()=>{const y=[];for(const $ of e){const ee=R.get($);ee&&y.push(ee)}return y},[R,e]),Y=b==="all"?V.length:b,ue=V.slice(0,Y),L=Math.max(0,V.length-ue.length),B=g&&V.length>1,ce=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[V.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:V.map(y=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[y.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:y.label}),y.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:y.sublabel}):null]},y.value))})]}),H=s.useMemo(()=>{const y=E.trim();return!ae||!y?n:n.filter($=>Su($,y))},[n,E,ae]),oe=s.useCallback(()=>{const y=K.current;if(!y)return;const $=y.getBoundingClientRect(),ee=ae?304:244,fe=window.innerHeight-$.bottom,ie=fe<ee&&$.top>fe;X({position:"fixed",left:$.left,top:ie?void 0:$.bottom+4,bottom:ie?window.innerHeight-$.top+4:void 0,width:Math.max($.width,240),zIndex:9999})},[ae]),k=s.useCallback(y=>{el(e,y)||r(y)},[r,e]),te=s.useCallback(y=>{const $=R.get(y);if($!=null&&$.disabled)return;const ee=Q.has(y)?e.filter(fe=>fe!==y):[...e,y];k(ee)},[k,R,e,Q]),z=s.useCallback(()=>k([]),[k]),I=s.useCallback(()=>{T(!1),O(""),x(0)},[]);s.useEffect(()=>w(!0),[]);const de=s.useMemo(()=>n.map(y=>y.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const y=new Set(n.map(ee=>ee.value)),$=e.filter(ee=>y.has(ee));el(e,$)||r($)},[de]),s.useEffect(()=>{if(!C)return;function y($){var fe,ie;const ee=$.target;!((fe=K.current)!=null&&fe.contains(ee))&&!((ie=D.current)!=null&&ie.contains(ee))&&I()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[I,C]),s.useEffect(()=>{C&&(x(0),oe(),ae&&setTimeout(()=>{var y;return(y=G.current)==null?void 0:y.focus()},0))},[C,ae,oe]),s.useEffect(()=>{if(C)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[C,oe]),s.useEffect(()=>{if(H.length===0){x(0);return}x(y=>Math.min(y,H.length-1))},[H.length]),s.useEffect(()=>{if(N<0||!U.current)return;const y=U.current.children[N];y==null||y.scrollIntoView({block:"nearest"})},[N]);function re(y){if(!o){if(!C){(y.key==="Enter"||y.key===" "||y.key==="ArrowDown")&&(y.preventDefault(),T(!0));return}if(y.key==="Escape"){y.preventDefault(),I();return}if(y.key==="ArrowDown"){if(y.preventDefault(),H.length===0)return;x($=>Math.min($+1,H.length-1));return}if(y.key==="ArrowUp"){y.preventDefault(),x($=>Math.max($-1,0));return}if(y.key==="Enter"&&H[N]&&!H[N].disabled){y.preventDefault(),te(H[N].value);return}y.key==="Backspace"&&!E&&e.length&&(y.preventDefault(),k(e.slice(0,-1)))}}const q=t.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{...P,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ae&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:E,onChange:y=>{O(y.target.value),x(0)},onKeyDown:y=>{(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter"||y.key==="Escape")&&(y.stopPropagation(),re(y))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),E&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:y=>{y.preventDefault(),O(""),x(0)},children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[t.jsxs("span",{children:[V.length," seleccionados",e.length>V.length?` (${e.length-V.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),z()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:S})]}),t.jsxs("ul",{ref:U,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ae?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[H.map((y,$)=>{const ee=$===N,fe=Q.has(y.value);return t.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:ie=>{ie.preventDefault(),!y.disabled&&te(y.value)},onMouseEnter:()=>!y.disabled&&x($),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:ee?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:y.disabled?"var(--text-muted)":"var(--text-main)",cursor:y.disabled?"not-allowed":"pointer",opacity:y.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:fe?"var(--primary)":"var(--border)",background:fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:fe&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),y.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:y.label}),y.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:y.sublabel})]}),y.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:y.badge})]},y.value)}),H.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:p})]})]});return t.jsxs("div",{ref:K,className:`relative ${l||"w-full"}`,style:i,onKeyDown:re,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(C?I():T(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Rs(c),padding:Rs(d),background:"var(--bg-input)",color:V.length?"var(--text-main)":"var(--text-muted)",border:C?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ue.length?(()=>{const y=t.jsxs(t.Fragment,{children:[ue.map($=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[$.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:$.color}}),f?t.jsx(Vt,{className:"min-w-0 flex-1",children:$.label}):t.jsx("span",{className:"break-words",children:$.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${$.label}`,onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation(),te($.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"h-3 w-3"})})]},$.value)),L>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},"aria-label":`${L} seleccionados más`,children:["+",L]})]});return B?t.jsx(Ft,{as:"span",content:ce,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:y}):y})():t.jsx("span",{className:"truncate",children:a})}),V.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":S,onMouseDown:y=>{y.preventDefault(),y.stopPropagation(),z()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(j.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&M&&pt.createPortal(q,document.body)]})}function Cu({inputMode:e="decimal",...r}){return t.jsx(oo,{...r,type:"number",inputMode:e})}function Mu(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 Tu({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=Mu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ge,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(j.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(Ge,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(j.HiChevronRight,{className:"h-4 w-4"})})]})}const tl=[{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 rl(e){return e==null?"":String(e)}function jn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function $u(e){return typeof e=="number"?`${e}px`:e}function Au({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:b,allowedCountryCodes:f,countryCodeOptions:g,countryCodePlaceholder:p="Codigo",countryCodeClassName:S="",countryCodeWidth:v=84,onPhoneValueChange:C,label:T,containerClassName:E="",helperText:O,helperDisplay:N="inline",labelAction:x,className:M="",required:w,disabled:P,floatingLabel:X,showPasswordToggle:K,nativeValidation:D,errorTooltipLabel:G="Error de validacion",...U}){var $;const[ae,Q]=s.useState(()=>rl(c)),[R,V]=s.useState(()=>jn(m)),Y=s.useMemo(()=>{const ee=g??tl,fe=f==null?void 0:f.map(jn);return fe!=null&&fe.length?ee.filter(ie=>fe.includes(ie.value)):ee},[f,g]),ue=(($=Y[0])==null?void 0:$.value)??"+1",L=Y.some(ee=>ee.value===jn(u??R))?jn(u??R):ue,B=i!==void 0?rl(i):ae,ce=`${L} ${B}`.trim(),H=n&&B.length>0&&!no(ce)?a:void 0,oe=l??H,k=!!oe,te=k&&o!=="tooltip",z=k&&o!=="inline",I=!!O&&N==="tooltip"&&!te,de=k?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",re=ee=>{const fe=ee.currentTarget.value;i===void 0&&Q(fe),C==null||C(fe,{countryCode:L,nationalNumber:fe,fullNumber:`${L} ${fe}`.trim()}),d==null||d(ee)},q=ee=>{u===void 0&&V(ee),b==null||b(ee),C==null||C(B,{countryCode:ee,nationalNumber:B,fullNumber:`${ee} ${B}`.trim()})},y=z?t.jsx(Ft,{as:"span",content:oe,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":G,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Xs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${E}`,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:T}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),I?t.jsx(Tr,{content:O}):null,x&&t.jsx("span",{className:"ml-auto normal-case",children:x})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${de}`,children:[t.jsx(ur,{value:L,onChange:q,options:Y,placeholder:p,disabled:P,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${S}`,style:{width:$u(v)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...U,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:P,required:void 0,"aria-label":U["aria-label"]??(typeof T=="string"?T:void 0),"aria-invalid":k||U["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 ${z?"pr-10":""} ${M}`,onChange:re}),y]})]}),t.jsx($r,{error:te?oe:void 0,helperText:O,helperDisplay:N})]})}function Lu({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,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Du=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),qn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Dr=12,Un=8,fo=(e,r,n)=>{const a=Yn(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},nl=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Dr?null:fo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Dr)return null;const o=Array.from(a.rows).indexOf(n);return fo(a,o+1,e)},Ou=(e,r)=>{var o;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((o=e.tBodies[0])==null?void 0:o.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},al=(e,r)=>Yn(e)>=Un?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),Hu=(e,r)=>Yn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),ol=e=>{e.querySelectorAll(".rich-table-row-active").forEach(r=>{r.classList.remove("rich-table-row-active")}),e.querySelectorAll(".rich-table-col-active").forEach(r=>{r.classList.remove("rich-table-col-active")})},sl=(e,r,n)=>{ol(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},Iu=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},Vn=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},ll=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},Bu=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?nl(r,n):bo(r);return l&&Xn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Ou(r,n):!1;case"table-col-add":return Number.isFinite(a)?al(r,a):zu(r);case"table-col-del":return Number.isFinite(a)?Hu(r,a):!1;default:return!1}},Yn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Fu=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},il=e=>(e==null?void 0:e.closest("table"))??null,cl=e=>{if(!e)return null;const r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(r==null?void 0:r.closest("td, th"))??null},Pu=e=>Array.from(e.querySelectorAll("th, td")),dl=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),o=e.closest("tr");return!o||o!==a[a.length-1]?!1:e===o.cells[o.cells.length-1]},_u=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},Xn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},bo=e=>{const r=Fu(e);if(r.length>=Dr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return fo(a,0,e)}return nl(e,Array.from(e.rows).indexOf(n))},zu=e=>{const r=Yn(e)-1;return r<0?!1:al(e,r)},mo=e=>{ll(e)},Wu=(e,r,n)=>{const a=qn(e,1,Dr),o=qn(r,1,Un),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},ul=()=>'<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>',ln=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),fl=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),ju=e=>e.replace(/[<>]/g,"").toLowerCase(),qu=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),Uu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Vu=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},Kn=(e,r)=>r.test(e),Yu=e=>Kn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),Xu=e=>Kn(e,/font-style\s*:\s*italic/i),Ku=e=>Kn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),Gu=e=>Kn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Gn=(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)},Zn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Zu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},bl=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"},Qu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Uu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Ju=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&&(Yu(a)&&Gn(n,"strong"),Xu(a)&&Gn(n,"em"),Ku(a)&&Gn(n,"u"),Gu(a)&&Gn(n,"s"))})},Ru=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Zu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=bl(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(bl(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=>{Qu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},ef=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,tf=e=>{const r=Vu(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()),Ju(o),Ru(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"){Zn(d),c.forEach(l);return}if(!qu.has(u)){Zn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=ef(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Du.has(u)){Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase();if(u==="td"||u==="th"){["colspan","rowspan"].includes(f)||d.removeAttribute(b.name);return}d.removeAttribute(b.name)}),u==="table"&&d.classList.add("rich-table"),c.forEach(l);return}if(Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase(),g=b.value;if(f.startsWith("on")||f==="style"||f==="class"){d.removeAttribute(b.name);return}if(f==="lang"||f.startsWith("data-")||f.startsWith("mso-")){d.removeAttribute(b.name);return}if((f==="href"||f==="src")&&/^\s*javascript:/i.test(g)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&f!=="href"&&f!=="src"&&f!=="alt"&&(["href","src","alt","target","rel"].includes(f)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){Zn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){Zn(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()},ho=e=>ln(e).replace(/\r\n?/g,`
25
- `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),rf=e=>new RegExp("\\p{L}","u").test(e),po=(e,r)=>{const n=e.trim();return!n||!rf(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===fl(n)},ml=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",ul())}(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 hl({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full"}){const i=s.useId(),c=o||i,d=s.useCallback(()=>document,[]),u=s.useRef(null),m=s.useRef(null),b=s.useRef(new Map),f=s.useRef(null),g=s.useRef(!1),p=s.useRef(e??""),S=s.useRef(r),v=s.useRef(()=>{}),C=s.useRef(!1),[T,E]=s.useState(()=>!e||e.trim()===""),[O,N]=s.useState(new Set),[x,M]=s.useState(null),[w,P]=s.useState(""),[X,K]=s.useState(""),[D,G]=s.useState(""),[U,ae]=s.useState(""),[Q,R]=s.useState(3),[V,Y]=s.useState(3),[ue,L]=s.useState(!0),[B,ce]=s.useState(!1),[H,oe]=s.useState(l==="full"),[k,te]=s.useState(null),[z,I]=s.useState(null),de=s.useRef(null),re=s.useRef(!1),q=s.useRef(null),y=s.useCallback(()=>g.current?m.current:u.current,[]);s.useEffect(()=>{S.current=r},[r]);const $=s.useCallback(()=>{const W=window.getSelection(),Z=y();if(!W||!Z||W.rangeCount===0||W.isCollapsed)return"";const me=W.getRangeAt(0);return!Z.contains(me.startContainer)||!Z.contains(me.endContainer)?"":W.toString()},[y]);s.useEffect(()=>{const W=e??"";if(C.current&&W===p.current){C.current=!1,E(!W||W.trim()==="");return}C.current=!1,p.current=W;const Z=[u.current,m.current].filter(pe=>!!pe);Z.forEach(pe=>{pe.innerHTML!==W&&(pe.innerHTML=W)}),E(!W||W.trim()===""),Z.forEach(pe=>mo(pe));const me=Z.map(pe=>ml(pe));return()=>me.forEach(pe=>pe())},[e]),s.useEffect(()=>{var pe,Ee;g.current=B;let W,Z=0,me;if(B){const ye=u.current;ye&&(p.current=Vn(ye));const Pe=()=>{var Ze;const Ie=m.current;if(!Ie){Z=requestAnimationFrame(Pe);return}Ie.innerHTML!==p.current&&(Ie.innerHTML=p.current),W=ml(Ie),mo(Ie),E(((Ze=Ie.textContent)==null?void 0:Ze.trim())===""),me=setTimeout(()=>Ie.focus(),60)};Z=requestAnimationFrame(Pe)}else{const ye=m.current,Pe=u.current,Ie=ye?Vn(ye):p.current,Ze=p.current;p.current=Ie,Pe&&Pe.innerHTML!==Ie&&(Pe.innerHTML=Ie),Ie!==Ze&&S.current(Ie),E(((Ee=(pe=ye??Pe)==null?void 0:pe.textContent)==null?void 0:Ee.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),me&&clearTimeout(me),W==null||W()}},[B]);const ee=s.useCallback(()=>{const W=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;W.forEach(pe=>{try{d().queryCommandState(pe)&&Z.add(pe)}catch{return}});try{const pe=ju(d().queryCommandValue("formatBlock"));pe&&Z.add(`formatBlock:${pe}`)}catch{}const me=$();po(me,"uppercase")&&Z.add("__upper"),po(me,"lowercase")&&Z.add("__lower"),po(me,"capitalize")&&Z.add("__cap"),N(Z)},[$,d]),fe=()=>{var Z;const W=y();W&&(p.current=Vn(W),C.current=!0,S.current(p.current),E(((Z=W.textContent)==null?void 0:Z.trim())===""))};v.current=fe;const ie=s.useCallback(()=>{q.current&&(clearTimeout(q.current),q.current=null),de.current&&(ol(de.current),de.current=null),re.current=!1,te(null),I(null)},[]),he=s.useCallback(()=>{q.current&&(clearTimeout(q.current),q.current=null)},[]),Te=s.useCallback(()=>{he(),q.current=setTimeout(()=>{re.current||ie()},280)},[he,ie]);s.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]);const De=s.useCallback(W=>{const Z=de.current;if(!Z||!Z.isConnected){ie();return}const me=(k==null?void 0:k.rowIndex)??(z==null?void 0:z.rowIndex)??-1,pe=(k==null?void 0:k.colIndex)??(z==null?void 0:z.colIndex)??-1;Bu(W,Z,me,pe,y()),ie(),v.current(),ee()},[y,ie,ee,z,k]),ft=s.useCallback(W=>{if(z)return;const Z=W.currentTarget,me=W.target;if(me.closest(".rich-table-action-bar, .rich-table-context-menu")){he();return}const pe=me.closest("td, th");if(!pe||!Z.contains(pe)){Te();return}const Ee=pe.closest("tr"),ye=pe.closest("table");if(!Ee||!ye||!Z.contains(ye)){Te();return}he(),ye.classList.add("rich-table"),de.current=ye,sl(ye,Ee,pe.cellIndex),te(Iu(ye,Ee,pe))},[he,Te,z]),Ct=s.useCallback(W=>{const Z=W.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){he();return}Te()},[he,Te]),nt=s.useCallback(W=>{const Z=W.currentTarget,pe=W.target.closest("td, th");if(!pe||!Z.contains(pe))return;const Ee=pe.closest("tr"),ye=pe.closest("table");if(!Ee||!ye||!Z.contains(ye))return;W.preventDefault(),ye.classList.add("rich-table"),de.current=ye;const Pe=Array.from(ye.rows).indexOf(Ee),Ie=pe.cellIndex;sl(ye,Ee,Ie),te(null),I({x:W.clientX,y:W.clientY,rowIndex:Pe,colIndex:Ie})},[]);s.useEffect(()=>{if(!k&&!z)return;const W=()=>Te();return window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[Te,z,k]),s.useEffect(()=>{if(!z)return;const W=Z=>{const me=Z.target;me instanceof Element&&me.closest(".rich-table-context-menu")||I(null)};return window.addEventListener("mousedown",W),()=>window.removeEventListener("mousedown",W)},[z]);const st=W=>{if(!W){const Z=u.current;Z&&(p.current=Vn(Z))}ce(!W)},le=(W,Z)=>{var me;(me=y())==null||me.focus(),d().execCommand(W,!1,Z),fe(),ee()},Se=W=>{le("formatBlock",W)},ne=()=>{var W;(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),fe(),ee()},Le=()=>{const W=window.getSelection();W&&W.rangeCount>0&&(f.current=W.getRangeAt(0).cloneRange())},Oe=()=>{const W=window.getSelection();W&&f.current&&(W.removeAllRanges(),W.addRange(f.current))},Ve=W=>{if(Le(),W==="link"){const Z=window.getSelection();K(Z&&!Z.isCollapsed?Z.toString():""),P("")}W==="image"&&(G(""),ae("")),W==="table"&&(R(3),Y(3),L(!0)),M(W)},je=()=>{var pe;if(!w.trim())return;Oe(),(pe=y())==null||pe.focus();const W=window.getSelection(),me=(W&&!W.isCollapsed?W.toString():"")||X.trim()||w.trim();d().execCommand("insertHTML",!1,`<a href="${ln(w.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${ln(me)}</a>`),fe(),M(null)},Be=(W,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${ln(W)}" alt="${ln(Z)}" class="rich-img" />${ul()}</span>`,et=()=>{var W;D.trim()&&(Oe(),(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,Be(D.trim(),U.trim())),fe(),M(null))},ot=()=>{var W;Oe(),(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,Wu(Q,V,ue)),fe(),M(null)},Ht=(W,Z=1200,me=1200,pe=.72)=>new Promise((Ee,ye)=>{const Pe=new FileReader;Pe.onerror=ye,Pe.onload=Ie=>{var sr;const Ze=(sr=Ie.target)==null?void 0:sr.result,Qe=new Image;Qe.onerror=ye,Qe.onload=()=>{let{width:vt,height:Kt}=Qe;if(vt>Z||Kt>me){const Gt=Math.min(Z/vt,me/Kt);vt=Math.round(vt*Gt),Kt=Math.round(Kt*Gt)}const It=document.createElement("canvas");It.width=vt,It.height=Kt;const lr=It.getContext("2d");if(!lr){Ee(Ze);return}lr.drawImage(Qe,0,0,vt,Kt),Ee(It.toDataURL("image/jpeg",pe))},Qe.src=Ze},Pe.readAsDataURL(W)}),be=W=>{W.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!W.contains(Z.anchorNode)){const me=document.createRange();me.selectNodeContents(W),me.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(me)}},ge=s.useRef(()=>{});ge.current=W=>{const Z=y();Z&&(be(Z),d().execCommand("insertHTML",!1,W),mo(Z),Z.querySelectorAll("p").forEach(me=>{!(me.textContent??"").replace(/[\u00a0\s]+/g,"")&&!me.querySelector("img, hr, table")&&me.remove()}),fe(),ee())};const He=s.useRef(Ht);He.current=Ht;const We=s.useRef(Be);We.current=Be;const Fe=s.useCallback(W=>{if(!W||b.current.has(W))return;const Z=me=>{const pe=me.clipboardData;if(!pe)return;const Ee=pe.getData("text/html"),ye=pe.getData("text/plain");if(Ee||ye){me.preventDefault(),me.stopPropagation();try{const Qe=Ee?tf(Ee):ho(ye);if(!Qe){ye&&ge.current(ho(ye));return}ge.current(Qe)}catch{ye&&ge.current(ho(ye))}return}const Ie=Array.from(pe.items).find(Qe=>Qe.type.startsWith("image/"));if(!Ie)return;me.preventDefault(),me.stopPropagation();const Ze=Ie.getAsFile();Ze&&He.current(Ze).then(Qe=>{ge.current(We.current(Qe,"imagen"))})};W.addEventListener("paste",Z,!0),b.current.set(W,()=>{W.removeEventListener("paste",Z,!0),b.current.delete(W)})},[]),bt=s.useCallback(W=>{var me;const Z=u.current;Z&&Z!==W&&((me=b.current.get(Z))==null||me()),u.current=W,W&&Fe(W)},[Fe]),ct=s.useCallback(W=>{var me;const Z=m.current;Z&&Z!==W&&((me=b.current.get(Z))==null||me()),m.current=W,W&&Fe(W)},[Fe]);s.useEffect(()=>{const W=b.current;return()=>{W.forEach(Z=>Z()),W.clear()}},[]);const qe=W=>{const Z=window.getSelection(),me=y();if(!Z||!me||Z.rangeCount===0||Z.isCollapsed)return;const pe=Z.getRangeAt(0);if(!me.contains(pe.startContainer)||!me.contains(pe.endContainer))return;const Ee=pe.toString();if(!Ee)return;let ye=Ee;W==="uppercase"?ye=Ee.toLocaleUpperCase():W==="lowercase"?ye=Ee.toLocaleLowerCase():ye=fl(Ee),pe.deleteContents();const Pe=document.createTextNode(ye);pe.insertNode(Pe);const Ie=document.createRange();Ie.setStart(Pe,0),Ie.setEnd(Pe,ye.length),Z.removeAllRanges(),Z.addRange(Ie),f.current=Ie.cloneRange(),fe(),ee()},Ye=()=>{Le(),ee()},dt=()=>{const W=y();W&&ll(W),fe(),ee()},mt=()=>{requestAnimationFrame(()=>{var W;(W=y())==null||W.focus()})},mr=W=>{var Z,me;if((W.metaKey||W.ctrlKey)&&W.key==="Enter"){if(W.preventDefault(),W.stopPropagation(),W.repeat)return;(Z=y())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),fe(),ee();return}if(W.key==="Tab"){const pe=window.getSelection(),Ee=cl((pe==null?void 0:pe.anchorNode)??null),ye=y(),Pe=il(Ee);if(Ee&&Pe&&(ye!=null&&ye.contains(Ee))){W.preventDefault();const Ie=Pu(Pe),Ze=Ie.indexOf(Ee),Qe=Ze>=0?Ie[Ze+1]:null;if(Qe)Xn(Qe,ye,!0);else if(dl(Ee,Pe)){const sr=bo(Pe);sr&&Xn(sr,ye,!0)}fe(),ee();return}W.preventDefault(),(me=y())==null||me.focus(),d().execCommand("insertText",!1,"    "),fe(),ee();return}if(W.key==="Enter"&&!W.shiftKey&&!(W.metaKey||W.ctrlKey)){const pe=window.getSelection(),Ee=cl((pe==null?void 0:pe.anchorNode)??null),ye=y(),Pe=il(Ee);if(Ee&&Pe&&(ye!=null&&ye.contains(Ee))&&dl(Ee,Pe)&&_u(Ee)){W.preventDefault();const Ie=bo(Pe);Ie&&Xn(Ie,ye,!0),fe(),ee();return}}if(W.key==="Escape"){if(z){I(null);return}if(x){M(null);return}if(g.current){ce(!1);return}}x||(W.ctrlKey||W.metaKey)&&(W.key==="b"&&(W.preventDefault(),le("bold")),W.key==="i"&&(W.preventDefault(),le("italic")),W.key==="u"&&(W.preventDefault(),le("underline")),W.key==="k"&&(W.preventDefault(),Ve("link")))},ut=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ze=(W,Z,me,pe,Ee)=>{const ye=Ee??(O.has(me)||me==="__link"&&x==="link"||me==="__img"&&x==="image"||me==="__table"&&x==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:mt,onMouseDown:Pe=>{Pe.preventDefault(),pe?pe():le(me)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ye?"var(--primary)":"var(--text-secondary)",background:ye?"rgba(59,130,246,0.12)":"transparent"},children:W},me)},vn=W=>{const Z=W.target;if(Z.closest("[data-action='delete-img']")){W.preventDefault();const me=Z.closest(".rich-img-wrap");me&&(me.remove(),fe())}},ba=()=>{he(),re.current=!0},ht=()=>{re.current=!1,Te()},Mt=(W,Z,me,pe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${pe?" rich-table-action-btn--danger":""}`,title:W,"aria-label":W,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),De(me)},children:Z}),Tt=()=>typeof document>"u"||!k&&!z?null:pt.createPortal(t.jsxs(t.Fragment,{children:[k&&!z&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:k.bar.x,top:k.bar.y},onMouseEnter:ba,onMouseLeave:ht,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",k.rowIndex+1," · Col ",k.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Mt("Añadir fila abajo","+","table-row-add"),Mt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Mt("Añadir columna a la derecha","+","table-col-add"),Mt("Eliminar columna","−","table-col-del")]}),Mt("Eliminar tabla","Eliminar","table-delete",!0)]}),z&&t.jsx("div",{className:"rich-table-context-menu",style:{left:z.x,top:z.y},onMouseDown:W=>W.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([W,Z])=>t.jsx("button",{type:"button",onMouseDown:me=>{me.preventDefault(),De(Z)},children:W},Z))})]}),document.body),or=W=>t.jsxs(t.Fragment,{children:[x==="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:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:w,onChange:Z=>P(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),je()),Z.key==="Escape"&&M(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:X,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),je()),Z.key==="Escape"&&M(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:je,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:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Dr,value:Q,onChange:Z=>R(qn(Number(Z.target.value),1,Dr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ot()),Z.key==="Escape"&&M(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:Un,value:V,onChange:Z=>Y(qn(Number(Z.target.value),1,Un)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ot()),Z.key==="Escape"&&M(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:ue,onChange:Z=>L(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:ot,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:D,onChange:Z=>G(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),et()),Z.key==="Escape"&&M(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:U,onChange:Z=>ae(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),et()),Z.key==="Escape"&&M(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:et,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),jr=(W,Z)=>{const me=l==="compact",pe=!me||H||W;return t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:Z},"data-toolbar-variant":l,children:[me&&!W&&t.jsxs("button",{type:"button",title:H?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),oe(ye=>!ye)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:H?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[H?t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"}),H?"Ocultar herramientas":"Herramientas"]}),pe&&t.jsxs(t.Fragment,{children:[ze(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ze(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ze(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ze(t.jsx(j.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ze(t.jsx(j.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ze(t.jsx(j.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Ve("link")),ut(),ze(t.jsx(j.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ze(t.jsx(j.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),ut(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Se("p"),O.has("formatBlock:p")||O.has("formatBlock:div")),ze(t.jsx(j.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Se("h2"),O.has("formatBlock:h2")),ze(t.jsx(j.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Se("h3"),O.has("formatBlock:h3")),ze(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Se("blockquote"),O.has("formatBlock:blockquote")),ut(),ze(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),ut(),ze(t.jsx(j.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ze(t.jsx(j.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),ut(),ze(t.jsx(j.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ze(t.jsx(j.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ze(t.jsx(j.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ze(t.jsx(j.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),ut(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>qe("uppercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>qe("lowercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>qe("capitalize")),ut(),ze(t.jsx(j.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ze(t.jsx(j.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Ve("image")),ze(t.jsx(j.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Ve("table")),ze(t.jsx(j.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",ne),ut(),ze(t.jsx(j.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ze(t.jsx(j.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Se("p"))]}),ut(),t.jsx("button",{type:"button",title:W?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),st(W)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:W?t.jsx(j.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(j.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Tt(),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:bt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:mr,onKeyUp:Ye,onSelect:Ye,onMouseUp:Ye,onMouseMove:ft,onMouseLeave:Ct,onContextMenu:nt,onMouseDown:vn,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${T?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),or("var(--bg-input)"),jr(!1,"var(--bg-input)")]}),t.jsxs(Za,{open:B,onClose:()=>ce(!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:ct,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:mr,onKeyUp:Ye,onSelect:Ye,onMouseUp:Ye,onMouseMove:ft,onMouseLeave:Ct,onContextMenu:nt,onMouseDown:vn,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${T?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),or("var(--bg-input)"),jr(!0,"var(--bg-input)")]})]})}const pl="[a-zA-Z0-9._@-]+",go=new RegExp(`@(${pl})`,"g"),nf=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
23
+ </body></html>`,Ce=window.open("","_blank");Ce&&(Ce.document.write(ve),Ce.document.close())}const Da=()=>!nt||!yn?null:pt.createPortal(t.jsxs("div",{ref:Po,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...lm,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(ce?await ce():Pm(),pa(!1)))()},children:[t.jsx(W.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(Se?await Se():_m(),pa(!1)))()},children:[t.jsx(W.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Oa=()=>{const h=$&&ye.trim().length>0,D=he!=null&&he.length?he:h?[{key:"bql",label:"BQL",value:ye}]:[],Q=ie.filter(_=>{const se=_.trim();return se?!new Set(Pe.split(`
24
+ `).map(Ce=>Ce.trim()).filter(Boolean)).has(se):!1}).slice(0,8);return!de&&zo===0&&!$&&!nt?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[zo>0&&t.jsxs("button",{type:"button",onClick:xm,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"}),zo," filtros"]}),$&&t.jsxs("div",{ref:Bo,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ze){Qe(!1);return}Sa(),Qe(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:Ze?"var(--primary)":h?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||h?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[t.jsx(W.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",h&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:y}),D.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[D.slice(0,3).map(_=>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:[_.label,":"]}),t.jsx("span",{className:"truncate",children:_.value})]},_.key)),D.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",D.length-3]})]}),h&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Bi,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})}),Ze&&pt.createPortal(t.jsxs("div",{ref:ki,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...nm,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:[ee.map(_=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_.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:[_.icon,_.label]},_.label)),fe.length>0&&t.jsxs("button",{type:"button",onClick:()=>vt(_=>!_),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":sr,children:[t.jsx(W.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),lr.length>0&&t.jsxs("button",{type:"button",onClick:()=>It(_=>!_),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":Kt,children:[t.jsx(W.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Te?"var(--danger)":h?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Fo,value:Pe,rows:3,onChange:_=>jo(_.target.value,_.target),onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Ii(Pe)),_.key==="Escape"&&Qe(!1)},placeholder:T,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(_=>t.jsx("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_)},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:_},_))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Te?"var(--danger)":"var(--text-muted)"},children:Te??(h?`${D.length||1} filtro${(D.length||1)===1?"":"s"} activo${(D.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),D.map(_=>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:[_.label,":"]}),t.jsx("span",{className:"truncate",children:_.value})]},_.key))]}),Kt&&lr.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(W.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Gt([]),It(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(W.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),lr.map(_=>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:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:_})}),t.jsx("button",{type:"button",onClick:()=>Gt(se=>se.filter(ve=>ve!==_)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})})]},_))]}),sr&&fe.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:fe.map(_=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_.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:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:_.bql}),_.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:_.description})]},_.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[h&&t.jsxs("button",{type:"button",onClick:Bi,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ii(Pe),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(W.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),nt&&t.jsx("button",{ref:ga,type:"button","aria-haspopup":"menu","aria-expanded":yn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var se;const _=(se=ga.current)==null?void 0:se.getBoundingClientRect();_&&im({top:_.bottom+4,right:window.innerWidth-_.right}),pa(ve=>!ve)},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)] ${yn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiArrowDownTray,{className:"h-4 w-4"})}),de&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&mt==="visibility","aria-label":ae,title:ae,onClick:_=>Pi(_,"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)] ${Ye&&mt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ji=()=>{if(!Om)return null;const h=Yc(it,Zo);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${Y?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Zt===0?"0 filas":`${Hm}–${Im} de ${Zt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(ur,{value:String(Ut),onChange:D=>Bm(Number(D)),options:Vo.map(D=>({value:String(D),label:String(D)})),placeholder:"Filas",searchable:!1,disabled:a,height:V,padding:X,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:P}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||it<=1,onClick:()=>Qo(it-1),onMouseEnter:D=>{D.currentTarget.disabled||(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="transparent",D.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(W.HiChevronLeft,{className:"h-3.5 w-3.5"})}),h.map((D,Q)=>D==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>Qo(D),onMouseEnter:_=>{_.currentTarget.disabled||D===it||(_.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",_.currentTarget.style.color="var(--primary)")},onMouseLeave:_=>{_.currentTarget.style.background=D===it?"var(--primary)":"transparent",_.currentTarget.style.color=D===it?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:D===it?"var(--primary)":"transparent",color:D===it?"var(--primary-fg)":"var(--text-muted)"},children:D},D)),t.jsx("button",{disabled:a||it>=Zo,onClick:()=>Qo(it+1),onMouseEnter:D=>{D.currentTarget.disabled||(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="transparent",D.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(W.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},zm=()=>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:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((h,D)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${_e}`},children:[Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},"select-cell"),$t.map((Q,_)=>t.jsx("div",{role:"cell",className:Y?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Mi(D,_)}%`,minWidth:32}})},Q.key))]},D))})]})})]}),Ro="min-w-0 max-w-full overflow-hidden";return J&&Le&&!et?t.jsx(Cn,{rows:o,columns:Math.max(4,$t.length||7)}):!a&&r.length===0&&!_o?zm():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:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx(es.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:$i,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((h,D)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${_e}`},children:[Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},"select-cell"),$t.map((Q,_)=>{const se=Ea[Q.key],ve=se!==void 0,Ce=Q.key===Go;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:Y?"px-2 py-1.5":"px-3 py-2",style:ve?{position:"sticky",left:se,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${_e}`:`inset 0 -1px 0 ${_e}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Mi(D,_)}%`,minWidth:32}})},Q.key)})]},D))})]})})}),Ji()]}):!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:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()})})}),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:_e,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??t.jsx(W.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx(es.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:$i,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:qi.map((h,D)=>{const Q=n(h),_=Ki(S==null?void 0:S(h)),se=D>0?Ki(S==null?void 0:S(qi[D-1])):null,ve=_&&_.key!==(se==null?void 0:se.key),Ce=Bt&&k.has(Q),$e=Bt&&(!E||E(h)),Ue=Xr?(m==null?void 0:m(h))??!0:!1,Ke=Ue&&Wi.has(Q),yt=!!d||g&&Ue,rt=Ce&&M?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":D%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[ve&&t.jsx("div",{role:"row",className:`grid ${_.className??""}`,style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},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:_.label}),_.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:_.description})]})})})}),t.jsxs("div",{role:"row",onClick:yt?xe=>{const Ae=xe.target;if(!(Ae!=null&&Ae.closest('[data-dt-disable-row-click="true"]'))){if(g&&Ue){Ui(Q);return}d==null||d(h)}}:void 0,className:`grid transition-colors ${yt?"cursor-pointer":""} ${H?H(h):""}`,style:{gridTemplateColumns:Kr,"--dt-row-bg":rt,"--dt-sticky-bg":rt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${_e}`},onMouseEnter:xe=>{Ce||(xe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),xe.currentTarget.style.setProperty("--dt-sticky-bg",Fm))},onMouseLeave:xe=>{xe.currentTarget.style.setProperty("--dt-row-bg",rt),xe.currentTarget.style.setProperty("--dt-sticky-bg",rt)},children:[Xr&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},"data-dt-disable-row-click":"true",children:Ue&&t.jsx("button",{type:"button","aria-label":Ke?"Contraer fila":"Desplegar fila","aria-expanded":Ke,onClick:xe=>{xe.stopPropagation(),Ui(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:Ke?t.jsx(W.HiChevronDown,{className:"h-4 w-4"}):t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})}),Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Xo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},onClick:xe=>{xe.stopPropagation(),$e&&v(Q)},children:t.jsx(Mn,{size:"sm",checked:Ce,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:xe=>xe.stopPropagation(),onChange:()=>{$e&&v(Q)}})}),$t.map(xe=>{const Ae=Ea[xe.key],ke=Ae!==void 0,we=xe.key===Go,Ne=fr(xe);return t.jsx("div",{role:"cell","data-dt-column-key":xe.key,"data-dt-disable-row-click":xe.disableRowClick||Ne?"true":void 0,className:`${Ne?"px-2 py-1.5 justify-center text-center":`${Y?"px-2 py-1.5":"px-3 py-2"} ${Vi(xe.align)}`} flex min-w-0 items-center ${zc} ${xe.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...ke?{position:"sticky",left:Ae,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${_e}`:`inset 0 -1px 0 ${_e}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},children:t.jsx(ys,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:xe.cell(h)})})},xe.key)})]}),Ke&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${_e}`},children:u(h)})})]},Q)})})]})})}),Ji()]})}const Gc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Hn({title:e="Sin resultados",description:r,icon:n=t.jsx(W.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:o,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Gc[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||o)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}function Pt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function xs(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function Cr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function er(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function ws(e){const r=Cr(e),n=(r.getDay()+6)%7;return er(r,-n)}function Va(e){const r=ws(e);return Array.from({length:7},(n,a)=>er(r,a))}function Ns(e){const r=e.getDay();return r===0||r===6}function In(e){return e.filter(r=>!Ns(r))}function ks(e){return In(Va(e))}function Zc(e){const r=Cr(e),n=r.getDay();return n===6?er(r,-1):n===0?er(r,-2):r}function Ya(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=ws(r);return Array.from({length:42},(a,o)=>er(n,o))}function Xa(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Ss(e){return Xa(e).map(In)}function Qc(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function tr(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=xs(n.start);if(!a)return null;const o=xs(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function Es(e,r){const n={};for(const a of e){const o=tr(a,r);if(!o)continue;let l=Cr(o.start);const i=Cr(o.end);for(;l.getTime()<=i.getTime();){const c=Pt(l);n[c]||(n[c]=[]),n[c].push(a),l=er(l,1)}}return n}function Ka(e,r,n){if(r.length===0)return[];const a=Cr(r[0]),o=Cr(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const m=tr(d,n),b=tr(u,n),f=(m==null?void 0:m.start.getTime())??0,p=(b==null?void 0:b.start.getTime())??0;return f-p||d.title.localeCompare(u.title)});for(const d of c){const u=tr(d,n);if(!u||!Qc(u.start,u.end,a,o))continue;const m=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((m.getTime()-a.getTime())/864e5)),p=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),g=Math.max(1,p-f+1);let k=l.findIndex(v=>v<f);k<0?(k=l.length,l.push(f+g-1)):l[k]=f+g-1,i.push({item:d,lane:k,colStart:f,colSpan:g})}return i}function Lt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Jc(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Rc(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Cs(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ms(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?er(e,n*7):er(e,n)}const ed=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],Ts=["Lun","Mar","Mié","Jue","Vie"];function td({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=tr(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Ft,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function rd({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=tr(e),l=o?`${Lt(o.start)} → ${Lt(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function nd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=tr(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function $s({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function As({value:e,options:r,onChange:n}){return t.jsx("div",{className:"inline-flex overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:r.map((a,o)=>{const l=e===a.value;return t.jsxs("button",{type:"button",onClick:()=>n(a.value),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold transition-colors",style:{background:l?"var(--primary)":"var(--bg-card)",color:l?"var(--primary-fg, #fff)":"var(--text-secondary)",borderRight:o<r.length-1?"1px solid var(--border)":void 0},children:[a.icon,a.label]},a.value)})})}function ad({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:m,hideWeekends:b=!1,renderToolbarExtra:f,renderPill:p,renderDayCard:g,renderWeekBar:k,tableColumns:v,tableProps:A,onItemClick:E,onDayClick:M,loading:H=!1,emptyTitle:S="Sin eventos",emptyDescription:x="No hay eventos para los filtros seleccionados.",legend:C,legendInteractive:w=!0,activeLegendKeys:P,defaultActiveLegendKeys:V,onActiveLegendKeysChange:X,getItemLegendKey:O,overloadLabel:K="Sobrecarga de eventos",notice:q,showOverload:le=!0,layout:J="span",className:G="",showToolbar:U=!0}){const Y=m??(b?[...Ts]:[...ed]),ue=b?5:7,L=b?"grid grid-cols-5":"grid grid-cols-7",B=s.useMemo(()=>(C??[]).map(ce=>ce.label),[C]),[de,I]=s.useState(()=>V??B),oe=s.useMemo(()=>P??(B.length>0?de:[]),[P,B.length,de]),N=s.useMemo(()=>new Set(oe),[oe]),R=ce=>{P===void 0&&I(ce),X==null||X(ce)},ae=ce=>{w&&(N.has(ce)?R(oe.filter(Se=>Se!==ce)):R([...oe,ce]))},$=s.useMemo(()=>{if(!w||B.length===0)return e;const ce=new Set(B);return e.filter(Se=>{const re=(O==null?void 0:O(Se))??Se.status;return!re||!ce.has(re)?!0:N.has(re)})},[e,w,B,N,O]),ne=s.useMemo(()=>Es($,c),[$,c]),te=s.useMemo(()=>{const ce=Ya(r);return b?In(ce):ce},[r,b]),j=s.useMemo(()=>{const ce=Ya(r);return b?Ss(ce):Xa(ce)},[r,b]),y=s.useMemo(()=>b?ks(r):Va(r),[r,b]),T=Pt(r),ee=ne[T]??[],fe=s.useMemo(()=>Ka($,y,c),[$,y,c]),ie=s.useMemo(()=>fe.length===0?1:Math.max(...fe.map(ce=>ce.lane))+1,[fe]),he=s.useMemo(()=>j.map(ce=>{const Se=Ka($,ce,c),re=Se.length===0?0:Math.max(...Se.map(Le=>Le.lane))+1;return{days:ce,bars:Se,laneCount:re}}),[j,$,c]),Te=36,De=38,ft=s.useMemo(()=>{const ce=l==="month"?te:l==="week"?y:[r],Se=[];for(const re of ce){const Le=Pt(re),Oe=ne[Le]??[];Oe.length>=u&&Se.push([re,Oe])}return Se},[l,te,y,r,ne,u]),Ct=l==="month"?Jc(r):l==="week"?`${Lt(y[0])} – ${Lt(y[6])}`:Rc(r),nt=s.useMemo(()=>[{key:"title",header:"Título",cell:ce=>ce.title},{key:"status",header:"Estado",cell:ce=>ce.status??"—"},{key:"range",header:"Rango",cell:ce=>{const Se=tr(ce,c);return Se?`${Lt(Se.start)} → ${Lt(Se.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ce=>ce.subtitle??"—"}],[c]),st=ce=>{if(n(ce),M){M(ce);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${G}`.trim(),children:[U?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":"Anterior",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ms(r,l,-1)),children:t.jsx(W.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:Ct}),t.jsx("button",{type:"button","aria-label":"Siguiente",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ms(r,l,1)),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f,t.jsx(As,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(W.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(W.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(As,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,C&&C.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:w?"group":void 0,"aria-label":w?"Filtrar por estado":void 0,children:C.map(ce=>{const Se=N.has(ce.label);return w?t.jsxs("button",{type:"button","aria-pressed":Se,onClick:()=>ae(ce.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Se?"var(--text-main)":"var(--text-muted)",background:Se?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Se?`1px solid color-mix(in srgb, ${ce.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Se?1:.45},title:Se?`Ocultar “${ce.label}”`:`Mostrar “${ce.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ce.color,boxShadow:Se?`0 0 0 2px color-mix(in srgb, ${ce.color} 25%, transparent)`:void 0},"aria-hidden":!0}),ce.label]},ce.label):t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ce.color},"aria-hidden":!0}),ce.label]},ce.label)})}):null,a==="calendar"&&q&&q.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:q.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[q.label,":"]})," ",q.items.join(", ")]}):a==="calendar"&&le&&ft.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[K,":"]})," ",ft.map(([ce,Se])=>`${Lt(ce)} (${Se.length})`).join(", ")]}):null,a==="table"?H||$.length>0?t.jsx(Ua,{columns:v??nt,data:$,getRowId:ce=>ce.id,loading:H,skeletonRows:8,emptyIcon:t.jsx(W.HiCalendarDays,{className:"h-10 w-10"}),emptyText:x,onRowClick:E,pageSize:25,compact:!0,...A}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:S,description:x}):null,a==="calendar"&&l==="month"&&J==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:L,style:{borderBottom:"1px solid var(--border)"},children:Y.map(ce=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ce},ce))}),t.jsx("div",{className:L,children:te.map(ce=>{const Se=Pt(ce),re=ne[Se]??[],Le=ce.getMonth()!==r.getMonth(),Oe=Math.max(0,re.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${ce.getDate()}`,onClick:()=>st(ce),onKeyDown:Ve=>{(Ve.key==="Enter"||Ve.key===" ")&&(Ve.preventDefault(),st(ce))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Le?"var(--text-muted)":"var(--text-main)"},children:ce.getDate()}),re.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:re.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[re.slice(0,d).map(Ve=>t.jsx($s,{item:Ve,day:ce,renderPill:p,onClick:()=>E==null?void 0:E(Ve)},Ve.id)),Oe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Oe," más"]}):null]})]},Se)})})]}):null,a==="calendar"&&l==="month"&&J==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:L,style:{borderBottom:"1px solid var(--border)"},children:Y.map(ce=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ce},ce))}),he.map(({days:ce,bars:Se,laneCount:re},Le)=>{const Oe=Math.min(re,d),Ve=Math.max(0,re-d),je=Te+Math.max(1,Oe)*De+(Ve>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:je,borderBottom:Le<he.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:L,style:{minHeight:je},children:ce.map(Be=>{const et=Pt(Be),ot=ne[et]??[],Ht=Be.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Be.getDate()}`,onClick:()=>st(Be),onKeyDown:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),st(Be))},className:"cursor-pointer p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",minHeight:je},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Ht?"var(--text-muted)":"var(--text-main)"},children:Be.getDate()}),ot.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ot.length}):null]})},et)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:Te,bottom:4},children:[Se.filter(Be=>Be.lane<d).map(Be=>{const et={left:`calc(${Be.colStart/ue*100}% + 4px)`,width:`calc(${Be.colSpan/ue*100}% - 8px)`,top:2+Be.lane*De,height:De-6,pointerEvents:"auto"};return p?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(Be.item,{day:ce[Be.colStart]})})},`${Be.item.id}-${Be.colStart}-${Le}`):k?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:k(Be.item)})},`${Be.item.id}-${Be.colStart}-${Le}`):t.jsx(td,{item:Be.item,style:et,onClick:()=>E==null?void 0:E(Be.item)},`${Be.item.id}-${Be.colStart}-${Le}`)}),Ve>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+Oe*De,color:"var(--text-muted)"},children:["+",Ve," más"]}):null]})]},`week-${Le}-${Pt(ce[0])}`)})]}):null,a==="calendar"&&l==="week"&&J==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:L,children:y.map(ce=>{const Se=Pt(ce),re=ne[Se]??[],Le=Math.max(0,re.length-d);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>st(ce),children:[Cs(ce),t.jsx("span",{className:"mt-1 block text-sm",children:ce.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[re.slice(0,d).map(Oe=>t.jsx($s,{item:Oe,day:ce,renderPill:p,onClick:()=>E==null?void 0:E(Oe)},Oe.id)),Le>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Le," más"]}):null]})]},Se)})})}):null,a==="calendar"&&l==="week"&&J==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${L} border-b`,style:{borderColor:"var(--border)"},children:y.map(ce=>t.jsx("button",{type:"button",className:"px-3 py-2 text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)",borderRight:"1px solid var(--border)"},onClick:()=>st(ce),children:Cs(ce)},Pt(ce)))}),t.jsxs("div",{className:`relative ${L}`,style:{minHeight:Math.max(220,ie*56+24)},children:[y.map(ce=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Pt(ce)}`)),fe.map(ce=>{const Se={left:`calc(${ce.colStart/ue*100}% + 4px)`,width:`calc(${ce.colSpan/ue*100}% - 8px)`,top:12+ce.lane*56,height:48};return k?t.jsx("div",{className:"absolute overflow-hidden",style:Se,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:k(ce.item)})},`${ce.item.id}-${ce.colStart}`):t.jsx(nd,{item:ce.item,style:Se,onClick:()=>E==null?void 0:E(ce.item)},`${ce.item.id}-${ce.colStart}`)}),fe.length===0&&!H?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:x}):null]})]}):null,a==="calendar"&&l==="day"?ee.length>0||H?t.jsxs("div",{className:"space-y-3",children:[H&&ee.length===0?t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,ee.map(ce=>g?t.jsx("div",{children:g(ce)},ce.id):t.jsx(rd,{item:ce,onClick:()=>E==null?void 0:E(ce)},ce.id))]}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:S,description:x}):null]})}function Ls(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 od(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Ls(e)}function sd(e){return typeof e=="function"?e():e}function Ga({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(W.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(W.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:p,type:g="button",...k}){const[v,A]=s.useState(!1),E=s.useRef(null);s.useEffect(()=>()=>{E.current&&window.clearTimeout(E.current)},[]);function M(S){A(!0),d==null||d(S),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{A(!1),E.current=null},r)}async function H(S){var C;if(c&&S.stopPropagation(),p==null||p(S),S.defaultPrevented)return;const x=sd(e);if(x)try{await od(x),M(x)}catch(w){try{Ls(x),M(x)}catch(P){u==null||u(P,x);return}(C=navigator.clipboard)!=null&&C.writeText||u==null||u(w,x)}}return t.jsxs("button",{...k,type:g,onClick:H,title:v?a:n,"aria-label":k["aria-label"]??(v?a:n),"data-copied":v?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:v?"scale(1.15)":"scale(1)"},children:v?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??f:f})]})}function ld({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(Ga,{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 Bn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function id({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(W.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:Bn(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:Bn(o),padding:Bn(l)}})]})}function cd({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((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[o&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Bn(d)},children:o}),t.jsx(ur,{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 dd={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Fn=180,ud="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Za({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:b=!0,closeOnEscape:f=!0,showCloseButton:p=!0,placement:g="center",bodyClassName:k="px-6 py-5",panelClassName:v="",backdropClassName:A=ud,contentClassName:E="p-4",ariaLabel:M,frameless:H=!1,disabled:S=!1}){const[x,C]=s.useState(!1),[w,P]=s.useState(!1),V=s.useRef(null);if(s.useEffect(()=>(e?(V.current&&clearTimeout(V.current),C(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),V.current=setTimeout(()=>C(!1),Fn+40)),()=>{V.current&&clearTimeout(V.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const J=G=>{G.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[f,r,e]),!x)return null;const X=n||a||o||l||p,O=u??dd[d],K=g==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",q=g==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",le=w?"translateY(0) scale(1)":g==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return pt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":M??n,className:`fixed inset-0 flex ${K} ${E}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${A}`,onClick:b?r:void 0,style:{opacity:w?1:0,transition:`opacity ${Fn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${H?"shadow-none":"shadow-2xl"} ${q} ${v}`,style:{maxWidth:O,background:H?"transparent":"var(--bg-card)",border:H?"none":"1px solid var(--border)",opacity:w?1:0,transform:le,transition:`opacity ${Fn}ms ease, transform ${Fn}ms ease`},onClick:J=>J.stopPropagation(),children:[S&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),X&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[o&&t.jsx("div",{className:"flex-shrink-0",children:o}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,p&&t.jsx(Ge,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${k}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const fd={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 bd({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=fd[l];return t.jsx(Za,{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(Ge,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ge,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ge,{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 md(e){return e?typeof e=="function"?e():e:""}function hd(e){return/^https?:\/\//i.test(e)}function Ds(e,r){try{return new URL(e,r).toString()}catch{return e}}function pd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||hd(l))return l;const i=md(n);return i?Ds(l,i):a&&typeof window<"u"?Ds(l,window.location.origin):l}function gd({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(W.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Ga,{...c,value:()=>pd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const vd={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 yd(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=vd[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 xd=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function wd({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return s.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>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&&!xd.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 Nd({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(ur,{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 kd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Qa={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Sd({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[b,f]=s.useState(null),p=s.useRef(null);p.current=b;const[g,k]=s.useState({}),[v,A]=s.useState(null),E=s.useRef(null);E.current=v;const[M,H]=s.useState({}),[S,x]=s.useState({}),C=s.useRef(new Set),w=s.useRef(null);s.useEffect(()=>{var B;const L=document.activeElement;(!L||L===document.body)&&((B=w.current)==null||B.focus({preventScroll:!0}))},[]);const P=e.map(L=>{var B,de,I;return`${L.key}:${((I=(de=(B=L.editable)==null?void 0:B.select)==null?void 0:de.options)==null?void 0:I.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(L=>{var I,oe;const B=(oe=(I=L.editable)==null?void 0:I.select)==null?void 0:oe.options;if(!B)return;const de=M[L.key];(!C.current.has(L.key)||(de==null?void 0:de.length)===0&&B.length>0)&&(C.current.add(L.key),H(N=>({...N,[L.key]:B})))})},[P]);const V=s.useCallback(async(L,B)=>{if(C.current.has(L))return;C.current.add(L);const{url:de,fetchOptions:I}=B.select??{};if(!(!de&&!I)){x(oe=>({...oe,[L]:!0}));try{let oe=[];if(I)oe=await I();else if(de){const N=await fetch(de);if(!N.ok)throw new Error("fetch failed");oe=await N.json()}H(N=>({...N,[L]:oe}))}catch{H(oe=>({...oe,[L]:[]}))}finally{x(oe=>({...oe,[L]:!1}))}}},[]),X=s.useRef(i);X.current=i;const O=s.useRef(a);O.current=a;const K=s.useRef(n);K.current=n;const q=s.useRef(e);q.current=e;const le=s.useRef(o);le.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const L=e.find(B=>B.selectable!==!1);L&&f({rowId:n(r[0]),colKey:L.key})}},[]),s.useEffect(()=>{if(!b)return;const L=w.current;if(!L)return;const B=L.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!B)return;const de=L.querySelector('[role="rowgroup"]');B.style.scrollMarginTop=`${(de==null?void 0:de.offsetHeight)??0}px`;const I=L.querySelector('[role="row"]');let oe=0;I&&I.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(N=>{N.style.position==="sticky"&&N.style.left!==""&&(oe=Math.max(oe,parseFloat(N.style.left)+N.offsetWidth))}),B.style.scrollMarginLeft=`${oe}px`,B.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=s.useCallback(L=>{var oe;const B=q.current,de=new Set,I=[];(oe=w.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(N=>{const R=N.dataset.cellId.split(":")[0];de.has(R)||(de.add(R),I.push(R))}),f(N=>{if(!N)return N;const R=B.findIndex(te=>te.key===N.colKey),ae=I.indexOf(N.rowId);let $=R,ne=ae;if(L==="up")ne=Math.max(0,ae-1);else if(L==="down")ne=Math.min(I.length-1,ae+1);else if(L==="left"){let te=R-1;for(;te>=0&&B[te].selectable===!1;)te--;te>=0&&($=te)}else if(L==="right"){let te=R+1;for(;te<B.length&&B[te].selectable===!1;)te++;te<B.length&&($=te)}return $===R&&ne===ae?N:{rowId:I[ne],colKey:B[$].key}})},[]),G=s.useCallback((L=!0)=>{const B=d.current;m(null),B&&f(B),L&&setTimeout(()=>{var de;return(de=w.current)==null?void 0:de.focus({preventScroll:!0})},0)},[]),U=s.useCallback(async(L,B,de)=>{var ie;const I=q.current.find(he=>he.key===B);if(!(I!=null&&I.editable))return;const{field:oe,type:N,mask:R,validate:ae}=I.editable,$=N==="number"?de===""?null:Number(de):de;if(R){const he=yd(de,R);if(he){k(Te=>({...Te,[`${L}:${B}`]:he}));return}}if(ae){const he=ae($);if(he){k(Te=>({...Te,[`${L}:${B}`]:he}));return}}const ne=K.current,te=X.current.find(he=>ne(he)===L);if(!te)return;const j=te[oe];m(null),k(he=>{const Te={...he};return delete Te[`${L}:${B}`],Te});const y=X.current,T=y.findIndex(he=>ne(he)===L),ee=y[Math.min(y.length-1,T+1)];if(f({rowId:ne(ee),colKey:B}),setTimeout(()=>{var Te,De;const he=document.activeElement;(!he||he===document.body||(Te=w.current)!=null&&Te.contains(he))&&((De=w.current)==null||De.focus({preventScroll:!0}))},0),String(j??"")===String($??""))return;const fe={...te,[oe]:$};c(he=>he.map(Te=>ne(Te)===L?fe:Te)),A({rowId:L,colKey:B});try{await((ie=O.current)==null?void 0:ie.call(O,{row:te,rowId:L,field:oe,oldValue:j,newValue:$}))}catch{c(he=>he.map(Te=>ne(Te)===L?te:Te)),k(he=>({...he,[`${L}:${B}`]:"Error al guardar. Intenta de nuevo."}))}finally{A(null)}},[]),Y=s.useCallback(L=>{if(E.current){L.preventDefault();return}if(d.current)return;const B=p.current;if(!(!B||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(L.key)))switch(L.preventDefault(),L.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(L.shiftKey?"left":"right");break;case"Enter":{const I=q.current.find(oe=>oe.key===B.colKey);I!=null&&I.editable&&!le.current?(m(B),I.editable.type==="select"&&!C.current.has(B.colKey)&&V(B.colKey,I.editable)):J("down");break}}},[J,V]),ue=s.useMemo(()=>e.map(L=>{if(!L.editable||o){const de={...L};if(delete de.editable,delete de.selectable,L.selectable===!1)return{...de,disableRowClick:!0};const I=de.cell;return{...de,className:`relative ${de.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const N=n(oe),R=(b==null?void 0:b.rowId)===N&&(b==null?void 0:b.colKey)===L.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${N}:${L.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var ae;E.current||(f({rowId:N,colKey:L.key}),(ae=w.current)==null||ae.focus({preventScroll:!0}))}}),R&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Qa}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:I(oe)})]})}}}const B=L.editable;return{...L,className:`relative ${L.className??""}`.trim(),disableRowClick:!0,cell:de=>{const I=n(de),oe=L.key,N=(u==null?void 0:u.rowId)===I&&(u==null?void 0:u.colKey)===oe,R=(b==null?void 0:b.rowId)===I&&(b==null?void 0:b.colKey)===oe,ae=g[`${I}:${oe}`],$=(v==null?void 0:v.rowId)===I&&(v==null?void 0:v.colKey)===oe,ne=de[B.field],te=String(ne??""),j=()=>{var T;E.current||(f({rowId:I,colKey:oe}),m({rowId:I,colKey:oe}),(T=w.current)==null||T.focus({preventScroll:!0}),B.type==="select"&&!C.current.has(oe)&&V(oe,B))};if(N){const T=B.type==="select"?t.jsx(Nd,{initialValue:te,options:M[oe]??[],loading:S[oe]??!1,onCommit:ee=>U(I,oe,ee),onCancel:G}):t.jsx(wd,{initialValue:te,type:B.type??"text",mask:B.mask,onCommit:ee=>U(I,oe,ee),onCancel:G});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:kd,onClick:ee=>ee.stopPropagation(),children:T})}const y=L.cell(de);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${I}:${oe}`,className:`peer absolute inset-0 z-10 ${$?"cursor-wait":"cursor-pointer"}`,onClick:j}),R&&!$&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Qa}),$&&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:Qa,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:ae?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(W.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:ae})]}):t.jsx("span",{className:"truncate",children:y})}),!$&&t.jsx(W.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,u,b,v,g,M,S,n,U,G,V]);return t.jsx("div",{ref:w,tabIndex:0,onKeyDown:Y,onBlur:L=>{var B;(B=w.current)!=null&&B.contains(L.relatedTarget)||setTimeout(()=>{var I,oe;const de=document.activeElement;de&&((I=de.closest)!=null&&I.call(de,"[data-bonsaif-select-dropdown]"))||(oe=w.current)!=null&&oe.contains(de)||G(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(Ua,{...l,columns:ue,data:i,getRowId:n})})}function lt(e){if(e)return new Date(`${e}T12:00:00`)}function Dt(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 Mr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Os(e){return e.map(r=>lt(r)).filter(r=>!!r)}function Ed(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Dt));return Array.from(r).sort()}function Ja(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Hs(e){const r=lt(e);if(!r)return e;const n=Ja(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 Ra={weekend:{dayOfWeek:[0,6]}},eo={weekend:"bonsaif-weekend"};function to({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 Cd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Md={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Td({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?Cd:null,...o?Md:null,...l?{fontWeight:800}:null,...n.style}})}function $d({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:lt(e),to:lt(r)},f=lt(a),[p,g]=s.useState(()=>lt(o||e)??new Date);s.useEffect(()=>{const M=lt(o||e);M&&g(M)},[o,e]);const k=s.useMemo(()=>{if(l<=1)return Mr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(p));const M=new Date(p.getFullYear(),p.getMonth()+l-1,1),H=p.getFullYear()===M.getFullYear(),S=new Intl.DateTimeFormat("es-MX",{month:"short",...H?{}:{year:"numeric"}}).format(p),x=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(M);return`${Mr(S)} – ${Mr(x)}`},[p,l]);function v(){g(new Date(p.getFullYear(),p.getMonth()-1,1))}function A(){g(new Date(p.getFullYear(),p.getMonth()+1,1))}const E=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:v,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:A,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsx(Ba.DayPicker,{mode:"range",selected:b,month:p,onMonthChange:g,onSelect:M=>{const H=M!=null&&M.from?Dt(M.from):e,S=M!=null&&M.to?Dt(M.to):"";n({startDate:H,endDate:S})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ra,modifiersClassNames:eo,components:{DayButton:Td,Weekday:to},classNames:{root:"bonsaif-range-daypicker w-full",months:E,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:M=>`${Mr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(M))} ${M.getFullYear()}`,formatWeekdayName:Ja}})]}),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 Is({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 Bs(e,r){const n=lt(e),a=lt(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(Dt(c)),c.setDate(c.getDate()+1);return i}function Fs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,o=new Date(e);return o.setHours(12,0,0,0),o.setDate(o.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(o);return c.setDate(o.getDate()+i),c})}function an(e,r,n){const a=new Set(e);for(const o of r)n==="add"?a.add(o):n==="remove"||a.has(o)?a.delete(o):a.add(o);return Array.from(a).sort()}function Ad(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Ld(e,r,n){return!!(r&&e<r||n&&e>n)}function Ps({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),m=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(S=>{let x=S;if(c){const C=b.current.filter(P=>!P.startsWith(c)),w=S.filter(P=>P.startsWith(c));x=[...C,...w].sort()}r==null||r(Ad(x,l))},[l,r,c]),p=s.useCallback((S,x=!1)=>Ld(S,a,o)?!0:!(!(i!=null&&i(S))||x&&b.current.includes(S)),[i,o,a]),g=s.useCallback(S=>S.filter(x=>!p(x)),[p]),k=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const S=()=>k();return window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),()=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S)}},[k]);const v=s.useCallback((S,x,C,w)=>{const P=g(Bs(S,x));f(C==="add"?an(w,P,"add"):an(w,P,"remove"))},[f,g]),A=s.useCallback((S,x)=>{if(n||x.button!==0)return;const C=Dt(S);if(p(C,!0)||x.shiftKey)return;m.current=!0;const w=[...b.current],P=w.includes(C)?"remove":"add";P==="add"&&p(C)||(u.current={active:!0,mode:P,anchor:C,latest:C,baseline:w},d.current=C,v(C,C,P,w),x.preventDefault())},[v,n,p]),E=s.useCallback(S=>{const x=u.current;if(!(x!=null&&x.active)||n)return;const C=Dt(S);x.mode==="add"&&p(C)||x.latest!==C&&(x.latest=C,v(x.anchor,C,x.mode,x.baseline))},[v,n,p]),M=s.useCallback((S,x)=>{if(n)return;const C=Dt(S);if(!p(C,!0)){if(m.current&&!x.shiftKey){m.current=!1,x.preventDefault(),x.stopPropagation();return}if(m.current=!1,x.shiftKey&&d.current){x.preventDefault(),x.stopPropagation();const w=g(Bs(d.current,C));f(an(b.current,w,"add"));return}!b.current.includes(C)&&p(C)||(d.current=C,f(an(b.current,[C],"toggle")))}},[f,n,g,p]),H=s.useCallback(S=>{if(n)return;const x=g(Ed(S));if(!x.length)return;const C=x.every(w=>b.current.includes(w));f(an(b.current,x,C?"remove":"add")),d.current=x[0]??d.current},[f,n,g]);return{onDayPointerDown:A,onDayPointerEnter:E,onDayClick:M,toggleWeek:H,endDrag:k}}function on(e){return Fs(e,1)[0]}function _s(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Dd({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:p=!1}){const g=s.useMemo(()=>Os(e),[e]),k=s.useMemo(()=>new Set(e),[e]),v=lt(n),A=lt(a),[E,M]=s.useState(()=>lt(l||e[0])??new Date),[H,S]=s.useState(()=>on(lt(l||e[0])??new Date)),[x,C]=s.useState(u),w=d??x;function P(L){d===void 0&&C(L),m==null||m(L)}s.useEffect(()=>{const L=lt(l);L&&(M(L),S(on(L)))},[l]);const{onDayPointerDown:V,onDayPointerEnter:X,onDayClick:O,toggleWeek:K}=Ps({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),q=s.useMemo(()=>{if(p)return!0;const L=[];return v&&L.push({before:v}),A&&L.push({after:A}),o&&L.push(B=>o(Dt(B))),L.length>0?L:void 0},[p,o,A,v]),le=s.useCallback(L=>t.jsx(Is,{...L,className:`bonsaif-multi-day-btn ${L.className??""}`,onDayPointerDown:V,onDayPointerEnter:X,onDayClickSelect:O}),[O,V,X]),J=s.useMemo(()=>Fs(H,1),[H]),G=J[6],U=w==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(J[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(G)}`:Mr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(E));function Y(){if(w==="week"){const L=_s(H,-7);S(on(L)),M(L);return}M(new Date(E.getFullYear(),E.getMonth()-1,1))}function ue(){if(w==="week"){const L=_s(H,7);S(on(L)),M(L);return}M(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":w==="month",className:`bonsaif-cal-view-btn${w==="month"?" is-active":""}`,disabled:p,onClick:()=>{P("month"),M(H)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":w==="week",className:`bonsaif-cal-view-btn${w==="week"?" is-active":""}`,disabled:p,onClick:()=>{P("week"),S(on(E))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:Y,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:U}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:ue,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&w==="month"?" · Semana (nº)":"",w==="week"?" · Botón semana completa":""]}),w==="month"?t.jsx(Ba.DayPicker,{mode:"multiple",required:!1,selected:g,month:E,onMonthChange:M,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(L,B)=>{K(B)},disabled:q,className:"bonsaif-multi-daypicker",modifiers:Ra,modifiersClassNames:eo,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:le,Weekday:to},formatters:{formatWeekdayName:Ja}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(L=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(L)},`h-${Dt(L)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(L=>{const B=Dt(L),de=k.has(B),I=p||(n?B<n:!1)||(a?B>a:!1)||!!(o!=null&&o(B)),oe=B===Dt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${de?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${I?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:I,"aria-pressed":de,onPointerDown:N=>V(L,N),onPointerEnter:()=>X(L),onClick:N=>O(L,N),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:L.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(L)})]})},B)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>K(J),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(L=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(B=>B!==L)),title:`Quitar ${L}`,children:[Hs(L),t.jsx("span",{"aria-hidden":!0,children:"×"})]},L))})]})}):null]})}const Od=Array.from({length:12},(e,r)=>r);function Hd({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 b=s.useMemo(()=>Os(e),[e]),f=lt(o),p=lt(l),g=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[k,v]=s.useState(g);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function A(w){v(w),a==null||a(w)}const{onDayPointerDown:E,onDayPointerEnter:M,onDayClick:H}=Ps({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${k}-`}),S=s.useCallback(w=>t.jsx(Is,{...w,className:`bonsaif-year-day-btn ${w.className??""}`,onDayPointerDown:E,onDayPointerEnter:M,onDayClickSelect:H}),[H,E,M]),x=b.filter(w=>w.getFullYear()===k),C=u?!0:[...f?[{before:f}]:[],...p?[{after:p}]:[]];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:()=>A(k-1),children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>A(k+1),children:t.jsx(W.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:Od.map(w=>{const P=new Date(k,w,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Mr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(P))}),t.jsx(Ba.DayPicker,{mode:"multiple",required:!1,selected:x,month:P,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:C,className:"bonsaif-year-month-picker",modifiers:Ra,modifiersClassNames:eo,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:S,Weekday:to},formatters:{formatWeekdayName:V=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(V)}})]},`${k}-${w}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",k]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(w=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(P=>P!==w)),title:`Quitar ${w}`,children:[Hs(w),t.jsx("span",{"aria-hidden":!0,children:"×"})]},w))})]})}):null]})}const Id="bonsaif-ui:hide-tooltips";function zs(){window.dispatchEvent(new CustomEvent(Id))}function Bd(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Fd({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,b]=s.useState(!1),[f,p]=s.useState({}),g=s.useRef(null),k=s.useRef(null),v=s.useCallback(S=>{u(S),c==null||c(S)},[c]),A=s.useCallback(()=>{const S=g.current;if(!S)return;const x=S.getBoundingClientRect(),C=typeof a=="number"?a:x.width,w=typeof a=="number"?a:Math.max(x.width,180),P=n==="end"?Math.max(8,x.right-w):Math.min(x.left,window.innerWidth-w-8),V=window.innerHeight-x.bottom,X=V<240&&x.top>V?void 0:x.bottom+6,O=X===void 0?window.innerHeight-x.top+6:void 0;p({position:"fixed",zIndex:9999,left:P,top:X,bottom:O,width:Bd(typeof a=="number"?C:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;A();const S=C=>{var P,V;const w=C.target;!((P=g.current)!=null&&P.contains(w))&&!((V=k.current)!=null&&V.contains(w))&&v(!1)},x=C=>{C.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",S),window.addEventListener("keydown",x),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{document.removeEventListener("mousedown",S),window.removeEventListener("keydown",x),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[d,v,A]);const E=S=>{o||(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),v(!d))},M=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(zs(),v(!d))}}):e,H=d?t.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(S=>t.jsxs("div",{children:[S.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:S.disabled,onClick:()=>{var x;S.disabled||(zs(),(x=S.onSelect)==null||x.call(S),v(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:S.danger?"var(--danger)":"var(--text-main)"},children:[S.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:S.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:S.label}),S.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:S.description})]})]})]},S.id))}):null;return t.jsxs("span",{ref:g,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:E,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[M,m&&H?pt.createPortal(H,document.body):null]})}const Pd=180,Ws="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function _d({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:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:p="Descartar cambios",unsavedChangesDescription:g="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:A,disabled:E=!1,disabledMessage:M,children:H}){const[S,x]=s.useState(!1),[C,w]=s.useState(!1),[P,V]=s.useState(!1),X=s.useCallback(()=>{w(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>V(!0))})},[]),O=s.useCallback(()=>{V(!1),window.setTimeout(()=>w(!1),Pd)},[]),K=E||c,q=s.useCallback(()=>{if(!K){if(f){X();return}r()}},[K,f,r,X]),le=s.useCallback(()=>{V(!1),w(!1),A==null||A(),r()},[r,A]);if(s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(V(!1),w(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const G=U=>{if(U.key==="Escape"&&!K){if(C){O();return}q()}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[O,K,C,e,q]),!S)return null;const J=M!==void 0?M:c?"Guardando…":null;return pt.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${Ws}`,onClick:q}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ge,{variant:"icon",onClick:q,title:"Cerrar",disabled:K,children:t.jsx(W.HiXMark,{className:"w-5 h-5"})}),o&&t.jsx("div",{className:"flex-shrink-0",children:o}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ge,{variant:"secondary",size:"sm",onClick:q,disabled:K,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ge,{variant:"primary",size:"sm",icon:t.jsx(tc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||K,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:H}),K&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:J?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:J})]}):null})]}),C&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Ws} transition-opacity duration-200 ease-out ${P?"opacity-100":"opacity-0"}`,onClick:O}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${P?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ge,{variant:"icon",onClick:O,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":v,children:t.jsx(W.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:p}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:g}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ge,{variant:"secondary",onClick:O,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Ge,{variant:"secondary",onClick:le,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body)}const zd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Wd=/^\+?[0-9\s().-]+$/,jd=7,qd=15;function _t(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 ro(e){return _t(e)?!1:zd.test(String(e))}function no(e){if(_t(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Wd.test(r)&&n.length>=jd&&n.length<=qd}function Ud(e="Este campo es requerido."){return r=>_t(r)?e:void 0}function Vd(e="Ingresa un correo valido."){return r=>_t(r)||ro(r)?void 0:e}function Yd(e="Ingresa un telefono valido."){return r=>_t(r)||no(r)?void 0:e}function Xd(e,r){return n=>_t(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Kd(e,r){return n=>_t(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function Gd(e,r){return n=>{if(_t(n))return;const a=js(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Zd(e,r){return n=>{if(_t(n))return;const a=js(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Qd(e,r="El formato no es valido."){return n=>_t(n)||e.test(String(n))?void 0:r}function Jd(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 qs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Us=s.createContext&&s.createContext(qs),Rd=["attr","size","title"];function eu(e,r){if(e==null)return{};var n,a,o=tu(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 tu(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function Pn(){return Pn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Pn.apply(null,arguments)}function Vs(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 _n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Vs(Object(n),!0).forEach(function(a){ru(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function ru(e,r,n){return(r=nu(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function nu(e){var r=au(e,"string");return typeof r=="symbol"?r:r+""}function au(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 Ys(e){return e&&e.map((r,n)=>s.createElement(r.tag,_n({key:n},r.attr),Ys(r.child)))}function ao(e){return r=>s.createElement(ou,Pn({attr:_n({},e.attr)},r),Ys(e.child))}function ou(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=eu(e,Rd),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Pn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:_n(_n({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 Us!==void 0?s.createElement(Us.Consumer,null,n=>r(n)):r(qs)}function Xs(e){return ao({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 su(e){return ao({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 lu(e){return ao({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 Tr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Ft,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(W.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function $r({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function zn({className:e="",...r}){return t.jsx("input",{...r,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function oo({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:b="",required:f,...p}){const[g,k]=s.useState(()=>!!p.autoFocus),[v,A]=s.useState(!1),E=p.type==="password"&&u,M=E&&v?"text":p.type,H=!!o,S=H&&l!=="tooltip",x=H&&l!=="inline",C=!!n&&a==="tooltip"&&!S,w=m?f:void 0,P=H?"border-[var(--danger)] focus:border-[var(--danger)]":"",V=x?E?"pr-20":"pr-10":E?"pr-10":"",X=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,O=g||X,K={top:O?7:12,color:g?"var(--primary)":"var(--text-muted)",fontSize:O?10:13,fontWeight:O?600:400,textTransform:O?"uppercase":"none"},q=Y=>{var ue;k(!0),(ue=p.onFocus)==null||ue.call(p,Y)},le=Y=>{var ue;k(!1),(ue=p.onBlur)==null||ue.call(p,Y)},J=E?t.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>A(Y=>!Y),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(su,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(lu,{className:"h-[18px] w-[18px]"})})]}):null,G=x?t.jsx(Ft,{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)] ${E?"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(Xs,{className:"h-[18px] w-[18px]"})})}):null,U=t.jsx($r,{error:S?o:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...p,type:M,required:w,placeholder:" ","aria-invalid":H||p["aria-invalid"],"data-has-value":X?"true":void 0,className:`h-11 w-full pt-5 ${V} ${P} ${b}`,onFocus:q,onBlur:le}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:K,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:O?7:12},children:c}),G,J]}),U]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),C?t.jsx(Tr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),E?t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...p,type:M,required:w,"aria-invalid":H||p["aria-invalid"],className:`w-full ${V} ${P} ${b}`,onFocus:q,onBlur:le}),G,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...p,required:w,"aria-invalid":H||p["aria-invalid"],className:`w-full ${V} ${P} ${b}`}),G]}),U]})}function Ks(e){return e==null?"":String(e)}function iu({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,b]=s.useState(()=>Ks(c)),f=i!==void 0?Ks(i):m,p=n&&f.length>0&&!ro(f)?a:void 0,g=k=>{i===void 0&&b(k.currentTarget.value),d==null||d(k)};return t.jsx(oo,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??p,errorDisplay:o,onChange:g})}const cu={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function du(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 Gs(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 uu(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function fu({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:b=!1,showFileList:f=!0,clearable:p=!0,browseLabel:g="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:A="o haz click para buscarlos en tu equipo",selectedLabel:E="Archivos seleccionados",size:M="md",containerClassName:H="",dropzoneClassName:S="",fileListClassName:x="",className:C="",id:w,accept:P,disabled:V,required:X,...O}){const K=s.useId(),q=w??K,le=s.useRef(null),[J,G]=s.useState(!1),[U,Y]=s.useState(i),ue=l??U,L=!!a,B=!!r&&n==="tooltip"&&!L,de=p&&ue.length>0&&!V,I=(T,ee)=>{l===void 0&&Y(T),c==null||c(T,ee)},oe=(T,ee)=>{const fe=T.filter(De=>Gs(De,P)),ie=T.filter(De=>!Gs(De,P)),he=b?[...ue,...fe]:fe,Te=uu(he,u,m);ie.length>0&&(d==null||d(ie)),I(Te,ee)},N=()=>{var T;V||(T=le.current)==null||T.click()},R=T=>{oe(Array.from(T.target.files??[]),T),T.target.value=""},ae=T=>{T.preventDefault(),V||G(!0)},$=T=>{T.currentTarget.contains(T.relatedTarget)||G(!1)},ne=T=>{T.preventDefault(),G(!1),!V&&oe(Array.from(T.dataTransfer.files),T)},te=T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),N())},j=T=>{I(ue.filter((ee,fe)=>fe!==T))},y=()=>{I([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${H}`,children:[(e||o||B)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),X&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),B?t.jsx(Tr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...O,ref:le,id:q,type:"file",accept:P,multiple:u,disabled:V,required:X&&ue.length===0,"aria-invalid":L||O["aria-invalid"],className:"sr-only",onChange:R}),t.jsxs("div",{role:"button",tabIndex:V?-1:0,"aria-controls":q,"aria-disabled":V||void 0,"aria-invalid":L||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)] ${cu[M]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":L?"border-[var(--danger)]":"border-[var(--border)]"} ${V?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${S} ${C}`,onClick:N,onDragOver:ae,onDragLeave:$,onDrop:ne,onKeyDown:te,children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(W.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:J?k:v}),A&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:A})]}),g&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:g})]}),f&&ue.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${x}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:E}),de&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:y,children:t.jsx(W.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ue.map((T,ee)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(W.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:T.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:du(T.size)})]}),!V&&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 ${T.name}`,onClick:()=>j(ee),children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]},`${T.name}-${T.lastModified}-${ee}`))})]}),t.jsx($r,{error:a,helperText:r,helperDisplay:n})]})}const bu=[{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 mu({fields:e,title:r="Layout",fieldTypes:n=bu,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=s.useState(()=>e.map(M=>({key:!1,type:"",...M}))),[f,p]=s.useState(""),[g,k]=s.useState(""),v=s.useCallback((M,H)=>{b(S=>{const x=S.map((C,w)=>w===M?{...C,...H}:C);return u==null||u(x),x})},[u]),A=s.useCallback(()=>{d==null||d(m)},[m,d]),E=s.useCallback(()=>{var x;const M=f.trim();if(!M){k("Ingresa un nombre de campo.");return}if(m.some(C=>C.name.toLowerCase()===M.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const S={name:M,key:!1,type:((x=n[0])==null?void 0:x.value)??""};b(C=>{const w=[...C,S];return u==null||u(w),w}),p(""),k("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((M,H)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:M.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Mn,{size:"sm",checked:M.key??!1,onChange:S=>v(H,{key:S.target.checked}),"aria-label":`${M.name} es clave`})}),t.jsx(ur,{value:M.type??"",onChange:S=>v(H,{type:S}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${M.name}`})]},M.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:f,onChange:M=>{p(M.currentTarget.value),g&&k("")},onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),E())},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(Ge,{variant:"secondary",onClick:E,height:36,padding:"0 12px",children:i})]}),g&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:g})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ge,{variant:"primary",onClick:A,disabled:c,loading:c,children:a})})]})})]})}function Wn({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(Tr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx($r,{error:o,helperText:n,helperDisplay:a})]})}function hu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Zs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=hu(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 Ot=260,Ar=420,so=380,zt="cubic-bezier(0.22, 1, 0.36, 1)",pu="cubic-bezier(0.16, 1, 0.3, 1)",lo="cubic-bezier(0.22, 1, 0.36, 1)",gu="cubic-bezier(0.22, 1, 0.36, 1)",vu=8,yu=1,xu=1.25,io={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},wu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",co=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function Nu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Qs(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 Lr({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:{...io,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=wu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(io.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 Js({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=vu,minZoom:c=yu,zoomStep:d=xu,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:p=!0,showThumbnails:g=!0,zIndex:k=1100,ariaLabel:v="Visor de imagen"}){const[A,E]=s.useState(!1),[M,H]=s.useState(!1),[S,x]=s.useState(a??0),[C,w]=s.useState(1),[P,V]=s.useState({x:0,y:0}),[X,O]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[K,q]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[le,J]=s.useState(!1),G=s.useRef(null),U=s.useRef(null),Y=s.useRef(null),ue=s.useRef(null),L=s.useRef(null),B=s.useRef(!1),de=s.useRef(!1),I=s.useRef(null),oe=s.useRef(null),N=s.useRef(null),R=s.useRef(null),ae=s.useRef(null),$=s.useRef(a??0),ne=a??S,te=n.length===0?0:sn(ne,0,Math.max(0,n.length-1)),j=n[te],y=n.length>1,T=Math.max(c,i),ee=g&&y,fe=s.useCallback(be=>{if(n.length===0)return;const ge=n.length-1,He=p?(be%n.length+n.length)%n.length:sn(be,0,ge);a===void 0&&x(He),o==null||o(He)},[a,p,o,n.length]),ie=s.useCallback(()=>{w(1),V({x:0,y:0})},[]),he=s.useCallback((be,ge)=>{if(ge<=c+.001)return{x:0,y:0};const He=R.current,We=ae.current;if(!He||!We)return be;const Fe=He.getBoundingClientRect(),bt=We.offsetWidth*ge,ct=We.offsetHeight*ge,qe=Math.max(0,(bt-Fe.width)/2+Fe.width*.15),Ye=Math.max(0,(ct-Fe.height)/2+Fe.height*.15);return{x:sn(be.x,-qe,qe),y:sn(be.y,-Ye,Ye)}},[c]),Te=s.useCallback(()=>{E(!1),q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ue.current=null,L.current=null,B.current=!1,de.current=!1,I.current&&(clearTimeout(I.current),I.current=null)},[]),De=s.useCallback(()=>{if(B.current)return;B.current=!0,H(!1),ie();const be=ue.current,ge=be!=null&&L.current!=null&&L.current===te;if(be&&ge){Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{const He=ae.current;if(!He){Y.current=null,G.current&&clearTimeout(G.current),G.current=setTimeout(Te,Ot+40);return}const We=He.getBoundingClientRect(),Fe=Qs(be,We);q({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),Y.current=requestAnimationFrame(()=>{q({enabled:!0,dx:Fe.dx,dy:Fe.dy,scale:Fe.scale,animate:!0}),Y.current=null})})}),G.current&&clearTimeout(G.current),G.current=setTimeout(Te,Ar+80);return}q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),G.current&&clearTimeout(G.current),G.current=setTimeout(Te,Ot+40)},[Te,ie,te]);s.useEffect(()=>(e?(G.current&&clearTimeout(G.current),I.current&&(clearTimeout(I.current),I.current=null),B.current=!1,de.current=!1,ue.current=Nu(l),L.current=ue.current!=null?a??S:null,E(!0),H(!1),ue.current?q({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(L.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{H(!0),q({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):A&&De(),()=>{G.current&&clearTimeout(G.current),Y.current!=null&&cancelAnimationFrame(Y.current)}),[e]);const ft=s.useCallback(()=>{if(!e||B.current||de.current)return;const be=ue.current,ge=ae.current;if(!be||!ge){be||(H(!0),de.current=!0);return}const He=ge.getBoundingClientRect();if(He.width<2||He.height<2)return;de.current=!0;const We=Qs(be,He);q({enabled:!0,dx:We.dx,dy:We.dy,scale:We.scale,animate:!1}),Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{q({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),H(!0),Y.current=null,I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),I.current=null},Ar+20)})})},[e]);s.useLayoutEffect(()=>{!A||!e||!ue.current||de.current||ft()},[A,e,ft]),s.useEffect(()=>{!e||B.current||L.current!=null&&L.current!==te&&q(be=>be.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:be)},[e,te]),s.useEffect(()=>{if(!e)return;const be=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=be}},[e]),s.useEffect(()=>{e&&ie()},[e,te,ie]),s.useEffect(()=>{a!==void 0&&x(a)},[a]),s.useEffect(()=>{if(!e){$.current=te,O({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const be=$.current;if(be===te)return;$.current=te;const ge=n.length;let He=1;if(ge>1){const We=(be+1)%ge===te,Fe=(be-1+ge)%ge===te;Fe&&!We?He=-1:We&&!Fe?He=1:He=te>be?1:-1}return U.current!=null&&(cancelAnimationFrame(U.current),U.current=null),O({opacity:0,x:He*56,scale:.94,blur:8,animate:!1}),U.current=requestAnimationFrame(()=>{U.current=requestAnimationFrame(()=>{O({opacity:1,x:0,scale:1,blur:0,animate:!0}),U.current=null})}),()=>{U.current!=null&&(cancelAnimationFrame(U.current),U.current=null)}},[e,te,n.length]);const Ct=C<=c+.001&&Math.abs(P.x)<.5&&Math.abs(P.y)<.5,nt=s.useCallback((be,ge,He)=>{w(We=>{const Fe=sn(be,c,T);if(Math.abs(Fe-We)<1e-4)return We;const bt=Fe/We,ct=Fe<We;return Fe<=c+.001?(V({x:0,y:0}),c):(V(qe=>{let Ye=qe;if(typeof ge=="number"&&typeof He=="number"&&R.current&&!ct){const dt=R.current.getBoundingClientRect(),mt=ge-dt.left-dt.width/2,mr=He-dt.top-dt.height/2;Ye={x:mt-(mt-qe.x)*bt,y:mr-(mr-qe.y)*bt}}else if(ct){Ye={x:qe.x*bt,y:qe.y*bt};const dt=Math.min(1,(We-Fe)/Math.max(.01,We-c));Ye={x:Ye.x*(1-dt*.65),y:Ye.y*(1-dt*.65)}}else Ye={x:qe.x*bt,y:qe.y*bt};return he(Ye,Fe)}),Fe)})},[he,c,T]),st=s.useCallback(()=>{nt(C*d)},[nt,C,d]),ce=s.useCallback(()=>{const be=Math.max(c,C/d);if(be<=c+.001){ie();return}w(be),V({x:0,y:0})},[c,ie,C,d]);s.useEffect(()=>{if(!e)return;const be=ge=>{if(ge.key==="Escape"&&m){ge.preventDefault(),r();return}ge.key==="ArrowLeft"&&y?(ge.preventDefault(),fe(te-1)):ge.key==="ArrowRight"&&y?(ge.preventDefault(),fe(te+1)):ge.key==="+"||ge.key==="="?(ge.preventDefault(),nt(C*d)):ge.key==="-"||ge.key==="_"?(ge.preventDefault(),ce()):ge.key==="0"&&(ge.preventDefault(),ie())};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[nt,m,y,r,e,ie,te,C,fe,ce,d]);const Se=be=>{be.preventDefault();const ge=be.deltaY>0?1/d:d;nt(C*ge,be.clientX,be.clientY)},re=be=>{C<=c+.001||(be.currentTarget.setPointerCapture(be.pointerId),J(!0),oe.current={pointerId:be.pointerId,startX:be.clientX,startY:be.clientY,originX:P.x,originY:P.y})},Le=be=>{const ge=oe.current;!ge||ge.pointerId!==be.pointerId||V(he({x:ge.originX+(be.clientX-ge.startX),y:ge.originY+(be.clientY-ge.startY)},C))},Oe=be=>{var ge;((ge=oe.current)==null?void 0:ge.pointerId)===be.pointerId&&(oe.current=null,J(!1))},Ve=be=>{if(be.stopPropagation(),C>c+.05){ie();return}nt(Math.min(T,3),be.clientX,be.clientY)},je=be=>{if(be.touches.length!==2)return;J(!0);const[ge,He]=[be.touches[0],be.touches[1]],We=Math.hypot(ge.clientX-He.clientX,ge.clientY-He.clientY);N.current={distance:We,scale:C}},Be=be=>{if(be.touches.length!==2||!N.current)return;be.preventDefault();const[ge,He]=[be.touches[0],be.touches[1]],We=Math.hypot(ge.clientX-He.clientX,ge.clientY-He.clientY),Fe=(ge.clientX+He.clientX)/2,bt=(ge.clientY+He.clientY)/2,ct=N.current.scale*(We/Math.max(1,N.current.distance));nt(ct,Fe,bt)},et=()=>{N.current=null,J(!1)};if(!A||!j)return null;const ot=K.enabled,Ht=K.animate?`transform ${Ar}ms ${gu}`:"none";return pt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:k},role:"dialog","aria-modal":"true","aria-label":v,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:M?1:0,transition:`opacity ${ot?Ar:Ot}ms ${zt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:R,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:ee?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:ot||M?1:0,transform:ot||M?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:ot?"none":`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},onClick:be=>{be.target===be.currentTarget&&u&&r()},onWheel:Se,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:K.enabled?`translate3d(${K.dx}px, ${K.dy}px, 0) scale(${K.scale})`:void 0,transformOrigin:"center center",transition:K.enabled?Ht:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:X.opacity,filter:X.blur?`blur(${X.blur}px)`:"blur(0px)",transform:`translate3d(${X.x}px, 0, 0) scale(${X.scale})`,transition:X.animate?[`opacity ${so}ms ${lo}`,`transform ${so}ms ${lo}`,`filter ${so}ms ${lo}`].join(", "):"none"},children:t.jsx("div",{ref:ae,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:C>c+.001?"grab":"zoom-in",transform:`translate3d(${P.x}px, ${P.y}px, 0) scale(${C})`,transformOrigin:"center center",transition:le?"none":`transform 220ms ${pu}`},onClick:be=>be.stopPropagation(),onDoubleClick:Ve,onPointerDown:re,onPointerMove:Le,onPointerUp:Oe,onPointerCancel:Oe,onTouchStart:je,onTouchMove:Be,onTouchEnd:et,children:t.jsx("img",{src:j.src,alt:j.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:co,imageRendering:C>2.5?"pixelated":"auto"},onLoad:()=>{ft()}},j.src+String(te))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:M?1:0,transform:M?"translateY(0)":"translateY(-6px)",transition:`opacity ${ot?Ar:Ot}ms ${zt}, transform ${ot?Ar:Ot}ms ${zt}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:io,children:[te+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(Lr,{label:"Alejar",onClick:ce,disabled:C<=c+.001,children:t.jsx(W.HiMinus,{className:"h-5 w-5"})}),t.jsx(Lr,{label:"Restablecer tamaño",onClick:ie,disabled:Ct,children:t.jsx(W.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Lr,{label:"Acercar",onClick:st,disabled:C>=T-.001,children:t.jsx(W.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Lr,{label:"Cerrar",onClick:r,children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),y?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:M?1:0,transform:M?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},children:t.jsx(Lr,{label:"Anterior",size:"lg",onClick:()=>fe(te-1),disabled:!p&&te<=0,children:t.jsx(W.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:M?1:0,transform:M?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},children:t.jsx(Lr,{label:"Siguiente",size:"lg",onClick:()=>fe(te+1),disabled:!p&&te>=n.length-1,children:t.jsx(W.HiChevronRight,{className:"h-6 w-6"})})})]}):null,ee?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((be,ge)=>{const He=ge===te;return t.jsx("button",{type:"button",role:"tab","aria-selected":He,"aria-label":be.alt||`Imagen ${ge+1}`,onClick:We=>{We.stopPropagation(),fe(ge)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:co,opacity:He?1:.42,transition:`opacity 180ms ${zt}`},children:t.jsx("img",{src:be.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:co}})},`${be.src}-${ge}`)})})}):null]})]}),document.body)}function ku({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(0),[f,p]=s.useState([]),[g,k]=s.useState(null),v=s.useCallback((E,M,H)=>{p(E),k(H??null),b(M),u(!0)},[]),A=s.useCallback(E=>{Zs(E,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:A,children:e}),t.jsx(Js,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:g,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Rs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function el(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function uo(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Su(e,r){if(!r)return!0;const n=uo(r);return uo(e.label).includes(n)||!!(e.sublabel&&uo(e.sublabel).includes(n))}function Eu({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:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:p=!0,emptyText:g="Sin resultados",clearLabel:k="Limpiar seleccion",pruneMissingValues:v=!0}){const[A,E]=s.useState(!1),[M,H]=s.useState(""),[S,x]=s.useState(0),[C,w]=s.useState(!1),[P,V]=s.useState({}),X=s.useRef(null),O=s.useRef(null),K=s.useRef(null),q=s.useRef(null),le=u&&n.length>=m,J=s.useMemo(()=>new Set(e),[e]),G=s.useMemo(()=>{const y=new Map;for(const T of n)y.set(T.value,T);return y},[n]),U=s.useMemo(()=>{const y=[];for(const T of e){const ee=G.get(T);ee&&y.push(ee)}return y},[G,e]),Y=b==="all"?U.length:b,ue=U.slice(0,Y),L=Math.max(0,U.length-ue.length),B=p&&U.length>1,de=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[U.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:U.map(y=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[y.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:y.label}),y.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:y.sublabel}):null]},y.value))})]}),I=s.useMemo(()=>{const y=M.trim();return!le||!y?n:n.filter(T=>Su(T,y))},[n,M,le]),oe=s.useCallback(()=>{const y=X.current;if(!y)return;const T=y.getBoundingClientRect(),ee=le?304:244,fe=window.innerHeight-T.bottom,ie=fe<ee&&T.top>fe;V({position:"fixed",left:T.left,top:ie?void 0:T.bottom+4,bottom:ie?window.innerHeight-T.top+4:void 0,width:Math.max(T.width,240),zIndex:9999})},[le]),N=s.useCallback(y=>{el(e,y)||r(y)},[r,e]),R=s.useCallback(y=>{const T=G.get(y);if(T!=null&&T.disabled)return;const ee=J.has(y)?e.filter(fe=>fe!==y):[...e,y];N(ee)},[N,G,e,J]),ae=s.useCallback(()=>N([]),[N]),$=s.useCallback(()=>{E(!1),H(""),x(0)},[]);s.useEffect(()=>w(!0),[]);const ne=s.useMemo(()=>n.map(y=>y.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const y=new Set(n.map(ee=>ee.value)),T=e.filter(ee=>y.has(ee));el(e,T)||r(T)},[ne]),s.useEffect(()=>{if(!A)return;function y(T){var fe,ie;const ee=T.target;!((fe=X.current)!=null&&fe.contains(ee))&&!((ie=O.current)!=null&&ie.contains(ee))&&$()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[$,A]),s.useEffect(()=>{A&&(x(0),oe(),le&&setTimeout(()=>{var y;return(y=K.current)==null?void 0:y.focus()},0))},[A,le,oe]),s.useEffect(()=>{if(A)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[A,oe]),s.useEffect(()=>{if(I.length===0){x(0);return}x(y=>Math.min(y,I.length-1))},[I.length]),s.useEffect(()=>{if(S<0||!q.current)return;const y=q.current.children[S];y==null||y.scrollIntoView({block:"nearest"})},[S]);function te(y){if(!o){if(!A){(y.key==="Enter"||y.key===" "||y.key==="ArrowDown")&&(y.preventDefault(),E(!0));return}if(y.key==="Escape"){y.preventDefault(),$();return}if(y.key==="ArrowDown"){if(y.preventDefault(),I.length===0)return;x(T=>Math.min(T+1,I.length-1));return}if(y.key==="ArrowUp"){y.preventDefault(),x(T=>Math.max(T-1,0));return}if(y.key==="Enter"&&I[S]&&!I[S].disabled){y.preventDefault(),R(I[S].value);return}y.key==="Backspace"&&!M&&e.length&&(y.preventDefault(),N(e.slice(0,-1)))}}const j=t.jsxs("div",{ref:O,className:"overflow-hidden rounded-xl shadow-xl",style:{...P,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[le&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:K,value:M,onChange:y=>{H(y.target.value),x(0)},onKeyDown:y=>{(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter"||y.key==="Escape")&&(y.stopPropagation(),te(y))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),M&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:y=>{y.preventDefault(),H(""),x(0)},children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[t.jsxs("span",{children:[U.length," seleccionados",e.length>U.length?` (${e.length-U.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:k})]}),t.jsxs("ul",{ref:q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:le?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[I.map((y,T)=>{const ee=T===S,fe=J.has(y.value);return t.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:ie=>{ie.preventDefault(),!y.disabled&&R(y.value)},onMouseEnter:()=>!y.disabled&&x(T),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:ee?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:y.disabled?"var(--text-muted)":"var(--text-main)",cursor:y.disabled?"not-allowed":"pointer",opacity:y.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:fe?"var(--primary)":"var(--border)",background:fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:fe&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),y.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:y.label}),y.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:y.sublabel})]}),y.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:y.badge})]},y.value)}),I.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:g})]})]});return t.jsxs("div",{ref:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:te,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(A?$():E(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Rs(c),padding:Rs(d),background:"var(--bg-input)",color:U.length?"var(--text-main)":"var(--text-muted)",border:A?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":A,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ue.length?(()=>{const y=t.jsxs(t.Fragment,{children:[ue.map(T=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[T.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:T.color}}),f?t.jsx(Vt,{className:"min-w-0 flex-1",children:T.label}):t.jsx("span",{className:"break-words",children:T.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${T.label}`,onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation(),R(T.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"h-3 w-3"})})]},T.value)),L>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},"aria-label":`${L} seleccionados más`,children:["+",L]})]});return B?t.jsx(Ft,{as:"span",content:de,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:y}):y})():t.jsx("span",{className:"truncate",children:a})}),U.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":k,onMouseDown:y=>{y.preventDefault(),y.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(W.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:A?"rotate(180deg)":"rotate(0deg)"}})]}),A&&C&&pt.createPortal(j,document.body)]})}function Cu({inputMode:e="decimal",...r}){return t.jsx(oo,{...r,type:"number",inputMode:e})}function Mu(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 Tu({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=Mu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ge,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(W.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,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(Ge,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})]})}const tl=[{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 rl(e){return e==null?"":String(e)}function jn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function $u(e){return typeof e=="number"?`${e}px`:e}function Au({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:b,allowedCountryCodes:f,countryCodeOptions:p,countryCodePlaceholder:g="Codigo",countryCodeClassName:k="",countryCodeWidth:v=84,onPhoneValueChange:A,label:E,containerClassName:M="",helperText:H,helperDisplay:S="inline",labelAction:x,className:C="",required:w,disabled:P,floatingLabel:V,showPasswordToggle:X,nativeValidation:O,errorTooltipLabel:K="Error de validacion",...q}){var T;const[le,J]=s.useState(()=>rl(c)),[G,U]=s.useState(()=>jn(m)),Y=s.useMemo(()=>{const ee=p??tl,fe=f==null?void 0:f.map(jn);return fe!=null&&fe.length?ee.filter(ie=>fe.includes(ie.value)):ee},[f,p]),ue=((T=Y[0])==null?void 0:T.value)??"+1",L=Y.some(ee=>ee.value===jn(u??G))?jn(u??G):ue,B=i!==void 0?rl(i):le,de=`${L} ${B}`.trim(),I=n&&B.length>0&&!no(de)?a:void 0,oe=l??I,N=!!oe,R=N&&o!=="tooltip",ae=N&&o!=="inline",$=!!H&&S==="tooltip"&&!R,ne=N?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",te=ee=>{const fe=ee.currentTarget.value;i===void 0&&J(fe),A==null||A(fe,{countryCode:L,nationalNumber:fe,fullNumber:`${L} ${fe}`.trim()}),d==null||d(ee)},j=ee=>{u===void 0&&U(ee),b==null||b(ee),A==null||A(B,{countryCode:ee,nationalNumber:B,fullNumber:`${ee} ${B}`.trim()})},y=ae?t.jsx(Ft,{as:"span",content:oe,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":K,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Xs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${M}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:E}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),$?t.jsx(Tr,{content:H}):null,x&&t.jsx("span",{className:"ml-auto normal-case",children:x})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${ne}`,children:[t.jsx(ur,{value:L,onChange:j,options:Y,placeholder:g,disabled:P,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:$u(v)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...q,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:P,required:void 0,"aria-label":q["aria-label"]??(typeof E=="string"?E:void 0),"aria-invalid":N||q["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${ae?"pr-10":""} ${C}`,onChange:te}),y]})]}),t.jsx($r,{error:R?oe:void 0,helperText:H,helperDisplay:S})]})}function Lu({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,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Du=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),qn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Dr=12,Un=8,fo=(e,r,n)=>{const a=Yn(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},nl=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Dr?null:fo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Dr)return null;const o=Array.from(a.rows).indexOf(n);return fo(a,o+1,e)},Ou=(e,r)=>{var o;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((o=e.tBodies[0])==null?void 0:o.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},al=(e,r)=>Yn(e)>=Un?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),Hu=(e,r)=>Yn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),ol=e=>{e.querySelectorAll(".rich-table-row-active").forEach(r=>{r.classList.remove("rich-table-row-active")}),e.querySelectorAll(".rich-table-col-active").forEach(r=>{r.classList.remove("rich-table-col-active")})},sl=(e,r,n)=>{ol(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},Iu=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},Vn=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},ll=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},Bu=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?nl(r,n):bo(r);return l&&Xn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Ou(r,n):!1;case"table-col-add":return Number.isFinite(a)?al(r,a):zu(r);case"table-col-del":return Number.isFinite(a)?Hu(r,a):!1;default:return!1}},Yn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Fu=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},il=e=>(e==null?void 0:e.closest("table"))??null,cl=e=>{if(!e)return null;const r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(r==null?void 0:r.closest("td, th"))??null},Pu=e=>Array.from(e.querySelectorAll("th, td")),dl=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),o=e.closest("tr");return!o||o!==a[a.length-1]?!1:e===o.cells[o.cells.length-1]},_u=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},Xn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},bo=e=>{const r=Fu(e);if(r.length>=Dr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return fo(a,0,e)}return nl(e,Array.from(e.rows).indexOf(n))},zu=e=>{const r=Yn(e)-1;return r<0?!1:al(e,r)},mo=e=>{ll(e)},Wu=(e,r,n)=>{const a=qn(e,1,Dr),o=qn(r,1,Un),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},ul=()=>'<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>',ln=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),fl=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),ju=e=>e.replace(/[<>]/g,"").toLowerCase(),qu=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),Uu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Vu=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},Kn=(e,r)=>r.test(e),Yu=e=>Kn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),Xu=e=>Kn(e,/font-style\s*:\s*italic/i),Ku=e=>Kn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),Gu=e=>Kn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Gn=(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)},Zn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Zu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},bl=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"},Qu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Uu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Ju=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&&(Yu(a)&&Gn(n,"strong"),Xu(a)&&Gn(n,"em"),Ku(a)&&Gn(n,"u"),Gu(a)&&Gn(n,"s"))})},Ru=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Zu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=bl(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(bl(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=>{Qu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},ef=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,tf=e=>{const r=Vu(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()),Ju(o),Ru(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"){Zn(d),c.forEach(l);return}if(!qu.has(u)){Zn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=ef(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Du.has(u)){Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase();if(u==="td"||u==="th"){["colspan","rowspan"].includes(f)||d.removeAttribute(b.name);return}d.removeAttribute(b.name)}),u==="table"&&d.classList.add("rich-table"),c.forEach(l);return}if(Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase(),p=b.value;if(f.startsWith("on")||f==="style"||f==="class"){d.removeAttribute(b.name);return}if(f==="lang"||f.startsWith("data-")||f.startsWith("mso-")){d.removeAttribute(b.name);return}if((f==="href"||f==="src")&&/^\s*javascript:/i.test(p)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&f!=="href"&&f!=="src"&&f!=="alt"&&(["href","src","alt","target","rel"].includes(f)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){Zn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){Zn(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()},ho=e=>ln(e).replace(/\r\n?/g,`
25
+ `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),rf=e=>new RegExp("\\p{L}","u").test(e),po=(e,r)=>{const n=e.trim();return!n||!rf(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===fl(n)},ml=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",ul())}(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 hl({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full"}){const i=s.useId(),c=o||i,d=s.useCallback(()=>document,[]),u=s.useRef(null),m=s.useRef(null),b=s.useRef(new Map),f=s.useRef(null),p=s.useRef(!1),g=s.useRef(e??""),k=s.useRef(r),v=s.useRef(()=>{}),A=s.useRef(!1),[E,M]=s.useState(()=>!e||e.trim()===""),[H,S]=s.useState(new Set),[x,C]=s.useState(null),[w,P]=s.useState(""),[V,X]=s.useState(""),[O,K]=s.useState(""),[q,le]=s.useState(""),[J,G]=s.useState(3),[U,Y]=s.useState(3),[ue,L]=s.useState(!0),[B,de]=s.useState(!1),[I,oe]=s.useState(l==="full"),[N,R]=s.useState(null),[ae,$]=s.useState(null),ne=s.useRef(null),te=s.useRef(!1),j=s.useRef(null),y=s.useCallback(()=>p.current?m.current:u.current,[]);s.useEffect(()=>{k.current=r},[r]);const T=s.useCallback(()=>{const z=window.getSelection(),Z=y();if(!z||!Z||z.rangeCount===0||z.isCollapsed)return"";const me=z.getRangeAt(0);return!Z.contains(me.startContainer)||!Z.contains(me.endContainer)?"":z.toString()},[y]);s.useEffect(()=>{const z=e??"";if(A.current&&z===g.current){A.current=!1,M(!z||z.trim()==="");return}A.current=!1,g.current=z;const Z=[u.current,m.current].filter(pe=>!!pe);Z.forEach(pe=>{pe.innerHTML!==z&&(pe.innerHTML=z)}),M(!z||z.trim()===""),Z.forEach(pe=>mo(pe));const me=Z.map(pe=>ml(pe));return()=>me.forEach(pe=>pe())},[e]),s.useEffect(()=>{var pe,Ee;p.current=B;let z,Z=0,me;if(B){const ye=u.current;ye&&(g.current=Vn(ye));const Pe=()=>{var Ze;const Ie=m.current;if(!Ie){Z=requestAnimationFrame(Pe);return}Ie.innerHTML!==g.current&&(Ie.innerHTML=g.current),z=ml(Ie),mo(Ie),M(((Ze=Ie.textContent)==null?void 0:Ze.trim())===""),me=setTimeout(()=>Ie.focus(),60)};Z=requestAnimationFrame(Pe)}else{const ye=m.current,Pe=u.current,Ie=ye?Vn(ye):g.current,Ze=g.current;g.current=Ie,Pe&&Pe.innerHTML!==Ie&&(Pe.innerHTML=Ie),Ie!==Ze&&k.current(Ie),M(((Ee=(pe=ye??Pe)==null?void 0:pe.textContent)==null?void 0:Ee.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),me&&clearTimeout(me),z==null||z()}},[B]);const ee=s.useCallback(()=>{const z=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;z.forEach(pe=>{try{d().queryCommandState(pe)&&Z.add(pe)}catch{return}});try{const pe=ju(d().queryCommandValue("formatBlock"));pe&&Z.add(`formatBlock:${pe}`)}catch{}const me=T();po(me,"uppercase")&&Z.add("__upper"),po(me,"lowercase")&&Z.add("__lower"),po(me,"capitalize")&&Z.add("__cap"),S(Z)},[T,d]),fe=()=>{var Z;const z=y();z&&(g.current=Vn(z),A.current=!0,k.current(g.current),M(((Z=z.textContent)==null?void 0:Z.trim())===""))};v.current=fe;const ie=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),ne.current&&(ol(ne.current),ne.current=null),te.current=!1,R(null),$(null)},[]),he=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null)},[]),Te=s.useCallback(()=>{he(),j.current=setTimeout(()=>{te.current||ie()},280)},[he,ie]);s.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const De=s.useCallback(z=>{const Z=ne.current;if(!Z||!Z.isConnected){ie();return}const me=(N==null?void 0:N.rowIndex)??(ae==null?void 0:ae.rowIndex)??-1,pe=(N==null?void 0:N.colIndex)??(ae==null?void 0:ae.colIndex)??-1;Bu(z,Z,me,pe,y()),ie(),v.current(),ee()},[y,ie,ee,ae,N]),ft=s.useCallback(z=>{if(ae)return;const Z=z.currentTarget,me=z.target;if(me.closest(".rich-table-action-bar, .rich-table-context-menu")){he();return}const pe=me.closest("td, th");if(!pe||!Z.contains(pe)){Te();return}const Ee=pe.closest("tr"),ye=pe.closest("table");if(!Ee||!ye||!Z.contains(ye)){Te();return}he(),ye.classList.add("rich-table"),ne.current=ye,sl(ye,Ee,pe.cellIndex),R(Iu(ye,Ee,pe))},[he,Te,ae]),Ct=s.useCallback(z=>{const Z=z.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){he();return}Te()},[he,Te]),nt=s.useCallback(z=>{const Z=z.currentTarget,pe=z.target.closest("td, th");if(!pe||!Z.contains(pe))return;const Ee=pe.closest("tr"),ye=pe.closest("table");if(!Ee||!ye||!Z.contains(ye))return;z.preventDefault(),ye.classList.add("rich-table"),ne.current=ye;const Pe=Array.from(ye.rows).indexOf(Ee),Ie=pe.cellIndex;sl(ye,Ee,Ie),R(null),$({x:z.clientX,y:z.clientY,rowIndex:Pe,colIndex:Ie})},[]);s.useEffect(()=>{if(!N&&!ae)return;const z=()=>Te();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[Te,ae,N]),s.useEffect(()=>{if(!ae)return;const z=Z=>{const me=Z.target;me instanceof Element&&me.closest(".rich-table-context-menu")||$(null)};return window.addEventListener("mousedown",z),()=>window.removeEventListener("mousedown",z)},[ae]);const st=z=>{if(!z){const Z=u.current;Z&&(g.current=Vn(Z))}de(!z)},ce=(z,Z)=>{var me;(me=y())==null||me.focus(),d().execCommand(z,!1,Z),fe(),ee()},Se=z=>{ce("formatBlock",z)},re=()=>{var z;(z=y())==null||z.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),fe(),ee()},Le=()=>{const z=window.getSelection();z&&z.rangeCount>0&&(f.current=z.getRangeAt(0).cloneRange())},Oe=()=>{const z=window.getSelection();z&&f.current&&(z.removeAllRanges(),z.addRange(f.current))},Ve=z=>{if(Le(),z==="link"){const Z=window.getSelection();X(Z&&!Z.isCollapsed?Z.toString():""),P("")}z==="image"&&(K(""),le("")),z==="table"&&(G(3),Y(3),L(!0)),C(z)},je=()=>{var pe;if(!w.trim())return;Oe(),(pe=y())==null||pe.focus();const z=window.getSelection(),me=(z&&!z.isCollapsed?z.toString():"")||V.trim()||w.trim();d().execCommand("insertHTML",!1,`<a href="${ln(w.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${ln(me)}</a>`),fe(),C(null)},Be=(z,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${ln(z)}" alt="${ln(Z)}" class="rich-img" />${ul()}</span>`,et=()=>{var z;O.trim()&&(Oe(),(z=y())==null||z.focus(),d().execCommand("insertHTML",!1,Be(O.trim(),q.trim())),fe(),C(null))},ot=()=>{var z;Oe(),(z=y())==null||z.focus(),d().execCommand("insertHTML",!1,Wu(J,U,ue)),fe(),C(null)},Ht=(z,Z=1200,me=1200,pe=.72)=>new Promise((Ee,ye)=>{const Pe=new FileReader;Pe.onerror=ye,Pe.onload=Ie=>{var sr;const Ze=(sr=Ie.target)==null?void 0:sr.result,Qe=new Image;Qe.onerror=ye,Qe.onload=()=>{let{width:vt,height:Kt}=Qe;if(vt>Z||Kt>me){const Gt=Math.min(Z/vt,me/Kt);vt=Math.round(vt*Gt),Kt=Math.round(Kt*Gt)}const It=document.createElement("canvas");It.width=vt,It.height=Kt;const lr=It.getContext("2d");if(!lr){Ee(Ze);return}lr.drawImage(Qe,0,0,vt,Kt),Ee(It.toDataURL("image/jpeg",pe))},Qe.src=Ze},Pe.readAsDataURL(z)}),be=z=>{z.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!z.contains(Z.anchorNode)){const me=document.createRange();me.selectNodeContents(z),me.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(me)}},ge=s.useRef(()=>{});ge.current=z=>{const Z=y();Z&&(be(Z),d().execCommand("insertHTML",!1,z),mo(Z),Z.querySelectorAll("p").forEach(me=>{!(me.textContent??"").replace(/[\u00a0\s]+/g,"")&&!me.querySelector("img, hr, table")&&me.remove()}),fe(),ee())};const He=s.useRef(Ht);He.current=Ht;const We=s.useRef(Be);We.current=Be;const Fe=s.useCallback(z=>{if(!z||b.current.has(z))return;const Z=me=>{const pe=me.clipboardData;if(!pe)return;const Ee=pe.getData("text/html"),ye=pe.getData("text/plain");if(Ee||ye){me.preventDefault(),me.stopPropagation();try{const Qe=Ee?tf(Ee):ho(ye);if(!Qe){ye&&ge.current(ho(ye));return}ge.current(Qe)}catch{ye&&ge.current(ho(ye))}return}const Ie=Array.from(pe.items).find(Qe=>Qe.type.startsWith("image/"));if(!Ie)return;me.preventDefault(),me.stopPropagation();const Ze=Ie.getAsFile();Ze&&He.current(Ze).then(Qe=>{ge.current(We.current(Qe,"imagen"))})};z.addEventListener("paste",Z,!0),b.current.set(z,()=>{z.removeEventListener("paste",Z,!0),b.current.delete(z)})},[]),bt=s.useCallback(z=>{var me;const Z=u.current;Z&&Z!==z&&((me=b.current.get(Z))==null||me()),u.current=z,z&&Fe(z)},[Fe]),ct=s.useCallback(z=>{var me;const Z=m.current;Z&&Z!==z&&((me=b.current.get(Z))==null||me()),m.current=z,z&&Fe(z)},[Fe]);s.useEffect(()=>{const z=b.current;return()=>{z.forEach(Z=>Z()),z.clear()}},[]);const qe=z=>{const Z=window.getSelection(),me=y();if(!Z||!me||Z.rangeCount===0||Z.isCollapsed)return;const pe=Z.getRangeAt(0);if(!me.contains(pe.startContainer)||!me.contains(pe.endContainer))return;const Ee=pe.toString();if(!Ee)return;let ye=Ee;z==="uppercase"?ye=Ee.toLocaleUpperCase():z==="lowercase"?ye=Ee.toLocaleLowerCase():ye=fl(Ee),pe.deleteContents();const Pe=document.createTextNode(ye);pe.insertNode(Pe);const Ie=document.createRange();Ie.setStart(Pe,0),Ie.setEnd(Pe,ye.length),Z.removeAllRanges(),Z.addRange(Ie),f.current=Ie.cloneRange(),fe(),ee()},Ye=()=>{Le(),ee()},dt=()=>{const z=y();z&&ll(z),fe(),ee()},mt=()=>{requestAnimationFrame(()=>{var z;(z=y())==null||z.focus()})},mr=z=>{var Z,me;if((z.metaKey||z.ctrlKey)&&z.key==="Enter"){if(z.preventDefault(),z.stopPropagation(),z.repeat)return;(Z=y())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),fe(),ee();return}if(z.key==="Tab"){const pe=window.getSelection(),Ee=cl((pe==null?void 0:pe.anchorNode)??null),ye=y(),Pe=il(Ee);if(Ee&&Pe&&(ye!=null&&ye.contains(Ee))){z.preventDefault();const Ie=Pu(Pe),Ze=Ie.indexOf(Ee),Qe=Ze>=0?Ie[Ze+1]:null;if(Qe)Xn(Qe,ye,!0);else if(dl(Ee,Pe)){const sr=bo(Pe);sr&&Xn(sr,ye,!0)}fe(),ee();return}z.preventDefault(),(me=y())==null||me.focus(),d().execCommand("insertText",!1,"    "),fe(),ee();return}if(z.key==="Enter"&&!z.shiftKey&&!(z.metaKey||z.ctrlKey)){const pe=window.getSelection(),Ee=cl((pe==null?void 0:pe.anchorNode)??null),ye=y(),Pe=il(Ee);if(Ee&&Pe&&(ye!=null&&ye.contains(Ee))&&dl(Ee,Pe)&&_u(Ee)){z.preventDefault();const Ie=bo(Pe);Ie&&Xn(Ie,ye,!0),fe(),ee();return}}if(z.key==="Escape"){if(ae){$(null);return}if(x){C(null);return}if(p.current){de(!1);return}}x||(z.ctrlKey||z.metaKey)&&(z.key==="b"&&(z.preventDefault(),ce("bold")),z.key==="i"&&(z.preventDefault(),ce("italic")),z.key==="u"&&(z.preventDefault(),ce("underline")),z.key==="k"&&(z.preventDefault(),Ve("link")))},ut=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ze=(z,Z,me,pe,Ee)=>{const ye=Ee??(H.has(me)||me==="__link"&&x==="link"||me==="__img"&&x==="image"||me==="__table"&&x==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:mt,onMouseDown:Pe=>{Pe.preventDefault(),pe?pe():ce(me)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ye?"var(--primary)":"var(--text-secondary)",background:ye?"rgba(59,130,246,0.12)":"transparent"},children:z},me)},vn=z=>{const Z=z.target;if(Z.closest("[data-action='delete-img']")){z.preventDefault();const me=Z.closest(".rich-img-wrap");me&&(me.remove(),fe())}},ba=()=>{he(),te.current=!0},ht=()=>{te.current=!1,Te()},Mt=(z,Z,me,pe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${pe?" rich-table-action-btn--danger":""}`,title:z,"aria-label":z,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),De(me)},children:Z}),Tt=()=>typeof document>"u"||!N&&!ae?null:pt.createPortal(t.jsxs(t.Fragment,{children:[N&&!ae&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:N.bar.x,top:N.bar.y},onMouseEnter:ba,onMouseLeave:ht,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",N.rowIndex+1," · Col ",N.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Mt("Añadir fila abajo","+","table-row-add"),Mt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Mt("Añadir columna a la derecha","+","table-col-add"),Mt("Eliminar columna","−","table-col-del")]}),Mt("Eliminar tabla","Eliminar","table-delete",!0)]}),ae&&t.jsx("div",{className:"rich-table-context-menu",style:{left:ae.x,top:ae.y},onMouseDown:z=>z.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([z,Z])=>t.jsx("button",{type:"button",onMouseDown:me=>{me.preventDefault(),De(Z)},children:z},Z))})]}),document.body),or=z=>t.jsxs(t.Fragment,{children:[x==="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:w,onChange:Z=>P(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),je()),Z.key==="Escape"&&C(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:V,onChange:Z=>X(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),je()),Z.key==="Escape"&&C(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:je,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:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:z},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Dr,value:J,onChange:Z=>G(qn(Number(Z.target.value),1,Dr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ot()),Z.key==="Escape"&&C(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:Un,value:U,onChange:Z=>Y(qn(Number(Z.target.value),1,Un)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ot()),Z.key==="Escape"&&C(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:ue,onChange:Z=>L(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:ot,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:O,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),et()),Z.key==="Escape"&&C(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:q,onChange:Z=>le(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),et()),Z.key==="Escape"&&C(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:et,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),jr=(z,Z)=>{const me=l==="compact",pe=!me||I||z;return t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:Z},"data-toolbar-variant":l,children:[me&&!z&&t.jsxs("button",{type:"button",title:I?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),oe(ye=>!ye)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:I?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[I?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"}),I?"Ocultar herramientas":"Herramientas"]}),pe&&t.jsxs(t.Fragment,{children:[ze(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ze(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ze(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ze(t.jsx(W.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ze(t.jsx(W.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ze(t.jsx(W.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Ve("link")),ut(),ze(t.jsx(W.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ze(t.jsx(W.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),ut(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Se("p"),H.has("formatBlock:p")||H.has("formatBlock:div")),ze(t.jsx(W.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Se("h2"),H.has("formatBlock:h2")),ze(t.jsx(W.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Se("h3"),H.has("formatBlock:h3")),ze(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Se("blockquote"),H.has("formatBlock:blockquote")),ut(),ze(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),ut(),ze(t.jsx(W.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ze(t.jsx(W.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),ut(),ze(t.jsx(W.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ze(t.jsx(W.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ze(t.jsx(W.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ze(t.jsx(W.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),ut(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>qe("uppercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>qe("lowercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>qe("capitalize")),ut(),ze(t.jsx(W.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ze(t.jsx(W.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Ve("image")),ze(t.jsx(W.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Ve("table")),ze(t.jsx(W.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",re),ut(),ze(t.jsx(W.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ze(t.jsx(W.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Se("p"))]}),ut(),t.jsx("button",{type:"button",title:z?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),st(z)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:z?t.jsx(W.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(W.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Tt(),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:bt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:mr,onKeyUp:Ye,onSelect:Ye,onMouseUp:Ye,onMouseMove:ft,onMouseLeave:Ct,onContextMenu:nt,onMouseDown:vn,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${E?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),or("var(--bg-input)"),jr(!1,"var(--bg-input)")]}),t.jsxs(Za,{open:B,onClose:()=>de(!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:ct,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:mr,onKeyUp:Ye,onSelect:Ye,onMouseUp:Ye,onMouseMove:ft,onMouseLeave:Ct,onContextMenu:nt,onMouseDown:vn,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${E?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),or("var(--bg-input)"),jr(!0,"var(--bg-input)")]})]})}const pl="[a-zA-Z0-9._@-]+",go=new RegExp(`@(${pl})`,"g"),nf=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
26
26
  `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function gl(e,r){if(r<=0)return!0;const n=e[r-1]??"";return cn.has(n)}function vl(e,r,n){var a;if(r<0||r>e.length)return null;for(let o=r-1;o>=0;o-=1){if(e[o]!=="@"){const c=e[o]??"";if(cn.has(c)||!nf.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):gl(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${pl}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function yl(e,r){var a;const n=Or(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function xl(e,r){if(r<=0)return!0;const n=Or(e,r);if(!n){const o=So(e);return gl(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return cn.has(o)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const o=a.textContent??"";if(o.length===0){a=a.previousSibling;continue}return cn.has(o[o.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const o=a;if(o.classList.contains("mention-chip")||o.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(o.tagName))return!0;const l=o.textContent??"";if(l.length===0){a=a.previousSibling;continue}return cn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function vo(e,r){const n=So(e);return vl(n,r,{isTriggerBoundary:a=>xl(e,a),isInsideExistingMention:a=>yl(e,a)})}function yo(e){return e.toLowerCase().trim()}function wl(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
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 xo(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=yo(d);!u||r.has(u)||(r.add(u),n.push(u))},o=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=o.exec(e))!==null;)a(l[1]??"");const i=wl(e);go.lastIndex=0;let c;for(;(c=go.exec(i))!==null;)a(c[1]??"");return n}function Nl(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function af(e,r){const n=xo(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(yo(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 kl(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 of(e,r){return r?e.filter(n=>n.userId!==r):e}function wo(e){var n;let r=e.nextSibling;for((r==null?void 0:r.nodeType)===Node.TEXT_NODE&&/^[ \u00a0]/.test(r.textContent??"")&&(r=r.nextSibling);r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").replace(/\u00a0/g," ").trim();)r=r.nextSibling;return r&&r.nodeType===Node.ELEMENT_NODE&&((n=r.classList)!=null&&n.contains("mention-chip"))?" ":!r||r.nodeType===Node.ELEMENT_NODE&&r.tagName==="BR"?" ":" "}function Sl(e){return!e||!/@/.test(e)?e:e.replace(go,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=o[a+r.length]??"";return u===" "||u===" "?`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>`:`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>${u?" ":" "}`})}function dn(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,o=wo(n),l=n.nextSibling;if((l==null?void 0:l.nodeType)===Node.TEXT_NODE){const i=l.textContent??"";if(i.startsWith(o))return;if(i.startsWith(" ")||i.startsWith(" ")){l.textContent=`${o}${i.slice(1)}`;return}if(i.length>0){l.textContent=`${o}${i}`;return}}n.after(a.createTextNode(o))})}function No(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&dn(a);const o=wo(e);let l=e.nextSibling;!l||l.nodeType!==Node.TEXT_NODE||!/^[ \u00a0]/.test(l.textContent??"")?(l=r.createTextNode(o),e.after(l)):(l.textContent??"").startsWith(o)||(l.textContent=`${o}${(l.textContent??"").slice(1)}`);const i=n==null?void 0:n.getSelection();if(!i)return;const c=r.createRange();c.setStart(l,((d=l.textContent)==null?void 0:d.length)??1),c.collapse(!0),i.removeAllRanges(),i.addRange(c)}const sf=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function El(e,r){return sf.has(e.tagName)&&e!==r}function ko(e,r){let n="",a,o,l=!1;const i=(f,g)=>{if(l||!(r!=null&&r.domPoint))return;const{container:p,offset:S}=r.domPoint;p===f&&S===g&&(o=n.length,l=!0)},c=(f,g)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:g},!0),d=f=>(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":(n+=`
29
- `,(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":!1),u=f=>{const g=f.data;for(let p=0;p<=g.length;p+=1){if(i(f,p),c(f,p))return!0;p<g.length&&(n+=g[p])}return!1},m=(f,g)=>{if(g&&n.length>0&&!n.endsWith(`
30
- `)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const p=f;if(p.tagName==="BR")return i(p,0),d(p.nextSibling??void 0)==="matched";const S=Array.from(f.childNodes);for(let v=0;v<S.length;v+=1){const C=S[v],T=v>0&&C.nodeType===Node.ELEMENT_NODE&&El(C,e);if(m(C,T))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],p=f>0&&g.nodeType===Node.ELEMENT_NODE&&El(g,e);if(m(g,p))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),p=g;for(;p;)g=p,p=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:o}}function So(e){return ko(e).plain}function Or(e,r){return r<0?null:ko(e,{locatePlain:r}).locate??null}function Qn(e,r,n){return e!==r&&!e.contains(r)?-1:ko(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function Cl(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Or(e,n),i=Or(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=Nl({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 b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),dn(e),No(m);const g=c.defaultView,p=g==null?void 0:g.getSelection(),S=p!=null&&p.rangeCount?Qn(e,p.getRangeAt(0).startContainer,p.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:S>=0?S:n+u.length+1}}function Ml(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Or(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Jn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function Tl(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 $l(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 Hr(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Rn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function Al(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Rn(e)}function Ll(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function Dl(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Hr(e),!0):!1}function ea(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let p=f;for(;p&&p.nodeType===Node.TEXT_NODE&&(p.textContent??"")==="";){const S=p;p=p[g],S.remove()}return p},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function Ol(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=Tl(a.previousSibling,"prev");return Jn(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(Jn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Hl(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=Tl(a.nextSibling,"next");if(Jn(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(Jn(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 Co=420,ta=6,Il=260,lf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Bl=4,cf={position:"relative"},df={position:"fixed",zIndex:11050,minWidth:Il,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},Fl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function uf(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function ff(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Il-8)),n=window.innerHeight-e.bottom-ta-8,a=e.top-ta-8;return n<Math.min(Co,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ta,maxHeight:Math.min(Co,Math.max(120,a))}:{left:r,top:e.bottom+ta,maxHeight:Math.min(Co,Math.max(120,n))}}function Pl({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="",toolbarVariant:b="full"}){const f=s.useId().replace(/:/g,""),g=s.useRef(null),p=s.useRef(null),S=s.useRef(new Map),v=s.useRef(n);v.current=n;const C=s.useRef(null),T=s.useRef(0),E=s.useRef([]),O=s.useRef(null),[N,x]=s.useState(null),[M,w]=s.useState([]),[P,X]=s.useState(0),[K,D]=s.useState([]),[G,U]=s.useState(!1),[ae,Q]=s.useState(!1);T.current=P,s.useEffect(()=>{Q(!0)},[]);const R=(N==null?void 0:N.query)??null;s.useEffect(()=>{if(R===null){w([]);return}const k=R.trim(),te=`${m}|${k.toLowerCase()||"*"}`,z=S.current.get(te);if(z){w(z),U(!1),X(0);return}const I=new AbortController;U(!0);const de=window.setTimeout(()=>{(async()=>{try{const re=await v.current(k,{signal:I.signal,limit:c});if(I.signal.aborted)return;const q=Array.isArray(re)?re:[];S.current.set(te,q),w(q),X(0)}catch{I.signal.aborted||w([])}finally{I.signal.aborted||U(!1)}})()},d);return()=>{I.abort(),window.clearTimeout(de)}},[R,c,d,m]);const V=s.useRef(a);V.current=a,s.useEffect(()=>{var k;(k=V.current)==null||k.call(V,kl(K))},[K]);const Y=s.useCallback(()=>{const k=uf(f);if(k.length===0)return null;const te=window.getSelection();if(te!=null&&te.rangeCount){const I=te.getRangeAt(0).startContainer;for(const de of k)if(de.contains(I))return de}const z=document.activeElement;for(const I of k)if(z===I||z&&I.contains(z))return I;for(const I of k)if(I.closest('[role="dialog"]'))return I;return k[0]??null},[f]),ue=s.useCallback(()=>{const k=Y(),te=window.getSelection();if(!k||!te||te.rangeCount===0){x(null);return}const z=te.getRangeAt(0);if(!k.contains(z.startContainer)){x(null);return}const I=Qn(k,z.startContainer,z.startOffset);if(I<0){x(null);return}const de=vo(k,I);if(!de){x(null);return}const re=z.getBoundingClientRect(),q=re.width===0&&re.height===0?(()=>{const $=document.createRange();return $.selectNodeContents(z.startContainer),$.collapse(!0),$.getBoundingClientRect()})():re;C.current={query:de.query,caretIndex:de.caretIndex,triggerIndex:de.triggerIndex};const y=ff(q);x($=>{const ee={query:de.query,...y};return $&&$.query===ee.query&&$.top===ee.top&&$.bottom===ee.bottom&&$.left===ee.left&&$.maxHeight===ee.maxHeight?$:ee})},[Y]),L=s.useCallback(k=>{r(k),ue()},[r,ue]);s.useEffect(()=>{const k=te=>{if(lf.has(te.key))return;const z=Y(),I=te.target;!z||!I||!z.contains(I)||ue()};return document.addEventListener("keyup",k,!0),()=>document.removeEventListener("keyup",k,!0)},[Y,ue]);const B=s.useCallback(k=>{const te=Y();if(!te)return;let z=-1;const I=window.getSelection();if(I&&I.rangeCount>0){const $=I.getRangeAt(0);te.contains($.startContainer)&&(z=Qn(te,$.startContainer,$.startOffset))}if(z<0&&C.current&&(z=C.current.caretIndex),z<0)return;const de=vo(te,z);if(!de)return;const re=Cl(te,{triggerIndex:de.triggerIndex,caretIndex:z,username:k.username,display:k.name,userId:k.userId});if(!re)return;dn(te),te.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const q={userId:k.userId,username:k.username,email:k.email??void 0,display:k.name??k.username};D($=>{const ee=new Map($.map(fe=>[fe.userId,fe]));return ee.set(q.userId,q),Array.from(ee.values())}),x(null),C.current=null;const y=k.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const $=Y();if(!$)return;$.focus(),dn($);const ee=Array.from($.querySelectorAll(".mention-chip")),fe=[...ee].reverse().find(ie=>ie.getAttribute("data-username")===y)??ee[ee.length-1];if(fe){No(fe);return}Ml($,re.caretPlainOffset)})})},[Y]);s.useEffect(()=>{const k=new Set(xo(e).map(te=>te.toLowerCase()));D(te=>{const z=te.filter(I=>k.has(I.username.toLowerCase()));return z.length===te.length?te:z})},[e]),s.useEffect(()=>{if(!N)return;const k=te=>{const z=te.target;if(!z||g.current&&g.current.contains(z)||p.current&&p.current.contains(z))return;const I=Y();I&&I.contains(z)||x(null)};return document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[N,Y]);const ce=s.useMemo(()=>M.slice(0,c),[M,c]);E.current=ce,s.useEffect(()=>{if(!N)return;const k=te=>{const z=Y(),I=te.target;if(!z||!I||!z.contains(I))return;const de=E.current;if(!(de.length===0&&te.key!=="Escape"))if(te.key==="ArrowDown")te.preventDefault(),te.stopPropagation(),X(re=>(re+1)%Math.max(de.length,1));else if(te.key==="ArrowUp")te.preventDefault(),te.stopPropagation(),X(re=>(re-1+de.length)%Math.max(de.length,1));else if(te.key==="Enter"||te.key==="Tab"){const re=de[T.current];re&&(te.preventDefault(),te.stopPropagation(),B(re))}else te.key==="Escape"&&(te.preventDefault(),te.stopPropagation(),x(null))};return document.addEventListener("keydown",k,!0),()=>document.removeEventListener("keydown",k,!0)},[Y,B,N]),s.useEffect(()=>{const k=q=>{q.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},te=q=>{const y=Y(),$=q.target;if(!y||!$||!y.contains($))return;if((q.metaKey||q.ctrlKey)&&q.key.toLowerCase()==="a"){q.preventDefault(),q.stopPropagation(),y.focus(),Al(y);return}if(q.key!=="Backspace"&&q.key!=="Delete")return;const ee=window.getSelection();if(ee&&!ee.isCollapsed&&ee.rangeCount>0){const he=ee.getRangeAt(0);if(y.contains(he.commonAncestorContainer)&&Eo(y).length>0&&Ll(he)){q.preventDefault(),q.stopPropagation(),Dl(y)&&k(y);return}}const fe=Eo(y);if(fe.length>0){q.preventDefault(),q.stopPropagation();for(const he of fe)ea(he);Hr(y),k(y);return}if(q.key==="Backspace"){const he=Ol(y);if(!he)return;q.preventDefault(),q.stopPropagation(),ea(he),Hr(y),k(y);return}const ie=Hl(y);ie&&(q.preventDefault(),q.stopPropagation(),ea(ie),Hr(y),k(y))},z=q=>{const y=Y();if(!y)return;const $=q.target;if(!($ instanceof Element)||!y.contains($))return;const ee=$.closest(".mention-chip");if(!(ee instanceof HTMLElement)||!y.contains(ee)){O.current=null,Hr(y);return}q.shiftKey||q.button!==0||(O.current={chip:ee,x:q.clientX,y:q.clientY})},I=q=>{const y=O.current;if(!y)return;const $=Math.abs(q.clientX-y.x),ee=Math.abs(q.clientY-y.y);($>Bl||ee>Bl)&&(O.current=null)},de=q=>{var ie;const y=Y(),$=O.current;if(O.current=null,!y||!$)return;const ee=q.target;if(!(ee instanceof Element)||!y.contains(ee)||!((ie=ee.closest(".mention-chip"))!=null&&ie.isSameNode($.chip)))return;const fe=window.getSelection();if(fe){if(!fe.isCollapsed){Rn(y);return}y.focus(),$l($.chip)}},re=()=>{const q=Y();if(!q)return;const y=window.getSelection();!y||y.rangeCount===0||!y.anchorNode||!q.contains(y.anchorNode)||!y.focusNode||!q.contains(y.focusNode)||Rn(q)};return document.addEventListener("keydown",te,!0),document.addEventListener("mousedown",z,!0),document.addEventListener("mousemove",I,!0),document.addEventListener("mouseup",de,!0),document.addEventListener("selectionchange",re),()=>{document.removeEventListener("keydown",te,!0),document.removeEventListener("mousedown",z,!0),document.removeEventListener("mousemove",I,!0),document.removeEventListener("mouseup",de,!0),document.removeEventListener("selectionchange",re)}},[Y]),s.useEffect(()=>{if(!N||!p.current)return;const k=p.current.querySelector(`[data-mention-index="${P}"]`);k==null||k.scrollIntoView({block:"nearest"})},[P,N]);const H=u?Sl(e):e,oe=N&&ae?pt.createPortal(t.jsxs("ul",{ref:p,style:{...df,left:N.left,top:N.top,bottom:N.bottom,maxHeight:N.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&ce.length===0&&t.jsx("li",{style:Fl,children:"Buscando…"}),!G&&ce.length===0&&t.jsx("li",{style:Fl,children:N.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${N.query}”`}),ce.map((k,te)=>{var z,I;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":te,onMouseDown:de=>{de.preventDefault(),B(k)},onMouseEnter:()=>X(te),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:te===P?"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:((z=k.name)==null?void 0:z.trim())||`@${k.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(I=k.name)!=null&&I.trim()?`@${k.username}`:null,k.email].filter(Boolean).join(" · ")||`@${k.username}`})]})},k.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:cf,className:i,children:[t.jsx(hl,{value:H,onChange:L,placeholder:l,minHeight:o,instanceId:f,toolbarVariant:b}),oe]})}function bf({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}){return o?t.jsx(Pl,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}):t.jsx(hl,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function mf({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:o}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const hf={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)"}},pf={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 gf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=hf[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 ${pf[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 _l={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)"}},vf={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"},yf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},xf={xs:148,sm:164,md:184},wf={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 Nf({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:b,optionClassName:f,spinnerClassName:g}){const[p,S]=s.useState(!1),[v,C]=s.useState(!1),[T,E]=s.useState(-1),[O,N]=s.useState({}),x=s.useRef(null),M=s.useRef(null),w=s.useRef(null),P=r.find(V=>V.value===e)??r[0],X={...P!=null&&P.tone?_l[P.tone]:void 0,...P==null?void 0:P.style},K=o||l||r.length===0,D=V=>{i&&V.stopPropagation()},G=s.useCallback(()=>{S(!1),E(-1)},[]),U=s.useCallback(()=>{const V=x.current;if(!V)return;const Y=V.getBoundingClientRect(),ue=Math.max(Y.width,xf[a]),L=Math.min(Math.max(r.length,1)*38+12,260),B=window.innerHeight-Y.bottom,ce=B<L&&Y.top>B,H=Math.min(Math.max(8,Y.left+Y.width/2-ue/2),window.innerWidth-ue-8);N({position:"fixed",left:H,top:ce?void 0:Y.bottom+6,bottom:ce?window.innerHeight-Y.top+6:void 0,width:ue,zIndex:9999})},[r.length,a]),ae=s.useCallback(V=>{V.disabled||(n(V.value),G())},[G,n]);s.useEffect(()=>C(!0),[]),s.useEffect(()=>{if(!p)return;U();const V=r.findIndex(Y=>Y.value===e);E(V>=0?V:0)},[p,r,U,e]),s.useEffect(()=>{if(!p)return;function V(Y){var L,B;const ue=Y.target;!((L=x.current)!=null&&L.contains(ue))&&!((B=M.current)!=null&&B.contains(ue))&&G()}return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[G,p]),s.useEffect(()=>{if(p)return window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[p,U]),s.useEffect(()=>{if(T<0||!w.current)return;const V=w.current.children[T];V==null||V.scrollIntoView({block:"nearest"})},[T]);function Q(V){if(!K){if(!p){["Enter"," ","ArrowDown","ArrowUp"].includes(V.key)&&(V.preventDefault(),S(!0));return}if(V.key==="Escape"){V.preventDefault(),G();return}if(V.key==="ArrowDown"){V.preventDefault(),E(Y=>Math.min(Y+1,r.length-1));return}if(V.key==="ArrowUp"){V.preventDefault(),E(Y=>Math.max(Y-1,0));return}if(V.key==="Enter"||V.key===" "){V.preventDefault();const Y=r[T];Y&&ae(Y)}}}const R=t.jsx("div",{ref:M,role:"listbox","aria-label":c,className:Qt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...O,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:D,onMouseDown:D,onPointerDown:D,children:t.jsx("div",{ref:w,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((V,Y)=>{const ue=V.value===e,L=Y===T,B={...V.tone?_l[V.tone]:void 0,...V.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ue,disabled:V.disabled,onMouseEnter:()=>!V.disabled&&E(Y),onMouseDown:ce=>{ce.preventDefault(),ae(V)},className:Qt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",wf[a],ue?V.className:void 0,f),style:{...ue?B:void 0,background:ue?B.background??"color-mix(in srgb, var(--primary) 12%, transparent)":L?"var(--bg-hover)":"transparent",color:ue?B.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ue?t.jsx(j.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:V.label})]},V.value)})})});return t.jsxs("span",{ref:x,className:Qt("relative inline-flex shrink-0 items-center",u),onKeyDown:Q,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":p,title:d,onClick:()=>!K&&S(V=>!V),className:Qt("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",vf[a],P==null?void 0:P.className,m),style:X,children:t.jsx("span",{className:"min-w-0 truncate",children:(P==null?void 0:P.label)??e})}),t.jsx(j.HiChevronDown,{"aria-hidden":"true",className:Qt("pointer-events-none absolute opacity-70 transition-transform",yf[a],p?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Qt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),p&&v&&pt.createPortal(R,document.body)]})}function kf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(p=>!p.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(p=>p.id===m)??u,f=p=>{p.disabled||a==null||a(p.id)},g=p=>{const S=e.filter(C=>!C.disabled);if(!S.length||!b)return;const v=S.findIndex(C=>C.id===b.id);(p.key==="ArrowRight"||p.key==="ArrowDown")&&(p.preventDefault(),f(S[(v+1)%S.length])),(p.key==="ArrowLeft"||p.key==="ArrowUp")&&(p.preventDefault(),f(S[(v-1+S.length)%S.length])),p.key==="Home"&&(p.preventDefault(),f(S[0])),p.key==="End"&&(p.preventDefault(),f(S[S.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:g,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(p=>{const S=p.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":S,"aria-controls":`${p.id}-panel`,id:`${p.id}-tab`,disabled:p.disabled,tabIndex:S?0:-1,onClick:()=>f(p),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:S?"var(--primary)":"var(--text-muted)",borderColor:S?"var(--primary)":"transparent",background:l==="pills"&&S?"var(--bg-card)":"transparent"},children:[p.icon&&t.jsx("span",{className:"shrink-0",children:p.icon}),t.jsx("span",{children:p.label}),p.badge&&t.jsx("span",{className:"shrink-0",children:p.badge})]},p.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function rr(...e){return e.filter(Boolean).join(" ")}function Sf({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:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:p="",contentClassName:S="",footerClassName:v=""}){var z;const C=((z=e[0])==null?void 0:z.id)??"",[T,E]=s.useState(n??C),[O,N]=s.useState(o),x=r??T,M=a??O,w=s.useMemo(()=>new Set(M),[M]),P=Math.max(0,e.findIndex(I=>I.id===x)),X=e[P]??e[0],K=e.length<=1?100:P/(e.length-1)*100,D=I=>{a||N(I),i==null||i(I)},G=I=>{const de=e.find(re=>re.id===I);de&&(r||E(I),l==null||l(I,de))},U=I=>w.has(I),ae=I=>e.slice(0,I).find(de=>!de.optional&&!w.has(de.id)),Q=I=>{const de=e[I];return!de||de.disabled?!1:I===P||d&&I<P?!0:!ae(I)},R=I=>{const de=e.findIndex(re=>re.id===I);return de>=0&&Q(de)},V=I=>{const de=e.findIndex(re=>re.id===I);if(de<0)return!1;if(!Q(de)){const re=ae(de);return re&&(c==null||c(e[de],re)),!1}return G(I),!0},Y=(I=X==null?void 0:X.id)=>{!I||w.has(I)||D([...M,I])},ue=(I=X==null?void 0:X.id)=>{if(!I)return;const de=e.findIndex(q=>q.id===I),re=M.filter(q=>{const y=e.findIndex($=>$.id===q);return y>=0&&y<de});D(re),de>=0&&P>de&&G(I)},L=()=>P<=0?!1:V(e[P-1].id),B=()=>{const I=e[P+1];return I?V(I.id):!1},ce={activeStep:X,activeIndex:P,completedStepIds:M,isCompleted:U,isUnlocked:R,completeStep:Y,uncompleteStep:ue,goToStep:V,goNext:B,goPrevious:L};if(!X)return null;const H=e[P+1],oe=P>0,k=H?R(H.id):!1,te=typeof X.content=="function"?X.content(ce):X.content;return t.jsxs("section",{className:rr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:rr("border-b border-[var(--border)] bg-[var(--bg-input)]",p),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:`${K}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((I,de)=>{const re=I.id===X.id,q=U(I.id),y=Q(de),$=ae(de);return t.jsxs("button",{type:"button",disabled:!y,"aria-current":re?"step":void 0,"aria-disabled":!y,title:!y&&$?`Completa ${$.title}`:I.title,onClick:()=>V(I.id),className:rr("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",re&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",q&&!re&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!re&&!q&&y&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!y&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:rr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",re&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:rr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",re&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",q&&!re&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!q&&!re&&y&&"border-[var(--border)] text-[var(--text-muted)]",!y&&"border-[var(--border)] text-[var(--text-muted)]"),children:q?t.jsx(j.HiCheck,{className:"h-4 w-4"}):y?de+1:t.jsx(j.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:rr("block truncate text-xs font-semibold transition-colors duration-200",re?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[de+1,". ",I.title]}),I.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:I.description})]}),I.badge&&t.jsx("span",{className:"shrink-0",children:I.badge})]})]},I.id)})})]}),t.jsx("div",{className:rr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",S),children:te},X.id),u&&t.jsxs("div",{className:rr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Ge,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(j.HiChevronLeft,{}),disabled:!oe,onClick:L,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",P+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[M.length," completados"]})]}),t.jsx(Ge,{height:38,padding:"0 14px",icon:t.jsx(j.HiChevronRight,{}),disabled:!H||!k,onClick:B,children:H&&!k?f:b})]})]})}const Ef={sm:"px-2.5 py-1.5 text-xs leading-5",md:"px-2.5 py-1.5 text-sm leading-5",lg:"px-3 py-2 text-sm leading-6"};function Cf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Mf(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),o=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(o)?o:2}}function zl(e,r){const{lineHeight:n,paddingY:a,borderY:o}=Mf(e);return Math.ceil(r*n+a+o)}const Wl=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const g=s.useRef(null),p=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",S=s.useCallback(()=>{const v=g.current;if(!v)return;v.style.height="auto";const C=v.scrollHeight,T=zl(v,i),E=o??(l!==void 0?zl(v,l):void 0),O=E!==void 0?Math.min(Math.max(C,T),E):Math.max(C,T);v.style.height=`${O}px`,v.style.overflowY=E!==void 0&&C>E?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{S()},[S,d,u]),s.useEffect(()=>{const v=g.current;if(!v||typeof ResizeObserver>"u")return;const C=new ResizeObserver(()=>S());return C.observe(v),()=>C.disconnect()},[S]),t.jsx("textarea",{...b,ref:v=>{g.current=v,Cf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{S(),m==null||m(v)},style:{...c,borderColor:p,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Ef[n]} ${r}`})});function Tf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Wn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Wl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const $f={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"},Af={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Lf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Df(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const jl=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:g,value:p,defaultValue:S,maxLength:v,onInput:C,...T},E){const O=s.useRef(null),N=Df(p,S),x=u??v,M=!!(b||f||d),w=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",P={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const D=O.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(X,[l,p]);const K=t.jsx("textarea",{...T,ref:D=>{O.current=D,Lf(E,D)},value:p,defaultValue:S,maxLength:v,"aria-invalid":m==="error"||T["aria-invalid"],onInput:D=>{X(),C==null||C(D)},style:{...P,borderColor:w},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 ${$f[a]} ${Af[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return M?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),K,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[N,x?`/${x}`:""]})]}):K});function Of({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Wn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(jl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const ql=[{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 Hf(e){return ql[e%ql.length]}let If=0;function Mo(){return++If}function Ul(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Bf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ff(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Bf(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Pf({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:b,helperDisplay:f="inline",error:g,required:p=!1}){const S=e!==void 0,v=!!g,C=!!b&&f==="tooltip"&&!v,[T,E]=s.useState(()=>(r??[]).map((q,y)=>({id:Mo(),value:q.trim(),colorIndex:y})));s.useEffect(()=>{S&&E(q=>{const y=e??[],$=new Map(q.map(ee=>[ee.value,ee]));return y.map((ee,fe)=>$.get(ee)??{id:Mo(),value:ee,colorIndex:fe})})},[S,e]);const O=T,[N,x]=s.useState(""),[M,w]=s.useState(null),[P,X]=s.useState(""),[K,D]=s.useState(!1),[G,U]=s.useState(!1),ae=s.useRef(null),Q=s.useRef(null),R=s.useRef(null);function V(){U(!0),setTimeout(()=>U(!1),400)}function Y(q){E(q),n==null||n(q.map(y=>y.value))}function ue(q){let y=O,$=!1,ee=!1;for(const fe of q){const ie=fe.trim();if(ie){if(c!==void 0&&y.length>=c){ee=!0;break}if(!d&&y.some(he=>he.value.toLowerCase()===ie.toLowerCase())){ee=!0;continue}if(!Ul(ie,u)){ee=!0;continue}y=[...y,{id:Mo(),value:ie,colorIndex:y.length}],$=!0}}return $&&Y(y),ee&&V(),$}function L(q){return ue([q])}function B(q){const y=O.filter($=>$.id!==q);Y(y.map(($,ee)=>({...$,colorIndex:ee})))}function ce(q,y){const $=y.trim();if(w(null),X(""),!$){B(q);return}if(!(!d&&O.some(ee=>ee.id!==q&&ee.value.toLowerCase()===$.toLowerCase()))){if(!Ul($,u)){V();return}Y(O.map(ee=>ee.id===q?{...ee,value:$}:ee))}}function H(q){o||(w(q.id),X(q.value),setTimeout(()=>{var y;return(y=Q.current)==null?void 0:y.select()},0))}function oe(q){if(q.key==="Enter"||i.includes(q.key)){q.preventDefault(),L(N)&&x("");return}if(q.key==="Backspace"&&N===""&&O.length>0){q.preventDefault();const y=O[O.length-1];B(y.id)}}function k(q,y){if(q.key==="Enter"){q.preventDefault(),ce(y,P),setTimeout(()=>{var $;return($=ae.current)==null?void 0:$.focus()},0);return}q.key==="Escape"&&(q.preventDefault(),w(null),X(""),setTimeout(()=>{var $;return($=ae.current)==null?void 0:$.focus()},0))}function te(){var q;o||(q=ae.current)==null||q.focus()}function z(q){if(o)return;const y=q.clipboardData.getData("text");if(!y||!(i.some(ie=>ie&&y.includes(ie))||y.includes(`
31
- `)))return;q.preventDefault();const ee=Ff(y,i);ue(ee)&&x("")}function I(){const q=N.trim();q&&L(q)&&x("")}const de=v?"var(--danger)":K?"var(--primary)":"var(--border)",re=c!==void 0&&O.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||p||C)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),p&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),C?t.jsx(Tr,{content:b}):null]}),t.jsxs("div",{ref:R,onClick:te,onFocus:()=>D(!0),onBlur:q=>{var y;(y=R.current)!=null&&y.contains(q.relatedTarget)||(D(!1),M!==null&&ce(M,P),M===null&&I())},style:{borderColor:de},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 xo(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=yo(d);!u||r.has(u)||(r.add(u),n.push(u))},o=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=o.exec(e))!==null;)a(l[1]??"");const i=wl(e);go.lastIndex=0;let c;for(;(c=go.exec(i))!==null;)a(c[1]??"");return n}function Nl(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function af(e,r){const n=xo(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(yo(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 kl(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 of(e,r){return r?e.filter(n=>n.userId!==r):e}function wo(e){var n;let r=e.nextSibling;for((r==null?void 0:r.nodeType)===Node.TEXT_NODE&&/^[ \u00a0]/.test(r.textContent??"")&&(r=r.nextSibling);r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").replace(/\u00a0/g," ").trim();)r=r.nextSibling;return r&&r.nodeType===Node.ELEMENT_NODE&&((n=r.classList)!=null&&n.contains("mention-chip"))?" ":!r||r.nodeType===Node.ELEMENT_NODE&&r.tagName==="BR"?" ":" "}function Sl(e){return!e||!/@/.test(e)?e:e.replace(go,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=o[a+r.length]??"";return u===" "||u===" "?`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>`:`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>${u?" ":" "}`})}function dn(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,o=wo(n),l=n.nextSibling;if((l==null?void 0:l.nodeType)===Node.TEXT_NODE){const i=l.textContent??"";if(i.startsWith(o))return;if(i.startsWith(" ")||i.startsWith(" ")){l.textContent=`${o}${i.slice(1)}`;return}if(i.length>0){l.textContent=`${o}${i}`;return}}n.after(a.createTextNode(o))})}function No(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&dn(a);const o=wo(e);let l=e.nextSibling;!l||l.nodeType!==Node.TEXT_NODE||!/^[ \u00a0]/.test(l.textContent??"")?(l=r.createTextNode(o),e.after(l)):(l.textContent??"").startsWith(o)||(l.textContent=`${o}${(l.textContent??"").slice(1)}`);const i=n==null?void 0:n.getSelection();if(!i)return;const c=r.createRange();c.setStart(l,((d=l.textContent)==null?void 0:d.length)??1),c.collapse(!0),i.removeAllRanges(),i.addRange(c)}const sf=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function El(e,r){return sf.has(e.tagName)&&e!==r}function ko(e,r){let n="",a,o,l=!1;const i=(f,p)=>{if(l||!(r!=null&&r.domPoint))return;const{container:g,offset:k}=r.domPoint;g===f&&k===p&&(o=n.length,l=!0)},c=(f,p)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:p},!0),d=f=>(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":(n+=`
29
+ `,(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":!1),u=f=>{const p=f.data;for(let g=0;g<=p.length;g+=1){if(i(f,g),c(f,g))return!0;g<p.length&&(n+=p[g])}return!1},m=(f,p)=>{if(p&&n.length>0&&!n.endsWith(`
30
+ `)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const g=f;if(g.tagName==="BR")return i(g,0),d(g.nextSibling??void 0)==="matched";const k=Array.from(f.childNodes);for(let v=0;v<k.length;v+=1){const A=k[v],E=v>0&&A.nodeType===Node.ELEMENT_NODE&&El(A,e);if(m(A,E))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const p=b[f],g=f>0&&p.nodeType===Node.ELEMENT_NODE&&El(p,e);if(m(p,g))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=f.nextNode(),g=p;for(;g;)p=g,g=f.nextNode();p&&(a={node:p,offset:p.data.length})}return{plain:n,locate:a,domOffset:o}}function So(e){return ko(e).plain}function Or(e,r){return r<0?null:ko(e,{locatePlain:r}).locate??null}function Qn(e,r,n){return e!==r&&!e.contains(r)?-1:ko(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function Cl(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Or(e,n),i=Or(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=Nl({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 b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),dn(e),No(m);const p=c.defaultView,g=p==null?void 0:p.getSelection(),k=g!=null&&g.rangeCount?Qn(e,g.getRangeAt(0).startContainer,g.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:k>=0?k:n+u.length+1}}function Ml(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Or(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Jn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function Tl(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 $l(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 Hr(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Rn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function Al(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Rn(e)}function Ll(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function Dl(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Hr(e),!0):!1}function ea(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,p)=>{let g=f;for(;g&&g.nodeType===Node.TEXT_NODE&&(g.textContent??"")==="";){const k=g;g=g[p],k.remove()}return g},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function Ol(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=Tl(a.previousSibling,"prev");return Jn(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(Jn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Hl(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=Tl(a.nextSibling,"next");if(Jn(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(Jn(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 Co=420,ta=6,Il=260,lf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Bl=4,cf={position:"relative"},df={position:"fixed",zIndex:11050,minWidth:Il,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},Fl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function uf(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function ff(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Il-8)),n=window.innerHeight-e.bottom-ta-8,a=e.top-ta-8;return n<Math.min(Co,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ta,maxHeight:Math.min(Co,Math.max(120,a))}:{left:r,top:e.bottom+ta,maxHeight:Math.min(Co,Math.max(120,n))}}function Pl({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="",toolbarVariant:b="full"}){const f=s.useId().replace(/:/g,""),p=s.useRef(null),g=s.useRef(null),k=s.useRef(new Map),v=s.useRef(n);v.current=n;const A=s.useRef(null),E=s.useRef(0),M=s.useRef([]),H=s.useRef(null),[S,x]=s.useState(null),[C,w]=s.useState([]),[P,V]=s.useState(0),[X,O]=s.useState([]),[K,q]=s.useState(!1),[le,J]=s.useState(!1);E.current=P,s.useEffect(()=>{J(!0)},[]);const G=(S==null?void 0:S.query)??null;s.useEffect(()=>{if(G===null){w([]);return}const N=G.trim(),R=`${m}|${N.toLowerCase()||"*"}`,ae=k.current.get(R);if(ae){w(ae),q(!1),V(0);return}const $=new AbortController;q(!0);const ne=window.setTimeout(()=>{(async()=>{try{const te=await v.current(N,{signal:$.signal,limit:c});if($.signal.aborted)return;const j=Array.isArray(te)?te:[];k.current.set(R,j),w(j),V(0)}catch{$.signal.aborted||w([])}finally{$.signal.aborted||q(!1)}})()},d);return()=>{$.abort(),window.clearTimeout(ne)}},[G,c,d,m]);const U=s.useRef(a);U.current=a,s.useEffect(()=>{var N;(N=U.current)==null||N.call(U,kl(X))},[X]);const Y=s.useCallback(()=>{const N=uf(f);if(N.length===0)return null;const R=window.getSelection();if(R!=null&&R.rangeCount){const $=R.getRangeAt(0).startContainer;for(const ne of N)if(ne.contains($))return ne}const ae=document.activeElement;for(const $ of N)if(ae===$||ae&&$.contains(ae))return $;for(const $ of N)if($.closest('[role="dialog"]'))return $;return N[0]??null},[f]),ue=s.useCallback(()=>{const N=Y(),R=window.getSelection();if(!N||!R||R.rangeCount===0){x(null);return}const ae=R.getRangeAt(0);if(!N.contains(ae.startContainer)){x(null);return}const $=Qn(N,ae.startContainer,ae.startOffset);if($<0){x(null);return}const ne=vo(N,$);if(!ne){x(null);return}const te=ae.getBoundingClientRect(),j=te.width===0&&te.height===0?(()=>{const T=document.createRange();return T.selectNodeContents(ae.startContainer),T.collapse(!0),T.getBoundingClientRect()})():te;A.current={query:ne.query,caretIndex:ne.caretIndex,triggerIndex:ne.triggerIndex};const y=ff(j);x(T=>{const ee={query:ne.query,...y};return T&&T.query===ee.query&&T.top===ee.top&&T.bottom===ee.bottom&&T.left===ee.left&&T.maxHeight===ee.maxHeight?T:ee})},[Y]),L=s.useCallback(N=>{r(N),ue()},[r,ue]);s.useEffect(()=>{const N=R=>{if(lf.has(R.key))return;const ae=Y(),$=R.target;!ae||!$||!ae.contains($)||ue()};return document.addEventListener("keyup",N,!0),()=>document.removeEventListener("keyup",N,!0)},[Y,ue]);const B=s.useCallback(N=>{const R=Y();if(!R)return;let ae=-1;const $=window.getSelection();if($&&$.rangeCount>0){const T=$.getRangeAt(0);R.contains(T.startContainer)&&(ae=Qn(R,T.startContainer,T.startOffset))}if(ae<0&&A.current&&(ae=A.current.caretIndex),ae<0)return;const ne=vo(R,ae);if(!ne)return;const te=Cl(R,{triggerIndex:ne.triggerIndex,caretIndex:ae,username:N.username,display:N.name,userId:N.userId});if(!te)return;dn(R),R.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const j={userId:N.userId,username:N.username,email:N.email??void 0,display:N.name??N.username};O(T=>{const ee=new Map(T.map(fe=>[fe.userId,fe]));return ee.set(j.userId,j),Array.from(ee.values())}),x(null),A.current=null;const y=N.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const T=Y();if(!T)return;T.focus(),dn(T);const ee=Array.from(T.querySelectorAll(".mention-chip")),fe=[...ee].reverse().find(ie=>ie.getAttribute("data-username")===y)??ee[ee.length-1];if(fe){No(fe);return}Ml(T,te.caretPlainOffset)})})},[Y]);s.useEffect(()=>{const N=new Set(xo(e).map(R=>R.toLowerCase()));O(R=>{const ae=R.filter($=>N.has($.username.toLowerCase()));return ae.length===R.length?R:ae})},[e]),s.useEffect(()=>{if(!S)return;const N=R=>{const ae=R.target;if(!ae||p.current&&p.current.contains(ae)||g.current&&g.current.contains(ae))return;const $=Y();$&&$.contains(ae)||x(null)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[S,Y]);const de=s.useMemo(()=>C.slice(0,c),[C,c]);M.current=de,s.useEffect(()=>{if(!S)return;const N=R=>{const ae=Y(),$=R.target;if(!ae||!$||!ae.contains($))return;const ne=M.current;if(!(ne.length===0&&R.key!=="Escape"))if(R.key==="ArrowDown")R.preventDefault(),R.stopPropagation(),V(te=>(te+1)%Math.max(ne.length,1));else if(R.key==="ArrowUp")R.preventDefault(),R.stopPropagation(),V(te=>(te-1+ne.length)%Math.max(ne.length,1));else if(R.key==="Enter"||R.key==="Tab"){const te=ne[E.current];te&&(R.preventDefault(),R.stopPropagation(),B(te))}else R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),x(null))};return document.addEventListener("keydown",N,!0),()=>document.removeEventListener("keydown",N,!0)},[Y,B,S]),s.useEffect(()=>{const N=j=>{j.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},R=j=>{const y=Y(),T=j.target;if(!y||!T||!y.contains(T))return;if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),y.focus(),Al(y);return}if(j.key!=="Backspace"&&j.key!=="Delete")return;const ee=window.getSelection();if(ee&&!ee.isCollapsed&&ee.rangeCount>0){const he=ee.getRangeAt(0);if(y.contains(he.commonAncestorContainer)&&Eo(y).length>0&&Ll(he)){j.preventDefault(),j.stopPropagation(),Dl(y)&&N(y);return}}const fe=Eo(y);if(fe.length>0){j.preventDefault(),j.stopPropagation();for(const he of fe)ea(he);Hr(y),N(y);return}if(j.key==="Backspace"){const he=Ol(y);if(!he)return;j.preventDefault(),j.stopPropagation(),ea(he),Hr(y),N(y);return}const ie=Hl(y);ie&&(j.preventDefault(),j.stopPropagation(),ea(ie),Hr(y),N(y))},ae=j=>{const y=Y();if(!y)return;const T=j.target;if(!(T instanceof Element)||!y.contains(T))return;const ee=T.closest(".mention-chip");if(!(ee instanceof HTMLElement)||!y.contains(ee)){H.current=null,Hr(y);return}j.shiftKey||j.button!==0||(H.current={chip:ee,x:j.clientX,y:j.clientY})},$=j=>{const y=H.current;if(!y)return;const T=Math.abs(j.clientX-y.x),ee=Math.abs(j.clientY-y.y);(T>Bl||ee>Bl)&&(H.current=null)},ne=j=>{var ie;const y=Y(),T=H.current;if(H.current=null,!y||!T)return;const ee=j.target;if(!(ee instanceof Element)||!y.contains(ee)||!((ie=ee.closest(".mention-chip"))!=null&&ie.isSameNode(T.chip)))return;const fe=window.getSelection();if(fe){if(!fe.isCollapsed){Rn(y);return}y.focus(),$l(T.chip)}},te=()=>{const j=Y();if(!j)return;const y=window.getSelection();!y||y.rangeCount===0||!y.anchorNode||!j.contains(y.anchorNode)||!y.focusNode||!j.contains(y.focusNode)||Rn(j)};return document.addEventListener("keydown",R,!0),document.addEventListener("mousedown",ae,!0),document.addEventListener("mousemove",$,!0),document.addEventListener("mouseup",ne,!0),document.addEventListener("selectionchange",te),()=>{document.removeEventListener("keydown",R,!0),document.removeEventListener("mousedown",ae,!0),document.removeEventListener("mousemove",$,!0),document.removeEventListener("mouseup",ne,!0),document.removeEventListener("selectionchange",te)}},[Y]),s.useEffect(()=>{if(!S||!g.current)return;const N=g.current.querySelector(`[data-mention-index="${P}"]`);N==null||N.scrollIntoView({block:"nearest"})},[P,S]);const I=u?Sl(e):e,oe=S&&le?pt.createPortal(t.jsxs("ul",{ref:g,style:{...df,left:S.left,top:S.top,bottom:S.bottom,maxHeight:S.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[K&&de.length===0&&t.jsx("li",{style:Fl,children:"Buscando…"}),!K&&de.length===0&&t.jsx("li",{style:Fl,children:S.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${S.query}”`}),de.map((N,R)=>{var ae,$;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":R,onMouseDown:ne=>{ne.preventDefault(),B(N)},onMouseEnter:()=>V(R),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:R===P?"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:((ae=N.name)==null?void 0:ae.trim())||`@${N.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[($=N.name)!=null&&$.trim()?`@${N.username}`:null,N.email].filter(Boolean).join(" · ")||`@${N.username}`})]})},N.userId)})]}),document.body):null;return t.jsxs("div",{ref:p,style:cf,className:i,children:[t.jsx(hl,{value:I,onChange:L,placeholder:l,minHeight:o,instanceId:f,toolbarVariant:b}),oe]})}function bf({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}){return o?t.jsx(Pl,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}):t.jsx(hl,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function mf({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:o}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const hf={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)"}},pf={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 gf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=hf[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 ${pf[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 _l={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)"}},vf={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"},yf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},xf={xs:148,sm:164,md:184},wf={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 Nf({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:b,optionClassName:f,spinnerClassName:p}){const[g,k]=s.useState(!1),[v,A]=s.useState(!1),[E,M]=s.useState(-1),[H,S]=s.useState({}),x=s.useRef(null),C=s.useRef(null),w=s.useRef(null),P=r.find(U=>U.value===e)??r[0],V={...P!=null&&P.tone?_l[P.tone]:void 0,...P==null?void 0:P.style},X=o||l||r.length===0,O=U=>{i&&U.stopPropagation()},K=s.useCallback(()=>{k(!1),M(-1)},[]),q=s.useCallback(()=>{const U=x.current;if(!U)return;const Y=U.getBoundingClientRect(),ue=Math.max(Y.width,xf[a]),L=Math.min(Math.max(r.length,1)*38+12,260),B=window.innerHeight-Y.bottom,de=B<L&&Y.top>B,I=Math.min(Math.max(8,Y.left+Y.width/2-ue/2),window.innerWidth-ue-8);S({position:"fixed",left:I,top:de?void 0:Y.bottom+6,bottom:de?window.innerHeight-Y.top+6:void 0,width:ue,zIndex:9999})},[r.length,a]),le=s.useCallback(U=>{U.disabled||(n(U.value),K())},[K,n]);s.useEffect(()=>A(!0),[]),s.useEffect(()=>{if(!g)return;q();const U=r.findIndex(Y=>Y.value===e);M(U>=0?U:0)},[g,r,q,e]),s.useEffect(()=>{if(!g)return;function U(Y){var L,B;const ue=Y.target;!((L=x.current)!=null&&L.contains(ue))&&!((B=C.current)!=null&&B.contains(ue))&&K()}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[K,g]),s.useEffect(()=>{if(g)return window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[g,q]),s.useEffect(()=>{if(E<0||!w.current)return;const U=w.current.children[E];U==null||U.scrollIntoView({block:"nearest"})},[E]);function J(U){if(!X){if(!g){["Enter"," ","ArrowDown","ArrowUp"].includes(U.key)&&(U.preventDefault(),k(!0));return}if(U.key==="Escape"){U.preventDefault(),K();return}if(U.key==="ArrowDown"){U.preventDefault(),M(Y=>Math.min(Y+1,r.length-1));return}if(U.key==="ArrowUp"){U.preventDefault(),M(Y=>Math.max(Y-1,0));return}if(U.key==="Enter"||U.key===" "){U.preventDefault();const Y=r[E];Y&&le(Y)}}}const G=t.jsx("div",{ref:C,role:"listbox","aria-label":c,className:Qt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...H,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:O,onMouseDown:O,onPointerDown:O,children:t.jsx("div",{ref:w,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((U,Y)=>{const ue=U.value===e,L=Y===E,B={...U.tone?_l[U.tone]:void 0,...U.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ue,disabled:U.disabled,onMouseEnter:()=>!U.disabled&&M(Y),onMouseDown:de=>{de.preventDefault(),le(U)},className:Qt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",wf[a],ue?U.className:void 0,f),style:{...ue?B:void 0,background:ue?B.background??"color-mix(in srgb, var(--primary) 12%, transparent)":L?"var(--bg-hover)":"transparent",color:ue?B.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ue?t.jsx(W.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.label})]},U.value)})})});return t.jsxs("span",{ref:x,className:Qt("relative inline-flex shrink-0 items-center",u),onKeyDown:J,onClick:O,onPointerDown:O,children:[t.jsx("button",{type:"button",disabled:X,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":g,title:d,onClick:()=>!X&&k(U=>!U),className:Qt("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",vf[a],P==null?void 0:P.className,m),style:V,children:t.jsx("span",{className:"min-w-0 truncate",children:(P==null?void 0:P.label)??e})}),t.jsx(W.HiChevronDown,{"aria-hidden":"true",className:Qt("pointer-events-none absolute opacity-70 transition-transform",yf[a],g?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Qt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",p)}),g&&v&&pt.createPortal(G,document.body)]})}function kf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(g=>!g.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(g=>g.id===m)??u,f=g=>{g.disabled||a==null||a(g.id)},p=g=>{const k=e.filter(A=>!A.disabled);if(!k.length||!b)return;const v=k.findIndex(A=>A.id===b.id);(g.key==="ArrowRight"||g.key==="ArrowDown")&&(g.preventDefault(),f(k[(v+1)%k.length])),(g.key==="ArrowLeft"||g.key==="ArrowUp")&&(g.preventDefault(),f(k[(v-1+k.length)%k.length])),g.key==="Home"&&(g.preventDefault(),f(k[0])),g.key==="End"&&(g.preventDefault(),f(k[k.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:p,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(g=>{const k=g.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${g.id}-panel`,id:`${g.id}-tab`,disabled:g.disabled,tabIndex:k?0:-1,onClick:()=>f(g),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[g.icon&&t.jsx("span",{className:"shrink-0",children:g.icon}),t.jsx("span",{children:g.label}),g.badge&&t.jsx("span",{className:"shrink-0",children:g.badge})]},g.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function rr(...e){return e.filter(Boolean).join(" ")}function Sf({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:b="Siguiente",blockedNextLabel:f="Completa este paso",className:p="",headerClassName:g="",contentClassName:k="",footerClassName:v=""}){var ae;const A=((ae=e[0])==null?void 0:ae.id)??"",[E,M]=s.useState(n??A),[H,S]=s.useState(o),x=r??E,C=a??H,w=s.useMemo(()=>new Set(C),[C]),P=Math.max(0,e.findIndex($=>$.id===x)),V=e[P]??e[0],X=e.length<=1?100:P/(e.length-1)*100,O=$=>{a||S($),i==null||i($)},K=$=>{const ne=e.find(te=>te.id===$);ne&&(r||M($),l==null||l($,ne))},q=$=>w.has($),le=$=>e.slice(0,$).find(ne=>!ne.optional&&!w.has(ne.id)),J=$=>{const ne=e[$];return!ne||ne.disabled?!1:$===P||d&&$<P?!0:!le($)},G=$=>{const ne=e.findIndex(te=>te.id===$);return ne>=0&&J(ne)},U=$=>{const ne=e.findIndex(te=>te.id===$);if(ne<0)return!1;if(!J(ne)){const te=le(ne);return te&&(c==null||c(e[ne],te)),!1}return K($),!0},Y=($=V==null?void 0:V.id)=>{!$||w.has($)||O([...C,$])},ue=($=V==null?void 0:V.id)=>{if(!$)return;const ne=e.findIndex(j=>j.id===$),te=C.filter(j=>{const y=e.findIndex(T=>T.id===j);return y>=0&&y<ne});O(te),ne>=0&&P>ne&&K($)},L=()=>P<=0?!1:U(e[P-1].id),B=()=>{const $=e[P+1];return $?U($.id):!1},de={activeStep:V,activeIndex:P,completedStepIds:C,isCompleted:q,isUnlocked:G,completeStep:Y,uncompleteStep:ue,goToStep:U,goNext:B,goPrevious:L};if(!V)return null;const I=e[P+1],oe=P>0,N=I?G(I.id):!1,R=typeof V.content=="function"?V.content(de):V.content;return t.jsxs("section",{className:rr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[t.jsxs("div",{className:rr("border-b border-[var(--border)] bg-[var(--bg-input)]",g),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${X}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(($,ne)=>{const te=$.id===V.id,j=q($.id),y=J(ne),T=le(ne);return t.jsxs("button",{type:"button",disabled:!y,"aria-current":te?"step":void 0,"aria-disabled":!y,title:!y&&T?`Completa ${T.title}`:$.title,onClick:()=>U($.id),className:rr("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",te&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",j&&!te&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!te&&!j&&y&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!y&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:rr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",te&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:rr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",te&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",j&&!te&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!j&&!te&&y&&"border-[var(--border)] text-[var(--text-muted)]",!y&&"border-[var(--border)] text-[var(--text-muted)]"),children:j?t.jsx(W.HiCheck,{className:"h-4 w-4"}):y?ne+1:t.jsx(W.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:rr("block truncate text-xs font-semibold transition-colors duration-200",te?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[ne+1,". ",$.title]}),$.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:$.description})]}),$.badge&&t.jsx("span",{className:"shrink-0",children:$.badge})]})]},$.id)})})]}),t.jsx("div",{className:rr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",k),children:R},V.id),u&&t.jsxs("div",{className:rr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Ge,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(W.HiChevronLeft,{}),disabled:!oe,onClick:L,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",P+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[C.length," completados"]})]}),t.jsx(Ge,{height:38,padding:"0 14px",icon:t.jsx(W.HiChevronRight,{}),disabled:!I||!N,onClick:B,children:I&&!N?f:b})]})]})}const Ef={sm:"px-2.5 py-1.5 text-xs leading-5",md:"px-2.5 py-1.5 text-sm leading-5",lg:"px-3 py-2 text-sm leading-6"};function Cf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Mf(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),o=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(o)?o:2}}function zl(e,r){const{lineHeight:n,paddingY:a,borderY:o}=Mf(e);return Math.ceil(r*n+a+o)}const Wl=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const p=s.useRef(null),g=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",k=s.useCallback(()=>{const v=p.current;if(!v)return;v.style.height="auto";const A=v.scrollHeight,E=zl(v,i),M=o??(l!==void 0?zl(v,l):void 0),H=M!==void 0?Math.min(Math.max(A,E),M):Math.max(A,E);v.style.height=`${H}px`,v.style.overflowY=M!==void 0&&A>M?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{k()},[k,d,u]),s.useEffect(()=>{const v=p.current;if(!v||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>k());return A.observe(v),()=>A.disconnect()},[k]),t.jsx("textarea",{...b,ref:v=>{p.current=v,Cf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{k(),m==null||m(v)},style:{...c,borderColor:g,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Ef[n]} ${r}`})});function Tf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Wn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Wl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const $f={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"},Af={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Lf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Df(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const jl=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:p,value:g,defaultValue:k,maxLength:v,onInput:A,...E},M){const H=s.useRef(null),S=Df(g,k),x=u??v,C=!!(b||f||d),w=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",P={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},V=()=>{const O=H.current;!O||!l||(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)};s.useEffect(V,[l,g]);const X=t.jsx("textarea",{...E,ref:O=>{H.current=O,Lf(M,O)},value:g,defaultValue:k,maxLength:v,"aria-invalid":m==="error"||E["aria-invalid"],onInput:O=>{V(),A==null||A(O)},style:{...P,borderColor:w},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 ${$f[a]} ${Af[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return C?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),X,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[S,x?`/${x}`:""]})]}):X});function Of({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Wn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(jl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const ql=[{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 Hf(e){return ql[e%ql.length]}let If=0;function Mo(){return++If}function Ul(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Bf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ff(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Bf(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Pf({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:b,helperDisplay:f="inline",error:p,required:g=!1}){const k=e!==void 0,v=!!p,A=!!b&&f==="tooltip"&&!v,[E,M]=s.useState(()=>(r??[]).map((j,y)=>({id:Mo(),value:j.trim(),colorIndex:y})));s.useEffect(()=>{k&&M(j=>{const y=e??[],T=new Map(j.map(ee=>[ee.value,ee]));return y.map((ee,fe)=>T.get(ee)??{id:Mo(),value:ee,colorIndex:fe})})},[k,e]);const H=E,[S,x]=s.useState(""),[C,w]=s.useState(null),[P,V]=s.useState(""),[X,O]=s.useState(!1),[K,q]=s.useState(!1),le=s.useRef(null),J=s.useRef(null),G=s.useRef(null);function U(){q(!0),setTimeout(()=>q(!1),400)}function Y(j){M(j),n==null||n(j.map(y=>y.value))}function ue(j){let y=H,T=!1,ee=!1;for(const fe of j){const ie=fe.trim();if(ie){if(c!==void 0&&y.length>=c){ee=!0;break}if(!d&&y.some(he=>he.value.toLowerCase()===ie.toLowerCase())){ee=!0;continue}if(!Ul(ie,u)){ee=!0;continue}y=[...y,{id:Mo(),value:ie,colorIndex:y.length}],T=!0}}return T&&Y(y),ee&&U(),T}function L(j){return ue([j])}function B(j){const y=H.filter(T=>T.id!==j);Y(y.map((T,ee)=>({...T,colorIndex:ee})))}function de(j,y){const T=y.trim();if(w(null),V(""),!T){B(j);return}if(!(!d&&H.some(ee=>ee.id!==j&&ee.value.toLowerCase()===T.toLowerCase()))){if(!Ul(T,u)){U();return}Y(H.map(ee=>ee.id===j?{...ee,value:T}:ee))}}function I(j){o||(w(j.id),V(j.value),setTimeout(()=>{var y;return(y=J.current)==null?void 0:y.select()},0))}function oe(j){if(j.key==="Enter"||i.includes(j.key)){j.preventDefault(),L(S)&&x("");return}if(j.key==="Backspace"&&S===""&&H.length>0){j.preventDefault();const y=H[H.length-1];B(y.id)}}function N(j,y){if(j.key==="Enter"){j.preventDefault(),de(y,P),setTimeout(()=>{var T;return(T=le.current)==null?void 0:T.focus()},0);return}j.key==="Escape"&&(j.preventDefault(),w(null),V(""),setTimeout(()=>{var T;return(T=le.current)==null?void 0:T.focus()},0))}function R(){var j;o||(j=le.current)==null||j.focus()}function ae(j){if(o)return;const y=j.clipboardData.getData("text");if(!y||!(i.some(ie=>ie&&y.includes(ie))||y.includes(`
31
+ `)))return;j.preventDefault();const ee=Ff(y,i);ue(ee)&&x("")}function $(){const j=S.trim();j&&L(j)&&x("")}const ne=v?"var(--danger)":X?"var(--primary)":"var(--border)",te=c!==void 0&&H.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||g||A)&&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}),g&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(Tr,{content:b}):null]}),t.jsxs("div",{ref:G,onClick:R,onFocus:()=>O(!0),onBlur:j=>{var y;(y=G.current)!=null&&y.contains(j.relatedTarget)||(O(!1),C!==null&&de(C,P),C===null&&$())},style:{borderColor:ne},className:`
32
32
  flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
33
33
  bg-[var(--bg-input)] px-2.5 py-2 transition-colors
34
34
  ${o?"cursor-not-allowed opacity-60":"cursor-text"}
35
- ${G?"animate-[tag-shake_0.4s_ease]":""}
35
+ ${K?"animate-[tag-shake_0.4s_ease]":""}
36
36
  `,children:[t.jsx("style",{children:`
37
37
  @keyframes tag-shake {
38
38
  0%,100% { transform: translateX(0); }
@@ -41,7 +41,7 @@ ${_}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
41
41
  60% { transform: translateX(-3px); }
42
42
  80% { transform: translateX(3px); }
43
43
  }
44
- `}),O.map(q=>{const y=Hf(q.colorIndex);return M===q.id?t.jsx("input",{ref:Q,value:P,disabled:o,onChange:$=>X($.target.value),onKeyDown:$=>k($,q.id),onBlur:()=>ce(q.id,P),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(P.length+2,6)}ch`}},q.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:y.bg,color:y.text,border:`1px solid ${y.border}`},children:[t.jsx("span",{className:"truncate",children:q.value}),t.jsx("button",{type:"button","aria-label":`Editar "${q.value}"`,disabled:o,tabIndex:-1,onClick:$=>{$.stopPropagation(),H(q)},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(j.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${q.value}"`,disabled:o,tabIndex:-1,onClick:$=>{$.stopPropagation(),B(q.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(j.HiXMark,{className:"h-3.5 w-3.5"})})]},q.id)}),!re&&t.jsx("input",{ref:ae,value:N,disabled:o,placeholder:O.length===0?a:"",onChange:q=>x(q.target.value),onKeyDown:oe,onPaste:z,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($r,{error:g,helperText:b,helperDisplay:f})]})}const _f=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function tt(e){return String(e).padStart(2,"0")}function To(e,r=Ir()){const n=e.trim();if(!n)return r;const a=n.match(_f);if(!a)return r;const o=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(i)||o<0||o>23||l<0||l>59||i<0||i>59?r:{hour24:o,minute:l,second:i}}function un(e,r=!0){const n=`${tt(e.hour24)}:${tt(e.minute)}`;return r?`${n}:${tt(e.second)}`:n}function ra(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function fn(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function zf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=To(e);if(n){const l=ra(o),i=`${l.hour12}:${tt(l.minute)}`;return`${a?`${i}:${tt(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Ir(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function Wf(e=!0){return un(Ir(),e)}function $o(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const wt=36,Ao=5,Vl=Math.floor(Ao/2),jf=52,qf=48,Xt=18;function Yl(e){return e*wt}function Xl(e){return Math.round(e/wt)}function Uf(e){return e.use12Hour??e.hour12??!1}function na({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=jf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const p=s.useRef(null),S=s.useRef(null),v=s.useRef(null),C=s.useRef(""),T=s.useRef(0),E=s.useRef(!1),[O,N]=s.useState(r),[x,M]=s.useState(""),w=s.useCallback(H=>{C.current=H,M(H)},[]),P=s.useMemo(()=>[...Array(Vl).fill(""),...e,...Array(Vl).fill("")],[e]),X=s.useCallback(()=>{const H=p.current;if(!H)return r;const oe=Xl(H.scrollTop),k=Math.min(Math.max(oe,0),e.length-1);return e[k]??r},[r,e]),K=s.useCallback((H,oe=!0)=>{const k=Math.min(Math.max(H,0),e.length-1),te=e[k],z=p.current;!z||!te||(S.current&&(window.clearTimeout(S.current),S.current=null),E.current=!0,T.current=k,z.scrollTop=Yl(k),N(te),oe&&te!==r&&n(te))},[n,r,e]);s.useLayoutEffect(()=>{S.current&&(window.clearTimeout(S.current),S.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),w(""),N(r);const H=e.indexOf(r);if(H>=0&&(T.current=H),H<0||!p.current)return;const oe=Yl(H);p.current.scrollTop!==oe&&(p.current.scrollTop=oe)},[o,r,w,e]);const D=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),G=s.useCallback((H,oe=!1)=>{D(),w("");const k=Number(H);if(!Number.isFinite(k))return;const te=Math.min(c,Math.max(0,k));let z=tt(te),I=e.indexOf(z);if(I<0){const de=Math.min(e.length-1,Math.max(0,te-(c===12?1:0)));z=e[de]??z,I=e.indexOf(z)}I>=0&&K(I),oe&&(b==null||b())},[D,c,b,K,w,e]),U=s.useCallback(H=>{const oe=Math.floor(c/10),k=C.current;if(k===""){if(H>oe){G(String(H),!0);return}const z=String(H);w(z),v.current=window.setTimeout(()=>{G(C.current,!0)},1200);return}D();const te=+`${k}${H}`;te<=c?G(String(te),!0):G(String(H),!0)},[D,G,c,w]),ae=s.useCallback(H=>{D(),w(""),K(T.current+H)},[D,K,w]),Q=H=>{if(d){H.key==="a"||H.key==="A"?(H.preventDefault(),n("AM"),b==null||b()):H.key==="p"||H.key==="P"?(H.preventDefault(),n("PM"),b==null||b()):H.key==="ArrowUp"||H.key==="ArrowDown"?(H.preventDefault(),n(r==="AM"?"PM":"AM")):H.key==="Tab"&&(H.preventDefault(),H.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(H.key)){H.preventDefault(),U(Number(H.key));return}H.key==="ArrowUp"?(H.preventDefault(),ae(-1)):H.key==="ArrowDown"?(H.preventDefault(),ae(1)):H.key==="Tab"&&(H.preventDefault(),D(),C.current!==""&&G(C.current,!1),H.shiftKey?f==null||f():b==null||b())},R=s.useCallback(()=>{const H=a.current,oe=p.current;oe&&H===a.current&&K(Xl(oe.scrollTop))},[K,a]),V=()=>{if(C.current!=="")return;if(E.current){E.current=!1;const oe=X();N(oe);const k=e.indexOf(oe);k>=0&&(T.current=k);return}N(X()),S.current&&window.clearTimeout(S.current);const H=a.current;S.current=window.setTimeout(()=>{H===a.current&&R()},100)},Y="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",ue=wt*Ao,L=ue+Xt*2,B=x!==""?x:null,ce=B!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":B??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:Q,onBlur:()=>{D(),C.current!==""&&G(C.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:L,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:Y,style:{top:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(-1),children:t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:p,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Xt,height:ue,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:V,onMouseUp:R,onTouchEnd:R,children:P.map((H,oe)=>{const k=H!==""&&H===O;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!H,onClick:()=>{if(!H)return;const te=e.indexOf(H);te>=0&&K(te)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:wt,scrollSnapAlign:"center",color:k?"var(--text-main)":"var(--text-muted)",fontSize:k?16:14,fontWeight:k?600:400,opacity:H?ce?k?0:.35:k?1:.35:0},children:H},`wheel-${oe}-${H}`)})}),B!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:Xt+ue/2-wt/2,height:wt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:B}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:Y,style:{bottom:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(1),children:t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Kl(){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:wt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Gl({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",b=m||!d,f=Uf({use12Hour:n,hour12:a}),g=s.useRef(e),p=To(e,Ir()),S=ra(p),[v,C]=s.useState(tt(f?S.hour12:p.hour24)),[T,E]=s.useState(tt(p.minute)),[O,N]=s.useState(tt(p.second)),[x,M]=s.useState(S.meridiem),[w,P]=s.useState(0),X=s.useRef(0),K=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[G,U]=s.useState("hour"),ae=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,o]),Q=s.useCallback(ie=>{U(he=>{const Te=ae.indexOf(he);return ae[(Te+ie+ae.length)%ae.length]})},[ae]);s.useEffect(()=>{var ie;(ie=D.current[G])==null||ie.focus()},[G]),s.useEffect(()=>{var ie;U("hour"),(ie=D.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===g.current)return;g.current=e;const ie=To(e,Ir()),he=ra(ie);C(tt(f?he.hour12:ie.hour24)),E(tt(ie.minute)),N(tt(ie.second)),M(he.meridiem)},[f,e]);const R=s.useMemo(()=>(f?$o(1,12):$o(0,23)).map(ie=>tt(ie)),[f]),V=s.useMemo(()=>$o(0,59).map(ie=>tt(ie)),[]),Y=V,ue=s.useMemo(()=>["AM","PM"],[]),L=s.useCallback(()=>f?fn({hour12:Number(v),minute:Number(T),second:Number(O),meridiem:x}):{hour24:Number(v),minute:Number(T),second:Number(O)},[v,f,x,T,O]),B=s.useCallback(ie=>{if(K.current)return;const he=un(ie,o);g.current=he,r(he)},[r,o]),ce=s.useCallback(()=>{B(L())},[L,B]),H=ie=>{C(ie),b&&B(f?fn({hour12:Number(ie),minute:Number(T),second:Number(O),meridiem:x}):{hour24:Number(ie),minute:Number(T),second:Number(O)})},oe=ie=>{E(ie),b&&B(f?fn({hour12:Number(v),minute:Number(ie),second:Number(O),meridiem:x}):{hour24:Number(v),minute:Number(ie),second:Number(O)})},k=ie=>{N(ie),b&&B(f?fn({hour12:Number(v),minute:Number(T),second:Number(ie),meridiem:x}):{hour24:Number(v),minute:Number(T),second:Number(ie)})},te=ie=>{M(ie),b&&B(fn({hour12:Number(v),minute:Number(T),second:Number(O),meridiem:ie}))},z=s.useCallback(()=>(X.current+=1,P(X.current),X.current),[]),I=s.useCallback(ie=>{const he=ra(ie),Te=un(ie,o);g.current=Te,C(tt(f?he.hour12:ie.hour24)),E(tt(ie.minute)),N(tt(ie.second)),M(he.meridiem),r(Te)},[f,r,o]),de=()=>{K.current=!0,z(),I(Ir()),queueMicrotask(()=>{const ie=Ir();un(ie,o)!==g.current&&(z(),I(ie)),K.current=!1})},re=()=>{ce(),d==null||d()},q=wt*Ao,y=q+Xt*2,$=Xt+q/2-wt/2,ee=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:y,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:$,height:wt,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:Xt,height:wt*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:Xt,height:wt*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(na,{syncEpochRef:X,forceSyncAt:w,values:R,selected:v,onSelect:H,label:"Horas",maxNumeric:f?12:23,isFocused:G==="hour",onFocus:()=>U("hour"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:ie=>{D.current.hour=ie}}),t.jsx(Kl,{}),t.jsx(na,{syncEpochRef:X,forceSyncAt:w,values:V,selected:T,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:G==="minute",onFocus:()=>U("minute"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:ie=>{D.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Kl,{}),t.jsx(na,{syncEpochRef:X,forceSyncAt:w,values:Y,selected:O,onSelect:k,label:"Segundos",maxNumeric:59,isFocused:G==="second",onFocus:()=>U("second"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:ie=>{D.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(na,{syncEpochRef:X,forceSyncAt:w,values:ue,selected:x,onSelect:ie=>te(ie),width:qf,label:"AM o PM",isMeridiem:!0,isFocused:G==="meridiem",onFocus:()=>U("meridiem"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:ie=>{D.current.meridiem=ie}})}):null]})]})}),fe=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(Ge,{variant:"ghost",size:"sm",onClick:de,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ge,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ge,{variant:"primary",size:"sm",onClick:re,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?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,ee,fe]})}function Vf(e){return e.use12Hour??e.hour12??!1}function Yf({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:b,helperText:f,helperDisplay:g,className:p,contentClassName:S,className:v=""}){const C=u==="popover",[T,E]=s.useState(!1),O=s.useRef(null),[N,x]=s.useState({horizontal:"left",vertical:"bottom"}),M=Vf({use12Hour:a,hour12:o}),w=s.useMemo(()=>r?zf(r,{use12Hour:M,showSeconds:l}):"",[M,l,r]);s.useEffect(()=>{if(!C||!T||!O.current)return;const K=O.current.getBoundingClientRect(),D=8,G=M?l?300:260:l?252:212,U=276,ae=K.left+G>window.innerWidth-D,Q=K.right-G>=D,R=K.bottom+8+U>window.innerHeight-D,V=K.top-8-U>=D;x({horizontal:ae&&Q?"right":"left",vertical:R&&V?"top":"bottom"})},[M,C,T,l]),s.useEffect(()=>{if(!C||!T)return;function K(G){O.current&&(O.current.contains(G.target)||E(!1))}function D(G){G.key==="Escape"&&E(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",D)}},[C,T]);const P=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||E(K=>!K)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${v}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":T?"var(--primary)":"var(--border)",color:w?"var(--text-main)":"var(--text-muted)",boxShadow:T?"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(j.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:w||c})]}),C?t.jsx(j.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${T?"rotate-180":""}`}):null]}),X=t.jsx(Gl,{variant:C?"popover":"panel",value:r||Wf(l),onChange:n,use12Hour:M,showSeconds:l,title:i,onClose:()=>E(!1)});return t.jsx(Wn,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:p,contentClassName:S,children:C?t.jsxs("div",{ref:O,className:"relative w-full",children:[P,T?t.jsx("div",{className:"absolute z-50",style:{...N.horizontal==="left"?{left:0}:{right:0},...N.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:X}):null]}):t.jsxs("div",{className:"space-y-2",children:[P,T?X:null]})})}const Xf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Kf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=Xf[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 Zl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Gf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Zf(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 Ql(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Jl(e){Ql(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Qf(e){const r=e.querySelector(Gf);return r instanceof HTMLElement?r:null}function Rl(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Zl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ha.OverlayScrollbars(l)){Jl(l);return}if(!Zf(l))return;const c={overflow:Ql(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Qf(l),u=d?Ha.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ha.OverlayScrollbars(l,c);Jl(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(Zl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function nr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function ei(e){try{const r=new URL(e);return nr(r.pathname)}catch{return""}}function Jf(e){const r=nr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return nr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?nr(`/${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())?"":nr(`/${a[0]}`)}const Lo="primeSuiteAppUrl",Rf={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"}},ti={xs:20,sm:28,md:36,lg:48,xl:64},ri=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],eb={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},tb="bonsaif.bot",rb="Bonsaif Bot",nb={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function ni(e){return typeof e=="string"?e.trim():""}function ab(e){var o;if(e!==void 0)return nr(e);const r=nr(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(Lo)||"";i&&window.sessionStorage.setItem(Lo,i);const c=window.sessionStorage.getItem(Lo)||"",d=i||c;if(d){const u=ei(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")?ei(a):nr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Jf(window.location.pathname)}function ob(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 sb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return ri[r%ri.length]}function lb(e,r){return e===tb||r===rb}function ib(e,r){return`${e.replace(/\/$/,"")}${r}`}function ai({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:b="xs",avatarVersion:f=0,className:g="",style:p}){const[S,v]=s.useState(!1),C=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[C,f]);const{wh:T,text:E}=Rf[a],O=ni(n)||ni(r)||c,N=ob(O),x=ab(d),M=lb(r,n),w=ib(x,"/favicon.svg"),P=s.useMemo(()=>{if(!C)return"";const U=new URLSearchParams;U.set("size",String(ti[a])),f&&U.set("v",String(f));const ae=U.toString();return`${x}/api/user/avatar/${encodeURIComponent(C)}${ae?`?${ae}`:""}`},[f,x,C,a]),X=ti[a],K=M?t.jsx("span",{className:`${T} ${nb[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${g}`,style:p,children:t.jsx("img",{src:w,alt:O,width:X,height:X,className:"h-full w-full object-contain"})}):P&&!S?t.jsx("img",{src:P,alt:O,width:X,height:X,className:`${T} rounded-full object-cover flex-shrink-0 ${g}`,style:p,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${C}-${f}`):t.jsx("span",{className:`${T} ${sb(O)} ${E} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:p,title:O,children:N});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[K,t.jsx("span",{className:`min-w-0 truncate ${eb[b]} font-medium text-[var(--text-main)] ${m}`,title:O,children:O})]});const D=l??!0,G=i??O;return D&&G?t.jsx(Ft,{as:"span",content:G,className:`inline-flex flex-shrink-0 ${u}`,children:K}):K}function cb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function db(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function oi({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=cb}){const[m,b]=s.useState(!1),f=db(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Rl,{}),t.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:t.jsx(j.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(j.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([g,p])=>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(j.HiChevronDown,{className:"h-3.5 w-3.5"}),g]}),t.jsx("div",{className:"space-y-1",children:p.map(S=>{const v=n===S.href||n.startsWith(`${S.href}/`);return t.jsxs(u,{href:S.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${v?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:S.icon??t.jsx(j.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:S.label})]},S.href)})})]},g))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(ai,{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(Ge,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(j.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 si="bonsaif-ui:prime-auth-sso",ub={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},Do={dashboard:t.jsx(j.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(j.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(j.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(j.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(j.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(j.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(j.HiUser,{className:"h-5 w-5"}),settings:t.jsx(j.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(j.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(j.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(j.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(j.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(j.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(j.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(j.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(j.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(j.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(j.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(j.HiShieldCheck,{className:"h-5 w-5"})};function fb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function bb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function mb(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,o=bb(n)&&a?a:n,l=ub[o]??fb(o);return[{label:"Inicio",href:"/"},{label:l}]}function Oo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function hb(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(j.HiHome,{className:"h-5 w-5"});if(Do[n])return Do[n];const a=r.length>1?r[r.length-2]:"";return Do[a]??t.jsx(j.HiHome,{className:"h-5 w-5"})}function pb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function li(){if(typeof window>"u")return!1;if(pb(window.location.href)){try{window.sessionStorage.setItem(si,"true")}catch{}return!0}try{return window.sessionStorage.getItem(si)==="true"}catch{return!1}}function gb({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=s.useRef(null),[f,g]=s.useState(!1),[p,S]=s.useState(d??"/"),[v,C]=s.useState(()=>li()),[T,E]=s.useState(null),O=d??p,N=c??mb(O),x=o??hb(O),M=u&&!v&&N.length>1,w=!M;s.useEffect(()=>{d||S(window.location.pathname)},[d]),s.useEffect(()=>{C(li())},[]),s.useEffect(()=>{if(m){g(!1);return}let X=null,K=0,D=0;const G=()=>{const Q=b.current,R=document.querySelector("[data-app-scroll='true']");return(Q==null?void 0:Q.closest(".os-viewport"))??(Q==null?void 0:Q.closest("[data-overlayscrollbars-viewport]"))??Oo(R)??R??window},U=()=>{const Q=X&&X!==window?X.scrollTop:window.scrollY;g(R=>R?Q>24:Q>72)},ae=()=>{X==null||X.removeEventListener("scroll",U),X=G(),X.addEventListener("scroll",U,{passive:!0}),U()};return ae(),K=window.requestAnimationFrame(ae),D=window.setTimeout(ae,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout(D),X==null||X.removeEventListener("scroll",U)}},[m]),s.useEffect(()=>{if(m){E(null);return}let X=0;const K=[],D=()=>{const Y=b.current,ue=Y==null?void 0:Y.parentElement,L=document.querySelector("[data-app-scroll='true']"),B=Oo(L)??L;if(!Y||!ue||!B){E(null);return}const ce=ue.getBoundingClientRect(),H=window.getComputedStyle(ue),oe=B.getBoundingClientRect(),k=B instanceof HTMLElement&&B.clientWidth>0?B.clientWidth:oe.width,te=ce.left+parseFloat(H.paddingLeft||"0"),z={marginLeft:Math.round(oe.left-te),width:Math.round(k)};E(I=>I&&I.marginLeft===z.marginLeft&&I.width===z.width?I:z)},G=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(D)};G(),window.addEventListener("resize",G);const U=new ResizeObserver(G),ae=b.current,Q=ae==null?void 0:ae.parentElement,R=document.querySelector("[data-app-scroll='true']"),V=Oo(R)??R;return[Q,R,V].forEach(Y=>{Y&&U.observe(Y)}),K.push(window.setTimeout(G,120)),K.push(window.setTimeout(G,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",G),U.disconnect(),K.forEach(Y=>window.clearTimeout(Y))}},[m]);const P={...T?{marginLeft:T.marginLeft,width:T.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:P,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":w?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:M?"var(--text-secondary)":"var(--text-muted)"},children:x}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(rs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function vb({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(oi,{currentPath:r,...a,children:e})}function ii(){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 yb(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 xb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(ii());const d=new MutationObserver(()=>o(ii()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>yb(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 g,p,S;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((p=m.data)==null?void 0:p.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((S=m.data)==null?void 0:S.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function wb(){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:ci(c.data.width,96,720),height:ci(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 ci(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Nb(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 kb(){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 Sb(){return"light"}function Eb({position:e="bottom-center"}){const r=s.useSyncExternalStore(Nb,kb,Sb);return t.jsx(Ia.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Cb({title:e,subtitle:r,actions:n,loading:a=!1,empty:o=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):o?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const bn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function di(e,r){return e.color??bn[r%bn.length]}function Wt(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 Nt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Br(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ho={warning:70,danger:90};function aa(e,r=Ho){const n=r.warning??Ho.warning,a=r.danger??Ho.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function mn(e,r){return Wt(aa(e,r))}function Fr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Pr(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const o=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<o.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${o[i]}`}function ui(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 _r(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Br((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function kt({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 St({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 ar=680,br="ease-out",Mb={top:18,right:8,bottom:12,left:0};function hn(e){return{...Mb,...e}}function pn(e){return e.map((r,n)=>({...r,color:di(r,n),label:r.label??r.key}))}function oa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Br(n[a.key])===null))}function Et(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function gn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function fi(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function sa(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Tb(e,r=Nt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function bi(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function $b({active:e,label:r,payload:n,valueFormat:a=Nt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(g=>g.dataKey!=="base"&&g.name!=="base"&&g.value!==null&&g.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)??((f=(b=o[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((g,p)=>{const S=g.payload,v=S&&typeof S.display=="number"?S.display:g.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:g.color??"var(--primary)"}}),g.name??g.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Tb(v,a)})]},String(g.dataKey??g.name??p))})})]})}function zr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Me.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($b,{valueFormat:e})})}function mi(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function hi(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 la(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),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),g=b&&(o==="drag"||o==="both"),p=s.useCallback(K=>{d(K),i==null||i(K)},[i]),S=s.useCallback(()=>{m(null),p(null)},[p]),v=!!c,C=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),T=s.useCallback((K,D)=>{const G=mi(e,r,K),U=mi(e,r,D);G<0||U<0||p(hi(G,U,e.length))},[p,e,r]),E=s.useCallback(K=>{g&&((K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m({leftLabel:K.activeLabel,rightLabel:K.activeLabel}))},[g]),O=s.useCallback(K=>{!g||!u||(K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m(D=>D&&{...D,rightLabel:K.activeLabel})},[u,g]),N=s.useCallback(()=>{if(g){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}T(u.leftLabel,u.rightLabel),m(null)}},[T,u,g]),x=s.useCallback(K=>{if(f){if(!K){p(null);return}p(hi(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[p,e.length,f]),M=g?{onMouseDown:E,onMouseMove:O,onMouseUp:N,onMouseLeave:()=>{u&&N()}}:{},w=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},P=t.jsxs(t.Fragment,{children:[g&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Me.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Me.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:w.startIndex,endIndex:w.endIndex,onChange:x,tickFormatter:K=>String(K)}):null]}),X=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:C,isZoomed:v,resetZoom:S,chartHandlers:M,zoomNodes:P,marginExtra:X}}function ia({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 Ab({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:b=Nt,yDomain:f,ariaLabel:g="Gráfico de líneas",curve:p=!0,strokeWidth:S=2.25,zoomable:v=!1,zoomMode:C="both",brushHeight:T,onZoomChange:E}){const O=oa(e,n),N=pn(n),x=la(e,r,{zoomable:v,zoomMode:C,brushHeight:T,onZoomChange:E}),M=hn({...m,...x.marginExtra});return l?t.jsx(kt,{height:a}):O?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ia,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.LineChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{stroke:fi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,N.map((w,P)=>t.jsx(Me.Line,{type:p?"monotone":"linear",dataKey:w.key,name:w.label,stroke:w.color,strokeWidth:P===0?S+.35:S,strokeOpacity:P===0?1:.88,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),x.zoomNodes]})})]})}function ca({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:b=Nt,yDomain:f,ariaLabel:g="Gráfico de área",stacked:p=!1,opacity:S=.22,zoomable:v=!1,zoomMode:C="both",brushHeight:T,onZoomChange:E}){const O=oa(e,n),N=pn(n),x=la(e,r,{zoomable:v,zoomMode:C,brushHeight:T,onZoomChange:E}),M=hn({...m,...x.marginExtra});return l?t.jsx(kt,{height:a}):O?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ia,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.AreaChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[t.jsx("defs",{children:N.map(w=>t.jsxs("linearGradient",{id:bi(w.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:w.color,stopOpacity:Math.min(.55,S+.28)}),t.jsx("stop",{offset:"48%",stopColor:w.color,stopOpacity:S*.5}),t.jsx("stop",{offset:"100%",stopColor:w.color,stopOpacity:0})]},w.key))}),c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{stroke:fi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,N.map(w=>t.jsx(Me.Area,{type:"monotone",dataKey:w.key,name:w.label,stroke:w.color,fill:`url(#${bi(w.key)})`,strokeWidth:2.25,stackId:p?"stack":void 0,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),x.zoomNodes]})})]})}function Lb({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:b=Nt,yDomain:f,ariaLabel:g="Gráfico de barras",layout:p="vertical",mode:S="grouped",barRadius:v=6,categoryAxisWidth:C=64,zoomable:T=!1,zoomMode:E="both",brushHeight:O,onZoomChange:N}){const x=oa(e,n),M=pn(n),w=p==="horizontal",P=la(e,r,{zoomable:T&&!w,zoomMode:E,brushHeight:O,onZoomChange:N}),X=hn({...m,...P.marginExtra});return l?t.jsx(kt,{height:a}):x?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ia,{visible:P.isZoomed,onReset:P.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:P.viewData,margin:X,layout:w?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...P.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!w,vertical:w}):null,w?t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{type:"number",tick:Et(),tickLine:!1,axisLine:!1,tickFormatter:K=>b(Number(K)),domain:f??["auto","auto"]}),t.jsx(Me.YAxis,{type:"category",dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,width:C})]}):t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:K=>b(Number(K)),dx:-2})]}),u?t.jsx(zr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,M.map((K,D)=>t.jsx(Me.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:D===0?1:.82,radius:w?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:S==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:ar,animationEasing:br},K.key)),P.zoomNodes]})})]})}function Db(e){return t.jsx(gi,{...e,variant:"pie"})}function Ob(e){return t.jsx(gi,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function pi(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function gi({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=Nt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:g=[...bn],padAngle:p,cornerRadius:S,variant:v}){const C=e.map((D,G)=>({name:String(D[r]??""),value:Br(D[n])??0,fill:g[G%g.length],row:D})).filter(D=>D.value>0),T=!C.length,E=v==="donut",O=C.length,N=pi(b,E?62:12),x=pi(f,78),M=Math.min(p??(E?2:3),Math.max(.5,10/Math.max(1,O))),w=Math.min(S??(E?10:8),Math.max(2,36/Math.max(1,O)));if(l)return t.jsx(kt,{height:a});if(T)return t.jsx(St,{height:a,text:i});const P=C.reduce((D,G)=>D+G.value,0),X=c?Math.min(96,28+Math.ceil(O/3)*22):0,K=Math.max(140,a-X);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":m??(v==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:K},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(zr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Me.Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${N}%`,outerRadius:`${x}%`,startAngle:90,endAngle:-270,paddingAngle:M,cornerRadius:w,minAngle:O>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:ar,animationEasing:br,label:!1,activeShape:Hb,children:C.map(D=>t.jsx(Me.Cell,{fill:D.fill},D.name))}),E?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(P)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:C.map(D=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:D.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:D.name,children:D.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(D.value)})]},D.name))}):null]})})}function Hb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Me.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Ib({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??Wt(o),m=e.map(x=>Br(x[r])).filter(x=>x!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,g=3,p=1,S=Math.min(...m),C=Math.max(...m)-S||1,T=m.map((x,M)=>{const w=p+M/(m.length-1)*(b-p*2),P=f-g-(x-S)/C*(f-g*2);return{x:w,y:P}}),E=T.map((x,M)=>`${M===0?"M":"L"}${x.x.toFixed(2)} ${x.y.toFixed(2)}`).join(" "),O=`${E} L${T[T.length-1].x.toFixed(2)} ${f} L${T[0].x.toFixed(2)} ${f} Z`,N=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:N,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:O,fill:`url(#${N})`}):null,t.jsx("path",{d:E,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Bb({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:b=!0,margin:f,valueFormat:g=Nt,yDomain:p,ariaLabel:S="Gráfico combinado",barRadius:v=6,zoomable:C=!1,zoomMode:T="both",brushHeight:E,onZoomChange:O}){const N=a??n.slice(0,Math.max(1,n.length-1)),x=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),M=[...N,...x.filter(U=>!N.some(ae=>ae.key===U.key))],w=oa(e,M),P=pn(N),X=pn(M),K=x.map(U=>{var Q;const ae=X.find(R=>R.key===U.key);return{...U,label:U.label??U.key,color:U.color??(ae==null?void 0:ae.color)??((Q=X[0])==null?void 0:Q.color)}}),D=la(e,r,{zoomable:C,zoomMode:T,brushHeight:E,onZoomChange:O}),G=hn({...f,...D.marginExtra});return c?t.jsx(kt,{height:l}):w?t.jsx(St,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":S,style:{height:l},children:[t.jsx(ia,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.ComposedChart,{data:D.viewData,margin:G,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:U=>g(Number(U)),dx:-2}),b?t.jsx(zr,{valueFormat:g,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,P.map(U=>t.jsx(Me.Bar,{dataKey:U.key,name:U.label,fill:U.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:ar,animationEasing:br},U.key)),K.map(U=>t.jsx(Me.Line,{type:"monotone",dataKey:U.key,name:U.label,stroke:U.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:U.color}},U.key)),D.zoomNodes]})})]})}function Fb({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:b=Nt,ariaLabel:f="Gráfico waterfall",increaseColor:g="#34d399",decreaseColor:p="#f87171",totalColor:S="var(--primary)"}){const v=s.useMemo(()=>Pb(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:p,totalColor:S}),[e,r,n,a,g,p,S]),C=!v.length,T=hn(m);return i?t.jsx(kt,{height:o}):C?t.jsx(St,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:v,margin:T,barCategoryGap:"42%",children:[d?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:"label",tick:Et(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,tickFormatter:E=>b(Number(E)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Me.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Me.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:ar,animationEasing:br,children:v.map(E=>t.jsx(Me.Cell,{fill:E.color},E.label))})]})})})}function Pb(e,r){let n=0;return e.map((a,o)=>{const l=Br(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const vi="bonsaif-funnel-chart-keyframes",_b=`
44
+ `}),H.map(j=>{const y=Hf(j.colorIndex);return C===j.id?t.jsx("input",{ref:J,value:P,disabled:o,onChange:T=>V(T.target.value),onKeyDown:T=>N(T,j.id),onBlur:()=>de(j.id,P),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(P.length+2,6)}ch`}},j.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:y.bg,color:y.text,border:`1px solid ${y.border}`},children:[t.jsx("span",{className:"truncate",children:j.value}),t.jsx("button",{type:"button","aria-label":`Editar "${j.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),I(j)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(W.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${j.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),B(j.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})})]},j.id)}),!te&&t.jsx("input",{ref:le,value:S,disabled:o,placeholder:H.length===0?a:"",onChange:j=>x(j.target.value),onKeyDown:oe,onPaste:ae,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($r,{error:p,helperText:b,helperDisplay:f})]})}const _f=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function tt(e){return String(e).padStart(2,"0")}function To(e,r=Ir()){const n=e.trim();if(!n)return r;const a=n.match(_f);if(!a)return r;const o=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(i)||o<0||o>23||l<0||l>59||i<0||i>59?r:{hour24:o,minute:l,second:i}}function un(e,r=!0){const n=`${tt(e.hour24)}:${tt(e.minute)}`;return r?`${n}:${tt(e.second)}`:n}function ra(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function fn(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function zf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=To(e);if(n){const l=ra(o),i=`${l.hour12}:${tt(l.minute)}`;return`${a?`${i}:${tt(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Ir(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function Wf(e=!0){return un(Ir(),e)}function $o(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const wt=36,Ao=5,Vl=Math.floor(Ao/2),jf=52,qf=48,Xt=18;function Yl(e){return e*wt}function Xl(e){return Math.round(e/wt)}function Uf(e){return e.use12Hour??e.hour12??!1}function na({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=jf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:p}){const g=s.useRef(null),k=s.useRef(null),v=s.useRef(null),A=s.useRef(""),E=s.useRef(0),M=s.useRef(!1),[H,S]=s.useState(r),[x,C]=s.useState(""),w=s.useCallback(I=>{A.current=I,C(I)},[]),P=s.useMemo(()=>[...Array(Vl).fill(""),...e,...Array(Vl).fill("")],[e]),V=s.useCallback(()=>{const I=g.current;if(!I)return r;const oe=Xl(I.scrollTop),N=Math.min(Math.max(oe,0),e.length-1);return e[N]??r},[r,e]),X=s.useCallback((I,oe=!0)=>{const N=Math.min(Math.max(I,0),e.length-1),R=e[N],ae=g.current;!ae||!R||(k.current&&(window.clearTimeout(k.current),k.current=null),M.current=!0,E.current=N,ae.scrollTop=Yl(N),S(R),oe&&R!==r&&n(R))},[n,r,e]);s.useLayoutEffect(()=>{k.current&&(window.clearTimeout(k.current),k.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),w(""),S(r);const I=e.indexOf(r);if(I>=0&&(E.current=I),I<0||!g.current)return;const oe=Yl(I);g.current.scrollTop!==oe&&(g.current.scrollTop=oe)},[o,r,w,e]);const O=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),K=s.useCallback((I,oe=!1)=>{O(),w("");const N=Number(I);if(!Number.isFinite(N))return;const R=Math.min(c,Math.max(0,N));let ae=tt(R),$=e.indexOf(ae);if($<0){const ne=Math.min(e.length-1,Math.max(0,R-(c===12?1:0)));ae=e[ne]??ae,$=e.indexOf(ae)}$>=0&&X($),oe&&(b==null||b())},[O,c,b,X,w,e]),q=s.useCallback(I=>{const oe=Math.floor(c/10),N=A.current;if(N===""){if(I>oe){K(String(I),!0);return}const ae=String(I);w(ae),v.current=window.setTimeout(()=>{K(A.current,!0)},1200);return}O();const R=+`${N}${I}`;R<=c?K(String(R),!0):K(String(I),!0)},[O,K,c,w]),le=s.useCallback(I=>{O(),w(""),X(E.current+I)},[O,X,w]),J=I=>{if(d){I.key==="a"||I.key==="A"?(I.preventDefault(),n("AM"),b==null||b()):I.key==="p"||I.key==="P"?(I.preventDefault(),n("PM"),b==null||b()):I.key==="ArrowUp"||I.key==="ArrowDown"?(I.preventDefault(),n(r==="AM"?"PM":"AM")):I.key==="Tab"&&(I.preventDefault(),I.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(I.key)){I.preventDefault(),q(Number(I.key));return}I.key==="ArrowUp"?(I.preventDefault(),le(-1)):I.key==="ArrowDown"?(I.preventDefault(),le(1)):I.key==="Tab"&&(I.preventDefault(),O(),A.current!==""&&K(A.current,!1),I.shiftKey?f==null||f():b==null||b())},G=s.useCallback(()=>{const I=a.current,oe=g.current;oe&&I===a.current&&X(Xl(oe.scrollTop))},[X,a]),U=()=>{if(A.current!=="")return;if(M.current){M.current=!1;const oe=V();S(oe);const N=e.indexOf(oe);N>=0&&(E.current=N);return}S(V()),k.current&&window.clearTimeout(k.current);const I=a.current;k.current=window.setTimeout(()=>{I===a.current&&G()},100)},Y="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",ue=wt*Ao,L=ue+Xt*2,B=x!==""?x:null,de=B!==null;return t.jsxs("div",{ref:p,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":B??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:J,onBlur:()=>{O(),A.current!==""&&K(A.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:L,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:Y,style:{top:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>le(-1),children:t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:g,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Xt,height:ue,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:U,onMouseUp:G,onTouchEnd:G,children:P.map((I,oe)=>{const N=I!==""&&I===H;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!I,onClick:()=>{if(!I)return;const R=e.indexOf(I);R>=0&&X(R)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:wt,scrollSnapAlign:"center",color:N?"var(--text-main)":"var(--text-muted)",fontSize:N?16:14,fontWeight:N?600:400,opacity:I?de?N?0:.35:N?1:.35:0},children:I},`wheel-${oe}-${I}`)})}),B!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:Xt+ue/2-wt/2,height:wt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:B}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:Y,style:{bottom:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>le(1),children:t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Kl(){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:wt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Gl({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",b=m||!d,f=Uf({use12Hour:n,hour12:a}),p=s.useRef(e),g=To(e,Ir()),k=ra(g),[v,A]=s.useState(tt(f?k.hour12:g.hour24)),[E,M]=s.useState(tt(g.minute)),[H,S]=s.useState(tt(g.second)),[x,C]=s.useState(k.meridiem),[w,P]=s.useState(0),V=s.useRef(0),X=s.useRef(!1),O=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[K,q]=s.useState("hour"),le=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,o]),J=s.useCallback(ie=>{q(he=>{const Te=le.indexOf(he);return le[(Te+ie+le.length)%le.length]})},[le]);s.useEffect(()=>{var ie;(ie=O.current[K])==null||ie.focus()},[K]),s.useEffect(()=>{var ie;q("hour"),(ie=O.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const ie=To(e,Ir()),he=ra(ie);A(tt(f?he.hour12:ie.hour24)),M(tt(ie.minute)),S(tt(ie.second)),C(he.meridiem)},[f,e]);const G=s.useMemo(()=>(f?$o(1,12):$o(0,23)).map(ie=>tt(ie)),[f]),U=s.useMemo(()=>$o(0,59).map(ie=>tt(ie)),[]),Y=U,ue=s.useMemo(()=>["AM","PM"],[]),L=s.useCallback(()=>f?fn({hour12:Number(v),minute:Number(E),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(E),second:Number(H)},[v,f,x,E,H]),B=s.useCallback(ie=>{if(X.current)return;const he=un(ie,o);p.current=he,r(he)},[r,o]),de=s.useCallback(()=>{B(L())},[L,B]),I=ie=>{A(ie),b&&B(f?fn({hour12:Number(ie),minute:Number(E),second:Number(H),meridiem:x}):{hour24:Number(ie),minute:Number(E),second:Number(H)})},oe=ie=>{M(ie),b&&B(f?fn({hour12:Number(v),minute:Number(ie),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(ie),second:Number(H)})},N=ie=>{S(ie),b&&B(f?fn({hour12:Number(v),minute:Number(E),second:Number(ie),meridiem:x}):{hour24:Number(v),minute:Number(E),second:Number(ie)})},R=ie=>{C(ie),b&&B(fn({hour12:Number(v),minute:Number(E),second:Number(H),meridiem:ie}))},ae=s.useCallback(()=>(V.current+=1,P(V.current),V.current),[]),$=s.useCallback(ie=>{const he=ra(ie),Te=un(ie,o);p.current=Te,A(tt(f?he.hour12:ie.hour24)),M(tt(ie.minute)),S(tt(ie.second)),C(he.meridiem),r(Te)},[f,r,o]),ne=()=>{X.current=!0,ae(),$(Ir()),queueMicrotask(()=>{const ie=Ir();un(ie,o)!==p.current&&(ae(),$(ie)),X.current=!1})},te=()=>{de(),d==null||d()},j=wt*Ao,y=j+Xt*2,T=Xt+j/2-wt/2,ee=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:y,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:T,height:wt,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:Xt,height:wt*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:Xt,height:wt*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(na,{syncEpochRef:V,forceSyncAt:w,values:G,selected:v,onSelect:I,label:"Horas",maxNumeric:f?12:23,isFocused:K==="hour",onFocus:()=>q("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.hour=ie}}),t.jsx(Kl,{}),t.jsx(na,{syncEpochRef:V,forceSyncAt:w,values:U,selected:E,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:K==="minute",onFocus:()=>q("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Kl,{}),t.jsx(na,{syncEpochRef:V,forceSyncAt:w,values:Y,selected:H,onSelect:N,label:"Segundos",maxNumeric:59,isFocused:K==="second",onFocus:()=>q("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(na,{syncEpochRef:V,forceSyncAt:w,values:ue,selected:x,onSelect:ie=>R(ie),width:qf,label:"AM o PM",isMeridiem:!0,isFocused:K==="meridiem",onFocus:()=>q("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.meridiem=ie}})}):null]})]})}),fe=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(Ge,{variant:"ghost",size:"sm",onClick:ne,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ge,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ge,{variant:"primary",size:"sm",onClick:te,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?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,ee,fe]})}function Vf(e){return e.use12Hour??e.hour12??!1}function Yf({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:b,helperText:f,helperDisplay:p,className:g,contentClassName:k,className:v=""}){const A=u==="popover",[E,M]=s.useState(!1),H=s.useRef(null),[S,x]=s.useState({horizontal:"left",vertical:"bottom"}),C=Vf({use12Hour:a,hour12:o}),w=s.useMemo(()=>r?zf(r,{use12Hour:C,showSeconds:l}):"",[C,l,r]);s.useEffect(()=>{if(!A||!E||!H.current)return;const X=H.current.getBoundingClientRect(),O=8,K=C?l?300:260:l?252:212,q=276,le=X.left+K>window.innerWidth-O,J=X.right-K>=O,G=X.bottom+8+q>window.innerHeight-O,U=X.top-8-q>=O;x({horizontal:le&&J?"right":"left",vertical:G&&U?"top":"bottom"})},[C,A,E,l]),s.useEffect(()=>{if(!A||!E)return;function X(K){H.current&&(H.current.contains(K.target)||M(!1))}function O(K){K.key==="Escape"&&M(!1)}return document.addEventListener("mousedown",X),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",O)}},[A,E]);const P=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||M(X=>!X)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${v}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":E?"var(--primary)":"var(--border)",color:w?"var(--text-main)":"var(--text-muted)",boxShadow:E?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(W.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:w||c})]}),A?t.jsx(W.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${E?"rotate-180":""}`}):null]}),V=t.jsx(Gl,{variant:A?"popover":"panel",value:r||Wf(l),onChange:n,use12Hour:C,showSeconds:l,title:i,onClose:()=>M(!1)});return t.jsx(Wn,{label:e,required:m,error:b,helperText:f,helperDisplay:p,className:g,contentClassName:k,children:A?t.jsxs("div",{ref:H,className:"relative w-full",children:[P,E?t.jsx("div",{className:"absolute z-50",style:{...S.horizontal==="left"?{left:0}:{right:0},...S.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:V}):null]}):t.jsxs("div",{className:"space-y-2",children:[P,E?V:null]})})}const Xf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Kf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=Xf[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 Zl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Gf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Zf(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 Ql(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Jl(e){Ql(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Qf(e){const r=e.querySelector(Gf);return r instanceof HTMLElement?r:null}function Rl(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Zl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ha.OverlayScrollbars(l)){Jl(l);return}if(!Zf(l))return;const c={overflow:Ql(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Qf(l),u=d?Ha.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ha.OverlayScrollbars(l,c);Jl(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(Zl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function nr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function ei(e){try{const r=new URL(e);return nr(r.pathname)}catch{return""}}function Jf(e){const r=nr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return nr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?nr(`/${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())?"":nr(`/${a[0]}`)}const Lo="primeSuiteAppUrl",Rf={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"}},ti={xs:20,sm:28,md:36,lg:48,xl:64},ri=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],eb={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},tb="bonsaif.bot",rb="Bonsaif Bot",nb={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function ni(e){return typeof e=="string"?e.trim():""}function ab(e){var o;if(e!==void 0)return nr(e);const r=nr(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(Lo)||"";i&&window.sessionStorage.setItem(Lo,i);const c=window.sessionStorage.getItem(Lo)||"",d=i||c;if(d){const u=ei(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")?ei(a):nr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Jf(window.location.pathname)}function ob(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 sb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return ri[r%ri.length]}function lb(e,r){return e===tb||r===rb}function ib(e,r){return`${e.replace(/\/$/,"")}${r}`}function ai({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:b="xs",avatarVersion:f=0,className:p="",style:g}){const[k,v]=s.useState(!1),A=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[A,f]);const{wh:E,text:M}=Rf[a],H=ni(n)||ni(r)||c,S=ob(H),x=ab(d),C=lb(r,n),w=ib(x,"/favicon.svg"),P=s.useMemo(()=>{if(!A)return"";const q=new URLSearchParams;q.set("size",String(ti[a])),f&&q.set("v",String(f));const le=q.toString();return`${x}/api/user/avatar/${encodeURIComponent(A)}${le?`?${le}`:""}`},[f,x,A,a]),V=ti[a],X=C?t.jsx("span",{className:`${E} ${nb[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${p}`,style:g,children:t.jsx("img",{src:w,alt:H,width:V,height:V,className:"h-full w-full object-contain"})}):P&&!k?t.jsx("img",{src:P,alt:H,width:V,height:V,className:`${E} rounded-full object-cover flex-shrink-0 ${p}`,style:g,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${A}-${f}`):t.jsx("span",{className:`${E} ${sb(H)} ${M} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:g,title:H,children:S});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[X,t.jsx("span",{className:`min-w-0 truncate ${eb[b]} font-medium text-[var(--text-main)] ${m}`,title:H,children:H})]});const O=l??!0,K=i??H;return O&&K?t.jsx(Ft,{as:"span",content:K,className:`inline-flex flex-shrink-0 ${u}`,children:X}):X}function cb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function db(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function oi({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=cb}){const[m,b]=s.useState(!1),f=db(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Rl,{}),t.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:t.jsx(W.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(W.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([p,g])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"}),p]}),t.jsx("div",{className:"space-y-1",children:g.map(k=>{const v=n===k.href||n.startsWith(`${k.href}/`);return t.jsxs(u,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${v?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:k.icon??t.jsx(W.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:k.label})]},k.href)})})]},p))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(ai,{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(Ge,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(W.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const si="bonsaif-ui:prime-auth-sso",ub={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},Do={dashboard:t.jsx(W.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(W.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(W.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(W.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(W.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(W.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(W.HiUser,{className:"h-5 w-5"}),settings:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(W.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(W.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(W.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(W.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(W.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(W.HiShieldCheck,{className:"h-5 w-5"})};function fb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function bb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function mb(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,o=bb(n)&&a?a:n,l=ub[o]??fb(o);return[{label:"Inicio",href:"/"},{label:l}]}function Oo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function hb(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(W.HiHome,{className:"h-5 w-5"});if(Do[n])return Do[n];const a=r.length>1?r[r.length-2]:"";return Do[a]??t.jsx(W.HiHome,{className:"h-5 w-5"})}function pb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function li(){if(typeof window>"u")return!1;if(pb(window.location.href)){try{window.sessionStorage.setItem(si,"true")}catch{}return!0}try{return window.sessionStorage.getItem(si)==="true"}catch{return!1}}function gb({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=s.useRef(null),[f,p]=s.useState(!1),[g,k]=s.useState(d??"/"),[v,A]=s.useState(()=>li()),[E,M]=s.useState(null),H=d??g,S=c??mb(H),x=o??hb(H),C=u&&!v&&S.length>1,w=!C;s.useEffect(()=>{d||k(window.location.pathname)},[d]),s.useEffect(()=>{A(li())},[]),s.useEffect(()=>{if(m){p(!1);return}let V=null,X=0,O=0;const K=()=>{const J=b.current,G=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??Oo(G)??G??window},q=()=>{const J=V&&V!==window?V.scrollTop:window.scrollY;p(G=>G?J>24:J>72)},le=()=>{V==null||V.removeEventListener("scroll",q),V=K(),V.addEventListener("scroll",q,{passive:!0}),q()};return le(),X=window.requestAnimationFrame(le),O=window.setTimeout(le,120),()=>{window.cancelAnimationFrame(X),window.clearTimeout(O),V==null||V.removeEventListener("scroll",q)}},[m]),s.useEffect(()=>{if(m){M(null);return}let V=0;const X=[],O=()=>{const Y=b.current,ue=Y==null?void 0:Y.parentElement,L=document.querySelector("[data-app-scroll='true']"),B=Oo(L)??L;if(!Y||!ue||!B){M(null);return}const de=ue.getBoundingClientRect(),I=window.getComputedStyle(ue),oe=B.getBoundingClientRect(),N=B instanceof HTMLElement&&B.clientWidth>0?B.clientWidth:oe.width,R=de.left+parseFloat(I.paddingLeft||"0"),ae={marginLeft:Math.round(oe.left-R),width:Math.round(N)};M($=>$&&$.marginLeft===ae.marginLeft&&$.width===ae.width?$:ae)},K=()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(O)};K(),window.addEventListener("resize",K);const q=new ResizeObserver(K),le=b.current,J=le==null?void 0:le.parentElement,G=document.querySelector("[data-app-scroll='true']"),U=Oo(G)??G;return[J,G,U].forEach(Y=>{Y&&q.observe(Y)}),X.push(window.setTimeout(K,120)),X.push(window.setTimeout(K,280)),()=>{window.cancelAnimationFrame(V),window.removeEventListener("resize",K),q.disconnect(),X.forEach(Y=>window.clearTimeout(Y))}},[m]);const P={...E?{marginLeft:E.marginLeft,width:E.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:P,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":w?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:C?"var(--text-secondary)":"var(--text-muted)"},children:x}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(rs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function vb({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(oi,{currentPath:r,...a,children:e})}function ii(){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 yb(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 xb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(ii());const d=new MutationObserver(()=>o(ii()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>yb(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 p,g,k;if(m.source!==((p=l.current)==null?void 0:p.contentWindow)||c&&m.origin!==c)return;if(((g=m.data)==null?void 0:g.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((k=m.data)==null?void 0:k.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function wb(){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:ci(c.data.width,96,720),height:ci(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 ci(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Nb(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 kb(){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 Sb(){return"light"}function Eb({position:e="bottom-center"}){const r=s.useSyncExternalStore(Nb,kb,Sb);return t.jsx(Ia.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Cb({title:e,subtitle:r,actions:n,loading:a=!1,empty:o=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):o?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const bn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function di(e,r){return e.color??bn[r%bn.length]}function Wt(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 Nt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Br(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ho={warning:70,danger:90};function aa(e,r=Ho){const n=r.warning??Ho.warning,a=r.danger??Ho.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function mn(e,r){return Wt(aa(e,r))}function Fr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Pr(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const o=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<o.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${o[i]}`}function ui(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 _r(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Br((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function kt({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 St({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 ar=680,br="ease-out",Mb={top:18,right:8,bottom:12,left:0};function hn(e){return{...Mb,...e}}function pn(e){return e.map((r,n)=>({...r,color:di(r,n),label:r.label??r.key}))}function oa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Br(n[a.key])===null))}function Et(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function gn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function fi(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function sa(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Tb(e,r=Nt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function bi(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function $b({active:e,label:r,payload:n,valueFormat:a=Nt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(p=>p.dataKey!=="base"&&p.name!=="base"&&p.value!==null&&p.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=o[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=o[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((p,g)=>{const k=p.payload,v=k&&typeof k.display=="number"?k.display:p.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:p.color??"var(--primary)"}}),p.name??p.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Tb(v,a)})]},String(p.dataKey??p.name??g))})})]})}function zr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Me.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($b,{valueFormat:e})})}function mi(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function hi(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 la(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),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),p=b&&(o==="drag"||o==="both"),g=s.useCallback(X=>{d(X),i==null||i(X)},[i]),k=s.useCallback(()=>{m(null),g(null)},[g]),v=!!c,A=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),E=s.useCallback((X,O)=>{const K=mi(e,r,X),q=mi(e,r,O);K<0||q<0||g(hi(K,q,e.length))},[g,e,r]),M=s.useCallback(X=>{p&&((X==null?void 0:X.activeLabel)===void 0||(X==null?void 0:X.activeLabel)===null||m({leftLabel:X.activeLabel,rightLabel:X.activeLabel}))},[p]),H=s.useCallback(X=>{!p||!u||(X==null?void 0:X.activeLabel)===void 0||(X==null?void 0:X.activeLabel)===null||m(O=>O&&{...O,rightLabel:X.activeLabel})},[u,p]),S=s.useCallback(()=>{if(p){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}E(u.leftLabel,u.rightLabel),m(null)}},[E,u,p]),x=s.useCallback(X=>{if(f){if(!X){g(null);return}g(hi(X.startIndex??0,X.endIndex??e.length-1,e.length))}},[g,e.length,f]),C=p?{onMouseDown:M,onMouseMove:H,onMouseUp:S,onMouseLeave:()=>{u&&S()}}:{},w=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},P=t.jsxs(t.Fragment,{children:[p&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Me.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Me.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:w.startIndex,endIndex:w.endIndex,onChange:x,tickFormatter:X=>String(X)}):null]}),V=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:p,viewData:A,isZoomed:v,resetZoom:k,chartHandlers:C,zoomNodes:P,marginExtra:V}}function ia({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 Ab({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:b=Nt,yDomain:f,ariaLabel:p="Gráfico de líneas",curve:g=!0,strokeWidth:k=2.25,zoomable:v=!1,zoomMode:A="both",brushHeight:E,onZoomChange:M}){const H=oa(e,n),S=pn(n),x=la(e,r,{zoomable:v,zoomMode:A,brushHeight:E,onZoomChange:M}),C=hn({...m,...x.marginExtra});return l?t.jsx(kt,{height:a}):H?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ia,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.LineChart,{data:x.viewData,margin:C,...x.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{stroke:fi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,S.map((w,P)=>t.jsx(Me.Line,{type:g?"monotone":"linear",dataKey:w.key,name:w.label,stroke:w.color,strokeWidth:P===0?k+.35:k,strokeOpacity:P===0?1:.88,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),x.zoomNodes]})})]})}function ca({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:b=Nt,yDomain:f,ariaLabel:p="Gráfico de área",stacked:g=!1,opacity:k=.22,zoomable:v=!1,zoomMode:A="both",brushHeight:E,onZoomChange:M}){const H=oa(e,n),S=pn(n),x=la(e,r,{zoomable:v,zoomMode:A,brushHeight:E,onZoomChange:M}),C=hn({...m,...x.marginExtra});return l?t.jsx(kt,{height:a}):H?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ia,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.AreaChart,{data:x.viewData,margin:C,...x.chartHandlers,children:[t.jsx("defs",{children:S.map(w=>t.jsxs("linearGradient",{id:bi(w.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:w.color,stopOpacity:Math.min(.55,k+.28)}),t.jsx("stop",{offset:"48%",stopColor:w.color,stopOpacity:k*.5}),t.jsx("stop",{offset:"100%",stopColor:w.color,stopOpacity:0})]},w.key))}),c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{stroke:fi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,S.map(w=>t.jsx(Me.Area,{type:"monotone",dataKey:w.key,name:w.label,stroke:w.color,fill:`url(#${bi(w.key)})`,strokeWidth:2.25,stackId:g?"stack":void 0,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),x.zoomNodes]})})]})}function Lb({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:b=Nt,yDomain:f,ariaLabel:p="Gráfico de barras",layout:g="vertical",mode:k="grouped",barRadius:v=6,categoryAxisWidth:A=64,zoomable:E=!1,zoomMode:M="both",brushHeight:H,onZoomChange:S}){const x=oa(e,n),C=pn(n),w=g==="horizontal",P=la(e,r,{zoomable:E&&!w,zoomMode:M,brushHeight:H,onZoomChange:S}),V=hn({...m,...P.marginExtra});return l?t.jsx(kt,{height:a}):x?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ia,{visible:P.isZoomed,onReset:P.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:P.viewData,margin:V,layout:w?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...P.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!w,vertical:w}):null,w?t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{type:"number",tick:Et(),tickLine:!1,axisLine:!1,tickFormatter:X=>b(Number(X)),domain:f??["auto","auto"]}),t.jsx(Me.YAxis,{type:"category",dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,width:A})]}):t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:X=>b(Number(X)),dx:-2})]}),u?t.jsx(zr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,C.map((X,O)=>t.jsx(Me.Bar,{dataKey:X.key,name:X.label,fill:X.color,fillOpacity:O===0?1:.82,radius:w?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:ar,animationEasing:br},X.key)),P.zoomNodes]})})]})}function Db(e){return t.jsx(gi,{...e,variant:"pie"})}function Ob(e){return t.jsx(gi,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function pi(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function gi({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=Nt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:p=[...bn],padAngle:g,cornerRadius:k,variant:v}){const A=e.map((O,K)=>({name:String(O[r]??""),value:Br(O[n])??0,fill:p[K%p.length],row:O})).filter(O=>O.value>0),E=!A.length,M=v==="donut",H=A.length,S=pi(b,M?62:12),x=pi(f,78),C=Math.min(g??(M?2:3),Math.max(.5,10/Math.max(1,H))),w=Math.min(k??(M?10:8),Math.max(2,36/Math.max(1,H)));if(l)return t.jsx(kt,{height:a});if(E)return t.jsx(St,{height:a,text:i});const P=A.reduce((O,K)=>O+K.value,0),V=c?Math.min(96,28+Math.ceil(H/3)*22):0,X=Math.max(140,a-V);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":m??(v==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:X},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(zr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Me.Pie,{data:A,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${S}%`,outerRadius:`${x}%`,startAngle:90,endAngle:-270,paddingAngle:C,cornerRadius:w,minAngle:H>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:ar,animationEasing:br,label:!1,activeShape:Hb,children:A.map(O=>t.jsx(Me.Cell,{fill:O.fill},O.name))}),M?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(P)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:A.map(O=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:O.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:O.name,children:O.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(O.value)})]},O.name))}):null]})})}function Hb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Me.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Ib({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??Wt(o),m=e.map(x=>Br(x[r])).filter(x=>x!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,p=3,g=1,k=Math.min(...m),A=Math.max(...m)-k||1,E=m.map((x,C)=>{const w=g+C/(m.length-1)*(b-g*2),P=f-p-(x-k)/A*(f-p*2);return{x:w,y:P}}),M=E.map((x,C)=>`${C===0?"M":"L"}${x.x.toFixed(2)} ${x.y.toFixed(2)}`).join(" "),H=`${M} L${E[E.length-1].x.toFixed(2)} ${f} L${E[0].x.toFixed(2)} ${f} Z`,S=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:S,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:H,fill:`url(#${S})`}):null,t.jsx("path",{d:M,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Bb({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:b=!0,margin:f,valueFormat:p=Nt,yDomain:g,ariaLabel:k="Gráfico combinado",barRadius:v=6,zoomable:A=!1,zoomMode:E="both",brushHeight:M,onZoomChange:H}){const S=a??n.slice(0,Math.max(1,n.length-1)),x=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),C=[...S,...x.filter(q=>!S.some(le=>le.key===q.key))],w=oa(e,C),P=pn(S),V=pn(C),X=x.map(q=>{var J;const le=V.find(G=>G.key===q.key);return{...q,label:q.label??q.key,color:q.color??(le==null?void 0:le.color)??((J=V[0])==null?void 0:J.color)}}),O=la(e,r,{zoomable:A,zoomMode:E,brushHeight:M,onZoomChange:H}),K=hn({...f,...O.marginExtra});return c?t.jsx(kt,{height:l}):w?t.jsx(St,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[t.jsx(ia,{visible:O.isZoomed,onReset:O.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.ComposedChart,{data:O.viewData,margin:K,barCategoryGap:"34%",...O.chartHandlers,children:[u?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:g??["auto","auto"],tickFormatter:q=>p(Number(q)),dx:-2}),b?t.jsx(zr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,P.map(q=>t.jsx(Me.Bar,{dataKey:q.key,name:q.label,fill:q.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:ar,animationEasing:br},q.key)),X.map(q=>t.jsx(Me.Line,{type:"monotone",dataKey:q.key,name:q.label,stroke:q.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:q.color}},q.key)),O.zoomNodes]})})]})}function Fb({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:b=Nt,ariaLabel:f="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:g="#f87171",totalColor:k="var(--primary)"}){const v=s.useMemo(()=>Pb(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:g,totalColor:k}),[e,r,n,a,p,g,k]),A=!v.length,E=hn(m);return i?t.jsx(kt,{height:o}):A?t.jsx(St,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:v,margin:E,barCategoryGap:"42%",children:[d?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:"label",tick:Et(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,tickFormatter:M=>b(Number(M)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Me.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Me.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:ar,animationEasing:br,children:v.map(M=>t.jsx(Me.Cell,{fill:M.color},M.label))})]})})})}function Pb(e,r){let n=0;return e.map((a,o)=>{const l=Br(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const vi="bonsaif-funnel-chart-keyframes",_b=`
45
45
  @keyframes bonsaif-funnel-stage-in {
46
46
  from {
47
47
  opacity: 0;
@@ -81,4 +81,4 @@ ${_}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
81
81
  animation: none !important;
82
82
  }
83
83
  }
84
- `;function zb(){if(typeof document>"u"||document.getElementById(vi))return;const e=document.createElement("style");e.id=vi,e.textContent=_b,document.head.appendChild(e)}function yi(e,r,n){return Math.min(n,Math.max(r,e))}function da(e,r,n){const a=yi(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function Wb(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=Br(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",g=o?String(d[o]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...g?{description:g}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function jb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),o=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function qb({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,g=o+l,p=Math.max(4,Math.min(14,l*.18)),S=da(d,"#000",r?.12:.22),v=da(d,"#fff",r?.08:0),C=da(d,"#fff",.22),T=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${f} ${g}`,`L ${b} ${g}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:T,fill:S}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${f} ${g}`,`L ${a} ${g}`,`L ${u} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:p,fill:C,stroke:da(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:p,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function Ub({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:g=.42,colors:p=[...bn],animationDuration:S=ar,valueFormat:v=Nt,ariaLabel:C="Gráfico embudo"}){const[T,E]=s.useState(null),[O,N]=s.useState(!1),x=s.useMemo(()=>Wb(e,r,n,a,o,p),[e,r,n,a,o,p]),M=s.useMemo(()=>x.map(k=>`${k.name}:${k.value}`).join("|"),[x]);if(s.useEffect(()=>{if(zb(),typeof window>"u")return;const k=window.matchMedia("(prefers-reduced-motion: reduce)");N(k.matches);const te=()=>N(k.matches);return k.addEventListener("change",te),()=>k.removeEventListener("change",te)},[]),c)return t.jsx(kt,{height:l});if(!x.length)return t.jsx(St,{height:l,text:d});const w=S>0&&!O,P=S,X=Math.min(90,Math.max(40,Math.round(S/8))),K=Math.round(P*.15),D=x.length*X+Math.round(P*.35),G=x.some(k=>k.title||k.description),U=m?160:24,ae=G?168:24,Q=f?36:8,R=U+220+ae,V=l,Y=18,ue=Math.max(120,V-Y-Q-8),L=U+110,ce=jb(x,{cx:L,topY:Y,plotH:ue,maxTopW:200,taper:yi(g,.2,.95),gap:10}),H=T!=null?ce[T]:null,oe="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":C,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${R} ${V}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:w?"bonsaif-funnel-label":void 0,style:w?{animation:`bonsaif-funnel-fade-in ${P}ms ${oe} both`}:void 0,x1:U-12,y1:Y,x2:U-12,y2:Y+ue,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ce.map(k=>{const te=k.y+k.h/2,z=k.cx-k.topW/2,I=k.index*X,de=w?{animation:`bonsaif-funnel-stage-in ${P}ms ${oe} ${I}ms both`}:void 0,re=w?{animation:`bonsaif-funnel-fade-in ${Math.round(P*.85)}ms ${oe} ${I+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:de,children:t.jsx(qb,{stage:k,hovered:T===k.index,onHover:E})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:re,children:[t.jsx("line",{x1:24,y1:te,x2:U-12,y2:te,stroke:k.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:U-12,y1:te,x2:z-6,y2:te,stroke:k.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:te-(b?6:0),textAnchor:"end",fill:k.color,fontSize:12,fontWeight:600,children:k.name.length>18?`${k.name.slice(0,16)}…`:k.name}),b?t.jsx("text",{x:20,y:te+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(k.value)}):null]}):null,(k.title||k.description)&&G?t.jsxs("g",{className:"bonsaif-funnel-anno",style:re,children:[t.jsx("line",{x1:k.cx+k.bottomW/2+6,y1:te,x2:U+220+8,y2:te,stroke:k.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),k.title?t.jsx("text",{x:U+220+14,y:te-(k.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:k.title.length>22?`${k.title.slice(0,20)}…`:k.title}):null,k.description?t.jsx("text",{x:U+220+14,y:te+(k.title?10:0),fill:"var(--text-muted)",fontSize:11,children:k.description.length>28?`${k.description.slice(0,26)}…`:k.description}):null]}):null]},`${k.name}-${k.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${L}, ${Y+ue+8})`,fill:"var(--primary)",style:w?{animation:`bonsaif-funnel-arrow-in ${Math.round(P*.7)}ms ${oe} ${D}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},M),u&&H?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:H.color},children:H.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(H.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(H.pct*100),"% del top)"]})]}):null]})}const Wr=135*Math.PI/180,Io=270*Math.PI/180;function Vb({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=Nt,tone:m="primary",color:b,thresholds:f,ariaLabel:g="Gauge",animationDuration:p=700,thickness:S=9,showScale:v=!1}){const C=s.useId().replace(/:/g,""),T=n-r||1,E=Math.min(1,Math.max(0,(e-r)/T)),[O,N]=s.useState(p>0?0:E);if(s.useEffect(()=>{if(l||i)return;if(p<=0){N(E);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){N(E);return}let R=0,V=0;N(L=>(V=L,L));const Y=performance.now(),ue=L=>{const B=Math.min(1,(L-Y)/p),ce=1-(1-B)**3;N(V+(E-V)*ce),B<1&&(R=requestAnimationFrame(ue))};return R=requestAnimationFrame(ue),()=>cancelAnimationFrame(R)},[E,p,l,i]),l)return t.jsx(kt,{height:a});if(i)return t.jsx(St,{height:a,text:c});const x=100,M=108,w=72,P=b??Yb(e,n,m,f),X=r+O*T,K=xi(x,M,w,Wr,Wr+Io),D=Wr+Math.max(.001,O)*Io,G=xi(x,M,w,Wr,D),U=ua(x,M,w,Wr),ae=ua(x,M,w,Wr+Io);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":g,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${C}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:P,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:P,stopOpacity:1})]})}),t.jsx("path",{d:K,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:S,strokeLinecap:"butt"}),t.jsx("path",{d:G,fill:"none",stroke:`url(#bonsaif-gauge-${C})`,strokeWidth:S,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x,y:M-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(X)}),d?t.jsx("text",{x,y:M+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:U.x-2,y:U.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ae.x+2,y:ae.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function Yb(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 Wt(n);const o=e/(r||1);return o>=.8?Wt("success"):o>=.5?Wt("warning"):Wt("danger")}function ua(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function xi(e,r,n,a,o){const l=ua(e,r,n,a),i=ua(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 Xb({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:b=Nt,tone:f="primary",showScale:g=!0,showStatus:p=!0,ariaLabel:S="Bullet chart"}){if(i)return t.jsx(kt,{height:o});if(c)return t.jsx(St,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(P=>P.value))??[],1)*1.05,T=[...a??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((P,X)=>P.value-X.value),E=Wt(f),O=Math.min(100,Math.max(0,e/v*100)),N=Math.min(100,Math.max(0,r/v*100)),x=e>=r,M=[0,.25,.5,.75,1].map(P=>P*v),w=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":S,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:T.map((P,X)=>{const K=X===0?0:T[X-1].value,D=Math.max(0,(P.value-K)/v*100);return t.jsx("div",{style:{width:`${D}%`,background:P.color??`color-mix(in srgb, var(--border) ${70-X*18}%, transparent)`}},X)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${O}%`,background:E,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${E} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${N}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:E,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),g?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:M.map((P,X)=>{const K=P/v*100,D=X===0,G=X===M.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${K}%`,transform:D?"none":G?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:D?0:G?"auto":void 0,marginRight:G?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":G?"right":"center"},children:b(P)})]},P)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),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:E,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),p?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Wt(x?"success":"warning")},children:x?"En meta":"Bajo meta"}):null]}),w]}):w})}function Kb({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:b=!0,thresholds:f,label:g="CPU",ariaLabel:p="Uso de CPU"}){var N;const S=o??[{key:a,label:"Uso",color:mn(r??_r(e,a)??0,f)}],v=r??_r(e,a)??_r(e,((N=S[0])==null?void 0:N.key)??a),C=!d&&(!e.length||v===null);if(d)return t.jsx(kt,{height:i});if(C)return t.jsx(St,{height:i,text:u});const T=Math.min(100,Math.max(0,v??0)),E=aa(T,f),O=mn(T,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":p,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[g,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:O},children:Fr(T,T<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:O,background:`color-mix(in srgb, ${O} 14%, transparent)`},children:E==="danger"?"Crítico":E==="warning"?"Alto":"Normal"})]}),t.jsx(ca,{data:e,xKey:n,series:S.map(x=>({...x,color:x.color??O})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:x=>Fr(x,0),ariaLabel:p,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Gb({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:b=!0,thresholds:f,label:g="RAM",ariaLabel:p="Uso de memoria"}){const S=r>0?r:1,v=Math.min(100,Math.max(0,e/S*100)),C=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(kt,{height:i});if(C)return t.jsx(St,{height:i,text:u});const T=aa(v,f),E=mn(v,f),O=Math.max(0,r-e),N=a.length>0?_r(a,l)??v:v,x=mn(N,f),M=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":p,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:g}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:E},children:Fr(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Pr(e)," / ",Pr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:E,background:`color-mix(in srgb, ${E} 14%, transparent)`},children:T==="danger"?"Crítico":T==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${g} ${Fr(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${E}, color-mix(in srgb, ${E} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Pr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Pr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Pr(O)]})]})]}),m&&a.length>1?t.jsx(ca,{data:a,xKey:o,series:[{key:l,label:"Uso",color:x}],height:M,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:w=>Fr(w,0),ariaLabel:`${p} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Zb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Qb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Jb({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=Zb,outboundColor:m=Qb,height:b=240,className:f="",loading:g=!1,emptyText:p="Sin datos de red",showLegend:S=!1,showTooltip:v=!0,label:C="Network",ariaLabel:T="Tráfico de red"}){const E=o??_r(e,n)??0,O=l??_r(e,a)??0,N=!g&&e.length===0;if(g)return t.jsx(kt,{height:b});if(N)return t.jsx(St,{height:b,text:p});const x=P=>ui(P,i),w=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":T,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:C}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:x(E),children:x(E)})]}),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:x(O),children:x(O)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ca,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:w,showLegend:S,showTooltip:v,valueFormat:x,ariaLabel:T,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const wi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Ni=["primeSuiteOrigin","primeSuiteProjectKey"];function Rb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of wi){const n=e.get(r);if(n){const a=fa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Ni){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=fa(n);if(a)return a}}if(document.referrer){const r=fa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function em(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of wi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Ni)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=fa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function fa(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 tm(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(F,"toast",{enumerable:!0,get:()=>Ia.toast}),F.Alert=wc,F.AreaChart=ca,F.AuthShell=oi,F.AutoGrowTextarea=Wl,F.AutoGrowTextareaField=Tf,F.BarChart=Lb,F.BonsaifButton=rc,F.BonsaifUIToaster=Eb,F.BulletChart=Xb,F.Button=Ge,F.CHART_PALETTE=bn,F.CalendarPicker=Cc,F.ChartCard=Cb,F.Checkbox=Mn,F.CodeBlock=ld,F.ComboChart=Bb,F.CompactFilterSelect=cd,F.CompactSearchInput=id,F.ConfirmDialog=bd,F.CopyButton=Ga,F.CopyLinkButton=gd,F.CpuChart=Kb,F.DataSheets=Sd,F.DataTable=Ua,F.DateRangePicker=$d,F.DonutChart=Ob,F.Drawer=_d,F.DropdownMenu=Fd,F.DynamicDetailTabs=yc,F.EmailField=iu,F.EmptyState=Hn,F.EventCalendar=ad,F.FieldHelperFooter=$r,F.FieldLabelInfo=Tr,F.FieldLayoutEditor=mu,F.FileUpload=fu,F.FormField=Wn,F.FunnelChart=Ub,F.GaugeChart=Vb,F.GlobalScrollbars=Rl,F.ImageLightbox=Js,F.ImageLightboxHost=ku,F.InputField=oo,F.LineChart=Ab,F.LoadingState=ss,F.MentionTextEditor=Pl,F.MicroserviceFrame=xb,F.Modal=Za,F.MouseTooltip=Ft,F.MultiDateCalendar=Dd,F.MultiSelect=Eu,F.NetworkChart=Jb,F.NumberField=Cu,F.PageHeader=gb,F.PageSearchInput=ts,F.Pagination=Tu,F.PhoneField=Au,F.PieChart=Db,F.PrimeAuthRouteShell=vb,F.PrimeSuiteChatFrame=wb,F.RadioGroup=Lu,F.RamChart=Gb,F.RichTextEditor=bf,F.SearchableSelect=ur,F.SectionPanel=mf,F.Sparkline=Ib,F.StatusBadge=gf,F.StatusSelect=Nf,F.StepWizard=Sf,F.TableSkeleton=Cn,F.Tabs=kf,F.TagInput=Pf,F.TextInput=zn,F.Textarea=jl,F.TextareaField=Of,F.TimeField=Yf,F.TimePicker=Gl,F.Toggle=Kf,F.TruncatedWithTooltip=Vt,F.UserAvatar=ai,F.WORKDAY_LABELS=Ts,F.WaterfallChart=Fb,F.YearMultiDateCalendar=Hd,F.buildMentionQueryRegex=vl,F.chunkMonthWeeks=Xa,F.chunkMonthWorkWeeks=Ss,F.clearMentionChipSelection=Hr,F.cn=Qt,F.computeWeekBars=Ka,F.configureBonsaifUI=Dc,F.dedupeMentions=kl,F.defaultValueFormat=Nt,F.deleteEditorSelection=Dl,F.describeParentTargetOrigin=em,F.emailFormat=Vd,F.ensureMentionChipTrailingSpaces=dn,F.extractMentionUsernames=xo,F.filterSelfMentions=of,F.filterWorkdays=In,F.findMentionChipAfterCaret=Hl,F.findMentionChipBeforeCaret=Ol,F.findMentionChipsInSelection=Eo,F.findMentionTriggerInEditor=vo,F.formatBytes=Pr,F.formatPercent=Fr,F.formatRate=ui,F.getBonsaifUIConfig=Oc,F.getDataTablePreferencesEndpoint=Wa,F.getEditorPlainText=So,F.getMonthGrid=Ya,F.getPlainTextOffset=Qn,F.getWeekDays=Va,F.getWorkWeekDays=ks,F.groupItemsByDay=Es,F.highlightMentions=Sl,F.htmlToText=wl,F.insertMentionInEditor=Cl,F.isMentionTriggerBoundary=xl,F.isPlainOffsetInsideMentionChip=yl,F.isValidEmail=ro,F.isValidPhone=no,F.isWeekend=Ns,F.locateTextOffset=Or,F.matches=Qd,F.maxLength=Kd,F.maxValue=Zd,F.mentionDisplayLabel=Nl,F.minLength=Xd,F.minValue=Gd,F.normalizeUsername=yo,F.openImageLightboxFromEvent=Zs,F.phoneCountryCodeOptions=tl,F.phoneFormat=Yd,F.placeCaretAfterMentionChip=No,F.placeCaretAtTextOffset=Ml,F.preferredMentionSpacer=wo,F.removeMentionChip=ea,F.required=Ud,F.resetBonsaifUIConfig=Hc,F.resolveMentions=af,F.resolveParentTargetOrigin=Rb,F.selectAllEditorContents=Al,F.selectMentionChip=$l,F.selectionIncludesNonChipText=Ll,F.seriesColor=di,F.setBonsaifDataTablePreferencesEndpoint=Ic,F.syncMentionChipSelectionHighlight=Rn,F.toDateKey=Pt,F.toNearestWorkday=Zc,F.toneColor=Wt,F.usageColor=mn,F.usageTone=aa,F.useValidationVisibility=tm,F.validateForm=Jd,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})}));
84
+ `;function zb(){if(typeof document>"u"||document.getElementById(vi))return;const e=document.createElement("style");e.id=vi,e.textContent=_b,document.head.appendChild(e)}function yi(e,r,n){return Math.min(n,Math.max(r,e))}function da(e,r,n){const a=yi(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function Wb(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=Br(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",p=o?String(d[o]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...p?{description:p}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function jb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),o=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function qb({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,p=o+l,g=Math.max(4,Math.min(14,l*.18)),k=da(d,"#000",r?.12:.22),v=da(d,"#fff",r?.08:0),A=da(d,"#fff",.22),E=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${f} ${p}`,`L ${b} ${p}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:E,fill:k}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${f} ${p}`,`L ${a} ${p}`,`L ${u} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:A,stroke:da(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function Ub({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:p=.42,colors:g=[...bn],animationDuration:k=ar,valueFormat:v=Nt,ariaLabel:A="Gráfico embudo"}){const[E,M]=s.useState(null),[H,S]=s.useState(!1),x=s.useMemo(()=>Wb(e,r,n,a,o,g),[e,r,n,a,o,g]),C=s.useMemo(()=>x.map(N=>`${N.name}:${N.value}`).join("|"),[x]);if(s.useEffect(()=>{if(zb(),typeof window>"u")return;const N=window.matchMedia("(prefers-reduced-motion: reduce)");S(N.matches);const R=()=>S(N.matches);return N.addEventListener("change",R),()=>N.removeEventListener("change",R)},[]),c)return t.jsx(kt,{height:l});if(!x.length)return t.jsx(St,{height:l,text:d});const w=k>0&&!H,P=k,V=Math.min(90,Math.max(40,Math.round(k/8))),X=Math.round(P*.15),O=x.length*V+Math.round(P*.35),K=x.some(N=>N.title||N.description),q=m?160:24,le=K?168:24,J=f?36:8,G=q+220+le,U=l,Y=18,ue=Math.max(120,U-Y-J-8),L=q+110,de=jb(x,{cx:L,topY:Y,plotH:ue,maxTopW:200,taper:yi(p,.2,.95),gap:10}),I=E!=null?de[E]:null,oe="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":A,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${G} ${U}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:w?"bonsaif-funnel-label":void 0,style:w?{animation:`bonsaif-funnel-fade-in ${P}ms ${oe} both`}:void 0,x1:q-12,y1:Y,x2:q-12,y2:Y+ue,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,de.map(N=>{const R=N.y+N.h/2,ae=N.cx-N.topW/2,$=N.index*V,ne=w?{animation:`bonsaif-funnel-stage-in ${P}ms ${oe} ${$}ms both`}:void 0,te=w?{animation:`bonsaif-funnel-fade-in ${Math.round(P*.85)}ms ${oe} ${$+X}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:ne,children:t.jsx(qb,{stage:N,hovered:E===N.index,onHover:M})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:te,children:[t.jsx("line",{x1:24,y1:R,x2:q-12,y2:R,stroke:N.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:q-12,y1:R,x2:ae-6,y2:R,stroke:N.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:R-(b?6:0),textAnchor:"end",fill:N.color,fontSize:12,fontWeight:600,children:N.name.length>18?`${N.name.slice(0,16)}…`:N.name}),b?t.jsx("text",{x:20,y:R+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(N.value)}):null]}):null,(N.title||N.description)&&K?t.jsxs("g",{className:"bonsaif-funnel-anno",style:te,children:[t.jsx("line",{x1:N.cx+N.bottomW/2+6,y1:R,x2:q+220+8,y2:R,stroke:N.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),N.title?t.jsx("text",{x:q+220+14,y:R-(N.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:N.title.length>22?`${N.title.slice(0,20)}…`:N.title}):null,N.description?t.jsx("text",{x:q+220+14,y:R+(N.title?10:0),fill:"var(--text-muted)",fontSize:11,children:N.description.length>28?`${N.description.slice(0,26)}…`:N.description}):null]}):null]},`${N.name}-${N.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${L}, ${Y+ue+8})`,fill:"var(--primary)",style:w?{animation:`bonsaif-funnel-arrow-in ${Math.round(P*.7)}ms ${oe} ${O}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},C),u&&I?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:I.color},children:I.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(I.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(I.pct*100),"% del top)"]})]}):null]})}const Wr=135*Math.PI/180,Io=270*Math.PI/180;function Vb({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=Nt,tone:m="primary",color:b,thresholds:f,ariaLabel:p="Gauge",animationDuration:g=700,thickness:k=9,showScale:v=!1}){const A=s.useId().replace(/:/g,""),E=n-r||1,M=Math.min(1,Math.max(0,(e-r)/E)),[H,S]=s.useState(g>0?0:M);if(s.useEffect(()=>{if(l||i)return;if(g<=0){S(M);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){S(M);return}let G=0,U=0;S(L=>(U=L,L));const Y=performance.now(),ue=L=>{const B=Math.min(1,(L-Y)/g),de=1-(1-B)**3;S(U+(M-U)*de),B<1&&(G=requestAnimationFrame(ue))};return G=requestAnimationFrame(ue),()=>cancelAnimationFrame(G)},[M,g,l,i]),l)return t.jsx(kt,{height:a});if(i)return t.jsx(St,{height:a,text:c});const x=100,C=108,w=72,P=b??Yb(e,n,m,f),V=r+H*E,X=xi(x,C,w,Wr,Wr+Io),O=Wr+Math.max(.001,H)*Io,K=xi(x,C,w,Wr,O),q=ua(x,C,w,Wr),le=ua(x,C,w,Wr+Io);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":p,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${A}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:P,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:P,stopOpacity:1})]})}),t.jsx("path",{d:X,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),t.jsx("path",{d:K,fill:"none",stroke:`url(#bonsaif-gauge-${A})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x,y:C-(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(V)}),d?t.jsx("text",{x,y:C+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:q.x-2,y:q.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:le.x+2,y:le.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function Yb(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 Wt(n);const o=e/(r||1);return o>=.8?Wt("success"):o>=.5?Wt("warning"):Wt("danger")}function ua(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function xi(e,r,n,a,o){const l=ua(e,r,n,a),i=ua(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 Xb({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:b=Nt,tone:f="primary",showScale:p=!0,showStatus:g=!0,ariaLabel:k="Bullet chart"}){if(i)return t.jsx(kt,{height:o});if(c)return t.jsx(St,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(P=>P.value))??[],1)*1.05,E=[...a??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((P,V)=>P.value-V.value),M=Wt(f),H=Math.min(100,Math.max(0,e/v*100)),S=Math.min(100,Math.max(0,r/v*100)),x=e>=r,C=[0,.25,.5,.75,1].map(P=>P*v),w=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:o*.42)},role:"img","aria-label":k,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:E.map((P,V)=>{const X=V===0?0:E[V-1].value,O=Math.max(0,(P.value-X)/v*100);return t.jsx("div",{style:{width:`${O}%`,background:P.color??`color-mix(in srgb, var(--border) ${70-V*18}%, transparent)`}},V)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${H}%`,background:M,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${M} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${S}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:M,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),p?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:C.map((P,V)=>{const X=P/v*100,O=V===0,K=V===C.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${X}%`,transform:O?"none":K?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:O?0:K?"auto":void 0,marginRight:K?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:O?"left":K?"right":"center"},children:b(P)})]},P)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),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:M,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),g?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Wt(x?"success":"warning")},children:x?"En meta":"Bajo meta"}):null]}),w]}):w})}function Kb({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:b=!0,thresholds:f,label:p="CPU",ariaLabel:g="Uso de CPU"}){var S;const k=o??[{key:a,label:"Uso",color:mn(r??_r(e,a)??0,f)}],v=r??_r(e,a)??_r(e,((S=k[0])==null?void 0:S.key)??a),A=!d&&(!e.length||v===null);if(d)return t.jsx(kt,{height:i});if(A)return t.jsx(St,{height:i,text:u});const E=Math.min(100,Math.max(0,v??0)),M=aa(E,f),H=mn(E,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":g,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[p,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:H},children:Fr(E,E<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:H,background:`color-mix(in srgb, ${H} 14%, transparent)`},children:M==="danger"?"Crítico":M==="warning"?"Alto":"Normal"})]}),t.jsx(ca,{data:e,xKey:n,series:k.map(x=>({...x,color:x.color??H})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:x=>Fr(x,0),ariaLabel:g,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Gb({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:b=!0,thresholds:f,label:p="RAM",ariaLabel:g="Uso de memoria"}){const k=r>0?r:1,v=Math.min(100,Math.max(0,e/k*100)),A=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(kt,{height:i});if(A)return t.jsx(St,{height:i,text:u});const E=aa(v,f),M=mn(v,f),H=Math.max(0,r-e),S=a.length>0?_r(a,l)??v:v,x=mn(S,f),C=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":g,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:p}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:M},children:Fr(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Pr(e)," / ",Pr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:M,background:`color-mix(in srgb, ${M} 14%, transparent)`},children:E==="danger"?"Crítico":E==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${p} ${Fr(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${M}, color-mix(in srgb, ${M} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Pr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Pr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Pr(H)]})]})]}),m&&a.length>1?t.jsx(ca,{data:a,xKey:o,series:[{key:l,label:"Uso",color:x}],height:C,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:w=>Fr(w,0),ariaLabel:`${g} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Zb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Qb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Jb({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=Zb,outboundColor:m=Qb,height:b=240,className:f="",loading:p=!1,emptyText:g="Sin datos de red",showLegend:k=!1,showTooltip:v=!0,label:A="Network",ariaLabel:E="Tráfico de red"}){const M=o??_r(e,n)??0,H=l??_r(e,a)??0,S=!p&&e.length===0;if(p)return t.jsx(kt,{height:b});if(S)return t.jsx(St,{height:b,text:g});const x=P=>ui(P,i),w=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":E,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:A}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:x(M),children:x(M)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background: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:x(H),children:x(H)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ca,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:w,showLegend:k,showTooltip:v,valueFormat:x,ariaLabel:E,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const wi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Ni=["primeSuiteOrigin","primeSuiteProjectKey"];function Rb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of wi){const n=e.get(r);if(n){const a=fa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Ni){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=fa(n);if(a)return a}}if(document.referrer){const r=fa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function em(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of wi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Ni)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=fa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function fa(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 tm(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(F,"toast",{enumerable:!0,get:()=>Ia.toast}),F.Alert=wc,F.AreaChart=ca,F.AuthShell=oi,F.AutoGrowTextarea=Wl,F.AutoGrowTextareaField=Tf,F.BarChart=Lb,F.BonsaifButton=rc,F.BonsaifUIToaster=Eb,F.BulletChart=Xb,F.Button=Ge,F.CHART_PALETTE=bn,F.CalendarPicker=Cc,F.ChartCard=Cb,F.Checkbox=Mn,F.CodeBlock=ld,F.ComboChart=Bb,F.CompactFilterSelect=cd,F.CompactSearchInput=id,F.ConfirmDialog=bd,F.CopyButton=Ga,F.CopyLinkButton=gd,F.CpuChart=Kb,F.DataSheets=Sd,F.DataTable=Ua,F.DateRangePicker=$d,F.DonutChart=Ob,F.Drawer=_d,F.DropdownMenu=Fd,F.DynamicDetailTabs=yc,F.EmailField=iu,F.EmptyState=Hn,F.EventCalendar=ad,F.FieldHelperFooter=$r,F.FieldLabelInfo=Tr,F.FieldLayoutEditor=mu,F.FileUpload=fu,F.FormField=Wn,F.FunnelChart=Ub,F.GaugeChart=Vb,F.GlobalScrollbars=Rl,F.ImageLightbox=Js,F.ImageLightboxHost=ku,F.InputField=oo,F.LineChart=Ab,F.LoadingState=ss,F.MentionTextEditor=Pl,F.MicroserviceFrame=xb,F.Modal=Za,F.MouseTooltip=Ft,F.MultiDateCalendar=Dd,F.MultiSelect=Eu,F.NetworkChart=Jb,F.NumberField=Cu,F.PageHeader=gb,F.PageSearchInput=ts,F.Pagination=Tu,F.PhoneField=Au,F.PieChart=Db,F.PrimeAuthRouteShell=vb,F.PrimeSuiteChatFrame=wb,F.RadioGroup=Lu,F.RamChart=Gb,F.RichTextEditor=bf,F.SearchableSelect=ur,F.SectionPanel=mf,F.Sparkline=Ib,F.StatusBadge=gf,F.StatusSelect=Nf,F.StepWizard=Sf,F.TableSkeleton=Cn,F.Tabs=kf,F.TagInput=Pf,F.TextInput=zn,F.Textarea=jl,F.TextareaField=Of,F.TimeField=Yf,F.TimePicker=Gl,F.Toggle=Kf,F.TruncatedWithTooltip=Vt,F.UserAvatar=ai,F.WORKDAY_LABELS=Ts,F.WaterfallChart=Fb,F.YearMultiDateCalendar=Hd,F.buildMentionQueryRegex=vl,F.chunkMonthWeeks=Xa,F.chunkMonthWorkWeeks=Ss,F.clearMentionChipSelection=Hr,F.cn=Qt,F.computeWeekBars=Ka,F.configureBonsaifUI=Dc,F.dedupeMentions=kl,F.defaultValueFormat=Nt,F.deleteEditorSelection=Dl,F.describeParentTargetOrigin=em,F.emailFormat=Vd,F.ensureMentionChipTrailingSpaces=dn,F.extractMentionUsernames=xo,F.filterSelfMentions=of,F.filterWorkdays=In,F.findMentionChipAfterCaret=Hl,F.findMentionChipBeforeCaret=Ol,F.findMentionChipsInSelection=Eo,F.findMentionTriggerInEditor=vo,F.formatBytes=Pr,F.formatPercent=Fr,F.formatRate=ui,F.getBonsaifUIConfig=Oc,F.getDataTablePreferencesEndpoint=Wa,F.getEditorPlainText=So,F.getMonthGrid=Ya,F.getPlainTextOffset=Qn,F.getWeekDays=Va,F.getWorkWeekDays=ks,F.groupItemsByDay=Es,F.highlightMentions=Sl,F.htmlToText=wl,F.insertMentionInEditor=Cl,F.isMentionTriggerBoundary=xl,F.isPlainOffsetInsideMentionChip=yl,F.isValidEmail=ro,F.isValidPhone=no,F.isWeekend=Ns,F.locateTextOffset=Or,F.matches=Qd,F.maxLength=Kd,F.maxValue=Zd,F.mentionDisplayLabel=Nl,F.minLength=Xd,F.minValue=Gd,F.normalizeUsername=yo,F.openImageLightboxFromEvent=Zs,F.phoneCountryCodeOptions=tl,F.phoneFormat=Yd,F.placeCaretAfterMentionChip=No,F.placeCaretAtTextOffset=Ml,F.preferredMentionSpacer=wo,F.removeMentionChip=ea,F.required=Ud,F.resetBonsaifUIConfig=Hc,F.resolveMentions=af,F.resolveParentTargetOrigin=Rb,F.selectAllEditorContents=Al,F.selectMentionChip=$l,F.selectionIncludesNonChipText=Ll,F.seriesColor=di,F.setBonsaifDataTablePreferencesEndpoint=Ic,F.syncMentionChipSelectionHighlight=Rn,F.toDateKey=Pt,F.toNearestWorkday=Zc,F.toneColor=Wt,F.usageColor=mn,F.usageTone=aa,F.useValidationVisibility=tm,F.validateForm=Jd,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})}));