bonsaif-ui 0.1.138 → 0.1.140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bonsaif-ui.js +5394 -5360
- package/dist/bonsaif-ui.umd.cjs +21 -21
- package/dist/components/ui/EventCalendar.d.ts +3 -1
- package/dist/components/ui/EventCalendar.d.ts.map +1 -1
- package/dist/components/ui/SearchableSelect.d.ts +3 -1
- package/dist/components/ui/SearchableSelect.d.ts.map +1 -1
- package/dist/components/ui/eventCalendarUtils.d.ts +13 -0
- package/dist/components/ui/eventCalendarUtils.d.ts.map +1 -1
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/components/ui/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(q,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],s):(q=typeof globalThis<"u"?globalThis:q||self,s(q.BonsaifUI={},q.React,q.jsxRuntime,q.ReactIconsHi2,q.ReactDOM,q.Recharts,q.OverlayScrollbarsGlobal,q.Sonner,q.OverlayScrollbarsReact,q.ReactDayPicker,q.ReactDayPickerStyles,q.ReactIconsFi))})(this,(function(q,s,t,j,gt,Me,Oa,Ha,Zo,Ia,Im,Zi){"use strict";"use client";function Qt(...e){return e.filter(Boolean).join(" ")}function Qi({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Qt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function Qo({value:e,onChange:r,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=s.useRef(null),[m,b]=s.useState(!1),f=l||m||e.trim().length>0,g=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",p=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=u.current)==null||v.focus())},[o]);const E=()=>{var v;b(!0),(v=u.current)==null||v.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?p:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),E())},children:[t.jsx(j.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${g} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${f?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:f?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:v=>{b(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{b(!1),v.currentTarget.style.borderColor="var(--border)",v.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Jo=s.createContext({});let Ro=0;const es="bonsaif-ui:hide-tooltips";function Sn(e=700){Ro=Date.now()+e}function Ji(){return Date.now()>Ro}function En(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function Ri(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(o=>{var l;return o.scrollWidth>o.clientWidth&&!!((l=o.textContent)!=null&&l.trim())&&o.tagName.toLowerCase()!=="svg"&&!o.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function Bt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:b="div"}){const f=s.useRef(null),g=s.useRef(null),p=s.useRef(null),E=s.useRef(!1),[v,w]=s.useState(null),[A,C]=s.useState("");s.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(G=>{const V=G.getAttribute("title");V&&(G.getAttribute("aria-label")||G.setAttribute("aria-label",V),G.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(G=>G.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const D=g.current;if(!D)return;const G=12,V=14,ne=D.getBoundingClientRect(),J=window.innerWidth-ne.width-G,R=window.innerHeight-ne.height-G;let U=v.mouseX+V,Y=v.mouseY+V,ce,L;if(!o&&f.current){const B=f.current.getBoundingClientRect(),le=B.left+B.width/2,O=B.top+B.height/2;l==="top"?(U=le-ne.width/2,Y=B.top-ne.height-V,L=ne.height-1):l==="left"?(U=B.left-ne.width-V,Y=O-ne.height/2,ce=ne.width-1):l==="right"?(U=B.right+V,Y=O-ne.height/2,ce=-7):(U=le-ne.width/2,Y=B.bottom+V,L=-7)}if(o&&(U>J&&(U=v.mouseX-ne.width-V),Y>R&&(Y=v.mouseY-ne.height-V)),U=Math.min(Math.max(G,U),Math.max(G,J)),Y=Math.min(Math.max(G,Y),Math.max(G,R)),!o&&f.current){const B=f.current.getBoundingClientRect(),le=B.left+B.width/2,O=B.top+B.height/2;l==="top"||l==="bottom"?ce=Math.min(Math.max(14,le-U),ne.width-14):L=Math.min(Math.max(14,O-Y),ne.height-14)}(Math.abs(U-v.x)>.5||Math.abs(Y-v.y)>.5||ce!==v.arrowX||L!==v.arrowY)&&w(B=>B&&{...B,x:U,y:Y,arrowX:ce,arrowY:L})},[o,l,v]);const H=()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},k=(D,G)=>{if(!Ji()||E.current)return;const V=f.current;if(V&&!En(V)){if(n){const ne=Ri(V);if(!ne)return;C(ne)}!n&&!r||w({mouseX:D,mouseY:G,x:D+14,y:G+14})}},x=()=>{const D=f.current;if(!D)return;const G=D.getBoundingClientRect();k(G.left+G.width/2,G.bottom)},M=()=>{H(),w(null)},N=()=>{if(!a){M();return}H(),p.current=window.setTimeout(()=>w(null),120)},z=()=>{Sn(),E.current=!0,M()},X=()=>{E.current=!1};s.useEffect(()=>{if(!v)return;if(En(f.current)){w(null);return}const D=()=>w(null),G=()=>{Sn(),E.current=!0,w(null)};document.addEventListener("pointerdown",G,!0),document.addEventListener("click",G,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const V=new MutationObserver(()=>{En(f.current)&&w(null)});return V.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",G,!0),document.removeEventListener("click",G,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),V.disconnect()}},[v]),s.useEffect(()=>{const D=()=>Sn(),G=()=>{Sn(),E.current=!0,w(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(es,G),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(es,G)}},[]);const K=n?A:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{H(),X(),o?k(D.clientX,D.clientY):x()},onMouseMove:D=>{v&&o&&k(D.clientX,D.clientY)},onMouseDown:z,onClick:z,onMouseLeave:()=>{X(),N()},onFocus:x,onBlur:M,children:e}),v&&K&&!En(f.current)?gt.createPortal(t.jsxs("div",{ref:g,role:"tooltip",className:d,onMouseEnter:a?H: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",...m},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),K]}),document.body):null]})}function ts(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const ec="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",tc={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"},rc="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",nc={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"},ac={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},oc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ba(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ba).join(" ").trim():s.isValidElement(e)?Ba(e.props.children):""}function sc(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Qe({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const g=s.useContext(Jo),p=l??g.iconOnly??e==="icon",E=g.compact??!1,v=g.headerAction??!1,w=v&&r==="md"?"sm":E&&!v&&r==="md"?"xs":r,A=e==="icon"||p,C=v&&A,H=Ba(d),k=o??f.title??f["aria-label"]??(p?H:void 0),x=k?void 0:f.title,M=f["aria-label"]??(typeof k=="string"?k:H||void 0),N=n?null:a??(p?sc(d):null),z=t.jsxs("button",{...f,title:x,"aria-label":M,"data-variant":e,"data-size":w,"data-icon":A?"true":void 0,disabled:m||n,className:`${ec} ${C?rc:tc[e]} ${A?ac[w]:nc[w]} ${E&&!A?"px-2.5":""} ${u}`,style:{...oc[e],height:ts(i),padding:ts(c),...b,...v&&!A?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...C?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):N,!p&&d]});return k?t.jsx(Bt,{as:"span",content:k,className:"inline-flex shrink-0",children:z}):z}const vt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Cn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=o?"px-2 py-2":"px-3 py-2.5",u=o?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:vt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:vt})]}),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:vt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:vt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...vt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,g)=>t.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...vt,width:`${46+(b*13+g*11)%42}%`,minWidth:28}})},`c-${b}-${g}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:vt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:vt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:vt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:vt})]})]})}function lc({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 ic({logoSrc:e,logoAlt:r}){return e?t.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[t.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),t.jsx("img",{src:e,alt:r,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function rs({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(Cn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(cc,{rows:i});if(e==="cards")return t.jsx(dc,{rows:i});const m=o||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(ic,{logoSrc:a,logoAlt:m}):null,t.jsx(lc,{size:b?"md":"sm"}),t.jsxs("div",{className:b?"space-y-1.5":"",children:[t.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f})}function cc({rows:e}){return t.jsx(Cn,{rows:e,columns:7})}function dc({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:vt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:vt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:vt})]},n))})}function ns(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function as(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function uc(e){return[e.label,ns(e.service),e.description,e.service].filter(Boolean).join(" ")}function fc(e){return typeof e=="function"?e:e.default}function bc(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(Qe,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function mc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:p,emptyState:E,loadingState:v,errorState:w=bc,renderTabLabel:A,searchableTabs:C="auto",tabsSearchThreshold:H=6,tabsSearchPlaceholder:k="Buscar modulo...",tabsSearchValue:x,onTabsSearchChange:M,emptySearchState:N,showTabCount:z=!0,className:X="",parentClassName:K="",contentClassName:D="",tabsClassName:G=""}){var Ye;const V=s.useMemo(()=>l.filter(ie=>!ie.hidden&&((b==null?void 0:b(ie,o))??!0)),[b,o,l]),ne=(Ye=V.find(ie=>!ie.disabled))==null?void 0:Ye.service,[J,R]=s.useState(u??ne??""),[U,Y]=s.useState({}),[ce,L]=s.useState({}),[B,le]=s.useState(""),[O,ae]=s.useState(!1),S=s.useRef(ce),ee=s.useRef(0),_=x??B,I=as(_),de=C===!0||C==="auto"&&V.length>=H,re=de&&_.trim().length>0,F=s.useMemo(()=>I?V.filter(ie=>as(uc(ie)).includes(I)):V,[I,V]),y=d??J,T=V.find(ie=>ie.service===y)??V.find(ie=>!ie.disabled);s.useEffect(()=>{!T&&ne&&R(ne)},[ne,T]),s.useEffect(()=>{S.current=ce},[ce]);const te=ie=>{ie.disabled||(d||R(ie.service),m==null||m(ie.service,ie))},fe=ie=>{x===void 0&&le(ie),M==null||M(ie)},se=(ie,Se)=>{const _e=F.filter(Ke=>!Ke.disabled),ot=_e.findIndex(Ke=>Ke.service===Se.service);ot<0||((ie.key==="ArrowRight"||ie.key==="ArrowDown")&&(ie.preventDefault(),te(_e[(ot+1)%_e.length])),(ie.key==="ArrowLeft"||ie.key==="ArrowUp")&&(ie.preventDefault(),te(_e[(ot-1+_e.length)%_e.length])),ie.key==="Home"&&(ie.preventDefault(),te(_e[0])),ie.key==="End"&&(ie.preventDefault(),te(_e[_e.length-1])))},he=s.useCallback(()=>{if(!T)return;const ie=T.service,Se=S.current[ie];if(Se!=null&&Se.loading||Se!=null&&Se.component&&f)return;const _e=(i==null?void 0:i[ie])??c;if(!_e){L(Ke=>({...Ke,[ie]:{loading:!1,error:new Error(`No module loader found for service "${ie}".`)}}));return}const ot=++ee.current;L(Ke=>({...Ke,[ie]:{...Ke[ie],loading:!0,error:void 0}})),_e(T,o).then(Ke=>{if(ot!==ee.current&&!f)return;const lt=fc(Ke);L(ct=>({...ct,[ie]:{component:lt,loading:!1}}))}).catch(Ke=>{const lt=Ke instanceof Error?Ke:new Error(String(Ke));L(ct=>({...ct,[ie]:{...ct[ie],loading:!1,error:lt}}))})},[o,f,c,i,T]);s.useEffect(he,[he]);const Ae=T?U[T.service]??null:null,De=T?ce[T.service]:void 0,ue=De==null?void 0:De.component,Te=ie=>{T&&Y(Se=>({...Se,[T.service]:ie}))},He=()=>{T&&Y(ie=>({...ie,[T.service]:null}))},Xe={context:o,parent:a,links:l,visibleLinks:V,filteredLinks:F,selectedLink:T,selectedService:T==null?void 0:T.service,activeItemId:Ae,tabsSearch:_,onSelectService:te,onOpenDetail:Te,onBackToList:He},je=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)] ${X}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${K}`,children:je}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(g||p||de||z)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[g&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:g}),p&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:p})]}),(de||z)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[z&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[F.length," / ",V.length]}),de&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${O?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!O,children:t.jsx(Qo,{value:_,onChange:fe,placeholder:k,className:"w-full",autoFocus:O,forceExpanded:!0,onEscape:()=>ae(!1),size:"sm",inputTabIndex:O?0:-1})}),t.jsx("button",{type:"button","aria-label":O?"Cerrar busqueda":"Buscar tabs","aria-expanded":O,onClick:()=>{O&&_&&fe(""),ae(ie=>!ie)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${O||re?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:O||re?t.jsx(j.HiXMark,{className:"h-4 w-4"}):t.jsx(j.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":g??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${G}`,children:F.length>0?F.map(ie=>{const Se=ie.service===(T==null?void 0:T.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Se,disabled:ie.disabled,onClick:()=>te(ie),onKeyDown:_e=>se(_e,ie),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Se?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:A?A(ie,Se):t.jsxs(t.Fragment,{children:[ie.icon,t.jsx("span",{children:ie.label??ns(ie.service)}),ie.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ie.badge})]})},ie.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:N??"No hay modulos que coincidan con la busqueda."})}),(T==null?void 0:T.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:T.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!T&&(E??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),T&&(De==null?void 0:De.loading)&&(v??t.jsx(rs,{title:"Cargando modulo..."})),T&&(De==null?void 0:De.error)&&w(De.error,he),T&&ue&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(ue,{context:o,parent:a,link:T,activeItemId:Ae,onOpenDetail:Te,onBackToList:He})]})]})]})}const hc={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(j.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(j.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(j.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(j.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(j.HiInformationCircle,{className:"h-5 w-5"})}};function pc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=hc[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(Qe,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]})}const os=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],gc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],vc=["lu","ma","mi","ju","vi","sá","do"],ss=6;function Fa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function xc(){const e=new Date;return Fa(e.getFullYear(),e.getMonth()+1,e.getDate())}function ls(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function yc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=ls(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${os[n-1]} ${r}`}function wc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=xc(),c=ls(e||l),d=a==="popover",[u,m]=s.useState(!1),b=s.useRef(null),[f,g]=s.useState({horizontal:"left",vertical:"bottom"}),[p,E]=s.useState(c.year),[v,w]=s.useState(c.month),[A,C]=s.useState("days"),H=16,[k,x]=s.useState(0),M=p-7+k,N=Array.from({length:H},(R,U)=>M+U);s.useEffect(()=>{if(!d||!u||!b.current)return;const R=b.current.getBoundingClientRect(),U=8,Y=280,ce=340,L=R.left+Y>window.innerWidth-U,B=R.right-Y>=U,le=R.bottom+8+ce>window.innerHeight-U,O=R.top-8-ce>=U;g({horizontal:L&&B?"right":"left",vertical:le&&O?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function R(Y){b.current&&(b.current.contains(Y.target)||m(!1))}function U(Y){Y.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",U)}},[d,u]);function z(){v===1?(E(R=>R-1),w(12)):w(R=>R-1)}function X(){v===12?(E(R=>R+1),w(1)):w(R=>R+1)}const K=(new Date(p,v-1,1).getDay()+6)%7,D=new Date(p,v,0).getDate(),G=[...Array(K).fill(null),...Array.from({length:D},(R,U)=>U+1)];for(;G.length<ss*7;)G.push(null);const V=G.slice(0,ss*7);function ne(R){const U=Fa(p,v,R);n&&U<n||(r(U),d&&m(!1))}const J=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${o}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:A==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:z,"aria-label":"Mes anterior",children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{C("years"),x(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[os[v-1]," ",p]}),t.jsx(j.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:X,"aria-label":"Mes siguiente",children:t.jsx(j.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(R=>R-H),"aria-label":"Años anteriores",children:t.jsx(j.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:[N[0]," – ",N[N.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(R=>R+H),"aria-label":"Años siguientes",children:t.jsx(j.HiChevronRight,{size:16})})]})}),A==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:gc.map((R,U)=>{const Y=U+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${Y?" is-active":""}`,onClick:()=>w(U+1),children:R},R)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:N.map(R=>{const U=R===p,Y=R===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${U?" is-active":""}${Y&&!U?" is-today":""}`,onClick:()=>{E(R),C("days")},children:R},R)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:vc.map(R=>t.jsx("div",{className:"bonsaif-multi-weekday",children:R},R))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:V.map((R,U)=>{if(R===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},U);const Y=Fa(p,v,R),ce=Y===e,L=Y===l,B=!!(n&&Y<n);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${L?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ce,onClick:()=>!B&&ne(R),children:R})},U)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(R=>!R),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(j.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:yc(e)})]}),t.jsx(j.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:J})]}):J}function Ut({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Bt,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Pa(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function _a(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Nc(e,r){if(!r.trim())return!0;const n=_a(r);return _a(e.label).includes(n)||!!(e.sublabel&&_a(e.sublabel).includes(n))}function dr({value:e,onChange:r,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:b,dropdownMinWidth:f,height:g=40,padding:p="0 10px",searchable:E=!0,minOptionsForSearch:v=6}){const[w,A]=s.useState(!1),[C,H]=s.useState(""),[k,x]=s.useState(-1),[M,N]=s.useState(!1),[z,X]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),V=s.useRef(null),ne=E&&n.length>=v,J=n.find(_=>_.value===e)??null,R=l==="ghost",U=a==="error"?"var(--danger)":w?"var(--primary)":"var(--border)",Y=ne&&C.trim()?n.filter(_=>Nc(_,C)):n,ce=s.useCallback(()=>{const _=K.current;if(!_)return;const I=_.getBoundingClientRect(),de=ne?272:212,re=window.innerHeight-I.bottom,F=re<de&&I.top>re;X({position:"fixed",left:I.left,top:F?void 0:I.bottom+4,bottom:F?window.innerHeight-I.top+4:void 0,width:I.width,minWidth:Pa(f),zIndex:9999})},[f,ne]);s.useEffect(()=>N(!0),[]),s.useEffect(()=>{if(!w)return;function _(I){var re,F;const de=I.target;!((re=K.current)!=null&&re.contains(de))&&!((F=D.current)!=null&&F.contains(de))&&(A(!1),H(""))}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[w]),s.useEffect(()=>{w&&(x(-1),ce(),ne&&setTimeout(()=>{var _;return(_=G.current)==null?void 0:_.focus()},0))},[w,ne,ce]),s.useEffect(()=>{if(w)return window.addEventListener("resize",ce),window.addEventListener("scroll",ce,!0),()=>{window.removeEventListener("resize",ce),window.removeEventListener("scroll",ce,!0)}},[w,ce]),s.useEffect(()=>{if(k<0||!V.current)return;const _=V.current.children[k];_==null||_.scrollIntoView({block:"nearest"})},[k]);const L=s.useCallback(_=>{r(_),A(!1),H("")},[r]),B=s.useRef(w);B.current=w;const le=s.useRef(Y);le.current=Y;const O=s.useRef(k);O.current=k;const ae=s.useRef(d);ae.current=d;const S=s.useRef(L);S.current=L,s.useEffect(()=>{function _(I){var y,T;const de=document.activeElement,re=((y=K.current)==null?void 0:y.contains(de))??!1,F=((T=D.current)==null?void 0:T.contains(de))??!1;if(!(!re&&!F)){if(!B.current){(I.key==="Enter"||I.key===" "||I.key==="ArrowDown")&&(I.preventDefault(),A(!0));return}switch(I.key){case"ArrowDown":I.preventDefault(),x(te=>Math.min(te+1,le.current.length-1));break;case"ArrowUp":I.preventDefault(),x(te=>Math.max(te-1,ae.current?-1:0));break;case"Enter":{I.preventDefault();const te=O.current,fe=le.current;te===-1&&ae.current?S.current(""):fe[te]&&!fe[te].disabled&&S.current(fe[te].value);break}case"Escape":I.preventDefault(),I.stopPropagation(),A(!1),H("");break}}}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[]);const ee=t.jsxs("div",{ref:D,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...z,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:C,onChange:_=>{H(_.target.value),x(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button",onMouseDown:_=>{_.preventDefault(),H("")},children:t.jsx(j.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:V,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ne?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:_=>{_.preventDefault(),L("")},onMouseEnter:()=>x(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:k===-1&&!C.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),Y.map((_,I)=>{const re=I===k,F=_.value===e;return t.jsxs("li",{role:"option","aria-selected":F,onMouseDown:y=>{y.preventDefault(),_.disabled||L(_.value)},onMouseEnter:()=>!_.disabled&&x(I),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:re?"var(--bg-hover)":F?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:_.disabled?"var(--text-muted)":"var(--text-main)",cursor:_.disabled?"not-allowed":"pointer",boxShadow:F?"inset 2px 0 0 var(--primary)":void 0},children:[_.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:_.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Ut,{className:"min-w-0 flex-1",children:_.label}),_.sublabel&&t.jsx(Ut,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:_.sublabel})]}),_.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:_.badge})]},_.value)}),Y.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:K,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&A(_=>!_),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Pa(g),padding:Pa(p),background:R?"transparent":"var(--bg-input)",color:J?"var(--text-main)":"var(--text-muted)",border:R?"1px solid transparent":`1px solid ${U}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":w,"aria-label":o,children:[(J==null?void 0:J.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:J.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:J?t.jsxs(t.Fragment,{children:[t.jsx(Ut,{className:"min-w-0 flex-1",children:J.label}),i&&J.sublabel&&t.jsx(Ut,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:J.sublabel})]}):t.jsx(Ut,{className:"min-w-0 flex-1",children:c})}),J&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:_=>{_.preventDefault(),_.stopPropagation(),L("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"w-3 h-3"})}):t.jsx(j.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:w?"rotate(180deg)":"rotate(0deg)"}})]}),w&&M&>.createPortal(ee,document.body)]})}const kc={sm:"h-4 w-4",md:"h-5 w-5"};function Sc(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Mn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=s.useRef(null);return s.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,Sc(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${kc[o]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${i}`}),t.jsx(j.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})}),is=32767;function Tn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=is?r:`${r.slice(0,is-1)}…`}const $n=[25,50,100,200,500];let At={dataTable:{pageSizeOptions:[...$n]}};function Ec(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function za(){const e=At.dataTable.preferencesEndpoint,r=Ec();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Cc(e){if(!Array.isArray(e))return[...$n];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...$n]}function cs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Mc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=cs(e.dataTable.preferencesEndpoint);At={...At,dataTable:{...At.dataTable,pageSizeOptions:Cc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??At.dataTable.preferencesEndpoint}}}function Tc(){return{dataTable:{pageSizeOptions:[...At.dataTable.pageSizeOptions]}}}function Qr(){return[...At.dataTable.pageSizeOptions]}function $c(){At={dataTable:{pageSizeOptions:[...$n]}}}function Ac(e){At={...At,dataTable:{...At.dataTable,preferencesEndpoint:cs(e)}}}const An=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],Lc=An.map(e=>({value:e.value,label:e.label})),Dc=12,Oc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ds={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Hc="bonsaif-ui:datatable:",Ic="[&_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",Bc=[],Fc=52;function Vt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function us(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function fs(e){return`${Hc}${e}`}function Ln(e){try{const r=window.localStorage.getItem(fs(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Pc(e,r){try{window.localStorage.setItem(fs(e),JSON.stringify(r))}catch{}}function _c(e,r){if(e===!0)return{...ds};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ds};const n={...Oc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function bs(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Wa(e,r,n){return typeof e!="number"||e<=0?n:rn(r).includes(e)?e:n}function Jr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Rr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=o.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function en(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(An.map(o=>o.value)),a=Object.entries(e).flatMap(([o,l])=>{if(!r.has(o)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[o,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function wt(e,r){if(ur(e))return Fc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function zc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function ur(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function ja(e){return e.sticky===!0}function ms(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Dn(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function Jt(e,r){const n=r.filter(ja).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),o=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...o,...l]}function Wc(e,r){if(r<=7)return Array.from({length:r},(a,o)=>o+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function Rt(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function jc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function kr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(kr).join(" ").trim():s.isValidElement(e)?kr(e.props.children):""}function On(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?jc(n):kr(n).trim()}function tn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Sr(e,r){const n=tn(e),a=tn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function rn(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Qr()}function qc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",o=((c=r.valueTo)==null?void 0:c.trim())??"",l=An.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return Sr(e,a)>0;case"greaterThanOrEqual":return Sr(e,a)>=0;case"lessThan":return Sr(e,a)<0;case"lessThanOrEqual":return Sr(e,a)<=0;case"between":return Sr(e,a)>=0&&Sr(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:tn(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(tn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=tn(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function hs({children:e,className:r="",style:n}){return t.jsx(Bt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function qa({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:g,expandOnRowClick:p=!1,selected:E,onToggleOne:v,onToggleAll:w,getRowSelectable:A,highlightSelected:C=!0,rowClassName:H,getRowCategory:k,stickyHeader:x=!0,pageSize:M=25,pageSizeOptions:N,pageSizeSelectWidth:z=62,pageSizeSelectHeight:X=30,pageSizeSelectPadding:K="0 7px",totalRows:D,page:G,onPageChange:V,onPageSizeChange:ne,storageKey:J,stickyFirstColumn:R=!1,bottomOffset:U=0,compact:Y=!0,restrictHeight:ce=!0,maxHeight:L,minTableWidth:B,enableColumnVisibility:le=!0,enableColumnFilters:O=!0,hiddenColumnKeys:ae,defaultHiddenColumnKeys:S=Bc,onHiddenColumnKeysChange:ee,columnVisibilityLabel:_="Columnas",enableBql:I=!1,bqlValue:de,defaultBqlValue:re="",onBqlChange:F,bqlDescription:y="Filtra registros con Bonsaif Query Language",bqlPlaceholder:T=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:
|
|
3
|
-
`).map(
|
|
4
|
-
${$}`;Po(P,Oo.current??void 0),requestAnimationFrame(()=>{const oe=Oo.current;if(!oe)return;oe.focus();const ve=oe.value.length;oe.setSelectionRange(ve,ve),Po(oe.value,oe)})}s.useEffect(()=>{Ie(xe)},[xe]);const ka=s.useCallback(()=>{const h=Do.current;if(!h)return;const $=h.getBoundingClientRect(),Q=12,P=8,oe=Math.min(780,Math.max(320,window.innerWidth-32)),ve=Math.max(Q,window.innerWidth-oe-Q),Ce=Math.min(Math.max(Q,$.left),ve),$e=$.bottom+P,Ue=window.innerHeight-$.top+P,Ze=window.innerHeight-$e-Q,yt=$.top-Q-P,nt=Ze<280&&yt>Ze,ye=Math.max(240,nt?yt:Ze);Jb({position:"fixed",zIndex:1e4,left:Ce,top:nt?void 0:$e,bottom:nt?Ue:void 0,width:oe,maxWidth:"calc(100vw - 24px)",maxHeight:ye,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Je)return;function h(P){var ve,Ce;if(Date.now()<xi.current)return;const oe=P.target;(ve=Do.current)!=null&&ve.contains(oe)||(Ce=vi.current)!=null&&Ce.contains(oe)||(Re(!1),xt(!1),Ht(!1))}function $(P){P.key==="Escape"&&(Re(!1),xt(!1),Ht(!1))}function Q(){ka()}return ka(),document.addEventListener("mousedown",h),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Je,ka]);function Di(h){const $=Rt(h,e);Be||ut($),ee==null||ee($)}function pm(h){Di(qe.includes(h)?qe.filter($=>$!==h):[...qe,h])}function gm(){Di([])}const _o=s.useCallback((h=ga.current)=>{if(!h)return;const $=h.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),P=Math.max(8,window.innerWidth-Q-8),oe=Math.min(Math.max(8,$.right-Q),P),ve=window.innerHeight-$.bottom,Ce=$.bottom+6,$e=window.innerHeight-$.top+6,Ze=ve<360&&$.top>ve?void 0:Ce,yt=Ze===void 0?$e:void 0,nt=Math.max(220,Ze===void 0?$.top-16:window.innerHeight-Ce-8),ye={position:"fixed",zIndex:9999,left:oe,top:Ze,bottom:yt,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:nt,"--dt-column-menu-max-height":`${nt}px`};em(ye)},[]);function Oi(h,$,Q=null){h.preventDefault(),h.stopPropagation();const P=ga.current===h.currentTarget&&ht===$&&bt===Q;if(Ve&&P){ft(!1),ze(null);return}ga.current=h.currentTarget,br($),ze(Q),fa(""),_o(h.currentTarget),ft(!0)}function vm(h){if(ur(h))return;const $=lr.current;if(!$)return;const P=Array.from($.querySelectorAll("[data-dt-column-key]")).filter(oe=>oe.dataset.dtColumnKey===h.key).reduce((oe,ve)=>{const Ce=ve.querySelector("[data-dt-autofit-content]"),$e=Ce?Ce.scrollWidth:Math.max(ve.scrollWidth,ve.offsetWidth);return Math.max(oe,Math.ceil($e+zc(ve)))},0);P<=0||Vr(oe=>({...oe,[h.key]:wt(h,P+12)}))}s.useEffect(()=>{Vr(h=>{const $=Object.fromEntries(e.map(Q=>[Q.key,wt(Q,Vt(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,wt(Q,h[Q.key]??$[Q.key])]))})},[_e,e]),s.useEffect(()=>{Be||ut(h=>Rt(h,e))},[_e,e,Be]),s.useEffect(()=>{function h(P){var Ce,$e;const oe=P.target,ve=P.target;ve!=null&&ve.closest("[data-bonsaif-select-dropdown='true']")||!((Ce=yi.current)!=null&&Ce.contains(oe))&&!(($e=ga.current)!=null&&$e.contains(oe))&&(ft(!1),ze(null))}function $(P){P.key==="Escape"&&(ft(!1),ze(null))}function Q(){_o()}return Ve&&(document.addEventListener("mousedown",h),window.addEventListener("keydown",$),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",$),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ve,_o]);const yn=s.useRef(null);s.useEffect(()=>{function h(Q){const P=yn.current;if(!P)return;const oe=Q.clientX-P.startX,ve=e.find(Ce=>Ce.key===P.colKey);ve&&Vr(Ce=>({...Ce,[P.colKey]:wt(ve,P.startWidth+oe)}))}function $(){yn.current&&(yn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",h),document.addEventListener("pointerup",$),()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",$)}},[e]);const wn=s.useRef(null),[Hi,zo]=s.useState(null);function xm(h,$){const Q=e.find(P=>P.key===h);if(!Q||!ms(Q)){$.preventDefault();return}wn.current=qr.indexOf(h),$.dataTransfer.effectAllowed="move"}function ym(h,$){$.preventDefault(),$.dataTransfer.dropEffect="move";const Q=qr.indexOf(h);Hi!==Q&&zo(Q)}function wm(h,$){$.preventDefault();const Q=wn.current,P=qr.indexOf(h);Q!==null&&Q!==P&&Ur(oe=>{const ve=[...oe],[Ce]=ve.splice(Q,1);return ve.splice(P,0,Ce),Jt(ve,e)}),wn.current=null,zo(null)}function Nm(){wn.current=null,zo(null)}function km(h){h.sortKey&&pr($=>($==null?void 0:$.key)===h.key?{key:h.key,dir:$.dir==="asc"?"desc":"asc"}:{key:h.key,dir:"asc"})}s.useEffect(()=>{va(1)},[r]),s.useEffect(()=>{va(1)},[Tt,pt]);const jt=!!(V&&ne),ir=M!==!1,Wo=s.useMemo(()=>rn(N??Qr()),[N]),it=jt?G??1:im,Ii=ir&&xa<1?typeof M=="number"&&M>0?M:Wo[0]??25:xa,qt=jt||ir?Ii:r.length,It=!!E&&!!v&&!!w,jo=s.useMemo(()=>A?r.filter(h=>A(h)):r,[r,A]),Xr=!!u,Bi=s.useMemo(()=>new Set(Wr?Array.from(b??[]):W),[Wr,b,W]),Sm=(Xr?40:0)+(It?40:0),qo=!sm&&(Ci||R),Sa=(()=>{if(!qo)return{};let h=Sm;const $={};return $t.forEach((Q,P)=>{(ja(Q)||!Ci&&R&&P===0)&&($[Q.key]=h,h+=hr[Q.key]??wt(Q,Vt(Q.width)))}),$})(),Uo=Object.keys(Sa),Vo=Uo.length>0?Uo[Uo.length-1]:null,Fi=It&&jo.length>0&&jo.every(h=>E.has(n(h))),Em=It&&E.size>0&&jo.some(h=>E.has(n(h)))&&!Fi,Ea=s.useMemo(()=>{if(jt)return r;const h=Object.entries(pt),$=Object.entries(Tt);return h.length===0&&$.length===0?r:r.filter(Q=>h.every(([P,oe])=>{const ve=e.find(Ce=>Ce.key===P);return ve?oe.includes(On(ve,Q)):!0})&&$.every(([P,oe])=>{const ve=e.find($e=>$e.key===P);if(!ve)return!0;const Ce=r.map($e=>On(ve,$e));return qc(On(ve,Q),oe,Ce)}))},[Tt,pt,e,r,jt]),gr=s.useMemo(()=>{if(!et)return Ea;const h=e.find($=>$.key===et.key&&$.sortKey);return h!=null&&h.sortKey?[...Ea].sort(($,Q)=>{const P=$[h.sortKey],oe=Q[h.sortKey],ve=P===oe?0:P==null?1:oe==null||P<oe?-1:1;return et.dir==="asc"?ve:-ve}):Ea},[Ea,et,e]),Pi=s.useMemo(()=>{if(jt||!ir)return gr;const h=(it-1)*qt;return gr.slice(h,h+qt)},[gr,jt,ir,it,qt]),Zt=jt?D??r.length:gr.length,Xo=ir?Math.max(1,Math.ceil(Zt/qt)):1,Cm=Math.min(...Wo),Mm=ir&&(Zt>qt||Zt>Cm),Tm=ir?(it-1)*qt+1:1,$m=ir?Math.min(it*qt,Zt):Zt;function Yo(h){if(a)return;const $=Math.max(1,Math.min(h,Xo));jt?V($):va($)}function Am(h){a||(J&&(mr.current=J),ya(h),jt?(ne(h),V(1)):(va(1),ne==null||ne(h)))}function _i(h){const $=new Set(Bi);$.has(h)?$.delete(h):$.add(h);const Q=Array.from($);Wr||Z(Q),g==null||g(Q)}s.useEffect(()=>{De==null||De({bql:xe,filters:pt,conditionFilters:Tt,sort:et,page:it,pageSize:qt,hiddenColumnKeys:qe})},[xe,pt,Tt,et,it,qt,qe,De]);const zi=h=>h==="center"?"justify-center text-center":h==="right"?"justify-end text-right":"justify-start text-left",Lm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Ko="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Pe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",vr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ca=`inset 0 0 0 1px ${Pe}`,Wi=$t.reduce((h,$)=>h+(hr[$.key]??Vt($.width)),(Xr?40:0)+(It?40:0)),ji=typeof B=="number"?B:typeof B=="string"?Number(((Ki=B.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ki[1])??NaN):NaN,Nn=Number.isFinite(ji)?Math.max(Wi,ji,ki):Math.max(Wi,ki),Ma=B??Nn,Yr=`${Xr?"40px ":""}${It?"40px ":""}${$t.map(h=>`${hr[h.key]??Vt(h.width)}px`).join(" ")}`;s.useEffect(()=>{et&&qe.includes(et.key)&&pr(null)},[qe,et]);function qi(h){return h?typeof h=="string"?{key:h,label:h}:h:null}const Ta=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,background:Ko,borderBottom:`1px solid ${vr}`},children:[Xr&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Pe}`}}),It&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Pe}`}:{borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Pe}`},children:t.jsx(Mn,{size:"sm",checked:Fi,indeterminate:Em,onChange:w,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),$t.map((h,$)=>{const Q=(et==null?void 0:et.key)===h.key,P=!!h.sortKey,oe=ur(h),ve=Sa[h.key],Ce=ve!==void 0,$e=h.key===Vo,Ue=ms(h),Ze=Hi===$,nt=(hr[h.key]??Vt(h.width))<120,ye=Object.prototype.hasOwnProperty.call(pt,h.key)||Object.prototype.hasOwnProperty.call(Tt,h.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":h.key,className:`group select-none ${nt?"text-left":zi(h.align)}`,style:{...Ce?{position:"sticky",left:ve,zIndex:12,background:Ko,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${vr}`:`inset 0 -1px 0 ${vr}`,borderRight:`1px solid ${Pe}`}:{position:"relative",borderBottom:`1px solid ${vr}`,borderRight:`1px solid ${Pe}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ze?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:oe?Y?"7px 6px":"9px 8px":Y?"8px 6px 10px":"10px 8px 12px"},onDragOver:Le=>{(Ue||wn.current!==null)&&ym(h.key,Le)},onDrop:Le=>wm(h.key,Le),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${oe?"justify-center":nt?"justify-start":h.align==="center"?"justify-center":h.align==="right"?"justify-end":"justify-start"}`,children:[Ue?t.jsx("span",{draggable:!0,onDragStart:Le=>{Le.stopPropagation(),xm(h.key,Le)},onDragEnd:Le=>{Le.stopPropagation(),Nm()},onClick:Le=>Le.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,oe?t.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:t.jsx(j.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(hs,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${Y?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:h.header})})}),P&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(h.header)}`,title:"Ordenar",onClick:Le=>{Le.stopPropagation(),km(h)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${Q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Q?et.dir==="asc"?t.jsx(j.HiChevronUp,{className:"h-3 w-3"}):t.jsx(j.HiChevronDown,{className:"h-3 w-3"}):t.jsx(j.HiChevronUpDown,{className:"h-3 w-3"})}),O&&!oe&&fm(h)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ve&&bt===h.key,"aria-label":`Filtrar ${String(h.header)}`,title:"Filtrar",onClick:Le=>Oi(Le,"filter",h.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ve&&ht==="filter"&&bt===h.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ye?"text-[var(--primary)] opacity-100":""}`,children:ye?t.jsx(j.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(j.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!oe&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Le=>{Le.preventDefault(),Le.stopPropagation(),yn.current={colKey:h.key,startX:Le.clientX,startWidth:hr[h.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Le=>{Le.preventDefault(),Le.stopPropagation(),yn.current=null,document.body.style.cursor="",document.body.style.userSelect="",vm(h)},onClick:Le=>Le.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},h.key)})]}),$a=()=>{if(!Ve||typeof document>"u"||ht==="visibility"&&!le||ht==="filter"&&!O)return null;const h=e.find(ye=>ye.key===bt),$=um(),Q=h?Object.prototype.hasOwnProperty.call(pt,h.key):!1,P=h?Tt[h.key]:void 0,oe=An.find(ye=>ye.value===(P==null?void 0:P.operator)),ve=h?pt[h.key]??[]:[],Ce=vn.trim().toLowerCase(),$e=Ce?$.filter(ye=>ye.label.toLowerCase().includes(Ce)):$,Ue=h&&$.length>0&&(!Q||ve.length===$.length),Ze=h&&Q&&ve.length>0&&ve.length<$.length,yt=qe.length,nt=()=>{h&&(Fo(h.key),$i(h.key))};return gt.createPortal(t.jsx("div",{ref:yi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Rb,borderColor:"var(--border)",background:"var(--bg-card)"},children:ht==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:yt>0?`${$t.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:gm,disabled:yt===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:Ei.map(ye=>{const Le=!qe.includes(ye.key),we=!(ye.hideable!==!1)||Le&&$t.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Le,disabled:we,onClick:()=>pm(ye.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Le?"var(--primary)":"var(--border)",background:Le?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Le&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.header})]},ye.key)})})]}):h?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",h.header]}),t.jsx("button",{type:"button",onClick:nt,disabled:!Q&&!P,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),h.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>pr({key:h.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(j.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(et==null?void 0:et.key)===h.key&&et.dir==="asc"&&t.jsx(j.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>pr({key:h.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(j.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(et==null?void 0:et.key)===h.key&&et.dir==="desc"&&t.jsx(j.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(dr,{value:(P==null?void 0:P.operator)??"",onChange:ye=>{if(!ye){$i(h.key);return}wa(h.key,{operator:ye,value:(P==null?void 0:P.value)??"",valueTo:(P==null?void 0:P.valueTo)??""})},options:Lc,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"}),(oe==null?void 0:oe.valueMode)!=="none"?t.jsx("input",{value:(P==null?void 0:P.value)??"",onChange:ye=>{P&&wa(h.key,{...P,value:ye.target.value})},disabled:!P,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):t.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(oe==null?void 0:oe.valueMode)==="between"&&t.jsx("input",{value:(P==null?void 0:P.valueTo)??"",onChange:ye=>{P&&wa(h.key,{...P,valueTo:ye.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:vn,onChange:ye=>fa(ye.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ze?"mixed":!!Ue,onClick:()=>{h&&(Ue&&!Q?Ti(h.key,[]):Fo(h.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ue||Ze?"var(--primary)":"var(--border)",background:Ue||Ze?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ze&&t.jsx(j.HiMinus,{className:"h-3 w-3"}),Ue&&!Ze&&t.jsx(j.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(ye=>{const Le=!Q||ve.includes(ye.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Le,onClick:()=>bm(h.key,ye.value,$.map(ke=>ke.value),Q),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Le?"var(--primary)":"var(--border)",background:Le?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Le&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.label})]},ye.value)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!xn)return;function h($){Ho.current&&!Ho.current.contains($.target)&&pa.current&&!pa.current.contains($.target)&&ha(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[xn]);function Ui(h,$){if(h.filterValue){const Q=h.filterValue($);return Q==null||Q===""?"":Tn(Q)}return Tn(kr(h.cell($)))}function Vi(h){return`"${Tn(h).replace(/"/g,'""')}"`}function Aa(h){return Tn(h).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Xi(){return jt&&Zt>gr.length&&Ha.toast.warning(`Exportando ${gr.length.toLocaleString("es-MX")} de ${Zt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),gr}function Dm(){const h=$t.filter(Ue=>!ur(Ue)),$=Xi(),Q=h.map(Ue=>Vi(kr(Ue.header))).join(","),P=$.map(Ue=>h.map(Ze=>Vi(Ui(Ze,Ue))).join(",")).join(`
|
|
5
|
-
`),
|
|
6
|
-
${
|
|
7
|
-
<html lang="es"><head><meta charset="utf-8"><title>${
|
|
1
|
+
(function(F,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],s):(F=typeof globalThis<"u"?globalThis:F||self,s(F.BonsaifUI={},F.React,F.jsxRuntime,F.ReactIconsHi2,F.ReactDOM,F.Recharts,F.OverlayScrollbarsGlobal,F.Sonner,F.OverlayScrollbarsReact,F.ReactDayPicker,F.ReactDayPickerStyles,F.ReactIconsFi))})(this,(function(F,s,t,W,pt,Me,Ha,Ia,es,Ba,Wm,tc){"use strict";"use client";function Qt(...e){return e.filter(Boolean).join(" ")}function rc({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Qt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function ts({value:e,onChange:r,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=s.useRef(null),[m,b]=s.useState(!1),f=l||m||e.trim().length>0,p=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",g=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=u.current)==null||v.focus())},[o]);const k=()=>{var v;b(!0),(v=u.current)==null||v.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?g:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),k())},children:[t.jsx(W.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${p} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${f?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:f?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:v=>{b(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{b(!1),v.currentTarget.style.borderColor="var(--border)",v.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const rs=s.createContext({});let ns=0;const as="bonsaif-ui:hide-tooltips";function Sn(e=700){ns=Date.now()+e}function nc(){return Date.now()>ns}function En(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function ac(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(o=>{var l;return o.scrollWidth>o.clientWidth&&!!((l=o.textContent)!=null&&l.trim())&&o.tagName.toLowerCase()!=="svg"&&!o.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function Ft({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:b="div"}){const f=s.useRef(null),p=s.useRef(null),g=s.useRef(null),k=s.useRef(!1),[v,A]=s.useState(null),[E,M]=s.useState("");s.useEffect(()=>{const O=f.current;O&&(O.querySelectorAll("[title]").forEach(K=>{const q=K.getAttribute("title");q&&(K.getAttribute("aria-label")||K.setAttribute("aria-label",q),K.removeAttribute("title"))}),O.querySelectorAll("svg title").forEach(K=>K.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const O=p.current;if(!O)return;const K=12,q=14,le=O.getBoundingClientRect(),J=window.innerWidth-le.width-K,G=window.innerHeight-le.height-K;let U=v.mouseX+q,Y=v.mouseY+q,ue,L;if(!o&&f.current){const B=f.current.getBoundingClientRect(),de=B.left+B.width/2,I=B.top+B.height/2;l==="top"?(U=de-le.width/2,Y=B.top-le.height-q,L=le.height-1):l==="left"?(U=B.left-le.width-q,Y=I-le.height/2,ue=le.width-1):l==="right"?(U=B.right+q,Y=I-le.height/2,ue=-7):(U=de-le.width/2,Y=B.bottom+q,L=-7)}if(o&&(U>J&&(U=v.mouseX-le.width-q),Y>G&&(Y=v.mouseY-le.height-q)),U=Math.min(Math.max(K,U),Math.max(K,J)),Y=Math.min(Math.max(K,Y),Math.max(K,G)),!o&&f.current){const B=f.current.getBoundingClientRect(),de=B.left+B.width/2,I=B.top+B.height/2;l==="top"||l==="bottom"?ue=Math.min(Math.max(14,de-U),le.width-14):L=Math.min(Math.max(14,I-Y),le.height-14)}(Math.abs(U-v.x)>.5||Math.abs(Y-v.y)>.5||ue!==v.arrowX||L!==v.arrowY)&&A(B=>B&&{...B,x:U,y:Y,arrowX:ue,arrowY:L})},[o,l,v]);const H=()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},S=(O,K)=>{if(!nc()||k.current)return;const q=f.current;if(q&&!En(q)){if(n){const le=ac(q);if(!le)return;M(le)}!n&&!r||A({mouseX:O,mouseY:K,x:O+14,y:K+14})}},x=()=>{const O=f.current;if(!O)return;const K=O.getBoundingClientRect();S(K.left+K.width/2,K.bottom)},C=()=>{H(),A(null)},w=()=>{if(!a){C();return}H(),g.current=window.setTimeout(()=>A(null),120)},P=()=>{Sn(),k.current=!0,C()},V=()=>{k.current=!1};s.useEffect(()=>{if(!v)return;if(En(f.current)){A(null);return}const O=()=>A(null),K=()=>{Sn(),k.current=!0,A(null)};document.addEventListener("pointerdown",K,!0),document.addEventListener("click",K,!0),document.addEventListener("scroll",O,!0),window.addEventListener("blur",O),document.addEventListener("visibilitychange",O),document.addEventListener("keydown",O,!0);const q=new MutationObserver(()=>{En(f.current)&&A(null)});return q.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("click",K,!0),document.removeEventListener("scroll",O,!0),window.removeEventListener("blur",O),document.removeEventListener("visibilitychange",O),document.removeEventListener("keydown",O,!0),q.disconnect()}},[v]),s.useEffect(()=>{const O=()=>Sn(),K=()=>{Sn(),k.current=!0,A(null)};return document.addEventListener("pointerdown",O,!0),document.addEventListener("click",O,!0),document.addEventListener("keydown",O,!0),window.addEventListener(as,K),()=>{document.removeEventListener("pointerdown",O,!0),document.removeEventListener("click",O,!0),document.removeEventListener("keydown",O,!0),window.removeEventListener(as,K)}},[]);const X=n?E:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:O=>{f.current=O},className:c,style:u,onMouseEnter:O=>{H(),V(),o?S(O.clientX,O.clientY):x()},onMouseMove:O=>{v&&o&&S(O.clientX,O.clientY)},onMouseDown:P,onClick:P,onMouseLeave:()=>{V(),w()},onFocus:x,onBlur:C,children:e}),v&&X&&!En(f.current)?pt.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:d,onMouseEnter:a?H:void 0,onMouseLeave:a?w:void 0,style:{position:"fixed",top:v.y,left:v.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),X]}),document.body):null]})}function os(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const oc="inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap leading-none font-medium transition-all duration-150 focus:outline-none disabled:opacity-50 rounded-lg",sc={primary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",secondary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",danger:"border border-[var(--border)] text-[var(--danger)] hover:border-[var(--danger)] hover:bg-[var(--danger-bg)] active:scale-[0.98] transition-colors",ghost:"text-[var(--text-secondary)] hover:opacity-70",icon:"text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},lc="border border-[var(--border)] text-[var(--text-muted)] shadow-sm shadow-black/5 hover:border-[var(--border)] hover:bg-[var(--bg-input)] hover:text-[var(--primary)] active:scale-[0.98] transition-colors",ic={xs:"h-8 px-2.5 text-xs",sm:"h-9 px-3.5 text-xs",md:"h-10 px-3.5 text-sm",lg:"h-11 px-4 text-sm font-semibold"},cc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},dc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Fa(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Fa).join(" ").trim():s.isValidElement(e)?Fa(e.props.children):""}function uc(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ge({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const p=s.useContext(rs),g=l??p.iconOnly??e==="icon",k=p.compact??!1,v=p.headerAction??!1,A=v&&r==="md"?"sm":k&&!v&&r==="md"?"xs":r,E=e==="icon"||g,M=v&&E,H=Fa(d),S=o??f.title??f["aria-label"]??(g?H:void 0),x=S?void 0:f.title,C=f["aria-label"]??(typeof S=="string"?S:H||void 0),w=n?null:a??(g?uc(d):null),P=t.jsxs("button",{...f,title:x,"aria-label":C,"data-variant":e,"data-size":A,"data-icon":E?"true":void 0,disabled:m||n,className:`${oc} ${M?lc:sc[e]} ${E?cc[A]:ic[A]} ${k&&!E?"px-2.5":""} ${u}`,style:{...dc[e],height:os(i),padding:os(c),...b,...v&&!E?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...M?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):w,!g&&d]});return S?t.jsx(Ft,{as:"span",content:S,className:"inline-flex shrink-0",children:P}):P}const gt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Cn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=o?"px-2 py-2":"px-3 py-2.5",u=o?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:gt})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...gt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,p)=>t.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...gt,width:`${46+(b*13+p*11)%42}%`,minWidth:28}})},`c-${b}-${p}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:gt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:gt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:gt})]})]})}function fc({size:e="md"}){const r=e==="sm"?"h-7 w-7":"h-9 w-9";return t.jsx("div",{className:`${r} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function bc({logoSrc:e,logoAlt:r}){return e?t.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[t.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),t.jsx("img",{src:e,alt:r,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function ss({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(Cn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(mc,{rows:i});if(e==="cards")return t.jsx(hc,{rows:i});const m=o||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(bc,{logoSrc:a,logoAlt:m}):null,t.jsx(fc,{size:b?"md":"sm"}),t.jsxs("div",{className:b?"space-y-1.5":"",children:[t.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f})}function mc({rows:e}){return t.jsx(Cn,{rows:e,columns:7})}function hc({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:gt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:gt})]},n))})}function ls(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function is(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function pc(e){return[e.label,ls(e.service),e.description,e.service].filter(Boolean).join(" ")}function gc(e){return typeof e=="function"?e:e.default}function vc(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ge,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function yc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:p,subtitle:g,emptyState:k,loadingState:v,errorState:A=vc,renderTabLabel:E,searchableTabs:M="auto",tabsSearchThreshold:H=6,tabsSearchPlaceholder:S="Buscar modulo...",tabsSearchValue:x,onTabsSearchChange:C,emptySearchState:w,showTabCount:P=!0,className:V="",parentClassName:X="",contentClassName:O="",tabsClassName:K=""}){var Se;const q=s.useMemo(()=>l.filter(re=>!re.hidden&&((b==null?void 0:b(re,o))??!0)),[b,o,l]),le=(Se=q.find(re=>!re.disabled))==null?void 0:Se.service,[J,G]=s.useState(u??le??""),[U,Y]=s.useState({}),[ue,L]=s.useState({}),[B,de]=s.useState(""),[I,oe]=s.useState(!1),N=s.useRef(ue),R=s.useRef(0),ae=x??B,$=is(ae),ne=M===!0||M==="auto"&&q.length>=H,te=ne&&ae.trim().length>0,j=s.useMemo(()=>$?q.filter(re=>is(pc(re)).includes($)):q,[$,q]),y=d??J,T=q.find(re=>re.service===y)??q.find(re=>!re.disabled);s.useEffect(()=>{!T&&le&&G(le)},[le,T]),s.useEffect(()=>{N.current=ue},[ue]);const ee=re=>{re.disabled||(d||G(re.service),m==null||m(re.service,re))},fe=re=>{x===void 0&&de(re),C==null||C(re)},ie=(re,Le)=>{const Oe=j.filter(je=>!je.disabled),Ve=Oe.findIndex(je=>je.service===Le.service);Ve<0||((re.key==="ArrowRight"||re.key==="ArrowDown")&&(re.preventDefault(),ee(Oe[(Ve+1)%Oe.length])),(re.key==="ArrowLeft"||re.key==="ArrowUp")&&(re.preventDefault(),ee(Oe[(Ve-1+Oe.length)%Oe.length])),re.key==="Home"&&(re.preventDefault(),ee(Oe[0])),re.key==="End"&&(re.preventDefault(),ee(Oe[Oe.length-1])))},he=s.useCallback(()=>{if(!T)return;const re=T.service,Le=N.current[re];if(Le!=null&&Le.loading||Le!=null&&Le.component&&f)return;const Oe=(i==null?void 0:i[re])??c;if(!Oe){L(je=>({...je,[re]:{loading:!1,error:new Error(`No module loader found for service "${re}".`)}}));return}const Ve=++R.current;L(je=>({...je,[re]:{...je[re],loading:!0,error:void 0}})),Oe(T,o).then(je=>{if(Ve!==R.current&&!f)return;const Be=gc(je);L(et=>({...et,[re]:{component:Be,loading:!1}}))}).catch(je=>{const Be=je instanceof Error?je:new Error(String(je));L(et=>({...et,[re]:{...et[re],loading:!1,error:Be}}))})},[o,f,c,i,T]);s.useEffect(he,[he]);const Te=T?U[T.service]??null:null,De=T?ue[T.service]:void 0,ft=De==null?void 0:De.component,Ct=re=>{T&&Y(Le=>({...Le,[T.service]:re}))},nt=()=>{T&&Y(re=>({...re,[T.service]:null}))},st={context:o,parent:a,links:l,visibleLinks:q,filteredLinks:j,selectedLink:T,selectedService:T==null?void 0:T.service,activeItemId:Te,tabsSearch:ae,onSelectService:ee,onOpenDetail:Ct,onBackToList:nt},ce=n?n(st):r?t.jsx(r,{...st}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${V}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${X}`,children:ce}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${O}`,children:[(p||g||ne||P)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[p&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),g&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:g})]}),(ne||P)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[P&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[j.length," / ",q.length]}),ne&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${I?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!I,children:t.jsx(ts,{value:ae,onChange:fe,placeholder:S,className:"w-full",autoFocus:I,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:I?0:-1})}),t.jsx("button",{type:"button","aria-label":I?"Cerrar busqueda":"Buscar tabs","aria-expanded":I,onClick:()=>{I&&ae&&fe(""),oe(re=>!re)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${I||te?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:I||te?t.jsx(W.HiXMark,{className:"h-4 w-4"}):t.jsx(W.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":p??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${K}`,children:j.length>0?j.map(re=>{const Le=re.service===(T==null?void 0:T.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Le,disabled:re.disabled,onClick:()=>ee(re),onKeyDown:Oe=>ie(Oe,re),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Le?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:E?E(re,Le):t.jsxs(t.Fragment,{children:[re.icon,t.jsx("span",{children:re.label??ls(re.service)}),re.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:re.badge})]})},re.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:w??"No hay modulos que coincidan con la busqueda."})}),(T==null?void 0:T.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:T.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!T&&(k??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),T&&(De==null?void 0:De.loading)&&(v??t.jsx(ss,{title:"Cargando modulo..."})),T&&(De==null?void 0:De.error)&&A(De.error,he),T&&ft&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(ft,{context:o,parent:a,link:T,activeItemId:Te,onOpenDetail:Ct,onBackToList:nt})]})]})]})}const xc={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(W.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(W.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})}};function wc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=xc[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&t.jsx("div",{className:"mt-3",children:o})]}),l&&t.jsx(Ge,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]})}const cs=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Nc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],kc=["lu","ma","mi","ju","vi","sá","do"],ds=6;function Pa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Sc(){const e=new Date;return Pa(e.getFullYear(),e.getMonth()+1,e.getDate())}function us(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function Ec(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=us(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${cs[n-1]} ${r}`}function Cc({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=Sc(),c=us(e||l),d=a==="popover",[u,m]=s.useState(!1),b=s.useRef(null),[f,p]=s.useState({horizontal:"left",vertical:"bottom"}),[g,k]=s.useState(c.year),[v,A]=s.useState(c.month),[E,M]=s.useState("days"),H=16,[S,x]=s.useState(0),C=g-7+S,w=Array.from({length:H},(G,U)=>C+U);s.useEffect(()=>{if(!d||!u||!b.current)return;const G=b.current.getBoundingClientRect(),U=8,Y=280,ue=340,L=G.left+Y>window.innerWidth-U,B=G.right-Y>=U,de=G.bottom+8+ue>window.innerHeight-U,I=G.top-8-ue>=U;p({horizontal:L&&B?"right":"left",vertical:de&&I?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function G(Y){b.current&&(b.current.contains(Y.target)||m(!1))}function U(Y){Y.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",G),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",U)}},[d,u]);function P(){v===1?(k(G=>G-1),A(12)):A(G=>G-1)}function V(){v===12?(k(G=>G+1),A(1)):A(G=>G+1)}const X=(new Date(g,v-1,1).getDay()+6)%7,O=new Date(g,v,0).getDate(),K=[...Array(X).fill(null),...Array.from({length:O},(G,U)=>U+1)];for(;K.length<ds*7;)K.push(null);const q=K.slice(0,ds*7);function le(G){const U=Pa(g,v,G);n&&U<n||(r(U),d&&m(!1))}const J=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${o}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:E==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:P,"aria-label":"Mes anterior",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{M("years"),x(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[cs[v-1]," ",g]}),t.jsx(W.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:V,"aria-label":"Mes siguiente",children:t.jsx(W.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(G=>G-H),"aria-label":"Años anteriores",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>M("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[w[0]," – ",w[w.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(G=>G+H),"aria-label":"Años siguientes",children:t.jsx(W.HiChevronRight,{size:16})})]})}),E==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Nc.map((G,U)=>{const Y=U+1===v;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${Y?" is-active":""}`,onClick:()=>A(U+1),children:G},G)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:w.map(G=>{const U=G===g,Y=G===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${U?" is-active":""}${Y&&!U?" is-today":""}`,onClick:()=>{k(G),M("days")},children:G},G)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:kc.map(G=>t.jsx("div",{className:"bonsaif-multi-weekday",children:G},G))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:q.map((G,U)=>{if(G===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},U);const Y=Pa(g,v,G),ue=Y===e,L=Y===l,B=!!(n&&Y<n);return t.jsx("div",{className:`bonsaif-multi-day${ue?" bonsaif-multi-day-selected":""}${L?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ue,onClick:()=>!B&&le(G),children:G})},U)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(G=>!G),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(W.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:Ec(e)})]}),t.jsx(W.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:J})]}):J}function Vt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Ft,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function _a(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function za(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Mc(e,r){if(!r.trim())return!0;const n=za(r);return za(e.label).includes(n)||!!(e.sublabel&&za(e.sublabel).includes(n))}function ur({value:e,onChange:r,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:b,dropdownMinWidth:f,dropdownZIndex:p=9999,height:g=40,padding:k="0 10px",searchable:v=!0,minOptionsForSearch:A=6}){const[E,M]=s.useState(!1),[H,S]=s.useState(""),[x,C]=s.useState(-1),[w,P]=s.useState(!1),[V,X]=s.useState({}),O=s.useRef(null),K=s.useRef(null),q=s.useRef(null),le=s.useRef(null),J=v&&n.length>=A,G=n.find($=>$.value===e)??null,U=l==="ghost",Y=a==="error"?"var(--danger)":E?"var(--primary)":"var(--border)",ue=J&&H.trim()?n.filter($=>Mc($,H)):n,L=s.useCallback(()=>{const $=O.current;if(!$)return;const ne=$.getBoundingClientRect(),te=J?272:212,j=window.innerHeight-ne.bottom,y=j<te&&ne.top>j;X({position:"fixed",left:ne.left,top:y?void 0:ne.bottom+4,bottom:y?window.innerHeight-ne.top+4:void 0,width:ne.width,minWidth:_a(f),zIndex:p})},[f,p,J]);s.useEffect(()=>P(!0),[]),s.useEffect(()=>{if(!E)return;function $(ne){var j,y;const te=ne.target;!((j=O.current)!=null&&j.contains(te))&&!((y=K.current)!=null&&y.contains(te))&&(M(!1),S(""))}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[E]),s.useEffect(()=>{E&&(C(-1),L(),J&&setTimeout(()=>{var $;return($=q.current)==null?void 0:$.focus()},0))},[E,J,L]),s.useEffect(()=>{if(E)return window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[E,L]),s.useEffect(()=>{if(x<0||!le.current)return;const $=le.current.children[x];$==null||$.scrollIntoView({block:"nearest"})},[x]);const B=s.useCallback($=>{r($),M(!1),S("")},[r]),de=s.useRef(E);de.current=E;const I=s.useRef(ue);I.current=ue;const oe=s.useRef(x);oe.current=x;const N=s.useRef(d);N.current=d;const R=s.useRef(B);R.current=B,s.useEffect(()=>{function $(ne){var T,ee;const te=document.activeElement,j=((T=O.current)==null?void 0:T.contains(te))??!1,y=((ee=K.current)==null?void 0:ee.contains(te))??!1;if(!(!j&&!y)){if(!de.current){(ne.key==="Enter"||ne.key===" "||ne.key==="ArrowDown")&&(ne.preventDefault(),M(!0));return}switch(ne.key){case"ArrowDown":ne.preventDefault(),C(fe=>Math.min(fe+1,I.current.length-1));break;case"ArrowUp":ne.preventDefault(),C(fe=>Math.max(fe-1,N.current?-1:0));break;case"Enter":{ne.preventDefault();const fe=oe.current,ie=I.current;fe===-1&&N.current?R.current(""):ie[fe]&&!ie[fe].disabled&&R.current(ie[fe].value);break}case"Escape":ne.preventDefault(),ne.stopPropagation(),M(!1),S("");break}}}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[]);const ae=t.jsxs("div",{ref:K,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...V,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[J&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:q,value:H,onChange:$=>{S($.target.value),C(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),H&&t.jsx("button",{type:"button",onMouseDown:$=>{$.preventDefault(),S("")},children:t.jsx(W.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:le,role:"listbox",className:"overflow-y-auto",style:{maxHeight:J?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:$=>{$.preventDefault(),B("")},onMouseEnter:()=>C(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:x===-1&&!H.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),ue.map(($,ne)=>{const j=ne===x,y=$.value===e;return t.jsxs("li",{role:"option","aria-selected":y,onMouseDown:T=>{T.preventDefault(),$.disabled||B($.value)},onMouseEnter:()=>!$.disabled&&C(ne),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:j?"var(--bg-hover)":y?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:$.disabled?"var(--text-muted)":"var(--text-main)",cursor:$.disabled?"not-allowed":"pointer",boxShadow:y?"inset 2px 0 0 var(--primary)":void 0},children:[$.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:$.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:$.label}),$.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:$.sublabel})]}),$.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:$.badge})]},$.value)}),ue.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:O,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&M($=>!$),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:_a(g),padding:_a(k),background:U?"transparent":"var(--bg-input)",color:G?"var(--text-main)":"var(--text-muted)",border:U?"1px solid transparent":`1px solid ${Y}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":E,"aria-label":o,children:[(G==null?void 0:G.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:G.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:G?t.jsxs(t.Fragment,{children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:G.label}),i&&G.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:G.sublabel})]}):t.jsx(Vt,{className:"min-w-0 flex-1",children:c})}),G&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:$=>{$.preventDefault(),$.stopPropagation(),B("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"w-3 h-3"})}):t.jsx(W.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:E?"rotate(180deg)":"rotate(0deg)"}})]}),E&&w&&pt.createPortal(ae,document.body)]})}const Tc={sm:"h-4 w-4",md:"h-5 w-5"};function $c(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Mn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=s.useRef(null);return s.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,$c(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${Tc[o]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${i}`}),t.jsx(W.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})}),fs=32767;function Tn(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=fs?r:`${r.slice(0,fs-1)}…`}const $n=[25,50,100,200,500];let At={dataTable:{pageSizeOptions:[...$n]}};function Ac(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function Wa(){const e=At.dataTable.preferencesEndpoint,r=Ac();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Lc(e){if(!Array.isArray(e))return[...$n];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...$n]}function bs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Dc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=bs(e.dataTable.preferencesEndpoint);At={...At,dataTable:{...At.dataTable,pageSizeOptions:Lc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??At.dataTable.preferencesEndpoint}}}function Oc(){return{dataTable:{pageSizeOptions:[...At.dataTable.pageSizeOptions]}}}function Jr(){return[...At.dataTable.pageSizeOptions]}function Hc(){At={dataTable:{pageSizeOptions:[...$n]}}}function Ic(e){At={...At,dataTable:{...At.dataTable,preferencesEndpoint:bs(e)}}}const An=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],Bc=An.map(e=>({value:e.value,label:e.label})),Fc=12,Pc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ms={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},_c="bonsaif-ui:datatable:",zc="[&_button]:h-7 [&_button]:min-h-0 [&_button]:gap-1 [&_button]:px-2 [&_button]:text-xs [&_button_svg]:h-3.5 [&_button_svg]:w-3.5 [&_button[data-icon=true]]:w-7 [&_button[data-icon=true]]:px-0",Wc=[],jc=52;function Yt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function hs(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function ps(e){return`${_c}${e}`}function Ln(e){try{const r=window.localStorage.getItem(ps(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function qc(e,r){try{window.localStorage.setItem(ps(e),JSON.stringify(r))}catch{}}function Uc(e,r){if(e===!0)return{...ms};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ms};const n={...Pc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function gs(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function ja(e,r,n){return typeof e!="number"||e<=0?n:nn(r).includes(e)?e:n}function Rr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function en(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=o.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function tn(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(An.map(o=>o.value)),a=Object.entries(e).flatMap(([o,l])=>{if(!r.has(o)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[o,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function xt(e,r){if(fr(e))return jc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Vc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function fr(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function qa(e){return e.sticky===!0}function vs(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Dn(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function Jt(e,r){const n=r.filter(qa).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),o=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...o,...l]}function Yc(e,r){if(r<=7)return Array.from({length:r},(a,o)=>o+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function Rt(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Xc(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function Sr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Sr).join(" ").trim():s.isValidElement(e)?Sr(e.props.children):""}function On(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Xc(n):Sr(n).trim()}function rn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Er(e,r){const n=rn(e),a=rn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function nn(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Jr()}function Kc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",o=((c=r.valueTo)==null?void 0:c.trim())??"",l=An.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return Er(e,a)>0;case"greaterThanOrEqual":return Er(e,a)>=0;case"lessThan":return Er(e,a)<0;case"lessThanOrEqual":return Er(e,a)<=0;case"between":return Er(e,a)>=0&&Er(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:rn(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(rn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=rn(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function ys({children:e,className:r="",style:n}){return t.jsx(Ft,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function Ua({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:p,expandOnRowClick:g=!1,selected:k,onToggleOne:v,onToggleAll:A,getRowSelectable:E,highlightSelected:M=!0,rowClassName:H,getRowCategory:S,stickyHeader:x=!0,pageSize:C=25,pageSizeOptions:w,pageSizeSelectWidth:P=62,pageSizeSelectHeight:V=30,pageSizeSelectPadding:X="0 7px",totalRows:O,page:K,onPageChange:q,onPageSizeChange:le,storageKey:J,stickyFirstColumn:G=!1,bottomOffset:U=0,compact:Y=!0,restrictHeight:ue=!0,maxHeight:L,minTableWidth:B,enableColumnVisibility:de=!0,enableColumnFilters:I=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:N=Wc,onHiddenColumnKeysChange:R,columnVisibilityLabel:ae="Columnas",enableBql:$=!1,bqlValue:ne,defaultBqlValue:te="",onBqlChange:j,bqlDescription:y="Filtra registros con Bonsaif Query Language",bqlPlaceholder:T=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:ee=[],bqlExamples:fe=[],bqlSuggestions:ie=[],bqlActiveFilters:he,bqlError:Te,onQueryChange:De,persistState:ft,onPreferencesReady:Ct,enableExport:nt=!1,exportFilename:st="datos",onExportCsv:ce,onExportPdf:Se}){var Ri;const re=Uc(ft,J),Le=Object.values(re).some(Boolean),Oe=e.map(h=>h.key).join(","),Ve=N.join(","),je=s.useRef(e),Be=s.useRef(N);je.current=e,Be.current=N;const[et,ot]=s.useState(!J||!Le),Ht=s.useRef(null),be=s.useRef(!J),ge=s.useRef(!1),He=s.useRef(Ct);He.current=Ct;const We=s.useRef(!J||!Le?J??"__none__":null),Fe=oe!==void 0,[bt,ct]=s.useState(()=>Rt(N,e)),qe=Rt(Fe?oe:bt,e),[Ye,dt]=s.useState(!1),[mt,mr]=s.useState("filter"),[ut,ze]=s.useState(null),[vn,ba]=s.useState(""),[ht,Mt]=s.useState({}),[Tt,or]=s.useState({}),jr=b!==void 0,[z,Z]=s.useState(f),me=ne!==void 0,[pe,Ee]=s.useState(te),ye=me?ne:pe,[Pe,Ie]=s.useState(ye),[Ze,Qe]=s.useState(!1),[sr,vt]=s.useState(!1),[Kt,It]=s.useState(!1),[lr,Gt]=s.useState([]),qr=s.useRef(null),hr=s.useRef(null),jt=s.useRef(j);jt.current=j;const ma=s.useRef(C);ma.current=C;const ha=s.useRef(w);ha.current=w;const rm=Array.isArray(w)?w.join(","):"",Bo=s.useRef(null),ki=s.useRef(null),Fo=s.useRef(null),Si=s.useRef(0),[nm,am]=s.useState({}),[om,sm]=s.useState({}),[yn,pa]=s.useState(!1),Po=s.useRef(null),ga=s.useRef(null),[lm,im]=s.useState({}),Ei=s.useRef(null),va=s.useRef(null),[_o,Ci]=s.useState(r.length>0||a||c===!1),Mi=(h,D)=>50+(h*17+D*13+7)%40,ir=s.useRef(null),[cm,dm]=s.useState(void 0),[Ti,um]=s.useState(0),[fm,bm]=s.useState(!1);s.useEffect(()=>{function h(){bm(window.innerWidth<640)}if(!ue||L!==void 0)return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h);const Q=C!==!1?48:0,_=12;function se(){if(h(),!ir.current)return;const ve=ir.current.getBoundingClientRect().top;dm(Math.max(120,window.innerHeight-ve-Q-_-U))}return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[a,C,U,ue,L]);const $i=ue?L??cm:void 0;s.useEffect(()=>{const h=ir.current;if(!h)return;const D=()=>um(h.clientWidth);if(D(),typeof ResizeObserver>"u")return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D);const Q=new ResizeObserver(D);return Q.observe(h),()=>Q.disconnect()},[a,et,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){Ci(!0);return}if(_o)return;const h=window.setTimeout(()=>{Ci(!0)},c);return()=>window.clearTimeout(h)},[r.length,c,_o,a]);const[Ur,Vr]=s.useState(()=>Jt(e.map(h=>h.key),e)),[pr,Yr]=s.useState(()=>Object.fromEntries(e.map(h=>[h.key,xt(h,Yt(h.width))]))),[Je,gr]=s.useState(null),[mm,ya]=s.useState(1),[xa,wa]=s.useState(C===!1?0:C);s.useEffect(()=>{var Ae;const h=je.current,D=Be.current,Q=h.map(ke=>ke.key),_=new Set(Q),se=()=>{var ke;ge.current||(ge.current=!0,(ke=He.current)==null||ke.call(He))};if(!J||!Le){re.layout&&Vr(Jt(Q,h)),Fe||ct(Rt(D,h)),be.current=!1,ot(!0),se();return}let ve=!1;const Ce=We.current===J;Ce||(be.current=!1,ot(!1),ge.current=!1);const $e=Ln(J);if(hs($e)&&!Ce){const ke=$e,we=nn(ha.current??Jr()),Ne=ma.current,xr=Ne===!1?0:Ne,dr=re.layout?ke==null?void 0:ke.columnOrder:void 0,wr=Array.isArray(dr)?dr.filter(Xe=>Q.includes(Xe)):[],Nr=Jt(wr.length>0?Dn(wr,Q):Q,h),kr=Object.fromEntries(h.map(Xe=>[Xe.key,xt(Xe,Yt(Xe.width))])),Gr=re.layout?(ke==null?void 0:ke.columnWidths)??{}:{},kn=Object.fromEntries(h.map(Xe=>[Xe.key,xt(Xe,Gr[Xe.key]??kr[Xe.key])])),Zr=Rt(re.layout?(ke==null?void 0:ke.hiddenColumnKeys)??D:D,h);if(re.layout&&(Vr(Nr),Yr(kn)),Fe||ct(Zr),re.filters&&(Mt(en(ke==null?void 0:ke.filters,_)),or(tn(ke==null?void 0:ke.conditionFilters,_))),re.sort){const Xe=Rr(ke==null?void 0:ke.sort)?ke.sort:null;gr(Xe&&_.has(Xe.key)?Xe:null)}if(re.bql){if(qr.current!==J){qr.current=J;const Xe=typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:te;me?(Ae=jt.current)==null||Ae.call(jt,Xe):Ee(Xe)}Gt(Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory.filter(Xe=>typeof Xe=="string"):[])}re.pagination&&hr.current!==J&&(hr.current=J,wa(ja(ke==null?void 0:ke.pageSize,we,xr))),We.current=J,ot(!0),se()}const yt=`${Wa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(J)}`,rt=new AbortController,xe=window.setTimeout(()=>rt.abort(),2500);return fetch(yt,{cache:"no-store",signal:rt.signal}).then(ke=>ke.ok?ke.json():null).then(ke=>{var ec;if(ve)return;const we=Ln(J),Ne=gs(hs(ke==null?void 0:ke.settings)?ke==null?void 0:ke.settings:null,we),xr=nn(ha.current??Jr()),dr=ma.current,wr=dr===!1?0:dr,Nr=re.layout?Ne==null?void 0:Ne.columnOrder:void 0,kr=Array.isArray(Nr)?Nr.filter(at=>Q.includes(at)):[],Gr=Jt(kr.length>0?Dn(kr,Q):Q,h),kn=Object.fromEntries(h.map(at=>[at.key,xt(at,Yt(at.width))])),Zr=re.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},Xe=Object.fromEntries(h.map(at=>[at.key,xt(at,Zr[at.key]??kn[at.key])])),Qr=Rt(re.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??D:D,h);if(re.layout&&(Vr(Gr),Yr(Xe)),Fe||ct(Qr),re.filters&&(Mt(en(Ne==null?void 0:Ne.filters,_)),or(tn(Ne==null?void 0:Ne.conditionFilters,_))),re.sort){const at=Rr(Ne==null?void 0:Ne.sort)?Ne.sort:null;gr(at&&_.has(at.key)?at:null)}if(re.bql){if(qr.current!==J){qr.current=J;const at=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:te;me?(ec=jt.current)==null||ec.call(jt,at):Ee(at)}Gt(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(at=>typeof at=="string"):[])}let Re;re.pagination&&(Re=ja(Ne==null?void 0:Ne.pageSize,xr,wr),hr.current!==J&&(hr.current=J,wa(Re))),Ht.current=JSON.stringify({columnOrder:Gr,columnWidths:Xe,hiddenColumnKeys:Qr,filters:en(Ne==null?void 0:Ne.filters,_),conditionFilters:tn(Ne==null?void 0:Ne.conditionFilters,_),sort:Rr(Ne==null?void 0:Ne.sort)?Ne.sort:null,bql:typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:"",bqlHistory:Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory:[],pageSize:re.pagination&&dr!==!1?Re:void 0}),be.current=!0}).catch(()=>{var ke;if(!ve){const we=Ln(J),Ne=nn(ha.current??Jr()),xr=ma.current,dr=xr===!1?0:xr,wr=re.layout?we==null?void 0:we.columnOrder:void 0,Nr=Array.isArray(wr)?wr.filter(Re=>Q.includes(Re)):[],kr=Jt(Nr.length>0?Dn(Nr,Q):Q,h),Gr=Object.fromEntries(h.map(Re=>[Re.key,xt(Re,Yt(Re.width))])),kn=re.layout?(we==null?void 0:we.columnWidths)??{}:{},Zr=Object.fromEntries(h.map(Re=>[Re.key,xt(Re,kn[Re.key]??Gr[Re.key])]));re.layout&&(Vr(kr),Yr(Zr));const Xe=Rt(re.layout?(we==null?void 0:we.hiddenColumnKeys)??D:D,h);if(Fe||ct(Xe),re.filters&&(Mt(en(we==null?void 0:we.filters,_)),or(tn(we==null?void 0:we.conditionFilters,_))),re.sort){const Re=Rr(we==null?void 0:we.sort)?we.sort:null;gr(Re&&_.has(Re.key)?Re:null)}if(re.bql){if(qr.current!==J){qr.current=J;const Re=typeof(we==null?void 0:we.bql)=="string"?we.bql:te;me?(ke=jt.current)==null||ke.call(jt,Re):Ee(Re)}Gt(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(Re=>typeof Re=="string"):[])}let Qr;re.pagination&&(Qr=ja(we==null?void 0:we.pageSize,Ne,dr),hr.current!==J&&(hr.current=J,wa(Qr))),Ht.current=JSON.stringify({columnOrder:kr,columnWidths:Zr,hiddenColumnKeys:Xe,filters:en(we==null?void 0:we.filters,_),conditionFilters:tn(we==null?void 0:we.conditionFilters,_),sort:Rr(we==null?void 0:we.sort)?we.sort:null,bql:typeof(we==null?void 0:we.bql)=="string"?we.bql:"",bqlHistory:Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory:[],pageSize:re.pagination&&xr!==!1?Qr:void 0}),be.current=!0}}).finally(()=>{window.clearTimeout(xe),ve||(We.current=J,ot(!0),se())}),()=>{ve=!0,rt.abort(),window.clearTimeout(xe)}},[J,Le,Oe,Ve,Fe,re.layout,re.filters,re.sort,re.bql,re.pagination,me,te,rm]),s.useEffect(()=>{if(!J||!et||!Le||!be.current)return;const h={};re.layout&&(h.columnOrder=Ur,h.columnWidths=pr,h.hiddenColumnKeys=qe),re.filters&&(h.filters=ht,h.conditionFilters=Tt),re.sort&&(h.sort=Je),re.bql&&(h.bql=ye,h.bqlHistory=lr),re.pagination&&C!==!1&&(h.pageSize=xa);const D=Ln(J),Q=gs(D,h),_=JSON.stringify(Q);if(_===Ht.current)return;qc(J,Q),Ht.current=_;const se=window.setTimeout(()=>{const ve=Wa()??"/api/user/preferences/datatables";fetch(ve,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:J,settings:Q})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(se)},[Ur,pr,qe,ht,Tt,Je,ye,lr,xa,C,J,et,Le,re.layout,re.filters,re.sort,re.bql,re.pagination]),s.useEffect(()=>{Vr(h=>{const D=e.map(Q=>Q.key);return Jt(Dn(h,D),e)})},[Oe,e]);const Ai=Jt(Ur,e).map(h=>e.find(D=>D.key===h)).filter(h=>!!h),$t=Ai.filter(h=>!qe.includes(h.key)),Li=e.some(qa),hm=Object.keys(ht).length,pm=Object.keys(Tt).length,zo=hm+pm;function Di(h){const D=new Set;return r.reduce((Q,_)=>{const se=On(h,_);return!se||D.has(se)||(D.add(se),Q.push({value:se,label:se})),Q},[])}function gm(){const h=e.find(D=>D.key===ut);return h?Di(h):[]}function vm(h){return!!(I&&!fr(h)&&(h.filterValue||h.sortKey||Di(h).length>0))}function Oi(h,D){Mt(Q=>{const _={...Q};return _[h]=D,_})}function ym(h,D,Q,_){const se=ht[h]??[],ve=_?se:Q.filter($e=>$e!==D),Ce=_?se.includes(D)?se.filter($e=>$e!==D):[...se,D]:ve;Ce.length===Q.length?Wo(h):Oi(h,Ce)}function Wo(h){Mt(D=>{const Q={...D};return delete Q[h],Q})}function Na(h,D){or(Q=>{const _={...Q};return D?_[h]=D:delete _[h],_})}function Hi(h){Na(h,null)}function xm(){Mt({}),or({})}function wm(h){me||Ee(h),j==null||j(h)}function Ii(h){const D=h.trim();Ie(D),(j==null?void 0:j(D))!==!1&&(me||Ee(D),Qe(!1),vt(!1),It(!1),D&&Gt(_=>[D,..._.filter(se=>se!==D)].slice(0,Fc)))}function Bi(){Ie(""),wm(""),Qe(!1),vt(!1),It(!1)}function jo(h,D){Ie(h),D&&(D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,180)}px`)}function ka(h){const D=h.trim();if(!D)return;Si.current=Date.now()+500;const Q=Pe.replace(/\s+$/u,""),_=Q.length===0?D:Q.split(`
|
|
3
|
+
`).map(se=>se.trim()).includes(D)?Q:`${Q}
|
|
4
|
+
${D}`;jo(_,Fo.current??void 0),requestAnimationFrame(()=>{const se=Fo.current;if(!se)return;se.focus();const ve=se.value.length;se.setSelectionRange(ve,ve),jo(se.value,se)})}s.useEffect(()=>{Ie(ye)},[ye]);const Sa=s.useCallback(()=>{const h=Bo.current;if(!h)return;const D=h.getBoundingClientRect(),Q=12,_=8,se=Math.min(780,Math.max(320,window.innerWidth-32)),ve=Math.max(Q,window.innerWidth-se-Q),Ce=Math.min(Math.max(Q,D.left),ve),$e=D.bottom+_,Ue=window.innerHeight-D.top+_,Ke=window.innerHeight-$e-Q,yt=D.top-Q-_,rt=Ke<280&&yt>Ke,xe=Math.max(240,rt?yt:Ke);am({position:"fixed",zIndex:1e4,left:Ce,top:rt?void 0:$e,bottom:rt?Ue:void 0,width:se,maxWidth:"calc(100vw - 24px)",maxHeight:xe,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ze)return;function h(_){var ve,Ce;if(Date.now()<Si.current)return;const se=_.target;(ve=Bo.current)!=null&&ve.contains(se)||(Ce=ki.current)!=null&&Ce.contains(se)||(Qe(!1),vt(!1),It(!1))}function D(_){_.key==="Escape"&&(Qe(!1),vt(!1),It(!1))}function Q(){Sa()}return Sa(),document.addEventListener("mousedown",h),window.addEventListener("keydown",D),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",D),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ze,Sa]);function Fi(h){const D=Rt(h,e);Fe||ct(D),R==null||R(D)}function Nm(h){Fi(qe.includes(h)?qe.filter(D=>D!==h):[...qe,h])}function km(){Fi([])}const qo=s.useCallback((h=va.current)=>{if(!h)return;const D=h.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),_=Math.max(8,window.innerWidth-Q-8),se=Math.min(Math.max(8,D.right-Q),_),ve=window.innerHeight-D.bottom,Ce=D.bottom+6,$e=window.innerHeight-D.top+6,Ke=ve<360&&D.top>ve?void 0:Ce,yt=Ke===void 0?$e:void 0,rt=Math.max(220,Ke===void 0?D.top-16:window.innerHeight-Ce-8),xe={position:"fixed",zIndex:9999,left:se,top:Ke,bottom:yt,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:rt,"--dt-column-menu-max-height":`${rt}px`};sm(xe)},[]);function Pi(h,D,Q=null){h.preventDefault(),h.stopPropagation();const _=va.current===h.currentTarget&&mt===D&&ut===Q;if(Ye&&_){dt(!1),ze(null);return}va.current=h.currentTarget,mr(D),ze(Q),ba(""),qo(h.currentTarget),dt(!0)}function Sm(h){if(fr(h))return;const D=ir.current;if(!D)return;const _=Array.from(D.querySelectorAll("[data-dt-column-key]")).filter(se=>se.dataset.dtColumnKey===h.key).reduce((se,ve)=>{const Ce=ve.querySelector("[data-dt-autofit-content]"),$e=Ce?Ce.scrollWidth:Math.max(ve.scrollWidth,ve.offsetWidth);return Math.max(se,Math.ceil($e+Vc(ve)))},0);_<=0||Yr(se=>({...se,[h.key]:xt(h,_+12)}))}s.useEffect(()=>{Yr(h=>{const D=Object.fromEntries(e.map(Q=>[Q.key,xt(Q,Yt(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,xt(Q,h[Q.key]??D[Q.key])]))})},[Oe,e]),s.useEffect(()=>{Fe||ct(h=>Rt(h,e))},[Oe,e,Fe]),s.useEffect(()=>{function h(_){var Ce,$e;const se=_.target,ve=_.target;ve!=null&&ve.closest("[data-bonsaif-select-dropdown='true']")||!((Ce=Ei.current)!=null&&Ce.contains(se))&&!(($e=va.current)!=null&&$e.contains(se))&&(dt(!1),ze(null))}function D(_){_.key==="Escape"&&(dt(!1),ze(null))}function Q(){qo()}return Ye&&(document.addEventListener("mousedown",h),window.addEventListener("keydown",D),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",h),window.removeEventListener("keydown",D),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ye,qo]);const xn=s.useRef(null);s.useEffect(()=>{function h(Q){const _=xn.current;if(!_)return;const se=Q.clientX-_.startX,ve=e.find(Ce=>Ce.key===_.colKey);ve&&Yr(Ce=>({...Ce,[_.colKey]:xt(ve,_.startWidth+se)}))}function D(){xn.current&&(xn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",h),document.addEventListener("pointerup",D),()=>{document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",D)}},[e]);const wn=s.useRef(null),[_i,Uo]=s.useState(null);function Em(h,D){const Q=e.find(_=>_.key===h);if(!Q||!vs(Q)){D.preventDefault();return}wn.current=Ur.indexOf(h),D.dataTransfer.effectAllowed="move"}function Cm(h,D){D.preventDefault(),D.dataTransfer.dropEffect="move";const Q=Ur.indexOf(h);_i!==Q&&Uo(Q)}function Mm(h,D){D.preventDefault();const Q=wn.current,_=Ur.indexOf(h);Q!==null&&Q!==_&&Vr(se=>{const ve=[...se],[Ce]=ve.splice(Q,1);return ve.splice(_,0,Ce),Jt(ve,e)}),wn.current=null,Uo(null)}function Tm(){wn.current=null,Uo(null)}function $m(h){h.sortKey&&gr(D=>(D==null?void 0:D.key)===h.key?{key:h.key,dir:D.dir==="asc"?"desc":"asc"}:{key:h.key,dir:"asc"})}s.useEffect(()=>{ya(1)},[r]),s.useEffect(()=>{ya(1)},[Tt,ht]);const qt=!!(q&&le),cr=C!==!1,Vo=s.useMemo(()=>nn(w??Jr()),[w]),it=qt?K??1:mm,zi=cr&&xa<1?typeof C=="number"&&C>0?C:Vo[0]??25:xa,Ut=qt||cr?zi:r.length,Bt=!!k&&!!v&&!!A,Yo=s.useMemo(()=>E?r.filter(h=>E(h)):r,[r,E]),Xr=!!u,Wi=s.useMemo(()=>new Set(jr?Array.from(b??[]):z),[jr,b,z]),Am=(Xr?40:0)+(Bt?40:0),Xo=!fm&&(Li||G),Ea=(()=>{if(!Xo)return{};let h=Am;const D={};return $t.forEach((Q,_)=>{(qa(Q)||!Li&&G&&_===0)&&(D[Q.key]=h,h+=pr[Q.key]??xt(Q,Yt(Q.width)))}),D})(),Ko=Object.keys(Ea),Go=Ko.length>0?Ko[Ko.length-1]:null,ji=Bt&&Yo.length>0&&Yo.every(h=>k.has(n(h))),Lm=Bt&&k.size>0&&Yo.some(h=>k.has(n(h)))&&!ji,Ca=s.useMemo(()=>{if(qt)return r;const h=Object.entries(ht),D=Object.entries(Tt);return h.length===0&&D.length===0?r:r.filter(Q=>h.every(([_,se])=>{const ve=e.find(Ce=>Ce.key===_);return ve?se.includes(On(ve,Q)):!0})&&D.every(([_,se])=>{const ve=e.find($e=>$e.key===_);if(!ve)return!0;const Ce=r.map($e=>On(ve,$e));return Kc(On(ve,Q),se,Ce)}))},[Tt,ht,e,r,qt]),vr=s.useMemo(()=>{if(!Je)return Ca;const h=e.find(D=>D.key===Je.key&&D.sortKey);return h!=null&&h.sortKey?[...Ca].sort((D,Q)=>{const _=D[h.sortKey],se=Q[h.sortKey],ve=_===se?0:_==null?1:se==null||_<se?-1:1;return Je.dir==="asc"?ve:-ve}):Ca},[Ca,Je,e]),qi=s.useMemo(()=>{if(qt||!cr)return vr;const h=(it-1)*Ut;return vr.slice(h,h+Ut)},[vr,qt,cr,it,Ut]),Zt=qt?O??r.length:vr.length,Zo=cr?Math.max(1,Math.ceil(Zt/Ut)):1,Dm=Math.min(...Vo),Om=cr&&(Zt>Ut||Zt>Dm),Hm=cr?(it-1)*Ut+1:1,Im=cr?Math.min(it*Ut,Zt):Zt;function Qo(h){if(a)return;const D=Math.max(1,Math.min(h,Zo));qt?q(D):ya(D)}function Bm(h){a||(J&&(hr.current=J),wa(h),qt?(le(h),q(1)):(ya(1),le==null||le(h)))}function Ui(h){const D=new Set(Wi);D.has(h)?D.delete(h):D.add(h);const Q=Array.from(D);jr||Z(Q),p==null||p(Q)}s.useEffect(()=>{De==null||De({bql:ye,filters:ht,conditionFilters:Tt,sort:Je,page:it,pageSize:Ut,hiddenColumnKeys:qe})},[ye,ht,Tt,Je,it,Ut,qe,De]);const Vi=h=>h==="center"?"justify-center text-center":h==="right"?"justify-end text-right":"justify-start text-left",Fm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Jo="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",_e="color-mix(in srgb, var(--border) 62%, var(--bg-card))",yr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ma=`inset 0 0 0 1px ${_e}`,Yi=$t.reduce((h,D)=>h+(pr[D.key]??Yt(D.width)),(Xr?40:0)+(Bt?40:0)),Xi=typeof B=="number"?B:typeof B=="string"?Number(((Ri=B.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ri[1])??NaN):NaN,Nn=Number.isFinite(Xi)?Math.max(Yi,Xi,Ti):Math.max(Yi,Ti),Ta=B??Nn,Kr=`${Xr?"40px ":""}${Bt?"40px ":""}${$t.map(h=>`${pr[h.key]??Yt(h.width)}px`).join(" ")}`;s.useEffect(()=>{Je&&qe.includes(Je.key)&&gr(null)},[qe,Je]);function Ki(h){return h?typeof h=="string"?{key:h,label:h}:h:null}const $a=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,background:Jo,borderBottom:`1px solid ${yr}`},children:[Xr&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`}}),Bt&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Xo?{position:"sticky",left:0,zIndex:12,background:Jo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`},children:t.jsx(Mn,{size:"sm",checked:ji,indeterminate:Lm,onChange:A,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),$t.map((h,D)=>{const Q=(Je==null?void 0:Je.key)===h.key,_=!!h.sortKey,se=fr(h),ve=Ea[h.key],Ce=ve!==void 0,$e=h.key===Go,Ue=vs(h),Ke=_i===D,rt=(pr[h.key]??Yt(h.width))<120,xe=Object.prototype.hasOwnProperty.call(ht,h.key)||Object.prototype.hasOwnProperty.call(Tt,h.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":h.key,className:`group select-none ${rt?"text-left":Vi(h.align)}`,style:{...Ce?{position:"sticky",left:ve,zIndex:12,background:Jo,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${yr}`:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${_e}`}:{position:"relative",borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${_e}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ke?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:se?Y?"7px 6px":"9px 8px":Y?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ae=>{(Ue||wn.current!==null)&&Cm(h.key,Ae)},onDrop:Ae=>Mm(h.key,Ae),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${se?"justify-center":rt?"justify-start":h.align==="center"?"justify-center":h.align==="right"?"justify-end":"justify-start"}`,children:[Ue?t.jsx("span",{draggable:!0,onDragStart:Ae=>{Ae.stopPropagation(),Em(h.key,Ae)},onDragEnd:Ae=>{Ae.stopPropagation(),Tm()},onClick:Ae=>Ae.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${Ke?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,se?t.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:t.jsx(W.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(ys,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${Y?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:h.header})})}),_&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(h.header)}`,title:"Ordenar",onClick:Ae=>{Ae.stopPropagation(),$m(h)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${Q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Q?Je.dir==="asc"?t.jsx(W.HiChevronUp,{className:"h-3 w-3"}):t.jsx(W.HiChevronDown,{className:"h-3 w-3"}):t.jsx(W.HiChevronUpDown,{className:"h-3 w-3"})}),I&&!se&&vm(h)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&ut===h.key,"aria-label":`Filtrar ${String(h.header)}`,title:"Filtrar",onClick:Ae=>Pi(Ae,"filter",h.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ye&&mt==="filter"&&ut===h.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":xe?"text-[var(--primary)] opacity-100":""}`,children:xe?t.jsx(W.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(W.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!se&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),xn.current={colKey:h.key,startX:Ae.clientX,startWidth:pr[h.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),xn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Sm(h)},onClick:Ae=>Ae.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},h.key)})]}),Aa=()=>{if(!Ye||typeof document>"u"||mt==="visibility"&&!de||mt==="filter"&&!I)return null;const h=e.find(xe=>xe.key===ut),D=gm(),Q=h?Object.prototype.hasOwnProperty.call(ht,h.key):!1,_=h?Tt[h.key]:void 0,se=An.find(xe=>xe.value===(_==null?void 0:_.operator)),ve=h?ht[h.key]??[]:[],Ce=vn.trim().toLowerCase(),$e=Ce?D.filter(xe=>xe.label.toLowerCase().includes(Ce)):D,Ue=h&&D.length>0&&(!Q||ve.length===D.length),Ke=h&&Q&&ve.length>0&&ve.length<D.length,yt=qe.length,rt=()=>{h&&(Wo(h.key),Hi(h.key))};return pt.createPortal(t.jsx("div",{ref:Ei,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...om,borderColor:"var(--border)",background:"var(--bg-card)"},children:mt==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:yt>0?`${$t.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:km,disabled:yt===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:Ai.map(xe=>{const Ae=!qe.includes(xe.key),we=!(xe.hideable!==!1)||Ae&&$t.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,disabled:we,onClick:()=>Nm(xe.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.header})]},xe.key)})})]}):h?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",h.header]}),t.jsx("button",{type:"button",onClick:rt,disabled:!Q&&!_,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),h.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>gr({key:h.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(W.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Je==null?void 0:Je.key)===h.key&&Je.dir==="asc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>gr({key:h.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(W.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Je==null?void 0:Je.key)===h.key&&Je.dir==="desc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(ur,{value:(_==null?void 0:_.operator)??"",onChange:xe=>{if(!xe){Hi(h.key);return}Na(h.key,{operator:xe,value:(_==null?void 0:_.value)??"",valueTo:(_==null?void 0:_.valueTo)??""})},options:Bc,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(se==null?void 0:se.valueMode)!=="none"?t.jsx("input",{value:(_==null?void 0:_.value)??"",onChange:xe=>{_&&Na(h.key,{..._,value:xe.target.value})},disabled:!_,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):t.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(se==null?void 0:se.valueMode)==="between"&&t.jsx("input",{value:(_==null?void 0:_.valueTo)??"",onChange:xe=>{_&&Na(h.key,{..._,valueTo:xe.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:vn,onChange:xe=>ba(xe.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ke?"mixed":!!Ue,onClick:()=>{h&&(Ue&&!Q?Oi(h.key,[]):Wo(h.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ue||Ke?"var(--primary)":"var(--border)",background:Ue||Ke?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ke&&t.jsx(W.HiMinus,{className:"h-3 w-3"}),Ue&&!Ke&&t.jsx(W.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(xe=>{const Ae=!Q||ve.includes(xe.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,onClick:()=>ym(h.key,xe.value,D.map(ke=>ke.value),Q),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.label})]},xe.value)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!yn)return;function h(D){Po.current&&!Po.current.contains(D.target)&&ga.current&&!ga.current.contains(D.target)&&pa(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[yn]);function Gi(h,D){if(h.filterValue){const Q=h.filterValue(D);return Q==null||Q===""?"":Tn(Q)}return Tn(Sr(h.cell(D)))}function Zi(h){return`"${Tn(h).replace(/"/g,'""')}"`}function La(h){return Tn(h).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Qi(){return qt&&Zt>vr.length&&Ia.toast.warning(`Exportando ${vr.length.toLocaleString("es-MX")} de ${Zt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),vr}function Pm(){const h=$t.filter(Ue=>!fr(Ue)),D=Qi(),Q=h.map(Ue=>Zi(Sr(Ue.header))).join(","),_=D.map(Ue=>h.map(Ke=>Zi(Gi(Ke,Ue))).join(",")).join(`
|
|
5
|
+
`),se=`${Q}
|
|
6
|
+
${_}`,ve=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),Ce=URL.createObjectURL(ve),$e=document.createElement("a");$e.href=Ce,$e.download=`${st}.csv`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Ce)}function _m(){const h=$t.filter($e=>!fr($e)),D=Qi(),Q=h.map($e=>La(Sr($e.header))),se=D.map($e=>h.map(Ue=>La(Gi(Ue,$e)))).map($e=>`<tr>${$e.map(Ue=>`<td>${Ue}</td>`).join("")}</tr>`).join(""),ve=`<!DOCTYPE html>
|
|
7
|
+
<html lang="es"><head><meta charset="utf-8"><title>${La(st)}</title>
|
|
8
8
|
<style>
|
|
9
9
|
body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
|
|
10
10
|
h3{margin:0 0 4px;font-size:14px}
|
|
@@ -15,24 +15,24 @@ ${P}`,ve=new Blob(["\uFEFF"+oe],{type:"text/csv;charset=utf-8;"}),Ce=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>${
|
|
18
|
+
<h3>${La(st)}</h3>
|
|
19
|
+
<p>${D.length} registros · ${new Date().toLocaleDateString("es")}</p>
|
|
20
20
|
<table><thead><tr>${Q.map($e=>`<th>${$e}</th>`).join("")}</tr></thead>
|
|
21
|
-
<tbody>${
|
|
21
|
+
<tbody>${se}</tbody></table>
|
|
22
22
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
23
|
-
</body></html>`,Ce=window.open("","_blank");Ce&&(Ce.document.write(ve),Ce.document.close())}const
|
|
24
|
-
`).map(Ce=>Ce.trim()).filter(Boolean)).has(oe):!1}).slice(0,8);return!le&&Bo===0&&!I&&!He?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[Bo>0&&t.jsxs("button",{type:"button",onClick:mm,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"}),Bo," filtros"]}),I&&t.jsxs("div",{ref:Do,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Je){Re(!1);return}ka(),Re(!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:Je?"var(--primary)":h?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Je||h?"var(--primary)":"var(--border)",color:Je?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Je,title:"Abrir filtros BQL",children:[t.jsx(j.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",h&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Je?t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:y}),$.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[$.slice(0,3).map(P=>t.jsxs("span",{className:"inline-flex max-w-44 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key)),$.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",$.length-3]})]}),h&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Li,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:t.jsx(j.HiXMark,{className:"h-4 w-4"})}),Je&>.createPortal(t.jsxs("div",{ref:vi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Qb,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[te.map(P=>t.jsxs("button",{type:"button",onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(P.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[P.icon,P.label]},P.label)),fe.length>0&&t.jsxs("button",{type:"button",onClick:()=>xt(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":or,children:[t.jsx(j.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),sr.length>0&&t.jsxs("button",{type:"button",onClick:()=>Ht(P=>!P),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":Kt,children:[t.jsx(j.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Ae?"var(--danger)":h?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Oo,value:Fe,rows:3,onChange:P=>Po(P.target.value,P.target),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),Ai(Fe)),P.key==="Escape"&&Re(!1)},placeholder:T,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),Q.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:Q.map(P=>t.jsx("button",{type:"button",onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(P)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:P},P))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Ae?"var(--danger)":"var(--text-muted)"},children:Ae??(h?`${$.length||1} filtro${($.length||1)===1?"":"s"} activo${($.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),$.map(P=>t.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[P.label,":"]}),t.jsx("span",{className:"truncate",children:P.value})]},P.key))]}),Kt&&sr.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(j.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Gt([]),Ht(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(j.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),sr.map(P=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(P)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P})}),t.jsx("button",{type:"button",onClick:()=>Gt(oe=>oe.filter(ve=>ve!==P)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"})})]},P))]}),or&&fe.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:fe.map(P=>t.jsxs("button",{type:"button",onMouseDown:oe=>{oe.preventDefault(),oe.stopPropagation()},onClick:oe=>{oe.preventDefault(),oe.stopPropagation(),Na(P.bql),xt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:P.bql}),P.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:P.description})]},P.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[h&&t.jsxs("button",{type:"button",onClick:Li,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ai(Fe),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(j.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),He&&t.jsx("button",{ref:pa,type:"button","aria-haspopup":"menu","aria-expanded":xn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var oe;const P=(oe=pa.current)==null?void 0:oe.getBoundingClientRect();P&&rm({top:P.bottom+4,right:window.innerWidth-P.right}),ha(ve=>!ve)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${xn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiArrowDownTray,{className:"h-4 w-4"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ve&&ht==="visibility","aria-label":_,title:_,onClick:P=>Oi(P,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Ve&&ht==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(j.HiCog6Tooth,{className:"h-4 w-4"})})]})},Yi=()=>{if(!Mm)return null;const h=Wc(it,Xo);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${Y?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Zt===0?"0 filas":`${Tm}–${$m} de ${Zt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(dr,{value:String(qt),onChange:$=>Am(Number($)),options:Wo.map($=>({value:String($),label:String($)})),placeholder:"Filas",searchable:!1,disabled:a,height:X,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:z}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||it<=1,onClick:()=>Yo(it-1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(j.HiChevronLeft,{className:"h-3.5 w-3.5"})}),h.map(($,Q)=>$==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>Yo($),onMouseEnter:P=>{P.currentTarget.disabled||$===it||(P.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",P.currentTarget.style.color="var(--primary)")},onMouseLeave:P=>{P.currentTarget.style.background=$===it?"var(--primary)":"transparent",P.currentTarget.style.color=$===it?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:$===it?"var(--primary)":"transparent",color:$===it?"var(--primary-fg)":"var(--text-muted)"},children:$},$)),t.jsx("button",{disabled:a||it>=Xo,onClick:()=>Yo(it+1),onMouseEnter:$=>{$.currentTarget.disabled||($.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",$.currentTarget.style.color="var(--primary)")},onMouseLeave:$=>{$.currentTarget.style.background="transparent",$.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(j.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},Hm=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((h,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Pe}`},children:[It&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`}},"select-cell"),$t.map((Q,P)=>t.jsx("div",{role:"cell",className:Y?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Ni($,P)}%`,minWidth:32}})},Q.key))]},$))})]})})]}),Go="min-w-0 max-w-full overflow-hidden";return J&&Se&&!ct?t.jsx(Cn,{rows:o,columns:Math.max(4,$t.length||7)}):!a&&r.length===0&&!Io?Hm():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Si,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((h,$)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr,borderBottom:`1px solid ${Pe}`},children:[It&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`}},"select-cell"),$t.map((Q,P)=>{const oe=Sa[Q.key],ve=oe!==void 0,Ce=Q.key===Vo;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:Y?"px-2 py-1.5":"px-3 py-2",style:ve?{position:"sticky",left:oe,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Pe}`:`inset 0 -1px 0 ${Pe}`,borderRight:`1px solid ${Pe}`}:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Ni($,P)}%`,minWidth:32}})},Q.key)})]},$))})]})})}),Yi()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Pe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??t.jsx(j.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ca},children:[$a(),La(),Da(),t.jsx("div",{ref:lr,className:Go,children:t.jsx(Zo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Si,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ma},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ta()}),t.jsx("div",{role:"rowgroup",children:Pi.map((h,$)=>{const Q=n(h),P=qi(k==null?void 0:k(h)),oe=$>0?qi(k==null?void 0:k(Pi[$-1])):null,ve=P&&P.key!==(oe==null?void 0:oe.key),Ce=It&&E.has(Q),$e=It&&(!A||A(h)),Ue=Xr?(m==null?void 0:m(h))??!0:!1,Ze=Ue&&Bi.has(Q),yt=!!d||p&&Ue,nt=Ce&&C?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":$%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[ve&&t.jsx("div",{role:"row",className:`grid ${P.className??""}`,style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:P.label}),P.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:P.description})]})})})}),t.jsxs("div",{role:"row",onClick:yt?ye=>{const Le=ye.target;if(!(Le!=null&&Le.closest('[data-dt-disable-row-click="true"]'))){if(p&&Ue){_i(Q);return}d==null||d(h)}}:void 0,className:`grid transition-colors ${yt?"cursor-pointer":""} ${H?H(h):""}`,style:{gridTemplateColumns:Yr,"--dt-row-bg":nt,"--dt-sticky-bg":nt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Pe}`},onMouseEnter:ye=>{Ce||(ye.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ye.currentTarget.style.setProperty("--dt-sticky-bg",Lm))},onMouseLeave:ye=>{ye.currentTarget.style.setProperty("--dt-row-bg",nt),ye.currentTarget.style.setProperty("--dt-sticky-bg",nt)},children:[Xr&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},"data-dt-disable-row-click":"true",children:Ue&&t.jsx("button",{type:"button","aria-label":Ze?"Contraer fila":"Desplegar fila","aria-expanded":Ze,onClick:ye=>{ye.stopPropagation(),_i(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:Ze?t.jsx(j.HiChevronDown,{className:"h-4 w-4"}):t.jsx(j.HiChevronRight,{className:"h-4 w-4"})})}),It&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:qo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Pe}`}:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`},onClick:ye=>{ye.stopPropagation(),$e&&v(Q)},children:t.jsx(Mn,{size:"sm",checked:Ce,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ye=>ye.stopPropagation(),onChange:()=>{$e&&v(Q)}})}),$t.map(ye=>{const Le=Sa[ye.key],ke=Le!==void 0,we=ye.key===Vo,Ne=ur(ye);return t.jsx("div",{role:"cell","data-dt-column-key":ye.key,"data-dt-disable-row-click":ye.disableRowClick||Ne?"true":void 0,className:`${Ne?"px-2 py-1.5 justify-center text-center":`${Y?"px-2 py-1.5":"px-3 py-2"} ${zi(ye.align)}`} flex min-w-0 items-center ${Ic} ${ye.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...ke?{position:"sticky",left:Le,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Pe}`:`inset 0 -1px 0 ${Pe}`,borderRight:`1px solid ${Pe}`}:{borderBottom:`1px solid ${Pe}`,borderRight:`1px solid ${Pe}`}},children:t.jsx(hs,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ye.cell(h)})})},ye.key)})]}),Ze&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Yr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Pe}`},children:u(h)})})]},Q)})})]})})}),Yi()]})}const Uc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Hn({title:e="Sin resultados",description:r,icon:n=t.jsx(j.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:o,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Uc[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 Ft(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 ps(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function nn(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Er(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function gs(e){const r=nn(e),n=(r.getDay()+6)%7;return Er(r,-n)}function vs(e){const r=gs(e);return Array.from({length:7},(n,a)=>Er(r,a))}function xs(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=gs(r);return Array.from({length:42},(a,o)=>Er(n,o))}function ys(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Vc(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function er(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=ps(n.start);if(!a)return null;const o=ps(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function ws(e,r){const n={};for(const a of e){const o=er(a,r);if(!o)continue;let l=nn(o.start);const i=nn(o.end);for(;l.getTime()<=i.getTime();){const c=Ft(l);n[c]||(n[c]=[]),n[c].push(a),l=Er(l,1)}}return n}function Ua(e,r,n){if(r.length===0)return[];const a=nn(r[0]),o=nn(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const m=er(d,n),b=er(u,n),f=(m==null?void 0:m.start.getTime())??0,g=(b==null?void 0:b.start.getTime())??0;return f-g||d.title.localeCompare(u.title)});for(const d of c){const u=er(d,n);if(!u||!Vc(u.start,u.end,a,o))continue;const m=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((m.getTime()-a.getTime())/864e5)),g=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),p=Math.max(1,g-f+1);let E=l.findIndex(v=>v<f);E<0?(E=l.length,l.push(f+p-1)):l[E]=f+p-1,i.push({item:d,lane:E,colStart:f,colSpan:p})}return i}function Lt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Xc(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Yc(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 Ns(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 ks(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?Er(e,n*7):Er(e,n)}const Kc=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"];function Gc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Bt,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function Zc({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=er(e),l=o?`${Lt(o.start)} → ${Lt(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function Qc({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=er(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function Ss({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 Es({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 Jc({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:m=[...Kc],renderToolbarExtra:b,renderPill:f,renderDayCard:g,renderWeekBar:p,tableColumns:E,tableProps:v,onItemClick:w,onDayClick:A,loading:C=!1,emptyTitle:H="Sin eventos",emptyDescription:k="No hay eventos para los filtros seleccionados.",legend:x,legendInteractive:M=!0,activeLegendKeys:N,defaultActiveLegendKeys:z,onActiveLegendKeysChange:X,getItemLegendKey:K,overloadLabel:D="Sobrecarga de eventos",notice:G,showOverload:V=!0,layout:ne="span",className:J="",showToolbar:R=!0}){const U=s.useMemo(()=>(x??[]).map(ue=>ue.label),[x]),[Y,ce]=s.useState(()=>z??U),L=s.useMemo(()=>N??(U.length>0?Y:[]),[N,U.length,Y]),B=s.useMemo(()=>new Set(L),[L]),le=ue=>{N===void 0&&ce(ue),X==null||X(ue)},O=ue=>{M&&(B.has(ue)?le(L.filter(Te=>Te!==ue)):le([...L,ue]))},ae=s.useMemo(()=>{if(!M||U.length===0)return e;const ue=new Set(U);return e.filter(Te=>{const He=(K==null?void 0:K(Te))??Te.status;return!He||!ue.has(He)?!0:B.has(He)})},[e,M,U,B,K]),S=s.useMemo(()=>ws(ae,c),[ae,c]),ee=s.useMemo(()=>xs(r),[r]),_=s.useMemo(()=>ys(ee),[ee]),I=s.useMemo(()=>vs(r),[r]),de=Ft(r),re=S[de]??[],F=s.useMemo(()=>Ua(ae,I,c),[ae,I,c]),y=s.useMemo(()=>F.length===0?1:Math.max(...F.map(ue=>ue.lane))+1,[F]),T=s.useMemo(()=>_.map(ue=>{const Te=Ua(ae,ue,c),He=Te.length===0?0:Math.max(...Te.map(Xe=>Xe.lane))+1;return{days:ue,bars:Te,laneCount:He}}),[_,ae,c]),te=36,fe=38,se=s.useMemo(()=>{const ue=l==="month"?ee:l==="week"?I:[r],Te=[];for(const He of ue){const Xe=Ft(He),je=S[Xe]??[];je.length>=u&&Te.push([He,je])}return Te},[l,ee,I,r,S,u]),he=l==="month"?Xc(r):l==="week"?`${Lt(I[0])} – ${Lt(I[6])}`:Yc(r),Ae=s.useMemo(()=>[{key:"title",header:"Título",cell:ue=>ue.title},{key:"status",header:"Estado",cell:ue=>ue.status??"—"},{key:"range",header:"Rango",cell:ue=>{const Te=er(ue,c);return Te?`${Lt(Te.start)} → ${Lt(Te.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ue=>ue.subtitle??"—"}],[c]),De=ue=>{if(n(ue),A){A(ue);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${J}`.trim(),children:[R?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(ks(r,l,-1)),children:t.jsx(j.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:he}),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(ks(r,l,1)),children:t.jsx(j.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b,t.jsx(Es,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(j.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(j.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(Es,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,x&&x.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:M?"group":void 0,"aria-label":M?"Filtrar por estado":void 0,children:x.map(ue=>{const Te=B.has(ue.label);return M?t.jsxs("button",{type:"button","aria-pressed":Te,onClick:()=>O(ue.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Te?"var(--text-main)":"var(--text-muted)",background:Te?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Te?`1px solid color-mix(in srgb, ${ue.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Te?1:.45},title:Te?`Ocultar “${ue.label}”`:`Mostrar “${ue.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ue.color,boxShadow:Te?`0 0 0 2px color-mix(in srgb, ${ue.color} 25%, transparent)`:void 0},"aria-hidden":!0}),ue.label]},ue.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:ue.color},"aria-hidden":!0}),ue.label]},ue.label)})}):null,a==="calendar"&&G&&G.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:G.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:[G.label,":"]})," ",G.items.join(", ")]}):a==="calendar"&&V&&se.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[D,":"]})," ",se.map(([ue,Te])=>`${Lt(ue)} (${Te.length})`).join(", ")]}):null,a==="table"?C||ae.length>0?t.jsx(qa,{columns:E??Ae,data:ae,getRowId:ue=>ue.id,loading:C,skeletonRows:8,emptyIcon:t.jsx(j.HiCalendarDays,{className:"h-10 w-10"}),emptyText:k,onRowClick:w,pageSize:25,compact:!0,...v}):t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:H,description:k}):null,a==="calendar"&&l==="month"&&ne==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--border)"},children:m.map(ue=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ue},ue))}),t.jsx("div",{className:"grid grid-cols-7",children:ee.map(ue=>{const Te=Ft(ue),He=S[Te]??[],Xe=ue.getMonth()!==r.getMonth(),je=Math.max(0,He.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${ue.getDate()}`,onClick:()=>De(ue),onKeyDown:Ye=>{(Ye.key==="Enter"||Ye.key===" ")&&(Ye.preventDefault(),De(ue))},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:Xe?"var(--text-muted)":"var(--text-main)"},children:ue.getDate()}),He.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:He.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[He.slice(0,d).map(Ye=>t.jsx(Ss,{item:Ye,day:ue,renderPill:f,onClick:()=>w==null?void 0:w(Ye)},Ye.id)),je>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",je," más"]}):null]})]},Te)})})]}):null,a==="calendar"&&l==="month"&&ne==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--border)"},children:m.map(ue=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ue},ue))}),T.map(({days:ue,bars:Te,laneCount:He},Xe)=>{const je=Math.min(He,d),Ye=Math.max(0,He-d),ie=te+Math.max(1,je)*fe+(Ye>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:ie,borderBottom:Xe<T.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:"grid grid-cols-7",style:{minHeight:ie},children:ue.map(Se=>{const _e=Ft(Se),ot=S[_e]??[],Ke=Se.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Se.getDate()}`,onClick:()=>De(Se),onKeyDown:lt=>{(lt.key==="Enter"||lt.key===" ")&&(lt.preventDefault(),De(Se))},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:ie},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Ke?"var(--text-muted)":"var(--text-main)"},children:Se.getDate()}),ot.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ot.length}):null]})},_e)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:te,bottom:4},children:[Te.filter(Se=>Se.lane<d).map(Se=>{const _e={left:`calc(${Se.colStart/7*100}% + 4px)`,width:`calc(${Se.colSpan/7*100}% - 8px)`,top:2+Se.lane*fe,height:fe-6,pointerEvents:"auto"};return f?t.jsx("div",{className:"absolute overflow-hidden",style:_e,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:f(Se.item,{day:ue[Se.colStart]})})},`${Se.item.id}-${Se.colStart}-${Xe}`):p?t.jsx("div",{className:"absolute overflow-hidden",style:_e,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(Se.item)})},`${Se.item.id}-${Se.colStart}-${Xe}`):t.jsx(Gc,{item:Se.item,style:_e,onClick:()=>w==null?void 0:w(Se.item)},`${Se.item.id}-${Se.colStart}-${Xe}`)}),Ye>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+je*fe,color:"var(--text-muted)"},children:["+",Ye," más"]}):null]})]},`week-${Xe}-${Ft(ue[0])}`)})]}):null,a==="calendar"&&l==="week"&&ne==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:"grid grid-cols-7",children:I.map(ue=>{const Te=Ft(ue),He=S[Te]??[],Xe=Math.max(0,He.length-d);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>De(ue),children:[Ns(ue),t.jsx("span",{className:"mt-1 block text-sm",children:ue.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[He.slice(0,d).map(je=>t.jsx(Ss,{item:je,day:ue,renderPill:f,onClick:()=>w==null?void 0:w(je)},je.id)),Xe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Xe," más"]}):null]})]},Te)})})}):null,a==="calendar"&&l==="week"&&ne==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:"grid grid-cols-7 border-b",style:{borderColor:"var(--border)"},children:I.map(ue=>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:()=>De(ue),children:Ns(ue)},Ft(ue)))}),t.jsxs("div",{className:"relative grid grid-cols-7",style:{minHeight:Math.max(220,y*56+24)},children:[I.map(ue=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Ft(ue)}`)),F.map(ue=>{const Te={left:`calc(${ue.colStart/7*100}% + 4px)`,width:`calc(${ue.colSpan/7*100}% - 8px)`,top:12+ue.lane*56,height:48};return p?t.jsx("div",{className:"absolute overflow-hidden",style:Te,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(ue.item)})},`${ue.item.id}-${ue.colStart}`):t.jsx(Qc,{item:ue.item,style:Te,onClick:()=>w==null?void 0:w(ue.item)},`${ue.item.id}-${ue.colStart}`)}),F.length===0&&!C?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:k}):null]})]}):null,a==="calendar"&&l==="day"?re.length>0||C?t.jsxs("div",{className:"space-y-3",children:[C&&re.length===0?t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,re.map(ue=>g?t.jsx("div",{children:g(ue)},ue.id):t.jsx(Zc,{item:ue,onClick:()=>w==null?void 0:w(ue)},ue.id))]}):t.jsx(Hn,{icon:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),title:H,description:k}):null]})}function Cs(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function Rc(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Cs(e)}function ed(e){return typeof e=="function"?e():e}function Va({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(j.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(j.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:g,type:p="button",...E}){const[v,w]=s.useState(!1),A=s.useRef(null);s.useEffect(()=>()=>{A.current&&window.clearTimeout(A.current)},[]);function C(k){w(!0),d==null||d(k),A.current&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{w(!1),A.current=null},r)}async function H(k){var M;if(c&&k.stopPropagation(),g==null||g(k),k.defaultPrevented)return;const x=ed(e);if(x)try{await Rc(x),C(x)}catch(N){try{Cs(x),C(x)}catch(z){u==null||u(z,x);return}(M=navigator.clipboard)!=null&&M.writeText||u==null||u(N,x)}}return t.jsxs("button",{...E,type:p,onClick:H,title:v?a:n,"aria-label":E["aria-label"]??(v?a:n),"data-copied":v?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:v?"scale(1.15)":"scale(1)"},children:v?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??f:f})]})}function td({code:e,children:r,title:n="Codigo",language:a,copyLabel:o="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(Va,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:o})]}),t.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function In(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function rd({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(j.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:In(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:In(o),padding:In(l)}})]})}function nd({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=o?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[o&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:In(d)},children:o}),t.jsx(dr,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const ad={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Bn=180,od="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Xa({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:g=!0,placement:p="center",bodyClassName:E="px-6 py-5",panelClassName:v="",backdropClassName:w=od,contentClassName:A="p-4",ariaLabel:C,frameless:H=!1,disabled:k=!1}){const[x,M]=s.useState(!1),[N,z]=s.useState(!1),X=s.useRef(null);if(s.useEffect(()=>(e?(X.current&&clearTimeout(X.current),M(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>z(!0)))):(z(!1),X.current=setTimeout(()=>M(!1),Bn+40)),()=>{X.current&&clearTimeout(X.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const J=R=>{R.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[f,r,e]),!x)return null;const K=n||a||o||l||g,D=u??ad[d],G=p==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",V=p==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=N?"translateY(0) scale(1)":p==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return gt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":C??n,className:`fixed inset-0 flex ${G} ${A}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${w}`,onClick:b?r:void 0,style:{opacity:N?1:0,transition:`opacity ${Bn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${H?"shadow-none":"shadow-2xl"} ${V} ${v}`,style:{maxWidth:D,background:H?"transparent":"var(--bg-card)",border:H?"none":"1px solid var(--border)",opacity:N?1:0,transform:ne,transition:`opacity ${Bn}ms ease, transform ${Bn}ms ease`},onClick:J=>J.stopPropagation(),children:[k&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),K&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[o&&t.jsx("div",{className:"flex-shrink-0",children:o}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,g&&t.jsx(Qe,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${E}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const sd={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 ld({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=sd[l];return t.jsx(Xa,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Qe,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(j.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(j.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Qe,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Qe,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function id(e){return e?typeof e=="function"?e():e:""}function cd(e){return/^https?:\/\//i.test(e)}function Ms(e,r){try{return new URL(e,r).toString()}catch{return e}}function dd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||cd(l))return l;const i=id(n);return i?Ms(l,i):a&&typeof window<"u"?Ms(l,window.location.origin):l}function ud({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(j.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Va,{...c,value:()=>dd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const fd={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 bd(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=fd[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 md=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function hd({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return s.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>o(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!md.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function pd({initialValue:e,options:r,loading:n,onCommit:a,onCancel:o}){const l=s.useRef(null);return s.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),o())},children:t.jsx(dr,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const gd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Ya={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function vd({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(r),d=s.useRef(null);s.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=s.useState(null);d.current=u;const[b,f]=s.useState(null),g=s.useRef(null);g.current=b;const[p,E]=s.useState({}),[v,w]=s.useState(null),A=s.useRef(null);A.current=v;const[C,H]=s.useState({}),[k,x]=s.useState({}),M=s.useRef(new Set),N=s.useRef(null);s.useEffect(()=>{var B;const L=document.activeElement;(!L||L===document.body)&&((B=N.current)==null||B.focus({preventScroll:!0}))},[]);const z=e.map(L=>{var B,le,O;return`${L.key}:${((O=(le=(B=L.editable)==null?void 0:B.select)==null?void 0:le.options)==null?void 0:O.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(L=>{var O,ae;const B=(ae=(O=L.editable)==null?void 0:O.select)==null?void 0:ae.options;if(!B)return;const le=C[L.key];(!M.current.has(L.key)||(le==null?void 0:le.length)===0&&B.length>0)&&(M.current.add(L.key),H(S=>({...S,[L.key]:B})))})},[z]);const X=s.useCallback(async(L,B)=>{if(M.current.has(L))return;M.current.add(L);const{url:le,fetchOptions:O}=B.select??{};if(!(!le&&!O)){x(ae=>({...ae,[L]:!0}));try{let ae=[];if(O)ae=await O();else if(le){const S=await fetch(le);if(!S.ok)throw new Error("fetch failed");ae=await S.json()}H(S=>({...S,[L]:ae}))}catch{H(ae=>({...ae,[L]:[]}))}finally{x(ae=>({...ae,[L]:!1}))}}},[]),K=s.useRef(i);K.current=i;const D=s.useRef(a);D.current=a;const G=s.useRef(n);G.current=n;const V=s.useRef(e);V.current=e;const ne=s.useRef(o);ne.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const L=e.find(B=>B.selectable!==!1);L&&f({rowId:n(r[0]),colKey:L.key})}},[]),s.useEffect(()=>{if(!b)return;const L=N.current;if(!L)return;const B=L.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!B)return;const le=L.querySelector('[role="rowgroup"]');B.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const O=L.querySelector('[role="row"]');let ae=0;O&&O.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(S=>{S.style.position==="sticky"&&S.style.left!==""&&(ae=Math.max(ae,parseFloat(S.style.left)+S.offsetWidth))}),B.style.scrollMarginLeft=`${ae}px`,B.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=s.useCallback(L=>{var ae;const B=V.current,le=new Set,O=[];(ae=N.current)==null||ae.querySelectorAll("[data-cell-id]").forEach(S=>{const ee=S.dataset.cellId.split(":")[0];le.has(ee)||(le.add(ee),O.push(ee))}),f(S=>{if(!S)return S;const ee=B.findIndex(re=>re.key===S.colKey),_=O.indexOf(S.rowId);let I=ee,de=_;if(L==="up")de=Math.max(0,_-1);else if(L==="down")de=Math.min(O.length-1,_+1);else if(L==="left"){let re=ee-1;for(;re>=0&&B[re].selectable===!1;)re--;re>=0&&(I=re)}else if(L==="right"){let re=ee+1;for(;re<B.length&&B[re].selectable===!1;)re++;re<B.length&&(I=re)}return I===ee&&de===_?S:{rowId:O[de],colKey:B[I].key}})},[]),R=s.useCallback((L=!0)=>{const B=d.current;m(null),B&&f(B),L&&setTimeout(()=>{var le;return(le=N.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),U=s.useCallback(async(L,B,le)=>{var se;const O=V.current.find(he=>he.key===B);if(!(O!=null&&O.editable))return;const{field:ae,type:S,mask:ee,validate:_}=O.editable,I=S==="number"?le===""?null:Number(le):le;if(ee){const he=bd(le,ee);if(he){E(Ae=>({...Ae,[`${L}:${B}`]:he}));return}}if(_){const he=_(I);if(he){E(Ae=>({...Ae,[`${L}:${B}`]:he}));return}}const de=G.current,re=K.current.find(he=>de(he)===L);if(!re)return;const F=re[ae];m(null),E(he=>{const Ae={...he};return delete Ae[`${L}:${B}`],Ae});const y=K.current,T=y.findIndex(he=>de(he)===L),te=y[Math.min(y.length-1,T+1)];if(f({rowId:de(te),colKey:B}),setTimeout(()=>{var Ae,De;const he=document.activeElement;(!he||he===document.body||(Ae=N.current)!=null&&Ae.contains(he))&&((De=N.current)==null||De.focus({preventScroll:!0}))},0),String(F??"")===String(I??""))return;const fe={...re,[ae]:I};c(he=>he.map(Ae=>de(Ae)===L?fe:Ae)),w({rowId:L,colKey:B});try{await((se=D.current)==null?void 0:se.call(D,{row:re,rowId:L,field:ae,oldValue:F,newValue:I}))}catch{c(he=>he.map(Ae=>de(Ae)===L?re:Ae)),E(he=>({...he,[`${L}:${B}`]:"Error al guardar. Intenta de nuevo."}))}finally{w(null)}},[]),Y=s.useCallback(L=>{if(A.current){L.preventDefault();return}if(d.current)return;const B=g.current;if(!(!B||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(L.key)))switch(L.preventDefault(),L.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(L.shiftKey?"left":"right");break;case"Enter":{const O=V.current.find(ae=>ae.key===B.colKey);O!=null&&O.editable&&!ne.current?(m(B),O.editable.type==="select"&&!M.current.has(B.colKey)&&X(B.colKey,O.editable)):J("down");break}}},[J,X]),ce=s.useMemo(()=>e.map(L=>{if(!L.editable||o){const le={...L};if(delete le.editable,delete le.selectable,L.selectable===!1)return{...le,disableRowClick:!0};const O=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const S=n(ae),ee=(b==null?void 0:b.rowId)===S&&(b==null?void 0:b.colKey)===L.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${S}:${L.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var _;A.current||(f({rowId:S,colKey:L.key}),(_=N.current)==null||_.focus({preventScroll:!0}))}}),ee&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:O(ae)})]})}}}const B=L.editable;return{...L,className:`relative ${L.className??""}`.trim(),disableRowClick:!0,cell:le=>{const O=n(le),ae=L.key,S=(u==null?void 0:u.rowId)===O&&(u==null?void 0:u.colKey)===ae,ee=(b==null?void 0:b.rowId)===O&&(b==null?void 0:b.colKey)===ae,_=p[`${O}:${ae}`],I=(v==null?void 0:v.rowId)===O&&(v==null?void 0:v.colKey)===ae,de=le[B.field],re=String(de??""),F=()=>{var T;A.current||(f({rowId:O,colKey:ae}),m({rowId:O,colKey:ae}),(T=N.current)==null||T.focus({preventScroll:!0}),B.type==="select"&&!M.current.has(ae)&&X(ae,B))};if(S){const T=B.type==="select"?t.jsx(pd,{initialValue:re,options:C[ae]??[],loading:k[ae]??!1,onCommit:te=>U(O,ae,te),onCancel:R}):t.jsx(hd,{initialValue:re,type:B.type??"text",mask:B.mask,onCommit:te=>U(O,ae,te),onCancel:R});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:gd,onClick:te=>te.stopPropagation(),children:T})}const y=L.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${O}:${ae}`,className:`peer absolute inset-0 z-10 ${I?"cursor-wait":"cursor-pointer"}`,onClick:F}),ee&&!I&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Ya}),I&&t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:Ya,children:[t.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:_?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(j.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:_})]}):t.jsx("span",{className:"truncate",children:y})}),!I&&t.jsx(j.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,u,b,v,p,C,k,n,U,R,X]);return t.jsx("div",{ref:N,tabIndex:0,onKeyDown:Y,onBlur:L=>{var B;(B=N.current)!=null&&B.contains(L.relatedTarget)||setTimeout(()=>{var O,ae;const le=document.activeElement;le&&((O=le.closest)!=null&&O.call(le,"[data-bonsaif-select-dropdown]"))||(ae=N.current)!=null&&ae.contains(le)||R(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(qa,{...l,columns:ce,data:i,getRowId:n})})}function st(e){if(e)return new Date(`${e}T12:00:00`)}function Dt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function Cr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ts(e){return e.map(r=>st(r)).filter(r=>!!r)}function xd(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Dt));return Array.from(r).sort()}function Ka(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function $s(e){const r=st(e);if(!r)return e;const n=Ka(r).replace(/\.$/u,"").replace(/^\w/u,o=>o.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const Ga={weekend:{dayOfWeek:[0,6]}},Za={weekend:"bonsaif-weekend"};function Qa({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),o=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${o?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const yd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},wd={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Nd({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,o=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${o?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?yd:null,...o?wd:null,...l?{fontWeight:800}:null,...n.style}})}function kd({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:st(e),to:st(r)},f=st(a),[g,p]=s.useState(()=>st(o||e)??new Date);s.useEffect(()=>{const C=st(o||e);C&&p(C)},[o,e]);const E=s.useMemo(()=>{if(l<=1)return Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const C=new Date(g.getFullYear(),g.getMonth()+l-1,1),H=g.getFullYear()===C.getFullYear(),k=new Intl.DateTimeFormat("es-MX",{month:"short",...H?{}:{year:"numeric"}}).format(g),x=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(C);return`${Cr(k)} – ${Cr(x)}`},[g,l]);function v(){p(new Date(g.getFullYear(),g.getMonth()-1,1))}function w(){p(new Date(g.getFullYear(),g.getMonth()+1,1))}const A=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:v,children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:w,children:t.jsx(j.HiChevronRight,{size:16})})]}),t.jsx(Ia.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:p,onSelect:C=>{const H=C!=null&&C.from?Dt(C.from):e,k=C!=null&&C.to?Dt(C.to):"";n({startDate:H,endDate:k})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ga,modifiersClassNames:Za,components:{DayButton:Nd,Weekday:Qa},classNames:{root:"bonsaif-range-daypicker w-full",months:A,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:C=>`${Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(C))} ${C.getFullYear()}`,formatWeekdayName:Ka}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function As({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:o,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),o==null||o(e.date,d))}})}function Ls(e,r){const n=st(e),a=st(r);if(!n||!a)return[];const o=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(o);for(;c<=l;)i.push(Dt(c)),c.setDate(c.getDate()+1);return i}function Ds(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,o=new Date(e);return o.setHours(12,0,0,0),o.setDate(o.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(o);return c.setDate(o.getDate()+i),c})}function an(e,r,n){const a=new Set(e);for(const o of r)n==="add"?a.add(o):n==="remove"||a.has(o)?a.delete(o):a.add(o);return Array.from(a).sort()}function Sd(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Ed(e,r,n){return!!(r&&e<r||n&&e>n)}function Os({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),m=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(k=>{let x=k;if(c){const M=b.current.filter(z=>!z.startsWith(c)),N=k.filter(z=>z.startsWith(c));x=[...M,...N].sort()}r==null||r(Sd(x,l))},[l,r,c]),g=s.useCallback((k,x=!1)=>Ed(k,a,o)?!0:!(!(i!=null&&i(k))||x&&b.current.includes(k)),[i,o,a]),p=s.useCallback(k=>k.filter(x=>!g(x)),[g]),E=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const k=()=>E();return window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k),()=>{window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)}},[E]);const v=s.useCallback((k,x,M,N)=>{const z=p(Ls(k,x));f(M==="add"?an(N,z,"add"):an(N,z,"remove"))},[f,p]),w=s.useCallback((k,x)=>{if(n||x.button!==0)return;const M=Dt(k);if(g(M,!0)||x.shiftKey)return;m.current=!0;const N=[...b.current],z=N.includes(M)?"remove":"add";z==="add"&&g(M)||(u.current={active:!0,mode:z,anchor:M,latest:M,baseline:N},d.current=M,v(M,M,z,N),x.preventDefault())},[v,n,g]),A=s.useCallback(k=>{const x=u.current;if(!(x!=null&&x.active)||n)return;const M=Dt(k);x.mode==="add"&&g(M)||x.latest!==M&&(x.latest=M,v(x.anchor,M,x.mode,x.baseline))},[v,n,g]),C=s.useCallback((k,x)=>{if(n)return;const M=Dt(k);if(!g(M,!0)){if(m.current&&!x.shiftKey){m.current=!1,x.preventDefault(),x.stopPropagation();return}if(m.current=!1,x.shiftKey&&d.current){x.preventDefault(),x.stopPropagation();const N=p(Ls(d.current,M));f(an(b.current,N,"add"));return}!b.current.includes(M)&&g(M)||(d.current=M,f(an(b.current,[M],"toggle")))}},[f,n,p,g]),H=s.useCallback(k=>{if(n)return;const x=p(xd(k));if(!x.length)return;const M=x.every(N=>b.current.includes(N));f(an(b.current,x,M?"remove":"add")),d.current=x[0]??d.current},[f,n,p]);return{onDayPointerDown:w,onDayPointerEnter:A,onDayClick:C,toggleWeek:H,endDrag:E}}function on(e){return Ds(e,1)[0]}function Hs(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Cd({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:g=!1}){const p=s.useMemo(()=>Ts(e),[e]),E=s.useMemo(()=>new Set(e),[e]),v=st(n),w=st(a),[A,C]=s.useState(()=>st(l||e[0])??new Date),[H,k]=s.useState(()=>on(st(l||e[0])??new Date)),[x,M]=s.useState(u),N=d??x;function z(L){d===void 0&&M(L),m==null||m(L)}s.useEffect(()=>{const L=st(l);L&&(C(L),k(on(L)))},[l]);const{onDayPointerDown:X,onDayPointerEnter:K,onDayClick:D,toggleWeek:G}=Os({value:e,onChange:r,disabled:g,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),V=s.useMemo(()=>{if(g)return!0;const L=[];return v&&L.push({before:v}),w&&L.push({after:w}),o&&L.push(B=>o(Dt(B))),L.length>0?L:void 0},[g,o,w,v]),ne=s.useCallback(L=>t.jsx(As,{...L,className:`bonsaif-multi-day-btn ${L.className??""}`,onDayPointerDown:X,onDayPointerEnter:K,onDayClickSelect:D}),[D,X,K]),J=s.useMemo(()=>Ds(H,1),[H]),R=J[6],U=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(R)}`:Cr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(A));function Y(){if(N==="week"){const L=Hs(H,-7);k(on(L)),C(L);return}C(new Date(A.getFullYear(),A.getMonth()-1,1))}function ce(){if(N==="week"){const L=Hs(H,7);k(on(L)),C(L);return}C(new Date(A.getFullYear(),A.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":N==="month",className:`bonsaif-cal-view-btn${N==="month"?" is-active":""}`,disabled:g,onClick:()=>{z("month"),C(H)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":N==="week",className:`bonsaif-cal-view-btn${N==="week"?" is-active":""}`,disabled:g,onClick:()=>{z("week"),k(on(A))},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:g,onClick:Y,children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:U}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana siguiente":"Mes siguiente",disabled:g,onClick:ce,children:t.jsx(j.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&N==="month"?" · Semana (nº)":"",N==="week"?" · Botón semana completa":""]}),N==="month"?t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:p,month:A,onMonthChange:C,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(L,B)=>{G(B)},disabled:V,className:"bonsaif-multi-daypicker",modifiers:Ga,modifiersClassNames:Za,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:ne,Weekday:Qa},formatters:{formatWeekdayName:Ka}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(L=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(L)},`h-${Dt(L)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(L=>{const B=Dt(L),le=E.has(B),O=g||(n?B<n:!1)||(a?B>a:!1)||!!(o!=null&&o(B)),ae=B===Dt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${le?" bonsaif-multi-day-selected":""}${ae?" bonsaif-multi-day-today":""}${O?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:O,"aria-pressed":le,onPointerDown:S=>X(L,S),onPointerEnter:()=>K(L),onClick:S=>D(L,S),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:L.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(L)})]})},B)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:g,onClick:()=>G(J),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(L=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:g,onClick:()=>r==null?void 0:r(e.filter(B=>B!==L)),title:`Quitar ${L}`,children:[$s(L),t.jsx("span",{"aria-hidden":!0,children:"×"})]},L))})]})}):null]})}const Md=Array.from({length:12},(e,r)=>r);function Td({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const b=s.useMemo(()=>Ts(e),[e]),f=st(o),g=st(l),p=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[E,v]=s.useState(p);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function w(N){v(N),a==null||a(N)}const{onDayPointerDown:A,onDayPointerEnter:C,onDayClick:H}=Os({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${E}-`}),k=s.useCallback(N=>t.jsx(As,{...N,className:`bonsaif-year-day-btn ${N.className??""}`,onDayPointerDown:A,onDayPointerEnter:C,onDayClickSelect:H}),[H,A,C]),x=b.filter(N=>N.getFullYear()===E),M=u?!0:[...f?[{before:f}]:[],...g?[{after:g}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>w(E-1),children:t.jsx(j.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>w(E+1),children:t.jsx(j.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:Md.map(N=>{const z=new Date(E,N,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Cr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(z))}),t.jsx(Ia.DayPicker,{mode:"multiple",required:!1,selected:x,month:z,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:M,className:"bonsaif-year-month-picker",modifiers:Ga,modifiersClassNames:Za,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:k,Weekday:Qa},formatters:{formatWeekdayName:X=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(X)}})]},`${E}-${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"," ·"," ",E]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(N=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(z=>z!==N)),title:`Quitar ${N}`,children:[$s(N),t.jsx("span",{"aria-hidden":!0,children:"×"})]},N))})]})}):null]})}const $d="bonsaif-ui:hide-tooltips";function Is(){window.dispatchEvent(new CustomEvent($d))}function Ad(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ld({trigger:e,items:r,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(!1),[f,g]=s.useState({}),p=s.useRef(null),E=s.useRef(null),v=s.useCallback(k=>{u(k),c==null||c(k)},[c]),w=s.useCallback(()=>{const k=p.current;if(!k)return;const x=k.getBoundingClientRect(),M=typeof a=="number"?a:x.width,N=typeof a=="number"?a:Math.max(x.width,180),z=n==="end"?Math.max(8,x.right-N):Math.min(x.left,window.innerWidth-N-8),X=window.innerHeight-x.bottom,K=X<240&&x.top>X?void 0:x.bottom+6,D=K===void 0?window.innerHeight-x.top+6:void 0;g({position:"fixed",zIndex:9999,left:z,top:K,bottom:D,width:Ad(typeof a=="number"?M:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;w();const k=M=>{var z,X;const N=M.target;!((z=p.current)!=null&&z.contains(N))&&!((X=E.current)!=null&&X.contains(N))&&v(!1)},x=M=>{M.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",k),window.addEventListener("keydown",x),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),()=>{document.removeEventListener("mousedown",k),window.removeEventListener("keydown",x),window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0)}},[d,v,w]);const A=k=>{o||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),v(!d))},C=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(Is(),v(!d))}}):e,H=d?t.jsx("div",{ref:E,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(k=>t.jsxs("div",{children:[k.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:k.disabled,onClick:()=>{var x;k.disabled||(Is(),(x=k.onSelect)==null||x.call(k),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:k.danger?"var(--danger)":"var(--text-main)"},children:[k.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:k.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:k.label}),k.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:k.description})]})]})]},k.id))}):null;return t.jsxs("span",{ref:p,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:A,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[C,m&&H?gt.createPortal(H,document.body):null]})}const Dd=180,Bs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Od({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:p="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:E="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:w,disabled:A=!1,disabledMessage:C,children:H}){const[k,x]=s.useState(!1),[M,N]=s.useState(!1),[z,X]=s.useState(!1),K=s.useCallback(()=>{N(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>X(!0))})},[]),D=s.useCallback(()=>{X(!1),window.setTimeout(()=>N(!1),Dd)},[]),G=A||c,V=s.useCallback(()=>{if(!G){if(f){K();return}r()}},[G,f,r,K]),ne=s.useCallback(()=>{X(!1),N(!1),w==null||w(),r()},[r,w]);if(s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(X(!1),N(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const R=U=>{if(U.key==="Escape"&&!G){if(M){D();return}V()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[D,G,M,e,V]),!k)return null;const J=C!==void 0?C:c?"Guardando…":null;return gt.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 ${Bs}`,onClick:V}),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(Qe,{variant:"icon",onClick:V,title:"Cerrar",disabled:G,children:t.jsx(j.HiXMark,{className:"w-5 h-5"})}),o&&t.jsx("div",{className:"flex-shrink-0",children:o}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{variant:"secondary",size:"sm",onClick:V,disabled:G,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Qe,{variant:"primary",size:"sm",icon:t.jsx(Zi.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||G,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:H}),G&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:J?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:J})]}):null})]}),M&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":g,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Bs} transition-opacity duration-200 ease-out ${z?"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 ${z?"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(Qe,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":v,children:t.jsx(j.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(j.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:p}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Qe,{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(Qe,{variant:"secondary",onClick:ne,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:E})]})]})]})]}),document.body)}const Hd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Id=/^\+?[0-9\s().-]+$/,Bd=7,Fd=15;function Pt(e){return e==null||String(e).trim()===""}function Fs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function Ja(e){return Pt(e)?!1:Hd.test(String(e))}function Ra(e){if(Pt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Id.test(r)&&n.length>=Bd&&n.length<=Fd}function Pd(e="Este campo es requerido."){return r=>Pt(r)?e:void 0}function _d(e="Ingresa un correo valido."){return r=>Pt(r)||Ja(r)?void 0:e}function zd(e="Ingresa un telefono valido."){return r=>Pt(r)||Ra(r)?void 0:e}function Wd(e,r){return n=>Pt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function jd(e,r){return n=>Pt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function qd(e,r){return n=>{if(Pt(n))return;const a=Fs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Ud(e,r){return n=>{if(Pt(n))return;const a=Fs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Vd(e,r="El formato no es valido."){return n=>Pt(n)||e.test(String(n))?void 0:r}function Xd(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 Ps={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},_s=s.createContext&&s.createContext(Ps),Yd=["attr","size","title"];function Kd(e,r){if(e==null)return{};var n,a,o=Gd(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 Gd(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function Fn(){return Fn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Fn.apply(null,arguments)}function zs(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function Pn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?zs(Object(n),!0).forEach(function(a){Zd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Zd(e,r,n){return(r=Qd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Qd(e){var r=Jd(e,"string");return typeof r=="symbol"?r:r+""}function Jd(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 Ws(e){return e&&e.map((r,n)=>s.createElement(r.tag,Pn({key:n},r.attr),Ws(r.child)))}function eo(e){return r=>s.createElement(Rd,Fn({attr:Pn({},e.attr)},r),Ws(e.child))}function Rd(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Kd(e,Yd),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Fn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Pn(Pn({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&s.createElement("title",null,l),e.children)};return _s!==void 0?s.createElement(_s.Consumer,null,n=>r(n)):r(Ps)}function js(e){return eo({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(e)}function eu(e){return eo({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(e)}function tu(e){return eo({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(e)}function Mr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Bt,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(j.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Tr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function _n({className:e="",...r}){return t.jsx("input",{...r,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function to({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:o,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:b="",required:f,...g}){const[p,E]=s.useState(()=>!!g.autoFocus),[v,w]=s.useState(!1),A=g.type==="password"&&u,C=A&&v?"text":g.type,H=!!o,k=H&&l!=="tooltip",x=H&&l!=="inline",M=!!n&&a==="tooltip"&&!k,N=m?f:void 0,z=H?"border-[var(--danger)] focus:border-[var(--danger)]":"",X=x?A?"pr-20":"pr-10":A?"pr-10":"",K=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,D=p||K,G={top:D?7:12,color:p?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},V=Y=>{var ce;E(!0),(ce=g.onFocus)==null||ce.call(g,Y)},ne=Y=>{var ce;E(!1),(ce=g.onBlur)==null||ce.call(g,Y)},J=A?t.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>w(Y=>!Y),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(eu,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(tu,{className:"h-[18px] w-[18px]"})})]}):null,R=x?t.jsx(Bt,{as:"span",content:o,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${A?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(js,{className:"h-[18px] w-[18px]"})})}):null,U=t.jsx(Tr,{error:k?o:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,type:C,required:N,placeholder:" ","aria-invalid":H||g["aria-invalid"],"data-has-value":K?"true":void 0,className:`h-11 w-full pt-5 ${X} ${z} ${b}`,onFocus:V,onBlur:ne}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:G,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:D?7:12},children:c}),R,J]}),U]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),M?t.jsx(Mr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),A?t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,type:C,required:N,"aria-invalid":H||g["aria-invalid"],className:`w-full ${X} ${z} ${b}`,onFocus:V,onBlur:ne}),R,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(_n,{...g,required:N,"aria-invalid":H||g["aria-invalid"],className:`w-full ${X} ${z} ${b}`}),R]}),U]})}function qs(e){return e==null?"":String(e)}function ru({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=s.useState(()=>qs(c)),f=i!==void 0?qs(i):m,g=n&&f.length>0&&!Ja(f)?a:void 0,p=E=>{i===void 0&&b(E.currentTarget.value),d==null||d(E)};return t.jsx(to,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:o,onChange:p})}const nu={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function au(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function Us(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 ou(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function su({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:b=!1,showFileList:f=!0,clearable:g=!0,browseLabel:p="Buscar archivos",dropLabel:E="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:w="o haz click para buscarlos en tu equipo",selectedLabel:A="Archivos seleccionados",size:C="md",containerClassName:H="",dropzoneClassName:k="",fileListClassName:x="",className:M="",id:N,accept:z,disabled:X,required:K,...D}){const G=s.useId(),V=N??G,ne=s.useRef(null),[J,R]=s.useState(!1),[U,Y]=s.useState(i),ce=l??U,L=!!a,B=!!r&&n==="tooltip"&&!L,le=g&&ce.length>0&&!X,O=(T,te)=>{l===void 0&&Y(T),c==null||c(T,te)},ae=(T,te)=>{const fe=T.filter(De=>Us(De,z)),se=T.filter(De=>!Us(De,z)),he=b?[...ce,...fe]:fe,Ae=ou(he,u,m);se.length>0&&(d==null||d(se)),O(Ae,te)},S=()=>{var T;X||(T=ne.current)==null||T.click()},ee=T=>{ae(Array.from(T.target.files??[]),T),T.target.value=""},_=T=>{T.preventDefault(),X||R(!0)},I=T=>{T.currentTarget.contains(T.relatedTarget)||R(!1)},de=T=>{T.preventDefault(),R(!1),!X&&ae(Array.from(T.dataTransfer.files),T)},re=T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),S())},F=T=>{O(ce.filter((te,fe)=>fe!==T))},y=()=>{O([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${H}`,children:[(e||o||B)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),K&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),B?t.jsx(Mr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:ne,id:V,type:"file",accept:z,multiple:u,disabled:X,required:K&&ce.length===0,"aria-invalid":L||D["aria-invalid"],className:"sr-only",onChange:ee}),t.jsxs("div",{role:"button",tabIndex:X?-1:0,"aria-controls":V,"aria-disabled":X||void 0,"aria-invalid":L||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${nu[C]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":L?"border-[var(--danger)]":"border-[var(--border)]"} ${X?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${k} ${M}`,onClick:S,onDragOver:_,onDragLeave:I,onDrop:de,onKeyDown:re,children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(j.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:J?E:v}),w&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:w})]}),p&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:p})]}),f&&ce.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${x}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:A}),le&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:y,children:t.jsx(j.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ce.map((T,te)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(j.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:T.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:au(T.size)})]}),!X&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${T.name}`,onClick:()=>F(te),children:t.jsx(j.HiXMark,{className:"h-4 w-4"})})]},`${T.name}-${T.lastModified}-${te}`))})]}),t.jsx(Tr,{error:a,helperText:r,helperDisplay:n})]})}const lu=[{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 iu({fields:e,title:r="Layout",fieldTypes:n=lu,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=s.useState(()=>e.map(C=>({key:!1,type:"",...C}))),[f,g]=s.useState(""),[p,E]=s.useState(""),v=s.useCallback((C,H)=>{b(k=>{const x=k.map((M,N)=>N===C?{...M,...H}:M);return u==null||u(x),x})},[u]),w=s.useCallback(()=>{d==null||d(m)},[m,d]),A=s.useCallback(()=>{var x;const C=f.trim();if(!C){E("Ingresa un nombre de campo.");return}if(m.some(M=>M.name.toLowerCase()===C.toLowerCase())){E("Ese campo ya existe en el arreglo.");return}const k={name:C,key:!1,type:((x=n[0])==null?void 0:x.value)??""};b(M=>{const N=[...M,k];return u==null||u(N),N}),g(""),E("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((C,H)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:C.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Mn,{size:"sm",checked:C.key??!1,onChange:k=>v(H,{key:k.target.checked}),"aria-label":`${C.name} es clave`})}),t.jsx(dr,{value:C.type??"",onChange:k=>v(H,{type:k}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${C.name}`})]},C.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:f,onChange:C=>{g(C.currentTarget.value),p&&E("")},onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),A())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Qe,{variant:"secondary",onClick:A,height:36,padding:"0 12px",children:i})]}),p&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:p})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Qe,{variant:"primary",onClick:w,disabled:c,loading:c,children:a})})]})})]})}function zn({label:e,children:r,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!o;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(Mr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Tr,{error:o,helperText:n,helperDisplay:a})]})}function cu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Vs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=cu(a),l=o.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(o.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const Ot=260,$r=420,ro=380,_t="cubic-bezier(0.22, 1, 0.36, 1)",du="cubic-bezier(0.16, 1, 0.3, 1)",no="cubic-bezier(0.22, 1, 0.36, 1)",uu="cubic-bezier(0.22, 1, 0.36, 1)",fu=8,bu=1,mu=1.25,ao={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},hu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",oo=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function pu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Xs(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),o=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:o,scale:Number.isFinite(n)?n:1}}function Ar({label:e,onClick:r,children:n,disabled:a,size:o="md"}){const l=o==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...ao,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=hu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(ao.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function Ys({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=fu,minZoom:c=bu,zoomStep:d=mu,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:p=!0,zIndex:E=1100,ariaLabel:v="Visor de imagen"}){const[w,A]=s.useState(!1),[C,H]=s.useState(!1),[k,x]=s.useState(a??0),[M,N]=s.useState(1),[z,X]=s.useState({x:0,y:0}),[K,D]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[G,V]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ne,J]=s.useState(!1),R=s.useRef(null),U=s.useRef(null),Y=s.useRef(null),ce=s.useRef(null),L=s.useRef(null),B=s.useRef(!1),le=s.useRef(!1),O=s.useRef(null),ae=s.useRef(null),S=s.useRef(null),ee=s.useRef(null),_=s.useRef(null),I=s.useRef(a??0),de=a??k,re=n.length===0?0:sn(de,0,Math.max(0,n.length-1)),F=n[re],y=n.length>1,T=Math.max(c,i),te=p&&y,fe=s.useCallback(me=>{if(n.length===0)return;const ge=n.length-1,Oe=g?(me%n.length+n.length)%n.length:sn(me,0,ge);a===void 0&&x(Oe),o==null||o(Oe)},[a,g,o,n.length]),se=s.useCallback(()=>{N(1),X({x:0,y:0})},[]),he=s.useCallback((me,ge)=>{if(ge<=c+.001)return{x:0,y:0};const Oe=ee.current,We=_.current;if(!Oe||!We)return me;const Be=Oe.getBoundingClientRect(),mt=We.offsetWidth*ge,ut=We.offsetHeight*ge,qe=Math.max(0,(mt-Be.width)/2+Be.width*.15),Ve=Math.max(0,(ut-Be.height)/2+Be.height*.15);return{x:sn(me.x,-qe,qe),y:sn(me.y,-Ve,Ve)}},[c]),Ae=s.useCallback(()=>{A(!1),V({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ce.current=null,L.current=null,B.current=!1,le.current=!1,O.current&&(clearTimeout(O.current),O.current=null)},[]),De=s.useCallback(()=>{if(B.current)return;B.current=!0,H(!1),se();const me=ce.current,ge=me!=null&&L.current!=null&&L.current===re;if(me&&ge){Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{const Oe=_.current;if(!Oe){Y.current=null,R.current&&clearTimeout(R.current),R.current=setTimeout(Ae,Ot+40);return}const We=Oe.getBoundingClientRect(),Be=Xs(me,We);V({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),Y.current=requestAnimationFrame(()=>{V({enabled:!0,dx:Be.dx,dy:Be.dy,scale:Be.scale,animate:!0}),Y.current=null})})}),R.current&&clearTimeout(R.current),R.current=setTimeout(Ae,$r+80);return}V({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),R.current&&clearTimeout(R.current),R.current=setTimeout(Ae,Ot+40)},[Ae,se,re]);s.useEffect(()=>(e?(R.current&&clearTimeout(R.current),O.current&&(clearTimeout(O.current),O.current=null),B.current=!1,le.current=!1,ce.current=pu(l),L.current=ce.current!=null?a??k:null,A(!0),H(!1),ce.current?V({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(L.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{H(!0),V({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):w&&De(),()=>{R.current&&clearTimeout(R.current),Y.current!=null&&cancelAnimationFrame(Y.current)}),[e]);const ue=s.useCallback(()=>{if(!e||B.current||le.current)return;const me=ce.current,ge=_.current;if(!me||!ge){me||(H(!0),le.current=!0);return}const Oe=ge.getBoundingClientRect();if(Oe.width<2||Oe.height<2)return;le.current=!0;const We=Xs(me,Oe);V({enabled:!0,dx:We.dx,dy:We.dy,scale:We.scale,animate:!1}),Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{V({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),H(!0),Y.current=null,O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{V({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),O.current=null},$r+20)})})},[e]);s.useLayoutEffect(()=>{!w||!e||!ce.current||le.current||ue()},[w,e,ue]),s.useEffect(()=>{!e||B.current||L.current!=null&&L.current!==re&&V(me=>me.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:me)},[e,re]),s.useEffect(()=>{if(!e)return;const me=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=me}},[e]),s.useEffect(()=>{e&&se()},[e,re,se]),s.useEffect(()=>{a!==void 0&&x(a)},[a]),s.useEffect(()=>{if(!e){I.current=re,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const me=I.current;if(me===re)return;I.current=re;const ge=n.length;let Oe=1;if(ge>1){const We=(me+1)%ge===re,Be=(me-1+ge)%ge===re;Be&&!We?Oe=-1:We&&!Be?Oe=1:Oe=re>me?1:-1}return U.current!=null&&(cancelAnimationFrame(U.current),U.current=null),D({opacity:0,x:Oe*56,scale:.94,blur:8,animate:!1}),U.current=requestAnimationFrame(()=>{U.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),U.current=null})}),()=>{U.current!=null&&(cancelAnimationFrame(U.current),U.current=null)}},[e,re,n.length]);const Te=M<=c+.001&&Math.abs(z.x)<.5&&Math.abs(z.y)<.5,He=s.useCallback((me,ge,Oe)=>{N(We=>{const Be=sn(me,c,T);if(Math.abs(Be-We)<1e-4)return We;const mt=Be/We,ut=Be<We;return Be<=c+.001?(X({x:0,y:0}),c):(X(qe=>{let Ve=qe;if(typeof ge=="number"&&typeof Oe=="number"&&ee.current&&!ut){const ft=ee.current.getBoundingClientRect(),ht=ge-ft.left-ft.width/2,br=Oe-ft.top-ft.height/2;Ve={x:ht-(ht-qe.x)*mt,y:br-(br-qe.y)*mt}}else if(ut){Ve={x:qe.x*mt,y:qe.y*mt};const ft=Math.min(1,(We-Be)/Math.max(.01,We-c));Ve={x:Ve.x*(1-ft*.65),y:Ve.y*(1-ft*.65)}}else Ve={x:qe.x*mt,y:qe.y*mt};return he(Ve,Be)}),Be)})},[he,c,T]),Xe=s.useCallback(()=>{He(M*d)},[He,M,d]),je=s.useCallback(()=>{const me=Math.max(c,M/d);if(me<=c+.001){se();return}N(me),X({x:0,y:0})},[c,se,M,d]);s.useEffect(()=>{if(!e)return;const me=ge=>{if(ge.key==="Escape"&&m){ge.preventDefault(),r();return}ge.key==="ArrowLeft"&&y?(ge.preventDefault(),fe(re-1)):ge.key==="ArrowRight"&&y?(ge.preventDefault(),fe(re+1)):ge.key==="+"||ge.key==="="?(ge.preventDefault(),He(M*d)):ge.key==="-"||ge.key==="_"?(ge.preventDefault(),je()):ge.key==="0"&&(ge.preventDefault(),se())};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[He,m,y,r,e,se,re,M,fe,je,d]);const Ye=me=>{me.preventDefault();const ge=me.deltaY>0?1/d:d;He(M*ge,me.clientX,me.clientY)},ie=me=>{M<=c+.001||(me.currentTarget.setPointerCapture(me.pointerId),J(!0),ae.current={pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,originX:z.x,originY:z.y})},Se=me=>{const ge=ae.current;!ge||ge.pointerId!==me.pointerId||X(he({x:ge.originX+(me.clientX-ge.startX),y:ge.originY+(me.clientY-ge.startY)},M))},_e=me=>{var ge;((ge=ae.current)==null?void 0:ge.pointerId)===me.pointerId&&(ae.current=null,J(!1))},ot=me=>{if(me.stopPropagation(),M>c+.05){se();return}He(Math.min(T,3),me.clientX,me.clientY)},Ke=me=>{if(me.touches.length!==2)return;J(!0);const[ge,Oe]=[me.touches[0],me.touches[1]],We=Math.hypot(ge.clientX-Oe.clientX,ge.clientY-Oe.clientY);S.current={distance:We,scale:M}},lt=me=>{if(me.touches.length!==2||!S.current)return;me.preventDefault();const[ge,Oe]=[me.touches[0],me.touches[1]],We=Math.hypot(ge.clientX-Oe.clientX,ge.clientY-Oe.clientY),Be=(ge.clientX+Oe.clientX)/2,mt=(ge.clientY+Oe.clientY)/2,ut=S.current.scale*(We/Math.max(1,S.current.distance));He(ut,Be,mt)},ct=()=>{S.current=null,J(!1)};if(!w||!F)return null;const dt=G.enabled,Yt=G.animate?`transform ${$r}ms ${uu}`:"none";return gt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:E},role:"dialog","aria-modal":"true","aria-label":v,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:C?1:0,transition:`opacity ${dt?$r:Ot}ms ${_t}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:ee,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:te?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:dt||C?1:0,transform:dt||C?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:dt?"none":`opacity ${Ot}ms ${_t}, transform ${Ot}ms ${_t}`},onClick:me=>{me.target===me.currentTarget&&u&&r()},onWheel:Ye,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:G.enabled?`translate3d(${G.dx}px, ${G.dy}px, 0) scale(${G.scale})`:void 0,transformOrigin:"center center",transition:G.enabled?Yt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:K.opacity,filter:K.blur?`blur(${K.blur}px)`:"blur(0px)",transform:`translate3d(${K.x}px, 0, 0) scale(${K.scale})`,transition:K.animate?[`opacity ${ro}ms ${no}`,`transform ${ro}ms ${no}`,`filter ${ro}ms ${no}`].join(", "):"none"},children:t.jsx("div",{ref:_,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:M>c+.001?"grab":"zoom-in",transform:`translate3d(${z.x}px, ${z.y}px, 0) scale(${M})`,transformOrigin:"center center",transition:ne?"none":`transform 220ms ${du}`},onClick:me=>me.stopPropagation(),onDoubleClick:ot,onPointerDown:ie,onPointerMove:Se,onPointerUp:_e,onPointerCancel:_e,onTouchStart:Ke,onTouchMove:lt,onTouchEnd:ct,children:t.jsx("img",{src:F.src,alt:F.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:oo,imageRendering:M>2.5?"pixelated":"auto"},onLoad:()=>{ue()}},F.src+String(re))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:C?1:0,transform:C?"translateY(0)":"translateY(-6px)",transition:`opacity ${dt?$r:Ot}ms ${_t}, transform ${dt?$r:Ot}ms ${_t}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:ao,children:[re+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(Ar,{label:"Alejar",onClick:je,disabled:M<=c+.001,children:t.jsx(j.HiMinus,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Restablecer tamaño",onClick:se,disabled:Te,children:t.jsx(j.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Ar,{label:"Acercar",onClick:Xe,disabled:M>=T-.001,children:t.jsx(j.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Ar,{label:"Cerrar",onClick:r,children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]})]}),y?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:C?1:0,transform:C?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ot}ms ${_t}, transform ${Ot}ms ${_t}`},children:t.jsx(Ar,{label:"Anterior",size:"lg",onClick:()=>fe(re-1),disabled:!g&&re<=0,children:t.jsx(j.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:C?1:0,transform:C?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ot}ms ${_t}, transform ${Ot}ms ${_t}`},children:t.jsx(Ar,{label:"Siguiente",size:"lg",onClick:()=>fe(re+1),disabled:!g&&re>=n.length-1,children:t.jsx(j.HiChevronRight,{className:"h-6 w-6"})})})]}):null,te?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((me,ge)=>{const Oe=ge===re;return t.jsx("button",{type:"button",role:"tab","aria-selected":Oe,"aria-label":me.alt||`Imagen ${ge+1}`,onClick:We=>{We.stopPropagation(),fe(ge)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:oo,opacity:Oe?1:.42,transition:`opacity 180ms ${_t}`},children:t.jsx("img",{src:me.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:oo}})},`${me.src}-${ge}`)})})}):null]})]}),document.body)}function gu({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(0),[f,g]=s.useState([]),[p,E]=s.useState(null),v=s.useCallback((A,C,H)=>{g(A),E(H??null),b(C),u(!0)},[]),w=s.useCallback(A=>{Vs(A,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:w,children:e}),t.jsx(Ys,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:p,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Ks(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Gs(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function so(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function vu(e,r){if(!r)return!0;const n=so(r);return so(e.label).includes(n)||!!(e.sublabel&&so(e.sublabel).includes(n))}function xu({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:g=!0,emptyText:p="Sin resultados",clearLabel:E="Limpiar seleccion",pruneMissingValues:v=!0}){const[w,A]=s.useState(!1),[C,H]=s.useState(""),[k,x]=s.useState(0),[M,N]=s.useState(!1),[z,X]=s.useState({}),K=s.useRef(null),D=s.useRef(null),G=s.useRef(null),V=s.useRef(null),ne=u&&n.length>=m,J=s.useMemo(()=>new Set(e),[e]),R=s.useMemo(()=>{const y=new Map;for(const T of n)y.set(T.value,T);return y},[n]),U=s.useMemo(()=>{const y=[];for(const T of e){const te=R.get(T);te&&y.push(te)}return y},[R,e]),Y=b==="all"?U.length:b,ce=U.slice(0,Y),L=Math.max(0,U.length-ce.length),B=g&&U.length>1,le=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[U.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:U.map(y=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[y.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:y.label}),y.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:y.sublabel}):null]},y.value))})]}),O=s.useMemo(()=>{const y=C.trim();return!ne||!y?n:n.filter(T=>vu(T,y))},[n,C,ne]),ae=s.useCallback(()=>{const y=K.current;if(!y)return;const T=y.getBoundingClientRect(),te=ne?304:244,fe=window.innerHeight-T.bottom,se=fe<te&&T.top>fe;X({position:"fixed",left:T.left,top:se?void 0:T.bottom+4,bottom:se?window.innerHeight-T.top+4:void 0,width:Math.max(T.width,240),zIndex:9999})},[ne]),S=s.useCallback(y=>{Gs(e,y)||r(y)},[r,e]),ee=s.useCallback(y=>{const T=R.get(y);if(T!=null&&T.disabled)return;const te=J.has(y)?e.filter(fe=>fe!==y):[...e,y];S(te)},[S,R,e,J]),_=s.useCallback(()=>S([]),[S]),I=s.useCallback(()=>{A(!1),H(""),x(0)},[]);s.useEffect(()=>N(!0),[]);const de=s.useMemo(()=>n.map(y=>y.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const y=new Set(n.map(te=>te.value)),T=e.filter(te=>y.has(te));Gs(e,T)||r(T)},[de]),s.useEffect(()=>{if(!w)return;function y(T){var fe,se;const te=T.target;!((fe=K.current)!=null&&fe.contains(te))&&!((se=D.current)!=null&&se.contains(te))&&I()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[I,w]),s.useEffect(()=>{w&&(x(0),ae(),ne&&setTimeout(()=>{var y;return(y=G.current)==null?void 0:y.focus()},0))},[w,ne,ae]),s.useEffect(()=>{if(w)return window.addEventListener("resize",ae),window.addEventListener("scroll",ae,!0),()=>{window.removeEventListener("resize",ae),window.removeEventListener("scroll",ae,!0)}},[w,ae]),s.useEffect(()=>{if(O.length===0){x(0);return}x(y=>Math.min(y,O.length-1))},[O.length]),s.useEffect(()=>{if(k<0||!V.current)return;const y=V.current.children[k];y==null||y.scrollIntoView({block:"nearest"})},[k]);function re(y){if(!o){if(!w){(y.key==="Enter"||y.key===" "||y.key==="ArrowDown")&&(y.preventDefault(),A(!0));return}if(y.key==="Escape"){y.preventDefault(),I();return}if(y.key==="ArrowDown"){if(y.preventDefault(),O.length===0)return;x(T=>Math.min(T+1,O.length-1));return}if(y.key==="ArrowUp"){y.preventDefault(),x(T=>Math.max(T-1,0));return}if(y.key==="Enter"&&O[k]&&!O[k].disabled){y.preventDefault(),ee(O[k].value);return}y.key==="Backspace"&&!C&&e.length&&(y.preventDefault(),S(e.slice(0,-1)))}}const F=t.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{...z,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(j.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:G,value:C,onChange:y=>{H(y.target.value),x(0)},onKeyDown:y=>{(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter"||y.key==="Escape")&&(y.stopPropagation(),re(y))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),C&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:y=>{y.preventDefault(),H(""),x(0)},children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[t.jsxs("span",{children:[U.length," seleccionados",e.length>U.length?` (${e.length-U.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),_()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:E})]}),t.jsxs("ul",{ref:V,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ne?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[O.map((y,T)=>{const te=T===k,fe=J.has(y.value);return t.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:se=>{se.preventDefault(),!y.disabled&&ee(y.value)},onMouseEnter:()=>!y.disabled&&x(T),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:te?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:y.disabled?"var(--text-muted)":"var(--text-main)",cursor:y.disabled?"not-allowed":"pointer",opacity:y.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:fe?"var(--primary)":"var(--border)",background:fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:fe&&t.jsx(j.HiCheck,{className:"h-3 w-3"})}),y.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Ut,{className:"min-w-0 flex-1",children:y.label}),y.sublabel&&t.jsx(Ut,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:y.sublabel})]}),y.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:y.badge})]},y.value)}),O.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:p})]})]});return t.jsxs("div",{ref:K,className:`relative ${l||"w-full"}`,style:i,onKeyDown:re,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(w?I():A(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Ks(c),padding:Ks(d),background:"var(--bg-input)",color:U.length?"var(--text-main)":"var(--text-muted)",border:w?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":w,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ce.length?(()=>{const y=t.jsxs(t.Fragment,{children:[ce.map(T=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[T.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:T.color}}),f?t.jsx(Ut,{className:"min-w-0 flex-1",children:T.label}):t.jsx("span",{className:"break-words",children:T.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${T.label}`,onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),ee(T.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"h-3 w-3"})})]},T.value)),L>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},"aria-label":`${L} seleccionados más`,children:["+",L]})]});return B?t.jsx(Bt,{as:"span",content:le,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:y}):y})():t.jsx("span",{className:"truncate",children:a})}),U.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":E,onMouseDown:y=>{y.preventDefault(),y.stopPropagation(),_()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(j.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:w?"rotate(180deg)":"rotate(0deg)"}})]}),w&&M&>.createPortal(F,document.body)]})}function yu({inputMode:e="decimal",...r}){return t.jsx(to,{...r,type:"number",inputMode:e})}function wu(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 Nu({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:o=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=wu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Qe,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(j.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(Qe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(j.HiChevronRight,{className:"h-4 w-4"})})]})}const Zs=[{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 Qs(e){return e==null?"":String(e)}function Wn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function ku(e){return typeof e=="number"?`${e}px`:e}function Su({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:g,countryCodePlaceholder:p="Codigo",countryCodeClassName:E="",countryCodeWidth:v=84,onPhoneValueChange:w,label:A,containerClassName:C="",helperText:H,helperDisplay:k="inline",labelAction:x,className:M="",required:N,disabled:z,floatingLabel:X,showPasswordToggle:K,nativeValidation:D,errorTooltipLabel:G="Error de validacion",...V}){var T;const[ne,J]=s.useState(()=>Qs(c)),[R,U]=s.useState(()=>Wn(m)),Y=s.useMemo(()=>{const te=g??Zs,fe=f==null?void 0:f.map(Wn);return fe!=null&&fe.length?te.filter(se=>fe.includes(se.value)):te},[f,g]),ce=((T=Y[0])==null?void 0:T.value)??"+1",L=Y.some(te=>te.value===Wn(u??R))?Wn(u??R):ce,B=i!==void 0?Qs(i):ne,le=`${L} ${B}`.trim(),O=n&&B.length>0&&!Ra(le)?a:void 0,ae=l??O,S=!!ae,ee=S&&o!=="tooltip",_=S&&o!=="inline",I=!!H&&k==="tooltip"&&!ee,de=S?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",re=te=>{const fe=te.currentTarget.value;i===void 0&&J(fe),w==null||w(fe,{countryCode:L,nationalNumber:fe,fullNumber:`${L} ${fe}`.trim()}),d==null||d(te)},F=te=>{u===void 0&&U(te),b==null||b(te),w==null||w(B,{countryCode:te,nationalNumber:B,fullNumber:`${te} ${B}`.trim()})},y=_?t.jsx(Bt,{as:"span",content:ae,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":G,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(js,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${C}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:A}),N&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),I?t.jsx(Mr,{content:H}):null,x&&t.jsx("span",{className:"ml-auto normal-case",children:x})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${de}`,children:[t.jsx(dr,{value:L,onChange:F,options:Y,placeholder:p,disabled:z,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${E}`,style:{width:ku(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",{...V,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:z,required:void 0,"aria-label":V["aria-label"]??(typeof A=="string"?A:void 0),"aria-invalid":S||V["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 ${_?"pr-10":""} ${M}`,onChange:re}),y]})]}),t.jsx(Tr,{error:ee?ae:void 0,helperText:H,helperDisplay:k})]})}function Eu({value:e,onChange:r,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[o&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:o}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Cu=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),jn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Lr=12,qn=8,lo=(e,r,n)=>{const a=Vn(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},Js=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Lr?null:lo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Lr)return null;const o=Array.from(a.rows).indexOf(n);return lo(a,o+1,e)},Mu=(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)},Rs=(e,r)=>Vn(e)>=qn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),Tu=(e,r)=>Vn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),el=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")})},tl=(e,r,n)=>{el(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")}))},$u=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},Un=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},rl=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")})},Au=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Js(r,n):io(r);return l&&Xn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Mu(r,n):!1;case"table-col-add":return Number.isFinite(a)?Rs(r,a):Hu(r);case"table-col-del":return Number.isFinite(a)?Tu(r,a):!1;default:return!1}},Vn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Lu=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},nl=e=>(e==null?void 0:e.closest("table"))??null,al=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},Du=e=>Array.from(e.querySelectorAll("th, td")),ol=(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]},Ou=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},Xn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},io=e=>{const r=Lu(e);if(r.length>=Lr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return lo(a,0,e)}return Js(e,Array.from(e.rows).indexOf(n))},Hu=e=>{const r=Vn(e)-1;return r<0?!1:Rs(e,r)},co=e=>{rl(e)},Iu=(e,r,n)=>{const a=jn(e,1,Lr),o=jn(r,1,qn),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},sl=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',ln=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ll=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),Bu=e=>e.replace(/[<>]/g,"").toLowerCase(),Fu=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),Pu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,_u=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},Yn=(e,r)=>r.test(e),zu=e=>Yn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),Wu=e=>Yn(e,/font-style\s*:\s*italic/i),ju=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),qu=e=>Yn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Kn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},Gn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Uu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},il=e=>{const r=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(r)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},Vu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Pu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Xu=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&&(zu(a)&&Kn(n,"strong"),Wu(a)&&Kn(n,"em"),ju(a)&&Kn(n,"u"),qu(a)&&Kn(n,"s"))})},Yu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Uu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=il(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(il(u)!==o)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(o);c.insertBefore(d,a),l.forEach(u=>{Vu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Ku=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Gu=e=>{const r=_u(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),o=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Xu(o),Yu(o);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){Gn(d),c.forEach(l);return}if(!Fu.has(u)){Gn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=Ku(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Cu.has(u)){Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase();if(u==="td"||u==="th"){["colspan","rowspan"].includes(f)||d.removeAttribute(b.name);return}d.removeAttribute(b.name)}),u==="table"&&d.classList.add("rich-table"),c.forEach(l);return}if(Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase(),g=b.value;if(f.startsWith("on")||f==="style"||f==="class"){d.removeAttribute(b.name);return}if(f==="lang"||f.startsWith("data-")||f.startsWith("mso-")){d.removeAttribute(b.name);return}if((f==="href"||f==="src")&&/^\s*javascript:/i.test(g)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&f!=="href"&&f!=="src"&&f!=="alt"&&(["href","src","alt","target","rel"].includes(f)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){Gn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){Gn(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),o.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),o.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},uo=e=>ln(e).replace(/\r\n?/g,`
|
|
25
|
-
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Zu=e=>new RegExp("\\p{L}","u").test(e),fo=(e,r)=>{const n=e.trim();return!n||!Zu(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===ll(n)},cl=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",sl())}(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 dl({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full"}){const i=s.useId(),c=o||i,d=s.useCallback(()=>document,[]),u=s.useRef(null),m=s.useRef(null),b=s.useRef(new Map),f=s.useRef(null),g=s.useRef(!1),p=s.useRef(e??""),E=s.useRef(r),v=s.useRef(()=>{}),w=s.useRef(!1),[A,C]=s.useState(()=>!e||e.trim()===""),[H,k]=s.useState(new Set),[x,M]=s.useState(null),[N,z]=s.useState(""),[X,K]=s.useState(""),[D,G]=s.useState(""),[V,ne]=s.useState(""),[J,R]=s.useState(3),[U,Y]=s.useState(3),[ce,L]=s.useState(!0),[B,le]=s.useState(!1),[O,ae]=s.useState(l==="full"),[S,ee]=s.useState(null),[_,I]=s.useState(null),de=s.useRef(null),re=s.useRef(!1),F=s.useRef(null),y=s.useCallback(()=>g.current?m.current:u.current,[]);s.useEffect(()=>{E.current=r},[r]);const T=s.useCallback(()=>{const W=window.getSelection(),Z=y();if(!W||!Z||W.rangeCount===0||W.isCollapsed)return"";const be=W.getRangeAt(0);return!Z.contains(be.startContainer)||!Z.contains(be.endContainer)?"":W.toString()},[y]);s.useEffect(()=>{const W=e??"";if(w.current&&W===p.current){w.current=!1,C(!W||W.trim()==="");return}w.current=!1,p.current=W;const Z=[u.current,m.current].filter(pe=>!!pe);Z.forEach(pe=>{pe.innerHTML!==W&&(pe.innerHTML=W)}),C(!W||W.trim()===""),Z.forEach(pe=>co(pe));const be=Z.map(pe=>cl(pe));return()=>be.forEach(pe=>pe())},[e]),s.useEffect(()=>{var pe,Ee;g.current=B;let W,Z=0,be;if(B){const xe=u.current;xe&&(p.current=Un(xe));const Fe=()=>{var Je;const Ie=m.current;if(!Ie){Z=requestAnimationFrame(Fe);return}Ie.innerHTML!==p.current&&(Ie.innerHTML=p.current),W=cl(Ie),co(Ie),C(((Je=Ie.textContent)==null?void 0:Je.trim())===""),be=setTimeout(()=>Ie.focus(),60)};Z=requestAnimationFrame(Fe)}else{const xe=m.current,Fe=u.current,Ie=xe?Un(xe):p.current,Je=p.current;p.current=Ie,Fe&&Fe.innerHTML!==Ie&&(Fe.innerHTML=Ie),Ie!==Je&&E.current(Ie),C(((Ee=(pe=xe??Fe)==null?void 0:pe.textContent)==null?void 0:Ee.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),be&&clearTimeout(be),W==null||W()}},[B]);const te=s.useCallback(()=>{const W=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;W.forEach(pe=>{try{d().queryCommandState(pe)&&Z.add(pe)}catch{return}});try{const pe=Bu(d().queryCommandValue("formatBlock"));pe&&Z.add(`formatBlock:${pe}`)}catch{}const be=T();fo(be,"uppercase")&&Z.add("__upper"),fo(be,"lowercase")&&Z.add("__lower"),fo(be,"capitalize")&&Z.add("__cap"),k(Z)},[T,d]),fe=()=>{var Z;const W=y();W&&(p.current=Un(W),w.current=!0,E.current(p.current),C(((Z=W.textContent)==null?void 0:Z.trim())===""))};v.current=fe;const se=s.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null),de.current&&(el(de.current),de.current=null),re.current=!1,ee(null),I(null)},[]),he=s.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null)},[]),Ae=s.useCallback(()=>{he(),F.current=setTimeout(()=>{re.current||se()},280)},[he,se]);s.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]);const De=s.useCallback(W=>{const Z=de.current;if(!Z||!Z.isConnected){se();return}const be=(S==null?void 0:S.rowIndex)??(_==null?void 0:_.rowIndex)??-1,pe=(S==null?void 0:S.colIndex)??(_==null?void 0:_.colIndex)??-1;Au(W,Z,be,pe,y()),se(),v.current(),te()},[y,se,te,_,S]),ue=s.useCallback(W=>{if(_)return;const Z=W.currentTarget,be=W.target;if(be.closest(".rich-table-action-bar, .rich-table-context-menu")){he();return}const pe=be.closest("td, th");if(!pe||!Z.contains(pe)){Ae();return}const Ee=pe.closest("tr"),xe=pe.closest("table");if(!Ee||!xe||!Z.contains(xe)){Ae();return}he(),xe.classList.add("rich-table"),de.current=xe,tl(xe,Ee,pe.cellIndex),ee($u(xe,Ee,pe))},[he,Ae,_]),Te=s.useCallback(W=>{const Z=W.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){he();return}Ae()},[he,Ae]),He=s.useCallback(W=>{const Z=W.currentTarget,pe=W.target.closest("td, th");if(!pe||!Z.contains(pe))return;const Ee=pe.closest("tr"),xe=pe.closest("table");if(!Ee||!xe||!Z.contains(xe))return;W.preventDefault(),xe.classList.add("rich-table"),de.current=xe;const Fe=Array.from(xe.rows).indexOf(Ee),Ie=pe.cellIndex;tl(xe,Ee,Ie),ee(null),I({x:W.clientX,y:W.clientY,rowIndex:Fe,colIndex:Ie})},[]);s.useEffect(()=>{if(!S&&!_)return;const W=()=>Ae();return window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[Ae,_,S]),s.useEffect(()=>{if(!_)return;const W=Z=>{const be=Z.target;be instanceof Element&&be.closest(".rich-table-context-menu")||I(null)};return window.addEventListener("mousedown",W),()=>window.removeEventListener("mousedown",W)},[_]);const Xe=W=>{if(!W){const Z=u.current;Z&&(p.current=Un(Z))}le(!W)},je=(W,Z)=>{var be;(be=y())==null||be.focus(),d().execCommand(W,!1,Z),fe(),te()},Ye=W=>{je("formatBlock",W)},ie=()=>{var W;(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),fe(),te()},Se=()=>{const W=window.getSelection();W&&W.rangeCount>0&&(f.current=W.getRangeAt(0).cloneRange())},_e=()=>{const W=window.getSelection();W&&f.current&&(W.removeAllRanges(),W.addRange(f.current))},ot=W=>{if(Se(),W==="link"){const Z=window.getSelection();K(Z&&!Z.isCollapsed?Z.toString():""),z("")}W==="image"&&(G(""),ne("")),W==="table"&&(R(3),Y(3),L(!0)),M(W)},Ke=()=>{var pe;if(!N.trim())return;_e(),(pe=y())==null||pe.focus();const W=window.getSelection(),be=(W&&!W.isCollapsed?W.toString():"")||X.trim()||N.trim();d().execCommand("insertHTML",!1,`<a href="${ln(N.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${ln(be)}</a>`),fe(),M(null)},lt=(W,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${ln(W)}" alt="${ln(Z)}" class="rich-img" />${sl()}</span>`,ct=()=>{var W;D.trim()&&(_e(),(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,lt(D.trim(),V.trim())),fe(),M(null))},dt=()=>{var W;_e(),(W=y())==null||W.focus(),d().execCommand("insertHTML",!1,Iu(J,U,ce)),fe(),M(null)},Yt=(W,Z=1200,be=1200,pe=.72)=>new Promise((Ee,xe)=>{const Fe=new FileReader;Fe.onerror=xe,Fe.onload=Ie=>{var or;const Je=(or=Ie.target)==null?void 0:or.result,Re=new Image;Re.onerror=xe,Re.onload=()=>{let{width:xt,height:Kt}=Re;if(xt>Z||Kt>be){const Gt=Math.min(Z/xt,be/Kt);xt=Math.round(xt*Gt),Kt=Math.round(Kt*Gt)}const Ht=document.createElement("canvas");Ht.width=xt,Ht.height=Kt;const sr=Ht.getContext("2d");if(!sr){Ee(Je);return}sr.drawImage(Re,0,0,xt,Kt),Ee(Ht.toDataURL("image/jpeg",pe))},Re.src=Je},Fe.readAsDataURL(W)}),me=W=>{W.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!W.contains(Z.anchorNode)){const be=document.createRange();be.selectNodeContents(W),be.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(be)}},ge=s.useRef(()=>{});ge.current=W=>{const Z=y();Z&&(me(Z),d().execCommand("insertHTML",!1,W),co(Z),Z.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr, table")&&be.remove()}),fe(),te())};const Oe=s.useRef(Yt);Oe.current=Yt;const We=s.useRef(lt);We.current=lt;const Be=s.useCallback(W=>{if(!W||b.current.has(W))return;const Z=be=>{const pe=be.clipboardData;if(!pe)return;const Ee=pe.getData("text/html"),xe=pe.getData("text/plain");if(Ee||xe){be.preventDefault(),be.stopPropagation();try{const Re=Ee?Gu(Ee):uo(xe);if(!Re){xe&&ge.current(uo(xe));return}ge.current(Re)}catch{xe&&ge.current(uo(xe))}return}const Ie=Array.from(pe.items).find(Re=>Re.type.startsWith("image/"));if(!Ie)return;be.preventDefault(),be.stopPropagation();const Je=Ie.getAsFile();Je&&Oe.current(Je).then(Re=>{ge.current(We.current(Re,"imagen"))})};W.addEventListener("paste",Z,!0),b.current.set(W,()=>{W.removeEventListener("paste",Z,!0),b.current.delete(W)})},[]),mt=s.useCallback(W=>{var be;const Z=u.current;Z&&Z!==W&&((be=b.current.get(Z))==null||be()),u.current=W,W&&Be(W)},[Be]),ut=s.useCallback(W=>{var be;const Z=m.current;Z&&Z!==W&&((be=b.current.get(Z))==null||be()),m.current=W,W&&Be(W)},[Be]);s.useEffect(()=>{const W=b.current;return()=>{W.forEach(Z=>Z()),W.clear()}},[]);const qe=W=>{const Z=window.getSelection(),be=y();if(!Z||!be||Z.rangeCount===0||Z.isCollapsed)return;const pe=Z.getRangeAt(0);if(!be.contains(pe.startContainer)||!be.contains(pe.endContainer))return;const Ee=pe.toString();if(!Ee)return;let xe=Ee;W==="uppercase"?xe=Ee.toLocaleUpperCase():W==="lowercase"?xe=Ee.toLocaleLowerCase():xe=ll(Ee),pe.deleteContents();const Fe=document.createTextNode(xe);pe.insertNode(Fe);const Ie=document.createRange();Ie.setStart(Fe,0),Ie.setEnd(Fe,xe.length),Z.removeAllRanges(),Z.addRange(Ie),f.current=Ie.cloneRange(),fe(),te()},Ve=()=>{Se(),te()},ft=()=>{const W=y();W&&rl(W),fe(),te()},ht=()=>{requestAnimationFrame(()=>{var W;(W=y())==null||W.focus()})},br=W=>{var Z,be;if((W.metaKey||W.ctrlKey)&&W.key==="Enter"){if(W.preventDefault(),W.stopPropagation(),W.repeat)return;(Z=y())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),fe(),te();return}if(W.key==="Tab"){const pe=window.getSelection(),Ee=al((pe==null?void 0:pe.anchorNode)??null),xe=y(),Fe=nl(Ee);if(Ee&&Fe&&(xe!=null&&xe.contains(Ee))){W.preventDefault();const Ie=Du(Fe),Je=Ie.indexOf(Ee),Re=Je>=0?Ie[Je+1]:null;if(Re)Xn(Re,xe,!0);else if(ol(Ee,Fe)){const or=io(Fe);or&&Xn(or,xe,!0)}fe(),te();return}W.preventDefault(),(be=y())==null||be.focus(),d().execCommand("insertText",!1," "),fe(),te();return}if(W.key==="Enter"&&!W.shiftKey&&!(W.metaKey||W.ctrlKey)){const pe=window.getSelection(),Ee=al((pe==null?void 0:pe.anchorNode)??null),xe=y(),Fe=nl(Ee);if(Ee&&Fe&&(xe!=null&&xe.contains(Ee))&&ol(Ee,Fe)&&Ou(Ee)){W.preventDefault();const Ie=io(Fe);Ie&&Xn(Ie,xe,!0),fe(),te();return}}if(W.key==="Escape"){if(_){I(null);return}if(x){M(null);return}if(g.current){le(!1);return}}x||(W.ctrlKey||W.metaKey)&&(W.key==="b"&&(W.preventDefault(),je("bold")),W.key==="i"&&(W.preventDefault(),je("italic")),W.key==="u"&&(W.preventDefault(),je("underline")),W.key==="k"&&(W.preventDefault(),ot("link")))},bt=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ze=(W,Z,be,pe,Ee)=>{const xe=Ee??(H.has(be)||be==="__link"&&x==="link"||be==="__img"&&x==="image"||be==="__table"&&x==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:ht,onMouseDown:Fe=>{Fe.preventDefault(),pe?pe():je(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:xe?"var(--primary)":"var(--text-secondary)",background:xe?"rgba(59,130,246,0.12)":"transparent"},children:W},be)},vn=W=>{const Z=W.target;if(Z.closest("[data-action='delete-img']")){W.preventDefault();const be=Z.closest(".rich-img-wrap");be&&(be.remove(),fe())}},fa=()=>{he(),re.current=!0},pt=()=>{re.current=!1,Ae()},Mt=(W,Z,be,pe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${pe?" rich-table-action-btn--danger":""}`,title:W,"aria-label":W,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),De(be)},children:Z}),Tt=()=>typeof document>"u"||!S&&!_?null:gt.createPortal(t.jsxs(t.Fragment,{children:[S&&!_&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:S.bar.x,top:S.bar.y},onMouseEnter:fa,onMouseLeave:pt,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"}),Mt("Añadir fila abajo","+","table-row-add"),Mt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Mt("Añadir columna a la derecha","+","table-col-add"),Mt("Eliminar columna","−","table-col-del")]}),Mt("Eliminar tabla","Eliminar","table-delete",!0)]}),_&&t.jsx("div",{className:"rich-table-context-menu",style:{left:_.x,top:_.y},onMouseDown:W=>W.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([W,Z])=>t.jsx("button",{type:"button",onMouseDown:be=>{be.preventDefault(),De(Z)},children:W},Z))})]}),document.body),ar=W=>t.jsxs(t.Fragment,{children:[x==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:N,onChange:Z=>z(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Ke()),Z.key==="Escape"&&M(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:X,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),Ke()),Z.key==="Escape"&&M(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Ke,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Lr,value:J,onChange:Z=>R(jn(Number(Z.target.value),1,Lr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),dt()),Z.key==="Escape"&&M(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:qn,value:U,onChange:Z=>Y(jn(Number(Z.target.value),1,qn)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),dt()),Z.key==="Escape"&&M(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:ce,onChange:Z=>L(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:dt,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:W},children:[t.jsx("input",{autoFocus:!0,type:"url",value:D,onChange:Z=>G(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ct()),Z.key==="Escape"&&M(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:V,onChange:Z=>ne(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ct()),Z.key==="Escape"&&M(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick: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:()=>M(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Wr=(W,Z)=>{const be=l==="compact",pe=!be||O||W;return t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:Z},"data-toolbar-variant":l,children:[be&&!W&&t.jsxs("button",{type:"button",title:O?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:ht,onMouseDown:Ee=>{Ee.preventDefault(),ae(xe=>!xe)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:O?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[O?t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"}),O?"Ocultar herramientas":"Herramientas"]}),pe&&t.jsxs(t.Fragment,{children:[ze(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ze(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ze(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ze(t.jsx(j.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ze(t.jsx(j.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ze(t.jsx(j.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ot("link")),bt(),ze(t.jsx(j.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ze(t.jsx(j.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),bt(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Ye("p"),H.has("formatBlock:p")||H.has("formatBlock:div")),ze(t.jsx(j.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Ye("h2"),H.has("formatBlock:h2")),ze(t.jsx(j.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Ye("h3"),H.has("formatBlock:h3")),ze(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Ye("blockquote"),H.has("formatBlock:blockquote")),bt(),ze(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),bt(),ze(t.jsx(j.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ze(t.jsx(j.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),bt(),ze(t.jsx(j.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ze(t.jsx(j.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ze(t.jsx(j.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ze(t.jsx(j.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),bt(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>qe("uppercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>qe("lowercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>qe("capitalize")),bt(),ze(t.jsx(j.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ze(t.jsx(j.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ot("image")),ze(t.jsx(j.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>ot("table")),ze(t.jsx(j.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",ie),bt(),ze(t.jsx(j.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ze(t.jsx(j.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Ye("p"))]}),bt(),t.jsx("button",{type:"button",title:W?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:ht,onMouseDown:Ee=>{Ee.preventDefault(),Xe(W)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:W?t.jsx(j.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(j.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Tt(),t.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{ref:mt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:ft,onKeyDown:br,onKeyUp:Ve,onSelect:Ve,onMouseUp:Ve,onMouseMove:ue,onMouseLeave:Te,onContextMenu:He,onMouseDown:vn,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ar("var(--bg-input)"),Wr(!1,"var(--bg-input)")]}),t.jsxs(Xa,{open:B,onClose:()=>le(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[t.jsx("div",{ref:ut,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:ft,onKeyDown:br,onKeyUp:Ve,onSelect:Ve,onMouseUp:Ve,onMouseMove:ue,onMouseLeave:Te,onContextMenu:He,onMouseDown:vn,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${A?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),ar("var(--bg-input)"),Wr(!0,"var(--bg-input)")]})]})}const ul="[a-zA-Z0-9._@-]+",bo=new RegExp(`@(${ul})`,"g"),Qu=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
|
|
26
|
-
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function
|
|
23
|
+
</body></html>`,Ce=window.open("","_blank");Ce&&(Ce.document.write(ve),Ce.document.close())}const Da=()=>!nt||!yn?null:pt.createPortal(t.jsxs("div",{ref:Po,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...lm,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(ce?await ce():Pm(),pa(!1)))()},children:[t.jsx(W.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),t.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{(async()=>(Se?await Se():_m(),pa(!1)))()},children:[t.jsx(W.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Oa=()=>{const h=$&&ye.trim().length>0,D=he!=null&&he.length?he:h?[{key:"bql",label:"BQL",value:ye}]:[],Q=ie.filter(_=>{const se=_.trim();return se?!new Set(Pe.split(`
|
|
24
|
+
`).map(Ce=>Ce.trim()).filter(Boolean)).has(se):!1}).slice(0,8);return!de&&zo===0&&!$&&!nt?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[zo>0&&t.jsxs("button",{type:"button",onClick:xm,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"}),zo," filtros"]}),$&&t.jsxs("div",{ref:Bo,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ze){Qe(!1);return}Sa(),Qe(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:Ze?"var(--primary)":h?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||h?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[t.jsx(W.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",h&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:y}),D.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[D.slice(0,3).map(_=>t.jsxs("span",{className:"inline-flex max-w-44 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[_.label,":"]}),t.jsx("span",{className:"truncate",children:_.value})]},_.key)),D.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",D.length-3]})]}),h&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Bi,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})}),Ze&&pt.createPortal(t.jsxs("div",{ref:ki,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...nm,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[ee.map(_=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[_.icon,_.label]},_.label)),fe.length>0&&t.jsxs("button",{type:"button",onClick:()=>vt(_=>!_),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":sr,children:[t.jsx(W.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),lr.length>0&&t.jsxs("button",{type:"button",onClick:()=>It(_=>!_),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":Kt,children:[t.jsx(W.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Te?"var(--danger)":h?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Fo,value:Pe,rows:3,onChange:_=>jo(_.target.value,_.target),onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Ii(Pe)),_.key==="Escape"&&Qe(!1)},placeholder:T,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),Q.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:Q.map(_=>t.jsx("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:_},_))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Te?"var(--danger)":"var(--text-muted)"},children:Te??(h?`${D.length||1} filtro${(D.length||1)===1?"":"s"} activo${(D.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),D.map(_=>t.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[_.label,":"]}),t.jsx("span",{className:"truncate",children:_.value})]},_.key))]}),Kt&&lr.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(W.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Gt([]),It(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(W.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),lr.map(_=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:_})}),t.jsx("button",{type:"button",onClick:()=>Gt(se=>se.filter(ve=>ve!==_)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})})]},_))]}),sr&&fe.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:fe.map(_=>t.jsxs("button",{type:"button",onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),ka(_.bql),vt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:_.bql}),_.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:_.description})]},_.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[h&&t.jsxs("button",{type:"button",onClick:Bi,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ii(Pe),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[t.jsx(W.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),nt&&t.jsx("button",{ref:ga,type:"button","aria-haspopup":"menu","aria-expanded":yn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var se;const _=(se=ga.current)==null?void 0:se.getBoundingClientRect();_&&im({top:_.bottom+4,right:window.innerWidth-_.right}),pa(ve=>!ve)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${yn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiArrowDownTray,{className:"h-4 w-4"})}),de&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&mt==="visibility","aria-label":ae,title:ae,onClick:_=>Pi(_,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Ye&&mt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ji=()=>{if(!Om)return null;const h=Yc(it,Zo);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${Y?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Zt===0?"0 filas":`${Hm}–${Im} de ${Zt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(ur,{value:String(Ut),onChange:D=>Bm(Number(D)),options:Vo.map(D=>({value:String(D),label:String(D)})),placeholder:"Filas",searchable:!1,disabled:a,height:V,padding:X,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:P}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||it<=1,onClick:()=>Qo(it-1),onMouseEnter:D=>{D.currentTarget.disabled||(D.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",D.currentTarget.style.color="var(--primary)")},onMouseLeave:D=>{D.currentTarget.style.background="transparent",D.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(W.HiChevronLeft,{className:"h-3.5 w-3.5"})}),h.map((D,Q)=>D==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>Qo(D),onMouseEnter:_=>{_.currentTarget.disabled||D===it||(_.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",_.currentTarget.style.color="var(--primary)")},onMouseLeave:_=>{_.currentTarget.style.background=D===it?"var(--primary)":"transparent",_.currentTarget.style.color=D===it?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:D===it?"var(--primary)":"transparent",color:D===it?"var(--primary-fg)":"var(--text-muted)"},children:D},D)),t.jsx("button",{disabled:a||it>=Zo,onClick:()=>Qo(it+1),onMouseEnter:D=>{D.currentTarget.disabled||(D.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",D.currentTarget.style.color="var(--primary)")},onMouseLeave:D=>{D.currentTarget.style.background="transparent",D.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:t.jsx(W.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},zm=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((h,D)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${_e}`},children:[Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},"select-cell"),$t.map((Q,_)=>t.jsx("div",{role:"cell",className:Y?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Mi(D,_)}%`,minWidth:32}})},Q.key))]},D))})]})})]}),Ro="min-w-0 max-w-full overflow-hidden";return J&&Le&&!et?t.jsx(Cn,{rows:o,columns:Math.max(4,$t.length||7)}):!a&&r.length===0&&!_o?zm():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx(es.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:$i,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((h,D)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${_e}`},children:[Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},"select-cell"),$t.map((Q,_)=>{const se=Ea[Q.key],ve=se!==void 0,Ce=Q.key===Go;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:Y?"px-2 py-1.5":"px-3 py-2",style:ve?{position:"sticky",left:se,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Ce?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${_e}`:`inset 0 -1px 0 ${_e}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Mi(D,_)}%`,minWidth:32}})},Q.key)})]},D))})]})})}),Ji()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:_e,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??t.jsx(W.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Ma},children:[Aa(),Da(),Oa(),t.jsx("div",{ref:ir,className:Ro,children:t.jsx(es.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:$i,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Nn,minWidth:Ta},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:$a()}),t.jsx("div",{role:"rowgroup",children:qi.map((h,D)=>{const Q=n(h),_=Ki(S==null?void 0:S(h)),se=D>0?Ki(S==null?void 0:S(qi[D-1])):null,ve=_&&_.key!==(se==null?void 0:se.key),Ce=Bt&&k.has(Q),$e=Bt&&(!E||E(h)),Ue=Xr?(m==null?void 0:m(h))??!0:!1,Ke=Ue&&Wi.has(Q),yt=!!d||g&&Ue,rt=Ce&&M?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":D%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[ve&&t.jsx("div",{role:"row",className:`grid ${_.className??""}`,style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:_.label}),_.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:_.description})]})})})}),t.jsxs("div",{role:"row",onClick:yt?xe=>{const Ae=xe.target;if(!(Ae!=null&&Ae.closest('[data-dt-disable-row-click="true"]'))){if(g&&Ue){Ui(Q);return}d==null||d(h)}}:void 0,className:`grid transition-colors ${yt?"cursor-pointer":""} ${H?H(h):""}`,style:{gridTemplateColumns:Kr,"--dt-row-bg":rt,"--dt-sticky-bg":rt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${_e}`},onMouseEnter:xe=>{Ce||(xe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),xe.currentTarget.style.setProperty("--dt-sticky-bg",Fm))},onMouseLeave:xe=>{xe.currentTarget.style.setProperty("--dt-row-bg",rt),xe.currentTarget.style.setProperty("--dt-sticky-bg",rt)},children:[Xr&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},"data-dt-disable-row-click":"true",children:Ue&&t.jsx("button",{type:"button","aria-label":Ke?"Contraer fila":"Desplegar fila","aria-expanded":Ke,onClick:xe=>{xe.stopPropagation(),Ui(Q)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:Ke?t.jsx(W.HiChevronDown,{className:"h-4 w-4"}):t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})}),Bt&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Xo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`},onClick:xe=>{xe.stopPropagation(),$e&&v(Q)},children:t.jsx(Mn,{size:"sm",checked:Ce,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:xe=>xe.stopPropagation(),onChange:()=>{$e&&v(Q)}})}),$t.map(xe=>{const Ae=Ea[xe.key],ke=Ae!==void 0,we=xe.key===Go,Ne=fr(xe);return t.jsx("div",{role:"cell","data-dt-column-key":xe.key,"data-dt-disable-row-click":xe.disableRowClick||Ne?"true":void 0,className:`${Ne?"px-2 py-1.5 justify-center text-center":`${Y?"px-2 py-1.5":"px-3 py-2"} ${Vi(xe.align)}`} flex min-w-0 items-center ${zc} ${xe.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...ke?{position:"sticky",left:Ae,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${_e}`:`inset 0 -1px 0 ${_e}`,borderRight:`1px solid ${_e}`}:{borderBottom:`1px solid ${_e}`,borderRight:`1px solid ${_e}`}},children:t.jsx(ys,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:xe.cell(h)})})},xe.key)})]}),Ke&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:Y?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${_e}`},children:u(h)})})]},Q)})})]})})}),Ji()]})}const Gc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Hn({title:e="Sin resultados",description:r,icon:n=t.jsx(W.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:o,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Gc[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||o)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}function Pt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function xs(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function Cr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function er(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function ws(e){const r=Cr(e),n=(r.getDay()+6)%7;return er(r,-n)}function Va(e){const r=ws(e);return Array.from({length:7},(n,a)=>er(r,a))}function Ns(e){const r=e.getDay();return r===0||r===6}function In(e){return e.filter(r=>!Ns(r))}function ks(e){return In(Va(e))}function Zc(e){const r=Cr(e),n=r.getDay();return n===6?er(r,-1):n===0?er(r,-2):r}function Ya(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=ws(r);return Array.from({length:42},(a,o)=>er(n,o))}function Xa(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Ss(e){return Xa(e).map(In)}function Qc(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function tr(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=xs(n.start);if(!a)return null;const o=xs(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function Es(e,r){const n={};for(const a of e){const o=tr(a,r);if(!o)continue;let l=Cr(o.start);const i=Cr(o.end);for(;l.getTime()<=i.getTime();){const c=Pt(l);n[c]||(n[c]=[]),n[c].push(a),l=er(l,1)}}return n}function Ka(e,r,n){if(r.length===0)return[];const a=Cr(r[0]),o=Cr(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const m=tr(d,n),b=tr(u,n),f=(m==null?void 0:m.start.getTime())??0,p=(b==null?void 0:b.start.getTime())??0;return f-p||d.title.localeCompare(u.title)});for(const d of c){const u=tr(d,n);if(!u||!Qc(u.start,u.end,a,o))continue;const m=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((m.getTime()-a.getTime())/864e5)),p=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),g=Math.max(1,p-f+1);let k=l.findIndex(v=>v<f);k<0?(k=l.length,l.push(f+g-1)):l[k]=f+g-1,i.push({item:d,lane:k,colStart:f,colSpan:g})}return i}function Lt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function Jc(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Rc(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Cs(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ms(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?er(e,n*7):er(e,n)}const ed=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],Ts=["Lun","Mar","Mié","Jue","Vie"];function td({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=tr(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Ft,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function rd({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=tr(e),l=o?`${Lt(o.start)} → ${Lt(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function nd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=tr(e),i=l?`${Lt(l.start)} → ${Lt(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function $s({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function As({value:e,options:r,onChange:n}){return t.jsx("div",{className:"inline-flex overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:r.map((a,o)=>{const l=e===a.value;return t.jsxs("button",{type:"button",onClick:()=>n(a.value),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold transition-colors",style:{background:l?"var(--primary)":"var(--bg-card)",color:l?"var(--primary-fg, #fff)":"var(--text-secondary)",borderRight:o<r.length-1?"1px solid var(--border)":void 0},children:[a.icon,a.label]},a.value)})})}function ad({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:m,hideWeekends:b=!1,renderToolbarExtra:f,renderPill:p,renderDayCard:g,renderWeekBar:k,tableColumns:v,tableProps:A,onItemClick:E,onDayClick:M,loading:H=!1,emptyTitle:S="Sin eventos",emptyDescription:x="No hay eventos para los filtros seleccionados.",legend:C,legendInteractive:w=!0,activeLegendKeys:P,defaultActiveLegendKeys:V,onActiveLegendKeysChange:X,getItemLegendKey:O,overloadLabel:K="Sobrecarga de eventos",notice:q,showOverload:le=!0,layout:J="span",className:G="",showToolbar:U=!0}){const Y=m??(b?[...Ts]:[...ed]),ue=b?5:7,L=b?"grid grid-cols-5":"grid grid-cols-7",B=s.useMemo(()=>(C??[]).map(ce=>ce.label),[C]),[de,I]=s.useState(()=>V??B),oe=s.useMemo(()=>P??(B.length>0?de:[]),[P,B.length,de]),N=s.useMemo(()=>new Set(oe),[oe]),R=ce=>{P===void 0&&I(ce),X==null||X(ce)},ae=ce=>{w&&(N.has(ce)?R(oe.filter(Se=>Se!==ce)):R([...oe,ce]))},$=s.useMemo(()=>{if(!w||B.length===0)return e;const ce=new Set(B);return e.filter(Se=>{const re=(O==null?void 0:O(Se))??Se.status;return!re||!ce.has(re)?!0:N.has(re)})},[e,w,B,N,O]),ne=s.useMemo(()=>Es($,c),[$,c]),te=s.useMemo(()=>{const ce=Ya(r);return b?In(ce):ce},[r,b]),j=s.useMemo(()=>{const ce=Ya(r);return b?Ss(ce):Xa(ce)},[r,b]),y=s.useMemo(()=>b?ks(r):Va(r),[r,b]),T=Pt(r),ee=ne[T]??[],fe=s.useMemo(()=>Ka($,y,c),[$,y,c]),ie=s.useMemo(()=>fe.length===0?1:Math.max(...fe.map(ce=>ce.lane))+1,[fe]),he=s.useMemo(()=>j.map(ce=>{const Se=Ka($,ce,c),re=Se.length===0?0:Math.max(...Se.map(Le=>Le.lane))+1;return{days:ce,bars:Se,laneCount:re}}),[j,$,c]),Te=36,De=38,ft=s.useMemo(()=>{const ce=l==="month"?te:l==="week"?y:[r],Se=[];for(const re of ce){const Le=Pt(re),Oe=ne[Le]??[];Oe.length>=u&&Se.push([re,Oe])}return Se},[l,te,y,r,ne,u]),Ct=l==="month"?Jc(r):l==="week"?`${Lt(y[0])} – ${Lt(y[6])}`:Rc(r),nt=s.useMemo(()=>[{key:"title",header:"Título",cell:ce=>ce.title},{key:"status",header:"Estado",cell:ce=>ce.status??"—"},{key:"range",header:"Rango",cell:ce=>{const Se=tr(ce,c);return Se?`${Lt(Se.start)} → ${Lt(Se.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ce=>ce.subtitle??"—"}],[c]),st=ce=>{if(n(ce),M){M(ce);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${G}`.trim(),children:[U?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":"Anterior",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ms(r,l,-1)),children:t.jsx(W.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:Ct}),t.jsx("button",{type:"button","aria-label":"Siguiente",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ms(r,l,1)),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f,t.jsx(As,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(W.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(W.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(As,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,C&&C.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:w?"group":void 0,"aria-label":w?"Filtrar por estado":void 0,children:C.map(ce=>{const Se=N.has(ce.label);return w?t.jsxs("button",{type:"button","aria-pressed":Se,onClick:()=>ae(ce.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Se?"var(--text-main)":"var(--text-muted)",background:Se?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Se?`1px solid color-mix(in srgb, ${ce.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Se?1:.45},title:Se?`Ocultar “${ce.label}”`:`Mostrar “${ce.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ce.color,boxShadow:Se?`0 0 0 2px color-mix(in srgb, ${ce.color} 25%, transparent)`:void 0},"aria-hidden":!0}),ce.label]},ce.label):t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ce.color},"aria-hidden":!0}),ce.label]},ce.label)})}):null,a==="calendar"&&q&&q.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:q.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[q.label,":"]})," ",q.items.join(", ")]}):a==="calendar"&&le&&ft.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[K,":"]})," ",ft.map(([ce,Se])=>`${Lt(ce)} (${Se.length})`).join(", ")]}):null,a==="table"?H||$.length>0?t.jsx(Ua,{columns:v??nt,data:$,getRowId:ce=>ce.id,loading:H,skeletonRows:8,emptyIcon:t.jsx(W.HiCalendarDays,{className:"h-10 w-10"}),emptyText:x,onRowClick:E,pageSize:25,compact:!0,...A}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:S,description:x}):null,a==="calendar"&&l==="month"&&J==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:L,style:{borderBottom:"1px solid var(--border)"},children:Y.map(ce=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ce},ce))}),t.jsx("div",{className:L,children:te.map(ce=>{const Se=Pt(ce),re=ne[Se]??[],Le=ce.getMonth()!==r.getMonth(),Oe=Math.max(0,re.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${ce.getDate()}`,onClick:()=>st(ce),onKeyDown:Ve=>{(Ve.key==="Enter"||Ve.key===" ")&&(Ve.preventDefault(),st(ce))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Le?"var(--text-muted)":"var(--text-main)"},children:ce.getDate()}),re.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:re.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[re.slice(0,d).map(Ve=>t.jsx($s,{item:Ve,day:ce,renderPill:p,onClick:()=>E==null?void 0:E(Ve)},Ve.id)),Oe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Oe," más"]}):null]})]},Se)})})]}):null,a==="calendar"&&l==="month"&&J==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:L,style:{borderBottom:"1px solid var(--border)"},children:Y.map(ce=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ce},ce))}),he.map(({days:ce,bars:Se,laneCount:re},Le)=>{const Oe=Math.min(re,d),Ve=Math.max(0,re-d),je=Te+Math.max(1,Oe)*De+(Ve>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:je,borderBottom:Le<he.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:L,style:{minHeight:je},children:ce.map(Be=>{const et=Pt(Be),ot=ne[et]??[],Ht=Be.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Be.getDate()}`,onClick:()=>st(Be),onKeyDown:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),st(Be))},className:"cursor-pointer p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",minHeight:je},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Ht?"var(--text-muted)":"var(--text-main)"},children:Be.getDate()}),ot.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ot.length}):null]})},et)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:Te,bottom:4},children:[Se.filter(Be=>Be.lane<d).map(Be=>{const et={left:`calc(${Be.colStart/ue*100}% + 4px)`,width:`calc(${Be.colSpan/ue*100}% - 8px)`,top:2+Be.lane*De,height:De-6,pointerEvents:"auto"};return p?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(Be.item,{day:ce[Be.colStart]})})},`${Be.item.id}-${Be.colStart}-${Le}`):k?t.jsx("div",{className:"absolute overflow-hidden",style:et,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:k(Be.item)})},`${Be.item.id}-${Be.colStart}-${Le}`):t.jsx(td,{item:Be.item,style:et,onClick:()=>E==null?void 0:E(Be.item)},`${Be.item.id}-${Be.colStart}-${Le}`)}),Ve>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+Oe*De,color:"var(--text-muted)"},children:["+",Ve," más"]}):null]})]},`week-${Le}-${Pt(ce[0])}`)})]}):null,a==="calendar"&&l==="week"&&J==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:L,children:y.map(ce=>{const Se=Pt(ce),re=ne[Se]??[],Le=Math.max(0,re.length-d);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>st(ce),children:[Cs(ce),t.jsx("span",{className:"mt-1 block text-sm",children:ce.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[re.slice(0,d).map(Oe=>t.jsx($s,{item:Oe,day:ce,renderPill:p,onClick:()=>E==null?void 0:E(Oe)},Oe.id)),Le>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Le," más"]}):null]})]},Se)})})}):null,a==="calendar"&&l==="week"&&J==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${L} border-b`,style:{borderColor:"var(--border)"},children:y.map(ce=>t.jsx("button",{type:"button",className:"px-3 py-2 text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)",borderRight:"1px solid var(--border)"},onClick:()=>st(ce),children:Cs(ce)},Pt(ce)))}),t.jsxs("div",{className:`relative ${L}`,style:{minHeight:Math.max(220,ie*56+24)},children:[y.map(ce=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Pt(ce)}`)),fe.map(ce=>{const Se={left:`calc(${ce.colStart/ue*100}% + 4px)`,width:`calc(${ce.colSpan/ue*100}% - 8px)`,top:12+ce.lane*56,height:48};return k?t.jsx("div",{className:"absolute overflow-hidden",style:Se,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:k(ce.item)})},`${ce.item.id}-${ce.colStart}`):t.jsx(nd,{item:ce.item,style:Se,onClick:()=>E==null?void 0:E(ce.item)},`${ce.item.id}-${ce.colStart}`)}),fe.length===0&&!H?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:x}):null]})]}):null,a==="calendar"&&l==="day"?ee.length>0||H?t.jsxs("div",{className:"space-y-3",children:[H&&ee.length===0?t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,ee.map(ce=>g?t.jsx("div",{children:g(ce)},ce.id):t.jsx(rd,{item:ce,onClick:()=>E==null?void 0:E(ce)},ce.id))]}):t.jsx(Hn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:S,description:x}):null]})}function Ls(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function od(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Ls(e)}function sd(e){return typeof e=="function"?e():e}function Ga({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(W.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(W.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:p,type:g="button",...k}){const[v,A]=s.useState(!1),E=s.useRef(null);s.useEffect(()=>()=>{E.current&&window.clearTimeout(E.current)},[]);function M(S){A(!0),d==null||d(S),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{A(!1),E.current=null},r)}async function H(S){var C;if(c&&S.stopPropagation(),p==null||p(S),S.defaultPrevented)return;const x=sd(e);if(x)try{await od(x),M(x)}catch(w){try{Ls(x),M(x)}catch(P){u==null||u(P,x);return}(C=navigator.clipboard)!=null&&C.writeText||u==null||u(w,x)}}return t.jsxs("button",{...k,type:g,onClick:H,title:v?a:n,"aria-label":k["aria-label"]??(v?a:n),"data-copied":v?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:v?"scale(1.15)":"scale(1)"},children:v?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??f:f})]})}function ld({code:e,children:r,title:n="Codigo",language:a,copyLabel:o="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(Ga,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:o})]}),t.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function Bn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function id({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(W.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:Bn(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:Bn(o),padding:Bn(l)}})]})}function cd({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=o?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[o&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Bn(d)},children:o}),t.jsx(ur,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const dd={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Fn=180,ud="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Za({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:p=!0,placement:g="center",bodyClassName:k="px-6 py-5",panelClassName:v="",backdropClassName:A=ud,contentClassName:E="p-4",ariaLabel:M,frameless:H=!1,disabled:S=!1}){const[x,C]=s.useState(!1),[w,P]=s.useState(!1),V=s.useRef(null);if(s.useEffect(()=>(e?(V.current&&clearTimeout(V.current),C(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),V.current=setTimeout(()=>C(!1),Fn+40)),()=>{V.current&&clearTimeout(V.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const J=G=>{G.key==="Escape"&&r()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[f,r,e]),!x)return null;const X=n||a||o||l||p,O=u??dd[d],K=g==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",q=g==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",le=w?"translateY(0) scale(1)":g==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return pt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":M??n,className:`fixed inset-0 flex ${K} ${E}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${A}`,onClick:b?r:void 0,style:{opacity:w?1:0,transition:`opacity ${Fn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${H?"shadow-none":"shadow-2xl"} ${q} ${v}`,style:{maxWidth:O,background:H?"transparent":"var(--bg-card)",border:H?"none":"1px solid var(--border)",opacity:w?1:0,transform:le,transition:`opacity ${Fn}ms ease, transform ${Fn}ms ease`},onClick:J=>J.stopPropagation(),children:[S&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),X&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[o&&t.jsx("div",{className:"flex-shrink-0",children:o}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,p&&t.jsx(Ge,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${k}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const fd={danger:{iconBg:"rgba(239,68,68,0.12)",iconColor:"var(--danger)",btnBg:"var(--danger)",btnColor:"#fff"},warning:{iconBg:"rgba(245,158,11,0.12)",iconColor:"var(--warning)",btnBg:"var(--warning)",btnColor:"#fff"},primary:{iconBg:"rgba(59,130,246,0.12)",iconColor:"var(--primary)",btnBg:"var(--primary)",btnColor:"#fff"}};function bd({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=fd[l];return t.jsx(Za,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ge,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ge,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ge,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function md(e){return e?typeof e=="function"?e():e:""}function hd(e){return/^https?:\/\//i.test(e)}function Ds(e,r){try{return new URL(e,r).toString()}catch{return e}}function pd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||hd(l))return l;const i=md(n);return i?Ds(l,i):a&&typeof window<"u"?Ds(l,window.location.origin):l}function gd({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(W.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Ga,{...c,value:()=>pd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const vd={email:{pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo inválido"},integer:{pattern:/^-?\d+$/,message:"Debe ser un número entero"},date:{pattern:/^\d{4}-\d{2}-\d{2}$/,message:"Fecha inválida"}};function yd(e,r){if(r.minLength!==void 0&&e.length<r.minLength)return r.message??`Mínimo ${r.minLength} caracteres`;if(r.maxLength!==void 0&&e.length>r.maxLength)return r.message??`Máximo ${r.maxLength} caracteres`;if(!e)return null;if(r.preset){const n=vd[r.preset];if(!n.pattern.test(e))return r.message??n.message}return r.pattern&&!r.pattern.test(e)?r.message??"Formato inválido":null}const xd=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function wd({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return s.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>o(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!xd.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Nd({initialValue:e,options:r,loading:n,onCommit:a,onCancel:o}){const l=s.useRef(null);return s.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),o())},children:t.jsx(ur,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const kd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Qa={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Sd({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(r),d=s.useRef(null);s.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=s.useState(null);d.current=u;const[b,f]=s.useState(null),p=s.useRef(null);p.current=b;const[g,k]=s.useState({}),[v,A]=s.useState(null),E=s.useRef(null);E.current=v;const[M,H]=s.useState({}),[S,x]=s.useState({}),C=s.useRef(new Set),w=s.useRef(null);s.useEffect(()=>{var B;const L=document.activeElement;(!L||L===document.body)&&((B=w.current)==null||B.focus({preventScroll:!0}))},[]);const P=e.map(L=>{var B,de,I;return`${L.key}:${((I=(de=(B=L.editable)==null?void 0:B.select)==null?void 0:de.options)==null?void 0:I.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(L=>{var I,oe;const B=(oe=(I=L.editable)==null?void 0:I.select)==null?void 0:oe.options;if(!B)return;const de=M[L.key];(!C.current.has(L.key)||(de==null?void 0:de.length)===0&&B.length>0)&&(C.current.add(L.key),H(N=>({...N,[L.key]:B})))})},[P]);const V=s.useCallback(async(L,B)=>{if(C.current.has(L))return;C.current.add(L);const{url:de,fetchOptions:I}=B.select??{};if(!(!de&&!I)){x(oe=>({...oe,[L]:!0}));try{let oe=[];if(I)oe=await I();else if(de){const N=await fetch(de);if(!N.ok)throw new Error("fetch failed");oe=await N.json()}H(N=>({...N,[L]:oe}))}catch{H(oe=>({...oe,[L]:[]}))}finally{x(oe=>({...oe,[L]:!1}))}}},[]),X=s.useRef(i);X.current=i;const O=s.useRef(a);O.current=a;const K=s.useRef(n);K.current=n;const q=s.useRef(e);q.current=e;const le=s.useRef(o);le.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const L=e.find(B=>B.selectable!==!1);L&&f({rowId:n(r[0]),colKey:L.key})}},[]),s.useEffect(()=>{if(!b)return;const L=w.current;if(!L)return;const B=L.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!B)return;const de=L.querySelector('[role="rowgroup"]');B.style.scrollMarginTop=`${(de==null?void 0:de.offsetHeight)??0}px`;const I=L.querySelector('[role="row"]');let oe=0;I&&I.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(N=>{N.style.position==="sticky"&&N.style.left!==""&&(oe=Math.max(oe,parseFloat(N.style.left)+N.offsetWidth))}),B.style.scrollMarginLeft=`${oe}px`,B.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const J=s.useCallback(L=>{var oe;const B=q.current,de=new Set,I=[];(oe=w.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(N=>{const R=N.dataset.cellId.split(":")[0];de.has(R)||(de.add(R),I.push(R))}),f(N=>{if(!N)return N;const R=B.findIndex(te=>te.key===N.colKey),ae=I.indexOf(N.rowId);let $=R,ne=ae;if(L==="up")ne=Math.max(0,ae-1);else if(L==="down")ne=Math.min(I.length-1,ae+1);else if(L==="left"){let te=R-1;for(;te>=0&&B[te].selectable===!1;)te--;te>=0&&($=te)}else if(L==="right"){let te=R+1;for(;te<B.length&&B[te].selectable===!1;)te++;te<B.length&&($=te)}return $===R&&ne===ae?N:{rowId:I[ne],colKey:B[$].key}})},[]),G=s.useCallback((L=!0)=>{const B=d.current;m(null),B&&f(B),L&&setTimeout(()=>{var de;return(de=w.current)==null?void 0:de.focus({preventScroll:!0})},0)},[]),U=s.useCallback(async(L,B,de)=>{var ie;const I=q.current.find(he=>he.key===B);if(!(I!=null&&I.editable))return;const{field:oe,type:N,mask:R,validate:ae}=I.editable,$=N==="number"?de===""?null:Number(de):de;if(R){const he=yd(de,R);if(he){k(Te=>({...Te,[`${L}:${B}`]:he}));return}}if(ae){const he=ae($);if(he){k(Te=>({...Te,[`${L}:${B}`]:he}));return}}const ne=K.current,te=X.current.find(he=>ne(he)===L);if(!te)return;const j=te[oe];m(null),k(he=>{const Te={...he};return delete Te[`${L}:${B}`],Te});const y=X.current,T=y.findIndex(he=>ne(he)===L),ee=y[Math.min(y.length-1,T+1)];if(f({rowId:ne(ee),colKey:B}),setTimeout(()=>{var Te,De;const he=document.activeElement;(!he||he===document.body||(Te=w.current)!=null&&Te.contains(he))&&((De=w.current)==null||De.focus({preventScroll:!0}))},0),String(j??"")===String($??""))return;const fe={...te,[oe]:$};c(he=>he.map(Te=>ne(Te)===L?fe:Te)),A({rowId:L,colKey:B});try{await((ie=O.current)==null?void 0:ie.call(O,{row:te,rowId:L,field:oe,oldValue:j,newValue:$}))}catch{c(he=>he.map(Te=>ne(Te)===L?te:Te)),k(he=>({...he,[`${L}:${B}`]:"Error al guardar. Intenta de nuevo."}))}finally{A(null)}},[]),Y=s.useCallback(L=>{if(E.current){L.preventDefault();return}if(d.current)return;const B=p.current;if(!(!B||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(L.key)))switch(L.preventDefault(),L.key){case"ArrowUp":J("up");break;case"ArrowDown":J("down");break;case"ArrowLeft":J("left");break;case"ArrowRight":J("right");break;case"Tab":J(L.shiftKey?"left":"right");break;case"Enter":{const I=q.current.find(oe=>oe.key===B.colKey);I!=null&&I.editable&&!le.current?(m(B),I.editable.type==="select"&&!C.current.has(B.colKey)&&V(B.colKey,I.editable)):J("down");break}}},[J,V]),ue=s.useMemo(()=>e.map(L=>{if(!L.editable||o){const de={...L};if(delete de.editable,delete de.selectable,L.selectable===!1)return{...de,disableRowClick:!0};const I=de.cell;return{...de,className:`relative ${de.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const N=n(oe),R=(b==null?void 0:b.rowId)===N&&(b==null?void 0:b.colKey)===L.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${N}:${L.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var ae;E.current||(f({rowId:N,colKey:L.key}),(ae=w.current)==null||ae.focus({preventScroll:!0}))}}),R&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Qa}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:I(oe)})]})}}}const B=L.editable;return{...L,className:`relative ${L.className??""}`.trim(),disableRowClick:!0,cell:de=>{const I=n(de),oe=L.key,N=(u==null?void 0:u.rowId)===I&&(u==null?void 0:u.colKey)===oe,R=(b==null?void 0:b.rowId)===I&&(b==null?void 0:b.colKey)===oe,ae=g[`${I}:${oe}`],$=(v==null?void 0:v.rowId)===I&&(v==null?void 0:v.colKey)===oe,ne=de[B.field],te=String(ne??""),j=()=>{var T;E.current||(f({rowId:I,colKey:oe}),m({rowId:I,colKey:oe}),(T=w.current)==null||T.focus({preventScroll:!0}),B.type==="select"&&!C.current.has(oe)&&V(oe,B))};if(N){const T=B.type==="select"?t.jsx(Nd,{initialValue:te,options:M[oe]??[],loading:S[oe]??!1,onCommit:ee=>U(I,oe,ee),onCancel:G}):t.jsx(wd,{initialValue:te,type:B.type??"text",mask:B.mask,onCommit:ee=>U(I,oe,ee),onCancel:G});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:kd,onClick:ee=>ee.stopPropagation(),children:T})}const y=L.cell(de);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${I}:${oe}`,className:`peer absolute inset-0 z-10 ${$?"cursor-wait":"cursor-pointer"}`,onClick:j}),R&&!$&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Qa}),$&&t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:Qa,children:[t.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:ae?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(W.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:ae})]}):t.jsx("span",{className:"truncate",children:y})}),!$&&t.jsx(W.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,u,b,v,g,M,S,n,U,G,V]);return t.jsx("div",{ref:w,tabIndex:0,onKeyDown:Y,onBlur:L=>{var B;(B=w.current)!=null&&B.contains(L.relatedTarget)||setTimeout(()=>{var I,oe;const de=document.activeElement;de&&((I=de.closest)!=null&&I.call(de,"[data-bonsaif-select-dropdown]"))||(oe=w.current)!=null&&oe.contains(de)||G(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(Ua,{...l,columns:ue,data:i,getRowId:n})})}function lt(e){if(e)return new Date(`${e}T12:00:00`)}function Dt(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function Mr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Os(e){return e.map(r=>lt(r)).filter(r=>!!r)}function Ed(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Dt));return Array.from(r).sort()}function Ja(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Hs(e){const r=lt(e);if(!r)return e;const n=Ja(r).replace(/\.$/u,"").replace(/^\w/u,o=>o.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const Ra={weekend:{dayOfWeek:[0,6]}},eo={weekend:"bonsaif-weekend"};function to({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),o=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${o?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const Cd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Md={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Td({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,o=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${o?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?Cd:null,...o?Md:null,...l?{fontWeight:800}:null,...n.style}})}function $d({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:lt(e),to:lt(r)},f=lt(a),[p,g]=s.useState(()=>lt(o||e)??new Date);s.useEffect(()=>{const M=lt(o||e);M&&g(M)},[o,e]);const k=s.useMemo(()=>{if(l<=1)return Mr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(p));const M=new Date(p.getFullYear(),p.getMonth()+l-1,1),H=p.getFullYear()===M.getFullYear(),S=new Intl.DateTimeFormat("es-MX",{month:"short",...H?{}:{year:"numeric"}}).format(p),x=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(M);return`${Mr(S)} – ${Mr(x)}`},[p,l]);function v(){g(new Date(p.getFullYear(),p.getMonth()-1,1))}function A(){g(new Date(p.getFullYear(),p.getMonth()+1,1))}const E=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:v,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:A,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsx(Ba.DayPicker,{mode:"range",selected:b,month:p,onMonthChange:g,onSelect:M=>{const H=M!=null&&M.from?Dt(M.from):e,S=M!=null&&M.to?Dt(M.to):"";n({startDate:H,endDate:S})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ra,modifiersClassNames:eo,components:{DayButton:Td,Weekday:to},classNames:{root:"bonsaif-range-daypicker w-full",months:E,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:M=>`${Mr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(M))} ${M.getFullYear()}`,formatWeekdayName:Ja}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function Is({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:o,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),o==null||o(e.date,d))}})}function Bs(e,r){const n=lt(e),a=lt(r);if(!n||!a)return[];const o=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(o);for(;c<=l;)i.push(Dt(c)),c.setDate(c.getDate()+1);return i}function Fs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,o=new Date(e);return o.setHours(12,0,0,0),o.setDate(o.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(o);return c.setDate(o.getDate()+i),c})}function an(e,r,n){const a=new Set(e);for(const o of r)n==="add"?a.add(o):n==="remove"||a.has(o)?a.delete(o):a.add(o);return Array.from(a).sort()}function Ad(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Ld(e,r,n){return!!(r&&e<r||n&&e>n)}function Ps({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),m=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(S=>{let x=S;if(c){const C=b.current.filter(P=>!P.startsWith(c)),w=S.filter(P=>P.startsWith(c));x=[...C,...w].sort()}r==null||r(Ad(x,l))},[l,r,c]),p=s.useCallback((S,x=!1)=>Ld(S,a,o)?!0:!(!(i!=null&&i(S))||x&&b.current.includes(S)),[i,o,a]),g=s.useCallback(S=>S.filter(x=>!p(x)),[p]),k=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const S=()=>k();return window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),()=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S)}},[k]);const v=s.useCallback((S,x,C,w)=>{const P=g(Bs(S,x));f(C==="add"?an(w,P,"add"):an(w,P,"remove"))},[f,g]),A=s.useCallback((S,x)=>{if(n||x.button!==0)return;const C=Dt(S);if(p(C,!0)||x.shiftKey)return;m.current=!0;const w=[...b.current],P=w.includes(C)?"remove":"add";P==="add"&&p(C)||(u.current={active:!0,mode:P,anchor:C,latest:C,baseline:w},d.current=C,v(C,C,P,w),x.preventDefault())},[v,n,p]),E=s.useCallback(S=>{const x=u.current;if(!(x!=null&&x.active)||n)return;const C=Dt(S);x.mode==="add"&&p(C)||x.latest!==C&&(x.latest=C,v(x.anchor,C,x.mode,x.baseline))},[v,n,p]),M=s.useCallback((S,x)=>{if(n)return;const C=Dt(S);if(!p(C,!0)){if(m.current&&!x.shiftKey){m.current=!1,x.preventDefault(),x.stopPropagation();return}if(m.current=!1,x.shiftKey&&d.current){x.preventDefault(),x.stopPropagation();const w=g(Bs(d.current,C));f(an(b.current,w,"add"));return}!b.current.includes(C)&&p(C)||(d.current=C,f(an(b.current,[C],"toggle")))}},[f,n,g,p]),H=s.useCallback(S=>{if(n)return;const x=g(Ed(S));if(!x.length)return;const C=x.every(w=>b.current.includes(w));f(an(b.current,x,C?"remove":"add")),d.current=x[0]??d.current},[f,n,g]);return{onDayPointerDown:A,onDayPointerEnter:E,onDayClick:M,toggleWeek:H,endDrag:k}}function on(e){return Fs(e,1)[0]}function _s(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Dd({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:m,showSummary:b=!0,className:f="",disabled:p=!1}){const g=s.useMemo(()=>Os(e),[e]),k=s.useMemo(()=>new Set(e),[e]),v=lt(n),A=lt(a),[E,M]=s.useState(()=>lt(l||e[0])??new Date),[H,S]=s.useState(()=>on(lt(l||e[0])??new Date)),[x,C]=s.useState(u),w=d??x;function P(L){d===void 0&&C(L),m==null||m(L)}s.useEffect(()=>{const L=lt(l);L&&(M(L),S(on(L)))},[l]);const{onDayPointerDown:V,onDayPointerEnter:X,onDayClick:O,toggleWeek:K}=Ps({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),q=s.useMemo(()=>{if(p)return!0;const L=[];return v&&L.push({before:v}),A&&L.push({after:A}),o&&L.push(B=>o(Dt(B))),L.length>0?L:void 0},[p,o,A,v]),le=s.useCallback(L=>t.jsx(Is,{...L,className:`bonsaif-multi-day-btn ${L.className??""}`,onDayPointerDown:V,onDayPointerEnter:X,onDayClickSelect:O}),[O,V,X]),J=s.useMemo(()=>Fs(H,1),[H]),G=J[6],U=w==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(J[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(G)}`:Mr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(E));function Y(){if(w==="week"){const L=_s(H,-7);S(on(L)),M(L);return}M(new Date(E.getFullYear(),E.getMonth()-1,1))}function ue(){if(w==="week"){const L=_s(H,7);S(on(L)),M(L);return}M(new Date(E.getFullYear(),E.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":w==="month",className:`bonsaif-cal-view-btn${w==="month"?" is-active":""}`,disabled:p,onClick:()=>{P("month"),M(H)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":w==="week",className:`bonsaif-cal-view-btn${w==="week"?" is-active":""}`,disabled:p,onClick:()=>{P("week"),S(on(E))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:Y,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:U}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":w==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:ue,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&w==="month"?" · Semana (nº)":"",w==="week"?" · Botón semana completa":""]}),w==="month"?t.jsx(Ba.DayPicker,{mode:"multiple",required:!1,selected:g,month:E,onMonthChange:M,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(L,B)=>{K(B)},disabled:q,className:"bonsaif-multi-daypicker",modifiers:Ra,modifiersClassNames:eo,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:le,Weekday:to},formatters:{formatWeekdayName:Ja}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:J.map(L=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(L)},`h-${Dt(L)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:J.map(L=>{const B=Dt(L),de=k.has(B),I=p||(n?B<n:!1)||(a?B>a:!1)||!!(o!=null&&o(B)),oe=B===Dt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${de?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${I?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:I,"aria-pressed":de,onPointerDown:N=>V(L,N),onPointerEnter:()=>X(L),onClick:N=>O(L,N),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:L.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(L)})]})},B)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>K(J),children:"Marcar / desmarcar semana"})]})]}),b?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(L=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(B=>B!==L)),title:`Quitar ${L}`,children:[Hs(L),t.jsx("span",{"aria-hidden":!0,children:"×"})]},L))})]})}):null]})}const Od=Array.from({length:12},(e,r)=>r);function Hd({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const b=s.useMemo(()=>Os(e),[e]),f=lt(o),p=lt(l),g=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[k,v]=s.useState(g);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function A(w){v(w),a==null||a(w)}const{onDayPointerDown:E,onDayPointerEnter:M,onDayClick:H}=Ps({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${k}-`}),S=s.useCallback(w=>t.jsx(Is,{...w,className:`bonsaif-year-day-btn ${w.className??""}`,onDayPointerDown:E,onDayPointerEnter:M,onDayClickSelect:H}),[H,E,M]),x=b.filter(w=>w.getFullYear()===k),C=u?!0:[...f?[{before:f}]:[],...p?[{after:p}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>A(k-1),children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>A(k+1),children:t.jsx(W.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:Od.map(w=>{const P=new Date(k,w,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Mr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(P))}),t.jsx(Ba.DayPicker,{mode:"multiple",required:!1,selected:x,month:P,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:C,className:"bonsaif-year-month-picker",modifiers:Ra,modifiersClassNames:eo,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:S,Weekday:to},formatters:{formatWeekdayName:V=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(V)}})]},`${k}-${w}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",k]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(w=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(P=>P!==w)),title:`Quitar ${w}`,children:[Hs(w),t.jsx("span",{"aria-hidden":!0,children:"×"})]},w))})]})}):null]})}const Id="bonsaif-ui:hide-tooltips";function zs(){window.dispatchEvent(new CustomEvent(Id))}function Bd(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Fd({trigger:e,items:r,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(!1),[f,p]=s.useState({}),g=s.useRef(null),k=s.useRef(null),v=s.useCallback(S=>{u(S),c==null||c(S)},[c]),A=s.useCallback(()=>{const S=g.current;if(!S)return;const x=S.getBoundingClientRect(),C=typeof a=="number"?a:x.width,w=typeof a=="number"?a:Math.max(x.width,180),P=n==="end"?Math.max(8,x.right-w):Math.min(x.left,window.innerWidth-w-8),V=window.innerHeight-x.bottom,X=V<240&&x.top>V?void 0:x.bottom+6,O=X===void 0?window.innerHeight-x.top+6:void 0;p({position:"fixed",zIndex:9999,left:P,top:X,bottom:O,width:Bd(typeof a=="number"?C:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;A();const S=C=>{var P,V;const w=C.target;!((P=g.current)!=null&&P.contains(w))&&!((V=k.current)!=null&&V.contains(w))&&v(!1)},x=C=>{C.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",S),window.addEventListener("keydown",x),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{document.removeEventListener("mousedown",S),window.removeEventListener("keydown",x),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[d,v,A]);const E=S=>{o||(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),v(!d))},M=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(zs(),v(!d))}}):e,H=d?t.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(S=>t.jsxs("div",{children:[S.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:S.disabled,onClick:()=>{var x;S.disabled||(zs(),(x=S.onSelect)==null||x.call(S),v(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:S.danger?"var(--danger)":"var(--text-main)"},children:[S.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:S.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:S.label}),S.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:S.description})]})]})]},S.id))}):null;return t.jsxs("span",{ref:g,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:E,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[M,m&&H?pt.createPortal(H,document.body):null]})}const Pd=180,Ws="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function _d({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:p="Descartar cambios",unsavedChangesDescription:g="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:A,disabled:E=!1,disabledMessage:M,children:H}){const[S,x]=s.useState(!1),[C,w]=s.useState(!1),[P,V]=s.useState(!1),X=s.useCallback(()=>{w(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>V(!0))})},[]),O=s.useCallback(()=>{V(!1),window.setTimeout(()=>w(!1),Pd)},[]),K=E||c,q=s.useCallback(()=>{if(!K){if(f){X();return}r()}},[K,f,r,X]),le=s.useCallback(()=>{V(!1),w(!1),A==null||A(),r()},[r,A]);if(s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(V(!1),w(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const G=U=>{if(U.key==="Escape"&&!K){if(C){O();return}q()}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[O,K,C,e,q]),!S)return null;const J=M!==void 0?M:c?"Guardando…":null;return pt.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${Ws}`,onClick:q}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ge,{variant:"icon",onClick:q,title:"Cerrar",disabled:K,children:t.jsx(W.HiXMark,{className:"w-5 h-5"})}),o&&t.jsx("div",{className:"flex-shrink-0",children:o}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ge,{variant:"secondary",size:"sm",onClick:q,disabled:K,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ge,{variant:"primary",size:"sm",icon:t.jsx(tc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||K,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:H}),K&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:J?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:J})]}):null})]}),C&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Ws} transition-opacity duration-200 ease-out ${P?"opacity-100":"opacity-0"}`,onClick:O}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${P?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ge,{variant:"icon",onClick:O,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":v,children:t.jsx(W.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:p}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:g}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ge,{variant:"secondary",onClick:O,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Ge,{variant:"secondary",onClick:le,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body)}const zd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Wd=/^\+?[0-9\s().-]+$/,jd=7,qd=15;function _t(e){return e==null||String(e).trim()===""}function js(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function ro(e){return _t(e)?!1:zd.test(String(e))}function no(e){if(_t(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Wd.test(r)&&n.length>=jd&&n.length<=qd}function Ud(e="Este campo es requerido."){return r=>_t(r)?e:void 0}function Vd(e="Ingresa un correo valido."){return r=>_t(r)||ro(r)?void 0:e}function Yd(e="Ingresa un telefono valido."){return r=>_t(r)||no(r)?void 0:e}function Xd(e,r){return n=>_t(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Kd(e,r){return n=>_t(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function Gd(e,r){return n=>{if(_t(n))return;const a=js(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Zd(e,r){return n=>{if(_t(n))return;const a=js(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Qd(e,r="El formato no es valido."){return n=>_t(n)||e.test(String(n))?void 0:r}function Jd(e,r){const n={};for(const a of Object.keys(r)){const o=r[a];if(!o)continue;const l=Array.isArray(o)?o:[o];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var qs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Us=s.createContext&&s.createContext(qs),Rd=["attr","size","title"];function eu(e,r){if(e==null)return{};var n,a,o=tu(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function tu(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function Pn(){return Pn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Pn.apply(null,arguments)}function Vs(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function _n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Vs(Object(n),!0).forEach(function(a){ru(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function ru(e,r,n){return(r=nu(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function nu(e){var r=au(e,"string");return typeof r=="symbol"?r:r+""}function au(e,r){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,r);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Ys(e){return e&&e.map((r,n)=>s.createElement(r.tag,_n({key:n},r.attr),Ys(r.child)))}function ao(e){return r=>s.createElement(ou,Pn({attr:_n({},e.attr)},r),Ys(e.child))}function ou(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=eu(e,Rd),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Pn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:_n(_n({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&s.createElement("title",null,l),e.children)};return Us!==void 0?s.createElement(Us.Consumer,null,n=>r(n)):r(qs)}function Xs(e){return ao({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(e)}function su(e){return ao({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(e)}function lu(e){return ao({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(e)}function Tr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(Ft,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(W.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function $r({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function zn({className:e="",...r}){return t.jsx("input",{...r,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function oo({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:o,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:b="",required:f,...p}){const[g,k]=s.useState(()=>!!p.autoFocus),[v,A]=s.useState(!1),E=p.type==="password"&&u,M=E&&v?"text":p.type,H=!!o,S=H&&l!=="tooltip",x=H&&l!=="inline",C=!!n&&a==="tooltip"&&!S,w=m?f:void 0,P=H?"border-[var(--danger)] focus:border-[var(--danger)]":"",V=x?E?"pr-20":"pr-10":E?"pr-10":"",X=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,O=g||X,K={top:O?7:12,color:g?"var(--primary)":"var(--text-muted)",fontSize:O?10:13,fontWeight:O?600:400,textTransform:O?"uppercase":"none"},q=Y=>{var ue;k(!0),(ue=p.onFocus)==null||ue.call(p,Y)},le=Y=>{var ue;k(!1),(ue=p.onBlur)==null||ue.call(p,Y)},J=E?t.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>A(Y=>!Y),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(su,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(lu,{className:"h-[18px] w-[18px]"})})]}):null,G=x?t.jsx(Ft,{as:"span",content:o,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${E?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Xs,{className:"h-[18px] w-[18px]"})})}):null,U=t.jsx($r,{error:S?o:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...p,type:M,required:w,placeholder:" ","aria-invalid":H||p["aria-invalid"],"data-has-value":X?"true":void 0,className:`h-11 w-full pt-5 ${V} ${P} ${b}`,onFocus:q,onBlur:le}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:K,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:O?7:12},children:c}),G,J]}),U]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),C?t.jsx(Tr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),E?t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...p,type:M,required:w,"aria-invalid":H||p["aria-invalid"],className:`w-full ${V} ${P} ${b}`,onFocus:q,onBlur:le}),G,J]}):t.jsxs("span",{className:"relative block",children:[t.jsx(zn,{...p,required:w,"aria-invalid":H||p["aria-invalid"],className:`w-full ${V} ${P} ${b}`}),G]}),U]})}function Ks(e){return e==null?"":String(e)}function iu({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=s.useState(()=>Ks(c)),f=i!==void 0?Ks(i):m,p=n&&f.length>0&&!ro(f)?a:void 0,g=k=>{i===void 0&&b(k.currentTarget.value),d==null||d(k)};return t.jsx(oo,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??p,errorDisplay:o,onChange:g})}const cu={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function du(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function Gs(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),o=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?o.startsWith(n.slice(0,-1)):o===n}):!0}function uu(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function fu({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:b=!1,showFileList:f=!0,clearable:p=!0,browseLabel:g="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:A="o haz click para buscarlos en tu equipo",selectedLabel:E="Archivos seleccionados",size:M="md",containerClassName:H="",dropzoneClassName:S="",fileListClassName:x="",className:C="",id:w,accept:P,disabled:V,required:X,...O}){const K=s.useId(),q=w??K,le=s.useRef(null),[J,G]=s.useState(!1),[U,Y]=s.useState(i),ue=l??U,L=!!a,B=!!r&&n==="tooltip"&&!L,de=p&&ue.length>0&&!V,I=(T,ee)=>{l===void 0&&Y(T),c==null||c(T,ee)},oe=(T,ee)=>{const fe=T.filter(De=>Gs(De,P)),ie=T.filter(De=>!Gs(De,P)),he=b?[...ue,...fe]:fe,Te=uu(he,u,m);ie.length>0&&(d==null||d(ie)),I(Te,ee)},N=()=>{var T;V||(T=le.current)==null||T.click()},R=T=>{oe(Array.from(T.target.files??[]),T),T.target.value=""},ae=T=>{T.preventDefault(),V||G(!0)},$=T=>{T.currentTarget.contains(T.relatedTarget)||G(!1)},ne=T=>{T.preventDefault(),G(!1),!V&&oe(Array.from(T.dataTransfer.files),T)},te=T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),N())},j=T=>{I(ue.filter((ee,fe)=>fe!==T))},y=()=>{I([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${H}`,children:[(e||o||B)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),X&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),B?t.jsx(Tr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...O,ref:le,id:q,type:"file",accept:P,multiple:u,disabled:V,required:X&&ue.length===0,"aria-invalid":L||O["aria-invalid"],className:"sr-only",onChange:R}),t.jsxs("div",{role:"button",tabIndex:V?-1:0,"aria-controls":q,"aria-disabled":V||void 0,"aria-invalid":L||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${cu[M]} ${J?"border-[var(--primary)] bg-[var(--bg-input)]":L?"border-[var(--danger)]":"border-[var(--border)]"} ${V?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${S} ${C}`,onClick:N,onDragOver:ae,onDragLeave:$,onDrop:ne,onKeyDown:te,children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(W.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:J?k:v}),A&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:A})]}),g&&t.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:g})]}),f&&ue.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${x}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:E}),de&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:y,children:t.jsx(W.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ue.map((T,ee)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(W.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:T.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:du(T.size)})]}),!V&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${T.name}`,onClick:()=>j(ee),children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]},`${T.name}-${T.lastModified}-${ee}`))})]}),t.jsx($r,{error:a,helperText:r,helperDisplay:n})]})}const bu=[{value:"texto",label:"texto"},{value:"numero",label:"número"},{value:"fecha",label:"fecha"},{value:"booleano",label:"booleano"},{value:"email",label:"email"},{value:"telefono",label:"teléfono"},{value:"select",label:"select"},{value:"textarea",label:"textarea"},{value:"archivo",label:"archivo"},{value:"imagen",label:"imagen"}];function mu({fields:e,title:r="Layout",fieldTypes:n=bu,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=s.useState(()=>e.map(M=>({key:!1,type:"",...M}))),[f,p]=s.useState(""),[g,k]=s.useState(""),v=s.useCallback((M,H)=>{b(S=>{const x=S.map((C,w)=>w===M?{...C,...H}:C);return u==null||u(x),x})},[u]),A=s.useCallback(()=>{d==null||d(m)},[m,d]),E=s.useCallback(()=>{var x;const M=f.trim();if(!M){k("Ingresa un nombre de campo.");return}if(m.some(C=>C.name.toLowerCase()===M.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const S={name:M,key:!1,type:((x=n[0])==null?void 0:x.value)??""};b(C=>{const w=[...C,S];return u==null||u(w),w}),p(""),k("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((M,H)=>t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:M.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Mn,{size:"sm",checked:M.key??!1,onChange:S=>v(H,{key:S.target.checked}),"aria-label":`${M.name} es clave`})}),t.jsx(ur,{value:M.type??"",onChange:S=>v(H,{type:S}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${M.name}`})]},M.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:f,onChange:M=>{p(M.currentTarget.value),g&&k("")},onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),E())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ge,{variant:"secondary",onClick:E,height:36,padding:"0 12px",children:i})]}),g&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:g})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ge,{variant:"primary",onClick:A,disabled:c,loading:c,children:a})})]})})]})}function Wn({label:e,children:r,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!o;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(Tr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx($r,{error:o,helperText:n,helperDisplay:a})]})}function hu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Zs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=hu(a),l=o.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(o.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const Ot=260,Ar=420,so=380,zt="cubic-bezier(0.22, 1, 0.36, 1)",pu="cubic-bezier(0.16, 1, 0.3, 1)",lo="cubic-bezier(0.22, 1, 0.36, 1)",gu="cubic-bezier(0.22, 1, 0.36, 1)",vu=8,yu=1,xu=1.25,io={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},wu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",co=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function Nu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Qs(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),o=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:o,scale:Number.isFinite(n)?n:1}}function Lr({label:e,onClick:r,children:n,disabled:a,size:o="md"}){const l=o==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...io,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=wu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(io.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function Js({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=vu,minZoom:c=yu,zoomStep:d=xu,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:p=!0,showThumbnails:g=!0,zIndex:k=1100,ariaLabel:v="Visor de imagen"}){const[A,E]=s.useState(!1),[M,H]=s.useState(!1),[S,x]=s.useState(a??0),[C,w]=s.useState(1),[P,V]=s.useState({x:0,y:0}),[X,O]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[K,q]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[le,J]=s.useState(!1),G=s.useRef(null),U=s.useRef(null),Y=s.useRef(null),ue=s.useRef(null),L=s.useRef(null),B=s.useRef(!1),de=s.useRef(!1),I=s.useRef(null),oe=s.useRef(null),N=s.useRef(null),R=s.useRef(null),ae=s.useRef(null),$=s.useRef(a??0),ne=a??S,te=n.length===0?0:sn(ne,0,Math.max(0,n.length-1)),j=n[te],y=n.length>1,T=Math.max(c,i),ee=g&&y,fe=s.useCallback(be=>{if(n.length===0)return;const ge=n.length-1,He=p?(be%n.length+n.length)%n.length:sn(be,0,ge);a===void 0&&x(He),o==null||o(He)},[a,p,o,n.length]),ie=s.useCallback(()=>{w(1),V({x:0,y:0})},[]),he=s.useCallback((be,ge)=>{if(ge<=c+.001)return{x:0,y:0};const He=R.current,We=ae.current;if(!He||!We)return be;const Fe=He.getBoundingClientRect(),bt=We.offsetWidth*ge,ct=We.offsetHeight*ge,qe=Math.max(0,(bt-Fe.width)/2+Fe.width*.15),Ye=Math.max(0,(ct-Fe.height)/2+Fe.height*.15);return{x:sn(be.x,-qe,qe),y:sn(be.y,-Ye,Ye)}},[c]),Te=s.useCallback(()=>{E(!1),q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ue.current=null,L.current=null,B.current=!1,de.current=!1,I.current&&(clearTimeout(I.current),I.current=null)},[]),De=s.useCallback(()=>{if(B.current)return;B.current=!0,H(!1),ie();const be=ue.current,ge=be!=null&&L.current!=null&&L.current===te;if(be&&ge){Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{const He=ae.current;if(!He){Y.current=null,G.current&&clearTimeout(G.current),G.current=setTimeout(Te,Ot+40);return}const We=He.getBoundingClientRect(),Fe=Qs(be,We);q({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),Y.current=requestAnimationFrame(()=>{q({enabled:!0,dx:Fe.dx,dy:Fe.dy,scale:Fe.scale,animate:!0}),Y.current=null})})}),G.current&&clearTimeout(G.current),G.current=setTimeout(Te,Ar+80);return}q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),G.current&&clearTimeout(G.current),G.current=setTimeout(Te,Ot+40)},[Te,ie,te]);s.useEffect(()=>(e?(G.current&&clearTimeout(G.current),I.current&&(clearTimeout(I.current),I.current=null),B.current=!1,de.current=!1,ue.current=Nu(l),L.current=ue.current!=null?a??S:null,E(!0),H(!1),ue.current?q({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(L.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{H(!0),q({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):A&&De(),()=>{G.current&&clearTimeout(G.current),Y.current!=null&&cancelAnimationFrame(Y.current)}),[e]);const ft=s.useCallback(()=>{if(!e||B.current||de.current)return;const be=ue.current,ge=ae.current;if(!be||!ge){be||(H(!0),de.current=!0);return}const He=ge.getBoundingClientRect();if(He.width<2||He.height<2)return;de.current=!0;const We=Qs(be,He);q({enabled:!0,dx:We.dx,dy:We.dy,scale:We.scale,animate:!1}),Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{q({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),H(!0),Y.current=null,I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{q({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),I.current=null},Ar+20)})})},[e]);s.useLayoutEffect(()=>{!A||!e||!ue.current||de.current||ft()},[A,e,ft]),s.useEffect(()=>{!e||B.current||L.current!=null&&L.current!==te&&q(be=>be.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:be)},[e,te]),s.useEffect(()=>{if(!e)return;const be=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=be}},[e]),s.useEffect(()=>{e&&ie()},[e,te,ie]),s.useEffect(()=>{a!==void 0&&x(a)},[a]),s.useEffect(()=>{if(!e){$.current=te,O({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const be=$.current;if(be===te)return;$.current=te;const ge=n.length;let He=1;if(ge>1){const We=(be+1)%ge===te,Fe=(be-1+ge)%ge===te;Fe&&!We?He=-1:We&&!Fe?He=1:He=te>be?1:-1}return U.current!=null&&(cancelAnimationFrame(U.current),U.current=null),O({opacity:0,x:He*56,scale:.94,blur:8,animate:!1}),U.current=requestAnimationFrame(()=>{U.current=requestAnimationFrame(()=>{O({opacity:1,x:0,scale:1,blur:0,animate:!0}),U.current=null})}),()=>{U.current!=null&&(cancelAnimationFrame(U.current),U.current=null)}},[e,te,n.length]);const Ct=C<=c+.001&&Math.abs(P.x)<.5&&Math.abs(P.y)<.5,nt=s.useCallback((be,ge,He)=>{w(We=>{const Fe=sn(be,c,T);if(Math.abs(Fe-We)<1e-4)return We;const bt=Fe/We,ct=Fe<We;return Fe<=c+.001?(V({x:0,y:0}),c):(V(qe=>{let Ye=qe;if(typeof ge=="number"&&typeof He=="number"&&R.current&&!ct){const dt=R.current.getBoundingClientRect(),mt=ge-dt.left-dt.width/2,mr=He-dt.top-dt.height/2;Ye={x:mt-(mt-qe.x)*bt,y:mr-(mr-qe.y)*bt}}else if(ct){Ye={x:qe.x*bt,y:qe.y*bt};const dt=Math.min(1,(We-Fe)/Math.max(.01,We-c));Ye={x:Ye.x*(1-dt*.65),y:Ye.y*(1-dt*.65)}}else Ye={x:qe.x*bt,y:qe.y*bt};return he(Ye,Fe)}),Fe)})},[he,c,T]),st=s.useCallback(()=>{nt(C*d)},[nt,C,d]),ce=s.useCallback(()=>{const be=Math.max(c,C/d);if(be<=c+.001){ie();return}w(be),V({x:0,y:0})},[c,ie,C,d]);s.useEffect(()=>{if(!e)return;const be=ge=>{if(ge.key==="Escape"&&m){ge.preventDefault(),r();return}ge.key==="ArrowLeft"&&y?(ge.preventDefault(),fe(te-1)):ge.key==="ArrowRight"&&y?(ge.preventDefault(),fe(te+1)):ge.key==="+"||ge.key==="="?(ge.preventDefault(),nt(C*d)):ge.key==="-"||ge.key==="_"?(ge.preventDefault(),ce()):ge.key==="0"&&(ge.preventDefault(),ie())};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[nt,m,y,r,e,ie,te,C,fe,ce,d]);const Se=be=>{be.preventDefault();const ge=be.deltaY>0?1/d:d;nt(C*ge,be.clientX,be.clientY)},re=be=>{C<=c+.001||(be.currentTarget.setPointerCapture(be.pointerId),J(!0),oe.current={pointerId:be.pointerId,startX:be.clientX,startY:be.clientY,originX:P.x,originY:P.y})},Le=be=>{const ge=oe.current;!ge||ge.pointerId!==be.pointerId||V(he({x:ge.originX+(be.clientX-ge.startX),y:ge.originY+(be.clientY-ge.startY)},C))},Oe=be=>{var ge;((ge=oe.current)==null?void 0:ge.pointerId)===be.pointerId&&(oe.current=null,J(!1))},Ve=be=>{if(be.stopPropagation(),C>c+.05){ie();return}nt(Math.min(T,3),be.clientX,be.clientY)},je=be=>{if(be.touches.length!==2)return;J(!0);const[ge,He]=[be.touches[0],be.touches[1]],We=Math.hypot(ge.clientX-He.clientX,ge.clientY-He.clientY);N.current={distance:We,scale:C}},Be=be=>{if(be.touches.length!==2||!N.current)return;be.preventDefault();const[ge,He]=[be.touches[0],be.touches[1]],We=Math.hypot(ge.clientX-He.clientX,ge.clientY-He.clientY),Fe=(ge.clientX+He.clientX)/2,bt=(ge.clientY+He.clientY)/2,ct=N.current.scale*(We/Math.max(1,N.current.distance));nt(ct,Fe,bt)},et=()=>{N.current=null,J(!1)};if(!A||!j)return null;const ot=K.enabled,Ht=K.animate?`transform ${Ar}ms ${gu}`:"none";return pt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:k},role:"dialog","aria-modal":"true","aria-label":v,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:M?1:0,transition:`opacity ${ot?Ar:Ot}ms ${zt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:R,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:ee?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:ot||M?1:0,transform:ot||M?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:ot?"none":`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},onClick:be=>{be.target===be.currentTarget&&u&&r()},onWheel:Se,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:K.enabled?`translate3d(${K.dx}px, ${K.dy}px, 0) scale(${K.scale})`:void 0,transformOrigin:"center center",transition:K.enabled?Ht:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:X.opacity,filter:X.blur?`blur(${X.blur}px)`:"blur(0px)",transform:`translate3d(${X.x}px, 0, 0) scale(${X.scale})`,transition:X.animate?[`opacity ${so}ms ${lo}`,`transform ${so}ms ${lo}`,`filter ${so}ms ${lo}`].join(", "):"none"},children:t.jsx("div",{ref:ae,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:C>c+.001?"grab":"zoom-in",transform:`translate3d(${P.x}px, ${P.y}px, 0) scale(${C})`,transformOrigin:"center center",transition:le?"none":`transform 220ms ${pu}`},onClick:be=>be.stopPropagation(),onDoubleClick:Ve,onPointerDown:re,onPointerMove:Le,onPointerUp:Oe,onPointerCancel:Oe,onTouchStart:je,onTouchMove:Be,onTouchEnd:et,children:t.jsx("img",{src:j.src,alt:j.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:co,imageRendering:C>2.5?"pixelated":"auto"},onLoad:()=>{ft()}},j.src+String(te))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:M?1:0,transform:M?"translateY(0)":"translateY(-6px)",transition:`opacity ${ot?Ar:Ot}ms ${zt}, transform ${ot?Ar:Ot}ms ${zt}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:io,children:[te+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(Lr,{label:"Alejar",onClick:ce,disabled:C<=c+.001,children:t.jsx(W.HiMinus,{className:"h-5 w-5"})}),t.jsx(Lr,{label:"Restablecer tamaño",onClick:ie,disabled:Ct,children:t.jsx(W.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Lr,{label:"Acercar",onClick:st,disabled:C>=T-.001,children:t.jsx(W.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Lr,{label:"Cerrar",onClick:r,children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),y?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:M?1:0,transform:M?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},children:t.jsx(Lr,{label:"Anterior",size:"lg",onClick:()=>fe(te-1),disabled:!p&&te<=0,children:t.jsx(W.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:M?1:0,transform:M?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ot}ms ${zt}, transform ${Ot}ms ${zt}`},children:t.jsx(Lr,{label:"Siguiente",size:"lg",onClick:()=>fe(te+1),disabled:!p&&te>=n.length-1,children:t.jsx(W.HiChevronRight,{className:"h-6 w-6"})})})]}):null,ee?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((be,ge)=>{const He=ge===te;return t.jsx("button",{type:"button",role:"tab","aria-selected":He,"aria-label":be.alt||`Imagen ${ge+1}`,onClick:We=>{We.stopPropagation(),fe(ge)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:co,opacity:He?1:.42,transition:`opacity 180ms ${zt}`},children:t.jsx("img",{src:be.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:co}})},`${be.src}-${ge}`)})})}):null]})]}),document.body)}function ku({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,b]=s.useState(0),[f,p]=s.useState([]),[g,k]=s.useState(null),v=s.useCallback((E,M,H)=>{p(E),k(H??null),b(M),u(!0)},[]),A=s.useCallback(E=>{Zs(E,v)},[v]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:A,children:e}),t.jsx(Js,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:g,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Rs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function el(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function uo(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Su(e,r){if(!r)return!0;const n=uo(r);return uo(e.label).includes(n)||!!(e.sublabel&&uo(e.sublabel).includes(n))}function Eu({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:p=!0,emptyText:g="Sin resultados",clearLabel:k="Limpiar seleccion",pruneMissingValues:v=!0}){const[A,E]=s.useState(!1),[M,H]=s.useState(""),[S,x]=s.useState(0),[C,w]=s.useState(!1),[P,V]=s.useState({}),X=s.useRef(null),O=s.useRef(null),K=s.useRef(null),q=s.useRef(null),le=u&&n.length>=m,J=s.useMemo(()=>new Set(e),[e]),G=s.useMemo(()=>{const y=new Map;for(const T of n)y.set(T.value,T);return y},[n]),U=s.useMemo(()=>{const y=[];for(const T of e){const ee=G.get(T);ee&&y.push(ee)}return y},[G,e]),Y=b==="all"?U.length:b,ue=U.slice(0,Y),L=Math.max(0,U.length-ue.length),B=p&&U.length>1,de=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[U.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:U.map(y=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[y.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:y.label}),y.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:y.sublabel}):null]},y.value))})]}),I=s.useMemo(()=>{const y=M.trim();return!le||!y?n:n.filter(T=>Su(T,y))},[n,M,le]),oe=s.useCallback(()=>{const y=X.current;if(!y)return;const T=y.getBoundingClientRect(),ee=le?304:244,fe=window.innerHeight-T.bottom,ie=fe<ee&&T.top>fe;V({position:"fixed",left:T.left,top:ie?void 0:T.bottom+4,bottom:ie?window.innerHeight-T.top+4:void 0,width:Math.max(T.width,240),zIndex:9999})},[le]),N=s.useCallback(y=>{el(e,y)||r(y)},[r,e]),R=s.useCallback(y=>{const T=G.get(y);if(T!=null&&T.disabled)return;const ee=J.has(y)?e.filter(fe=>fe!==y):[...e,y];N(ee)},[N,G,e,J]),ae=s.useCallback(()=>N([]),[N]),$=s.useCallback(()=>{E(!1),H(""),x(0)},[]);s.useEffect(()=>w(!0),[]);const ne=s.useMemo(()=>n.map(y=>y.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const y=new Set(n.map(ee=>ee.value)),T=e.filter(ee=>y.has(ee));el(e,T)||r(T)},[ne]),s.useEffect(()=>{if(!A)return;function y(T){var fe,ie;const ee=T.target;!((fe=X.current)!=null&&fe.contains(ee))&&!((ie=O.current)!=null&&ie.contains(ee))&&$()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[$,A]),s.useEffect(()=>{A&&(x(0),oe(),le&&setTimeout(()=>{var y;return(y=K.current)==null?void 0:y.focus()},0))},[A,le,oe]),s.useEffect(()=>{if(A)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[A,oe]),s.useEffect(()=>{if(I.length===0){x(0);return}x(y=>Math.min(y,I.length-1))},[I.length]),s.useEffect(()=>{if(S<0||!q.current)return;const y=q.current.children[S];y==null||y.scrollIntoView({block:"nearest"})},[S]);function te(y){if(!o){if(!A){(y.key==="Enter"||y.key===" "||y.key==="ArrowDown")&&(y.preventDefault(),E(!0));return}if(y.key==="Escape"){y.preventDefault(),$();return}if(y.key==="ArrowDown"){if(y.preventDefault(),I.length===0)return;x(T=>Math.min(T+1,I.length-1));return}if(y.key==="ArrowUp"){y.preventDefault(),x(T=>Math.max(T-1,0));return}if(y.key==="Enter"&&I[S]&&!I[S].disabled){y.preventDefault(),R(I[S].value);return}y.key==="Backspace"&&!M&&e.length&&(y.preventDefault(),N(e.slice(0,-1)))}}const j=t.jsxs("div",{ref:O,className:"overflow-hidden rounded-xl shadow-xl",style:{...P,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[le&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:K,value:M,onChange:y=>{H(y.target.value),x(0)},onKeyDown:y=>{(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter"||y.key==="Escape")&&(y.stopPropagation(),te(y))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),M&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:y=>{y.preventDefault(),H(""),x(0)},children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[t.jsxs("span",{children:[U.length," seleccionados",e.length>U.length?` (${e.length-U.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:k})]}),t.jsxs("ul",{ref:q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:le?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[I.map((y,T)=>{const ee=T===S,fe=J.has(y.value);return t.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:ie=>{ie.preventDefault(),!y.disabled&&R(y.value)},onMouseEnter:()=>!y.disabled&&x(T),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:ee?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:y.disabled?"var(--text-muted)":"var(--text-main)",cursor:y.disabled?"not-allowed":"pointer",opacity:y.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:fe?"var(--primary)":"var(--border)",background:fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:fe&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),y.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Vt,{className:"min-w-0 flex-1",children:y.label}),y.sublabel&&t.jsx(Vt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:y.sublabel})]}),y.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:y.badge})]},y.value)}),I.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:g})]})]});return t.jsxs("div",{ref:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:te,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(A?$():E(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Rs(c),padding:Rs(d),background:"var(--bg-input)",color:U.length?"var(--text-main)":"var(--text-muted)",border:A?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":A,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ue.length?(()=>{const y=t.jsxs(t.Fragment,{children:[ue.map(T=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[T.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:T.color}}),f?t.jsx(Vt,{className:"min-w-0 flex-1",children:T.label}):t.jsx("span",{className:"break-words",children:T.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${T.label}`,onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation(),R(T.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"h-3 w-3"})})]},T.value)),L>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},"aria-label":`${L} seleccionados más`,children:["+",L]})]});return B?t.jsx(Ft,{as:"span",content:de,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:y}):y})():t.jsx("span",{className:"truncate",children:a})}),U.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":k,onMouseDown:y=>{y.preventDefault(),y.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(W.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:A?"rotate(180deg)":"rotate(0deg)"}})]}),A&&C&&pt.createPortal(j,document.body)]})}function Cu({inputMode:e="decimal",...r}){return t.jsx(oo,{...r,type:"number",inputMode:e})}function Mu(e,r,n){const a=[],o=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),o>2&&a.push("...");for(let i=o;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function Tu({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:o=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=Mu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ge,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(W.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(Ge,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})]})}const tl=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function rl(e){return e==null?"":String(e)}function jn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function $u(e){return typeof e=="number"?`${e}px`:e}function Au({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:p,countryCodePlaceholder:g="Codigo",countryCodeClassName:k="",countryCodeWidth:v=84,onPhoneValueChange:A,label:E,containerClassName:M="",helperText:H,helperDisplay:S="inline",labelAction:x,className:C="",required:w,disabled:P,floatingLabel:V,showPasswordToggle:X,nativeValidation:O,errorTooltipLabel:K="Error de validacion",...q}){var T;const[le,J]=s.useState(()=>rl(c)),[G,U]=s.useState(()=>jn(m)),Y=s.useMemo(()=>{const ee=p??tl,fe=f==null?void 0:f.map(jn);return fe!=null&&fe.length?ee.filter(ie=>fe.includes(ie.value)):ee},[f,p]),ue=((T=Y[0])==null?void 0:T.value)??"+1",L=Y.some(ee=>ee.value===jn(u??G))?jn(u??G):ue,B=i!==void 0?rl(i):le,de=`${L} ${B}`.trim(),I=n&&B.length>0&&!no(de)?a:void 0,oe=l??I,N=!!oe,R=N&&o!=="tooltip",ae=N&&o!=="inline",$=!!H&&S==="tooltip"&&!R,ne=N?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",te=ee=>{const fe=ee.currentTarget.value;i===void 0&&J(fe),A==null||A(fe,{countryCode:L,nationalNumber:fe,fullNumber:`${L} ${fe}`.trim()}),d==null||d(ee)},j=ee=>{u===void 0&&U(ee),b==null||b(ee),A==null||A(B,{countryCode:ee,nationalNumber:B,fullNumber:`${ee} ${B}`.trim()})},y=ae?t.jsx(Ft,{as:"span",content:oe,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:t.jsx("span",{tabIndex:0,role:"img","aria-label":K,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Xs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${M}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:E}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),$?t.jsx(Tr,{content:H}):null,x&&t.jsx("span",{className:"ml-auto normal-case",children:x})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${ne}`,children:[t.jsx(ur,{value:L,onChange:j,options:Y,placeholder:g,disabled:P,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:$u(v)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...q,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:P,required:void 0,"aria-label":q["aria-label"]??(typeof E=="string"?E:void 0),"aria-invalid":N||q["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${ae?"pr-10":""} ${C}`,onChange:te}),y]})]}),t.jsx($r,{error:R?oe:void 0,helperText:H,helperDisplay:S})]})}function Lu({value:e,onChange:r,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[o&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:o}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Du=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),qn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Dr=12,Un=8,fo=(e,r,n)=>{const a=Yn(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},nl=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Dr?null:fo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Dr)return null;const o=Array.from(a.rows).indexOf(n);return fo(a,o+1,e)},Ou=(e,r)=>{var o;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((o=e.tBodies[0])==null?void 0:o.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},al=(e,r)=>Yn(e)>=Un?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),Hu=(e,r)=>Yn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),ol=e=>{e.querySelectorAll(".rich-table-row-active").forEach(r=>{r.classList.remove("rich-table-row-active")}),e.querySelectorAll(".rich-table-col-active").forEach(r=>{r.classList.remove("rich-table-col-active")})},sl=(e,r,n)=>{ol(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},Iu=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},Vn=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},ll=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},Bu=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?nl(r,n):bo(r);return l&&Xn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Ou(r,n):!1;case"table-col-add":return Number.isFinite(a)?al(r,a):zu(r);case"table-col-del":return Number.isFinite(a)?Hu(r,a):!1;default:return!1}},Yn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Fu=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},il=e=>(e==null?void 0:e.closest("table"))??null,cl=e=>{if(!e)return null;const r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(r==null?void 0:r.closest("td, th"))??null},Pu=e=>Array.from(e.querySelectorAll("th, td")),dl=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),o=e.closest("tr");return!o||o!==a[a.length-1]?!1:e===o.cells[o.cells.length-1]},_u=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},Xn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},bo=e=>{const r=Fu(e);if(r.length>=Dr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return fo(a,0,e)}return nl(e,Array.from(e.rows).indexOf(n))},zu=e=>{const r=Yn(e)-1;return r<0?!1:al(e,r)},mo=e=>{ll(e)},Wu=(e,r,n)=>{const a=qn(e,1,Dr),o=qn(r,1,Un),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},ul=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',ln=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),fl=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),ju=e=>e.replace(/[<>]/g,"").toLowerCase(),qu=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),Uu=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Vu=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},Kn=(e,r)=>r.test(e),Yu=e=>Kn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),Xu=e=>Kn(e,/font-style\s*:\s*italic/i),Ku=e=>Kn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),Gu=e=>Kn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Gn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},Zn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Zu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},bl=e=>{const r=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(r)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},Qu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(Uu,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Ju=e=>{const r=Array.from(e.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));r.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),r.forEach(n=>{const a=n.getAttribute("style")??"";a&&(Yu(a)&&Gn(n,"strong"),Xu(a)&&Gn(n,"em"),Ku(a)&&Gn(n,"u"),Gu(a)&&Gn(n,"s"))})},Ru=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Zu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=bl(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(bl(u)!==o)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(o);c.insertBefore(d,a),l.forEach(u=>{Qu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},ef=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,tf=e=>{const r=Vu(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),o=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Ju(o),Ru(o);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){Zn(d),c.forEach(l);return}if(!qu.has(u)){Zn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=ef(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Du.has(u)){Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase();if(u==="td"||u==="th"){["colspan","rowspan"].includes(f)||d.removeAttribute(b.name);return}d.removeAttribute(b.name)}),u==="table"&&d.classList.add("rich-table"),c.forEach(l);return}if(Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase(),p=b.value;if(f.startsWith("on")||f==="style"||f==="class"){d.removeAttribute(b.name);return}if(f==="lang"||f.startsWith("data-")||f.startsWith("mso-")){d.removeAttribute(b.name);return}if((f==="href"||f==="src")&&/^\s*javascript:/i.test(p)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&f!=="href"&&f!=="src"&&f!=="alt"&&(["href","src","alt","target","rel"].includes(f)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){Zn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){Zn(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),o.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),o.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},ho=e=>ln(e).replace(/\r\n?/g,`
|
|
25
|
+
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),rf=e=>new RegExp("\\p{L}","u").test(e),po=(e,r)=>{const n=e.trim();return!n||!rf(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===fl(n)},ml=e=>{const r=a=>{var o,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(o=a.parentNode)==null||o.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",ul())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const o=a.src;a.src="",a.src=o}});const n=a=>{const o=a.target;o.tagName==="IMG"&&r(o)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function hl({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full"}){const i=s.useId(),c=o||i,d=s.useCallback(()=>document,[]),u=s.useRef(null),m=s.useRef(null),b=s.useRef(new Map),f=s.useRef(null),p=s.useRef(!1),g=s.useRef(e??""),k=s.useRef(r),v=s.useRef(()=>{}),A=s.useRef(!1),[E,M]=s.useState(()=>!e||e.trim()===""),[H,S]=s.useState(new Set),[x,C]=s.useState(null),[w,P]=s.useState(""),[V,X]=s.useState(""),[O,K]=s.useState(""),[q,le]=s.useState(""),[J,G]=s.useState(3),[U,Y]=s.useState(3),[ue,L]=s.useState(!0),[B,de]=s.useState(!1),[I,oe]=s.useState(l==="full"),[N,R]=s.useState(null),[ae,$]=s.useState(null),ne=s.useRef(null),te=s.useRef(!1),j=s.useRef(null),y=s.useCallback(()=>p.current?m.current:u.current,[]);s.useEffect(()=>{k.current=r},[r]);const T=s.useCallback(()=>{const z=window.getSelection(),Z=y();if(!z||!Z||z.rangeCount===0||z.isCollapsed)return"";const me=z.getRangeAt(0);return!Z.contains(me.startContainer)||!Z.contains(me.endContainer)?"":z.toString()},[y]);s.useEffect(()=>{const z=e??"";if(A.current&&z===g.current){A.current=!1,M(!z||z.trim()==="");return}A.current=!1,g.current=z;const Z=[u.current,m.current].filter(pe=>!!pe);Z.forEach(pe=>{pe.innerHTML!==z&&(pe.innerHTML=z)}),M(!z||z.trim()===""),Z.forEach(pe=>mo(pe));const me=Z.map(pe=>ml(pe));return()=>me.forEach(pe=>pe())},[e]),s.useEffect(()=>{var pe,Ee;p.current=B;let z,Z=0,me;if(B){const ye=u.current;ye&&(g.current=Vn(ye));const Pe=()=>{var Ze;const Ie=m.current;if(!Ie){Z=requestAnimationFrame(Pe);return}Ie.innerHTML!==g.current&&(Ie.innerHTML=g.current),z=ml(Ie),mo(Ie),M(((Ze=Ie.textContent)==null?void 0:Ze.trim())===""),me=setTimeout(()=>Ie.focus(),60)};Z=requestAnimationFrame(Pe)}else{const ye=m.current,Pe=u.current,Ie=ye?Vn(ye):g.current,Ze=g.current;g.current=Ie,Pe&&Pe.innerHTML!==Ie&&(Pe.innerHTML=Ie),Ie!==Ze&&k.current(Ie),M(((Ee=(pe=ye??Pe)==null?void 0:pe.textContent)==null?void 0:Ee.trim())==="")}return()=>{Z&&cancelAnimationFrame(Z),me&&clearTimeout(me),z==null||z()}},[B]);const ee=s.useCallback(()=>{const z=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Z=new Set;z.forEach(pe=>{try{d().queryCommandState(pe)&&Z.add(pe)}catch{return}});try{const pe=ju(d().queryCommandValue("formatBlock"));pe&&Z.add(`formatBlock:${pe}`)}catch{}const me=T();po(me,"uppercase")&&Z.add("__upper"),po(me,"lowercase")&&Z.add("__lower"),po(me,"capitalize")&&Z.add("__cap"),S(Z)},[T,d]),fe=()=>{var Z;const z=y();z&&(g.current=Vn(z),A.current=!0,k.current(g.current),M(((Z=z.textContent)==null?void 0:Z.trim())===""))};v.current=fe;const ie=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),ne.current&&(ol(ne.current),ne.current=null),te.current=!1,R(null),$(null)},[]),he=s.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null)},[]),Te=s.useCallback(()=>{he(),j.current=setTimeout(()=>{te.current||ie()},280)},[he,ie]);s.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const De=s.useCallback(z=>{const Z=ne.current;if(!Z||!Z.isConnected){ie();return}const me=(N==null?void 0:N.rowIndex)??(ae==null?void 0:ae.rowIndex)??-1,pe=(N==null?void 0:N.colIndex)??(ae==null?void 0:ae.colIndex)??-1;Bu(z,Z,me,pe,y()),ie(),v.current(),ee()},[y,ie,ee,ae,N]),ft=s.useCallback(z=>{if(ae)return;const Z=z.currentTarget,me=z.target;if(me.closest(".rich-table-action-bar, .rich-table-context-menu")){he();return}const pe=me.closest("td, th");if(!pe||!Z.contains(pe)){Te();return}const Ee=pe.closest("tr"),ye=pe.closest("table");if(!Ee||!ye||!Z.contains(ye)){Te();return}he(),ye.classList.add("rich-table"),ne.current=ye,sl(ye,Ee,pe.cellIndex),R(Iu(ye,Ee,pe))},[he,Te,ae]),Ct=s.useCallback(z=>{const Z=z.relatedTarget;if(Z instanceof Element&&(Z.closest(".rich-table-action-bar")||Z.closest(".rich-table-context-menu"))){he();return}Te()},[he,Te]),nt=s.useCallback(z=>{const Z=z.currentTarget,pe=z.target.closest("td, th");if(!pe||!Z.contains(pe))return;const Ee=pe.closest("tr"),ye=pe.closest("table");if(!Ee||!ye||!Z.contains(ye))return;z.preventDefault(),ye.classList.add("rich-table"),ne.current=ye;const Pe=Array.from(ye.rows).indexOf(Ee),Ie=pe.cellIndex;sl(ye,Ee,Ie),R(null),$({x:z.clientX,y:z.clientY,rowIndex:Pe,colIndex:Ie})},[]);s.useEffect(()=>{if(!N&&!ae)return;const z=()=>Te();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[Te,ae,N]),s.useEffect(()=>{if(!ae)return;const z=Z=>{const me=Z.target;me instanceof Element&&me.closest(".rich-table-context-menu")||$(null)};return window.addEventListener("mousedown",z),()=>window.removeEventListener("mousedown",z)},[ae]);const st=z=>{if(!z){const Z=u.current;Z&&(g.current=Vn(Z))}de(!z)},ce=(z,Z)=>{var me;(me=y())==null||me.focus(),d().execCommand(z,!1,Z),fe(),ee()},Se=z=>{ce("formatBlock",z)},re=()=>{var z;(z=y())==null||z.focus(),d().execCommand("insertHTML",!1,"<hr><p><br></p>"),fe(),ee()},Le=()=>{const z=window.getSelection();z&&z.rangeCount>0&&(f.current=z.getRangeAt(0).cloneRange())},Oe=()=>{const z=window.getSelection();z&&f.current&&(z.removeAllRanges(),z.addRange(f.current))},Ve=z=>{if(Le(),z==="link"){const Z=window.getSelection();X(Z&&!Z.isCollapsed?Z.toString():""),P("")}z==="image"&&(K(""),le("")),z==="table"&&(G(3),Y(3),L(!0)),C(z)},je=()=>{var pe;if(!w.trim())return;Oe(),(pe=y())==null||pe.focus();const z=window.getSelection(),me=(z&&!z.isCollapsed?z.toString():"")||V.trim()||w.trim();d().execCommand("insertHTML",!1,`<a href="${ln(w.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${ln(me)}</a>`),fe(),C(null)},Be=(z,Z="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${ln(z)}" alt="${ln(Z)}" class="rich-img" />${ul()}</span>`,et=()=>{var z;O.trim()&&(Oe(),(z=y())==null||z.focus(),d().execCommand("insertHTML",!1,Be(O.trim(),q.trim())),fe(),C(null))},ot=()=>{var z;Oe(),(z=y())==null||z.focus(),d().execCommand("insertHTML",!1,Wu(J,U,ue)),fe(),C(null)},Ht=(z,Z=1200,me=1200,pe=.72)=>new Promise((Ee,ye)=>{const Pe=new FileReader;Pe.onerror=ye,Pe.onload=Ie=>{var sr;const Ze=(sr=Ie.target)==null?void 0:sr.result,Qe=new Image;Qe.onerror=ye,Qe.onload=()=>{let{width:vt,height:Kt}=Qe;if(vt>Z||Kt>me){const Gt=Math.min(Z/vt,me/Kt);vt=Math.round(vt*Gt),Kt=Math.round(Kt*Gt)}const It=document.createElement("canvas");It.width=vt,It.height=Kt;const lr=It.getContext("2d");if(!lr){Ee(Ze);return}lr.drawImage(Qe,0,0,vt,Kt),Ee(It.toDataURL("image/jpeg",pe))},Qe.src=Ze},Pe.readAsDataURL(z)}),be=z=>{z.focus();const Z=window.getSelection();if(!Z||Z.rangeCount===0||!z.contains(Z.anchorNode)){const me=document.createRange();me.selectNodeContents(z),me.collapse(!1),Z==null||Z.removeAllRanges(),Z==null||Z.addRange(me)}},ge=s.useRef(()=>{});ge.current=z=>{const Z=y();Z&&(be(Z),d().execCommand("insertHTML",!1,z),mo(Z),Z.querySelectorAll("p").forEach(me=>{!(me.textContent??"").replace(/[\u00a0\s]+/g,"")&&!me.querySelector("img, hr, table")&&me.remove()}),fe(),ee())};const He=s.useRef(Ht);He.current=Ht;const We=s.useRef(Be);We.current=Be;const Fe=s.useCallback(z=>{if(!z||b.current.has(z))return;const Z=me=>{const pe=me.clipboardData;if(!pe)return;const Ee=pe.getData("text/html"),ye=pe.getData("text/plain");if(Ee||ye){me.preventDefault(),me.stopPropagation();try{const Qe=Ee?tf(Ee):ho(ye);if(!Qe){ye&&ge.current(ho(ye));return}ge.current(Qe)}catch{ye&&ge.current(ho(ye))}return}const Ie=Array.from(pe.items).find(Qe=>Qe.type.startsWith("image/"));if(!Ie)return;me.preventDefault(),me.stopPropagation();const Ze=Ie.getAsFile();Ze&&He.current(Ze).then(Qe=>{ge.current(We.current(Qe,"imagen"))})};z.addEventListener("paste",Z,!0),b.current.set(z,()=>{z.removeEventListener("paste",Z,!0),b.current.delete(z)})},[]),bt=s.useCallback(z=>{var me;const Z=u.current;Z&&Z!==z&&((me=b.current.get(Z))==null||me()),u.current=z,z&&Fe(z)},[Fe]),ct=s.useCallback(z=>{var me;const Z=m.current;Z&&Z!==z&&((me=b.current.get(Z))==null||me()),m.current=z,z&&Fe(z)},[Fe]);s.useEffect(()=>{const z=b.current;return()=>{z.forEach(Z=>Z()),z.clear()}},[]);const qe=z=>{const Z=window.getSelection(),me=y();if(!Z||!me||Z.rangeCount===0||Z.isCollapsed)return;const pe=Z.getRangeAt(0);if(!me.contains(pe.startContainer)||!me.contains(pe.endContainer))return;const Ee=pe.toString();if(!Ee)return;let ye=Ee;z==="uppercase"?ye=Ee.toLocaleUpperCase():z==="lowercase"?ye=Ee.toLocaleLowerCase():ye=fl(Ee),pe.deleteContents();const Pe=document.createTextNode(ye);pe.insertNode(Pe);const Ie=document.createRange();Ie.setStart(Pe,0),Ie.setEnd(Pe,ye.length),Z.removeAllRanges(),Z.addRange(Ie),f.current=Ie.cloneRange(),fe(),ee()},Ye=()=>{Le(),ee()},dt=()=>{const z=y();z&&ll(z),fe(),ee()},mt=()=>{requestAnimationFrame(()=>{var z;(z=y())==null||z.focus()})},mr=z=>{var Z,me;if((z.metaKey||z.ctrlKey)&&z.key==="Enter"){if(z.preventDefault(),z.stopPropagation(),z.repeat)return;(Z=y())==null||Z.focus(),d().execCommand("insertLineBreak",!1)||d().execCommand("insertHTML",!1,"<br>"),fe(),ee();return}if(z.key==="Tab"){const pe=window.getSelection(),Ee=cl((pe==null?void 0:pe.anchorNode)??null),ye=y(),Pe=il(Ee);if(Ee&&Pe&&(ye!=null&&ye.contains(Ee))){z.preventDefault();const Ie=Pu(Pe),Ze=Ie.indexOf(Ee),Qe=Ze>=0?Ie[Ze+1]:null;if(Qe)Xn(Qe,ye,!0);else if(dl(Ee,Pe)){const sr=bo(Pe);sr&&Xn(sr,ye,!0)}fe(),ee();return}z.preventDefault(),(me=y())==null||me.focus(),d().execCommand("insertText",!1," "),fe(),ee();return}if(z.key==="Enter"&&!z.shiftKey&&!(z.metaKey||z.ctrlKey)){const pe=window.getSelection(),Ee=cl((pe==null?void 0:pe.anchorNode)??null),ye=y(),Pe=il(Ee);if(Ee&&Pe&&(ye!=null&&ye.contains(Ee))&&dl(Ee,Pe)&&_u(Ee)){z.preventDefault();const Ie=bo(Pe);Ie&&Xn(Ie,ye,!0),fe(),ee();return}}if(z.key==="Escape"){if(ae){$(null);return}if(x){C(null);return}if(p.current){de(!1);return}}x||(z.ctrlKey||z.metaKey)&&(z.key==="b"&&(z.preventDefault(),ce("bold")),z.key==="i"&&(z.preventDefault(),ce("italic")),z.key==="u"&&(z.preventDefault(),ce("underline")),z.key==="k"&&(z.preventDefault(),Ve("link")))},ut=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ze=(z,Z,me,pe,Ee)=>{const ye=Ee??(H.has(me)||me==="__link"&&x==="link"||me==="__img"&&x==="image"||me==="__table"&&x==="table");return t.jsx("button",{type:"button",title:Z,tabIndex:-1,onFocus:mt,onMouseDown:Pe=>{Pe.preventDefault(),pe?pe():ce(me)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ye?"var(--primary)":"var(--text-secondary)",background:ye?"rgba(59,130,246,0.12)":"transparent"},children:z},me)},vn=z=>{const Z=z.target;if(Z.closest("[data-action='delete-img']")){z.preventDefault();const me=Z.closest(".rich-img-wrap");me&&(me.remove(),fe())}},ba=()=>{he(),te.current=!0},ht=()=>{te.current=!1,Te()},Mt=(z,Z,me,pe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${pe?" rich-table-action-btn--danger":""}`,title:z,"aria-label":z,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),De(me)},children:Z}),Tt=()=>typeof document>"u"||!N&&!ae?null:pt.createPortal(t.jsxs(t.Fragment,{children:[N&&!ae&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:N.bar.x,top:N.bar.y},onMouseEnter:ba,onMouseLeave:ht,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",N.rowIndex+1," · Col ",N.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Mt("Añadir fila abajo","+","table-row-add"),Mt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Mt("Añadir columna a la derecha","+","table-col-add"),Mt("Eliminar columna","−","table-col-del")]}),Mt("Eliminar tabla","Eliminar","table-delete",!0)]}),ae&&t.jsx("div",{className:"rich-table-context-menu",style:{left:ae.x,top:ae.y},onMouseDown:z=>z.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([z,Z])=>t.jsx("button",{type:"button",onMouseDown:me=>{me.preventDefault(),De(Z)},children:z},Z))})]}),document.body),or=z=>t.jsxs(t.Fragment,{children:[x==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:w,onChange:Z=>P(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),je()),Z.key==="Escape"&&C(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:V,onChange:Z=>X(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),je()),Z.key==="Escape"&&C(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:je,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:z},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Dr,value:J,onChange:Z=>G(qn(Number(Z.target.value),1,Dr)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ot()),Z.key==="Escape"&&C(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:Un,value:U,onChange:Z=>Y(qn(Number(Z.target.value),1,Un)),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),ot()),Z.key==="Escape"&&C(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:ue,onChange:Z=>L(Z.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:ot,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),x==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:O,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),et()),Z.key==="Escape"&&C(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:q,onChange:Z=>le(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),et()),Z.key==="Escape"&&C(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:et,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),jr=(z,Z)=>{const me=l==="compact",pe=!me||I||z;return t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:Z},"data-toolbar-variant":l,children:[me&&!z&&t.jsxs("button",{type:"button",title:I?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),oe(ye=>!ye)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:I?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[I?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"}),I?"Ocultar herramientas":"Herramientas"]}),pe&&t.jsxs(t.Fragment,{children:[ze(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ze(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ze(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ze(t.jsx(W.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ze(t.jsx(W.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ze(t.jsx(W.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Ve("link")),ut(),ze(t.jsx(W.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ze(t.jsx(W.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),ut(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Se("p"),H.has("formatBlock:p")||H.has("formatBlock:div")),ze(t.jsx(W.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Se("h2"),H.has("formatBlock:h2")),ze(t.jsx(W.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Se("h3"),H.has("formatBlock:h3")),ze(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Se("blockquote"),H.has("formatBlock:blockquote")),ut(),ze(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),ut(),ze(t.jsx(W.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ze(t.jsx(W.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),ut(),ze(t.jsx(W.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ze(t.jsx(W.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ze(t.jsx(W.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ze(t.jsx(W.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),ut(),ze(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>qe("uppercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>qe("lowercase")),ze(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>qe("capitalize")),ut(),ze(t.jsx(W.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ze(t.jsx(W.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Ve("image")),ze(t.jsx(W.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Ve("table")),ze(t.jsx(W.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",re),ut(),ze(t.jsx(W.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ze(t.jsx(W.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Se("p"))]}),ut(),t.jsx("button",{type:"button",title:z?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:Ee=>{Ee.preventDefault(),st(z)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:z?t.jsx(W.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(W.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[Tt(),t.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{ref:bt,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:mr,onKeyUp:Ye,onSelect:Ye,onMouseUp:Ye,onMouseMove:ft,onMouseLeave:Ct,onContextMenu:nt,onMouseDown:vn,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${E?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),or("var(--bg-input)"),jr(!1,"var(--bg-input)")]}),t.jsxs(Za,{open:B,onClose:()=>de(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[t.jsx("div",{ref:ct,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":c,onInput:dt,onKeyDown:mr,onKeyUp:Ye,onSelect:Ye,onMouseUp:Ye,onMouseMove:ft,onMouseLeave:Ct,onContextMenu:nt,onMouseDown:vn,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${E?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),or("var(--bg-input)"),jr(!0,"var(--bg-input)")]})]})}const pl="[a-zA-Z0-9._@-]+",go=new RegExp(`@(${pl})`,"g"),nf=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
|
|
26
|
+
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function gl(e,r){if(r<=0)return!0;const n=e[r-1]??"";return cn.has(n)}function vl(e,r,n){var a;if(r<0||r>e.length)return null;for(let o=r-1;o>=0;o-=1){if(e[o]!=="@"){const c=e[o]??"";if(cn.has(c)||!nf.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,o)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(o):gl(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${pl}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function yl(e,r){var a;const n=Or(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function xl(e,r){if(r<=0)return!0;const n=Or(e,r);if(!n){const o=So(e);return gl(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return cn.has(o)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const o=a.textContent??"";if(o.length===0){a=a.previousSibling;continue}return cn.has(o[o.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const o=a;if(o.classList.contains("mention-chip")||o.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(o.tagName))return!0;const l=o.textContent??"";if(l.length===0){a=a.previousSibling;continue}return cn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function vo(e,r){const n=So(e);return vl(n,r,{isTriggerBoundary:a=>xl(e,a),isInsideExistingMention:a=>yl(e,a)})}function yo(e){return e.toLowerCase().trim()}function wl(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
|
|
27
27
|
`).replace(/<\/(p|div|li)>/gi,`
|
|
28
|
-
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function
|
|
29
|
-
`,(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":!1),u=f=>{const
|
|
30
|
-
`)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const p=f;if(p.tagName==="BR")return i(p,0),d(p.nextSibling??void 0)==="matched";const E=Array.from(f.childNodes);for(let v=0;v<E.length;v+=1){const w=E[v],A=v>0&&w.nodeType===Node.ELEMENT_NODE&&yl(w,e);if(m(w,A))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],p=f>0&&g.nodeType===Node.ELEMENT_NODE&&yl(g,e);if(m(g,p))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),p=g;for(;p;)g=p,p=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:o}}function yo(e){return xo(e).plain}function Dr(e,r){return r<0?null:xo(e,{locatePlain:r}).locate??null}function Zn(e,r,n){return e!==r&&!e.contains(r)?-1:xo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function wl(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Dr(e,n),i=Dr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=gl({name:r.display,username:o}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",o.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${o}`;const b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),dn(e),vo(m);const g=c.defaultView,p=g==null?void 0:g.getSelection(),E=p!=null&&p.rangeCount?Zn(e,p.getRangeAt(0).startContainer,p.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:E>=0?E:n+u.length+1}}function Nl(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Dr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Qn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function kl(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 Sl(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function Or(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Jn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function El(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Jn(e)}function Cl(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function Ml(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Or(e),!0):!1}function Rn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let p=f;for(;p&&p.nodeType===Node.TEXT_NODE&&(p.textContent??"")==="";){const E=p;p=p[g],E.remove()}return p},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function Tl(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=kl(a.previousSibling,"prev");return Qn(c)&&(o===0||o===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o-1;for(;c>=0;){const d=i[c];if(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function $l(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=kl(a.nextSibling,"next");if(Qn(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o;for(;c<i.length;){const d=i[c];if(Qn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function wo(e){var o;const r=(o=e.ownerDocument.defaultView)==null?void 0:o.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const No=420,ea=6,Al=260,tf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Ll=4,rf={position:"relative"},nf={position:"fixed",zIndex:11050,minWidth:Al,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},Dl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function af(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function of(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Al-8)),n=window.innerHeight-e.bottom-ea-8,a=e.top-ea-8;return n<Math.min(No,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ea,maxHeight:Math.min(No,Math.max(120,a))}:{left:r,top:e.bottom+ea,maxHeight:Math.min(No,Math.max(120,n))}}function Ol({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m="",toolbarVariant:b="full"}){const f=s.useId().replace(/:/g,""),g=s.useRef(null),p=s.useRef(null),E=s.useRef(new Map),v=s.useRef(n);v.current=n;const w=s.useRef(null),A=s.useRef(0),C=s.useRef([]),H=s.useRef(null),[k,x]=s.useState(null),[M,N]=s.useState([]),[z,X]=s.useState(0),[K,D]=s.useState([]),[G,V]=s.useState(!1),[ne,J]=s.useState(!1);A.current=z,s.useEffect(()=>{J(!0)},[]);const R=(k==null?void 0:k.query)??null;s.useEffect(()=>{if(R===null){N([]);return}const S=R.trim(),ee=`${m}|${S.toLowerCase()||"*"}`,_=E.current.get(ee);if(_){N(_),V(!1),X(0);return}const I=new AbortController;V(!0);const de=window.setTimeout(()=>{(async()=>{try{const re=await v.current(S,{signal:I.signal,limit:c});if(I.signal.aborted)return;const F=Array.isArray(re)?re:[];E.current.set(ee,F),N(F),X(0)}catch{I.signal.aborted||N([])}finally{I.signal.aborted||V(!1)}})()},d);return()=>{I.abort(),window.clearTimeout(de)}},[R,c,d,m]);const U=s.useRef(a);U.current=a,s.useEffect(()=>{var S;(S=U.current)==null||S.call(U,vl(K))},[K]);const Y=s.useCallback(()=>{const S=af(f);if(S.length===0)return null;const ee=window.getSelection();if(ee!=null&&ee.rangeCount){const I=ee.getRangeAt(0).startContainer;for(const de of S)if(de.contains(I))return de}const _=document.activeElement;for(const I of S)if(_===I||_&&I.contains(_))return I;for(const I of S)if(I.closest('[role="dialog"]'))return I;return S[0]??null},[f]),ce=s.useCallback(()=>{const S=Y(),ee=window.getSelection();if(!S||!ee||ee.rangeCount===0){x(null);return}const _=ee.getRangeAt(0);if(!S.contains(_.startContainer)){x(null);return}const I=Zn(S,_.startContainer,_.startOffset);if(I<0){x(null);return}const de=mo(S,I);if(!de){x(null);return}const re=_.getBoundingClientRect(),F=re.width===0&&re.height===0?(()=>{const T=document.createRange();return T.selectNodeContents(_.startContainer),T.collapse(!0),T.getBoundingClientRect()})():re;w.current={query:de.query,caretIndex:de.caretIndex,triggerIndex:de.triggerIndex};const y=of(F);x(T=>{const te={query:de.query,...y};return T&&T.query===te.query&&T.top===te.top&&T.bottom===te.bottom&&T.left===te.left&&T.maxHeight===te.maxHeight?T:te})},[Y]),L=s.useCallback(S=>{r(S),ce()},[r,ce]);s.useEffect(()=>{const S=ee=>{if(tf.has(ee.key))return;const _=Y(),I=ee.target;!_||!I||!_.contains(I)||ce()};return document.addEventListener("keyup",S,!0),()=>document.removeEventListener("keyup",S,!0)},[Y,ce]);const B=s.useCallback(S=>{const ee=Y();if(!ee)return;let _=-1;const I=window.getSelection();if(I&&I.rangeCount>0){const T=I.getRangeAt(0);ee.contains(T.startContainer)&&(_=Zn(ee,T.startContainer,T.startOffset))}if(_<0&&w.current&&(_=w.current.caretIndex),_<0)return;const de=mo(ee,_);if(!de)return;const re=wl(ee,{triggerIndex:de.triggerIndex,caretIndex:_,username:S.username,display:S.name,userId:S.userId});if(!re)return;dn(ee),ee.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const F={userId:S.userId,username:S.username,email:S.email??void 0,display:S.name??S.username};D(T=>{const te=new Map(T.map(fe=>[fe.userId,fe]));return te.set(F.userId,F),Array.from(te.values())}),x(null),w.current=null;const y=S.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const T=Y();if(!T)return;T.focus(),dn(T);const te=Array.from(T.querySelectorAll(".mention-chip")),fe=[...te].reverse().find(se=>se.getAttribute("data-username")===y)??te[te.length-1];if(fe){vo(fe);return}Nl(T,re.caretPlainOffset)})})},[Y]);s.useEffect(()=>{const S=new Set(po(e).map(ee=>ee.toLowerCase()));D(ee=>{const _=ee.filter(I=>S.has(I.username.toLowerCase()));return _.length===ee.length?ee:_})},[e]),s.useEffect(()=>{if(!k)return;const S=ee=>{const _=ee.target;if(!_||g.current&&g.current.contains(_)||p.current&&p.current.contains(_))return;const I=Y();I&&I.contains(_)||x(null)};return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[k,Y]);const le=s.useMemo(()=>M.slice(0,c),[M,c]);C.current=le,s.useEffect(()=>{if(!k)return;const S=ee=>{const _=Y(),I=ee.target;if(!_||!I||!_.contains(I))return;const de=C.current;if(!(de.length===0&&ee.key!=="Escape"))if(ee.key==="ArrowDown")ee.preventDefault(),ee.stopPropagation(),X(re=>(re+1)%Math.max(de.length,1));else if(ee.key==="ArrowUp")ee.preventDefault(),ee.stopPropagation(),X(re=>(re-1+de.length)%Math.max(de.length,1));else if(ee.key==="Enter"||ee.key==="Tab"){const re=de[A.current];re&&(ee.preventDefault(),ee.stopPropagation(),B(re))}else ee.key==="Escape"&&(ee.preventDefault(),ee.stopPropagation(),x(null))};return document.addEventListener("keydown",S,!0),()=>document.removeEventListener("keydown",S,!0)},[Y,B,k]),s.useEffect(()=>{const S=F=>{F.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},ee=F=>{const y=Y(),T=F.target;if(!y||!T||!y.contains(T))return;if((F.metaKey||F.ctrlKey)&&F.key.toLowerCase()==="a"){F.preventDefault(),F.stopPropagation(),y.focus(),El(y);return}if(F.key!=="Backspace"&&F.key!=="Delete")return;const te=window.getSelection();if(te&&!te.isCollapsed&&te.rangeCount>0){const he=te.getRangeAt(0);if(y.contains(he.commonAncestorContainer)&&wo(y).length>0&&Cl(he)){F.preventDefault(),F.stopPropagation(),Ml(y)&&S(y);return}}const fe=wo(y);if(fe.length>0){F.preventDefault(),F.stopPropagation();for(const he of fe)Rn(he);Or(y),S(y);return}if(F.key==="Backspace"){const he=Tl(y);if(!he)return;F.preventDefault(),F.stopPropagation(),Rn(he),Or(y),S(y);return}const se=$l(y);se&&(F.preventDefault(),F.stopPropagation(),Rn(se),Or(y),S(y))},_=F=>{const y=Y();if(!y)return;const T=F.target;if(!(T instanceof Element)||!y.contains(T))return;const te=T.closest(".mention-chip");if(!(te instanceof HTMLElement)||!y.contains(te)){H.current=null,Or(y);return}F.shiftKey||F.button!==0||(H.current={chip:te,x:F.clientX,y:F.clientY})},I=F=>{const y=H.current;if(!y)return;const T=Math.abs(F.clientX-y.x),te=Math.abs(F.clientY-y.y);(T>Ll||te>Ll)&&(H.current=null)},de=F=>{var se;const y=Y(),T=H.current;if(H.current=null,!y||!T)return;const te=F.target;if(!(te instanceof Element)||!y.contains(te)||!((se=te.closest(".mention-chip"))!=null&&se.isSameNode(T.chip)))return;const fe=window.getSelection();if(fe){if(!fe.isCollapsed){Jn(y);return}y.focus(),Sl(T.chip)}},re=()=>{const F=Y();if(!F)return;const y=window.getSelection();!y||y.rangeCount===0||!y.anchorNode||!F.contains(y.anchorNode)||!y.focusNode||!F.contains(y.focusNode)||Jn(F)};return document.addEventListener("keydown",ee,!0),document.addEventListener("mousedown",_,!0),document.addEventListener("mousemove",I,!0),document.addEventListener("mouseup",de,!0),document.addEventListener("selectionchange",re),()=>{document.removeEventListener("keydown",ee,!0),document.removeEventListener("mousedown",_,!0),document.removeEventListener("mousemove",I,!0),document.removeEventListener("mouseup",de,!0),document.removeEventListener("selectionchange",re)}},[Y]),s.useEffect(()=>{if(!k||!p.current)return;const S=p.current.querySelector(`[data-mention-index="${z}"]`);S==null||S.scrollIntoView({block:"nearest"})},[z,k]);const O=u?xl(e):e,ae=k&&ne?gt.createPortal(t.jsxs("ul",{ref:p,style:{...nf,left:k.left,top:k.top,bottom:k.bottom,maxHeight:k.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&le.length===0&&t.jsx("li",{style:Dl,children:"Buscando…"}),!G&&le.length===0&&t.jsx("li",{style:Dl,children:k.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${k.query}”`}),le.map((S,ee)=>{var _,I;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":ee,onMouseDown:de=>{de.preventDefault(),B(S)},onMouseEnter:()=>X(ee),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:ee===z?"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:((_=S.name)==null?void 0:_.trim())||`@${S.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(I=S.name)!=null&&I.trim()?`@${S.username}`:null,S.email].filter(Boolean).join(" · ")||`@${S.username}`})]})},S.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:rf,className:i,children:[t.jsx(dl,{value:O,onChange:L,placeholder:l,minHeight:o,instanceId:f,toolbarVariant:b}),ae]})}function sf({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}){return o?t.jsx(Ol,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}):t.jsx(dl,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function lf({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:o}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const cf={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)"}},df={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 uf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=cf[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 ${df[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 Hl={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)"}},ff={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"},bf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},mf={xs:148,sm:164,md:184},hf={xs:"px-2.5 py-1.5 text-xs",sm:"px-3 py-2 text-sm",md:"px-3.5 py-2.5 text-sm"};function pf({value:e,options:r,onChange:n,size:a="sm",disabled:o=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:b,optionClassName:f,spinnerClassName:g}){const[p,E]=s.useState(!1),[v,w]=s.useState(!1),[A,C]=s.useState(-1),[H,k]=s.useState({}),x=s.useRef(null),M=s.useRef(null),N=s.useRef(null),z=r.find(U=>U.value===e)??r[0],X={...z!=null&&z.tone?Hl[z.tone]:void 0,...z==null?void 0:z.style},K=o||l||r.length===0,D=U=>{i&&U.stopPropagation()},G=s.useCallback(()=>{E(!1),C(-1)},[]),V=s.useCallback(()=>{const U=x.current;if(!U)return;const Y=U.getBoundingClientRect(),ce=Math.max(Y.width,mf[a]),L=Math.min(Math.max(r.length,1)*38+12,260),B=window.innerHeight-Y.bottom,le=B<L&&Y.top>B,O=Math.min(Math.max(8,Y.left+Y.width/2-ce/2),window.innerWidth-ce-8);k({position:"fixed",left:O,top:le?void 0:Y.bottom+6,bottom:le?window.innerHeight-Y.top+6:void 0,width:ce,zIndex:9999})},[r.length,a]),ne=s.useCallback(U=>{U.disabled||(n(U.value),G())},[G,n]);s.useEffect(()=>w(!0),[]),s.useEffect(()=>{if(!p)return;V();const U=r.findIndex(Y=>Y.value===e);C(U>=0?U:0)},[p,r,V,e]),s.useEffect(()=>{if(!p)return;function U(Y){var L,B;const ce=Y.target;!((L=x.current)!=null&&L.contains(ce))&&!((B=M.current)!=null&&B.contains(ce))&&G()}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[G,p]),s.useEffect(()=>{if(p)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[p,V]),s.useEffect(()=>{if(A<0||!N.current)return;const U=N.current.children[A];U==null||U.scrollIntoView({block:"nearest"})},[A]);function J(U){if(!K){if(!p){["Enter"," ","ArrowDown","ArrowUp"].includes(U.key)&&(U.preventDefault(),E(!0));return}if(U.key==="Escape"){U.preventDefault(),G();return}if(U.key==="ArrowDown"){U.preventDefault(),C(Y=>Math.min(Y+1,r.length-1));return}if(U.key==="ArrowUp"){U.preventDefault(),C(Y=>Math.max(Y-1,0));return}if(U.key==="Enter"||U.key===" "){U.preventDefault();const Y=r[A];Y&&ne(Y)}}}const R=t.jsx("div",{ref:M,role:"listbox","aria-label":c,className:Qt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...H,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((U,Y)=>{const ce=U.value===e,L=Y===A,B={...U.tone?Hl[U.tone]:void 0,...U.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ce,disabled:U.disabled,onMouseEnter:()=>!U.disabled&&C(Y),onMouseDown:le=>{le.preventDefault(),ne(U)},className:Qt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",hf[a],ce?U.className:void 0,f),style:{...ce?B:void 0,background:ce?B.background??"color-mix(in srgb, var(--primary) 12%, transparent)":L?"var(--bg-hover)":"transparent",color:ce?B.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ce?t.jsx(j.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.label})]},U.value)})})});return t.jsxs("span",{ref:x,className:Qt("relative inline-flex shrink-0 items-center",u),onKeyDown:J,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:K,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":p,title:d,onClick:()=>!K&&E(U=>!U),className:Qt("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",ff[a],z==null?void 0:z.className,m),style:X,children:t.jsx("span",{className:"min-w-0 truncate",children:(z==null?void 0:z.label)??e})}),t.jsx(j.HiChevronDown,{"aria-hidden":"true",className:Qt("pointer-events-none absolute opacity-70 transition-transform",bf[a],p?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Qt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),p&&v&>.createPortal(R,document.body)]})}function gf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(p=>!p.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(p=>p.id===m)??u,f=p=>{p.disabled||a==null||a(p.id)},g=p=>{const E=e.filter(w=>!w.disabled);if(!E.length||!b)return;const v=E.findIndex(w=>w.id===b.id);(p.key==="ArrowRight"||p.key==="ArrowDown")&&(p.preventDefault(),f(E[(v+1)%E.length])),(p.key==="ArrowLeft"||p.key==="ArrowUp")&&(p.preventDefault(),f(E[(v-1+E.length)%E.length])),p.key==="Home"&&(p.preventDefault(),f(E[0])),p.key==="End"&&(p.preventDefault(),f(E[E.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:g,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(p=>{const E=p.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":E,"aria-controls":`${p.id}-panel`,id:`${p.id}-tab`,disabled:p.disabled,tabIndex:E?0:-1,onClick:()=>f(p),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:E?"var(--primary)":"var(--text-muted)",borderColor:E?"var(--primary)":"transparent",background:l==="pills"&&E?"var(--bg-card)":"transparent"},children:[p.icon&&t.jsx("span",{className:"shrink-0",children:p.icon}),t.jsx("span",{children:p.label}),p.badge&&t.jsx("span",{className:"shrink-0",children:p.badge})]},p.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function tr(...e){return e.filter(Boolean).join(" ")}function vf({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:p="",contentClassName:E="",footerClassName:v=""}){var _;const w=((_=e[0])==null?void 0:_.id)??"",[A,C]=s.useState(n??w),[H,k]=s.useState(o),x=r??A,M=a??H,N=s.useMemo(()=>new Set(M),[M]),z=Math.max(0,e.findIndex(I=>I.id===x)),X=e[z]??e[0],K=e.length<=1?100:z/(e.length-1)*100,D=I=>{a||k(I),i==null||i(I)},G=I=>{const de=e.find(re=>re.id===I);de&&(r||C(I),l==null||l(I,de))},V=I=>N.has(I),ne=I=>e.slice(0,I).find(de=>!de.optional&&!N.has(de.id)),J=I=>{const de=e[I];return!de||de.disabled?!1:I===z||d&&I<z?!0:!ne(I)},R=I=>{const de=e.findIndex(re=>re.id===I);return de>=0&&J(de)},U=I=>{const de=e.findIndex(re=>re.id===I);if(de<0)return!1;if(!J(de)){const re=ne(de);return re&&(c==null||c(e[de],re)),!1}return G(I),!0},Y=(I=X==null?void 0:X.id)=>{!I||N.has(I)||D([...M,I])},ce=(I=X==null?void 0:X.id)=>{if(!I)return;const de=e.findIndex(F=>F.id===I),re=M.filter(F=>{const y=e.findIndex(T=>T.id===F);return y>=0&&y<de});D(re),de>=0&&z>de&&G(I)},L=()=>z<=0?!1:U(e[z-1].id),B=()=>{const I=e[z+1];return I?U(I.id):!1},le={activeStep:X,activeIndex:z,completedStepIds:M,isCompleted:V,isUnlocked:R,completeStep:Y,uncompleteStep:ce,goToStep:U,goNext:B,goPrevious:L};if(!X)return null;const O=e[z+1],ae=z>0,S=O?R(O.id):!1,ee=typeof X.content=="function"?X.content(le):X.content;return t.jsxs("section",{className:tr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:tr("border-b border-[var(--border)] bg-[var(--bg-input)]",p),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${K}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((I,de)=>{const re=I.id===X.id,F=V(I.id),y=J(de),T=ne(de);return t.jsxs("button",{type:"button",disabled:!y,"aria-current":re?"step":void 0,"aria-disabled":!y,title:!y&&T?`Completa ${T.title}`:I.title,onClick:()=>U(I.id),className:tr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",re&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",F&&!re&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!re&&!F&&y&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!y&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:tr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",re&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:tr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",re&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",F&&!re&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!F&&!re&&y&&"border-[var(--border)] text-[var(--text-muted)]",!y&&"border-[var(--border)] text-[var(--text-muted)]"),children:F?t.jsx(j.HiCheck,{className:"h-4 w-4"}):y?de+1:t.jsx(j.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:tr("block truncate text-xs font-semibold transition-colors duration-200",re?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[de+1,". ",I.title]}),I.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:I.description})]}),I.badge&&t.jsx("span",{className:"shrink-0",children:I.badge})]})]},I.id)})})]}),t.jsx("div",{className:tr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",E),children:ee},X.id),u&&t.jsxs("div",{className:tr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Qe,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(j.HiChevronLeft,{}),disabled:!ae,onClick:L,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",z+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[M.length," completados"]})]}),t.jsx(Qe,{height:38,padding:"0 14px",icon:t.jsx(j.HiChevronRight,{}),disabled:!O||!S,onClick:B,children:O&&!S?f:b})]})]})}const xf={sm:"px-2.5 py-1.5 text-xs leading-5",md:"px-2.5 py-1.5 text-sm leading-5",lg:"px-3 py-2 text-sm leading-6"};function yf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function wf(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 Il(e,r){const{lineHeight:n,paddingY:a,borderY:o}=wf(e);return Math.ceil(r*n+a+o)}const Bl=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const g=s.useRef(null),p=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",E=s.useCallback(()=>{const v=g.current;if(!v)return;v.style.height="auto";const w=v.scrollHeight,A=Il(v,i),C=o??(l!==void 0?Il(v,l):void 0),H=C!==void 0?Math.min(Math.max(w,A),C):Math.max(w,A);v.style.height=`${H}px`,v.style.overflowY=C!==void 0&&w>C?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{E()},[E,d,u]),s.useEffect(()=>{const v=g.current;if(!v||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>E());return w.observe(v),()=>w.disconnect()},[E]),t.jsx("textarea",{...b,ref:v=>{g.current=v,yf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{E(),m==null||m(v)},style:{...c,borderColor:p,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${xf[n]} ${r}`})});function Nf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Bl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const kf={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"},Sf={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Ef(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Cf(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Fl=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:g,value:p,defaultValue:E,maxLength:v,onInput:w,...A},C){const H=s.useRef(null),k=Cf(p,E),x=u??v,M=!!(b||f||d),N=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",z={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const D=H.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(X,[l,p]);const K=t.jsx("textarea",{...A,ref:D=>{H.current=D,Ef(C,D)},value:p,defaultValue:E,maxLength:v,"aria-invalid":m==="error"||A["aria-invalid"],onInput:D=>{X(),w==null||w(D)},style:{...z,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 ${kf[a]} ${Sf[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return M?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),K,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[k,x?`/${x}`:""]})]}):K});function Mf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(zn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Fl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Pl=[{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 Tf(e){return Pl[e%Pl.length]}let $f=0;function ko(){return++$f}function _l(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Af(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lf(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Af(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Df({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:b,helperDisplay:f="inline",error:g,required:p=!1}){const E=e!==void 0,v=!!g,w=!!b&&f==="tooltip"&&!v,[A,C]=s.useState(()=>(r??[]).map((F,y)=>({id:ko(),value:F.trim(),colorIndex:y})));s.useEffect(()=>{E&&C(F=>{const y=e??[],T=new Map(F.map(te=>[te.value,te]));return y.map((te,fe)=>T.get(te)??{id:ko(),value:te,colorIndex:fe})})},[E,e]);const H=A,[k,x]=s.useState(""),[M,N]=s.useState(null),[z,X]=s.useState(""),[K,D]=s.useState(!1),[G,V]=s.useState(!1),ne=s.useRef(null),J=s.useRef(null),R=s.useRef(null);function U(){V(!0),setTimeout(()=>V(!1),400)}function Y(F){C(F),n==null||n(F.map(y=>y.value))}function ce(F){let y=H,T=!1,te=!1;for(const fe of F){const se=fe.trim();if(se){if(c!==void 0&&y.length>=c){te=!0;break}if(!d&&y.some(he=>he.value.toLowerCase()===se.toLowerCase())){te=!0;continue}if(!_l(se,u)){te=!0;continue}y=[...y,{id:ko(),value:se,colorIndex:y.length}],T=!0}}return T&&Y(y),te&&U(),T}function L(F){return ce([F])}function B(F){const y=H.filter(T=>T.id!==F);Y(y.map((T,te)=>({...T,colorIndex:te})))}function le(F,y){const T=y.trim();if(N(null),X(""),!T){B(F);return}if(!(!d&&H.some(te=>te.id!==F&&te.value.toLowerCase()===T.toLowerCase()))){if(!_l(T,u)){U();return}Y(H.map(te=>te.id===F?{...te,value:T}:te))}}function O(F){o||(N(F.id),X(F.value),setTimeout(()=>{var y;return(y=J.current)==null?void 0:y.select()},0))}function ae(F){if(F.key==="Enter"||i.includes(F.key)){F.preventDefault(),L(k)&&x("");return}if(F.key==="Backspace"&&k===""&&H.length>0){F.preventDefault();const y=H[H.length-1];B(y.id)}}function S(F,y){if(F.key==="Enter"){F.preventDefault(),le(y,z),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0);return}F.key==="Escape"&&(F.preventDefault(),N(null),X(""),setTimeout(()=>{var T;return(T=ne.current)==null?void 0:T.focus()},0))}function ee(){var F;o||(F=ne.current)==null||F.focus()}function _(F){if(o)return;const y=F.clipboardData.getData("text");if(!y||!(i.some(se=>se&&y.includes(se))||y.includes(`
|
|
31
|
-
`)))return;
|
|
28
|
+
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function xo(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=yo(d);!u||r.has(u)||(r.add(u),n.push(u))},o=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=o.exec(e))!==null;)a(l[1]??"");const i=wl(e);go.lastIndex=0;let c;for(;(c=go.exec(i))!==null;)a(c[1]??"");return n}function Nl(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function af(e,r){const n=xo(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(yo(i.username),i)});const o=new Set,l=[];for(const i of n){const c=a.get(i);c&&(o.has(c.userId)||(o.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function kl(e){const r=new Set,n=[];for(const a of e)r.has(a.userId)||(r.add(a.userId),n.push(a));return n}function of(e,r){return r?e.filter(n=>n.userId!==r):e}function wo(e){var n;let r=e.nextSibling;for((r==null?void 0:r.nodeType)===Node.TEXT_NODE&&/^[ \u00a0]/.test(r.textContent??"")&&(r=r.nextSibling);r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").replace(/\u00a0/g," ").trim();)r=r.nextSibling;return r&&r.nodeType===Node.ELEMENT_NODE&&((n=r.classList)!=null&&n.contains("mention-chip"))?" ":!r||r.nodeType===Node.ELEMENT_NODE&&r.tagName==="BR"?" ":" "}function Sl(e){return!e||!/@/.test(e)?e:e.replace(go,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=o[a+r.length]??"";return u===" "||u===" "?`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>`:`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>${u?" ":" "}`})}function dn(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,o=wo(n),l=n.nextSibling;if((l==null?void 0:l.nodeType)===Node.TEXT_NODE){const i=l.textContent??"";if(i.startsWith(o))return;if(i.startsWith(" ")||i.startsWith(" ")){l.textContent=`${o}${i.slice(1)}`;return}if(i.length>0){l.textContent=`${o}${i}`;return}}n.after(a.createTextNode(o))})}function No(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&dn(a);const o=wo(e);let l=e.nextSibling;!l||l.nodeType!==Node.TEXT_NODE||!/^[ \u00a0]/.test(l.textContent??"")?(l=r.createTextNode(o),e.after(l)):(l.textContent??"").startsWith(o)||(l.textContent=`${o}${(l.textContent??"").slice(1)}`);const i=n==null?void 0:n.getSelection();if(!i)return;const c=r.createRange();c.setStart(l,((d=l.textContent)==null?void 0:d.length)??1),c.collapse(!0),i.removeAllRanges(),i.addRange(c)}const sf=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function El(e,r){return sf.has(e.tagName)&&e!==r}function ko(e,r){let n="",a,o,l=!1;const i=(f,p)=>{if(l||!(r!=null&&r.domPoint))return;const{container:g,offset:k}=r.domPoint;g===f&&k===p&&(o=n.length,l=!0)},c=(f,p)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:p},!0),d=f=>(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":(n+=`
|
|
29
|
+
`,(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":!1),u=f=>{const p=f.data;for(let g=0;g<=p.length;g+=1){if(i(f,g),c(f,g))return!0;g<p.length&&(n+=p[g])}return!1},m=(f,p)=>{if(p&&n.length>0&&!n.endsWith(`
|
|
30
|
+
`)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const g=f;if(g.tagName==="BR")return i(g,0),d(g.nextSibling??void 0)==="matched";const k=Array.from(f.childNodes);for(let v=0;v<k.length;v+=1){const A=k[v],E=v>0&&A.nodeType===Node.ELEMENT_NODE&&El(A,e);if(m(A,E))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const p=b[f],g=f>0&&p.nodeType===Node.ELEMENT_NODE&&El(p,e);if(m(p,g))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=f.nextNode(),g=p;for(;g;)p=g,g=f.nextNode();p&&(a={node:p,offset:p.data.length})}return{plain:n,locate:a,domOffset:o}}function So(e){return ko(e).plain}function Or(e,r){return r<0?null:ko(e,{locatePlain:r}).locate??null}function Qn(e,r,n){return e!==r&&!e.contains(r)?-1:ko(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function Cl(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Or(e,n),i=Or(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=Nl({name:r.display,username:o}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",o.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${o}`;const b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(m,b),d.insertNode(f),dn(e),No(m);const p=c.defaultView,g=p==null?void 0:p.getSelection(),k=g!=null&&g.rangeCount?Qn(e,g.getRangeAt(0).startContainer,g.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:k>=0?k:n+u.length+1}}function Ml(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Or(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Jn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function Tl(e,r){let n=e;for(;n&&n.nodeType===Node.TEXT_NODE&&!(n.textContent??"").replace(/\u00a0/g," ").trim();)n=r==="prev"?n.previousSibling:n.nextSibling;return n}function $l(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function Hr(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Rn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function Al(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Rn(e)}function Ll(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function Dl(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Hr(e),!0):!1}function ea(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,p)=>{let g=f;for(;g&&g.nodeType===Node.TEXT_NODE&&(g.textContent??"")==="";){const k=g;g=g[p],k.remove()}return g},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function Ol(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=Tl(a.previousSibling,"prev");return Jn(c)&&(o===0||o===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o-1;for(;c>=0;){const d=i[c];if(Jn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Hl(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(o>=i.length){const c=Tl(a.nextSibling,"next");if(Jn(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o;for(;c<i.length;){const d=i[c];if(Jn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function Eo(e){var o;const r=(o=e.ownerDocument.defaultView)==null?void 0:o.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const Co=420,ta=6,Il=260,lf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Bl=4,cf={position:"relative"},df={position:"fixed",zIndex:11050,minWidth:Il,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},Fl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function uf(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function ff(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Il-8)),n=window.innerHeight-e.bottom-ta-8,a=e.top-ta-8;return n<Math.min(Co,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ta,maxHeight:Math.min(Co,Math.max(120,a))}:{left:r,top:e.bottom+ta,maxHeight:Math.min(Co,Math.max(120,n))}}function Pl({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m="",toolbarVariant:b="full"}){const f=s.useId().replace(/:/g,""),p=s.useRef(null),g=s.useRef(null),k=s.useRef(new Map),v=s.useRef(n);v.current=n;const A=s.useRef(null),E=s.useRef(0),M=s.useRef([]),H=s.useRef(null),[S,x]=s.useState(null),[C,w]=s.useState([]),[P,V]=s.useState(0),[X,O]=s.useState([]),[K,q]=s.useState(!1),[le,J]=s.useState(!1);E.current=P,s.useEffect(()=>{J(!0)},[]);const G=(S==null?void 0:S.query)??null;s.useEffect(()=>{if(G===null){w([]);return}const N=G.trim(),R=`${m}|${N.toLowerCase()||"*"}`,ae=k.current.get(R);if(ae){w(ae),q(!1),V(0);return}const $=new AbortController;q(!0);const ne=window.setTimeout(()=>{(async()=>{try{const te=await v.current(N,{signal:$.signal,limit:c});if($.signal.aborted)return;const j=Array.isArray(te)?te:[];k.current.set(R,j),w(j),V(0)}catch{$.signal.aborted||w([])}finally{$.signal.aborted||q(!1)}})()},d);return()=>{$.abort(),window.clearTimeout(ne)}},[G,c,d,m]);const U=s.useRef(a);U.current=a,s.useEffect(()=>{var N;(N=U.current)==null||N.call(U,kl(X))},[X]);const Y=s.useCallback(()=>{const N=uf(f);if(N.length===0)return null;const R=window.getSelection();if(R!=null&&R.rangeCount){const $=R.getRangeAt(0).startContainer;for(const ne of N)if(ne.contains($))return ne}const ae=document.activeElement;for(const $ of N)if(ae===$||ae&&$.contains(ae))return $;for(const $ of N)if($.closest('[role="dialog"]'))return $;return N[0]??null},[f]),ue=s.useCallback(()=>{const N=Y(),R=window.getSelection();if(!N||!R||R.rangeCount===0){x(null);return}const ae=R.getRangeAt(0);if(!N.contains(ae.startContainer)){x(null);return}const $=Qn(N,ae.startContainer,ae.startOffset);if($<0){x(null);return}const ne=vo(N,$);if(!ne){x(null);return}const te=ae.getBoundingClientRect(),j=te.width===0&&te.height===0?(()=>{const T=document.createRange();return T.selectNodeContents(ae.startContainer),T.collapse(!0),T.getBoundingClientRect()})():te;A.current={query:ne.query,caretIndex:ne.caretIndex,triggerIndex:ne.triggerIndex};const y=ff(j);x(T=>{const ee={query:ne.query,...y};return T&&T.query===ee.query&&T.top===ee.top&&T.bottom===ee.bottom&&T.left===ee.left&&T.maxHeight===ee.maxHeight?T:ee})},[Y]),L=s.useCallback(N=>{r(N),ue()},[r,ue]);s.useEffect(()=>{const N=R=>{if(lf.has(R.key))return;const ae=Y(),$=R.target;!ae||!$||!ae.contains($)||ue()};return document.addEventListener("keyup",N,!0),()=>document.removeEventListener("keyup",N,!0)},[Y,ue]);const B=s.useCallback(N=>{const R=Y();if(!R)return;let ae=-1;const $=window.getSelection();if($&&$.rangeCount>0){const T=$.getRangeAt(0);R.contains(T.startContainer)&&(ae=Qn(R,T.startContainer,T.startOffset))}if(ae<0&&A.current&&(ae=A.current.caretIndex),ae<0)return;const ne=vo(R,ae);if(!ne)return;const te=Cl(R,{triggerIndex:ne.triggerIndex,caretIndex:ae,username:N.username,display:N.name,userId:N.userId});if(!te)return;dn(R),R.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const j={userId:N.userId,username:N.username,email:N.email??void 0,display:N.name??N.username};O(T=>{const ee=new Map(T.map(fe=>[fe.userId,fe]));return ee.set(j.userId,j),Array.from(ee.values())}),x(null),A.current=null;const y=N.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const T=Y();if(!T)return;T.focus(),dn(T);const ee=Array.from(T.querySelectorAll(".mention-chip")),fe=[...ee].reverse().find(ie=>ie.getAttribute("data-username")===y)??ee[ee.length-1];if(fe){No(fe);return}Ml(T,te.caretPlainOffset)})})},[Y]);s.useEffect(()=>{const N=new Set(xo(e).map(R=>R.toLowerCase()));O(R=>{const ae=R.filter($=>N.has($.username.toLowerCase()));return ae.length===R.length?R:ae})},[e]),s.useEffect(()=>{if(!S)return;const N=R=>{const ae=R.target;if(!ae||p.current&&p.current.contains(ae)||g.current&&g.current.contains(ae))return;const $=Y();$&&$.contains(ae)||x(null)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[S,Y]);const de=s.useMemo(()=>C.slice(0,c),[C,c]);M.current=de,s.useEffect(()=>{if(!S)return;const N=R=>{const ae=Y(),$=R.target;if(!ae||!$||!ae.contains($))return;const ne=M.current;if(!(ne.length===0&&R.key!=="Escape"))if(R.key==="ArrowDown")R.preventDefault(),R.stopPropagation(),V(te=>(te+1)%Math.max(ne.length,1));else if(R.key==="ArrowUp")R.preventDefault(),R.stopPropagation(),V(te=>(te-1+ne.length)%Math.max(ne.length,1));else if(R.key==="Enter"||R.key==="Tab"){const te=ne[E.current];te&&(R.preventDefault(),R.stopPropagation(),B(te))}else R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),x(null))};return document.addEventListener("keydown",N,!0),()=>document.removeEventListener("keydown",N,!0)},[Y,B,S]),s.useEffect(()=>{const N=j=>{j.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},R=j=>{const y=Y(),T=j.target;if(!y||!T||!y.contains(T))return;if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),y.focus(),Al(y);return}if(j.key!=="Backspace"&&j.key!=="Delete")return;const ee=window.getSelection();if(ee&&!ee.isCollapsed&&ee.rangeCount>0){const he=ee.getRangeAt(0);if(y.contains(he.commonAncestorContainer)&&Eo(y).length>0&&Ll(he)){j.preventDefault(),j.stopPropagation(),Dl(y)&&N(y);return}}const fe=Eo(y);if(fe.length>0){j.preventDefault(),j.stopPropagation();for(const he of fe)ea(he);Hr(y),N(y);return}if(j.key==="Backspace"){const he=Ol(y);if(!he)return;j.preventDefault(),j.stopPropagation(),ea(he),Hr(y),N(y);return}const ie=Hl(y);ie&&(j.preventDefault(),j.stopPropagation(),ea(ie),Hr(y),N(y))},ae=j=>{const y=Y();if(!y)return;const T=j.target;if(!(T instanceof Element)||!y.contains(T))return;const ee=T.closest(".mention-chip");if(!(ee instanceof HTMLElement)||!y.contains(ee)){H.current=null,Hr(y);return}j.shiftKey||j.button!==0||(H.current={chip:ee,x:j.clientX,y:j.clientY})},$=j=>{const y=H.current;if(!y)return;const T=Math.abs(j.clientX-y.x),ee=Math.abs(j.clientY-y.y);(T>Bl||ee>Bl)&&(H.current=null)},ne=j=>{var ie;const y=Y(),T=H.current;if(H.current=null,!y||!T)return;const ee=j.target;if(!(ee instanceof Element)||!y.contains(ee)||!((ie=ee.closest(".mention-chip"))!=null&&ie.isSameNode(T.chip)))return;const fe=window.getSelection();if(fe){if(!fe.isCollapsed){Rn(y);return}y.focus(),$l(T.chip)}},te=()=>{const j=Y();if(!j)return;const y=window.getSelection();!y||y.rangeCount===0||!y.anchorNode||!j.contains(y.anchorNode)||!y.focusNode||!j.contains(y.focusNode)||Rn(j)};return document.addEventListener("keydown",R,!0),document.addEventListener("mousedown",ae,!0),document.addEventListener("mousemove",$,!0),document.addEventListener("mouseup",ne,!0),document.addEventListener("selectionchange",te),()=>{document.removeEventListener("keydown",R,!0),document.removeEventListener("mousedown",ae,!0),document.removeEventListener("mousemove",$,!0),document.removeEventListener("mouseup",ne,!0),document.removeEventListener("selectionchange",te)}},[Y]),s.useEffect(()=>{if(!S||!g.current)return;const N=g.current.querySelector(`[data-mention-index="${P}"]`);N==null||N.scrollIntoView({block:"nearest"})},[P,S]);const I=u?Sl(e):e,oe=S&&le?pt.createPortal(t.jsxs("ul",{ref:g,style:{...df,left:S.left,top:S.top,bottom:S.bottom,maxHeight:S.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[K&&de.length===0&&t.jsx("li",{style:Fl,children:"Buscando…"}),!K&&de.length===0&&t.jsx("li",{style:Fl,children:S.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${S.query}”`}),de.map((N,R)=>{var ae,$;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":R,onMouseDown:ne=>{ne.preventDefault(),B(N)},onMouseEnter:()=>V(R),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:R===P?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((ae=N.name)==null?void 0:ae.trim())||`@${N.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[($=N.name)!=null&&$.trim()?`@${N.username}`:null,N.email].filter(Boolean).join(" · ")||`@${N.username}`})]})},N.userId)})]}),document.body):null;return t.jsxs("div",{ref:p,style:cf,className:i,children:[t.jsx(hl,{value:I,onChange:L,placeholder:l,minHeight:o,instanceId:f,toolbarVariant:b}),oe]})}function bf({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}){return o?t.jsx(Pl,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m,toolbarVariant:b}):t.jsx(hl,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b})}function mf({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:o}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const hf={neutral:{text:"var(--text-secondary)",bg:"var(--bg-input)",border:"var(--border)"},primary:{text:"var(--primary)",bg:"color-mix(in srgb, var(--primary) 10%, transparent)",border:"color-mix(in srgb, var(--primary) 24%, var(--border))"},success:{text:"#047857",bg:"rgba(16, 185, 129, 0.11)",border:"rgba(16, 185, 129, 0.24)"},warning:{text:"#b45309",bg:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)"},danger:{text:"var(--danger)",bg:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))"},info:{text:"#2563eb",bg:"rgba(59, 130, 246, 0.11)",border:"rgba(59, 130, 246, 0.24)"}},pf={xs:"min-h-5 px-1.5 text-[10px]",sm:"min-h-6 px-2 text-xs",md:"min-h-7 px-2.5 text-sm"};function gf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=hf[r];return t.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${pf[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[o&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const _l={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},vf={xs:"min-h-5 px-1.5 pr-6 text-[10px]",sm:"min-h-6 px-2 pr-7 text-xs",md:"min-h-7 px-2.5 pr-8 text-sm"},yf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},xf={xs:148,sm:164,md:184},wf={xs:"px-2.5 py-1.5 text-xs",sm:"px-3 py-2 text-sm",md:"px-3.5 py-2.5 text-sm"};function Nf({value:e,options:r,onChange:n,size:a="sm",disabled:o=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:b,optionClassName:f,spinnerClassName:p}){const[g,k]=s.useState(!1),[v,A]=s.useState(!1),[E,M]=s.useState(-1),[H,S]=s.useState({}),x=s.useRef(null),C=s.useRef(null),w=s.useRef(null),P=r.find(U=>U.value===e)??r[0],V={...P!=null&&P.tone?_l[P.tone]:void 0,...P==null?void 0:P.style},X=o||l||r.length===0,O=U=>{i&&U.stopPropagation()},K=s.useCallback(()=>{k(!1),M(-1)},[]),q=s.useCallback(()=>{const U=x.current;if(!U)return;const Y=U.getBoundingClientRect(),ue=Math.max(Y.width,xf[a]),L=Math.min(Math.max(r.length,1)*38+12,260),B=window.innerHeight-Y.bottom,de=B<L&&Y.top>B,I=Math.min(Math.max(8,Y.left+Y.width/2-ue/2),window.innerWidth-ue-8);S({position:"fixed",left:I,top:de?void 0:Y.bottom+6,bottom:de?window.innerHeight-Y.top+6:void 0,width:ue,zIndex:9999})},[r.length,a]),le=s.useCallback(U=>{U.disabled||(n(U.value),K())},[K,n]);s.useEffect(()=>A(!0),[]),s.useEffect(()=>{if(!g)return;q();const U=r.findIndex(Y=>Y.value===e);M(U>=0?U:0)},[g,r,q,e]),s.useEffect(()=>{if(!g)return;function U(Y){var L,B;const ue=Y.target;!((L=x.current)!=null&&L.contains(ue))&&!((B=C.current)!=null&&B.contains(ue))&&K()}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[K,g]),s.useEffect(()=>{if(g)return window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[g,q]),s.useEffect(()=>{if(E<0||!w.current)return;const U=w.current.children[E];U==null||U.scrollIntoView({block:"nearest"})},[E]);function J(U){if(!X){if(!g){["Enter"," ","ArrowDown","ArrowUp"].includes(U.key)&&(U.preventDefault(),k(!0));return}if(U.key==="Escape"){U.preventDefault(),K();return}if(U.key==="ArrowDown"){U.preventDefault(),M(Y=>Math.min(Y+1,r.length-1));return}if(U.key==="ArrowUp"){U.preventDefault(),M(Y=>Math.max(Y-1,0));return}if(U.key==="Enter"||U.key===" "){U.preventDefault();const Y=r[E];Y&&le(Y)}}}const G=t.jsx("div",{ref:C,role:"listbox","aria-label":c,className:Qt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...H,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:O,onMouseDown:O,onPointerDown:O,children:t.jsx("div",{ref:w,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((U,Y)=>{const ue=U.value===e,L=Y===E,B={...U.tone?_l[U.tone]:void 0,...U.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ue,disabled:U.disabled,onMouseEnter:()=>!U.disabled&&M(Y),onMouseDown:de=>{de.preventDefault(),le(U)},className:Qt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",wf[a],ue?U.className:void 0,f),style:{...ue?B:void 0,background:ue?B.background??"color-mix(in srgb, var(--primary) 12%, transparent)":L?"var(--bg-hover)":"transparent",color:ue?B.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ue?t.jsx(W.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.label})]},U.value)})})});return t.jsxs("span",{ref:x,className:Qt("relative inline-flex shrink-0 items-center",u),onKeyDown:J,onClick:O,onPointerDown:O,children:[t.jsx("button",{type:"button",disabled:X,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":g,title:d,onClick:()=>!X&&k(U=>!U),className:Qt("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",vf[a],P==null?void 0:P.className,m),style:V,children:t.jsx("span",{className:"min-w-0 truncate",children:(P==null?void 0:P.label)??e})}),t.jsx(W.HiChevronDown,{"aria-hidden":"true",className:Qt("pointer-events-none absolute opacity-70 transition-transform",yf[a],g?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Qt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",p)}),g&&v&&pt.createPortal(G,document.body)]})}function kf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(g=>!g.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(g=>g.id===m)??u,f=g=>{g.disabled||a==null||a(g.id)},p=g=>{const k=e.filter(A=>!A.disabled);if(!k.length||!b)return;const v=k.findIndex(A=>A.id===b.id);(g.key==="ArrowRight"||g.key==="ArrowDown")&&(g.preventDefault(),f(k[(v+1)%k.length])),(g.key==="ArrowLeft"||g.key==="ArrowUp")&&(g.preventDefault(),f(k[(v-1+k.length)%k.length])),g.key==="Home"&&(g.preventDefault(),f(k[0])),g.key==="End"&&(g.preventDefault(),f(k[k.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:p,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(g=>{const k=g.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${g.id}-panel`,id:`${g.id}-tab`,disabled:g.disabled,tabIndex:k?0:-1,onClick:()=>f(g),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[g.icon&&t.jsx("span",{className:"shrink-0",children:g.icon}),t.jsx("span",{children:g.label}),g.badge&&t.jsx("span",{className:"shrink-0",children:g.badge})]},g.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function rr(...e){return e.filter(Boolean).join(" ")}function Sf({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:p="",headerClassName:g="",contentClassName:k="",footerClassName:v=""}){var ae;const A=((ae=e[0])==null?void 0:ae.id)??"",[E,M]=s.useState(n??A),[H,S]=s.useState(o),x=r??E,C=a??H,w=s.useMemo(()=>new Set(C),[C]),P=Math.max(0,e.findIndex($=>$.id===x)),V=e[P]??e[0],X=e.length<=1?100:P/(e.length-1)*100,O=$=>{a||S($),i==null||i($)},K=$=>{const ne=e.find(te=>te.id===$);ne&&(r||M($),l==null||l($,ne))},q=$=>w.has($),le=$=>e.slice(0,$).find(ne=>!ne.optional&&!w.has(ne.id)),J=$=>{const ne=e[$];return!ne||ne.disabled?!1:$===P||d&&$<P?!0:!le($)},G=$=>{const ne=e.findIndex(te=>te.id===$);return ne>=0&&J(ne)},U=$=>{const ne=e.findIndex(te=>te.id===$);if(ne<0)return!1;if(!J(ne)){const te=le(ne);return te&&(c==null||c(e[ne],te)),!1}return K($),!0},Y=($=V==null?void 0:V.id)=>{!$||w.has($)||O([...C,$])},ue=($=V==null?void 0:V.id)=>{if(!$)return;const ne=e.findIndex(j=>j.id===$),te=C.filter(j=>{const y=e.findIndex(T=>T.id===j);return y>=0&&y<ne});O(te),ne>=0&&P>ne&&K($)},L=()=>P<=0?!1:U(e[P-1].id),B=()=>{const $=e[P+1];return $?U($.id):!1},de={activeStep:V,activeIndex:P,completedStepIds:C,isCompleted:q,isUnlocked:G,completeStep:Y,uncompleteStep:ue,goToStep:U,goNext:B,goPrevious:L};if(!V)return null;const I=e[P+1],oe=P>0,N=I?G(I.id):!1,R=typeof V.content=="function"?V.content(de):V.content;return t.jsxs("section",{className:rr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[t.jsxs("div",{className:rr("border-b border-[var(--border)] bg-[var(--bg-input)]",g),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${X}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(($,ne)=>{const te=$.id===V.id,j=q($.id),y=J(ne),T=le(ne);return t.jsxs("button",{type:"button",disabled:!y,"aria-current":te?"step":void 0,"aria-disabled":!y,title:!y&&T?`Completa ${T.title}`:$.title,onClick:()=>U($.id),className:rr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",te&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",j&&!te&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!te&&!j&&y&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!y&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:rr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",te&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:rr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",te&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",j&&!te&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!j&&!te&&y&&"border-[var(--border)] text-[var(--text-muted)]",!y&&"border-[var(--border)] text-[var(--text-muted)]"),children:j?t.jsx(W.HiCheck,{className:"h-4 w-4"}):y?ne+1:t.jsx(W.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:rr("block truncate text-xs font-semibold transition-colors duration-200",te?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[ne+1,". ",$.title]}),$.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:$.description})]}),$.badge&&t.jsx("span",{className:"shrink-0",children:$.badge})]})]},$.id)})})]}),t.jsx("div",{className:rr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",k),children:R},V.id),u&&t.jsxs("div",{className:rr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Ge,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(W.HiChevronLeft,{}),disabled:!oe,onClick:L,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",P+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[C.length," completados"]})]}),t.jsx(Ge,{height:38,padding:"0 14px",icon:t.jsx(W.HiChevronRight,{}),disabled:!I||!N,onClick:B,children:I&&!N?f:b})]})]})}const Ef={sm:"px-2.5 py-1.5 text-xs leading-5",md:"px-2.5 py-1.5 text-sm leading-5",lg:"px-3 py-2 text-sm leading-6"};function Cf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Mf(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),o=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(o)?o:2}}function zl(e,r){const{lineHeight:n,paddingY:a,borderY:o}=Mf(e);return Math.ceil(r*n+a+o)}const Wl=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const p=s.useRef(null),g=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",k=s.useCallback(()=>{const v=p.current;if(!v)return;v.style.height="auto";const A=v.scrollHeight,E=zl(v,i),M=o??(l!==void 0?zl(v,l):void 0),H=M!==void 0?Math.min(Math.max(A,E),M):Math.max(A,E);v.style.height=`${H}px`,v.style.overflowY=M!==void 0&&A>M?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{k()},[k,d,u]),s.useEffect(()=>{const v=p.current;if(!v||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>k());return A.observe(v),()=>A.disconnect()},[k]),t.jsx("textarea",{...b,ref:v=>{p.current=v,Cf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{k(),m==null||m(v)},style:{...c,borderColor:g,minHeight:void 0},className:`w-full resize-none overflow-hidden rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Ef[n]} ${r}`})});function Tf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Wn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Wl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const $f={sm:"min-h-20 px-2.5 py-1.5 text-xs leading-5",md:"min-h-24 px-2.5 py-2 text-sm leading-5",lg:"min-h-32 px-3 py-2.5 text-sm leading-6"},Af={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Lf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Df(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const jl=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:p,value:g,defaultValue:k,maxLength:v,onInput:A,...E},M){const H=s.useRef(null),S=Df(g,k),x=u??v,C=!!(b||f||d),w=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",P={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},V=()=>{const O=H.current;!O||!l||(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)};s.useEffect(V,[l,g]);const X=t.jsx("textarea",{...E,ref:O=>{H.current=O,Lf(M,O)},value:g,defaultValue:k,maxLength:v,"aria-invalid":m==="error"||E["aria-invalid"],onInput:O=>{V(),A==null||A(O)},style:{...P,borderColor:w},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${$f[a]} ${Af[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return C?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),X,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[S,x?`/${x}`:""]})]}):X});function Of({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Wn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(jl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const ql=[{bg:"#dbeafe",text:"#1e40af",border:"#bfdbfe"},{bg:"#dcfce7",text:"#166534",border:"#bbf7d0"},{bg:"#fce7f3",text:"#9d174d",border:"#fbcfe8"},{bg:"#fef9c3",text:"#854d0e",border:"#fef08a"},{bg:"#ede9fe",text:"#5b21b6",border:"#ddd6fe"},{bg:"#ffedd5",text:"#9a3412",border:"#fed7aa"},{bg:"#cffafe",text:"#155e75",border:"#a5f3fc"},{bg:"#f0fdf4",text:"#14532d",border:"#bbf7d0"}];function Hf(e){return ql[e%ql.length]}let If=0;function Mo(){return++If}function Ul(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Bf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ff(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Bf(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Pf({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:b,helperDisplay:f="inline",error:p,required:g=!1}){const k=e!==void 0,v=!!p,A=!!b&&f==="tooltip"&&!v,[E,M]=s.useState(()=>(r??[]).map((j,y)=>({id:Mo(),value:j.trim(),colorIndex:y})));s.useEffect(()=>{k&&M(j=>{const y=e??[],T=new Map(j.map(ee=>[ee.value,ee]));return y.map((ee,fe)=>T.get(ee)??{id:Mo(),value:ee,colorIndex:fe})})},[k,e]);const H=E,[S,x]=s.useState(""),[C,w]=s.useState(null),[P,V]=s.useState(""),[X,O]=s.useState(!1),[K,q]=s.useState(!1),le=s.useRef(null),J=s.useRef(null),G=s.useRef(null);function U(){q(!0),setTimeout(()=>q(!1),400)}function Y(j){M(j),n==null||n(j.map(y=>y.value))}function ue(j){let y=H,T=!1,ee=!1;for(const fe of j){const ie=fe.trim();if(ie){if(c!==void 0&&y.length>=c){ee=!0;break}if(!d&&y.some(he=>he.value.toLowerCase()===ie.toLowerCase())){ee=!0;continue}if(!Ul(ie,u)){ee=!0;continue}y=[...y,{id:Mo(),value:ie,colorIndex:y.length}],T=!0}}return T&&Y(y),ee&&U(),T}function L(j){return ue([j])}function B(j){const y=H.filter(T=>T.id!==j);Y(y.map((T,ee)=>({...T,colorIndex:ee})))}function de(j,y){const T=y.trim();if(w(null),V(""),!T){B(j);return}if(!(!d&&H.some(ee=>ee.id!==j&&ee.value.toLowerCase()===T.toLowerCase()))){if(!Ul(T,u)){U();return}Y(H.map(ee=>ee.id===j?{...ee,value:T}:ee))}}function I(j){o||(w(j.id),V(j.value),setTimeout(()=>{var y;return(y=J.current)==null?void 0:y.select()},0))}function oe(j){if(j.key==="Enter"||i.includes(j.key)){j.preventDefault(),L(S)&&x("");return}if(j.key==="Backspace"&&S===""&&H.length>0){j.preventDefault();const y=H[H.length-1];B(y.id)}}function N(j,y){if(j.key==="Enter"){j.preventDefault(),de(y,P),setTimeout(()=>{var T;return(T=le.current)==null?void 0:T.focus()},0);return}j.key==="Escape"&&(j.preventDefault(),w(null),V(""),setTimeout(()=>{var T;return(T=le.current)==null?void 0:T.focus()},0))}function R(){var j;o||(j=le.current)==null||j.focus()}function ae(j){if(o)return;const y=j.clipboardData.getData("text");if(!y||!(i.some(ie=>ie&&y.includes(ie))||y.includes(`
|
|
31
|
+
`)))return;j.preventDefault();const ee=Ff(y,i);ue(ee)&&x("")}function $(){const j=S.trim();j&&L(j)&&x("")}const ne=v?"var(--danger)":X?"var(--primary)":"var(--border)",te=c!==void 0&&H.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||g||A)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),g&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(Tr,{content:b}):null]}),t.jsxs("div",{ref:G,onClick:R,onFocus:()=>O(!0),onBlur:j=>{var y;(y=G.current)!=null&&y.contains(j.relatedTarget)||(O(!1),C!==null&&de(C,P),C===null&&$())},style:{borderColor:ne},className:`
|
|
32
32
|
flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
|
|
33
33
|
bg-[var(--bg-input)] px-2.5 py-2 transition-colors
|
|
34
34
|
${o?"cursor-not-allowed opacity-60":"cursor-text"}
|
|
35
|
-
${
|
|
35
|
+
${K?"animate-[tag-shake_0.4s_ease]":""}
|
|
36
36
|
`,children:[t.jsx("style",{children:`
|
|
37
37
|
@keyframes tag-shake {
|
|
38
38
|
0%,100% { transform: translateX(0); }
|
|
@@ -41,7 +41,7 @@ ${P}`,ve=new Blob(["\uFEFF"+oe],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
|
|
|
41
41
|
60% { transform: translateX(-3px); }
|
|
42
42
|
80% { transform: translateX(3px); }
|
|
43
43
|
}
|
|
44
|
-
`}),H.map(F=>{const y=Tf(F.colorIndex);return M===F.id?t.jsx("input",{ref:J,value:z,disabled:o,onChange:T=>X(T.target.value),onKeyDown:T=>S(T,F.id),onBlur:()=>le(F.id,z),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(z.length+2,6)}ch`}},F.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:y.bg,color:y.text,border:`1px solid ${y.border}`},children:[t.jsx("span",{className:"truncate",children:F.value}),t.jsx("button",{type:"button","aria-label":`Editar "${F.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),O(F)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(j.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${F.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),B(F.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(j.HiXMark,{className:"h-3.5 w-3.5"})})]},F.id)}),!re&&t.jsx("input",{ref:ne,value:k,disabled:o,placeholder:H.length===0?a:"",onChange:F=>x(F.target.value),onKeyDown:ae,onPaste:_,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),t.jsx(Tr,{error:g,helperText:b,helperDisplay:f})]})}const Of=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function rt(e){return String(e).padStart(2,"0")}function So(e,r=Hr()){const n=e.trim();if(!n)return r;const a=n.match(Of);if(!a)return r;const o=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(i)||o<0||o>23||l<0||l>59||i<0||i>59?r:{hour24:o,minute:l,second:i}}function un(e,r=!0){const n=`${rt(e.hour24)}:${rt(e.minute)}`;return r?`${n}:${rt(e.second)}`:n}function ta(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function fn(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function Hf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=So(e);if(n){const l=ta(o),i=`${l.hour12}:${rt(l.minute)}`;return`${a?`${i}:${rt(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Hr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function If(e=!0){return un(Hr(),e)}function Eo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const Nt=36,Co=5,zl=Math.floor(Co/2),Bf=52,Ff=48,Xt=18;function Wl(e){return e*Nt}function jl(e){return Math.round(e/Nt)}function Pf(e){return e.use12Hour??e.hour12??!1}function ra({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=Bf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const p=s.useRef(null),E=s.useRef(null),v=s.useRef(null),w=s.useRef(""),A=s.useRef(0),C=s.useRef(!1),[H,k]=s.useState(r),[x,M]=s.useState(""),N=s.useCallback(O=>{w.current=O,M(O)},[]),z=s.useMemo(()=>[...Array(zl).fill(""),...e,...Array(zl).fill("")],[e]),X=s.useCallback(()=>{const O=p.current;if(!O)return r;const ae=jl(O.scrollTop),S=Math.min(Math.max(ae,0),e.length-1);return e[S]??r},[r,e]),K=s.useCallback((O,ae=!0)=>{const S=Math.min(Math.max(O,0),e.length-1),ee=e[S],_=p.current;!_||!ee||(E.current&&(window.clearTimeout(E.current),E.current=null),C.current=!0,A.current=S,_.scrollTop=Wl(S),k(ee),ae&&ee!==r&&n(ee))},[n,r,e]);s.useLayoutEffect(()=>{E.current&&(window.clearTimeout(E.current),E.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),N(""),k(r);const O=e.indexOf(r);if(O>=0&&(A.current=O),O<0||!p.current)return;const ae=Wl(O);p.current.scrollTop!==ae&&(p.current.scrollTop=ae)},[o,r,N,e]);const D=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),G=s.useCallback((O,ae=!1)=>{D(),N("");const S=Number(O);if(!Number.isFinite(S))return;const ee=Math.min(c,Math.max(0,S));let _=rt(ee),I=e.indexOf(_);if(I<0){const de=Math.min(e.length-1,Math.max(0,ee-(c===12?1:0)));_=e[de]??_,I=e.indexOf(_)}I>=0&&K(I),ae&&(b==null||b())},[D,c,b,K,N,e]),V=s.useCallback(O=>{const ae=Math.floor(c/10),S=w.current;if(S===""){if(O>ae){G(String(O),!0);return}const _=String(O);N(_),v.current=window.setTimeout(()=>{G(w.current,!0)},1200);return}D();const ee=+`${S}${O}`;ee<=c?G(String(ee),!0):G(String(O),!0)},[D,G,c,N]),ne=s.useCallback(O=>{D(),N(""),K(A.current+O)},[D,K,N]),J=O=>{if(d){O.key==="a"||O.key==="A"?(O.preventDefault(),n("AM"),b==null||b()):O.key==="p"||O.key==="P"?(O.preventDefault(),n("PM"),b==null||b()):O.key==="ArrowUp"||O.key==="ArrowDown"?(O.preventDefault(),n(r==="AM"?"PM":"AM")):O.key==="Tab"&&(O.preventDefault(),O.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(O.key)){O.preventDefault(),V(Number(O.key));return}O.key==="ArrowUp"?(O.preventDefault(),ne(-1)):O.key==="ArrowDown"?(O.preventDefault(),ne(1)):O.key==="Tab"&&(O.preventDefault(),D(),w.current!==""&&G(w.current,!1),O.shiftKey?f==null||f():b==null||b())},R=s.useCallback(()=>{const O=a.current,ae=p.current;ae&&O===a.current&&K(jl(ae.scrollTop))},[K,a]),U=()=>{if(w.current!=="")return;if(C.current){C.current=!1;const ae=X();k(ae);const S=e.indexOf(ae);S>=0&&(A.current=S);return}k(X()),E.current&&window.clearTimeout(E.current);const O=a.current;E.current=window.setTimeout(()=>{O===a.current&&R()},100)},Y="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",ce=Nt*Co,L=ce+Xt*2,B=x!==""?x:null,le=B!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":B??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:J,onBlur:()=>{D(),w.current!==""&&G(w.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:L,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:Y,style:{top:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:t.jsx(j.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:p,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Xt,height:ce,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:U,onMouseUp:R,onTouchEnd:R,children:z.map((O,ae)=>{const S=O!==""&&O===H;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!O,onClick:()=>{if(!O)return;const ee=e.indexOf(O);ee>=0&&K(ee)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:Nt,scrollSnapAlign:"center",color:S?"var(--text-main)":"var(--text-muted)",fontSize:S?16:14,fontWeight:S?600:400,opacity:O?le?S?0:.35:S?1:.35:0},children:O},`wheel-${ae}-${O}`)})}),B!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:Xt+ce/2-Nt/2,height:Nt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:B}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:Y,style:{bottom:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function ql(){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:Nt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Ul({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",b=m||!d,f=Pf({use12Hour:n,hour12:a}),g=s.useRef(e),p=So(e,Hr()),E=ta(p),[v,w]=s.useState(rt(f?E.hour12:p.hour24)),[A,C]=s.useState(rt(p.minute)),[H,k]=s.useState(rt(p.second)),[x,M]=s.useState(E.meridiem),[N,z]=s.useState(0),X=s.useRef(0),K=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[G,V]=s.useState("hour"),ne=s.useMemo(()=>{const se=["hour","minute"];return o&&se.push("second"),f&&se.push("meridiem"),se},[f,o]),J=s.useCallback(se=>{V(he=>{const Ae=ne.indexOf(he);return ne[(Ae+se+ne.length)%ne.length]})},[ne]);s.useEffect(()=>{var se;(se=D.current[G])==null||se.focus()},[G]),s.useEffect(()=>{var se;V("hour"),(se=D.current.hour)==null||se.focus()},[]),s.useEffect(()=>{if(e===g.current)return;g.current=e;const se=So(e,Hr()),he=ta(se);w(rt(f?he.hour12:se.hour24)),C(rt(se.minute)),k(rt(se.second)),M(he.meridiem)},[f,e]);const R=s.useMemo(()=>(f?Eo(1,12):Eo(0,23)).map(se=>rt(se)),[f]),U=s.useMemo(()=>Eo(0,59).map(se=>rt(se)),[]),Y=U,ce=s.useMemo(()=>["AM","PM"],[]),L=s.useCallback(()=>f?fn({hour12:Number(v),minute:Number(A),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(A),second:Number(H)},[v,f,x,A,H]),B=s.useCallback(se=>{if(K.current)return;const he=un(se,o);g.current=he,r(he)},[r,o]),le=s.useCallback(()=>{B(L())},[L,B]),O=se=>{w(se),b&&B(f?fn({hour12:Number(se),minute:Number(A),second:Number(H),meridiem:x}):{hour24:Number(se),minute:Number(A),second:Number(H)})},ae=se=>{C(se),b&&B(f?fn({hour12:Number(v),minute:Number(se),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(se),second:Number(H)})},S=se=>{k(se),b&&B(f?fn({hour12:Number(v),minute:Number(A),second:Number(se),meridiem:x}):{hour24:Number(v),minute:Number(A),second:Number(se)})},ee=se=>{M(se),b&&B(fn({hour12:Number(v),minute:Number(A),second:Number(H),meridiem:se}))},_=s.useCallback(()=>(X.current+=1,z(X.current),X.current),[]),I=s.useCallback(se=>{const he=ta(se),Ae=un(se,o);g.current=Ae,w(rt(f?he.hour12:se.hour24)),C(rt(se.minute)),k(rt(se.second)),M(he.meridiem),r(Ae)},[f,r,o]),de=()=>{K.current=!0,_(),I(Hr()),queueMicrotask(()=>{const se=Hr();un(se,o)!==g.current&&(_(),I(se)),K.current=!1})},re=()=>{le(),d==null||d()},F=Nt*Co,y=F+Xt*2,T=Xt+F/2-Nt/2,te=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:y,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:T,height:Nt,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:Xt,height:Nt*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:Xt,height:Nt*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(ra,{syncEpochRef:X,forceSyncAt:N,values:R,selected:v,onSelect:O,label:"Horas",maxNumeric:f?12:23,isFocused:G==="hour",onFocus:()=>V("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.hour=se}}),t.jsx(ql,{}),t.jsx(ra,{syncEpochRef:X,forceSyncAt:N,values:U,selected:A,onSelect:ae,label:"Minutos",maxNumeric:59,isFocused:G==="minute",onFocus:()=>V("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.minute=se}}),o?t.jsxs(t.Fragment,{children:[t.jsx(ql,{}),t.jsx(ra,{syncEpochRef:X,forceSyncAt:N,values:Y,selected:H,onSelect:S,label:"Segundos",maxNumeric:59,isFocused:G==="second",onFocus:()=>V("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.second=se}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ra,{syncEpochRef:X,forceSyncAt:N,values:ce,selected:x,onSelect:se=>ee(se),width:Ff,label:"AM o PM",isMeridiem:!0,isFocused:G==="meridiem",onFocus:()=>V("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:se=>{D.current.meridiem=se}})}):null]})]})}),fe=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Qe,{variant:"ghost",size:"sm",onClick:de,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Qe,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Qe,{variant:"primary",size:"sm",onClick:re,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?o?300:260:o?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,te,fe]})}function _f(e){return e.use12Hour??e.hour12??!1}function zf({label:e,value:r,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:b,helperText:f,helperDisplay:g,className:p,contentClassName:E,className:v=""}){const w=u==="popover",[A,C]=s.useState(!1),H=s.useRef(null),[k,x]=s.useState({horizontal:"left",vertical:"bottom"}),M=_f({use12Hour:a,hour12:o}),N=s.useMemo(()=>r?Hf(r,{use12Hour:M,showSeconds:l}):"",[M,l,r]);s.useEffect(()=>{if(!w||!A||!H.current)return;const K=H.current.getBoundingClientRect(),D=8,G=M?l?300:260:l?252:212,V=276,ne=K.left+G>window.innerWidth-D,J=K.right-G>=D,R=K.bottom+8+V>window.innerHeight-D,U=K.top-8-V>=D;x({horizontal:ne&&J?"right":"left",vertical:R&&U?"top":"bottom"})},[M,w,A,l]),s.useEffect(()=>{if(!w||!A)return;function K(G){H.current&&(H.current.contains(G.target)||C(!1))}function D(G){G.key==="Escape"&&C(!1)}return document.addEventListener("mousedown",K),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",D)}},[w,A]);const z=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||C(K=>!K)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${v}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":A?"var(--primary)":"var(--border)",color:N?"var(--text-main)":"var(--text-muted)",boxShadow:A?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(j.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:N||c})]}),w?t.jsx(j.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${A?"rotate-180":""}`}):null]}),X=t.jsx(Ul,{variant:w?"popover":"panel",value:r||If(l),onChange:n,use12Hour:M,showSeconds:l,title:i,onClose:()=>C(!1)});return t.jsx(zn,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:p,contentClassName:E,children:w?t.jsxs("div",{ref:H,className:"relative w-full",children:[z,A?t.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:X}):null]}):t.jsxs("div",{className:"space-y-2",children:[z,A?X:null]})})}const Wf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function jf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=Wf[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 Vl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),qf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Uf(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 Xl(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Yl(e){Xl(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Vf(e){const r=e.querySelector(qf);return r instanceof HTMLElement?r:null}function Kl(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Vl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Oa.OverlayScrollbars(l)){Yl(l);return}if(!Uf(l))return;const c={overflow:Xl(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Vf(l),u=d?Oa.OverlayScrollbars({target:l,elements:{viewport:d}},c):Oa.OverlayScrollbars(l,c);Yl(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const o=new MutationObserver(a);return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),o.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(Vl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function rr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Gl(e){try{const r=new URL(e);return rr(r.pathname)}catch{return""}}function Xf(e){const r=rr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return rr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?rr(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":rr(`/${a[0]}`)}const Mo="primeSuiteAppUrl",Yf={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"}},Zl={xs:20,sm:28,md:36,lg:48,xl:64},Ql=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Kf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Gf="bonsaif.bot",Zf="Bonsaif Bot",Qf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Jl(e){return typeof e=="string"?e.trim():""}function Jf(e){var o;if(e!==void 0)return rr(e);const r=rr(typeof process<"u"&&((o=process.env)==null?void 0:o.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(Mo)||"";i&&window.sessionStorage.setItem(Mo,i);const c=window.sessionStorage.getItem(Mo)||"",d=i||c;if(d){const u=Gl(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?Gl(a):rr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Xf(window.location.pathname)}function Rf(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 eb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ql[r%Ql.length]}function tb(e,r){return e===Gf||r===Zf}function rb(e,r){return`${e.replace(/\/$/,"")}${r}`}function Rl({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:b="xs",avatarVersion:f=0,className:g="",style:p}){const[E,v]=s.useState(!1),w=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[w,f]);const{wh:A,text:C}=Yf[a],H=Jl(n)||Jl(r)||c,k=Rf(H),x=Jf(d),M=tb(r,n),N=rb(x,"/favicon.svg"),z=s.useMemo(()=>{if(!w)return"";const V=new URLSearchParams;V.set("size",String(Zl[a])),f&&V.set("v",String(f));const ne=V.toString();return`${x}/api/user/avatar/${encodeURIComponent(w)}${ne?`?${ne}`:""}`},[f,x,w,a]),X=Zl[a],K=M?t.jsx("span",{className:`${A} ${Qf[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${g}`,style:p,children:t.jsx("img",{src:N,alt:H,width:X,height:X,className:"h-full w-full object-contain"})}):z&&!E?t.jsx("img",{src:z,alt:H,width:X,height:X,className:`${A} rounded-full object-cover flex-shrink-0 ${g}`,style:p,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${w}-${f}`):t.jsx("span",{className:`${A} ${eb(H)} ${C} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:p,title:H,children:k});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[K,t.jsx("span",{className:`min-w-0 truncate ${Kf[b]} font-medium text-[var(--text-main)] ${m}`,title:H,children:H})]});const D=l??!0,G=i??H;return D&&G?t.jsx(Bt,{as:"span",content:G,className:`inline-flex flex-shrink-0 ${u}`,children:K}):K}function nb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function ab(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function ei({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=nb}){const[m,b]=s.useState(!1),f=ab(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Kl,{}),t.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:t.jsx(j.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(j.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:t.jsx(j.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([g,p])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(j.HiChevronDown,{className:"h-3.5 w-3.5"}),g]}),t.jsx("div",{className:"space-y-1",children:p.map(E=>{const v=n===E.href||n.startsWith(`${E.href}/`);return t.jsxs(u,{href:E.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${v?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:E.icon??t.jsx(j.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:E.label})]},E.href)})})]},g))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(Rl,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Qe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(j.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const ti="bonsaif-ui:prime-auth-sso",ob={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},To={dashboard:t.jsx(j.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(j.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(j.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(j.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(j.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(j.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(j.HiUser,{className:"h-5 w-5"}),settings:t.jsx(j.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(j.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(j.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(j.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(j.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(j.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(j.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(j.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(j.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(j.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(j.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(j.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(j.HiShieldCheck,{className:"h-5 w-5"})};function sb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function lb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function ib(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=lb(n)&&a?a:n,l=ob[o]??sb(o);return[{label:"Inicio",href:"/"},{label:l}]}function $o(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function cb(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(j.HiHome,{className:"h-5 w-5"});if(To[n])return To[n];const a=r.length>1?r[r.length-2]:"";return To[a]??t.jsx(j.HiHome,{className:"h-5 w-5"})}function db(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function ri(){if(typeof window>"u")return!1;if(db(window.location.href)){try{window.sessionStorage.setItem(ti,"true")}catch{}return!0}try{return window.sessionStorage.getItem(ti)==="true"}catch{return!1}}function ub({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=s.useRef(null),[f,g]=s.useState(!1),[p,E]=s.useState(d??"/"),[v,w]=s.useState(()=>ri()),[A,C]=s.useState(null),H=d??p,k=c??ib(H),x=o??cb(H),M=u&&!v&&k.length>1,N=!M;s.useEffect(()=>{d||E(window.location.pathname)},[d]),s.useEffect(()=>{w(ri())},[]),s.useEffect(()=>{if(m){g(!1);return}let X=null,K=0,D=0;const G=()=>{const J=b.current,R=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??$o(R)??R??window},V=()=>{const J=X&&X!==window?X.scrollTop:window.scrollY;g(R=>R?J>24:J>72)},ne=()=>{X==null||X.removeEventListener("scroll",V),X=G(),X.addEventListener("scroll",V,{passive:!0}),V()};return ne(),K=window.requestAnimationFrame(ne),D=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(K),window.clearTimeout(D),X==null||X.removeEventListener("scroll",V)}},[m]),s.useEffect(()=>{if(m){C(null);return}let X=0;const K=[],D=()=>{const Y=b.current,ce=Y==null?void 0:Y.parentElement,L=document.querySelector("[data-app-scroll='true']"),B=$o(L)??L;if(!Y||!ce||!B){C(null);return}const le=ce.getBoundingClientRect(),O=window.getComputedStyle(ce),ae=B.getBoundingClientRect(),S=B instanceof HTMLElement&&B.clientWidth>0?B.clientWidth:ae.width,ee=le.left+parseFloat(O.paddingLeft||"0"),_={marginLeft:Math.round(ae.left-ee),width:Math.round(S)};C(I=>I&&I.marginLeft===_.marginLeft&&I.width===_.width?I:_)},G=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(D)};G(),window.addEventListener("resize",G);const V=new ResizeObserver(G),ne=b.current,J=ne==null?void 0:ne.parentElement,R=document.querySelector("[data-app-scroll='true']"),U=$o(R)??R;return[J,R,U].forEach(Y=>{Y&&V.observe(Y)}),K.push(window.setTimeout(G,120)),K.push(window.setTimeout(G,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",G),V.disconnect(),K.forEach(Y=>window.clearTimeout(Y))}},[m]);const z={...A?{marginLeft:A.marginLeft,width:A.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:z,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":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 ${f||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 ${f||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 ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:M?"var(--text-secondary)":"var(--text-muted)"},children:x}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(Jo.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function fb({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(ei,{currentPath:r,...a,children:e})}function ni(){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 bb(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 mb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(ni());const d=new MutationObserver(()=>o(ni()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>bb(r,a,n),[n,r,a]),c=s.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return s.useEffect(()=>{if(!n)return;const d=n;function u(m){var g,p,E;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((p=m.data)==null?void 0:p.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((E=m.data)==null?void 0:E.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function hb(){const[e,r]=s.useState(""),[n,a]=s.useState(!1),[o,l]=s.useState({width:96,height:96});return s.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),s.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:ai(c.data.width,96,720),height:ai(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 ai(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function pb(e){const r=document.documentElement,n=new MutationObserver(e);n.observe(r,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function gb(){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 vb(){return"light"}function xb({position:e="bottom-center"}){const r=s.useSyncExternalStore(pb,gb,vb);return t.jsx(Ha.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function yb({title:e,subtitle:r,actions:n,loading:a=!1,empty:o=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):o?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const bn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function oi(e,r){return e.color??bn[r%bn.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 kt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Ir(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ao={warning:70,danger:90};function na(e,r=Ao){const n=r.warning??Ao.warning,a=r.danger??Ao.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function mn(e,r){return zt(na(e,r))}function Br(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Fr(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const o=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<o.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${o[i]}`}function si(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",o=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(o<1024)return`${a}${Math.round(o)} ${l[0]}`;let i=o/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function Pr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Ir((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function St({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 Et({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const nr=680,fr="ease-out",wb={top:18,right:8,bottom:12,left:0};function hn(e){return{...wb,...e}}function pn(e){return e.map((r,n)=>({...r,color:oi(r,n),label:r.label??r.key}))}function aa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Ir(n[a.key])===null))}function Ct(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function gn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function li(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function oa(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Nb(e,r=kt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function ii(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function kb({active:e,label:r,payload:n,valueFormat:a=kt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(g=>g.dataKey!=="base"&&g.name!=="base"&&g.value!==null&&g.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=o[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=o[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((g,p)=>{const E=g.payload,v=E&&typeof E.display=="number"?E.display:g.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:g.color??"var(--primary)"}}),g.name??g.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Nb(v,a)})]},String(g.dataKey??g.name??p))})})]})}function _r({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Me.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...o},content:r??t.jsx(kb,{valueFormat:e})})}function ci(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function di(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),o=Math.min(n-1,Math.max(e,r));return o-a<1||a===0&&o>=n-1?null:{startIndex:a,endIndex:o}}function sa(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,m]=s.useState(null),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),g=b&&(o==="drag"||o==="both"),p=s.useCallback(K=>{d(K),i==null||i(K)},[i]),E=s.useCallback(()=>{m(null),p(null)},[p]),v=!!c,w=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),A=s.useCallback((K,D)=>{const G=ci(e,r,K),V=ci(e,r,D);G<0||V<0||p(di(G,V,e.length))},[p,e,r]),C=s.useCallback(K=>{g&&((K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m({leftLabel:K.activeLabel,rightLabel:K.activeLabel}))},[g]),H=s.useCallback(K=>{!g||!u||(K==null?void 0:K.activeLabel)===void 0||(K==null?void 0:K.activeLabel)===null||m(D=>D&&{...D,rightLabel:K.activeLabel})},[u,g]),k=s.useCallback(()=>{if(g){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}A(u.leftLabel,u.rightLabel),m(null)}},[A,u,g]),x=s.useCallback(K=>{if(f){if(!K){p(null);return}p(di(K.startIndex??0,K.endIndex??e.length-1,e.length))}},[p,e.length,f]),M=g?{onMouseDown:C,onMouseMove:H,onMouseUp:k,onMouseLeave:()=>{u&&k()}}:{},N=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},z=t.jsxs(t.Fragment,{children:[g&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Me.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Me.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:N.startIndex,endIndex:N.endIndex,onChange:x,tickFormatter:K=>String(K)}):null]}),X=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:w,isZoomed:v,resetZoom:E,chartHandlers:M,zoomNodes:z,marginExtra:X}}function la({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Sb({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=kt,yDomain:f,ariaLabel:g="Gráfico de líneas",curve:p=!0,strokeWidth:E=2.25,zoomable:v=!1,zoomMode:w="both",brushHeight:A,onZoomChange:C}){const H=aa(e,n),k=pn(n),x=sa(e,r,{zoomable:v,zoomMode:w,brushHeight:A,onZoomChange:C}),M=hn({...m,...x.marginExtra});return l?t.jsx(St,{height:a}):H?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.LineChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:li(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,k.map((N,z)=>t.jsx(Me.Line,{type:p?"monotone":"linear",dataKey:N.key,name:N.label,stroke:N.color,strokeWidth:z===0?E+.35:E,strokeOpacity:z===0?1:.88,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),x.zoomNodes]})})]})}function ia({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=kt,yDomain:f,ariaLabel:g="Gráfico de área",stacked:p=!1,opacity:E=.22,zoomable:v=!1,zoomMode:w="both",brushHeight:A,onZoomChange:C}){const H=aa(e,n),k=pn(n),x=sa(e,r,{zoomable:v,zoomMode:w,brushHeight:A,onZoomChange:C}),M=hn({...m,...x.marginExtra});return l?t.jsx(St,{height:a}):H?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.AreaChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[t.jsx("defs",{children:k.map(N=>t.jsxs("linearGradient",{id:ii(N.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:N.color,stopOpacity:Math.min(.55,E+.28)}),t.jsx("stop",{offset:"48%",stopColor:N.color,stopOpacity:E*.5}),t.jsx("stop",{offset:"100%",stopColor:N.color,stopOpacity:0})]},N.key))}),c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{stroke:li(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,k.map(N=>t.jsx(Me.Area,{type:"monotone",dataKey:N.key,name:N.label,stroke:N.color,fill:`url(#${ii(N.key)})`,strokeWidth:2.25,stackId:p?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),x.zoomNodes]})})]})}function Eb({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=kt,yDomain:f,ariaLabel:g="Gráfico de barras",layout:p="vertical",mode:E="grouped",barRadius:v=6,categoryAxisWidth:w=64,zoomable:A=!1,zoomMode:C="both",brushHeight:H,onZoomChange:k}){const x=aa(e,n),M=pn(n),N=p==="horizontal",z=sa(e,r,{zoomable:A&&!N,zoomMode:C,brushHeight:H,onZoomChange:k}),X=hn({...m,...z.marginExtra});return l?t.jsx(St,{height:a}):x?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(la,{visible:z.isZoomed,onReset:z.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:z.viewData,margin:X,layout:N?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...z.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!N,vertical:N}):null,N?t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{type:"number",tick:Ct(),tickLine:!1,axisLine:!1,tickFormatter:K=>b(Number(K)),domain:f??["auto","auto"]}),t.jsx(Me.YAxis,{type:"category",dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,width:w})]}):t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:K=>b(Number(K)),dx:-2})]}),u?t.jsx(_r,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,M.map((K,D)=>t.jsx(Me.Bar,{dataKey:K.key,name:K.label,fill:K.color,fillOpacity:D===0?1:.82,radius:N?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:E==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:nr,animationEasing:fr},K.key)),z.zoomNodes]})})]})}function Cb(e){return t.jsx(fi,{...e,variant:"pie"})}function Mb(e){return t.jsx(fi,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function ui(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function fi({data:e,nameKey:r,valueKey:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=kt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:g=[...bn],padAngle:p,cornerRadius:E,variant:v}){const w=e.map((D,G)=>({name:String(D[r]??""),value:Ir(D[n])??0,fill:g[G%g.length],row:D})).filter(D=>D.value>0),A=!w.length,C=v==="donut",H=w.length,k=ui(b,C?62:12),x=ui(f,78),M=Math.min(p??(C?2:3),Math.max(.5,10/Math.max(1,H))),N=Math.min(E??(C?10:8),Math.max(2,36/Math.max(1,H)));if(l)return t.jsx(St,{height:a});if(A)return t.jsx(Et,{height:a,text:i});const z=w.reduce((D,G)=>D+G.value,0),X=c?Math.min(96,28+Math.ceil(H/3)*22):0,K=Math.max(140,a-X);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":m??(v==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:K},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(_r,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Me.Pie,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${k}%`,outerRadius:`${x}%`,startAngle:90,endAngle:-270,paddingAngle:M,cornerRadius:N,minAngle:H>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,label:!1,activeShape:Tb,children:w.map(D=>t.jsx(Me.Cell,{fill:D.fill},D.name))}),C?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(z)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:w.map(D=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:D.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:D.name,children:D.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(D.value)})]},D.name))}):null]})})}function Tb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Me.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function $b({data:e,dataKey:r,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??zt(o),m=e.map(x=>Ir(x[r])).filter(x=>x!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,g=3,p=1,E=Math.min(...m),w=Math.max(...m)-E||1,A=m.map((x,M)=>{const N=p+M/(m.length-1)*(b-p*2),z=f-g-(x-E)/w*(f-g*2);return{x:N,y:z}}),C=A.map((x,M)=>`${M===0?"M":"L"}${x.x.toFixed(2)} ${x.y.toFixed(2)}`).join(" "),H=`${C} L${A[A.length-1].x.toFixed(2)} ${f} L${A[0].x.toFixed(2)} ${f} Z`,k=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:H,fill:`url(#${k})`}):null,t.jsx("path",{d:C,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Ab({data:e,xKey:r,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:b=!0,margin:f,valueFormat:g=kt,yDomain:p,ariaLabel:E="Gráfico combinado",barRadius:v=6,zoomable:w=!1,zoomMode:A="both",brushHeight:C,onZoomChange:H}){const k=a??n.slice(0,Math.max(1,n.length-1)),x=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),M=[...k,...x.filter(V=>!k.some(ne=>ne.key===V.key))],N=aa(e,M),z=pn(k),X=pn(M),K=x.map(V=>{var J;const ne=X.find(R=>R.key===V.key);return{...V,label:V.label??V.key,color:V.color??(ne==null?void 0:ne.color)??((J=X[0])==null?void 0:J.color)}}),D=sa(e,r,{zoomable:w,zoomMode:A,brushHeight:C,onZoomChange:H}),G=hn({...f,...D.marginExtra});return c?t.jsx(St,{height:l}):N?t.jsx(Et,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":E,style:{height:l},children:[t.jsx(la,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.ComposedChart,{data:D.viewData,margin:G,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:V=>g(Number(V)),dx:-2}),b?t.jsx(_r,{valueFormat:g,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:oa()}):null,z.map(V=>t.jsx(Me.Bar,{dataKey:V.key,name:V.label,fill:V.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:nr,animationEasing:fr},V.key)),K.map(V=>t.jsx(Me.Line,{type:"monotone",dataKey:V.key,name:V.label,stroke:V.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:V.color}},V.key)),D.zoomNodes]})})]})}function Lb({data:e,xKey:r,valueKey:n,typeKey:a,height:o=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=kt,ariaLabel:f="Gráfico waterfall",increaseColor:g="#34d399",decreaseColor:p="#f87171",totalColor:E="var(--primary)"}){const v=s.useMemo(()=>Db(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:p,totalColor:E}),[e,r,n,a,g,p,E]),w=!v.length,A=hn(m);return i?t.jsx(St,{height:o}):w?t.jsx(Et,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:v,margin:A,barCategoryGap:"42%",children:[d?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:"label",tick:Ct(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Me.YAxis,{tick:Ct(),tickLine:!1,axisLine:!1,width:44,tickFormatter:C=>b(Number(C)),dx:-2}),u?t.jsx(_r,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Me.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Me.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:nr,animationEasing:fr,children:v.map(C=>t.jsx(Me.Cell,{fill:C.color},C.label))})]})})})}function Db(e,r){let n=0;return e.map((a,o)=>{const l=Ir(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const bi="bonsaif-funnel-chart-keyframes",Ob=`
|
|
44
|
+
`}),H.map(j=>{const y=Hf(j.colorIndex);return C===j.id?t.jsx("input",{ref:J,value:P,disabled:o,onChange:T=>V(T.target.value),onKeyDown:T=>N(T,j.id),onBlur:()=>de(j.id,P),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(P.length+2,6)}ch`}},j.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:y.bg,color:y.text,border:`1px solid ${y.border}`},children:[t.jsx("span",{className:"truncate",children:j.value}),t.jsx("button",{type:"button","aria-label":`Editar "${j.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),I(j)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(W.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${j.value}"`,disabled:o,tabIndex:-1,onClick:T=>{T.stopPropagation(),B(j.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})})]},j.id)}),!te&&t.jsx("input",{ref:le,value:S,disabled:o,placeholder:H.length===0?a:"",onChange:j=>x(j.target.value),onKeyDown:oe,onPaste:ae,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),t.jsx($r,{error:p,helperText:b,helperDisplay:f})]})}const _f=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function tt(e){return String(e).padStart(2,"0")}function To(e,r=Ir()){const n=e.trim();if(!n)return r;const a=n.match(_f);if(!a)return r;const o=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(i)||o<0||o>23||l<0||l>59||i<0||i>59?r:{hour24:o,minute:l,second:i}}function un(e,r=!0){const n=`${tt(e.hour24)}:${tt(e.minute)}`;return r?`${n}:${tt(e.second)}`:n}function ra(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function fn(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function zf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=To(e);if(n){const l=ra(o),i=`${l.hour12}:${tt(l.minute)}`;return`${a?`${i}:${tt(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Ir(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function Wf(e=!0){return un(Ir(),e)}function $o(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const wt=36,Ao=5,Vl=Math.floor(Ao/2),jf=52,qf=48,Xt=18;function Yl(e){return e*wt}function Xl(e){return Math.round(e/wt)}function Uf(e){return e.use12Hour??e.hour12??!1}function na({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=jf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:p}){const g=s.useRef(null),k=s.useRef(null),v=s.useRef(null),A=s.useRef(""),E=s.useRef(0),M=s.useRef(!1),[H,S]=s.useState(r),[x,C]=s.useState(""),w=s.useCallback(I=>{A.current=I,C(I)},[]),P=s.useMemo(()=>[...Array(Vl).fill(""),...e,...Array(Vl).fill("")],[e]),V=s.useCallback(()=>{const I=g.current;if(!I)return r;const oe=Xl(I.scrollTop),N=Math.min(Math.max(oe,0),e.length-1);return e[N]??r},[r,e]),X=s.useCallback((I,oe=!0)=>{const N=Math.min(Math.max(I,0),e.length-1),R=e[N],ae=g.current;!ae||!R||(k.current&&(window.clearTimeout(k.current),k.current=null),M.current=!0,E.current=N,ae.scrollTop=Yl(N),S(R),oe&&R!==r&&n(R))},[n,r,e]);s.useLayoutEffect(()=>{k.current&&(window.clearTimeout(k.current),k.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),w(""),S(r);const I=e.indexOf(r);if(I>=0&&(E.current=I),I<0||!g.current)return;const oe=Yl(I);g.current.scrollTop!==oe&&(g.current.scrollTop=oe)},[o,r,w,e]);const O=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),K=s.useCallback((I,oe=!1)=>{O(),w("");const N=Number(I);if(!Number.isFinite(N))return;const R=Math.min(c,Math.max(0,N));let ae=tt(R),$=e.indexOf(ae);if($<0){const ne=Math.min(e.length-1,Math.max(0,R-(c===12?1:0)));ae=e[ne]??ae,$=e.indexOf(ae)}$>=0&&X($),oe&&(b==null||b())},[O,c,b,X,w,e]),q=s.useCallback(I=>{const oe=Math.floor(c/10),N=A.current;if(N===""){if(I>oe){K(String(I),!0);return}const ae=String(I);w(ae),v.current=window.setTimeout(()=>{K(A.current,!0)},1200);return}O();const R=+`${N}${I}`;R<=c?K(String(R),!0):K(String(I),!0)},[O,K,c,w]),le=s.useCallback(I=>{O(),w(""),X(E.current+I)},[O,X,w]),J=I=>{if(d){I.key==="a"||I.key==="A"?(I.preventDefault(),n("AM"),b==null||b()):I.key==="p"||I.key==="P"?(I.preventDefault(),n("PM"),b==null||b()):I.key==="ArrowUp"||I.key==="ArrowDown"?(I.preventDefault(),n(r==="AM"?"PM":"AM")):I.key==="Tab"&&(I.preventDefault(),I.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(I.key)){I.preventDefault(),q(Number(I.key));return}I.key==="ArrowUp"?(I.preventDefault(),le(-1)):I.key==="ArrowDown"?(I.preventDefault(),le(1)):I.key==="Tab"&&(I.preventDefault(),O(),A.current!==""&&K(A.current,!1),I.shiftKey?f==null||f():b==null||b())},G=s.useCallback(()=>{const I=a.current,oe=g.current;oe&&I===a.current&&X(Xl(oe.scrollTop))},[X,a]),U=()=>{if(A.current!=="")return;if(M.current){M.current=!1;const oe=V();S(oe);const N=e.indexOf(oe);N>=0&&(E.current=N);return}S(V()),k.current&&window.clearTimeout(k.current);const I=a.current;k.current=window.setTimeout(()=>{I===a.current&&G()},100)},Y="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",ue=wt*Ao,L=ue+Xt*2,B=x!==""?x:null,de=B!==null;return t.jsxs("div",{ref:p,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":B??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:J,onBlur:()=>{O(),A.current!==""&&K(A.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:L,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:Y,style:{top:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>le(-1),children:t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:g,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Xt,height:ue,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:U,onMouseUp:G,onTouchEnd:G,children:P.map((I,oe)=>{const N=I!==""&&I===H;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!I,onClick:()=>{if(!I)return;const R=e.indexOf(I);R>=0&&X(R)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:wt,scrollSnapAlign:"center",color:N?"var(--text-main)":"var(--text-muted)",fontSize:N?16:14,fontWeight:N?600:400,opacity:I?de?N?0:.35:N?1:.35:0},children:I},`wheel-${oe}-${I}`)})}),B!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:Xt+ue/2-wt/2,height:wt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:B}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:Y,style:{bottom:0,height:Xt,color:"var(--text-muted)",opacity:.35},onClick:()=>le(1),children:t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Kl(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:wt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Gl({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",b=m||!d,f=Uf({use12Hour:n,hour12:a}),p=s.useRef(e),g=To(e,Ir()),k=ra(g),[v,A]=s.useState(tt(f?k.hour12:g.hour24)),[E,M]=s.useState(tt(g.minute)),[H,S]=s.useState(tt(g.second)),[x,C]=s.useState(k.meridiem),[w,P]=s.useState(0),V=s.useRef(0),X=s.useRef(!1),O=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[K,q]=s.useState("hour"),le=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,o]),J=s.useCallback(ie=>{q(he=>{const Te=le.indexOf(he);return le[(Te+ie+le.length)%le.length]})},[le]);s.useEffect(()=>{var ie;(ie=O.current[K])==null||ie.focus()},[K]),s.useEffect(()=>{var ie;q("hour"),(ie=O.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const ie=To(e,Ir()),he=ra(ie);A(tt(f?he.hour12:ie.hour24)),M(tt(ie.minute)),S(tt(ie.second)),C(he.meridiem)},[f,e]);const G=s.useMemo(()=>(f?$o(1,12):$o(0,23)).map(ie=>tt(ie)),[f]),U=s.useMemo(()=>$o(0,59).map(ie=>tt(ie)),[]),Y=U,ue=s.useMemo(()=>["AM","PM"],[]),L=s.useCallback(()=>f?fn({hour12:Number(v),minute:Number(E),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(E),second:Number(H)},[v,f,x,E,H]),B=s.useCallback(ie=>{if(X.current)return;const he=un(ie,o);p.current=he,r(he)},[r,o]),de=s.useCallback(()=>{B(L())},[L,B]),I=ie=>{A(ie),b&&B(f?fn({hour12:Number(ie),minute:Number(E),second:Number(H),meridiem:x}):{hour24:Number(ie),minute:Number(E),second:Number(H)})},oe=ie=>{M(ie),b&&B(f?fn({hour12:Number(v),minute:Number(ie),second:Number(H),meridiem:x}):{hour24:Number(v),minute:Number(ie),second:Number(H)})},N=ie=>{S(ie),b&&B(f?fn({hour12:Number(v),minute:Number(E),second:Number(ie),meridiem:x}):{hour24:Number(v),minute:Number(E),second:Number(ie)})},R=ie=>{C(ie),b&&B(fn({hour12:Number(v),minute:Number(E),second:Number(H),meridiem:ie}))},ae=s.useCallback(()=>(V.current+=1,P(V.current),V.current),[]),$=s.useCallback(ie=>{const he=ra(ie),Te=un(ie,o);p.current=Te,A(tt(f?he.hour12:ie.hour24)),M(tt(ie.minute)),S(tt(ie.second)),C(he.meridiem),r(Te)},[f,r,o]),ne=()=>{X.current=!0,ae(),$(Ir()),queueMicrotask(()=>{const ie=Ir();un(ie,o)!==p.current&&(ae(),$(ie)),X.current=!1})},te=()=>{de(),d==null||d()},j=wt*Ao,y=j+Xt*2,T=Xt+j/2-wt/2,ee=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:y,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:T,height:wt,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:Xt,height:wt*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:Xt,height:wt*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(na,{syncEpochRef:V,forceSyncAt:w,values:G,selected:v,onSelect:I,label:"Horas",maxNumeric:f?12:23,isFocused:K==="hour",onFocus:()=>q("hour"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.hour=ie}}),t.jsx(Kl,{}),t.jsx(na,{syncEpochRef:V,forceSyncAt:w,values:U,selected:E,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:K==="minute",onFocus:()=>q("minute"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Kl,{}),t.jsx(na,{syncEpochRef:V,forceSyncAt:w,values:Y,selected:H,onSelect:N,label:"Segundos",maxNumeric:59,isFocused:K==="second",onFocus:()=>q("second"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(na,{syncEpochRef:V,forceSyncAt:w,values:ue,selected:x,onSelect:ie=>R(ie),width:qf,label:"AM o PM",isMeridiem:!0,isFocused:K==="meridiem",onFocus:()=>q("meridiem"),onAdvance:()=>J(1),onBack:()=>J(-1),setColumnRef:ie=>{O.current.meridiem=ie}})}):null]})]})}),fe=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ge,{variant:"ghost",size:"sm",onClick:ne,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ge,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ge,{variant:"primary",size:"sm",onClick:te,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?o?300:260:o?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,ee,fe]})}function Vf(e){return e.use12Hour??e.hour12??!1}function Yf({label:e,value:r,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:b,helperText:f,helperDisplay:p,className:g,contentClassName:k,className:v=""}){const A=u==="popover",[E,M]=s.useState(!1),H=s.useRef(null),[S,x]=s.useState({horizontal:"left",vertical:"bottom"}),C=Vf({use12Hour:a,hour12:o}),w=s.useMemo(()=>r?zf(r,{use12Hour:C,showSeconds:l}):"",[C,l,r]);s.useEffect(()=>{if(!A||!E||!H.current)return;const X=H.current.getBoundingClientRect(),O=8,K=C?l?300:260:l?252:212,q=276,le=X.left+K>window.innerWidth-O,J=X.right-K>=O,G=X.bottom+8+q>window.innerHeight-O,U=X.top-8-q>=O;x({horizontal:le&&J?"right":"left",vertical:G&&U?"top":"bottom"})},[C,A,E,l]),s.useEffect(()=>{if(!A||!E)return;function X(K){H.current&&(H.current.contains(K.target)||M(!1))}function O(K){K.key==="Escape"&&M(!1)}return document.addEventListener("mousedown",X),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",O)}},[A,E]);const P=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||M(X=>!X)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${v}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":E?"var(--primary)":"var(--border)",color:w?"var(--text-main)":"var(--text-muted)",boxShadow:E?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(W.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:w||c})]}),A?t.jsx(W.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${E?"rotate-180":""}`}):null]}),V=t.jsx(Gl,{variant:A?"popover":"panel",value:r||Wf(l),onChange:n,use12Hour:C,showSeconds:l,title:i,onClose:()=>M(!1)});return t.jsx(Wn,{label:e,required:m,error:b,helperText:f,helperDisplay:p,className:g,contentClassName:k,children:A?t.jsxs("div",{ref:H,className:"relative w-full",children:[P,E?t.jsx("div",{className:"absolute z-50",style:{...S.horizontal==="left"?{left:0}:{right:0},...S.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:V}):null]}):t.jsxs("div",{className:"space-y-2",children:[P,E?V:null]})})}const Xf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Kf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=Xf[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${o}`,style:{width:i.width,height:i.height,background:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:e?"var(--primary-fg)":"var(--text-muted)"}})})}const Zl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Gf=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Zf(e){if(!(e instanceof HTMLElement)||e.dataset.overlayScroll==="false"||e.matches("[data-overlayscrollbars]")||e.closest("[data-overlayscrollbars]")||e.matches("textarea,input,select,[contenteditable='true']"))return!1;const r=window.getComputedStyle(e);return!(![r.overflow,r.overflowX,r.overflowY].join(" ").match(/auto|scroll/)||e.clientWidth===0&&e.clientHeight===0)}function Ql(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Jl(e){Ql(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Qf(e){const r=e.querySelector(Gf);return r instanceof HTMLElement?r:null}function Rl(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(Zl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ha.OverlayScrollbars(l)){Jl(l);return}if(!Zf(l))return;const c={overflow:Ql(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Qf(l),u=d?Ha.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ha.OverlayScrollbars(l,c);Jl(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const o=new MutationObserver(a);return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),o.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(Zl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function nr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function ei(e){try{const r=new URL(e);return nr(r.pathname)}catch{return""}}function Jf(e){const r=nr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return nr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?nr(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":nr(`/${a[0]}`)}const Lo="primeSuiteAppUrl",Rf={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},ti={xs:20,sm:28,md:36,lg:48,xl:64},ri=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],eb={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},tb="bonsaif.bot",rb="Bonsaif Bot",nb={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function ni(e){return typeof e=="string"?e.trim():""}function ab(e){var o;if(e!==void 0)return nr(e);const r=nr(typeof process<"u"&&((o=process.env)==null?void 0:o.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(Lo)||"";i&&window.sessionStorage.setItem(Lo,i);const c=window.sessionStorage.getItem(Lo)||"",d=i||c;if(d){const u=ei(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?ei(a):nr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Jf(window.location.pathname)}function ob(e){const r=e.split(/\s+/).map(n=>n.trim()).filter(Boolean);return r.length===0?"?":r.length===1?r[0].slice(0,1).toUpperCase():`${r[0].slice(0,1)}${r[1].slice(0,1)}`.toUpperCase()}function sb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return ri[r%ri.length]}function lb(e,r){return e===tb||r===rb}function ib(e,r){return`${e.replace(/\/$/,"")}${r}`}function ai({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:b="xs",avatarVersion:f=0,className:p="",style:g}){const[k,v]=s.useState(!1),A=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[A,f]);const{wh:E,text:M}=Rf[a],H=ni(n)||ni(r)||c,S=ob(H),x=ab(d),C=lb(r,n),w=ib(x,"/favicon.svg"),P=s.useMemo(()=>{if(!A)return"";const q=new URLSearchParams;q.set("size",String(ti[a])),f&&q.set("v",String(f));const le=q.toString();return`${x}/api/user/avatar/${encodeURIComponent(A)}${le?`?${le}`:""}`},[f,x,A,a]),V=ti[a],X=C?t.jsx("span",{className:`${E} ${nb[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${p}`,style:g,children:t.jsx("img",{src:w,alt:H,width:V,height:V,className:"h-full w-full object-contain"})}):P&&!k?t.jsx("img",{src:P,alt:H,width:V,height:V,className:`${E} rounded-full object-cover flex-shrink-0 ${p}`,style:g,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${A}-${f}`):t.jsx("span",{className:`${E} ${sb(H)} ${M} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:g,title:H,children:S});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[X,t.jsx("span",{className:`min-w-0 truncate ${eb[b]} font-medium text-[var(--text-main)] ${m}`,title:H,children:H})]});const O=l??!0,K=i??H;return O&&K?t.jsx(Ft,{as:"span",content:K,className:`inline-flex flex-shrink-0 ${u}`,children:X}):X}function cb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function db(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function oi({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=cb}){const[m,b]=s.useState(!1),f=db(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Rl,{}),t.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>b(!0),children:t.jsx(W.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(W.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>b(!1),children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([p,g])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"}),p]}),t.jsx("div",{className:"space-y-1",children:g.map(k=>{const v=n===k.href||n.startsWith(`${k.href}/`);return t.jsxs(u,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${v?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:k.icon??t.jsx(W.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:k.label})]},k.href)})})]},p))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(ai,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Ge,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(W.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const si="bonsaif-ui:prime-auth-sso",ub={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},Do={dashboard:t.jsx(W.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(W.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(W.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(W.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(W.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(W.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(W.HiUser,{className:"h-5 w-5"}),settings:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(W.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(W.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(W.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(W.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(W.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(W.HiShieldCheck,{className:"h-5 w-5"})};function fb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function bb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function mb(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,o=bb(n)&&a?a:n,l=ub[o]??fb(o);return[{label:"Inicio",href:"/"},{label:l}]}function Oo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function hb(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(W.HiHome,{className:"h-5 w-5"});if(Do[n])return Do[n];const a=r.length>1?r[r.length-2]:"";return Do[a]??t.jsx(W.HiHome,{className:"h-5 w-5"})}function pb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function li(){if(typeof window>"u")return!1;if(pb(window.location.href)){try{window.sessionStorage.setItem(si,"true")}catch{}return!0}try{return window.sessionStorage.getItem(si)==="true"}catch{return!1}}function gb({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=s.useRef(null),[f,p]=s.useState(!1),[g,k]=s.useState(d??"/"),[v,A]=s.useState(()=>li()),[E,M]=s.useState(null),H=d??g,S=c??mb(H),x=o??hb(H),C=u&&!v&&S.length>1,w=!C;s.useEffect(()=>{d||k(window.location.pathname)},[d]),s.useEffect(()=>{A(li())},[]),s.useEffect(()=>{if(m){p(!1);return}let V=null,X=0,O=0;const K=()=>{const J=b.current,G=document.querySelector("[data-app-scroll='true']");return(J==null?void 0:J.closest(".os-viewport"))??(J==null?void 0:J.closest("[data-overlayscrollbars-viewport]"))??Oo(G)??G??window},q=()=>{const J=V&&V!==window?V.scrollTop:window.scrollY;p(G=>G?J>24:J>72)},le=()=>{V==null||V.removeEventListener("scroll",q),V=K(),V.addEventListener("scroll",q,{passive:!0}),q()};return le(),X=window.requestAnimationFrame(le),O=window.setTimeout(le,120),()=>{window.cancelAnimationFrame(X),window.clearTimeout(O),V==null||V.removeEventListener("scroll",q)}},[m]),s.useEffect(()=>{if(m){M(null);return}let V=0;const X=[],O=()=>{const Y=b.current,ue=Y==null?void 0:Y.parentElement,L=document.querySelector("[data-app-scroll='true']"),B=Oo(L)??L;if(!Y||!ue||!B){M(null);return}const de=ue.getBoundingClientRect(),I=window.getComputedStyle(ue),oe=B.getBoundingClientRect(),N=B instanceof HTMLElement&&B.clientWidth>0?B.clientWidth:oe.width,R=de.left+parseFloat(I.paddingLeft||"0"),ae={marginLeft:Math.round(oe.left-R),width:Math.round(N)};M($=>$&&$.marginLeft===ae.marginLeft&&$.width===ae.width?$:ae)},K=()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(O)};K(),window.addEventListener("resize",K);const q=new ResizeObserver(K),le=b.current,J=le==null?void 0:le.parentElement,G=document.querySelector("[data-app-scroll='true']"),U=Oo(G)??G;return[J,G,U].forEach(Y=>{Y&&q.observe(Y)}),X.push(window.setTimeout(K,120)),X.push(window.setTimeout(K,280)),()=>{window.cancelAnimationFrame(V),window.removeEventListener("resize",K),q.disconnect(),X.forEach(Y=>window.clearTimeout(Y))}},[m]);const P={...E?{marginLeft:E.marginLeft,width:E.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:P,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":w?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||w?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:C?"var(--text-secondary)":"var(--text-muted)"},children:x}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(rs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function vb({children:e,currentPath:r=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(r)?t.jsx(t.Fragment,{children:e}):t.jsx(oi,{currentPath:r,...a,children:e})}function ii(){if(typeof window>"u")return"system";const e=localStorage.getItem("theme");return e==="light"||e==="dark"?e:e==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function yb(e,r,n){try{const a=new URL(e),o=a.searchParams.get("callbackUrl");if(o){const l=new URL(o,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function xb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(ii());const d=new MutationObserver(()=>o(ii()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>yb(r,a,n),[n,r,a]),c=s.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return s.useEffect(()=>{if(!n)return;const d=n;function u(m){var p,g,k;if(m.source!==((p=l.current)==null?void 0:p.contentWindow)||c&&m.origin!==c)return;if(((g=m.data)==null?void 0:g.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((k=m.data)==null?void 0:k.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function wb(){const[e,r]=s.useState(""),[n,a]=s.useState(!1),[o,l]=s.useState({width:96,height:96});return s.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),s.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:ci(c.data.width,96,720),height:ci(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${o.width}px, 100vw)`:96,height:n?`min(${o.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function ci(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Nb(e){const r=document.documentElement,n=new MutationObserver(e);n.observe(r,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function kb(){const e=localStorage.getItem("theme")||"system",r=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||e==="dark"||e==="system"&&r?"dark":"light"}function Sb(){return"light"}function Eb({position:e="bottom-center"}){const r=s.useSyncExternalStore(Nb,kb,Sb);return t.jsx(Ia.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Cb({title:e,subtitle:r,actions:n,loading:a=!1,empty:o=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):o?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const bn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function di(e,r){return e.color??bn[r%bn.length]}function Wt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const Nt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Br(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ho={warning:70,danger:90};function aa(e,r=Ho){const n=r.warning??Ho.warning,a=r.danger??Ho.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function mn(e,r){return Wt(aa(e,r))}function Fr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Pr(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const o=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<o.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${o[i]}`}function ui(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",o=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(o<1024)return`${a}${Math.round(o)} ${l[0]}`;let i=o/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function _r(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Br((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function kt({height:e}){return t.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:t.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function St({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const ar=680,br="ease-out",Mb={top:18,right:8,bottom:12,left:0};function hn(e){return{...Mb,...e}}function pn(e){return e.map((r,n)=>({...r,color:di(r,n),label:r.label??r.key}))}function oa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Br(n[a.key])===null))}function Et(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function gn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function fi(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function sa(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Tb(e,r=Nt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function bi(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function $b({active:e,label:r,payload:n,valueFormat:a=Nt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(p=>p.dataKey!=="base"&&p.name!=="base"&&p.value!==null&&p.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=o[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=o[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((p,g)=>{const k=p.payload,v=k&&typeof k.display=="number"?k.display:p.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:p.color??"var(--primary)"}}),p.name??p.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Tb(v,a)})]},String(p.dataKey??p.name??g))})})]})}function zr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Me.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...o},content:r??t.jsx($b,{valueFormat:e})})}function mi(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function hi(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),o=Math.min(n-1,Math.max(e,r));return o-a<1||a===0&&o>=n-1?null:{startIndex:a,endIndex:o}}function la(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,m]=s.useState(null),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),p=b&&(o==="drag"||o==="both"),g=s.useCallback(X=>{d(X),i==null||i(X)},[i]),k=s.useCallback(()=>{m(null),g(null)},[g]),v=!!c,A=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),E=s.useCallback((X,O)=>{const K=mi(e,r,X),q=mi(e,r,O);K<0||q<0||g(hi(K,q,e.length))},[g,e,r]),M=s.useCallback(X=>{p&&((X==null?void 0:X.activeLabel)===void 0||(X==null?void 0:X.activeLabel)===null||m({leftLabel:X.activeLabel,rightLabel:X.activeLabel}))},[p]),H=s.useCallback(X=>{!p||!u||(X==null?void 0:X.activeLabel)===void 0||(X==null?void 0:X.activeLabel)===null||m(O=>O&&{...O,rightLabel:X.activeLabel})},[u,p]),S=s.useCallback(()=>{if(p){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}E(u.leftLabel,u.rightLabel),m(null)}},[E,u,p]),x=s.useCallback(X=>{if(f){if(!X){g(null);return}g(hi(X.startIndex??0,X.endIndex??e.length-1,e.length))}},[g,e.length,f]),C=p?{onMouseDown:M,onMouseMove:H,onMouseUp:S,onMouseLeave:()=>{u&&S()}}:{},w=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},P=t.jsxs(t.Fragment,{children:[p&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Me.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Me.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:w.startIndex,endIndex:w.endIndex,onChange:x,tickFormatter:X=>String(X)}):null]}),V=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:p,viewData:A,isZoomed:v,resetZoom:k,chartHandlers:C,zoomNodes:P,marginExtra:V}}function ia({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Ab({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=Nt,yDomain:f,ariaLabel:p="Gráfico de líneas",curve:g=!0,strokeWidth:k=2.25,zoomable:v=!1,zoomMode:A="both",brushHeight:E,onZoomChange:M}){const H=oa(e,n),S=pn(n),x=la(e,r,{zoomable:v,zoomMode:A,brushHeight:E,onZoomChange:M}),C=hn({...m,...x.marginExtra});return l?t.jsx(kt,{height:a}):H?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ia,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.LineChart,{data:x.viewData,margin:C,...x.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{stroke:fi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,S.map((w,P)=>t.jsx(Me.Line,{type:g?"monotone":"linear",dataKey:w.key,name:w.label,stroke:w.color,strokeWidth:P===0?k+.35:k,strokeOpacity:P===0?1:.88,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),x.zoomNodes]})})]})}function ca({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=Nt,yDomain:f,ariaLabel:p="Gráfico de área",stacked:g=!1,opacity:k=.22,zoomable:v=!1,zoomMode:A="both",brushHeight:E,onZoomChange:M}){const H=oa(e,n),S=pn(n),x=la(e,r,{zoomable:v,zoomMode:A,brushHeight:E,onZoomChange:M}),C=hn({...m,...x.marginExtra});return l?t.jsx(kt,{height:a}):H?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ia,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.AreaChart,{data:x.viewData,margin:C,...x.chartHandlers,children:[t.jsx("defs",{children:S.map(w=>t.jsxs("linearGradient",{id:bi(w.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:w.color,stopOpacity:Math.min(.55,k+.28)}),t.jsx("stop",{offset:"48%",stopColor:w.color,stopOpacity:k*.5}),t.jsx("stop",{offset:"100%",stopColor:w.color,stopOpacity:0})]},w.key))}),c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:w=>b(Number(w)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{stroke:fi(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,S.map(w=>t.jsx(Me.Area,{type:"monotone",dataKey:w.key,name:w.label,stroke:w.color,fill:`url(#${bi(w.key)})`,strokeWidth:2.25,stackId:g?"stack":void 0,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:w.color}},w.key)),x.zoomNodes]})})]})}function Lb({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=Nt,yDomain:f,ariaLabel:p="Gráfico de barras",layout:g="vertical",mode:k="grouped",barRadius:v=6,categoryAxisWidth:A=64,zoomable:E=!1,zoomMode:M="both",brushHeight:H,onZoomChange:S}){const x=oa(e,n),C=pn(n),w=g==="horizontal",P=la(e,r,{zoomable:E&&!w,zoomMode:M,brushHeight:H,onZoomChange:S}),V=hn({...m,...P.marginExtra});return l?t.jsx(kt,{height:a}):x?t.jsx(St,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ia,{visible:P.isZoomed,onReset:P.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:P.viewData,margin:V,layout:w?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...P.chartHandlers,children:[c?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!w,vertical:w}):null,w?t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{type:"number",tick:Et(),tickLine:!1,axisLine:!1,tickFormatter:X=>b(Number(X)),domain:f??["auto","auto"]}),t.jsx(Me.YAxis,{type:"category",dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,width:A})]}):t.jsxs(t.Fragment,{children:[t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:X=>b(Number(X)),dx:-2})]}),u?t.jsx(zr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,C.map((X,O)=>t.jsx(Me.Bar,{dataKey:X.key,name:X.label,fill:X.color,fillOpacity:O===0?1:.82,radius:w?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:ar,animationEasing:br},X.key)),P.zoomNodes]})})]})}function Db(e){return t.jsx(gi,{...e,variant:"pie"})}function Ob(e){return t.jsx(gi,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function pi(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function gi({data:e,nameKey:r,valueKey:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=Nt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:p=[...bn],padAngle:g,cornerRadius:k,variant:v}){const A=e.map((O,K)=>({name:String(O[r]??""),value:Br(O[n])??0,fill:p[K%p.length],row:O})).filter(O=>O.value>0),E=!A.length,M=v==="donut",H=A.length,S=pi(b,M?62:12),x=pi(f,78),C=Math.min(g??(M?2:3),Math.max(.5,10/Math.max(1,H))),w=Math.min(k??(M?10:8),Math.max(2,36/Math.max(1,H)));if(l)return t.jsx(kt,{height:a});if(E)return t.jsx(St,{height:a,text:i});const P=A.reduce((O,K)=>O+K.value,0),V=c?Math.min(96,28+Math.ceil(H/3)*22):0,X=Math.max(140,a-V);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":m??(v==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:X},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(zr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Me.Pie,{data:A,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${S}%`,outerRadius:`${x}%`,startAngle:90,endAngle:-270,paddingAngle:C,cornerRadius:w,minAngle:H>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:ar,animationEasing:br,label:!1,activeShape:Hb,children:A.map(O=>t.jsx(Me.Cell,{fill:O.fill},O.name))}),M?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(P)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:A.map(O=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:O.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:O.name,children:O.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(O.value)})]},O.name))}):null]})})}function Hb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Me.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Ib({data:e,dataKey:r,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??Wt(o),m=e.map(x=>Br(x[r])).filter(x=>x!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,p=3,g=1,k=Math.min(...m),A=Math.max(...m)-k||1,E=m.map((x,C)=>{const w=g+C/(m.length-1)*(b-g*2),P=f-p-(x-k)/A*(f-p*2);return{x:w,y:P}}),M=E.map((x,C)=>`${C===0?"M":"L"}${x.x.toFixed(2)} ${x.y.toFixed(2)}`).join(" "),H=`${M} L${E[E.length-1].x.toFixed(2)} ${f} L${E[0].x.toFixed(2)} ${f} Z`,S=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:S,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:H,fill:`url(#${S})`}):null,t.jsx("path",{d:M,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Bb({data:e,xKey:r,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:b=!0,margin:f,valueFormat:p=Nt,yDomain:g,ariaLabel:k="Gráfico combinado",barRadius:v=6,zoomable:A=!1,zoomMode:E="both",brushHeight:M,onZoomChange:H}){const S=a??n.slice(0,Math.max(1,n.length-1)),x=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),C=[...S,...x.filter(q=>!S.some(le=>le.key===q.key))],w=oa(e,C),P=pn(S),V=pn(C),X=x.map(q=>{var J;const le=V.find(G=>G.key===q.key);return{...q,label:q.label??q.key,color:q.color??(le==null?void 0:le.color)??((J=V[0])==null?void 0:J.color)}}),O=la(e,r,{zoomable:A,zoomMode:E,brushHeight:M,onZoomChange:H}),K=hn({...f,...O.marginExtra});return c?t.jsx(kt,{height:l}):w?t.jsx(St,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[t.jsx(ia,{visible:O.isZoomed,onReset:O.resetZoom}),t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.ComposedChart,{data:O.viewData,margin:K,barCategoryGap:"34%",...O.chartHandlers,children:[u?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:r,tick:Et(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,domain:g??["auto","auto"],tickFormatter:q=>p(Number(q)),dx:-2}),b?t.jsx(zr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sa()}):null,P.map(q=>t.jsx(Me.Bar,{dataKey:q.key,name:q.label,fill:q.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:ar,animationEasing:br},q.key)),X.map(q=>t.jsx(Me.Line,{type:"monotone",dataKey:q.key,name:q.label,stroke:q.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:ar,animationEasing:br,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:q.color}},q.key)),O.zoomNodes]})})]})}function Fb({data:e,xKey:r,valueKey:n,typeKey:a,height:o=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=Nt,ariaLabel:f="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:g="#f87171",totalColor:k="var(--primary)"}){const v=s.useMemo(()=>Pb(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:g,totalColor:k}),[e,r,n,a,p,g,k]),A=!v.length,E=hn(m);return i?t.jsx(kt,{height:o}):A?t.jsx(St,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Me.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Me.BarChart,{data:v,margin:E,barCategoryGap:"42%",children:[d?t.jsx(Me.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Me.XAxis,{dataKey:"label",tick:Et(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Me.YAxis,{tick:Et(),tickLine:!1,axisLine:!1,width:44,tickFormatter:M=>b(Number(M)),dx:-2}),u?t.jsx(zr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Me.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Me.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:ar,animationEasing:br,children:v.map(M=>t.jsx(Me.Cell,{fill:M.color},M.label))})]})})})}function Pb(e,r){let n=0;return e.map((a,o)=>{const l=Br(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const vi="bonsaif-funnel-chart-keyframes",_b=`
|
|
45
45
|
@keyframes bonsaif-funnel-stage-in {
|
|
46
46
|
from {
|
|
47
47
|
opacity: 0;
|
|
@@ -81,4 +81,4 @@ ${P}`,ve=new Blob(["\uFEFF"+oe],{type:"text/csv;charset=utf-8;"}),Ce=URL.createO
|
|
|
81
81
|
animation: none !important;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
`;function Hb(){if(typeof document>"u"||document.getElementById(bi))return;const e=document.createElement("style");e.id=bi,e.textContent=Ob,document.head.appendChild(e)}function mi(e,r,n){return Math.min(n,Math.max(r,e))}function ca(e,r,n){const a=mi(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function Ib(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=Ir(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",g=o?String(d[o]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...g?{description:g}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function Bb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),o=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function Fb({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,g=o+l,p=Math.max(4,Math.min(14,l*.18)),E=ca(d,"#000",r?.12:.22),v=ca(d,"#fff",r?.08:0),w=ca(d,"#fff",.22),A=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${f} ${g}`,`L ${b} ${g}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:A,fill:E}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${f} ${g}`,`L ${a} ${g}`,`L ${u} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:p,fill:w,stroke:ca(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:p,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function Pb({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:g=.42,colors:p=[...bn],animationDuration:E=nr,valueFormat:v=kt,ariaLabel:w="Gráfico embudo"}){const[A,C]=s.useState(null),[H,k]=s.useState(!1),x=s.useMemo(()=>Ib(e,r,n,a,o,p),[e,r,n,a,o,p]),M=s.useMemo(()=>x.map(S=>`${S.name}:${S.value}`).join("|"),[x]);if(s.useEffect(()=>{if(Hb(),typeof window>"u")return;const S=window.matchMedia("(prefers-reduced-motion: reduce)");k(S.matches);const ee=()=>k(S.matches);return S.addEventListener("change",ee),()=>S.removeEventListener("change",ee)},[]),c)return t.jsx(St,{height:l});if(!x.length)return t.jsx(Et,{height:l,text:d});const N=E>0&&!H,z=E,X=Math.min(90,Math.max(40,Math.round(E/8))),K=Math.round(z*.15),D=x.length*X+Math.round(z*.35),G=x.some(S=>S.title||S.description),V=m?160:24,ne=G?168:24,J=f?36:8,R=V+220+ne,U=l,Y=18,ce=Math.max(120,U-Y-J-8),L=V+110,le=Bb(x,{cx:L,topY:Y,plotH:ce,maxTopW:200,taper:mi(g,.2,.95),gap:10}),O=A!=null?le[A]:null,ae="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":w,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${R} ${U}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:N?"bonsaif-funnel-label":void 0,style:N?{animation:`bonsaif-funnel-fade-in ${z}ms ${ae} both`}:void 0,x1:V-12,y1:Y,x2:V-12,y2:Y+ce,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,le.map(S=>{const ee=S.y+S.h/2,_=S.cx-S.topW/2,I=S.index*X,de=N?{animation:`bonsaif-funnel-stage-in ${z}ms ${ae} ${I}ms both`}:void 0,re=N?{animation:`bonsaif-funnel-fade-in ${Math.round(z*.85)}ms ${ae} ${I+K}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:de,children:t.jsx(Fb,{stage:S,hovered:A===S.index,onHover:C})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:re,children:[t.jsx("line",{x1:24,y1:ee,x2:V-12,y2:ee,stroke:S.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:V-12,y1:ee,x2:_-6,y2:ee,stroke:S.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:ee-(b?6:0),textAnchor:"end",fill:S.color,fontSize:12,fontWeight:600,children:S.name.length>18?`${S.name.slice(0,16)}…`:S.name}),b?t.jsx("text",{x:20,y:ee+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(S.value)}):null]}):null,(S.title||S.description)&&G?t.jsxs("g",{className:"bonsaif-funnel-anno",style:re,children:[t.jsx("line",{x1:S.cx+S.bottomW/2+6,y1:ee,x2:V+220+8,y2:ee,stroke:S.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),S.title?t.jsx("text",{x:V+220+14,y:ee-(S.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:S.title.length>22?`${S.title.slice(0,20)}…`:S.title}):null,S.description?t.jsx("text",{x:V+220+14,y:ee+(S.title?10:0),fill:"var(--text-muted)",fontSize:11,children:S.description.length>28?`${S.description.slice(0,26)}…`:S.description}):null]}):null]},`${S.name}-${S.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${L}, ${Y+ce+8})`,fill:"var(--primary)",style:N?{animation:`bonsaif-funnel-arrow-in ${Math.round(z*.7)}ms ${ae} ${D}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},M),u&&O?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:O.color},children:O.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(O.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(O.pct*100),"% del top)"]})]}):null]})}const zr=135*Math.PI/180,Lo=270*Math.PI/180;function _b({value:e,min:r=0,max:n=100,height:a=180,className:o="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=kt,tone:m="primary",color:b,thresholds:f,ariaLabel:g="Gauge",animationDuration:p=700,thickness:E=9,showScale:v=!1}){const w=s.useId().replace(/:/g,""),A=n-r||1,C=Math.min(1,Math.max(0,(e-r)/A)),[H,k]=s.useState(p>0?0:C);if(s.useEffect(()=>{if(l||i)return;if(p<=0){k(C);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){k(C);return}let R=0,U=0;k(L=>(U=L,L));const Y=performance.now(),ce=L=>{const B=Math.min(1,(L-Y)/p),le=1-(1-B)**3;k(U+(C-U)*le),B<1&&(R=requestAnimationFrame(ce))};return R=requestAnimationFrame(ce),()=>cancelAnimationFrame(R)},[C,p,l,i]),l)return t.jsx(St,{height:a});if(i)return t.jsx(Et,{height:a,text:c});const x=100,M=108,N=72,z=b??zb(e,n,m,f),X=r+H*A,K=hi(x,M,N,zr,zr+Lo),D=zr+Math.max(.001,H)*Lo,G=hi(x,M,N,zr,D),V=da(x,M,N,zr),ne=da(x,M,N,zr+Lo);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":g,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${w}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:z,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:z,stopOpacity:1})]})}),t.jsx("path",{d:K,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:E,strokeLinecap:"butt"}),t.jsx("path",{d:G,fill:"none",stroke:`url(#bonsaif-gauge-${w})`,strokeWidth:E,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x,y:M-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(X)}),d?t.jsx("text",{x,y:M+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:V.x-2,y:V.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ne.x+2,y:ne.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function zb(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return zt(n);const o=e/(r||1);return o>=.8?zt("success"):o>=.5?zt("warning"):zt("danger")}function da(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function hi(e,r,n,a,o){const l=da(e,r,n,a),i=da(e,r,n,o),c=o-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function Wb({value:e,target:r,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:b=kt,tone:f="primary",showScale:g=!0,showStatus:p=!0,ariaLabel:E="Bullet chart"}){if(i)return t.jsx(St,{height:o});if(c)return t.jsx(Et,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(z=>z.value))??[],1)*1.05,A=[...a??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((z,X)=>z.value-X.value),C=zt(f),H=Math.min(100,Math.max(0,e/v*100)),k=Math.min(100,Math.max(0,r/v*100)),x=e>=r,M=[0,.25,.5,.75,1].map(z=>z*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,u?28:o*.42)},role:"img","aria-label":E,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:A.map((z,X)=>{const K=X===0?0:A[X-1].value,D=Math.max(0,(z.value-K)/v*100);return t.jsx("div",{style:{width:`${D}%`,background:z.color??`color-mix(in srgb, var(--border) ${70-X*18}%, transparent)`}},X)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${H}%`,background:C,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${C} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${k}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:C,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),g?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:M.map((z,X)=>{const K=z/v*100,D=X===0,G=X===M.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${K}%`,transform:D?"none":G?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:D?0:G?"auto":void 0,marginRight:G?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":G?"right":"center"},children:b(z)})]},z)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:C,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),p?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:zt(x?"success":"warning")},children:x?"En meta":"Bajo meta"}):null]}),N]}):N})}function jb({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:o,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:f,label:g="CPU",ariaLabel:p="Uso de CPU"}){var k;const E=o??[{key:a,label:"Uso",color:mn(r??Pr(e,a)??0,f)}],v=r??Pr(e,a)??Pr(e,((k=E[0])==null?void 0:k.key)??a),w=!d&&(!e.length||v===null);if(d)return t.jsx(St,{height:i});if(w)return t.jsx(Et,{height:i,text:u});const A=Math.min(100,Math.max(0,v??0)),C=na(A,f),H=mn(A,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":p,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[g,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:H},children:Br(A,A<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:H,background:`color-mix(in srgb, ${H} 14%, transparent)`},children:C==="danger"?"Crítico":C==="warning"?"Alto":"Normal"})]}),t.jsx(ia,{data:e,xKey:n,series:E.map(x=>({...x,color:x.color??H})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:x=>Br(x,0),ariaLabel:p,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function qb({used:e,total:r,cached:n,data:a=[],timeKey:o="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:f,label:g="RAM",ariaLabel:p="Uso de memoria"}){const E=r>0?r:1,v=Math.min(100,Math.max(0,e/E*100)),w=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(St,{height:i});if(w)return t.jsx(Et,{height:i,text:u});const A=na(v,f),C=mn(v,f),H=Math.max(0,r-e),k=a.length>0?Pr(a,l)??v:v,x=mn(k,f),M=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":p,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:g}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:C},children:Br(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Fr(e)," / ",Fr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:C,background:`color-mix(in srgb, ${C} 14%, transparent)`},children:A==="danger"?"Crítico":A==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${g} ${Br(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${C}, color-mix(in srgb, ${C} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Fr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Fr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Fr(H)]})]})]}),m&&a.length>1?t.jsx(ia,{data:a,xKey:o,series:[{key:l,label:"Uso",color:x}],height:M,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:N=>Br(N,0),ariaLabel:`${p} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Ub="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Vb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Xb({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:o,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=Ub,outboundColor:m=Vb,height:b=240,className:f="",loading:g=!1,emptyText:p="Sin datos de red",showLegend:E=!1,showTooltip:v=!0,label:w="Network",ariaLabel:A="Tráfico de red"}){const C=o??Pr(e,n)??0,H=l??Pr(e,a)??0,k=!g&&e.length===0;if(g)return t.jsx(St,{height:b});if(k)return t.jsx(Et,{height:b,text:p});const x=z=>si(z,i),N=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":A,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:w}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:x(C),children:x(C)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:x(H),children:x(H)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ia,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:N,showLegend:E,showTooltip:v,valueFormat:x,ariaLabel:A,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const pi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],gi=["primeSuiteOrigin","primeSuiteProjectKey"];function Yb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of pi){const n=e.get(r);if(n){const a=ua(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of gi){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=ua(n);if(a)return a}}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Kb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of pi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of gi)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=ua(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function ua(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function Gb(e){const[r,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=s.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),d=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(q,"toast",{enumerable:!0,get:()=>Ha.toast}),q.Alert=pc,q.AreaChart=ia,q.AuthShell=ei,q.AutoGrowTextarea=Bl,q.AutoGrowTextareaField=Nf,q.BarChart=Eb,q.BonsaifButton=Qi,q.BonsaifUIToaster=xb,q.BulletChart=Wb,q.Button=Qe,q.CHART_PALETTE=bn,q.CalendarPicker=wc,q.ChartCard=yb,q.Checkbox=Mn,q.CodeBlock=td,q.ComboChart=Ab,q.CompactFilterSelect=nd,q.CompactSearchInput=rd,q.ConfirmDialog=ld,q.CopyButton=Va,q.CopyLinkButton=ud,q.CpuChart=jb,q.DataSheets=vd,q.DataTable=qa,q.DateRangePicker=kd,q.DonutChart=Mb,q.Drawer=Od,q.DropdownMenu=Ld,q.DynamicDetailTabs=mc,q.EmailField=ru,q.EmptyState=Hn,q.EventCalendar=Jc,q.FieldHelperFooter=Tr,q.FieldLabelInfo=Mr,q.FieldLayoutEditor=iu,q.FileUpload=su,q.FormField=zn,q.FunnelChart=Pb,q.GaugeChart=_b,q.GlobalScrollbars=Kl,q.ImageLightbox=Ys,q.ImageLightboxHost=gu,q.InputField=to,q.LineChart=Sb,q.LoadingState=rs,q.MentionTextEditor=Ol,q.MicroserviceFrame=mb,q.Modal=Xa,q.MouseTooltip=Bt,q.MultiDateCalendar=Cd,q.MultiSelect=xu,q.NetworkChart=Xb,q.NumberField=yu,q.PageHeader=ub,q.PageSearchInput=Qo,q.Pagination=Nu,q.PhoneField=Su,q.PieChart=Cb,q.PrimeAuthRouteShell=fb,q.PrimeSuiteChatFrame=hb,q.RadioGroup=Eu,q.RamChart=qb,q.RichTextEditor=sf,q.SearchableSelect=dr,q.SectionPanel=lf,q.Sparkline=$b,q.StatusBadge=uf,q.StatusSelect=pf,q.StepWizard=vf,q.TableSkeleton=Cn,q.Tabs=gf,q.TagInput=Df,q.TextInput=_n,q.Textarea=Fl,q.TextareaField=Mf,q.TimeField=zf,q.TimePicker=Ul,q.Toggle=jf,q.TruncatedWithTooltip=Ut,q.UserAvatar=Rl,q.WaterfallChart=Lb,q.YearMultiDateCalendar=Td,q.buildMentionQueryRegex=bl,q.chunkMonthWeeks=ys,q.clearMentionChipSelection=Or,q.cn=Qt,q.computeWeekBars=Ua,q.configureBonsaifUI=Mc,q.dedupeMentions=vl,q.defaultValueFormat=kt,q.deleteEditorSelection=Ml,q.describeParentTargetOrigin=Kb,q.emailFormat=_d,q.ensureMentionChipTrailingSpaces=dn,q.extractMentionUsernames=po,q.filterSelfMentions=Ru,q.findMentionChipAfterCaret=$l,q.findMentionChipBeforeCaret=Tl,q.findMentionChipsInSelection=wo,q.findMentionTriggerInEditor=mo,q.formatBytes=Fr,q.formatPercent=Br,q.formatRate=si,q.getBonsaifUIConfig=Tc,q.getDataTablePreferencesEndpoint=za,q.getEditorPlainText=yo,q.getMonthGrid=xs,q.getPlainTextOffset=Zn,q.getWeekDays=vs,q.groupItemsByDay=ws,q.highlightMentions=xl,q.htmlToText=pl,q.insertMentionInEditor=wl,q.isMentionTriggerBoundary=hl,q.isPlainOffsetInsideMentionChip=ml,q.isValidEmail=Ja,q.isValidPhone=Ra,q.locateTextOffset=Dr,q.matches=Vd,q.maxLength=jd,q.maxValue=Ud,q.mentionDisplayLabel=gl,q.minLength=Wd,q.minValue=qd,q.normalizeUsername=ho,q.openImageLightboxFromEvent=Vs,q.phoneCountryCodeOptions=Zs,q.phoneFormat=zd,q.placeCaretAfterMentionChip=vo,q.placeCaretAtTextOffset=Nl,q.preferredMentionSpacer=go,q.removeMentionChip=Rn,q.required=Pd,q.resetBonsaifUIConfig=$c,q.resolveMentions=Ju,q.resolveParentTargetOrigin=Yb,q.selectAllEditorContents=El,q.selectMentionChip=Sl,q.selectionIncludesNonChipText=Cl,q.seriesColor=oi,q.setBonsaifDataTablePreferencesEndpoint=Ac,q.syncMentionChipSelectionHighlight=Jn,q.toDateKey=Ft,q.toneColor=zt,q.usageColor=mn,q.usageTone=na,q.useValidationVisibility=Gb,q.validateForm=Xd,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})}));
|
|
84
|
+
`;function zb(){if(typeof document>"u"||document.getElementById(vi))return;const e=document.createElement("style");e.id=vi,e.textContent=_b,document.head.appendChild(e)}function yi(e,r,n){return Math.min(n,Math.max(r,e))}function da(e,r,n){const a=yi(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function Wb(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=Br(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",p=o?String(d[o]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...p?{description:p}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function jb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),o=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function qb({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,p=o+l,g=Math.max(4,Math.min(14,l*.18)),k=da(d,"#000",r?.12:.22),v=da(d,"#fff",r?.08:0),A=da(d,"#fff",.22),E=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${f} ${p}`,`L ${b} ${p}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:E,fill:k}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${f} ${p}`,`L ${a} ${p}`,`L ${u} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:A,stroke:da(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function Ub({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:p=.42,colors:g=[...bn],animationDuration:k=ar,valueFormat:v=Nt,ariaLabel:A="Gráfico embudo"}){const[E,M]=s.useState(null),[H,S]=s.useState(!1),x=s.useMemo(()=>Wb(e,r,n,a,o,g),[e,r,n,a,o,g]),C=s.useMemo(()=>x.map(N=>`${N.name}:${N.value}`).join("|"),[x]);if(s.useEffect(()=>{if(zb(),typeof window>"u")return;const N=window.matchMedia("(prefers-reduced-motion: reduce)");S(N.matches);const R=()=>S(N.matches);return N.addEventListener("change",R),()=>N.removeEventListener("change",R)},[]),c)return t.jsx(kt,{height:l});if(!x.length)return t.jsx(St,{height:l,text:d});const w=k>0&&!H,P=k,V=Math.min(90,Math.max(40,Math.round(k/8))),X=Math.round(P*.15),O=x.length*V+Math.round(P*.35),K=x.some(N=>N.title||N.description),q=m?160:24,le=K?168:24,J=f?36:8,G=q+220+le,U=l,Y=18,ue=Math.max(120,U-Y-J-8),L=q+110,de=jb(x,{cx:L,topY:Y,plotH:ue,maxTopW:200,taper:yi(p,.2,.95),gap:10}),I=E!=null?de[E]:null,oe="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":A,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${G} ${U}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:w?"bonsaif-funnel-label":void 0,style:w?{animation:`bonsaif-funnel-fade-in ${P}ms ${oe} both`}:void 0,x1:q-12,y1:Y,x2:q-12,y2:Y+ue,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,de.map(N=>{const R=N.y+N.h/2,ae=N.cx-N.topW/2,$=N.index*V,ne=w?{animation:`bonsaif-funnel-stage-in ${P}ms ${oe} ${$}ms both`}:void 0,te=w?{animation:`bonsaif-funnel-fade-in ${Math.round(P*.85)}ms ${oe} ${$+X}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:ne,children:t.jsx(qb,{stage:N,hovered:E===N.index,onHover:M})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:te,children:[t.jsx("line",{x1:24,y1:R,x2:q-12,y2:R,stroke:N.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:q-12,y1:R,x2:ae-6,y2:R,stroke:N.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:R-(b?6:0),textAnchor:"end",fill:N.color,fontSize:12,fontWeight:600,children:N.name.length>18?`${N.name.slice(0,16)}…`:N.name}),b?t.jsx("text",{x:20,y:R+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(N.value)}):null]}):null,(N.title||N.description)&&K?t.jsxs("g",{className:"bonsaif-funnel-anno",style:te,children:[t.jsx("line",{x1:N.cx+N.bottomW/2+6,y1:R,x2:q+220+8,y2:R,stroke:N.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),N.title?t.jsx("text",{x:q+220+14,y:R-(N.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:N.title.length>22?`${N.title.slice(0,20)}…`:N.title}):null,N.description?t.jsx("text",{x:q+220+14,y:R+(N.title?10:0),fill:"var(--text-muted)",fontSize:11,children:N.description.length>28?`${N.description.slice(0,26)}…`:N.description}):null]}):null]},`${N.name}-${N.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${L}, ${Y+ue+8})`,fill:"var(--primary)",style:w?{animation:`bonsaif-funnel-arrow-in ${Math.round(P*.7)}ms ${oe} ${O}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},C),u&&I?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:I.color},children:I.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(I.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(I.pct*100),"% del top)"]})]}):null]})}const Wr=135*Math.PI/180,Io=270*Math.PI/180;function Vb({value:e,min:r=0,max:n=100,height:a=180,className:o="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=Nt,tone:m="primary",color:b,thresholds:f,ariaLabel:p="Gauge",animationDuration:g=700,thickness:k=9,showScale:v=!1}){const A=s.useId().replace(/:/g,""),E=n-r||1,M=Math.min(1,Math.max(0,(e-r)/E)),[H,S]=s.useState(g>0?0:M);if(s.useEffect(()=>{if(l||i)return;if(g<=0){S(M);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){S(M);return}let G=0,U=0;S(L=>(U=L,L));const Y=performance.now(),ue=L=>{const B=Math.min(1,(L-Y)/g),de=1-(1-B)**3;S(U+(M-U)*de),B<1&&(G=requestAnimationFrame(ue))};return G=requestAnimationFrame(ue),()=>cancelAnimationFrame(G)},[M,g,l,i]),l)return t.jsx(kt,{height:a});if(i)return t.jsx(St,{height:a,text:c});const x=100,C=108,w=72,P=b??Yb(e,n,m,f),V=r+H*E,X=xi(x,C,w,Wr,Wr+Io),O=Wr+Math.max(.001,H)*Io,K=xi(x,C,w,Wr,O),q=ua(x,C,w,Wr),le=ua(x,C,w,Wr+Io);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":p,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${A}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:P,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:P,stopOpacity:1})]})}),t.jsx("path",{d:X,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),t.jsx("path",{d:K,fill:"none",stroke:`url(#bonsaif-gauge-${A})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x,y:C-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(V)}),d?t.jsx("text",{x,y:C+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:q.x-2,y:q.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:le.x+2,y:le.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function Yb(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return Wt(n);const o=e/(r||1);return o>=.8?Wt("success"):o>=.5?Wt("warning"):Wt("danger")}function ua(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function xi(e,r,n,a,o){const l=ua(e,r,n,a),i=ua(e,r,n,o),c=o-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function Xb({value:e,target:r,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:b=Nt,tone:f="primary",showScale:p=!0,showStatus:g=!0,ariaLabel:k="Bullet chart"}){if(i)return t.jsx(kt,{height:o});if(c)return t.jsx(St,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(P=>P.value))??[],1)*1.05,E=[...a??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((P,V)=>P.value-V.value),M=Wt(f),H=Math.min(100,Math.max(0,e/v*100)),S=Math.min(100,Math.max(0,r/v*100)),x=e>=r,C=[0,.25,.5,.75,1].map(P=>P*v),w=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:o*.42)},role:"img","aria-label":k,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:E.map((P,V)=>{const X=V===0?0:E[V-1].value,O=Math.max(0,(P.value-X)/v*100);return t.jsx("div",{style:{width:`${O}%`,background:P.color??`color-mix(in srgb, var(--border) ${70-V*18}%, transparent)`}},V)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${H}%`,background:M,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${M} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${S}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:M,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),p?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:C.map((P,V)=>{const X=P/v*100,O=V===0,K=V===C.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${X}%`,transform:O?"none":K?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:O?0:K?"auto":void 0,marginRight:K?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:O?"left":K?"right":"center"},children:b(P)})]},P)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:M,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),g?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Wt(x?"success":"warning")},children:x?"En meta":"Bajo meta"}):null]}),w]}):w})}function Kb({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:o,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:f,label:p="CPU",ariaLabel:g="Uso de CPU"}){var S;const k=o??[{key:a,label:"Uso",color:mn(r??_r(e,a)??0,f)}],v=r??_r(e,a)??_r(e,((S=k[0])==null?void 0:S.key)??a),A=!d&&(!e.length||v===null);if(d)return t.jsx(kt,{height:i});if(A)return t.jsx(St,{height:i,text:u});const E=Math.min(100,Math.max(0,v??0)),M=aa(E,f),H=mn(E,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":g,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[p,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:H},children:Fr(E,E<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:H,background:`color-mix(in srgb, ${H} 14%, transparent)`},children:M==="danger"?"Crítico":M==="warning"?"Alto":"Normal"})]}),t.jsx(ca,{data:e,xKey:n,series:k.map(x=>({...x,color:x.color??H})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:x=>Fr(x,0),ariaLabel:g,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Gb({used:e,total:r,cached:n,data:a=[],timeKey:o="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:f,label:p="RAM",ariaLabel:g="Uso de memoria"}){const k=r>0?r:1,v=Math.min(100,Math.max(0,e/k*100)),A=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(kt,{height:i});if(A)return t.jsx(St,{height:i,text:u});const E=aa(v,f),M=mn(v,f),H=Math.max(0,r-e),S=a.length>0?_r(a,l)??v:v,x=mn(S,f),C=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":g,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:p}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:M},children:Fr(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Pr(e)," / ",Pr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:M,background:`color-mix(in srgb, ${M} 14%, transparent)`},children:E==="danger"?"Crítico":E==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${p} ${Fr(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${M}, color-mix(in srgb, ${M} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Pr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Pr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Pr(H)]})]})]}),m&&a.length>1?t.jsx(ca,{data:a,xKey:o,series:[{key:l,label:"Uso",color:x}],height:C,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:w=>Fr(w,0),ariaLabel:`${g} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Zb="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Qb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Jb({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:o,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=Zb,outboundColor:m=Qb,height:b=240,className:f="",loading:p=!1,emptyText:g="Sin datos de red",showLegend:k=!1,showTooltip:v=!0,label:A="Network",ariaLabel:E="Tráfico de red"}){const M=o??_r(e,n)??0,H=l??_r(e,a)??0,S=!p&&e.length===0;if(p)return t.jsx(kt,{height:b});if(S)return t.jsx(St,{height:b,text:g});const x=P=>ui(P,i),w=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":E,children:[t.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:A}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:x(M),children:x(M)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:x(H),children:x(H)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(ca,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:w,showLegend:k,showTooltip:v,valueFormat:x,ariaLabel:E,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const wi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Ni=["primeSuiteOrigin","primeSuiteProjectKey"];function Rb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of wi){const n=e.get(r);if(n){const a=fa(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Ni){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=fa(n);if(a)return a}}if(document.referrer){const r=fa(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function em(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of wi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Ni)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=fa(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function fa(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function tm(e){const[r,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=s.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),d=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(F,"toast",{enumerable:!0,get:()=>Ia.toast}),F.Alert=wc,F.AreaChart=ca,F.AuthShell=oi,F.AutoGrowTextarea=Wl,F.AutoGrowTextareaField=Tf,F.BarChart=Lb,F.BonsaifButton=rc,F.BonsaifUIToaster=Eb,F.BulletChart=Xb,F.Button=Ge,F.CHART_PALETTE=bn,F.CalendarPicker=Cc,F.ChartCard=Cb,F.Checkbox=Mn,F.CodeBlock=ld,F.ComboChart=Bb,F.CompactFilterSelect=cd,F.CompactSearchInput=id,F.ConfirmDialog=bd,F.CopyButton=Ga,F.CopyLinkButton=gd,F.CpuChart=Kb,F.DataSheets=Sd,F.DataTable=Ua,F.DateRangePicker=$d,F.DonutChart=Ob,F.Drawer=_d,F.DropdownMenu=Fd,F.DynamicDetailTabs=yc,F.EmailField=iu,F.EmptyState=Hn,F.EventCalendar=ad,F.FieldHelperFooter=$r,F.FieldLabelInfo=Tr,F.FieldLayoutEditor=mu,F.FileUpload=fu,F.FormField=Wn,F.FunnelChart=Ub,F.GaugeChart=Vb,F.GlobalScrollbars=Rl,F.ImageLightbox=Js,F.ImageLightboxHost=ku,F.InputField=oo,F.LineChart=Ab,F.LoadingState=ss,F.MentionTextEditor=Pl,F.MicroserviceFrame=xb,F.Modal=Za,F.MouseTooltip=Ft,F.MultiDateCalendar=Dd,F.MultiSelect=Eu,F.NetworkChart=Jb,F.NumberField=Cu,F.PageHeader=gb,F.PageSearchInput=ts,F.Pagination=Tu,F.PhoneField=Au,F.PieChart=Db,F.PrimeAuthRouteShell=vb,F.PrimeSuiteChatFrame=wb,F.RadioGroup=Lu,F.RamChart=Gb,F.RichTextEditor=bf,F.SearchableSelect=ur,F.SectionPanel=mf,F.Sparkline=Ib,F.StatusBadge=gf,F.StatusSelect=Nf,F.StepWizard=Sf,F.TableSkeleton=Cn,F.Tabs=kf,F.TagInput=Pf,F.TextInput=zn,F.Textarea=jl,F.TextareaField=Of,F.TimeField=Yf,F.TimePicker=Gl,F.Toggle=Kf,F.TruncatedWithTooltip=Vt,F.UserAvatar=ai,F.WORKDAY_LABELS=Ts,F.WaterfallChart=Fb,F.YearMultiDateCalendar=Hd,F.buildMentionQueryRegex=vl,F.chunkMonthWeeks=Xa,F.chunkMonthWorkWeeks=Ss,F.clearMentionChipSelection=Hr,F.cn=Qt,F.computeWeekBars=Ka,F.configureBonsaifUI=Dc,F.dedupeMentions=kl,F.defaultValueFormat=Nt,F.deleteEditorSelection=Dl,F.describeParentTargetOrigin=em,F.emailFormat=Vd,F.ensureMentionChipTrailingSpaces=dn,F.extractMentionUsernames=xo,F.filterSelfMentions=of,F.filterWorkdays=In,F.findMentionChipAfterCaret=Hl,F.findMentionChipBeforeCaret=Ol,F.findMentionChipsInSelection=Eo,F.findMentionTriggerInEditor=vo,F.formatBytes=Pr,F.formatPercent=Fr,F.formatRate=ui,F.getBonsaifUIConfig=Oc,F.getDataTablePreferencesEndpoint=Wa,F.getEditorPlainText=So,F.getMonthGrid=Ya,F.getPlainTextOffset=Qn,F.getWeekDays=Va,F.getWorkWeekDays=ks,F.groupItemsByDay=Es,F.highlightMentions=Sl,F.htmlToText=wl,F.insertMentionInEditor=Cl,F.isMentionTriggerBoundary=xl,F.isPlainOffsetInsideMentionChip=yl,F.isValidEmail=ro,F.isValidPhone=no,F.isWeekend=Ns,F.locateTextOffset=Or,F.matches=Qd,F.maxLength=Kd,F.maxValue=Zd,F.mentionDisplayLabel=Nl,F.minLength=Xd,F.minValue=Gd,F.normalizeUsername=yo,F.openImageLightboxFromEvent=Zs,F.phoneCountryCodeOptions=tl,F.phoneFormat=Yd,F.placeCaretAfterMentionChip=No,F.placeCaretAtTextOffset=Ml,F.preferredMentionSpacer=wo,F.removeMentionChip=ea,F.required=Ud,F.resetBonsaifUIConfig=Hc,F.resolveMentions=af,F.resolveParentTargetOrigin=Rb,F.selectAllEditorContents=Al,F.selectMentionChip=$l,F.selectionIncludesNonChipText=Ll,F.seriesColor=di,F.setBonsaifDataTablePreferencesEndpoint=Ic,F.syncMentionChipSelectionHighlight=Rn,F.toDateKey=Pt,F.toNearestWorkday=Zc,F.toneColor=Wt,F.usageColor=mn,F.usageTone=aa,F.useValidationVisibility=tm,F.validateForm=Jd,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})}));
|