Skip to content

The only tool you need to know what is happening and how to fix it.

44.5 KB
Raw Blame
import"./DsnmJJEf.js";import{C as Te,D as Se,bo as Ee,B as Ce,J as xe,j as v,k as Rt,l as h,g as d,bn as Me,bk as g,bp as Ae,bm as At,bl as ke,ai as Fe,b as N,ac as Ie,A as Ne,u as T,c as M,f as A,s as R,x as L,d as k,p as B,bq as Oe,a as K,aT as De,aV as Pe,aq as Lt}from"./BKFspo1J.js";import{i as Re}from"./COK9M2N0.js";import{q as Le,B as Be,l as Ke,b as f,r as We,t as _e,u as Ue,v as Ve,w as ut,p as D,d as Ge,a as W,g as gt,e as Bt,h as bt,m as Kt,k as qe,x as He}from"./BoImjCaE.js";import{p as b}from"./CARHnQ8P.js";import{S as je}from"./8zLz30Kn.js";function ze(n,t,e){Te&&Se();var r=new xe(n),s=!Ee();Ce(()=>{var i=t();s&&i!==null&&typeof i=="object"&&(i={}),r.ensure(i,e)})}function O(n){let t=v(Rt(n));return{[Be]:!0,[Le]:!0,get current(){return d(t)},set current(e){h(t,e,!0)}}}O.from=Ke;O.with=f;O.flatten=We;O.readonly=_e;O.isBox=Ue;O.isWritableBox=Ve;const Ye=typeof window<"u"?window:void 0;function Xe(n){let t=n.activeElement;for(;t?.shadowRoot;){const e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}class Ze{#t;#e;constructor(t={}){const{window:e=Ye,document:r=e?.document}=t;e!==void 0&&(this.#t=r,this.#e=Me(s=>{const i=g(e,"focusin",s),o=g(e,"focusout",s);return()=>{i(),o()}}))}get current(){return this.#e?.(),this.#t?Xe(this.#t):null}}new Ze;class z{#t;#e;constructor(t){this.#t=t,this.#e=Symbol(t)}get key(){return this.#e}exists(){return Ae(this.#e)}get(){const t=At(this.#e);if(t===void 0)throw new Error(`Context "${this.#t}" not found`);return t}getOr(t){const e=At(this.#e);return e===void 0?t:e}set(t){return ke(this.#e,t)}}function Je(n,t){switch(n){case"post":N(t);break;case"pre":Fe(t);break}}function Wt(n,t,e,r={}){const{lazy:s=!1}=r;let i=!s,o=Array.isArray(n)?[]:void 0;Je(t,()=>{const u=Array.isArray(n)?n.map(c=>c()):n();if(!i){i=!0,o=u;return}const a=Ie(()=>e(u,o));return o=u,a})}function S(n,t,e){Wt(n,"post",t,e)}function Qe(n,t,e){Wt(n,"pre",t,e)}S.pre=Qe;function _(n){N(()=>()=>{n()})}function $e(n,t){return setTimeout(t,n)}function E(n){Ne().then(n)}const tn=1,en=9,nn=11;function ht(n){return ut(n)&&n.nodeType===tn&&typeof n.nodeName=="string"}function _t(n){return ut(n)&&n.nodeType===en}function rn(n){return ut(n)&&n.constructor?.name==="VisualViewport"}function sn(n){return ut(n)&&n.nodeType!==void 0}function Ut(n){return sn(n)&&n.nodeType===nn&&"host"in n}function on(n,t){if(!n||!t||!ht(n)||!ht(t))return!1;const e=t.getRootNode?.();if(n===t||n.contains(t))return!0;if(e&&Ut(e)){let r=t;for(;r;){if(n===r)return!0;r=r.parentNode||r.host}}return!1}function Y(n){return _t(n)?n:rn(n)?n.document:n?.ownerDocument??document}function Vt(n){return Ut(n)?Vt(n.host):_t(n)?n.defaultView??window:ht(n)?n.ownerDocument?.defaultView??window:window}function un(n){let t=n.activeElement;for(;t?.shadowRoot;){const e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}class mt{element;#t=T(()=>this.element.current?this.element.current.getRootNode()??document:document);get root(){return d(this.#t)}set root(t){h(this.#t,t)}constructor(t){typeof t=="function"?this.element=f(t):this.element=t}getDocument=()=>Y(this.root);getWindow=()=>this.getDocument().defaultView??window;getActiveElement=()=>un(this.root);isActiveElement=t=>t===this.getActiveElement();getElementById(t){return this.root.getElementById(t)}querySelector=t=>this.root?this.root.querySelector(t):null;querySelectorAll=t=>this.root?this.root.querySelectorAll(t):[];setTimeout=(t,e)=>this.getWindow().setTimeout(t,e);clearTimeout=t=>this.getWindow().clearTimeout(t)}const Ar="Alt",H="ArrowDown",X="ArrowLeft",Z="ArrowRight",et="ArrowUp",kr="Backspace",Fr="CapsLock",Ir="Control",Gt="End",qt="Enter",an="Escape",Nr="F1",Or="F10",Dr="F11",Pr="F12",Rr="F2",Lr="F3",Br="F4",Kr="F5",Wr="F6",_r="F7",Ur="F8",Vr="F9",Ht="Home",Gr="Meta",cn="PageDown",ln="PageUp",qr="Shift",at=" ",hn="Tab",Hr="p",jr="n",zr="j",Yr="k",Xr="h",Zr="l";function dn(n){return window.getComputedStyle(n).getPropertyValue("direction")}function fn(n="ltr",t="horizontal"){return{horizontal:n==="rtl"?X:Z,vertical:H}[t]}function pn(n="ltr",t="horizontal"){return{horizontal:n==="rtl"?Z:X,vertical:et}[t]}function gn(n="ltr",t="horizontal"){return["ltr","rtl"].includes(n)||(n="ltr"),["horizontal","vertical"].includes(t)||(t="horizontal"),{nextKey:fn(n,t),prevKey:pn(n,t)}}const jt=typeof document<"u",kt=bn();function bn(){return jt&&window?.navigator?.userAgent&&(/iP(ad|hone|od)/.test(window.navigator.userAgent)||window?.navigator?.maxTouchPoints>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function C(n){return n instanceof HTMLElement}function dt(n){return n instanceof Element}function zt(n){return n instanceof Element||n instanceof SVGElement}function Jr(n){return n.matches(":focus-visible")}function Qr(n){return n!==null}function mn(n){return n instanceof HTMLInputElement&&"select"in n}class vn{#t;#e=O(null);constructor(t){this.#t=t}getCandidateNodes(){return this.#t.rootNode.current?this.#t.candidateSelector?Array.from(this.#t.rootNode.current.querySelectorAll(this.#t.candidateSelector)):this.#t.candidateAttr?Array.from(this.#t.rootNode.current.querySelectorAll(`[${this.#t.candidateAttr}]:not([data-disabled])`)):[]:[]}focusFirstCandidate(){const t=this.getCandidateNodes();t.length&&t[0]?.focus()}handleKeydown(t,e,r=!1){const s=this.#t.rootNode.current;if(!s||!t)return;const i=this.getCandidateNodes();if(!i.length)return;const o=i.indexOf(t),u=dn(s),{nextKey:a,prevKey:c}=gn(u,this.#t.orientation.current),p=this.#t.loop.current,l={[a]:o+1,[c]:o-1,[Ht]:0,[Gt]:i.length-1};if(r){const J=a===H?Z:H,F=c===et?X:et;l[J]=o+1,l[F]=o-1}let m=l[e.key];if(m===void 0)return;e.preventDefault(),m<0&&p?m=i.length-1:m===i.length&&p&&(m=0);const y=i[m];if(y)return y.focus(),this.#e.current=y.id,this.#t.onCandidateFocus?.(y),y}getTabIndex(t){const e=this.getCandidateNodes(),r=this.#e.current!==null;return t&&!r&&e[0]===t?(this.#e.current=t.id,0):t?.id===this.#e.current?0:-1}setCurrentTabStopId(t){this.#e.current=t}focusCurrentTabStop(){const t=this.#e.current;if(!t)return;const e=this.#t.rootNode.current?.querySelector(`#${t}`);!e||!C(e)||e.focus()}}class yn{#t;#e=null;constructor(t){this.#t=t,_(()=>this.#n())}#n(){this.#e&&(window.cancelAnimationFrame(this.#e),this.#e=null)}run(t){this.#n();const e=this.#t.ref.current;if(e){if(typeof e.getAnimations!="function"){this.#r(t);return}this.#e=window.requestAnimationFrame(()=>{const r=e.getAnimations();if(r.length===0){this.#r(t);return}Promise.allSettled(r.map(s=>s.finished)).then(()=>{this.#r(t)})})}}#r(t){const e=()=>{t()};this.#t.afterTick?E(e):e()}}class wn{#t;#e;#n;#r=v(!1);constructor(t){this.#t=t,h(this.#r,t.open.current,!0),this.#e=t.enabled??!0,this.#n=new yn({ref:this.#t.ref,afterTick:this.#t.open}),S(()=>this.#t.open.current,e=>{e&&h(this.#r,!0),this.#e&&this.#n.run(()=>{e===this.#t.open.current&&(this.#t.open.current||h(this.#r,!1),this.#t.onComplete?.())})})}get shouldRender(){return d(this.#r)}}function w(){}function Tn(n,t){var e=M(),r=A(e);ze(r,()=>t.children,s=>{var i=M(),o=A(i);R(o,()=>t.children??L),k(s,i)}),k(n,e)}const Sn=new z("BitsConfig");function En(){const n=new Cn(null,{});return Sn.getOr(n).opts}class Cn{opts;constructor(t,e){const r=xn(t,e);this.opts={defaultPortalTo:r(s=>s.defaultPortalTo),defaultLocale:r(s=>s.defaultLocale)}}}function xn(n,t){return e=>f(()=>{const s=e(t)?.current;if(s!==void 0)return s;if(n!==null)return e(n.opts)?.current})}function Yt(n,t){return e=>{const r=En();return f(()=>{const s=e();if(s!==void 0)return s;const i=n(r).current;return i!==void 0?i:t})}}const $r=Yt(n=>n.defaultLocale,"en"),Mn=Yt(n=>n.defaultPortalTo,"body");function ts(n,t){B(t,!0);const e=Mn(()=>t.to),r=Oe();let s=T(i);function i(){if(!jt||t.disabled)return null;let l=null;return typeof e.current=="string"?l=document.querySelector(e.current):l=e.current,l}let o;function u(){o&&(Pe(o),o=null)}S([()=>d(s),()=>t.disabled],([l,m])=>{if(!l||m){u();return}return o=De(Tn,{target:l,props:{children:t.children},context:r}),()=>{u()}});var a=M(),c=A(a);{var p=l=>{var m=M(),y=A(m);R(y,()=>t.children??L),k(l,m)};Re(c,l=>{t.disabled&&l(p)})}k(n,a),K()}class An{eventName;options;constructor(t,e={bubbles:!0,cancelable:!0}){this.eventName=t,this.options=e}createEvent(t){return new CustomEvent(this.eventName,{...this.options,detail:t})}dispatch(t,e){const r=this.createEvent(e);return t.dispatchEvent(r),r}listen(t,e,r){const s=i=>{e(i)};return g(t,this.eventName,s,r)}}function Ft(n,t=500){let e=null;const r=(...s)=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{n(...s)},t)};return r.destroy=()=>{e!==null&&(clearTimeout(e),e=null)},r}function Xt(n,t){return n===t||n.contains(t)}function Zt(n){return n?.ownerDocument??document}function es(n){if(!n)return null;for(const t of n.childNodes)if(t.nodeType!==Node.COMMENT_NODE)return t;return null}function kn(n,t){const{clientX:e,clientY:r}=n,s=t.getBoundingClientRect();return e<s.left||e>s.right||r<s.top||r>s.bottom}const ft=[qt,at],Fn=[H,ln,Ht],Jt=[et,cn,Gt],In=[...Fn,...Jt],Nn={ltr:[...ft,Z],rtl:[...ft,X]},ns={ltr:[X],rtl:[Z]};function nt(n){return n.pointerType==="mouse"}function On(n,{select:t=!1}={}){if(!n||!n.focus)return;const e=Y(n);if(e.activeElement===n)return;const r=e.activeElement;n.focus({preventScroll:!0}),n!==r&&mn(n)&&t&&n.select()}function Dn(n,{select:t=!1}={},e){const r=e();for(const s of n)if(On(s,{select:t}),e()!==r)return!0}var Qt=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],rt=Qt.join(","),$t=typeof Element>"u",I=$t?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,st=!$t&&Element.prototype.getRootNode?function(n){var t;return n==null||(t=n.getRootNode)===null||t===void 0?void 0:t.call(n)}:function(n){return n?.ownerDocument},j=function(t,e){var r;e===void 0&&(e=!0);var s=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),i=s===""||s==="true",o=i||e&&t&&j(t.parentNode);return o},Pn=function(t){var e,r=t==null||(e=t.getAttribute)===null||e===void 0?void 0:e.call(t,"contenteditable");return r===""||r==="true"},te=function(t,e,r){if(j(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(rt));return e&&I.call(t,rt)&&s.unshift(t),s=s.filter(r),s},it=function(t,e,r){for(var s=[],i=Array.from(t);i.length;){var o=i.shift();if(!j(o,!1))if(o.tagName==="SLOT"){var u=o.assignedElements(),a=u.length?u:o.children,c=it(a,!0,r);r.flatten?s.push.apply(s,c):s.push({scopeParent:o,candidates:c})}else{var p=I.call(o,rt);p&&r.filter(o)&&(e||!t.includes(o))&&s.push(o);var l=o.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(o),m=!j(l,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(o));if(l&&m){var y=it(l===!0?o.children:l.children,!0,r);r.flatten?s.push.apply(s,y):s.push({scopeParent:o,candidates:y})}else i.unshift.apply(i,o.children)}}return s},ee=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},ne=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Pn(t))&&!ee(t)?0:t.tabIndex},Rn=function(t,e){var r=ne(t);return r<0&&e&&!ee(t)?0:r},Ln=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},re=function(t){return t.tagName==="INPUT"},Bn=function(t){return re(t)&&t.type==="hidden"},Kn=function(t){var e=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return e},Wn=function(t,e){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===e)return t[r]},_n=function(t){if(!t.name)return!0;var e=t.form||st(t),r=function(u){return e.querySelectorAll('input[type="radio"][name="'+u+'"]')},s;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")s=r(window.CSS.escape(t.name));else try{s=r(t.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var i=Wn(s,t.form);return!i||i===t},Un=function(t){return re(t)&&t.type==="radio"},Vn=function(t){return Un(t)&&!_n(t)},Gn=function(t){var e,r=t&&st(t),s=(e=r)===null||e===void 0?void 0:e.host,i=!1;if(r&&r!==t){var o,u,a;for(i=!!((o=s)!==null&&o!==void 0&&(u=o.ownerDocument)!==null&&u!==void 0&&u.contains(s)||t!=null&&(a=t.ownerDocument)!==null&&a!==void 0&&a.contains(t));!i&&s;){var c,p,l;r=st(s),s=(c=r)===null||c===void 0?void 0:c.host,i=!!((p=s)!==null&&p!==void 0&&(l=p.ownerDocument)!==null&&l!==void 0&&l.contains(s))}}return i},It=function(t){var e=t.getBoundingClientRect(),r=e.width,s=e.height;return r===0&&s===0},qn=function(t,e){var r=e.displayCheck,s=e.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var i=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(t).visibility==="hidden")return!0;var o=I.call(t,"details>summary:first-of-type"),u=o?t.parentElement:t;if(I.call(u,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof s=="function"){for(var a=t;t;){var c=t.parentElement,p=st(t);if(c&&!c.shadowRoot&&s(c)===!0)return It(t);t.assignedSlot?t=t.assignedSlot:!c&&p!==t.ownerDocument?t=p.host:t=c}t=a}if(Gn(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return It(t);return!1},Hn=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if(e.tagName==="FIELDSET"&&e.disabled){for(var r=0;r<e.children.length;r++){var s=e.children.item(r);if(s.tagName==="LEGEND")return I.call(e,"fieldset[disabled] *")?!0:!s.contains(t)}return!0}e=e.parentElement}return!1},ot=function(t,e){return!(e.disabled||j(e)||Bn(e)||qn(e,t)||Kn(e)||Hn(e))},pt=function(t,e){return!(Vn(e)||ne(e)<0||!ot(t,e))},jn=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},se=function(t){var e=[],r=[];return t.forEach(function(s,i){var o=!!s.scopeParent,u=o?s.scopeParent:s,a=Rn(u,o),c=o?se(s.candidates):u;a===0?o?e.push.apply(e,c):e.push(u):r.push({documentOrder:i,tabIndex:a,item:s,isScope:o,content:c})}),r.sort(Ln).reduce(function(s,i){return i.isScope?s.push.apply(s,i.content):s.push(i.content),s},[]).concat(e)},ie=function(t,e){e=e||{};var r;return e.getShadowRoot?r=it([t],e.includeContainer,{filter:pt.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:jn}):r=te(t,e.includeContainer,pt.bind(null,e)),se(r)},oe=function(t,e){e=e||{};var r;return e.getShadowRoot?r=it([t],e.includeContainer,{filter:ot.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):r=te(t,e.includeContainer,ot.bind(null,e)),r},vt=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return I.call(t,rt)===!1?!1:pt(e,t)},zn=Qt.concat("iframe").join(","),ue=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return I.call(t,zn)===!1?!1:ot(e,t)};function q(){return{getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"}}function Yn(n,t){if(!vt(n,q()))return Xn(n,t);const e=Y(n),r=ie(e.body,q());t==="prev"&&r.reverse();const s=r.indexOf(n);return s===-1?e.body:r.slice(s+1)[0]}function Xn(n,t){const e=Y(n);if(!ue(n,q()))return e.body;const r=oe(e.body,q());t==="prev"&&r.reverse();const s=r.indexOf(n);return s===-1?e.body:r.slice(s+1).find(o=>vt(o,q()))??e.body}function rs(n,t){const e=[];for(let r=0;r<n.length;r+=t)e.push(n.slice(r,r+t));return e}function ss(n,t){return n>=0&&n<t.length}function is(n,t,e=!0){if(!(n.length===0||t<0||t>=n.length))return n.length===1&&t===0?n[0]:t===n.length-1?e?n[0]:void 0:n[t+1]}function os(n,t,e=!0){if(!(n.length===0||t<0||t>=n.length))return n.length===1&&t===0?n[0]:t===0?e?n[n.length-1]:void 0:n[t-1]}function us(n,t,e,r=!0){if(n.length===0||t<0||t>=n.length)return;let s=t+e;return r?s=(s%n.length+n.length)%n.length:s=Math.max(0,Math.min(s,n.length-1)),n[s]}function as(n,t,e,r=!0){if(n.length===0||t<0||t>=n.length)return;let s=t-e;return r?s=(s%n.length+n.length)%n.length:s=Math.max(0,Math.min(s,n.length-1)),n[s]}function ae(n,t,e){const r=t.toLowerCase();if(r.endsWith(" ")){const l=r.slice(0,-1);if(n.filter(F=>F.toLowerCase().startsWith(l)).length<=1)return ae(n,l,e);const y=e?.toLowerCase();if(y&&y.startsWith(l)&&y.charAt(l.length)===" "&&t.trim()===l)return e;const J=n.filter(F=>F.toLowerCase().startsWith(r));if(J.length>0){const F=e?n.indexOf(e):-1;return Nt(J,Math.max(F,0)).find(we=>we!==e)||e}}const i=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,o=i.toLowerCase(),u=e?n.indexOf(e):-1;let a=Nt(n,Math.max(u,0));i.length===1&&(a=a.filter(l=>l!==e));const p=a.find(l=>l?.toLowerCase().startsWith(o));return p!==e?p:void 0}function Nt(n,t){return n.map((e,r)=>n[(t+r)%n.length])}const Zn={afterMs:1e4,onChange:w};function ce(n,t){const{afterMs:e,onChange:r,getWindow:s}={...Zn,...t};let i=null,o=v(Rt(n));function u(){return s().setTimeout(()=>{h(o,n,!0),r?.(n)},e)}return N(()=>()=>{i&&s().clearTimeout(i)}),f(()=>d(o),a=>{h(o,a,!0),r?.(a),i&&s().clearTimeout(i),i=u()})}class Jn{#t;#e;#n=T(()=>this.#t.onMatch?this.#t.onMatch:t=>t.focus());#r=T(()=>this.#t.getCurrentItem?this.#t.getCurrentItem:this.#t.getActiveElement);constructor(t){this.#t=t,this.#e=ce("",{afterMs:1e3,getWindow:t.getWindow}),this.handleTypeaheadSearch=this.handleTypeaheadSearch.bind(this),this.resetTypeahead=this.resetTypeahead.bind(this)}handleTypeaheadSearch(t,e){if(!e.length)return;this.#e.current=this.#e.current+t;const r=d(this.#r)(),s=e.find(a=>a===r)?.textContent?.trim()??"",i=e.map(a=>a.textContent?.trim()??""),o=ae(i,this.#e.current,s),u=e.find(a=>a.textContent?.trim()===o);return u&&d(this.#n)(u),u}resetTypeahead(){this.#e.current=""}get search(){return this.#e.current}}class Qn{#t;#e;#n;#r=v(null);constructor(t){this.#t=t,this.#e=T(()=>this.#t.enabled()),this.#n=ce(!1,{afterMs:t.transitTimeout??300,onChange:e=>{d(this.#e)&&this.#t.setIsPointerInTransit?.(e)},getWindow:()=>Vt(this.#t.triggerNode())}),S([t.triggerNode,t.contentNode,t.enabled],([e,r,s])=>{if(!e||!r||!s)return;const i=u=>{this.#i(u,r)},o=u=>{this.#i(u,e)};return D(g(e,"pointerleave",i),g(r,"pointerleave",o))}),S(()=>d(this.#r),()=>{const e=s=>{if(!d(this.#r))return;const i=s.target;if(!dt(i))return;const o={x:s.clientX,y:s.clientY},u=t.triggerNode()?.contains(i)||t.contentNode()?.contains(i),a=!nr(o,d(this.#r));u?this.#s():a&&(this.#s(),t.onPointerExit())},r=Y(t.triggerNode()??t.contentNode());if(r)return g(r,"pointermove",e)})}#s(){h(this.#r,null),this.#n.current=!1}#i(t,e){const r=t.currentTarget;if(!C(r))return;const s={x:t.clientX,y:t.clientY},i=$n(s,r.getBoundingClientRect()),o=tr(s,i),u=er(e.getBoundingClientRect()),a=rr([...o,...u]);h(this.#r,a,!0),this.#n.current=!0}}function $n(n,t){const e=Math.abs(t.top-n.y),r=Math.abs(t.bottom-n.y),s=Math.abs(t.right-n.x),i=Math.abs(t.left-n.x);switch(Math.min(e,r,s,i)){case i:return"left";case s:return"right";case e:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function tr(n,t,e=5){const r=e*1.5;switch(t){case"top":return[{x:n.x-e,y:n.y+e},{x:n.x,y:n.y-r},{x:n.x+e,y:n.y+e}];case"bottom":return[{x:n.x-e,y:n.y-e},{x:n.x,y:n.y+r},{x:n.x+e,y:n.y-e}];case"left":return[{x:n.x+e,y:n.y-e},{x:n.x-r,y:n.y},{x:n.x+e,y:n.y+e}];case"right":return[{x:n.x-e,y:n.y-e},{x:n.x+r,y:n.y},{x:n.x-e,y:n.y+e}]}}function er(n){const{top:t,right:e,bottom:r,left:s}=n;return[{x:s,y:t},{x:e,y:t},{x:e,y:r},{x:s,y:r}]}function nr(n,t){const{x:e,y:r}=n;let s=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const u=t[i].x,a=t[i].y,c=t[o].x,p=t[o].y;a>r!=p>r&&e<(c-u)*(r-a)/(p-a)+u&&(s=!s)}return s}function rr(n){const t=n.slice();return t.sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:e.y>r.y?1:0),sr(t)}function sr(n){if(n.length<=1)return n.slice();const t=[];for(let r=0;r<n.length;r++){const s=n[r];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))t.pop();else break}t.push(s)}t.pop();const e=[];for(let r=n.length-1;r>=0;r--){const s=n[r];for(;e.length>=2;){const i=e[e.length-1],o=e[e.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))e.pop();else break}e.push(s)}return e.pop(),t.length===1&&e.length===1&&t[0].x===e[0].x&&t[0].y===e[0].y?t:t.concat(e)}const ir="data-context-menu-trigger",or="data-context-menu-content",yt=new z("Menu.Root"),P=new z("Menu.Root | Menu.Sub"),wt=new z("Menu.Content"),ur=new z("Menu.Group | Menu.RadioGroup"),le=new An("bitsmenuopen",{bubbles:!1,cancelable:!0}),ar=Ge({component:"menu",parts:["trigger","content","sub-trigger","item","group","group-heading","checkbox-group","checkbox-item","radio-group","radio-item","separator","sub-content","arrow"]});class he{static create(t){const e=new he(t);return yt.set(e)}opts;isUsingKeyboard=new x;#t=v(!1);get ignoreCloseAutoFocus(){return d(this.#t)}set ignoreCloseAutoFocus(t){h(this.#t,t,!0)}#e=v(!1);get isPointerInTransit(){return d(this.#e)}set isPointerInTransit(t){h(this.#e,t,!0)}constructor(t){this.opts=t}getBitsAttr=t=>ar.getAttr(t,this.opts.variant.current)}class Tt{static create(t,e){return P.set(new Tt(t,e,null))}opts;root;parentMenu;contentId=f(()=>"");#t=v(null);get contentNode(){return d(this.#t)}set contentNode(t){h(this.#t,t,!0)}contentPresence;#e=v(null);get triggerNode(){return d(this.#e)}set triggerNode(t){h(this.#e,t,!0)}constructor(t,e,r){this.opts=t,this.root=e,this.parentMenu=r,this.contentPresence=new wn({ref:f(()=>this.contentNode),open:this.opts.open,onComplete:()=>{this.opts.onOpenChangeComplete.current(this.opts.open.current)}}),r&&S(()=>r.opts.open.current,()=>{r.opts.open.current||(this.opts.open.current=!1)})}toggleOpen(){this.opts.open.current=!this.opts.open.current}onOpen(){this.opts.open.current=!0}onClose(){this.opts.open.current=!1}}class de{static create(t){return wt.set(new de(t,P.get()))}opts;parentMenu;rovingFocusGroup;domContext;attachment;#t=v("");get search(){return d(this.#t)}set search(t){h(this.#t,t,!0)}#e=0;#n;#r=v(!1);get mounted(){return d(this.#r)}set mounted(t){h(this.#r,t,!0)}#s;constructor(t,e){this.opts=t,this.parentMenu=e,this.domContext=new mt(t.ref),this.attachment=W(this.opts.ref,r=>{this.parentMenu.contentNode!==r&&(this.parentMenu.contentNode=r)}),e.contentId=t.id,this.#s=t.isSub??!1,this.onkeydown=this.onkeydown.bind(this),this.onblur=this.onblur.bind(this),this.onfocus=this.onfocus.bind(this),this.handleInteractOutside=this.handleInteractOutside.bind(this),new Qn({contentNode:()=>this.parentMenu.contentNode,triggerNode:()=>this.parentMenu.triggerNode,enabled:()=>this.parentMenu.opts.open.current&&!!this.parentMenu.triggerNode?.hasAttribute(this.parentMenu.root.getBitsAttr("sub-trigger")),onPointerExit:()=>{this.parentMenu.opts.open.current=!1},setIsPointerInTransit:r=>{this.parentMenu.root.isPointerInTransit=r}}),this.#n=new Jn({getActiveElement:()=>this.domContext.getActiveElement(),getWindow:()=>this.domContext.getWindow()}).handleTypeaheadSearch,this.rovingFocusGroup=new vn({rootNode:f(()=>this.parentMenu.contentNode),candidateAttr:this.parentMenu.root.getBitsAttr("item"),loop:this.opts.loop,orientation:f(()=>"vertical")}),S(()=>this.parentMenu.contentNode,r=>{if(!r)return;const s=()=>{E(()=>{this.parentMenu.root.isUsingKeyboard.current&&this.rovingFocusGroup.focusFirstCandidate()})};return le.listen(r,s)}),N(()=>{this.parentMenu.opts.open.current||this.domContext.getWindow().clearTimeout(this.#e)})}#i(){const t=this.parentMenu.contentNode;return t?Array.from(t.querySelectorAll(`[${this.parentMenu.root.getBitsAttr("item")}]:not([data-disabled])`)):[]}#u(){return this.parentMenu.root.isPointerInTransit}onCloseAutoFocus=t=>{this.opts.onCloseAutoFocus.current?.(t),!(t.defaultPrevented||this.#s)&&this.parentMenu.triggerNode&&vt(this.parentMenu.triggerNode)&&(t.preventDefault(),this.parentMenu.triggerNode.focus())};handleTabKeyDown(t){let e=this.parentMenu;for(;e.parentMenu!==null;)e=e.parentMenu;if(!e.triggerNode)return;t.preventDefault();const r=Yn(e.triggerNode,t.shiftKey?"prev":"next");r?(this.parentMenu.root.ignoreCloseAutoFocus=!0,e.onClose(),E(()=>{r.focus(),E(()=>{this.parentMenu.root.ignoreCloseAutoFocus=!1})})):this.domContext.getDocument().body.focus()}onkeydown(t){if(t.defaultPrevented)return;if(t.key===hn){this.handleTabKeyDown(t);return}const e=t.target,r=t.currentTarget;if(!C(e)||!C(r))return;const s=e.closest(`[${this.parentMenu.root.getBitsAttr("content")}]`)?.id===this.parentMenu.contentId.current,i=t.ctrlKey||t.altKey||t.metaKey,o=t.key.length===1;if(this.rovingFocusGroup.handleKeydown(e,t)||t.code==="Space")return;const a=this.#i();s&&!i&&o&&this.#n(t.key,a),t.target?.id===this.parentMenu.contentId.current&&In.includes(t.key)&&(t.preventDefault(),Jt.includes(t.key)&&a.reverse(),Dn(a,{select:!1},()=>this.domContext.getActiveElement()))}onblur(t){dt(t.currentTarget)&&dt(t.target)&&(t.currentTarget.contains?.(t.target)||(this.domContext.getWindow().clearTimeout(this.#e),this.search=""))}onfocus(t){this.parentMenu.root.isUsingKeyboard.current&&E(()=>this.rovingFocusGroup.focusFirstCandidate())}onItemEnter(){return this.#u()}onItemLeave(t){if(t.currentTarget.hasAttribute(this.parentMenu.root.getBitsAttr("sub-trigger"))||this.#u()||this.parentMenu.root.isUsingKeyboard.current)return;this.parentMenu.contentNode?.focus(),this.rovingFocusGroup.setCurrentTabStopId("")}onTriggerLeave(){return!!this.#u()}handleInteractOutside(t){if(!zt(t.target))return;const e=this.parentMenu.triggerNode?.id;if(t.target.id===e){t.preventDefault();return}t.target.closest(`#${e}`)&&t.preventDefault()}get shouldRender(){return this.parentMenu.contentPresence.shouldRender}#o=T(()=>({open:this.parentMenu.opts.open.current}));get snippetProps(){return d(this.#o)}set snippetProps(t){h(this.#o,t)}#a=T(()=>({id:this.opts.id.current,role:"menu","aria-orientation":"vertical",[this.parentMenu.root.getBitsAttr("content")]:"","data-state":gt(this.parentMenu.opts.open.current),onkeydown:this.onkeydown,onblur:this.onblur,onfocus:this.onfocus,dir:this.parentMenu.root.opts.dir.current,style:{pointerEvents:"auto"},...this.attachment}));get props(){return d(this.#a)}set props(t){h(this.#a,t)}popperProps={onCloseAutoFocus:t=>this.onCloseAutoFocus(t)}}class fe{opts;content;attachment;#t=v(!1);constructor(t,e){this.opts=t,this.content=e,this.attachment=W(this.opts.ref),this.onpointermove=this.onpointermove.bind(this),this.onpointerleave=this.onpointerleave.bind(this),this.onfocus=this.onfocus.bind(this),this.onblur=this.onblur.bind(this)}onpointermove(t){if(!t.defaultPrevented&&nt(t))if(this.opts.disabled.current)this.content.onItemLeave(t);else{if(this.content.onItemEnter())return;const r=t.currentTarget;if(!C(r))return;r.focus()}}onpointerleave(t){t.defaultPrevented||nt(t)&&this.content.onItemLeave(t)}onfocus(t){E(()=>{t.defaultPrevented||this.opts.disabled.current||h(this.#t,!0)})}onblur(t){E(()=>{t.defaultPrevented||h(this.#t,!1)})}#e=T(()=>({id:this.opts.id.current,tabindex:-1,role:"menuitem","aria-disabled":bt(this.opts.disabled.current),"data-disabled":Bt(this.opts.disabled.current),"data-highlighted":d(this.#t)?"":void 0,[this.content.parentMenu.root.getBitsAttr("item")]:"",onpointermove:this.onpointermove,onpointerleave:this.onpointerleave,onfocus:this.onfocus,onblur:this.onblur,...this.attachment}));get props(){return d(this.#e)}set props(t){h(this.#e,t)}}class pe{static create(t){const e=new fe(t,wt.get());return new pe(t,e)}opts;item;root;#t=!1;constructor(t,e){this.opts=t,this.item=e,this.root=e.content.parentMenu.root,this.onkeydown=this.onkeydown.bind(this),this.onclick=this.onclick.bind(this),this.onpointerdown=this.onpointerdown.bind(this),this.onpointerup=this.onpointerup.bind(this)}#e(){if(this.item.opts.disabled.current)return;const t=new CustomEvent("menuitemselect",{bubbles:!0,cancelable:!0});if(this.opts.onSelect.current(t),t.defaultPrevented){this.item.content.parentMenu.root.isUsingKeyboard.current=!1;return}this.opts.closeOnSelect.current&&this.item.content.parentMenu.root.opts.onClose()}onkeydown(t){const e=this.item.content.search!=="";if(!(this.item.opts.disabled.current||e&&t.key===at)&&ft.includes(t.key)){if(!C(t.currentTarget))return;t.currentTarget.click(),t.preventDefault()}}onclick(t){this.item.opts.disabled.current||this.#e()}onpointerup(t){if(!t.defaultPrevented&&!this.#t){if(!C(t.currentTarget))return;t.currentTarget?.click()}}onpointerdown(t){this.#t=!0}#n=T(()=>Kt(this.item.props,{onclick:this.onclick,onpointerdown:this.onpointerdown,onpointerup:this.onpointerup,onkeydown:this.onkeydown}));get props(){return d(this.#n)}set props(t){h(this.#n,t)}}class ge{static create(t){const e=wt.get(),r=new fe(t,e),s=P.get();return new ge(t,r,e,s)}opts;item;content;submenu;attachment;#t=null;constructor(t,e,r,s){this.opts=t,this.item=e,this.content=r,this.submenu=s,this.attachment=W(this.opts.ref,i=>this.submenu.triggerNode=i),this.onpointerleave=this.onpointerleave.bind(this),this.onpointermove=this.onpointermove.bind(this),this.onkeydown=this.onkeydown.bind(this),this.onclick=this.onclick.bind(this),_(()=>{this.#e()})}#e(){this.#t!==null&&(this.content.domContext.getWindow().clearTimeout(this.#t),this.#t=null)}onpointermove(t){nt(t)&&!this.item.opts.disabled.current&&!this.submenu.opts.open.current&&!this.#t&&!this.content.parentMenu.root.isPointerInTransit&&(this.#t=this.content.domContext.setTimeout(()=>{this.submenu.onOpen(),this.#e()},this.opts.openDelay.current))}onpointerleave(t){nt(t)&&this.#e()}onkeydown(t){const e=this.content.search!=="";this.item.opts.disabled.current||e&&t.key===at||Nn[this.submenu.root.opts.dir.current].includes(t.key)&&(t.currentTarget.click(),t.preventDefault())}onclick(t){if(this.item.opts.disabled.current||!C(t.currentTarget))return;t.currentTarget.focus();const e=new CustomEvent("menusubtriggerselect",{bubbles:!0,cancelable:!0});this.opts.onSelect.current(e),this.submenu.opts.open.current||(this.submenu.onOpen(),E(()=>{const r=this.submenu.contentNode;r&&le.dispatch(r)}))}#n=T(()=>Kt({"aria-haspopup":"menu","aria-expanded":bt(this.submenu.opts.open.current),"data-state":gt(this.submenu.opts.open.current),"aria-controls":this.submenu.opts.open.current?this.submenu.contentId.current:void 0,[this.submenu.root.getBitsAttr("sub-trigger")]:"",onclick:this.onclick,onpointermove:this.onpointermove,onpointerleave:this.onpointerleave,onkeydown:this.onkeydown,...this.attachment},this.item.props));get props(){return d(this.#n)}set props(t){h(this.#n,t)}}class be{static create(t){return ur.set(new be(t,yt.get()))}opts;root;attachment;#t=v(void 0);get groupHeadingId(){return d(this.#t)}set groupHeadingId(t){h(this.#t,t,!0)}constructor(t,e){this.opts=t,this.root=e,this.attachment=W(this.opts.ref)}#e=T(()=>({id:this.opts.id.current,role:"group","aria-labelledby":this.groupHeadingId,[this.root.getBitsAttr("group")]:"",...this.attachment}));get props(){return d(this.#e)}set props(t){h(this.#e,t)}}class me{static create(t){return new me(t,yt.get())}opts;root;attachment;constructor(t,e){this.opts=t,this.root=e,this.attachment=W(this.opts.ref)}#t=T(()=>({id:this.opts.id.current,role:"group",[this.root.getBitsAttr("separator")]:"",...this.attachment}));get props(){return d(this.#t)}set props(t){h(this.#t,t)}}class ve{static create(t){return new ve(t,P.get())}opts;parentMenu;attachment;constructor(t,e){this.opts=t,this.parentMenu=e,this.attachment=W(this.opts.ref,r=>this.parentMenu.triggerNode=r)}onclick=t=>{this.opts.disabled.current||t.detail!==0||(this.parentMenu.toggleOpen(),t.preventDefault())};onpointerdown=t=>{if(!this.opts.disabled.current){if(t.pointerType==="touch")return t.preventDefault();t.button===0&&t.ctrlKey===!1&&(this.parentMenu.toggleOpen(),this.parentMenu.opts.open.current||t.preventDefault())}};onpointerup=t=>{this.opts.disabled.current||t.pointerType==="touch"&&(t.preventDefault(),this.parentMenu.toggleOpen())};onkeydown=t=>{if(!this.opts.disabled.current){if(t.key===at||t.key===qt){this.parentMenu.toggleOpen(),t.preventDefault();return}t.key===H&&(this.parentMenu.onOpen(),t.preventDefault())}};#t=T(()=>{if(this.parentMenu.opts.open.current&&this.parentMenu.contentId.current)return this.parentMenu.contentId.current});#e=T(()=>({id:this.opts.id.current,disabled:this.opts.disabled.current,"aria-haspopup":"menu","aria-expanded":bt(this.parentMenu.opts.open.current),"aria-controls":d(this.#t),"data-disabled":Bt(this.opts.disabled.current),"data-state":gt(this.parentMenu.opts.open.current),[this.parentMenu.root.getBitsAttr("trigger")]:"",onclick:this.onclick,onpointerdown:this.onpointerdown,onpointerup:this.onpointerup,onkeydown:this.onkeydown,...this.attachment}));get props(){return d(this.#e)}set props(t){h(this.#e,t)}}class cs{static create(t){const e=P.get();return P.set(new Tt(t,e.root,e))}}globalThis.bitsDismissableLayers??=new Map;class St{static create(t){return new St(t)}opts;#t;#e;#n={pointerdown:!1};#r=!1;#s=!1;#i=void 0;#u;#o=w;constructor(t){this.opts=t,this.#e=t.interactOutsideBehavior,this.#t=t.onInteractOutside,this.#u=t.onFocusOutside,N(()=>{this.#i=Zt(this.opts.ref.current)});let e=w;const r=()=>{this.#d(),globalThis.bitsDismissableLayers.delete(this),this.#c.destroy(),e()};S([()=>this.opts.enabled.current,()=>this.opts.ref.current],()=>{if(!(!this.opts.enabled.current||!this.opts.ref.current))return $e(1,()=>{this.opts.ref.current&&(globalThis.bitsDismissableLayers.set(this,this.#e),e(),e=this.#h())}),r}),_(()=>{this.#d.destroy(),globalThis.bitsDismissableLayers.delete(this),this.#c.destroy(),this.#o(),e()})}#a=t=>{t.defaultPrevented||this.opts.ref.current&&E(()=>{!this.opts.ref.current||this.#b(t.target)||t.target&&!this.#s&&this.#u.current?.(t)})};#h(){return D(g(this.#i,"pointerdown",D(this.#f,this.#g),{capture:!0}),g(this.#i,"pointerdown",D(this.#p,this.#c)),g(this.#i,"focusin",this.#a))}#l=t=>{let e=t;e.defaultPrevented&&(e=Ot(t)),this.#t.current(t)};#c=Ft(t=>{if(!this.opts.ref.current){this.#o();return}const e=this.opts.isValidEvent.current(t,this.opts.ref.current)||hr(t,this.opts.ref.current);if(!this.#r||this.#m()||!e){this.#o();return}let r=t;if(r.defaultPrevented&&(r=Ot(r)),this.#e.current!=="close"&&this.#e.current!=="defer-otherwise-close"){this.#o();return}t.pointerType==="touch"?(this.#o(),this.#o=g(this.#i,"click",this.#l,{once:!0})):this.#t.current(r)},10);#f=t=>{this.#n[t.type]=!0};#p=t=>{this.#n[t.type]=!1};#g=()=>{this.opts.ref.current&&(this.#r=lr(this.opts.ref.current))};#b=t=>this.opts.ref.current?Xt(this.opts.ref.current,t):!1;#d=Ft(()=>{for(const t in this.#n)this.#n[t]=!1;this.#r=!1},20);#m(){return Object.values(this.#n).some(Boolean)}#v=()=>{this.#s=!0};#y=()=>{this.#s=!1};props={onfocuscapture:this.#v,onblurcapture:this.#y}}function cr(n=[...globalThis.bitsDismissableLayers]){return n.findLast(([t,{current:e}])=>e==="close"||e==="ignore")}function lr(n){const t=[...globalThis.bitsDismissableLayers],e=cr(t);if(e)return e[0].opts.ref.current===n;const[r]=t[0];return r.opts.ref.current===n}function hr(n,t){const e=n.target;if(!zt(e))return!1;const r=!!e.closest(`[${ir}]`);if("button"in n&&n.button>0&&!r)return!1;if("button"in n&&n.button===0&&r)return!0;const s=!!t.closest(`[${or}]`);return r&&s?!1:Zt(e).documentElement.contains(e)&&!Xt(t,e)&&kn(n,t)}function Ot(n){const t=n.currentTarget,e=n.target;let r;n instanceof PointerEvent?r=new PointerEvent(n.type,n):r=new PointerEvent("pointerdown",n);let s=!1;return new Proxy(r,{get:(o,u)=>u==="currentTarget"?t:u==="target"?e:u==="preventDefault"?()=>{s=!0,typeof o.preventDefault=="function"&&o.preventDefault()}:u==="defaultPrevented"?s:u in o?o[u]:n[u]})}function ls(n,t){B(t,!0);let e=b(t,"interactOutsideBehavior",3,"close"),r=b(t,"onInteractOutside",3,w),s=b(t,"onFocusOutside",3,w),i=b(t,"isValidEvent",3,()=>!1);const o=St.create({id:f(()=>t.id),interactOutsideBehavior:f(()=>e()),onInteractOutside:f(()=>r()),enabled:f(()=>t.enabled),onFocusOutside:f(()=>s()),isValidEvent:f(()=>i()),ref:t.ref});var u=M(),a=A(u);R(a,()=>t.children??L,()=>({props:o.props})),k(n,u),K()}globalThis.bitsEscapeLayers??=new Map;class Et{static create(t){return new Et(t)}opts;domContext;constructor(t){this.opts=t,this.domContext=new mt(this.opts.ref);let e=w;S(()=>t.enabled.current,r=>(r&&(globalThis.bitsEscapeLayers.set(this,t.escapeKeydownBehavior),e=this.#t()),()=>{e(),globalThis.bitsEscapeLayers.delete(this)}))}#t=()=>g(this.domContext.getDocument(),"keydown",this.#e,{passive:!1});#e=t=>{if(t.key!==an||!dr(this))return;const e=new KeyboardEvent(t.type,t);t.preventDefault();const r=this.opts.escapeKeydownBehavior.current;r!=="close"&&r!=="defer-otherwise-close"||this.opts.onEscapeKeydown.current(e)}}function dr(n){const t=[...globalThis.bitsEscapeLayers],e=t.findLast(([s,{current:i}])=>i==="close"||i==="ignore");if(e)return e[0]===n;const[r]=t[0];return r===n}function hs(n,t){B(t,!0);let e=b(t,"escapeKeydownBehavior",3,"close"),r=b(t,"onEscapeKeydown",3,w);Et.create({escapeKeydownBehavior:f(()=>e()),onEscapeKeydown:f(()=>r()),enabled:f(()=>t.enabled),ref:t.ref});var s=M(),i=A(s);R(i,()=>t.children??L),k(n,s),K()}class Ct{static instance;#t=qe([]);#e=new WeakMap;#n=new WeakMap;static getInstance(){return this.instance||(this.instance=new Ct),this.instance}register(t){const e=this.getActive();e&&e!==t&&e.pause();const r=document.activeElement;r&&r!==document.body&&this.#n.set(t,r),this.#t.current=this.#t.current.filter(s=>s!==t),this.#t.current.unshift(t)}unregister(t){this.#t.current=this.#t.current.filter(r=>r!==t);const e=this.getActive();e&&e.resume()}getActive(){return this.#t.current[0]}setFocusMemory(t,e){this.#e.set(t,e)}getFocusMemory(t){return this.#e.get(t)}isActiveScope(t){return this.getActive()===t}setPreFocusMemory(t,e){this.#n.set(t,e)}getPreFocusMemory(t){return this.#n.get(t)}clearPreFocusMemory(t){this.#n.delete(t)}}class xt{#t=!1;#e=null;#n=Ct.getInstance();#r=[];#s;constructor(t){this.#s=t}get paused(){return this.#t}pause(){this.#t=!0}resume(){this.#t=!1}#i(){for(const t of this.#r)t();this.#r=[]}mount(t){this.#e&&this.unmount(),this.#e=t,this.#n.register(this),this.#a(),this.#u()}unmount(){this.#e&&(this.#i(),this.#o(),this.#n.unregister(this),this.#n.clearPreFocusMemory(this),this.#e=null)}#u(){if(!this.#e)return;const t=new CustomEvent("focusScope.onOpenAutoFocus",{bubbles:!1,cancelable:!0});this.#s.onOpenAutoFocus.current(t),t.defaultPrevented||requestAnimationFrame(()=>{if(!this.#e)return;const e=this.#l();e?(e.focus(),this.#n.setFocusMemory(this,e)):this.#e.focus()})}#o(){const t=new CustomEvent("focusScope.onCloseAutoFocus",{bubbles:!1,cancelable:!0});if(this.#s.onCloseAutoFocus.current?.(t),!t.defaultPrevented){const e=this.#n.getPreFocusMemory(this);if(e&&document.contains(e))try{e.focus()}catch{document.body.focus()}}}#a(){if(!this.#e||!this.#s.trap.current)return;const t=this.#e,e=t.ownerDocument,r=o=>{if(this.#t||!this.#n.isActiveScope(this))return;const u=o.target;if(!u)return;if(t.contains(u))this.#n.setFocusMemory(this,u);else{const c=this.#n.getFocusMemory(this);if(c&&t.contains(c)&&ue(c))o.preventDefault(),c.focus();else{const p=this.#l(),l=this.#c()[0];(p||l||t).focus()}}},s=o=>{if(!this.#s.loop||this.#t||o.key!=="Tab"||!this.#n.isActiveScope(this))return;const u=this.#h();if(u.length<2)return;const a=u[0],c=u[u.length-1];!o.shiftKey&&e.activeElement===c?(o.preventDefault(),a.focus()):o.shiftKey&&e.activeElement===a&&(o.preventDefault(),c.focus())};this.#r.push(g(e,"focusin",r,{capture:!0}),g(t,"keydown",s));const i=new MutationObserver(()=>{const o=this.#n.getFocusMemory(this);if(o&&!t.contains(o)){const u=this.#l(),a=this.#c()[0],c=u||a;c?(c.focus(),this.#n.setFocusMemory(this,c)):t.focus()}});i.observe(t,{childList:!0,subtree:!0}),this.#r.push(()=>i.disconnect())}#h(){return this.#e?ie(this.#e,{includeContainer:!1,getShadowRoot:!0}):[]}#l(){return this.#h()[0]||null}#c(){return this.#e?oe(this.#e,{includeContainer:!1,getShadowRoot:!0}):[]}static use(t){let e=null;return S([()=>t.ref.current,()=>t.enabled.current],([r,s])=>{r&&s?(e||(e=new xt(t)),e.mount(r)):e&&(e.unmount(),e=null)}),_(()=>{e?.unmount()}),{get props(){return{tabindex:-1}}}}}function ds(n,t){B(t,!0);let e=b(t,"enabled",3,!1),r=b(t,"trapFocus",3,!1),s=b(t,"loop",3,!1),i=b(t,"onCloseAutoFocus",3,w),o=b(t,"onOpenAutoFocus",3,w);const u=xt.use({enabled:f(()=>e()),trap:f(()=>r()),loop:s(),onCloseAutoFocus:f(()=>i()),onOpenAutoFocus:f(()=>o()),ref:t.ref});var a=M(),c=A(a);R(c,()=>t.focusScope??L,()=>({props:u.props})),k(n,a),K()}globalThis.bitsTextSelectionLayers??=new Map;class Mt{static create(t){return new Mt(t)}opts;domContext;#t=w;constructor(t){this.opts=t,this.domContext=new mt(t.ref);let e=w;S(()=>this.opts.enabled.current,r=>(r&&(globalThis.bitsTextSelectionLayers.set(this,this.opts.enabled),e(),e=this.#e()),()=>{e(),this.#r(),globalThis.bitsTextSelectionLayers.delete(this)}))}#e(){return D(g(this.domContext.getDocument(),"pointerdown",this.#n),g(this.domContext.getDocument(),"pointerup",He(this.#r,this.opts.onPointerUp.current)))}#n=t=>{const e=this.opts.ref.current,r=t.target;!C(e)||!C(r)||!this.opts.enabled.current||!pr(this)||!on(e,r)||(this.opts.onPointerDown.current(t),!t.defaultPrevented&&(this.#t=fr(e,this.domContext.getDocument().body)))};#r=()=>{this.#t(),this.#t=w}}const Dt=n=>n.style.userSelect||n.style.webkitUserSelect;function fr(n,t){const e=Dt(t),r=Dt(n);return Q(t,"none"),Q(n,"text"),()=>{Q(t,e),Q(n,r)}}function Q(n,t){n.style.userSelect=t,n.style.webkitUserSelect=t}function pr(n){const t=[...globalThis.bitsTextSelectionLayers];if(!t.length)return!1;const e=t.at(-1);return e?e[0]===n:!1}function fs(n,t){B(t,!0);let e=b(t,"preventOverflowTextSelection",3,!0),r=b(t,"onPointerDown",3,w),s=b(t,"onPointerUp",3,w);Mt.create({id:f(()=>t.id),onPointerDown:f(()=>r()),onPointerUp:f(()=>s()),enabled:f(()=>t.enabled&&e()),ref:t.ref});var i=M(),o=A(i);R(o,()=>t.children??L),k(n,i),K()}globalThis.bitsIdCounter??={current:0};function gr(n="bits"){return globalThis.bitsIdCounter.current++,`${n}-${globalThis.bitsIdCounter.current}`}class br{#t;#e=0;#n=v();#r;constructor(t){this.#t=t}#s(){this.#e-=1,this.#r&&this.#e<=0&&(this.#r(),h(this.#n,void 0),this.#r=void 0)}get(...t){return this.#e+=1,d(this.#n)===void 0&&(this.#r=Lt(()=>{h(this.#n,this.#t(...t),!0)})),N(()=>()=>{this.#s()}),d(this.#n)}}const tt=new je;let $=v(null),ct=null,U=null,V=!1;const Pt=f(()=>{for(const n of tt.values())if(n)return!0;return!1});let lt=null;const mr=new br(()=>{function n(){document.body.setAttribute("style",d($)??""),document.body.style.removeProperty("--scrollbar-width"),kt&&ct?.(),h($,null)}function t(){U!==null&&(window.clearTimeout(U),U=null)}function e(s,i){t(),V=!0,lt=Date.now();const o=lt,u=()=>{U=null,lt===o&&(ye(tt)?V=!1:(V=!1,i()))},a=s===null?24:s;U=window.setTimeout(u,a)}function r(){d($)===null&&tt.size===0&&!V&&h($,document.body.getAttribute("style"),!0)}return S(()=>Pt.current,()=>{if(!Pt.current)return;r(),V=!1;const s=getComputedStyle(document.body),i=window.innerWidth-document.documentElement.clientWidth,u={padding:Number.parseInt(s.paddingRight??"0",10)+i,margin:Number.parseInt(s.marginRight??"0",10)};i>0&&(document.body.style.paddingRight=`${u.padding}px`,document.body.style.marginRight=`${u.margin}px`,document.body.style.setProperty("--scrollbar-width",`${i}px`),document.body.style.overflow="hidden"),kt&&(ct=g(document,"touchmove",a=>{a.target===document.documentElement&&(a.touches.length>1||a.preventDefault())},{passive:!1})),E(()=>{document.body.style.pointerEvents="none",document.body.style.overflow="hidden"})}),_(()=>()=>{ct?.()}),{get lockMap(){return tt},resetBodyStyle:n,scheduleCleanupIfNoNewLocks:e,cancelPendingCleanup:t,ensureInitialStyleCaptured:r}});class vr{#t=gr();#e;#n=()=>null;#r;locked;constructor(t,e=()=>null){this.#e=t,this.#n=e,this.#r=mr.get(),this.#r&&(this.#r.cancelPendingCleanup(),this.#r.ensureInitialStyleCaptured(),this.#r.lockMap.set(this.#t,this.#e??!1),this.locked=f(()=>this.#r.lockMap.get(this.#t)??!1,r=>this.#r.lockMap.set(this.#t,r)),_(()=>{if(this.#r.lockMap.delete(this.#t),ye(this.#r.lockMap))return;const r=this.#n();this.#r.scheduleCleanupIfNoNewLocks(r,()=>{this.#r.resetBodyStyle()})}))}}function ye(n){for(const[t,e]of n)if(e)return!0;return!1}function ps(n,t){B(t,!0);let e=b(t,"preventScroll",3,!0),r=b(t,"restoreScrollDelay",3,null);e()&&new vr(e(),()=>r()),K()}let G=v(!1);class x{static _refs=0;static _cleanup;constructor(){N(()=>(x._refs===0&&(x._cleanup=Lt(()=>{const t=[],e=s=>{h(G,!1)},r=s=>{h(G,!0)};return t.push(g(document,"pointerdown",e,{capture:!0}),g(document,"pointermove",e,{capture:!0}),g(document,"keydown",r,{capture:!0})),D(...t)})),x._refs++,()=>{x._refs--,x._refs===0&&(h(G,!1),x._cleanup?.())}))}get current(){return d(G)}set current(t){h(G,t,!0)}}export{Z as $,ae as A,Jn as B,z as C,ls as D,qt as E,ds as F,Qn as G,et as H,H as I,hn as J,ln as K,Ht as L,pe as M,cn as N,Gt as O,ts as P,is as Q,vn as R,at as S,fs as T,os as U,us as V,as as W,E as X,kt as Y,an as Z,X as _,wn as a,qr as a0,Fr as a1,Ir as a2,Ar as a3,Gr as a4,Nr as a5,Rr as a6,Lr as a7,Br as a8,Kr as a9,Wr as aa,_r as ab,Ur as ac,Vr as ad,Or as ae,Dr as af,Pr as ag,kr as ah,es as ai,Xr as aj,Yr as ak,Hr as al,Zr as am,zr as an,jr as ao,jt as ap,Y as aq,ss as ar,rs as as,$r as at,be as au,dt as b,hs as c,ps as d,$e as e,me as f,he as g,Tt as h,C as i,de as j,ze as k,ve as l,mt as m,w as n,_ as o,Jr as p,Ye as q,Qr as r,Vt as s,cs as t,gr as u,le as v,S as w,ns as x,ge as y,ce as z};