bonsaif-ui 0.1.50 → 0.1.51
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 +636 -632
- package/dist/bonsaif-ui.umd.cjs +3 -3
- package/dist/components/ui/DataSheets.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(Y,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),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","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],l):(Y=typeof globalThis<"u"?globalThis:Y||self,l(Y.BonsaifUI={},Y.React,Y.jsxRuntime,Y.ReactIconsHi2,Y.ReactDOM,Y.OverlayScrollbarsGlobal,Y.Sonner,Y.OverlayScrollbarsReact,Y.ReactDayPicker,Y.ReactDayPickerStyles,Y.ReactIconsFi))})(this,(function(Y,l,e,v,je,Zt,Jt,Qt,Rt,li,$n){"use strict";"use client";function Je(...r){return r.filter(Boolean).join(" ")}function Ln({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:Je("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function ea({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:c=!1,onEscape:u,size:b="default",inputTabIndex:p}){const m=l.useRef(null),[h,x]=l.useState(!1),g=c||h||r.trim().length>0,M=b==="sm"?"h-9 rounded-md":"h-10 rounded-lg",C=n||"w-48 max-w-full sm:w-64 lg:w-72";l.useEffect(()=>{var S;s&&((S=m.current)==null||S.focus())},[s]);const N=()=>{var S;x(!0),(S=m.current)==null||S.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${g?C:"w-24 sm:w-28"}`,onMouseDown:S=>{g||(S.preventDefault(),N())},children:[e.jsx(v.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)"}}),e.jsx("input",{ref:m,type:"text",tabIndex:p,"aria-label":a,value:r,onChange:S=>t(S.target.value),onKeyDown:S=>{S.key==="Escape"&&(u==null||u())},placeholder:g?a:"Buscar",className:`${M} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${g?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${b==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:g?"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:S=>{x(!0),S.currentTarget.style.borderColor="var(--primary)",S.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:S=>{x(!1),S.currentTarget.style.borderColor="var(--border)",S.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const ra=l.createContext({});let ta=0;const aa="bonsaif-ui:hide-tooltips";function Ir(r=700){ta=Date.now()+r}function Tn(){return Date.now()>ta}function Or(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(a=>a.contains(r))?!1:t.length>0}function An(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var c;return s.scrollWidth>s.clientWidth&&!!((c=s.textContent)!=null&&c.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function dr({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:c="bottom",showArrow:u=!1,className:b="",tooltipClassName:p="",style:m,tooltipStyle:h,as:x="div"}){const g=l.useRef(null),M=l.useRef(null),C=l.useRef(null),N=l.useRef(!1),[S,B]=l.useState(null),[ee,z]=l.useState("");l.useEffect(()=>{const $=g.current;$&&($.querySelectorAll("[title]").forEach(F=>{const V=F.getAttribute("title");V&&(F.getAttribute("aria-label")||F.setAttribute("aria-label",V),F.removeAttribute("title"))}),$.querySelectorAll("svg title").forEach(F=>F.remove()))}),l.useLayoutEffect(()=>{if(!S)return;const $=M.current;if(!$)return;const F=12,V=14,_=$.getBoundingClientRect(),le=window.innerWidth-_.width-F,q=window.innerHeight-_.height-F;let i=S.mouseX+V,y=S.mouseY+V,A,P;if(!s&&g.current){const D=g.current.getBoundingClientRect(),ae=D.left+D.width/2,ie=D.top+D.height/2;c==="top"?(i=ae-_.width/2,y=D.top-_.height-V,P=_.height-1):c==="left"?(i=D.left-_.width-V,y=ie-_.height/2,A=_.width-1):c==="right"?(i=D.right+V,y=ie-_.height/2,A=-7):(i=ae-_.width/2,y=D.bottom+V,P=-7)}if(s&&(i>le&&(i=S.mouseX-_.width-V),y>q&&(y=S.mouseY-_.height-V)),i=Math.min(Math.max(F,i),Math.max(F,le)),y=Math.min(Math.max(F,y),Math.max(F,q)),!s&&g.current){const D=g.current.getBoundingClientRect(),ae=D.left+D.width/2,ie=D.top+D.height/2;c==="top"||c==="bottom"?A=Math.min(Math.max(14,ae-i),_.width-14):P=Math.min(Math.max(14,ie-y),_.height-14)}(Math.abs(i-S.x)>.5||Math.abs(y-S.y)>.5||A!==S.arrowX||P!==S.arrowY)&&B(D=>D&&{...D,x:i,y,arrowX:A,arrowY:P})},[s,c,S]);const X=()=>{C.current&&(window.clearTimeout(C.current),C.current=null)},T=($,F)=>{if(!Tn()||N.current)return;const V=g.current;if(V&&!Or(V)){if(a){const _=An(V);if(!_)return;z(_)}!a&&!t||B({mouseX:$,mouseY:F,x:$+14,y:F+14})}},U=()=>{const $=g.current;if(!$)return;const F=$.getBoundingClientRect();T(F.left+F.width/2,F.bottom)},Q=()=>{X(),B(null)},re=()=>{if(!n){Q();return}X(),C.current=window.setTimeout(()=>B(null),120)},W=()=>{Ir(),N.current=!0,Q()},J=()=>{N.current=!1};l.useEffect(()=>{if(!S)return;if(Or(g.current)){B(null);return}const $=()=>B(null),F=()=>{Ir(),N.current=!0,B(null)};document.addEventListener("pointerdown",F,!0),document.addEventListener("click",F,!0),document.addEventListener("scroll",$,!0),window.addEventListener("blur",$),document.addEventListener("visibilitychange",$),document.addEventListener("keydown",$,!0);const V=new MutationObserver(()=>{Or(g.current)&&B(null)});return V.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",F,!0),document.removeEventListener("click",F,!0),document.removeEventListener("scroll",$,!0),window.removeEventListener("blur",$),document.removeEventListener("visibilitychange",$),document.removeEventListener("keydown",$,!0),V.disconnect()}},[S]),l.useEffect(()=>{const $=()=>Ir(),F=()=>{Ir(),N.current=!0,B(null)};return document.addEventListener("pointerdown",$,!0),document.addEventListener("click",$,!0),document.addEventListener("keydown",$,!0),window.addEventListener(aa,F),()=>{document.removeEventListener("pointerdown",$,!0),document.removeEventListener("click",$,!0),document.removeEventListener("keydown",$,!0),window.removeEventListener(aa,F)}},[]);const R=a?ee:t;return e.jsxs(e.Fragment,{children:[e.jsx(x,{ref:$=>{g.current=$},className:b,style:m,onMouseEnter:$=>{X(),J(),s?T($.clientX,$.clientY):U()},onMouseMove:$=>{S&&s&&T($.clientX,$.clientY)},onMouseDown:W,onClick:W,onMouseLeave:()=>{J(),re()},onFocus:U,onBlur:Q,children:r}),S&&R&&!Or(g.current)?je.createPortal(e.jsxs("div",{ref:M,role:"tooltip",className:p,onMouseEnter:n?X:void 0,onMouseLeave:n?re:void 0,style:{position:"fixed",top:S.y,left:S.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:n?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...h},children:[u&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(h==null?void 0:h.background)??"var(--bg-card)",borderLeft:c==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderTop:c==="bottom"||c==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderRight:c==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderBottom:c==="top"||c==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:S.arrowX===void 0?void 0:S.arrowX-6,top:S.arrowY===void 0?void 0:S.arrowY-6,zIndex:-1}}),R]}),document.body):null]})}function na(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Hn="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",Dn={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"},Bn="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",In={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"},On={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Fn={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function xt(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(xt).join(" ").trim():l.isValidElement(r)?xt(r.props.children):""}function Pn(r){return l.Children.toArray(r).find(l.isValidElement)??null}function Te({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:c,height:u,padding:b,children:p,className:m="",disabled:h,style:x,...g}){const M=l.useContext(ra),C=c??M.iconOnly??r==="icon",N=M.compact??!1,S=M.headerAction??!1,B=S&&t==="md"?"sm":N&&!S&&t==="md"?"xs":t,ee=r==="icon"||C,z=S&&ee,X=xt(p),T=s??g.title??g["aria-label"]??(C?X:void 0),U=T?void 0:g.title,Q=g["aria-label"]??(typeof T=="string"?T:X||void 0),re=a?null:n??(C?Pn(p):null),W=e.jsxs("button",{...g,title:U,"aria-label":Q,"data-variant":r,"data-size":B,"data-icon":ee?"true":void 0,disabled:h||a,className:`${Hn} ${z?Bn:Dn[r]} ${ee?On[B]:In[B]} ${N&&!ee?"px-2.5":""} ${m}`,style:{...Fn[r],height:na(u),padding:na(b),...x,...S&&!ee?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...z?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):re,!C&&p]});return T?e.jsx(dr,{as:"span",content:T,className:"inline-flex shrink-0",children:W}):W}function la({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(oa,{rows:a}):r==="sections"?e.jsx(zn,{rows:a}):r==="cards"?e.jsx(jn,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] p-6 shadow-[var(--card-shadow)]",style:{background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px) saturate(1.08)",WebkitBackdropFilter:"blur(10px) saturate(1.08)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:n})]})]})})}function zn({rows:r}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:Math.max(2,Math.min(r,4))}).map((t,a)=>e.jsxs("section",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-5 w-20 animate-pulse rounded-full bg-[var(--bg-input)]"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"})]})]}),e.jsx(oa,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function jn({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded bg-[var(--bg-input)]"})]},a))})}function oa({rows:r,compact:t=!1}){const a=t?5:6;return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsx("div",{className:"grid border-b border-[var(--border)]",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((n,s)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"})},s))}),Array.from({length:r}).map((n,s)=>e.jsx("div",{className:"grid border-b border-[var(--border)] last:border-b-0",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((c,u)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-full bg-[var(--bg-input)]",style:{width:`${52+(s*13+u*11)%36}%`}})},u))},s))]})}function sa(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function ia(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function _n(r){return[r.label,sa(r.service),r.description,r.service].filter(Boolean).join(" ")}function Wn(r){return typeof r=="function"?r:r.default}function qn(r,t){return e.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:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(Te,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function Un({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:c,moduleRegistry:u,loadModule:b,activeService:p,initialService:m,onActiveServiceChange:h,canAccess:x,keepAlive:g=!0,title:M,subtitle:C,emptyState:N,loadingState:S,errorState:B=qn,renderTabLabel:ee,searchableTabs:z="auto",tabsSearchThreshold:X=6,tabsSearchPlaceholder:T="Buscar modulo...",tabsSearchValue:U,onTabsSearchChange:Q,emptySearchState:re,showTabCount:W=!0,className:J="",parentClassName:R="",contentClassName:$="",tabsClassName:F=""}){var ze;const V=l.useMemo(()=>c.filter(ne=>!ne.hidden&&((x==null?void 0:x(ne,s))??!0)),[x,s,c]),_=(ze=V.find(ne=>!ne.disabled))==null?void 0:ze.service,[le,q]=l.useState(m??_??""),[i,y]=l.useState({}),[A,P]=l.useState({}),[D,ae]=l.useState(""),[ie,pe]=l.useState(!1),L=l.useRef(A),oe=l.useRef(0),O=U??D,H=ia(O),Z=z===!0||z==="auto"&&V.length>=X,G=Z&&O.trim().length>0,te=l.useMemo(()=>H?V.filter(ne=>ia(_n(ne)).includes(H)):V,[H,V]),ue=p??le,se=V.find(ne=>ne.service===ue)??V.find(ne=>!ne.disabled);l.useEffect(()=>{!se&&_&&q(_)},[_,se]),l.useEffect(()=>{L.current=A},[A]);const w=ne=>{ne.disabled||(p||q(ne.service),h==null||h(ne.service,ne))},I=ne=>{U===void 0&&ae(ne),Q==null||Q(ne)},de=(ne,Me)=>{const $e=te.filter(Ae=>!Ae.disabled),Oe=$e.findIndex(Ae=>Ae.service===Me.service);Oe<0||((ne.key==="ArrowRight"||ne.key==="ArrowDown")&&(ne.preventDefault(),w($e[(Oe+1)%$e.length])),(ne.key==="ArrowLeft"||ne.key==="ArrowUp")&&(ne.preventDefault(),w($e[(Oe-1+$e.length)%$e.length])),ne.key==="Home"&&(ne.preventDefault(),w($e[0])),ne.key==="End"&&(ne.preventDefault(),w($e[$e.length-1])))},be=l.useCallback(()=>{if(!se)return;const ne=se.service,Me=L.current[ne];if(Me!=null&&Me.loading||Me!=null&&Me.component&&g)return;const $e=(u==null?void 0:u[ne])??b;if(!$e){P(Ae=>({...Ae,[ne]:{loading:!1,error:new Error(`No module loader found for service "${ne}".`)}}));return}const Oe=++oe.current;P(Ae=>({...Ae,[ne]:{...Ae[ne],loading:!0,error:void 0}})),$e(se,s).then(Ae=>{if(Oe!==oe.current&&!g)return;const Ye=Wn(Ae);P(Ie=>({...Ie,[ne]:{component:Ye,loading:!1}}))}).catch(Ae=>{const Ye=Ae instanceof Error?Ae:new Error(String(Ae));P(Ie=>({...Ie,[ne]:{...Ie[ne],loading:!1,error:Ye}}))})},[s,g,b,u,se]);l.useEffect(be,[be]);const ke=se?i[se.service]??null:null,me=se?A[se.service]:void 0,Se=me==null?void 0:me.component,we=ne=>{se&&y(Me=>({...Me,[se.service]:ne}))},fe=()=>{se&&y(ne=>({...ne,[se.service]:null}))},Be={context:s,parent:n,links:c,visibleLinks:V,filteredLinks:te,selectedLink:se,selectedService:se==null?void 0:se.service,activeItemId:ke,tabsSearch:O,onSelectService:w,onOpenDetail:we,onBackToList:fe},Ge=a?a(Be):t?e.jsx(t,{...Be}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${J}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${R}`,children:Ge}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${$}`,children:[(M||C||Z||W)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[M&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:M}),C&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:C})]}),(Z||W)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[W&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[te.length," / ",V.length]}),Z&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${ie?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!ie,children:e.jsx(ea,{value:O,onChange:I,placeholder:T,className:"w-full",autoFocus:ie,forceExpanded:!0,onEscape:()=>pe(!1),size:"sm",inputTabIndex:ie?0:-1})}),e.jsx("button",{type:"button","aria-label":ie?"Cerrar busqueda":"Buscar tabs","aria-expanded":ie,onClick:()=>{ie&&O&&I(""),pe(ne=>!ne)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${ie||G?"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:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:ie||G?e.jsx(v.HiXMark,{className:"h-4 w-4"}):e.jsx(v.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":M??"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 ${F}`,children:te.length>0?te.map(ne=>{const Me=ne.service===(se==null?void 0:se.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":Me,disabled:ne.disabled,onClick:()=>w(ne),onKeyDown:$e=>de($e,ne),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Me?"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:ee?ee(ne,Me):e.jsxs(e.Fragment,{children:[ne.icon,e.jsx("span",{children:ne.label??sa(ne.service)}),ne.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ne.badge})]})},ne.service)}):e.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:re??"No hay modulos que coincidan con la busqueda."})}),(se==null?void 0:se.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:se.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!se&&(N??e.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."})),se&&(me==null?void 0:me.loading)&&(S??e.jsx(la,{title:"Cargando modulo..."})),se&&(me==null?void 0:me.error)&&B(me.error,be),se&&Se&&!(me!=null&&me.loading)&&!(me!=null&&me.error)&&e.jsx(Se,{context:s,parent:n,link:se,activeItemId:ke,onOpenDetail:we,onBackToList:fe})]})]})]})}const Vn={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(v.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(v.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(v.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:e.jsx(v.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(v.HiInformationCircle,{className:"h-5 w-5"})}};function Kn({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:c,className:u=""}){const b=Vn[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${u}`,style:{background:b.background,borderColor:b.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:b.color},children:n??b.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),s&&e.jsx("div",{className:"mt-3",children:s})]}),c&&e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:c,className:"-mr-1 -mt-1",children:e.jsx(v.HiXMark,{className:"h-4 w-4"})})]})}const ca=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Gn=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Yn=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],yt=6;function wt(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function Xn(){const r=new Date;return wt(r.getFullYear(),r.getMonth()+1,r.getDate())}function da(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Zn(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=da(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${ca[a-1]} ${t}`}function Jn({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=Xn(),u=da(r||s),b=n==="popover",[p,m]=l.useState(!1),h=l.useRef(null),[x,g]=l.useState({horizontal:"left",vertical:"bottom"}),[M,C]=l.useState(u.year),[N,S]=l.useState(u.month),[B,ee]=l.useState("days"),z=16,[X,T]=l.useState(0),U=M-7+X,Q=Array.from({length:z},(q,i)=>U+i);l.useEffect(()=>{if(!b||!p||!h.current)return;const q=h.current.getBoundingClientRect(),i=8,y=280,A=340,P=q.left+y>window.innerWidth-i,D=q.right-y>=i,ae=q.bottom+8+A>window.innerHeight-i,ie=q.top-8-A>=i;g({horizontal:P&&D?"right":"left",vertical:ae&&ie?"top":"bottom"})},[b,p]),l.useEffect(()=>{if(!b||!p)return;function q(y){h.current&&(h.current.contains(y.target)||m(!1))}function i(y){y.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",q),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",q),document.removeEventListener("keydown",i)}},[b,p]);function re(){N===1?(C(q=>q-1),S(12)):S(q=>q-1)}function W(){N===12?(C(q=>q+1),S(1)):S(q=>q+1)}const J=new Date(M,N-1,1).getDay(),R=new Date(M,N,0).getDate(),$=[...Array(J).fill(null),...Array.from({length:R},(q,i)=>i+1)];for(;$.length<yt*7;)$.push(null);const F=$.slice(0,yt*7);function V(q){const i=wt(M,N,q);a&&i<a||(t(i),b&&m(!1))}const _={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},le=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:B==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:re,style:_,title:"Mes anterior",children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{ee("years"),T(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[ca[N-1]," ",M,e.jsx(v.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:W,style:_,title:"Mes siguiente",children:e.jsx(v.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>T(q=>q-z),style:_,children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>ee("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Q[0]," – ",Q[Q.length-1]]}),e.jsx("button",{type:"button",onClick:()=>T(q=>q+z),style:_,children:e.jsx(v.HiChevronRight,{size:16})})]})}),B==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:Gn.map((q,i)=>{const y=i+1===N;return e.jsx("button",{type:"button",onClick:()=>S(i+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:y?700:400,padding:"4px 0",background:y?"var(--primary)":"transparent",color:y?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:q},q)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:Q.map(q=>{const i=q===M;return e.jsx("button",{type:"button",onClick:()=>{C(q),ee("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:i?700:400,padding:"6px 0",background:i?"var(--primary)":"transparent",color:i?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:q===new Date().getFullYear()&&!i?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:q},q)})})]}),B==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Yn.map(q=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:q},q))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${yt},1fr)`,padding:"4px 8px 10px",gap:2},children:F.map((q,i)=>{if(q===null)return e.jsx("div",{style:{aspectRatio:"1"}},i);const y=wt(M,N,q),A=y===r,P=y===s,D=!!(a&&y<a);return e.jsx("button",{type:"button",onClick:()=>!D&&V(q),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:D?"not-allowed":"pointer",fontSize:12,fontWeight:A||P?700:400,background:A?"var(--primary)":"transparent",color:A?"var(--primary-fg, #ffffff)":D?"var(--text-muted)":"var(--text-main)",opacity:D?.4:1,outline:P&&!A?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:q},i)})})]})]});return b?e.jsxs("div",{ref:h,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>m(q=>!q),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${p?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:p?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(v.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Zn(r)})]}),e.jsx(v.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${p?"rotate-180":""}`})]}),p&&e.jsx("div",{className:"absolute z-50",style:{...x.horizontal==="left"?{left:0}:{right:0},...x.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:le})]}):le}const Qn={sm:"h-4 w-4",md:"h-5 w-5"};function Rn(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Fr=l.forwardRef(function({label:t,description:a,error:n,size:s="md",indeterminate:c=!1,className:u="",containerClassName:b="",disabled:p,...m},h){const x=l.useRef(null);return l.useEffect(()=>{x.current&&(x.current.indeterminate=c)},[c]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${p?"cursor-not-allowed opacity-60":"cursor-pointer"} ${b}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...m,ref:g=>{x.current=g,Rn(h,g)},type:"checkbox",disabled:p,"aria-checked":c?"mixed":m["aria-checked"],"aria-invalid":!!n||m["aria-invalid"],className:`peer ${Qn[s]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${u}`}),e.jsx(v.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(t||a||n)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),a&&!n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:a}),n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:n})]})]})});function ua(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function el(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}ua(r)}function rl(r){return typeof r=="function"?r():r}function Nt({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:c=e.jsx(v.HiClipboardDocument,{size:14}),copiedIcon:u=e.jsx(v.HiCheck,{size:14}),stopPropagation:b=!0,onCopied:p,onCopyError:m,className:h="",style:x,children:g,onClick:M,type:C="button",...N}){const[S,B]=l.useState(!1),ee=l.useRef(null);l.useEffect(()=>()=>{ee.current&&window.clearTimeout(ee.current)},[]);function z(T){B(!0),p==null||p(T),ee.current&&window.clearTimeout(ee.current),ee.current=window.setTimeout(()=>{B(!1),ee.current=null},t)}async function X(T){var Q;if(b&&T.stopPropagation(),M==null||M(T),T.defaultPrevented)return;const U=rl(r);if(U)try{await el(U),z(U)}catch(re){try{ua(U),z(U)}catch(W){m==null||m(W,U);return}(Q=navigator.clipboard)!=null&&Q.writeText||m==null||m(re,U)}}return e.jsxs("button",{...N,type:C,onClick:X,title:S?n:a,"aria-label":N["aria-label"]??(S?n:a),"data-copied":S?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${g?"min-w-7 px-2":"w-7"} ${h}`,style:{cursor:"pointer",background:S?"rgba(22,163,74,0.15)":"var(--bg-card)",border:S?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:S?"#16a34a":"var(--text-secondary)",boxShadow:S?"0 0 0 3px rgba(22,163,74,0.12)":"none",...x},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:S?"scale(1.15)":"scale(1)"},children:S?u:c}),g&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:S?s??g:g})]})}function tl({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:c="Copiado",className:u="",style:b,onCopied:p}){const m=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${u}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...b},children:[e.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:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(Nt,{value:m,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:c,onCopied:p,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.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:e.jsx("code",{className:n?`language-${n}`:void 0,children:m})})]})}function kt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function rr({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:c="default",showSelectedSublabel:u=!0,placeholder:b="Seleccionar…",emptyLabel:p,disabled:m=!1,className:h="",style:x,dropdownMinWidth:g,height:M=40,padding:C="0 10px",searchable:N=!0,minOptionsForSearch:S=6}){const[B,ee]=l.useState(!1),[z,X]=l.useState(""),[T,U]=l.useState(-1),[Q,re]=l.useState(!1),[W,J]=l.useState({}),R=l.useRef(null),$=l.useRef(null),F=l.useRef(null),V=l.useRef(null),_=N&&a.length>=S,le=a.find(O=>O.value===r)??null,q=c==="ghost",i=n==="error"?"var(--danger)":B?"var(--primary)":"var(--border)",y=_&&z.trim()?a.filter(O=>{var H;return O.label.toLowerCase().includes(z.toLowerCase())||((H=O.sublabel)==null?void 0:H.toLowerCase().includes(z.toLowerCase()))}):a,A=l.useCallback(()=>{const O=R.current;if(!O)return;const H=O.getBoundingClientRect(),Z=_?272:212,G=window.innerHeight-H.bottom,te=G<Z&&H.top>G;J({position:"fixed",left:H.left,top:te?void 0:H.bottom+4,bottom:te?window.innerHeight-H.top+4:void 0,width:H.width,minWidth:kt(g),zIndex:9999})},[g,_]);l.useEffect(()=>re(!0),[]),l.useEffect(()=>{if(!B)return;function O(H){var G,te;const Z=H.target;!((G=R.current)!=null&&G.contains(Z))&&!((te=$.current)!=null&&te.contains(Z))&&(ee(!1),X(""))}return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[B]),l.useEffect(()=>{B&&(U(-1),A(),_&&setTimeout(()=>{var O;return(O=F.current)==null?void 0:O.focus()},0))},[B,_,A]),l.useEffect(()=>{if(B)return window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[B,A]),l.useEffect(()=>{if(T<0||!V.current)return;const O=V.current.children[T];O==null||O.scrollIntoView({block:"nearest"})},[T]);const P=l.useCallback(O=>{t(O),ee(!1),X("")},[t]),D=l.useRef(B);D.current=B;const ae=l.useRef(y);ae.current=y;const ie=l.useRef(T);ie.current=T;const pe=l.useRef(p);pe.current=p;const L=l.useRef(P);L.current=P,l.useEffect(()=>{function O(H){var ue,se;const Z=document.activeElement,G=((ue=R.current)==null?void 0:ue.contains(Z))??!1,te=((se=$.current)==null?void 0:se.contains(Z))??!1;if(!(!G&&!te)){if(!D.current){(H.key==="Enter"||H.key===" "||H.key==="ArrowDown")&&(H.preventDefault(),ee(!0));return}switch(H.key){case"ArrowDown":H.preventDefault(),U(w=>Math.min(w+1,ae.current.length-1));break;case"ArrowUp":H.preventDefault(),U(w=>Math.max(w-1,pe.current?-1:0));break;case"Enter":{H.preventDefault();const w=ie.current,I=ae.current;w===-1&&pe.current?L.current(""):I[w]&&!I[w].disabled&&L.current(I[w].value);break}case"Escape":H.preventDefault(),H.stopPropagation(),ee(!1),X("");break}}}return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[]);const oe=e.jsxs("div",{ref:$,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[_&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(v.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:F,value:z,onChange:O=>{X(O.target.value),U(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),z&&e.jsx("button",{type:"button",onMouseDown:O=>{O.preventDefault(),X("")},children:e.jsx(v.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:V,role:"listbox",className:"overflow-y-auto",style:{maxHeight:_?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[p&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:O=>{O.preventDefault(),P("")},onMouseEnter:()=>U(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:T===-1&&!z.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:p}),y.map((O,H)=>{const G=H===T,te=O.value===r;return e.jsxs("li",{role:"option","aria-selected":te,onMouseDown:ue=>{ue.preventDefault(),O.disabled||P(O.value)},onMouseEnter:()=>!O.disabled&&U(H),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:G?"var(--bg-hover)":te?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:O.disabled?"var(--text-muted)":"var(--text-main)",cursor:O.disabled?"not-allowed":"pointer",boxShadow:te?"inset 2px 0 0 var(--primary)":void 0},children:[O.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:O.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:O.label}),O.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:O.sublabel})]}),O.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:O.badge})]},O.value)}),y.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:R,className:`relative ${h||"w-full"}`,style:x,children:[e.jsxs("button",{type:"button",disabled:m,onClick:()=>!m&&ee(O=>!O),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:kt(M),padding:kt(C),background:q?"transparent":"var(--bg-input)",color:le?"var(--text-main)":"var(--text-muted)",border:q?"1px solid transparent":`1px solid ${i}`,opacity:m?.5:1,cursor:m?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":B,"aria-label":s,children:[(le==null?void 0:le.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:le.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:le?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:le.label}),u&&le.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:le.sublabel})]}):e.jsx("span",{className:"truncate",children:b})}),le&&p?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:O=>{O.preventDefault(),O.stopPropagation(),P("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(v.HiXMark,{className:"w-3 h-3"})}):e.jsx(v.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:B?"rotate(180deg)":"rotate(0deg)"}})]}),B&&Q&&je.createPortal(oe,document.body)]})}function Pr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function al({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:c="0 10px 0 30px",iconLeft:u=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(v.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:Pr(u)}}),e.jsx("input",{type:"text",value:r,onChange:b=>t(b.target.value),placeholder:a,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:Pr(s),padding:Pr(c)}})]})}function nl({value:r,onChange:t,options:a,placeholder:n,icon:s,className:c="",height:u=40,padding:b,iconLeft:p=10,searchable:m=!0}){const h=s?a.map((x,g)=>g===0&&!x.color?{...x,sublabel:x.sublabel??void 0}:x):a;return e.jsxs("div",{className:`relative ${c}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Pr(p)},children:s}),e.jsx(rr,{value:r,onChange:t,options:h,placeholder:n,searchable:m,minOptionsForSearch:5,height:u,padding:b??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const ll={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},zr=180,ol="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function St({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:c,footer:u,children:b,size:p="md",maxWidth:m,zIndex:h=1e3,closeOnBackdrop:x=!0,closeOnEscape:g=!0,showCloseButton:M=!0,placement:C="center",bodyClassName:N="px-6 py-5",panelClassName:S="",backdropClassName:B=ol,contentClassName:ee="p-4",ariaLabel:z,frameless:X=!1,disabled:T=!1}){const[U,Q]=l.useState(!1),[re,W]=l.useState(!1),J=l.useRef(null);if(l.useEffect(()=>(r?(J.current&&clearTimeout(J.current),Q(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>W(!0)))):(W(!1),J.current=setTimeout(()=>Q(!1),zr+40)),()=>{J.current&&clearTimeout(J.current)}),[r]),l.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),l.useEffect(()=>{if(!r||!g)return;const le=q=>{q.key==="Escape"&&t()};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[g,t,r]),!U)return null;const R=a||n||s||c||M,$=m??ll[p],F=C==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",V=C==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",_=re?"translateY(0) scale(1)":C==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return je.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":z??a,className:`fixed inset-0 flex ${F} ${ee}`,style:{zIndex:h},children:[e.jsx("div",{className:`absolute inset-0 ${B}`,onClick:x?t:void 0,style:{opacity:re?1:0,transition:`opacity ${zr}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${X?"shadow-none":"shadow-2xl"} ${V} ${S}`,style:{maxWidth:$,background:X?"transparent":"var(--bg-card)",border:X?"none":"1px solid var(--border)",opacity:re?1:0,transform:_,transition:`opacity ${zr}ms ease, transform ${zr}ms ease`},onClick:le=>le.stopPropagation(),children:[T&&e.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)"}}),R&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[c,M&&e.jsx(Te,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(v.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${N}`,children:b}),u&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:u})]})]}),document.body)}const sl={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 il({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:c="danger",closeOnBackdrop:u=!0,onConfirm:b,onCancel:p}){const m=sl[c];return e.jsxs(St,{open:r,onClose:p,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,closeOnBackdrop:u,children:[e.jsx(Te,{variant:"icon",onClick:p,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(v.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:m.iconBg},children:e.jsx(v.HiExclamationTriangle,{className:"h-5 w-5",style:{color:m.iconColor}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main)"},children:t}),a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:a}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:p,className:"flex-1",style:{background:"var(--bg-input)"},children:s}),e.jsx(Te,{variant:"danger",onClick:b,className:"flex-1",style:{background:m.btnBg,color:m.btnColor,borderColor:"transparent"},children:n})]})]})}function cl(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function dl({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:s=e.jsx(v.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(Nt,{...c,value:()=>cl(r,t),title:a,copiedTitle:n,icon:s})}const jr=[{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"}],ul=jr.map(r=>({value:r.value,label:r.label})),bl=12,fl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!1},pl="bonsaif-ui:datatable:",ml="[&_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",hl=[],vl=52;function tr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function gl(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function ba(r){return`${pl}${r}`}function fa(r){try{const t=window.localStorage.getItem(ba(r));if(!t)return null;const a=JSON.parse(t);return a&&typeof a=="object"?a:null}catch{return null}}function xl(r,t){try{window.localStorage.setItem(ba(r),JSON.stringify(t))}catch{}}function yl(r){return r===!0?{layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0}:r===!1?{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1}:{...fl,...r??{}}}function _r(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function Wr(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=Object.entries(r).flatMap(([n,s])=>{if(!t.has(n)||!Array.isArray(s))return[];const c=s.filter(u=>typeof u=="string");return c.length>0?[[n,c]]:[]});return Object.fromEntries(a)}function qr(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=new Set(jr.map(s=>s.value)),n=Object.entries(r).flatMap(([s,c])=>{if(!t.has(s)||!c||typeof c!="object")return[];const u=c;return!u.operator||!a.has(u.operator)?[]:[[s,{operator:u.operator,value:typeof u.value=="string"?u.value:"",valueTo:typeof u.valueTo=="string"?u.valueTo:""}]]});return Object.fromEntries(n)}function Ke(r,t){if(ar(r))return vl;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function wl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function ar(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Nl(r,t){if(t<=7)return Array.from({length:t},(n,s)=>s+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function nr(r,t){var u;const a=new Set(t.filter(b=>b.hideable!==!1).map(b=>b.key)),n=Array.from(new Set(r??[])).filter(b=>a.has(b));if(t.filter(b=>!n.includes(b.key)).length>0)return n;const c=(u=t.find(b=>b.hideable!==!1))==null?void 0:u.key;return c?n.filter(b=>b!==c):[]}function kl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function ur(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(ur).join(" ").trim():l.isValidElement(r)?ur(r.props.children):""}function Ur(r,t){const a=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||a===null||a===void 0||a instanceof Date?kl(a):ur(a).trim()}function Nr(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function br(r,t){const a=Nr(r),n=Nr(t);return a!==null&&n!==null?a-n:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function Sl(r,t,a){var u,b;const n=((u=t.value)==null?void 0:u.trim())??"",s=((b=t.valueTo)==null?void 0:b.trim())??"",c=jr.find(p=>p.value===t.operator);if((c==null?void 0:c.valueMode)==="single"&&!n||(c==null?void 0:c.valueMode)==="between"&&(!n||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===n.toLowerCase();case"notEquals":return r.toLowerCase()!==n.toLowerCase();case"greaterThan":return br(r,n)>0;case"greaterThanOrEqual":return br(r,n)>=0;case"lessThan":return br(r,n)<0;case"lessThanOrEqual":return br(r,n)<=0;case"between":return br(r,n)>=0&&br(r,s)<=0;case"top10":case"bottom10":{const m=a.map(x=>({value:x,number:Nr(x)})).filter(x=>x.number!==null).sort((x,g)=>x.number-g.number).map(x=>x.value);return(t.operator==="top10"?m.slice(-10):m.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const p=a.map(Nr).filter(x=>x!==null);if(p.length===0)return!1;const m=p.reduce((x,g)=>x+g,0)/p.length,h=Nr(r);return h===null?!1:t.operator==="aboveAverage"?h>m:h<m}default:return!0}}function pa({children:r,className:t="",style:a}){return e.jsx(dr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function ma({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:c,emptyText:u="Sin resultados",initialEmptyDelay:b=450,onRowClick:p,renderExpandedRow:m,getRowCanExpand:h,expandedRowIds:x,defaultExpandedRowIds:g=[],onExpandedRowIdsChange:M,expandOnRowClick:C=!1,selected:N,onToggleOne:S,onToggleAll:B,highlightSelected:ee=!0,rowClassName:z,getRowCategory:X,stickyHeader:T=!0,pageSize:U=25,pageSizeOptions:Q=[25,50,100],pageSizeSelectWidth:re=62,pageSizeSelectHeight:W=30,pageSizeSelectPadding:J="0 7px",totalRows:R,page:$,onPageChange:F,onPageSizeChange:V,storageKey:_,stickyFirstColumn:le=!1,bottomOffset:q=0,compact:i=!0,restrictHeight:y=!0,maxHeight:A,minTableWidth:P,enableColumnVisibility:D=!0,enableColumnFilters:ae=!0,hiddenColumnKeys:ie,defaultHiddenColumnKeys:pe=hl,onHiddenColumnKeysChange:L,columnVisibilityLabel:oe="Columnas",enableBql:O=!1,bqlValue:H,defaultBqlValue:Z="",onBqlChange:G,bqlDescription:te="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ue=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:se=[],bqlExamples:w=[],bqlSuggestions:I=[],bqlActiveFilters:de,bqlError:be,onQueryChange:ke,persistState:me,enableExport:Se=!1,exportFilename:we="datos"}){var Mn;const fe=yl(me),Be=Object.values(fe).some(Boolean),Ge=r.map(o=>o.key).join(","),ze=pe.join(","),ne=l.useRef(r),Me=l.useRef(pe);ne.current=r,Me.current=pe;const[$e,Oe]=l.useState(!_||!Be),Ae=l.useRef(null),Ye=l.useRef(!_),Ie=ie!==void 0,[ws,Sr]=l.useState(()=>nr(pe,r)),Fe=nr(Ie?ie:ws,r),[Re,Zr]=l.useState(!1),[lr,Ns]=l.useState("filter"),[Cr,Jr]=l.useState(null),[Xa,Za]=l.useState(""),[Pe,Er]=l.useState({}),[We,Qr]=l.useState({}),Ht=x!==void 0,[Ja,ks]=l.useState(g),Mr=H!==void 0,[Ss,Dt]=l.useState(Z),Xe=Mr?H:Ss,[Rr,et]=l.useState(Xe),[Ze,or]=l.useState(!1),[Qa,fr]=l.useState(!1),[Ra,pr]=l.useState(!1),[$r,Lr]=l.useState([]),Bt=l.useRef(null),en=l.useRef(null),It=l.useRef(null),[Cs,Es]=l.useState({}),[Ms,$s]=l.useState({}),[Tr,rt]=l.useState(!1),Ot=l.useRef(null),tt=l.useRef(null),[Ls,Ts]=l.useState({}),rn=l.useRef(null),at=l.useRef(null),[Ft,tn]=l.useState(t.length>0||n||b===!1),an=(o,d)=>50+(o*17+d*13+7)%40,er=l.useRef(null),[As,Hs]=l.useState(void 0),[nn,Ds]=l.useState(0),[Pt,Bs]=l.useState(!1);l.useEffect(()=>{function o(){Bs(window.innerWidth<640)}if(!y||A!==void 0)return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o);const E=U!==!1?48:0,f=12;function K(){if(o(),!er.current)return;const k=er.current.getBoundingClientRect().top;Hs(Math.max(120,window.innerHeight-k-E-f-q))}return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[n,U,q,y,A]);const ln=y?A??As:void 0;l.useEffect(()=>{const o=er.current;if(!o)return;const d=()=>Ds(o.clientWidth);if(d(),typeof ResizeObserver>"u")return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d);const E=new ResizeObserver(d);return E.observe(o),()=>E.disconnect()},[n,$e,t.length]),l.useEffect(()=>{if(b===!1||n||t.length>0){tn(!0);return}if(Ft)return;const o=window.setTimeout(()=>{tn(!0)},b);return()=>window.clearTimeout(o)},[t.length,b,Ft,n]);const[mr,Ar]=l.useState(()=>r.map(o=>o.key)),[hr,Hr]=l.useState(()=>Object.fromEntries(r.map(o=>[o.key,Ke(o,tr(o.width))]))),[Ce,vr]=l.useState(null),[Is,nt]=l.useState(1),[lt,zt]=l.useState(U===!1?0:U);l.useEffect(()=>{const o=ne.current,d=Me.current,E=o.map(k=>k.key),f=new Set(E);if(!_||!Be){fe.layout&&Ar(E),Ie||Sr(nr(d,o)),Ye.current=!1,Oe(!0);return}let K=!1;return Ye.current=!1,Oe(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(_)}`,{cache:"no-store"}).then(k=>k.ok?k.json():null).then(k=>{if(K)return;const ce=fa(_),j=gl(k==null?void 0:k.settings)?k==null?void 0:k.settings:ce,Ee=fe.layout?j==null?void 0:j.columnOrder:void 0,Ne=Array.isArray(Ee)?Ee.filter(Le=>E.includes(Le)):[],he=E.filter(Le=>!Ne.includes(Le)),ge=Ne.length>0?[...Ne,...he]:E,ve=Object.fromEntries(o.map(Le=>[Le.key,Ke(Le,tr(Le.width))])),He=fe.layout?(j==null?void 0:j.columnWidths)??{}:{},ye=Object.fromEntries(o.map(Le=>[Le.key,Ke(Le,He[Le.key]??ve[Le.key])])),gt=nr(fe.layout?(j==null?void 0:j.hiddenColumnKeys)??d:d,o);if(fe.layout&&(Ar(ge),Hr(ye)),Ie||Sr(gt),fe.filters&&(Er(Wr(j==null?void 0:j.filters,f)),Qr(qr(j==null?void 0:j.conditionFilters,f))),fe.sort){const Le=_r(j==null?void 0:j.sort)?j.sort:null;vr(Le&&f.has(Le.key)?Le:null)}if(fe.bql){const Le=typeof(j==null?void 0:j.bql)=="string"?j.bql:Z;Mr?G==null||G(Le):Dt(Le)}fe.bql&&Lr(Array.isArray(j==null?void 0:j.bqlHistory)?j.bqlHistory.filter(Le=>typeof Le=="string"):[]),fe.pagination&&typeof(j==null?void 0:j.pageSize)=="number"&&j.pageSize>0&&zt(j.pageSize),Ae.current=JSON.stringify({columnOrder:ge,columnWidths:ye,hiddenColumnKeys:gt,filters:Wr(j==null?void 0:j.filters,f),conditionFilters:qr(j==null?void 0:j.conditionFilters,f),sort:_r(j==null?void 0:j.sort)?j.sort:null,bql:typeof(j==null?void 0:j.bql)=="string"?j.bql:"",bqlHistory:Array.isArray(j==null?void 0:j.bqlHistory)?j.bqlHistory:[],pageSize:typeof(j==null?void 0:j.pageSize)=="number"?j.pageSize:void 0}),Ye.current=!0}).catch(()=>{if(!K){const k=fa(_),ce=fe.layout?k==null?void 0:k.columnOrder:void 0,j=Array.isArray(ce)?ce.filter(ye=>E.includes(ye)):[],Ee=E.filter(ye=>!j.includes(ye)),Ne=j.length>0?[...j,...Ee]:E,he=Object.fromEntries(o.map(ye=>[ye.key,Ke(ye,tr(ye.width))])),ge=fe.layout?(k==null?void 0:k.columnWidths)??{}:{},ve=Object.fromEntries(o.map(ye=>[ye.key,Ke(ye,ge[ye.key]??he[ye.key])]));fe.layout&&(Ar(Ne),Hr(ve));const He=nr(fe.layout?(k==null?void 0:k.hiddenColumnKeys)??d:d,o);if(Ie||Sr(He),fe.filters&&(Er(Wr(k==null?void 0:k.filters,f)),Qr(qr(k==null?void 0:k.conditionFilters,f))),fe.sort){const ye=_r(k==null?void 0:k.sort)?k.sort:null;vr(ye&&f.has(ye.key)?ye:null)}if(fe.bql){const ye=typeof(k==null?void 0:k.bql)=="string"?k.bql:Z;Mr?G==null||G(ye):Dt(ye)}fe.bql&&Lr(Array.isArray(k==null?void 0:k.bqlHistory)?k.bqlHistory.filter(ye=>typeof ye=="string"):[]),fe.pagination&&typeof(k==null?void 0:k.pageSize)=="number"&&k.pageSize>0&&zt(k.pageSize),Ae.current=JSON.stringify({columnOrder:Ne,columnWidths:ve,hiddenColumnKeys:He,filters:Wr(k==null?void 0:k.filters,f),conditionFilters:qr(k==null?void 0:k.conditionFilters,f),sort:_r(k==null?void 0:k.sort)?k.sort:null,bql:typeof(k==null?void 0:k.bql)=="string"?k.bql:"",bqlHistory:Array.isArray(k==null?void 0:k.bqlHistory)?k.bqlHistory:[],pageSize:typeof(k==null?void 0:k.pageSize)=="number"?k.pageSize:void 0}),Ye.current=!0}}).finally(()=>{K||Oe(!0)}),()=>{K=!0}},[_,Be,Ge,ze,Ie,fe.layout,fe.filters,fe.sort,fe.bql,fe.pagination,Mr,G,Z]),l.useEffect(()=>{if(!_||!$e||!Be||!Ye.current)return;const o={};fe.layout&&(o.columnOrder=mr,o.columnWidths=hr,o.hiddenColumnKeys=Fe),fe.filters&&(o.filters=Pe,o.conditionFilters=We),fe.sort&&(o.sort=Ce),fe.bql&&(o.bql=Xe,o.bqlHistory=$r),fe.pagination&&U!==!1&&(o.pageSize=lt);const d=JSON.stringify(o);if(d===Ae.current)return;xl(_,o),Ae.current=d;const E=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_,settings:o})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(E)},[mr,hr,Fe,Pe,We,Ce,Xe,$r,lt,U,_,$e,Be,fe.layout,fe.filters,fe.sort,fe.bql,fe.pagination]),l.useEffect(()=>{Ar(o=>{const d=r.map(K=>K.key),E=o.filter(K=>d.includes(K)),f=d.filter(K=>!E.includes(K));return[...E,...f]})},[Ge,r]);const on=mr.map(o=>r.find(d=>d.key===o)).filter(o=>!!o),qe=on.filter(o=>!Fe.includes(o.key)),Os=Object.keys(Pe).length,Fs=Object.keys(We).length,jt=Os+Fs;function sn(o){const d=new Set;return t.reduce((E,f)=>{const K=Ur(o,f);return!K||d.has(K)||(d.add(K),E.push({value:K,label:K})),E},[])}function Ps(){const o=r.find(d=>d.key===Cr);return o?sn(o):[]}function zs(o){return!!(ae&&!ar(o)&&(o.filterValue||o.sortKey||sn(o).length>0))}function cn(o,d){Er(E=>{const f={...E};return f[o]=d,f})}function js(o,d,E,f){const K=Pe[o]??[],k=f?K:E.filter(j=>j!==d),ce=f?K.includes(d)?K.filter(j=>j!==d):[...K,d]:k;ce.length===E.length?_t(o):cn(o,ce)}function _t(o){Er(d=>{const E={...d};return delete E[o],E})}function ot(o,d){Qr(E=>{const f={...E};return d?f[o]=d:delete f[o],f})}function dn(o){ot(o,null)}function _s(){Er({}),Qr({})}function un(o){Mr||Dt(o),G==null||G(o)}function st(o){const d=o.trim();et(d),un(d),or(!1),fr(!1),pr(!1),d&&Lr(E=>[d,...E.filter(f=>f!==d)].slice(0,bl))}function bn(){et(""),un(""),or(!1),fr(!1),pr(!1)}function Wt(o,d){et(o),d&&(d.style.height="auto",d.style.height=`${Math.min(d.scrollHeight,180)}px`)}l.useEffect(()=>{et(Xe)},[Xe]);const it=l.useCallback(()=>{const o=Bt.current;if(!o)return;const d=o.getBoundingClientRect(),E=12,f=8,K=Math.min(780,Math.max(320,window.innerWidth-32)),k=Math.max(E,window.innerWidth-K-E),ce=Math.min(Math.max(E,d.left),k),j=d.bottom+f,Ee=window.innerHeight-d.top+f,Ne=window.innerHeight-j-E,he=d.top-E-f,ge=Ne<280&&he>Ne,ve=Math.max(240,ge?he:Ne);Es({position:"fixed",zIndex:1e4,left:ce,top:ge?void 0:j,bottom:ge?Ee:void 0,width:K,maxWidth:"calc(100vw - 24px)",maxHeight:ve,overflowY:"auto"})},[]);l.useEffect(()=>{if(!Ze)return;function o(f){var k,ce;const K=f.target;(k=Bt.current)!=null&&k.contains(K)||(ce=en.current)!=null&&ce.contains(K)||(or(!1),fr(!1),pr(!1))}function d(f){f.key==="Escape"&&(or(!1),fr(!1),pr(!1))}function E(){it()}return it(),document.addEventListener("mousedown",o),window.addEventListener("keydown",d),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",d),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[Ze,it]);function fn(o){const d=nr(o,r);Ie||Sr(d),L==null||L(d)}function Ws(o){fn(Fe.includes(o)?Fe.filter(d=>d!==o):[...Fe,o])}function qs(){fn([])}const qt=l.useCallback((o=at.current)=>{if(!o)return;const d=o.getBoundingClientRect(),E=Math.min(292,Math.max(240,window.innerWidth-16)),f=Math.max(8,window.innerWidth-E-8),K=Math.min(Math.max(8,d.right-E),f),k=window.innerHeight-d.bottom,ce=d.bottom+6,j=window.innerHeight-d.top+6,Ne=k<360&&d.top>k?void 0:ce,he=Ne===void 0?j:void 0,ge=Math.max(220,Ne===void 0?d.top-16:window.innerHeight-ce-8),ve={position:"fixed",zIndex:9999,left:K,top:Ne,bottom:he,width:E,maxWidth:"calc(100vw - 16px)",maxHeight:ge,"--dt-column-menu-max-height":`${ge}px`};$s(ve)},[]);function pn(o,d,E=null){o.preventDefault(),o.stopPropagation();const f=at.current===o.currentTarget&&lr===d&&Cr===E;if(Re&&f){Zr(!1),Jr(null);return}at.current=o.currentTarget,Ns(d),Jr(E),Za(""),qt(o.currentTarget),Zr(!0)}function Us(o){if(ar(o))return;const d=er.current;if(!d)return;const f=Array.from(d.querySelectorAll("[data-dt-column-key]")).filter(K=>K.dataset.dtColumnKey===o.key).reduce((K,k)=>{const ce=k.querySelector("[data-dt-autofit-content]"),j=ce?ce.scrollWidth:Math.max(k.scrollWidth,k.offsetWidth);return Math.max(K,Math.ceil(j+wl(k)))},0);f<=0||Hr(K=>({...K,[o.key]:Ke(o,f+12)}))}l.useEffect(()=>{Hr(o=>{const d=Object.fromEntries(r.map(E=>[E.key,Ke(E,tr(E.width))]));return Object.fromEntries(r.map(E=>[E.key,Ke(E,o[E.key]??d[E.key])]))})},[Ge,r]),l.useEffect(()=>{Ie||Sr(o=>nr(o,r))},[Ge,r,Ie]),l.useEffect(()=>{function o(f){var ce,j;const K=f.target,k=f.target;k!=null&&k.closest("[data-bonsaif-select-dropdown='true']")||!((ce=rn.current)!=null&&ce.contains(K))&&!((j=at.current)!=null&&j.contains(K))&&(Zr(!1),Jr(null))}function d(f){f.key==="Escape"&&(Zr(!1),Jr(null))}function E(){qt()}return Re&&(document.addEventListener("mousedown",o),window.addEventListener("keydown",d),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0)),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",d),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[Re,qt]);const Dr=l.useRef(null);l.useEffect(()=>{function o(E){const f=Dr.current;if(!f)return;const K=E.clientX-f.startX,k=r.find(ce=>ce.key===f.colKey);k&&Hr(ce=>({...ce,[f.colKey]:Ke(k,f.startWidth+K)}))}function d(){Dr.current&&(Dr.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",o),document.addEventListener("pointerup",d),()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",d)}},[r]);const ct=l.useRef(null),[mn,Ut]=l.useState(null);function Vs(o,d){ct.current=mr.indexOf(o),d.dataTransfer.effectAllowed="move"}function Ks(o,d){d.preventDefault(),d.dataTransfer.dropEffect="move";const E=mr.indexOf(o);mn!==E&&Ut(E)}function Gs(o,d){d.preventDefault();const E=ct.current,f=mr.indexOf(o);E!==null&&E!==f&&Ar(K=>{const k=[...K],[ce]=k.splice(E,1);return k.splice(f,0,ce),k}),ct.current=null,Ut(null)}function Ys(){ct.current=null,Ut(null)}function Xs(o){o.sortKey&&vr(d=>(d==null?void 0:d.key)===o.key?{key:o.key,dir:d.dir==="asc"?"desc":"asc"}:{key:o.key,dir:"asc"})}l.useEffect(()=>{nt(1)},[t]),l.useEffect(()=>{nt(1)},[We,Pe]);const sr=!!(F&&V),ir=U!==!1,De=sr?$??1:Is,Ue=sr||ir?lt:t.length,Ve=!!N&&!!S&&!!B,gr=!!m,hn=l.useMemo(()=>new Set(Ht?Array.from(x??[]):Ja),[Ht,x,Ja]),Vt=(gr?40:0)+(Ve?40:0),Zs=Ve&&t.length>0&&N.size===t.length,Js=Ve&&N.size>0&&N.size<t.length,dt=l.useMemo(()=>{const o=Object.entries(Pe),d=Object.entries(We);return o.length===0&&d.length===0?t:t.filter(E=>o.every(([f,K])=>{const k=r.find(ce=>ce.key===f);return k?K.includes(Ur(k,E)):!0})&&d.every(([f,K])=>{const k=r.find(j=>j.key===f);if(!k)return!0;const ce=t.map(j=>Ur(k,j));return Sl(Ur(k,E),K,ce)}))},[We,Pe,r,t]),cr=l.useMemo(()=>{if(!Ce)return dt;const o=r.find(d=>d.key===Ce.key&&d.sortKey);return o!=null&&o.sortKey?[...dt].sort((d,E)=>{const f=d[o.sortKey],K=E[o.sortKey],k=f===K?0:f==null?1:K==null||f<K?-1:1;return Ce.dir==="asc"?k:-k}):dt},[dt,Ce,r]),vn=l.useMemo(()=>{if(sr||!ir)return cr;const o=(De-1)*Ue;return cr.slice(o,o+Ue)},[cr,sr,ir,De,Ue]),xr=sr?R??t.length:cr.length,Kt=ir?Math.max(1,Math.ceil(xr/Ue)):1,Qs=ir&&xr>Ue,Rs=ir?(De-1)*Ue+1:1,ei=ir?Math.min(De*Ue,xr):xr;function Gt(o){if(n)return;const d=Math.max(1,Math.min(o,Kt));sr?F(d):nt(d)}function ri(o){n||(zt(o),sr?(V(o),F(1)):nt(1),V&&V(o))}function gn(o){const d=new Set(hn);d.has(o)?d.delete(o):d.add(o);const E=Array.from(d);Ht||ks(E),M==null||M(E)}l.useEffect(()=>{ke==null||ke({bql:Xe,filters:Pe,conditionFilters:We,sort:Ce,page:De,pageSize:Ue,hiddenColumnKeys:Fe})},[Xe,Pe,We,Ce,De,Ue,Fe,ke]);const xn=o=>o==="center"?"text-center":o==="right"?"text-right":"text-left",ti="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Yt="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",xe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",yr="color-mix(in srgb, var(--primary) 24%, var(--border))",ut=`inset 0 0 0 1px ${xe}`,yn=qe.reduce((o,d)=>o+(hr[d.key]??tr(d.width)),(gr?40:0)+(Ve?40:0)),wn=typeof P=="number"?P:typeof P=="string"?Number(((Mn=P.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Mn[1])??NaN):NaN,Br=Number.isFinite(wn)?Math.max(yn,wn,nn):Math.max(yn,nn),bt=P??Br,wr=`${gr?"40px ":""}${Ve?"40px ":""}${qe.map(o=>`${hr[o.key]??tr(o.width)}px`).join(" ")}`;l.useEffect(()=>{Ce&&Fe.includes(Ce.key)&&vr(null)},[Fe,Ce]);function Nn(o){return o?typeof o=="string"?{key:o,label:o}:o:null}const ft=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,background:Yt,borderBottom:`1px solid ${yr}`},children:[gr&&e.jsx("div",{role:"columnheader",className:`${i?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${xe}`}}),Ve&&e.jsx("div",{role:"columnheader",className:`${i?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:le?{position:"sticky",left:0,zIndex:12,background:Yt,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${xe}`},children:e.jsx(Fr,{size:"sm",checked:Zs,indeterminate:Js,onChange:B,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),qe.map((o,d)=>{const E=(Ce==null?void 0:Ce.key)===o.key,f=!!o.sortKey,K=ar(o),k=le&&!Pt&&d===0,ce=mn===d,Ee=(hr[o.key]??tr(o.width))<120,Ne=Object.prototype.hasOwnProperty.call(Pe,o.key)||Object.prototype.hasOwnProperty.call(We,o.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":o.key,className:`group select-none ${Ee?"text-left":xn(o.align)}`,style:{...k?{position:"sticky",left:Vt,zIndex:12,background:Yt,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${xe}`}:{position:"relative",borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${xe}`},color:E?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ce?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:K?i?"7px 6px":"9px 8px":i?"8px 6px 10px":"10px 8px 12px"},onDragOver:he=>Ks(o.key,he),onDrop:he=>Gs(o.key,he),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${K?"justify-center":Ee?"justify-start":o.align==="center"?"justify-center":o.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:he=>{he.stopPropagation(),Vs(o.key,he)},onDragEnd:he=>{he.stopPropagation(),Ys()},onClick:he=>he.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 ${ce?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),K?e.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:e.jsx(v.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(pa,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${i?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:o.header})})}),f&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(o.header)}`,title:"Ordenar",onClick:he=>{he.stopPropagation(),Xs(o)},"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 ${E?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:E?Ce.dir==="asc"?e.jsx(v.HiChevronUp,{className:"h-3 w-3"}):e.jsx(v.HiChevronDown,{className:"h-3 w-3"}):e.jsx(v.HiChevronUpDown,{className:"h-3 w-3"})}),ae&&!K&&zs(o)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&Cr===o.key,"aria-label":`Filtrar ${String(o.header)}`,title:"Filtrar",onClick:he=>pn(he,"filter",o.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 ${Re&&lr==="filter"&&Cr===o.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Ne?"text-[var(--primary)] opacity-100":""}`,children:Ne?e.jsx(v.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(v.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!K&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:he=>{he.preventDefault(),he.stopPropagation(),Dr.current={colKey:o.key,startX:he.clientX,startWidth:hr[o.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:he=>{he.preventDefault(),he.stopPropagation(),Dr.current=null,document.body.style.cursor="",document.body.style.userSelect="",Us(o)},onClick:he=>he.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:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},o.key)})]}),pt=()=>{if(!Re||typeof document>"u"||lr==="visibility"&&!D||lr==="filter"&&!ae)return null;const o=r.find(ve=>ve.key===Cr),d=Ps(),E=o?Object.prototype.hasOwnProperty.call(Pe,o.key):!1,f=o?We[o.key]:void 0,K=jr.find(ve=>ve.value===(f==null?void 0:f.operator)),k=o?Pe[o.key]??[]:[],ce=Xa.trim().toLowerCase(),j=ce?d.filter(ve=>ve.label.toLowerCase().includes(ce)):d,Ee=o&&d.length>0&&(!E||k.length===d.length),Ne=o&&E&&k.length>0&&k.length<d.length,he=Fe.length,ge=()=>{o&&(_t(o.key),dn(o.key))};return je.createPortal(e.jsx("div",{ref:rn,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ms,borderColor:"var(--border)",background:"var(--bg-card)"},children:lr==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:he>0?`${qe.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:qs,disabled:he===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:on.map(ve=>{const He=!Fe.includes(ve.key),gt=!(ve.hideable!==!1)||He&&qe.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":He,disabled:gt,onClick:()=>Ws(ve.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:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:He?"var(--primary)":"var(--border)",background:He?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:He&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.header})]},ve.key)})})]}):o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",o.header]}),e.jsx("button",{type:"button",onClick:ge,disabled:!E&&!f,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"})]}),o.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>vr({key:o.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(v.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ce==null?void 0:Ce.key)===o.key&&Ce.dir==="asc"&&e.jsx(v.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>vr({key:o.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(v.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ce==null?void 0:Ce.key)===o.key&&Ce.dir==="desc"&&e.jsx(v.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[e.jsx(rr,{value:(f==null?void 0:f.operator)??"",onChange:ve=>{if(!ve){dn(o.key);return}ot(o.key,{operator:ve,value:(f==null?void 0:f.value)??"",valueTo:(f==null?void 0:f.valueTo)??""})},options:ul,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"}),(K==null?void 0:K.valueMode)!=="none"?e.jsx("input",{value:(f==null?void 0:f.value)??"",onChange:ve=>{f&&ot(o.key,{...f,value:ve.target.value})},disabled:!f,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)"}}):e.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"})]}),(K==null?void 0:K.valueMode)==="between"&&e.jsx("input",{value:(f==null?void 0:f.valueTo)??"",onChange:ve=>{f&&ot(o.key,{...f,valueTo:ve.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)"}})]}),e.jsx("div",{className:"border-b border-[var(--border)] p-2",children:e.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:[e.jsx(v.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Xa,onChange:ve=>Za(ve.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)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne?"mixed":!!Ee,onClick:()=>{o&&(Ee&&!E?cn(o.key,[]):_t(o.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:[e.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee||Ne?"var(--primary)":"var(--border)",background:Ee||Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ne&&e.jsx(v.HiMinus,{className:"h-3 w-3"}),Ee&&!Ne&&e.jsx(v.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),j.map(ve=>{const He=!E||k.includes(ve.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":He,onClick:()=>js(o.key,ve.value,d.map(ye=>ye.value),E),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:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:He?"var(--primary)":"var(--border)",background:He?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:He&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.label})]},ve.value)}),j.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};l.useEffect(()=>{if(!Tr)return;function o(d){Ot.current&&!Ot.current.contains(d.target)&&tt.current&&!tt.current.contains(d.target)&&rt(!1)}return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[Tr]);function kn(o,d){if(o.filterValue){const E=o.filterValue(d);return E==null||E===""?"":String(E)}return ur(o.cell(d))}function Sn(o){return`"${o.replace(/"/g,'""')}"`}function mt(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ai(){const o=qe.filter(j=>!ar(j)),d=o.map(j=>Sn(ur(j.header))).join(","),E=cr.map(j=>o.map(Ee=>Sn(kn(Ee,j))).join(",")).join(`
|
|
1
|
+
(function(Y,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),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","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],l):(Y=typeof globalThis<"u"?globalThis:Y||self,l(Y.BonsaifUI={},Y.React,Y.jsxRuntime,Y.ReactIconsHi2,Y.ReactDOM,Y.OverlayScrollbarsGlobal,Y.Sonner,Y.OverlayScrollbarsReact,Y.ReactDayPicker,Y.ReactDayPickerStyles,Y.ReactIconsFi))})(this,(function(Y,l,e,v,je,Zt,Jt,Qt,Rt,li,$n){"use strict";"use client";function Je(...r){return r.filter(Boolean).join(" ")}function Ln({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:Je("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function ea({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:c=!1,onEscape:u,size:b="default",inputTabIndex:p}){const m=l.useRef(null),[h,x]=l.useState(!1),g=c||h||r.trim().length>0,$=b==="sm"?"h-9 rounded-md":"h-10 rounded-lg",C=n||"w-48 max-w-full sm:w-64 lg:w-72";l.useEffect(()=>{var S;s&&((S=m.current)==null||S.focus())},[s]);const N=()=>{var S;x(!0),(S=m.current)==null||S.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${g?C:"w-24 sm:w-28"}`,onMouseDown:S=>{g||(S.preventDefault(),N())},children:[e.jsx(v.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)"}}),e.jsx("input",{ref:m,type:"text",tabIndex:p,"aria-label":a,value:r,onChange:S=>t(S.target.value),onKeyDown:S=>{S.key==="Escape"&&(u==null||u())},placeholder:g?a:"Buscar",className:`${$} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${g?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${b==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:g?"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:S=>{x(!0),S.currentTarget.style.borderColor="var(--primary)",S.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:S=>{x(!1),S.currentTarget.style.borderColor="var(--border)",S.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const ra=l.createContext({});let ta=0;const aa="bonsaif-ui:hide-tooltips";function Ir(r=700){ta=Date.now()+r}function Tn(){return Date.now()>ta}function Or(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(a=>a.contains(r))?!1:t.length>0}function An(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var c;return s.scrollWidth>s.clientWidth&&!!((c=s.textContent)!=null&&c.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function dr({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:c="bottom",showArrow:u=!1,className:b="",tooltipClassName:p="",style:m,tooltipStyle:h,as:x="div"}){const g=l.useRef(null),$=l.useRef(null),C=l.useRef(null),N=l.useRef(!1),[S,B]=l.useState(null),[ee,z]=l.useState("");l.useEffect(()=>{const T=g.current;T&&(T.querySelectorAll("[title]").forEach(P=>{const V=P.getAttribute("title");V&&(P.getAttribute("aria-label")||P.setAttribute("aria-label",V),P.removeAttribute("title"))}),T.querySelectorAll("svg title").forEach(P=>P.remove()))}),l.useLayoutEffect(()=>{if(!S)return;const T=$.current;if(!T)return;const P=12,V=14,_=T.getBoundingClientRect(),le=window.innerWidth-_.width-P,q=window.innerHeight-_.height-P;let i=S.mouseX+V,y=S.mouseY+V,M,O;if(!s&&g.current){const D=g.current.getBoundingClientRect(),ae=D.left+D.width/2,ie=D.top+D.height/2;c==="top"?(i=ae-_.width/2,y=D.top-_.height-V,O=_.height-1):c==="left"?(i=D.left-_.width-V,y=ie-_.height/2,M=_.width-1):c==="right"?(i=D.right+V,y=ie-_.height/2,M=-7):(i=ae-_.width/2,y=D.bottom+V,O=-7)}if(s&&(i>le&&(i=S.mouseX-_.width-V),y>q&&(y=S.mouseY-_.height-V)),i=Math.min(Math.max(P,i),Math.max(P,le)),y=Math.min(Math.max(P,y),Math.max(P,q)),!s&&g.current){const D=g.current.getBoundingClientRect(),ae=D.left+D.width/2,ie=D.top+D.height/2;c==="top"||c==="bottom"?M=Math.min(Math.max(14,ae-i),_.width-14):O=Math.min(Math.max(14,ie-y),_.height-14)}(Math.abs(i-S.x)>.5||Math.abs(y-S.y)>.5||M!==S.arrowX||O!==S.arrowY)&&B(D=>D&&{...D,x:i,y,arrowX:M,arrowY:O})},[s,c,S]);const X=()=>{C.current&&(window.clearTimeout(C.current),C.current=null)},L=(T,P)=>{if(!Tn()||N.current)return;const V=g.current;if(V&&!Or(V)){if(a){const _=An(V);if(!_)return;z(_)}!a&&!t||B({mouseX:T,mouseY:P,x:T+14,y:P+14})}},U=()=>{const T=g.current;if(!T)return;const P=T.getBoundingClientRect();L(P.left+P.width/2,P.bottom)},Q=()=>{X(),B(null)},re=()=>{if(!n){Q();return}X(),C.current=window.setTimeout(()=>B(null),120)},W=()=>{Ir(),N.current=!0,Q()},J=()=>{N.current=!1};l.useEffect(()=>{if(!S)return;if(Or(g.current)){B(null);return}const T=()=>B(null),P=()=>{Ir(),N.current=!0,B(null)};document.addEventListener("pointerdown",P,!0),document.addEventListener("click",P,!0),document.addEventListener("scroll",T,!0),window.addEventListener("blur",T),document.addEventListener("visibilitychange",T),document.addEventListener("keydown",T,!0);const V=new MutationObserver(()=>{Or(g.current)&&B(null)});return V.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",P,!0),document.removeEventListener("click",P,!0),document.removeEventListener("scroll",T,!0),window.removeEventListener("blur",T),document.removeEventListener("visibilitychange",T),document.removeEventListener("keydown",T,!0),V.disconnect()}},[S]),l.useEffect(()=>{const T=()=>Ir(),P=()=>{Ir(),N.current=!0,B(null)};return document.addEventListener("pointerdown",T,!0),document.addEventListener("click",T,!0),document.addEventListener("keydown",T,!0),window.addEventListener(aa,P),()=>{document.removeEventListener("pointerdown",T,!0),document.removeEventListener("click",T,!0),document.removeEventListener("keydown",T,!0),window.removeEventListener(aa,P)}},[]);const R=a?ee:t;return e.jsxs(e.Fragment,{children:[e.jsx(x,{ref:T=>{g.current=T},className:b,style:m,onMouseEnter:T=>{X(),J(),s?L(T.clientX,T.clientY):U()},onMouseMove:T=>{S&&s&&L(T.clientX,T.clientY)},onMouseDown:W,onClick:W,onMouseLeave:()=>{J(),re()},onFocus:U,onBlur:Q,children:r}),S&&R&&!Or(g.current)?je.createPortal(e.jsxs("div",{ref:$,role:"tooltip",className:p,onMouseEnter:n?X:void 0,onMouseLeave:n?re:void 0,style:{position:"fixed",top:S.y,left:S.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:n?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...h},children:[u&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(h==null?void 0:h.background)??"var(--bg-card)",borderLeft:c==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderTop:c==="bottom"||c==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderRight:c==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderBottom:c==="top"||c==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:S.arrowX===void 0?void 0:S.arrowX-6,top:S.arrowY===void 0?void 0:S.arrowY-6,zIndex:-1}}),R]}),document.body):null]})}function na(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Hn="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",Dn={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"},Bn="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",In={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"},On={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Fn={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function xt(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(xt).join(" ").trim():l.isValidElement(r)?xt(r.props.children):""}function Pn(r){return l.Children.toArray(r).find(l.isValidElement)??null}function Te({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:c,height:u,padding:b,children:p,className:m="",disabled:h,style:x,...g}){const $=l.useContext(ra),C=c??$.iconOnly??r==="icon",N=$.compact??!1,S=$.headerAction??!1,B=S&&t==="md"?"sm":N&&!S&&t==="md"?"xs":t,ee=r==="icon"||C,z=S&&ee,X=xt(p),L=s??g.title??g["aria-label"]??(C?X:void 0),U=L?void 0:g.title,Q=g["aria-label"]??(typeof L=="string"?L:X||void 0),re=a?null:n??(C?Pn(p):null),W=e.jsxs("button",{...g,title:U,"aria-label":Q,"data-variant":r,"data-size":B,"data-icon":ee?"true":void 0,disabled:h||a,className:`${Hn} ${z?Bn:Dn[r]} ${ee?On[B]:In[B]} ${N&&!ee?"px-2.5":""} ${m}`,style:{...Fn[r],height:na(u),padding:na(b),...x,...S&&!ee?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...z?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):re,!C&&p]});return L?e.jsx(dr,{as:"span",content:L,className:"inline-flex shrink-0",children:W}):W}function la({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(oa,{rows:a}):r==="sections"?e.jsx(zn,{rows:a}):r==="cards"?e.jsx(jn,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] p-6 shadow-[var(--card-shadow)]",style:{background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px) saturate(1.08)",WebkitBackdropFilter:"blur(10px) saturate(1.08)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:n})]})]})})}function zn({rows:r}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:Math.max(2,Math.min(r,4))}).map((t,a)=>e.jsxs("section",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-5 w-20 animate-pulse rounded-full bg-[var(--bg-input)]"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"})]})]}),e.jsx(oa,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function jn({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded bg-[var(--bg-input)]"})]},a))})}function oa({rows:r,compact:t=!1}){const a=t?5:6;return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsx("div",{className:"grid border-b border-[var(--border)]",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((n,s)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"})},s))}),Array.from({length:r}).map((n,s)=>e.jsx("div",{className:"grid border-b border-[var(--border)] last:border-b-0",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((c,u)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-full bg-[var(--bg-input)]",style:{width:`${52+(s*13+u*11)%36}%`}})},u))},s))]})}function sa(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function ia(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function _n(r){return[r.label,sa(r.service),r.description,r.service].filter(Boolean).join(" ")}function Wn(r){return typeof r=="function"?r:r.default}function qn(r,t){return e.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:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(Te,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function Un({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:c,moduleRegistry:u,loadModule:b,activeService:p,initialService:m,onActiveServiceChange:h,canAccess:x,keepAlive:g=!0,title:$,subtitle:C,emptyState:N,loadingState:S,errorState:B=qn,renderTabLabel:ee,searchableTabs:z="auto",tabsSearchThreshold:X=6,tabsSearchPlaceholder:L="Buscar modulo...",tabsSearchValue:U,onTabsSearchChange:Q,emptySearchState:re,showTabCount:W=!0,className:J="",parentClassName:R="",contentClassName:T="",tabsClassName:P=""}){var ze;const V=l.useMemo(()=>c.filter(ne=>!ne.hidden&&((x==null?void 0:x(ne,s))??!0)),[x,s,c]),_=(ze=V.find(ne=>!ne.disabled))==null?void 0:ze.service,[le,q]=l.useState(m??_??""),[i,y]=l.useState({}),[M,O]=l.useState({}),[D,ae]=l.useState(""),[ie,pe]=l.useState(!1),A=l.useRef(M),oe=l.useRef(0),F=U??D,H=ia(F),Z=z===!0||z==="auto"&&V.length>=X,G=Z&&F.trim().length>0,te=l.useMemo(()=>H?V.filter(ne=>ia(_n(ne)).includes(H)):V,[H,V]),ue=p??le,se=V.find(ne=>ne.service===ue)??V.find(ne=>!ne.disabled);l.useEffect(()=>{!se&&_&&q(_)},[_,se]),l.useEffect(()=>{A.current=M},[M]);const w=ne=>{ne.disabled||(p||q(ne.service),h==null||h(ne.service,ne))},I=ne=>{U===void 0&&ae(ne),Q==null||Q(ne)},de=(ne,Me)=>{const $e=te.filter(Ae=>!Ae.disabled),Oe=$e.findIndex(Ae=>Ae.service===Me.service);Oe<0||((ne.key==="ArrowRight"||ne.key==="ArrowDown")&&(ne.preventDefault(),w($e[(Oe+1)%$e.length])),(ne.key==="ArrowLeft"||ne.key==="ArrowUp")&&(ne.preventDefault(),w($e[(Oe-1+$e.length)%$e.length])),ne.key==="Home"&&(ne.preventDefault(),w($e[0])),ne.key==="End"&&(ne.preventDefault(),w($e[$e.length-1])))},be=l.useCallback(()=>{if(!se)return;const ne=se.service,Me=A.current[ne];if(Me!=null&&Me.loading||Me!=null&&Me.component&&g)return;const $e=(u==null?void 0:u[ne])??b;if(!$e){O(Ae=>({...Ae,[ne]:{loading:!1,error:new Error(`No module loader found for service "${ne}".`)}}));return}const Oe=++oe.current;O(Ae=>({...Ae,[ne]:{...Ae[ne],loading:!0,error:void 0}})),$e(se,s).then(Ae=>{if(Oe!==oe.current&&!g)return;const Ye=Wn(Ae);O(Ie=>({...Ie,[ne]:{component:Ye,loading:!1}}))}).catch(Ae=>{const Ye=Ae instanceof Error?Ae:new Error(String(Ae));O(Ie=>({...Ie,[ne]:{...Ie[ne],loading:!1,error:Ye}}))})},[s,g,b,u,se]);l.useEffect(be,[be]);const ke=se?i[se.service]??null:null,me=se?M[se.service]:void 0,Se=me==null?void 0:me.component,we=ne=>{se&&y(Me=>({...Me,[se.service]:ne}))},fe=()=>{se&&y(ne=>({...ne,[se.service]:null}))},Be={context:s,parent:n,links:c,visibleLinks:V,filteredLinks:te,selectedLink:se,selectedService:se==null?void 0:se.service,activeItemId:ke,tabsSearch:F,onSelectService:w,onOpenDetail:we,onBackToList:fe},Ge=a?a(Be):t?e.jsx(t,{...Be}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${J}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${R}`,children:Ge}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${T}`,children:[($||C||Z||W)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[$&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:$}),C&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:C})]}),(Z||W)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[W&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[te.length," / ",V.length]}),Z&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${ie?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!ie,children:e.jsx(ea,{value:F,onChange:I,placeholder:L,className:"w-full",autoFocus:ie,forceExpanded:!0,onEscape:()=>pe(!1),size:"sm",inputTabIndex:ie?0:-1})}),e.jsx("button",{type:"button","aria-label":ie?"Cerrar busqueda":"Buscar tabs","aria-expanded":ie,onClick:()=>{ie&&F&&I(""),pe(ne=>!ne)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${ie||G?"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:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:ie||G?e.jsx(v.HiXMark,{className:"h-4 w-4"}):e.jsx(v.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":$??"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 ${P}`,children:te.length>0?te.map(ne=>{const Me=ne.service===(se==null?void 0:se.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":Me,disabled:ne.disabled,onClick:()=>w(ne),onKeyDown:$e=>de($e,ne),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Me?"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:ee?ee(ne,Me):e.jsxs(e.Fragment,{children:[ne.icon,e.jsx("span",{children:ne.label??sa(ne.service)}),ne.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ne.badge})]})},ne.service)}):e.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:re??"No hay modulos que coincidan con la busqueda."})}),(se==null?void 0:se.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:se.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!se&&(N??e.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."})),se&&(me==null?void 0:me.loading)&&(S??e.jsx(la,{title:"Cargando modulo..."})),se&&(me==null?void 0:me.error)&&B(me.error,be),se&&Se&&!(me!=null&&me.loading)&&!(me!=null&&me.error)&&e.jsx(Se,{context:s,parent:n,link:se,activeItemId:ke,onOpenDetail:we,onBackToList:fe})]})]})]})}const Vn={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(v.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(v.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(v.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:e.jsx(v.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(v.HiInformationCircle,{className:"h-5 w-5"})}};function Kn({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:c,className:u=""}){const b=Vn[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${u}`,style:{background:b.background,borderColor:b.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:b.color},children:n??b.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),s&&e.jsx("div",{className:"mt-3",children:s})]}),c&&e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:c,className:"-mr-1 -mt-1",children:e.jsx(v.HiXMark,{className:"h-4 w-4"})})]})}const ca=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Gn=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Yn=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],yt=6;function wt(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function Xn(){const r=new Date;return wt(r.getFullYear(),r.getMonth()+1,r.getDate())}function da(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Zn(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=da(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${ca[a-1]} ${t}`}function Jn({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=Xn(),u=da(r||s),b=n==="popover",[p,m]=l.useState(!1),h=l.useRef(null),[x,g]=l.useState({horizontal:"left",vertical:"bottom"}),[$,C]=l.useState(u.year),[N,S]=l.useState(u.month),[B,ee]=l.useState("days"),z=16,[X,L]=l.useState(0),U=$-7+X,Q=Array.from({length:z},(q,i)=>U+i);l.useEffect(()=>{if(!b||!p||!h.current)return;const q=h.current.getBoundingClientRect(),i=8,y=280,M=340,O=q.left+y>window.innerWidth-i,D=q.right-y>=i,ae=q.bottom+8+M>window.innerHeight-i,ie=q.top-8-M>=i;g({horizontal:O&&D?"right":"left",vertical:ae&&ie?"top":"bottom"})},[b,p]),l.useEffect(()=>{if(!b||!p)return;function q(y){h.current&&(h.current.contains(y.target)||m(!1))}function i(y){y.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",q),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",q),document.removeEventListener("keydown",i)}},[b,p]);function re(){N===1?(C(q=>q-1),S(12)):S(q=>q-1)}function W(){N===12?(C(q=>q+1),S(1)):S(q=>q+1)}const J=new Date($,N-1,1).getDay(),R=new Date($,N,0).getDate(),T=[...Array(J).fill(null),...Array.from({length:R},(q,i)=>i+1)];for(;T.length<yt*7;)T.push(null);const P=T.slice(0,yt*7);function V(q){const i=wt($,N,q);a&&i<a||(t(i),b&&m(!1))}const _={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},le=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:B==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:re,style:_,title:"Mes anterior",children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{ee("years"),L(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[ca[N-1]," ",$,e.jsx(v.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:W,style:_,title:"Mes siguiente",children:e.jsx(v.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>L(q=>q-z),style:_,children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>ee("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Q[0]," – ",Q[Q.length-1]]}),e.jsx("button",{type:"button",onClick:()=>L(q=>q+z),style:_,children:e.jsx(v.HiChevronRight,{size:16})})]})}),B==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:Gn.map((q,i)=>{const y=i+1===N;return e.jsx("button",{type:"button",onClick:()=>S(i+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:y?700:400,padding:"4px 0",background:y?"var(--primary)":"transparent",color:y?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:q},q)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:Q.map(q=>{const i=q===$;return e.jsx("button",{type:"button",onClick:()=>{C(q),ee("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:i?700:400,padding:"6px 0",background:i?"var(--primary)":"transparent",color:i?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:q===new Date().getFullYear()&&!i?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:q},q)})})]}),B==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Yn.map(q=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:q},q))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${yt},1fr)`,padding:"4px 8px 10px",gap:2},children:P.map((q,i)=>{if(q===null)return e.jsx("div",{style:{aspectRatio:"1"}},i);const y=wt($,N,q),M=y===r,O=y===s,D=!!(a&&y<a);return e.jsx("button",{type:"button",onClick:()=>!D&&V(q),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:D?"not-allowed":"pointer",fontSize:12,fontWeight:M||O?700:400,background:M?"var(--primary)":"transparent",color:M?"var(--primary-fg, #ffffff)":D?"var(--text-muted)":"var(--text-main)",opacity:D?.4:1,outline:O&&!M?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:q},i)})})]})]});return b?e.jsxs("div",{ref:h,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>m(q=>!q),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${p?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:p?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(v.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Zn(r)})]}),e.jsx(v.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${p?"rotate-180":""}`})]}),p&&e.jsx("div",{className:"absolute z-50",style:{...x.horizontal==="left"?{left:0}:{right:0},...x.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:le})]}):le}const Qn={sm:"h-4 w-4",md:"h-5 w-5"};function Rn(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Fr=l.forwardRef(function({label:t,description:a,error:n,size:s="md",indeterminate:c=!1,className:u="",containerClassName:b="",disabled:p,...m},h){const x=l.useRef(null);return l.useEffect(()=>{x.current&&(x.current.indeterminate=c)},[c]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${p?"cursor-not-allowed opacity-60":"cursor-pointer"} ${b}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...m,ref:g=>{x.current=g,Rn(h,g)},type:"checkbox",disabled:p,"aria-checked":c?"mixed":m["aria-checked"],"aria-invalid":!!n||m["aria-invalid"],className:`peer ${Qn[s]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${u}`}),e.jsx(v.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(t||a||n)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),a&&!n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:a}),n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:n})]})]})});function ua(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function el(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}ua(r)}function rl(r){return typeof r=="function"?r():r}function Nt({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:c=e.jsx(v.HiClipboardDocument,{size:14}),copiedIcon:u=e.jsx(v.HiCheck,{size:14}),stopPropagation:b=!0,onCopied:p,onCopyError:m,className:h="",style:x,children:g,onClick:$,type:C="button",...N}){const[S,B]=l.useState(!1),ee=l.useRef(null);l.useEffect(()=>()=>{ee.current&&window.clearTimeout(ee.current)},[]);function z(L){B(!0),p==null||p(L),ee.current&&window.clearTimeout(ee.current),ee.current=window.setTimeout(()=>{B(!1),ee.current=null},t)}async function X(L){var Q;if(b&&L.stopPropagation(),$==null||$(L),L.defaultPrevented)return;const U=rl(r);if(U)try{await el(U),z(U)}catch(re){try{ua(U),z(U)}catch(W){m==null||m(W,U);return}(Q=navigator.clipboard)!=null&&Q.writeText||m==null||m(re,U)}}return e.jsxs("button",{...N,type:C,onClick:X,title:S?n:a,"aria-label":N["aria-label"]??(S?n:a),"data-copied":S?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${g?"min-w-7 px-2":"w-7"} ${h}`,style:{cursor:"pointer",background:S?"rgba(22,163,74,0.15)":"var(--bg-card)",border:S?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:S?"#16a34a":"var(--text-secondary)",boxShadow:S?"0 0 0 3px rgba(22,163,74,0.12)":"none",...x},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:S?"scale(1.15)":"scale(1)"},children:S?u:c}),g&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:S?s??g:g})]})}function tl({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:c="Copiado",className:u="",style:b,onCopied:p}){const m=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${u}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...b},children:[e.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:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(Nt,{value:m,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:c,onCopied:p,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.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:e.jsx("code",{className:n?`language-${n}`:void 0,children:m})})]})}function kt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function rr({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:c="default",showSelectedSublabel:u=!0,placeholder:b="Seleccionar…",emptyLabel:p,disabled:m=!1,className:h="",style:x,dropdownMinWidth:g,height:$=40,padding:C="0 10px",searchable:N=!0,minOptionsForSearch:S=6}){const[B,ee]=l.useState(!1),[z,X]=l.useState(""),[L,U]=l.useState(-1),[Q,re]=l.useState(!1),[W,J]=l.useState({}),R=l.useRef(null),T=l.useRef(null),P=l.useRef(null),V=l.useRef(null),_=N&&a.length>=S,le=a.find(F=>F.value===r)??null,q=c==="ghost",i=n==="error"?"var(--danger)":B?"var(--primary)":"var(--border)",y=_&&z.trim()?a.filter(F=>{var H;return F.label.toLowerCase().includes(z.toLowerCase())||((H=F.sublabel)==null?void 0:H.toLowerCase().includes(z.toLowerCase()))}):a,M=l.useCallback(()=>{const F=R.current;if(!F)return;const H=F.getBoundingClientRect(),Z=_?272:212,G=window.innerHeight-H.bottom,te=G<Z&&H.top>G;J({position:"fixed",left:H.left,top:te?void 0:H.bottom+4,bottom:te?window.innerHeight-H.top+4:void 0,width:H.width,minWidth:kt(g),zIndex:9999})},[g,_]);l.useEffect(()=>re(!0),[]),l.useEffect(()=>{if(!B)return;function F(H){var G,te;const Z=H.target;!((G=R.current)!=null&&G.contains(Z))&&!((te=T.current)!=null&&te.contains(Z))&&(ee(!1),X(""))}return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[B]),l.useEffect(()=>{B&&(U(-1),M(),_&&setTimeout(()=>{var F;return(F=P.current)==null?void 0:F.focus()},0))},[B,_,M]),l.useEffect(()=>{if(B)return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[B,M]),l.useEffect(()=>{if(L<0||!V.current)return;const F=V.current.children[L];F==null||F.scrollIntoView({block:"nearest"})},[L]);const O=l.useCallback(F=>{t(F),ee(!1),X("")},[t]),D=l.useRef(B);D.current=B;const ae=l.useRef(y);ae.current=y;const ie=l.useRef(L);ie.current=L;const pe=l.useRef(p);pe.current=p;const A=l.useRef(O);A.current=O,l.useEffect(()=>{function F(H){var ue,se;const Z=document.activeElement,G=((ue=R.current)==null?void 0:ue.contains(Z))??!1,te=((se=T.current)==null?void 0:se.contains(Z))??!1;if(!(!G&&!te)){if(!D.current){(H.key==="Enter"||H.key===" "||H.key==="ArrowDown")&&(H.preventDefault(),ee(!0));return}switch(H.key){case"ArrowDown":H.preventDefault(),U(w=>Math.min(w+1,ae.current.length-1));break;case"ArrowUp":H.preventDefault(),U(w=>Math.max(w-1,pe.current?-1:0));break;case"Enter":{H.preventDefault();const w=ie.current,I=ae.current;w===-1&&pe.current?A.current(""):I[w]&&!I[w].disabled&&A.current(I[w].value);break}case"Escape":H.preventDefault(),H.stopPropagation(),ee(!1),X("");break}}}return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[]);const oe=e.jsxs("div",{ref:T,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[_&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(v.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:P,value:z,onChange:F=>{X(F.target.value),U(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),z&&e.jsx("button",{type:"button",onMouseDown:F=>{F.preventDefault(),X("")},children:e.jsx(v.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:V,role:"listbox",className:"overflow-y-auto",style:{maxHeight:_?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[p&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:F=>{F.preventDefault(),O("")},onMouseEnter:()=>U(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:L===-1&&!z.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:p}),y.map((F,H)=>{const G=H===L,te=F.value===r;return e.jsxs("li",{role:"option","aria-selected":te,onMouseDown:ue=>{ue.preventDefault(),F.disabled||O(F.value)},onMouseEnter:()=>!F.disabled&&U(H),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:G?"var(--bg-hover)":te?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:F.disabled?"var(--text-muted)":"var(--text-main)",cursor:F.disabled?"not-allowed":"pointer",boxShadow:te?"inset 2px 0 0 var(--primary)":void 0},children:[F.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:F.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:F.label}),F.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:F.sublabel})]}),F.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:F.badge})]},F.value)}),y.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:R,className:`relative ${h||"w-full"}`,style:x,children:[e.jsxs("button",{type:"button",disabled:m,onClick:()=>!m&&ee(F=>!F),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:kt($),padding:kt(C),background:q?"transparent":"var(--bg-input)",color:le?"var(--text-main)":"var(--text-muted)",border:q?"1px solid transparent":`1px solid ${i}`,opacity:m?.5:1,cursor:m?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":B,"aria-label":s,children:[(le==null?void 0:le.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:le.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:le?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:le.label}),u&&le.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:le.sublabel})]}):e.jsx("span",{className:"truncate",children:b})}),le&&p?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:F=>{F.preventDefault(),F.stopPropagation(),O("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(v.HiXMark,{className:"w-3 h-3"})}):e.jsx(v.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:B?"rotate(180deg)":"rotate(0deg)"}})]}),B&&Q&&je.createPortal(oe,document.body)]})}function Pr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function al({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:c="0 10px 0 30px",iconLeft:u=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(v.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:Pr(u)}}),e.jsx("input",{type:"text",value:r,onChange:b=>t(b.target.value),placeholder:a,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:Pr(s),padding:Pr(c)}})]})}function nl({value:r,onChange:t,options:a,placeholder:n,icon:s,className:c="",height:u=40,padding:b,iconLeft:p=10,searchable:m=!0}){const h=s?a.map((x,g)=>g===0&&!x.color?{...x,sublabel:x.sublabel??void 0}:x):a;return e.jsxs("div",{className:`relative ${c}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Pr(p)},children:s}),e.jsx(rr,{value:r,onChange:t,options:h,placeholder:n,searchable:m,minOptionsForSearch:5,height:u,padding:b??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const ll={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},zr=180,ol="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function St({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:c,footer:u,children:b,size:p="md",maxWidth:m,zIndex:h=1e3,closeOnBackdrop:x=!0,closeOnEscape:g=!0,showCloseButton:$=!0,placement:C="center",bodyClassName:N="px-6 py-5",panelClassName:S="",backdropClassName:B=ol,contentClassName:ee="p-4",ariaLabel:z,frameless:X=!1,disabled:L=!1}){const[U,Q]=l.useState(!1),[re,W]=l.useState(!1),J=l.useRef(null);if(l.useEffect(()=>(r?(J.current&&clearTimeout(J.current),Q(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>W(!0)))):(W(!1),J.current=setTimeout(()=>Q(!1),zr+40)),()=>{J.current&&clearTimeout(J.current)}),[r]),l.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),l.useEffect(()=>{if(!r||!g)return;const le=q=>{q.key==="Escape"&&t()};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[g,t,r]),!U)return null;const R=a||n||s||c||$,T=m??ll[p],P=C==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",V=C==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",_=re?"translateY(0) scale(1)":C==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return je.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":z??a,className:`fixed inset-0 flex ${P} ${ee}`,style:{zIndex:h},children:[e.jsx("div",{className:`absolute inset-0 ${B}`,onClick:x?t:void 0,style:{opacity:re?1:0,transition:`opacity ${zr}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${X?"shadow-none":"shadow-2xl"} ${V} ${S}`,style:{maxWidth:T,background:X?"transparent":"var(--bg-card)",border:X?"none":"1px solid var(--border)",opacity:re?1:0,transform:_,transition:`opacity ${zr}ms ease, transform ${zr}ms ease`},onClick:le=>le.stopPropagation(),children:[L&&e.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)"}}),R&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[c,$&&e.jsx(Te,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(v.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${N}`,children:b}),u&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:u})]})]}),document.body)}const sl={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 il({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:c="danger",closeOnBackdrop:u=!0,onConfirm:b,onCancel:p}){const m=sl[c];return e.jsxs(St,{open:r,onClose:p,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,closeOnBackdrop:u,children:[e.jsx(Te,{variant:"icon",onClick:p,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(v.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:m.iconBg},children:e.jsx(v.HiExclamationTriangle,{className:"h-5 w-5",style:{color:m.iconColor}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main)"},children:t}),a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:a}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:p,className:"flex-1",style:{background:"var(--bg-input)"},children:s}),e.jsx(Te,{variant:"danger",onClick:b,className:"flex-1",style:{background:m.btnBg,color:m.btnColor,borderColor:"transparent"},children:n})]})]})}function cl(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function dl({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:s=e.jsx(v.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(Nt,{...c,value:()=>cl(r,t),title:a,copiedTitle:n,icon:s})}const jr=[{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"}],ul=jr.map(r=>({value:r.value,label:r.label})),bl=12,fl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!1},pl="bonsaif-ui:datatable:",ml="[&_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",hl=[],vl=52;function tr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function gl(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function ba(r){return`${pl}${r}`}function fa(r){try{const t=window.localStorage.getItem(ba(r));if(!t)return null;const a=JSON.parse(t);return a&&typeof a=="object"?a:null}catch{return null}}function xl(r,t){try{window.localStorage.setItem(ba(r),JSON.stringify(t))}catch{}}function yl(r){return r===!0?{layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0}:r===!1?{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1}:{...fl,...r??{}}}function _r(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function Wr(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=Object.entries(r).flatMap(([n,s])=>{if(!t.has(n)||!Array.isArray(s))return[];const c=s.filter(u=>typeof u=="string");return c.length>0?[[n,c]]:[]});return Object.fromEntries(a)}function qr(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=new Set(jr.map(s=>s.value)),n=Object.entries(r).flatMap(([s,c])=>{if(!t.has(s)||!c||typeof c!="object")return[];const u=c;return!u.operator||!a.has(u.operator)?[]:[[s,{operator:u.operator,value:typeof u.value=="string"?u.value:"",valueTo:typeof u.valueTo=="string"?u.valueTo:""}]]});return Object.fromEntries(n)}function Ke(r,t){if(ar(r))return vl;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function wl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function ar(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Nl(r,t){if(t<=7)return Array.from({length:t},(n,s)=>s+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function nr(r,t){var u;const a=new Set(t.filter(b=>b.hideable!==!1).map(b=>b.key)),n=Array.from(new Set(r??[])).filter(b=>a.has(b));if(t.filter(b=>!n.includes(b.key)).length>0)return n;const c=(u=t.find(b=>b.hideable!==!1))==null?void 0:u.key;return c?n.filter(b=>b!==c):[]}function kl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function ur(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(ur).join(" ").trim():l.isValidElement(r)?ur(r.props.children):""}function Ur(r,t){const a=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||a===null||a===void 0||a instanceof Date?kl(a):ur(a).trim()}function Nr(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function br(r,t){const a=Nr(r),n=Nr(t);return a!==null&&n!==null?a-n:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function Sl(r,t,a){var u,b;const n=((u=t.value)==null?void 0:u.trim())??"",s=((b=t.valueTo)==null?void 0:b.trim())??"",c=jr.find(p=>p.value===t.operator);if((c==null?void 0:c.valueMode)==="single"&&!n||(c==null?void 0:c.valueMode)==="between"&&(!n||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===n.toLowerCase();case"notEquals":return r.toLowerCase()!==n.toLowerCase();case"greaterThan":return br(r,n)>0;case"greaterThanOrEqual":return br(r,n)>=0;case"lessThan":return br(r,n)<0;case"lessThanOrEqual":return br(r,n)<=0;case"between":return br(r,n)>=0&&br(r,s)<=0;case"top10":case"bottom10":{const m=a.map(x=>({value:x,number:Nr(x)})).filter(x=>x.number!==null).sort((x,g)=>x.number-g.number).map(x=>x.value);return(t.operator==="top10"?m.slice(-10):m.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const p=a.map(Nr).filter(x=>x!==null);if(p.length===0)return!1;const m=p.reduce((x,g)=>x+g,0)/p.length,h=Nr(r);return h===null?!1:t.operator==="aboveAverage"?h>m:h<m}default:return!0}}function pa({children:r,className:t="",style:a}){return e.jsx(dr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function ma({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:c,emptyText:u="Sin resultados",initialEmptyDelay:b=450,onRowClick:p,renderExpandedRow:m,getRowCanExpand:h,expandedRowIds:x,defaultExpandedRowIds:g=[],onExpandedRowIdsChange:$,expandOnRowClick:C=!1,selected:N,onToggleOne:S,onToggleAll:B,highlightSelected:ee=!0,rowClassName:z,getRowCategory:X,stickyHeader:L=!0,pageSize:U=25,pageSizeOptions:Q=[25,50,100],pageSizeSelectWidth:re=62,pageSizeSelectHeight:W=30,pageSizeSelectPadding:J="0 7px",totalRows:R,page:T,onPageChange:P,onPageSizeChange:V,storageKey:_,stickyFirstColumn:le=!1,bottomOffset:q=0,compact:i=!0,restrictHeight:y=!0,maxHeight:M,minTableWidth:O,enableColumnVisibility:D=!0,enableColumnFilters:ae=!0,hiddenColumnKeys:ie,defaultHiddenColumnKeys:pe=hl,onHiddenColumnKeysChange:A,columnVisibilityLabel:oe="Columnas",enableBql:F=!1,bqlValue:H,defaultBqlValue:Z="",onBqlChange:G,bqlDescription:te="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ue=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:se=[],bqlExamples:w=[],bqlSuggestions:I=[],bqlActiveFilters:de,bqlError:be,onQueryChange:ke,persistState:me,enableExport:Se=!1,exportFilename:we="datos"}){var Mn;const fe=yl(me),Be=Object.values(fe).some(Boolean),Ge=r.map(o=>o.key).join(","),ze=pe.join(","),ne=l.useRef(r),Me=l.useRef(pe);ne.current=r,Me.current=pe;const[$e,Oe]=l.useState(!_||!Be),Ae=l.useRef(null),Ye=l.useRef(!_),Ie=ie!==void 0,[ws,Sr]=l.useState(()=>nr(pe,r)),Fe=nr(Ie?ie:ws,r),[Re,Zr]=l.useState(!1),[lr,Ns]=l.useState("filter"),[Cr,Jr]=l.useState(null),[Xa,Za]=l.useState(""),[Pe,Er]=l.useState({}),[We,Qr]=l.useState({}),Ht=x!==void 0,[Ja,ks]=l.useState(g),Mr=H!==void 0,[Ss,Dt]=l.useState(Z),Xe=Mr?H:Ss,[Rr,et]=l.useState(Xe),[Ze,or]=l.useState(!1),[Qa,fr]=l.useState(!1),[Ra,pr]=l.useState(!1),[$r,Lr]=l.useState([]),Bt=l.useRef(null),en=l.useRef(null),It=l.useRef(null),[Cs,Es]=l.useState({}),[Ms,$s]=l.useState({}),[Tr,rt]=l.useState(!1),Ot=l.useRef(null),tt=l.useRef(null),[Ls,Ts]=l.useState({}),rn=l.useRef(null),at=l.useRef(null),[Ft,tn]=l.useState(t.length>0||n||b===!1),an=(o,d)=>50+(o*17+d*13+7)%40,er=l.useRef(null),[As,Hs]=l.useState(void 0),[nn,Ds]=l.useState(0),[Pt,Bs]=l.useState(!1);l.useEffect(()=>{function o(){Bs(window.innerWidth<640)}if(!y||M!==void 0)return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o);const E=U!==!1?48:0,f=12;function K(){if(o(),!er.current)return;const k=er.current.getBoundingClientRect().top;Hs(Math.max(120,window.innerHeight-k-E-f-q))}return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[n,U,q,y,M]);const ln=y?M??As:void 0;l.useEffect(()=>{const o=er.current;if(!o)return;const d=()=>Ds(o.clientWidth);if(d(),typeof ResizeObserver>"u")return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d);const E=new ResizeObserver(d);return E.observe(o),()=>E.disconnect()},[n,$e,t.length]),l.useEffect(()=>{if(b===!1||n||t.length>0){tn(!0);return}if(Ft)return;const o=window.setTimeout(()=>{tn(!0)},b);return()=>window.clearTimeout(o)},[t.length,b,Ft,n]);const[mr,Ar]=l.useState(()=>r.map(o=>o.key)),[hr,Hr]=l.useState(()=>Object.fromEntries(r.map(o=>[o.key,Ke(o,tr(o.width))]))),[Ce,vr]=l.useState(null),[Is,nt]=l.useState(1),[lt,zt]=l.useState(U===!1?0:U);l.useEffect(()=>{const o=ne.current,d=Me.current,E=o.map(k=>k.key),f=new Set(E);if(!_||!Be){fe.layout&&Ar(E),Ie||Sr(nr(d,o)),Ye.current=!1,Oe(!0);return}let K=!1;return Ye.current=!1,Oe(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(_)}`,{cache:"no-store"}).then(k=>k.ok?k.json():null).then(k=>{if(K)return;const ce=fa(_),j=gl(k==null?void 0:k.settings)?k==null?void 0:k.settings:ce,Ee=fe.layout?j==null?void 0:j.columnOrder:void 0,Ne=Array.isArray(Ee)?Ee.filter(Le=>E.includes(Le)):[],he=E.filter(Le=>!Ne.includes(Le)),ge=Ne.length>0?[...Ne,...he]:E,ve=Object.fromEntries(o.map(Le=>[Le.key,Ke(Le,tr(Le.width))])),He=fe.layout?(j==null?void 0:j.columnWidths)??{}:{},ye=Object.fromEntries(o.map(Le=>[Le.key,Ke(Le,He[Le.key]??ve[Le.key])])),gt=nr(fe.layout?(j==null?void 0:j.hiddenColumnKeys)??d:d,o);if(fe.layout&&(Ar(ge),Hr(ye)),Ie||Sr(gt),fe.filters&&(Er(Wr(j==null?void 0:j.filters,f)),Qr(qr(j==null?void 0:j.conditionFilters,f))),fe.sort){const Le=_r(j==null?void 0:j.sort)?j.sort:null;vr(Le&&f.has(Le.key)?Le:null)}if(fe.bql){const Le=typeof(j==null?void 0:j.bql)=="string"?j.bql:Z;Mr?G==null||G(Le):Dt(Le)}fe.bql&&Lr(Array.isArray(j==null?void 0:j.bqlHistory)?j.bqlHistory.filter(Le=>typeof Le=="string"):[]),fe.pagination&&typeof(j==null?void 0:j.pageSize)=="number"&&j.pageSize>0&&zt(j.pageSize),Ae.current=JSON.stringify({columnOrder:ge,columnWidths:ye,hiddenColumnKeys:gt,filters:Wr(j==null?void 0:j.filters,f),conditionFilters:qr(j==null?void 0:j.conditionFilters,f),sort:_r(j==null?void 0:j.sort)?j.sort:null,bql:typeof(j==null?void 0:j.bql)=="string"?j.bql:"",bqlHistory:Array.isArray(j==null?void 0:j.bqlHistory)?j.bqlHistory:[],pageSize:typeof(j==null?void 0:j.pageSize)=="number"?j.pageSize:void 0}),Ye.current=!0}).catch(()=>{if(!K){const k=fa(_),ce=fe.layout?k==null?void 0:k.columnOrder:void 0,j=Array.isArray(ce)?ce.filter(ye=>E.includes(ye)):[],Ee=E.filter(ye=>!j.includes(ye)),Ne=j.length>0?[...j,...Ee]:E,he=Object.fromEntries(o.map(ye=>[ye.key,Ke(ye,tr(ye.width))])),ge=fe.layout?(k==null?void 0:k.columnWidths)??{}:{},ve=Object.fromEntries(o.map(ye=>[ye.key,Ke(ye,ge[ye.key]??he[ye.key])]));fe.layout&&(Ar(Ne),Hr(ve));const He=nr(fe.layout?(k==null?void 0:k.hiddenColumnKeys)??d:d,o);if(Ie||Sr(He),fe.filters&&(Er(Wr(k==null?void 0:k.filters,f)),Qr(qr(k==null?void 0:k.conditionFilters,f))),fe.sort){const ye=_r(k==null?void 0:k.sort)?k.sort:null;vr(ye&&f.has(ye.key)?ye:null)}if(fe.bql){const ye=typeof(k==null?void 0:k.bql)=="string"?k.bql:Z;Mr?G==null||G(ye):Dt(ye)}fe.bql&&Lr(Array.isArray(k==null?void 0:k.bqlHistory)?k.bqlHistory.filter(ye=>typeof ye=="string"):[]),fe.pagination&&typeof(k==null?void 0:k.pageSize)=="number"&&k.pageSize>0&&zt(k.pageSize),Ae.current=JSON.stringify({columnOrder:Ne,columnWidths:ve,hiddenColumnKeys:He,filters:Wr(k==null?void 0:k.filters,f),conditionFilters:qr(k==null?void 0:k.conditionFilters,f),sort:_r(k==null?void 0:k.sort)?k.sort:null,bql:typeof(k==null?void 0:k.bql)=="string"?k.bql:"",bqlHistory:Array.isArray(k==null?void 0:k.bqlHistory)?k.bqlHistory:[],pageSize:typeof(k==null?void 0:k.pageSize)=="number"?k.pageSize:void 0}),Ye.current=!0}}).finally(()=>{K||Oe(!0)}),()=>{K=!0}},[_,Be,Ge,ze,Ie,fe.layout,fe.filters,fe.sort,fe.bql,fe.pagination,Mr,G,Z]),l.useEffect(()=>{if(!_||!$e||!Be||!Ye.current)return;const o={};fe.layout&&(o.columnOrder=mr,o.columnWidths=hr,o.hiddenColumnKeys=Fe),fe.filters&&(o.filters=Pe,o.conditionFilters=We),fe.sort&&(o.sort=Ce),fe.bql&&(o.bql=Xe,o.bqlHistory=$r),fe.pagination&&U!==!1&&(o.pageSize=lt);const d=JSON.stringify(o);if(d===Ae.current)return;xl(_,o),Ae.current=d;const E=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_,settings:o})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(E)},[mr,hr,Fe,Pe,We,Ce,Xe,$r,lt,U,_,$e,Be,fe.layout,fe.filters,fe.sort,fe.bql,fe.pagination]),l.useEffect(()=>{Ar(o=>{const d=r.map(K=>K.key),E=o.filter(K=>d.includes(K)),f=d.filter(K=>!E.includes(K));return[...E,...f]})},[Ge,r]);const on=mr.map(o=>r.find(d=>d.key===o)).filter(o=>!!o),qe=on.filter(o=>!Fe.includes(o.key)),Os=Object.keys(Pe).length,Fs=Object.keys(We).length,jt=Os+Fs;function sn(o){const d=new Set;return t.reduce((E,f)=>{const K=Ur(o,f);return!K||d.has(K)||(d.add(K),E.push({value:K,label:K})),E},[])}function Ps(){const o=r.find(d=>d.key===Cr);return o?sn(o):[]}function zs(o){return!!(ae&&!ar(o)&&(o.filterValue||o.sortKey||sn(o).length>0))}function cn(o,d){Er(E=>{const f={...E};return f[o]=d,f})}function js(o,d,E,f){const K=Pe[o]??[],k=f?K:E.filter(j=>j!==d),ce=f?K.includes(d)?K.filter(j=>j!==d):[...K,d]:k;ce.length===E.length?_t(o):cn(o,ce)}function _t(o){Er(d=>{const E={...d};return delete E[o],E})}function ot(o,d){Qr(E=>{const f={...E};return d?f[o]=d:delete f[o],f})}function dn(o){ot(o,null)}function _s(){Er({}),Qr({})}function un(o){Mr||Dt(o),G==null||G(o)}function st(o){const d=o.trim();et(d),un(d),or(!1),fr(!1),pr(!1),d&&Lr(E=>[d,...E.filter(f=>f!==d)].slice(0,bl))}function bn(){et(""),un(""),or(!1),fr(!1),pr(!1)}function Wt(o,d){et(o),d&&(d.style.height="auto",d.style.height=`${Math.min(d.scrollHeight,180)}px`)}l.useEffect(()=>{et(Xe)},[Xe]);const it=l.useCallback(()=>{const o=Bt.current;if(!o)return;const d=o.getBoundingClientRect(),E=12,f=8,K=Math.min(780,Math.max(320,window.innerWidth-32)),k=Math.max(E,window.innerWidth-K-E),ce=Math.min(Math.max(E,d.left),k),j=d.bottom+f,Ee=window.innerHeight-d.top+f,Ne=window.innerHeight-j-E,he=d.top-E-f,ge=Ne<280&&he>Ne,ve=Math.max(240,ge?he:Ne);Es({position:"fixed",zIndex:1e4,left:ce,top:ge?void 0:j,bottom:ge?Ee:void 0,width:K,maxWidth:"calc(100vw - 24px)",maxHeight:ve,overflowY:"auto"})},[]);l.useEffect(()=>{if(!Ze)return;function o(f){var k,ce;const K=f.target;(k=Bt.current)!=null&&k.contains(K)||(ce=en.current)!=null&&ce.contains(K)||(or(!1),fr(!1),pr(!1))}function d(f){f.key==="Escape"&&(or(!1),fr(!1),pr(!1))}function E(){it()}return it(),document.addEventListener("mousedown",o),window.addEventListener("keydown",d),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",d),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[Ze,it]);function fn(o){const d=nr(o,r);Ie||Sr(d),A==null||A(d)}function Ws(o){fn(Fe.includes(o)?Fe.filter(d=>d!==o):[...Fe,o])}function qs(){fn([])}const qt=l.useCallback((o=at.current)=>{if(!o)return;const d=o.getBoundingClientRect(),E=Math.min(292,Math.max(240,window.innerWidth-16)),f=Math.max(8,window.innerWidth-E-8),K=Math.min(Math.max(8,d.right-E),f),k=window.innerHeight-d.bottom,ce=d.bottom+6,j=window.innerHeight-d.top+6,Ne=k<360&&d.top>k?void 0:ce,he=Ne===void 0?j:void 0,ge=Math.max(220,Ne===void 0?d.top-16:window.innerHeight-ce-8),ve={position:"fixed",zIndex:9999,left:K,top:Ne,bottom:he,width:E,maxWidth:"calc(100vw - 16px)",maxHeight:ge,"--dt-column-menu-max-height":`${ge}px`};$s(ve)},[]);function pn(o,d,E=null){o.preventDefault(),o.stopPropagation();const f=at.current===o.currentTarget&&lr===d&&Cr===E;if(Re&&f){Zr(!1),Jr(null);return}at.current=o.currentTarget,Ns(d),Jr(E),Za(""),qt(o.currentTarget),Zr(!0)}function Us(o){if(ar(o))return;const d=er.current;if(!d)return;const f=Array.from(d.querySelectorAll("[data-dt-column-key]")).filter(K=>K.dataset.dtColumnKey===o.key).reduce((K,k)=>{const ce=k.querySelector("[data-dt-autofit-content]"),j=ce?ce.scrollWidth:Math.max(k.scrollWidth,k.offsetWidth);return Math.max(K,Math.ceil(j+wl(k)))},0);f<=0||Hr(K=>({...K,[o.key]:Ke(o,f+12)}))}l.useEffect(()=>{Hr(o=>{const d=Object.fromEntries(r.map(E=>[E.key,Ke(E,tr(E.width))]));return Object.fromEntries(r.map(E=>[E.key,Ke(E,o[E.key]??d[E.key])]))})},[Ge,r]),l.useEffect(()=>{Ie||Sr(o=>nr(o,r))},[Ge,r,Ie]),l.useEffect(()=>{function o(f){var ce,j;const K=f.target,k=f.target;k!=null&&k.closest("[data-bonsaif-select-dropdown='true']")||!((ce=rn.current)!=null&&ce.contains(K))&&!((j=at.current)!=null&&j.contains(K))&&(Zr(!1),Jr(null))}function d(f){f.key==="Escape"&&(Zr(!1),Jr(null))}function E(){qt()}return Re&&(document.addEventListener("mousedown",o),window.addEventListener("keydown",d),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0)),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",d),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[Re,qt]);const Dr=l.useRef(null);l.useEffect(()=>{function o(E){const f=Dr.current;if(!f)return;const K=E.clientX-f.startX,k=r.find(ce=>ce.key===f.colKey);k&&Hr(ce=>({...ce,[f.colKey]:Ke(k,f.startWidth+K)}))}function d(){Dr.current&&(Dr.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",o),document.addEventListener("pointerup",d),()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",d)}},[r]);const ct=l.useRef(null),[mn,Ut]=l.useState(null);function Vs(o,d){ct.current=mr.indexOf(o),d.dataTransfer.effectAllowed="move"}function Ks(o,d){d.preventDefault(),d.dataTransfer.dropEffect="move";const E=mr.indexOf(o);mn!==E&&Ut(E)}function Gs(o,d){d.preventDefault();const E=ct.current,f=mr.indexOf(o);E!==null&&E!==f&&Ar(K=>{const k=[...K],[ce]=k.splice(E,1);return k.splice(f,0,ce),k}),ct.current=null,Ut(null)}function Ys(){ct.current=null,Ut(null)}function Xs(o){o.sortKey&&vr(d=>(d==null?void 0:d.key)===o.key?{key:o.key,dir:d.dir==="asc"?"desc":"asc"}:{key:o.key,dir:"asc"})}l.useEffect(()=>{nt(1)},[t]),l.useEffect(()=>{nt(1)},[We,Pe]);const sr=!!(P&&V),ir=U!==!1,De=sr?T??1:Is,Ue=sr||ir?lt:t.length,Ve=!!N&&!!S&&!!B,gr=!!m,hn=l.useMemo(()=>new Set(Ht?Array.from(x??[]):Ja),[Ht,x,Ja]),Vt=(gr?40:0)+(Ve?40:0),Zs=Ve&&t.length>0&&N.size===t.length,Js=Ve&&N.size>0&&N.size<t.length,dt=l.useMemo(()=>{const o=Object.entries(Pe),d=Object.entries(We);return o.length===0&&d.length===0?t:t.filter(E=>o.every(([f,K])=>{const k=r.find(ce=>ce.key===f);return k?K.includes(Ur(k,E)):!0})&&d.every(([f,K])=>{const k=r.find(j=>j.key===f);if(!k)return!0;const ce=t.map(j=>Ur(k,j));return Sl(Ur(k,E),K,ce)}))},[We,Pe,r,t]),cr=l.useMemo(()=>{if(!Ce)return dt;const o=r.find(d=>d.key===Ce.key&&d.sortKey);return o!=null&&o.sortKey?[...dt].sort((d,E)=>{const f=d[o.sortKey],K=E[o.sortKey],k=f===K?0:f==null?1:K==null||f<K?-1:1;return Ce.dir==="asc"?k:-k}):dt},[dt,Ce,r]),vn=l.useMemo(()=>{if(sr||!ir)return cr;const o=(De-1)*Ue;return cr.slice(o,o+Ue)},[cr,sr,ir,De,Ue]),xr=sr?R??t.length:cr.length,Kt=ir?Math.max(1,Math.ceil(xr/Ue)):1,Qs=ir&&xr>Ue,Rs=ir?(De-1)*Ue+1:1,ei=ir?Math.min(De*Ue,xr):xr;function Gt(o){if(n)return;const d=Math.max(1,Math.min(o,Kt));sr?P(d):nt(d)}function ri(o){n||(zt(o),sr?(V(o),P(1)):nt(1),V&&V(o))}function gn(o){const d=new Set(hn);d.has(o)?d.delete(o):d.add(o);const E=Array.from(d);Ht||ks(E),$==null||$(E)}l.useEffect(()=>{ke==null||ke({bql:Xe,filters:Pe,conditionFilters:We,sort:Ce,page:De,pageSize:Ue,hiddenColumnKeys:Fe})},[Xe,Pe,We,Ce,De,Ue,Fe,ke]);const xn=o=>o==="center"?"text-center":o==="right"?"text-right":"text-left",ti="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Yt="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",xe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",yr="color-mix(in srgb, var(--primary) 24%, var(--border))",ut=`inset 0 0 0 1px ${xe}`,yn=qe.reduce((o,d)=>o+(hr[d.key]??tr(d.width)),(gr?40:0)+(Ve?40:0)),wn=typeof O=="number"?O:typeof O=="string"?Number(((Mn=O.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Mn[1])??NaN):NaN,Br=Number.isFinite(wn)?Math.max(yn,wn,nn):Math.max(yn,nn),bt=O??Br,wr=`${gr?"40px ":""}${Ve?"40px ":""}${qe.map(o=>`${hr[o.key]??tr(o.width)}px`).join(" ")}`;l.useEffect(()=>{Ce&&Fe.includes(Ce.key)&&vr(null)},[Fe,Ce]);function Nn(o){return o?typeof o=="string"?{key:o,label:o}:o:null}const ft=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,background:Yt,borderBottom:`1px solid ${yr}`},children:[gr&&e.jsx("div",{role:"columnheader",className:`${i?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${xe}`}}),Ve&&e.jsx("div",{role:"columnheader",className:`${i?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:le?{position:"sticky",left:0,zIndex:12,background:Yt,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${xe}`},children:e.jsx(Fr,{size:"sm",checked:Zs,indeterminate:Js,onChange:B,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),qe.map((o,d)=>{const E=(Ce==null?void 0:Ce.key)===o.key,f=!!o.sortKey,K=ar(o),k=le&&!Pt&&d===0,ce=mn===d,Ee=(hr[o.key]??tr(o.width))<120,Ne=Object.prototype.hasOwnProperty.call(Pe,o.key)||Object.prototype.hasOwnProperty.call(We,o.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":o.key,className:`group select-none ${Ee?"text-left":xn(o.align)}`,style:{...k?{position:"sticky",left:Vt,zIndex:12,background:Yt,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${xe}`}:{position:"relative",borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${xe}`},color:E?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ce?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:K?i?"7px 6px":"9px 8px":i?"8px 6px 10px":"10px 8px 12px"},onDragOver:he=>Ks(o.key,he),onDrop:he=>Gs(o.key,he),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${K?"justify-center":Ee?"justify-start":o.align==="center"?"justify-center":o.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:he=>{he.stopPropagation(),Vs(o.key,he)},onDragEnd:he=>{he.stopPropagation(),Ys()},onClick:he=>he.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 ${ce?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),K?e.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:e.jsx(v.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(pa,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${i?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:o.header})})}),f&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(o.header)}`,title:"Ordenar",onClick:he=>{he.stopPropagation(),Xs(o)},"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 ${E?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:E?Ce.dir==="asc"?e.jsx(v.HiChevronUp,{className:"h-3 w-3"}):e.jsx(v.HiChevronDown,{className:"h-3 w-3"}):e.jsx(v.HiChevronUpDown,{className:"h-3 w-3"})}),ae&&!K&&zs(o)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&Cr===o.key,"aria-label":`Filtrar ${String(o.header)}`,title:"Filtrar",onClick:he=>pn(he,"filter",o.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 ${Re&&lr==="filter"&&Cr===o.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Ne?"text-[var(--primary)] opacity-100":""}`,children:Ne?e.jsx(v.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(v.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!K&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:he=>{he.preventDefault(),he.stopPropagation(),Dr.current={colKey:o.key,startX:he.clientX,startWidth:hr[o.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:he=>{he.preventDefault(),he.stopPropagation(),Dr.current=null,document.body.style.cursor="",document.body.style.userSelect="",Us(o)},onClick:he=>he.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:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},o.key)})]}),pt=()=>{if(!Re||typeof document>"u"||lr==="visibility"&&!D||lr==="filter"&&!ae)return null;const o=r.find(ve=>ve.key===Cr),d=Ps(),E=o?Object.prototype.hasOwnProperty.call(Pe,o.key):!1,f=o?We[o.key]:void 0,K=jr.find(ve=>ve.value===(f==null?void 0:f.operator)),k=o?Pe[o.key]??[]:[],ce=Xa.trim().toLowerCase(),j=ce?d.filter(ve=>ve.label.toLowerCase().includes(ce)):d,Ee=o&&d.length>0&&(!E||k.length===d.length),Ne=o&&E&&k.length>0&&k.length<d.length,he=Fe.length,ge=()=>{o&&(_t(o.key),dn(o.key))};return je.createPortal(e.jsx("div",{ref:rn,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ms,borderColor:"var(--border)",background:"var(--bg-card)"},children:lr==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:he>0?`${qe.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:qs,disabled:he===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:on.map(ve=>{const He=!Fe.includes(ve.key),gt=!(ve.hideable!==!1)||He&&qe.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":He,disabled:gt,onClick:()=>Ws(ve.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:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:He?"var(--primary)":"var(--border)",background:He?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:He&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.header})]},ve.key)})})]}):o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",o.header]}),e.jsx("button",{type:"button",onClick:ge,disabled:!E&&!f,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"})]}),o.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>vr({key:o.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(v.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ce==null?void 0:Ce.key)===o.key&&Ce.dir==="asc"&&e.jsx(v.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>vr({key:o.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:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(v.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ce==null?void 0:Ce.key)===o.key&&Ce.dir==="desc"&&e.jsx(v.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[e.jsx(rr,{value:(f==null?void 0:f.operator)??"",onChange:ve=>{if(!ve){dn(o.key);return}ot(o.key,{operator:ve,value:(f==null?void 0:f.value)??"",valueTo:(f==null?void 0:f.valueTo)??""})},options:ul,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"}),(K==null?void 0:K.valueMode)!=="none"?e.jsx("input",{value:(f==null?void 0:f.value)??"",onChange:ve=>{f&&ot(o.key,{...f,value:ve.target.value})},disabled:!f,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)"}}):e.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"})]}),(K==null?void 0:K.valueMode)==="between"&&e.jsx("input",{value:(f==null?void 0:f.valueTo)??"",onChange:ve=>{f&&ot(o.key,{...f,valueTo:ve.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)"}})]}),e.jsx("div",{className:"border-b border-[var(--border)] p-2",children:e.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:[e.jsx(v.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Xa,onChange:ve=>Za(ve.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)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne?"mixed":!!Ee,onClick:()=>{o&&(Ee&&!E?cn(o.key,[]):_t(o.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:[e.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee||Ne?"var(--primary)":"var(--border)",background:Ee||Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ne&&e.jsx(v.HiMinus,{className:"h-3 w-3"}),Ee&&!Ne&&e.jsx(v.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),j.map(ve=>{const He=!E||k.includes(ve.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":He,onClick:()=>js(o.key,ve.value,d.map(ye=>ye.value),E),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:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:He?"var(--primary)":"var(--border)",background:He?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:He&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.label})]},ve.value)}),j.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};l.useEffect(()=>{if(!Tr)return;function o(d){Ot.current&&!Ot.current.contains(d.target)&&tt.current&&!tt.current.contains(d.target)&&rt(!1)}return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[Tr]);function kn(o,d){if(o.filterValue){const E=o.filterValue(d);return E==null||E===""?"":String(E)}return ur(o.cell(d))}function Sn(o){return`"${o.replace(/"/g,'""')}"`}function mt(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ai(){const o=qe.filter(j=>!ar(j)),d=o.map(j=>Sn(ur(j.header))).join(","),E=cr.map(j=>o.map(Ee=>Sn(kn(Ee,j))).join(",")).join(`
|
|
3
3
|
`),f=`${d}
|
|
4
4
|
${E}`,K=new Blob(["\uFEFF"+f],{type:"text/csv;charset=utf-8;"}),k=URL.createObjectURL(K),ce=document.createElement("a");ce.href=k,ce.download=`${we}.csv`,document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),URL.revokeObjectURL(k)}function ni(){const o=qe.filter(ce=>!ar(ce)),d=o.map(ce=>mt(ur(ce.header))),f=cr.map(ce=>o.map(j=>mt(kn(j,ce)))).map(ce=>`<tr>${ce.map(j=>`<td>${j}</td>`).join("")}</tr>`).join(""),K=`<!DOCTYPE html>
|
|
5
5
|
<html lang="es"><head><meta charset="utf-8"><title>${mt(we)}</title>
|
|
@@ -18,4 +18,4 @@ ${E}`,K=new Blob(["\uFEFF"+f],{type:"text/csv;charset=utf-8;"}),k=URL.createObje
|
|
|
18
18
|
<table><thead><tr>${d.map(ce=>`<th>${ce}</th>`).join("")}</tr></thead>
|
|
19
19
|
<tbody>${f}</tbody></table>
|
|
20
20
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
21
|
-
</body></html>`,k=window.open("","_blank");k&&(k.document.write(K),k.document.close())}const ht=()=>!Se||!Tr?null:je.createPortal(e.jsxs("div",{ref:Ot,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ls,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[e.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:()=>{ai(),rt(!1)},children:[e.jsx(v.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),e.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:()=>{ni(),rt(!1)},children:[e.jsx(v.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),vt=()=>{const o=O&&Xe.trim().length>0,d=de!=null&&de.length?de:o?[{key:"bql",label:"BQL",value:Xe}]:[],E=I.filter(f=>f.trim()&&f!==Rr).slice(0,8);return!D&&jt===0&&!O&&!Se?null:e.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:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[jt>0&&e.jsxs("button",{type:"button",onClick:_s,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:[e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"}),jt," filtros"]}),O&&e.jsxs("div",{ref:Bt,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(Ze){or(!1);return}it(),or(!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)":o?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||o?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[e.jsx(v.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",o&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?e.jsx(v.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(v.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:te}),d.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[d.slice(0,3).map(f=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key)),d.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",d.length-3]})]}),o&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:bn,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:e.jsx(v.HiXMark,{className:"h-4 w-4"})}),Ze&&je.createPortal(e.jsxs("div",{ref:en,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Cs,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[se.map(f=>e.jsxs("button",{type:"button",onClick:()=>st(f.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:[f.icon,f.label]},f.label)),w.length>0&&e.jsxs("button",{type:"button",onClick:()=>fr(f=>!f),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":Qa,children:[e.jsx(v.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),$r.length>0&&e.jsxs("button",{type:"button",onClick:()=>pr(f=>!f),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":Ra,children:[e.jsx(v.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${be?"var(--danger)":o?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:It,value:Rr,rows:3,onChange:f=>Wt(f.target.value,f.target),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),st(Rr)),f.key==="Escape"&&or(!1)},placeholder:ue,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"}}),E.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:E.map(f=>e.jsx("button",{type:"button",onMouseDown:K=>{var k;K.preventDefault(),Wt(f),(k=It.current)==null||k.focus()},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:f},f))})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 text-xs",style:{color:be?"var(--danger)":"var(--text-muted)"},children:be??(o?`${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(f=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key))]}),Ra&&$r.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx(v.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Lr([]),pr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(v.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),$r.map(f=>e.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[e.jsx("button",{type:"button",onClick:()=>st(f),className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:f})}),e.jsx("button",{type:"button",onClick:()=>Lr(K=>K.filter(k=>k!==f)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"})})]},f))]}),Qa&&w.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:w.map(f=>e.jsxs("button",{type:"button",onClick:()=>{var K;Wt(f.bql),fr(!1),(K=It.current)==null||K.focus()},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:f.bql}),f.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:f.description})]},f.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[o&&e.jsxs("button",{type:"button",onClick:bn,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:[e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>st(Rr),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:[e.jsx(v.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Se&&e.jsx("button",{ref:tt,type:"button","aria-haspopup":"menu","aria-expanded":Tr,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var K;const f=(K=tt.current)==null?void 0:K.getBoundingClientRect();f&&Ts({top:f.bottom+4,right:window.innerWidth-f.right}),rt(k=>!k)},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)] ${Tr?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiArrowDownTray,{className:"h-4 w-4"})}),D&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&lr==="visibility","aria-label":oe,title:oe,onClick:f=>pn(f,"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)] ${Re&&lr==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiCog6Tooth,{className:"h-4 w-4"})})]})},Cn=()=>{if(!Qs)return null;const o=Nl(De,Kt);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${i?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:xr===0?"0 filas":`${Rs}–${ei} de ${xr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(rr,{value:String(Ue),onChange:d=>ri(Number(d)),options:Q.map(d=>({value:String(d),label:String(d)})),placeholder:"Filas",searchable:!1,disabled:n,height:W,padding:J,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:re}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||De<=1,onClick:()=>Gt(De-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:e.jsx(v.HiChevronLeft,{className:"h-3.5 w-3.5"})}),o.map((d,E)=>d==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${E}`):e.jsx("button",{disabled:n,onClick:()=>Gt(d),onMouseEnter:f=>{f.currentTarget.disabled||d===De||(f.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",f.currentTarget.style.color="var(--primary)")},onMouseLeave:f=>{f.currentTarget.style.background=d===De?"var(--primary)":"transparent",f.currentTarget.style.color=d===De?"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===De?"var(--primary)":"transparent",color:d===De?"var(--primary-fg)":"var(--text-muted)"},children:d},d)),e.jsx("button",{disabled:n||De>=Kt,onClick:()=>Gt(De+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:e.jsx(v.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},En=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:T?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>e.jsx("div",{role:"cell",className:i?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key))]},d))})]})})]}),Xt="min-w-0 max-w-full overflow-hidden";return _&&!$e&&t.length===0||!n&&t.length===0&&!Ft?En():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:T?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>{const K=le&&!Pt&&f===0;return e.jsx("div",{role:"cell","data-dt-column-key":E.key,className:i?"px-2 py-1.5":"px-3 py-2",style:K?{position:"sticky",left:Vt,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key)})]},d))})]})})}),Cn()]}):!n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:e.jsx("div",{role:"rowgroup",style:T?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()})})}),e.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:xe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.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:c??e.jsx(v.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:u}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:T?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:vn.map((o,d)=>{const E=a(o),f=Nn(X==null?void 0:X(o)),K=d>0?Nn(X==null?void 0:X(vn[d-1])):null,k=f&&f.key!==(K==null?void 0:K.key),ce=Ve&&N.has(E),j=gr?(h==null?void 0:h(o))??!0:!1,Ee=j&&hn.has(E),Ne=!!p||C&&j,he=ce&&ee?"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 e.jsxs(l.Fragment,{children:[k&&e.jsx("div",{role:"row",className:`grid ${f.className??""}`,style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:f.label}),f.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:f.description})]})})})}),e.jsxs("div",{role:"row",onClick:Ne?ge=>{const ve=ge.target;if(!(ve!=null&&ve.closest('[data-dt-disable-row-click="true"]'))){if(C&&j){gn(E);return}p==null||p(o)}}:void 0,className:`grid transition-colors ${Ne?"cursor-pointer":""} ${z?z(o):""}`,style:{gridTemplateColumns:wr,"--dt-row-bg":he,"--dt-sticky-bg":he,background:"var(--dt-row-bg)",borderBottom:`1px solid ${xe}`},onMouseEnter:ge=>{ce||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",ti))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",he),ge.currentTarget.style.setProperty("--dt-sticky-bg",he)},children:[gr&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},"data-dt-disable-row-click":"true",children:j&&e.jsx("button",{type:"button","aria-label":Ee?"Contraer fila":"Desplegar fila","aria-expanded":Ee,onClick:ge=>{ge.stopPropagation(),gn(E)},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:Ee?e.jsx(v.HiChevronDown,{className:"h-4 w-4"}):e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})}),Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:le?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},onClick:ge=>{ge.stopPropagation(),S(E)},children:e.jsx(Fr,{size:"sm",checked:ce,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ge=>ge.stopPropagation(),onChange:()=>S(E)})}),qe.map((ge,ve)=>{const He=le&&!Pt&&ve===0,ye=ar(ge);return e.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||ye?"true":void 0,className:`${ye?"px-2 py-1.5 text-center":`${i?"px-2 py-1.5":"px-3 py-2"} ${xn(ge.align)}`} ${ml} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...He?{position:"sticky",left:Vt,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},children:e.jsx(pa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(o)})})},ge.key)})]}),Ee&&m&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${xe}`},children:m(o)})})]},E)})})]})})}),Cn()]})}const Cl={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 El(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const a=Cl[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const Ml=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function $l({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[c,u]=l.useState(r),b=l.useRef(null),p=(a==null?void 0:a.preset)==="date",m=p?"date":t==="number"?"number":"text";return l.useEffect(()=>{var h,x;(h=b.current)==null||h.focus(),p||(x=b.current)==null||x.select()},[p]),e.jsx("input",{ref:b,type:m,value:c,maxLength:a==null?void 0:a.maxLength,onChange:h=>u(h.target.value),onBlur:()=>n(c),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),n(c)),h.key==="Escape"&&(h.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!Ml.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Ll({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const c=l.useRef(null),[u,b]=l.useState(r);return l.useEffect(()=>{if(a)return;const p=setTimeout(()=>{var m,h;(h=(m=c.current)==null?void 0:m.querySelector("button"))==null||h.click()},0);return()=>clearTimeout(p)},[a]),e.jsx("div",{ref:c,className:"w-full",tabIndex:-1,onKeyDown:p=>{p.key==="Escape"&&(p.stopPropagation(),s()),p.key==="Enter"&&(p.preventDefault(),p.stopPropagation(),n(u))},children:e.jsx(rr,{value:u,onChange:p=>{b(p),setTimeout(()=>{var m;return(m=c.current)==null?void 0:m.focus({preventScroll:!0})},0)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Tl={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ha={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Al({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...c}){const[u,b]=l.useState(t),p=l.useRef(null);l.useEffect(()=>{p.current||b(t)},[t]);const[m,h]=l.useState(null);p.current=m;const[x,g]=l.useState(null),M=l.useRef(null);M.current=x;const[C,N]=l.useState({}),[S,B]=l.useState({}),[ee,z]=l.useState({}),X=l.useRef(new Set),T=l.useRef(null);l.useEffect(()=>{var y;const i=document.activeElement;(!i||i===document.body)&&((y=T.current)==null||y.focus({preventScroll:!0}))},[]);const U=r.map(i=>{var y,A,P;return`${i.key}:${((P=(A=(y=i.editable)==null?void 0:y.select)==null?void 0:A.options)==null?void 0:P.length)??-1}`}).join("|");l.useEffect(()=>{r.forEach(i=>{var P,D;const y=(D=(P=i.editable)==null?void 0:P.select)==null?void 0:D.options;if(!y)return;const A=S[i.key];(!X.current.has(i.key)||(A==null?void 0:A.length)===0&&y.length>0)&&(X.current.add(i.key),B(ae=>({...ae,[i.key]:y})))})},[U]);const Q=l.useCallback(async(i,y)=>{if(X.current.has(i))return;X.current.add(i);const{url:A,fetchOptions:P}=y.select??{};if(!(!A&&!P)){z(D=>({...D,[i]:!0}));try{let D=[];if(P)D=await P();else if(A){const ae=await fetch(A);if(!ae.ok)throw new Error("fetch failed");D=await ae.json()}B(ae=>({...ae,[i]:D}))}catch{B(D=>({...D,[i]:[]}))}finally{z(D=>({...D,[i]:!1}))}}},[]),re=l.useRef(u);re.current=u;const W=l.useRef(n);W.current=n;const J=l.useRef(a);J.current=a;const R=l.useRef(r);R.current=r;const $=l.useRef(s);$.current=s,l.useEffect(()=>{if(r.length>0&&t.length>0){const i=r.find(y=>y.selectable!==!1);i&&g({rowId:a(t[0]),colKey:i.key})}},[]),l.useEffect(()=>{if(!x)return;const i=T.current;if(!i)return;const y=i.querySelector(`[data-cell-id="${x.rowId}:${x.colKey}"]`);if(!y)return;const A=i.querySelector('[role="rowgroup"]');y.style.scrollMarginTop=`${(A==null?void 0:A.offsetHeight)??0}px`;const P=i.querySelector('[role="row"]');let D=0;P&&P.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ae=>{ae.style.position==="sticky"&&ae.style.left!==""&&(D=Math.max(D,parseFloat(ae.style.left)+ae.offsetWidth))}),y.style.scrollMarginLeft=`${D}px`,y.scrollIntoView({block:"nearest",inline:"nearest"})},[x]);const F=l.useCallback(i=>{var D;const y=R.current,A=new Set,P=[];(D=T.current)==null||D.querySelectorAll("[data-cell-id]").forEach(ae=>{const ie=ae.dataset.cellId.split(":")[0];A.has(ie)||(A.add(ie),P.push(ie))}),g(ae=>{if(!ae)return ae;const ie=y.findIndex(O=>O.key===ae.colKey),pe=P.indexOf(ae.rowId);let L=ie,oe=pe;if(i==="up")oe=Math.max(0,pe-1);else if(i==="down")oe=Math.min(P.length-1,pe+1);else if(i==="left"){let O=ie-1;for(;O>=0&&y[O].selectable===!1;)O--;O>=0&&(L=O)}else if(i==="right"){let O=ie+1;for(;O<y.length&&y[O].selectable===!1;)O++;O<y.length&&(L=O)}return L===ie&&oe===pe?ae:{rowId:P[oe],colKey:y[L].key}})},[]),V=l.useCallback((i=!0)=>{const y=p.current;h(null),y&&g(y),i&&setTimeout(()=>{var A;return(A=T.current)==null?void 0:A.focus({preventScroll:!0})},0)},[]),_=l.useCallback(async(i,y,A)=>{var se;const P=R.current.find(w=>w.key===y);if(!(P!=null&&P.editable))return;const{field:D,type:ae,mask:ie,validate:pe}=P.editable,L=ae==="number"?A===""?null:Number(A):A;if(ie){const w=El(A,ie);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}if(pe){const w=pe(L);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}const oe=J.current,O=re.current.find(w=>oe(w)===i);if(!O)return;const H=O[D];h(null),N(w=>{const I={...w};return delete I[`${i}:${y}`],I});const Z=re.current,G=Z.findIndex(w=>oe(w)===i),te=Z[Math.min(Z.length-1,G+1)];if(g({rowId:oe(te),colKey:y}),setTimeout(()=>{var I,de;const w=document.activeElement;(!w||w===document.body||(I=T.current)!=null&&I.contains(w))&&((de=T.current)==null||de.focus({preventScroll:!0}))},0),String(H??"")===String(L??""))return;const ue={...O,[D]:L};b(w=>w.map(I=>oe(I)===i?ue:I));try{await((se=W.current)==null?void 0:se.call(W,{row:O,rowId:i,field:D,oldValue:H,newValue:L}))}catch{b(w=>w.map(I=>oe(I)===i?O:I)),N(w=>({...w,[`${i}:${y}`]:"Error al guardar. Intenta de nuevo."}))}},[]),le=l.useCallback(i=>{if(p.current)return;const y=M.current;if(!(!y||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(i.key)))switch(i.preventDefault(),i.key){case"ArrowUp":F("up");break;case"ArrowDown":F("down");break;case"ArrowLeft":F("left");break;case"ArrowRight":F("right");break;case"Tab":F(i.shiftKey?"left":"right");break;case"Enter":{const P=R.current.find(D=>D.key===y.colKey);P!=null&&P.editable&&!$.current?(h(y),P.editable.type==="select"&&!X.current.has(y.colKey)&&Q(y.colKey,P.editable)):F("down");break}}},[F,Q]),q=l.useMemo(()=>r.map(i=>{if(!i.editable||s){const{editable:A,selectable:P,...D}=i;if(i.selectable===!1)return{...D,disableRowClick:!0};const ae=D.cell;return{...D,className:`relative ${D.className??""}`.trim(),disableRowClick:!0,cell:ie=>{const pe=a(ie),L=(x==null?void 0:x.rowId)===pe&&(x==null?void 0:x.colKey)===i.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${pe}:${i.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var oe;g({rowId:pe,colKey:i.key}),(oe=T.current)==null||oe.focus({preventScroll:!0})}}),L&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:ae(ie)})]})}}}const y=i.editable;return{...i,className:`relative ${i.className??""}`.trim(),disableRowClick:!0,cell:A=>{const P=a(A),D=i.key,ae=(m==null?void 0:m.rowId)===P&&(m==null?void 0:m.colKey)===D,ie=(x==null?void 0:x.rowId)===P&&(x==null?void 0:x.colKey)===D,pe=C[`${P}:${D}`],L=A[y.field],oe=String(L??""),O=()=>{var Z;g({rowId:P,colKey:D}),h({rowId:P,colKey:D}),(Z=T.current)==null||Z.focus({preventScroll:!0}),y.type==="select"&&!X.current.has(D)&&Q(D,y)};if(ae){const Z=y.type==="select"?e.jsx(Ll,{initialValue:oe,options:S[D]??[],loading:ee[D]??!1,onCommit:G=>_(P,D,G),onCancel:V}):e.jsx($l,{initialValue:oe,type:y.type??"text",mask:y.mask,onCommit:G=>_(P,D,G),onCancel:V});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Tl,onClick:G=>G.stopPropagation(),children:Z})}const H=i.cell(A);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${P}:${D}`,className:"peer absolute inset-0 z-10 cursor-pointer",onClick:O}),ie&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:pe?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(v.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:pe})]}):e.jsx("span",{className:"truncate",children:H})}),e.jsx(v.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"})]})}}}),[r,s,m,x,C,S,ee,a,_,V,Q]);return e.jsx("div",{ref:T,tabIndex:0,onKeyDown:le,onBlur:i=>{var y;(y=T.current)!=null&&y.contains(i.relatedTarget)||V(!1)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(ma,{...c,columns:q,data:u,getRowId:a})})}function kr(r){return r?new Date(`${r}T12:00:00`):void 0}function va(r){return r.toISOString().slice(0,10)}function Hl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:u,formatters:b}=Rt.useDayPicker(),p=!!a&&t===0,m=!!n&&t===c.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:b.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":u.labelPrevious(a),onClick:()=>a&&s(a),disabled:!p,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":u.labelNext(n),onClick:()=>n&&s(n),disabled:!m,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:m?1:.45,cursor:m?"pointer":"not-allowed"},children:e.jsx(v.HiChevronRight,{size:16})})]})}function Dl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Bl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:u=!0,startLabel:b="Inicio",endLabel:p="Regreso"}){const m={from:kr(r),to:kr(t)},h=kr(n),[x,g]=l.useState(kr(s||r));return l.useEffect(()=>{g(kr(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(Rt.DayPicker,{mode:"range",selected:m,month:x,onMonthChange:g,onSelect:M=>{const C=M!=null&&M.from?va(M.from):r,N=M!=null&&M.to?va(M.to):"";a({startDate:C,endDate:N})},numberOfMonths:c,hideNavigation:!0,disabled:h?{before:h}:void 0,showOutsideDays:!1,components:{MonthCaption:Hl},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:M=>Dl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(M)),formatWeekdayName:M=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(M)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),u&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[b,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[p,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Il="bonsaif-ui:hide-tooltips";function ga(){window.dispatchEvent(new CustomEvent(Il))}function Ol(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Fl({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:u="",onOpenChange:b}){const[p,m]=l.useState(!1),[h,x]=l.useState(!1),[g,M]=l.useState({}),C=l.useRef(null),N=l.useRef(null),S=l.useCallback(T=>{m(T),b==null||b(T)},[b]),B=l.useCallback(()=>{const T=C.current;if(!T)return;const U=T.getBoundingClientRect(),Q=typeof n=="number"?n:U.width,re=typeof n=="number"?n:Math.max(U.width,180),W=a==="end"?Math.max(8,U.right-re):Math.min(U.left,window.innerWidth-re-8),J=window.innerHeight-U.bottom,R=J<240&&U.top>J?void 0:U.bottom+6,$=R===void 0?window.innerHeight-U.top+6:void 0;M({position:"fixed",zIndex:9999,left:W,top:R,bottom:$,width:Ol(typeof n=="number"?Q:n)})},[a,n]);l.useEffect(()=>x(!0),[]),l.useEffect(()=>{if(!p)return;B();const T=Q=>{var W,J;const re=Q.target;!((W=C.current)!=null&&W.contains(re))&&!((J=N.current)!=null&&J.contains(re))&&S(!1)},U=Q=>{Q.key==="Escape"&&S(!1)};return document.addEventListener("mousedown",T),window.addEventListener("keydown",U),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0),()=>{document.removeEventListener("mousedown",T),window.removeEventListener("keydown",U),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}},[p,S,B]);const ee=T=>{s||(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S(!p))},z=l.isValidElement(r)?l.cloneElement(r,{onClick:()=>{s||(ga(),S(!p))}}):r,X=p?e.jsx("div",{ref:N,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${u}`,style:g,children:t.map(T=>e.jsxs("div",{children:[T.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:T.disabled,onClick:()=>{var U;T.disabled||(ga(),(U=T.onSelect)==null||U.call(T),S(!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:T.danger?"var(--danger)":"var(--text-main)"},children:[T.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:T.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:T.label}),T.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:T.description})]})]})]},T.id))}):null;return e.jsxs("span",{ref:C,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":p,onKeyDown:ee,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[z,h&&X?je.createPortal(X,document.body):null]})}const Pl=180,xa="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function zl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:u,loading:b=!1,confirmDisabled:p=!1,headerActions:m,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:x=440,hasUnsavedChanges:g=!1,unsavedChangesTitle:M="Descartar cambios",unsavedChangesDescription:C="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:N="Descartar",unsavedChangesCancelLabel:S="Seguir editando",onDiscardChanges:B,disabled:ee=!1,children:z}){const[X,T]=l.useState(!1),[U,Q]=l.useState(!1),[re,W]=l.useState(!1),J=l.useCallback(()=>{Q(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),R=l.useCallback(()=>{W(!1),window.setTimeout(()=>Q(!1),Pl)},[]),$=l.useCallback(()=>{if(g){J();return}t()},[g,t,J]),F=l.useCallback(()=>{W(!1),Q(!1),B==null||B(),t()},[t,B]);return l.useEffect(()=>{T(!0)},[]),l.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(W(!1),Q(!1)),()=>{document.body.style.overflow=""}),[r]),l.useEffect(()=>{if(!r)return;const V=_=>{if(_.key==="Escape"){if(U){R();return}$()}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[R,U,r,$]),X?je.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:`absolute inset-0 ${xa}`,onClick:$}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${x}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Te,{variant:"icon",onClick:$,title:"Cerrar",children:e.jsx(v.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(m||u)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m,u&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{variant:"secondary",size:"sm",onClick:$,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Te,{variant:"primary",size:"sm",icon:e.jsx($n.FiSave,{className:"w-4 h-4"}),onClick:u,loading:b,disabled:p,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:h,children:z})]}),ee&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),U&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":M,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${xa} transition-opacity duration-200 ease-out ${re?"opacity-100":"opacity-0"}`,onClick:R}),e.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 ${re?"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:[e.jsx(Te,{variant:"icon",onClick:R,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":S,children:e.jsx(v.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:e.jsx(v.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:M}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:C}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:R,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:S}),e.jsx(Te,{variant:"secondary",onClick:F,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:N})]})]})]})]}),document.body):null}const jl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,_l=/^\+?[0-9\s().-]+$/,Wl=7,ql=15;function _e(r){return r==null||String(r).trim()===""}function ya(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Ct(r){return _e(r)?!1:jl.test(String(r))}function Et(r){if(_e(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return _l.test(t)&&a.length>=Wl&&a.length<=ql}function Ul(r="Este campo es requerido."){return t=>_e(t)?r:void 0}function Vl(r="Ingresa un correo valido."){return t=>_e(t)||Ct(t)?void 0:r}function Kl(r="Ingresa un telefono valido."){return t=>_e(t)||Et(t)?void 0:r}function Gl(r,t){return a=>_e(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function Yl(r,t){return a=>_e(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function Xl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Zl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function Jl(r,t="El formato no es valido."){return a=>_e(a)||r.test(String(a))?void 0:t}function Ql(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const c=Array.isArray(s)?s:[s];for(const u of c){const b=u(r[n],r);if(b){a[n]=b;break}}}return{valid:Object.keys(a).length===0,errors:a}}var wa={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Na=l.createContext&&l.createContext(wa),Rl=["attr","size","title"];function eo(r,t){if(r==null)return{};var a,n,s=ro(r,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(n=0;n<c.length;n++)a=c[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function ro(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Vr(){return Vr=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Vr.apply(null,arguments)}function ka(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Kr(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?ka(Object(a),!0).forEach(function(n){to(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):ka(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function to(r,t,a){return(t=ao(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function ao(r){var t=no(r,"string");return typeof t=="symbol"?t:t+""}function no(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Sa(r){return r&&r.map((t,a)=>l.createElement(t.tag,Kr({key:a},t.attr),Sa(t.child)))}function Mt(r){return t=>l.createElement(lo,Vr({attr:Kr({},r.attr)},t),Sa(r.child))}function lo(r){var t=a=>{var{attr:n,size:s,title:c}=r,u=eo(r,Rl),b=s||a.size||"1em",p;return a.className&&(p=a.className),r.className&&(p=(p?p+" ":"")+r.className),l.createElement("svg",Vr({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,u,{className:p,style:Kr(Kr({color:r.color||a.color},a.style),r.style),height:b,width:b,xmlns:"http://www.w3.org/2000/svg"}),c&&l.createElement("title",null,c),r.children)};return Na!==void 0?l.createElement(Na.Consumer,null,a=>t(a)):t(wa)}function Ca(r){return Mt({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:[]}]})(r)}function oo(r){return Mt({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:[]}]})(r)}function so(r){return Mt({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:[]}]})(r)}function Gr({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function $t({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:c="Error de validacion",labelAction:u,floatingLabel:b=!1,showPasswordToggle:p=!0,nativeValidation:m=!1,className:h="",required:x,...g}){const[M,C]=l.useState(()=>!!g.autoFocus),[N,S]=l.useState(!1),B=g.type==="password"&&p,ee=B&&N?"text":g.type,z=!!n,X=z&&s!=="tooltip",T=z&&s!=="inline",U=m?x:void 0,Q=z?"border-[var(--danger)] focus:border-[var(--danger)]":"",re=T?B?"pr-20":"pr-10":B?"pr-10":"",W=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,J=M||W,R={top:J?7:12,color:M?"var(--primary)":"var(--text-muted)",fontSize:J?10:13,fontWeight:J?600:400,textTransform:J?"uppercase":"none"},$=le=>{var q;C(!0),(q=g.onFocus)==null||q.call(g,le)},F=le=>{var q;C(!1),(q=g.onBlur)==null||q.call(g,le)},V=B?e.jsxs("button",{type:"button","aria-label":N?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":N,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>S(le=>!le),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${N?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(oo,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${N?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(so,{className:"h-[18px] w-[18px]"})})]}):null,_=T?e.jsx(dr,{as:"span",content:n,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)] ${B?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":c,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return b?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,placeholder:" ","aria-invalid":z||g["aria-invalid"],"data-has-value":W?"true":void 0,className:`h-11 w-full pt-5 ${re} ${Q} ${h}`,onFocus:$,onBlur:F}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:R,children:[r,x&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),u&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:J?7:12},children:u}),_,V]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),x&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u&&e.jsx("span",{className:"ml-auto normal-case",children:u})]}),B?e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`,onFocus:$,onBlur:F}),_,V]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`}),_]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function Ea(r){return r==null?"":String(r)}function io({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,...m}){const[h,x]=l.useState(()=>Ea(b)),g=u!==void 0?Ea(u):h,M=a&&g.length>0&&!Ct(g)?n:void 0,C=N=>{u===void 0&&x(N.currentTarget.value),p==null||p(N)};return e.jsx($t,{...m,value:u,defaultValue:b,type:"text",inputMode:t,autoComplete:r,error:c??M,errorDisplay:s,onChange:C})}const co={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function uo({title:r="Sin resultados",description:t,icon:a=e.jsx(v.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:u=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${co[c]} ${u}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.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:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}const bo={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function fo(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Ma(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function po(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function mo({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:c=[],onFilesChange:u,onRejectedFiles:b,multiple:p=!1,maxFiles:m,appendFiles:h=!1,showFileList:x=!0,clearable:g=!0,browseLabel:M="Buscar archivos",dropLabel:C="Suelta los archivos aqui",emptyLabel:N="Arrastra y suelta archivos",emptyDescription:S="o haz click para buscarlos en tu equipo",selectedLabel:B="Archivos seleccionados",size:ee="md",containerClassName:z="",dropzoneClassName:X="",fileListClassName:T="",className:U="",id:Q,accept:re,disabled:W,required:J,...R}){const $=l.useId(),F=Q??$,V=l.useRef(null),[_,le]=l.useState(!1),[q,i]=l.useState(c),y=s??q,A=!!a,P=g&&y.length>0&&!W,D=(te,ue)=>{s===void 0&&i(te),u==null||u(te,ue)},ae=(te,ue)=>{const se=te.filter(be=>Ma(be,re)),w=te.filter(be=>!Ma(be,re)),I=h?[...y,...se]:se,de=po(I,p,m);w.length>0&&(b==null||b(w)),D(de,ue)},ie=()=>{var te;W||(te=V.current)==null||te.click()},pe=te=>{ae(Array.from(te.target.files??[]),te),te.target.value=""},L=te=>{te.preventDefault(),W||le(!0)},oe=te=>{te.currentTarget.contains(te.relatedTarget)||le(!1)},O=te=>{te.preventDefault(),le(!1),!W&&ae(Array.from(te.dataTransfer.files),te)},H=te=>{te.key!=="Enter"&&te.key!==" "||(te.preventDefault(),ie())},Z=te=>{D(y.filter((ue,se)=>se!==te))},G=()=>{D([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,children:[(r||n)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),J&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...R,ref:V,id:F,type:"file",accept:re,multiple:p,disabled:W,required:J&&y.length===0,"aria-invalid":A||R["aria-invalid"],className:"sr-only",onChange:pe}),e.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":F,"aria-disabled":W||void 0,"aria-invalid":A||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${bo[ee]} ${_?"border-[var(--primary)] bg-[var(--bg-input)]":A?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${X} ${U}`,onClick:ie,onDragOver:L,onDragLeave:oe,onDrop:O,onKeyDown:H,children:[e.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:e.jsx(v.HiArrowUpTray,{className:"h-5 w-5"})}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:_?C:N}),S&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:S})]}),M&&e.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:M})]}),x&&y.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${T}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:B}),P&&e.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:G,children:e.jsx(v.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:y.map((te,ue)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.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:e.jsx(v.HiDocument,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:te.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:fo(te.size)})]}),!W&&e.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 ${te.name}`,onClick:()=>Z(ue),children:e.jsx(v.HiXMark,{className:"h-4 w-4"})})]},`${te.name}-${te.lastModified}-${ue}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const ho=[{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 vo({fields:r,title:t="Layout",fieldTypes:a=ho,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:c="Nuevo campo",addFieldLabel:u="Anadir",loading:b=!1,onSave:p,onChange:m}){const[h,x]=l.useState(()=>r.map(z=>({key:!1,type:"",...z}))),[g,M]=l.useState(""),[C,N]=l.useState(""),S=l.useCallback((z,X)=>{x(T=>{const U=T.map((Q,re)=>re===z?{...Q,...X}:Q);return m==null||m(U),U})},[m]),B=l.useCallback(()=>{p==null||p(h)},[h,p]),ee=l.useCallback(()=>{var U;const z=g.trim();if(!z){N("Ingresa un nombre de campo.");return}if(h.some(Q=>Q.name.toLowerCase()===z.toLowerCase())){N("Ese campo ya existe en el arreglo.");return}const T={name:z,key:!1,type:((U=a[0])==null?void 0:U.value)??""};x(Q=>{const re=[...Q,T];return m==null||m(re),re}),M(""),N("")},[a,h,g,m]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.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:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[h.map((z,X)=>e.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:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:z.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Fr,{size:"sm",checked:z.key??!1,onChange:T=>S(X,{key:T.target.checked}),"aria-label":`${z.name} es clave`})}),e.jsx(rr,{value:z.type??"",onChange:T=>S(X,{type:T}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${z.name}`})]},z.name)),h.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:g,onChange:z=>{M(z.currentTarget.value),C&&N("")},onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),ee())},placeholder:c,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"}),e.jsx(Te,{variant:"secondary",onClick:ee,height:36,padding:"0 12px",children:u})]}),C&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:C})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Te,{variant:"primary",onClick:B,disabled:b,loading:b,children:n})})]})})]})}function $a({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:u="",contentClassName:b=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${u}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),c&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${b}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function La(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function go(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function xo({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:u,height:b=40,padding:p="6px 10px",searchable:m=!0,minOptionsForSearch:h=6,maxVisibleValues:x=2,truncateSelectedValues:g=!0,emptyText:M="Sin resultados",clearLabel:C="Limpiar seleccion"}){const[N,S]=l.useState(!1),[B,ee]=l.useState(""),[z,X]=l.useState(0),[T,U]=l.useState(!1),[Q,re]=l.useState({}),W=l.useRef(null),J=l.useRef(null),R=l.useRef(null),$=l.useRef(null),F=m&&a.length>=h,V=l.useMemo(()=>new Set(r),[r]),_=l.useMemo(()=>a.filter(L=>V.has(L.value)),[a,V]),le=x==="all"?_.length:x,q=_.slice(0,le),i=Math.max(0,_.length-q.length),y=F&&B.trim()?a.filter(L=>{var oe;return L.label.toLowerCase().includes(B.toLowerCase())||((oe=L.sublabel)==null?void 0:oe.toLowerCase().includes(B.toLowerCase()))}):a,A=l.useCallback(()=>{const L=W.current;if(!L)return;const oe=L.getBoundingClientRect(),O=F?304:244,H=window.innerHeight-oe.bottom,Z=H<O&&oe.top>H;re({position:"fixed",left:oe.left,top:Z?void 0:oe.bottom+4,bottom:Z?window.innerHeight-oe.top+4:void 0,width:oe.width,zIndex:9999})},[F]),P=l.useCallback(L=>{go(r,L)||t(L)},[t,r]),D=l.useCallback(L=>{const oe=a.find(H=>H.value===L);if(oe!=null&&oe.disabled)return;const O=V.has(L)?r.filter(H=>H!==L):[...r,L];P(O)},[P,a,r,V]),ae=l.useCallback(()=>P([]),[P]);l.useEffect(()=>U(!0),[]),l.useEffect(()=>{if(!N)return;function L(oe){var H,Z;const O=oe.target;!((H=W.current)!=null&&H.contains(O))&&!((Z=J.current)!=null&&Z.contains(O))&&(S(!1),ee(""))}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[N]),l.useEffect(()=>{N&&(X(0),A(),F&&setTimeout(()=>{var L;return(L=R.current)==null?void 0:L.focus()},0))},[N,F,A]),l.useEffect(()=>{if(N)return window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[N,A]),l.useEffect(()=>{if(z<0||!$.current)return;const L=$.current.children[z];L==null||L.scrollIntoView({block:"nearest"})},[z]);function ie(L){if(!N){(L.key==="Enter"||L.key===" "||L.key==="ArrowDown")&&(L.preventDefault(),S(!0));return}L.key==="Escape"&&(L.preventDefault(),S(!1),ee("")),L.key==="ArrowDown"&&(L.preventDefault(),X(oe=>Math.min(oe+1,y.length-1))),L.key==="ArrowUp"&&(L.preventDefault(),X(oe=>Math.max(oe-1,0))),L.key==="Enter"&&y[z]&&(L.preventDefault(),D(y[z].value)),L.key==="Backspace"&&!B&&r.length&&(L.preventDefault(),P(r.slice(0,-1)))}const pe=e.jsxs("div",{ref:J,className:"overflow-hidden rounded-xl shadow-xl",style:{...Q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[F&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(v.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:R,value:B,onChange:L=>{ee(L.target.value),X(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),B&&e.jsx("button",{type:"button",onMouseDown:L=>{L.preventDefault(),ee("")},children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),_.length>0&&e.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:[e.jsxs("span",{children:[_.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:L=>{L.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:C})]}),e.jsxs("ul",{ref:$,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:F?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[y.map((L,oe)=>{const O=oe===z,H=V.has(L.value);return e.jsxs("li",{role:"option","aria-selected":H,onMouseDown:Z=>{Z.preventDefault(),D(L.value)},onMouseEnter:()=>!L.disabled&&X(oe),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:O?"var(--bg-hover)":H?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:L.disabled?"var(--text-muted)":"var(--text-main)",cursor:L.disabled?"not-allowed":"pointer",opacity:L.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:H?"var(--primary)":"var(--border)",background:H?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:H&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),L.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:L.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:L.label}),L.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:L.sublabel})]}),L.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:L.badge})]},L.value)}),y.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:M})]})]});return e.jsxs("div",{ref:W,className:`relative ${c||"w-full"}`,style:u,onKeyDown:ie,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&S(L=>!L),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:La(b),padding:La(p),background:"var(--bg-input)",color:_.length?"var(--text-main)":"var(--text-muted)",border:N?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":N,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:q.length?e.jsxs(e.Fragment,{children:[q.map(L=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${g?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[L.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:L.color}}),e.jsx("span",{className:g?"truncate":"break-words",children:L.label})]},L.value)),i>0&&e.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",i]})]}):e.jsx("span",{className:"truncate",children:n})}),_.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":C,onMouseDown:L=>{L.preventDefault(),L.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(v.HiXMark,{className:"h-3 w-3"})}):e.jsx(v.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:N?"rotate(180deg)":"rotate(0deg)"}})]}),N&&T&&je.createPortal(pe,document.body)]})}function yo({inputMode:r="decimal",...t}){return e.jsx($t,{...t,type:"number",inputMode:r})}function wo(r,t,a){const n=[],s=Math.max(2,r-a),c=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let u=s;u<=c;u+=1)n.push(u);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function No({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const u=Math.max(1,t),b=Math.min(Math.max(1,r),u),p=wo(b,u,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${c}`,children:[e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||b<=1,onClick:()=>a(b-1),children:e.jsx(v.HiChevronLeft,{className:"h-4 w-4"})}),p.map((m,h)=>m==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${h}`):e.jsx("button",{type:"button","aria-current":m===b?"page":void 0,disabled:n,onClick:()=>a(m),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:m===b?"var(--primary)":"var(--border)",background:m===b?"var(--primary)":"var(--bg-card)",color:m===b?"var(--primary-fg)":"var(--text-secondary)"},children:m},m)),e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||b>=u,onClick:()=>a(b+1),children:e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})]})}const Ta=[{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 Aa(r){return r==null?"":String(r)}function Yr(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function ko(r){return typeof r=="number"?`${r}px`:r}function So({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,countryCode:m,defaultCountryCode:h="+1",onCountryCodeChange:x,allowedCountryCodes:g,countryCodeOptions:M,countryCodePlaceholder:C="Codigo",countryCodeClassName:N="",countryCodeWidth:S=84,onPhoneValueChange:B,label:ee,containerClassName:z="",helperText:X,labelAction:T,className:U="",required:Q,disabled:re,floatingLabel:W,showPasswordToggle:J,nativeValidation:R,errorTooltipLabel:$="Error de validacion",...F}){var te;const[V,_]=l.useState(()=>Aa(b)),[le,q]=l.useState(()=>Yr(h)),i=l.useMemo(()=>{const ue=M??Ta,se=g==null?void 0:g.map(Yr);return se!=null&&se.length?ue.filter(w=>se.includes(w.value)):ue},[g,M]),y=((te=i[0])==null?void 0:te.value)??"+1",A=i.some(ue=>ue.value===Yr(m??le))?Yr(m??le):y,P=u!==void 0?Aa(u):V,D=`${A} ${P}`.trim(),ae=a&&P.length>0&&!Et(D)?n:void 0,ie=c??ae,pe=!!ie,L=pe&&s!=="tooltip",oe=pe&&s!=="inline",O=pe?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",H=ue=>{const se=ue.currentTarget.value;u===void 0&&_(se),B==null||B(se,{countryCode:A,nationalNumber:se,fullNumber:`${A} ${se}`.trim()}),p==null||p(ue)},Z=ue=>{m===void 0&&q(ue),x==null||x(ue),B==null||B(P,{countryCode:ue,nationalNumber:P,fullNumber:`${ue} ${P}`.trim()})},G=oe?e.jsx(dr,{as:"span",content:ie,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:e.jsx("span",{tabIndex:0,role:"img","aria-label":$,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:ee}),Q&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),T&&e.jsx("span",{className:"ml-auto normal-case",children:T})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${O}`,children:[e.jsx(rr,{value:A,onChange:Z,options:i,placeholder:C,disabled:re,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${N}`,style:{width:ko(S)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...F,value:u,defaultValue:b,type:"tel",inputMode:t,autoComplete:r,disabled:re,required:void 0,"aria-label":F["aria-label"]??(typeof ee=="string"?ee:void 0),"aria-invalid":pe||F["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 ${oe?"pr-10":""} ${U}`,onChange:H}),G]})]}),L?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:ie}):X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:X}):null]})}function Co({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:u=!1,className:b="",optionClassName:p=""}){return e.jsxs("fieldset",{className:`min-w-0 ${b}`,disabled:u,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:c==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(m=>{const h=m.value===r,x=u||m.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${x?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${p}`,style:{borderColor:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.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:[e.jsx("input",{type:"radio",name:n,value:m.value,checked:h,disabled:x,onChange:()=>t(m.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:m.label}),m.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:m.description})]})]},m.value)})})]})}const Ha=()=>'<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>',Xr=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Da=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),Eo=r=>r.replace(/[<>]/g,"").toLowerCase(),Mo=r=>new RegExp("\\p{L}","u").test(r),Lt=(r,t)=>{const a=r.trim();return!a||!Mo(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===Da(a)},Ba=r=>{const t=n=>{var s,c;if(!n.closest(".rich-img-wrap")){const u=document.createElement("span");u.className="rich-img-wrap",u.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(u,n),u.appendChild(n),u.insertAdjacentHTML("beforeend",Ha())}(c=n.closest(".rich-img-wrap"))==null||c.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function $o({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px"}){const s=l.useRef(null),c=l.useRef(null),u=l.useRef(null),b=l.useRef(!1),p=l.useRef(r??""),m=l.useRef(t),[h,x]=l.useState(()=>!r||r.trim()===""),[g,M]=l.useState(new Set),[C,N]=l.useState(null),[S,B]=l.useState(""),[ee,z]=l.useState(""),[X,T]=l.useState(""),[U,Q]=l.useState(""),[re,W]=l.useState(!1),J=l.useCallback(()=>b.current?c.current:s.current,[]);l.useEffect(()=>{m.current=t},[t]);const R=l.useCallback(()=>{const w=window.getSelection(),I=J();if(!w||!I||w.rangeCount===0||w.isCollapsed)return"";const de=w.getRangeAt(0);return!I.contains(de.startContainer)||!I.contains(de.endContainer)?"":w.toString()},[J]);l.useEffect(()=>{const w=r??"";p.current=w;const I=[s.current,c.current].filter(be=>!!be);I.forEach(be=>{be.innerHTML!==w&&(be.innerHTML=w)}),x(!w||w.trim()==="");const de=I.map(be=>Ba(be));return()=>de.forEach(be=>be())},[r]),l.useEffect(()=>{var be,ke;b.current=re;let w,I=0,de;if(re){const me=s.current;me&&(p.current=me.innerHTML);const Se=()=>{var fe;const we=c.current;if(!we){I=requestAnimationFrame(Se);return}we.innerHTML!==p.current&&(we.innerHTML=p.current),w=Ba(we),x(((fe=we.textContent)==null?void 0:fe.trim())===""),de=setTimeout(()=>we.focus(),60)};I=requestAnimationFrame(Se)}else{const me=c.current,Se=s.current,we=(me==null?void 0:me.innerHTML)??p.current,fe=p.current;p.current=we,Se&&Se.innerHTML!==we&&(Se.innerHTML=we),we!==fe&&m.current(we),x(((ke=(be=me??Se)==null?void 0:be.textContent)==null?void 0:ke.trim())==="")}return()=>{I&&cancelAnimationFrame(I),de&&clearTimeout(de),w==null||w()}},[re]);const $=l.useCallback(()=>{const w=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],I=new Set;w.forEach(be=>{try{document.queryCommandState(be)&&I.add(be)}catch{return}});try{const be=Eo(document.queryCommandValue("formatBlock"));be&&I.add(`formatBlock:${be}`)}catch{return}const de=R();Lt(de,"uppercase")&&I.add("__upper"),Lt(de,"lowercase")&&I.add("__lower"),Lt(de,"capitalize")&&I.add("__cap"),M(I)},[R]),F=()=>{var I;const w=J();w&&(p.current=w.innerHTML,m.current(p.current),x(((I=w.textContent)==null?void 0:I.trim())===""))},V=w=>{if(!w){const I=s.current;I&&(p.current=I.innerHTML)}W(!w)},_=(w,I)=>{var de;(de=J())==null||de.focus(),document.execCommand(w,!1,I),F(),$()},le=w=>{_("formatBlock",w)},q=()=>{var w;(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,"<hr><p><br></p>"),F(),$()},i=()=>{const w=window.getSelection();w&&w.rangeCount>0&&(u.current=w.getRangeAt(0).cloneRange())},y=()=>{const w=window.getSelection();w&&u.current&&(w.removeAllRanges(),w.addRange(u.current))},A=w=>{if(i(),w==="link"){const I=window.getSelection();z(I&&!I.isCollapsed?I.toString():""),B("")}w==="image"&&(T(""),Q("")),N(w)},P=()=>{var be;if(!S.trim())return;y(),(be=J())==null||be.focus();const w=window.getSelection(),de=(w&&!w.isCollapsed?w.toString():"")||ee.trim()||S.trim();document.execCommand("insertHTML",!1,`<a href="${Xr(S.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Xr(de)}</a>`),F(),N(null)},D=(w,I="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Xr(w)}" alt="${Xr(I)}" class="rich-img" />${Ha()}</span>`,ae=()=>{var w;X.trim()&&(y(),(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,D(X.trim(),U.trim())),F(),N(null))},ie=(w,I=1200,de=1200,be=.72)=>new Promise((ke,me)=>{const Se=new FileReader;Se.onerror=me,Se.onload=we=>{var Ge;const fe=(Ge=we.target)==null?void 0:Ge.result,Be=new Image;Be.onerror=me,Be.onload=()=>{let{width:ze,height:ne}=Be;if(ze>I||ne>de){const Oe=Math.min(I/ze,de/ne);ze=Math.round(ze*Oe),ne=Math.round(ne*Oe)}const Me=document.createElement("canvas");Me.width=ze,Me.height=ne;const $e=Me.getContext("2d");if(!$e){ke(fe);return}$e.drawImage(Be,0,0,ze,ne),ke(Me.toDataURL("image/jpeg",be))},Be.src=fe},Se.readAsDataURL(w)}),pe=w=>{const de=Array.from(w.clipboardData.items).find(ke=>ke.type.startsWith("image/"));if(!de)return;w.preventDefault();const be=de.getAsFile();be&&ie(be).then(ke=>{var me;(me=J())==null||me.focus(),document.execCommand("insertHTML",!1,D(ke,"imagen")),F()})},L=w=>{const I=window.getSelection(),de=J();if(!I||!de||I.rangeCount===0||I.isCollapsed)return;const be=I.getRangeAt(0);if(!de.contains(be.startContainer)||!de.contains(be.endContainer))return;const ke=be.toString();if(!ke)return;let me=ke;w==="uppercase"?me=ke.toLocaleUpperCase():w==="lowercase"?me=ke.toLocaleLowerCase():me=Da(ke),be.deleteContents();const Se=document.createTextNode(me);be.insertNode(Se);const we=document.createRange();we.setStart(Se,0),we.setEnd(Se,me.length),I.removeAllRanges(),I.addRange(we),u.current=we.cloneRange(),F(),$()},oe=()=>{i(),$()},O=()=>{F(),$()},H=w=>{if(w.key==="Escape"){if(C){N(null);return}if(b.current){W(!1);return}}C||(w.ctrlKey||w.metaKey)&&(w.key==="b"&&(w.preventDefault(),_("bold")),w.key==="i"&&(w.preventDefault(),_("italic")),w.key==="u"&&(w.preventDefault(),_("underline")),w.key==="k"&&(w.preventDefault(),A("link")))},Z=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),G=(w,I,de,be,ke)=>{const me=ke??(g.has(de)||de==="__link"&&C==="link"||de==="__img"&&C==="image");return e.jsx("button",{type:"button",title:I,onMouseDown:Se=>{Se.preventDefault(),be?be():_(de)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:me?"var(--primary)":"var(--text-secondary)",background:me?"rgba(59,130,246,0.12)":"transparent"},children:w},de)},te=w=>{const I=w.target;if(I.closest("[data-action='delete-img']")){w.preventDefault();const de=I.closest(".rich-img-wrap");de&&(de.remove(),F())}},ue=w=>e.jsxs(e.Fragment,{children:[C==="link"&&e.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:[e.jsx("input",{autoFocus:!0,type:"url",value:S,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),P()),I.key==="Escape"&&N(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:ee,onChange:I=>z(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),P()),I.key==="Escape"&&N(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:P,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),C==="image"&&e.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:[e.jsx("input",{autoFocus:!0,type:"url",value:X,onChange:I=>T(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.key==="Escape"&&N(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:U,onChange:I=>Q(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.key==="Escape"&&N(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:ae,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),se=(w,I)=>e.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:I},children:[G(e.jsx(v.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),G(e.jsx(v.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>le("p"),g.has("formatBlock:p")||g.has("formatBlock:div")),G(e.jsx(v.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>le("h2"),g.has("formatBlock:h2")),G(e.jsx(v.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>le("h3"),g.has("formatBlock:h3")),G(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>le("blockquote"),g.has("formatBlock:blockquote")),Z(),G(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),G(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),G(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),G(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Z(),G(e.jsx(v.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),G(e.jsx(v.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),G(e.jsx(v.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),G(e.jsx(v.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Z(),G(e.jsx(v.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),G(e.jsx(v.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),G(e.jsx(v.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),G(e.jsx(v.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>L("uppercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>L("lowercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>L("capitalize")),Z(),G(e.jsx(v.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>A("link")),G(e.jsx(v.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),G(e.jsx(v.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>A("image")),G(e.jsx(v.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",q),Z(),G(e.jsx(v.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),G(e.jsx(v.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>le("p")),Z(),e.jsx("button",{type:"button",title:w?"Salir del modo de enfoque (Esc)":"Modo de enfoque",onMouseDown:de=>{de.preventDefault(),V(w)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:w?e.jsx(v.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(v.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return e.jsxs(e.Fragment,{children:[e.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:[e.jsx("div",{ref:s,contentEditable:!0,suppressContentEditableWarning:!0,onInput:O,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ue("var(--bg-input)"),se(!1,"var(--bg-input)")]}),e.jsxs(St,{open:re,onClose:()=>W(!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:[e.jsx("div",{ref:c,contentEditable:!0,suppressContentEditableWarning:!0,onInput:O,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),ue("var(--bg-input)"),se(!0,"var(--bg-input)")]})]})}function Lo({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:u="",bodyClassName:b="p-4"}){const p=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${u}`,children:[p&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.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:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:b,children:s}),c&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:c})]})}const To={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)"}},Ao={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 Ho({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const u=To[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Ao[a]} ${c}`,style:{color:u.text,background:u.bg,borderColor:u.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:u.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Ia={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)"}},Do={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"},Bo={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Io={xs:148,sm:164,md:184},Oo={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 Fo({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:c=!1,stopPropagation:u=!1,ariaLabel:b="Cambiar estado",title:p="Cambiar estado",className:m,selectClassName:h,menuClassName:x,optionClassName:g,spinnerClassName:M}){const[C,N]=l.useState(!1),[S,B]=l.useState(!1),[ee,z]=l.useState(-1),[X,T]=l.useState({}),U=l.useRef(null),Q=l.useRef(null),re=l.useRef(null),W=t.find(i=>i.value===r)??t[0],J={...W!=null&&W.tone?Ia[W.tone]:void 0,...W==null?void 0:W.style},R=s||c||t.length===0,$=i=>{u&&i.stopPropagation()},F=l.useCallback(()=>{N(!1),z(-1)},[]),V=l.useCallback(()=>{const i=U.current;if(!i)return;const y=i.getBoundingClientRect(),A=Math.max(y.width,Io[n]),P=Math.min(Math.max(t.length,1)*38+12,260),D=window.innerHeight-y.bottom,ae=D<P&&y.top>D,ie=Math.min(Math.max(8,y.left+y.width/2-A/2),window.innerWidth-A-8);T({position:"fixed",left:ie,top:ae?void 0:y.bottom+6,bottom:ae?window.innerHeight-y.top+6:void 0,width:A,zIndex:9999})},[t.length,n]),_=l.useCallback(i=>{i.disabled||(a(i.value),F())},[F,a]);l.useEffect(()=>B(!0),[]),l.useEffect(()=>{if(!C)return;V();const i=t.findIndex(y=>y.value===r);z(i>=0?i:0)},[C,t,V,r]),l.useEffect(()=>{if(!C)return;function i(y){var P,D;const A=y.target;!((P=U.current)!=null&&P.contains(A))&&!((D=Q.current)!=null&&D.contains(A))&&F()}return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[F,C]),l.useEffect(()=>{if(C)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[C,V]),l.useEffect(()=>{if(ee<0||!re.current)return;const i=re.current.children[ee];i==null||i.scrollIntoView({block:"nearest"})},[ee]);function le(i){if(!R){if(!C){["Enter"," ","ArrowDown","ArrowUp"].includes(i.key)&&(i.preventDefault(),N(!0));return}if(i.key==="Escape"){i.preventDefault(),F();return}if(i.key==="ArrowDown"){i.preventDefault(),z(y=>Math.min(y+1,t.length-1));return}if(i.key==="ArrowUp"){i.preventDefault(),z(y=>Math.max(y-1,0));return}if(i.key==="Enter"||i.key===" "){i.preventDefault();const y=t[ee];y&&_(y)}}}const q=e.jsx("div",{ref:Q,role:"listbox","aria-label":b,className:Je("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",x),style:{...X,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:$,onMouseDown:$,onPointerDown:$,children:e.jsx("div",{ref:re,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((i,y)=>{const A=i.value===r,P=y===ee,D={...i.tone?Ia[i.tone]:void 0,...i.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":A,disabled:i.disabled,onMouseEnter:()=>!i.disabled&&z(y),onMouseDown:ae=>{ae.preventDefault(),_(i)},className:Je("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Oo[n],A?i.className:void 0,g),style:{...A?D:void 0,background:A?D.background??"color-mix(in srgb, var(--primary) 12%, transparent)":P?"var(--bg-hover)":"transparent",color:A?D.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:A?e.jsx(v.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.label})]},i.value)})})});return e.jsxs("span",{ref:U,className:Je("relative inline-flex shrink-0 items-center",m),onKeyDown:le,onClick:$,onPointerDown:$,children:[e.jsx("button",{type:"button",disabled:R,"aria-label":b,"aria-haspopup":"listbox","aria-expanded":C,title:p,onClick:()=>!R&&N(i=>!i),className:Je("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",Do[n],W==null?void 0:W.className,h),style:J,children:e.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??r})}),e.jsx(v.HiChevronDown,{"aria-hidden":"true",className:Je("pointer-events-none absolute opacity-70 transition-transform",Bo[n],C?"rotate-180":"rotate-0")}),c&&e.jsx("span",{"aria-hidden":"true",className:Je("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",M)}),C&&S&&je.createPortal(q,document.body)]})}function Po({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:u="",listClassName:b="",panelClassName:p=""}){const m=r.find(C=>!C.disabled)??r[0],h=t??a??(m==null?void 0:m.id),x=r.find(C=>C.id===h)??m,g=C=>{C.disabled||n==null||n(C.id)},M=C=>{const N=r.filter(B=>!B.disabled);if(!N.length||!x)return;const S=N.findIndex(B=>B.id===x.id);(C.key==="ArrowRight"||C.key==="ArrowDown")&&(C.preventDefault(),g(N[(S+1)%N.length])),(C.key==="ArrowLeft"||C.key==="ArrowUp")&&(C.preventDefault(),g(N[(S-1+N.length)%N.length])),C.key==="Home"&&(C.preventDefault(),g(N[0])),C.key==="End"&&(C.preventDefault(),g(N[N.length-1]))};return e.jsxs("div",{className:u,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:M,className:`flex min-w-0 gap-1 overflow-x-auto ${c==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${b}`,children:r.map(C=>{const N=C.id===(x==null?void 0:x.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":N,"aria-controls":`${C.id}-panel`,id:`${C.id}-tab`,disabled:C.disabled,tabIndex:N?0:-1,onClick:()=>g(C),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 ${c==="underline"?"border-b-2":"rounded-md border"}`,style:{color:N?"var(--primary)":"var(--text-muted)",borderColor:N?"var(--primary)":"transparent",background:c==="pills"&&N?"var(--bg-card)":"transparent"},children:[C.icon&&e.jsx("span",{className:"shrink-0",children:C.icon}),e.jsx("span",{children:C.label}),C.badge&&e.jsx("span",{className:"shrink-0",children:C.badge})]},C.id)})}),(x==null?void 0:x.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${x.id}-panel`,"aria-labelledby":`${x.id}-tab`,className:`pt-4 ${p}`,children:x.content})]})}function Qe(...r){return r.filter(Boolean).join(" ")}function zo({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:u,onBlockedStep:b,allowBackNavigation:p=!0,showFooter:m=!0,previousLabel:h="Anterior",nextLabel:x="Siguiente",blockedNextLabel:g="Completa este paso",className:M="",headerClassName:C="",contentClassName:N="",footerClassName:S=""}){var O;const B=((O=r[0])==null?void 0:O.id)??"",[ee,z]=l.useState(a??B),[X,T]=l.useState(s),U=t??ee,Q=n??X,re=l.useMemo(()=>new Set(Q),[Q]),W=Math.max(0,r.findIndex(H=>H.id===U)),J=r[W]??r[0],R=r.length<=1?100:W/(r.length-1)*100,$=H=>{n||T(H),u==null||u(H)},F=H=>{const Z=r.find(G=>G.id===H);Z&&(t||z(H),c==null||c(H,Z))},V=H=>re.has(H),_=H=>r.slice(0,H).find(Z=>!Z.optional&&!re.has(Z.id)),le=H=>{const Z=r[H];return!Z||Z.disabled?!1:H===W||p&&H<W?!0:!_(H)},q=H=>{const Z=r.findIndex(G=>G.id===H);return Z>=0&&le(Z)},i=H=>{const Z=r.findIndex(G=>G.id===H);if(Z<0)return!1;if(!le(Z)){const G=_(Z);return G&&(b==null||b(r[Z],G)),!1}return F(H),!0},y=(H=J==null?void 0:J.id)=>{!H||re.has(H)||$([...Q,H])},A=(H=J==null?void 0:J.id)=>{if(!H)return;const Z=r.findIndex(te=>te.id===H),G=Q.filter(te=>{const ue=r.findIndex(se=>se.id===te);return ue>=0&&ue<Z});$(G),Z>=0&&W>Z&&F(H)},P=()=>W<=0?!1:i(r[W-1].id),D=()=>{const H=r[W+1];return H?i(H.id):!1},ae={activeStep:J,activeIndex:W,completedStepIds:Q,isCompleted:V,isUnlocked:q,completeStep:y,uncompleteStep:A,goToStep:i,goNext:D,goPrevious:P};if(!J)return null;const ie=r[W+1],pe=W>0,L=ie?q(ie.id):!1,oe=typeof J.content=="function"?J.content(ae):J.content;return e.jsxs("section",{className:Qe("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",M),children:[e.jsxs("div",{className:Qe("border-b border-[var(--border)] bg-[var(--bg-input)]",C),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${R}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((H,Z)=>{const G=H.id===J.id,te=V(H.id),ue=le(Z),se=_(Z);return e.jsxs("button",{type:"button",disabled:!ue,"aria-current":G?"step":void 0,"aria-disabled":!ue,title:!ue&&se?`Completa ${se.title}`:H.title,onClick:()=>i(H.id),className:Qe("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",G&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",te&&!G&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!G&&!te&&ue&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ue&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:Qe("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",G&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:Qe("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",G&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",te&&!G&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!te&&!G&&ue&&"border-[var(--border)] text-[var(--text-muted)]",!ue&&"border-[var(--border)] text-[var(--text-muted)]"),children:te?e.jsx(v.HiCheck,{className:"h-4 w-4"}):ue?Z+1:e.jsx(v.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:Qe("block truncate text-xs font-semibold transition-colors duration-200",G?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Z+1,". ",H.title]}),H.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:H.description})]}),H.badge&&e.jsx("span",{className:"shrink-0",children:H.badge})]})]},H.id)})})]}),e.jsx("div",{className:Qe("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",N),children:oe},J.id),m&&e.jsxs("div",{className:Qe("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",S),children:[e.jsx(Te,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(v.HiChevronLeft,{}),disabled:!pe,onClick:P,children:h}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",W+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[Q.length," completados"]})]}),e.jsx(Te,{height:38,padding:"0 14px",icon:e.jsx(v.HiChevronRight,{}),disabled:!ie||!L,onClick:D,children:ie&&!L?g:x})]})]})}const jo={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"},_o={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Wo(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function qo(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Oa=l.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:c=!1,minRows:u,maxRows:b,showCount:p=!1,maxCount:m,status:h="default",icon:x,action:g,style:M,value:C,defaultValue:N,maxLength:S,onInput:B,...ee},z){const X=l.useRef(null),T=qo(C,N),U=m??S,Q=!!(x||g||p),re=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",W={...M??{},...u?{minHeight:`${u*24+18}px`}:null,...b?{maxHeight:`${b*24+18}px`}:null},J=()=>{const $=X.current;!$||!c||($.style.height="auto",$.style.height=`${$.scrollHeight}px`)};l.useEffect(J,[c,C]);const R=e.jsx("textarea",{...ee,ref:$=>{X.current=$,Wo(z,$)},value:C,defaultValue:N,maxLength:S,"aria-invalid":h==="error"||ee["aria-invalid"],onInput:$=>{J(),B==null||B($)},style:{...W,borderColor:re},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 ${jo[n]} ${_o[c?"none":s]} ${x?"pl-8":""} ${g?"pr-10":""} ${t}`});return Q?e.jsxs("span",{className:`relative block ${a}`,children:[x&&e.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:x}),R,g&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:g}),p&&e.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:[T,U?`/${U}`:""]})]}):R});function Uo({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:u="",status:b,...p}){return e.jsx($a,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Oa,{...p,required:c,status:n?"error":b,className:`w-full ${u}`})})}const Vo={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Ko({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const u=Vo[n],b=r?u.width-u.thumb-u.padding*2:0;return e.jsx("button",{...c,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:u.width,height:u.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:u.thumb,height:u.thumb,left:u.padding,top:"50%",transform:`translate(${b}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Fa=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function Go(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function Pa(r){return r.classList.contains("sidebar-scroll")}function za(r){Pa(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function ja(){return l.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Fa).forEach(c=>{if(!Go(c))return;if(Zt.OverlayScrollbars(c)){za(c);return}const b=Zt.OverlayScrollbars(c,{overflow:Pa(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});za(c),r.set(c,b)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(Fa).forEach(c=>{var u;c instanceof HTMLElement&&((u=r.get(c))==null||u.destroy())})}},[]),null}const Yo={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"}},_a=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Xo={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Zo="bonsaif.bot",Jo="Bonsaif Bot",Qo={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Wa(r){return typeof r=="string"?r.trim():""}function Ro(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return _a[t%_a.length]}function es(r,t){return r===Zo||t===Jo}function rs(r,t){return`${r.replace(/\/$/,"")}${t}`}function qa({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:u,fallbackLabel:b="Usuario",wrapperClassName:p="",labelClassName:m="",labelSize:h="xs",avatarVersion:x=0,className:g="",style:M}){var V;const[C,N]=l.useState(!1),S=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";l.useEffect(()=>{N(!1)},[S,x]);const{wh:B,text:ee}=Yo[n],z=Wa(a)||Wa(t)||b,X=z.trim()[0]||"?",T=typeof process<"u"&&((V=process.env)==null?void 0:V.NEXT_PUBLIC_BASE_PATH)||"",U=es(t,a),Q=rs(T,"/favicon.svg"),re=S?`${T}/api/user/avatar/${S}${x?`?v=${x}`:""}`:"",J={xs:20,sm:28,md:36,lg:48,xl:64}[n],R=U?e.jsx("span",{className:`${B} ${Qo[n]} 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:M,children:e.jsx("img",{src:Q,alt:z,width:J,height:J,className:"h-full w-full object-contain"})}):re&&!C?e.jsx("img",{src:re,alt:z,width:J,height:J,className:`${B} rounded-full object-cover flex-shrink-0 ${g}`,style:M,onError:()=>N(!0)},`${S}-${x}`):e.jsx("span",{className:`${B} ${Ro(z)} ${ee} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:M,title:z,children:X});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${p}`,children:[R,e.jsx("span",{className:`min-w-0 truncate ${Xo[h]} font-medium text-[var(--text-main)] ${m}`,title:z,children:z})]});const $=c??!0,F=u??z;return $&&F?e.jsx(dr,{as:"span",content:F,className:`inline-flex flex-shrink-0 ${p}`,children:R}):R}function ts({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function as(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Ua({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:u,footer:b,onLogout:p,LinkComponent:m=ts}){const[h,x]=l.useState(!1),g=as(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(ja,{}),e.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:()=>x(!0),children:e.jsx(v.HiBars3,{className:"h-5 w-5"})}),h&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>x(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${h?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:c??e.jsx(v.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),e.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:()=>x(!1),children:e.jsx(v.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(g).map(([M,C])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(v.HiChevronDown,{className:"h-3.5 w-3.5"}),M]}),e.jsx("div",{className:"space-y-1",children:C.map(N=>{const S=a===N.href||a.startsWith(`${N.href}/`);return e.jsxs(m,{href:N.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${S?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:N.icon??e.jsx(v.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:N.label})]},N.href)})})]},M))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(qa,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),p&&e.jsxs(Te,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:p,children:[e.jsx(v.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),b]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[u,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Va="bonsaif-ui:prime-auth-sso",ns={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"},Tt={dashboard:e.jsx(v.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(v.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(v.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(v.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(v.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(v.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(v.HiUser,{className:"h-5 w-5"}),settings:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(v.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(v.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(v.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(v.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(v.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(v.HiShieldCheck,{className:"h-5 w-5"})};function ls({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function os(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ss(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function is(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=ss(a)&&n?n:a,c=ns[s]??os(s);return[{label:"Inicio",href:"/"},{label:c}]}function At(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function cs(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(v.HiHome,{className:"h-5 w-5"});if(Tt[a])return Tt[a];const n=t.length>1?t[t.length-2]:"";return Tt[n]??e.jsx(v.HiHome,{className:"h-5 w-5"})}function ds(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Ka(){if(typeof window>"u")return!1;if(ds(window.location.href)){try{window.sessionStorage.setItem(Va,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Va)==="true"}catch{return!1}}function us({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:u="",breadcrumbs:b,currentPath:p,showBreadcrumbs:m=!0,contained:h=!1,LinkComponent:x=ls}){const g=l.useRef(null),[M,C]=l.useState(!1),[N,S]=l.useState(p??"/"),[B,ee]=l.useState(()=>Ka()),[z,X]=l.useState(null),T=p??N,U=b??is(T),Q=s??cs(T),re=m&&!B&&U.length>1,W=!re;l.useEffect(()=>{p||S(window.location.pathname)},[p]),l.useEffect(()=>{ee(Ka())},[]),l.useEffect(()=>{if(h){C(!1);return}let R=null,$=0,F=0;const V=()=>{const q=g.current,i=document.querySelector("[data-app-scroll='true']");return(q==null?void 0:q.closest(".os-viewport"))??(q==null?void 0:q.closest("[data-overlayscrollbars-viewport]"))??At(i)??i??window},_=()=>{const q=R&&R!==window?R.scrollTop:window.scrollY;C(i=>i?q>24:q>72)},le=()=>{R==null||R.removeEventListener("scroll",_),R=V(),R.addEventListener("scroll",_,{passive:!0}),_()};return le(),$=window.requestAnimationFrame(le),F=window.setTimeout(le,120),()=>{window.cancelAnimationFrame($),window.clearTimeout(F),R==null||R.removeEventListener("scroll",_)}},[h]),l.useEffect(()=>{if(h){X(null);return}let R=0;const $=[],F=()=>{const A=g.current,P=A==null?void 0:A.parentElement,D=document.querySelector("[data-app-scroll='true']"),ae=At(D)??D;if(!A||!P||!ae){X(null);return}const ie=P.getBoundingClientRect(),pe=window.getComputedStyle(P),L=ae.getBoundingClientRect(),oe=ae instanceof HTMLElement&&ae.clientWidth>0?ae.clientWidth:L.width,O=ie.left+parseFloat(pe.paddingLeft||"0"),H={marginLeft:Math.round(L.left-O),width:Math.round(oe)};X(Z=>Z&&Z.marginLeft===H.marginLeft&&Z.width===H.width?Z:H)},V=()=>{window.cancelAnimationFrame(R),R=window.requestAnimationFrame(F)};V(),window.addEventListener("resize",V);const _=new ResizeObserver(V),le=g.current,q=le==null?void 0:le.parentElement,i=document.querySelector("[data-app-scroll='true']"),y=At(i)??i;return[q,i,y].forEach(A=>{A&&_.observe(A)}),$.push(window.setTimeout(V,120)),$.push(window.setTimeout(V,280)),()=>{window.cancelAnimationFrame(R),window.removeEventListener("resize",V),_.disconnect(),$.forEach(A=>window.clearTimeout(A))}},[h]);const J={...z?{marginLeft:z.marginLeft,width:z.width}:null,"--page-header-control-height":M?"34px":"40px","--page-header-control-padding-x":M?"10px":"14px","--page-header-control-icon-left":M?"10px":"12px",background:h?"var(--bg-card)":M?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:h||M?"1px solid var(--border)":"1px solid transparent",boxShadow:M?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:g,"data-page-header":"true","data-compact":M?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:J,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${M?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":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"} ${u}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${M||W?"gap-1":"gap-1.5 sm:gap-2"}`,children:[re&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${M?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:U.map((R,$)=>{const F=$===U.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[$>0&&e.jsx(v.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),R.href&&!F?e.jsx(x,{href:R.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:R.label}):e.jsx("span",{"aria-current":F?"page":void 0,className:F?"truncate font-semibold":"truncate",style:{color:F?"var(--text-main)":"var(--text-muted)"},children:R.label})]},`${R.label}-${$}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${M||W?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${M?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:re?"var(--text-secondary)":"var(--text-muted)"},children:Q}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${M?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${M?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":M,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${M?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${M?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${M?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(ra.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function bs({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Ua,{currentPath:t,...n,children:r})}function Ga(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function fs(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const c=new URL(s,n.origin);return c.searchParams.set("theme",t),a&&(c.searchParams.set("primeAuthOrigin",window.location.origin),c.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${c.pathname}${c.search}${c.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function ps({name:r,src:t,projectKey:a}){const[n,s]=l.useState("system"),c=l.useRef(null);l.useEffect(()=>{s(Ga());const p=new MutationObserver(()=>s(Ga()));return p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>p.disconnect()},[]);const u=l.useMemo(()=>fs(t,n,a),[a,t,n]),b=l.useMemo(()=>{try{return new URL(u).origin}catch{return""}},[u]);return l.useEffect(()=>{if(!a)return;const p=a;function m(h){var M,C,N;if(h.source!==((M=c.current)==null?void 0:M.contentWindow)||b&&h.origin!==b)return;if(((C=h.data)==null?void 0:C.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((N=h.data)==null?void 0:N.type)!=="prime-microservice:navigation")return;const x=h.data.path;if(!x||!x.startsWith("/")||x.startsWith("//"))return;const g=`/apps/${encodeURIComponent(p)}${x}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==g&&(window.history.replaceState(window.history.state,"",g),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",m),()=>{window.removeEventListener("message",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[b,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:c,src:u,title:r,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 ms(){const[r,t]=l.useState(""),[a,n]=l.useState(!1),[s,c]=l.useState({width:96,height:96});return l.useEffect(()=>{let u=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(b=>b.ok?b.json():null).then(b=>{!u&&(b!=null&&b.src)&&t(b.src)}).catch(()=>{}),()=>{u=!0}},[]),l.useEffect(()=>{const u=b=>{var m;if(((m=b.data)==null?void 0:m.type)!=="prime-suite-chat:state")return;const p=!!b.data.active;n(p),c({width:Ya(b.data.width,96,720),height:Ya(b.data.height,96,560)})};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ya(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function hs(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function vs(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function gs(){return"light"}function xs({position:r="bottom-center"}){const t=l.useSyncExternalStore(hs,vs,gs);return e.jsx(Jt.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function ys(r){const[t,a]=l.useState({}),[n,s]=l.useState(!1),c=l.useCallback(m=>n||t[m]?r[m]:void 0,[r,n,t]),u=l.useCallback(m=>{a(h=>({...h,[m]:!0}))},[]),b=l.useCallback(()=>{s(!0)},[]),p=l.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:c,touchField:u,submit:b,reset:p}}Object.defineProperty(Y,"toast",{enumerable:!0,get:()=>Jt.toast}),Y.Alert=Kn,Y.AuthShell=Ua,Y.BonsaifButton=Ln,Y.BonsaifUIToaster=xs,Y.Button=Te,Y.CalendarPicker=Jn,Y.Checkbox=Fr,Y.CodeBlock=tl,Y.CompactFilterSelect=nl,Y.CompactSearchInput=al,Y.ConfirmDialog=il,Y.CopyButton=Nt,Y.CopyLinkButton=dl,Y.DataSheets=Al,Y.DataTable=ma,Y.DateRangePicker=Bl,Y.Drawer=zl,Y.DropdownMenu=Fl,Y.DynamicDetailTabs=Un,Y.EmailField=io,Y.EmptyState=uo,Y.FieldLayoutEditor=vo,Y.FileUpload=mo,Y.FormField=$a,Y.GlobalScrollbars=ja,Y.InputField=$t,Y.LoadingState=la,Y.MicroserviceFrame=ps,Y.Modal=St,Y.MouseTooltip=dr,Y.MultiSelect=xo,Y.NumberField=yo,Y.PageHeader=us,Y.PageSearchInput=ea,Y.Pagination=No,Y.PhoneField=So,Y.PrimeAuthRouteShell=bs,Y.PrimeSuiteChatFrame=ms,Y.RadioGroup=Co,Y.RichTextEditor=$o,Y.SearchableSelect=rr,Y.SectionPanel=Lo,Y.StatusBadge=Ho,Y.StatusSelect=Fo,Y.StepWizard=zo,Y.Tabs=Po,Y.TextInput=Gr,Y.Textarea=Oa,Y.TextareaField=Uo,Y.Toggle=Ko,Y.UserAvatar=qa,Y.cn=Je,Y.emailFormat=Vl,Y.isValidEmail=Ct,Y.isValidPhone=Et,Y.matches=Jl,Y.maxLength=Yl,Y.maxValue=Zl,Y.minLength=Gl,Y.minValue=Xl,Y.phoneCountryCodeOptions=Ta,Y.phoneFormat=Kl,Y.required=Ul,Y.useValidationVisibility=ys,Y.validateForm=Ql,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
|
|
21
|
+
</body></html>`,k=window.open("","_blank");k&&(k.document.write(K),k.document.close())}const ht=()=>!Se||!Tr?null:je.createPortal(e.jsxs("div",{ref:Ot,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ls,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[e.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:()=>{ai(),rt(!1)},children:[e.jsx(v.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),e.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:()=>{ni(),rt(!1)},children:[e.jsx(v.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),vt=()=>{const o=F&&Xe.trim().length>0,d=de!=null&&de.length?de:o?[{key:"bql",label:"BQL",value:Xe}]:[],E=I.filter(f=>f.trim()&&f!==Rr).slice(0,8);return!D&&jt===0&&!F&&!Se?null:e.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:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[jt>0&&e.jsxs("button",{type:"button",onClick:_s,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:[e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"}),jt," filtros"]}),F&&e.jsxs("div",{ref:Bt,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(Ze){or(!1);return}it(),or(!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)":o?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||o?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[e.jsx(v.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",o&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?e.jsx(v.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(v.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:te}),d.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[d.slice(0,3).map(f=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key)),d.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",d.length-3]})]}),o&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:bn,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:e.jsx(v.HiXMark,{className:"h-4 w-4"})}),Ze&&je.createPortal(e.jsxs("div",{ref:en,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Cs,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[se.map(f=>e.jsxs("button",{type:"button",onClick:()=>st(f.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:[f.icon,f.label]},f.label)),w.length>0&&e.jsxs("button",{type:"button",onClick:()=>fr(f=>!f),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":Qa,children:[e.jsx(v.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),$r.length>0&&e.jsxs("button",{type:"button",onClick:()=>pr(f=>!f),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":Ra,children:[e.jsx(v.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${be?"var(--danger)":o?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:It,value:Rr,rows:3,onChange:f=>Wt(f.target.value,f.target),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),st(Rr)),f.key==="Escape"&&or(!1)},placeholder:ue,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"}}),E.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:E.map(f=>e.jsx("button",{type:"button",onMouseDown:K=>{var k;K.preventDefault(),Wt(f),(k=It.current)==null||k.focus()},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:f},f))})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 text-xs",style:{color:be?"var(--danger)":"var(--text-muted)"},children:be??(o?`${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(f=>e.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:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[f.label,":"]}),e.jsx("span",{className:"truncate",children:f.value})]},f.key))]}),Ra&&$r.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx(v.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Lr([]),pr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(v.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),$r.map(f=>e.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[e.jsx("button",{type:"button",onClick:()=>st(f),className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:f})}),e.jsx("button",{type:"button",onClick:()=>Lr(K=>K.filter(k=>k!==f)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"})})]},f))]}),Qa&&w.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:w.map(f=>e.jsxs("button",{type:"button",onClick:()=>{var K;Wt(f.bql),fr(!1),(K=It.current)==null||K.focus()},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:f.bql}),f.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:f.description})]},f.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[o&&e.jsxs("button",{type:"button",onClick:bn,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:[e.jsx(v.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>st(Rr),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:[e.jsx(v.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Se&&e.jsx("button",{ref:tt,type:"button","aria-haspopup":"menu","aria-expanded":Tr,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var K;const f=(K=tt.current)==null?void 0:K.getBoundingClientRect();f&&Ts({top:f.bottom+4,right:window.innerWidth-f.right}),rt(k=>!k)},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)] ${Tr?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiArrowDownTray,{className:"h-4 w-4"})}),D&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&lr==="visibility","aria-label":oe,title:oe,onClick:f=>pn(f,"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)] ${Re&&lr==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(v.HiCog6Tooth,{className:"h-4 w-4"})})]})},Cn=()=>{if(!Qs)return null;const o=Nl(De,Kt);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${i?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:xr===0?"0 filas":`${Rs}–${ei} de ${xr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(rr,{value:String(Ue),onChange:d=>ri(Number(d)),options:Q.map(d=>({value:String(d),label:String(d)})),placeholder:"Filas",searchable:!1,disabled:n,height:W,padding:J,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:re}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||De<=1,onClick:()=>Gt(De-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:e.jsx(v.HiChevronLeft,{className:"h-3.5 w-3.5"})}),o.map((d,E)=>d==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${E}`):e.jsx("button",{disabled:n,onClick:()=>Gt(d),onMouseEnter:f=>{f.currentTarget.disabled||d===De||(f.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",f.currentTarget.style.color="var(--primary)")},onMouseLeave:f=>{f.currentTarget.style.background=d===De?"var(--primary)":"transparent",f.currentTarget.style.color=d===De?"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===De?"var(--primary)":"transparent",color:d===De?"var(--primary-fg)":"var(--text-muted)"},children:d},d)),e.jsx("button",{disabled:n||De>=Kt,onClick:()=>Gt(De+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:e.jsx(v.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},En=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>e.jsx("div",{role:"cell",className:i?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key))]},d))})]})})]}),Xt="min-w-0 max-w-full overflow-hidden";return _&&!$e&&t.length===0||!n&&t.length===0&&!Ft?En():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((o,d)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${xe}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},"select-cell"),qe.map((E,f)=>{const K=le&&!Pt&&f===0;return e.jsx("div",{role:"cell","data-dt-column-key":E.key,className:i?"px-2 py-1.5":"px-3 py-2",style:K?{position:"sticky",left:Vt,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${an(d,f)}%`,minWidth:32}})},E.key)})]},d))})]})})}),Cn()]}):!n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()})})}),e.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:xe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.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:c??e.jsx(v.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:u}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ut},children:[pt(),ht(),vt(),e.jsx("div",{ref:er,className:Xt,children:e.jsx(Qt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ln,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Br,minWidth:bt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:vn.map((o,d)=>{const E=a(o),f=Nn(X==null?void 0:X(o)),K=d>0?Nn(X==null?void 0:X(vn[d-1])):null,k=f&&f.key!==(K==null?void 0:K.key),ce=Ve&&N.has(E),j=gr?(h==null?void 0:h(o))??!0:!1,Ee=j&&hn.has(E),Ne=!!p||C&&j,he=ce&&ee?"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 e.jsxs(l.Fragment,{children:[k&&e.jsx("div",{role:"row",className:`grid ${f.className??""}`,style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:f.label}),f.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:f.description})]})})})}),e.jsxs("div",{role:"row",onClick:Ne?ge=>{const ve=ge.target;if(!(ve!=null&&ve.closest('[data-dt-disable-row-click="true"]'))){if(C&&j){gn(E);return}p==null||p(o)}}:void 0,className:`grid transition-colors ${Ne?"cursor-pointer":""} ${z?z(o):""}`,style:{gridTemplateColumns:wr,"--dt-row-bg":he,"--dt-sticky-bg":he,background:"var(--dt-row-bg)",borderBottom:`1px solid ${xe}`},onMouseEnter:ge=>{ce||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",ti))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",he),ge.currentTarget.style.setProperty("--dt-sticky-bg",he)},children:[gr&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},"data-dt-disable-row-click":"true",children:j&&e.jsx("button",{type:"button","aria-label":Ee?"Contraer fila":"Desplegar fila","aria-expanded":Ee,onClick:ge=>{ge.stopPropagation(),gn(E)},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:Ee?e.jsx(v.HiChevronDown,{className:"h-4 w-4"}):e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})}),Ve&&e.jsx("div",{role:"cell",className:`${i?"px-2 py-1.5":"px-3 py-2"} w-10`,style:le?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`},onClick:ge=>{ge.stopPropagation(),S(E)},children:e.jsx(Fr,{size:"sm",checked:ce,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ge=>ge.stopPropagation(),onChange:()=>S(E)})}),qe.map((ge,ve)=>{const He=le&&!Pt&&ve===0,ye=ar(ge);return e.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||ye?"true":void 0,className:`${ye?"px-2 py-1.5 text-center":`${i?"px-2 py-1.5":"px-3 py-2"} ${xn(ge.align)}`} ${ml} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...He?{position:"sticky",left:Vt,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xe}`,borderRight:`1px solid ${xe}`}:{borderBottom:`1px solid ${xe}`,borderRight:`1px solid ${xe}`}},children:e.jsx(pa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(o)})})},ge.key)})]}),Ee&&m&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:i?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${xe}`},children:m(o)})})]},E)})})]})})}),Cn()]})}const Cl={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 El(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const a=Cl[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const Ml=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function $l({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[c,u]=l.useState(r),b=l.useRef(null),p=(a==null?void 0:a.preset)==="date",m=p?"date":t==="number"?"number":"text";return l.useEffect(()=>{var h,x;(h=b.current)==null||h.focus(),p||(x=b.current)==null||x.select()},[p]),e.jsx("input",{ref:b,type:m,value:c,maxLength:a==null?void 0:a.maxLength,onChange:h=>u(h.target.value),onBlur:()=>n(c),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),n(c)),h.key==="Escape"&&(h.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!Ml.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Ll({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const c=l.useRef(null),[u,b]=l.useState(r);return l.useEffect(()=>{if(a)return;const p=setTimeout(()=>{var m,h;(h=(m=c.current)==null?void 0:m.querySelector("button"))==null||h.click()},0);return()=>clearTimeout(p)},[a]),e.jsx("div",{ref:c,className:"w-full",tabIndex:-1,onKeyDown:p=>{p.key==="Escape"&&(p.stopPropagation(),s()),p.key==="Enter"&&(p.preventDefault(),p.stopPropagation(),n(u))},children:e.jsx(rr,{value:u,onChange:p=>{b(p),setTimeout(()=>{var m;return(m=c.current)==null?void 0:m.focus({preventScroll:!0})},0)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Tl={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ha={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Al({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...c}){const[u,b]=l.useState(t),p=l.useRef(null);l.useEffect(()=>{p.current||b(t)},[t]);const[m,h]=l.useState(null);p.current=m;const[x,g]=l.useState(null),$=l.useRef(null);$.current=x;const[C,N]=l.useState({}),[S,B]=l.useState({}),[ee,z]=l.useState({}),X=l.useRef(new Set),L=l.useRef(null);l.useEffect(()=>{var y;const i=document.activeElement;(!i||i===document.body)&&((y=L.current)==null||y.focus({preventScroll:!0}))},[]);const U=r.map(i=>{var y,M,O;return`${i.key}:${((O=(M=(y=i.editable)==null?void 0:y.select)==null?void 0:M.options)==null?void 0:O.length)??-1}`}).join("|");l.useEffect(()=>{r.forEach(i=>{var O,D;const y=(D=(O=i.editable)==null?void 0:O.select)==null?void 0:D.options;if(!y)return;const M=S[i.key];(!X.current.has(i.key)||(M==null?void 0:M.length)===0&&y.length>0)&&(X.current.add(i.key),B(ae=>({...ae,[i.key]:y})))})},[U]);const Q=l.useCallback(async(i,y)=>{if(X.current.has(i))return;X.current.add(i);const{url:M,fetchOptions:O}=y.select??{};if(!(!M&&!O)){z(D=>({...D,[i]:!0}));try{let D=[];if(O)D=await O();else if(M){const ae=await fetch(M);if(!ae.ok)throw new Error("fetch failed");D=await ae.json()}B(ae=>({...ae,[i]:D}))}catch{B(D=>({...D,[i]:[]}))}finally{z(D=>({...D,[i]:!1}))}}},[]),re=l.useRef(u);re.current=u;const W=l.useRef(n);W.current=n;const J=l.useRef(a);J.current=a;const R=l.useRef(r);R.current=r;const T=l.useRef(s);T.current=s,l.useEffect(()=>{if(r.length>0&&t.length>0){const i=r.find(y=>y.selectable!==!1);i&&g({rowId:a(t[0]),colKey:i.key})}},[]),l.useEffect(()=>{if(!x)return;const i=L.current;if(!i)return;const y=i.querySelector(`[data-cell-id="${x.rowId}:${x.colKey}"]`);if(!y)return;const M=i.querySelector('[role="rowgroup"]');y.style.scrollMarginTop=`${(M==null?void 0:M.offsetHeight)??0}px`;const O=i.querySelector('[role="row"]');let D=0;O&&O.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ae=>{ae.style.position==="sticky"&&ae.style.left!==""&&(D=Math.max(D,parseFloat(ae.style.left)+ae.offsetWidth))}),y.style.scrollMarginLeft=`${D}px`,y.scrollIntoView({block:"nearest",inline:"nearest"})},[x]);const P=l.useCallback(i=>{var D;const y=R.current,M=new Set,O=[];(D=L.current)==null||D.querySelectorAll("[data-cell-id]").forEach(ae=>{const ie=ae.dataset.cellId.split(":")[0];M.has(ie)||(M.add(ie),O.push(ie))}),g(ae=>{if(!ae)return ae;const ie=y.findIndex(F=>F.key===ae.colKey),pe=O.indexOf(ae.rowId);let A=ie,oe=pe;if(i==="up")oe=Math.max(0,pe-1);else if(i==="down")oe=Math.min(O.length-1,pe+1);else if(i==="left"){let F=ie-1;for(;F>=0&&y[F].selectable===!1;)F--;F>=0&&(A=F)}else if(i==="right"){let F=ie+1;for(;F<y.length&&y[F].selectable===!1;)F++;F<y.length&&(A=F)}return A===ie&&oe===pe?ae:{rowId:O[oe],colKey:y[A].key}})},[]),V=l.useCallback((i=!0)=>{const y=p.current;h(null),y&&g(y),i&&setTimeout(()=>{var M;return(M=L.current)==null?void 0:M.focus({preventScroll:!0})},0)},[]),_=l.useCallback(async(i,y,M)=>{var se;const O=R.current.find(w=>w.key===y);if(!(O!=null&&O.editable))return;const{field:D,type:ae,mask:ie,validate:pe}=O.editable,A=ae==="number"?M===""?null:Number(M):M;if(ie){const w=El(M,ie);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}if(pe){const w=pe(A);if(w){N(I=>({...I,[`${i}:${y}`]:w}));return}}const oe=J.current,F=re.current.find(w=>oe(w)===i);if(!F)return;const H=F[D];h(null),N(w=>{const I={...w};return delete I[`${i}:${y}`],I});const Z=re.current,G=Z.findIndex(w=>oe(w)===i),te=Z[Math.min(Z.length-1,G+1)];if(g({rowId:oe(te),colKey:y}),setTimeout(()=>{var I,de;const w=document.activeElement;(!w||w===document.body||(I=L.current)!=null&&I.contains(w))&&((de=L.current)==null||de.focus({preventScroll:!0}))},0),String(H??"")===String(A??""))return;const ue={...F,[D]:A};b(w=>w.map(I=>oe(I)===i?ue:I));try{await((se=W.current)==null?void 0:se.call(W,{row:F,rowId:i,field:D,oldValue:H,newValue:A}))}catch{b(w=>w.map(I=>oe(I)===i?F:I)),N(w=>({...w,[`${i}:${y}`]:"Error al guardar. Intenta de nuevo."}))}},[]),le=l.useCallback(i=>{if(p.current)return;const y=$.current;if(!(!y||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(i.key)))switch(i.preventDefault(),i.key){case"ArrowUp":P("up");break;case"ArrowDown":P("down");break;case"ArrowLeft":P("left");break;case"ArrowRight":P("right");break;case"Tab":P(i.shiftKey?"left":"right");break;case"Enter":{const O=R.current.find(D=>D.key===y.colKey);O!=null&&O.editable&&!T.current?(h(y),O.editable.type==="select"&&!X.current.has(y.colKey)&&Q(y.colKey,O.editable)):P("down");break}}},[P,Q]),q=l.useMemo(()=>r.map(i=>{if(!i.editable||s){const{editable:M,selectable:O,...D}=i;if(i.selectable===!1)return{...D,disableRowClick:!0};const ae=D.cell;return{...D,className:`relative ${D.className??""}`.trim(),disableRowClick:!0,cell:ie=>{const pe=a(ie),A=(x==null?void 0:x.rowId)===pe&&(x==null?void 0:x.colKey)===i.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${pe}:${i.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var oe;g({rowId:pe,colKey:i.key}),(oe=L.current)==null||oe.focus({preventScroll:!0})}}),A&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:ae(ie)})]})}}}const y=i.editable;return{...i,className:`relative ${i.className??""}`.trim(),disableRowClick:!0,cell:M=>{const O=a(M),D=i.key,ae=(m==null?void 0:m.rowId)===O&&(m==null?void 0:m.colKey)===D,ie=(x==null?void 0:x.rowId)===O&&(x==null?void 0:x.colKey)===D,pe=C[`${O}:${D}`],A=M[y.field],oe=String(A??""),F=()=>{var Z;g({rowId:O,colKey:D}),h({rowId:O,colKey:D}),(Z=L.current)==null||Z.focus({preventScroll:!0}),y.type==="select"&&!X.current.has(D)&&Q(D,y)};if(ae){const Z=y.type==="select"?e.jsx(Ll,{initialValue:oe,options:S[D]??[],loading:ee[D]??!1,onCommit:G=>_(O,D,G),onCancel:V}):e.jsx($l,{initialValue:oe,type:y.type??"text",mask:y.mask,onCommit:G=>_(O,D,G),onCancel:V});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Tl,onClick:G=>G.stopPropagation(),children:Z})}const H=i.cell(M);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${O}:${D}`,className:"peer absolute inset-0 z-10 cursor-pointer",onClick:F}),ie&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:pe?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(v.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:pe})]}):e.jsx("span",{className:"truncate",children:H})}),e.jsx(v.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"})]})}}}),[r,s,m,x,C,S,ee,a,_,V,Q]);return e.jsx("div",{ref:L,tabIndex:0,onKeyDown:le,onBlur:i=>{var y;(y=L.current)!=null&&y.contains(i.relatedTarget)||setTimeout(()=>{var O,D;const M=document.activeElement;M&&((O=M.closest)!=null&&O.call(M,"[data-bonsaif-select-dropdown]"))||(D=L.current)!=null&&D.contains(M)||V(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(ma,{...c,columns:q,data:u,getRowId:a})})}function kr(r){return r?new Date(`${r}T12:00:00`):void 0}function va(r){return r.toISOString().slice(0,10)}function Hl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:u,formatters:b}=Rt.useDayPicker(),p=!!a&&t===0,m=!!n&&t===c.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:b.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":u.labelPrevious(a),onClick:()=>a&&s(a),disabled:!p,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(v.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":u.labelNext(n),onClick:()=>n&&s(n),disabled:!m,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:m?1:.45,cursor:m?"pointer":"not-allowed"},children:e.jsx(v.HiChevronRight,{size:16})})]})}function Dl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Bl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:u=!0,startLabel:b="Inicio",endLabel:p="Regreso"}){const m={from:kr(r),to:kr(t)},h=kr(n),[x,g]=l.useState(kr(s||r));return l.useEffect(()=>{g(kr(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(Rt.DayPicker,{mode:"range",selected:m,month:x,onMonthChange:g,onSelect:$=>{const C=$!=null&&$.from?va($.from):r,N=$!=null&&$.to?va($.to):"";a({startDate:C,endDate:N})},numberOfMonths:c,hideNavigation:!0,disabled:h?{before:h}:void 0,showOutsideDays:!1,components:{MonthCaption:Hl},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:$=>Dl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($)),formatWeekdayName:$=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format($)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),u&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[b,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[p,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Il="bonsaif-ui:hide-tooltips";function ga(){window.dispatchEvent(new CustomEvent(Il))}function Ol(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Fl({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:u="",onOpenChange:b}){const[p,m]=l.useState(!1),[h,x]=l.useState(!1),[g,$]=l.useState({}),C=l.useRef(null),N=l.useRef(null),S=l.useCallback(L=>{m(L),b==null||b(L)},[b]),B=l.useCallback(()=>{const L=C.current;if(!L)return;const U=L.getBoundingClientRect(),Q=typeof n=="number"?n:U.width,re=typeof n=="number"?n:Math.max(U.width,180),W=a==="end"?Math.max(8,U.right-re):Math.min(U.left,window.innerWidth-re-8),J=window.innerHeight-U.bottom,R=J<240&&U.top>J?void 0:U.bottom+6,T=R===void 0?window.innerHeight-U.top+6:void 0;$({position:"fixed",zIndex:9999,left:W,top:R,bottom:T,width:Ol(typeof n=="number"?Q:n)})},[a,n]);l.useEffect(()=>x(!0),[]),l.useEffect(()=>{if(!p)return;B();const L=Q=>{var W,J;const re=Q.target;!((W=C.current)!=null&&W.contains(re))&&!((J=N.current)!=null&&J.contains(re))&&S(!1)},U=Q=>{Q.key==="Escape"&&S(!1)};return document.addEventListener("mousedown",L),window.addEventListener("keydown",U),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0),()=>{document.removeEventListener("mousedown",L),window.removeEventListener("keydown",U),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}},[p,S,B]);const ee=L=>{s||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),S(!p))},z=l.isValidElement(r)?l.cloneElement(r,{onClick:()=>{s||(ga(),S(!p))}}):r,X=p?e.jsx("div",{ref:N,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${u}`,style:g,children:t.map(L=>e.jsxs("div",{children:[L.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:L.disabled,onClick:()=>{var U;L.disabled||(ga(),(U=L.onSelect)==null||U.call(L),S(!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:L.danger?"var(--danger)":"var(--text-main)"},children:[L.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:L.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:L.label}),L.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:L.description})]})]})]},L.id))}):null;return e.jsxs("span",{ref:C,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":p,onKeyDown:ee,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[z,h&&X?je.createPortal(X,document.body):null]})}const Pl=180,xa="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function zl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:u,loading:b=!1,confirmDisabled:p=!1,headerActions:m,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:x=440,hasUnsavedChanges:g=!1,unsavedChangesTitle:$="Descartar cambios",unsavedChangesDescription:C="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:N="Descartar",unsavedChangesCancelLabel:S="Seguir editando",onDiscardChanges:B,disabled:ee=!1,children:z}){const[X,L]=l.useState(!1),[U,Q]=l.useState(!1),[re,W]=l.useState(!1),J=l.useCallback(()=>{Q(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),R=l.useCallback(()=>{W(!1),window.setTimeout(()=>Q(!1),Pl)},[]),T=l.useCallback(()=>{if(g){J();return}t()},[g,t,J]),P=l.useCallback(()=>{W(!1),Q(!1),B==null||B(),t()},[t,B]);return l.useEffect(()=>{L(!0)},[]),l.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(W(!1),Q(!1)),()=>{document.body.style.overflow=""}),[r]),l.useEffect(()=>{if(!r)return;const V=_=>{if(_.key==="Escape"){if(U){R();return}T()}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[R,U,r,T]),X?je.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:`absolute inset-0 ${xa}`,onClick:T}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${x}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Te,{variant:"icon",onClick:T,title:"Cerrar",children:e.jsx(v.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(m||u)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m,u&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{variant:"secondary",size:"sm",onClick:T,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Te,{variant:"primary",size:"sm",icon:e.jsx($n.FiSave,{className:"w-4 h-4"}),onClick:u,loading:b,disabled:p,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:h,children:z})]}),ee&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),U&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":$,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${xa} transition-opacity duration-200 ease-out ${re?"opacity-100":"opacity-0"}`,onClick:R}),e.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 ${re?"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:[e.jsx(Te,{variant:"icon",onClick:R,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":S,children:e.jsx(v.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:e.jsx(v.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:$}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:C}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:R,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:S}),e.jsx(Te,{variant:"secondary",onClick:P,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:N})]})]})]})]}),document.body):null}const jl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,_l=/^\+?[0-9\s().-]+$/,Wl=7,ql=15;function _e(r){return r==null||String(r).trim()===""}function ya(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Ct(r){return _e(r)?!1:jl.test(String(r))}function Et(r){if(_e(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return _l.test(t)&&a.length>=Wl&&a.length<=ql}function Ul(r="Este campo es requerido."){return t=>_e(t)?r:void 0}function Vl(r="Ingresa un correo valido."){return t=>_e(t)||Ct(t)?void 0:r}function Kl(r="Ingresa un telefono valido."){return t=>_e(t)||Et(t)?void 0:r}function Gl(r,t){return a=>_e(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function Yl(r,t){return a=>_e(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function Xl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Zl(r,t){return a=>{if(_e(a))return;const n=ya(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function Jl(r,t="El formato no es valido."){return a=>_e(a)||r.test(String(a))?void 0:t}function Ql(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const c=Array.isArray(s)?s:[s];for(const u of c){const b=u(r[n],r);if(b){a[n]=b;break}}}return{valid:Object.keys(a).length===0,errors:a}}var wa={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Na=l.createContext&&l.createContext(wa),Rl=["attr","size","title"];function eo(r,t){if(r==null)return{};var a,n,s=ro(r,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(n=0;n<c.length;n++)a=c[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function ro(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Vr(){return Vr=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Vr.apply(null,arguments)}function ka(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Kr(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?ka(Object(a),!0).forEach(function(n){to(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):ka(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function to(r,t,a){return(t=ao(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function ao(r){var t=no(r,"string");return typeof t=="symbol"?t:t+""}function no(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Sa(r){return r&&r.map((t,a)=>l.createElement(t.tag,Kr({key:a},t.attr),Sa(t.child)))}function Mt(r){return t=>l.createElement(lo,Vr({attr:Kr({},r.attr)},t),Sa(r.child))}function lo(r){var t=a=>{var{attr:n,size:s,title:c}=r,u=eo(r,Rl),b=s||a.size||"1em",p;return a.className&&(p=a.className),r.className&&(p=(p?p+" ":"")+r.className),l.createElement("svg",Vr({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,u,{className:p,style:Kr(Kr({color:r.color||a.color},a.style),r.style),height:b,width:b,xmlns:"http://www.w3.org/2000/svg"}),c&&l.createElement("title",null,c),r.children)};return Na!==void 0?l.createElement(Na.Consumer,null,a=>t(a)):t(wa)}function Ca(r){return Mt({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:[]}]})(r)}function oo(r){return Mt({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:[]}]})(r)}function so(r){return Mt({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:[]}]})(r)}function Gr({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function $t({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:c="Error de validacion",labelAction:u,floatingLabel:b=!1,showPasswordToggle:p=!0,nativeValidation:m=!1,className:h="",required:x,...g}){const[$,C]=l.useState(()=>!!g.autoFocus),[N,S]=l.useState(!1),B=g.type==="password"&&p,ee=B&&N?"text":g.type,z=!!n,X=z&&s!=="tooltip",L=z&&s!=="inline",U=m?x:void 0,Q=z?"border-[var(--danger)] focus:border-[var(--danger)]":"",re=L?B?"pr-20":"pr-10":B?"pr-10":"",W=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,J=$||W,R={top:J?7:12,color:$?"var(--primary)":"var(--text-muted)",fontSize:J?10:13,fontWeight:J?600:400,textTransform:J?"uppercase":"none"},T=le=>{var q;C(!0),(q=g.onFocus)==null||q.call(g,le)},P=le=>{var q;C(!1),(q=g.onBlur)==null||q.call(g,le)},V=B?e.jsxs("button",{type:"button","aria-label":N?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":N,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>S(le=>!le),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${N?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(oo,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${N?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(so,{className:"h-[18px] w-[18px]"})})]}):null,_=L?e.jsx(dr,{as:"span",content:n,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)] ${B?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":c,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return b?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,placeholder:" ","aria-invalid":z||g["aria-invalid"],"data-has-value":W?"true":void 0,className:`h-11 w-full pt-5 ${re} ${Q} ${h}`,onFocus:T,onBlur:P}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:R,children:[r,x&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),u&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:J?7:12},children:u}),_,V]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),x&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u&&e.jsx("span",{className:"ml-auto normal-case",children:u})]}),B?e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,type:ee,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`,onFocus:T,onBlur:P}),_,V]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...g,required:U,"aria-invalid":z||g["aria-invalid"],className:`w-full ${re} ${Q} ${h}`}),_]}),X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function Ea(r){return r==null?"":String(r)}function io({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,...m}){const[h,x]=l.useState(()=>Ea(b)),g=u!==void 0?Ea(u):h,$=a&&g.length>0&&!Ct(g)?n:void 0,C=N=>{u===void 0&&x(N.currentTarget.value),p==null||p(N)};return e.jsx($t,{...m,value:u,defaultValue:b,type:"text",inputMode:t,autoComplete:r,error:c??$,errorDisplay:s,onChange:C})}const co={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function uo({title:r="Sin resultados",description:t,icon:a=e.jsx(v.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:u=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${co[c]} ${u}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.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:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}const bo={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function fo(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Ma(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function po(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function mo({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:c=[],onFilesChange:u,onRejectedFiles:b,multiple:p=!1,maxFiles:m,appendFiles:h=!1,showFileList:x=!0,clearable:g=!0,browseLabel:$="Buscar archivos",dropLabel:C="Suelta los archivos aqui",emptyLabel:N="Arrastra y suelta archivos",emptyDescription:S="o haz click para buscarlos en tu equipo",selectedLabel:B="Archivos seleccionados",size:ee="md",containerClassName:z="",dropzoneClassName:X="",fileListClassName:L="",className:U="",id:Q,accept:re,disabled:W,required:J,...R}){const T=l.useId(),P=Q??T,V=l.useRef(null),[_,le]=l.useState(!1),[q,i]=l.useState(c),y=s??q,M=!!a,O=g&&y.length>0&&!W,D=(te,ue)=>{s===void 0&&i(te),u==null||u(te,ue)},ae=(te,ue)=>{const se=te.filter(be=>Ma(be,re)),w=te.filter(be=>!Ma(be,re)),I=h?[...y,...se]:se,de=po(I,p,m);w.length>0&&(b==null||b(w)),D(de,ue)},ie=()=>{var te;W||(te=V.current)==null||te.click()},pe=te=>{ae(Array.from(te.target.files??[]),te),te.target.value=""},A=te=>{te.preventDefault(),W||le(!0)},oe=te=>{te.currentTarget.contains(te.relatedTarget)||le(!1)},F=te=>{te.preventDefault(),le(!1),!W&&ae(Array.from(te.dataTransfer.files),te)},H=te=>{te.key!=="Enter"&&te.key!==" "||(te.preventDefault(),ie())},Z=te=>{D(y.filter((ue,se)=>se!==te))},G=()=>{D([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,children:[(r||n)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),J&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...R,ref:V,id:P,type:"file",accept:re,multiple:p,disabled:W,required:J&&y.length===0,"aria-invalid":M||R["aria-invalid"],className:"sr-only",onChange:pe}),e.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":P,"aria-disabled":W||void 0,"aria-invalid":M||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)] ${bo[ee]} ${_?"border-[var(--primary)] bg-[var(--bg-input)]":M?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${X} ${U}`,onClick:ie,onDragOver:A,onDragLeave:oe,onDrop:F,onKeyDown:H,children:[e.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:e.jsx(v.HiArrowUpTray,{className:"h-5 w-5"})}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:_?C:N}),S&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:S})]}),$&&e.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:$})]}),x&&y.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:B}),O&&e.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:G,children:e.jsx(v.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:y.map((te,ue)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.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:e.jsx(v.HiDocument,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:te.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:fo(te.size)})]}),!W&&e.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 ${te.name}`,onClick:()=>Z(ue),children:e.jsx(v.HiXMark,{className:"h-4 w-4"})})]},`${te.name}-${te.lastModified}-${ue}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const ho=[{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 vo({fields:r,title:t="Layout",fieldTypes:a=ho,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:c="Nuevo campo",addFieldLabel:u="Anadir",loading:b=!1,onSave:p,onChange:m}){const[h,x]=l.useState(()=>r.map(z=>({key:!1,type:"",...z}))),[g,$]=l.useState(""),[C,N]=l.useState(""),S=l.useCallback((z,X)=>{x(L=>{const U=L.map((Q,re)=>re===z?{...Q,...X}:Q);return m==null||m(U),U})},[m]),B=l.useCallback(()=>{p==null||p(h)},[h,p]),ee=l.useCallback(()=>{var U;const z=g.trim();if(!z){N("Ingresa un nombre de campo.");return}if(h.some(Q=>Q.name.toLowerCase()===z.toLowerCase())){N("Ese campo ya existe en el arreglo.");return}const L={name:z,key:!1,type:((U=a[0])==null?void 0:U.value)??""};x(Q=>{const re=[...Q,L];return m==null||m(re),re}),$(""),N("")},[a,h,g,m]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.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:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[h.map((z,X)=>e.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:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:z.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Fr,{size:"sm",checked:z.key??!1,onChange:L=>S(X,{key:L.target.checked}),"aria-label":`${z.name} es clave`})}),e.jsx(rr,{value:z.type??"",onChange:L=>S(X,{type:L}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${z.name}`})]},z.name)),h.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:g,onChange:z=>{$(z.currentTarget.value),C&&N("")},onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),ee())},placeholder:c,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"}),e.jsx(Te,{variant:"secondary",onClick:ee,height:36,padding:"0 12px",children:u})]}),C&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:C})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Te,{variant:"primary",onClick:B,disabled:b,loading:b,children:n})})]})})]})}function $a({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:u="",contentClassName:b=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${u}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),c&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${b}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function La(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function go(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function xo({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:u,height:b=40,padding:p="6px 10px",searchable:m=!0,minOptionsForSearch:h=6,maxVisibleValues:x=2,truncateSelectedValues:g=!0,emptyText:$="Sin resultados",clearLabel:C="Limpiar seleccion"}){const[N,S]=l.useState(!1),[B,ee]=l.useState(""),[z,X]=l.useState(0),[L,U]=l.useState(!1),[Q,re]=l.useState({}),W=l.useRef(null),J=l.useRef(null),R=l.useRef(null),T=l.useRef(null),P=m&&a.length>=h,V=l.useMemo(()=>new Set(r),[r]),_=l.useMemo(()=>a.filter(A=>V.has(A.value)),[a,V]),le=x==="all"?_.length:x,q=_.slice(0,le),i=Math.max(0,_.length-q.length),y=P&&B.trim()?a.filter(A=>{var oe;return A.label.toLowerCase().includes(B.toLowerCase())||((oe=A.sublabel)==null?void 0:oe.toLowerCase().includes(B.toLowerCase()))}):a,M=l.useCallback(()=>{const A=W.current;if(!A)return;const oe=A.getBoundingClientRect(),F=P?304:244,H=window.innerHeight-oe.bottom,Z=H<F&&oe.top>H;re({position:"fixed",left:oe.left,top:Z?void 0:oe.bottom+4,bottom:Z?window.innerHeight-oe.top+4:void 0,width:oe.width,zIndex:9999})},[P]),O=l.useCallback(A=>{go(r,A)||t(A)},[t,r]),D=l.useCallback(A=>{const oe=a.find(H=>H.value===A);if(oe!=null&&oe.disabled)return;const F=V.has(A)?r.filter(H=>H!==A):[...r,A];O(F)},[O,a,r,V]),ae=l.useCallback(()=>O([]),[O]);l.useEffect(()=>U(!0),[]),l.useEffect(()=>{if(!N)return;function A(oe){var H,Z;const F=oe.target;!((H=W.current)!=null&&H.contains(F))&&!((Z=J.current)!=null&&Z.contains(F))&&(S(!1),ee(""))}return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[N]),l.useEffect(()=>{N&&(X(0),M(),P&&setTimeout(()=>{var A;return(A=R.current)==null?void 0:A.focus()},0))},[N,P,M]),l.useEffect(()=>{if(N)return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[N,M]),l.useEffect(()=>{if(z<0||!T.current)return;const A=T.current.children[z];A==null||A.scrollIntoView({block:"nearest"})},[z]);function ie(A){if(!N){(A.key==="Enter"||A.key===" "||A.key==="ArrowDown")&&(A.preventDefault(),S(!0));return}A.key==="Escape"&&(A.preventDefault(),S(!1),ee("")),A.key==="ArrowDown"&&(A.preventDefault(),X(oe=>Math.min(oe+1,y.length-1))),A.key==="ArrowUp"&&(A.preventDefault(),X(oe=>Math.max(oe-1,0))),A.key==="Enter"&&y[z]&&(A.preventDefault(),D(y[z].value)),A.key==="Backspace"&&!B&&r.length&&(A.preventDefault(),O(r.slice(0,-1)))}const pe=e.jsxs("div",{ref:J,className:"overflow-hidden rounded-xl shadow-xl",style:{...Q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[P&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(v.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:R,value:B,onChange:A=>{ee(A.target.value),X(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),B&&e.jsx("button",{type:"button",onMouseDown:A=>{A.preventDefault(),ee("")},children:e.jsx(v.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),_.length>0&&e.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:[e.jsxs("span",{children:[_.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:A=>{A.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:C})]}),e.jsxs("ul",{ref:T,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:P?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[y.map((A,oe)=>{const F=oe===z,H=V.has(A.value);return e.jsxs("li",{role:"option","aria-selected":H,onMouseDown:Z=>{Z.preventDefault(),D(A.value)},onMouseEnter:()=>!A.disabled&&X(oe),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:F?"var(--bg-hover)":H?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:A.disabled?"var(--text-muted)":"var(--text-main)",cursor:A.disabled?"not-allowed":"pointer",opacity:A.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:H?"var(--primary)":"var(--border)",background:H?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:H&&e.jsx(v.HiCheck,{className:"h-3 w-3"})}),A.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:A.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:A.label}),A.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:A.sublabel})]}),A.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:A.badge})]},A.value)}),y.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:$})]})]});return e.jsxs("div",{ref:W,className:`relative ${c||"w-full"}`,style:u,onKeyDown:ie,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&S(A=>!A),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:La(b),padding:La(p),background:"var(--bg-input)",color:_.length?"var(--text-main)":"var(--text-muted)",border:N?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":N,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:q.length?e.jsxs(e.Fragment,{children:[q.map(A=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${g?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[A.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:A.color}}),e.jsx("span",{className:g?"truncate":"break-words",children:A.label})]},A.value)),i>0&&e.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",i]})]}):e.jsx("span",{className:"truncate",children:n})}),_.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":C,onMouseDown:A=>{A.preventDefault(),A.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(v.HiXMark,{className:"h-3 w-3"})}):e.jsx(v.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:N?"rotate(180deg)":"rotate(0deg)"}})]}),N&&L&&je.createPortal(pe,document.body)]})}function yo({inputMode:r="decimal",...t}){return e.jsx($t,{...t,type:"number",inputMode:r})}function wo(r,t,a){const n=[],s=Math.max(2,r-a),c=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let u=s;u<=c;u+=1)n.push(u);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function No({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const u=Math.max(1,t),b=Math.min(Math.max(1,r),u),p=wo(b,u,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${c}`,children:[e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||b<=1,onClick:()=>a(b-1),children:e.jsx(v.HiChevronLeft,{className:"h-4 w-4"})}),p.map((m,h)=>m==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${h}`):e.jsx("button",{type:"button","aria-current":m===b?"page":void 0,disabled:n,onClick:()=>a(m),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:m===b?"var(--primary)":"var(--border)",background:m===b?"var(--primary)":"var(--bg-card)",color:m===b?"var(--primary-fg)":"var(--text-secondary)"},children:m},m)),e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||b>=u,onClick:()=>a(b+1),children:e.jsx(v.HiChevronRight,{className:"h-4 w-4"})})]})}const Ta=[{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 Aa(r){return r==null?"":String(r)}function Yr(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function ko(r){return typeof r=="number"?`${r}px`:r}function So({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:c,value:u,defaultValue:b,onChange:p,countryCode:m,defaultCountryCode:h="+1",onCountryCodeChange:x,allowedCountryCodes:g,countryCodeOptions:$,countryCodePlaceholder:C="Codigo",countryCodeClassName:N="",countryCodeWidth:S=84,onPhoneValueChange:B,label:ee,containerClassName:z="",helperText:X,labelAction:L,className:U="",required:Q,disabled:re,floatingLabel:W,showPasswordToggle:J,nativeValidation:R,errorTooltipLabel:T="Error de validacion",...P}){var te;const[V,_]=l.useState(()=>Aa(b)),[le,q]=l.useState(()=>Yr(h)),i=l.useMemo(()=>{const ue=$??Ta,se=g==null?void 0:g.map(Yr);return se!=null&&se.length?ue.filter(w=>se.includes(w.value)):ue},[g,$]),y=((te=i[0])==null?void 0:te.value)??"+1",M=i.some(ue=>ue.value===Yr(m??le))?Yr(m??le):y,O=u!==void 0?Aa(u):V,D=`${M} ${O}`.trim(),ae=a&&O.length>0&&!Et(D)?n:void 0,ie=c??ae,pe=!!ie,A=pe&&s!=="tooltip",oe=pe&&s!=="inline",F=pe?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",H=ue=>{const se=ue.currentTarget.value;u===void 0&&_(se),B==null||B(se,{countryCode:M,nationalNumber:se,fullNumber:`${M} ${se}`.trim()}),p==null||p(ue)},Z=ue=>{m===void 0&&q(ue),x==null||x(ue),B==null||B(O,{countryCode:ue,nationalNumber:O,fullNumber:`${ue} ${O}`.trim()})},G=oe?e.jsx(dr,{as:"span",content:ie,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:e.jsx("span",{tabIndex:0,role:"img","aria-label":T,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Ca,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${z}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:ee}),Q&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L&&e.jsx("span",{className:"ml-auto normal-case",children:L})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${F}`,children:[e.jsx(rr,{value:M,onChange:Z,options:i,placeholder:C,disabled:re,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${N}`,style:{width:ko(S)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...P,value:u,defaultValue:b,type:"tel",inputMode:t,autoComplete:r,disabled:re,required:void 0,"aria-label":P["aria-label"]??(typeof ee=="string"?ee:void 0),"aria-invalid":pe||P["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 ${oe?"pr-10":""} ${U}`,onChange:H}),G]})]}),A?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:ie}):X?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:X}):null]})}function Co({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:u=!1,className:b="",optionClassName:p=""}){return e.jsxs("fieldset",{className:`min-w-0 ${b}`,disabled:u,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:c==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(m=>{const h=m.value===r,x=u||m.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${x?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${p}`,style:{borderColor:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.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:[e.jsx("input",{type:"radio",name:n,value:m.value,checked:h,disabled:x,onChange:()=>t(m.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:m.label}),m.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:m.description})]})]},m.value)})})]})}const Ha=()=>'<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>',Xr=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Da=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),Eo=r=>r.replace(/[<>]/g,"").toLowerCase(),Mo=r=>new RegExp("\\p{L}","u").test(r),Lt=(r,t)=>{const a=r.trim();return!a||!Mo(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===Da(a)},Ba=r=>{const t=n=>{var s,c;if(!n.closest(".rich-img-wrap")){const u=document.createElement("span");u.className="rich-img-wrap",u.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(u,n),u.appendChild(n),u.insertAdjacentHTML("beforeend",Ha())}(c=n.closest(".rich-img-wrap"))==null||c.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function $o({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px"}){const s=l.useRef(null),c=l.useRef(null),u=l.useRef(null),b=l.useRef(!1),p=l.useRef(r??""),m=l.useRef(t),[h,x]=l.useState(()=>!r||r.trim()===""),[g,$]=l.useState(new Set),[C,N]=l.useState(null),[S,B]=l.useState(""),[ee,z]=l.useState(""),[X,L]=l.useState(""),[U,Q]=l.useState(""),[re,W]=l.useState(!1),J=l.useCallback(()=>b.current?c.current:s.current,[]);l.useEffect(()=>{m.current=t},[t]);const R=l.useCallback(()=>{const w=window.getSelection(),I=J();if(!w||!I||w.rangeCount===0||w.isCollapsed)return"";const de=w.getRangeAt(0);return!I.contains(de.startContainer)||!I.contains(de.endContainer)?"":w.toString()},[J]);l.useEffect(()=>{const w=r??"";p.current=w;const I=[s.current,c.current].filter(be=>!!be);I.forEach(be=>{be.innerHTML!==w&&(be.innerHTML=w)}),x(!w||w.trim()==="");const de=I.map(be=>Ba(be));return()=>de.forEach(be=>be())},[r]),l.useEffect(()=>{var be,ke;b.current=re;let w,I=0,de;if(re){const me=s.current;me&&(p.current=me.innerHTML);const Se=()=>{var fe;const we=c.current;if(!we){I=requestAnimationFrame(Se);return}we.innerHTML!==p.current&&(we.innerHTML=p.current),w=Ba(we),x(((fe=we.textContent)==null?void 0:fe.trim())===""),de=setTimeout(()=>we.focus(),60)};I=requestAnimationFrame(Se)}else{const me=c.current,Se=s.current,we=(me==null?void 0:me.innerHTML)??p.current,fe=p.current;p.current=we,Se&&Se.innerHTML!==we&&(Se.innerHTML=we),we!==fe&&m.current(we),x(((ke=(be=me??Se)==null?void 0:be.textContent)==null?void 0:ke.trim())==="")}return()=>{I&&cancelAnimationFrame(I),de&&clearTimeout(de),w==null||w()}},[re]);const T=l.useCallback(()=>{const w=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],I=new Set;w.forEach(be=>{try{document.queryCommandState(be)&&I.add(be)}catch{return}});try{const be=Eo(document.queryCommandValue("formatBlock"));be&&I.add(`formatBlock:${be}`)}catch{return}const de=R();Lt(de,"uppercase")&&I.add("__upper"),Lt(de,"lowercase")&&I.add("__lower"),Lt(de,"capitalize")&&I.add("__cap"),$(I)},[R]),P=()=>{var I;const w=J();w&&(p.current=w.innerHTML,m.current(p.current),x(((I=w.textContent)==null?void 0:I.trim())===""))},V=w=>{if(!w){const I=s.current;I&&(p.current=I.innerHTML)}W(!w)},_=(w,I)=>{var de;(de=J())==null||de.focus(),document.execCommand(w,!1,I),P(),T()},le=w=>{_("formatBlock",w)},q=()=>{var w;(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,"<hr><p><br></p>"),P(),T()},i=()=>{const w=window.getSelection();w&&w.rangeCount>0&&(u.current=w.getRangeAt(0).cloneRange())},y=()=>{const w=window.getSelection();w&&u.current&&(w.removeAllRanges(),w.addRange(u.current))},M=w=>{if(i(),w==="link"){const I=window.getSelection();z(I&&!I.isCollapsed?I.toString():""),B("")}w==="image"&&(L(""),Q("")),N(w)},O=()=>{var be;if(!S.trim())return;y(),(be=J())==null||be.focus();const w=window.getSelection(),de=(w&&!w.isCollapsed?w.toString():"")||ee.trim()||S.trim();document.execCommand("insertHTML",!1,`<a href="${Xr(S.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Xr(de)}</a>`),P(),N(null)},D=(w,I="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Xr(w)}" alt="${Xr(I)}" class="rich-img" />${Ha()}</span>`,ae=()=>{var w;X.trim()&&(y(),(w=J())==null||w.focus(),document.execCommand("insertHTML",!1,D(X.trim(),U.trim())),P(),N(null))},ie=(w,I=1200,de=1200,be=.72)=>new Promise((ke,me)=>{const Se=new FileReader;Se.onerror=me,Se.onload=we=>{var Ge;const fe=(Ge=we.target)==null?void 0:Ge.result,Be=new Image;Be.onerror=me,Be.onload=()=>{let{width:ze,height:ne}=Be;if(ze>I||ne>de){const Oe=Math.min(I/ze,de/ne);ze=Math.round(ze*Oe),ne=Math.round(ne*Oe)}const Me=document.createElement("canvas");Me.width=ze,Me.height=ne;const $e=Me.getContext("2d");if(!$e){ke(fe);return}$e.drawImage(Be,0,0,ze,ne),ke(Me.toDataURL("image/jpeg",be))},Be.src=fe},Se.readAsDataURL(w)}),pe=w=>{const de=Array.from(w.clipboardData.items).find(ke=>ke.type.startsWith("image/"));if(!de)return;w.preventDefault();const be=de.getAsFile();be&&ie(be).then(ke=>{var me;(me=J())==null||me.focus(),document.execCommand("insertHTML",!1,D(ke,"imagen")),P()})},A=w=>{const I=window.getSelection(),de=J();if(!I||!de||I.rangeCount===0||I.isCollapsed)return;const be=I.getRangeAt(0);if(!de.contains(be.startContainer)||!de.contains(be.endContainer))return;const ke=be.toString();if(!ke)return;let me=ke;w==="uppercase"?me=ke.toLocaleUpperCase():w==="lowercase"?me=ke.toLocaleLowerCase():me=Da(ke),be.deleteContents();const Se=document.createTextNode(me);be.insertNode(Se);const we=document.createRange();we.setStart(Se,0),we.setEnd(Se,me.length),I.removeAllRanges(),I.addRange(we),u.current=we.cloneRange(),P(),T()},oe=()=>{i(),T()},F=()=>{P(),T()},H=w=>{if(w.key==="Escape"){if(C){N(null);return}if(b.current){W(!1);return}}C||(w.ctrlKey||w.metaKey)&&(w.key==="b"&&(w.preventDefault(),_("bold")),w.key==="i"&&(w.preventDefault(),_("italic")),w.key==="u"&&(w.preventDefault(),_("underline")),w.key==="k"&&(w.preventDefault(),M("link")))},Z=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),G=(w,I,de,be,ke)=>{const me=ke??(g.has(de)||de==="__link"&&C==="link"||de==="__img"&&C==="image");return e.jsx("button",{type:"button",title:I,onMouseDown:Se=>{Se.preventDefault(),be?be():_(de)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:me?"var(--primary)":"var(--text-secondary)",background:me?"rgba(59,130,246,0.12)":"transparent"},children:w},de)},te=w=>{const I=w.target;if(I.closest("[data-action='delete-img']")){w.preventDefault();const de=I.closest(".rich-img-wrap");de&&(de.remove(),P())}},ue=w=>e.jsxs(e.Fragment,{children:[C==="link"&&e.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:[e.jsx("input",{autoFocus:!0,type:"url",value:S,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),O()),I.key==="Escape"&&N(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:ee,onChange:I=>z(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),O()),I.key==="Escape"&&N(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:O,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),C==="image"&&e.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:[e.jsx("input",{autoFocus:!0,type:"url",value:X,onChange:I=>L(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.key==="Escape"&&N(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:U,onChange:I=>Q(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),ae()),I.key==="Escape"&&N(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:ae,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),se=(w,I)=>e.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:I},children:[G(e.jsx(v.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),G(e.jsx(v.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>le("p"),g.has("formatBlock:p")||g.has("formatBlock:div")),G(e.jsx(v.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>le("h2"),g.has("formatBlock:h2")),G(e.jsx(v.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>le("h3"),g.has("formatBlock:h3")),G(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>le("blockquote"),g.has("formatBlock:blockquote")),Z(),G(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),G(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),G(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),G(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Z(),G(e.jsx(v.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),G(e.jsx(v.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),G(e.jsx(v.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),G(e.jsx(v.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Z(),G(e.jsx(v.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),G(e.jsx(v.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),G(e.jsx(v.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),G(e.jsx(v.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Z(),G(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>A("uppercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>A("lowercase")),G(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>A("capitalize")),Z(),G(e.jsx(v.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>M("link")),G(e.jsx(v.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),G(e.jsx(v.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>M("image")),G(e.jsx(v.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",q),Z(),G(e.jsx(v.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),G(e.jsx(v.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>le("p")),Z(),e.jsx("button",{type:"button",title:w?"Salir del modo de enfoque (Esc)":"Modo de enfoque",onMouseDown:de=>{de.preventDefault(),V(w)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:w?e.jsx(v.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(v.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return e.jsxs(e.Fragment,{children:[e.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:[e.jsx("div",{ref:s,contentEditable:!0,suppressContentEditableWarning:!0,onInput:F,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ue("var(--bg-input)"),se(!1,"var(--bg-input)")]}),e.jsxs(St,{open:re,onClose:()=>W(!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:[e.jsx("div",{ref:c,contentEditable:!0,suppressContentEditableWarning:!0,onInput:F,onKeyDown:H,onKeyUp:oe,onSelect:oe,onMouseUp:oe,onPaste:pe,onMouseDown:te,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),ue("var(--bg-input)"),se(!0,"var(--bg-input)")]})]})}function Lo({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:u="",bodyClassName:b="p-4"}){const p=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${u}`,children:[p&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.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:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:b,children:s}),c&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:c})]})}const To={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)"}},Ao={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 Ho({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const u=To[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Ao[a]} ${c}`,style:{color:u.text,background:u.bg,borderColor:u.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:u.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Ia={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)"}},Do={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"},Bo={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Io={xs:148,sm:164,md:184},Oo={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 Fo({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:c=!1,stopPropagation:u=!1,ariaLabel:b="Cambiar estado",title:p="Cambiar estado",className:m,selectClassName:h,menuClassName:x,optionClassName:g,spinnerClassName:$}){const[C,N]=l.useState(!1),[S,B]=l.useState(!1),[ee,z]=l.useState(-1),[X,L]=l.useState({}),U=l.useRef(null),Q=l.useRef(null),re=l.useRef(null),W=t.find(i=>i.value===r)??t[0],J={...W!=null&&W.tone?Ia[W.tone]:void 0,...W==null?void 0:W.style},R=s||c||t.length===0,T=i=>{u&&i.stopPropagation()},P=l.useCallback(()=>{N(!1),z(-1)},[]),V=l.useCallback(()=>{const i=U.current;if(!i)return;const y=i.getBoundingClientRect(),M=Math.max(y.width,Io[n]),O=Math.min(Math.max(t.length,1)*38+12,260),D=window.innerHeight-y.bottom,ae=D<O&&y.top>D,ie=Math.min(Math.max(8,y.left+y.width/2-M/2),window.innerWidth-M-8);L({position:"fixed",left:ie,top:ae?void 0:y.bottom+6,bottom:ae?window.innerHeight-y.top+6:void 0,width:M,zIndex:9999})},[t.length,n]),_=l.useCallback(i=>{i.disabled||(a(i.value),P())},[P,a]);l.useEffect(()=>B(!0),[]),l.useEffect(()=>{if(!C)return;V();const i=t.findIndex(y=>y.value===r);z(i>=0?i:0)},[C,t,V,r]),l.useEffect(()=>{if(!C)return;function i(y){var O,D;const M=y.target;!((O=U.current)!=null&&O.contains(M))&&!((D=Q.current)!=null&&D.contains(M))&&P()}return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[P,C]),l.useEffect(()=>{if(C)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[C,V]),l.useEffect(()=>{if(ee<0||!re.current)return;const i=re.current.children[ee];i==null||i.scrollIntoView({block:"nearest"})},[ee]);function le(i){if(!R){if(!C){["Enter"," ","ArrowDown","ArrowUp"].includes(i.key)&&(i.preventDefault(),N(!0));return}if(i.key==="Escape"){i.preventDefault(),P();return}if(i.key==="ArrowDown"){i.preventDefault(),z(y=>Math.min(y+1,t.length-1));return}if(i.key==="ArrowUp"){i.preventDefault(),z(y=>Math.max(y-1,0));return}if(i.key==="Enter"||i.key===" "){i.preventDefault();const y=t[ee];y&&_(y)}}}const q=e.jsx("div",{ref:Q,role:"listbox","aria-label":b,className:Je("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",x),style:{...X,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:T,onMouseDown:T,onPointerDown:T,children:e.jsx("div",{ref:re,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((i,y)=>{const M=i.value===r,O=y===ee,D={...i.tone?Ia[i.tone]:void 0,...i.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":M,disabled:i.disabled,onMouseEnter:()=>!i.disabled&&z(y),onMouseDown:ae=>{ae.preventDefault(),_(i)},className:Je("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Oo[n],M?i.className:void 0,g),style:{...M?D:void 0,background:M?D.background??"color-mix(in srgb, var(--primary) 12%, transparent)":O?"var(--bg-hover)":"transparent",color:M?D.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:M?e.jsx(v.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.label})]},i.value)})})});return e.jsxs("span",{ref:U,className:Je("relative inline-flex shrink-0 items-center",m),onKeyDown:le,onClick:T,onPointerDown:T,children:[e.jsx("button",{type:"button",disabled:R,"aria-label":b,"aria-haspopup":"listbox","aria-expanded":C,title:p,onClick:()=>!R&&N(i=>!i),className:Je("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",Do[n],W==null?void 0:W.className,h),style:J,children:e.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??r})}),e.jsx(v.HiChevronDown,{"aria-hidden":"true",className:Je("pointer-events-none absolute opacity-70 transition-transform",Bo[n],C?"rotate-180":"rotate-0")}),c&&e.jsx("span",{"aria-hidden":"true",className:Je("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",$)}),C&&S&&je.createPortal(q,document.body)]})}function Po({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:u="",listClassName:b="",panelClassName:p=""}){const m=r.find(C=>!C.disabled)??r[0],h=t??a??(m==null?void 0:m.id),x=r.find(C=>C.id===h)??m,g=C=>{C.disabled||n==null||n(C.id)},$=C=>{const N=r.filter(B=>!B.disabled);if(!N.length||!x)return;const S=N.findIndex(B=>B.id===x.id);(C.key==="ArrowRight"||C.key==="ArrowDown")&&(C.preventDefault(),g(N[(S+1)%N.length])),(C.key==="ArrowLeft"||C.key==="ArrowUp")&&(C.preventDefault(),g(N[(S-1+N.length)%N.length])),C.key==="Home"&&(C.preventDefault(),g(N[0])),C.key==="End"&&(C.preventDefault(),g(N[N.length-1]))};return e.jsxs("div",{className:u,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:$,className:`flex min-w-0 gap-1 overflow-x-auto ${c==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${b}`,children:r.map(C=>{const N=C.id===(x==null?void 0:x.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":N,"aria-controls":`${C.id}-panel`,id:`${C.id}-tab`,disabled:C.disabled,tabIndex:N?0:-1,onClick:()=>g(C),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 ${c==="underline"?"border-b-2":"rounded-md border"}`,style:{color:N?"var(--primary)":"var(--text-muted)",borderColor:N?"var(--primary)":"transparent",background:c==="pills"&&N?"var(--bg-card)":"transparent"},children:[C.icon&&e.jsx("span",{className:"shrink-0",children:C.icon}),e.jsx("span",{children:C.label}),C.badge&&e.jsx("span",{className:"shrink-0",children:C.badge})]},C.id)})}),(x==null?void 0:x.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${x.id}-panel`,"aria-labelledby":`${x.id}-tab`,className:`pt-4 ${p}`,children:x.content})]})}function Qe(...r){return r.filter(Boolean).join(" ")}function zo({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:u,onBlockedStep:b,allowBackNavigation:p=!0,showFooter:m=!0,previousLabel:h="Anterior",nextLabel:x="Siguiente",blockedNextLabel:g="Completa este paso",className:$="",headerClassName:C="",contentClassName:N="",footerClassName:S=""}){var F;const B=((F=r[0])==null?void 0:F.id)??"",[ee,z]=l.useState(a??B),[X,L]=l.useState(s),U=t??ee,Q=n??X,re=l.useMemo(()=>new Set(Q),[Q]),W=Math.max(0,r.findIndex(H=>H.id===U)),J=r[W]??r[0],R=r.length<=1?100:W/(r.length-1)*100,T=H=>{n||L(H),u==null||u(H)},P=H=>{const Z=r.find(G=>G.id===H);Z&&(t||z(H),c==null||c(H,Z))},V=H=>re.has(H),_=H=>r.slice(0,H).find(Z=>!Z.optional&&!re.has(Z.id)),le=H=>{const Z=r[H];return!Z||Z.disabled?!1:H===W||p&&H<W?!0:!_(H)},q=H=>{const Z=r.findIndex(G=>G.id===H);return Z>=0&&le(Z)},i=H=>{const Z=r.findIndex(G=>G.id===H);if(Z<0)return!1;if(!le(Z)){const G=_(Z);return G&&(b==null||b(r[Z],G)),!1}return P(H),!0},y=(H=J==null?void 0:J.id)=>{!H||re.has(H)||T([...Q,H])},M=(H=J==null?void 0:J.id)=>{if(!H)return;const Z=r.findIndex(te=>te.id===H),G=Q.filter(te=>{const ue=r.findIndex(se=>se.id===te);return ue>=0&&ue<Z});T(G),Z>=0&&W>Z&&P(H)},O=()=>W<=0?!1:i(r[W-1].id),D=()=>{const H=r[W+1];return H?i(H.id):!1},ae={activeStep:J,activeIndex:W,completedStepIds:Q,isCompleted:V,isUnlocked:q,completeStep:y,uncompleteStep:M,goToStep:i,goNext:D,goPrevious:O};if(!J)return null;const ie=r[W+1],pe=W>0,A=ie?q(ie.id):!1,oe=typeof J.content=="function"?J.content(ae):J.content;return e.jsxs("section",{className:Qe("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",$),children:[e.jsxs("div",{className:Qe("border-b border-[var(--border)] bg-[var(--bg-input)]",C),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${R}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((H,Z)=>{const G=H.id===J.id,te=V(H.id),ue=le(Z),se=_(Z);return e.jsxs("button",{type:"button",disabled:!ue,"aria-current":G?"step":void 0,"aria-disabled":!ue,title:!ue&&se?`Completa ${se.title}`:H.title,onClick:()=>i(H.id),className:Qe("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",G&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",te&&!G&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!G&&!te&&ue&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ue&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:Qe("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",G&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:Qe("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",G&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",te&&!G&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!te&&!G&&ue&&"border-[var(--border)] text-[var(--text-muted)]",!ue&&"border-[var(--border)] text-[var(--text-muted)]"),children:te?e.jsx(v.HiCheck,{className:"h-4 w-4"}):ue?Z+1:e.jsx(v.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:Qe("block truncate text-xs font-semibold transition-colors duration-200",G?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Z+1,". ",H.title]}),H.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:H.description})]}),H.badge&&e.jsx("span",{className:"shrink-0",children:H.badge})]})]},H.id)})})]}),e.jsx("div",{className:Qe("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",N),children:oe},J.id),m&&e.jsxs("div",{className:Qe("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",S),children:[e.jsx(Te,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(v.HiChevronLeft,{}),disabled:!pe,onClick:O,children:h}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",W+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[Q.length," completados"]})]}),e.jsx(Te,{height:38,padding:"0 14px",icon:e.jsx(v.HiChevronRight,{}),disabled:!ie||!A,onClick:D,children:ie&&!A?g:x})]})]})}const jo={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"},_o={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Wo(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function qo(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Oa=l.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:c=!1,minRows:u,maxRows:b,showCount:p=!1,maxCount:m,status:h="default",icon:x,action:g,style:$,value:C,defaultValue:N,maxLength:S,onInput:B,...ee},z){const X=l.useRef(null),L=qo(C,N),U=m??S,Q=!!(x||g||p),re=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",W={...$??{},...u?{minHeight:`${u*24+18}px`}:null,...b?{maxHeight:`${b*24+18}px`}:null},J=()=>{const T=X.current;!T||!c||(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)};l.useEffect(J,[c,C]);const R=e.jsx("textarea",{...ee,ref:T=>{X.current=T,Wo(z,T)},value:C,defaultValue:N,maxLength:S,"aria-invalid":h==="error"||ee["aria-invalid"],onInput:T=>{J(),B==null||B(T)},style:{...W,borderColor:re},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 ${jo[n]} ${_o[c?"none":s]} ${x?"pl-8":""} ${g?"pr-10":""} ${t}`});return Q?e.jsxs("span",{className:`relative block ${a}`,children:[x&&e.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:x}),R,g&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:g}),p&&e.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:[L,U?`/${U}`:""]})]}):R});function Uo({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:u="",status:b,...p}){return e.jsx($a,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Oa,{...p,required:c,status:n?"error":b,className:`w-full ${u}`})})}const Vo={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Ko({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const u=Vo[n],b=r?u.width-u.thumb-u.padding*2:0;return e.jsx("button",{...c,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:u.width,height:u.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:u.thumb,height:u.thumb,left:u.padding,top:"50%",transform:`translate(${b}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Fa=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function Go(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function Pa(r){return r.classList.contains("sidebar-scroll")}function za(r){Pa(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function ja(){return l.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Fa).forEach(c=>{if(!Go(c))return;if(Zt.OverlayScrollbars(c)){za(c);return}const b=Zt.OverlayScrollbars(c,{overflow:Pa(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});za(c),r.set(c,b)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(Fa).forEach(c=>{var u;c instanceof HTMLElement&&((u=r.get(c))==null||u.destroy())})}},[]),null}const Yo={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"}},_a=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Xo={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Zo="bonsaif.bot",Jo="Bonsaif Bot",Qo={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Wa(r){return typeof r=="string"?r.trim():""}function Ro(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return _a[t%_a.length]}function es(r,t){return r===Zo||t===Jo}function rs(r,t){return`${r.replace(/\/$/,"")}${t}`}function qa({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:u,fallbackLabel:b="Usuario",wrapperClassName:p="",labelClassName:m="",labelSize:h="xs",avatarVersion:x=0,className:g="",style:$}){var V;const[C,N]=l.useState(!1),S=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";l.useEffect(()=>{N(!1)},[S,x]);const{wh:B,text:ee}=Yo[n],z=Wa(a)||Wa(t)||b,X=z.trim()[0]||"?",L=typeof process<"u"&&((V=process.env)==null?void 0:V.NEXT_PUBLIC_BASE_PATH)||"",U=es(t,a),Q=rs(L,"/favicon.svg"),re=S?`${L}/api/user/avatar/${S}${x?`?v=${x}`:""}`:"",J={xs:20,sm:28,md:36,lg:48,xl:64}[n],R=U?e.jsx("span",{className:`${B} ${Qo[n]} 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:$,children:e.jsx("img",{src:Q,alt:z,width:J,height:J,className:"h-full w-full object-contain"})}):re&&!C?e.jsx("img",{src:re,alt:z,width:J,height:J,className:`${B} rounded-full object-cover flex-shrink-0 ${g}`,style:$,onError:()=>N(!0)},`${S}-${x}`):e.jsx("span",{className:`${B} ${Ro(z)} ${ee} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:$,title:z,children:X});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${p}`,children:[R,e.jsx("span",{className:`min-w-0 truncate ${Xo[h]} font-medium text-[var(--text-main)] ${m}`,title:z,children:z})]});const T=c??!0,P=u??z;return T&&P?e.jsx(dr,{as:"span",content:P,className:`inline-flex flex-shrink-0 ${p}`,children:R}):R}function ts({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function as(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Ua({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:u,footer:b,onLogout:p,LinkComponent:m=ts}){const[h,x]=l.useState(!1),g=as(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(ja,{}),e.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:()=>x(!0),children:e.jsx(v.HiBars3,{className:"h-5 w-5"})}),h&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>x(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${h?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:c??e.jsx(v.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),e.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:()=>x(!1),children:e.jsx(v.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(g).map(([$,C])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(v.HiChevronDown,{className:"h-3.5 w-3.5"}),$]}),e.jsx("div",{className:"space-y-1",children:C.map(N=>{const S=a===N.href||a.startsWith(`${N.href}/`);return e.jsxs(m,{href:N.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${S?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:N.icon??e.jsx(v.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:N.label})]},N.href)})})]},$))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(qa,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),p&&e.jsxs(Te,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:p,children:[e.jsx(v.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),b]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[u,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Va="bonsaif-ui:prime-auth-sso",ns={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"},Tt={dashboard:e.jsx(v.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(v.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(v.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(v.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(v.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(v.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(v.HiUser,{className:"h-5 w-5"}),settings:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(v.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(v.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(v.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(v.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(v.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(v.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(v.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(v.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(v.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(v.HiShieldCheck,{className:"h-5 w-5"})};function ls({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function os(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ss(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function is(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=ss(a)&&n?n:a,c=ns[s]??os(s);return[{label:"Inicio",href:"/"},{label:c}]}function At(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function cs(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(v.HiHome,{className:"h-5 w-5"});if(Tt[a])return Tt[a];const n=t.length>1?t[t.length-2]:"";return Tt[n]??e.jsx(v.HiHome,{className:"h-5 w-5"})}function ds(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Ka(){if(typeof window>"u")return!1;if(ds(window.location.href)){try{window.sessionStorage.setItem(Va,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Va)==="true"}catch{return!1}}function us({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:u="",breadcrumbs:b,currentPath:p,showBreadcrumbs:m=!0,contained:h=!1,LinkComponent:x=ls}){const g=l.useRef(null),[$,C]=l.useState(!1),[N,S]=l.useState(p??"/"),[B,ee]=l.useState(()=>Ka()),[z,X]=l.useState(null),L=p??N,U=b??is(L),Q=s??cs(L),re=m&&!B&&U.length>1,W=!re;l.useEffect(()=>{p||S(window.location.pathname)},[p]),l.useEffect(()=>{ee(Ka())},[]),l.useEffect(()=>{if(h){C(!1);return}let R=null,T=0,P=0;const V=()=>{const q=g.current,i=document.querySelector("[data-app-scroll='true']");return(q==null?void 0:q.closest(".os-viewport"))??(q==null?void 0:q.closest("[data-overlayscrollbars-viewport]"))??At(i)??i??window},_=()=>{const q=R&&R!==window?R.scrollTop:window.scrollY;C(i=>i?q>24:q>72)},le=()=>{R==null||R.removeEventListener("scroll",_),R=V(),R.addEventListener("scroll",_,{passive:!0}),_()};return le(),T=window.requestAnimationFrame(le),P=window.setTimeout(le,120),()=>{window.cancelAnimationFrame(T),window.clearTimeout(P),R==null||R.removeEventListener("scroll",_)}},[h]),l.useEffect(()=>{if(h){X(null);return}let R=0;const T=[],P=()=>{const M=g.current,O=M==null?void 0:M.parentElement,D=document.querySelector("[data-app-scroll='true']"),ae=At(D)??D;if(!M||!O||!ae){X(null);return}const ie=O.getBoundingClientRect(),pe=window.getComputedStyle(O),A=ae.getBoundingClientRect(),oe=ae instanceof HTMLElement&&ae.clientWidth>0?ae.clientWidth:A.width,F=ie.left+parseFloat(pe.paddingLeft||"0"),H={marginLeft:Math.round(A.left-F),width:Math.round(oe)};X(Z=>Z&&Z.marginLeft===H.marginLeft&&Z.width===H.width?Z:H)},V=()=>{window.cancelAnimationFrame(R),R=window.requestAnimationFrame(P)};V(),window.addEventListener("resize",V);const _=new ResizeObserver(V),le=g.current,q=le==null?void 0:le.parentElement,i=document.querySelector("[data-app-scroll='true']"),y=At(i)??i;return[q,i,y].forEach(M=>{M&&_.observe(M)}),T.push(window.setTimeout(V,120)),T.push(window.setTimeout(V,280)),()=>{window.cancelAnimationFrame(R),window.removeEventListener("resize",V),_.disconnect(),T.forEach(M=>window.clearTimeout(M))}},[h]);const J={...z?{marginLeft:z.marginLeft,width:z.width}:null,"--page-header-control-height":$?"34px":"40px","--page-header-control-padding-x":$?"10px":"14px","--page-header-control-icon-left":$?"10px":"12px",background:h?"var(--bg-card)":$?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:h||$?"1px solid var(--border)":"1px solid transparent",boxShadow:$?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:g,"data-page-header":"true","data-compact":$?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:J,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${$?"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"} ${u}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${$||W?"gap-1":"gap-1.5 sm:gap-2"}`,children:[re&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${$?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:U.map((R,T)=>{const P=T===U.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[T>0&&e.jsx(v.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),R.href&&!P?e.jsx(x,{href:R.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:R.label}):e.jsx("span",{"aria-current":P?"page":void 0,className:P?"truncate font-semibold":"truncate",style:{color:P?"var(--text-main)":"var(--text-muted)"},children:R.label})]},`${R.label}-${T}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${$||W?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${$?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:re?"var(--text-secondary)":"var(--text-muted)"},children:Q}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${$?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${$?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":$,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${$?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.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 ${$?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.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 ${$?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(ra.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function bs({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Ua,{currentPath:t,...n,children:r})}function Ga(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function fs(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const c=new URL(s,n.origin);return c.searchParams.set("theme",t),a&&(c.searchParams.set("primeAuthOrigin",window.location.origin),c.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${c.pathname}${c.search}${c.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function ps({name:r,src:t,projectKey:a}){const[n,s]=l.useState("system"),c=l.useRef(null);l.useEffect(()=>{s(Ga());const p=new MutationObserver(()=>s(Ga()));return p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>p.disconnect()},[]);const u=l.useMemo(()=>fs(t,n,a),[a,t,n]),b=l.useMemo(()=>{try{return new URL(u).origin}catch{return""}},[u]);return l.useEffect(()=>{if(!a)return;const p=a;function m(h){var $,C,N;if(h.source!==(($=c.current)==null?void 0:$.contentWindow)||b&&h.origin!==b)return;if(((C=h.data)==null?void 0:C.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((N=h.data)==null?void 0:N.type)!=="prime-microservice:navigation")return;const x=h.data.path;if(!x||!x.startsWith("/")||x.startsWith("//"))return;const g=`/apps/${encodeURIComponent(p)}${x}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==g&&(window.history.replaceState(window.history.state,"",g),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",m),()=>{window.removeEventListener("message",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[b,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:c,src:u,title:r,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 ms(){const[r,t]=l.useState(""),[a,n]=l.useState(!1),[s,c]=l.useState({width:96,height:96});return l.useEffect(()=>{let u=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(b=>b.ok?b.json():null).then(b=>{!u&&(b!=null&&b.src)&&t(b.src)}).catch(()=>{}),()=>{u=!0}},[]),l.useEffect(()=>{const u=b=>{var m;if(((m=b.data)==null?void 0:m.type)!=="prime-suite-chat:state")return;const p=!!b.data.active;n(p),c({width:Ya(b.data.width,96,720),height:Ya(b.data.height,96,560)})};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ya(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function hs(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function vs(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function gs(){return"light"}function xs({position:r="bottom-center"}){const t=l.useSyncExternalStore(hs,vs,gs);return e.jsx(Jt.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function ys(r){const[t,a]=l.useState({}),[n,s]=l.useState(!1),c=l.useCallback(m=>n||t[m]?r[m]:void 0,[r,n,t]),u=l.useCallback(m=>{a(h=>({...h,[m]:!0}))},[]),b=l.useCallback(()=>{s(!0)},[]),p=l.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:c,touchField:u,submit:b,reset:p}}Object.defineProperty(Y,"toast",{enumerable:!0,get:()=>Jt.toast}),Y.Alert=Kn,Y.AuthShell=Ua,Y.BonsaifButton=Ln,Y.BonsaifUIToaster=xs,Y.Button=Te,Y.CalendarPicker=Jn,Y.Checkbox=Fr,Y.CodeBlock=tl,Y.CompactFilterSelect=nl,Y.CompactSearchInput=al,Y.ConfirmDialog=il,Y.CopyButton=Nt,Y.CopyLinkButton=dl,Y.DataSheets=Al,Y.DataTable=ma,Y.DateRangePicker=Bl,Y.Drawer=zl,Y.DropdownMenu=Fl,Y.DynamicDetailTabs=Un,Y.EmailField=io,Y.EmptyState=uo,Y.FieldLayoutEditor=vo,Y.FileUpload=mo,Y.FormField=$a,Y.GlobalScrollbars=ja,Y.InputField=$t,Y.LoadingState=la,Y.MicroserviceFrame=ps,Y.Modal=St,Y.MouseTooltip=dr,Y.MultiSelect=xo,Y.NumberField=yo,Y.PageHeader=us,Y.PageSearchInput=ea,Y.Pagination=No,Y.PhoneField=So,Y.PrimeAuthRouteShell=bs,Y.PrimeSuiteChatFrame=ms,Y.RadioGroup=Co,Y.RichTextEditor=$o,Y.SearchableSelect=rr,Y.SectionPanel=Lo,Y.StatusBadge=Ho,Y.StatusSelect=Fo,Y.StepWizard=zo,Y.Tabs=Po,Y.TextInput=Gr,Y.Textarea=Oa,Y.TextareaField=Uo,Y.Toggle=Ko,Y.UserAvatar=qa,Y.cn=Je,Y.emailFormat=Vl,Y.isValidEmail=Ct,Y.isValidPhone=Et,Y.matches=Jl,Y.maxLength=Yl,Y.maxValue=Zl,Y.minLength=Gl,Y.minValue=Xl,Y.phoneCountryCodeOptions=Ta,Y.phoneFormat=Kl,Y.required=Ul,Y.useValidationVisibility=ys,Y.validateForm=Ql,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
|