bonsaif-ui 0.1.134 → 0.1.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- (function(U,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],o):(U=typeof globalThis<"u"?globalThis:U||self,o(U.BonsaifUI={},U.React,U.jsxRuntime,U.ReactIconsHi2,U.ReactDOM,U.Recharts,U.OverlayScrollbarsGlobal,U.Sonner,U.OverlayScrollbarsReact,U.ReactDayPicker,U.ReactDayPickerStyles,U.ReactIconsFi))})(this,(function(U,o,t,j,ft,Se,Ma,Ta,jo,$a,um,Ii){"use strict";"use client";function Gt(...e){return e.filter(Boolean).join(" ")}function Oi({variant:e="primary",className:r,type:n="button",children:a,...s}){return t.jsx("button",{className:Gt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...s,children:a})}function qo({value:e,onChange:r,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=o.useRef(null),[m,b]=o.useState(!1),f=l||m||e.trim().length>0,g=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",h=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var v;s&&((v=u.current)==null||v.focus())},[s]);const C=()=>{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?h:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),C())},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 Uo=o.createContext({});let Vo=0;const Xo="bonsaif-ui:hide-tooltips";function yn(e=700){Vo=Date.now()+e}function Hi(){return Date.now()>Vo}function xn(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 Bi(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function Wt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:b="div"}){const f=o.useRef(null),g=o.useRef(null),h=o.useRef(null),C=o.useRef(!1),[v,E]=o.useState(null),[A,S]=o.useState("");o.useEffect(()=>{const L=f.current;L&&(L.querySelectorAll("[title]").forEach(G=>{const q=G.getAttribute("title");q&&(G.getAttribute("aria-label")||G.setAttribute("aria-label",q),G.removeAttribute("title"))}),L.querySelectorAll("svg title").forEach(G=>G.remove()))}),o.useLayoutEffect(()=>{if(!v)return;const L=g.current;if(!L)return;const G=12,q=14,ne=L.getBoundingClientRect(),J=window.innerWidth-ne.width-G,R=window.innerHeight-ne.height-G;let V=v.mouseX+q,X=v.mouseY+q,ce,D;if(!s&&f.current){const _=f.current.getBoundingClientRect(),le=_.left+_.width/2,I=_.top+_.height/2;l==="top"?(V=le-ne.width/2,X=_.top-ne.height-q,D=ne.height-1):l==="left"?(V=_.left-ne.width-q,X=I-ne.height/2,ce=ne.width-1):l==="right"?(V=_.right+q,X=I-ne.height/2,ce=-7):(V=le-ne.width/2,X=_.bottom+q,D=-7)}if(s&&(V>J&&(V=v.mouseX-ne.width-q),X>R&&(X=v.mouseY-ne.height-q)),V=Math.min(Math.max(G,V),Math.max(G,J)),X=Math.min(Math.max(G,X),Math.max(G,R)),!s&&f.current){const _=f.current.getBoundingClientRect(),le=_.left+_.width/2,I=_.top+_.height/2;l==="top"||l==="bottom"?ce=Math.min(Math.max(14,le-V),ne.width-14):D=Math.min(Math.max(14,I-X),ne.height-14)}(Math.abs(V-v.x)>.5||Math.abs(X-v.y)>.5||ce!==v.arrowX||D!==v.arrowY)&&E(_=>_&&{..._,x:V,y:X,arrowX:ce,arrowY:D})},[s,l,v]);const O=()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},N=(L,G)=>{if(!Hi()||C.current)return;const q=f.current;if(q&&!xn(q)){if(n){const ne=Bi(q);if(!ne)return;S(ne)}!n&&!r||E({mouseX:L,mouseY:G,x:L+14,y:G+14})}},y=()=>{const L=f.current;if(!L)return;const G=L.getBoundingClientRect();N(G.left+G.width/2,G.bottom)},T=()=>{O(),E(null)},w=()=>{if(!a){T();return}O(),h.current=window.setTimeout(()=>E(null),120)},F=()=>{yn(),C.current=!0,T()},Y=()=>{C.current=!1};o.useEffect(()=>{if(!v)return;if(xn(f.current)){E(null);return}const L=()=>E(null),G=()=>{yn(),C.current=!0,E(null)};document.addEventListener("pointerdown",G,!0),document.addEventListener("click",G,!0),document.addEventListener("scroll",L,!0),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),document.addEventListener("keydown",L,!0);const q=new MutationObserver(()=>{xn(f.current)&&E(null)});return q.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",L,!0),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),document.removeEventListener("keydown",L,!0),q.disconnect()}},[v]),o.useEffect(()=>{const L=()=>yn(),G=()=>{yn(),C.current=!0,E(null)};return document.addEventListener("pointerdown",L,!0),document.addEventListener("click",L,!0),document.addEventListener("keydown",L,!0),window.addEventListener(Xo,G),()=>{document.removeEventListener("pointerdown",L,!0),document.removeEventListener("click",L,!0),document.removeEventListener("keydown",L,!0),window.removeEventListener(Xo,G)}},[]);const K=n?A:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:L=>{f.current=L},className:c,style:u,onMouseEnter:L=>{O(),Y(),s?N(L.clientX,L.clientY):y()},onMouseMove:L=>{v&&s&&N(L.clientX,L.clientY)},onMouseDown:F,onClick:F,onMouseLeave:()=>{Y(),w()},onFocus:y,onBlur:T,children:e}),v&&K&&!xn(f.current)?ft.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 Yo(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Fi="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",Pi={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"},_i="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",zi={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"},Wi={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},ji={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Aa(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Aa).join(" ").trim():o.isValidElement(e)?Aa(e.props.children):""}function qi(e){return o.Children.toArray(e).find(o.isValidElement)??null}function Ue({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const g=o.useContext(Uo),h=l??g.iconOnly??e==="icon",C=g.compact??!1,v=g.headerAction??!1,E=v&&r==="md"?"sm":C&&!v&&r==="md"?"xs":r,A=e==="icon"||h,S=v&&A,O=Aa(d),N=s??f.title??f["aria-label"]??(h?O:void 0),y=N?void 0:f.title,T=f["aria-label"]??(typeof N=="string"?N:O||void 0),w=n?null:a??(h?qi(d):null),F=t.jsxs("button",{...f,title:y,"aria-label":T,"data-variant":e,"data-size":E,"data-icon":A?"true":void 0,disabled:m||n,className:`${Fi} ${S?_i:Pi[e]} ${A?Wi[E]:zi[E]} ${C&&!A?"px-2.5":""} ${u}`,style:{...ji[e],height:Yo(i),padding:Yo(c),...b,...v&&!A?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...S?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):w,!h&&d]});return N?t.jsx(Wt,{as:"span",content:N,className:"inline-flex shrink-0",children:F}):F}const bt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function wn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=s?"px-2 py-2":"px-3 py-2.5",u=s?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:bt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:bt})]}),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:bt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:bt})]})]}),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:{...bt,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:{...bt,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:bt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:bt})]}),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:bt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:bt})]})]})}function Ui({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 Vi({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 Ko({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(wn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(Xi,{rows:i});if(e==="cards")return t.jsx(Yi,{rows:i});const m=s||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(Vi,{logoSrc:a,logoAlt:m}):null,t.jsx(Ui,{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 Xi({rows:e}){return t.jsx(wn,{rows:e,columns:7})}function Yi({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:bt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:bt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:bt})]},n))})}function Go(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 Zo(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Ki(e){return[e.label,Go(e.service),e.description,e.service].filter(Boolean).join(" ")}function Gi(e){return typeof e=="function"?e:e.default}function Zi(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ue,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Qi({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:h,emptyState:C,loadingState:v,errorState:E=Zi,renderTabLabel:A,searchableTabs:S="auto",tabsSearchThreshold:O=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:y,onTabsSearchChange:T,emptySearchState:w,showTabCount:F=!0,className:Y="",parentClassName:K="",contentClassName:L="",tabsClassName:G=""}){var mt;const q=o.useMemo(()=>l.filter(ie=>!ie.hidden&&((b==null?void 0:b(ie,s))??!0)),[b,s,l]),ne=(mt=q.find(ie=>!ie.disabled))==null?void 0:mt.service,[J,R]=o.useState(u??ne??""),[V,X]=o.useState({}),[ce,D]=o.useState({}),[_,le]=o.useState(""),[I,oe]=o.useState(!1),k=o.useRef(ce),te=o.useRef(0),P=y??_,z=Zo(P),de=S===!0||S==="auto"&&q.length>=O,re=de&&P.trim().length>0,W=o.useMemo(()=>z?q.filter(ie=>Zo(Ki(ie)).includes(z)):q,[z,q]),x=d??J,M=q.find(ie=>ie.service===x)??q.find(ie=>!ie.disabled);o.useEffect(()=>{!M&&ne&&R(ne)},[ne,M]),o.useEffect(()=>{k.current=ce},[ce]);const ee=ie=>{ie.disabled||(d||R(ie.service),m==null||m(ie.service,ie))},ue=ie=>{y===void 0&&le(ie),T==null||T(ie)},se=(ie,Fe)=>{const ze=W.filter(Ve=>!Ve.disabled),it=ze.findIndex(Ve=>Ve.service===Fe.service);it<0||((ie.key==="ArrowRight"||ie.key==="ArrowDown")&&(ie.preventDefault(),ee(ze[(it+1)%ze.length])),(ie.key==="ArrowLeft"||ie.key==="ArrowUp")&&(ie.preventDefault(),ee(ze[(it-1+ze.length)%ze.length])),ie.key==="Home"&&(ie.preventDefault(),ee(ze[0])),ie.key==="End"&&(ie.preventDefault(),ee(ze[ze.length-1])))},pe=o.useCallback(()=>{if(!M)return;const ie=M.service,Fe=k.current[ie];if(Fe!=null&&Fe.loading||Fe!=null&&Fe.component&&f)return;const ze=(i==null?void 0:i[ie])??c;if(!ze){D(Ve=>({...Ve,[ie]:{loading:!1,error:new Error(`No module loader found for service "${ie}".`)}}));return}const it=++te.current;D(Ve=>({...Ve,[ie]:{...Ve[ie],loading:!0,error:void 0}})),ze(M,s).then(Ve=>{if(it!==te.current&&!f)return;const kt=Gi(Ve);D(rt=>({...rt,[ie]:{component:kt,loading:!1}}))}).catch(Ve=>{const kt=Ve instanceof Error?Ve:new Error(String(Ve));D(rt=>({...rt,[ie]:{...rt[ie],loading:!1,error:kt}}))})},[s,f,c,i,M]);o.useEffect(pe,[pe]);const Me=M?V[M.service]??null:null,Ie=M?ce[M.service]:void 0,At=Ie==null?void 0:Ie.component,Bt=ie=>{M&&X(Fe=>({...Fe,[M.service]:ie}))},Re=()=>{M&&X(ie=>({...ie,[M.service]:null}))},Ft={context:s,parent:a,links:l,visibleLinks:q,filteredLinks:W,selectedLink:M,selectedService:M==null?void 0:M.service,activeItemId:Me,tabsSearch:P,onSelectService:ee,onOpenDetail:Bt,onBackToList:Re},lt=n?n(Ft):r?t.jsx(r,{...Ft}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${Y}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${K}`,children:lt}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,children:[(g||h||de||F)&&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}),h&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:h})]}),(de||F)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[F&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[W.length," / ",q.length]}),de&&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(qo,{value:P,onChange:ue,placeholder:N,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&&P&&ue(""),oe(ie=>!ie)},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||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:I||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:W.length>0?W.map(ie=>{const Fe=ie.service===(M==null?void 0:M.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Fe,disabled:ie.disabled,onClick:()=>ee(ie),onKeyDown:ze=>se(ze,ie),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 ${Fe?"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:A?A(ie,Fe):t.jsxs(t.Fragment,{children:[ie.icon,t.jsx("span",{children:ie.label??Go(ie.service)}),ie.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ie.badge})]})},ie.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."})}),(M==null?void 0:M.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:M.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!M&&(C??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."})),M&&(Ie==null?void 0:Ie.loading)&&(v??t.jsx(Ko,{title:"Cargando modulo..."})),M&&(Ie==null?void 0:Ie.error)&&E(Ie.error,pe),M&&At&&!(Ie!=null&&Ie.loading)&&!(Ie!=null&&Ie.error)&&t.jsx(At,{context:s,parent:a,link:M,activeItemId:Me,onOpenDetail:Bt,onBackToList:Re})]})]})]})}const Ji={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 Ri({variant:e="info",title:r,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=Ji[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&t.jsx("div",{className:"mt-3",children:s})]}),l&&t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]})}const Qo=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],ec=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],tc=["lu","ma","mi","ju","vi","sá","do"],Jo=6;function La(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function rc(){const e=new Date;return La(e.getFullYear(),e.getMonth()+1,e.getDate())}function Ro(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function nc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Ro(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Qo[n-1]} ${r}`}function ac({value:e,onChange:r,minDate:n,displayMode:a="inline",className:s=""}){const l=rc(),c=Ro(e||l),d=a==="popover",[u,m]=o.useState(!1),b=o.useRef(null),[f,g]=o.useState({horizontal:"left",vertical:"bottom"}),[h,C]=o.useState(c.year),[v,E]=o.useState(c.month),[A,S]=o.useState("days"),O=16,[N,y]=o.useState(0),T=h-7+N,w=Array.from({length:O},(R,V)=>T+V);o.useEffect(()=>{if(!d||!u||!b.current)return;const R=b.current.getBoundingClientRect(),V=8,X=280,ce=340,D=R.left+X>window.innerWidth-V,_=R.right-X>=V,le=R.bottom+8+ce>window.innerHeight-V,I=R.top-8-ce>=V;g({horizontal:D&&_?"right":"left",vertical:le&&I?"top":"bottom"})},[d,u]),o.useEffect(()=>{if(!d||!u)return;function R(X){b.current&&(b.current.contains(X.target)||m(!1))}function V(X){X.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",V)}},[d,u]);function F(){v===1?(C(R=>R-1),E(12)):E(R=>R-1)}function Y(){v===12?(C(R=>R+1),E(1)):E(R=>R+1)}const K=(new Date(h,v-1,1).getDay()+6)%7,L=new Date(h,v,0).getDate(),G=[...Array(K).fill(null),...Array.from({length:L},(R,V)=>V+1)];for(;G.length<Jo*7;)G.push(null);const q=G.slice(0,Jo*7);function ne(R){const V=La(h,v,R);n&&V<n||(r(V),d&&m(!1))}const J=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${s}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:A==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:F,"aria-label":"Mes anterior",children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{S("years"),y(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Qo[v-1]," ",h]}),t.jsx(j.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:Y,"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:()=>y(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:()=>S("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:()=>y(R=>R+O),"aria-label":"Años siguientes",children:t.jsx(j.HiChevronRight,{size:16})})]})}),A==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:ec.map((R,V)=>{const X=V+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${X?" is-active":""}`,onClick:()=>E(V+1),children:R},R)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:w.map(R=>{const V=R===h,X=R===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${V?" is-active":""}${X&&!V?" is-today":""}`,onClick:()=>{C(R),S("days")},children:R},R)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:tc.map(R=>t.jsx("div",{className:"bonsaif-multi-weekday",children:R},R))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:q.map((R,V)=>{if(R===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},V);const X=La(h,v,R),ce=X===e,D=X===l,_=!!(n&&X<n);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${D?" bonsaif-multi-day-today":""}${_?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:_,"aria-pressed":ce,onClick:()=>!_&&ne(R),children:R})},V)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${s}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(R=>!R),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(j.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:nc(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:J})]}):J}const oc={sm:"h-4 w-4",md:"h-5 w-5"};function sc(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Nn=o.forwardRef(function({label:r,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,sc(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${oc[s]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${i}`}),t.jsx(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})]})]})});function es(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function lc(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}es(e)}function ic(e){return typeof e=="function"?e():e}function Da({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,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:h="button",...C}){const[v,E]=o.useState(!1),A=o.useRef(null);o.useEffect(()=>()=>{A.current&&window.clearTimeout(A.current)},[]);function S(N){E(!0),d==null||d(N),A.current&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{E(!1),A.current=null},r)}async function O(N){var T;if(c&&N.stopPropagation(),g==null||g(N),N.defaultPrevented)return;const y=ic(e);if(y)try{await lc(y),S(y)}catch(w){try{es(y),S(y)}catch(F){u==null||u(F,y);return}(T=navigator.clipboard)!=null&&T.writeText||u==null||u(w,y)}}return t.jsxs("button",{...C,type:h,onClick:O,title:v?a:n,"aria-label":C["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?s??f:f})]})}function cc({code:e,children:r,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(Da,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),t.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function jt({children:e,className:r="",style:n,as:a="span",followCursor:s=!1,placement:l="top"}){return t.jsx(Wt,{onlyWhenOverflow:!0,as:a,followCursor:s,placement:l,showArrow:!s,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Ia(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Oa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function dc(e,r){if(!r.trim())return!0;const n=Oa(r);return Oa(e.label).includes(n)||!!(e.sublabel&&Oa(e.sublabel).includes(n))}function lr({value:e,onChange:r,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:b,dropdownMinWidth:f,height:g=40,padding:h="0 10px",searchable:C=!0,minOptionsForSearch:v=6}){const[E,A]=o.useState(!1),[S,O]=o.useState(""),[N,y]=o.useState(-1),[T,w]=o.useState(!1),[F,Y]=o.useState({}),K=o.useRef(null),L=o.useRef(null),G=o.useRef(null),q=o.useRef(null),ne=C&&n.length>=v,J=n.find(P=>P.value===e)??null,R=l==="ghost",V=a==="error"?"var(--danger)":E?"var(--primary)":"var(--border)",X=ne&&S.trim()?n.filter(P=>dc(P,S)):n,ce=o.useCallback(()=>{const P=K.current;if(!P)return;const z=P.getBoundingClientRect(),de=ne?272:212,re=window.innerHeight-z.bottom,W=re<de&&z.top>re;Y({position:"fixed",left:z.left,top:W?void 0:z.bottom+4,bottom:W?window.innerHeight-z.top+4:void 0,width:z.width,minWidth:Ia(f),zIndex:9999})},[f,ne]);o.useEffect(()=>w(!0),[]),o.useEffect(()=>{if(!E)return;function P(z){var re,W;const de=z.target;!((re=K.current)!=null&&re.contains(de))&&!((W=L.current)!=null&&W.contains(de))&&(A(!1),O(""))}return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[E]),o.useEffect(()=>{E&&(y(-1),ce(),ne&&setTimeout(()=>{var P;return(P=G.current)==null?void 0:P.focus()},0))},[E,ne,ce]),o.useEffect(()=>{if(E)return window.addEventListener("resize",ce),window.addEventListener("scroll",ce,!0),()=>{window.removeEventListener("resize",ce),window.removeEventListener("scroll",ce,!0)}},[E,ce]),o.useEffect(()=>{if(N<0||!q.current)return;const P=q.current.children[N];P==null||P.scrollIntoView({block:"nearest"})},[N]);const D=o.useCallback(P=>{r(P),A(!1),O("")},[r]),_=o.useRef(E);_.current=E;const le=o.useRef(X);le.current=X;const I=o.useRef(N);I.current=N;const oe=o.useRef(d);oe.current=d;const k=o.useRef(D);k.current=D,o.useEffect(()=>{function P(z){var x,M;const de=document.activeElement,re=((x=K.current)==null?void 0:x.contains(de))??!1,W=((M=L.current)==null?void 0:M.contains(de))??!1;if(!(!re&&!W)){if(!_.current){(z.key==="Enter"||z.key===" "||z.key==="ArrowDown")&&(z.preventDefault(),A(!0));return}switch(z.key){case"ArrowDown":z.preventDefault(),y(ee=>Math.min(ee+1,le.current.length-1));break;case"ArrowUp":z.preventDefault(),y(ee=>Math.max(ee-1,oe.current?-1:0));break;case"Enter":{z.preventDefault();const ee=I.current,ue=le.current;ee===-1&&oe.current?k.current(""):ue[ee]&&!ue[ee].disabled&&k.current(ue[ee].value);break}case"Escape":z.preventDefault(),z.stopPropagation(),A(!1),O("");break}}}return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[]);const te=t.jsxs("div",{ref:L,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...F,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:S,onChange:P=>{O(P.target.value),y(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),S&&t.jsx("button",{type:"button",onMouseDown:P=>{P.preventDefault(),O("")},children:t.jsx(j.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:q,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ne?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:P=>{P.preventDefault(),D("")},onMouseEnter:()=>y(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:N===-1&&!S.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),X.map((P,z)=>{const re=z===N,W=P.value===e;return t.jsxs("li",{role:"option","aria-selected":W,onMouseDown:x=>{x.preventDefault(),P.disabled||D(P.value)},onMouseEnter:()=>!P.disabled&&y(z),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:re?"var(--bg-hover)":W?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:P.disabled?"var(--text-muted)":"var(--text-main)",cursor:P.disabled?"not-allowed":"pointer",boxShadow:W?"inset 2px 0 0 var(--primary)":void 0},children:[P.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:P.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(jt,{className:"min-w-0 flex-1",children:P.label}),P.sublabel&&t.jsx(jt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:P.sublabel})]}),P.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:P.badge})]},P.value)}),X.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&&A(P=>!P),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Ia(g),padding:Ia(h),background:R?"transparent":"var(--bg-input)",color:J?"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":E,"aria-label":s,children:[(J==null?void 0:J.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:J.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:J?t.jsxs(t.Fragment,{children:[t.jsx(jt,{className:"min-w-0 flex-1",children:J.label}),i&&J.sublabel&&t.jsx(jt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:J.sublabel})]}):t.jsx(jt,{className:"min-w-0 flex-1",children:c})}),J&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:P=>{P.preventDefault(),P.stopPropagation(),D("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(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:E?"rotate(180deg)":"rotate(0deg)"}})]}),E&&T&&ft.createPortal(te,document.body)]})}function kn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function uc({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(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:kn(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:kn(s),padding:kn(l)}})]})}function fc({value:e,onChange:r,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=s?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[s&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:kn(d)},children:s}),t.jsx(lr,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const bc={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Cn=180,mc="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Ha({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:g=!0,placement:h="center",bodyClassName:C="px-6 py-5",panelClassName:v="",backdropClassName:E=mc,contentClassName:A="p-4",ariaLabel:S,frameless:O=!1,disabled:N=!1}){const[y,T]=o.useState(!1),[w,F]=o.useState(!1),Y=o.useRef(null);if(o.useEffect(()=>(e?(Y.current&&clearTimeout(Y.current),T(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>F(!0)))):(F(!1),Y.current=setTimeout(()=>T(!1),Cn+40)),()=>{Y.current&&clearTimeout(Y.current)}),[e]),o.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),o.useEffect(()=>{if(!e||!f)return;const J=R=>{R.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[f,r,e]),!y)return null;const K=n||a||s||l||g,L=u??bc[d],G=h==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",q=h==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=w?"translateY(0) scale(1)":h==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ft.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":S??n,className:`fixed inset-0 flex ${G} ${A}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${E}`,onClick:b?r:void 0,style:{opacity:w?1:0,transition:`opacity ${Cn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${O?"shadow-none":"shadow-2xl"} ${q} ${v}`,style:{maxWidth:L,background:O?"transparent":"var(--bg-card)",border:O?"none":"1px solid var(--border)",opacity:w?1:0,transform:ne,transition:`opacity ${Cn}ms ease, transform ${Cn}ms ease`},onClick:J=>J.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:[s&&t.jsx("div",{className:"flex-shrink-0",children:s}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,g&&t.jsx(Ue,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${C}`,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 pc={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 hc({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=pc[l];return t.jsx(Ha,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ue,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(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(Ue,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),t.jsx(Ue,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function gc(e){return e?typeof e=="function"?e():e:""}function vc(e){return/^https?:\/\//i.test(e)}function ts(e,r){try{return new URL(e,r).toString()}catch{return e}}function yc(e,r,n,a=!1){const s=typeof e=="function"?e():e,l=r?r(s):s;if(!l||vc(l))return l;const i=gc(n);return i?ts(l,i):a&&typeof window<"u"?ts(l,window.location.origin):l}function xc({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(j.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Da,{...c,value:()=>yc(e,r,n,a),title:s,copiedTitle:l,icon:i})}const rs=32767;function Sn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=rs?r:`${r.slice(0,rs-1)}…`}const En=[25,50,100,200,500];let Mt={dataTable:{pageSizeOptions:[...En]}};function wc(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function Ba(){const e=Mt.dataTable.preferencesEndpoint,r=wc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Nc(e){if(!Array.isArray(e))return[...En];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:[...En]}function ns(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function kc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=ns(e.dataTable.preferencesEndpoint);Mt={...Mt,dataTable:{...Mt.dataTable,pageSizeOptions:Nc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Mt.dataTable.preferencesEndpoint}}}function Cc(){return{dataTable:{pageSizeOptions:[...Mt.dataTable.pageSizeOptions]}}}function Yr(){return[...Mt.dataTable.pageSizeOptions]}function Sc(){Mt={dataTable:{pageSizeOptions:[...En]}}}function Ec(e){Mt={...Mt,dataTable:{...Mt.dataTable,preferencesEndpoint:ns(e)}}}const Mn=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],Mc=Mn.map(e=>({value:e.value,label:e.label})),Tc=12,$c={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},as={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Ac="bonsaif-ui:datatable:",Lc="[&_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",Dc=[],Ic=52;function qt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function os(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 ss(e){return`${Ac}${e}`}function Tn(e){try{const r=window.localStorage.getItem(ss(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Oc(e,r){try{window.localStorage.setItem(ss(e),JSON.stringify(r))}catch{}}function Hc(e,r){if(e===!0)return{...as};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...as};const n={...$c,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function ls(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Fa(e,r,n){return typeof e!="number"||e<=0?n:Jr(r).includes(e)?e:n}function Kr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Gr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,s])=>{if(!r.has(a)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Zr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(Mn.map(s=>s.value)),a=Object.entries(e).flatMap(([s,l])=>{if(!r.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function gt(e,r){if(ir(e))return Ic;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Bc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function ir(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function Pa(e){return e.sticky===!0}function is(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function $n(e,r){const a=[...e.filter(s=>r.includes(s))];for(let s=0;s<r.length;s+=1){const l=r[s];if(a.includes(l))continue;let i=a.length;for(let c=s-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=s+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 Zt(e,r){const n=r.filter(Pa).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),s=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...s,...l]}function Fc(e,r){if(r<=7)return Array.from({length:r},(a,s)=>s+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function Qt(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 Pc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function xr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(xr).join(" ").trim():o.isValidElement(e)?xr(e.props.children):""}function An(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?Pc(n):xr(n).trim()}function Qr(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function wr(e,r){const n=Qr(e),a=Qr(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Jr(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:Yr()}function _c(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",s=((c=r.valueTo)==null?void 0:c.trim())??"",l=Mn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return wr(e,a)>0;case"greaterThanOrEqual":return wr(e,a)>=0;case"lessThan":return wr(e,a)<0;case"lessThanOrEqual":return wr(e,a)<=0;case"between":return wr(e,a)>=0&&wr(e,s)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:Qr(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(Qr).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=Qr(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function cs({children:e,className:r="",style:n}){return t.jsx(Wt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function ds({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:g,expandOnRowClick:h=!1,selected:C,onToggleOne:v,onToggleAll:E,getRowSelectable:A,highlightSelected:S=!0,rowClassName:O,getRowCategory:N,stickyHeader:y=!0,pageSize:T=25,pageSizeOptions:w,pageSizeSelectWidth:F=62,pageSizeSelectHeight:Y=30,pageSizeSelectPadding:K="0 7px",totalRows:L,page:G,onPageChange:q,onPageSizeChange:ne,storageKey:J,stickyFirstColumn:R=!1,bottomOffset:V=0,compact:X=!0,restrictHeight:ce=!0,maxHeight:D,minTableWidth:_,enableColumnVisibility:le=!0,enableColumnFilters:I=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:k=Dc,onHiddenColumnKeysChange:te,columnVisibilityLabel:P="Columnas",enableBql:z=!1,bqlValue:de,defaultBqlValue:re="",onBqlChange:W,bqlDescription:x="Filtra registros con Bonsaif Query Language",bqlPlaceholder:M=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:ee=[],bqlExamples:ue=[],bqlSuggestions:se=[],bqlActiveFilters:pe,bqlError:Me,onQueryChange:Ie,persistState:At,onPreferencesReady:Bt,enableExport:Re=!1,exportFilename:Ft="datos",onExportCsv:lt,onExportPdf:mt}){var Li;const ie=Hc(At,J),Fe=Object.values(ie).some(Boolean),ze=e.map(p=>p.key).join(","),it=k.join(","),Ve=o.useRef(e),kt=o.useRef(k);Ve.current=e,kt.current=k;const[rt,nt]=o.useState(!J||!Fe),Vt=o.useRef(null),be=o.useRef(!J),he=o.useRef(!1),$e=o.useRef(Bt);$e.current=Bt;const Be=o.useRef(!J||!Fe?J??"__none__":null),Le=oe!==void 0,[ct,at]=o.useState(()=>Qt(k,e)),Pe=Qt(Le?oe:ct,e),[We,ot]=o.useState(!1),[dt,dr]=o.useState("filter"),[st,He]=o.useState(null),[bn,sa]=o.useState(""),[ut,Ct]=o.useState({}),[St,tr]=o.useState({}),Fr=b!==void 0,[B,Z]=o.useState(f),fe=de!==void 0,[me,Ce]=o.useState(re),ve=fe?de:me,[De,Ae]=o.useState(ve),[Xe,Ye]=o.useState(!1),[rr,pt]=o.useState(!1),[Xt,Lt]=o.useState(!1),[nr,Yt]=o.useState([]),Pr=o.useRef(null),ur=o.useRef(null),Pt=o.useRef(W);Pt.current=W;const la=o.useRef(T);la.current=T;const ia=o.useRef(w);ia.current=w;const Eb=Array.isArray(w)?w.join(","):"",Co=o.useRef(null),ti=o.useRef(null),So=o.useRef(null),ri=o.useRef(0),[Mb,Tb]=o.useState({}),[$b,Ab]=o.useState({}),[mn,ca]=o.useState(!1),Eo=o.useRef(null),da=o.useRef(null),[Lb,Db]=o.useState({}),ni=o.useRef(null),ua=o.useRef(null),[Mo,ai]=o.useState(r.length>0||a||c===!1),oi=(p,$)=>50+(p*17+$*13+7)%40,ar=o.useRef(null),[Ib,Ob]=o.useState(void 0),[si,Hb]=o.useState(0),[Bb,Fb]=o.useState(!1);o.useEffect(()=>{function p(){Fb(window.innerWidth<640)}if(!ce||D!==void 0)return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const Q=T!==!1?48:0,H=12;function ae(){if(p(),!ar.current)return;const ge=ar.current.getBoundingClientRect().top;Ob(Math.max(120,window.innerHeight-ge-Q-H-V))}return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[a,T,V,ce,D]);const li=ce?D??Ib:void 0;o.useEffect(()=>{const p=ar.current;if(!p)return;const $=()=>Hb(p.clientWidth);if($(),typeof ResizeObserver>"u")return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$);const Q=new ResizeObserver($);return Q.observe(p),()=>Q.disconnect()},[a,rt,r.length]),o.useEffect(()=>{if(c===!1||a||r.length>0){ai(!0);return}if(Mo)return;const p=window.setTimeout(()=>{ai(!0)},c);return()=>window.clearTimeout(p)},[r.length,c,Mo,a]);const[_r,zr]=o.useState(()=>Zt(e.map(p=>p.key),e)),[fr,Wr]=o.useState(()=>Object.fromEntries(e.map(p=>[p.key,gt(p,qt(p.width))]))),[Ke,br]=o.useState(null),[Pb,fa]=o.useState(1),[ba,ma]=o.useState(T===!1?0:T);o.useEffect(()=>{var Te;const p=Ve.current,$=kt.current,Q=p.map(Ne=>Ne.key),H=new Set(Q),ae=()=>{var Ne;he.current||(he.current=!0,(Ne=$e.current)==null||Ne.call($e))};if(!J||!Fe){ie.layout&&zr(Zt(Q,p)),Le||at(Qt($,p)),be.current=!1,nt(!0),ae();return}let ge=!1;const ke=Be.current===J;ke||(be.current=!1,nt(!1),he.current=!1);const Ee=Tn(J);if(os(Ee)&&!ke){const Ne=Ee,xe=Jr(ia.current??Yr()),we=la.current,hr=we===!1?0:we,sr=ie.layout?Ne==null?void 0:Ne.columnOrder:void 0,gr=Array.isArray(sr)?sr.filter(je=>Q.includes(je)):[],vr=Zt(gr.length>0?$n(gr,Q):Q,p),yr=Object.fromEntries(p.map(je=>[je.key,gt(je,qt(je.width))])),Ur=ie.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},vn=Object.fromEntries(p.map(je=>[je.key,gt(je,Ur[je.key]??yr[je.key])])),Vr=Qt(ie.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??$:$,p);if(ie.layout&&(zr(vr),Wr(vn)),Le||at(Vr),ie.filters&&(Ct(Gr(Ne==null?void 0:Ne.filters,H)),tr(Zr(Ne==null?void 0:Ne.conditionFilters,H))),ie.sort){const je=Kr(Ne==null?void 0:Ne.sort)?Ne.sort:null;br(je&&H.has(je.key)?je:null)}if(ie.bql){if(Pr.current!==J){Pr.current=J;const je=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:re;fe?(Te=Pt.current)==null||Te.call(Pt,je):Ce(je)}Yt(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(je=>typeof je=="string"):[])}ie.pagination&&ur.current!==J&&(ur.current=J,ma(Fa(Ne==null?void 0:Ne.pageSize,xe,hr))),Be.current=J,nt(!0),ae()}const ht=`${Ba()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(J)}`,Qe=new AbortController,ye=window.setTimeout(()=>Qe.abort(),2500);return fetch(ht,{cache:"no-store",signal:Qe.signal}).then(Ne=>Ne.ok?Ne.json():null).then(Ne=>{var Di;if(ge)return;const xe=Tn(J),we=ls(os(Ne==null?void 0:Ne.settings)?Ne==null?void 0:Ne.settings:null,xe),hr=Jr(ia.current??Yr()),sr=la.current,gr=sr===!1?0:sr,vr=ie.layout?we==null?void 0:we.columnOrder:void 0,yr=Array.isArray(vr)?vr.filter(Je=>Q.includes(Je)):[],Ur=Zt(yr.length>0?$n(yr,Q):Q,p),vn=Object.fromEntries(p.map(Je=>[Je.key,gt(Je,qt(Je.width))])),Vr=ie.layout?(we==null?void 0:we.columnWidths)??{}:{},je=Object.fromEntries(p.map(Je=>[Je.key,gt(Je,Vr[Je.key]??vn[Je.key])])),Xr=Qt(ie.layout?(we==null?void 0:we.hiddenColumnKeys)??$:$,p);if(ie.layout&&(zr(Ur),Wr(je)),Le||at(Xr),ie.filters&&(Ct(Gr(we==null?void 0:we.filters,H)),tr(Zr(we==null?void 0:we.conditionFilters,H))),ie.sort){const Je=Kr(we==null?void 0:we.sort)?we.sort:null;br(Je&&H.has(Je.key)?Je:null)}if(ie.bql){if(Pr.current!==J){Pr.current=J;const Je=typeof(we==null?void 0:we.bql)=="string"?we.bql:re;fe?(Di=Pt.current)==null||Di.call(Pt,Je):Ce(Je)}Yt(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(Je=>typeof Je=="string"):[])}let Ge;ie.pagination&&(Ge=Fa(we==null?void 0:we.pageSize,hr,gr),ur.current!==J&&(ur.current=J,ma(Ge))),Vt.current=JSON.stringify({columnOrder:Ur,columnWidths:je,hiddenColumnKeys:Xr,filters:Gr(we==null?void 0:we.filters,H),conditionFilters:Zr(we==null?void 0:we.conditionFilters,H),sort:Kr(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:ie.pagination&&sr!==!1?Ge:void 0}),be.current=!0}).catch(()=>{var Ne;if(!ge){const xe=Tn(J),we=Jr(ia.current??Yr()),hr=la.current,sr=hr===!1?0:hr,gr=ie.layout?xe==null?void 0:xe.columnOrder:void 0,vr=Array.isArray(gr)?gr.filter(Ge=>Q.includes(Ge)):[],yr=Zt(vr.length>0?$n(vr,Q):Q,p),Ur=Object.fromEntries(p.map(Ge=>[Ge.key,gt(Ge,qt(Ge.width))])),vn=ie.layout?(xe==null?void 0:xe.columnWidths)??{}:{},Vr=Object.fromEntries(p.map(Ge=>[Ge.key,gt(Ge,vn[Ge.key]??Ur[Ge.key])]));ie.layout&&(zr(yr),Wr(Vr));const je=Qt(ie.layout?(xe==null?void 0:xe.hiddenColumnKeys)??$:$,p);if(Le||at(je),ie.filters&&(Ct(Gr(xe==null?void 0:xe.filters,H)),tr(Zr(xe==null?void 0:xe.conditionFilters,H))),ie.sort){const Ge=Kr(xe==null?void 0:xe.sort)?xe.sort:null;br(Ge&&H.has(Ge.key)?Ge:null)}if(ie.bql){if(Pr.current!==J){Pr.current=J;const Ge=typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:re;fe?(Ne=Pt.current)==null||Ne.call(Pt,Ge):Ce(Ge)}Yt(Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory.filter(Ge=>typeof Ge=="string"):[])}let Xr;ie.pagination&&(Xr=Fa(xe==null?void 0:xe.pageSize,we,sr),ur.current!==J&&(ur.current=J,ma(Xr))),Vt.current=JSON.stringify({columnOrder:yr,columnWidths:Vr,hiddenColumnKeys:je,filters:Gr(xe==null?void 0:xe.filters,H),conditionFilters:Zr(xe==null?void 0:xe.conditionFilters,H),sort:Kr(xe==null?void 0:xe.sort)?xe.sort:null,bql:typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:"",bqlHistory:Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory:[],pageSize:ie.pagination&&hr!==!1?Xr:void 0}),be.current=!0}}).finally(()=>{window.clearTimeout(ye),ge||(Be.current=J,nt(!0),ae())}),()=>{ge=!0,Qe.abort(),window.clearTimeout(ye)}},[J,Fe,ze,it,Le,ie.layout,ie.filters,ie.sort,ie.bql,ie.pagination,fe,re,Eb]),o.useEffect(()=>{if(!J||!rt||!Fe||!be.current)return;const p={};ie.layout&&(p.columnOrder=_r,p.columnWidths=fr,p.hiddenColumnKeys=Pe),ie.filters&&(p.filters=ut,p.conditionFilters=St),ie.sort&&(p.sort=Ke),ie.bql&&(p.bql=ve,p.bqlHistory=nr),ie.pagination&&T!==!1&&(p.pageSize=ba);const $=Tn(J),Q=ls($,p),H=JSON.stringify(Q);if(H===Vt.current)return;Oc(J,Q),Vt.current=H;const ae=window.setTimeout(()=>{const ge=Ba()??"/api/user/preferences/datatables";fetch(ge,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:J,settings:Q})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(ae)},[_r,fr,Pe,ut,St,Ke,ve,nr,ba,T,J,rt,Fe,ie.layout,ie.filters,ie.sort,ie.bql,ie.pagination]),o.useEffect(()=>{zr(p=>{const $=e.map(Q=>Q.key);return Zt($n(p,$),e)})},[ze,e]);const ii=Zt(_r,e).map(p=>e.find($=>$.key===p)).filter(p=>!!p),Et=ii.filter(p=>!Pe.includes(p.key)),ci=e.some(Pa),_b=Object.keys(ut).length,zb=Object.keys(St).length,To=_b+zb;function di(p){const $=new Set;return r.reduce((Q,H)=>{const ae=An(p,H);return!ae||$.has(ae)||($.add(ae),Q.push({value:ae,label:ae})),Q},[])}function Wb(){const p=e.find($=>$.key===st);return p?di(p):[]}function jb(p){return!!(I&&!ir(p)&&(p.filterValue||p.sortKey||di(p).length>0))}function ui(p,$){Ct(Q=>{const H={...Q};return H[p]=$,H})}function qb(p,$,Q,H){const ae=ut[p]??[],ge=H?ae:Q.filter(Ee=>Ee!==$),ke=H?ae.includes($)?ae.filter(Ee=>Ee!==$):[...ae,$]:ge;ke.length===Q.length?$o(p):ui(p,ke)}function $o(p){Ct($=>{const Q={...$};return delete Q[p],Q})}function pa(p,$){tr(Q=>{const H={...Q};return $?H[p]=$:delete H[p],H})}function fi(p){pa(p,null)}function Ub(){Ct({}),tr({})}function Vb(p){fe||Ce(p),W==null||W(p)}function bi(p){const $=p.trim();Ae($),(W==null?void 0:W($))!==!1&&(fe||Ce($),Ye(!1),pt(!1),Lt(!1),$&&Yt(H=>[$,...H.filter(ae=>ae!==$)].slice(0,Tc)))}function mi(){Ae(""),Vb(""),Ye(!1),pt(!1),Lt(!1)}function Ao(p,$){Ae(p),$&&($.style.height="auto",$.style.height=`${Math.min($.scrollHeight,180)}px`)}function ha(p){const $=p.trim();if(!$)return;ri.current=Date.now()+500;const Q=De.replace(/\s+$/u,""),H=Q.length===0?$:Q.split(`
3
- `).map(ae=>ae.trim()).includes($)?Q:`${Q}
4
- ${$}`;Ao(H,So.current??void 0),requestAnimationFrame(()=>{const ae=So.current;if(!ae)return;ae.focus();const ge=ae.value.length;ae.setSelectionRange(ge,ge),Ao(ae.value,ae)})}o.useEffect(()=>{Ae(ve)},[ve]);const ga=o.useCallback(()=>{const p=Co.current;if(!p)return;const $=p.getBoundingClientRect(),Q=12,H=8,ae=Math.min(780,Math.max(320,window.innerWidth-32)),ge=Math.max(Q,window.innerWidth-ae-Q),ke=Math.min(Math.max(Q,$.left),ge),Ee=$.bottom+H,_e=window.innerHeight-$.top+H,qe=window.innerHeight-Ee-Q,ht=$.top-Q-H,Qe=qe<280&&ht>qe,ye=Math.max(240,Qe?ht:qe);Tb({position:"fixed",zIndex:1e4,left:ke,top:Qe?void 0:Ee,bottom:Qe?_e:void 0,width:ae,maxWidth:"calc(100vw - 24px)",maxHeight:ye,overflowY:"auto"})},[]);o.useEffect(()=>{if(!Xe)return;function p(H){var ge,ke;if(Date.now()<ri.current)return;const ae=H.target;(ge=Co.current)!=null&&ge.contains(ae)||(ke=ti.current)!=null&&ke.contains(ae)||(Ye(!1),pt(!1),Lt(!1))}function $(H){H.key==="Escape"&&(Ye(!1),pt(!1),Lt(!1))}function Q(){ga()}return ga(),document.addEventListener("mousedown",p),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Xe,ga]);function pi(p){const $=Qt(p,e);Le||at($),te==null||te($)}function Xb(p){pi(Pe.includes(p)?Pe.filter($=>$!==p):[...Pe,p])}function Yb(){pi([])}const Lo=o.useCallback((p=ua.current)=>{if(!p)return;const $=p.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),H=Math.max(8,window.innerWidth-Q-8),ae=Math.min(Math.max(8,$.right-Q),H),ge=window.innerHeight-$.bottom,ke=$.bottom+6,Ee=window.innerHeight-$.top+6,qe=ge<360&&$.top>ge?void 0:ke,ht=qe===void 0?Ee:void 0,Qe=Math.max(220,qe===void 0?$.top-16:window.innerHeight-ke-8),ye={position:"fixed",zIndex:9999,left:ae,top:qe,bottom:ht,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:Qe,"--dt-column-menu-max-height":`${Qe}px`};Ab(ye)},[]);function hi(p,$,Q=null){p.preventDefault(),p.stopPropagation();const H=ua.current===p.currentTarget&&dt===$&&st===Q;if(We&&H){ot(!1),He(null);return}ua.current=p.currentTarget,dr($),He(Q),sa(""),Lo(p.currentTarget),ot(!0)}function Kb(p){if(ir(p))return;const $=ar.current;if(!$)return;const H=Array.from($.querySelectorAll("[data-dt-column-key]")).filter(ae=>ae.dataset.dtColumnKey===p.key).reduce((ae,ge)=>{const ke=ge.querySelector("[data-dt-autofit-content]"),Ee=ke?ke.scrollWidth:Math.max(ge.scrollWidth,ge.offsetWidth);return Math.max(ae,Math.ceil(Ee+Bc(ge)))},0);H<=0||Wr(ae=>({...ae,[p.key]:gt(p,H+12)}))}o.useEffect(()=>{Wr(p=>{const $=Object.fromEntries(e.map(Q=>[Q.key,gt(Q,qt(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,gt(Q,p[Q.key]??$[Q.key])]))})},[ze,e]),o.useEffect(()=>{Le||at(p=>Qt(p,e))},[ze,e,Le]),o.useEffect(()=>{function p(H){var ke,Ee;const ae=H.target,ge=H.target;ge!=null&&ge.closest("[data-bonsaif-select-dropdown='true']")||!((ke=ni.current)!=null&&ke.contains(ae))&&!((Ee=ua.current)!=null&&Ee.contains(ae))&&(ot(!1),He(null))}function $(H){H.key==="Escape"&&(ot(!1),He(null))}function Q(){Lo()}return We&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[We,Lo]);const pn=o.useRef(null);o.useEffect(()=>{function p(Q){const H=pn.current;if(!H)return;const ae=Q.clientX-H.startX,ge=e.find(ke=>ke.key===H.colKey);ge&&Wr(ke=>({...ke,[H.colKey]:gt(ge,H.startWidth+ae)}))}function $(){pn.current&&(pn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",$),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",$)}},[e]);const hn=o.useRef(null),[gi,Do]=o.useState(null);function Gb(p,$){const Q=e.find(H=>H.key===p);if(!Q||!is(Q)){$.preventDefault();return}hn.current=_r.indexOf(p),$.dataTransfer.effectAllowed="move"}function Zb(p,$){$.preventDefault(),$.dataTransfer.dropEffect="move";const Q=_r.indexOf(p);gi!==Q&&Do(Q)}function Qb(p,$){$.preventDefault();const Q=hn.current,H=_r.indexOf(p);Q!==null&&Q!==H&&zr(ae=>{const ge=[...ae],[ke]=ge.splice(Q,1);return ge.splice(H,0,ke),Zt(ge,e)}),hn.current=null,Do(null)}function Jb(){hn.current=null,Do(null)}function Rb(p){p.sortKey&&br($=>($==null?void 0:$.key)===p.key?{key:p.key,dir:$.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}o.useEffect(()=>{fa(1)},[r]),o.useEffect(()=>{fa(1)},[St,ut]);const _t=!!(q&&ne),or=T!==!1,Io=o.useMemo(()=>Jr(w??Yr()),[w]),tt=_t?G??1:Pb,vi=or&&ba<1?typeof T=="number"&&T>0?T:Io[0]??25:ba,zt=_t||or?vi:r.length,Dt=!!C&&!!v&&!!E,Oo=o.useMemo(()=>A?r.filter(p=>A(p)):r,[r,A]),jr=!!u,yi=o.useMemo(()=>new Set(Fr?Array.from(b??[]):B),[Fr,b,B]),em=(jr?40:0)+(Dt?40:0),Ho=!Bb&&(ci||R),va=(()=>{if(!Ho)return{};let p=em;const $={};return Et.forEach((Q,H)=>{(Pa(Q)||!ci&&R&&H===0)&&($[Q.key]=p,p+=fr[Q.key]??gt(Q,qt(Q.width)))}),$})(),Bo=Object.keys(va),Fo=Bo.length>0?Bo[Bo.length-1]:null,xi=Dt&&Oo.length>0&&Oo.every(p=>C.has(n(p))),tm=Dt&&C.size>0&&Oo.some(p=>C.has(n(p)))&&!xi,ya=o.useMemo(()=>{if(_t)return r;const p=Object.entries(ut),$=Object.entries(St);return p.length===0&&$.length===0?r:r.filter(Q=>p.every(([H,ae])=>{const ge=e.find(ke=>ke.key===H);return ge?ae.includes(An(ge,Q)):!0})&&$.every(([H,ae])=>{const ge=e.find(Ee=>Ee.key===H);if(!ge)return!0;const ke=r.map(Ee=>An(ge,Ee));return _c(An(ge,Q),ae,ke)}))},[St,ut,e,r,_t]),mr=o.useMemo(()=>{if(!Ke)return ya;const p=e.find($=>$.key===Ke.key&&$.sortKey);return p!=null&&p.sortKey?[...ya].sort(($,Q)=>{const H=$[p.sortKey],ae=Q[p.sortKey],ge=H===ae?0:H==null?1:ae==null||H<ae?-1:1;return Ke.dir==="asc"?ge:-ge}):ya},[ya,Ke,e]),wi=o.useMemo(()=>{if(_t||!or)return mr;const p=(tt-1)*zt;return mr.slice(p,p+zt)},[mr,_t,or,tt,zt]),Kt=_t?L??r.length:mr.length,Po=or?Math.max(1,Math.ceil(Kt/zt)):1,rm=Math.min(...Io),nm=or&&(Kt>zt||Kt>rm),am=or?(tt-1)*zt+1:1,om=or?Math.min(tt*zt,Kt):Kt;function _o(p){if(a)return;const $=Math.max(1,Math.min(p,Po));_t?q($):fa($)}function sm(p){a||(J&&(ur.current=J),ma(p),_t?(ne(p),q(1)):(fa(1),ne==null||ne(p)))}function Ni(p){const $=new Set(yi);$.has(p)?$.delete(p):$.add(p);const Q=Array.from($);Fr||Z(Q),g==null||g(Q)}o.useEffect(()=>{Ie==null||Ie({bql:ve,filters:ut,conditionFilters:St,sort:Ke,page:tt,pageSize:zt,hiddenColumnKeys:Pe})},[ve,ut,St,Ke,tt,zt,Pe,Ie]);const ki=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",lm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",zo="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",pr="color-mix(in srgb, var(--primary) 24%, var(--border))",xa=`inset 0 0 0 1px ${Oe}`,Ci=Et.reduce((p,$)=>p+(fr[$.key]??qt($.width)),(jr?40:0)+(Dt?40:0)),Si=typeof _=="number"?_:typeof _=="string"?Number(((Li=_.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Li[1])??NaN):NaN,gn=Number.isFinite(Si)?Math.max(Ci,Si,si):Math.max(Ci,si),wa=_??gn,qr=`${jr?"40px ":""}${Dt?"40px ":""}${Et.map(p=>`${fr[p.key]??qt(p.width)}px`).join(" ")}`;o.useEffect(()=>{Ke&&Pe.includes(Ke.key)&&br(null)},[Pe,Ke]);function Ei(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const Na=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:qr,background:zo,borderBottom:`1px solid ${pr}`},children:[jr&&t.jsx("div",{role:"columnheader",className:`${X?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${pr}`,borderRight:`1px solid ${Oe}`}}),Dt&&t.jsx("div",{role:"columnheader",className:`${X?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Ho?{position:"sticky",left:0,zIndex:12,background:zo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${pr}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${pr}`,borderRight:`1px solid ${Oe}`},children:t.jsx(Nn,{size:"sm",checked:xi,indeterminate:tm,onChange:E,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Et.map((p,$)=>{const Q=(Ke==null?void 0:Ke.key)===p.key,H=!!p.sortKey,ae=ir(p),ge=va[p.key],ke=ge!==void 0,Ee=p.key===Fo,_e=is(p),qe=gi===$,Qe=(fr[p.key]??qt(p.width))<120,ye=Object.prototype.hasOwnProperty.call(ut,p.key)||Object.prototype.hasOwnProperty.call(St,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${Qe?"text-left":ki(p.align)}`,style:{...ke?{position:"sticky",left:ge,zIndex:12,background:zo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Ee?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${pr}`:`inset 0 -1px 0 ${pr}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${pr}`,borderRight:`1px solid ${Oe}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:qe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ae?X?"7px 6px":"9px 8px":X?"8px 6px 10px":"10px 8px 12px"},onDragOver:Te=>{(_e||hn.current!==null)&&Zb(p.key,Te)},onDrop:Te=>Qb(p.key,Te),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ae?"justify-center":Qe?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[_e?t.jsx("span",{draggable:!0,onDragStart:Te=>{Te.stopPropagation(),Gb(p.key,Te)},onDragEnd:Te=>{Te.stopPropagation(),Jb()},onClick:Te=>Te.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 ${qe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ae?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(cs,{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 ${X?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),H&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:Te=>{Te.stopPropagation(),Rb(p)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${Q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Q?Ke.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"})}),I&&!ae&&jb(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":We&&st===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:Te=>hi(Te,"filter",p.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${We&&dt==="filter"&&st===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ye?"text-[var(--primary)] opacity-100":""}`,children:ye?t.jsx(j.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(j.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ae&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Te=>{Te.preventDefault(),Te.stopPropagation(),pn.current={colKey:p.key,startX:Te.clientX,startWidth:fr[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Te=>{Te.preventDefault(),Te.stopPropagation(),pn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Kb(p)},onClick:Te=>Te.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),ka=()=>{if(!We||typeof document>"u"||dt==="visibility"&&!le||dt==="filter"&&!I)return null;const p=e.find(ye=>ye.key===st),$=Wb(),Q=p?Object.prototype.hasOwnProperty.call(ut,p.key):!1,H=p?St[p.key]:void 0,ae=Mn.find(ye=>ye.value===(H==null?void 0:H.operator)),ge=p?ut[p.key]??[]:[],ke=bn.trim().toLowerCase(),Ee=ke?$.filter(ye=>ye.label.toLowerCase().includes(ke)):$,_e=p&&$.length>0&&(!Q||ge.length===$.length),qe=p&&Q&&ge.length>0&&ge.length<$.length,ht=Pe.length,Qe=()=>{p&&($o(p.key),fi(p.key))};return ft.createPortal(t.jsx("div",{ref:ni,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...$b,borderColor:"var(--border)",background:"var(--bg-card)"},children:dt==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:ht>0?`${Et.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Yb,disabled:ht===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:ii.map(ye=>{const Te=!Pe.includes(ye.key),xe=!(ye.hideable!==!1)||Te&&Et.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Te,disabled:xe,onClick:()=>Xb(ye.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Te?"var(--primary)":"var(--border)",background:Te?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Te&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.header})]},ye.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:Qe,disabled:!Q&&!H,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>br({key:p.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(j.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ke==null?void 0:Ke.key)===p.key&&Ke.dir==="asc"&&t.jsx(j.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>br({key:p.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(j.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ke==null?void 0:Ke.key)===p.key&&Ke.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(lr,{value:(H==null?void 0:H.operator)??"",onChange:ye=>{if(!ye){fi(p.key);return}pa(p.key,{operator:ye,value:(H==null?void 0:H.value)??"",valueTo:(H==null?void 0:H.valueTo)??""})},options:Mc,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"}),(ae==null?void 0:ae.valueMode)!=="none"?t.jsx("input",{value:(H==null?void 0:H.value)??"",onChange:ye=>{H&&pa(p.key,{...H,value:ye.target.value})},disabled:!H,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"})]}),(ae==null?void 0:ae.valueMode)==="between"&&t.jsx("input",{value:(H==null?void 0:H.valueTo)??"",onChange:ye=>{H&&pa(p.key,{...H,valueTo:ye.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:bn,onChange:ye=>sa(ye.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe?"mixed":!!_e,onClick:()=>{p&&(_e&&!Q?ui(p.key,[]):$o(p.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:_e||qe?"var(--primary)":"var(--border)",background:_e||qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[qe&&t.jsx(j.HiMinus,{className:"h-3 w-3"}),_e&&!qe&&t.jsx(j.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Ee.map(ye=>{const Te=!Q||ge.includes(ye.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Te,onClick:()=>qb(p.key,ye.value,$.map(Ne=>Ne.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:Te?"var(--primary)":"var(--border)",background:Te?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Te&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.label})]},ye.value)}),Ee.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!mn)return;function p($){Eo.current&&!Eo.current.contains($.target)&&da.current&&!da.current.contains($.target)&&ca(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[mn]);function Mi(p,$){if(p.filterValue){const Q=p.filterValue($);return Q==null||Q===""?"":Sn(Q)}return Sn(xr(p.cell($)))}function Ti(p){return`"${Sn(p).replace(/"/g,'""')}"`}function Ca(p){return Sn(p).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function $i(){return _t&&Kt>mr.length&&Ta.toast.warning(`Exportando ${mr.length.toLocaleString("es-MX")} de ${Kt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),mr}function im(){const p=Et.filter(_e=>!ir(_e)),$=$i(),Q=p.map(_e=>Ti(xr(_e.header))).join(","),H=$.map(_e=>p.map(qe=>Ti(Mi(qe,_e))).join(",")).join(`
5
- `),ae=`${Q}
6
- ${H}`,ge=new Blob(["\uFEFF"+ae],{type:"text/csv;charset=utf-8;"}),ke=URL.createObjectURL(ge),Ee=document.createElement("a");Ee.href=ke,Ee.download=`${Ft}.csv`,document.body.appendChild(Ee),Ee.click(),document.body.removeChild(Ee),URL.revokeObjectURL(ke)}function cm(){const p=Et.filter(Ee=>!ir(Ee)),$=$i(),Q=p.map(Ee=>Ca(xr(Ee.header))),ae=$.map(Ee=>p.map(_e=>Ca(Mi(_e,Ee)))).map(Ee=>`<tr>${Ee.map(_e=>`<td>${_e}</td>`).join("")}</tr>`).join(""),ge=`<!DOCTYPE html>
7
- <html lang="es"><head><meta charset="utf-8"><title>${Ca(Ft)}</title>
1
+ (function(q,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):(q=typeof globalThis<"u"?globalThis:q||self,s(q.BonsaifUI={},q.React,q.jsxRuntime,q.ReactIconsHi2,q.ReactDOM,q.Recharts,q.OverlayScrollbarsGlobal,q.Sonner,q.OverlayScrollbarsReact,q.ReactDayPicker,q.ReactDayPickerStyles,q.ReactIconsFi))})(this,(function(q,s,t,W,ht,Me,Oa,Ha,Zo,Ia,Hm,Ki){"use strict";"use client";function Zt(...e){return e.filter(Boolean).join(" ")}function Gi({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Zt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function Qo({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",h=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 E=()=>{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?h:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),E())},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:`${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(W.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Jo=s.createContext({});let Ro=0;const es="bonsaif-ui:hide-tooltips";function Sn(e=700){Ro=Date.now()+e}function Zi(){return Date.now()>Ro}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 Qi(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 Bt({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),h=s.useRef(null),E=s.useRef(!1),[v,S]=s.useState(null),[A,C]=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,ne=D.getBoundingClientRect(),J=window.innerWidth-ne.width-G,R=window.innerHeight-ne.height-G;let V=v.mouseX+U,X=v.mouseY+U,de,H;if(!o&&f.current){const I=f.current.getBoundingClientRect(),le=I.left+I.width/2,L=I.top+I.height/2;l==="top"?(V=le-ne.width/2,X=I.top-ne.height-U,H=ne.height-1):l==="left"?(V=I.left-ne.width-U,X=L-ne.height/2,de=ne.width-1):l==="right"?(V=I.right+U,X=L-ne.height/2,de=-7):(V=le-ne.width/2,X=I.bottom+U,H=-7)}if(o&&(V>J&&(V=v.mouseX-ne.width-U),X>R&&(X=v.mouseY-ne.height-U)),V=Math.min(Math.max(G,V),Math.max(G,J)),X=Math.min(Math.max(G,X),Math.max(G,R)),!o&&f.current){const I=f.current.getBoundingClientRect(),le=I.left+I.width/2,L=I.top+I.height/2;l==="top"||l==="bottom"?de=Math.min(Math.max(14,le-V),ne.width-14):H=Math.min(Math.max(14,L-X),ne.height-14)}(Math.abs(V-v.x)>.5||Math.abs(X-v.y)>.5||de!==v.arrowX||H!==v.arrowY)&&S(I=>I&&{...I,x:V,y:X,arrowX:de,arrowY:H})},[o,l,v]);const O=()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},N=(D,G)=>{if(!Zi()||E.current)return;const U=f.current;if(U&&!En(U)){if(n){const ne=Qi(U);if(!ne)return;C(ne)}!n&&!r||S({mouseX:D,mouseY:G,x:D+14,y:G+14})}},y=()=>{const D=f.current;if(!D)return;const G=D.getBoundingClientRect();N(G.left+G.width/2,G.bottom)},M=()=>{O(),S(null)},k=()=>{if(!a){M();return}O(),h.current=window.setTimeout(()=>S(null),120)},_=()=>{Sn(),E.current=!0,M()},Y=()=>{E.current=!1};s.useEffect(()=>{if(!v)return;if(En(f.current)){S(null);return}const D=()=>S(null),G=()=>{Sn(),E.current=!0,S(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)&&S(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(),E.current=!0,S(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(es,G),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(es,G)}},[]);const K=n?A:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{O(),Y(),o?N(D.clientX,D.clientY):y()},onMouseMove:D=>{v&&o&&N(D.clientX,D.clientY)},onMouseDown:_,onClick:_,onMouseLeave:()=>{Y(),k()},onFocus:y,onBlur:M,children:e}),v&&K&&!En(f.current)?ht.createPortal(t.jsxs("div",{ref:g,role:"tooltip",className:d,onMouseEnter:a?O:void 0,onMouseLeave:a?k: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 ts(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Ji="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",Ri={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"},ec="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",tc={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"},rc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},nc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ba(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ba).join(" ").trim():s.isValidElement(e)?Ba(e.props.children):""}function ac(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ve({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const g=s.useContext(Jo),h=l??g.iconOnly??e==="icon",E=g.compact??!1,v=g.headerAction??!1,S=v&&r==="md"?"sm":E&&!v&&r==="md"?"xs":r,A=e==="icon"||h,C=v&&A,O=Ba(d),N=o??f.title??f["aria-label"]??(h?O:void 0),y=N?void 0:f.title,M=f["aria-label"]??(typeof N=="string"?N:O||void 0),k=n?null:a??(h?ac(d):null),_=t.jsxs("button",{...f,title:y,"aria-label":M,"data-variant":e,"data-size":S,"data-icon":A?"true":void 0,disabled:m||n,className:`${Ji} ${C?ec:Ri[e]} ${A?rc[S]:tc[S]} ${E&&!A?"px-2.5":""} ${u}`,style:{...nc[e],height:ts(i),padding:ts(c),...b,...v&&!A?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...C?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):k,!h&&d]});return N?t.jsx(Bt,{as:"span",content:N,className:"inline-flex shrink-0",children:_}):_}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 oc({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 sc({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 rs({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(lc,{rows:i});if(e==="cards")return t.jsx(ic,{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(sc,{logoSrc:a,logoAlt:m}):null,t.jsx(oc,{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 lc({rows:e}){return t.jsx(Cn,{rows:e,columns:7})}function ic({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 ns(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function as(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function cc(e){return[e.label,ns(e.service),e.description,e.service].filter(Boolean).join(" ")}function dc(e){return typeof e=="function"?e:e.default}function uc(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ve,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function fc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:h,emptyState:E,loadingState:v,errorState:S=uc,renderTabLabel:A,searchableTabs:C="auto",tabsSearchThreshold:O=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:y,onTabsSearchChange:M,emptySearchState:k,showTabCount:_=!0,className:Y="",parentClassName:K="",contentClassName:D="",tabsClassName:G=""}){var Le;const U=s.useMemo(()=>l.filter(ce=>!ce.hidden&&((b==null?void 0:b(ce,o))??!0)),[b,o,l]),ne=(Le=U.find(ce=>!ce.disabled))==null?void 0:Le.service,[J,R]=s.useState(u??ne??""),[V,X]=s.useState({}),[de,H]=s.useState({}),[I,le]=s.useState(""),[L,oe]=s.useState(!1),w=s.useRef(de),te=s.useRef(0),B=y??I,F=as(B),ue=C===!0||C==="auto"&&U.length>=O,re=ue&&B.trim().length>0,j=s.useMemo(()=>F?U.filter(ce=>as(cc(ce)).includes(F)):U,[F,U]),x=d??J,T=U.find(ce=>ce.service===x)??U.find(ce=>!ce.disabled);s.useEffect(()=>{!T&&ne&&R(ne)},[ne,T]),s.useEffect(()=>{w.current=de},[de]);const ee=ce=>{ce.disabled||(d||R(ce.service),m==null||m(ce.service,ce))},fe=ce=>{y===void 0&&le(ce),M==null||M(ce)},ie=(ce,Pe)=>{const _e=j.filter(Xe=>!Xe.disabled),at=_e.findIndex(Xe=>Xe.service===Pe.service);at<0||((ce.key==="ArrowRight"||ce.key==="ArrowDown")&&(ce.preventDefault(),ee(_e[(at+1)%_e.length])),(ce.key==="ArrowLeft"||ce.key==="ArrowUp")&&(ce.preventDefault(),ee(_e[(at-1+_e.length)%_e.length])),ce.key==="Home"&&(ce.preventDefault(),ee(_e[0])),ce.key==="End"&&(ce.preventDefault(),ee(_e[_e.length-1])))},pe=s.useCallback(()=>{if(!T)return;const ce=T.service,Pe=w.current[ce];if(Pe!=null&&Pe.loading||Pe!=null&&Pe.component&&f)return;const _e=(i==null?void 0:i[ce])??c;if(!_e){H(Xe=>({...Xe,[ce]:{loading:!1,error:new Error(`No module loader found for service "${ce}".`)}}));return}const at=++te.current;H(Xe=>({...Xe,[ce]:{...Xe[ce],loading:!0,error:void 0}})),_e(T,o).then(Xe=>{if(at!==te.current&&!f)return;const Ct=dc(Xe);H(lt=>({...lt,[ce]:{component:Ct,loading:!1}}))}).catch(Xe=>{const Ct=Xe instanceof Error?Xe:new Error(String(Xe));H(lt=>({...lt,[ce]:{...lt[ce],loading:!1,error:Ct}}))})},[o,f,c,i,T]);s.useEffect(pe,[pe]);const ae=T?V[T.service]??null:null,ye=T?de[T.service]:void 0,Qe=ye==null?void 0:ye.component,Je=ce=>{T&&X(Pe=>({...Pe,[T.service]:ce}))},et=()=>{T&&X(ce=>({...ce,[T.service]:null}))},ft={context:o,parent:a,links:l,visibleLinks:U,filteredLinks:j,selectedLink:T,selectedService:T==null?void 0:T.service,activeItemId:ae,tabsSearch:B,onSelectService:ee,onOpenDetail:Je,onBackToList:et},nt=n?n(ft):r?t.jsx(r,{...ft}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${Y}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${K}`,children:nt}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(g||h||ue||_)&&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}),h&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:h})]}),(ue||_)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[_&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[j.length," / ",U.length]}),ue&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${L?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!L,children:t.jsx(Qo,{value:B,onChange:fe,placeholder:N,className:"w-full",autoFocus:L,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:L?0:-1})}),t.jsx("button",{type:"button","aria-label":L?"Cerrar busqueda":"Buscar tabs","aria-expanded":L,onClick:()=>{L&&B&&fe(""),oe(ce=>!ce)},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 ${L||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:L||re?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":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:j.length>0?j.map(ce=>{const Pe=ce.service===(T==null?void 0:T.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Pe,disabled:ce.disabled,onClick:()=>ee(ce),onKeyDown:_e=>ie(_e,ce),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 ${Pe?"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:A?A(ce,Pe):t.jsxs(t.Fragment,{children:[ce.icon,t.jsx("span",{children:ce.label??ns(ce.service)}),ce.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ce.badge})]})},ce.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:k??"No hay modulos que coincidan con la busqueda."})}),(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&&(E??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),T&&(ye==null?void 0:ye.loading)&&(v??t.jsx(rs,{title:"Cargando modulo..."})),T&&(ye==null?void 0:ye.error)&&S(ye.error,pe),T&&Qe&&!(ye!=null&&ye.loading)&&!(ye!=null&&ye.error)&&t.jsx(Qe,{context:o,parent:a,link:T,activeItemId:ae,onOpenDetail:Je,onBackToList:et})]})]})]})}const bc={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 mc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=bc[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&t.jsx("div",{className:"mt-3",children:o})]}),l&&t.jsx(Ve,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]})}const os=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],pc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],hc=["lu","ma","mi","ju","vi","sá","do"],ss=6;function Fa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function gc(){const e=new Date;return Fa(e.getFullYear(),e.getMonth()+1,e.getDate())}function ls(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function vc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=ls(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${os[n-1]} ${r}`}function yc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=gc(),c=ls(e||l),d=a==="popover",[u,m]=s.useState(!1),b=s.useRef(null),[f,g]=s.useState({horizontal:"left",vertical:"bottom"}),[h,E]=s.useState(c.year),[v,S]=s.useState(c.month),[A,C]=s.useState("days"),O=16,[N,y]=s.useState(0),M=h-7+N,k=Array.from({length:O},(R,V)=>M+V);s.useEffect(()=>{if(!d||!u||!b.current)return;const R=b.current.getBoundingClientRect(),V=8,X=280,de=340,H=R.left+X>window.innerWidth-V,I=R.right-X>=V,le=R.bottom+8+de>window.innerHeight-V,L=R.top-8-de>=V;g({horizontal:H&&I?"right":"left",vertical:le&&L?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function R(X){b.current&&(b.current.contains(X.target)||m(!1))}function V(X){X.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",V)}},[d,u]);function _(){v===1?(E(R=>R-1),S(12)):S(R=>R-1)}function Y(){v===12?(E(R=>R+1),S(1)):S(R=>R+1)}const K=(new Date(h,v-1,1).getDay()+6)%7,D=new Date(h,v,0).getDate(),G=[...Array(K).fill(null),...Array.from({length:D},(R,V)=>V+1)];for(;G.length<ss*7;)G.push(null);const U=G.slice(0,ss*7);function ne(R){const V=Fa(h,v,R);n&&V<n||(r(V),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:A==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:_,"aria-label":"Mes anterior",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{C("years"),y(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[os[v-1]," ",h]}),t.jsx(W.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:Y,"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:()=>y(R=>R-O),"aria-label":"Años anteriores",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>C("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[k[0]," – ",k[k.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>y(R=>R+O),"aria-label":"Años siguientes",children:t.jsx(W.HiChevronRight,{size:16})})]})}),A==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:pc.map((R,V)=>{const X=V+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${X?" is-active":""}`,onClick:()=>S(V+1),children:R},R)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:k.map(R=>{const V=R===h,X=R===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${V?" is-active":""}${X&&!V?" is-today":""}`,onClick:()=>{E(R),C("days")},children:R},R)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:hc.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 X=Fa(h,v,R),de=X===e,H=X===l,I=!!(n&&X<n);return t.jsx("div",{className:`bonsaif-multi-day${de?" bonsaif-multi-day-selected":""}${H?" bonsaif-multi-day-today":""}${I?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:I,"aria-pressed":de,onClick:()=>!I&&ne(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(W.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:vc(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 qt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Bt,{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 Pa(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function _a(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function xc(e,r){if(!r.trim())return!0;const n=_a(r);return _a(e.label).includes(n)||!!(e.sublabel&&_a(e.sublabel).includes(n))}function dr({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:h="0 10px",searchable:E=!0,minOptionsForSearch:v=6}){const[S,A]=s.useState(!1),[C,O]=s.useState(""),[N,y]=s.useState(-1),[M,k]=s.useState(!1),[_,Y]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),U=s.useRef(null),ne=E&&n.length>=v,J=n.find(B=>B.value===e)??null,R=l==="ghost",V=a==="error"?"var(--danger)":S?"var(--primary)":"var(--border)",X=ne&&C.trim()?n.filter(B=>xc(B,C)):n,de=s.useCallback(()=>{const B=K.current;if(!B)return;const F=B.getBoundingClientRect(),ue=ne?272:212,re=window.innerHeight-F.bottom,j=re<ue&&F.top>re;Y({position:"fixed",left:F.left,top:j?void 0:F.bottom+4,bottom:j?window.innerHeight-F.top+4:void 0,width:F.width,minWidth:Pa(f),zIndex:9999})},[f,ne]);s.useEffect(()=>k(!0),[]),s.useEffect(()=>{if(!S)return;function B(F){var re,j;const ue=F.target;!((re=K.current)!=null&&re.contains(ue))&&!((j=D.current)!=null&&j.contains(ue))&&(A(!1),O(""))}return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[S]),s.useEffect(()=>{S&&(y(-1),de(),ne&&setTimeout(()=>{var B;return(B=G.current)==null?void 0:B.focus()},0))},[S,ne,de]),s.useEffect(()=>{if(S)return window.addEventListener("resize",de),window.addEventListener("scroll",de,!0),()=>{window.removeEventListener("resize",de),window.removeEventListener("scroll",de,!0)}},[S,de]),s.useEffect(()=>{if(N<0||!U.current)return;const B=U.current.children[N];B==null||B.scrollIntoView({block:"nearest"})},[N]);const H=s.useCallback(B=>{r(B),A(!1),O("")},[r]),I=s.useRef(S);I.current=S;const le=s.useRef(X);le.current=X;const L=s.useRef(N);L.current=N;const oe=s.useRef(d);oe.current=d;const w=s.useRef(H);w.current=H,s.useEffect(()=>{function B(F){var x,T;const ue=document.activeElement,re=((x=K.current)==null?void 0:x.contains(ue))??!1,j=((T=D.current)==null?void 0:T.contains(ue))??!1;if(!(!re&&!j)){if(!I.current){(F.key==="Enter"||F.key===" "||F.key==="ArrowDown")&&(F.preventDefault(),A(!0));return}switch(F.key){case"ArrowDown":F.preventDefault(),y(ee=>Math.min(ee+1,le.current.length-1));break;case"ArrowUp":F.preventDefault(),y(ee=>Math.max(ee-1,oe.current?-1:0));break;case"Enter":{F.preventDefault();const ee=L.current,fe=le.current;ee===-1&&oe.current?w.current(""):fe[ee]&&!fe[ee].disabled&&w.current(fe[ee].value);break}case"Escape":F.preventDefault(),F.stopPropagation(),A(!1),O("");break}}}return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[]);const te=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{..._,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:C,onChange:B=>{O(B.target.value),y(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button",onMouseDown:B=>{B.preventDefault(),O("")},children:t.jsx(W.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:ne?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:B=>{B.preventDefault(),H("")},onMouseEnter:()=>y(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:N===-1&&!C.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),X.map((B,F)=>{const re=F===N,j=B.value===e;return t.jsxs("li",{role:"option","aria-selected":j,onMouseDown:x=>{x.preventDefault(),B.disabled||H(B.value)},onMouseEnter:()=>!B.disabled&&y(F),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:re?"var(--bg-hover)":j?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:B.disabled?"var(--text-muted)":"var(--text-main)",cursor:B.disabled?"not-allowed":"pointer",boxShadow:j?"inset 2px 0 0 var(--primary)":void 0},children:[B.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:B.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(qt,{className:"min-w-0 flex-1",children:B.label}),B.sublabel&&t.jsx(qt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:B.sublabel})]}),B.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:B.badge})]},B.value)}),X.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&&A(B=>!B),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Pa(g),padding:Pa(h),background:R?"transparent":"var(--bg-input)",color:J?"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":S,"aria-label":o,children:[(J==null?void 0:J.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:J.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:J?t.jsxs(t.Fragment,{children:[t.jsx(qt,{className:"min-w-0 flex-1",children:J.label}),i&&J.sublabel&&t.jsx(qt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:J.sublabel})]}):t.jsx(qt,{className:"min-w-0 flex-1",children:c})}),J&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:B=>{B.preventDefault(),B.stopPropagation(),H("")},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:S?"rotate(180deg)":"rotate(0deg)"}})]}),S&&M&&ht.createPortal(te,document.body)]})}const wc={sm:"h-4 w-4",md:"h-5 w-5"};function Nc(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,Nc(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${wc[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})]})]})}),is=32767;function Tn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=is?r:`${r.slice(0,is-1)}…`}const $n=[25,50,100,200,500];let At={dataTable:{pageSizeOptions:[...$n]}};function kc(){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 za(){const e=At.dataTable.preferencesEndpoint,r=kc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Sc(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 cs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Ec(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=cs(e.dataTable.preferencesEndpoint);At={...At,dataTable:{...At.dataTable,pageSizeOptions:Sc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??At.dataTable.preferencesEndpoint}}}function Cc(){return{dataTable:{pageSizeOptions:[...At.dataTable.pageSizeOptions]}}}function Qr(){return[...At.dataTable.pageSizeOptions]}function Mc(){At={dataTable:{pageSizeOptions:[...$n]}}}function Tc(e){At={...At,dataTable:{...At.dataTable,preferencesEndpoint:cs(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"}],$c=An.map(e=>({value:e.value,label:e.label})),Ac=12,Lc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ds={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Dc="bonsaif-ui:datatable:",Oc="[&_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",Hc=[],Ic=52;function Ut(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function us(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 fs(e){return`${Dc}${e}`}function Ln(e){try{const r=window.localStorage.getItem(fs(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Bc(e,r){try{window.localStorage.setItem(fs(e),JSON.stringify(r))}catch{}}function Fc(e,r){if(e===!0)return{...ds};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ds};const n={...Lc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function bs(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Wa(e,r,n){return typeof e!="number"||e<=0?n:rn(r).includes(e)?e:n}function Jr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Rr(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 en(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(ur(e))return Ic;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Pc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function ur(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function ja(e){return e.sticky===!0}function ms(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 Qt(e,r){const n=r.filter(ja).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 _c(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 Jt(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 zc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function kr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(kr).join(" ").trim():s.isValidElement(e)?kr(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?zc(n):kr(n).trim()}function tn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Sr(e,r){const n=tn(e),a=tn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function rn(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:Qr()}function Wc(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 Sr(e,a)>0;case"greaterThanOrEqual":return Sr(e,a)>=0;case"lessThan":return Sr(e,a)<0;case"lessThanOrEqual":return Sr(e,a)<=0;case"between":return Sr(e,a)>=0&&Sr(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:tn(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(tn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=tn(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ps({children:e,className:r="",style:n}){return t.jsx(Bt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function qa({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:h=!1,selected:E,onToggleOne:v,onToggleAll:S,getRowSelectable:A,highlightSelected:C=!0,rowClassName:O,getRowCategory:N,stickyHeader:y=!0,pageSize:M=25,pageSizeOptions:k,pageSizeSelectWidth:_=62,pageSizeSelectHeight:Y=30,pageSizeSelectPadding:K="0 7px",totalRows:D,page:G,onPageChange:U,onPageSizeChange:ne,storageKey:J,stickyFirstColumn:R=!1,bottomOffset:V=0,compact:X=!0,restrictHeight:de=!0,maxHeight:H,minTableWidth:I,enableColumnVisibility:le=!0,enableColumnFilters:L=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:w=Hc,onHiddenColumnKeysChange:te,columnVisibilityLabel:B="Columnas",enableBql:F=!1,bqlValue:ue,defaultBqlValue:re="",onBqlChange:j,bqlDescription:x="Filtra registros con Bonsaif Query Language",bqlPlaceholder:T=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:ee=[],bqlExamples:fe=[],bqlSuggestions:ie=[],bqlActiveFilters:pe,bqlError:ae,onQueryChange:ye,persistState:Qe,onPreferencesReady:Je,enableExport:et=!1,exportFilename:ft="datos",onExportCsv:nt,onExportPdf:Le}){var Xi;const ce=Fc(Qe,J),Pe=Object.values(ce).some(Boolean),_e=e.map(p=>p.key).join(","),at=w.join(","),Xe=s.useRef(e),Ct=s.useRef(w);Xe.current=e,Ct.current=w;const[lt,it]=s.useState(!J||!Pe),Xt=s.useRef(null),me=s.useRef(!J),ge=s.useRef(!1),Ae=s.useRef(Je);Ae.current=Je;const Fe=s.useRef(!J||!Pe?J??"__none__":null),Oe=oe!==void 0,[bt,ct]=s.useState(()=>Jt(w,e)),ze=Jt(Oe?oe:bt,e),[je,dt]=s.useState(!1),[mt,br]=s.useState("filter"),[ut,Be]=s.useState(null),[vn,fa]=s.useState(""),[pt,Mt]=s.useState({}),[Tt,ar]=s.useState({}),Wr=b!==void 0,[z,Z]=s.useState(f),be=ue!==void 0,[he,Ee]=s.useState(re),xe=be?ue:he,[He,De]=s.useState(xe),[Ye,Ke]=s.useState(!1),[or,vt]=s.useState(!1),[Yt,Ht]=s.useState(!1),[sr,Kt]=s.useState([]),jr=s.useRef(null),mr=s.useRef(null),zt=s.useRef(j);zt.current=j;const ba=s.useRef(M);ba.current=M;const ma=s.useRef(k);ma.current=k;const Gb=Array.isArray(k)?k.join(","):"",Do=s.useRef(null),hi=s.useRef(null),Oo=s.useRef(null),gi=s.useRef(0),[Zb,Qb]=s.useState({}),[Jb,Rb]=s.useState({}),[yn,pa]=s.useState(!1),Ho=s.useRef(null),ha=s.useRef(null),[em,tm]=s.useState({}),vi=s.useRef(null),ga=s.useRef(null),[Io,yi]=s.useState(r.length>0||a||c===!1),xi=(p,$)=>50+(p*17+$*13+7)%40,lr=s.useRef(null),[rm,nm]=s.useState(void 0),[wi,am]=s.useState(0),[om,sm]=s.useState(!1);s.useEffect(()=>{function p(){sm(window.innerWidth<640)}if(!de||H!==void 0)return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const Q=M!==!1?48:0,P=12;function se(){if(p(),!lr.current)return;const ve=lr.current.getBoundingClientRect().top;nm(Math.max(120,window.innerHeight-ve-Q-P-V))}return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[a,M,V,de,H]);const Ni=de?H??rm:void 0;s.useEffect(()=>{const p=lr.current;if(!p)return;const $=()=>am(p.clientWidth);if($(),typeof ResizeObserver>"u")return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$);const Q=new ResizeObserver($);return Q.observe(p),()=>Q.disconnect()},[a,lt,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){yi(!0);return}if(Io)return;const p=window.setTimeout(()=>{yi(!0)},c);return()=>window.clearTimeout(p)},[r.length,c,Io,a]);const[qr,Ur]=s.useState(()=>Qt(e.map(p=>p.key),e)),[pr,Vr]=s.useState(()=>Object.fromEntries(e.map(p=>[p.key,xt(p,Ut(p.width))]))),[Ge,hr]=s.useState(null),[lm,va]=s.useState(1),[ya,xa]=s.useState(M===!1?0:M);s.useEffect(()=>{var $e;const p=Xe.current,$=Ct.current,Q=p.map(Se=>Se.key),P=new Set(Q),se=()=>{var Se;ge.current||(ge.current=!0,(Se=Ae.current)==null||Se.call(Ae))};if(!J||!Pe){ce.layout&&Ur(Qt(Q,p)),Oe||ct(Jt($,p)),me.current=!1,it(!0),se();return}let ve=!1;const Ce=Fe.current===J;Ce||(me.current=!1,it(!1),ge.current=!1);const Te=Ln(J);if(us(Te)&&!Ce){const Se=Te,Ne=rn(ma.current??Qr()),ke=ba.current,yr=ke===!1?0:ke,cr=ce.layout?Se==null?void 0:Se.columnOrder:void 0,xr=Array.isArray(cr)?cr.filter(qe=>Q.includes(qe)):[],wr=Qt(xr.length>0?Dn(xr,Q):Q,p),Nr=Object.fromEntries(p.map(qe=>[qe.key,xt(qe,Ut(qe.width))])),Kr=ce.layout?(Se==null?void 0:Se.columnWidths)??{}:{},kn=Object.fromEntries(p.map(qe=>[qe.key,xt(qe,Kr[qe.key]??Nr[qe.key])])),Gr=Jt(ce.layout?(Se==null?void 0:Se.hiddenColumnKeys)??$:$,p);if(ce.layout&&(Ur(wr),Vr(kn)),Oe||ct(Gr),ce.filters&&(Mt(Rr(Se==null?void 0:Se.filters,P)),ar(en(Se==null?void 0:Se.conditionFilters,P))),ce.sort){const qe=Jr(Se==null?void 0:Se.sort)?Se.sort:null;hr(qe&&P.has(qe.key)?qe:null)}if(ce.bql){if(jr.current!==J){jr.current=J;const qe=typeof(Se==null?void 0:Se.bql)=="string"?Se.bql:re;be?($e=zt.current)==null||$e.call(zt,qe):Ee(qe)}Kt(Array.isArray(Se==null?void 0:Se.bqlHistory)?Se.bqlHistory.filter(qe=>typeof qe=="string"):[])}ce.pagination&&mr.current!==J&&(mr.current=J,xa(Wa(Se==null?void 0:Se.pageSize,Ne,yr))),Fe.current=J,it(!0),se()}const yt=`${za()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(J)}`,tt=new AbortController,we=window.setTimeout(()=>tt.abort(),2500);return fetch(yt,{cache:"no-store",signal:tt.signal}).then(Se=>Se.ok?Se.json():null).then(Se=>{var Yi;if(ve)return;const Ne=Ln(J),ke=bs(us(Se==null?void 0:Se.settings)?Se==null?void 0:Se.settings:null,Ne),yr=rn(ma.current??Qr()),cr=ba.current,xr=cr===!1?0:cr,wr=ce.layout?ke==null?void 0:ke.columnOrder:void 0,Nr=Array.isArray(wr)?wr.filter(rt=>Q.includes(rt)):[],Kr=Qt(Nr.length>0?Dn(Nr,Q):Q,p),kn=Object.fromEntries(p.map(rt=>[rt.key,xt(rt,Ut(rt.width))])),Gr=ce.layout?(ke==null?void 0:ke.columnWidths)??{}:{},qe=Object.fromEntries(p.map(rt=>[rt.key,xt(rt,Gr[rt.key]??kn[rt.key])])),Zr=Jt(ce.layout?(ke==null?void 0:ke.hiddenColumnKeys)??$:$,p);if(ce.layout&&(Ur(Kr),Vr(qe)),Oe||ct(Zr),ce.filters&&(Mt(Rr(ke==null?void 0:ke.filters,P)),ar(en(ke==null?void 0:ke.conditionFilters,P))),ce.sort){const rt=Jr(ke==null?void 0:ke.sort)?ke.sort:null;hr(rt&&P.has(rt.key)?rt:null)}if(ce.bql){if(jr.current!==J){jr.current=J;const rt=typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:re;be?(Yi=zt.current)==null||Yi.call(zt,rt):Ee(rt)}Kt(Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory.filter(rt=>typeof rt=="string"):[])}let Ze;ce.pagination&&(Ze=Wa(ke==null?void 0:ke.pageSize,yr,xr),mr.current!==J&&(mr.current=J,xa(Ze))),Xt.current=JSON.stringify({columnOrder:Kr,columnWidths:qe,hiddenColumnKeys:Zr,filters:Rr(ke==null?void 0:ke.filters,P),conditionFilters:en(ke==null?void 0:ke.conditionFilters,P),sort:Jr(ke==null?void 0:ke.sort)?ke.sort:null,bql:typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:"",bqlHistory:Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory:[],pageSize:ce.pagination&&cr!==!1?Ze:void 0}),me.current=!0}).catch(()=>{var Se;if(!ve){const Ne=Ln(J),ke=rn(ma.current??Qr()),yr=ba.current,cr=yr===!1?0:yr,xr=ce.layout?Ne==null?void 0:Ne.columnOrder:void 0,wr=Array.isArray(xr)?xr.filter(Ze=>Q.includes(Ze)):[],Nr=Qt(wr.length>0?Dn(wr,Q):Q,p),Kr=Object.fromEntries(p.map(Ze=>[Ze.key,xt(Ze,Ut(Ze.width))])),kn=ce.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},Gr=Object.fromEntries(p.map(Ze=>[Ze.key,xt(Ze,kn[Ze.key]??Kr[Ze.key])]));ce.layout&&(Ur(Nr),Vr(Gr));const qe=Jt(ce.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??$:$,p);if(Oe||ct(qe),ce.filters&&(Mt(Rr(Ne==null?void 0:Ne.filters,P)),ar(en(Ne==null?void 0:Ne.conditionFilters,P))),ce.sort){const Ze=Jr(Ne==null?void 0:Ne.sort)?Ne.sort:null;hr(Ze&&P.has(Ze.key)?Ze:null)}if(ce.bql){if(jr.current!==J){jr.current=J;const Ze=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:re;be?(Se=zt.current)==null||Se.call(zt,Ze):Ee(Ze)}Kt(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(Ze=>typeof Ze=="string"):[])}let Zr;ce.pagination&&(Zr=Wa(Ne==null?void 0:Ne.pageSize,ke,cr),mr.current!==J&&(mr.current=J,xa(Zr))),Xt.current=JSON.stringify({columnOrder:Nr,columnWidths:Gr,hiddenColumnKeys:qe,filters:Rr(Ne==null?void 0:Ne.filters,P),conditionFilters:en(Ne==null?void 0:Ne.conditionFilters,P),sort:Jr(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:ce.pagination&&yr!==!1?Zr:void 0}),me.current=!0}}).finally(()=>{window.clearTimeout(we),ve||(Fe.current=J,it(!0),se())}),()=>{ve=!0,tt.abort(),window.clearTimeout(we)}},[J,Pe,_e,at,Oe,ce.layout,ce.filters,ce.sort,ce.bql,ce.pagination,be,re,Gb]),s.useEffect(()=>{if(!J||!lt||!Pe||!me.current)return;const p={};ce.layout&&(p.columnOrder=qr,p.columnWidths=pr,p.hiddenColumnKeys=ze),ce.filters&&(p.filters=pt,p.conditionFilters=Tt),ce.sort&&(p.sort=Ge),ce.bql&&(p.bql=xe,p.bqlHistory=sr),ce.pagination&&M!==!1&&(p.pageSize=ya);const $=Ln(J),Q=bs($,p),P=JSON.stringify(Q);if(P===Xt.current)return;Bc(J,Q),Xt.current=P;const se=window.setTimeout(()=>{const ve=za()??"/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)},[qr,pr,ze,pt,Tt,Ge,xe,sr,ya,M,J,lt,Pe,ce.layout,ce.filters,ce.sort,ce.bql,ce.pagination]),s.useEffect(()=>{Ur(p=>{const $=e.map(Q=>Q.key);return Qt(Dn(p,$),e)})},[_e,e]);const ki=Qt(qr,e).map(p=>e.find($=>$.key===p)).filter(p=>!!p),$t=ki.filter(p=>!ze.includes(p.key)),Si=e.some(ja),im=Object.keys(pt).length,cm=Object.keys(Tt).length,Bo=im+cm;function Ei(p){const $=new Set;return r.reduce((Q,P)=>{const se=On(p,P);return!se||$.has(se)||($.add(se),Q.push({value:se,label:se})),Q},[])}function dm(){const p=e.find($=>$.key===ut);return p?Ei(p):[]}function um(p){return!!(L&&!ur(p)&&(p.filterValue||p.sortKey||Ei(p).length>0))}function Ci(p,$){Mt(Q=>{const P={...Q};return P[p]=$,P})}function fm(p,$,Q,P){const se=pt[p]??[],ve=P?se:Q.filter(Te=>Te!==$),Ce=P?se.includes($)?se.filter(Te=>Te!==$):[...se,$]:ve;Ce.length===Q.length?Fo(p):Ci(p,Ce)}function Fo(p){Mt($=>{const Q={...$};return delete Q[p],Q})}function wa(p,$){ar(Q=>{const P={...Q};return $?P[p]=$:delete P[p],P})}function Mi(p){wa(p,null)}function bm(){Mt({}),ar({})}function mm(p){be||Ee(p),j==null||j(p)}function Ti(p){const $=p.trim();De($),(j==null?void 0:j($))!==!1&&(be||Ee($),Ke(!1),vt(!1),Ht(!1),$&&Kt(P=>[$,...P.filter(se=>se!==$)].slice(0,Ac)))}function $i(){De(""),mm(""),Ke(!1),vt(!1),Ht(!1)}function Po(p,$){De(p),$&&($.style.height="auto",$.style.height=`${Math.min($.scrollHeight,180)}px`)}function Na(p){const $=p.trim();if(!$)return;gi.current=Date.now()+500;const Q=He.replace(/\s+$/u,""),P=Q.length===0?$:Q.split(`
3
+ `).map(se=>se.trim()).includes($)?Q:`${Q}
4
+ ${$}`;Po(P,Oo.current??void 0),requestAnimationFrame(()=>{const se=Oo.current;if(!se)return;se.focus();const ve=se.value.length;se.setSelectionRange(ve,ve),Po(se.value,se)})}s.useEffect(()=>{De(xe)},[xe]);const ka=s.useCallback(()=>{const p=Do.current;if(!p)return;const $=p.getBoundingClientRect(),Q=12,P=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,$.left),ve),Te=$.bottom+P,We=window.innerHeight-$.top+P,Ue=window.innerHeight-Te-Q,yt=$.top-Q-P,tt=Ue<280&&yt>Ue,we=Math.max(240,tt?yt:Ue);Qb({position:"fixed",zIndex:1e4,left:Ce,top:tt?void 0:Te,bottom:tt?We:void 0,width:se,maxWidth:"calc(100vw - 24px)",maxHeight:we,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ye)return;function p(P){var ve,Ce;if(Date.now()<gi.current)return;const se=P.target;(ve=Do.current)!=null&&ve.contains(se)||(Ce=hi.current)!=null&&Ce.contains(se)||(Ke(!1),vt(!1),Ht(!1))}function $(P){P.key==="Escape"&&(Ke(!1),vt(!1),Ht(!1))}function Q(){ka()}return ka(),document.addEventListener("mousedown",p),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ye,ka]);function Ai(p){const $=Jt(p,e);Oe||ct($),te==null||te($)}function pm(p){Ai(ze.includes(p)?ze.filter($=>$!==p):[...ze,p])}function hm(){Ai([])}const _o=s.useCallback((p=ga.current)=>{if(!p)return;const $=p.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),P=Math.max(8,window.innerWidth-Q-8),se=Math.min(Math.max(8,$.right-Q),P),ve=window.innerHeight-$.bottom,Ce=$.bottom+6,Te=window.innerHeight-$.top+6,Ue=ve<360&&$.top>ve?void 0:Ce,yt=Ue===void 0?Te:void 0,tt=Math.max(220,Ue===void 0?$.top-16:window.innerHeight-Ce-8),we={position:"fixed",zIndex:9999,left:se,top:Ue,bottom:yt,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:tt,"--dt-column-menu-max-height":`${tt}px`};Rb(we)},[]);function Li(p,$,Q=null){p.preventDefault(),p.stopPropagation();const P=ga.current===p.currentTarget&&mt===$&&ut===Q;if(je&&P){dt(!1),Be(null);return}ga.current=p.currentTarget,br($),Be(Q),fa(""),_o(p.currentTarget),dt(!0)}function gm(p){if(ur(p))return;const $=lr.current;if(!$)return;const P=Array.from($.querySelectorAll("[data-dt-column-key]")).filter(se=>se.dataset.dtColumnKey===p.key).reduce((se,ve)=>{const Ce=ve.querySelector("[data-dt-autofit-content]"),Te=Ce?Ce.scrollWidth:Math.max(ve.scrollWidth,ve.offsetWidth);return Math.max(se,Math.ceil(Te+Pc(ve)))},0);P<=0||Vr(se=>({...se,[p.key]:xt(p,P+12)}))}s.useEffect(()=>{Vr(p=>{const $=Object.fromEntries(e.map(Q=>[Q.key,xt(Q,Ut(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,xt(Q,p[Q.key]??$[Q.key])]))})},[_e,e]),s.useEffect(()=>{Oe||ct(p=>Jt(p,e))},[_e,e,Oe]),s.useEffect(()=>{function p(P){var Ce,Te;const se=P.target,ve=P.target;ve!=null&&ve.closest("[data-bonsaif-select-dropdown='true']")||!((Ce=vi.current)!=null&&Ce.contains(se))&&!((Te=ga.current)!=null&&Te.contains(se))&&(dt(!1),Be(null))}function $(P){P.key==="Escape"&&(dt(!1),Be(null))}function Q(){_o()}return je&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[je,_o]);const xn=s.useRef(null);s.useEffect(()=>{function p(Q){const P=xn.current;if(!P)return;const se=Q.clientX-P.startX,ve=e.find(Ce=>Ce.key===P.colKey);ve&&Vr(Ce=>({...Ce,[P.colKey]:xt(ve,P.startWidth+se)}))}function $(){xn.current&&(xn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",$),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",$)}},[e]);const wn=s.useRef(null),[Di,zo]=s.useState(null);function vm(p,$){const Q=e.find(P=>P.key===p);if(!Q||!ms(Q)){$.preventDefault();return}wn.current=qr.indexOf(p),$.dataTransfer.effectAllowed="move"}function ym(p,$){$.preventDefault(),$.dataTransfer.dropEffect="move";const Q=qr.indexOf(p);Di!==Q&&zo(Q)}function xm(p,$){$.preventDefault();const Q=wn.current,P=qr.indexOf(p);Q!==null&&Q!==P&&Ur(se=>{const ve=[...se],[Ce]=ve.splice(Q,1);return ve.splice(P,0,Ce),Qt(ve,e)}),wn.current=null,zo(null)}function wm(){wn.current=null,zo(null)}function Nm(p){p.sortKey&&hr($=>($==null?void 0:$.key)===p.key?{key:p.key,dir:$.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}s.useEffect(()=>{va(1)},[r]),s.useEffect(()=>{va(1)},[Tt,pt]);const Wt=!!(U&&ne),ir=M!==!1,Wo=s.useMemo(()=>rn(k??Qr()),[k]),st=Wt?G??1:lm,Oi=ir&&ya<1?typeof M=="number"&&M>0?M:Wo[0]??25:ya,jt=Wt||ir?Oi:r.length,It=!!E&&!!v&&!!S,jo=s.useMemo(()=>A?r.filter(p=>A(p)):r,[r,A]),Xr=!!u,Hi=s.useMemo(()=>new Set(Wr?Array.from(b??[]):z),[Wr,b,z]),km=(Xr?40:0)+(It?40:0),qo=!om&&(Si||R),Sa=(()=>{if(!qo)return{};let p=km;const $={};return $t.forEach((Q,P)=>{(ja(Q)||!Si&&R&&P===0)&&($[Q.key]=p,p+=pr[Q.key]??xt(Q,Ut(Q.width)))}),$})(),Uo=Object.keys(Sa),Vo=Uo.length>0?Uo[Uo.length-1]:null,Ii=It&&jo.length>0&&jo.every(p=>E.has(n(p))),Sm=It&&E.size>0&&jo.some(p=>E.has(n(p)))&&!Ii,Ea=s.useMemo(()=>{if(Wt)return r;const p=Object.entries(pt),$=Object.entries(Tt);return p.length===0&&$.length===0?r:r.filter(Q=>p.every(([P,se])=>{const ve=e.find(Ce=>Ce.key===P);return ve?se.includes(On(ve,Q)):!0})&&$.every(([P,se])=>{const ve=e.find(Te=>Te.key===P);if(!ve)return!0;const Ce=r.map(Te=>On(ve,Te));return Wc(On(ve,Q),se,Ce)}))},[Tt,pt,e,r,Wt]),gr=s.useMemo(()=>{if(!Ge)return Ea;const p=e.find($=>$.key===Ge.key&&$.sortKey);return p!=null&&p.sortKey?[...Ea].sort(($,Q)=>{const P=$[p.sortKey],se=Q[p.sortKey],ve=P===se?0:P==null?1:se==null||P<se?-1:1;return Ge.dir==="asc"?ve:-ve}):Ea},[Ea,Ge,e]),Bi=s.useMemo(()=>{if(Wt||!ir)return gr;const p=(st-1)*jt;return gr.slice(p,p+jt)},[gr,Wt,ir,st,jt]),Gt=Wt?D??r.length:gr.length,Xo=ir?Math.max(1,Math.ceil(Gt/jt)):1,Em=Math.min(...Wo),Cm=ir&&(Gt>jt||Gt>Em),Mm=ir?(st-1)*jt+1:1,Tm=ir?Math.min(st*jt,Gt):Gt;function Yo(p){if(a)return;const $=Math.max(1,Math.min(p,Xo));Wt?U($):va($)}function $m(p){a||(J&&(mr.current=J),xa(p),Wt?(ne(p),U(1)):(va(1),ne==null||ne(p)))}function Fi(p){const $=new Set(Hi);$.has(p)?$.delete(p):$.add(p);const Q=Array.from($);Wr||Z(Q),g==null||g(Q)}s.useEffect(()=>{ye==null||ye({bql:xe,filters:pt,conditionFilters:Tt,sort:Ge,page:st,pageSize:jt,hiddenColumnKeys:ze})},[xe,pt,Tt,Ge,st,jt,ze,ye]);const Pi=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",Am="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Ko="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%)",Ie="color-mix(in srgb, var(--border) 62%, var(--bg-card))",vr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ca=`inset 0 0 0 1px ${Ie}`,_i=$t.reduce((p,$)=>p+(pr[$.key]??Ut($.width)),(Xr?40:0)+(It?40:0)),zi=typeof I=="number"?I:typeof I=="string"?Number(((Xi=I.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Xi[1])??NaN):NaN,Nn=Number.isFinite(zi)?Math.max(_i,zi,wi):Math.max(_i,wi),Ma=I??Nn,Yr=`${Xr?"40px ":""}${It?"40px ":""}${$t.map(p=>`${pr[p.key]??Ut(p.width)}px`).join(" ")}`;s.useEffect(()=>{Ge&&ze.includes(Ge.key)&&hr(null)},[ze,Ge]);function Wi(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const Ta=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,background:Ko,borderBottom:`1px solid ${vr}`},children:[Xr&&t.jsx("div",{role:"columnheader",className:`${X?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Ie}`}}),It&&t.jsx("div",{role:"columnheader",className:`${X?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Ie}`}:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Ie}`},children:t.jsx(Mn,{size:"sm",checked:Ii,indeterminate:Sm,onChange:S,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),$t.map((p,$)=>{const Q=(Ge==null?void 0:Ge.key)===p.key,P=!!p.sortKey,se=ur(p),ve=Sa[p.key],Ce=ve!==void 0,Te=p.key===Vo,We=ms(p),Ue=Di===$,tt=(pr[p.key]??Ut(p.width))<120,we=Object.prototype.hasOwnProperty.call(pt,p.key)||Object.prototype.hasOwnProperty.call(Tt,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${tt?"text-left":Pi(p.align)}`,style:{...Ce?{position:"sticky",left:ve,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Te?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${vr}`:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Ie}`}:{position:"relative",borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Ie}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ue?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:se?X?"7px 6px":"9px 8px":X?"8px 6px 10px":"10px 8px 12px"},onDragOver:$e=>{(We||wn.current!==null)&&ym(p.key,$e)},onDrop:$e=>xm(p.key,$e),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${se?"justify-center":tt?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[We?t.jsx("span",{draggable:!0,onDragStart:$e=>{$e.stopPropagation(),vm(p.key,$e)},onDragEnd:$e=>{$e.stopPropagation(),wm()},onClick:$e=>$e.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${Ue?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,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(ps,{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 ${X?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),P&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:$e=>{$e.stopPropagation(),Nm(p)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${Q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Q?Ge.dir==="asc"?t.jsx(W.HiChevronUp,{className:"h-3 w-3"}):t.jsx(W.HiChevronDown,{className:"h-3 w-3"}):t.jsx(W.HiChevronUpDown,{className:"h-3 w-3"})}),L&&!se&&um(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":je&&ut===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:$e=>Li($e,"filter",p.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${je&&mt==="filter"&&ut===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":we?"text-[var(--primary)] opacity-100":""}`,children:we?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:$e=>{$e.preventDefault(),$e.stopPropagation(),xn.current={colKey:p.key,startX:$e.clientX,startWidth:pr[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:$e=>{$e.preventDefault(),$e.stopPropagation(),xn.current=null,document.body.style.cursor="",document.body.style.userSelect="",gm(p)},onClick:$e=>$e.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),$a=()=>{if(!je||typeof document>"u"||mt==="visibility"&&!le||mt==="filter"&&!L)return null;const p=e.find(we=>we.key===ut),$=dm(),Q=p?Object.prototype.hasOwnProperty.call(pt,p.key):!1,P=p?Tt[p.key]:void 0,se=An.find(we=>we.value===(P==null?void 0:P.operator)),ve=p?pt[p.key]??[]:[],Ce=vn.trim().toLowerCase(),Te=Ce?$.filter(we=>we.label.toLowerCase().includes(Ce)):$,We=p&&$.length>0&&(!Q||ve.length===$.length),Ue=p&&Q&&ve.length>0&&ve.length<$.length,yt=ze.length,tt=()=>{p&&(Fo(p.key),Mi(p.key))};return ht.createPortal(t.jsx("div",{ref:vi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Jb,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:hm,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:ki.map(we=>{const $e=!ze.includes(we.key),Ne=!(we.hideable!==!1)||$e&&$t.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":$e,disabled:Ne,onClick:()=>pm(we.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:$e?"var(--primary)":"var(--border)",background:$e?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:$e&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:we.header})]},we.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:tt,disabled:!Q&&!P,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>hr({key:p.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(W.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ge==null?void 0:Ge.key)===p.key&&Ge.dir==="asc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>hr({key:p.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(W.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ge==null?void 0:Ge.key)===p.key&&Ge.dir==="desc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(dr,{value:(P==null?void 0:P.operator)??"",onChange:we=>{if(!we){Mi(p.key);return}wa(p.key,{operator:we,value:(P==null?void 0:P.value)??"",valueTo:(P==null?void 0:P.valueTo)??""})},options:$c,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:(P==null?void 0:P.value)??"",onChange:we=>{P&&wa(p.key,{...P,value:we.target.value})},disabled:!P,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:(P==null?void 0:P.valueTo)??"",onChange:we=>{P&&wa(p.key,{...P,valueTo:we.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:we=>fa(we.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ue?"mixed":!!We,onClick:()=>{p&&(We&&!Q?Ci(p.key,[]):Fo(p.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:We||Ue?"var(--primary)":"var(--border)",background:We||Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ue&&t.jsx(W.HiMinus,{className:"h-3 w-3"}),We&&!Ue&&t.jsx(W.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Te.map(we=>{const $e=!Q||ve.includes(we.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":$e,onClick:()=>fm(p.key,we.value,$.map(Se=>Se.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:$e?"var(--primary)":"var(--border)",background:$e?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:$e&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:we.label})]},we.value)}),Te.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!yn)return;function p($){Ho.current&&!Ho.current.contains($.target)&&ha.current&&!ha.current.contains($.target)&&pa(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[yn]);function ji(p,$){if(p.filterValue){const Q=p.filterValue($);return Q==null||Q===""?"":Tn(Q)}return Tn(kr(p.cell($)))}function qi(p){return`"${Tn(p).replace(/"/g,'""')}"`}function Aa(p){return Tn(p).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ui(){return Wt&&Gt>gr.length&&Ha.toast.warning(`Exportando ${gr.length.toLocaleString("es-MX")} de ${Gt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),gr}function Lm(){const p=$t.filter(We=>!ur(We)),$=Ui(),Q=p.map(We=>qi(kr(We.header))).join(","),P=$.map(We=>p.map(Ue=>qi(ji(Ue,We))).join(",")).join(`
5
+ `),se=`${Q}
6
+ ${P}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createObjectURL(ve),Te=document.createElement("a");Te.href=Ce,Te.download=`${ft}.csv`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(Ce)}function Dm(){const p=$t.filter(Te=>!ur(Te)),$=Ui(),Q=p.map(Te=>Aa(kr(Te.header))),se=$.map(Te=>p.map(We=>Aa(ji(We,Te)))).map(Te=>`<tr>${Te.map(We=>`<td>${We}</td>`).join("")}</tr>`).join(""),ve=`<!DOCTYPE html>
7
+ <html lang="es"><head><meta charset="utf-8"><title>${Aa(ft)}</title>
8
8
  <style>
9
9
  body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
10
10
  h3{margin:0 0 4px;font-size:14px}
@@ -15,23 +15,23 @@ ${H}`,ge=new Blob(["\uFEFF"+ae],{type:"text/csv;charset=utf-8;"}),ke=URL.createO
15
15
  tr:nth-child(even) td{background:#f9f9f9}
16
16
  @media print{body{margin:0}@page{margin:1cm}}
17
17
  </style></head><body>
18
- <h3>${Ca(Ft)}</h3>
18
+ <h3>${Aa(ft)}</h3>
19
19
  <p>${$.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
- <table><thead><tr>${Q.map(Ee=>`<th>${Ee}</th>`).join("")}</tr></thead>
21
- <tbody>${ae}</tbody></table>
20
+ <table><thead><tr>${Q.map(Te=>`<th>${Te}</th>`).join("")}</tr></thead>
21
+ <tbody>${se}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,ke=window.open("","_blank");ke&&(ke.document.write(ge),ke.document.close())}const Sa=()=>!Re||!mn?null:ft.createPortal(t.jsxs("div",{ref:Eo,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Lb,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()=>(lt?await lt():im(),ca(!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()=>(mt?await mt():cm(),ca(!1)))()},children:[t.jsx(j.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Ea=()=>{const p=z&&ve.trim().length>0,$=pe!=null&&pe.length?pe:p?[{key:"bql",label:"BQL",value:ve}]:[],Q=se.filter(H=>{const ae=H.trim();return ae?!new Set(De.split(`
24
- `).map(ke=>ke.trim()).filter(Boolean)).has(ae):!1}).slice(0,8);return!le&&To===0&&!z&&!Re?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:[To>0&&t.jsxs("button",{type:"button",onClick:Ub,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"}),To," filtros"]}),z&&t.jsxs("div",{ref:Co,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Xe){Ye(!1);return}ga(),Ye(!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:Xe?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Xe||p?"var(--primary)":"var(--border)",color:Xe?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Xe,title:"Abrir filtros BQL",children:[t.jsx(j.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Xe?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:x}),$.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[$.slice(0,3).map(H=>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:[H.label,":"]}),t.jsx("span",{className:"truncate",children:H.value})]},H.key)),$.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",$.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:mi,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"})}),Xe&&ft.createPortal(t.jsxs("div",{ref:ti,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Mb,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(H=>t.jsxs("button",{type:"button",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),ha(H.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:[H.icon,H.label]},H.label)),ue.length>0&&t.jsxs("button",{type:"button",onClick:()=>pt(H=>!H),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":rr,children:[t.jsx(j.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),nr.length>0&&t.jsxs("button",{type:"button",onClick:()=>Lt(H=>!H),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":Xt,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 ${Me?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:So,value:De,rows:3,onChange:H=>Ao(H.target.value,H.target),onKeyDown:H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),bi(De)),H.key==="Escape"&&Ye(!1)},placeholder:M,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(H=>t.jsx("button",{type:"button",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),ha(H)},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:H},H))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Me?"var(--danger)":"var(--text-muted)"},children:Me??(p?`${$.length||1} filtro${($.length||1)===1?"":"s"} activo${($.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),$.map(H=>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:[H.label,":"]}),t.jsx("span",{className:"truncate",children:H.value})]},H.key))]}),Xt&&nr.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:()=>{Yt([]),Lt(!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"]})]}),nr.map(H=>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:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),ha(H)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:H})}),t.jsx("button",{type:"button",onClick:()=>Yt(ae=>ae.filter(ge=>ge!==H)),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"})})]},H))]}),rr&&ue.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:ue.map(H=>t.jsxs("button",{type:"button",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),ha(H.bql),pt(!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:H.bql}),H.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:H.description})]},H.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:mi,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:()=>bi(De),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)]})]}),Re&&t.jsx("button",{ref:da,type:"button","aria-haspopup":"menu","aria-expanded":mn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ae;const H=(ae=da.current)==null?void 0:ae.getBoundingClientRect();H&&Db({top:H.bottom+4,right:window.innerWidth-H.right}),ca(ge=>!ge)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${mn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiArrowDownTray,{className:"h-4 w-4"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":We&&dt==="visibility","aria-label":P,title:P,onClick:H=>hi(H,"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)] ${We&&dt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ai=()=>{if(!nm)return null;const p=Fc(tt,Po);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 ${X?"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:Kt===0?"0 filas":`${am}–${om} de ${Kt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(lr,{value:String(zt),onChange:$=>sm(Number($)),options:Io.map($=>({value:String($),label:String($)})),placeholder:"Filas",searchable:!1,disabled:a,height:Y,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:F}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||tt<=1,onClick:()=>_o(tt-1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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"})}),p.map(($,Q)=>$==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>_o($),onMouseEnter:H=>{H.currentTarget.disabled||$===tt||(H.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",H.currentTarget.style.color="var(--primary)")},onMouseLeave:H=>{H.currentTarget.style.background=$===tt?"var(--primary)":"transparent",H.currentTarget.style.color=$===tt?"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:$===tt?"var(--primary)":"transparent",color:$===tt?"var(--primary-fg)":"var(--text-muted)"},children:$},$)),t.jsx("button",{disabled:a||tt>=Po,onClick:()=>_o(tt+1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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"})]})},dm=()=>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:xa},children:[ka(),Sa(),Ea(),t.jsx("div",{ref:ar,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:wa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Na()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((p,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:qr,borderBottom:`1px solid ${Oe}`},children:[Dt&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),Et.map((Q,H)=>t.jsx("div",{role:"cell",className:X?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${oi($,H)}%`,minWidth:32}})},Q.key))]},$))})]})})]}),Wo="min-w-0 max-w-full overflow-hidden";return J&&Fe&&!rt?t.jsx(wn,{rows:s,columns:Math.max(4,Et.length||7)}):!a&&r.length===0&&!Mo?dm():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:xa},children:[ka(),Sa(),Ea(),t.jsx("div",{ref:ar,className:Wo,children:t.jsx(jo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:li,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:wa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Na()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((p,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:qr,borderBottom:`1px solid ${Oe}`},children:[Dt&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),Et.map((Q,H)=>{const ae=va[Q.key],ge=ae!==void 0,ke=Q.key===Fo;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:X?"px-2 py-1.5":"px-3 py-2",style:ge?{position:"sticky",left:ae,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ke?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${oi($,H)}%`,minWidth:32}})},Q.key)})]},$))})]})})}),Ai()]}):!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:xa},children:[ka(),Sa(),Ea(),t.jsx("div",{ref:ar,className:Wo,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:wa},children:t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Na()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??t.jsx(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:xa},children:[ka(),Sa(),Ea(),t.jsx("div",{ref:ar,className:Wo,children:t.jsx(jo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:li,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:gn,minWidth:wa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Na()}),t.jsx("div",{role:"rowgroup",children:wi.map((p,$)=>{const Q=n(p),H=Ei(N==null?void 0:N(p)),ae=$>0?Ei(N==null?void 0:N(wi[$-1])):null,ge=H&&H.key!==(ae==null?void 0:ae.key),ke=Dt&&C.has(Q),Ee=Dt&&(!A||A(p)),_e=jr?(m==null?void 0:m(p))??!0:!1,qe=_e&&yi.has(Q),ht=!!d||h&&_e,Qe=ke&&S?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":$%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(o.Fragment,{children:[ge&&t.jsx("div",{role:"row",className:`grid ${H.className??""}`,style:{gridTemplateColumns:qr},children:t.jsx("div",{role:"cell",className:X?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:H.label}),H.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:H.description})]})})})}),t.jsxs("div",{role:"row",onClick:ht?ye=>{const Te=ye.target;if(!(Te!=null&&Te.closest('[data-dt-disable-row-click="true"]'))){if(h&&_e){Ni(Q);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${ht?"cursor-pointer":""} ${O?O(p):""}`,style:{gridTemplateColumns:qr,"--dt-row-bg":Qe,"--dt-sticky-bg":Qe,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ye=>{ke||(ye.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ye.currentTarget.style.setProperty("--dt-sticky-bg",lm))},onMouseLeave:ye=>{ye.currentTarget.style.setProperty("--dt-row-bg",Qe),ye.currentTarget.style.setProperty("--dt-sticky-bg",Qe)},children:[jr&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:_e&&t.jsx("button",{type:"button","aria-label":qe?"Contraer fila":"Desplegar fila","aria-expanded":qe,onClick:ye=>{ye.stopPropagation(),Ni(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:qe?t.jsx(j.HiChevronDown,{className:"h-4 w-4"}):t.jsx(j.HiChevronRight,{className:"h-4 w-4"})})}),Dt&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Ho?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ye=>{ye.stopPropagation(),Ee&&v(Q)},children:t.jsx(Nn,{size:"sm",checked:ke,disabled:!Ee,"aria-label":Ee?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Ee?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ye=>ye.stopPropagation(),onChange:()=>{Ee&&v(Q)}})}),Et.map(ye=>{const Te=va[ye.key],Ne=Te!==void 0,xe=ye.key===Fo,we=ir(ye);return t.jsx("div",{role:"cell","data-dt-column-key":ye.key,"data-dt-disable-row-click":ye.disableRowClick||we?"true":void 0,className:`${we?"px-2 py-1.5 justify-center text-center":`${X?"px-2 py-1.5":"px-3 py-2"} ${ki(ye.align)}`} flex min-w-0 items-center ${Lc} ${ye.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ne?{position:"sticky",left:Te,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:xe?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:t.jsx(cs,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ye.cell(p)})})},ye.key)})]}),qe&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:qr},children:t.jsx("div",{role:"cell",className:X?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Oe}`},children:u(p)})})]},Q)})})]})})}),Ai()]})}const zc={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 Wc(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=zc[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 jc=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function qc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(e),c=o.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return o.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>s(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!jc.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 Uc({initialValue:e,options:r,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:t.jsx(lr,{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 Vc={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},_a={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Xc({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(r),d=o.useRef(null);o.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=o.useState(null);d.current=u;const[b,f]=o.useState(null),g=o.useRef(null);g.current=b;const[h,C]=o.useState({}),[v,E]=o.useState(null),A=o.useRef(null);A.current=v;const[S,O]=o.useState({}),[N,y]=o.useState({}),T=o.useRef(new Set),w=o.useRef(null);o.useEffect(()=>{var _;const D=document.activeElement;(!D||D===document.body)&&((_=w.current)==null||_.focus({preventScroll:!0}))},[]);const F=e.map(D=>{var _,le,I;return`${D.key}:${((I=(le=(_=D.editable)==null?void 0:_.select)==null?void 0:le.options)==null?void 0:I.length)??-1}`}).join("|");o.useEffect(()=>{e.forEach(D=>{var I,oe;const _=(oe=(I=D.editable)==null?void 0:I.select)==null?void 0:oe.options;if(!_)return;const le=S[D.key];(!T.current.has(D.key)||(le==null?void 0:le.length)===0&&_.length>0)&&(T.current.add(D.key),O(k=>({...k,[D.key]:_})))})},[F]);const Y=o.useCallback(async(D,_)=>{if(T.current.has(D))return;T.current.add(D);const{url:le,fetchOptions:I}=_.select??{};if(!(!le&&!I)){y(oe=>({...oe,[D]:!0}));try{let oe=[];if(I)oe=await I();else if(le){const k=await fetch(le);if(!k.ok)throw new Error("fetch failed");oe=await k.json()}O(k=>({...k,[D]:oe}))}catch{O(oe=>({...oe,[D]:[]}))}finally{y(oe=>({...oe,[D]:!1}))}}},[]),K=o.useRef(i);K.current=i;const L=o.useRef(a);L.current=a;const G=o.useRef(n);G.current=n;const q=o.useRef(e);q.current=e;const ne=o.useRef(s);ne.current=s,o.useEffect(()=>{if(e.length>0&&r.length>0){const D=e.find(_=>_.selectable!==!1);D&&f({rowId:n(r[0]),colKey:D.key})}},[]),o.useEffect(()=>{if(!b)return;const D=w.current;if(!D)return;const _=D.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!_)return;const le=D.querySelector('[role="rowgroup"]');_.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const I=D.querySelector('[role="row"]');let oe=0;I&&I.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(k=>{k.style.position==="sticky"&&k.style.left!==""&&(oe=Math.max(oe,parseFloat(k.style.left)+k.offsetWidth))}),_.style.scrollMarginLeft=`${oe}px`,_.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=o.useCallback(D=>{var oe;const _=q.current,le=new Set,I=[];(oe=w.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(k=>{const te=k.dataset.cellId.split(":")[0];le.has(te)||(le.add(te),I.push(te))}),f(k=>{if(!k)return k;const te=_.findIndex(re=>re.key===k.colKey),P=I.indexOf(k.rowId);let z=te,de=P;if(D==="up")de=Math.max(0,P-1);else if(D==="down")de=Math.min(I.length-1,P+1);else if(D==="left"){let re=te-1;for(;re>=0&&_[re].selectable===!1;)re--;re>=0&&(z=re)}else if(D==="right"){let re=te+1;for(;re<_.length&&_[re].selectable===!1;)re++;re<_.length&&(z=re)}return z===te&&de===P?k:{rowId:I[de],colKey:_[z].key}})},[]),R=o.useCallback((D=!0)=>{const _=d.current;m(null),_&&f(_),D&&setTimeout(()=>{var le;return(le=w.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),V=o.useCallback(async(D,_,le)=>{var se;const I=q.current.find(pe=>pe.key===_);if(!(I!=null&&I.editable))return;const{field:oe,type:k,mask:te,validate:P}=I.editable,z=k==="number"?le===""?null:Number(le):le;if(te){const pe=Wc(le,te);if(pe){C(Me=>({...Me,[`${D}:${_}`]:pe}));return}}if(P){const pe=P(z);if(pe){C(Me=>({...Me,[`${D}:${_}`]:pe}));return}}const de=G.current,re=K.current.find(pe=>de(pe)===D);if(!re)return;const W=re[oe];m(null),C(pe=>{const Me={...pe};return delete Me[`${D}:${_}`],Me});const x=K.current,M=x.findIndex(pe=>de(pe)===D),ee=x[Math.min(x.length-1,M+1)];if(f({rowId:de(ee),colKey:_}),setTimeout(()=>{var Me,Ie;const pe=document.activeElement;(!pe||pe===document.body||(Me=w.current)!=null&&Me.contains(pe))&&((Ie=w.current)==null||Ie.focus({preventScroll:!0}))},0),String(W??"")===String(z??""))return;const ue={...re,[oe]:z};c(pe=>pe.map(Me=>de(Me)===D?ue:Me)),E({rowId:D,colKey:_});try{await((se=L.current)==null?void 0:se.call(L,{row:re,rowId:D,field:oe,oldValue:W,newValue:z}))}catch{c(pe=>pe.map(Me=>de(Me)===D?re:Me)),C(pe=>({...pe,[`${D}:${_}`]:"Error al guardar. Intenta de nuevo."}))}finally{E(null)}},[]),X=o.useCallback(D=>{if(A.current){D.preventDefault();return}if(d.current)return;const _=g.current;if(!(!_||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(D.key)))switch(D.preventDefault(),D.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(D.shiftKey?"left":"right");break;case"Enter":{const I=q.current.find(oe=>oe.key===_.colKey);I!=null&&I.editable&&!ne.current?(m(_),I.editable.type==="select"&&!T.current.has(_.colKey)&&Y(_.colKey,I.editable)):J("down");break}}},[J,Y]),ce=o.useMemo(()=>e.map(D=>{if(!D.editable||s){const le={...D};if(delete le.editable,delete le.selectable,D.selectable===!1)return{...le,disableRowClick:!0};const I=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const k=n(oe),te=(b==null?void 0:b.rowId)===k&&(b==null?void 0:b.colKey)===D.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${k}:${D.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var P;A.current||(f({rowId:k,colKey:D.key}),(P=w.current)==null||P.focus({preventScroll:!0}))}}),te&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:_a}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:I(oe)})]})}}}const _=D.editable;return{...D,className:`relative ${D.className??""}`.trim(),disableRowClick:!0,cell:le=>{const I=n(le),oe=D.key,k=(u==null?void 0:u.rowId)===I&&(u==null?void 0:u.colKey)===oe,te=(b==null?void 0:b.rowId)===I&&(b==null?void 0:b.colKey)===oe,P=h[`${I}:${oe}`],z=(v==null?void 0:v.rowId)===I&&(v==null?void 0:v.colKey)===oe,de=le[_.field],re=String(de??""),W=()=>{var M;A.current||(f({rowId:I,colKey:oe}),m({rowId:I,colKey:oe}),(M=w.current)==null||M.focus({preventScroll:!0}),_.type==="select"&&!T.current.has(oe)&&Y(oe,_))};if(k){const M=_.type==="select"?t.jsx(Uc,{initialValue:re,options:S[oe]??[],loading:N[oe]??!1,onCommit:ee=>V(I,oe,ee),onCancel:R}):t.jsx(qc,{initialValue:re,type:_.type??"text",mask:_.mask,onCommit:ee=>V(I,oe,ee),onCancel:R});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Vc,onClick:ee=>ee.stopPropagation(),children:M})}const x=D.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${I}:${oe}`,className:`peer absolute inset-0 z-10 ${z?"cursor-wait":"cursor-pointer"}`,onClick:W}),te&&!z&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:_a}),z&&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:_a,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:P?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:P})]}):t.jsx("span",{className:"truncate",children:x})}),!z&&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,s,u,b,v,h,S,N,n,V,R,Y]);return t.jsx("div",{ref:w,tabIndex:0,onKeyDown:X,onBlur:D=>{var _;(_=w.current)!=null&&_.contains(D.relatedTarget)||setTimeout(()=>{var I,oe;const le=document.activeElement;le&&((I=le.closest)!=null&&I.call(le,"[data-bonsaif-select-dropdown]"))||(oe=w.current)!=null&&oe.contains(le)||R(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(ds,{...l,columns:ce,data:i,getRowId:n})})}function et(e){if(e)return new Date(`${e}T12:00:00`)}function Tt(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 Nr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function us(e){return e.map(r=>et(r)).filter(r=>!!r)}function Yc(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Tt));return Array.from(r).sort()}function za(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function fs(e){const r=et(e);if(!r)return e;const n=za(r).replace(/\.$/u,"").replace(/^\w/u,s=>s.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const Wa={weekend:{dayOfWeek:[0,6]}},ja={weekend:"bonsaif-weekend"};function qa({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),s=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${s?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const Kc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Gc={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Zc({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,s=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${s?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?Kc:null,...s?Gc:null,...l?{fontWeight:800}:null,...n.style}})}function Qc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:et(e),to:et(r)},f=et(a),[g,h]=o.useState(()=>et(s||e)??new Date);o.useEffect(()=>{const S=et(s||e);S&&h(S)},[s,e]);const C=o.useMemo(()=>{if(l<=1)return Nr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const S=new Date(g.getFullYear(),g.getMonth()+l-1,1),O=g.getFullYear()===S.getFullYear(),N=new Intl.DateTimeFormat("es-MX",{month:"short",...O?{}:{year:"numeric"}}).format(g),y=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(S);return`${Nr(N)} – ${Nr(y)}`},[g,l]);function v(){h(new Date(g.getFullYear(),g.getMonth()-1,1))}function E(){h(new Date(g.getFullYear(),g.getMonth()+1,1))}const A=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:C}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:E,children:t.jsx(j.HiChevronRight,{size:16})})]}),t.jsx($a.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:h,onSelect:S=>{const O=S!=null&&S.from?Tt(S.from):e,N=S!=null&&S.to?Tt(S.to):"";n({startDate:O,endDate:N})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Wa,modifiersClassNames:ja,components:{DayButton:Zc,Weekday:qa},classNames:{root:"bonsaif-range-daypicker w-full",months:A,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:S=>`${Nr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(S))} ${S.getFullYear()}`,formatWeekdayName:za}})]}),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 bs({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:s,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),s==null||s(e.date,d))}})}function ms(e,r){const n=et(e),a=et(r);if(!n||!a)return[];const s=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(s);for(;c<=l;)i.push(Tt(c)),c.setDate(c.getDate()+1);return i}function ps(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,s=new Date(e);return s.setHours(12,0,0,0),s.setDate(s.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(s);return c.setDate(s.getDate()+i),c})}function Rr(e,r,n){const a=new Set(e);for(const s of r)n==="add"?a.add(s):n==="remove"||a.has(s)?a.delete(s):a.add(s);return Array.from(a).sort()}function Jc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Rc(e,r,n){return!!(r&&e<r||n&&e>n)}function hs({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:s,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=o.useRef(null),u=o.useRef(null),m=o.useRef(!1),b=o.useRef(e);b.current=e;const f=o.useCallback(N=>{let y=N;if(c){const T=b.current.filter(F=>!F.startsWith(c)),w=N.filter(F=>F.startsWith(c));y=[...T,...w].sort()}r==null||r(Jc(y,l))},[l,r,c]),g=o.useCallback((N,y=!1)=>Rc(N,a,s)?!0:!(!(i!=null&&i(N))||y&&b.current.includes(N)),[i,s,a]),h=o.useCallback(N=>N.filter(y=>!g(y)),[g]),C=o.useCallback(()=>{u.current=null},[]);o.useEffect(()=>{const N=()=>C();return window.addEventListener("pointerup",N),window.addEventListener("pointercancel",N),()=>{window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",N)}},[C]);const v=o.useCallback((N,y,T,w)=>{const F=h(ms(N,y));f(T==="add"?Rr(w,F,"add"):Rr(w,F,"remove"))},[f,h]),E=o.useCallback((N,y)=>{if(n||y.button!==0)return;const T=Tt(N);if(g(T,!0)||y.shiftKey)return;m.current=!0;const w=[...b.current],F=w.includes(T)?"remove":"add";F==="add"&&g(T)||(u.current={active:!0,mode:F,anchor:T,latest:T,baseline:w},d.current=T,v(T,T,F,w),y.preventDefault())},[v,n,g]),A=o.useCallback(N=>{const y=u.current;if(!(y!=null&&y.active)||n)return;const T=Tt(N);y.mode==="add"&&g(T)||y.latest!==T&&(y.latest=T,v(y.anchor,T,y.mode,y.baseline))},[v,n,g]),S=o.useCallback((N,y)=>{if(n)return;const T=Tt(N);if(!g(T,!0)){if(m.current&&!y.shiftKey){m.current=!1,y.preventDefault(),y.stopPropagation();return}if(m.current=!1,y.shiftKey&&d.current){y.preventDefault(),y.stopPropagation();const w=h(ms(d.current,T));f(Rr(b.current,w,"add"));return}!b.current.includes(T)&&g(T)||(d.current=T,f(Rr(b.current,[T],"toggle")))}},[f,n,h,g]),O=o.useCallback(N=>{if(n)return;const y=h(Yc(N));if(!y.length)return;const T=y.every(w=>b.current.includes(w));f(Rr(b.current,y,T?"remove":"add")),d.current=y[0]??d.current},[f,n,h]);return{onDayPointerDown:E,onDayPointerEnter:A,onDayClick:S,toggleWeek:O,endDrag:C}}function en(e){return ps(e,1)[0]}function gs(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function ed({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:s,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:g=!1}){const h=o.useMemo(()=>us(e),[e]),C=o.useMemo(()=>new Set(e),[e]),v=et(n),E=et(a),[A,S]=o.useState(()=>et(l||e[0])??new Date),[O,N]=o.useState(()=>en(et(l||e[0])??new Date)),[y,T]=o.useState(u),w=d??y;function F(D){d===void 0&&T(D),m==null||m(D)}o.useEffect(()=>{const D=et(l);D&&(S(D),N(en(D)))},[l]);const{onDayPointerDown:Y,onDayPointerEnter:K,onDayClick:L,toggleWeek:G}=hs({value:e,onChange:r,disabled:g,minDate:n,maxDate:a,maxDates:i,isDateDisabled:s}),q=o.useMemo(()=>{if(g)return!0;const D=[];return v&&D.push({before:v}),E&&D.push({after:E}),s&&D.push(_=>s(Tt(_))),D.length>0?D:void 0},[g,s,E,v]),ne=o.useCallback(D=>t.jsx(bs,{...D,className:`bonsaif-multi-day-btn ${D.className??""}`,onDayPointerDown:Y,onDayPointerEnter:K,onDayClickSelect:L}),[L,Y,K]),J=o.useMemo(()=>ps(O,1),[O]),R=J[6],V=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(R)}`:Nr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(A));function X(){if(w==="week"){const D=gs(O,-7);N(en(D)),S(D);return}S(new Date(A.getFullYear(),A.getMonth()-1,1))}function ce(){if(w==="week"){const D=gs(O,7);N(en(D)),S(D);return}S(new Date(A.getFullYear(),A.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:()=>{F("month"),S(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:()=>{F("week"),N(en(A))},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:X,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:ce,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($a.DayPicker,{mode:"multiple",required:!1,selected:h,month:A,onMonthChange:S,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(D,_)=>{G(_)},disabled:q,className:"bonsaif-multi-daypicker",modifiers:Wa,modifiersClassNames:ja,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:ne,Weekday:qa},formatters:{formatWeekdayName:za}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(D=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(D)},`h-${Tt(D)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(D=>{const _=Tt(D),le=C.has(_),I=g||(n?_<n:!1)||(a?_>a:!1)||!!(s!=null&&s(_)),oe=_===Tt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${le?" 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":le,onPointerDown:k=>Y(D,k),onPointerEnter:()=>K(D),onClick:k=>L(D,k),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:D.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(D)})]})},_)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:g,onClick:()=>G(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(D=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:g,onClick:()=>r==null?void 0:r(e.filter(_=>_!==D)),title:`Quitar ${D}`,children:[fs(D),t.jsx("span",{"aria-hidden":!0,children:"×"})]},D))})]})}):null]})}const td=Array.from({length:12},(e,r)=>r);function rd({value:e=[],onChange:r,year:n,onYearChange:a,minDate:s,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const b=o.useMemo(()=>us(e),[e]),f=et(s),g=et(l),h=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[C,v]=o.useState(h);o.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function E(w){v(w),a==null||a(w)}const{onDayPointerDown:A,onDayPointerEnter:S,onDayClick:O}=hs({value:e,onChange:r,disabled:u||m,minDate:s,maxDate:l,maxDates:i,retainOutsidePrefix:`${C}-`}),N=o.useCallback(w=>t.jsx(bs,{...w,className:`bonsaif-year-day-btn ${w.className??""}`,onDayPointerDown:A,onDayPointerEnter:S,onDayClickSelect:O}),[O,A,S]),y=b.filter(w=>w.getFullYear()===C),T=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:()=>E(C-1),children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:C}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>E(C+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:td.map(w=>{const F=new Date(C,w,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Nr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(F))}),t.jsx($a.DayPicker,{mode:"multiple",required:!1,selected:y,month:F,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:T,className:"bonsaif-year-month-picker",modifiers:Wa,modifiersClassNames:ja,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:qa},formatters:{formatWeekdayName:Y=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(Y)}})]},`${C}-${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"," ·"," ",C]}),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(F=>F!==w)),title:`Quitar ${w}`,children:[fs(w),t.jsx("span",{"aria-hidden":!0,children:"×"})]},w))})]})}):null]})}const nd="bonsaif-ui:hide-tooltips";function vs(){window.dispatchEvent(new CustomEvent(nd))}function ad(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function od({trigger:e,items:r,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(!1),[f,g]=o.useState({}),h=o.useRef(null),C=o.useRef(null),v=o.useCallback(N=>{u(N),c==null||c(N)},[c]),E=o.useCallback(()=>{const N=h.current;if(!N)return;const y=N.getBoundingClientRect(),T=typeof a=="number"?a:y.width,w=typeof a=="number"?a:Math.max(y.width,180),F=n==="end"?Math.max(8,y.right-w):Math.min(y.left,window.innerWidth-w-8),Y=window.innerHeight-y.bottom,K=Y<240&&y.top>Y?void 0:y.bottom+6,L=K===void 0?window.innerHeight-y.top+6:void 0;g({position:"fixed",zIndex:9999,left:F,top:K,bottom:L,width:ad(typeof a=="number"?T:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!d)return;E();const N=T=>{var F,Y;const w=T.target;!((F=h.current)!=null&&F.contains(w))&&!((Y=C.current)!=null&&Y.contains(w))&&v(!1)},y=T=>{T.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",y),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",y),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[d,v,E]);const A=N=>{s||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),v(!d))},S=o.isValidElement(e)?o.cloneElement(e,{onClick:()=>{s||(vs(),v(!d))}}):e,O=d?t.jsx("div",{ref:C,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 y;N.disabled||(vs(),(y=N.onSelect)==null||y.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:h,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:A,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[S,m&&O?ft.createPortal(O,document.body):null]})}const sd=180,ys="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function ld({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:h="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:C="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:E,disabled:A=!1,disabledMessage:S,children:O}){const[N,y]=o.useState(!1),[T,w]=o.useState(!1),[F,Y]=o.useState(!1),K=o.useCallback(()=>{w(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>Y(!0))})},[]),L=o.useCallback(()=>{Y(!1),window.setTimeout(()=>w(!1),sd)},[]),G=A||c,q=o.useCallback(()=>{if(!G){if(f){K();return}r()}},[G,f,r,K]),ne=o.useCallback(()=>{Y(!1),w(!1),E==null||E(),r()},[r,E]);if(o.useEffect(()=>{y(!0)},[]),o.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(Y(!1),w(!1)),()=>{document.body.style.overflow=""}),[e]),o.useEffect(()=>{if(!e)return;const R=V=>{if(V.key==="Escape"&&!G){if(T){L();return}q()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[L,G,T,e,q]),!N)return null;const J=S!==void 0?S:c?"Guardando…":null;return ft.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 ${ys}`,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(Ue,{variant:"icon",onClick:q,title:"Cerrar",disabled:G,children:t.jsx(j.HiXMark,{className:"w-5 h-5"})}),s&&t.jsx("div",{className:"flex-shrink-0",children:s}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ue,{variant:"secondary",size:"sm",onClick:q,disabled:G,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ue,{variant:"primary",size:"sm",icon:t.jsx(Ii.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: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})]}),T&&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 ${ys} transition-opacity duration-200 ease-out ${F?"opacity-100":"opacity-0"}`,onClick:L}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${F?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ue,{variant:"icon",onClick:L,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":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:h}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ue,{variant:"secondary",onClick:L,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Ue,{variant:"secondary",onClick:ne,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:C})]})]})]})]}),document.body)}const id=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,cd=/^\+?[0-9\s().-]+$/,dd=7,ud=15;function It(e){return e==null||String(e).trim()===""}function xs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function Ua(e){return It(e)?!1:id.test(String(e))}function Va(e){if(It(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return cd.test(r)&&n.length>=dd&&n.length<=ud}function fd(e="Este campo es requerido."){return r=>It(r)?e:void 0}function bd(e="Ingresa un correo valido."){return r=>It(r)||Ua(r)?void 0:e}function md(e="Ingresa un telefono valido."){return r=>It(r)||Va(r)?void 0:e}function pd(e,r){return n=>It(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function hd(e,r){return n=>It(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function gd(e,r){return n=>{if(It(n))return;const a=xs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function vd(e,r){return n=>{if(It(n))return;const a=xs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function yd(e,r="El formato no es valido."){return n=>It(n)||e.test(String(n))?void 0:r}function xd(e,r){const n={};for(const a of Object.keys(r)){const s=r[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var ws={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ns=o.createContext&&o.createContext(ws),wd=["attr","size","title"];function Nd(e,r){if(e==null)return{};var n,a,s=kd(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function kd(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 Ln(){return Ln=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},Ln.apply(null,arguments)}function ks(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,a)}return n}function Dn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ks(Object(n),!0).forEach(function(a){Cd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ks(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Cd(e,r,n){return(r=Sd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Sd(e){var r=Ed(e,"string");return typeof r=="symbol"?r:r+""}function Ed(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 Cs(e){return e&&e.map((r,n)=>o.createElement(r.tag,Dn({key:n},r.attr),Cs(r.child)))}function Xa(e){return r=>o.createElement(Md,Ln({attr:Dn({},e.attr)},r),Cs(e.child))}function Md(e){var r=n=>{var{attr:a,size:s,title:l}=e,i=Nd(e,wd),c=s||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),o.createElement("svg",Ln({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Dn(Dn({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),e.children)};return Ns!==void 0?o.createElement(Ns.Consumer,null,n=>r(n)):r(ws)}function Ss(e){return Xa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(e)}function Td(e){return Xa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(e)}function $d(e){return Xa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(e)}function kr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Wt,{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 Cr({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 In({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 Ya({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:b="",required:f,...g}){const[h,C]=o.useState(()=>!!g.autoFocus),[v,E]=o.useState(!1),A=g.type==="password"&&u,S=A&&v?"text":g.type,O=!!s,N=O&&l!=="tooltip",y=O&&l!=="inline",T=!!n&&a==="tooltip"&&!N,w=m?f:void 0,F=O?"border-[var(--danger)] focus:border-[var(--danger)]":"",Y=y?A?"pr-20":"pr-10":A?"pr-10":"",K=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,L=h||K,G={top:L?7:12,color:h?"var(--primary)":"var(--text-muted)",fontSize:L?10:13,fontWeight:L?600:400,textTransform:L?"uppercase":"none"},q=X=>{var ce;C(!0),(ce=g.onFocus)==null||ce.call(g,X)},ne=X=>{var ce;C(!1),(ce=g.onBlur)==null||ce.call(g,X)},J=A?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:()=>E(X=>!X),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(Td,{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($d,{className:"h-[18px] w-[18px]"})})]}):null,R=y?t.jsx(Wt,{as:"span",content:s,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${A?"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(Ss,{className:"h-[18px] w-[18px]"})})}):null,V=t.jsx(Cr,{error:N?s:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(In,{...g,type:S,required:w,placeholder:" ","aria-invalid":O||g["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${Y} ${F} ${b}`,onFocus:q,onBlur:ne}),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:L?7:12},children:c}),R,J]}),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:"*"}),T?t.jsx(kr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),A?t.jsxs("span",{className:"relative block",children:[t.jsx(In,{...g,type:S,required:w,"aria-invalid":O||g["aria-invalid"],className:`w-full ${Y} ${F} ${b}`,onFocus:q,onBlur:ne}),R,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(In,{...g,required:w,"aria-invalid":O||g["aria-invalid"],className:`w-full ${Y} ${F} ${b}`}),R]}),V]})}function Es(e){return e==null?"":String(e)}function Ad({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=o.useState(()=>Es(c)),f=i!==void 0?Es(i):m,g=n&&f.length>0&&!Ua(f)?a:void 0,h=C=>{i===void 0&&b(C.currentTarget.value),d==null||d(C)};return t.jsx(Ya,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:s,onChange:h})}const Ld={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Dd({title:e="Sin resultados",description:r,icon:n=t.jsx(j.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:s,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Ld[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||s)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Id={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Od(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 Ms(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),s=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function Hd(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Bd({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:b=!1,showFileList:f=!0,clearable:g=!0,browseLabel:h="Buscar archivos",dropLabel:C="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:E="o haz click para buscarlos en tu equipo",selectedLabel:A="Archivos seleccionados",size:S="md",containerClassName:O="",dropzoneClassName:N="",fileListClassName:y="",className:T="",id:w,accept:F,disabled:Y,required:K,...L}){const G=o.useId(),q=w??G,ne=o.useRef(null),[J,R]=o.useState(!1),[V,X]=o.useState(i),ce=l??V,D=!!a,_=!!r&&n==="tooltip"&&!D,le=g&&ce.length>0&&!Y,I=(M,ee)=>{l===void 0&&X(M),c==null||c(M,ee)},oe=(M,ee)=>{const ue=M.filter(Ie=>Ms(Ie,F)),se=M.filter(Ie=>!Ms(Ie,F)),pe=b?[...ce,...ue]:ue,Me=Hd(pe,u,m);se.length>0&&(d==null||d(se)),I(Me,ee)},k=()=>{var M;Y||(M=ne.current)==null||M.click()},te=M=>{oe(Array.from(M.target.files??[]),M),M.target.value=""},P=M=>{M.preventDefault(),Y||R(!0)},z=M=>{M.currentTarget.contains(M.relatedTarget)||R(!1)},de=M=>{M.preventDefault(),R(!1),!Y&&oe(Array.from(M.dataTransfer.files),M)},re=M=>{M.key!=="Enter"&&M.key!==" "||(M.preventDefault(),k())},W=M=>{I(ce.filter((ee,ue)=>ue!==M))},x=()=>{I([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${O}`,children:[(e||s||_)&&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:"*"}),_?t.jsx(kr,{content:r}):null,s&&t.jsx("span",{className:"ml-auto normal-case",children:s})]}),t.jsx("input",{...L,ref:ne,id:q,type:"file",accept:F,multiple:u,disabled:Y,required:K&&ce.length===0,"aria-invalid":D||L["aria-invalid"],className:"sr-only",onChange:te}),t.jsxs("div",{role:"button",tabIndex:Y?-1:0,"aria-controls":q,"aria-disabled":Y||void 0,"aria-invalid":D||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)] ${Id[S]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":D?"border-[var(--danger)]":"border-[var(--border)]"} ${Y?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${N} ${T}`,onClick:k,onDragOver:P,onDragLeave:z,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:J?C:v}),E&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:E})]}),h&&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:h})]}),f&&ce.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${y}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:A}),le&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:x,children:t.jsx(j.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ce.map((M,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:M.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Od(M.size)})]}),!Y&&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 ${M.name}`,onClick:()=>W(ee),children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]},`${M.name}-${M.lastModified}-${ee}`))})]}),t.jsx(Cr,{error:a,helperText:r,helperDisplay:n})]})}const Fd=[{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 Pd({fields:e,title:r="Layout",fieldTypes:n=Fd,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=o.useState(()=>e.map(S=>({key:!1,type:"",...S}))),[f,g]=o.useState(""),[h,C]=o.useState(""),v=o.useCallback((S,O)=>{b(N=>{const y=N.map((T,w)=>w===S?{...T,...O}:T);return u==null||u(y),y})},[u]),E=o.useCallback(()=>{d==null||d(m)},[m,d]),A=o.useCallback(()=>{var y;const S=f.trim();if(!S){C("Ingresa un nombre de campo.");return}if(m.some(T=>T.name.toLowerCase()===S.toLowerCase())){C("Ese campo ya existe en el arreglo.");return}const N={name:S,key:!1,type:((y=n[0])==null?void 0:y.value)??""};b(T=>{const w=[...T,N];return u==null||u(w),w}),g(""),C("")},[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((S,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:S.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Nn,{size:"sm",checked:S.key??!1,onChange:N=>v(O,{key:N.target.checked}),"aria-label":`${S.name} es clave`})}),t.jsx(lr,{value:S.type??"",onChange:N=>v(O,{type:N}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${S.name}`})]},S.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[s&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:f,onChange:S=>{g(S.currentTarget.value),h&&C("")},onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),A())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ue,{variant:"secondary",onClick:A,height:36,padding:"0 12px",children:i})]}),h&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:h})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ue,{variant:"primary",onClick:E,disabled:c,loading:c,children:a})})]})})]})}function On({label:e,children:r,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!s;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(kr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Cr,{error:s,helperText:n,helperDisplay:a})]})}function _d(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Ts(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,s=_d(a),l=s.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(s.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const $t=260,Sr=420,Ka=380,Ot="cubic-bezier(0.22, 1, 0.36, 1)",zd="cubic-bezier(0.16, 1, 0.3, 1)",Ga="cubic-bezier(0.22, 1, 0.36, 1)",Wd="cubic-bezier(0.22, 1, 0.36, 1)",jd=8,qd=1,Ud=1.25,Za={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)"},Vd="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",Qa=10;function tn(e,r,n){return Math.min(n,Math.max(r,e))}function Xd(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function $s(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),s=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:s,scale:Number.isFinite(n)?n:1}}function Er({label:e,onClick:r,children:n,disabled:a,size:s="md"}){const l=s==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Za,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=Vd,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Za.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 As({open:e,onClose:r,slides:n,index:a,onIndexChange:s,originRect:l=null,maxZoom:i=jd,minZoom:c=qd,zoomStep:d=Ud,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:h=!0,zIndex:C=1100,ariaLabel:v="Visor de imagen"}){const[E,A]=o.useState(!1),[S,O]=o.useState(!1),[N,y]=o.useState(a??0),[T,w]=o.useState(1),[F,Y]=o.useState({x:0,y:0}),[K,L]=o.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[G,q]=o.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ne,J]=o.useState(!1),R=o.useRef(null),V=o.useRef(null),X=o.useRef(null),ce=o.useRef(null),D=o.useRef(null),_=o.useRef(!1),le=o.useRef(!1),I=o.useRef(null),oe=o.useRef(null),k=o.useRef(null),te=o.useRef(null),P=o.useRef(null),z=o.useRef(a??0),de=a??N,re=n.length===0?0:tn(de,0,Math.max(0,n.length-1)),W=n[re],x=n.length>1,M=Math.max(c,i),ee=h&&x,ue=o.useCallback(be=>{if(n.length===0)return;const he=n.length-1,$e=g?(be%n.length+n.length)%n.length:tn(be,0,he);a===void 0&&y($e),s==null||s($e)},[a,g,s,n.length]),se=o.useCallback(()=>{w(1),Y({x:0,y:0})},[]),pe=o.useCallback((be,he)=>{if(he<=c+.001)return{x:0,y:0};const $e=te.current,Be=P.current;if(!$e||!Be)return be;const Le=$e.getBoundingClientRect(),ct=Be.offsetWidth*he,at=Be.offsetHeight*he,Pe=Math.max(0,(ct-Le.width)/2+Le.width*.15),We=Math.max(0,(at-Le.height)/2+Le.height*.15);return{x:tn(be.x,-Pe,Pe),y:tn(be.y,-We,We)}},[c]),Me=o.useCallback(()=>{A(!1),q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ce.current=null,D.current=null,_.current=!1,le.current=!1,I.current&&(clearTimeout(I.current),I.current=null)},[]),Ie=o.useCallback(()=>{if(_.current)return;_.current=!0,O(!1),se();const be=ce.current,he=be!=null&&D.current!=null&&D.current===re;if(be&&he){X.current!=null&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{X.current=requestAnimationFrame(()=>{const $e=P.current;if(!$e){X.current=null,R.current&&clearTimeout(R.current),R.current=setTimeout(Me,$t+40);return}const Be=$e.getBoundingClientRect(),Le=$s(be,Be);q({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),X.current=requestAnimationFrame(()=>{q({enabled:!0,dx:Le.dx,dy:Le.dy,scale:Le.scale,animate:!0}),X.current=null})})}),R.current&&clearTimeout(R.current),R.current=setTimeout(Me,Sr+80);return}q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),R.current&&clearTimeout(R.current),R.current=setTimeout(Me,$t+40)},[Me,se,re]);o.useEffect(()=>(e?(R.current&&clearTimeout(R.current),I.current&&(clearTimeout(I.current),I.current=null),_.current=!1,le.current=!1,ce.current=Xd(l),D.current=ce.current!=null?a??N:null,A(!0),O(!1),ce.current?q({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(D.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{O(!0),q({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):E&&Ie(),()=>{R.current&&clearTimeout(R.current),X.current!=null&&cancelAnimationFrame(X.current)}),[e]);const At=o.useCallback(()=>{if(!e||_.current||le.current)return;const be=ce.current,he=P.current;if(!be||!he){be||(O(!0),le.current=!0);return}const $e=he.getBoundingClientRect();if($e.width<2||$e.height<2)return;le.current=!0;const Be=$s(be,$e);q({enabled:!0,dx:Be.dx,dy:Be.dy,scale:Be.scale,animate:!1}),X.current!=null&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{X.current=requestAnimationFrame(()=>{q({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),O(!0),X.current=null,I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),I.current=null},Sr+20)})})},[e]);o.useLayoutEffect(()=>{!E||!e||!ce.current||le.current||At()},[E,e,At]),o.useEffect(()=>{!e||_.current||D.current!=null&&D.current!==re&&q(be=>be.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:be)},[e,re]),o.useEffect(()=>{if(!e)return;const be=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=be}},[e]),o.useEffect(()=>{e&&se()},[e,re,se]),o.useEffect(()=>{a!==void 0&&y(a)},[a]),o.useEffect(()=>{if(!e){z.current=re,L({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const be=z.current;if(be===re)return;z.current=re;const he=n.length;let $e=1;if(he>1){const Be=(be+1)%he===re,Le=(be-1+he)%he===re;Le&&!Be?$e=-1:Be&&!Le?$e=1:$e=re>be?1:-1}return V.current!=null&&(cancelAnimationFrame(V.current),V.current=null),L({opacity:0,x:$e*56,scale:.94,blur:8,animate:!1}),V.current=requestAnimationFrame(()=>{V.current=requestAnimationFrame(()=>{L({opacity:1,x:0,scale:1,blur:0,animate:!0}),V.current=null})}),()=>{V.current!=null&&(cancelAnimationFrame(V.current),V.current=null)}},[e,re,n.length]);const Bt=T<=c+.001&&Math.abs(F.x)<.5&&Math.abs(F.y)<.5,Re=o.useCallback((be,he,$e)=>{w(Be=>{const Le=tn(be,c,M);if(Math.abs(Le-Be)<1e-4)return Be;const ct=Le/Be,at=Le<Be;return Le<=c+.001?(Y({x:0,y:0}),c):(Y(Pe=>{let We=Pe;if(typeof he=="number"&&typeof $e=="number"&&te.current&&!at){const ot=te.current.getBoundingClientRect(),dt=he-ot.left-ot.width/2,dr=$e-ot.top-ot.height/2;We={x:dt-(dt-Pe.x)*ct,y:dr-(dr-Pe.y)*ct}}else if(at){We={x:Pe.x*ct,y:Pe.y*ct};const ot=Math.min(1,(Be-Le)/Math.max(.01,Be-c));We={x:We.x*(1-ot*.65),y:We.y*(1-ot*.65)}}else We={x:Pe.x*ct,y:Pe.y*ct};return pe(We,Le)}),Le)})},[pe,c,M]),Ft=o.useCallback(()=>{Re(T*d)},[Re,T,d]),lt=o.useCallback(()=>{const be=Math.max(c,T/d);if(be<=c+.001){se();return}w(be),Y({x:0,y:0})},[c,se,T,d]);o.useEffect(()=>{if(!e)return;const be=he=>{if(he.key==="Escape"&&m){he.preventDefault(),r();return}he.key==="ArrowLeft"&&x?(he.preventDefault(),ue(re-1)):he.key==="ArrowRight"&&x?(he.preventDefault(),ue(re+1)):he.key==="+"||he.key==="="?(he.preventDefault(),Re(T*d)):he.key==="-"||he.key==="_"?(he.preventDefault(),lt()):he.key==="0"&&(he.preventDefault(),se())};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[Re,m,x,r,e,se,re,T,ue,lt,d]);const mt=be=>{be.preventDefault();const he=be.deltaY>0?1/d:d;Re(T*he,be.clientX,be.clientY)},ie=be=>{T<=c+.001||(be.currentTarget.setPointerCapture(be.pointerId),J(!0),oe.current={pointerId:be.pointerId,startX:be.clientX,startY:be.clientY,originX:F.x,originY:F.y})},Fe=be=>{const he=oe.current;!he||he.pointerId!==be.pointerId||Y(pe({x:he.originX+(be.clientX-he.startX),y:he.originY+(be.clientY-he.startY)},T))},ze=be=>{var he;((he=oe.current)==null?void 0:he.pointerId)===be.pointerId&&(oe.current=null,J(!1))},it=be=>{if(be.stopPropagation(),T>c+.05){se();return}Re(Math.min(M,3),be.clientX,be.clientY)},Ve=be=>{if(be.touches.length!==2)return;J(!0);const[he,$e]=[be.touches[0],be.touches[1]],Be=Math.hypot(he.clientX-$e.clientX,he.clientY-$e.clientY);k.current={distance:Be,scale:T}},kt=be=>{if(be.touches.length!==2||!k.current)return;be.preventDefault();const[he,$e]=[be.touches[0],be.touches[1]],Be=Math.hypot(he.clientX-$e.clientX,he.clientY-$e.clientY),Le=(he.clientX+$e.clientX)/2,ct=(he.clientY+$e.clientY)/2,at=k.current.scale*(Be/Math.max(1,k.current.distance));Re(at,Le,ct)},rt=()=>{k.current=null,J(!1)};if(!E||!W)return null;const nt=G.enabled,Vt=G.animate?`transform ${Sr}ms ${Wd}`:"none";return ft.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:C},role:"dialog","aria-modal":"true","aria-label":v,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:S?1:0,transition:`opacity ${nt?Sr:$t}ms ${Ot}`,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:nt||S?1:0,transform:nt||S?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:nt?"none":`opacity ${$t}ms ${Ot}, transform ${$t}ms ${Ot}`},onClick:be=>{be.target===be.currentTarget&&u&&r()},onWheel:mt,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?Vt: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 ${Ka}ms ${Ga}`,`transform ${Ka}ms ${Ga}`,`filter ${Ka}ms ${Ga}`].join(", "):"none"},children:t.jsx("div",{ref:P,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:T>c+.001?"grab":"zoom-in",transform:`translate3d(${F.x}px, ${F.y}px, 0) scale(${T})`,transformOrigin:"center center",transition:ne?"none":`transform 220ms ${zd}`},onClick:be=>be.stopPropagation(),onDoubleClick:it,onPointerDown:ie,onPointerMove:Fe,onPointerUp:ze,onPointerCancel:ze,onTouchStart:Ve,onTouchMove:kt,onTouchEnd:rt,children:t.jsx("img",{src:W.src,alt:W.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:Qa,imageRendering:T>2.5?"pixelated":"auto"},onLoad:()=>{At()}},W.src+String(re))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:S?1:0,transform:S?"translateY(0)":"translateY(-6px)",transition:`opacity ${nt?Sr:$t}ms ${Ot}, transform ${nt?Sr:$t}ms ${Ot}`},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:Za,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(Er,{label:"Alejar",onClick:lt,disabled:T<=c+.001,children:t.jsx(j.HiMinus,{className:"h-5 w-5"})}),t.jsx(Er,{label:"Restablecer tamaño",onClick:se,disabled:Bt,children:t.jsx(j.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Er,{label:"Acercar",onClick:Ft,disabled:T>=M-.001,children:t.jsx(j.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Er,{label:"Cerrar",onClick:r,children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]})]}),x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:S?1:0,transform:S?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${$t}ms ${Ot}, transform ${$t}ms ${Ot}`},children:t.jsx(Er,{label:"Anterior",size:"lg",onClick:()=>ue(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:S?1:0,transform:S?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${$t}ms ${Ot}, transform ${$t}ms ${Ot}`},children:t.jsx(Er,{label:"Siguiente",size:"lg",onClick:()=>ue(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,he)=>{const $e=he===re;return t.jsx("button",{type:"button",role:"tab","aria-selected":$e,"aria-label":be.alt||`Imagen ${he+1}`,onClick:Be=>{Be.stopPropagation(),ue(he)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:Qa,opacity:$e?1:.42,transition:`opacity 180ms ${Ot}`},children:t.jsx("img",{src:be.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:Qa}})},`${be.src}-${he}`)})})}):null]})]}),document.body)}function Yd({children:e,className:r,style:n,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(0),[f,g]=o.useState([]),[h,C]=o.useState(null),v=o.useCallback((A,S,O)=>{g(A),C(O??null),b(S),u(!0)},[]),E=o.useCallback(A=>{Ts(A,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:E,children:e}),t.jsx(As,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:h,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c})]})}function Ls(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ds(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Ja(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Kd(e,r){if(!r)return!0;const n=Ja(r);return Ja(e.label).includes(n)||!!(e.sublabel&&Ja(e.sublabel).includes(n))}function Gd({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:g=!0,emptyText:h="Sin resultados",clearLabel:C="Limpiar seleccion",pruneMissingValues:v=!0}){const[E,A]=o.useState(!1),[S,O]=o.useState(""),[N,y]=o.useState(0),[T,w]=o.useState(!1),[F,Y]=o.useState({}),K=o.useRef(null),L=o.useRef(null),G=o.useRef(null),q=o.useRef(null),ne=u&&n.length>=m,J=o.useMemo(()=>new Set(e),[e]),R=o.useMemo(()=>{const x=new Map;for(const M of n)x.set(M.value,M);return x},[n]),V=o.useMemo(()=>{const x=[];for(const M of e){const ee=R.get(M);ee&&x.push(ee)}return x},[R,e]),X=b==="all"?V.length:b,ce=V.slice(0,X),D=Math.max(0,V.length-ce.length),_=g&&V.length>1,le=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(x=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[x.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:x.label}),x.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:x.sublabel}):null]},x.value))})]}),I=o.useMemo(()=>{const x=S.trim();return!ne||!x?n:n.filter(M=>Kd(M,x))},[n,S,ne]),oe=o.useCallback(()=>{const x=K.current;if(!x)return;const M=x.getBoundingClientRect(),ee=ne?304:244,ue=window.innerHeight-M.bottom,se=ue<ee&&M.top>ue;Y({position:"fixed",left:M.left,top:se?void 0:M.bottom+4,bottom:se?window.innerHeight-M.top+4:void 0,width:Math.max(M.width,240),zIndex:9999})},[ne]),k=o.useCallback(x=>{Ds(e,x)||r(x)},[r,e]),te=o.useCallback(x=>{const M=R.get(x);if(M!=null&&M.disabled)return;const ee=J.has(x)?e.filter(ue=>ue!==x):[...e,x];k(ee)},[k,R,e,J]),P=o.useCallback(()=>k([]),[k]),z=o.useCallback(()=>{A(!1),O(""),y(0)},[]);o.useEffect(()=>w(!0),[]);const de=o.useMemo(()=>n.map(x=>x.value).join("\0"),[n]);o.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const x=new Set(n.map(ee=>ee.value)),M=e.filter(ee=>x.has(ee));Ds(e,M)||r(M)},[de]),o.useEffect(()=>{if(!E)return;function x(M){var ue,se;const ee=M.target;!((ue=K.current)!=null&&ue.contains(ee))&&!((se=L.current)!=null&&se.contains(ee))&&z()}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[z,E]),o.useEffect(()=>{E&&(y(0),oe(),ne&&setTimeout(()=>{var x;return(x=G.current)==null?void 0:x.focus()},0))},[E,ne,oe]),o.useEffect(()=>{if(E)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[E,oe]),o.useEffect(()=>{if(I.length===0){y(0);return}y(x=>Math.min(x,I.length-1))},[I.length]),o.useEffect(()=>{if(N<0||!q.current)return;const x=q.current.children[N];x==null||x.scrollIntoView({block:"nearest"})},[N]);function re(x){if(!s){if(!E){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),A(!0));return}if(x.key==="Escape"){x.preventDefault(),z();return}if(x.key==="ArrowDown"){if(x.preventDefault(),I.length===0)return;y(M=>Math.min(M+1,I.length-1));return}if(x.key==="ArrowUp"){x.preventDefault(),y(M=>Math.max(M-1,0));return}if(x.key==="Enter"&&I[N]&&!I[N].disabled){x.preventDefault(),te(I[N].value);return}x.key==="Backspace"&&!S&&e.length&&(x.preventDefault(),k(e.slice(0,-1)))}}const W=t.jsxs("div",{ref:L,className:"overflow-hidden rounded-xl shadow-xl",style:{...F,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:S,onChange:x=>{O(x.target.value),y(0)},onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter"||x.key==="Escape")&&(x.stopPropagation(),re(x))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),S&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:x=>{x.preventDefault(),O(""),y(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:x=>{x.preventDefault(),P()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:C})]}),t.jsxs("ul",{ref:q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ne?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[I.map((x,M)=>{const ee=M===N,ue=J.has(x.value);return t.jsxs("li",{role:"option","aria-selected":ue,onMouseDown:se=>{se.preventDefault(),!x.disabled&&te(x.value)},onMouseEnter:()=>!x.disabled&&y(M),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:ee?"var(--bg-hover)":ue?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:x.disabled?"var(--text-muted)":"var(--text-main)",cursor:x.disabled?"not-allowed":"pointer",opacity:x.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ue?"var(--primary)":"var(--border)",background:ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ue&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),x.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(jt,{className:"min-w-0 flex-1",children:x.label}),x.sublabel&&t.jsx(jt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:x.sublabel})]}),x.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:x.badge})]},x.value)}),I.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:h})]})]});return t.jsxs("div",{ref:K,className:`relative ${l||"w-full"}`,style:i,onKeyDown:re,children:[t.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(E?z():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Ls(c),padding:Ls(d),background:"var(--bg-input)",color:V.length?"var(--text-main)":"var(--text-muted)",border:E?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":E,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ce.length?(()=>{const x=t.jsxs(t.Fragment,{children:[ce.map(M=>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:[M.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:M.color}}),f?t.jsx(jt,{className:"min-w-0 flex-1",children:M.label}):t.jsx("span",{className:"break-words",children:M.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${M.label}`,onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation(),te(M.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"})})]},M.value)),D>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":`${D} seleccionados más`,children:["+",D]})]});return _?t.jsx(Wt,{as:"span",content:le,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:x}):x})():t.jsx("span",{className:"truncate",children:a})}),V.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":C,onMouseDown:x=>{x.preventDefault(),x.stopPropagation(),P()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(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:E?"rotate(180deg)":"rotate(0deg)"}})]}),E&&T&&ft.createPortal(W,document.body)]})}function Zd({inputMode:e="decimal",...r}){return t.jsx(Ya,{...r,type:"number",inputMode:e})}function Qd(e,r,n){const a=[],s=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function Jd({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=Qd(c,i,s);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(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(Ue,{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 Is=[{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 Os(e){return e==null?"":String(e)}function Hn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Rd(e){return typeof e=="number"?`${e}px`:e}function eu({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:g,countryCodePlaceholder:h="Codigo",countryCodeClassName:C="",countryCodeWidth:v=84,onPhoneValueChange:E,label:A,containerClassName:S="",helperText:O,helperDisplay:N="inline",labelAction:y,className:T="",required:w,disabled:F,floatingLabel:Y,showPasswordToggle:K,nativeValidation:L,errorTooltipLabel:G="Error de validacion",...q}){var M;const[ne,J]=o.useState(()=>Os(c)),[R,V]=o.useState(()=>Hn(m)),X=o.useMemo(()=>{const ee=g??Is,ue=f==null?void 0:f.map(Hn);return ue!=null&&ue.length?ee.filter(se=>ue.includes(se.value)):ee},[f,g]),ce=((M=X[0])==null?void 0:M.value)??"+1",D=X.some(ee=>ee.value===Hn(u??R))?Hn(u??R):ce,_=i!==void 0?Os(i):ne,le=`${D} ${_}`.trim(),I=n&&_.length>0&&!Va(le)?a:void 0,oe=l??I,k=!!oe,te=k&&s!=="tooltip",P=k&&s!=="inline",z=!!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 ue=ee.currentTarget.value;i===void 0&&J(ue),E==null||E(ue,{countryCode:D,nationalNumber:ue,fullNumber:`${D} ${ue}`.trim()}),d==null||d(ee)},W=ee=>{u===void 0&&V(ee),b==null||b(ee),E==null||E(_,{countryCode:ee,nationalNumber:_,fullNumber:`${ee} ${_}`.trim()})},x=P?t.jsx(Wt,{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(Ss,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${S}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:A}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),z?t.jsx(kr,{content:O}):null,y&&t.jsx("span",{className:"ml-auto normal-case",children:y})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${de}`,children:[t.jsx(lr,{value:D,onChange:W,options:X,placeholder:h,disabled:F,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${C}`,style:{width:Rd(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:F,required:void 0,"aria-label":q["aria-label"]??(typeof A=="string"?A:void 0),"aria-invalid":k||q["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${P?"pr-10":""} ${T}`,onChange:re}),x]})]}),t.jsx(Cr,{error:te?oe:void 0,helperText:O,helperDisplay:N})]})}function tu({value:e,onChange:r,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const ru=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),Bn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Mr=12,Fn=8,Ra=(e,r,n)=>{const a=_n(n),s=e.insertRow(r);for(let l=0;l<a;l+=1){const i=s.insertCell(-1);i.innerHTML="<br>"}return s.cells[0]??null},Hs=(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>=Mr?null:Ra(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Mr)return null;const s=Array.from(a.rows).indexOf(n);return Ra(a,s+1,e)},nu=(e,r)=>{var s;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((s=e.tBodies[0])==null?void 0:s.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},Bs=(e,r)=>_n(e)>=Fn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,s=document.createElement(a?"th":"td");a?s.textContent=`Columna ${n.cells.length+1}`:s.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(s,l.nextSibling):n.appendChild(s)}),!0),au=(e,r)=>_n(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Fs=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")})},Ps=(e,r,n)=>{Fs(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var s;(s=a.cells[n])==null||s.classList.add("rich-table-col-active")}))},ou=(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}}},Pn=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},_s=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")})},su=(e,r,n,a,s)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Hs(r,n):eo(r);return l&&zn(l,s,!0),!!l}case"table-row-del":return Number.isFinite(n)?nu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Bs(r,a):du(r);case"table-col-del":return Number.isFinite(a)?au(r,a):!1;default:return!1}},_n=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},lu=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},zs=e=>(e==null?void 0:e.closest("table"))??null,Ws=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},iu=e=>Array.from(e.querySelectorAll("th, td")),js=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),s=e.closest("tr");return!s||s!==a[a.length-1]?!1:e===s.cells[s.cells.length-1]},cu=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()===""},zn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(a)},eo=e=>{const r=lu(e);if(r.length>=Mr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return Ra(a,0,e)}return Hs(e,Array.from(e.rows).indexOf(n))},du=e=>{const r=_n(e)-1;return r<0?!1:Bs(e,r)},to=e=>{_s(e)},uu=(e,r,n)=>{const a=Bn(e,1,Mr),s=Bn(r,1,Fn),l=n?`<thead><tr>${Array.from({length:s},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:s},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},qs=()=>'<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>',rn=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),Us=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),fu=e=>e.replace(/[<>]/g,"").toLowerCase(),bu=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"]),mu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,pu=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},Wn=(e,r)=>r.test(e),hu=e=>Wn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),gu=e=>Wn(e,/font-style\s*:\s*italic/i),vu=e=>Wn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),yu=e=>Wn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),jn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},qn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},xu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},Vs=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"},wu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(mu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Nu=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&&(hu(a)&&jn(n,"strong"),gu(a)&&jn(n,"em"),vu(a)&&jn(n,"u"),yu(a)&&jn(n,"s"))})},ku=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(xu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],s=Vs(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(Vs(u)!==s)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(s);c.insertBefore(d,a),l.forEach(u=>{wu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Cu=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Su=e=>{const r=pu(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),s=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;s.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Nu(s),ku(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){qn(d),c.forEach(l);return}if(!bu.has(u)){qn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=Cu(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(ru.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){qn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){qn(d),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},ro=e=>rn(e).replace(/\r\n?/g,`
25
- `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Eu=e=>new RegExp("\\p{L}","u").test(e),no=(e,r)=>{const n=e.trim();return!n||!Eu(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===Us(n)},Xs=e=>{const r=a=>{var s,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=a.parentNode)==null||s.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",qs())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&r(s)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function Ys({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s,toolbarVariant:l="full"}){const i=o.useId(),c=s||i,d=o.useCallback(()=>document,[]),u=o.useRef(null),m=o.useRef(null),b=o.useRef(new Map),f=o.useRef(null),g=o.useRef(!1),h=o.useRef(e??""),C=o.useRef(r),v=o.useRef(()=>{}),E=o.useRef(!1),[A,S]=o.useState(()=>!e||e.trim()===""),[O,N]=o.useState(new Set),[y,T]=o.useState(null),[w,F]=o.useState(""),[Y,K]=o.useState(""),[L,G]=o.useState(""),[q,ne]=o.useState(""),[J,R]=o.useState(3),[V,X]=o.useState(3),[ce,D]=o.useState(!0),[_,le]=o.useState(!1),[I,oe]=o.useState(l==="full"),[k,te]=o.useState(null),[P,z]=o.useState(null),de=o.useRef(null),re=o.useRef(!1),W=o.useRef(null),x=o.useCallback(()=>g.current?m.current:u.current,[]);o.useEffect(()=>{C.current=r},[r]);const M=o.useCallback(()=>{const B=window.getSelection(),Z=x();if(!B||!Z||B.rangeCount===0||B.isCollapsed)return"";const fe=B.getRangeAt(0);return!Z.contains(fe.startContainer)||!Z.contains(fe.endContainer)?"":B.toString()},[x]);o.useEffect(()=>{const B=e??"";if(E.current&&B===h.current){E.current=!1,S(!B||B.trim()==="");return}E.current=!1,h.current=B;const Z=[u.current,m.current].filter(me=>!!me);Z.forEach(me=>{me.innerHTML!==B&&(me.innerHTML=B)}),S(!B||B.trim()===""),Z.forEach(me=>to(me));const fe=Z.map(me=>Xs(me));return()=>fe.forEach(me=>me())},[e]),o.useEffect(()=>{var me,Ce;g.current=_;let B,Z=0,fe;if(_){const ve=u.current;ve&&(h.current=Pn(ve));const De=()=>{var Xe;const Ae=m.current;if(!Ae){Z=requestAnimationFrame(De);return}Ae.innerHTML!==h.current&&(Ae.innerHTML=h.current),B=Xs(Ae),to(Ae),S(((Xe=Ae.textContent)==null?void 0:Xe.trim())===""),fe=setTimeout(()=>Ae.focus(),60)};Z=requestAnimationFrame(De)}else{const ve=m.current,De=u.current,Ae=ve?Pn(ve):h.current,Xe=h.current;h.current=Ae,De&&De.innerHTML!==Ae&&(De.innerHTML=Ae),Ae!==Xe&&C.current(Ae),S(((Ce=(me=ve??De)==null?void 0:me.textContent)==null?void 0:Ce.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),fe&&clearTimeout(fe),B==null||B()}},[_]);const ee=o.useCallback(()=>{const B=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;B.forEach(me=>{try{d().queryCommandState(me)&&Z.add(me)}catch{return}});try{const me=fu(d().queryCommandValue("formatBlock"));me&&Z.add(`formatBlock:${me}`)}catch{}const fe=M();no(fe,"uppercase")&&Z.add("__upper"),no(fe,"lowercase")&&Z.add("__lower"),no(fe,"capitalize")&&Z.add("__cap"),N(Z)},[M,d]),ue=()=>{var Z;const B=x();B&&(h.current=Pn(B),E.current=!0,C.current(h.current),S(((Z=B.textContent)==null?void 0:Z.trim())===""))};v.current=ue;const se=o.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null),de.current&&(Fs(de.current),de.current=null),re.current=!1,te(null),z(null)},[]),pe=o.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null)},[]),Me=o.useCallback(()=>{pe(),W.current=setTimeout(()=>{re.current||se()},280)},[pe,se]);o.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]);const Ie=o.useCallback(B=>{const Z=de.current;if(!Z||!Z.isConnected){se();return}const fe=(k==null?void 0:k.rowIndex)??(P==null?void 0:P.rowIndex)??-1,me=(k==null?void 0:k.colIndex)??(P==null?void 0:P.colIndex)??-1;su(B,Z,fe,me,x()),se(),v.current(),ee()},[x,se,ee,P,k]),At=o.useCallback(B=>{if(P)return;const Z=B.currentTarget,fe=B.target;if(fe.closest(".rich-table-action-bar, .rich-table-context-menu")){pe();return}const me=fe.closest("td, th");if(!me||!Z.contains(me)){Me();return}const Ce=me.closest("tr"),ve=me.closest("table");if(!Ce||!ve||!Z.contains(ve)){Me();return}pe(),ve.classList.add("rich-table"),de.current=ve,Ps(ve,Ce,me.cellIndex),te(ou(ve,Ce,me))},[pe,Me,P]),Bt=o.useCallback(B=>{const Z=B.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){pe();return}Me()},[pe,Me]),Re=o.useCallback(B=>{const Z=B.currentTarget,me=B.target.closest("td, th");if(!me||!Z.contains(me))return;const Ce=me.closest("tr"),ve=me.closest("table");if(!Ce||!ve||!Z.contains(ve))return;B.preventDefault(),ve.classList.add("rich-table"),de.current=ve;const De=Array.from(ve.rows).indexOf(Ce),Ae=me.cellIndex;Ps(ve,Ce,Ae),te(null),z({x:B.clientX,y:B.clientY,rowIndex:De,colIndex:Ae})},[]);o.useEffect(()=>{if(!k&&!P)return;const B=()=>Me();return window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}},[Me,P,k]),o.useEffect(()=>{if(!P)return;const B=Z=>{const fe=Z.target;fe instanceof Element&&fe.closest(".rich-table-context-menu")||z(null)};return window.addEventListener("mousedown",B),()=>window.removeEventListener("mousedown",B)},[P]);const Ft=B=>{if(!B){const Z=u.current;Z&&(h.current=Pn(Z))}le(!B)},lt=(B,Z)=>{var fe;(fe=x())==null||fe.focus(),d().execCommand(B,!1,Z),ue(),ee()},mt=B=>{lt("formatBlock",B)},ie=()=>{var B;(B=x())==null||B.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),ue(),ee()},Fe=()=>{const B=window.getSelection();B&&B.rangeCount>0&&(f.current=B.getRangeAt(0).cloneRange())},ze=()=>{const B=window.getSelection();B&&f.current&&(B.removeAllRanges(),B.addRange(f.current))},it=B=>{if(Fe(),B==="link"){const Z=window.getSelection();K(Z&&!Z.isCollapsed?Z.toString():""),F("")}B==="image"&&(G(""),ne("")),B==="table"&&(R(3),X(3),D(!0)),T(B)},Ve=()=>{var me;if(!w.trim())return;ze(),(me=x())==null||me.focus();const B=window.getSelection(),fe=(B&&!B.isCollapsed?B.toString():"")||Y.trim()||w.trim();d().execCommand("insertHTML",!1,`<a href="${rn(w.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${rn(fe)}</a>`),ue(),T(null)},kt=(B,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${rn(B)}" alt="${rn(Z)}" class="rich-img" />${qs()}</span>`,rt=()=>{var B;L.trim()&&(ze(),(B=x())==null||B.focus(),d().execCommand("insertHTML",!1,kt(L.trim(),q.trim())),ue(),T(null))},nt=()=>{var B;ze(),(B=x())==null||B.focus(),d().execCommand("insertHTML",!1,uu(J,V,ce)),ue(),T(null)},Vt=(B,Z=1200,fe=1200,me=.72)=>new Promise((Ce,ve)=>{const De=new FileReader;De.onerror=ve,De.onload=Ae=>{var rr;const Xe=(rr=Ae.target)==null?void 0:rr.result,Ye=new Image;Ye.onerror=ve,Ye.onload=()=>{let{width:pt,height:Xt}=Ye;if(pt>Z||Xt>fe){const Yt=Math.min(Z/pt,fe/Xt);pt=Math.round(pt*Yt),Xt=Math.round(Xt*Yt)}const Lt=document.createElement("canvas");Lt.width=pt,Lt.height=Xt;const nr=Lt.getContext("2d");if(!nr){Ce(Xe);return}nr.drawImage(Ye,0,0,pt,Xt),Ce(Lt.toDataURL("image/jpeg",me))},Ye.src=Xe},De.readAsDataURL(B)}),be=B=>{B.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!B.contains(Z.anchorNode)){const fe=document.createRange();fe.selectNodeContents(B),fe.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(fe)}},he=o.useRef(()=>{});he.current=B=>{const Z=x();Z&&(be(Z),d().execCommand("insertHTML",!1,B),to(Z),Z.querySelectorAll("p").forEach(fe=>{!(fe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!fe.querySelector("img, hr, table")&&fe.remove()}),ue(),ee())};const $e=o.useRef(Vt);$e.current=Vt;const Be=o.useRef(kt);Be.current=kt;const Le=o.useCallback(B=>{if(!B||b.current.has(B))return;const Z=fe=>{const me=fe.clipboardData;if(!me)return;const Ce=me.getData("text/html"),ve=me.getData("text/plain");if(Ce||ve){fe.preventDefault(),fe.stopPropagation();try{const Ye=Ce?Su(Ce):ro(ve);if(!Ye){ve&&he.current(ro(ve));return}he.current(Ye)}catch{ve&&he.current(ro(ve))}return}const Ae=Array.from(me.items).find(Ye=>Ye.type.startsWith("image/"));if(!Ae)return;fe.preventDefault(),fe.stopPropagation();const Xe=Ae.getAsFile();Xe&&$e.current(Xe).then(Ye=>{he.current(Be.current(Ye,"imagen"))})};B.addEventListener("paste",Z,!0),b.current.set(B,()=>{B.removeEventListener("paste",Z,!0),b.current.delete(B)})},[]),ct=o.useCallback(B=>{var fe;const Z=u.current;Z&&Z!==B&&((fe=b.current.get(Z))==null||fe()),u.current=B,B&&Le(B)},[Le]),at=o.useCallback(B=>{var fe;const Z=m.current;Z&&Z!==B&&((fe=b.current.get(Z))==null||fe()),m.current=B,B&&Le(B)},[Le]);o.useEffect(()=>{const B=b.current;return()=>{B.forEach(Z=>Z()),B.clear()}},[]);const Pe=B=>{const Z=window.getSelection(),fe=x();if(!Z||!fe||Z.rangeCount===0||Z.isCollapsed)return;const me=Z.getRangeAt(0);if(!fe.contains(me.startContainer)||!fe.contains(me.endContainer))return;const Ce=me.toString();if(!Ce)return;let ve=Ce;B==="uppercase"?ve=Ce.toLocaleUpperCase():B==="lowercase"?ve=Ce.toLocaleLowerCase():ve=Us(Ce),me.deleteContents();const De=document.createTextNode(ve);me.insertNode(De);const Ae=document.createRange();Ae.setStart(De,0),Ae.setEnd(De,ve.length),Z.removeAllRanges(),Z.addRange(Ae),f.current=Ae.cloneRange(),ue(),ee()},We=()=>{Fe(),ee()},ot=()=>{const B=x();B&&_s(B),ue(),ee()},dt=()=>{requestAnimationFrame(()=>{var B;(B=x())==null||B.focus()})},dr=B=>{var Z,fe;if((B.metaKey||B.ctrlKey)&&B.key==="Enter"){if(B.preventDefault(),B.stopPropagation(),B.repeat)return;(Z=x())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),ue(),ee();return}if(B.key==="Tab"){const me=window.getSelection(),Ce=Ws((me==null?void 0:me.anchorNode)??null),ve=x(),De=zs(Ce);if(Ce&&De&&(ve!=null&&ve.contains(Ce))){B.preventDefault();const Ae=iu(De),Xe=Ae.indexOf(Ce),Ye=Xe>=0?Ae[Xe+1]:null;if(Ye)zn(Ye,ve,!0);else if(js(Ce,De)){const rr=eo(De);rr&&zn(rr,ve,!0)}ue(),ee();return}B.preventDefault(),(fe=x())==null||fe.focus(),d().execCommand("insertText",!1,"    "),ue(),ee();return}if(B.key==="Enter"&&!B.shiftKey&&!(B.metaKey||B.ctrlKey)){const me=window.getSelection(),Ce=Ws((me==null?void 0:me.anchorNode)??null),ve=x(),De=zs(Ce);if(Ce&&De&&(ve!=null&&ve.contains(Ce))&&js(Ce,De)&&cu(Ce)){B.preventDefault();const Ae=eo(De);Ae&&zn(Ae,ve,!0),ue(),ee();return}}if(B.key==="Escape"){if(P){z(null);return}if(y){T(null);return}if(g.current){le(!1);return}}y||(B.ctrlKey||B.metaKey)&&(B.key==="b"&&(B.preventDefault(),lt("bold")),B.key==="i"&&(B.preventDefault(),lt("italic")),B.key==="u"&&(B.preventDefault(),lt("underline")),B.key==="k"&&(B.preventDefault(),it("link")))},st=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),He=(B,Z,fe,me,Ce)=>{const ve=Ce??(O.has(fe)||fe==="__link"&&y==="link"||fe==="__img"&&y==="image"||fe==="__table"&&y==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:dt,onMouseDown:De=>{De.preventDefault(),me?me():lt(fe)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ve?"var(--primary)":"var(--text-secondary)",background:ve?"rgba(59,130,246,0.12)":"transparent"},children:B},fe)},bn=B=>{const Z=B.target;if(Z.closest("[data-action='delete-img']")){B.preventDefault();const fe=Z.closest(".rich-img-wrap");fe&&(fe.remove(),ue())}},sa=()=>{pe(),re.current=!0},ut=()=>{re.current=!1,Me()},Ct=(B,Z,fe,me=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${me?" rich-table-action-btn--danger":""}`,title:B,"aria-label":B,onMouseDown:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),Ie(fe)},children:Z}),St=()=>typeof document>"u"||!k&&!P?null:ft.createPortal(t.jsxs(t.Fragment,{children:[k&&!P&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:k.bar.x,top:k.bar.y},onMouseEnter:sa,onMouseLeave:ut,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"}),Ct("Añadir fila abajo","+","table-row-add"),Ct("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Ct("Añadir columna a la derecha","+","table-col-add"),Ct("Eliminar columna","−","table-col-del")]}),Ct("Eliminar tabla","Eliminar","table-delete",!0)]}),P&&t.jsx("div",{className:"rich-table-context-menu",style:{left:P.x,top:P.y},onMouseDown:B=>B.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([B,Z])=>t.jsx("button",{type:"button",onMouseDown:fe=>{fe.preventDefault(),Ie(Z)},children:B},Z))})]}),document.body),tr=B=>t.jsxs(t.Fragment,{children:[y==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:B},children:[t.jsx("input",{autoFocus:!0,type:"url",value:w,onChange:Z=>F(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Ve()),Z.key==="Escape"&&T(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:Y,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Ve()),Z.key==="Escape"&&T(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:Ve,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:()=>T(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),y==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:B},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Mr,value:J,onChange:Z=>R(Bn(Number(Z.target.value),1,Mr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),nt()),Z.key==="Escape"&&T(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:Fn,value:V,onChange:Z=>X(Bn(Number(Z.target.value),1,Fn)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),nt()),Z.key==="Escape"&&T(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:ce,onChange:Z=>D(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:nt,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:()=>T(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),y==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:B},children:[t.jsx("input",{autoFocus:!0,type:"url",value:L,onChange:Z=>G(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),rt()),Z.key==="Escape"&&T(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=>ne(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),rt()),Z.key==="Escape"&&T(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:rt,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:()=>T(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Fr=(B,Z)=>{const fe=l==="full"||I||B;return t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:Z},children:[He(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),He(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),He(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),He(t.jsx(j.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),He(t.jsx(j.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),He(t.jsx(j.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>it("link")),l==="compact"&&!B&&t.jsxs("button",{type:"button",title:I?"Ocultar herramientas":"Mostrar más herramientas",tabIndex:-1,onFocus:dt,onMouseDown:me=>{me.preventDefault(),oe(Ce=>!Ce)},className:"ml-0.5 flex h-7 items-center gap-0.5 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)"},children:[I?t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"}),I?"Menos":"Más"]}),fe&&t.jsxs(t.Fragment,{children:[st(),He(t.jsx(j.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),He(t.jsx(j.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),st(),He(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>mt("p"),O.has("formatBlock:p")||O.has("formatBlock:div")),He(t.jsx(j.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>mt("h2"),O.has("formatBlock:h2")),He(t.jsx(j.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>mt("h3"),O.has("formatBlock:h3")),He(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>mt("blockquote"),O.has("formatBlock:blockquote")),st(),He(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),st(),He(t.jsx(j.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),He(t.jsx(j.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),st(),He(t.jsx(j.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),He(t.jsx(j.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),He(t.jsx(j.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),He(t.jsx(j.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),st(),He(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>Pe("uppercase")),He(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>Pe("lowercase")),He(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>Pe("capitalize")),st(),He(t.jsx(j.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),He(t.jsx(j.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>it("image")),He(t.jsx(j.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>it("table")),He(t.jsx(j.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",ie),st(),He(t.jsx(j.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),He(t.jsx(j.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>mt("p"))]}),st(),t.jsx("button",{type:"button",title:B?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:dt,onMouseDown:me=>{me.preventDefault(),Ft(B)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:B?t.jsx(j.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(j.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[St(),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:ct,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:ot,onKeyDown:dr,onKeyUp:We,onSelect:We,onMouseUp:We,onMouseMove:At,onMouseLeave:Bt,onContextMenu:Re,onMouseDown:bn,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),tr("var(--bg-input)"),Fr(!1,"var(--bg-input)")]}),t.jsxs(Ha,{open:_,onClose:()=>le(!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:at,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:ot,onKeyDown:dr,onKeyUp:We,onSelect:We,onMouseUp:We,onMouseMove:At,onMouseLeave:Bt,onContextMenu:Re,onMouseDown:bn,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),tr("var(--bg-input)"),Fr(!0,"var(--bg-input)")]})]})}const Ks="[a-zA-Z0-9._@-]+",ao=new RegExp(`@(${Ks})`,"g"),Mu=/[a-zA-Z0-9._@-]/,nn=new Set([" ",`
26
- `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function Gs(e,r){if(r<=0)return!0;const n=e[r-1]??"";return nn.has(n)}function Zs(e,r,n){var a;if(r<0||r>e.length)return null;for(let s=r-1;s>=0;s-=1){if(e[s]!=="@"){const c=e[s]??"";if(nn.has(c)||!Mu.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,s)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(s):Gs(e,s)))continue;const i=e.slice(s+1,r);return i.length>0&&!new RegExp(`^${Ks}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:r}}return null}function Qs(e,r){var a;const n=Tr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Js(e,r){if(r<=0)return!0;const n=Tr(e,r);if(!n){const s=fo(e);return Gs(s,r)}if(n.offset>0){const s=n.node.data[n.offset-1]??"";return nn.has(s)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const s=a.textContent??"";if(s.length===0){a=a.previousSibling;continue}return nn.has(s[s.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const s=a;if(s.classList.contains("mention-chip")||s.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(s.tagName))return!0;const l=s.textContent??"";if(l.length===0){a=a.previousSibling;continue}return nn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function oo(e,r){const n=fo(e);return Zs(n,r,{isTriggerBoundary:a=>Js(e,a),isInsideExistingMention:a=>Qs(e,a)})}function so(e){return e.toLowerCase().trim()}function Rs(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
23
+ </body></html>`,Ce=window.open("","_blank");Ce&&(Ce.document.write(ve),Ce.document.close())}const La=()=>!et||!yn?null:ht.createPortal(t.jsxs("div",{ref:Ho,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...em,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()=>(nt?await nt():Lm(),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()=>(Le?await Le():Dm(),pa(!1)))()},children:[t.jsx(W.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Da=()=>{const p=F&&xe.trim().length>0,$=pe!=null&&pe.length?pe:p?[{key:"bql",label:"BQL",value:xe}]:[],Q=ie.filter(P=>{const se=P.trim();return se?!new Set(He.split(`
24
+ `).map(Ce=>Ce.trim()).filter(Boolean)).has(se):!1}).slice(0,8);return!le&&Bo===0&&!F&&!et?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:[Bo>0&&t.jsxs("button",{type:"button",onClick:bm,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"}),Bo," filtros"]}),F&&t.jsxs("div",{ref:Do,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ye){Ke(!1);return}ka(),Ke(!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:Ye?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ye||p?"var(--primary)":"var(--border)",color:Ye?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ye,title:"Abrir filtros BQL",children:[t.jsx(W.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ye?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:x}),$.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[$.slice(0,3).map(P=>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:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key)),$.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",$.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:$i,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"})}),Ye&&ht.createPortal(t.jsxs("div",{ref:hi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Zb,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(P=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),Na(P.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:[P.icon,P.label]},P.label)),fe.length>0&&t.jsxs("button",{type:"button",onClick:()=>vt(P=>!P),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":or,children:[t.jsx(W.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),sr.length>0&&t.jsxs("button",{type:"button",onClick:()=>Ht(P=>!P),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":Yt,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 ${ae?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Oo,value:He,rows:3,onChange:P=>Po(P.target.value,P.target),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),Ti(He)),P.key==="Escape"&&Ke(!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(P=>t.jsx("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),Na(P)},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:P},P))})]}),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:ae?"var(--danger)":"var(--text-muted)"},children:ae??(p?`${$.length||1} filtro${($.length||1)===1?"":"s"} activo${($.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),$.map(P=>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:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key))]}),Yt&&sr.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:()=>{Kt([]),Ht(!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"]})]}),sr.map(P=>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(),Na(P)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P})}),t.jsx("button",{type:"button",onClick:()=>Kt(se=>se.filter(ve=>ve!==P)),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"})})]},P))]}),or&&fe.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:fe.map(P=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),Na(P.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:P.bql}),P.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:P.description})]},P.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:$i,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:()=>Ti(He),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)]})]}),et&&t.jsx("button",{ref:ha,type:"button","aria-haspopup":"menu","aria-expanded":yn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var se;const P=(se=ha.current)==null?void 0:se.getBoundingClientRect();P&&tm({top:P.bottom+4,right:window.innerWidth-P.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"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":je&&mt==="visibility","aria-label":B,title:B,onClick:P=>Li(P,"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)] ${je&&mt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiCog6Tooth,{className:"h-4 w-4"})})]})},Vi=()=>{if(!Cm)return null;const p=_c(st,Xo);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 ${X?"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:Gt===0?"0 filas":`${Mm}–${Tm} de ${Gt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(dr,{value:String(jt),onChange:$=>$m(Number($)),options:Wo.map($=>({value:String($),label:String($)})),placeholder:"Filas",searchable:!1,disabled:a,height:Y,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:_}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||st<=1,onClick:()=>Yo(st-1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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"})}),p.map(($,Q)=>$==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>Yo($),onMouseEnter:P=>{P.currentTarget.disabled||$===st||(P.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",P.currentTarget.style.color="var(--primary)")},onMouseLeave:P=>{P.currentTarget.style.background=$===st?"var(--primary)":"transparent",P.currentTarget.style.color=$===st?"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:$===st?"var(--primary)":"transparent",color:$===st?"var(--primary-fg)":"var(--text-muted)"},children:$},$)),t.jsx("button",{disabled:a||st>=Xo,onClick:()=>Yo(st+1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.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"})]})},Om=()=>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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((p,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Ie}`},children:[It&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`}},"select-cell"),$t.map((Q,P)=>t.jsx("div",{role:"cell",className:X?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xi($,P)}%`,minWidth:32}})},Q.key))]},$))})]})})]}),Go="min-w-0 max-w-full overflow-hidden";return J&&Pe&&!lt?t.jsx(Cn,{rows:o,columns:Math.max(4,$t.length||7)}):!a&&r.length===0&&!Io?Om():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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ni,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((p,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Ie}`},children:[It&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`}},"select-cell"),$t.map((Q,P)=>{const se=Sa[Q.key],ve=se!==void 0,Ce=Q.key===Vo;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:X?"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 ${Ie}`:`inset 0 -1px 0 ${Ie}`,borderRight:`1px solid ${Ie}`}:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${xi($,P)}%`,minWidth:32}})},Q.key)})]},$))})]})})}),Vi()]}):!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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Ie,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:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ni,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Bi.map((p,$)=>{const Q=n(p),P=Wi(N==null?void 0:N(p)),se=$>0?Wi(N==null?void 0:N(Bi[$-1])):null,ve=P&&P.key!==(se==null?void 0:se.key),Ce=It&&E.has(Q),Te=It&&(!A||A(p)),We=Xr?(m==null?void 0:m(p))??!0:!1,Ue=We&&Hi.has(Q),yt=!!d||h&&We,tt=Ce&&C?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":$%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 ${P.className??""}`,style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:X?"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 ${Ie}`,borderRight:`1px solid ${Ie}`},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:P.label}),P.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:P.description})]})})})}),t.jsxs("div",{role:"row",onClick:yt?we=>{const $e=we.target;if(!($e!=null&&$e.closest('[data-dt-disable-row-click="true"]'))){if(h&&We){Fi(Q);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${yt?"cursor-pointer":""} ${O?O(p):""}`,style:{gridTemplateColumns:Yr,"--dt-row-bg":tt,"--dt-sticky-bg":tt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Ie}`},onMouseEnter:we=>{Ce||(we.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),we.currentTarget.style.setProperty("--dt-sticky-bg",Am))},onMouseLeave:we=>{we.currentTarget.style.setProperty("--dt-row-bg",tt),we.currentTarget.style.setProperty("--dt-sticky-bg",tt)},children:[Xr&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},"data-dt-disable-row-click":"true",children:We&&t.jsx("button",{type:"button","aria-label":Ue?"Contraer fila":"Desplegar fila","aria-expanded":Ue,onClick:we=>{we.stopPropagation(),Fi(Q)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:Ue?t.jsx(W.HiChevronDown,{className:"h-4 w-4"}):t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})}),It&&t.jsx("div",{role:"cell",className:`${X?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Ie}`}:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`},onClick:we=>{we.stopPropagation(),Te&&v(Q)},children:t.jsx(Mn,{size:"sm",checked:Ce,disabled:!Te,"aria-label":Te?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Te?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:we=>we.stopPropagation(),onChange:()=>{Te&&v(Q)}})}),$t.map(we=>{const $e=Sa[we.key],Se=$e!==void 0,Ne=we.key===Vo,ke=ur(we);return t.jsx("div",{role:"cell","data-dt-column-key":we.key,"data-dt-disable-row-click":we.disableRowClick||ke?"true":void 0,className:`${ke?"px-2 py-1.5 justify-center text-center":`${X?"px-2 py-1.5":"px-3 py-2"} ${Pi(we.align)}`} flex min-w-0 items-center ${Oc} ${we.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Se?{position:"sticky",left:$e,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:Ne?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ie}`:`inset 0 -1px 0 ${Ie}`,borderRight:`1px solid ${Ie}`}:{borderBottom:`1px solid ${Ie}`,borderRight:`1px solid ${Ie}`}},children:t.jsx(ps,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:we.cell(p)})})},we.key)})]}),Ue&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:X?"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 ${Ie}`},children:u(p)})})]},Q)})})]})})}),Vi()]})}const jc={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 ${jc[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 Rt(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 hs(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 nn(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 gs(e){const r=nn(e),n=(r.getDay()+6)%7;return Er(r,-n)}function vs(e){const r=gs(e);return Array.from({length:7},(n,a)=>Er(r,a))}function ys(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=gs(r);return Array.from({length:42},(a,o)=>Er(n,o))}function xs(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function qc(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function er(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=hs(n.start);if(!a)return null;const o=hs(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function ws(e,r){const n={};for(const a of e){const o=er(a,r);if(!o)continue;let l=nn(o.start);const i=nn(o.end);for(;l.getTime()<=i.getTime();){const c=Rt(l);n[c]||(n[c]=[]),n[c].push(a),l=Er(l,1)}}return n}function Ua(e,r,n){if(r.length===0)return[];const a=nn(r[0]),o=nn(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const m=er(d,n),b=er(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=er(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)),h=Math.max(1,g-f+1);let E=l.findIndex(v=>v<f);E<0?(E=l.length,l.push(f+h-1)):l[E]=f+h-1,i.push({item:d,lane:E,colStart:f,colSpan:h})}return i}function Lt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Uc(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Vc(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 Xc(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 Ns(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?Er(e,n*7):Er(e,n)}const Yc=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"];function Kc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Bt,{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 Gc({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=er(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 Zc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(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 ks({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 Qc({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:m=[...Yc],renderToolbarExtra:b,renderPill:f,renderDayCard:g,renderWeekBar:h,tableColumns:E,tableProps:v,onItemClick:S,onDayClick:A,loading:C=!1,emptyTitle:O="Sin eventos",emptyDescription:N="No hay eventos para los filtros seleccionados.",legend:y,legendInteractive:M=!0,activeLegendKeys:k,defaultActiveLegendKeys:_,onActiveLegendKeysChange:Y,getItemLegendKey:K,overloadLabel:D="Sobrecarga de eventos",className:G="",showToolbar:U=!0}){const ne=s.useMemo(()=>(y??[]).map(ae=>ae.label),[y]),[J,R]=s.useState(()=>_??ne),V=k??(ne.length>0?J:[]),X=s.useMemo(()=>new Set(V),[V]),de=ae=>{k===void 0&&R(ae),Y==null||Y(ae)},H=ae=>{M&&(X.has(ae)?de(V.filter(ye=>ye!==ae)):de([...V,ae]))},I=s.useMemo(()=>{if(!M||ne.length===0)return e;const ae=new Set(ne);return e.filter(ye=>{const Qe=(K==null?void 0:K(ye))??ye.status;return!Qe||!ae.has(Qe)?!0:X.has(Qe)})},[e,M,ne,X,K]),le=s.useMemo(()=>ws(I,c),[I,c]),L=s.useMemo(()=>ys(r),[r]),oe=s.useMemo(()=>xs(L),[L]),w=s.useMemo(()=>vs(r),[r]),te=Rt(r),B=le[te]??[],F=s.useMemo(()=>Ua(I,w,c),[I,w,c]),ue=s.useMemo(()=>F.length===0?1:Math.max(...F.map(ae=>ae.lane))+1,[F]),re=s.useMemo(()=>oe.map(ae=>{const ye=Ua(I,ae,c),Qe=ye.length===0?0:Math.max(...ye.map(Je=>Je.lane))+1;return{days:ae,bars:ye,laneCount:Qe}}),[oe,I,c]),j=36,x=34,T=l==="month"?L:l==="week"?w:[r],ee=s.useMemo(()=>{const ae=[];for(const ye of T){const Qe=Rt(ye),Je=le[Qe]??[];Je.length>=u&&ae.push([ye,Je])}return ae},[T,le,u]),fe=l==="month"?Uc(r):l==="week"?`${Lt(w[0])} – ${Lt(w[6])}`:Vc(r),ie=s.useMemo(()=>[{key:"title",header:"Título",cell:ae=>ae.title},{key:"status",header:"Estado",cell:ae=>ae.status??"—"},{key:"range",header:"Rango",cell:ae=>{const ye=er(ae,c);return ye?`${Lt(ye.start)} → ${Lt(ye.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ae=>ae.subtitle??"—"}],[c]),pe=ae=>{if(n(ae),A){A(ae);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(Ns(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:fe}),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(Ns(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:[b,t.jsx(ks,{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(ks,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,y&&y.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:M?"group":void 0,"aria-label":M?"Filtrar por estado":void 0,children:y.map(ae=>{const ye=X.has(ae.label);return M?t.jsxs("button",{type:"button","aria-pressed":ye,onClick:()=>H(ae.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:ye?"var(--text-main)":"var(--text-muted)",background:ye?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:ye?`1px solid color-mix(in srgb, ${ae.color} 55%, var(--border))`:"1px solid var(--border)",opacity:ye?1:.45},title:ye?`Ocultar “${ae.label}”`:`Mostrar “${ae.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ae.color,boxShadow:ye?`0 0 0 2px color-mix(in srgb, ${ae.color} 25%, transparent)`:void 0},"aria-hidden":!0}),ae.label]},ae.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:ae.color},"aria-hidden":!0}),ae.label]},ae.label)})}):null,a==="calendar"&&ee.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:[D,":"]})," ",ee.map(([ae,ye])=>`${Lt(ae)} (${ye.length})`).join(", ")]}):null,a==="table"?C||I.length>0?t.jsx(qa,{columns:E??ie,data:I,getRowId:ae=>ae.id,loading:C,skeletonRows:8,emptyIcon:t.jsx(W.HiCalendarDays,{className:"h-10 w-10"}),emptyText:N,onRowClick:S,pageSize:25,compact:!0,...v}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:O,description:N}):null,a==="calendar"&&l==="month"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--border)"},children:m.map(ae=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ae},ae))}),re.map(({days:ae,bars:ye,laneCount:Qe},Je)=>{const et=Math.min(Qe,d),ft=Math.max(0,Qe-d),nt=j+Math.max(1,et)*x+(ft>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:nt,borderBottom:Je<re.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:"grid grid-cols-7",style:{minHeight:nt},children:ae.map(Le=>{const ce=Rt(Le),Pe=le[ce]??[],_e=Le.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Le.getDate()}`,onClick:()=>pe(Le),onKeyDown:at=>{(at.key==="Enter"||at.key===" ")&&(at.preventDefault(),pe(Le))},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:nt},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:_e?"var(--text-muted)":"var(--text-main)"},children:Le.getDate()}),Pe.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:Pe.length}):null]})},ce)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:j,bottom:4},children:[ye.filter(Le=>Le.lane<d).map(Le=>{const ce={left:`calc(${Le.colStart/7*100}% + 4px)`,width:`calc(${Le.colSpan/7*100}% - 8px)`,top:2+Le.lane*x,height:x-6,pointerEvents:"auto"};return f?t.jsx("div",{className:"absolute",style:ce,children:f(Le.item,{day:ae[Le.colStart]})},`${Le.item.id}-${Le.colStart}-${Je}`):h?t.jsx("div",{className:"absolute",style:ce,children:h(Le.item)},`${Le.item.id}-${Le.colStart}-${Je}`):t.jsx(Kc,{item:Le.item,style:ce,onClick:()=>S==null?void 0:S(Le.item)},`${Le.item.id}-${Le.colStart}-${Je}`)}),ft>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+et*x,color:"var(--text-muted)"},children:["+",ft," más"]}):null]})]},`week-${Je}-${Rt(ae[0])}`)})]}):null,a==="calendar"&&l==="week"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7 border-b",style:{borderColor:"var(--border)"},children:w.map(ae=>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:()=>pe(ae),children:Xc(ae)},Rt(ae)))}),t.jsxs("div",{className:"relative grid grid-cols-7",style:{minHeight:Math.max(220,ue*56+24)},children:[w.map(ae=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Rt(ae)}`)),F.map(ae=>{const ye={left:`calc(${ae.colStart/7*100}% + 4px)`,width:`calc(${ae.colSpan/7*100}% - 8px)`,top:12+ae.lane*56};return h?t.jsx("div",{className:"absolute",style:ye,children:h(ae.item)},`${ae.item.id}-${ae.colStart}`):t.jsx(Zc,{item:ae.item,style:ye,onClick:()=>S==null?void 0:S(ae.item)},`${ae.item.id}-${ae.colStart}`)}),F.length===0&&!C?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:N}):null]})]}):null,a==="calendar"&&l==="day"?B.length>0||C?t.jsxs("div",{className:"space-y-3",children:[C&&B.length===0?t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,B.map(ae=>g?t.jsx("div",{children:g(ae)},ae.id):t.jsx(Gc,{item:ae,onClick:()=>S==null?void 0:S(ae)},ae.id))]}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:O,description:N}):null]})}function Ss(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 Jc(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Ss(e)}function Rc(e){return typeof e=="function"?e():e}function Va({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:g,type:h="button",...E}){const[v,S]=s.useState(!1),A=s.useRef(null);s.useEffect(()=>()=>{A.current&&window.clearTimeout(A.current)},[]);function C(N){S(!0),d==null||d(N),A.current&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{S(!1),A.current=null},r)}async function O(N){var M;if(c&&N.stopPropagation(),g==null||g(N),N.defaultPrevented)return;const y=Rc(e);if(y)try{await Jc(y),C(y)}catch(k){try{Ss(y),C(y)}catch(_){u==null||u(_,y);return}(M=navigator.clipboard)!=null&&M.writeText||u==null||u(k,y)}}return t.jsxs("button",{...E,type:h,onClick:O,title:v?a:n,"aria-label":E["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 ed({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(Va,{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 In(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function td({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(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:In(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:In(o),padding:In(l)}})]})}function rd({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:In(d)},children:o}),t.jsx(dr,{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 nd={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Bn=180,ad="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Xa({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:h="center",bodyClassName:E="px-6 py-5",panelClassName:v="",backdropClassName:S=ad,contentClassName:A="p-4",ariaLabel:C,frameless:O=!1,disabled:N=!1}){const[y,M]=s.useState(!1),[k,_]=s.useState(!1),Y=s.useRef(null);if(s.useEffect(()=>(e?(Y.current&&clearTimeout(Y.current),M(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>_(!0)))):(_(!1),Y.current=setTimeout(()=>M(!1),Bn+40)),()=>{Y.current&&clearTimeout(Y.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=R=>{R.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[f,r,e]),!y)return null;const K=n||a||o||l||g,D=u??nd[d],G=h==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",U=h==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=k?"translateY(0) scale(1)":h==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ht.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":C??n,className:`fixed inset-0 flex ${G} ${A}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${S}`,onClick:b?r:void 0,style:{opacity:k?1:0,transition:`opacity ${Bn}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:k?1:0,transform:ne,transition:`opacity ${Bn}ms ease, transform ${Bn}ms ease`},onClick:J=>J.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(Ve,{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 ${E}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const od={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 sd({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=od[l];return t.jsx(Xa,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ve,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(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(Ve,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ve,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function ld(e){return e?typeof e=="function"?e():e:""}function id(e){return/^https?:\/\//i.test(e)}function Es(e,r){try{return new URL(e,r).toString()}catch{return e}}function cd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||id(l))return l;const i=ld(n);return i?Es(l,i):a&&typeof window<"u"?Es(l,window.location.origin):l}function dd({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(Va,{...c,value:()=>cd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const ud={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 fd(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=ud[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 bd=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function md({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&&!bd.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 pd({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(dr,{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 hd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Ya={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function gd({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[h,E]=s.useState({}),[v,S]=s.useState(null),A=s.useRef(null);A.current=v;const[C,O]=s.useState({}),[N,y]=s.useState({}),M=s.useRef(new Set),k=s.useRef(null);s.useEffect(()=>{var I;const H=document.activeElement;(!H||H===document.body)&&((I=k.current)==null||I.focus({preventScroll:!0}))},[]);const _=e.map(H=>{var I,le,L;return`${H.key}:${((L=(le=(I=H.editable)==null?void 0:I.select)==null?void 0:le.options)==null?void 0:L.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(H=>{var L,oe;const I=(oe=(L=H.editable)==null?void 0:L.select)==null?void 0:oe.options;if(!I)return;const le=C[H.key];(!M.current.has(H.key)||(le==null?void 0:le.length)===0&&I.length>0)&&(M.current.add(H.key),O(w=>({...w,[H.key]:I})))})},[_]);const Y=s.useCallback(async(H,I)=>{if(M.current.has(H))return;M.current.add(H);const{url:le,fetchOptions:L}=I.select??{};if(!(!le&&!L)){y(oe=>({...oe,[H]:!0}));try{let oe=[];if(L)oe=await L();else if(le){const w=await fetch(le);if(!w.ok)throw new Error("fetch failed");oe=await w.json()}O(w=>({...w,[H]:oe}))}catch{O(oe=>({...oe,[H]:[]}))}finally{y(oe=>({...oe,[H]:!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 ne=s.useRef(o);ne.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const H=e.find(I=>I.selectable!==!1);H&&f({rowId:n(r[0]),colKey:H.key})}},[]),s.useEffect(()=>{if(!b)return;const H=k.current;if(!H)return;const I=H.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!I)return;const le=H.querySelector('[role="rowgroup"]');I.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const L=H.querySelector('[role="row"]');let oe=0;L&&L.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(w=>{w.style.position==="sticky"&&w.style.left!==""&&(oe=Math.max(oe,parseFloat(w.style.left)+w.offsetWidth))}),I.style.scrollMarginLeft=`${oe}px`,I.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=s.useCallback(H=>{var oe;const I=U.current,le=new Set,L=[];(oe=k.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(w=>{const te=w.dataset.cellId.split(":")[0];le.has(te)||(le.add(te),L.push(te))}),f(w=>{if(!w)return w;const te=I.findIndex(re=>re.key===w.colKey),B=L.indexOf(w.rowId);let F=te,ue=B;if(H==="up")ue=Math.max(0,B-1);else if(H==="down")ue=Math.min(L.length-1,B+1);else if(H==="left"){let re=te-1;for(;re>=0&&I[re].selectable===!1;)re--;re>=0&&(F=re)}else if(H==="right"){let re=te+1;for(;re<I.length&&I[re].selectable===!1;)re++;re<I.length&&(F=re)}return F===te&&ue===B?w:{rowId:L[ue],colKey:I[F].key}})},[]),R=s.useCallback((H=!0)=>{const I=d.current;m(null),I&&f(I),H&&setTimeout(()=>{var le;return(le=k.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),V=s.useCallback(async(H,I,le)=>{var ie;const L=U.current.find(pe=>pe.key===I);if(!(L!=null&&L.editable))return;const{field:oe,type:w,mask:te,validate:B}=L.editable,F=w==="number"?le===""?null:Number(le):le;if(te){const pe=fd(le,te);if(pe){E(ae=>({...ae,[`${H}:${I}`]:pe}));return}}if(B){const pe=B(F);if(pe){E(ae=>({...ae,[`${H}:${I}`]:pe}));return}}const ue=G.current,re=K.current.find(pe=>ue(pe)===H);if(!re)return;const j=re[oe];m(null),E(pe=>{const ae={...pe};return delete ae[`${H}:${I}`],ae});const x=K.current,T=x.findIndex(pe=>ue(pe)===H),ee=x[Math.min(x.length-1,T+1)];if(f({rowId:ue(ee),colKey:I}),setTimeout(()=>{var ae,ye;const pe=document.activeElement;(!pe||pe===document.body||(ae=k.current)!=null&&ae.contains(pe))&&((ye=k.current)==null||ye.focus({preventScroll:!0}))},0),String(j??"")===String(F??""))return;const fe={...re,[oe]:F};c(pe=>pe.map(ae=>ue(ae)===H?fe:ae)),S({rowId:H,colKey:I});try{await((ie=D.current)==null?void 0:ie.call(D,{row:re,rowId:H,field:oe,oldValue:j,newValue:F}))}catch{c(pe=>pe.map(ae=>ue(ae)===H?re:ae)),E(pe=>({...pe,[`${H}:${I}`]:"Error al guardar. Intenta de nuevo."}))}finally{S(null)}},[]),X=s.useCallback(H=>{if(A.current){H.preventDefault();return}if(d.current)return;const I=g.current;if(!(!I||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(H.key)))switch(H.preventDefault(),H.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(H.shiftKey?"left":"right");break;case"Enter":{const L=U.current.find(oe=>oe.key===I.colKey);L!=null&&L.editable&&!ne.current?(m(I),L.editable.type==="select"&&!M.current.has(I.colKey)&&Y(I.colKey,L.editable)):J("down");break}}},[J,Y]),de=s.useMemo(()=>e.map(H=>{if(!H.editable||o){const le={...H};if(delete le.editable,delete le.selectable,H.selectable===!1)return{...le,disableRowClick:!0};const L=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const w=n(oe),te=(b==null?void 0:b.rowId)===w&&(b==null?void 0:b.colKey)===H.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${w}:${H.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var B;A.current||(f({rowId:w,colKey:H.key}),(B=k.current)==null||B.focus({preventScroll:!0}))}}),te&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:L(oe)})]})}}}const I=H.editable;return{...H,className:`relative ${H.className??""}`.trim(),disableRowClick:!0,cell:le=>{const L=n(le),oe=H.key,w=(u==null?void 0:u.rowId)===L&&(u==null?void 0:u.colKey)===oe,te=(b==null?void 0:b.rowId)===L&&(b==null?void 0:b.colKey)===oe,B=h[`${L}:${oe}`],F=(v==null?void 0:v.rowId)===L&&(v==null?void 0:v.colKey)===oe,ue=le[I.field],re=String(ue??""),j=()=>{var T;A.current||(f({rowId:L,colKey:oe}),m({rowId:L,colKey:oe}),(T=k.current)==null||T.focus({preventScroll:!0}),I.type==="select"&&!M.current.has(oe)&&Y(oe,I))};if(w){const T=I.type==="select"?t.jsx(pd,{initialValue:re,options:C[oe]??[],loading:N[oe]??!1,onCommit:ee=>V(L,oe,ee),onCancel:R}):t.jsx(md,{initialValue:re,type:I.type??"text",mask:I.mask,onCommit:ee=>V(L,oe,ee),onCancel:R});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:hd,onClick:ee=>ee.stopPropagation(),children:T})}const x=H.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${L}:${oe}`,className:`peer absolute inset-0 z-10 ${F?"cursor-wait":"cursor-pointer"}`,onClick:j}),te&&!F&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),F&&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:Ya,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:B?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:B})]}):t.jsx("span",{className:"truncate",children:x})}),!F&&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,h,C,N,n,V,R,Y]);return t.jsx("div",{ref:k,tabIndex:0,onKeyDown:X,onBlur:H=>{var I;(I=k.current)!=null&&I.contains(H.relatedTarget)||setTimeout(()=>{var L,oe;const le=document.activeElement;le&&((L=le.closest)!=null&&L.call(le,"[data-bonsaif-select-dropdown]"))||(oe=k.current)!=null&&oe.contains(le)||R(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(qa,{...l,columns:de,data:i,getRowId:n})})}function ot(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 Cr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Cs(e){return e.map(r=>ot(r)).filter(r=>!!r)}function vd(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Dt));return Array.from(r).sort()}function Ka(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Ms(e){const r=ot(e);if(!r)return e;const n=Ka(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 Ga={weekend:{dayOfWeek:[0,6]}},Za={weekend:"bonsaif-weekend"};function Qa({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 yd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},xd={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function wd({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?yd:null,...o?xd:null,...l?{fontWeight:800}:null,...n.style}})}function Nd({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:ot(e),to:ot(r)},f=ot(a),[g,h]=s.useState(()=>ot(o||e)??new Date);s.useEffect(()=>{const C=ot(o||e);C&&h(C)},[o,e]);const E=s.useMemo(()=>{if(l<=1)return Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const C=new Date(g.getFullYear(),g.getMonth()+l-1,1),O=g.getFullYear()===C.getFullYear(),N=new Intl.DateTimeFormat("es-MX",{month:"short",...O?{}:{year:"numeric"}}).format(g),y=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(C);return`${Cr(N)} – ${Cr(y)}`},[g,l]);function v(){h(new Date(g.getFullYear(),g.getMonth()-1,1))}function S(){h(new Date(g.getFullYear(),g.getMonth()+1,1))}const A=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:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:S,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsx(Ia.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:h,onSelect:C=>{const O=C!=null&&C.from?Dt(C.from):e,N=C!=null&&C.to?Dt(C.to):"";n({startDate:O,endDate:N})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ga,modifiersClassNames:Za,components:{DayButton:wd,Weekday:Qa},classNames:{root:"bonsaif-range-daypicker w-full",months:A,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:C=>`${Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(C))} ${C.getFullYear()}`,formatWeekdayName:Ka}})]}),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 Ts({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:o,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),o==null||o(e.date,d))}})}function $s(e,r){const n=ot(e),a=ot(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 As(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 kd(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Sd(e,r,n){return!!(r&&e<r||n&&e>n)}function Ls({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 y=N;if(c){const M=b.current.filter(_=>!_.startsWith(c)),k=N.filter(_=>_.startsWith(c));y=[...M,...k].sort()}r==null||r(kd(y,l))},[l,r,c]),g=s.useCallback((N,y=!1)=>Sd(N,a,o)?!0:!(!(i!=null&&i(N))||y&&b.current.includes(N)),[i,o,a]),h=s.useCallback(N=>N.filter(y=>!g(y)),[g]),E=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const N=()=>E();return window.addEventListener("pointerup",N),window.addEventListener("pointercancel",N),()=>{window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",N)}},[E]);const v=s.useCallback((N,y,M,k)=>{const _=h($s(N,y));f(M==="add"?an(k,_,"add"):an(k,_,"remove"))},[f,h]),S=s.useCallback((N,y)=>{if(n||y.button!==0)return;const M=Dt(N);if(g(M,!0)||y.shiftKey)return;m.current=!0;const k=[...b.current],_=k.includes(M)?"remove":"add";_==="add"&&g(M)||(u.current={active:!0,mode:_,anchor:M,latest:M,baseline:k},d.current=M,v(M,M,_,k),y.preventDefault())},[v,n,g]),A=s.useCallback(N=>{const y=u.current;if(!(y!=null&&y.active)||n)return;const M=Dt(N);y.mode==="add"&&g(M)||y.latest!==M&&(y.latest=M,v(y.anchor,M,y.mode,y.baseline))},[v,n,g]),C=s.useCallback((N,y)=>{if(n)return;const M=Dt(N);if(!g(M,!0)){if(m.current&&!y.shiftKey){m.current=!1,y.preventDefault(),y.stopPropagation();return}if(m.current=!1,y.shiftKey&&d.current){y.preventDefault(),y.stopPropagation();const k=h($s(d.current,M));f(an(b.current,k,"add"));return}!b.current.includes(M)&&g(M)||(d.current=M,f(an(b.current,[M],"toggle")))}},[f,n,h,g]),O=s.useCallback(N=>{if(n)return;const y=h(vd(N));if(!y.length)return;const M=y.every(k=>b.current.includes(k));f(an(b.current,y,M?"remove":"add")),d.current=y[0]??d.current},[f,n,h]);return{onDayPointerDown:S,onDayPointerEnter:A,onDayClick:C,toggleWeek:O,endDrag:E}}function on(e){return As(e,1)[0]}function Ds(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Ed({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 h=s.useMemo(()=>Cs(e),[e]),E=s.useMemo(()=>new Set(e),[e]),v=ot(n),S=ot(a),[A,C]=s.useState(()=>ot(l||e[0])??new Date),[O,N]=s.useState(()=>on(ot(l||e[0])??new Date)),[y,M]=s.useState(u),k=d??y;function _(H){d===void 0&&M(H),m==null||m(H)}s.useEffect(()=>{const H=ot(l);H&&(C(H),N(on(H)))},[l]);const{onDayPointerDown:Y,onDayPointerEnter:K,onDayClick:D,toggleWeek:G}=Ls({value:e,onChange:r,disabled:g,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),U=s.useMemo(()=>{if(g)return!0;const H=[];return v&&H.push({before:v}),S&&H.push({after:S}),o&&H.push(I=>o(Dt(I))),H.length>0?H:void 0},[g,o,S,v]),ne=s.useCallback(H=>t.jsx(Ts,{...H,className:`bonsaif-multi-day-btn ${H.className??""}`,onDayPointerDown:Y,onDayPointerEnter:K,onDayClickSelect:D}),[D,Y,K]),J=s.useMemo(()=>As(O,1),[O]),R=J[6],V=k==="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(R)}`:Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(A));function X(){if(k==="week"){const H=Ds(O,-7);N(on(H)),C(H);return}C(new Date(A.getFullYear(),A.getMonth()-1,1))}function de(){if(k==="week"){const H=Ds(O,7);N(on(H)),C(H);return}C(new Date(A.getFullYear(),A.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":k==="month",className:`bonsaif-cal-view-btn${k==="month"?" is-active":""}`,disabled:g,onClick:()=>{_("month"),C(O)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":k==="week",className:`bonsaif-cal-view-btn${k==="week"?" is-active":""}`,disabled:g,onClick:()=>{_("week"),N(on(A))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":k==="week"?"Semana anterior":"Mes anterior",disabled:g,onClick:X,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:V}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":k==="week"?"Semana siguiente":"Mes siguiente",disabled:g,onClick:de,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&k==="month"?" · Semana (nº)":"",k==="week"?" · Botón semana completa":""]}),k==="month"?t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:h,month:A,onMonthChange:C,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(H,I)=>{G(I)},disabled:U,className:"bonsaif-multi-daypicker",modifiers:Ga,modifiersClassNames:Za,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:ne,Weekday:Qa},formatters:{formatWeekdayName:Ka}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(H=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(H)},`h-${Dt(H)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(H=>{const I=Dt(H),le=E.has(I),L=g||(n?I<n:!1)||(a?I>a:!1)||!!(o!=null&&o(I)),oe=I===Dt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${le?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${L?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:L,"aria-pressed":le,onPointerDown:w=>Y(H,w),onPointerEnter:()=>K(H),onClick:w=>D(H,w),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:H.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(H)})]})},I)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:g,onClick:()=>G(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(H=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:g,onClick:()=>r==null?void 0:r(e.filter(I=>I!==H)),title:`Quitar ${H}`,children:[Ms(H),t.jsx("span",{"aria-hidden":!0,children:"×"})]},H))})]})}):null]})}const Cd=Array.from({length:12},(e,r)=>r);function Md({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(()=>Cs(e),[e]),f=ot(o),g=ot(l),h=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[E,v]=s.useState(h);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function S(k){v(k),a==null||a(k)}const{onDayPointerDown:A,onDayPointerEnter:C,onDayClick:O}=Ls({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${E}-`}),N=s.useCallback(k=>t.jsx(Ts,{...k,className:`bonsaif-year-day-btn ${k.className??""}`,onDayPointerDown:A,onDayPointerEnter:C,onDayClickSelect:O}),[O,A,C]),y=b.filter(k=>k.getFullYear()===E),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:()=>S(E-1),children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>S(E+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:Cd.map(k=>{const _=new Date(E,k,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(_))}),t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:y,month:_,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:M,className:"bonsaif-year-month-picker",modifiers:Ga,modifiersClassNames:Za,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:Qa},formatters:{formatWeekdayName:Y=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(Y)}})]},`${E}-${k}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",E]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(k=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(_=>_!==k)),title:`Quitar ${k}`,children:[Ms(k),t.jsx("span",{"aria-hidden":!0,children:"×"})]},k))})]})}):null]})}const Td="bonsaif-ui:hide-tooltips";function Os(){window.dispatchEvent(new CustomEvent(Td))}function $d(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ad({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({}),h=s.useRef(null),E=s.useRef(null),v=s.useCallback(N=>{u(N),c==null||c(N)},[c]),S=s.useCallback(()=>{const N=h.current;if(!N)return;const y=N.getBoundingClientRect(),M=typeof a=="number"?a:y.width,k=typeof a=="number"?a:Math.max(y.width,180),_=n==="end"?Math.max(8,y.right-k):Math.min(y.left,window.innerWidth-k-8),Y=window.innerHeight-y.bottom,K=Y<240&&y.top>Y?void 0:y.bottom+6,D=K===void 0?window.innerHeight-y.top+6:void 0;g({position:"fixed",zIndex:9999,left:_,top:K,bottom:D,width:$d(typeof a=="number"?M:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;S();const N=M=>{var _,Y;const k=M.target;!((_=h.current)!=null&&_.contains(k))&&!((Y=E.current)!=null&&Y.contains(k))&&v(!1)},y=M=>{M.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",y),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",y),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[d,v,S]);const A=N=>{o||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),v(!d))},C=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(Os(),v(!d))}}):e,O=d?t.jsx("div",{ref:E,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style: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 y;N.disabled||(Os(),(y=N.onSelect)==null||y.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:h,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:A,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[C,m&&O?ht.createPortal(O,document.body):null]})}const Ld=180,Hs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Dd({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:h="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:E="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:S,disabled:A=!1,disabledMessage:C,children:O}){const[N,y]=s.useState(!1),[M,k]=s.useState(!1),[_,Y]=s.useState(!1),K=s.useCallback(()=>{k(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>Y(!0))})},[]),D=s.useCallback(()=>{Y(!1),window.setTimeout(()=>k(!1),Ld)},[]),G=A||c,U=s.useCallback(()=>{if(!G){if(f){K();return}r()}},[G,f,r,K]),ne=s.useCallback(()=>{Y(!1),k(!1),S==null||S(),r()},[r,S]);if(s.useEffect(()=>{y(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(Y(!1),k(!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 J=C!==void 0?C:c?"Guardando…":null;return ht.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${Hs}`,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(Ve,{variant:"icon",onClick:U,title:"Cerrar",disabled:G,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(Ve,{variant:"secondary",size:"sm",onClick:U,disabled:G,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ve,{variant:"primary",size:"sm",icon:t.jsx(Ki.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: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})]}),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 ${Hs} transition-opacity duration-200 ease-out ${_?"opacity-100":"opacity-0"}`,onClick:D}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${_?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ve,{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(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:g}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:h}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ve,{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(Ve,{variant:"secondary",onClick:ne,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:E})]})]})]})]}),document.body)}const Od=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Hd=/^\+?[0-9\s().-]+$/,Id=7,Bd=15;function Ft(e){return e==null||String(e).trim()===""}function Is(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function Ja(e){return Ft(e)?!1:Od.test(String(e))}function Ra(e){if(Ft(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Hd.test(r)&&n.length>=Id&&n.length<=Bd}function Fd(e="Este campo es requerido."){return r=>Ft(r)?e:void 0}function Pd(e="Ingresa un correo valido."){return r=>Ft(r)||Ja(r)?void 0:e}function _d(e="Ingresa un telefono valido."){return r=>Ft(r)||Ra(r)?void 0:e}function zd(e,r){return n=>Ft(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Wd(e,r){return n=>Ft(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function jd(e,r){return n=>{if(Ft(n))return;const a=Is(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function qd(e,r){return n=>{if(Ft(n))return;const a=Is(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Ud(e,r="El formato no es valido."){return n=>Ft(n)||e.test(String(n))?void 0:r}function Vd(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 Bs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Fs=s.createContext&&s.createContext(Bs),Xd=["attr","size","title"];function Yd(e,r){if(e==null)return{};var n,a,o=Kd(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 Kd(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 Fn(){return Fn=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},Fn.apply(null,arguments)}function Ps(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 Pn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ps(Object(n),!0).forEach(function(a){Gd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ps(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Gd(e,r,n){return(r=Zd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Zd(e){var r=Qd(e,"string");return typeof r=="symbol"?r:r+""}function Qd(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 _s(e){return e&&e.map((r,n)=>s.createElement(r.tag,Pn({key:n},r.attr),_s(r.child)))}function eo(e){return r=>s.createElement(Jd,Fn({attr:Pn({},e.attr)},r),_s(e.child))}function Jd(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Yd(e,Xd),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Fn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Pn(Pn({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 Fs!==void 0?s.createElement(Fs.Consumer,null,n=>r(n)):r(Bs)}function zs(e){return eo({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 Rd(e){return eo({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 eu(e){return eo({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 Mr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Bt,{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 Tr({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 _n({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 to({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[h,E]=s.useState(()=>!!g.autoFocus),[v,S]=s.useState(!1),A=g.type==="password"&&u,C=A&&v?"text":g.type,O=!!o,N=O&&l!=="tooltip",y=O&&l!=="inline",M=!!n&&a==="tooltip"&&!N,k=m?f:void 0,_=O?"border-[var(--danger)] focus:border-[var(--danger)]":"",Y=y?A?"pr-20":"pr-10":A?"pr-10":"",K=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,D=h||K,G={top:D?7:12,color:h?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},U=X=>{var de;E(!0),(de=g.onFocus)==null||de.call(g,X)},ne=X=>{var de;E(!1),(de=g.onBlur)==null||de.call(g,X)},J=A?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:()=>S(X=>!X),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(Rd,{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(eu,{className:"h-[18px] w-[18px]"})})]}):null,R=y?t.jsx(Bt,{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)] ${A?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(zs,{className:"h-[18px] w-[18px]"})})}):null,V=t.jsx(Tr,{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(_n,{...g,type:C,required:k,placeholder:" ","aria-invalid":O||g["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${Y} ${_} ${b}`,onFocus:U,onBlur:ne}),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,J]}),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(Mr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),A?t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,type:C,required:k,"aria-invalid":O||g["aria-invalid"],className:`w-full ${Y} ${_} ${b}`,onFocus:U,onBlur:ne}),R,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,required:k,"aria-invalid":O||g["aria-invalid"],className:`w-full ${Y} ${_} ${b}`}),R]}),V]})}function Ws(e){return e==null?"":String(e)}function tu({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=s.useState(()=>Ws(c)),f=i!==void 0?Ws(i):m,g=n&&f.length>0&&!Ja(f)?a:void 0,h=E=>{i===void 0&&b(E.currentTarget.value),d==null||d(E)};return t.jsx(to,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:o,onChange:h})}const ru={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function nu(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function js(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),o=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?o.startsWith(n.slice(0,-1)):o===n}):!0}function au(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function ou({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:h="Buscar archivos",dropLabel:E="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:S="o haz click para buscarlos en tu equipo",selectedLabel:A="Archivos seleccionados",size:C="md",containerClassName:O="",dropzoneClassName:N="",fileListClassName:y="",className:M="",id:k,accept:_,disabled:Y,required:K,...D}){const G=s.useId(),U=k??G,ne=s.useRef(null),[J,R]=s.useState(!1),[V,X]=s.useState(i),de=l??V,H=!!a,I=!!r&&n==="tooltip"&&!H,le=g&&de.length>0&&!Y,L=(T,ee)=>{l===void 0&&X(T),c==null||c(T,ee)},oe=(T,ee)=>{const fe=T.filter(ye=>js(ye,_)),ie=T.filter(ye=>!js(ye,_)),pe=b?[...de,...fe]:fe,ae=au(pe,u,m);ie.length>0&&(d==null||d(ie)),L(ae,ee)},w=()=>{var T;Y||(T=ne.current)==null||T.click()},te=T=>{oe(Array.from(T.target.files??[]),T),T.target.value=""},B=T=>{T.preventDefault(),Y||R(!0)},F=T=>{T.currentTarget.contains(T.relatedTarget)||R(!1)},ue=T=>{T.preventDefault(),R(!1),!Y&&oe(Array.from(T.dataTransfer.files),T)},re=T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),w())},j=T=>{L(de.filter((ee,fe)=>fe!==T))},x=()=>{L([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${O}`,children:[(e||o||I)&&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:"*"}),I?t.jsx(Mr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:ne,id:U,type:"file",accept:_,multiple:u,disabled:Y,required:K&&de.length===0,"aria-invalid":H||D["aria-invalid"],className:"sr-only",onChange:te}),t.jsxs("div",{role:"button",tabIndex:Y?-1:0,"aria-controls":U,"aria-disabled":Y||void 0,"aria-invalid":H||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)] ${ru[C]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":H?"border-[var(--danger)]":"border-[var(--border)]"} ${Y?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${N} ${M}`,onClick:w,onDragOver:B,onDragLeave:F,onDrop:ue,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(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?E:v}),S&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:S})]}),h&&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:h})]}),f&&de.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${y}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:A}),le&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:x,children:t.jsx(W.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:de.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:nu(T.size)})]}),!Y&&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(Tr,{error:a,helperText:r,helperDisplay:n})]})}const su=[{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 lu({fields:e,title:r="Layout",fieldTypes:n=su,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(C=>({key:!1,type:"",...C}))),[f,g]=s.useState(""),[h,E]=s.useState(""),v=s.useCallback((C,O)=>{b(N=>{const y=N.map((M,k)=>k===C?{...M,...O}:M);return u==null||u(y),y})},[u]),S=s.useCallback(()=>{d==null||d(m)},[m,d]),A=s.useCallback(()=>{var y;const C=f.trim();if(!C){E("Ingresa un nombre de campo.");return}if(m.some(M=>M.name.toLowerCase()===C.toLowerCase())){E("Ese campo ya existe en el arreglo.");return}const N={name:C,key:!1,type:((y=n[0])==null?void 0:y.value)??""};b(M=>{const k=[...M,N];return u==null||u(k),k}),g(""),E("")},[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((C,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:C.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Mn,{size:"sm",checked:C.key??!1,onChange:N=>v(O,{key:N.target.checked}),"aria-label":`${C.name} es clave`})}),t.jsx(dr,{value:C.type??"",onChange:N=>v(O,{type:N}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${C.name}`})]},C.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:C=>{g(C.currentTarget.value),h&&E("")},onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),A())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ve,{variant:"secondary",onClick:A,height:36,padding:"0 12px",children:i})]}),h&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:h})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ve,{variant:"primary",onClick:S,disabled:c,loading:c,children:a})})]})})]})}function zn({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(Mr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Tr,{error:o,helperText:n,helperDisplay:a})]})}function iu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function qs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=iu(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,$r=420,ro=380,Pt="cubic-bezier(0.22, 1, 0.36, 1)",cu="cubic-bezier(0.16, 1, 0.3, 1)",no="cubic-bezier(0.22, 1, 0.36, 1)",du="cubic-bezier(0.22, 1, 0.36, 1)",uu=8,fu=1,bu=1.25,ao={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)"},mu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",oo=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function pu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Us(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 Ar({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:{...ao,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=mu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(ao.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 Vs({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=uu,minZoom:c=fu,zoomStep:d=bu,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:h=!0,zIndex:E=1100,ariaLabel:v="Visor de imagen"}){const[S,A]=s.useState(!1),[C,O]=s.useState(!1),[N,y]=s.useState(a??0),[M,k]=s.useState(1),[_,Y]=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}),[ne,J]=s.useState(!1),R=s.useRef(null),V=s.useRef(null),X=s.useRef(null),de=s.useRef(null),H=s.useRef(null),I=s.useRef(!1),le=s.useRef(!1),L=s.useRef(null),oe=s.useRef(null),w=s.useRef(null),te=s.useRef(null),B=s.useRef(null),F=s.useRef(a??0),ue=a??N,re=n.length===0?0:sn(ue,0,Math.max(0,n.length-1)),j=n[re],x=n.length>1,T=Math.max(c,i),ee=h&&x,fe=s.useCallback(me=>{if(n.length===0)return;const ge=n.length-1,Ae=g?(me%n.length+n.length)%n.length:sn(me,0,ge);a===void 0&&y(Ae),o==null||o(Ae)},[a,g,o,n.length]),ie=s.useCallback(()=>{k(1),Y({x:0,y:0})},[]),pe=s.useCallback((me,ge)=>{if(ge<=c+.001)return{x:0,y:0};const Ae=te.current,Fe=B.current;if(!Ae||!Fe)return me;const Oe=Ae.getBoundingClientRect(),bt=Fe.offsetWidth*ge,ct=Fe.offsetHeight*ge,ze=Math.max(0,(bt-Oe.width)/2+Oe.width*.15),je=Math.max(0,(ct-Oe.height)/2+Oe.height*.15);return{x:sn(me.x,-ze,ze),y:sn(me.y,-je,je)}},[c]),ae=s.useCallback(()=>{A(!1),U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),de.current=null,H.current=null,I.current=!1,le.current=!1,L.current&&(clearTimeout(L.current),L.current=null)},[]),ye=s.useCallback(()=>{if(I.current)return;I.current=!0,O(!1),ie();const me=de.current,ge=me!=null&&H.current!=null&&H.current===re;if(me&&ge){X.current!=null&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{X.current=requestAnimationFrame(()=>{const Ae=B.current;if(!Ae){X.current=null,R.current&&clearTimeout(R.current),R.current=setTimeout(ae,Ot+40);return}const Fe=Ae.getBoundingClientRect(),Oe=Us(me,Fe);U({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),X.current=requestAnimationFrame(()=>{U({enabled:!0,dx:Oe.dx,dy:Oe.dy,scale:Oe.scale,animate:!0}),X.current=null})})}),R.current&&clearTimeout(R.current),R.current=setTimeout(ae,$r+80);return}U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),R.current&&clearTimeout(R.current),R.current=setTimeout(ae,Ot+40)},[ae,ie,re]);s.useEffect(()=>(e?(R.current&&clearTimeout(R.current),L.current&&(clearTimeout(L.current),L.current=null),I.current=!1,le.current=!1,de.current=pu(l),H.current=de.current!=null?a??N:null,A(!0),O(!1),de.current?U({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(H.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{O(!0),U({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):S&&ye(),()=>{R.current&&clearTimeout(R.current),X.current!=null&&cancelAnimationFrame(X.current)}),[e]);const Qe=s.useCallback(()=>{if(!e||I.current||le.current)return;const me=de.current,ge=B.current;if(!me||!ge){me||(O(!0),le.current=!0);return}const Ae=ge.getBoundingClientRect();if(Ae.width<2||Ae.height<2)return;le.current=!0;const Fe=Us(me,Ae);U({enabled:!0,dx:Fe.dx,dy:Fe.dy,scale:Fe.scale,animate:!1}),X.current!=null&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{X.current=requestAnimationFrame(()=>{U({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),O(!0),X.current=null,L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{U({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),L.current=null},$r+20)})})},[e]);s.useLayoutEffect(()=>{!S||!e||!de.current||le.current||Qe()},[S,e,Qe]),s.useEffect(()=>{!e||I.current||H.current!=null&&H.current!==re&&U(me=>me.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:me)},[e,re]),s.useEffect(()=>{if(!e)return;const me=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=me}},[e]),s.useEffect(()=>{e&&ie()},[e,re,ie]),s.useEffect(()=>{a!==void 0&&y(a)},[a]),s.useEffect(()=>{if(!e){F.current=re,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const me=F.current;if(me===re)return;F.current=re;const ge=n.length;let Ae=1;if(ge>1){const Fe=(me+1)%ge===re,Oe=(me-1+ge)%ge===re;Oe&&!Fe?Ae=-1:Fe&&!Oe?Ae=1:Ae=re>me?1:-1}return V.current!=null&&(cancelAnimationFrame(V.current),V.current=null),D({opacity:0,x:Ae*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 Je=M<=c+.001&&Math.abs(_.x)<.5&&Math.abs(_.y)<.5,et=s.useCallback((me,ge,Ae)=>{k(Fe=>{const Oe=sn(me,c,T);if(Math.abs(Oe-Fe)<1e-4)return Fe;const bt=Oe/Fe,ct=Oe<Fe;return Oe<=c+.001?(Y({x:0,y:0}),c):(Y(ze=>{let je=ze;if(typeof ge=="number"&&typeof Ae=="number"&&te.current&&!ct){const dt=te.current.getBoundingClientRect(),mt=ge-dt.left-dt.width/2,br=Ae-dt.top-dt.height/2;je={x:mt-(mt-ze.x)*bt,y:br-(br-ze.y)*bt}}else if(ct){je={x:ze.x*bt,y:ze.y*bt};const dt=Math.min(1,(Fe-Oe)/Math.max(.01,Fe-c));je={x:je.x*(1-dt*.65),y:je.y*(1-dt*.65)}}else je={x:ze.x*bt,y:ze.y*bt};return pe(je,Oe)}),Oe)})},[pe,c,T]),ft=s.useCallback(()=>{et(M*d)},[et,M,d]),nt=s.useCallback(()=>{const me=Math.max(c,M/d);if(me<=c+.001){ie();return}k(me),Y({x:0,y:0})},[c,ie,M,d]);s.useEffect(()=>{if(!e)return;const me=ge=>{if(ge.key==="Escape"&&m){ge.preventDefault(),r();return}ge.key==="ArrowLeft"&&x?(ge.preventDefault(),fe(re-1)):ge.key==="ArrowRight"&&x?(ge.preventDefault(),fe(re+1)):ge.key==="+"||ge.key==="="?(ge.preventDefault(),et(M*d)):ge.key==="-"||ge.key==="_"?(ge.preventDefault(),nt()):ge.key==="0"&&(ge.preventDefault(),ie())};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[et,m,x,r,e,ie,re,M,fe,nt,d]);const Le=me=>{me.preventDefault();const ge=me.deltaY>0?1/d:d;et(M*ge,me.clientX,me.clientY)},ce=me=>{M<=c+.001||(me.currentTarget.setPointerCapture(me.pointerId),J(!0),oe.current={pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,originX:_.x,originY:_.y})},Pe=me=>{const ge=oe.current;!ge||ge.pointerId!==me.pointerId||Y(pe({x:ge.originX+(me.clientX-ge.startX),y:ge.originY+(me.clientY-ge.startY)},M))},_e=me=>{var ge;((ge=oe.current)==null?void 0:ge.pointerId)===me.pointerId&&(oe.current=null,J(!1))},at=me=>{if(me.stopPropagation(),M>c+.05){ie();return}et(Math.min(T,3),me.clientX,me.clientY)},Xe=me=>{if(me.touches.length!==2)return;J(!0);const[ge,Ae]=[me.touches[0],me.touches[1]],Fe=Math.hypot(ge.clientX-Ae.clientX,ge.clientY-Ae.clientY);w.current={distance:Fe,scale:M}},Ct=me=>{if(me.touches.length!==2||!w.current)return;me.preventDefault();const[ge,Ae]=[me.touches[0],me.touches[1]],Fe=Math.hypot(ge.clientX-Ae.clientX,ge.clientY-Ae.clientY),Oe=(ge.clientX+Ae.clientX)/2,bt=(ge.clientY+Ae.clientY)/2,ct=w.current.scale*(Fe/Math.max(1,w.current.distance));et(ct,Oe,bt)},lt=()=>{w.current=null,J(!1)};if(!S||!j)return null;const it=G.enabled,Xt=G.animate?`transform ${$r}ms ${du}`:"none";return ht.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:E},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:C?1:0,transition:`opacity ${it?$r:Ot}ms ${Pt}`,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:it||C?1:0,transform:it||C?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:it?"none":`opacity ${Ot}ms ${Pt}, transform ${Ot}ms ${Pt}`},onClick:me=>{me.target===me.currentTarget&&u&&r()},onWheel:Le,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?Xt: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 ${ro}ms ${no}`,`transform ${ro}ms ${no}`,`filter ${ro}ms ${no}`].join(", "):"none"},children:t.jsx("div",{ref:B,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:M>c+.001?"grab":"zoom-in",transform:`translate3d(${_.x}px, ${_.y}px, 0) scale(${M})`,transformOrigin:"center center",transition:ne?"none":`transform 220ms ${cu}`},onClick:me=>me.stopPropagation(),onDoubleClick:at,onPointerDown:ce,onPointerMove:Pe,onPointerUp:_e,onPointerCancel:_e,onTouchStart:Xe,onTouchMove:Ct,onTouchEnd:lt,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:oo,imageRendering:M>2.5?"pixelated":"auto"},onLoad:()=>{Qe()}},j.src+String(re))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:C?1:0,transform:C?"translateY(0)":"translateY(-6px)",transition:`opacity ${it?$r:Ot}ms ${Pt}, transform ${it?$r:Ot}ms ${Pt}`},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:ao,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(Ar,{label:"Alejar",onClick:nt,disabled:M<=c+.001,children:t.jsx(W.HiMinus,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Restablecer tamaño",onClick:ie,disabled:Je,children:t.jsx(W.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Acercar",onClick:ft,disabled:M>=T-.001,children:t.jsx(W.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Ar,{label:"Cerrar",onClick:r,children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:C?1:0,transform:C?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ot}ms ${Pt}, transform ${Ot}ms ${Pt}`},children:t.jsx(Ar,{label:"Anterior",size:"lg",onClick:()=>fe(re-1),disabled:!g&&re<=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:C?1:0,transform:C?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ot}ms ${Pt}, transform ${Ot}ms ${Pt}`},children:t.jsx(Ar,{label:"Siguiente",size:"lg",onClick:()=>fe(re+1),disabled:!g&&re>=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((me,ge)=>{const Ae=ge===re;return t.jsx("button",{type:"button",role:"tab","aria-selected":Ae,"aria-label":me.alt||`Imagen ${ge+1}`,onClick:Fe=>{Fe.stopPropagation(),fe(ge)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:oo,opacity:Ae?1:.42,transition:`opacity 180ms ${Pt}`},children:t.jsx("img",{src:me.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:oo}})},`${me.src}-${ge}`)})})}):null]})]}),document.body)}function hu({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([]),[h,E]=s.useState(null),v=s.useCallback((A,C,O)=>{g(A),E(O??null),b(C),u(!0)},[]),S=s.useCallback(A=>{qs(A,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:S,children:e}),t.jsx(Vs,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:h,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Xs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ys(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function so(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function gu(e,r){if(!r)return!0;const n=so(r);return so(e.label).includes(n)||!!(e.sublabel&&so(e.sublabel).includes(n))}function vu({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:g=!0,emptyText:h="Sin resultados",clearLabel:E="Limpiar seleccion",pruneMissingValues:v=!0}){const[S,A]=s.useState(!1),[C,O]=s.useState(""),[N,y]=s.useState(0),[M,k]=s.useState(!1),[_,Y]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),U=s.useRef(null),ne=u&&n.length>=m,J=s.useMemo(()=>new Set(e),[e]),R=s.useMemo(()=>{const x=new Map;for(const T of n)x.set(T.value,T);return x},[n]),V=s.useMemo(()=>{const x=[];for(const T of e){const ee=R.get(T);ee&&x.push(ee)}return x},[R,e]),X=b==="all"?V.length:b,de=V.slice(0,X),H=Math.max(0,V.length-de.length),I=g&&V.length>1,le=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(x=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[x.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:x.label}),x.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:x.sublabel}):null]},x.value))})]}),L=s.useMemo(()=>{const x=C.trim();return!ne||!x?n:n.filter(T=>gu(T,x))},[n,C,ne]),oe=s.useCallback(()=>{const x=K.current;if(!x)return;const T=x.getBoundingClientRect(),ee=ne?304:244,fe=window.innerHeight-T.bottom,ie=fe<ee&&T.top>fe;Y({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})},[ne]),w=s.useCallback(x=>{Ys(e,x)||r(x)},[r,e]),te=s.useCallback(x=>{const T=R.get(x);if(T!=null&&T.disabled)return;const ee=J.has(x)?e.filter(fe=>fe!==x):[...e,x];w(ee)},[w,R,e,J]),B=s.useCallback(()=>w([]),[w]),F=s.useCallback(()=>{A(!1),O(""),y(0)},[]);s.useEffect(()=>k(!0),[]);const ue=s.useMemo(()=>n.map(x=>x.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const x=new Set(n.map(ee=>ee.value)),T=e.filter(ee=>x.has(ee));Ys(e,T)||r(T)},[ue]),s.useEffect(()=>{if(!S)return;function x(T){var fe,ie;const ee=T.target;!((fe=K.current)!=null&&fe.contains(ee))&&!((ie=D.current)!=null&&ie.contains(ee))&&F()}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[F,S]),s.useEffect(()=>{S&&(y(0),oe(),ne&&setTimeout(()=>{var x;return(x=G.current)==null?void 0:x.focus()},0))},[S,ne,oe]),s.useEffect(()=>{if(S)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[S,oe]),s.useEffect(()=>{if(L.length===0){y(0);return}y(x=>Math.min(x,L.length-1))},[L.length]),s.useEffect(()=>{if(N<0||!U.current)return;const x=U.current.children[N];x==null||x.scrollIntoView({block:"nearest"})},[N]);function re(x){if(!o){if(!S){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),A(!0));return}if(x.key==="Escape"){x.preventDefault(),F();return}if(x.key==="ArrowDown"){if(x.preventDefault(),L.length===0)return;y(T=>Math.min(T+1,L.length-1));return}if(x.key==="ArrowUp"){x.preventDefault(),y(T=>Math.max(T-1,0));return}if(x.key==="Enter"&&L[N]&&!L[N].disabled){x.preventDefault(),te(L[N].value);return}x.key==="Backspace"&&!C&&e.length&&(x.preventDefault(),w(e.slice(0,-1)))}}const j=t.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{..._,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&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:G,value:C,onChange:x=>{O(x.target.value),y(0)},onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter"||x.key==="Escape")&&(x.stopPropagation(),re(x))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:x=>{x.preventDefault(),O(""),y(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:[V.length," seleccionados",e.length>V.length?` (${e.length-V.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:x=>{x.preventDefault(),B()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:E})]}),t.jsxs("ul",{ref:U,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ne?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[L.map((x,T)=>{const ee=T===N,fe=J.has(x.value);return t.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:ie=>{ie.preventDefault(),!x.disabled&&te(x.value)},onMouseEnter:()=>!x.disabled&&y(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:x.disabled?"var(--text-muted)":"var(--text-main)",cursor:x.disabled?"not-allowed":"pointer",opacity:x.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor: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"})}),x.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(qt,{className:"min-w-0 flex-1",children:x.label}),x.sublabel&&t.jsx(qt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:x.sublabel})]}),x.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:x.badge})]},x.value)}),L.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:h})]})]});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||(S?F():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Xs(c),padding:Xs(d),background:"var(--bg-input)",color:V.length?"var(--text-main)":"var(--text-muted)",border:S?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":S,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:de.length?(()=>{const x=t.jsxs(t.Fragment,{children:[de.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(qt,{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(),te(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)),H>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":`${H} seleccionados más`,children:["+",H]})]});return I?t.jsx(Bt,{as:"span",content:le,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:x}):x})():t.jsx("span",{className:"truncate",children:a})}),V.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":E,onMouseDown:x=>{x.preventDefault(),x.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:"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:S?"rotate(180deg)":"rotate(0deg)"}})]}),S&&M&&ht.createPortal(j,document.body)]})}function yu({inputMode:e="decimal",...r}){return t.jsx(to,{...r,type:"number",inputMode:e})}function xu(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 wu({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=xu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ve,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(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(Ve,{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 Ks=[{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 Gs(e){return e==null?"":String(e)}function Wn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Nu(e){return typeof e=="number"?`${e}px`:e}function ku({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:h="Codigo",countryCodeClassName:E="",countryCodeWidth:v=84,onPhoneValueChange:S,label:A,containerClassName:C="",helperText:O,helperDisplay:N="inline",labelAction:y,className:M="",required:k,disabled:_,floatingLabel:Y,showPasswordToggle:K,nativeValidation:D,errorTooltipLabel:G="Error de validacion",...U}){var T;const[ne,J]=s.useState(()=>Gs(c)),[R,V]=s.useState(()=>Wn(m)),X=s.useMemo(()=>{const ee=g??Ks,fe=f==null?void 0:f.map(Wn);return fe!=null&&fe.length?ee.filter(ie=>fe.includes(ie.value)):ee},[f,g]),de=((T=X[0])==null?void 0:T.value)??"+1",H=X.some(ee=>ee.value===Wn(u??R))?Wn(u??R):de,I=i!==void 0?Gs(i):ne,le=`${H} ${I}`.trim(),L=n&&I.length>0&&!Ra(le)?a:void 0,oe=l??L,w=!!oe,te=w&&o!=="tooltip",B=w&&o!=="inline",F=!!O&&N==="tooltip"&&!te,ue=w?"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&&J(fe),S==null||S(fe,{countryCode:H,nationalNumber:fe,fullNumber:`${H} ${fe}`.trim()}),d==null||d(ee)},j=ee=>{u===void 0&&V(ee),b==null||b(ee),S==null||S(I,{countryCode:ee,nationalNumber:I,fullNumber:`${ee} ${I}`.trim()})},x=B?t.jsx(Bt,{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(zs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${C}`,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:A}),k&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),F?t.jsx(Mr,{content:O}):null,y&&t.jsx("span",{className:"ml-auto normal-case",children:y})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${ue}`,children:[t.jsx(dr,{value:H,onChange:j,options:X,placeholder:h,disabled:_,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${E}`,style:{width:Nu(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:_,required:void 0,"aria-label":U["aria-label"]??(typeof A=="string"?A:void 0),"aria-invalid":w||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 ${B?"pr-10":""} ${M}`,onChange:re}),x]})]}),t.jsx(Tr,{error:te?oe:void 0,helperText:O,helperDisplay:N})]})}function Su({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 Eu=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),jn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Lr=12,qn=8,lo=(e,r,n)=>{const a=Vn(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},Zs=(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>=Lr?null:lo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Lr)return null;const o=Array.from(a.rows).indexOf(n);return lo(a,o+1,e)},Cu=(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)},Qs=(e,r)=>Vn(e)>=qn?!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),Mu=(e,r)=>Vn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Js=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")})},Rs=(e,r,n)=>{Js(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")}))},Tu=(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}}},Un=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},el=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},$u=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Zs(r,n):io(r);return l&&Xn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Cu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Qs(r,a):Ou(r);case"table-col-del":return Number.isFinite(a)?Mu(r,a):!1;default:return!1}},Vn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Au=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},tl=e=>(e==null?void 0:e.closest("table"))??null,rl=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},Lu=e=>Array.from(e.querySelectorAll("th, td")),nl=(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]},Du=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)},io=e=>{const r=Au(e);if(r.length>=Lr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return lo(a,0,e)}return Zs(e,Array.from(e.rows).indexOf(n))},Ou=e=>{const r=Vn(e)-1;return r<0?!1:Qs(e,r)},co=e=>{el(e)},Hu=(e,r,n)=>{const a=jn(e,1,Lr),o=jn(r,1,qn),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},al=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',ln=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),ol=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),Iu=e=>e.replace(/[<>]/g,"").toLowerCase(),Bu=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"]),Fu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Pu=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},Yn=(e,r)=>r.test(e),_u=e=>Yn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),zu=e=>Yn(e,/font-style\s*:\s*italic/i),Wu=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),ju=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Kn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},Gn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},qu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},sl=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"},Uu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Fu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Vu=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&&(_u(a)&&Kn(n,"strong"),zu(a)&&Kn(n,"em"),Wu(a)&&Kn(n,"u"),ju(a)&&Kn(n,"s"))})},Xu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(qu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=sl(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(sl(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=>{Uu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Yu=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Ku=e=>{const r=Pu(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()),Vu(o),Xu(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"){Gn(d),c.forEach(l);return}if(!Bu.has(u)){Gn(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=Yu(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Eu.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){Gn(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"){Gn(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()},uo=e=>ln(e).replace(/\r\n?/g,`
25
+ `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Gu=e=>new RegExp("\\p{L}","u").test(e),fo=(e,r)=>{const n=e.trim();return!n||!Gu(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===ol(n)},ll=e=>{const r=a=>{var o,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(o=a.parentNode)==null||o.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",al())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const o=a.src;a.src="",a.src=o}});const n=a=>{const o=a.target;o.tagName==="IMG"&&r(o)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function il({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),h=s.useRef(e??""),E=s.useRef(r),v=s.useRef(()=>{}),S=s.useRef(!1),[A,C]=s.useState(()=>!e||e.trim()===""),[O,N]=s.useState(new Set),[y,M]=s.useState(null),[k,_]=s.useState(""),[Y,K]=s.useState(""),[D,G]=s.useState(""),[U,ne]=s.useState(""),[J,R]=s.useState(3),[V,X]=s.useState(3),[de,H]=s.useState(!0),[I,le]=s.useState(!1),[L,oe]=s.useState(l==="full"),[w,te]=s.useState(null),[B,F]=s.useState(null),ue=s.useRef(null),re=s.useRef(!1),j=s.useRef(null),x=s.useCallback(()=>g.current?m.current:u.current,[]);s.useEffect(()=>{E.current=r},[r]);const T=s.useCallback(()=>{const z=window.getSelection(),Z=x();if(!z||!Z||z.rangeCount===0||z.isCollapsed)return"";const be=z.getRangeAt(0);return!Z.contains(be.startContainer)||!Z.contains(be.endContainer)?"":z.toString()},[x]);s.useEffect(()=>{const z=e??"";if(S.current&&z===h.current){S.current=!1,C(!z||z.trim()==="");return}S.current=!1,h.current=z;const Z=[u.current,m.current].filter(he=>!!he);Z.forEach(he=>{he.innerHTML!==z&&(he.innerHTML=z)}),C(!z||z.trim()===""),Z.forEach(he=>co(he));const be=Z.map(he=>ll(he));return()=>be.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Ee;g.current=I;let z,Z=0,be;if(I){const xe=u.current;xe&&(h.current=Un(xe));const He=()=>{var Ye;const De=m.current;if(!De){Z=requestAnimationFrame(He);return}De.innerHTML!==h.current&&(De.innerHTML=h.current),z=ll(De),co(De),C(((Ye=De.textContent)==null?void 0:Ye.trim())===""),be=setTimeout(()=>De.focus(),60)};Z=requestAnimationFrame(He)}else{const xe=m.current,He=u.current,De=xe?Un(xe):h.current,Ye=h.current;h.current=De,He&&He.innerHTML!==De&&(He.innerHTML=De),De!==Ye&&E.current(De),C(((Ee=(he=xe??He)==null?void 0:he.textContent)==null?void 0:Ee.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),be&&clearTimeout(be),z==null||z()}},[I]);const ee=s.useCallback(()=>{const z=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;z.forEach(he=>{try{d().queryCommandState(he)&&Z.add(he)}catch{return}});try{const he=Iu(d().queryCommandValue("formatBlock"));he&&Z.add(`formatBlock:${he}`)}catch{}const be=T();fo(be,"uppercase")&&Z.add("__upper"),fo(be,"lowercase")&&Z.add("__lower"),fo(be,"capitalize")&&Z.add("__cap"),N(Z)},[T,d]),fe=()=>{var Z;const z=x();z&&(h.current=Un(z),S.current=!0,E.current(h.current),C(((Z=z.textContent)==null?void 0:Z.trim())===""))};v.current=fe;const ie=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),ue.current&&(Js(ue.current),ue.current=null),re.current=!1,te(null),F(null)},[]),pe=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null)},[]),ae=s.useCallback(()=>{pe(),j.current=setTimeout(()=>{re.current||ie()},280)},[pe,ie]);s.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const ye=s.useCallback(z=>{const Z=ue.current;if(!Z||!Z.isConnected){ie();return}const be=(w==null?void 0:w.rowIndex)??(B==null?void 0:B.rowIndex)??-1,he=(w==null?void 0:w.colIndex)??(B==null?void 0:B.colIndex)??-1;$u(z,Z,be,he,x()),ie(),v.current(),ee()},[x,ie,ee,B,w]),Qe=s.useCallback(z=>{if(B)return;const Z=z.currentTarget,be=z.target;if(be.closest(".rich-table-action-bar, .rich-table-context-menu")){pe();return}const he=be.closest("td, th");if(!he||!Z.contains(he)){ae();return}const Ee=he.closest("tr"),xe=he.closest("table");if(!Ee||!xe||!Z.contains(xe)){ae();return}pe(),xe.classList.add("rich-table"),ue.current=xe,Rs(xe,Ee,he.cellIndex),te(Tu(xe,Ee,he))},[pe,ae,B]),Je=s.useCallback(z=>{const Z=z.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){pe();return}ae()},[pe,ae]),et=s.useCallback(z=>{const Z=z.currentTarget,he=z.target.closest("td, th");if(!he||!Z.contains(he))return;const Ee=he.closest("tr"),xe=he.closest("table");if(!Ee||!xe||!Z.contains(xe))return;z.preventDefault(),xe.classList.add("rich-table"),ue.current=xe;const He=Array.from(xe.rows).indexOf(Ee),De=he.cellIndex;Rs(xe,Ee,De),te(null),F({x:z.clientX,y:z.clientY,rowIndex:He,colIndex:De})},[]);s.useEffect(()=>{if(!w&&!B)return;const z=()=>ae();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[ae,B,w]),s.useEffect(()=>{if(!B)return;const z=Z=>{const be=Z.target;be instanceof Element&&be.closest(".rich-table-context-menu")||F(null)};return window.addEventListener("mousedown",z),()=>window.removeEventListener("mousedown",z)},[B]);const ft=z=>{if(!z){const Z=u.current;Z&&(h.current=Un(Z))}le(!z)},nt=(z,Z)=>{var be;(be=x())==null||be.focus(),d().execCommand(z,!1,Z),fe(),ee()},Le=z=>{nt("formatBlock",z)},ce=()=>{var z;(z=x())==null||z.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),fe(),ee()},Pe=()=>{const z=window.getSelection();z&&z.rangeCount>0&&(f.current=z.getRangeAt(0).cloneRange())},_e=()=>{const z=window.getSelection();z&&f.current&&(z.removeAllRanges(),z.addRange(f.current))},at=z=>{if(Pe(),z==="link"){const Z=window.getSelection();K(Z&&!Z.isCollapsed?Z.toString():""),_("")}z==="image"&&(G(""),ne("")),z==="table"&&(R(3),X(3),H(!0)),M(z)},Xe=()=>{var he;if(!k.trim())return;_e(),(he=x())==null||he.focus();const z=window.getSelection(),be=(z&&!z.isCollapsed?z.toString():"")||Y.trim()||k.trim();d().execCommand("insertHTML",!1,`<a href="${ln(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${ln(be)}</a>`),fe(),M(null)},Ct=(z,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${ln(z)}" alt="${ln(Z)}" class="rich-img" />${al()}</span>`,lt=()=>{var z;D.trim()&&(_e(),(z=x())==null||z.focus(),d().execCommand("insertHTML",!1,Ct(D.trim(),U.trim())),fe(),M(null))},it=()=>{var z;_e(),(z=x())==null||z.focus(),d().execCommand("insertHTML",!1,Hu(J,V,de)),fe(),M(null)},Xt=(z,Z=1200,be=1200,he=.72)=>new Promise((Ee,xe)=>{const He=new FileReader;He.onerror=xe,He.onload=De=>{var or;const Ye=(or=De.target)==null?void 0:or.result,Ke=new Image;Ke.onerror=xe,Ke.onload=()=>{let{width:vt,height:Yt}=Ke;if(vt>Z||Yt>be){const Kt=Math.min(Z/vt,be/Yt);vt=Math.round(vt*Kt),Yt=Math.round(Yt*Kt)}const Ht=document.createElement("canvas");Ht.width=vt,Ht.height=Yt;const sr=Ht.getContext("2d");if(!sr){Ee(Ye);return}sr.drawImage(Ke,0,0,vt,Yt),Ee(Ht.toDataURL("image/jpeg",he))},Ke.src=Ye},He.readAsDataURL(z)}),me=z=>{z.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!z.contains(Z.anchorNode)){const be=document.createRange();be.selectNodeContents(z),be.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(be)}},ge=s.useRef(()=>{});ge.current=z=>{const Z=x();Z&&(me(Z),d().execCommand("insertHTML",!1,z),co(Z),Z.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr, table")&&be.remove()}),fe(),ee())};const Ae=s.useRef(Xt);Ae.current=Xt;const Fe=s.useRef(Ct);Fe.current=Ct;const Oe=s.useCallback(z=>{if(!z||b.current.has(z))return;const Z=be=>{const he=be.clipboardData;if(!he)return;const Ee=he.getData("text/html"),xe=he.getData("text/plain");if(Ee||xe){be.preventDefault(),be.stopPropagation();try{const Ke=Ee?Ku(Ee):uo(xe);if(!Ke){xe&&ge.current(uo(xe));return}ge.current(Ke)}catch{xe&&ge.current(uo(xe))}return}const De=Array.from(he.items).find(Ke=>Ke.type.startsWith("image/"));if(!De)return;be.preventDefault(),be.stopPropagation();const Ye=De.getAsFile();Ye&&Ae.current(Ye).then(Ke=>{ge.current(Fe.current(Ke,"imagen"))})};z.addEventListener("paste",Z,!0),b.current.set(z,()=>{z.removeEventListener("paste",Z,!0),b.current.delete(z)})},[]),bt=s.useCallback(z=>{var be;const Z=u.current;Z&&Z!==z&&((be=b.current.get(Z))==null||be()),u.current=z,z&&Oe(z)},[Oe]),ct=s.useCallback(z=>{var be;const Z=m.current;Z&&Z!==z&&((be=b.current.get(Z))==null||be()),m.current=z,z&&Oe(z)},[Oe]);s.useEffect(()=>{const z=b.current;return()=>{z.forEach(Z=>Z()),z.clear()}},[]);const ze=z=>{const Z=window.getSelection(),be=x();if(!Z||!be||Z.rangeCount===0||Z.isCollapsed)return;const he=Z.getRangeAt(0);if(!be.contains(he.startContainer)||!be.contains(he.endContainer))return;const Ee=he.toString();if(!Ee)return;let xe=Ee;z==="uppercase"?xe=Ee.toLocaleUpperCase():z==="lowercase"?xe=Ee.toLocaleLowerCase():xe=ol(Ee),he.deleteContents();const He=document.createTextNode(xe);he.insertNode(He);const De=document.createRange();De.setStart(He,0),De.setEnd(He,xe.length),Z.removeAllRanges(),Z.addRange(De),f.current=De.cloneRange(),fe(),ee()},je=()=>{Pe(),ee()},dt=()=>{const z=x();z&&el(z),fe(),ee()},mt=()=>{requestAnimationFrame(()=>{var z;(z=x())==null||z.focus()})},br=z=>{var Z,be;if((z.metaKey||z.ctrlKey)&&z.key==="Enter"){if(z.preventDefault(),z.stopPropagation(),z.repeat)return;(Z=x())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),fe(),ee();return}if(z.key==="Tab"){const he=window.getSelection(),Ee=rl((he==null?void 0:he.anchorNode)??null),xe=x(),He=tl(Ee);if(Ee&&He&&(xe!=null&&xe.contains(Ee))){z.preventDefault();const De=Lu(He),Ye=De.indexOf(Ee),Ke=Ye>=0?De[Ye+1]:null;if(Ke)Xn(Ke,xe,!0);else if(nl(Ee,He)){const or=io(He);or&&Xn(or,xe,!0)}fe(),ee();return}z.preventDefault(),(be=x())==null||be.focus(),d().execCommand("insertText",!1,"    "),fe(),ee();return}if(z.key==="Enter"&&!z.shiftKey&&!(z.metaKey||z.ctrlKey)){const he=window.getSelection(),Ee=rl((he==null?void 0:he.anchorNode)??null),xe=x(),He=tl(Ee);if(Ee&&He&&(xe!=null&&xe.contains(Ee))&&nl(Ee,He)&&Du(Ee)){z.preventDefault();const De=io(He);De&&Xn(De,xe,!0),fe(),ee();return}}if(z.key==="Escape"){if(B){F(null);return}if(y){M(null);return}if(g.current){le(!1);return}}y||(z.ctrlKey||z.metaKey)&&(z.key==="b"&&(z.preventDefault(),nt("bold")),z.key==="i"&&(z.preventDefault(),nt("italic")),z.key==="u"&&(z.preventDefault(),nt("underline")),z.key==="k"&&(z.preventDefault(),at("link")))},ut=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Be=(z,Z,be,he,Ee)=>{const xe=Ee??(O.has(be)||be==="__link"&&y==="link"||be==="__img"&&y==="image"||be==="__table"&&y==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:mt,onMouseDown:He=>{He.preventDefault(),he?he():nt(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:xe?"var(--primary)":"var(--text-secondary)",background:xe?"rgba(59,130,246,0.12)":"transparent"},children:z},be)},vn=z=>{const Z=z.target;if(Z.closest("[data-action='delete-img']")){z.preventDefault();const be=Z.closest(".rich-img-wrap");be&&(be.remove(),fe())}},fa=()=>{pe(),re.current=!0},pt=()=>{re.current=!1,ae()},Mt=(z,Z,be,he=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${he?" rich-table-action-btn--danger":""}`,title:z,"aria-label":z,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),ye(be)},children:Z}),Tt=()=>typeof document>"u"||!w&&!B?null:ht.createPortal(t.jsxs(t.Fragment,{children:[w&&!B&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:w.bar.x,top:w.bar.y},onMouseEnter:fa,onMouseLeave:pt,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",w.rowIndex+1," · Col ",w.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)]}),B&&t.jsx("div",{className:"rich-table-context-menu",style:{left:B.x,top:B.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:be=>{be.preventDefault(),ye(Z)},children:z},Z))})]}),document.body),ar=z=>t.jsxs(t.Fragment,{children:[y==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:Z=>_(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Xe()),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:Y,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Xe()),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:Xe,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"})]}),y==="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:Lr,value:J,onChange:Z=>R(jn(Number(Z.target.value),1,Lr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),it()),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:qn,value:V,onChange:Z=>X(jn(Number(Z.target.value),1,qn)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),it()),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:de,onChange:Z=>H(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:it,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"})]}),y==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:D,onChange:Z=>G(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),lt()),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=>ne(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),lt()),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:lt,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"})]})]}),Wr=(z,Z)=>{const be=l==="compact",he=!be||L||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:[be&&!z&&t.jsxs("button",{type:"button",title:L?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),oe(xe=>!xe)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:L?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[L?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"}),L?"Ocultar herramientas":"Herramientas"]}),he&&t.jsxs(t.Fragment,{children:[Be(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Be(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Be(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Be(t.jsx(W.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Be(t.jsx(W.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Be(t.jsx(W.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>at("link")),ut(),Be(t.jsx(W.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Be(t.jsx(W.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),ut(),Be(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Le("p"),O.has("formatBlock:p")||O.has("formatBlock:div")),Be(t.jsx(W.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Le("h2"),O.has("formatBlock:h2")),Be(t.jsx(W.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Le("h3"),O.has("formatBlock:h3")),Be(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Le("blockquote"),O.has("formatBlock:blockquote")),ut(),Be(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),ut(),Be(t.jsx(W.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Be(t.jsx(W.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),ut(),Be(t.jsx(W.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Be(t.jsx(W.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Be(t.jsx(W.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Be(t.jsx(W.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),ut(),Be(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>ze("uppercase")),Be(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>ze("lowercase")),Be(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>ze("capitalize")),ut(),Be(t.jsx(W.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Be(t.jsx(W.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>at("image")),Be(t.jsx(W.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>at("table")),Be(t.jsx(W.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",ce),ut(),Be(t.jsx(W.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Be(t.jsx(W.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Le("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(),ft(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:br,onKeyUp:je,onSelect:je,onMouseUp:je,onMouseMove:Qe,onMouseLeave:Je,onContextMenu:et,onMouseDown:vn,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ar("var(--bg-input)"),Wr(!1,"var(--bg-input)")]}),t.jsxs(Xa,{open:I,onClose:()=>le(!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:br,onKeyUp:je,onSelect:je,onMouseUp:je,onMouseMove:Qe,onMouseLeave:Je,onContextMenu:et,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${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),ar("var(--bg-input)"),Wr(!0,"var(--bg-input)")]})]})}const cl="[a-zA-Z0-9._@-]+",bo=new RegExp(`@(${cl})`,"g"),Zu=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
26
+ `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function dl(e,r){if(r<=0)return!0;const n=e[r-1]??"";return cn.has(n)}function ul(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)||!Zu.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):dl(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${cl}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function fl(e,r){var a;const n=Dr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function bl(e,r){if(r<=0)return!0;const n=Dr(e,r);if(!n){const o=xo(e);return dl(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 mo(e,r){const n=xo(e);return ul(n,r,{isTriggerBoundary:a=>bl(e,a),isInsideExistingMention:a=>fl(e,a)})}function po(e){return e.toLowerCase().trim()}function ml(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 lo(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=so(d);!u||r.has(u)||(r.add(u),n.push(u))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(e))!==null;)a(l[1]??"");const i=Rs(e);ao.lastIndex=0;let c;for(;(c=ao.exec(i))!==null;)a(c[1]??"");return n}function el(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Tu(e,r){const n=lo(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(so(i.username),i)});const s=new Set,l=[];for(const i of n){const c=a.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function tl(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 $u(e,r){return r?e.filter(n=>n.userId!==r):e}function io(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 rl(e){return!e||!/@/.test(e)?e:e.replace(ao,(r,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=s[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 an(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,s=io(n),l=n.nextSibling;if((l==null?void 0:l.nodeType)===Node.TEXT_NODE){const i=l.textContent??"";if(i.startsWith(s))return;if(i.startsWith(" ")||i.startsWith(" ")){l.textContent=`${s}${i.slice(1)}`;return}if(i.length>0){l.textContent=`${s}${i}`;return}}n.after(a.createTextNode(s))})}function co(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&an(a);const s=io(e);let l=e.nextSibling;!l||l.nodeType!==Node.TEXT_NODE||!/^[ \u00a0]/.test(l.textContent??"")?(l=r.createTextNode(s),e.after(l)):(l.textContent??"").startsWith(s)||(l.textContent=`${s}${(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 Au=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function nl(e,r){return Au.has(e.tagName)&&e!==r}function uo(e,r){let n="",a,s,l=!1;const i=(f,g)=>{if(l||!(r!=null&&r.domPoint))return;const{container:h,offset:C}=r.domPoint;h===f&&C===g&&(s=n.length,l=!0)},c=(f,g)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:g},!0),d=f=>(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":(n+=`
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 ho(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=po(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=ml(e);bo.lastIndex=0;let c;for(;(c=bo.exec(i))!==null;)a(c[1]??"");return n}function pl(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Qu(e,r){const n=ho(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(po(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 hl(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 Ju(e,r){return r?e.filter(n=>n.userId!==r):e}function go(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 gl(e){return!e||!/@/.test(e)?e:e.replace(bo,(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=go(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 vo(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&dn(a);const o=go(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 Ru=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function vl(e,r){return Ru.has(e.tagName)&&e!==r}function yo(e,r){let n="",a,o,l=!1;const i=(f,g)=>{if(l||!(r!=null&&r.domPoint))return;const{container:h,offset:E}=r.domPoint;h===f&&E===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
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 h=0;h<=g.length;h+=1){if(i(f,h),c(f,h))return!0;h<g.length&&(n+=g[h])}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 h=f;if(h.tagName==="BR")return i(h,0),d(h.nextSibling??void 0)==="matched";const C=Array.from(f.childNodes);for(let v=0;v<C.length;v+=1){const E=C[v],A=v>0&&E.nodeType===Node.ELEMENT_NODE&&nl(E,e);if(m(E,A))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],h=f>0&&g.nodeType===Node.ELEMENT_NODE&&nl(g,e);if(m(g,h))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),h=g;for(;h;)g=h,h=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:s}}function fo(e){return uo(e).plain}function Tr(e,r){return r<0?null:uo(e,{locatePlain:r}).locate??null}function Un(e,r,n){return e!==r&&!e.contains(r)?-1:uo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function al(e,r){const{triggerIndex:n,caretIndex:a,username:s}=r;if(a<n)return null;const l=Tr(e,n),i=Tr(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=el({name:r.display,username:s}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",s.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${s}`;const b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),an(e),co(m);const g=c.defaultView,h=g==null?void 0:g.getSelection(),C=h!=null&&h.rangeCount?Un(e,h.getRangeAt(0).startContainer,h.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:C>=0?C:n+u.length+1}}function ol(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Tr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}function Vn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function sl(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 ll(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function $r(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Xn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(s=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(s)||r.isCollapsed&&i.startContainer===s&&i.endContainer===s)&&(l=!0)}catch{l=!1}s.classList.toggle("is-selected",l)})}function il(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Xn(e)}function cl(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(),$r(e),!0):!1}function Yn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let h=f;for(;h&&h.nodeType===Node.TEXT_NODE&&(h.textContent??"")==="";){const C=h;h=h[g],C.remove()}return h},s=a(e.nextSibling,"nextSibling");if(s&&s.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(s.textContent??"")){const f=s;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function ul(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=sl(a.previousSibling,"prev");return Vn(c)&&(s===0||s===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s-1;for(;c>=0;){const d=i[c];if(Vn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function fl(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(s>=i.length){const c=sl(a.nextSibling,"next");if(Vn(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s;for(;c<i.length;){const d=i[c];if(Vn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function bo(e){var s;const r=(s=e.ownerDocument.defaultView)==null?void 0:s.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const mo=420,Kn=6,bl=260,Lu=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ml=4,Du={position:"relative"},Iu={position:"fixed",zIndex:11050,minWidth:bl,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},pl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Ou(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function Hu(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-bl-8)),n=window.innerHeight-e.bottom-Kn-8,a=e.top-Kn-8;return n<Math.min(mo,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+Kn,maxHeight:Math.min(mo,Math.max(120,a))}:{left:r,top:e.bottom+Kn,maxHeight:Math.min(mo,Math.max(120,n))}}function hl({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m="",toolbarVariant:b="full"}){const f=o.useId().replace(/:/g,""),g=o.useRef(null),h=o.useRef(null),C=o.useRef(new Map),v=o.useRef(n);v.current=n;const E=o.useRef(null),A=o.useRef(0),S=o.useRef([]),O=o.useRef(null),[N,y]=o.useState(null),[T,w]=o.useState([]),[F,Y]=o.useState(0),[K,L]=o.useState([]),[G,q]=o.useState(!1),[ne,J]=o.useState(!1);A.current=F,o.useEffect(()=>{J(!0)},[]);const R=(N==null?void 0:N.query)??null;o.useEffect(()=>{if(R===null){w([]);return}const k=R.trim(),te=`${m}|${k.toLowerCase()||"*"}`,P=C.current.get(te);if(P){w(P),q(!1),Y(0);return}const z=new AbortController;q(!0);const de=window.setTimeout(()=>{(async()=>{try{const re=await v.current(k,{signal:z.signal,limit:c});if(z.signal.aborted)return;const W=Array.isArray(re)?re:[];C.current.set(te,W),w(W),Y(0)}catch{z.signal.aborted||w([])}finally{z.signal.aborted||q(!1)}})()},d);return()=>{z.abort(),window.clearTimeout(de)}},[R,c,d,m]);const V=o.useRef(a);V.current=a,o.useEffect(()=>{var k;(k=V.current)==null||k.call(V,tl(K))},[K]);const X=o.useCallback(()=>{const k=Ou(f);if(k.length===0)return null;const te=window.getSelection();if(te!=null&&te.rangeCount){const z=te.getRangeAt(0).startContainer;for(const de of k)if(de.contains(z))return de}const P=document.activeElement;for(const z of k)if(P===z||P&&z.contains(P))return z;for(const z of k)if(z.closest('[role="dialog"]'))return z;return k[0]??null},[f]),ce=o.useCallback(()=>{const k=X(),te=window.getSelection();if(!k||!te||te.rangeCount===0){y(null);return}const P=te.getRangeAt(0);if(!k.contains(P.startContainer)){y(null);return}const z=Un(k,P.startContainer,P.startOffset);if(z<0){y(null);return}const de=oo(k,z);if(!de){y(null);return}const re=P.getBoundingClientRect(),W=re.width===0&&re.height===0?(()=>{const M=document.createRange();return M.selectNodeContents(P.startContainer),M.collapse(!0),M.getBoundingClientRect()})():re;E.current={query:de.query,caretIndex:de.caretIndex,triggerIndex:de.triggerIndex};const x=Hu(W);y(M=>{const ee={query:de.query,...x};return M&&M.query===ee.query&&M.top===ee.top&&M.bottom===ee.bottom&&M.left===ee.left&&M.maxHeight===ee.maxHeight?M:ee})},[X]),D=o.useCallback(k=>{r(k),ce()},[r,ce]);o.useEffect(()=>{const k=te=>{if(Lu.has(te.key))return;const P=X(),z=te.target;!P||!z||!P.contains(z)||ce()};return document.addEventListener("keyup",k,!0),()=>document.removeEventListener("keyup",k,!0)},[X,ce]);const _=o.useCallback(k=>{const te=X();if(!te)return;let P=-1;const z=window.getSelection();if(z&&z.rangeCount>0){const M=z.getRangeAt(0);te.contains(M.startContainer)&&(P=Un(te,M.startContainer,M.startOffset))}if(P<0&&E.current&&(P=E.current.caretIndex),P<0)return;const de=oo(te,P);if(!de)return;const re=al(te,{triggerIndex:de.triggerIndex,caretIndex:P,username:k.username,display:k.name,userId:k.userId});if(!re)return;an(te),te.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const W={userId:k.userId,username:k.username,email:k.email??void 0,display:k.name??k.username};L(M=>{const ee=new Map(M.map(ue=>[ue.userId,ue]));return ee.set(W.userId,W),Array.from(ee.values())}),y(null),E.current=null;const x=k.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const M=X();if(!M)return;M.focus(),an(M);const ee=Array.from(M.querySelectorAll(".mention-chip")),ue=[...ee].reverse().find(se=>se.getAttribute("data-username")===x)??ee[ee.length-1];if(ue){co(ue);return}ol(M,re.caretPlainOffset)})})},[X]);o.useEffect(()=>{const k=new Set(lo(e).map(te=>te.toLowerCase()));L(te=>{const P=te.filter(z=>k.has(z.username.toLowerCase()));return P.length===te.length?te:P})},[e]),o.useEffect(()=>{if(!N)return;const k=te=>{const P=te.target;if(!P||g.current&&g.current.contains(P)||h.current&&h.current.contains(P))return;const z=X();z&&z.contains(P)||y(null)};return document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[N,X]);const le=o.useMemo(()=>T.slice(0,c),[T,c]);S.current=le,o.useEffect(()=>{if(!N)return;const k=te=>{const P=X(),z=te.target;if(!P||!z||!P.contains(z))return;const de=S.current;if(!(de.length===0&&te.key!=="Escape"))if(te.key==="ArrowDown")te.preventDefault(),te.stopPropagation(),Y(re=>(re+1)%Math.max(de.length,1));else if(te.key==="ArrowUp")te.preventDefault(),te.stopPropagation(),Y(re=>(re-1+de.length)%Math.max(de.length,1));else if(te.key==="Enter"||te.key==="Tab"){const re=de[A.current];re&&(te.preventDefault(),te.stopPropagation(),_(re))}else te.key==="Escape"&&(te.preventDefault(),te.stopPropagation(),y(null))};return document.addEventListener("keydown",k,!0),()=>document.removeEventListener("keydown",k,!0)},[X,_,N]),o.useEffect(()=>{const k=W=>{W.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},te=W=>{const x=X(),M=W.target;if(!x||!M||!x.contains(M))return;if((W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="a"){W.preventDefault(),W.stopPropagation(),x.focus(),il(x);return}if(W.key!=="Backspace"&&W.key!=="Delete")return;const ee=window.getSelection();if(ee&&!ee.isCollapsed&&ee.rangeCount>0){const pe=ee.getRangeAt(0);if(x.contains(pe.commonAncestorContainer)&&bo(x).length>0&&cl(pe)){W.preventDefault(),W.stopPropagation(),dl(x)&&k(x);return}}const ue=bo(x);if(ue.length>0){W.preventDefault(),W.stopPropagation();for(const pe of ue)Yn(pe);$r(x),k(x);return}if(W.key==="Backspace"){const pe=ul(x);if(!pe)return;W.preventDefault(),W.stopPropagation(),Yn(pe),$r(x),k(x);return}const se=fl(x);se&&(W.preventDefault(),W.stopPropagation(),Yn(se),$r(x),k(x))},P=W=>{const x=X();if(!x)return;const M=W.target;if(!(M instanceof Element)||!x.contains(M))return;const ee=M.closest(".mention-chip");if(!(ee instanceof HTMLElement)||!x.contains(ee)){O.current=null,$r(x);return}W.shiftKey||W.button!==0||(O.current={chip:ee,x:W.clientX,y:W.clientY})},z=W=>{const x=O.current;if(!x)return;const M=Math.abs(W.clientX-x.x),ee=Math.abs(W.clientY-x.y);(M>ml||ee>ml)&&(O.current=null)},de=W=>{var se;const x=X(),M=O.current;if(O.current=null,!x||!M)return;const ee=W.target;if(!(ee instanceof Element)||!x.contains(ee)||!((se=ee.closest(".mention-chip"))!=null&&se.isSameNode(M.chip)))return;const ue=window.getSelection();if(ue){if(!ue.isCollapsed){Xn(x);return}x.focus(),ll(M.chip)}},re=()=>{const W=X();if(!W)return;const x=window.getSelection();!x||x.rangeCount===0||!x.anchorNode||!W.contains(x.anchorNode)||!x.focusNode||!W.contains(x.focusNode)||Xn(W)};return document.addEventListener("keydown",te,!0),document.addEventListener("mousedown",P,!0),document.addEventListener("mousemove",z,!0),document.addEventListener("mouseup",de,!0),document.addEventListener("selectionchange",re),()=>{document.removeEventListener("keydown",te,!0),document.removeEventListener("mousedown",P,!0),document.removeEventListener("mousemove",z,!0),document.removeEventListener("mouseup",de,!0),document.removeEventListener("selectionchange",re)}},[X]),o.useEffect(()=>{if(!N||!h.current)return;const k=h.current.querySelector(`[data-mention-index="${F}"]`);k==null||k.scrollIntoView({block:"nearest"})},[F,N]);const I=u?rl(e):e,oe=N&&ne?ft.createPortal(t.jsxs("ul",{ref:h,style:{...Iu,left:N.left,top:N.top,bottom:N.bottom,maxHeight:N.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&le.length===0&&t.jsx("li",{style:pl,children:"Buscando…"}),!G&&le.length===0&&t.jsx("li",{style:pl,children:N.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${N.query}”`}),le.map((k,te)=>{var P,z;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":te,onMouseDown:de=>{de.preventDefault(),_(k)},onMouseEnter:()=>Y(te),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:te===F?"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:((P=k.name)==null?void 0:P.trim())||`@${k.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(z=k.name)!=null&&z.trim()?`@${k.username}`:null,k.email].filter(Boolean).join(" · ")||`@${k.username}`})]})},k.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:Du,className:i,children:[t.jsx(Ys,{value:I,onChange:D,placeholder:l,minHeight:s,instanceId:f,toolbarVariant:b}),oe]})}function Bu({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}){return s?t.jsx(hl,{value:e,onChange:r,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}):t.jsx(Ys,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function Fu({title:e,subtitle:r,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:s}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Pu={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)"}},_u={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 zu({children:e,tone:r="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=Pu[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 ${_u[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const gl={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},Wu={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"},ju={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},qu={xs:148,sm:164,md:184},Uu={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 Vu({value:e,options:r,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:b,optionClassName:f,spinnerClassName:g}){const[h,C]=o.useState(!1),[v,E]=o.useState(!1),[A,S]=o.useState(-1),[O,N]=o.useState({}),y=o.useRef(null),T=o.useRef(null),w=o.useRef(null),F=r.find(V=>V.value===e)??r[0],Y={...F!=null&&F.tone?gl[F.tone]:void 0,...F==null?void 0:F.style},K=s||l||r.length===0,L=V=>{i&&V.stopPropagation()},G=o.useCallback(()=>{C(!1),S(-1)},[]),q=o.useCallback(()=>{const V=y.current;if(!V)return;const X=V.getBoundingClientRect(),ce=Math.max(X.width,qu[a]),D=Math.min(Math.max(r.length,1)*38+12,260),_=window.innerHeight-X.bottom,le=_<D&&X.top>_,I=Math.min(Math.max(8,X.left+X.width/2-ce/2),window.innerWidth-ce-8);N({position:"fixed",left:I,top:le?void 0:X.bottom+6,bottom:le?window.innerHeight-X.top+6:void 0,width:ce,zIndex:9999})},[r.length,a]),ne=o.useCallback(V=>{V.disabled||(n(V.value),G())},[G,n]);o.useEffect(()=>E(!0),[]),o.useEffect(()=>{if(!h)return;q();const V=r.findIndex(X=>X.value===e);S(V>=0?V:0)},[h,r,q,e]),o.useEffect(()=>{if(!h)return;function V(X){var D,_;const ce=X.target;!((D=y.current)!=null&&D.contains(ce))&&!((_=T.current)!=null&&_.contains(ce))&&G()}return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[G,h]),o.useEffect(()=>{if(h)return window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[h,q]),o.useEffect(()=>{if(A<0||!w.current)return;const V=w.current.children[A];V==null||V.scrollIntoView({block:"nearest"})},[A]);function J(V){if(!K){if(!h){["Enter"," ","ArrowDown","ArrowUp"].includes(V.key)&&(V.preventDefault(),C(!0));return}if(V.key==="Escape"){V.preventDefault(),G();return}if(V.key==="ArrowDown"){V.preventDefault(),S(X=>Math.min(X+1,r.length-1));return}if(V.key==="ArrowUp"){V.preventDefault(),S(X=>Math.max(X-1,0));return}if(V.key==="Enter"||V.key===" "){V.preventDefault();const X=r[A];X&&ne(X)}}}const R=t.jsx("div",{ref:T,role:"listbox","aria-label":c,className:Gt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...O,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:L,onMouseDown:L,onPointerDown:L,children:t.jsx("div",{ref:w,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((V,X)=>{const ce=V.value===e,D=X===A,_={...V.tone?gl[V.tone]:void 0,...V.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ce,disabled:V.disabled,onMouseEnter:()=>!V.disabled&&S(X),onMouseDown:le=>{le.preventDefault(),ne(V)},className:Gt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Uu[a],ce?V.className:void 0,f),style:{...ce?_:void 0,background:ce?_.background??"color-mix(in srgb, var(--primary) 12%, transparent)":D?"var(--bg-hover)":"transparent",color:ce?_.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ce?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:y,className:Gt("relative inline-flex shrink-0 items-center",u),onKeyDown:J,onClick:L,onPointerDown:L,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":h,title:d,onClick:()=>!K&&C(V=>!V),className:Gt("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",Wu[a],F==null?void 0:F.className,m),style:Y,children:t.jsx("span",{className:"min-w-0 truncate",children:(F==null?void 0:F.label)??e})}),t.jsx(j.HiChevronDown,{"aria-hidden":"true",className:Gt("pointer-events-none absolute opacity-70 transition-transform",ju[a],h?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Gt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),h&&v&&ft.createPortal(R,document.body)]})}function Xu({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(h=>!h.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(h=>h.id===m)??u,f=h=>{h.disabled||a==null||a(h.id)},g=h=>{const C=e.filter(E=>!E.disabled);if(!C.length||!b)return;const v=C.findIndex(E=>E.id===b.id);(h.key==="ArrowRight"||h.key==="ArrowDown")&&(h.preventDefault(),f(C[(v+1)%C.length])),(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),f(C[(v-1+C.length)%C.length])),h.key==="Home"&&(h.preventDefault(),f(C[0])),h.key==="End"&&(h.preventDefault(),f(C[C.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":s,onKeyDown:g,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(h=>{const C=h.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":C,"aria-controls":`${h.id}-panel`,id:`${h.id}-tab`,disabled:h.disabled,tabIndex:C?0:-1,onClick:()=>f(h),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:C?"var(--primary)":"var(--text-muted)",borderColor:C?"var(--primary)":"transparent",background:l==="pills"&&C?"var(--bg-card)":"transparent"},children:[h.icon&&t.jsx("span",{className:"shrink-0",children:h.icon}),t.jsx("span",{children:h.label}),h.badge&&t.jsx("span",{className:"shrink-0",children:h.badge})]},h.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 Jt(...e){return e.filter(Boolean).join(" ")}function Yu({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:h="",contentClassName:C="",footerClassName:v=""}){var P;const E=((P=e[0])==null?void 0:P.id)??"",[A,S]=o.useState(n??E),[O,N]=o.useState(s),y=r??A,T=a??O,w=o.useMemo(()=>new Set(T),[T]),F=Math.max(0,e.findIndex(z=>z.id===y)),Y=e[F]??e[0],K=e.length<=1?100:F/(e.length-1)*100,L=z=>{a||N(z),i==null||i(z)},G=z=>{const de=e.find(re=>re.id===z);de&&(r||S(z),l==null||l(z,de))},q=z=>w.has(z),ne=z=>e.slice(0,z).find(de=>!de.optional&&!w.has(de.id)),J=z=>{const de=e[z];return!de||de.disabled?!1:z===F||d&&z<F?!0:!ne(z)},R=z=>{const de=e.findIndex(re=>re.id===z);return de>=0&&J(de)},V=z=>{const de=e.findIndex(re=>re.id===z);if(de<0)return!1;if(!J(de)){const re=ne(de);return re&&(c==null||c(e[de],re)),!1}return G(z),!0},X=(z=Y==null?void 0:Y.id)=>{!z||w.has(z)||L([...T,z])},ce=(z=Y==null?void 0:Y.id)=>{if(!z)return;const de=e.findIndex(W=>W.id===z),re=T.filter(W=>{const x=e.findIndex(M=>M.id===W);return x>=0&&x<de});L(re),de>=0&&F>de&&G(z)},D=()=>F<=0?!1:V(e[F-1].id),_=()=>{const z=e[F+1];return z?V(z.id):!1},le={activeStep:Y,activeIndex:F,completedStepIds:T,isCompleted:q,isUnlocked:R,completeStep:X,uncompleteStep:ce,goToStep:V,goNext:_,goPrevious:D};if(!Y)return null;const I=e[F+1],oe=F>0,k=I?R(I.id):!1,te=typeof Y.content=="function"?Y.content(le):Y.content;return t.jsxs("section",{className:Jt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:Jt("border-b border-[var(--border)] bg-[var(--bg-input)]",h),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((z,de)=>{const re=z.id===Y.id,W=q(z.id),x=J(de),M=ne(de);return t.jsxs("button",{type:"button",disabled:!x,"aria-current":re?"step":void 0,"aria-disabled":!x,title:!x&&M?`Completa ${M.title}`:z.title,onClick:()=>V(z.id),className:Jt("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",W&&!re&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!re&&!W&&x&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!x&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Jt("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:Jt("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)]",W&&!re&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!W&&!re&&x&&"border-[var(--border)] text-[var(--text-muted)]",!x&&"border-[var(--border)] text-[var(--text-muted)]"),children:W?t.jsx(j.HiCheck,{className:"h-4 w-4"}):x?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:Jt("block truncate text-xs font-semibold transition-colors duration-200",re?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[de+1,". ",z.title]}),z.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:z.description})]}),z.badge&&t.jsx("span",{className:"shrink-0",children:z.badge})]})]},z.id)})})]}),t.jsx("div",{className:Jt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",C),children:te},Y.id),u&&t.jsxs("div",{className:Jt("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(Ue,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(j.HiChevronLeft,{}),disabled:!oe,onClick:D,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",F+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[T.length," completados"]})]}),t.jsx(Ue,{height:38,padding:"0 14px",icon:t.jsx(j.HiChevronRight,{}),disabled:!I||!k,onClick:_,children:I&&!k?f:b})]})]})}const Ku={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 Gu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Zu(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),s=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(s)?s:2}}function vl(e,r){const{lineHeight:n,paddingY:a,borderY:s}=Zu(e);return Math.ceil(r*n+a+s)}const yl=o.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:s,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const g=o.useRef(null),h=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",C=o.useCallback(()=>{const v=g.current;if(!v)return;v.style.height="auto";const E=v.scrollHeight,A=vl(v,i),S=s??(l!==void 0?vl(v,l):void 0),O=S!==void 0?Math.min(Math.max(E,A),S):Math.max(E,A);v.style.height=`${O}px`,v.style.overflowY=S!==void 0&&E>S?"auto":"hidden"},[s,l,i]);return o.useLayoutEffect(()=>{C()},[C,d,u]),o.useEffect(()=>{const v=g.current;if(!v||typeof ResizeObserver>"u")return;const E=new ResizeObserver(()=>C());return E.observe(v),()=>E.disconnect()},[C]),t.jsx("textarea",{...b,ref:v=>{g.current=v,Gu(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{C(),m==null||m(v)},style:{...c,borderColor:h,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 ${Ku[n]} ${r}`})});function Qu({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(On,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(yl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const Ju={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"},Ru={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function ef(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function tf(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const xl=o.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:g,value:h,defaultValue:C,maxLength:v,onInput:E,...A},S){const O=o.useRef(null),N=tf(h,C),y=u??v,T=!!(b||f||d),w=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",F={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},Y=()=>{const L=O.current;!L||!l||(L.style.height="auto",L.style.height=`${L.scrollHeight}px`)};o.useEffect(Y,[l,h]);const K=t.jsx("textarea",{...A,ref:L=>{O.current=L,ef(S,L)},value:h,defaultValue:C,maxLength:v,"aria-invalid":m==="error"||A["aria-invalid"],onInput:L=>{Y(),E==null||E(L)},style:{...F,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 ${Ju[a]} ${Ru[l?"none":s]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return T?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),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,y?`/${y}`:""]})]}):K});function rf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(On,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(xl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const wl=[{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 nf(e){return wl[e%wl.length]}let af=0;function po(){return++af}function Nl(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function of(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sf(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>of(s)).join("|")}|\\r?\\n`,"g");return e.split(a).map(s=>s.trim()).filter(Boolean)}function lf({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:b,helperDisplay:f="inline",error:g,required:h=!1}){const C=e!==void 0,v=!!g,E=!!b&&f==="tooltip"&&!v,[A,S]=o.useState(()=>(r??[]).map((W,x)=>({id:po(),value:W.trim(),colorIndex:x})));o.useEffect(()=>{C&&S(W=>{const x=e??[],M=new Map(W.map(ee=>[ee.value,ee]));return x.map((ee,ue)=>M.get(ee)??{id:po(),value:ee,colorIndex:ue})})},[C,e]);const O=A,[N,y]=o.useState(""),[T,w]=o.useState(null),[F,Y]=o.useState(""),[K,L]=o.useState(!1),[G,q]=o.useState(!1),ne=o.useRef(null),J=o.useRef(null),R=o.useRef(null);function V(){q(!0),setTimeout(()=>q(!1),400)}function X(W){S(W),n==null||n(W.map(x=>x.value))}function ce(W){let x=O,M=!1,ee=!1;for(const ue of W){const se=ue.trim();if(se){if(c!==void 0&&x.length>=c){ee=!0;break}if(!d&&x.some(pe=>pe.value.toLowerCase()===se.toLowerCase())){ee=!0;continue}if(!Nl(se,u)){ee=!0;continue}x=[...x,{id:po(),value:se,colorIndex:x.length}],M=!0}}return M&&X(x),ee&&V(),M}function D(W){return ce([W])}function _(W){const x=O.filter(M=>M.id!==W);X(x.map((M,ee)=>({...M,colorIndex:ee})))}function le(W,x){const M=x.trim();if(w(null),Y(""),!M){_(W);return}if(!(!d&&O.some(ee=>ee.id!==W&&ee.value.toLowerCase()===M.toLowerCase()))){if(!Nl(M,u)){V();return}X(O.map(ee=>ee.id===W?{...ee,value:M}:ee))}}function I(W){s||(w(W.id),Y(W.value),setTimeout(()=>{var x;return(x=J.current)==null?void 0:x.select()},0))}function oe(W){if(W.key==="Enter"||i.includes(W.key)){W.preventDefault(),D(N)&&y("");return}if(W.key==="Backspace"&&N===""&&O.length>0){W.preventDefault();const x=O[O.length-1];_(x.id)}}function k(W,x){if(W.key==="Enter"){W.preventDefault(),le(x,F),setTimeout(()=>{var M;return(M=ne.current)==null?void 0:M.focus()},0);return}W.key==="Escape"&&(W.preventDefault(),w(null),Y(""),setTimeout(()=>{var M;return(M=ne.current)==null?void 0:M.focus()},0))}function te(){var W;s||(W=ne.current)==null||W.focus()}function P(W){if(s)return;const x=W.clipboardData.getData("text");if(!x||!(i.some(se=>se&&x.includes(se))||x.includes(`
31
- `)))return;W.preventDefault();const ee=sf(x,i);ce(ee)&&y("")}function z(){const W=N.trim();W&&D(W)&&y("")}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||h||E)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),h&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E?t.jsx(kr,{content:b}):null]}),t.jsxs("div",{ref:R,onClick:te,onFocus:()=>L(!0),onBlur:W=>{var x;(x=R.current)!=null&&x.contains(W.relatedTarget)||(L(!1),T!==null&&le(T,F),T===null&&z())},style:{borderColor:de},className:`
30
+ `)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const h=f;if(h.tagName==="BR")return i(h,0),d(h.nextSibling??void 0)==="matched";const E=Array.from(f.childNodes);for(let v=0;v<E.length;v+=1){const S=E[v],A=v>0&&S.nodeType===Node.ELEMENT_NODE&&vl(S,e);if(m(S,A))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],h=f>0&&g.nodeType===Node.ELEMENT_NODE&&vl(g,e);if(m(g,h))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),h=g;for(;h;)g=h,h=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:o}}function xo(e){return yo(e).plain}function Dr(e,r){return r<0?null:yo(e,{locatePlain:r}).locate??null}function Zn(e,r,n){return e!==r&&!e.contains(r)?-1:yo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function yl(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Dr(e,n),i=Dr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=pl({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),vo(m);const g=c.defaultView,h=g==null?void 0:g.getSelection(),E=h!=null&&h.rangeCount?Zn(e,h.getRangeAt(0).startContainer,h.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:E>=0?E:n+u.length+1}}function xl(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Dr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Qn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function wl(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 Nl(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 Or(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Jn(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 kl(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Jn(e)}function Sl(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function El(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(),Or(e),!0):!1}function Rn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let h=f;for(;h&&h.nodeType===Node.TEXT_NODE&&(h.textContent??"")==="";){const E=h;h=h[g],E.remove()}return h},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 Cl(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=wl(a.previousSibling,"prev");return Qn(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(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Ml(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=wl(a.nextSibling,"next");if(Qn(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(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function wo(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 No=420,ea=6,Tl=260,ef=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),$l=4,tf={position:"relative"},rf={position:"fixed",zIndex:11050,minWidth:Tl,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},Al={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function nf(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function af(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Tl-8)),n=window.innerHeight-e.bottom-ea-8,a=e.top-ea-8;return n<Math.min(No,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ea,maxHeight:Math.min(No,Math.max(120,a))}:{left:r,top:e.bottom+ea,maxHeight:Math.min(No,Math.max(120,n))}}function Ll({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),h=s.useRef(null),E=s.useRef(new Map),v=s.useRef(n);v.current=n;const S=s.useRef(null),A=s.useRef(0),C=s.useRef([]),O=s.useRef(null),[N,y]=s.useState(null),[M,k]=s.useState([]),[_,Y]=s.useState(0),[K,D]=s.useState([]),[G,U]=s.useState(!1),[ne,J]=s.useState(!1);A.current=_,s.useEffect(()=>{J(!0)},[]);const R=(N==null?void 0:N.query)??null;s.useEffect(()=>{if(R===null){k([]);return}const w=R.trim(),te=`${m}|${w.toLowerCase()||"*"}`,B=E.current.get(te);if(B){k(B),U(!1),Y(0);return}const F=new AbortController;U(!0);const ue=window.setTimeout(()=>{(async()=>{try{const re=await v.current(w,{signal:F.signal,limit:c});if(F.signal.aborted)return;const j=Array.isArray(re)?re:[];E.current.set(te,j),k(j),Y(0)}catch{F.signal.aborted||k([])}finally{F.signal.aborted||U(!1)}})()},d);return()=>{F.abort(),window.clearTimeout(ue)}},[R,c,d,m]);const V=s.useRef(a);V.current=a,s.useEffect(()=>{var w;(w=V.current)==null||w.call(V,hl(K))},[K]);const X=s.useCallback(()=>{const w=nf(f);if(w.length===0)return null;const te=window.getSelection();if(te!=null&&te.rangeCount){const F=te.getRangeAt(0).startContainer;for(const ue of w)if(ue.contains(F))return ue}const B=document.activeElement;for(const F of w)if(B===F||B&&F.contains(B))return F;for(const F of w)if(F.closest('[role="dialog"]'))return F;return w[0]??null},[f]),de=s.useCallback(()=>{const w=X(),te=window.getSelection();if(!w||!te||te.rangeCount===0){y(null);return}const B=te.getRangeAt(0);if(!w.contains(B.startContainer)){y(null);return}const F=Zn(w,B.startContainer,B.startOffset);if(F<0){y(null);return}const ue=mo(w,F);if(!ue){y(null);return}const re=B.getBoundingClientRect(),j=re.width===0&&re.height===0?(()=>{const T=document.createRange();return T.selectNodeContents(B.startContainer),T.collapse(!0),T.getBoundingClientRect()})():re;S.current={query:ue.query,caretIndex:ue.caretIndex,triggerIndex:ue.triggerIndex};const x=af(j);y(T=>{const ee={query:ue.query,...x};return T&&T.query===ee.query&&T.top===ee.top&&T.bottom===ee.bottom&&T.left===ee.left&&T.maxHeight===ee.maxHeight?T:ee})},[X]),H=s.useCallback(w=>{r(w),de()},[r,de]);s.useEffect(()=>{const w=te=>{if(ef.has(te.key))return;const B=X(),F=te.target;!B||!F||!B.contains(F)||de()};return document.addEventListener("keyup",w,!0),()=>document.removeEventListener("keyup",w,!0)},[X,de]);const I=s.useCallback(w=>{const te=X();if(!te)return;let B=-1;const F=window.getSelection();if(F&&F.rangeCount>0){const T=F.getRangeAt(0);te.contains(T.startContainer)&&(B=Zn(te,T.startContainer,T.startOffset))}if(B<0&&S.current&&(B=S.current.caretIndex),B<0)return;const ue=mo(te,B);if(!ue)return;const re=yl(te,{triggerIndex:ue.triggerIndex,caretIndex:B,username:w.username,display:w.name,userId:w.userId});if(!re)return;dn(te),te.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const j={userId:w.userId,username:w.username,email:w.email??void 0,display:w.name??w.username};D(T=>{const ee=new Map(T.map(fe=>[fe.userId,fe]));return ee.set(j.userId,j),Array.from(ee.values())}),y(null),S.current=null;const x=w.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const T=X();if(!T)return;T.focus(),dn(T);const ee=Array.from(T.querySelectorAll(".mention-chip")),fe=[...ee].reverse().find(ie=>ie.getAttribute("data-username")===x)??ee[ee.length-1];if(fe){vo(fe);return}xl(T,re.caretPlainOffset)})})},[X]);s.useEffect(()=>{const w=new Set(ho(e).map(te=>te.toLowerCase()));D(te=>{const B=te.filter(F=>w.has(F.username.toLowerCase()));return B.length===te.length?te:B})},[e]),s.useEffect(()=>{if(!N)return;const w=te=>{const B=te.target;if(!B||g.current&&g.current.contains(B)||h.current&&h.current.contains(B))return;const F=X();F&&F.contains(B)||y(null)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[N,X]);const le=s.useMemo(()=>M.slice(0,c),[M,c]);C.current=le,s.useEffect(()=>{if(!N)return;const w=te=>{const B=X(),F=te.target;if(!B||!F||!B.contains(F))return;const ue=C.current;if(!(ue.length===0&&te.key!=="Escape"))if(te.key==="ArrowDown")te.preventDefault(),te.stopPropagation(),Y(re=>(re+1)%Math.max(ue.length,1));else if(te.key==="ArrowUp")te.preventDefault(),te.stopPropagation(),Y(re=>(re-1+ue.length)%Math.max(ue.length,1));else if(te.key==="Enter"||te.key==="Tab"){const re=ue[A.current];re&&(te.preventDefault(),te.stopPropagation(),I(re))}else te.key==="Escape"&&(te.preventDefault(),te.stopPropagation(),y(null))};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[X,I,N]),s.useEffect(()=>{const w=j=>{j.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},te=j=>{const x=X(),T=j.target;if(!x||!T||!x.contains(T))return;if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),x.focus(),kl(x);return}if(j.key!=="Backspace"&&j.key!=="Delete")return;const ee=window.getSelection();if(ee&&!ee.isCollapsed&&ee.rangeCount>0){const pe=ee.getRangeAt(0);if(x.contains(pe.commonAncestorContainer)&&wo(x).length>0&&Sl(pe)){j.preventDefault(),j.stopPropagation(),El(x)&&w(x);return}}const fe=wo(x);if(fe.length>0){j.preventDefault(),j.stopPropagation();for(const pe of fe)Rn(pe);Or(x),w(x);return}if(j.key==="Backspace"){const pe=Cl(x);if(!pe)return;j.preventDefault(),j.stopPropagation(),Rn(pe),Or(x),w(x);return}const ie=Ml(x);ie&&(j.preventDefault(),j.stopPropagation(),Rn(ie),Or(x),w(x))},B=j=>{const x=X();if(!x)return;const T=j.target;if(!(T instanceof Element)||!x.contains(T))return;const ee=T.closest(".mention-chip");if(!(ee instanceof HTMLElement)||!x.contains(ee)){O.current=null,Or(x);return}j.shiftKey||j.button!==0||(O.current={chip:ee,x:j.clientX,y:j.clientY})},F=j=>{const x=O.current;if(!x)return;const T=Math.abs(j.clientX-x.x),ee=Math.abs(j.clientY-x.y);(T>$l||ee>$l)&&(O.current=null)},ue=j=>{var ie;const x=X(),T=O.current;if(O.current=null,!x||!T)return;const ee=j.target;if(!(ee instanceof Element)||!x.contains(ee)||!((ie=ee.closest(".mention-chip"))!=null&&ie.isSameNode(T.chip)))return;const fe=window.getSelection();if(fe){if(!fe.isCollapsed){Jn(x);return}x.focus(),Nl(T.chip)}},re=()=>{const j=X();if(!j)return;const x=window.getSelection();!x||x.rangeCount===0||!x.anchorNode||!j.contains(x.anchorNode)||!x.focusNode||!j.contains(x.focusNode)||Jn(j)};return document.addEventListener("keydown",te,!0),document.addEventListener("mousedown",B,!0),document.addEventListener("mousemove",F,!0),document.addEventListener("mouseup",ue,!0),document.addEventListener("selectionchange",re),()=>{document.removeEventListener("keydown",te,!0),document.removeEventListener("mousedown",B,!0),document.removeEventListener("mousemove",F,!0),document.removeEventListener("mouseup",ue,!0),document.removeEventListener("selectionchange",re)}},[X]),s.useEffect(()=>{if(!N||!h.current)return;const w=h.current.querySelector(`[data-mention-index="${_}"]`);w==null||w.scrollIntoView({block:"nearest"})},[_,N]);const L=u?gl(e):e,oe=N&&ne?ht.createPortal(t.jsxs("ul",{ref:h,style:{...rf,left:N.left,top:N.top,bottom:N.bottom,maxHeight:N.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&le.length===0&&t.jsx("li",{style:Al,children:"Buscando…"}),!G&&le.length===0&&t.jsx("li",{style:Al,children:N.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${N.query}”`}),le.map((w,te)=>{var B,F;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":te,onMouseDown:ue=>{ue.preventDefault(),I(w)},onMouseEnter:()=>Y(te),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:te===_?"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:((B=w.name)==null?void 0:B.trim())||`@${w.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(F=w.name)!=null&&F.trim()?`@${w.username}`:null,w.email].filter(Boolean).join(" · ")||`@${w.username}`})]})},w.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:tf,className:i,children:[t.jsx(il,{value:L,onChange:H,placeholder:l,minHeight:o,instanceId:f,toolbarVariant:b}),oe]})}function of({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(Ll,{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(il,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function sf({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 lf={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)"}},cf={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 df({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=lf[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 ${cf[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 Dl={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},uf={xs:"min-h-5 px-1.5 pr-6 text-[10px]",sm:"min-h-6 px-2 pr-7 text-xs",md:"min-h-7 px-2.5 pr-8 text-sm"},ff={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},bf={xs:148,sm:164,md:184},mf={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 pf({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[h,E]=s.useState(!1),[v,S]=s.useState(!1),[A,C]=s.useState(-1),[O,N]=s.useState({}),y=s.useRef(null),M=s.useRef(null),k=s.useRef(null),_=r.find(V=>V.value===e)??r[0],Y={..._!=null&&_.tone?Dl[_.tone]:void 0,..._==null?void 0:_.style},K=o||l||r.length===0,D=V=>{i&&V.stopPropagation()},G=s.useCallback(()=>{E(!1),C(-1)},[]),U=s.useCallback(()=>{const V=y.current;if(!V)return;const X=V.getBoundingClientRect(),de=Math.max(X.width,bf[a]),H=Math.min(Math.max(r.length,1)*38+12,260),I=window.innerHeight-X.bottom,le=I<H&&X.top>I,L=Math.min(Math.max(8,X.left+X.width/2-de/2),window.innerWidth-de-8);N({position:"fixed",left:L,top:le?void 0:X.bottom+6,bottom:le?window.innerHeight-X.top+6:void 0,width:de,zIndex:9999})},[r.length,a]),ne=s.useCallback(V=>{V.disabled||(n(V.value),G())},[G,n]);s.useEffect(()=>S(!0),[]),s.useEffect(()=>{if(!h)return;U();const V=r.findIndex(X=>X.value===e);C(V>=0?V:0)},[h,r,U,e]),s.useEffect(()=>{if(!h)return;function V(X){var H,I;const de=X.target;!((H=y.current)!=null&&H.contains(de))&&!((I=M.current)!=null&&I.contains(de))&&G()}return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[G,h]),s.useEffect(()=>{if(h)return window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[h,U]),s.useEffect(()=>{if(A<0||!k.current)return;const V=k.current.children[A];V==null||V.scrollIntoView({block:"nearest"})},[A]);function J(V){if(!K){if(!h){["Enter"," ","ArrowDown","ArrowUp"].includes(V.key)&&(V.preventDefault(),E(!0));return}if(V.key==="Escape"){V.preventDefault(),G();return}if(V.key==="ArrowDown"){V.preventDefault(),C(X=>Math.min(X+1,r.length-1));return}if(V.key==="ArrowUp"){V.preventDefault(),C(X=>Math.max(X-1,0));return}if(V.key==="Enter"||V.key===" "){V.preventDefault();const X=r[A];X&&ne(X)}}}const R=t.jsx("div",{ref:M,role:"listbox","aria-label":c,className:Zt("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:k,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((V,X)=>{const de=V.value===e,H=X===A,I={...V.tone?Dl[V.tone]:void 0,...V.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":de,disabled:V.disabled,onMouseEnter:()=>!V.disabled&&C(X),onMouseDown:le=>{le.preventDefault(),ne(V)},className:Zt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",mf[a],de?V.className:void 0,f),style:{...de?I:void 0,background:de?I.background??"color-mix(in srgb, var(--primary) 12%, transparent)":H?"var(--bg-hover)":"transparent",color:de?I.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:de?t.jsx(W.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:y,className:Zt("relative inline-flex shrink-0 items-center",u),onKeyDown:J,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":h,title:d,onClick:()=>!K&&E(V=>!V),className:Zt("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",uf[a],_==null?void 0:_.className,m),style:Y,children:t.jsx("span",{className:"min-w-0 truncate",children:(_==null?void 0:_.label)??e})}),t.jsx(W.HiChevronDown,{"aria-hidden":"true",className:Zt("pointer-events-none absolute opacity-70 transition-transform",ff[a],h?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Zt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),h&&v&&ht.createPortal(R,document.body)]})}function hf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(h=>!h.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(h=>h.id===m)??u,f=h=>{h.disabled||a==null||a(h.id)},g=h=>{const E=e.filter(S=>!S.disabled);if(!E.length||!b)return;const v=E.findIndex(S=>S.id===b.id);(h.key==="ArrowRight"||h.key==="ArrowDown")&&(h.preventDefault(),f(E[(v+1)%E.length])),(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),f(E[(v-1+E.length)%E.length])),h.key==="Home"&&(h.preventDefault(),f(E[0])),h.key==="End"&&(h.preventDefault(),f(E[E.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(h=>{const E=h.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":E,"aria-controls":`${h.id}-panel`,id:`${h.id}-tab`,disabled:h.disabled,tabIndex:E?0:-1,onClick:()=>f(h),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:E?"var(--primary)":"var(--text-muted)",borderColor:E?"var(--primary)":"transparent",background:l==="pills"&&E?"var(--bg-card)":"transparent"},children:[h.icon&&t.jsx("span",{className:"shrink-0",children:h.icon}),t.jsx("span",{children:h.label}),h.badge&&t.jsx("span",{className:"shrink-0",children:h.badge})]},h.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 tr(...e){return e.filter(Boolean).join(" ")}function gf({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:h="",contentClassName:E="",footerClassName:v=""}){var B;const S=((B=e[0])==null?void 0:B.id)??"",[A,C]=s.useState(n??S),[O,N]=s.useState(o),y=r??A,M=a??O,k=s.useMemo(()=>new Set(M),[M]),_=Math.max(0,e.findIndex(F=>F.id===y)),Y=e[_]??e[0],K=e.length<=1?100:_/(e.length-1)*100,D=F=>{a||N(F),i==null||i(F)},G=F=>{const ue=e.find(re=>re.id===F);ue&&(r||C(F),l==null||l(F,ue))},U=F=>k.has(F),ne=F=>e.slice(0,F).find(ue=>!ue.optional&&!k.has(ue.id)),J=F=>{const ue=e[F];return!ue||ue.disabled?!1:F===_||d&&F<_?!0:!ne(F)},R=F=>{const ue=e.findIndex(re=>re.id===F);return ue>=0&&J(ue)},V=F=>{const ue=e.findIndex(re=>re.id===F);if(ue<0)return!1;if(!J(ue)){const re=ne(ue);return re&&(c==null||c(e[ue],re)),!1}return G(F),!0},X=(F=Y==null?void 0:Y.id)=>{!F||k.has(F)||D([...M,F])},de=(F=Y==null?void 0:Y.id)=>{if(!F)return;const ue=e.findIndex(j=>j.id===F),re=M.filter(j=>{const x=e.findIndex(T=>T.id===j);return x>=0&&x<ue});D(re),ue>=0&&_>ue&&G(F)},H=()=>_<=0?!1:V(e[_-1].id),I=()=>{const F=e[_+1];return F?V(F.id):!1},le={activeStep:Y,activeIndex:_,completedStepIds:M,isCompleted:U,isUnlocked:R,completeStep:X,uncompleteStep:de,goToStep:V,goNext:I,goPrevious:H};if(!Y)return null;const L=e[_+1],oe=_>0,w=L?R(L.id):!1,te=typeof Y.content=="function"?Y.content(le):Y.content;return t.jsxs("section",{className:tr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:tr("border-b border-[var(--border)] bg-[var(--bg-input)]",h),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((F,ue)=>{const re=F.id===Y.id,j=U(F.id),x=J(ue),T=ne(ue);return t.jsxs("button",{type:"button",disabled:!x,"aria-current":re?"step":void 0,"aria-disabled":!x,title:!x&&T?`Completa ${T.title}`:F.title,onClick:()=>V(F.id),className:tr("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",j&&!re&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!re&&!j&&x&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!x&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:tr("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:tr("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)]",j&&!re&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!j&&!re&&x&&"border-[var(--border)] text-[var(--text-muted)]",!x&&"border-[var(--border)] text-[var(--text-muted)]"),children:j?t.jsx(W.HiCheck,{className:"h-4 w-4"}):x?ue+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:tr("block truncate text-xs font-semibold transition-colors duration-200",re?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[ue+1,". ",F.title]}),F.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:F.description})]}),F.badge&&t.jsx("span",{className:"shrink-0",children:F.badge})]})]},F.id)})})]}),t.jsx("div",{className:tr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",E),children:te},Y.id),u&&t.jsxs("div",{className:tr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Ve,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(W.HiChevronLeft,{}),disabled:!oe,onClick:H,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",_+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[M.length," completados"]})]}),t.jsx(Ve,{height:38,padding:"0 14px",icon:t.jsx(W.HiChevronRight,{}),disabled:!L||!w,onClick:I,children:L&&!w?f:b})]})]})}const vf={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 yf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function xf(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 Ol(e,r){const{lineHeight:n,paddingY:a,borderY:o}=xf(e);return Math.ceil(r*n+a+o)}const Hl=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),h=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",E=s.useCallback(()=>{const v=g.current;if(!v)return;v.style.height="auto";const S=v.scrollHeight,A=Ol(v,i),C=o??(l!==void 0?Ol(v,l):void 0),O=C!==void 0?Math.min(Math.max(S,A),C):Math.max(S,A);v.style.height=`${O}px`,v.style.overflowY=C!==void 0&&S>C?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{E()},[E,d,u]),s.useEffect(()=>{const v=g.current;if(!v||typeof ResizeObserver>"u")return;const S=new ResizeObserver(()=>E());return S.observe(v),()=>S.disconnect()},[E]),t.jsx("textarea",{...b,ref:v=>{g.current=v,yf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{E(),m==null||m(v)},style:{...c,borderColor:h,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 ${vf[n]} ${r}`})});function wf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Hl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Nf={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"},kf={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Sf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Ef(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Il=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:h,defaultValue:E,maxLength:v,onInput:S,...A},C){const O=s.useRef(null),N=Ef(h,E),y=u??v,M=!!(b||f||d),k=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",_={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},Y=()=>{const D=O.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(Y,[l,h]);const K=t.jsx("textarea",{...A,ref:D=>{O.current=D,Sf(C,D)},value:h,defaultValue:E,maxLength:v,"aria-invalid":m==="error"||A["aria-invalid"],onInput:D=>{Y(),S==null||S(D)},style:{..._,borderColor:k},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Nf[a]} ${kf[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,y?`/${y}`:""]})]}):K});function Cf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Il,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Bl=[{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 Mf(e){return Bl[e%Bl.length]}let Tf=0;function ko(){return++Tf}function Fl(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function $f(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Af(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>$f(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Lf({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:h=!1}){const E=e!==void 0,v=!!g,S=!!b&&f==="tooltip"&&!v,[A,C]=s.useState(()=>(r??[]).map((j,x)=>({id:ko(),value:j.trim(),colorIndex:x})));s.useEffect(()=>{E&&C(j=>{const x=e??[],T=new Map(j.map(ee=>[ee.value,ee]));return x.map((ee,fe)=>T.get(ee)??{id:ko(),value:ee,colorIndex:fe})})},[E,e]);const O=A,[N,y]=s.useState(""),[M,k]=s.useState(null),[_,Y]=s.useState(""),[K,D]=s.useState(!1),[G,U]=s.useState(!1),ne=s.useRef(null),J=s.useRef(null),R=s.useRef(null);function V(){U(!0),setTimeout(()=>U(!1),400)}function X(j){C(j),n==null||n(j.map(x=>x.value))}function de(j){let x=O,T=!1,ee=!1;for(const fe of j){const ie=fe.trim();if(ie){if(c!==void 0&&x.length>=c){ee=!0;break}if(!d&&x.some(pe=>pe.value.toLowerCase()===ie.toLowerCase())){ee=!0;continue}if(!Fl(ie,u)){ee=!0;continue}x=[...x,{id:ko(),value:ie,colorIndex:x.length}],T=!0}}return T&&X(x),ee&&V(),T}function H(j){return de([j])}function I(j){const x=O.filter(T=>T.id!==j);X(x.map((T,ee)=>({...T,colorIndex:ee})))}function le(j,x){const T=x.trim();if(k(null),Y(""),!T){I(j);return}if(!(!d&&O.some(ee=>ee.id!==j&&ee.value.toLowerCase()===T.toLowerCase()))){if(!Fl(T,u)){V();return}X(O.map(ee=>ee.id===j?{...ee,value:T}:ee))}}function L(j){o||(k(j.id),Y(j.value),setTimeout(()=>{var x;return(x=J.current)==null?void 0:x.select()},0))}function oe(j){if(j.key==="Enter"||i.includes(j.key)){j.preventDefault(),H(N)&&y("");return}if(j.key==="Backspace"&&N===""&&O.length>0){j.preventDefault();const x=O[O.length-1];I(x.id)}}function w(j,x){if(j.key==="Enter"){j.preventDefault(),le(x,_),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0);return}j.key==="Escape"&&(j.preventDefault(),k(null),Y(""),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0))}function te(){var j;o||(j=ne.current)==null||j.focus()}function B(j){if(o)return;const x=j.clipboardData.getData("text");if(!x||!(i.some(ie=>ie&&x.includes(ie))||x.includes(`
31
+ `)))return;j.preventDefault();const ee=Af(x,i);de(ee)&&y("")}function F(){const j=N.trim();j&&H(j)&&y("")}const ue=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||h||S)&&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}),h&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),S?t.jsx(Mr,{content:b}):null]}),t.jsxs("div",{ref:R,onClick:te,onFocus:()=>D(!0),onBlur:j=>{var x;(x=R.current)!=null&&x.contains(j.relatedTarget)||(D(!1),M!==null&&le(M,_),M===null&&F())},style:{borderColor:ue},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
- ${s?"cursor-not-allowed opacity-60":"cursor-text"}
34
+ ${o?"cursor-not-allowed opacity-60":"cursor-text"}
35
35
  ${G?"animate-[tag-shake_0.4s_ease]":""}
36
36
  `,children:[t.jsx("style",{children:`
37
37
  @keyframes tag-shake {
@@ -41,7 +41,7 @@ ${H}`,ge=new Blob(["\uFEFF"+ae],{type:"text/csv;charset=utf-8;"}),ke=URL.createO
41
41
  60% { transform: translateX(-3px); }
42
42
  80% { transform: translateX(3px); }
43
43
  }
44
- `}),O.map(W=>{const x=nf(W.colorIndex);return T===W.id?t.jsx("input",{ref:J,value:F,disabled:s,onChange:M=>Y(M.target.value),onKeyDown:M=>k(M,W.id),onBlur:()=>le(W.id,F),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(F.length+2,6)}ch`}},W.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:x.bg,color:x.text,border:`1px solid ${x.border}`},children:[t.jsx("span",{className:"truncate",children:W.value}),t.jsx("button",{type:"button","aria-label":`Editar "${W.value}"`,disabled:s,tabIndex:-1,onClick:M=>{M.stopPropagation(),I(W)},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 "${W.value}"`,disabled:s,tabIndex:-1,onClick:M=>{M.stopPropagation(),_(W.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"})})]},W.id)}),!re&&t.jsx("input",{ref:ne,value:N,disabled:s,placeholder:O.length===0?a:"",onChange:W=>y(W.target.value),onKeyDown:oe,onPaste:P,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(Cr,{error:g,helperText:b,helperDisplay:f})]})}const cf=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Ze(e){return String(e).padStart(2,"0")}function ho(e,r=Ar()){const n=e.trim();if(!n)return r;const a=n.match(cf);if(!a)return r;const s=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||s<0||s>23||l<0||l>59||i<0||i>59?r:{hour24:s,minute:l,second:i}}function on(e,r=!0){const n=`${Ze(e.hour24)}:${Ze(e.minute)}`;return r?`${n}:${Ze(e.second)}`:n}function Gn(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 sn(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 df(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,s=ho(e);if(n){const l=Gn(s),i=`${l.hour12}:${Ze(l.minute)}`;return`${a?`${i}:${Ze(l.second)}`:i} ${l.meridiem}`}return on(s,a)}function Ar(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function uf(e=!0){return on(Ar(),e)}function go(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const vt=36,vo=5,kl=Math.floor(vo/2),ff=52,bf=48,Ut=18;function Cl(e){return e*vt}function Sl(e){return Math.round(e/vt)}function mf(e){return e.use12Hour??e.hour12??!1}function Zn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:s=0,width:l=ff,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const h=o.useRef(null),C=o.useRef(null),v=o.useRef(null),E=o.useRef(""),A=o.useRef(0),S=o.useRef(!1),[O,N]=o.useState(r),[y,T]=o.useState(""),w=o.useCallback(I=>{E.current=I,T(I)},[]),F=o.useMemo(()=>[...Array(kl).fill(""),...e,...Array(kl).fill("")],[e]),Y=o.useCallback(()=>{const I=h.current;if(!I)return r;const oe=Sl(I.scrollTop),k=Math.min(Math.max(oe,0),e.length-1);return e[k]??r},[r,e]),K=o.useCallback((I,oe=!0)=>{const k=Math.min(Math.max(I,0),e.length-1),te=e[k],P=h.current;!P||!te||(C.current&&(window.clearTimeout(C.current),C.current=null),S.current=!0,A.current=k,P.scrollTop=Cl(k),N(te),oe&&te!==r&&n(te))},[n,r,e]);o.useLayoutEffect(()=>{C.current&&(window.clearTimeout(C.current),C.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),w(""),N(r);const I=e.indexOf(r);if(I>=0&&(A.current=I),I<0||!h.current)return;const oe=Cl(I);h.current.scrollTop!==oe&&(h.current.scrollTop=oe)},[s,r,w,e]);const L=o.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),G=o.useCallback((I,oe=!1)=>{L(),w("");const k=Number(I);if(!Number.isFinite(k))return;const te=Math.min(c,Math.max(0,k));let P=Ze(te),z=e.indexOf(P);if(z<0){const de=Math.min(e.length-1,Math.max(0,te-(c===12?1:0)));P=e[de]??P,z=e.indexOf(P)}z>=0&&K(z),oe&&(b==null||b())},[L,c,b,K,w,e]),q=o.useCallback(I=>{const oe=Math.floor(c/10),k=E.current;if(k===""){if(I>oe){G(String(I),!0);return}const P=String(I);w(P),v.current=window.setTimeout(()=>{G(E.current,!0)},1200);return}L();const te=+`${k}${I}`;te<=c?G(String(te),!0):G(String(I),!0)},[L,G,c,w]),ne=o.useCallback(I=>{L(),w(""),K(A.current+I)},[L,K,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(),ne(-1)):I.key==="ArrowDown"?(I.preventDefault(),ne(1)):I.key==="Tab"&&(I.preventDefault(),L(),E.current!==""&&G(E.current,!1),I.shiftKey?f==null||f():b==null||b())},R=o.useCallback(()=>{const I=a.current,oe=h.current;oe&&I===a.current&&K(Sl(oe.scrollTop))},[K,a]),V=()=>{if(E.current!=="")return;if(S.current){S.current=!1;const oe=Y();N(oe);const k=e.indexOf(oe);k>=0&&(A.current=k);return}N(Y()),C.current&&window.clearTimeout(C.current);const I=a.current;C.current=window.setTimeout(()=>{I===a.current&&R()},100)},X="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",ce=vt*vo,D=ce+Ut*2,_=y!==""?y:null,le=_!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":_??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:J,onBlur:()=>{L(),E.current!==""&&G(E.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:D,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:X,style:{top:0,height:Ut,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:h,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Ut,height:ce,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:V,onMouseUp:R,onTouchEnd:R,children:F.map((I,oe)=>{const k=I!==""&&I===O;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!I,onClick:()=>{if(!I)return;const te=e.indexOf(I);te>=0&&K(te)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:vt,scrollSnapAlign:"center",color:k?"var(--text-main)":"var(--text-muted)",fontSize:k?16:14,fontWeight:k?600:400,opacity:I?le?k?0:.35:k?1:.35:0},children:I},`wheel-${oe}-${I}`)})}),_!==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:Ut+ce/2-vt/2,height:vt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:_}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:X,style:{bottom:0,height:Ut,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function El(){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:vt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Ml({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:s=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",b=m||!d,f=mf({use12Hour:n,hour12:a}),g=o.useRef(e),h=ho(e,Ar()),C=Gn(h),[v,E]=o.useState(Ze(f?C.hour12:h.hour24)),[A,S]=o.useState(Ze(h.minute)),[O,N]=o.useState(Ze(h.second)),[y,T]=o.useState(C.meridiem),[w,F]=o.useState(0),Y=o.useRef(0),K=o.useRef(!1),L=o.useRef({hour:null,minute:null,second:null,meridiem:null}),[G,q]=o.useState("hour"),ne=o.useMemo(()=>{const se=["hour","minute"];return s&&se.push("second"),f&&se.push("meridiem"),se},[f,s]),J=o.useCallback(se=>{q(pe=>{const Me=ne.indexOf(pe);return ne[(Me+se+ne.length)%ne.length]})},[ne]);o.useEffect(()=>{var se;(se=L.current[G])==null||se.focus()},[G]),o.useEffect(()=>{var se;q("hour"),(se=L.current.hour)==null||se.focus()},[]),o.useEffect(()=>{if(e===g.current)return;g.current=e;const se=ho(e,Ar()),pe=Gn(se);E(Ze(f?pe.hour12:se.hour24)),S(Ze(se.minute)),N(Ze(se.second)),T(pe.meridiem)},[f,e]);const R=o.useMemo(()=>(f?go(1,12):go(0,23)).map(se=>Ze(se)),[f]),V=o.useMemo(()=>go(0,59).map(se=>Ze(se)),[]),X=V,ce=o.useMemo(()=>["AM","PM"],[]),D=o.useCallback(()=>f?sn({hour12:Number(v),minute:Number(A),second:Number(O),meridiem:y}):{hour24:Number(v),minute:Number(A),second:Number(O)},[v,f,y,A,O]),_=o.useCallback(se=>{if(K.current)return;const pe=on(se,s);g.current=pe,r(pe)},[r,s]),le=o.useCallback(()=>{_(D())},[D,_]),I=se=>{E(se),b&&_(f?sn({hour12:Number(se),minute:Number(A),second:Number(O),meridiem:y}):{hour24:Number(se),minute:Number(A),second:Number(O)})},oe=se=>{S(se),b&&_(f?sn({hour12:Number(v),minute:Number(se),second:Number(O),meridiem:y}):{hour24:Number(v),minute:Number(se),second:Number(O)})},k=se=>{N(se),b&&_(f?sn({hour12:Number(v),minute:Number(A),second:Number(se),meridiem:y}):{hour24:Number(v),minute:Number(A),second:Number(se)})},te=se=>{T(se),b&&_(sn({hour12:Number(v),minute:Number(A),second:Number(O),meridiem:se}))},P=o.useCallback(()=>(Y.current+=1,F(Y.current),Y.current),[]),z=o.useCallback(se=>{const pe=Gn(se),Me=on(se,s);g.current=Me,E(Ze(f?pe.hour12:se.hour24)),S(Ze(se.minute)),N(Ze(se.second)),T(pe.meridiem),r(Me)},[f,r,s]),de=()=>{K.current=!0,P(),z(Ar()),queueMicrotask(()=>{const se=Ar();on(se,s)!==g.current&&(P(),z(se)),K.current=!1})},re=()=>{le(),d==null||d()},W=vt*vo,x=W+Ut*2,M=Ut+W/2-vt/2,ee=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:x,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:M,height:vt,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:Ut,height:vt*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:Ut,height:vt*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(Zn,{syncEpochRef:Y,forceSyncAt:w,values:R,selected:v,onSelect:I,label:"Horas",maxNumeric:f?12:23,isFocused:G==="hour",onFocus:()=>q("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{L.current.hour=se}}),t.jsx(El,{}),t.jsx(Zn,{syncEpochRef:Y,forceSyncAt:w,values:V,selected:A,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:G==="minute",onFocus:()=>q("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{L.current.minute=se}}),s?t.jsxs(t.Fragment,{children:[t.jsx(El,{}),t.jsx(Zn,{syncEpochRef:Y,forceSyncAt:w,values:X,selected:O,onSelect:k,label:"Segundos",maxNumeric:59,isFocused:G==="second",onFocus:()=>q("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{L.current.second=se}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Zn,{syncEpochRef:Y,forceSyncAt:w,values:ce,selected:y,onSelect:se=>te(se),width:bf,label:"AM o PM",isMeridiem:!0,isFocused:G==="meridiem",onFocus:()=>q("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{L.current.meridiem=se}})}):null]})]})}),ue=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ue,{variant:"ghost",size:"sm",onClick: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(Ue,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ue,{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?s?300:260:s?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,ee,ue]})}function pf(e){return e.use12Hour??e.hour12??!1}function hf({label:e,value:r,onChange:n,use12Hour:a,hour12:s,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:b,helperText:f,helperDisplay:g,className:h,contentClassName:C,className:v=""}){const E=u==="popover",[A,S]=o.useState(!1),O=o.useRef(null),[N,y]=o.useState({horizontal:"left",vertical:"bottom"}),T=pf({use12Hour:a,hour12:s}),w=o.useMemo(()=>r?df(r,{use12Hour:T,showSeconds:l}):"",[T,l,r]);o.useEffect(()=>{if(!E||!A||!O.current)return;const K=O.current.getBoundingClientRect(),L=8,G=T?l?300:260:l?252:212,q=276,ne=K.left+G>window.innerWidth-L,J=K.right-G>=L,R=K.bottom+8+q>window.innerHeight-L,V=K.top-8-q>=L;y({horizontal:ne&&J?"right":"left",vertical:R&&V?"top":"bottom"})},[T,E,A,l]),o.useEffect(()=>{if(!E||!A)return;function K(G){O.current&&(O.current.contains(G.target)||S(!1))}function L(G){G.key==="Escape"&&S(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",L)}},[E,A]);const F=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||S(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)":A?"var(--primary)":"var(--border)",color:w?"var(--text-main)":"var(--text-muted)",boxShadow:A?"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})]}),E?t.jsx(j.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${A?"rotate-180":""}`}):null]}),Y=t.jsx(Ml,{variant:E?"popover":"panel",value:r||uf(l),onChange:n,use12Hour:T,showSeconds:l,title:i,onClose:()=>S(!1)});return t.jsx(On,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:h,contentClassName:C,children:E?t.jsxs("div",{ref:O,className:"relative w-full",children:[F,A?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:Y}):null]}):t.jsxs("div",{className:"space-y-2",children:[F,A?Y:null]})})}const gf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function vf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=gf[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:i.width,height:i.height,background:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:e?"var(--primary-fg)":"var(--text-muted)"}})})}const Tl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),yf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function xf(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 $l(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Al(e){$l(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function wf(e){const r=e.querySelector(yf);return r instanceof HTMLElement?r:null}function Ll(){return o.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Tl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ma.OverlayScrollbars(l)){Al(l);return}if(!xf(l))return;const c={overflow:$l(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=wf(l),u=d?Ma.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ma.OverlayScrollbars(l,c);Al(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const s=new MutationObserver(a);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(Tl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function Rt(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Dl(e){try{const r=new URL(e);return Rt(r.pathname)}catch{return""}}function Nf(e){const r=Rt(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return Rt(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?Rt(`/${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())?"":Rt(`/${a[0]}`)}const yo="primeSuiteAppUrl",kf={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"}},Il={xs:20,sm:28,md:36,lg:48,xl:64},Ol=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Cf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Sf="bonsaif.bot",Ef="Bonsaif Bot",Mf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Hl(e){return typeof e=="string"?e.trim():""}function Tf(e){var s;if(e!==void 0)return Rt(e);const r=Rt(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(yo)||"";i&&window.sessionStorage.setItem(yo,i);const c=window.sessionStorage.getItem(yo)||"",d=i||c;if(d){const u=Dl(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")?Dl(a):Rt(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Nf(window.location.pathname)}function $f(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 Af(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ol[r%Ol.length]}function Lf(e,r){return e===Sf||r===Ef}function Df(e,r){return`${e.replace(/\/$/,"")}${r}`}function Bl({userId:e,username:r,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:b="xs",avatarVersion:f=0,className:g="",style:h}){const[C,v]=o.useState(!1),E=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";o.useEffect(()=>{v(!1)},[E,f]);const{wh:A,text:S}=kf[a],O=Hl(n)||Hl(r)||c,N=$f(O),y=Tf(d),T=Lf(r,n),w=Df(y,"/favicon.svg"),F=o.useMemo(()=>{if(!E)return"";const q=new URLSearchParams;q.set("size",String(Il[a])),f&&q.set("v",String(f));const ne=q.toString();return`${y}/api/user/avatar/${encodeURIComponent(E)}${ne?`?${ne}`:""}`},[f,y,E,a]),Y=Il[a],K=T?t.jsx("span",{className:`${A} ${Mf[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:h,children:t.jsx("img",{src:w,alt:O,width:Y,height:Y,className:"h-full w-full object-contain"})}):F&&!C?t.jsx("img",{src:F,alt:O,width:Y,height:Y,className:`${A} rounded-full object-cover flex-shrink-0 ${g}`,style:h,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${E}-${f}`):t.jsx("span",{className:`${A} ${Af(O)} ${S} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:h,title:O,children:N});if(s)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 ${Cf[b]} font-medium text-[var(--text-main)] ${m}`,title:O,children:O})]});const L=l??!0,G=i??O;return L&&G?t.jsx(Wt,{as:"span",content:G,className:`inline-flex flex-shrink-0 ${u}`,children:K}):K}function If({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Of(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Fl({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=If}){const[m,b]=o.useState(!1),f=Of(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Ll,{}),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:s}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:t.jsx(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,h])=>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:h.map(C=>{const v=n===C.href||n.startsWith(`${C.href}/`);return t.jsxs(u,{href:C.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:C.icon??t.jsx(j.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:C.label})]},C.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(Bl,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Ue,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(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 Pl="bonsaif-ui:prime-auth-sso",Hf={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"},xo={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 Bf(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Ff(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Pf(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,s=Ff(n)&&a?a:n,l=Hf[s]??Bf(s);return[{label:"Inicio",href:"/"},{label:l}]}function wo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function _f(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(xo[n])return xo[n];const a=r.length>1?r[r.length-2]:"";return xo[a]??t.jsx(j.HiHome,{className:"h-5 w-5"})}function zf(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function _l(){if(typeof window>"u")return!1;if(zf(window.location.href)){try{window.sessionStorage.setItem(Pl,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Pl)==="true"}catch{return!1}}function Wf({title:e,subtitle:r,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=o.useRef(null),[f,g]=o.useState(!1),[h,C]=o.useState(d??"/"),[v,E]=o.useState(()=>_l()),[A,S]=o.useState(null),O=d??h,N=c??Pf(O),y=s??_f(O),T=u&&!v&&N.length>1,w=!T;o.useEffect(()=>{d||C(window.location.pathname)},[d]),o.useEffect(()=>{E(_l())},[]),o.useEffect(()=>{if(m){g(!1);return}let Y=null,K=0,L=0;const G=()=>{const J=b.current,R=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??wo(R)??R??window},q=()=>{const J=Y&&Y!==window?Y.scrollTop:window.scrollY;g(R=>R?J>24:J>72)},ne=()=>{Y==null||Y.removeEventListener("scroll",q),Y=G(),Y.addEventListener("scroll",q,{passive:!0}),q()};return ne(),K=window.requestAnimationFrame(ne),L=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout(L),Y==null||Y.removeEventListener("scroll",q)}},[m]),o.useEffect(()=>{if(m){S(null);return}let Y=0;const K=[],L=()=>{const X=b.current,ce=X==null?void 0:X.parentElement,D=document.querySelector("[data-app-scroll='true']"),_=wo(D)??D;if(!X||!ce||!_){S(null);return}const le=ce.getBoundingClientRect(),I=window.getComputedStyle(ce),oe=_.getBoundingClientRect(),k=_ instanceof HTMLElement&&_.clientWidth>0?_.clientWidth:oe.width,te=le.left+parseFloat(I.paddingLeft||"0"),P={marginLeft:Math.round(oe.left-te),width:Math.round(k)};S(z=>z&&z.marginLeft===P.marginLeft&&z.width===P.width?z:P)},G=()=>{window.cancelAnimationFrame(Y),Y=window.requestAnimationFrame(L)};G(),window.addEventListener("resize",G);const q=new ResizeObserver(G),ne=b.current,J=ne==null?void 0:ne.parentElement,R=document.querySelector("[data-app-scroll='true']"),V=wo(R)??R;return[J,R,V].forEach(X=>{X&&q.observe(X)}),K.push(window.setTimeout(G,120)),K.push(window.setTimeout(G,280)),()=>{window.cancelAnimationFrame(Y),window.removeEventListener("resize",G),q.disconnect(),K.forEach(X=>window.clearTimeout(X))}},[m]);const F={...A?{marginLeft:A.marginLeft,width:A.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:F,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:T?"var(--text-secondary)":"var(--text-muted)"},children:y}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(Uo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function jf({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(Fl,{currentPath:r,...a,children:e})}function zl(){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 qf(e,r,n){try{const a=new URL(e),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function Uf({name:e,src:r,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(zl());const d=new MutationObserver(()=>s(zl()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=o.useMemo(()=>qf(r,a,n),[n,r,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const d=n;function u(m){var g,h,C;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((h=m.data)==null?void 0:h.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((C=m.data)==null?void 0:C.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 Vf(){const[e,r]=o.useState(""),[n,a]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:Wl(c.data.width,96,720),height:Wl(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Wl(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Xf(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 Yf(){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 Kf(){return"light"}function Gf({position:e="bottom-center"}){const r=o.useSyncExternalStore(Xf,Yf,Kf);return t.jsx(Ta.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Zf({title:e,subtitle:r,actions:n,loading:a=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const ln=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function jl(e,r){return e.color??ln[r%ln.length]}function Ht(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 yt=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 Lr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const No={warning:70,danger:90};function Qn(e,r=No){const n=r.warning??No.warning,a=r.danger??No.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function cn(e,r){return Ht(Qn(e,r))}function Dr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Ir(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const s=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function ql(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",s=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${a}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function Or(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const s=Lr((n=e[a])==null?void 0:n[r]);if(s!==null)return s}return null}function xt({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 wt({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 er=680,cr="ease-out",Qf={top:18,right:8,bottom:12,left:0};function dn(e){return{...Qf,...e}}function un(e){return e.map((r,n)=>({...r,color:jl(r,n),label:r.label??r.key}))}function Jn(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Lr(n[a.key])===null))}function Nt(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function fn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Ul(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Rn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Jf(e,r=yt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function Vl(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Rf({active:e,label:r,payload:n,valueFormat:a=yt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const s=n.filter(g=>g.dataKey!=="base"&&g.name!=="base"&&g.value!==null&&g.value!==void 0);if(!s.length)return null;const l=((d=(c=s[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=s[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=s[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((g,h)=>{const C=g.payload,v=C&&typeof C.display=="number"?C.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:Jf(v,a)})]},String(g.dataKey??g.name??h))})})]})}function Hr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Se.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:r??t.jsx(Rf,{valueFormat:e})})}function Xl(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Yl(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),s=Math.min(n-1,Math.max(e,r));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function ea(e,r,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=o.useState(null),[u,m]=o.useState(null),b=!!a&&e.length>1,f=b&&(s==="brush"||s==="both"),g=b&&(s==="drag"||s==="both"),h=o.useCallback(K=>{d(K),i==null||i(K)},[i]),C=o.useCallback(()=>{m(null),h(null)},[h]),v=!!c,E=o.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),A=o.useCallback((K,L)=>{const G=Xl(e,r,K),q=Xl(e,r,L);G<0||q<0||h(Yl(G,q,e.length))},[h,e,r]),S=o.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=o.useCallback(K=>{!g||!u||(K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m(L=>L&&{...L,rightLabel:K.activeLabel})},[u,g]),N=o.useCallback(()=>{if(g){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}A(u.leftLabel,u.rightLabel),m(null)}},[A,u,g]),y=o.useCallback(K=>{if(f){if(!K){h(null);return}h(Yl(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[h,e.length,f]),T=g?{onMouseDown:S,onMouseMove:O,onMouseUp:N,onMouseLeave:()=>{u&&N()}}:{},w=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},F=t.jsxs(t.Fragment,{children:[g&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Se.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Se.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:y,tickFormatter:K=>String(K)}):null]}),Y=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:E,isZoomed:v,resetZoom:C,chartHandlers:T,zoomNodes:F,marginExtra:Y}}function ta({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 eb({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=yt,yDomain:f,ariaLabel:g="Gráfico de líneas",curve:h=!0,strokeWidth:C=2.25,zoomable:v=!1,zoomMode:E="both",brushHeight:A,onZoomChange:S}){const O=Jn(e,n),N=un(n),y=ea(e,r,{zoomable:v,zoomMode:E,brushHeight:A,onZoomChange:S}),T=dn({...m,...y.marginExtra});return l?t.jsx(xt,{height:a}):O?t.jsx(wt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ta,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.LineChart,{data:y.viewData,margin:T,...y.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:fn(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:Nt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:Nt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Hr,{valueFormat:b,cursor:{stroke:Ul(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Rn()}):null,N.map((w,F)=>t.jsx(Se.Line,{type:h?"monotone":"linear",dataKey:w.key,name:w.label,stroke:w.color,strokeWidth:F===0?C+.35:C,strokeOpacity:F===0?1:.88,isAnimationActive:!0,animationDuration:er,animationEasing:cr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function ra({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=yt,yDomain:f,ariaLabel:g="Gráfico de área",stacked:h=!1,opacity:C=.22,zoomable:v=!1,zoomMode:E="both",brushHeight:A,onZoomChange:S}){const O=Jn(e,n),N=un(n),y=ea(e,r,{zoomable:v,zoomMode:E,brushHeight:A,onZoomChange:S}),T=dn({...m,...y.marginExtra});return l?t.jsx(xt,{height:a}):O?t.jsx(wt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ta,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.AreaChart,{data:y.viewData,margin:T,...y.chartHandlers,children:[t.jsx("defs",{children:N.map(w=>t.jsxs("linearGradient",{id:Vl(w.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:w.color,stopOpacity:Math.min(.55,C+.28)}),t.jsx("stop",{offset:"48%",stopColor:w.color,stopOpacity:C*.5}),t.jsx("stop",{offset:"100%",stopColor:w.color,stopOpacity:0})]},w.key))}),c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:fn(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:Nt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Se.YAxis,{tick:Nt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(Hr,{valueFormat:b,cursor:{stroke:Ul(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Rn()}):null,N.map(w=>t.jsx(Se.Area,{type:"monotone",dataKey:w.key,name:w.label,stroke:w.color,fill:`url(#${Vl(w.key)})`,strokeWidth:2.25,stackId:h?"stack":void 0,isAnimationActive:!0,animationDuration:er,animationEasing:cr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),y.zoomNodes]})})]})}function tb({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=yt,yDomain:f,ariaLabel:g="Gráfico de barras",layout:h="vertical",mode:C="grouped",barRadius:v=6,categoryAxisWidth:E=64,zoomable:A=!1,zoomMode:S="both",brushHeight:O,onZoomChange:N}){const y=Jn(e,n),T=un(n),w=h==="horizontal",F=ea(e,r,{zoomable:A&&!w,zoomMode:S,brushHeight:O,onZoomChange:N}),Y=dn({...m,...F.marginExtra});return l?t.jsx(xt,{height:a}):y?t.jsx(wt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(ta,{visible:F.isZoomed,onReset:F.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:F.viewData,margin:Y,layout:w?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...F.chartHandlers,children:[c?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:fn(),horizontal:!w,vertical:w}):null,w?t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{type:"number",tick:Nt(),tickLine:!1,axisLine:!1,tickFormatter:K=>b(Number(K)),domain:f??["auto","auto"]}),t.jsx(Se.YAxis,{type:"category",dataKey:r,tick:Nt(),tickLine:!1,axisLine:!1,width:E})]}):t.jsxs(t.Fragment,{children:[t.jsx(Se.XAxis,{dataKey:r,tick:Nt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:Nt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:K=>b(Number(K)),dx:-2})]}),u?t.jsx(Hr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Rn()}):null,T.map((K,L)=>t.jsx(Se.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:L===0?1:.82,radius:w?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:C==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:er,animationEasing:cr},K.key)),F.zoomNodes]})})]})}function rb(e){return t.jsx(Gl,{...e,variant:"pie"})}function nb(e){return t.jsx(Gl,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Kl(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Gl({data:e,nameKey:r,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=yt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:g=[...ln],padAngle:h,cornerRadius:C,variant:v}){const E=e.map((L,G)=>({name:String(L[r]??""),value:Lr(L[n])??0,fill:g[G%g.length],row:L})).filter(L=>L.value>0),A=!E.length,S=v==="donut",O=E.length,N=Kl(b,S?62:12),y=Kl(f,78),T=Math.min(h??(S?2:3),Math.max(.5,10/Math.max(1,O))),w=Math.min(C??(S?10:8),Math.max(2,36/Math.max(1,O)));if(l)return t.jsx(xt,{height:a});if(A)return t.jsx(wt,{height:a,text:i});const F=E.reduce((L,G)=>L+G.value,0),Y=c?Math.min(96,28+Math.ceil(O/3)*22):0,K=Math.max(140,a-Y);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${s}`,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(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Hr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Se.Pie,{data:E,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${N}%`,outerRadius:`${y}%`,startAngle:90,endAngle:-270,paddingAngle:T,cornerRadius:w,minAngle:O>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:er,animationEasing:cr,label:!1,activeShape:ab,children:E.map(L=>t.jsx(Se.Cell,{fill:L.fill},L.name))}),S?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(F)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:E.map(L=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:L.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:L.name,children:L.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(L.value)})]},L.name))}):null]})})}function ab(e){const{outerRadius:r=0,...n}=e;return t.jsx(Se.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function ob({data:e,dataKey:r,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??Ht(s),m=e.map(y=>Lr(y[r])).filter(y=>y!==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,h=1,C=Math.min(...m),E=Math.max(...m)-C||1,A=m.map((y,T)=>{const w=h+T/(m.length-1)*(b-h*2),F=f-g-(y-C)/E*(f-g*2);return{x:w,y:F}}),S=A.map((y,T)=>`${T===0?"M":"L"}${y.x.toFixed(2)} ${y.y.toFixed(2)}`).join(" "),O=`${S} L${A[A.length-1].x.toFixed(2)} ${f} L${A[0].x.toFixed(2)} ${f} Z`,N=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id: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:S,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function sb({data:e,xKey:r,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:b=!0,margin:f,valueFormat:g=yt,yDomain:h,ariaLabel:C="Gráfico combinado",barRadius:v=6,zoomable:E=!1,zoomMode:A="both",brushHeight:S,onZoomChange:O}){const N=a??n.slice(0,Math.max(1,n.length-1)),y=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),T=[...N,...y.filter(q=>!N.some(ne=>ne.key===q.key))],w=Jn(e,T),F=un(N),Y=un(T),K=y.map(q=>{var J;const ne=Y.find(R=>R.key===q.key);return{...q,label:q.label??q.key,color:q.color??(ne==null?void 0:ne.color)??((J=Y[0])==null?void 0:J.color)}}),L=ea(e,r,{zoomable:E,zoomMode:A,brushHeight:S,onZoomChange:O}),G=dn({...f,...L.marginExtra});return c?t.jsx(xt,{height:l}):w?t.jsx(wt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":C,style:{height:l},children:[t.jsx(ta,{visible:L.isZoomed,onReset:L.resetZoom}),t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.ComposedChart,{data:L.viewData,margin:G,barCategoryGap:"34%",...L.chartHandlers,children:[u?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:fn(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:r,tick:Nt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Se.YAxis,{tick:Nt(),tickLine:!1,axisLine:!1,width:44,domain:h??["auto","auto"],tickFormatter:q=>g(Number(q)),dx:-2}),b?t.jsx(Hr,{valueFormat:g,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Se.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Rn()}):null,F.map(q=>t.jsx(Se.Bar,{dataKey:q.key,name:q.label,fill:q.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:er,animationEasing:cr},q.key)),K.map(q=>t.jsx(Se.Line,{type:"monotone",dataKey:q.key,name:q.label,stroke:q.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:er,animationEasing:cr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:q.color}},q.key)),L.zoomNodes]})})]})}function lb({data:e,xKey:r,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=yt,ariaLabel:f="Gráfico waterfall",increaseColor:g="#34d399",decreaseColor:h="#f87171",totalColor:C="var(--primary)"}){const v=o.useMemo(()=>ib(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:h,totalColor:C}),[e,r,n,a,g,h,C]),E=!v.length,A=dn(m);return i?t.jsx(xt,{height:s}):E?t.jsx(wt,{height:s,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:s},children:t.jsx(Se.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Se.BarChart,{data:v,margin:A,barCategoryGap:"42%",children:[d?t.jsx(Se.CartesianGrid,{strokeDasharray:"2 8",stroke:fn(),vertical:!1}):null,t.jsx(Se.XAxis,{dataKey:"label",tick:Nt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Se.YAxis,{tick:Nt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:S=>b(Number(S)),dx:-2}),u?t.jsx(Hr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Se.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Se.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:er,animationEasing:cr,children:v.map(S=>t.jsx(Se.Cell,{fill:S.color},S.label))})]})})})}function ib(e,r){let n=0;return e.map((a,s)=>{const l=Lr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||s===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&s===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const Zl="bonsaif-funnel-chart-keyframes",cb=`
44
+ `}),O.map(j=>{const x=Mf(j.colorIndex);return M===j.id?t.jsx("input",{ref:J,value:_,disabled:o,onChange:T=>Y(T.target.value),onKeyDown:T=>w(T,j.id),onBlur:()=>le(j.id,_),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(_.length+2,6)}ch`}},j.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:x.bg,color:x.text,border:`1px solid ${x.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(),L(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(),I(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)}),!re&&t.jsx("input",{ref:ne,value:N,disabled:o,placeholder:O.length===0?a:"",onChange:j=>y(j.target.value),onKeyDown:oe,onPaste:B,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(Tr,{error:g,helperText:b,helperDisplay:f})]})}const Df=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Re(e){return String(e).padStart(2,"0")}function So(e,r=Hr()){const n=e.trim();if(!n)return r;const a=n.match(Df);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=`${Re(e.hour24)}:${Re(e.minute)}`;return r?`${n}:${Re(e.second)}`:n}function ta(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 Of(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=So(e);if(n){const l=ta(o),i=`${l.hour12}:${Re(l.minute)}`;return`${a?`${i}:${Re(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Hr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function Hf(e=!0){return un(Hr(),e)}function Eo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const wt=36,Co=5,Pl=Math.floor(Co/2),If=52,Bf=48,Vt=18;function _l(e){return e*wt}function zl(e){return Math.round(e/wt)}function Ff(e){return e.use12Hour??e.hour12??!1}function ra({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=If,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const h=s.useRef(null),E=s.useRef(null),v=s.useRef(null),S=s.useRef(""),A=s.useRef(0),C=s.useRef(!1),[O,N]=s.useState(r),[y,M]=s.useState(""),k=s.useCallback(L=>{S.current=L,M(L)},[]),_=s.useMemo(()=>[...Array(Pl).fill(""),...e,...Array(Pl).fill("")],[e]),Y=s.useCallback(()=>{const L=h.current;if(!L)return r;const oe=zl(L.scrollTop),w=Math.min(Math.max(oe,0),e.length-1);return e[w]??r},[r,e]),K=s.useCallback((L,oe=!0)=>{const w=Math.min(Math.max(L,0),e.length-1),te=e[w],B=h.current;!B||!te||(E.current&&(window.clearTimeout(E.current),E.current=null),C.current=!0,A.current=w,B.scrollTop=_l(w),N(te),oe&&te!==r&&n(te))},[n,r,e]);s.useLayoutEffect(()=>{E.current&&(window.clearTimeout(E.current),E.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),k(""),N(r);const L=e.indexOf(r);if(L>=0&&(A.current=L),L<0||!h.current)return;const oe=_l(L);h.current.scrollTop!==oe&&(h.current.scrollTop=oe)},[o,r,k,e]);const D=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),G=s.useCallback((L,oe=!1)=>{D(),k("");const w=Number(L);if(!Number.isFinite(w))return;const te=Math.min(c,Math.max(0,w));let B=Re(te),F=e.indexOf(B);if(F<0){const ue=Math.min(e.length-1,Math.max(0,te-(c===12?1:0)));B=e[ue]??B,F=e.indexOf(B)}F>=0&&K(F),oe&&(b==null||b())},[D,c,b,K,k,e]),U=s.useCallback(L=>{const oe=Math.floor(c/10),w=S.current;if(w===""){if(L>oe){G(String(L),!0);return}const B=String(L);k(B),v.current=window.setTimeout(()=>{G(S.current,!0)},1200);return}D();const te=+`${w}${L}`;te<=c?G(String(te),!0):G(String(L),!0)},[D,G,c,k]),ne=s.useCallback(L=>{D(),k(""),K(A.current+L)},[D,K,k]),J=L=>{if(d){L.key==="a"||L.key==="A"?(L.preventDefault(),n("AM"),b==null||b()):L.key==="p"||L.key==="P"?(L.preventDefault(),n("PM"),b==null||b()):L.key==="ArrowUp"||L.key==="ArrowDown"?(L.preventDefault(),n(r==="AM"?"PM":"AM")):L.key==="Tab"&&(L.preventDefault(),L.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(L.key)){L.preventDefault(),U(Number(L.key));return}L.key==="ArrowUp"?(L.preventDefault(),ne(-1)):L.key==="ArrowDown"?(L.preventDefault(),ne(1)):L.key==="Tab"&&(L.preventDefault(),D(),S.current!==""&&G(S.current,!1),L.shiftKey?f==null||f():b==null||b())},R=s.useCallback(()=>{const L=a.current,oe=h.current;oe&&L===a.current&&K(zl(oe.scrollTop))},[K,a]),V=()=>{if(S.current!=="")return;if(C.current){C.current=!1;const oe=Y();N(oe);const w=e.indexOf(oe);w>=0&&(A.current=w);return}N(Y()),E.current&&window.clearTimeout(E.current);const L=a.current;E.current=window.setTimeout(()=>{L===a.current&&R()},100)},X="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",de=wt*Co,H=de+Vt*2,I=y!==""?y:null,le=I!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":I??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:J,onBlur:()=>{D(),S.current!==""&&G(S.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:H,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:X,style:{top:0,height:Vt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:h,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Vt,height:de,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:V,onMouseUp:R,onTouchEnd:R,children:_.map((L,oe)=>{const w=L!==""&&L===O;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!L,onClick:()=>{if(!L)return;const te=e.indexOf(L);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:w?"var(--text-main)":"var(--text-muted)",fontSize:w?16:14,fontWeight:w?600:400,opacity:L?le?w?0:.35:w?1:.35:0},children:L},`wheel-${oe}-${L}`)})}),I!==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:Vt+de/2-wt/2,height:wt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:I}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:X,style:{bottom:0,height:Vt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Wl(){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 jl({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=Ff({use12Hour:n,hour12:a}),g=s.useRef(e),h=So(e,Hr()),E=ta(h),[v,S]=s.useState(Re(f?E.hour12:h.hour24)),[A,C]=s.useState(Re(h.minute)),[O,N]=s.useState(Re(h.second)),[y,M]=s.useState(E.meridiem),[k,_]=s.useState(0),Y=s.useRef(0),K=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[G,U]=s.useState("hour"),ne=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,o]),J=s.useCallback(ie=>{U(pe=>{const ae=ne.indexOf(pe);return ne[(ae+ie+ne.length)%ne.length]})},[ne]);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=So(e,Hr()),pe=ta(ie);S(Re(f?pe.hour12:ie.hour24)),C(Re(ie.minute)),N(Re(ie.second)),M(pe.meridiem)},[f,e]);const R=s.useMemo(()=>(f?Eo(1,12):Eo(0,23)).map(ie=>Re(ie)),[f]),V=s.useMemo(()=>Eo(0,59).map(ie=>Re(ie)),[]),X=V,de=s.useMemo(()=>["AM","PM"],[]),H=s.useCallback(()=>f?fn({hour12:Number(v),minute:Number(A),second:Number(O),meridiem:y}):{hour24:Number(v),minute:Number(A),second:Number(O)},[v,f,y,A,O]),I=s.useCallback(ie=>{if(K.current)return;const pe=un(ie,o);g.current=pe,r(pe)},[r,o]),le=s.useCallback(()=>{I(H())},[H,I]),L=ie=>{S(ie),b&&I(f?fn({hour12:Number(ie),minute:Number(A),second:Number(O),meridiem:y}):{hour24:Number(ie),minute:Number(A),second:Number(O)})},oe=ie=>{C(ie),b&&I(f?fn({hour12:Number(v),minute:Number(ie),second:Number(O),meridiem:y}):{hour24:Number(v),minute:Number(ie),second:Number(O)})},w=ie=>{N(ie),b&&I(f?fn({hour12:Number(v),minute:Number(A),second:Number(ie),meridiem:y}):{hour24:Number(v),minute:Number(A),second:Number(ie)})},te=ie=>{M(ie),b&&I(fn({hour12:Number(v),minute:Number(A),second:Number(O),meridiem:ie}))},B=s.useCallback(()=>(Y.current+=1,_(Y.current),Y.current),[]),F=s.useCallback(ie=>{const pe=ta(ie),ae=un(ie,o);g.current=ae,S(Re(f?pe.hour12:ie.hour24)),C(Re(ie.minute)),N(Re(ie.second)),M(pe.meridiem),r(ae)},[f,r,o]),ue=()=>{K.current=!0,B(),F(Hr()),queueMicrotask(()=>{const ie=Hr();un(ie,o)!==g.current&&(B(),F(ie)),K.current=!1})},re=()=>{le(),d==null||d()},j=wt*Co,x=j+Vt*2,T=Vt+j/2-wt/2,ee=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:x,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top: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:Vt,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:Vt,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(ra,{syncEpochRef:Y,forceSyncAt:k,values:R,selected:v,onSelect:L,label:"Horas",maxNumeric:f?12:23,isFocused:G==="hour",onFocus:()=>U("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{D.current.hour=ie}}),t.jsx(Wl,{}),t.jsx(ra,{syncEpochRef:Y,forceSyncAt:k,values:V,selected:A,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:G==="minute",onFocus:()=>U("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{D.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Wl,{}),t.jsx(ra,{syncEpochRef:Y,forceSyncAt:k,values:X,selected:O,onSelect:w,label:"Segundos",maxNumeric:59,isFocused:G==="second",onFocus:()=>U("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{D.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ra,{syncEpochRef:Y,forceSyncAt:k,values:de,selected:y,onSelect:ie=>te(ie),width:Bf,label:"AM o PM",isMeridiem:!0,isFocused:G==="meridiem",onFocus:()=>U("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-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(Ve,{variant:"ghost",size:"sm",onClick:ue,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ve,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ve,{variant:"primary",size:"sm",onClick: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 Pf(e){return e.use12Hour??e.hour12??!1}function _f({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:h,contentClassName:E,className:v=""}){const S=u==="popover",[A,C]=s.useState(!1),O=s.useRef(null),[N,y]=s.useState({horizontal:"left",vertical:"bottom"}),M=Pf({use12Hour:a,hour12:o}),k=s.useMemo(()=>r?Of(r,{use12Hour:M,showSeconds:l}):"",[M,l,r]);s.useEffect(()=>{if(!S||!A||!O.current)return;const K=O.current.getBoundingClientRect(),D=8,G=M?l?300:260:l?252:212,U=276,ne=K.left+G>window.innerWidth-D,J=K.right-G>=D,R=K.bottom+8+U>window.innerHeight-D,V=K.top-8-U>=D;y({horizontal:ne&&J?"right":"left",vertical:R&&V?"top":"bottom"})},[M,S,A,l]),s.useEffect(()=>{if(!S||!A)return;function K(G){O.current&&(O.current.contains(G.target)||C(!1))}function D(G){G.key==="Escape"&&C(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",D)}},[S,A]);const _=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||C(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)":A?"var(--primary)":"var(--border)",color:k?"var(--text-main)":"var(--text-muted)",boxShadow:A?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(W.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:k||c})]}),S?t.jsx(W.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${A?"rotate-180":""}`}):null]}),Y=t.jsx(jl,{variant:S?"popover":"panel",value:r||Hf(l),onChange:n,use12Hour:M,showSeconds:l,title:i,onClose:()=>C(!1)});return t.jsx(zn,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:h,contentClassName:E,children:S?t.jsxs("div",{ref:O,className:"relative w-full",children:[_,A?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:Y}):null]}):t.jsxs("div",{className:"space-y-2",children:[_,A?Y:null]})})}const zf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Wf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=zf[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 ql=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),jf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function qf(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 Ul(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Vl(e){Ul(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Uf(e){const r=e.querySelector(jf);return r instanceof HTMLElement?r:null}function Xl(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(ql).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Oa.OverlayScrollbars(l)){Vl(l);return}if(!qf(l))return;const c={overflow:Ul(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Uf(l),u=d?Oa.OverlayScrollbars({target:l,elements:{viewport:d}},c):Oa.OverlayScrollbars(l,c);Vl(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(ql).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function rr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Yl(e){try{const r=new URL(e);return rr(r.pathname)}catch{return""}}function Vf(e){const r=rr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return rr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?rr(`/${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())?"":rr(`/${a[0]}`)}const Mo="primeSuiteAppUrl",Xf={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"}},Kl={xs:20,sm:28,md:36,lg:48,xl:64},Gl=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Yf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Kf="bonsaif.bot",Gf="Bonsaif Bot",Zf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Zl(e){return typeof e=="string"?e.trim():""}function Qf(e){var o;if(e!==void 0)return rr(e);const r=rr(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(Mo)||"";i&&window.sessionStorage.setItem(Mo,i);const c=window.sessionStorage.getItem(Mo)||"",d=i||c;if(d){const u=Yl(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")?Yl(a):rr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Vf(window.location.pathname)}function Jf(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 Rf(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Gl[r%Gl.length]}function eb(e,r){return e===Kf||r===Gf}function tb(e,r){return`${e.replace(/\/$/,"")}${r}`}function Ql({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:h}){const[E,v]=s.useState(!1),S=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[S,f]);const{wh:A,text:C}=Xf[a],O=Zl(n)||Zl(r)||c,N=Jf(O),y=Qf(d),M=eb(r,n),k=tb(y,"/favicon.svg"),_=s.useMemo(()=>{if(!S)return"";const U=new URLSearchParams;U.set("size",String(Kl[a])),f&&U.set("v",String(f));const ne=U.toString();return`${y}/api/user/avatar/${encodeURIComponent(S)}${ne?`?${ne}`:""}`},[f,y,S,a]),Y=Kl[a],K=M?t.jsx("span",{className:`${A} ${Zf[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:h,children:t.jsx("img",{src:k,alt:O,width:Y,height:Y,className:"h-full w-full object-contain"})}):_&&!E?t.jsx("img",{src:_,alt:O,width:Y,height:Y,className:`${A} rounded-full object-cover flex-shrink-0 ${g}`,style:h,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${S}-${f}`):t.jsx("span",{className:`${A} ${Rf(O)} ${C} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:h,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 ${Yf[b]} font-medium text-[var(--text-main)] ${m}`,title:O,children:O})]});const D=l??!0,G=i??O;return D&&G?t.jsx(Bt,{as:"span",content:G,className:`inline-flex flex-shrink-0 ${u}`,children:K}):K}function rb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function nb(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Jl({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=rb}){const[m,b]=s.useState(!1),f=nb(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Xl,{}),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(([g,h])=>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"}),g]}),t.jsx("div",{className:"space-y-1",children:h.map(E=>{const v=n===E.href||n.startsWith(`${E.href}/`);return t.jsxs(u,{href:E.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${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:E.icon??t.jsx(W.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:E.label})]},E.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(Ql,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Ve,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(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 Rl="bonsaif-ui:prime-auth-sso",ab={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"},To={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 ob(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function sb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function lb(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=sb(n)&&a?a:n,l=ab[o]??ob(o);return[{label:"Inicio",href:"/"},{label:l}]}function $o(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function ib(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(To[n])return To[n];const a=r.length>1?r[r.length-2]:"";return To[a]??t.jsx(W.HiHome,{className:"h-5 w-5"})}function cb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function ei(){if(typeof window>"u")return!1;if(cb(window.location.href)){try{window.sessionStorage.setItem(Rl,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Rl)==="true"}catch{return!1}}function db({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),[h,E]=s.useState(d??"/"),[v,S]=s.useState(()=>ei()),[A,C]=s.useState(null),O=d??h,N=c??lb(O),y=o??ib(O),M=u&&!v&&N.length>1,k=!M;s.useEffect(()=>{d||E(window.location.pathname)},[d]),s.useEffect(()=>{S(ei())},[]),s.useEffect(()=>{if(m){g(!1);return}let Y=null,K=0,D=0;const G=()=>{const J=b.current,R=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??$o(R)??R??window},U=()=>{const J=Y&&Y!==window?Y.scrollTop:window.scrollY;g(R=>R?J>24:J>72)},ne=()=>{Y==null||Y.removeEventListener("scroll",U),Y=G(),Y.addEventListener("scroll",U,{passive:!0}),U()};return ne(),K=window.requestAnimationFrame(ne),D=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout(D),Y==null||Y.removeEventListener("scroll",U)}},[m]),s.useEffect(()=>{if(m){C(null);return}let Y=0;const K=[],D=()=>{const X=b.current,de=X==null?void 0:X.parentElement,H=document.querySelector("[data-app-scroll='true']"),I=$o(H)??H;if(!X||!de||!I){C(null);return}const le=de.getBoundingClientRect(),L=window.getComputedStyle(de),oe=I.getBoundingClientRect(),w=I instanceof HTMLElement&&I.clientWidth>0?I.clientWidth:oe.width,te=le.left+parseFloat(L.paddingLeft||"0"),B={marginLeft:Math.round(oe.left-te),width:Math.round(w)};C(F=>F&&F.marginLeft===B.marginLeft&&F.width===B.width?F:B)},G=()=>{window.cancelAnimationFrame(Y),Y=window.requestAnimationFrame(D)};G(),window.addEventListener("resize",G);const U=new ResizeObserver(G),ne=b.current,J=ne==null?void 0:ne.parentElement,R=document.querySelector("[data-app-scroll='true']"),V=$o(R)??R;return[J,R,V].forEach(X=>{X&&U.observe(X)}),K.push(window.setTimeout(G,120)),K.push(window.setTimeout(G,280)),()=>{window.cancelAnimationFrame(Y),window.removeEventListener("resize",G),U.disconnect(),K.forEach(X=>window.clearTimeout(X))}},[m]);const _={...A?{marginLeft:A.marginLeft,width:A.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:_,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":k?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||k?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||k?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:M?"var(--text-secondary)":"var(--text-muted)"},children:y}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(Jo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function ub({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(Jl,{currentPath:r,...a,children:e})}function ti(){if(typeof window>"u")return"system";const e=localStorage.getItem("theme");return e==="light"||e==="dark"?e:e==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function fb(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 bb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(ti());const d=new MutationObserver(()=>o(ti()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>fb(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,h,E;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((h=m.data)==null?void 0:h.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((E=m.data)==null?void 0:E.type)!=="prime-microservice:navigation")return;const 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 mb(){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:ri(c.data.width,96,720),height:ri(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 ri(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function pb(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 hb(){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 gb(){return"light"}function vb({position:e="bottom-center"}){const r=s.useSyncExternalStore(pb,hb,gb);return t.jsx(Ha.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function yb({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 ni(e,r){return e.color??bn[r%bn.length]}function _t(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 Ir(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ao={warning:70,danger:90};function na(e,r=Ao){const n=r.warning??Ao.warning,a=r.danger??Ao.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function mn(e,r){return _t(na(e,r))}function Br(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Fr(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 ai(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",o=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(o<1024)return`${a}${Math.round(o)} ${l[0]}`;let i=o/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function Pr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Ir((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 nr=680,fr="ease-out",xb={top:18,right:8,bottom:12,left:0};function pn(e){return{...xb,...e}}function hn(e){return e.map((r,n)=>({...r,color:ni(r,n),label:r.label??r.key}))}function aa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Ir(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 oi(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function oa(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function wb(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 si(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Nb({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,h)=>{const E=g.payload,v=E&&typeof E.display=="number"?E.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:wb(v,a)})]},String(g.dataKey??g.name??h))})})]})}function _r({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(Nb,{valueFormat:e})})}function li(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function ii(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 sa(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"),h=s.useCallback(K=>{d(K),i==null||i(K)},[i]),E=s.useCallback(()=>{m(null),h(null)},[h]),v=!!c,S=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),A=s.useCallback((K,D)=>{const G=li(e,r,K),U=li(e,r,D);G<0||U<0||h(ii(G,U,e.length))},[h,e,r]),C=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}A(u.leftLabel,u.rightLabel),m(null)}},[A,u,g]),y=s.useCallback(K=>{if(f){if(!K){h(null);return}h(ii(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[h,e.length,f]),M=g?{onMouseDown:C,onMouseMove:O,onMouseUp:N,onMouseLeave:()=>{u&&N()}}:{},k=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},_=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:k.startIndex,endIndex:k.endIndex,onChange:y,tickFormatter:K=>String(K)}):null]}),Y=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:S,isZoomed:v,resetZoom:E,chartHandlers:M,zoomNodes:_,marginExtra:Y}}function la({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 kb({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:h=!0,strokeWidth:E=2.25,zoomable:v=!1,zoomMode:S="both",brushHeight:A,onZoomChange:C}){const O=aa(e,n),N=hn(n),y=sa(e,r,{zoomable:v,zoomMode:S,brushHeight:A,onZoomChange:C}),M=pn({...m,...y.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(la,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.LineChart,{data:y.viewData,margin:M,...y.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:k=>b(Number(k)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:oi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,N.map((k,_)=>t.jsx(Me.Line,{type:h?"monotone":"linear",dataKey:k.key,name:k.label,stroke:k.color,strokeWidth:_===0?E+.35:E,strokeOpacity:_===0?1:.88,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:k.color}},k.key)),y.zoomNodes]})})]})}function ia({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:h=!1,opacity:E=.22,zoomable:v=!1,zoomMode:S="both",brushHeight:A,onZoomChange:C}){const O=aa(e,n),N=hn(n),y=sa(e,r,{zoomable:v,zoomMode:S,brushHeight:A,onZoomChange:C}),M=pn({...m,...y.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(la,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.AreaChart,{data:y.viewData,margin:M,...y.chartHandlers,children:[t.jsx("defs",{children:N.map(k=>t.jsxs("linearGradient",{id:si(k.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:k.color,stopOpacity:Math.min(.55,E+.28)}),t.jsx("stop",{offset:"48%",stopColor:k.color,stopOpacity:E*.5}),t.jsx("stop",{offset:"100%",stopColor:k.color,stopOpacity:0})]},k.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:k=>b(Number(k)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:oi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,N.map(k=>t.jsx(Me.Area,{type:"monotone",dataKey:k.key,name:k.label,stroke:k.color,fill:`url(#${si(k.key)})`,strokeWidth:2.25,stackId:h?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:k.color}},k.key)),y.zoomNodes]})})]})}function Sb({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:h="vertical",mode:E="grouped",barRadius:v=6,categoryAxisWidth:S=64,zoomable:A=!1,zoomMode:C="both",brushHeight:O,onZoomChange:N}){const y=aa(e,n),M=hn(n),k=h==="horizontal",_=sa(e,r,{zoomable:A&&!k,zoomMode:C,brushHeight:O,onZoomChange:N}),Y=pn({...m,..._.marginExtra});return l?t.jsx(kt,{height:a}):y?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(la,{visible:_.isZoomed,onReset:_.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:_.viewData,margin:Y,layout:k?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,..._.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!k,vertical:k}):null,k?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:S})]}):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(_r,{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:oa()}):null,M.map((K,D)=>t.jsx(Me.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:D===0?1:.82,radius:k?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:E==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr},K.key)),_.zoomNodes]})})]})}function Eb(e){return t.jsx(di,{...e,variant:"pie"})}function Cb(e){return t.jsx(di,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function ci(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function di({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:h,cornerRadius:E,variant:v}){const S=e.map((D,G)=>({name:String(D[r]??""),value:Ir(D[n])??0,fill:g[G%g.length],row:D})).filter(D=>D.value>0),A=!S.length,C=v==="donut",O=S.length,N=ci(b,C?62:12),y=ci(f,78),M=Math.min(h??(C?2:3),Math.max(.5,10/Math.max(1,O))),k=Math.min(E??(C?10:8),Math.max(2,36/Math.max(1,O)));if(l)return t.jsx(kt,{height:a});if(A)return t.jsx(St,{height:a,text:i});const _=S.reduce((D,G)=>D+G.value,0),Y=c?Math.min(96,28+Math.ceil(O/3)*22):0,K=Math.max(140,a-Y);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(_r,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Me.Pie,{data:S,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${N}%`,outerRadius:`${y}%`,startAngle:90,endAngle:-270,paddingAngle:M,cornerRadius:k,minAngle:O>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,label:!1,activeShape:Mb,children:S.map(D=>t.jsx(Me.Cell,{fill:D.fill},D.name))}),C?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(_)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:S.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 Mb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Me.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Tb({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??_t(o),m=e.map(y=>Ir(y[r])).filter(y=>y!==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,h=1,E=Math.min(...m),S=Math.max(...m)-E||1,A=m.map((y,M)=>{const k=h+M/(m.length-1)*(b-h*2),_=f-g-(y-E)/S*(f-g*2);return{x:k,y:_}}),C=A.map((y,M)=>`${M===0?"M":"L"}${y.x.toFixed(2)} ${y.y.toFixed(2)}`).join(" "),O=`${C} L${A[A.length-1].x.toFixed(2)} ${f} L${A[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:C,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function $b({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:h,ariaLabel:E="Gráfico combinado",barRadius:v=6,zoomable:S=!1,zoomMode:A="both",brushHeight:C,onZoomChange:O}){const N=a??n.slice(0,Math.max(1,n.length-1)),y=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),M=[...N,...y.filter(U=>!N.some(ne=>ne.key===U.key))],k=aa(e,M),_=hn(N),Y=hn(M),K=y.map(U=>{var J;const ne=Y.find(R=>R.key===U.key);return{...U,label:U.label??U.key,color:U.color??(ne==null?void 0:ne.color)??((J=Y[0])==null?void 0:J.color)}}),D=sa(e,r,{zoomable:S,zoomMode:A,brushHeight:C,onZoomChange:O}),G=pn({...f,...D.marginExtra});return c?t.jsx(kt,{height:l}):k?t.jsx(St,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":E,style:{height:l},children:[t.jsx(la,{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:h??["auto","auto"],tickFormatter:U=>g(Number(U)),dx:-2}),b?t.jsx(_r,{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:oa()}):null,_.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:nr,animationEasing:fr},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:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:U.color}},U.key)),D.zoomNodes]})})]})}function Ab({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:h="#f87171",totalColor:E="var(--primary)"}){const v=s.useMemo(()=>Lb(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:h,totalColor:E}),[e,r,n,a,g,h,E]),S=!v.length,A=pn(m);return i?t.jsx(kt,{height:o}):S?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:A,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:C=>b(Number(C)),dx:-2}),u?t.jsx(_r,{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:nr,animationEasing:fr,children:v.map(C=>t.jsx(Me.Cell,{fill:C.color},C.label))})]})})})}function Lb(e,r){let n=0;return e.map((a,o)=>{const l=Ir(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 ui="bonsaif-funnel-chart-keyframes",Db=`
45
45
  @keyframes bonsaif-funnel-stage-in {
46
46
  from {
47
47
  opacity: 0;
@@ -81,4 +81,4 @@ ${H}`,ge=new Blob(["\uFEFF"+ae],{type:"text/csv;charset=utf-8;"}),ke=URL.createO
81
81
  animation: none !important;
82
82
  }
83
83
  }
84
- `;function db(){if(typeof document>"u"||document.getElementById(Zl))return;const e=document.createElement("style");e.id=Zl,e.textContent=cb,document.head.appendChild(e)}function Ql(e,r,n){return Math.min(n,Math.max(r,e))}function na(e,r,n){const a=Ql(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function ub(e,r,n,a,s,l){const i=e.map((d,u)=>{const m=Lr(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",g=s?String(d[s]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...g?{description:g}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function fb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),s=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(s+r.gap),h:s,topW:b,bottomW:f,cx:r.cx}})}function bb({stage:e,hovered:r,onHover:n}){const{cx:a,y:s,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,g=s+l,h=Math.max(4,Math.min(14,l*.18)),C=na(d,"#000",r?.12:.22),v=na(d,"#fff",r?.08:0),E=na(d,"#fff",.22),A=[`M ${u} ${s}`,`L ${m} ${s}`,`L ${f} ${g}`,`L ${b} ${g}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:A,fill:C}),t.jsx("path",{d:[`M ${u} ${s}`,`L ${m} ${s}`,`L ${m} ${s+1}`,`L ${f} ${g}`,`L ${a} ${g}`,`L ${u} ${s}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:h,fill:E,stroke:na(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:h,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function mb({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:s,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:g=.42,colors:h=[...ln],animationDuration:C=er,valueFormat:v=yt,ariaLabel:E="Gráfico embudo"}){const[A,S]=o.useState(null),[O,N]=o.useState(!1),y=o.useMemo(()=>ub(e,r,n,a,s,h),[e,r,n,a,s,h]),T=o.useMemo(()=>y.map(k=>`${k.name}:${k.value}`).join("|"),[y]);if(o.useEffect(()=>{if(db(),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(xt,{height:l});if(!y.length)return t.jsx(wt,{height:l,text:d});const w=C>0&&!O,F=C,Y=Math.min(90,Math.max(40,Math.round(C/8))),K=Math.round(F*.15),L=y.length*Y+Math.round(F*.35),G=y.some(k=>k.title||k.description),q=m?160:24,ne=G?168:24,J=f?36:8,R=q+220+ne,V=l,X=18,ce=Math.max(120,V-X-J-8),D=q+110,le=fb(y,{cx:D,topY:X,plotH:ce,maxTopW:200,taper:Ql(g,.2,.95),gap:10}),I=A!=null?le[A]: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":E,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 ${F}ms ${oe} both`}:void 0,x1:q-12,y1:X,x2:q-12,y2:X+ce,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,le.map(k=>{const te=k.y+k.h/2,P=k.cx-k.topW/2,z=k.index*Y,de=w?{animation:`bonsaif-funnel-stage-in ${F}ms ${oe} ${z}ms both`}:void 0,re=w?{animation:`bonsaif-funnel-fade-in ${Math.round(F*.85)}ms ${oe} ${z+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:de,children:t.jsx(bb,{stage:k,hovered:A===k.index,onHover:S})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:re,children:[t.jsx("line",{x1:24,y1:te,x2:q-12,y2:te,stroke:k.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:q-12,y1:te,x2:P-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:q+220+8,y2:te,stroke:k.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),k.title?t.jsx("text",{x:q+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:q+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(${D}, ${X+ce+8})`,fill:"var(--primary)",style:w?{animation:`bonsaif-funnel-arrow-in ${Math.round(F*.7)}ms ${oe} ${L}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},T),u&&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 Br=135*Math.PI/180,ko=270*Math.PI/180;function pb({value:e,min:r=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=yt,tone:m="primary",color:b,thresholds:f,ariaLabel:g="Gauge",animationDuration:h=700,thickness:C=9,showScale:v=!1}){const E=o.useId().replace(/:/g,""),A=n-r||1,S=Math.min(1,Math.max(0,(e-r)/A)),[O,N]=o.useState(h>0?0:S);if(o.useEffect(()=>{if(l||i)return;if(h<=0){N(S);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){N(S);return}let R=0,V=0;N(D=>(V=D,D));const X=performance.now(),ce=D=>{const _=Math.min(1,(D-X)/h),le=1-(1-_)**3;N(V+(S-V)*le),_<1&&(R=requestAnimationFrame(ce))};return R=requestAnimationFrame(ce),()=>cancelAnimationFrame(R)},[S,h,l,i]),l)return t.jsx(xt,{height:a});if(i)return t.jsx(wt,{height:a,text:c});const y=100,T=108,w=72,F=b??hb(e,n,m,f),Y=r+O*A,K=Jl(y,T,w,Br,Br+ko),L=Br+Math.max(.001,O)*ko,G=Jl(y,T,w,Br,L),q=aa(y,T,w,Br),ne=aa(y,T,w,Br+ko);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":g,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${E}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:F,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:F,stopOpacity:1})]})}),t.jsx("path",{d:K,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:C,strokeLinecap:"butt"}),t.jsx("path",{d:G,fill:"none",stroke:`url(#bonsaif-gauge-${E})`,strokeWidth:C,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:y,y:T-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(Y)}),d?t.jsx("text",{x:y,y:T+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:q.x-2,y:q.y+C+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ne.x+2,y:ne.y+C+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function hb(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 Ht(n);const s=e/(r||1);return s>=.8?Ht("success"):s>=.5?Ht("warning"):Ht("danger")}function aa(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function Jl(e,r,n,a,s){const l=aa(e,r,n,a),i=aa(e,r,n,s),c=s-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function gb({value:e,target:r,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:b=yt,tone:f="primary",showScale:g=!0,showStatus:h=!0,ariaLabel:C="Bullet chart"}){if(i)return t.jsx(xt,{height:s});if(c)return t.jsx(wt,{height:s,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(F=>F.value))??[],1)*1.05,A=[...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((F,Y)=>F.value-Y.value),S=Ht(f),O=Math.min(100,Math.max(0,e/v*100)),N=Math.min(100,Math.max(0,r/v*100)),y=e>=r,T=[0,.25,.5,.75,1].map(F=>F*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:s*.42)},role:"img","aria-label":C,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:A.map((F,Y)=>{const K=Y===0?0:A[Y-1].value,L=Math.max(0,(F.value-K)/v*100);return t.jsx("div",{style:{width:`${L}%`,background:F.color??`color-mix(in srgb, var(--border) ${70-Y*18}%, transparent)`}},Y)})}),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:S,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${S} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${N}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:S,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),g?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:T.map((F,Y)=>{const K=F/v*100,L=Y===0,G=Y===T.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${K}%`,transform:L?"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:L?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:L?"left":G?"right":"center"},children:b(F)})]},F)})}):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:S,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),h?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Ht(y?"success":"warning")},children:y?"En meta":"Bajo meta"}):null]}),w]}):w})}function vb({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:f,label:g="CPU",ariaLabel:h="Uso de CPU"}){var N;const C=s??[{key:a,label:"Uso",color:cn(r??Or(e,a)??0,f)}],v=r??Or(e,a)??Or(e,((N=C[0])==null?void 0:N.key)??a),E=!d&&(!e.length||v===null);if(d)return t.jsx(xt,{height:i});if(E)return t.jsx(wt,{height:i,text:u});const A=Math.min(100,Math.max(0,v??0)),S=Qn(A,f),O=cn(A,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":h,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:Dr(A,A<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:O,background:`color-mix(in srgb, ${O} 14%, transparent)`},children:S==="danger"?"Crítico":S==="warning"?"Alto":"Normal"})]}),t.jsx(ra,{data:e,xKey:n,series:C.map(y=>({...y,color:y.color??O})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:y=>Dr(y,0),ariaLabel:h,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function yb({used:e,total:r,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:f,label:g="RAM",ariaLabel:h="Uso de memoria"}){const C=r>0?r:1,v=Math.min(100,Math.max(0,e/C*100)),E=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(xt,{height:i});if(E)return t.jsx(wt,{height:i,text:u});const A=Qn(v,f),S=cn(v,f),O=Math.max(0,r-e),N=a.length>0?Or(a,l)??v:v,y=cn(N,f),T=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":h,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:S},children:Dr(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Ir(e)," / ",Ir(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:S,background:`color-mix(in srgb, ${S} 14%, transparent)`},children:A==="danger"?"Crítico":A==="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} ${Dr(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${S}, color-mix(in srgb, ${S} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Ir(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Ir(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Ir(O)]})]})]}),m&&a.length>1?t.jsx(ra,{data:a,xKey:s,series:[{key:l,label:"Uso",color:y}],height:T,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:w=>Dr(w,0),ariaLabel:`${h} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const xb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",wb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Nb({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=xb,outboundColor:m=wb,height:b=240,className:f="",loading:g=!1,emptyText:h="Sin datos de red",showLegend:C=!1,showTooltip:v=!0,label:E="Network",ariaLabel:A="Tráfico de red"}){const S=s??Or(e,n)??0,O=l??Or(e,a)??0,N=!g&&e.length===0;if(g)return t.jsx(xt,{height:b});if(N)return t.jsx(wt,{height:b,text:h});const y=F=>ql(F,i),w=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":A,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:E}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:y(S),children:y(S)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background: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:y(O),children:y(O)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ra,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:w,showLegend:C,showTooltip:v,valueFormat:y,ariaLabel:A,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Rl=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],ei=["primeSuiteOrigin","primeSuiteProjectKey"];function kb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of Rl){const n=e.get(r);if(n){const a=oa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of ei){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=oa(n);if(a)return a}}if(document.referrer){const r=oa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Cb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of Rl)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of ei)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=oa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function oa(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 Sb(e){const[r,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=o.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),d=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(U,"toast",{enumerable:!0,get:()=>Ta.toast}),U.Alert=Ri,U.AreaChart=ra,U.AuthShell=Fl,U.AutoGrowTextarea=yl,U.AutoGrowTextareaField=Qu,U.BarChart=tb,U.BonsaifButton=Oi,U.BonsaifUIToaster=Gf,U.BulletChart=gb,U.Button=Ue,U.CHART_PALETTE=ln,U.CalendarPicker=ac,U.ChartCard=Zf,U.Checkbox=Nn,U.CodeBlock=cc,U.ComboChart=sb,U.CompactFilterSelect=fc,U.CompactSearchInput=uc,U.ConfirmDialog=hc,U.CopyButton=Da,U.CopyLinkButton=xc,U.CpuChart=vb,U.DataSheets=Xc,U.DataTable=ds,U.DateRangePicker=Qc,U.DonutChart=nb,U.Drawer=ld,U.DropdownMenu=od,U.DynamicDetailTabs=Qi,U.EmailField=Ad,U.EmptyState=Dd,U.FieldHelperFooter=Cr,U.FieldLabelInfo=kr,U.FieldLayoutEditor=Pd,U.FileUpload=Bd,U.FormField=On,U.FunnelChart=mb,U.GaugeChart=pb,U.GlobalScrollbars=Ll,U.ImageLightbox=As,U.ImageLightboxHost=Yd,U.InputField=Ya,U.LineChart=eb,U.LoadingState=Ko,U.MentionTextEditor=hl,U.MicroserviceFrame=Uf,U.Modal=Ha,U.MouseTooltip=Wt,U.MultiDateCalendar=ed,U.MultiSelect=Gd,U.NetworkChart=Nb,U.NumberField=Zd,U.PageHeader=Wf,U.PageSearchInput=qo,U.Pagination=Jd,U.PhoneField=eu,U.PieChart=rb,U.PrimeAuthRouteShell=jf,U.PrimeSuiteChatFrame=Vf,U.RadioGroup=tu,U.RamChart=yb,U.RichTextEditor=Bu,U.SearchableSelect=lr,U.SectionPanel=Fu,U.Sparkline=ob,U.StatusBadge=zu,U.StatusSelect=Vu,U.StepWizard=Yu,U.TableSkeleton=wn,U.Tabs=Xu,U.TagInput=lf,U.TextInput=In,U.Textarea=xl,U.TextareaField=rf,U.TimeField=hf,U.TimePicker=Ml,U.Toggle=vf,U.TruncatedWithTooltip=jt,U.UserAvatar=Bl,U.WaterfallChart=lb,U.YearMultiDateCalendar=rd,U.buildMentionQueryRegex=Zs,U.clearMentionChipSelection=$r,U.cn=Gt,U.configureBonsaifUI=kc,U.dedupeMentions=tl,U.defaultValueFormat=yt,U.deleteEditorSelection=dl,U.describeParentTargetOrigin=Cb,U.emailFormat=bd,U.ensureMentionChipTrailingSpaces=an,U.extractMentionUsernames=lo,U.filterSelfMentions=$u,U.findMentionChipAfterCaret=fl,U.findMentionChipBeforeCaret=ul,U.findMentionChipsInSelection=bo,U.findMentionTriggerInEditor=oo,U.formatBytes=Ir,U.formatPercent=Dr,U.formatRate=ql,U.getBonsaifUIConfig=Cc,U.getDataTablePreferencesEndpoint=Ba,U.getEditorPlainText=fo,U.getPlainTextOffset=Un,U.highlightMentions=rl,U.htmlToText=Rs,U.insertMentionInEditor=al,U.isMentionTriggerBoundary=Js,U.isPlainOffsetInsideMentionChip=Qs,U.isValidEmail=Ua,U.isValidPhone=Va,U.locateTextOffset=Tr,U.matches=yd,U.maxLength=hd,U.maxValue=vd,U.mentionDisplayLabel=el,U.minLength=pd,U.minValue=gd,U.normalizeUsername=so,U.openImageLightboxFromEvent=Ts,U.phoneCountryCodeOptions=Is,U.phoneFormat=md,U.placeCaretAfterMentionChip=co,U.placeCaretAtTextOffset=ol,U.preferredMentionSpacer=io,U.removeMentionChip=Yn,U.required=fd,U.resetBonsaifUIConfig=Sc,U.resolveMentions=Tu,U.resolveParentTargetOrigin=kb,U.selectAllEditorContents=il,U.selectMentionChip=ll,U.selectionIncludesNonChipText=cl,U.seriesColor=jl,U.setBonsaifDataTablePreferencesEndpoint=Ec,U.syncMentionChipSelectionHighlight=Xn,U.toneColor=Ht,U.usageColor=cn,U.usageTone=Qn,U.useValidationVisibility=Sb,U.validateForm=xd,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
84
+ `;function Ob(){if(typeof document>"u"||document.getElementById(ui))return;const e=document.createElement("style");e.id=ui,e.textContent=Db,document.head.appendChild(e)}function fi(e,r,n){return Math.min(n,Math.max(r,e))}function ca(e,r,n){const a=fi(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function Hb(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=Ir(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 Ib(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 Bb({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,h=Math.max(4,Math.min(14,l*.18)),E=ca(d,"#000",r?.12:.22),v=ca(d,"#fff",r?.08:0),S=ca(d,"#fff",.22),A=[`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:A,fill:E}),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:h,fill:S,stroke:ca(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:h,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function Fb({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:h=[...bn],animationDuration:E=nr,valueFormat:v=Nt,ariaLabel:S="Gráfico embudo"}){const[A,C]=s.useState(null),[O,N]=s.useState(!1),y=s.useMemo(()=>Hb(e,r,n,a,o,h),[e,r,n,a,o,h]),M=s.useMemo(()=>y.map(w=>`${w.name}:${w.value}`).join("|"),[y]);if(s.useEffect(()=>{if(Ob(),typeof window>"u")return;const w=window.matchMedia("(prefers-reduced-motion: reduce)");N(w.matches);const te=()=>N(w.matches);return w.addEventListener("change",te),()=>w.removeEventListener("change",te)},[]),c)return t.jsx(kt,{height:l});if(!y.length)return t.jsx(St,{height:l,text:d});const k=E>0&&!O,_=E,Y=Math.min(90,Math.max(40,Math.round(E/8))),K=Math.round(_*.15),D=y.length*Y+Math.round(_*.35),G=y.some(w=>w.title||w.description),U=m?160:24,ne=G?168:24,J=f?36:8,R=U+220+ne,V=l,X=18,de=Math.max(120,V-X-J-8),H=U+110,le=Ib(y,{cx:H,topY:X,plotH:de,maxTopW:200,taper:fi(g,.2,.95),gap:10}),L=A!=null?le[A]: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":S,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:k?"bonsaif-funnel-label":void 0,style:k?{animation:`bonsaif-funnel-fade-in ${_}ms ${oe} both`}:void 0,x1:U-12,y1:X,x2:U-12,y2:X+de,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,le.map(w=>{const te=w.y+w.h/2,B=w.cx-w.topW/2,F=w.index*Y,ue=k?{animation:`bonsaif-funnel-stage-in ${_}ms ${oe} ${F}ms both`}:void 0,re=k?{animation:`bonsaif-funnel-fade-in ${Math.round(_*.85)}ms ${oe} ${F+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:ue,children:t.jsx(Bb,{stage:w,hovered:A===w.index,onHover:C})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:re,children:[t.jsx("line",{x1:24,y1:te,x2:U-12,y2:te,stroke:w.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:U-12,y1:te,x2:B-6,y2:te,stroke:w.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:te-(b?6:0),textAnchor:"end",fill:w.color,fontSize:12,fontWeight:600,children:w.name.length>18?`${w.name.slice(0,16)}…`:w.name}),b?t.jsx("text",{x:20,y:te+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(w.value)}):null]}):null,(w.title||w.description)&&G?t.jsxs("g",{className:"bonsaif-funnel-anno",style:re,children:[t.jsx("line",{x1:w.cx+w.bottomW/2+6,y1:te,x2:U+220+8,y2:te,stroke:w.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),w.title?t.jsx("text",{x:U+220+14,y:te-(w.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:w.title.length>22?`${w.title.slice(0,20)}…`:w.title}):null,w.description?t.jsx("text",{x:U+220+14,y:te+(w.title?10:0),fill:"var(--text-muted)",fontSize:11,children:w.description.length>28?`${w.description.slice(0,26)}…`:w.description}):null]}):null]},`${w.name}-${w.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${H}, ${X+de+8})`,fill:"var(--primary)",style:k?{animation:`bonsaif-funnel-arrow-in ${Math.round(_*.7)}ms ${oe} ${D}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},M),u&&L?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:L.color},children:L.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(L.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(L.pct*100),"% del top)"]})]}):null]})}const zr=135*Math.PI/180,Lo=270*Math.PI/180;function Pb({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:h=700,thickness:E=9,showScale:v=!1}){const S=s.useId().replace(/:/g,""),A=n-r||1,C=Math.min(1,Math.max(0,(e-r)/A)),[O,N]=s.useState(h>0?0:C);if(s.useEffect(()=>{if(l||i)return;if(h<=0){N(C);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){N(C);return}let R=0,V=0;N(H=>(V=H,H));const X=performance.now(),de=H=>{const I=Math.min(1,(H-X)/h),le=1-(1-I)**3;N(V+(C-V)*le),I<1&&(R=requestAnimationFrame(de))};return R=requestAnimationFrame(de),()=>cancelAnimationFrame(R)},[C,h,l,i]),l)return t.jsx(kt,{height:a});if(i)return t.jsx(St,{height:a,text:c});const y=100,M=108,k=72,_=b??_b(e,n,m,f),Y=r+O*A,K=bi(y,M,k,zr,zr+Lo),D=zr+Math.max(.001,O)*Lo,G=bi(y,M,k,zr,D),U=da(y,M,k,zr),ne=da(y,M,k,zr+Lo);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-${S}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:_,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:_,stopOpacity:1})]})}),t.jsx("path",{d:K,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:E,strokeLinecap:"butt"}),t.jsx("path",{d:G,fill:"none",stroke:`url(#bonsaif-gauge-${S})`,strokeWidth:E,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:y,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(Y)}),d?t.jsx("text",{x:y,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+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ne.x+2,y:ne.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function _b(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 _t(n);const o=e/(r||1);return o>=.8?_t("success"):o>=.5?_t("warning"):_t("danger")}function da(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function bi(e,r,n,a,o){const l=da(e,r,n,a),i=da(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 zb({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:h=!0,ariaLabel:E="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(_=>_.value))??[],1)*1.05,A=[...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((_,Y)=>_.value-Y.value),C=_t(f),O=Math.min(100,Math.max(0,e/v*100)),N=Math.min(100,Math.max(0,r/v*100)),y=e>=r,M=[0,.25,.5,.75,1].map(_=>_*v),k=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:o*.42)},role:"img","aria-label":E,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:A.map((_,Y)=>{const K=Y===0?0:A[Y-1].value,D=Math.max(0,(_.value-K)/v*100);return t.jsx("div",{style:{width:`${D}%`,background:_.color??`color-mix(in srgb, var(--border) ${70-Y*18}%, transparent)`}},Y)})}),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:C,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${C} 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:C,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((_,Y)=>{const K=_/v*100,D=Y===0,G=Y===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(_)})]},_)})}):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:C,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),h?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:_t(y?"success":"warning")},children:y?"En meta":"Bajo meta"}):null]}),k]}):k})}function Wb({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:h="Uso de CPU"}){var N;const E=o??[{key:a,label:"Uso",color:mn(r??Pr(e,a)??0,f)}],v=r??Pr(e,a)??Pr(e,((N=E[0])==null?void 0:N.key)??a),S=!d&&(!e.length||v===null);if(d)return t.jsx(kt,{height:i});if(S)return t.jsx(St,{height:i,text:u});const A=Math.min(100,Math.max(0,v??0)),C=na(A,f),O=mn(A,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":h,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:Br(A,A<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:O,background:`color-mix(in srgb, ${O} 14%, transparent)`},children:C==="danger"?"Crítico":C==="warning"?"Alto":"Normal"})]}),t.jsx(ia,{data:e,xKey:n,series:E.map(y=>({...y,color:y.color??O})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:y=>Br(y,0),ariaLabel:h,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function jb({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:h="Uso de memoria"}){const E=r>0?r:1,v=Math.min(100,Math.max(0,e/E*100)),S=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(kt,{height:i});if(S)return t.jsx(St,{height:i,text:u});const A=na(v,f),C=mn(v,f),O=Math.max(0,r-e),N=a.length>0?Pr(a,l)??v:v,y=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":h,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:C},children:Br(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Fr(e)," / ",Fr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:C,background:`color-mix(in srgb, ${C} 14%, transparent)`},children:A==="danger"?"Crítico":A==="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} ${Br(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${C}, color-mix(in srgb, ${C} 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"})," ",Fr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Fr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Fr(O)]})]})]}),m&&a.length>1?t.jsx(ia,{data:a,xKey:o,series:[{key:l,label:"Uso",color:y}],height:M,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:k=>Br(k,0),ariaLabel:`${h} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const qb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Ub="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Vb({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=qb,outboundColor:m=Ub,height:b=240,className:f="",loading:g=!1,emptyText:h="Sin datos de red",showLegend:E=!1,showTooltip:v=!0,label:S="Network",ariaLabel:A="Tráfico de red"}){const C=o??Pr(e,n)??0,O=l??Pr(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:h});const y=_=>ai(_,i),k=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":A,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:S}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:y(C),children:y(C)})]}),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:y(O),children:y(O)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ia,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:k,showLegend:E,showTooltip:v,valueFormat:y,ariaLabel:A,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const mi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],pi=["primeSuiteOrigin","primeSuiteProjectKey"];function Xb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of mi){const n=e.get(r);if(n){const a=ua(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of pi){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=ua(n);if(a)return a}}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Yb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of mi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of pi)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function ua(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 Kb(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(q,"toast",{enumerable:!0,get:()=>Ha.toast}),q.Alert=mc,q.AreaChart=ia,q.AuthShell=Jl,q.AutoGrowTextarea=Hl,q.AutoGrowTextareaField=wf,q.BarChart=Sb,q.BonsaifButton=Gi,q.BonsaifUIToaster=vb,q.BulletChart=zb,q.Button=Ve,q.CHART_PALETTE=bn,q.CalendarPicker=yc,q.ChartCard=yb,q.Checkbox=Mn,q.CodeBlock=ed,q.ComboChart=$b,q.CompactFilterSelect=rd,q.CompactSearchInput=td,q.ConfirmDialog=sd,q.CopyButton=Va,q.CopyLinkButton=dd,q.CpuChart=Wb,q.DataSheets=gd,q.DataTable=qa,q.DateRangePicker=Nd,q.DonutChart=Cb,q.Drawer=Dd,q.DropdownMenu=Ad,q.DynamicDetailTabs=fc,q.EmailField=tu,q.EmptyState=Hn,q.EventCalendar=Qc,q.FieldHelperFooter=Tr,q.FieldLabelInfo=Mr,q.FieldLayoutEditor=lu,q.FileUpload=ou,q.FormField=zn,q.FunnelChart=Fb,q.GaugeChart=Pb,q.GlobalScrollbars=Xl,q.ImageLightbox=Vs,q.ImageLightboxHost=hu,q.InputField=to,q.LineChart=kb,q.LoadingState=rs,q.MentionTextEditor=Ll,q.MicroserviceFrame=bb,q.Modal=Xa,q.MouseTooltip=Bt,q.MultiDateCalendar=Ed,q.MultiSelect=vu,q.NetworkChart=Vb,q.NumberField=yu,q.PageHeader=db,q.PageSearchInput=Qo,q.Pagination=wu,q.PhoneField=ku,q.PieChart=Eb,q.PrimeAuthRouteShell=ub,q.PrimeSuiteChatFrame=mb,q.RadioGroup=Su,q.RamChart=jb,q.RichTextEditor=of,q.SearchableSelect=dr,q.SectionPanel=sf,q.Sparkline=Tb,q.StatusBadge=df,q.StatusSelect=pf,q.StepWizard=gf,q.TableSkeleton=Cn,q.Tabs=hf,q.TagInput=Lf,q.TextInput=_n,q.Textarea=Il,q.TextareaField=Cf,q.TimeField=_f,q.TimePicker=jl,q.Toggle=Wf,q.TruncatedWithTooltip=qt,q.UserAvatar=Ql,q.WaterfallChart=Ab,q.YearMultiDateCalendar=Md,q.buildMentionQueryRegex=ul,q.chunkMonthWeeks=xs,q.clearMentionChipSelection=Or,q.cn=Zt,q.computeWeekBars=Ua,q.configureBonsaifUI=Ec,q.dedupeMentions=hl,q.defaultValueFormat=Nt,q.deleteEditorSelection=El,q.describeParentTargetOrigin=Yb,q.emailFormat=Pd,q.ensureMentionChipTrailingSpaces=dn,q.extractMentionUsernames=ho,q.filterSelfMentions=Ju,q.findMentionChipAfterCaret=Ml,q.findMentionChipBeforeCaret=Cl,q.findMentionChipsInSelection=wo,q.findMentionTriggerInEditor=mo,q.formatBytes=Fr,q.formatPercent=Br,q.formatRate=ai,q.getBonsaifUIConfig=Cc,q.getDataTablePreferencesEndpoint=za,q.getEditorPlainText=xo,q.getMonthGrid=ys,q.getPlainTextOffset=Zn,q.getWeekDays=vs,q.groupItemsByDay=ws,q.highlightMentions=gl,q.htmlToText=ml,q.insertMentionInEditor=yl,q.isMentionTriggerBoundary=bl,q.isPlainOffsetInsideMentionChip=fl,q.isValidEmail=Ja,q.isValidPhone=Ra,q.locateTextOffset=Dr,q.matches=Ud,q.maxLength=Wd,q.maxValue=qd,q.mentionDisplayLabel=pl,q.minLength=zd,q.minValue=jd,q.normalizeUsername=po,q.openImageLightboxFromEvent=qs,q.phoneCountryCodeOptions=Ks,q.phoneFormat=_d,q.placeCaretAfterMentionChip=vo,q.placeCaretAtTextOffset=xl,q.preferredMentionSpacer=go,q.removeMentionChip=Rn,q.required=Fd,q.resetBonsaifUIConfig=Mc,q.resolveMentions=Qu,q.resolveParentTargetOrigin=Xb,q.selectAllEditorContents=kl,q.selectMentionChip=Nl,q.selectionIncludesNonChipText=Sl,q.seriesColor=ni,q.setBonsaifDataTablePreferencesEndpoint=Tc,q.syncMentionChipSelectionHighlight=Jn,q.toDateKey=Rt,q.toneColor=_t,q.usageColor=mn,q.usageTone=na,q.useValidationVisibility=Kb,q.validateForm=Vd,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})}));