@bazza-ui/react 0.1.0-canary.12 → 0.1.0-canary.14

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.
Files changed (57) hide show
  1. package/dist/{ListboxStore-nmorsoqX.d.cts → ListboxStore-DCGGpiBg.d.cts} +1 -1
  2. package/dist/{ListboxStore-BYBpGrOz.d.ts → ListboxStore-DZ73dOaC.d.ts} +1 -1
  3. package/dist/chunk-NNGWBSWK.js +2 -0
  4. package/dist/chunk-NNGWBSWK.js.map +1 -0
  5. package/dist/chunk-Z2RGBRJP.cjs +2 -0
  6. package/dist/{chunk-EYMK7XHC.cjs.map → chunk-Z2RGBRJP.cjs.map} +1 -1
  7. package/dist/combobox/index.cjs +1 -1
  8. package/dist/combobox/index.d.cts +8 -8
  9. package/dist/combobox/index.d.ts +8 -8
  10. package/dist/combobox/index.js +1 -1
  11. package/dist/command-menu/index.cjs +1 -1
  12. package/dist/command-menu/index.cjs.map +1 -1
  13. package/dist/command-menu/index.d.cts +9 -9
  14. package/dist/command-menu/index.d.ts +9 -9
  15. package/dist/command-menu/index.js +1 -1
  16. package/dist/command-menu/index.js.map +1 -1
  17. package/dist/context-menu/index.cjs +1 -1
  18. package/dist/context-menu/index.cjs.map +1 -1
  19. package/dist/context-menu/index.d.cts +39 -15
  20. package/dist/context-menu/index.d.ts +39 -15
  21. package/dist/context-menu/index.js +1 -1
  22. package/dist/context-menu/index.js.map +1 -1
  23. package/dist/dropdown-menu/index.cjs +1 -1
  24. package/dist/dropdown-menu/index.cjs.map +1 -1
  25. package/dist/dropdown-menu/index.d.cts +39 -15
  26. package/dist/dropdown-menu/index.d.ts +39 -15
  27. package/dist/dropdown-menu/index.js +1 -1
  28. package/dist/dropdown-menu/index.js.map +1 -1
  29. package/dist/{events-DOGItflK.d.ts → events-D6K5-_aP.d.ts} +71 -3
  30. package/dist/{events-DPsuhBln.d.cts → events-DuKEM5sQ.d.cts} +71 -3
  31. package/dist/internal/listbox/index.d.cts +4 -4
  32. package/dist/internal/listbox/index.d.ts +4 -4
  33. package/dist/internal/popup-menu/index.cjs +1 -1
  34. package/dist/internal/popup-menu/index.cjs.map +1 -1
  35. package/dist/internal/popup-menu/index.d.cts +9 -9
  36. package/dist/internal/popup-menu/index.d.ts +9 -9
  37. package/dist/internal/popup-menu/index.js +1 -1
  38. package/dist/loaders/index.d.cts +1 -1
  39. package/dist/loaders/index.d.ts +1 -1
  40. package/dist/{resolve-Dk_fAKb2.d.cts → resolve-C5shwZ1S.d.cts} +1 -1
  41. package/dist/{resolve-BYm41YfG.d.ts → resolve-DA6nHdAi.d.ts} +1 -1
  42. package/dist/{scroll-arrow-CNd0tgME.d.ts → scroll-arrow-CxHg9cFW.d.ts} +2 -2
  43. package/dist/{scroll-arrow-B81wZTZ2.d.cts → scroll-arrow-rsrV6nun.d.cts} +2 -2
  44. package/dist/select/index.cjs +1 -1
  45. package/dist/select/index.d.cts +8 -8
  46. package/dist/select/index.d.ts +8 -8
  47. package/dist/select/index.js +1 -1
  48. package/dist/{separator-De8l8DKO.d.ts → separator-DaXKN0QW.d.ts} +2 -2
  49. package/dist/{separator-BiySI623.d.cts → separator-DzfgGPjS.d.cts} +2 -2
  50. package/dist/{surface-context-ClmxshBW.d.ts → surface-context-BMizU8oI.d.ts} +1 -1
  51. package/dist/{surface-context-DF-L-30G.d.cts → surface-context-r2eYfQth.d.cts} +1 -1
  52. package/dist/{type-guards-BC2B6bVi.d.cts → type-guards-BO8iCz9M.d.cts} +5 -4
  53. package/dist/{type-guards-ybcHBB3C.d.ts → type-guards-BOg6-eFO.d.ts} +5 -4
  54. package/package.json +3 -3
  55. package/dist/chunk-65TSJ7MA.js +0 -2
  56. package/dist/chunk-65TSJ7MA.js.map +0 -1
  57. package/dist/chunk-EYMK7XHC.cjs +0 -2
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _chunkXMZZ62VJcjs = require('./chunk-XMZZ62VJ.cjs');var _react = require('react'); var Do = _interopRequireWildcard(_react); var wo = _interopRequireWildcard(_react); var _t = _interopRequireWildcard(_react); var No = _interopRequireWildcard(_react); var Jt = _interopRequireWildcard(_react); var to = _interopRequireWildcard(_react); var no = _interopRequireWildcard(_react); var xe = _interopRequireWildcard(_react); var be = _interopRequireWildcard(_react); var Lr = _interopRequireWildcard(_react); var Go = _interopRequireWildcard(_react); var Or = _interopRequireWildcard(_react); var he = _interopRequireWildcard(_react); var uo = _interopRequireWildcard(_react); var Je = _interopRequireWildcard(_react); var Ge = _interopRequireWildcard(_react); var Ao = _interopRequireWildcard(_react); var ae = _interopRequireWildcard(_react); var ce = _interopRequireWildcard(_react); var Vo = _interopRequireWildcard(_react); var Se = _interopRequireWildcard(_react); var Qt = _interopRequireWildcard(_react); var jo = _interopRequireWildcard(_react); var Qo = _interopRequireWildcard(_react); var bo = _interopRequireWildcard(_react); var ho = _interopRequireWildcard(_react); var Dt = _interopRequireWildcard(_react); var nt = _interopRequireWildcard(_react); var ze = _interopRequireWildcard(_react); var Ce = _interopRequireWildcard(_react); var _ = _interopRequireWildcard(_react); var Wo = _interopRequireWildcard(_react); var $e = _interopRequireWildcard(_react); var rt = _interopRequireWildcard(_react); var ke = _interopRequireWildcard(_react); var ue = _interopRequireWildcard(_react); var Qe = _interopRequireWildcard(_react); var en = _interopRequireWildcard(_react); var tn = _interopRequireWildcard(_react); var St = _interopRequireWildcard(_react); var Ye = _interopRequireWildcard(_react); var Ie = _interopRequireWildcard(_react); var on = _interopRequireWildcard(_react); var nn = _interopRequireWildcard(_react); var et = _interopRequireWildcard(_react); var rn = _interopRequireWildcard(_react); var sn = _interopRequireWildcard(_react); var un = _interopRequireWildcard(_react); var an = _interopRequireWildcard(_react); var cn = _interopRequireWildcard(_react); var Ae = _interopRequireWildcard(_react); var ds = _interopRequireWildcard(_react); var pn = _interopRequireWildcard(_react); var st = _interopRequireWildcard(_react); var ln = _interopRequireWildcard(_react); var fs = _interopRequireWildcard(_react); var dn = _interopRequireWildcard(_react); var ms = _interopRequireWildcard(_react); var gs = _interopRequireWildcard(_react); var le = _interopRequireWildcard(_react); var Y = _interopRequireWildcard(_react); var Rn = _interopRequireWildcard(_react); var Ps = _interopRequireWildcard(_react); var Sn = _interopRequireWildcard(_react); var Pn = _interopRequireWildcard(_react); var tt = _interopRequireWildcard(_react); var Zt = _interopRequireWildcard(_react); var Le = _interopRequireWildcard(_react); var ft = _interopRequireWildcard(_react);var Mn=Do.createContext(null);function Pe(){let e=Do.useContext(Mn);if(!e)throw new Error("FocusOwner components must be used within a FocusOwnerProvider");return e}var Cn=wo.createContext(null);function vt(){let e=wo.useContext(Cn);if(!e)throw new Error("OpenChain components must be used within an OpenChainProvider");return e}var it=_t.createContext(null);function Te(){let e=_t.useContext(it);if(!e)throw new Error("PopupMenu components must be used within a PopupMenu.Root or ContextMenu.Root");return e}function ct(){return _t.useContext(it)}var Bt=No.createContext(null);function Dr(){return No.useContext(Bt)}var Lo=Jt.createContext(null);function eo(){let e=Jt.useContext(Lo);if(!e)throw new Error("SubmenuTrigger must be used within a Submenu");return e}function Ke(){return Jt.useContext(Lo)}var Oo=to.createContext(null);function oo(){let e=to.useContext(Oo);if(!e)throw new Error("Subpage components must be used within a PopupMenu.Subpage");return e}function pt(){return to.useContext(Oo)}var ro=no.createContext(null);function kt(){let e=no.useContext(ro);if(!e)throw new Error("Subpage components must be used within a PopupMenu.Popup");return e}function so(){return no.useContext(ro)}var _store = require('@base-ui/utils/store');var vs={ownerId:_store.createSelector.call(void 0, e=>e.ownerId),isOwner:_store.createSelector.call(void 0, (e,o)=>e.ownerId===o)},ao= exports.n =class extends _store.ReactStore{constructor(){super({ownerId:null},{},vs)}setOwnerId(o){this.set("ownerId",o)}clearOwner(){this.set("ownerId",null)}};function vn(e){return typeof e=="object"&&e!==null&&"def"in e&&typeof e.id=="string"&&typeof e.definitionKey=="string"&&Array.isArray(e.definitionPath)&&Array.isArray(e.children)&&typeof e.depth=="number"&&"parent"in e}function ks(e){let o="";for(let r=0;r<e.length;r+=1){let t=e.charCodeAt(r),s=t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===46||t===95||t===126||t===45;o+=s?String.fromCharCode(t):`%${t.toString(16).padStart(4,"0")}`}return o}function kn(e,o="surface"){return o==="menu"?e.definitionKey:e.definitionPath.map(ks).join("/")}function In(e){switch(e.kind){case"group":case"radio-group":return e.id;case"separator":return e.id;default:return _nullishCoalesce(e.id, () => (_chunkXMZZ62VJcjs.s.call(void 0, e.value)))}}function Dn(e){switch(e.kind){case"group":case"radio-group":return e.nodes;case"submenu":case"subpage":case"tree-item":return _nullishCoalesce(e.nodes, () => ([]));default:return[]}}function Ht(e){return e.kind==="submenu"||e.kind==="subpage"}function wn(e,o,r,t){return e.map((s,n)=>{let c=In(s),p=[...r,c],f={def:s,kind:s.kind,definitionKey:c,definitionPath:p,parent:o,children:[],depth:o?o.depth+1:0,index:n},d=t(f),a={...f,id:d};return a.children=wn(Dn(s),a,Ht(s)?a.definitionPath:r,t),a})}function lt(e){let o=e.def.nodes;if(!o||o.length===0)return[];let r=new Set(o);return e.children.filter(t=>r.has(t.def))}function Nn(e,o,r,t,s){let n=In(e),c=[...r,n],p={def:e,kind:e.kind,definitionKey:n,definitionPath:c,parent:o,children:[],depth:o?o.depth+1:0,index:t};return{definitionKey:n,definitionPath:c,id:s(p)}}function Nr(e={}){let o=_nullishCoalesce(e.idScope, () => ("surface")),r=_nullishCoalesce(e.getResolvedId, () => ((l=>kn(l,o)))),t=[],s=null,n=new Map,c=new Map,p=new WeakMap,f=new Set,d=!1,a=new WeakMap,R=!1,b=new WeakMap,P={},g=l=>{if(o==="menu")return P;let h=l.parent;for(;h;){if(Ht(h.def))return h;h=h.parent}return P},S=l=>{process.env.NODE_ENV!=="production"&&console.warn(l)},C=l=>o==="menu"?"menu":l===P?"root surface":`surface "${l.definitionPath.join("/")}"`,L=l=>{if(process.env.NODE_ENV==="production")return;l.id===""&&(R||(R=!0,S(`[PopupMenu] Empty Resolved ID for ${l.kind} definition.`)));let h=c.get(l.id);!h||h===l||f.has(l.id)||(f.add(l.id),S(`[PopupMenu] Duplicate Resolved ID "${l.id}" in menu scope; ${h.kind} and ${l.kind} definitions conflict.`))},D=(l,h=P)=>{l.definitionKey===""&&(d||(d=!0,S(`[PopupMenu] Empty Definition Key in ${l.kind} definition (${C(h)}).`)));let y=b.get(h);y||(y=new Map,b.set(h,y));let N=y.get(l.definitionKey);N||(N=new Set,y.set(l.definitionKey,N));let F=[...N].find(m=>m!==l);if(F){let m=a.get(h);m||(m=new Set,a.set(h,m)),m.has(l.definitionKey)||(m.add(l.definitionKey),S(`[PopupMenu] Duplicate Definition Key "${l.definitionKey}" in ${C(h)}; ${F.kind} and ${l.kind} definitions conflict.`))}N.add(l),n.has(l.def)||n.set(l.def,l),L(l),c.has(l.id)||c.set(l.id,l);let T=o==="surface"&&Ht(l.def)?l:h;for(let m of l.children)D(m,T)},I=l=>{let h=g(l),y=b.get(h),N=_optionalChain([y, 'optionalAccess', _2 => _2.get, 'call', _3 => _3(l.definitionKey)]);N&&(N.delete(l),N.size===0&&_optionalChain([y, 'optionalAccess', _4 => _4.delete, 'call', _5 => _5(l.definitionKey)]),_optionalChain([y, 'optionalAccess', _6 => _6.size])===0&&b.delete(h)),n.get(l.def)===l&&n.delete(l.def),c.get(l.id)===l&&c.delete(l.id),p.delete(l);for(let F of l.children)I(F)},v=(l,h)=>l.length===h.length&&l.every((y,N)=>y===h[N]),u=l=>Ht(l.def)?l.definitionPath:l.parent?u(l.parent):[],i=(l,h,y,N)=>{let F=new Map;for(let k of l){let A=F.get(k.id);A?A.push(k):F.set(k.id,[k])}let T=[],m=new Set;for(let[k,A]of h.entries()){let{id:M}=Nn(A,y,N,k,r),j=_optionalChain([F, 'access', _7 => _7.get, 'call', _8 => _8(M), 'optionalAccess', _9 => _9.find, 'call', _10 => _10(E=>!m.has(E)&&E.kind===A.kind)]);j?(m.add(j),T.push(j)):T.push(void 0)}let O=l.length===h.length;for(let k of l)m.has(k)||(O=!1,I(k));let G=h.map((k,A)=>{let M=T[A],{definitionKey:w,definitionPath:j,id:E}=Nn(k,y,N,A,r);if(!M){O=!1;let H=wn([k],y,N,r)[0];return H.index=A,H.id=Nn(k,y,N,A,r).id,D(H,g(H)),H}if(M.def===k&&v(M.definitionPath,j))return(l[A]!==M||M.index!==A)&&(O=!1),M.index=A,M;O=!1,n.get(M.def)===M&&n.delete(M.def);let U=g(M),$=b.get(U),re=_optionalChain([$, 'optionalAccess', _11 => _11.get, 'call', _12 => _12(M.definitionKey)]);return re&&(re.delete(M),re.size===0&&_optionalChain([$, 'optionalAccess', _13 => _13.delete, 'call', _14 => _14(M.definitionKey)]),_optionalChain([$, 'optionalAccess', _15 => _15.size])===0&&b.delete(U)),M.def=k,M.definitionKey=w,M.definitionPath=j,M.index=A,M.id!==E&&(c.get(M.id)===M&&c.delete(M.id),M.id=E,L(M),c.has(E)||c.set(E,M)),n.has(k)||n.set(k,M),p.delete(M),M.children=i(M.children,Dn(k),M,Ht(k)?M.definitionPath:N),D(M,g(M)),M});return O?l:G};return{getResolvedId:r,idScope:o,get rootNodes(){return t},setContent(l){l!==s&&(t=i(t,l,null,[]),s=l)},graft(l,h){h!==p.get(l)&&(l.children=i(l.children,h,l,u(l)),p.set(l,h))},getNodeForDef(l){return n.get(l)},getNodeById(l){return c.get(l)}}}var Ds={isOpen:_store.createSelector.call(void 0, (e,o)=>e.chain.includes(o)),isLast:_store.createSelector.call(void 0, (e,o)=>e.chain.length>0&&e.chain[e.chain.length-1]===o),hasOpenSubmenu:_store.createSelector.call(void 0, (e,o)=>e.chain.length>o)},To=class extends _store.ReactStore{constructor(){super({chain:[]},{},Ds)}open(o){if(this.state.chain.includes(o))return;let r=[...this.state.chain,o];this.set("chain",r)}close(o){let r=this.state.chain.filter(t=>t!==o);this.set("chain",r)}clear(){this.set("chain",[])}};function ws(e={}){let{onOpenChange:o,defaultOpen:r=!1,virtualized:t=!1,items:s,onHighlightChange:n,closeOnOutsidePress:c="pointerdown",disabled:p=!1,defaultDisabled:f=!1,getResolvedId:d,idScope:a="surface"}=e,R=xe.useRef(null);R.current===null&&(R.current=Nr({getResolvedId:d,idScope:a}));let b=R.current,P=xe.useCallback((k,A,M)=>{_optionalChain([n, 'optionalCall', _16 => _16(k,k===null?null:_nullishCoalesce(b.getNodeById(k), () => (null)),A,M)])},[b,n]),[g,S]=xe.useState(f),C=p||g,L=xe.useCallback(k=>{S(k)},[]);xe.useEffect(()=>{_chunkXMZZ62VJcjs.c.call(void 0, )},[]);let D=xe.useRef(null),I=xe.useCallback((k,A)=>{if(!k&&A.reason===_chunkXMZZ62VJcjs.a.focusOut&&D.current){let M=D.current;D.current=null;let w=_chunkXMZZ62VJcjs.b.call(void 0, _chunkXMZZ62VJcjs.a.outsidePress,M);_optionalChain([o, 'optionalCall', _17 => _17(k,w)]),w.isCanceled&&A.cancel();return}D.current=null,_optionalChain([o, 'optionalCall', _18 => _18(k,A)])},[o]),v=_chunkXMZZ62VJcjs.y.useStore(void 0,{open:r},{onOpenChange:I}),u=v.useState("open"),i=xe.useRef(null);i.current||(i.current=new ao);let l=i.current,h=xe.useRef(null);h.current||(h.current=new To);let y=h.current,N=xe.useRef(new Map),F=xe.useCallback((k,A)=>{let M=Math.random().toString(36).slice(2);return N.current.set(M,{depth:k,setOpen:A}),()=>{N.current.delete(M)}},[]),T=xe.useCallback((k=_chunkXMZZ62VJcjs.a.itemPress,A)=>{let M=[...N.current.values()].sort((w,j)=>j.depth-w.depth);for(let w of M)w.setOpen(!1);v.setOpen(!1,k,A),l.clearOwner(),y.clear()},[v,l,y]),m=xe.useRef(T);m.current=T,xe.useEffect(()=>{if(!u||C){D.current=null;return}let k=A=>{let M=A.target;if(!M)return;let w=M.closest("[data-open]")!==null,j=M.closest("[data-popup-open]")!==null;c==="pointerdown"&&!(w||j)?m.current(_chunkXMZZ62VJcjs.a.outsidePress,A):D.current=A};return document.addEventListener("pointerdown",k,!0),()=>{document.removeEventListener("pointerdown",k,!0),D.current=null}},[u,c,C]);let O=xe.useCallback((k,A=_chunkXMZZ62VJcjs.a.none,M)=>{let w=A===_chunkXMZZ62VJcjs.a.imperativeAction;C&&!w||(v.setOpen(k,A,M),k||(l.clearOwner(),y.clear()))},[v,l,y,C]),G=xe.useMemo(()=>{if(!(!t&&!n))return{virtualized:t,items:_nullishCoalesce(s, () => ([])),onHighlightChange:P}},[t,s,P,n]);return{menuTreeResolver:b,store:v,focusOwnerStore:l,openChainStore:y,registerSurface:F,closeAll:T,virtualization:G,handleOpenChange:O,disabled:C,setDisabled:L}}var Ns=140;function On(e){let{surfaceId:o,store:r}=e,[t,s]=be.useState([]),n=be.useRef(t);be.useEffect(()=>{n.current=t},[t]);let c=be.useRef(new Map),p=be.useRef(new Set),f=be.useRef(new Map),[,d]=be.useState(0),[a,R]=be.useState(!1),b=be.useRef(null),P=be.useCallback(()=>{b.current!==null&&(clearTimeout(b.current),b.current=null)},[]),g=be.useCallback(()=>{R(!0),P(),b.current=setTimeout(()=>{b.current=null,R(!1)},Ns)},[P]);be.useEffect(()=>P,[P]);let S=be.useCallback(m=>{let O={surfaceId:m.surfaceId,closeRootOnEsc:m.closeRootOnEsc},G=f.current.get(m.pageId);return G?(process.env.NODE_ENV!=="production"&&!p.current.has(m.pageId)&&(p.current.add(m.pageId),console.warn(`PopupMenu: page ID "${m.pageId}" is registered more than once in this popup. The first registration wins. Give each Subpage a unique pageId; data-first subpages use the node's Resolved ID.`)),G.push(O)):(f.current.set(m.pageId,[O]),c.current.set(m.pageId,O),d(k=>k+1)),()=>{let k=f.current.get(m.pageId);if(!k)return;let A=k.indexOf(O);if(A===-1)return;let M=A===0;if(k.splice(A,1),!M)return;let w=k[0];if(w){c.current.set(m.pageId,w),d(j=>j+1);return}f.current.delete(m.pageId),c.current.delete(m.pageId),d(j=>j+1),s(j=>j.includes(m.pageId)?j.filter(U=>U!==m.pageId):j)}},[]),C=be.useCallback(m=>{if(!c.current.has(m))return!1;let O=n.current;return O[O.length-1]===m?!1:(s(k=>[...k,m]),g(),!0)},[g]),L=be.useCallback(()=>n.current.length===0?!1:(s(O=>O.slice(0,-1)),g(),!0),[g]),D=be.useCallback(m=>_nullishCoalesce(_optionalChain([c, 'access', _19 => _19.current, 'access', _20 => _20.get, 'call', _21 => _21(m), 'optionalAccess', _22 => _22.surfaceId]), () => (null)),[]),I=be.useCallback(()=>{s([]),R(!1),P()},[P]);be.useEffect(()=>{if(!r)return;let m=r.context.onPopupCloseComplete,O=()=>{_optionalChain([m, 'optionalCall', _23 => _23()]),I()};return r.context.onPopupCloseComplete=O,()=>{r.context.onPopupCloseComplete===O&&(r.context.onPopupCloseComplete=m),P()}},[r,I,P]);let v=_nullishCoalesce(t[t.length-1], () => (null)),u=v===null?void 0:c.current.get(v),i=v===null?o:_nullishCoalesce(_optionalChain([u, 'optionalAccess', _24 => _24.surfaceId]), () => (o)),l=v===null?!0:_nullishCoalesce(_optionalChain([u, 'optionalAccess', _25 => _25.closeRootOnEsc]), () => (!0)),h=t.length>0,y=t,N=_nullishCoalesce(y[y.length-1], () => (null)),F=N!==null;return{subpageStackContextValue:be.useMemo(()=>({activePageId:v,rootSurfaceId:o,activeSurfaceId:i,canGoBack:h,shouldCloseRootOnEsc:l,stack:t,registerPage:S,openPage:C,goBack:L,getSurfaceId:D}),[v,o,i,h,l,t,S,C,L,D]),isSubpageNavigating:a,hasOpenSubpage:F,subpageId:N,openSubpageIds:y}}var _popover = require('@base-ui/react/popover');var Tn=Go.createContext(null);function q(){return Go.useContext(Tn)}function W(e,o){if(e)return`bazzaui-${e}-${o}`}var _jsxruntime = require('react/jsx-runtime');var Os=Lr.forwardRef(function(o,r){let t=q(),s=W(t,"arrow");return _jsxruntime.jsx.call(void 0, _popover.Popover.Arrow,{ref:r,...s?{[s]:""}:{},...o})});var Es=Or.forwardRef(function(o,r){let{showOn:t,...s}=o,n=Ke(),c=vt(),p=Pe(),f=n!==null,d=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _26 => _26.childSurfaceId]), () => ("")),a=_nullishCoalesce(t, () => ((f?"focus":"open"))),R=c.useState("isOpen",d),b=c.useState("isLast",d),P=p.useState("isOwner",d),g=!0;f&&(a==="open"?g=R:b?g=P:g=R);let S=q(),C=W(S,"backdrop");if(!g)return null;let L={pointerEvents:"none",...s.style};return _jsxruntime.jsx.call(void 0, _popover.Popover.Backdrop,{ref:r,...C?{[C]:""}:{},...s,style:L})});var Gn=(b=>(b.slot="bazzaui-[component]-popup",b.open="data-open",b.closed="data-closed",b.side="data-side",b.align="data-align",b.startingStyle="data-starting-style",b.endingStyle="data-ending-style",b.instant="data-instant",b.focused="data-focused",b.hasOpenSubmenu="data-has-open-submenu",b.submenu="data-submenu",b.navigating="data-navigating",b))(Gn||{});var Tr=uo.createContext(null);function zi(){let e=uo.useContext(Tr);if(!e)throw new Error("Combobox components must be used within a Combobox.Root");return e}function jt(){return uo.useContext(Tr)}var io=Je.createContext(null),co= exports.z =Je.createContext(null);function En(){let e=Je.useContext(io);if(!e)throw new Error("useDataSurfaceContext must be used within a DataSurface component");return e}function An(){return Je.useContext(io)}function Eo(){let e=Je.useContext(co);if(!e)throw new Error("Data components must be used within PopupMenu.Popup");return e}function Gr(){return Je.useContext(co)}var po=Je.createContext(null);function Fs(){let e=Je.useContext(po);if(!e)throw new Error("useDataList must be used within a List component");return e}function Vs(){return Je.useContext(po)}var lo=Ao.createContext(null);function Er(){return Ao.useContext(lo)}var Fn=ae.createContext(null);function It(){return ae.useContext(Fn)}function fo(){return ae.useContext(Fn)}function Ar(e){let{children:o,searchQuery:r}=e,[t,s]=ae.useState(()=>new Map),[n,c]=ae.useState(null),[p,f]=ae.useState(()=>new Map),[d,a]=ae.useState(null),R=ae.useCallback(w=>{c(w)},[]),b=ae.useCallback(()=>{c(null),a(null)},[]),P=ae.useCallback(w=>{c(j=>j&&{...j,result:w}),w.isError&&w.error?a(w.error):w.isError||a(null)},[]),g=ae.useCallback(w=>{s(j=>{let E=new Map(j);return E.set(w.id,w),E})},[]),S=ae.useCallback(w=>{s(j=>{let E=new Map(j);return E.delete(w),E}),f(j=>{let E=new Map(j);return E.delete(w),E})},[]),C=ae.useCallback((w,j)=>{s(E=>{let U=E.get(w);if(!U)return E;let $=new Map(E);return $.set(w,{...U,result:j}),$}),j.isError&&j.error?f(E=>{let U=new Map(E);return U.set(w,j.error),U}):j.isError||f(E=>{if(!E.has(w))return E;let U=new Map(E);return U.delete(w),U})},[]),L=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _27 => _27.config, 'access', _28 => _28.type])==="static"&&n.result.isFetching)return!0;for(let[,w]of t)if(w.config.type==="static"&&w.result.isFetching)return!0;return!1},[t,n]),D=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _29 => _29.config, 'access', _30 => _30.type])==="static"&&n.result.isLoading)return!0;for(let[,w]of t)if(w.config.type==="static"&&w.result.isLoading)return!0;return!1},[t,n]),I=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _31 => _31.config, 'access', _32 => _32.type])==="static"&&n.result.isInitialLoading)return!0;for(let[,w]of t)if(w.config.type==="static"&&w.result.isInitialLoading)return!0;return!1},[t,n]),v=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _33 => _33.config, 'access', _34 => _34.type])==="static"&&n.result.isRefetching)return!0;for(let[,w]of t)if(w.config.type==="static"&&w.result.isRefetching)return!0;return!1},[t,n]),u=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _35 => _35.config, 'access', _36 => _36.type])==="query"&&n.result.isFetching)return!0;for(let[,w]of t)if(w.config.type==="query"&&w.result.isFetching)return!0;return!1},[t,n]),i=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _37 => _37.config, 'access', _38 => _38.type])==="query"&&n.result.isLoading)return!0;for(let[,w]of t)if(w.config.type==="query"&&w.result.isLoading)return!0;return!1},[t,n]),l=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _39 => _39.config, 'access', _40 => _40.type])==="query"&&n.result.isInitialLoading)return!0;for(let[,w]of t)if(w.config.type==="query"&&w.result.isInitialLoading)return!0;return!1},[t,n]),h=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _41 => _41.config, 'access', _42 => _42.type])==="query"&&n.result.isRefetching)return!0;for(let[,w]of t)if(w.config.type==="query"&&w.result.isRefetching)return!0;return!1},[t,n]),y=(_nullishCoalesce(_optionalChain([n, 'optionalAccess', _43 => _43.result, 'access', _44 => _44.isFetching]), () => (!1)))||L||u,N=(_nullishCoalesce(_optionalChain([n, 'optionalAccess', _45 => _45.result, 'access', _46 => _46.isLoading]), () => (!1)))||D||i,F=(_nullishCoalesce(_optionalChain([n, 'optionalAccess', _47 => _47.result, 'access', _48 => _48.isInitialLoading]), () => (!1)))||I||l,T=(_nullishCoalesce(_optionalChain([n, 'optionalAccess', _49 => _49.result, 'access', _50 => _50.isRefetching]), () => (!1)))||v||h,m=ae.useMemo(()=>{if(t.size===0&&!n)return!1;for(let[,w]of t)if(!w.result.isRefetching)return!1;return n?n.result.isRefetching:!0},[t,n]),O=ae.useMemo(()=>_nullishCoalesce(_optionalChain([n, 'optionalAccess', _51 => _51.result, 'access', _52 => _52.isLoading]), () => (!1)),[n]),G=ae.useMemo(()=>{if(_optionalChain([n, 'optionalAccess', _53 => _53.result, 'access', _54 => _54.isFetching]))return!1;for(let[,w]of t)if(w.result.isFetching)return!1;return!0},[t,n]),k=ae.useCallback(()=>{let w=[];_optionalChain([n, 'optionalAccess', _55 => _55.result, 'access', _56 => _56.data])&&!d&&w.push({kind:"root",nodes:n.result.data});for(let[j,E]of t)p.has(j)||E.result.data&&w.push({kind:"branch",id:j,nodes:E.result.data});return w},[t,p,n,d]),A=ae.useCallback(()=>{let w=[];d&&w.push({kind:"root",reason:"error"});for(let[j]of p)w.push({kind:"branch",id:j,reason:"error"});return{isLoading:N,isFetching:y,isInitialLoading:F,isRefetching:T,isAllRefetching:m,isStaticLoading:D,isStaticInitialLoading:I,isStaticRefetching:v,isQueryLoading:i,isQueryInitialLoading:l,isQueryRefetching:h,skippedMenus:w}},[y,N,F,T,m,D,I,v,i,l,h,p,d]),M=ae.useMemo(()=>({registerLoader:g,unregisterLoader:S,updateLoaderResult:C,registerRootLoader:R,unregisterRootLoader:b,updateRootLoaderResult:P,searchQuery:r,loaders:t,root:n,isAnyLoading:N,isAnyFetching:y,isAnyInitialLoading:F,isAnyRefetching:T,isAllRefetching:m,isRootLoading:O,isStaticLoading:D,isStaticFetching:L,isStaticInitialLoading:I,isStaticRefetching:v,isQueryLoading:i,isQueryFetching:u,isQueryInitialLoading:l,isQueryRefetching:h,allResolved:G,getAsyncNodes:k,erroredLoaders:p,rootError:d,getAsyncState:A}),[g,S,C,R,b,P,r,t,n,N,y,F,T,m,O,D,L,I,v,i,u,l,h,G,k,p,d,A]);return _jsxruntime.jsx.call(void 0, Fn.Provider,{value:M,children:o})}function Fr(e){return e.kind==="link-item"}function Vr(e){return e.kind==="tree-item"}function ge(e,o){return e.def.kind===o}function qe(e){let o=e.def.kind;return o==="item"||o==="link-item"||o==="radio-item"||o==="checkbox-item"||o==="submenu"||o==="subpage"||o==="tree-item"}function Hs(e){return e.initialQueryBehavior!==void 0?e.initialQueryBehavior===!1?!1:{value:_nullishCoalesce(e.initialQueryBehavior.value, () => ("")),loadWhen:_nullishCoalesce(e.initialQueryBehavior.loadWhen, () => ("needed"))}:e.initialQuery!==void 0?{value:e.initialQuery,loadWhen:"needed"}:{value:"",loadWhen:"needed"}}function js(e,o){let r=_nullishCoalesce(e.minQueryLength, () => (1)),t=Hs(e);return o.length>=r?{effectiveQuery:o,enabled:!0,isBelowMinLength:!1}:t!==!1?{effectiveQuery:t.value,enabled:!0,isBelowMinLength:!1}:{effectiveQuery:"",enabled:!1,isBelowMinLength:!0}}function Vn(e,o,r){let t=e.def;if(!t.asyncNodes||!r)return;let s=r.loaders.get(e.id);if(!s)return;let n=t.asyncNodes.type==="query"?js(t.asyncNodes,o).isBelowMinLength:!1;return{status:s.result.status,fetchStatus:s.result.fetchStatus,loadingPhase:s.result.loadingPhase,isLoading:s.result.isLoading,isFetching:s.result.isFetching,isInitialLoading:s.result.isInitialLoading,isRefetching:s.result.isRefetching,isError:s.result.isError,error:s.result.error,isBelowMinLength:n}}function Fo(e,o=[],r=null){let t=[];for(let s of e){let n=s.def;if(n.kind!=="separator"){if(n.kind==="group"){t.push(...Fo(s.children,o,{id:n.id,label:n.label}));continue}if(n.kind==="radio-group"){if(n.hidden)continue;t.push(...Fo(s.children,o,null));continue}if(!n.hidden&&(n.kind==="submenu"||n.kind==="subpage")&&(n.kind==="subpage"&&t.push({node:s,pageId:s.id,context:{search:null,breadcrumbs:o,isDeepSearchResult:!1,highlighted:!1,disabled:_nullishCoalesce(n.disabled, () => (!1)),group:r,tree:null}}),s.children.length)){let c={node:n,menuNode:s,value:n.value,id:n.id};t.push(...Fo(s.children,[...o,c],null))}}}return t}function Br(e){let{children:o}=e,r=It(),t=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _57 => _57.searchQuery]), () => ("")),{dataSurfaceContext:s,resolvedNodes:n}=Eo(),c=n&&(!s||n.content===s.content)?n:null,p=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _58 => _58.nodes]), () => ([])),f=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _59 => _59.graftVersion]), () => (0)),d=Ge.useMemo(()=>Fo(p),[p,f]),a=Ge.useCallback(b=>{let{node:P,context:g,pageId:S}=b,C=P.def,L={node:C,menuNode:P,value:C.value,id:C.id},D=(v,u)=>{let i=v.def,l=v.id;if(i.kind==="item")return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:i.render({node:v,props:{id:l,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1)),closeOnClick:i.closeOnClick,onSelect:i.onSelect,shortcut:i.shortcut},context:{...u,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1))}})},l);if(i.kind==="link-item")return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:i.render({node:v,props:{id:l,value:i.value,href:i.href,disabled:_nullishCoalesce(i.disabled, () => (!1)),closeOnClick:i.closeOnClick,onSelect:i.onSelect,shortcut:i.shortcut,forceOrder:i.forceOrder,forceScore:i.forceScore},context:{...u,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1))}})},l);if(i.kind==="checkbox-item")return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:i.render({node:v,props:{id:l,value:i.value,checked:i.checked,onCheckedChange:i.onCheckedChange,disabled:_nullishCoalesce(i.disabled, () => (!1)),closeOnClick:i.closeOnClick},context:{...u,value:i.value,checked:i.checked,disabled:_nullishCoalesce(i.disabled, () => (!1))}})},l);if(i.kind==="radio-item")return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:i.render({node:v,props:{id:l,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1)),closeOnClick:i.closeOnClick,onSelect:i.onSelect,shortcut:i.shortcut},context:{...u,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1))}})},l);if(i.kind==="submenu"){let N=Vn(v,t,r),F=lt(v),T={node:i,menuNode:v,value:i.value,id:i.id},m=O=>{let G=O.def;if(G.kind==="separator")return null;if(G.kind==="group"){let k=O.children.filter(M=>(M.def.kind==="item"||M.def.kind==="link-item"||M.def.kind==="checkbox-item"||M.def.kind==="submenu"||M.def.kind==="subpage")&&!M.def.hidden);if(k.length===0)return null;let A=k.map(M=>D(M,{search:null,breadcrumbs:[...u.breadcrumbs,T],isDeepSearchResult:!1,highlighted:!1,disabled:_nullishCoalesce(M.def.disabled, () => (!1)),group:{id:G.id,label:G.label},tree:null}));if(G.render){let M={search:null,matchCount:k.length,breadcrumbs:[...u.breadcrumbs,T],isDeepSearchResult:!1},w=O;return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:G.render({node:w,props:{},context:{...M,label:G.label},children:_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:A})})},G.id)}return _jsxruntime.jsx.call(void 0, "div",{role:"group","aria-label":G.label,children:A},G.id)}return G.kind==="radio-group"?I(O,[...u.breadcrumbs,T]):G.kind!=="item"&&G.kind!=="link-item"&&G.kind!=="checkbox-item"&&G.kind!=="submenu"&&G.kind!=="subpage"?null:D(O,{search:null,breadcrumbs:[...u.breadcrumbs,T],isDeepSearchResult:!1,highlighted:!1,disabled:_nullishCoalesce(G.disabled, () => (!1)),group:null,tree:null})};return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:i.render({node:v,props:{id:l,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1))},context:{...u,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1)),async:N},nodes:F,asyncContent:i.asyncNodes,renderNode:m})},l)}if(i.kind!=="subpage")return null;let h=Vn(v,t,r),y=v.id;return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:i.renderTrigger({node:v,props:{id:l,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1)),targetPageId:y},context:{...u,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1)),async:h}})},y)},I=(v,u=[])=>{let i=v.def,l=u.length>0,h={search:null,matchCount:i.nodes.length,breadcrumbs:u,isDeepSearchResult:l},y=v.children.map(N=>!qe(N)||N.def.hidden?null:D(N,{search:null,breadcrumbs:u,isDeepSearchResult:l,highlighted:!1,disabled:_nullishCoalesce(N.def.disabled, () => (!1)),group:null,tree:null}));return i.render?_jsxruntime.jsx.call(void 0, Ge.Fragment,{children:i.render({node:v,props:{value:i.value,onValueChange:i.onValueChange,disabled:_nullishCoalesce(i.disabled, () => (!1))},context:{...h,label:i.label,value:i.value,disabled:_nullishCoalesce(i.disabled, () => (!1))},children:_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:y})})},i.id):_jsxruntime.jsx.call(void 0, "div",{role:"radiogroup","aria-label":i.label,children:y},i.id)};return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:_jsxruntime.jsx.call(void 0, lo.Provider,{value:P,children:C.renderContent({node:P,pageId:S,context:{...g,value:C.value,disabled:_nullishCoalesce(C.disabled, () => (!1)),async:Vn(P,t,r)},nodes:lt(P),asyncContent:C.asyncNodes,renderNode:v=>{let u=v.def;if(u.kind==="separator")return null;if(u.kind==="group"){let i=v.children.filter(h=>(h.def.kind==="item"||h.def.kind==="link-item"||h.def.kind==="checkbox-item"||h.def.kind==="submenu"||h.def.kind==="subpage")&&!h.def.hidden);if(i.length===0)return null;let l=i.map(h=>D(h,{search:null,breadcrumbs:[...g.breadcrumbs,L],isDeepSearchResult:!1,highlighted:!1,disabled:_nullishCoalesce(h.def.disabled, () => (!1)),group:{id:u.id,label:u.label},tree:null}));if(u.render){let h={search:null,matchCount:i.length,breadcrumbs:[...g.breadcrumbs,L],isDeepSearchResult:!1},y=v;return _jsxruntime.jsx.call(void 0, Ge.Fragment,{children:u.render({node:y,props:{},context:{...h,label:u.label},children:_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:l})})},u.id)}return _jsxruntime.jsx.call(void 0, "div",{role:"group","aria-label":u.label,children:l},u.id)}return u.kind==="radio-group"?I(v,[...g.breadcrumbs,L]):u.kind!=="item"&&u.kind!=="link-item"&&u.kind!=="checkbox-item"&&u.kind!=="submenu"&&u.kind!=="subpage"?null:D(v,{search:null,breadcrumbs:[...g.breadcrumbs,L],isDeepSearchResult:!1,highlighted:!1,disabled:_nullishCoalesce(u.disabled, () => (!1)),group:null,tree:null})}})})},S)},[r,t]);if(!s)return null;let R={subpages:d,renderSubpageContent:a};return o?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o(R)}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:d.map(a)})}function Hr(e,o,r){return Math.min(r,Math.max(o,e))}function go(e,o){return typeof e!="number"||Number.isNaN(e)?o:e}var jr={enabled:!1,idleColor:"#0088ff",successColor:"#00aa66",missColor:"#ff3b30",triangleFillOpacity:.2,overlayOpacity:1,showStroke:!0,strokeWidth:1.5,strokeDasharray:"6 4",showDots:!0,dotRadius:4,freezeOnPointerLeave:!0,persistOnSuccess:!0,showMissState:!1,missFreezeDuration:220};function zr(e,o){let r=jr;if(typeof e=="boolean")return{...r,enabled:e};if(!e)return{...r,enabled:!!o};let t=Hr(go(e.triangleFillOpacity,r.triangleFillOpacity),0,1),s=Hr(go(e.overlayOpacity,r.overlayOpacity),0,1),n=Math.max(0,go(e.strokeWidth,r.strokeWidth)),c=Math.max(0,go(e.dotRadius,r.dotRadius)),p=Math.max(0,go(e.missFreezeDuration,r.missFreezeDuration));return{...r,...e,enabled:_nullishCoalesce(e.enabled, () => (!0)),idleColor:_nullishCoalesce(e.idleColor, () => (r.idleColor)),successColor:_nullishCoalesce(e.successColor, () => (r.successColor)),missColor:_nullishCoalesce(e.missColor, () => (r.missColor)),triangleFillOpacity:t,overlayOpacity:s,showStroke:_nullishCoalesce(e.showStroke, () => (r.showStroke)),strokeWidth:n,strokeDasharray:_nullishCoalesce(e.strokeDasharray, () => (r.strokeDasharray)),showDots:_nullishCoalesce(e.showDots, () => (r.showDots)),dotRadius:c,freezeOnPointerLeave:_nullishCoalesce(e.freezeOnPointerLeave, () => (r.freezeOnPointerLeave)),persistOnSuccess:_nullishCoalesce(e.persistOnSuccess, () => (r.persistOnSuccess)),showMissState:_nullishCoalesce(e.showMissState, () => (r.showMissState)),missFreezeDuration:p}}var zs={showSafeTriangleArea:jr,logAimGuardEvents:!1},Bn=Vo.createContext(zs);function Bo(){return Vo.useContext(Bn)}var Qr=ce.createContext({aimGuardActive:!1,guardedTriggerId:null,guardedDepth:null,guardedSubmenuSurfaceId:null,activateAimGuard:()=>{},clearAimGuard:()=>{},aimGuardActiveRef:{current:!1},guardedTriggerIdRef:{current:null},guardedDepthRef:{current:null},guardedSubmenuSurfaceIdRef:{current:null},isGuardBlocking:()=>!1}),zt=()=>ce.useContext(Qr);function Kr({children:e}){let{logAimGuardEvents:o}=Bo(),[r,t]=ce.useState(!1),[s,n]=ce.useState(null),[c,p]=ce.useState(null),[f,d]=ce.useState(null),a=ce.useRef(!1),R=ce.useRef(null),b=ce.useRef(null),P=ce.useRef(null);ce.useEffect(()=>{a.current=r},[r]),ce.useEffect(()=>{R.current=s},[s]),ce.useEffect(()=>{b.current=c},[c]),ce.useEffect(()=>{P.current=f},[f]);let g=ce.useRef(null),S=ce.useCallback((u,i)=>{!o||typeof window>"u"||console.log(`[PopupMenu][AimGuardProvider] ${u}`,{aimGuardActive:a.current,guardedTriggerId:R.current,guardedDepth:b.current,guardedSubmenuSurfaceId:P.current,...i})},[o]),C=ce.useCallback(()=>{a.current=!1,R.current=null,b.current=null,P.current=null,t(!1),n(null),p(null),d(null)},[]),L=ce.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null),S("clear"),C()},[C,S]),D=ce.useCallback((u,i,l,h=450)=>{S("activate",{triggerId:u,depth:i,submenuSurfaceId:l,timeoutMs:h}),a.current=!0,R.current=u,b.current=i,P.current=l,n(u),p(i),d(l),t(!0),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S("timeout-expired",{triggerId:u,depth:i,submenuSurfaceId:l}),C(),g.current=null},h)},[C,S]);ce.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null),S("provider-unmount-clear")},[S]);let I=ce.useCallback(u=>a.current&&R.current!==u,[]),v=ce.useMemo(()=>({aimGuardActive:r,guardedTriggerId:s,guardedDepth:c,guardedSubmenuSurfaceId:f,activateAimGuard:D,clearAimGuard:L,aimGuardActiveRef:a,guardedTriggerIdRef:R,guardedDepthRef:b,guardedSubmenuSurfaceIdRef:P,isGuardBlocking:I}),[r,s,c,f,D,L,I]);return _jsxruntime.jsx.call(void 0, Qr.Provider,{value:v,children:e})}var qs=he.forwardRef(function(o,r){let{children:t,className:s,render:n,...c}=o,p=Ke(),{clearAimGuard:f,aimGuardActiveRef:d,guardedSubmenuSurfaceIdRef:a}=zt(),R=Pe(),b=vt(),P=ct(),g=_nullishCoalesce(_optionalChain([P, 'optionalAccess', _60 => _60.depth]), () => (0)),S=jt(),C=he.useId(),L=_nullishCoalesce(_optionalChain([p, 'optionalAccess', _61 => _61.childSurfaceId]), () => (C)),{subpageStackContextValue:D,isSubpageNavigating:I,hasOpenSubpage:v,subpageId:u,openSubpageIds:i}=On({surfaceId:L,store:_nullishCoalesce(_optionalChain([P, 'optionalAccess', _62 => _62.store]), () => (null))}),[l,h]=he.useState(null),[y,N]=he.useState(null),F=D.activeSurfaceId,T=he.useRef(0);he.useEffect(()=>{_optionalChain([p, 'optionalAccess', _63 => _63.open])&&(T.current=Date.now())},[_optionalChain([p, 'optionalAccess', _64 => _64.open])]);let m=R.useState("isOwner",F),O=b.useState("hasOpenSubmenu",g),G=he.useRef(null),k=he.useCallback(x=>{G.current=x,typeof r=="function"?r(x):r&&(r.current=x),_optionalChain([p, 'optionalAccess', _65 => _65.contentRef])&&(p.contentRef.current=x)},[r,p]);he.useEffect(()=>{g===0&&_optionalChain([P, 'optionalAccess', _66 => _66.store, 'access', _67 => _67.setPopupRef, 'call', _68 => _68(G)])},[g,P]);let A=he.useCallback(()=>{p&&d.current&&a.current===L&&f()},[p,d,a,L,f]);he.useEffect(()=>{_optionalChain([p, 'optionalAccess', _69 => _69.open])!==!1||!d.current||a.current!==L||f()},[_optionalChain([p, 'optionalAccess', _70 => _70.open]),d,a,L,f]),he.useEffect(()=>()=>{d.current&&a.current===L&&f()},[d,a,L,f]);let M=he.useCallback(x=>{if(Date.now()-T.current<100||!p)return;let V=x.target;if(!_optionalChain([G, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.contains, 'call', _73 => _73(V)]))return;let X=V instanceof Element?V:V.parentElement;if(X){let te=X.closest("[data-base-ui-focusable]");if(te&&te!==G.current)return}R.state.ownerId!==p.childSurfaceId&&R.setOwnerId(p.childSurfaceId)},[p,R]),w=p||S?!1:void 0,j=p||S?!1:void 0,E=_optionalChain([S, 'optionalAccess', _74 => _74.layout])==="input-embedded",U=!!p,$=he.useCallback(x=>({...x,isSubmenu:U,hasOpenSubpage:v,subpageId:u,openSubpageIds:i}),[v,U,i,u]),re=he.useMemo(()=>typeof s=="function"?x=>s($(x)):s,[s,$]),H=he.useMemo(()=>typeof n=="function"?(x,K)=>n(x,$(K)):n,[n,$]),ne=q(),Q=W(ne,"popup"),B=he.useMemo(()=>({dataSurfaceContext:l,setDataSurfaceContext:h,resolvedNodes:y,setResolvedNodes:N}),[l,y]);return _jsxruntime.jsx.call(void 0, Bt.Provider,{value:L,children:_jsxruntime.jsx.call(void 0, ro.Provider,{value:D,children:_jsxruntime.jsx.call(void 0, co.Provider,{value:B,children:_jsxruntime.jsxs.call(void 0, _popover.Popover.Popup,{ref:k,initialFocus:w,finalFocus:j,className:re,render:H,"data-input-embedded":E?"":void 0,...Q?{[Q]:""}:{},"data-focused":m?"":void 0,"data-has-open-submenu":O?"":void 0,"data-submenu":U?"":void 0,"data-navigating":I?"":void 0,onPointerMove:x=>{A(),M(x),_optionalChain([c, 'access', _75 => _75.onPointerMove, 'optionalCall', _76 => _76(x)])},...c,children:[t,_jsxruntime.jsx.call(void 0, Br,{})]})})})})});var Zs=_popover.Popover.Portal;var qr=(p=>(p.availableWidth="--available-width",p.availableHeight="--available-height",p.anchorWidth="--anchor-width",p.anchorHeight="--anchor-height",p.transformOrigin="--transform-origin",p.positionerWidth="--positioner-width",p.positionerHeight="--positioner-height",p))(qr||{});var _reactdom = require('react-dom');var Wr=.5;function Xs(e){if(Ur(e))return{side:"shift",align:"shift"}}function Ur(e){return e==="left"||e==="right"||e==="inline-start"||e==="inline-end"}var _s=Se.forwardRef(function(o,r){let{side:t,align:s,alignOffset:n,collisionAvoidance:c,virtualAnchor:p,style:f,...d}=o,{store:a,depth:R,virtualAnchor:b,menuType:P}=Te(),g=Ke(),S=Se.useRef(0),C=Se.useRef(!1),[,L]=Se.useReducer(Q=>Q+1,0),D=Se.useRef(!1),I=Se.useRef({first:null,second:null}),v=Se.useCallback(()=>{if(typeof window>"u"){I.current.first=null,I.current.second=null;return}I.current.first!==null&&(window.cancelAnimationFrame(I.current.first),I.current.first=null),I.current.second!==null&&(window.cancelAnimationFrame(I.current.second),I.current.second=null)},[]),u=Se.useCallback(()=>{v(),D.current=!1},[v]),i=Se.useCallback(()=>{v(),D.current=!0,!(typeof window>"u")&&(I.current.first=window.requestAnimationFrame(()=>{I.current.first=null,I.current.second=window.requestAnimationFrame(()=>{I.current.second=null,D.current=!1})}))},[v]),l=R>0,h=l?p:_nullishCoalesce(p, () => (b)),N=_nullishCoalesce(t, () => ((l?"right":"bottom"))),T=_nullishCoalesce(s, () => ((l||P==="context"?"start":"center"))),m=T==="list-start"&&Ur(N),O=T==="list-start"?"start":T,G=_nullishCoalesce(_optionalChain([g, 'optionalAccess', _77 => _77.open]), () => (!1)),k=a.useState("inputActive"),A=a.context.hideUntilActive,M=Se.useRef(k),w=Se.useCallback(()=>{if(!m)return!1;let Q=_optionalChain([g, 'optionalAccess', _78 => _78.contentRef, 'access', _79 => _79.current]);if(!Q)return!1;let B=Q.getBoundingClientRect(),x=Q.querySelector('[role="listbox"]');if(!x){let fe=S.current;return S.current=0,Math.abs(fe)>Wr}let K=x.getBoundingClientRect(),V=getComputedStyle(x),X=Number.parseFloat(V.paddingTop)||0,te=-(K.top+X-B.top),J=S.current;return S.current=te,Math.abs(te-J)>Wr},[m,g]);Se.useLayoutEffect(()=>{!m||!G||C.current||(w(),C.current=!0,L())},[m,G,w]),Se.useLayoutEffect(()=>{if(!m||!G)return;let Q=_optionalChain([g, 'optionalAccess', _80 => _80.contentRef, 'access', _81 => _81.current]);if(!Q||typeof ResizeObserver>"u")return;let B=new ResizeObserver(()=>{D.current||w()&&_reactdom.flushSync.call(void 0, ()=>{L()})});B.observe(Q);let x=Q.querySelector('[role="listbox"]');return x&&B.observe(x),()=>{B.disconnect()}},[m,G,g,w]),Se.useLayoutEffect(()=>{let Q=M.current;M.current=k,!(!m||!G)&&A&&!Q&&k&&i()},[m,G,A,k,i]),Se.useEffect(()=>{G||(C.current=!1,S.current=0,u())},[G,u]),Se.useEffect(()=>u,[u]);let j=m?S.current+(typeof n=="number"?n:0):n,E=_nullishCoalesce(c, () => (Xs(N))),U=h?{anchor:h}:{},re=m&&!C.current&&G?{...f,transition:"none"}:f,H=q(),ne=W(H,"positioner");return _jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:r,side:N,align:O,alignOffset:j,collisionAvoidance:E,style:re,...ne?{[ne]:""}:{},"data-align":m?"list-start":void 0,...U,...d})});var jn=jo.createContext(null);function zo(){return jo.useContext(jn)}var zn=Qo.createContext(null);function Ko(){return Qo.useContext(zn)}var qo= (_class =class{constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }__init() {this.zones=new Map}__init2() {this.surfaces=new Map}registerSurface(o,r){return this.surfaces.set(o,r),()=>{this.surfaces.get(o)===r&&this.surfaces.delete(o)}}getParentSurfaceId(o){return _nullishCoalesce(_optionalChain([this, 'access', _82 => _82.surfaces, 'access', _83 => _83.get, 'call', _84 => _84(o), 'optionalAccess', _85 => _85.parentSurfaceId]), () => (null))}closeSurface(o){_optionalChain([this, 'access', _86 => _86.surfaces, 'access', _87 => _87.get, 'call', _88 => _88(o), 'optionalAccess', _89 => _89.close, 'call', _90 => _90()])}registerZone(o,r,t){let s=this.zones.get(o);return s||(s=new Map,this.zones.set(o,s)),s.set(r,t),()=>{let n=this.zones.get(o);_optionalChain([n, 'optionalAccess', _91 => _91.delete, 'call', _92 => _92(r)]),n&&n.size===0&&this.zones.delete(o)}}getZoneElements(o){let r=this.zones.get(o);return r?[...r.values()].sort((t,s)=>t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1):[]}}, _class);function ea(e){let{store:o,focusOwnerStore:r,openChainStore:t,disabled:s,depth:n,closeAll:c,explicitTabBehavior:p=!1,tabWithoutZones:f="close",registerSurface:d,virtualization:a,debug:R,virtualAnchor:b,menuType:P="dropdown",closeOnOutsidePress:g="pointerdown",componentName:S,children:C,menuTreeResolver:L}=e,D=Qt.useRef(null);D.current||(D.current=new qo);let I=Qt.useMemo(()=>({store:o,disabled:s,depth:n,closeAll:c,explicitTabBehavior:p,tabWithoutZones:f,registerSurface:d,virtualization:a,virtualAnchor:b,menuType:P,closeOnOutsidePress:g}),[o,s,n,c,p,f,d,a,b,P,g]),v=Qt.useMemo(()=>({store:o,depth:n,closeAll:c,registerSurface:d,virtualization:a}),[o,n,c,d,a]),u=Qt.useMemo(()=>({showSafeTriangleArea:zr(_optionalChain([R, 'optionalAccess', _93 => _93.showSafeTriangleArea]),_optionalChain([R, 'optionalAccess', _94 => _94.showSubmenuSafeTriangleArea])),logAimGuardEvents:_nullishCoalesce(_optionalChain([R, 'optionalAccess', _95 => _95.logAimGuardEvents]), () => (!1))}),[_optionalChain([R, 'optionalAccess', _96 => _96.showSafeTriangleArea]),_optionalChain([R, 'optionalAccess', _97 => _97.showSubmenuSafeTriangleArea]),_optionalChain([R, 'optionalAccess', _98 => _98.logAimGuardEvents])]);return _jsxruntime.jsx.call(void 0, zn.Provider,{value:L,children:_jsxruntime.jsx.call(void 0, Tn.Provider,{value:S,children:_jsxruntime.jsx.call(void 0, Bn.Provider,{value:u,children:_jsxruntime.jsx.call(void 0, it.Provider,{value:I,children:_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.i.Provider,{value:v,children:_jsxruntime.jsx.call(void 0, Kr,{children:_jsxruntime.jsx.call(void 0, Mn.Provider,{value:r,children:_jsxruntime.jsx.call(void 0, Cn.Provider,{value:t,children:_jsxruntime.jsx.call(void 0, jn.Provider,{value:D.current,children:C})})})})})})})})})}function Ee(e){let{closeOnClick:o=!0,disabled:r=!1,activatable:t=!0,...s}=e,{aimGuardActiveRef:n,guardedDepthRef:c}=zt(),{closeAll:p}=_chunkXMZZ62VJcjs.j.call(void 0, ),d=_nullishCoalesce(_optionalChain([ct, 'call', _99 => _99(), 'optionalAccess', _100 => _100.disabled]), () => (!1)),a=r||d,R=bo.useMemo(()=>({aimGuardActiveRef:n,guardedDepthRef:c}),[n,c]),b=bo.useCallback(g=>{o&&p()},[o,p]),P=_chunkXMZZ62VJcjs.t.call(void 0, {...s,disabled:a,activatable:t,aimGuard:R,closeOnClick:o,onAfterSelect:b});return bo.useMemo(()=>({...P,disabled:a}),[P,a])}function Ro(e){let{store:o,surfaceId:r,focusOwnerStore:t,depth:s,submenuContext:n,subpageContext:c=null,enabled:p,disabled:f=!1,enableTypeToSearch:d=!1,onKeyDown:a,closeAll:R,skipFocusOwnerCheck:b=!1}=e,P=ho.useMemo(()=>n?{setOpen:C=>{C||(n.suppressAutoOpenRef.current=!0),n.setOpen(C)},parentSurfaceId:n.parentSurfaceId,closeRootOnEsc:n.closeRootOnEsc}:null,[n]),g=ho.useMemo(()=>c?{goBack:c.goBack,parentSurfaceId:c.parentSurfaceId,closeRootOnEsc:c.closeRootOnEsc}:null,[c]),S=ho.useCallback(C=>{C.itemId&&C.closeOnClick&&R()},[R]);return _chunkXMZZ62VJcjs.u.call(void 0, {store:o,surfaceId:r,enabled:p&&!f,onKeyDown:a,onSelect:S,closeAll:R,focusOwner:t,depth:s,submenuContext:P,subpageContext:g,enableTypeToSearch:d,skipFocusOwnerCheck:b})}var _userender = require('@base-ui/react/use-render');function tp(e){return e==null||e===""}function Zr(e,o){if(e==null)return"";if(o)return o(e);if(typeof e=="object"&&"label"in e){let r=e.label;if(typeof r=="string")return r}return String(e)}function $r(e,o){return e==null?"":o?o(e):typeof e=="object"&&"value"in e?String(e.value):String(e)}var Yr={slot:"bazzaui-[component]-icon",open:"data-popup-open"};var oa={open:e=>e?{[Yr.open]:""}:null},na= exports.U =Dt.forwardRef(function(o,r){let{render:t,className:s,style:n,children:c,onPointerDown:p,onClick:f,...d}=o,{store:a}=Te(),R=a.useState("open"),b=jt(),P=Dt.useMemo(()=>({open:R}),[R]),g=Dt.useCallback(D=>{b&&D.preventDefault(),_optionalChain([p, 'optionalCall', _101 => _101(D)])},[b,p]),S=Dt.useCallback(D=>{if(_optionalChain([f, 'optionalCall', _102 => _102(D)]),!D.defaultPrevented&&b)if(R)b.closeCombobox();else{if((b.multiple?b.values.length>0:b.value!=null)&&!b.multiple){let v=$r(b.value,b.itemToStringValue),i=_nullishCoalesce(b.itemTextRegistry.get(v), () => (Zr(b.value,b.itemToStringLabel)));b.onInputValueChange(i)}b.openCombobox()}},[f,b,R]),C=q(),L=W(C,"icon");return _userender.useRender.call(void 0, {render:t,ref:r,state:P,stateAttributesMapping:oa,props:{...d,...L?{[L]:""}:{},className:s,style:n,children:c,onPointerDown:g,onClick:S},defaultTagName:"span"})});var sa={first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null},aa= exports.V =nt.forwardRef(function(o,r){let{render:t,className:s,style:n,children:c,...p}=o,{store:f}=_chunkXMZZ62VJcjs.p.call(void 0, ),d=nt.useId(),[a,R]=nt.useState(null);nt.useLayoutEffect(()=>{if(a)return f.registerRow(d,a,{kind:"empty"})},[a,d,f]);let b=q(),P=W(b,"empty"),g=fo(),S=g?g.isRootLoading||g.isAnyLoading&&g.searchQuery.length>0:!1,C=f.useState("hasSearchWithNoResults"),L=!S&&C,D=f.useState("isFirstRow",d),I=f.useState("isLastRow",d),v=nt.useMemo(()=>({first:D,last:I}),[D,I]),u=_userender.useRender.call(void 0, {render:t,ref:[R,r],state:v,stateAttributesMapping:sa,props:{...p,...P?{[P]:""}:{},role:"presentation",className:s,style:n,children:c},defaultTagName:"div"});return L?u:null});var ia=ze.forwardRef(function(o,r){let{value:t,onValueChange:s,hideUntilActive:n=!1,backspaceGoesBack:c=!1,disabled:p=!1,render:f,className:d,style:a,onKeyDown:R,onPointerDown:b,...P}=o,{store:g,surfaceId:S}=_chunkXMZZ62VJcjs.p.call(void 0, ),{depth:C,closeAll:L}=_chunkXMZZ62VJcjs.j.call(void 0, ),D=Ke(),I=pt(),{disabled:v}=Te(),u=v||p,i=Pe(),l=ze.useRef(null),h=g.useState("search"),y=g.useState("highlightedId"),N=g.context.listId,F=g.context.inputId;ze.useEffect(()=>(g.setHideUntilActive(n),()=>g.setHideUntilActive(!1)),[g,n]);let T=g.useState("inputActive"),m=g.useState("pendingSearch"),O=!n||T;ze.useEffect(()=>{if(O)return g.setHasInput(!0),()=>g.setHasInput(!1)},[g,O]);let k=t!==void 0?t:h;ze.useEffect(()=>{m&&l.current&&(g.setSearch(m),_optionalChain([s, 'optionalCall', _103 => _103(m)]),g.setPendingSearch(""),l.current.focus())},[m,g,s]);let A=ze.useCallback(H=>{let ne=H.target.value;g.setSearch(ne),_optionalChain([s, 'optionalCall', _104 => _104(ne)])},[s,g]),M=ze.useCallback(H=>{_optionalChain([b, 'optionalCall', _105 => _105(H)]),!u&&i.state.ownerId!==S&&i.setOwnerId(S)},[b,u,i,S]),{handleKeyDown:w}=Ro({store:g,surfaceId:S,focusOwnerStore:i,depth:C,submenuContext:D,subpageContext:I,enabled:!0,disabled:u,enableTypeToSearch:!1,onKeyDown:R,closeAll:L}),j=ze.useCallback(H=>{if(c&&H.key==="Backspace"&&!H.repeat&&!H.nativeEvent.isComposing&&H.keyCode!==229&&k===""&&I&&I.goBack()){H.preventDefault(),I.parentSurfaceId&&i.setOwnerId(I.parentSurfaceId);return}w(H)},[c,k,I,i,w]),E=ze.useMemo(()=>({active:T}),[T]),U=q(),$=W(U,"input"),re=_userender.useRender.call(void 0, {render:f,ref:[l,r],state:E,props:{...P,...$?{[$]:""}:{},id:F,type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":!0,"aria-controls":N,"aria-activedescendant":_nullishCoalesce(y, () => (void 0)),autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:u,className:d,style:a,value:k,onChange:A,onKeyDown:j,onPointerDown:M},defaultTagName:"input"});return O?re:null});var pa={first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstGroup:e=>e?{"data-first-group":""}:null,lastGroup:e=>e?{"data-last-group":""}:null},Qn= exports.X =Wo.forwardRef(function(o,r){let{render:t,className:s,style:n,children:c,...p}=o,{store:f}=_chunkXMZZ62VJcjs.p.call(void 0, ),d=_chunkXMZZ62VJcjs.e.call(void 0, ),a=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _106 => _106.groupId]), () => ("")),R=f.useState("isFirstGroup",a),b=f.useState("isLastGroup",a),P=f.useState("isFirstRow",a),g=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _107 => _107.positional, 'optionalAccess', _108 => _108.firstGroup]), () => (R)),S=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _109 => _109.positional, 'optionalAccess', _110 => _110.lastGroup]), () => (b)),C=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _111 => _111.positional, 'optionalAccess', _112 => _112.first]), () => (P)),L=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _113 => _113.positional, 'optionalAccess', _114 => _114.last]), () => (!1)),D=Wo.useMemo(()=>({first:C,last:L,firstGroup:g,lastGroup:S}),[C,L,g,S]),I=q(),v=W(I,"group-label");return _userender.useRender.call(void 0, {render:t,ref:r,state:D,stateAttributesMapping:pa,props:{...p,...v?{[v]:""}:{},role:"presentation","aria-hidden":"true",className:s,style:n,children:c},defaultTagName:"div"})});function Uo(e,o=!0,r=!0){let t=[];for(let s of e)if(s.def.kind!=="separator"){if(s.def.kind==="group"){t.push(...Uo(lt(s),o,r));continue}if(s.def.kind==="radio-group"){if(s.def.hidden)continue;t.push(...Uo(lt(s),o,r));continue}if(s.def.kind==="submenu"||s.def.kind==="subpage"){if(s.def.hidden)continue;let n=_nullishCoalesce(s.def.includeInDeepSearch, () => (o)),c=r&&n===!0&&s.def.deepSearch!==!1;s.def.asyncNodes&&c&&t.push({id:s.id,node:s,config:s.def.asyncNodes}),c&&t.push(...Uo(lt(s),o,!0))}}return t}function Zo(e){return e.type==="query"&&(e.initialQueryBehavior===!1?"needed":_nullishCoalesce(_optionalChain([e, 'access', _115 => _115.initialQueryBehavior, 'optionalAccess', _116 => _116.loadWhen]), () => ("needed")))==="parent-open"?!0:e.loadStrategy==="eager"}function Kn(e,o=!0,r=!0){let t=new Set,s=[];for(let n of Uo(e,o,r))t.has(n.id)||(t.add(n.id),s.push(n));return s}function Xr({resolver:e,content:o,asyncContent:r,coordinator:t,graftParent:s,isSubpageSurface:n,isResolutionRoot:c,includeInDeepSearch:p}){$e.useMemo(()=>{!e||n||(s?e.graft(s,o):c&&e.setContent(o))},[e,o,s,n,c]);let f=$e.useMemo(()=>n&&e?o.map(C=>e.getNodeForDef(C)).filter(C=>C!==void 0):[],[n,e,o]),d=n?_nullishCoalesce(_nullishCoalesce(s, () => (_optionalChain([f, 'access', _117 => _117[0], 'optionalAccess', _118 => _118.parent]))), () => (null)):null,[a,R]=$e.useState(0),b=$e.useMemo(()=>n?_nullishCoalesce(_optionalChain([d, 'optionalAccess', _119 => _119.children]), () => (f)):s?s.children:c&&e?e.rootNodes:[],[n,d,f,s,e,c,o,a]),P=$e.useMemo(()=>Kn(b,p),[b,p]),g=$e.useRef(new Set);return $e.useEffect(()=>{if(!e||!t||n&&!d)return;let C=new Map(t.getAsyncNodes().filter(u=>u.kind==="branch").map(u=>[u.id,u.nodes])),L=!1,D=(u,i)=>{if(!u)return;let l=u.children;e.graft(u,i),L||=l!==u.children},I=_optionalChain([t, 'access', _120 => _120.getAsyncNodes, 'call', _121 => _121(), 'access', _122 => _122.find, 'call', _123 => _123(u=>u.kind==="root"), 'optionalAccess', _124 => _124.nodes]);if(n&&d){let u=_nullishCoalesce(d.def.nodes, () => ([]));D(d,I?r?I:[...u,...I]:u)}else{let u=I?r?I:[...o,...I]:o;if(s)D(s,u);else if(c){let i=e.rootNodes;e.setContent(u),L||=i!==e.rootNodes}}let v=new Set(P.map(u=>u.node));for(let u of g.current)v.has(u)||D(u,_nullishCoalesce(u.def.nodes, () => ([])));g.current=v;for(let u of P){let i=C.get(u.id),l=_nullishCoalesce(u.node.def.nodes, () => ([]));D(u.node,i?[...l,...i]:l)}L&&R(u=>u+1)},[e,_optionalChain([t, 'optionalAccess', _125 => _125.loaders]),_optionalChain([t, 'optionalAccess', _126 => _126.erroredLoaders]),_optionalChain([t, 'optionalAccess', _127 => _127.root]),o,r,P,s,n,d,c]),{nodes:$e.useMemo(()=>n?_nullishCoalesce(_optionalChain([d, 'optionalAccess', _128 => _128.children]), () => (f)):s?s.children:c&&e?e.rootNodes:[],[n,d,f,s,e,c,o,a]),graftVersion:a,asyncSubmenus:P}}function la(e){return e}function So(e){return"kind"in e&&e.kind==="group"}function Po(e){return"kind"in e&&e.kind==="radio-group"}function xo(e){return"kind"in e&&e.kind==="separator"}function da(e){return"kind"in e&&e.kind==="row"}function $o(e){let o=[];for(let r of e)ge(r,"tree-item")||ge(r,"item")||ge(r,"submenu")?o.push(r):process.env.NODE_ENV!=="production"&&console.warn(`Unsupported ${r.kind} child skipped inside tree-item.`);return o}function Rt(e,o={}){let{deep:r=!1,includeInDeepSearch:t=!0,descendantsIncluded:s=!0,breadcrumbs:n=[],group:c=null,radioGroup:p=null,inheritedKeywords:f=[]}=o,d=[];for(let a of e)if(!ge(a,"separator")){if(ge(a,"group")){let R={id:a.def.id,label:a.def.label,groupDef:a.def,menuNode:a};d.push(...Rt(a.children,{deep:r,includeInDeepSearch:t,descendantsIncluded:s,breadcrumbs:n,group:R,radioGroup:null,inheritedKeywords:f}));continue}if(ge(a,"radio-group")){if(a.def.hidden)continue;let R={id:a.def.id,label:a.def.label,radioGroupDef:a.def,menuNode:a};d.push(...Rt(a.children,{deep:r,includeInDeepSearch:t,descendantsIncluded:s,breadcrumbs:n,group:null,radioGroup:R,inheritedKeywords:f}));continue}if(qe(a)&&!a.def.hidden){if(ge(a,"item")||ge(a,"radio-item")||ge(a,"checkbox-item")||ge(a,"link-item")){d.push({node:a,breadcrumbs:n,group:c,radioGroup:p,inheritedKeywords:f});continue}if(ge(a,"tree-item")){if(a.def.selectable!==!1&&d.push({node:a,breadcrumbs:n,group:c,radioGroup:p,inheritedKeywords:f}),a.children.length&&a.def.deepSearch!==!1){let R={node:a.def,menuNode:a,value:a.def.value,id:a.def.id};d.push(...Rt($o(a.children),{deep:r,includeInDeepSearch:t,descendantsIncluded:s,breadcrumbs:[...n,R],group:c,radioGroup:p,inheritedKeywords:[...f,a.def.value]}))}continue}if(ge(a,"submenu")||ge(a,"subpage")){let R=_nullishCoalesce(a.def.includeInDeepSearch, () => (t));if((!r||s&&R!==!1)&&d.push({node:a,breadcrumbs:n,group:c,radioGroup:p,inheritedKeywords:f}),r&&s&&R===!0&&a.def.deepSearch!==!1&&a.children.length){let g={node:a.def,menuNode:a,value:a.def.value,id:a.def.id},S=[...n,g];d.push(...Rt(a.children.filter(C=>C.kind==="tree-item"?(process.env.NODE_ENV!=="production"&&console.warn("Unsupported tree-item child skipped inside submenu/subpage."),!1):!0),{deep:r,includeInDeepSearch:t,descendantsIncluded:!0,breadcrumbs:S,group:null,radioGroup:null,inheritedKeywords:f}))}}}}return d}function qn(e,o,r,t,s,n,c){let p=$o(e.children).filter(b=>!b.def.hidden),f={depth:t,hasChildren:p.length>0,isLastChild:c,ancestorsLast:s,header:e.def.selectable===!1},d=[{kind:"row",node:e,context:{search:null,breadcrumbs:n,isDeepSearchResult:!1,highlighted:e.def.id===o,disabled:_nullishCoalesce(e.def.disabled, () => (!1)),group:r,tree:f}}],a={node:e.def,menuNode:e,value:e.def.value,id:e.def.id},R=[...n,a];return p.forEach((b,P)=>{let g=P===p.length-1;if(ge(b,"tree-item")){d.push(...qn(b,o,r,t+1,[...s,c],R,g));return}d.push({kind:"row",node:b,context:{search:null,breadcrumbs:R,isDeepSearchResult:!1,highlighted:b.def.id===o,disabled:_nullishCoalesce(b.def.disabled, () => (!1)),group:r,tree:{depth:t+1,hasChildren:ge(b,"submenu")&&b.children.length>0,isLastChild:g,ancestorsLast:[...s,c],header:!1}}})}),d}function Wn(e,o){let r=[];for(let t of e){if(ge(t,"separator")){r.push({kind:"separator",node:t});continue}if(ge(t,"group")){let n=[],c=t.children.filter(p=>qe(p)&&!p.def.hidden);for(let p of t.children){if(ge(p,"separator")||ge(p,"group")||ge(p,"radio-group")||!qe(p)||p.def.hidden)continue;if(ge(p,"tree-item")){n.push(...qn(p,o,{id:t.def.id,label:t.def.label},0,[],[],p===c.at(-1)));continue}let f={search:null,breadcrumbs:[],isDeepSearchResult:!1,highlighted:p.def.id===o,disabled:_nullishCoalesce(p.def.disabled, () => (!1)),group:{id:t.def.id,label:t.def.label},tree:null};n.push({kind:"row",node:p,context:f})}if(n.length>0){let p={search:null,matchCount:n.length,breadcrumbs:[],isDeepSearchResult:!1};r.push({kind:"group",node:t,context:p,items:n,bestScore:1})}continue}if(ge(t,"radio-group")){if(t.def.hidden)continue;let n=[];for(let c of t.children){if(!qe(c)||c.def.hidden)continue;let p={search:null,breadcrumbs:[],isDeepSearchResult:!1,highlighted:c.def.id===o,disabled:_nullishCoalesce(c.def.disabled, () => (!1)),group:null,tree:null};n.push({kind:"row",node:c,context:p,radioGroup:{id:t.def.id,label:t.def.label}})}if(n.length>0){let c={search:null,matchCount:n.length,breadcrumbs:[],isDeepSearchResult:!1};r.push({kind:"radio-group",node:t,context:c,items:n,bestScore:1})}continue}if(!qe(t)||t.def.hidden)continue;if(ge(t,"tree-item")){let n=e.filter(c=>qe(c)&&!c.def.hidden);r.push(...qn(t,o,null,0,[],[],t===n.at(-1)));continue}let s={search:null,breadcrumbs:[],isDeepSearchResult:!1,highlighted:t.def.id===o,disabled:_nullishCoalesce(t.def.disabled, () => (!1)),group:null,tree:null};r.push({kind:"row",node:t,context:s})}return r}function Un(e,o,r){return e.map(t=>{let s=t.breadcrumbs.length>0,n={search:o?{query:o,score:t.score}:null,breadcrumbs:t.breadcrumbs,isDeepSearchResult:s,highlighted:t.node.def.id===r,disabled:_nullishCoalesce(t.node.def.disabled, () => (!1)),group:t.group?{id:t.group.id,label:t.group.label}:null,tree:null};return{kind:"row",node:t.node,context:n,radioGroup:t.radioGroup?{id:t.radioGroup.id,label:t.radioGroup.label}:void 0}})}function yo(e,o,r){let t=e.breadcrumbs.length>0,s={search:o?{query:o,score:e.score}:null,breadcrumbs:e.breadcrumbs,isDeepSearchResult:t,highlighted:e.node.def.id===r,disabled:_nullishCoalesce(e.node.def.disabled, () => (!1)),group:e.group?{id:e.group.id,label:e.group.label}:null,tree:null};return{kind:"row",node:e.node,context:s,radioGroup:e.radioGroup?{id:e.radioGroup.id,label:e.radioGroup.label}:void 0}}function Yo(e,o,r=_chunkXMZZ62VJcjs.r){let t=r(o);if(!t)return e.map(({node:n,breadcrumbs:c,group:p,radioGroup:f})=>({node:n,score:1,breadcrumbs:c,group:p,radioGroup:f}));let s=[];for(let{node:n,breadcrumbs:c,group:p,radioGroup:f,inheritedKeywords:d}of e){let a=_chunkXMZZ62VJcjs.r.call(void 0, n.def.value),R=[..._nullishCoalesce(n.def.keywords, () => ([])),...d].map(g=>_chunkXMZZ62VJcjs.r.call(void 0, g)).filter(Boolean),b=_chunkXMZZ62VJcjs.w.call(void 0, a,t,R.length>0?R:void 0),P=_nullishCoalesce(n.def.forceScore, () => (b));P>0&&s.push({node:n,score:P,breadcrumbs:c,group:p,radioGroup:f})}return s}function wt(e){return _nullishCoalesce(e.forceOrder, () => (0))}function Kt(e,o){let r=wt(e.node.def)-wt(o.node.def);return r!==0?r:o.score-e.score}function Zn(e){return e==="submenu"||e==="subpage"?1:0}function $n(e,o){let r=e.forceOrder-o.forceOrder;if(r!==0)return r;let t=e.kindRank-o.kindRank;return t!==0?t:o.score-e.score}function Xo(e){if(e.length===0)return 0;let o=Number.POSITIVE_INFINITY;for(let r of e){let t=wt(r.node.def);t<o&&(o=t)}return o===Number.POSITIVE_INFINITY?0:o}function Yn(e){return[...e].sort(Kt)}function Xn(e){let o=new Map;for(let s of e){let n=wt(s.node.def),c=_nullishCoalesce(o.get(n), () => ({items:[],branches:[]}));s.node.kind==="item"||s.node.kind==="link-item"||s.node.kind==="radio-item"||s.node.kind==="checkbox-item"||s.node.kind==="tree-item"?c.items.push(s):c.branches.push(s),o.set(n,c)}let r=[...o.keys()].sort((s,n)=>s-n),t=[];for(let s of r){let n=o.get(s);n&&t.push(...n.items,...n.branches)}return t}function _n(e){let o=new Set,r=[];for(let t of e)o.has(t.node.id)||(o.add(t.node.id),r.push(t));return r}var _r=e=>e;function fa(e){let{query:o,normalizeQuery:r,nodes:t,highlightedId:s,deepSearch:n=!0,includeInDeepSearch:c=!0,minLength:p=0,radioGroupSearchBehavior:f="preserve"}=e,d=n&&o.length>=p,a=Rt(t,{deep:d,includeInDeepSearch:c}),R=new Map;if(f==="preserve-show-all"){for(let u of a)if(u.radioGroup){let i=R.get(u.radioGroup.id);i?i.items.push(u):R.set(u.radioGroup.id,{radioGroupDef:u.radioGroup.radioGroupDef,menuNode:u.radioGroup.menuNode,items:[u],breadcrumbs:u.breadcrumbs})}}let b=Yo(a,o,r),P=new Map,g=[];for(let u of b)if(u.radioGroup)if(f==="flatten")g.push(u);else{let i=P.get(u.radioGroup.id);i?i.items.push(u):P.set(u.radioGroup.id,{radioGroupDef:u.radioGroup.radioGroupDef,menuNode:u.radioGroup.menuNode,items:[u],breadcrumbs:u.breadcrumbs})}else g.push(u);let S=Yn(g),C=Xn(S),L=_n(C),D=Un(L,o,s),I=[];if(f!=="flatten")for(let[u,{items:i,breadcrumbs:l}]of P){let h;if(f==="preserve-show-all"){let T=R.get(u);if(T){let m=new Map(i.map(O=>[O.node.id,O.score]));h=T.items.map(O=>({node:O.node,score:_nullishCoalesce(m.get(O.node.id), () => (0)),breadcrumbs:O.breadcrumbs,group:O.group,radioGroup:O.radioGroup}))}else h=i}else h=i;h.sort(Kt);let y=Math.max(...h.map(T=>T.score),0),N=l.length>0,F={search:o?{query:o,bestScore:y}:null,matchCount:i.length,breadcrumbs:l,isDeepSearchResult:N};I.push({kind:"radio-group",node:P.get(u).menuNode,context:F,items:h.map(T=>yo(T,o,s)),bestScore:y})}let v=[...D.map(u=>({node:u,score:_nullishCoalesce(_optionalChain([u, 'access', _129 => _129.context, 'access', _130 => _130.search, 'optionalAccess', _131 => _131.score]), () => (0)),forceOrder:wt(u.node.def),kindRank:Zn(u.node.kind)})),...I.map(u=>({node:u,score:u.bestScore,forceOrder:Xo(u.items),kindRank:0}))];return v.sort($n),{displayNodes:v.map(u=>u.node),isDeepSearching:d}}function ma(e){let{query:o,normalizeQuery:r,nodes:t,highlightedId:s,deepSearch:n=!0,includeInDeepSearch:c=!0,minLength:p=0,sortGroups:f=!0,radioGroupSearchBehavior:d="preserve"}=e,a=n&&o.length>=p,R=Rt(t,{deep:a,includeInDeepSearch:c}),b=new Map;if(d==="preserve-show-all"){for(let u of R)if(u.radioGroup){let i=b.get(u.radioGroup.id);i?i.items.push(u):b.set(u.radioGroup.id,{radioGroupDef:u.radioGroup.radioGroupDef,menuNode:u.radioGroup.menuNode,items:[u],breadcrumbs:u.breadcrumbs})}}let P=Yo(R,o,r),g=new Map,S=new Map,C=[];for(let u of P)if(u.radioGroup)if(d==="flatten")C.push(u);else{let i=S.get(u.radioGroup.id);i?i.items.push(u):S.set(u.radioGroup.id,{radioGroupDef:u.radioGroup.radioGroupDef,menuNode:u.radioGroup.menuNode,items:[u],breadcrumbs:u.breadcrumbs})}else if(u.group){let i=g.get(u.group.id);i?i.items.push(u):g.set(u.group.id,{groupDef:u.group.groupDef,menuNode:u.group.menuNode,items:[u],breadcrumbs:u.breadcrumbs})}else C.push(u);let L=[];for(let[u,{items:i,breadcrumbs:l}]of g){i.sort(Kt);let h=Math.max(...i.map(F=>F.score),0),y=l.length>0,N={search:o?{query:o,bestScore:h}:null,matchCount:i.length,breadcrumbs:l,isDeepSearchResult:y};L.push({kind:"group",node:g.get(u).menuNode,context:N,items:i.map(F=>yo(F,o,s)),bestScore:h})}let D=[];if(d!=="flatten")for(let[u,{items:i,breadcrumbs:l}]of S){let h;if(d==="preserve-show-all"){let T=b.get(u);if(T){let m=new Map(i.map(O=>[O.node.id,O.score]));h=T.items.map(O=>({node:O.node,score:_nullishCoalesce(m.get(O.node.id), () => (0)),breadcrumbs:O.breadcrumbs,group:O.group,radioGroup:O.radioGroup}))}else h=i}else h=i;h.sort(Kt);let y=Math.max(...h.map(T=>T.score),0),N=l.length>0,F={search:o?{query:o,bestScore:y}:null,matchCount:i.length,breadcrumbs:l,isDeepSearchResult:N};D.push({kind:"radio-group",node:S.get(u).menuNode,context:F,items:h.map(T=>yo(T,o,s)),bestScore:y})}let I=C.sort(Kt).map(u=>yo(u,o,s)),v=[...L.map(u=>({node:u,score:u.bestScore,forceOrder:Xo(u.items),kindRank:0})),...D.map(u=>({node:u,score:u.bestScore,forceOrder:Xo(u.items),kindRank:0})),...I.map(u=>({node:u,score:_nullishCoalesce(_optionalChain([u, 'access', _132 => _132.context, 'access', _133 => _133.search, 'optionalAccess', _134 => _134.score]), () => (0)),forceOrder:wt(u.node.def),kindRank:Zn(u.node.kind)}))];return f&&v.sort($n),{displayNodes:v.map(u=>u.node),isDeepSearching:a}}function Jn(e){let{query:o,nodes:r,highlightedId:t,groupSearchBehavior:s="preserve"}=e,c=(_nullishCoalesce(e.normalizeQuery, () => ((0, _chunkXMZZ62VJcjs.r))))(o),p=c===o?{...e,normalizeQuery:_r}:{...e,query:c,normalizeQuery:_r};return c?s==="preserve"?ma(p):fa(p):{displayNodes:Wn(r,t),isDeepSearching:!1}}function er(e,o,r,t,s){if(!o&&!r)return null;let n=`${e}-label`;return r?_jsxruntime.jsx.call(void 0, _.Fragment,{children:r({node:t,props:{id:n},context:s})},n):_jsxruntime.jsx.call(void 0, Qn,{id:n,children:o},n)}function ga(e){let o=[];for(let r of e)if(So(r))for(let t of r.items)!t.node.def.disabled&&t.node.id&&o.push(t.node.id);else if(Po(r))for(let t of r.items)!t.node.def.disabled&&t.node.id&&o.push(t.node.id);else xo(r)||!r.node.def.disabled&&r.node.id&&o.push(r.node.id);return o}function ba(e,o){if(e.length===0||o.length<=e.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==o[r])return!1;return!0}function tr(e){return e.map(o=>_nullishCoalesce(o.id, () => (o.value))).join(">")}function Jr(e){return So(e)?`group:${e.node.def.id}:${tr(e.context.breadcrumbs)}`:Po(e)?`radio-group:${e.node.def.id}:${tr(e.context.breadcrumbs)}`:xo(e)?`separator:${_nullishCoalesce(e.node.def.id, () => ("separator"))}`:`row:${e.node.def.kind}:${_nullishCoalesce(e.node.def.id, () => (""))}:${e.node.def.value}:${tr(e.context.breadcrumbs)}`}var ha=e=>e;function Ra(e,o){let r=e.map(a=>[Jr(a),a]),t=new Map(r),s=r.map(([a])=>a),n=o.filter(a=>t.has(a)),c=new Set(n),p=s.filter(a=>!c.has(a)),f=[...n,...p];return{orderedNodes:f.map(a=>t.get(a)).filter(a=>a!==void 0),nextOrder:f}}function Sa(e){return e.initialQueryBehavior!==void 0?e.initialQueryBehavior===!1?!1:{value:_nullishCoalesce(e.initialQueryBehavior.value, () => ("")),loadWhen:_nullishCoalesce(e.initialQueryBehavior.loadWhen, () => ("needed"))}:e.initialQuery!==void 0?{value:e.initialQuery,loadWhen:"needed"}:{value:"",loadWhen:"needed"}}function or(e,o){let r=_nullishCoalesce(e.minQueryLength, () => (1)),t=Sa(e);return o.length>=r?{effectiveQuery:o,enabled:!0,isBelowMinLength:!1}:t!==!1?{effectiveQuery:t.value,enabled:!0,isBelowMinLength:!1}:{effectiveQuery:"",enabled:!1,isBelowMinLength:!0}}function Pa({info:e,query:o,enabled:r}){let t=It(),{config:s,id:n}=e,c=s.Loader,p=_.useMemo(()=>s.type!=="query"?null:or(s,o),[s,o]),f=_nullishCoalesce(_optionalChain([p, 'optionalAccess', _135 => _135.effectiveQuery]), () => (o)),d=_nullishCoalesce(_optionalChain([p, 'optionalAccess', _136 => _136.enabled]), () => (!0));return r||Zo(s)?_jsxruntime.jsx.call(void 0, c,{query:f,enabled:d,children:R=>_jsxruntime.jsx.call(void 0, es,{kind:"branch",id:n,config:s,result:R,coordinator:t})}):null}function es({kind:e,id:o,config:r,result:t,coordinator:s}){let n=_.useRef(r),c=_.useRef(s),p=_.useRef(t),f=_.useRef(null);return n.current=r,c.current=s,p.current=t,_.useEffect(()=>{let d=c.current;if(d)return e==="root"?d.registerRootLoader({config:n.current,result:p.current}):d.registerLoader({id:o,config:n.current,result:p.current}),()=>{e==="root"?d.unregisterRootLoader():d.unregisterLoader(o)}},[e,o]),_.useEffect(()=>{let d=c.current;if(!d)return;let a=f.current;(a===null||a.data!==t.data||a.status!==t.status||a.fetchStatus!==t.fetchStatus||a.loadingPhase!==t.loadingPhase||a.isLoading!==t.isLoading||a.isFetching!==t.isFetching||a.isInitialLoading!==t.isInitialLoading||a.isRefetching!==t.isRefetching||a.isPending!==t.isPending||a.isSuccess!==t.isSuccess||a.isError!==t.isError||a.isPaused!==t.isPaused||a.hasData!==t.hasData||a.hasFetched!==t.hasFetched||a.error!==t.error)&&(f.current={data:t.data,status:t.status,fetchStatus:t.fetchStatus,loadingPhase:t.loadingPhase,isLoading:t.isLoading,isFetching:t.isFetching,isInitialLoading:t.isInitialLoading,isRefetching:t.isRefetching,isPending:t.isPending,isSuccess:t.isSuccess,isError:t.isError,isPaused:t.isPaused,hasData:t.hasData,hasFetched:t.hasFetched,error:t.error},e==="root"?d.updateRootLoaderResult(t):d.updateLoaderResult(o,t))},[e,o,t.data,t.status,t.fetchStatus,t.loadingPhase,t.isLoading,t.isFetching,t.isInitialLoading,t.isRefetching,t.isPending,t.isSuccess,t.isError,t.isPaused,t.hasData,t.hasFetched,t.error]),null}function xa({query:e}){let o=En(),r=It(),{asyncContent:t}=o,s=_.useMemo(()=>_optionalChain([t, 'optionalAccess', _137 => _137.type])!=="query"?null:or(t,e),[t,e]),n=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _138 => _138.effectiveQuery]), () => (e)),c=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _139 => _139.enabled]), () => (!0));if(!t)return null;let p=t.Loader;return _jsxruntime.jsx.call(void 0, p,{query:n,enabled:c,children:f=>_jsxruntime.jsx.call(void 0, es,{kind:"root",config:t,result:f,coordinator:r})})}var ts=_.forwardRef(function(o,r){let{children:t,content:s,asyncContent:n,deepSearchConfig:c,includeInDeepSearch:p,search:f,normalizedSearch:d,store:a,label:R="Menu",remeasureDependencies:b,...P}=o,g=Ko(),{setResolvedNodes:S}=Eo(),C=Er(),{depth:L}=_chunkXMZZ62VJcjs.j.call(void 0, ),D=pt(),I=so(),v=!!(D&&_optionalChain([I, 'optionalAccess', _140 => _140.getSurfaceId, 'call', _141 => _141(D.pageId)])),u=L===0&&!v,i=It(),l=_nullishCoalesce(c.minLength, () => (0)),h=c.enabled!==!1&&d.length>=l,{nodes:y,graftVersion:N,asyncSubmenus:F}=Xr({resolver:g,content:s,asyncContent:n,coordinator:i,graftParent:C,isSubpageSurface:v,isResolutionRoot:u,includeInDeepSearch:p}),T=h||F.some(Q=>Zo(Q.config))||n&&n.loadStrategy==="eager";_.useEffect(()=>{v||S({nodes:y,graftVersion:N,content:s})},[v,S,y,N,s]);let m=_.useRef(0);_.useEffect(()=>{!v||N===0||m.current!==N&&(m.current=N,S(Q=>Q&&{...Q,graftVersion:Q.graftVersion+1}))},[v,S,N]);let O=_.useRef(null),{displayNodes:G,isDeepSearching:k}=_.useMemo(()=>{let Q=Jn({query:d,normalizeQuery:ha,nodes:y,highlightedId:null,deepSearch:c.enabled,includeInDeepSearch:p,minLength:c.minLength,groupSearchBehavior:c.groupSearchBehavior,radioGroupSearchBehavior:c.radioGroupSearchBehavior,sortGroups:c.sortGroups}),B=_nullishCoalesce(c.asyncResultBehavior, () => ("stream")),x=F.length+(n?1:0),K=x>0,V=B==="block"&&Q.isDeepSearching&&K&&i!==null&&(i.loaders.size+(i.root?1:0)<x||i.isAnyLoading),X=Q.displayNodes;if(V)O.current=null,X=[];else if(B==="stream"&&Q.isDeepSearching){let te=O.current;if(!te||te.query!==d)O.current={query:d,order:X.map(Jr)};else{let{orderedNodes:J,nextOrder:fe}=Ra(X,te.order);X=J,O.current={query:d,order:fe}}}else O.current=null;return{displayNodes:X,isDeepSearching:Q.isDeepSearching}},[d,y,N,c,p,F.length,n,i,_optionalChain([i, 'optionalAccess', _142 => _142.isAnyLoading]),_optionalChain([i, 'optionalAccess', _143 => _143.loaders])]),A=_.useRef([]),M=_.useRef(null),w=_.useRef("replace"),j=_.useMemo(()=>ga(G),[G]),E=_.useMemo(()=>{let Q=A.current,B=j;if(Q.length!==B.length||Q.some((K,V)=>K!==B[V])){let V=(_nullishCoalesce(c.asyncResultBehavior, () => ("stream")))==="stream"&&k&&M.current===d&&ba(Q,B);return w.current=V?"append":"replace",A.current=B,M.current=d,B}return Q},[j,c.asyncResultBehavior,k,d]);_.useEffect(()=>{a.setOrderedItems(E,{reason:w.current})},[a,E]);let U=_.useCallback(Q=>{let B=Q.node,x=B.def,{context:K}=Q,V=B.id,X=te=>{if(!te.def.asyncNodes||!i)return;let J=i.loaders.get(te.id);if(!J)return;let fe=te.def.asyncNodes.type==="query"?or(te.def.asyncNodes,d).isBelowMinLength:!1;return{status:J.result.status,fetchStatus:J.result.fetchStatus,loadingPhase:J.result.loadingPhase,isLoading:J.result.isLoading,isFetching:J.result.isFetching,isInitialLoading:J.result.isInitialLoading,isRefetching:J.result.isRefetching,isError:J.result.isError,error:J.result.error,isBelowMinLength:fe}};if(x.kind==="item")return _jsxruntime.jsx.call(void 0, _.Fragment,{children:x.render({node:B,props:{id:V,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1)),closeOnClick:x.closeOnClick,onSelect:x.onSelect,shortcut:x.shortcut,forceOrder:x.forceOrder,forceScore:x.forceScore},context:{...K,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1))}})},V);if(x.kind==="link-item")return _jsxruntime.jsx.call(void 0, _.Fragment,{children:x.render({node:B,props:{id:V,value:x.value,href:x.href,disabled:_nullishCoalesce(x.disabled, () => (!1)),closeOnClick:x.closeOnClick,onSelect:x.onSelect,shortcut:x.shortcut,forceOrder:x.forceOrder,forceScore:x.forceScore},context:{...K,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1))}})},V);if(x.kind==="tree-item")return _jsxruntime.jsx.call(void 0, _.Fragment,{children:x.render({node:B,props:{id:V,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1)),selectable:x.selectable!==!1,closeOnClick:x.closeOnClick,onSelect:x.onSelect,forceOrder:x.forceOrder,forceScore:x.forceScore},context:{...K,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1))}})},V);if(x.kind==="radio-item")return _jsxruntime.jsx.call(void 0, _.Fragment,{children:x.render({node:B,props:{id:V,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1)),closeOnClick:x.closeOnClick,onSelect:x.onSelect,shortcut:x.shortcut,forceOrder:x.forceOrder,forceScore:x.forceScore},context:{...K,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1))}})},V);if(x.kind==="checkbox-item")return _jsxruntime.jsx.call(void 0, _.Fragment,{children:x.render({node:B,props:{id:V,value:x.value,checked:x.checked,onCheckedChange:x.onCheckedChange,disabled:_nullishCoalesce(x.disabled, () => (!1)),closeOnClick:x.closeOnClick,forceOrder:x.forceOrder,forceScore:x.forceScore},context:{...K,value:x.value,checked:x.checked,disabled:_nullishCoalesce(x.disabled, () => (!1))}})},V);if(x.kind==="submenu"){let te=X(B),J=lt(B),fe={node:x,menuNode:B,value:x.value,id:x.id},Oe=We=>{let me=We,ie=We.def;if(ie.kind==="separator")return null;if(ie.kind==="group"){let Xe=me.children.filter(ye=>qe(ye)&&(ye.kind==="item"||ye.kind==="link-item"||ye.kind==="checkbox-item"||ye.kind==="submenu"||ye.kind==="subpage")&&!ye.def.hidden);if(Xe.length===0)return null;let we=Xe.map(ye=>{let Z={search:null,breadcrumbs:[...K.breadcrumbs,fe],isDeepSearchResult:!1,highlighted:!1,disabled:_nullishCoalesce(ye.def.disabled, () => (!1)),group:{id:ie.id,label:ie.label},tree:null};return U({kind:"row",node:ye,context:Z})});if(ie.render){let ye={search:null,matchCount:Xe.length,breadcrumbs:[...K.breadcrumbs,fe],isDeepSearchResult:!1};return _jsxruntime.jsx.call(void 0, _.Fragment,{children:ie.render({node:me,props:{},context:{...ye,label:ie.label},children:_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:we})})},ie.id)}return _jsxruntime.jsx.call(void 0, "div",{role:"group","aria-label":ie.label,children:we},ie.id)}if(ie.kind==="radio-group")return $(me,[...K.breadcrumbs,fe]);if(ie.kind!=="item"&&ie.kind!=="link-item"&&ie.kind!=="checkbox-item"&&ie.kind!=="submenu"&&ie.kind!=="subpage")return null;let Fe={search:null,breadcrumbs:[...K.breadcrumbs,fe],isDeepSearchResult:!1,highlighted:!1,disabled:_nullishCoalesce(ie.disabled, () => (!1)),group:null,tree:null};return U({kind:"row",node:me,context:Fe})};return _jsxruntime.jsx.call(void 0, _.Fragment,{children:_jsxruntime.jsx.call(void 0, lo.Provider,{value:B,children:x.render({node:B,props:{id:V,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1)),forceOrder:x.forceOrder,forceScore:x.forceScore},context:{...K,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1)),async:te},nodes:J,asyncContent:x.asyncNodes,renderNode:Oe})})},V)}if(x.kind==="subpage"){let te=X(B),J=B.id;return _jsxruntime.jsx.call(void 0, _.Fragment,{children:x.renderTrigger({node:B,props:{id:V,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1)),targetPageId:J},context:{...K,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1)),async:te}})},V)}return null},[i,d,k]),$=_.useCallback((Q,B=[])=>{let x=Q.def,K=B.length>0,V={search:null,matchCount:x.nodes.length,breadcrumbs:B,isDeepSearchResult:K},X=Q.children.map(te=>{if(!qe(te)||te.def.hidden)return null;let J={search:null,breadcrumbs:B,isDeepSearchResult:K,highlighted:!1,disabled:_nullishCoalesce(te.def.disabled, () => (!1)),group:null,tree:null};return U({kind:"row",node:te,context:J,radioGroup:{id:x.id,label:x.label}})});return x.render?_jsxruntime.jsx.call(void 0, _.Fragment,{children:x.render({node:Q,props:{value:x.value,onValueChange:x.onValueChange,disabled:_nullishCoalesce(x.disabled, () => (!1))},context:{...V,label:x.label,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1))},children:_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:X})})},x.id):_jsxruntime.jsxs.call(void 0, "div",{role:"radiogroup","aria-label":x.label,children:[er(x.id,x.label,x.renderLabel,Q,{...V,label:x.label,value:x.value,disabled:_nullishCoalesce(x.disabled, () => (!1))}),X]},x.id)},[U]),re=_.useCallback(Q=>{if(So(Q)){let B=Q.node,{context:x,items:K}=Q,V=B.def,X=K.map(te=>U(te));return V.render?_jsxruntime.jsx.call(void 0, _.Fragment,{children:V.render({node:B,props:{},context:{...x,label:V.label},children:_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:X})})},V.id):_jsxruntime.jsxs.call(void 0, "div",{role:"group","aria-label":V.label,children:[er(V.id,V.label,V.renderLabel,B,{...x,label:V.label}),X]},V.id)}if(Po(Q)){let B=Q.node,{context:x,items:K}=Q,V=B.def,X=K.map(te=>U(te));return V.render?_jsxruntime.jsx.call(void 0, _.Fragment,{children:V.render({node:B,props:{value:V.value,onValueChange:V.onValueChange,disabled:_nullishCoalesce(V.disabled, () => (!1))},context:{...x,label:V.label,value:V.value,disabled:_nullishCoalesce(V.disabled, () => (!1))},children:_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:X})})},V.id):_jsxruntime.jsxs.call(void 0, "div",{role:"radiogroup","aria-label":V.label,children:[er(V.id,V.label,V.renderLabel,B,{...x,label:V.label,value:V.value,disabled:_nullishCoalesce(V.disabled, () => (!1))}),X]},V.id)}if(xo(Q)){let B=Q.node.def;return B.render?_jsxruntime.jsx.call(void 0, _.Fragment,{children:B.render({props:{id:B.id}})},_nullishCoalesce(B.id, () => ("separator"))):_jsxruntime.jsx.call(void 0, "div",{role:"none"},_nullishCoalesce(B.id, () => ("separator")))}return U(Q)},[U]),H=_.useMemo(()=>i?i.getAsyncState():{isLoading:!1,isFetching:!1,isInitialLoading:!1,isRefetching:!1,isAllRefetching:!1,isStaticLoading:!1,isStaticInitialLoading:!1,isStaticRefetching:!1,isQueryLoading:!1,isQueryInitialLoading:!1,isQueryRefetching:!1,skippedMenus:[]},[i,_optionalChain([i, 'optionalAccess', _144 => _144.loaders]),_optionalChain([i, 'optionalAccess', _145 => _145.erroredLoaders]),_optionalChain([i, 'optionalAccess', _146 => _146.root])]),ne=_.useMemo(()=>({search:f,nodes:G,renderNode:re,count:G.length,isDeepSearching:k,async:H}),[f,G,re,k,H]);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[T&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, xa,{query:d}),F.map(Q=>_jsxruntime.jsx.call(void 0, Pa,{info:Q,query:d,enabled:h},Q.id))]}),_jsxruntime.jsx.call(void 0, po.Provider,{value:ne,children:_jsxruntime.jsx.call(void 0, nr,{ref:r,label:R,...P,remeasureDependencies:[k,..._nullishCoalesce(b, () => ([]))],children:t})})]})});var rr=(o=>(o.rowWidth="--row-width",o))(rr||{});var nr=Ce.forwardRef(function(o,r){let{children:t,label:s="Suggestions",measureRowWidth:n=!0,maxRowWidth:c,scrollContainerRef:p,remeasureDependencies:f,render:d,className:a,style:R,onKeyDown:b,onPointerDown:P,...g}=o,{store:S,surfaceId:C}=_chunkXMZZ62VJcjs.p.call(void 0, ),{depth:L,closeAll:D}=_chunkXMZZ62VJcjs.j.call(void 0, ),I=Ke(),v=pt(),{disabled:u}=Te(),i=Pe(),l=jt(),h=Ce.useRef(null),y=Ce.useRef(null);Ce.useEffect(()=>{S.setListRef(h)},[S]),Ce.useEffect(()=>{if(p)return S.setListScrollContainerRef(p),()=>{S.setListScrollContainerRef({current:null})}},[S,p]),Ce.useLayoutEffect(()=>{if(!n||!h.current)return;let K=h.current.closest("[data-open]");y.current=K},[n]);let{queueMeasurement:N,resetMeasurements:F,clearMeasuredIds:T}=_chunkXMZZ62VJcjs.v.call(void 0, {listRef:h,targetRef:y,maxWidth:c,enabled:n}),m=Ce.useRef(null),O=Ce.useRef(!1);Ce.useEffect(()=>{let K=_nullishCoalesce(m.current, () => ([])),V=O.current;if(m.current=_nullishCoalesce(f, () => (null)),O.current=!0,!n||!V)return;let X=_nullishCoalesce(f, () => ([]));if(K.length!==X.length||X.some((J,fe)=>!Object.is(J,K[fe]))){T();for(let[J,fe]of S.context.refs.itemRefs)fe.current&&N(fe.current,J)}}),Ce.useEffect(()=>{if(n)return S.context.onCloseComplete=F,()=>{S.context.onCloseComplete=void 0}},[n,F,S]);let G=Ce.useMemo(()=>n?{queueMeasurement:N}:null,[n,N]),k=S.useState("search"),A=S.useState("filteredCount"),M=S.useState("hasInput"),w=S.useState("highlightedId"),j=S.context.listId,E=!M&&!u,{handleKeyDown:U}=Ro({store:S,surfaceId:C,focusOwnerStore:i,depth:L,submenuContext:I,subpageContext:v,enabled:E,disabled:u,enableTypeToSearch:!0,onKeyDown:b,closeAll:D}),$=Ce.useCallback(K=>{K.target instanceof HTMLInputElement||K.preventDefault(),_optionalChain([P, 'optionalCall', _147 => _147(K)])},[P]),re=Ce.useMemo(()=>({search:k,filteredCount:A}),[k,A]),H=typeof t=="function"?t(re):t,ne=G?_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.l.Provider,{value:G,children:H}):H,Q=_optionalChain([l, 'optionalAccess', _148 => _148.layout])==="input-embedded",B=q(),x=W(B,"list");return _userender.useRender.call(void 0, {render:d,ref:[h,r],props:{...g,...x?{[x]:""}:{},id:j,role:"listbox","aria-label":s,"aria-activedescendant":E?_nullishCoalesce(w, () => (void 0)):void 0,tabIndex:E?0:-1,"data-popup-menu-list":"","data-input-embedded":Q?"":void 0,className:a,style:R,onKeyDown:U,onPointerDown:$,children:ne},defaultTagName:"div"})}),Ma= exports.ca =Ce.forwardRef(function(o,r){let t=An(),{store:s}=_chunkXMZZ62VJcjs.p.call(void 0, ),n=s.useState("search"),c=s.useState("normalizedSearch");return t?_jsxruntime.jsx.call(void 0, ts,{ref:r,...o,content:t.content,asyncContent:t.asyncContent,deepSearchConfig:t.deepSearchConfig,includeInDeepSearch:t.includeInDeepSearch,search:n,normalizedSearch:c,store:s}):_jsxruntime.jsx.call(void 0, nr,{ref:r,...o})});var va={first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null},ka= exports.da =rt.forwardRef(function(o,r){let{forceMount:t=!1,render:s,className:n,style:c,children:p,...f}=o,{store:d}=_chunkXMZZ62VJcjs.p.call(void 0, ),a=rt.useId(),[R,b]=rt.useState(null);rt.useLayoutEffect(()=>{if(R)return d.registerRow(a,R,{kind:"loading"})},[R,a,d]);let P=q(),g=W(P,"loading"),S=fo(),C=S?S.isRootLoading||S.isAnyLoading&&S.searchQuery.length>0:!1,L=t||C,D=d.useState("isFirstRow",a),I=d.useState("isLastRow",a),v=rt.useMemo(()=>({first:D,last:I}),[D,I]),u=_userender.useRender.call(void 0, {render:s,ref:[b,r],state:v,stateAttributesMapping:va,props:{...f,...g?{[g]:""}:{},role:"presentation",className:n,style:c,children:p},defaultTagName:"div"});return L?u:null});var os={slot:"bazzaui-[component]-scroll-[up|down]-arrow",direction:"data-direction",side:"data-side"};var Da={direction:e=>e?{[os.direction]:String(e)}:null,visible:e=>({"data-visible":e?"true":"false"})},ns=ke.forwardRef(function(o,r){let{direction:t,keepMounted:s=!1,scrollSpeed:n=10,render:c,className:p,style:f,children:d,...a}=o,{store:R}=_chunkXMZZ62VJcjs.p.call(void 0, ),[b,P]=ke.useState(!1),g=ke.useRef(!1),S=ke.useRef(null),L=R.useState("openMethod")==="touch",D=ke.useCallback(()=>{if(L){P(!1);return}let F=_optionalChain([R, 'access', _149 => _149.context, 'access', _150 => _150.refs, 'access', _151 => _151.listRef, 'optionalAccess', _152 => _152.current]);if(!F){P(!1);return}if(t==="up")P(F.scrollTop>0);else{let T=F.scrollTop+F.clientHeight>=F.scrollHeight-1;P(!T)}},[R,t,L]);ke.useEffect(()=>{let F=_optionalChain([R, 'access', _153 => _153.context, 'access', _154 => _154.refs, 'access', _155 => _155.listRef, 'optionalAccess', _156 => _156.current]);if(!F)return;D(),F.addEventListener("scroll",D,{passive:!0});let T=new ResizeObserver(D);return T.observe(F),()=>{F.removeEventListener("scroll",D),T.disconnect()}},[R,D]);let I=R.useState("filteredCount");ke.useEffect(()=>{requestAnimationFrame(D)},[I,D]);let v=ke.useCallback(()=>{g.current=!0;let N=()=>{if(!g.current)return;let T=_optionalChain([R, 'access', _157 => _157.context, 'access', _158 => _158.refs, 'access', _159 => _159.listRef, 'optionalAccess', _160 => _160.current]);if(T){let m=t==="up"?-n:n;T.scrollTop+=m}S.current=requestAnimationFrame(N)};S.current=requestAnimationFrame(N)},[R,t,n]),u=ke.useCallback(()=>{g.current=!1,S.current&&(cancelAnimationFrame(S.current),S.current=null)},[]);ke.useEffect(()=>()=>{S.current&&cancelAnimationFrame(S.current)},[]);let i=ke.useMemo(()=>({direction:t,visible:b}),[t,b]),l=b||s,h=q(),y=W(h,t==="up"?"scroll-up-arrow":"scroll-down-arrow");return _userender.useRender.call(void 0, {render:c,ref:r,state:i,stateAttributesMapping:Da,props:{...a,...y?{[y]:""}:{},className:p,style:f,onPointerEnter:N=>{v(),_optionalChain([a, 'access', _161 => _161.onPointerEnter, 'optionalCall', _162 => _162(N)])},onPointerLeave:N=>{u(),_optionalChain([a, 'access', _163 => _163.onPointerLeave, 'optionalCall', _164 => _164(N)])},children:d},defaultTagName:"div",enabled:l})}),wa= exports.ea =ke.forwardRef(function(o,r){return _jsxruntime.jsx.call(void 0, ns,{ref:r,direction:"up",...o})}),Na= exports.fa =ke.forwardRef(function(o,r){return _jsxruntime.jsx.call(void 0, ns,{ref:r,direction:"down",...o})});var _useStableCallback = require('@base-ui/utils/useStableCallback');var ss="a[href], button, input, select, textarea, [tabindex]";function _o(e){let o=Array.from(e.querySelectorAll(ss));return(e.matches(ss)?[e,...o]:o).filter(t=>t.tabIndex>=0&&!t.hasAttribute("disabled")&&!(t instanceof HTMLInputElement&&t.type==="hidden")&&t.closest('[hidden], [inert], [aria-hidden="true"]')===null)}function Ta({children:e}){let{store:o}=_chunkXMZZ62VJcjs.p.call(void 0, ),r=o.useState("normalizedSearch");return _jsxruntime.jsx.call(void 0, Ar,{searchQuery:r,children:e})}var Ga=ue.forwardRef(function(o,r){let{filter:t=_chunkXMZZ62VJcjs.x,normalizeSearch:s=_chunkXMZZ62VJcjs.r,search:n,onSearchChange:c,defaultSearch:p="",loop:f=!0,autoHighlightFirst:d=!0,clearSearchOnClose:a="after-exit",resetScrollOnSearch:R=!0,skipAutoFocus:b=!1,orderedItems:P,content:g,asyncContent:S,deepSearch:C,includeInDeepSearch:L=!0,render:D,className:I,style:v,onKeyDown:u,onFocus:i,onPointerDown:l,onPointerMove:h,children:y,...N}=o,F=ue.useMemo(()=>_optionalChain([g, 'optionalAccess', _165 => _165.map, 'call', _166 => _166(ee=>vn(ee)?ee.def:ee)]),[g]),T=g!==void 0||S!==void 0||C!==void 0||o.includeInDeepSearch!==void 0,{store:m,depth:O,virtualization:G}=_chunkXMZZ62VJcjs.j.call(void 0, );m.initializeDefaultSearch(p);let k=Ke(),A=pt(),M=so(),w=Pe(),j=ue.useRef(0),E=ue.useId(),U=ue.useId(),$=ue.useId(),H=_nullishCoalesce(_nullishCoalesce(Dr(), () => (_optionalChain([k, 'optionalAccess', _167 => _167.childSurfaceId]))), () => ($)),ne=zo(),Q=ue.useMemo(()=>M?A&&M.getSurfaceId(A.pageId)?M.activePageId===A.pageId:M.activePageId===null:!0,[M,A]),B=w.useState("isOwner",H),x=_useStableCallback.useStableCallback.call(void 0, ee=>{_optionalChain([c, 'optionalCall', _168 => _168(ee)])});ue.useEffect(()=>{m.context.filter=T?!1:t,m.setSearchNormalizer(s),m.context.loop=f,m.context.autoHighlightFirst=d,m.context.clearSearchOnClose=a,m.context.resetScrollOnSearch=R,m.context.listId=E,m.context.inputId=U,m.context.onSearchChange=x,G&&(m.setVirtualized(G.virtualized),m.setVirtualItems(G.items),m.setOnHighlightChange(G.onHighlightChange)),typeof d=="string"&&m.applyAutoHighlight()},[m,t,s,f,d,a,R,E,U,x,G,T]);let K=Te(),V=ue.useMemo(()=>typeof C=="boolean"||C===void 0?{enabled:_nullishCoalesce(C, () => (!0)),minLength:0,groupSearchBehavior:"preserve",radioGroupSearchBehavior:"preserve",sortGroups:!0,asyncResultBehavior:"stream"}:{enabled:_nullishCoalesce(C.enabled, () => (!0)),minLength:_nullishCoalesce(C.minLength, () => (0)),groupSearchBehavior:_nullishCoalesce(C.groupSearchBehavior, () => ("preserve")),radioGroupSearchBehavior:_nullishCoalesce(C.radioGroupSearchBehavior, () => ("preserve")),sortGroups:_nullishCoalesce(C.sortGroups, () => (!0)),asyncResultBehavior:_nullishCoalesce(C.asyncResultBehavior, () => ("stream"))},[C]),X=ue.useId(),te=ue.useMemo(()=>({content:_nullishCoalesce(F, () => ([])),asyncContent:S,deepSearchConfig:V,includeInDeepSearch:L,listId:X}),[F,S,V,L,X]),fe=_optionalChain([Gr, 'call', _169 => _169(), 'optionalAccess', _170 => _170.setDataSurfaceContext]),Oe=!!(A&&_optionalChain([M, 'optionalAccess', _171 => _171.getSurfaceId, 'call', _172 => _172(A.pageId)]));ue.useEffect(()=>{if(!(!T||!fe||Oe))return fe(te),()=>{fe(ee=>ee===te?null:ee)}},[T,fe,te,Oe]),ue.useEffect(()=>{P&&m.setOrderedItems(P)},[m,P]),m.useControlledProp("searchProp",n);let We=m.useState("open"),me=ue.useRef(null);ue.useEffect(()=>{We&&(j.current=Date.now())},[We]),ue.useEffect(()=>{Q&&O===0&&We&&w.setOwnerId(H)},[O,We,H,w,Q]),ue.useEffect(()=>{if(!(!ne||!Q)&&K.explicitTabBehavior)return ne.registerSurface(H,{parentSurfaceId:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _173 => _173.parentSurfaceId]), () => (null)),close:k?()=>{k.suppressAutoOpenRef.current=!0,k.setOpen(!1)}:()=>{}})},[ne,Q,K.explicitTabBehavior,H,k]);let ie=ue.useRef(!1);ue.useEffect(()=>{(!Q||!We)&&(ie.current=!1)},[Q,We]),ue.useEffect(()=>{if(!Q||!B||b)return;let ee=setTimeout(()=>{requestAnimationFrame(()=>{if(!me.current)return;let Ze=_nullishCoalesce(_optionalChain([ne, 'optionalAccess', _174 => _174.getZoneElements, 'call', _175 => _175(H)]), () => ([])),xt=!ie.current;ie.current=!0;let Nt=Ze.some(gt=>document.activeElement!==null&&gt.contains(document.activeElement));if(K.explicitTabBehavior&&document.activeElement&&me.current.contains(document.activeElement)&&!(xt&&Nt))return;let Lt=Array.from(me.current.querySelectorAll("input")).find(gt=>!Ze.some(Ot=>Ot.contains(gt))),yt=me.current.querySelector('[role="listbox"]'),_e=Ze.flatMap(_o)[0],mt=_nullishCoalesce(_nullishCoalesce(Lt, () => (yt)), () => (_e));mt&&mt instanceof HTMLElement&&mt.focus()})},0);return()=>clearTimeout(ee)},[Q,B,b,K.explicitTabBehavior,ne,H]);let Fe=ue.useMemo(()=>({store:m,surfaceId:H}),[m,H]),Xe=ue.useCallback(ee=>{ee.target instanceof HTMLInputElement||ee.preventDefault(),_optionalChain([l, 'optionalCall', _176 => _176(ee)])},[l]),we=ue.useCallback(ee=>{if(_optionalChain([h, 'optionalCall', _177 => _177(ee)]),Date.now()-j.current<100)return;let xt=ee.target;_optionalChain([me, 'access', _178 => _178.current, 'optionalAccess', _179 => _179.contains, 'call', _180 => _180(xt)])&&w.state.ownerId!==H&&w.setOwnerId(H)},[h,H,w]),ye=ue.useCallback(ee=>{if(_optionalChain([u, 'optionalCall', _181 => _181(ee)]),ee.defaultPrevented||ee.key!=="Tab"||!K.explicitTabBehavior)return;let Ze=ee.target;if(!_optionalChain([me, 'access', _182 => _182.current, 'optionalAccess', _183 => _183.contains, 'call', _184 => _184(Ze)]))return;let Nt=(_nullishCoalesce(_optionalChain([ne, 'optionalAccess', _185 => _185.getZoneElements, 'call', _186 => _186(H)]), () => ([]))).flatMap(_o);if(Nt.length===0){if(!ne){if(K.tabWithoutZones==="inert"){ee.preventDefault();return}K.closeAll(_chunkXMZZ62VJcjs.a.focusOut,ee.nativeEvent);return}let Mt=[],Tt=H;for(;;){let z=ne.getParentSurfaceId(Tt);if(!z){if(K.tabWithoutZones==="inert"){ee.preventDefault();return}K.closeAll(_chunkXMZZ62VJcjs.a.focusOut,ee.nativeEvent);return}Mt.push(Tt);let oe=ne.getZoneElements(z).flatMap(_o);if(oe.length>0){ee.preventDefault();for(let Me of Mt)ne.closeSurface(Me);w.setOwnerId(z),_optionalChain([(ee.shiftKey?oe[oe.length-1]:oe[0]), 'optionalAccess', _187 => _187.focus, 'call', _188 => _188()]);return}Tt=z}}let $t=m.state.hasInput?m.context.inputId:m.context.listId,Lt=$t?document.getElementById($t):null,yt=new Set;Lt instanceof HTMLElement&&yt.add(Lt);for(let Mt of Nt)yt.add(Mt);let _e=[...yt];ee.preventDefault();let mt=document.activeElement,gt=mt?_e.indexOf(mt):-1,Ot=ee.shiftKey?-1:1;_optionalChain([(gt===-1?ee.shiftKey?_e[_e.length-1]:_e[0]:_e[(gt+Ot+_e.length)%_e.length]), 'optionalAccess', _189 => _189.focus, 'call', _190 => _190()])},[u,K,m,ne,H,w]),Z=ue.useCallback(ee=>{if(_optionalChain([i, 'optionalCall', _191 => _191(ee)]),!K.explicitTabBehavior)return;let Ze=ee.target;_optionalChain([me, 'access', _192 => _192.current, 'optionalAccess', _193 => _193.contains, 'call', _194 => _194(Ze)])&&w.state.ownerId!==H&&w.setOwnerId(H)},[i,K,w,H]),Ue=q(),se=W(Ue,"surface"),De=T?_jsxruntime.jsx.call(void 0, io.Provider,{value:te,children:_jsxruntime.jsx.call(void 0, Ta,{children:y})}):y,Pt=_userender.useRender.call(void 0, {render:D,ref:[me,r],props:{...N,...se?{[se]:""}:{},className:I,style:v,onPointerDown:Xe,onPointerMove:we,onKeyDown:ye,onFocus:Z,children:De},enabled:Q,defaultTagName:"div"});return _jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.o.Provider,{value:Fe,children:Pt})});var ar=en.createContext(null);function as(){let e=en.useContext(ar);if(!e)throw new Error("PopupMenu.CheckboxItemIndicator must be used within PopupMenu.CheckboxItem");return e}var Fa={checked:e=>e?{"data-checked":""}:{"data-unchecked":""},highlighted:e=>e?{"data-highlighted":""}:null,disabled:e=>e?{"data-disabled":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstInGroup:e=>e?{"data-first-in-group":""}:null,lastInGroup:e=>e?{"data-last-in-group":""}:null},Va= exports.ha =Qe.forwardRef(function(o,r){let{id:t,checked:s,defaultChecked:n=!1,onCheckedChange:c,value:p,keywords:f,disabled:d=!1,onSelect:a,forceMount:R=!1,closeOnClick:b=!1,shortcut:P,forceOrder:g,forceScore:S,render:C,className:L,style:D,onClick:I,onPointerDown:v,onPointerMove:u,children:i,...l}=o,[h,y]=Qe.useState(n),N=s!==void 0,F=N?s:h,T=Qe.useCallback(($=_chunkXMZZ62VJcjs.a.itemPress,re)=>{let H=!F,ne=_chunkXMZZ62VJcjs.b.call(void 0, $,re);_optionalChain([c, 'optionalCall', _195 => _195(H,ne)]),!ne.isCanceled&&(N||y(H))},[F,N,c]),m=Ee({id:t,value:p,keywords:f,disabled:d,forceMount:R,shortcut:P,forceOrder:g,forceScore:S,closeOnClick:b,children:i}),O=m.disabled;Qe.useEffect(()=>{let $=()=>{O||(T(),_optionalChain([a, 'optionalCall', _196 => _196()]))};return m.registerSelect($)},[O,T,a,m]);let G=Qe.useMemo(()=>({highlighted:m.isHighlighted,disabled:O,checked:F,first:m.positional.first,last:m.positional.last,firstInGroup:m.positional.firstInGroup,lastInGroup:m.positional.lastInGroup}),[m.isHighlighted,O,F,m.positional]),k=Qe.useMemo(()=>({...m.contextValue,checked:F,toggle:T}),[m.contextValue,F,T]),A=Qe.useCallback($=>{_optionalChain([I, 'optionalCall', _197 => _197($)]),$.defaultPrevented||m.handlers.onClick($)},[I,m.handlers]),M=Qe.useCallback($=>{m.handlers.onPointerDown($),_optionalChain([v, 'optionalCall', _198 => _198($)])},[m.handlers,v]),w=Qe.useCallback($=>{_optionalChain([u, 'optionalCall', _199 => _199($)]),$.defaultPrevented||m.handlers.onPointerMove($)},[u,m.handlers]),j=q(),E=W(j,"checkbox-item"),U=_userender.useRender.call(void 0, {render:C,ref:[m.ref,m.rowRef,r],state:G,stateAttributesMapping:Fa,props:{...l,...E?{[E]:""}:{},id:m.id,role:"menuitemcheckbox",tabIndex:-1,"aria-checked":F,"aria-disabled":O||void 0,className:L,style:D,onClick:A,onPointerMove:w,onPointerDown:M,children:i},enabled:m.isVisible,defaultTagName:"div"});return m.isVisible?_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.f.Provider,{value:m.contextValue,children:_jsxruntime.jsx.call(void 0, ar.Provider,{value:k,children:U})}):null});var Ha={checked:e=>e?{"data-checked":""}:{"data-unchecked":""},disabled:e=>e?{"data-disabled":""}:null},ja= exports.ia =tn.forwardRef(function(o,r){let{keepMounted:t=!1,render:s,className:n,style:c,children:p,...f}=o,{checked:d,highlighted:a,disabled:R,toggle:b}=as(),P=tn.useMemo(()=>({checked:d,highlighted:a,disabled:R,toggle:b}),[d,a,R,b]),g=t||d,S=q(),C=W(S,"checkbox-item-indicator");return _userender.useRender.call(void 0, {render:s,ref:r,state:P,stateAttributesMapping:Ha,props:{...f,...C?{[C]:""}:{},"aria-hidden":!0,className:n,style:c,children:p},enabled:g,defaultTagName:"span"})});var Qa={highlighted:e=>e?{"data-highlighted":""}:null,disabled:e=>e?{"data-disabled":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstInGroup:e=>e?{"data-first-in-group":""}:null,lastInGroup:e=>e?{"data-last-in-group":""}:null},ur= exports.ja =St.forwardRef(function(o,r){let{id:t,value:s,keywords:n,disabled:c=!1,activatable:p=!0,onSelect:f,forceMount:d=!1,closeOnClick:a=!0,shortcut:R,forceOrder:b,forceScore:P,render:g,className:S,style:C,onClick:L,onPointerDown:D,onPointerMove:I,children:v,...u}=o,i=Ee({id:t,value:s,keywords:n,disabled:c,activatable:p,forceMount:d,shortcut:R,forceOrder:b,forceScore:P,onSelect:f,closeOnClick:a,children:v}),l=i.disabled,h=St.useMemo(()=>({highlighted:i.isHighlighted,disabled:l,first:i.positional.first,last:i.positional.last,firstInGroup:i.positional.firstInGroup,lastInGroup:i.positional.lastInGroup}),[i.isHighlighted,l,i.positional]),y=St.useCallback(G=>{_optionalChain([L, 'optionalCall', _200 => _200(G)]),G.defaultPrevented||i.handlers.onClick(G)},[L,i.handlers]),N=St.useCallback(G=>{i.handlers.onPointerDown(G),_optionalChain([D, 'optionalCall', _201 => _201(G)])},[i.handlers,D]),F=St.useCallback(G=>{_optionalChain([I, 'optionalCall', _202 => _202(G)]),G.defaultPrevented||i.handlers.onPointerMove(G)},[I,i.handlers]),T=_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.f.Provider,{value:i.contextValue,children:v}),m=q(),O=W(m,"item");return _userender.useRender.call(void 0, {render:g,ref:[i.ref,i.rowRef,r],state:h,stateAttributesMapping:Qa,props:{...u,...O?{[O]:""}:{},id:i.id,role:"option",tabIndex:-1,"aria-selected":i.isHighlighted,"aria-disabled":l||void 0,className:S,style:C,onClick:y,onPointerMove:F,onPointerDown:N,children:T},enabled:i.isVisible,defaultTagName:"div"})});var Wa={highlighted:e=>e?{"data-highlighted":""}:null,disabled:e=>e?{"data-disabled":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstInGroup:e=>e?{"data-first-in-group":""}:null,lastInGroup:e=>e?{"data-last-in-group":""}:null},Ua= exports.ka =Ye.forwardRef(function(o,r){let{id:t,value:s,keywords:n,disabled:c=!1,onSelect:p,forceMount:f=!1,closeOnClick:d=!1,shortcut:a,forceOrder:R,forceScore:b,render:P,className:g,style:S,onClick:C,onPointerDown:L,onPointerMove:D,children:I,...v}=o,{closeAll:u}=_chunkXMZZ62VJcjs.j.call(void 0, ),i=Ye.useRef(null),l=Ee({id:t,value:s,keywords:n,disabled:c,forceMount:f,shortcut:a,forceOrder:R,forceScore:b,closeOnClick:d,children:I}),h=l.disabled;Ye.useEffect(()=>{let k=()=>{h||_optionalChain([i, 'access', _203 => _203.current, 'optionalAccess', _204 => _204.click, 'call', _205 => _205()])};return l.registerSelect(k)},[h,l]);let y=Ye.useMemo(()=>({highlighted:l.isHighlighted,disabled:h,first:l.positional.first,last:l.positional.last,firstInGroup:l.positional.firstInGroup,lastInGroup:l.positional.lastInGroup}),[l.isHighlighted,h,l.positional]),N=Ye.useCallback(k=>{if(_optionalChain([C, 'optionalCall', _206 => _206(k)]),!k.defaultPrevented){if(h){k.preventDefault();return}_optionalChain([p, 'optionalCall', _207 => _207()]),d&&!k.metaKey&&!k.ctrlKey&&!k.shiftKey&&!k.altKey&&u()}},[C,h,p,d,u]),F=Ye.useCallback(k=>{l.handlers.onPointerDown(k),_optionalChain([L, 'optionalCall', _208 => _208(k)])},[l.handlers,L]),T=Ye.useCallback(k=>{_optionalChain([D, 'optionalCall', _209 => _209(k)]),k.defaultPrevented||l.handlers.onPointerMove(k)},[D,l.handlers]),m=_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.f.Provider,{value:l.contextValue,children:I}),O=q(),G=W(O,"link-item");return _userender.useRender.call(void 0, {render:P,ref:[l.ref,l.rowRef,i,r],state:y,stateAttributesMapping:Wa,props:{...v,...G?{[G]:""}:{},id:l.id,role:"option",tabIndex:-1,"aria-selected":l.isHighlighted,"aria-disabled":h||void 0,className:g,style:S,onClick:N,onPointerMove:T,onPointerDown:F,children:m},enabled:l.isVisible,defaultTagName:"a"})});var Co=on.createContext(null);function is(){let e=on.useContext(Co);if(!e)throw new Error("PopupMenu.RadioItem must be used within PopupMenu.RadioGroup");return e}var Ya={disabled:e=>e?{"data-disabled":""}:null,firstGroup:e=>e?{"data-first-group":""}:null,lastGroup:e=>e?{"data-last-group":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null},Xa= exports.la =Ie.forwardRef(function(o,r){let{value:t,defaultValue:s,onValueChange:n,disabled:c=!1,forceMount:p=!1,render:f,className:d,style:a,children:R,...b}=o,{store:P}=_chunkXMZZ62VJcjs.p.call(void 0, ),g=Te(),S=Ie.useId(),C=Ie.useRef(null),[L,D]=Ie.useState(null),I=c||g.disabled,[v,u]=Ie.useState(s),i=t!==void 0,l=i?t:v,h=Ie.useCallback((E,U=_chunkXMZZ62VJcjs.a.itemPress,$)=>{let re=_chunkXMZZ62VJcjs.b.call(void 0, U,$);_optionalChain([n, 'optionalCall', _210 => _210(E,re)]),!re.isCanceled&&(i||u(E))},[i,n]);Ie.useEffect(()=>P.registerGroup(S,C),[S,P]),Ie.useLayoutEffect(()=>{if(L)return P.registerRow(S,L,{kind:"group"})},[L,S,P]);let y=P.useState("isGroupVisible",S),N=p||y,F=P.useState("isFirstGroup",S),T=P.useState("isLastGroup",S),m=P.useState("isFirstRow",S),O=P.useState("isLastRow",S),G=Ie.useMemo(()=>({value:l,setValue:h,disabled:I}),[l,h,I]),k=Ie.useMemo(()=>({groupId:S}),[S]),A=Ie.useMemo(()=>({disabled:I,firstGroup:F,lastGroup:T,first:m,last:O}),[I,F,T,m,O]),M=q(),w=W(M,"radio-group"),j=_userender.useRender.call(void 0, {render:f,ref:[C,D,r],state:A,stateAttributesMapping:Ya,props:{...b,...w?{[w]:""}:{},role:"group","aria-disabled":I||void 0,className:d,style:a,children:R},enabled:N,defaultTagName:"div"});return N?_jsxruntime.jsx.call(void 0, Co.Provider,{value:G,children:_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.d.Provider,{value:k,children:j})}):null});function _a(e){let{value:o,onValueChange:r,disabled:t=!1,children:s}=e,n=nn.useCallback((p,f=_chunkXMZZ62VJcjs.a.itemPress,d)=>{let a=_chunkXMZZ62VJcjs.b.call(void 0, f,d);_optionalChain([r, 'optionalCall', _211 => _211(p,a)])},[r]),c=nn.useMemo(()=>({value:o,setValue:n,disabled:t}),[o,n,t]);return _jsxruntime.jsx.call(void 0, Co.Provider,{value:c,children:s})}var ir=rn.createContext(null);function ps(){let e=rn.useContext(ir);if(!e)throw new Error("PopupMenu.RadioItemIndicator must be used within PopupMenu.RadioItem");return e}var ou={checked:e=>e?{"data-checked":""}:{"data-unchecked":""},highlighted:e=>e?{"data-highlighted":""}:null,disabled:e=>e?{"data-disabled":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstInGroup:e=>e?{"data-first-in-group":""}:null,lastInGroup:e=>e?{"data-last-in-group":""}:null},nu= exports.na =et.forwardRef(function(o,r){let{id:t,value:s,keywords:n,disabled:c=!1,onSelect:p,forceMount:f=!1,closeOnClick:d=!1,shortcut:a,forceOrder:R,forceScore:b,render:P,className:g,style:S,onClick:C,onPointerDown:L,onPointerMove:D,children:I,...v}=o,u=is(),i=c||u.disabled,l=u.value===s,h=Ee({id:t,keywords:n,disabled:i,forceMount:f,shortcut:a,forceOrder:R,forceScore:b,closeOnClick:d,children:I}),y=h.disabled;et.useEffect(()=>{let M=()=>{y||(u.setValue(s),_optionalChain([p, 'optionalCall', _212 => _212()]))};return h.registerSelect(M)},[y,u,s,p,h]);let N=et.useMemo(()=>({highlighted:h.isHighlighted,disabled:y,checked:l,first:h.positional.first,last:h.positional.last,firstInGroup:h.positional.firstInGroup,lastInGroup:h.positional.lastInGroup}),[h.isHighlighted,y,l,h.positional]),F=et.useMemo(()=>({...h.contextValue,checked:l}),[h.contextValue,l]),T=et.useCallback(M=>{_optionalChain([C, 'optionalCall', _213 => _213(M)]),M.defaultPrevented||h.handlers.onClick(M)},[C,h.handlers]),m=et.useCallback(M=>{h.handlers.onPointerDown(M),_optionalChain([L, 'optionalCall', _214 => _214(M)])},[h.handlers,L]),O=et.useCallback(M=>{_optionalChain([D, 'optionalCall', _215 => _215(M)]),M.defaultPrevented||h.handlers.onPointerMove(M)},[D,h.handlers]),G=q(),k=W(G,"radio-item"),A=_userender.useRender.call(void 0, {render:P,ref:[h.ref,h.rowRef,r],state:N,stateAttributesMapping:ou,props:{...v,...k?{[k]:""}:{},id:h.id,role:"menuitemradio",tabIndex:-1,"aria-checked":l,"aria-disabled":y||void 0,className:g,style:S,onClick:T,onPointerMove:O,onPointerDown:m,children:I},enabled:h.isVisible,defaultTagName:"div"});return h.isVisible?_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.f.Provider,{value:h.contextValue,children:_jsxruntime.jsx.call(void 0, ir.Provider,{value:F,children:A})}):null});var su={checked:e=>e?{"data-checked":""}:{"data-unchecked":""},disabled:e=>e?{"data-disabled":""}:null},au= exports.oa =sn.forwardRef(function(o,r){let{keepMounted:t=!1,render:s,className:n,style:c,children:p,...f}=o,{checked:d,highlighted:a,disabled:R}=ps(),b=sn.useMemo(()=>({checked:d,highlighted:a,disabled:R}),[d,a,R]),P=t||d,g=q(),S=W(g,"radio-item-indicator");return _userender.useRender.call(void 0, {render:s,ref:r,state:b,stateAttributesMapping:su,props:{...f,...S?{[S]:""}:{},"aria-hidden":!0,className:n,style:c,children:p},enabled:P,defaultTagName:"span"})});function Wt(e){let{surfaceId:o}=_chunkXMZZ62VJcjs.p.call(void 0, ),r=zo(),t=an.useId();an.useLayoutEffect(()=>{if(!(!r||!e))return r.registerZone(o,t,e)},[r,o,t,e])}var iu=un.forwardRef(function(o,r){let{render:t,className:s,style:n,...c}=o,[p,f]=un.useState(null);Wt(p);let d=q(),a=W(d,"focus-zone");return _userender.useRender.call(void 0, {render:t,ref:[f,r],state:{},props:{...c,...a?{[a]:""}:{},className:s,style:n},defaultTagName:"div"})});var pu=cn.forwardRef(function(o,r){let{render:t,className:s,style:n,...c}=o,[p,f]=cn.useState(null);Wt(p);let d=q(),a=W(d,"footer");return _userender.useRender.call(void 0, {render:t,ref:[f,r],state:{},props:{...c,...a?{[a]:""}:{},className:s,style:n},defaultTagName:"div"})});var du={first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstGroup:e=>e?{"data-first-group":""}:null,lastGroup:e=>e?{"data-last-group":""}:null},fu= exports.ra =Ae.forwardRef(function(o,r){let{forceMount:t=!1,render:s,className:n,style:c,children:p,...f}=o,{store:d}=_chunkXMZZ62VJcjs.p.call(void 0, ),a=Ae.useId(),R=Ae.useRef(null),[b,P]=Ae.useState(null);Ae.useEffect(()=>d.registerGroup(a,R),[a,d]),Ae.useLayoutEffect(()=>{if(b)return d.registerRow(a,b,{kind:"group"})},[b,a,d]);let g=d.useState("isGroupVisible",a),S=t||g,C=d.useState("isFirstGroup",a),L=d.useState("isLastGroup",a),D=d.useState("isFirstRow",a),I=d.useState("isLastRow",a),v=Ae.useMemo(()=>({groupId:a}),[a]),u=Ae.useMemo(()=>({hidden:!S,firstGroup:C,lastGroup:L,first:D,last:I}),[S,C,L,D,I]),i=q(),l=W(i,"group"),h=_userender.useRender.call(void 0, {render:s,ref:[R,P,r],state:u,stateAttributesMapping:du,props:{...f,...l?{[l]:""}:{},role:"presentation",className:n,style:c,children:p},enabled:S,defaultTagName:"div"});return S?_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.d.Provider,{value:v,children:h}):null});function gu(e){let{groupId:o,positional:r,children:t}=e,s=ds.useMemo(()=>({groupId:o,positional:r}),[o,r]);return _jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.d.Provider,{value:s,children:t})}var Ru=pn.forwardRef(function(o,r){let{render:t,className:s,style:n,...c}=o,[p,f]=pn.useState(null);Wt(p);let d=q(),a=W(d,"header");return _userender.useRender.call(void 0, {render:t,ref:[f,r],state:{},props:{...c,...a?{[a]:""}:{},className:s,style:n},defaultTagName:"div"})});var Pu={first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null},xu= exports.ua =st.forwardRef(function(o,r){let{alwaysRender:t=!1,render:s,className:n,style:c,...p}=o,{store:f}=_chunkXMZZ62VJcjs.p.call(void 0, ),d=st.useId(),[a,R]=st.useState(null);st.useLayoutEffect(()=>{if(a)return f.registerRow(d,a,{kind:"separator"})},[a,d,f]);let g=f.useState("normalizedSearch").length>0&&!t,S=f.useState("isFirstRow",d),C=f.useState("isLastRow",d),L=st.useMemo(()=>({first:S,last:C}),[S,C]),D=q(),I=W(D,"separator"),v=_userender.useRender.call(void 0, {render:s,ref:[R,r],state:L,stateAttributesMapping:Pu,props:{...p,...I?{[I]:""}:{},role:"none",className:n,style:c},defaultTagName:"div"});return g?null:v});var Mu={highlighted:e=>e?{"data-highlighted":""}:null},Cu= exports.va =ln.forwardRef(function(o,r){let{children:t,render:s,className:n,style:c,...p}=o,{shortcut:f,highlighted:d}=_chunkXMZZ62VJcjs.g.call(void 0, ),a=ln.useMemo(()=>({shortcut:f,highlighted:d}),[f,d]),R=typeof t=="function"?t(a):_nullishCoalesce(t, () => (f)),b=q(),P=W(b,"shortcut");return _userender.useRender.call(void 0, {render:s,ref:r,state:a,stateAttributesMapping:Mu,props:{...p,...P?{[P]:""}:{},className:n,style:c,children:R},defaultTagName:"kbd"})});var cr=dn.createContext(null);function Ut(){return dn.useContext(cr)}var ku={depth:e=>({"data-depth":String(e)})},Iu= exports.wa =fs.forwardRef(function(o,r){let{render:t,className:s,style:n,children:c,...p}=o,f=(_nullishCoalesce(_optionalChain([Ut, 'call', _216 => _216(), 'optionalAccess', _217 => _217.depth]), () => (0)))+1,d=q(),a=W(d,"tree"),b=_userender.useRender.call(void 0, {render:t,ref:r,state:{depth:f},stateAttributesMapping:ku,props:{...p,...a?{[a]:""}:{},role:"presentation",className:s,style:n,children:c},defaultTagName:"div"});return _jsxruntime.jsx.call(void 0, cr.Provider,{value:{depth:f},children:b})});function fn(e,o){return typeof e=="function"?r=>({...e(r),"--tree-depth":o}):{...e,"--tree-depth":o}}var Nu={depth:e=>({"data-depth":String(e)})},Lu= exports.xa =ms.forwardRef(function(o,r){let{depth:t,render:s,className:n,style:c,children:p,...f}=o,d=Ut(),a=_nullishCoalesce(_nullishCoalesce(t, () => (_optionalChain([d, 'optionalAccess', _218 => _218.depth]))), () => (0)),R=q(),b=W(R,"tree-connector");return _userender.useRender.call(void 0, {render:s,ref:r,state:{depth:a},stateAttributesMapping:Nu,props:{...f,...b?{[b]:""}:{},"aria-hidden":"true","data-depth":a,className:n,style:fn(c,a),children:p},defaultTagName:"span"})});var Ou=gs.forwardRef(function(o,r){let{selectable:t=!0,depth:s,style:n,children:c,...p}=o,f=Ut(),d=_nullishCoalesce(_nullishCoalesce(s, () => (_optionalChain([f, 'optionalAccess', _219 => _219.depth]))), () => (0)),a=q(),R=W(a,"tree-item");return _jsxruntime.jsx.call(void 0, ur,{...p,ref:r,activatable:t,style:fn(n,d),...R?{[R]:""}:{},"data-tree-item":"","data-depth":d,...t===!1?{"data-header":""}:{},children:c})});function Eu(e){let{open:o,onOpenChange:r,defaultOpen:t=!1,closeRootOnEsc:s=!0,virtualized:n=!1,items:c,onHighlightChange:p,onOpenChangeComplete:f,disabled:d=!1,actionsRef:a,children:R,...b}=e,P=_chunkXMZZ62VJcjs.k.call(void 0, ),g=ct(),S=_nullishCoalesce(_optionalChain([P, 'optionalAccess', _220 => _220.depth]), () => (0)),C=_optionalChain([P, 'optionalAccess', _221 => _221.closeAll]),L=_optionalChain([P, 'optionalAccess', _222 => _222.registerSurface]),D=Ko(),I=le.useCallback((B,x,K)=>{_optionalChain([p, 'optionalCall', _223 => _223(B,B===null?null:_nullishCoalesce(_optionalChain([D, 'optionalAccess', _224 => _224.getNodeById, 'call', _225 => _225(B)]), () => (null)),x,K)])},[D,p]),{surfaceId:v}=_chunkXMZZ62VJcjs.p.call(void 0, ),u=le.useId(),i=le.useRef(null),l=le.useRef(null),h=le.useRef(!1),y=_chunkXMZZ62VJcjs.y.useStore(void 0,{open:t}),[N,F]=le.useState(!1),T=(_nullishCoalesce(_optionalChain([g, 'optionalAccess', _226 => _226.disabled]), () => (!1)))||d||N,m=le.useCallback(B=>{F(B)},[]),O=le.useCallback(B=>{B&&T||y.setOpen(B)},[y,T]);y.useControlledProp("openProp",o);let G=vt(),k=y.useState("open");le.useEffect(()=>{k?G.open(u):G.close(u)},[k,u,G]);let A=le.useCallback((B,x)=>{_optionalChain([r, 'optionalCall', _227 => _227(B,x)]),!x.isCanceled&&O(B)},[O,r]),M=le.useCallback(B=>{!B&&y.context.clearSearchOnClose==="after-exit"&&(y.clearSearch(),y.setInputActive(!1)),B||(y.clearHighlight(),_optionalChain([y, 'access', _228 => _228.context, 'access', _229 => _229.onCloseComplete, 'optionalCall', _230 => _230()]),_optionalChain([y, 'access', _231 => _231.context, 'access', _232 => _232.onPopupCloseComplete, 'optionalCall', _233 => _233()])),_optionalChain([f, 'optionalCall', _234 => _234(B)])},[y,f]),[w,j]=le.useState(!0);le.useEffect(()=>{if(!P)return;let B=P.store,x=()=>{let V=B.state.open;j(V)};return x(),B.observe("open",x)},[P]),le.useEffect(()=>{w||O(!1)},[w,O]);let E=S+1;le.useEffect(()=>{if(L)return L(E,B=>O(B))},[L,E,O]);let U=le.useRef(null);le.useImperativeHandle(a,()=>({close:()=>{_optionalChain([U, 'access', _235 => _235.current, 'optionalAccess', _236 => _236.close, 'call', _237 => _237()])},unmount:()=>{_optionalChain([U, 'access', _238 => _238.current, 'optionalAccess', _239 => _239.unmount, 'call', _240 => _240()])},setDisabled:m}),[m]);let $=le.useMemo(()=>({open:k,setOpen:O,suppressAutoOpenRef:h,triggerRef:i,contentRef:l,parentSurfaceId:v,childSurfaceId:u,closeRootOnEsc:s}),[k,O,v,u,s]),re=le.useCallback(()=>()=>{},[]),H=le.useMemo(()=>{if(!(!n&&!p))return{virtualized:n,items:_nullishCoalesce(c, () => ([])),onHighlightChange:I}},[n,c,I,p]),ne=le.useMemo(()=>({store:y,depth:E,closeAll:_nullishCoalesce(C, () => ((()=>y.setOpen(!1)))),registerSurface:_nullishCoalesce(L, () => (re)),virtualization:H}),[y,E,C,L,re,H]),Q=le.useMemo(()=>({store:y,disabled:T,depth:E,closeAll:_nullishCoalesce(C, () => ((()=>O(!1)))),explicitTabBehavior:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _241 => _241.explicitTabBehavior]), () => (!1)),tabWithoutZones:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _242 => _242.tabWithoutZones]), () => ("close")),registerSurface:_nullishCoalesce(L, () => (re)),virtualization:H,virtualAnchor:_optionalChain([g, 'optionalAccess', _243 => _243.virtualAnchor]),menuType:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _244 => _244.menuType]), () => ("dropdown")),closeOnOutsidePress:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _245 => _245.closeOnOutsidePress]), () => ("pointerdown"))}),[y,T,E,C,_optionalChain([g, 'optionalAccess', _246 => _246.explicitTabBehavior]),_optionalChain([g, 'optionalAccess', _247 => _247.tabWithoutZones]),L,O,re,H,_optionalChain([g, 'optionalAccess', _248 => _248.virtualAnchor]),_optionalChain([g, 'optionalAccess', _249 => _249.menuType]),_optionalChain([g, 'optionalAccess', _250 => _250.closeOnOutsidePress])]);return _jsxruntime.jsx.call(void 0, Lo.Provider,{value:$,children:_jsxruntime.jsx.call(void 0, it.Provider,{value:Q,children:_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.i.Provider,{value:ne,children:_jsxruntime.jsx.call(void 0, _popover.Popover.Root,{...b,open:k,onOpenChange:A,onOpenChangeComplete:M,actionsRef:a?U:void 0,children:R})})})})}function bs(e,o,r){let t=[],s=e.left-o;s>0&&t.push({side:"left",gap:s});let n=o-e.right;n>0&&t.push({side:"right",gap:n});let c=e.top-r;c>0&&t.push({side:"top",gap:c});let p=r-e.bottom;if(p>0&&t.push({side:"bottom",gap:p}),t.length>0)return t.sort((d,a)=>a.gap-d.gap),t[0].side;let f=[{side:"left",value:Math.abs(o-e.left)},{side:"right",value:Math.abs(o-e.right)},{side:"top",value:Math.abs(r-e.top)},{side:"bottom",value:Math.abs(r-e.bottom)}];return f.sort((d,a)=>d.value-a.value),f[0].side}function gn(e,o,r,t){if(o){let s=(o.left+o.right)/2,n=(o.top+o.bottom)/2;return bs(e,s,n)}if(t===void 0){if(r<e.left)return"left";if(r>e.right)return"right";let s=(e.left+e.right)/2;return r<=s?"left":"right"}return bs(e,r,t)}function pr(e,o,r,t,s,n){let c=0,p=0,f=Math.min(Math.max(e.length-1,0),4);for(let a=e.length-f-1;a<e.length-1;a++){if(a<0)continue;let[R,b]=e[a],[P,g]=e[a+1];c+=P-R,p+=g-b}if(Math.hypot(c,p)<.5){let a=s?(s.left+s.right)/2:o,R=s?(s.top+s.bottom)/2:r;if(t==="left"||t==="right"){let b=t==="right"?n.right:n.left,P=(n.top+n.bottom)/2;c=b-a,p=P-R}else{let b=t==="top"?n.top:n.bottom;c=(n.left+n.right)/2-a,p=b-R}}return{dx:c,dy:p}}function lr(e,o,r,t,s,n){let{dx:c,dy:p}=r,f=s==="left"||s==="right",d=f?c:p;if(Math.abs(d)<.01||s==="left"&&c<=0||s==="right"&&c>=0||s==="top"&&p<=0||s==="bottom"&&p>=0)return!1;let R=((s==="left"?t.left:s==="right"?t.right:s==="top"?t.top:t.bottom)-(f?e:o))/d;if(R<=0)return!1;let b=f?o+R*p:e+R*c,P=n?f?n.height:n.width:null,g=P?P*.75:28,S=Math.max(12,Math.min(36,g)),C=(f?t.top:t.left)-S*.25,L=(f?t.bottom:t.right)+S*.25;return b>=C&&b<=L}function vo(e,o=!1){let r=["mouse","pen"];return o||r.push("",void 0),r.includes(e)}var hn=new Set,bn=null;function Au(){if(bn!==null||typeof window>"u")return;let e=o=>{for(let r of hn){let t=r.trailRef.current;t.push([o.clientX,o.clientY]),t.length>r.limit&&t.shift()}};window.addEventListener("pointermove",e,{passive:!0}),bn=()=>{window.removeEventListener("pointermove",e),bn=null}}function Fu(){hn.size===0&&_optionalChain([bn, 'optionalCall', _251 => _251()])}function hs(e=4){let o=Rn.useRef([]);return Rn.useEffect(()=>{let r={trailRef:o,limit:e};return hn.add(r),Au(),()=>{hn.delete(r),o.current=[],Fu()}},[e]),o}function Rs(){let[e,o]=Sn.useState([0,0]);return Sn.useEffect(()=>{let r=t=>{o([t.clientX,t.clientY])};return window.addEventListener("pointermove",r,{passive:!0}),()=>{window.removeEventListener("pointermove",r)}},[]),e}function xs(e){let{config:o,contentRef:r,triggerRef:t,tone:s,contentRectOverride:n,triggerRectOverride:c,mousePointOverride:p}=e,[f,d]=Rs(),a=Ps.useMemo(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches:!1,[]),R=r.current,b=_nullishCoalesce(n, () => (_optionalChain([R, 'optionalAccess', _252 => _252.getBoundingClientRect, 'call', _253 => _253()])));if(!b||a||typeof document>"u"||!document.body)return null;let P=_nullishCoalesce(c, () => ((t.current?t.current.getBoundingClientRect():null))),g=_nullishCoalesce(_optionalChain([p, 'optionalAccess', _254 => _254[0]]), () => (f)),S=_nullishCoalesce(_optionalChain([p, 'optionalAccess', _255 => _255[1]]), () => (d)),C=b.left,L=b.top,D=b.width,I=b.height;if(!D||!I)return null;let v=gn(b,P,g,S);if(v==="top"||v==="bottom"||v==="left"&&g>=C||v==="right"&&g<=C+D)return null;let u=2,i=Math.max(0,Math.min(100,(S-L)/I*100)),l=v==="left"?Math.max(C-g,10)+u:Math.max(g-(C+D),10)+u,h=Math.max(0,Math.min(1,o.overlayOpacity)),y=Math.max(0,Math.min(1,o.triangleFillOpacity)),N=o.showStroke?Math.max(0,o.strokeWidth):0,F=o.showDots?Math.max(0,o.dotRadius):0,T=Math.max(1,Math.min(l,I)/2),m=Math.min(Math.max(F,N/2)+.5,T),O=o.showDots?Math.max(0,Math.min(F,m-N/2-.5)):0,G=Math.max(m,Math.min(I-m,i/100*I)),k=v==="left"?C-l:C+D,A=o.idleColor;s==="activated"?A=o.successColor:s==="missed"&&(A=o.missColor);let M=v==="left"?[[l-m,m],[m,G],[l-m,I-m]]:[[m,m],[m,I-m],[l-m,G]],w=M.map(([E,U])=>`${E},${U}`).join(" "),j=_jsxruntime.jsxs.call(void 0, "svg",{"data-bazzaui-submenu-safe-triangle-area":"","data-safe-triangle-tone":s,"aria-hidden":!0,viewBox:`0 0 ${l} ${I}`,style:{position:"fixed",top:L,left:k,width:l,height:I,pointerEvents:"none",zIndex:Number.MAX_SAFE_INTEGER,transform:"translateZ(0)",opacity:h},children:[_jsxruntime.jsx.call(void 0, "polygon",{points:w,fill:A,fillOpacity:y,stroke:o.showStroke?A:"none",strokeWidth:N,strokeDasharray:o.showStroke?o.strokeDasharray:void 0,strokeLinecap:"round",strokeLinejoin:"round"}),o.showDots?M.map(([E,U])=>_jsxruntime.jsx.call(void 0, "circle",{cx:E,cy:U,r:O,fill:A},`${E}-${U}`)):null]});return _reactdom.createPortal.call(void 0, j,document.body)}var zu={popupOpen:e=>e?{"data-popup-open":""}:null,popupFocused:e=>e?{"data-popup-focused":""}:null},Qu= exports.Aa =Pn.forwardRef(function(o,r){let{render:t,className:s,style:n,children:c,...p}=o,{open:f,childSurfaceId:d}=eo(),R=Pe().useState("isOwner",d),b=Pn.useMemo(()=>({popupOpen:f,popupFocused:R}),[f,R]),P=q(),g=W(P,"submenu-trigger-indicator");return _userender.useRender.call(void 0, {render:t,ref:r,state:b,stateAttributesMapping:zu,props:{...p,...g?{[g]:""}:{},"aria-hidden":!0,className:s,style:n,children:c},defaultTagName:"span"})});var Wu={submenuTrigger:e=>e?{"data-submenu-trigger":""}:null,popupOpen:e=>e?{"data-popup-open":""}:null,popupFocused:e=>e?{"data-popup-focused":""}:null,highlighted:e=>e?{"data-highlighted":""}:null,disabled:e=>e?{"data-disabled":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstInGroup:e=>e?{"data-first-in-group":""}:null,lastInGroup:e=>e?{"data-last-in-group":""}:null},Uu= exports.Ba =Y.forwardRef(function(o,r){let{id:t,value:s,keywords:n,disabled:c=!1,forceMount:p=!1,openOnHighlight:f=!0,delay:d,closeDelay:a=0,closeOnPointerLeave:R=!0,forceOrder:b,forceScore:P,render:g,className:S,style:C,onPointerDown:L,onPointerMove:D,onPointerEnter:I,onPointerLeave:v,children:u,...i}=o,l=Y.useMemo(()=>typeof d=="number"?{pointer:d,keyboard:d}:{pointer:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _256 => _256.pointer]), () => (0)),keyboard:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _257 => _257.keyboard]), () => (150))},[d]),{store:h}=_chunkXMZZ62VJcjs.p.call(void 0, ),{depth:y}=_chunkXMZZ62VJcjs.j.call(void 0, ),N=y-1,F=eo(),{open:T,setOpen:m,suppressAutoOpenRef:O,triggerRef:G,contentRef:k,childSurfaceId:A}=F,M=Y.useRef(null),w=Y.useRef(null),j=Y.useRef(null),E=Y.useRef(null),U=Y.useCallback(()=>{M.current!==null&&(clearTimeout(M.current),M.current=null)},[]),$=Y.useCallback(()=>{w.current!==null&&(clearTimeout(w.current),w.current=null)},[]),re=Y.useCallback(()=>{if(R){if($(),a<=0){m(!1);return}w.current=setTimeout(()=>{w.current=null,m(!1)},a)}},[$,a,R,m]),H=Y.useCallback(()=>{j.current&&(j.current(),j.current=null),E.current!==null&&(clearTimeout(E.current),E.current=null)},[]);Y.useEffect(()=>()=>{U(),$(),H()},[U,$,H]);let ne=Pe(),{aimGuardActive:Q,guardedTriggerId:B,guardedDepth:x,aimGuardActiveRef:K,guardedTriggerIdRef:V,guardedDepthRef:X,activateAimGuard:te,clearAimGuard:J}=zt(),fe=hs(4),{showSafeTriangleArea:Oe,logAimGuardEvents:We}=Bo(),me=Oe.enabled,[ie,Fe]=Y.useState("hidden"),[Xe,we]=Y.useState(null),ye=Y.useRef(null),Z=Ee({id:t,value:s,keywords:n,disabled:c,forceMount:p,forceOrder:b,forceScore:P,isSubmenuTrigger:!0,closeOnClick:!1,children:u}),Ue=Z.disabled,se=Y.useCallback((z,oe)=>{We&&console.log(`[PopupMenu][AimGuard] ${z}`,{triggerId:Z.id,triggerStoreId:Z.storeId,parentDepth:N,aimGuardActive:K.current,guardedTriggerId:V.current,guardedDepth:X.current,...oe})},[We,Z.id,Z.storeId,N,K,V,X]),De=Y.useCallback(()=>{ye.current!==null&&(clearTimeout(ye.current),ye.current=null)},[]);Y.useEffect(()=>De,[De]);let Pt=Y.useCallback(z=>{me&&(De(),Oe.freezeOnPointerLeave?we(z):we(null),Fe("activated"))},[me,Oe.freezeOnPointerLeave,De]),ee=Y.useCallback(z=>{if(De(),!me||!Oe.showMissState){Fe("hidden"),we(null);return}Fe("missed"),we(z);let oe=Oe.missFreezeDuration;if(oe<=0){Fe("hidden"),we(null);return}ye.current=setTimeout(()=>{ye.current=null,Fe("hidden"),we(null)},oe)},[De,me,Oe.showMissState,Oe.missFreezeDuration]),Ze=Y.useCallback((z,oe,Re,Me,at,Gt)=>{if(H(),se("leave-monitor-start",{anchor:z,initialHit:Re,timeoutMs:Me,closeDelay:a,triggerRect:oe,initialPointerX:at,initialPointerY:Gt}),Me<=0){se("leave-monitor-skip-timeout",{timeoutMs:Me});return}let Ct=Re,ot=at,Yt=Gt,Xt=mr=>{if(!vo(mr.pointerType))return;let ut=_optionalChain([k, 'access', _258 => _258.current, 'optionalAccess', _259 => _259.getBoundingClientRect, 'call', _260 => _260()]);if(!ut){se("leave-monitor-stop-no-content-rect"),H();return}let{clientX:Ve,clientY:Be}=mr,ys=Ve>=ut.left&&Ve<=ut.right&&Be>=ut.top&&Be<=ut.bottom,Et=z==="left"||z==="right"?Ve-ot:Be-Yt;if(ot=Ve,Yt=Be,ys){se("leave-monitor-inside-popup",{clientX:Ve,clientY:Be}),$(),H();return}let gr=z==="left"&&Et<=-2||z==="right"&&Et>=2||z==="top"&&Et<=-2||z==="bottom"&&Et>=2;if(se("leave-monitor-pointermove",{anchor:z,clientX:Ve,clientY:Be,axisDelta:Et,movedAwayFromSubmenu:gr,lastHit:Ct}),Ct&&gr){let Ms={contentRect:ut,triggerRect:oe,pointerX:Ve,pointerY:Be};Ct=!1,se("leave-monitor-reversal-close",{anchor:z,clientX:Ve,clientY:Be,axisDelta:Et}),ee(Ms),J(),re(),(a<=0||!R)&&H();return}let br=pr(fe.current,Ve,Be,z,oe,ut),ko=lr(Ve,Be,br,ut,z,oe);if(se("leave-monitor-hit-eval",{anchor:z,clientX:Ve,clientY:Be,hit:ko,lastHit:Ct,heading:br}),ko===Ct)return;let hr={contentRect:ut,triggerRect:oe,pointerX:Ve,pointerY:Be};if(Ct=ko,ko){se("leave-monitor-hit-transition",{anchor:z,clientX:Ve,clientY:Be}),Pt(hr),$(),te(Z.id,N,A,600),h.setHighlightedId(Z.storeId),m(!0);return}se("leave-monitor-miss-transition",{anchor:z,clientX:Ve,clientY:Be}),ee(hr),J(),re(),(a<=0||!R)&&H()};window.addEventListener("pointermove",Xt,{passive:!0}),j.current=()=>{se("leave-monitor-cleanup-remove-listener"),window.removeEventListener("pointermove",Xt)},E.current=setTimeout(()=>{E.current=null,se("leave-monitor-timeout-expired",{timeoutMs:Me}),H()},Me)},[H,se,k,$,fe,Pt,te,Z.id,N,A,h,Z.storeId,m,ee,J,re,a,R]);Y.useEffect(()=>{me||(De(),Fe("hidden"),we(null))},[me,De]),Y.useEffect(()=>{if(!me||Oe.persistOnSuccess||ie!=="activated")return;Q&&B===Z.id&&x===N||(De(),Fe("hidden"),we(null))},[me,Oe.persistOnSuccess,ie,Q,B,x,Z.id,N,De]),Y.useEffect(()=>{ie!=="activated"||T||(De(),Fe("hidden"),we(null))},[ie,T,De]),Y.useEffect(()=>{T||($(),H())},[T,$,H]),Y.useEffect(()=>{T||!K.current||V.current!==Z.id||X.current!==N||J()},[T,Z.id,N,K,V,X,J]),Y.useEffect(()=>{Z.isVisible||!K.current||V.current!==Z.id||X.current!==N||J()},[Z.isVisible,Z.id,N,K,V,X,J]),Y.useEffect(()=>()=>{K.current&&V.current===Z.id&&X.current===N&&J()},[Z.id,N,K,V,X,J]),Y.useEffect(()=>{if(!T)return;let z=k.current;if(!z)return;let oe=()=>{$(),H()},Re=()=>{$(),H()};return z.addEventListener("pointerenter",oe),z.addEventListener("pointermove",Re,{passive:!0}),()=>{z.removeEventListener("pointerenter",oe),z.removeEventListener("pointermove",Re)}},[T,k,$,H]),Y.useEffect(()=>h.registerSubmenuOpen(Z.storeId,()=>{m(!0),ne.setOwnerId(A),requestAnimationFrame(()=>{let z=_optionalChain([k, 'access', _261 => _261.current, 'optionalAccess', _262 => _262.querySelector, 'call', _263 => _263("input")]),oe=_optionalChain([k, 'access', _264 => _264.current, 'optionalAccess', _265 => _265.querySelector, 'call', _266 => _266('[role="listbox"]')]),Re=_nullishCoalesce(z, () => (oe));Re&&Re instanceof HTMLElement&&Re.focus()})}),[Z.storeId,h,m,ne,A,k]),Y.useEffect(()=>h.registerSubmenuClose(Z.storeId,()=>m(!1)),[Z.storeId,h,m]);let xt=ne.useState("isOwner",A);Y.useEffect(()=>{!Z.isVisible&&T&&m(!1)},[Z.isVisible,T,m]),Y.useEffect(()=>{Z.isHighlighted||(O.current=!1)},[Z.isHighlighted,O]),Y.useEffect(()=>{if(!f)return;if(!Z.isHighlighted||h.state.highlightSource!=="keyboard"){U();return}if(O.current)return;let z=l.keyboard;return z<=0?m(!0):M.current=setTimeout(()=>{M.current=null,!O.current&&m(!0)},z),U},[Z.isHighlighted,h,l.keyboard,m,U,f]),Y.useEffect(()=>(G.current=Z.ref.current,()=>{G.current=null}),[G,Z.ref]);let Nt=Y.useCallback(z=>{z.preventDefault(),T&&(O.current=!0,se("pointerdown-suppress-auto-open",{clientX:z.clientX,clientY:z.clientY})),_optionalChain([L, 'optionalCall', _267 => _267(z)])},[T,se,L,O]),$t=Y.useCallback(z=>{if(_optionalChain([D, 'optionalCall', _268 => _268(z)]),z.defaultPrevented||Ue||!vo(z.pointerType)||!h.shouldAllowPointerHighlight(z.clientX,z.clientY))return;if(K.current&&X.current===N&&V.current!==Z.id){se("pointermove-blocked-by-guard",{clientX:z.clientX,clientY:z.clientY,blockedByTriggerId:V.current});return}if(h.setHighlightedId(Z.storeId),!f||T)return;if(O.current){se("pointermove-open-suppressed-after-explicit-close",{clientX:z.clientX,clientY:z.clientY});return}H(),$();let oe=l.pointer;if(oe<=0){m(!0);return}M.current===null&&(M.current=setTimeout(()=>{M.current=null,m(!0)},oe))},[D,Ue,K,X,N,V,Z.id,Z.storeId,f,T,O,H,$,l.pointer,m,se,h]),Lt=Y.useCallback(z=>{if(_optionalChain([I, 'optionalCall', _269 => _269(z)]),z.defaultPrevented||Ue||!vo(z.pointerType))return;if(K.current&&X.current===N&&V.current!==Z.id){se("pointerenter-blocked-by-guard",{clientX:z.clientX,clientY:z.clientY,blockedByTriggerId:V.current,blockedByDepth:X.current});return}if(se("pointerenter-submenu-trigger",{clientX:z.clientX,clientY:z.clientY}),me&&(De(),we(null),Fe("hover")),h.setHighlightedId(Z.storeId),!f)return;if(O.current){se("pointerenter-open-suppressed-after-explicit-close",{clientX:z.clientX,clientY:z.clientY});return}H(),J(),U(),$();let oe=l.pointer;oe<=0?m(!0):M.current=setTimeout(()=>{M.current=null,m(!0)},oe)},[I,Ue,K,X,V,Z.id,Z.storeId,h,f,O,H,J,U,$,De,me,l.pointer,m,se,N]),yt=Y.useCallback(z=>{if(_optionalChain([v, 'optionalCall', _270 => _270(z)]),z.defaultPrevented||Ue||!vo(z.pointerType))return;if(U(),se("pointerleave-submenu-trigger",{clientX:z.clientX,clientY:z.clientY}),K.current&&X.current===N&&V.current!==Z.id){se("pointerleave-blocked-by-guard",{clientX:z.clientX,clientY:z.clientY,blockedByTriggerId:V.current,blockedByDepth:X.current});return}let oe=_optionalChain([k, 'access', _271 => _271.current, 'optionalAccess', _272 => _272.getBoundingClientRect, 'call', _273 => _273()]);if(!oe){se("pointerleave-no-content-rect"),H(),De(),Fe("hidden"),we(null),J(),re();return}let{clientX:Re,clientY:Me}=z,at=_nullishCoalesce(_optionalChain([G, 'access', _274 => _274.current, 'optionalAccess', _275 => _275.getBoundingClientRect, 'call', _276 => _276()]), () => (null)),Gt={contentRect:oe,triggerRect:at,pointerX:Re,pointerY:Me};if(Re>=oe.left&&Re<=oe.right&&Me>=oe.top&&Me<=oe.bottom){se("pointerleave-inside-popup-success",{clientX:Re,clientY:Me}),Pt(Gt),$(),H(),J();return}let ot=gn(oe,at,Re,Me),Yt=pr(fe.current,Re,Me,ot,at,oe),Xt=lr(Re,Me,Yt,oe,ot,at);se("pointerleave-hit-eval",{anchor:ot,hit:Xt,clientX:Re,clientY:Me,heading:Yt}),Xt?(se("pointerleave-hit-activate-guard",{anchor:ot,clientX:Re,clientY:Me}),Pt(Gt),te(Z.id,N,A,600),h.setHighlightedId(Z.storeId),m(!0),Ze(ot,at,!0,600,Re,Me)):(se("pointerleave-miss-close",{anchor:ot,clientX:Re,clientY:Me}),ee(Gt),J(),re(),R&&a>0?Ze(ot,at,!1,a,Re,Me):H())},[v,Ue,U,K,X,V,Z.id,Z.storeId,a,R,k,H,De,J,Pt,ee,m,$,re,Ze,G,fe,te,N,A,h,se]),_e=Y.useMemo(()=>({submenuTrigger:!0,popupOpen:T,popupFocused:xt,highlighted:Z.isHighlighted,disabled:Ue,first:Z.positional.first,last:Z.positional.last,firstInGroup:Z.positional.firstInGroup,lastInGroup:Z.positional.lastInGroup}),[T,xt,Z.isHighlighted,Ue,Z.positional]),mt=_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.f.Provider,{value:Z.contextValue,children:u}),gt=q(),Ot=W(gt,"submenu-trigger"),fr=_userender.useRender.call(void 0, {render:g,ref:[Z.ref,Z.rowRef,r],state:_e,stateAttributesMapping:Wu,props:{...i,...Ot?{[Ot]:""}:{},id:Z.id,role:"menuitem","aria-haspopup":"menu","aria-expanded":T,tabIndex:-1,"aria-disabled":Ue||void 0,className:S,style:C,onPointerMove:$t,onPointerDown:Nt,onPointerEnter:Lt,onPointerLeave:yt,children:mt},defaultTagName:"div"}),Mt=Y.useMemo(()=>ie==="hover"?"hover":ie==="activated"?"activated":ie==="missed"?"missed":null,[ie]),Tt=_jsxruntime.jsx.call(void 0, _popover.Popover.Trigger,{nativeButton:!1,disabled:Ue,render:fr});return Z.isVisible?!me||Mt===null?Tt:_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[Tt,_jsxruntime.jsx.call(void 0, xs,{config:Oe,contentRef:k,triggerRef:G,tone:Mt,contentRectOverride:_optionalChain([Xe, 'optionalAccess', _277 => _277.contentRect]),triggerRectOverride:_optionalChain([Xe, 'optionalAccess', _278 => _278.triggerRect]),mousePointOverride:Xe?[Xe.pointerX,Xe.pointerY]:null})]}):null});function Yu(e){let{pageId:o,closeRootOnEsc:r=!1,children:t}=e,s=_chunkXMZZ62VJcjs.k.call(void 0, ),n=ct(),c=kt();if(!s||!n)throw new Error("PopupMenu.Subpage must be used within PopupMenu.Popup");let p=_chunkXMZZ62VJcjs.y.useStore(void 0,{open:!1}),f=tt.useId(),d=s.store.useState("open"),a=c.activePageId,R=c.stack,b=c.registerPage,P=c.goBack,g=c.getSurfaceId,S=c.rootSurfaceId,C=a===o&&g(o)===f;tt.useEffect(()=>b({pageId:o,surfaceId:f,closeRootOnEsc:r}),[b,o,f,r]),tt.useEffect(()=>{p.setOpen(d&&C)},[p,d,C]),tt.useEffect(()=>s.registerSurface(s.depth,i=>p.setOpen(i)),[s,p]);let L=tt.useMemo(()=>{let i=R.lastIndexOf(o);if(i<=0)return S;let l=R[i-1];return l===void 0?null:g(l)},[R,o,g,S]),D=tt.useMemo(()=>({pageId:o,surfaceId:f,parentSurfaceId:L,isActive:C,closeRootOnEsc:r,goBack:P}),[o,f,L,C,r,P]),I=tt.useMemo(()=>({store:p,depth:s.depth,closeAll:s.closeAll,registerSurface:s.registerSurface,virtualization:s.virtualization}),[p,s]),v=tt.useMemo(()=>({store:p,depth:n.depth,closeAll:n.closeAll,explicitTabBehavior:n.explicitTabBehavior,tabWithoutZones:n.tabWithoutZones,registerSurface:n.registerSurface,virtualization:n.virtualization,virtualAnchor:n.virtualAnchor,menuType:n.menuType,disabled:n.disabled,closeOnOutsidePress:n.closeOnOutsidePress}),[p,n]),u=C;return _jsxruntime.jsx.call(void 0, Oo.Provider,{value:D,children:_jsxruntime.jsx.call(void 0, Bt.Provider,{value:f,children:_jsxruntime.jsx.call(void 0, it.Provider,{value:v,children:_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.i.Provider,{value:I,children:u?t:null})})})})}var _u={canGoBack:e=>e?{"data-can-go-back":""}:null,disabled:e=>e?{"data-disabled":""}:null},Ju= exports.Da =Zt.forwardRef(function(o,r){let{disabled:t=!1,render:s,className:n,style:c,onClick:p,children:f,...d}=o,a=oo(),R=kt(),b=Pe(),P=Te(),g=t||P.disabled,S=Zt.useCallback(I=>{if(_optionalChain([p, 'optionalCall', _279 => _279(I)]),I.defaultPrevented||g)return;a.goBack()&&a.parentSurfaceId&&b.setOwnerId(a.parentSurfaceId)},[p,g,a,b]),C=Zt.useMemo(()=>({canGoBack:R.canGoBack,disabled:g}),[R.canGoBack,g]),L=q(),D=W(L,"subpage-back");return _userender.useRender.call(void 0, {render:s,ref:r,state:C,stateAttributesMapping:_u,props:{...d,...D?{[D]:""}:{},type:"button",disabled:g,className:n,style:c,onClick:S,children:f},defaultTagName:"button"})});var ti={subpageBackItem:e=>e?{"data-subpage-back-item":""}:null,highlighted:e=>e?{"data-highlighted":""}:null,disabled:e=>e?{"data-disabled":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstInGroup:e=>e?{"data-first-in-group":""}:null,lastInGroup:e=>e?{"data-last-in-group":""}:null},oi= exports.Ea =Le.forwardRef(function(o,r){let{id:t,value:s,keywords:n,disabled:c=!1,forceMount:p=!1,onSelect:f,onSelectAsync:d,render:a,className:R,style:b,onClick:P,onPointerMove:g,onPointerDown:S,children:C,...L}=o,D=oo(),I=Pe(),[v,u]=Le.useState(!1),i=Le.useRef(null);Le.useEffect(()=>()=>{_optionalChain([i, 'access', _280 => _280.current, 'optionalAccess', _281 => _281.abort, 'call', _282 => _282()])},[]);let l=Le.useCallback(()=>{let M=D.goBack();return M&&D.parentSurfaceId&&I.setOwnerId(D.parentSurfaceId),M},[D,I]),h=Le.useCallback(()=>{if(d){if(v)return;_optionalChain([i, 'access', _283 => _283.current, 'optionalAccess', _284 => _284.abort, 'call', _285 => _285()]);let M=new AbortController;i.current=M,u(!0);let w=!1,j={goBack:()=>{let E=l();return E&&(w=!0),E},signal:M.signal};d(j).then(E=>{M.signal.aborted||E!==!1&&!w&&j.goBack()}).catch(()=>{}).finally(()=>{M.signal.aborted||u(!1)});return}_optionalChain([f, 'optionalCall', _286 => _286()]),l()},[f,d,l,v]),y=Ee({id:t,value:s,keywords:n,disabled:c||v,forceMount:p,closeOnClick:!1,onSelect:h,children:C}),N=y.disabled,F=Le.useMemo(()=>({subpageBackItem:!0,highlighted:y.isHighlighted,disabled:N,first:y.positional.first,last:y.positional.last,firstInGroup:y.positional.firstInGroup,lastInGroup:y.positional.lastInGroup}),[y.isHighlighted,N,y.positional]),T=Le.useCallback(M=>{_optionalChain([P, 'optionalCall', _287 => _287(M)]),M.defaultPrevented||y.handlers.onClick(M)},[P,y.handlers]),m=Le.useCallback(M=>{y.handlers.onPointerDown(M),_optionalChain([S, 'optionalCall', _288 => _288(M)])},[y.handlers,S]),O=Le.useCallback(M=>{_optionalChain([g, 'optionalCall', _289 => _289(M)]),M.defaultPrevented||y.handlers.onPointerMove(M)},[g,y.handlers]),G=_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.f.Provider,{value:y.contextValue,children:C}),k=q(),A=W(k,"subpage-back-item");return _userender.useRender.call(void 0, {render:a,ref:[y.ref,y.rowRef,r],state:F,stateAttributesMapping:ti,props:{...L,...A?{[A]:""}:{},id:y.id,role:"option",tabIndex:-1,"aria-selected":y.isHighlighted,"aria-disabled":N||void 0,className:R,style:b,onClick:T,onPointerMove:O,onPointerDown:m,children:G},enabled:y.isVisible,defaultTagName:"div"})});var si={subpageTrigger:e=>e?{"data-subpage-trigger":""}:null,popupOpen:e=>e?{"data-popup-open":""}:null,popupFocused:e=>e?{"data-popup-focused":""}:null,highlighted:e=>e?{"data-highlighted":""}:null,disabled:e=>e?{"data-disabled":""}:null,first:e=>e?{"data-first":""}:null,last:e=>e?{"data-last":""}:null,firstInGroup:e=>e?{"data-first-in-group":""}:null,lastInGroup:e=>e?{"data-last-in-group":""}:null},ai= exports.Fa =ft.forwardRef(function(o,r){let{id:t,value:s,keywords:n,disabled:c=!1,forceMount:p=!1,forceOrder:f,forceScore:d,targetPageId:a,render:R,className:b,style:P,onClick:g,onPointerDown:S,onPointerMove:C,children:L,...D}=o,I=Pe(),v=kt(),u=v.activePageId,i=v.openPage,l=v.getSurfaceId,h=ft.useCallback(()=>{if(!i(a))return;let U=l(a);U&&I.setOwnerId(U)},[i,l,a,I]),y=Ee({id:t,value:s,keywords:n,disabled:c,forceMount:p,forceOrder:f,forceScore:d,isSubmenuTrigger:!1,closeOnClick:!1,onSelect:h,children:L}),N=y.disabled,F=u===a,T=l(a),m=I.useState("isOwner",_nullishCoalesce(T, () => (""))),O=ft.useCallback(E=>{y.handlers.onPointerDown(E),_optionalChain([S, 'optionalCall', _290 => _290(E)])},[y.handlers,S]),G=ft.useCallback(E=>{_optionalChain([g, 'optionalCall', _291 => _291(E)]),E.defaultPrevented||y.handlers.onClick(E)},[y.handlers,g]),k=ft.useCallback(E=>{_optionalChain([C, 'optionalCall', _292 => _292(E)]),E.defaultPrevented||y.handlers.onPointerMove(E)},[C,y.handlers]),A=ft.useMemo(()=>({subpageTrigger:!0,popupOpen:F,popupFocused:m,highlighted:y.isHighlighted,disabled:N,first:y.positional.first,last:y.positional.last,firstInGroup:y.positional.firstInGroup,lastInGroup:y.positional.lastInGroup}),[F,m,y.isHighlighted,N,y.positional]),M=_jsxruntime.jsx.call(void 0, _chunkXMZZ62VJcjs.f.Provider,{value:y.contextValue,children:L}),w=q(),j=W(w,"subpage-trigger");return _userender.useRender.call(void 0, {render:R,ref:[y.ref,y.rowRef,r],state:A,stateAttributesMapping:si,props:{...D,...j?{[j]:""}:{},id:y.id,role:"menuitem","aria-haspopup":"menu","aria-expanded":F,tabIndex:-1,"aria-disabled":N||void 0,className:b,style:P,onPointerDown:O,onClick:G,onPointerMove:k,children:M},enabled:y.isVisible,defaultTagName:"div"})});exports.a = Pe; exports.b = vt; exports.c = it; exports.d = Te; exports.e = ct; exports.f = Bt; exports.g = eo; exports.h = Ke; exports.i = oo; exports.j = pt; exports.k = ro; exports.l = kt; exports.m = so; exports.n = ao; exports.o = vn; exports.p = kn; exports.q = ws; exports.r = On; exports.s = Os; exports.t = Es; exports.u = Gn; exports.v = Tr; exports.w = zi; exports.x = jt; exports.y = io; exports.z = co; exports.A = En; exports.B = An; exports.C = po; exports.D = Fs; exports.E = Vs; exports.F = It; exports.G = fo; exports.H = Fr; exports.I = Vr; exports.J = Br; exports.K = qs; exports.L = Zs; exports.M = qr; exports.N = _s; exports.O = ea; exports.P = Ee; exports.Q = Ro; exports.R = tp; exports.S = Zr; exports.T = $r; exports.U = na; exports.V = aa; exports.W = ia; exports.X = Qn; exports.Y = la; exports.Z = So; exports._ = Po; exports.$ = xo; exports.aa = da; exports.ba = rr; exports.ca = Ma; exports.da = ka; exports.ea = wa; exports.fa = Na; exports.ga = Ga; exports.ha = Va; exports.ia = ja; exports.ja = ur; exports.ka = Ua; exports.la = Xa; exports.ma = _a; exports.na = nu; exports.oa = au; exports.pa = iu; exports.qa = pu; exports.ra = fu; exports.sa = gu; exports.ta = Ru; exports.ua = xu; exports.va = Cu; exports.wa = Iu; exports.xa = Lu; exports.ya = Ou; exports.za = Eu; exports.Aa = Qu; exports.Ba = Uu; exports.Ca = Yu; exports.Da = Ju; exports.Ea = oi; exports.Fa = ai;
2
+ //# sourceMappingURL=chunk-Z2RGBRJP.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-EYMK7XHC.cjs","../src/internal/popup-menu/contexts/focus-owner-context.ts","../src/internal/popup-menu/contexts/open-chain-context.ts","../src/internal/popup-menu/contexts/popup-menu-context.ts","../src/internal/popup-menu/contexts/popup-surface-id-context.ts","../src/internal/popup-menu/contexts/submenu-context.ts","../src/internal/popup-menu/contexts/subpage-context.ts","../src/internal/popup-menu/contexts/subpage-stack-context.ts","../src/internal/popup-menu/store/FocusOwnerStore.ts","../src/internal/popup-menu/hooks/use-popup-menu-root.ts","../src/internal/popup-menu/menu-tree/resolve.ts"],"names":["FocusOwnerContext","useFocusOwner","context","OpenChainContext","useOpenChain","PopupMenuContext","usePopupMenuContext","useMaybePopupMenuContext","PopupSurfaceIdContext","usePopupSurfaceId","SubmenuContext","useSubmenuContext","useMaybeSubmenuContext","SubpageContext","useSubpageContext","useMaybeSubpageContext","SubpageStackContext","useSubpageStack","useMaybeSubpageStack","selectors","createSelector","state","surfaceId","FocusOwnerStore","ReactStore","id","isPopupMenuNode","value","encodeDefinitionPathEntry","entry","encoded","index","codeUnit","isSafe"],"mappings":"AAAA,ugCAAyM,o0FCElL,IAOjBA,EAAAA,CAA0B,EAAA,CAAA,aAAA,CAAsC,IAAI,CAAA,CAEnE,SAASC,EAAAA,CAAAA,CAAiC,CAC/C,IAAMC,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWF,EAAiB,CAAA,CAClD,EAAA,CAAI,CAACE,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,gEACF,CAAA,CAEF,OAAOA,CACT,CCjBA,IAOMC,EAAAA,CAAyB,EAAA,CAAA,aAAA,CAAqC,IAAI,CAAA,CAEjE,SAASC,EAAAA,CAAAA,CAA+B,CAC7C,IAAMF,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWC,EAAgB,CAAA,CACjD,EAAA,CAAI,CAACD,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,+DACF,CAAA,CAEF,OAAOA,CACT,CCjBA,IAiGMG,EAAAA,CAAyB,EAAA,CAAA,aAAA,CAA4C,IAAI,CAAA,CAMxE,SAASC,EAAAA,CAAAA,CAA6C,CAC3D,IAAMJ,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWG,EAAgB,CAAA,CACjD,EAAA,CAAI,CAACH,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,+EACF,CAAA,CAEF,OAAOA,CACT,CAMO,SAASK,EAAAA,CAAAA,CAAyD,CACvE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAgB,CAC1C,CCvHA,IAaMG,EAAAA,CAA8B,EAAA,CAAA,aAAA,CAA6B,IAAI,CAAA,CAE9D,SAASC,EAAAA,CAAAA,CAAmC,CACjD,OAAa,EAAA,CAAA,UAAA,CAAWD,EAAqB,CAC/C,CCjBA,IA8BME,EAAAA,CAAuB,EAAA,CAAA,aAAA,CAA0C,IAAI,CAAA,CAEpE,SAASC,EAAAA,CAAAA,CAAyC,CACvD,IAAMT,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWQ,EAAc,CAAA,CAC/C,EAAA,CAAI,CAACR,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,8CAA8C,CAAA,CAEhE,OAAOA,CACT,CAEO,SAASU,EAAAA,CAAAA,CAAqD,CACnE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAc,CACxC,CC1CA,IAiBMG,EAAAA,CAAuB,EAAA,CAAA,aAAA,CAA0C,IAAI,CAAA,CAEpE,SAASC,EAAAA,CAAAA,CAAyC,CACvD,IAAMZ,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWW,EAAc,CAAA,CAC/C,EAAA,CAAI,CAACX,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,4DACF,CAAA,CAEF,OAAOA,CACT,CAEO,SAASa,EAAAA,CAAAA,CAAqD,CACnE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAc,CACxC,CC/BA,IA+BMG,EAAAA,CACE,EAAA,CAAA,aAAA,CAA+C,IAAI,CAAA,CAEpD,SAASC,EAAAA,CAAAA,CAA4C,CAC1D,IAAMf,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWc,EAAmB,CAAA,CACpD,EAAA,CAAI,CAACd,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,0DAA0D,CAAA,CAE5E,OAAOA,CACT,CAEO,SAASgB,EAAAA,CAAAA,CAAwD,CACtE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAmB,CAC7C,CC9CA,6CAA2C,IAerCG,EAAAA,CAAY,CAChB,OAAA,CAASC,mCAAAA,CAAgBC,EAA2BA,CAAAA,CAAM,OAAO,CAAA,CACjE,OAAA,CAASD,mCAAAA,CACNC,CAAAA,CAAwBC,CAAAA,CAAAA,EAAsBD,CAAAA,CAAM,OAAA,GAAYC,CACnE,CACF,CAAA,CAaaC,EAAAA,aAAN,MAAA,QAA8BC,iBAInC,CACA,WAAA,CAAA,CAAc,CACZ,KAAA,CAAM,CAAE,OAAA,CAAS,IAAK,CAAA,CAAG,CAAC,CAAA,CAAGL,EAAS,CACxC,CAMA,UAAA,CAAWM,CAAAA,CAAmB,CAC5B,IAAA,CAAK,GAAA,CAAI,SAAA,CAAWA,CAAE,CACxB,CAMA,UAAA,CAAA,CAAa,CACX,IAAA,CAAK,GAAA,CAAI,SAAA,CAAW,IAAI,CAC1B,CACF,CAAA,CCvDA,SCOgBC,EAAAA,CAAgBC,CAAAA,CAAwC,CACtE,OACE,OAAOA,CAAAA,EAAU,QAAA,EACjBA,CAAAA,GAAU,IAAA,EACV,KAAA,GAASA,CAAAA,EACT,OAAQA,CAAAA,CAAwB,EAAA,EAAO,QAAA,EACvC,OAAQA,CAAAA,CAAwB,aAAA,EAAkB,QAAA,EAClD,KAAA,CAAM,OAAA,CAASA,CAAAA,CAAwB,cAAc,CAAA,EACrD,KAAA,CAAM,OAAA,CAASA,CAAAA,CAAwB,QAAQ,CAAA,EAC/C,OAAQA,CAAAA,CAAwB,KAAA,EAAU,QAAA,EAC1C,QAAA,GAAYA,CAEhB,CAEA,SAASC,EAAAA,CAA0BC,CAAAA,CAAuB,CACxD,IAAIC,CAAAA,CAAU,EAAA,CACd,GAAA,CAAA,IAASC,CAAAA,CAAQ,CAAA,CAAGA,CAAAA,CAAQF,CAAAA,CAAM,MAAA,CAAQE,CAAAA,EAAS,CAAA,CAAG,CACpD,IAAMC,CAAAA,CAAWH,CAAAA,CAAM,UAAA,CAAWE,CAAK,CAAA,CACjCE,CAAAA,CACHD,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,EAAA,EAChCA,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,GAAA,EAChCA,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,EAAA,EACjCA,CAAAA,GAAa,EAAA,EACbA,CAAAA,GAAa,EAAA,EACbA,CAAAA,GAAa,GAAA,EACbA,CAAAA,GAAa,EAAA,CACfF,CAAAA,EAAWG,CAAAA,CACP,MAAA,CAAO,YAAA,CAAaD,CAAQ,CAAA,CAC5B,CAAA,CAAA,EAAIA,CAAAA,CAAS,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,CAAG,GAAG,CAAC,CAAA,CAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-EYMK7XHC.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\nimport type { FocusOwnerStore } from '../store/FocusOwnerStore.js'\n\n// ============================================================================\n// Focus Owner Context\n// ============================================================================\n\nconst FocusOwnerContext = React.createContext<FocusOwnerStore | null>(null)\n\nexport function useFocusOwner(): FocusOwnerStore {\n const context = React.useContext(FocusOwnerContext)\n if (!context) {\n throw new Error(\n 'FocusOwner components must be used within a FocusOwnerProvider',\n )\n }\n return context\n}\n\nexport function useMaybeFocusOwner(): FocusOwnerStore | null {\n return React.useContext(FocusOwnerContext)\n}\n\nexport { FocusOwnerContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { OpenChainStore } from '../store/OpenChainStore.js'\n\n// ============================================================================\n// Open Chain Context\n// ============================================================================\n\nconst OpenChainContext = React.createContext<OpenChainStore | null>(null)\n\nexport function useOpenChain(): OpenChainStore {\n const context = React.useContext(OpenChainContext)\n if (!context) {\n throw new Error(\n 'OpenChain components must be used within an OpenChainProvider',\n )\n }\n return context\n}\n\nexport function useMaybeOpenChain(): OpenChainStore | null {\n return React.useContext(OpenChainContext)\n}\n\nexport { OpenChainContext }\n","'use client'\n\nimport * as React from 'react'\nimport type {\n ListboxStore,\n VirtualItem,\n} from '../../listbox/store/ListboxStore.js'\nimport type {\n HighlightChangeEventDetails,\n PopupMenuOpenChangeReason,\n} from '../events.js'\n\n// ============================================================================\n// Popup Menu Context\n// ============================================================================\n// Shared root-level context for popup menus (DropdownMenu, ContextMenu).\n// Provides core menu functionality to all child components.\n\n/**\n * Virtual anchor for positioning the menu at a specific point.\n * Used by ContextMenu to position at cursor location.\n */\nexport interface VirtualAnchor {\n getBoundingClientRect(): DOMRect\n}\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\n/**\n * Shared context value for popup menus.\n * Both DropdownMenu.Root and ContextMenu.Root provide this context.\n */\nexport interface PopupMenuContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Whether this menu tree currently ignores user interaction. */\n disabled: boolean\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: (reason?: PopupMenuOpenChangeReason, event?: Event) => void\n /**\n * Internal: when true, Surface handles Tab explicitly (close the tree, or\n * cycle through focus zones). Enabled only by DropdownMenu.Root and\n * ContextMenu.Root — never Select or Combobox.\n */\n explicitTabBehavior: boolean\n /**\n * Internal: what Tab does under `explicitTabBehavior` when the surface (and\n * its ancestors) have no focus-zone tabbables. `'close'` closes the whole\n * tree (dropdown/context-menu). `'inert'` swallows the event, keeping focus\n * where it is (command palette).\n */\n tabWithoutZones: 'close' | 'inert'\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n /**\n * Virtual anchor for positioning.\n * Used by ContextMenu to position at cursor location.\n * DropdownMenu uses the Popover's anchor (trigger button) instead.\n */\n virtualAnchor?: VirtualAnchor\n /**\n * Type of menu for positioning logic.\n * - 'dropdown': positions relative to trigger button\n * - 'context': positions at cursor with fixed positioning\n */\n menuType: 'dropdown' | 'context'\n /**\n * When to close the menu on outside interactions.\n * - 'pointerdown': Close immediately when pointer is pressed outside (default)\n * - 'click': Close when a full click (pointerdown + pointerup) occurs outside\n * @default 'pointerdown'\n */\n closeOnOutsidePress: 'click' | 'pointerdown'\n}\n\nconst PopupMenuContext = React.createContext<PopupMenuContextValue | null>(null)\n\n/**\n * Hook to access the popup menu context.\n * Throws if used outside a popup menu.\n */\nexport function usePopupMenuContext(): PopupMenuContextValue {\n const context = React.useContext(PopupMenuContext)\n if (!context) {\n throw new Error(\n 'PopupMenu components must be used within a PopupMenu.Root or ContextMenu.Root',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally access the popup menu context.\n * Returns null if used outside a popup menu.\n */\nexport function useMaybePopupMenuContext(): PopupMenuContextValue | null {\n return React.useContext(PopupMenuContext)\n}\n\n// Re-export for convenience\nexport type { VirtualItem }\nexport { PopupMenuContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Popup Surface ID Context\n// ============================================================================\n\n/**\n * Context for passing surfaceId from Popup to Surface.\n * This ensures Popup and Surface share the same ID for data attribute tracking.\n *\n * For root menus, Popup generates the ID and provides it via this context.\n * For submenus, the ID comes from SubmenuContext.childSurfaceId instead.\n */\nconst PopupSurfaceIdContext = React.createContext<string | null>(null)\n\nexport function usePopupSurfaceId(): string | null {\n return React.useContext(PopupSurfaceIdContext)\n}\n\nexport { PopupSurfaceIdContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubmenuContextValue {\n /** Whether the submenu is open */\n open: boolean\n /** Set the submenu open state */\n setOpen: (open: boolean) => void\n /**\n * Latch set by explicit close actions (keyboard ArrowLeft/Ctrl+H/Escape-in-submenu,\n * or clicking the open trigger). While set and the trigger remains highlighted,\n * pointer/keyboard auto-open is suppressed. Reset when highlight leaves the trigger.\n */\n suppressAutoOpenRef: React.MutableRefObject<boolean>\n /** Reference to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Reference to the submenu content element (for aim guard rect calculations) */\n contentRef: React.RefObject<HTMLElement | null>\n /** Surface ID of the parent menu (for keyboard navigation back) */\n parentSurfaceId: string\n /** Surface ID of this submenu (for keyboard navigation into) */\n childSurfaceId: string\n /**\n * Whether pressing Escape in this submenu closes the entire menu from the root.\n * When true, Escape closes the entire menu tree.\n * When false, Escape only closes this submenu and moves focus to the parent.\n * @default true\n */\n closeRootOnEsc: boolean\n}\n\nconst SubmenuContext = React.createContext<SubmenuContextValue | null>(null)\n\nexport function useSubmenuContext(): SubmenuContextValue {\n const context = React.useContext(SubmenuContext)\n if (!context) {\n throw new Error('SubmenuTrigger must be used within a Submenu')\n }\n return context\n}\n\nexport function useMaybeSubmenuContext(): SubmenuContextValue | null {\n return React.useContext(SubmenuContext)\n}\n\nexport { SubmenuContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubpageContextValue {\n /** Current page ID. */\n pageId: string\n /** Surface ID for this page. */\n surfaceId: string\n /** Surface ID for the previous page, if available. */\n parentSurfaceId: string | null\n /** Whether this page is currently active. */\n isActive: boolean\n /** Whether Escape should close the entire menu tree from this page. */\n closeRootOnEsc: boolean\n /** Navigate back one page. Returns true when navigation happened. */\n goBack: () => boolean\n}\n\nconst SubpageContext = React.createContext<SubpageContextValue | null>(null)\n\nexport function useSubpageContext(): SubpageContextValue {\n const context = React.useContext(SubpageContext)\n if (!context) {\n throw new Error(\n 'Subpage components must be used within a PopupMenu.Subpage',\n )\n }\n return context\n}\n\nexport function useMaybeSubpageContext(): SubpageContextValue | null {\n return React.useContext(SubpageContext)\n}\n\nexport { SubpageContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubpageRegistration {\n pageId: string\n surfaceId: string\n closeRootOnEsc: boolean\n}\n\nexport interface SubpageStackContextValue {\n /** Active page ID; `null` when the root surface is active. */\n activePageId: string | null\n /** Surface ID of the root surface. */\n rootSurfaceId: string\n /** Surface ID for the currently active page. */\n activeSurfaceId: string\n /** Whether there is a previous page to navigate back to. */\n canGoBack: boolean\n /** Whether Escape in the active page should close the entire menu tree. */\n shouldCloseRootOnEsc: boolean\n /** Open page IDs, bottom to top; empty at root. */\n stack: readonly string[]\n /** Register a page and return an unregister cleanup. */\n registerPage: (registration: SubpageRegistration) => () => void\n /** Push a page onto the stack. Returns true when navigation happened. */\n openPage: (pageId: string) => boolean\n /** Pop one page from the stack. Returns true when navigation happened. */\n goBack: () => boolean\n /** Resolve a surface ID for a page ID. */\n getSurfaceId: (pageId: string) => string | null\n}\n\nconst SubpageStackContext =\n React.createContext<SubpageStackContextValue | null>(null)\n\nexport function useSubpageStack(): SubpageStackContextValue {\n const context = React.useContext(SubpageStackContext)\n if (!context) {\n throw new Error('Subpage components must be used within a PopupMenu.Popup')\n }\n return context\n}\n\nexport function useMaybeSubpageStack(): SubpageStackContextValue | null {\n return React.useContext(SubpageStackContext)\n}\n\nexport { SubpageStackContext }\n","import { createSelector, ReactStore } from '@base-ui/utils/store'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface FocusOwnerState {\n /** Which surface currently owns focus (surfaceId or null) */\n ownerId: string | null\n}\n\n// ============================================================================\n// Selectors\n// ============================================================================\n\nconst selectors = {\n ownerId: createSelector((state: FocusOwnerState) => state.ownerId),\n isOwner: createSelector(\n (state: FocusOwnerState, surfaceId: string) => state.ownerId === surfaceId,\n ),\n}\n\n// ============================================================================\n// Store\n// ============================================================================\n\n/**\n * Tracks which menu surface owns DOM focus.\n * Single instance per menu tree (created at root, shared via context).\n *\n * Used by: DropdownMenu, ContextMenu\n * Not used by: Select, CommandMenu (single surface)\n */\nexport class FocusOwnerStore extends ReactStore<\n FocusOwnerState,\n Record<string, never>,\n typeof selectors\n> {\n constructor() {\n super({ ownerId: null }, {}, selectors)\n }\n\n /**\n * Set the owner surface ID.\n * Call this when focus should transfer to a new surface.\n */\n setOwnerId(id: string | null) {\n this.set('ownerId', id)\n }\n\n /**\n * Clear the owner (set to null).\n * Call this when the menu tree closes.\n */\n clearOwner() {\n this.set('ownerId', null)\n }\n}\n\nexport type { FocusOwnerState as State }\n","'use client'\n\nimport * as React from 'react'\nimport type { ChangeEventDetails } from '../../../utils/events/index.js'\nimport {\n createChangeEventDetails,\n REASONS,\n} from '../../../utils/events/index.js'\nimport { ensureInputModalityTracking } from '../../../utils/input-modality.js'\nimport { ListboxStore, type VirtualItem } from '../../listbox/index.js'\nimport type { VirtualizationConfig } from '../contexts/popup-menu-context.js'\nimport type {\n HighlightChangeEventDetails,\n PopupMenuHighlightChangeHandler,\n PopupMenuOpenChangeReason,\n} from '../events.js'\nimport type { MenuTreeResolver } from '../menu-tree/resolver.js'\nimport { createMenuTreeResolver } from '../menu-tree/resolver.js'\nimport type { GetResolvedIdFn, PopupMenuIdScope } from '../menu-tree/types.js'\nimport { FocusOwnerStore } from '../store/FocusOwnerStore.js'\nimport { OpenChainStore } from '../store/OpenChainStore.js'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface UsePopupMenuRootParams {\n /**\n * Computes canonical Resolved IDs for data-first content from the Unresolved Menu Node (definitional facts only).\n * @default explicit `def.id` verbatim, else the joined definition path\n * Read once when the menu root mounts — later changes have no effect.\n */\n getResolvedId?: GetResolvedIdFn\n /** Definition Key uniqueness scope. Read once when the menu root mounts. */\n idScope?: PopupMenuIdScope\n /**\n * Callback when the open state changes.\n * The second parameter contains event details including the reason for the change.\n */\n onOpenChange?: (\n open: boolean,\n eventDetails: ChangeEventDetails<string>,\n ) => void\n\n /**\n * Whether the menu is initially open.\n * @default false\n */\n defaultOpen?: boolean\n\n /**\n * Whether virtualization mode is enabled.\n * @default false\n */\n virtualized?: boolean\n\n /**\n * Pre-registered items for virtualization.\n */\n items?: VirtualItem[]\n\n /**\n * Callback when the highlighted item changes. `id` is first; `node` is the\n * resolved menu node enrichment and may be null.\n * The fourth parameter contains event details including the reason for the change.\n */\n onHighlightChange?: PopupMenuHighlightChangeHandler<HighlightChangeEventDetails>\n\n /**\n * When to close the menu on outside interactions.\n * - 'pointerdown': Close immediately when pointer is pressed outside (default)\n * - 'click': Close when a full click (pointerdown + pointerup) occurs outside\n * @default 'pointerdown'\n */\n closeOnOutsidePress?: 'click' | 'pointerdown'\n\n /**\n * Whether the menu should ignore user interaction.\n * Can be controlled declaratively via this prop, or imperatively via actionsRef.setDisabled().\n * @default false\n */\n disabled?: boolean\n\n /**\n * Initial disabled state for imperative usage.\n * Ignored when `disabled` prop is true.\n * @default false\n */\n defaultDisabled?: boolean\n}\n\nexport interface PopupMenuRootActions {\n /** Close the menu tree imperatively. */\n close: () => void\n /** Unmount the popup imperatively (when keep-mounted mode is enabled). */\n unmount: () => void\n /** Enable/disable the menu tree imperatively. */\n setDisabled: (disabled: boolean) => void\n}\n\nexport interface UsePopupMenuRootReturn {\n /** The menu-tree resolver for this menu root. */\n menuTreeResolver: MenuTreeResolver\n /** The Listbox store instance */\n store: ListboxStore\n /** The FocusOwner store instance */\n focusOwnerStore: FocusOwnerStore\n /** The OpenChain store instance */\n openChainStore: OpenChainStore\n /** Register a surface (submenu) for closeAll tracking */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Close the entire menu tree */\n closeAll: (reason?: PopupMenuOpenChangeReason, event?: Event) => void\n /** Virtualization configuration (if enabled) */\n virtualization: VirtualizationConfig | undefined\n /** Handle open state change (updates store and clears stores on close) */\n handleOpenChange: (\n open: boolean,\n reason?: PopupMenuOpenChangeReason,\n event?: Event,\n ) => void\n /** Whether the menu currently ignores user interaction. */\n disabled: boolean\n /** Update imperative disabled state. */\n setDisabled: (disabled: boolean) => void\n}\n\n// ============================================================================\n// Hook\n// ============================================================================\n\n/**\n * Hook that creates and manages the core stores and utilities for popup menus.\n * Used by both DropdownMenu.Root and ContextMenu.Root.\n *\n * Provides:\n * - ListboxStore for item management\n * - FocusOwnerStore for focus tracking across submenus\n * - OpenChainStore for tracking open submenu chain\n * - Surface registry for closeAll functionality\n */\nexport function usePopupMenuRoot(\n params: UsePopupMenuRootParams = {},\n): UsePopupMenuRootReturn {\n const {\n onOpenChange,\n defaultOpen = false,\n virtualized = false,\n items: itemsProp,\n onHighlightChange,\n closeOnOutsidePress = 'pointerdown',\n disabled: disabledProp = false,\n defaultDisabled = false,\n getResolvedId,\n idScope = 'surface',\n } = params\n\n const menuTreeResolverRef = React.useRef<MenuTreeResolver | null>(null)\n if (menuTreeResolverRef.current === null) {\n menuTreeResolverRef.current = createMenuTreeResolver({\n getResolvedId,\n idScope,\n })\n }\n const menuTreeResolver = menuTreeResolverRef.current\n\n const handleHighlightChange = React.useCallback(\n (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => {\n onHighlightChange?.(\n id,\n id === null ? null : (menuTreeResolver.getNodeById(id) ?? null),\n index,\n eventDetails,\n )\n },\n [menuTreeResolver, onHighlightChange],\n )\n\n const [imperativeDisabled, setImperativeDisabled] =\n React.useState(defaultDisabled)\n const disabled = disabledProp || imperativeDisabled\n\n const setDisabled = React.useCallback((nextDisabled: boolean) => {\n setImperativeDisabled(nextDisabled)\n }, [])\n\n // Begin tracking global input modality so the store can attribute opens to\n // mouse/touch/pen/keyboard. Idempotent; installed once for the whole app.\n React.useEffect(() => {\n ensureInputModalityTracking()\n }, [])\n\n // Track outside pointer events to distinguish outside-press from focus-out\n // When a pointerdown happens outside the menu, we store it so that if a\n // focus-out close happens immediately after, we can treat it as outside-press\n const outsidePointerEventRef = React.useRef<PointerEvent | null>(null)\n\n // Create stable callback wrapper for onOpenChange that converts focus-out to outside-press\n // when the close was triggered by a pointer event outside the menu\n const stableOnOpenChange = React.useCallback(\n (open: boolean, eventDetails: ChangeEventDetails<string>) => {\n // If closing due to focus-out but we have a stored outside pointer event,\n // convert the reason to outside-press for better cancel() support\n if (\n !open &&\n eventDetails.reason === REASONS.focusOut &&\n outsidePointerEventRef.current\n ) {\n const pointerEvent = outsidePointerEventRef.current\n outsidePointerEventRef.current = null\n\n // Create new event details with outside-press reason and the pointer event\n const convertedDetails = createChangeEventDetails(\n REASONS.outsidePress,\n pointerEvent,\n )\n\n onOpenChange?.(open, convertedDetails)\n\n // If the converted callback canceled, also cancel the original\n if (convertedDetails.isCanceled) {\n eventDetails.cancel()\n }\n return\n }\n\n // Clear the pointer event ref if we're not using it\n outsidePointerEventRef.current = null\n\n onOpenChange?.(open, eventDetails)\n },\n [onOpenChange],\n )\n\n // Create the store instance\n const store = ListboxStore.useStore(\n undefined,\n { open: defaultOpen },\n {\n onOpenChange: stableOnOpenChange,\n },\n )\n\n // Get current open state for the pointer event listener\n const isOpen = store.useState('open')\n\n // Create focus owner store (single instance for entire menu tree)\n const focusOwnerStoreRef = React.useRef<FocusOwnerStore | null>(null)\n if (!focusOwnerStoreRef.current) {\n focusOwnerStoreRef.current = new FocusOwnerStore()\n }\n const focusOwnerStore = focusOwnerStoreRef.current\n\n // Create open chain store (single instance for entire menu tree)\n const openChainStoreRef = React.useRef<OpenChainStore | null>(null)\n if (!openChainStoreRef.current) {\n openChainStoreRef.current = new OpenChainStore()\n }\n const openChainStore = openChainStoreRef.current\n\n // Registry for tracking open submenus (for closeAll)\n type SurfaceEntry = { depth: number; setOpen: (open: boolean) => void }\n const surfaceRegistryRef = React.useRef<Map<string, SurfaceEntry>>(new Map())\n\n // Register a surface (submenu) for closeAll tracking\n const registerSurface = React.useCallback(\n (depth: number, setOpen: (open: boolean) => void) => {\n const id = Math.random().toString(36).slice(2)\n surfaceRegistryRef.current.set(id, { depth, setOpen })\n return () => {\n surfaceRegistryRef.current.delete(id)\n }\n },\n [],\n )\n\n // Close the entire menu tree from deepest submenu to root\n const closeAll = React.useCallback(\n (reason: PopupMenuOpenChangeReason = REASONS.itemPress, event?: Event) => {\n // Sort surfaces by depth (deepest first)\n const surfaces = [...surfaceRegistryRef.current.values()].sort(\n (a, b) => b.depth - a.depth,\n )\n\n // Close each submenu from deepest to shallowest\n for (const surface of surfaces) {\n surface.setOpen(false)\n }\n\n // Finally close the root\n store.setOpen(false, reason, event)\n\n // Clear focus ownership and open chain\n focusOwnerStore.clearOwner()\n openChainStore.clear()\n },\n [store, focusOwnerStore, openChainStore],\n )\n\n // Ref to hold closeAll for use in the pointerdown effect\n const closeAllRef = React.useRef(closeAll)\n closeAllRef.current = closeAll\n\n // Listen for pointerdown events on document to detect outside clicks\n // This is a single listener at the root level that handles the entire menu tree.\n // Behavior depends on closeOnOutsidePress:\n // - 'pointerdown': Close immediately when pointer is pressed outside\n // - 'click': Store event and convert focus-out to outside-press reason\n React.useEffect(() => {\n if (!isOpen || disabled) {\n outsidePointerEventRef.current = null\n return\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Element | null\n if (!target) return\n\n // Check if the pointerdown is inside any part of the menu tree or its triggers\n // base-ui sets data-open on popups and data-popup-open on triggers\n const isInsidePopup = target.closest('[data-open]') !== null\n const isInsideTrigger = target.closest('[data-popup-open]') !== null\n const isInside = isInsidePopup || isInsideTrigger\n\n if (closeOnOutsidePress === 'pointerdown' && !isInside) {\n // Close entire menu tree immediately on pointerdown outside\n closeAllRef.current(REASONS.outsidePress, event)\n } else {\n // Store the event for focus-out-to-outside-press conversion\n outsidePointerEventRef.current = event\n }\n }\n\n // Use capture phase to see the event before any stopPropagation\n document.addEventListener('pointerdown', handlePointerDown, true)\n return () => {\n document.removeEventListener('pointerdown', handlePointerDown, true)\n outsidePointerEventRef.current = null\n }\n }, [isOpen, closeOnOutsidePress, disabled])\n\n // Handle open state change\n const handleOpenChange = React.useCallback(\n (\n newOpen: boolean,\n reason: PopupMenuOpenChangeReason = REASONS.none,\n event?: Event,\n ) => {\n const isImperativeAction = reason === REASONS.imperativeAction\n\n // Ignore user-driven open/close interactions while disabled.\n if (disabled && !isImperativeAction) {\n return\n }\n\n store.setOpen(newOpen, reason, event)\n // Clear focus ownership and open chain when menu closes\n if (!newOpen) {\n focusOwnerStore.clearOwner()\n openChainStore.clear()\n }\n },\n [store, focusOwnerStore, openChainStore, disabled],\n )\n\n // Memoize listbox wiring config\n const virtualization = React.useMemo(() => {\n if (!virtualized && !onHighlightChange) {\n return undefined\n }\n\n return {\n virtualized,\n items: itemsProp ?? [],\n onHighlightChange: handleHighlightChange,\n }\n }, [virtualized, itemsProp, handleHighlightChange, onHighlightChange])\n\n return {\n menuTreeResolver,\n store,\n focusOwnerStore,\n openChainStore,\n registerSurface,\n closeAll,\n virtualization,\n handleOpenChange,\n disabled,\n setDisabled,\n }\n}\n","import { slugify } from '../../listbox/utils/normalize.js'\nimport type { NodeDef } from '../data-first/types.js'\nimport type {\n GetResolvedIdFn,\n PopupMenuIdScope,\n PopupMenuNode,\n UnresolvedMenuNode,\n} from './types.js'\n\nexport function isPopupMenuNode(value: unknown): value is PopupMenuNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'def' in value &&\n typeof (value as PopupMenuNode).id === 'string' &&\n typeof (value as PopupMenuNode).definitionKey === 'string' &&\n Array.isArray((value as PopupMenuNode).definitionPath) &&\n Array.isArray((value as PopupMenuNode).children) &&\n typeof (value as PopupMenuNode).depth === 'number' &&\n 'parent' in value\n )\n}\n\nfunction encodeDefinitionPathEntry(entry: string): string {\n let encoded = ''\n for (let index = 0; index < entry.length; index += 1) {\n const codeUnit = entry.charCodeAt(index)\n const isSafe =\n (codeUnit >= 0x41 && codeUnit <= 0x5a) ||\n (codeUnit >= 0x61 && codeUnit <= 0x7a) ||\n (codeUnit >= 0x30 && codeUnit <= 0x39) ||\n codeUnit === 0x2e ||\n codeUnit === 0x5f ||\n codeUnit === 0x7e ||\n codeUnit === 0x2d\n encoded += isSafe\n ? String.fromCharCode(codeUnit)\n : `%${codeUnit.toString(16).padStart(4, '0')}`\n }\n return encoded\n}\n\n/** Default Resolved ID, using surface-scoped encoded paths unless menu scope is selected. */\nexport function defaultGetResolvedId(\n node: UnresolvedMenuNode,\n idScope: PopupMenuIdScope = 'surface',\n): string {\n if (idScope === 'menu') return node.definitionKey\n return node.definitionPath.map(encodeDefinitionPathEntry).join('/')\n}\n\n/** Definition Key for a def: explicit `id` verbatim, else slugified `value`. */\nexport function definitionKeyForDef(def: NodeDef): string {\n switch (def.kind) {\n case 'group':\n case 'radio-group':\n return def.id\n case 'separator':\n return def.id\n default:\n return def.id ?? slugify(def.value)\n }\n}\n\n/** Child defs of a def, in def order; empty for leaf kinds. */\nexport function childDefsOf(def: NodeDef): readonly NodeDef[] {\n switch (def.kind) {\n case 'group':\n case 'radio-group':\n return def.nodes\n case 'submenu':\n case 'subpage':\n case 'tree-item':\n return def.nodes ?? []\n default:\n return []\n }\n}\n\n/** Kinds whose Definition Key is part of their descendants' definition paths. */\nexport function contributesDefinitionPath(def: NodeDef): boolean {\n return def.kind === 'submenu' || def.kind === 'subpage'\n}\n\n/**\n * Resolve a def list into node instances under `parent`.\n * `basePath` is the path segments contributed by ancestors (the parent's\n * `definitionPath` when the parent contributes a segment, otherwise the parent's\n * own base path); pass `[]` for roots.\n */\nexport function resolveNodeDefs(\n defs: readonly NodeDef[],\n parent: PopupMenuNode | null,\n basePath: readonly string[],\n getResolvedId: GetResolvedIdFn,\n): PopupMenuNode[] {\n return defs.map((def, index) => {\n const definitionKey = definitionKeyForDef(def)\n const definitionPath = [...basePath, definitionKey]\n const unresolved: UnresolvedMenuNode = {\n def,\n kind: def.kind,\n definitionKey,\n definitionPath,\n parent,\n children: [],\n depth: parent ? parent.depth + 1 : 0,\n index,\n }\n // Call the seam before spreading so the node reflects any reads the seam\n // performs on the final definitional facts (spread-then-call would copy\n // the fields before the seam runs).\n const id = getResolvedId(unresolved)\n const node: PopupMenuNode = { ...unresolved, id }\n node.children = resolveNodeDefs(\n childDefsOf(def),\n node,\n contributesDefinitionPath(def) ? node.definitionPath : basePath,\n getResolvedId,\n )\n return node\n })\n}\n\n/**\n * The branch's resolved static children: the Menu Nodes whose def is one of\n * the branch def's authored `nodes`, in `children` order. Loader results are\n * grafted as children too but are never in `def.nodes`, so they are excluded\n * whether the graft appended to or replaced the static children.\n */\nexport function staticChildrenOf(branch: PopupMenuNode): PopupMenuNode[] {\n const authored = (branch.def as { nodes?: readonly NodeDef[] }).nodes\n if (!authored || authored.length === 0) return []\n const authoredSet = new Set<NodeDef>(authored)\n return branch.children.filter((child) => authoredSet.has(child.def))\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-Z2RGBRJP.cjs","../src/internal/popup-menu/contexts/focus-owner-context.ts","../src/internal/popup-menu/contexts/open-chain-context.ts","../src/internal/popup-menu/contexts/popup-menu-context.ts","../src/internal/popup-menu/contexts/popup-surface-id-context.ts","../src/internal/popup-menu/contexts/submenu-context.ts","../src/internal/popup-menu/contexts/subpage-context.ts","../src/internal/popup-menu/contexts/subpage-stack-context.ts","../src/internal/popup-menu/store/FocusOwnerStore.ts","../src/internal/popup-menu/hooks/use-popup-menu-root.ts","../src/internal/popup-menu/menu-tree/resolve.ts"],"names":["FocusOwnerContext","useFocusOwner","context","OpenChainContext","useOpenChain","PopupMenuContext","usePopupMenuContext","useMaybePopupMenuContext","PopupSurfaceIdContext","usePopupSurfaceId","SubmenuContext","useSubmenuContext","useMaybeSubmenuContext","SubpageContext","useSubpageContext","useMaybeSubpageContext","SubpageStackContext","useSubpageStack","useMaybeSubpageStack","selectors","createSelector","state","surfaceId","FocusOwnerStore","ReactStore","id","isPopupMenuNode","value","encodeDefinitionPathEntry","entry","encoded","index","codeUnit","isSafe"],"mappings":"AAAA,ugCAAyM,82FCElL,IAOjBA,EAAAA,CAA0B,EAAA,CAAA,aAAA,CAAsC,IAAI,CAAA,CAEnE,SAASC,EAAAA,CAAAA,CAAiC,CAC/C,IAAMC,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWF,EAAiB,CAAA,CAClD,EAAA,CAAI,CAACE,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,gEACF,CAAA,CAEF,OAAOA,CACT,CCjBA,IAOMC,EAAAA,CAAyB,EAAA,CAAA,aAAA,CAAqC,IAAI,CAAA,CAEjE,SAASC,EAAAA,CAAAA,CAA+B,CAC7C,IAAMF,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWC,EAAgB,CAAA,CACjD,EAAA,CAAI,CAACD,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,+DACF,CAAA,CAEF,OAAOA,CACT,CCjBA,IAiGMG,EAAAA,CAAyB,EAAA,CAAA,aAAA,CAA4C,IAAI,CAAA,CAMxE,SAASC,EAAAA,CAAAA,CAA6C,CAC3D,IAAMJ,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWG,EAAgB,CAAA,CACjD,EAAA,CAAI,CAACH,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,+EACF,CAAA,CAEF,OAAOA,CACT,CAMO,SAASK,EAAAA,CAAAA,CAAyD,CACvE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAgB,CAC1C,CCvHA,IAaMG,EAAAA,CAA8B,EAAA,CAAA,aAAA,CAA6B,IAAI,CAAA,CAE9D,SAASC,EAAAA,CAAAA,CAAmC,CACjD,OAAa,EAAA,CAAA,UAAA,CAAWD,EAAqB,CAC/C,CCjBA,IA8BME,EAAAA,CAAuB,EAAA,CAAA,aAAA,CAA0C,IAAI,CAAA,CAEpE,SAASC,EAAAA,CAAAA,CAAyC,CACvD,IAAMT,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWQ,EAAc,CAAA,CAC/C,EAAA,CAAI,CAACR,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,8CAA8C,CAAA,CAEhE,OAAOA,CACT,CAEO,SAASU,EAAAA,CAAAA,CAAqD,CACnE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAc,CACxC,CC1CA,IAiBMG,EAAAA,CAAuB,EAAA,CAAA,aAAA,CAA0C,IAAI,CAAA,CAEpE,SAASC,EAAAA,CAAAA,CAAyC,CACvD,IAAMZ,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWW,EAAc,CAAA,CAC/C,EAAA,CAAI,CAACX,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,4DACF,CAAA,CAEF,OAAOA,CACT,CAEO,SAASa,EAAAA,CAAAA,CAAqD,CACnE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAc,CACxC,CC/BA,IA+BMG,EAAAA,CACE,EAAA,CAAA,aAAA,CAA+C,IAAI,CAAA,CAEpD,SAASC,EAAAA,CAAAA,CAA4C,CAC1D,IAAMf,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWc,EAAmB,CAAA,CACpD,EAAA,CAAI,CAACd,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,0DAA0D,CAAA,CAE5E,OAAOA,CACT,CAEO,SAASgB,EAAAA,CAAAA,CAAwD,CACtE,OAAa,EAAA,CAAA,UAAA,CAAWF,EAAmB,CAC7C,CC9CA,6CAA2C,IAerCG,EAAAA,CAAY,CAChB,OAAA,CAASC,mCAAAA,CAAgBC,EAA2BA,CAAAA,CAAM,OAAO,CAAA,CACjE,OAAA,CAASD,mCAAAA,CACNC,CAAAA,CAAwBC,CAAAA,CAAAA,EAAsBD,CAAAA,CAAM,OAAA,GAAYC,CACnE,CACF,CAAA,CAaaC,EAAAA,aAAN,MAAA,QAA8BC,iBAInC,CACA,WAAA,CAAA,CAAc,CACZ,KAAA,CAAM,CAAE,OAAA,CAAS,IAAK,CAAA,CAAG,CAAC,CAAA,CAAGL,EAAS,CACxC,CAMA,UAAA,CAAWM,CAAAA,CAAmB,CAC5B,IAAA,CAAK,GAAA,CAAI,SAAA,CAAWA,CAAE,CACxB,CAMA,UAAA,CAAA,CAAa,CACX,IAAA,CAAK,GAAA,CAAI,SAAA,CAAW,IAAI,CAC1B,CACF,CAAA,CCvDA,SCOgBC,EAAAA,CAAgBC,CAAAA,CAAwC,CACtE,OACE,OAAOA,CAAAA,EAAU,QAAA,EACjBA,CAAAA,GAAU,IAAA,EACV,KAAA,GAASA,CAAAA,EACT,OAAQA,CAAAA,CAAwB,EAAA,EAAO,QAAA,EACvC,OAAQA,CAAAA,CAAwB,aAAA,EAAkB,QAAA,EAClD,KAAA,CAAM,OAAA,CAASA,CAAAA,CAAwB,cAAc,CAAA,EACrD,KAAA,CAAM,OAAA,CAASA,CAAAA,CAAwB,QAAQ,CAAA,EAC/C,OAAQA,CAAAA,CAAwB,KAAA,EAAU,QAAA,EAC1C,QAAA,GAAYA,CAEhB,CAEA,SAASC,EAAAA,CAA0BC,CAAAA,CAAuB,CACxD,IAAIC,CAAAA,CAAU,EAAA,CACd,GAAA,CAAA,IAASC,CAAAA,CAAQ,CAAA,CAAGA,CAAAA,CAAQF,CAAAA,CAAM,MAAA,CAAQE,CAAAA,EAAS,CAAA,CAAG,CACpD,IAAMC,CAAAA,CAAWH,CAAAA,CAAM,UAAA,CAAWE,CAAK,CAAA,CACjCE,CAAAA,CACHD,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,EAAA,EAChCA,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,GAAA,EAChCA,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,EAAA,EACjCA,CAAAA,GAAa,EAAA,EACbA,CAAAA,GAAa,EAAA,EACbA,CAAAA,GAAa,GAAA,EACbA,CAAAA,GAAa,EAAA,CACfF,CAAAA,EAAWG,CAAAA,CACP,MAAA,CAAO,YAAA,CAAaD,CAAQ,CAAA,CAC5B,CAAA,CAAA,EAAIA,CAAAA,CAAS,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,CAAG,GAAG,CAAC,CAAA,CAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-Z2RGBRJP.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\nimport type { FocusOwnerStore } from '../store/FocusOwnerStore.js'\n\n// ============================================================================\n// Focus Owner Context\n// ============================================================================\n\nconst FocusOwnerContext = React.createContext<FocusOwnerStore | null>(null)\n\nexport function useFocusOwner(): FocusOwnerStore {\n const context = React.useContext(FocusOwnerContext)\n if (!context) {\n throw new Error(\n 'FocusOwner components must be used within a FocusOwnerProvider',\n )\n }\n return context\n}\n\nexport function useMaybeFocusOwner(): FocusOwnerStore | null {\n return React.useContext(FocusOwnerContext)\n}\n\nexport { FocusOwnerContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { OpenChainStore } from '../store/OpenChainStore.js'\n\n// ============================================================================\n// Open Chain Context\n// ============================================================================\n\nconst OpenChainContext = React.createContext<OpenChainStore | null>(null)\n\nexport function useOpenChain(): OpenChainStore {\n const context = React.useContext(OpenChainContext)\n if (!context) {\n throw new Error(\n 'OpenChain components must be used within an OpenChainProvider',\n )\n }\n return context\n}\n\nexport function useMaybeOpenChain(): OpenChainStore | null {\n return React.useContext(OpenChainContext)\n}\n\nexport { OpenChainContext }\n","'use client'\n\nimport * as React from 'react'\nimport type {\n ListboxStore,\n VirtualItem,\n} from '../../listbox/store/ListboxStore.js'\nimport type {\n HighlightChangeEventDetails,\n PopupMenuOpenChangeReason,\n} from '../events.js'\n\n// ============================================================================\n// Popup Menu Context\n// ============================================================================\n// Shared root-level context for popup menus (DropdownMenu, ContextMenu).\n// Provides core menu functionality to all child components.\n\n/**\n * Virtual anchor for positioning the menu at a specific point.\n * Used by ContextMenu to position at cursor location.\n */\nexport interface VirtualAnchor {\n getBoundingClientRect(): DOMRect\n}\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\n/**\n * Shared context value for popup menus.\n * Both DropdownMenu.Root and ContextMenu.Root provide this context.\n */\nexport interface PopupMenuContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Whether this menu tree currently ignores user interaction. */\n disabled: boolean\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: (reason?: PopupMenuOpenChangeReason, event?: Event) => void\n /**\n * Internal: when true, Surface handles Tab explicitly (close the tree, or\n * cycle through focus zones). Enabled only by DropdownMenu.Root and\n * ContextMenu.Root — never Select or Combobox.\n */\n explicitTabBehavior: boolean\n /**\n * Internal: what Tab does under `explicitTabBehavior` when the surface (and\n * its ancestors) have no focus-zone tabbables. `'close'` closes the whole\n * tree (dropdown/context-menu). `'inert'` swallows the event, keeping focus\n * where it is (command palette).\n */\n tabWithoutZones: 'close' | 'inert'\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n /**\n * Virtual anchor for positioning.\n * Used by ContextMenu to position at cursor location.\n * DropdownMenu uses the Popover's anchor (trigger button) instead.\n */\n virtualAnchor?: VirtualAnchor\n /**\n * Type of menu for positioning logic.\n * - 'dropdown': positions relative to trigger button\n * - 'context': positions at cursor with fixed positioning\n */\n menuType: 'dropdown' | 'context'\n /**\n * When to close the menu on outside interactions.\n * - 'pointerdown': Close immediately when pointer is pressed outside (default)\n * - 'click': Close when a full click (pointerdown + pointerup) occurs outside\n * @default 'pointerdown'\n */\n closeOnOutsidePress: 'click' | 'pointerdown'\n}\n\nconst PopupMenuContext = React.createContext<PopupMenuContextValue | null>(null)\n\n/**\n * Hook to access the popup menu context.\n * Throws if used outside a popup menu.\n */\nexport function usePopupMenuContext(): PopupMenuContextValue {\n const context = React.useContext(PopupMenuContext)\n if (!context) {\n throw new Error(\n 'PopupMenu components must be used within a PopupMenu.Root or ContextMenu.Root',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally access the popup menu context.\n * Returns null if used outside a popup menu.\n */\nexport function useMaybePopupMenuContext(): PopupMenuContextValue | null {\n return React.useContext(PopupMenuContext)\n}\n\n// Re-export for convenience\nexport type { VirtualItem }\nexport { PopupMenuContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Popup Surface ID Context\n// ============================================================================\n\n/**\n * Context for passing surfaceId from Popup to Surface.\n * This ensures Popup and Surface share the same ID for data attribute tracking.\n *\n * For root menus, Popup generates the ID and provides it via this context.\n * For submenus, the ID comes from SubmenuContext.childSurfaceId instead.\n */\nconst PopupSurfaceIdContext = React.createContext<string | null>(null)\n\nexport function usePopupSurfaceId(): string | null {\n return React.useContext(PopupSurfaceIdContext)\n}\n\nexport { PopupSurfaceIdContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubmenuContextValue {\n /** Whether the submenu is open */\n open: boolean\n /** Set the submenu open state */\n setOpen: (open: boolean) => void\n /**\n * Latch set by explicit close actions (keyboard ArrowLeft/Ctrl+H/Escape-in-submenu,\n * or clicking the open trigger). While set and the trigger remains highlighted,\n * pointer/keyboard auto-open is suppressed. Reset when highlight leaves the trigger.\n */\n suppressAutoOpenRef: React.MutableRefObject<boolean>\n /** Reference to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Reference to the submenu content element (for aim guard rect calculations) */\n contentRef: React.RefObject<HTMLElement | null>\n /** Surface ID of the parent menu (for keyboard navigation back) */\n parentSurfaceId: string\n /** Surface ID of this submenu (for keyboard navigation into) */\n childSurfaceId: string\n /**\n * Whether pressing Escape in this submenu closes the entire menu from the root.\n * When true, Escape closes the entire menu tree.\n * When false, Escape only closes this submenu and moves focus to the parent.\n * @default true\n */\n closeRootOnEsc: boolean\n}\n\nconst SubmenuContext = React.createContext<SubmenuContextValue | null>(null)\n\nexport function useSubmenuContext(): SubmenuContextValue {\n const context = React.useContext(SubmenuContext)\n if (!context) {\n throw new Error('SubmenuTrigger must be used within a Submenu')\n }\n return context\n}\n\nexport function useMaybeSubmenuContext(): SubmenuContextValue | null {\n return React.useContext(SubmenuContext)\n}\n\nexport { SubmenuContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubpageContextValue {\n /** Current page ID. */\n pageId: string\n /** Surface ID for this page. */\n surfaceId: string\n /** Surface ID for the previous page, if available. */\n parentSurfaceId: string | null\n /** Whether this page is currently active. */\n isActive: boolean\n /** Whether Escape should close the entire menu tree from this page. */\n closeRootOnEsc: boolean\n /** Navigate back one page. Returns true when navigation happened. */\n goBack: () => boolean\n}\n\nconst SubpageContext = React.createContext<SubpageContextValue | null>(null)\n\nexport function useSubpageContext(): SubpageContextValue {\n const context = React.useContext(SubpageContext)\n if (!context) {\n throw new Error(\n 'Subpage components must be used within a PopupMenu.Subpage',\n )\n }\n return context\n}\n\nexport function useMaybeSubpageContext(): SubpageContextValue | null {\n return React.useContext(SubpageContext)\n}\n\nexport { SubpageContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubpageRegistration {\n pageId: string\n surfaceId: string\n closeRootOnEsc: boolean\n}\n\nexport interface SubpageStackContextValue {\n /** Active page ID; `null` when the root surface is active. */\n activePageId: string | null\n /** Surface ID of the root surface. */\n rootSurfaceId: string\n /** Surface ID for the currently active page. */\n activeSurfaceId: string\n /** Whether there is a previous page to navigate back to. */\n canGoBack: boolean\n /** Whether Escape in the active page should close the entire menu tree. */\n shouldCloseRootOnEsc: boolean\n /** Open page IDs, bottom to top; empty at root. */\n stack: readonly string[]\n /** Register a page and return an unregister cleanup. */\n registerPage: (registration: SubpageRegistration) => () => void\n /** Push a page onto the stack. Returns true when navigation happened. */\n openPage: (pageId: string) => boolean\n /** Pop one page from the stack. Returns true when navigation happened. */\n goBack: () => boolean\n /** Resolve a surface ID for a page ID. */\n getSurfaceId: (pageId: string) => string | null\n}\n\nconst SubpageStackContext =\n React.createContext<SubpageStackContextValue | null>(null)\n\nexport function useSubpageStack(): SubpageStackContextValue {\n const context = React.useContext(SubpageStackContext)\n if (!context) {\n throw new Error('Subpage components must be used within a PopupMenu.Popup')\n }\n return context\n}\n\nexport function useMaybeSubpageStack(): SubpageStackContextValue | null {\n return React.useContext(SubpageStackContext)\n}\n\nexport { SubpageStackContext }\n","import { createSelector, ReactStore } from '@base-ui/utils/store'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface FocusOwnerState {\n /** Which surface currently owns focus (surfaceId or null) */\n ownerId: string | null\n}\n\n// ============================================================================\n// Selectors\n// ============================================================================\n\nconst selectors = {\n ownerId: createSelector((state: FocusOwnerState) => state.ownerId),\n isOwner: createSelector(\n (state: FocusOwnerState, surfaceId: string) => state.ownerId === surfaceId,\n ),\n}\n\n// ============================================================================\n// Store\n// ============================================================================\n\n/**\n * Tracks which menu surface owns DOM focus.\n * Single instance per menu tree (created at root, shared via context).\n *\n * Used by: DropdownMenu, ContextMenu\n * Not used by: Select, CommandMenu (single surface)\n */\nexport class FocusOwnerStore extends ReactStore<\n FocusOwnerState,\n Record<string, never>,\n typeof selectors\n> {\n constructor() {\n super({ ownerId: null }, {}, selectors)\n }\n\n /**\n * Set the owner surface ID.\n * Call this when focus should transfer to a new surface.\n */\n setOwnerId(id: string | null) {\n this.set('ownerId', id)\n }\n\n /**\n * Clear the owner (set to null).\n * Call this when the menu tree closes.\n */\n clearOwner() {\n this.set('ownerId', null)\n }\n}\n\nexport type { FocusOwnerState as State }\n","'use client'\n\nimport * as React from 'react'\nimport type { ChangeEventDetails } from '../../../utils/events/index.js'\nimport {\n createChangeEventDetails,\n REASONS,\n} from '../../../utils/events/index.js'\nimport { ensureInputModalityTracking } from '../../../utils/input-modality.js'\nimport { ListboxStore, type VirtualItem } from '../../listbox/index.js'\nimport type { VirtualizationConfig } from '../contexts/popup-menu-context.js'\nimport type {\n HighlightChangeEventDetails,\n PopupMenuHighlightChangeHandler,\n PopupMenuOpenChangeReason,\n} from '../events.js'\nimport type { MenuTreeResolver } from '../menu-tree/resolver.js'\nimport { createMenuTreeResolver } from '../menu-tree/resolver.js'\nimport type { GetResolvedIdFn, PopupMenuIdScope } from '../menu-tree/types.js'\nimport { FocusOwnerStore } from '../store/FocusOwnerStore.js'\nimport { OpenChainStore } from '../store/OpenChainStore.js'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface UsePopupMenuRootParams {\n /**\n * Computes canonical Resolved IDs for data-first content from the Unresolved Menu Node (definitional facts only).\n * @default explicit `def.id` verbatim, else the joined definition path\n * Read once when the menu root mounts — later changes have no effect.\n */\n getResolvedId?: GetResolvedIdFn\n /** Definition Key uniqueness scope. Read once when the menu root mounts. */\n idScope?: PopupMenuIdScope\n /**\n * Callback when the open state changes.\n * The second parameter contains event details including the reason for the change.\n */\n onOpenChange?: (\n open: boolean,\n eventDetails: ChangeEventDetails<string>,\n ) => void\n\n /**\n * Whether the menu is initially open.\n * @default false\n */\n defaultOpen?: boolean\n\n /**\n * Whether virtualization mode is enabled.\n * @default false\n */\n virtualized?: boolean\n\n /**\n * Pre-registered items for virtualization.\n */\n items?: VirtualItem[]\n\n /**\n * Callback when the highlighted item changes. `id` is first; `node` is the\n * resolved menu node enrichment and may be null.\n * The fourth parameter contains event details including the reason for the change.\n */\n onHighlightChange?: PopupMenuHighlightChangeHandler<HighlightChangeEventDetails>\n\n /**\n * When to close the menu on outside interactions.\n * - 'pointerdown': Close immediately when pointer is pressed outside (default)\n * - 'click': Close when a full click (pointerdown + pointerup) occurs outside\n * @default 'pointerdown'\n */\n closeOnOutsidePress?: 'click' | 'pointerdown'\n\n /**\n * Whether the menu should ignore user interaction.\n * Can be controlled declaratively via this prop, or imperatively via actionsRef.setDisabled().\n * @default false\n */\n disabled?: boolean\n\n /**\n * Initial disabled state for imperative usage.\n * Ignored when `disabled` prop is true.\n * @default false\n */\n defaultDisabled?: boolean\n}\n\nexport interface PopupMenuRootActions {\n /** Close the menu tree imperatively. */\n close: () => void\n /** Unmount the popup imperatively (when keep-mounted mode is enabled). */\n unmount: () => void\n /** Enable/disable the menu tree imperatively. */\n setDisabled: (disabled: boolean) => void\n}\n\nexport interface UsePopupMenuRootReturn {\n /** The menu-tree resolver for this menu root. */\n menuTreeResolver: MenuTreeResolver\n /** The Listbox store instance */\n store: ListboxStore\n /** The FocusOwner store instance */\n focusOwnerStore: FocusOwnerStore\n /** The OpenChain store instance */\n openChainStore: OpenChainStore\n /** Register a surface (submenu) for closeAll tracking */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Close the entire menu tree */\n closeAll: (reason?: PopupMenuOpenChangeReason, event?: Event) => void\n /** Virtualization configuration (if enabled) */\n virtualization: VirtualizationConfig | undefined\n /** Handle open state change (updates store and clears stores on close) */\n handleOpenChange: (\n open: boolean,\n reason?: PopupMenuOpenChangeReason,\n event?: Event,\n ) => void\n /** Whether the menu currently ignores user interaction. */\n disabled: boolean\n /** Update imperative disabled state. */\n setDisabled: (disabled: boolean) => void\n}\n\n// ============================================================================\n// Hook\n// ============================================================================\n\n/**\n * Hook that creates and manages the core stores and utilities for popup menus.\n * Used by both DropdownMenu.Root and ContextMenu.Root.\n *\n * Provides:\n * - ListboxStore for item management\n * - FocusOwnerStore for focus tracking across submenus\n * - OpenChainStore for tracking open submenu chain\n * - Surface registry for closeAll functionality\n */\nexport function usePopupMenuRoot(\n params: UsePopupMenuRootParams = {},\n): UsePopupMenuRootReturn {\n const {\n onOpenChange,\n defaultOpen = false,\n virtualized = false,\n items: itemsProp,\n onHighlightChange,\n closeOnOutsidePress = 'pointerdown',\n disabled: disabledProp = false,\n defaultDisabled = false,\n getResolvedId,\n idScope = 'surface',\n } = params\n\n const menuTreeResolverRef = React.useRef<MenuTreeResolver | null>(null)\n if (menuTreeResolverRef.current === null) {\n menuTreeResolverRef.current = createMenuTreeResolver({\n getResolvedId,\n idScope,\n })\n }\n const menuTreeResolver = menuTreeResolverRef.current\n\n const handleHighlightChange = React.useCallback(\n (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => {\n onHighlightChange?.(\n id,\n id === null ? null : (menuTreeResolver.getNodeById(id) ?? null),\n index,\n eventDetails,\n )\n },\n [menuTreeResolver, onHighlightChange],\n )\n\n const [imperativeDisabled, setImperativeDisabled] =\n React.useState(defaultDisabled)\n const disabled = disabledProp || imperativeDisabled\n\n const setDisabled = React.useCallback((nextDisabled: boolean) => {\n setImperativeDisabled(nextDisabled)\n }, [])\n\n // Begin tracking global input modality so the store can attribute opens to\n // mouse/touch/pen/keyboard. Idempotent; installed once for the whole app.\n React.useEffect(() => {\n ensureInputModalityTracking()\n }, [])\n\n // Track outside pointer events to distinguish outside-press from focus-out\n // When a pointerdown happens outside the menu, we store it so that if a\n // focus-out close happens immediately after, we can treat it as outside-press\n const outsidePointerEventRef = React.useRef<PointerEvent | null>(null)\n\n // Create stable callback wrapper for onOpenChange that converts focus-out to outside-press\n // when the close was triggered by a pointer event outside the menu\n const stableOnOpenChange = React.useCallback(\n (open: boolean, eventDetails: ChangeEventDetails<string>) => {\n // If closing due to focus-out but we have a stored outside pointer event,\n // convert the reason to outside-press for better cancel() support\n if (\n !open &&\n eventDetails.reason === REASONS.focusOut &&\n outsidePointerEventRef.current\n ) {\n const pointerEvent = outsidePointerEventRef.current\n outsidePointerEventRef.current = null\n\n // Create new event details with outside-press reason and the pointer event\n const convertedDetails = createChangeEventDetails(\n REASONS.outsidePress,\n pointerEvent,\n )\n\n onOpenChange?.(open, convertedDetails)\n\n // If the converted callback canceled, also cancel the original\n if (convertedDetails.isCanceled) {\n eventDetails.cancel()\n }\n return\n }\n\n // Clear the pointer event ref if we're not using it\n outsidePointerEventRef.current = null\n\n onOpenChange?.(open, eventDetails)\n },\n [onOpenChange],\n )\n\n // Create the store instance\n const store = ListboxStore.useStore(\n undefined,\n { open: defaultOpen },\n {\n onOpenChange: stableOnOpenChange,\n },\n )\n\n // Get current open state for the pointer event listener\n const isOpen = store.useState('open')\n\n // Create focus owner store (single instance for entire menu tree)\n const focusOwnerStoreRef = React.useRef<FocusOwnerStore | null>(null)\n if (!focusOwnerStoreRef.current) {\n focusOwnerStoreRef.current = new FocusOwnerStore()\n }\n const focusOwnerStore = focusOwnerStoreRef.current\n\n // Create open chain store (single instance for entire menu tree)\n const openChainStoreRef = React.useRef<OpenChainStore | null>(null)\n if (!openChainStoreRef.current) {\n openChainStoreRef.current = new OpenChainStore()\n }\n const openChainStore = openChainStoreRef.current\n\n // Registry for tracking open submenus (for closeAll)\n type SurfaceEntry = { depth: number; setOpen: (open: boolean) => void }\n const surfaceRegistryRef = React.useRef<Map<string, SurfaceEntry>>(new Map())\n\n // Register a surface (submenu) for closeAll tracking\n const registerSurface = React.useCallback(\n (depth: number, setOpen: (open: boolean) => void) => {\n const id = Math.random().toString(36).slice(2)\n surfaceRegistryRef.current.set(id, { depth, setOpen })\n return () => {\n surfaceRegistryRef.current.delete(id)\n }\n },\n [],\n )\n\n // Close the entire menu tree from deepest submenu to root\n const closeAll = React.useCallback(\n (reason: PopupMenuOpenChangeReason = REASONS.itemPress, event?: Event) => {\n // Sort surfaces by depth (deepest first)\n const surfaces = [...surfaceRegistryRef.current.values()].sort(\n (a, b) => b.depth - a.depth,\n )\n\n // Close each submenu from deepest to shallowest\n for (const surface of surfaces) {\n surface.setOpen(false)\n }\n\n // Finally close the root\n store.setOpen(false, reason, event)\n\n // Clear focus ownership and open chain\n focusOwnerStore.clearOwner()\n openChainStore.clear()\n },\n [store, focusOwnerStore, openChainStore],\n )\n\n // Ref to hold closeAll for use in the pointerdown effect\n const closeAllRef = React.useRef(closeAll)\n closeAllRef.current = closeAll\n\n // Listen for pointerdown events on document to detect outside clicks\n // This is a single listener at the root level that handles the entire menu tree.\n // Behavior depends on closeOnOutsidePress:\n // - 'pointerdown': Close immediately when pointer is pressed outside\n // - 'click': Store event and convert focus-out to outside-press reason\n React.useEffect(() => {\n if (!isOpen || disabled) {\n outsidePointerEventRef.current = null\n return\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Element | null\n if (!target) return\n\n // Check if the pointerdown is inside any part of the menu tree or its triggers\n // base-ui sets data-open on popups and data-popup-open on triggers\n const isInsidePopup = target.closest('[data-open]') !== null\n const isInsideTrigger = target.closest('[data-popup-open]') !== null\n const isInside = isInsidePopup || isInsideTrigger\n\n if (closeOnOutsidePress === 'pointerdown' && !isInside) {\n // Close entire menu tree immediately on pointerdown outside\n closeAllRef.current(REASONS.outsidePress, event)\n } else {\n // Store the event for focus-out-to-outside-press conversion\n outsidePointerEventRef.current = event\n }\n }\n\n // Use capture phase to see the event before any stopPropagation\n document.addEventListener('pointerdown', handlePointerDown, true)\n return () => {\n document.removeEventListener('pointerdown', handlePointerDown, true)\n outsidePointerEventRef.current = null\n }\n }, [isOpen, closeOnOutsidePress, disabled])\n\n // Handle open state change\n const handleOpenChange = React.useCallback(\n (\n newOpen: boolean,\n reason: PopupMenuOpenChangeReason = REASONS.none,\n event?: Event,\n ) => {\n const isImperativeAction = reason === REASONS.imperativeAction\n\n // Ignore user-driven open/close interactions while disabled.\n if (disabled && !isImperativeAction) {\n return\n }\n\n store.setOpen(newOpen, reason, event)\n // Clear focus ownership and open chain when menu closes\n if (!newOpen) {\n focusOwnerStore.clearOwner()\n openChainStore.clear()\n }\n },\n [store, focusOwnerStore, openChainStore, disabled],\n )\n\n // Memoize listbox wiring config\n const virtualization = React.useMemo(() => {\n if (!virtualized && !onHighlightChange) {\n return undefined\n }\n\n return {\n virtualized,\n items: itemsProp ?? [],\n onHighlightChange: handleHighlightChange,\n }\n }, [virtualized, itemsProp, handleHighlightChange, onHighlightChange])\n\n return {\n menuTreeResolver,\n store,\n focusOwnerStore,\n openChainStore,\n registerSurface,\n closeAll,\n virtualization,\n handleOpenChange,\n disabled,\n setDisabled,\n }\n}\n","import { slugify } from '../../listbox/utils/normalize.js'\nimport type { NodeDef } from '../data-first/types.js'\nimport type {\n GetResolvedIdFn,\n PopupMenuIdScope,\n PopupMenuNode,\n UnresolvedMenuNode,\n} from './types.js'\n\nexport function isPopupMenuNode(value: unknown): value is PopupMenuNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'def' in value &&\n typeof (value as PopupMenuNode).id === 'string' &&\n typeof (value as PopupMenuNode).definitionKey === 'string' &&\n Array.isArray((value as PopupMenuNode).definitionPath) &&\n Array.isArray((value as PopupMenuNode).children) &&\n typeof (value as PopupMenuNode).depth === 'number' &&\n 'parent' in value\n )\n}\n\nfunction encodeDefinitionPathEntry(entry: string): string {\n let encoded = ''\n for (let index = 0; index < entry.length; index += 1) {\n const codeUnit = entry.charCodeAt(index)\n const isSafe =\n (codeUnit >= 0x41 && codeUnit <= 0x5a) ||\n (codeUnit >= 0x61 && codeUnit <= 0x7a) ||\n (codeUnit >= 0x30 && codeUnit <= 0x39) ||\n codeUnit === 0x2e ||\n codeUnit === 0x5f ||\n codeUnit === 0x7e ||\n codeUnit === 0x2d\n encoded += isSafe\n ? String.fromCharCode(codeUnit)\n : `%${codeUnit.toString(16).padStart(4, '0')}`\n }\n return encoded\n}\n\n/** Default Resolved ID, using surface-scoped encoded paths unless menu scope is selected. */\nexport function defaultGetResolvedId(\n node: UnresolvedMenuNode,\n idScope: PopupMenuIdScope = 'surface',\n): string {\n if (idScope === 'menu') return node.definitionKey\n return node.definitionPath.map(encodeDefinitionPathEntry).join('/')\n}\n\n/** Definition Key for a def: explicit `id` verbatim, else slugified `value`. */\nexport function definitionKeyForDef(def: NodeDef): string {\n switch (def.kind) {\n case 'group':\n case 'radio-group':\n return def.id\n case 'separator':\n return def.id\n default:\n return def.id ?? slugify(def.value)\n }\n}\n\n/** Child defs of a def, in def order; empty for leaf kinds. */\nexport function childDefsOf(def: NodeDef): readonly NodeDef[] {\n switch (def.kind) {\n case 'group':\n case 'radio-group':\n return def.nodes\n case 'submenu':\n case 'subpage':\n case 'tree-item':\n return def.nodes ?? []\n default:\n return []\n }\n}\n\n/** Kinds whose Definition Key is part of their descendants' definition paths. */\nexport function contributesDefinitionPath(def: NodeDef): boolean {\n return def.kind === 'submenu' || def.kind === 'subpage'\n}\n\n/**\n * Resolve a def list into node instances under `parent`.\n * `basePath` is the path segments contributed by ancestors (the parent's\n * `definitionPath` when the parent contributes a segment, otherwise the parent's\n * own base path); pass `[]` for roots.\n */\nexport function resolveNodeDefs(\n defs: readonly NodeDef[],\n parent: PopupMenuNode | null,\n basePath: readonly string[],\n getResolvedId: GetResolvedIdFn,\n): PopupMenuNode[] {\n return defs.map((def, index) => {\n const definitionKey = definitionKeyForDef(def)\n const definitionPath = [...basePath, definitionKey]\n const unresolved: UnresolvedMenuNode = {\n def,\n kind: def.kind,\n definitionKey,\n definitionPath,\n parent,\n children: [],\n depth: parent ? parent.depth + 1 : 0,\n index,\n }\n // Call the seam before spreading so the node reflects any reads the seam\n // performs on the final definitional facts (spread-then-call would copy\n // the fields before the seam runs).\n const id = getResolvedId(unresolved)\n const node: PopupMenuNode = { ...unresolved, id }\n node.children = resolveNodeDefs(\n childDefsOf(def),\n node,\n contributesDefinitionPath(def) ? node.definitionPath : basePath,\n getResolvedId,\n )\n return node\n })\n}\n\n/**\n * The branch's resolved static children: the Menu Nodes whose def is one of\n * the branch def's authored `nodes`, in `children` order. Loader results are\n * grafted as children too but are never in `def.nodes`, so they are excluded\n * whether the graft appended to or replaced the static children.\n */\nexport function staticChildrenOf(branch: PopupMenuNode): PopupMenuNode[] {\n const authored = (branch.def as { nodes?: readonly NodeDef[] }).nodes\n if (!authored || authored.length === 0) return []\n const authoredSet = new Set<NodeDef>(authored)\n return branch.children.filter((child) => authoredSet.has(child.def))\n}\n"]}