Files
2026-11-12 06:29:38 +08:00

2 lines
30 KiB
JavaScript

import{$ as Ze}from"./Item-D8Sud-UP.js";import{b as et,a as tt,p as rt}from"./chunk-2QQAR2RD-YG5LNmAk.js";import{t as ce,f as ot,X as te,an as at,ao as U,ap as O,aq as nt,ar as st,a7 as _e,a8 as De,ai as lt,as as ye,ac as it,at as dt,au as ct,aj as ut,a6 as ft,v as Ee,x as pt,z as vt,w as bt,av as ht,B as gt,aw as mt,D as W,n as J,Y as Ie,E as Pe,ah as yt,y as $t}from"./index-DiaaLdUu.js";import{r as m,R as oe,j as g}from"./react-vendor-jWT2yUdV.js";import{$ as xt,b as wt,m as Te,u as Et,c as Pt,d as Nt,e as St,f as Ct,g as Tt,h as Mt,i as kt}from"./chunk-KVDW62ZT-CGYYmJoP.js";import{$ as Kt}from"./useHover-DC1o5-bm.js";import{$ as _t}from"./usePress-BrNwsdVw.js";import{f as Dt,h as It,j as Ft,i as At}from"./SelectionManager-Dl9uHsLK.js";import{m as Rt}from"./chunk-UX7UMZL5-CMHjUaC_.js";var Lt=ce({base:["w-full","p-1","min-w-[200px]"]});ce({slots:{base:["flex","group","gap-2","items-center","justify-between","relative","px-2","py-1.5","w-full","h-full","box-border","rounded-small","outline-none","cursor-pointer","tap-highlight-transparent","data-[pressed=true]:opacity-70",...ot,"data-[focus-visible=true]:dark:ring-offset-background-content1"],wrapper:"w-full flex flex-col items-start justify-center",title:"flex-1 text-small font-normal truncate",description:["w-full","text-tiny","text-foreground-500","group-hover:text-current"],selectedIcon:["text-inherit","w-3","h-3","flex-shrink-0"],shortcut:["px-1","py-0.5","rounded","font-sans","text-foreground-500","text-tiny","border-small","border-default-300","group-hover:border-current"]},variants:{variant:{solid:{base:""},bordered:{base:"border-medium border-transparent bg-transparent"},light:{base:"bg-transparent"},faded:{base:"border-small border-transparent hover:border-default data-[hover=true]:bg-default-100"},flat:{base:""},shadow:{base:"data-[hover=true]:shadow-lg"}},color:{default:{},primary:{},secondary:{},success:{},warning:{},danger:{}},isDisabled:{true:{base:"opacity-disabled pointer-events-none"}},disableAnimation:{true:{},false:{}}},defaultVariants:{variant:"solid",color:"default"},compoundVariants:[{variant:"solid",color:"default",class:{base:"data-[hover=true]:bg-default data-[hover=true]:text-default-foreground"}},{variant:"solid",color:"primary",class:{base:"data-[hover=true]:bg-primary data-[hover=true]:text-primary-foreground"}},{variant:"solid",color:"secondary",class:{base:"data-[hover=true]:bg-secondary data-[hover=true]:text-secondary-foreground"}},{variant:"solid",color:"success",class:{base:"data-[hover=true]:bg-success data-[hover=true]:text-success-foreground"}},{variant:"solid",color:"warning",class:{base:"data-[hover=true]:bg-warning data-[hover=true]:text-warning-foreground"}},{variant:"solid",color:"danger",class:{base:"data-[hover=true]:bg-danger data-[hover=true]:text-danger-foreground"}},{variant:"shadow",color:"default",class:{base:"data-[hover=true]:shadow-default/50 data-[hover=true]:bg-default data-[hover=true]:text-default-foreground"}},{variant:"shadow",color:"primary",class:{base:"data-[hover=true]:shadow-primary/30 data-[hover=true]:bg-primary data-[hover=true]:text-primary-foreground"}},{variant:"shadow",color:"secondary",class:{base:"data-[hover=true]:shadow-secondary/30 data-[hover=true]:bg-secondary data-[hover=true]:text-secondary-foreground"}},{variant:"shadow",color:"success",class:{base:"data-[hover=true]:shadow-success/30 data-[hover=true]:bg-success data-[hover=true]:text-success-foreground"}},{variant:"shadow",color:"warning",class:{base:"data-[hover=true]:shadow-warning/30 data-[hover=true]:bg-warning data-[hover=true]:text-warning-foreground"}},{variant:"shadow",color:"danger",class:{base:"data-[hover=true]:shadow-danger/30 data-[hover=true]:bg-danger data-[hover=true]:text-danger-foreground"}},{variant:"bordered",color:"default",class:{base:"data-[hover=true]:border-default"}},{variant:"bordered",color:"primary",class:{base:"data-[hover=true]:border-primary data-[hover=true]:text-primary"}},{variant:"bordered",color:"secondary",class:{base:"data-[hover=true]:border-secondary data-[hover=true]:text-secondary"}},{variant:"bordered",color:"success",class:{base:"data-[hover=true]:border-success data-[hover=true]:text-success"}},{variant:"bordered",color:"warning",class:{base:"data-[hover=true]:border-warning data-[hover=true]:text-warning"}},{variant:"bordered",color:"danger",class:{base:"data-[hover=true]:border-danger data-[hover=true]:text-danger"}},{variant:"flat",color:"default",class:{base:"data-[hover=true]:bg-default/40 data-[hover=true]:text-default-foreground"}},{variant:"flat",color:"primary",class:{base:"data-[hover=true]:bg-primary/20 data-[hover=true]:text-primary"}},{variant:"flat",color:"secondary",class:{base:"data-[hover=true]:bg-secondary/20 data-[hover=true]:text-secondary"}},{variant:"flat",color:"success",class:{base:"data-[hover=true]:bg-success/20 data-[hover=true]:text-success "}},{variant:"flat",color:"warning",class:{base:"data-[hover=true]:bg-warning/20 data-[hover=true]:text-warning"}},{variant:"flat",color:"danger",class:{base:"data-[hover=true]:bg-danger/20 data-[hover=true]:text-danger"}},{variant:"faded",color:"default",class:{base:"data-[hover=true]:text-default-foreground"}},{variant:"faded",color:"primary",class:{base:"data-[hover=true]:text-primary"}},{variant:"faded",color:"secondary",class:{base:"data-[hover=true]:text-secondary"}},{variant:"faded",color:"success",class:{base:"data-[hover=true]:text-success"}},{variant:"faded",color:"warning",class:{base:"data-[hover=true]:text-warning"}},{variant:"faded",color:"danger",class:{base:"data-[hover=true]:text-danger"}},{variant:"light",color:"default",class:{base:"data-[hover=true]:text-default-500"}},{variant:"light",color:"primary",class:{base:"data-[hover=true]:text-primary"}},{variant:"light",color:"secondary",class:{base:"data-[hover=true]:text-secondary"}},{variant:"light",color:"success",class:{base:"data-[hover=true]:text-success"}},{variant:"light",color:"warning",class:{base:"data-[hover=true]:text-warning"}},{variant:"light",color:"danger",class:{base:"data-[hover=true]:text-danger"}}]});ce({slots:{base:"relative mb-2",heading:"pl-1 text-tiny text-foreground-500",group:"data-[has-title=true]:pt-1",divider:"mt-2"}});ce({base:"w-full flex flex-col gap-0.5 p-1"});var jt=(e,t)=>{if(!e&&!t)return{};const r=new Set([...Object.keys(e||{}),...Object.keys(t||{})]);return Array.from(r).reduce((a,o)=>({...a,[o]:te(e==null?void 0:e[o],t==null?void 0:t[o])}),{})};function Ot(e){const t=at(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:r,visibility:a}=e.style,o=r!=="none"&&a!=="hidden"&&a!=="collapse";if(o){const{getComputedStyle:s}=e.ownerDocument.defaultView;let{display:i,visibility:n}=s(e);o=i!=="none"&&n!=="hidden"&&n!=="collapse"}return o}function Ht(e,t){return!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Fe(e,t){return e.nodeName!=="#comment"&&Ot(e)&&Ht(e,t)&&(!e.parentElement||Fe(e.parentElement,e))}const Me=oe.createContext(null),$e="react-aria-focus-scope-restore";let $=null;function Bt(e){let{children:t,contain:r,restoreFocus:a,autoFocus:o}=e,s=m.useRef(null),i=m.useRef(null),n=m.useRef([]),{parentNode:c}=m.useContext(Me)||{},l=m.useMemo(()=>new we({scopeRef:n}),[n]);U(()=>{let f=c||C.root;if(C.getTreeNode(f.scopeRef)&&$&&!de($,f.scopeRef)){let p=C.getTreeNode($);p&&(f=p)}f.addChild(l),C.addNode(l)},[l,c]),U(()=>{let f=C.getTreeNode(n);f&&(f.contain=!!r)},[r]),U(()=>{var f;let p=(f=s.current)===null||f===void 0?void 0:f.nextSibling,v=[],N=b=>b.stopPropagation();for(;p&&p!==i.current;)v.push(p),p.addEventListener($e,N),p=p.nextSibling;return n.current=v,()=>{for(let b of v)b.removeEventListener($e,N)}},[t]),Yt(n,a,r),Wt(n,r),Gt(n,a,r),qt(n,o),m.useEffect(()=>{const f=O(n.current?n.current[0]:void 0).activeElement;let p=null;if(L(f,n.current)){for(let v of C.traverse())v.scopeRef&&L(f,v.scopeRef.current)&&(p=v);p===C.getTreeNode(n)&&($=p.scopeRef)}},[n]),U(()=>()=>{var f,p,v;let N=(v=(p=C.getTreeNode(n))===null||p===void 0||(f=p.parent)===null||f===void 0?void 0:f.scopeRef)!==null&&v!==void 0?v:null;(n===$||de(n,$))&&(!N||C.getTreeNode(N))&&($=N),C.removeTreeNode(n)},[n]);let d=m.useMemo(()=>Ut(n),[]),u=m.useMemo(()=>({focusManager:d,parentNode:l}),[l,d]);return oe.createElement(Me.Provider,{value:u},oe.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:s}),t,oe.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:i}))}function Ut(e){return{focusNext(t={}){let r=e.current,{from:a,tabbable:o,wrap:s,accept:i}=t,n=a||O(r[0]).activeElement,c=r[0].previousElementSibling,l=Z(r),d=X(l,{tabbable:o,accept:i},r);d.currentNode=L(n,r)?n:c;let u=d.nextNode();return!u&&s&&(d.currentNode=c,u=d.nextNode()),u&&q(u,!0),u},focusPrevious(t={}){let r=e.current,{from:a,tabbable:o,wrap:s,accept:i}=t,n=a||O(r[0]).activeElement,c=r[r.length-1].nextElementSibling,l=Z(r),d=X(l,{tabbable:o,accept:i},r);d.currentNode=L(n,r)?n:c;let u=d.previousNode();return!u&&s&&(d.currentNode=c,u=d.previousNode()),u&&q(u,!0),u},focusFirst(t={}){let r=e.current,{tabbable:a,accept:o}=t,s=Z(r),i=X(s,{tabbable:a,accept:o},r);i.currentNode=r[0].previousElementSibling;let n=i.nextNode();return n&&q(n,!0),n},focusLast(t={}){let r=e.current,{tabbable:a,accept:o}=t,s=Z(r),i=X(s,{tabbable:a,accept:o},r);i.currentNode=r[r.length-1].nextElementSibling;let n=i.previousNode();return n&&q(n,!0),n}}}const Ne=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]"],Vt=Ne.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";Ne.push('[tabindex]:not([tabindex="-1"]):not([disabled])');const zt=Ne.join(':not([hidden]):not([tabindex="-1"]),');function Z(e){return e[0].parentElement}function le(e){let t=C.getTreeNode($);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function Wt(e,t){let r=m.useRef(void 0),a=m.useRef(void 0);U(()=>{let o=e.current;if(!t){a.current&&(cancelAnimationFrame(a.current),a.current=void 0);return}const s=O(o?o[0]:void 0);let i=l=>{if(l.key!=="Tab"||l.altKey||l.ctrlKey||l.metaKey||!le(e)||l.isComposing)return;let d=s.activeElement,u=e.current;if(!u||!L(d,u))return;let f=Z(u),p=X(f,{tabbable:!0},u);if(!d)return;p.currentNode=d;let v=l.shiftKey?p.previousNode():p.nextNode();v||(p.currentNode=l.shiftKey?u[u.length-1].nextElementSibling:u[0].previousElementSibling,v=l.shiftKey?p.previousNode():p.nextNode()),l.preventDefault(),v&&q(v,!0)},n=l=>{(!$||de($,e))&&L(l.target,e.current)?($=e,r.current=l.target):le(e)&&!ee(l.target,e)?r.current?r.current.focus():$&&$.current&&xe($.current):le(e)&&(r.current=l.target)},c=l=>{a.current&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{if(s.activeElement&&le(e)&&!ee(s.activeElement,e))if($=e,s.body.contains(l.target)){var d;r.current=l.target,(d=r.current)===null||d===void 0||d.focus()}else $.current&&xe($.current)})};return s.addEventListener("keydown",i,!1),s.addEventListener("focusin",n,!1),o==null||o.forEach(l=>l.addEventListener("focusin",n,!1)),o==null||o.forEach(l=>l.addEventListener("focusout",c,!1)),()=>{s.removeEventListener("keydown",i,!1),s.removeEventListener("focusin",n,!1),o==null||o.forEach(l=>l.removeEventListener("focusin",n,!1)),o==null||o.forEach(l=>l.removeEventListener("focusout",c,!1))}},[e,t]),U(()=>()=>{a.current&&cancelAnimationFrame(a.current)},[a])}function Ae(e){return ee(e)}function L(e,t){return!e||!t?!1:t.some(r=>r.contains(e))}function ee(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:r}of C.traverse(C.getTreeNode(t)))if(r&&L(e,r.current))return!0;return!1}function de(e,t){var r;let a=(r=C.getTreeNode(t))===null||r===void 0?void 0:r.parent;for(;a;){if(a.scopeRef===e)return!0;a=a.parent}return!1}function q(e,t=!1){if(e!=null&&!t)try{nt(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function Re(e,t=!0){let r=e[0].previousElementSibling,a=Z(e),o=X(a,{tabbable:t},e);o.currentNode=r;let s=o.nextNode();return t&&!s&&(a=Z(e),o=X(a,{tabbable:!1},e),o.currentNode=r,s=o.nextNode()),s}function xe(e,t=!0){q(Re(e,t))}function qt(e,t){const r=oe.useRef(t);m.useEffect(()=>{if(r.current){$=e;const a=O(e.current?e.current[0]:void 0);!L(a.activeElement,$.current)&&e.current&&xe(e.current)}r.current=!1},[e])}function Yt(e,t,r){U(()=>{if(t||r)return;let a=e.current;const o=O(a?a[0]:void 0);let s=i=>{let n=i.target;L(n,e.current)?$=e:Ae(n)||($=null)};return o.addEventListener("focusin",s,!1),a==null||a.forEach(i=>i.addEventListener("focusin",s,!1)),()=>{o.removeEventListener("focusin",s,!1),a==null||a.forEach(i=>i.removeEventListener("focusin",s,!1))}},[e,t,r])}function ke(e){let t=C.getTreeNode($);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function Gt(e,t,r){const a=m.useRef(typeof document<"u"?O(e.current?e.current[0]:void 0).activeElement:null);U(()=>{let o=e.current;const s=O(o?o[0]:void 0);if(!t||r)return;let i=()=>{(!$||de($,e))&&L(s.activeElement,e.current)&&($=e)};return s.addEventListener("focusin",i,!1),o==null||o.forEach(n=>n.addEventListener("focusin",i,!1)),()=>{s.removeEventListener("focusin",i,!1),o==null||o.forEach(n=>n.removeEventListener("focusin",i,!1))}},[e,r]),U(()=>{const o=O(e.current?e.current[0]:void 0);if(!t)return;let s=i=>{if(i.key!=="Tab"||i.altKey||i.ctrlKey||i.metaKey||!le(e)||i.isComposing)return;let n=o.activeElement;if(!ee(n,e)||!ke(e))return;let c=C.getTreeNode(e);if(!c)return;let l=c.nodeToRestore,d=X(o.body,{tabbable:!0});d.currentNode=n;let u=i.shiftKey?d.previousNode():d.nextNode();if((!l||!o.body.contains(l)||l===o.body)&&(l=void 0,c.nodeToRestore=void 0),(!u||!ee(u,e))&&l){d.currentNode=l;do u=i.shiftKey?d.previousNode():d.nextNode();while(ee(u,e));i.preventDefault(),i.stopPropagation(),u?q(u,!0):Ae(l)?q(l,!0):n.blur()}};return r||o.addEventListener("keydown",s,!0),()=>{r||o.removeEventListener("keydown",s,!0)}},[e,t,r]),U(()=>{const o=O(e.current?e.current[0]:void 0);if(!t)return;let s=C.getTreeNode(e);if(s){var i;return s.nodeToRestore=(i=a.current)!==null&&i!==void 0?i:void 0,()=>{let n=C.getTreeNode(e);if(!n)return;let c=n.nodeToRestore;if(t&&c&&(o.activeElement&&ee(o.activeElement,e)||o.activeElement===o.body&&ke(e))){let l=C.clone();requestAnimationFrame(()=>{if(o.activeElement===o.body){let d=l.getTreeNode(e);for(;d;){if(d.nodeToRestore&&d.nodeToRestore.isConnected){Ke(d.nodeToRestore);return}d=d.parent}for(d=l.getTreeNode(e);d;){if(d.scopeRef&&d.scopeRef.current&&C.getTreeNode(d.scopeRef)){let u=Re(d.scopeRef.current,!0);Ke(u);return}d=d.parent}}})}}}},[e,t])}function Ke(e){e.dispatchEvent(new CustomEvent($e,{bubbles:!0,cancelable:!0}))&&q(e)}function X(e,t,r){let a=t!=null&&t.tabbable?zt:Vt,o=O(e).createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(s){var i;return!(t==null||(i=t.from)===null||i===void 0)&&i.contains(s)?NodeFilter.FILTER_REJECT:s.matches(a)&&Fe(s)&&(!r||L(s,r))&&(!(t!=null&&t.accept)||t.accept(s))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(o.currentNode=t.from),o}class Se{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,r,a){let o=this.fastMap.get(r??null);if(!o)return;let s=new we({scopeRef:t});o.addChild(s),s.parent=o,this.fastMap.set(t,s),a&&(s.nodeToRestore=a)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let r=this.fastMap.get(t);if(!r)return;let a=r.parent;for(let s of this.traverse())s!==r&&r.nodeToRestore&&s.nodeToRestore&&r.scopeRef&&r.scopeRef.current&&L(s.nodeToRestore,r.scopeRef.current)&&(s.nodeToRestore=r.nodeToRestore);let o=r.children;a&&(a.removeChild(r),o.size>0&&o.forEach(s=>a&&a.addChild(s))),this.fastMap.delete(r.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let r of t.children)yield*this.traverse(r)}clone(){var t;let r=new Se;var a;for(let o of this.traverse())r.addTreeNode(o.scopeRef,(a=(t=o.parent)===null||t===void 0?void 0:t.scopeRef)!==null&&a!==void 0?a:null,o.nodeToRestore);return r}constructor(){this.fastMap=new Map,this.root=new we({scopeRef:null}),this.fastMap.set(null,this.root)}}class we{addChild(t){this.children.add(t),t.parent=this}removeChild(t){this.children.delete(t),t.parent=void 0}constructor(t){this.children=new Set,this.contain=!1,this.scopeRef=t.scopeRef}}let C=new Se;var[Jt,Le]=st({name:"DropdownContext",errorMessage:"useDropdownContext: `context` is undefined. Seems you forgot to wrap all popover components within `<Dropdown />`"});function Xt(e){const{isSelected:t,disableAnimation:r,...a}=e;return g.jsx("svg",{"aria-hidden":"true","data-selected":t,role:"presentation",viewBox:"0 0 17 18",...a,children:g.jsx("polyline",{fill:"none",points:"1 9 7 14 15 4",stroke:"currentColor",strokeDasharray:22,strokeDashoffset:t?44:66,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,style:r?{}:{transition:"stroke-dashoffset 200ms ease"}})})}const je=new WeakMap;function Qt(e,t,r){let{shouldFocusWrap:a=!0,onKeyDown:o,onKeyUp:s,...i}=e;!e["aria-label"]&&!e["aria-labelledby"]&&console.warn("An aria-label or aria-labelledby prop is required for accessibility.");let n=_e(e,{labelable:!0}),{listProps:c}=xt({...i,ref:r,selectionManager:t.selectionManager,collection:t.collection,disabledKeys:t.disabledKeys,shouldFocusWrap:a,linkBehavior:"override"});return je.set(t,{onClose:e.onClose,onAction:e.onAction}),{menuProps:De(n,{onKeyDown:o,onKeyUp:s},{role:"menu",...c,onKeyDown:l=>{var d;l.key!=="Escape"&&((d=c.onKeyDown)===null||d===void 0||d.call(c,l))}})}}function Zt(e,t,r){let{id:a,key:o,closeOnSelect:s,isVirtualized:i,"aria-haspopup":n,onPressStart:c,onPressUp:l,onPress:d,onPressChange:u,onPressEnd:f,onHoverStart:p,onHoverChange:v,onHoverEnd:N,onKeyDown:b,onKeyUp:D,onFocus:k,onFocusChange:w,onBlur:T,selectionManager:h=t.selectionManager}=e,y=!!n,j=y&&e["aria-expanded"]==="true";var E;let I=(E=e.isDisabled)!==null&&E!==void 0?E:h.isDisabled(o);var A;let F=(A=e.isSelected)!==null&&A!==void 0?A:h.isSelected(o),H=je.get(t),x=t.collection.getItem(o),R=e.onClose||H.onClose,B=lt(),P=S=>{var se;if(!y){if(!(x==null||(se=x.props)===null||se===void 0)&&se.onAction?x.props.onAction():e.onAction&&e.onAction(o),H.onAction){let ge=H.onAction;ge(o)}S.target instanceof HTMLAnchorElement&&x&&B.open(S.target,S,x.props.href,x.props.routerOptions)}},K="menuitem";y||(h.selectionMode==="single"?K="menuitemradio":h.selectionMode==="multiple"&&(K="menuitemcheckbox"));let M=ye(),V=ye(),re=ye(),Y={id:a,"aria-disabled":I||void 0,role:K,"aria-label":e["aria-label"],"aria-labelledby":M,"aria-describedby":[V,re].filter(Boolean).join(" ")||void 0,"aria-controls":e["aria-controls"],"aria-haspopup":n,"aria-expanded":e["aria-expanded"]};h.selectionMode!=="none"&&!y&&(Y["aria-checked"]=F),i&&(Y["aria-posinset"]=x==null?void 0:x.index,Y["aria-setsize"]=wt(t.collection));let ae=S=>{S.pointerType==="keyboard"&&P(S),c==null||c(S)},ue=S=>{S.pointerType!=="keyboard"&&(P(S),!y&&R&&(s??(h.selectionMode!=="multiple"||h.isLink(o)))&&R()),l==null||l(S)},{itemProps:G,isFocused:fe}=Dt({selectionManager:h,key:o,ref:r,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,linkBehavior:"none"}),{pressProps:pe,isPressed:ve}=_t({onPressStart:ae,onPress:d,onPressUp:ue,onPressChange:u,onPressEnd:f,isDisabled:I}),{hoverProps:be}=Kt({isDisabled:I,onHoverStart(S){!it()&&!(j&&n==="dialog")&&(h.setFocused(!0),h.setFocusedKey(o)),p==null||p(S)},onHoverChange:v,onHoverEnd:N}),{keyboardProps:ie}=dt({onKeyDown:S=>{if(S.repeat){S.continuePropagation();return}switch(S.key){case" ":!I&&h.selectionMode==="none"&&!y&&s!==!1&&R&&R();break;case"Enter":!I&&s!==!1&&!y&&R&&R();break;default:y||S.continuePropagation(),b==null||b(S);break}},onKeyUp:D}),{focusProps:he}=ct({onBlur:T,onFocus:k,onFocusChange:w}),ne=_e(x==null?void 0:x.props);delete ne.id;let z=ut(x==null?void 0:x.props);return{menuItemProps:{...Y,...De(ne,z,y?{onFocus:G.onFocus,"data-key":G["data-key"]}:G,pe,be,ie,he),tabIndex:G.tabIndex!=null&&j?-1:G.tabIndex},labelProps:{id:M},descriptionProps:{id:V},keyboardShortcutProps:{id:re},isFocused:fe,isSelected:F,isPressed:ve,isDisabled:I}}function er(e){let{heading:t,"aria-label":r}=e,a=ft();return{itemProps:{role:"presentation"},headingProps:t?{id:a,role:"presentation"}:{},groupProps:{role:"group","aria-label":r,"aria-labelledby":t?a:void 0}}}function tr(e){var t,r;const a=Ee(),[o,s]=pt(e,Te.variantKeys),{as:i,item:n,state:c,shortcut:l,description:d,startContent:u,endContent:f,isVirtualized:p,selectedIcon:v,className:N,classNames:b,onAction:D,autoFocus:k,onPress:w,onPressStart:T,onPressUp:h,onPressEnd:y,onPressChange:j,onHoverStart:E,onHoverChange:I,onHoverEnd:A,hideSelectedIcon:F=!1,isReadOnly:H=!1,closeOnSelect:x,onClose:R,onClick:B,...P}=o,K=(r=(t=e.disableAnimation)!=null?t:a==null?void 0:a.disableAnimation)!=null?r:!1,M=m.useRef(null),V=i||(P!=null&&P.href?"a":"li"),re=typeof V=="string",{rendered:Y,key:ae}=n,ue=c.disabledKeys.has(ae)||e.isDisabled,G=c.selectionManager.selectionMode!=="none",fe=Et(),{isFocusVisible:pe,focusProps:ve}=vt({autoFocus:k});B&&typeof B=="function"&&bt("onClick is deprecated, please use onPress instead. See: https://github.com/heroui-inc/heroui/issues/4292","MenuItem");const be=m.useCallback(_=>{B==null||B(_),w==null||w(_)},[B,w]),{isPressed:ie,isFocused:he,isSelected:ne,isDisabled:z,menuItemProps:S,labelProps:se,descriptionProps:ge,keyboardShortcutProps:ze}=Zt({key:ae,onClose:R,isDisabled:ue,onPress:be,onPressStart:T,onPressUp:h,onPressEnd:y,onPressChange:j,"aria-label":o["aria-label"],closeOnSelect:x,isVirtualized:p,onAction:D},c,M);let{hoverProps:We,isHovered:Ce}=ht({isDisabled:z,onHoverStart(_){Pt()||(c.selectionManager.setFocused(!0),c.selectionManager.setFocusedKey(ae)),E==null||E(_)},onHoverChange:I,onHoverEnd:A}),me=S;const Q=m.useMemo(()=>Te({...s,isDisabled:z,disableAnimation:K,hasTitleTextChild:typeof Y=="string",hasDescriptionTextChild:typeof d=="string"}),[gt(s),z,K,Y,d]),qe=te(b==null?void 0:b.base,N);H&&(me=mt(me));const Ye=(_={})=>({ref:M,...J(H?{}:ve,Ie(P,{enabled:re}),me,We,_),"data-focus":W(he),"data-selectable":W(G),"data-hover":W(fe?Ce||ie:Ce),"data-disabled":W(z),"data-selected":W(ne),"data-pressed":W(ie),"data-focus-visible":W(pe),className:Q.base({class:te(qe,_.className)})}),Ge=(_={})=>({...J(se,_),className:Q.title({class:b==null?void 0:b.title})}),Je=(_={})=>({...J(ge,_),className:Q.description({class:b==null?void 0:b.description})}),Xe=(_={})=>({...J(ze,_),className:Q.shortcut({class:b==null?void 0:b.shortcut})}),Qe=m.useCallback((_={})=>({"aria-hidden":W(!0),"data-disabled":W(z),className:Q.selectedIcon({class:b==null?void 0:b.selectedIcon}),..._}),[z,Q,b]);return{Component:V,domRef:M,slots:Q,classNames:b,isSelectable:G,isSelected:ne,isDisabled:z,rendered:Y,shortcut:l,description:d,startContent:u,endContent:f,selectedIcon:v,disableAnimation:K,getItemProps:Ye,getLabelProps:Ge,hideSelectedIcon:F,getDescriptionProps:Je,getKeyboardShortcutProps:Xe,getSelectedIconProps:Qe}}var Oe=e=>{const{Component:t,slots:r,classNames:a,rendered:o,shortcut:s,description:i,isSelectable:n,isSelected:c,isDisabled:l,selectedIcon:d,startContent:u,endContent:f,disableAnimation:p,hideSelectedIcon:v,getItemProps:N,getLabelProps:b,getDescriptionProps:D,getKeyboardShortcutProps:k,getSelectedIconProps:w}=tr(e),T=m.useMemo(()=>{const h=g.jsx(Xt,{disableAnimation:p,isSelected:c});return typeof d=="function"?d({icon:h,isSelected:c,isDisabled:l}):d||h},[d,c,l,p]);return g.jsxs(t,{...N(),children:[u,i?g.jsxs("div",{className:r.wrapper({class:a==null?void 0:a.wrapper}),children:[g.jsx("span",{...b(),children:o}),g.jsx("span",{...D(),children:i})]}):g.jsx("span",{...b(),children:o}),s&&g.jsx("kbd",{...k(),children:s}),n&&!v&&g.jsx("span",{...w(),children:T}),f]})};Oe.displayName="HeroUI.MenuItem";var He=Oe,Be=Pe(({item:e,state:t,as:r,variant:a,color:o,disableAnimation:s,onAction:i,closeOnSelect:n,className:c,classNames:l,showDivider:d=!1,hideSelectedIcon:u,dividerProps:f={},itemClasses:p,title:v,...N},b)=>{const D=r||"li",k=m.useMemo(()=>Nt(),[]),w=te(l==null?void 0:l.base,c),T=te(l==null?void 0:l.divider,f==null?void 0:f.className),{itemProps:h,headingProps:y,groupProps:j}=er({heading:e.rendered,"aria-label":e["aria-label"]});return g.jsxs(D,{"data-slot":"base",...J(h,N),className:k.base({class:w}),children:[e.rendered&&g.jsx("span",{...y,className:k.heading({class:l==null?void 0:l.heading}),"data-slot":"heading",children:e.rendered}),g.jsxs("ul",{...j,className:k.group({class:l==null?void 0:l.group}),"data-has-title":!!e.rendered,"data-slot":"group",children:[[...e.childNodes].map(E=>{const{key:I,props:A}=E;let F=g.jsx(He,{classNames:p,closeOnSelect:n,color:o,disableAnimation:s,hideSelectedIcon:u,item:E,state:t,variant:a,onAction:i,...A},I);return E.wrapper&&(F=E.wrapper(F)),F}),d&&g.jsx(St,{as:"li",className:k.divider({class:T}),...f})]})]})});Be.displayName="HeroUI.MenuSection";var rr=Be;class or{*[Symbol.iterator](){yield*this.iterable}get size(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(t){let r=this.keyMap.get(t);var a;return r&&(a=r.prevKey)!==null&&a!==void 0?a:null}getKeyAfter(t){let r=this.keyMap.get(t);var a;return r&&(a=r.nextKey)!==null&&a!==void 0?a:null}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(t){var r;return(r=this.keyMap.get(t))!==null&&r!==void 0?r:null}at(t){const r=[...this.getKeys()];return this.getItem(r[t])}constructor(t,{expandedKeys:r}={}){this.keyMap=new Map,this.firstKey=null,this.lastKey=null,this.iterable=t,r=r||new Set;let a=n=>{if(this.keyMap.set(n.key,n),n.childNodes&&(n.type==="section"||r.has(n.key)))for(let c of n.childNodes)a(c)};for(let n of t)a(n);let o=null,s=0;for(let[n,c]of this.keyMap)o?(o.nextKey=n,c.prevKey=o.key):(this.firstKey=n,c.prevKey=void 0),c.type==="item"&&(c.index=s++),o=c,o.nextKey=void 0;var i;this.lastKey=(i=o==null?void 0:o.key)!==null&&i!==void 0?i:null}}function ar(e){let{onExpandedChange:t}=e,[r,a]=yt(e.expandedKeys?new Set(e.expandedKeys):void 0,e.defaultExpandedKeys?new Set(e.defaultExpandedKeys):new Set,t),o=It(e),s=m.useMemo(()=>e.disabledKeys?new Set(e.disabledKeys):new Set,[e.disabledKeys]),i=Ft(e,m.useCallback(c=>new or(c,{expandedKeys:r}),[r]),null);return m.useEffect(()=>{o.focusedKey!=null&&!i.getItem(o.focusedKey)&&o.setFocusedKey(null)},[i,o.focusedKey]),{collection:i,expandedKeys:r,disabledKeys:s,toggleKey:c=>{a(nr(r,c))},setExpandedKeys:a,selectionManager:new At(i,o)}}function nr(e,t){let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r}function sr(e){var t;const r=Ee(),{as:a,ref:o,variant:s,color:i,children:n,disableAnimation:c=(t=r==null?void 0:r.disableAnimation)!=null?t:!1,onAction:l,closeOnSelect:d,itemClasses:u,className:f,state:p,topContent:v,bottomContent:N,hideEmptyContent:b=!1,hideSelectedIcon:D=!1,emptyContent:k="No items.",menuProps:w,onClose:T,classNames:h,...y}=e,j=a||"ul",E=$t(o),I=typeof j=="string",A=ar({...y,...w,children:n}),F=p||A,{menuProps:H}=Qt({...y,...w,onAction:l},F,E),x=m.useMemo(()=>Ct({className:f}),[f]),R=te(h==null?void 0:h.base,f);return{Component:j,state:F,variant:s,color:i,disableAnimation:c,onClose:T,topContent:v,bottomContent:N,closeOnSelect:d,className:f,itemClasses:u,getBaseProps:(M={})=>({ref:E,"data-slot":"base",className:x.base({class:R}),...Ie(y,{enabled:I}),...M}),getListProps:(M={})=>({"data-slot":"list",className:x.list({class:h==null?void 0:h.list}),...H,...M}),hideEmptyContent:b,hideSelectedIcon:D,getEmptyContentProps:(M={})=>({children:k,className:x.emptyContent({class:h==null?void 0:h.emptyContent}),...M})}}var lr=Pe(function(t,r){const{Component:a,state:o,closeOnSelect:s,color:i,disableAnimation:n,hideSelectedIcon:c,hideEmptyContent:l,variant:d,onClose:u,topContent:f,bottomContent:p,itemClasses:v,getBaseProps:N,getListProps:b,getEmptyContentProps:D}=sr({...t,ref:r}),k=g.jsxs(a,{...b(),children:[!o.collection.size&&!l&&g.jsx("li",{children:g.jsx("div",{...D()})}),[...o.collection].map(w=>{const T={closeOnSelect:s,color:i,disableAnimation:n,item:w,state:o,variant:d,onClose:u,hideSelectedIcon:c,...w.props},h=jt(v,T==null?void 0:T.classNames);if(w.type==="section")return g.jsx(rr,{...T,itemClasses:h},w.key);let y=g.jsx(He,{...T,classNames:h},w.key);return w.wrapper&&(y=w.wrapper(y)),y})]});return g.jsxs("div",{...N(),children:[f,k,p]})}),ir=lr,dr=Ze,Er=dr,cr=Pe(function(t,r){const{getMenuProps:a}=Le();return g.jsx(et,{children:g.jsx(Bt,{contain:!0,restoreFocus:!0,children:g.jsx(ir,{...a(t,r)})})})}),Pr=cr,Ue=e=>{const{getMenuTriggerProps:t}=Le(),{children:r,...a}=e;return g.jsx(tt,{...t(a),children:r})};Ue.displayName="HeroUI.DropdownTrigger";var Nr=Ue,ur=(e,t)=>{if(e){const r=Array.isArray(e.children)?e.children:[...(e==null?void 0:e.items)||[]];if(r&&r.length)return r.find(o=>{if(o&&o.key===t)return o})||{}}return null},fr=(e,t,r)=>{const a=r||ur(e,t);return a&&a.props&&"closeOnSelect"in a.props?a.props.closeOnSelect:e==null?void 0:e.closeOnSelect};function pr(e){var t;const r=Ee(),{as:a,triggerRef:o,isOpen:s,defaultOpen:i,onOpenChange:n,isDisabled:c,type:l="menu",trigger:d="press",placement:u="bottom",closeOnSelect:f=!0,shouldBlockScroll:p=!0,classNames:v,disableAnimation:N=(t=r==null?void 0:r.disableAnimation)!=null?t:!1,onClose:b,className:D,...k}=e,w=a||"div",T=m.useRef(null),h=o||T,y=m.useRef(null),j=m.useRef(null),E=Tt({trigger:d,isOpen:s,defaultOpen:i,onOpenChange:P=>{n==null||n(P),P||b==null||b()}}),{menuTriggerProps:I,menuProps:A}=Mt({type:l,trigger:d,isDisabled:c},E,h),F=m.useMemo(()=>Lt({className:D}),[D]),H=P=>{P!==void 0&&!P||f&&E.close()},x=(P={})=>{const K=J(k,P);return{state:E,placement:u,ref:j,disableAnimation:N,shouldBlockScroll:p,scrollRef:y,triggerRef:h,...K,classNames:{...v,...P.classNames,content:te(F,v==null?void 0:v.content,P.className)},shouldCloseOnInteractOutside:K!=null&&K.shouldCloseOnInteractOutside?K.shouldCloseOnInteractOutside:M=>kt(M,T,E)}},R=(P={})=>{const{onPress:K,onPressStart:M,...V}=I;return J(V,{isDisabled:c},P)},B=(P,K=null)=>({ref:Rt(K,y),menuProps:A,closeOnSelect:f,...J(P,{onAction:(M,V)=>{const re=fr(P,M,V);H(re)},onClose:E.close})});return{Component:w,menuRef:y,menuProps:A,classNames:F,closeOnSelect:f,onClose:E.close,autoFocus:E.focusStrategy||!0,disableAnimation:N,getPopoverProps:x,getMenuProps:B,getMenuTriggerProps:R}}var Ve=e=>{const{children:t,...r}=e,a=pr(r),[o,s]=oe.Children.toArray(t);return g.jsx(Jt,{value:a,children:g.jsxs(rt,{...a.getPopoverProps(),children:[o,s]})})};Ve.displayName="HeroUI.Dropdown";var Sr=Ve;export{Nr as a,Pr as b,Sr as d,Er as m};