bonsaif-ui 0.1.38 → 0.1.40
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/README.md +13 -0
- package/dist/bonsaif-ui.js +1196 -1162
- package/dist/bonsaif-ui.umd.cjs +6 -6
- package/dist/components/ui/ConfirmDialog.d.ts +3 -1
- package/dist/components/ui/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/ui/DataTable.d.ts.map +1 -1
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(q,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):(q=typeof globalThis<"u"?globalThis:q||self,l(q.BonsaifUI={},q.React,q.jsxRuntime,q.ReactIconsHi2,q.ReactDOM,q.OverlayScrollbarsGlobal,q.Sonner,q.OverlayScrollbarsReact,q.ReactDayPicker,q.ReactDayPickerStyles,q.ReactIconsFi))})(this,(function(q,l,e,p,ze,Jt,Qt,Rt,ea,Js,En){"use strict";"use client";function Je(...r){return r.filter(Boolean).join(" ")}function Mn({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 ra({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:c=!1,onEscape:d,size:b="default",inputTabIndex:f}){const h=l.useRef(null),[k,S]=l.useState(!1),m=c||k||r.trim().length>0,C=b==="sm"?"h-9 rounded-md":"h-10 rounded-lg",N=n||"w-48 max-w-full sm:w-64 lg:w-72";l.useEffect(()=>{var w;s&&((w=h.current)==null||w.focus())},[s]);const x=()=>{var w;S(!0),(w=h.current)==null||w.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${m?N:"w-24 sm:w-28"}`,onMouseDown:w=>{m||(w.preventDefault(),x())},children:[e.jsx(p.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:h,type:"text",tabIndex:f,"aria-label":a,value:r,onChange:w=>t(w.target.value),onKeyDown:w=>{w.key==="Escape"&&(d==null||d())},placeholder:m?a:"Buscar",className:`${C} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${m?"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:m?"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:w=>{S(!0),w.currentTarget.style.borderColor="var(--primary)",w.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:w=>{S(!1),w.currentTarget.style.borderColor="var(--border)",w.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(p.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const ta=l.createContext({});let aa=0;const na="bonsaif-ui:hide-tooltips";function Br(r=700){aa=Date.now()+r}function Ln(){return Date.now()>aa}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 $n(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 cr({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:c="bottom",showArrow:d=!1,className:b="",tooltipClassName:f="",style:h,tooltipStyle:k,as:S="div"}){const m=l.useRef(null),C=l.useRef(null),N=l.useRef(null),x=l.useRef(!1),[w,H]=l.useState(null),[Y,D]=l.useState("");l.useEffect(()=>{const E=m.current;E&&(E.querySelectorAll("[title]").forEach(B=>{const _=B.getAttribute("title");_&&(B.getAttribute("aria-label")||B.setAttribute("aria-label",_),B.removeAttribute("title"))}),E.querySelectorAll("svg title").forEach(B=>B.remove()))}),l.useLayoutEffect(()=>{if(!w)return;const E=C.current;if(!E)return;const B=12,_=14,O=E.getBoundingClientRect(),ee=window.innerWidth-O.width-B,P=window.innerHeight-O.height-B;let g=w.mouseX+_,z=w.mouseY+_,V,ae;if(!s&&m.current){const te=m.current.getBoundingClientRect(),he=te.left+te.width/2,$=te.top+te.height/2;c==="top"?(g=he-O.width/2,z=te.top-O.height-_,ae=O.height-1):c==="left"?(g=te.left-O.width-_,z=$-O.height/2,V=O.width-1):c==="right"?(g=te.right+_,z=$-O.height/2,V=-7):(g=he-O.width/2,z=te.bottom+_,ae=-7)}if(s&&(g>ee&&(g=w.mouseX-O.width-_),z>P&&(z=w.mouseY-O.height-_)),g=Math.min(Math.max(B,g),Math.max(B,ee)),z=Math.min(Math.max(B,z),Math.max(B,P)),!s&&m.current){const te=m.current.getBoundingClientRect(),he=te.left+te.width/2,$=te.top+te.height/2;c==="top"||c==="bottom"?V=Math.min(Math.max(14,he-g),O.width-14):ae=Math.min(Math.max(14,$-z),O.height-14)}(Math.abs(g-w.x)>.5||Math.abs(z-w.y)>.5||V!==w.arrowX||ae!==w.arrowY)&&H(te=>te&&{...te,x:g,y:z,arrowX:V,arrowY:ae})},[s,c,w]);const G=()=>{N.current&&(window.clearTimeout(N.current),N.current=null)},L=(E,B)=>{if(!Ln()||x.current)return;const _=m.current;if(_&&!Or(_)){if(a){const O=$n(_);if(!O)return;D(O)}!a&&!t||H({mouseX:E,mouseY:B,x:E+14,y:B+14})}},I=()=>{const E=m.current;if(!E)return;const B=E.getBoundingClientRect();L(B.left+B.width/2,B.bottom)},X=()=>{G(),H(null)},J=()=>{if(!n){X();return}G(),N.current=window.setTimeout(()=>H(null),120)},F=()=>{Br(),x.current=!0,X()},K=()=>{x.current=!1};l.useEffect(()=>{if(!w)return;if(Or(m.current)){H(null);return}const E=()=>H(null),B=()=>{Br(),x.current=!0,H(null)};document.addEventListener("pointerdown",B,!0),document.addEventListener("click",B,!0),document.addEventListener("scroll",E,!0),window.addEventListener("blur",E),document.addEventListener("visibilitychange",E),document.addEventListener("keydown",E,!0);const _=new MutationObserver(()=>{Or(m.current)&&H(null)});return _.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",B,!0),document.removeEventListener("click",B,!0),document.removeEventListener("scroll",E,!0),window.removeEventListener("blur",E),document.removeEventListener("visibilitychange",E),document.removeEventListener("keydown",E,!0),_.disconnect()}},[w]),l.useEffect(()=>{const E=()=>Br(),B=()=>{Br(),x.current=!0,H(null)};return document.addEventListener("pointerdown",E,!0),document.addEventListener("click",E,!0),document.addEventListener("keydown",E,!0),window.addEventListener(na,B),()=>{document.removeEventListener("pointerdown",E,!0),document.removeEventListener("click",E,!0),document.removeEventListener("keydown",E,!0),window.removeEventListener(na,B)}},[]);const Z=a?Y:t;return e.jsxs(e.Fragment,{children:[e.jsx(S,{ref:E=>{m.current=E},className:b,style:h,onMouseEnter:E=>{G(),K(),s?L(E.clientX,E.clientY):I()},onMouseMove:E=>{w&&s&&L(E.clientX,E.clientY)},onMouseDown:F,onClick:F,onMouseLeave:()=>{K(),J()},onFocus:I,onBlur:X,children:r}),w&&Z&&!Or(m.current)?ze.createPortal(e.jsxs("div",{ref:C,role:"tooltip",className:f,onMouseEnter:n?G:void 0,onMouseLeave:n?J:void 0,style:{position:"fixed",top:w.y,left:w.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",...k},children:[d&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(k==null?void 0:k.background)??"var(--bg-card)",borderLeft:c==="right"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,borderTop:c==="bottom"||c==="right"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,borderRight:c==="left"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,borderBottom:c==="top"||c==="left"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:w.arrowX===void 0?void 0:w.arrowX-6,top:w.arrowY===void 0?void 0:w.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function la(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Tn="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",Hn={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"},An="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",Dn={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"},Bn={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},On={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function pt(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(pt).join(" ").trim():l.isValidElement(r)?pt(r.props.children):""}function In(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:d,padding:b,children:f,className:h="",disabled:k,style:S,...m}){const C=l.useContext(ta),N=c??C.iconOnly??r==="icon",x=C.compact??!1,w=C.headerAction??!1,H=w&&t==="md"?"sm":x&&!w&&t==="md"?"xs":t,Y=r==="icon"||N,D=w&&Y,G=pt(f),L=s??m.title??m["aria-label"]??(N?G:void 0),I=L?void 0:m.title,X=m["aria-label"]??(typeof L=="string"?L:G||void 0),J=a?null:n??(N?In(f):null),F=e.jsxs("button",{...m,title:I,"aria-label":X,"data-variant":r,"data-size":H,"data-icon":Y?"true":void 0,disabled:k||a,className:`${Tn} ${D?An:Hn[r]} ${Y?Bn[H]:Dn[H]} ${x&&!Y?"px-2.5":""} ${h}`,style:{...On[r],height:la(d),padding:la(b),...S,...w&&!Y?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...D?{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"}):J,!N&&f]});return L?e.jsx(cr,{as:"span",content:L,className:"inline-flex shrink-0",children:F}):F}function oa({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(sa,{rows:a}):r==="sections"?e.jsx(Fn,{rows:a}):r==="cards"?e.jsx(Pn,{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 Fn({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(sa,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function Pn({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 sa({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,d)=>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+d*11)%36}%`}})},d))},s))]})}function ia(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 ca(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function jn(r){return[r.label,ia(r.service),r.description,r.service].filter(Boolean).join(" ")}function zn(r){return typeof r=="function"?r:r.default}function _n(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 Wn({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:c,moduleRegistry:d,loadModule:b,activeService:f,initialService:h,onActiveServiceChange:k,canAccess:S,keepAlive:m=!0,title:C,subtitle:N,emptyState:x,loadingState:w,errorState:H=_n,renderTabLabel:Y,searchableTabs:D="auto",tabsSearchThreshold:G=6,tabsSearchPlaceholder:L="Buscar modulo...",tabsSearchValue:I,onTabsSearchChange:X,emptySearchState:J,showTabCount:F=!0,className:K="",parentClassName:Z="",contentClassName:E="",tabsClassName:B=""}){var je;const _=l.useMemo(()=>c.filter(Q=>!Q.hidden&&((S==null?void 0:S(Q,s))??!0)),[S,s,c]),O=(je=_.find(Q=>!Q.disabled))==null?void 0:je.service,[ee,P]=l.useState(h??O??""),[g,z]=l.useState({}),[V,ae]=l.useState({}),[te,he]=l.useState(""),[$,ue]=l.useState(!1),T=l.useRef(V),se=l.useRef(0),fe=I??te,U=ca(fe),re=D===!0||D==="auto"&&_.length>=G,R=re&&fe.trim().length>0,ne=l.useMemo(()=>U?_.filter(Q=>ca(jn(Q)).includes(U)):_,[U,_]),ve=f??ee,oe=_.find(Q=>Q.service===ve)??_.find(Q=>!Q.disabled);l.useEffect(()=>{!oe&&O&&P(O)},[O,oe]),l.useEffect(()=>{T.current=V},[V]);const M=Q=>{Q.disabled||(f||P(Q.service),k==null||k(Q.service,Q))},W=Q=>{I===void 0&&he(Q),X==null||X(Q)},ie=(Q,Me)=>{const Le=ne.filter(He=>!He.disabled),Ie=Le.findIndex(He=>He.service===Me.service);Ie<0||((Q.key==="ArrowRight"||Q.key==="ArrowDown")&&(Q.preventDefault(),M(Le[(Ie+1)%Le.length])),(Q.key==="ArrowLeft"||Q.key==="ArrowUp")&&(Q.preventDefault(),M(Le[(Ie-1+Le.length)%Le.length])),Q.key==="Home"&&(Q.preventDefault(),M(Le[0])),Q.key==="End"&&(Q.preventDefault(),M(Le[Le.length-1])))},ce=l.useCallback(()=>{if(!oe)return;const Q=oe.service,Me=T.current[Q];if(Me!=null&&Me.loading||Me!=null&&Me.component&&m)return;const Le=(d==null?void 0:d[Q])??b;if(!Le){ae(He=>({...He,[Q]:{loading:!1,error:new Error(`No module loader found for service "${Q}".`)}}));return}const Ie=++se.current;ae(He=>({...He,[Q]:{...He[Q],loading:!0,error:void 0}})),Le(oe,s).then(He=>{if(Ie!==se.current&&!m)return;const Ke=zn(He);ae(Oe=>({...Oe,[Q]:{component:Ke,loading:!1}}))}).catch(He=>{const Ke=He instanceof Error?He:new Error(String(He));ae(Oe=>({...Oe,[Q]:{...Oe[Q],loading:!1,error:Ke}}))})},[s,m,b,d,oe]);l.useEffect(ce,[ce]);const ke=oe?g[oe.service]??null:null,be=oe?V[oe.service]:void 0,Se=be==null?void 0:be.component,we=Q=>{oe&&z(Me=>({...Me,[oe.service]:Q}))},de=()=>{oe&&z(Q=>({...Q,[oe.service]:null}))},Be={context:s,parent:n,links:c,visibleLinks:_,filteredLinks:ne,selectedLink:oe,selectedService:oe==null?void 0:oe.service,activeItemId:ke,tabsSearch:fe,onSelectService:M,onOpenDetail:we,onBackToList:de},Ve=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)] ${K}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Ve}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${E}`,children:[(C||N||re||F)&&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:[C&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:C}),N&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:N})]}),(re||F)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[F&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[ne.length," / ",_.length]}),re&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${$?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!$,children:e.jsx(ra,{value:fe,onChange:W,placeholder:L,className:"w-full",autoFocus:$,forceExpanded:!0,onEscape:()=>ue(!1),size:"sm",inputTabIndex:$?0:-1})}),e.jsx("button",{type:"button","aria-label":$?"Cerrar busqueda":"Buscar tabs","aria-expanded":$,onClick:()=>{$&&fe&&W(""),ue(Q=>!Q)},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 ${$||R?"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:$||R?e.jsx(p.HiXMark,{className:"h-4 w-4"}):e.jsx(p.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":C??"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 ${B}`,children:ne.length>0?ne.map(Q=>{const Me=Q.service===(oe==null?void 0:oe.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":Me,disabled:Q.disabled,onClick:()=>M(Q),onKeyDown:Le=>ie(Le,Q),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:Y?Y(Q,Me):e.jsxs(e.Fragment,{children:[Q.icon,e.jsx("span",{children:Q.label??ia(Q.service)}),Q.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:Q.badge})]})},Q.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:J??"No hay modulos que coincidan con la busqueda."})}),(oe==null?void 0:oe.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:oe.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!oe&&(x??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."})),oe&&(be==null?void 0:be.loading)&&(w??e.jsx(oa,{title:"Cargando modulo..."})),oe&&(be==null?void 0:be.error)&&H(be.error,ce),oe&&Se&&!(be!=null&&be.loading)&&!(be!=null&&be.error)&&e.jsx(Se,{context:s,parent:n,link:oe,activeItemId:ke,onOpenDetail:we,onBackToList:de})]})]})]})}const qn={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(p.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(p.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(p.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(p.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(p.HiInformationCircle,{className:"h-5 w-5"})}};function Un({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:c,className:d=""}){const b=qn[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 ${d}`,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(p.HiXMark,{className:"h-4 w-4"})})]})}const da=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Vn=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Kn=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],mt=6;function ht(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function Gn(){const r=new Date;return ht(r.getFullYear(),r.getMonth()+1,r.getDate())}function ua(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Yn(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=ua(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${da[a-1]} ${t}`}function Xn({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=Gn(),d=ua(r||s),b=n==="popover",[f,h]=l.useState(!1),k=l.useRef(null),[S,m]=l.useState({horizontal:"left",vertical:"bottom"}),[C,N]=l.useState(d.year),[x,w]=l.useState(d.month),[H,Y]=l.useState("days"),D=16,[G,L]=l.useState(0),I=C-7+G,X=Array.from({length:D},(P,g)=>I+g);l.useEffect(()=>{if(!b||!f||!k.current)return;const P=k.current.getBoundingClientRect(),g=8,z=280,V=340,ae=P.left+z>window.innerWidth-g,te=P.right-z>=g,he=P.bottom+8+V>window.innerHeight-g,$=P.top-8-V>=g;m({horizontal:ae&&te?"right":"left",vertical:he&&$?"top":"bottom"})},[b,f]),l.useEffect(()=>{if(!b||!f)return;function P(z){k.current&&(k.current.contains(z.target)||h(!1))}function g(z){z.key==="Escape"&&h(!1)}return document.addEventListener("mousedown",P),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",g)}},[b,f]);function J(){x===1?(N(P=>P-1),w(12)):w(P=>P-1)}function F(){x===12?(N(P=>P+1),w(1)):w(P=>P+1)}const K=new Date(C,x-1,1).getDay(),Z=new Date(C,x,0).getDate(),E=[...Array(K).fill(null),...Array.from({length:Z},(P,g)=>g+1)];for(;E.length<mt*7;)E.push(null);const B=E.slice(0,mt*7);function _(P){const g=ht(C,x,P);a&&g<a||(t(g),b&&h(!1))}const O={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ee=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:H==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:J,style:O,title:"Mes anterior",children:e.jsx(p.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{Y("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:[da[x-1]," ",C,e.jsx(p.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:F,style:O,title:"Mes siguiente",children:e.jsx(p.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>L(P=>P-D),style:O,children:e.jsx(p.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>Y("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[X[0]," – ",X[X.length-1]]}),e.jsx("button",{type:"button",onClick:()=>L(P=>P+D),style:O,children:e.jsx(p.HiChevronRight,{size:16})})]})}),H==="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:Vn.map((P,g)=>{const z=g+1===x;return e.jsx("button",{type:"button",onClick:()=>w(g+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:z?700:400,padding:"4px 0",background:z?"var(--primary)":"transparent",color:z?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:P},P)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:X.map(P=>{const g=P===C;return e.jsx("button",{type:"button",onClick:()=>{N(P),Y("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:g?700:400,padding:"6px 0",background:g?"var(--primary)":"transparent",color:g?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:P===new Date().getFullYear()&&!g?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:P},P)})})]}),H==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Kn.map(P=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:P},P))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${mt},1fr)`,padding:"4px 8px 10px",gap:2},children:B.map((P,g)=>{if(P===null)return e.jsx("div",{style:{aspectRatio:"1"}},g);const z=ht(C,x,P),V=z===r,ae=z===s,te=!!(a&&z<a);return e.jsx("button",{type:"button",onClick:()=>!te&&_(P),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:te?"not-allowed":"pointer",fontSize:12,fontWeight:V||ae?700:400,background:V?"var(--primary)":"transparent",color:V?"var(--primary-fg, #ffffff)":te?"var(--text-muted)":"var(--text-main)",opacity:te?.4:1,outline:ae&&!V?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:P},g)})})]})]});return b?e.jsxs("div",{ref:k,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>h(P=>!P),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 ${f?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:f?"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(p.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Yn(r)})]}),e.jsx(p.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsx("div",{className:"absolute z-50",style:{...S.horizontal==="left"?{left:0}:{right:0},...S.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:ee})]}):ee}const Zn={sm:"h-4 w-4",md:"h-5 w-5"};function Jn(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Ir=l.forwardRef(function({label:t,description:a,error:n,size:s="md",indeterminate:c=!1,className:d="",containerClassName:b="",disabled:f,...h},k){const S=l.useRef(null);return l.useEffect(()=>{S.current&&(S.current.indeterminate=c)},[c]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${f?"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",{...h,ref:m=>{S.current=m,Jn(k,m)},type:"checkbox",disabled:f,"aria-checked":c?"mixed":h["aria-checked"],"aria-invalid":!!n||h["aria-invalid"],className:`peer ${Zn[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 ${d}`}),e.jsx(p.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 ba(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 Qn(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}ba(r)}function Rn(r){return typeof r=="function"?r():r}function vt({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:c=e.jsx(p.HiClipboardDocument,{size:14}),copiedIcon:d=e.jsx(p.HiCheck,{size:14}),stopPropagation:b=!0,onCopied:f,onCopyError:h,className:k="",style:S,children:m,onClick:C,type:N="button",...x}){const[w,H]=l.useState(!1),Y=l.useRef(null);l.useEffect(()=>()=>{Y.current&&window.clearTimeout(Y.current)},[]);function D(L){H(!0),f==null||f(L),Y.current&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{H(!1),Y.current=null},t)}async function G(L){var X;if(b&&L.stopPropagation(),C==null||C(L),L.defaultPrevented)return;const I=Rn(r);if(I)try{await Qn(I),D(I)}catch(J){try{ba(I),D(I)}catch(F){h==null||h(F,I);return}(X=navigator.clipboard)!=null&&X.writeText||h==null||h(J,I)}}return e.jsxs("button",{...x,type:N,onClick:G,title:w?n:a,"aria-label":x["aria-label"]??(w?n:a),"data-copied":w?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${m?"min-w-7 px-2":"w-7"} ${k}`,style:{cursor:"pointer",background:w?"rgba(22,163,74,0.15)":"var(--bg-card)",border:w?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:w?"#16a34a":"var(--text-secondary)",boxShadow:w?"0 0 0 3px rgba(22,163,74,0.12)":"none",...S},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:w?"scale(1.15)":"scale(1)"},children:w?d:c}),m&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:w?s??m:m})]})}function el({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:c="Copiado",className:d="",style:b,onCopied:f}){const h=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${d}`,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(vt,{value:h,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:c,onCopied:f,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:h})})]})}function gt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function dr({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:c="default",showSelectedSublabel:d=!0,placeholder:b="Seleccionar…",emptyLabel:f,disabled:h=!1,className:k="",style:S,dropdownMinWidth:m,height:C=40,padding:N="0 10px",searchable:x=!0,minOptionsForSearch:w=6}){const[H,Y]=l.useState(!1),[D,G]=l.useState(""),[L,I]=l.useState(-1),[X,J]=l.useState(!1),[F,K]=l.useState({}),Z=l.useRef(null),E=l.useRef(null),B=l.useRef(null),_=l.useRef(null),O=x&&a.length>=w,ee=a.find($=>$.value===r)??null,P=c==="ghost",g=n==="error"?"var(--danger)":H?"var(--primary)":"var(--border)",z=O&&D.trim()?a.filter($=>{var ue;return $.label.toLowerCase().includes(D.toLowerCase())||((ue=$.sublabel)==null?void 0:ue.toLowerCase().includes(D.toLowerCase()))}):a,V=l.useCallback(()=>{const $=Z.current;if(!$)return;const ue=$.getBoundingClientRect(),T=O?272:212,se=window.innerHeight-ue.bottom,fe=se<T&&ue.top>se;K({position:"fixed",left:ue.left,top:fe?void 0:ue.bottom+4,bottom:fe?window.innerHeight-ue.top+4:void 0,width:ue.width,minWidth:gt(m),zIndex:9999})},[m,O]);l.useEffect(()=>J(!0),[]),l.useEffect(()=>{if(!H)return;function $(ue){var se,fe;const T=ue.target;!((se=Z.current)!=null&&se.contains(T))&&!((fe=E.current)!=null&&fe.contains(T))&&(Y(!1),G(""))}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[H]),l.useEffect(()=>{H&&(I(-1),V(),O&&setTimeout(()=>{var $;return($=B.current)==null?void 0:$.focus()},0))},[H,O,V]),l.useEffect(()=>{if(H)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[H,V]),l.useEffect(()=>{if(L<0||!_.current)return;const $=_.current.children[L];$==null||$.scrollIntoView({block:"nearest"})},[L]);const ae=l.useCallback($=>{t($),Y(!1),G("")},[t]);function te($){if(!H){($.key==="Enter"||$.key===" "||$.key==="ArrowDown")&&($.preventDefault(),Y(!0));return}$.key==="Escape"?($.preventDefault(),Y(!1),G("")):$.key==="ArrowDown"?($.preventDefault(),I(ue=>Math.min(ue+1,z.length-1))):$.key==="ArrowUp"?($.preventDefault(),I(ue=>Math.max(ue-1,f?-1:0))):$.key==="Enter"&&($.preventDefault(),L===-1&&f?ae(""):z[L]&&ae(z[L].value))}const he=e.jsxs("div",{ref:E,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...F,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[O&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(p.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:B,value:D,onChange:$=>{G($.target.value),I(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),D&&e.jsx("button",{type:"button",onMouseDown:$=>{$.preventDefault(),G("")},children:e.jsx(p.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:_,role:"listbox",className:"overflow-y-auto",style:{maxHeight:O?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[f&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:$=>{$.preventDefault(),ae("")},onMouseEnter:()=>I(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:L===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:f}),z.map(($,ue)=>{const se=ue===L,fe=$.value===r;return e.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:U=>{U.preventDefault(),$.disabled||ae($.value)},onMouseEnter:()=>!$.disabled&&I(ue),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:se?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:$.disabled?"var(--text-muted)":"var(--text-main)",cursor:$.disabled?"not-allowed":"pointer",boxShadow:fe?"inset 2px 0 0 var(--primary)":void 0},children:[$.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:$.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:$.label}),$.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:$.sublabel})]}),$.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:$.badge})]},$.value)}),z.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:Z,className:`relative ${k||"w-full"}`,style:S,onKeyDown:te,children:[e.jsxs("button",{type:"button",disabled:h,onClick:()=>!h&&Y($=>!$),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:gt(C),padding:gt(N),background:P?"transparent":"var(--bg-input)",color:ee?"var(--text-main)":"var(--text-muted)",border:P?"1px solid transparent":`1px solid ${g}`,opacity:h?.5:1,cursor:h?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":H,"aria-label":s,children:[(ee==null?void 0:ee.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:ee.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:ee?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:ee.label}),d&&ee.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:ee.sublabel})]}):e.jsx("span",{className:"truncate",children:b})}),ee&&f?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:$=>{$.preventDefault(),$.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(p.HiXMark,{className:"w-3 h-3"})}):e.jsx(p.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:H?"rotate(180deg)":"rotate(0deg)"}})]}),H&&X&&ze.createPortal(he,document.body)]})}function Fr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function rl({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:c="0 10px 0 30px",iconLeft:d=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(p.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:Fr(d)}}),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:Fr(s),padding:Fr(c)}})]})}function tl({value:r,onChange:t,options:a,placeholder:n,icon:s,className:c="",height:d=40,padding:b,iconLeft:f=10,searchable:h=!0}){const k=s?a.map((S,m)=>m===0&&!S.color?{...S,sublabel:S.sublabel??void 0}:S):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:Fr(f)},children:s}),e.jsx(dr,{value:r,onChange:t,options:k,placeholder:n,searchable:h,minOptionsForSearch:5,height:d,padding:b??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const al={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Pr=180,nl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function xt({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:c,footer:d,children:b,size:f="md",maxWidth:h,zIndex:k=1e3,closeOnBackdrop:S=!0,closeOnEscape:m=!0,showCloseButton:C=!0,placement:N="center",bodyClassName:x="px-6 py-5",panelClassName:w="",backdropClassName:H=nl,contentClassName:Y="p-4",ariaLabel:D,frameless:G=!1}){const[L,I]=l.useState(!1),[X,J]=l.useState(!1),F=l.useRef(null);if(l.useEffect(()=>(r?(F.current&&clearTimeout(F.current),I(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>J(!0)))):(J(!1),F.current=setTimeout(()=>I(!1),Pr+40)),()=>{F.current&&clearTimeout(F.current)}),[r]),l.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),l.useEffect(()=>{if(!r||!m)return;const O=ee=>{ee.key==="Escape"&&t()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[m,t,r]),!L)return null;const K=a||n||s||c||C,Z=h??al[f],E=N==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",B=N==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",_=X?"translateY(0) scale(1)":N==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ze.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":D??a,className:`fixed inset-0 flex ${E} ${Y}`,style:{zIndex:k},children:[e.jsx("div",{className:`absolute inset-0 ${H}`,onClick:S?t:void 0,style:{opacity:X?1:0,transition:`opacity ${Pr}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${G?"shadow-none":"shadow-2xl"} ${B} ${w}`,style:{maxWidth:Z,background:G?"transparent":"var(--bg-card)",border:G?"none":"1px solid var(--border)",opacity:X?1:0,transform:_,transition:`opacity ${Pr}ms ease, transform ${Pr}ms ease`},onClick:O=>O.stopPropagation(),children:[K&&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,C&&e.jsx(Te,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(p.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${x}`,children:b}),d&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:d})]})]}),document.body)}const ll={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 ol({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:c="danger",onConfirm:d,onCancel:b}){const f=ll[c];return e.jsxs(xt,{open:r,onClose:b,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,children:[e.jsx(Te,{variant:"icon",onClick:b,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(p.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:f.iconBg},children:e.jsx(p.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.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:b,className:"flex-1",style:{background:"var(--bg-input)"},children:s}),e.jsx(Te,{variant:"danger",onClick:d,className:"flex-1",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:n})]})]})}function sl(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function il({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:s=e.jsx(p.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(vt,{...c,value:()=>sl(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"}],cl=jr.map(r=>({value:r.value,label:r.label})),dl=12,ul={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!1},bl="bonsaif-ui:datatable:",fl="[&_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",pl=[],ml=52;function rr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function hl(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 fa(r){return`${bl}${r}`}function pa(r){try{const t=window.localStorage.getItem(fa(r));if(!t)return null;const a=JSON.parse(t);return a&&typeof a=="object"?a:null}catch{return null}}function vl(r,t){try{window.localStorage.setItem(fa(r),JSON.stringify(t))}catch{}}function gl(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}:{...ul,...r??{}}}function zr(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function _r(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(d=>typeof d=="string");return c.length>0?[[n,c]]:[]});return Object.fromEntries(a)}function Wr(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 d=c;return!d.operator||!a.has(d.operator)?[]:[[s,{operator:d.operator,value:typeof d.value=="string"?d.value:"",valueTo:typeof d.valueTo=="string"?d.valueTo:""}]]});return Object.fromEntries(n)}function Ue(r,t){if(tr(r))return ml;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function xl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function tr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function yl(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 ar(r,t){var d;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=(d=t.find(b=>b.hideable!==!1))==null?void 0:d.key;return c?n.filter(b=>b!==c):[]}function wl(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 qr(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?wl(a):ur(a).trim()}function wr(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=wr(r),n=wr(t);return a!==null&&n!==null?a-n:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function Nl(r,t,a){var d,b;const n=((d=t.value)==null?void 0:d.trim())??"",s=((b=t.valueTo)==null?void 0:b.trim())??"",c=jr.find(f=>f.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 h=a.map(S=>({value:S,number:wr(S)})).filter(S=>S.number!==null).sort((S,m)=>S.number-m.number).map(S=>S.value);return(t.operator==="top10"?h.slice(-10):h.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const f=a.map(wr).filter(S=>S!==null);if(f.length===0)return!1;const h=f.reduce((S,m)=>S+m,0)/f.length,k=wr(r);return k===null?!1:t.operator==="aboveAverage"?k>h:k<h}default:return!0}}function ma({children:r,className:t="",style:a}){return e.jsx(cr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function kl({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:c,emptyText:d="Sin resultados",initialEmptyDelay:b=450,onRowClick:f,renderExpandedRow:h,getRowCanExpand:k,expandedRowIds:S,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:C,expandOnRowClick:N=!1,selected:x,onToggleOne:w,onToggleAll:H,highlightSelected:Y=!0,rowClassName:D,getRowCategory:G,stickyHeader:L=!0,pageSize:I=25,pageSizeOptions:X=[25,50,100],pageSizeSelectWidth:J=62,pageSizeSelectHeight:F=30,pageSizeSelectPadding:K="0 7px",totalRows:Z,page:E,onPageChange:B,onPageSizeChange:_,storageKey:O,stickyFirstColumn:ee=!1,bottomOffset:P=0,compact:g=!0,restrictHeight:z=!0,maxHeight:V,minTableWidth:ae,enableColumnVisibility:te=!0,enableColumnFilters:he=!0,hiddenColumnKeys:$,defaultHiddenColumnKeys:ue=pl,onHiddenColumnKeysChange:T,columnVisibilityLabel:se="Columnas",enableBql:fe=!1,bqlValue:U,defaultBqlValue:re="",onBqlChange:R,bqlDescription:ne="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ve=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:oe=[],bqlExamples:M=[],bqlSuggestions:W=[],bqlActiveFilters:ie,bqlError:ce,onQueryChange:ke,persistState:be,enableExport:Se=!1,exportFilename:we="datos"}){var Cn;const de=gl(be),Be=Object.values(de).some(Boolean),Ve=r.map(o=>o.key).join(","),je=ue.join(","),Q=l.useRef(r),Me=l.useRef(ue);Q.current=r,Me.current=ue;const[Le,Ie]=l.useState(!O||!Be),He=l.useRef(null),Ke=l.useRef(!O),Oe=$!==void 0,[fs,kr]=l.useState(()=>ar(ue,r)),Fe=ar(Oe?$:fs,r),[Re,Xr]=l.useState(!1),[nr,ps]=l.useState("filter"),[Sr,Zr]=l.useState(null),[Ya,Xa]=l.useState(""),[Pe,Cr]=l.useState({}),[We,Jr]=l.useState({}),Mt=S!==void 0,[Za,ms]=l.useState(m),Er=U!==void 0,[hs,Lt]=l.useState(re),Ge=Er?U:hs,[Qr,Rr]=l.useState(Ge),[Ye,lr]=l.useState(!1),[Ja,fr]=l.useState(!1),[Qa,pr]=l.useState(!1),[Mr,Lr]=l.useState([]),$t=l.useRef(null),Ra=l.useRef(null),Tt=l.useRef(null),[vs,gs]=l.useState({}),[xs,ys]=l.useState({}),[$r,et]=l.useState(!1),Ht=l.useRef(null),rt=l.useRef(null),[ws,Ns]=l.useState({}),en=l.useRef(null),tt=l.useRef(null),[At,rn]=l.useState(t.length>0||n||b===!1),tn=(o,i)=>50+(o*17+i*13+7)%40,er=l.useRef(null),[ks,Ss]=l.useState(void 0),[an,Cs]=l.useState(0),[Dt,Es]=l.useState(!1);l.useEffect(()=>{function o(){Es(window.innerWidth<640)}if(!z||V!==void 0)return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o);const y=I!==!1?48:0,u=12;function j(){if(o(),!er.current)return;const v=er.current.getBoundingClientRect().top;Ss(Math.max(120,window.innerHeight-v-y-u-P))}return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[n,I,P,z,V]);const Bt=z?V??ks:void 0;l.useEffect(()=>{const o=er.current;if(!o)return;const i=()=>Cs(o.clientWidth);if(i(),typeof ResizeObserver>"u")return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i);const y=new ResizeObserver(i);return y.observe(o),()=>y.disconnect()},[n,Le,t.length]),l.useEffect(()=>{if(b===!1||n||t.length>0){rn(!0);return}if(At)return;const o=window.setTimeout(()=>{rn(!0)},b);return()=>window.clearTimeout(o)},[t.length,b,At,n]);const[mr,Tr]=l.useState(()=>r.map(o=>o.key)),[hr,Hr]=l.useState(()=>Object.fromEntries(r.map(o=>[o.key,Ue(o,rr(o.width))]))),[Ce,vr]=l.useState(null),[Ms,at]=l.useState(1),[nt,Ot]=l.useState(I===!1?0:I);l.useEffect(()=>{const o=Q.current,i=Me.current,y=o.map(v=>v.key),u=new Set(y);if(!O||!Be){de.layout&&Tr(y),Oe||kr(ar(i,o)),Ke.current=!1,Ie(!0);return}let j=!1;return Ke.current=!1,Ie(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(O)}`,{cache:"no-store"}).then(v=>v.ok?v.json():null).then(v=>{if(j)return;const le=pa(O),A=hl(v==null?void 0:v.settings)?v==null?void 0:v.settings:le,Ee=de.layout?A==null?void 0:A.columnOrder:void 0,Ne=Array.isArray(Ee)?Ee.filter($e=>y.includes($e)):[],pe=y.filter($e=>!Ne.includes($e)),ge=Ne.length>0?[...Ne,...pe]:y,me=Object.fromEntries(o.map($e=>[$e.key,Ue($e,rr($e.width))])),Ae=de.layout?(A==null?void 0:A.columnWidths)??{}:{},xe=Object.fromEntries(o.map($e=>[$e.key,Ue($e,Ae[$e.key]??me[$e.key])])),ft=ar(de.layout?(A==null?void 0:A.hiddenColumnKeys)??i:i,o);if(de.layout&&(Tr(ge),Hr(xe)),Oe||kr(ft),de.filters&&(Cr(_r(A==null?void 0:A.filters,u)),Jr(Wr(A==null?void 0:A.conditionFilters,u))),de.sort){const $e=zr(A==null?void 0:A.sort)?A.sort:null;vr($e&&u.has($e.key)?$e:null)}if(de.bql){const $e=typeof(A==null?void 0:A.bql)=="string"?A.bql:re;Er?R==null||R($e):Lt($e)}de.bql&&Lr(Array.isArray(A==null?void 0:A.bqlHistory)?A.bqlHistory.filter($e=>typeof $e=="string"):[]),de.pagination&&typeof(A==null?void 0:A.pageSize)=="number"&&A.pageSize>0&&Ot(A.pageSize),He.current=JSON.stringify({columnOrder:ge,columnWidths:xe,hiddenColumnKeys:ft,filters:_r(A==null?void 0:A.filters,u),conditionFilters:Wr(A==null?void 0:A.conditionFilters,u),sort:zr(A==null?void 0:A.sort)?A.sort:null,bql:typeof(A==null?void 0:A.bql)=="string"?A.bql:"",bqlHistory:Array.isArray(A==null?void 0:A.bqlHistory)?A.bqlHistory:[],pageSize:typeof(A==null?void 0:A.pageSize)=="number"?A.pageSize:void 0}),Ke.current=!0}).catch(()=>{if(!j){const v=pa(O),le=de.layout?v==null?void 0:v.columnOrder:void 0,A=Array.isArray(le)?le.filter(xe=>y.includes(xe)):[],Ee=y.filter(xe=>!A.includes(xe)),Ne=A.length>0?[...A,...Ee]:y,pe=Object.fromEntries(o.map(xe=>[xe.key,Ue(xe,rr(xe.width))])),ge=de.layout?(v==null?void 0:v.columnWidths)??{}:{},me=Object.fromEntries(o.map(xe=>[xe.key,Ue(xe,ge[xe.key]??pe[xe.key])]));de.layout&&(Tr(Ne),Hr(me));const Ae=ar(de.layout?(v==null?void 0:v.hiddenColumnKeys)??i:i,o);if(Oe||kr(Ae),de.filters&&(Cr(_r(v==null?void 0:v.filters,u)),Jr(Wr(v==null?void 0:v.conditionFilters,u))),de.sort){const xe=zr(v==null?void 0:v.sort)?v.sort:null;vr(xe&&u.has(xe.key)?xe:null)}if(de.bql){const xe=typeof(v==null?void 0:v.bql)=="string"?v.bql:re;Er?R==null||R(xe):Lt(xe)}de.bql&&Lr(Array.isArray(v==null?void 0:v.bqlHistory)?v.bqlHistory.filter(xe=>typeof xe=="string"):[]),de.pagination&&typeof(v==null?void 0:v.pageSize)=="number"&&v.pageSize>0&&Ot(v.pageSize),He.current=JSON.stringify({columnOrder:Ne,columnWidths:me,hiddenColumnKeys:Ae,filters:_r(v==null?void 0:v.filters,u),conditionFilters:Wr(v==null?void 0:v.conditionFilters,u),sort:zr(v==null?void 0:v.sort)?v.sort:null,bql:typeof(v==null?void 0:v.bql)=="string"?v.bql:"",bqlHistory:Array.isArray(v==null?void 0:v.bqlHistory)?v.bqlHistory:[],pageSize:typeof(v==null?void 0:v.pageSize)=="number"?v.pageSize:void 0}),Ke.current=!0}}).finally(()=>{j||Ie(!0)}),()=>{j=!0}},[O,Be,Ve,je,Oe,de.layout,de.filters,de.sort,de.bql,de.pagination,Er,R,re]),l.useEffect(()=>{if(!O||!Le||!Be||!Ke.current)return;const o={};de.layout&&(o.columnOrder=mr,o.columnWidths=hr,o.hiddenColumnKeys=Fe),de.filters&&(o.filters=Pe,o.conditionFilters=We),de.sort&&(o.sort=Ce),de.bql&&(o.bql=Ge,o.bqlHistory=Mr),de.pagination&&I!==!1&&(o.pageSize=nt);const i=JSON.stringify(o);if(i===He.current)return;vl(O,o),He.current=i;const y=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:O,settings:o})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(y)},[mr,hr,Fe,Pe,We,Ce,Ge,Mr,nt,I,O,Le,Be,de.layout,de.filters,de.sort,de.bql,de.pagination]),l.useEffect(()=>{Tr(o=>{const i=r.map(j=>j.key),y=o.filter(j=>i.includes(j)),u=i.filter(j=>!y.includes(j));return[...y,...u]})},[Ve,r]);const nn=mr.map(o=>r.find(i=>i.key===o)).filter(o=>!!o),Xe=nn.filter(o=>!Fe.includes(o.key)),Ls=Object.keys(Pe).length,$s=Object.keys(We).length,It=Ls+$s;function ln(o){const i=new Set;return t.reduce((y,u)=>{const j=qr(o,u);return!j||i.has(j)||(i.add(j),y.push({value:j,label:j})),y},[])}function Ts(){const o=r.find(i=>i.key===Sr);return o?ln(o):[]}function Hs(o){return!!(he&&!tr(o)&&(o.filterValue||o.sortKey||ln(o).length>0))}function on(o,i){Cr(y=>{const u={...y};return u[o]=i,u})}function As(o,i,y,u){const j=Pe[o]??[],v=u?j:y.filter(A=>A!==i),le=u?j.includes(i)?j.filter(A=>A!==i):[...j,i]:v;le.length===y.length?Ft(o):on(o,le)}function Ft(o){Cr(i=>{const y={...i};return delete y[o],y})}function lt(o,i){Jr(y=>{const u={...y};return i?u[o]=i:delete u[o],u})}function sn(o){lt(o,null)}function Ds(){Cr({}),Jr({})}function cn(o){Er||Lt(o),R==null||R(o)}function ot(o){const i=o.trim();Rr(i),cn(i),lr(!1),fr(!1),pr(!1),i&&Lr(y=>[i,...y.filter(u=>u!==i)].slice(0,dl))}function dn(){Rr(""),cn(""),lr(!1),fr(!1),pr(!1)}function Pt(o,i){Rr(o),i&&(i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight,180)}px`)}l.useEffect(()=>{Rr(Ge)},[Ge]);const st=l.useCallback(()=>{const o=$t.current;if(!o)return;const i=o.getBoundingClientRect(),y=12,u=8,j=Math.min(780,Math.max(320,window.innerWidth-32)),v=Math.max(y,window.innerWidth-j-y),le=Math.min(Math.max(y,i.left),v),A=i.bottom+u,Ee=window.innerHeight-i.top+u,Ne=window.innerHeight-A-y,pe=i.top-y-u,ge=Ne<280&&pe>Ne,me=Math.max(240,ge?pe:Ne);gs({position:"fixed",zIndex:1e4,left:le,top:ge?void 0:A,bottom:ge?Ee:void 0,width:j,maxWidth:"calc(100vw - 24px)",maxHeight:me,overflowY:"auto"})},[]);l.useEffect(()=>{if(!Ye)return;function o(u){var v,le;const j=u.target;(v=$t.current)!=null&&v.contains(j)||(le=Ra.current)!=null&&le.contains(j)||(lr(!1),fr(!1),pr(!1))}function i(u){u.key==="Escape"&&(lr(!1),fr(!1),pr(!1))}function y(){st()}return st(),document.addEventListener("mousedown",o),window.addEventListener("keydown",i),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",i),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[Ye,st]);function un(o){const i=ar(o,r);Oe||kr(i),T==null||T(i)}function Bs(o){un(Fe.includes(o)?Fe.filter(i=>i!==o):[...Fe,o])}function Os(){un([])}const jt=l.useCallback((o=tt.current)=>{if(!o)return;const i=o.getBoundingClientRect(),y=Math.min(292,Math.max(240,window.innerWidth-16)),u=Math.max(8,window.innerWidth-y-8),j=Math.min(Math.max(8,i.right-y),u),v=window.innerHeight-i.bottom,le=i.bottom+6,A=window.innerHeight-i.top+6,Ne=v<360&&i.top>v?void 0:le,pe=Ne===void 0?A:void 0,ge=Math.max(220,Ne===void 0?i.top-16:window.innerHeight-le-8),me={position:"fixed",zIndex:9999,left:j,top:Ne,bottom:pe,width:y,maxWidth:"calc(100vw - 16px)",maxHeight:ge,"--dt-column-menu-max-height":`${ge}px`};ys(me)},[]);function bn(o,i,y=null){o.preventDefault(),o.stopPropagation();const u=tt.current===o.currentTarget&&nr===i&&Sr===y;if(Re&&u){Xr(!1),Zr(null);return}tt.current=o.currentTarget,ps(i),Zr(y),Xa(""),jt(o.currentTarget),Xr(!0)}function Is(o){if(tr(o))return;const i=er.current;if(!i)return;const u=Array.from(i.querySelectorAll("[data-dt-column-key]")).filter(j=>j.dataset.dtColumnKey===o.key).reduce((j,v)=>{const le=v.querySelector("[data-dt-autofit-content]"),A=le?le.scrollWidth:Math.max(v.scrollWidth,v.offsetWidth);return Math.max(j,Math.ceil(A+xl(v)))},0);u<=0||Hr(j=>({...j,[o.key]:Ue(o,u+12)}))}l.useEffect(()=>{Hr(o=>{const i=Object.fromEntries(r.map(y=>[y.key,Ue(y,rr(y.width))]));return Object.fromEntries(r.map(y=>[y.key,Ue(y,o[y.key]??i[y.key])]))})},[Ve,r]),l.useEffect(()=>{Oe||kr(o=>ar(o,r))},[Ve,r,Oe]),l.useEffect(()=>{function o(u){var le,A;const j=u.target,v=u.target;v!=null&&v.closest("[data-bonsaif-select-dropdown='true']")||!((le=en.current)!=null&&le.contains(j))&&!((A=tt.current)!=null&&A.contains(j))&&(Xr(!1),Zr(null))}function i(u){u.key==="Escape"&&(Xr(!1),Zr(null))}function y(){jt()}return Re&&(document.addEventListener("mousedown",o),window.addEventListener("keydown",i),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0)),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",i),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[Re,jt]);const Ar=l.useRef(null);l.useEffect(()=>{function o(y){const u=Ar.current;if(!u)return;const j=y.clientX-u.startX,v=r.find(le=>le.key===u.colKey);v&&Hr(le=>({...le,[u.colKey]:Ue(v,u.startWidth+j)}))}function i(){Ar.current&&(Ar.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i)}},[r]);const it=l.useRef(null),[fn,zt]=l.useState(null);function Fs(o,i){it.current=mr.indexOf(o),i.dataTransfer.effectAllowed="move"}function Ps(o,i){i.preventDefault(),i.dataTransfer.dropEffect="move";const y=mr.indexOf(o);fn!==y&&zt(y)}function js(o,i){i.preventDefault();const y=it.current,u=mr.indexOf(o);y!==null&&y!==u&&Tr(j=>{const v=[...j],[le]=v.splice(y,1);return v.splice(u,0,le),v}),it.current=null,zt(null)}function zs(){it.current=null,zt(null)}function _s(o){o.sortKey&&vr(i=>(i==null?void 0:i.key)===o.key?{key:o.key,dir:i.dir==="asc"?"desc":"asc"}:{key:o.key,dir:"asc"})}l.useEffect(()=>{at(1)},[t]),l.useEffect(()=>{at(1)},[We,Pe]);const or=!!(B&&_),sr=I!==!1,De=or?E??1:Ms,qe=or||sr?nt:t.length,Ze=!!x&&!!w&&!!H,gr=!!h,pn=l.useMemo(()=>new Set(Mt?Array.from(S??[]):Za),[Mt,S,Za]),_t=(gr?40:0)+(Ze?40:0),Ws=Ze&&t.length>0&&x.size===t.length,qs=Ze&&x.size>0&&x.size<t.length,ct=l.useMemo(()=>{const o=Object.entries(Pe),i=Object.entries(We);return o.length===0&&i.length===0?t:t.filter(y=>o.every(([u,j])=>{const v=r.find(le=>le.key===u);return v?j.includes(qr(v,y)):!0})&&i.every(([u,j])=>{const v=r.find(A=>A.key===u);if(!v)return!0;const le=t.map(A=>qr(v,A));return Nl(qr(v,y),j,le)}))},[We,Pe,r,t]),ir=l.useMemo(()=>{if(!Ce)return ct;const o=r.find(i=>i.key===Ce.key&&i.sortKey);return o!=null&&o.sortKey?[...ct].sort((i,y)=>{const u=i[o.sortKey],j=y[o.sortKey],v=u===j?0:u==null?1:j==null||u<j?-1:1;return Ce.dir==="asc"?v:-v}):ct},[ct,Ce,r]),mn=l.useMemo(()=>{if(or||!sr)return ir;const o=(De-1)*qe;return ir.slice(o,o+qe)},[ir,or,sr,De,qe]),xr=or?Z??t.length:ir.length,Wt=sr?Math.max(1,Math.ceil(xr/qe)):1,Us=sr&&xr>qe,Vs=sr?(De-1)*qe+1:1,Ks=sr?Math.min(De*qe,xr):xr;function qt(o){if(n)return;const i=Math.max(1,Math.min(o,Wt));or?B(i):at(i)}function Gs(o){n||(Ot(o),or?(_(o),B(1)):at(1),_&&_(o))}function hn(o){const i=new Set(pn);i.has(o)?i.delete(o):i.add(o);const y=Array.from(i);Mt||ms(y),C==null||C(y)}l.useEffect(()=>{ke==null||ke({bql:Ge,filters:Pe,conditionFilters:We,sort:Ce,page:De,pageSize:qe,hiddenColumnKeys:Fe})},[Ge,Pe,We,Ce,De,qe,Fe,ke]);const vn=o=>o==="center"?"text-center":o==="right"?"text-right":"text-left",Ys="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Ut="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%)",ye="color-mix(in srgb, var(--border) 62%, var(--bg-card))",yr="color-mix(in srgb, var(--primary) 24%, var(--border))",dt=`inset 0 0 0 1px ${ye}`,gn=Xe.reduce((o,i)=>o+(hr[i.key]??rr(i.width)),(gr?40:0)+(Ze?40:0)),xn=typeof ae=="number"?ae:typeof ae=="string"?Number(((Cn=ae.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Cn[1])??NaN):NaN,ut=Number.isFinite(xn)?Math.max(gn,xn,an):Math.max(gn,an),Vt=ae??ut,Dr=`${gr?"40px ":""}${Ze?"40px ":""}${Xe.map(o=>`${hr[o.key]??rr(o.width)}px`).join(" ")}`;l.useEffect(()=>{Ce&&Fe.includes(Ce.key)&&vr(null)},[Fe,Ce]);function yn(o){return o?typeof o=="string"?{key:o,label:o}:o:null}const Kt=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Dr,background:Ut,borderBottom:`1px solid ${yr}`},children:[gr&&e.jsx("div",{role:"columnheader",className:`${g?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${ye}`}}),Ze&&e.jsx("div",{role:"columnheader",className:`${g?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:ee?{position:"sticky",left:0,zIndex:12,background:Ut,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${ye}`}:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${ye}`},children:e.jsx(Ir,{size:"sm",checked:Ws,indeterminate:qs,onChange:H,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Xe.map((o,i)=>{const y=(Ce==null?void 0:Ce.key)===o.key,u=!!o.sortKey,j=tr(o),v=ee&&!Dt&&i===0,le=fn===i,Ee=(hr[o.key]??rr(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":vn(o.align)}`,style:{...v?{position:"sticky",left:_t,zIndex:12,background:Ut,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 ${ye}`}:{position:"relative",borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${ye}`},color:y?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:le?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:j?g?"7px 6px":"9px 8px":g?"8px 6px 10px":"10px 8px 12px"},onDragOver:pe=>Ps(o.key,pe),onDrop:pe=>js(o.key,pe),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${j?"justify-center":Ee?"justify-start":o.align==="center"?"justify-center":o.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:pe=>{pe.stopPropagation(),Fs(o.key,pe)},onDragEnd:pe=>{pe.stopPropagation(),zs()},onClick:pe=>pe.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 ${le?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),j?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(p.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(ma,{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 ${g?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:o.header})})}),u&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(o.header)}`,title:"Ordenar",onClick:pe=>{pe.stopPropagation(),_s(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 ${y?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:y?Ce.dir==="asc"?e.jsx(p.HiChevronUp,{className:"h-3 w-3"}):e.jsx(p.HiChevronDown,{className:"h-3 w-3"}):e.jsx(p.HiChevronUpDown,{className:"h-3 w-3"})}),he&&!j&&Hs(o)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&Sr===o.key,"aria-label":`Filtrar ${String(o.header)}`,title:"Filtrar",onClick:pe=>bn(pe,"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&&nr==="filter"&&Sr===o.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Ne?"text-[var(--primary)] opacity-100":""}`,children:Ne?e.jsx(p.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(p.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!j&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:pe=>{pe.preventDefault(),pe.stopPropagation(),Ar.current={colKey:o.key,startX:pe.clientX,startWidth:hr[o.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:pe=>{pe.preventDefault(),pe.stopPropagation(),Ar.current=null,document.body.style.cursor="",document.body.style.userSelect="",Is(o)},onClick:pe=>pe.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",style:{right:0,width:8,cursor:"col-resize",zIndex:6},children:e.jsx("span",{style:{width:3,height:"calc(100% - 8px)",borderRadius:2,background:"var(--primary)",display:"block"}})})]},o.key)})]}),Gt=()=>{if(!Re||typeof document>"u"||nr==="visibility"&&!te||nr==="filter"&&!he)return null;const o=r.find(me=>me.key===Sr),i=Ts(),y=o?Object.prototype.hasOwnProperty.call(Pe,o.key):!1,u=o?We[o.key]:void 0,j=jr.find(me=>me.value===(u==null?void 0:u.operator)),v=o?Pe[o.key]??[]:[],le=Ya.trim().toLowerCase(),A=le?i.filter(me=>me.label.toLowerCase().includes(le)):i,Ee=o&&i.length>0&&(!y||v.length===i.length),Ne=o&&y&&v.length>0&&v.length<i.length,pe=Fe.length,ge=()=>{o&&(Ft(o.key),sn(o.key))};return ze.createPortal(e.jsx("div",{ref:en,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...xs,borderColor:"var(--border)",background:"var(--bg-card)"},children:nr==="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:pe>0?`${Xe.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:Os,disabled:pe===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:nn.map(me=>{const Ae=!Fe.includes(me.key),ft=!(me.hideable!==!1)||Ae&&Xe.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,disabled:ft,onClick:()=>Bs(me.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:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&e.jsx(p.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:me.header})]},me.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:!y&&!u,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(p.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(p.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(p.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(p.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(dr,{value:(u==null?void 0:u.operator)??"",onChange:me=>{if(!me){sn(o.key);return}lt(o.key,{operator:me,value:(u==null?void 0:u.value)??"",valueTo:(u==null?void 0:u.valueTo)??""})},options:cl,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"}),(j==null?void 0:j.valueMode)!=="none"?e.jsx("input",{value:(u==null?void 0:u.value)??"",onChange:me=>{u&<(o.key,{...u,value:me.target.value})},disabled:!u,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"})]}),(j==null?void 0:j.valueMode)==="between"&&e.jsx("input",{value:(u==null?void 0:u.valueTo)??"",onChange:me=>{u&<(o.key,{...u,valueTo:me.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(p.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Ya,onChange:me=>Xa(me.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&&!y?on(o.key,[]):Ft(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(p.HiMinus,{className:"h-3 w-3"}),Ee&&!Ne&&e.jsx(p.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),A.map(me=>{const Ae=!y||v.includes(me.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,onClick:()=>As(o.key,me.value,i.map(xe=>xe.value),y),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:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&e.jsx(p.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:me.label})]},me.value)}),A.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(!$r)return;function o(i){Ht.current&&!Ht.current.contains(i.target)&&rt.current&&!rt.current.contains(i.target)&&et(!1)}return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[$r]);function wn(o,i){if(o.filterValue){const y=o.filterValue(i);return y==null||y===""?"":String(y)}return ur(o.cell(i))}function Nn(o){return`"${o.replace(/"/g,'""')}"`}function bt(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Xs(){const o=Xe.filter(A=>!tr(A)),i=o.map(A=>Nn(ur(A.header))).join(","),y=ir.map(A=>o.map(Ee=>Nn(wn(Ee,A))).join(",")).join(`
|
|
1
|
+
(function(q,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):(q=typeof globalThis<"u"?globalThis:q||self,l(q.BonsaifUI={},q.React,q.jsxRuntime,q.ReactIconsHi2,q.ReactDOM,q.OverlayScrollbarsGlobal,q.Sonner,q.OverlayScrollbarsReact,q.ReactDayPicker,q.ReactDayPickerStyles,q.ReactIconsFi))})(this,(function(q,l,e,p,je,Zt,Jt,Qt,Rt,Js,En){"use strict";"use client";function Je(...r){return r.filter(Boolean).join(" ")}function Mn({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:d,size:b="default",inputTabIndex:f}){const m=l.useRef(null),[k,S]=l.useState(!1),h=c||k||r.trim().length>0,C=b==="sm"?"h-9 rounded-md":"h-10 rounded-lg",N=n||"w-48 max-w-full sm:w-64 lg:w-72";l.useEffect(()=>{var w;s&&((w=m.current)==null||w.focus())},[s]);const g=()=>{var w;S(!0),(w=m.current)==null||w.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${h?N:"w-24 sm:w-28"}`,onMouseDown:w=>{h||(w.preventDefault(),g())},children:[e.jsx(p.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:f,"aria-label":a,value:r,onChange:w=>t(w.target.value),onKeyDown:w=>{w.key==="Escape"&&(d==null||d())},placeholder:h?a:"Buscar",className:`${C} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${h?"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:h?"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:w=>{S(!0),w.currentTarget.style.borderColor="var(--primary)",w.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:w=>{S(!1),w.currentTarget.style.borderColor="var(--border)",w.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(p.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 Or(r=700){ta=Date.now()+r}function Ln(){return Date.now()>ta}function Ir(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 $n(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 cr({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:c="bottom",showArrow:d=!1,className:b="",tooltipClassName:f="",style:m,tooltipStyle:k,as:S="div"}){const h=l.useRef(null),C=l.useRef(null),N=l.useRef(null),g=l.useRef(!1),[w,H]=l.useState(null),[Y,D]=l.useState("");l.useEffect(()=>{const E=h.current;E&&(E.querySelectorAll("[title]").forEach(B=>{const _=B.getAttribute("title");_&&(B.getAttribute("aria-label")||B.setAttribute("aria-label",_),B.removeAttribute("title"))}),E.querySelectorAll("svg title").forEach(B=>B.remove()))}),l.useLayoutEffect(()=>{if(!w)return;const E=C.current;if(!E)return;const B=12,_=14,O=E.getBoundingClientRect(),ee=window.innerWidth-O.width-B,P=window.innerHeight-O.height-B;let v=w.mouseX+_,j=w.mouseY+_,V,ae;if(!s&&h.current){const te=h.current.getBoundingClientRect(),he=te.left+te.width/2,$=te.top+te.height/2;c==="top"?(v=he-O.width/2,j=te.top-O.height-_,ae=O.height-1):c==="left"?(v=te.left-O.width-_,j=$-O.height/2,V=O.width-1):c==="right"?(v=te.right+_,j=$-O.height/2,V=-7):(v=he-O.width/2,j=te.bottom+_,ae=-7)}if(s&&(v>ee&&(v=w.mouseX-O.width-_),j>P&&(j=w.mouseY-O.height-_)),v=Math.min(Math.max(B,v),Math.max(B,ee)),j=Math.min(Math.max(B,j),Math.max(B,P)),!s&&h.current){const te=h.current.getBoundingClientRect(),he=te.left+te.width/2,$=te.top+te.height/2;c==="top"||c==="bottom"?V=Math.min(Math.max(14,he-v),O.width-14):ae=Math.min(Math.max(14,$-j),O.height-14)}(Math.abs(v-w.x)>.5||Math.abs(j-w.y)>.5||V!==w.arrowX||ae!==w.arrowY)&&H(te=>te&&{...te,x:v,y:j,arrowX:V,arrowY:ae})},[s,c,w]);const G=()=>{N.current&&(window.clearTimeout(N.current),N.current=null)},M=(E,B)=>{if(!Ln()||g.current)return;const _=h.current;if(_&&!Ir(_)){if(a){const O=$n(_);if(!O)return;D(O)}!a&&!t||H({mouseX:E,mouseY:B,x:E+14,y:B+14})}},I=()=>{const E=h.current;if(!E)return;const B=E.getBoundingClientRect();M(B.left+B.width/2,B.bottom)},X=()=>{G(),H(null)},J=()=>{if(!n){X();return}G(),N.current=window.setTimeout(()=>H(null),120)},F=()=>{Or(),g.current=!0,X()},K=()=>{g.current=!1};l.useEffect(()=>{if(!w)return;if(Ir(h.current)){H(null);return}const E=()=>H(null),B=()=>{Or(),g.current=!0,H(null)};document.addEventListener("pointerdown",B,!0),document.addEventListener("click",B,!0),document.addEventListener("scroll",E,!0),window.addEventListener("blur",E),document.addEventListener("visibilitychange",E),document.addEventListener("keydown",E,!0);const _=new MutationObserver(()=>{Ir(h.current)&&H(null)});return _.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",B,!0),document.removeEventListener("click",B,!0),document.removeEventListener("scroll",E,!0),window.removeEventListener("blur",E),document.removeEventListener("visibilitychange",E),document.removeEventListener("keydown",E,!0),_.disconnect()}},[w]),l.useEffect(()=>{const E=()=>Or(),B=()=>{Or(),g.current=!0,H(null)};return document.addEventListener("pointerdown",E,!0),document.addEventListener("click",E,!0),document.addEventListener("keydown",E,!0),window.addEventListener(aa,B),()=>{document.removeEventListener("pointerdown",E,!0),document.removeEventListener("click",E,!0),document.removeEventListener("keydown",E,!0),window.removeEventListener(aa,B)}},[]);const Z=a?Y:t;return e.jsxs(e.Fragment,{children:[e.jsx(S,{ref:E=>{h.current=E},className:b,style:m,onMouseEnter:E=>{G(),K(),s?M(E.clientX,E.clientY):I()},onMouseMove:E=>{w&&s&&M(E.clientX,E.clientY)},onMouseDown:F,onClick:F,onMouseLeave:()=>{K(),J()},onFocus:I,onBlur:X,children:r}),w&&Z&&!Ir(h.current)?je.createPortal(e.jsxs("div",{ref:C,role:"tooltip",className:f,onMouseEnter:n?G:void 0,onMouseLeave:n?J:void 0,style:{position:"fixed",top:w.y,left:w.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",...k},children:[d&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(k==null?void 0:k.background)??"var(--bg-card)",borderLeft:c==="right"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,borderTop:c==="bottom"||c==="right"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,borderRight:c==="left"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,borderBottom:c==="top"||c==="left"?(k==null?void 0:k.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:w.arrowX===void 0?void 0:w.arrowX-6,top:w.arrowY===void 0?void 0:w.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function na(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Tn="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",Hn={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"},An="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",Dn={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"},Bn={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},On={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function gt(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(gt).join(" ").trim():l.isValidElement(r)?gt(r.props.children):""}function In(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:d,padding:b,children:f,className:m="",disabled:k,style:S,...h}){const C=l.useContext(ra),N=c??C.iconOnly??r==="icon",g=C.compact??!1,w=C.headerAction??!1,H=w&&t==="md"?"sm":g&&!w&&t==="md"?"xs":t,Y=r==="icon"||N,D=w&&Y,G=gt(f),M=s??h.title??h["aria-label"]??(N?G:void 0),I=M?void 0:h.title,X=h["aria-label"]??(typeof M=="string"?M:G||void 0),J=a?null:n??(N?In(f):null),F=e.jsxs("button",{...h,title:I,"aria-label":X,"data-variant":r,"data-size":H,"data-icon":Y?"true":void 0,disabled:k||a,className:`${Tn} ${D?An:Hn[r]} ${Y?Bn[H]:Dn[H]} ${g&&!Y?"px-2.5":""} ${m}`,style:{...On[r],height:na(d),padding:na(b),...S,...w&&!Y?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...D?{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"}):J,!N&&f]});return M?e.jsx(cr,{as:"span",content:M,className:"inline-flex shrink-0",children:F}):F}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(Fn,{rows:a}):r==="cards"?e.jsx(Pn,{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 Fn({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 Pn({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,d)=>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+d*11)%36}%`}})},d))},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 zn(r){return[r.label,sa(r.service),r.description,r.service].filter(Boolean).join(" ")}function jn(r){return typeof r=="function"?r:r.default}function _n(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 Wn({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:c,moduleRegistry:d,loadModule:b,activeService:f,initialService:m,onActiveServiceChange:k,canAccess:S,keepAlive:h=!0,title:C,subtitle:N,emptyState:g,loadingState:w,errorState:H=_n,renderTabLabel:Y,searchableTabs:D="auto",tabsSearchThreshold:G=6,tabsSearchPlaceholder:M="Buscar modulo...",tabsSearchValue:I,onTabsSearchChange:X,emptySearchState:J,showTabCount:F=!0,className:K="",parentClassName:Z="",contentClassName:E="",tabsClassName:B=""}){var ze;const _=l.useMemo(()=>c.filter(Q=>!Q.hidden&&((S==null?void 0:S(Q,s))??!0)),[S,s,c]),O=(ze=_.find(Q=>!Q.disabled))==null?void 0:ze.service,[ee,P]=l.useState(m??O??""),[v,j]=l.useState({}),[V,ae]=l.useState({}),[te,he]=l.useState(""),[$,ue]=l.useState(!1),T=l.useRef(V),se=l.useRef(0),fe=I??te,U=ia(fe),re=D===!0||D==="auto"&&_.length>=G,R=re&&fe.trim().length>0,ne=l.useMemo(()=>U?_.filter(Q=>ia(zn(Q)).includes(U)):_,[U,_]),ve=f??ee,oe=_.find(Q=>Q.service===ve)??_.find(Q=>!Q.disabled);l.useEffect(()=>{!oe&&O&&P(O)},[O,oe]),l.useEffect(()=>{T.current=V},[V]);const L=Q=>{Q.disabled||(f||P(Q.service),k==null||k(Q.service,Q))},W=Q=>{I===void 0&&he(Q),X==null||X(Q)},ie=(Q,Me)=>{const Le=ne.filter(He=>!He.disabled),Ie=Le.findIndex(He=>He.service===Me.service);Ie<0||((Q.key==="ArrowRight"||Q.key==="ArrowDown")&&(Q.preventDefault(),L(Le[(Ie+1)%Le.length])),(Q.key==="ArrowLeft"||Q.key==="ArrowUp")&&(Q.preventDefault(),L(Le[(Ie-1+Le.length)%Le.length])),Q.key==="Home"&&(Q.preventDefault(),L(Le[0])),Q.key==="End"&&(Q.preventDefault(),L(Le[Le.length-1])))},ce=l.useCallback(()=>{if(!oe)return;const Q=oe.service,Me=T.current[Q];if(Me!=null&&Me.loading||Me!=null&&Me.component&&h)return;const Le=(d==null?void 0:d[Q])??b;if(!Le){ae(He=>({...He,[Q]:{loading:!1,error:new Error(`No module loader found for service "${Q}".`)}}));return}const Ie=++se.current;ae(He=>({...He,[Q]:{...He[Q],loading:!0,error:void 0}})),Le(oe,s).then(He=>{if(Ie!==se.current&&!h)return;const Ye=jn(He);ae(Oe=>({...Oe,[Q]:{component:Ye,loading:!1}}))}).catch(He=>{const Ye=He instanceof Error?He:new Error(String(He));ae(Oe=>({...Oe,[Q]:{...Oe[Q],loading:!1,error:Ye}}))})},[s,h,b,d,oe]);l.useEffect(ce,[ce]);const ke=oe?v[oe.service]??null:null,be=oe?V[oe.service]:void 0,Se=be==null?void 0:be.component,we=Q=>{oe&&j(Me=>({...Me,[oe.service]:Q}))},de=()=>{oe&&j(Q=>({...Q,[oe.service]:null}))},Be={context:s,parent:n,links:c,visibleLinks:_,filteredLinks:ne,selectedLink:oe,selectedService:oe==null?void 0:oe.service,activeItemId:ke,tabsSearch:fe,onSelectService:L,onOpenDetail:we,onBackToList:de},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)] ${K}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Ge}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${E}`,children:[(C||N||re||F)&&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:[C&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:C}),N&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:N})]}),(re||F)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[F&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[ne.length," / ",_.length]}),re&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${$?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!$,children:e.jsx(ea,{value:fe,onChange:W,placeholder:M,className:"w-full",autoFocus:$,forceExpanded:!0,onEscape:()=>ue(!1),size:"sm",inputTabIndex:$?0:-1})}),e.jsx("button",{type:"button","aria-label":$?"Cerrar busqueda":"Buscar tabs","aria-expanded":$,onClick:()=>{$&&fe&&W(""),ue(Q=>!Q)},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 ${$||R?"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:$||R?e.jsx(p.HiXMark,{className:"h-4 w-4"}):e.jsx(p.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":C??"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 ${B}`,children:ne.length>0?ne.map(Q=>{const Me=Q.service===(oe==null?void 0:oe.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":Me,disabled:Q.disabled,onClick:()=>L(Q),onKeyDown:Le=>ie(Le,Q),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:Y?Y(Q,Me):e.jsxs(e.Fragment,{children:[Q.icon,e.jsx("span",{children:Q.label??sa(Q.service)}),Q.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:Q.badge})]})},Q.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:J??"No hay modulos que coincidan con la busqueda."})}),(oe==null?void 0:oe.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:oe.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!oe&&(g??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."})),oe&&(be==null?void 0:be.loading)&&(w??e.jsx(la,{title:"Cargando modulo..."})),oe&&(be==null?void 0:be.error)&&H(be.error,ce),oe&&Se&&!(be!=null&&be.loading)&&!(be!=null&&be.error)&&e.jsx(Se,{context:s,parent:n,link:oe,activeItemId:ke,onOpenDetail:we,onBackToList:de})]})]})]})}const qn={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(p.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(p.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(p.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(p.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(p.HiInformationCircle,{className:"h-5 w-5"})}};function Un({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:c,className:d=""}){const b=qn[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 ${d}`,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(p.HiXMark,{className:"h-4 w-4"})})]})}const ca=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Vn=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Kn=["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 Gn(){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 Yn(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 Xn({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=Gn(),d=da(r||s),b=n==="popover",[f,m]=l.useState(!1),k=l.useRef(null),[S,h]=l.useState({horizontal:"left",vertical:"bottom"}),[C,N]=l.useState(d.year),[g,w]=l.useState(d.month),[H,Y]=l.useState("days"),D=16,[G,M]=l.useState(0),I=C-7+G,X=Array.from({length:D},(P,v)=>I+v);l.useEffect(()=>{if(!b||!f||!k.current)return;const P=k.current.getBoundingClientRect(),v=8,j=280,V=340,ae=P.left+j>window.innerWidth-v,te=P.right-j>=v,he=P.bottom+8+V>window.innerHeight-v,$=P.top-8-V>=v;h({horizontal:ae&&te?"right":"left",vertical:he&&$?"top":"bottom"})},[b,f]),l.useEffect(()=>{if(!b||!f)return;function P(j){k.current&&(k.current.contains(j.target)||m(!1))}function v(j){j.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",P),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",v)}},[b,f]);function J(){g===1?(N(P=>P-1),w(12)):w(P=>P-1)}function F(){g===12?(N(P=>P+1),w(1)):w(P=>P+1)}const K=new Date(C,g-1,1).getDay(),Z=new Date(C,g,0).getDate(),E=[...Array(K).fill(null),...Array.from({length:Z},(P,v)=>v+1)];for(;E.length<yt*7;)E.push(null);const B=E.slice(0,yt*7);function _(P){const v=wt(C,g,P);a&&v<a||(t(v),b&&m(!1))}const O={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ee=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:H==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:J,style:O,title:"Mes anterior",children:e.jsx(p.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{Y("years"),M(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[g-1]," ",C,e.jsx(p.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:F,style:O,title:"Mes siguiente",children:e.jsx(p.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>M(P=>P-D),style:O,children:e.jsx(p.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>Y("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[X[0]," – ",X[X.length-1]]}),e.jsx("button",{type:"button",onClick:()=>M(P=>P+D),style:O,children:e.jsx(p.HiChevronRight,{size:16})})]})}),H==="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:Vn.map((P,v)=>{const j=v+1===g;return e.jsx("button",{type:"button",onClick:()=>w(v+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:j?700:400,padding:"4px 0",background:j?"var(--primary)":"transparent",color:j?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:P},P)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:X.map(P=>{const v=P===C;return e.jsx("button",{type:"button",onClick:()=>{N(P),Y("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:v?700:400,padding:"6px 0",background:v?"var(--primary)":"transparent",color:v?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:P===new Date().getFullYear()&&!v?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:P},P)})})]}),H==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Kn.map(P=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:P},P))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${yt},1fr)`,padding:"4px 8px 10px",gap:2},children:B.map((P,v)=>{if(P===null)return e.jsx("div",{style:{aspectRatio:"1"}},v);const j=wt(C,g,P),V=j===r,ae=j===s,te=!!(a&&j<a);return e.jsx("button",{type:"button",onClick:()=>!te&&_(P),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:te?"not-allowed":"pointer",fontSize:12,fontWeight:V||ae?700:400,background:V?"var(--primary)":"transparent",color:V?"var(--primary-fg, #ffffff)":te?"var(--text-muted)":"var(--text-main)",opacity:te?.4:1,outline:ae&&!V?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:P},v)})})]})]});return b?e.jsxs("div",{ref:k,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>m(P=>!P),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 ${f?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:f?"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(p.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Yn(r)})]}),e.jsx(p.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsx("div",{className:"absolute z-50",style:{...S.horizontal==="left"?{left:0}:{right:0},...S.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:ee})]}):ee}const Zn={sm:"h-4 w-4",md:"h-5 w-5"};function Jn(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:d="",containerClassName:b="",disabled:f,...m},k){const S=l.useRef(null);return l.useEffect(()=>{S.current&&(S.current.indeterminate=c)},[c]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${f?"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:h=>{S.current=h,Jn(k,h)},type:"checkbox",disabled:f,"aria-checked":c?"mixed":m["aria-checked"],"aria-invalid":!!n||m["aria-invalid"],className:`peer ${Zn[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 ${d}`}),e.jsx(p.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 Qn(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}ua(r)}function Rn(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(p.HiClipboardDocument,{size:14}),copiedIcon:d=e.jsx(p.HiCheck,{size:14}),stopPropagation:b=!0,onCopied:f,onCopyError:m,className:k="",style:S,children:h,onClick:C,type:N="button",...g}){const[w,H]=l.useState(!1),Y=l.useRef(null);l.useEffect(()=>()=>{Y.current&&window.clearTimeout(Y.current)},[]);function D(M){H(!0),f==null||f(M),Y.current&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{H(!1),Y.current=null},t)}async function G(M){var X;if(b&&M.stopPropagation(),C==null||C(M),M.defaultPrevented)return;const I=Rn(r);if(I)try{await Qn(I),D(I)}catch(J){try{ua(I),D(I)}catch(F){m==null||m(F,I);return}(X=navigator.clipboard)!=null&&X.writeText||m==null||m(J,I)}}return e.jsxs("button",{...g,type:N,onClick:G,title:w?n:a,"aria-label":g["aria-label"]??(w?n:a),"data-copied":w?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${h?"min-w-7 px-2":"w-7"} ${k}`,style:{cursor:"pointer",background:w?"rgba(22,163,74,0.15)":"var(--bg-card)",border:w?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:w?"#16a34a":"var(--text-secondary)",boxShadow:w?"0 0 0 3px rgba(22,163,74,0.12)":"none",...S},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:w?"scale(1.15)":"scale(1)"},children:w?d:c}),h&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:w?s??h:h})]})}function el({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:c="Copiado",className:d="",style:b,onCopied:f}){const m=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${d}`,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:f,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 dr({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:c="default",showSelectedSublabel:d=!0,placeholder:b="Seleccionar…",emptyLabel:f,disabled:m=!1,className:k="",style:S,dropdownMinWidth:h,height:C=40,padding:N="0 10px",searchable:g=!0,minOptionsForSearch:w=6}){const[H,Y]=l.useState(!1),[D,G]=l.useState(""),[M,I]=l.useState(-1),[X,J]=l.useState(!1),[F,K]=l.useState({}),Z=l.useRef(null),E=l.useRef(null),B=l.useRef(null),_=l.useRef(null),O=g&&a.length>=w,ee=a.find($=>$.value===r)??null,P=c==="ghost",v=n==="error"?"var(--danger)":H?"var(--primary)":"var(--border)",j=O&&D.trim()?a.filter($=>{var ue;return $.label.toLowerCase().includes(D.toLowerCase())||((ue=$.sublabel)==null?void 0:ue.toLowerCase().includes(D.toLowerCase()))}):a,V=l.useCallback(()=>{const $=Z.current;if(!$)return;const ue=$.getBoundingClientRect(),T=O?272:212,se=window.innerHeight-ue.bottom,fe=se<T&&ue.top>se;K({position:"fixed",left:ue.left,top:fe?void 0:ue.bottom+4,bottom:fe?window.innerHeight-ue.top+4:void 0,width:ue.width,minWidth:kt(h),zIndex:9999})},[h,O]);l.useEffect(()=>J(!0),[]),l.useEffect(()=>{if(!H)return;function $(ue){var se,fe;const T=ue.target;!((se=Z.current)!=null&&se.contains(T))&&!((fe=E.current)!=null&&fe.contains(T))&&(Y(!1),G(""))}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[H]),l.useEffect(()=>{H&&(I(-1),V(),O&&setTimeout(()=>{var $;return($=B.current)==null?void 0:$.focus()},0))},[H,O,V]),l.useEffect(()=>{if(H)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[H,V]),l.useEffect(()=>{if(M<0||!_.current)return;const $=_.current.children[M];$==null||$.scrollIntoView({block:"nearest"})},[M]);const ae=l.useCallback($=>{t($),Y(!1),G("")},[t]);function te($){if(!H){($.key==="Enter"||$.key===" "||$.key==="ArrowDown")&&($.preventDefault(),Y(!0));return}$.key==="Escape"?($.preventDefault(),Y(!1),G("")):$.key==="ArrowDown"?($.preventDefault(),I(ue=>Math.min(ue+1,j.length-1))):$.key==="ArrowUp"?($.preventDefault(),I(ue=>Math.max(ue-1,f?-1:0))):$.key==="Enter"&&($.preventDefault(),M===-1&&f?ae(""):j[M]&&ae(j[M].value))}const he=e.jsxs("div",{ref:E,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...F,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[O&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(p.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:B,value:D,onChange:$=>{G($.target.value),I(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),D&&e.jsx("button",{type:"button",onMouseDown:$=>{$.preventDefault(),G("")},children:e.jsx(p.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:_,role:"listbox",className:"overflow-y-auto",style:{maxHeight:O?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[f&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:$=>{$.preventDefault(),ae("")},onMouseEnter:()=>I(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:M===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:f}),j.map(($,ue)=>{const se=ue===M,fe=$.value===r;return e.jsxs("li",{role:"option","aria-selected":fe,onMouseDown:U=>{U.preventDefault(),$.disabled||ae($.value)},onMouseEnter:()=>!$.disabled&&I(ue),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:se?"var(--bg-hover)":fe?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:$.disabled?"var(--text-muted)":"var(--text-main)",cursor:$.disabled?"not-allowed":"pointer",boxShadow:fe?"inset 2px 0 0 var(--primary)":void 0},children:[$.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:$.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:$.label}),$.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:$.sublabel})]}),$.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:$.badge})]},$.value)}),j.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:Z,className:`relative ${k||"w-full"}`,style:S,onKeyDown:te,children:[e.jsxs("button",{type:"button",disabled:m,onClick:()=>!m&&Y($=>!$),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:kt(C),padding:kt(N),background:P?"transparent":"var(--bg-input)",color:ee?"var(--text-main)":"var(--text-muted)",border:P?"1px solid transparent":`1px solid ${v}`,opacity:m?.5:1,cursor:m?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":H,"aria-label":s,children:[(ee==null?void 0:ee.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:ee.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:ee?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:ee.label}),d&&ee.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:ee.sublabel})]}):e.jsx("span",{className:"truncate",children:b})}),ee&&f?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:$=>{$.preventDefault(),$.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(p.HiXMark,{className:"w-3 h-3"})}):e.jsx(p.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:H?"rotate(180deg)":"rotate(0deg)"}})]}),H&&X&&je.createPortal(he,document.body)]})}function Pr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function rl({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:c="0 10px 0 30px",iconLeft:d=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(p.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(d)}}),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 tl({value:r,onChange:t,options:a,placeholder:n,icon:s,className:c="",height:d=40,padding:b,iconLeft:f=10,searchable:m=!0}){const k=s?a.map((S,h)=>h===0&&!S.color?{...S,sublabel:S.sublabel??void 0}:S):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(f)},children:s}),e.jsx(dr,{value:r,onChange:t,options:k,placeholder:n,searchable:m,minOptionsForSearch:5,height:d,padding:b??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const al={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},zr=180,nl="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:d,children:b,size:f="md",maxWidth:m,zIndex:k=1e3,closeOnBackdrop:S=!0,closeOnEscape:h=!0,showCloseButton:C=!0,placement:N="center",bodyClassName:g="px-6 py-5",panelClassName:w="",backdropClassName:H=nl,contentClassName:Y="p-4",ariaLabel:D,frameless:G=!1}){const[M,I]=l.useState(!1),[X,J]=l.useState(!1),F=l.useRef(null);if(l.useEffect(()=>(r?(F.current&&clearTimeout(F.current),I(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>J(!0)))):(J(!1),F.current=setTimeout(()=>I(!1),zr+40)),()=>{F.current&&clearTimeout(F.current)}),[r]),l.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),l.useEffect(()=>{if(!r||!h)return;const O=ee=>{ee.key==="Escape"&&t()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[h,t,r]),!M)return null;const K=a||n||s||c||C,Z=m??al[f],E=N==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",B=N==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",_=X?"translateY(0) scale(1)":N==="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":D??a,className:`fixed inset-0 flex ${E} ${Y}`,style:{zIndex:k},children:[e.jsx("div",{className:`absolute inset-0 ${H}`,onClick:S?t:void 0,style:{opacity:X?1:0,transition:`opacity ${zr}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${G?"shadow-none":"shadow-2xl"} ${B} ${w}`,style:{maxWidth:Z,background:G?"transparent":"var(--bg-card)",border:G?"none":"1px solid var(--border)",opacity:X?1:0,transform:_,transition:`opacity ${zr}ms ease, transform ${zr}ms ease`},onClick:O=>O.stopPropagation(),children:[K&&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,C&&e.jsx(Te,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(p.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${g}`,children:b}),d&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:d})]})]}),document.body)}const ll={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 ol({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:c="danger",closeOnBackdrop:d=!0,onConfirm:b,onCancel:f}){const m=ll[c];return e.jsxs(St,{open:r,onClose:f,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,closeOnBackdrop:d,children:[e.jsx(Te,{variant:"icon",onClick:f,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(p.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(p.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:f,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 sl(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function il({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:s=e.jsx(p.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(Nt,{...c,value:()=>sl(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"}],cl=jr.map(r=>({value:r.value,label:r.label})),dl=12,ul={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!1},bl="bonsaif-ui:datatable:",fl="[&_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",pl=[],ml=52;function rr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function hl(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`${bl}${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 vl(r,t){try{window.localStorage.setItem(ba(r),JSON.stringify(t))}catch{}}function xl(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}:{...ul,...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(d=>typeof d=="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 d=c;return!d.operator||!a.has(d.operator)?[]:[[s,{operator:d.operator,value:typeof d.value=="string"?d.value:"",valueTo:typeof d.valueTo=="string"?d.valueTo:""}]]});return Object.fromEntries(n)}function Ke(r,t){if(tr(r))return ml;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function gl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function tr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function yl(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 ar(r,t){var d;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=(d=t.find(b=>b.hideable!==!1))==null?void 0:d.key;return c?n.filter(b=>b!==c):[]}function wl(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?wl(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 Nl(r,t,a){var d,b;const n=((d=t.value)==null?void 0:d.trim())??"",s=((b=t.valueTo)==null?void 0:b.trim())??"",c=jr.find(f=>f.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(S=>({value:S,number:Nr(S)})).filter(S=>S.number!==null).sort((S,h)=>S.number-h.number).map(S=>S.value);return(t.operator==="top10"?m.slice(-10):m.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const f=a.map(Nr).filter(S=>S!==null);if(f.length===0)return!1;const m=f.reduce((S,h)=>S+h,0)/f.length,k=Nr(r);return k===null?!1:t.operator==="aboveAverage"?k>m:k<m}default:return!0}}function pa({children:r,className:t="",style:a}){return e.jsx(cr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function kl({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:c,emptyText:d="Sin resultados",initialEmptyDelay:b=450,onRowClick:f,renderExpandedRow:m,getRowCanExpand:k,expandedRowIds:S,defaultExpandedRowIds:h=[],onExpandedRowIdsChange:C,expandOnRowClick:N=!1,selected:g,onToggleOne:w,onToggleAll:H,highlightSelected:Y=!0,rowClassName:D,getRowCategory:G,stickyHeader:M=!0,pageSize:I=25,pageSizeOptions:X=[25,50,100],pageSizeSelectWidth:J=62,pageSizeSelectHeight:F=30,pageSizeSelectPadding:K="0 7px",totalRows:Z,page:E,onPageChange:B,onPageSizeChange:_,storageKey:O,stickyFirstColumn:ee=!1,bottomOffset:P=0,compact:v=!0,restrictHeight:j=!0,maxHeight:V,minTableWidth:ae,enableColumnVisibility:te=!0,enableColumnFilters:he=!0,hiddenColumnKeys:$,defaultHiddenColumnKeys:ue=pl,onHiddenColumnKeysChange:T,columnVisibilityLabel:se="Columnas",enableBql:fe=!1,bqlValue:U,defaultBqlValue:re="",onBqlChange:R,bqlDescription:ne="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ve=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:oe=[],bqlExamples:L=[],bqlSuggestions:W=[],bqlActiveFilters:ie,bqlError:ce,onQueryChange:ke,persistState:be,enableExport:Se=!1,exportFilename:we="datos"}){var Cn;const de=xl(be),Be=Object.values(de).some(Boolean),Ge=r.map(o=>o.key).join(","),ze=ue.join(","),Q=l.useRef(r),Me=l.useRef(ue);Q.current=r,Me.current=ue;const[Le,Ie]=l.useState(!O||!Be),He=l.useRef(null),Ye=l.useRef(!O),Oe=$!==void 0,[fs,Sr]=l.useState(()=>ar(ue,r)),Fe=ar(Oe?$:fs,r),[Re,Zr]=l.useState(!1),[nr,ps]=l.useState("filter"),[Cr,Jr]=l.useState(null),[Ga,Ya]=l.useState(""),[Pe,Er]=l.useState({}),[We,Qr]=l.useState({}),At=S!==void 0,[Xa,ms]=l.useState(h),Mr=U!==void 0,[hs,Dt]=l.useState(re),Xe=Mr?U:hs,[Rr,et]=l.useState(Xe),[Ze,lr]=l.useState(!1),[Za,fr]=l.useState(!1),[Ja,pr]=l.useState(!1),[Lr,$r]=l.useState([]),Bt=l.useRef(null),Qa=l.useRef(null),Ot=l.useRef(null),[vs,xs]=l.useState({}),[gs,ys]=l.useState({}),[Tr,rt]=l.useState(!1),It=l.useRef(null),tt=l.useRef(null),[ws,Ns]=l.useState({}),Ra=l.useRef(null),at=l.useRef(null),[Ft,en]=l.useState(t.length>0||n||b===!1),rn=(o,i)=>50+(o*17+i*13+7)%40,er=l.useRef(null),[ks,Ss]=l.useState(void 0),[tn,Cs]=l.useState(0),[Pt,Es]=l.useState(!1);l.useEffect(()=>{function o(){Es(window.innerWidth<640)}if(!j||V!==void 0)return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o);const y=I!==!1?48:0,u=12;function z(){if(o(),!er.current)return;const x=er.current.getBoundingClientRect().top;Ss(Math.max(120,window.innerHeight-x-y-u-P))}return z(),window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[n,I,P,j,V]);const an=j?V??ks:void 0;l.useEffect(()=>{const o=er.current;if(!o)return;const i=()=>Cs(o.clientWidth);if(i(),typeof ResizeObserver>"u")return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i);const y=new ResizeObserver(i);return y.observe(o),()=>y.disconnect()},[n,Le,t.length]),l.useEffect(()=>{if(b===!1||n||t.length>0){en(!0);return}if(Ft)return;const o=window.setTimeout(()=>{en(!0)},b);return()=>window.clearTimeout(o)},[t.length,b,Ft,n]);const[mr,Hr]=l.useState(()=>r.map(o=>o.key)),[hr,Ar]=l.useState(()=>Object.fromEntries(r.map(o=>[o.key,Ke(o,rr(o.width))]))),[Ce,vr]=l.useState(null),[Ms,nt]=l.useState(1),[lt,zt]=l.useState(I===!1?0:I);l.useEffect(()=>{const o=Q.current,i=Me.current,y=o.map(x=>x.key),u=new Set(y);if(!O||!Be){de.layout&&Hr(y),Oe||Sr(ar(i,o)),Ye.current=!1,Ie(!0);return}let z=!1;return Ye.current=!1,Ie(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(O)}`,{cache:"no-store"}).then(x=>x.ok?x.json():null).then(x=>{if(z)return;const le=fa(O),A=hl(x==null?void 0:x.settings)?x==null?void 0:x.settings:le,Ee=de.layout?A==null?void 0:A.columnOrder:void 0,Ne=Array.isArray(Ee)?Ee.filter($e=>y.includes($e)):[],pe=y.filter($e=>!Ne.includes($e)),xe=Ne.length>0?[...Ne,...pe]:y,me=Object.fromEntries(o.map($e=>[$e.key,Ke($e,rr($e.width))])),Ae=de.layout?(A==null?void 0:A.columnWidths)??{}:{},ye=Object.fromEntries(o.map($e=>[$e.key,Ke($e,Ae[$e.key]??me[$e.key])])),xt=ar(de.layout?(A==null?void 0:A.hiddenColumnKeys)??i:i,o);if(de.layout&&(Hr(xe),Ar(ye)),Oe||Sr(xt),de.filters&&(Er(Wr(A==null?void 0:A.filters,u)),Qr(qr(A==null?void 0:A.conditionFilters,u))),de.sort){const $e=_r(A==null?void 0:A.sort)?A.sort:null;vr($e&&u.has($e.key)?$e:null)}if(de.bql){const $e=typeof(A==null?void 0:A.bql)=="string"?A.bql:re;Mr?R==null||R($e):Dt($e)}de.bql&&$r(Array.isArray(A==null?void 0:A.bqlHistory)?A.bqlHistory.filter($e=>typeof $e=="string"):[]),de.pagination&&typeof(A==null?void 0:A.pageSize)=="number"&&A.pageSize>0&&zt(A.pageSize),He.current=JSON.stringify({columnOrder:xe,columnWidths:ye,hiddenColumnKeys:xt,filters:Wr(A==null?void 0:A.filters,u),conditionFilters:qr(A==null?void 0:A.conditionFilters,u),sort:_r(A==null?void 0:A.sort)?A.sort:null,bql:typeof(A==null?void 0:A.bql)=="string"?A.bql:"",bqlHistory:Array.isArray(A==null?void 0:A.bqlHistory)?A.bqlHistory:[],pageSize:typeof(A==null?void 0:A.pageSize)=="number"?A.pageSize:void 0}),Ye.current=!0}).catch(()=>{if(!z){const x=fa(O),le=de.layout?x==null?void 0:x.columnOrder:void 0,A=Array.isArray(le)?le.filter(ye=>y.includes(ye)):[],Ee=y.filter(ye=>!A.includes(ye)),Ne=A.length>0?[...A,...Ee]:y,pe=Object.fromEntries(o.map(ye=>[ye.key,Ke(ye,rr(ye.width))])),xe=de.layout?(x==null?void 0:x.columnWidths)??{}:{},me=Object.fromEntries(o.map(ye=>[ye.key,Ke(ye,xe[ye.key]??pe[ye.key])]));de.layout&&(Hr(Ne),Ar(me));const Ae=ar(de.layout?(x==null?void 0:x.hiddenColumnKeys)??i:i,o);if(Oe||Sr(Ae),de.filters&&(Er(Wr(x==null?void 0:x.filters,u)),Qr(qr(x==null?void 0:x.conditionFilters,u))),de.sort){const ye=_r(x==null?void 0:x.sort)?x.sort:null;vr(ye&&u.has(ye.key)?ye:null)}if(de.bql){const ye=typeof(x==null?void 0:x.bql)=="string"?x.bql:re;Mr?R==null||R(ye):Dt(ye)}de.bql&&$r(Array.isArray(x==null?void 0:x.bqlHistory)?x.bqlHistory.filter(ye=>typeof ye=="string"):[]),de.pagination&&typeof(x==null?void 0:x.pageSize)=="number"&&x.pageSize>0&&zt(x.pageSize),He.current=JSON.stringify({columnOrder:Ne,columnWidths:me,hiddenColumnKeys:Ae,filters:Wr(x==null?void 0:x.filters,u),conditionFilters:qr(x==null?void 0:x.conditionFilters,u),sort:_r(x==null?void 0:x.sort)?x.sort:null,bql:typeof(x==null?void 0:x.bql)=="string"?x.bql:"",bqlHistory:Array.isArray(x==null?void 0:x.bqlHistory)?x.bqlHistory:[],pageSize:typeof(x==null?void 0:x.pageSize)=="number"?x.pageSize:void 0}),Ye.current=!0}}).finally(()=>{z||Ie(!0)}),()=>{z=!0}},[O,Be,Ge,ze,Oe,de.layout,de.filters,de.sort,de.bql,de.pagination,Mr,R,re]),l.useEffect(()=>{if(!O||!Le||!Be||!Ye.current)return;const o={};de.layout&&(o.columnOrder=mr,o.columnWidths=hr,o.hiddenColumnKeys=Fe),de.filters&&(o.filters=Pe,o.conditionFilters=We),de.sort&&(o.sort=Ce),de.bql&&(o.bql=Xe,o.bqlHistory=Lr),de.pagination&&I!==!1&&(o.pageSize=lt);const i=JSON.stringify(o);if(i===He.current)return;vl(O,o),He.current=i;const y=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:O,settings:o})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(y)},[mr,hr,Fe,Pe,We,Ce,Xe,Lr,lt,I,O,Le,Be,de.layout,de.filters,de.sort,de.bql,de.pagination]),l.useEffect(()=>{Hr(o=>{const i=r.map(z=>z.key),y=o.filter(z=>i.includes(z)),u=i.filter(z=>!y.includes(z));return[...y,...u]})},[Ge,r]);const nn=mr.map(o=>r.find(i=>i.key===o)).filter(o=>!!o),qe=nn.filter(o=>!Fe.includes(o.key)),Ls=Object.keys(Pe).length,$s=Object.keys(We).length,jt=Ls+$s;function ln(o){const i=new Set;return t.reduce((y,u)=>{const z=Ur(o,u);return!z||i.has(z)||(i.add(z),y.push({value:z,label:z})),y},[])}function Ts(){const o=r.find(i=>i.key===Cr);return o?ln(o):[]}function Hs(o){return!!(he&&!tr(o)&&(o.filterValue||o.sortKey||ln(o).length>0))}function on(o,i){Er(y=>{const u={...y};return u[o]=i,u})}function As(o,i,y,u){const z=Pe[o]??[],x=u?z:y.filter(A=>A!==i),le=u?z.includes(i)?z.filter(A=>A!==i):[...z,i]:x;le.length===y.length?_t(o):on(o,le)}function _t(o){Er(i=>{const y={...i};return delete y[o],y})}function ot(o,i){Qr(y=>{const u={...y};return i?u[o]=i:delete u[o],u})}function sn(o){ot(o,null)}function Ds(){Er({}),Qr({})}function cn(o){Mr||Dt(o),R==null||R(o)}function st(o){const i=o.trim();et(i),cn(i),lr(!1),fr(!1),pr(!1),i&&$r(y=>[i,...y.filter(u=>u!==i)].slice(0,dl))}function dn(){et(""),cn(""),lr(!1),fr(!1),pr(!1)}function Wt(o,i){et(o),i&&(i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight,180)}px`)}l.useEffect(()=>{et(Xe)},[Xe]);const it=l.useCallback(()=>{const o=Bt.current;if(!o)return;const i=o.getBoundingClientRect(),y=12,u=8,z=Math.min(780,Math.max(320,window.innerWidth-32)),x=Math.max(y,window.innerWidth-z-y),le=Math.min(Math.max(y,i.left),x),A=i.bottom+u,Ee=window.innerHeight-i.top+u,Ne=window.innerHeight-A-y,pe=i.top-y-u,xe=Ne<280&&pe>Ne,me=Math.max(240,xe?pe:Ne);xs({position:"fixed",zIndex:1e4,left:le,top:xe?void 0:A,bottom:xe?Ee:void 0,width:z,maxWidth:"calc(100vw - 24px)",maxHeight:me,overflowY:"auto"})},[]);l.useEffect(()=>{if(!Ze)return;function o(u){var x,le;const z=u.target;(x=Bt.current)!=null&&x.contains(z)||(le=Qa.current)!=null&&le.contains(z)||(lr(!1),fr(!1),pr(!1))}function i(u){u.key==="Escape"&&(lr(!1),fr(!1),pr(!1))}function y(){it()}return it(),document.addEventListener("mousedown",o),window.addEventListener("keydown",i),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",i),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[Ze,it]);function un(o){const i=ar(o,r);Oe||Sr(i),T==null||T(i)}function Bs(o){un(Fe.includes(o)?Fe.filter(i=>i!==o):[...Fe,o])}function Os(){un([])}const qt=l.useCallback((o=at.current)=>{if(!o)return;const i=o.getBoundingClientRect(),y=Math.min(292,Math.max(240,window.innerWidth-16)),u=Math.max(8,window.innerWidth-y-8),z=Math.min(Math.max(8,i.right-y),u),x=window.innerHeight-i.bottom,le=i.bottom+6,A=window.innerHeight-i.top+6,Ne=x<360&&i.top>x?void 0:le,pe=Ne===void 0?A:void 0,xe=Math.max(220,Ne===void 0?i.top-16:window.innerHeight-le-8),me={position:"fixed",zIndex:9999,left:z,top:Ne,bottom:pe,width:y,maxWidth:"calc(100vw - 16px)",maxHeight:xe,"--dt-column-menu-max-height":`${xe}px`};ys(me)},[]);function bn(o,i,y=null){o.preventDefault(),o.stopPropagation();const u=at.current===o.currentTarget&&nr===i&&Cr===y;if(Re&&u){Zr(!1),Jr(null);return}at.current=o.currentTarget,ps(i),Jr(y),Ya(""),qt(o.currentTarget),Zr(!0)}function Is(o){if(tr(o))return;const i=er.current;if(!i)return;const u=Array.from(i.querySelectorAll("[data-dt-column-key]")).filter(z=>z.dataset.dtColumnKey===o.key).reduce((z,x)=>{const le=x.querySelector("[data-dt-autofit-content]"),A=le?le.scrollWidth:Math.max(x.scrollWidth,x.offsetWidth);return Math.max(z,Math.ceil(A+gl(x)))},0);u<=0||Ar(z=>({...z,[o.key]:Ke(o,u+12)}))}l.useEffect(()=>{Ar(o=>{const i=Object.fromEntries(r.map(y=>[y.key,Ke(y,rr(y.width))]));return Object.fromEntries(r.map(y=>[y.key,Ke(y,o[y.key]??i[y.key])]))})},[Ge,r]),l.useEffect(()=>{Oe||Sr(o=>ar(o,r))},[Ge,r,Oe]),l.useEffect(()=>{function o(u){var le,A;const z=u.target,x=u.target;x!=null&&x.closest("[data-bonsaif-select-dropdown='true']")||!((le=Ra.current)!=null&&le.contains(z))&&!((A=at.current)!=null&&A.contains(z))&&(Zr(!1),Jr(null))}function i(u){u.key==="Escape"&&(Zr(!1),Jr(null))}function y(){qt()}return Re&&(document.addEventListener("mousedown",o),window.addEventListener("keydown",i),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0)),()=>{document.removeEventListener("mousedown",o),window.removeEventListener("keydown",i),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[Re,qt]);const Dr=l.useRef(null);l.useEffect(()=>{function o(y){const u=Dr.current;if(!u)return;const z=y.clientX-u.startX,x=r.find(le=>le.key===u.colKey);x&&Ar(le=>({...le,[u.colKey]:Ke(x,u.startWidth+z)}))}function i(){Dr.current&&(Dr.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i)}},[r]);const ct=l.useRef(null),[fn,Ut]=l.useState(null);function Fs(o,i){ct.current=mr.indexOf(o),i.dataTransfer.effectAllowed="move"}function Ps(o,i){i.preventDefault(),i.dataTransfer.dropEffect="move";const y=mr.indexOf(o);fn!==y&&Ut(y)}function zs(o,i){i.preventDefault();const y=ct.current,u=mr.indexOf(o);y!==null&&y!==u&&Hr(z=>{const x=[...z],[le]=x.splice(y,1);return x.splice(u,0,le),x}),ct.current=null,Ut(null)}function js(){ct.current=null,Ut(null)}function _s(o){o.sortKey&&vr(i=>(i==null?void 0:i.key)===o.key?{key:o.key,dir:i.dir==="asc"?"desc":"asc"}:{key:o.key,dir:"asc"})}l.useEffect(()=>{nt(1)},[t]),l.useEffect(()=>{nt(1)},[We,Pe]);const or=!!(B&&_),sr=I!==!1,De=or?E??1:Ms,Ue=or||sr?lt:t.length,Ve=!!g&&!!w&&!!H,xr=!!m,pn=l.useMemo(()=>new Set(At?Array.from(S??[]):Xa),[At,S,Xa]),Vt=(xr?40:0)+(Ve?40:0),Ws=Ve&&t.length>0&&g.size===t.length,qs=Ve&&g.size>0&&g.size<t.length,dt=l.useMemo(()=>{const o=Object.entries(Pe),i=Object.entries(We);return o.length===0&&i.length===0?t:t.filter(y=>o.every(([u,z])=>{const x=r.find(le=>le.key===u);return x?z.includes(Ur(x,y)):!0})&&i.every(([u,z])=>{const x=r.find(A=>A.key===u);if(!x)return!0;const le=t.map(A=>Ur(x,A));return Nl(Ur(x,y),z,le)}))},[We,Pe,r,t]),ir=l.useMemo(()=>{if(!Ce)return dt;const o=r.find(i=>i.key===Ce.key&&i.sortKey);return o!=null&&o.sortKey?[...dt].sort((i,y)=>{const u=i[o.sortKey],z=y[o.sortKey],x=u===z?0:u==null?1:z==null||u<z?-1:1;return Ce.dir==="asc"?x:-x}):dt},[dt,Ce,r]),mn=l.useMemo(()=>{if(or||!sr)return ir;const o=(De-1)*Ue;return ir.slice(o,o+Ue)},[ir,or,sr,De,Ue]),gr=or?Z??t.length:ir.length,Kt=sr?Math.max(1,Math.ceil(gr/Ue)):1,Us=sr&&gr>Ue,Vs=sr?(De-1)*Ue+1:1,Ks=sr?Math.min(De*Ue,gr):gr;function Gt(o){if(n)return;const i=Math.max(1,Math.min(o,Kt));or?B(i):nt(i)}function Gs(o){n||(zt(o),or?(_(o),B(1)):nt(1),_&&_(o))}function hn(o){const i=new Set(pn);i.has(o)?i.delete(o):i.add(o);const y=Array.from(i);At||ms(y),C==null||C(y)}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 vn=o=>o==="center"?"text-center":o==="right"?"text-right":"text-left",Ys="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%)",ge="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 ${ge}`,xn=qe.reduce((o,i)=>o+(hr[i.key]??rr(i.width)),(xr?40:0)+(Ve?40:0)),gn=typeof ae=="number"?ae:typeof ae=="string"?Number(((Cn=ae.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Cn[1])??NaN):NaN,Br=Number.isFinite(gn)?Math.max(xn,gn,tn):Math.max(xn,tn),bt=ae??Br,wr=`${xr?"40px ":""}${Ve?"40px ":""}${qe.map(o=>`${hr[o.key]??rr(o.width)}px`).join(" ")}`;l.useEffect(()=>{Ce&&Fe.includes(Ce.key)&&vr(null)},[Fe,Ce]);function yn(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:[xr&&e.jsx("div",{role:"columnheader",className:`${v?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${ge}`}}),Ve&&e.jsx("div",{role:"columnheader",className:`${v?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:ee?{position:"sticky",left:0,zIndex:12,background:Yt,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${yr}`,borderRight:`1px solid ${ge}`}:{borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${ge}`},children:e.jsx(Fr,{size:"sm",checked:Ws,indeterminate:qs,onChange:H,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),qe.map((o,i)=>{const y=(Ce==null?void 0:Ce.key)===o.key,u=!!o.sortKey,z=tr(o),x=ee&&!Pt&&i===0,le=fn===i,Ee=(hr[o.key]??rr(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":vn(o.align)}`,style:{...x?{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 ${ge}`}:{position:"relative",borderBottom:`1px solid ${yr}`,borderRight:`1px solid ${ge}`},color:y?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:le?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:z?v?"7px 6px":"9px 8px":v?"8px 6px 10px":"10px 8px 12px"},onDragOver:pe=>Ps(o.key,pe),onDrop:pe=>zs(o.key,pe),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${z?"justify-center":Ee?"justify-start":o.align==="center"?"justify-center":o.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:pe=>{pe.stopPropagation(),Fs(o.key,pe)},onDragEnd:pe=>{pe.stopPropagation(),js()},onClick:pe=>pe.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 ${le?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),z?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(p.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 ${v?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:o.header})})}),u&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(o.header)}`,title:"Ordenar",onClick:pe=>{pe.stopPropagation(),_s(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 ${y?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:y?Ce.dir==="asc"?e.jsx(p.HiChevronUp,{className:"h-3 w-3"}):e.jsx(p.HiChevronDown,{className:"h-3 w-3"}):e.jsx(p.HiChevronUpDown,{className:"h-3 w-3"})}),he&&!z&&Hs(o)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&Cr===o.key,"aria-label":`Filtrar ${String(o.header)}`,title:"Filtrar",onClick:pe=>bn(pe,"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&&nr==="filter"&&Cr===o.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Ne?"text-[var(--primary)] opacity-100":""}`,children:Ne?e.jsx(p.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(p.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!z&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:pe=>{pe.preventDefault(),pe.stopPropagation(),Dr.current={colKey:o.key,startX:pe.clientX,startWidth:hr[o.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:pe=>{pe.preventDefault(),pe.stopPropagation(),Dr.current=null,document.body.style.cursor="",document.body.style.userSelect="",Is(o)},onClick:pe=>pe.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",style:{right:0,width:8,cursor:"col-resize",zIndex:6},children:e.jsx("span",{style:{width:3,height:"calc(100% - 8px)",borderRadius:2,background:"var(--primary)",display:"block"}})})]},o.key)})]}),pt=()=>{if(!Re||typeof document>"u"||nr==="visibility"&&!te||nr==="filter"&&!he)return null;const o=r.find(me=>me.key===Cr),i=Ts(),y=o?Object.prototype.hasOwnProperty.call(Pe,o.key):!1,u=o?We[o.key]:void 0,z=jr.find(me=>me.value===(u==null?void 0:u.operator)),x=o?Pe[o.key]??[]:[],le=Ga.trim().toLowerCase(),A=le?i.filter(me=>me.label.toLowerCase().includes(le)):i,Ee=o&&i.length>0&&(!y||x.length===i.length),Ne=o&&y&&x.length>0&&x.length<i.length,pe=Fe.length,xe=()=>{o&&(_t(o.key),sn(o.key))};return je.createPortal(e.jsx("div",{ref:Ra,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...gs,borderColor:"var(--border)",background:"var(--bg-card)"},children:nr==="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:pe>0?`${qe.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:Os,disabled:pe===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:nn.map(me=>{const Ae=!Fe.includes(me.key),xt=!(me.hideable!==!1)||Ae&&qe.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,disabled:xt,onClick:()=>Bs(me.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:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&e.jsx(p.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:me.header})]},me.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:xe,disabled:!y&&!u,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(p.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(p.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(p.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(p.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(dr,{value:(u==null?void 0:u.operator)??"",onChange:me=>{if(!me){sn(o.key);return}ot(o.key,{operator:me,value:(u==null?void 0:u.value)??"",valueTo:(u==null?void 0:u.valueTo)??""})},options:cl,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"}),(z==null?void 0:z.valueMode)!=="none"?e.jsx("input",{value:(u==null?void 0:u.value)??"",onChange:me=>{u&&ot(o.key,{...u,value:me.target.value})},disabled:!u,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"})]}),(z==null?void 0:z.valueMode)==="between"&&e.jsx("input",{value:(u==null?void 0:u.valueTo)??"",onChange:me=>{u&&ot(o.key,{...u,valueTo:me.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(p.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Ga,onChange:me=>Ya(me.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&&!y?on(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(p.HiMinus,{className:"h-3 w-3"}),Ee&&!Ne&&e.jsx(p.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),A.map(me=>{const Ae=!y||x.includes(me.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,onClick:()=>As(o.key,me.value,i.map(ye=>ye.value),y),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:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&e.jsx(p.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:me.label})]},me.value)}),A.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(i){It.current&&!It.current.contains(i.target)&&tt.current&&!tt.current.contains(i.target)&&rt(!1)}return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[Tr]);function wn(o,i){if(o.filterValue){const y=o.filterValue(i);return y==null||y===""?"":String(y)}return ur(o.cell(i))}function Nn(o){return`"${o.replace(/"/g,'""')}"`}function mt(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Xs(){const o=qe.filter(A=>!tr(A)),i=o.map(A=>Nn(ur(A.header))).join(","),y=ir.map(A=>o.map(Ee=>Nn(wn(Ee,A))).join(",")).join(`
|
|
3
3
|
`),u=`${i}
|
|
4
|
-
${y}`,
|
|
5
|
-
<html lang="es"><head><meta charset="utf-8"><title>${
|
|
4
|
+
${y}`,z=new Blob(["\uFEFF"+u],{type:"text/csv;charset=utf-8;"}),x=URL.createObjectURL(z),le=document.createElement("a");le.href=x,le.download=`${we}.csv`,document.body.appendChild(le),le.click(),document.body.removeChild(le),URL.revokeObjectURL(x)}function Zs(){const o=qe.filter(le=>!tr(le)),i=o.map(le=>mt(ur(le.header))),u=ir.map(le=>o.map(A=>mt(wn(A,le)))).map(le=>`<tr>${le.map(A=>`<td>${A}</td>`).join("")}</tr>`).join(""),z=`<!DOCTYPE html>
|
|
5
|
+
<html lang="es"><head><meta charset="utf-8"><title>${mt(we)}</title>
|
|
6
6
|
<style>
|
|
7
7
|
body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
|
|
8
8
|
h3{margin:0 0 4px;font-size:14px}
|
|
@@ -13,9 +13,9 @@ ${y}`,j=new Blob(["\uFEFF"+u],{type:"text/csv;charset=utf-8;"}),v=URL.createObje
|
|
|
13
13
|
tr:nth-child(even) td{background:#f9f9f9}
|
|
14
14
|
@media print{body{margin:0}@page{margin:1cm}}
|
|
15
15
|
</style></head><body>
|
|
16
|
-
<h3>${
|
|
16
|
+
<h3>${mt(we)}</h3>
|
|
17
17
|
<p>${ir.length} registros · ${new Date().toLocaleDateString("es")}</p>
|
|
18
18
|
<table><thead><tr>${i.map(le=>`<th>${le}</th>`).join("")}</tr></thead>
|
|
19
19
|
<tbody>${u}</tbody></table>
|
|
20
20
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
21
|
-
</body></html>`,v=window.open("","_blank");v&&(v.document.write(j),v.document.close())}const Yt=()=>!Se||!$r?null:ze.createPortal(e.jsxs("div",{ref:Ht,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...ws,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:()=>{Xs(),et(!1)},children:[e.jsx(p.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:()=>{Zs(),et(!1)},children:[e.jsx(p.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Xt=()=>{const o=fe&&Ge.trim().length>0,i=ie!=null&&ie.length?ie:o?[{key:"bql",label:"BQL",value:Ge}]:[],y=W.filter(u=>u.trim()&&u!==Qr).slice(0,8);return!te&&It===0&&!fe&&!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:[It>0&&e.jsxs("button",{type:"button",onClick:Ds,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(p.HiXMark,{className:"h-3.5 w-3.5"}),It," filtros"]}),fe&&e.jsxs("div",{ref:$t,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(Ye){lr(!1);return}st(),lr(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:Ye?"var(--primary)":o?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ye||o?"var(--primary)":"var(--border)",color:Ye?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ye,title:"Abrir filtros BQL",children:[e.jsx(p.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",o&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ye?e.jsx(p.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(p.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:ne}),i.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[i.slice(0,3).map(u=>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:[u.label,":"]}),e.jsx("span",{className:"truncate",children:u.value})]},u.key)),i.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",i.length-3]})]}),o&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:dn,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(p.HiXMark,{className:"h-4 w-4"})}),Ye&&ze.createPortal(e.jsxs("div",{ref:Ra,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...vs,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:[oe.map(u=>e.jsxs("button",{type:"button",onClick:()=>ot(u.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:[u.icon,u.label]},u.label)),M.length>0&&e.jsxs("button",{type:"button",onClick:()=>fr(u=>!u),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":Ja,children:[e.jsx(p.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Mr.length>0&&e.jsxs("button",{type:"button",onClick:()=>pr(u=>!u),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(p.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 ${ce?"var(--danger)":o?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:Tt,value:Qr,rows:3,onChange:u=>Pt(u.target.value,u.target),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),ot(Qr)),u.key==="Escape"&&lr(!1)},placeholder:ve,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"}}),y.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:y.map(u=>e.jsx("button",{type:"button",onMouseDown:j=>{var v;j.preventDefault(),Pt(u),(v=Tt.current)==null||v.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:u},u))})]}),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:ce?"var(--danger)":"var(--text-muted)"},children:ce??(o?`${i.length||1} filtro${(i.length||1)===1?"":"s"} activo${(i.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),i.map(u=>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:[u.label,":"]}),e.jsx("span",{className:"truncate",children:u.value})]},u.key))]}),Qa&&Mr.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(p.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(p.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Mr.map(u=>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:()=>ot(u),className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:u})}),e.jsx("button",{type:"button",onClick:()=>Lr(j=>j.filter(v=>v!==u)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(p.HiXMark,{className:"h-3.5 w-3.5"})})]},u))]}),Ja&&M.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:M.map(u=>e.jsxs("button",{type:"button",onClick:()=>{var j;Pt(u.bql),fr(!1),(j=Tt.current)==null||j.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:u.bql}),u.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:u.description})]},u.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:dn,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(p.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>ot(Qr),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(p.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Se&&e.jsx("button",{ref:rt,type:"button","aria-haspopup":"menu","aria-expanded":$r,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var j;const u=(j=rt.current)==null?void 0:j.getBoundingClientRect();u&&Ns({top:u.bottom+4,right:window.innerWidth-u.right}),et(v=>!v)},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)] ${$r?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(p.HiArrowDownTray,{className:"h-4 w-4"})}),te&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&nr==="visibility","aria-label":se,title:se,onClick:u=>bn(u,"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&&nr==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(p.HiCog6Tooth,{className:"h-4 w-4"})})]})},kn=()=>{if(!Us)return null;const o=yl(De,Wt);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 ${g?"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":`${Vs}–${Ks} de ${xr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(dr,{value:String(qe),onChange:i=>Gs(Number(i)),options:X.map(i=>({value:String(i),label:String(i)})),placeholder:"Filas",searchable:!1,disabled:n,height:F,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:J}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||De<=1,onClick:()=>qt(De-1),onMouseEnter:i=>{i.currentTarget.disabled||(i.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",i.currentTarget.style.color="var(--primary)")},onMouseLeave:i=>{i.currentTarget.style.background="transparent",i.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(p.HiChevronLeft,{className:"h-3.5 w-3.5"})}),o.map((i,y)=>i==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${y}`):e.jsx("button",{disabled:n,onClick:()=>qt(i),onMouseEnter:u=>{u.currentTarget.disabled||i===De||(u.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",u.currentTarget.style.color="var(--primary)")},onMouseLeave:u=>{u.currentTarget.style.background=i===De?"var(--primary)":"transparent",u.currentTarget.style.color=i===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:i===De?"var(--primary)":"transparent",color:i===De?"var(--primary-fg)":"var(--text-muted)"},children:i},i)),e.jsx("button",{disabled:n||De>=Wt,onClick:()=>qt(De+1),onMouseEnter:i=>{i.currentTarget.disabled||(i.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",i.currentTarget.style.color="var(--primary)")},onMouseLeave:i=>{i.currentTarget.style.background="transparent",i.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(p.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},Sn=()=>e.jsx("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:dt},children:e.jsxs("div",{ref:er,className:"min-w-0 max-w-full",style:{maxHeight:Bt,background:"var(--bg-card)"},children:[e.jsx("div",{className:"border-b px-3 py-2",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:e.jsx("div",{className:"h-3.5 w-40 animate-pulse rounded-full",style:{background:"var(--border)"}})}),e.jsx("div",{className:"space-y-2 p-3",children:Array.from({length:Math.min(6,s)}).map((o,i)=>e.jsx("div",{className:"grid grid-cols-[1.2fr_1fr_0.8fr_0.7fr] gap-3",children:Array.from({length:4}).map((y,u)=>e.jsx("div",{className:"h-3.5 animate-pulse rounded-full",style:{background:"var(--border)",width:`${tn(i,u)}%`,minWidth:32}},u))},i))})]})}),Zt="min-w-0 max-w-full overflow-hidden";return O&&!Le&&t.length===0||!n&&t.length===0&&!At?Sn():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:dt},children:[Gt(),Yt(),Xt(),e.jsx("div",{ref:er,className:Zt,children:e.jsx(Rt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Bt,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:ut,minWidth:Vt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Kt()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((o,i)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Dr,borderBottom:`1px solid ${ye}`},children:[Ze&&e.jsx("div",{role:"cell",className:`${g?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${ye}`,borderRight:`1px solid ${ye}`}},"select-cell"),Xe.map((y,u)=>{const j=ee&&!Dt&&u===0;return e.jsx("div",{role:"cell","data-dt-column-key":y.key,className:g?"px-2 py-1.5":"px-3 py-2",style:j?{position:"sticky",left:_t,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 ${ye}`,borderRight:`1px solid ${ye}`}:{borderBottom:`1px solid ${ye}`,borderRight:`1px solid ${ye}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${tn(i,u)}%`,minWidth:32}})},y.key)})]},i))})]})})}),kn()]}):!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:dt},children:[Gt(),Yt(),Xt(),e.jsx("div",{ref:er,className:Zt,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:ut,minWidth:Vt},children:e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Kt()})})}),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:ye,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(p.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:d}),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:dt},children:[Gt(),Yt(),Xt(),e.jsx("div",{ref:er,className:Zt,children:e.jsx(Rt.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Bt,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:ut,minWidth:Vt},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Kt()}),e.jsx("div",{role:"rowgroup",children:mn.map((o,i)=>{const y=a(o),u=yn(G==null?void 0:G(o)),j=i>0?yn(G==null?void 0:G(mn[i-1])):null,v=u&&u.key!==(j==null?void 0:j.key),le=Ze&&x.has(y),A=gr?(k==null?void 0:k(o))??!0:!1,Ee=A&&pn.has(y),Ne=!!f||N&&A,pe=le&&Y?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":i%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(l.Fragment,{children:[v&&e.jsx("div",{role:"row",className:`grid ${u.className??""}`,style:{gridTemplateColumns:Dr},children:e.jsx("div",{role:"cell",className:g?"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 ${ye}`,borderRight:`1px solid ${ye}`},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:u.label}),u.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:u.description})]})})})}),e.jsxs("div",{role:"row",onClick:Ne?ge=>{const me=ge.target;if(!(me!=null&&me.closest('[data-dt-disable-row-click="true"]'))){if(N&&A){hn(y);return}f==null||f(o)}}:void 0,className:`grid transition-colors ${Ne?"cursor-pointer":""} ${D?D(o):""}`,style:{gridTemplateColumns:Dr,"--dt-row-bg":pe,"--dt-sticky-bg":pe,background:"var(--dt-row-bg)",borderBottom:`1px solid ${ye}`},onMouseEnter:ge=>{le||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",Ys))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",pe),ge.currentTarget.style.setProperty("--dt-sticky-bg",pe)},children:[gr&&e.jsx("div",{role:"cell",className:`${g?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${ye}`,borderRight:`1px solid ${ye}`},"data-dt-disable-row-click":"true",children:A&&e.jsx("button",{type:"button","aria-label":Ee?"Contraer fila":"Desplegar fila","aria-expanded":Ee,onClick:ge=>{ge.stopPropagation(),hn(y)},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(p.HiChevronDown,{className:"h-4 w-4"}):e.jsx(p.HiChevronRight,{className:"h-4 w-4"})})}),Ze&&e.jsx("div",{role:"cell",className:`${g?"px-2 py-1.5":"px-3 py-2"} w-10`,style:ee?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${ye}`}:{borderBottom:`1px solid ${ye}`,borderRight:`1px solid ${ye}`},onClick:ge=>{ge.stopPropagation(),w(y)},children:e.jsx(Ir,{size:"sm",checked:le,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ge=>ge.stopPropagation(),onChange:()=>w(y)})}),Xe.map((ge,me)=>{const Ae=ee&&!Dt&&me===0,xe=tr(ge);return e.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||xe?"true":void 0,className:`${xe?"px-2 py-1.5 text-center":`${g?"px-2 py-1.5":"px-3 py-2"} ${vn(ge.align)}`} ${fl} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ae?{position:"sticky",left:_t,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${ye}`,borderRight:`1px solid ${ye}`}:{borderBottom:`1px solid ${ye}`,borderRight:`1px solid ${ye}`}},children:e.jsx(ma,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(o)})})},ge.key)})]}),Ee&&h&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Dr},children:e.jsx("div",{role:"cell",className:g?"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 ${ye}`},children:h(o)})})]},y)})})]})})}),kn()]})}function Nr(r){return r?new Date(`${r}T12:00:00`):void 0}function ha(r){return r.toISOString().slice(0,10)}function Sl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:d,formatters:b}=ea.useDayPicker(),f=!!a&&t===0,h=!!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":d.labelPrevious(a),onClick:()=>a&&s(a),disabled:!f,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:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(p.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":d.labelNext(n),onClick:()=>n&&s(n),disabled:!h,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:h?1:.45,cursor:h?"pointer":"not-allowed"},children:e.jsx(p.HiChevronRight,{size:16})})]})}function Cl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function El({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:d=!0,startLabel:b="Inicio",endLabel:f="Regreso"}){const h={from:Nr(r),to:Nr(t)},k=Nr(n),[S,m]=l.useState(Nr(s||r));return l.useEffect(()=>{m(Nr(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(ea.DayPicker,{mode:"range",selected:h,month:S,onMonthChange:m,onSelect:C=>{const N=C!=null&&C.from?ha(C.from):r,x=C!=null&&C.to?ha(C.to):"";a({startDate:N,endDate:x})},numberOfMonths:c,hideNavigation:!0,disabled:k?{before:k}:void 0,showOutsideDays:!1,components:{MonthCaption:Sl},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:C=>Cl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(C)),formatWeekdayName:C=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(C)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),d&&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:[f,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Ml="bonsaif-ui:hide-tooltips";function va(){window.dispatchEvent(new CustomEvent(Ml))}function Ll(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function $l({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:d="",onOpenChange:b}){const[f,h]=l.useState(!1),[k,S]=l.useState(!1),[m,C]=l.useState({}),N=l.useRef(null),x=l.useRef(null),w=l.useCallback(L=>{h(L),b==null||b(L)},[b]),H=l.useCallback(()=>{const L=N.current;if(!L)return;const I=L.getBoundingClientRect(),X=typeof n=="number"?n:I.width,J=typeof n=="number"?n:Math.max(I.width,180),F=a==="end"?Math.max(8,I.right-J):Math.min(I.left,window.innerWidth-J-8),K=window.innerHeight-I.bottom,Z=K<240&&I.top>K?void 0:I.bottom+6,E=Z===void 0?window.innerHeight-I.top+6:void 0;C({position:"fixed",zIndex:9999,left:F,top:Z,bottom:E,width:Ll(typeof n=="number"?X:n)})},[a,n]);l.useEffect(()=>S(!0),[]),l.useEffect(()=>{if(!f)return;H();const L=X=>{var F,K;const J=X.target;!((F=N.current)!=null&&F.contains(J))&&!((K=x.current)!=null&&K.contains(J))&&w(!1)},I=X=>{X.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",L),window.addEventListener("keydown",I),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{document.removeEventListener("mousedown",L),window.removeEventListener("keydown",I),window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[f,w,H]);const Y=L=>{s||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),w(!f))},D=l.isValidElement(r)?l.cloneElement(r,{onClick:()=>{s||(va(),w(!f))}}):r,G=f?e.jsx("div",{ref:x,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${d}`,style:m,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 I;L.disabled||(va(),(I=L.onSelect)==null||I.call(L),w(!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:N,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":f,onKeyDown:Y,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[D,k&&G?ze.createPortal(G,document.body):null]})}const Tl=180,ga="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Hl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:d,loading:b=!1,confirmDisabled:f=!1,headerActions:h,bodyClassName:k="flex-1 overflow-y-auto px-6 py-5",width:S=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:C="Descartar cambios",unsavedChangesDescription:N="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:x="Descartar",unsavedChangesCancelLabel:w="Seguir editando",onDiscardChanges:H,children:Y}){const[D,G]=l.useState(!1),[L,I]=l.useState(!1),[X,J]=l.useState(!1),F=l.useCallback(()=>{I(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>J(!0))})},[]),K=l.useCallback(()=>{J(!1),window.setTimeout(()=>I(!1),Tl)},[]),Z=l.useCallback(()=>{if(m){F();return}t()},[m,t,F]),E=l.useCallback(()=>{J(!1),I(!1),H==null||H(),t()},[t,H]);return l.useEffect(()=>{G(!0)},[]),l.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(J(!1),I(!1)),()=>{document.body.style.overflow=""}),[r]),l.useEffect(()=>{if(!r)return;const B=_=>{if(_.key==="Escape"){if(L){K();return}Z()}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[K,L,r,Z]),D?ze.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 ${ga}`,onClick:Z}),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, ${S}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:Z,title:"Cerrar",children:e.jsx(p.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})]})]}),(h||d)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[h,d&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{variant:"secondary",size:"sm",onClick:Z,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Te,{variant:"primary",size:"sm",icon:e.jsx(En.FiSave,{className:"w-4 h-4"}),onClick:d,loading:b,disabled:f,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:k,children:Y})]}),L&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":C,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${ga} transition-opacity duration-200 ease-out ${X?"opacity-100":"opacity-0"}`,onClick:K}),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 ${X?"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:K,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":w,children:e.jsx(p.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(p.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:C}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:N}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:K,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:w}),e.jsx(Te,{variant:"secondary",onClick:E,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:x})]})]})]})]}),document.body):null}const Al=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Dl=/^\+?[0-9\s().-]+$/,Bl=7,Ol=15;function _e(r){return r==null||String(r).trim()===""}function xa(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function yt(r){return _e(r)?!1:Al.test(String(r))}function wt(r){if(_e(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return Dl.test(t)&&a.length>=Bl&&a.length<=Ol}function Il(r="Este campo es requerido."){return t=>_e(t)?r:void 0}function Fl(r="Ingresa un correo valido."){return t=>_e(t)||yt(t)?void 0:r}function Pl(r="Ingresa un telefono valido."){return t=>_e(t)||wt(t)?void 0:r}function jl(r,t){return a=>_e(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function zl(r,t){return a=>_e(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function _l(r,t){return a=>{if(_e(a))return;const n=xa(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Wl(r,t){return a=>{if(_e(a))return;const n=xa(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function ql(r,t="El formato no es valido."){return a=>_e(a)||r.test(String(a))?void 0:t}function Ul(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 d of c){const b=d(r[n],r);if(b){a[n]=b;break}}}return{valid:Object.keys(a).length===0,errors:a}}var ya={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},wa=l.createContext&&l.createContext(ya),Vl=["attr","size","title"];function Kl(r,t){if(r==null)return{};var a,n,s=Gl(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 Gl(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 Ur(){return Ur=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},Ur.apply(null,arguments)}function Na(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 Vr(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Na(Object(a),!0).forEach(function(n){Yl(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Na(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function Yl(r,t,a){return(t=Xl(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function Xl(r){var t=Zl(r,"string");return typeof t=="symbol"?t:t+""}function Zl(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 ka(r){return r&&r.map((t,a)=>l.createElement(t.tag,Vr({key:a},t.attr),ka(t.child)))}function Nt(r){return t=>l.createElement(Jl,Ur({attr:Vr({},r.attr)},t),ka(r.child))}function Jl(r){var t=a=>{var{attr:n,size:s,title:c}=r,d=Kl(r,Vl),b=s||a.size||"1em",f;return a.className&&(f=a.className),r.className&&(f=(f?f+" ":"")+r.className),l.createElement("svg",Ur({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,d,{className:f,style:Vr(Vr({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 wa!==void 0?l.createElement(wa.Consumer,null,a=>t(a)):t(ya)}function Sa(r){return Nt({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 Ql(r){return Nt({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 Rl(r){return Nt({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 Kr({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 kt({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:c="Error de validacion",labelAction:d,floatingLabel:b=!1,showPasswordToggle:f=!0,nativeValidation:h=!1,className:k="",required:S,...m}){const[C,N]=l.useState(()=>!!m.autoFocus),[x,w]=l.useState(!1),H=m.type==="password"&&f,Y=H&&x?"text":m.type,D=!!n,G=D&&s!=="tooltip",L=D&&s!=="inline",I=h?S:void 0,X=D?"border-[var(--danger)] focus:border-[var(--danger)]":"",J=L?H?"pr-20":"pr-10":H?"pr-10":"",F=m.value!==void 0?String(m.value).length>0:m.defaultValue!==void 0&&String(m.defaultValue).length>0,K=C||F,Z={top:K?7:12,color:C?"var(--primary)":"var(--text-muted)",fontSize:K?10:13,fontWeight:K?600:400,textTransform:K?"uppercase":"none"},E=ee=>{var P;N(!0),(P=m.onFocus)==null||P.call(m,ee)},B=ee=>{var P;N(!1),(P=m.onBlur)==null||P.call(m,ee)},_=H?e.jsxs("button",{type:"button","aria-label":x?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":x,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>w(ee=>!ee),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${x?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(Ql,{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 ${x?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(Rl,{className:"h-[18px] w-[18px]"})})]}):null,O=L?e.jsx(cr,{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)] ${H?"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(Sa,{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(Kr,{...m,type:Y,required:I,placeholder:" ","aria-invalid":D||m["aria-invalid"],"data-has-value":F?"true":void 0,className:`h-11 w-full pt-5 ${J} ${X} ${k}`,onFocus:E,onBlur:B}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[r,S&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),d&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:K?7:12},children:d}),O,_]}),G?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}),S&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),d&&e.jsx("span",{className:"ml-auto normal-case",children:d})]}),H?e.jsxs("span",{className:"relative block",children:[e.jsx(Kr,{...m,type:Y,required:I,"aria-invalid":D||m["aria-invalid"],className:`w-full ${J} ${X} ${k}`,onFocus:E,onBlur:B}),O,_]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Kr,{...m,required:I,"aria-invalid":D||m["aria-invalid"],className:`w-full ${J} ${X} ${k}`}),O]}),G?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 Ca(r){return r==null?"":String(r)}function eo({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:c,value:d,defaultValue:b,onChange:f,...h}){const[k,S]=l.useState(()=>Ca(b)),m=d!==void 0?Ca(d):k,C=a&&m.length>0&&!yt(m)?n:void 0,N=x=>{d===void 0&&S(x.currentTarget.value),f==null||f(x)};return e.jsx(kt,{...h,value:d,defaultValue:b,type:"text",inputMode:t,autoComplete:r,error:c??C,errorDisplay:s,onChange:N})}const ro={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function to({title:r="Sin resultados",description:t,icon:a=e.jsx(p.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:d=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${ro[c]} ${d}`,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 ao={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function no(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 Ea(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 lo(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function oo({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:c=[],onFilesChange:d,onRejectedFiles:b,multiple:f=!1,maxFiles:h,appendFiles:k=!1,showFileList:S=!0,clearable:m=!0,browseLabel:C="Buscar archivos",dropLabel:N="Suelta los archivos aqui",emptyLabel:x="Arrastra y suelta archivos",emptyDescription:w="o haz click para buscarlos en tu equipo",selectedLabel:H="Archivos seleccionados",size:Y="md",containerClassName:D="",dropzoneClassName:G="",fileListClassName:L="",className:I="",id:X,accept:J,disabled:F,required:K,...Z}){const E=l.useId(),B=X??E,_=l.useRef(null),[O,ee]=l.useState(!1),[P,g]=l.useState(c),z=s??P,V=!!a,ae=m&&z.length>0&&!F,te=(ne,ve)=>{s===void 0&&g(ne),d==null||d(ne,ve)},he=(ne,ve)=>{const oe=ne.filter(ce=>Ea(ce,J)),M=ne.filter(ce=>!Ea(ce,J)),W=k?[...z,...oe]:oe,ie=lo(W,f,h);M.length>0&&(b==null||b(M)),te(ie,ve)},$=()=>{var ne;F||(ne=_.current)==null||ne.click()},ue=ne=>{he(Array.from(ne.target.files??[]),ne),ne.target.value=""},T=ne=>{ne.preventDefault(),F||ee(!0)},se=ne=>{ne.currentTarget.contains(ne.relatedTarget)||ee(!1)},fe=ne=>{ne.preventDefault(),ee(!1),!F&&he(Array.from(ne.dataTransfer.files),ne)},U=ne=>{ne.key!=="Enter"&&ne.key!==" "||(ne.preventDefault(),$())},re=ne=>{te(z.filter((ve,oe)=>oe!==ne))},R=()=>{te([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${D}`,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}),K&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...Z,ref:_,id:B,type:"file",accept:J,multiple:f,disabled:F,required:K&&z.length===0,"aria-invalid":V||Z["aria-invalid"],className:"sr-only",onChange:ue}),e.jsxs("div",{role:"button",tabIndex:F?-1:0,"aria-controls":B,"aria-disabled":F||void 0,"aria-invalid":V||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)] ${ao[Y]} ${O?"border-[var(--primary)] bg-[var(--bg-input)]":V?"border-[var(--danger)]":"border-[var(--border)]"} ${F?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${G} ${I}`,onClick:$,onDragOver:T,onDragLeave:se,onDrop:fe,onKeyDown:U,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(p.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:O?N:x}),w&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:w})]}),C&&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:C})]}),S&&z.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:H}),ae&&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:R,children:e.jsx(p.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:z.map((ne,ve)=>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(p.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:ne.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:no(ne.size)})]}),!F&&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 ${ne.name}`,onClick:()=>re(ve),children:e.jsx(p.HiXMark,{className:"h-4 w-4"})})]},`${ne.name}-${ne.lastModified}-${ve}`))})]}),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 so=[{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 io({fields:r,title:t="Layout",fieldTypes:a=so,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:c="Nuevo campo",addFieldLabel:d="Anadir",loading:b=!1,onSave:f,onChange:h}){const[k,S]=l.useState(()=>r.map(D=>({key:!1,type:"",...D}))),[m,C]=l.useState(""),[N,x]=l.useState(""),w=l.useCallback((D,G)=>{S(L=>{const I=L.map((X,J)=>J===D?{...X,...G}:X);return h==null||h(I),I})},[h]),H=l.useCallback(()=>{f==null||f(k)},[k,f]),Y=l.useCallback(()=>{var I;const D=m.trim();if(!D){x("Ingresa un nombre de campo.");return}if(k.some(X=>X.name.toLowerCase()===D.toLowerCase())){x("Ese campo ya existe en el arreglo.");return}const L={name:D,key:!1,type:((I=a[0])==null?void 0:I.value)??""};S(X=>{const J=[...X,L];return h==null||h(J),J}),C(""),x("")},[a,k,m,h]);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:[k.map((D,G)=>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:D.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Ir,{size:"sm",checked:D.key??!1,onChange:L=>w(G,{key:L.target.checked}),"aria-label":`${D.name} es clave`})}),e.jsx(dr,{value:D.type??"",onChange:L=>w(G,{type:L}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${D.name}`})]},D.name)),k.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:m,onChange:D=>{C(D.currentTarget.value),N&&x("")},onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),Y())},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:Y,height:36,padding:"0 12px",children:d})]}),N&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:N})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Te,{variant:"primary",onClick:H,disabled:b,loading:b,children:n})})]})})]})}function Ma({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:d="",contentClassName:b=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${d}`,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 co(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function uo({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:d,height:b=40,padding:f="6px 10px",searchable:h=!0,minOptionsForSearch:k=6,maxVisibleValues:S=2,truncateSelectedValues:m=!0,emptyText:C="Sin resultados",clearLabel:N="Limpiar seleccion"}){const[x,w]=l.useState(!1),[H,Y]=l.useState(""),[D,G]=l.useState(0),[L,I]=l.useState(!1),[X,J]=l.useState({}),F=l.useRef(null),K=l.useRef(null),Z=l.useRef(null),E=l.useRef(null),B=h&&a.length>=k,_=l.useMemo(()=>new Set(r),[r]),O=l.useMemo(()=>a.filter(T=>_.has(T.value)),[a,_]),ee=S==="all"?O.length:S,P=O.slice(0,ee),g=Math.max(0,O.length-P.length),z=B&&H.trim()?a.filter(T=>{var se;return T.label.toLowerCase().includes(H.toLowerCase())||((se=T.sublabel)==null?void 0:se.toLowerCase().includes(H.toLowerCase()))}):a,V=l.useCallback(()=>{const T=F.current;if(!T)return;const se=T.getBoundingClientRect(),fe=B?304:244,U=window.innerHeight-se.bottom,re=U<fe&&se.top>U;J({position:"fixed",left:se.left,top:re?void 0:se.bottom+4,bottom:re?window.innerHeight-se.top+4:void 0,width:se.width,zIndex:9999})},[B]),ae=l.useCallback(T=>{co(r,T)||t(T)},[t,r]),te=l.useCallback(T=>{const se=a.find(U=>U.value===T);if(se!=null&&se.disabled)return;const fe=_.has(T)?r.filter(U=>U!==T):[...r,T];ae(fe)},[ae,a,r,_]),he=l.useCallback(()=>ae([]),[ae]);l.useEffect(()=>I(!0),[]),l.useEffect(()=>{if(!x)return;function T(se){var U,re;const fe=se.target;!((U=F.current)!=null&&U.contains(fe))&&!((re=K.current)!=null&&re.contains(fe))&&(w(!1),Y(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[x]),l.useEffect(()=>{x&&(G(0),V(),B&&setTimeout(()=>{var T;return(T=Z.current)==null?void 0:T.focus()},0))},[x,B,V]),l.useEffect(()=>{if(x)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[x,V]),l.useEffect(()=>{if(D<0||!E.current)return;const T=E.current.children[D];T==null||T.scrollIntoView({block:"nearest"})},[D]);function $(T){if(!x){(T.key==="Enter"||T.key===" "||T.key==="ArrowDown")&&(T.preventDefault(),w(!0));return}T.key==="Escape"&&(T.preventDefault(),w(!1),Y("")),T.key==="ArrowDown"&&(T.preventDefault(),G(se=>Math.min(se+1,z.length-1))),T.key==="ArrowUp"&&(T.preventDefault(),G(se=>Math.max(se-1,0))),T.key==="Enter"&&z[D]&&(T.preventDefault(),te(z[D].value)),T.key==="Backspace"&&!H&&r.length&&(T.preventDefault(),ae(r.slice(0,-1)))}const ue=e.jsxs("div",{ref:K,className:"overflow-hidden rounded-xl shadow-xl",style:{...X,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[B&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(p.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:Z,value:H,onChange:T=>{Y(T.target.value),G(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),H&&e.jsx("button",{type:"button",onMouseDown:T=>{T.preventDefault(),Y("")},children:e.jsx(p.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),O.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:[O.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:T=>{T.preventDefault(),he()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:N})]}),e.jsxs("ul",{ref:E,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:B?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[z.map((T,se)=>{const fe=se===D,U=_.has(T.value);return e.jsxs("li",{role:"option","aria-selected":U,onMouseDown:re=>{re.preventDefault(),te(T.value)},onMouseEnter:()=>!T.disabled&&G(se),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:fe?"var(--bg-hover)":U?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:T.disabled?"var(--text-muted)":"var(--text-main)",cursor:T.disabled?"not-allowed":"pointer",opacity:T.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:U?"var(--primary)":"var(--border)",background:U?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:U&&e.jsx(p.HiCheck,{className:"h-3 w-3"})}),T.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:T.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:T.label}),T.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:T.sublabel})]}),T.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:T.badge})]},T.value)}),z.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:C})]})]});return e.jsxs("div",{ref:F,className:`relative ${c||"w-full"}`,style:d,onKeyDown:$,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&w(T=>!T),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(f),background:"var(--bg-input)",color:O.length?"var(--text-main)":"var(--text-muted)",border:x?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":x,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:P.length?e.jsxs(e.Fragment,{children:[P.map(T=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${m?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[T.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:T.color}}),e.jsx("span",{className:m?"truncate":"break-words",children:T.label})]},T.value)),g>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:["+",g]})]}):e.jsx("span",{className:"truncate",children:n})}),O.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":N,onMouseDown:T=>{T.preventDefault(),T.stopPropagation(),he()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(p.HiXMark,{className:"h-3 w-3"})}):e.jsx(p.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:x?"rotate(180deg)":"rotate(0deg)"}})]}),x&&L&&ze.createPortal(ue,document.body)]})}function bo({inputMode:r="decimal",...t}){return e.jsx(kt,{...t,type:"number",inputMode:r})}function fo(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 d=s;d<=c;d+=1)n.push(d);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function po({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const d=Math.max(1,t),b=Math.min(Math.max(1,r),d),f=fo(b,d,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(p.HiChevronLeft,{className:"h-4 w-4"})}),f.map((h,k)=>h==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${k}`):e.jsx("button",{type:"button","aria-current":h===b?"page":void 0,disabled:n,onClick:()=>a(h),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:h===b?"var(--primary)":"var(--border)",background:h===b?"var(--primary)":"var(--bg-card)",color:h===b?"var(--primary-fg)":"var(--text-secondary)"},children:h},h)),e.jsx(Te,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||b>=d,onClick:()=>a(b+1),children:e.jsx(p.HiChevronRight,{className:"h-4 w-4"})})]})}const $a=[{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 Ta(r){return r==null?"":String(r)}function Gr(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function mo(r){return typeof r=="number"?`${r}px`:r}function ho({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:c,value:d,defaultValue:b,onChange:f,countryCode:h,defaultCountryCode:k="+1",onCountryCodeChange:S,allowedCountryCodes:m,countryCodeOptions:C,countryCodePlaceholder:N="Codigo",countryCodeClassName:x="",countryCodeWidth:w=84,onPhoneValueChange:H,label:Y,containerClassName:D="",helperText:G,labelAction:L,className:I="",required:X,disabled:J,floatingLabel:F,showPasswordToggle:K,nativeValidation:Z,errorTooltipLabel:E="Error de validacion",...B}){var ne;const[_,O]=l.useState(()=>Ta(b)),[ee,P]=l.useState(()=>Gr(k)),g=l.useMemo(()=>{const ve=C??$a,oe=m==null?void 0:m.map(Gr);return oe!=null&&oe.length?ve.filter(M=>oe.includes(M.value)):ve},[m,C]),z=((ne=g[0])==null?void 0:ne.value)??"+1",V=g.some(ve=>ve.value===Gr(h??ee))?Gr(h??ee):z,ae=d!==void 0?Ta(d):_,te=`${V} ${ae}`.trim(),he=a&&ae.length>0&&!wt(te)?n:void 0,$=c??he,ue=!!$,T=ue&&s!=="tooltip",se=ue&&s!=="inline",fe=ue?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",U=ve=>{const oe=ve.currentTarget.value;d===void 0&&O(oe),H==null||H(oe,{countryCode:V,nationalNumber:oe,fullNumber:`${V} ${oe}`.trim()}),f==null||f(ve)},re=ve=>{h===void 0&&P(ve),S==null||S(ve),H==null||H(ae,{countryCode:ve,nationalNumber:ae,fullNumber:`${ve} ${ae}`.trim()})},R=se?e.jsx(cr,{as:"span",content:$,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":E,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Sa,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${D}`,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:Y}),X&&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 ${fe}`,children:[e.jsx(dr,{value:V,onChange:re,options:g,placeholder:N,disabled:J,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${x}`,style:{width:mo(w)},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",{...B,value:d,defaultValue:b,type:"tel",inputMode:t,autoComplete:r,disabled:J,required:void 0,"aria-label":B["aria-label"]??(typeof Y=="string"?Y:void 0),"aria-invalid":ue||B["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 ${se?"pr-10":""} ${I}`,onChange:U}),R]})]}),T?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:$}):G?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:G}):null]})}function vo({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:d=!1,className:b="",optionClassName:f=""}){return e.jsxs("fieldset",{className:`min-w-0 ${b}`,disabled:d,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(h=>{const k=h.value===r,S=d||h.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 ${S?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${f}`,style:{borderColor:k?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:k?"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:h.value,checked:k,disabled:S,onChange:()=>t(h.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${k?"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:h.label}),h.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:h.description})]})]},h.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>',Yr=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Aa=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),go=r=>r.replace(/[<>]/g,"").toLowerCase(),xo=r=>new RegExp("\\p{L}","u").test(r),St=(r,t)=>{const a=r.trim();return!a||!xo(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===Aa(a)},Da=r=>{const t=n=>{var s,c;if(!n.closest(".rich-img-wrap")){const d=document.createElement("span");d.className="rich-img-wrap",d.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(d,n),d.appendChild(n),d.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 yo({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px"}){const s=l.useRef(null),c=l.useRef(null),d=l.useRef(null),b=l.useRef(!1),f=l.useRef(r??""),h=l.useRef(t),[k,S]=l.useState(()=>!r||r.trim()===""),[m,C]=l.useState(new Set),[N,x]=l.useState(null),[w,H]=l.useState(""),[Y,D]=l.useState(""),[G,L]=l.useState(""),[I,X]=l.useState(""),[J,F]=l.useState(!1),K=l.useCallback(()=>b.current?c.current:s.current,[]);l.useEffect(()=>{h.current=t},[t]);const Z=l.useCallback(()=>{const M=window.getSelection(),W=K();if(!M||!W||M.rangeCount===0||M.isCollapsed)return"";const ie=M.getRangeAt(0);return!W.contains(ie.startContainer)||!W.contains(ie.endContainer)?"":M.toString()},[K]);l.useEffect(()=>{const M=r??"";f.current=M;const W=[s.current,c.current].filter(ce=>!!ce);W.forEach(ce=>{ce.innerHTML!==M&&(ce.innerHTML=M)}),S(!M||M.trim()==="");const ie=W.map(ce=>Da(ce));return()=>ie.forEach(ce=>ce())},[r]),l.useEffect(()=>{var ce,ke;b.current=J;let M,W=0,ie;if(J){const be=s.current;be&&(f.current=be.innerHTML);const Se=()=>{var de;const we=c.current;if(!we){W=requestAnimationFrame(Se);return}we.innerHTML!==f.current&&(we.innerHTML=f.current),M=Da(we),S(((de=we.textContent)==null?void 0:de.trim())===""),ie=setTimeout(()=>we.focus(),60)};W=requestAnimationFrame(Se)}else{const be=c.current,Se=s.current,we=(be==null?void 0:be.innerHTML)??f.current,de=f.current;f.current=we,Se&&Se.innerHTML!==we&&(Se.innerHTML=we),we!==de&&h.current(we),S(((ke=(ce=be??Se)==null?void 0:ce.textContent)==null?void 0:ke.trim())==="")}return()=>{W&&cancelAnimationFrame(W),ie&&clearTimeout(ie),M==null||M()}},[J]);const E=l.useCallback(()=>{const M=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],W=new Set;M.forEach(ce=>{try{document.queryCommandState(ce)&&W.add(ce)}catch{return}});try{const ce=go(document.queryCommandValue("formatBlock"));ce&&W.add(`formatBlock:${ce}`)}catch{return}const ie=Z();St(ie,"uppercase")&&W.add("__upper"),St(ie,"lowercase")&&W.add("__lower"),St(ie,"capitalize")&&W.add("__cap"),C(W)},[Z]),B=()=>{var W;const M=K();M&&(f.current=M.innerHTML,h.current(f.current),S(((W=M.textContent)==null?void 0:W.trim())===""))},_=M=>{if(!M){const W=s.current;W&&(f.current=W.innerHTML)}F(!M)},O=(M,W)=>{var ie;(ie=K())==null||ie.focus(),document.execCommand(M,!1,W),B(),E()},ee=M=>{O("formatBlock",M)},P=()=>{var M;(M=K())==null||M.focus(),document.execCommand("insertHTML",!1,"<hr><p><br></p>"),B(),E()},g=()=>{const M=window.getSelection();M&&M.rangeCount>0&&(d.current=M.getRangeAt(0).cloneRange())},z=()=>{const M=window.getSelection();M&&d.current&&(M.removeAllRanges(),M.addRange(d.current))},V=M=>{if(g(),M==="link"){const W=window.getSelection();D(W&&!W.isCollapsed?W.toString():""),H("")}M==="image"&&(L(""),X("")),x(M)},ae=()=>{var ce;if(!w.trim())return;z(),(ce=K())==null||ce.focus();const M=window.getSelection(),ie=(M&&!M.isCollapsed?M.toString():"")||Y.trim()||w.trim();document.execCommand("insertHTML",!1,`<a href="${Yr(w.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Yr(ie)}</a>`),B(),x(null)},te=(M,W="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Yr(M)}" alt="${Yr(W)}" class="rich-img" />${Ha()}</span>`,he=()=>{var M;G.trim()&&(z(),(M=K())==null||M.focus(),document.execCommand("insertHTML",!1,te(G.trim(),I.trim())),B(),x(null))},$=(M,W=1200,ie=1200,ce=.72)=>new Promise((ke,be)=>{const Se=new FileReader;Se.onerror=be,Se.onload=we=>{var Ve;const de=(Ve=we.target)==null?void 0:Ve.result,Be=new Image;Be.onerror=be,Be.onload=()=>{let{width:je,height:Q}=Be;if(je>W||Q>ie){const Ie=Math.min(W/je,ie/Q);je=Math.round(je*Ie),Q=Math.round(Q*Ie)}const Me=document.createElement("canvas");Me.width=je,Me.height=Q;const Le=Me.getContext("2d");if(!Le){ke(de);return}Le.drawImage(Be,0,0,je,Q),ke(Me.toDataURL("image/jpeg",ce))},Be.src=de},Se.readAsDataURL(M)}),ue=M=>{const ie=Array.from(M.clipboardData.items).find(ke=>ke.type.startsWith("image/"));if(!ie)return;M.preventDefault();const ce=ie.getAsFile();ce&&$(ce).then(ke=>{var be;(be=K())==null||be.focus(),document.execCommand("insertHTML",!1,te(ke,"imagen")),B()})},T=M=>{const W=window.getSelection(),ie=K();if(!W||!ie||W.rangeCount===0||W.isCollapsed)return;const ce=W.getRangeAt(0);if(!ie.contains(ce.startContainer)||!ie.contains(ce.endContainer))return;const ke=ce.toString();if(!ke)return;let be=ke;M==="uppercase"?be=ke.toLocaleUpperCase():M==="lowercase"?be=ke.toLocaleLowerCase():be=Aa(ke),ce.deleteContents();const Se=document.createTextNode(be);ce.insertNode(Se);const we=document.createRange();we.setStart(Se,0),we.setEnd(Se,be.length),W.removeAllRanges(),W.addRange(we),d.current=we.cloneRange(),B(),E()},se=()=>{g(),E()},fe=()=>{B(),E()},U=M=>{if(M.key==="Escape"){if(N){x(null);return}if(b.current){F(!1);return}}N||(M.ctrlKey||M.metaKey)&&(M.key==="b"&&(M.preventDefault(),O("bold")),M.key==="i"&&(M.preventDefault(),O("italic")),M.key==="u"&&(M.preventDefault(),O("underline")),M.key==="k"&&(M.preventDefault(),V("link")))},re=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),R=(M,W,ie,ce,ke)=>{const be=ke??(m.has(ie)||ie==="__link"&&N==="link"||ie==="__img"&&N==="image");return e.jsx("button",{type:"button",title:W,onMouseDown:Se=>{Se.preventDefault(),ce?ce():O(ie)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:be?"var(--primary)":"var(--text-secondary)",background:be?"rgba(59,130,246,0.12)":"transparent"},children:M},ie)},ne=M=>{const W=M.target;if(W.closest("[data-action='delete-img']")){M.preventDefault();const ie=W.closest(".rich-img-wrap");ie&&(ie.remove(),B())}},ve=M=>e.jsxs(e.Fragment,{children:[N==="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:M},children:[e.jsx("input",{autoFocus:!0,type:"url",value:w,onChange:W=>H(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ae()),W.key==="Escape"&&x(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:Y,onChange:W=>D(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ae()),W.key==="Escape"&&x(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: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:()=>x(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),N==="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:M},children:[e.jsx("input",{autoFocus:!0,type:"url",value:G,onChange:W=>L(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),he()),W.key==="Escape"&&x(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:I,onChange:W=>X(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),he()),W.key==="Escape"&&x(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:he,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:()=>x(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),oe=(M,W)=>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:W},children:[R(e.jsx(p.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),R(e.jsx(p.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),re(),R(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ee("p"),m.has("formatBlock:p")||m.has("formatBlock:div")),R(e.jsx(p.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ee("h2"),m.has("formatBlock:h2")),R(e.jsx(p.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ee("h3"),m.has("formatBlock:h3")),R(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ee("blockquote"),m.has("formatBlock:blockquote")),re(),R(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),R(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),R(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),R(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),re(),R(e.jsx(p.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),R(e.jsx(p.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),R(e.jsx(p.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),R(e.jsx(p.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),re(),R(e.jsx(p.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),R(e.jsx(p.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),R(e.jsx(p.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),R(e.jsx(p.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),re(),R(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>T("uppercase")),R(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>T("lowercase")),R(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>T("capitalize")),re(),R(e.jsx(p.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>V("link")),R(e.jsx(p.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),R(e.jsx(p.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>V("image")),R(e.jsx(p.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",P),re(),R(e.jsx(p.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),R(e.jsx(p.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ee("p")),re(),e.jsx("button",{type:"button",title:M?"Salir del modo de enfoque (Esc)":"Modo de enfoque",onMouseDown:ie=>{ie.preventDefault(),_(M)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:M?e.jsx(p.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(p.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:fe,onKeyDown:U,onKeyUp:se,onSelect:se,onMouseUp:se,onPaste:ue,onMouseDown:ne,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${k?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ve("var(--bg-input)"),oe(!1,"var(--bg-input)")]}),e.jsxs(xt,{open:J,onClose:()=>F(!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:fe,onKeyDown:U,onKeyUp:se,onSelect:se,onMouseUp:se,onPaste:ue,onMouseDown:ne,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${k?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),ve("var(--bg-input)"),oe(!0,"var(--bg-input)")]})]})}function wo({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:d="",bodyClassName:b="p-4"}){const f=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${d}`,children:[f&&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 No={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)"}},ko={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 So({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const d=No[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 ${ko[a]} ${c}`,style:{color:d.text,background:d.bg,borderColor:d.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:d.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Ba={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)"}},Co={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"},Eo={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Mo={xs:148,sm:164,md:184},Lo={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 $o({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:c=!1,stopPropagation:d=!1,ariaLabel:b="Cambiar estado",title:f="Cambiar estado",className:h,selectClassName:k,menuClassName:S,optionClassName:m,spinnerClassName:C}){const[N,x]=l.useState(!1),[w,H]=l.useState(!1),[Y,D]=l.useState(-1),[G,L]=l.useState({}),I=l.useRef(null),X=l.useRef(null),J=l.useRef(null),F=t.find(g=>g.value===r)??t[0],K={...F!=null&&F.tone?Ba[F.tone]:void 0,...F==null?void 0:F.style},Z=s||c||t.length===0,E=g=>{d&&g.stopPropagation()},B=l.useCallback(()=>{x(!1),D(-1)},[]),_=l.useCallback(()=>{const g=I.current;if(!g)return;const z=g.getBoundingClientRect(),V=Math.max(z.width,Mo[n]),ae=Math.min(Math.max(t.length,1)*38+12,260),te=window.innerHeight-z.bottom,he=te<ae&&z.top>te,$=Math.min(Math.max(8,z.left+z.width/2-V/2),window.innerWidth-V-8);L({position:"fixed",left:$,top:he?void 0:z.bottom+6,bottom:he?window.innerHeight-z.top+6:void 0,width:V,zIndex:9999})},[t.length,n]),O=l.useCallback(g=>{g.disabled||(a(g.value),B())},[B,a]);l.useEffect(()=>H(!0),[]),l.useEffect(()=>{if(!N)return;_();const g=t.findIndex(z=>z.value===r);D(g>=0?g:0)},[N,t,_,r]),l.useEffect(()=>{if(!N)return;function g(z){var ae,te;const V=z.target;!((ae=I.current)!=null&&ae.contains(V))&&!((te=X.current)!=null&&te.contains(V))&&B()}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[B,N]),l.useEffect(()=>{if(N)return window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[N,_]),l.useEffect(()=>{if(Y<0||!J.current)return;const g=J.current.children[Y];g==null||g.scrollIntoView({block:"nearest"})},[Y]);function ee(g){if(!Z){if(!N){["Enter"," ","ArrowDown","ArrowUp"].includes(g.key)&&(g.preventDefault(),x(!0));return}if(g.key==="Escape"){g.preventDefault(),B();return}if(g.key==="ArrowDown"){g.preventDefault(),D(z=>Math.min(z+1,t.length-1));return}if(g.key==="ArrowUp"){g.preventDefault(),D(z=>Math.max(z-1,0));return}if(g.key==="Enter"||g.key===" "){g.preventDefault();const z=t[Y];z&&O(z)}}}const P=e.jsx("div",{ref:X,role:"listbox","aria-label":b,className:Je("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",S),style:{...G,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:E,onMouseDown:E,onPointerDown:E,children:e.jsx("div",{ref:J,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((g,z)=>{const V=g.value===r,ae=z===Y,te={...g.tone?Ba[g.tone]:void 0,...g.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":V,disabled:g.disabled,onMouseEnter:()=>!g.disabled&&D(z),onMouseDown:he=>{he.preventDefault(),O(g)},className:Je("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Lo[n],V?g.className:void 0,m),style:{...V?te:void 0,background:V?te.background??"color-mix(in srgb, var(--primary) 12%, transparent)":ae?"var(--bg-hover)":"transparent",color:V?te.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:V?e.jsx(p.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label})]},g.value)})})});return e.jsxs("span",{ref:I,className:Je("relative inline-flex shrink-0 items-center",h),onKeyDown:ee,onClick:E,onPointerDown:E,children:[e.jsx("button",{type:"button",disabled:Z,"aria-label":b,"aria-haspopup":"listbox","aria-expanded":N,title:f,onClick:()=>!Z&&x(g=>!g),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",Co[n],F==null?void 0:F.className,k),style:K,children:e.jsx("span",{className:"min-w-0 truncate",children:(F==null?void 0:F.label)??r})}),e.jsx(p.HiChevronDown,{"aria-hidden":"true",className:Je("pointer-events-none absolute opacity-70 transition-transform",Eo[n],N?"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)}),N&&w&&ze.createPortal(P,document.body)]})}function To({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:d="",listClassName:b="",panelClassName:f=""}){const h=r.find(N=>!N.disabled)??r[0],k=t??a??(h==null?void 0:h.id),S=r.find(N=>N.id===k)??h,m=N=>{N.disabled||n==null||n(N.id)},C=N=>{const x=r.filter(H=>!H.disabled);if(!x.length||!S)return;const w=x.findIndex(H=>H.id===S.id);(N.key==="ArrowRight"||N.key==="ArrowDown")&&(N.preventDefault(),m(x[(w+1)%x.length])),(N.key==="ArrowLeft"||N.key==="ArrowUp")&&(N.preventDefault(),m(x[(w-1+x.length)%x.length])),N.key==="Home"&&(N.preventDefault(),m(x[0])),N.key==="End"&&(N.preventDefault(),m(x[x.length-1]))};return e.jsxs("div",{className:d,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:C,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(N=>{const x=N.id===(S==null?void 0:S.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":x,"aria-controls":`${N.id}-panel`,id:`${N.id}-tab`,disabled:N.disabled,tabIndex:x?0:-1,onClick:()=>m(N),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:x?"var(--primary)":"var(--text-muted)",borderColor:x?"var(--primary)":"transparent",background:c==="pills"&&x?"var(--bg-card)":"transparent"},children:[N.icon&&e.jsx("span",{className:"shrink-0",children:N.icon}),e.jsx("span",{children:N.label}),N.badge&&e.jsx("span",{className:"shrink-0",children:N.badge})]},N.id)})}),(S==null?void 0:S.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${S.id}-panel`,"aria-labelledby":`${S.id}-tab`,className:`pt-4 ${f}`,children:S.content})]})}function Qe(...r){return r.filter(Boolean).join(" ")}function Ho({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:d,onBlockedStep:b,allowBackNavigation:f=!0,showFooter:h=!0,previousLabel:k="Anterior",nextLabel:S="Siguiente",blockedNextLabel:m="Completa este paso",className:C="",headerClassName:N="",contentClassName:x="",footerClassName:w=""}){var fe;const H=((fe=r[0])==null?void 0:fe.id)??"",[Y,D]=l.useState(a??H),[G,L]=l.useState(s),I=t??Y,X=n??G,J=l.useMemo(()=>new Set(X),[X]),F=Math.max(0,r.findIndex(U=>U.id===I)),K=r[F]??r[0],Z=r.length<=1?100:F/(r.length-1)*100,E=U=>{n||L(U),d==null||d(U)},B=U=>{const re=r.find(R=>R.id===U);re&&(t||D(U),c==null||c(U,re))},_=U=>J.has(U),O=U=>r.slice(0,U).find(re=>!re.optional&&!J.has(re.id)),ee=U=>{const re=r[U];return!re||re.disabled?!1:U===F||f&&U<F?!0:!O(U)},P=U=>{const re=r.findIndex(R=>R.id===U);return re>=0&&ee(re)},g=U=>{const re=r.findIndex(R=>R.id===U);if(re<0)return!1;if(!ee(re)){const R=O(re);return R&&(b==null||b(r[re],R)),!1}return B(U),!0},z=(U=K==null?void 0:K.id)=>{!U||J.has(U)||E([...X,U])},V=(U=K==null?void 0:K.id)=>{if(!U)return;const re=r.findIndex(ne=>ne.id===U),R=X.filter(ne=>{const ve=r.findIndex(oe=>oe.id===ne);return ve>=0&&ve<re});E(R),re>=0&&F>re&&B(U)},ae=()=>F<=0?!1:g(r[F-1].id),te=()=>{const U=r[F+1];return U?g(U.id):!1},he={activeStep:K,activeIndex:F,completedStepIds:X,isCompleted:_,isUnlocked:P,completeStep:z,uncompleteStep:V,goToStep:g,goNext:te,goPrevious:ae};if(!K)return null;const $=r[F+1],ue=F>0,T=$?P($.id):!1,se=typeof K.content=="function"?K.content(he):K.content;return e.jsxs("section",{className:Qe("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",C),children:[e.jsxs("div",{className:Qe("border-b border-[var(--border)] bg-[var(--bg-input)]",N),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:`${Z}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((U,re)=>{const R=U.id===K.id,ne=_(U.id),ve=ee(re),oe=O(re);return e.jsxs("button",{type:"button",disabled:!ve,"aria-current":R?"step":void 0,"aria-disabled":!ve,title:!ve&&oe?`Completa ${oe.title}`:U.title,onClick:()=>g(U.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",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",ne&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!ne&&ve&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ve&&"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",R&&"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",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",ne&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!ne&&!R&&ve&&"border-[var(--border)] text-[var(--text-muted)]",!ve&&"border-[var(--border)] text-[var(--text-muted)]"),children:ne?e.jsx(p.HiCheck,{className:"h-4 w-4"}):ve?re+1:e.jsx(p.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",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[re+1,". ",U.title]}),U.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:U.description})]}),U.badge&&e.jsx("span",{className:"shrink-0",children:U.badge})]})]},U.id)})})]}),e.jsx("div",{className:Qe("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",x),children:se},K.id),h&&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",w),children:[e.jsx(Te,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(p.HiChevronLeft,{}),disabled:!ue,onClick:ae,children:k}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",F+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[X.length," completados"]})]}),e.jsx(Te,{height:38,padding:"0 14px",icon:e.jsx(p.HiChevronRight,{}),disabled:!$||!T,onClick:te,children:$&&!T?m:S})]})]})}const Ao={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"},Do={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Bo(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function Oo(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:d,maxRows:b,showCount:f=!1,maxCount:h,status:k="default",icon:S,action:m,style:C,value:N,defaultValue:x,maxLength:w,onInput:H,...Y},D){const G=l.useRef(null),L=Oo(N,x),I=h??w,X=!!(S||m||f),J=k==="error"?"var(--danger)":k==="success"?"#16a34a":"var(--border)",F={...C??{},...d?{minHeight:`${d*24+18}px`}:null,...b?{maxHeight:`${b*24+18}px`}:null},K=()=>{const E=G.current;!E||!c||(E.style.height="auto",E.style.height=`${E.scrollHeight}px`)};l.useEffect(K,[c,N]);const Z=e.jsx("textarea",{...Y,ref:E=>{G.current=E,Bo(D,E)},value:N,defaultValue:x,maxLength:w,"aria-invalid":k==="error"||Y["aria-invalid"],onInput:E=>{K(),H==null||H(E)},style:{...F,borderColor:J},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 ${Ao[n]} ${Do[c?"none":s]} ${S?"pl-8":""} ${m?"pr-10":""} ${t}`});return X?e.jsxs("span",{className:`relative block ${a}`,children:[S&&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:S}),Z,m&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:m}),f&&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,I?`/${I}`:""]})]}):Z});function Io({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:d="",status:b,...f}){return e.jsx(Ma,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Oa,{...f,required:c,status:n?"error":b,className:`w-full ${d}`})})}const Fo={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Po({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const d=Fo[n],b=r?d.width-d.thumb-d.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:d.width,height:d.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:d.thumb,height:d.thumb,left:d.padding,top:"50%",transform:`translate(${b}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Ia=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function jo(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 Fa(r){return r.classList.contains("sidebar-scroll")}function Pa(r){Fa(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(Ia).forEach(c=>{if(!jo(c))return;if(Jt.OverlayScrollbars(c)){Pa(c);return}const b=Jt.OverlayScrollbars(c,{overflow:Fa(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});Pa(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(Ia).forEach(c=>{var d;c instanceof HTMLElement&&((d=r.get(c))==null||d.destroy())})}},[]),null}const zo={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"}},za=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],_o={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Wo="bonsaif.bot",qo="Bonsaif Bot",Uo={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function _a(r){return typeof r=="string"?r.trim():""}function Vo(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return za[t%za.length]}function Ko(r,t){return r===Wo||t===qo}function Go(r,t){return`${r.replace(/\/$/,"")}${t}`}function Wa({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:d,fallbackLabel:b="Usuario",wrapperClassName:f="",labelClassName:h="",labelSize:k="xs",avatarVersion:S=0,className:m="",style:C}){var _;const[N,x]=l.useState(!1),w=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";l.useEffect(()=>{x(!1)},[w,S]);const{wh:H,text:Y}=zo[n],D=_a(a)||_a(t)||b,G=D.trim()[0]||"?",L=typeof process<"u"&&((_=process.env)==null?void 0:_.NEXT_PUBLIC_BASE_PATH)||"",I=Ko(t,a),X=Go(L,"/favicon.svg"),J=w?`${L}/api/user/avatar/${w}${S?`?v=${S}`:""}`:"",K={xs:20,sm:28,md:36,lg:48,xl:64}[n],Z=I?e.jsx("span",{className:`${H} ${Uo[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 ${m}`,style:C,children:e.jsx("img",{src:X,alt:D,width:K,height:K,className:"h-full w-full object-contain"})}):J&&!N?e.jsx("img",{src:J,alt:D,width:K,height:K,className:`${H} rounded-full object-cover flex-shrink-0 ${m}`,style:C,onError:()=>x(!0)},`${w}-${S}`):e.jsx("span",{className:`${H} ${Vo(D)} ${Y} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${m}`,style:C,title:D,children:G});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[Z,e.jsx("span",{className:`min-w-0 truncate ${_o[k]} font-medium text-[var(--text-main)] ${h}`,title:D,children:D})]});const E=c??!0,B=d??D;return E&&B?e.jsx(cr,{as:"span",content:B,className:`inline-flex flex-shrink-0 ${f}`,children:Z}):Z}function Yo({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function Xo(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function qa({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:d,footer:b,onLogout:f,LinkComponent:h=Yo}){const[k,S]=l.useState(!1),m=Xo(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:()=>S(!0),children:e.jsx(p.HiBars3,{className:"h-5 w-5"})}),k&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>S(!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 ${k?"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(p.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:()=>S(!1),children:e.jsx(p.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(m).map(([C,N])=>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(p.HiChevronDown,{className:"h-3.5 w-3.5"}),C]}),e.jsx("div",{className:"space-y-1",children:N.map(x=>{const w=a===x.href||a.startsWith(`${x.href}/`);return e.jsxs(h,{href:x.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${w?"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:x.icon??e.jsx(p.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:x.label})]},x.href)})})]},C))}),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(Wa,{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})]})]}),f&&e.jsxs(Te,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:f,children:[e.jsx(p.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),b]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[d,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const Ua="bonsaif-ui:prime-auth-sso",Zo={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"},Ct={dashboard:e.jsx(p.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(p.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(p.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(p.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(p.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(p.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(p.HiUser,{className:"h-5 w-5"}),settings:e.jsx(p.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(p.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(p.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(p.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(p.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(p.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(p.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(p.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(p.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(p.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(p.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(p.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(p.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(p.HiShieldCheck,{className:"h-5 w-5"})};function Jo({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function Qo(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ro(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function es(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=Ro(a)&&n?n:a,c=Zo[s]??Qo(s);return[{label:"Inicio",href:"/"},{label:c}]}function Et(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function rs(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(p.HiHome,{className:"h-5 w-5"});if(Ct[a])return Ct[a];const n=t.length>1?t[t.length-2]:"";return Ct[n]??e.jsx(p.HiHome,{className:"h-5 w-5"})}function ts(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Va(){if(typeof window>"u")return!1;if(ts(window.location.href)){try{window.sessionStorage.setItem(Ua,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Ua)==="true"}catch{return!1}}function as({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:d="",breadcrumbs:b,currentPath:f,showBreadcrumbs:h=!0,contained:k=!1,LinkComponent:S=Jo}){const m=l.useRef(null),[C,N]=l.useState(!1),[x,w]=l.useState(f??"/"),[H,Y]=l.useState(()=>Va()),[D,G]=l.useState(null),L=f??x,I=b??es(L),X=s??rs(L),J=h&&!H&&I.length>1,F=!J;l.useEffect(()=>{f||w(window.location.pathname)},[f]),l.useEffect(()=>{Y(Va())},[]),l.useEffect(()=>{if(k){N(!1);return}let Z=null,E=0,B=0;const _=()=>{const P=m.current,g=document.querySelector("[data-app-scroll='true']");return(P==null?void 0:P.closest(".os-viewport"))??(P==null?void 0:P.closest("[data-overlayscrollbars-viewport]"))??Et(g)??g??window},O=()=>{const P=Z&&Z!==window?Z.scrollTop:window.scrollY;N(g=>g?P>24:P>72)},ee=()=>{Z==null||Z.removeEventListener("scroll",O),Z=_(),Z.addEventListener("scroll",O,{passive:!0}),O()};return ee(),E=window.requestAnimationFrame(ee),B=window.setTimeout(ee,120),()=>{window.cancelAnimationFrame(E),window.clearTimeout(B),Z==null||Z.removeEventListener("scroll",O)}},[k]),l.useEffect(()=>{if(k){G(null);return}let Z=0;const E=[],B=()=>{const V=m.current,ae=V==null?void 0:V.parentElement,te=document.querySelector("[data-app-scroll='true']"),he=Et(te)??te;if(!V||!ae||!he){G(null);return}const $=ae.getBoundingClientRect(),ue=window.getComputedStyle(ae),T=he.getBoundingClientRect(),se=he instanceof HTMLElement&&he.clientWidth>0?he.clientWidth:T.width,fe=$.left+parseFloat(ue.paddingLeft||"0"),U={marginLeft:Math.round(T.left-fe),width:Math.round(se)};G(re=>re&&re.marginLeft===U.marginLeft&&re.width===U.width?re:U)},_=()=>{window.cancelAnimationFrame(Z),Z=window.requestAnimationFrame(B)};_(),window.addEventListener("resize",_);const O=new ResizeObserver(_),ee=m.current,P=ee==null?void 0:ee.parentElement,g=document.querySelector("[data-app-scroll='true']"),z=Et(g)??g;return[P,g,z].forEach(V=>{V&&O.observe(V)}),E.push(window.setTimeout(_,120)),E.push(window.setTimeout(_,280)),()=>{window.cancelAnimationFrame(Z),window.removeEventListener("resize",_),O.disconnect(),E.forEach(V=>window.clearTimeout(V))}},[k]);const K={...D?{marginLeft:D.marginLeft,width:D.width}:null,"--page-header-control-height":C?"34px":"40px","--page-header-control-padding-x":C?"10px":"14px","--page-header-control-icon-left":C?"10px":"12px",background:k?"var(--bg-card)":C?"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:k||C?"1px solid var(--border)":"1px solid transparent",boxShadow:C?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:m,"data-page-header":"true","data-compact":C?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${k?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:K,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${C?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":F?"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"} ${d}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${C||F?"gap-1":"gap-1.5 sm:gap-2"}`,children:[J&&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 ${C?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:I.map((Z,E)=>{const B=E===I.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[E>0&&e.jsx(p.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),Z.href&&!B?e.jsx(S,{href:Z.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:Z.label}):e.jsx("span",{"aria-current":B?"page":void 0,className:B?"truncate font-semibold":"truncate",style:{color:B?"var(--text-main)":"var(--text-muted)"},children:Z.label})]},`${Z.label}-${E}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${C||F?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${C?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:J?"var(--text-secondary)":"var(--text-muted)"},children:X}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${C?"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 ${C?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":C,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${C?"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 ${C?"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 ${C?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(ta.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function ns({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(qa,{currentPath:t,...n,children:r})}function Ka(){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 ls(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 os({name:r,src:t,projectKey:a}){const[n,s]=l.useState("system"),c=l.useRef(null);l.useEffect(()=>{s(Ka());const f=new MutationObserver(()=>s(Ka()));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>f.disconnect()},[]);const d=l.useMemo(()=>ls(t,n,a),[a,t,n]),b=l.useMemo(()=>{try{return new URL(d).origin}catch{return""}},[d]);return l.useEffect(()=>{if(!a)return;const f=a;function h(k){var C,N,x;if(k.source!==((C=c.current)==null?void 0:C.contentWindow)||b&&k.origin!==b)return;if(((N=k.data)==null?void 0:N.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!k.data.active}}));return}if(((x=k.data)==null?void 0:x.type)!=="prime-microservice:navigation")return;const S=k.data.path;if(!S||!S.startsWith("/")||S.startsWith("//"))return;const m=`/apps/${encodeURIComponent(f)}${S}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==m&&(window.history.replaceState(window.history.state,"",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",h),()=>{window.removeEventListener("message",h),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:d,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 ss(){const[r,t]=l.useState(""),[a,n]=l.useState(!1),[s,c]=l.useState({width:96,height:96});return l.useEffect(()=>{let d=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(b=>b.ok?b.json():null).then(b=>{!d&&(b!=null&&b.src)&&t(b.src)}).catch(()=>{}),()=>{d=!0}},[]),l.useEffect(()=>{const d=b=>{var h;if(((h=b.data)==null?void 0:h.type)!=="prime-suite-chat:state")return;const f=!!b.data.active;n(f),c({width:Ga(b.data.width,96,720),height:Ga(b.data.height,96,560)})};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]),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 Ga(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function is(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 cs(){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 ds(){return"light"}function us({position:r="bottom-center"}){const t=l.useSyncExternalStore(is,cs,ds);return e.jsx(Qt.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function bs(r){const[t,a]=l.useState({}),[n,s]=l.useState(!1),c=l.useCallback(h=>n||t[h]?r[h]:void 0,[r,n,t]),d=l.useCallback(h=>{a(k=>({...k,[h]:!0}))},[]),b=l.useCallback(()=>{s(!0)},[]),f=l.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:c,touchField:d,submit:b,reset:f}}Object.defineProperty(q,"toast",{enumerable:!0,get:()=>Qt.toast}),q.Alert=Un,q.AuthShell=qa,q.BonsaifButton=Mn,q.BonsaifUIToaster=us,q.Button=Te,q.CalendarPicker=Xn,q.Checkbox=Ir,q.CodeBlock=el,q.CompactFilterSelect=tl,q.CompactSearchInput=rl,q.ConfirmDialog=ol,q.CopyButton=vt,q.CopyLinkButton=il,q.DataTable=kl,q.DateRangePicker=El,q.Drawer=Hl,q.DropdownMenu=$l,q.DynamicDetailTabs=Wn,q.EmailField=eo,q.EmptyState=to,q.FieldLayoutEditor=io,q.FileUpload=oo,q.FormField=Ma,q.GlobalScrollbars=ja,q.InputField=kt,q.LoadingState=oa,q.MicroserviceFrame=os,q.Modal=xt,q.MouseTooltip=cr,q.MultiSelect=uo,q.NumberField=bo,q.PageHeader=as,q.PageSearchInput=ra,q.Pagination=po,q.PhoneField=ho,q.PrimeAuthRouteShell=ns,q.PrimeSuiteChatFrame=ss,q.RadioGroup=vo,q.RichTextEditor=yo,q.SearchableSelect=dr,q.SectionPanel=wo,q.StatusBadge=So,q.StatusSelect=$o,q.StepWizard=Ho,q.Tabs=To,q.TextInput=Kr,q.Textarea=Oa,q.TextareaField=Io,q.Toggle=Po,q.UserAvatar=Wa,q.cn=Je,q.emailFormat=Fl,q.isValidEmail=yt,q.isValidPhone=wt,q.matches=ql,q.maxLength=zl,q.maxValue=Wl,q.minLength=jl,q.minValue=_l,q.phoneCountryCodeOptions=$a,q.phoneFormat=Pl,q.required=Il,q.useValidationVisibility=bs,q.validateForm=Ul,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})}));
|
|
21
|
+
</body></html>`,x=window.open("","_blank");x&&(x.document.write(z),x.document.close())}const ht=()=>!Se||!Tr?null:je.createPortal(e.jsxs("div",{ref:It,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...ws,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:()=>{Xs(),rt(!1)},children:[e.jsx(p.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:()=>{Zs(),rt(!1)},children:[e.jsx(p.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),vt=()=>{const o=fe&&Xe.trim().length>0,i=ie!=null&&ie.length?ie:o?[{key:"bql",label:"BQL",value:Xe}]:[],y=W.filter(u=>u.trim()&&u!==Rr).slice(0,8);return!te&&jt===0&&!fe&&!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:Ds,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(p.HiXMark,{className:"h-3.5 w-3.5"}),jt," filtros"]}),fe&&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){lr(!1);return}it(),lr(!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(p.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(p.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(p.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:ne}),i.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[i.slice(0,3).map(u=>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:[u.label,":"]}),e.jsx("span",{className:"truncate",children:u.value})]},u.key)),i.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",i.length-3]})]}),o&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:dn,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(p.HiXMark,{className:"h-4 w-4"})}),Ze&&je.createPortal(e.jsxs("div",{ref:Qa,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...vs,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:[oe.map(u=>e.jsxs("button",{type:"button",onClick:()=>st(u.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:[u.icon,u.label]},u.label)),L.length>0&&e.jsxs("button",{type:"button",onClick:()=>fr(u=>!u),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":Za,children:[e.jsx(p.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Lr.length>0&&e.jsxs("button",{type:"button",onClick:()=>pr(u=>!u),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":Ja,children:[e.jsx(p.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 ${ce?"var(--danger)":o?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:Ot,value:Rr,rows:3,onChange:u=>Wt(u.target.value,u.target),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),st(Rr)),u.key==="Escape"&&lr(!1)},placeholder:ve,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"}}),y.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:y.map(u=>e.jsx("button",{type:"button",onMouseDown:z=>{var x;z.preventDefault(),Wt(u),(x=Ot.current)==null||x.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:u},u))})]}),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:ce?"var(--danger)":"var(--text-muted)"},children:ce??(o?`${i.length||1} filtro${(i.length||1)===1?"":"s"} activo${(i.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),i.map(u=>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:[u.label,":"]}),e.jsx("span",{className:"truncate",children:u.value})]},u.key))]}),Ja&&Lr.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(p.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{$r([]),pr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(p.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Lr.map(u=>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(u),className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:u})}),e.jsx("button",{type:"button",onClick:()=>$r(z=>z.filter(x=>x!==u)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(p.HiXMark,{className:"h-3.5 w-3.5"})})]},u))]}),Za&&L.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:L.map(u=>e.jsxs("button",{type:"button",onClick:()=>{var z;Wt(u.bql),fr(!1),(z=Ot.current)==null||z.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:u.bql}),u.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:u.description})]},u.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:dn,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(p.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(p.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 z;const u=(z=tt.current)==null?void 0:z.getBoundingClientRect();u&&Ns({top:u.bottom+4,right:window.innerWidth-u.right}),rt(x=>!x)},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(p.HiArrowDownTray,{className:"h-4 w-4"})}),te&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&nr==="visibility","aria-label":se,title:se,onClick:u=>bn(u,"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&&nr==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(p.HiCog6Tooth,{className:"h-4 w-4"})})]})},kn=()=>{if(!Us)return null;const o=yl(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 ${v?"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:gr===0?"0 filas":`${Vs}–${Ks} de ${gr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(dr,{value:String(Ue),onChange:i=>Gs(Number(i)),options:X.map(i=>({value:String(i),label:String(i)})),placeholder:"Filas",searchable:!1,disabled:n,height:F,padding:K,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:J}})]})]}),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:i=>{i.currentTarget.disabled||(i.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",i.currentTarget.style.color="var(--primary)")},onMouseLeave:i=>{i.currentTarget.style.background="transparent",i.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(p.HiChevronLeft,{className:"h-3.5 w-3.5"})}),o.map((i,y)=>i==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${y}`):e.jsx("button",{disabled:n,onClick:()=>Gt(i),onMouseEnter:u=>{u.currentTarget.disabled||i===De||(u.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",u.currentTarget.style.color="var(--primary)")},onMouseLeave:u=>{u.currentTarget.style.background=i===De?"var(--primary)":"transparent",u.currentTarget.style.color=i===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:i===De?"var(--primary)":"transparent",color:i===De?"var(--primary-fg)":"var(--text-muted)"},children:i},i)),e.jsx("button",{disabled:n||De>=Kt,onClick:()=>Gt(De+1),onMouseEnter:i=>{i.currentTarget.disabled||(i.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",i.currentTarget.style.color="var(--primary)")},onMouseLeave:i=>{i.currentTarget.style.background="transparent",i.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(p.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},Sn=()=>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:M?{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,i)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${ge}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${v?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${ge}`,borderRight:`1px solid ${ge}`}},"select-cell"),qe.map((y,u)=>e.jsx("div",{role:"cell",className:v?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${ge}`,borderRight:`1px solid ${ge}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${rn(i,u)}%`,minWidth:32}})},y.key))]},i))})]})})]}),Xt="min-w-0 max-w-full overflow-hidden";return O&&!Le&&t.length===0||!n&&t.length===0&&!Ft?Sn():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:an,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:M?{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,i)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr,borderBottom:`1px solid ${ge}`},children:[Ve&&e.jsx("div",{role:"cell",className:`${v?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${ge}`,borderRight:`1px solid ${ge}`}},"select-cell"),qe.map((y,u)=>{const z=ee&&!Pt&&u===0;return e.jsx("div",{role:"cell","data-dt-column-key":y.key,className:v?"px-2 py-1.5":"px-3 py-2",style:z?{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 ${ge}`,borderRight:`1px solid ${ge}`}:{borderBottom:`1px solid ${ge}`,borderRight:`1px solid ${ge}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${rn(i,u)}%`,minWidth:32}})},y.key)})]},i))})]})})}),kn()]}):!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:M?{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:ge,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(p.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:d}),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:an,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:M?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ft()}),e.jsx("div",{role:"rowgroup",children:mn.map((o,i)=>{const y=a(o),u=yn(G==null?void 0:G(o)),z=i>0?yn(G==null?void 0:G(mn[i-1])):null,x=u&&u.key!==(z==null?void 0:z.key),le=Ve&&g.has(y),A=xr?(k==null?void 0:k(o))??!0:!1,Ee=A&&pn.has(y),Ne=!!f||N&&A,pe=le&&Y?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":i%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(l.Fragment,{children:[x&&e.jsx("div",{role:"row",className:`grid ${u.className??""}`,style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:v?"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 ${ge}`,borderRight:`1px solid ${ge}`},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:u.label}),u.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:u.description})]})})})}),e.jsxs("div",{role:"row",onClick:Ne?xe=>{const me=xe.target;if(!(me!=null&&me.closest('[data-dt-disable-row-click="true"]'))){if(N&&A){hn(y);return}f==null||f(o)}}:void 0,className:`grid transition-colors ${Ne?"cursor-pointer":""} ${D?D(o):""}`,style:{gridTemplateColumns:wr,"--dt-row-bg":pe,"--dt-sticky-bg":pe,background:"var(--dt-row-bg)",borderBottom:`1px solid ${ge}`},onMouseEnter:xe=>{le||(xe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),xe.currentTarget.style.setProperty("--dt-sticky-bg",Ys))},onMouseLeave:xe=>{xe.currentTarget.style.setProperty("--dt-row-bg",pe),xe.currentTarget.style.setProperty("--dt-sticky-bg",pe)},children:[xr&&e.jsx("div",{role:"cell",className:`${v?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${ge}`,borderRight:`1px solid ${ge}`},"data-dt-disable-row-click":"true",children:A&&e.jsx("button",{type:"button","aria-label":Ee?"Contraer fila":"Desplegar fila","aria-expanded":Ee,onClick:xe=>{xe.stopPropagation(),hn(y)},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(p.HiChevronDown,{className:"h-4 w-4"}):e.jsx(p.HiChevronRight,{className:"h-4 w-4"})})}),Ve&&e.jsx("div",{role:"cell",className:`${v?"px-2 py-1.5":"px-3 py-2"} w-10`,style:ee?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${ge}`}:{borderBottom:`1px solid ${ge}`,borderRight:`1px solid ${ge}`},onClick:xe=>{xe.stopPropagation(),w(y)},children:e.jsx(Fr,{size:"sm",checked:le,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:xe=>xe.stopPropagation(),onChange:()=>w(y)})}),qe.map((xe,me)=>{const Ae=ee&&!Pt&&me===0,ye=tr(xe);return e.jsx("div",{role:"cell","data-dt-column-key":xe.key,"data-dt-disable-row-click":xe.disableRowClick||ye?"true":void 0,className:`${ye?"px-2 py-1.5 text-center":`${v?"px-2 py-1.5":"px-3 py-2"} ${vn(xe.align)}`} ${fl} ${xe.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ae?{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 ${ge}`,borderRight:`1px solid ${ge}`}:{borderBottom:`1px solid ${ge}`,borderRight:`1px solid ${ge}`}},children:e.jsx(pa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:xe.cell(o)})})},xe.key)})]}),Ee&&m&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:wr},children:e.jsx("div",{role:"cell",className:v?"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 ${ge}`},children:m(o)})})]},y)})})]})})}),kn()]})}function kr(r){return r?new Date(`${r}T12:00:00`):void 0}function ma(r){return r.toISOString().slice(0,10)}function Sl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:c,labels:d,formatters:b}=Rt.useDayPicker(),f=!!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":d.labelPrevious(a),onClick:()=>a&&s(a),disabled:!f,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:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(p.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":d.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(p.HiChevronRight,{size:16})})]})}function Cl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function El({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:c=1,showSummary:d=!0,startLabel:b="Inicio",endLabel:f="Regreso"}){const m={from:kr(r),to:kr(t)},k=kr(n),[S,h]=l.useState(kr(s||r));return l.useEffect(()=>{h(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:S,onMonthChange:h,onSelect:C=>{const N=C!=null&&C.from?ma(C.from):r,g=C!=null&&C.to?ma(C.to):"";a({startDate:N,endDate:g})},numberOfMonths:c,hideNavigation:!0,disabled:k?{before:k}:void 0,showOutsideDays:!1,components:{MonthCaption:Sl},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:C=>Cl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(C)),formatWeekdayName:C=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(C)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),d&&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:[f,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Ml="bonsaif-ui:hide-tooltips";function ha(){window.dispatchEvent(new CustomEvent(Ml))}function Ll(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function $l({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:c="",menuClassName:d="",onOpenChange:b}){const[f,m]=l.useState(!1),[k,S]=l.useState(!1),[h,C]=l.useState({}),N=l.useRef(null),g=l.useRef(null),w=l.useCallback(M=>{m(M),b==null||b(M)},[b]),H=l.useCallback(()=>{const M=N.current;if(!M)return;const I=M.getBoundingClientRect(),X=typeof n=="number"?n:I.width,J=typeof n=="number"?n:Math.max(I.width,180),F=a==="end"?Math.max(8,I.right-J):Math.min(I.left,window.innerWidth-J-8),K=window.innerHeight-I.bottom,Z=K<240&&I.top>K?void 0:I.bottom+6,E=Z===void 0?window.innerHeight-I.top+6:void 0;C({position:"fixed",zIndex:9999,left:F,top:Z,bottom:E,width:Ll(typeof n=="number"?X:n)})},[a,n]);l.useEffect(()=>S(!0),[]),l.useEffect(()=>{if(!f)return;H();const M=X=>{var F,K;const J=X.target;!((F=N.current)!=null&&F.contains(J))&&!((K=g.current)!=null&&K.contains(J))&&w(!1)},I=X=>{X.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",M),window.addEventListener("keydown",I),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{document.removeEventListener("mousedown",M),window.removeEventListener("keydown",I),window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[f,w,H]);const Y=M=>{s||(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),w(!f))},D=l.isValidElement(r)?l.cloneElement(r,{onClick:()=>{s||(ha(),w(!f))}}):r,G=f?e.jsx("div",{ref:g,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${d}`,style:h,children:t.map(M=>e.jsxs("div",{children:[M.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:M.disabled,onClick:()=>{var I;M.disabled||(ha(),(I=M.onSelect)==null||I.call(M),w(!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:M.danger?"var(--danger)":"var(--text-main)"},children:[M.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:M.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:M.label}),M.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:M.description})]})]})]},M.id))}):null;return e.jsxs("span",{ref:N,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":f,onKeyDown:Y,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${c}`,children:[D,k&&G?je.createPortal(G,document.body):null]})}const Tl=180,va="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Hl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:c="Guardar",onConfirm:d,loading:b=!1,confirmDisabled:f=!1,headerActions:m,bodyClassName:k="flex-1 overflow-y-auto px-6 py-5",width:S=440,hasUnsavedChanges:h=!1,unsavedChangesTitle:C="Descartar cambios",unsavedChangesDescription:N="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:g="Descartar",unsavedChangesCancelLabel:w="Seguir editando",onDiscardChanges:H,children:Y}){const[D,G]=l.useState(!1),[M,I]=l.useState(!1),[X,J]=l.useState(!1),F=l.useCallback(()=>{I(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>J(!0))})},[]),K=l.useCallback(()=>{J(!1),window.setTimeout(()=>I(!1),Tl)},[]),Z=l.useCallback(()=>{if(h){F();return}t()},[h,t,F]),E=l.useCallback(()=>{J(!1),I(!1),H==null||H(),t()},[t,H]);return l.useEffect(()=>{G(!0)},[]),l.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(J(!1),I(!1)),()=>{document.body.style.overflow=""}),[r]),l.useEffect(()=>{if(!r)return;const B=_=>{if(_.key==="Escape"){if(M){K();return}Z()}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[K,M,r,Z]),D?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 ${va}`,onClick:Z}),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, ${S}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:Z,title:"Cerrar",children:e.jsx(p.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||d)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m,d&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{variant:"secondary",size:"sm",onClick:Z,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Te,{variant:"primary",size:"sm",icon:e.jsx(En.FiSave,{className:"w-4 h-4"}),onClick:d,loading:b,disabled:f,title:c})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:k,children:Y})]}),M&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":C,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${va} transition-opacity duration-200 ease-out ${X?"opacity-100":"opacity-0"}`,onClick:K}),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 ${X?"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:K,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":w,children:e.jsx(p.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(p.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:C}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:N}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Te,{variant:"secondary",onClick:K,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:w}),e.jsx(Te,{variant:"secondary",onClick:E,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:g})]})]})]})]}),document.body):null}const Al=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Dl=/^\+?[0-9\s().-]+$/,Bl=7,Ol=15;function _e(r){return r==null||String(r).trim()===""}function xa(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Ct(r){return _e(r)?!1:Al.test(String(r))}function Et(r){if(_e(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return Dl.test(t)&&a.length>=Bl&&a.length<=Ol}function Il(r="Este campo es requerido."){return t=>_e(t)?r:void 0}function Fl(r="Ingresa un correo valido."){return t=>_e(t)||Ct(t)?void 0:r}function Pl(r="Ingresa un telefono valido."){return t=>_e(t)||Et(t)?void 0:r}function zl(r,t){return a=>_e(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function jl(r,t){return a=>_e(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function _l(r,t){return a=>{if(_e(a))return;const n=xa(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Wl(r,t){return a=>{if(_e(a))return;const n=xa(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function ql(r,t="El formato no es valido."){return a=>_e(a)||r.test(String(a))?void 0:t}function Ul(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 d of c){const b=d(r[n],r);if(b){a[n]=b;break}}}return{valid:Object.keys(a).length===0,errors:a}}var ga={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ya=l.createContext&&l.createContext(ga),Vl=["attr","size","title"];function Kl(r,t){if(r==null)return{};var a,n,s=Gl(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 Gl(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 wa(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?wa(Object(a),!0).forEach(function(n){Yl(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):wa(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function Yl(r,t,a){return(t=Xl(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function Xl(r){var t=Zl(r,"string");return typeof t=="symbol"?t:t+""}function Zl(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 Na(r){return r&&r.map((t,a)=>l.createElement(t.tag,Kr({key:a},t.attr),Na(t.child)))}function Mt(r){return t=>l.createElement(Jl,Vr({attr:Kr({},r.attr)},t),Na(r.child))}function Jl(r){var t=a=>{var{attr:n,size:s,title:c}=r,d=Kl(r,Vl),b=s||a.size||"1em",f;return a.className&&(f=a.className),r.className&&(f=(f?f+" ":"")+r.className),l.createElement("svg",Vr({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,d,{className:f,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 ya!==void 0?l.createElement(ya.Consumer,null,a=>t(a)):t(ga)}function ka(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 Ql(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 Rl(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 Lt({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:c="Error de validacion",labelAction:d,floatingLabel:b=!1,showPasswordToggle:f=!0,nativeValidation:m=!1,className:k="",required:S,...h}){const[C,N]=l.useState(()=>!!h.autoFocus),[g,w]=l.useState(!1),H=h.type==="password"&&f,Y=H&&g?"text":h.type,D=!!n,G=D&&s!=="tooltip",M=D&&s!=="inline",I=m?S:void 0,X=D?"border-[var(--danger)] focus:border-[var(--danger)]":"",J=M?H?"pr-20":"pr-10":H?"pr-10":"",F=h.value!==void 0?String(h.value).length>0:h.defaultValue!==void 0&&String(h.defaultValue).length>0,K=C||F,Z={top:K?7:12,color:C?"var(--primary)":"var(--text-muted)",fontSize:K?10:13,fontWeight:K?600:400,textTransform:K?"uppercase":"none"},E=ee=>{var P;N(!0),(P=h.onFocus)==null||P.call(h,ee)},B=ee=>{var P;N(!1),(P=h.onBlur)==null||P.call(h,ee)},_=H?e.jsxs("button",{type:"button","aria-label":g?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":g,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>w(ee=>!ee),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(Ql,{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 ${g?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(Rl,{className:"h-[18px] w-[18px]"})})]}):null,O=M?e.jsx(cr,{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)] ${H?"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(ka,{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,{...h,type:Y,required:I,placeholder:" ","aria-invalid":D||h["aria-invalid"],"data-has-value":F?"true":void 0,className:`h-11 w-full pt-5 ${J} ${X} ${k}`,onFocus:E,onBlur:B}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[r,S&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),d&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:K?7:12},children:d}),O,_]}),G?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}),S&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),d&&e.jsx("span",{className:"ml-auto normal-case",children:d})]}),H?e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...h,type:Y,required:I,"aria-invalid":D||h["aria-invalid"],className:`w-full ${J} ${X} ${k}`,onFocus:E,onBlur:B}),O,_]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Gr,{...h,required:I,"aria-invalid":D||h["aria-invalid"],className:`w-full ${J} ${X} ${k}`}),O]}),G?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 Sa(r){return r==null?"":String(r)}function eo({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:c,value:d,defaultValue:b,onChange:f,...m}){const[k,S]=l.useState(()=>Sa(b)),h=d!==void 0?Sa(d):k,C=a&&h.length>0&&!Ct(h)?n:void 0,N=g=>{d===void 0&&S(g.currentTarget.value),f==null||f(g)};return e.jsx(Lt,{...m,value:d,defaultValue:b,type:"text",inputMode:t,autoComplete:r,error:c??C,errorDisplay:s,onChange:N})}const ro={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function to({title:r="Sin resultados",description:t,icon:a=e.jsx(p.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:c="md",className:d=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${ro[c]} ${d}`,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 ao={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function no(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 Ca(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 lo(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function oo({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:c=[],onFilesChange:d,onRejectedFiles:b,multiple:f=!1,maxFiles:m,appendFiles:k=!1,showFileList:S=!0,clearable:h=!0,browseLabel:C="Buscar archivos",dropLabel:N="Suelta los archivos aqui",emptyLabel:g="Arrastra y suelta archivos",emptyDescription:w="o haz click para buscarlos en tu equipo",selectedLabel:H="Archivos seleccionados",size:Y="md",containerClassName:D="",dropzoneClassName:G="",fileListClassName:M="",className:I="",id:X,accept:J,disabled:F,required:K,...Z}){const E=l.useId(),B=X??E,_=l.useRef(null),[O,ee]=l.useState(!1),[P,v]=l.useState(c),j=s??P,V=!!a,ae=h&&j.length>0&&!F,te=(ne,ve)=>{s===void 0&&v(ne),d==null||d(ne,ve)},he=(ne,ve)=>{const oe=ne.filter(ce=>Ca(ce,J)),L=ne.filter(ce=>!Ca(ce,J)),W=k?[...j,...oe]:oe,ie=lo(W,f,m);L.length>0&&(b==null||b(L)),te(ie,ve)},$=()=>{var ne;F||(ne=_.current)==null||ne.click()},ue=ne=>{he(Array.from(ne.target.files??[]),ne),ne.target.value=""},T=ne=>{ne.preventDefault(),F||ee(!0)},se=ne=>{ne.currentTarget.contains(ne.relatedTarget)||ee(!1)},fe=ne=>{ne.preventDefault(),ee(!1),!F&&he(Array.from(ne.dataTransfer.files),ne)},U=ne=>{ne.key!=="Enter"&&ne.key!==" "||(ne.preventDefault(),$())},re=ne=>{te(j.filter((ve,oe)=>oe!==ne))},R=()=>{te([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${D}`,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}),K&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...Z,ref:_,id:B,type:"file",accept:J,multiple:f,disabled:F,required:K&&j.length===0,"aria-invalid":V||Z["aria-invalid"],className:"sr-only",onChange:ue}),e.jsxs("div",{role:"button",tabIndex:F?-1:0,"aria-controls":B,"aria-disabled":F||void 0,"aria-invalid":V||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)] ${ao[Y]} ${O?"border-[var(--primary)] bg-[var(--bg-input)]":V?"border-[var(--danger)]":"border-[var(--border)]"} ${F?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${G} ${I}`,onClick:$,onDragOver:T,onDragLeave:se,onDrop:fe,onKeyDown:U,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(p.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:O?N:g}),w&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:w})]}),C&&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:C})]}),S&&j.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${M}`,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:H}),ae&&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:R,children:e.jsx(p.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:j.map((ne,ve)=>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(p.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:ne.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:no(ne.size)})]}),!F&&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 ${ne.name}`,onClick:()=>re(ve),children:e.jsx(p.HiXMark,{className:"h-4 w-4"})})]},`${ne.name}-${ne.lastModified}-${ve}`))})]}),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 so=[{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 io({fields:r,title:t="Layout",fieldTypes:a=so,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:c="Nuevo campo",addFieldLabel:d="Anadir",loading:b=!1,onSave:f,onChange:m}){const[k,S]=l.useState(()=>r.map(D=>({key:!1,type:"",...D}))),[h,C]=l.useState(""),[N,g]=l.useState(""),w=l.useCallback((D,G)=>{S(M=>{const I=M.map((X,J)=>J===D?{...X,...G}:X);return m==null||m(I),I})},[m]),H=l.useCallback(()=>{f==null||f(k)},[k,f]),Y=l.useCallback(()=>{var I;const D=h.trim();if(!D){g("Ingresa un nombre de campo.");return}if(k.some(X=>X.name.toLowerCase()===D.toLowerCase())){g("Ese campo ya existe en el arreglo.");return}const M={name:D,key:!1,type:((I=a[0])==null?void 0:I.value)??""};S(X=>{const J=[...X,M];return m==null||m(J),J}),C(""),g("")},[a,k,h,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:[k.map((D,G)=>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:D.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Fr,{size:"sm",checked:D.key??!1,onChange:M=>w(G,{key:M.target.checked}),"aria-label":`${D.name} es clave`})}),e.jsx(dr,{value:D.type??"",onChange:M=>w(G,{type:M}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${D.name}`})]},D.name)),k.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:h,onChange:D=>{C(D.currentTarget.value),N&&g("")},onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),Y())},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:Y,height:36,padding:"0 12px",children:d})]}),N&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:N})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Te,{variant:"primary",onClick:H,disabled:b,loading:b,children:n})})]})})]})}function Ea({label:r,children:t,helperText:a,error:n,labelAction:s,required:c=!1,className:d="",contentClassName:b=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${d}`,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 Ma(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function co(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function uo({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:c="",style:d,height:b=40,padding:f="6px 10px",searchable:m=!0,minOptionsForSearch:k=6,maxVisibleValues:S=2,truncateSelectedValues:h=!0,emptyText:C="Sin resultados",clearLabel:N="Limpiar seleccion"}){const[g,w]=l.useState(!1),[H,Y]=l.useState(""),[D,G]=l.useState(0),[M,I]=l.useState(!1),[X,J]=l.useState({}),F=l.useRef(null),K=l.useRef(null),Z=l.useRef(null),E=l.useRef(null),B=m&&a.length>=k,_=l.useMemo(()=>new Set(r),[r]),O=l.useMemo(()=>a.filter(T=>_.has(T.value)),[a,_]),ee=S==="all"?O.length:S,P=O.slice(0,ee),v=Math.max(0,O.length-P.length),j=B&&H.trim()?a.filter(T=>{var se;return T.label.toLowerCase().includes(H.toLowerCase())||((se=T.sublabel)==null?void 0:se.toLowerCase().includes(H.toLowerCase()))}):a,V=l.useCallback(()=>{const T=F.current;if(!T)return;const se=T.getBoundingClientRect(),fe=B?304:244,U=window.innerHeight-se.bottom,re=U<fe&&se.top>U;J({position:"fixed",left:se.left,top:re?void 0:se.bottom+4,bottom:re?window.innerHeight-se.top+4:void 0,width:se.width,zIndex:9999})},[B]),ae=l.useCallback(T=>{co(r,T)||t(T)},[t,r]),te=l.useCallback(T=>{const se=a.find(U=>U.value===T);if(se!=null&&se.disabled)return;const fe=_.has(T)?r.filter(U=>U!==T):[...r,T];ae(fe)},[ae,a,r,_]),he=l.useCallback(()=>ae([]),[ae]);l.useEffect(()=>I(!0),[]),l.useEffect(()=>{if(!g)return;function T(se){var U,re;const fe=se.target;!((U=F.current)!=null&&U.contains(fe))&&!((re=K.current)!=null&&re.contains(fe))&&(w(!1),Y(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[g]),l.useEffect(()=>{g&&(G(0),V(),B&&setTimeout(()=>{var T;return(T=Z.current)==null?void 0:T.focus()},0))},[g,B,V]),l.useEffect(()=>{if(g)return window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[g,V]),l.useEffect(()=>{if(D<0||!E.current)return;const T=E.current.children[D];T==null||T.scrollIntoView({block:"nearest"})},[D]);function $(T){if(!g){(T.key==="Enter"||T.key===" "||T.key==="ArrowDown")&&(T.preventDefault(),w(!0));return}T.key==="Escape"&&(T.preventDefault(),w(!1),Y("")),T.key==="ArrowDown"&&(T.preventDefault(),G(se=>Math.min(se+1,j.length-1))),T.key==="ArrowUp"&&(T.preventDefault(),G(se=>Math.max(se-1,0))),T.key==="Enter"&&j[D]&&(T.preventDefault(),te(j[D].value)),T.key==="Backspace"&&!H&&r.length&&(T.preventDefault(),ae(r.slice(0,-1)))}const ue=e.jsxs("div",{ref:K,className:"overflow-hidden rounded-xl shadow-xl",style:{...X,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[B&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(p.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:Z,value:H,onChange:T=>{Y(T.target.value),G(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),H&&e.jsx("button",{type:"button",onMouseDown:T=>{T.preventDefault(),Y("")},children:e.jsx(p.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),O.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:[O.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:T=>{T.preventDefault(),he()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:N})]}),e.jsxs("ul",{ref:E,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:B?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[j.map((T,se)=>{const fe=se===D,U=_.has(T.value);return e.jsxs("li",{role:"option","aria-selected":U,onMouseDown:re=>{re.preventDefault(),te(T.value)},onMouseEnter:()=>!T.disabled&&G(se),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:fe?"var(--bg-hover)":U?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:T.disabled?"var(--text-muted)":"var(--text-main)",cursor:T.disabled?"not-allowed":"pointer",opacity:T.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:U?"var(--primary)":"var(--border)",background:U?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:U&&e.jsx(p.HiCheck,{className:"h-3 w-3"})}),T.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:T.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:T.label}),T.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:T.sublabel})]}),T.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:T.badge})]},T.value)}),j.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:C})]})]});return e.jsxs("div",{ref:F,className:`relative ${c||"w-full"}`,style:d,onKeyDown:$,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&w(T=>!T),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Ma(b),padding:Ma(f),background:"var(--bg-input)",color:O.length?"var(--text-main)":"var(--text-muted)",border:g?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":g,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:P.length?e.jsxs(e.Fragment,{children:[P.map(T=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${h?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[T.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:T.color}}),e.jsx("span",{className:h?"truncate":"break-words",children:T.label})]},T.value)),v>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:["+",v]})]}):e.jsx("span",{className:"truncate",children:n})}),O.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":N,onMouseDown:T=>{T.preventDefault(),T.stopPropagation(),he()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(p.HiXMark,{className:"h-3 w-3"})}):e.jsx(p.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&M&&je.createPortal(ue,document.body)]})}function bo({inputMode:r="decimal",...t}){return e.jsx(Lt,{...t,type:"number",inputMode:r})}function fo(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 d=s;d<=c;d+=1)n.push(d);return c<t-1&&n.push("..."),t>1&&n.push(t),n}function po({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:c=""}){const d=Math.max(1,t),b=Math.min(Math.max(1,r),d),f=fo(b,d,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(p.HiChevronLeft,{className:"h-4 w-4"})}),f.map((m,k)=>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-${k}`):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>=d,onClick:()=>a(b+1),children:e.jsx(p.HiChevronRight,{className:"h-4 w-4"})})]})}const La=[{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 $a(r){return r==null?"":String(r)}function Yr(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function mo(r){return typeof r=="number"?`${r}px`:r}function ho({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:c,value:d,defaultValue:b,onChange:f,countryCode:m,defaultCountryCode:k="+1",onCountryCodeChange:S,allowedCountryCodes:h,countryCodeOptions:C,countryCodePlaceholder:N="Codigo",countryCodeClassName:g="",countryCodeWidth:w=84,onPhoneValueChange:H,label:Y,containerClassName:D="",helperText:G,labelAction:M,className:I="",required:X,disabled:J,floatingLabel:F,showPasswordToggle:K,nativeValidation:Z,errorTooltipLabel:E="Error de validacion",...B}){var ne;const[_,O]=l.useState(()=>$a(b)),[ee,P]=l.useState(()=>Yr(k)),v=l.useMemo(()=>{const ve=C??La,oe=h==null?void 0:h.map(Yr);return oe!=null&&oe.length?ve.filter(L=>oe.includes(L.value)):ve},[h,C]),j=((ne=v[0])==null?void 0:ne.value)??"+1",V=v.some(ve=>ve.value===Yr(m??ee))?Yr(m??ee):j,ae=d!==void 0?$a(d):_,te=`${V} ${ae}`.trim(),he=a&&ae.length>0&&!Et(te)?n:void 0,$=c??he,ue=!!$,T=ue&&s!=="tooltip",se=ue&&s!=="inline",fe=ue?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",U=ve=>{const oe=ve.currentTarget.value;d===void 0&&O(oe),H==null||H(oe,{countryCode:V,nationalNumber:oe,fullNumber:`${V} ${oe}`.trim()}),f==null||f(ve)},re=ve=>{m===void 0&&P(ve),S==null||S(ve),H==null||H(ae,{countryCode:ve,nationalNumber:ae,fullNumber:`${ve} ${ae}`.trim()})},R=se?e.jsx(cr,{as:"span",content:$,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":E,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(ka,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${D}`,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:Y}),X&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),M&&e.jsx("span",{className:"ml-auto normal-case",children:M})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${fe}`,children:[e.jsx(dr,{value:V,onChange:re,options:v,placeholder:N,disabled:J,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${g}`,style:{width:mo(w)},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",{...B,value:d,defaultValue:b,type:"tel",inputMode:t,autoComplete:r,disabled:J,required:void 0,"aria-label":B["aria-label"]??(typeof Y=="string"?Y:void 0),"aria-invalid":ue||B["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 ${se?"pr-10":""} ${I}`,onChange:U}),R]})]}),T?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:$}):G?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:G}):null]})}function vo({value:r,onChange:t,options:a,name:n,label:s,orientation:c="vertical",disabled:d=!1,className:b="",optionClassName:f=""}){return e.jsxs("fieldset",{className:`min-w-0 ${b}`,disabled:d,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 k=m.value===r,S=d||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 ${S?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${f}`,style:{borderColor:k?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:k?"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:k,disabled:S,onChange:()=>t(m.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${k?"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 Ta=()=>'<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,"'"),Ha=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),xo=r=>r.replace(/[<>]/g,"").toLowerCase(),go=r=>new RegExp("\\p{L}","u").test(r),$t=(r,t)=>{const a=r.trim();return!a||!go(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===Ha(a)},Aa=r=>{const t=n=>{var s,c;if(!n.closest(".rich-img-wrap")){const d=document.createElement("span");d.className="rich-img-wrap",d.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(d,n),d.appendChild(n),d.insertAdjacentHTML("beforeend",Ta())}(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 yo({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px"}){const s=l.useRef(null),c=l.useRef(null),d=l.useRef(null),b=l.useRef(!1),f=l.useRef(r??""),m=l.useRef(t),[k,S]=l.useState(()=>!r||r.trim()===""),[h,C]=l.useState(new Set),[N,g]=l.useState(null),[w,H]=l.useState(""),[Y,D]=l.useState(""),[G,M]=l.useState(""),[I,X]=l.useState(""),[J,F]=l.useState(!1),K=l.useCallback(()=>b.current?c.current:s.current,[]);l.useEffect(()=>{m.current=t},[t]);const Z=l.useCallback(()=>{const L=window.getSelection(),W=K();if(!L||!W||L.rangeCount===0||L.isCollapsed)return"";const ie=L.getRangeAt(0);return!W.contains(ie.startContainer)||!W.contains(ie.endContainer)?"":L.toString()},[K]);l.useEffect(()=>{const L=r??"";f.current=L;const W=[s.current,c.current].filter(ce=>!!ce);W.forEach(ce=>{ce.innerHTML!==L&&(ce.innerHTML=L)}),S(!L||L.trim()==="");const ie=W.map(ce=>Aa(ce));return()=>ie.forEach(ce=>ce())},[r]),l.useEffect(()=>{var ce,ke;b.current=J;let L,W=0,ie;if(J){const be=s.current;be&&(f.current=be.innerHTML);const Se=()=>{var de;const we=c.current;if(!we){W=requestAnimationFrame(Se);return}we.innerHTML!==f.current&&(we.innerHTML=f.current),L=Aa(we),S(((de=we.textContent)==null?void 0:de.trim())===""),ie=setTimeout(()=>we.focus(),60)};W=requestAnimationFrame(Se)}else{const be=c.current,Se=s.current,we=(be==null?void 0:be.innerHTML)??f.current,de=f.current;f.current=we,Se&&Se.innerHTML!==we&&(Se.innerHTML=we),we!==de&&m.current(we),S(((ke=(ce=be??Se)==null?void 0:ce.textContent)==null?void 0:ke.trim())==="")}return()=>{W&&cancelAnimationFrame(W),ie&&clearTimeout(ie),L==null||L()}},[J]);const E=l.useCallback(()=>{const L=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],W=new Set;L.forEach(ce=>{try{document.queryCommandState(ce)&&W.add(ce)}catch{return}});try{const ce=xo(document.queryCommandValue("formatBlock"));ce&&W.add(`formatBlock:${ce}`)}catch{return}const ie=Z();$t(ie,"uppercase")&&W.add("__upper"),$t(ie,"lowercase")&&W.add("__lower"),$t(ie,"capitalize")&&W.add("__cap"),C(W)},[Z]),B=()=>{var W;const L=K();L&&(f.current=L.innerHTML,m.current(f.current),S(((W=L.textContent)==null?void 0:W.trim())===""))},_=L=>{if(!L){const W=s.current;W&&(f.current=W.innerHTML)}F(!L)},O=(L,W)=>{var ie;(ie=K())==null||ie.focus(),document.execCommand(L,!1,W),B(),E()},ee=L=>{O("formatBlock",L)},P=()=>{var L;(L=K())==null||L.focus(),document.execCommand("insertHTML",!1,"<hr><p><br></p>"),B(),E()},v=()=>{const L=window.getSelection();L&&L.rangeCount>0&&(d.current=L.getRangeAt(0).cloneRange())},j=()=>{const L=window.getSelection();L&&d.current&&(L.removeAllRanges(),L.addRange(d.current))},V=L=>{if(v(),L==="link"){const W=window.getSelection();D(W&&!W.isCollapsed?W.toString():""),H("")}L==="image"&&(M(""),X("")),g(L)},ae=()=>{var ce;if(!w.trim())return;j(),(ce=K())==null||ce.focus();const L=window.getSelection(),ie=(L&&!L.isCollapsed?L.toString():"")||Y.trim()||w.trim();document.execCommand("insertHTML",!1,`<a href="${Xr(w.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Xr(ie)}</a>`),B(),g(null)},te=(L,W="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Xr(L)}" alt="${Xr(W)}" class="rich-img" />${Ta()}</span>`,he=()=>{var L;G.trim()&&(j(),(L=K())==null||L.focus(),document.execCommand("insertHTML",!1,te(G.trim(),I.trim())),B(),g(null))},$=(L,W=1200,ie=1200,ce=.72)=>new Promise((ke,be)=>{const Se=new FileReader;Se.onerror=be,Se.onload=we=>{var Ge;const de=(Ge=we.target)==null?void 0:Ge.result,Be=new Image;Be.onerror=be,Be.onload=()=>{let{width:ze,height:Q}=Be;if(ze>W||Q>ie){const Ie=Math.min(W/ze,ie/Q);ze=Math.round(ze*Ie),Q=Math.round(Q*Ie)}const Me=document.createElement("canvas");Me.width=ze,Me.height=Q;const Le=Me.getContext("2d");if(!Le){ke(de);return}Le.drawImage(Be,0,0,ze,Q),ke(Me.toDataURL("image/jpeg",ce))},Be.src=de},Se.readAsDataURL(L)}),ue=L=>{const ie=Array.from(L.clipboardData.items).find(ke=>ke.type.startsWith("image/"));if(!ie)return;L.preventDefault();const ce=ie.getAsFile();ce&&$(ce).then(ke=>{var be;(be=K())==null||be.focus(),document.execCommand("insertHTML",!1,te(ke,"imagen")),B()})},T=L=>{const W=window.getSelection(),ie=K();if(!W||!ie||W.rangeCount===0||W.isCollapsed)return;const ce=W.getRangeAt(0);if(!ie.contains(ce.startContainer)||!ie.contains(ce.endContainer))return;const ke=ce.toString();if(!ke)return;let be=ke;L==="uppercase"?be=ke.toLocaleUpperCase():L==="lowercase"?be=ke.toLocaleLowerCase():be=Ha(ke),ce.deleteContents();const Se=document.createTextNode(be);ce.insertNode(Se);const we=document.createRange();we.setStart(Se,0),we.setEnd(Se,be.length),W.removeAllRanges(),W.addRange(we),d.current=we.cloneRange(),B(),E()},se=()=>{v(),E()},fe=()=>{B(),E()},U=L=>{if(L.key==="Escape"){if(N){g(null);return}if(b.current){F(!1);return}}N||(L.ctrlKey||L.metaKey)&&(L.key==="b"&&(L.preventDefault(),O("bold")),L.key==="i"&&(L.preventDefault(),O("italic")),L.key==="u"&&(L.preventDefault(),O("underline")),L.key==="k"&&(L.preventDefault(),V("link")))},re=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),R=(L,W,ie,ce,ke)=>{const be=ke??(h.has(ie)||ie==="__link"&&N==="link"||ie==="__img"&&N==="image");return e.jsx("button",{type:"button",title:W,onMouseDown:Se=>{Se.preventDefault(),ce?ce():O(ie)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:be?"var(--primary)":"var(--text-secondary)",background:be?"rgba(59,130,246,0.12)":"transparent"},children:L},ie)},ne=L=>{const W=L.target;if(W.closest("[data-action='delete-img']")){L.preventDefault();const ie=W.closest(".rich-img-wrap");ie&&(ie.remove(),B())}},ve=L=>e.jsxs(e.Fragment,{children:[N==="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:L},children:[e.jsx("input",{autoFocus:!0,type:"url",value:w,onChange:W=>H(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ae()),W.key==="Escape"&&g(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:Y,onChange:W=>D(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ae()),W.key==="Escape"&&g(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: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:()=>g(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),N==="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:L},children:[e.jsx("input",{autoFocus:!0,type:"url",value:G,onChange:W=>M(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),he()),W.key==="Escape"&&g(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:I,onChange:W=>X(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),he()),W.key==="Escape"&&g(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:he,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:()=>g(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),oe=(L,W)=>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:W},children:[R(e.jsx(p.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),R(e.jsx(p.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),re(),R(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ee("p"),h.has("formatBlock:p")||h.has("formatBlock:div")),R(e.jsx(p.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ee("h2"),h.has("formatBlock:h2")),R(e.jsx(p.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ee("h3"),h.has("formatBlock:h3")),R(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ee("blockquote"),h.has("formatBlock:blockquote")),re(),R(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),R(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),R(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),R(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),re(),R(e.jsx(p.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),R(e.jsx(p.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),R(e.jsx(p.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),R(e.jsx(p.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),re(),R(e.jsx(p.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),R(e.jsx(p.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),R(e.jsx(p.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),R(e.jsx(p.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),re(),R(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>T("uppercase")),R(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>T("lowercase")),R(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>T("capitalize")),re(),R(e.jsx(p.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>V("link")),R(e.jsx(p.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),R(e.jsx(p.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>V("image")),R(e.jsx(p.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",P),re(),R(e.jsx(p.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),R(e.jsx(p.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ee("p")),re(),e.jsx("button",{type:"button",title:L?"Salir del modo de enfoque (Esc)":"Modo de enfoque",onMouseDown:ie=>{ie.preventDefault(),_(L)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:L?e.jsx(p.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(p.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:fe,onKeyDown:U,onKeyUp:se,onSelect:se,onMouseUp:se,onPaste:ue,onMouseDown:ne,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${k?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),ve("var(--bg-input)"),oe(!1,"var(--bg-input)")]}),e.jsxs(St,{open:J,onClose:()=>F(!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:fe,onKeyDown:U,onKeyUp:se,onSelect:se,onMouseUp:se,onPaste:ue,onMouseDown:ne,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${k?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),ve("var(--bg-input)"),oe(!0,"var(--bg-input)")]})]})}function wo({title:r,subtitle:t,icon:a,actions:n,children:s,footer:c,className:d="",bodyClassName:b="p-4"}){const f=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${d}`,children:[f&&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 No={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)"}},ko={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 So({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:c=""}){const d=No[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 ${ko[a]} ${c}`,style:{color:d.text,background:d.bg,borderColor:d.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:d.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Da={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)"}},Co={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"},Eo={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Mo={xs:148,sm:164,md:184},Lo={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 $o({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:c=!1,stopPropagation:d=!1,ariaLabel:b="Cambiar estado",title:f="Cambiar estado",className:m,selectClassName:k,menuClassName:S,optionClassName:h,spinnerClassName:C}){const[N,g]=l.useState(!1),[w,H]=l.useState(!1),[Y,D]=l.useState(-1),[G,M]=l.useState({}),I=l.useRef(null),X=l.useRef(null),J=l.useRef(null),F=t.find(v=>v.value===r)??t[0],K={...F!=null&&F.tone?Da[F.tone]:void 0,...F==null?void 0:F.style},Z=s||c||t.length===0,E=v=>{d&&v.stopPropagation()},B=l.useCallback(()=>{g(!1),D(-1)},[]),_=l.useCallback(()=>{const v=I.current;if(!v)return;const j=v.getBoundingClientRect(),V=Math.max(j.width,Mo[n]),ae=Math.min(Math.max(t.length,1)*38+12,260),te=window.innerHeight-j.bottom,he=te<ae&&j.top>te,$=Math.min(Math.max(8,j.left+j.width/2-V/2),window.innerWidth-V-8);M({position:"fixed",left:$,top:he?void 0:j.bottom+6,bottom:he?window.innerHeight-j.top+6:void 0,width:V,zIndex:9999})},[t.length,n]),O=l.useCallback(v=>{v.disabled||(a(v.value),B())},[B,a]);l.useEffect(()=>H(!0),[]),l.useEffect(()=>{if(!N)return;_();const v=t.findIndex(j=>j.value===r);D(v>=0?v:0)},[N,t,_,r]),l.useEffect(()=>{if(!N)return;function v(j){var ae,te;const V=j.target;!((ae=I.current)!=null&&ae.contains(V))&&!((te=X.current)!=null&&te.contains(V))&&B()}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[B,N]),l.useEffect(()=>{if(N)return window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[N,_]),l.useEffect(()=>{if(Y<0||!J.current)return;const v=J.current.children[Y];v==null||v.scrollIntoView({block:"nearest"})},[Y]);function ee(v){if(!Z){if(!N){["Enter"," ","ArrowDown","ArrowUp"].includes(v.key)&&(v.preventDefault(),g(!0));return}if(v.key==="Escape"){v.preventDefault(),B();return}if(v.key==="ArrowDown"){v.preventDefault(),D(j=>Math.min(j+1,t.length-1));return}if(v.key==="ArrowUp"){v.preventDefault(),D(j=>Math.max(j-1,0));return}if(v.key==="Enter"||v.key===" "){v.preventDefault();const j=t[Y];j&&O(j)}}}const P=e.jsx("div",{ref:X,role:"listbox","aria-label":b,className:Je("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",S),style:{...G,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:E,onMouseDown:E,onPointerDown:E,children:e.jsx("div",{ref:J,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((v,j)=>{const V=v.value===r,ae=j===Y,te={...v.tone?Da[v.tone]:void 0,...v.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":V,disabled:v.disabled,onMouseEnter:()=>!v.disabled&&D(j),onMouseDown:he=>{he.preventDefault(),O(v)},className:Je("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Lo[n],V?v.className:void 0,h),style:{...V?te:void 0,background:V?te.background??"color-mix(in srgb, var(--primary) 12%, transparent)":ae?"var(--bg-hover)":"transparent",color:V?te.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:V?e.jsx(p.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.label})]},v.value)})})});return e.jsxs("span",{ref:I,className:Je("relative inline-flex shrink-0 items-center",m),onKeyDown:ee,onClick:E,onPointerDown:E,children:[e.jsx("button",{type:"button",disabled:Z,"aria-label":b,"aria-haspopup":"listbox","aria-expanded":N,title:f,onClick:()=>!Z&&g(v=>!v),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",Co[n],F==null?void 0:F.className,k),style:K,children:e.jsx("span",{className:"min-w-0 truncate",children:(F==null?void 0:F.label)??r})}),e.jsx(p.HiChevronDown,{"aria-hidden":"true",className:Je("pointer-events-none absolute opacity-70 transition-transform",Eo[n],N?"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)}),N&&w&&je.createPortal(P,document.body)]})}function To({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:c="underline",className:d="",listClassName:b="",panelClassName:f=""}){const m=r.find(N=>!N.disabled)??r[0],k=t??a??(m==null?void 0:m.id),S=r.find(N=>N.id===k)??m,h=N=>{N.disabled||n==null||n(N.id)},C=N=>{const g=r.filter(H=>!H.disabled);if(!g.length||!S)return;const w=g.findIndex(H=>H.id===S.id);(N.key==="ArrowRight"||N.key==="ArrowDown")&&(N.preventDefault(),h(g[(w+1)%g.length])),(N.key==="ArrowLeft"||N.key==="ArrowUp")&&(N.preventDefault(),h(g[(w-1+g.length)%g.length])),N.key==="Home"&&(N.preventDefault(),h(g[0])),N.key==="End"&&(N.preventDefault(),h(g[g.length-1]))};return e.jsxs("div",{className:d,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:C,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(N=>{const g=N.id===(S==null?void 0:S.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":g,"aria-controls":`${N.id}-panel`,id:`${N.id}-tab`,disabled:N.disabled,tabIndex:g?0:-1,onClick:()=>h(N),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:g?"var(--primary)":"var(--text-muted)",borderColor:g?"var(--primary)":"transparent",background:c==="pills"&&g?"var(--bg-card)":"transparent"},children:[N.icon&&e.jsx("span",{className:"shrink-0",children:N.icon}),e.jsx("span",{children:N.label}),N.badge&&e.jsx("span",{className:"shrink-0",children:N.badge})]},N.id)})}),(S==null?void 0:S.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${S.id}-panel`,"aria-labelledby":`${S.id}-tab`,className:`pt-4 ${f}`,children:S.content})]})}function Qe(...r){return r.filter(Boolean).join(" ")}function Ho({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:c,onCompletedStepIdsChange:d,onBlockedStep:b,allowBackNavigation:f=!0,showFooter:m=!0,previousLabel:k="Anterior",nextLabel:S="Siguiente",blockedNextLabel:h="Completa este paso",className:C="",headerClassName:N="",contentClassName:g="",footerClassName:w=""}){var fe;const H=((fe=r[0])==null?void 0:fe.id)??"",[Y,D]=l.useState(a??H),[G,M]=l.useState(s),I=t??Y,X=n??G,J=l.useMemo(()=>new Set(X),[X]),F=Math.max(0,r.findIndex(U=>U.id===I)),K=r[F]??r[0],Z=r.length<=1?100:F/(r.length-1)*100,E=U=>{n||M(U),d==null||d(U)},B=U=>{const re=r.find(R=>R.id===U);re&&(t||D(U),c==null||c(U,re))},_=U=>J.has(U),O=U=>r.slice(0,U).find(re=>!re.optional&&!J.has(re.id)),ee=U=>{const re=r[U];return!re||re.disabled?!1:U===F||f&&U<F?!0:!O(U)},P=U=>{const re=r.findIndex(R=>R.id===U);return re>=0&&ee(re)},v=U=>{const re=r.findIndex(R=>R.id===U);if(re<0)return!1;if(!ee(re)){const R=O(re);return R&&(b==null||b(r[re],R)),!1}return B(U),!0},j=(U=K==null?void 0:K.id)=>{!U||J.has(U)||E([...X,U])},V=(U=K==null?void 0:K.id)=>{if(!U)return;const re=r.findIndex(ne=>ne.id===U),R=X.filter(ne=>{const ve=r.findIndex(oe=>oe.id===ne);return ve>=0&&ve<re});E(R),re>=0&&F>re&&B(U)},ae=()=>F<=0?!1:v(r[F-1].id),te=()=>{const U=r[F+1];return U?v(U.id):!1},he={activeStep:K,activeIndex:F,completedStepIds:X,isCompleted:_,isUnlocked:P,completeStep:j,uncompleteStep:V,goToStep:v,goNext:te,goPrevious:ae};if(!K)return null;const $=r[F+1],ue=F>0,T=$?P($.id):!1,se=typeof K.content=="function"?K.content(he):K.content;return e.jsxs("section",{className:Qe("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",C),children:[e.jsxs("div",{className:Qe("border-b border-[var(--border)] bg-[var(--bg-input)]",N),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:`${Z}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((U,re)=>{const R=U.id===K.id,ne=_(U.id),ve=ee(re),oe=O(re);return e.jsxs("button",{type:"button",disabled:!ve,"aria-current":R?"step":void 0,"aria-disabled":!ve,title:!ve&&oe?`Completa ${oe.title}`:U.title,onClick:()=>v(U.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",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",ne&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!ne&&ve&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ve&&"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",R&&"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",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",ne&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!ne&&!R&&ve&&"border-[var(--border)] text-[var(--text-muted)]",!ve&&"border-[var(--border)] text-[var(--text-muted)]"),children:ne?e.jsx(p.HiCheck,{className:"h-4 w-4"}):ve?re+1:e.jsx(p.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",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[re+1,". ",U.title]}),U.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:U.description})]}),U.badge&&e.jsx("span",{className:"shrink-0",children:U.badge})]})]},U.id)})})]}),e.jsx("div",{className:Qe("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",g),children:se},K.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",w),children:[e.jsx(Te,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(p.HiChevronLeft,{}),disabled:!ue,onClick:ae,children:k}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",F+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[X.length," completados"]})]}),e.jsx(Te,{height:38,padding:"0 14px",icon:e.jsx(p.HiChevronRight,{}),disabled:!$||!T,onClick:te,children:$&&!T?h:S})]})]})}const Ao={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"},Do={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Bo(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function Oo(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Ba=l.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:c=!1,minRows:d,maxRows:b,showCount:f=!1,maxCount:m,status:k="default",icon:S,action:h,style:C,value:N,defaultValue:g,maxLength:w,onInput:H,...Y},D){const G=l.useRef(null),M=Oo(N,g),I=m??w,X=!!(S||h||f),J=k==="error"?"var(--danger)":k==="success"?"#16a34a":"var(--border)",F={...C??{},...d?{minHeight:`${d*24+18}px`}:null,...b?{maxHeight:`${b*24+18}px`}:null},K=()=>{const E=G.current;!E||!c||(E.style.height="auto",E.style.height=`${E.scrollHeight}px`)};l.useEffect(K,[c,N]);const Z=e.jsx("textarea",{...Y,ref:E=>{G.current=E,Bo(D,E)},value:N,defaultValue:g,maxLength:w,"aria-invalid":k==="error"||Y["aria-invalid"],onInput:E=>{K(),H==null||H(E)},style:{...F,borderColor:J},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 ${Ao[n]} ${Do[c?"none":s]} ${S?"pl-8":""} ${h?"pr-10":""} ${t}`});return X?e.jsxs("span",{className:`relative block ${a}`,children:[S&&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:S}),Z,h&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:h}),f&&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:[M,I?`/${I}`:""]})]}):Z});function Io({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:c,className:d="",status:b,...f}){return e.jsx(Ea,{label:r,required:c,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Ba,{...f,required:c,status:n?"error":b,className:`w-full ${d}`})})}const Fo={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Po({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...c}){const d=Fo[n],b=r?d.width-d.thumb-d.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:d.width,height:d.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:d.thumb,height:d.thumb,left:d.padding,top:"50%",transform:`translate(${b}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Oa=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function zo(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 Ia(r){return r.classList.contains("sidebar-scroll")}function Fa(r){Ia(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Pa(){return l.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Oa).forEach(c=>{if(!zo(c))return;if(Zt.OverlayScrollbars(c)){Fa(c);return}const b=Zt.OverlayScrollbars(c,{overflow:Ia(c)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});Fa(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(Oa).forEach(c=>{var d;c instanceof HTMLElement&&((d=r.get(c))==null||d.destroy())})}},[]),null}const jo={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"}},za=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],_o={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Wo="bonsaif.bot",qo="Bonsaif Bot",Uo={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function ja(r){return typeof r=="string"?r.trim():""}function Vo(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return za[t%za.length]}function Ko(r,t){return r===Wo||t===qo}function Go(r,t){return`${r.replace(/\/$/,"")}${t}`}function _a({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:c,tooltipContent:d,fallbackLabel:b="Usuario",wrapperClassName:f="",labelClassName:m="",labelSize:k="xs",avatarVersion:S=0,className:h="",style:C}){var _;const[N,g]=l.useState(!1),w=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";l.useEffect(()=>{g(!1)},[w,S]);const{wh:H,text:Y}=jo[n],D=ja(a)||ja(t)||b,G=D.trim()[0]||"?",M=typeof process<"u"&&((_=process.env)==null?void 0:_.NEXT_PUBLIC_BASE_PATH)||"",I=Ko(t,a),X=Go(M,"/favicon.svg"),J=w?`${M}/api/user/avatar/${w}${S?`?v=${S}`:""}`:"",K={xs:20,sm:28,md:36,lg:48,xl:64}[n],Z=I?e.jsx("span",{className:`${H} ${Uo[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 ${h}`,style:C,children:e.jsx("img",{src:X,alt:D,width:K,height:K,className:"h-full w-full object-contain"})}):J&&!N?e.jsx("img",{src:J,alt:D,width:K,height:K,className:`${H} rounded-full object-cover flex-shrink-0 ${h}`,style:C,onError:()=>g(!0)},`${w}-${S}`):e.jsx("span",{className:`${H} ${Vo(D)} ${Y} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${h}`,style:C,title:D,children:G});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[Z,e.jsx("span",{className:`min-w-0 truncate ${_o[k]} font-medium text-[var(--text-main)] ${m}`,title:D,children:D})]});const E=c??!0,B=d??D;return E&&B?e.jsx(cr,{as:"span",content:B,className:`inline-flex flex-shrink-0 ${f}`,children:Z}):Z}function Yo({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function Xo(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Wa({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:c,header:d,footer:b,onLogout:f,LinkComponent:m=Yo}){const[k,S]=l.useState(!1),h=Xo(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Pa,{}),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:()=>S(!0),children:e.jsx(p.HiBars3,{className:"h-5 w-5"})}),k&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>S(!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 ${k?"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(p.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:()=>S(!1),children:e.jsx(p.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(h).map(([C,N])=>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(p.HiChevronDown,{className:"h-3.5 w-3.5"}),C]}),e.jsx("div",{className:"space-y-1",children:N.map(g=>{const w=a===g.href||a.startsWith(`${g.href}/`);return e.jsxs(m,{href:g.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${w?"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:g.icon??e.jsx(p.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:g.label})]},g.href)})})]},C))}),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(_a,{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})]})]}),f&&e.jsxs(Te,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:f,children:[e.jsx(p.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),b]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[d,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const qa="bonsaif-ui:prime-auth-sso",Zo={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(p.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(p.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(p.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(p.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(p.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(p.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(p.HiUser,{className:"h-5 w-5"}),settings:e.jsx(p.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(p.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(p.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(p.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(p.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(p.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(p.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(p.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(p.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(p.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(p.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(p.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(p.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(p.HiShieldCheck,{className:"h-5 w-5"})};function Jo({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function Qo(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ro(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function es(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=Ro(a)&&n?n:a,c=Zo[s]??Qo(s);return[{label:"Inicio",href:"/"},{label:c}]}function Ht(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function rs(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(p.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(p.HiHome,{className:"h-5 w-5"})}function ts(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Ua(){if(typeof window>"u")return!1;if(ts(window.location.href)){try{window.sessionStorage.setItem(qa,"true")}catch{}return!0}try{return window.sessionStorage.getItem(qa)==="true"}catch{return!1}}function as({title:r,subtitle:t,action:a,meta:n,icon:s,className:c="",contentClassName:d="",breadcrumbs:b,currentPath:f,showBreadcrumbs:m=!0,contained:k=!1,LinkComponent:S=Jo}){const h=l.useRef(null),[C,N]=l.useState(!1),[g,w]=l.useState(f??"/"),[H,Y]=l.useState(()=>Ua()),[D,G]=l.useState(null),M=f??g,I=b??es(M),X=s??rs(M),J=m&&!H&&I.length>1,F=!J;l.useEffect(()=>{f||w(window.location.pathname)},[f]),l.useEffect(()=>{Y(Ua())},[]),l.useEffect(()=>{if(k){N(!1);return}let Z=null,E=0,B=0;const _=()=>{const P=h.current,v=document.querySelector("[data-app-scroll='true']");return(P==null?void 0:P.closest(".os-viewport"))??(P==null?void 0:P.closest("[data-overlayscrollbars-viewport]"))??Ht(v)??v??window},O=()=>{const P=Z&&Z!==window?Z.scrollTop:window.scrollY;N(v=>v?P>24:P>72)},ee=()=>{Z==null||Z.removeEventListener("scroll",O),Z=_(),Z.addEventListener("scroll",O,{passive:!0}),O()};return ee(),E=window.requestAnimationFrame(ee),B=window.setTimeout(ee,120),()=>{window.cancelAnimationFrame(E),window.clearTimeout(B),Z==null||Z.removeEventListener("scroll",O)}},[k]),l.useEffect(()=>{if(k){G(null);return}let Z=0;const E=[],B=()=>{const V=h.current,ae=V==null?void 0:V.parentElement,te=document.querySelector("[data-app-scroll='true']"),he=Ht(te)??te;if(!V||!ae||!he){G(null);return}const $=ae.getBoundingClientRect(),ue=window.getComputedStyle(ae),T=he.getBoundingClientRect(),se=he instanceof HTMLElement&&he.clientWidth>0?he.clientWidth:T.width,fe=$.left+parseFloat(ue.paddingLeft||"0"),U={marginLeft:Math.round(T.left-fe),width:Math.round(se)};G(re=>re&&re.marginLeft===U.marginLeft&&re.width===U.width?re:U)},_=()=>{window.cancelAnimationFrame(Z),Z=window.requestAnimationFrame(B)};_(),window.addEventListener("resize",_);const O=new ResizeObserver(_),ee=h.current,P=ee==null?void 0:ee.parentElement,v=document.querySelector("[data-app-scroll='true']"),j=Ht(v)??v;return[P,v,j].forEach(V=>{V&&O.observe(V)}),E.push(window.setTimeout(_,120)),E.push(window.setTimeout(_,280)),()=>{window.cancelAnimationFrame(Z),window.removeEventListener("resize",_),O.disconnect(),E.forEach(V=>window.clearTimeout(V))}},[k]);const K={...D?{marginLeft:D.marginLeft,width:D.width}:null,"--page-header-control-height":C?"34px":"40px","--page-header-control-padding-x":C?"10px":"14px","--page-header-control-icon-left":C?"10px":"12px",background:k?"var(--bg-card)":C?"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:k||C?"1px solid var(--border)":"1px solid transparent",boxShadow:C?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:h,"data-page-header":"true","data-compact":C?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${k?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${c}`,style:K,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${C?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":F?"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"} ${d}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${C||F?"gap-1":"gap-1.5 sm:gap-2"}`,children:[J&&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 ${C?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:I.map((Z,E)=>{const B=E===I.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[E>0&&e.jsx(p.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),Z.href&&!B?e.jsx(S,{href:Z.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:Z.label}):e.jsx("span",{"aria-current":B?"page":void 0,className:B?"truncate font-semibold":"truncate",style:{color:B?"var(--text-main)":"var(--text-muted)"},children:Z.label})]},`${Z.label}-${E}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${C||F?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${C?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:J?"var(--text-secondary)":"var(--text-muted)"},children:X}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${C?"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 ${C?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":C,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${C?"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 ${C?"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 ${C?"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 ns({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(Wa,{currentPath:t,...n,children:r})}function Va(){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 ls(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 os({name:r,src:t,projectKey:a}){const[n,s]=l.useState("system"),c=l.useRef(null);l.useEffect(()=>{s(Va());const f=new MutationObserver(()=>s(Va()));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>f.disconnect()},[]);const d=l.useMemo(()=>ls(t,n,a),[a,t,n]),b=l.useMemo(()=>{try{return new URL(d).origin}catch{return""}},[d]);return l.useEffect(()=>{if(!a)return;const f=a;function m(k){var C,N,g;if(k.source!==((C=c.current)==null?void 0:C.contentWindow)||b&&k.origin!==b)return;if(((N=k.data)==null?void 0:N.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!k.data.active}}));return}if(((g=k.data)==null?void 0:g.type)!=="prime-microservice:navigation")return;const S=k.data.path;if(!S||!S.startsWith("/")||S.startsWith("//"))return;const h=`/apps/${encodeURIComponent(f)}${S}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==h&&(window.history.replaceState(window.history.state,"",h),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:d,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 ss(){const[r,t]=l.useState(""),[a,n]=l.useState(!1),[s,c]=l.useState({width:96,height:96});return l.useEffect(()=>{let d=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(b=>b.ok?b.json():null).then(b=>{!d&&(b!=null&&b.src)&&t(b.src)}).catch(()=>{}),()=>{d=!0}},[]),l.useEffect(()=>{const d=b=>{var m;if(((m=b.data)==null?void 0:m.type)!=="prime-suite-chat:state")return;const f=!!b.data.active;n(f),c({width:Ka(b.data.width,96,720),height:Ka(b.data.height,96,560)})};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]),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 Ka(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function is(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 cs(){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 ds(){return"light"}function us({position:r="bottom-center"}){const t=l.useSyncExternalStore(is,cs,ds);return e.jsx(Jt.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function bs(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]),d=l.useCallback(m=>{a(k=>({...k,[m]:!0}))},[]),b=l.useCallback(()=>{s(!0)},[]),f=l.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:c,touchField:d,submit:b,reset:f}}Object.defineProperty(q,"toast",{enumerable:!0,get:()=>Jt.toast}),q.Alert=Un,q.AuthShell=Wa,q.BonsaifButton=Mn,q.BonsaifUIToaster=us,q.Button=Te,q.CalendarPicker=Xn,q.Checkbox=Fr,q.CodeBlock=el,q.CompactFilterSelect=tl,q.CompactSearchInput=rl,q.ConfirmDialog=ol,q.CopyButton=Nt,q.CopyLinkButton=il,q.DataTable=kl,q.DateRangePicker=El,q.Drawer=Hl,q.DropdownMenu=$l,q.DynamicDetailTabs=Wn,q.EmailField=eo,q.EmptyState=to,q.FieldLayoutEditor=io,q.FileUpload=oo,q.FormField=Ea,q.GlobalScrollbars=Pa,q.InputField=Lt,q.LoadingState=la,q.MicroserviceFrame=os,q.Modal=St,q.MouseTooltip=cr,q.MultiSelect=uo,q.NumberField=bo,q.PageHeader=as,q.PageSearchInput=ea,q.Pagination=po,q.PhoneField=ho,q.PrimeAuthRouteShell=ns,q.PrimeSuiteChatFrame=ss,q.RadioGroup=vo,q.RichTextEditor=yo,q.SearchableSelect=dr,q.SectionPanel=wo,q.StatusBadge=So,q.StatusSelect=$o,q.StepWizard=Ho,q.Tabs=To,q.TextInput=Gr,q.Textarea=Ba,q.TextareaField=Io,q.Toggle=Po,q.UserAvatar=_a,q.cn=Je,q.emailFormat=Fl,q.isValidEmail=Ct,q.isValidPhone=Et,q.matches=ql,q.maxLength=jl,q.maxValue=Wl,q.minLength=zl,q.minValue=_l,q.phoneCountryCodeOptions=La,q.phoneFormat=Pl,q.required=Il,q.useValidationVisibility=bs,q.validateForm=Ul,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})}));
|