bonsaif-ui 0.1.164 → 0.1.166
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.
- package/CHANGELOG.md +4 -0
- package/dist/bonsaif-ui.js +7097 -6733
- package/dist/bonsaif-ui.umd.cjs +29 -29
- package/dist/components/icons/FileTypeIcon.d.ts +11 -0
- package/dist/components/icons/FileTypeIcon.d.ts.map +1 -0
- package/dist/components/icons/createIcon.d.ts +20 -0
- package/dist/components/icons/createIcon.d.ts.map +1 -0
- package/dist/components/icons/fileIcons.d.ts +42 -0
- package/dist/components/icons/fileIcons.d.ts.map +1 -0
- package/dist/components/icons/fileTypeIconMeta.d.ts +8 -0
- package/dist/components/icons/fileTypeIconMeta.d.ts.map +1 -0
- package/dist/components/icons/index.d.ts +8 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/notifications/BonsaifUIToaster.d.ts.map +1 -1
- package/dist/components/ui/VideoPlayer.d.ts +3 -1
- package/dist/components/ui/VideoPlayer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(I,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],s):(I=typeof globalThis<"u"?globalThis:I||self,s(I.BonsaifUI={},I.React,I.jsxRuntime,I.ReactIconsHi2,I.ReactDOM,I.Recharts,I.OverlayScrollbarsGlobal,I.Sonner,I.OverlayScrollbarsReact,I.ReactDayPicker,I.ReactDayPickerStyles,I.ReactIconsFi))})(this,(function(I,s,t,H,ft,Ie,Xa,Ya,ws,Ga,ym,Oc){"use strict";"use client";function We(...e){return e.filter(Boolean).join(" ")}function Ic({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:We("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function Ns({value:e,onChange:r,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:f}){const d=s.useRef(null),[h,b]=s.useState(!1),u=l||h||e.trim().length>0,p=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",v=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var g;o&&((g=d.current)==null||g.focus())},[o]);const w=()=>{var g;b(!0),(g=d.current)==null||g.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${u?v:"w-24 sm:w-28"}`,onMouseDown:g=>{u||(g.preventDefault(),w())},children:[t.jsx(H.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:d,type:"text",tabIndex:f,"aria-label":n,value:e,onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(i==null||i())},placeholder:u?n:"Buscar",className:`${p} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${u?"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:u?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:g=>{b(!0),g.currentTarget.style.borderColor="var(--primary)",g.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:g=>{b(!1),g.currentTarget.style.borderColor="var(--border)",g.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(H.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const ks=s.createContext({});let Ss=0;const Cs="bonsaif-ui:hide-tooltips";function Bn(e=700){Ss=Date.now()+e}function Bc(){return Date.now()>Ss}function Fn(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 Fc(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 Vt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:f="",style:d,tooltipStyle:h,as:b="div"}){const u=s.useRef(null),p=s.useRef(null),v=s.useRef(null),w=s.useRef(!1),[g,E]=s.useState(null),[y,M]=s.useState("");s.useEffect(()=>{const $=u.current;$&&($.querySelectorAll("[title]").forEach(Q=>{const X=Q.getAttribute("title");X&&(Q.getAttribute("aria-label")||Q.setAttribute("aria-label",X),Q.removeAttribute("title"))}),$.querySelectorAll("svg title").forEach(Q=>Q.remove()))}),s.useLayoutEffect(()=>{if(!g)return;const $=p.current;if(!$)return;const Q=12,X=14,se=$.getBoundingClientRect(),J=window.innerWidth-se.width-Q,fe=window.innerHeight-se.height-Q;let te=g.mouseX+X,z=g.mouseY+X,R,A;if(!o&&u.current){const F=u.current.getBoundingClientRect(),ue=F.left+F.width/2,P=F.top+F.height/2;l==="top"?(te=ue-se.width/2,z=F.top-se.height-X,A=se.height-1):l==="left"?(te=F.left-se.width-X,z=P-se.height/2,R=se.width-1):l==="right"?(te=F.right+X,z=P-se.height/2,R=-7):(te=ue-se.width/2,z=F.bottom+X,A=-7)}if(o&&(te>J&&(te=g.mouseX-se.width-X),z>fe&&(z=g.mouseY-se.height-X)),te=Math.min(Math.max(Q,te),Math.max(Q,J)),z=Math.min(Math.max(Q,z),Math.max(Q,fe)),!o&&u.current){const F=u.current.getBoundingClientRect(),ue=F.left+F.width/2,P=F.top+F.height/2;l==="top"||l==="bottom"?R=Math.min(Math.max(14,ue-te),se.width-14):A=Math.min(Math.max(14,P-z),se.height-14)}(Math.abs(te-g.x)>.5||Math.abs(z-g.y)>.5||R!==g.arrowX||A!==g.arrowY)&&E(F=>F&&{...F,x:te,y:z,arrowX:R,arrowY:A})},[o,l,g]);const L=()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},C=($,Q)=>{if(!Bc()||w.current)return;const X=u.current;if(X&&!Fn(X)){if(n){const se=Fc(X);if(!se)return;M(se)}!n&&!r||E({mouseX:$,mouseY:Q,x:$+14,y:Q+14})}},m=()=>{const $=u.current;if(!$)return;const Q=$.getBoundingClientRect();C(Q.left+Q.width/2,Q.bottom)},k=()=>{L(),E(null)},N=()=>{if(!a){k();return}L(),v.current=window.setTimeout(()=>E(null),120)},_=()=>{Bn(),w.current=!0,k()},q=()=>{w.current=!1};s.useEffect(()=>{if(!g)return;if(Fn(u.current)){E(null);return}const $=()=>E(null),Q=()=>{Bn(),w.current=!0,E(null)};document.addEventListener("pointerdown",Q,!0),document.addEventListener("click",Q,!0),document.addEventListener("scroll",$,!0),window.addEventListener("blur",$),document.addEventListener("visibilitychange",$),document.addEventListener("keydown",$,!0);const X=new MutationObserver(()=>{Fn(u.current)&&E(null)});return X.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Q,!0),document.removeEventListener("click",Q,!0),document.removeEventListener("scroll",$,!0),window.removeEventListener("blur",$),document.removeEventListener("visibilitychange",$),document.removeEventListener("keydown",$,!0),X.disconnect()}},[g]),s.useEffect(()=>{const $=()=>Bn(),Q=()=>{Bn(),w.current=!0,E(null)};return document.addEventListener("pointerdown",$,!0),document.addEventListener("click",$,!0),document.addEventListener("keydown",$,!0),window.addEventListener(Cs,Q),()=>{document.removeEventListener("pointerdown",$,!0),document.removeEventListener("click",$,!0),document.removeEventListener("keydown",$,!0),window.removeEventListener(Cs,Q)}},[]);const K=n?y:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:$=>{u.current=$},className:c,style:d,onMouseEnter:$=>{L(),q(),o?C($.clientX,$.clientY):m()},onMouseMove:$=>{g&&o&&C($.clientX,$.clientY)},onMouseDown:_,onClick:_,onMouseLeave:()=>{q(),N()},onFocus:m,onBlur:k,children:e}),g&&K&&!Fn(u.current)?ft.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:f,onMouseEnter:a?L:void 0,onMouseLeave:a?N:void 0,style:{position:"fixed",top:g.y,left:g.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...h},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(h==null?void 0:h.background)??"var(--bg-card)",borderLeft:l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:g.arrowX===void 0?void 0:g.arrowX-6,top:g.arrowY===void 0?void 0:g.arrowY-6,zIndex:-1}}),K]}),document.body):null]})}function Es(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Pc="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",_c={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"},zc="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",Wc={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"},jc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},qc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ka(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ka).join(" ").trim():s.isValidElement(e)?Ka(e.props.children):""}function Uc(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ke({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:f,className:d="",disabled:h,style:b,...u}){const p=s.useContext(ks),v=l??p.iconOnly??e==="icon",w=p.compact??!1,g=p.headerAction??!1,E=g&&r==="md"?"sm":w&&!g&&r==="md"?"xs":r,y=e==="icon"||v,M=g&&y,L=Ka(f),C=o??u.title??u["aria-label"]??(v?L:void 0),m=C?void 0:u.title,k=u["aria-label"]??(typeof C=="string"?C:L||void 0),N=n?null:a??(v?Uc(f):null),_=t.jsxs("button",{...u,title:m,"aria-label":k,"data-variant":e,"data-size":E,"data-icon":y?"true":void 0,disabled:h||n,className:`${Pc} ${M?zc:_c[e]} ${y?jc[E]:Wc[E]} ${w&&!y?"px-2.5":""} ${d}`,style:{...qc[e],height:Es(i),padding:Es(c),...b,...g&&!y?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...M?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):N,!v&&f]});return C?t.jsx(Vt,{as:"span",content:C,className:"inline-flex shrink-0",children:_}):_}const kt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Pn({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)),f=o?"px-2 py-2":"px-3 py-2.5",d=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:kt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:kt})]}),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:kt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:kt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((h,b)=>t.jsx("div",{className:`${d} 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:{...kt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((h,b)=>Array.from({length:i}).map((u,p)=>t.jsx("div",{className:`${f} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...kt,width:`${46+(b*13+p*11)%42}%`,minWidth:28}})},`c-${b}-${p}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:kt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:kt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((h,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:kt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:kt})]})]})}function Vc({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 Xc({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 Ms({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:f,className:d=""}){if(e==="table")return t.jsx(Pn,{rows:i,columns:c,className:d});if(e==="sections")return t.jsx(Yc,{rows:i});if(e==="cards")return t.jsx(Gc,{rows:i});const h=o||(typeof r=="string"?r:"Aplicación"),b=l==="bare",u=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(Xc,{logoSrc:a,logoAlt:h}):null,t.jsx(Vc,{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,f&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:f})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${d}`,role:"status","aria-live":"polite","aria-busy":"true",children:u}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${d}`,role:"status","aria-live":"polite","aria-busy":"true",children:u})}function Yc({rows:e}){return t.jsx(Pn,{rows:e,columns:7})}function Gc({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:kt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:kt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:kt})]},n))})}function Ts(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 Ls(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Kc(e){return[e.label,Ts(e.service),e.description,e.service].filter(Boolean).join(" ")}function Zc(e){return typeof e=="function"?e:e.default}function Qc(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ke,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Jc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:f,initialService:d,onActiveServiceChange:h,canAccess:b,keepAlive:u=!0,title:p,subtitle:v,emptyState:w,loadingState:g,errorState:E=Qc,renderTabLabel:y,searchableTabs:M="auto",tabsSearchThreshold:L=6,tabsSearchPlaceholder:C="Buscar modulo...",tabsSearchValue:m,onTabsSearchChange:k,emptySearchState:N,showTabCount:_=!0,className:q="",parentClassName:K="",contentClassName:$="",tabsClassName:Q=""}){var we;const X=s.useMemo(()=>l.filter(ne=>!ne.hidden&&((b==null?void 0:b(ne,o))??!0)),[b,o,l]),se=(we=X.find(ne=>!ne.disabled))==null?void 0:we.service,[J,fe]=s.useState(d??se??""),[te,z]=s.useState({}),[R,A]=s.useState({}),[F,ue]=s.useState(""),[P,oe]=s.useState(!1),j=s.useRef(R),S=s.useRef(0),U=m??F,T=Ls(U),Y=M===!0||M==="auto"&&X.length>=L,ce=Y&&U.trim().length>0,V=s.useMemo(()=>T?X.filter(ne=>Ls(Kc(ne)).includes(T)):X,[T,X]),G=f??J,D=X.find(ne=>ne.service===G)??X.find(ne=>!ne.disabled);s.useEffect(()=>{!D&&se&&fe(se)},[se,D]),s.useEffect(()=>{j.current=R},[R]);const le=ne=>{ne.disabled||(f||fe(ne.service),h==null||h(ne.service,ne))},be=ne=>{m===void 0&&ue(ne),k==null||k(ne)},ie=(ne,Oe)=>{const qe=V.filter(Ze=>!Ze.disabled),Qe=qe.findIndex(Ze=>Ze.service===Oe.service);Qe<0||((ne.key==="ArrowRight"||ne.key==="ArrowDown")&&(ne.preventDefault(),le(qe[(Qe+1)%qe.length])),(ne.key==="ArrowLeft"||ne.key==="ArrowUp")&&(ne.preventDefault(),le(qe[(Qe-1+qe.length)%qe.length])),ne.key==="Home"&&(ne.preventDefault(),le(qe[0])),ne.key==="End"&&(ne.preventDefault(),le(qe[qe.length-1])))},ge=s.useCallback(()=>{if(!D)return;const ne=D.service,Oe=j.current[ne];if(Oe!=null&&Oe.loading||Oe!=null&&Oe.component&&u)return;const qe=(i==null?void 0:i[ne])??c;if(!qe){A(Ze=>({...Ze,[ne]:{loading:!1,error:new Error(`No module loader found for service "${ne}".`)}}));return}const Qe=++S.current;A(Ze=>({...Ze,[ne]:{...Ze[ne],loading:!0,error:void 0}})),qe(D,o).then(Ze=>{if(Qe!==S.current&&!u)return;const Ue=Zc(Ze);A(et=>({...et,[ne]:{component:Ue,loading:!1}}))}).catch(Ze=>{const Ue=Ze instanceof Error?Ze:new Error(String(Ze));A(et=>({...et,[ne]:{...et[ne],loading:!1,error:Ue}}))})},[o,u,c,i,D]);s.useEffect(ge,[ge]);const $e=D?te[D.service]??null:null,De=D?R[D.service]:void 0,Nt=De==null?void 0:De.component,yt=ne=>{D&&z(Oe=>({...Oe,[D.service]:ne}))},re=()=>{D&&z(ne=>({...ne,[D.service]:null}))},xe={context:o,parent:a,links:l,visibleLinks:X,filteredLinks:V,selectedLink:D,selectedService:D==null?void 0:D.service,activeItemId:$e,tabsSearch:U,onSelectService:le,onOpenDetail:yt,onBackToList:re},ae=n?n(xe):r?t.jsx(r,{...xe}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${q}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${K}`,children:ae}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${$}`,children:[(p||v||Y||_)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[p&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),v&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:v})]}),(Y||_)&&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:[V.length," / ",X.length]}),Y&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${P?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!P,children:t.jsx(Ns,{value:U,onChange:be,placeholder:C,className:"w-full",autoFocus:P,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:P?0:-1})}),t.jsx("button",{type:"button","aria-label":P?"Cerrar busqueda":"Buscar tabs","aria-expanded":P,onClick:()=>{P&&U&&be(""),oe(ne=>!ne)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${P||ce?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:P||ce?t.jsx(H.HiXMark,{className:"h-4 w-4"}):t.jsx(H.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":p??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Q}`,children:V.length>0?V.map(ne=>{const Oe=ne.service===(D==null?void 0:D.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Oe,disabled:ne.disabled,onClick:()=>le(ne),onKeyDown:qe=>ie(qe,ne),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Oe?"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:y?y(ne,Oe):t.jsxs(t.Fragment,{children:[ne.icon,t.jsx("span",{children:ne.label??Ts(ne.service)}),ne.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ne.badge})]})},ne.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:N??"No hay modulos que coincidan con la busqueda."})}),(D==null?void 0:D.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:D.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!D&&(w??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),D&&(De==null?void 0:De.loading)&&(g??t.jsx(Ms,{title:"Cargando modulo..."})),D&&(De==null?void 0:De.error)&&E(De.error,ge),D&&Nt&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(Nt,{context:o,parent:a,link:D,activeItemId:$e,onOpenDetail:yt,onBackToList:re})]})]})]})}const Rc={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(H.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(H.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(H.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(H.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(H.HiInformationCircle,{className:"h-5 w-5"})}};function ed({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=Rc[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&t.jsx("div",{className:"mt-3",children:o})]}),l&&t.jsx(Ke,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(H.HiXMark,{className:"h-4 w-4"})})]})}const As=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],td=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],rd=["lu","ma","mi","ju","vi","sá","do"],$s=6;function Za(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function nd(){const e=new Date;return Za(e.getFullYear(),e.getMonth()+1,e.getDate())}function Qa(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function ad(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Qa(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${As[n-1]} ${r}`}function Ds(e){const{year:r,month:n,day:a}=Qa(e);if(!r||!n||!a)return!1;const o=new Date(r,n-1,a).getDay();return o===0||o===6}function od({value:e,onChange:r,minDate:n,maxDate:a,disableWeekends:o=!1,displayMode:l="inline",className:i=""}){const c=nd(),d=Qa(e||c),h=l==="popover",[b,u]=s.useState(!1),p=s.useRef(null),[v,w]=s.useState({horizontal:"left",vertical:"bottom"}),[g,E]=s.useState(d.year),[y,M]=s.useState(d.month),[L,C]=s.useState("days"),m=16,[k,N]=s.useState(0),_=g-7+k,q=Array.from({length:m},(z,R)=>_+R);s.useEffect(()=>{if(!h||!b||!p.current)return;const z=p.current.getBoundingClientRect(),R=8,A=280,F=340,ue=z.left+A>window.innerWidth-R,P=z.right-A>=R,oe=z.bottom+8+F>window.innerHeight-R,j=z.top-8-F>=R;w({horizontal:ue&&P?"right":"left",vertical:oe&&j?"top":"bottom"})},[h,b]),s.useEffect(()=>{if(!h||!b)return;function z(A){p.current&&(p.current.contains(A.target)||u(!1))}function R(A){A.key==="Escape"&&u(!1)}return document.addEventListener("mousedown",z),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("keydown",R)}},[h,b]);function K(){y===1?(E(z=>z-1),M(12)):M(z=>z-1)}function $(){y===12?(E(z=>z+1),M(1)):M(z=>z+1)}const Q=(new Date(g,y-1,1).getDay()+6)%7,X=new Date(g,y,0).getDate(),se=[...Array(Q).fill(null),...Array.from({length:X},(z,R)=>R+1)];for(;se.length<$s*7;)se.push(null);const J=se.slice(0,$s*7);function fe(z){const R=Za(g,y,z);n&&R<n||a&&R>a||o&&Ds(R)||(r(R),h&&u(!1))}const te=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${i}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:L==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:K,"aria-label":"Mes anterior",children:t.jsx(H.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{C("years"),N(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[As[y-1]," ",g]}),t.jsx(H.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:$,"aria-label":"Mes siguiente",children:t.jsx(H.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(z=>z-m),"aria-label":"Años anteriores",children:t.jsx(H.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:[q[0]," – ",q[q.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(z=>z+m),"aria-label":"Años siguientes",children:t.jsx(H.HiChevronRight,{size:16})})]})}),L==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:td.map((z,R)=>{const A=R+1===y;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${A?" is-active":""}`,onClick:()=>M(R+1),children:z},z)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:q.map(z=>{const R=z===g,A=z===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${R?" is-active":""}${A&&!R?" is-today":""}`,onClick:()=>{E(z),C("days")},children:z},z)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:rd.map(z=>t.jsx("div",{className:"bonsaif-multi-weekday",children:z},z))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:J.map((z,R)=>{if(z===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},R);const A=Za(g,y,z),F=A===e,ue=A===c,P=!!(n&&A<n)||!!(a&&A>a)||o&&Ds(A);return t.jsx("div",{className:`bonsaif-multi-day${F?" bonsaif-multi-day-selected":""}${ue?" bonsaif-multi-day-today":""}${P?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:P,"aria-pressed":F,onClick:()=>!P&&fe(z),children:z})},R)})})]})]})});return h?t.jsxs("div",{ref:p,className:`relative w-full ${i}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>u(z=>!z),className:"bonsaif-cal-trigger","data-open":b?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(H.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:ad(e)})]}),t.jsx(H.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${b?"rotate-180":""}`})]}),b&&t.jsx("div",{className:"absolute z-50",style:{...v.horizontal==="left"?{left:0}:{right:0},...v.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:te})]}):te}function Rt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Vt,{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 Ja(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ra(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function sd(e,r){if(!r.trim())return!0;const n=Ra(r);return Ra(e.label).includes(n)||!!(e.sublabel&&Ra(e.sublabel).includes(n))}function vr({value:e,onChange:r,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:f,disabled:d=!1,className:h="",style:b,dropdownMinWidth:u,dropdownZIndex:p=9999,height:v=40,padding:w="0 10px",searchable:g=!0,minOptionsForSearch:E=6}){const[y,M]=s.useState(!1),[L,C]=s.useState(""),[m,k]=s.useState(-1),[N,_]=s.useState(!1),[q,K]=s.useState({}),$=s.useRef(null),Q=s.useRef(null),X=s.useRef(null),se=s.useRef(null),J=g&&n.length>=E,fe=n.find(T=>T.value===e)??null,te=l==="ghost",z=a==="error"?"var(--danger)":y?"var(--primary)":"var(--border)",R=J&&L.trim()?n.filter(T=>sd(T,L)):n,A=s.useCallback(()=>{const T=$.current;if(!(T!=null&&T.isConnected))return;const Y=T.getBoundingClientRect();if(Y.width<1&&Y.height<1||Y.bottom<0||Y.top>window.innerHeight)return;const ce=J?272:212,V=window.innerHeight-Y.bottom,G=V<ce&&Y.top>V,D=8,le=Math.max(Y.width,0),be=Math.max(D,window.innerWidth-le-D),ie=Math.min(Math.max(D,Y.left),be);K({position:"fixed",left:ie,top:G?void 0:Y.bottom+4,bottom:G?window.innerHeight-Y.top+4:void 0,width:Y.width,minWidth:Ja(u),zIndex:p})},[u,p,J]);s.useEffect(()=>_(!0),[]),s.useEffect(()=>{if(!y)return;function T(Y){var V,G;const ce=Y.target;!((V=$.current)!=null&&V.contains(ce))&&!((G=Q.current)!=null&&G.contains(ce))&&(M(!1),C(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[y]),s.useEffect(()=>{y&&(k(-1),A(),J&&setTimeout(()=>{var T;return(T=X.current)==null?void 0:T.focus()},0))},[y,J,A]),s.useEffect(()=>{if(y)return window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[y,A]),s.useEffect(()=>{if(m<0||!se.current)return;const T=se.current.children[m];T==null||T.scrollIntoView({block:"nearest"})},[m]);const F=s.useCallback(T=>{r(T),M(!1),C("")},[r]),ue=s.useRef(y);ue.current=y;const P=s.useRef(R);P.current=R;const oe=s.useRef(m);oe.current=m;const j=s.useRef(f);j.current=f;const S=s.useRef(F);S.current=F,s.useEffect(()=>{function T(Y){var D,le;const ce=document.activeElement,V=((D=$.current)==null?void 0:D.contains(ce))??!1,G=((le=Q.current)==null?void 0:le.contains(ce))??!1;if(!(!V&&!G)){if(!ue.current){(Y.key==="Enter"||Y.key===" "||Y.key==="ArrowDown")&&(Y.preventDefault(),M(!0));return}switch(Y.key){case"ArrowDown":Y.preventDefault(),k(be=>Math.min(be+1,P.current.length-1));break;case"ArrowUp":Y.preventDefault(),k(be=>Math.max(be-1,j.current?-1:0));break;case"Enter":{Y.preventDefault();const be=oe.current,ie=P.current;be===-1&&j.current?S.current(""):ie[be]&&!ie[be].disabled&&S.current(ie[be].value);break}case"Escape":Y.preventDefault(),Y.stopPropagation(),M(!1),C("");break}}}return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const U=t.jsxs("div",{ref:Q,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[J&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(H.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:X,value:L,onChange:T=>{C(T.target.value),k(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),L&&t.jsx("button",{type:"button",onMouseDown:T=>{T.preventDefault(),C("")},children:t.jsx(H.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:se,role:"listbox",className:"overflow-y-auto",style:{maxHeight:J?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[f&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:T=>{T.preventDefault(),F("")},onMouseEnter:()=>k(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:m===-1&&!L.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:f}),R.map((T,Y)=>{const V=Y===m,G=T.value===e;return t.jsxs("li",{role:"option","aria-selected":G,onMouseDown:D=>{D.preventDefault(),T.disabled||F(T.value)},onMouseEnter:()=>!T.disabled&&k(Y),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:V?"var(--bg-hover)":G?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:T.disabled?"var(--text-muted)":"var(--text-main)",cursor:T.disabled?"not-allowed":"pointer",boxShadow:G?"inset 2px 0 0 var(--primary)":void 0},children:[T.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:T.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Rt,{className:"min-w-0 flex-1",children:T.label}),T.sublabel&&t.jsx(Rt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:T.sublabel})]}),T.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:T.badge})]},T.value)}),R.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:$,className:`relative ${h||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:d,onClick:()=>!d&&M(T=>!T),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Ja(v),padding:Ja(w),background:te?"transparent":"var(--bg-input)",color:fe?"var(--text-main)":"var(--text-muted)",border:te?"1px solid transparent":`1px solid ${z}`,opacity:d?.5:1,cursor:d?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":y,"aria-label":o,children:[(fe==null?void 0:fe.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:fe.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:fe?t.jsxs(t.Fragment,{children:[t.jsx(Rt,{className:"min-w-0 flex-1",children:fe.label}),i&&fe.sublabel&&t.jsx(Rt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:fe.sublabel})]}):t.jsx(Rt,{className:"min-w-0 flex-1",children:c})}),fe&&f?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:T=>{T.preventDefault(),T.stopPropagation(),F("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(H.HiXMark,{className:"w-3 h-3"})}):t.jsx(H.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:y?"rotate(180deg)":"rotate(0deg)"}})]}),y&&N&&ft.createPortal(U,document.body)]})}const ld={sm:"h-4 w-4",md:"h-5 w-5"};function id(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const _n=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:f,...d},h){const b=s.useRef(null);return s.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${f?"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",{...d,ref:u=>{b.current=u,id(h,u)},type:"checkbox",disabled:f,"aria-checked":l?"mixed":d["aria-checked"],"aria-invalid":!!a||d["aria-invalid"],className:`peer ${ld[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(H.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})]})]})}),Hs=32767;function zn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=Hs?r:`${r.slice(0,Hs-1)}…`}const Wn=[25,50,100,200,500];let Pt={dataTable:{pageSizeOptions:[...Wn]}};function cd(){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 eo(){const e=Pt.dataTable.preferencesEndpoint,r=cd();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function dd(e){if(!Array.isArray(e))return[...Wn];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:[...Wn]}function Os(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function ud(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=Os(e.dataTable.preferencesEndpoint);Pt={...Pt,dataTable:{...Pt.dataTable,pageSizeOptions:dd(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Pt.dataTable.preferencesEndpoint}}}function fd(){return{dataTable:{pageSizeOptions:[...Pt.dataTable.pageSizeOptions]}}}function cn(){return[...Pt.dataTable.pageSizeOptions]}function bd(){Pt={dataTable:{pageSizeOptions:[...Wn]}}}function hd(e){Pt={...Pt,dataTable:{...Pt.dataTable,preferencesEndpoint:Os(e)}}}const jn=[{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"}],pd=jn.map(e=>({value:e.value,label:e.label})),md=12,gd={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Is={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},vd="bonsaif-ui:datatable:",xd="[&_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",yd=[],wd=52;function er(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function Bs(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.filterOptionValues&&Object.keys(e.filterOptionValues).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function Fs(e){return`${vd}${e}`}function qn(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 Nd(e,r){try{window.localStorage.setItem(Fs(e),JSON.stringify(r))}catch{}}function kd(e,r){if(e===!0)return{...Is};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...Is};const n={...gd,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function Ps(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function to(e,r,n){return typeof e!="number"||e<=0?n:hn(r).includes(e)?e:n}function dn(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function un(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 Sd(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=[...new Set(o.filter(i=>typeof i=="string"&&i.trim().length>0))];return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Cd(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!o||typeof o!="object")return[];const l=Object.fromEntries(Object.entries(o).flatMap(([i,c])=>typeof i=="string"&&i.trim()&&typeof c=="string"&&c.trim()?[[i,c]]:[]));return Object.keys(l).length>0?[[a,l]]:[]});return Object.fromEntries(n)}function fn(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(jn.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 Mt(e,r){if(xr(e))return wd;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Ed(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function xr(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function ro(e){return e.sticky===!0}function _s(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Un(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 f=r[c],d=a.indexOf(f);if(d!==-1){i=d+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const f=r[c],d=a.indexOf(f);if(d!==-1){i=d;break}}a.splice(i,0,l)}return a}function or(e,r){const n=r.filter(ro).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 Md(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 sr(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 Td(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function Hr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Hr).join(" ").trim():s.isValidElement(e)?Hr(e.props.children):""}function Vn(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?Td(n):Hr(n).trim()}function bn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Or(e,r){const n=bn(e),a=bn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function hn(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:cn()}function Ld(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=jn.find(f=>f.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 Or(e,a)>0;case"greaterThanOrEqual":return Or(e,a)>=0;case"lessThan":return Or(e,a)<0;case"lessThanOrEqual":return Or(e,a)<=0;case"between":return Or(e,a)>=0&&Or(e,o)<=0;case"top10":case"bottom10":{const d=n.map(b=>({value:b,number:bn(b)})).filter(b=>b.number!==null).sort((b,u)=>b.number-u.number).map(b=>b.value);return(r.operator==="top10"?d.slice(-10):d.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const f=n.map(bn).filter(b=>b!==null);if(f.length===0)return!1;const d=f.reduce((b,u)=>b+u,0)/f.length,h=bn(e);return h===null?!1:r.operator==="aboveAverage"?h>d:h<d}default:return!0}}function zs({children:e,className:r="",style:n}){return t.jsx(Vt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function no({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:f,renderExpandedRow:d,getRowCanExpand:h,expandedRowIds:b,defaultExpandedRowIds:u=[],onExpandedRowIdsChange:p,expandOnRowClick:v=!1,selected:w,onToggleOne:g,onToggleAll:E,getRowSelectable:y,highlightSelected:M=!0,rowClassName:L,getRowCategory:C,stickyHeader:m=!0,pageSize:k=25,pageSizeOptions:N,pageSizeSelectWidth:_=62,pageSizeSelectHeight:q=30,pageSizeSelectPadding:K="0 7px",totalRows:$,page:Q,onPageChange:X,onPageSizeChange:se,storageKey:J,stickyFirstColumn:fe=!1,bottomOffset:te=0,compact:z=!0,restrictHeight:R=!0,maxHeight:A,minTableWidth:F,enableColumnVisibility:ue=!0,enableColumnFilters:P=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:j=yd,onHiddenColumnKeysChange:S,columnVisibilityLabel:U="Columnas",enableBql:T=!1,bqlValue:Y,defaultBqlValue:ce="",onBqlChange:V,bqlDescription:G="Filtra registros con Bonsaif Query Language",bqlPlaceholder:D=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:le=[],bqlExamples:be=[],bqlSuggestions:ie=[],bqlActiveFilters:ge,bqlError:$e,onQueryChange:De,persistState:Nt,onPreferencesReady:yt,enableExport:re=!1,exportFilename:xe="datos",onExportCsv:ae,onExportPdf:we}){var Dc;const ne=kd(Nt,J),Oe=Object.values(ne).some(Boolean),qe=e.map(x=>x.key).join(","),Qe=j.join(","),Ze=s.useRef(e),Ue=s.useRef(j);Ze.current=e,Ue.current=j;const[et,St]=s.useState(!J||!Oe),vt=s.useRef(null),Ct=s.useRef(!J),ve=s.useRef(!1),ke=s.useRef(yt);ke.current=yt;const Pe=s.useRef(!J||!Oe?J??"__none__":null),je=oe!==void 0,[Je,at]=s.useState(()=>sr(j,e)),st=sr(je?oe:Je,e),[tt,ct]=s.useState(!1),[ot,Nr]=s.useState("filter"),[bt,kr]=s.useState(null),[Ht,Ye]=s.useState(""),[ht,br]=s.useState({}),[Et,jt]=s.useState({}),Sr=s.useRef({}),hr=s.useRef({});function Rr(x,O){if(!x)return;const Z=Sd(x.filterOptionValues,O),B=Cd(x.filterOptionLabels,O);Object.keys(Z).length>0&&(Sr.current={...Sr.current,...Z}),Object.keys(B).length>0&&(hr.current={...hr.current,...B})}const W=b!==void 0,[ee,me]=s.useState(u),pe=Y!==void 0,[ye,Se]=s.useState(ce),_e=pe?Y:ye,[Te,lt]=s.useState(_e),[Ve,pt]=s.useState(!1),[dt,mt]=s.useState(!1),[rr,qt]=s.useState(!1),[Ot,nr]=s.useState([]),pr=s.useRef(null),It=s.useRef(null),xt=s.useRef(null),Zt=s.useRef(V);Zt.current=V;const Ca=s.useRef(k);Ca.current=k;const Ea=s.useRef(N);Ea.current=N;const Ip=Array.isArray(N)?N.join(","):"",ns=s.useRef(null),ac=s.useRef(null),as=s.useRef(null),oc=s.useRef(0),[Bp,Fp]=s.useState({}),[Pp,_p]=s.useState({}),[Ln,Ma]=s.useState(!1),os=s.useRef(null),Ta=s.useRef(null),[zp,Wp]=s.useState({}),sc=s.useRef(null),An=s.useRef(null),[ss,lc]=s.useState(r.length>0||a||c===!1),ic=(x,O)=>50+(x*17+O*13+7)%40,Bt=s.useRef(null),[jp,qp]=s.useState(void 0),[cc,Up]=s.useState(0),[Vp,Xp]=s.useState(!1);s.useEffect(()=>{function x(){Xp(window.innerWidth<640)}if(!R||A!==void 0)return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x);const Z=k!==!1?48:0,B=12;function de(){if(x(),!Bt.current)return;const Ee=Bt.current.getBoundingClientRect().top;qp(Math.max(120,window.innerHeight-Ee-Z-B-te))}de(),window.addEventListener("resize",de);const he=typeof ResizeObserver<"u"&&Bt.current?new ResizeObserver(()=>de()):null;return Bt.current&&he&&he.observe(Bt.current),()=>{window.removeEventListener("resize",de),he==null||he.disconnect()}},[a,k,te,R,A,et,r.length]);const dc=R?A??jp:void 0;s.useEffect(()=>{const x=Bt.current;if(!x)return;const O=()=>Up(x.clientWidth);if(O(),typeof ResizeObserver>"u")return window.addEventListener("resize",O),()=>window.removeEventListener("resize",O);const Z=new ResizeObserver(O);return Z.observe(x),()=>Z.disconnect()},[a,et,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){lc(!0);return}if(ss)return;const x=window.setTimeout(()=>{lc(!0)},c);return()=>window.clearTimeout(x)},[r.length,c,ss,a]);const[en,tn]=s.useState(()=>or(e.map(x=>x.key),e)),[Cr,rn]=s.useState(()=>Object.fromEntries(e.map(x=>[x.key,Mt(x,er(x.width))]))),[rt,Er]=s.useState(null),[Yp,La]=s.useState(1),[Aa,$a]=s.useState(k===!1?0:k);s.useEffect(()=>{var Fe;const x=Ze.current,O=Ue.current,Z=x.map(Le=>Le.key),B=new Set(Z),de=()=>{var Le;ve.current||(ve.current=!0,(Le=ke.current)==null||Le.call(ke))};if(!J||!Oe){ne.layout&&tn(or(Z,x)),je||at(sr(O,x)),Ct.current=!1,St(!0),de();return}let he=!1;const Ee=Pe.current===J;Ee||(Ct.current=!1,St(!1),ve.current=!1);const He=qn(J);if(Bs(He)&&!Ee){const Le=He,Me=hn(Ea.current??cn()),Ae=Ca.current,Lr=Ae===!1?0:Ae,gr=ne.layout?Le==null?void 0:Le.columnOrder:void 0,Ar=Array.isArray(gr)?gr.filter(Re=>Z.includes(Re)):[],$r=or(Ar.length>0?Un(Ar,Z):Z,x),Dr=Object.fromEntries(x.map(Re=>[Re.key,Mt(Re,er(Re.width))])),on=ne.layout?(Le==null?void 0:Le.columnWidths)??{}:{},In=Object.fromEntries(x.map(Re=>[Re.key,Mt(Re,on[Re.key]??Dr[Re.key])])),sn=sr(ne.layout?(Le==null?void 0:Le.hiddenColumnKeys)??O:O,x);if(ne.layout&&(tn($r),rn(In)),je||at(sn),ne.filters&&It.current!==J&&(It.current=J,Rr(Le,B),br(un(Le==null?void 0:Le.filters,B)),jt(fn(Le==null?void 0:Le.conditionFilters,B))),ne.sort){const Re=dn(Le==null?void 0:Le.sort)?Le.sort:null;Er(Re&&B.has(Re.key)?Re:null)}if(ne.bql){if(pr.current!==J){pr.current=J;const Re=typeof(Le==null?void 0:Le.bql)=="string"?Le.bql:ce;pe?(Fe=Zt.current)==null||Fe.call(Zt,Re):Se(Re)}nr(Array.isArray(Le==null?void 0:Le.bqlHistory)?Le.bqlHistory.filter(Re=>typeof Re=="string"):[])}ne.pagination&&xt.current!==J&&(xt.current=J,$a(to(Le==null?void 0:Le.pageSize,Me,Lr))),Pe.current=J,St(!0),de()}const Be=`${eo()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(J)}`,Ge=new AbortController,Ce=window.setTimeout(()=>Ge.abort(),2500);return fetch(Be,{cache:"no-store",signal:Ge.signal}).then(Le=>Le.ok?Le.json():null).then(Le=>{var Hc;if(he)return;const Me=qn(J),Ae=Ps(Bs(Le==null?void 0:Le.settings)?Le==null?void 0:Le.settings:null,Me),Lr=hn(Ea.current??cn()),gr=Ca.current,Ar=gr===!1?0:gr,$r=ne.layout?Ae==null?void 0:Ae.columnOrder:void 0,Dr=Array.isArray($r)?$r.filter(ut=>Z.includes(ut)):[],on=or(Dr.length>0?Un(Dr,Z):Z,x),In=Object.fromEntries(x.map(ut=>[ut.key,Mt(ut,er(ut.width))])),sn=ne.layout?(Ae==null?void 0:Ae.columnWidths)??{}:{},Re=Object.fromEntries(x.map(ut=>[ut.key,Mt(ut,sn[ut.key]??In[ut.key])])),ln=sr(ne.layout?(Ae==null?void 0:Ae.hiddenColumnKeys)??O:O,x);if(ne.layout&&(tn(on),rn(Re)),je||at(ln),ne.filters&&It.current!==J&&(It.current=J,Rr(Ae,B),br(un(Ae==null?void 0:Ae.filters,B)),jt(fn(Ae==null?void 0:Ae.conditionFilters,B))),ne.sort){const ut=dn(Ae==null?void 0:Ae.sort)?Ae.sort:null;Er(ut&&B.has(ut.key)?ut:null)}if(ne.bql){if(pr.current!==J){pr.current=J;const ut=typeof(Ae==null?void 0:Ae.bql)=="string"?Ae.bql:ce;pe?(Hc=Zt.current)==null||Hc.call(Zt,ut):Se(ut)}nr(Array.isArray(Ae==null?void 0:Ae.bqlHistory)?Ae.bqlHistory.filter(ut=>typeof ut=="string"):[])}let nt;ne.pagination&&(nt=to(Ae==null?void 0:Ae.pageSize,Lr,Ar),xt.current!==J&&(xt.current=J,$a(nt))),vt.current=JSON.stringify({columnOrder:on,columnWidths:Re,hiddenColumnKeys:ln,filters:un(Ae==null?void 0:Ae.filters,B),conditionFilters:fn(Ae==null?void 0:Ae.conditionFilters,B),sort:dn(Ae==null?void 0:Ae.sort)?Ae.sort:null,bql:typeof(Ae==null?void 0:Ae.bql)=="string"?Ae.bql:"",bqlHistory:Array.isArray(Ae==null?void 0:Ae.bqlHistory)?Ae.bqlHistory:[],pageSize:ne.pagination&&gr!==!1?nt:void 0}),Ct.current=!0}).catch(()=>{var Le;if(!he){const Me=qn(J),Ae=hn(Ea.current??cn()),Lr=Ca.current,gr=Lr===!1?0:Lr,Ar=ne.layout?Me==null?void 0:Me.columnOrder:void 0,$r=Array.isArray(Ar)?Ar.filter(nt=>Z.includes(nt)):[],Dr=or($r.length>0?Un($r,Z):Z,x),on=Object.fromEntries(x.map(nt=>[nt.key,Mt(nt,er(nt.width))])),In=ne.layout?(Me==null?void 0:Me.columnWidths)??{}:{},sn=Object.fromEntries(x.map(nt=>[nt.key,Mt(nt,In[nt.key]??on[nt.key])]));ne.layout&&(tn(Dr),rn(sn));const Re=sr(ne.layout?(Me==null?void 0:Me.hiddenColumnKeys)??O:O,x);if(je||at(Re),ne.filters&&It.current!==J&&(It.current=J,Rr(Me,B),br(un(Me==null?void 0:Me.filters,B)),jt(fn(Me==null?void 0:Me.conditionFilters,B))),ne.sort){const nt=dn(Me==null?void 0:Me.sort)?Me.sort:null;Er(nt&&B.has(nt.key)?nt:null)}if(ne.bql){if(pr.current!==J){pr.current=J;const nt=typeof(Me==null?void 0:Me.bql)=="string"?Me.bql:ce;pe?(Le=Zt.current)==null||Le.call(Zt,nt):Se(nt)}nr(Array.isArray(Me==null?void 0:Me.bqlHistory)?Me.bqlHistory.filter(nt=>typeof nt=="string"):[])}let ln;ne.pagination&&(ln=to(Me==null?void 0:Me.pageSize,Ae,gr),xt.current!==J&&(xt.current=J,$a(ln))),vt.current=JSON.stringify({columnOrder:Dr,columnWidths:sn,hiddenColumnKeys:Re,filters:un(Me==null?void 0:Me.filters,B),conditionFilters:fn(Me==null?void 0:Me.conditionFilters,B),sort:dn(Me==null?void 0:Me.sort)?Me.sort:null,bql:typeof(Me==null?void 0:Me.bql)=="string"?Me.bql:"",bqlHistory:Array.isArray(Me==null?void 0:Me.bqlHistory)?Me.bqlHistory:[],pageSize:ne.pagination&&Lr!==!1?ln:void 0}),Ct.current=!0}}).finally(()=>{window.clearTimeout(Ce),he||(Pe.current=J,St(!0),de())}),()=>{he=!0,Ge.abort(),window.clearTimeout(Ce)}},[J,Oe,qe,Qe,je,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination,pe,ce,Ip]),s.useEffect(()=>{if(!J||!et||!Oe||!Ct.current)return;const x={};ne.layout&&(x.columnOrder=en,x.columnWidths=Cr,x.hiddenColumnKeys=st),ne.filters&&(x.filters=ht,x.conditionFilters=Et,x.filterOptionValues=Sr.current,x.filterOptionLabels=hr.current),ne.sort&&(x.sort=rt),ne.bql&&(x.bql=_e,x.bqlHistory=Ot),ne.pagination&&k!==!1&&(x.pageSize=Aa);const O=qn(J),Z=Ps(O,x),B=JSON.stringify(Z);if(B===vt.current)return;Nd(J,Z),vt.current=B;const de=window.setTimeout(()=>{const he=eo()??"/api/user/preferences/datatables";fetch(he,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:J,settings:Z})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(de)},[en,Cr,st,ht,Et,rt,_e,Ot,Aa,k,J,et,Oe,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination,r]),s.useEffect(()=>{tn(x=>{const O=e.map(Z=>Z.key);return or(Un(x,O),e)})},[qe,e]);const uc=or(en,e).map(x=>e.find(O=>O.key===x)).filter(x=>!!x),Ft=uc.filter(x=>!st.includes(x.key)),fc=e.some(ro),Gp=Object.keys(ht).length,Kp=Object.keys(Et).length,ls=Gp+Kp;function is(x){var He;const O=!!(X&&se),Z=new Map,B=(Ne,ze)=>{const Be=Ne.trim();if(!Be)return;const Ge=(ze??Be).trim()||Be;Z.has(Be)?ze!=null&&ze.trim()&&Z.get(Be)===Be&&Z.set(Be,Ge):Z.set(Be,Ge)};for(const Ne of x.filterOptions??[])typeof Ne=="string"?B(Ne):Ne!=null&&Ne.value&&B(Ne.value,Ne.label);if(O){const Ne=hr.current[x.key]??{};for(const ze of Sr.current[x.key]??[])B(ze,Ne[ze])}for(const Ne of r){const ze=Vn(x,Ne),Be=((He=x.filterOptionLabel)==null?void 0:He.call(x,Ne))??void 0;B(ze,Be??void 0)}for(const Ne of ht[x.key]??[])B(Ne);const de=Ne=>/^[a-f\d]{24}$/i.test(Ne.trim()),he=new Map;for(const[Ne,ze]of Z){const Be=ze.trim().toLowerCase(),Ge=he.get(Be)??[];Ge.push(Ne),he.set(Be,Ge)}for(const Ne of he.values()){if(Ne.length<2)continue;const ze=Ne.find(de)??Ne.slice().sort((Be,Ge)=>Be.localeCompare(Ge))[0];for(const Be of Ne)Be!==ze&&Z.delete(Be)}const Ee=Array.from(Z.keys()).sort((Ne,ze)=>{const Be=Z.get(Ne)??Ne,Ge=Z.get(ze)??ze;return Be.localeCompare(Ge,void 0,{numeric:!0,sensitivity:"base"})});return O&&(Sr.current[x.key]=Ee,hr.current[x.key]=Object.fromEntries(Z.entries())),Ee.map(Ne=>({value:Ne,label:Z.get(Ne)??Ne}))}function Zp(){const x=e.find(O=>O.key===bt);return x?is(x):[]}function Qp(x){return!!(P&&!xr(x)&&(x.filterValue||x.sortKey||is(x).length>0))}function cs(x,O){br(Z=>{const B={...Z};return B[x]=O,B})}function Jp(x,O,Z,B){const de=ht[x]??[],he=B?de.includes(O)?de.filter(He=>He!==O):[...de,O]:[O];Z.length>0&&he.length===Z.length&&Z.every(He=>he.includes(He))?Da(x):cs(x,he)}function Da(x){br(O=>{const Z={...O};return delete Z[x],Z})}function Ha(x,O){jt(Z=>{const B={...Z};return O?B[x]=O:delete B[x],B})}function bc(x){Ha(x,null)}function Rp(){br({}),jt({})}function em(x){pe||Se(x),V==null||V(x)}function hc(x){const O=x.trim();lt(O),(V==null?void 0:V(O))!==!1&&(pe||Se(O),pt(!1),mt(!1),qt(!1),O&&nr(B=>[O,...B.filter(de=>de!==O)].slice(0,md)))}function pc(){lt(""),em(""),pt(!1),mt(!1),qt(!1)}function ds(x,O){lt(x),O&&(O.style.height="auto",O.style.height=`${Math.min(O.scrollHeight,180)}px`)}function Oa(x){const O=x.trim();if(!O)return;oc.current=Date.now()+500;const Z=Te.replace(/\s+$/u,""),B=Z.length===0?O:Z.split(`
|
|
3
|
-
`).map(de=>de.trim()).includes(
|
|
4
|
-
${O}`;ds(B,as.current??void 0),requestAnimationFrame(()=>{const de=as.current;if(!de)return;de.focus();const he=de.value.length;de.setSelectionRange(he,he),ds(de.value,de)})}s.useEffect(()=>{lt(_e)},[_e]);const Ia=s.useCallback(()=>{const x=ns.current;if(!x)return;const O=x.getBoundingClientRect(),Z=12,B=8,de=Math.min(780,Math.max(320,window.innerWidth-32)),he=Math.max(Z,window.innerWidth-de-Z),Ee=Math.min(Math.max(Z,O.left),he),He=O.bottom+B,Ne=window.innerHeight-O.top+B,ze=window.innerHeight-He-Z,Be=O.top-Z-B,Ge=ze<280&&Be>ze,Ce=Math.max(240,Ge?Be:ze);Fp({position:"fixed",zIndex:1e4,left:Ee,top:Ge?void 0:He,bottom:Ge?Ne:void 0,width:de,maxWidth:"calc(100vw - 24px)",maxHeight:Ce,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ve)return;function x(B){var he,Ee;if(Date.now()<oc.current)return;const de=B.target;(he=ns.current)!=null&&he.contains(de)||(Ee=ac.current)!=null&&Ee.contains(de)||(pt(!1),mt(!1),qt(!1))}function O(B){B.key==="Escape"&&(pt(!1),mt(!1),qt(!1))}function Z(){Ia()}return Ia(),document.addEventListener("mousedown",x),window.addEventListener("keydown",O),window.addEventListener("resize",Z),window.addEventListener("scroll",Z,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",O),window.removeEventListener("resize",Z),window.removeEventListener("scroll",Z,!0)}},[Ve,Ia]);function mc(x){const O=sr(x,e);je||at(O),S==null||S(O)}function tm(x){mc(st.includes(x)?st.filter(O=>O!==x):[...st,x])}function rm(){mc([])}const Ba=s.useCallback(x=>{var de;if(x!=null&&x.isConnected)return x;if(!bt)return null;const Z=`[role="columnheader"][data-dt-column-key="${typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(bt):bt.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"] button[aria-haspopup="menu"]`,B=((de=Bt.current)==null?void 0:de.querySelector(Z))??document.querySelector(Z);return B&&(An.current=B),B},[bt]),$n=s.useCallback((x=An.current)=>{const O=Ba(x);if(!O)return;const B=(O.closest("th")??O.closest("[role='columnheader']")??O.closest("[data-dt-column-key]")??O).getBoundingClientRect();if(B.width<1&&B.height<1||B.bottom<0||B.top>window.innerHeight)return;const de=Math.min(292,Math.max(240,window.innerWidth-16)),he=8,Ee=Math.max(he,window.innerWidth-de-he),He=Math.min(Math.max(he,B.left),Ee),Ne=window.innerHeight-B.bottom,ze=B.bottom+6,Be=window.innerHeight-B.top+6,Ce=Ne<360&&B.top>Ne?void 0:ze,Fe=Ce===void 0?Be:void 0,Le=Math.max(220,Ce===void 0?B.top-16:window.innerHeight-ze-8),Me={position:"fixed",zIndex:9999,left:He,top:Ce,bottom:Fe,width:de,maxWidth:"calc(100vw - 16px)",maxHeight:Le,"--dt-column-menu-max-height":`${Le}px`};_p(Me)},[Ba]);function gc(x,O,Z=null){x.preventDefault(),x.stopPropagation();const B=An.current===x.currentTarget&&ot===O&&bt===Z;if(tt&&B){ct(!1),kr(null);return}if(An.current=x.currentTarget,Nr(O),kr(Z),Ye(""),O==="filter"&&Z){const de=e.find(Ee=>Ee.key===Z),he=ht[Z];if(de&&(he!=null&&he.length)){const Ee=is(de),He=new Map(Ee.map(Be=>[Be.label.trim().toLowerCase(),Be.value])),Ne=[...new Set(he.map(Be=>Ee.some(Ge=>Ge.value===Be)?Be:He.get(Be.trim().toLowerCase())??Be))];(Ne.length!==he.length||Ne.some((Be,Ge)=>Be!==he[Ge]))&&(Ee.length>0&&Ne.length===Ee.length&&Ee.every(Be=>Ne.includes(Be.value))?Da(Z):cs(Z,Ne))}}$n(x.currentTarget),ct(!0)}function nm(x){if(xr(x))return;const O=Bt.current;if(!O)return;const B=Array.from(O.querySelectorAll("[data-dt-column-key]")).filter(de=>de.dataset.dtColumnKey===x.key).reduce((de,he)=>{const Ee=he.querySelector("[data-dt-autofit-content]"),He=Ee?Ee.scrollWidth:Math.max(he.scrollWidth,he.offsetWidth);return Math.max(de,Math.ceil(He+Ed(he)))},0);B<=0||rn(de=>({...de,[x.key]:Mt(x,B+12)}))}s.useEffect(()=>{rn(x=>{const O=Object.fromEntries(e.map(Z=>[Z.key,Mt(Z,er(Z.width))]));return Object.fromEntries(e.map(Z=>[Z.key,Mt(Z,x[Z.key]??O[Z.key])]))})},[qe,e]),s.useEffect(()=>{je||at(x=>sr(x,e))},[qe,e,je]),s.useEffect(()=>{function x(B){var He;const de=B.target,he=B.target;if(he!=null&&he.closest("[data-bonsaif-select-dropdown='true']"))return;const Ee=Ba(An.current);!((He=sc.current)!=null&&He.contains(de))&&!(Ee!=null&&Ee.contains(de))&&(ct(!1),kr(null))}function O(B){B.key==="Escape"&&(ct(!1),kr(null))}function Z(){$n()}return tt&&(document.addEventListener("mousedown",x),window.addEventListener("keydown",O),window.addEventListener("resize",Z),window.addEventListener("scroll",Z,!0)),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",O),window.removeEventListener("resize",Z),window.removeEventListener("scroll",Z,!0)}},[tt,Ba,$n]),s.useLayoutEffect(()=>{!tt||!bt||$n()},[tt,bt,ht,Et,r,$n]);const Dn=s.useRef(null);s.useEffect(()=>{function x(Z){const B=Dn.current;if(!B)return;const de=Z.clientX-B.startX,he=e.find(Ee=>Ee.key===B.colKey);he&&rn(Ee=>({...Ee,[B.colKey]:Mt(he,B.startWidth+de)}))}function O(){Dn.current&&(Dn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",x),document.addEventListener("pointerup",O),()=>{document.removeEventListener("pointermove",x),document.removeEventListener("pointerup",O)}},[e]);const Hn=s.useRef(null),[vc,us]=s.useState(null);function am(x,O){const Z=e.find(B=>B.key===x);if(!Z||!_s(Z)){O.preventDefault();return}Hn.current=en.indexOf(x),O.dataTransfer.effectAllowed="move"}function om(x,O){O.preventDefault(),O.dataTransfer.dropEffect="move";const Z=en.indexOf(x);vc!==Z&&us(Z)}function sm(x,O){O.preventDefault();const Z=Hn.current,B=en.indexOf(x);Z!==null&&Z!==B&&tn(de=>{const he=[...de],[Ee]=he.splice(Z,1);return he.splice(B,0,Ee),or(he,e)}),Hn.current=null,us(null)}function lm(){Hn.current=null,us(null)}function im(x){x.sortKey&&Er(O=>(O==null?void 0:O.key)===x.key?{key:x.key,dir:O.dir==="asc"?"desc":"asc"}:{key:x.key,dir:"asc"})}s.useEffect(()=>{La(1)},[r]),s.useEffect(()=>{La(1)},[Et,ht]);const Qt=!!(X&&se),mr=k!==!1,fs=s.useMemo(()=>hn(N??cn()),[N]),wt=Qt?Q??1:Yp,xc=mr&&Aa<1?typeof k=="number"&&k>0?k:fs[0]??25:Aa,Jt=Qt||mr?xc:r.length,Ut=!!w&&!!g&&!!E,bs=s.useMemo(()=>y?r.filter(x=>y(x)):r,[r,y]),nn=!!d,yc=s.useMemo(()=>new Set(W?Array.from(b??[]):ee),[W,b,ee]),cm=(nn?40:0)+(Ut?40:0),hs=!Vp&&(fc||fe),Fa=(()=>{if(!hs)return{};let x=cm;const O={};return Ft.forEach((Z,B)=>{(ro(Z)||!fc&&fe&&B===0)&&(O[Z.key]=x,x+=Cr[Z.key]??Mt(Z,er(Z.width)))}),O})(),ps=Object.keys(Fa),ms=ps.length>0?ps[ps.length-1]:null,wc=Ut&&bs.length>0&&bs.every(x=>w.has(n(x))),dm=Ut&&w.size>0&&bs.some(x=>w.has(n(x)))&&!wc,Pa=s.useMemo(()=>{if(Qt)return r;const x=Object.entries(ht),O=Object.entries(Et);return x.length===0&&O.length===0?r:r.filter(Z=>x.every(([B,de])=>{const he=e.find(Ee=>Ee.key===B);return he?de.includes(Vn(he,Z)):!0})&&O.every(([B,de])=>{const he=e.find(He=>He.key===B);if(!he)return!0;const Ee=r.map(He=>Vn(he,He));return Ld(Vn(he,Z),de,Ee)}))},[Et,ht,e,r,Qt]),Mr=s.useMemo(()=>{if(!rt)return Pa;const x=e.find(O=>O.key===rt.key&&O.sortKey);return x!=null&&x.sortKey?[...Pa].sort((O,Z)=>{const B=O[x.sortKey],de=Z[x.sortKey],he=B===de?0:B==null?1:de==null||B<de?-1:1;return rt.dir==="asc"?he:-he}):Pa},[Pa,rt,e]),Nc=s.useMemo(()=>{if(Qt||!mr)return Mr;const x=(wt-1)*Jt;return Mr.slice(x,x+Jt)},[Mr,Qt,mr,wt,Jt]),ar=Qt?$??r.length:Mr.length,gs=mr?Math.max(1,Math.ceil(ar/Jt)):1,um=Math.min(...fs),fm=mr&&(ar>Jt||ar>um),bm=mr?(wt-1)*Jt+1:1,hm=mr?Math.min(wt*Jt,ar):ar;function vs(x){if(a)return;const O=Math.max(1,Math.min(x,gs));Qt?X(O):La(O)}function pm(x){a||(J&&(xt.current=J),$a(x),Qt?(se(x),X(1)):(La(1),se==null||se(x)))}function kc(x){const O=new Set(yc);O.has(x)?O.delete(x):O.add(x);const Z=Array.from(O);W||me(Z),p==null||p(Z)}s.useEffect(()=>{De==null||De({bql:_e,filters:ht,conditionFilters:Et,sort:rt,page:wt,pageSize:Jt,hiddenColumnKeys:st})},[_e,ht,Et,rt,wt,Jt,st,De]);const Sc=x=>x==="center"?"justify-center text-center":x==="right"?"justify-end text-right":"justify-start text-left",mm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",xs="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%)",Xe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Tr="color-mix(in srgb, var(--primary) 24%, var(--border))",_a=`inset 0 0 0 1px ${Xe}`,Cc=Ft.reduce((x,O)=>x+(Cr[O.key]??er(O.width)),(nn?40:0)+(Ut?40:0)),Ec=typeof F=="number"?F:typeof F=="string"?Number(((Dc=F.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Dc[1])??NaN):NaN,On=Number.isFinite(Ec)?Math.max(Cc,Ec,cc):Math.max(Cc,cc),za=F??On,an=`${nn?"40px ":""}${Ut?"40px ":""}${Ft.map(x=>`${Cr[x.key]??er(x.width)}px`).join(" ")}`;s.useEffect(()=>{rt&&st.includes(rt.key)&&Er(null)},[st,rt]);function Mc(x){return x?typeof x=="string"?{key:x,label:x}:x:null}const Wa=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:an,background:xs,borderBottom:`1px solid ${Tr}`},children:[nn&&t.jsx("div",{role:"columnheader",className:`${z?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Tr}`,borderRight:`1px solid ${Xe}`}}),Ut&&t.jsx("div",{role:"columnheader",className:`${z?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:hs?{position:"sticky",left:0,zIndex:12,background:xs,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${Tr}`,borderRight:`1px solid ${Xe}`}:{borderBottom:`1px solid ${Tr}`,borderRight:`1px solid ${Xe}`},children:t.jsx(_n,{size:"sm",checked:wc,indeterminate:dm,onChange:E,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Ft.map((x,O)=>{const Z=(rt==null?void 0:rt.key)===x.key,B=!!x.sortKey,de=xr(x),he=Fa[x.key],Ee=he!==void 0,He=x.key===ms,Ne=_s(x),ze=vc===O,Ge=(Cr[x.key]??er(x.width))<120,Ce=Object.prototype.hasOwnProperty.call(ht,x.key)||Object.prototype.hasOwnProperty.call(Et,x.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":x.key,className:`group select-none ${Ge?"text-left":Sc(x.align)}`,style:{...Ee?{position:"sticky",left:he,zIndex:12,background:xs,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:He?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Tr}`:`inset 0 -1px 0 ${Tr}`,borderRight:`1px solid ${Xe}`}:{position:"relative",borderBottom:`1px solid ${Tr}`,borderRight:`1px solid ${Xe}`},color:Z?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ze?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:de?z?"7px 6px":"9px 8px":z?"8px 6px 10px":"10px 8px 12px"},onDragOver:Fe=>{(Ne||Hn.current!==null)&&om(x.key,Fe)},onDrop:Fe=>sm(x.key,Fe),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${de?"justify-center":Ge?"justify-start":x.align==="center"?"justify-center":x.align==="right"?"justify-end":"justify-start"}`,children:[Ne?t.jsx("span",{draggable:!0,onDragStart:Fe=>{Fe.stopPropagation(),am(x.key,Fe)},onDragEnd:Fe=>{Fe.stopPropagation(),lm()},onClick:Fe=>Fe.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 ${ze?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,de?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(H.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(zs,{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 ${z?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:x.header})})}),B&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(x.header)}`,title:"Ordenar",onClick:Fe=>{Fe.stopPropagation(),im(x)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${Z?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Z?rt.dir==="asc"?t.jsx(H.HiChevronUp,{className:"h-3 w-3"}):t.jsx(H.HiChevronDown,{className:"h-3 w-3"}):t.jsx(H.HiChevronUpDown,{className:"h-3 w-3"})}),P&&!de&&Qp(x)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":tt&&bt===x.key,"aria-label":`Filtrar ${String(x.header)}`,title:"Filtrar",onClick:Fe=>gc(Fe,"filter",x.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 ${tt&&ot==="filter"&&bt===x.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Ce?"text-[var(--primary)] opacity-100":""}`,children:Ce?t.jsx(H.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(H.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!de&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Dn.current={colKey:x.key,startX:Fe.clientX,startWidth:Cr[x.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Dn.current=null,document.body.style.cursor="",document.body.style.userSelect="",nm(x)},onClick:Fe=>Fe.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"}})]})})]},x.key)})]}),ja=()=>{if(!tt||typeof document>"u"||ot==="visibility"&&!ue||ot==="filter"&&!P)return null;const x=e.find(Ce=>Ce.key===bt),O=Zp(),Z=x?Object.prototype.hasOwnProperty.call(ht,x.key):!1,B=x?Et[x.key]:void 0,de=jn.find(Ce=>Ce.value===(B==null?void 0:B.operator)),he=x?ht[x.key]??[]:[],Ee=Ht.trim().toLowerCase(),He=Ee?O.filter(Ce=>Ce.label.toLowerCase().includes(Ee)):O,Ne=x&&O.length>0&&(!Z||he.length===O.length),ze=x&&Z&&he.length>0&&he.length<O.length,Be=st.length,Ge=()=>{x&&(Da(x.key),bc(x.key))};return ft.createPortal(t.jsx("div",{ref:sc,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Pp,borderColor:"var(--border)",background:"var(--bg-card)"},children:ot==="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:Be>0?`${Ft.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:rm,disabled:Be===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:uc.map(Ce=>{const Fe=!st.includes(Ce.key),Me=!(Ce.hideable!==!1)||Fe&&Ft.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Fe,disabled:Me,onClick:()=>tm(Ce.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:Fe?"var(--primary)":"var(--border)",background:Fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Fe&&t.jsx(H.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ce.header})]},Ce.key)})})]}):x?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 ",x.header]}),t.jsx("button",{type:"button",onClick:Ge,disabled:!Z&&!B,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"})]}),x.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:()=>Er({key:x.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(H.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(rt==null?void 0:rt.key)===x.key&&rt.dir==="asc"&&t.jsx(H.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>Er({key:x.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(H.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(rt==null?void 0:rt.key)===x.key&&rt.dir==="desc"&&t.jsx(H.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(vr,{value:(B==null?void 0:B.operator)??"",onChange:Ce=>{if(!Ce){bc(x.key);return}Ha(x.key,{operator:Ce,value:(B==null?void 0:B.value)??"",valueTo:(B==null?void 0:B.valueTo)??""})},options:pd,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"}),(de==null?void 0:de.valueMode)!=="none"?t.jsx("input",{value:(B==null?void 0:B.value)??"",onChange:Ce=>{B&&Ha(x.key,{...B,value:Ce.target.value})},disabled:!B,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"})]}),(de==null?void 0:de.valueMode)==="between"&&t.jsx("input",{value:(B==null?void 0:B.valueTo)??"",onChange:Ce=>{B&&Ha(x.key,{...B,valueTo:Ce.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(H.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:Ht,onChange:Ce=>Ye(Ce.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":ze?"mixed":!!Ne,onClick:()=>{x&&(Ne?cs(x.key,[]):Da(x.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:Ne||ze?"var(--primary)":"var(--border)",background:Ne||ze?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[ze&&t.jsx(H.HiMinus,{className:"h-3 w-3"}),Ne&&!ze&&t.jsx(H.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),He.map(Ce=>{const Fe=!Z||he.includes(Ce.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Fe,onClick:()=>Jp(x.key,Ce.value,O.map(Le=>Le.value),Z),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Fe?"var(--primary)":"var(--border)",background:Fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Fe&&t.jsx(H.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ce.label})]},Ce.value)}),He.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(!Ln)return;function x(O){os.current&&!os.current.contains(O.target)&&Ta.current&&!Ta.current.contains(O.target)&&Ma(!1)}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[Ln]);function Tc(x,O){if(x.filterValue){const Z=x.filterValue(O);return Z==null||Z===""?"":zn(Z)}return zn(Hr(x.cell(O)))}function Lc(x){return`"${zn(x).replace(/"/g,'""')}"`}function qa(x){return zn(x).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ac(){return Qt&&ar>Mr.length&&Ya.toast.warning(`Exportando ${Mr.length.toLocaleString("es-MX")} de ${ar.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),Mr}function gm(){const x=Ft.filter(Ne=>!xr(Ne)),O=Ac(),Z=x.map(Ne=>Lc(Hr(Ne.header))).join(","),B=O.map(Ne=>x.map(ze=>Lc(Tc(ze,Ne))).join(",")).join(`
|
|
5
|
-
`),de=`${
|
|
6
|
-
${B}`,he=new Blob(["\uFEFF"+de],{type:"text/csv;charset=utf-8;"}),Ee=URL.createObjectURL(he),
|
|
7
|
-
<html lang="es"><head><meta charset="utf-8"><title>${
|
|
1
|
+
(function(A,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):(A=typeof globalThis<"u"?globalThis:A||self,s(A.BonsaifUI={},A.React,A.jsxRuntime,A.ReactIconsHi2,A.ReactDOM,A.Recharts,A.OverlayScrollbarsGlobal,A.Sonner,A.OverlayScrollbarsReact,A.ReactDayPicker,A.ReactDayPickerStyles,A.ReactIconsFi))})(this,(function(A,s,t,F,bt,Oe,Ra,eo,As,to,mg,vd){"use strict";"use client";function Pe(...e){return e.filter(Boolean).join(" ")}function xd({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Pe("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function Ls({value:e,onChange:r,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:f}){const d=s.useRef(null),[h,b]=s.useState(!1),u=l||h||e.trim().length>0,p=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",g=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=d.current)==null||v.focus())},[o]);const w=()=>{var v;b(!0),(v=d.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 ${u?g:"w-24 sm:w-28"}`,onMouseDown:v=>{u||(v.preventDefault(),w())},children:[t.jsx(F.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:d,type:"text",tabIndex:f,"aria-label":n,value:e,onChange:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:u?n:"Buscar",className:`${p} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${u?"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:u?"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(F.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const $s=s.createContext({});let Ds=0;const Is="bonsaif-ui:hide-tooltips";function _n(e=700){Ds=Date.now()+e}function yd(){return Date.now()>Ds}function zn(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 wd(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 Xt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:f="",style:d,tooltipStyle:h,as:b="div"}){const u=s.useRef(null),p=s.useRef(null),g=s.useRef(null),w=s.useRef(!1),[v,E]=s.useState(null),[y,T]=s.useState("");s.useEffect(()=>{const D=u.current;D&&(D.querySelectorAll("[title]").forEach(Z=>{const O=Z.getAttribute("title");O&&(Z.getAttribute("aria-label")||Z.setAttribute("aria-label",O),Z.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(Z=>Z.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const D=p.current;if(!D)return;const Z=12,O=14,ne=D.getBoundingClientRect(),ee=window.innerWidth-ne.width-Z,fe=window.innerHeight-ne.height-Z;let J=v.mouseX+O,W=v.mouseY+O,R,$;if(!o&&u.current){const P=u.current.getBoundingClientRect(),ue=P.left+P.width/2,z=P.top+P.height/2;l==="top"?(J=ue-ne.width/2,W=P.top-ne.height-O,$=ne.height-1):l==="left"?(J=P.left-ne.width-O,W=z-ne.height/2,R=ne.width-1):l==="right"?(J=P.right+O,W=z-ne.height/2,R=-7):(J=ue-ne.width/2,W=P.bottom+O,$=-7)}if(o&&(J>ee&&(J=v.mouseX-ne.width-O),W>fe&&(W=v.mouseY-ne.height-O)),J=Math.min(Math.max(Z,J),Math.max(Z,ee)),W=Math.min(Math.max(Z,W),Math.max(Z,fe)),!o&&u.current){const P=u.current.getBoundingClientRect(),ue=P.left+P.width/2,z=P.top+P.height/2;l==="top"||l==="bottom"?R=Math.min(Math.max(14,ue-J),ne.width-14):$=Math.min(Math.max(14,z-W),ne.height-14)}(Math.abs(J-v.x)>.5||Math.abs(W-v.y)>.5||R!==v.arrowX||$!==v.arrowY)&&E(P=>P&&{...P,x:J,y:W,arrowX:R,arrowY:$})},[o,l,v]);const L=()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},C=(D,Z)=>{if(!yd()||w.current)return;const O=u.current;if(O&&!zn(O)){if(n){const ne=wd(O);if(!ne)return;T(ne)}!n&&!r||E({mouseX:D,mouseY:Z,x:D+14,y:Z+14})}},m=()=>{const D=u.current;if(!D)return;const Z=D.getBoundingClientRect();C(Z.left+Z.width/2,Z.bottom)},S=()=>{L(),E(null)},N=()=>{if(!a){S();return}L(),g.current=window.setTimeout(()=>E(null),120)},_=()=>{_n(),w.current=!0,S()},U=()=>{w.current=!1};s.useEffect(()=>{if(!v)return;if(zn(u.current)){E(null);return}const D=()=>E(null),Z=()=>{_n(),w.current=!0,E(null)};document.addEventListener("pointerdown",Z,!0),document.addEventListener("click",Z,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const O=new MutationObserver(()=>{zn(u.current)&&E(null)});return O.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Z,!0),document.removeEventListener("click",Z,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),O.disconnect()}},[v]),s.useEffect(()=>{const D=()=>_n(),Z=()=>{_n(),w.current=!0,E(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(Is,Z),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(Is,Z)}},[]);const K=n?y:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{u.current=D},className:c,style:d,onMouseEnter:D=>{L(),U(),o?C(D.clientX,D.clientY):m()},onMouseMove:D=>{v&&o&&C(D.clientX,D.clientY)},onMouseDown:_,onClick:_,onMouseLeave:()=>{U(),N()},onFocus:m,onBlur:S,children:e}),v&&K&&!zn(u.current)?bt.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:f,onMouseEnter:a?L:void 0,onMouseLeave:a?N:void 0,style:{position:"fixed",top:v.y,left:v.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...h},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(h==null?void 0:h.background)??"var(--bg-card)",borderLeft:l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),K]}),document.body):null]})}function Fs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Nd="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",kd={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"},Sd="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",Cd={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"},Ed={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Md={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function ro(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(ro).join(" ").trim():s.isValidElement(e)?ro(e.props.children):""}function Td(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ke({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:f,className:d="",disabled:h,style:b,...u}){const p=s.useContext($s),g=l??p.iconOnly??e==="icon",w=p.compact??!1,v=p.headerAction??!1,E=v&&r==="md"?"sm":w&&!v&&r==="md"?"xs":r,y=e==="icon"||g,T=v&&y,L=ro(f),C=o??u.title??u["aria-label"]??(g?L:void 0),m=C?void 0:u.title,S=u["aria-label"]??(typeof C=="string"?C:L||void 0),N=n?null:a??(g?Td(f):null),_=t.jsxs("button",{...u,title:m,"aria-label":S,"data-variant":e,"data-size":E,"data-icon":y?"true":void 0,disabled:h||n,className:`${Nd} ${T?Sd:kd[e]} ${y?Ed[E]:Cd[E]} ${w&&!y?"px-2.5":""} ${d}`,style:{...Md[e],height:Fs(i),padding:Fs(c),...b,...v&&!y?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...T?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):N,!g&&f]});return C?t.jsx(Xt,{as:"span",content:C,className:"inline-flex shrink-0",children:_}):_}const St={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:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),f=o?"px-2 py-2":"px-3 py-2.5",d=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:St}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:St})]}),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:St}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:St})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((h,b)=>t.jsx("div",{className:`${d} 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:{...St,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((h,b)=>Array.from({length:i}).map((u,p)=>t.jsx("div",{className:`${f} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...St,width:`${46+(b*13+p*11)%42}%`,minWidth:28}})},`c-${b}-${p}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:St}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:St})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((h,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:St},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:St})]})]})}function Ad({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 Ld({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 Os({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:f,className:d=""}){if(e==="table")return t.jsx(Wn,{rows:i,columns:c,className:d});if(e==="sections")return t.jsx($d,{rows:i});if(e==="cards")return t.jsx(Dd,{rows:i});const h=o||(typeof r=="string"?r:"Aplicación"),b=l==="bare",u=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(Ld,{logoSrc:a,logoAlt:h}):null,t.jsx(Ad,{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,f&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:f})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${d}`,role:"status","aria-live":"polite","aria-busy":"true",children:u}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${d}`,role:"status","aria-live":"polite","aria-busy":"true",children:u})}function $d({rows:e}){return t.jsx(Wn,{rows:e,columns:7})}function Dd({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:St}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:St}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:St})]},n))})}function Hs(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Bs(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Id(e){return[e.label,Hs(e.service),e.description,e.service].filter(Boolean).join(" ")}function Fd(e){return typeof e=="function"?e:e.default}function Od(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ke,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Hd({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:f,initialService:d,onActiveServiceChange:h,canAccess:b,keepAlive:u=!0,title:p,subtitle:g,emptyState:w,loadingState:v,errorState:E=Od,renderTabLabel:y,searchableTabs:T="auto",tabsSearchThreshold:L=6,tabsSearchPlaceholder:C="Buscar modulo...",tabsSearchValue:m,onTabsSearchChange:S,emptySearchState:N,showTabCount:_=!0,className:U="",parentClassName:K="",contentClassName:D="",tabsClassName:Z=""}){var we;const O=s.useMemo(()=>l.filter(ae=>!ae.hidden&&((b==null?void 0:b(ae,o))??!0)),[b,o,l]),ne=(we=O.find(ae=>!ae.disabled))==null?void 0:we.service,[ee,fe]=s.useState(d??ne??""),[J,W]=s.useState({}),[R,$]=s.useState({}),[P,ue]=s.useState(""),[z,se]=s.useState(!1),q=s.useRef(R),k=s.useRef(0),V=m??P,M=Bs(V),Y=T===!0||T==="auto"&&O.length>=L,ce=Y&&V.trim().length>0,X=s.useMemo(()=>M?O.filter(ae=>Bs(Id(ae)).includes(M)):O,[M,O]),G=f??ee,I=O.find(ae=>ae.service===G)??O.find(ae=>!ae.disabled);s.useEffect(()=>{!I&&ne&&fe(ne)},[ne,I]),s.useEffect(()=>{q.current=R},[R]);const le=ae=>{ae.disabled||(f||fe(ae.service),h==null||h(ae.service,ae))},be=ae=>{m===void 0&&ue(ae),S==null||S(ae)},ie=(ae,Fe)=>{const qe=X.filter(Ze=>!Ze.disabled),Je=qe.findIndex(Ze=>Ze.service===Fe.service);Je<0||((ae.key==="ArrowRight"||ae.key==="ArrowDown")&&(ae.preventDefault(),le(qe[(Je+1)%qe.length])),(ae.key==="ArrowLeft"||ae.key==="ArrowUp")&&(ae.preventDefault(),le(qe[(Je-1+qe.length)%qe.length])),ae.key==="Home"&&(ae.preventDefault(),le(qe[0])),ae.key==="End"&&(ae.preventDefault(),le(qe[qe.length-1])))},ge=s.useCallback(()=>{if(!I)return;const ae=I.service,Fe=q.current[ae];if(Fe!=null&&Fe.loading||Fe!=null&&Fe.component&&u)return;const qe=(i==null?void 0:i[ae])??c;if(!qe){$(Ze=>({...Ze,[ae]:{loading:!1,error:new Error(`No module loader found for service "${ae}".`)}}));return}const Je=++k.current;$(Ze=>({...Ze,[ae]:{...Ze[ae],loading:!0,error:void 0}})),qe(I,o).then(Ze=>{if(Je!==k.current&&!u)return;const Ue=Fd(Ze);$(tt=>({...tt,[ae]:{component:Ue,loading:!1}}))}).catch(Ze=>{const Ue=Ze instanceof Error?Ze:new Error(String(Ze));$(tt=>({...tt,[ae]:{...tt[ae],loading:!1,error:Ue}}))})},[o,u,c,i,I]);s.useEffect(ge,[ge]);const $e=I?J[I.service]??null:null,De=I?R[I.service]:void 0,kt=De==null?void 0:De.component,wt=ae=>{I&&W(Fe=>({...Fe,[I.service]:ae}))},re=()=>{I&&W(ae=>({...ae,[I.service]:null}))},xe={context:o,parent:a,links:l,visibleLinks:O,filteredLinks:X,selectedLink:I,selectedService:I==null?void 0:I.service,activeItemId:$e,tabsSearch:V,onSelectService:le,onOpenDetail:wt,onBackToList:re},oe=n?n(xe):r?t.jsx(r,{...xe}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${U}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${K}`,children:oe}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(p||g||Y||_)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[p&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),g&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:g})]}),(Y||_)&&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:[X.length," / ",O.length]}),Y&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${z?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!z,children:t.jsx(Ls,{value:V,onChange:be,placeholder:C,className:"w-full",autoFocus:z,forceExpanded:!0,onEscape:()=>se(!1),size:"sm",inputTabIndex:z?0:-1})}),t.jsx("button",{type:"button","aria-label":z?"Cerrar busqueda":"Buscar tabs","aria-expanded":z,onClick:()=>{z&&V&&be(""),se(ae=>!ae)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${z||ce?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:z||ce?t.jsx(F.HiXMark,{className:"h-4 w-4"}):t.jsx(F.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":p??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Z}`,children:X.length>0?X.map(ae=>{const Fe=ae.service===(I==null?void 0:I.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Fe,disabled:ae.disabled,onClick:()=>le(ae),onKeyDown:qe=>ie(qe,ae),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${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:y?y(ae,Fe):t.jsxs(t.Fragment,{children:[ae.icon,t.jsx("span",{children:ae.label??Hs(ae.service)}),ae.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ae.badge})]})},ae.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:N??"No hay modulos que coincidan con la busqueda."})}),(I==null?void 0:I.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:I.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!I&&(w??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),I&&(De==null?void 0:De.loading)&&(v??t.jsx(Os,{title:"Cargando modulo..."})),I&&(De==null?void 0:De.error)&&E(De.error,ge),I&&kt&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(kt,{context:o,parent:a,link:I,activeItemId:$e,onOpenDetail:wt,onBackToList:re})]})]})]})}const Bd={sm:16,md:20,lg:24,xl:32};function Ps(e){if(e!=null)return typeof e=="number"?e:Bd[e]}function _s(e,r){const n=Ps(e);return n==null?r:{width:n,height:n,...r}}function Pd(e,r){const n=s.forwardRef(function({className:o,title:l,size:i,style:c,...f},d){const h=i!=null;return t.jsxs("svg",{ref:d,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":l?void 0:!0,role:l?"img":void 0,className:Pe("block shrink-0",!h&&"h-[1em] w-[1em]",o),style:_s(i,c),...f,children:[l?t.jsx("title",{children:l}):null,r]})});return n.displayName=e,n}function xr(e,r){const n=s.forwardRef(function({className:o,title:l,size:i,style:c,...f},d){const h=i!=null;return t.jsxs("svg",{ref:d,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":l?void 0:!0,role:l?"img":void 0,className:Pe("block shrink-0",!h&&"h-[1em] w-[1em]",o),style:_s(i,c),...f,children:[l?t.jsx("title",{children:l}):null,r]})});return n.displayName=e,n}const _d=t.jsx("path",{d:"M5 2.5h8.25L19 8.25V20.5A1.5 1.5 0 0 1 17.5 22h-11A1.5 1.5 0 0 1 5 20.5V2.5Z"}),zd=t.jsx("path",{fill:"#fff",fillOpacity:.32,d:"M13.25 2.5V8.25H19Z"});function Wd(e,r=5.5){const n=e.length>3;return t.jsx("text",{x:"12",y:"16.75",textAnchor:"middle",fill:"#fff",fontSize:n?Math.min(r,4.6):r,fontWeight:700,fontFamily:"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",letterSpacing:n?"-0.06em":"0.01em",style:{userSelect:"none"},children:e})}function un(e){return t.jsxs(t.Fragment,{children:[_d,zd,e]})}function Qe(e,r,n){return xr(e,un(Wd(r,n)))}const zs=xr("FileFolderIcon",t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M3.25 8.1V7.1A1.6 1.6 0 0 1 4.85 5.5h4.05c.38 0 .74.13 1.03.37l1.02.85c.29.24.65.37 1.03.37h7.17A1.6 1.6 0 0 1 20.75 8.7v.4H3.25Z"}),t.jsx("path",{d:"M3.25 8.5h17.5v9A1.75 1.75 0 0 1 19 19.25H5A1.75 1.75 0 0 1 3.25 17.5v-9Z"})]})),Ws=Qe("FilePdfIcon","PDF",5.75),js=Qe("FileDocIcon","DOC",5.6),jn=Qe("FileDocxIcon","DOCX",4.7),qs=Qe("FileTxtIcon","TXT",5.6),jd=jn,Us=Qe("FileCsvIcon","CSV",5.6),Vs=Qe("FileXlsIcon","XLS",5.6),qn=Qe("FileXlsxIcon","XLSX",4.7),qd=qn,Xs=Qe("FilePptIcon","PPT",5.6),Un=Qe("FilePptxIcon","PPTX",4.7),Ud=Un,Ys=Qe("FileFigIcon","FIG",5.6),Gs=Qe("FileAiIcon","AI",5.75),Ks=Qe("FilePsdIcon","PSD",5.6),Zs=Qe("FileInddIcon","INDD",4.7),Qs=Qe("FileAepIcon","AEP",5.6),Js=Qe("FileSvgIcon","SVG",5.6),Rs=Qe("FileMp3Icon","MP3",5.6),el=Qe("FileWavIcon","WAV",5.6),tl=xr("FileAudioIcon",un(t.jsx("path",{fill:"#fff",d:"M10.2 10.4v6.2c0 .7-.55 1.25-1.25 1.25S7.7 17.3 7.7 16.6s.55-1.25 1.25-1.25c.2 0 .38.05.55.12V11.6l5.3-1.2v5.55c0 .7-.55 1.25-1.25 1.25s-1.25-.55-1.25-1.25.55-1.25 1.25-1.25c.2 0 .38.05.55.12V10.05l.2-.05-5.1 1.4Z"}))),rl=Qe("FileMp4Icon","MP4",5.6),nl=Qe("FileMpegIcon","MPEG",4.4),al=Qe("FileAviIcon","AVI",5.6),ol=Qe("FileMkvIcon","MKV",5.6),sl=xr("FileVideoIcon",un(t.jsx("path",{fill:"#fff",d:"M8.2 11.1h5.1c.55 0 1 .45 1 1v3.6c0 .55-.45 1-1 1H8.2c-.55 0-1-.45-1-1v-3.6c0-.55.45-1 1-1Zm7.05 1.05 2.55-1.35v5.2l-2.55-1.35v-2.5Z"}))),ll=Qe("FileZipIcon","ZIP",5.6),il=Qe("FileRarIcon","RAR",5.6),Vn=Qe("FileImgIcon","IMG",5.6),cl=Qe("FileJpgIcon","JPG",5.6),dl=Qe("FilePngIcon","PNG",5.6),Vd=Vn,ul=xr("FileCodeIcon",un(t.jsxs("g",{fill:"none",stroke:"#fff",strokeWidth:1.65,strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m8.2 12.2-2.25 1.9 2.25 1.9"}),t.jsx("path",{d:"m15.8 12.2 2.25 1.9-2.25 1.9"}),t.jsx("path",{d:"m12.85 11.45-1.2 5.4"})]}))),fl=xr("FileDocfyIcon",un(t.jsxs(t.Fragment,{children:[t.jsx("path",{fill:"#fff",d:"M7.5 12h9v1.4H7.5z"}),t.jsx("path",{fill:"#fff",d:"M7.5 14.55h9v1.4H7.5z"}),t.jsx("path",{fill:"#fff",d:"M7.5 17.1h5.75v1.4H7.5z"})]}))),no=Qe("FileGenericIcon","FILE",4.8),bl={folder:"text-amber-500",pdf:"text-[#EA4335]",doc:"text-[#4285F4]",docx:"text-[#4285F4]",word:"text-[#4285F4]",txt:"text-[#5F6368]",csv:"text-[#34A853]",xls:"text-[#34A853]",xlsx:"text-[#34A853]",excel:"text-[#34A853]",ppt:"text-[#EA4335]",pptx:"text-[#EA4335]",powerpoint:"text-[#EA4335]",fig:"text-[#A142F4]",ai:"text-[#FF6D00]",psd:"text-[#304FFE]",indd:"text-[#C2185B]",aep:"text-[#9C27B0]",svg:"text-[#A142F4]",mp3:"text-[#E91E63]",wav:"text-[#E91E63]",audio:"text-[#E91E63]",mp4:"text-[#4285F4]",mpeg:"text-[#4285F4]",avi:"text-[#4285F4]",mkv:"text-[#4285F4]",video:"text-[#4285F4]",zip:"text-[#5F6368]",rar:"text-[#5F6368]",img:"text-[#5F6368]",jpg:"text-[#5F6368]",png:"text-[#5F6368]",image:"text-[#5F6368]",code:"text-[#3949AB]",docfy:"text-[#4285F4]",generic:"text-[#9AA0A6]"},Xd=["folder","pdf","doc","docx","txt","csv","xls","xlsx","ppt","pptx","fig","ai","psd","indd","aep","svg","mp3","wav","audio","mp4","mpeg","avi","mkv","video","zip","rar","img","jpg","png","code","docfy","generic"],Yd={folder:zs,pdf:Ws,doc:js,docx:jn,word:jn,txt:qs,csv:Us,xls:Vs,xlsx:qn,excel:qn,ppt:Xs,pptx:Un,powerpoint:Un,fig:Ys,ai:Gs,psd:Ks,indd:Zs,aep:Qs,svg:Js,mp3:Rs,wav:el,audio:tl,mp4:rl,mpeg:nl,avi:al,mkv:ol,video:sl,zip:ll,rar:il,img:Vn,jpg:cl,png:dl,image:Vn,code:ul,docfy:fl,generic:no};function Gd({kind:e,colored:r=!0,className:n="",size:a,...o}){const l=Yd[e]??no,c=[r?bl[e]:"",n].filter(Boolean).join(" ");return t.jsx(l,{className:c||void 0,size:a,...o})}const Kd={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(F.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(F.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(F.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(F.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(F.HiInformationCircle,{className:"h-5 w-5"})}};function Zd({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=Kd[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&t.jsx("div",{className:"mt-3",children:o})]}),l&&t.jsx(Ke,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(F.HiXMark,{className:"h-4 w-4"})})]})}const hl=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Qd=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Jd=["lu","ma","mi","ju","vi","sá","do"],pl=6;function ao(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Rd(){const e=new Date;return ao(e.getFullYear(),e.getMonth()+1,e.getDate())}function oo(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function eu(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=oo(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${hl[n-1]} ${r}`}function ml(e){const{year:r,month:n,day:a}=oo(e);if(!r||!n||!a)return!1;const o=new Date(r,n-1,a).getDay();return o===0||o===6}function tu({value:e,onChange:r,minDate:n,maxDate:a,disableWeekends:o=!1,displayMode:l="inline",className:i=""}){const c=Rd(),d=oo(e||c),h=l==="popover",[b,u]=s.useState(!1),p=s.useRef(null),[g,w]=s.useState({horizontal:"left",vertical:"bottom"}),[v,E]=s.useState(d.year),[y,T]=s.useState(d.month),[L,C]=s.useState("days"),m=16,[S,N]=s.useState(0),_=v-7+S,U=Array.from({length:m},(W,R)=>_+R);s.useEffect(()=>{if(!h||!b||!p.current)return;const W=p.current.getBoundingClientRect(),R=8,$=280,P=340,ue=W.left+$>window.innerWidth-R,z=W.right-$>=R,se=W.bottom+8+P>window.innerHeight-R,q=W.top-8-P>=R;w({horizontal:ue&&z?"right":"left",vertical:se&&q?"top":"bottom"})},[h,b]),s.useEffect(()=>{if(!h||!b)return;function W($){p.current&&(p.current.contains($.target)||u(!1))}function R($){$.key==="Escape"&&u(!1)}return document.addEventListener("mousedown",W),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",R)}},[h,b]);function K(){y===1?(E(W=>W-1),T(12)):T(W=>W-1)}function D(){y===12?(E(W=>W+1),T(1)):T(W=>W+1)}const Z=(new Date(v,y-1,1).getDay()+6)%7,O=new Date(v,y,0).getDate(),ne=[...Array(Z).fill(null),...Array.from({length:O},(W,R)=>R+1)];for(;ne.length<pl*7;)ne.push(null);const ee=ne.slice(0,pl*7);function fe(W){const R=ao(v,y,W);n&&R<n||a&&R>a||o&&ml(R)||(r(R),h&&u(!1))}const J=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${i}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:L==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:K,"aria-label":"Mes anterior",children:t.jsx(F.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{C("years"),N(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[hl[y-1]," ",v]}),t.jsx(F.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:D,"aria-label":"Mes siguiente",children:t.jsx(F.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(W=>W-m),"aria-label":"Años anteriores",children:t.jsx(F.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:[U[0]," – ",U[U.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(W=>W+m),"aria-label":"Años siguientes",children:t.jsx(F.HiChevronRight,{size:16})})]})}),L==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Qd.map((W,R)=>{const $=R+1===y;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${$?" is-active":""}`,onClick:()=>T(R+1),children:W},W)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:U.map(W=>{const R=W===v,$=W===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${R?" is-active":""}${$&&!R?" is-today":""}`,onClick:()=>{E(W),C("days")},children:W},W)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Jd.map(W=>t.jsx("div",{className:"bonsaif-multi-weekday",children:W},W))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:ee.map((W,R)=>{if(W===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},R);const $=ao(v,y,W),P=$===e,ue=$===c,z=!!(n&&$<n)||!!(a&&$>a)||o&&ml($);return t.jsx("div",{className:`bonsaif-multi-day${P?" bonsaif-multi-day-selected":""}${ue?" bonsaif-multi-day-today":""}${z?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:z,"aria-pressed":P,onClick:()=>!z&&fe(W),children:W})},R)})})]})]})});return h?t.jsxs("div",{ref:p,className:`relative w-full ${i}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>u(W=>!W),className:"bonsaif-cal-trigger","data-open":b?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(F.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:eu(e)})]}),t.jsx(F.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${b?"rotate-180":""}`})]}),b&&t.jsx("div",{className:"absolute z-50",style:{...g.horizontal==="left"?{left:0}:{right:0},...g.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:J})]}):J}function er({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Xt,{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 so(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function lo(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function ru(e,r){if(!r.trim())return!0;const n=lo(r);return lo(e.label).includes(n)||!!(e.sublabel&&lo(e.sublabel).includes(n))}function yr({value:e,onChange:r,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:f,disabled:d=!1,className:h="",style:b,dropdownMinWidth:u,dropdownZIndex:p=9999,height:g=40,padding:w="0 10px",searchable:v=!0,minOptionsForSearch:E=6}){const[y,T]=s.useState(!1),[L,C]=s.useState(""),[m,S]=s.useState(-1),[N,_]=s.useState(!1),[U,K]=s.useState({}),D=s.useRef(null),Z=s.useRef(null),O=s.useRef(null),ne=s.useRef(null),ee=v&&n.length>=E,fe=n.find(M=>M.value===e)??null,J=l==="ghost",W=a==="error"?"var(--danger)":y?"var(--primary)":"var(--border)",R=ee&&L.trim()?n.filter(M=>ru(M,L)):n,$=s.useCallback(()=>{const M=D.current;if(!(M!=null&&M.isConnected))return;const Y=M.getBoundingClientRect();if(Y.width<1&&Y.height<1||Y.bottom<0||Y.top>window.innerHeight)return;const ce=ee?272:212,X=window.innerHeight-Y.bottom,G=X<ce&&Y.top>X,I=8,le=Math.max(Y.width,0),be=Math.max(I,window.innerWidth-le-I),ie=Math.min(Math.max(I,Y.left),be);K({position:"fixed",left:ie,top:G?void 0:Y.bottom+4,bottom:G?window.innerHeight-Y.top+4:void 0,width:Y.width,minWidth:so(u),zIndex:p})},[u,p,ee]);s.useEffect(()=>_(!0),[]),s.useEffect(()=>{if(!y)return;function M(Y){var X,G;const ce=Y.target;!((X=D.current)!=null&&X.contains(ce))&&!((G=Z.current)!=null&&G.contains(ce))&&(T(!1),C(""))}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[y]),s.useEffect(()=>{y&&(S(-1),$(),ee&&setTimeout(()=>{var M;return(M=O.current)==null?void 0:M.focus()},0))},[y,ee,$]),s.useEffect(()=>{if(y)return window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[y,$]),s.useEffect(()=>{if(m<0||!ne.current)return;const M=ne.current.children[m];M==null||M.scrollIntoView({block:"nearest"})},[m]);const P=s.useCallback(M=>{r(M),T(!1),C("")},[r]),ue=s.useRef(y);ue.current=y;const z=s.useRef(R);z.current=R;const se=s.useRef(m);se.current=m;const q=s.useRef(f);q.current=f;const k=s.useRef(P);k.current=P,s.useEffect(()=>{function M(Y){var I,le;const ce=document.activeElement,X=((I=D.current)==null?void 0:I.contains(ce))??!1,G=((le=Z.current)==null?void 0:le.contains(ce))??!1;if(!(!X&&!G)){if(!ue.current){(Y.key==="Enter"||Y.key===" "||Y.key==="ArrowDown")&&(Y.preventDefault(),T(!0));return}switch(Y.key){case"ArrowDown":Y.preventDefault(),S(be=>Math.min(be+1,z.current.length-1));break;case"ArrowUp":Y.preventDefault(),S(be=>Math.max(be-1,q.current?-1:0));break;case"Enter":{Y.preventDefault();const be=se.current,ie=z.current;be===-1&&q.current?k.current(""):ie[be]&&!ie[be].disabled&&k.current(ie[be].value);break}case"Escape":Y.preventDefault(),Y.stopPropagation(),T(!1),C("");break}}}return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[]);const V=t.jsxs("div",{ref:Z,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...U,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ee&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(F.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:O,value:L,onChange:M=>{C(M.target.value),S(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),L&&t.jsx("button",{type:"button",onMouseDown:M=>{M.preventDefault(),C("")},children:t.jsx(F.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:ne,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ee?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[f&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:M=>{M.preventDefault(),P("")},onMouseEnter:()=>S(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:m===-1&&!L.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:f}),R.map((M,Y)=>{const X=Y===m,G=M.value===e;return t.jsxs("li",{role:"option","aria-selected":G,onMouseDown:I=>{I.preventDefault(),M.disabled||P(M.value)},onMouseEnter:()=>!M.disabled&&S(Y),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:X?"var(--bg-hover)":G?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:M.disabled?"var(--text-muted)":"var(--text-main)",cursor:M.disabled?"not-allowed":"pointer",boxShadow:G?"inset 2px 0 0 var(--primary)":void 0},children:[M.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:M.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(er,{className:"min-w-0 flex-1",children:M.label}),M.sublabel&&t.jsx(er,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:M.sublabel})]}),M.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:M.badge})]},M.value)}),R.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:D,className:`relative ${h||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:d,onClick:()=>!d&&T(M=>!M),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:so(g),padding:so(w),background:J?"transparent":"var(--bg-input)",color:fe?"var(--text-main)":"var(--text-muted)",border:J?"1px solid transparent":`1px solid ${W}`,opacity:d?.5:1,cursor:d?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":y,"aria-label":o,children:[(fe==null?void 0:fe.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:fe.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:fe?t.jsxs(t.Fragment,{children:[t.jsx(er,{className:"min-w-0 flex-1",children:fe.label}),i&&fe.sublabel&&t.jsx(er,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:fe.sublabel})]}):t.jsx(er,{className:"min-w-0 flex-1",children:c})}),fe&&f?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:M=>{M.preventDefault(),M.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(F.HiXMark,{className:"w-3 h-3"})}):t.jsx(F.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:y?"rotate(180deg)":"rotate(0deg)"}})]}),y&&N&&bt.createPortal(V,document.body)]})}const nu={sm:"h-4 w-4",md:"h-5 w-5"};function au(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Xn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:f,...d},h){const b=s.useRef(null);return s.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${f?"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",{...d,ref:u=>{b.current=u,au(h,u)},type:"checkbox",disabled:f,"aria-checked":l?"mixed":d["aria-checked"],"aria-invalid":!!a||d["aria-invalid"],className:`peer ${nu[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(F.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(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})]})]})}),gl=32767;function Yn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=gl?r:`${r.slice(0,gl-1)}…`}const Gn=[25,50,100,200,500];let _t={dataTable:{pageSizeOptions:[...Gn]}};function ou(){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 io(){const e=_t.dataTable.preferencesEndpoint,r=ou();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function su(e){if(!Array.isArray(e))return[...Gn];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:[...Gn]}function vl(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function lu(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=vl(e.dataTable.preferencesEndpoint);_t={..._t,dataTable:{..._t.dataTable,pageSizeOptions:su(e.dataTable.pageSizeOptions),preferencesEndpoint:r??_t.dataTable.preferencesEndpoint}}}function iu(){return{dataTable:{pageSizeOptions:[..._t.dataTable.pageSizeOptions]}}}function fn(){return[..._t.dataTable.pageSizeOptions]}function cu(){_t={dataTable:{pageSizeOptions:[...Gn]}}}function du(e){_t={..._t,dataTable:{..._t.dataTable,preferencesEndpoint:vl(e)}}}const Kn=[{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"}],uu=Kn.map(e=>({value:e.value,label:e.label})),fu=12,bu={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},xl={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},hu="bonsaif-ui:datatable:",pu="[&_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",mu=[],gu=52;function tr(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function yl(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.filterOptionValues&&Object.keys(e.filterOptionValues).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function wl(e){return`${hu}${e}`}function Zn(e){try{const r=window.localStorage.getItem(wl(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function vu(e,r){try{window.localStorage.setItem(wl(e),JSON.stringify(r))}catch{}}function xu(e,r){if(e===!0)return{...xl};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...xl};const n={...bu,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function Nl(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function co(e,r,n){return typeof e!="number"||e<=0?n:gn(r).includes(e)?e:n}function bn(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function hn(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 yu(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=[...new Set(o.filter(i=>typeof i=="string"&&i.trim().length>0))];return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function wu(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!o||typeof o!="object")return[];const l=Object.fromEntries(Object.entries(o).flatMap(([i,c])=>typeof i=="string"&&i.trim()&&typeof c=="string"&&c.trim()?[[i,c]]:[]));return Object.keys(l).length>0?[[a,l]]:[]});return Object.fromEntries(n)}function pn(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(Kn.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 Tt(e,r){if(wr(e))return gu;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Nu(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function wr(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function uo(e){return e.sticky===!0}function kl(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Qn(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 f=r[c],d=a.indexOf(f);if(d!==-1){i=d+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const f=r[c],d=a.indexOf(f);if(d!==-1){i=d;break}}a.splice(i,0,l)}return a}function sr(e,r){const n=r.filter(uo).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 ku(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 lr(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 Su(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function Or(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Or).join(" ").trim():s.isValidElement(e)?Or(e.props.children):""}function Jn(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?Su(n):Or(n).trim()}function mn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Hr(e,r){const n=mn(e),a=mn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function gn(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:fn()}function Cu(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=Kn.find(f=>f.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 Hr(e,a)>0;case"greaterThanOrEqual":return Hr(e,a)>=0;case"lessThan":return Hr(e,a)<0;case"lessThanOrEqual":return Hr(e,a)<=0;case"between":return Hr(e,a)>=0&&Hr(e,o)<=0;case"top10":case"bottom10":{const d=n.map(b=>({value:b,number:mn(b)})).filter(b=>b.number!==null).sort((b,u)=>b.number-u.number).map(b=>b.value);return(r.operator==="top10"?d.slice(-10):d.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const f=n.map(mn).filter(b=>b!==null);if(f.length===0)return!1;const d=f.reduce((b,u)=>b+u,0)/f.length,h=mn(e);return h===null?!1:r.operator==="aboveAverage"?h>d:h<d}default:return!0}}function Sl({children:e,className:r="",style:n}){return t.jsx(Xt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function fo({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:f,renderExpandedRow:d,getRowCanExpand:h,expandedRowIds:b,defaultExpandedRowIds:u=[],onExpandedRowIdsChange:p,expandOnRowClick:g=!1,selected:w,onToggleOne:v,onToggleAll:E,getRowSelectable:y,highlightSelected:T=!0,rowClassName:L,getRowCategory:C,stickyHeader:m=!0,pageSize:S=25,pageSizeOptions:N,pageSizeSelectWidth:_=62,pageSizeSelectHeight:U=30,pageSizeSelectPadding:K="0 7px",totalRows:D,page:Z,onPageChange:O,onPageSizeChange:ne,storageKey:ee,stickyFirstColumn:fe=!1,bottomOffset:J=0,compact:W=!0,restrictHeight:R=!0,maxHeight:$,minTableWidth:P,enableColumnVisibility:ue=!0,enableColumnFilters:z=!0,hiddenColumnKeys:se,defaultHiddenColumnKeys:q=mu,onHiddenColumnKeysChange:k,columnVisibilityLabel:V="Columnas",enableBql:M=!1,bqlValue:Y,defaultBqlValue:ce="",onBqlChange:X,bqlDescription:G="Filtra registros con Bonsaif Query Language",bqlPlaceholder:I=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:le=[],bqlExamples:be=[],bqlSuggestions:ie=[],bqlActiveFilters:ge,bqlError:$e,onQueryChange:De,persistState:kt,onPreferencesReady:wt,enableExport:re=!1,exportFilename:xe="datos",onExportCsv:oe,onExportPdf:we}){var md;const ae=xu(kt,ee),Fe=Object.values(ae).some(Boolean),qe=e.map(x=>x.key).join(","),Je=q.join(","),Ze=s.useRef(e),Ue=s.useRef(q);Ze.current=e,Ue.current=q;const[tt,Ct]=s.useState(!ee||!Fe),xt=s.useRef(null),Et=s.useRef(!ee),ve=s.useRef(!1),ke=s.useRef(wt);ke.current=wt;const _e=s.useRef(!ee||!Fe?ee??"__none__":null),je=se!==void 0,[Re,ot]=s.useState(()=>lr(q,e)),lt=lr(je?se:Re,e),[rt,dt]=s.useState(!1),[st,Sr]=s.useState("filter"),[ht,Cr]=s.useState(null),[Ft,Ye]=s.useState(""),[pt,hr]=s.useState({}),[Mt,qt]=s.useState({}),Er=s.useRef({}),pr=s.useRef({});function tn(x,H){if(!x)return;const Q=yu(x.filterOptionValues,H),B=wu(x.filterOptionLabels,H);Object.keys(Q).length>0&&(Er.current={...Er.current,...Q}),Object.keys(B).length>0&&(pr.current={...pr.current,...B})}const j=b!==void 0,[te,me]=s.useState(u),pe=Y!==void 0,[ye,Se]=s.useState(ce),ze=pe?Y:ye,[Te,it]=s.useState(ze),[Ve,mt]=s.useState(!1),[ut,gt]=s.useState(!1),[nr,Ut]=s.useState(!1),[Ot,ar]=s.useState([]),mr=s.useRef(null),Ht=s.useRef(null),yt=s.useRef(null),Qt=s.useRef(X);Qt.current=X;const Da=s.useRef(S);Da.current=S;const Ia=s.useRef(N);Ia.current=N;const $m=Array.isArray(N)?N.join(","):"",us=s.useRef(null),jc=s.useRef(null),fs=s.useRef(null),qc=s.useRef(0),[Dm,Im]=s.useState({}),[Fm,Om]=s.useState({}),[Dn,Fa]=s.useState(!1),bs=s.useRef(null),Oa=s.useRef(null),[Hm,Bm]=s.useState({}),Uc=s.useRef(null),In=s.useRef(null),[hs,Vc]=s.useState(r.length>0||a||c===!1),Xc=(x,H)=>50+(x*17+H*13+7)%40,Bt=s.useRef(null),[Pm,_m]=s.useState(void 0),[Yc,zm]=s.useState(0),[Wm,jm]=s.useState(!1);s.useEffect(()=>{function x(){jm(window.innerWidth<640)}if(!R||$!==void 0)return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x);const Q=S!==!1?48:0,B=12;function de(){if(x(),!Bt.current)return;const Ee=Bt.current.getBoundingClientRect().top;_m(Math.max(120,window.innerHeight-Ee-Q-B-J))}de(),window.addEventListener("resize",de);const he=typeof ResizeObserver<"u"&&Bt.current?new ResizeObserver(()=>de()):null;return Bt.current&&he&&he.observe(Bt.current),()=>{window.removeEventListener("resize",de),he==null||he.disconnect()}},[a,S,J,R,$,tt,r.length]);const Gc=R?$??Pm:void 0;s.useEffect(()=>{const x=Bt.current;if(!x)return;const H=()=>zm(x.clientWidth);if(H(),typeof ResizeObserver>"u")return window.addEventListener("resize",H),()=>window.removeEventListener("resize",H);const Q=new ResizeObserver(H);return Q.observe(x),()=>Q.disconnect()},[a,tt,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){Vc(!0);return}if(hs)return;const x=window.setTimeout(()=>{Vc(!0)},c);return()=>window.clearTimeout(x)},[r.length,c,hs,a]);const[rn,nn]=s.useState(()=>sr(e.map(x=>x.key),e)),[Mr,an]=s.useState(()=>Object.fromEntries(e.map(x=>[x.key,Tt(x,tr(x.width))]))),[nt,Tr]=s.useState(null),[qm,Ha]=s.useState(1),[Ba,Pa]=s.useState(S===!1?0:S);s.useEffect(()=>{var Be;const x=Ze.current,H=Ue.current,Q=x.map(Ae=>Ae.key),B=new Set(Q),de=()=>{var Ae;ve.current||(ve.current=!0,(Ae=ke.current)==null||Ae.call(ke))};if(!ee||!Fe){ae.layout&&nn(sr(Q,x)),je||ot(lr(H,x)),Et.current=!1,Ct(!0),de();return}let he=!1;const Ee=_e.current===ee;Ee||(Et.current=!1,Ct(!1),ve.current=!1);const Ie=Zn(ee);if(yl(Ie)&&!Ee){const Ae=Ie,Me=gn(Ia.current??fn()),Le=Da.current,$r=Le===!1?0:Le,vr=ae.layout?Ae==null?void 0:Ae.columnOrder:void 0,Dr=Array.isArray(vr)?vr.filter(et=>Q.includes(et)):[],Ir=sr(Dr.length>0?Qn(Dr,Q):Q,x),Fr=Object.fromEntries(x.map(et=>[et.key,Tt(et,tr(et.width))])),ln=ae.layout?(Ae==null?void 0:Ae.columnWidths)??{}:{},Pn=Object.fromEntries(x.map(et=>[et.key,Tt(et,ln[et.key]??Fr[et.key])])),cn=lr(ae.layout?(Ae==null?void 0:Ae.hiddenColumnKeys)??H:H,x);if(ae.layout&&(nn(Ir),an(Pn)),je||ot(cn),ae.filters&&Ht.current!==ee&&(Ht.current=ee,tn(Ae,B),hr(hn(Ae==null?void 0:Ae.filters,B)),qt(pn(Ae==null?void 0:Ae.conditionFilters,B))),ae.sort){const et=bn(Ae==null?void 0:Ae.sort)?Ae.sort:null;Tr(et&&B.has(et.key)?et:null)}if(ae.bql){if(mr.current!==ee){mr.current=ee;const et=typeof(Ae==null?void 0:Ae.bql)=="string"?Ae.bql:ce;pe?(Be=Qt.current)==null||Be.call(Qt,et):Se(et)}ar(Array.isArray(Ae==null?void 0:Ae.bqlHistory)?Ae.bqlHistory.filter(et=>typeof et=="string"):[])}ae.pagination&&yt.current!==ee&&(yt.current=ee,Pa(co(Ae==null?void 0:Ae.pageSize,Me,$r))),_e.current=ee,Ct(!0),de()}const He=`${io()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(ee)}`,Ge=new AbortController,Ce=window.setTimeout(()=>Ge.abort(),2500);return fetch(He,{cache:"no-store",signal:Ge.signal}).then(Ae=>Ae.ok?Ae.json():null).then(Ae=>{var gd;if(he)return;const Me=Zn(ee),Le=Nl(yl(Ae==null?void 0:Ae.settings)?Ae==null?void 0:Ae.settings:null,Me),$r=gn(Ia.current??fn()),vr=Da.current,Dr=vr===!1?0:vr,Ir=ae.layout?Le==null?void 0:Le.columnOrder:void 0,Fr=Array.isArray(Ir)?Ir.filter(ft=>Q.includes(ft)):[],ln=sr(Fr.length>0?Qn(Fr,Q):Q,x),Pn=Object.fromEntries(x.map(ft=>[ft.key,Tt(ft,tr(ft.width))])),cn=ae.layout?(Le==null?void 0:Le.columnWidths)??{}:{},et=Object.fromEntries(x.map(ft=>[ft.key,Tt(ft,cn[ft.key]??Pn[ft.key])])),dn=lr(ae.layout?(Le==null?void 0:Le.hiddenColumnKeys)??H:H,x);if(ae.layout&&(nn(ln),an(et)),je||ot(dn),ae.filters&&Ht.current!==ee&&(Ht.current=ee,tn(Le,B),hr(hn(Le==null?void 0:Le.filters,B)),qt(pn(Le==null?void 0:Le.conditionFilters,B))),ae.sort){const ft=bn(Le==null?void 0:Le.sort)?Le.sort:null;Tr(ft&&B.has(ft.key)?ft:null)}if(ae.bql){if(mr.current!==ee){mr.current=ee;const ft=typeof(Le==null?void 0:Le.bql)=="string"?Le.bql:ce;pe?(gd=Qt.current)==null||gd.call(Qt,ft):Se(ft)}ar(Array.isArray(Le==null?void 0:Le.bqlHistory)?Le.bqlHistory.filter(ft=>typeof ft=="string"):[])}let at;ae.pagination&&(at=co(Le==null?void 0:Le.pageSize,$r,Dr),yt.current!==ee&&(yt.current=ee,Pa(at))),xt.current=JSON.stringify({columnOrder:ln,columnWidths:et,hiddenColumnKeys:dn,filters:hn(Le==null?void 0:Le.filters,B),conditionFilters:pn(Le==null?void 0:Le.conditionFilters,B),sort:bn(Le==null?void 0:Le.sort)?Le.sort:null,bql:typeof(Le==null?void 0:Le.bql)=="string"?Le.bql:"",bqlHistory:Array.isArray(Le==null?void 0:Le.bqlHistory)?Le.bqlHistory:[],pageSize:ae.pagination&&vr!==!1?at:void 0}),Et.current=!0}).catch(()=>{var Ae;if(!he){const Me=Zn(ee),Le=gn(Ia.current??fn()),$r=Da.current,vr=$r===!1?0:$r,Dr=ae.layout?Me==null?void 0:Me.columnOrder:void 0,Ir=Array.isArray(Dr)?Dr.filter(at=>Q.includes(at)):[],Fr=sr(Ir.length>0?Qn(Ir,Q):Q,x),ln=Object.fromEntries(x.map(at=>[at.key,Tt(at,tr(at.width))])),Pn=ae.layout?(Me==null?void 0:Me.columnWidths)??{}:{},cn=Object.fromEntries(x.map(at=>[at.key,Tt(at,Pn[at.key]??ln[at.key])]));ae.layout&&(nn(Fr),an(cn));const et=lr(ae.layout?(Me==null?void 0:Me.hiddenColumnKeys)??H:H,x);if(je||ot(et),ae.filters&&Ht.current!==ee&&(Ht.current=ee,tn(Me,B),hr(hn(Me==null?void 0:Me.filters,B)),qt(pn(Me==null?void 0:Me.conditionFilters,B))),ae.sort){const at=bn(Me==null?void 0:Me.sort)?Me.sort:null;Tr(at&&B.has(at.key)?at:null)}if(ae.bql){if(mr.current!==ee){mr.current=ee;const at=typeof(Me==null?void 0:Me.bql)=="string"?Me.bql:ce;pe?(Ae=Qt.current)==null||Ae.call(Qt,at):Se(at)}ar(Array.isArray(Me==null?void 0:Me.bqlHistory)?Me.bqlHistory.filter(at=>typeof at=="string"):[])}let dn;ae.pagination&&(dn=co(Me==null?void 0:Me.pageSize,Le,vr),yt.current!==ee&&(yt.current=ee,Pa(dn))),xt.current=JSON.stringify({columnOrder:Fr,columnWidths:cn,hiddenColumnKeys:et,filters:hn(Me==null?void 0:Me.filters,B),conditionFilters:pn(Me==null?void 0:Me.conditionFilters,B),sort:bn(Me==null?void 0:Me.sort)?Me.sort:null,bql:typeof(Me==null?void 0:Me.bql)=="string"?Me.bql:"",bqlHistory:Array.isArray(Me==null?void 0:Me.bqlHistory)?Me.bqlHistory:[],pageSize:ae.pagination&&$r!==!1?dn:void 0}),Et.current=!0}}).finally(()=>{window.clearTimeout(Ce),he||(_e.current=ee,Ct(!0),de())}),()=>{he=!0,Ge.abort(),window.clearTimeout(Ce)}},[ee,Fe,qe,Je,je,ae.layout,ae.filters,ae.sort,ae.bql,ae.pagination,pe,ce,$m]),s.useEffect(()=>{if(!ee||!tt||!Fe||!Et.current)return;const x={};ae.layout&&(x.columnOrder=rn,x.columnWidths=Mr,x.hiddenColumnKeys=lt),ae.filters&&(x.filters=pt,x.conditionFilters=Mt,x.filterOptionValues=Er.current,x.filterOptionLabels=pr.current),ae.sort&&(x.sort=nt),ae.bql&&(x.bql=ze,x.bqlHistory=Ot),ae.pagination&&S!==!1&&(x.pageSize=Ba);const H=Zn(ee),Q=Nl(H,x),B=JSON.stringify(Q);if(B===xt.current)return;vu(ee,Q),xt.current=B;const de=window.setTimeout(()=>{const he=io()??"/api/user/preferences/datatables";fetch(he,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:ee,settings:Q})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(de)},[rn,Mr,lt,pt,Mt,nt,ze,Ot,Ba,S,ee,tt,Fe,ae.layout,ae.filters,ae.sort,ae.bql,ae.pagination,r]),s.useEffect(()=>{nn(x=>{const H=e.map(Q=>Q.key);return sr(Qn(x,H),e)})},[qe,e]);const Kc=sr(rn,e).map(x=>e.find(H=>H.key===x)).filter(x=>!!x),Pt=Kc.filter(x=>!lt.includes(x.key)),Zc=e.some(uo),Um=Object.keys(pt).length,Vm=Object.keys(Mt).length,ps=Um+Vm;function ms(x){var Ie;const H=!!(O&&ne),Q=new Map,B=(Ne,We)=>{const He=Ne.trim();if(!He)return;const Ge=(We??He).trim()||He;Q.has(He)?We!=null&&We.trim()&&Q.get(He)===He&&Q.set(He,Ge):Q.set(He,Ge)};for(const Ne of x.filterOptions??[])typeof Ne=="string"?B(Ne):Ne!=null&&Ne.value&&B(Ne.value,Ne.label);if(H){const Ne=pr.current[x.key]??{};for(const We of Er.current[x.key]??[])B(We,Ne[We])}for(const Ne of r){const We=Jn(x,Ne),He=((Ie=x.filterOptionLabel)==null?void 0:Ie.call(x,Ne))??void 0;B(We,He??void 0)}for(const Ne of pt[x.key]??[])B(Ne);const de=Ne=>/^[a-f\d]{24}$/i.test(Ne.trim()),he=new Map;for(const[Ne,We]of Q){const He=We.trim().toLowerCase(),Ge=he.get(He)??[];Ge.push(Ne),he.set(He,Ge)}for(const Ne of he.values()){if(Ne.length<2)continue;const We=Ne.find(de)??Ne.slice().sort((He,Ge)=>He.localeCompare(Ge))[0];for(const He of Ne)He!==We&&Q.delete(He)}const Ee=Array.from(Q.keys()).sort((Ne,We)=>{const He=Q.get(Ne)??Ne,Ge=Q.get(We)??We;return He.localeCompare(Ge,void 0,{numeric:!0,sensitivity:"base"})});return H&&(Er.current[x.key]=Ee,pr.current[x.key]=Object.fromEntries(Q.entries())),Ee.map(Ne=>({value:Ne,label:Q.get(Ne)??Ne}))}function Xm(){const x=e.find(H=>H.key===ht);return x?ms(x):[]}function Ym(x){return!!(z&&!wr(x)&&(x.filterValue||x.sortKey||ms(x).length>0))}function gs(x,H){hr(Q=>{const B={...Q};return B[x]=H,B})}function Gm(x,H,Q,B){const de=pt[x]??[],he=B?de.includes(H)?de.filter(Ie=>Ie!==H):[...de,H]:[H];Q.length>0&&he.length===Q.length&&Q.every(Ie=>he.includes(Ie))?_a(x):gs(x,he)}function _a(x){hr(H=>{const Q={...H};return delete Q[x],Q})}function za(x,H){qt(Q=>{const B={...Q};return H?B[x]=H:delete B[x],B})}function Qc(x){za(x,null)}function Km(){hr({}),qt({})}function Zm(x){pe||Se(x),X==null||X(x)}function Jc(x){const H=x.trim();it(H),(X==null?void 0:X(H))!==!1&&(pe||Se(H),mt(!1),gt(!1),Ut(!1),H&&ar(B=>[H,...B.filter(de=>de!==H)].slice(0,fu)))}function Rc(){it(""),Zm(""),mt(!1),gt(!1),Ut(!1)}function vs(x,H){it(x),H&&(H.style.height="auto",H.style.height=`${Math.min(H.scrollHeight,180)}px`)}function Wa(x){const H=x.trim();if(!H)return;qc.current=Date.now()+500;const Q=Te.replace(/\s+$/u,""),B=Q.length===0?H:Q.split(`
|
|
3
|
+
`).map(de=>de.trim()).includes(H)?Q:`${Q}
|
|
4
|
+
${H}`;vs(B,fs.current??void 0),requestAnimationFrame(()=>{const de=fs.current;if(!de)return;de.focus();const he=de.value.length;de.setSelectionRange(he,he),vs(de.value,de)})}s.useEffect(()=>{it(ze)},[ze]);const ja=s.useCallback(()=>{const x=us.current;if(!x)return;const H=x.getBoundingClientRect(),Q=12,B=8,de=Math.min(780,Math.max(320,window.innerWidth-32)),he=Math.max(Q,window.innerWidth-de-Q),Ee=Math.min(Math.max(Q,H.left),he),Ie=H.bottom+B,Ne=window.innerHeight-H.top+B,We=window.innerHeight-Ie-Q,He=H.top-Q-B,Ge=We<280&&He>We,Ce=Math.max(240,Ge?He:We);Im({position:"fixed",zIndex:1e4,left:Ee,top:Ge?void 0:Ie,bottom:Ge?Ne:void 0,width:de,maxWidth:"calc(100vw - 24px)",maxHeight:Ce,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ve)return;function x(B){var he,Ee;if(Date.now()<qc.current)return;const de=B.target;(he=us.current)!=null&&he.contains(de)||(Ee=jc.current)!=null&&Ee.contains(de)||(mt(!1),gt(!1),Ut(!1))}function H(B){B.key==="Escape"&&(mt(!1),gt(!1),Ut(!1))}function Q(){ja()}return ja(),document.addEventListener("mousedown",x),window.addEventListener("keydown",H),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",H),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ve,ja]);function ed(x){const H=lr(x,e);je||ot(H),k==null||k(H)}function Qm(x){ed(lt.includes(x)?lt.filter(H=>H!==x):[...lt,x])}function Jm(){ed([])}const qa=s.useCallback(x=>{var de;if(x!=null&&x.isConnected)return x;if(!ht)return null;const Q=`[role="columnheader"][data-dt-column-key="${typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(ht):ht.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"] button[aria-haspopup="menu"]`,B=((de=Bt.current)==null?void 0:de.querySelector(Q))??document.querySelector(Q);return B&&(In.current=B),B},[ht]),Fn=s.useCallback((x=In.current)=>{const H=qa(x);if(!H)return;const B=(H.closest("th")??H.closest("[role='columnheader']")??H.closest("[data-dt-column-key]")??H).getBoundingClientRect();if(B.width<1&&B.height<1||B.bottom<0||B.top>window.innerHeight)return;const de=Math.min(292,Math.max(240,window.innerWidth-16)),he=8,Ee=Math.max(he,window.innerWidth-de-he),Ie=Math.min(Math.max(he,B.left),Ee),Ne=window.innerHeight-B.bottom,We=B.bottom+6,He=window.innerHeight-B.top+6,Ce=Ne<360&&B.top>Ne?void 0:We,Be=Ce===void 0?He:void 0,Ae=Math.max(220,Ce===void 0?B.top-16:window.innerHeight-We-8),Me={position:"fixed",zIndex:9999,left:Ie,top:Ce,bottom:Be,width:de,maxWidth:"calc(100vw - 16px)",maxHeight:Ae,"--dt-column-menu-max-height":`${Ae}px`};Om(Me)},[qa]);function td(x,H,Q=null){x.preventDefault(),x.stopPropagation();const B=In.current===x.currentTarget&&st===H&&ht===Q;if(rt&&B){dt(!1),Cr(null);return}if(In.current=x.currentTarget,Sr(H),Cr(Q),Ye(""),H==="filter"&&Q){const de=e.find(Ee=>Ee.key===Q),he=pt[Q];if(de&&(he!=null&&he.length)){const Ee=ms(de),Ie=new Map(Ee.map(He=>[He.label.trim().toLowerCase(),He.value])),Ne=[...new Set(he.map(He=>Ee.some(Ge=>Ge.value===He)?He:Ie.get(He.trim().toLowerCase())??He))];(Ne.length!==he.length||Ne.some((He,Ge)=>He!==he[Ge]))&&(Ee.length>0&&Ne.length===Ee.length&&Ee.every(He=>Ne.includes(He.value))?_a(Q):gs(Q,Ne))}}Fn(x.currentTarget),dt(!0)}function Rm(x){if(wr(x))return;const H=Bt.current;if(!H)return;const B=Array.from(H.querySelectorAll("[data-dt-column-key]")).filter(de=>de.dataset.dtColumnKey===x.key).reduce((de,he)=>{const Ee=he.querySelector("[data-dt-autofit-content]"),Ie=Ee?Ee.scrollWidth:Math.max(he.scrollWidth,he.offsetWidth);return Math.max(de,Math.ceil(Ie+Nu(he)))},0);B<=0||an(de=>({...de,[x.key]:Tt(x,B+12)}))}s.useEffect(()=>{an(x=>{const H=Object.fromEntries(e.map(Q=>[Q.key,Tt(Q,tr(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,Tt(Q,x[Q.key]??H[Q.key])]))})},[qe,e]),s.useEffect(()=>{je||ot(x=>lr(x,e))},[qe,e,je]),s.useEffect(()=>{function x(B){var Ie;const de=B.target,he=B.target;if(he!=null&&he.closest("[data-bonsaif-select-dropdown='true']"))return;const Ee=qa(In.current);!((Ie=Uc.current)!=null&&Ie.contains(de))&&!(Ee!=null&&Ee.contains(de))&&(dt(!1),Cr(null))}function H(B){B.key==="Escape"&&(dt(!1),Cr(null))}function Q(){Fn()}return rt&&(document.addEventListener("mousedown",x),window.addEventListener("keydown",H),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",H),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[rt,qa,Fn]),s.useLayoutEffect(()=>{!rt||!ht||Fn()},[rt,ht,pt,Mt,r,Fn]);const On=s.useRef(null);s.useEffect(()=>{function x(Q){const B=On.current;if(!B)return;const de=Q.clientX-B.startX,he=e.find(Ee=>Ee.key===B.colKey);he&&an(Ee=>({...Ee,[B.colKey]:Tt(he,B.startWidth+de)}))}function H(){On.current&&(On.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",x),document.addEventListener("pointerup",H),()=>{document.removeEventListener("pointermove",x),document.removeEventListener("pointerup",H)}},[e]);const Hn=s.useRef(null),[rd,xs]=s.useState(null);function eg(x,H){const Q=e.find(B=>B.key===x);if(!Q||!kl(Q)){H.preventDefault();return}Hn.current=rn.indexOf(x),H.dataTransfer.effectAllowed="move"}function tg(x,H){H.preventDefault(),H.dataTransfer.dropEffect="move";const Q=rn.indexOf(x);rd!==Q&&xs(Q)}function rg(x,H){H.preventDefault();const Q=Hn.current,B=rn.indexOf(x);Q!==null&&Q!==B&&nn(de=>{const he=[...de],[Ee]=he.splice(Q,1);return he.splice(B,0,Ee),sr(he,e)}),Hn.current=null,xs(null)}function ng(){Hn.current=null,xs(null)}function ag(x){x.sortKey&&Tr(H=>(H==null?void 0:H.key)===x.key?{key:x.key,dir:H.dir==="asc"?"desc":"asc"}:{key:x.key,dir:"asc"})}s.useEffect(()=>{Ha(1)},[r]),s.useEffect(()=>{Ha(1)},[Mt,pt]);const Jt=!!(O&&ne),gr=S!==!1,ys=s.useMemo(()=>gn(N??fn()),[N]),Nt=Jt?Z??1:qm,nd=gr&&Ba<1?typeof S=="number"&&S>0?S:ys[0]??25:Ba,Rt=Jt||gr?nd:r.length,Vt=!!w&&!!v&&!!E,ws=s.useMemo(()=>y?r.filter(x=>y(x)):r,[r,y]),on=!!d,ad=s.useMemo(()=>new Set(j?Array.from(b??[]):te),[j,b,te]),og=(on?40:0)+(Vt?40:0),Ns=!Wm&&(Zc||fe),Ua=(()=>{if(!Ns)return{};let x=og;const H={};return Pt.forEach((Q,B)=>{(uo(Q)||!Zc&&fe&&B===0)&&(H[Q.key]=x,x+=Mr[Q.key]??Tt(Q,tr(Q.width)))}),H})(),ks=Object.keys(Ua),Ss=ks.length>0?ks[ks.length-1]:null,od=Vt&&ws.length>0&&ws.every(x=>w.has(n(x))),sg=Vt&&w.size>0&&ws.some(x=>w.has(n(x)))&&!od,Va=s.useMemo(()=>{if(Jt)return r;const x=Object.entries(pt),H=Object.entries(Mt);return x.length===0&&H.length===0?r:r.filter(Q=>x.every(([B,de])=>{const he=e.find(Ee=>Ee.key===B);return he?de.includes(Jn(he,Q)):!0})&&H.every(([B,de])=>{const he=e.find(Ie=>Ie.key===B);if(!he)return!0;const Ee=r.map(Ie=>Jn(he,Ie));return Cu(Jn(he,Q),de,Ee)}))},[Mt,pt,e,r,Jt]),Ar=s.useMemo(()=>{if(!nt)return Va;const x=e.find(H=>H.key===nt.key&&H.sortKey);return x!=null&&x.sortKey?[...Va].sort((H,Q)=>{const B=H[x.sortKey],de=Q[x.sortKey],he=B===de?0:B==null?1:de==null||B<de?-1:1;return nt.dir==="asc"?he:-he}):Va},[Va,nt,e]),sd=s.useMemo(()=>{if(Jt||!gr)return Ar;const x=(Nt-1)*Rt;return Ar.slice(x,x+Rt)},[Ar,Jt,gr,Nt,Rt]),or=Jt?D??r.length:Ar.length,Cs=gr?Math.max(1,Math.ceil(or/Rt)):1,lg=Math.min(...ys),ig=gr&&(or>Rt||or>lg),cg=gr?(Nt-1)*Rt+1:1,dg=gr?Math.min(Nt*Rt,or):or;function Es(x){if(a)return;const H=Math.max(1,Math.min(x,Cs));Jt?O(H):Ha(H)}function ug(x){a||(ee&&(yt.current=ee),Pa(x),Jt?(ne(x),O(1)):(Ha(1),ne==null||ne(x)))}function ld(x){const H=new Set(ad);H.has(x)?H.delete(x):H.add(x);const Q=Array.from(H);j||me(Q),p==null||p(Q)}s.useEffect(()=>{De==null||De({bql:ze,filters:pt,conditionFilters:Mt,sort:nt,page:Nt,pageSize:Rt,hiddenColumnKeys:lt})},[ze,pt,Mt,nt,Nt,Rt,lt,De]);const id=x=>x==="center"?"justify-center text-center":x==="right"?"justify-end text-right":"justify-start text-left",fg="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Ms="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%)",Xe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Lr="color-mix(in srgb, var(--primary) 24%, var(--border))",Xa=`inset 0 0 0 1px ${Xe}`,cd=Pt.reduce((x,H)=>x+(Mr[H.key]??tr(H.width)),(on?40:0)+(Vt?40:0)),dd=typeof P=="number"?P:typeof P=="string"?Number(((md=P.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:md[1])??NaN):NaN,Bn=Number.isFinite(dd)?Math.max(cd,dd,Yc):Math.max(cd,Yc),Ya=P??Bn,sn=`${on?"40px ":""}${Vt?"40px ":""}${Pt.map(x=>`${Mr[x.key]??tr(x.width)}px`).join(" ")}`;s.useEffect(()=>{nt&<.includes(nt.key)&&Tr(null)},[lt,nt]);function ud(x){return x?typeof x=="string"?{key:x,label:x}:x:null}const Ga=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:sn,background:Ms,borderBottom:`1px solid ${Lr}`},children:[on&&t.jsx("div",{role:"columnheader",className:`${W?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Lr}`,borderRight:`1px solid ${Xe}`}}),Vt&&t.jsx("div",{role:"columnheader",className:`${W?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Ns?{position:"sticky",left:0,zIndex:12,background:Ms,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${Lr}`,borderRight:`1px solid ${Xe}`}:{borderBottom:`1px solid ${Lr}`,borderRight:`1px solid ${Xe}`},children:t.jsx(Xn,{size:"sm",checked:od,indeterminate:sg,onChange:E,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Pt.map((x,H)=>{const Q=(nt==null?void 0:nt.key)===x.key,B=!!x.sortKey,de=wr(x),he=Ua[x.key],Ee=he!==void 0,Ie=x.key===Ss,Ne=kl(x),We=rd===H,Ge=(Mr[x.key]??tr(x.width))<120,Ce=Object.prototype.hasOwnProperty.call(pt,x.key)||Object.prototype.hasOwnProperty.call(Mt,x.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":x.key,className:`group select-none ${Ge?"text-left":id(x.align)}`,style:{...Ee?{position:"sticky",left:he,zIndex:12,background:Ms,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Ie?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Lr}`:`inset 0 -1px 0 ${Lr}`,borderRight:`1px solid ${Xe}`}:{position:"relative",borderBottom:`1px solid ${Lr}`,borderRight:`1px solid ${Xe}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:We?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:de?W?"7px 6px":"9px 8px":W?"8px 6px 10px":"10px 8px 12px"},onDragOver:Be=>{(Ne||Hn.current!==null)&&tg(x.key,Be)},onDrop:Be=>rg(x.key,Be),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${de?"justify-center":Ge?"justify-start":x.align==="center"?"justify-center":x.align==="right"?"justify-end":"justify-start"}`,children:[Ne?t.jsx("span",{draggable:!0,onDragStart:Be=>{Be.stopPropagation(),eg(x.key,Be)},onDragEnd:Be=>{Be.stopPropagation(),ng()},onClick:Be=>Be.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 ${We?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,de?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(F.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(Sl,{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 ${W?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:x.header})})}),B&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(x.header)}`,title:"Ordenar",onClick:Be=>{Be.stopPropagation(),ag(x)},"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?nt.dir==="asc"?t.jsx(F.HiChevronUp,{className:"h-3 w-3"}):t.jsx(F.HiChevronDown,{className:"h-3 w-3"}):t.jsx(F.HiChevronUpDown,{className:"h-3 w-3"})}),z&&!de&&Ym(x)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":rt&&ht===x.key,"aria-label":`Filtrar ${String(x.header)}`,title:"Filtrar",onClick:Be=>td(Be,"filter",x.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 ${rt&&st==="filter"&&ht===x.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Ce?"text-[var(--primary)] opacity-100":""}`,children:Ce?t.jsx(F.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(F.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!de&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Be=>{Be.preventDefault(),Be.stopPropagation(),On.current={colKey:x.key,startX:Be.clientX,startWidth:Mr[x.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Be=>{Be.preventDefault(),Be.stopPropagation(),On.current=null,document.body.style.cursor="",document.body.style.userSelect="",Rm(x)},onClick:Be=>Be.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"}})]})})]},x.key)})]}),Ka=()=>{if(!rt||typeof document>"u"||st==="visibility"&&!ue||st==="filter"&&!z)return null;const x=e.find(Ce=>Ce.key===ht),H=Xm(),Q=x?Object.prototype.hasOwnProperty.call(pt,x.key):!1,B=x?Mt[x.key]:void 0,de=Kn.find(Ce=>Ce.value===(B==null?void 0:B.operator)),he=x?pt[x.key]??[]:[],Ee=Ft.trim().toLowerCase(),Ie=Ee?H.filter(Ce=>Ce.label.toLowerCase().includes(Ee)):H,Ne=x&&H.length>0&&(!Q||he.length===H.length),We=x&&Q&&he.length>0&&he.length<H.length,He=lt.length,Ge=()=>{x&&(_a(x.key),Qc(x.key))};return bt.createPortal(t.jsx("div",{ref:Uc,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Fm,borderColor:"var(--border)",background:"var(--bg-card)"},children:st==="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:He>0?`${Pt.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Jm,disabled:He===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:Kc.map(Ce=>{const Be=!lt.includes(Ce.key),Me=!(Ce.hideable!==!1)||Be&&Pt.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Be,disabled:Me,onClick:()=>Qm(Ce.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:Be?"var(--primary)":"var(--border)",background:Be?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Be&&t.jsx(F.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ce.header})]},Ce.key)})})]}):x?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 ",x.header]}),t.jsx("button",{type:"button",onClick:Ge,disabled:!Q&&!B,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"})]}),x.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:()=>Tr({key:x.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(F.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(nt==null?void 0:nt.key)===x.key&&nt.dir==="asc"&&t.jsx(F.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>Tr({key:x.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(F.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(nt==null?void 0:nt.key)===x.key&&nt.dir==="desc"&&t.jsx(F.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(yr,{value:(B==null?void 0:B.operator)??"",onChange:Ce=>{if(!Ce){Qc(x.key);return}za(x.key,{operator:Ce,value:(B==null?void 0:B.value)??"",valueTo:(B==null?void 0:B.valueTo)??""})},options:uu,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"}),(de==null?void 0:de.valueMode)!=="none"?t.jsx("input",{value:(B==null?void 0:B.value)??"",onChange:Ce=>{B&&za(x.key,{...B,value:Ce.target.value})},disabled:!B,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"})]}),(de==null?void 0:de.valueMode)==="between"&&t.jsx("input",{value:(B==null?void 0:B.valueTo)??"",onChange:Ce=>{B&&za(x.key,{...B,valueTo:Ce.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(F.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:Ft,onChange:Ce=>Ye(Ce.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":We?"mixed":!!Ne,onClick:()=>{x&&(Ne?gs(x.key,[]):_a(x.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:Ne||We?"var(--primary)":"var(--border)",background:Ne||We?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[We&&t.jsx(F.HiMinus,{className:"h-3 w-3"}),Ne&&!We&&t.jsx(F.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Ie.map(Ce=>{const Be=!Q||he.includes(Ce.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Be,onClick:()=>Gm(x.key,Ce.value,H.map(Ae=>Ae.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:Be?"var(--primary)":"var(--border)",background:Be?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Be&&t.jsx(F.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ce.label})]},Ce.value)}),Ie.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(!Dn)return;function x(H){bs.current&&!bs.current.contains(H.target)&&Oa.current&&!Oa.current.contains(H.target)&&Fa(!1)}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[Dn]);function fd(x,H){if(x.filterValue){const Q=x.filterValue(H);return Q==null||Q===""?"":Yn(Q)}return Yn(Or(x.cell(H)))}function bd(x){return`"${Yn(x).replace(/"/g,'""')}"`}function Za(x){return Yn(x).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function hd(){return Jt&&or>Ar.length&&eo.toast.warning(`Exportando ${Ar.length.toLocaleString("es-MX")} de ${or.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),Ar}function bg(){const x=Pt.filter(Ne=>!wr(Ne)),H=hd(),Q=x.map(Ne=>bd(Or(Ne.header))).join(","),B=H.map(Ne=>x.map(We=>bd(fd(We,Ne))).join(",")).join(`
|
|
5
|
+
`),de=`${Q}
|
|
6
|
+
${B}`,he=new Blob(["\uFEFF"+de],{type:"text/csv;charset=utf-8;"}),Ee=URL.createObjectURL(he),Ie=document.createElement("a");Ie.href=Ee,Ie.download=`${xe}.csv`,document.body.appendChild(Ie),Ie.click(),document.body.removeChild(Ie),URL.revokeObjectURL(Ee)}function hg(){const x=Pt.filter(Ie=>!wr(Ie)),H=hd(),Q=x.map(Ie=>Za(Or(Ie.header))),de=H.map(Ie=>x.map(Ne=>Za(fd(Ne,Ie)))).map(Ie=>`<tr>${Ie.map(Ne=>`<td>${Ne}</td>`).join("")}</tr>`).join(""),he=`<!DOCTYPE html>
|
|
7
|
+
<html lang="es"><head><meta charset="utf-8"><title>${Za(xe)}</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,39 +15,39 @@ ${B}`,he=new Blob(["\uFEFF"+de],{type:"text/csv;charset=utf-8;"}),Ee=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>${
|
|
19
|
-
<p>${
|
|
20
|
-
<table><thead><tr>${
|
|
18
|
+
<h3>${Za(xe)}</h3>
|
|
19
|
+
<p>${H.length} registros · ${new Date().toLocaleDateString("es")}</p>
|
|
20
|
+
<table><thead><tr>${Q.map(Ie=>`<th>${Ie}</th>`).join("")}</tr></thead>
|
|
21
21
|
<tbody>${de}</tbody></table>
|
|
22
22
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
23
|
-
</body></html>`,Ee=window.open("","_blank");Ee&&(Ee.document.write(he),Ee.document.close())}const
|
|
24
|
-
`).map(Ee=>Ee.trim()).filter(Boolean)).has(de):!1}).slice(0,8);return!ue&&ls===0&&!T&&!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:[ls>0&&t.jsxs("button",{type:"button",onClick:Rp,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(H.HiXMark,{className:"h-3.5 w-3.5"}),ls," filtros"]}),T&&t.jsxs("div",{ref:ns,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ve){pt(!1);return}Ia(),pt(!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:Ve?"var(--primary)":x?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ve||x?"var(--primary)":"var(--border)",color:Ve?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ve,title:"Abrir filtros BQL",children:[t.jsx(H.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",x&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ve?t.jsx(H.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(H.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:G}),O.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[O.slice(0,3).map(B=>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:[B.label,":"]}),t.jsx("span",{className:"truncate",children:B.value})]},B.key)),O.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",O.length-3]})]}),x&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:pc,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(H.HiXMark,{className:"h-4 w-4"})}),Ve&&ft.createPortal(t.jsxs("div",{ref:ac,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Bp,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:[le.map(B=>t.jsxs("button",{type:"button",onMouseDown:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Oa(B.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:[B.icon,B.label]},B.label)),be.length>0&&t.jsxs("button",{type:"button",onClick:()=>mt(B=>!B),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":dt,children:[t.jsx(H.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Ot.length>0&&t.jsxs("button",{type:"button",onClick:()=>qt(B=>!B),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(H.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 ${$e?"var(--danger)":x?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:as,value:Te,rows:3,onChange:B=>ds(B.target.value,B.target),onKeyDown:B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),hc(Te)),B.key==="Escape"&&pt(!1)},placeholder:D,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),Z.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:Z.map(B=>t.jsx("button",{type:"button",onMouseDown:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Oa(B)},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:B},B))})]}),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:$e?"var(--danger)":"var(--text-muted)"},children:$e??(x?`${O.length||1} filtro${(O.length||1)===1?"":"s"} activo${(O.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),O.map(B=>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:[B.label,":"]}),t.jsx("span",{className:"truncate",children:B.value})]},B.key))]}),rr&&Ot.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(H.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{nr([]),qt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(H.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Ot.map(B=>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:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Oa(B)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:B})}),t.jsx("button",{type:"button",onClick:()=>nr(de=>de.filter(he=>he!==B)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(H.HiXMark,{className:"h-3.5 w-3.5"})})]},B))]}),dt&&be.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:be.map(B=>t.jsxs("button",{type:"button",onMouseDown:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Oa(B.bql),mt(!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:B.bql}),B.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:B.description})]},B.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[x&&t.jsxs("button",{type:"button",onClick:pc,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(H.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>hc(Te),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(H.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),re&&t.jsx("button",{ref:Ta,type:"button","aria-haspopup":"menu","aria-expanded":Ln,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var de;const B=(de=Ta.current)==null?void 0:de.getBoundingClientRect();B&&Wp({top:B.bottom+4,right:window.innerWidth-B.right}),Ma(he=>!he)},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)] ${Ln?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(H.HiArrowDownTray,{className:"h-4 w-4"})}),ue&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":tt&&ot==="visibility","aria-label":U,title:U,onClick:B=>gc(B,"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)] ${tt&&ot==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(H.HiCog6Tooth,{className:"h-4 w-4"})})]})},$c=()=>{if(!fm)return null;const x=Md(wt,gs);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 ${z?"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:ar===0?"0 filas":`${bm}–${hm} de ${ar}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(vr,{value:String(Jt),onChange:O=>pm(Number(O)),options:fs.map(O=>({value:String(O),label:String(O)})),placeholder:"Filas",searchable:!1,disabled:a,height:q,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||wt<=1,onClick:()=>vs(wt-1),onMouseEnter:O=>{O.currentTarget.disabled||(O.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",O.currentTarget.style.color="var(--primary)")},onMouseLeave:O=>{O.currentTarget.style.background="transparent",O.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(H.HiChevronLeft,{className:"h-3.5 w-3.5"})}),x.map((O,Z)=>O==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Z}`):t.jsx("button",{disabled:a,onClick:()=>vs(O),onMouseEnter:B=>{B.currentTarget.disabled||O===wt||(B.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",B.currentTarget.style.color="var(--primary)")},onMouseLeave:B=>{B.currentTarget.style.background=O===wt?"var(--primary)":"transparent",B.currentTarget.style.color=O===wt?"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:O===wt?"var(--primary)":"transparent",color:O===wt?"var(--primary-fg)":"var(--text-muted)"},children:O},O)),t.jsx("button",{disabled:a||wt>=gs,onClick:()=>vs(wt+1),onMouseEnter:O=>{O.currentTarget.disabled||(O.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",O.currentTarget.style.color="var(--primary)")},onMouseLeave:O=>{O.currentTarget.style.background="transparent",O.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(H.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},xm=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:_a},children:[ja(),Ua(),Va(),t.jsx("div",{ref:Bt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:On,minWidth:za},children:[t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((x,O)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:an,borderBottom:`1px solid ${Xe}`},children:[Ut&&t.jsx("div",{role:"cell",className:`${z?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`}},"select-cell"),Ft.map((Z,B)=>t.jsx("div",{role:"cell",className:z?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ic(O,B)}%`,minWidth:32}})},Z.key))]},O))})]})})]}),ys="min-w-0 max-w-full overflow-hidden";return J&&Oe&&!et?t.jsx(Pn,{rows:o,columns:Math.max(4,Ft.length||7)}):!a&&r.length===0&&!ss?xm():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:_a},children:[ja(),Ua(),Va(),t.jsx("div",{ref:Bt,className:ys,children:t.jsx(ws.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:dc,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:On,minWidth:za},children:[t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Wa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((x,O)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:an,borderBottom:`1px solid ${Xe}`},children:[Ut&&t.jsx("div",{role:"cell",className:`${z?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`}},"select-cell"),Ft.map((Z,B)=>{const de=Fa[Z.key],he=de!==void 0,Ee=Z.key===ms;return t.jsx("div",{role:"cell","data-dt-column-key":Z.key,className:z?"px-2 py-1.5":"px-3 py-2",style:he?{position:"sticky",left:de,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ee?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Xe}`:`inset 0 -1px 0 ${Xe}`,borderRight:`1px solid ${Xe}`}:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ic(O,B)}%`,minWidth:32}})},Z.key)})]},O))})]})})}),$c()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:_a},children:[ja(),Ua(),Va(),t.jsx("div",{ref:Bt,className:ys,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:On,minWidth:za},children:t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Wa()})})}),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:Xe,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(H.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:_a},children:[ja(),Ua(),Va(),t.jsx("div",{ref:Bt,className:ys,children:t.jsx(ws.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:dc,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:On,minWidth:za},children:[t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Wa()}),t.jsx("div",{role:"rowgroup",children:Nc.map((x,O)=>{const Z=n(x),B=Mc(C==null?void 0:C(x)),de=O>0?Mc(C==null?void 0:C(Nc[O-1])):null,he=B&&B.key!==(de==null?void 0:de.key),Ee=Ut&&w.has(Z),He=Ut&&(!y||y(x)),Ne=nn?(h==null?void 0:h(x))??!0:!1,ze=Ne&&yc.has(Z),Be=!!f||v&&Ne,Ge=Ee&&M?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":O%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[he&&t.jsx("div",{role:"row",className:`grid ${B.className??""}`,style:{gridTemplateColumns:an},children:t.jsx("div",{role:"cell",className:z?"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 ${Xe}`,borderRight:`1px solid ${Xe}`},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:B.label}),B.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:B.description})]})})})}),t.jsxs("div",{role:"row",onClick:Be?Ce=>{const Fe=Ce.target;if(!(Fe!=null&&Fe.closest('[data-dt-disable-row-click="true"]'))){if(v&&Ne){kc(Z);return}f==null||f(x)}}:void 0,className:`grid transition-colors ${Be?"cursor-pointer":""} ${L?L(x):""}`,style:{gridTemplateColumns:an,"--dt-row-bg":Ge,"--dt-sticky-bg":Ge,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Xe}`},onMouseEnter:Ce=>{Ee||(Ce.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),Ce.currentTarget.style.setProperty("--dt-sticky-bg",mm))},onMouseLeave:Ce=>{Ce.currentTarget.style.setProperty("--dt-row-bg",Ge),Ce.currentTarget.style.setProperty("--dt-sticky-bg",Ge)},children:[nn&&t.jsx("div",{role:"cell",className:`${z?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},"data-dt-disable-row-click":"true",children:Ne&&t.jsx("button",{type:"button","aria-label":ze?"Contraer fila":"Desplegar fila","aria-expanded":ze,onClick:Ce=>{Ce.stopPropagation(),kc(Z)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:ze?t.jsx(H.HiChevronDown,{className:"h-4 w-4"}):t.jsx(H.HiChevronRight,{className:"h-4 w-4"})})}),Ut&&t.jsx("div",{role:"cell",className:`${z?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:hs?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Xe}`}:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},onClick:Ce=>{Ce.stopPropagation(),He&&g(Z)},children:t.jsx(_n,{size:"sm",checked:Ee,disabled:!He,"aria-label":He?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:He?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:Ce=>Ce.stopPropagation(),onChange:()=>{He&&g(Z)}})}),Ft.map(Ce=>{const Fe=Fa[Ce.key],Le=Fe!==void 0,Me=Ce.key===ms,Ae=xr(Ce);return t.jsx("div",{role:"cell","data-dt-column-key":Ce.key,"data-dt-disable-row-click":Ce.disableRowClick||Ae?"true":void 0,className:`${Ae?"px-2 py-1.5 justify-center text-center":`${z?"px-2 py-1.5":"px-3 py-2"} ${Sc(Ce.align)}`} flex min-w-0 items-center ${xd} ${Ce.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Le?{position:"sticky",left:Fe,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:Me?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Xe}`:`inset 0 -1px 0 ${Xe}`,borderRight:`1px solid ${Xe}`}:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`}},children:t.jsx(zs,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:Ce.cell(x)})})},Ce.key)})]}),ze&&d&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:an},children:t.jsx("div",{role:"cell",className:z?"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 ${Xe}`},children:d(x)})})]},Z)})})]})})}),$c()]})}const Ad={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Xn({title:e="Sin resultados",description:r,icon:n=t.jsx(H.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:o,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Ad[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||o)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}function Xt(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 Ws(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 Ir(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function lr(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function js(e){const r=Ir(e),n=(r.getDay()+6)%7;return lr(r,-n)}function ao(e){const r=js(e);return Array.from({length:7},(n,a)=>lr(r,a))}function qs(e){const r=e.getDay();return r===0||r===6}function Yn(e){return e.filter(r=>!qs(r))}function Us(e){return Yn(ao(e))}function $d(e){const r=Ir(e),n=r.getDay();return n===6?lr(r,-1):n===0?lr(r,-2):r}function oo(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=js(r);return Array.from({length:42},(a,o)=>lr(n,o))}function so(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Vs(e){return so(e).map(Yn)}function Dd(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function ir(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=Ws(n.start);if(!a)return null;const o=Ws(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function Xs(e,r){const n={};for(const a of e){const o=ir(a,r);if(!o)continue;let l=Ir(o.start);const i=Ir(o.end);for(;l.getTime()<=i.getTime();){const c=Xt(l);n[c]||(n[c]=[]),n[c].push(a),l=lr(l,1)}}return n}function lo(e,r,n){if(r.length===0)return[];const a=Ir(r[0]),o=Ir(r[r.length-1]),l=[],i=[],c=[...e].sort((f,d)=>{const h=ir(f,n),b=ir(d,n),u=(h==null?void 0:h.start.getTime())??0,p=(b==null?void 0:b.start.getTime())??0;return u-p||f.title.localeCompare(d.title)});for(const f of c){const d=ir(f,n);if(!d||!Dd(d.start,d.end,a,o))continue;const h=d.start.getTime()<a.getTime()?a:d.start,b=d.end.getTime()>o.getTime()?o:d.end,u=Math.max(0,Math.round((h.getTime()-a.getTime())/864e5)),p=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),v=Math.max(1,p-u+1);let w=l.findIndex(g=>g<u);w<0?(w=l.length,l.push(u+v-1)):l[w]=u+v-1,i.push({item:f,lane:w,colStart:u,colSpan:v})}return i}function _t(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Hd(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Od(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 Ys(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 Gs(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?lr(e,n*7):lr(e,n)}const Id=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],Ks=["Lun","Mar","Mié","Jue","Vie"];function Bd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=ir(e),i=l?`${_t(l.start)} → ${_t(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Vt,{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:f=>{f.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 Fd({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=ir(e),l=o?`${_t(o.start)} → ${_t(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 Pd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=ir(e),i=l?`${_t(l.start)} → ${_t(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 Zs({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function Qs({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 _d({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:f=3,overloadThreshold:d=5,weekdayLabels:h,hideWeekends:b=!1,renderToolbarExtra:u,renderPill:p,renderDayCard:v,renderWeekBar:w,tableColumns:g,tableProps:E,onItemClick:y,onDayClick:M,loading:L=!1,emptyTitle:C="Sin eventos",emptyDescription:m="No hay eventos para los filtros seleccionados.",legend:k,legendInteractive:N=!0,activeLegendKeys:_,defaultActiveLegendKeys:q,onActiveLegendKeysChange:K,getItemLegendKey:$,overloadLabel:Q="Sobrecarga de eventos",notice:X,showOverload:se=!0,layout:J="span",className:fe="",showToolbar:te=!0}){const z=h??(b?[...Ks]:[...Id]),R=b?5:7,A=b?"grid grid-cols-5":"grid grid-cols-7",F=s.useMemo(()=>(k??[]).map(ae=>ae.label),[k]),[ue,P]=s.useState(()=>q??F),oe=s.useMemo(()=>_??(F.length>0?ue:[]),[_,F.length,ue]),j=s.useMemo(()=>new Set(oe),[oe]),S=ae=>{_===void 0&&P(ae),K==null||K(ae)},U=ae=>{N&&(j.has(ae)?S(oe.filter(we=>we!==ae)):S([...oe,ae]))},T=s.useMemo(()=>{if(!N||F.length===0)return e;const ae=new Set(F);return e.filter(we=>{const ne=($==null?void 0:$(we))??we.status;return!ne||!ae.has(ne)?!0:j.has(ne)})},[e,N,F,j,$]),Y=s.useMemo(()=>Xs(T,c),[T,c]),ce=s.useMemo(()=>{const ae=oo(r);return b?Yn(ae):ae},[r,b]),V=s.useMemo(()=>{const ae=oo(r);return b?Vs(ae):so(ae)},[r,b]),G=s.useMemo(()=>b?Us(r):ao(r),[r,b]),D=Xt(r),le=Y[D]??[],be=s.useMemo(()=>lo(T,G,c),[T,G,c]),ie=s.useMemo(()=>be.length===0?1:Math.max(...be.map(ae=>ae.lane))+1,[be]),ge=s.useMemo(()=>V.map(ae=>{const we=lo(T,ae,c),ne=we.length===0?0:Math.max(...we.map(Oe=>Oe.lane))+1;return{days:ae,bars:we,laneCount:ne}}),[V,T,c]),$e=36,De=38,Nt=s.useMemo(()=>{const ae=l==="month"?ce:l==="week"?G:[r],we=[];for(const ne of ae){const Oe=Xt(ne),qe=Y[Oe]??[];qe.length>=d&&we.push([ne,qe])}return we},[l,ce,G,r,Y,d]),yt=l==="month"?Hd(r):l==="week"?`${_t(G[0])} – ${_t(G[6])}`:Od(r),re=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 we=ir(ae,c);return we?`${_t(we.start)} → ${_t(we.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ae=>ae.subtitle??"—"}],[c]),xe=ae=>{if(n(ae),M){M(ae);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${fe}`.trim(),children:[te?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(Gs(r,l,-1)),children:t.jsx(H.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:yt}),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(Gs(r,l,1)),children:t.jsx(H.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:[u,t.jsx(Qs,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(H.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(H.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(Qs,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,k&&k.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:N?"group":void 0,"aria-label":N?"Filtrar por estado":void 0,children:k.map(ae=>{const we=j.has(ae.label);return N?t.jsxs("button",{type:"button","aria-pressed":we,onClick:()=>U(ae.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:we?"var(--text-main)":"var(--text-muted)",background:we?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:we?`1px solid color-mix(in srgb, ${ae.color} 55%, var(--border))`:"1px solid var(--border)",opacity:we?1:.45},title:we?`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:we?`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"&&X&&X.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:X.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[X.label,":"]})," ",X.items.join(", ")]}):a==="calendar"&&se&&Nt.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:[Q,":"]})," ",Nt.map(([ae,we])=>`${_t(ae)} (${we.length})`).join(", ")]}):null,a==="table"?L||T.length>0?t.jsx(no,{columns:g??re,data:T,getRowId:ae=>ae.id,loading:L,skeletonRows:8,emptyIcon:t.jsx(H.HiCalendarDays,{className:"h-10 w-10"}),emptyText:m,onRowClick:y,pageSize:25,compact:!0,...E}):t.jsx(Xn,{icon:t.jsx(H.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:m}):null,a==="calendar"&&l==="month"&&J==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:A,style:{borderBottom:"1px solid var(--border)"},children:z.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))}),t.jsx("div",{className:A,children:ce.map(ae=>{const we=Xt(ae),ne=Y[we]??[],Oe=ae.getMonth()!==r.getMonth(),qe=Math.max(0,ne.length-f);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${ae.getDate()}`,onClick:()=>xe(ae),onKeyDown:Qe=>{(Qe.key==="Enter"||Qe.key===" ")&&(Qe.preventDefault(),xe(ae))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Oe?"var(--text-muted)":"var(--text-main)"},children:ae.getDate()}),ne.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ne.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[ne.slice(0,f).map(Qe=>t.jsx(Zs,{item:Qe,day:ae,renderPill:p,onClick:()=>y==null?void 0:y(Qe)},Qe.id)),qe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",qe," más"]}):null]})]},we)})})]}):null,a==="calendar"&&l==="month"&&J==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:A,style:{borderBottom:"1px solid var(--border)"},children:z.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))}),ge.map(({days:ae,bars:we,laneCount:ne},Oe)=>{const qe=Math.min(ne,f),Qe=Math.max(0,ne-f),Ze=$e+Math.max(1,qe)*De+(Qe>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:Ze,borderBottom:Oe<ge.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:A,style:{minHeight:Ze},children:ae.map(Ue=>{const et=Xt(Ue),St=Y[et]??[],vt=Ue.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Ue.getDate()}`,onClick:()=>xe(Ue),onKeyDown:Ct=>{(Ct.key==="Enter"||Ct.key===" ")&&(Ct.preventDefault(),xe(Ue))},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:Ze},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:vt?"var(--text-muted)":"var(--text-main)"},children:Ue.getDate()}),St.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:St.length}):null]})},et)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:$e,bottom:4},children:[we.filter(Ue=>Ue.lane<f).map(Ue=>{const et={left:`calc(${Ue.colStart/R*100}% + 4px)`,width:`calc(${Ue.colSpan/R*100}% - 8px)`,top:2+Ue.lane*De,height:De-6,pointerEvents:"auto"};return p?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(Ue.item,{day:ae[Ue.colStart]})})},`${Ue.item.id}-${Ue.colStart}-${Oe}`):w?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(Ue.item)})},`${Ue.item.id}-${Ue.colStart}-${Oe}`):t.jsx(Bd,{item:Ue.item,style:et,onClick:()=>y==null?void 0:y(Ue.item)},`${Ue.item.id}-${Ue.colStart}-${Oe}`)}),Qe>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+qe*De,color:"var(--text-muted)"},children:["+",Qe," más"]}):null]})]},`week-${Oe}-${Xt(ae[0])}`)})]}):null,a==="calendar"&&l==="week"&&J==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:A,children:G.map(ae=>{const we=Xt(ae),ne=Y[we]??[],Oe=Math.max(0,ne.length-f);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>xe(ae),children:[Ys(ae),t.jsx("span",{className:"mt-1 block text-sm",children:ae.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[ne.slice(0,f).map(qe=>t.jsx(Zs,{item:qe,day:ae,renderPill:p,onClick:()=>y==null?void 0:y(qe)},qe.id)),Oe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Oe," más"]}):null]})]},we)})})}):null,a==="calendar"&&l==="week"&&J==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${A} border-b`,style:{borderColor:"var(--border)"},children:G.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:()=>xe(ae),children:Ys(ae)},Xt(ae)))}),t.jsxs("div",{className:`relative ${A}`,style:{minHeight:Math.max(220,ie*56+24)},children:[G.map(ae=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Xt(ae)}`)),be.map(ae=>{const we={left:`calc(${ae.colStart/R*100}% + 4px)`,width:`calc(${ae.colSpan/R*100}% - 8px)`,top:12+ae.lane*56,height:48};return w?t.jsx("div",{className:"absolute overflow-hidden",style:we,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(ae.item)})},`${ae.item.id}-${ae.colStart}`):t.jsx(Pd,{item:ae.item,style:we,onClick:()=>y==null?void 0:y(ae.item)},`${ae.item.id}-${ae.colStart}`)}),be.length===0&&!L?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:m}):null]})]}):null,a==="calendar"&&l==="day"?le.length>0||L?t.jsxs("div",{className:"space-y-3",children:[L&&le.length===0?t.jsx(Xn,{icon:t.jsx(H.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,le.map(ae=>v?t.jsx("div",{children:v(ae)},ae.id):t.jsx(Fd,{item:ae,onClick:()=>y==null?void 0:y(ae)},ae.id))]}):t.jsx(Xn,{icon:t.jsx(H.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:m}):null]})}function zd(e){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select(),r.setSelectionRange(0,e.length);const n=document.execCommand("copy");if(document.body.removeChild(r),!n)throw new Error("execCommand_copy_failed")}async function io(e){var n;const r=String(e??"");if(!r.trim())throw new Error("empty_clipboard_text");try{if(typeof window<"u"&&window.focus(),(n=navigator.clipboard)!=null&&n.writeText){await navigator.clipboard.writeText(r);return}}catch{}zd(r)}function Wd(e){return typeof e=="function"?e():e}function co({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(H.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(H.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:f,onCopyError:d,className:h="",style:b,children:u,onClick:p,type:v="button",...w}){const[g,E]=s.useState(!1),y=s.useRef(null);s.useEffect(()=>()=>{y.current&&window.clearTimeout(y.current)},[]);function M(C){E(!0),f==null||f(C),y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{E(!1),y.current=null},r)}async function L(C){if(c&&C.stopPropagation(),p==null||p(C),C.defaultPrevented)return;const m=Wd(e);if(m)try{await io(m),M(m)}catch(k){d==null||d(k,m)}}return t.jsxs("button",{...w,type:v,onClick:L,title:g?a:n,"aria-label":w["aria-label"]??(g?a:n),"data-copied":g?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${u?"min-w-7 px-2":"w-7"} ${h}`,style:{cursor:"pointer",background:g?"rgba(22,163,74,0.15)":"var(--bg-card)",border:g?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:g?"#16a34a":"var(--text-secondary)",boxShadow:g?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:g?"scale(1.15)":"scale(1)"},children:g?i:l}),u&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:g?o??u:u})]})}const jd=new Set(["as","async","await","break","case","catch","class","const","continue","declare","default","else","enum","export","extends","false","finally","for","from","function","if","implements","import","in","interface","keyof","let","new","null","of","private","protected","public","readonly","return","satisfies","super","switch","this","throw","true","try","type","typeof","undefined","var","void","while"]),qd=new Set(["","text","txt","plain","prompt"]);function Js(e){const r=(e??"txt").toLowerCase();return r==="typescript"?"ts":r==="javascript"?"js":r==="text"||r==="plain"||r==="prompt"?"txt":r||"txt"}function Rs(e){return!qd.has((e??"").toLowerCase())}function Ud(e,r){const n=(r??"").toLowerCase();if(!Rs(n))return e.split(`
|
|
23
|
+
</body></html>`,Ee=window.open("","_blank");Ee&&(Ee.document.write(he),Ee.document.close())}const Qa=()=>!re||!Dn?null:bt.createPortal(t.jsxs("div",{ref:bs,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Hm,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()=>(oe?await oe():bg(),Fa(!1)))()},children:[t.jsx(F.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()=>(we?await we():hg(),Fa(!1)))()},children:[t.jsx(F.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Ja=()=>{const x=M&&ze.trim().length>0,H=ge!=null&&ge.length?ge:x?[{key:"bql",label:"BQL",value:ze}]:[],Q=ie.filter(B=>{const de=B.trim();return de?!new Set(Te.split(`
|
|
24
|
+
`).map(Ee=>Ee.trim()).filter(Boolean)).has(de):!1}).slice(0,8);return!ue&&ps===0&&!M&&!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:[ps>0&&t.jsxs("button",{type:"button",onClick:Km,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(F.HiXMark,{className:"h-3.5 w-3.5"}),ps," filtros"]}),M&&t.jsxs("div",{ref:us,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ve){mt(!1);return}ja(),mt(!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:Ve?"var(--primary)":x?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ve||x?"var(--primary)":"var(--border)",color:Ve?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ve,title:"Abrir filtros BQL",children:[t.jsx(F.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",x&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ve?t.jsx(F.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(F.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:G}),H.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[H.slice(0,3).map(B=>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:[B.label,":"]}),t.jsx("span",{className:"truncate",children:B.value})]},B.key)),H.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",H.length-3]})]}),x&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Rc,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(F.HiXMark,{className:"h-4 w-4"})}),Ve&&bt.createPortal(t.jsxs("div",{ref:jc,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Dm,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:[le.map(B=>t.jsxs("button",{type:"button",onMouseDown:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Wa(B.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:[B.icon,B.label]},B.label)),be.length>0&&t.jsxs("button",{type:"button",onClick:()=>gt(B=>!B),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":ut,children:[t.jsx(F.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Ot.length>0&&t.jsxs("button",{type:"button",onClick:()=>Ut(B=>!B),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":nr,children:[t.jsx(F.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 ${$e?"var(--danger)":x?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:fs,value:Te,rows:3,onChange:B=>vs(B.target.value,B.target),onKeyDown:B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),Jc(Te)),B.key==="Escape"&&mt(!1)},placeholder:I,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(B=>t.jsx("button",{type:"button",onMouseDown:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Wa(B)},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:B},B))})]}),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:$e?"var(--danger)":"var(--text-muted)"},children:$e??(x?`${H.length||1} filtro${(H.length||1)===1?"":"s"} activo${(H.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),H.map(B=>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:[B.label,":"]}),t.jsx("span",{className:"truncate",children:B.value})]},B.key))]}),nr&&Ot.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(F.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{ar([]),Ut(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(F.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Ot.map(B=>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:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Wa(B)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:B})}),t.jsx("button",{type:"button",onClick:()=>ar(de=>de.filter(he=>he!==B)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(F.HiXMark,{className:"h-3.5 w-3.5"})})]},B))]}),ut&&be.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:be.map(B=>t.jsxs("button",{type:"button",onMouseDown:de=>{de.preventDefault(),de.stopPropagation()},onClick:de=>{de.preventDefault(),de.stopPropagation(),Wa(B.bql),gt(!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:B.bql}),B.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:B.description})]},B.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[x&&t.jsxs("button",{type:"button",onClick:Rc,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(F.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Jc(Te),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(F.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),re&&t.jsx("button",{ref:Oa,type:"button","aria-haspopup":"menu","aria-expanded":Dn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var de;const B=(de=Oa.current)==null?void 0:de.getBoundingClientRect();B&&Bm({top:B.bottom+4,right:window.innerWidth-B.right}),Fa(he=>!he)},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)] ${Dn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(F.HiArrowDownTray,{className:"h-4 w-4"})}),ue&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":rt&&st==="visibility","aria-label":V,title:V,onClick:B=>td(B,"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)] ${rt&&st==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(F.HiCog6Tooth,{className:"h-4 w-4"})})]})},pd=()=>{if(!ig)return null;const x=ku(Nt,Cs);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 ${W?"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:or===0?"0 filas":`${cg}–${dg} de ${or}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(yr,{value:String(Rt),onChange:H=>ug(Number(H)),options:ys.map(H=>({value:String(H),label:String(H)})),placeholder:"Filas",searchable:!1,disabled:a,height:U,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||Nt<=1,onClick:()=>Es(Nt-1),onMouseEnter:H=>{H.currentTarget.disabled||(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="transparent",H.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(F.HiChevronLeft,{className:"h-3.5 w-3.5"})}),x.map((H,Q)=>H==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>Es(H),onMouseEnter:B=>{B.currentTarget.disabled||H===Nt||(B.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",B.currentTarget.style.color="var(--primary)")},onMouseLeave:B=>{B.currentTarget.style.background=H===Nt?"var(--primary)":"transparent",B.currentTarget.style.color=H===Nt?"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:H===Nt?"var(--primary)":"transparent",color:H===Nt?"var(--primary-fg)":"var(--text-muted)"},children:H},H)),t.jsx("button",{disabled:a||Nt>=Cs,onClick:()=>Es(Nt+1),onMouseEnter:H=>{H.currentTarget.disabled||(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="transparent",H.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(F.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},pg=()=>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(),Qa(),Ja(),t.jsx("div",{ref:Bt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Bn,minWidth:Ya},children:[t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ga()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((x,H)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:sn,borderBottom:`1px solid ${Xe}`},children:[Vt&&t.jsx("div",{role:"cell",className:`${W?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`}},"select-cell"),Pt.map((Q,B)=>t.jsx("div",{role:"cell",className:W?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Xc(H,B)}%`,minWidth:32}})},Q.key))]},H))})]})})]}),Ts="min-w-0 max-w-full overflow-hidden";return ee&&Fe&&!tt?t.jsx(Wn,{rows:o,columns:Math.max(4,Pt.length||7)}):!a&&r.length===0&&!hs?pg():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(),Qa(),Ja(),t.jsx("div",{ref:Bt,className:Ts,children:t.jsx(As.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Gc,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Bn,minWidth:Ya},children:[t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ga()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((x,H)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:sn,borderBottom:`1px solid ${Xe}`},children:[Vt&&t.jsx("div",{role:"cell",className:`${W?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`}},"select-cell"),Pt.map((Q,B)=>{const de=Ua[Q.key],he=de!==void 0,Ee=Q.key===Ss;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:W?"px-2 py-1.5":"px-3 py-2",style:he?{position:"sticky",left:de,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ee?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Xe}`:`inset 0 -1px 0 ${Xe}`,borderRight:`1px solid ${Xe}`}:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Xc(H,B)}%`,minWidth:32}})},Q.key)})]},H))})]})})}),pd()]}):!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(),Qa(),Ja(),t.jsx("div",{ref:Bt,className:Ts,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Bn,minWidth:Ya},children:t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ga()})})}),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:Xe,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(F.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(),Qa(),Ja(),t.jsx("div",{ref:Bt,className:Ts,children:t.jsx(As.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Gc,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Bn,minWidth:Ya},children:[t.jsx("div",{role:"rowgroup",style:m?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ga()}),t.jsx("div",{role:"rowgroup",children:sd.map((x,H)=>{const Q=n(x),B=ud(C==null?void 0:C(x)),de=H>0?ud(C==null?void 0:C(sd[H-1])):null,he=B&&B.key!==(de==null?void 0:de.key),Ee=Vt&&w.has(Q),Ie=Vt&&(!y||y(x)),Ne=on?(h==null?void 0:h(x))??!0:!1,We=Ne&&ad.has(Q),He=!!f||g&&Ne,Ge=Ee&&T?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":H%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[he&&t.jsx("div",{role:"row",className:`grid ${B.className??""}`,style:{gridTemplateColumns:sn},children:t.jsx("div",{role:"cell",className:W?"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 ${Xe}`,borderRight:`1px solid ${Xe}`},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:B.label}),B.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:B.description})]})})})}),t.jsxs("div",{role:"row",onClick:He?Ce=>{const Be=Ce.target;if(!(Be!=null&&Be.closest('[data-dt-disable-row-click="true"]'))){if(g&&Ne){ld(Q);return}f==null||f(x)}}:void 0,className:`grid transition-colors ${He?"cursor-pointer":""} ${L?L(x):""}`,style:{gridTemplateColumns:sn,"--dt-row-bg":Ge,"--dt-sticky-bg":Ge,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Xe}`},onMouseEnter:Ce=>{Ee||(Ce.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),Ce.currentTarget.style.setProperty("--dt-sticky-bg",fg))},onMouseLeave:Ce=>{Ce.currentTarget.style.setProperty("--dt-row-bg",Ge),Ce.currentTarget.style.setProperty("--dt-sticky-bg",Ge)},children:[on&&t.jsx("div",{role:"cell",className:`${W?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},"data-dt-disable-row-click":"true",children:Ne&&t.jsx("button",{type:"button","aria-label":We?"Contraer fila":"Desplegar fila","aria-expanded":We,onClick:Ce=>{Ce.stopPropagation(),ld(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:We?t.jsx(F.HiChevronDown,{className:"h-4 w-4"}):t.jsx(F.HiChevronRight,{className:"h-4 w-4"})})}),Vt&&t.jsx("div",{role:"cell",className:`${W?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Ns?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Xe}`}:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`},onClick:Ce=>{Ce.stopPropagation(),Ie&&v(Q)},children:t.jsx(Xn,{size:"sm",checked:Ee,disabled:!Ie,"aria-label":Ie?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Ie?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:Ce=>Ce.stopPropagation(),onChange:()=>{Ie&&v(Q)}})}),Pt.map(Ce=>{const Be=Ua[Ce.key],Ae=Be!==void 0,Me=Ce.key===Ss,Le=wr(Ce);return t.jsx("div",{role:"cell","data-dt-column-key":Ce.key,"data-dt-disable-row-click":Ce.disableRowClick||Le?"true":void 0,className:`${Le?"px-2 py-1.5 justify-center text-center":`${W?"px-2 py-1.5":"px-3 py-2"} ${id(Ce.align)}`} flex min-w-0 items-center ${pu} ${Ce.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ae?{position:"sticky",left:Be,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:Me?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Xe}`:`inset 0 -1px 0 ${Xe}`,borderRight:`1px solid ${Xe}`}:{borderBottom:`1px solid ${Xe}`,borderRight:`1px solid ${Xe}`}},children:t.jsx(Sl,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:Ce.cell(x)})})},Ce.key)})]}),We&&d&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:sn},children:t.jsx("div",{role:"cell",className:W?"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 ${Xe}`},children:d(x)})})]},Q)})})]})})}),pd()]})}const Eu={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Rn({title:e="Sin resultados",description:r,icon:n=t.jsx(F.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 ${Eu[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 Yt(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 Cl(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 Br(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function ir(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function El(e){const r=Br(e),n=(r.getDay()+6)%7;return ir(r,-n)}function bo(e){const r=El(e);return Array.from({length:7},(n,a)=>ir(r,a))}function Ml(e){const r=e.getDay();return r===0||r===6}function ea(e){return e.filter(r=>!Ml(r))}function Tl(e){return ea(bo(e))}function Mu(e){const r=Br(e),n=r.getDay();return n===6?ir(r,-1):n===0?ir(r,-2):r}function ho(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=El(r);return Array.from({length:42},(a,o)=>ir(n,o))}function po(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Al(e){return po(e).map(ea)}function Tu(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function cr(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=Cl(n.start);if(!a)return null;const o=Cl(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function Ll(e,r){const n={};for(const a of e){const o=cr(a,r);if(!o)continue;let l=Br(o.start);const i=Br(o.end);for(;l.getTime()<=i.getTime();){const c=Yt(l);n[c]||(n[c]=[]),n[c].push(a),l=ir(l,1)}}return n}function mo(e,r,n){if(r.length===0)return[];const a=Br(r[0]),o=Br(r[r.length-1]),l=[],i=[],c=[...e].sort((f,d)=>{const h=cr(f,n),b=cr(d,n),u=(h==null?void 0:h.start.getTime())??0,p=(b==null?void 0:b.start.getTime())??0;return u-p||f.title.localeCompare(d.title)});for(const f of c){const d=cr(f,n);if(!d||!Tu(d.start,d.end,a,o))continue;const h=d.start.getTime()<a.getTime()?a:d.start,b=d.end.getTime()>o.getTime()?o:d.end,u=Math.max(0,Math.round((h.getTime()-a.getTime())/864e5)),p=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),g=Math.max(1,p-u+1);let w=l.findIndex(v=>v<u);w<0?(w=l.length,l.push(u+g-1)):l[w]=u+g-1,i.push({item:f,lane:w,colStart:u,colSpan:g})}return i}function zt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Au(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Lu(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 $l(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 Dl(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?ir(e,n*7):ir(e,n)}const $u=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],Il=["Lun","Mar","Mié","Jue","Vie"];function Du({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=cr(e),i=l?`${zt(l.start)} → ${zt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Xt,{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:f=>{f.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 Iu({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=cr(e),l=o?`${zt(o.start)} → ${zt(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 Fu({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=cr(e),i=l?`${zt(l.start)} → ${zt(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 Fl({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function Ol({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 Ou({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:f=3,overloadThreshold:d=5,weekdayLabels:h,hideWeekends:b=!1,renderToolbarExtra:u,renderPill:p,renderDayCard:g,renderWeekBar:w,tableColumns:v,tableProps:E,onItemClick:y,onDayClick:T,loading:L=!1,emptyTitle:C="Sin eventos",emptyDescription:m="No hay eventos para los filtros seleccionados.",legend:S,legendInteractive:N=!0,activeLegendKeys:_,defaultActiveLegendKeys:U,onActiveLegendKeysChange:K,getItemLegendKey:D,overloadLabel:Z="Sobrecarga de eventos",notice:O,showOverload:ne=!0,layout:ee="span",className:fe="",showToolbar:J=!0}){const W=h??(b?[...Il]:[...$u]),R=b?5:7,$=b?"grid grid-cols-5":"grid grid-cols-7",P=s.useMemo(()=>(S??[]).map(oe=>oe.label),[S]),[ue,z]=s.useState(()=>U??P),se=s.useMemo(()=>_??(P.length>0?ue:[]),[_,P.length,ue]),q=s.useMemo(()=>new Set(se),[se]),k=oe=>{_===void 0&&z(oe),K==null||K(oe)},V=oe=>{N&&(q.has(oe)?k(se.filter(we=>we!==oe)):k([...se,oe]))},M=s.useMemo(()=>{if(!N||P.length===0)return e;const oe=new Set(P);return e.filter(we=>{const ae=(D==null?void 0:D(we))??we.status;return!ae||!oe.has(ae)?!0:q.has(ae)})},[e,N,P,q,D]),Y=s.useMemo(()=>Ll(M,c),[M,c]),ce=s.useMemo(()=>{const oe=ho(r);return b?ea(oe):oe},[r,b]),X=s.useMemo(()=>{const oe=ho(r);return b?Al(oe):po(oe)},[r,b]),G=s.useMemo(()=>b?Tl(r):bo(r),[r,b]),I=Yt(r),le=Y[I]??[],be=s.useMemo(()=>mo(M,G,c),[M,G,c]),ie=s.useMemo(()=>be.length===0?1:Math.max(...be.map(oe=>oe.lane))+1,[be]),ge=s.useMemo(()=>X.map(oe=>{const we=mo(M,oe,c),ae=we.length===0?0:Math.max(...we.map(Fe=>Fe.lane))+1;return{days:oe,bars:we,laneCount:ae}}),[X,M,c]),$e=36,De=38,kt=s.useMemo(()=>{const oe=l==="month"?ce:l==="week"?G:[r],we=[];for(const ae of oe){const Fe=Yt(ae),qe=Y[Fe]??[];qe.length>=d&&we.push([ae,qe])}return we},[l,ce,G,r,Y,d]),wt=l==="month"?Au(r):l==="week"?`${zt(G[0])} – ${zt(G[6])}`:Lu(r),re=s.useMemo(()=>[{key:"title",header:"Título",cell:oe=>oe.title},{key:"status",header:"Estado",cell:oe=>oe.status??"—"},{key:"range",header:"Rango",cell:oe=>{const we=cr(oe,c);return we?`${zt(we.start)} → ${zt(we.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:oe=>oe.subtitle??"—"}],[c]),xe=oe=>{if(n(oe),T){T(oe);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${fe}`.trim(),children:[J?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(Dl(r,l,-1)),children:t.jsx(F.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:wt}),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(Dl(r,l,1)),children:t.jsx(F.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:[u,t.jsx(Ol,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(F.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(F.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(Ol,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,S&&S.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:N?"group":void 0,"aria-label":N?"Filtrar por estado":void 0,children:S.map(oe=>{const we=q.has(oe.label);return N?t.jsxs("button",{type:"button","aria-pressed":we,onClick:()=>V(oe.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:we?"var(--text-main)":"var(--text-muted)",background:we?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:we?`1px solid color-mix(in srgb, ${oe.color} 55%, var(--border))`:"1px solid var(--border)",opacity:we?1:.45},title:we?`Ocultar “${oe.label}”`:`Mostrar “${oe.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:oe.color,boxShadow:we?`0 0 0 2px color-mix(in srgb, ${oe.color} 25%, transparent)`:void 0},"aria-hidden":!0}),oe.label]},oe.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:oe.color},"aria-hidden":!0}),oe.label]},oe.label)})}):null,a==="calendar"&&O&&O.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:O.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[O.label,":"]})," ",O.items.join(", ")]}):a==="calendar"&&ne&&kt.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:[Z,":"]})," ",kt.map(([oe,we])=>`${zt(oe)} (${we.length})`).join(", ")]}):null,a==="table"?L||M.length>0?t.jsx(fo,{columns:v??re,data:M,getRowId:oe=>oe.id,loading:L,skeletonRows:8,emptyIcon:t.jsx(F.HiCalendarDays,{className:"h-10 w-10"}),emptyText:m,onRowClick:y,pageSize:25,compact:!0,...E}):t.jsx(Rn,{icon:t.jsx(F.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:m}):null,a==="calendar"&&l==="month"&&ee==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:$,style:{borderBottom:"1px solid var(--border)"},children:W.map(oe=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:oe},oe))}),t.jsx("div",{className:$,children:ce.map(oe=>{const we=Yt(oe),ae=Y[we]??[],Fe=oe.getMonth()!==r.getMonth(),qe=Math.max(0,ae.length-f);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${oe.getDate()}`,onClick:()=>xe(oe),onKeyDown:Je=>{(Je.key==="Enter"||Je.key===" ")&&(Je.preventDefault(),xe(oe))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Fe?"var(--text-muted)":"var(--text-main)"},children:oe.getDate()}),ae.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ae.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[ae.slice(0,f).map(Je=>t.jsx(Fl,{item:Je,day:oe,renderPill:p,onClick:()=>y==null?void 0:y(Je)},Je.id)),qe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",qe," más"]}):null]})]},we)})})]}):null,a==="calendar"&&l==="month"&&ee==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:$,style:{borderBottom:"1px solid var(--border)"},children:W.map(oe=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:oe},oe))}),ge.map(({days:oe,bars:we,laneCount:ae},Fe)=>{const qe=Math.min(ae,f),Je=Math.max(0,ae-f),Ze=$e+Math.max(1,qe)*De+(Je>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:Ze,borderBottom:Fe<ge.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:$,style:{minHeight:Ze},children:oe.map(Ue=>{const tt=Yt(Ue),Ct=Y[tt]??[],xt=Ue.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Ue.getDate()}`,onClick:()=>xe(Ue),onKeyDown:Et=>{(Et.key==="Enter"||Et.key===" ")&&(Et.preventDefault(),xe(Ue))},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:Ze},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:xt?"var(--text-muted)":"var(--text-main)"},children:Ue.getDate()}),Ct.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:Ct.length}):null]})},tt)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:$e,bottom:4},children:[we.filter(Ue=>Ue.lane<f).map(Ue=>{const tt={left:`calc(${Ue.colStart/R*100}% + 4px)`,width:`calc(${Ue.colSpan/R*100}% - 8px)`,top:2+Ue.lane*De,height:De-6,pointerEvents:"auto"};return p?t.jsx("div",{className:"absolute overflow-hidden",style:tt,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(Ue.item,{day:oe[Ue.colStart]})})},`${Ue.item.id}-${Ue.colStart}-${Fe}`):w?t.jsx("div",{className:"absolute overflow-hidden",style:tt,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(Ue.item)})},`${Ue.item.id}-${Ue.colStart}-${Fe}`):t.jsx(Du,{item:Ue.item,style:tt,onClick:()=>y==null?void 0:y(Ue.item)},`${Ue.item.id}-${Ue.colStart}-${Fe}`)}),Je>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+qe*De,color:"var(--text-muted)"},children:["+",Je," más"]}):null]})]},`week-${Fe}-${Yt(oe[0])}`)})]}):null,a==="calendar"&&l==="week"&&ee==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:$,children:G.map(oe=>{const we=Yt(oe),ae=Y[we]??[],Fe=Math.max(0,ae.length-f);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>xe(oe),children:[$l(oe),t.jsx("span",{className:"mt-1 block text-sm",children:oe.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[ae.slice(0,f).map(qe=>t.jsx(Fl,{item:qe,day:oe,renderPill:p,onClick:()=>y==null?void 0:y(qe)},qe.id)),Fe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Fe," más"]}):null]})]},we)})})}):null,a==="calendar"&&l==="week"&&ee==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${$} border-b`,style:{borderColor:"var(--border)"},children:G.map(oe=>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:()=>xe(oe),children:$l(oe)},Yt(oe)))}),t.jsxs("div",{className:`relative ${$}`,style:{minHeight:Math.max(220,ie*56+24)},children:[G.map(oe=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Yt(oe)}`)),be.map(oe=>{const we={left:`calc(${oe.colStart/R*100}% + 4px)`,width:`calc(${oe.colSpan/R*100}% - 8px)`,top:12+oe.lane*56,height:48};return w?t.jsx("div",{className:"absolute overflow-hidden",style:we,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(oe.item)})},`${oe.item.id}-${oe.colStart}`):t.jsx(Fu,{item:oe.item,style:we,onClick:()=>y==null?void 0:y(oe.item)},`${oe.item.id}-${oe.colStart}`)}),be.length===0&&!L?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:m}):null]})]}):null,a==="calendar"&&l==="day"?le.length>0||L?t.jsxs("div",{className:"space-y-3",children:[L&&le.length===0?t.jsx(Rn,{icon:t.jsx(F.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,le.map(oe=>g?t.jsx("div",{children:g(oe)},oe.id):t.jsx(Iu,{item:oe,onClick:()=>y==null?void 0:y(oe)},oe.id))]}):t.jsx(Rn,{icon:t.jsx(F.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:m}):null]})}function Hu(e){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select(),r.setSelectionRange(0,e.length);const n=document.execCommand("copy");if(document.body.removeChild(r),!n)throw new Error("execCommand_copy_failed")}async function go(e){var n;const r=String(e??"");if(!r.trim())throw new Error("empty_clipboard_text");try{if(typeof window<"u"&&window.focus(),(n=navigator.clipboard)!=null&&n.writeText){await navigator.clipboard.writeText(r);return}}catch{}Hu(r)}function Bu(e){return typeof e=="function"?e():e}function vo({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(F.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(F.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:f,onCopyError:d,className:h="",style:b,children:u,onClick:p,type:g="button",...w}){const[v,E]=s.useState(!1),y=s.useRef(null);s.useEffect(()=>()=>{y.current&&window.clearTimeout(y.current)},[]);function T(C){E(!0),f==null||f(C),y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{E(!1),y.current=null},r)}async function L(C){if(c&&C.stopPropagation(),p==null||p(C),C.defaultPrevented)return;const m=Bu(e);if(m)try{await go(m),T(m)}catch(S){d==null||d(S,m)}}return t.jsxs("button",{...w,type:g,onClick:L,title:v?a:n,"aria-label":w["aria-label"]??(v?a:n),"data-copied":v?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${u?"min-w-7 px-2":"w-7"} ${h}`,style:{cursor:"pointer",background:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:v?"scale(1.15)":"scale(1)"},children:v?i:l}),u&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??u:u})]})}const Pu=new Set(["as","async","await","break","case","catch","class","const","continue","declare","default","else","enum","export","extends","false","finally","for","from","function","if","implements","import","in","interface","keyof","let","new","null","of","private","protected","public","readonly","return","satisfies","super","switch","this","throw","true","try","type","typeof","undefined","var","void","while"]),_u=new Set(["","text","txt","plain","prompt"]);function Hl(e){const r=(e??"txt").toLowerCase();return r==="typescript"?"ts":r==="javascript"?"js":r==="text"||r==="plain"||r==="prompt"?"txt":r||"txt"}function Bl(e){return!_u.has((e??"").toLowerCase())}function zu(e,r){const n=(r??"").toLowerCase();if(!Bl(n))return e.split(`
|
|
25
25
|
`).map(u=>[{kind:"plain",text:u}]);const a=n==="html"||n==="xml"||n==="svg",o=n==="css"||n==="scss",l=n==="json",i=[];let c=0,f=!1,d=!1;const h=(u,p)=>{p&&i.push({kind:u,text:p})};for(;c<e.length;){const u=e.slice(c),p=u[0];if(p===`
|
|
26
26
|
`){h("plain",`
|
|
27
|
-
`),c+=1;continue}const
|
|
27
|
+
`),c+=1;continue}const g=u.match(/^[^\S\n]+/);if(g){h("plain",g[0]),c+=g[0].length;continue}if(!l&&u.startsWith("//")){const E=u.indexOf(`
|
|
28
28
|
`),y=E===-1?u:u.slice(0,E);h("comment",y),c+=y.length;continue}if(!l&&!a&&u.startsWith("/*")){const E=u.indexOf("*/"),y=E===-1?u:u.slice(0,E+2);h("comment",y),c+=y.length;continue}if(p==='"'||p==="'"||p==="`"){let E=1;for(;E<u.length;){if(u[E]==="\\"){E+=2;continue}if(u[E]===p){E+=1;break}if(u[E]===`
|
|
29
|
-
`&&p!=="`")break;E+=1}h("string",u.slice(0,E)),c+=E;continue}if((a||!o)&&(u.startsWith("</")||u.startsWith("<"))&&/^<\/?[A-Za-z]/.test(u)){const E=u.startsWith("</");h("punct",E?"</":"<"),c+=E?2:1,f=!0,d=!0;continue}if(f&&p===">"){h("punct",">"),f=!1,d=!1,c+=1;continue}const w=u.match(/^\d+(?:\.\d+)?/);if(w&&!f){h("number",w[0]),c+=w[0].length;continue}const
|
|
30
|
-
`).forEach((
|
|
31
|
-
`).map(C=>[{kind:"plain",text:C}]),y=String(Math.max(E.length,1)).length,M=d??p,L=Vd(n,a);return t.jsxs("div",{className:`min-w-0 overflow-hidden rounded-xl border shadow-[0_16px_40px_rgba(2,6,23,0.28)] ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0d1117",color:"#e6edf3",...c},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b px-3 py-2",style:{borderColor:"rgba(148, 163, 184, 0.16)",background:"#161b22"},children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#ff5f57]"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#febc2e]"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#28c840]"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-[#c9d1d9]",children:L}),t.jsx("span",{className:"shrink-0 rounded-md bg-[#0d1117] px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-[#8b949e]",children:Js(a)}),M&&t.jsxs("div",{className:"flex shrink-0 overflow-hidden rounded-md border border-white/10 text-[11px]",role:"group","aria-label":"Vista del codigo",children:[t.jsx("button",{type:"button",className:"px-2 py-1",style:{background:g?"#238636":"transparent",color:g?"#fff":"#8b949e"},"aria-pressed":g,onClick:()=>w("code"),children:"Codigo"}),t.jsx("button",{type:"button",className:"px-2 py-1",style:{background:g?"transparent":"#238636",color:g?"#8b949e":"#fff"},"aria-pressed":!g,onClick:()=>w("raw"),children:"Raw"})]}),t.jsx(co,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:t.jsx("span",{className:"hidden sm:inline",children:l}),onCopied:b,className:"h-7 shrink-0 px-2",style:{background:"#21262d",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f0f6fc"},children:t.jsx("span",{className:"hidden sm:inline",children:o})})]}),t.jsx("div",{className:"max-h-[min(28rem,70vh)] overflow-auto",children:t.jsx("div",{className:"grid min-w-max py-3 text-[12px] leading-6 sm:text-[13px]",style:{gridTemplateColumns:f?"auto minmax(0, 1fr)":"minmax(0, 1fr)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:E.map((C,m)=>t.jsxs("div",{className:"contents",children:[f&&t.jsx("span",{"aria-hidden":!0,className:"sticky left-0 select-none border-r px-3 text-right",style:{minWidth:`${y+2}ch`,color:"#6e7681",borderColor:"rgba(148, 163, 184, 0.16)",background:"#0d1117"},children:m+1}),t.jsx("code",{className:"whitespace-pre px-3",children:C.length===0?" ":C.map((k,N)=>t.jsx("span",{style:{color:g?el[k.kind]:el.plain},children:k.text},N))})]},m))})})]})}function Gn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Yd({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(H.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:Gn(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:Gn(o),padding:Gn(l)}})]})}function Gd({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:f=10,searchable:d=!0}){const h=o?n.map((b,u)=>u===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:Gn(f)},children:o}),t.jsx(vr,{value:e,onChange:r,options:h,placeholder:a,searchable:d,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Kd={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Kn=180,Zd="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function uo({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:f="md",maxWidth:d,zIndex:h=1e3,closeOnBackdrop:b=!0,closeOnEscape:u=!0,showCloseButton:p=!0,placement:v="center",bodyClassName:w="px-6 py-5",panelClassName:g="",backdropClassName:E=Zd,contentClassName:y="p-4",ariaLabel:M,frameless:L=!1,disabled:C=!1}){const[m,k]=s.useState(!1),[N,_]=s.useState(!1),q=s.useRef(null);if(s.useEffect(()=>(e?(q.current&&clearTimeout(q.current),k(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>_(!0)))):(_(!1),q.current=setTimeout(()=>k(!1),Kn+40)),()=>{q.current&&clearTimeout(q.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!u)return;const J=fe=>{fe.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[u,r,e]),!m)return null;const K=n||a||o||l||p,$=d??Kd[f],Q=v==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",X=v==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",se=N?"translateY(0) scale(1)":v==="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":M??n,className:`fixed inset-0 flex ${Q} ${y}`,style:{zIndex:h},children:[t.jsx("div",{className:`absolute inset-0 ${E}`,onClick:b?r:void 0,style:{opacity:N?1:0,transition:`opacity ${Kn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${L?"shadow-none":"shadow-2xl"} ${X} ${g}`,style:{maxWidth:$,background:L?"transparent":"var(--bg-card)",border:L?"none":"1px solid var(--border)",opacity:N?1:0,transform:se,transition:`opacity ${Kn}ms ease, transform ${Kn}ms ease`},onClick:J=>J.stopPropagation(),children:[C&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),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,p&&t.jsx(Ke,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(H.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${w}`,children:c}),i&&t.jsx("div",{className:"flex min-w-0 flex-shrink-0 flex-wrap justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const Qd={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 Jd({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:f}){const d=Qd[l];return t.jsx(uo,{open:e,onClose:f,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ke,{variant:"icon",onClick:f,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(H.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:d.iconBg},children:t.jsx(H.HiExclamationTriangle,{className:"h-5 w-5",style:{color:d.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ke,{variant:"secondary",onClick:f,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ke,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:d.btnBg,color:d.btnColor,borderColor:"transparent"},children:a})]})]})})}function Rd(e){return e?typeof e=="function"?e():e:""}function eu(e){return/^https?:\/\//i.test(e)}function tl(e,r){try{return new URL(e,r).toString()}catch{return e}}function tu(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||eu(l))return l;const i=Rd(n);return i?tl(l,i):a&&typeof window<"u"?tl(l,window.location.origin):l}function ru({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(H.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(co,{...c,value:()=>tu(e,r,n,a),title:o,copiedTitle:l,icon:i})}const nu={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 au(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=nu[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 ou=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function su({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),f=(n==null?void 0:n.preset)==="date",d=f?"date":r==="number"?"number":"text";return s.useEffect(()=>{var h,b;(h=c.current)==null||h.focus(),f||(b=c.current)==null||b.select()},[f]),t.jsx("input",{ref:c,type:d,value:l,maxLength:n==null?void 0:n.maxLength,onChange:h=>i(h.target.value),onBlur:()=>o(),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),a(l)),h.key==="Escape"&&(h.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!ou.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function lu({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,f;(f=(c=l.current)==null?void 0:c.querySelector("button"))==null||f.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(vr,{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 iu={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},fo={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function cu({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(r),f=s.useRef(null);s.useEffect(()=>{f.current||c(r)},[r]);const[d,h]=s.useState(null);f.current=d;const[b,u]=s.useState(null),p=s.useRef(null);p.current=b;const[v,w]=s.useState({}),[g,E]=s.useState(null),y=s.useRef(null);y.current=g;const[M,L]=s.useState({}),[C,m]=s.useState({}),k=s.useRef(new Set),N=s.useRef(null);s.useEffect(()=>{var F;const A=document.activeElement;(!A||A===document.body)&&((F=N.current)==null||F.focus({preventScroll:!0}))},[]);const _=e.map(A=>{var F,ue,P;return`${A.key}:${((P=(ue=(F=A.editable)==null?void 0:F.select)==null?void 0:ue.options)==null?void 0:P.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(A=>{var P,oe;const F=(oe=(P=A.editable)==null?void 0:P.select)==null?void 0:oe.options;if(!F)return;const ue=M[A.key];(!k.current.has(A.key)||(ue==null?void 0:ue.length)===0&&F.length>0)&&(k.current.add(A.key),L(j=>({...j,[A.key]:F})))})},[_]);const q=s.useCallback(async(A,F)=>{if(k.current.has(A))return;k.current.add(A);const{url:ue,fetchOptions:P}=F.select??{};if(!(!ue&&!P)){m(oe=>({...oe,[A]:!0}));try{let oe=[];if(P)oe=await P();else if(ue){const j=await fetch(ue);if(!j.ok)throw new Error("fetch failed");oe=await j.json()}L(j=>({...j,[A]:oe}))}catch{L(oe=>({...oe,[A]:[]}))}finally{m(oe=>({...oe,[A]:!1}))}}},[]),K=s.useRef(i);K.current=i;const $=s.useRef(a);$.current=a;const Q=s.useRef(n);Q.current=n;const X=s.useRef(e);X.current=e;const se=s.useRef(o);se.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const A=e.find(F=>F.selectable!==!1);A&&u({rowId:n(r[0]),colKey:A.key})}},[]),s.useEffect(()=>{if(!b)return;const A=N.current;if(!A)return;const F=A.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!F)return;const ue=A.querySelector('[role="rowgroup"]');F.style.scrollMarginTop=`${(ue==null?void 0:ue.offsetHeight)??0}px`;const P=A.querySelector('[role="row"]');let oe=0;P&&P.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(j=>{j.style.position==="sticky"&&j.style.left!==""&&(oe=Math.max(oe,parseFloat(j.style.left)+j.offsetWidth))}),F.style.scrollMarginLeft=`${oe}px`,F.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=s.useCallback(A=>{var oe;const F=X.current,ue=new Set,P=[];(oe=N.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(j=>{const S=j.dataset.cellId.split(":")[0];ue.has(S)||(ue.add(S),P.push(S))}),u(j=>{if(!j)return j;const S=F.findIndex(ce=>ce.key===j.colKey),U=P.indexOf(j.rowId);let T=S,Y=U;if(A==="up")Y=Math.max(0,U-1);else if(A==="down")Y=Math.min(P.length-1,U+1);else if(A==="left"){let ce=S-1;for(;ce>=0&&F[ce].selectable===!1;)ce--;ce>=0&&(T=ce)}else if(A==="right"){let ce=S+1;for(;ce<F.length&&F[ce].selectable===!1;)ce++;ce<F.length&&(T=ce)}return T===S&&Y===U?j:{rowId:P[Y],colKey:F[T].key}})},[]),fe=s.useCallback((A=!0)=>{const F=f.current;h(null),F&&u(F),A&&setTimeout(()=>{var ue;return(ue=N.current)==null?void 0:ue.focus({preventScroll:!0})},0)},[]),te=s.useCallback(async(A,F,ue)=>{var ie;const P=X.current.find(ge=>ge.key===F);if(!(P!=null&&P.editable))return;const{field:oe,type:j,mask:S,validate:U}=P.editable,T=j==="number"?ue===""?null:Number(ue):ue;if(S){const ge=au(ue,S);if(ge){w($e=>({...$e,[`${A}:${F}`]:ge}));return}}if(U){const ge=U(T);if(ge){w($e=>({...$e,[`${A}:${F}`]:ge}));return}}const Y=Q.current,ce=K.current.find(ge=>Y(ge)===A);if(!ce)return;const V=ce[oe];h(null),w(ge=>{const $e={...ge};return delete $e[`${A}:${F}`],$e});const G=K.current,D=G.findIndex(ge=>Y(ge)===A),le=G[Math.min(G.length-1,D+1)];if(u({rowId:Y(le),colKey:F}),setTimeout(()=>{var $e,De;const ge=document.activeElement;(!ge||ge===document.body||($e=N.current)!=null&&$e.contains(ge))&&((De=N.current)==null||De.focus({preventScroll:!0}))},0),String(V??"")===String(T??""))return;const be={...ce,[oe]:T};c(ge=>ge.map($e=>Y($e)===A?be:$e)),E({rowId:A,colKey:F});try{await((ie=$.current)==null?void 0:ie.call($,{row:ce,rowId:A,field:oe,oldValue:V,newValue:T}))}catch{c(ge=>ge.map($e=>Y($e)===A?ce:$e)),w(ge=>({...ge,[`${A}:${F}`]:"Error al guardar. Intenta de nuevo."}))}finally{E(null)}},[]),z=s.useCallback(A=>{if(y.current){A.preventDefault();return}if(f.current)return;const F=p.current;if(!(!F||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(A.key)))switch(A.preventDefault(),A.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(A.shiftKey?"left":"right");break;case"Enter":{const P=X.current.find(oe=>oe.key===F.colKey);P!=null&&P.editable&&!se.current?(h(F),P.editable.type==="select"&&!k.current.has(F.colKey)&&q(F.colKey,P.editable)):J("down");break}}},[J,q]),R=s.useMemo(()=>e.map(A=>{if(!A.editable||o){const ue={...A};if(delete ue.editable,delete ue.selectable,A.selectable===!1)return{...ue,disableRowClick:!0};const P=ue.cell;return{...ue,className:`relative ${ue.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const j=n(oe),S=(b==null?void 0:b.rowId)===j&&(b==null?void 0:b.colKey)===A.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${j}:${A.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var U;y.current||(u({rowId:j,colKey:A.key}),(U=N.current)==null||U.focus({preventScroll:!0}))}}),S&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:fo}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:P(oe)})]})}}}const F=A.editable;return{...A,className:`relative ${A.className??""}`.trim(),disableRowClick:!0,cell:ue=>{const P=n(ue),oe=A.key,j=(d==null?void 0:d.rowId)===P&&(d==null?void 0:d.colKey)===oe,S=(b==null?void 0:b.rowId)===P&&(b==null?void 0:b.colKey)===oe,U=v[`${P}:${oe}`],T=(g==null?void 0:g.rowId)===P&&(g==null?void 0:g.colKey)===oe,Y=ue[F.field],ce=String(Y??""),V=()=>{var D;y.current||(u({rowId:P,colKey:oe}),h({rowId:P,colKey:oe}),(D=N.current)==null||D.focus({preventScroll:!0}),F.type==="select"&&!k.current.has(oe)&&q(oe,F))};if(j){const D=F.type==="select"?t.jsx(lu,{initialValue:ce,options:M[oe]??[],loading:C[oe]??!1,onCommit:le=>te(P,oe,le),onCancel:fe}):t.jsx(su,{initialValue:ce,type:F.type??"text",mask:F.mask,onCommit:le=>te(P,oe,le),onCancel:fe});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:iu,onClick:le=>le.stopPropagation(),children:D})}const G=A.cell(ue);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${P}:${oe}`,className:`peer absolute inset-0 z-10 ${T?"cursor-wait":"cursor-pointer"}`,onClick:V}),S&&!T&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:fo}),T&&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:fo,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:U?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(H.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:U})]}):t.jsx("span",{className:"truncate",children:G})}),!T&&t.jsx(H.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,d,b,g,v,M,C,n,te,fe,q]);return t.jsx("div",{ref:N,tabIndex:0,onKeyDown:z,onBlur:A=>{var F;(F=N.current)!=null&&F.contains(A.relatedTarget)||setTimeout(()=>{var P,oe;const ue=document.activeElement;ue&&((P=ue.closest)!=null&&P.call(ue,"[data-bonsaif-select-dropdown]"))||(oe=N.current)!=null&&oe.contains(ue)||fe(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(no,{...l,columns:R,data:i,getRowId:n})})}function gt(e){if(e)return new Date(`${e}T12:00:00`)}function zt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function Br(e){return e.charAt(0).toUpperCase()+e.slice(1)}function rl(e){return e.map(r=>gt(r)).filter(r=>!!r)}function du(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(zt));return Array.from(r).sort()}function bo(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function nl(e){const r=gt(e);if(!r)return e;const n=bo(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 ho={weekend:{dayOfWeek:[0,6]}},po={weekend:"bonsaif-weekend"};function mo({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),o=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${o?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const uu={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},fu={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function bu({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?uu:null,...o?fu:null,...l?{fontWeight:800}:null,...n.style}})}function hu({startDate:e,endDate:r,onChange:n,minDate:a,maxDate:o,viewMonth:l,numberOfMonths:i=1,orientation:c="horizontal",showSummary:f=!0,startLabel:d="Inicio",endLabel:h="Regreso",className:b=""}){const u={from:gt(e),to:gt(r)},p=gt(a),v=gt(o),w=[...p?[{before:p}]:[],...v?[{after:v}]:[]],[g,E]=s.useState(()=>gt(l||e)??new Date);s.useEffect(()=>{const m=gt(l||e);m&&E(m)},[l,e]);const y=s.useMemo(()=>{if(i<=1)return Br(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const m=new Date(g.getFullYear(),g.getMonth()+i-1,1),k=g.getFullYear()===m.getFullYear(),N=new Intl.DateTimeFormat("es-MX",{month:"short",...k?{}:{year:"numeric"}}).format(g),_=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(m);return`${Br(N)} – ${Br(_)}`},[g,i]);function M(){E(new Date(g.getFullYear(),g.getMonth()-1,1))}function L(){E(new Date(g.getFullYear(),g.getMonth()+1,1))}const C=i>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${c}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${b}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:M,children:t.jsx(H.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:y}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:L,children:t.jsx(H.HiChevronRight,{size:16})})]}),t.jsx(Ga.DayPicker,{mode:"range",selected:u,month:g,onMonthChange:E,onSelect:m=>{const k=m!=null&&m.from?zt(m.from):e,N=m!=null&&m.to?zt(m.to):"";n({startDate:k,endDate:N})},numberOfMonths:i,hideNavigation:!0,weekStartsOn:1,disabled:w.length>0?w:void 0,showOutsideDays:!1,modifiers:ho,modifiersClassNames:po,components:{DayButton:bu,Weekday:mo},classNames:{root:"bonsaif-range-daypicker w-full",months:C,month:i>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:i>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:m=>`${Br(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(m))} ${m.getFullYear()}`,formatWeekdayName:bo}})]}),f?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:[h,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function al({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:f=>{var d;i||(n==null||n(e.date,f),(d=l.onPointerDown)==null||d.call(l,f))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:f=>{i||(f.preventDefault(),f.stopPropagation(),o==null||o(e.date,f))}})}function ol(e,r){const n=gt(e),a=gt(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(zt(c)),c.setDate(c.getDate()+1);return i}function sl(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 pn(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 pu(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function mu(e,r,n){return!!(r&&e<r||n&&e>n)}function ll({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const f=s.useRef(null),d=s.useRef(null),h=s.useRef(!1),b=s.useRef(e);b.current=e;const u=s.useCallback(C=>{let m=C;if(c){const k=b.current.filter(_=>!_.startsWith(c)),N=C.filter(_=>_.startsWith(c));m=[...k,...N].sort()}r==null||r(pu(m,l))},[l,r,c]),p=s.useCallback((C,m=!1)=>mu(C,a,o)?!0:!(!(i!=null&&i(C))||m&&b.current.includes(C)),[i,o,a]),v=s.useCallback(C=>C.filter(m=>!p(m)),[p]),w=s.useCallback(()=>{d.current=null},[]);s.useEffect(()=>{const C=()=>w();return window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),()=>{window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C)}},[w]);const g=s.useCallback((C,m,k,N)=>{const _=v(ol(C,m));u(k==="add"?pn(N,_,"add"):pn(N,_,"remove"))},[u,v]),E=s.useCallback((C,m)=>{if(n||m.button!==0)return;const k=zt(C);if(p(k,!0)||m.shiftKey)return;h.current=!0;const N=[...b.current],_=N.includes(k)?"remove":"add";_==="add"&&p(k)||(d.current={active:!0,mode:_,anchor:k,latest:k,baseline:N},f.current=k,g(k,k,_,N),m.preventDefault())},[g,n,p]),y=s.useCallback(C=>{const m=d.current;if(!(m!=null&&m.active)||n)return;const k=zt(C);m.mode==="add"&&p(k)||m.latest!==k&&(m.latest=k,g(m.anchor,k,m.mode,m.baseline))},[g,n,p]),M=s.useCallback((C,m)=>{if(n)return;const k=zt(C);if(!p(k,!0)){if(h.current&&!m.shiftKey){h.current=!1,m.preventDefault(),m.stopPropagation();return}if(h.current=!1,m.shiftKey&&f.current){m.preventDefault(),m.stopPropagation();const N=v(ol(f.current,k));u(pn(b.current,N,"add"));return}!b.current.includes(k)&&p(k)||(f.current=k,u(pn(b.current,[k],"toggle")))}},[u,n,v,p]),L=s.useCallback(C=>{if(n)return;const m=v(du(C));if(!m.length)return;const k=m.every(N=>b.current.includes(N));u(pn(b.current,m,k?"remove":"add")),f.current=m[0]??f.current},[u,n,v]);return{onDayPointerDown:E,onDayPointerEnter:y,onDayClick:M,toggleWeek:L,endDrag:w}}function mn(e){return sl(e,1)[0]}function il(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function gu({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:f,defaultViewMode:d="month",onViewModeChange:h,showSummary:b=!0,className:u="",disabled:p=!1}){const v=s.useMemo(()=>rl(e),[e]),w=s.useMemo(()=>new Set(e),[e]),g=gt(n),E=gt(a),[y,M]=s.useState(()=>gt(l||e[0])??new Date),[L,C]=s.useState(()=>mn(gt(l||e[0])??new Date)),[m,k]=s.useState(d),N=f??m;function _(A){f===void 0&&k(A),h==null||h(A)}s.useEffect(()=>{const A=gt(l);A&&(M(A),C(mn(A)))},[l]);const{onDayPointerDown:q,onDayPointerEnter:K,onDayClick:$,toggleWeek:Q}=ll({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),X=s.useMemo(()=>{if(p)return!0;const A=[];return g&&A.push({before:g}),E&&A.push({after:E}),o&&A.push(F=>o(zt(F))),A.length>0?A:void 0},[p,o,E,g]),se=s.useCallback(A=>t.jsx(al,{...A,className:`bonsaif-multi-day-btn ${A.className??""}`,onDayPointerDown:q,onDayPointerEnter:K,onDayClickSelect:$}),[$,q,K]),J=s.useMemo(()=>sl(L,1),[L]),fe=J[6],te=N==="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(fe)}`:Br(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(y));function z(){if(N==="week"){const A=il(L,-7);C(mn(A)),M(A);return}M(new Date(y.getFullYear(),y.getMonth()-1,1))}function R(){if(N==="week"){const A=il(L,7);C(mn(A)),M(A);return}M(new Date(y.getFullYear(),y.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${u}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":N==="month",className:`bonsaif-cal-view-btn${N==="month"?" is-active":""}`,disabled:p,onClick:()=>{_("month"),M(L)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":N==="week",className:`bonsaif-cal-view-btn${N==="week"?" is-active":""}`,disabled:p,onClick:()=>{_("week"),C(mn(y))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:z,children:t.jsx(H.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:te}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:R,children:t.jsx(H.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&N==="month"?" · Semana (nº)":"",N==="week"?" · Botón semana completa":""]}),N==="month"?t.jsx(Ga.DayPicker,{mode:"multiple",required:!1,selected:v,month:y,onMonthChange:M,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(A,F)=>{Q(F)},disabled:X,className:"bonsaif-multi-daypicker",modifiers:ho,modifiersClassNames:po,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:se,Weekday:mo},formatters:{formatWeekdayName:bo}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(A=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(A)},`h-${zt(A)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(A=>{const F=zt(A),ue=w.has(F),P=p||(n?F<n:!1)||(a?F>a:!1)||!!(o!=null&&o(F)),oe=F===zt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ue?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${P?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:P,"aria-pressed":ue,onPointerDown:j=>q(A,j),onPointerEnter:()=>K(A),onClick:j=>$(A,j),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:A.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(A)})]})},F)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>Q(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(A=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(F=>F!==A)),title:`Quitar ${A}`,children:[nl(A),t.jsx("span",{"aria-hidden":!0,children:"×"})]},A))})]})}):null]})}const vu=Array.from({length:12},(e,r)=>r);function xu({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:f="",disabled:d=!1,readOnly:h=!1}){const b=s.useMemo(()=>rl(e),[e]),u=gt(o),p=gt(l),v=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[w,g]=s.useState(v);s.useEffect(()=>{typeof n=="number"&&g(n)},[n]);function E(N){g(N),a==null||a(N)}const{onDayPointerDown:y,onDayPointerEnter:M,onDayClick:L}=ll({value:e,onChange:r,disabled:d||h,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${w}-`}),C=s.useCallback(N=>t.jsx(al,{...N,className:`bonsaif-year-day-btn ${N.className??""}`,onDayPointerDown:y,onDayPointerEnter:M,onDayClickSelect:L}),[L,y,M]),m=b.filter(N=>N.getFullYear()===w),k=d?!0:[...u?[{before:u}]:[],...p?[{after:p}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${h?" bonsaif-year-multi-date-calendar--readonly":""} ${f}`,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:d,onClick:()=>E(w-1),children:t.jsx(H.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:w}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:d,onClick:()=>E(w+1),children:t.jsx(H.HiChevronRight,{size:16})})]}),!h&&!d?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:vu.map(N=>{const _=new Date(w,N,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Br(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(_))}),t.jsx(Ga.DayPicker,{mode:"multiple",required:!1,selected:m,month:_,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:k,className:"bonsaif-year-month-picker",modifiers:ho,modifiersClassNames:po,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:C,Weekday:mo},formatters:{formatWeekdayName:q=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(q)}})]},`${w}-${N}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",w]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(N=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:d||h,onClick:()=>r==null?void 0:r(e.filter(_=>_!==N)),title:`Quitar ${N}`,children:[nl(N),t.jsx("span",{"aria-hidden":!0,children:"×"})]},N))})]})}):null]})}const yu="bonsaif-ui:hide-tooltips";function cl(){window.dispatchEvent(new CustomEvent(yu))}function wu(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Nu({trigger:e,items:r,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[f,d]=s.useState(!1),[h,b]=s.useState(!1),[u,p]=s.useState({}),v=s.useRef(null),w=s.useRef(null),g=s.useCallback(C=>{d(C),c==null||c(C)},[c]),E=s.useCallback(()=>{const C=v.current;if(!C)return;const m=C.getBoundingClientRect(),k=typeof a=="number"?a:m.width,N=typeof a=="number"?a:Math.max(m.width,180),_=n==="end"?Math.max(8,m.right-N):Math.min(m.left,window.innerWidth-N-8),q=window.innerHeight-m.bottom,K=q<240&&m.top>q?void 0:m.bottom+6,$=K===void 0?window.innerHeight-m.top+6:void 0;p({position:"fixed",zIndex:9999,left:_,top:K,bottom:$,width:wu(typeof a=="number"?k:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!f)return;E();const C=k=>{var _,q;const N=k.target;!((_=v.current)!=null&&_.contains(N))&&!((q=w.current)!=null&&q.contains(N))&&g(!1)},m=k=>{k.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",C),window.addEventListener("keydown",m),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("keydown",m),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[f,g,E]);const y=C=>{o||(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),g(!f))},M=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(cl(),g(!f))}}):e,L=f?t.jsx("div",{ref:w,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:u,children:r.map(C=>t.jsxs("div",{children:[C.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:C.disabled,onClick:()=>{var m;C.disabled||(cl(),(m=C.onSelect)==null||m.call(C),g(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:C.danger?"var(--danger)":"var(--text-main)"},children:[C.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:C.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:C.label}),C.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:C.description})]})]})]},C.id))}):null;return t.jsxs("span",{ref:v,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":f,onKeyDown:y,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[M,h&&L?ft.createPortal(L,document.body):null]})}const ku=180,dl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Su({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:f=!1,headerActions:d,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:u=!1,unsavedChangesTitle:p="Descartar cambios",unsavedChangesDescription:v="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:w="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:E,disabled:y=!1,disabledMessage:M,children:L}){const[C,m]=s.useState(!1),[k,N]=s.useState(!1),[_,q]=s.useState(!1),K=s.useCallback(()=>{N(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>q(!0))})},[]),$=s.useCallback(()=>{q(!1),window.setTimeout(()=>N(!1),ku)},[]),Q=y||c,X=s.useCallback(()=>{if(!Q){if(u){K();return}r()}},[Q,u,r,K]),se=s.useCallback(()=>{q(!1),N(!1),E==null||E(),r()},[r,E]);if(s.useEffect(()=>{m(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(q(!1),N(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const fe=te=>{if(te.key==="Escape"&&!Q){if(k){$();return}X()}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[$,Q,k,e,X]),!C)return null;const J=M!==void 0?M: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 ${dl}`,onClick:X}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ke,{variant:"icon",onClick:X,title:"Cerrar",disabled:Q,children:t.jsx(H.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})]})]}),(d||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ke,{variant:"secondary",size:"sm",onClick:X,disabled:Q,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ke,{variant:"primary",size:"sm",icon:t.jsx(Oc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:f||Q,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:h,children:L}),Q&&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})]}),k&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${dl} transition-opacity duration-200 ease-out ${_?"opacity-100":"opacity-0"}`,onClick:$}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${_?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ke,{variant:"icon",onClick:$,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,children:t.jsx(H.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(H.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:p}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:v}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ke,{variant:"secondary",onClick:$,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx(Ke,{variant:"secondary",onClick:se,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:w})]})]})]})]}),document.body)}const Cu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Eu=/^\+?[0-9\s().-]+$/,Mu=7,Tu=15;function Yt(e){return e==null||String(e).trim()===""}function ul(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function go(e){return Yt(e)?!1:Cu.test(String(e))}function vo(e){if(Yt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Eu.test(r)&&n.length>=Mu&&n.length<=Tu}function Lu(e="Este campo es requerido."){return r=>Yt(r)?e:void 0}function Au(e="Ingresa un correo valido."){return r=>Yt(r)||go(r)?void 0:e}function $u(e="Ingresa un telefono valido."){return r=>Yt(r)||vo(r)?void 0:e}function Du(e,r){return n=>Yt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Hu(e,r){return n=>Yt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function Ou(e,r){return n=>{if(Yt(n))return;const a=ul(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Iu(e,r){return n=>{if(Yt(n))return;const a=ul(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Bu(e,r="El formato no es valido."){return n=>Yt(n)||e.test(String(n))?void 0:r}function Fu(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 fl={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},bl=s.createContext&&s.createContext(fl),Pu=["attr","size","title"];function _u(e,r){if(e==null)return{};var n,a,o=zu(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 zu(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 Zn(){return Zn=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},Zn.apply(null,arguments)}function hl(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 Qn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?hl(Object(n),!0).forEach(function(a){Wu(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hl(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Wu(e,r,n){return(r=ju(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function ju(e){var r=qu(e,"string");return typeof r=="symbol"?r:r+""}function qu(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 pl(e){return e&&e.map((r,n)=>s.createElement(r.tag,Qn({key:n},r.attr),pl(r.child)))}function xo(e){return r=>s.createElement(Uu,Zn({attr:Qn({},e.attr)},r),pl(e.child))}function Uu(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=_u(e,Pu),c=o||n.size||"1em",f;return n.className&&(f=n.className),e.className&&(f=(f?f+" ":"")+e.className),s.createElement("svg",Zn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:f,style:Qn(Qn({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 bl!==void 0?s.createElement(bl.Consumer,null,n=>r(n)):r(fl)}function ml(e){return xo({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 Vu(e){return xo({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 Xu(e){return xo({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 Fr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Vt,{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(H.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Pr({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 Jn({className:e="",...r}){return t.jsx("input",{...r,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function yo({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:o,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:f=!1,showPasswordToggle:d=!0,nativeValidation:h=!1,className:b="",required:u,...p}){const[v,w]=s.useState(()=>!!p.autoFocus),[g,E]=s.useState(!1),y=p.type==="password"&&d,M=y&&g?"text":p.type,L=!!o,C=L&&l!=="tooltip",m=L&&l!=="inline",k=!!n&&a==="tooltip"&&!C,N=h?u:void 0,_=L?"border-[var(--danger)] focus:border-[var(--danger)]":"",q=m?y?"pr-20":"pr-10":y?"pr-10":"",K=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,$=v||K,Q={top:$?7:12,color:v?"var(--primary)":"var(--text-muted)",fontSize:$?10:13,fontWeight:$?600:400,textTransform:$?"uppercase":"none"},X=z=>{var R;w(!0),(R=p.onFocus)==null||R.call(p,z)},se=z=>{var R;w(!1),(R=p.onBlur)==null||R.call(p,z)},J=y?t.jsxs("button",{type:"button","aria-label":g?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":g,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>E(z=>!z),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(Vu,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(Xu,{className:"h-[18px] w-[18px]"})})]}):null,fe=m?t.jsx(Vt,{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)] ${y?"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(ml,{className:"h-[18px] w-[18px]"})})}):null,te=t.jsx(Pr,{error:C?o:void 0,helperText:n,helperDisplay:a});return f?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(Jn,{...p,type:M,required:N,placeholder:" ","aria-invalid":L||p["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${q} ${_} ${b}`,onFocus:X,onBlur:se}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Q,children:[e,u&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:$?7:12},children:c}),fe,J]}),te]}):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}),u&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),k?t.jsx(Fr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),y?t.jsxs("span",{className:"relative block",children:[t.jsx(Jn,{...p,type:M,required:N,"aria-invalid":L||p["aria-invalid"],className:`w-full ${q} ${_} ${b}`,onFocus:X,onBlur:se}),fe,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Jn,{...p,required:N,"aria-invalid":L||p["aria-invalid"],className:`w-full ${q} ${_} ${b}`}),fe]}),te]})}function gl(e){return e==null?"":String(e)}function Yu({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:f,...d}){const[h,b]=s.useState(()=>gl(c)),u=i!==void 0?gl(i):h,p=n&&u.length>0&&!go(u)?a:void 0,v=w=>{i===void 0&&b(w.currentTarget.value),f==null||f(w)};return t.jsx(yo,{...d,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??p,errorDisplay:o,onChange:v})}const Gu={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Ku(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 vl(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 Zu(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Qu({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:f,multiple:d=!1,maxFiles:h,appendFiles:b=!1,showFileList:u=!0,clearable:p=!0,browseLabel:v="Buscar archivos",dropLabel:w="Suelta los archivos aqui",emptyLabel:g="Arrastra y suelta archivos",emptyDescription:E="o haz click para buscarlos en tu equipo",selectedLabel:y="Archivos seleccionados",size:M="md",containerClassName:L="",dropzoneClassName:C="",fileListClassName:m="",className:k="",id:N,accept:_,disabled:q,required:K,...$}){const Q=s.useId(),X=N??Q,se=s.useRef(null),[J,fe]=s.useState(!1),[te,z]=s.useState(i),R=l??te,A=!!a,F=!!r&&n==="tooltip"&&!A,ue=p&&R.length>0&&!q,P=(D,le)=>{l===void 0&&z(D),c==null||c(D,le)},oe=(D,le)=>{const be=D.filter(De=>vl(De,_)),ie=D.filter(De=>!vl(De,_)),ge=b?[...R,...be]:be,$e=Zu(ge,d,h);ie.length>0&&(f==null||f(ie)),P($e,le)},j=()=>{var D;q||(D=se.current)==null||D.click()},S=D=>{oe(Array.from(D.target.files??[]),D),D.target.value=""},U=D=>{D.preventDefault(),q||fe(!0)},T=D=>{D.currentTarget.contains(D.relatedTarget)||fe(!1)},Y=D=>{D.preventDefault(),fe(!1),!q&&oe(Array.from(D.dataTransfer.files),D)},ce=D=>{D.key!=="Enter"&&D.key!==" "||(D.preventDefault(),j())},V=D=>{P(R.filter((le,be)=>be!==D))},G=()=>{P([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${L}`,children:[(e||o||F)&&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:"*"}),F?t.jsx(Fr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...$,ref:se,id:X,type:"file",accept:_,multiple:d,disabled:q,required:K&&R.length===0,"aria-invalid":A||$["aria-invalid"],className:"sr-only",onChange:S}),t.jsxs("div",{role:"button",tabIndex:q?-1:0,"aria-controls":X,"aria-disabled":q||void 0,"aria-invalid":A||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)] ${Gu[M]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":A?"border-[var(--danger)]":"border-[var(--border)]"} ${q?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${C} ${k}`,onClick:j,onDragOver:U,onDragLeave:T,onDrop:Y,onKeyDown:ce,children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(H.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?w:g}),E&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:E})]}),v&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:v})]}),u&&R.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${m}`,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:y}),ue&&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:G,children:t.jsx(H.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:R.map((D,le)=>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(H.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:D.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Ku(D.size)})]}),!q&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${D.name}`,onClick:()=>V(le),children:t.jsx(H.HiXMark,{className:"h-4 w-4"})})]},`${D.name}-${D.lastModified}-${le}`))})]}),t.jsx(Pr,{error:a,helperText:r,helperDisplay:n})]})}const Ju=[{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 Ru({fields:e,title:r="Layout",fieldTypes:n=Ju,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:f,onChange:d}){const[h,b]=s.useState(()=>e.map(M=>({key:!1,type:"",...M}))),[u,p]=s.useState(""),[v,w]=s.useState(""),g=s.useCallback((M,L)=>{b(C=>{const m=C.map((k,N)=>N===M?{...k,...L}:k);return d==null||d(m),m})},[d]),E=s.useCallback(()=>{f==null||f(h)},[h,f]),y=s.useCallback(()=>{var m;const M=u.trim();if(!M){w("Ingresa un nombre de campo.");return}if(h.some(k=>k.name.toLowerCase()===M.toLowerCase())){w("Ese campo ya existe en el arreglo.");return}const C={name:M,key:!1,type:((m=n[0])==null?void 0:m.value)??""};b(k=>{const N=[...k,C];return d==null||d(N),N}),p(""),w("")},[n,h,u,d]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[h.map((M,L)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:M.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(_n,{size:"sm",checked:M.key??!1,onChange:C=>g(L,{key:C.target.checked}),"aria-label":`${M.name} es clave`})}),t.jsx(vr,{value:M.type??"",onChange:C=>g(L,{type:C}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${M.name}`})]},M.name)),h.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:u,onChange:M=>{p(M.currentTarget.value),v&&w("")},onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),y())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ke,{variant:"secondary",onClick:y,height:36,padding:"0 12px",children:i})]}),v&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:v})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ke,{variant:"primary",onClick:E,disabled:c,loading:c,children:a})})]})})]})}function Rn({label:e,children:r,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:f=""}){const d=!!n&&a==="tooltip"&&!o;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||d)&&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:"*"}),d?t.jsx(Fr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${f}`,children:r}),t.jsx(Pr,{error:o,helperText:n,helperDisplay:a})]})}function ef(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function xl(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=ef(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 Wt=260,_r=420,wo=380,Gt="cubic-bezier(0.22, 1, 0.36, 1)",tf="cubic-bezier(0.16, 1, 0.3, 1)",No="cubic-bezier(0.22, 1, 0.36, 1)",rf="cubic-bezier(0.22, 1, 0.36, 1)",nf=8,af=1,of=1.25,ko={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)"},sf="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",So=10;function gn(e,r,n){return Math.min(n,Math.max(r,e))}function lf(e,r,n){const a=(n||"").trim();if(a)return a.replace(/[\r\n"]/g," ");const o=(r||"").trim();if(o&&/\.[a-z0-9]{2,5}$/i.test(o))return o.replace(/[\r\n"]/g," ");try{const i=new URL(e,"http://local.invalid").pathname.split("/").pop()||"";if(i&&/\.[a-z0-9]{2,5}$/i.test(i))return decodeURIComponent(i).replace(/[\r\n"]/g," ")}catch{}return o||"imagen"}async function cf(e){const r=lf(e.src,e.alt,e.downloadName);try{const n=await fetch(e.src,{credentials:"include",cache:"no-store"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=r,l.rel="noopener",document.body.appendChild(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(o),6e4)}catch{const n=document.createElement("a");n.href=e.src,n.download=r,n.target="_blank",n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()}}function df(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function yl(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 yr({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:{...ko,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=sf,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(ko.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 wl({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=nf,minZoom:c=af,zoomStep:f=of,closeOnBackdrop:d=!0,closeOnEscape:h=!0,showCounter:b=!0,showZoomControls:u=!0,showDownload:p=!0,loop:v=!0,showThumbnails:w=!0,zIndex:g=1100,ariaLabel:E="Visor de imagen"}){const[y,M]=s.useState(!1),[L,C]=s.useState(!1),[m,k]=s.useState(a??0),[N,_]=s.useState(1),[q,K]=s.useState({x:0,y:0}),[$,Q]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[X,se]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[J,fe]=s.useState(!1),te=s.useRef(null),z=s.useRef(null),R=s.useRef(null),A=s.useRef(null),F=s.useRef(null),ue=s.useRef(!1),P=s.useRef(!1),oe=s.useRef(null),j=s.useRef(null),S=s.useRef(null),U=s.useRef(null),T=s.useRef(null),Y=s.useRef(a??0),ce=a??m,V=n.length===0?0:gn(ce,0,Math.max(0,n.length-1)),G=n[V],D=n.length>1,le=Math.max(c,i),be=w&&D,ie=s.useCallback(ve=>{if(n.length===0)return;const ke=n.length-1,Pe=v?(ve%n.length+n.length)%n.length:gn(ve,0,ke);a===void 0&&k(Pe),o==null||o(Pe)},[a,v,o,n.length]),ge=s.useCallback(()=>{_(1),K({x:0,y:0})},[]),$e=s.useCallback((ve,ke)=>{if(ke<=c+.001)return{x:0,y:0};const Pe=U.current,je=T.current;if(!Pe||!je)return ve;const Je=Pe.getBoundingClientRect(),at=je.offsetWidth*ke,st=je.offsetHeight*ke,tt=Math.max(0,(at-Je.width)/2+Je.width*.15),ct=Math.max(0,(st-Je.height)/2+Je.height*.15);return{x:gn(ve.x,-tt,tt),y:gn(ve.y,-ct,ct)}},[c]),De=s.useCallback(()=>{M(!1),se({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),A.current=null,F.current=null,ue.current=!1,P.current=!1,oe.current&&(clearTimeout(oe.current),oe.current=null)},[]),Nt=s.useCallback(()=>{if(ue.current)return;ue.current=!0,C(!1),ge();const ve=A.current,ke=ve!=null&&F.current!=null&&F.current===V;if(ve&&ke){R.current!=null&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{R.current=requestAnimationFrame(()=>{const Pe=T.current;if(!Pe){R.current=null,te.current&&clearTimeout(te.current),te.current=setTimeout(De,Wt+40);return}const je=Pe.getBoundingClientRect(),Je=yl(ve,je);se({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),R.current=requestAnimationFrame(()=>{se({enabled:!0,dx:Je.dx,dy:Je.dy,scale:Je.scale,animate:!0}),R.current=null})})}),te.current&&clearTimeout(te.current),te.current=setTimeout(De,_r+80);return}se({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),te.current&&clearTimeout(te.current),te.current=setTimeout(De,Wt+40)},[De,ge,V]);s.useEffect(()=>(e?(te.current&&clearTimeout(te.current),oe.current&&(clearTimeout(oe.current),oe.current=null),ue.current=!1,P.current=!1,A.current=df(l),F.current=A.current!=null?a??m:null,M(!0),C(!1),A.current?se({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(F.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{C(!0),se({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):y&&Nt(),()=>{te.current&&clearTimeout(te.current),R.current!=null&&cancelAnimationFrame(R.current)}),[e]);const yt=s.useCallback(()=>{if(!e||ue.current||P.current)return;const ve=A.current,ke=T.current;if(!ve||!ke){ve||(C(!0),P.current=!0);return}const Pe=ke.getBoundingClientRect();if(Pe.width<2||Pe.height<2)return;P.current=!0;const je=yl(ve,Pe);se({enabled:!0,dx:je.dx,dy:je.dy,scale:je.scale,animate:!1}),R.current!=null&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{R.current=requestAnimationFrame(()=>{se({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),C(!0),R.current=null,oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{se({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),oe.current=null},_r+20)})})},[e]);s.useLayoutEffect(()=>{!y||!e||!A.current||P.current||yt()},[y,e,yt]),s.useEffect(()=>{!e||ue.current||F.current!=null&&F.current!==V&&se(ve=>ve.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ve)},[e,V]),s.useEffect(()=>{if(!e)return;const ve=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ve}},[e]),s.useEffect(()=>{e&&ge()},[e,V,ge]),s.useEffect(()=>{a!==void 0&&k(a)},[a]),s.useEffect(()=>{if(!e){Y.current=V,Q({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ve=Y.current;if(ve===V)return;Y.current=V;const ke=n.length;let Pe=1;if(ke>1){const je=(ve+1)%ke===V,Je=(ve-1+ke)%ke===V;Je&&!je?Pe=-1:je&&!Je?Pe=1:Pe=V>ve?1:-1}return z.current!=null&&(cancelAnimationFrame(z.current),z.current=null),Q({opacity:0,x:Pe*56,scale:.94,blur:8,animate:!1}),z.current=requestAnimationFrame(()=>{z.current=requestAnimationFrame(()=>{Q({opacity:1,x:0,scale:1,blur:0,animate:!0}),z.current=null})}),()=>{z.current!=null&&(cancelAnimationFrame(z.current),z.current=null)}},[e,V,n.length]);const re=N<=c+.001&&Math.abs(q.x)<.5&&Math.abs(q.y)<.5,xe=s.useCallback((ve,ke,Pe)=>{_(je=>{const Je=gn(ve,c,le);if(Math.abs(Je-je)<1e-4)return je;const at=Je/je,st=Je<je;return Je<=c+.001?(K({x:0,y:0}),c):(K(tt=>{let ct=tt;if(typeof ke=="number"&&typeof Pe=="number"&&U.current&&!st){const ot=U.current.getBoundingClientRect(),Nr=ke-ot.left-ot.width/2,bt=Pe-ot.top-ot.height/2;ct={x:Nr-(Nr-tt.x)*at,y:bt-(bt-tt.y)*at}}else if(st){ct={x:tt.x*at,y:tt.y*at};const ot=Math.min(1,(je-Je)/Math.max(.01,je-c));ct={x:ct.x*(1-ot*.65),y:ct.y*(1-ot*.65)}}else ct={x:tt.x*at,y:tt.y*at};return $e(ct,Je)}),Je)})},[$e,c,le]),ae=s.useCallback(()=>{xe(N*f)},[xe,N,f]),we=s.useCallback(()=>{const ve=Math.max(c,N/f);if(ve<=c+.001){ge();return}_(ve),K({x:0,y:0})},[c,ge,N,f]);s.useEffect(()=>{if(!e)return;const ve=ke=>{if(ke.key==="Escape"&&h){ke.preventDefault(),r();return}ke.key==="ArrowLeft"&&D?(ke.preventDefault(),ie(V-1)):ke.key==="ArrowRight"&&D?(ke.preventDefault(),ie(V+1)):ke.key==="+"||ke.key==="="?(ke.preventDefault(),xe(N*f)):ke.key==="-"||ke.key==="_"?(ke.preventDefault(),we()):ke.key==="0"&&(ke.preventDefault(),ge())};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[xe,h,D,r,e,ge,V,N,ie,we,f]);const ne=ve=>{ve.preventDefault();const ke=ve.deltaY>0?1/f:f;xe(N*ke,ve.clientX,ve.clientY)},Oe=ve=>{N<=c+.001||(ve.currentTarget.setPointerCapture(ve.pointerId),fe(!0),j.current={pointerId:ve.pointerId,startX:ve.clientX,startY:ve.clientY,originX:q.x,originY:q.y})},qe=ve=>{const ke=j.current;!ke||ke.pointerId!==ve.pointerId||K($e({x:ke.originX+(ve.clientX-ke.startX),y:ke.originY+(ve.clientY-ke.startY)},N))},Qe=ve=>{var ke;((ke=j.current)==null?void 0:ke.pointerId)===ve.pointerId&&(j.current=null,fe(!1))},Ze=ve=>{if(ve.stopPropagation(),N>c+.05){ge();return}xe(Math.min(le,3),ve.clientX,ve.clientY)},Ue=ve=>{if(ve.touches.length!==2)return;fe(!0);const[ke,Pe]=[ve.touches[0],ve.touches[1]],je=Math.hypot(ke.clientX-Pe.clientX,ke.clientY-Pe.clientY);S.current={distance:je,scale:N}},et=ve=>{if(ve.touches.length!==2||!S.current)return;ve.preventDefault();const[ke,Pe]=[ve.touches[0],ve.touches[1]],je=Math.hypot(ke.clientX-Pe.clientX,ke.clientY-Pe.clientY),Je=(ke.clientX+Pe.clientX)/2,at=(ke.clientY+Pe.clientY)/2,st=S.current.scale*(je/Math.max(1,S.current.distance));xe(st,Je,at)},St=()=>{S.current=null,fe(!1)};if(!y||!G)return null;const vt=X.enabled,Ct=X.animate?`transform ${_r}ms ${rf}`:"none";return ft.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:g},role:"dialog","aria-modal":"true","aria-label":E,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:L?1:0,transition:`opacity ${vt?_r:Wt}ms ${Gt}`,cursor:"default",zIndex:0},onClick:()=>{d&&r()}}),t.jsx("div",{ref:U,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:be?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:vt||L?1:0,transform:vt||L?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:vt?"none":`opacity ${Wt}ms ${Gt}, transform ${Wt}ms ${Gt}`},onClick:ve=>{ve.target===ve.currentTarget&&d&&r()},onWheel:ne,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:X.enabled?`translate3d(${X.dx}px, ${X.dy}px, 0) scale(${X.scale})`:void 0,transformOrigin:"center center",transition:X.enabled?Ct:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:$.opacity,filter:$.blur?`blur(${$.blur}px)`:"blur(0px)",transform:`translate3d(${$.x}px, 0, 0) scale(${$.scale})`,transition:$.animate?[`opacity ${wo}ms ${No}`,`transform ${wo}ms ${No}`,`filter ${wo}ms ${No}`].join(", "):"none"},children:t.jsx("div",{ref:T,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:N>c+.001?"grab":"zoom-in",transform:`translate3d(${q.x}px, ${q.y}px, 0) scale(${N})`,transformOrigin:"center center",transition:J?"none":`transform 220ms ${tf}`},onClick:ve=>ve.stopPropagation(),onDoubleClick:Ze,onPointerDown:Oe,onPointerMove:qe,onPointerUp:Qe,onPointerCancel:Qe,onTouchStart:Ue,onTouchMove:et,onTouchEnd:St,children:t.jsx("img",{src:G.src,alt:G.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:So,imageRendering:N>2.5?"pixelated":"auto"},onLoad:()=>{yt()}},G.src+String(V))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:L?1:0,transform:L?"translateY(0)":"translateY(-6px)",transition:`opacity ${vt?_r:Wt}ms ${Gt}, transform ${vt?_r:Wt}ms ${Gt}`},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:ko,children:[V+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[u?t.jsxs(t.Fragment,{children:[t.jsx(yr,{label:"Alejar",onClick:we,disabled:N<=c+.001,children:t.jsx(H.HiMinus,{className:"h-5 w-5"})}),t.jsx(yr,{label:"Restablecer tamaño",onClick:ge,disabled:re,children:t.jsx(H.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(yr,{label:"Acercar",onClick:ae,disabled:N>=le-.001,children:t.jsx(H.HiPlus,{className:"h-5 w-5"})})]}):null,p&&(G!=null&&G.src)?t.jsx(yr,{label:"Descargar",onClick:()=>{cf(G)},children:t.jsx(H.HiArrowDownTray,{className:"h-5 w-5"})}):null,t.jsx(yr,{label:"Cerrar",onClick:r,children:t.jsx(H.HiXMark,{className:"h-5 w-5"})})]})]}),D?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:L?1:0,transform:L?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Wt}ms ${Gt}, transform ${Wt}ms ${Gt}`},children:t.jsx(yr,{label:"Anterior",size:"lg",onClick:()=>ie(V-1),disabled:!v&&V<=0,children:t.jsx(H.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:L?1:0,transform:L?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Wt}ms ${Gt}, transform ${Wt}ms ${Gt}`},children:t.jsx(yr,{label:"Siguiente",size:"lg",onClick:()=>ie(V+1),disabled:!v&&V>=n.length-1,children:t.jsx(H.HiChevronRight,{className:"h-6 w-6"})})})]}):null,be?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((ve,ke)=>{const Pe=ke===V;return t.jsx("button",{type:"button",role:"tab","aria-selected":Pe,"aria-label":ve.alt||`Imagen ${ke+1}`,onClick:je=>{je.stopPropagation(),ie(ke)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:So,opacity:Pe?1:.42,transition:`opacity 180ms ${Gt}`},children:t.jsx("img",{src:ve.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:So}})},`${ve.src}-${ke}`)})})}):null]})]}),document.body)}function uf({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:f,zIndex:d}){const[h,b]=s.useState(!1),[u,p]=s.useState(0),[v,w]=s.useState([]),[g,E]=s.useState(null),y=s.useCallback((L,C,m)=>{w(L),E(m??null),p(C),b(!0)},[]),M=s.useCallback(L=>{xl(L,y)},[y]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:M,children:e}),t.jsx(wl,{open:h,onClose:()=>b(!1),index:u,onIndexChange:p,slides:v,originRect:g,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:f,zIndex:d})]})}function ff(e,r){return e.includes(r)?e.filter(n=>n!==r):[...e,r]}function Co(e,r,n,a,o){const l=r.findIndex(u=>u.value===n),i=r.findIndex(u=>u.value===a);if(l<0||i<0)return o==="select"?e:ff(e,a);const c=r[i];if(o==="toggle-target"&&(c!=null&&c.disabled))return e;const f=o==="select"?!0:!e.includes(a),d=Math.min(l,i),h=Math.max(l,i),b=new Set;for(let u=d;u<=h;u+=1){const p=r[u];p&&!p.disabled&&b.add(p.value)}if(b.size===0)return e;if(f){const u=[...e],p=new Set(e);for(let v=d;v<=h;v+=1){const w=r[v];!w||w.disabled||p.has(w.value)||(u.push(w.value),p.add(w.value))}return u}return e.filter(u=>!b.has(u))}function bf(e,r){const n=r.filter(i=>!i.disabled);if(n.length===0)return e;const a=new Set(e);if(n.every(i=>a.has(i.value))){const i=new Set(n.map(c=>c.value));return e.filter(c=>!i.has(c))}const l=[...e];for(const i of n)a.has(i.value)||(l.push(i.value),a.add(i.value));return l}function Nl(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function kl(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Eo(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function hf(e,r){if(!r)return!0;const n=Eo(r);return Eo(e.label).includes(n)||!!(e.sublabel&&Eo(e.sublabel).includes(n))}function pf({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:f="6px 10px",searchable:d=!0,minOptionsForSearch:h=6,maxVisibleValues:b=2,truncateSelectedValues:u=!0,selectedOverflowPopover:p=!0,emptyText:v="Sin resultados",clearLabel:w="Limpiar seleccion",selectAllLabel:g="Seleccionar todo",pruneMissingValues:E=!0}){const[y,M]=s.useState(!1),[L,C]=s.useState(""),[m,k]=s.useState(0),[N,_]=s.useState(!1),[q,K]=s.useState({}),$=s.useRef(null),Q=s.useRef(null),X=s.useRef(null),se=s.useRef(null),J=s.useRef(null),fe=s.useRef(!1),te=s.useRef(!1),z=d&&n.length>=h,R=s.useMemo(()=>new Set(e),[e]),A=s.useMemo(()=>{const re=new Map;for(const xe of n)re.set(xe.value,xe);return re},[n]),F=s.useMemo(()=>{const re=[];for(const xe of e){const ae=A.get(xe);ae&&re.push(ae)}return re},[A,e]),ue=b==="all"?F.length:b,P=F.slice(0,ue),oe=Math.max(0,F.length-P.length),j=p&&F.length>1,S=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[F.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:F.map(re=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[re.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:re.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:re.label}),re.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:re.sublabel}):null]},re.value))})]}),U=s.useMemo(()=>{const re=L.trim();return!z||!re?n:n.filter(xe=>hf(xe,re))},[n,L,z]),T=s.useMemo(()=>U.filter(re=>!re.disabled),[U]),Y=T.length>0&&T.every(re=>R.has(re.value)),ce=!Y&&T.some(re=>R.has(re.value)),V=s.useCallback(()=>{const re=$.current;if(!re)return;const xe=re.getBoundingClientRect(),ae=z?304:244,we=window.innerHeight-xe.bottom,ne=we<ae&&xe.top>we;K({position:"fixed",left:xe.left,top:ne?void 0:xe.bottom+4,bottom:ne?window.innerHeight-xe.top+4:void 0,width:Math.max(xe.width,240),zIndex:9999})},[z]),G=s.useCallback(re=>{kl(e,re)||r(re)},[r,e]),D=s.useCallback(re=>{const xe=A.get(re);if(xe!=null&&xe.disabled)return;const ae=R.has(re)?e.filter(we=>we!==re):[...e,re];G(ae)},[G,A,e,R]),le=s.useCallback(()=>G([]),[G]),be=s.useCallback(()=>{G(bf(e,U))},[G,U,e]),ie=s.useCallback(()=>{M(!1),C(""),k(0),fe.current=!1},[]);s.useEffect(()=>_(!0),[]);const ge=s.useMemo(()=>n.map(re=>re.value).join("\0"),[n]);s.useEffect(()=>{if(!E||e.length===0||n.length===0)return;const re=new Set(n.map(ae=>ae.value)),xe=e.filter(ae=>re.has(ae));kl(e,xe)||r(xe)},[ge]),s.useEffect(()=>{if(!y)return;function re(xe){const ae=xe.target;if(!(ae instanceof Node)||!ae.isConnected)return;const we=xe.composedPath();Q.current&&(Q.current.contains(ae)||we.includes(Q.current))||$.current&&($.current.contains(ae)||we.includes($.current))||ie()}return document.addEventListener("mousedown",re,!0),()=>document.removeEventListener("mousedown",re,!0)},[ie,y]),s.useEffect(()=>{function re(){window.setTimeout(()=>{te.current=!1},0)}return window.addEventListener("mouseup",re),()=>window.removeEventListener("mouseup",re)},[]),s.useLayoutEffect(()=>{y&&V()},[y,F.length,V]),s.useEffect(()=>{y&&(fe.current=!1,k(0),V(),z&&setTimeout(()=>{var re;return(re=X.current)==null?void 0:re.focus()},0))},[y,z,V]),s.useEffect(()=>{if(y)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[y,V]),s.useEffect(()=>{if(U.length===0){k(0);return}k(re=>Math.min(re,U.length-1))},[U.length]),s.useEffect(()=>{if(m<0||!se.current)return;const re=se.current.children[m];re==null||re.scrollIntoView({block:"nearest"})},[m]);function $e(re,xe){if(fe.current=!0,U.length===0)return;const ae=Math.min(Math.max(m+re,0),U.length-1);if(xe){const we=U[m];!J.current&&we&&!we.disabled&&(J.current=we.value);const ne=J.current,Oe=U[ae];ne&&Oe&&G(Co(e,U,ne,Oe.value,"select"))}k(ae)}function De(re){const xe=U[m];if(!xe||xe.disabled)return;const ae=J.current;if(re&&ae&&ae!==xe.value){G(Co(e,U,ae,xe.value,"toggle-target"));return}D(xe.value),J.current=xe.value}function Nt(re){if(!o){if(!y){(re.key==="Enter"||re.key===" "||re.key==="ArrowDown")&&(re.preventDefault(),M(!0));return}if(re.key==="Escape"){re.preventDefault(),ie();return}if(re.key==="ArrowDown"){re.preventDefault(),$e(1,re.shiftKey);return}if(re.key==="ArrowUp"){re.preventDefault(),$e(-1,re.shiftKey);return}if(re.key===" "||re.key==="Spacebar"){if(re.target===X.current&&!re.shiftKey&&!fe.current)return;re.preventDefault(),De(re.shiftKey);return}if(re.key==="Enter"&&U[m]&&!U[m].disabled){re.preventDefault(),De(re.shiftKey);return}re.key==="Backspace"&&!L&&e.length&&(re.preventDefault(),G(e.slice(0,-1)))}}const yt=t.jsxs("div",{ref:Q,className:"overflow-hidden rounded-xl shadow-xl",onMouseDown:re=>{re.preventDefault(),re.stopPropagation(),te.current=!0},style:{...q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[z&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(H.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:X,value:L,onChange:re=>{fe.current=!1,C(re.target.value),k(0)},onKeyDown:re=>{const xe=re.key===" "||re.key==="Spacebar";xe&&!re.shiftKey&&!fe.current||(re.key==="ArrowDown"||re.key==="ArrowUp"||re.key==="Enter"||re.key==="Escape"||xe)&&(re.preventDefault(),re.stopPropagation(),Nt(re))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),L&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:re=>{re.preventDefault(),C(""),k(0)},children:t.jsx(H.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex animate-[multiSelectSummaryIn_180ms_ease-out] 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",{className:"inline-block animate-[multiSelectSummaryIn_180ms_ease-out]",children:[F.length," seleccionados",e.length>F.length?` (${e.length-F.length} no disponibles)`:""]},F.length),t.jsx("button",{type:"button",onMouseDown:re=>{re.preventDefault(),le()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:w})]}),T.length>0&&t.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:t.jsxs("button",{type:"button",role:"checkbox","aria-checked":Y?!0:ce?"mixed":!1,onMouseDown:re=>{re.preventDefault(),be()},className:"flex w-full min-w-0 items-center gap-2 text-left text-sm",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:Y||ce?"var(--primary)":"var(--border)",background:Y||ce?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[ce&&t.jsx(H.HiMinus,{className:"h-3 w-3"}),Y&&t.jsx(H.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"truncate font-medium",children:g})]})}),t.jsxs("ul",{ref:se,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:z?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[U.map((re,xe)=>{const ae=xe===m,we=R.has(re.value);return t.jsxs("li",{role:"option","aria-selected":we,onMouseDown:ne=>{if(ne.preventDefault(),re.disabled)return;k(xe);const Oe=J.current;if(ne.shiftKey&&Oe&&Oe!==re.value){G(Co(e,U,Oe,re.value,"toggle-target"));return}D(re.value),J.current=re.value},onMouseEnter:()=>!re.disabled&&k(xe),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:ae?"var(--bg-hover)":we?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:re.disabled?"var(--text-muted)":"var(--text-main)",cursor:re.disabled?"not-allowed":"pointer",opacity:re.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:we?"var(--primary)":"var(--border)",background:we?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:we&&t.jsx(H.HiCheck,{className:"h-3 w-3"})}),re.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:re.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Rt,{className:"min-w-0 flex-1",children:re.label}),re.sublabel&&t.jsx(Rt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:re.sublabel})]}),re.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:re.badge})]},re.value)}),U.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:v})]})]});return t.jsxs("div",{ref:$,className:`relative ${l||"w-full"}`,style:i,onKeyDown:Nt,children:[t.jsxs("button",{type:"button",disabled:o,onClick:re=>{if(te.current){re.preventDefault(),re.stopPropagation();return}o||(y?ie():M(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Nl(c),padding:Nl(f),background:"var(--bg-input)",color:F.length?"var(--text-main)":"var(--text-muted)",border:y?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":y,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:P.length?(()=>{const re=t.jsxs(t.Fragment,{children:[P.map(xe=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${u?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[xe.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:xe.color}}),u?t.jsx(Rt,{className:"min-w-0 flex-1",children:xe.label}):t.jsx("span",{className:"break-words",children:xe.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${xe.label}`,onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation(),D(xe.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(H.HiXMark,{className:"h-3 w-3"})})]},xe.value)),oe>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},"aria-label":`${oe} seleccionados más`,children:["+",oe]})]});return j?t.jsx(Vt,{as:"span",content:S,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:re}):re})():t.jsx("span",{className:"truncate",children:a})}),F.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":w,onMouseDown:re=>{re.preventDefault(),re.stopPropagation(),le()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(H.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(H.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:y?"rotate(180deg)":"rotate(0deg)"}})]}),y&&N&&ft.createPortal(yt,document.body)]})}function mf({inputMode:e="decimal",...r}){return t.jsx(yo,{...r,type:"number",inputMode:e})}function gf(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 vf({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),f=gf(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ke,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(H.HiChevronLeft,{className:"h-4 w-4"})}),f.map((d,h)=>d==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${h}`):t.jsx("button",{type:"button","aria-current":d===c?"page":void 0,disabled:a,onClick:()=>n(d),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:d===c?"var(--primary)":"var(--border)",background:d===c?"var(--primary)":"var(--bg-card)",color:d===c?"var(--primary-fg)":"var(--text-secondary)"},children:d},d)),t.jsx(Ke,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(H.HiChevronRight,{className:"h-4 w-4"})})]})}const Sl=[{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 Cl(e){return e==null?"":String(e)}function ea(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function xf(e){return typeof e=="number"?`${e}px`:e}function yf({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:f,countryCode:d,defaultCountryCode:h="+1",onCountryCodeChange:b,allowedCountryCodes:u,countryCodeOptions:p,countryCodePlaceholder:v="Codigo",countryCodeClassName:w="",countryCodeWidth:g=84,onPhoneValueChange:E,label:y,containerClassName:M="",helperText:L,helperDisplay:C="inline",labelAction:m,className:k="",required:N,disabled:_,floatingLabel:q,showPasswordToggle:K,nativeValidation:$,errorTooltipLabel:Q="Error de validacion",...X}){var D;const[se,J]=s.useState(()=>Cl(c)),[fe,te]=s.useState(()=>ea(h)),z=s.useMemo(()=>{const le=p??Sl,be=u==null?void 0:u.map(ea);return be!=null&&be.length?le.filter(ie=>be.includes(ie.value)):le},[u,p]),R=((D=z[0])==null?void 0:D.value)??"+1",A=z.some(le=>le.value===ea(d??fe))?ea(d??fe):R,F=i!==void 0?Cl(i):se,ue=`${A} ${F}`.trim(),P=n&&F.length>0&&!vo(ue)?a:void 0,oe=l??P,j=!!oe,S=j&&o!=="tooltip",U=j&&o!=="inline",T=!!L&&C==="tooltip"&&!S,Y=j?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ce=le=>{const be=le.currentTarget.value;i===void 0&&J(be),E==null||E(be,{countryCode:A,nationalNumber:be,fullNumber:`${A} ${be}`.trim()}),f==null||f(le)},V=le=>{d===void 0&&te(le),b==null||b(le),E==null||E(F,{countryCode:le,nationalNumber:F,fullNumber:`${le} ${F}`.trim()})},G=U?t.jsx(Vt,{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":Q,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(ml,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${M}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:y}),N&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),T?t.jsx(Fr,{content:L}):null,m&&t.jsx("span",{className:"ml-auto normal-case",children:m})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${Y}`,children:[t.jsx(vr,{value:A,onChange:V,options:z,placeholder:v,disabled:_,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${w}`,style:{width:xf(g)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...X,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:_,required:void 0,"aria-label":X["aria-label"]??(typeof y=="string"?y:void 0),"aria-invalid":j||X["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 ${U?"pr-10":""} ${k}`,onChange:ce}),G]})]}),t.jsx(Pr,{error:S?oe:void 0,helperText:L,helperDisplay:C})]})}function wf({value:e,onChange:r,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:f=""}){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(d=>{const h=d.value===e,b=i||d.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)]"} ${f}`,style:{borderColor:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:d.value,checked:h,disabled:b,onChange:()=>r(d.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:d.label}),d.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:d.description})]})]},d.value)})})]})}const Nf='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-clipboard" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M17.663 3.118c.225.015.45.032.673.05C19.876 3.298 21 4.604 21 6.109v9.642a3 3 0 0 1-3 3V16.5c0-5.922-4.576-10.775-10.384-11.217.324-1.132 1.3-2.01 2.548-2.114.224-.019.448-.036.673-.051A3 3 0 0 1 13.5 1.5H15a3 3 0 0 1 2.663 1.618ZM12 4.5A1.5 1.5 0 0 1 13.5 3H15a1.5 1.5 0 0 1 1.5 1.5H12Z" clip-rule="evenodd"></path><path d="M3 8.625c0-1.036.84-1.875 1.875-1.875h.375A3.75 3.75 0 0 1 9 10.5v1.875c0 1.036.84 1.875 1.875 1.875h1.875A3.75 3.75 0 0 1 16.5 18v2.625c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 0 1 3 20.625v-12Z"></path><path d="M10.5 10.5a5.23 5.23 0 0 0-1.279-3.434 9.768 9.768 0 0 1 6.963 6.963 5.23 5.23 0 0 0-3.434-1.279h-1.875a.375.375 0 0 1-.375-.375V10.5Z"></path></svg>',kf='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-check" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z" clip-rule="evenodd"></path></svg>';function El(){return`<button type="button" class="rich-code-copy" data-action="copy-code" title="Copiar" aria-label="Copiar">${Nf}${kf}</button>`}const Sf=new Set(["div","p","li","tr","pre","h1","h2","h3","h4","h5","h6"]);function Ml(e){const r=n=>{if(n.nodeType===Node.TEXT_NODE)return(n.textContent??"").replace(/\u00a0/g," ");if(n.nodeType!==Node.ELEMENT_NODE)return"";const a=n,o=a.tagName.toLowerCase();if(o==="br")return`
|
|
32
|
-
`;if(o==="script"||o==="style")return"";let l="";for(const i of Array.from(a.childNodes))l+=r(i);return
|
|
29
|
+
`&&p!=="`")break;E+=1}h("string",u.slice(0,E)),c+=E;continue}if((a||!o)&&(u.startsWith("</")||u.startsWith("<"))&&/^<\/?[A-Za-z]/.test(u)){const E=u.startsWith("</");h("punct",E?"</":"<"),c+=E?2:1,f=!0,d=!0;continue}if(f&&p===">"){h("punct",">"),f=!1,d=!1,c+=1;continue}const w=u.match(/^\d+(?:\.\d+)?/);if(w&&!f){h("number",w[0]),c+=w[0].length;continue}const v=u.match(/^[A-Za-z_$][\w$-]*/);if(v){const E=v[0];let y="plain";d?(y=/^[A-Z]/.test(E)?"component":"tag",d=!1):f?y="attr":!a&&!o&&!l&&Pu.has(E)?y="keyword":!a&&!o&&/^[A-Z]/.test(E)?y="component":l&&(y="attr"),h(y,E),c+=E.length;continue}h("punct",p),c+=1}const b=[[]];for(const u of i)u.text.split(`
|
|
30
|
+
`).forEach((g,w)=>{w>0&&b.push([]),g&&b[b.length-1].push({kind:u.kind,text:g})});return b}const Pl={plain:"#d4d4d4",comment:"#6a9955",string:"#ce9178",keyword:"#569cd6",number:"#b5cea8",tag:"#4fc1ff",attr:"#9cdcfe",component:"#4ec9b0",punct:"#d4d4d4"};function Wu(e,r){if(typeof e=="string"){const n=e.trim();if(/\.[a-z0-9]+$/i.test(n))return n;if(/prompt/i.test(n))return"prompt.txt";if(n&&!/^(codigo|código|code)$/i.test(n))return n}return`ejemplo.${Hl(r)}`}function ju({code:e,children:r,title:n="Codigo",language:a="tsx",copyLabel:o="Copiar",copiedLabel:l="Copiado",className:i="",style:c,showLineNumbers:f=!0,showModeToggle:d,defaultMode:h="code",onCopied:b}){const u=(e??r??"").replace(/^\n/,"").replace(/\s+$/,""),p=Bl(a),[g,w]=s.useState(p?h:"raw"),v=g==="code"&&p,E=v?zu(u,a):u.split(`
|
|
31
|
+
`).map(C=>[{kind:"plain",text:C}]),y=String(Math.max(E.length,1)).length,T=d??p,L=Wu(n,a);return t.jsxs("div",{className:`min-w-0 overflow-hidden rounded-xl border shadow-[0_16px_40px_rgba(2,6,23,0.28)] ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0d1117",color:"#e6edf3",...c},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b px-3 py-2",style:{borderColor:"rgba(148, 163, 184, 0.16)",background:"#161b22"},children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#ff5f57]"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#febc2e]"}),t.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#28c840]"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-[#c9d1d9]",children:L}),t.jsx("span",{className:"shrink-0 rounded-md bg-[#0d1117] px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-[#8b949e]",children:Hl(a)}),T&&t.jsxs("div",{className:"flex shrink-0 overflow-hidden rounded-md border border-white/10 text-[11px]",role:"group","aria-label":"Vista del codigo",children:[t.jsx("button",{type:"button",className:"px-2 py-1",style:{background:v?"#238636":"transparent",color:v?"#fff":"#8b949e"},"aria-pressed":v,onClick:()=>w("code"),children:"Codigo"}),t.jsx("button",{type:"button",className:"px-2 py-1",style:{background:v?"transparent":"#238636",color:v?"#8b949e":"#fff"},"aria-pressed":!v,onClick:()=>w("raw"),children:"Raw"})]}),t.jsx(vo,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:t.jsx("span",{className:"hidden sm:inline",children:l}),onCopied:b,className:"h-7 shrink-0 px-2",style:{background:"#21262d",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f0f6fc"},children:t.jsx("span",{className:"hidden sm:inline",children:o})})]}),t.jsx("div",{className:"max-h-[min(28rem,70vh)] overflow-auto",children:t.jsx("div",{className:"grid min-w-max py-3 text-[12px] leading-6 sm:text-[13px]",style:{gridTemplateColumns:f?"auto minmax(0, 1fr)":"minmax(0, 1fr)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:E.map((C,m)=>t.jsxs("div",{className:"contents",children:[f&&t.jsx("span",{"aria-hidden":!0,className:"sticky left-0 select-none border-r px-3 text-right",style:{minWidth:`${y+2}ch`,color:"#6e7681",borderColor:"rgba(148, 163, 184, 0.16)",background:"#0d1117"},children:m+1}),t.jsx("code",{className:"whitespace-pre px-3",children:C.length===0?" ":C.map((S,N)=>t.jsx("span",{style:{color:v?Pl[S.kind]:Pl.plain},children:S.text},N))})]},m))})})]})}function ta(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function qu({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(F.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:ta(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:ta(o),padding:ta(l)}})]})}function Uu({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:f=10,searchable:d=!0}){const h=o?n.map((b,u)=>u===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:ta(f)},children:o}),t.jsx(yr,{value:e,onChange:r,options:h,placeholder:a,searchable:d,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Vu={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},ra=180,Xu="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function xo({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:f="md",maxWidth:d,zIndex:h=1e3,closeOnBackdrop:b=!0,closeOnEscape:u=!0,showCloseButton:p=!0,placement:g="center",bodyClassName:w="px-6 py-5",panelClassName:v="",backdropClassName:E=Xu,contentClassName:y="p-4",ariaLabel:T,frameless:L=!1,disabled:C=!1}){const[m,S]=s.useState(!1),[N,_]=s.useState(!1),U=s.useRef(null);if(s.useEffect(()=>(e?(U.current&&clearTimeout(U.current),S(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>_(!0)))):(_(!1),U.current=setTimeout(()=>S(!1),ra+40)),()=>{U.current&&clearTimeout(U.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!u)return;const ee=fe=>{fe.key==="Escape"&&r()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[u,r,e]),!m)return null;const K=n||a||o||l||p,D=d??Vu[f],Z=g==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",O=g==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=N?"translateY(0) scale(1)":g==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return bt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":T??n,className:`fixed inset-0 flex ${Z} ${y}`,style:{zIndex:h},children:[t.jsx("div",{className:`absolute inset-0 ${E}`,onClick:b?r:void 0,style:{opacity:N?1:0,transition:`opacity ${ra}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${L?"shadow-none":"shadow-2xl"} ${O} ${v}`,style:{maxWidth:D,background:L?"transparent":"var(--bg-card)",border:L?"none":"1px solid var(--border)",opacity:N?1:0,transform:ne,transition:`opacity ${ra}ms ease, transform ${ra}ms ease`},onClick:ee=>ee.stopPropagation(),children:[C&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),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,p&&t.jsx(Ke,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(F.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${w}`,children:c}),i&&t.jsx("div",{className:"flex min-w-0 flex-shrink-0 flex-wrap justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const Yu={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 Gu({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:f}){const d=Yu[l];return t.jsx(xo,{open:e,onClose:f,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ke,{variant:"icon",onClick:f,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(F.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:d.iconBg},children:t.jsx(F.HiExclamationTriangle,{className:"h-5 w-5",style:{color:d.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ke,{variant:"secondary",onClick:f,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ke,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:d.btnBg,color:d.btnColor,borderColor:"transparent"},children:a})]})]})})}function Ku(e){return e?typeof e=="function"?e():e:""}function Zu(e){return/^https?:\/\//i.test(e)}function _l(e,r){try{return new URL(e,r).toString()}catch{return e}}function Qu(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||Zu(l))return l;const i=Ku(n);return i?_l(l,i):a&&typeof window<"u"?_l(l,window.location.origin):l}function Ju({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(F.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(vo,{...c,value:()=>Qu(e,r,n,a),title:o,copiedTitle:l,icon:i})}const Ru={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 ef(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=Ru[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 tf=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function rf({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),f=(n==null?void 0:n.preset)==="date",d=f?"date":r==="number"?"number":"text";return s.useEffect(()=>{var h,b;(h=c.current)==null||h.focus(),f||(b=c.current)==null||b.select()},[f]),t.jsx("input",{ref:c,type:d,value:l,maxLength:n==null?void 0:n.maxLength,onChange:h=>i(h.target.value),onBlur:()=>o(),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),a(l)),h.key==="Escape"&&(h.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!tf.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function nf({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,f;(f=(c=l.current)==null?void 0:c.querySelector("button"))==null||f.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(yr,{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 af={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},yo={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function of({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(r),f=s.useRef(null);s.useEffect(()=>{f.current||c(r)},[r]);const[d,h]=s.useState(null);f.current=d;const[b,u]=s.useState(null),p=s.useRef(null);p.current=b;const[g,w]=s.useState({}),[v,E]=s.useState(null),y=s.useRef(null);y.current=v;const[T,L]=s.useState({}),[C,m]=s.useState({}),S=s.useRef(new Set),N=s.useRef(null);s.useEffect(()=>{var P;const $=document.activeElement;(!$||$===document.body)&&((P=N.current)==null||P.focus({preventScroll:!0}))},[]);const _=e.map($=>{var P,ue,z;return`${$.key}:${((z=(ue=(P=$.editable)==null?void 0:P.select)==null?void 0:ue.options)==null?void 0:z.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach($=>{var z,se;const P=(se=(z=$.editable)==null?void 0:z.select)==null?void 0:se.options;if(!P)return;const ue=T[$.key];(!S.current.has($.key)||(ue==null?void 0:ue.length)===0&&P.length>0)&&(S.current.add($.key),L(q=>({...q,[$.key]:P})))})},[_]);const U=s.useCallback(async($,P)=>{if(S.current.has($))return;S.current.add($);const{url:ue,fetchOptions:z}=P.select??{};if(!(!ue&&!z)){m(se=>({...se,[$]:!0}));try{let se=[];if(z)se=await z();else if(ue){const q=await fetch(ue);if(!q.ok)throw new Error("fetch failed");se=await q.json()}L(q=>({...q,[$]:se}))}catch{L(se=>({...se,[$]:[]}))}finally{m(se=>({...se,[$]:!1}))}}},[]),K=s.useRef(i);K.current=i;const D=s.useRef(a);D.current=a;const Z=s.useRef(n);Z.current=n;const O=s.useRef(e);O.current=e;const ne=s.useRef(o);ne.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const $=e.find(P=>P.selectable!==!1);$&&u({rowId:n(r[0]),colKey:$.key})}},[]),s.useEffect(()=>{if(!b)return;const $=N.current;if(!$)return;const P=$.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!P)return;const ue=$.querySelector('[role="rowgroup"]');P.style.scrollMarginTop=`${(ue==null?void 0:ue.offsetHeight)??0}px`;const z=$.querySelector('[role="row"]');let se=0;z&&z.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(q=>{q.style.position==="sticky"&&q.style.left!==""&&(se=Math.max(se,parseFloat(q.style.left)+q.offsetWidth))}),P.style.scrollMarginLeft=`${se}px`,P.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const ee=s.useCallback($=>{var se;const P=O.current,ue=new Set,z=[];(se=N.current)==null||se.querySelectorAll("[data-cell-id]").forEach(q=>{const k=q.dataset.cellId.split(":")[0];ue.has(k)||(ue.add(k),z.push(k))}),u(q=>{if(!q)return q;const k=P.findIndex(ce=>ce.key===q.colKey),V=z.indexOf(q.rowId);let M=k,Y=V;if($==="up")Y=Math.max(0,V-1);else if($==="down")Y=Math.min(z.length-1,V+1);else if($==="left"){let ce=k-1;for(;ce>=0&&P[ce].selectable===!1;)ce--;ce>=0&&(M=ce)}else if($==="right"){let ce=k+1;for(;ce<P.length&&P[ce].selectable===!1;)ce++;ce<P.length&&(M=ce)}return M===k&&Y===V?q:{rowId:z[Y],colKey:P[M].key}})},[]),fe=s.useCallback(($=!0)=>{const P=f.current;h(null),P&&u(P),$&&setTimeout(()=>{var ue;return(ue=N.current)==null?void 0:ue.focus({preventScroll:!0})},0)},[]),J=s.useCallback(async($,P,ue)=>{var ie;const z=O.current.find(ge=>ge.key===P);if(!(z!=null&&z.editable))return;const{field:se,type:q,mask:k,validate:V}=z.editable,M=q==="number"?ue===""?null:Number(ue):ue;if(k){const ge=ef(ue,k);if(ge){w($e=>({...$e,[`${$}:${P}`]:ge}));return}}if(V){const ge=V(M);if(ge){w($e=>({...$e,[`${$}:${P}`]:ge}));return}}const Y=Z.current,ce=K.current.find(ge=>Y(ge)===$);if(!ce)return;const X=ce[se];h(null),w(ge=>{const $e={...ge};return delete $e[`${$}:${P}`],$e});const G=K.current,I=G.findIndex(ge=>Y(ge)===$),le=G[Math.min(G.length-1,I+1)];if(u({rowId:Y(le),colKey:P}),setTimeout(()=>{var $e,De;const ge=document.activeElement;(!ge||ge===document.body||($e=N.current)!=null&&$e.contains(ge))&&((De=N.current)==null||De.focus({preventScroll:!0}))},0),String(X??"")===String(M??""))return;const be={...ce,[se]:M};c(ge=>ge.map($e=>Y($e)===$?be:$e)),E({rowId:$,colKey:P});try{await((ie=D.current)==null?void 0:ie.call(D,{row:ce,rowId:$,field:se,oldValue:X,newValue:M}))}catch{c(ge=>ge.map($e=>Y($e)===$?ce:$e)),w(ge=>({...ge,[`${$}:${P}`]:"Error al guardar. Intenta de nuevo."}))}finally{E(null)}},[]),W=s.useCallback($=>{if(y.current){$.preventDefault();return}if(f.current)return;const P=p.current;if(!(!P||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes($.key)))switch($.preventDefault(),$.key){case"ArrowUp":ee("up");break;case"ArrowDown":ee("down");break;case"ArrowLeft":ee("left");break;case"ArrowRight":ee("right");break;case"Tab":ee($.shiftKey?"left":"right");break;case"Enter":{const z=O.current.find(se=>se.key===P.colKey);z!=null&&z.editable&&!ne.current?(h(P),z.editable.type==="select"&&!S.current.has(P.colKey)&&U(P.colKey,z.editable)):ee("down");break}}},[ee,U]),R=s.useMemo(()=>e.map($=>{if(!$.editable||o){const ue={...$};if(delete ue.editable,delete ue.selectable,$.selectable===!1)return{...ue,disableRowClick:!0};const z=ue.cell;return{...ue,className:`relative ${ue.className??""}`.trim(),disableRowClick:!0,cell:se=>{const q=n(se),k=(b==null?void 0:b.rowId)===q&&(b==null?void 0:b.colKey)===$.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${q}:${$.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var V;y.current||(u({rowId:q,colKey:$.key}),(V=N.current)==null||V.focus({preventScroll:!0}))}}),k&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:yo}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:z(se)})]})}}}const P=$.editable;return{...$,className:`relative ${$.className??""}`.trim(),disableRowClick:!0,cell:ue=>{const z=n(ue),se=$.key,q=(d==null?void 0:d.rowId)===z&&(d==null?void 0:d.colKey)===se,k=(b==null?void 0:b.rowId)===z&&(b==null?void 0:b.colKey)===se,V=g[`${z}:${se}`],M=(v==null?void 0:v.rowId)===z&&(v==null?void 0:v.colKey)===se,Y=ue[P.field],ce=String(Y??""),X=()=>{var I;y.current||(u({rowId:z,colKey:se}),h({rowId:z,colKey:se}),(I=N.current)==null||I.focus({preventScroll:!0}),P.type==="select"&&!S.current.has(se)&&U(se,P))};if(q){const I=P.type==="select"?t.jsx(nf,{initialValue:ce,options:T[se]??[],loading:C[se]??!1,onCommit:le=>J(z,se,le),onCancel:fe}):t.jsx(rf,{initialValue:ce,type:P.type??"text",mask:P.mask,onCommit:le=>J(z,se,le),onCancel:fe});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:af,onClick:le=>le.stopPropagation(),children:I})}const G=$.cell(ue);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${z}:${se}`,className:`peer absolute inset-0 z-10 ${M?"cursor-wait":"cursor-pointer"}`,onClick:X}),k&&!M&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:yo}),M&&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:yo,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:V?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(F.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:V})]}):t.jsx("span",{className:"truncate",children:G})}),!M&&t.jsx(F.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,d,b,v,g,T,C,n,J,fe,U]);return t.jsx("div",{ref:N,tabIndex:0,onKeyDown:W,onBlur:$=>{var P;(P=N.current)!=null&&P.contains($.relatedTarget)||setTimeout(()=>{var z,se;const ue=document.activeElement;ue&&((z=ue.closest)!=null&&z.call(ue,"[data-bonsaif-select-dropdown]"))||(se=N.current)!=null&&se.contains(ue)||fe(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(fo,{...l,columns:R,data:i,getRowId:n})})}function vt(e){if(e)return new Date(`${e}T12:00:00`)}function Wt(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 Pr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function zl(e){return e.map(r=>vt(r)).filter(r=>!!r)}function sf(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Wt));return Array.from(r).sort()}function wo(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Wl(e){const r=vt(e);if(!r)return e;const n=wo(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 No={weekend:{dayOfWeek:[0,6]}},ko={weekend:"bonsaif-weekend"};function So({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 lf={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},cf={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function df({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?lf:null,...o?cf:null,...l?{fontWeight:800}:null,...n.style}})}function uf({startDate:e,endDate:r,onChange:n,minDate:a,maxDate:o,viewMonth:l,numberOfMonths:i=1,orientation:c="horizontal",showSummary:f=!0,startLabel:d="Inicio",endLabel:h="Regreso",className:b=""}){const u={from:vt(e),to:vt(r)},p=vt(a),g=vt(o),w=[...p?[{before:p}]:[],...g?[{after:g}]:[]],[v,E]=s.useState(()=>vt(l||e)??new Date);s.useEffect(()=>{const m=vt(l||e);m&&E(m)},[l,e]);const y=s.useMemo(()=>{if(i<=1)return Pr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(v));const m=new Date(v.getFullYear(),v.getMonth()+i-1,1),S=v.getFullYear()===m.getFullYear(),N=new Intl.DateTimeFormat("es-MX",{month:"short",...S?{}:{year:"numeric"}}).format(v),_=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(m);return`${Pr(N)} – ${Pr(_)}`},[v,i]);function T(){E(new Date(v.getFullYear(),v.getMonth()-1,1))}function L(){E(new Date(v.getFullYear(),v.getMonth()+1,1))}const C=i>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${c}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${b}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:T,children:t.jsx(F.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:y}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:L,children:t.jsx(F.HiChevronRight,{size:16})})]}),t.jsx(to.DayPicker,{mode:"range",selected:u,month:v,onMonthChange:E,onSelect:m=>{const S=m!=null&&m.from?Wt(m.from):e,N=m!=null&&m.to?Wt(m.to):"";n({startDate:S,endDate:N})},numberOfMonths:i,hideNavigation:!0,weekStartsOn:1,disabled:w.length>0?w:void 0,showOutsideDays:!1,modifiers:No,modifiersClassNames:ko,components:{DayButton:df,Weekday:So},classNames:{root:"bonsaif-range-daypicker w-full",months:C,month:i>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:i>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:m=>`${Pr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(m))} ${m.getFullYear()}`,formatWeekdayName:wo}})]}),f?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:[h,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function jl({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:f=>{var d;i||(n==null||n(e.date,f),(d=l.onPointerDown)==null||d.call(l,f))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:f=>{i||(f.preventDefault(),f.stopPropagation(),o==null||o(e.date,f))}})}function ql(e,r){const n=vt(e),a=vt(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(Wt(c)),c.setDate(c.getDate()+1);return i}function Ul(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 vn(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 ff(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function bf(e,r,n){return!!(r&&e<r||n&&e>n)}function Vl({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const f=s.useRef(null),d=s.useRef(null),h=s.useRef(!1),b=s.useRef(e);b.current=e;const u=s.useCallback(C=>{let m=C;if(c){const S=b.current.filter(_=>!_.startsWith(c)),N=C.filter(_=>_.startsWith(c));m=[...S,...N].sort()}r==null||r(ff(m,l))},[l,r,c]),p=s.useCallback((C,m=!1)=>bf(C,a,o)?!0:!(!(i!=null&&i(C))||m&&b.current.includes(C)),[i,o,a]),g=s.useCallback(C=>C.filter(m=>!p(m)),[p]),w=s.useCallback(()=>{d.current=null},[]);s.useEffect(()=>{const C=()=>w();return window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),()=>{window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C)}},[w]);const v=s.useCallback((C,m,S,N)=>{const _=g(ql(C,m));u(S==="add"?vn(N,_,"add"):vn(N,_,"remove"))},[u,g]),E=s.useCallback((C,m)=>{if(n||m.button!==0)return;const S=Wt(C);if(p(S,!0)||m.shiftKey)return;h.current=!0;const N=[...b.current],_=N.includes(S)?"remove":"add";_==="add"&&p(S)||(d.current={active:!0,mode:_,anchor:S,latest:S,baseline:N},f.current=S,v(S,S,_,N),m.preventDefault())},[v,n,p]),y=s.useCallback(C=>{const m=d.current;if(!(m!=null&&m.active)||n)return;const S=Wt(C);m.mode==="add"&&p(S)||m.latest!==S&&(m.latest=S,v(m.anchor,S,m.mode,m.baseline))},[v,n,p]),T=s.useCallback((C,m)=>{if(n)return;const S=Wt(C);if(!p(S,!0)){if(h.current&&!m.shiftKey){h.current=!1,m.preventDefault(),m.stopPropagation();return}if(h.current=!1,m.shiftKey&&f.current){m.preventDefault(),m.stopPropagation();const N=g(ql(f.current,S));u(vn(b.current,N,"add"));return}!b.current.includes(S)&&p(S)||(f.current=S,u(vn(b.current,[S],"toggle")))}},[u,n,g,p]),L=s.useCallback(C=>{if(n)return;const m=g(sf(C));if(!m.length)return;const S=m.every(N=>b.current.includes(N));u(vn(b.current,m,S?"remove":"add")),f.current=m[0]??f.current},[u,n,g]);return{onDayPointerDown:E,onDayPointerEnter:y,onDayClick:T,toggleWeek:L,endDrag:w}}function xn(e){return Ul(e,1)[0]}function Xl(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function hf({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:f,defaultViewMode:d="month",onViewModeChange:h,showSummary:b=!0,className:u="",disabled:p=!1}){const g=s.useMemo(()=>zl(e),[e]),w=s.useMemo(()=>new Set(e),[e]),v=vt(n),E=vt(a),[y,T]=s.useState(()=>vt(l||e[0])??new Date),[L,C]=s.useState(()=>xn(vt(l||e[0])??new Date)),[m,S]=s.useState(d),N=f??m;function _($){f===void 0&&S($),h==null||h($)}s.useEffect(()=>{const $=vt(l);$&&(T($),C(xn($)))},[l]);const{onDayPointerDown:U,onDayPointerEnter:K,onDayClick:D,toggleWeek:Z}=Vl({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),O=s.useMemo(()=>{if(p)return!0;const $=[];return v&&$.push({before:v}),E&&$.push({after:E}),o&&$.push(P=>o(Wt(P))),$.length>0?$:void 0},[p,o,E,v]),ne=s.useCallback($=>t.jsx(jl,{...$,className:`bonsaif-multi-day-btn ${$.className??""}`,onDayPointerDown:U,onDayPointerEnter:K,onDayClickSelect:D}),[D,U,K]),ee=s.useMemo(()=>Ul(L,1),[L]),fe=ee[6],J=N==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(ee[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(fe)}`:Pr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(y));function W(){if(N==="week"){const $=Xl(L,-7);C(xn($)),T($);return}T(new Date(y.getFullYear(),y.getMonth()-1,1))}function R(){if(N==="week"){const $=Xl(L,7);C(xn($)),T($);return}T(new Date(y.getFullYear(),y.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${u}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":N==="month",className:`bonsaif-cal-view-btn${N==="month"?" is-active":""}`,disabled:p,onClick:()=>{_("month"),T(L)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":N==="week",className:`bonsaif-cal-view-btn${N==="week"?" is-active":""}`,disabled:p,onClick:()=>{_("week"),C(xn(y))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:W,children:t.jsx(F.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:J}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:R,children:t.jsx(F.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&N==="month"?" · Semana (nº)":"",N==="week"?" · Botón semana completa":""]}),N==="month"?t.jsx(to.DayPicker,{mode:"multiple",required:!1,selected:g,month:y,onMonthChange:T,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:($,P)=>{Z(P)},disabled:O,className:"bonsaif-multi-daypicker",modifiers:No,modifiersClassNames:ko,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:So},formatters:{formatWeekdayName:wo}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:ee.map($=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format($)},`h-${Wt($)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:ee.map($=>{const P=Wt($),ue=w.has(P),z=p||(n?P<n:!1)||(a?P>a:!1)||!!(o!=null&&o(P)),se=P===Wt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ue?" bonsaif-multi-day-selected":""}${se?" bonsaif-multi-day-today":""}${z?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:z,"aria-pressed":ue,onPointerDown:q=>U($,q),onPointerEnter:()=>K($),onClick:q=>D($,q),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:$.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format($)})]})},P)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>Z(ee),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map($=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(P=>P!==$)),title:`Quitar ${$}`,children:[Wl($),t.jsx("span",{"aria-hidden":!0,children:"×"})]},$))})]})}):null]})}const pf=Array.from({length:12},(e,r)=>r);function mf({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:f="",disabled:d=!1,readOnly:h=!1}){const b=s.useMemo(()=>zl(e),[e]),u=vt(o),p=vt(l),g=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[w,v]=s.useState(g);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function E(N){v(N),a==null||a(N)}const{onDayPointerDown:y,onDayPointerEnter:T,onDayClick:L}=Vl({value:e,onChange:r,disabled:d||h,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${w}-`}),C=s.useCallback(N=>t.jsx(jl,{...N,className:`bonsaif-year-day-btn ${N.className??""}`,onDayPointerDown:y,onDayPointerEnter:T,onDayClickSelect:L}),[L,y,T]),m=b.filter(N=>N.getFullYear()===w),S=d?!0:[...u?[{before:u}]:[],...p?[{after:p}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${h?" bonsaif-year-multi-date-calendar--readonly":""} ${f}`,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:d,onClick:()=>E(w-1),children:t.jsx(F.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:w}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:d,onClick:()=>E(w+1),children:t.jsx(F.HiChevronRight,{size:16})})]}),!h&&!d?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:pf.map(N=>{const _=new Date(w,N,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Pr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(_))}),t.jsx(to.DayPicker,{mode:"multiple",required:!1,selected:m,month:_,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:S,className:"bonsaif-year-month-picker",modifiers:No,modifiersClassNames:ko,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:C,Weekday:So},formatters:{formatWeekdayName:U=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(U)}})]},`${w}-${N}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",w]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(N=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:d||h,onClick:()=>r==null?void 0:r(e.filter(_=>_!==N)),title:`Quitar ${N}`,children:[Wl(N),t.jsx("span",{"aria-hidden":!0,children:"×"})]},N))})]})}):null]})}const gf="bonsaif-ui:hide-tooltips";function Yl(){window.dispatchEvent(new CustomEvent(gf))}function vf(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function xf({trigger:e,items:r,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[f,d]=s.useState(!1),[h,b]=s.useState(!1),[u,p]=s.useState({}),g=s.useRef(null),w=s.useRef(null),v=s.useCallback(C=>{d(C),c==null||c(C)},[c]),E=s.useCallback(()=>{const C=g.current;if(!C)return;const m=C.getBoundingClientRect(),S=typeof a=="number"?a:m.width,N=typeof a=="number"?a:Math.max(m.width,180),_=n==="end"?Math.max(8,m.right-N):Math.min(m.left,window.innerWidth-N-8),U=window.innerHeight-m.bottom,K=U<240&&m.top>U?void 0:m.bottom+6,D=K===void 0?window.innerHeight-m.top+6:void 0;p({position:"fixed",zIndex:9999,left:_,top:K,bottom:D,width:vf(typeof a=="number"?S:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!f)return;E();const C=S=>{var _,U;const N=S.target;!((_=g.current)!=null&&_.contains(N))&&!((U=w.current)!=null&&U.contains(N))&&v(!1)},m=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",C),window.addEventListener("keydown",m),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("keydown",m),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[f,v,E]);const y=C=>{o||(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),v(!f))},T=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(Yl(),v(!f))}}):e,L=f?t.jsx("div",{ref:w,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:u,children:r.map(C=>t.jsxs("div",{children:[C.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:C.disabled,onClick:()=>{var m;C.disabled||(Yl(),(m=C.onSelect)==null||m.call(C),v(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:C.danger?"var(--danger)":"var(--text-main)"},children:[C.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:C.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:C.label}),C.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:C.description})]})]})]},C.id))}):null;return t.jsxs("span",{ref:g,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":f,onKeyDown:y,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[T,h&&L?bt.createPortal(L,document.body):null]})}const yf=180,Gl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function wf({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:f=!1,headerActions:d,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:u=!1,unsavedChangesTitle:p="Descartar cambios",unsavedChangesDescription:g="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:w="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:E,disabled:y=!1,disabledMessage:T,children:L}){const[C,m]=s.useState(!1),[S,N]=s.useState(!1),[_,U]=s.useState(!1),K=s.useCallback(()=>{N(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>U(!0))})},[]),D=s.useCallback(()=>{U(!1),window.setTimeout(()=>N(!1),yf)},[]),Z=y||c,O=s.useCallback(()=>{if(!Z){if(u){K();return}r()}},[Z,u,r,K]),ne=s.useCallback(()=>{U(!1),N(!1),E==null||E(),r()},[r,E]);if(s.useEffect(()=>{m(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(U(!1),N(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const fe=J=>{if(J.key==="Escape"&&!Z){if(S){D();return}O()}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[D,Z,S,e,O]),!C)return null;const ee=T!==void 0?T:c?"Guardando…":null;return bt.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 ${Gl}`,onClick:O}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ke,{variant:"icon",onClick:O,title:"Cerrar",disabled:Z,children:t.jsx(F.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})]})]}),(d||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ke,{variant:"secondary",size:"sm",onClick:O,disabled:Z,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ke,{variant:"primary",size:"sm",icon:t.jsx(vd.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:f||Z,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:h,children:L}),Z&&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:ee?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:ee})]}):null})]}),S&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Gl} transition-opacity duration-200 ease-out ${_?"opacity-100":"opacity-0"}`,onClick:D}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${_?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ke,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":v,children:t.jsx(F.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(F.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:p}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:g}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ke,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Ke,{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:w})]})]})]})]}),document.body)}const Nf=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,kf=/^\+?[0-9\s().-]+$/,Sf=7,Cf=15;function Gt(e){return e==null||String(e).trim()===""}function Kl(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function Co(e){return Gt(e)?!1:Nf.test(String(e))}function Eo(e){if(Gt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return kf.test(r)&&n.length>=Sf&&n.length<=Cf}function Ef(e="Este campo es requerido."){return r=>Gt(r)?e:void 0}function Mf(e="Ingresa un correo valido."){return r=>Gt(r)||Co(r)?void 0:e}function Tf(e="Ingresa un telefono valido."){return r=>Gt(r)||Eo(r)?void 0:e}function Af(e,r){return n=>Gt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Lf(e,r){return n=>Gt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function $f(e,r){return n=>{if(Gt(n))return;const a=Kl(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Df(e,r){return n=>{if(Gt(n))return;const a=Kl(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function If(e,r="El formato no es valido."){return n=>Gt(n)||e.test(String(n))?void 0:r}function Ff(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 Zl={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ql=s.createContext&&s.createContext(Zl),Of=["attr","size","title"];function Hf(e,r){if(e==null)return{};var n,a,o=Bf(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 Bf(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 na(){return na=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},na.apply(null,arguments)}function Jl(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 aa(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Jl(Object(n),!0).forEach(function(a){Pf(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jl(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Pf(e,r,n){return(r=_f(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function _f(e){var r=zf(e,"string");return typeof r=="symbol"?r:r+""}function zf(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 Rl(e){return e&&e.map((r,n)=>s.createElement(r.tag,aa({key:n},r.attr),Rl(r.child)))}function Mo(e){return r=>s.createElement(Wf,na({attr:aa({},e.attr)},r),Rl(e.child))}function Wf(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Hf(e,Of),c=o||n.size||"1em",f;return n.className&&(f=n.className),e.className&&(f=(f?f+" ":"")+e.className),s.createElement("svg",na({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:f,style:aa(aa({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 Ql!==void 0?s.createElement(Ql.Consumer,null,n=>r(n)):r(Zl)}function ei(e){return Mo({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 jf(e){return Mo({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 qf(e){return Mo({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(e)}function _r({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Xt,{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(F.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function zr({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 oa({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:f=!1,showPasswordToggle:d=!0,nativeValidation:h=!1,className:b="",required:u,...p}){const[g,w]=s.useState(()=>!!p.autoFocus),[v,E]=s.useState(!1),y=p.type==="password"&&d,T=y&&v?"text":p.type,L=!!o,C=L&&l!=="tooltip",m=L&&l!=="inline",S=!!n&&a==="tooltip"&&!C,N=h?u:void 0,_=L?"border-[var(--danger)] focus:border-[var(--danger)]":"",U=m?y?"pr-20":"pr-10":y?"pr-10":"",K=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,D=g||K,Z={top:D?7:12,color:g?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},O=W=>{var R;w(!0),(R=p.onFocus)==null||R.call(p,W)},ne=W=>{var R;w(!1),(R=p.onBlur)==null||R.call(p,W)},ee=y?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(W=>!W),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(jf,{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(qf,{className:"h-[18px] w-[18px]"})})]}):null,fe=m?t.jsx(Xt,{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)] ${y?"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(ei,{className:"h-[18px] w-[18px]"})})}):null,J=t.jsx(zr,{error:C?o:void 0,helperText:n,helperDisplay:a});return f?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(oa,{...p,type:T,required:N,placeholder:" ","aria-invalid":L||p["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${U} ${_} ${b}`,onFocus:O,onBlur:ne}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[e,u&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:D?7:12},children:c}),fe,ee]}),J]}):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}),u&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),S?t.jsx(_r,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),y?t.jsxs("span",{className:"relative block",children:[t.jsx(oa,{...p,type:T,required:N,"aria-invalid":L||p["aria-invalid"],className:`w-full ${U} ${_} ${b}`,onFocus:O,onBlur:ne}),fe,ee]}):t.jsxs("span",{className:"relative block",children:[t.jsx(oa,{...p,required:N,"aria-invalid":L||p["aria-invalid"],className:`w-full ${U} ${_} ${b}`}),fe]}),J]})}function ti(e){return e==null?"":String(e)}function Uf({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:f,...d}){const[h,b]=s.useState(()=>ti(c)),u=i!==void 0?ti(i):h,p=n&&u.length>0&&!Co(u)?a:void 0,g=w=>{i===void 0&&b(w.currentTarget.value),f==null||f(w)};return t.jsx(To,{...d,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??p,errorDisplay:o,onChange:g})}const Vf={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Xf(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 ri(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 Yf(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Gf({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:f,multiple:d=!1,maxFiles:h,appendFiles:b=!1,showFileList:u=!0,clearable:p=!0,browseLabel:g="Buscar archivos",dropLabel:w="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:E="o haz click para buscarlos en tu equipo",selectedLabel:y="Archivos seleccionados",size:T="md",containerClassName:L="",dropzoneClassName:C="",fileListClassName:m="",className:S="",id:N,accept:_,disabled:U,required:K,...D}){const Z=s.useId(),O=N??Z,ne=s.useRef(null),[ee,fe]=s.useState(!1),[J,W]=s.useState(i),R=l??J,$=!!a,P=!!r&&n==="tooltip"&&!$,ue=p&&R.length>0&&!U,z=(I,le)=>{l===void 0&&W(I),c==null||c(I,le)},se=(I,le)=>{const be=I.filter(De=>ri(De,_)),ie=I.filter(De=>!ri(De,_)),ge=b?[...R,...be]:be,$e=Yf(ge,d,h);ie.length>0&&(f==null||f(ie)),z($e,le)},q=()=>{var I;U||(I=ne.current)==null||I.click()},k=I=>{se(Array.from(I.target.files??[]),I),I.target.value=""},V=I=>{I.preventDefault(),U||fe(!0)},M=I=>{I.currentTarget.contains(I.relatedTarget)||fe(!1)},Y=I=>{I.preventDefault(),fe(!1),!U&&se(Array.from(I.dataTransfer.files),I)},ce=I=>{I.key!=="Enter"&&I.key!==" "||(I.preventDefault(),q())},X=I=>{z(R.filter((le,be)=>be!==I))},G=()=>{z([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${L}`,children:[(e||o||P)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),K&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),P?t.jsx(_r,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:ne,id:O,type:"file",accept:_,multiple:d,disabled:U,required:K&&R.length===0,"aria-invalid":$||D["aria-invalid"],className:"sr-only",onChange:k}),t.jsxs("div",{role:"button",tabIndex:U?-1:0,"aria-controls":O,"aria-disabled":U||void 0,"aria-invalid":$||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Vf[T]} ${ee?"border-[var(--primary)] bg-[var(--bg-input)]":$?"border-[var(--danger)]":"border-[var(--border)]"} ${U?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${C} ${S}`,onClick:q,onDragOver:V,onDragLeave:M,onDrop:Y,onKeyDown:ce,children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(F.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:ee?w:v}),E&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:E})]}),g&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:g})]}),u&&R.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${m}`,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:y}),ue&&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:G,children:t.jsx(F.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:R.map((I,le)=>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(F.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:I.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Xf(I.size)})]}),!U&&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 ${I.name}`,onClick:()=>X(le),children:t.jsx(F.HiXMark,{className:"h-4 w-4"})})]},`${I.name}-${I.lastModified}-${le}`))})]}),t.jsx(zr,{error:a,helperText:r,helperDisplay:n})]})}const Kf=[{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 Zf({fields:e,title:r="Layout",fieldTypes:n=Kf,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:f,onChange:d}){const[h,b]=s.useState(()=>e.map(T=>({key:!1,type:"",...T}))),[u,p]=s.useState(""),[g,w]=s.useState(""),v=s.useCallback((T,L)=>{b(C=>{const m=C.map((S,N)=>N===T?{...S,...L}:S);return d==null||d(m),m})},[d]),E=s.useCallback(()=>{f==null||f(h)},[h,f]),y=s.useCallback(()=>{var m;const T=u.trim();if(!T){w("Ingresa un nombre de campo.");return}if(h.some(S=>S.name.toLowerCase()===T.toLowerCase())){w("Ese campo ya existe en el arreglo.");return}const C={name:T,key:!1,type:((m=n[0])==null?void 0:m.value)??""};b(S=>{const N=[...S,C];return d==null||d(N),N}),p(""),w("")},[n,h,u,d]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[h.map((T,L)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:T.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Xn,{size:"sm",checked:T.key??!1,onChange:C=>v(L,{key:C.target.checked}),"aria-label":`${T.name} es clave`})}),t.jsx(yr,{value:T.type??"",onChange:C=>v(L,{type:C}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${T.name}`})]},T.name)),h.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:u,onChange:T=>{p(T.currentTarget.value),g&&w("")},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),y())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ke,{variant:"secondary",onClick:y,height:36,padding:"0 12px",children:i})]}),g&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:g})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ke,{variant:"primary",onClick:E,disabled:c,loading:c,children:a})})]})})]})}function sa({label:e,children:r,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:f=""}){const d=!!n&&a==="tooltip"&&!o;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||d)&&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:"*"}),d?t.jsx(_r,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${f}`,children:r}),t.jsx(zr,{error:o,helperText:n,helperDisplay:a})]})}function Qf(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function ni(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=Qf(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 jt=260,Wr=420,Ao=380,Kt="cubic-bezier(0.22, 1, 0.36, 1)",Jf="cubic-bezier(0.16, 1, 0.3, 1)",Lo="cubic-bezier(0.22, 1, 0.36, 1)",Rf="cubic-bezier(0.22, 1, 0.36, 1)",eb=8,tb=1,rb=1.25,$o={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)"},nb="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",Do=10;function yn(e,r,n){return Math.min(n,Math.max(r,e))}function ab(e,r,n){const a=(n||"").trim();if(a)return a.replace(/[\r\n"]/g," ");const o=(r||"").trim();if(o&&/\.[a-z0-9]{2,5}$/i.test(o))return o.replace(/[\r\n"]/g," ");try{const i=new URL(e,"http://local.invalid").pathname.split("/").pop()||"";if(i&&/\.[a-z0-9]{2,5}$/i.test(i))return decodeURIComponent(i).replace(/[\r\n"]/g," ")}catch{}return o||"imagen"}async function ob(e){const r=ab(e.src,e.alt,e.downloadName);try{const n=await fetch(e.src,{credentials:"include",cache:"no-store"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=r,l.rel="noopener",document.body.appendChild(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(o),6e4)}catch{const n=document.createElement("a");n.href=e.src,n.download=r,n.target="_blank",n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()}}function sb(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function ai(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 Nr({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:{...$o,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=nb,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String($o.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 oi({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=eb,minZoom:c=tb,zoomStep:f=rb,closeOnBackdrop:d=!0,closeOnEscape:h=!0,showCounter:b=!0,showZoomControls:u=!0,showDownload:p=!0,loop:g=!0,showThumbnails:w=!0,zIndex:v=1100,ariaLabel:E="Visor de imagen"}){const[y,T]=s.useState(!1),[L,C]=s.useState(!1),[m,S]=s.useState(a??0),[N,_]=s.useState(1),[U,K]=s.useState({x:0,y:0}),[D,Z]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[O,ne]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ee,fe]=s.useState(!1),J=s.useRef(null),W=s.useRef(null),R=s.useRef(null),$=s.useRef(null),P=s.useRef(null),ue=s.useRef(!1),z=s.useRef(!1),se=s.useRef(null),q=s.useRef(null),k=s.useRef(null),V=s.useRef(null),M=s.useRef(null),Y=s.useRef(a??0),ce=a??m,X=n.length===0?0:yn(ce,0,Math.max(0,n.length-1)),G=n[X],I=n.length>1,le=Math.max(c,i),be=w&&I,ie=s.useCallback(ve=>{if(n.length===0)return;const ke=n.length-1,_e=g?(ve%n.length+n.length)%n.length:yn(ve,0,ke);a===void 0&&S(_e),o==null||o(_e)},[a,g,o,n.length]),ge=s.useCallback(()=>{_(1),K({x:0,y:0})},[]),$e=s.useCallback((ve,ke)=>{if(ke<=c+.001)return{x:0,y:0};const _e=V.current,je=M.current;if(!_e||!je)return ve;const Re=_e.getBoundingClientRect(),ot=je.offsetWidth*ke,lt=je.offsetHeight*ke,rt=Math.max(0,(ot-Re.width)/2+Re.width*.15),dt=Math.max(0,(lt-Re.height)/2+Re.height*.15);return{x:yn(ve.x,-rt,rt),y:yn(ve.y,-dt,dt)}},[c]),De=s.useCallback(()=>{T(!1),ne({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),$.current=null,P.current=null,ue.current=!1,z.current=!1,se.current&&(clearTimeout(se.current),se.current=null)},[]),kt=s.useCallback(()=>{if(ue.current)return;ue.current=!0,C(!1),ge();const ve=$.current,ke=ve!=null&&P.current!=null&&P.current===X;if(ve&&ke){R.current!=null&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{R.current=requestAnimationFrame(()=>{const _e=M.current;if(!_e){R.current=null,J.current&&clearTimeout(J.current),J.current=setTimeout(De,jt+40);return}const je=_e.getBoundingClientRect(),Re=ai(ve,je);ne({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),R.current=requestAnimationFrame(()=>{ne({enabled:!0,dx:Re.dx,dy:Re.dy,scale:Re.scale,animate:!0}),R.current=null})})}),J.current&&clearTimeout(J.current),J.current=setTimeout(De,Wr+80);return}ne({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),J.current&&clearTimeout(J.current),J.current=setTimeout(De,jt+40)},[De,ge,X]);s.useEffect(()=>(e?(J.current&&clearTimeout(J.current),se.current&&(clearTimeout(se.current),se.current=null),ue.current=!1,z.current=!1,$.current=sb(l),P.current=$.current!=null?a??m:null,T(!0),C(!1),$.current?ne({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(P.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{C(!0),ne({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):y&&kt(),()=>{J.current&&clearTimeout(J.current),R.current!=null&&cancelAnimationFrame(R.current)}),[e]);const wt=s.useCallback(()=>{if(!e||ue.current||z.current)return;const ve=$.current,ke=M.current;if(!ve||!ke){ve||(C(!0),z.current=!0);return}const _e=ke.getBoundingClientRect();if(_e.width<2||_e.height<2)return;z.current=!0;const je=ai(ve,_e);ne({enabled:!0,dx:je.dx,dy:je.dy,scale:je.scale,animate:!1}),R.current!=null&&cancelAnimationFrame(R.current),R.current=requestAnimationFrame(()=>{R.current=requestAnimationFrame(()=>{ne({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),C(!0),R.current=null,se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{ne({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),se.current=null},Wr+20)})})},[e]);s.useLayoutEffect(()=>{!y||!e||!$.current||z.current||wt()},[y,e,wt]),s.useEffect(()=>{!e||ue.current||P.current!=null&&P.current!==X&&ne(ve=>ve.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ve)},[e,X]),s.useEffect(()=>{if(!e)return;const ve=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ve}},[e]),s.useEffect(()=>{e&&ge()},[e,X,ge]),s.useEffect(()=>{a!==void 0&&S(a)},[a]),s.useEffect(()=>{if(!e){Y.current=X,Z({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ve=Y.current;if(ve===X)return;Y.current=X;const ke=n.length;let _e=1;if(ke>1){const je=(ve+1)%ke===X,Re=(ve-1+ke)%ke===X;Re&&!je?_e=-1:je&&!Re?_e=1:_e=X>ve?1:-1}return W.current!=null&&(cancelAnimationFrame(W.current),W.current=null),Z({opacity:0,x:_e*56,scale:.94,blur:8,animate:!1}),W.current=requestAnimationFrame(()=>{W.current=requestAnimationFrame(()=>{Z({opacity:1,x:0,scale:1,blur:0,animate:!0}),W.current=null})}),()=>{W.current!=null&&(cancelAnimationFrame(W.current),W.current=null)}},[e,X,n.length]);const re=N<=c+.001&&Math.abs(U.x)<.5&&Math.abs(U.y)<.5,xe=s.useCallback((ve,ke,_e)=>{_(je=>{const Re=yn(ve,c,le);if(Math.abs(Re-je)<1e-4)return je;const ot=Re/je,lt=Re<je;return Re<=c+.001?(K({x:0,y:0}),c):(K(rt=>{let dt=rt;if(typeof ke=="number"&&typeof _e=="number"&&V.current&&!lt){const st=V.current.getBoundingClientRect(),Sr=ke-st.left-st.width/2,ht=_e-st.top-st.height/2;dt={x:Sr-(Sr-rt.x)*ot,y:ht-(ht-rt.y)*ot}}else if(lt){dt={x:rt.x*ot,y:rt.y*ot};const st=Math.min(1,(je-Re)/Math.max(.01,je-c));dt={x:dt.x*(1-st*.65),y:dt.y*(1-st*.65)}}else dt={x:rt.x*ot,y:rt.y*ot};return $e(dt,Re)}),Re)})},[$e,c,le]),oe=s.useCallback(()=>{xe(N*f)},[xe,N,f]),we=s.useCallback(()=>{const ve=Math.max(c,N/f);if(ve<=c+.001){ge();return}_(ve),K({x:0,y:0})},[c,ge,N,f]);s.useEffect(()=>{if(!e)return;const ve=ke=>{if(ke.key==="Escape"&&h){ke.preventDefault(),r();return}ke.key==="ArrowLeft"&&I?(ke.preventDefault(),ie(X-1)):ke.key==="ArrowRight"&&I?(ke.preventDefault(),ie(X+1)):ke.key==="+"||ke.key==="="?(ke.preventDefault(),xe(N*f)):ke.key==="-"||ke.key==="_"?(ke.preventDefault(),we()):ke.key==="0"&&(ke.preventDefault(),ge())};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[xe,h,I,r,e,ge,X,N,ie,we,f]);const ae=ve=>{ve.preventDefault();const ke=ve.deltaY>0?1/f:f;xe(N*ke,ve.clientX,ve.clientY)},Fe=ve=>{N<=c+.001||(ve.currentTarget.setPointerCapture(ve.pointerId),fe(!0),q.current={pointerId:ve.pointerId,startX:ve.clientX,startY:ve.clientY,originX:U.x,originY:U.y})},qe=ve=>{const ke=q.current;!ke||ke.pointerId!==ve.pointerId||K($e({x:ke.originX+(ve.clientX-ke.startX),y:ke.originY+(ve.clientY-ke.startY)},N))},Je=ve=>{var ke;((ke=q.current)==null?void 0:ke.pointerId)===ve.pointerId&&(q.current=null,fe(!1))},Ze=ve=>{if(ve.stopPropagation(),N>c+.05){ge();return}xe(Math.min(le,3),ve.clientX,ve.clientY)},Ue=ve=>{if(ve.touches.length!==2)return;fe(!0);const[ke,_e]=[ve.touches[0],ve.touches[1]],je=Math.hypot(ke.clientX-_e.clientX,ke.clientY-_e.clientY);k.current={distance:je,scale:N}},tt=ve=>{if(ve.touches.length!==2||!k.current)return;ve.preventDefault();const[ke,_e]=[ve.touches[0],ve.touches[1]],je=Math.hypot(ke.clientX-_e.clientX,ke.clientY-_e.clientY),Re=(ke.clientX+_e.clientX)/2,ot=(ke.clientY+_e.clientY)/2,lt=k.current.scale*(je/Math.max(1,k.current.distance));xe(lt,Re,ot)},Ct=()=>{k.current=null,fe(!1)};if(!y||!G)return null;const xt=O.enabled,Et=O.animate?`transform ${Wr}ms ${Rf}`:"none";return bt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:v},role:"dialog","aria-modal":"true","aria-label":E,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:L?1:0,transition:`opacity ${xt?Wr:jt}ms ${Kt}`,cursor:"default",zIndex:0},onClick:()=>{d&&r()}}),t.jsx("div",{ref:V,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:be?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:xt||L?1:0,transform:xt||L?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:xt?"none":`opacity ${jt}ms ${Kt}, transform ${jt}ms ${Kt}`},onClick:ve=>{ve.target===ve.currentTarget&&d&&r()},onWheel:ae,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:O.enabled?`translate3d(${O.dx}px, ${O.dy}px, 0) scale(${O.scale})`:void 0,transformOrigin:"center center",transition:O.enabled?Et:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:D.opacity,filter:D.blur?`blur(${D.blur}px)`:"blur(0px)",transform:`translate3d(${D.x}px, 0, 0) scale(${D.scale})`,transition:D.animate?[`opacity ${Ao}ms ${Lo}`,`transform ${Ao}ms ${Lo}`,`filter ${Ao}ms ${Lo}`].join(", "):"none"},children:t.jsx("div",{ref:M,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:N>c+.001?"grab":"zoom-in",transform:`translate3d(${U.x}px, ${U.y}px, 0) scale(${N})`,transformOrigin:"center center",transition:ee?"none":`transform 220ms ${Jf}`},onClick:ve=>ve.stopPropagation(),onDoubleClick:Ze,onPointerDown:Fe,onPointerMove:qe,onPointerUp:Je,onPointerCancel:Je,onTouchStart:Ue,onTouchMove:tt,onTouchEnd:Ct,children:t.jsx("img",{src:G.src,alt:G.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:Do,imageRendering:N>2.5?"pixelated":"auto"},onLoad:()=>{wt()}},G.src+String(X))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:L?1:0,transform:L?"translateY(0)":"translateY(-6px)",transition:`opacity ${xt?Wr:jt}ms ${Kt}, transform ${xt?Wr:jt}ms ${Kt}`},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:$o,children:[X+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[u?t.jsxs(t.Fragment,{children:[t.jsx(Nr,{label:"Alejar",onClick:we,disabled:N<=c+.001,children:t.jsx(F.HiMinus,{className:"h-5 w-5"})}),t.jsx(Nr,{label:"Restablecer tamaño",onClick:ge,disabled:re,children:t.jsx(F.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Nr,{label:"Acercar",onClick:oe,disabled:N>=le-.001,children:t.jsx(F.HiPlus,{className:"h-5 w-5"})})]}):null,p&&(G!=null&&G.src)?t.jsx(Nr,{label:"Descargar",onClick:()=>{ob(G)},children:t.jsx(F.HiArrowDownTray,{className:"h-5 w-5"})}):null,t.jsx(Nr,{label:"Cerrar",onClick:r,children:t.jsx(F.HiXMark,{className:"h-5 w-5"})})]})]}),I?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:L?1:0,transform:L?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${jt}ms ${Kt}, transform ${jt}ms ${Kt}`},children:t.jsx(Nr,{label:"Anterior",size:"lg",onClick:()=>ie(X-1),disabled:!g&&X<=0,children:t.jsx(F.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:L?1:0,transform:L?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${jt}ms ${Kt}, transform ${jt}ms ${Kt}`},children:t.jsx(Nr,{label:"Siguiente",size:"lg",onClick:()=>ie(X+1),disabled:!g&&X>=n.length-1,children:t.jsx(F.HiChevronRight,{className:"h-6 w-6"})})})]}):null,be?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((ve,ke)=>{const _e=ke===X;return t.jsx("button",{type:"button",role:"tab","aria-selected":_e,"aria-label":ve.alt||`Imagen ${ke+1}`,onClick:je=>{je.stopPropagation(),ie(ke)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:Do,opacity:_e?1:.42,transition:`opacity 180ms ${Kt}`},children:t.jsx("img",{src:ve.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:Do}})},`${ve.src}-${ke}`)})})}):null]})]}),document.body)}function lb({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:f,zIndex:d}){const[h,b]=s.useState(!1),[u,p]=s.useState(0),[g,w]=s.useState([]),[v,E]=s.useState(null),y=s.useCallback((L,C,m)=>{w(L),E(m??null),p(C),b(!0)},[]),T=s.useCallback(L=>{ni(L,y)},[y]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:T,children:e}),t.jsx(oi,{open:h,onClose:()=>b(!1),index:u,onIndexChange:p,slides:g,originRect:v,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:f,zIndex:d})]})}function ib(e,r){return e.includes(r)?e.filter(n=>n!==r):[...e,r]}function Io(e,r,n,a,o){const l=r.findIndex(u=>u.value===n),i=r.findIndex(u=>u.value===a);if(l<0||i<0)return o==="select"?e:ib(e,a);const c=r[i];if(o==="toggle-target"&&(c!=null&&c.disabled))return e;const f=o==="select"?!0:!e.includes(a),d=Math.min(l,i),h=Math.max(l,i),b=new Set;for(let u=d;u<=h;u+=1){const p=r[u];p&&!p.disabled&&b.add(p.value)}if(b.size===0)return e;if(f){const u=[...e],p=new Set(e);for(let g=d;g<=h;g+=1){const w=r[g];!w||w.disabled||p.has(w.value)||(u.push(w.value),p.add(w.value))}return u}return e.filter(u=>!b.has(u))}function cb(e,r){const n=r.filter(i=>!i.disabled);if(n.length===0)return e;const a=new Set(e);if(n.every(i=>a.has(i.value))){const i=new Set(n.map(c=>c.value));return e.filter(c=>!i.has(c))}const l=[...e];for(const i of n)a.has(i.value)||(l.push(i.value),a.add(i.value));return l}function si(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function li(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Fo(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function db(e,r){if(!r)return!0;const n=Fo(r);return Fo(e.label).includes(n)||!!(e.sublabel&&Fo(e.sublabel).includes(n))}function ub({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:f="6px 10px",searchable:d=!0,minOptionsForSearch:h=6,maxVisibleValues:b=2,truncateSelectedValues:u=!0,selectedOverflowPopover:p=!0,emptyText:g="Sin resultados",clearLabel:w="Limpiar seleccion",selectAllLabel:v="Seleccionar todo",pruneMissingValues:E=!0}){const[y,T]=s.useState(!1),[L,C]=s.useState(""),[m,S]=s.useState(0),[N,_]=s.useState(!1),[U,K]=s.useState({}),D=s.useRef(null),Z=s.useRef(null),O=s.useRef(null),ne=s.useRef(null),ee=s.useRef(null),fe=s.useRef(!1),J=s.useRef(!1),W=d&&n.length>=h,R=s.useMemo(()=>new Set(e),[e]),$=s.useMemo(()=>{const re=new Map;for(const xe of n)re.set(xe.value,xe);return re},[n]),P=s.useMemo(()=>{const re=[];for(const xe of e){const oe=$.get(xe);oe&&re.push(oe)}return re},[$,e]),ue=b==="all"?P.length:b,z=P.slice(0,ue),se=Math.max(0,P.length-z.length),q=p&&P.length>1,k=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:[P.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:P.map(re=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[re.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:re.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:re.label}),re.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:re.sublabel}):null]},re.value))})]}),V=s.useMemo(()=>{const re=L.trim();return!W||!re?n:n.filter(xe=>db(xe,re))},[n,L,W]),M=s.useMemo(()=>V.filter(re=>!re.disabled),[V]),Y=M.length>0&&M.every(re=>R.has(re.value)),ce=!Y&&M.some(re=>R.has(re.value)),X=s.useCallback(()=>{const re=D.current;if(!re)return;const xe=re.getBoundingClientRect(),oe=W?304:244,we=window.innerHeight-xe.bottom,ae=we<oe&&xe.top>we;K({position:"fixed",left:xe.left,top:ae?void 0:xe.bottom+4,bottom:ae?window.innerHeight-xe.top+4:void 0,width:Math.max(xe.width,240),zIndex:9999})},[W]),G=s.useCallback(re=>{li(e,re)||r(re)},[r,e]),I=s.useCallback(re=>{const xe=$.get(re);if(xe!=null&&xe.disabled)return;const oe=R.has(re)?e.filter(we=>we!==re):[...e,re];G(oe)},[G,$,e,R]),le=s.useCallback(()=>G([]),[G]),be=s.useCallback(()=>{G(cb(e,V))},[G,V,e]),ie=s.useCallback(()=>{T(!1),C(""),S(0),fe.current=!1},[]);s.useEffect(()=>_(!0),[]);const ge=s.useMemo(()=>n.map(re=>re.value).join("\0"),[n]);s.useEffect(()=>{if(!E||e.length===0||n.length===0)return;const re=new Set(n.map(oe=>oe.value)),xe=e.filter(oe=>re.has(oe));li(e,xe)||r(xe)},[ge]),s.useEffect(()=>{if(!y)return;function re(xe){const oe=xe.target;if(!(oe instanceof Node)||!oe.isConnected)return;const we=xe.composedPath();Z.current&&(Z.current.contains(oe)||we.includes(Z.current))||D.current&&(D.current.contains(oe)||we.includes(D.current))||ie()}return document.addEventListener("mousedown",re,!0),()=>document.removeEventListener("mousedown",re,!0)},[ie,y]),s.useEffect(()=>{function re(){window.setTimeout(()=>{J.current=!1},0)}return window.addEventListener("mouseup",re),()=>window.removeEventListener("mouseup",re)},[]),s.useLayoutEffect(()=>{y&&X()},[y,P.length,X]),s.useEffect(()=>{y&&(fe.current=!1,S(0),X(),W&&setTimeout(()=>{var re;return(re=O.current)==null?void 0:re.focus()},0))},[y,W,X]),s.useEffect(()=>{if(y)return window.addEventListener("resize",X),window.addEventListener("scroll",X,!0),()=>{window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)}},[y,X]),s.useEffect(()=>{if(V.length===0){S(0);return}S(re=>Math.min(re,V.length-1))},[V.length]),s.useEffect(()=>{if(m<0||!ne.current)return;const re=ne.current.children[m];re==null||re.scrollIntoView({block:"nearest"})},[m]);function $e(re,xe){if(fe.current=!0,V.length===0)return;const oe=Math.min(Math.max(m+re,0),V.length-1);if(xe){const we=V[m];!ee.current&&we&&!we.disabled&&(ee.current=we.value);const ae=ee.current,Fe=V[oe];ae&&Fe&&G(Io(e,V,ae,Fe.value,"select"))}S(oe)}function De(re){const xe=V[m];if(!xe||xe.disabled)return;const oe=ee.current;if(re&&oe&&oe!==xe.value){G(Io(e,V,oe,xe.value,"toggle-target"));return}I(xe.value),ee.current=xe.value}function kt(re){if(!o){if(!y){(re.key==="Enter"||re.key===" "||re.key==="ArrowDown")&&(re.preventDefault(),T(!0));return}if(re.key==="Escape"){re.preventDefault(),ie();return}if(re.key==="ArrowDown"){re.preventDefault(),$e(1,re.shiftKey);return}if(re.key==="ArrowUp"){re.preventDefault(),$e(-1,re.shiftKey);return}if(re.key===" "||re.key==="Spacebar"){if(re.target===O.current&&!re.shiftKey&&!fe.current)return;re.preventDefault(),De(re.shiftKey);return}if(re.key==="Enter"&&V[m]&&!V[m].disabled){re.preventDefault(),De(re.shiftKey);return}re.key==="Backspace"&&!L&&e.length&&(re.preventDefault(),G(e.slice(0,-1)))}}const wt=t.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",onMouseDown:re=>{re.preventDefault(),re.stopPropagation(),J.current=!0},style:{...U,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[W&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(F.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:O,value:L,onChange:re=>{fe.current=!1,C(re.target.value),S(0)},onKeyDown:re=>{const xe=re.key===" "||re.key==="Spacebar";xe&&!re.shiftKey&&!fe.current||(re.key==="ArrowDown"||re.key==="ArrowUp"||re.key==="Enter"||re.key==="Escape"||xe)&&(re.preventDefault(),re.stopPropagation(),kt(re))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),L&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:re=>{re.preventDefault(),C(""),S(0)},children:t.jsx(F.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex animate-[multiSelectSummaryIn_180ms_ease-out] 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",{className:"inline-block animate-[multiSelectSummaryIn_180ms_ease-out]",children:[P.length," seleccionados",e.length>P.length?` (${e.length-P.length} no disponibles)`:""]},P.length),t.jsx("button",{type:"button",onMouseDown:re=>{re.preventDefault(),le()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:w})]}),M.length>0&&t.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:t.jsxs("button",{type:"button",role:"checkbox","aria-checked":Y?!0:ce?"mixed":!1,onMouseDown:re=>{re.preventDefault(),be()},className:"flex w-full min-w-0 items-center gap-2 text-left text-sm",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:Y||ce?"var(--primary)":"var(--border)",background:Y||ce?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[ce&&t.jsx(F.HiMinus,{className:"h-3 w-3"}),Y&&t.jsx(F.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"truncate font-medium",children:v})]})}),t.jsxs("ul",{ref:ne,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:W?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[V.map((re,xe)=>{const oe=xe===m,we=R.has(re.value);return t.jsxs("li",{role:"option","aria-selected":we,onMouseDown:ae=>{if(ae.preventDefault(),re.disabled)return;S(xe);const Fe=ee.current;if(ae.shiftKey&&Fe&&Fe!==re.value){G(Io(e,V,Fe,re.value,"toggle-target"));return}I(re.value),ee.current=re.value},onMouseEnter:()=>!re.disabled&&S(xe),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:oe?"var(--bg-hover)":we?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:re.disabled?"var(--text-muted)":"var(--text-main)",cursor:re.disabled?"not-allowed":"pointer",opacity:re.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:we?"var(--primary)":"var(--border)",background:we?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:we&&t.jsx(F.HiCheck,{className:"h-3 w-3"})}),re.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:re.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(er,{className:"min-w-0 flex-1",children:re.label}),re.sublabel&&t.jsx(er,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:re.sublabel})]}),re.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:re.badge})]},re.value)}),V.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:g})]})]});return t.jsxs("div",{ref:D,className:`relative ${l||"w-full"}`,style:i,onKeyDown:kt,children:[t.jsxs("button",{type:"button",disabled:o,onClick:re=>{if(J.current){re.preventDefault(),re.stopPropagation();return}o||(y?ie():T(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:si(c),padding:si(f),background:"var(--bg-input)",color:P.length?"var(--text-main)":"var(--text-muted)",border:y?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":y,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:z.length?(()=>{const re=t.jsxs(t.Fragment,{children:[z.map(xe=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${u?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[xe.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:xe.color}}),u?t.jsx(er,{className:"min-w-0 flex-1",children:xe.label}):t.jsx("span",{className:"break-words",children:xe.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${xe.label}`,onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation(),I(xe.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(F.HiXMark,{className:"h-3 w-3"})})]},xe.value)),se>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":`${se} seleccionados más`,children:["+",se]})]});return q?t.jsx(Xt,{as:"span",content:k,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:re}):re})():t.jsx("span",{className:"truncate",children:a})}),P.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":w,onMouseDown:re=>{re.preventDefault(),re.stopPropagation(),le()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(F.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(F.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:y?"rotate(180deg)":"rotate(0deg)"}})]}),y&&N&&bt.createPortal(wt,document.body)]})}function fb({inputMode:e="decimal",...r}){return t.jsx(To,{...r,type:"number",inputMode:e})}function bb(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 hb({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),f=bb(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ke,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(F.HiChevronLeft,{className:"h-4 w-4"})}),f.map((d,h)=>d==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${h}`):t.jsx("button",{type:"button","aria-current":d===c?"page":void 0,disabled:a,onClick:()=>n(d),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:d===c?"var(--primary)":"var(--border)",background:d===c?"var(--primary)":"var(--bg-card)",color:d===c?"var(--primary-fg)":"var(--text-secondary)"},children:d},d)),t.jsx(Ke,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(F.HiChevronRight,{className:"h-4 w-4"})})]})}const ii=[{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 ci(e){return e==null?"":String(e)}function la(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function pb(e){return typeof e=="number"?`${e}px`:e}function mb({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:f,countryCode:d,defaultCountryCode:h="+1",onCountryCodeChange:b,allowedCountryCodes:u,countryCodeOptions:p,countryCodePlaceholder:g="Codigo",countryCodeClassName:w="",countryCodeWidth:v=84,onPhoneValueChange:E,label:y,containerClassName:T="",helperText:L,helperDisplay:C="inline",labelAction:m,className:S="",required:N,disabled:_,floatingLabel:U,showPasswordToggle:K,nativeValidation:D,errorTooltipLabel:Z="Error de validacion",...O}){var I;const[ne,ee]=s.useState(()=>ci(c)),[fe,J]=s.useState(()=>la(h)),W=s.useMemo(()=>{const le=p??ii,be=u==null?void 0:u.map(la);return be!=null&&be.length?le.filter(ie=>be.includes(ie.value)):le},[u,p]),R=((I=W[0])==null?void 0:I.value)??"+1",$=W.some(le=>le.value===la(d??fe))?la(d??fe):R,P=i!==void 0?ci(i):ne,ue=`${$} ${P}`.trim(),z=n&&P.length>0&&!Eo(ue)?a:void 0,se=l??z,q=!!se,k=q&&o!=="tooltip",V=q&&o!=="inline",M=!!L&&C==="tooltip"&&!k,Y=q?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ce=le=>{const be=le.currentTarget.value;i===void 0&&ee(be),E==null||E(be,{countryCode:$,nationalNumber:be,fullNumber:`${$} ${be}`.trim()}),f==null||f(le)},X=le=>{d===void 0&&J(le),b==null||b(le),E==null||E(P,{countryCode:le,nationalNumber:P,fullNumber:`${le} ${P}`.trim()})},G=V?t.jsx(Xt,{as:"span",content:se,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":Z,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(ei,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${T}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:y}),N&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),M?t.jsx(_r,{content:L}):null,m&&t.jsx("span",{className:"ml-auto normal-case",children:m})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${Y}`,children:[t.jsx(yr,{value:$,onChange:X,options:W,placeholder:g,disabled:_,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${w}`,style:{width:pb(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",{...O,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:_,required:void 0,"aria-label":O["aria-label"]??(typeof y=="string"?y:void 0),"aria-invalid":q||O["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 ${V?"pr-10":""} ${S}`,onChange:ce}),G]})]}),t.jsx(zr,{error:k?se:void 0,helperText:L,helperDisplay:C})]})}function gb({value:e,onChange:r,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:f=""}){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(d=>{const h=d.value===e,b=i||d.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)]"} ${f}`,style:{borderColor:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:d.value,checked:h,disabled:b,onChange:()=>r(d.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:d.label}),d.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:d.description})]})]},d.value)})})]})}const vb='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-clipboard" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M17.663 3.118c.225.015.45.032.673.05C19.876 3.298 21 4.604 21 6.109v9.642a3 3 0 0 1-3 3V16.5c0-5.922-4.576-10.775-10.384-11.217.324-1.132 1.3-2.01 2.548-2.114.224-.019.448-.036.673-.051A3 3 0 0 1 13.5 1.5H15a3 3 0 0 1 2.663 1.618ZM12 4.5A1.5 1.5 0 0 1 13.5 3H15a1.5 1.5 0 0 1 1.5 1.5H12Z" clip-rule="evenodd"></path><path d="M3 8.625c0-1.036.84-1.875 1.875-1.875h.375A3.75 3.75 0 0 1 9 10.5v1.875c0 1.036.84 1.875 1.875 1.875h1.875A3.75 3.75 0 0 1 16.5 18v2.625c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 0 1 3 20.625v-12Z"></path><path d="M10.5 10.5a5.23 5.23 0 0 0-1.279-3.434 9.768 9.768 0 0 1 6.963 6.963 5.23 5.23 0 0 0-3.434-1.279h-1.875a.375.375 0 0 1-.375-.375V10.5Z"></path></svg>',xb='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-check" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z" clip-rule="evenodd"></path></svg>';function di(){return`<button type="button" class="rich-code-copy" data-action="copy-code" title="Copiar" aria-label="Copiar">${vb}${xb}</button>`}const yb=new Set(["div","p","li","tr","pre","h1","h2","h3","h4","h5","h6"]);function ui(e){const r=n=>{if(n.nodeType===Node.TEXT_NODE)return(n.textContent??"").replace(/\u00a0/g," ");if(n.nodeType!==Node.ELEMENT_NODE)return"";const a=n,o=a.tagName.toLowerCase();if(o==="br")return`
|
|
32
|
+
`;if(o==="script"||o==="style")return"";let l="";for(const i of Array.from(a.childNodes))l+=r(i);return yb.has(o)&&l.length>0&&!l.endsWith(`
|
|
33
33
|
`)&&(l+=`
|
|
34
34
|
`),l};return r(e).replace(/\r\n?/g,`
|
|
35
35
|
`).replace(/\n{3,}/g,`
|
|
36
36
|
|
|
37
|
-
`).replace(/^\n+/,"").replace(/\n+$/,"")}async function
|
|
38
|
-
`),o=r(a).replace(/\n/g,"<br>")||"<br>",l=`<div class="rich-code-wrap"><div class="rich-code-header" contenteditable="false"><span class="rich-code-label">Código</span>${El()}</div><pre class="rich-code-block"><code>${o}</code></pre></div>`;return n?`${l}<p><br></p>`:l}const Cf=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),ta=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),zr=12,ra=8,Mo=(e,r,n)=>{const a=aa(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},$l=(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>=zr?null:Mo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=zr)return null;const o=Array.from(a.rows).indexOf(n);return Mo(a,o+1,e)},Ef=(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)},Dl=(e,r)=>aa(e)>=ra?!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),Mf=(e,r)=>aa(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Hl=e=>{e.querySelectorAll(".rich-table-row-active").forEach(r=>{r.classList.remove("rich-table-row-active")}),e.querySelectorAll(".rich-table-col-active").forEach(r=>{r.classList.remove("rich-table-col-active")})},Ol=(e,r,n)=>{Hl(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},Tf=(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}}},na=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},Il=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},Lf=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?$l(r,n):To(r);return l&&oa(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Ef(r,n):!1;case"table-col-add":return Number.isFinite(a)?Dl(r,a):Hf(r);case"table-col-del":return Number.isFinite(a)?Mf(r,a):!1;default:return!1}},aa=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Af=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},Bl=e=>(e==null?void 0:e.closest("table"))??null,Fl=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},$f=e=>Array.from(e.querySelectorAll("th, td")),Pl=(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]},Df=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()===""},oa=(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)},To=e=>{const r=Af(e);if(r.length>=zr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return Mo(a,0,e)}return $l(e,Array.from(e.rows).indexOf(n))},Hf=e=>{const r=aa(e)-1;return r<0?!1:Dl(e,r)},Lo=e=>{Il(e)},Of=(e,r,n)=>{const a=ta(e,1,zr),o=ta(r,1,ra),l=n?`<thead><tr>${Array.from({length:o},(c,f)=>`<th>Columna ${f+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>`},_l=()=>'<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>',Wr=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),zl=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),If=e=>e.replace(/[<>]/g,"").toLowerCase(),Bf=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","pre","code","button","a","img","hr","sup","sub","table","thead","tbody","tfoot","tr","th","td","caption"]),Ff=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Pf=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},sa=(e,r)=>r.test(e),_f=e=>sa(e,/font-weight\s*:\s*(bold|[6-9]00)/i),zf=e=>sa(e,/font-style\s*:\s*italic/i),Wf=e=>sa(e,/text-decoration(?:-line)?\s*:[^;]*underline|text-underline\s*:/i),jf=e=>sa(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),la=(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)},vn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Wl=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)||!!e.querySelector("[data-word-list]")},qf=e=>{const n=(e.getAttribute("style")??"").match(/mso-list\s*:[^;]*\blevel(\d+)/i),a=n?Number(n[1]):1;return Number.isFinite(a)&&a>0?a:1},Uf=e=>{var o;const r=(o=e.querySelector("[data-word-list]"))==null?void 0:o.getAttribute("data-word-list");if(r==="ol"||r==="ul")return r;const n=e.getAttribute("style")??"",a=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(n)||/^\s*\d+[.)]\s/.test(a)||/^\s*[a-zA-Z][.)]\s/.test(a)?"ol":"ul"},Vf=e=>{e.querySelectorAll("span, font").forEach(o=>{const l=o.getAttribute("style")??"",i=o.getAttribute("face")??"";(o.hasAttribute("data-word-list")||/symbol|wingdings|webdings/i.test(l)||/symbol|wingdings|webdings/i.test(i))&&o.remove()});const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Ff,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"").replace(/^[\s\u00a0]+/,"");a!==n.textContent&&(n.textContent=a)},Xf=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&&(_f(a)&&la(n,"strong"),zf(a)&&la(n,"em"),Wf(a)&&la(n,"u"),jf(a)&&la(n,"s"))})},Yf=e=>{let r=(e==null?void 0:e.nextSibling)??null;for(;r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").trim();)r=r.nextSibling;return r instanceof HTMLElement?r:null},Ao=e=>{const r=e.match(/text-align\s*:\s*(center|right|justify)/i);return r?`rich-align-${r[1].toLowerCase()}`:""},Gf=e=>{e.querySelectorAll("b, strong, i, em").forEach(r=>{const n=r.getAttribute("style")??"",a=r.tagName.toLowerCase(),o=(a==="b"||a==="strong")&&/font-weight\s*:\s*(normal|400)\b/i.test(n),l=(a==="i"||a==="em")&&/font-style\s*:\s*normal\b/i.test(n);(o||l)&&vn(r)})},Kf=e=>{e.querySelectorAll("p, div, h1").forEach(r=>{if(Wl(r))return;const n=r.getAttribute("class")??"",a=r.getAttribute("style")??"";let o="";if(/MsoTitle|MsoSubtitle|MsoHeading1|\bHeading1\b/i.test(n)||/outline-level\s*:\s*1\b/i.test(a)?o="h2":/MsoHeading[2-9]|\bHeading[2-9]\b/i.test(n)||/outline-level\s*:\s*[2-9]\b/i.test(a)?o="h3":/MsoQuote|MsoIntenseQuote/i.test(n)&&(o="blockquote"),!o||r.tagName.toLowerCase()===o)return;const l=r.ownerDocument.createElement(o),i=Ao(a);for(i&&(l.className=i),a&&l.setAttribute("style",a);r.firstChild;)l.appendChild(r.firstChild);r.replaceWith(l)})},Zf=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(a=>Wl(a)&&!a.closest("ul, ol"));if(!r.length)return;let n=0;for(;n<r.length;){const a=[r[n]];let o=n+1;for(;o<r.length&&Yf(a[a.length-1])===r[o];)a.push(r[o]),o+=1;const l=a[0].parentNode;if(!l){n=o;continue}const i=[],c=a[0],f=(d,h)=>{for(;i.length&&i[i.length-1].level>h;)i.pop();const b=i[i.length-1];if(b&&b.level===h&&b.kind===d)return b.list;b&&b.level===h&&i.pop();const u=c.ownerDocument.createElement(d);if(!i.length)l.insertBefore(u,c);else{const p=i[i.length-1].list;let v=p.lastElementChild;(!v||v.tagName.toLowerCase()!=="li")&&(v=c.ownerDocument.createElement("li"),p.appendChild(v)),v.appendChild(u)}return i.push({list:u,level:h,kind:d}),u};a.forEach(d=>{const h=Uf(d),b=qf(d),u=Ao(d.getAttribute("style")??"");Vf(d);const p=f(h,b),v=d.ownerDocument.createElement("li");for(u&&(v.className=u);d.firstChild;)v.appendChild(d.firstChild);p.appendChild(v),d.remove()}),n=o}},Qf=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Jf=e=>e.replace(/<!--\[if\s+gte\s+vml[\s\S]*?<!\[endif\]-->/gi,"").replace(/<v:[\s\S]*?<\/v:[^>]+>/gi,"").replace(/<!(?:--\[if\s+!supportLists\]-->|\[if\s+!supportLists\]>)([\s\S]*?)<!\[endif\](?:-->|>)/gi,(r,n)=>{const a=n.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return`<span data-word-list="${/^\d|^[a-z]\s*[.)]/i.test(a)?"ol":"ul"}"></span>`}).replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<!\[if\s+!vml\]>/gi,"").replace(/<!\[endif\]>/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?[ovwm]:[^>]*>/gi,""),Rf=e=>{const r=Pf(Jf(e)),a=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html"),o=a.body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, textarea, select, noscript").forEach(c=>c.remove()),Gf(o),Kf(o),Xf(o),Zf(o),o.querySelectorAll("p, h2, h3, li, td, th, blockquote").forEach(c=>{const f=Ao(c.getAttribute("style")??"");f&&c.classList.add(f)});const l=c=>{const f=Array.from(c.childNodes);if(c.nodeType===Node.ELEMENT_NODE){const d=c,h=d.tagName.toLowerCase();if(h==="html"||h==="body"){f.forEach(l);return}if(h==="font"){vn(d),f.forEach(l);return}if(!Bf.has(h)){vn(d),f.forEach(l);return}if(h==="div"){const u=d.getAttribute("class")??"";if(/rich-table-wrap/.test(u)){Array.from(d.attributes).forEach(p=>{p.name.toLowerCase()!=="class"&&d.removeAttribute(p.name)}),d.className="rich-table-wrap",f.forEach(l);return}if(/rich-code-wrap/.test(u)){Array.from(d.attributes).forEach(p=>{p.name.toLowerCase()!=="class"&&d.removeAttribute(p.name)}),d.className="rich-code-wrap",f.forEach(l);return}if(/rich-code-header/.test(u)){Array.from(d.attributes).forEach(p=>{const v=p.name.toLowerCase();v!=="class"&&v!=="contenteditable"&&d.removeAttribute(p.name)}),d.className="rich-code-header",d.setAttribute("contenteditable","false"),f.forEach(l);return}}if(h==="button"){if(d.closest(".rich-code-wrap")&&d.getAttribute("data-action")==="copy-code"){Array.from(d.attributes).forEach(p=>{const v=p.name.toLowerCase();["type","class","data-action","title","aria-label"].includes(v)||d.removeAttribute(p.name)}),d.setAttribute("type","button"),d.className="rich-code-copy",d.setAttribute("data-action","copy-code");return}d.remove();return}if(h==="pre"){Array.from(d.attributes).forEach(u=>{u.name.toLowerCase()!=="class"&&d.removeAttribute(u.name)}),d.classList.contains("rich-code-block")||d.classList.add("rich-code-block"),f.forEach(l);return}if(h==="code"){Array.from(d.attributes).forEach(u=>{d.removeAttribute(u.name)}),f.forEach(l);return}const b=Qf(h);if(b!==h){const u=d.ownerDocument.createElement(b);for(;d.firstChild;)u.appendChild(d.firstChild);d.replaceWith(u),l(u);return}if(Cf.has(h)){Array.from(d.attributes).forEach(u=>{const p=u.name.toLowerCase();if(h==="td"||h==="th"){["colspan","rowspan"].includes(p)||d.removeAttribute(u.name);return}d.removeAttribute(u.name)}),h==="table"&&d.classList.add("rich-table"),f.forEach(l);return}if(Array.from(d.attributes).forEach(u=>{const p=u.name.toLowerCase(),v=u.value;if(p.startsWith("on")||p==="style"){d.removeAttribute(u.name);return}if(p==="class"){const w=Array.from(d.classList).filter(g=>g.startsWith("rich-align-"));w.length?d.className=w.join(" "):d.removeAttribute(u.name);return}if(p==="lang"||p.startsWith("data-")||p.startsWith("mso-")){d.removeAttribute(u.name);return}if((p==="href"||p==="src")&&/^\s*javascript:/i.test(v)){d.removeAttribute(u.name);return}h!=="a"&&h!=="img"&&p!=="href"&&p!=="src"&&p!=="alt"&&(["href","src","alt","target","rel"].includes(p)||d.removeAttribute(u.name))}),h==="a"){const u=d.getAttribute("href");if(!u||/^\s*#/.test(u)&&u.length<2){vn(d),f.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(h==="img"){const u=d.getAttribute("src")??"";if(!u||/^\s*javascript:/i.test(u)||/^file:/i.test(u)||/scheme\s*=\s*["']?file/i.test(u)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(p=>{["src","alt","class"].includes(p.name.toLowerCase())||d.removeAttribute(p.name)})}if(h==="span"){vn(d),f.forEach(l);return}}f.forEach(l)};l(o),o.querySelectorAll("pre").forEach(c=>{if(c.closest(".rich-code-wrap"))return;const f=c.textContent??"",d=a.createElement("div");d.innerHTML=Do(f,!1);const h=d.querySelector(".rich-code-wrap");h&&c.replaceWith(h)}),o.querySelectorAll("p, h2, h3, li").forEach(c=>{const f=(c.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=c.querySelector("img, hr"),h=!f&&!d&&Array.from(c.childNodes).every(b=>b.nodeType===Node.TEXT_NODE||b.nodeType===Node.ELEMENT_NODE&&b.tagName.toLowerCase()==="br");(!f&&!d||h)&&c.remove()}),o.querySelectorAll("li, td, th").forEach(c=>{const f=Array.from(c.children).filter(d=>/^(p|div)$/i.test(d.tagName));if(f.length===1&&c.children.length===1){const d=f[0];for(Array.from(d.classList).forEach(h=>{h.startsWith("rich-align-")&&c.classList.add(h)});d.firstChild;)c.insertBefore(d.firstChild,d);d.remove()}}),o.querySelectorAll("ul + ul, ol + ol").forEach(c=>{const f=c.previousElementSibling;if(!(!f||f.tagName!==c.tagName)){for(;c.firstChild;)f.appendChild(c.firstChild);c.remove()}});const i=(c,f)=>{const d=f==="start"?c.firstChild:c.lastChild;if(!d||d.nodeType!==Node.TEXT_NODE||!d.textContent)return;const h=f==="start"?d.textContent.replace(/^[\s\u00a0]+/,""):d.textContent.replace(/[\s\u00a0]+$/,"");h!==d.textContent&&(d.textContent=h)};return o.querySelectorAll("p, h2, h3, li, blockquote").forEach(c=>{i(c,"start"),i(c,"end")}),o.querySelectorAll("strong, b, em, i, u, s").forEach(c=>{let f=c.nextSibling;for(;f&&f.nodeType===Node.TEXT_NODE&&!(f.textContent??"").trim();)f=f.nextSibling;if(f&&f.nodeType===Node.ELEMENT_NODE&&f.tagName===c.tagName){const d=f;for(;d.firstChild;)c.appendChild(d.firstChild);d.remove()}}),o.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/[\u200b\ufeff\u00ad]/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},$o=e=>Wr(e).replace(/\r\n?/g,`
|
|
39
|
-
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),
|
|
40
|
-
`);if(!/```/.test(r))return $o(e);const n=[],a=/```(?:[\w-]*\n)?([\s\S]*?)```/g;let o=0,l;for(;(l=a.exec(r))!==null;)l.index>o&&n.push($o(r.slice(o,l.index))),n.push(Do(l[1]??"")),o=a.lastIndex;return o<r.length&&n.push($o(r.slice(o))),n.join("")},jl=/```[\s\S]+?```/,eb=e=>{const r=(e.textContent??"").replace(/\u00a0/g," ");if(!e.querySelector(".rich-code-wrap")&&r.includes("```")&&jl.test(r)){const o=jr(r);if(o.includes("rich-code-wrap"))return e.innerHTML=o,!0}let n=!1;const a=Array.from(e.children).filter(o=>o instanceof HTMLElement&&!o.classList.contains("rich-code-wrap"));for(const o of a){if(o.closest(".rich-code-wrap"))continue;const l=(o.textContent??"").replace(/\u00a0/g," ");if(!l.includes("```")||!jl.test(l))continue;const i=jr(l);if(!i.includes("rich-code-wrap"))continue;const c=document.createElement("div");c.innerHTML=i;const f=o.parentNode;if(f){for(;c.firstChild;)f.insertBefore(c.firstChild,o);o.remove(),n=!0}}return n},tb=e=>new RegExp("\\p{L}","u").test(e),Ho=(e,r)=>{const n=e.trim();return!n||!tb(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===zl(n)},ql=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",_l())}(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 Ul({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full",focusModalZIndex:i=1e3}){const c=s.useId(),f=o||c,d=s.useCallback(()=>document,[]),h=s.useRef(null),b=s.useRef(null),u=s.useRef(new Map),p=s.useRef(null),v=s.useRef(!1),w=s.useRef(e??""),g=s.useRef(r),E=s.useRef(()=>{}),y=s.useRef(!1),[M,L]=s.useState(()=>!e||e.trim()===""),[C,m]=s.useState(new Set),[k,N]=s.useState(null),[_,q]=s.useState(""),[K,$]=s.useState(""),[Q,X]=s.useState(""),[se,J]=s.useState(""),[fe,te]=s.useState(3),[z,R]=s.useState(3),[A,F]=s.useState(!0),[ue,P]=s.useState(!1),[oe,j]=s.useState(l==="full"),[S,U]=s.useState(null),[T,Y]=s.useState(null),ce=s.useRef(null),V=s.useRef(!1),G=s.useRef(null),D=s.useCallback(()=>v.current?b.current:h.current,[]);s.useEffect(()=>{g.current=r},[r]);const le=s.useCallback(()=>{const W=window.getSelection(),ee=D();if(!W||!ee||W.rangeCount===0||W.isCollapsed)return"";const me=W.getRangeAt(0);return!ee.contains(me.startContainer)||!ee.contains(me.endContainer)?"":W.toString()},[D]);s.useEffect(()=>{const W=e??"";if(y.current&&W===w.current){y.current=!1,L(!W||W.trim()==="");return}y.current=!1,w.current=W;const ee=[h.current,b.current].filter(pe=>!!pe);ee.forEach(pe=>{pe.innerHTML!==W&&(pe.innerHTML=W)}),L(!W||W.trim()===""),ee.forEach(pe=>Lo(pe));const me=ee.map(pe=>ql(pe));return()=>me.forEach(pe=>pe())},[e]),s.useEffect(()=>{var pe,ye;v.current=ue;let W,ee=0,me;if(ue){const Se=h.current;Se&&(w.current=na(Se));const _e=()=>{var lt;const Te=b.current;if(!Te){ee=requestAnimationFrame(_e);return}Te.innerHTML!==w.current&&(Te.innerHTML=w.current),W=ql(Te),Lo(Te),L(((lt=Te.textContent)==null?void 0:lt.trim())===""),me=setTimeout(()=>Te.focus(),60)};ee=requestAnimationFrame(_e)}else{const Se=b.current,_e=h.current,Te=Se?na(Se):w.current,lt=w.current;w.current=Te,_e&&_e.innerHTML!==Te&&(_e.innerHTML=Te),Te!==lt&&g.current(Te),L(((ye=(pe=Se??_e)==null?void 0:pe.textContent)==null?void 0:ye.trim())==="")}return()=>{ee&&cancelAnimationFrame(ee),me&&clearTimeout(me),W==null||W()}},[ue]);const be=s.useCallback(()=>{const W=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],ee=new Set;W.forEach(pe=>{try{d().queryCommandState(pe)&&ee.add(pe)}catch{return}});try{const pe=If(d().queryCommandValue("formatBlock"));pe&&ee.add(`formatBlock:${pe}`)}catch{}const me=le();Ho(me,"uppercase")&&ee.add("__upper"),Ho(me,"lowercase")&&ee.add("__lower"),Ho(me,"capitalize")&&ee.add("__cap");try{const pe=window.getSelection();let ye=(pe==null?void 0:pe.anchorNode)??null;(ye==null?void 0:ye.nodeType)===Node.TEXT_NODE&&(ye=ye.parentElement),ye instanceof Element&&ye.closest(".rich-code-wrap")&&ee.add("__code")}catch{}m(ee)},[le,d]),ie=()=>{var ee;const W=D();W&&(eb(W),w.current=na(W),y.current=!0,g.current(w.current),L(((ee=W.textContent)==null?void 0:ee.trim())===""))};E.current=ie;const ge=s.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=null),ce.current&&(Hl(ce.current),ce.current=null),V.current=!1,U(null),Y(null)},[]),$e=s.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=null)},[]),De=s.useCallback(()=>{$e(),G.current=setTimeout(()=>{V.current||ge()},280)},[$e,ge]);s.useEffect(()=>()=>{G.current&&clearTimeout(G.current)},[]);const Nt=s.useCallback(W=>{const ee=ce.current;if(!ee||!ee.isConnected){ge();return}const me=(S==null?void 0:S.rowIndex)??(T==null?void 0:T.rowIndex)??-1,pe=(S==null?void 0:S.colIndex)??(T==null?void 0:T.colIndex)??-1;Lf(W,ee,me,pe,D()),ge(),E.current(),be()},[D,ge,be,T,S]),yt=s.useCallback(W=>{if(T)return;const ee=W.currentTarget,me=W.target;if(me.closest(".rich-table-action-bar, .rich-table-context-menu")){$e();return}const pe=me.closest("td, th");if(!pe||!ee.contains(pe)){De();return}const ye=pe.closest("tr"),Se=pe.closest("table");if(!ye||!Se||!ee.contains(Se)){De();return}$e(),Se.classList.add("rich-table"),ce.current=Se,Ol(Se,ye,pe.cellIndex),U(Tf(Se,ye,pe))},[$e,De,T]),re=s.useCallback(W=>{const ee=W.relatedTarget;if(ee instanceof Element&&(ee.closest(".rich-table-action-bar")||ee.closest(".rich-table-context-menu"))){$e();return}De()},[$e,De]),xe=s.useCallback(W=>{const ee=W.currentTarget,pe=W.target.closest("td, th");if(!pe||!ee.contains(pe))return;const ye=pe.closest("tr"),Se=pe.closest("table");if(!ye||!Se||!ee.contains(Se))return;W.preventDefault(),Se.classList.add("rich-table"),ce.current=Se;const _e=Array.from(Se.rows).indexOf(ye),Te=pe.cellIndex;Ol(Se,ye,Te),U(null),Y({x:W.clientX,y:W.clientY,rowIndex:_e,colIndex:Te})},[]);s.useEffect(()=>{if(!S&&!T)return;const W=()=>De();return window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[De,T,S]),s.useEffect(()=>{if(!T)return;const W=ee=>{const me=ee.target;me instanceof Element&&me.closest(".rich-table-context-menu")||Y(null)};return window.addEventListener("mousedown",W),()=>window.removeEventListener("mousedown",W)},[T]);const ae=W=>{if(!W){const ee=h.current;ee&&(w.current=na(ee))}P(!W)},we=(W,ee)=>{var me;(me=D())==null||me.focus(),d().execCommand(W,!1,ee),ie(),be()},ne=W=>{we("formatBlock",W)},Oe=()=>{var W;(W=D())==null||W.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),ie(),be()},qe=()=>{const W=window.getSelection();W&&W.rangeCount>0&&(p.current=W.getRangeAt(0).cloneRange())},Qe=()=>{const W=window.getSelection();W&&p.current&&(W.removeAllRanges(),W.addRange(p.current))},Ze=W=>{if(qe(),W==="link"){const ee=window.getSelection();$(ee&&!ee.isCollapsed?ee.toString():""),q("")}W==="image"&&(X(""),J("")),W==="table"&&(te(3),R(3),F(!0)),N(W)},Ue=()=>{var pe;if(!_.trim())return;Qe(),(pe=D())==null||pe.focus();const W=window.getSelection(),me=(W&&!W.isCollapsed?W.toString():"")||K.trim()||_.trim();d().execCommand("insertHTML",!1,`<a href="${Wr(_.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Wr(me)}</a>`),ie(),N(null)},et=(W,ee="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Wr(W)}" alt="${Wr(ee)}" class="rich-img" />${_l()}</span>`,St=()=>{var W;Q.trim()&&(Qe(),(W=D())==null||W.focus(),d().execCommand("insertHTML",!1,et(Q.trim(),se.trim())),ie(),N(null))},vt=()=>{var W;Qe(),(W=D())==null||W.focus(),d().execCommand("insertHTML",!1,Of(fe,z,A)),ie(),N(null)},Ct=()=>{var me;Qe(),(me=D())==null||me.focus();const W=window.getSelection(),ee=W&&!W.isCollapsed?W.toString():"";d().execCommand("insertHTML",!1,Do(ee)),ie()},ve=(W,ee=1200,me=1200,pe=.72)=>new Promise((ye,Se)=>{const _e=new FileReader;_e.onerror=Se,_e.onload=Te=>{var pt;const lt=(pt=Te.target)==null?void 0:pt.result,Ve=new Image;Ve.onerror=Se,Ve.onload=()=>{let{width:dt,height:mt}=Ve;if(dt>ee||mt>me){const Ot=Math.min(ee/dt,me/mt);dt=Math.round(dt*Ot),mt=Math.round(mt*Ot)}const rr=document.createElement("canvas");rr.width=dt,rr.height=mt;const qt=rr.getContext("2d");if(!qt){ye(lt);return}qt.drawImage(Ve,0,0,dt,mt),ye(rr.toDataURL("image/jpeg",pe))},Ve.src=lt},_e.readAsDataURL(W)}),ke=W=>{W.focus();const ee=window.getSelection();if(!ee||ee.rangeCount===0||!W.contains(ee.anchorNode)){const me=document.createRange();me.selectNodeContents(W),me.collapse(!1),ee==null||ee.removeAllRanges(),ee==null||ee.addRange(me)}},Pe=s.useRef(()=>{});Pe.current=W=>{const ee=D();if(!ee)return;ke(ee);const me=window.getSelection(),pe=/<(?:p|div|ul|ol|h[1-6]|table|blockquote|pre|hr)\b/i.test(W),ye=me&&me.rangeCount>0?me.getRangeAt(0):null,Se=(ye==null?void 0:ye.startContainer.nodeType)===Node.ELEMENT_NODE?ye.startContainer:ye==null?void 0:ye.startContainer.parentElement,_e=!!(Se!=null&&Se.closest("li, table"));if(!pe||!ye||!ee.contains(ye.startContainer)||_e)d().execCommand("insertHTML",!1,W);else{ye.deleteContents();let Te=ye.startContainer.nodeType===Node.ELEMENT_NODE?ye.startContainer:ye.startContainer.parentElement;const lt=new Set(["p","div","h2","h3","blockquote"]);for(;Te&&Te!==ee&&!lt.has(Te.tagName.toLowerCase());)Te=Te.parentElement;const Ve=document.createElement("div");Ve.innerHTML=W;const pt=Array.from(Ve.childNodes);if(!Te||Te===ee){ye.insertNode(Ve);const dt=Ve.parentNode;for(;Ve.firstChild;)dt==null||dt.insertBefore(Ve.firstChild,Ve);Ve.remove()}else{const dt=document.createRange();dt.setStart(ye.endContainer,ye.endOffset),dt.setEnd(Te,Te.childNodes.length);const mt=dt.extractContents(),rr=(mt.textContent??"").replace(/[\u00a0\s]+/g,""),qt=(Te.textContent??"").replace(/[\u00a0\s]+/g,""),Ot=Te.parentNode;if(!Ot)d().execCommand("insertHTML",!1,W);else{const nr=!qt&&!Te.querySelector("img, table, hr"),pr=nr?Te:Te.nextSibling;let It=null;for(const xt of pt)Ot.insertBefore(xt,pr),It=xt;if(rr&&It){const xt=document.createElement("p");xt.appendChild(mt),Ot.insertBefore(xt,It.nextSibling)}if(nr&&Te.remove(),It&&me){const xt=document.createRange();xt.setStartAfter(It),xt.collapse(!0),me.removeAllRanges(),me.addRange(xt)}}}}Lo(ee),ee.querySelectorAll("p").forEach(Te=>{!(Te.textContent??"").replace(/[\u00a0\s]+/g,"")&&!Te.querySelector("img, hr, table")&&Te.remove()}),ie(),be()};const je=s.useRef(ve);je.current=ve;const Je=s.useRef(et);Je.current=et;const at=s.useCallback(W=>{if(!W||u.current.has(W))return;const ee=me=>{const pe=me.clipboardData;if(!pe)return;const ye=pe.getData("text/html"),Se=pe.getData("text/plain");if(ye||Se){me.preventDefault(),me.stopPropagation();try{const Ve=ye?Rf(ye):jr(Se),pt=Se.replace(/\s+/g," ").trim(),dt=Ve.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim(),mt=/<(?:ul|ol|table|img|h2|h3|blockquote)\b/i.test(Ve);if(pt.length>80&&!mt&&dt.length<pt.length*.6){Pe.current(jr(Se));return}if(!Ve){Se&&Pe.current(jr(Se));return}Pe.current(Ve)}catch{Se&&Pe.current(jr(Se))}return}const Te=Array.from(pe.items).find(Ve=>Ve.type.startsWith("image/"));if(!Te)return;me.preventDefault(),me.stopPropagation();const lt=Te.getAsFile();lt&&je.current(lt).then(Ve=>{Pe.current(Je.current(Ve,"imagen"))})};W.addEventListener("paste",ee,!0),u.current.set(W,()=>{W.removeEventListener("paste",ee,!0),u.current.delete(W)})},[]),st=s.useCallback(W=>{var me;const ee=h.current;ee&&ee!==W&&((me=u.current.get(ee))==null||me()),h.current=W,W&&at(W)},[at]),tt=s.useCallback(W=>{var me;const ee=b.current;ee&&ee!==W&&((me=u.current.get(ee))==null||me()),b.current=W,W&&at(W)},[at]);s.useEffect(()=>{const W=u.current;return()=>{W.forEach(ee=>ee()),W.clear()}},[]);const ct=W=>{const ee=window.getSelection(),me=D();if(!ee||!me||ee.rangeCount===0||ee.isCollapsed)return;const pe=ee.getRangeAt(0);if(!me.contains(pe.startContainer)||!me.contains(pe.endContainer))return;const ye=pe.toString();if(!ye)return;let Se=ye;W==="uppercase"?Se=ye.toLocaleUpperCase():W==="lowercase"?Se=ye.toLocaleLowerCase():Se=zl(ye),pe.deleteContents();const _e=document.createTextNode(Se);pe.insertNode(_e);const Te=document.createRange();Te.setStart(_e,0),Te.setEnd(_e,Se.length),ee.removeAllRanges(),ee.addRange(Te),p.current=Te.cloneRange(),ie(),be()},ot=()=>{qe(),be()},Nr=()=>{const W=D();W&&Il(W),ie(),be()},bt=()=>{requestAnimationFrame(()=>{var W;(W=D())==null||W.focus()})},kr=W=>{var ee,me;if((W.metaKey||W.ctrlKey)&&W.key==="Enter"){if(W.preventDefault(),W.stopPropagation(),W.repeat)return;(ee=D())==null||ee.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),ie(),be();return}if(W.key==="Tab"){const pe=window.getSelection(),ye=Fl((pe==null?void 0:pe.anchorNode)??null),Se=D(),_e=Bl(ye);if(ye&&_e&&(Se!=null&&Se.contains(ye))){W.preventDefault();const Te=$f(_e),lt=Te.indexOf(ye),Ve=lt>=0?Te[lt+1]:null;if(Ve)oa(Ve,Se,!0);else if(Pl(ye,_e)){const pt=To(_e);pt&&oa(pt,Se,!0)}ie(),be();return}W.preventDefault(),(me=D())==null||me.focus(),d().execCommand("insertText",!1," "),ie(),be();return}if(W.key==="Enter"&&!W.shiftKey&&!(W.metaKey||W.ctrlKey)){const pe=window.getSelection(),ye=Fl((pe==null?void 0:pe.anchorNode)??null),Se=D(),_e=Bl(ye);if(ye&&_e&&(Se!=null&&Se.contains(ye))&&Pl(ye,_e)&&Df(ye)){W.preventDefault();const Te=To(_e);Te&&oa(Te,Se,!0),ie(),be();return}}if(W.key==="Escape"){if(T){Y(null);return}if(k){N(null);return}if(v.current){P(!1);return}}k||(W.ctrlKey||W.metaKey)&&(W.key==="b"&&(W.preventDefault(),we("bold")),W.key==="i"&&(W.preventDefault(),we("italic")),W.key==="u"&&(W.preventDefault(),we("underline")),W.key==="k"&&(W.preventDefault(),Ze("link")))},Ht=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ye=(W,ee,me,pe,ye)=>{const Se=ye??(C.has(me)||me==="__link"&&k==="link"||me==="__img"&&k==="image"||me==="__table"&&k==="table");return t.jsx("button",{type:"button",title:ee,tabIndex:-1,onFocus:bt,onMouseDown:_e=>{_e.preventDefault(),pe?pe():we(me)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Se?"var(--primary)":"var(--text-secondary)",background:Se?"rgba(59,130,246,0.12)":"transparent"},children:W},me)},ht=W=>{const ee=W.target;if(ee.closest("[data-action='delete-img']")){W.preventDefault();const pe=ee.closest(".rich-img-wrap");pe&&(pe.remove(),ie());return}const me=ee.closest("[data-action='copy-code']");me instanceof HTMLButtonElement&&(W.preventDefault(),Tl(me).catch(()=>{}))},br=()=>{$e(),V.current=!0},Et=()=>{V.current=!1,De()},jt=(W,ee,me,pe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${pe?" rich-table-action-btn--danger":""}`,title:W,"aria-label":W,onMouseDown:ye=>{ye.preventDefault(),ye.stopPropagation(),Nt(me)},children:ee}),Sr=()=>typeof document>"u"||!S&&!T?null:ft.createPortal(t.jsxs(t.Fragment,{children:[S&&!T&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:S.bar.x,top:S.bar.y},onMouseEnter:br,onMouseLeave:Et,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",S.rowIndex+1," · Col ",S.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),jt("Añadir fila abajo","+","table-row-add"),jt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),jt("Añadir columna a la derecha","+","table-col-add"),jt("Eliminar columna","−","table-col-del")]}),jt("Eliminar tabla","Eliminar","table-delete",!0)]}),T&&t.jsx("div",{className:"rich-table-context-menu",style:{left:T.x,top:T.y},onMouseDown:W=>W.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([W,ee])=>t.jsx("button",{type:"button",onMouseDown:me=>{me.preventDefault(),Nt(ee)},children:W},ee))})]}),document.body),hr=W=>t.jsxs(t.Fragment,{children:[k==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:_,onChange:ee=>q(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),Ue()),ee.key==="Escape"&&N(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:K,onChange:ee=>$(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),Ue()),ee.key==="Escape"&&N(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Ue,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),k==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:zr,value:fe,onChange:ee=>te(ta(Number(ee.target.value),1,zr)),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),vt()),ee.key==="Escape"&&N(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:ra,value:z,onChange:ee=>R(ta(Number(ee.target.value),1,ra)),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),vt()),ee.key==="Escape"&&N(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:A,onChange:ee=>F(ee.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:vt,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),k==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:Q,onChange:ee=>X(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),St()),ee.key==="Escape"&&N(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:se,onChange:ee=>J(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),St()),ee.key==="Escape"&&N(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:St,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Rr=(W,ee)=>{const me=l==="compact",pe=!me||oe||W;return t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:ee},"data-toolbar-variant":l,children:[me&&!W&&t.jsxs("button",{type:"button",title:oe?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:bt,onMouseDown:ye=>{ye.preventDefault(),j(Se=>!Se)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:oe?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[oe?t.jsx(H.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(H.HiChevronDown,{className:"h-3.5 w-3.5"}),oe?"Ocultar herramientas":"Herramientas"]}),pe&&t.jsxs(t.Fragment,{children:[Ye(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ye(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ye(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ye(t.jsx(H.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ye(t.jsx(H.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ye(t.jsx(H.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Ze("link")),Ht(),Ye(t.jsx(H.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ye(t.jsx(H.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Ht(),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ne("p"),C.has("formatBlock:p")||C.has("formatBlock:div")),Ye(t.jsx(H.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ne("h2"),C.has("formatBlock:h2")),Ye(t.jsx(H.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ne("h3"),C.has("formatBlock:h3")),Ye(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ne("blockquote"),C.has("formatBlock:blockquote")),Ye(t.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"10px"},children:"</>"}),"Bloque de código","__code",()=>Ct(),C.has("__code")),Ht(),Ye(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Ht(),Ye(t.jsx(H.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ye(t.jsx(H.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Ht(),Ye(t.jsx(H.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ye(t.jsx(H.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ye(t.jsx(H.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ye(t.jsx(H.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Ht(),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>ct("uppercase")),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>ct("lowercase")),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>ct("capitalize")),Ht(),Ye(t.jsx(H.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ye(t.jsx(H.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Ze("image")),Ye(t.jsx(H.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Ze("table")),Ye(t.jsx(H.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",Oe),Ht(),Ye(t.jsx(H.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ye(t.jsx(H.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ne("p"))]}),Ht(),t.jsx("button",{type:"button",title:W?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:bt,onMouseDown:ye=>{ye.preventDefault(),ae(W)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:W?t.jsx(H.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(H.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Sr(),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:st,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":f,onInput:Nr,onKeyDown:kr,onKeyUp:ot,onSelect:ot,onMouseUp:ot,onMouseMove:yt,onMouseLeave:re,onContextMenu:xe,onMouseDown:ht,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${M?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),hr("var(--bg-input)"),Rr(!1,"var(--bg-input)")]}),t.jsxs(uo,{open:ue,onClose:()=>P(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",zIndex:i,children:[t.jsx("div",{ref:tt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":f,onInput:Nr,onKeyDown:kr,onKeyUp:ot,onSelect:ot,onMouseUp:ot,onMouseMove:yt,onMouseLeave:re,onContextMenu:xe,onMouseDown:ht,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${M?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),hr("var(--bg-input)"),Rr(!0,"var(--bg-input)")]})]})}const Vl="[a-zA-Z0-9._@-]+",Oo=new RegExp(`@(${Vl})`,"g"),rb=/[a-zA-Z0-9._@-]/,xn=new Set([" ",`
|
|
41
|
-
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function
|
|
37
|
+
`).replace(/^\n+/,"").replace(/\n+$/,"")}async function fi(e){const r=e.closest(".rich-code-wrap"),n=r==null?void 0:r.querySelector("pre"),a=(n==null?void 0:n.querySelector("code"))??n,o=a?ui(a):"";if(!o.trim())throw new Error("empty_code_block");await go(o),bi(e)}function bi(e,r=2e3){e.setAttribute("data-copied","true"),e.title="Copiado",e.setAttribute("aria-label","Copiado"),window.setTimeout(()=>{e.removeAttribute("data-copied"),e.title="Copiar",e.setAttribute("aria-label","Copiar")},r)}function hi(e,r,n=!0){const a=e.replace(/\r\n?/g,`
|
|
38
|
+
`),o=r(a).replace(/\n/g,"<br>")||"<br>",l=`<div class="rich-code-wrap"><div class="rich-code-header" contenteditable="false"><span class="rich-code-label">Código</span>${di()}</div><pre class="rich-code-block"><code>${o}</code></pre></div>`;return n?`${l}<p><br></p>`:l}const wb=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),ia=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),jr=12,ca=8,Oo=(e,r,n)=>{const a=ua(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},pi=(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>=jr?null:Oo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=jr)return null;const o=Array.from(a.rows).indexOf(n);return Oo(a,o+1,e)},Nb=(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)},mi=(e,r)=>ua(e)>=ca?!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),kb=(e,r)=>ua(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),gi=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")})},vi=(e,r,n)=>{gi(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")}))},Sb=(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}}},da=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},xi=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")})},Cb=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?pi(r,n):Ho(r);return l&&fa(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Nb(r,n):!1;case"table-col-add":return Number.isFinite(a)?mi(r,a):Ab(r);case"table-col-del":return Number.isFinite(a)?kb(r,a):!1;default:return!1}},ua=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Eb=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},yi=e=>(e==null?void 0:e.closest("table"))??null,wi=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},Mb=e=>Array.from(e.querySelectorAll("th, td")),Ni=(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]},Tb=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()===""},fa=(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)},Ho=e=>{const r=Eb(e);if(r.length>=jr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return Oo(a,0,e)}return pi(e,Array.from(e.rows).indexOf(n))},Ab=e=>{const r=ua(e)-1;return r<0?!1:mi(e,r)},Bo=e=>{xi(e)},Lb=(e,r,n)=>{const a=ia(e,1,jr),o=ia(r,1,ca),l=n?`<thead><tr>${Array.from({length:o},(c,f)=>`<th>Columna ${f+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>`},ki=()=>'<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>',qr=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Si=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),$b=e=>e.replace(/[<>]/g,"").toLowerCase(),Db=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","pre","code","button","a","img","hr","sup","sub","table","thead","tbody","tfoot","tr","th","td","caption"]),Ib=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Fb=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},ba=(e,r)=>r.test(e),Ob=e=>ba(e,/font-weight\s*:\s*(bold|[6-9]00)/i),Hb=e=>ba(e,/font-style\s*:\s*italic/i),Bb=e=>ba(e,/text-decoration(?:-line)?\s*:[^;]*underline|text-underline\s*:/i),Pb=e=>ba(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),ha=(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)},wn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Ci=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)||!!e.querySelector("[data-word-list]")},_b=e=>{const n=(e.getAttribute("style")??"").match(/mso-list\s*:[^;]*\blevel(\d+)/i),a=n?Number(n[1]):1;return Number.isFinite(a)&&a>0?a:1},zb=e=>{var o;const r=(o=e.querySelector("[data-word-list]"))==null?void 0:o.getAttribute("data-word-list");if(r==="ol"||r==="ul")return r;const n=e.getAttribute("style")??"",a=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(n)||/^\s*\d+[.)]\s/.test(a)||/^\s*[a-zA-Z][.)]\s/.test(a)?"ol":"ul"},Wb=e=>{e.querySelectorAll("span, font").forEach(o=>{const l=o.getAttribute("style")??"",i=o.getAttribute("face")??"";(o.hasAttribute("data-word-list")||/symbol|wingdings|webdings/i.test(l)||/symbol|wingdings|webdings/i.test(i))&&o.remove()});const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Ib,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"").replace(/^[\s\u00a0]+/,"");a!==n.textContent&&(n.textContent=a)},jb=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&&(Ob(a)&&ha(n,"strong"),Hb(a)&&ha(n,"em"),Bb(a)&&ha(n,"u"),Pb(a)&&ha(n,"s"))})},qb=e=>{let r=(e==null?void 0:e.nextSibling)??null;for(;r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").trim();)r=r.nextSibling;return r instanceof HTMLElement?r:null},Po=e=>{const r=e.match(/text-align\s*:\s*(center|right|justify)/i);return r?`rich-align-${r[1].toLowerCase()}`:""},Ub=e=>{e.querySelectorAll("b, strong, i, em").forEach(r=>{const n=r.getAttribute("style")??"",a=r.tagName.toLowerCase(),o=(a==="b"||a==="strong")&&/font-weight\s*:\s*(normal|400)\b/i.test(n),l=(a==="i"||a==="em")&&/font-style\s*:\s*normal\b/i.test(n);(o||l)&&wn(r)})},Vb=e=>{e.querySelectorAll("p, div, h1").forEach(r=>{if(Ci(r))return;const n=r.getAttribute("class")??"",a=r.getAttribute("style")??"";let o="";if(/MsoTitle|MsoSubtitle|MsoHeading1|\bHeading1\b/i.test(n)||/outline-level\s*:\s*1\b/i.test(a)?o="h2":/MsoHeading[2-9]|\bHeading[2-9]\b/i.test(n)||/outline-level\s*:\s*[2-9]\b/i.test(a)?o="h3":/MsoQuote|MsoIntenseQuote/i.test(n)&&(o="blockquote"),!o||r.tagName.toLowerCase()===o)return;const l=r.ownerDocument.createElement(o),i=Po(a);for(i&&(l.className=i),a&&l.setAttribute("style",a);r.firstChild;)l.appendChild(r.firstChild);r.replaceWith(l)})},Xb=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(a=>Ci(a)&&!a.closest("ul, ol"));if(!r.length)return;let n=0;for(;n<r.length;){const a=[r[n]];let o=n+1;for(;o<r.length&&qb(a[a.length-1])===r[o];)a.push(r[o]),o+=1;const l=a[0].parentNode;if(!l){n=o;continue}const i=[],c=a[0],f=(d,h)=>{for(;i.length&&i[i.length-1].level>h;)i.pop();const b=i[i.length-1];if(b&&b.level===h&&b.kind===d)return b.list;b&&b.level===h&&i.pop();const u=c.ownerDocument.createElement(d);if(!i.length)l.insertBefore(u,c);else{const p=i[i.length-1].list;let g=p.lastElementChild;(!g||g.tagName.toLowerCase()!=="li")&&(g=c.ownerDocument.createElement("li"),p.appendChild(g)),g.appendChild(u)}return i.push({list:u,level:h,kind:d}),u};a.forEach(d=>{const h=zb(d),b=_b(d),u=Po(d.getAttribute("style")??"");Wb(d);const p=f(h,b),g=d.ownerDocument.createElement("li");for(u&&(g.className=u);d.firstChild;)g.appendChild(d.firstChild);p.appendChild(g),d.remove()}),n=o}},Yb=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Gb=e=>e.replace(/<!--\[if\s+gte\s+vml[\s\S]*?<!\[endif\]-->/gi,"").replace(/<v:[\s\S]*?<\/v:[^>]+>/gi,"").replace(/<!(?:--\[if\s+!supportLists\]-->|\[if\s+!supportLists\]>)([\s\S]*?)<!\[endif\](?:-->|>)/gi,(r,n)=>{const a=n.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return`<span data-word-list="${/^\d|^[a-z]\s*[.)]/i.test(a)?"ol":"ul"}"></span>`}).replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<!\[if\s+!vml\]>/gi,"").replace(/<!\[endif\]>/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?[ovwm]:[^>]*>/gi,""),Kb=e=>{const r=Fb(Gb(e)),a=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html"),o=a.body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, textarea, select, noscript").forEach(c=>c.remove()),Ub(o),Vb(o),jb(o),Xb(o),o.querySelectorAll("p, h2, h3, li, td, th, blockquote").forEach(c=>{const f=Po(c.getAttribute("style")??"");f&&c.classList.add(f)});const l=c=>{const f=Array.from(c.childNodes);if(c.nodeType===Node.ELEMENT_NODE){const d=c,h=d.tagName.toLowerCase();if(h==="html"||h==="body"){f.forEach(l);return}if(h==="font"){wn(d),f.forEach(l);return}if(!Db.has(h)){wn(d),f.forEach(l);return}if(h==="div"){const u=d.getAttribute("class")??"";if(/rich-table-wrap/.test(u)){Array.from(d.attributes).forEach(p=>{p.name.toLowerCase()!=="class"&&d.removeAttribute(p.name)}),d.className="rich-table-wrap",f.forEach(l);return}if(/rich-code-wrap/.test(u)){Array.from(d.attributes).forEach(p=>{p.name.toLowerCase()!=="class"&&d.removeAttribute(p.name)}),d.className="rich-code-wrap",f.forEach(l);return}if(/rich-code-header/.test(u)){Array.from(d.attributes).forEach(p=>{const g=p.name.toLowerCase();g!=="class"&&g!=="contenteditable"&&d.removeAttribute(p.name)}),d.className="rich-code-header",d.setAttribute("contenteditable","false"),f.forEach(l);return}}if(h==="button"){if(d.closest(".rich-code-wrap")&&d.getAttribute("data-action")==="copy-code"){Array.from(d.attributes).forEach(p=>{const g=p.name.toLowerCase();["type","class","data-action","title","aria-label"].includes(g)||d.removeAttribute(p.name)}),d.setAttribute("type","button"),d.className="rich-code-copy",d.setAttribute("data-action","copy-code");return}d.remove();return}if(h==="pre"){Array.from(d.attributes).forEach(u=>{u.name.toLowerCase()!=="class"&&d.removeAttribute(u.name)}),d.classList.contains("rich-code-block")||d.classList.add("rich-code-block"),f.forEach(l);return}if(h==="code"){Array.from(d.attributes).forEach(u=>{d.removeAttribute(u.name)}),f.forEach(l);return}const b=Yb(h);if(b!==h){const u=d.ownerDocument.createElement(b);for(;d.firstChild;)u.appendChild(d.firstChild);d.replaceWith(u),l(u);return}if(wb.has(h)){Array.from(d.attributes).forEach(u=>{const p=u.name.toLowerCase();if(h==="td"||h==="th"){["colspan","rowspan"].includes(p)||d.removeAttribute(u.name);return}d.removeAttribute(u.name)}),h==="table"&&d.classList.add("rich-table"),f.forEach(l);return}if(Array.from(d.attributes).forEach(u=>{const p=u.name.toLowerCase(),g=u.value;if(p.startsWith("on")||p==="style"){d.removeAttribute(u.name);return}if(p==="class"){const w=Array.from(d.classList).filter(v=>v.startsWith("rich-align-"));w.length?d.className=w.join(" "):d.removeAttribute(u.name);return}if(p==="lang"||p.startsWith("data-")||p.startsWith("mso-")){d.removeAttribute(u.name);return}if((p==="href"||p==="src")&&/^\s*javascript:/i.test(g)){d.removeAttribute(u.name);return}h!=="a"&&h!=="img"&&p!=="href"&&p!=="src"&&p!=="alt"&&(["href","src","alt","target","rel"].includes(p)||d.removeAttribute(u.name))}),h==="a"){const u=d.getAttribute("href");if(!u||/^\s*#/.test(u)&&u.length<2){wn(d),f.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(h==="img"){const u=d.getAttribute("src")??"";if(!u||/^\s*javascript:/i.test(u)||/^file:/i.test(u)||/scheme\s*=\s*["']?file/i.test(u)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(p=>{["src","alt","class"].includes(p.name.toLowerCase())||d.removeAttribute(p.name)})}if(h==="span"){wn(d),f.forEach(l);return}}f.forEach(l)};l(o),o.querySelectorAll("pre").forEach(c=>{if(c.closest(".rich-code-wrap"))return;const f=c.textContent??"",d=a.createElement("div");d.innerHTML=zo(f,!1);const h=d.querySelector(".rich-code-wrap");h&&c.replaceWith(h)}),o.querySelectorAll("p, h2, h3, li").forEach(c=>{const f=(c.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=c.querySelector("img, hr"),h=!f&&!d&&Array.from(c.childNodes).every(b=>b.nodeType===Node.TEXT_NODE||b.nodeType===Node.ELEMENT_NODE&&b.tagName.toLowerCase()==="br");(!f&&!d||h)&&c.remove()}),o.querySelectorAll("li, td, th").forEach(c=>{const f=Array.from(c.children).filter(d=>/^(p|div)$/i.test(d.tagName));if(f.length===1&&c.children.length===1){const d=f[0];for(Array.from(d.classList).forEach(h=>{h.startsWith("rich-align-")&&c.classList.add(h)});d.firstChild;)c.insertBefore(d.firstChild,d);d.remove()}}),o.querySelectorAll("ul + ul, ol + ol").forEach(c=>{const f=c.previousElementSibling;if(!(!f||f.tagName!==c.tagName)){for(;c.firstChild;)f.appendChild(c.firstChild);c.remove()}});const i=(c,f)=>{const d=f==="start"?c.firstChild:c.lastChild;if(!d||d.nodeType!==Node.TEXT_NODE||!d.textContent)return;const h=f==="start"?d.textContent.replace(/^[\s\u00a0]+/,""):d.textContent.replace(/[\s\u00a0]+$/,"");h!==d.textContent&&(d.textContent=h)};return o.querySelectorAll("p, h2, h3, li, blockquote").forEach(c=>{i(c,"start"),i(c,"end")}),o.querySelectorAll("strong, b, em, i, u, s").forEach(c=>{let f=c.nextSibling;for(;f&&f.nodeType===Node.TEXT_NODE&&!(f.textContent??"").trim();)f=f.nextSibling;if(f&&f.nodeType===Node.ELEMENT_NODE&&f.tagName===c.tagName){const d=f;for(;d.firstChild;)c.appendChild(d.firstChild);d.remove()}}),o.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/[\u200b\ufeff\u00ad]/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},_o=e=>qr(e).replace(/\r\n?/g,`
|
|
39
|
+
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),zo=(e,r=!0)=>hi(e,qr,r),Ur=e=>{const r=e.replace(/\r\n?/g,`
|
|
40
|
+
`);if(!/```/.test(r))return _o(e);const n=[],a=/```(?:[\w-]*\n)?([\s\S]*?)```/g;let o=0,l;for(;(l=a.exec(r))!==null;)l.index>o&&n.push(_o(r.slice(o,l.index))),n.push(zo(l[1]??"")),o=a.lastIndex;return o<r.length&&n.push(_o(r.slice(o))),n.join("")},Ei=/```[\s\S]+?```/,Zb=e=>{const r=(e.textContent??"").replace(/\u00a0/g," ");if(!e.querySelector(".rich-code-wrap")&&r.includes("```")&&Ei.test(r)){const o=Ur(r);if(o.includes("rich-code-wrap"))return e.innerHTML=o,!0}let n=!1;const a=Array.from(e.children).filter(o=>o instanceof HTMLElement&&!o.classList.contains("rich-code-wrap"));for(const o of a){if(o.closest(".rich-code-wrap"))continue;const l=(o.textContent??"").replace(/\u00a0/g," ");if(!l.includes("```")||!Ei.test(l))continue;const i=Ur(l);if(!i.includes("rich-code-wrap"))continue;const c=document.createElement("div");c.innerHTML=i;const f=o.parentNode;if(f){for(;c.firstChild;)f.insertBefore(c.firstChild,o);o.remove(),n=!0}}return n},Qb=e=>new RegExp("\\p{L}","u").test(e),Wo=(e,r)=>{const n=e.trim();return!n||!Qb(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===Si(n)},Mi=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",ki())}(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 Ti({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full",focusModalZIndex:i=1e3}){const c=s.useId(),f=o||c,d=s.useCallback(()=>document,[]),h=s.useRef(null),b=s.useRef(null),u=s.useRef(new Map),p=s.useRef(null),g=s.useRef(!1),w=s.useRef(e??""),v=s.useRef(r),E=s.useRef(()=>{}),y=s.useRef(!1),[T,L]=s.useState(()=>!e||e.trim()===""),[C,m]=s.useState(new Set),[S,N]=s.useState(null),[_,U]=s.useState(""),[K,D]=s.useState(""),[Z,O]=s.useState(""),[ne,ee]=s.useState(""),[fe,J]=s.useState(3),[W,R]=s.useState(3),[$,P]=s.useState(!0),[ue,z]=s.useState(!1),[se,q]=s.useState(l==="full"),[k,V]=s.useState(null),[M,Y]=s.useState(null),ce=s.useRef(null),X=s.useRef(!1),G=s.useRef(null),I=s.useCallback(()=>g.current?b.current:h.current,[]);s.useEffect(()=>{v.current=r},[r]);const le=s.useCallback(()=>{const j=window.getSelection(),te=I();if(!j||!te||j.rangeCount===0||j.isCollapsed)return"";const me=j.getRangeAt(0);return!te.contains(me.startContainer)||!te.contains(me.endContainer)?"":j.toString()},[I]);s.useEffect(()=>{const j=e??"";if(y.current&&j===w.current){y.current=!1,L(!j||j.trim()==="");return}y.current=!1,w.current=j;const te=[h.current,b.current].filter(pe=>!!pe);te.forEach(pe=>{pe.innerHTML!==j&&(pe.innerHTML=j)}),L(!j||j.trim()===""),te.forEach(pe=>Bo(pe));const me=te.map(pe=>Mi(pe));return()=>me.forEach(pe=>pe())},[e]),s.useEffect(()=>{var pe,ye;g.current=ue;let j,te=0,me;if(ue){const Se=h.current;Se&&(w.current=da(Se));const ze=()=>{var it;const Te=b.current;if(!Te){te=requestAnimationFrame(ze);return}Te.innerHTML!==w.current&&(Te.innerHTML=w.current),j=Mi(Te),Bo(Te),L(((it=Te.textContent)==null?void 0:it.trim())===""),me=setTimeout(()=>Te.focus(),60)};te=requestAnimationFrame(ze)}else{const Se=b.current,ze=h.current,Te=Se?da(Se):w.current,it=w.current;w.current=Te,ze&&ze.innerHTML!==Te&&(ze.innerHTML=Te),Te!==it&&v.current(Te),L(((ye=(pe=Se??ze)==null?void 0:pe.textContent)==null?void 0:ye.trim())==="")}return()=>{te&&cancelAnimationFrame(te),me&&clearTimeout(me),j==null||j()}},[ue]);const be=s.useCallback(()=>{const j=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],te=new Set;j.forEach(pe=>{try{d().queryCommandState(pe)&&te.add(pe)}catch{return}});try{const pe=$b(d().queryCommandValue("formatBlock"));pe&&te.add(`formatBlock:${pe}`)}catch{}const me=le();Wo(me,"uppercase")&&te.add("__upper"),Wo(me,"lowercase")&&te.add("__lower"),Wo(me,"capitalize")&&te.add("__cap");try{const pe=window.getSelection();let ye=(pe==null?void 0:pe.anchorNode)??null;(ye==null?void 0:ye.nodeType)===Node.TEXT_NODE&&(ye=ye.parentElement),ye instanceof Element&&ye.closest(".rich-code-wrap")&&te.add("__code")}catch{}m(te)},[le,d]),ie=()=>{var te;const j=I();j&&(Zb(j),w.current=da(j),y.current=!0,v.current(w.current),L(((te=j.textContent)==null?void 0:te.trim())===""))};E.current=ie;const ge=s.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=null),ce.current&&(gi(ce.current),ce.current=null),X.current=!1,V(null),Y(null)},[]),$e=s.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=null)},[]),De=s.useCallback(()=>{$e(),G.current=setTimeout(()=>{X.current||ge()},280)},[$e,ge]);s.useEffect(()=>()=>{G.current&&clearTimeout(G.current)},[]);const kt=s.useCallback(j=>{const te=ce.current;if(!te||!te.isConnected){ge();return}const me=(k==null?void 0:k.rowIndex)??(M==null?void 0:M.rowIndex)??-1,pe=(k==null?void 0:k.colIndex)??(M==null?void 0:M.colIndex)??-1;Cb(j,te,me,pe,I()),ge(),E.current(),be()},[I,ge,be,M,k]),wt=s.useCallback(j=>{if(M)return;const te=j.currentTarget,me=j.target;if(me.closest(".rich-table-action-bar, .rich-table-context-menu")){$e();return}const pe=me.closest("td, th");if(!pe||!te.contains(pe)){De();return}const ye=pe.closest("tr"),Se=pe.closest("table");if(!ye||!Se||!te.contains(Se)){De();return}$e(),Se.classList.add("rich-table"),ce.current=Se,vi(Se,ye,pe.cellIndex),V(Sb(Se,ye,pe))},[$e,De,M]),re=s.useCallback(j=>{const te=j.relatedTarget;if(te instanceof Element&&(te.closest(".rich-table-action-bar")||te.closest(".rich-table-context-menu"))){$e();return}De()},[$e,De]),xe=s.useCallback(j=>{const te=j.currentTarget,pe=j.target.closest("td, th");if(!pe||!te.contains(pe))return;const ye=pe.closest("tr"),Se=pe.closest("table");if(!ye||!Se||!te.contains(Se))return;j.preventDefault(),Se.classList.add("rich-table"),ce.current=Se;const ze=Array.from(Se.rows).indexOf(ye),Te=pe.cellIndex;vi(Se,ye,Te),V(null),Y({x:j.clientX,y:j.clientY,rowIndex:ze,colIndex:Te})},[]);s.useEffect(()=>{if(!k&&!M)return;const j=()=>De();return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[De,M,k]),s.useEffect(()=>{if(!M)return;const j=te=>{const me=te.target;me instanceof Element&&me.closest(".rich-table-context-menu")||Y(null)};return window.addEventListener("mousedown",j),()=>window.removeEventListener("mousedown",j)},[M]);const oe=j=>{if(!j){const te=h.current;te&&(w.current=da(te))}z(!j)},we=(j,te)=>{var me;(me=I())==null||me.focus(),d().execCommand(j,!1,te),ie(),be()},ae=j=>{we("formatBlock",j)},Fe=()=>{var j;(j=I())==null||j.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),ie(),be()},qe=()=>{const j=window.getSelection();j&&j.rangeCount>0&&(p.current=j.getRangeAt(0).cloneRange())},Je=()=>{const j=window.getSelection();j&&p.current&&(j.removeAllRanges(),j.addRange(p.current))},Ze=j=>{if(qe(),j==="link"){const te=window.getSelection();D(te&&!te.isCollapsed?te.toString():""),U("")}j==="image"&&(O(""),ee("")),j==="table"&&(J(3),R(3),P(!0)),N(j)},Ue=()=>{var pe;if(!_.trim())return;Je(),(pe=I())==null||pe.focus();const j=window.getSelection(),me=(j&&!j.isCollapsed?j.toString():"")||K.trim()||_.trim();d().execCommand("insertHTML",!1,`<a href="${qr(_.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${qr(me)}</a>`),ie(),N(null)},tt=(j,te="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${qr(j)}" alt="${qr(te)}" class="rich-img" />${ki()}</span>`,Ct=()=>{var j;Z.trim()&&(Je(),(j=I())==null||j.focus(),d().execCommand("insertHTML",!1,tt(Z.trim(),ne.trim())),ie(),N(null))},xt=()=>{var j;Je(),(j=I())==null||j.focus(),d().execCommand("insertHTML",!1,Lb(fe,W,$)),ie(),N(null)},Et=()=>{var me;Je(),(me=I())==null||me.focus();const j=window.getSelection(),te=j&&!j.isCollapsed?j.toString():"";d().execCommand("insertHTML",!1,zo(te)),ie()},ve=(j,te=1200,me=1200,pe=.72)=>new Promise((ye,Se)=>{const ze=new FileReader;ze.onerror=Se,ze.onload=Te=>{var mt;const it=(mt=Te.target)==null?void 0:mt.result,Ve=new Image;Ve.onerror=Se,Ve.onload=()=>{let{width:ut,height:gt}=Ve;if(ut>te||gt>me){const Ot=Math.min(te/ut,me/gt);ut=Math.round(ut*Ot),gt=Math.round(gt*Ot)}const nr=document.createElement("canvas");nr.width=ut,nr.height=gt;const Ut=nr.getContext("2d");if(!Ut){ye(it);return}Ut.drawImage(Ve,0,0,ut,gt),ye(nr.toDataURL("image/jpeg",pe))},Ve.src=it},ze.readAsDataURL(j)}),ke=j=>{j.focus();const te=window.getSelection();if(!te||te.rangeCount===0||!j.contains(te.anchorNode)){const me=document.createRange();me.selectNodeContents(j),me.collapse(!1),te==null||te.removeAllRanges(),te==null||te.addRange(me)}},_e=s.useRef(()=>{});_e.current=j=>{const te=I();if(!te)return;ke(te);const me=window.getSelection(),pe=/<(?:p|div|ul|ol|h[1-6]|table|blockquote|pre|hr)\b/i.test(j),ye=me&&me.rangeCount>0?me.getRangeAt(0):null,Se=(ye==null?void 0:ye.startContainer.nodeType)===Node.ELEMENT_NODE?ye.startContainer:ye==null?void 0:ye.startContainer.parentElement,ze=!!(Se!=null&&Se.closest("li, table"));if(!pe||!ye||!te.contains(ye.startContainer)||ze)d().execCommand("insertHTML",!1,j);else{ye.deleteContents();let Te=ye.startContainer.nodeType===Node.ELEMENT_NODE?ye.startContainer:ye.startContainer.parentElement;const it=new Set(["p","div","h2","h3","blockquote"]);for(;Te&&Te!==te&&!it.has(Te.tagName.toLowerCase());)Te=Te.parentElement;const Ve=document.createElement("div");Ve.innerHTML=j;const mt=Array.from(Ve.childNodes);if(!Te||Te===te){ye.insertNode(Ve);const ut=Ve.parentNode;for(;Ve.firstChild;)ut==null||ut.insertBefore(Ve.firstChild,Ve);Ve.remove()}else{const ut=document.createRange();ut.setStart(ye.endContainer,ye.endOffset),ut.setEnd(Te,Te.childNodes.length);const gt=ut.extractContents(),nr=(gt.textContent??"").replace(/[\u00a0\s]+/g,""),Ut=(Te.textContent??"").replace(/[\u00a0\s]+/g,""),Ot=Te.parentNode;if(!Ot)d().execCommand("insertHTML",!1,j);else{const ar=!Ut&&!Te.querySelector("img, table, hr"),mr=ar?Te:Te.nextSibling;let Ht=null;for(const yt of mt)Ot.insertBefore(yt,mr),Ht=yt;if(nr&&Ht){const yt=document.createElement("p");yt.appendChild(gt),Ot.insertBefore(yt,Ht.nextSibling)}if(ar&&Te.remove(),Ht&&me){const yt=document.createRange();yt.setStartAfter(Ht),yt.collapse(!0),me.removeAllRanges(),me.addRange(yt)}}}}Bo(te),te.querySelectorAll("p").forEach(Te=>{!(Te.textContent??"").replace(/[\u00a0\s]+/g,"")&&!Te.querySelector("img, hr, table")&&Te.remove()}),ie(),be()};const je=s.useRef(ve);je.current=ve;const Re=s.useRef(tt);Re.current=tt;const ot=s.useCallback(j=>{if(!j||u.current.has(j))return;const te=me=>{const pe=me.clipboardData;if(!pe)return;const ye=pe.getData("text/html"),Se=pe.getData("text/plain");if(ye||Se){me.preventDefault(),me.stopPropagation();try{const Ve=ye?Kb(ye):Ur(Se),mt=Se.replace(/\s+/g," ").trim(),ut=Ve.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim(),gt=/<(?:ul|ol|table|img|h2|h3|blockquote)\b/i.test(Ve);if(mt.length>80&&!gt&&ut.length<mt.length*.6){_e.current(Ur(Se));return}if(!Ve){Se&&_e.current(Ur(Se));return}_e.current(Ve)}catch{Se&&_e.current(Ur(Se))}return}const Te=Array.from(pe.items).find(Ve=>Ve.type.startsWith("image/"));if(!Te)return;me.preventDefault(),me.stopPropagation();const it=Te.getAsFile();it&&je.current(it).then(Ve=>{_e.current(Re.current(Ve,"imagen"))})};j.addEventListener("paste",te,!0),u.current.set(j,()=>{j.removeEventListener("paste",te,!0),u.current.delete(j)})},[]),lt=s.useCallback(j=>{var me;const te=h.current;te&&te!==j&&((me=u.current.get(te))==null||me()),h.current=j,j&&ot(j)},[ot]),rt=s.useCallback(j=>{var me;const te=b.current;te&&te!==j&&((me=u.current.get(te))==null||me()),b.current=j,j&&ot(j)},[ot]);s.useEffect(()=>{const j=u.current;return()=>{j.forEach(te=>te()),j.clear()}},[]);const dt=j=>{const te=window.getSelection(),me=I();if(!te||!me||te.rangeCount===0||te.isCollapsed)return;const pe=te.getRangeAt(0);if(!me.contains(pe.startContainer)||!me.contains(pe.endContainer))return;const ye=pe.toString();if(!ye)return;let Se=ye;j==="uppercase"?Se=ye.toLocaleUpperCase():j==="lowercase"?Se=ye.toLocaleLowerCase():Se=Si(ye),pe.deleteContents();const ze=document.createTextNode(Se);pe.insertNode(ze);const Te=document.createRange();Te.setStart(ze,0),Te.setEnd(ze,Se.length),te.removeAllRanges(),te.addRange(Te),p.current=Te.cloneRange(),ie(),be()},st=()=>{qe(),be()},Sr=()=>{const j=I();j&&xi(j),ie(),be()},ht=()=>{requestAnimationFrame(()=>{var j;(j=I())==null||j.focus()})},Cr=j=>{var te,me;if((j.metaKey||j.ctrlKey)&&j.key==="Enter"){if(j.preventDefault(),j.stopPropagation(),j.repeat)return;(te=I())==null||te.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),ie(),be();return}if(j.key==="Tab"){const pe=window.getSelection(),ye=wi((pe==null?void 0:pe.anchorNode)??null),Se=I(),ze=yi(ye);if(ye&&ze&&(Se!=null&&Se.contains(ye))){j.preventDefault();const Te=Mb(ze),it=Te.indexOf(ye),Ve=it>=0?Te[it+1]:null;if(Ve)fa(Ve,Se,!0);else if(Ni(ye,ze)){const mt=Ho(ze);mt&&fa(mt,Se,!0)}ie(),be();return}j.preventDefault(),(me=I())==null||me.focus(),d().execCommand("insertText",!1," "),ie(),be();return}if(j.key==="Enter"&&!j.shiftKey&&!(j.metaKey||j.ctrlKey)){const pe=window.getSelection(),ye=wi((pe==null?void 0:pe.anchorNode)??null),Se=I(),ze=yi(ye);if(ye&&ze&&(Se!=null&&Se.contains(ye))&&Ni(ye,ze)&&Tb(ye)){j.preventDefault();const Te=Ho(ze);Te&&fa(Te,Se,!0),ie(),be();return}}if(j.key==="Escape"){if(M){Y(null);return}if(S){N(null);return}if(g.current){z(!1);return}}S||(j.ctrlKey||j.metaKey)&&(j.key==="b"&&(j.preventDefault(),we("bold")),j.key==="i"&&(j.preventDefault(),we("italic")),j.key==="u"&&(j.preventDefault(),we("underline")),j.key==="k"&&(j.preventDefault(),Ze("link")))},Ft=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ye=(j,te,me,pe,ye)=>{const Se=ye??(C.has(me)||me==="__link"&&S==="link"||me==="__img"&&S==="image"||me==="__table"&&S==="table");return t.jsx("button",{type:"button",title:te,tabIndex:-1,onFocus:ht,onMouseDown:ze=>{ze.preventDefault(),pe?pe():we(me)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Se?"var(--primary)":"var(--text-secondary)",background:Se?"rgba(59,130,246,0.12)":"transparent"},children:j},me)},pt=j=>{const te=j.target;if(te.closest("[data-action='delete-img']")){j.preventDefault();const pe=te.closest(".rich-img-wrap");pe&&(pe.remove(),ie());return}const me=te.closest("[data-action='copy-code']");me instanceof HTMLButtonElement&&(j.preventDefault(),fi(me).catch(()=>{}))},hr=()=>{$e(),X.current=!0},Mt=()=>{X.current=!1,De()},qt=(j,te,me,pe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${pe?" rich-table-action-btn--danger":""}`,title:j,"aria-label":j,onMouseDown:ye=>{ye.preventDefault(),ye.stopPropagation(),kt(me)},children:te}),Er=()=>typeof document>"u"||!k&&!M?null:bt.createPortal(t.jsxs(t.Fragment,{children:[k&&!M&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:k.bar.x,top:k.bar.y},onMouseEnter:hr,onMouseLeave:Mt,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"}),qt("Añadir fila abajo","+","table-row-add"),qt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),qt("Añadir columna a la derecha","+","table-col-add"),qt("Eliminar columna","−","table-col-del")]}),qt("Eliminar tabla","Eliminar","table-delete",!0)]}),M&&t.jsx("div",{className:"rich-table-context-menu",style:{left:M.x,top:M.y},onMouseDown:j=>j.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(([j,te])=>t.jsx("button",{type:"button",onMouseDown:me=>{me.preventDefault(),kt(te)},children:j},te))})]}),document.body),pr=j=>t.jsxs(t.Fragment,{children:[S==="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:j},children:[t.jsx("input",{autoFocus:!0,type:"url",value:_,onChange:te=>U(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),Ue()),te.key==="Escape"&&N(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:K,onChange:te=>D(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),Ue()),te.key==="Escape"&&N(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Ue,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),S==="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:j},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:jr,value:fe,onChange:te=>J(ia(Number(te.target.value),1,jr)),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),xt()),te.key==="Escape"&&N(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:ca,value:W,onChange:te=>R(ia(Number(te.target.value),1,ca)),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),xt()),te.key==="Escape"&&N(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:$,onChange:te=>P(te.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:xt,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),S==="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:j},children:[t.jsx("input",{autoFocus:!0,type:"url",value:Z,onChange:te=>O(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),Ct()),te.key==="Escape"&&N(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:ne,onChange:te=>ee(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),Ct()),te.key==="Escape"&&N(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Ct,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),tn=(j,te)=>{const me=l==="compact",pe=!me||se||j;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:te},"data-toolbar-variant":l,children:[me&&!j&&t.jsxs("button",{type:"button",title:se?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:ht,onMouseDown:ye=>{ye.preventDefault(),q(Se=>!Se)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:se?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[se?t.jsx(F.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(F.HiChevronDown,{className:"h-3.5 w-3.5"}),se?"Ocultar herramientas":"Herramientas"]}),pe&&t.jsxs(t.Fragment,{children:[Ye(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ye(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ye(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ye(t.jsx(F.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ye(t.jsx(F.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ye(t.jsx(F.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Ze("link")),Ft(),Ye(t.jsx(F.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ye(t.jsx(F.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Ft(),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ae("p"),C.has("formatBlock:p")||C.has("formatBlock:div")),Ye(t.jsx(F.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ae("h2"),C.has("formatBlock:h2")),Ye(t.jsx(F.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ae("h3"),C.has("formatBlock:h3")),Ye(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ae("blockquote"),C.has("formatBlock:blockquote")),Ye(t.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"10px"},children:"</>"}),"Bloque de código","__code",()=>Et(),C.has("__code")),Ft(),Ye(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Ft(),Ye(t.jsx(F.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ye(t.jsx(F.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Ft(),Ye(t.jsx(F.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ye(t.jsx(F.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ye(t.jsx(F.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ye(t.jsx(F.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Ft(),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>dt("uppercase")),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>dt("lowercase")),Ye(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>dt("capitalize")),Ft(),Ye(t.jsx(F.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ye(t.jsx(F.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Ze("image")),Ye(t.jsx(F.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Ze("table")),Ye(t.jsx(F.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",Fe),Ft(),Ye(t.jsx(F.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ye(t.jsx(F.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ae("p"))]}),Ft(),t.jsx("button",{type:"button",title:j?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:ht,onMouseDown:ye=>{ye.preventDefault(),oe(j)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:j?t.jsx(F.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(F.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Er(),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:lt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":f,onInput:Sr,onKeyDown:Cr,onKeyUp:st,onSelect:st,onMouseUp:st,onMouseMove:wt,onMouseLeave:re,onContextMenu:xe,onMouseDown:pt,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${T?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),pr("var(--bg-input)"),tn(!1,"var(--bg-input)")]}),t.jsxs(xo,{open:ue,onClose:()=>z(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",zIndex:i,children:[t.jsx("div",{ref:rt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":f,onInput:Sr,onKeyDown:Cr,onKeyUp:st,onSelect:st,onMouseUp:st,onMouseMove:wt,onMouseLeave:re,onContextMenu:xe,onMouseDown:pt,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${T?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),pr("var(--bg-input)"),tn(!0,"var(--bg-input)")]})]})}const Ai="[a-zA-Z0-9._@-]+",jo=new RegExp(`@(${Ai})`,"g"),Jb=/[a-zA-Z0-9._@-]/,Nn=new Set([" ",`
|
|
41
|
+
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function Li(e,r){if(r<=0)return!0;const n=e[r-1]??"";return Nn.has(n)}function $i(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(Nn.has(c)||!Jb.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):Li(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${Ai}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function Di(e,r){var a;const n=Vr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Ii(e,r){if(r<=0)return!0;const n=Vr(e,r);if(!n){const o=Ko(e);return Li(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return Nn.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 Nn.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 Nn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function qo(e,r){const n=Ko(e);return $i(n,r,{isTriggerBoundary:a=>Ii(e,a),isInsideExistingMention:a=>Di(e,a)})}function Uo(e){return e.toLowerCase().trim()}function Fi(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
|
|
42
42
|
`).replace(/<\/(p|div|li)>/gi,`
|
|
43
|
-
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function
|
|
44
|
-
`,(r==null?void 0:r.locatePlain)===n.length?(u==null?void 0:u.nodeType)===Node.TEXT_NODE?(a={node:u,offset:0},"matched"):"matched-at-newline":!1),d=u=>{const p=u.data;for(let
|
|
45
|
-
`)&&f(u)==="matched")return!0;if(u.nodeType===Node.TEXT_NODE)return d(u);if(u.nodeType!==Node.ELEMENT_NODE)return!1;const v=u;if(v.tagName==="BR")return i(v,0),f(v.nextSibling??void 0)==="matched";const w=Array.from(u.childNodes);for(let g=0;g<w.length;g+=1){const E=w[g],y=g>0&&E.nodeType===Node.ELEMENT_NODE&&ei(E,e);if(h(E,y))return!0}return!1},b=Array.from(e.childNodes);for(let u=0;u<b.length;u+=1){const p=b[u],v=u>0&&p.nodeType===Node.ELEMENT_NODE&&ei(p,e);if(h(p,v))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const u=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=u.nextNode(),v=p;for(;v;)p=v,v=u.nextNode();p&&(a={node:p,offset:p.data.length})}return{plain:n,locate:a,domOffset:o}}function Wo(e){return zo(e).plain}function qr(e,r){return r<0?null:zo(e,{locatePlain:r}).locate??null}function ia(e,r,n){return e!==r&&!e.contains(r)?-1:zo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function ti(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=qr(e,n),i=qr(e,a);if(!l||!i)return null;const c=e.ownerDocument,f=c.createRange();f.setStart(l.node,l.offset),f.setEnd(i.node,i.offset),f.deleteContents();const d=Ql({name:r.display,username:o}),h=c.createElement("span");h.className="mention-chip",h.setAttribute("data-username",o.toLowerCase()),r.userId&&h.setAttribute("data-userid",String(r.userId)),h.contentEditable="false",h.textContent=d,h.title=`@${o}`;const b=c.createTextNode(" "),u=c.createDocumentFragment();u.append(h,b),f.insertNode(u),yn(e),_o(h);const p=c.defaultView,v=p==null?void 0:p.getSelection(),w=v!=null&&v.rangeCount?ia(e,v.getRangeAt(0).startContainer,v.getRangeAt(0).startOffset):n+d.length+1;return{caretPlainOffset:w>=0?w:n+d.length+1}}function ri(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=qr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function ca(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function ni(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 ai(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function Ur(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function da(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 oi(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),da(e)}function si(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function li(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(),Ur(e),!0):!1}function ua(e){var h,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(u,p)=>{let v=u;for(;v&&v.nodeType===Node.TEXT_NODE&&(v.textContent??"")==="";){const w=v;v=v[p],w.remove()}return v},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const u=o;(u.data.length??0)<=1?u.remove():u.data=u.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const f=(h=r.defaultView)==null?void 0:h.getSelection();if(!f)return;const d=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const u=((b=l.textContent)==null?void 0:b.length)??0;d.setStart(l,u)}else d.setStartAfter(l);else i.childNodes[c]?d.setStart(i,c):(d.selectNodeContents(i),d.collapse(!1));d.collapse(!0),f.removeAllRanges(),f.addRange(d)}function ii(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=ni(a.previousSibling,"prev");return ca(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 f=i[c];if(ca(f))return f;if(f.nodeType===Node.TEXT_NODE&&!(f.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function ci(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=ni(a.nextSibling,"next");if(ca(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o;for(;c<i.length;){const f=i[c];if(ca(f))return f;if(f.nodeType===Node.TEXT_NODE&&!(f.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function jo(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 qo=420,fa=6,di=260,sb=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ui=4,lb={position:"relative"},ib={position:"fixed",zIndex:11050,minWidth:di,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},fi={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function cb(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function db(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-di-8)),n=window.innerHeight-e.bottom-fa-8,a=e.top-fa-8;return n<Math.min(qo,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+fa,maxHeight:Math.min(qo,Math.max(120,a))}:{left:r,top:e.bottom+fa,maxHeight:Math.min(qo,Math.max(120,n))}}function bi({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:f=140,highlightInEditor:d=!1,searchCacheKey:h="",toolbarVariant:b="full",focusModalZIndex:u}){const p=s.useId().replace(/:/g,""),v=s.useRef(null),w=s.useRef(null),g=s.useRef(new Map),E=s.useRef(n);E.current=n;const y=s.useRef(null),M=s.useRef(0),L=s.useRef([]),C=s.useRef(null),[m,k]=s.useState(null),[N,_]=s.useState([]),[q,K]=s.useState(0),[$,Q]=s.useState([]),[X,se]=s.useState(!1),[J,fe]=s.useState(!1);M.current=q,s.useEffect(()=>{fe(!0)},[]);const te=(m==null?void 0:m.query)??null;s.useEffect(()=>{if(te===null){_([]);return}const S=te.trim(),U=`${h}|${S.toLowerCase()||"*"}`,T=g.current.get(U);if(T){_(T),se(!1),K(0);return}const Y=new AbortController;se(!0);const ce=window.setTimeout(()=>{(async()=>{try{const V=await E.current(S,{signal:Y.signal,limit:c});if(Y.signal.aborted)return;const G=Array.isArray(V)?V:[];g.current.set(U,G),_(G),K(0)}catch{Y.signal.aborted||_([])}finally{Y.signal.aborted||se(!1)}})()},f);return()=>{Y.abort(),window.clearTimeout(ce)}},[te,c,f,h]);const z=s.useRef(a);z.current=a,s.useEffect(()=>{var S;(S=z.current)==null||S.call(z,Jl($))},[$]);const R=s.useCallback(()=>{const S=cb(p);if(S.length===0)return null;const U=window.getSelection();if(U!=null&&U.rangeCount){const Y=U.getRangeAt(0).startContainer;for(const ce of S)if(ce.contains(Y))return ce}const T=document.activeElement;for(const Y of S)if(T===Y||T&&Y.contains(T))return Y;for(const Y of S)if(Y.closest('[role="dialog"]'))return Y;return S[0]??null},[p]),A=s.useCallback(()=>{const S=R(),U=window.getSelection();if(!S||!U||U.rangeCount===0){k(null);return}const T=U.getRangeAt(0);if(!S.contains(T.startContainer)){k(null);return}const Y=ia(S,T.startContainer,T.startOffset);if(Y<0){k(null);return}const ce=Io(S,Y);if(!ce){k(null);return}const V=T.getBoundingClientRect(),G=V.width===0&&V.height===0?(()=>{const le=document.createRange();return le.selectNodeContents(T.startContainer),le.collapse(!0),le.getBoundingClientRect()})():V;y.current={query:ce.query,caretIndex:ce.caretIndex,triggerIndex:ce.triggerIndex};const D=db(G);k(le=>{const be={query:ce.query,...D};return le&&le.query===be.query&&le.top===be.top&&le.bottom===be.bottom&&le.left===be.left&&le.maxHeight===be.maxHeight?le:be})},[R]),F=s.useCallback(S=>{r(S),A()},[r,A]);s.useEffect(()=>{const S=U=>{if(sb.has(U.key))return;const T=R(),Y=U.target;!T||!Y||!T.contains(Y)||A()};return document.addEventListener("keyup",S,!0),()=>document.removeEventListener("keyup",S,!0)},[R,A]);const ue=s.useCallback(S=>{const U=R();if(!U)return;let T=-1;const Y=window.getSelection();if(Y&&Y.rangeCount>0){const le=Y.getRangeAt(0);U.contains(le.startContainer)&&(T=ia(U,le.startContainer,le.startOffset))}if(T<0&&y.current&&(T=y.current.caretIndex),T<0)return;const ce=Io(U,T);if(!ce)return;const V=ti(U,{triggerIndex:ce.triggerIndex,caretIndex:T,username:S.username,display:S.name,userId:S.userId});if(!V)return;yn(U),U.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const G={userId:S.userId,username:S.username,email:S.email??void 0,display:S.name??S.username};Q(le=>{const be=new Map(le.map(ie=>[ie.userId,ie]));return be.set(G.userId,G),Array.from(be.values())}),k(null),y.current=null;const D=S.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const le=R();if(!le)return;le.focus(),yn(le);const be=Array.from(le.querySelectorAll(".mention-chip")),ie=[...be].reverse().find(ge=>ge.getAttribute("data-username")===D)??be[be.length-1];if(ie){_o(ie);return}ri(le,V.caretPlainOffset)})})},[R]);s.useEffect(()=>{const S=new Set(Fo(e).map(U=>U.toLowerCase()));Q(U=>{const T=U.filter(Y=>S.has(Y.username.toLowerCase()));return T.length===U.length?U:T})},[e]),s.useEffect(()=>{if(!m)return;const S=U=>{const T=U.target;if(!T||v.current&&v.current.contains(T)||w.current&&w.current.contains(T))return;const Y=R();Y&&Y.contains(T)||k(null)};return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[m,R]);const P=s.useMemo(()=>N.slice(0,c),[N,c]);L.current=P,s.useEffect(()=>{if(!m)return;const S=U=>{const T=R(),Y=U.target;if(!T||!Y||!T.contains(Y))return;const ce=L.current;if(!(ce.length===0&&U.key!=="Escape"))if(U.key==="ArrowDown")U.preventDefault(),U.stopPropagation(),K(V=>(V+1)%Math.max(ce.length,1));else if(U.key==="ArrowUp")U.preventDefault(),U.stopPropagation(),K(V=>(V-1+ce.length)%Math.max(ce.length,1));else if(U.key==="Enter"||U.key==="Tab"){const V=ce[M.current];V&&(U.preventDefault(),U.stopPropagation(),ue(V))}else U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),k(null))};return document.addEventListener("keydown",S,!0),()=>document.removeEventListener("keydown",S,!0)},[R,ue,m]),s.useEffect(()=>{const S=G=>{G.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},U=G=>{const D=R(),le=G.target;if(!D||!le||!D.contains(le))return;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="a"){G.preventDefault(),G.stopPropagation(),D.focus(),oi(D);return}if(G.key!=="Backspace"&&G.key!=="Delete")return;const be=window.getSelection();if(be&&!be.isCollapsed&&be.rangeCount>0){const $e=be.getRangeAt(0);if(D.contains($e.commonAncestorContainer)&&jo(D).length>0&&si($e)){G.preventDefault(),G.stopPropagation(),li(D)&&S(D);return}}const ie=jo(D);if(ie.length>0){G.preventDefault(),G.stopPropagation();for(const $e of ie)ua($e);Ur(D),S(D);return}if(G.key==="Backspace"){const $e=ii(D);if(!$e)return;G.preventDefault(),G.stopPropagation(),ua($e),Ur(D),S(D);return}const ge=ci(D);ge&&(G.preventDefault(),G.stopPropagation(),ua(ge),Ur(D),S(D))},T=G=>{const D=R();if(!D)return;const le=G.target;if(!(le instanceof Element)||!D.contains(le))return;const be=le.closest(".mention-chip");if(!(be instanceof HTMLElement)||!D.contains(be)){C.current=null,Ur(D);return}G.shiftKey||G.button!==0||(C.current={chip:be,x:G.clientX,y:G.clientY})},Y=G=>{const D=C.current;if(!D)return;const le=Math.abs(G.clientX-D.x),be=Math.abs(G.clientY-D.y);(le>ui||be>ui)&&(C.current=null)},ce=G=>{var ge;const D=R(),le=C.current;if(C.current=null,!D||!le)return;const be=G.target;if(!(be instanceof Element)||!D.contains(be)||!((ge=be.closest(".mention-chip"))!=null&&ge.isSameNode(le.chip)))return;const ie=window.getSelection();if(ie){if(!ie.isCollapsed){da(D);return}D.focus(),ai(le.chip)}},V=()=>{const G=R();if(!G)return;const D=window.getSelection();!D||D.rangeCount===0||!D.anchorNode||!G.contains(D.anchorNode)||!D.focusNode||!G.contains(D.focusNode)||da(G)};return document.addEventListener("keydown",U,!0),document.addEventListener("mousedown",T,!0),document.addEventListener("mousemove",Y,!0),document.addEventListener("mouseup",ce,!0),document.addEventListener("selectionchange",V),()=>{document.removeEventListener("keydown",U,!0),document.removeEventListener("mousedown",T,!0),document.removeEventListener("mousemove",Y,!0),document.removeEventListener("mouseup",ce,!0),document.removeEventListener("selectionchange",V)}},[R]),s.useEffect(()=>{if(!m||!w.current)return;const S=w.current.querySelector(`[data-mention-index="${q}"]`);S==null||S.scrollIntoView({block:"nearest"})},[q,m]);const oe=d?Rl(e):e,j=m&&J?ft.createPortal(t.jsxs("ul",{ref:w,style:{...ib,left:m.left,top:m.top,bottom:m.bottom,maxHeight:m.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[X&&P.length===0&&t.jsx("li",{style:fi,children:"Buscando…"}),!X&&P.length===0&&t.jsx("li",{style:fi,children:m.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${m.query}”`}),P.map((S,U)=>{var T,Y;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":U,onMouseDown:ce=>{ce.preventDefault(),ue(S)},onMouseEnter:()=>K(U),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:U===q?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((T=S.name)==null?void 0:T.trim())||`@${S.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(Y=S.name)!=null&&Y.trim()?`@${S.username}`:null,S.email].filter(Boolean).join(" · ")||`@${S.username}`})]})},S.userId)})]}),document.body):null;return t.jsxs("div",{ref:v,style:lb,className:i,children:[t.jsx(Ul,{value:oe,onChange:F,placeholder:l,minHeight:o,instanceId:p,toolbarVariant:b,focusModalZIndex:u}),j]})}function ub({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:f,highlightInEditor:d,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:u}){return o?t.jsx(bi,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:f,highlightInEditor:d,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:u}):t.jsx(Ul,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b,focusModalZIndex:u})}function fb({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const f=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[f&&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 bb={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)"}},hb={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 pb({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=bb[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 ${hb[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 hi={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)"}},mb={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"},gb={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},vb={xs:148,sm:164,md:184},xb={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 yb({value:e,options:r,onChange:n,size:a="sm",disabled:o=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:f="Cambiar estado",className:d,selectClassName:h,menuClassName:b,optionClassName:u,spinnerClassName:p}){const[v,w]=s.useState(!1),[g,E]=s.useState(!1),[y,M]=s.useState(-1),[L,C]=s.useState({}),m=s.useRef(null),k=s.useRef(null),N=s.useRef(null),_=r.find(te=>te.value===e)??r[0],q={..._!=null&&_.tone?hi[_.tone]:void 0,..._==null?void 0:_.style},K=o||l||r.length===0,$=te=>{i&&te.stopPropagation()},Q=s.useCallback(()=>{w(!1),M(-1)},[]),X=s.useCallback(()=>{const te=m.current;if(!te)return;const z=te.getBoundingClientRect(),R=Math.max(z.width,vb[a]),A=Math.min(Math.max(r.length,1)*38+12,260),F=window.innerHeight-z.bottom,ue=F<A&&z.top>F,P=Math.min(Math.max(8,z.left+z.width/2-R/2),window.innerWidth-R-8);C({position:"fixed",left:P,top:ue?void 0:z.bottom+6,bottom:ue?window.innerHeight-z.top+6:void 0,width:R,zIndex:9999})},[r.length,a]),se=s.useCallback(te=>{te.disabled||(n(te.value),Q())},[Q,n]);s.useEffect(()=>E(!0),[]),s.useEffect(()=>{if(!v)return;X();const te=r.findIndex(z=>z.value===e);M(te>=0?te:0)},[v,r,X,e]),s.useEffect(()=>{if(!v)return;function te(z){var A,F;const R=z.target;!((A=m.current)!=null&&A.contains(R))&&!((F=k.current)!=null&&F.contains(R))&&Q()}return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[Q,v]),s.useEffect(()=>{if(v)return window.addEventListener("resize",X),window.addEventListener("scroll",X,!0),()=>{window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)}},[v,X]),s.useEffect(()=>{if(y<0||!N.current)return;const te=N.current.children[y];te==null||te.scrollIntoView({block:"nearest"})},[y]);function J(te){if(!K){if(!v){["Enter"," ","ArrowDown","ArrowUp"].includes(te.key)&&(te.preventDefault(),w(!0));return}if(te.key==="Escape"){te.preventDefault(),Q();return}if(te.key==="ArrowDown"){te.preventDefault(),M(z=>Math.min(z+1,r.length-1));return}if(te.key==="ArrowUp"){te.preventDefault(),M(z=>Math.max(z-1,0));return}if(te.key==="Enter"||te.key===" "){te.preventDefault();const z=r[y];z&&se(z)}}}const fe=t.jsx("div",{ref:k,role:"listbox","aria-label":c,className:We("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...L,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:$,onMouseDown:$,onPointerDown:$,children:t.jsx("div",{ref:N,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((te,z)=>{const R=te.value===e,A=z===y,F={...te.tone?hi[te.tone]:void 0,...te.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":R,disabled:te.disabled,onMouseEnter:()=>!te.disabled&&M(z),onMouseDown:ue=>{ue.preventDefault(),se(te)},className:We("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",xb[a],R?te.className:void 0,u),style:{...R?F:void 0,background:R?F.background??"color-mix(in srgb, var(--primary) 12%, transparent)":A?"var(--bg-hover)":"transparent",color:R?F.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:R?t.jsx(H.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:te.label})]},te.value)})})});return t.jsxs("span",{ref:m,className:We("relative inline-flex shrink-0 items-center",d),onKeyDown:J,onClick:$,onPointerDown:$,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":v,title:f,onClick:()=>!K&&w(te=>!te),className:We("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",mb[a],_==null?void 0:_.className,h),style:q,children:t.jsx("span",{className:"min-w-0 truncate",children:(_==null?void 0:_.label)??e})}),t.jsx(H.HiChevronDown,{"aria-hidden":"true",className:We("pointer-events-none absolute opacity-70 transition-transform",gb[a],v?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:We("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",p)}),v&&g&&ft.createPortal(fe,document.body)]})}function wb({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:f=""}){const d=e.find(v=>!v.disabled)??e[0],h=r??n??(d==null?void 0:d.id),b=e.find(v=>v.id===h)??d,u=v=>{v.disabled||a==null||a(v.id)},p=v=>{const w=e.filter(E=>!E.disabled);if(!w.length||!b)return;const g=w.findIndex(E=>E.id===b.id);(v.key==="ArrowRight"||v.key==="ArrowDown")&&(v.preventDefault(),u(w[(g+1)%w.length])),(v.key==="ArrowLeft"||v.key==="ArrowUp")&&(v.preventDefault(),u(w[(g-1+w.length)%w.length])),v.key==="Home"&&(v.preventDefault(),u(w[0])),v.key==="End"&&(v.preventDefault(),u(w[w.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:p,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(v=>{const w=v.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":w,"aria-controls":`${v.id}-panel`,id:`${v.id}-tab`,disabled:v.disabled,tabIndex:w?0:-1,onClick:()=>u(v),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:w?"var(--primary)":"var(--text-muted)",borderColor:w?"var(--primary)":"transparent",background:l==="pills"&&w?"var(--bg-card)":"transparent"},children:[v.icon&&t.jsx("span",{className:"shrink-0",children:v.icon}),t.jsx("span",{children:v.label}),v.badge&&t.jsx("span",{className:"shrink-0",children:v.badge})]},v.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${f}`,children:b.content})]})}function cr(...e){return e.filter(Boolean).join(" ")}function Nb({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:f=!0,showFooter:d=!0,previousLabel:h="Anterior",nextLabel:b="Siguiente",blockedNextLabel:u="Completa este paso",className:p="",headerClassName:v="",contentClassName:w="",footerClassName:g=""}){var U;const E=((U=e[0])==null?void 0:U.id)??"",[y,M]=s.useState(n??E),[L,C]=s.useState(o),m=r??y,k=a??L,N=s.useMemo(()=>new Set(k),[k]),_=Math.max(0,e.findIndex(T=>T.id===m)),q=e[_]??e[0],K=e.length<=1?100:_/(e.length-1)*100,$=T=>{a||C(T),i==null||i(T)},Q=T=>{const Y=e.find(ce=>ce.id===T);Y&&(r||M(T),l==null||l(T,Y))},X=T=>N.has(T),se=T=>e.slice(0,T).find(Y=>!Y.optional&&!N.has(Y.id)),J=T=>{const Y=e[T];return!Y||Y.disabled?!1:T===_||f&&T<_?!0:!se(T)},fe=T=>{const Y=e.findIndex(ce=>ce.id===T);return Y>=0&&J(Y)},te=T=>{const Y=e.findIndex(ce=>ce.id===T);if(Y<0)return!1;if(!J(Y)){const ce=se(Y);return ce&&(c==null||c(e[Y],ce)),!1}return Q(T),!0},z=(T=q==null?void 0:q.id)=>{!T||N.has(T)||$([...k,T])},R=(T=q==null?void 0:q.id)=>{if(!T)return;const Y=e.findIndex(V=>V.id===T),ce=k.filter(V=>{const G=e.findIndex(D=>D.id===V);return G>=0&&G<Y});$(ce),Y>=0&&_>Y&&Q(T)},A=()=>_<=0?!1:te(e[_-1].id),F=()=>{const T=e[_+1];return T?te(T.id):!1},ue={activeStep:q,activeIndex:_,completedStepIds:k,isCompleted:X,isUnlocked:fe,completeStep:z,uncompleteStep:R,goToStep:te,goNext:F,goPrevious:A};if(!q)return null;const P=e[_+1],oe=_>0,j=P?fe(P.id):!1,S=typeof q.content=="function"?q.content(ue):q.content;return t.jsxs("section",{className:cr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[t.jsxs("div",{className:cr("border-b border-[var(--border)] bg-[var(--bg-input)]",v),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${K}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((T,Y)=>{const ce=T.id===q.id,V=X(T.id),G=J(Y),D=se(Y);return t.jsxs("button",{type:"button",disabled:!G,"aria-current":ce?"step":void 0,"aria-disabled":!G,title:!G&&D?`Completa ${D.title}`:T.title,onClick:()=>te(T.id),className:cr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",ce&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",V&&!ce&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ce&&!V&&G&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!G&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:cr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",ce&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:cr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",ce&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",V&&!ce&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!V&&!ce&&G&&"border-[var(--border)] text-[var(--text-muted)]",!G&&"border-[var(--border)] text-[var(--text-muted)]"),children:V?t.jsx(H.HiCheck,{className:"h-4 w-4"}):G?Y+1:t.jsx(H.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:cr("block truncate text-xs font-semibold transition-colors duration-200",ce?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Y+1,". ",T.title]}),T.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:T.description})]}),T.badge&&t.jsx("span",{className:"shrink-0",children:T.badge})]})]},T.id)})})]}),t.jsx("div",{className:cr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",w),children:S},q.id),d&&t.jsxs("div",{className:cr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",g),children:[t.jsx(Ke,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(H.HiChevronLeft,{}),disabled:!oe,onClick:A,children:h}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",_+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[k.length," completados"]})]}),t.jsx(Ke,{height:38,padding:"0 14px",icon:t.jsx(H.HiChevronRight,{}),disabled:!P||!j,onClick:F,children:P&&!j?u:b})]})]})}const kb={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 Sb(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Cb(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 pi(e,r){const{lineHeight:n,paddingY:a,borderY:o}=Cb(e);return Math.ceil(r*n+a+o)}const mi=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:f,defaultValue:d,onInput:h,...b},u){const p=s.useRef(null),v=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",w=s.useCallback(()=>{const g=p.current;if(!g)return;g.style.height="auto";const E=g.scrollHeight,y=pi(g,i),M=o??(l!==void 0?pi(g,l):void 0),L=M!==void 0?Math.min(Math.max(E,y),M):Math.max(E,y);g.style.height=`${L}px`,g.style.overflowY=M!==void 0&&E>M?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{w()},[w,f,d]),s.useEffect(()=>{const g=p.current;if(!g||typeof ResizeObserver>"u")return;const E=new ResizeObserver(()=>w());return E.observe(g),()=>E.disconnect()},[w]),t.jsx("textarea",{...b,ref:g=>{p.current=g,Sb(u,g)},rows:i,value:f,defaultValue:d,"aria-invalid":a==="error"||b["aria-invalid"],onInput:g=>{w(),h==null||h(g)},style:{...c,borderColor:v,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${kb[n]} ${r}`})});function Eb({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:f,...d}){return t.jsx(Rn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(mi,{...d,required:i,status:o?"error":f,className:`w-full ${c}`})})}const Mb={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"},Tb={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Lb(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Ab(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const gi=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:f=!1,maxCount:d,status:h="default",icon:b,action:u,style:p,value:v,defaultValue:w,maxLength:g,onInput:E,...y},M){const L=s.useRef(null),C=Ab(v,w),m=d??g,k=!!(b||u||f),N=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",_={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},q=()=>{const $=L.current;!$||!l||($.style.height="auto",$.style.height=`${$.scrollHeight}px`)};s.useEffect(q,[l,v]);const K=t.jsx("textarea",{...y,ref:$=>{L.current=$,Lb(M,$)},value:v,defaultValue:w,maxLength:g,"aria-invalid":h==="error"||y["aria-invalid"],onInput:$=>{q(),E==null||E($)},style:{..._,borderColor:N},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Mb[a]} ${Tb[l?"none":o]} ${b?"pl-8":""} ${u?"pr-10":""} ${r}`});return k?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,u&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:u}),f&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[C,m?`/${m}`:""]})]}):K});function $b({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:f,...d}){return t.jsx(Rn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(gi,{...d,required:i,status:o?"error":f,className:`w-full ${c}`})})}const vi=[{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 Db(e){return vi[e%vi.length]}let Hb=0;function Uo(){return++Hb}function xi(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Ob(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ib(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Ob(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Bb({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:f=!1,validate:d,label:h,helperText:b,helperDisplay:u="inline",error:p,required:v=!1}){const w=e!==void 0,g=!!p,E=!!b&&u==="tooltip"&&!g,[y,M]=s.useState(()=>(r??[]).map((V,G)=>({id:Uo(),value:V.trim(),colorIndex:G})));s.useEffect(()=>{w&&M(V=>{const G=e??[],D=new Map(V.map(le=>[le.value,le]));return G.map((le,be)=>D.get(le)??{id:Uo(),value:le,colorIndex:be})})},[w,e]);const L=y,[C,m]=s.useState(""),[k,N]=s.useState(null),[_,q]=s.useState(""),[K,$]=s.useState(!1),[Q,X]=s.useState(!1),se=s.useRef(null),J=s.useRef(null),fe=s.useRef(null);function te(){X(!0),setTimeout(()=>X(!1),400)}function z(V){M(V),n==null||n(V.map(G=>G.value))}function R(V){let G=L,D=!1,le=!1;for(const be of V){const ie=be.trim();if(ie){if(c!==void 0&&G.length>=c){le=!0;break}if(!f&&G.some(ge=>ge.value.toLowerCase()===ie.toLowerCase())){le=!0;continue}if(!xi(ie,d)){le=!0;continue}G=[...G,{id:Uo(),value:ie,colorIndex:G.length}],D=!0}}return D&&z(G),le&&te(),D}function A(V){return R([V])}function F(V){const G=L.filter(D=>D.id!==V);z(G.map((D,le)=>({...D,colorIndex:le})))}function ue(V,G){const D=G.trim();if(N(null),q(""),!D){F(V);return}if(!(!f&&L.some(le=>le.id!==V&&le.value.toLowerCase()===D.toLowerCase()))){if(!xi(D,d)){te();return}z(L.map(le=>le.id===V?{...le,value:D}:le))}}function P(V){o||(N(V.id),q(V.value),setTimeout(()=>{var G;return(G=J.current)==null?void 0:G.select()},0))}function oe(V){if(V.key==="Enter"||i.includes(V.key)){V.preventDefault(),A(C)&&m("");return}if(V.key==="Backspace"&&C===""&&L.length>0){V.preventDefault();const G=L[L.length-1];F(G.id)}}function j(V,G){if(V.key==="Enter"){V.preventDefault(),ue(G,_),setTimeout(()=>{var D;return(D=se.current)==null?void 0:D.focus()},0);return}V.key==="Escape"&&(V.preventDefault(),N(null),q(""),setTimeout(()=>{var D;return(D=se.current)==null?void 0:D.focus()},0))}function S(){var V;o||(V=se.current)==null||V.focus()}function U(V){if(o)return;const G=V.clipboardData.getData("text");if(!G||!(i.some(ie=>ie&&G.includes(ie))||G.includes(`
|
|
46
|
-
`)))return;
|
|
43
|
+
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function Vo(e){if(!e)return[];const r=new Set,n=[],a=f=>{const d=Uo(f);!d||r.has(d)||(r.add(d),n.push(d))},o=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=o.exec(e))!==null;)a(l[1]??"");const i=Fi(e);jo.lastIndex=0;let c;for(;(c=jo.exec(i))!==null;)a(c[1]??"");return n}function Oi(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Rb(e,r){const n=Vo(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(Uo(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 Hi(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 eh(e,r){return r?e.filter(n=>n.userId!==r):e}function Xo(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 Bi(e){return!e||!/@/.test(e)?e:e.replace(jo,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const f=(n??"").toLowerCase(),d=o[a+r.length]??"";return d===" "||d===" "?`<span class="mention-chip" contenteditable="false" data-username="${f}">${r}</span>`:`<span class="mention-chip" contenteditable="false" data-username="${f}">${r}</span>${d?" ":" "}`})}function kn(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,o=Xo(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 Yo(e){var f;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&kn(a);const o=Xo(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,((f=l.textContent)==null?void 0:f.length)??1),c.collapse(!0),i.removeAllRanges(),i.addRange(c)}const th=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function Pi(e,r){return th.has(e.tagName)&&e!==r}function Go(e,r){let n="",a,o,l=!1;const i=(u,p)=>{if(l||!(r!=null&&r.domPoint))return;const{container:g,offset:w}=r.domPoint;g===u&&w===p&&(o=n.length,l=!0)},c=(u,p)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:u,offset:p},!0),f=u=>(r==null?void 0:r.locatePlain)===n.length?(u==null?void 0:u.nodeType)===Node.TEXT_NODE?(a={node:u,offset:0},"matched"):"matched-at-newline":(n+=`
|
|
44
|
+
`,(r==null?void 0:r.locatePlain)===n.length?(u==null?void 0:u.nodeType)===Node.TEXT_NODE?(a={node:u,offset:0},"matched"):"matched-at-newline":!1),d=u=>{const p=u.data;for(let g=0;g<=p.length;g+=1){if(i(u,g),c(u,g))return!0;g<p.length&&(n+=p[g])}return!1},h=(u,p)=>{if(p&&n.length>0&&!n.endsWith(`
|
|
45
|
+
`)&&f(u)==="matched")return!0;if(u.nodeType===Node.TEXT_NODE)return d(u);if(u.nodeType!==Node.ELEMENT_NODE)return!1;const g=u;if(g.tagName==="BR")return i(g,0),f(g.nextSibling??void 0)==="matched";const w=Array.from(u.childNodes);for(let v=0;v<w.length;v+=1){const E=w[v],y=v>0&&E.nodeType===Node.ELEMENT_NODE&&Pi(E,e);if(h(E,y))return!0}return!1},b=Array.from(e.childNodes);for(let u=0;u<b.length;u+=1){const p=b[u],g=u>0&&p.nodeType===Node.ELEMENT_NODE&&Pi(p,e);if(h(p,g))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const u=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=u.nextNode(),g=p;for(;g;)p=g,g=u.nextNode();p&&(a={node:p,offset:p.data.length})}return{plain:n,locate:a,domOffset:o}}function Ko(e){return Go(e).plain}function Vr(e,r){return r<0?null:Go(e,{locatePlain:r}).locate??null}function pa(e,r,n){return e!==r&&!e.contains(r)?-1:Go(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function _i(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Vr(e,n),i=Vr(e,a);if(!l||!i)return null;const c=e.ownerDocument,f=c.createRange();f.setStart(l.node,l.offset),f.setEnd(i.node,i.offset),f.deleteContents();const d=Oi({name:r.display,username:o}),h=c.createElement("span");h.className="mention-chip",h.setAttribute("data-username",o.toLowerCase()),r.userId&&h.setAttribute("data-userid",String(r.userId)),h.contentEditable="false",h.textContent=d,h.title=`@${o}`;const b=c.createTextNode(" "),u=c.createDocumentFragment();u.append(h,b),f.insertNode(u),kn(e),Yo(h);const p=c.defaultView,g=p==null?void 0:p.getSelection(),w=g!=null&&g.rangeCount?pa(e,g.getRangeAt(0).startContainer,g.getRangeAt(0).startOffset):n+d.length+1;return{caretPlainOffset:w>=0?w:n+d.length+1}}function zi(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Vr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function ma(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function Wi(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 ji(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 Xr(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function ga(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 qi(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),ga(e)}function Ui(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function Vi(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(),Xr(e),!0):!1}function va(e){var h,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(u,p)=>{let g=u;for(;g&&g.nodeType===Node.TEXT_NODE&&(g.textContent??"")==="";){const w=g;g=g[p],w.remove()}return g},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const u=o;(u.data.length??0)<=1?u.remove():u.data=u.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const f=(h=r.defaultView)==null?void 0:h.getSelection();if(!f)return;const d=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const u=((b=l.textContent)==null?void 0:b.length)??0;d.setStart(l,u)}else d.setStartAfter(l);else i.childNodes[c]?d.setStart(i,c):(d.selectNodeContents(i),d.collapse(!1));d.collapse(!0),f.removeAllRanges(),f.addRange(d)}function Xi(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=Wi(a.previousSibling,"prev");return ma(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 f=i[c];if(ma(f))return f;if(f.nodeType===Node.TEXT_NODE&&!(f.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Yi(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=Wi(a.nextSibling,"next");if(ma(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o;for(;c<i.length;){const f=i[c];if(ma(f))return f;if(f.nodeType===Node.TEXT_NODE&&!(f.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function Zo(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 Qo=420,xa=6,Gi=260,rh=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Ki=4,nh={position:"relative"},ah={position:"fixed",zIndex:11050,minWidth:Gi,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},Zi={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function oh(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function sh(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Gi-8)),n=window.innerHeight-e.bottom-xa-8,a=e.top-xa-8;return n<Math.min(Qo,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+xa,maxHeight:Math.min(Qo,Math.max(120,a))}:{left:r,top:e.bottom+xa,maxHeight:Math.min(Qo,Math.max(120,n))}}function Qi({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:f=140,highlightInEditor:d=!1,searchCacheKey:h="",toolbarVariant:b="full",focusModalZIndex:u}){const p=s.useId().replace(/:/g,""),g=s.useRef(null),w=s.useRef(null),v=s.useRef(new Map),E=s.useRef(n);E.current=n;const y=s.useRef(null),T=s.useRef(0),L=s.useRef([]),C=s.useRef(null),[m,S]=s.useState(null),[N,_]=s.useState([]),[U,K]=s.useState(0),[D,Z]=s.useState([]),[O,ne]=s.useState(!1),[ee,fe]=s.useState(!1);T.current=U,s.useEffect(()=>{fe(!0)},[]);const J=(m==null?void 0:m.query)??null;s.useEffect(()=>{if(J===null){_([]);return}const k=J.trim(),V=`${h}|${k.toLowerCase()||"*"}`,M=v.current.get(V);if(M){_(M),ne(!1),K(0);return}const Y=new AbortController;ne(!0);const ce=window.setTimeout(()=>{(async()=>{try{const X=await E.current(k,{signal:Y.signal,limit:c});if(Y.signal.aborted)return;const G=Array.isArray(X)?X:[];v.current.set(V,G),_(G),K(0)}catch{Y.signal.aborted||_([])}finally{Y.signal.aborted||ne(!1)}})()},f);return()=>{Y.abort(),window.clearTimeout(ce)}},[J,c,f,h]);const W=s.useRef(a);W.current=a,s.useEffect(()=>{var k;(k=W.current)==null||k.call(W,Hi(D))},[D]);const R=s.useCallback(()=>{const k=oh(p);if(k.length===0)return null;const V=window.getSelection();if(V!=null&&V.rangeCount){const Y=V.getRangeAt(0).startContainer;for(const ce of k)if(ce.contains(Y))return ce}const M=document.activeElement;for(const Y of k)if(M===Y||M&&Y.contains(M))return Y;for(const Y of k)if(Y.closest('[role="dialog"]'))return Y;return k[0]??null},[p]),$=s.useCallback(()=>{const k=R(),V=window.getSelection();if(!k||!V||V.rangeCount===0){S(null);return}const M=V.getRangeAt(0);if(!k.contains(M.startContainer)){S(null);return}const Y=pa(k,M.startContainer,M.startOffset);if(Y<0){S(null);return}const ce=qo(k,Y);if(!ce){S(null);return}const X=M.getBoundingClientRect(),G=X.width===0&&X.height===0?(()=>{const le=document.createRange();return le.selectNodeContents(M.startContainer),le.collapse(!0),le.getBoundingClientRect()})():X;y.current={query:ce.query,caretIndex:ce.caretIndex,triggerIndex:ce.triggerIndex};const I=sh(G);S(le=>{const be={query:ce.query,...I};return le&&le.query===be.query&&le.top===be.top&&le.bottom===be.bottom&&le.left===be.left&&le.maxHeight===be.maxHeight?le:be})},[R]),P=s.useCallback(k=>{r(k),$()},[r,$]);s.useEffect(()=>{const k=V=>{if(rh.has(V.key))return;const M=R(),Y=V.target;!M||!Y||!M.contains(Y)||$()};return document.addEventListener("keyup",k,!0),()=>document.removeEventListener("keyup",k,!0)},[R,$]);const ue=s.useCallback(k=>{const V=R();if(!V)return;let M=-1;const Y=window.getSelection();if(Y&&Y.rangeCount>0){const le=Y.getRangeAt(0);V.contains(le.startContainer)&&(M=pa(V,le.startContainer,le.startOffset))}if(M<0&&y.current&&(M=y.current.caretIndex),M<0)return;const ce=qo(V,M);if(!ce)return;const X=_i(V,{triggerIndex:ce.triggerIndex,caretIndex:M,username:k.username,display:k.name,userId:k.userId});if(!X)return;kn(V),V.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const G={userId:k.userId,username:k.username,email:k.email??void 0,display:k.name??k.username};Z(le=>{const be=new Map(le.map(ie=>[ie.userId,ie]));return be.set(G.userId,G),Array.from(be.values())}),S(null),y.current=null;const I=k.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const le=R();if(!le)return;le.focus(),kn(le);const be=Array.from(le.querySelectorAll(".mention-chip")),ie=[...be].reverse().find(ge=>ge.getAttribute("data-username")===I)??be[be.length-1];if(ie){Yo(ie);return}zi(le,X.caretPlainOffset)})})},[R]);s.useEffect(()=>{const k=new Set(Vo(e).map(V=>V.toLowerCase()));Z(V=>{const M=V.filter(Y=>k.has(Y.username.toLowerCase()));return M.length===V.length?V:M})},[e]),s.useEffect(()=>{if(!m)return;const k=V=>{const M=V.target;if(!M||g.current&&g.current.contains(M)||w.current&&w.current.contains(M))return;const Y=R();Y&&Y.contains(M)||S(null)};return document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[m,R]);const z=s.useMemo(()=>N.slice(0,c),[N,c]);L.current=z,s.useEffect(()=>{if(!m)return;const k=V=>{const M=R(),Y=V.target;if(!M||!Y||!M.contains(Y))return;const ce=L.current;if(!(ce.length===0&&V.key!=="Escape"))if(V.key==="ArrowDown")V.preventDefault(),V.stopPropagation(),K(X=>(X+1)%Math.max(ce.length,1));else if(V.key==="ArrowUp")V.preventDefault(),V.stopPropagation(),K(X=>(X-1+ce.length)%Math.max(ce.length,1));else if(V.key==="Enter"||V.key==="Tab"){const X=ce[T.current];X&&(V.preventDefault(),V.stopPropagation(),ue(X))}else V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),S(null))};return document.addEventListener("keydown",k,!0),()=>document.removeEventListener("keydown",k,!0)},[R,ue,m]),s.useEffect(()=>{const k=G=>{G.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},V=G=>{const I=R(),le=G.target;if(!I||!le||!I.contains(le))return;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="a"){G.preventDefault(),G.stopPropagation(),I.focus(),qi(I);return}if(G.key!=="Backspace"&&G.key!=="Delete")return;const be=window.getSelection();if(be&&!be.isCollapsed&&be.rangeCount>0){const $e=be.getRangeAt(0);if(I.contains($e.commonAncestorContainer)&&Zo(I).length>0&&Ui($e)){G.preventDefault(),G.stopPropagation(),Vi(I)&&k(I);return}}const ie=Zo(I);if(ie.length>0){G.preventDefault(),G.stopPropagation();for(const $e of ie)va($e);Xr(I),k(I);return}if(G.key==="Backspace"){const $e=Xi(I);if(!$e)return;G.preventDefault(),G.stopPropagation(),va($e),Xr(I),k(I);return}const ge=Yi(I);ge&&(G.preventDefault(),G.stopPropagation(),va(ge),Xr(I),k(I))},M=G=>{const I=R();if(!I)return;const le=G.target;if(!(le instanceof Element)||!I.contains(le))return;const be=le.closest(".mention-chip");if(!(be instanceof HTMLElement)||!I.contains(be)){C.current=null,Xr(I);return}G.shiftKey||G.button!==0||(C.current={chip:be,x:G.clientX,y:G.clientY})},Y=G=>{const I=C.current;if(!I)return;const le=Math.abs(G.clientX-I.x),be=Math.abs(G.clientY-I.y);(le>Ki||be>Ki)&&(C.current=null)},ce=G=>{var ge;const I=R(),le=C.current;if(C.current=null,!I||!le)return;const be=G.target;if(!(be instanceof Element)||!I.contains(be)||!((ge=be.closest(".mention-chip"))!=null&&ge.isSameNode(le.chip)))return;const ie=window.getSelection();if(ie){if(!ie.isCollapsed){ga(I);return}I.focus(),ji(le.chip)}},X=()=>{const G=R();if(!G)return;const I=window.getSelection();!I||I.rangeCount===0||!I.anchorNode||!G.contains(I.anchorNode)||!I.focusNode||!G.contains(I.focusNode)||ga(G)};return document.addEventListener("keydown",V,!0),document.addEventListener("mousedown",M,!0),document.addEventListener("mousemove",Y,!0),document.addEventListener("mouseup",ce,!0),document.addEventListener("selectionchange",X),()=>{document.removeEventListener("keydown",V,!0),document.removeEventListener("mousedown",M,!0),document.removeEventListener("mousemove",Y,!0),document.removeEventListener("mouseup",ce,!0),document.removeEventListener("selectionchange",X)}},[R]),s.useEffect(()=>{if(!m||!w.current)return;const k=w.current.querySelector(`[data-mention-index="${U}"]`);k==null||k.scrollIntoView({block:"nearest"})},[U,m]);const se=d?Bi(e):e,q=m&&ee?bt.createPortal(t.jsxs("ul",{ref:w,style:{...ah,left:m.left,top:m.top,bottom:m.bottom,maxHeight:m.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[O&&z.length===0&&t.jsx("li",{style:Zi,children:"Buscando…"}),!O&&z.length===0&&t.jsx("li",{style:Zi,children:m.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${m.query}”`}),z.map((k,V)=>{var M,Y;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":V,onMouseDown:ce=>{ce.preventDefault(),ue(k)},onMouseEnter:()=>K(V),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:V===U?"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:((M=k.name)==null?void 0:M.trim())||`@${k.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(Y=k.name)!=null&&Y.trim()?`@${k.username}`:null,k.email].filter(Boolean).join(" · ")||`@${k.username}`})]})},k.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:nh,className:i,children:[t.jsx(Ti,{value:se,onChange:P,placeholder:l,minHeight:o,instanceId:p,toolbarVariant:b,focusModalZIndex:u}),q]})}function lh({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:f,highlightInEditor:d,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:u}){return o?t.jsx(Qi,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:f,highlightInEditor:d,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:u}):t.jsx(Ti,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b,focusModalZIndex:u})}function ih({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const f=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[f&&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 ch={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)"}},dh={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 uh({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=ch[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 ${dh[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 Ji={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)"}},fh={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"},bh={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},hh={xs:148,sm:164,md:184},ph={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 mh({value:e,options:r,onChange:n,size:a="sm",disabled:o=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:f="Cambiar estado",className:d,selectClassName:h,menuClassName:b,optionClassName:u,spinnerClassName:p}){const[g,w]=s.useState(!1),[v,E]=s.useState(!1),[y,T]=s.useState(-1),[L,C]=s.useState({}),m=s.useRef(null),S=s.useRef(null),N=s.useRef(null),_=r.find(J=>J.value===e)??r[0],U={..._!=null&&_.tone?Ji[_.tone]:void 0,..._==null?void 0:_.style},K=o||l||r.length===0,D=J=>{i&&J.stopPropagation()},Z=s.useCallback(()=>{w(!1),T(-1)},[]),O=s.useCallback(()=>{const J=m.current;if(!J)return;const W=J.getBoundingClientRect(),R=Math.max(W.width,hh[a]),$=Math.min(Math.max(r.length,1)*38+12,260),P=window.innerHeight-W.bottom,ue=P<$&&W.top>P,z=Math.min(Math.max(8,W.left+W.width/2-R/2),window.innerWidth-R-8);C({position:"fixed",left:z,top:ue?void 0:W.bottom+6,bottom:ue?window.innerHeight-W.top+6:void 0,width:R,zIndex:9999})},[r.length,a]),ne=s.useCallback(J=>{J.disabled||(n(J.value),Z())},[Z,n]);s.useEffect(()=>E(!0),[]),s.useEffect(()=>{if(!g)return;O();const J=r.findIndex(W=>W.value===e);T(J>=0?J:0)},[g,r,O,e]),s.useEffect(()=>{if(!g)return;function J(W){var $,P;const R=W.target;!(($=m.current)!=null&&$.contains(R))&&!((P=S.current)!=null&&P.contains(R))&&Z()}return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[Z,g]),s.useEffect(()=>{if(g)return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[g,O]),s.useEffect(()=>{if(y<0||!N.current)return;const J=N.current.children[y];J==null||J.scrollIntoView({block:"nearest"})},[y]);function ee(J){if(!K){if(!g){["Enter"," ","ArrowDown","ArrowUp"].includes(J.key)&&(J.preventDefault(),w(!0));return}if(J.key==="Escape"){J.preventDefault(),Z();return}if(J.key==="ArrowDown"){J.preventDefault(),T(W=>Math.min(W+1,r.length-1));return}if(J.key==="ArrowUp"){J.preventDefault(),T(W=>Math.max(W-1,0));return}if(J.key==="Enter"||J.key===" "){J.preventDefault();const W=r[y];W&&ne(W)}}}const fe=t.jsx("div",{ref:S,role:"listbox","aria-label":c,className:Pe("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...L,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:D,onMouseDown:D,onPointerDown:D,children:t.jsx("div",{ref:N,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((J,W)=>{const R=J.value===e,$=W===y,P={...J.tone?Ji[J.tone]:void 0,...J.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":R,disabled:J.disabled,onMouseEnter:()=>!J.disabled&&T(W),onMouseDown:ue=>{ue.preventDefault(),ne(J)},className:Pe("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",ph[a],R?J.className:void 0,u),style:{...R?P:void 0,background:R?P.background??"color-mix(in srgb, var(--primary) 12%, transparent)":$?"var(--bg-hover)":"transparent",color:R?P.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:R?t.jsx(F.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:J.label})]},J.value)})})});return t.jsxs("span",{ref:m,className:Pe("relative inline-flex shrink-0 items-center",d),onKeyDown:ee,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":g,title:f,onClick:()=>!K&&w(J=>!J),className:Pe("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",fh[a],_==null?void 0:_.className,h),style:U,children:t.jsx("span",{className:"min-w-0 truncate",children:(_==null?void 0:_.label)??e})}),t.jsx(F.HiChevronDown,{"aria-hidden":"true",className:Pe("pointer-events-none absolute opacity-70 transition-transform",bh[a],g?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Pe("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",p)}),g&&v&&bt.createPortal(fe,document.body)]})}function gh({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:f=""}){const d=e.find(g=>!g.disabled)??e[0],h=r??n??(d==null?void 0:d.id),b=e.find(g=>g.id===h)??d,u=g=>{g.disabled||a==null||a(g.id)},p=g=>{const w=e.filter(E=>!E.disabled);if(!w.length||!b)return;const v=w.findIndex(E=>E.id===b.id);(g.key==="ArrowRight"||g.key==="ArrowDown")&&(g.preventDefault(),u(w[(v+1)%w.length])),(g.key==="ArrowLeft"||g.key==="ArrowUp")&&(g.preventDefault(),u(w[(v-1+w.length)%w.length])),g.key==="Home"&&(g.preventDefault(),u(w[0])),g.key==="End"&&(g.preventDefault(),u(w[w.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:p,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(g=>{const w=g.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":w,"aria-controls":`${g.id}-panel`,id:`${g.id}-tab`,disabled:g.disabled,tabIndex:w?0:-1,onClick:()=>u(g),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:w?"var(--primary)":"var(--text-muted)",borderColor:w?"var(--primary)":"transparent",background:l==="pills"&&w?"var(--bg-card)":"transparent"},children:[g.icon&&t.jsx("span",{className:"shrink-0",children:g.icon}),t.jsx("span",{children:g.label}),g.badge&&t.jsx("span",{className:"shrink-0",children:g.badge})]},g.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${f}`,children:b.content})]})}function dr(...e){return e.filter(Boolean).join(" ")}function vh({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:f=!0,showFooter:d=!0,previousLabel:h="Anterior",nextLabel:b="Siguiente",blockedNextLabel:u="Completa este paso",className:p="",headerClassName:g="",contentClassName:w="",footerClassName:v=""}){var V;const E=((V=e[0])==null?void 0:V.id)??"",[y,T]=s.useState(n??E),[L,C]=s.useState(o),m=r??y,S=a??L,N=s.useMemo(()=>new Set(S),[S]),_=Math.max(0,e.findIndex(M=>M.id===m)),U=e[_]??e[0],K=e.length<=1?100:_/(e.length-1)*100,D=M=>{a||C(M),i==null||i(M)},Z=M=>{const Y=e.find(ce=>ce.id===M);Y&&(r||T(M),l==null||l(M,Y))},O=M=>N.has(M),ne=M=>e.slice(0,M).find(Y=>!Y.optional&&!N.has(Y.id)),ee=M=>{const Y=e[M];return!Y||Y.disabled?!1:M===_||f&&M<_?!0:!ne(M)},fe=M=>{const Y=e.findIndex(ce=>ce.id===M);return Y>=0&&ee(Y)},J=M=>{const Y=e.findIndex(ce=>ce.id===M);if(Y<0)return!1;if(!ee(Y)){const ce=ne(Y);return ce&&(c==null||c(e[Y],ce)),!1}return Z(M),!0},W=(M=U==null?void 0:U.id)=>{!M||N.has(M)||D([...S,M])},R=(M=U==null?void 0:U.id)=>{if(!M)return;const Y=e.findIndex(X=>X.id===M),ce=S.filter(X=>{const G=e.findIndex(I=>I.id===X);return G>=0&&G<Y});D(ce),Y>=0&&_>Y&&Z(M)},$=()=>_<=0?!1:J(e[_-1].id),P=()=>{const M=e[_+1];return M?J(M.id):!1},ue={activeStep:U,activeIndex:_,completedStepIds:S,isCompleted:O,isUnlocked:fe,completeStep:W,uncompleteStep:R,goToStep:J,goNext:P,goPrevious:$};if(!U)return null;const z=e[_+1],se=_>0,q=z?fe(z.id):!1,k=typeof U.content=="function"?U.content(ue):U.content;return t.jsxs("section",{className:dr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[t.jsxs("div",{className:dr("border-b border-[var(--border)] bg-[var(--bg-input)]",g),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${K}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((M,Y)=>{const ce=M.id===U.id,X=O(M.id),G=ee(Y),I=ne(Y);return t.jsxs("button",{type:"button",disabled:!G,"aria-current":ce?"step":void 0,"aria-disabled":!G,title:!G&&I?`Completa ${I.title}`:M.title,onClick:()=>J(M.id),className:dr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",ce&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",X&&!ce&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ce&&!X&&G&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!G&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:dr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",ce&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:dr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",ce&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",X&&!ce&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!X&&!ce&&G&&"border-[var(--border)] text-[var(--text-muted)]",!G&&"border-[var(--border)] text-[var(--text-muted)]"),children:X?t.jsx(F.HiCheck,{className:"h-4 w-4"}):G?Y+1:t.jsx(F.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:dr("block truncate text-xs font-semibold transition-colors duration-200",ce?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Y+1,". ",M.title]}),M.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:M.description})]}),M.badge&&t.jsx("span",{className:"shrink-0",children:M.badge})]})]},M.id)})})]}),t.jsx("div",{className:dr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",w),children:k},U.id),d&&t.jsxs("div",{className:dr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Ke,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(F.HiChevronLeft,{}),disabled:!se,onClick:$,children:h}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",_+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[S.length," completados"]})]}),t.jsx(Ke,{height:38,padding:"0 14px",icon:t.jsx(F.HiChevronRight,{}),disabled:!z||!q,onClick:P,children:z&&!q?u:b})]})]})}const xh={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 yh(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function wh(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 Ri(e,r){const{lineHeight:n,paddingY:a,borderY:o}=wh(e);return Math.ceil(r*n+a+o)}const ec=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:f,defaultValue:d,onInput:h,...b},u){const p=s.useRef(null),g=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",w=s.useCallback(()=>{const v=p.current;if(!v)return;v.style.height="auto";const E=v.scrollHeight,y=Ri(v,i),T=o??(l!==void 0?Ri(v,l):void 0),L=T!==void 0?Math.min(Math.max(E,y),T):Math.max(E,y);v.style.height=`${L}px`,v.style.overflowY=T!==void 0&&E>T?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{w()},[w,f,d]),s.useEffect(()=>{const v=p.current;if(!v||typeof ResizeObserver>"u")return;const E=new ResizeObserver(()=>w());return E.observe(v),()=>E.disconnect()},[w]),t.jsx("textarea",{...b,ref:v=>{p.current=v,yh(u,v)},rows:i,value:f,defaultValue:d,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{w(),h==null||h(v)},style:{...c,borderColor:g,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${xh[n]} ${r}`})});function Nh({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:f,...d}){return t.jsx(sa,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(ec,{...d,required:i,status:o?"error":f,className:`w-full ${c}`})})}const kh={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"},Sh={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Ch(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Eh(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const tc=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:f=!1,maxCount:d,status:h="default",icon:b,action:u,style:p,value:g,defaultValue:w,maxLength:v,onInput:E,...y},T){const L=s.useRef(null),C=Eh(g,w),m=d??v,S=!!(b||u||f),N=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",_={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},U=()=>{const D=L.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(U,[l,g]);const K=t.jsx("textarea",{...y,ref:D=>{L.current=D,Ch(T,D)},value:g,defaultValue:w,maxLength:v,"aria-invalid":h==="error"||y["aria-invalid"],onInput:D=>{U(),E==null||E(D)},style:{..._,borderColor:N},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${kh[a]} ${Sh[l?"none":o]} ${b?"pl-8":""} ${u?"pr-10":""} ${r}`});return S?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,u&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:u}),f&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[C,m?`/${m}`:""]})]}):K});function Mh({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:f,...d}){return t.jsx(sa,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(tc,{...d,required:i,status:o?"error":f,className:`w-full ${c}`})})}const rc=[{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 Th(e){return rc[e%rc.length]}let Ah=0;function Jo(){return++Ah}function nc(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Lh(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $h(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Lh(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Dh({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:f=!1,validate:d,label:h,helperText:b,helperDisplay:u="inline",error:p,required:g=!1}){const w=e!==void 0,v=!!p,E=!!b&&u==="tooltip"&&!v,[y,T]=s.useState(()=>(r??[]).map((X,G)=>({id:Jo(),value:X.trim(),colorIndex:G})));s.useEffect(()=>{w&&T(X=>{const G=e??[],I=new Map(X.map(le=>[le.value,le]));return G.map((le,be)=>I.get(le)??{id:Jo(),value:le,colorIndex:be})})},[w,e]);const L=y,[C,m]=s.useState(""),[S,N]=s.useState(null),[_,U]=s.useState(""),[K,D]=s.useState(!1),[Z,O]=s.useState(!1),ne=s.useRef(null),ee=s.useRef(null),fe=s.useRef(null);function J(){O(!0),setTimeout(()=>O(!1),400)}function W(X){T(X),n==null||n(X.map(G=>G.value))}function R(X){let G=L,I=!1,le=!1;for(const be of X){const ie=be.trim();if(ie){if(c!==void 0&&G.length>=c){le=!0;break}if(!f&&G.some(ge=>ge.value.toLowerCase()===ie.toLowerCase())){le=!0;continue}if(!nc(ie,d)){le=!0;continue}G=[...G,{id:Jo(),value:ie,colorIndex:G.length}],I=!0}}return I&&W(G),le&&J(),I}function $(X){return R([X])}function P(X){const G=L.filter(I=>I.id!==X);W(G.map((I,le)=>({...I,colorIndex:le})))}function ue(X,G){const I=G.trim();if(N(null),U(""),!I){P(X);return}if(!(!f&&L.some(le=>le.id!==X&&le.value.toLowerCase()===I.toLowerCase()))){if(!nc(I,d)){J();return}W(L.map(le=>le.id===X?{...le,value:I}:le))}}function z(X){o||(N(X.id),U(X.value),setTimeout(()=>{var G;return(G=ee.current)==null?void 0:G.select()},0))}function se(X){if(X.key==="Enter"||i.includes(X.key)){X.preventDefault(),$(C)&&m("");return}if(X.key==="Backspace"&&C===""&&L.length>0){X.preventDefault();const G=L[L.length-1];P(G.id)}}function q(X,G){if(X.key==="Enter"){X.preventDefault(),ue(G,_),setTimeout(()=>{var I;return(I=ne.current)==null?void 0:I.focus()},0);return}X.key==="Escape"&&(X.preventDefault(),N(null),U(""),setTimeout(()=>{var I;return(I=ne.current)==null?void 0:I.focus()},0))}function k(){var X;o||(X=ne.current)==null||X.focus()}function V(X){if(o)return;const G=X.clipboardData.getData("text");if(!G||!(i.some(ie=>ie&&G.includes(ie))||G.includes(`
|
|
46
|
+
`)))return;X.preventDefault();const le=$h(G,i);R(le)&&m("")}function M(){const X=C.trim();X&&$(X)&&m("")}const Y=v?"var(--danger)":K?"var(--primary)":"var(--border)",ce=c!==void 0&&L.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(h||g||E)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[h&&t.jsx("span",{children:h}),g&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E?t.jsx(_r,{content:b}):null]}),t.jsxs("div",{ref:fe,onClick:k,onFocus:()=>D(!0),onBlur:X=>{var G;(G=fe.current)!=null&&G.contains(X.relatedTarget)||(D(!1),S!==null&&ue(S,_),S===null&&M())},style:{borderColor:Y},className:`
|
|
47
47
|
flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
|
|
48
48
|
bg-[var(--bg-input)] px-2.5 py-2 transition-colors
|
|
49
49
|
${o?"cursor-not-allowed opacity-60":"cursor-text"}
|
|
50
|
-
${
|
|
50
|
+
${Z?"animate-[tag-shake_0.4s_ease]":""}
|
|
51
51
|
`,children:[t.jsx("style",{children:`
|
|
52
52
|
@keyframes tag-shake {
|
|
53
53
|
0%,100% { transform: translateX(0); }
|
|
@@ -56,7 +56,7 @@ ${B}`,he=new Blob(["\uFEFF"+de],{type:"text/csv;charset=utf-8;"}),Ee=URL.createO
|
|
|
56
56
|
60% { transform: translateX(-3px); }
|
|
57
57
|
80% { transform: translateX(3px); }
|
|
58
58
|
}
|
|
59
|
-
`}),L.map(V=>{const G=Db(V.colorIndex);return k===V.id?t.jsx("input",{ref:J,value:_,disabled:o,onChange:D=>q(D.target.value),onKeyDown:D=>j(D,V.id),onBlur:()=>ue(V.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`}},V.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:G.bg,color:G.text,border:`1px solid ${G.border}`},children:[t.jsx("span",{className:"truncate",children:V.value}),t.jsx("button",{type:"button","aria-label":`Editar "${V.value}"`,disabled:o,tabIndex:-1,onClick:D=>{D.stopPropagation(),P(V)},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(H.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${V.value}"`,disabled:o,tabIndex:-1,onClick:D=>{D.stopPropagation(),F(V.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(H.HiXMark,{className:"h-3.5 w-3.5"})})]},V.id)}),!ce&&t.jsx("input",{ref:se,value:C,disabled:o,placeholder:L.length===0?a:"",onChange:V=>m(V.target.value),onKeyDown:oe,onPaste:U,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(Pr,{error:p,helperText:b,helperDisplay:u})]})}const Fb=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function it(e){return String(e).padStart(2,"0")}function Vo(e,r=Vr()){const n=e.trim();if(!n)return r;const a=n.match(Fb);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 wn(e,r=!0){const n=`${it(e.hour24)}:${it(e.minute)}`;return r?`${n}:${it(e.second)}`:n}function ba(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 Nn(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 Pb(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=Vo(e);if(n){const l=ba(o),i=`${l.hour12}:${it(l.minute)}`;return`${a?`${i}:${it(l.second)}`:i} ${l.meridiem}`}return wn(o,a)}function Vr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function _b(e=!0){return wn(Vr(),e)}function Xo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const Tt=36,Yo=5,yi=Math.floor(Yo/2),zb=52,Wb=48,tr=18;function wi(e){return e*Tt}function Ni(e){return Math.round(e/Tt)}function jb(e){return e.use12Hour??e.hour12??!1}function ha({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=zb,label:i,maxNumeric:c=59,isMeridiem:f=!1,isFocused:d=!1,onFocus:h,onAdvance:b,onBack:u,setColumnRef:p}){const v=s.useRef(null),w=s.useRef(null),g=s.useRef(null),E=s.useRef(""),y=s.useRef(0),M=s.useRef(!1),[L,C]=s.useState(r),[m,k]=s.useState(""),N=s.useCallback(P=>{E.current=P,k(P)},[]),_=s.useMemo(()=>[...Array(yi).fill(""),...e,...Array(yi).fill("")],[e]),q=s.useCallback(()=>{const P=v.current;if(!P)return r;const oe=Ni(P.scrollTop),j=Math.min(Math.max(oe,0),e.length-1);return e[j]??r},[r,e]),K=s.useCallback((P,oe=!0)=>{const j=Math.min(Math.max(P,0),e.length-1),S=e[j],U=v.current;!U||!S||(w.current&&(window.clearTimeout(w.current),w.current=null),M.current=!0,y.current=j,U.scrollTop=wi(j),C(S),oe&&S!==r&&n(S))},[n,r,e]);s.useLayoutEffect(()=>{w.current&&(window.clearTimeout(w.current),w.current=null),g.current&&(window.clearTimeout(g.current),g.current=null),N(""),C(r);const P=e.indexOf(r);if(P>=0&&(y.current=P),P<0||!v.current)return;const oe=wi(P);v.current.scrollTop!==oe&&(v.current.scrollTop=oe)},[o,r,N,e]);const $=s.useCallback(()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},[]),Q=s.useCallback((P,oe=!1)=>{$(),N("");const j=Number(P);if(!Number.isFinite(j))return;const S=Math.min(c,Math.max(0,j));let U=it(S),T=e.indexOf(U);if(T<0){const Y=Math.min(e.length-1,Math.max(0,S-(c===12?1:0)));U=e[Y]??U,T=e.indexOf(U)}T>=0&&K(T),oe&&(b==null||b())},[$,c,b,K,N,e]),X=s.useCallback(P=>{const oe=Math.floor(c/10),j=E.current;if(j===""){if(P>oe){Q(String(P),!0);return}const U=String(P);N(U),g.current=window.setTimeout(()=>{Q(E.current,!0)},1200);return}$();const S=+`${j}${P}`;S<=c?Q(String(S),!0):Q(String(P),!0)},[$,Q,c,N]),se=s.useCallback(P=>{$(),N(""),K(y.current+P)},[$,K,N]),J=P=>{if(f){P.key==="a"||P.key==="A"?(P.preventDefault(),n("AM"),b==null||b()):P.key==="p"||P.key==="P"?(P.preventDefault(),n("PM"),b==null||b()):P.key==="ArrowUp"||P.key==="ArrowDown"?(P.preventDefault(),n(r==="AM"?"PM":"AM")):P.key==="Tab"&&(P.preventDefault(),P.shiftKey?u==null||u():b==null||b());return}if(/^\d$/.test(P.key)){P.preventDefault(),X(Number(P.key));return}P.key==="ArrowUp"?(P.preventDefault(),se(-1)):P.key==="ArrowDown"?(P.preventDefault(),se(1)):P.key==="Tab"&&(P.preventDefault(),$(),E.current!==""&&Q(E.current,!1),P.shiftKey?u==null||u():b==null||b())},fe=s.useCallback(()=>{const P=a.current,oe=v.current;oe&&P===a.current&&K(Ni(oe.scrollTop))},[K,a]),te=()=>{if(E.current!=="")return;if(M.current){M.current=!1;const oe=q();C(oe);const j=e.indexOf(oe);j>=0&&(y.current=j);return}C(q()),w.current&&window.clearTimeout(w.current);const P=a.current;w.current=window.setTimeout(()=>{P===a.current&&fe()},100)},z="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",R=Tt*Yo,A=R+tr*2,F=m!==""?m:null,ue=F!==null;return t.jsxs("div",{ref:p,role:"spinbutton",tabIndex:d?0:-1,"aria-label":i,"aria-valuetext":F??r,"aria-valuenow":f?void 0:Number(r),onFocus:h,onMouseDown:()=>h==null?void 0:h(),onKeyDown:J,onBlur:()=>{$(),E.current!==""&&Q(E.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:A,boxShadow:d?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:z,style:{top:0,height:tr,color:"var(--text-muted)",opacity:.35},onClick:()=>se(-1),children:t.jsx(H.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:v,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:tr,height:R,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:te,onMouseUp:fe,onTouchEnd:fe,children:_.map((P,oe)=>{const j=P!==""&&P===L;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!P,onClick:()=>{if(!P)return;const S=e.indexOf(P);S>=0&&K(S)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:Tt,scrollSnapAlign:"center",color:j?"var(--text-main)":"var(--text-muted)",fontSize:j?16:14,fontWeight:j?600:400,opacity:P?ue?j?0:.35:j?1:.35:0},children:P},`wheel-${oe}-${P}`)})}),F!==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:tr+R/2-Tt/2,height:Tt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:F}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:z,style:{bottom:0,height:tr,color:"var(--text-muted)",opacity:.35},onClick:()=>se(1),children:t.jsx(H.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function ki(){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:Tt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Si({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:f,className:d=""}){const h=i==="popover",b=h||!f,u=jb({use12Hour:n,hour12:a}),p=s.useRef(e),v=Vo(e,Vr()),w=ba(v),[g,E]=s.useState(it(u?w.hour12:v.hour24)),[y,M]=s.useState(it(v.minute)),[L,C]=s.useState(it(v.second)),[m,k]=s.useState(w.meridiem),[N,_]=s.useState(0),q=s.useRef(0),K=s.useRef(!1),$=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[Q,X]=s.useState("hour"),se=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),u&&ie.push("meridiem"),ie},[u,o]),J=s.useCallback(ie=>{X(ge=>{const $e=se.indexOf(ge);return se[($e+ie+se.length)%se.length]})},[se]);s.useEffect(()=>{var ie;(ie=$.current[Q])==null||ie.focus()},[Q]),s.useEffect(()=>{var ie;X("hour"),(ie=$.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const ie=Vo(e,Vr()),ge=ba(ie);E(it(u?ge.hour12:ie.hour24)),M(it(ie.minute)),C(it(ie.second)),k(ge.meridiem)},[u,e]);const fe=s.useMemo(()=>(u?Xo(1,12):Xo(0,23)).map(ie=>it(ie)),[u]),te=s.useMemo(()=>Xo(0,59).map(ie=>it(ie)),[]),z=te,R=s.useMemo(()=>["AM","PM"],[]),A=s.useCallback(()=>u?Nn({hour12:Number(g),minute:Number(y),second:Number(L),meridiem:m}):{hour24:Number(g),minute:Number(y),second:Number(L)},[g,u,m,y,L]),F=s.useCallback(ie=>{if(K.current)return;const ge=wn(ie,o);p.current=ge,r(ge)},[r,o]),ue=s.useCallback(()=>{F(A())},[A,F]),P=ie=>{E(ie),b&&F(u?Nn({hour12:Number(ie),minute:Number(y),second:Number(L),meridiem:m}):{hour24:Number(ie),minute:Number(y),second:Number(L)})},oe=ie=>{M(ie),b&&F(u?Nn({hour12:Number(g),minute:Number(ie),second:Number(L),meridiem:m}):{hour24:Number(g),minute:Number(ie),second:Number(L)})},j=ie=>{C(ie),b&&F(u?Nn({hour12:Number(g),minute:Number(y),second:Number(ie),meridiem:m}):{hour24:Number(g),minute:Number(y),second:Number(ie)})},S=ie=>{k(ie),b&&F(Nn({hour12:Number(g),minute:Number(y),second:Number(L),meridiem:ie}))},U=s.useCallback(()=>(q.current+=1,_(q.current),q.current),[]),T=s.useCallback(ie=>{const ge=ba(ie),$e=wn(ie,o);p.current=$e,E(it(u?ge.hour12:ie.hour24)),M(it(ie.minute)),C(it(ie.second)),k(ge.meridiem),r($e)},[u,r,o]),Y=()=>{K.current=!0,U(),T(Vr()),queueMicrotask(()=>{const ie=Vr();wn(ie,o)!==p.current&&(U(),T(ie)),K.current=!1})},ce=()=>{ue(),f==null||f()},V=Tt*Yo,G=V+tr*2,D=tr+V/2-Tt/2,le=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:G,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:D,height:Tt,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:tr,height:Tt*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:tr,height:Tt*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(ha,{syncEpochRef:q,forceSyncAt:N,values:fe,selected:g,onSelect:P,label:"Horas",maxNumeric:u?12:23,isFocused:Q==="hour",onFocus:()=>X("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{$.current.hour=ie}}),t.jsx(ki,{}),t.jsx(ha,{syncEpochRef:q,forceSyncAt:N,values:te,selected:y,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:Q==="minute",onFocus:()=>X("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{$.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(ki,{}),t.jsx(ha,{syncEpochRef:q,forceSyncAt:N,values:z,selected:L,onSelect:j,label:"Segundos",maxNumeric:59,isFocused:Q==="second",onFocus:()=>X("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{$.current.second=ie}})]}):null,u?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ha,{syncEpochRef:q,forceSyncAt:N,values:R,selected:m,onSelect:ie=>S(ie),width:Wb,label:"AM o PM",isMeridiem:!0,isFocused:Q==="meridiem",onFocus:()=>X("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{$.current.meridiem=ie}})}):null]})]})}),be=t.jsxs("div",{className:`flex items-center ${h?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:h?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ke,{variant:"ghost",size:"sm",onClick:Y,className:h?"text-xs":void 0,children:"Ahora"}),!h&&(c||f)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ke,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,f?t.jsx(Ke,{variant:"primary",size:"sm",onClick:ce,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${d}`,style:{borderRadius:h?12:14,border:h?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:h?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:u?o?300:260:o?252:212},children:[!h&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,le,be]})}function qb(e){return e.use12Hour??e.hour12??!1}function Ub({label:e,value:r,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:f=!1,displayMode:d="popover",required:h,error:b,helperText:u,helperDisplay:p,className:v,contentClassName:w,className:g=""}){const E=d==="popover",[y,M]=s.useState(!1),L=s.useRef(null),[C,m]=s.useState({horizontal:"left",vertical:"bottom"}),k=qb({use12Hour:a,hour12:o}),N=s.useMemo(()=>r?Pb(r,{use12Hour:k,showSeconds:l}):"",[k,l,r]);s.useEffect(()=>{if(!E||!y||!L.current)return;const K=L.current.getBoundingClientRect(),$=8,Q=k?l?300:260:l?252:212,X=276,se=K.left+Q>window.innerWidth-$,J=K.right-Q>=$,fe=K.bottom+8+X>window.innerHeight-$,te=K.top-8-X>=$;m({horizontal:se&&J?"right":"left",vertical:fe&&te?"top":"bottom"})},[k,E,y,l]),s.useEffect(()=>{if(!E||!y)return;function K(Q){L.current&&(L.current.contains(Q.target)||M(!1))}function $(Q){Q.key==="Escape"&&M(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",$)}},[E,y]);const _=t.jsxs("button",{type:"button",disabled:f,onClick:()=>{f||M(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 ${g}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":y?"var(--primary)":"var(--border)",color:N?"var(--text-main)":"var(--text-muted)",boxShadow:y?"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(H.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:N||c})]}),E?t.jsx(H.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${y?"rotate-180":""}`}):null]}),q=t.jsx(Si,{variant:E?"popover":"panel",value:r||_b(l),onChange:n,use12Hour:k,showSeconds:l,title:i,onClose:()=>M(!1)});return t.jsx(Rn,{label:e,required:h,error:b,helperText:u,helperDisplay:p,className:v,contentClassName:w,children:E?t.jsxs("div",{ref:L,className:"relative w-full",children:[_,y?t.jsx("div",{className:"absolute z-50",style:{...C.horizontal==="left"?{left:0}:{right:0},...C.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:q}):null]}):t.jsxs("div",{className:"space-y-2",children:[_,y?q:null]})})}function Vb(e,r){return e.icon?e.icon:e.kind==="folder"?r?t.jsx(H.HiFolderOpen,{className:"h-4 w-4"}):t.jsx(H.HiFolder,{className:"h-4 w-4"}):e.kind==="file"?t.jsx(H.HiDocument,{className:"h-4 w-4"}):e.kind==="group"?t.jsx(H.HiUserGroup,{className:"h-4 w-4"}):e.kind==="person"?t.jsx(H.HiUser,{className:"h-4 w-4"}):null}function Xb(e){return e.searchText?e.searchText:typeof e.label=="string"||typeof e.label=="number"?String(e.label):e.id}function Yb(e){const r=[],n=a=>{var o;for(const l of a)(o=l.children)!=null&&o.length&&(r.push(l.id),n(l.children))};return n(e),r}function Gb(e,r){const n=r.trim().toLowerCase();if(!n)return{nodes:e,expandIds:[]};const a=[],o=l=>{const i=[];for(const c of l){const f=c.children?o(c.children):[];(Xb(c).toLowerCase().includes(n)||f.length>0)&&(f.length>0&&a.push(c.id),i.push(f.length>0?{...c,children:f}:c))}return i};return{nodes:o(e),expandIds:a}}function Ci(e,r,n=0,a=null){var l;const o=[];for(const i of e){const c=!!((l=i.children)!=null&&l.length);o.push({node:i,depth:n,parentId:a,hasChildren:c}),c&&r.has(i.id)&&o.push(...Ci(i.children,r,n+1,i.id))}return o}function Kb({nodes:e,selectedId:r,defaultSelectedId:n=null,onSelect:a,expandedIds:o,defaultExpandedIds:l,onExpandedChange:i,defaultExpandAll:c=!1,searchable:f=!1,searchPlaceholder:d="Buscar...",emptyLabel:h="Sin elementos",noResultsLabel:b="Sin resultados",className:u,size:p="md",ariaLabel:v="Lista de arbol"}){const w=s.useId(),g=s.useRef(null),[E,y]=s.useState(""),[M,L]=s.useState(n),[C,m]=s.useState(()=>l??(c?Yb(e):[])),[k,N]=s.useState(null),_=s.useRef(new Map),[q,K]=s.useState(()=>new Set);s.useEffect(()=>()=>{_.current.forEach(S=>window.clearTimeout(S))},[]);const $=r!==void 0?r:M,Q=o??C,X=s.useMemo(()=>new Set(Q),[Q]),se=s.useMemo(()=>Gb(e,E),[e,E]),J=E.trim().length>0,fe=s.useMemo(()=>J?new Set([...X,...se.expandIds]):X,[X,se.expandIds,J]),te=s.useMemo(()=>Ci(se.nodes,fe),[se.nodes,fe]);s.useEffect(()=>{!k&&te[0]&&N(te[0].node.id)},[k,te]);function z(S){o===void 0&&m(S),i==null||i(S)}function R(S){K(T=>{const Y=new Set(T);return Y.add(S),Y});const U=_.current.get(S);U&&window.clearTimeout(U),_.current.set(S,window.setTimeout(()=>{K(T=>{if(!T.has(S))return T;const Y=new Set(T);return Y.delete(S),Y})},240))}function A(S){const U=new Set(Q);U.has(S)?U.delete(S):(U.add(S),R(S)),z([...U])}function F(S){S.disabled||(r===void 0&&L(S.id),a==null||a(S),N(S.id))}function ue(S){var Y,ce;if(te.length===0)return;const U=Math.max(0,te.findIndex(V=>V.node.id===k)),T=te[Math.min(te.length-1,Math.max(0,U+S))];T&&(N(T.node.id),(ce=(Y=g.current)==null?void 0:Y.querySelector(`[data-tree-id="${CSS.escape(T.node.id)}"]`))==null||ce.focus())}function P(S,U){var T,Y;S.key==="ArrowDown"?(S.preventDefault(),ue(1)):S.key==="ArrowUp"?(S.preventDefault(),ue(-1)):S.key==="ArrowRight"?(S.preventDefault(),U.hasChildren&&!fe.has(U.node.id)?A(U.node.id):ue(1)):S.key==="ArrowLeft"?(S.preventDefault(),U.hasChildren&&fe.has(U.node.id)?A(U.node.id):U.parentId&&(N(U.parentId),(Y=(T=g.current)==null?void 0:T.querySelector(`[data-tree-id="${CSS.escape(U.parentId)}"]`))==null||Y.focus())):(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),U.hasChildren&&S.key===" "?A(U.node.id):F(U.node))}const oe=p==="sm"?"py-1.5":"py-2",j=p==="sm"?"text-xs":"text-sm";return t.jsxs("div",{className:We("overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)]",u),children:[f&&t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsx("label",{htmlFor:w,className:"sr-only",children:d}),t.jsxs("div",{className:"relative",children:[t.jsx(H.HiMagnifyingGlass,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--text-muted)]"}),t.jsx("input",{id:w,value:E,onChange:S=>y(S.target.value),placeholder:d,className:"h-9 w-full rounded-lg border border-[var(--border)] bg-[var(--bg-input)] pl-8 pr-3 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--primary)]/30"})]})]}),te.length===0?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-[var(--text-muted)]",children:e.length===0?h:b}):t.jsx("div",{ref:g,role:"tree","aria-label":v,className:"max-h-[28rem] overflow-auto p-1.5",children:te.map((S,U)=>{const T=S.hasChildren&&fe.has(S.node.id),Y=$===S.node.id,ce=k===S.node.id,V=Vb(S.node,T),G=S.parentId!=null&&q.has(S.parentId),D=G?te.slice(0,U).filter(le=>le.parentId===S.parentId).length:0;return t.jsxs("div",{role:"treeitem","aria-expanded":S.hasChildren?T:void 0,"aria-selected":Y,"aria-disabled":S.node.disabled||void 0,"data-tree-id":S.node.id,tabIndex:ce||!k&&S===te[0]?0:-1,onKeyDown:le=>P(le,S),onFocus:()=>N(S.node.id),style:{paddingLeft:8+S.depth*16,animationDelay:G?`${Math.min(D,8)*28}ms`:void 0},className:We("group flex min-w-0 items-center gap-1 rounded-lg pr-2 outline-none transition-colors duration-150",G&&"bonsaif-rise",oe,S.node.disabled?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-[var(--bg-hover)]",Y&&"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]","focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40"),onClick:()=>{(S.node.kind==="folder"||S.node.kind==="group")&&S.hasChildren&&A(S.node.id),F(S.node)},children:[S.hasChildren?t.jsx("button",{type:"button","aria-label":T?"Contraer":"Expandir",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] hover:bg-[var(--bg-secondary)] hover:text-[var(--text-main)]",onClick:le=>{le.stopPropagation(),A(S.node.id)},children:t.jsx(H.HiChevronRight,{className:We("h-3.5 w-3.5 transition-transform duration-200 ease-out",T&&"rotate-90")})}):t.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center",children:!V&&t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"})}),V&&t.jsx("span",{className:We("inline-flex h-5 w-5 shrink-0 items-center justify-center transition-transform duration-200",T&&S.node.kind==="folder"&&"scale-110",S.node.kind==="folder"?"text-[#d4a017]":S.node.kind==="group"?"text-[var(--primary)]":"text-[var(--text-muted)]"),children:V}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:We("block truncate font-medium text-[var(--text-main)]",j),children:S.node.label}),S.node.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:S.node.description})]}),S.node.badge&&t.jsx("span",{className:"shrink-0",children:S.node.badge}),S.node.trailing&&t.jsx("span",{className:"shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:S.node.trailing})]},S.node.id)})})]})}const Go={neutral:"var(--text-muted)",primary:"var(--primary)",success:"#059669",warning:"#d97706",danger:"var(--danger, #dc2626)",info:"#2563eb"};function Zb({items:e,className:r,ariaLabel:n="Historial"}){return t.jsx("ol",{className:We("m-0 list-none p-0",r),"aria-label":n,children:e.map((a,o)=>{const l=a.tone??"primary",i=o===e.length-1;return t.jsxs("li",{className:"bonsaif-rise relative flex gap-3 pb-5 last:pb-0",style:{animationDelay:`${Math.min(o,8)*40}ms`},children:[!i&&t.jsx("span",{"aria-hidden":!0,className:"absolute bottom-0 left-[11px] top-6 w-px bg-[var(--border)]"}),t.jsx("span",{className:"relative z-[1] mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border bg-[var(--bg-card)] text-[11px]",style:{borderColor:Go[l],color:Go[l]},children:a.icon??t.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:Go[l]}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("p",{className:"m-0 truncate text-sm font-semibold text-[var(--text-main)]",children:a.title}),a.time&&t.jsx("time",{className:"shrink-0 text-xs text-[var(--text-muted)]",children:a.time})]}),a.description&&t.jsx("p",{className:"m-0 mt-1 text-sm leading-5 text-[var(--text-muted)]",children:a.description})]})]},a.id)})})}const Qb={up:{color:"#059669",icon:t.jsx(H.HiArrowUp,{className:"h-3.5 w-3.5"})},down:{color:"#dc2626",icon:t.jsx(H.HiArrowDown,{className:"h-3.5 w-3.5"})},neutral:{color:"var(--text-muted)",icon:t.jsx(H.HiMinus,{className:"h-3.5 w-3.5"})}};function Jb({label:e,value:r,delta:n,deltaTone:a="neutral",hint:o,sparkline:l,className:i}){const c=Qb[a];return t.jsxs("article",{className:We("bonsaif-rise flex min-w-0 flex-col gap-3 rounded-xl border border-[var(--border)] bg-[var(--bg-card)] p-4",i),children:[t.jsx("p",{className:"m-0 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:e}),t.jsxs("div",{className:"flex items-end justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"m-0 truncate text-2xl font-semibold tracking-tight text-[var(--text-main)]",children:r}),(n||o)&&t.jsxs("p",{className:"m-0 mt-1 flex items-center gap-1.5 text-xs text-[var(--text-muted)]",children:[n&&t.jsxs("span",{className:"inline-flex items-center gap-0.5 font-semibold",style:{color:c.color},children:[c.icon,n]}),o&&t.jsx("span",{className:"truncate",children:o})]})]}),l&&t.jsx("div",{className:"w-24 shrink-0",children:l})]})]})}function Rb(e,r,n){return r==="bottom"?{top:e.bottom+8,left:e.left+e.width/2-n.width/2}:r==="left"?{top:e.top+e.height/2-n.height/2,left:e.left-n.width-8}:r==="right"?{top:e.top+e.height/2-n.height/2,left:e.right+8}:{top:e.top-n.height-8,left:e.left+e.width/2-n.width/2}}function Ei({content:e,children:r,placement:n="top",delay:a=400,className:o}){const l=s.useId(),i=s.useRef(null),c=s.useRef(null),f=s.useRef(null),[d,h]=s.useState(!1),[b,u]=s.useState({top:0,left:0});function p(){f.current&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>h(!0),a)}function v(){f.current&&window.clearTimeout(f.current),h(!1)}s.useEffect(()=>{if(!d)return;const g=i.current,E=c.current;if(!g||!E)return;const y=Rb(g.getBoundingClientRect(),n,E.getBoundingClientRect()),M=Math.min(window.innerWidth-E.offsetWidth-8,Math.max(8,y.left)),L=Math.min(window.innerHeight-E.offsetHeight-8,Math.max(8,y.top));u({top:L,left:M})},[d,n,e]),s.useEffect(()=>()=>{f.current&&window.clearTimeout(f.current)},[]);const w={position:"fixed",top:b.top,left:b.left,zIndex:1e4};return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:i,className:"inline-flex",onMouseEnter:p,onMouseLeave:v,onFocus:p,onBlur:v,"aria-describedby":d?l:void 0,children:r}),d&&typeof document<"u"&&ft.createPortal(t.jsx("div",{ref:c,id:l,role:"tooltip",style:w,className:We("bonsaif-pop pointer-events-none max-w-xs rounded-md bg-[var(--text-main)] px-2 py-1 text-xs font-medium text-[var(--bg-card)] shadow-lg",o),children:e}),document.body)]})}function eh({trigger:e,children:r,align:n="start",open:a,defaultOpen:o=!1,onOpenChange:l,width:i=280,className:c}){const[f,d]=s.useState(o),[h,b]=s.useState({}),u=s.useRef(null),p=s.useRef(null),v=a??f,w=s.useCallback(E=>{a===void 0&&d(E),l==null||l(E)},[l,a]),g=s.useCallback(()=>{const E=u.current;if(!E)return;const y=E.getBoundingClientRect(),M=n==="end"?Math.max(8,y.right-i):Math.min(y.left,window.innerWidth-i-8),L=window.innerHeight-y.bottom,C=L<220&&y.top>L?void 0:y.bottom+6,m=C===void 0?window.innerHeight-y.top+6:void 0;b({position:"fixed",zIndex:9999,left:M,top:C,bottom:m,width:i})},[n,i]);return s.useEffect(()=>{if(!v)return;g();const E=M=>{var C,m;const L=M.target;(C=u.current)!=null&&C.contains(L)||(m=p.current)!=null&&m.contains(L)||w(!1)},y=M=>{M.key==="Escape"&&w(!1)};return window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),document.addEventListener("mousedown",E),document.addEventListener("keydown",y),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",y)}},[v,w,g]),t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:u,className:"inline-flex",onClick:()=>w(!v),children:e}),v&&typeof document<"u"&&ft.createPortal(t.jsx("div",{ref:p,"data-bonsaif-overlay":"true",role:"dialog",style:h,className:We("bonsaif-pop rounded-xl border border-[var(--border)] bg-[var(--bg-card)] p-3 text-sm text-[var(--text-main)] shadow-xl",c),children:r}),document.body)]})}function th({items:e,type:r="single",value:n,defaultValue:a=[],onValueChange:o,className:l}){const[i,c]=s.useState(a),f=n??i;function d(h){const b=f.includes(h),u=r==="single"?b?[]:[h]:b?f.filter(p=>p!==h):[...f,h];n===void 0&&c(u),o==null||o(u)}return t.jsx("div",{className:We("divide-y divide-[var(--border)] overflow-hidden rounded-xl border border-[var(--border)]",l),children:e.map(h=>{const b=f.includes(h.id);return t.jsxs("div",{className:"bg-[var(--bg-card)]",children:[t.jsxs("button",{type:"button",disabled:h.disabled,"aria-expanded":b,className:"flex w-full items-center gap-3 px-4 py-3 text-left disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>d(h.id),children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-semibold text-[var(--text-main)]",children:h.title}),h.description&&t.jsx("span",{className:"mt-0.5 block truncate text-xs text-[var(--text-muted)]",children:h.description})]}),t.jsx(H.HiChevronDown,{className:We("h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-200 ease-out",b&&"rotate-180")})]}),t.jsx("div",{className:"bonsaif-collapse","data-open":b?"true":"false",children:t.jsx("div",{inert:b?void 0:!0,children:t.jsx("div",{className:"px-4 pb-4 text-sm leading-6 text-[var(--text-main)]",children:h.content})})})]},h.id)})})}function rh({value:e,options:r,onChange:n,size:a="md",ariaLabel:o,className:l}){return t.jsx("div",{role:"radiogroup","aria-label":o,className:We("inline-flex rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-0.5",l),children:r.map(i=>{const c=i.value===e;return t.jsxs("button",{type:"button",role:"radio","aria-checked":c,disabled:i.disabled,onClick:()=>n(i.value),className:We("inline-flex items-center gap-1.5 rounded-md font-semibold transition-[background-color,color,box-shadow] duration-200 ease-out disabled:cursor-not-allowed disabled:opacity-40",a==="sm"?"px-2.5 py-1 text-xs":"px-3 py-1.5 text-sm",c?"bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"text-[var(--text-muted)] hover:text-[var(--text-main)]"),children:[i.icon,i.label]},i.value)})})}const Mi=160;function Ti(e,r){const n=new Float32Array(r),a=Math.max(1,Math.floor(e.length/r));for(let o=0;o<r;o+=1){const l=o*a;let i=0;for(let c=0;c<a;c+=1){const f=Math.abs(e[l+c]??0);f>i&&(i=f)}n[o]=i}return n}function nh(e,r=Mi){const n=Ti(e.getChannelData(0),r);return e.numberOfChannels>1?{mode:"multichannel",up:n,down:Ti(e.getChannelData(1),r)}:{mode:"mono",mono:n}}function ah(e,r,n,a={}){const o=a.bars??Mi,l=a.monoColor??"#34d399",i=a.upColor??"#60a5fa",c=a.downColor??"#34d399",f=a.background??"rgba(16, 185, 129, 0.08)",d=window.devicePixelRatio||1,h=e.clientWidth,b=e.clientHeight;if(h<2||b<2)return;(e.width!==Math.floor(h*d)||e.height!==Math.floor(b*d))&&(e.width=Math.floor(h*d),e.height=Math.floor(b*d));const u=e.getContext("2d");if(!u)return;u.setTransform(d,0,0,d,0,0),u.clearRect(0,0,h,b),u.fillStyle=f,u.fillRect(0,0,h,b);const p=b/2;if(u.save(),u.strokeStyle="rgba(255,255,255,0.28)",u.setLineDash([3,4]),u.beginPath(),u.moveTo(0,p),u.lineTo(h,p),u.stroke(),u.restore(),!r)return;const v=h/o,w=Math.max(1,v*.55),g=Math.max(0,Math.min(1,n));for(let y=0;y<o;y+=1){const M=y*v+(v-w)/2;if(u.globalAlpha=y/o<=g?1:.38,r.mode==="mono"){const L=(r.mono[y]??0)*(b*.46);u.fillStyle=l,u.fillRect(M,p-L,w,Math.max(L*2,1))}else{const L=(r.up[y]??0)*(b*.46),C=(r.down[y]??0)*(b*.46);u.fillStyle=i,u.fillRect(M,p-L,w,Math.max(L,.5)),u.fillStyle=c,u.fillRect(M,p,w,Math.max(C,.5))}}u.globalAlpha=1;const E=g*h;u.fillStyle="rgba(255,255,255,0.85)",u.fillRect(E,6,1.5,b-12)}const oh=[.75,1,1.25,1.5,2],sh=5,lh=["Cliente","Asesor"],Li=["#60a5fa","#34d399"];function kn(e){if(!Number.isFinite(e)||e<0)return"0:00";const r=Math.floor(e),n=Math.floor(r/60),a=r%60;return`${n}:${String(a).padStart(2,"0")}`}function ih(e){return`${e}×`}function ch({src:e,title:r="Grabacion",downloadName:n,className:a,fetchCredentials:o="omit",channelLabels:l,channelColors:i,skipSeconds:c=sh,showDownload:f=!0}){const d=s.useRef(null),h=s.useRef(null),b=s.useRef(null),u=s.useRef(""),p=s.useRef(!1),v=s.useRef(0),[w,g]=s.useState(!1),[E,y]=s.useState(0),[M,L]=s.useState(0),[C,m]=s.useState(1),[k,N]=s.useState(1),[_,q]=s.useState(!1),[K,$]=s.useState(""),[Q,X]=s.useState(""),[se,J]=s.useState(!1),fe=l??lh,te=(i==null?void 0:i[0])??Li[0],z=(i==null?void 0:i[1])??Li[1],R=s.useRef({monoColor:z,upColor:te,downColor:z});R.current={monoColor:z,upColor:te,downColor:z};function A(j){v.current=j;const S=h.current;S&&ah(S,b.current,j,R.current)}s.useEffect(()=>{if(b.current=null,$(""),y(0),L(0),g(!1),X(""),J(!1),q(!!e),!e){q(!1);return}const j=new AbortController;let S=!0;return(async()=>{var U,T;try{const Y=await fetch(e,{credentials:o,signal:j.signal});if(!Y.ok)throw new Error("unavailable");const ce=await Y.arrayBuffer();if(!S)return;const V=((T=(U=Y.headers.get("content-type"))==null?void 0:U.split(";")[0])==null?void 0:T.trim())||"audio/wav",G=URL.createObjectURL(new Blob([ce],{type:V}));if(!S){URL.revokeObjectURL(G);return}u.current&&p.current&&URL.revokeObjectURL(u.current),u.current=G,p.current=!0,X(G);const D=new AudioContext;D.state==="suspended"&&await D.resume();const le=await D.decodeAudioData(ce.slice(0));if(!S){await D.close();return}b.current=nh(le),J(b.current.mode==="multichannel"),Number.isFinite(le.duration)&&L(le.duration),await D.close();const be=d.current,ie=be&&be.duration?be.currentTime/be.duration:0;A(ie)}catch(Y){if(Y.name==="AbortError")return;$("No se pudo cargar el audio")}finally{S&&q(!1)}})(),()=>{S=!1,j.abort(),u.current&&p.current&&URL.revokeObjectURL(u.current),u.current="",p.current=!1}},[e,o]),s.useEffect(()=>{A(v.current)},[te,z]),s.useEffect(()=>{const j=h.current;if(!j||!e)return;const S=new ResizeObserver(()=>{A(v.current)});return S.observe(j),A(v.current),()=>S.disconnect()},[e]);function F(){const j=d.current;j&&(j.paused?j.play().catch(()=>$("No se pudo reproducir el audio")):j.pause())}function ue(j){const S=d.current;if(!S)return;const U=Math.min(Math.max(0,S.currentTime+j),Number.isFinite(S.duration)?S.duration:S.currentTime+j);S.currentTime=U,y(U)}function P(j){const S=d.current;if(!S||!Number.isFinite(S.duration)||S.duration<=0)return;const U=j.currentTarget.getBoundingClientRect(),T=Math.min(1,Math.max(0,(j.clientX-U.left)/U.width));S.currentTime=T*S.duration,y(S.currentTime),A(T)}const oe=M||0;return t.jsxs("div",{className:We("overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)]",a),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("p",{className:"m-0 truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx("span",{className:"text-[11px] tabular-nums text-[var(--text-muted)]",children:kn(oe||E)}),f&&e?t.jsx("a",{href:e,download:n||!0,className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-[var(--text-muted)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-main)]","aria-label":"Descargar audio",children:t.jsx(H.HiArrowDownTray,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{className:"px-3 py-3",children:[se?t.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-3 text-[11px] text-[var(--text-muted)]",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:te}}),fe[0]]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:z}}),fe[1]]})]}):null,t.jsx("canvas",{ref:h,onClick:P,role:"slider","aria-label":"Posicion en la grabacion","aria-valuemin":0,"aria-valuemax":oe||0,"aria-valuenow":E,"aria-valuetext":`${kn(E)} de ${kn(oe)}`,className:We("h-16 w-full cursor-pointer rounded-lg bg-[rgba(6,78,59,0.35)]",!e&&"opacity-50")}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[t.jsx("button",{type:"button","aria-label":"Retroceder",disabled:!Q,onClick:()=>ue(-c),className:"rounded-md p-1 text-[var(--text-muted)] hover:text-[var(--text-main)] disabled:opacity-40",children:t.jsx(H.HiBackward,{className:"h-4 w-4"})}),t.jsx("button",{type:"button","aria-label":w?"Pausar":"Reproducir",disabled:!Q,onClick:F,className:"flex h-9 w-9 items-center justify-center rounded-full border-2 border-[var(--primary)] text-[var(--primary)] transition-transform duration-150 active:scale-95 disabled:opacity-40",children:w?t.jsx(H.HiPause,{className:"h-4 w-4"}):t.jsx(H.HiPlay,{className:"h-4 w-4"})}),t.jsx("button",{type:"button","aria-label":"Adelantar",disabled:!Q,onClick:()=>ue(c),className:"rounded-md p-1 text-[var(--text-muted)] hover:text-[var(--text-main)] disabled:opacity-40",children:t.jsx(H.HiForward,{className:"h-4 w-4"})}),t.jsxs("span",{className:"px-1 text-[11px] tabular-nums text-[var(--text-muted)]",children:[kn(E)," / ",kn(oe)]}),oh.map(j=>t.jsx("button",{type:"button",disabled:!Q,onClick:()=>{m(j),d.current&&(d.current.playbackRate=j)},className:We("rounded-full border border-[var(--border)] px-2 py-0.5 text-[10px] font-semibold disabled:opacity-40",C===j?"bg-[var(--bg-hover)] text-[var(--text-main)]":"text-[var(--text-muted)]"),children:ih(j)},j)),t.jsxs("label",{className:"ml-auto inline-flex items-center gap-1 text-[var(--text-muted)]",children:[t.jsx(H.HiSpeakerWave,{className:"h-3.5 w-3.5"}),t.jsx("input",{type:"range",min:0,max:1,step:.05,value:k,disabled:!Q,"aria-label":"Volumen",onChange:j=>{const S=Number(j.target.value);N(S),d.current&&(d.current.volume=S)},className:"h-1 w-16 accent-[var(--primary)] disabled:opacity-40"})]})]}),_?t.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:"Cargando forma de onda…"}):null,K?t.jsx("p",{className:"mt-2 text-[11px] text-[var(--danger,#dc2626)]",children:K}):null]}),Q?t.jsx("audio",{ref:d,src:Q,preload:"auto",className:"hidden",onPlay:()=>g(!0),onPause:()=>g(!1),onTimeUpdate:j=>{const S=j.currentTarget;y(S.currentTime),Number.isFinite(S.duration)&&L(S.duration),A(S.duration?S.currentTime/S.duration:0)},onLoadedMetadata:j=>{const S=j.currentTarget;Number.isFinite(S.duration)&&L(S.duration)},onEnded:()=>g(!1),onError:()=>$("No se pudo reproducir el audio")}):null]})}const Ko=[1,1.25,1.5,2];function Ai(e){if(!Number.isFinite(e)||e<0)return"0:00";const r=Math.floor(e),n=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return n>0?`${n}:${String(a).padStart(2,"0")}:${String(o).padStart(2,"0")}`:`${a}:${String(o).padStart(2,"0")}`}function dh({src:e,poster:r,title:n="Video",downloadName:a,className:o}){const l=s.useRef(null),i=s.useRef(null),[c,f]=s.useState(!1),[d,h]=s.useState(!1),[b,u]=s.useState(!1),[p,v]=s.useState(0),[w,g]=s.useState(0),[E,y]=s.useState(1);s.useEffect(()=>{const k=()=>u(document.fullscreenElement===l.current);return document.addEventListener("fullscreenchange",k),()=>document.removeEventListener("fullscreenchange",k)},[]);function M(){const k=i.current;!k||!e||(k.paused?(k.play(),f(!0)):(k.pause(),f(!1)))}function L(){const k=i.current,N=Ko[(Ko.indexOf(E)+1)%Ko.length]??1;y(N),k&&(k.playbackRate=N)}function C(){const k=i.current;k&&(k.muted=!k.muted,h(k.muted))}function m(){const k=l.current;k&&(document.fullscreenElement===k?document.exitFullscreen():k.requestFullscreen())}return t.jsx("div",{ref:l,className:We("bonsaif-fade overflow-hidden rounded-xl border border-[var(--border)] bg-black",o),children:t.jsxs("div",{className:"relative",children:[t.jsx("video",{ref:i,src:e,poster:r,preload:"metadata",playsInline:!0,className:"aspect-video w-full bg-black","aria-label":n,onClick:M,onTimeUpdate:k=>v(k.currentTarget.currentTime),onLoadedMetadata:k=>g(k.currentTarget.duration),onPlay:()=>f(!0),onPause:()=>f(!1),onEnded:()=>f(!1)}),!c&&t.jsx("button",{type:"button",onClick:M,disabled:!e,"aria-label":"Reproducir",className:"bonsaif-pop absolute left-1/2 top-1/2 inline-flex h-14 w-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-white/90 text-black shadow-lg transition-transform duration-150 hover:scale-105 active:scale-95 disabled:opacity-40",children:t.jsx(H.HiPlay,{className:"h-6 w-6"})}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 bg-gradient-to-b from-black/70 to-transparent px-3 py-2",children:t.jsx("p",{className:"m-0 truncate text-sm font-semibold text-white",children:n})}),t.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent px-3 pb-3 pt-8",children:[t.jsx("input",{type:"range",min:0,max:w||0,step:.1,value:Math.min(p,w||0),disabled:!e||!w,"aria-label":"Posicion",className:"mb-2 h-1 w-full accent-white",onChange:k=>{const N=Number(k.currentTarget.value);v(N),i.current&&(i.current.currentTime=N)}}),t.jsxs("div",{className:"flex items-center gap-1.5 text-white",children:[t.jsx("button",{type:"button",onClick:M,disabled:!e,"aria-label":c?"Pausar":"Reproducir",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-transform duration-150 hover:bg-white/15 active:scale-95 disabled:opacity-40",children:c?t.jsx(H.HiPause,{className:"h-4 w-4"}):t.jsx(H.HiPlay,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:C,disabled:!e,"aria-label":d?"Activar sonido":"Silenciar",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-colors duration-150 hover:bg-white/15 disabled:opacity-40",children:d?t.jsx(H.HiSpeakerXMark,{className:"h-4 w-4"}):t.jsx(H.HiSpeakerWave,{className:"h-4 w-4"})}),t.jsxs("span",{className:"ml-1 text-xs tabular-nums text-white/80",children:[Ai(p)," / ",Ai(w)]}),t.jsx("span",{className:"ml-auto"}),t.jsxs("button",{type:"button",onClick:L,disabled:!e,"aria-label":"Velocidad",className:"h-8 rounded-md px-2 text-xs font-semibold transition-colors duration-150 hover:bg-white/15 disabled:opacity-40",children:[E,"x"]}),e&&t.jsx("a",{href:e,download:a||!0,"aria-label":"Descargar video",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-colors duration-150 hover:bg-white/15",children:t.jsx(H.HiArrowDownTray,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:m,"aria-label":b?"Salir de pantalla completa":"Pantalla completa",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-colors duration-150 hover:bg-white/15",children:b?t.jsx(H.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(H.HiArrowsPointingOut,{className:"h-4 w-4"})})]})]})]})})}function dr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function $i(e){try{const r=new URL(e);return dr(r.pathname)}catch{return""}}function uh(e){const r=dr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return dr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?dr(`/${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())?"":dr(`/${a[0]}`)}const Zo="primeSuiteAppUrl",fh={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"}},Di={xs:20,sm:28,md:36,lg:48,xl:64},Hi=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],bh={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},hh="bonsaif.bot",ph="Bonsaif Bot",mh={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Oi(e){return typeof e=="string"?e.trim():""}function gh(e){var o;if(e!==void 0)return dr(e);const r=dr(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(Zo)||"";i&&window.sessionStorage.setItem(Zo,i);const c=window.sessionStorage.getItem(Zo)||"",f=i||c;if(f){const d=$i(f);if(d&&!/^\/admin(\/|$)/i.test(d))return d}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?$i(a):dr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return uh(window.location.pathname)}function vh(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 xh(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Hi[r%Hi.length]}function yh(e,r){return e===hh||r===ph}function wh(e,r){return`${e.replace(/\/$/,"")}${r}`}function Qo({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:f,wrapperClassName:d="",labelClassName:h="",labelSize:b="xs",avatarVersion:u=0,className:p="",style:v}){const[w,g]=s.useState(!1),E=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{g(!1)},[E,u]);const{wh:y,text:M}=fh[a],L=Oi(n)||Oi(r)||c,C=vh(L),m=gh(f),k=yh(r,n),N=wh(m,"/favicon.svg"),_=s.useMemo(()=>{if(!E)return"";const X=new URLSearchParams;X.set("size",String(Di[a])),u&&X.set("v",String(u));const se=X.toString();return`${m}/api/user/avatar/${encodeURIComponent(E)}${se?`?${se}`:""}`},[u,m,E,a]),q=Di[a],K=k?t.jsx("span",{className:`${y} ${mh[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${p}`,style:v,children:t.jsx("img",{src:N,alt:L,width:q,height:q,className:"h-full w-full object-contain"})}):_&&!w?t.jsx("img",{src:_,alt:L,width:q,height:q,className:`${y} rounded-full object-cover flex-shrink-0 ${p}`,style:v,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${E}-${u}`):t.jsx("span",{className:`${y} ${xh(L)} ${M} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:v,title:L,children:C});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${d}`,children:[K,t.jsx("span",{className:`min-w-0 truncate ${bh[b]} font-medium text-[var(--text-main)] ${h}`,title:L,children:L})]});const $=l??!0,Q=i??L;return $&&Q?t.jsx(Vt,{as:"span",content:Q,className:`inline-flex flex-shrink-0 ${d}`,children:K}):K}function Nh({people:e,max:r=4,size:n="sm",className:a}){const o=e.slice(0,r),l=e.slice(r),i=n==="xs"?"-ml-1.5":n==="md"?"-ml-3":"-ml-2";return t.jsxs("div",{className:We("flex items-center",a),"aria-label":"Personas",children:[o.map((c,f)=>t.jsx("span",{className:We("relative bonsaif-rise rounded-full ring-2 ring-[var(--bg-card)] transition-transform duration-150 hover:z-20 hover:scale-105",f>0&&i),style:{animationDelay:`${f*40}ms`},children:t.jsx(Qo,{userId:c.userId,username:c.username,name:c.name,size:n,showTooltip:!0})},c.id)),l.length>0&&t.jsx(Ei,{content:l.map(c=>c.name).join(", "),children:t.jsxs("span",{className:We("relative z-10 inline-flex items-center justify-center rounded-full bg-[var(--bg-input)] font-semibold text-[var(--text-main)] ring-2 ring-[var(--bg-card)] transition-transform duration-150 hover:z-20 hover:scale-105",i,n==="xs"?"h-5 min-w-5 px-1 text-[9px]":n==="md"?"h-9 min-w-9 px-1.5 text-xs":"h-7 min-w-7 px-1 text-[10px]"),children:["+",l.length]})})]})}function kh({children:e,items:r,className:n}){const a=s.useRef(null),[o,l]=s.useState(!1),[i,c]=s.useState({x:0,y:0}),[f,d]=s.useState({});function h(b){b.preventDefault(),c({x:b.clientX,y:b.clientY}),l(!0)}return s.useEffect(()=>{if(!o)return;const b=a.current,u=(b==null?void 0:b.offsetWidth)??200,p=(b==null?void 0:b.offsetHeight)??160,v=Math.min(i.x,window.innerWidth-u-8),w=Math.min(i.y,window.innerHeight-p-8);d({position:"fixed",zIndex:1e4,left:Math.max(8,v),top:Math.max(8,w),minWidth:180});const g=y=>{var M;(M=a.current)!=null&&M.contains(y.target)||l(!1)},E=y=>{y.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",E)}},[o,i.x,i.y]),t.jsxs(t.Fragment,{children:[t.jsx("div",{onContextMenu:h,className:n,children:e}),o&&typeof document<"u"&&ft.createPortal(t.jsx("div",{ref:a,role:"menu","data-bonsaif-overlay":"true",style:f,className:"bonsaif-pop overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl",children:r.map(b=>t.jsxs("div",{children:[b.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:b.disabled,className:We("flex w-full items-start gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors duration-150 hover:bg-[var(--bg-hover)] disabled:cursor-not-allowed disabled:opacity-40",b.danger?"text-[var(--danger)]":"text-[var(--text-main)]"),onClick:()=>{var u;b.disabled||((u=b.onSelect)==null||u.call(b),l(!1))},children:[b.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:b.icon}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate font-medium",children:b.label}),b.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:b.description})]})]})]},b.id))}),document.body)]})}const Sh={primary:"var(--primary)",success:"#059669",warning:"#d97706",danger:"var(--danger, #dc2626)"};function Ch({value:e,max:r=100,label:n,showValue:a=!0,tone:o="primary",size:l="md",className:i}){const c=r>0?r:100,f=Math.min(1,Math.max(0,e/c)),d=Math.round(f*100);return t.jsxs("div",{className:We("min-w-0",i),children:[(n||a)&&t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-3 text-xs",children:[t.jsx("span",{className:"truncate font-medium text-[var(--text-main)]",children:n}),a&&t.jsxs("span",{className:"shrink-0 tabular-nums text-[var(--text-muted)]",children:[d,"%"]})]}),t.jsx("div",{role:"progressbar","aria-valuenow":Math.round(e),"aria-valuemin":0,"aria-valuemax":c,"aria-label":typeof n=="string"?n:"Progreso",className:We("overflow-hidden rounded-full bg-[var(--bg-input)]",l==="sm"?"h-1.5":"h-2.5"),children:t.jsx("div",{className:"h-full rounded-full transition-[width] duration-300 ease-out",style:{width:`${d}%`,background:Sh[o]}})})]})}function Ii({title:e,items:r,query:n,onQuery:a,selected:o,onToggle:l,onMove:i,placeholder:c}){const f=r.filter(d=>`${d.label} ${d.description??""}`.toLowerCase().includes(n.trim().toLowerCase()));return t.jsxs("section",{className:"flex min-h-64 min-w-0 flex-1 flex-col overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)]",children:[t.jsxs("header",{className:"border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("p",{className:"m-0 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:[e,t.jsxs("span",{className:"ml-1 tabular-nums",children:["(",r.length,")"]})]}),t.jsx("input",{value:n,onChange:d=>a(d.currentTarget.value),placeholder:c,className:"mt-2 h-8 w-full rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]"})]}),t.jsx("ul",{className:"m-0 flex-1 list-none overflow-auto p-1.5",children:f.length===0?t.jsx("li",{className:"px-2 py-6 text-center text-xs text-[var(--text-muted)]",children:"Sin resultados"}):f.map(d=>{const h=o.has(d.id);return t.jsx("li",{children:t.jsxs("button",{type:"button",disabled:d.disabled,onClick:()=>l(d.id),onDoubleClick:()=>i(d.id),className:We("flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40",h?"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]":"hover:bg-[var(--bg-hover)]"),children:[t.jsx("span",{"aria-hidden":!0,className:We("mt-0.5 h-3.5 w-3.5 shrink-0 rounded border",h?"border-[var(--primary)] bg-[var(--primary)]":"border-[var(--border)]")}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:d.label}),d.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:d.description})]})]})},d.id)})})]})}function Eh({items:e,value:r,onChange:n,availableLabel:a="Disponibles",assignedLabel:o="Asignados",searchPlaceholder:l="Buscar...",className:i}){const[c,f]=s.useState(""),[d,h]=s.useState(""),[b,u]=s.useState([]),p=s.useMemo(()=>new Set(r),[r]),v=s.useMemo(()=>new Set(b),[b]),w=e.filter(M=>!p.has(M.id)),g=e.filter(M=>p.has(M.id));function E(M){u(L=>L.includes(M)?L.filter(C=>C!==M):[...L,M])}function y(M,L){const C=new Set(M.filter(k=>e.some(N=>N.id===k&&!N.disabled)));if(C.size===0)return;const m=L==="assigned"?[...r,...[...C].filter(k=>!p.has(k))]:r.filter(k=>!C.has(k));n(m),u(k=>k.filter(N=>!C.has(N)))}return t.jsxs("div",{className:We("flex flex-col gap-3 sm:flex-row sm:items-stretch",i),children:[t.jsx(Ii,{title:a,items:w,query:c,onQuery:f,selected:v,onToggle:E,onMove:M=>y([M],"assigned"),placeholder:l}),t.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 sm:flex-col",children:[t.jsx("button",{type:"button","aria-label":"Asignar",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-[var(--text-main)] transition-colors duration-150 hover:bg-[var(--bg-hover)]",onClick:()=>y(b.filter(M=>!p.has(M)),"assigned"),children:t.jsx(H.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button","aria-label":"Quitar",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-[var(--text-main)] transition-colors duration-150 hover:bg-[var(--bg-hover)]",onClick:()=>y(b.filter(M=>p.has(M)),"available"),children:t.jsx(H.HiChevronLeft,{className:"h-4 w-4"})})]}),t.jsx(Ii,{title:o,items:g,query:d,onQuery:h,selected:v,onToggle:E,onMove:M=>y([M],"available"),placeholder:l})]})}function Mh({items:e,columns:r=1,className:n,ariaLabel:a="Propiedades"}){return t.jsx("dl",{"aria-label":a,className:We("bonsaif-fade m-0 grid gap-px overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--border)]",r===2?"sm:grid-cols-2":"grid-cols-1",n),children:e.map(o=>t.jsxs("div",{className:"bg-[var(--bg-card)] px-4 py-3",children:[t.jsx("dt",{className:"text-xs font-medium text-[var(--text-muted)]",children:o.label}),t.jsx("dd",{className:"m-0 mt-1 text-sm font-medium text-[var(--text-main)]",children:o.value}),o.hint&&t.jsx("p",{className:"m-0 mt-1 text-xs text-[var(--text-muted)]",children:o.hint})]},o.id))})}function Th({chips:e,onRemove:r,onClear:n,clearLabel:a="Limpiar",emptyLabel:o="Sin filtros",className:l}){return e.length===0?t.jsx("p",{className:We("m-0 text-sm text-[var(--text-muted)]",l),children:o}):t.jsxs("div",{className:We("flex flex-wrap items-center gap-2",l),"aria-label":"Filtros aplicados",children:[e.map(i=>t.jsxs("span",{className:"bonsaif-rise inline-flex max-w-full items-center gap-1 rounded-full border border-[var(--border)] bg-[var(--bg-input)] py-1 pl-2.5 pr-1 text-xs text-[var(--text-main)]",children:[t.jsx("span",{className:"text-[var(--text-muted)]",children:i.label}),i.value&&t.jsx("span",{className:"truncate font-semibold",children:i.value}),t.jsx("button",{type:"button","aria-label":`Quitar ${typeof i.label=="string"?i.label:"filtro"}`,className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-[var(--text-muted)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-main)]",onClick:()=>r(i.id),children:t.jsx(H.HiXMark,{className:"h-3.5 w-3.5"})})]},i.id)),n&&t.jsx("button",{type:"button",onClick:n,className:"text-xs font-semibold text-[var(--primary)] hover:underline",children:a})]})}function Lh({items:e,open:r,defaultOpen:n=!1,onOpenChange:a,shortcut:o=!1,placeholder:l="Buscar...",emptyLabel:i="Sin resultados",className:c}){const[f,d]=s.useState(n),[h,b]=s.useState(""),[u,p]=s.useState(0),v=s.useRef(null),w=r??f,g=s.useCallback(m=>{r===void 0&&d(m),a==null||a(m),m||(b(""),p(0))},[r,a]),E=s.useMemo(()=>{const m=h.trim().toLowerCase();return m?e.filter(k=>`${k.label} ${k.group??""} ${k.keywords??""}`.toLowerCase().includes(m)):e},[e,h]),y=s.useRef(w);y.current=w,s.useEffect(()=>{if(!o)return;const m=k=>{(k.metaKey||k.ctrlKey)&&k.key.toLowerCase()==="k"&&(k.preventDefault(),g(!y.current))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[o,g]),s.useEffect(()=>{if(!w)return;const m=window.requestAnimationFrame(()=>{var N;return(N=v.current)==null?void 0:N.focus()}),k=N=>{N.key==="Escape"&&g(!1)};return document.addEventListener("keydown",k),()=>{window.cancelAnimationFrame(m),document.removeEventListener("keydown",k)}},[w,g]),s.useEffect(()=>{p(0)},[h,w]);function M(m){var k;m.disabled||((k=m.onSelect)==null||k.call(m),g(!1))}function L(m){if(m.key==="ArrowDown")m.preventDefault(),p(k=>Math.min(E.length-1,k+1));else if(m.key==="ArrowUp")m.preventDefault(),p(k=>Math.max(0,k-1));else if(m.key==="Enter"){m.preventDefault();const k=E[u];k&&M(k)}}if(!w||typeof document>"u")return null;let C="";return ft.createPortal(t.jsx("div",{className:"bonsaif-fade fixed inset-0 z-[10000] flex items-start justify-center bg-black/40 p-4 pt-[12vh]",onMouseDown:()=>g(!1),children:t.jsxs("div",{role:"dialog","aria-label":"Paleta de comandos","data-bonsaif-overlay":"true",className:We("bonsaif-pop w-full max-w-lg overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)] shadow-2xl",c),onMouseDown:m=>m.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-3",children:[t.jsx(H.HiMagnifyingGlass,{className:"h-4 w-4 text-[var(--text-muted)]"}),t.jsx("input",{ref:v,value:h,onChange:m=>b(m.currentTarget.value),onKeyDown:L,placeholder:l,className:"h-12 w-full bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)]"})]}),t.jsx("div",{className:"max-h-80 overflow-auto p-1.5",role:"listbox",children:E.length===0?t.jsx("p",{className:"px-3 py-8 text-center text-sm text-[var(--text-muted)]",children:i}):E.map((m,k)=>{const N=m.group&&m.group!==C;m.group&&(C=m.group);const _=k===u;return t.jsxs("div",{children:[N&&t.jsx("p",{className:"px-2 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:m.group}),t.jsxs("button",{type:"button",role:"option","aria-selected":_,disabled:m.disabled,className:We("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-[var(--text-main)] disabled:opacity-40",_&&"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]"),onMouseEnter:()=>p(k),onClick:()=>M(m),children:[m.icon&&t.jsx("span",{className:"text-[var(--text-muted)]",children:m.icon}),t.jsx("span",{className:"truncate",children:m.label})]})]},m.id)})})]})}),document.body)}const Ah={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function $h({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=Ah[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 Xr=360,ur=10,pa=14,Jo=220;function Dh(e){if(typeof document>"u")return null;const r=document.querySelector(e);if(!(r instanceof HTMLElement))return null;const n=r.getBoundingClientRect();return n.width===0&&n.height===0?null:{top:n.top,left:n.left,width:n.width,height:n.height}}function Hh(e,r,n={width:window.innerWidth,height:window.innerHeight}){if(e&&e!=="auto")return e;const a=n.height-(r.top+r.height),o=r.top,l=n.width-(r.left+r.width);return a>=Jo?"bottom":o>=Jo?"top":l>=Xr+24?"right":"left"}function Oh(e){return{top:Math.max(8,e.top-ur),left:Math.max(8,e.left-ur),width:e.width+ur*2,height:e.height+ur*2}}function Ih(e,r,n={width:window.innerWidth,height:window.innerHeight}){const a=e.left+e.width/2,o=e.top+e.height/2,l=n.width-Xr-16;return r==="bottom"?{top:e.top+e.height+ur+pa,left:Math.min(Math.max(16,a-Xr/2),l)}:r==="top"?{top:Math.max(16,e.top-ur-pa-Jo),left:Math.min(Math.max(16,a-Xr/2),l)}:r==="right"?{top:Math.min(Math.max(16,o-120),n.height-260),left:Math.min(e.left+e.width+ur+pa,l)}:{top:Math.min(Math.max(16,o-120),n.height-260),left:Math.max(16,e.left-ur-pa-Xr)}}function Bh(e){const r=document.querySelector(e);r instanceof HTMLElement&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}function Fh({steps:e,open:r,onOpenChange:n,label:a="Guía",storageKey:o,onStepChange:l,backLabel:i="Atrás",skipLabel:c="Saltar",nextLabel:f="Siguiente",doneLabel:d="Listo",closeLabel:h="Cerrar guía",zIndex:b=1100}){const u=s.useId(),[p,v]=s.useState(0),[w,g]=s.useState(null),[E,y]=s.useState(!1),M=e[p]??e[0],L=e.length;s.useEffect(()=>{y(!0)},[]),s.useEffect(()=>{r&&v(0)},[r]),s.useEffect(()=>{!r||!M||l==null||l(M,p)},[r,M,p,l]);const C=s.useCallback(()=>{M&&g(Dh(M.target))},[M]);s.useLayoutEffect(()=>{if(!r||!M)return;Bh(M.target);const q=window.setTimeout(C,80),K=window.setTimeout(C,280);return()=>{window.clearTimeout(q),window.clearTimeout(K)}},[r,M,C]),s.useEffect(()=>{if(r)return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[r,C]);const m=s.useCallback(()=>{if(n(!1),!!o)try{localStorage.setItem(o,"done")}catch{}},[n,o]);s.useEffect(()=>{if(!r)return;function q(K){if(K.key==="Escape"){K.preventDefault(),m();return}if(K.key==="ArrowRight"||K.key==="Enter"){K.preventDefault(),v($=>Math.min($+1,L-1));return}K.key==="ArrowLeft"&&(K.preventDefault(),v($=>Math.max($-1,0)))}return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[r,m,L]);const k=s.useMemo(()=>!w||!M?"bottom":Hh(M.placement,w),[w,M]),N=s.useMemo(()=>w?Oh(w):null,[w]),_=s.useMemo(()=>typeof window>"u"?{top:96,left:16}:N?Ih(N,k):{top:96,left:Math.max(16,(window.innerWidth-Xr)/2)},[N,k]);return!E||!r||!M?null:ft.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:b},role:"dialog","aria-modal":"true","aria-labelledby":u,children:[t.jsx("button",{type:"button",className:"absolute inset-0 cursor-default bg-transparent","aria-label":h,onClick:m}),N?t.jsx("div",{className:"pointer-events-none absolute rounded-xl border-2 border-[var(--primary)] transition-all duration-200",style:{top:N.top,left:N.left,width:N.width,height:N.height,boxShadow:"0 0 0 9999px rgba(0, 0, 0, 0.58)"}}):t.jsx("div",{className:"pointer-events-none absolute inset-0 bg-black/58"}),t.jsxs("div",{className:"absolute w-[min(360px,calc(100vw-2rem))] rounded-2xl border border-[var(--border)] bg-[var(--bg-card)] p-4 shadow-2xl",style:{..._,zIndex:b+1},children:[t.jsxs("div",{className:"mb-3 flex items-start gap-2",children:[t.jsx("div",{className:"mt-0.5 rounded-lg p-1.5 text-[var(--primary)]",style:{background:"color-mix(in srgb, var(--primary) 15%, transparent)"},children:t.jsx(H.HiOutlineLightBulb,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider text-[var(--text-muted)]",children:[a," · ",p+1,"/",L]}),t.jsx("h2",{id:u,className:"mt-0.5 text-sm font-semibold text-[var(--text-main)]",children:M.title})]}),t.jsx(Ke,{variant:"icon",iconOnly:!0,"aria-label":h,tooltip:"Cerrar",onClick:m,children:t.jsx(H.HiXMark,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"space-y-3 text-sm leading-6 text-[var(--text-secondary)]",children:[M.body,M.caption?t.jsx("p",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2 font-mono text-[11px] text-[var(--text-main)]",children:M.caption}):null]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[t.jsx(Ke,{variant:"secondary",size:"sm",disabled:p===0,onClick:()=>v(q=>Math.max(q-1,0)),children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ke,{variant:"secondary",size:"sm",onClick:m,children:c}),p<L-1?t.jsx(Ke,{size:"sm",onClick:()=>v(q=>Math.min(q+1,L-1)),children:f}):t.jsx(Ke,{size:"sm",onClick:m,children:d})]})]})]})]}),document.body)}function Ph(e){const[r,n]=s.useState(!1);s.useEffect(()=>{try{if(localStorage.getItem(e)==="done")return;n(!0)}catch{n(!0)}},[e]);const a=s.useCallback(()=>{try{localStorage.setItem(e,"done")}catch{}},[e]),o=s.useCallback(()=>n(!0),[]),l=s.useCallback((i=!0)=>{n(!1),i&&a()},[a]);return{open:r,setOpen:n,openTour:o,closeTour:l,markDone:a}}const Bi=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),_h=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function zh(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 Fi(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Pi(e){Fi(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Wh(e){const r=e.querySelector(_h);return r instanceof HTMLElement?r:null}function _i(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Bi).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Xa.OverlayScrollbars(l)){Pi(l);return}if(!zh(l))return;const c={overflow:Fi(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},f=Wh(l),d=f?Xa.OverlayScrollbars({target:l,elements:{viewport:f}},c):Xa.OverlayScrollbars(l,c);Pi(l),e.set(l,d)})},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(Bi).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function jh({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function qh(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function zi({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:f,LinkComponent:d=jh}){const[h,b]=s.useState(!1),u=qh(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(_i,{}),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(H.HiBars3,{className:"h-5 w-5"})}),h&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${h?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(H.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(H.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(u).map(([p,v])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(H.HiChevronDown,{className:"h-3.5 w-3.5"}),p]}),t.jsx("div",{className:"space-y-1",children:v.map(w=>{const g=n===w.href||n.startsWith(`${w.href}/`);return t.jsxs(d,{href:w.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${g?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:w.icon??t.jsx(H.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:w.label})]},w.href)})})]},p))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(Qo,{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})]})]}),f&&t.jsxs(Ke,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:f,children:[t.jsx(H.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 Wi="bonsaif-ui:prime-auth-sso",Uh={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"},Ro={dashboard:t.jsx(H.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(H.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(H.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(H.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(H.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(H.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(H.HiUser,{className:"h-5 w-5"}),settings:t.jsx(H.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(H.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(H.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(H.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(H.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(H.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(H.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(H.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(H.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(H.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(H.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(H.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(H.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(H.HiShieldCheck,{className:"h-5 w-5"})};function Vh(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Xh(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Yh(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=Xh(n)&&a?a:n,l=Uh[o]??Vh(o);return[{label:"Inicio",href:"/"},{label:l}]}function es(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Gh(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(H.HiHome,{className:"h-5 w-5"});if(Ro[n])return Ro[n];const a=r.length>1?r[r.length-2]:"";return Ro[a]??t.jsx(H.HiHome,{className:"h-5 w-5"})}function Kh(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function ji(){if(typeof window>"u")return!1;if(Kh(window.location.href)){try{window.sessionStorage.setItem(Wi,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Wi)==="true"}catch{return!1}}function Zh({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:f,showBreadcrumbs:d=!0,contained:h=!1}){const b=s.useRef(null),[u,p]=s.useState(!1),[v,w]=s.useState(f??"/"),[g,E]=s.useState(()=>ji()),[y,M]=s.useState(null),L=f??v,C=c??Yh(L),m=o??Gh(L),k=d&&!g&&C.length>1,N=!k;s.useEffect(()=>{f||w(window.location.pathname)},[f]),s.useEffect(()=>{E(ji())},[]),s.useEffect(()=>{if(h){p(!1);return}let q=null,K=0,$=0;const Q=()=>{const J=b.current,fe=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??es(fe)??fe??window},X=()=>{const J=q&&q!==window?q.scrollTop:window.scrollY;p(fe=>fe?J>24:J>72)},se=()=>{q==null||q.removeEventListener("scroll",X),q=Q(),q.addEventListener("scroll",X,{passive:!0}),X()};return se(),K=window.requestAnimationFrame(se),$=window.setTimeout(se,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout($),q==null||q.removeEventListener("scroll",X)}},[h]),s.useEffect(()=>{if(h){M(null);return}let q=0;const K=[],$=()=>{const z=b.current,R=z==null?void 0:z.parentElement,A=document.querySelector("[data-app-scroll='true']"),F=es(A)??A;if(!z||!R||!F){M(null);return}const ue=R.getBoundingClientRect(),P=window.getComputedStyle(R),oe=F.getBoundingClientRect(),j=F instanceof HTMLElement&&F.clientWidth>0?F.clientWidth:oe.width,S=ue.left+parseFloat(P.paddingLeft||"0"),U={marginLeft:Math.round(oe.left-S),width:Math.round(j)};M(T=>T&&T.marginLeft===U.marginLeft&&T.width===U.width?T:U)},Q=()=>{window.cancelAnimationFrame(q),q=window.requestAnimationFrame($)};Q(),window.addEventListener("resize",Q);const X=new ResizeObserver(Q),se=b.current,J=se==null?void 0:se.parentElement,fe=document.querySelector("[data-app-scroll='true']"),te=es(fe)??fe;return[J,fe,te].forEach(z=>{z&&X.observe(z)}),K.push(window.setTimeout(Q,120)),K.push(window.setTimeout(Q,280)),()=>{window.cancelAnimationFrame(q),window.removeEventListener("resize",Q),X.disconnect(),K.forEach(z=>window.clearTimeout(z))}},[h]);const _={...y?{marginLeft:y.marginLeft,width:y.width}:null,"--page-header-control-height":u?"34px":"40px","--page-header-control-padding-x":u?"10px":"14px","--page-header-control-icon-left":u?"10px":"12px",background:h?"var(--bg-card)":u?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:h||u?"1px solid var(--border)":"1px solid transparent",boxShadow:u?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":u?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:_,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${u?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":N?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${u||N?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${u||N?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${u?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:k?"var(--text-secondary)":"var(--text-muted)"},children:m}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${u?"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 ${u?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":u,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${u?"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 ${u?"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 ${u?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(ks.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Qh({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(zi,{currentPath:r,...a,children:e})}function qi(){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 Jh(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 Rh({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(qi());const f=new MutationObserver(()=>o(qi()));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>f.disconnect()},[]);const i=s.useMemo(()=>Jh(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 f=n;function d(h){var p,v,w;if(h.source!==((p=l.current)==null?void 0:p.contentWindow)||c&&h.origin!==c)return;if(((v=h.data)==null?void 0:v.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((w=h.data)==null?void 0:w.type)!=="prime-microservice:navigation")return;const b=h.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const u=`/apps/${encodeURIComponent(f)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==u&&(window.history.replaceState(window.history.state,"",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",d),()=>{window.removeEventListener("message",d),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 ep(){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 d;if(((d=c.data)==null?void 0:d.type)!=="prime-suite-chat:state")return;const f=!!c.data.active;a(f),l({width:Ui(c.data.width,96,720),height:Ui(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 Ui(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function tp(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 rp(){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 np(){return"light"}function ap({position:e="bottom-center"}){const r=s.useSyncExternalStore(tp,rp,np);return t.jsx(Ya.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function op({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 Sn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Vi(e,r){return e.color??Sn[r%Sn.length]}function Kt(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 Lt=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 Yr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const ts={warning:70,danger:90};function ma(e,r=ts){const n=r.warning??ts.warning,a=r.danger??ts.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function Cn(e,r){return Kt(ma(e,r))}function Gr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Kr(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 Xi(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 f=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${f.replace(/\.0$/,"")} ${l[c]}`}function Zr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Yr((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function At({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 $t({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 fr=680,wr="ease-out",sp={top:18,right:8,bottom:12,left:0};function En(e){return{...sp,...e}}function Mn(e){return e.map((r,n)=>({...r,color:Vi(r,n),label:r.label??r.key}))}function ga(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Yr(n[a.key])===null))}function Dt(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Tn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Yi(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function va(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function lp(e,r=Lt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function Gi(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function ip({active:e,label:r,payload:n,valueFormat:a=Lt}){var c,f,d,h,b,u;if(!e||!(n!=null&&n.length))return null;const o=n.filter(p=>p.dataKey!=="base"&&p.name!=="base"&&p.value!==null&&p.value!==void 0);if(!o.length)return null;const l=((f=(c=o[0])==null?void 0:c.payload)==null?void 0:f.fullName)??((h=(d=o[0])==null?void 0:d.payload)==null?void 0:h.tooltipLabel)??((u=(b=o[0])==null?void 0:b.payload)==null?void 0:u.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((p,v)=>{const w=p.payload,g=w&&typeof w.display=="number"?w.display:p.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:p.color??"var(--primary)"}}),p.name??p.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:lp(g,a)})]},String(p.dataKey??p.name??v))})})]})}function Qr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Ie.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(ip,{valueFormat:e})})}function Ki(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Zi(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 xa(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,f]=s.useState(null),[d,h]=s.useState(null),b=!!a&&e.length>1,u=b&&(o==="brush"||o==="both"),p=b&&(o==="drag"||o==="both"),v=s.useCallback(K=>{f(K),i==null||i(K)},[i]),w=s.useCallback(()=>{h(null),v(null)},[v]),g=!!c,E=s.useMemo(()=>!c||u?e:e.slice(c.startIndex,c.endIndex+1),[e,u,c]),y=s.useCallback((K,$)=>{const Q=Ki(e,r,K),X=Ki(e,r,$);Q<0||X<0||v(Zi(Q,X,e.length))},[v,e,r]),M=s.useCallback(K=>{p&&((K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||h({leftLabel:K.activeLabel,rightLabel:K.activeLabel}))},[p]),L=s.useCallback(K=>{!p||!d||(K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||h($=>$&&{...$,rightLabel:K.activeLabel})},[d,p]),C=s.useCallback(()=>{if(p){if(!d||d.rightLabel===null||d.rightLabel===void 0){h(null);return}y(d.leftLabel,d.rightLabel),h(null)}},[y,d,p]),m=s.useCallback(K=>{if(u){if(!K){v(null);return}v(Zi(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[v,e.length,u]),k=p?{onMouseDown:M,onMouseMove:L,onMouseUp:C,onMouseLeave:()=>{d&&C()}}:{},N=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},_=t.jsxs(t.Fragment,{children:[p&&d&&d.rightLabel!==null&&d.rightLabel!==void 0?t.jsx(Ie.ReferenceArea,{x1:d.leftLabel,x2:d.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,u?t.jsx(Ie.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:N.startIndex,endIndex:N.endIndex,onChange:m,tickFormatter:K=>String(K)}):null]}),q=u?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:u,showDrag:p,viewData:E,isZoomed:g,resetZoom:w,chartHandlers:k,zoomNodes:_,marginExtra:q}}function ya({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function cp({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,yDomain:u,ariaLabel:p="Gráfico de líneas",curve:v=!0,strokeWidth:w=2.25,zoomable:g=!1,zoomMode:E="both",brushHeight:y,onZoomChange:M}){const L=ga(e,n),C=Mn(n),m=xa(e,r,{zoomable:g,zoomMode:E,brushHeight:y,onZoomChange:M}),k=En({...h,...m.marginExtra});return l?t.jsx(At,{height:a}):L?t.jsx($t,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ya,{visible:m.isZoomed,onReset:m.resetZoom}),t.jsx(Ie.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ie.LineChart,{data:m.viewData,margin:k,...m.chartHandlers,children:[c?t.jsx(Ie.CartesianGrid,{strokeDasharray:"2 8",stroke:Tn(),vertical:!1}):null,t.jsx(Ie.XAxis,{dataKey:r,tick:Dt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ie.YAxis,{tick:Dt(),tickLine:!1,axisLine:!1,width:44,domain:u??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),d?t.jsx(Qr,{valueFormat:b,cursor:{stroke:Yi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,f?t.jsx(Ie.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:va()}):null,C.map((N,_)=>t.jsx(Ie.Line,{type:v?"monotone":"linear",dataKey:N.key,name:N.label,stroke:N.color,strokeWidth:_===0?w+.35:w,strokeOpacity:_===0?1:.88,isAnimationActive:!0,animationDuration:fr,animationEasing:wr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),m.zoomNodes]})})]})}function wa({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,yDomain:u,ariaLabel:p="Gráfico de área",stacked:v=!1,opacity:w=.22,zoomable:g=!1,zoomMode:E="both",brushHeight:y,onZoomChange:M}){const L=ga(e,n),C=Mn(n),m=xa(e,r,{zoomable:g,zoomMode:E,brushHeight:y,onZoomChange:M}),k=En({...h,...m.marginExtra});return l?t.jsx(At,{height:a}):L?t.jsx($t,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ya,{visible:m.isZoomed,onReset:m.resetZoom}),t.jsx(Ie.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ie.AreaChart,{data:m.viewData,margin:k,...m.chartHandlers,children:[t.jsx("defs",{children:C.map(N=>t.jsxs("linearGradient",{id:Gi(N.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:N.color,stopOpacity:Math.min(.55,w+.28)}),t.jsx("stop",{offset:"48%",stopColor:N.color,stopOpacity:w*.5}),t.jsx("stop",{offset:"100%",stopColor:N.color,stopOpacity:0})]},N.key))}),c?t.jsx(Ie.CartesianGrid,{strokeDasharray:"2 8",stroke:Tn(),vertical:!1}):null,t.jsx(Ie.XAxis,{dataKey:r,tick:Dt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ie.YAxis,{tick:Dt(),tickLine:!1,axisLine:!1,width:44,domain:u??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),d?t.jsx(Qr,{valueFormat:b,cursor:{stroke:Yi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,f?t.jsx(Ie.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:va()}):null,C.map(N=>t.jsx(Ie.Area,{type:"monotone",dataKey:N.key,name:N.label,stroke:N.color,fill:`url(#${Gi(N.key)})`,strokeWidth:2.25,stackId:v?"stack":void 0,isAnimationActive:!0,animationDuration:fr,animationEasing:wr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),m.zoomNodes]})})]})}function dp({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,yDomain:u,ariaLabel:p="Gráfico de barras",layout:v="vertical",mode:w="grouped",barRadius:g=6,categoryAxisWidth:E=64,zoomable:y=!1,zoomMode:M="both",brushHeight:L,onZoomChange:C}){const m=ga(e,n),k=Mn(n),N=v==="horizontal",_=xa(e,r,{zoomable:y&&!N,zoomMode:M,brushHeight:L,onZoomChange:C}),q=En({...h,..._.marginExtra});return l?t.jsx(At,{height:a}):m?t.jsx($t,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ya,{visible:_.isZoomed,onReset:_.resetZoom}),t.jsx(Ie.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ie.BarChart,{data:_.viewData,margin:q,layout:N?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,..._.chartHandlers,children:[c?t.jsx(Ie.CartesianGrid,{strokeDasharray:"2 8",stroke:Tn(),horizontal:!N,vertical:N}):null,N?t.jsxs(t.Fragment,{children:[t.jsx(Ie.XAxis,{type:"number",tick:Dt(),tickLine:!1,axisLine:!1,tickFormatter:K=>b(Number(K)),domain:u??["auto","auto"]}),t.jsx(Ie.YAxis,{type:"category",dataKey:r,tick:Dt(),tickLine:!1,axisLine:!1,width:E})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ie.XAxis,{dataKey:r,tick:Dt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ie.YAxis,{tick:Dt(),tickLine:!1,axisLine:!1,width:44,domain:u??["auto","auto"],tickFormatter:K=>b(Number(K)),dx:-2})]}),d?t.jsx(Qr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,f?t.jsx(Ie.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:va()}):null,k.map((K,$)=>t.jsx(Ie.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:$===0?1:.82,radius:N?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:w==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:fr,animationEasing:wr},K.key)),_.zoomNodes]})})]})}function up(e){return t.jsx(Ji,{...e,variant:"pie"})}function fp(e){return t.jsx(Ji,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Qi(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Ji({data:e,nameKey:r,valueKey:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:f=!0,valueFormat:d=Lt,ariaLabel:h,innerRadius:b,outerRadius:u,colors:p=[...Sn],padAngle:v,cornerRadius:w,variant:g}){const E=e.map(($,Q)=>({name:String($[r]??""),value:Yr($[n])??0,fill:p[Q%p.length],row:$})).filter($=>$.value>0),y=!E.length,M=g==="donut",L=E.length,C=Qi(b,M?62:12),m=Qi(u,78),k=Math.min(v??(M?2:3),Math.max(.5,10/Math.max(1,L))),N=Math.min(w??(M?10:8),Math.max(2,36/Math.max(1,L)));if(l)return t.jsx(At,{height:a});if(y)return t.jsx($t,{height:a,text:i});const _=E.reduce(($,Q)=>$+Q.value,0),q=c?Math.min(96,28+Math.ceil(L/3)*22):0,K=Math.max(140,a-q);return t.jsx("div",{className:`bonsaif-chart bonsaif-${g}-chart w-full ${o}`,role:"img","aria-label":h??(g==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:K},children:t.jsx(Ie.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ie.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[f?t.jsx(Qr,{valueFormat:d,isAnimationActive:!1}):null,t.jsx(Ie.Pie,{data:E,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${C}%`,outerRadius:`${m}%`,startAngle:90,endAngle:-270,paddingAngle:k,cornerRadius:N,minAngle:L>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:fr,animationEasing:wr,label:!1,activeShape:bp,children:E.map($=>t.jsx(Ie.Cell,{fill:$.fill},$.name))}),M?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:d(_)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:E.map($=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:$.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:$.name,children:$.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:d($.value)})]},$.name))}):null]})})}function bp(e){const{outerRadius:r=0,...n}=e;return t.jsx(Ie.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function hp({data:e,dataKey:r,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:f="Sparkline"}){const d=l??Kt(o),h=e.map(m=>Yr(m[r])).filter(m=>m!==null);if(h.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":f});const b=120,u=36,p=3,v=1,w=Math.min(...h),E=Math.max(...h)-w||1,y=h.map((m,k)=>{const N=v+k/(h.length-1)*(b-v*2),_=u-p-(m-w)/E*(u-p*2);return{x:N,y:_}}),M=y.map((m,k)=>`${k===0?"M":"L"}${m.x.toFixed(2)} ${m.y.toFixed(2)}`).join(" "),L=`${M} L${y[y.length-1].x.toFixed(2)} ${u} L${y[0].x.toFixed(2)} ${u} Z`,C=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":f,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${u}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:C,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:d,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:d,stopOpacity:0})]})}):null,i?t.jsx("path",{d:L,fill:`url(#${C})`}):null,t.jsx("path",{d:M,fill:"none",stroke:d,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function pp({data:e,xKey:r,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:f="Sin datos para mostrar",showGrid:d=!0,showLegend:h=!0,showTooltip:b=!0,margin:u,valueFormat:p=Lt,yDomain:v,ariaLabel:w="Gráfico combinado",barRadius:g=6,zoomable:E=!1,zoomMode:y="both",brushHeight:M,onZoomChange:L}){const C=a??n.slice(0,Math.max(1,n.length-1)),m=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),k=[...C,...m.filter(X=>!C.some(se=>se.key===X.key))],N=ga(e,k),_=Mn(C),q=Mn(k),K=m.map(X=>{var J;const se=q.find(fe=>fe.key===X.key);return{...X,label:X.label??X.key,color:X.color??(se==null?void 0:se.color)??((J=q[0])==null?void 0:J.color)}}),$=xa(e,r,{zoomable:E,zoomMode:y,brushHeight:M,onZoomChange:L}),Q=En({...u,...$.marginExtra});return c?t.jsx(At,{height:l}):N?t.jsx($t,{height:l,text:f}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":w,style:{height:l},children:[t.jsx(ya,{visible:$.isZoomed,onReset:$.resetZoom}),t.jsx(Ie.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ie.ComposedChart,{data:$.viewData,margin:Q,barCategoryGap:"34%",...$.chartHandlers,children:[d?t.jsx(Ie.CartesianGrid,{strokeDasharray:"2 8",stroke:Tn(),vertical:!1}):null,t.jsx(Ie.XAxis,{dataKey:r,tick:Dt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ie.YAxis,{tick:Dt(),tickLine:!1,axisLine:!1,width:44,domain:v??["auto","auto"],tickFormatter:X=>p(Number(X)),dx:-2}),b?t.jsx(Qr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,h?t.jsx(Ie.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:va()}):null,_.map(X=>t.jsx(Ie.Bar,{dataKey:X.key,name:X.label,fill:X.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:fr,animationEasing:wr},X.key)),K.map(X=>t.jsx(Ie.Line,{type:"monotone",dataKey:X.key,name:X.label,stroke:X.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:fr,animationEasing:wr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:X.color}},X.key)),$.zoomNodes]})})]})}function mp({data:e,xKey:r,valueKey:n,typeKey:a,height:o=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,ariaLabel:u="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:v="#f87171",totalColor:w="var(--primary)"}){const g=s.useMemo(()=>gp(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:v,totalColor:w}),[e,r,n,a,p,v,w]),E=!g.length,y=En(h);return i?t.jsx(At,{height:o}):E?t.jsx($t,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":u,style:{height:o},children:t.jsx(Ie.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ie.BarChart,{data:g,margin:y,barCategoryGap:"42%",children:[f?t.jsx(Ie.CartesianGrid,{strokeDasharray:"2 8",stroke:Tn(),vertical:!1}):null,t.jsx(Ie.XAxis,{dataKey:"label",tick:Dt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Ie.YAxis,{tick:Dt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:M=>b(Number(M)),dx:-2}),d?t.jsx(Qr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Ie.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Ie.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:fr,animationEasing:wr,children:g.map(M=>t.jsx(Ie.Cell,{fill:M.color},M.label))})]})})})}function gp(e,r){let n=0;return e.map((a,o)=>{const l=Yr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let f="increase",d=0,h=0,b=l;return c&&i==="total"?(f="total",d=0,h=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(f="total",d=0,h=Math.abs(n),b=n):(f=i==="decrease"||l<0?"decrease":"increase",f==="decrease"?(d=n+l,h=Math.abs(l),n=n+l):(d=n,h=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:d,delta:h,display:b,kind:f,color:f==="total"?r.totalColor:f==="decrease"?r.decreaseColor:r.increaseColor}})}const Ri="bonsaif-funnel-chart-keyframes",vp=`
|
|
59
|
+
`}),L.map(X=>{const G=Th(X.colorIndex);return S===X.id?t.jsx("input",{ref:ee,value:_,disabled:o,onChange:I=>U(I.target.value),onKeyDown:I=>q(I,X.id),onBlur:()=>ue(X.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`}},X.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:G.bg,color:G.text,border:`1px solid ${G.border}`},children:[t.jsx("span",{className:"truncate",children:X.value}),t.jsx("button",{type:"button","aria-label":`Editar "${X.value}"`,disabled:o,tabIndex:-1,onClick:I=>{I.stopPropagation(),z(X)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(F.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${X.value}"`,disabled:o,tabIndex:-1,onClick:I=>{I.stopPropagation(),P(X.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(F.HiXMark,{className:"h-3.5 w-3.5"})})]},X.id)}),!ce&&t.jsx("input",{ref:ne,value:C,disabled:o,placeholder:L.length===0?a:"",onChange:X=>m(X.target.value),onKeyDown:se,onPaste:V,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(zr,{error:p,helperText:b,helperDisplay:u})]})}const Ih=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function ct(e){return String(e).padStart(2,"0")}function Ro(e,r=Yr()){const n=e.trim();if(!n)return r;const a=n.match(Ih);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 Sn(e,r=!0){const n=`${ct(e.hour24)}:${ct(e.minute)}`;return r?`${n}:${ct(e.second)}`:n}function ya(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 Cn(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 Fh(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=Ro(e);if(n){const l=ya(o),i=`${l.hour12}:${ct(l.minute)}`;return`${a?`${i}:${ct(l.second)}`:i} ${l.meridiem}`}return Sn(o,a)}function Yr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function Oh(e=!0){return Sn(Yr(),e)}function es(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const At=36,ts=5,ac=Math.floor(ts/2),Hh=52,Bh=48,rr=18;function oc(e){return e*At}function sc(e){return Math.round(e/At)}function Ph(e){return e.use12Hour??e.hour12??!1}function wa({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=Hh,label:i,maxNumeric:c=59,isMeridiem:f=!1,isFocused:d=!1,onFocus:h,onAdvance:b,onBack:u,setColumnRef:p}){const g=s.useRef(null),w=s.useRef(null),v=s.useRef(null),E=s.useRef(""),y=s.useRef(0),T=s.useRef(!1),[L,C]=s.useState(r),[m,S]=s.useState(""),N=s.useCallback(z=>{E.current=z,S(z)},[]),_=s.useMemo(()=>[...Array(ac).fill(""),...e,...Array(ac).fill("")],[e]),U=s.useCallback(()=>{const z=g.current;if(!z)return r;const se=sc(z.scrollTop),q=Math.min(Math.max(se,0),e.length-1);return e[q]??r},[r,e]),K=s.useCallback((z,se=!0)=>{const q=Math.min(Math.max(z,0),e.length-1),k=e[q],V=g.current;!V||!k||(w.current&&(window.clearTimeout(w.current),w.current=null),T.current=!0,y.current=q,V.scrollTop=oc(q),C(k),se&&k!==r&&n(k))},[n,r,e]);s.useLayoutEffect(()=>{w.current&&(window.clearTimeout(w.current),w.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),N(""),C(r);const z=e.indexOf(r);if(z>=0&&(y.current=z),z<0||!g.current)return;const se=oc(z);g.current.scrollTop!==se&&(g.current.scrollTop=se)},[o,r,N,e]);const D=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),Z=s.useCallback((z,se=!1)=>{D(),N("");const q=Number(z);if(!Number.isFinite(q))return;const k=Math.min(c,Math.max(0,q));let V=ct(k),M=e.indexOf(V);if(M<0){const Y=Math.min(e.length-1,Math.max(0,k-(c===12?1:0)));V=e[Y]??V,M=e.indexOf(V)}M>=0&&K(M),se&&(b==null||b())},[D,c,b,K,N,e]),O=s.useCallback(z=>{const se=Math.floor(c/10),q=E.current;if(q===""){if(z>se){Z(String(z),!0);return}const V=String(z);N(V),v.current=window.setTimeout(()=>{Z(E.current,!0)},1200);return}D();const k=+`${q}${z}`;k<=c?Z(String(k),!0):Z(String(z),!0)},[D,Z,c,N]),ne=s.useCallback(z=>{D(),N(""),K(y.current+z)},[D,K,N]),ee=z=>{if(f){z.key==="a"||z.key==="A"?(z.preventDefault(),n("AM"),b==null||b()):z.key==="p"||z.key==="P"?(z.preventDefault(),n("PM"),b==null||b()):z.key==="ArrowUp"||z.key==="ArrowDown"?(z.preventDefault(),n(r==="AM"?"PM":"AM")):z.key==="Tab"&&(z.preventDefault(),z.shiftKey?u==null||u():b==null||b());return}if(/^\d$/.test(z.key)){z.preventDefault(),O(Number(z.key));return}z.key==="ArrowUp"?(z.preventDefault(),ne(-1)):z.key==="ArrowDown"?(z.preventDefault(),ne(1)):z.key==="Tab"&&(z.preventDefault(),D(),E.current!==""&&Z(E.current,!1),z.shiftKey?u==null||u():b==null||b())},fe=s.useCallback(()=>{const z=a.current,se=g.current;se&&z===a.current&&K(sc(se.scrollTop))},[K,a]),J=()=>{if(E.current!=="")return;if(T.current){T.current=!1;const se=U();C(se);const q=e.indexOf(se);q>=0&&(y.current=q);return}C(U()),w.current&&window.clearTimeout(w.current);const z=a.current;w.current=window.setTimeout(()=>{z===a.current&&fe()},100)},W="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",R=At*ts,$=R+rr*2,P=m!==""?m:null,ue=P!==null;return t.jsxs("div",{ref:p,role:"spinbutton",tabIndex:d?0:-1,"aria-label":i,"aria-valuetext":P??r,"aria-valuenow":f?void 0:Number(r),onFocus:h,onMouseDown:()=>h==null?void 0:h(),onKeyDown:ee,onBlur:()=>{D(),E.current!==""&&Z(E.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:$,boxShadow:d?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:W,style:{top:0,height:rr,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:t.jsx(F.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:g,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:rr,height:R,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:J,onMouseUp:fe,onTouchEnd:fe,children:_.map((z,se)=>{const q=z!==""&&z===L;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!z,onClick:()=>{if(!z)return;const k=e.indexOf(z);k>=0&&K(k)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:At,scrollSnapAlign:"center",color:q?"var(--text-main)":"var(--text-muted)",fontSize:q?16:14,fontWeight:q?600:400,opacity:z?ue?q?0:.35:q?1:.35:0},children:z},`wheel-${se}-${z}`)})}),P!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:rr+R/2-At/2,height:At,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:P}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:W,style:{bottom:0,height:rr,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:t.jsx(F.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function lc(){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:At,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function ic({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:f,className:d=""}){const h=i==="popover",b=h||!f,u=Ph({use12Hour:n,hour12:a}),p=s.useRef(e),g=Ro(e,Yr()),w=ya(g),[v,E]=s.useState(ct(u?w.hour12:g.hour24)),[y,T]=s.useState(ct(g.minute)),[L,C]=s.useState(ct(g.second)),[m,S]=s.useState(w.meridiem),[N,_]=s.useState(0),U=s.useRef(0),K=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[Z,O]=s.useState("hour"),ne=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),u&&ie.push("meridiem"),ie},[u,o]),ee=s.useCallback(ie=>{O(ge=>{const $e=ne.indexOf(ge);return ne[($e+ie+ne.length)%ne.length]})},[ne]);s.useEffect(()=>{var ie;(ie=D.current[Z])==null||ie.focus()},[Z]),s.useEffect(()=>{var ie;O("hour"),(ie=D.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const ie=Ro(e,Yr()),ge=ya(ie);E(ct(u?ge.hour12:ie.hour24)),T(ct(ie.minute)),C(ct(ie.second)),S(ge.meridiem)},[u,e]);const fe=s.useMemo(()=>(u?es(1,12):es(0,23)).map(ie=>ct(ie)),[u]),J=s.useMemo(()=>es(0,59).map(ie=>ct(ie)),[]),W=J,R=s.useMemo(()=>["AM","PM"],[]),$=s.useCallback(()=>u?Cn({hour12:Number(v),minute:Number(y),second:Number(L),meridiem:m}):{hour24:Number(v),minute:Number(y),second:Number(L)},[v,u,m,y,L]),P=s.useCallback(ie=>{if(K.current)return;const ge=Sn(ie,o);p.current=ge,r(ge)},[r,o]),ue=s.useCallback(()=>{P($())},[$,P]),z=ie=>{E(ie),b&&P(u?Cn({hour12:Number(ie),minute:Number(y),second:Number(L),meridiem:m}):{hour24:Number(ie),minute:Number(y),second:Number(L)})},se=ie=>{T(ie),b&&P(u?Cn({hour12:Number(v),minute:Number(ie),second:Number(L),meridiem:m}):{hour24:Number(v),minute:Number(ie),second:Number(L)})},q=ie=>{C(ie),b&&P(u?Cn({hour12:Number(v),minute:Number(y),second:Number(ie),meridiem:m}):{hour24:Number(v),minute:Number(y),second:Number(ie)})},k=ie=>{S(ie),b&&P(Cn({hour12:Number(v),minute:Number(y),second:Number(L),meridiem:ie}))},V=s.useCallback(()=>(U.current+=1,_(U.current),U.current),[]),M=s.useCallback(ie=>{const ge=ya(ie),$e=Sn(ie,o);p.current=$e,E(ct(u?ge.hour12:ie.hour24)),T(ct(ie.minute)),C(ct(ie.second)),S(ge.meridiem),r($e)},[u,r,o]),Y=()=>{K.current=!0,V(),M(Yr()),queueMicrotask(()=>{const ie=Yr();Sn(ie,o)!==p.current&&(V(),M(ie)),K.current=!1})},ce=()=>{ue(),f==null||f()},X=At*ts,G=X+rr*2,I=rr+X/2-At/2,le=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:G,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:I,height:At,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:rr,height:At*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:rr,height:At*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(wa,{syncEpochRef:U,forceSyncAt:N,values:fe,selected:v,onSelect:z,label:"Horas",maxNumeric:u?12:23,isFocused:Z==="hour",onFocus:()=>O("hour"),onAdvance:()=>ee(1),onBack:()=>ee(-1),setColumnRef:ie=>{D.current.hour=ie}}),t.jsx(lc,{}),t.jsx(wa,{syncEpochRef:U,forceSyncAt:N,values:J,selected:y,onSelect:se,label:"Minutos",maxNumeric:59,isFocused:Z==="minute",onFocus:()=>O("minute"),onAdvance:()=>ee(1),onBack:()=>ee(-1),setColumnRef:ie=>{D.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(lc,{}),t.jsx(wa,{syncEpochRef:U,forceSyncAt:N,values:W,selected:L,onSelect:q,label:"Segundos",maxNumeric:59,isFocused:Z==="second",onFocus:()=>O("second"),onAdvance:()=>ee(1),onBack:()=>ee(-1),setColumnRef:ie=>{D.current.second=ie}})]}):null,u?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(wa,{syncEpochRef:U,forceSyncAt:N,values:R,selected:m,onSelect:ie=>k(ie),width:Bh,label:"AM o PM",isMeridiem:!0,isFocused:Z==="meridiem",onFocus:()=>O("meridiem"),onAdvance:()=>ee(1),onBack:()=>ee(-1),setColumnRef:ie=>{D.current.meridiem=ie}})}):null]})]})}),be=t.jsxs("div",{className:`flex items-center ${h?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:h?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ke,{variant:"ghost",size:"sm",onClick:Y,className:h?"text-xs":void 0,children:"Ahora"}),!h&&(c||f)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ke,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,f?t.jsx(Ke,{variant:"primary",size:"sm",onClick:ce,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${d}`,style:{borderRadius:h?12:14,border:h?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:h?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:u?o?300:260:o?252:212},children:[!h&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,le,be]})}function _h(e){return e.use12Hour??e.hour12??!1}function zh({label:e,value:r,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:f=!1,displayMode:d="popover",required:h,error:b,helperText:u,helperDisplay:p,className:g,contentClassName:w,className:v=""}){const E=d==="popover",[y,T]=s.useState(!1),L=s.useRef(null),[C,m]=s.useState({horizontal:"left",vertical:"bottom"}),S=_h({use12Hour:a,hour12:o}),N=s.useMemo(()=>r?Fh(r,{use12Hour:S,showSeconds:l}):"",[S,l,r]);s.useEffect(()=>{if(!E||!y||!L.current)return;const K=L.current.getBoundingClientRect(),D=8,Z=S?l?300:260:l?252:212,O=276,ne=K.left+Z>window.innerWidth-D,ee=K.right-Z>=D,fe=K.bottom+8+O>window.innerHeight-D,J=K.top-8-O>=D;m({horizontal:ne&&ee?"right":"left",vertical:fe&&J?"top":"bottom"})},[S,E,y,l]),s.useEffect(()=>{if(!E||!y)return;function K(Z){L.current&&(L.current.contains(Z.target)||T(!1))}function D(Z){Z.key==="Escape"&&T(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",D)}},[E,y]);const _=t.jsxs("button",{type:"button",disabled:f,onClick:()=>{f||T(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)":y?"var(--primary)":"var(--border)",color:N?"var(--text-main)":"var(--text-muted)",boxShadow:y?"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(F.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:N||c})]}),E?t.jsx(F.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${y?"rotate-180":""}`}):null]}),U=t.jsx(ic,{variant:E?"popover":"panel",value:r||Oh(l),onChange:n,use12Hour:S,showSeconds:l,title:i,onClose:()=>T(!1)});return t.jsx(sa,{label:e,required:h,error:b,helperText:u,helperDisplay:p,className:g,contentClassName:w,children:E?t.jsxs("div",{ref:L,className:"relative w-full",children:[_,y?t.jsx("div",{className:"absolute z-50",style:{...C.horizontal==="left"?{left:0}:{right:0},...C.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:U}):null]}):t.jsxs("div",{className:"space-y-2",children:[_,y?U:null]})})}function Wh(e,r){return e.icon?e.icon:e.kind==="folder"?r?t.jsx(F.HiFolderOpen,{className:"h-4 w-4"}):t.jsx(F.HiFolder,{className:"h-4 w-4"}):e.kind==="file"?t.jsx(F.HiDocument,{className:"h-4 w-4"}):e.kind==="group"?t.jsx(F.HiUserGroup,{className:"h-4 w-4"}):e.kind==="person"?t.jsx(F.HiUser,{className:"h-4 w-4"}):null}function jh(e){return e.searchText?e.searchText:typeof e.label=="string"||typeof e.label=="number"?String(e.label):e.id}function qh(e){const r=[],n=a=>{var o;for(const l of a)(o=l.children)!=null&&o.length&&(r.push(l.id),n(l.children))};return n(e),r}function Uh(e,r){const n=r.trim().toLowerCase();if(!n)return{nodes:e,expandIds:[]};const a=[],o=l=>{const i=[];for(const c of l){const f=c.children?o(c.children):[];(jh(c).toLowerCase().includes(n)||f.length>0)&&(f.length>0&&a.push(c.id),i.push(f.length>0?{...c,children:f}:c))}return i};return{nodes:o(e),expandIds:a}}function cc(e,r,n=0,a=null){var l;const o=[];for(const i of e){const c=!!((l=i.children)!=null&&l.length);o.push({node:i,depth:n,parentId:a,hasChildren:c}),c&&r.has(i.id)&&o.push(...cc(i.children,r,n+1,i.id))}return o}function Vh({nodes:e,selectedId:r,defaultSelectedId:n=null,onSelect:a,expandedIds:o,defaultExpandedIds:l,onExpandedChange:i,defaultExpandAll:c=!1,searchable:f=!1,searchPlaceholder:d="Buscar...",emptyLabel:h="Sin elementos",noResultsLabel:b="Sin resultados",className:u,size:p="md",ariaLabel:g="Lista de arbol"}){const w=s.useId(),v=s.useRef(null),[E,y]=s.useState(""),[T,L]=s.useState(n),[C,m]=s.useState(()=>l??(c?qh(e):[])),[S,N]=s.useState(null),_=s.useRef(new Map),[U,K]=s.useState(()=>new Set);s.useEffect(()=>()=>{_.current.forEach(k=>window.clearTimeout(k))},[]);const D=r!==void 0?r:T,Z=o??C,O=s.useMemo(()=>new Set(Z),[Z]),ne=s.useMemo(()=>Uh(e,E),[e,E]),ee=E.trim().length>0,fe=s.useMemo(()=>ee?new Set([...O,...ne.expandIds]):O,[O,ne.expandIds,ee]),J=s.useMemo(()=>cc(ne.nodes,fe),[ne.nodes,fe]);s.useEffect(()=>{!S&&J[0]&&N(J[0].node.id)},[S,J]);function W(k){o===void 0&&m(k),i==null||i(k)}function R(k){K(M=>{const Y=new Set(M);return Y.add(k),Y});const V=_.current.get(k);V&&window.clearTimeout(V),_.current.set(k,window.setTimeout(()=>{K(M=>{if(!M.has(k))return M;const Y=new Set(M);return Y.delete(k),Y})},240))}function $(k){const V=new Set(Z);V.has(k)?V.delete(k):(V.add(k),R(k)),W([...V])}function P(k){k.disabled||(r===void 0&&L(k.id),a==null||a(k),N(k.id))}function ue(k){var Y,ce;if(J.length===0)return;const V=Math.max(0,J.findIndex(X=>X.node.id===S)),M=J[Math.min(J.length-1,Math.max(0,V+k))];M&&(N(M.node.id),(ce=(Y=v.current)==null?void 0:Y.querySelector(`[data-tree-id="${CSS.escape(M.node.id)}"]`))==null||ce.focus())}function z(k,V){var M,Y;k.key==="ArrowDown"?(k.preventDefault(),ue(1)):k.key==="ArrowUp"?(k.preventDefault(),ue(-1)):k.key==="ArrowRight"?(k.preventDefault(),V.hasChildren&&!fe.has(V.node.id)?$(V.node.id):ue(1)):k.key==="ArrowLeft"?(k.preventDefault(),V.hasChildren&&fe.has(V.node.id)?$(V.node.id):V.parentId&&(N(V.parentId),(Y=(M=v.current)==null?void 0:M.querySelector(`[data-tree-id="${CSS.escape(V.parentId)}"]`))==null||Y.focus())):(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),V.hasChildren&&k.key===" "?$(V.node.id):P(V.node))}const se=p==="sm"?"py-1.5":"py-2",q=p==="sm"?"text-xs":"text-sm";return t.jsxs("div",{className:Pe("overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)]",u),children:[f&&t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsx("label",{htmlFor:w,className:"sr-only",children:d}),t.jsxs("div",{className:"relative",children:[t.jsx(F.HiMagnifyingGlass,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--text-muted)]"}),t.jsx("input",{id:w,value:E,onChange:k=>y(k.target.value),placeholder:d,className:"h-9 w-full rounded-lg border border-[var(--border)] bg-[var(--bg-input)] pl-8 pr-3 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--primary)]/30"})]})]}),J.length===0?t.jsx("p",{className:"px-4 py-8 text-center text-sm text-[var(--text-muted)]",children:e.length===0?h:b}):t.jsx("div",{ref:v,role:"tree","aria-label":g,className:"max-h-[28rem] overflow-auto p-1.5",children:J.map((k,V)=>{const M=k.hasChildren&&fe.has(k.node.id),Y=D===k.node.id,ce=S===k.node.id,X=Wh(k.node,M),G=k.parentId!=null&&U.has(k.parentId),I=G?J.slice(0,V).filter(le=>le.parentId===k.parentId).length:0;return t.jsxs("div",{role:"treeitem","aria-expanded":k.hasChildren?M:void 0,"aria-selected":Y,"aria-disabled":k.node.disabled||void 0,"data-tree-id":k.node.id,tabIndex:ce||!S&&k===J[0]?0:-1,onKeyDown:le=>z(le,k),onFocus:()=>N(k.node.id),style:{paddingLeft:8+k.depth*16,animationDelay:G?`${Math.min(I,8)*28}ms`:void 0},className:Pe("group flex min-w-0 items-center gap-1 rounded-lg pr-2 outline-none transition-colors duration-150",G&&"bonsaif-rise",se,k.node.disabled?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-[var(--bg-hover)]",Y&&"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]","focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40"),onClick:()=>{(k.node.kind==="folder"||k.node.kind==="group")&&k.hasChildren&&$(k.node.id),P(k.node)},children:[k.hasChildren?t.jsx("button",{type:"button","aria-label":M?"Contraer":"Expandir",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] hover:bg-[var(--bg-secondary)] hover:text-[var(--text-main)]",onClick:le=>{le.stopPropagation(),$(k.node.id)},children:t.jsx(F.HiChevronRight,{className:Pe("h-3.5 w-3.5 transition-transform duration-200 ease-out",M&&"rotate-90")})}):t.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center",children:!X&&t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"})}),X&&t.jsx("span",{className:Pe("inline-flex h-5 w-5 shrink-0 items-center justify-center transition-transform duration-200",M&&k.node.kind==="folder"&&"scale-110",k.node.kind==="folder"?"text-[#d4a017]":k.node.kind==="group"?"text-[var(--primary)]":"text-[var(--text-muted)]"),children:X}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:Pe("block truncate font-medium text-[var(--text-main)]",q),children:k.node.label}),k.node.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:k.node.description})]}),k.node.badge&&t.jsx("span",{className:"shrink-0",children:k.node.badge}),k.node.trailing&&t.jsx("span",{className:"shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:k.node.trailing})]},k.node.id)})})]})}const rs={neutral:"var(--text-muted)",primary:"var(--primary)",success:"#059669",warning:"#d97706",danger:"var(--danger, #dc2626)",info:"#2563eb"};function Xh({items:e,className:r,ariaLabel:n="Historial"}){return t.jsx("ol",{className:Pe("m-0 list-none p-0",r),"aria-label":n,children:e.map((a,o)=>{const l=a.tone??"primary",i=o===e.length-1;return t.jsxs("li",{className:"bonsaif-rise relative flex gap-3 pb-5 last:pb-0",style:{animationDelay:`${Math.min(o,8)*40}ms`},children:[!i&&t.jsx("span",{"aria-hidden":!0,className:"absolute bottom-0 left-[11px] top-6 w-px bg-[var(--border)]"}),t.jsx("span",{className:"relative z-[1] mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border bg-[var(--bg-card)] text-[11px]",style:{borderColor:rs[l],color:rs[l]},children:a.icon??t.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:rs[l]}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("p",{className:"m-0 truncate text-sm font-semibold text-[var(--text-main)]",children:a.title}),a.time&&t.jsx("time",{className:"shrink-0 text-xs text-[var(--text-muted)]",children:a.time})]}),a.description&&t.jsx("p",{className:"m-0 mt-1 text-sm leading-5 text-[var(--text-muted)]",children:a.description})]})]},a.id)})})}const Yh={up:{color:"#059669",icon:t.jsx(F.HiArrowUp,{className:"h-3.5 w-3.5"})},down:{color:"#dc2626",icon:t.jsx(F.HiArrowDown,{className:"h-3.5 w-3.5"})},neutral:{color:"var(--text-muted)",icon:t.jsx(F.HiMinus,{className:"h-3.5 w-3.5"})}};function Gh({label:e,value:r,delta:n,deltaTone:a="neutral",hint:o,sparkline:l,className:i}){const c=Yh[a];return t.jsxs("article",{className:Pe("bonsaif-rise flex min-w-0 flex-col gap-3 rounded-xl border border-[var(--border)] bg-[var(--bg-card)] p-4",i),children:[t.jsx("p",{className:"m-0 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:e}),t.jsxs("div",{className:"flex items-end justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"m-0 truncate text-2xl font-semibold tracking-tight text-[var(--text-main)]",children:r}),(n||o)&&t.jsxs("p",{className:"m-0 mt-1 flex items-center gap-1.5 text-xs text-[var(--text-muted)]",children:[n&&t.jsxs("span",{className:"inline-flex items-center gap-0.5 font-semibold",style:{color:c.color},children:[c.icon,n]}),o&&t.jsx("span",{className:"truncate",children:o})]})]}),l&&t.jsx("div",{className:"w-24 shrink-0",children:l})]})]})}function Kh(e,r,n){return r==="bottom"?{top:e.bottom+8,left:e.left+e.width/2-n.width/2}:r==="left"?{top:e.top+e.height/2-n.height/2,left:e.left-n.width-8}:r==="right"?{top:e.top+e.height/2-n.height/2,left:e.right+8}:{top:e.top-n.height-8,left:e.left+e.width/2-n.width/2}}function dc({content:e,children:r,placement:n="top",delay:a=400,className:o}){const l=s.useId(),i=s.useRef(null),c=s.useRef(null),f=s.useRef(null),[d,h]=s.useState(!1),[b,u]=s.useState({top:0,left:0});function p(){f.current&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>h(!0),a)}function g(){f.current&&window.clearTimeout(f.current),h(!1)}s.useEffect(()=>{if(!d)return;const v=i.current,E=c.current;if(!v||!E)return;const y=Kh(v.getBoundingClientRect(),n,E.getBoundingClientRect()),T=Math.min(window.innerWidth-E.offsetWidth-8,Math.max(8,y.left)),L=Math.min(window.innerHeight-E.offsetHeight-8,Math.max(8,y.top));u({top:L,left:T})},[d,n,e]),s.useEffect(()=>()=>{f.current&&window.clearTimeout(f.current)},[]);const w={position:"fixed",top:b.top,left:b.left,zIndex:1e4};return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:i,className:"inline-flex",onMouseEnter:p,onMouseLeave:g,onFocus:p,onBlur:g,"aria-describedby":d?l:void 0,children:r}),d&&typeof document<"u"&&bt.createPortal(t.jsx("div",{ref:c,id:l,role:"tooltip",style:w,className:Pe("bonsaif-pop pointer-events-none max-w-xs rounded-md bg-[var(--text-main)] px-2 py-1 text-xs font-medium text-[var(--bg-card)] shadow-lg",o),children:e}),document.body)]})}function Zh({trigger:e,children:r,align:n="start",open:a,defaultOpen:o=!1,onOpenChange:l,width:i=280,className:c}){const[f,d]=s.useState(o),[h,b]=s.useState({}),u=s.useRef(null),p=s.useRef(null),g=a??f,w=s.useCallback(E=>{a===void 0&&d(E),l==null||l(E)},[l,a]),v=s.useCallback(()=>{const E=u.current;if(!E)return;const y=E.getBoundingClientRect(),T=n==="end"?Math.max(8,y.right-i):Math.min(y.left,window.innerWidth-i-8),L=window.innerHeight-y.bottom,C=L<220&&y.top>L?void 0:y.bottom+6,m=C===void 0?window.innerHeight-y.top+6:void 0;b({position:"fixed",zIndex:9999,left:T,top:C,bottom:m,width:i})},[n,i]);return s.useEffect(()=>{if(!g)return;v();const E=T=>{var C,m;const L=T.target;(C=u.current)!=null&&C.contains(L)||(m=p.current)!=null&&m.contains(L)||w(!1)},y=T=>{T.key==="Escape"&&w(!1)};return window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),document.addEventListener("mousedown",E),document.addEventListener("keydown",y),()=>{window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",y)}},[g,w,v]),t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:u,className:"inline-flex",onClick:()=>w(!g),children:e}),g&&typeof document<"u"&&bt.createPortal(t.jsx("div",{ref:p,"data-bonsaif-overlay":"true",role:"dialog",style:h,className:Pe("bonsaif-pop rounded-xl border border-[var(--border)] bg-[var(--bg-card)] p-3 text-sm text-[var(--text-main)] shadow-xl",c),children:r}),document.body)]})}function Qh({items:e,type:r="single",value:n,defaultValue:a=[],onValueChange:o,className:l}){const[i,c]=s.useState(a),f=n??i;function d(h){const b=f.includes(h),u=r==="single"?b?[]:[h]:b?f.filter(p=>p!==h):[...f,h];n===void 0&&c(u),o==null||o(u)}return t.jsx("div",{className:Pe("divide-y divide-[var(--border)] overflow-hidden rounded-xl border border-[var(--border)]",l),children:e.map(h=>{const b=f.includes(h.id);return t.jsxs("div",{className:"bg-[var(--bg-card)]",children:[t.jsxs("button",{type:"button",disabled:h.disabled,"aria-expanded":b,className:"flex w-full items-center gap-3 px-4 py-3 text-left disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>d(h.id),children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-semibold text-[var(--text-main)]",children:h.title}),h.description&&t.jsx("span",{className:"mt-0.5 block truncate text-xs text-[var(--text-muted)]",children:h.description})]}),t.jsx(F.HiChevronDown,{className:Pe("h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-200 ease-out",b&&"rotate-180")})]}),t.jsx("div",{className:"bonsaif-collapse","data-open":b?"true":"false",children:t.jsx("div",{inert:b?void 0:!0,children:t.jsx("div",{className:"px-4 pb-4 text-sm leading-6 text-[var(--text-main)]",children:h.content})})})]},h.id)})})}function Jh({value:e,options:r,onChange:n,size:a="md",ariaLabel:o,className:l}){return t.jsx("div",{role:"radiogroup","aria-label":o,className:Pe("inline-flex rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-0.5",l),children:r.map(i=>{const c=i.value===e;return t.jsxs("button",{type:"button",role:"radio","aria-checked":c,disabled:i.disabled,onClick:()=>n(i.value),className:Pe("inline-flex items-center gap-1.5 rounded-md font-semibold transition-[background-color,color,box-shadow] duration-200 ease-out disabled:cursor-not-allowed disabled:opacity-40",a==="sm"?"px-2.5 py-1 text-xs":"px-3 py-1.5 text-sm",c?"bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"text-[var(--text-muted)] hover:text-[var(--text-main)]"),children:[i.icon,i.label]},i.value)})})}const uc=160;function fc(e,r){const n=new Float32Array(r),a=Math.max(1,Math.floor(e.length/r));for(let o=0;o<r;o+=1){const l=o*a;let i=0;for(let c=0;c<a;c+=1){const f=Math.abs(e[l+c]??0);f>i&&(i=f)}n[o]=i}return n}function Rh(e,r=uc){const n=fc(e.getChannelData(0),r);return e.numberOfChannels>1?{mode:"multichannel",up:n,down:fc(e.getChannelData(1),r)}:{mode:"mono",mono:n}}function ep(e,r,n,a={}){const o=a.bars??uc,l=a.monoColor??"#34d399",i=a.upColor??"#60a5fa",c=a.downColor??"#34d399",f=a.background??"rgba(16, 185, 129, 0.08)",d=window.devicePixelRatio||1,h=e.clientWidth,b=e.clientHeight;if(h<2||b<2)return;(e.width!==Math.floor(h*d)||e.height!==Math.floor(b*d))&&(e.width=Math.floor(h*d),e.height=Math.floor(b*d));const u=e.getContext("2d");if(!u)return;u.setTransform(d,0,0,d,0,0),u.clearRect(0,0,h,b),u.fillStyle=f,u.fillRect(0,0,h,b);const p=b/2;if(u.save(),u.strokeStyle="rgba(255,255,255,0.28)",u.setLineDash([3,4]),u.beginPath(),u.moveTo(0,p),u.lineTo(h,p),u.stroke(),u.restore(),!r)return;const g=h/o,w=Math.max(1,g*.55),v=Math.max(0,Math.min(1,n));for(let y=0;y<o;y+=1){const T=y*g+(g-w)/2;if(u.globalAlpha=y/o<=v?1:.38,r.mode==="mono"){const L=(r.mono[y]??0)*(b*.46);u.fillStyle=l,u.fillRect(T,p-L,w,Math.max(L*2,1))}else{const L=(r.up[y]??0)*(b*.46),C=(r.down[y]??0)*(b*.46);u.fillStyle=i,u.fillRect(T,p-L,w,Math.max(L,.5)),u.fillStyle=c,u.fillRect(T,p,w,Math.max(C,.5))}}u.globalAlpha=1;const E=v*h;u.fillStyle="rgba(255,255,255,0.85)",u.fillRect(E,6,1.5,b-12)}const tp=[.75,1,1.25,1.5,2],rp=5,np=["Cliente","Asesor"],bc=["#60a5fa","#34d399"];function En(e){if(!Number.isFinite(e)||e<0)return"0:00";const r=Math.floor(e),n=Math.floor(r/60),a=r%60;return`${n}:${String(a).padStart(2,"0")}`}function ap(e){return`${e}×`}function op({src:e,title:r="Grabacion",downloadName:n,className:a,fetchCredentials:o="omit",channelLabels:l,channelColors:i,skipSeconds:c=rp,showDownload:f=!0}){const d=s.useRef(null),h=s.useRef(null),b=s.useRef(null),u=s.useRef(""),p=s.useRef(!1),g=s.useRef(0),[w,v]=s.useState(!1),[E,y]=s.useState(0),[T,L]=s.useState(0),[C,m]=s.useState(1),[S,N]=s.useState(1),[_,U]=s.useState(!1),[K,D]=s.useState(""),[Z,O]=s.useState(""),[ne,ee]=s.useState(!1),fe=l??np,J=(i==null?void 0:i[0])??bc[0],W=(i==null?void 0:i[1])??bc[1],R=s.useRef({monoColor:W,upColor:J,downColor:W});R.current={monoColor:W,upColor:J,downColor:W};function $(q){g.current=q;const k=h.current;k&&ep(k,b.current,q,R.current)}s.useEffect(()=>{if(b.current=null,D(""),y(0),L(0),v(!1),O(""),ee(!1),U(!!e),!e){U(!1);return}const q=new AbortController;let k=!0;return(async()=>{var V,M;try{const Y=await fetch(e,{credentials:o,signal:q.signal});if(!Y.ok)throw new Error("unavailable");const ce=await Y.arrayBuffer();if(!k)return;const X=((M=(V=Y.headers.get("content-type"))==null?void 0:V.split(";")[0])==null?void 0:M.trim())||"audio/wav",G=URL.createObjectURL(new Blob([ce],{type:X}));if(!k){URL.revokeObjectURL(G);return}u.current&&p.current&&URL.revokeObjectURL(u.current),u.current=G,p.current=!0,O(G);const I=new AudioContext;I.state==="suspended"&&await I.resume();const le=await I.decodeAudioData(ce.slice(0));if(!k){await I.close();return}b.current=Rh(le),ee(b.current.mode==="multichannel"),Number.isFinite(le.duration)&&L(le.duration),await I.close();const be=d.current,ie=be&&be.duration?be.currentTime/be.duration:0;$(ie)}catch(Y){if(Y.name==="AbortError")return;D("No se pudo cargar el audio")}finally{k&&U(!1)}})(),()=>{k=!1,q.abort(),u.current&&p.current&&URL.revokeObjectURL(u.current),u.current="",p.current=!1}},[e,o]),s.useEffect(()=>{$(g.current)},[J,W]),s.useEffect(()=>{const q=h.current;if(!q||!e)return;const k=new ResizeObserver(()=>{$(g.current)});return k.observe(q),$(g.current),()=>k.disconnect()},[e]);function P(){const q=d.current;q&&(q.paused?q.play().catch(()=>D("No se pudo reproducir el audio")):q.pause())}function ue(q){const k=d.current;if(!k)return;const V=Math.min(Math.max(0,k.currentTime+q),Number.isFinite(k.duration)?k.duration:k.currentTime+q);k.currentTime=V,y(V)}function z(q){const k=d.current;if(!k||!Number.isFinite(k.duration)||k.duration<=0)return;const V=q.currentTarget.getBoundingClientRect(),M=Math.min(1,Math.max(0,(q.clientX-V.left)/V.width));k.currentTime=M*k.duration,y(k.currentTime),$(M)}const se=T||0;return t.jsxs("div",{className:Pe("overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)]",a),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("p",{className:"m-0 truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx("span",{className:"text-[11px] tabular-nums text-[var(--text-muted)]",children:En(se||E)}),f&&e?t.jsx("a",{href:e,download:n||!0,className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-[var(--text-muted)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-main)]","aria-label":"Descargar audio",children:t.jsx(F.HiArrowDownTray,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{className:"px-3 py-3",children:[ne?t.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-3 text-[11px] text-[var(--text-muted)]",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:J}}),fe[0]]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:W}}),fe[1]]})]}):null,t.jsx("canvas",{ref:h,onClick:z,role:"slider","aria-label":"Posicion en la grabacion","aria-valuemin":0,"aria-valuemax":se||0,"aria-valuenow":E,"aria-valuetext":`${En(E)} de ${En(se)}`,className:Pe("h-16 w-full cursor-pointer rounded-lg bg-[rgba(6,78,59,0.35)]",!e&&"opacity-50")}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[t.jsx("button",{type:"button","aria-label":"Retroceder",disabled:!Z,onClick:()=>ue(-c),className:"rounded-md p-1 text-[var(--text-muted)] hover:text-[var(--text-main)] disabled:opacity-40",children:t.jsx(F.HiBackward,{className:"h-4 w-4"})}),t.jsx("button",{type:"button","aria-label":w?"Pausar":"Reproducir",disabled:!Z,onClick:P,className:"flex h-9 w-9 items-center justify-center rounded-full border-2 border-[var(--primary)] text-[var(--primary)] transition-transform duration-150 active:scale-95 disabled:opacity-40",children:w?t.jsx(F.HiPause,{className:"h-4 w-4"}):t.jsx(F.HiPlay,{className:"h-4 w-4"})}),t.jsx("button",{type:"button","aria-label":"Adelantar",disabled:!Z,onClick:()=>ue(c),className:"rounded-md p-1 text-[var(--text-muted)] hover:text-[var(--text-main)] disabled:opacity-40",children:t.jsx(F.HiForward,{className:"h-4 w-4"})}),t.jsxs("span",{className:"px-1 text-[11px] tabular-nums text-[var(--text-muted)]",children:[En(E)," / ",En(se)]}),tp.map(q=>t.jsx("button",{type:"button",disabled:!Z,onClick:()=>{m(q),d.current&&(d.current.playbackRate=q)},className:Pe("rounded-full border border-[var(--border)] px-2 py-0.5 text-[10px] font-semibold disabled:opacity-40",C===q?"bg-[var(--bg-hover)] text-[var(--text-main)]":"text-[var(--text-muted)]"),children:ap(q)},q)),t.jsxs("label",{className:"ml-auto inline-flex items-center gap-1 text-[var(--text-muted)]",children:[t.jsx(F.HiSpeakerWave,{className:"h-3.5 w-3.5"}),t.jsx("input",{type:"range",min:0,max:1,step:.05,value:S,disabled:!Z,"aria-label":"Volumen",onChange:q=>{const k=Number(q.target.value);N(k),d.current&&(d.current.volume=k)},className:"h-1 w-16 accent-[var(--primary)] disabled:opacity-40"})]})]}),_?t.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:"Cargando forma de onda…"}):null,K?t.jsx("p",{className:"mt-2 text-[11px] text-[var(--danger,#dc2626)]",children:K}):null]}),Z?t.jsx("audio",{ref:d,src:Z,preload:"auto",className:"hidden",onPlay:()=>v(!0),onPause:()=>v(!1),onTimeUpdate:q=>{const k=q.currentTarget;y(k.currentTime),Number.isFinite(k.duration)&&L(k.duration),$(k.duration?k.currentTime/k.duration:0)},onLoadedMetadata:q=>{const k=q.currentTarget;Number.isFinite(k.duration)&&L(k.duration)},onEnded:()=>v(!1),onError:()=>D("No se pudo reproducir el audio")}):null]})}const ns=[1,1.25,1.5,2];function hc(e){if(!Number.isFinite(e)||e<0)return"0:00";const r=Math.floor(e),n=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return n>0?`${n}:${String(a).padStart(2,"0")}:${String(o).padStart(2,"0")}`:`${a}:${String(o).padStart(2,"0")}`}function sp({src:e,poster:r,title:n="Video",downloadName:a,className:o,fetchCredentials:l="omit"}){const i=s.useRef(null),c=s.useRef(null),f=s.useRef(""),[d,h]=s.useState(""),[b,u]=s.useState(""),[p,g]=s.useState(!1),[w,v]=s.useState(!1),[E,y]=s.useState(!1),[T,L]=s.useState(0),[C,m]=s.useState(0),[S,N]=s.useState(1);s.useEffect(()=>{const O=()=>y(document.fullscreenElement===i.current);return document.addEventListener("fullscreenchange",O),()=>document.removeEventListener("fullscreenchange",O)},[]),s.useEffect(()=>{if(u(""),h(""),f.current&&(URL.revokeObjectURL(f.current),f.current=""),!(e!=null&&e.trim()))return;if(l==="omit"&&!e.startsWith("blob:")){h(e);return}const O=new AbortController;let ne=!0;return(async()=>{var ee,fe;try{const J=await fetch(e,{credentials:l,signal:O.signal});if(!J.ok)throw new Error("unavailable");const W=((fe=(ee=J.headers.get("content-type"))==null?void 0:ee.split(";")[0])==null?void 0:fe.trim())||"video/mp4",R=await J.blob();if(!ne)return;const $=URL.createObjectURL(R.type?R:new Blob([R],{type:W}));f.current=$,h($)}catch(J){if(J.name==="AbortError")return;ne&&u("No se pudo cargar el video")}})(),()=>{ne=!1,O.abort(),f.current&&(URL.revokeObjectURL(f.current),f.current="")}},[e,l]);function _(){const O=c.current;!O||!d||(O.paused?(O.play(),g(!0)):(O.pause(),g(!1)))}function U(){const O=c.current,ne=ns[(ns.indexOf(S)+1)%ns.length]??1;N(ne),O&&(O.playbackRate=ne)}function K(){const O=c.current;O&&(O.muted=!O.muted,v(O.muted))}function D(){const O=i.current;O&&(document.fullscreenElement===O?document.exitFullscreen():O.requestFullscreen())}const Z=d.trim()?d:void 0;return e!=null&&e.trim()?t.jsx("div",{ref:i,className:Pe("bonsaif-fade overflow-hidden rounded-xl border border-[var(--border)] bg-black",o),children:t.jsxs("div",{className:"relative",children:[t.jsx("video",{ref:c,src:Z,poster:r,preload:"metadata",playsInline:!0,className:"aspect-video w-full bg-black","aria-label":n,onClick:_,onTimeUpdate:O=>L(O.currentTarget.currentTime),onLoadedMetadata:O=>m(O.currentTarget.duration),onPlay:()=>g(!0),onPause:()=>g(!1),onEnded:()=>g(!1)}),!p&&t.jsx("button",{type:"button",onClick:_,disabled:!d||!!b,"aria-label":"Reproducir",className:"bonsaif-pop absolute left-1/2 top-1/2 inline-flex h-14 w-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-white/90 text-black shadow-lg transition-transform duration-150 hover:scale-105 active:scale-95 disabled:opacity-40",children:t.jsx(F.HiPlay,{className:"h-6 w-6"})}),b?t.jsx("p",{className:"absolute inset-x-0 bottom-14 px-3 text-center text-xs text-red-200",children:b}):null,t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 bg-gradient-to-b from-black/70 to-transparent px-3 py-2",children:t.jsx("p",{className:"m-0 truncate text-sm font-semibold text-white",children:n})}),t.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent px-3 pb-3 pt-8",children:[t.jsx("input",{type:"range",min:0,max:C||0,step:.1,value:Math.min(T,C||0),disabled:!d||!C,"aria-label":"Posicion",className:"mb-2 h-1 w-full accent-white",onChange:O=>{const ne=Number(O.currentTarget.value);L(ne),c.current&&(c.current.currentTime=ne)}}),t.jsxs("div",{className:"flex items-center gap-1.5 text-white",children:[t.jsx("button",{type:"button",onClick:_,disabled:!d,"aria-label":p?"Pausar":"Reproducir",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-transform duration-150 hover:bg-white/15 active:scale-95 disabled:opacity-40",children:p?t.jsx(F.HiPause,{className:"h-4 w-4"}):t.jsx(F.HiPlay,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:K,disabled:!d,"aria-label":w?"Activar sonido":"Silenciar",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-colors duration-150 hover:bg-white/15 disabled:opacity-40",children:w?t.jsx(F.HiSpeakerXMark,{className:"h-4 w-4"}):t.jsx(F.HiSpeakerWave,{className:"h-4 w-4"})}),t.jsxs("span",{className:"ml-1 text-xs tabular-nums text-white/80",children:[hc(T)," / ",hc(C)]}),t.jsx("span",{className:"ml-auto"}),t.jsxs("button",{type:"button",onClick:U,disabled:!d,"aria-label":"Velocidad",className:"h-8 rounded-md px-2 text-xs font-semibold transition-colors duration-150 hover:bg-white/15 disabled:opacity-40",children:[S,"x"]}),d&&t.jsx("a",{href:d,download:a||!0,"aria-label":"Descargar video",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-colors duration-150 hover:bg-white/15",children:t.jsx(F.HiArrowDownTray,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:D,"aria-label":E?"Salir de pantalla completa":"Pantalla completa",className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-colors duration-150 hover:bg-white/15",children:E?t.jsx(F.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(F.HiArrowsPointingOut,{className:"h-4 w-4"})})]})]})]})}):t.jsx("div",{className:Pe("bonsaif-fade flex aspect-video items-center justify-center rounded-xl border border-[var(--border)] bg-[var(--bg-input)] px-4 text-center text-sm text-[var(--text-muted)]",o),children:"Video no disponible"})}function ur(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function pc(e){try{const r=new URL(e);return ur(r.pathname)}catch{return""}}function lp(e){const r=ur(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return ur(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?ur(`/${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())?"":ur(`/${a[0]}`)}const as="primeSuiteAppUrl",ip={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"}},mc={xs:20,sm:28,md:36,lg:48,xl:64},gc=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],cp={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},dp="bonsaif.bot",up="Bonsaif Bot",fp={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function vc(e){return typeof e=="string"?e.trim():""}function bp(e){var o;if(e!==void 0)return ur(e);const r=ur(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(as)||"";i&&window.sessionStorage.setItem(as,i);const c=window.sessionStorage.getItem(as)||"",f=i||c;if(f){const d=pc(f);if(d&&!/^\/admin(\/|$)/i.test(d))return d}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?pc(a):ur(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return lp(window.location.pathname)}function hp(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 pp(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return gc[r%gc.length]}function mp(e,r){return e===dp||r===up}function gp(e,r){return`${e.replace(/\/$/,"")}${r}`}function os({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:f,wrapperClassName:d="",labelClassName:h="",labelSize:b="xs",avatarVersion:u=0,className:p="",style:g}){const[w,v]=s.useState(!1),E=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[E,u]);const{wh:y,text:T}=ip[a],L=vc(n)||vc(r)||c,C=hp(L),m=bp(f),S=mp(r,n),N=gp(m,"/favicon.svg"),_=s.useMemo(()=>{if(!E)return"";const O=new URLSearchParams;O.set("size",String(mc[a])),u&&O.set("v",String(u));const ne=O.toString();return`${m}/api/user/avatar/${encodeURIComponent(E)}${ne?`?${ne}`:""}`},[u,m,E,a]),U=mc[a],K=S?t.jsx("span",{className:`${y} ${fp[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${p}`,style:g,children:t.jsx("img",{src:N,alt:L,width:U,height:U,className:"h-full w-full object-contain"})}):_&&!w?t.jsx("img",{src:_,alt:L,width:U,height:U,className:`${y} rounded-full object-cover flex-shrink-0 ${p}`,style:g,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${E}-${u}`):t.jsx("span",{className:`${y} ${pp(L)} ${T} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:g,title:L,children:C});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${d}`,children:[K,t.jsx("span",{className:`min-w-0 truncate ${cp[b]} font-medium text-[var(--text-main)] ${h}`,title:L,children:L})]});const D=l??!0,Z=i??L;return D&&Z?t.jsx(Xt,{as:"span",content:Z,className:`inline-flex flex-shrink-0 ${d}`,children:K}):K}function vp({people:e,max:r=4,size:n="sm",className:a}){const o=e.slice(0,r),l=e.slice(r),i=n==="xs"?"-ml-1.5":n==="md"?"-ml-3":"-ml-2";return t.jsxs("div",{className:Pe("flex items-center",a),"aria-label":"Personas",children:[o.map((c,f)=>t.jsx("span",{className:Pe("relative bonsaif-rise rounded-full ring-2 ring-[var(--bg-card)] transition-transform duration-150 hover:z-20 hover:scale-105",f>0&&i),style:{animationDelay:`${f*40}ms`},children:t.jsx(os,{userId:c.userId,username:c.username,name:c.name,size:n,showTooltip:!0})},c.id)),l.length>0&&t.jsx(dc,{content:l.map(c=>c.name).join(", "),children:t.jsxs("span",{className:Pe("relative z-10 inline-flex items-center justify-center rounded-full bg-[var(--bg-input)] font-semibold text-[var(--text-main)] ring-2 ring-[var(--bg-card)] transition-transform duration-150 hover:z-20 hover:scale-105",i,n==="xs"?"h-5 min-w-5 px-1 text-[9px]":n==="md"?"h-9 min-w-9 px-1.5 text-xs":"h-7 min-w-7 px-1 text-[10px]"),children:["+",l.length]})})]})}function xp({children:e,items:r,className:n}){const a=s.useRef(null),[o,l]=s.useState(!1),[i,c]=s.useState({x:0,y:0}),[f,d]=s.useState({});function h(b){b.preventDefault(),c({x:b.clientX,y:b.clientY}),l(!0)}return s.useEffect(()=>{if(!o)return;const b=a.current,u=(b==null?void 0:b.offsetWidth)??200,p=(b==null?void 0:b.offsetHeight)??160,g=Math.min(i.x,window.innerWidth-u-8),w=Math.min(i.y,window.innerHeight-p-8);d({position:"fixed",zIndex:1e4,left:Math.max(8,g),top:Math.max(8,w),minWidth:180});const v=y=>{var T;(T=a.current)!=null&&T.contains(y.target)||l(!1)},E=y=>{y.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",E)}},[o,i.x,i.y]),t.jsxs(t.Fragment,{children:[t.jsx("div",{onContextMenu:h,className:n,children:e}),o&&typeof document<"u"&&bt.createPortal(t.jsx("div",{ref:a,role:"menu","data-bonsaif-overlay":"true",style:f,className:"bonsaif-pop overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl",children:r.map(b=>t.jsxs("div",{children:[b.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:b.disabled,className:Pe("flex w-full items-start gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors duration-150 hover:bg-[var(--bg-hover)] disabled:cursor-not-allowed disabled:opacity-40",b.danger?"text-[var(--danger)]":"text-[var(--text-main)]"),onClick:()=>{var u;b.disabled||((u=b.onSelect)==null||u.call(b),l(!1))},children:[b.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:b.icon}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate font-medium",children:b.label}),b.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:b.description})]})]})]},b.id))}),document.body)]})}const yp={primary:"var(--primary)",success:"#059669",warning:"#d97706",danger:"var(--danger, #dc2626)"};function wp({value:e,max:r=100,label:n,showValue:a=!0,tone:o="primary",size:l="md",className:i}){const c=r>0?r:100,f=Math.min(1,Math.max(0,e/c)),d=Math.round(f*100);return t.jsxs("div",{className:Pe("min-w-0",i),children:[(n||a)&&t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-3 text-xs",children:[t.jsx("span",{className:"truncate font-medium text-[var(--text-main)]",children:n}),a&&t.jsxs("span",{className:"shrink-0 tabular-nums text-[var(--text-muted)]",children:[d,"%"]})]}),t.jsx("div",{role:"progressbar","aria-valuenow":Math.round(e),"aria-valuemin":0,"aria-valuemax":c,"aria-label":typeof n=="string"?n:"Progreso",className:Pe("overflow-hidden rounded-full bg-[var(--bg-input)]",l==="sm"?"h-1.5":"h-2.5"),children:t.jsx("div",{className:"h-full rounded-full transition-[width] duration-300 ease-out",style:{width:`${d}%`,background:yp[o]}})})]})}function xc({title:e,items:r,query:n,onQuery:a,selected:o,onToggle:l,onMove:i,placeholder:c}){const f=r.filter(d=>`${d.label} ${d.description??""}`.toLowerCase().includes(n.trim().toLowerCase()));return t.jsxs("section",{className:"flex min-h-64 min-w-0 flex-1 flex-col overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)]",children:[t.jsxs("header",{className:"border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("p",{className:"m-0 text-xs font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:[e,t.jsxs("span",{className:"ml-1 tabular-nums",children:["(",r.length,")"]})]}),t.jsx("input",{value:n,onChange:d=>a(d.currentTarget.value),placeholder:c,className:"mt-2 h-8 w-full rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]"})]}),t.jsx("ul",{className:"m-0 flex-1 list-none overflow-auto p-1.5",children:f.length===0?t.jsx("li",{className:"px-2 py-6 text-center text-xs text-[var(--text-muted)]",children:"Sin resultados"}):f.map(d=>{const h=o.has(d.id);return t.jsx("li",{children:t.jsxs("button",{type:"button",disabled:d.disabled,onClick:()=>l(d.id),onDoubleClick:()=>i(d.id),className:Pe("flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40",h?"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]":"hover:bg-[var(--bg-hover)]"),children:[t.jsx("span",{"aria-hidden":!0,className:Pe("mt-0.5 h-3.5 w-3.5 shrink-0 rounded border",h?"border-[var(--primary)] bg-[var(--primary)]":"border-[var(--border)]")}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:d.label}),d.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:d.description})]})]})},d.id)})})]})}function Np({items:e,value:r,onChange:n,availableLabel:a="Disponibles",assignedLabel:o="Asignados",searchPlaceholder:l="Buscar...",className:i}){const[c,f]=s.useState(""),[d,h]=s.useState(""),[b,u]=s.useState([]),p=s.useMemo(()=>new Set(r),[r]),g=s.useMemo(()=>new Set(b),[b]),w=e.filter(T=>!p.has(T.id)),v=e.filter(T=>p.has(T.id));function E(T){u(L=>L.includes(T)?L.filter(C=>C!==T):[...L,T])}function y(T,L){const C=new Set(T.filter(S=>e.some(N=>N.id===S&&!N.disabled)));if(C.size===0)return;const m=L==="assigned"?[...r,...[...C].filter(S=>!p.has(S))]:r.filter(S=>!C.has(S));n(m),u(S=>S.filter(N=>!C.has(N)))}return t.jsxs("div",{className:Pe("flex flex-col gap-3 sm:flex-row sm:items-stretch",i),children:[t.jsx(xc,{title:a,items:w,query:c,onQuery:f,selected:g,onToggle:E,onMove:T=>y([T],"assigned"),placeholder:l}),t.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 sm:flex-col",children:[t.jsx("button",{type:"button","aria-label":"Asignar",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-[var(--text-main)] transition-colors duration-150 hover:bg-[var(--bg-hover)]",onClick:()=>y(b.filter(T=>!p.has(T)),"assigned"),children:t.jsx(F.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button","aria-label":"Quitar",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-[var(--text-main)] transition-colors duration-150 hover:bg-[var(--bg-hover)]",onClick:()=>y(b.filter(T=>p.has(T)),"available"),children:t.jsx(F.HiChevronLeft,{className:"h-4 w-4"})})]}),t.jsx(xc,{title:o,items:v,query:d,onQuery:h,selected:g,onToggle:E,onMove:T=>y([T],"available"),placeholder:l})]})}function kp({items:e,columns:r=1,className:n,ariaLabel:a="Propiedades"}){return t.jsx("dl",{"aria-label":a,className:Pe("bonsaif-fade m-0 grid gap-px overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--border)]",r===2?"sm:grid-cols-2":"grid-cols-1",n),children:e.map(o=>t.jsxs("div",{className:"bg-[var(--bg-card)] px-4 py-3",children:[t.jsx("dt",{className:"text-xs font-medium text-[var(--text-muted)]",children:o.label}),t.jsx("dd",{className:"m-0 mt-1 text-sm font-medium text-[var(--text-main)]",children:o.value}),o.hint&&t.jsx("p",{className:"m-0 mt-1 text-xs text-[var(--text-muted)]",children:o.hint})]},o.id))})}function Sp({chips:e,onRemove:r,onClear:n,clearLabel:a="Limpiar",emptyLabel:o="Sin filtros",className:l}){return e.length===0?t.jsx("p",{className:Pe("m-0 text-sm text-[var(--text-muted)]",l),children:o}):t.jsxs("div",{className:Pe("flex flex-wrap items-center gap-2",l),"aria-label":"Filtros aplicados",children:[e.map(i=>t.jsxs("span",{className:"bonsaif-rise inline-flex max-w-full items-center gap-1 rounded-full border border-[var(--border)] bg-[var(--bg-input)] py-1 pl-2.5 pr-1 text-xs text-[var(--text-main)]",children:[t.jsx("span",{className:"text-[var(--text-muted)]",children:i.label}),i.value&&t.jsx("span",{className:"truncate font-semibold",children:i.value}),t.jsx("button",{type:"button","aria-label":`Quitar ${typeof i.label=="string"?i.label:"filtro"}`,className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-[var(--text-muted)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-main)]",onClick:()=>r(i.id),children:t.jsx(F.HiXMark,{className:"h-3.5 w-3.5"})})]},i.id)),n&&t.jsx("button",{type:"button",onClick:n,className:"text-xs font-semibold text-[var(--primary)] hover:underline",children:a})]})}function Cp({items:e,open:r,defaultOpen:n=!1,onOpenChange:a,shortcut:o=!1,placeholder:l="Buscar...",emptyLabel:i="Sin resultados",className:c}){const[f,d]=s.useState(n),[h,b]=s.useState(""),[u,p]=s.useState(0),g=s.useRef(null),w=r??f,v=s.useCallback(m=>{r===void 0&&d(m),a==null||a(m),m||(b(""),p(0))},[r,a]),E=s.useMemo(()=>{const m=h.trim().toLowerCase();return m?e.filter(S=>`${S.label} ${S.group??""} ${S.keywords??""}`.toLowerCase().includes(m)):e},[e,h]),y=s.useRef(w);y.current=w,s.useEffect(()=>{if(!o)return;const m=S=>{(S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"&&(S.preventDefault(),v(!y.current))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[o,v]),s.useEffect(()=>{if(!w)return;const m=window.requestAnimationFrame(()=>{var N;return(N=g.current)==null?void 0:N.focus()}),S=N=>{N.key==="Escape"&&v(!1)};return document.addEventListener("keydown",S),()=>{window.cancelAnimationFrame(m),document.removeEventListener("keydown",S)}},[w,v]),s.useEffect(()=>{p(0)},[h,w]);function T(m){var S;m.disabled||((S=m.onSelect)==null||S.call(m),v(!1))}function L(m){if(m.key==="ArrowDown")m.preventDefault(),p(S=>Math.min(E.length-1,S+1));else if(m.key==="ArrowUp")m.preventDefault(),p(S=>Math.max(0,S-1));else if(m.key==="Enter"){m.preventDefault();const S=E[u];S&&T(S)}}if(!w||typeof document>"u")return null;let C="";return bt.createPortal(t.jsx("div",{className:"bonsaif-fade fixed inset-0 z-[10000] flex items-start justify-center bg-black/40 p-4 pt-[12vh]",onMouseDown:()=>v(!1),children:t.jsxs("div",{role:"dialog","aria-label":"Paleta de comandos","data-bonsaif-overlay":"true",className:Pe("bonsaif-pop w-full max-w-lg overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-card)] shadow-2xl",c),onMouseDown:m=>m.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-3",children:[t.jsx(F.HiMagnifyingGlass,{className:"h-4 w-4 text-[var(--text-muted)]"}),t.jsx("input",{ref:g,value:h,onChange:m=>b(m.currentTarget.value),onKeyDown:L,placeholder:l,className:"h-12 w-full bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)]"})]}),t.jsx("div",{className:"max-h-80 overflow-auto p-1.5",role:"listbox",children:E.length===0?t.jsx("p",{className:"px-3 py-8 text-center text-sm text-[var(--text-muted)]",children:i}):E.map((m,S)=>{const N=m.group&&m.group!==C;m.group&&(C=m.group);const _=S===u;return t.jsxs("div",{children:[N&&t.jsx("p",{className:"px-2 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-muted)]",children:m.group}),t.jsxs("button",{type:"button",role:"option","aria-selected":_,disabled:m.disabled,className:Pe("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-[var(--text-main)] disabled:opacity-40",_&&"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]"),onMouseEnter:()=>p(S),onClick:()=>T(m),children:[m.icon&&t.jsx("span",{className:"text-[var(--text-muted)]",children:m.icon}),t.jsx("span",{className:"truncate",children:m.label})]})]},m.id)})})]})}),document.body)}const Ep={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Mp({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=Ep[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 Gr=360,fr=10,Na=14,ss=220;function Tp(e){if(typeof document>"u")return null;const r=document.querySelector(e);if(!(r instanceof HTMLElement))return null;const n=r.getBoundingClientRect();return n.width===0&&n.height===0?null:{top:n.top,left:n.left,width:n.width,height:n.height}}function Ap(e,r,n={width:window.innerWidth,height:window.innerHeight}){if(e&&e!=="auto")return e;const a=n.height-(r.top+r.height),o=r.top,l=n.width-(r.left+r.width);return a>=ss?"bottom":o>=ss?"top":l>=Gr+24?"right":"left"}function Lp(e){return{top:Math.max(8,e.top-fr),left:Math.max(8,e.left-fr),width:e.width+fr*2,height:e.height+fr*2}}function $p(e,r,n={width:window.innerWidth,height:window.innerHeight}){const a=e.left+e.width/2,o=e.top+e.height/2,l=n.width-Gr-16;return r==="bottom"?{top:e.top+e.height+fr+Na,left:Math.min(Math.max(16,a-Gr/2),l)}:r==="top"?{top:Math.max(16,e.top-fr-Na-ss),left:Math.min(Math.max(16,a-Gr/2),l)}:r==="right"?{top:Math.min(Math.max(16,o-120),n.height-260),left:Math.min(e.left+e.width+fr+Na,l)}:{top:Math.min(Math.max(16,o-120),n.height-260),left:Math.max(16,e.left-fr-Na-Gr)}}function Dp(e){const r=document.querySelector(e);r instanceof HTMLElement&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}function Ip({steps:e,open:r,onOpenChange:n,label:a="Guía",storageKey:o,onStepChange:l,backLabel:i="Atrás",skipLabel:c="Saltar",nextLabel:f="Siguiente",doneLabel:d="Listo",closeLabel:h="Cerrar guía",zIndex:b=1100}){const u=s.useId(),[p,g]=s.useState(0),[w,v]=s.useState(null),[E,y]=s.useState(!1),T=e[p]??e[0],L=e.length;s.useEffect(()=>{y(!0)},[]),s.useEffect(()=>{r&&g(0)},[r]),s.useEffect(()=>{!r||!T||l==null||l(T,p)},[r,T,p,l]);const C=s.useCallback(()=>{T&&v(Tp(T.target))},[T]);s.useLayoutEffect(()=>{if(!r||!T)return;Dp(T.target);const U=window.setTimeout(C,80),K=window.setTimeout(C,280);return()=>{window.clearTimeout(U),window.clearTimeout(K)}},[r,T,C]),s.useEffect(()=>{if(r)return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[r,C]);const m=s.useCallback(()=>{if(n(!1),!!o)try{localStorage.setItem(o,"done")}catch{}},[n,o]);s.useEffect(()=>{if(!r)return;function U(K){if(K.key==="Escape"){K.preventDefault(),m();return}if(K.key==="ArrowRight"||K.key==="Enter"){K.preventDefault(),g(D=>Math.min(D+1,L-1));return}K.key==="ArrowLeft"&&(K.preventDefault(),g(D=>Math.max(D-1,0)))}return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[r,m,L]);const S=s.useMemo(()=>!w||!T?"bottom":Ap(T.placement,w),[w,T]),N=s.useMemo(()=>w?Lp(w):null,[w]),_=s.useMemo(()=>typeof window>"u"?{top:96,left:16}:N?$p(N,S):{top:96,left:Math.max(16,(window.innerWidth-Gr)/2)},[N,S]);return!E||!r||!T?null:bt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:b},role:"dialog","aria-modal":"true","aria-labelledby":u,children:[t.jsx("button",{type:"button",className:"absolute inset-0 cursor-default bg-transparent","aria-label":h,onClick:m}),N?t.jsx("div",{className:"pointer-events-none absolute rounded-xl border-2 border-[var(--primary)] transition-all duration-200",style:{top:N.top,left:N.left,width:N.width,height:N.height,boxShadow:"0 0 0 9999px rgba(0, 0, 0, 0.58)"}}):t.jsx("div",{className:"pointer-events-none absolute inset-0 bg-black/58"}),t.jsxs("div",{className:"absolute w-[min(360px,calc(100vw-2rem))] rounded-2xl border border-[var(--border)] bg-[var(--bg-card)] p-4 shadow-2xl",style:{..._,zIndex:b+1},children:[t.jsxs("div",{className:"mb-3 flex items-start gap-2",children:[t.jsx("div",{className:"mt-0.5 rounded-lg p-1.5 text-[var(--primary)]",style:{background:"color-mix(in srgb, var(--primary) 15%, transparent)"},children:t.jsx(F.HiOutlineLightBulb,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider text-[var(--text-muted)]",children:[a," · ",p+1,"/",L]}),t.jsx("h2",{id:u,className:"mt-0.5 text-sm font-semibold text-[var(--text-main)]",children:T.title})]}),t.jsx(Ke,{variant:"icon",iconOnly:!0,"aria-label":h,tooltip:"Cerrar",onClick:m,children:t.jsx(F.HiXMark,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"space-y-3 text-sm leading-6 text-[var(--text-secondary)]",children:[T.body,T.caption?t.jsx("p",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2 font-mono text-[11px] text-[var(--text-main)]",children:T.caption}):null]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[t.jsx(Ke,{variant:"secondary",size:"sm",disabled:p===0,onClick:()=>g(U=>Math.max(U-1,0)),children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ke,{variant:"secondary",size:"sm",onClick:m,children:c}),p<L-1?t.jsx(Ke,{size:"sm",onClick:()=>g(U=>Math.min(U+1,L-1)),children:f}):t.jsx(Ke,{size:"sm",onClick:m,children:d})]})]})]})]}),document.body)}function Fp(e){const[r,n]=s.useState(!1);s.useEffect(()=>{try{if(localStorage.getItem(e)==="done")return;n(!0)}catch{n(!0)}},[e]);const a=s.useCallback(()=>{try{localStorage.setItem(e,"done")}catch{}},[e]),o=s.useCallback(()=>n(!0),[]),l=s.useCallback((i=!0)=>{n(!1),i&&a()},[a]);return{open:r,setOpen:n,openTour:o,closeTour:l,markDone:a}}const yc=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Op=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Hp(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 wc(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Nc(e){wc(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Bp(e){const r=e.querySelector(Op);return r instanceof HTMLElement?r:null}function kc(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(yc).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ra.OverlayScrollbars(l)){Nc(l);return}if(!Hp(l))return;const c={overflow:wc(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},f=Bp(l),d=f?Ra.OverlayScrollbars({target:l,elements:{viewport:f}},c):Ra.OverlayScrollbars(l,c);Nc(l),e.set(l,d)})},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(yc).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function Pp({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function _p(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Sc({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:f,LinkComponent:d=Pp}){const[h,b]=s.useState(!1),u=_p(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(kc,{}),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(F.HiBars3,{className:"h-5 w-5"})}),h&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${h?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(F.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(F.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(u).map(([p,g])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(F.HiChevronDown,{className:"h-3.5 w-3.5"}),p]}),t.jsx("div",{className:"space-y-1",children:g.map(w=>{const v=n===w.href||n.startsWith(`${w.href}/`);return t.jsxs(d,{href:w.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${v?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:w.icon??t.jsx(F.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:w.label})]},w.href)})})]},p))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(os,{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})]})]}),f&&t.jsxs(Ke,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:f,children:[t.jsx(F.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 Cc="bonsaif-ui:prime-auth-sso",zp={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"},ls={dashboard:t.jsx(F.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(F.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(F.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(F.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(F.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(F.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(F.HiUser,{className:"h-5 w-5"}),settings:t.jsx(F.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(F.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(F.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(F.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(F.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(F.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(F.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(F.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(F.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(F.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(F.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(F.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(F.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(F.HiShieldCheck,{className:"h-5 w-5"})};function Wp(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function jp(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function qp(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=jp(n)&&a?a:n,l=zp[o]??Wp(o);return[{label:"Inicio",href:"/"},{label:l}]}function is(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Up(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(F.HiHome,{className:"h-5 w-5"});if(ls[n])return ls[n];const a=r.length>1?r[r.length-2]:"";return ls[a]??t.jsx(F.HiHome,{className:"h-5 w-5"})}function Vp(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Ec(){if(typeof window>"u")return!1;if(Vp(window.location.href)){try{window.sessionStorage.setItem(Cc,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Cc)==="true"}catch{return!1}}function Xp({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:f,showBreadcrumbs:d=!0,contained:h=!1}){const b=s.useRef(null),[u,p]=s.useState(!1),[g,w]=s.useState(f??"/"),[v,E]=s.useState(()=>Ec()),[y,T]=s.useState(null),L=f??g,C=c??qp(L),m=o??Up(L),S=d&&!v&&C.length>1,N=!S;s.useEffect(()=>{f||w(window.location.pathname)},[f]),s.useEffect(()=>{E(Ec())},[]),s.useEffect(()=>{if(h){p(!1);return}let U=null,K=0,D=0;const Z=()=>{const ee=b.current,fe=document.querySelector("[data-app-scroll='true']");return(ee==null?void 0:ee.closest(".os-viewport"))??(ee==null?void 0:ee.closest("[data-overlayscrollbars-viewport]"))??is(fe)??fe??window},O=()=>{const ee=U&&U!==window?U.scrollTop:window.scrollY;p(fe=>fe?ee>24:ee>72)},ne=()=>{U==null||U.removeEventListener("scroll",O),U=Z(),U.addEventListener("scroll",O,{passive:!0}),O()};return ne(),K=window.requestAnimationFrame(ne),D=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout(D),U==null||U.removeEventListener("scroll",O)}},[h]),s.useEffect(()=>{if(h){T(null);return}let U=0;const K=[],D=()=>{const W=b.current,R=W==null?void 0:W.parentElement,$=document.querySelector("[data-app-scroll='true']"),P=is($)??$;if(!W||!R||!P){T(null);return}const ue=R.getBoundingClientRect(),z=window.getComputedStyle(R),se=P.getBoundingClientRect(),q=P instanceof HTMLElement&&P.clientWidth>0?P.clientWidth:se.width,k=ue.left+parseFloat(z.paddingLeft||"0"),V={marginLeft:Math.round(se.left-k),width:Math.round(q)};T(M=>M&&M.marginLeft===V.marginLeft&&M.width===V.width?M:V)},Z=()=>{window.cancelAnimationFrame(U),U=window.requestAnimationFrame(D)};Z(),window.addEventListener("resize",Z);const O=new ResizeObserver(Z),ne=b.current,ee=ne==null?void 0:ne.parentElement,fe=document.querySelector("[data-app-scroll='true']"),J=is(fe)??fe;return[ee,fe,J].forEach(W=>{W&&O.observe(W)}),K.push(window.setTimeout(Z,120)),K.push(window.setTimeout(Z,280)),()=>{window.cancelAnimationFrame(U),window.removeEventListener("resize",Z),O.disconnect(),K.forEach(W=>window.clearTimeout(W))}},[h]);const _={...y?{marginLeft:y.marginLeft,width:y.width}:null,"--page-header-control-height":u?"34px":"40px","--page-header-control-padding-x":u?"10px":"14px","--page-header-control-icon-left":u?"10px":"12px",background:h?"var(--bg-card)":u?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:h||u?"1px solid var(--border)":"1px solid transparent",boxShadow:u?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":u?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:_,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${u?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":N?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${u||N?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${u||N?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${u?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:S?"var(--text-secondary)":"var(--text-muted)"},children:m}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${u?"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 ${u?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":u,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${u?"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 ${u?"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 ${u?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx($s.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Yp({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(Sc,{currentPath:r,...a,children:e})}function Mc(){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 Gp(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 Kp({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(Mc());const f=new MutationObserver(()=>o(Mc()));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>f.disconnect()},[]);const i=s.useMemo(()=>Gp(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 f=n;function d(h){var p,g,w;if(h.source!==((p=l.current)==null?void 0:p.contentWindow)||c&&h.origin!==c)return;if(((g=h.data)==null?void 0:g.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((w=h.data)==null?void 0:w.type)!=="prime-microservice:navigation")return;const b=h.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const u=`/apps/${encodeURIComponent(f)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==u&&(window.history.replaceState(window.history.state,"",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",d),()=>{window.removeEventListener("message",d),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 Zp(){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 d;if(((d=c.data)==null?void 0:d.type)!=="prime-suite-chat:state")return;const f=!!c.data.active;a(f),l({width:Tc(c.data.width,96,720),height:Tc(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 Tc(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Qp(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 Jp(){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 Rp(){return"light"}function em({position:e="bottom-center"}){const r=s.useSyncExternalStore(Qp,Jp,Rp);return t.jsx(eo.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0,expand:!0,visibleToasts:4,style:{zIndex:99999},toastOptions:{duration:6e3}})}function tm({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 Mn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Ac(e,r){return e.color??Mn[r%Mn.length]}function Zt(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 Lt=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 Kr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const cs={warning:70,danger:90};function ka(e,r=cs){const n=r.warning??cs.warning,a=r.danger??cs.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function Tn(e,r){return Zt(ka(e,r))}function Zr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Qr(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 Lc(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 f=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${f.replace(/\.0$/,"")} ${l[c]}`}function Jr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Kr((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function $t({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 Dt({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 br=680,kr="ease-out",rm={top:18,right:8,bottom:12,left:0};function An(e){return{...rm,...e}}function Ln(e){return e.map((r,n)=>({...r,color:Ac(r,n),label:r.label??r.key}))}function Sa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Kr(n[a.key])===null))}function It(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function $n(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function $c(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Ca(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function nm(e,r=Lt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function Dc(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function am({active:e,label:r,payload:n,valueFormat:a=Lt}){var c,f,d,h,b,u;if(!e||!(n!=null&&n.length))return null;const o=n.filter(p=>p.dataKey!=="base"&&p.name!=="base"&&p.value!==null&&p.value!==void 0);if(!o.length)return null;const l=((f=(c=o[0])==null?void 0:c.payload)==null?void 0:f.fullName)??((h=(d=o[0])==null?void 0:d.payload)==null?void 0:h.tooltipLabel)??((u=(b=o[0])==null?void 0:b.payload)==null?void 0:u.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((p,g)=>{const w=p.payload,v=w&&typeof w.display=="number"?w.display:p.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:p.color??"var(--primary)"}}),p.name??p.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:nm(v,a)})]},String(p.dataKey??p.name??g))})})]})}function Rr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Oe.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(am,{valueFormat:e})})}function Ic(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Fc(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 Ea(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,f]=s.useState(null),[d,h]=s.useState(null),b=!!a&&e.length>1,u=b&&(o==="brush"||o==="both"),p=b&&(o==="drag"||o==="both"),g=s.useCallback(K=>{f(K),i==null||i(K)},[i]),w=s.useCallback(()=>{h(null),g(null)},[g]),v=!!c,E=s.useMemo(()=>!c||u?e:e.slice(c.startIndex,c.endIndex+1),[e,u,c]),y=s.useCallback((K,D)=>{const Z=Ic(e,r,K),O=Ic(e,r,D);Z<0||O<0||g(Fc(Z,O,e.length))},[g,e,r]),T=s.useCallback(K=>{p&&((K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||h({leftLabel:K.activeLabel,rightLabel:K.activeLabel}))},[p]),L=s.useCallback(K=>{!p||!d||(K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||h(D=>D&&{...D,rightLabel:K.activeLabel})},[d,p]),C=s.useCallback(()=>{if(p){if(!d||d.rightLabel===null||d.rightLabel===void 0){h(null);return}y(d.leftLabel,d.rightLabel),h(null)}},[y,d,p]),m=s.useCallback(K=>{if(u){if(!K){g(null);return}g(Fc(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[g,e.length,u]),S=p?{onMouseDown:T,onMouseMove:L,onMouseUp:C,onMouseLeave:()=>{d&&C()}}:{},N=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},_=t.jsxs(t.Fragment,{children:[p&&d&&d.rightLabel!==null&&d.rightLabel!==void 0?t.jsx(Oe.ReferenceArea,{x1:d.leftLabel,x2:d.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,u?t.jsx(Oe.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:N.startIndex,endIndex:N.endIndex,onChange:m,tickFormatter:K=>String(K)}):null]}),U=u?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:u,showDrag:p,viewData:E,isZoomed:v,resetZoom:w,chartHandlers:S,zoomNodes:_,marginExtra:U}}function Ma({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 om({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,yDomain:u,ariaLabel:p="Gráfico de líneas",curve:g=!0,strokeWidth:w=2.25,zoomable:v=!1,zoomMode:E="both",brushHeight:y,onZoomChange:T}){const L=Sa(e,n),C=Ln(n),m=Ea(e,r,{zoomable:v,zoomMode:E,brushHeight:y,onZoomChange:T}),S=An({...h,...m.marginExtra});return l?t.jsx($t,{height:a}):L?t.jsx(Dt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(Ma,{visible:m.isZoomed,onReset:m.resetZoom}),t.jsx(Oe.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Oe.LineChart,{data:m.viewData,margin:S,...m.chartHandlers,children:[c?t.jsx(Oe.CartesianGrid,{strokeDasharray:"2 8",stroke:$n(),vertical:!1}):null,t.jsx(Oe.XAxis,{dataKey:r,tick:It(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Oe.YAxis,{tick:It(),tickLine:!1,axisLine:!1,width:44,domain:u??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),d?t.jsx(Rr,{valueFormat:b,cursor:{stroke:$c(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,f?t.jsx(Oe.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Ca()}):null,C.map((N,_)=>t.jsx(Oe.Line,{type:g?"monotone":"linear",dataKey:N.key,name:N.label,stroke:N.color,strokeWidth:_===0?w+.35:w,strokeOpacity:_===0?1:.88,isAnimationActive:!0,animationDuration:br,animationEasing:kr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),m.zoomNodes]})})]})}function Ta({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,yDomain:u,ariaLabel:p="Gráfico de área",stacked:g=!1,opacity:w=.22,zoomable:v=!1,zoomMode:E="both",brushHeight:y,onZoomChange:T}){const L=Sa(e,n),C=Ln(n),m=Ea(e,r,{zoomable:v,zoomMode:E,brushHeight:y,onZoomChange:T}),S=An({...h,...m.marginExtra});return l?t.jsx($t,{height:a}):L?t.jsx(Dt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(Ma,{visible:m.isZoomed,onReset:m.resetZoom}),t.jsx(Oe.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Oe.AreaChart,{data:m.viewData,margin:S,...m.chartHandlers,children:[t.jsx("defs",{children:C.map(N=>t.jsxs("linearGradient",{id:Dc(N.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:N.color,stopOpacity:Math.min(.55,w+.28)}),t.jsx("stop",{offset:"48%",stopColor:N.color,stopOpacity:w*.5}),t.jsx("stop",{offset:"100%",stopColor:N.color,stopOpacity:0})]},N.key))}),c?t.jsx(Oe.CartesianGrid,{strokeDasharray:"2 8",stroke:$n(),vertical:!1}):null,t.jsx(Oe.XAxis,{dataKey:r,tick:It(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Oe.YAxis,{tick:It(),tickLine:!1,axisLine:!1,width:44,domain:u??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),d?t.jsx(Rr,{valueFormat:b,cursor:{stroke:$c(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,f?t.jsx(Oe.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Ca()}):null,C.map(N=>t.jsx(Oe.Area,{type:"monotone",dataKey:N.key,name:N.label,stroke:N.color,fill:`url(#${Dc(N.key)})`,strokeWidth:2.25,stackId:g?"stack":void 0,isAnimationActive:!0,animationDuration:br,animationEasing:kr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),m.zoomNodes]})})]})}function sm({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,yDomain:u,ariaLabel:p="Gráfico de barras",layout:g="vertical",mode:w="grouped",barRadius:v=6,categoryAxisWidth:E=64,zoomable:y=!1,zoomMode:T="both",brushHeight:L,onZoomChange:C}){const m=Sa(e,n),S=Ln(n),N=g==="horizontal",_=Ea(e,r,{zoomable:y&&!N,zoomMode:T,brushHeight:L,onZoomChange:C}),U=An({...h,..._.marginExtra});return l?t.jsx($t,{height:a}):m?t.jsx(Dt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(Ma,{visible:_.isZoomed,onReset:_.resetZoom}),t.jsx(Oe.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Oe.BarChart,{data:_.viewData,margin:U,layout:N?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,..._.chartHandlers,children:[c?t.jsx(Oe.CartesianGrid,{strokeDasharray:"2 8",stroke:$n(),horizontal:!N,vertical:N}):null,N?t.jsxs(t.Fragment,{children:[t.jsx(Oe.XAxis,{type:"number",tick:It(),tickLine:!1,axisLine:!1,tickFormatter:K=>b(Number(K)),domain:u??["auto","auto"]}),t.jsx(Oe.YAxis,{type:"category",dataKey:r,tick:It(),tickLine:!1,axisLine:!1,width:E})]}):t.jsxs(t.Fragment,{children:[t.jsx(Oe.XAxis,{dataKey:r,tick:It(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Oe.YAxis,{tick:It(),tickLine:!1,axisLine:!1,width:44,domain:u??["auto","auto"],tickFormatter:K=>b(Number(K)),dx:-2})]}),d?t.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,f?t.jsx(Oe.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Ca()}):null,S.map((K,D)=>t.jsx(Oe.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:D===0?1:.82,radius:N?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:w==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:br,animationEasing:kr},K.key)),_.zoomNodes]})})]})}function lm(e){return t.jsx(Hc,{...e,variant:"pie"})}function im(e){return t.jsx(Hc,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Oc(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Hc({data:e,nameKey:r,valueKey:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:f=!0,valueFormat:d=Lt,ariaLabel:h,innerRadius:b,outerRadius:u,colors:p=[...Mn],padAngle:g,cornerRadius:w,variant:v}){const E=e.map((D,Z)=>({name:String(D[r]??""),value:Kr(D[n])??0,fill:p[Z%p.length],row:D})).filter(D=>D.value>0),y=!E.length,T=v==="donut",L=E.length,C=Oc(b,T?62:12),m=Oc(u,78),S=Math.min(g??(T?2:3),Math.max(.5,10/Math.max(1,L))),N=Math.min(w??(T?10:8),Math.max(2,36/Math.max(1,L)));if(l)return t.jsx($t,{height:a});if(y)return t.jsx(Dt,{height:a,text:i});const _=E.reduce((D,Z)=>D+Z.value,0),U=c?Math.min(96,28+Math.ceil(L/3)*22):0,K=Math.max(140,a-U);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":h??(v==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:K},children:t.jsx(Oe.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Oe.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[f?t.jsx(Rr,{valueFormat:d,isAnimationActive:!1}):null,t.jsx(Oe.Pie,{data:E,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${C}%`,outerRadius:`${m}%`,startAngle:90,endAngle:-270,paddingAngle:S,cornerRadius:N,minAngle:L>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:br,animationEasing:kr,label:!1,activeShape:cm,children:E.map(D=>t.jsx(Oe.Cell,{fill:D.fill},D.name))}),T?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:d(_)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:E.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:d(D.value)})]},D.name))}):null]})})}function cm(e){const{outerRadius:r=0,...n}=e;return t.jsx(Oe.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function dm({data:e,dataKey:r,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:f="Sparkline"}){const d=l??Zt(o),h=e.map(m=>Kr(m[r])).filter(m=>m!==null);if(h.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":f});const b=120,u=36,p=3,g=1,w=Math.min(...h),E=Math.max(...h)-w||1,y=h.map((m,S)=>{const N=g+S/(h.length-1)*(b-g*2),_=u-p-(m-w)/E*(u-p*2);return{x:N,y:_}}),T=y.map((m,S)=>`${S===0?"M":"L"}${m.x.toFixed(2)} ${m.y.toFixed(2)}`).join(" "),L=`${T} L${y[y.length-1].x.toFixed(2)} ${u} L${y[0].x.toFixed(2)} ${u} Z`,C=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":f,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${u}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:C,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:d,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:d,stopOpacity:0})]})}):null,i?t.jsx("path",{d:L,fill:`url(#${C})`}):null,t.jsx("path",{d:T,fill:"none",stroke:d,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function um({data:e,xKey:r,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:f="Sin datos para mostrar",showGrid:d=!0,showLegend:h=!0,showTooltip:b=!0,margin:u,valueFormat:p=Lt,yDomain:g,ariaLabel:w="Gráfico combinado",barRadius:v=6,zoomable:E=!1,zoomMode:y="both",brushHeight:T,onZoomChange:L}){const C=a??n.slice(0,Math.max(1,n.length-1)),m=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),S=[...C,...m.filter(O=>!C.some(ne=>ne.key===O.key))],N=Sa(e,S),_=Ln(C),U=Ln(S),K=m.map(O=>{var ee;const ne=U.find(fe=>fe.key===O.key);return{...O,label:O.label??O.key,color:O.color??(ne==null?void 0:ne.color)??((ee=U[0])==null?void 0:ee.color)}}),D=Ea(e,r,{zoomable:E,zoomMode:y,brushHeight:T,onZoomChange:L}),Z=An({...u,...D.marginExtra});return c?t.jsx($t,{height:l}):N?t.jsx(Dt,{height:l,text:f}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":w,style:{height:l},children:[t.jsx(Ma,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Oe.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Oe.ComposedChart,{data:D.viewData,margin:Z,barCategoryGap:"34%",...D.chartHandlers,children:[d?t.jsx(Oe.CartesianGrid,{strokeDasharray:"2 8",stroke:$n(),vertical:!1}):null,t.jsx(Oe.XAxis,{dataKey:r,tick:It(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Oe.YAxis,{tick:It(),tickLine:!1,axisLine:!1,width:44,domain:g??["auto","auto"],tickFormatter:O=>p(Number(O)),dx:-2}),b?t.jsx(Rr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,h?t.jsx(Oe.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Ca()}):null,_.map(O=>t.jsx(Oe.Bar,{dataKey:O.key,name:O.label,fill:O.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:br,animationEasing:kr},O.key)),K.map(O=>t.jsx(Oe.Line,{type:"monotone",dataKey:O.key,name:O.label,stroke:O.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:br,animationEasing:kr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:O.color}},O.key)),D.zoomNodes]})})]})}function fm({data:e,xKey:r,valueKey:n,typeKey:a,height:o=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:f=!0,showTooltip:d=!0,margin:h,valueFormat:b=Lt,ariaLabel:u="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:g="#f87171",totalColor:w="var(--primary)"}){const v=s.useMemo(()=>bm(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:g,totalColor:w}),[e,r,n,a,p,g,w]),E=!v.length,y=An(h);return i?t.jsx($t,{height:o}):E?t.jsx(Dt,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":u,style:{height:o},children:t.jsx(Oe.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Oe.BarChart,{data:v,margin:y,barCategoryGap:"42%",children:[f?t.jsx(Oe.CartesianGrid,{strokeDasharray:"2 8",stroke:$n(),vertical:!1}):null,t.jsx(Oe.XAxis,{dataKey:"label",tick:It(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Oe.YAxis,{tick:It(),tickLine:!1,axisLine:!1,width:44,tickFormatter:T=>b(Number(T)),dx:-2}),d?t.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Oe.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Oe.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:br,animationEasing:kr,children:v.map(T=>t.jsx(Oe.Cell,{fill:T.color},T.label))})]})})})}function bm(e,r){let n=0;return e.map((a,o)=>{const l=Kr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let f="increase",d=0,h=0,b=l;return c&&i==="total"?(f="total",d=0,h=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(f="total",d=0,h=Math.abs(n),b=n):(f=i==="decrease"||l<0?"decrease":"increase",f==="decrease"?(d=n+l,h=Math.abs(l),n=n+l):(d=n,h=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:d,delta:h,display:b,kind:f,color:f==="total"?r.totalColor:f==="decrease"?r.decreaseColor:r.increaseColor}})}const Bc="bonsaif-funnel-chart-keyframes",hm=`
|
|
60
60
|
@keyframes bonsaif-funnel-stage-in {
|
|
61
61
|
from {
|
|
62
62
|
opacity: 0;
|
|
@@ -96,4 +96,4 @@ ${B}`,he=new Blob(["\uFEFF"+de],{type:"text/csv;charset=utf-8;"}),Ee=URL.createO
|
|
|
96
96
|
animation: none !important;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
`;function xp(){if(typeof document>"u"||document.getElementById(Ri))return;const e=document.createElement("style");e.id=Ri,e.textContent=vp,document.head.appendChild(e)}function ec(e,r,n){return Math.min(n,Math.max(r,e))}function Na(e,r,n){const a=ec(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function yp(e,r,n,a,o,l){const i=e.map((f,d)=>{const h=Yr(f[n])??0,b=String(f[r]??""),u=a?String(f[a]??"").trim():"",p=o?String(f[o]??"").trim():"";return{name:b,value:h,color:l[d%l.length],...u?{title:u}:{},...p?{description:p}:{}}}).filter(f=>f.value>0&&f.name),c=Math.max(...i.map(f=>f.value),1);return i.map(f=>({...f,pct:f.value/c}))}function wp(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,f)=>{const d=n===1?0:f/n,h=n===1?1:(f+1)/n,b=l+(i-l)*d,u=l+(i-l)*h;return{...c,index:f,y:r.topY+f*(o+r.gap),h:o,topW:b,bottomW:u,cx:r.cx}})}function Np({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:f}=e,d=a-i/2,h=a+i/2,b=a-c/2,u=a+c/2,p=o+l,v=Math.max(4,Math.min(14,l*.18)),w=Na(f,"#000",r?.12:.22),g=Na(f,"#fff",r?.08:0),E=Na(f,"#fff",.22),y=[`M ${d} ${o}`,`L ${h} ${o}`,`L ${u} ${p}`,`L ${b} ${p}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:y,fill:w}),t.jsx("path",{d:[`M ${d} ${o}`,`L ${h} ${o}`,`L ${h} ${o+1}`,`L ${u} ${p}`,`L ${a} ${p}`,`L ${d} ${o}`,"Z"].join(" "),fill:g,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:v,fill:E,stroke:Na(f,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:v,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function kp({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:f="Sin datos para mostrar",showTooltip:d=!0,showLabels:h=!0,showValues:b=!0,showBottomArrow:u=!0,taper:p=.42,colors:v=[...Sn],animationDuration:w=fr,valueFormat:g=Lt,ariaLabel:E="Gráfico embudo"}){const[y,M]=s.useState(null),[L,C]=s.useState(!1),m=s.useMemo(()=>yp(e,r,n,a,o,v),[e,r,n,a,o,v]),k=s.useMemo(()=>m.map(j=>`${j.name}:${j.value}`).join("|"),[m]);if(s.useEffect(()=>{if(xp(),typeof window>"u")return;const j=window.matchMedia("(prefers-reduced-motion: reduce)");C(j.matches);const S=()=>C(j.matches);return j.addEventListener("change",S),()=>j.removeEventListener("change",S)},[]),c)return t.jsx(At,{height:l});if(!m.length)return t.jsx($t,{height:l,text:f});const N=w>0&&!L,_=w,q=Math.min(90,Math.max(40,Math.round(w/8))),K=Math.round(_*.15),$=m.length*q+Math.round(_*.35),Q=m.some(j=>j.title||j.description),X=h?160:24,se=Q?168:24,J=u?36:8,fe=X+220+se,te=l,z=18,R=Math.max(120,te-z-J-8),A=X+110,ue=wp(m,{cx:A,topY:z,plotH:R,maxTopW:200,taper:ec(p,.2,.95),gap:10}),P=y!=null?ue[y]: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 ${fe} ${te}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[h?t.jsx("line",{className:N?"bonsaif-funnel-label":void 0,style:N?{animation:`bonsaif-funnel-fade-in ${_}ms ${oe} both`}:void 0,x1:X-12,y1:z,x2:X-12,y2:z+R,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ue.map(j=>{const S=j.y+j.h/2,U=j.cx-j.topW/2,T=j.index*q,Y=N?{animation:`bonsaif-funnel-stage-in ${_}ms ${oe} ${T}ms both`}:void 0,ce=N?{animation:`bonsaif-funnel-fade-in ${Math.round(_*.85)}ms ${oe} ${T+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:Y,children:t.jsx(Np,{stage:j,hovered:y===j.index,onHover:M})}),h?t.jsxs("g",{className:"bonsaif-funnel-label",style:ce,children:[t.jsx("line",{x1:24,y1:S,x2:X-12,y2:S,stroke:j.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:X-12,y1:S,x2:U-6,y2:S,stroke:j.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:S-(b?6:0),textAnchor:"end",fill:j.color,fontSize:12,fontWeight:600,children:j.name.length>18?`${j.name.slice(0,16)}…`:j.name}),b?t.jsx("text",{x:20,y:S+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:g(j.value)}):null]}):null,(j.title||j.description)&&Q?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ce,children:[t.jsx("line",{x1:j.cx+j.bottomW/2+6,y1:S,x2:X+220+8,y2:S,stroke:j.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),j.title?t.jsx("text",{x:X+220+14,y:S-(j.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:j.title.length>22?`${j.title.slice(0,20)}…`:j.title}):null,j.description?t.jsx("text",{x:X+220+14,y:S+(j.title?10:0),fill:"var(--text-muted)",fontSize:11,children:j.description.length>28?`${j.description.slice(0,26)}…`:j.description}):null]}):null]},`${j.name}-${j.index}`)}),u?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${A}, ${z+R+8})`,fill:"var(--primary)",style:N?{animation:`bonsaif-funnel-arrow-in ${Math.round(_*.7)}ms ${oe} ${$}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]},k),d&&P?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:P.color},children:P.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),g(P.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(P.pct*100),"% del top)"]})]}):null]})}const Jr=135*Math.PI/180,rs=270*Math.PI/180;function Sp({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:f,valueFormat:d=Lt,tone:h="primary",color:b,thresholds:u,ariaLabel:p="Gauge",animationDuration:v=700,thickness:w=9,showScale:g=!1}){const E=s.useId().replace(/:/g,""),y=n-r||1,M=Math.min(1,Math.max(0,(e-r)/y)),[L,C]=s.useState(v>0?0:M);if(s.useEffect(()=>{if(l||i)return;if(v<=0){C(M);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){C(M);return}let fe=0,te=0;C(A=>(te=A,A));const z=performance.now(),R=A=>{const F=Math.min(1,(A-z)/v),ue=1-(1-F)**3;C(te+(M-te)*ue),F<1&&(fe=requestAnimationFrame(R))};return fe=requestAnimationFrame(R),()=>cancelAnimationFrame(fe)},[M,v,l,i]),l)return t.jsx(At,{height:a});if(i)return t.jsx($t,{height:a,text:c});const m=100,k=108,N=72,_=b??Cp(e,n,h,u),q=r+L*y,K=tc(m,k,N,Jr,Jr+rs),$=Jr+Math.max(.001,L)*rs,Q=tc(m,k,N,Jr,$),X=ka(m,k,N,Jr),se=ka(m,k,N,Jr+rs);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":p,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${E}`,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:w,strokeLinecap:"butt"}),t.jsx("path",{d:Q,fill:"none",stroke:`url(#bonsaif-gauge-${E})`,strokeWidth:w,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:m,y:k-(f?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:d(q)}),f?t.jsx("text",{x:m,y:k+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:f}):null,g?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:X.x-2,y:X.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:d(r)}),t.jsx("text",{x:se.x+2,y:se.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:d(n)})]}):null]})})}function Cp(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,f)=>c.value-f.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return Kt(n);const o=e/(r||1);return o>=.8?Kt("success"):o>=.5?Kt("warning"):Kt("danger")}function ka(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function tc(e,r,n,a,o){const l=ka(e,r,n,a),i=ka(e,r,n,o),c=o-a,f=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${f} 1 ${i.x} ${i.y}`}function Ep({value:e,target:r,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:f="Sin datos para mostrar",label:d,subtitle:h,valueFormat:b=Lt,tone:u="primary",showScale:p=!0,showStatus:v=!0,ariaLabel:w="Bullet chart"}){if(i)return t.jsx(At,{height:o});if(c)return t.jsx($t,{height:o,text:f});const g=n??Math.max(e,r,...(a==null?void 0:a.map(_=>_.value))??[],1)*1.05,y=[...a??[{value:g*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:g*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:g,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((_,q)=>_.value-q.value),M=Kt(u),L=Math.min(100,Math.max(0,e/g*100)),C=Math.min(100,Math.max(0,r/g*100)),m=e>=r,k=[0,.25,.5,.75,1].map(_=>_*g),N=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,d?28:o*.42)},role:"img","aria-label":w,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:y.map((_,q)=>{const K=q===0?0:y[q-1].value,$=Math.max(0,(_.value-K)/g*100);return t.jsx("div",{style:{width:`${$}%`,background:_.color??`color-mix(in srgb, var(--border) ${70-q*18}%, transparent)`}},q)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${L}%`,background:M,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${M} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${C}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:M,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),p?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:k.map((_,q)=>{const K=_/g*100,$=q===0,Q=q===k.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${K}%`,transform:$?"none":Q?"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:$?0:Q?"auto":void 0,marginRight:Q?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:$?"left":Q?"right":"center"},children:b(_)})]},_)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:d?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:d}),h?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:h}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:M,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),v?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Kt(m?"success":"warning")},children:m?"En meta":"Bajo meta"}):null]}),N]}):N})}function Mp({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:o,cores:l,height:i=220,className:c="",loading:f=!1,emptyText:d="Sin datos de CPU",showLegend:h=!1,showTooltip:b=!0,thresholds:u,label:p="CPU",ariaLabel:v="Uso de CPU"}){var C;const w=o??[{key:a,label:"Uso",color:Cn(r??Zr(e,a)??0,u)}],g=r??Zr(e,a)??Zr(e,((C=w[0])==null?void 0:C.key)??a),E=!f&&(!e.length||g===null);if(f)return t.jsx(At,{height:i});if(E)return t.jsx($t,{height:i,text:d});const y=Math.min(100,Math.max(0,g??0)),M=ma(y,u),L=Cn(y,u);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[p,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:L},children:Gr(y,y<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:L,background:`color-mix(in srgb, ${L} 14%, transparent)`},children:M==="danger"?"Crítico":M==="warning"?"Alto":"Normal"})]}),t.jsx(wa,{data:e,xKey:n,series:w.map(m=>({...m,color:m.color??L})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:h,showTooltip:b,valueFormat:m=>Gr(m,0),ariaLabel:v,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Tp({used:e,total:r,cached:n,data:a=[],timeKey:o="t",usageKey:l="usage",height:i=220,className:c="",loading:f=!1,emptyText:d="Sin datos de memoria",showHistory:h=!0,showTooltip:b=!0,thresholds:u,label:p="RAM",ariaLabel:v="Uso de memoria"}){const w=r>0?r:1,g=Math.min(100,Math.max(0,e/w*100)),E=!f&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(f)return t.jsx(At,{height:i});if(E)return t.jsx($t,{height:i,text:d});const y=ma(g,u),M=Cn(g,u),L=Math.max(0,r-e),C=a.length>0?Zr(a,l)??g:g,m=Cn(C,u),k=h&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:p}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:M},children:Gr(g,g<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Kr(e)," / ",Kr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:M,background:`color-mix(in srgb, ${M} 14%, transparent)`},children:y==="danger"?"Crítico":y==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(g),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${p} ${Gr(g,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${M}, color-mix(in srgb, ${M} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Kr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Kr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Kr(L)]})]})]}),h&&a.length>1?t.jsx(wa,{data:a,xKey:o,series:[{key:l,label:"Uso",color:m}],height:k,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:N=>Gr(N,0),ariaLabel:`${v} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Lp="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Ap="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function $p({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:o,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:f="Salida",inboundColor:d=Lp,outboundColor:h=Ap,height:b=240,className:u="",loading:p=!1,emptyText:v="Sin datos de red",showLegend:w=!1,showTooltip:g=!0,label:E="Network",ariaLabel:y="Tráfico de red"}){const M=o??Zr(e,n)??0,L=l??Zr(e,a)??0,C=!p&&e.length===0;if(p)return t.jsx(At,{height:b});if(C)return t.jsx($t,{height:b,text:v});const m=_=>Xi(_,i),N=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${u}`,role:"group","aria-label":y,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:d},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:d},title:m(M),children:m(M)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:h},"aria-hidden":!0}),f]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:h},title:m(L),children:m(L)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(wa,{data:e,xKey:r,series:[{key:n,label:c,color:d},{key:a,label:f,color:h}],height:N,showLegend:w,showTooltip:g,valueFormat:m,ariaLabel:y,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const rc=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],nc=["primeSuiteOrigin","primeSuiteProjectKey"];function Dp(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of rc){const n=e.get(r);if(n){const a=Sa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of nc){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=Sa(n);if(a)return a}}if(document.referrer){const r=Sa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Hp(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of rc)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of nc)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=Sa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function Sa(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 Op(e){const[r,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(d=>a||r[d]?e[d]:void 0,[e,a,r]),i=s.useCallback(d=>{n(h=>({...h,[d]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),f=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:f}}Object.defineProperty(I,"toast",{enumerable:!0,get:()=>Ya.toast}),I.Accordion=th,I.Alert=ed,I.AreaChart=wa,I.AudioPlayer=ch,I.AuthShell=zi,I.AutoGrowTextarea=mi,I.AutoGrowTextareaField=Eb,I.AvatarGroup=Nh,I.BarChart=dp,I.BonsaifButton=Ic,I.BonsaifUIToaster=ap,I.BulletChart=Ep,I.Button=Ke,I.CHART_PALETTE=Sn,I.CalendarPicker=od,I.ChartCard=op,I.Checkbox=_n,I.CodeBlock=Xd,I.ComboChart=pp,I.CommandPalette=Lh,I.CompactFilterSelect=Gd,I.CompactSearchInput=Yd,I.ConfirmDialog=Jd,I.ContextMenu=kh,I.CopyButton=co,I.CopyLinkButton=ru,I.CpuChart=Mp,I.DataSheets=cu,I.DataTable=no,I.DateRangePicker=hu,I.DonutChart=fp,I.Drawer=Su,I.DropdownMenu=Nu,I.DynamicDetailTabs=Jc,I.EmailField=Yu,I.EmptyState=Xn,I.EventCalendar=_d,I.FieldHelperFooter=Pr,I.FieldLabelInfo=Fr,I.FieldLayoutEditor=Ru,I.FileUpload=Qu,I.FilterChips=Th,I.FormField=Rn,I.FunnelChart=kp,I.GaugeChart=Sp,I.GlobalScrollbars=_i,I.ImageLightbox=wl,I.ImageLightboxHost=uf,I.InputField=yo,I.KpiCard=Jb,I.LineChart=cp,I.LoadingState=Ms,I.MentionTextEditor=bi,I.MicroserviceFrame=Rh,I.Modal=uo,I.MouseTooltip=Vt,I.MultiDateCalendar=gu,I.MultiSelect=pf,I.NetworkChart=$p,I.NumberField=mf,I.PageHeader=Zh,I.PageSearchInput=Ns,I.Pagination=vf,I.PhoneField=yf,I.PieChart=up,I.Popover=eh,I.PrimeAuthRouteShell=Qh,I.PrimeSuiteChatFrame=ep,I.Progress=Ch,I.PropertyList=Mh,I.RadioGroup=wf,I.RamChart=Tp,I.RichTextEditor=ub,I.SearchableSelect=vr,I.SectionPanel=fb,I.SegmentedControl=rh,I.Sparkline=hp,I.SpotlightTour=Fh,I.StatusBadge=pb,I.StatusSelect=yb,I.StepWizard=Nb,I.TableSkeleton=Pn,I.Tabs=wb,I.TagInput=Bb,I.TextInput=Jn,I.Textarea=gi,I.TextareaField=$b,I.TimeField=Ub,I.TimePicker=Si,I.Timeline=Zb,I.Toggle=$h,I.Tooltip=Ei,I.TransferList=Eh,I.TreeList=Kb,I.TruncatedWithTooltip=Rt,I.UserAvatar=Qo,I.VideoPlayer=dh,I.WORKDAY_LABELS=Ks,I.WaterfallChart=mp,I.YearMultiDateCalendar=xu,I.buildMentionQueryRegex=Yl,I.chunkMonthWeeks=so,I.chunkMonthWorkWeeks=Vs,I.clearMentionChipSelection=Ur,I.cn=We,I.computeWeekBars=lo,I.configureBonsaifUI=ud,I.copyRichCodeBlockFromButton=Tl,I.copyTextToClipboard=io,I.dedupeMentions=Jl,I.defaultValueFormat=Lt,I.deleteEditorSelection=li,I.describeParentTargetOrigin=Hp,I.emailFormat=Au,I.ensureMentionChipTrailingSpaces=yn,I.extractMentionUsernames=Fo,I.filterSelfMentions=ab,I.filterWorkdays=Yn,I.findMentionChipAfterCaret=ci,I.findMentionChipBeforeCaret=ii,I.findMentionChipsInSelection=jo,I.findMentionTriggerInEditor=Io,I.formatBytes=Kr,I.formatPercent=Gr,I.formatRate=Xi,I.getBonsaifUIConfig=fd,I.getDataTablePreferencesEndpoint=eo,I.getEditorPlainText=Wo,I.getMonthGrid=oo,I.getPlainTextOffset=ia,I.getWeekDays=ao,I.getWorkWeekDays=Us,I.groupItemsByDay=Xs,I.highlightMentions=Rl,I.htmlToText=Zl,I.insertMentionInEditor=ti,I.isMentionTriggerBoundary=Kl,I.isPlainOffsetInsideMentionChip=Gl,I.isValidEmail=go,I.isValidPhone=vo,I.isWeekend=qs,I.locateTextOffset=qr,I.makeRichCodeBlockHtml=Al,I.markRichCodeCopyButtonCopied=Ll,I.matches=Bu,I.maxLength=Hu,I.maxValue=Iu,I.mentionDisplayLabel=Ql,I.minLength=Du,I.minValue=Ou,I.normalizeUsername=Bo,I.openImageLightboxFromEvent=xl,I.phoneCountryCodeOptions=Sl,I.phoneFormat=$u,I.placeCaretAfterMentionChip=_o,I.placeCaretAtTextOffset=ri,I.preferredMentionSpacer=Po,I.removeMentionChip=ua,I.required=Lu,I.resetBonsaifUIConfig=bd,I.resolveMentions=nb,I.resolveParentTargetOrigin=Dp,I.richCodeBlockPlainText=Ml,I.richCodeCopyButtonHtml=El,I.selectAllEditorContents=oi,I.selectMentionChip=ai,I.selectionIncludesNonChipText=si,I.seriesColor=Vi,I.setBonsaifDataTablePreferencesEndpoint=hd,I.syncMentionChipSelectionHighlight=da,I.toDateKey=Xt,I.toNearestWorkday=$d,I.toneColor=Kt,I.usageColor=Cn,I.usageTone=ma,I.useSpotlightTour=Ph,I.useValidationVisibility=Op,I.validateForm=Fu,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
|
|
99
|
+
`;function pm(){if(typeof document>"u"||document.getElementById(Bc))return;const e=document.createElement("style");e.id=Bc,e.textContent=hm,document.head.appendChild(e)}function Pc(e,r,n){return Math.min(n,Math.max(r,e))}function Aa(e,r,n){const a=Pc(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function mm(e,r,n,a,o,l){const i=e.map((f,d)=>{const h=Kr(f[n])??0,b=String(f[r]??""),u=a?String(f[a]??"").trim():"",p=o?String(f[o]??"").trim():"";return{name:b,value:h,color:l[d%l.length],...u?{title:u}:{},...p?{description:p}:{}}}).filter(f=>f.value>0&&f.name),c=Math.max(...i.map(f=>f.value),1);return i.map(f=>({...f,pct:f.value/c}))}function gm(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,f)=>{const d=n===1?0:f/n,h=n===1?1:(f+1)/n,b=l+(i-l)*d,u=l+(i-l)*h;return{...c,index:f,y:r.topY+f*(o+r.gap),h:o,topW:b,bottomW:u,cx:r.cx}})}function vm({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:f}=e,d=a-i/2,h=a+i/2,b=a-c/2,u=a+c/2,p=o+l,g=Math.max(4,Math.min(14,l*.18)),w=Aa(f,"#000",r?.12:.22),v=Aa(f,"#fff",r?.08:0),E=Aa(f,"#fff",.22),y=[`M ${d} ${o}`,`L ${h} ${o}`,`L ${u} ${p}`,`L ${b} ${p}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:y,fill:w}),t.jsx("path",{d:[`M ${d} ${o}`,`L ${h} ${o}`,`L ${h} ${o+1}`,`L ${u} ${p}`,`L ${a} ${p}`,`L ${d} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:E,stroke:Aa(f,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function xm({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:f="Sin datos para mostrar",showTooltip:d=!0,showLabels:h=!0,showValues:b=!0,showBottomArrow:u=!0,taper:p=.42,colors:g=[...Mn],animationDuration:w=br,valueFormat:v=Lt,ariaLabel:E="Gráfico embudo"}){const[y,T]=s.useState(null),[L,C]=s.useState(!1),m=s.useMemo(()=>mm(e,r,n,a,o,g),[e,r,n,a,o,g]),S=s.useMemo(()=>m.map(q=>`${q.name}:${q.value}`).join("|"),[m]);if(s.useEffect(()=>{if(pm(),typeof window>"u")return;const q=window.matchMedia("(prefers-reduced-motion: reduce)");C(q.matches);const k=()=>C(q.matches);return q.addEventListener("change",k),()=>q.removeEventListener("change",k)},[]),c)return t.jsx($t,{height:l});if(!m.length)return t.jsx(Dt,{height:l,text:f});const N=w>0&&!L,_=w,U=Math.min(90,Math.max(40,Math.round(w/8))),K=Math.round(_*.15),D=m.length*U+Math.round(_*.35),Z=m.some(q=>q.title||q.description),O=h?160:24,ne=Z?168:24,ee=u?36:8,fe=O+220+ne,J=l,W=18,R=Math.max(120,J-W-ee-8),$=O+110,ue=gm(m,{cx:$,topY:W,plotH:R,maxTopW:200,taper:Pc(p,.2,.95),gap:10}),z=y!=null?ue[y]:null,se="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 ${fe} ${J}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[h?t.jsx("line",{className:N?"bonsaif-funnel-label":void 0,style:N?{animation:`bonsaif-funnel-fade-in ${_}ms ${se} both`}:void 0,x1:O-12,y1:W,x2:O-12,y2:W+R,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ue.map(q=>{const k=q.y+q.h/2,V=q.cx-q.topW/2,M=q.index*U,Y=N?{animation:`bonsaif-funnel-stage-in ${_}ms ${se} ${M}ms both`}:void 0,ce=N?{animation:`bonsaif-funnel-fade-in ${Math.round(_*.85)}ms ${se} ${M+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:Y,children:t.jsx(vm,{stage:q,hovered:y===q.index,onHover:T})}),h?t.jsxs("g",{className:"bonsaif-funnel-label",style:ce,children:[t.jsx("line",{x1:24,y1:k,x2:O-12,y2:k,stroke:q.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:O-12,y1:k,x2:V-6,y2:k,stroke:q.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:k-(b?6:0),textAnchor:"end",fill:q.color,fontSize:12,fontWeight:600,children:q.name.length>18?`${q.name.slice(0,16)}…`:q.name}),b?t.jsx("text",{x:20,y:k+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(q.value)}):null]}):null,(q.title||q.description)&&Z?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ce,children:[t.jsx("line",{x1:q.cx+q.bottomW/2+6,y1:k,x2:O+220+8,y2:k,stroke:q.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),q.title?t.jsx("text",{x:O+220+14,y:k-(q.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:q.title.length>22?`${q.title.slice(0,20)}…`:q.title}):null,q.description?t.jsx("text",{x:O+220+14,y:k+(q.title?10:0),fill:"var(--text-muted)",fontSize:11,children:q.description.length>28?`${q.description.slice(0,26)}…`:q.description}):null]}):null]},`${q.name}-${q.index}`)}),u?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${$}, ${W+R+8})`,fill:"var(--primary)",style:N?{animation:`bonsaif-funnel-arrow-in ${Math.round(_*.7)}ms ${se} ${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]},S),d&&z?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:z.color},children:z.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(z.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(z.pct*100),"% del top)"]})]}):null]})}const en=135*Math.PI/180,ds=270*Math.PI/180;function ym({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:f,valueFormat:d=Lt,tone:h="primary",color:b,thresholds:u,ariaLabel:p="Gauge",animationDuration:g=700,thickness:w=9,showScale:v=!1}){const E=s.useId().replace(/:/g,""),y=n-r||1,T=Math.min(1,Math.max(0,(e-r)/y)),[L,C]=s.useState(g>0?0:T);if(s.useEffect(()=>{if(l||i)return;if(g<=0){C(T);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){C(T);return}let fe=0,J=0;C($=>(J=$,$));const W=performance.now(),R=$=>{const P=Math.min(1,($-W)/g),ue=1-(1-P)**3;C(J+(T-J)*ue),P<1&&(fe=requestAnimationFrame(R))};return fe=requestAnimationFrame(R),()=>cancelAnimationFrame(fe)},[T,g,l,i]),l)return t.jsx($t,{height:a});if(i)return t.jsx(Dt,{height:a,text:c});const m=100,S=108,N=72,_=b??wm(e,n,h,u),U=r+L*y,K=_c(m,S,N,en,en+ds),D=en+Math.max(.001,L)*ds,Z=_c(m,S,N,en,D),O=La(m,S,N,en),ne=La(m,S,N,en+ds);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":p,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${E}`,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:w,strokeLinecap:"butt"}),t.jsx("path",{d:Z,fill:"none",stroke:`url(#bonsaif-gauge-${E})`,strokeWidth:w,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:m,y:S-(f?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:d(U)}),f?t.jsx("text",{x:m,y:S+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:f}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:O.x-2,y:O.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:d(r)}),t.jsx("text",{x:ne.x+2,y:ne.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:d(n)})]}):null]})})}function wm(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,f)=>c.value-f.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return Zt(n);const o=e/(r||1);return o>=.8?Zt("success"):o>=.5?Zt("warning"):Zt("danger")}function La(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function _c(e,r,n,a,o){const l=La(e,r,n,a),i=La(e,r,n,o),c=o-a,f=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${f} 1 ${i.x} ${i.y}`}function Nm({value:e,target:r,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:f="Sin datos para mostrar",label:d,subtitle:h,valueFormat:b=Lt,tone:u="primary",showScale:p=!0,showStatus:g=!0,ariaLabel:w="Bullet chart"}){if(i)return t.jsx($t,{height:o});if(c)return t.jsx(Dt,{height:o,text:f});const v=n??Math.max(e,r,...(a==null?void 0:a.map(_=>_.value))??[],1)*1.05,y=[...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((_,U)=>_.value-U.value),T=Zt(u),L=Math.min(100,Math.max(0,e/v*100)),C=Math.min(100,Math.max(0,r/v*100)),m=e>=r,S=[0,.25,.5,.75,1].map(_=>_*v),N=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,d?28:o*.42)},role:"img","aria-label":w,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:y.map((_,U)=>{const K=U===0?0:y[U-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-U*18}%, transparent)`}},U)})}),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:`${L}%`,background:T,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${T} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${C}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:T,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),p?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:S.map((_,U)=>{const K=_/v*100,D=U===0,Z=U===S.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${K}%`,transform:D?"none":Z?"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:Z?"auto":void 0,marginRight:Z?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":Z?"right":"center"},children:b(_)})]},_)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:d?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:d}),h?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:h}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:T,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),g?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Zt(m?"success":"warning")},children:m?"En meta":"Bajo meta"}):null]}),N]}):N})}function km({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:o,cores:l,height:i=220,className:c="",loading:f=!1,emptyText:d="Sin datos de CPU",showLegend:h=!1,showTooltip:b=!0,thresholds:u,label:p="CPU",ariaLabel:g="Uso de CPU"}){var C;const w=o??[{key:a,label:"Uso",color:Tn(r??Jr(e,a)??0,u)}],v=r??Jr(e,a)??Jr(e,((C=w[0])==null?void 0:C.key)??a),E=!f&&(!e.length||v===null);if(f)return t.jsx($t,{height:i});if(E)return t.jsx(Dt,{height:i,text:d});const y=Math.min(100,Math.max(0,v??0)),T=ka(y,u),L=Tn(y,u);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":g,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[p,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:L},children:Zr(y,y<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:L,background:`color-mix(in srgb, ${L} 14%, transparent)`},children:T==="danger"?"Crítico":T==="warning"?"Alto":"Normal"})]}),t.jsx(Ta,{data:e,xKey:n,series:w.map(m=>({...m,color:m.color??L})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:h,showTooltip:b,valueFormat:m=>Zr(m,0),ariaLabel:g,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Sm({used:e,total:r,cached:n,data:a=[],timeKey:o="t",usageKey:l="usage",height:i=220,className:c="",loading:f=!1,emptyText:d="Sin datos de memoria",showHistory:h=!0,showTooltip:b=!0,thresholds:u,label:p="RAM",ariaLabel:g="Uso de memoria"}){const w=r>0?r:1,v=Math.min(100,Math.max(0,e/w*100)),E=!f&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(f)return t.jsx($t,{height:i});if(E)return t.jsx(Dt,{height:i,text:d});const y=ka(v,u),T=Tn(v,u),L=Math.max(0,r-e),C=a.length>0?Jr(a,l)??v:v,m=Tn(C,u),S=h&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":g,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:p}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:T},children:Zr(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Qr(e)," / ",Qr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:T,background:`color-mix(in srgb, ${T} 14%, transparent)`},children:y==="danger"?"Crítico":y==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${p} ${Zr(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${T}, color-mix(in srgb, ${T} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Qr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Qr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Qr(L)]})]})]}),h&&a.length>1?t.jsx(Ta,{data:a,xKey:o,series:[{key:l,label:"Uso",color:m}],height:S,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:N=>Zr(N,0),ariaLabel:`${g} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Cm="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Em="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Mm({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:o,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:f="Salida",inboundColor:d=Cm,outboundColor:h=Em,height:b=240,className:u="",loading:p=!1,emptyText:g="Sin datos de red",showLegend:w=!1,showTooltip:v=!0,label:E="Network",ariaLabel:y="Tráfico de red"}){const T=o??Jr(e,n)??0,L=l??Jr(e,a)??0,C=!p&&e.length===0;if(p)return t.jsx($t,{height:b});if(C)return t.jsx(Dt,{height:b,text:g});const m=_=>Lc(_,i),N=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${u}`,role:"group","aria-label":y,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:d},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:d},title:m(T),children:m(T)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:h},"aria-hidden":!0}),f]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:h},title:m(L),children:m(L)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(Ta,{data:e,xKey:r,series:[{key:n,label:c,color:d},{key:a,label:f,color:h}],height:N,showLegend:w,showTooltip:v,valueFormat:m,ariaLabel:y,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const zc=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Wc=["primeSuiteOrigin","primeSuiteProjectKey"];function Tm(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of zc){const n=e.get(r);if(n){const a=$a(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Wc){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=$a(n);if(a)return a}}if(document.referrer){const r=$a(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Am(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of zc)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Wc)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=$a(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function $a(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 Lm(e){const[r,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(d=>a||r[d]?e[d]:void 0,[e,a,r]),i=s.useCallback(d=>{n(h=>({...h,[d]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),f=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:f}}Object.defineProperty(A,"toast",{enumerable:!0,get:()=>eo.toast}),A.Accordion=Qh,A.Alert=Zd,A.AreaChart=Ta,A.AudioPlayer=op,A.AuthShell=Sc,A.AutoGrowTextarea=ec,A.AutoGrowTextareaField=Nh,A.AvatarGroup=vp,A.BarChart=sm,A.BonsaifButton=xd,A.BonsaifUIToaster=em,A.BulletChart=Nm,A.Button=Ke,A.CHART_PALETTE=Mn,A.CalendarPicker=tu,A.ChartCard=tm,A.Checkbox=Xn,A.CodeBlock=ju,A.ComboChart=um,A.CommandPalette=Cp,A.CompactFilterSelect=Uu,A.CompactSearchInput=qu,A.ConfirmDialog=Gu,A.ContextMenu=xp,A.CopyButton=vo,A.CopyLinkButton=Ju,A.CpuChart=km,A.DataSheets=of,A.DataTable=fo,A.DateRangePicker=uf,A.DonutChart=im,A.Drawer=wf,A.DropdownMenu=xf,A.DynamicDetailTabs=Hd,A.EmailField=Uf,A.EmptyState=Rn,A.EventCalendar=Ou,A.FILE_TYPE_ICON_COLOR=bl,A.FILE_TYPE_ICON_KINDS=Xd,A.FieldHelperFooter=zr,A.FieldLabelInfo=_r,A.FieldLayoutEditor=Zf,A.FileAepIcon=Qs,A.FileAiIcon=Gs,A.FileAudioIcon=tl,A.FileAviIcon=al,A.FileCodeIcon=ul,A.FileCsvIcon=Us,A.FileDocIcon=js,A.FileDocfyIcon=fl,A.FileDocxIcon=jn,A.FileExcelIcon=qd,A.FileFigIcon=Ys,A.FileFolderIcon=zs,A.FileGenericIcon=no,A.FileImageIcon=Vd,A.FileImgIcon=Vn,A.FileInddIcon=Zs,A.FileJpgIcon=cl,A.FileMkvIcon=ol,A.FileMp3Icon=Rs,A.FileMp4Icon=rl,A.FileMpegIcon=nl,A.FilePdfIcon=Ws,A.FilePngIcon=dl,A.FilePowerpointIcon=Ud,A.FilePptIcon=Xs,A.FilePptxIcon=Un,A.FilePsdIcon=Ks,A.FileRarIcon=il,A.FileSvgIcon=Js,A.FileTxtIcon=qs,A.FileTypeIcon=Gd,A.FileUpload=Gf,A.FileVideoIcon=sl,A.FileWavIcon=el,A.FileWordIcon=jd,A.FileXlsIcon=Vs,A.FileXlsxIcon=qn,A.FileZipIcon=ll,A.FilterChips=Sp,A.FormField=sa,A.FunnelChart=xm,A.GaugeChart=ym,A.GlobalScrollbars=kc,A.ImageLightbox=oi,A.ImageLightboxHost=lb,A.InputField=To,A.KpiCard=Gh,A.LineChart=om,A.LoadingState=Os,A.MentionTextEditor=Qi,A.MicroserviceFrame=Kp,A.Modal=xo,A.MouseTooltip=Xt,A.MultiDateCalendar=hf,A.MultiSelect=ub,A.NetworkChart=Mm,A.NumberField=fb,A.PageHeader=Xp,A.PageSearchInput=Ls,A.Pagination=hb,A.PhoneField=mb,A.PieChart=lm,A.Popover=Zh,A.PrimeAuthRouteShell=Yp,A.PrimeSuiteChatFrame=Zp,A.Progress=wp,A.PropertyList=kp,A.RadioGroup=gb,A.RamChart=Sm,A.RichTextEditor=lh,A.SearchableSelect=yr,A.SectionPanel=ih,A.SegmentedControl=Jh,A.Sparkline=dm,A.SpotlightTour=Ip,A.StatusBadge=uh,A.StatusSelect=mh,A.StepWizard=vh,A.TableSkeleton=Wn,A.Tabs=gh,A.TagInput=Dh,A.TextInput=oa,A.Textarea=tc,A.TextareaField=Mh,A.TimeField=zh,A.TimePicker=ic,A.Timeline=Xh,A.Toggle=Mp,A.Tooltip=dc,A.TransferList=Np,A.TreeList=Vh,A.TruncatedWithTooltip=er,A.UserAvatar=os,A.VideoPlayer=sp,A.WORKDAY_LABELS=Il,A.WaterfallChart=fm,A.YearMultiDateCalendar=mf,A.buildMentionQueryRegex=$i,A.chunkMonthWeeks=po,A.chunkMonthWorkWeeks=Al,A.clearMentionChipSelection=Xr,A.cn=Pe,A.computeWeekBars=mo,A.configureBonsaifUI=lu,A.copyRichCodeBlockFromButton=fi,A.copyTextToClipboard=go,A.createFilledIcon=xr,A.createIcon=Pd,A.dedupeMentions=Hi,A.defaultValueFormat=Lt,A.deleteEditorSelection=Vi,A.describeParentTargetOrigin=Am,A.emailFormat=Mf,A.ensureMentionChipTrailingSpaces=kn,A.extractMentionUsernames=Vo,A.filterSelfMentions=eh,A.filterWorkdays=ea,A.findMentionChipAfterCaret=Yi,A.findMentionChipBeforeCaret=Xi,A.findMentionChipsInSelection=Zo,A.findMentionTriggerInEditor=qo,A.formatBytes=Qr,A.formatPercent=Zr,A.formatRate=Lc,A.getBonsaifUIConfig=iu,A.getDataTablePreferencesEndpoint=io,A.getEditorPlainText=Ko,A.getMonthGrid=ho,A.getPlainTextOffset=pa,A.getWeekDays=bo,A.getWorkWeekDays=Tl,A.groupItemsByDay=Ll,A.highlightMentions=Bi,A.htmlToText=Fi,A.insertMentionInEditor=_i,A.isMentionTriggerBoundary=Ii,A.isPlainOffsetInsideMentionChip=Di,A.isValidEmail=Co,A.isValidPhone=Eo,A.isWeekend=Ml,A.locateTextOffset=Vr,A.makeRichCodeBlockHtml=hi,A.markRichCodeCopyButtonCopied=bi,A.matches=If,A.maxLength=Lf,A.maxValue=Df,A.mentionDisplayLabel=Oi,A.minLength=Af,A.minValue=$f,A.normalizeUsername=Uo,A.openImageLightboxFromEvent=ni,A.phoneCountryCodeOptions=ii,A.phoneFormat=Tf,A.placeCaretAfterMentionChip=Yo,A.placeCaretAtTextOffset=zi,A.preferredMentionSpacer=Xo,A.removeMentionChip=va,A.required=Ef,A.resetBonsaifUIConfig=cu,A.resolveIconSizePx=Ps,A.resolveMentions=Rb,A.resolveParentTargetOrigin=Tm,A.richCodeBlockPlainText=ui,A.richCodeCopyButtonHtml=di,A.selectAllEditorContents=qi,A.selectMentionChip=ji,A.selectionIncludesNonChipText=Ui,A.seriesColor=Ac,A.setBonsaifDataTablePreferencesEndpoint=du,A.syncMentionChipSelectionHighlight=ga,A.toDateKey=Yt,A.toNearestWorkday=Mu,A.toneColor=Zt,A.usageColor=Tn,A.usageTone=ka,A.useSpotlightTour=Fp,A.useValidationVisibility=Lm,A.validateForm=Ff,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
|