tokentracker-cli 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{DashboardPage-C025vDYN.js → DashboardPage-BAb5mCnt.js} +1 -1
- package/dashboard/dist/assets/{LandingExtras-BDqTHI3x.js → LandingExtras-yaFs24Wt.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-BWJsZZGo.js → LeaderboardPage-5mTskSwq.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-Fm0S6umm.js → LeaderboardProfilePage-ccbyuG4J.js} +1 -1
- package/dashboard/dist/assets/{MatrixRain-_cKLHK44.js → MatrixRain-jvkSzQkB.js} +1 -1
- package/dashboard/dist/assets/{MatrixShell-DyMWapvD.js → MatrixShell-unVoF8fw.js} +1 -1
- package/dashboard/dist/assets/{main-DSjEYl46.js → main-DQ7YU0WX.js} +4 -4
- package/dashboard/dist/assets/{vibeusage-api-B9iVLrJk.js → vibeusage-api-BkDJCLN3.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/lib/fs.js +14 -0
- package/src/lib/local-api.js +9 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as m,u as bn,i as Ng,a as nt,g as Ig,b as yr,c as br,d as Wt,e as Ei,f as ks,h as fo,j as ia,k as cr,t as xt,l as _,T as Fg,m as b,n as Te,o as Bn,p as id,q as ad,s as he,N as ld,v as ts,w as ns,x as pn,y as Ve,z as Hr,E as Nn,A as jg,B as sn,C as Vl,D as ut,F as cd,G as vt,H as At,I as mn,J as or,K as Ae,L as on,M as _l,O as aa,P as la,Q as ur,R as In,S as Lg,U as ud,V as Vg,W as rs,X as ho,Y as dd,Z as _g,_ as fd,$ as Wg,a0 as hd,a1 as md,a2 as q,a3 as ca,a4 as pd,a5 as Bg,a6 as $g,a7 as Yg,a8 as Hg,a9 as Ug,aa as Gg,ab as Kg,ac as zg,ad as Qt,ae as qg,af as Xg,ag as Io}from"./main-DSjEYl46.js";import{g as Zg,a as ua,b as Qg,c as Jg,d as ey,e as Fo,f as ty,r as ny,h as Wl,i as ry,j as sy,t as oy,s as iy}from"./vibeusage-api-B9iVLrJk.js";const ay=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ly=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Bl=e=>{const t=ly(e);return t.charAt(0).toUpperCase()+t.slice(1)},gd=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),cy=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var uy={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const dy=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...a},l)=>m.createElement("svg",{ref:l,...uy,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:gd("lucide",s),...!o&&!cy(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,u])=>m.createElement(c,u)),...Array.isArray(o)?o:[o]]));const fy=(e,t)=>{const n=m.forwardRef(({className:r,...s},o)=>m.createElement(dy,{ref:o,iconNode:t,className:gd(`lucide-${ay(Bl(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Bl(e),n};const hy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],my=fy("info",hy),py=500,gy={style:{transition:"none"}},yd="data-base-ui-click-trigger",yy={fallbackAxisSide:"end"},by={clipPath:"inset(50%)",position:"fixed",top:0,left:0},xy=[];function da(e){m.useEffect(e,xy)}const Rr=0;class gn{static create(){return new gn}currentId=Rr;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Rr,n()},t)}isStarted(){return this.currentId!==Rr}clear=()=>{this.currentId!==Rr&&(clearTimeout(this.currentId),this.currentId=Rr)};disposeEffect=()=>this.clear}function Vn(){const e=bn(gn.create).current;return da(e.disposeEffect),e}function $n(e){return e?.ownerDocument||document}const xr=typeof navigator<"u",jo=Sy(),bd=Cy(),xd=Ty(),vy=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),vd=jo.platform==="MacIntel"&&jo.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(jo.platform),wy=xr&&/apple/i.test(navigator.vendor),Mi=xr&&/android/i.test(bd)||/android/i.test(xd);xr&&bd.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const ky=xd.includes("jsdom/");function Sy(){if(!xr)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function Ty(){if(!xr)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Cy(){if(!xr)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Di="data-base-ui-focusable",wd="active",kd="selected",Sd="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Qn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function we(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Ng(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function dt(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Ct(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Ey(e){return e.matches("html,body")}function qe(e){return e?.ownerDocument||document}function Td(e){return nt(e)&&e.matches(Sd)}function $l(e){return e?e.getAttribute("role")==="combobox"&&Td(e):!1}function Pi(e){return e?e.hasAttribute(Di)?e:e.querySelector(`[${Di}]`)||e:null}function Fn(e,t,n=!0){return e.filter(s=>s.parentId===t&&(!n||s.context?.open)).flatMap(s=>[s,...Fn(e,s.id,n)])}function Yl(e,t){let n=[],r=e.find(s=>s.id===t)?.parentId;for(;r;){const s=e.find(o=>o.id===r);r=s?.parentId,s&&(n=n.concat(s))}return n}function My(e){e.preventDefault(),e.stopPropagation()}function Dy(e){return"nativeEvent"in e}function Py(e){return e.mozInputSource===0&&e.isTrusted?!0:Mi&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Ry(e){return ky?!1:!Mi&&e.width===0&&e.height===0||Mi&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function dr(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Cd(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Oy=["top","right","bottom","left"],fr=Math.min,ft=Math.max,Gs=Math.round,Ss=Math.floor,Ht=e=>({x:e,y:e}),Ay={left:"right",right:"left",bottom:"top",top:"bottom"};function Ri(e,t,n){return ft(e,fr(t,n))}function nn(e,t){return typeof e=="function"?e(t):e}function it(e){return e.split("-")[0]}function xn(e){return e.split("-")[1]}function fa(e){return e==="x"?"y":"x"}function ha(e){return e==="y"?"height":"width"}function yt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ma(e){return fa(yt(e))}function Ny(e,t,n){n===void 0&&(n=!1);const r=xn(e),s=ma(e),o=ha(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=Ks(i)),[i,Ks(i)]}function Iy(e){const t=Ks(e);return[Oi(e),t,Oi(t)]}function Oi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Hl=["left","right"],Ul=["right","left"],Fy=["top","bottom"],jy=["bottom","top"];function Ly(e,t,n){switch(e){case"top":case"bottom":return n?t?Ul:Hl:t?Hl:Ul;case"left":case"right":return t?Fy:jy;default:return[]}}function Vy(e,t,n,r){const s=xn(e);let o=Ly(it(e),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),t&&(o=o.concat(o.map(Oi)))),o}function Ks(e){const t=it(e);return Ay[t]+e.slice(t.length)}function _y(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ed(e){return typeof e!="number"?_y(e):{top:e,right:e,bottom:e,left:e}}function zs(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}var Wy=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],qs=Wy.join(","),Md=typeof Element>"u",hr=Md?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Xs=!Md&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Zs=function(t,n){var r;n===void 0&&(n=!0);var s=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),o=s===""||s==="true",i=o||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Zs(t.parentNode));return i},By=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Dd=function(t,n,r){if(Zs(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(qs));return n&&hr.call(t,qs)&&s.unshift(t),s=s.filter(r),s},Qs=function(t,n,r){for(var s=[],o=Array.from(t);o.length;){var i=o.shift();if(!Zs(i,!1))if(i.tagName==="SLOT"){var a=i.assignedElements(),l=a.length?a:i.children,c=Qs(l,!0,r);r.flatten?s.push.apply(s,c):s.push({scopeParent:i,candidates:c})}else{var u=hr.call(i,qs);u&&r.filter(i)&&(n||!t.includes(i))&&s.push(i);var d=i.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(i),f=!Zs(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(i));if(d&&f){var h=Qs(d===!0?i.children:d.children,!0,r);r.flatten?s.push.apply(s,h):s.push({scopeParent:i,candidates:h})}else o.unshift.apply(o,i.children)}}return s},Pd=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Rd=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||By(t))&&!Pd(t)?0:t.tabIndex},$y=function(t,n){var r=Rd(t);return r<0&&n&&!Pd(t)?0:r},Yy=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Od=function(t){return t.tagName==="INPUT"},Hy=function(t){return Od(t)&&t.type==="hidden"},Uy=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},Gy=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},Ky=function(t){if(!t.name)return!0;var n=t.form||Xs(t),r=function(a){return n.querySelectorAll('input[type="radio"][name="'+a+'"]')},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(i){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",i.message),!1}var o=Gy(s,t.form);return!o||o===t},zy=function(t){return Od(t)&&t.type==="radio"},qy=function(t){return zy(t)&&!Ky(t)},Xy=function(t){var n,r=t&&Xs(t),s=(n=r)===null||n===void 0?void 0:n.host,o=!1;if(r&&r!==t){var i,a,l;for(o=!!((i=s)!==null&&i!==void 0&&(a=i.ownerDocument)!==null&&a!==void 0&&a.contains(s)||t!=null&&(l=t.ownerDocument)!==null&&l!==void 0&&l.contains(t));!o&&s;){var c,u,d;r=Xs(s),s=(c=r)===null||c===void 0?void 0:c.host,o=!!((u=s)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(s))}}return o},Gl=function(t){var n=t.getBoundingClientRect(),r=n.width,s=n.height;return r===0&&s===0},Zy=function(t,n){var r=n.displayCheck,s=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var o=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(t).visibility==="hidden")return!0;var i=hr.call(t,"details>summary:first-of-type"),a=i?t.parentElement:t;if(hr.call(a,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof s=="function"){for(var l=t;t;){var c=t.parentElement,u=Xs(t);if(c&&!c.shadowRoot&&s(c)===!0)return Gl(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(Xy(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Gl(t);return!1},Qy=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var s=n.children.item(r);if(s.tagName==="LEGEND")return hr.call(n,"fieldset[disabled] *")?!0:!s.contains(t)}return!0}n=n.parentElement}return!1},Ai=function(t,n){return!(n.disabled||Hy(n)||Zy(n,t)||Uy(n)||Qy(n))},Ni=function(t,n){return!(qy(n)||Rd(n)<0||!Ai(t,n))},Jy=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Ad=function(t){var n=[],r=[];return t.forEach(function(s,o){var i=!!s.scopeParent,a=i?s.scopeParent:s,l=$y(a,i),c=i?Ad(s.candidates):a;l===0?i?n.push.apply(n,c):n.push(a):r.push({documentOrder:o,tabIndex:l,item:s,isScope:i,content:c})}),r.sort(Yy).reduce(function(s,o){return o.isScope?s.push.apply(s,o.content):s.push(o.content),s},[]).concat(n)},ss=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Qs([t],n.includeContainer,{filter:Ni.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:Jy}):r=Dd(t,n.includeContainer,Ni.bind(null,n)),Ad(r)},eb=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Qs([t],n.includeContainer,{filter:Ai.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Dd(t,n.includeContainer,Ai.bind(null,n)),r},Nd=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return hr.call(t,qs)===!1?!1:Ni(n,t)};const vr=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Id(e,t){const n=ss(e,vr()),r=n.length;if(r===0)return;const s=Qn(qe(e)),o=n.indexOf(s),i=o===-1?t===1?0:r-1:o+t;return n[i]}function pa(e){return Id(qe(e).body,1)||e}function Fd(e){return Id(qe(e).body,-1)||e}function jd(e,t){if(!e)return null;const n=ss(qe(e).body,vr()),r=n.length;if(r===0)return null;const s=n.indexOf(e);if(s===-1)return null;const o=(s+t+r)%r;return n[o]}function tb(e){return jd(e,1)}function nb(e){return jd(e,-1)}function ir(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!we(n,r)}function rb(e){ss(e,vr()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Kl(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function sb({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:s="sun",cacheKey:o,timeZone:i,tzOffsetMinutes:a,now:l}={}){const c=m.useMemo(()=>Ig({weeks:r,weekStartsOn:s,now:l}),[l,r,s]),[u,d]=m.useState([]),[f,h]=m.useState(null),[p,g]=m.useState("edge"),[y,w]=m.useState(!1),[x,v]=m.useState(null),k=yr(),S=br(t),C=!n,M=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),D=m.useMemo(()=>{if(!o)return null;const j=fo({timeZone:i,offsetMinutes:a});return`vibeusage.heatmap.${o}.${r}.${s}.${j}`},[o,i,a,r,s]),F=m.useCallback(()=>{if(!D||typeof window>"u")return null;try{const j=window.localStorage.getItem(D);if(!j)return null;const N=JSON.parse(j);return!N||!N.heatmap?null:N}catch{return null}},[D]),T=m.useCallback(j=>{if(!(!D||typeof window>"u"))try{window.localStorage.setItem(D,JSON.stringify(j))}catch{}},[D]),R=m.useCallback(()=>{if(!(!D||typeof window>"u"))try{window.localStorage.removeItem(D)}catch{}},[D]),A=m.useCallback(async()=>{const j=await Wt(t);if(!(!j&&!k&&!M)){w(!0),v(null);try{try{const P=await Zg({baseUrl:e,accessToken:j,weeks:r,to:c.to,weekStartsOn:s,timeZone:i,tzOffsetMinutes:a}),I=Array.isArray(P?.weeks)?P.weeks:[];if(!I.length&&C){const W=F();if(W?.heatmap){h(W.heatmap),d(W.daily||[]),g("cache");return}}if(!I.some(W=>(Array.isArray(W)?W:[]).some(Q=>Q&&Number.isFinite(Number(Q.level))))&&I.length){const W=[];for(const Y of I)for(const $ of Array.isArray(Y)?Y:[])$?.day&&W.push({day:$.day,total_tokens:$.total_tokens??$.value??0,billable_total_tokens:$.billable_total_tokens??$.value??$.total_tokens??0});const Q=Ei({dailyRows:W,weeks:r,to:P?.to||c.to,weekStartsOn:s});d(W),h({...Q,week_starts_on:s,active_days:W.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:ks({dailyRows:W,to:P?.to||c.to})}),g("client"),C?T({heatmap:{...Q,week_starts_on:s,active_days:W.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:ks({dailyRows:W,to:P?.to||c.to})},daily:W,fetchedAt:new Date().toISOString()}):R();return}h(P||null),d([]),g("edge"),P&&C?T({heatmap:P,daily:[],fetchedAt:new Date().toISOString()}):C||R();return}catch(P){const I=P,B=I?.status??I?.statusCode;if(B===401||B===403)throw P}const N=await ua({baseUrl:e,accessToken:j,from:c.from,to:c.to,timeZone:i,tzOffsetMinutes:a}),V=Array.isArray(N?.data)?N.data:[];d(V);const U=Ei({dailyRows:V,weeks:r,to:c.to,weekStartsOn:s});h({...U,week_starts_on:s,active_days:V.filter(P=>Number(P?.billable_total_tokens??P?.total_tokens)>0).length,streak_days:ks({dailyRows:V,to:c.to})}),g("client"),C?T({heatmap:{...U,week_starts_on:s,active_days:V.filter(P=>Number(P?.billable_total_tokens??P?.total_tokens)>0).length,streak_days:ks({dailyRows:V,to:c.to})},daily:V,fetchedAt:new Date().toISOString()}):R()}catch(N){if(C){const V=F();if(V?.heatmap)h(V.heatmap),d(V.daily||[]),g("cache"),v(null);else{const U=N;v(U?.message||String(U)),d([]),h(null),g("edge")}}else{const V=N;v(V?.message||String(V)),d([]),h(null),g("edge")}}finally{w(!1)}}},[t,e,k,n,C,c.from,c.to,F,S,i,a,s,r,R,T,M]);return m.useEffect(()=>{if(!S&&!n&&!k&&!M){d([]),w(!1),v(null),h(null),g("edge");return}if(!C)R(),d([]),v(null),h(null),g("edge");else{const j=F();j?.heatmap&&(h(j.heatmap),d(j.daily||[]),g("cache"))}A()},[t,k,F,A,S,n,C,R,M]),{range:c,daily:u,heatmap:f,source:k?"mock":p==="client"?"edge":p,loading:y,error:x,refresh:A}}function ob({baseUrl:e,accessToken:t,limit:n=3,from:r,to:s,source:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=m.useState([]),[u,d]=m.useState(!1),[f,h]=m.useState(null),p=yr(),g=br(t),y=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),w=m.useCallback(async()=>{const x=await Wt(t);if(!x&&!p&&!y){c([]),h(null),d(!1);return}d(!0),h(null);try{const v=await Qg({baseUrl:e,accessToken:x,limit:n,from:r,to:s,source:o,timeZone:i,tzOffsetMinutes:a});c(Array.isArray(v?.entries)?v.entries:[])}catch(v){const k=v?.message||String(v);h(k),c([])}finally{d(!1)}},[t,e,r,n,p,o,i,s,a,y]);return m.useEffect(()=>{if(!g&&!p&&!y){c([]),h(null),d(!1);return}w()},[p,w,g,y]),{entries:l,loading:u,error:f,refresh:w}}const ib=24;function ab({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:s,to:o,months:i=ib,cacheKey:a,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:d,sharedRange:f}={}){const[h,p]=m.useState([]),[g,y]=m.useState(()=>({from:s,to:o})),[w,x]=m.useState("edge"),[v,k]=m.useState(null),[S,C]=m.useState(!1),[M,D]=m.useState(null),F=yr(),T=br(t),R=!n,A=Array.isArray(d),E=f?.from||s,j=f?.to||o,N=m.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),V=(()=>{if(!a)return null;const Y=lb(e)||"default",$=fo({timeZone:l,offsetMinutes:c});if(N==="hourly")return`vibeusage.trend.${a}.${Y}.hourly.${o||s||"day"}.${$}`;if(N==="monthly")return`vibeusage.trend.${a}.${Y}.monthly.${i}.${o||"today"}.${$}`;const z=`${s||""}.${o||""}`;return`vibeusage.trend.${a}.${Y}.daily.${z}.${$}`})(),U=m.useCallback(()=>{if(!V||typeof window>"u")return null;try{const Y=window.localStorage.getItem(V);if(!Y)return null;const $=JSON.parse(Y);return!$||!Array.isArray($.rows)?null:$}catch{return null}},[V]),P=m.useCallback(Y=>{if(!(!V||typeof window>"u"))try{window.localStorage.setItem(V,JSON.stringify(Y))}catch{}},[V]),I=m.useCallback(()=>{if(!(!V||typeof window>"u"))try{window.localStorage.removeItem(V)}catch{}},[V]),B=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),W=m.useCallback(async()=>{if(A){p(Array.isArray(d)?d:[]),y({from:E,to:j}),x("shared"),k(null),C(!1),D(null);return}const Y=await Wt(t);if(!(!Y&&!F&&!B)){C(!0),D(null);try{let $;N==="hourly"?$=await Jg({baseUrl:e,accessToken:Y,day:o||s,timeZone:l,tzOffsetMinutes:c}):N==="monthly"?$=await ey({baseUrl:e,accessToken:Y,months:i,to:o,timeZone:l,tzOffsetMinutes:c}):$=await ua({baseUrl:e,accessToken:Y,from:s,to:o,timeZone:l,tzOffsetMinutes:c});const z=$?.from||s||$?.day||null,Z=$?.to||o||$?.day||null;let ce=Array.isArray($?.data)?$.data:[];N==="daily"?ce=Vo(ce,z||s,Z||o,{timeZone:l,offsetMinutes:c,now:u}):N==="hourly"?ce=_o(ce,{timeZone:l,offsetMinutes:c,now:u}):N==="monthly"&&(ce=Wo(ce,{timeZone:l,offsetMinutes:c,now:u}));const Se=new Date().toISOString();p(ce),y({from:z,to:Z}),x("edge"),k(Se),R?P({rows:ce,from:z,to:Z,mode:N,fetchedAt:Se}):I()}catch($){if(R){const z=U();if(z?.rows){let Z=N==="daily"?Vo(z.rows||[],z.from||s,z.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(z.rows)?z.rows:[];N==="hourly"?Z=_o(Z,{timeZone:l,offsetMinutes:c,now:u}):N==="monthly"&&(Z=Wo(Z,{timeZone:l,offsetMinutes:c,now:u})),p(Z),y({from:z.from||s,to:z.to||o}),x("cache"),k(z.fetchedAt||null),D(null)}else{p([]),y({from:s,to:o}),x("edge"),k(null);const Z=$;D(Z?.message||String(Z))}}else{p([]),y({from:s,to:o}),x("edge"),k(null);const z=$;D(z?.message||String(z))}}finally{C(!1)}}},[t,e,s,F,n,R,N,i,U,T,A,E,d,j,l,o,c,u,I,P,B]);m.useEffect(()=>{if(A){p(Array.isArray(d)?d:[]),y({from:E,to:j}),x("shared"),k(null),C(!1),D(null);return}if(!T&&!n&&!F&&!B){p([]),y({from:s,to:o}),D(null),C(!1),x("edge"),k(null);return}if(!R)I(),p([]),y({from:s,to:o}),D(null),x("edge"),k(null);else{const Y=U();if(Y?.rows){let $=N==="daily"?Vo(Y.rows||[],Y.from||s,Y.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(Y.rows)?Y.rows:[];N==="hourly"?$=_o($,{timeZone:l,offsetMinutes:c,now:u}):N==="monthly"&&($=Wo($,{timeZone:l,offsetMinutes:c,now:u})),p($),y({from:Y.from||s,to:Y.to||o}),x("cache"),k(Y.fetchedAt||null)}}W()},[t,F,U,W,A,E,d,j,T,n,R,I,B]);const Q=F?"mock":w;return{rows:h,from:g.from||s,to:g.to||o,source:Q,fetchedAt:v,loading:S,error:M,refresh:W}}function lb(e){try{return new URL(e).host}catch{return null}}function Lo(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),s=Number(n[1])-1,o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(r,s,o));return Number.isFinite(i.getTime())&&cr(i)===t?i:null}function cb(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Vo(e,t,n,{timeZone:r,offsetMinutes:s,now:o}={}){const i=Lo(t),a=Lo(n);if(!i||!a||a<i)return Array.isArray(e)?e:[];const l=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,c=ia({timeZone:r,offsetMinutes:s,date:l}),u=Lo(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const h=[];for(let p=i;p<=a;p=cb(p,1)){const g=cr(p),y=f.get(g),w=p.getTime()>d;if(y){h.push({...y,missing:!1,future:w});continue}h.push({day:g,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return h}function _o(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Ld({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.hour||o?.label||"",a=ub(i);if(!a)return{...o,future:!1};const l=a.dayNum>s.dayNum||a.dayNum===s.dayNum&&a.slot>s.slot;return{...o,future:l}}):e}function Wo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Ld({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.month||o?.label||"",a=db(i);if(!a)return{...o,future:!1};const l=a.year>s.year||a.year===s.year&&a.month>s.month;return{...o,future:l}}):e}function Ld({timeZone:e,offsetMinutes:t,now:n}={}){const r=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const f=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(r).reduce((x,v)=>(v.type&&v.value&&(x[v.type]=v.value),x),{}),h=Number(f.year),p=Number(f.month),g=Number(f.day),y=Number(f.hour),w=Number(f.minute);if(Number.isFinite(h)&&Number.isFinite(p)&&Number.isFinite(g)&&Number.isFinite(y)&&Number.isFinite(w)){const x=y*2+(w>=30?1:0);return{year:h,month:p,day:g,hour:y,minute:w,dayNum:h*1e4+p*100+g,slot:x}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),d=u.getUTCFullYear(),f=u.getUTCMonth()+1,h=u.getUTCDate(),p=u.getUTCHours(),g=u.getUTCMinutes(),y=p*2+(g>=30?1:0);return{year:d,month:f,day:h,hour:p,minute:g,dayNum:d*1e4+f*100+h,slot:y}}const s=r.getFullYear(),o=r.getMonth()+1,i=r.getDate(),a=r.getHours(),l=r.getMinutes(),c=a*2+(l>=30?1:0);return{year:s,month:o,day:i,hour:a,minute:l,dayNum:s*1e4+o*100+i,slot:c}}function ub(e){if(!e)return null;const t=String(e).trim(),[n,r]=t.split("T");if(!n||!r)return null;const s=n.split("-");if(s.length!==3)return null;const o=Number(s[0]),i=Number(s[1]),a=Number(s[2]);if(!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(a))return null;const l=r.split(":"),c=Number(l[0]),u=Number(l[1]);if(!Number.isFinite(c)||c<0||c>23||!Number.isFinite(u)||u<0||u>59)return null;const d=c*2+(u>=30?1:0);return{dayNum:o*1e4+i*100+a,slot:d}}function db(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const r=Number(n[0]),s=Number(n[1]);return!Number.isFinite(r)||!Number.isFinite(s)||s<1||s>12?null:{year:r,month:s}}function zl({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:s,includeDaily:o=!0,cacheKey:i,timeZone:a,tzOffsetMinutes:l,now:c}={}){const[u,d]=m.useState([]),[f,h]=m.useState(null),[p,g]=m.useState(null),[y,w]=m.useState("edge"),[x,v]=m.useState(null),[k,S]=m.useState(!1),[C,M]=m.useState(null),D=yr(),F=br(t),T=!n,R=(()=>{if(!i)return null;const P=fb(e)||"default",I=o?"daily":"summary",B=fo({timeZone:a,offsetMinutes:l});return`vibeusage.usage.${i}.${P}.${r}.${s}.${I}.${B}`})(),A=m.useCallback(()=>{if(!R||typeof window>"u")return null;try{const P=window.localStorage.getItem(R);if(!P)return null;const I=JSON.parse(P);return!I||!I.summary?null:I}catch{return null}},[R]),E=m.useCallback(P=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(P))}catch{}},[R]),j=m.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),N=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),V=m.useCallback(async()=>{const P=await Wt(t);if(!(!P&&!D&&!N)){S(!0),M(null);try{let I=null,B=null;if(o){const[z,Z]=await Promise.allSettled([ua({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l}),Fo({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0})]);if(z.status==="rejected")throw z.reason;I=z.value,B=Z.status==="fulfilled"?Z.value:null}else B=await Fo({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0});let W=o&&Array.isArray(I?.data)?I.data:[];o&&(W=$o(W,r,s,{timeZone:a,offsetMinutes:l,now:c}));let Q=B?.totals||I?.summary?.totals||null,Y=B?.rolling||I?.summary?.rolling||null;if(o&&!Q&&!B)try{const z=await Fo({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0});Q=z?.totals||null,Y=z?.rolling||Y}catch{}const $=new Date().toISOString();d(W),h(Q),g(Y),w("edge"),v($),Q&&T?E({summary:Q,rolling:Y,daily:W,from:r,to:s,includeDaily:o,fetchedAt:$}):T||j()}catch(I){if(T){const B=A();if(B?.summary){h(B.summary),g(B.rolling||null);const W=Array.isArray(B.daily)?B.daily:[],Q=o?$o(W,B.from||r,B.to||s,{timeZone:a,offsetMinutes:l,now:c}):W;d(Q),w("cache"),v(B.fetchedAt||null),M(null)}else{const W=I;M(W?.message||String(W)),d([]),h(null),g(null),w("edge"),v(null)}}else{const B=I;M(B?.message||String(B)),d([]),h(null),g(null),w("edge"),v(null)}}finally{S(!1)}}},[t,e,r,o,D,n,T,c,A,F,a,s,l,j,E,N]);return m.useEffect(()=>{const P=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!F&&!n&&!D&&!P){d([]),h(null),g(null),M(null),S(!1),w("edge"),v(null);return}if(!T)j(),d([]),h(null),g(null),M(null),w("edge"),v(null);else{const I=A();if(I?.summary){h(I.summary),g(I.rolling||null);const B=Array.isArray(I.daily)?I.daily:[],W=o?$o(B,I.from||r,I.to||s,{timeZone:a,offsetMinutes:l,now:c}):B;d(W),w("cache"),v(I.fetchedAt||null)}}V()},[t,D,A,V,F,n,T,j,N]),{daily:u,summary:f,rolling:p,source:D?"mock":y,fetchedAt:x,loading:k,error:C,refresh:V}}function fb(e){try{return new URL(e).host}catch{return null}}function Bo(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),s=Number(n[1])-1,o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(r,s,o));return Number.isFinite(i.getTime())&&cr(i)===t?i:null}function hb(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function $o(e,t,n,{timeZone:r,offsetMinutes:s,now:o}={}){const i=Bo(t),a=Bo(n);if(!i||!a||a<i)return Array.isArray(e)?e:[];const l=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,c=ia({timeZone:r,offsetMinutes:s,date:l}),u=Bo(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const h=[];for(let p=i;p<=a;p=hb(p,1)){const g=cr(p),y=f.get(g),w=p.getTime()>d;if(y){h.push({...y,missing:!1,future:w});continue}h.push({day:g,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return h}function mb({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:s,cacheKey:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=m.useState(null),[u,d]=m.useState("edge"),[f,h]=m.useState(!1),[p,g]=m.useState(null),y=yr(),w=br(t),x=!n,v=m.useMemo(()=>{if(!o)return null;const T=pb(e)||"default",R=fo({timeZone:i,offsetMinutes:a});return`vibeusage.modelBreakdown.${o}.${T}.${r}.${s}.${R}`},[e,o,r,i,s,a]),k=m.useCallback(()=>{if(!v||typeof window>"u")return null;try{const T=window.localStorage.getItem(v);if(!T)return null;const R=JSON.parse(T);return!R||!R.breakdown?null:R}catch{return null}},[v]),S=m.useCallback(T=>{if(!(!v||typeof window>"u"))try{window.localStorage.setItem(v,JSON.stringify(T))}catch{}},[v]),C=m.useCallback(()=>{if(!(!v||typeof window>"u"))try{window.localStorage.removeItem(v)}catch{}},[v]),M=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),D=m.useCallback(async()=>{const T=await Wt(t);if(!(!T&&!y&&!M)){h(!0),g(null);try{const R=await ty({baseUrl:e,accessToken:T,from:r,to:s,timeZone:i,tzOffsetMinutes:a});c(R||null),d("edge"),R&&x?S({breakdown:R,fetchedAt:new Date().toISOString()}):x||C()}catch(R){if(x){const A=k();if(A?.breakdown)c(A.breakdown),d("cache"),g(null);else{c(null),d("edge");const E=R;g(E?.message||String(E))}}else{c(null),d("edge");const A=R;g(A?.message||String(A))}}finally{h(!1)}}},[t,e,r,y,n,x,k,i,s,w,a,C,S,M]);return m.useEffect(()=>{if(!w&&!n&&!y&&!M){c(null),d("edge"),g(null),h(!1);return}if(!x)C(),c(null),d("edge"),g(null);else{const T=k();T?.breakdown&&(c(T.breakdown),d("cache"))}D()},[t,y,k,D,w,n,x,C,M]),{breakdown:l,source:y?"mock":u,loading:f,error:p,refresh:D}}function pb(e){try{return new URL(e).host}catch{return null}}const Vd=new Set(["day","hour","month"]);function gb(e){return Vd.has(e)}function ql(e){if(e==null)return null;const t=String(e).trim();if(!/^[0-9]+$/.test(t))return null;const n=t.replace(/^0+/,"");return n.length===0?"0":n}function yb(e,t){const n=ql(e),r=ql(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const s=xt(e),o=xt(t);return s==null&&o==null?0:s==null?1:o==null?-1:s===o?0:s<o?-1:1}function bb(e,t){const n=typeof e=="string"?e:String(e||""),r=typeof t=="string"?t:String(t||"");return n===r?0:n<r?-1:1}function xb(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),s=Number(n[2]),o=Number(n[3]);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(r,s-1,o));return!Number.isFinite(i.getTime())||i.getUTCFullYear()!==r||i.getUTCMonth()+1!==s||i.getUTCDate()!==o?null:i.getTime()}function vb(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(s)||s<1||s>12)return null;const o=new Date(Date.UTC(r,s-1,1));return Number.isFinite(o.getTime())?o.getTime():null}function wb(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!n)return null;const r=Number(n[1]),s=Number(n[2]),o=Number(n[3]),i=Number(n[4]),a=Number(n[5]),l=Number(n[6]||0);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(a)||!Number.isFinite(l)||s<1||s>12||o<1||o>31||i<0||i>23||a<0||a>59||l<0||l>59)return null;const c=new Date(Date.UTC(r,s-1,o,i,a,l));return Number.isFinite(c.getTime())?c.getTime():null}function kb(e,t,n){const r=n==="hour"?wb:n==="month"?vb:xb,s=r(e),o=r(t);return s!=null&&o!=null?s===o?0:s<o?-1:1:bb(e,t)}function _d(e,{key:t,dir:n}){const r=n==="asc"?1:-1,s=Array.isArray(e)?e:[],o=Vd.has(t)?(a,l)=>kb(a,l,t):yb,i=a=>t==="total_tokens"&&a?.billable_total_tokens!=null?a.billable_total_tokens:a?.[t];return s.map((a,l)=>({row:a,index:l})).sort((a,l)=>{const c=i(a.row),u=i(l.row),d=c==null,f=u==null;if(d&&f)return a.index-l.index;if(d)return 1;if(f)return-1;const h=o(c,u);return h!==0?h*r:a.index-l.index}).map(a=>a.row)}const Sb=[{key:"day",label:_("daily.sort.date.label"),title:_("daily.sort.date.title")},{key:"total_tokens",label:_("daily.sort.total.label"),title:_("daily.sort.total.title")},{key:"input_tokens",label:_("daily.sort.input.label"),title:_("daily.sort.input.title")},{key:"output_tokens",label:_("daily.sort.output.label"),title:_("daily.sort.output.title")},{key:"cached_input_tokens",label:_("daily.sort.cached.label"),title:_("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:_("daily.sort.reasoning.label"),title:_("daily.sort.reasoning.title")},{key:"conversation_count",label:_("daily.sort.conversations.label"),title:_("daily.sort.conversations.title")}];function Xl(e){const t=gb(e)?e:"day";return Sb.map((n,r)=>r===0?{...n,key:t}:n)}function Zl(e,{key:t,dir:n}){return _d(e,{key:t,dir:n})}const Js=12,Tb=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Cb(e){if(typeof e=="bigint")return e!==0n;if(typeof e=="number")return Number.isFinite(e)&&e!==0;if(e==null)return!1;const t=String(e).trim();if(!t||!/^-?\d+$/.test(t))return!1;const n=t.startsWith("-")?t.slice(1):t;return/[1-9]/.test(n)}function Eb(e){return Tb.some(t=>Cb(e?.[t]))}function Mb(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=_d(t,{key:"month",dir:"asc"}),r=n.findIndex(s=>s?.month&&Eb(s));return r===-1?t:n.slice(r)}function Db(e,t,n=Js){const r=Array.isArray(e)?e:[],s=Number.isFinite(n)&&n>0?n:Js,i=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*s;return r.slice(i,i+s)}function Pb({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:r,heatmapLoading:s,activeDays:o,hasActiveDeviceToken:i}={}){return e||t?!1:n?!0:r&&!s&&o===0&&!i}function Wd(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Rb(e){const t=Wd(e?.model_id);return t||null}function Bd(e,t){return e?.model?String(e.model):t}function Ob(e,{copyFn:t}={}){const n=typeof t=="function"?t:i=>i,s=(Array.isArray(e?.sources)?e.sources:[]).map(i=>{const a=xt(i?.totals?.billable_total_tokens??i?.totals?.total_tokens)??0,l=xt(i?.totals?.total_cost_usd)??0;return{source:i?.source,totalTokens:Number.isFinite(a)?a:0,totalCost:Number.isFinite(l)?l:0,models:Array.isArray(i?.models)?i.models:[]}}).filter(i=>i.totalTokens>0);if(!s.length)return[];const o=s.reduce((i,a)=>i+a.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),s.slice().sort((i,a)=>a.totalTokens-i.totalTokens).map(i=>{const a=i.source?String(i.source).toUpperCase():n("shared.placeholder.short"),l=o>0?i.totalTokens/o*100:0,c=Number.isFinite(l)?l.toFixed(1):"0.0",u=i.models.map(d=>{const f=xt(d?.totals?.billable_total_tokens??d?.totals?.total_tokens)??0;if(!Number.isFinite(f)||f<=0)return null;const h=i.totalTokens>0?Math.round(f/i.totalTokens*1e3)/10:0,p=Bd(d,n("shared.placeholder.short")),g=Rb(d),y=i.totalCost>0&&i.totalTokens>0?f/i.totalTokens*i.totalCost:null;return{id:g,name:p,share:h,usage:f,cost:y}}).filter(Boolean);return{label:a,totalPercent:String(c),usd:i.totalCost,usage:i.totalTokens,models:u}})}function Ab(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:f=>f,s=Array.isArray(e?.sources)?e.sources:[];if(!s.length)return[];const o=new Map,i=new Map,a=new Map;let l=0;for(const f of s){const h=Array.isArray(f?.models)?f.models:[];for(const p of h){const g=xt(p?.totals?.billable_total_tokens)??0;if(!Number.isFinite(g)||g<=0)continue;l+=g;const y=Bd(p,r("shared.placeholder.short")),w=Wd(y);if(!w)continue;o.set(w,(o.get(w)||0)+g);const x=a.get(w)||0;g>=x&&(a.set(w,g),i.set(w,y))}}if(!o.size)return[];const c=Array.from(o.values()).reduce((f,h)=>f+h,0),u=l>0?l:c,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(o.entries()).map(([f,h])=>{const p=u>0?(h/u*100).toFixed(1):"0.0";return{id:f,name:i.get(f)||r("shared.placeholder.short"),tokens:h,percent:String(p)}}).sort((f,h)=>h.tokens!==f.tokens?h.tokens-f.tokens:String(f.name).localeCompare(String(h.name))).slice(0,d)}function ga(){const e=m.useContext(Fg);if(e===null)throw new Error("useTheme must be used within a ThemeProvider");return e}const En=12,Or=3,Yo=26,Nb=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],Ib=["#064e3b","#065f46","#059669","#10b981","#34d399"],Fb=[_("heatmap.month.jan"),_("heatmap.month.feb"),_("heatmap.month.mar"),_("heatmap.month.apr"),_("heatmap.month.may"),_("heatmap.month.jun"),_("heatmap.month.jul"),_("heatmap.month.aug"),_("heatmap.month.sep"),_("heatmap.month.oct"),_("heatmap.month.nov"),_("heatmap.month.dec")];function jb(e){if(typeof e=="bigint")return e.toLocaleString();if(typeof e=="number")return Number.isFinite(e)?Math.round(e).toLocaleString():"0";if(typeof e=="string"){const t=Number(e);return Number.isFinite(t)?Math.round(t).toLocaleString():e}return"0"}function Lb(e){if(typeof e!="string")return null;const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;const n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return Number.isFinite(n.getTime())?n:null}function $d(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Vb(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function _b(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return $d(e,-((r-n+7)%7))}function Wb(e,t,n){if(!e)return[];const r=Lb(t)||new Date,s=[];for(let c=11;c>=0;c-=1)s.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-c,1)));const o=_b(r,n),i=$d(o,-(e-1)*7),a=[],l=new Set;for(const c of s){const u=Math.floor(Vb(i,c)/7);u<0||u>=e||l.has(u)||(l.add(u),a.push({label:Fb[c.getUTCMonth()],index:u}))}return a}function Bb({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:s}=ga(),i=s==="dark"?Ib:Nb,a=m.useRef(null);m.useEffect(()=>{const p=a.current;p&&(p.scrollLeft=p.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=m.useMemo(()=>{const p=Array.isArray(e?.weeks)?e.weeks:[];if(!p.length)return{weeks:[]};const g=[];for(const y of p)for(const w of Array.isArray(y)?y:[])w?.day&&g.push({day:w.day,total_tokens:w.total_tokens??w.value??0,billable_total_tokens:w.billable_total_tokens??w.value??w.total_tokens??0});return Ei({dailyRows:g,weeks:Math.max(52,p.length),to:e?.to,weekStartsOn:l})},[e?.to,e?.weeks,l]),u=c?.weeks||[],d=l==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(p=>_(`heatmap.day.${p.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(p=>_(`heatmap.day.${p.toLowerCase()}`)),f=m.useMemo(()=>Wb(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return b.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:_("heatmap.empty")});const h=Yo+u.length*En+Math.max(0,u.length-1)*Or;return b.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[b.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[b.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:_("heatmap.title")}),b.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||_("heatmap.legend.utc")})]}),b.jsx("div",{ref:a,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:b.jsxs("div",{style:{minWidth:h},children:[b.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${Yo}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[b.jsx("span",{}),f.map(p=>b.jsx("span",{style:{gridColumnStart:p.index+2},className:"whitespace-nowrap",children:p.label},`${p.label}-${p.index}`))]}),b.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${Yo}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[b.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${En}px)`,rowGap:Or},children:d.map(p=>b.jsx("span",{className:"leading-none",children:p},p))}),b.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${En}px)`,gap:Or},children:u.map((p,g)=>(Array.isArray(p)?p:[]).map((y,w)=>{if(!y)return null;const x=y.day||`e-${g}-${w}`,v=Number(y.level)||0,k=i[v]||i[0],S=t||n||_("heatmap.legend.utc");return b.jsx("span",{title:_("heatmap.tooltip",{day:y.day,value:jb(y.value),unit:_("heatmap.unit.tokens"),tz:S}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:En,height:En,background:k}},x)}))})]})]})}),!r&&b.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[b.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.less")}),b.jsx("div",{className:"flex gap-0.5",children:i.map((p,g)=>b.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:p}},g))}),b.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.more")})]})]})}const $b={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Yd={...$b,position:"fixed",top:0,left:0};function Bt(e){const t=bn(Yb,e).current;return t.next=e,Te(t.effect),t}function Yb(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var eo=Symbol("NOT_FOUND");function Hb(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Ub(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function Gb(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var Ql=e=>Array.isArray(e)?e:[e];function Kb(e){const t=Array.isArray(e[0])?e[0]:e;return Gb(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function zb(e,t){const n=[],{length:r}=e;for(let s=0;s<r;s++)n.push(e[s].apply(null,t));return n}function qb(e){let t;return{get(n){return t&&e(t.key,n)?t.value:eo},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function Xb(e,t){let n=[];function r(a){const l=n.findIndex(c=>t(a,c.key));if(l>-1){const c=n[l];return l>0&&(n.splice(l,1),n.unshift(c)),c.value}return eo}function s(a,l){r(a)===eo&&(n.unshift({key:a,value:l}),n.length>e&&n.pop())}function o(){return n}function i(){n=[]}return{get:r,put:s,getEntries:o,clear:i}}var Zb=(e,t)=>e===t;function Qb(e){return function(n,r){if(n===null||r===null||n.length!==r.length)return!1;const{length:s}=n;for(let o=0;o<s;o++)if(!e(n[o],r[o]))return!1;return!0}}function Jb(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=Zb,maxSize:s=1,resultEqualityCheck:o}=n,i=Qb(r);let a=0;const l=s<=1?qb(i):Xb(s,i);function c(){let u=l.get(arguments);if(u===eo){if(u=e.apply(null,arguments),a++,o){const f=l.getEntries().find(h=>o(h.value,u));f&&(u=f.value,a!==0&&a--)}l.put(arguments,u)}return u}return c.clearCache=()=>{l.clear(),c.resetResultsCount()},c.resultsCount=()=>a,c.resetResultsCount=()=>{a=0},c}var e0=class{constructor(e){this.value=e}deref(){return this.value}},t0=typeof WeakRef<"u"?WeakRef:e0,n0=0,Jl=1;function Ts(){return{s:n0,v:void 0,o:null,p:null}}function Hd(e,t={}){let n=Ts();const{resultEqualityCheck:r}=t;let s,o=0;function i(){let a=n;const{length:l}=arguments;for(let d=0,f=l;d<f;d++){const h=arguments[d];if(typeof h=="function"||typeof h=="object"&&h!==null){let p=a.o;p===null&&(a.o=p=new WeakMap);const g=p.get(h);g===void 0?(a=Ts(),p.set(h,a)):a=g}else{let p=a.p;p===null&&(a.p=p=new Map);const g=p.get(h);g===void 0?(a=Ts(),p.set(h,a)):a=g}}const c=a;let u;if(a.s===Jl)u=a.v;else if(u=e.apply(null,arguments),o++,r){const d=s?.deref?.()??s;d!=null&&r(d,u)&&(u=d,o!==0&&o--),s=typeof u=="object"&&u!==null||typeof u=="function"?new t0(u):u}return c.s=Jl,c.v=u,u}return i.clearCache=()=>{n=Ts(),i.resetResultsCount()},i.resultsCount=()=>o,i.resetResultsCount=()=>{o=0},i}function Ud(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...s)=>{let o=0,i=0,a,l={},c=s.pop();typeof c=="object"&&(l=c,c=s.pop()),Hb(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:d,memoizeOptions:f=[],argsMemoize:h=Hd,argsMemoizeOptions:p=[]}=u,g=Ql(f),y=Ql(p),w=Kb(s),x=d(function(){return o++,c.apply(null,arguments)},...g),v=h(function(){i++;const S=zb(w,arguments);return a=x.apply(null,S),a},...y);return Object.assign(v,{resultFunc:c,memoizedResultFunc:x,dependencies:w,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>a,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:d,argsMemoize:h})};return Object.assign(r,{withTypes:()=>r}),r}var r0=Ud(Hd),s0=Object.assign((e,t=r0)=>{Ub(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(o=>e[o]);return t(r,(...o)=>o.reduce((i,a,l)=>(i[n[l]]=a,i),{}))},{withTypes:()=>s0});Ud({memoize:Jb,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const pe=(e,t,n,r,s,o,...i)=>{if(i.length>0)throw new Error(Bn(1));let a;if(e)a=e;else throw new Error("Missing arguments");return a};var Ho={exports:{}},Uo={};var ec;function o0(){if(ec)return Uo;ec=1;var e=id();function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function a(d,f){var h=f(),p=r({inst:{value:h,getSnapshot:f}}),g=p[0].inst,y=p[1];return o(function(){g.value=h,g.getSnapshot=f,l(g)&&y({inst:g})},[d,h,f]),s(function(){return l(g)&&y({inst:g}),d(function(){l(g)&&y({inst:g})})},[d]),i(h),h}function l(d){var f=d.getSnapshot;d=d.value;try{var h=f();return!n(d,h)}catch{return!0}}function c(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Uo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Uo}var tc;function Gd(){return tc||(tc=1,Ho.exports=o0()),Ho.exports}var i0=Gd(),Go={exports:{}},Ko={};var nc;function a0(){if(nc)return Ko;nc=1;var e=id(),t=Gd();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;return Ko.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var p=o(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=a(function(){function w(C){if(!x){if(x=!0,v=C,C=f(C),h!==void 0&&g.hasValue){var M=g.value;if(h(M,C))return k=M}return k=C}if(M=k,r(v,C))return M;var D=f(C);return h!==void 0&&h(M,D)?(v=C,M):(v=C,k=D)}var x=!1,v,k,S=d===void 0?null:d;return[function(){return w(u())},S===null?void 0:function(){return w(S())}]},[u,d,f,h]);var y=s(c,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=y},[y]),l(y),y},Ko}var rc;function l0(){return rc||(rc=1,Go.exports=a0()),Go.exports}var c0=l0();const u0=ad(19),d0=u0?h0:m0;function f0(e,t,n,r,s){return d0(e,t,n,r,s)}function h0(e,t,n,r,s){const o=m.useCallback(()=>t(e.getSnapshot(),n,r,s),[e,t,n,r,s]);return i0.useSyncExternalStore(e.subscribe,o,o)}function m0(e,t,n,r,s){return c0.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,r,s))}class Vr{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){Vr.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Vr.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Vr.prototype.setState.call(this,t)}}class ya extends Vr{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){m.useDebugValue(t),Te(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Te(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this,r=Object.values(t);Te(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){m.useDebugValue(t);const s=this,o=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,o),!o&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})),Te(()=>{o&&!Object.is(s.state[t],n)&&super.setState({...s.state,[t]:n})},[s,t,n,r,o])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.update(n)}setState(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.setState({...this.state,...n})}select=(t,n,r,s)=>{const o=this.selectors[t];return o(this.state,n,r,s)};useState=(t,n,r,s)=>{m.useDebugValue(t);const o=this.selectors[t];return f0(this,o,n,r,s)};useContextCallback(t,n){m.useDebugValue(t);const r=he(n??ld);this.context[t]=r}useStateSetter(t){const n=m.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let s=r(this.state);return n(s,s,this),this.subscribe(o=>{const i=r(o);if(!Object.is(s,i)){const a=s;s=i,n(i,a,this)}})}}const Cs=null;class p0{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s<n.length;s+=1)n[s]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Es=new p0;class Vt{static create(){return new Vt}static request(t){return Es.request(t)}static cancel(t){return Es.cancel(t)}currentId=Cs;request(t){this.cancel(),this.currentId=Es.request(()=>{this.currentId=Cs,t()})}cancel=()=>{this.currentId!==Cs&&(Es.cancel(this.currentId),this.currentId=Cs)};disposeEffect=()=>this.cancel}function ba(){const e=bn(Vt.create).current;return da(e.disposeEffect),e}function Kd(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class g0{nodesRef={current:[]};events=Kd();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const zd=m.createContext(null),qd=m.createContext(null),Yn=()=>m.useContext(zd)?.id||null,wr=e=>{const t=m.useContext(qd);return e??t};function y0(e){const t=ts(),n=wr(e),r=Yn();return Te(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function b0(e){const{children:t,id:n}=e,r=Yn();return b.jsx(zd.Provider,{value:m.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function x0(e){const{children:t,externalTree:n}=e,r=bn(()=>n??new g0).current;return b.jsx(qd.Provider,{value:r,children:t})}function Ur(e){return`data-base-ui-${e}`}function zo(e,t,n){if(n&&!dr(n))return 0;if(typeof e=="number")return e;if(typeof e=="function"){const r=e();return typeof r=="number"?r:r?.[t]}return e?.[t]}const mr=m.forwardRef(function(t,n){const[r,s]=m.useState();Te(()=>{wy&&s("button")},[]);const o={tabIndex:0,role:r};return b.jsx("span",{...t,ref:n,style:Yd,"aria-hidden":r?void 0:!0,...o,"data-base-ui-focus-guard":""})});let sc=0;function qo(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:s=!1}=t;r&&cancelAnimationFrame(sc);const o=()=>e?.focus({preventScroll:n});s?o():sc=requestAnimationFrame(o)}const ar={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function oc(e){return e==="inert"?ar.inert:e==="aria-hidden"?ar["aria-hidden"]:ar.none}let Ms=new WeakSet,Ds={},Xo=0;const Xd=e=>e&&(e.host||Xd(e.parentNode)),v0=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=Xd(n);return e.contains(r)?r:null}).filter(n=>n!=null);function w0(e,t,n,r){const s="data-base-ui-inert",o=r?"inert":n?"aria-hidden":null,i=v0(t,e),a=new Set,l=new Set(i),c=[];Ds[s]||(Ds[s]=new WeakMap);const u=Ds[s];i.forEach(d),f(t),a.clear();function d(h){!h||a.has(h)||(a.add(h),h.parentNode&&d(h.parentNode))}function f(h){!h||l.has(h)||[].forEach.call(h.children,p=>{if(ns(p)!=="script")if(a.has(p))f(p);else{const g=o?p.getAttribute(o):null,y=g!==null&&g!=="false",w=oc(o),x=(w.get(p)||0)+1,v=(u.get(p)||0)+1;w.set(p,x),u.set(p,v),c.push(p),x===1&&y&&Ms.add(p),v===1&&p.setAttribute(s,""),!y&&o&&p.setAttribute(o,o==="inert"?"":"true")}})}return Xo+=1,()=>{c.forEach(h=>{const p=oc(o),y=(p.get(h)||0)-1,w=(u.get(h)||0)-1;p.set(h,y),u.set(h,w),y||(!Ms.has(h)&&o&&h.removeAttribute(o),Ms.delete(h)),w||h.removeAttribute(s)}),Xo-=1,Xo||(ar.inert=new WeakMap,ar["aria-hidden"]=new WeakMap,ar.none=new WeakMap,Ms=new WeakSet,Ds={})}}function k0(e,t=!1,n=!1){const r=qe(e[0]).body;return w0(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const Zd=m.createContext(null),Qd=()=>m.useContext(Zd),S0=Ur("portal");function T0(e={}){const{ref:t,container:n,componentProps:r=Nn,elementProps:s,elementState:o}=e,i=ts(),l=Qd()?.portalNode,[c,u]=m.useState(null),[d,f]=m.useState(null),h=he(w=>{w!==null&&f(w)}),p=m.useRef(null);Te(()=>{if(n===null){p.current&&(p.current=null,f(null),u(null));return}if(i==null)return;const w=(n&&(jg(n)?n:n.current))??l??document.body;if(w==null){p.current&&(p.current=null,f(null),u(null));return}p.current!==w&&(p.current=w,f(null),u(w))},[n,l,i]);const g=sn("div",r,{ref:[t,h],state:o,props:[{id:i,[S0]:""},s]});return{portalNode:d,portalSubtree:c&&g?pn.createPortal(g,c):null}}const Jd=m.forwardRef(function(t,n){const{children:r,container:s,className:o,render:i,renderGuards:a,...l}=t,{portalNode:c,portalSubtree:u}=T0({container:s,ref:n,componentProps:t,elementProps:l}),d=m.useRef(null),f=m.useRef(null),h=m.useRef(null),p=m.useRef(null),[g,y]=m.useState(null),w=g?.modal,x=g?.open,v=typeof a=="boolean"?a:!!g&&!g.modal&&g.open&&!!c;m.useEffect(()=>{if(!c||w)return;function S(C){c&&C.relatedTarget&&ir(C)&&(C.type==="focusin"?Kl:rb)(c)}return c.addEventListener("focusin",S,!0),c.addEventListener("focusout",S,!0),()=>{c.removeEventListener("focusin",S,!0),c.removeEventListener("focusout",S,!0)}},[c,w]),m.useEffect(()=>{!c||x||Kl(c)},[x,c]);const k=m.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:h,afterInsideRef:p,portalNode:c,setFocusManagerState:y}),[c]);return b.jsxs(m.Fragment,{children:[u,b.jsxs(Zd.Provider,{value:k,children:[v&&c&&b.jsx(mr,{"data-type":"outside",ref:d,onFocus:S=>{if(ir(S,c))h.current?.focus();else{const C=g?g.domReference:null;Fd(C)?.focus()}}}),v&&c&&b.jsx("span",{"aria-owns":c.id,style:by}),c&&pn.createPortal(r,c),v&&c&&b.jsx(mr,{"data-type":"outside",ref:f,onFocus:S=>{if(ir(S,c))p.current?.focus();else{const C=g?g.domReference:null;pa(C)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Ve(Hr,S.nativeEvent))}}})]})]})});function Jt(e){return e==null?e:"current"in e?e.current:e}function C0(e,t){const n=vt(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const ic=20;let fn=[];function xa(){fn=fn.filter(e=>e.isConnected)}function E0(e){xa(),e&&ns(e)!=="body"&&(fn.push(e),fn.length>ic&&(fn=fn.slice(-ic)))}function Zo(){return xa(),fn[fn.length-1]}function M0(e){if(!e)return null;const t=vr();return Nd(e,t)?e:ss(e,t)[0]||e}function D0(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():At(e).display!=="none"}function ac(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=vr(),s=eb(e,n).filter(i=>{const a=i.getAttribute("data-tabindex")||"";return Nd(i,n)||i.hasAttribute("data-tabindex")&&!a.startsWith("-")}),o=e.getAttribute("tabindex");t.current.includes("floating")||s.length===0?o!=="0"&&e.setAttribute("tabindex","0"):(o!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function ef(e){const{context:t,children:n,disabled:r=!1,order:s=["content"],initialFocus:o=!0,returnFocus:i=!0,restoreFocus:a=!1,modal:l=!0,closeOnFocusOut:c=!0,openInteractionType:u="",getInsideElements:d=()=>[],nextFocusableElement:f,previousFocusableElement:h,beforeContentFocusGuardRef:p,externalTree:g}=e,y="rootStore"in t?t.rootStore:t,w=y.useState("open"),x=y.useState("domReferenceElement"),v=y.useState("floatingElement"),{events:k,dataRef:S}=y.context,C=he(()=>S.current.floatingContext?.nodeId),M=he(d),D=o===!1,F=$l(x)&&D,T=Bt(s),R=Bt(o),A=Bt(i),E=Bt(u),j=wr(g),N=Qd(),V=m.useRef(null),U=m.useRef(null),P=m.useRef(!1),I=m.useRef(!1),B=m.useRef(!1),W=m.useRef(-1),Q=m.useRef(""),Y=m.useRef(""),$=m.useRef(null),z=m.useRef(null),Z=Vl($,p,N?.beforeInsideRef),ce=Vl(z,N?.afterInsideRef),Se=Vn(),Re=Vn(),Ee=ba(),Je=N!=null,L=Pi(v),ue=he((H=L)=>H?ss(H,vr()):[]),te=he(H=>{const se=ue(H);return T.current.map(()=>se).filter(Boolean).flat()});m.useEffect(()=>{if(r||!l)return;function H(ie){ie.key==="Tab"&&we(L,Qn(qe(L)))&&ue().length===0&&!F&&My(ie)}const se=qe(L);return se.addEventListener("keydown",H),()=>{se.removeEventListener("keydown",H)}},[r,x,L,l,T,F,ue,te]),m.useEffect(()=>{if(r||!v)return;function H(se){const ie=dt(se),ge=ue().indexOf(ie);ge!==-1&&(W.current=ge)}return v.addEventListener("focusin",H),()=>{v.removeEventListener("focusin",H)}},[r,v,ue]),m.useEffect(()=>{if(r||!w)return;const H=qe(L);function se(){B.current=!1}function ie(ge){const J=dt(ge),ne=we(v,J)||we(x,J)||we(N?.portalNode,J);B.current=!ne,Y.current=ge.pointerType||"keyboard"}function me(){Y.current="keyboard"}return H.addEventListener("pointerdown",ie,!0),H.addEventListener("pointerup",se,!0),H.addEventListener("pointercancel",se,!0),H.addEventListener("keydown",me,!0),()=>{H.removeEventListener("pointerdown",ie,!0),H.removeEventListener("pointerup",se,!0),H.removeEventListener("pointercancel",se,!0),H.removeEventListener("keydown",me,!0)}},[r,v,x,L,w,N]),m.useEffect(()=>{if(r||!c)return;function H(){I.current=!0,Re.start(0,()=>{I.current=!1})}function se(J){const ne=J.relatedTarget,Ie=J.currentTarget,be=dt(J);queueMicrotask(()=>{const _e=C(),Ge=y.context.triggerElements,ot=ne?.hasAttribute(Ur("focus-guard"))&&[$.current,z.current,N?.beforeInsideRef.current,N?.afterInsideRef.current,N?.beforeOutsideRef.current,N?.afterOutsideRef.current,Jt(h),Jt(f)].includes(ne),Oe=!(we(x,ne)||we(v,ne)||we(ne,v)||we(N?.portalNode,ne)||ne!=null&&Ge.hasElement(ne)||Ge.hasMatchingElement(ye=>we(ye,ne))||ot||j&&(Fn(j.nodesRef.current,_e).find(ye=>we(ye.context?.elements.floating,ne)||we(ye.context?.elements.domReference,ne))||Yl(j.nodesRef.current,_e).find(ye=>[ye.context?.elements.floating,Pi(ye.context?.elements.floating)].includes(ne)||ye.context?.elements.domReference===ne)));if(Ie===x&&L&&ac(L,T),a&&Ie!==x&&!D0(be)&&Qn(qe(L))===qe(L).body){if(nt(L)&&(L.focus(),a==="popup")){Ee.request(()=>{L.focus()});return}const ye=W.current,Fe=ue(),$e=Fe[ye]||Fe[Fe.length-1]||L;nt($e)&&$e.focus()}if(S.current.insideReactTree){S.current.insideReactTree=!1;return}(F||!l)&&ne&&Oe&&!I.current&&(F||ne!==Zo())&&(P.current=!0,y.setOpen(!1,Ve(Hr,J)))})}function ie(){B.current||(S.current.insideReactTree=!0,Se.start(0,()=>{S.current.insideReactTree=!1}))}const me=nt(x)?x:null,ge=[];if(!(!v&&!me))return me&&(me.addEventListener("focusout",se),me.addEventListener("pointerdown",H),ge.push(()=>{me.removeEventListener("focusout",se),me.removeEventListener("pointerdown",H)})),v&&(v.addEventListener("focusout",se),N&&(v.addEventListener("focusout",ie,!0),ge.push(()=>{v.removeEventListener("focusout",ie,!0)})),ge.push(()=>{v.removeEventListener("focusout",se)})),()=>{ge.forEach(J=>{J()})}},[r,x,v,L,l,j,N,y,c,a,ue,F,C,T,S,Se,Re,Ee,f,h]),m.useEffect(()=>{if(r||!v||!w)return;const H=Array.from(N?.portalNode?.querySelectorAll(`[${Ur("portal")}]`)||[]),ie=(j?Yl(j.nodesRef.current,C()):[]).find(J=>$l(J.context?.elements.domReference||null))?.context?.elements.domReference,me=[v,ie,...H,...M(),V.current,U.current,$.current,z.current,N?.beforeOutsideRef.current,N?.afterOutsideRef.current,Jt(h),Jt(f),F?x:null].filter(J=>J!=null),ge=k0(me,l||F);return()=>{ge()}},[w,r,x,v,l,T,N,F,j,C,M,f,h]),Te(()=>{if(!w||r||!nt(L))return;const H=qe(L),se=Qn(H);queueMicrotask(()=>{const ie=te(L),me=R.current,ge=typeof me=="function"?me(E.current||""):me;if(ge===void 0||ge===!1)return;let J;ge===!0||ge===null?J=ie[0]||L:J=Jt(ge),J=J||ie[0]||L,!we(L,se)&&qo(J,{preventScroll:J===L})})},[r,w,L,D,te,R,E]),Te(()=>{if(r||!L)return;const H=qe(L),se=Qn(H);E0(se);function ie(J){if(J.open||(Q.current=C0(J.nativeEvent,Y.current)),J.reason===ut&&J.nativeEvent.type==="mouseleave"&&(P.current=!0),J.reason===cd)if(J.nested)P.current=!1;else if(Py(J.nativeEvent)||Ry(J.nativeEvent))P.current=!1;else{let ne=!1;document.createElement("div").focus({get preventScroll(){return ne=!0,!1}}),ne?P.current=!1:P.current=!0}}k.on("openchange",ie);const me=H.createElement("span");me.setAttribute("tabindex","-1"),me.setAttribute("aria-hidden","true"),Object.assign(me.style,Yd),Je&&x&&x.insertAdjacentElement("afterend",me);function ge(){const J=A.current;let ne=typeof J=="function"?J(Q.current):J;if(ne===void 0||ne===!1)return null;if(ne===null&&(ne=!0),typeof ne=="boolean"){const be=x||Zo();return be&&be.isConnected?be:me}const Ie=x||Zo()||me;return Jt(ne)||Ie}return()=>{k.off("openchange",ie);const J=Qn(H),ne=we(v,J)||j&&Fn(j.nodesRef.current,C(),!1).some(be=>we(be.context?.elements.floating,J)),Ie=ge();queueMicrotask(()=>{const be=M0(Ie),_e=typeof A.current!="boolean";A.current&&!P.current&&nt(be)&&(!(!_e&&be!==J&&J!==H.body)||ne)&&be.focus({preventScroll:!0}),me.remove()})}},[r,v,L,A,S,k,j,Je,x,C]),m.useEffect(()=>{queueMicrotask(()=>{P.current=!1})},[r]),m.useEffect(()=>{if(r||!w)return;function H(ie){dt(ie)?.closest(`[${yd}]`)&&(I.current=!0)}const se=qe(L);return se.addEventListener("pointerdown",H,!0),()=>{se.removeEventListener("pointerdown",H,!0)}},[r,w,L]),Te(()=>{if(!r&&N)return N.setFocusManagerState({modal:l,closeOnFocusOut:c,open:w,onOpenChange:y.setOpen,domReference:x}),()=>{N.setFocusManagerState(null)}},[r,N,l,w,y,c,x]),Te(()=>{if(!(r||!L))return ac(L,T),()=>{queueMicrotask(xa)}},[r,L,T]);const Me=!r&&(l?!F:!0)&&(Je||l);return b.jsxs(m.Fragment,{children:[Me&&b.jsx(mr,{"data-type":"inside",ref:Z,onFocus:H=>{if(l){const se=te();qo(se[se.length-1])}else N?.portalNode&&(P.current=!1,ir(H,N.portalNode)?pa(x)?.focus():Jt(h??N.beforeOutsideRef)?.focus())}}),n,Me&&b.jsx(mr,{"data-type":"inside",ref:ce,onFocus:H=>{l?qo(te()[0]):N?.portalNode&&(c&&(P.current=!0),ir(H,N.portalNode)?Fd(x)?.focus():Jt(f??N.afterOutsideRef)?.focus())}})]})}function P0(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:s=!0,event:o="click",toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:l=!0,touchOpenDelay:c=0}=t,u=m.useRef(void 0),d=ba(),f=Vn(),h=m.useMemo(()=>({onPointerDown(p){u.current=p.pointerType},onMouseDown(p){const g=u.current,y=p.nativeEvent,w=n.select("open");if(p.button!==0||o==="click"||dr(g,!0)&&a)return;const x=r.current.openEvent,v=x?.type,k=n.select("domReferenceElement")!==p.currentTarget,S=w&&k||!(w&&i&&(!(x&&l)||v==="click"||v==="mousedown"));if(Td(y.target)){const M=Ve(mn,y,y.target);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,M)}):n.setOpen(S,M);return}const C=p.currentTarget;d.request(()=>{const M=Ve(mn,y,C);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,M)}):n.setOpen(S,M)})},onClick(p){if(o==="mousedown-only")return;const g=u.current;if(o==="mousedown"&&g){u.current=void 0;return}if(dr(g,!0)&&a)return;const y=n.select("open"),w=r.current.openEvent,x=n.select("domReferenceElement")!==p.currentTarget,v=y&&x||!(y&&i&&(!(w&&l)||Cd(w))),k=Ve(mn,p.nativeEvent,p.currentTarget);v&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,k)}):n.setOpen(v,k)},onKeyDown(){u.current=void 0}}),[r,o,a,n,l,i,d,f,c]);return m.useMemo(()=>s?{reference:h}:Nn,[s,h])}function lc(e,t,n){let{reference:r,floating:s}=e;const o=yt(t),i=ma(t),a=ha(i),l=it(t),c=o==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[a]/2-s[a]/2;let h;switch(l){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-s.width,y:d};break;default:h={x:r.x,y:r.y}}switch(xn(t)){case"start":h[i]-=f*(n&&c?-1:1);break;case"end":h[i]+=f*(n&&c?-1:1);break}return h}async function R0(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=nn(t,e),p=Ed(h),y=a[f?d==="floating"?"reference":"floating":d],w=zs(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(y)))==null||n?y:y.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=d==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),k=await(o.isElement==null?void 0:o.isElement(v))?await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1}:{x:1,y:1},S=zs(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:v,strategy:l}):x);return{top:(w.top-S.top+p.top)/k.y,bottom:(S.bottom-w.bottom+p.bottom)/k.y,left:(w.left-S.left+p.left)/k.x,right:(S.right-w.right+p.right)/k.x}}const O0=50,A0=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:R0},l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:d}=lc(c,r,l),f=r,h=0;const p={};for(let g=0;g<o.length;g++){const y=o[g];if(!y)continue;const{name:w,fn:x}=y,{x:v,y:k,data:S,reset:C}=await x({x:u,y:d,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:a,elements:{reference:e,floating:t}});u=v??u,d=k??d,p[w]={...p[w],...S},C&&h<O0&&(h++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:u,y:d}=lc(c,f,l)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}},N0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=nn(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const w=it(s),x=yt(a),v=it(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(v||!g?[Ks(a)]:Iy(a)),C=p!=="none";!f&&C&&S.push(...Vy(a,g,p,k));const M=[a,...S],D=await l.detectOverflow(t,y),F=[];let T=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&F.push(D[w]),d){const j=Ny(s,i,k);F.push(D[j[0]],D[j[1]])}if(T=[...T,{placement:s,overflows:F}],!F.every(j=>j<=0)){var R,A;const j=(((R=o.flip)==null?void 0:R.index)||0)+1,N=M[j];if(N&&(!(d==="alignment"?x!==yt(N):!1)||T.every(P=>yt(P.placement)===x?P.overflows[0]>0:!0)))return{data:{index:j,overflows:T},reset:{placement:N}};let V=(A=T.filter(U=>U.overflows[0]<=0).sort((U,P)=>U.overflows[1]-P.overflows[1])[0])==null?void 0:A.placement;if(!V)switch(h){case"bestFit":{var E;const U=(E=T.filter(P=>{if(C){const I=yt(P.placement);return I===x||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,B)=>I+B,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:E[0];U&&(V=U);break}case"initialPlacement":V=a;break}if(s!==V)return{reset:{placement:V}}}return{}}}};function cc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function uc(e){return Oy.some(t=>e[t]>=0)}const I0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...o}=nn(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...o,elementContext:"reference"}),a=cc(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:uc(a)}}}case"escaped":{const i=await r.detectOverflow(t,{...o,altBoundary:!0}),a=cc(i,n.floating);return{data:{escapedOffsets:a,escaped:uc(a)}}}default:return{}}}}},tf=new Set(["left","top"]);async function F0(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=it(n),a=xn(n),l=yt(n)==="y",c=tf.has(i)?-1:1,u=o&&l?-1:1,d=nn(t,e);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const j0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:i,middlewareData:a}=t,l=await F0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:i}}}}},L0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:o}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x,y:v}=w;return{x,y:v}}},...c}=nn(e,t),u={x:n,y:r},d=await o.detectOverflow(t,c),f=yt(it(s)),h=fa(f);let p=u[h],g=u[f];if(i){const w=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=p+d[w],k=p-d[x];p=Ri(v,p,k)}if(a){const w=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=g+d[w],k=g-d[x];g=Ri(v,g,k)}const y=l.fn({...t,[h]:p,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:i,[f]:a}}}}}},V0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:o,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=nn(e,t),u={x:n,y:r},d=yt(s),f=fa(d);let h=u[f],p=u[d];const g=nn(a,t),y=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const v=f==="y"?"height":"width",k=o.reference[f]-o.floating[v]+y.mainAxis,S=o.reference[f]+o.reference[v]-y.mainAxis;h<k?h=k:h>S&&(h=S)}if(c){var w,x;const v=f==="y"?"width":"height",k=tf.has(it(s)),S=o.reference[d]-o.floating[v]+(k&&((w=i.offset)==null?void 0:w[d])||0)+(k?0:y.crossAxis),C=o.reference[d]+o.reference[v]+(k?0:((x=i.offset)==null?void 0:x[d])||0)-(k?y.crossAxis:0);p<S?p=S:p>C&&(p=C)}return{[f]:h,[d]:p}}}},_0=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:o,platform:i,elements:a}=t,{apply:l=()=>{},...c}=nn(e,t),u=await i.detectOverflow(t,c),d=it(s),f=xn(s),h=yt(s)==="y",{width:p,height:g}=o.floating;let y,w;d==="top"||d==="bottom"?(y=d,w=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=d,y=f==="end"?"top":"bottom");const x=g-u.top-u.bottom,v=p-u.left-u.right,k=fr(g-u[y],x),S=fr(p-u[w],v),C=!t.middlewareData.shift;let M=k,D=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(D=v),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(M=x),C&&!f){const T=ft(u.left,0),R=ft(u.right,0),A=ft(u.top,0),E=ft(u.bottom,0);h?D=p-2*(T!==0||R!==0?T+R:ft(u.left,u.right)):M=g-2*(A!==0||E!==0?A+E:ft(u.top,u.bottom))}await l({...t,availableWidth:D,availableHeight:M});const F=await i.getDimensions(a.floating);return p!==F.width||g!==F.height?{reset:{rects:!0}}:{}}}};function nf(e){const t=At(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=nt(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,a=Gs(n)!==o||Gs(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function va(e){return Ae(e)?e:e.contextElement}function lr(e){const t=va(e);if(!nt(t))return Ht(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=nf(t);let i=(o?Gs(n.width):n.width)/r,a=(o?Gs(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const W0=Ht(0);function rf(e){const t=vt(e);return!aa()||!t.visualViewport?W0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function B0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vt(e)?!1:t}function _n(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=va(e);let i=Ht(1);t&&(r?Ae(r)&&(i=lr(r)):i=lr(e));const a=B0(o,n,r)?rf(o):Ht(0);let l=(s.left+a.x)/i.x,c=(s.top+a.y)/i.y,u=s.width/i.x,d=s.height/i.y;if(o){const f=vt(o),h=r&&Ae(r)?vt(r):r;let p=f,g=_l(p);for(;g&&r&&h!==p;){const y=lr(g),w=g.getBoundingClientRect(),x=At(g),v=w.left+(g.clientLeft+parseFloat(x.paddingLeft))*y.x,k=w.top+(g.clientTop+parseFloat(x.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,d*=y.y,l+=v,c+=k,p=vt(g),g=_l(p)}}return zs({width:u,height:d,x:l,y:c})}function mo(e,t){const n=ho(e).scrollLeft;return t?t.left+n:_n(on(e)).left+n}function sf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-mo(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function $0(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",i=on(r),a=t?la(t.floating):!1;if(r===i||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Ht(1);const u=Ht(0),d=nt(r);if((d||!d&&!o)&&((ns(r)!=="body"||rs(i))&&(l=ho(r)),d)){const h=_n(r);c=lr(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=i&&!d&&!o?sf(i,l):Ht(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function Y0(e){return Array.from(e.getClientRects())}function H0(e){const t=on(e),n=ho(e),r=e.ownerDocument.body,s=ft(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ft(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+mo(e);const a=-n.scrollTop;return At(r).direction==="rtl"&&(i+=ft(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}const dc=25;function U0(e,t){const n=vt(e),r=on(e),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,a=0,l=0;if(s){o=s.width,i=s.height;const u=aa();(!u||u&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=mo(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=dc&&(o-=p)}else c<=dc&&(o+=c);return{width:o,height:i,x:a,y:l}}function G0(e,t){const n=_n(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=nt(e)?lr(e):Ht(1),i=e.clientWidth*o.x,a=e.clientHeight*o.y,l=s*o.x,c=r*o.y;return{width:i,height:a,x:l,y:c}}function fc(e,t,n){let r;if(t==="viewport")r=U0(e,n);else if(t==="document")r=H0(on(e));else if(Ae(t))r=G0(t,n);else{const s=rf(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return zs(r)}function of(e,t){const n=ur(e);return n===t||!Ae(n)||In(n)?!1:At(n).position==="fixed"||of(n,t)}function K0(e,t){const n=t.get(e);if(n)return n;let r=or(e,[],!1).filter(a=>Ae(a)&&ns(a)!=="body"),s=null;const o=At(e).position==="fixed";let i=o?ur(e):e;for(;Ae(i)&&!In(i);){const a=At(i),l=ud(i);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||rs(i)&&!l&&of(e,i))?r=r.filter(u=>u!==i):s=a,i=ur(i)}return t.set(e,r),r}function z0(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?la(t)?[]:K0(t,this._c):[].concat(n),r],a=fc(t,i[0],s);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<i.length;f++){const h=fc(t,i[f],s);l=ft(h.top,l),c=fr(h.right,c),u=fr(h.bottom,u),d=ft(h.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function q0(e){const{width:t,height:n}=nf(e);return{width:t,height:n}}function X0(e,t,n){const r=nt(t),s=on(t),o=n==="fixed",i=_n(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=Ht(0);function c(){l.x=mo(s)}if(r||!r&&!o)if((ns(t)!=="body"||rs(s))&&(a=ho(t)),r){const h=_n(t,!0,o,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else s&&c();o&&!r&&s&&c();const u=s&&!r&&!o?sf(s,a):Ht(0),d=i.left+a.scrollLeft-l.x-u.x,f=i.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function Qo(e){return At(e).position==="static"}function hc(e,t){if(!nt(e)||At(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return on(e)===n&&(n=n.ownerDocument.body),n}function af(e,t){const n=vt(e);if(la(e))return n;if(!nt(e)){let s=ur(e);for(;s&&!In(s);){if(Ae(s)&&!Qo(s))return s;s=ur(s)}return n}let r=hc(e,t);for(;r&&Lg(r)&&Qo(r);)r=hc(r,t);return r&&In(r)&&Qo(r)&&!ud(r)?n:r||Vg(e)||n}const Z0=async function(e){const t=this.getOffsetParent||af,n=this.getDimensions,r=await n(e.floating);return{reference:X0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Q0(e){return At(e).direction==="rtl"}const J0={convertOffsetParentRelativeRectToViewportRelativeRect:$0,getDocumentElement:on,getClippingRect:z0,getOffsetParent:af,getElementRects:Z0,getClientRects:Y0,getDimensions:q0,getScale:lr,isElement:Ae,isRTL:Q0};function lf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ex(e,t){let n=null,r;const s=on(e);function o(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),o();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:h}=c;if(a||t(),!f||!h)return;const p=Ss(d),g=Ss(s.clientWidth-(u+f)),y=Ss(s.clientHeight-(d+h)),w=Ss(u),v={rootMargin:-p+"px "+-g+"px "+-y+"px "+-w+"px",threshold:ft(0,fr(1,l))||1};let k=!0;function S(C){const M=C[0].intersectionRatio;if(M!==l){if(!k)return i();M?i(!1,M):r=setTimeout(()=>{i(!1,1e-7)},1e3)}M===1&&!lf(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...v,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,v)}n.observe(e)}return i(!0),o}function mc(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=va(e),u=s||o?[...c?or(c):[],...t?or(t):[]]:[];u.forEach(w=>{s&&w.addEventListener("scroll",n,{passive:!0}),o&&w.addEventListener("resize",n)});const d=c&&a?ex(c,n):null;let f=-1,h=null;i&&(h=new ResizeObserver(w=>{let[x]=w;x&&x.target===c&&h&&t&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(t)})),n()}),c&&!l&&h.observe(c),t&&h.observe(t));let p,g=l?_n(e):null;l&&y();function y(){const w=_n(e);g&&!lf(g,w)&&n(),g=w,p=requestAnimationFrame(y)}return n(),()=>{var w;u.forEach(x=>{s&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),d?.(),(w=h)==null||w.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const tx=j0,nx=L0,rx=N0,sx=_0,ox=I0,ix=V0,ax=(e,t,n)=>{const r=new Map,s={platform:J0,...n},o={...s.platform,_c:r};return A0(e,t,{...s,platform:o})};var lx=typeof document<"u",cx=function(){},Fs=lx?m.useLayoutEffect:cx;function to(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!to(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!to(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function cf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pc(e,t){const n=cf(e);return Math.round(t*n)/n}function Jo(e){const t=m.useRef(e);return Fs(()=>{t.current=e}),t}function ux(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=m.useState(r);to(f,r)||h(r);const[p,g]=m.useState(null),[y,w]=m.useState(null),x=m.useCallback(P=>{P!==C.current&&(C.current=P,g(P))},[]),v=m.useCallback(P=>{P!==M.current&&(M.current=P,w(P))},[]),k=o||p,S=i||y,C=m.useRef(null),M=m.useRef(null),D=m.useRef(u),F=l!=null,T=Jo(l),R=Jo(s),A=Jo(c),E=m.useCallback(()=>{if(!C.current||!M.current)return;const P={placement:t,strategy:n,middleware:f};R.current&&(P.platform=R.current),ax(C.current,M.current,P).then(I=>{const B={...I,isPositioned:A.current!==!1};j.current&&!to(D.current,B)&&(D.current=B,pn.flushSync(()=>{d(B)}))})},[f,t,n,R,A]);Fs(()=>{c===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,d(P=>({...P,isPositioned:!1})))},[c]);const j=m.useRef(!1);Fs(()=>(j.current=!0,()=>{j.current=!1}),[]),Fs(()=>{if(k&&(C.current=k),S&&(M.current=S),k&&S){if(T.current)return T.current(k,S,E);E()}},[k,S,E,T,F]);const N=m.useMemo(()=>({reference:C,floating:M,setReference:x,setFloating:v}),[x,v]),V=m.useMemo(()=>({reference:k,floating:S}),[k,S]),U=m.useMemo(()=>{const P={position:n,left:0,top:0};if(!V.floating)return P;const I=pc(V.floating,u.x),B=pc(V.floating,u.y);return a?{...P,transform:"translate("+I+"px, "+B+"px)",...cf(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:B}},[n,a,V.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:E,refs:N,elements:V,floatingStyles:U}),[u,E,N,V,U])}const dx=(e,t)=>{const n=tx(e);return{name:n.name,fn:n.fn,options:[e,t]}},fx=(e,t)=>{const n=nx(e);return{name:n.name,fn:n.fn,options:[e,t]}},hx=(e,t)=>({fn:ix(e).fn,options:[e,t]}),mx=(e,t)=>{const n=rx(e);return{name:n.name,fn:n.fn,options:[e,t]}},px=(e,t)=>{const n=sx(e);return{name:n.name,fn:n.fn,options:[e,t]}},gx=(e,t)=>{const n=ox(e);return{name:n.name,fn:n.fn,options:[e,t]}},yx={intentional:"onClick",sloppy:"onPointerDown"};function bx(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function uf(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingElement"),o=n.useState("referenceElement"),i=n.useState("domReferenceElement"),{onOpenChange:a,dataRef:l}=n.context,{enabled:c=!0,escapeKey:u=!0,outsidePress:d=!0,outsidePressEvent:f="sloppy",referencePress:h=!1,referencePressEvent:p="sloppy",ancestorScroll:g=!1,bubbles:y,externalTree:w}=t,x=wr(w),v=he(typeof d=="function"?d:()=>!1),k=typeof d=="function"?v:d,S=m.useRef(!1),{escapeKey:C,outsidePress:M}=bx(y),D=m.useRef(null),F=Vn(),T=Vn(),R=he(()=>{T.clear(),l.current.insideReactTree=!1}),A=m.useRef(!1),E=m.useRef(""),j=he(L=>{E.current=L.pointerType}),N=he(()=>{const L=E.current,ue=L==="pen"||!L?"mouse":L,te=typeof f=="function"?f():f;return typeof te=="string"?te:te[ue]}),V=he(L=>{if(!r||!c||!u||L.key!=="Escape"||A.current)return;const ue=l.current.floatingContext?.nodeId,te=x?Fn(x.nodesRef.current,ue):[];if(!C&&te.length>0){let se=!0;if(te.forEach(ie=>{ie.context?.open&&!ie.context.dataRef.current.__escapeKeyBubbles&&(se=!1)}),!se)return}const Me=Dy(L)?L.nativeEvent:L,H=Ve(dd,Me);n.setOpen(!1,H),!C&&!H.isPropagationAllowed&&L.stopPropagation()}),U=he(L=>{const ue=N();return ue==="intentional"&&L.type!=="click"||ue==="sloppy"&&L.type==="click"}),P=he(()=>{l.current.insideReactTree=!0,T.start(0,R)}),I=he((L,ue=!1)=>{if(U(L)){R();return}if(l.current.insideReactTree){R();return}if(N()==="intentional"&&ue||typeof k=="function"&&!k(L))return;const te=dt(L),Me=`[${Ur("inert")}]`,H=qe(n.select("floatingElement")).querySelectorAll(Me),se=n.context.triggerElements;if(te&&(se.hasElement(te)||se.hasMatchingElement(ne=>we(ne,te))))return;let ie=Ae(te)?te:null;for(;ie&&!In(ie);){const ne=ur(ie);if(In(ne)||!Ae(ne))break;ie=ne}if(H.length&&Ae(te)&&!Ey(te)&&!we(te,n.select("floatingElement"))&&Array.from(H).every(ne=>!we(ie,ne)))return;if(nt(te)&&!("touches"in L)){const ne=In(te),Ie=At(te),be=/auto|scroll/,_e=ne||be.test(Ie.overflowX),Ge=ne||be.test(Ie.overflowY),ot=_e&&te.clientWidth>0&&te.scrollWidth>te.clientWidth,Oe=Ge&&te.clientHeight>0&&te.scrollHeight>te.clientHeight,ye=Ie.direction==="rtl",Fe=Oe&&(ye?L.offsetX<=te.offsetWidth-te.clientWidth:L.offsetX>te.clientWidth),$e=ot&&L.offsetY>te.clientHeight;if(Fe||$e)return}const me=l.current.floatingContext?.nodeId,ge=x&&Fn(x.nodesRef.current,me).some(ne=>Ct(L,ne.context?.elements.floating));if(Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||ge)return;const J=x?Fn(x.nodesRef.current,me):[];if(J.length>0){let ne=!0;if(J.forEach(Ie=>{Ie.context?.open&&!Ie.context.dataRef.current.__outsidePressBubbles&&(ne=!1)}),!ne)return}n.setOpen(!1,Ve(cd,L)),R()}),B=he(L=>{N()!=="sloppy"||L.pointerType==="touch"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||I(L)}),W=he(L=>{if(N()!=="sloppy"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement")))return;const ue=L.touches[0];ue&&(D.current={startTime:Date.now(),startX:ue.clientX,startY:ue.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},F.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}),Q=he(L=>{const ue=dt(L);function te(){W(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Y=he(L=>{const ue=S.current;if(S.current=!1,F.clear(),L.type==="mousedown"&&D.current&&!D.current.dismissOnMouseDown)return;const te=dt(L);function Me(){L.type==="pointerdown"?B(L):I(L,ue),te?.removeEventListener(L.type,Me)}te?.addEventListener(L.type,Me)}),$=he(L=>{if(N()!=="sloppy"||!D.current||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement")))return;const ue=L.touches[0];if(!ue)return;const te=Math.abs(ue.clientX-D.current.startX),Me=Math.abs(ue.clientY-D.current.startY),H=Math.sqrt(te*te+Me*Me);H>5&&(D.current.dismissOnTouchEnd=!0),H>10&&(I(L),F.clear(),D.current=null)}),z=he(L=>{const ue=dt(L);function te(){$(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Z=he(L=>{N()!=="sloppy"||!D.current||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||(D.current.dismissOnTouchEnd&&I(L),F.clear(),D.current=null)}),ce=he(L=>{const ue=dt(L);function te(){Z(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)});m.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=C,l.current.__outsidePressBubbles=M;const L=new gn;function ue(ie){n.setOpen(!1,Ve(_g,ie))}function te(){L.clear(),A.current=!0}function Me(){L.start(aa()?5:0,()=>{A.current=!1})}const H=qe(s);H.addEventListener("pointerdown",j,!0),u&&(H.addEventListener("keydown",V),H.addEventListener("compositionstart",te),H.addEventListener("compositionend",Me)),k&&(H.addEventListener("click",Y,!0),H.addEventListener("pointerdown",Y,!0),H.addEventListener("touchstart",Q,!0),H.addEventListener("touchmove",z,!0),H.addEventListener("touchend",ce,!0),H.addEventListener("mousedown",Y,!0));let se=[];return g&&(Ae(i)&&(se=or(i)),Ae(s)&&(se=se.concat(or(s))),!Ae(o)&&o&&o.contextElement&&(se=se.concat(or(o.contextElement)))),se=se.filter(ie=>ie!==H.defaultView?.visualViewport),se.forEach(ie=>{ie.addEventListener("scroll",ue,{passive:!0})}),()=>{H.removeEventListener("pointerdown",j,!0),u&&(H.removeEventListener("keydown",V),H.removeEventListener("compositionstart",te),H.removeEventListener("compositionend",Me)),k&&(H.removeEventListener("click",Y,!0),H.removeEventListener("pointerdown",Y,!0),H.removeEventListener("touchstart",Q,!0),H.removeEventListener("touchmove",z,!0),H.removeEventListener("touchend",ce,!0),H.removeEventListener("mousedown",Y,!0)),se.forEach(ie=>{ie.removeEventListener("scroll",ue)}),L.clear(),S.current=!1}},[l,s,o,i,u,k,r,a,g,c,C,M,V,I,Y,B,Q,z,ce,j,n]),m.useEffect(R,[k,R]);const Se=m.useMemo(()=>({onKeyDown:V,...h&&{[yx[p]]:L=>{n.setOpen(!1,Ve(mn,L.nativeEvent))},...p!=="intentional"&&{onClick(L){n.setOpen(!1,Ve(mn,L.nativeEvent))}}}}),[V,n,h,p]),Re=he(L=>{const ue=dt(L.nativeEvent);!we(n.select("floatingElement"),ue)||L.button!==0||(S.current=!0)}),Ee=he(L=>{!r||!c||L.button!==0||(S.current=!0)}),Je=m.useMemo(()=>({onKeyDown:V,onPointerDown:Re,onMouseDown:Re,onMouseUp:Re,onClickCapture:P,onMouseDownCapture(L){P(),Ee(L)},onPointerDownCapture(L){P(),Ee(L)},onMouseUpCapture:P,onTouchEndCapture:P,onTouchMoveCapture:P}),[V,Re,P,Ee]);return m.useMemo(()=>c?{reference:Se,floating:Je,trigger:Se}:{},[c,Se,Je])}const xx={open:pe(e=>e.open),domReferenceElement:pe(e=>e.domReferenceElement),referenceElement:pe(e=>e.positionReference??e.referenceElement),floatingElement:pe(e=>e.floatingElement),floatingId:pe(e=>e.floatingId)};class wa extends ya{constructor(t){const{nested:n,noEmit:r,onOpenChange:s,triggerElements:o,...i}=t;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:Kd(),nested:n,noEmit:r,triggerElements:o},xx)}setOpen=(t,n)=>{if((!t||!this.state.open||Cd(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)}this.context.onOpenChange?.(t,n)}}function vx(e,t=!1,n=!1){const[r,s]=m.useState(e&&t?"idle":void 0),[o,i]=m.useState(e);return e&&!o&&(i(!0),s("starting")),!e&&o&&r!=="ending"&&!n&&s("ending"),!e&&!o&&r==="ending"&&s(void 0),Te(()=>{if(!e&&o&&r!=="ending"&&n){const a=Vt.request(()=>{s("ending")});return()=>{Vt.cancel(a)}}},[e,o,r,n]),Te(()=>{if(!e||t)return;const a=Vt.request(()=>{s(void 0)});return()=>{Vt.cancel(a)}},[t,e]),Te(()=>{if(!e||!t)return;e&&o&&r!=="idle"&&s("starting");const a=Vt.request(()=>{s("idle")});return()=>{Vt.cancel(a)}},[t,e,o,s,r]),m.useMemo(()=>({mounted:o,setMounted:i,transitionStatus:r}),[o,r])}let Gr=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const wx={[Gr.startingStyle]:""},kx={[Gr.endingStyle]:""},po={transitionStatus(e){return e==="starting"?wx:e==="ending"?kx:null}};function df(e,t=!1,n=!0){const r=ba();return he((s,o=null)=>{r.cancel();function i(){pn.flushSync(s)}const a=Jt(e);if(a==null)return;const l=a;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)s();else{let c=function(){const d=Gr.startingStyle;if(!l.hasAttribute(d)){r.request(u);return}const f=new MutationObserver(()=>{l.hasAttribute(d)||(f.disconnect(),u())});f.observe(l,{attributes:!0,attributeFilter:[d]}),o?.addEventListener("abort",()=>f.disconnect(),{once:!0})},u=function(){Promise.all(l.getAnimations().map(d=>d.finished)).then(()=>{o?.aborted||i()}).catch(()=>{const d=l.getAnimations();if(n){if(o?.aborted)return;i()}else d.length>0&&d.some(f=>f.pending||f.playState!=="finished")&&u()})};if(t){c();return}r.request(u)}})}function ka(e){const{enabled:t=!0,open:n,ref:r,onComplete:s}=e,o=he(s),i=df(r,n,!1);m.useEffect(()=>{if(!t)return;const a=new AbortController;return i(o,a.signal),()=>{a.abort()}},[t,n,o,i])}function Sx(e,t){const n=m.useRef(null),r=m.useRef(null);return m.useCallback(s=>{if(e!==void 0){if(n.current!==null){const o=n.current,i=r.current,a=t.context.triggerElements.getById(o);i&&a===i&&t.context.triggerElements.delete(o),n.current=null,r.current=null}s!==null&&(n.current=e,r.current=s,t.context.triggerElements.add(e,s))}},[t,e])}function Tx(e,t,n,r){const s=n.useState("isMountedByTrigger",e),o=Sx(e,n),i=he(a=>{if(o(a),!a||!n.select("open"))return;const l=n.select("activeTriggerId");if(l===e){n.update({activeTriggerElement:a,...r});return}l==null&&n.update({activeTriggerId:e,activeTriggerElement:a,...r})});return Te(()=>{s&&n.update({activeTriggerElement:t.current,...r})},[s,n,t,...Object.values(r)]),{registerTrigger:i,isMountedByThisTrigger:s}}function ff(e){const t=e.useState("open");Te(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,s]=n.value;e.update({activeTriggerId:r,activeTriggerElement:s})}}},[t,e])}function hf(e,t,n){const{mounted:r,setMounted:s,transitionStatus:o}=vx(e);t.useSyncedValues({mounted:r,transitionStatus:o});const i=he(()=>{s(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),a=t.useState("preventUnmountingOnClose");return ka({enabled:!a,open:e,ref:t.context.popupRef,onComplete(){e||i()}}),{forceUnmount:i,transitionStatus:o}}class go{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elements.delete(r),this.elements.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elements.delete(n),this.idMap.delete(t))}hasElement(t){return this.elements.has(t)}hasMatchingElement(t){for(const n of this.elements)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function Cx(){return new wa({open:!1,floatingElement:null,referenceElement:null,triggerElements:new go,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function mf(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Cx(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Nn,inactiveTriggerProps:Nn,popupProps:Nn}}const pf={open:pe(e=>e.open),mounted:pe(e=>e.mounted),transitionStatus:pe(e=>e.transitionStatus),floatingRootContext:pe(e=>e.floatingRootContext),preventUnmountingOnClose:pe(e=>e.preventUnmountingOnClose),payload:pe(e=>e.payload),activeTriggerId:pe(e=>e.activeTriggerId),activeTriggerElement:pe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:pe((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:pe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:pe(e=>e.popupProps),popupElement:pe(e=>e.popupElement),positionerElement:pe(e=>e.positionerElement)};function Ex(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=ts(),o=Yn()!=null,i=bn(()=>new wa({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new go,floatingId:s,nested:o,noEmit:e.noEmit||!1})).current;return Te(()=>{const a={open:t,floatingId:s};r.reference!==void 0&&(a.referenceElement=r.reference,a.domReferenceElement=Ae(r.reference)?r.reference:null),r.floating!==void 0&&(a.floatingElement=r.floating),i.update(a)},[t,s,r.reference,r.floating,i]),i.context.onOpenChange=n,i.context.nested=o,i.context.noEmit=e.noEmit||!1,i}function Mx(e={}){const{nodeId:t,externalTree:n}=e,r=Ex(e),s=e.rootContext||r,o={reference:s.useState("referenceElement"),floating:s.useState("floatingElement"),domReference:s.useState("domReferenceElement")},[i,a]=m.useState(null),l=m.useRef(null),c=wr(n);Te(()=>{o.domReference&&(l.current=o.domReference)},[o.domReference]);const u=ux({...e,elements:{...o,...i&&{reference:i}}}),d=m.useCallback(M=>{const D=Ae(M)?{getBoundingClientRect:()=>M.getBoundingClientRect(),getClientRects:()=>M.getClientRects(),contextElement:M}:M;a(D),u.refs.setReference(D)},[u.refs]),[f,h]=m.useState(null),[p,g]=m.useState(null);s.useSyncedValue("referenceElement",f),s.useSyncedValue("domReferenceElement",Ae(f)?f:null),s.useSyncedValue("floatingElement",p);const y=m.useCallback(M=>{(Ae(M)||M===null)&&(l.current=M,h(M)),(Ae(u.refs.reference.current)||u.refs.reference.current===null||M!==null&&!Ae(M))&&u.refs.setReference(M)},[u.refs,h]),w=m.useCallback(M=>{g(M),u.refs.setFloating(M)},[u.refs]),x=m.useMemo(()=>({...u.refs,setReference:y,setFloating:w,setPositionReference:d,domReference:l}),[u.refs,y,w,d]),v=m.useMemo(()=>({...u.elements,domReference:o.domReference}),[u.elements,o.domReference]),k=s.useState("open"),S=s.useState("floatingId"),C=m.useMemo(()=>({...u,dataRef:s.context.dataRef,open:k,onOpenChange:s.setOpen,events:s.context.events,floatingId:S,refs:x,elements:v,nodeId:t,rootStore:s}),[u,x,v,t,s,k,S]);return Te(()=>{s.context.dataRef.current.floatingContext=C;const M=c?.nodesRef.current.find(D=>D.id===t);M&&(M.context=C)}),m.useMemo(()=>({...u,context:C,refs:x,elements:v,rootStore:s}),[u,x,v,C,s])}function gf(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:s}=e,o=ts(),i=Yn()!=null,a=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=bn(()=>new wa({open:a,referenceElement:l,floatingElement:c,triggerElements:u,onOpenChange:s,floatingId:o,nested:i,noEmit:n})).current;return Te(()=>{const f={open:a,floatingId:o,referenceElement:l,floatingElement:c};Ae(l)&&(f.domReferenceElement=l),d.state.positionReference===d.state.referenceElement&&(f.positionReference=l),d.update(f)},[a,o,l,c,d]),d.context.onOpenChange=s,d.context.nested=i,d.context.noEmit=n,d}const Ii=Ur("safe-polygon"),Dx=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Sd}`;function Px(e){return e?!!e.closest(Dx):!1}function yf(e){const t=m.useRef(void 0),n=m.useRef(!1),r=m.useRef(void 0),s=m.useRef(!0),o=m.useRef(!1),i=m.useRef(()=>{}),a=m.useRef(!1),l=Vn(),c=Vn(),u=m.useRef(void 0);return m.useMemo(()=>{const d=e.context.dataRef.current;return d.hoverInteractionState||(d.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:s,performedPointerEventsMutationRef:o,unbindMouseMoveRef:i,restTimeoutPendingRef:a,openChangeTimeout:l,restTimeout:c,handleCloseOptionsRef:u}),d.hoverInteractionState},[e,t,n,r,s,o,i,a,l,c,u])}const Rx=new Set(["click","mousedown"]);function Ox(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingElement"),o=n.useState("domReferenceElement"),{dataRef:i}=n.context,{enabled:a=!0,closeDelay:l=0,externalTree:c}=t,{pointerTypeRef:u,interactedInsideRef:d,handlerRef:f,performedPointerEventsMutationRef:h,unbindMouseMoveRef:p,restTimeoutPendingRef:g,openChangeTimeout:y,handleCloseOptionsRef:w}=yf(n),x=wr(c),v=Yn(),k=he(()=>d.current?!0:i.current.openEvent?Rx.has(i.current.openEvent.type):!1),S=he(()=>{const T=i.current.openEvent?.type;return T?.includes("mouse")&&T!=="mousedown"}),C=m.useCallback((T,R=!0)=>{const A=Ax(l,u.current);A&&!f.current?y.start(A,()=>n.setOpen(!1,Ve(ut,T))):R&&(y.clear(),n.setOpen(!1,Ve(ut,T)))},[l,f,n,u,y]),M=he(()=>{p.current(),f.current=void 0}),D=he(()=>{if(h.current){const T=qe(s).body;T.style.pointerEvents="",T.removeAttribute(Ii),h.current=!1}}),F=he(T=>{const R=dt(T);if(!Px(R)){d.current=!1;return}d.current=!0});Te(()=>{r||(u.current=void 0,g.current=!1,d.current=!1,M(),D())},[r,u,g,d,M,D]),m.useEffect(()=>()=>{M()},[M]),m.useEffect(()=>D,[D]),Te(()=>{if(a&&r&&w.current?.blockPointerEvents&&S()&&Ae(o)&&s){h.current=!0;const T=qe(s).body;T.setAttribute(Ii,"");const R=o,A=s,E=x?.nodesRef.current.find(j=>j.id===v)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),T.style.pointerEvents="none",R.style.pointerEvents="auto",A.style.pointerEvents="auto",()=>{T.style.pointerEvents="",R.style.pointerEvents="",A.style.pointerEvents=""}}},[a,r,o,s,w,S,x,v,h]),m.useEffect(()=>{if(!a)return;function T(j){if(k()||!i.current.floatingContext||!n.select("open"))return;const N=n.context.triggerElements;j.relatedTarget&&N.hasElement(j.relatedTarget)||(D(),M(),k()||C(j))}function R(j){y.clear(),D(),f.current?.(j),M()}function A(j){k()||C(j,!1)}const E=s;return E&&(E.addEventListener("mouseleave",T),E.addEventListener("mouseenter",R),E.addEventListener("mouseleave",A),E.addEventListener("pointerdown",F,!0)),()=>{E&&(E.removeEventListener("mouseleave",T),E.removeEventListener("mouseenter",R),E.removeEventListener("mouseleave",A),E.removeEventListener("pointerdown",F,!0))}})}function Ax(e,t){return t&&!dr(t)?0:typeof e=="function"?e():e}function ei(e){return typeof e=="function"?e():e}const Nx={current:null};function Ix(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:r,events:s}=n.context,{enabled:o=!0,delay:i=0,handleClose:a=null,mouseOnly:l=!1,restMs:c=0,move:u=!0,triggerElementRef:d=Nx,externalTree:f,isActiveTrigger:h=!0}=t,p=wr(f),{pointerTypeRef:g,interactedInsideRef:y,handlerRef:w,blockMouseMoveRef:x,performedPointerEventsMutationRef:v,unbindMouseMoveRef:k,restTimeoutPendingRef:S,openChangeTimeout:C,restTimeout:M,handleCloseOptionsRef:D}=yf(n),F=Bt(a),T=Bt(i),R=Bt(c);h&&(D.current=F.current?.__options);const A=he(()=>y.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=m.useCallback((U,P=!0)=>{const I=zo(T.current,"close",g.current);I&&!w.current?C.start(I,()=>n.setOpen(!1,Ve(ut,U))):P&&(C.clear(),n.setOpen(!1,Ve(ut,U)))},[T,w,n,g,C]),j=he(()=>{k.current(),w.current=void 0}),N=he(()=>{if(v.current){const U=qe(n.select("domReferenceElement")).body;U.style.pointerEvents="",U.removeAttribute(Ii),v.current=!1}});m.useEffect(()=>{if(!o)return;function U(P){P.open||(C.clear(),M.clear(),x.current=!0,S.current=!1)}return s.on("openchange",U),()=>{s.off("openchange",U)}},[o,s,C,M,x,S]);const V=he(U=>{if(A()||!r.current.floatingContext)return;const P=n.context.triggerElements;if(U.relatedTarget&&P.hasElement(U.relatedTarget))return;const I=d.current;F.current?.({...r.current.floatingContext,tree:p,x:U.clientX,y:U.clientY,onClose(){N(),j(),!A()&&I===n.select("domReferenceElement")&&E(U)}})(U)});return m.useEffect(()=>{if(!o)return;const U=d.current??(h?n.select("domReferenceElement"):null);if(!Ae(U))return;function P(W){if(C.clear(),x.current=!1,l&&!dr(g.current)||ei(R.current)>0&&!zo(T.current,"open"))return;const Q=zo(T.current,"open",g.current),Y=n.select("domReferenceElement"),$=n.context.triggerElements,z=($.hasElement(W.target)||$.hasMatchingElement(Re=>we(Re,W.target)))&&(!Y||!we(Y,W.target)),Z=W.currentTarget??null,ce=n.select("open"),Se=!ce||z;z&&ce?n.setOpen(!0,Ve(ut,W,Z)):Q?C.start(Q,()=>{Se&&n.setOpen(!0,Ve(ut,W,Z))}):Se&&n.setOpen(!0,Ve(ut,W,Z))}function I(W){if(A()){N();return}k.current();const Q=n.select("domReferenceElement"),Y=qe(Q);M.clear(),S.current=!1;const $=n.context.triggerElements;if(W.relatedTarget&&$.hasElement(W.relatedTarget))return;if(F.current&&r.current.floatingContext){n.select("open")||C.clear();const Z=d.current;w.current=F.current({...r.current.floatingContext,tree:p,x:W.clientX,y:W.clientY,onClose(){N(),j(),!A()&&Z===n.select("domReferenceElement")&&E(W,!0)}});const ce=w.current;ce(W),Y.addEventListener("mousemove",ce),k.current=()=>{Y.removeEventListener("mousemove",ce)};return}(g.current!=="touch"||!we(n.select("floatingElement"),W.relatedTarget))&&E(W)}function B(W){V(W)}return n.select("open")&&U.addEventListener("mouseleave",B),u&&U.addEventListener("mousemove",P,{once:!0}),U.addEventListener("mouseenter",P),U.addEventListener("mouseleave",I),()=>{U.removeEventListener("mouseleave",B),u&&U.removeEventListener("mousemove",P),U.removeEventListener("mouseenter",P),U.removeEventListener("mouseleave",I)}},[j,N,x,r,T,E,n,o,F,V,h,A,l,u,g,R,M,S,C,d,p,k,w]),m.useMemo(()=>{function U(P){g.current=P.pointerType}return{onPointerDown:U,onPointerEnter:U,onMouseMove(P){const{nativeEvent:I}=P,B=P.currentTarget,W=n.select("domReferenceElement"),Q=n.context.triggerElements,Y=n.select("open"),$=(Q.hasElement(P.target)||Q.hasMatchingElement(Z=>we(Z,P.target)))&&(!W||!we(W,P.target));if(l&&!dr(g.current)||Y&&!$||ei(R.current)===0||!$&&S.current&&P.movementX**2+P.movementY**2<2)return;M.clear();function z(){if(S.current=!1,A())return;const Z=n.select("open");!x.current&&(!Z||$)&&n.setOpen(!0,Ve(ut,I,B))}g.current==="touch"?pn.flushSync(()=>{z()}):$&&Y?z():(S.current=!0,M.start(ei(R.current),z))}}},[x,A,l,n,g,R,M,S])}function Sa(e=[]){const t=e.map(c=>c?.reference),n=e.map(c=>c?.floating),r=e.map(c=>c?.item),s=e.map(c=>c?.trigger),o=m.useCallback(c=>Ps(c,e,"reference"),t),i=m.useCallback(c=>Ps(c,e,"floating"),n),a=m.useCallback(c=>Ps(c,e,"item"),r),l=m.useCallback(c=>Ps(c,e,"trigger"),s);return m.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:a,getTriggerProps:l}),[o,i,a,l])}function Ps(e,t,n){const r=new Map,s=n==="item",o={};n==="floating"&&(o.tabIndex=-1,o[Di]="");for(const i in e)s&&e&&(i===wd||i===kd)||(o[i]=e[i]);for(let i=0;i<t.length;i+=1){let a;const l=t[i]?.[n];typeof l=="function"?a=e?l(e):null:a=l,a&&gc(o,a,s,r)}return gc(o,e,s,r),o}function gc(e,t,n,r){for(const s in t){const o=t[s];n&&(s===wd||s===kd)||(s.startsWith("on")?(r.has(s)||r.set(s,[]),typeof o=="function"&&(r.get(s)?.push(o),e[s]=(...i)=>r.get(s)?.map(a=>a(...i)).find(a=>a!==void 0))):e[s]=o)}}const Fx=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function bf(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingId"),o=n.useState("domReferenceElement"),i=n.useState("floatingElement"),{enabled:a=!0,role:l="dialog"}=t,c=ts(),u=o?.id||c,d=m.useMemo(()=>Pi(i)?.id||s,[i,s]),f=Fx.get(l)??l,p=Yn()!=null,g=m.useMemo(()=>f==="tooltip"||l==="label"?Nn:{"aria-haspopup":f==="alertdialog"?"dialog":f,"aria-expanded":"false",...f==="listbox"&&{role:"combobox"},...f==="menu"&&p&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[f,p,l]),y=m.useMemo(()=>f==="tooltip"||l==="label"?{[`aria-${l==="label"?"labelledby":"describedby"}`]:r?d:void 0}:{...g,"aria-expanded":r?"true":"false","aria-controls":r?d:void 0,...f==="menu"&&{id:u}},[f,d,r,u,l,g]),w=m.useMemo(()=>{const v={id:d,...f&&{role:f}};return f==="tooltip"||l==="label"?v:{...v,...f==="menu"&&{"aria-labelledby":u}}},[f,d,u,l]),x=m.useCallback(({active:v,selected:k})=>{const S={role:"option",...v&&{id:`${d}-fui-option`}};switch(l){case"select":case"combobox":return{...S,"aria-selected":k}}return{}},[d,l]);return m.useMemo(()=>a?{reference:y,floating:w,item:x,trigger:g}:{},[a,y,w,g,x])}function yc(e,t){const[n,r]=e;let s=!1;const o=t.length;for(let i=0,a=o-1;i<o;a=i++){const[l,c]=t[i]||[0,0],[u,d]=t[a]||[0,0];c>=r!=d>=r&&n<=(u-l)*(r-c)/(d-c)+l&&(s=!s)}return s}function jx(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Lx(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,s=new gn;let o=!1,i=null,a=null,l=typeof performance<"u"?performance.now():0;function c(d,f){const h=performance.now(),p=h-l;if(i===null||a===null||p===0)return i=d,a=f,l=h,null;const g=d-i,y=f-a,x=Math.sqrt(g*g+y*y)/p;return i=d,a=f,l=h,x}const u=({x:d,y:f,placement:h,elements:p,onClose:g,nodeId:y,tree:w})=>function(v){function k(){s.clear(),g()}if(s.clear(),!p.domReference||!p.floating||h==null||d==null||f==null)return;const{clientX:S,clientY:C}=v,M=[S,C],D=dt(v),F=v.type==="mouseleave",T=we(p.floating,D),R=we(p.domReference,D),A=p.domReference.getBoundingClientRect(),E=p.floating.getBoundingClientRect(),j=h.split("-")[0],N=d>E.right-E.width/2,V=f>E.bottom-E.height/2,U=jx(M,A),P=E.width>A.width,I=E.height>A.height,B=(P?A:E).left,W=(P?A:E).right,Q=(I?A:E).top,Y=(I?A:E).bottom;if(T&&(o=!0,!F))return;if(R&&(o=!1),R&&!F){o=!0;return}if(F&&Ae(v.relatedTarget)&&we(p.floating,v.relatedTarget)||w&&Fn(w.nodesRef.current,y).some(({context:Z})=>Z?.open))return;if(j==="top"&&f>=A.bottom-1||j==="bottom"&&f<=A.top+1||j==="left"&&d>=A.right-1||j==="right"&&d<=A.left+1)return k();let $=[];switch(j){case"top":$=[[B,A.top+1],[B,E.bottom-1],[W,E.bottom-1],[W,A.top+1]];break;case"bottom":$=[[B,E.top+1],[B,A.bottom-1],[W,A.bottom-1],[W,E.top+1]];break;case"left":$=[[E.right-1,Y],[E.right-1,Q],[A.left+1,Q],[A.left+1,Y]];break;case"right":$=[[A.right-1,Y],[A.right-1,Q],[E.left+1,Q],[E.left+1,Y]];break}function z([Z,ce]){switch(j){case"top":{const Se=[P?Z+t/2:N?Z+t*4:Z-t*4,ce+t+1],Re=[P?Z-t/2:N?Z+t*4:Z-t*4,ce+t+1],Ee=[[E.left,N||P?E.bottom-t:E.top],[E.right,N?P?E.bottom-t:E.top:E.bottom-t]];return[Se,Re,...Ee]}case"bottom":{const Se=[P?Z+t/2:N?Z+t*4:Z-t*4,ce-t],Re=[P?Z-t/2:N?Z+t*4:Z-t*4,ce-t],Ee=[[E.left,N||P?E.top+t:E.bottom],[E.right,N?P?E.top+t:E.bottom:E.top+t]];return[Se,Re,...Ee]}case"left":{const Se=[Z+t+1,I?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z+t+1,I?ce-t/2:V?ce+t*4:ce-t*4];return[...[[V||I?E.right-t:E.left,E.top],[V?I?E.right-t:E.left:E.right-t,E.bottom]],Se,Re]}case"right":{const Se=[Z-t,I?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z-t,I?ce-t/2:V?ce+t*4:ce-t*4],Ee=[[V||I?E.left+t:E.right,E.top],[V?I?E.left+t:E.right:E.left+t,E.bottom]];return[Se,Re,...Ee]}default:return[]}}if(!yc([S,C],$)){if(o&&!U)return k();if(!F&&r){const Z=c(v.clientX,v.clientY);if(Z!==null&&Z<.1)return k()}yc([S,C],z([d,f]))?!o&&r&&s.start(40,k):k()}};return u.__options={blockPointerEvents:n},u}function Vx(e){const t=m.useRef(""),n=m.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:m.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s&&e(s,s.pointerType),e(s,t.current),t.current=""},[e]),onPointerDown:n}}function xf(e){const[t,n]=m.useState(null),r=he((a,l)=>{e||n(l||(vd?"touch":""))}),s=m.useCallback(()=>{n(null)},[]),{onClick:o,onPointerDown:i}=Vx(r);return m.useMemo(()=>({openMethod:t,reset:s,triggerProps:{onClick:o,onPointerDown:i}}),[t,s,o,i])}let Pt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Gr.startingStyle]="startingStyle",e[e.endingStyle=Gr.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),Fi=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const _x={[Fi.popupOpen]:""},Wx={[Fi.popupOpen]:"",[Fi.pressed]:""},Bx={[Pt.open]:""},$x={[Pt.closed]:""},Yx={[Pt.anchorHidden]:""},Hx={open(e){return e?_x:null}},Ux={open(e){return e?Wx:null}},os={open(e){return e?Bx:$x},anchorHidden(e){return e?Yx:null}};function vf(e){return ad(19)?e:e?"true":void 0}let bc={},xc={},vc="";function Gx(e){if(typeof document>"u")return!1;const t=$n(e);return vt(t).innerWidth-t.documentElement.clientWidth>0}function Kx(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=$n(e).documentElement,s={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY};r.style.scrollbarGutter="stable",r.style.overflowY="scroll";const o=r.offsetWidth;r.style.overflowY="hidden";const i=r.offsetWidth;return Object.assign(r.style,s),o===i}function zx(e){const t=$n(e),n=t.documentElement,r=t.body,s=rs(n)?n:r,o=s.style.overflow;return s.style.overflow="hidden",()=>{s.style.overflow=o}}function qx(e){const t=$n(e),n=t.documentElement,r=t.body,s=vt(n);let o=0,i=0,a=!1;const l=Vt.create();if(vy&&(s.visualViewport?.scale??1)!==1)return()=>{};function c(){const f=s.getComputedStyle(n),h=s.getComputedStyle(r),y=(f.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,bc={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},vc=n.style.scrollBehavior,xc={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const w=n.scrollHeight>n.clientHeight,x=n.scrollWidth>n.clientWidth,v=f.overflowY==="scroll"||h.overflowY==="scroll",k=f.overflowX==="scroll"||h.overflowX==="scroll",S=Math.max(0,s.innerWidth-r.clientWidth),C=Math.max(0,s.innerHeight-r.clientHeight),M=parseFloat(h.marginTop)+parseFloat(h.marginBottom),D=parseFloat(h.marginLeft)+parseFloat(h.marginRight),F=rs(n)?n:r;if(a=Kx(e),a){n.style.scrollbarGutter=y,F.style.overflowY="hidden",F.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:y,overflowY:"hidden",overflowX:"hidden"}),(w||v)&&(n.style.overflowY="scroll"),(x||k)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:M||C?`calc(100dvh - ${M+C}px)`:"100dvh",width:D||S?`calc(100vw - ${D+S}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,bc),Object.assign(r.style,xc),a||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=vc)}function d(){u(),l.request(c)}return c(),s.addEventListener("resize",d),()=>{l.cancel(),u(),typeof s.removeEventListener=="function"&&s.removeEventListener("resize",d)}}class Xx{lockCount=0;restore=null;timeoutLock=gn.create();timeoutUnlock=gn.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=$n(t).documentElement,s=vt(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ld;return}const o=vd||!Gx(t);this.restore=o?zx(t):qx(t)}}const Zx=new Xx;function wf(e=!0,t=null){Te(()=>{if(e)return Zx.acquire(t)},[e,t])}const Qx=m.createContext(void 0);function Jx(){return m.useContext(Qx)?.direction??"ltr"}const ev=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0,offsetParent:d="real"}=nn(e,t)||{};if(c==null)return{};const f=Ed(u),h={x:n,y:r},p=ma(s),g=ha(p),y=await i.getDimensions(c),w=p==="y",x=w?"top":"left",v=w?"bottom":"right",k=w?"clientHeight":"clientWidth",S=o.reference[g]+o.reference[p]-h[p]-o.floating[g],C=h[p]-o.reference[p],M=d==="real"?await i.getOffsetParent?.(c):a.floating;let D=a.floating[k]||o.floating[g];(!D||!await i.isElement?.(M))&&(D=a.floating[k]||o.floating[g]);const F=S/2-C/2,T=D/2-y[g]/2-1,R=Math.min(f[x],T),A=Math.min(f[v],T),E=R,j=D-y[g]-A,N=D/2-y[g]/2+F,V=Ri(E,N,j),U=!l.arrow&&xn(s)!=null&&N!==V&&o.reference[g]/2-(N<E?R:A)-y[g]/2<0,P=U?N<E?N-E:N-j:0;return{[p]:h[p]+P,data:{[p]:V,centerOffset:N-V-P,...U&&{alignmentOffset:P}},reset:U}}}),tv=(e,t)=>({...ev(e),options:[e,t]}),nv={name:"hide",async fn(e){const{width:t,height:n,x:r,y:s}=e.rects.reference,o=t===0&&n===0&&r===0&&s===0;return{data:{referenceHidden:(await gx().fn(e)).data?.referenceHidden||o}}}},js={sideX:"left",sideY:"top"},rv={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:s},platform:o,strategy:i,placement:a}=e,l=vt(s),c=l.getComputedStyle(s);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:t,y:n,data:js};const d=await o.getOffsetParent?.(s);let f={width:0,height:0};if(i==="fixed"&&l?.visualViewport)f={width:l.visualViewport.width,height:l.visualViewport.height};else if(d===l){const x=$n(s);f={width:x.documentElement.clientWidth,height:x.documentElement.clientHeight}}else await o.isElement?.(d)&&(f=await o.getDimensions(d));const h=it(a);let p=t,g=n;h==="left"&&(p=f.width-(t+r.width)),h==="top"&&(g=f.height-(n+r.height));const y=h==="left"?"right":js.sideX,w=h==="top"?"bottom":js.sideY;return{x:p,y:g,data:{sideX:y,sideY:w}}}};function kf(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function wc(e,t,n){const{rects:r,placement:s}=e;return{side:kf(t,it(s),n),align:xn(s)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function sv(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:s=0,align:o="center",alignOffset:i=0,collisionBoundary:a,collisionPadding:l=5,sticky:c=!1,arrowPadding:u=5,disableAnchorTracking:d=!1,keepMounted:f=!1,floatingRootContext:h,mounted:p,collisionAvoidance:g,shiftCrossAxis:y=!1,nodeId:w,adaptiveOrigin:x,lazyFlip:v=!1,externalTree:k}=e,[S,C]=m.useState(null);!p&&S!==null&&C(null);const M=g.side||"flip",D=g.align||"flip",F=g.fallbackAxisSide||"end",T=typeof t=="function"?t:void 0,R=he(T),A=T?R:t,E=Bt(t),N=Jx()==="rtl",V=S||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":N?"left":"right","inline-start":N?"right":"left"}[r],U=o==="center"?V:`${V}-${o}`;let P=l;const I=1,B=r==="bottom"?I:0,W=r==="top"?I:0,Q=r==="right"?I:0,Y=r==="left"?I:0;typeof P=="number"?P={top:P+B,right:P+Y,bottom:P+W,left:P+Q}:P&&(P={top:(P.top||0)+B,right:(P.right||0)+Y,bottom:(P.bottom||0)+W,left:(P.left||0)+Q});const $={boundary:a==="clipping-ancestors"?"clippingAncestors":a,padding:P},z=m.useRef(null),Z=Bt(s),ce=Bt(i),Ee=[dx(De=>{const Ye=wc(De,r,N),re=typeof Z.current=="function"?Z.current(Ye):Z.current,G=typeof ce.current=="function"?ce.current(Ye):ce.current;return{mainAxis:re,crossAxis:G,alignmentAxis:G}},[typeof s!="function"?s:0,typeof i!="function"?i:0,N,r])],Je=D==="none"&&M!=="shift",L=!Je&&(c||y||M==="shift"),ue=M==="none"?null:mx({...$,padding:{top:P.top+I,right:P.right+I,bottom:P.bottom+I,left:P.left+I},mainAxis:!y&&M==="flip",crossAxis:D==="flip"?"alignment":!1,fallbackAxisSideDirection:F}),te=Je?null:fx(De=>{const Ye=$n(De.elements.floating).documentElement;return{...$,rootBoundary:y?{x:0,y:0,width:Ye.clientWidth,height:Ye.clientHeight}:void 0,mainAxis:D!=="none",crossAxis:L,limiter:c||y?void 0:hx(re=>{if(!z.current)return{};const{width:G,height:oe}=z.current.getBoundingClientRect(),de=yt(it(re.placement)),xe=de==="y"?G:oe,fe=de==="y"?P.left+P.right:P.top+P.bottom;return{offset:xe/2+fe/2}})}},[$,c,y,P,D]);M==="shift"||D==="shift"||o==="center"?Ee.push(te,ue):Ee.push(ue,te),Ee.push(px({...$,apply({elements:{floating:De},rects:{reference:Ye},availableWidth:re,availableHeight:G}){Object.entries({"--available-width":`${re}px`,"--available-height":`${G}px`,"--anchor-width":`${Ye.width}px`,"--anchor-height":`${Ye.height}px`}).forEach(([oe,de])=>{De.style.setProperty(oe,de)})}}),tv(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(De){const{elements:Ye,middlewareData:re,placement:G,rects:oe,y:de}=De,xe=it(G),fe=yt(xe),It=z.current,wn=re.arrow?.x||0,kn=re.arrow?.y||0,ln=It?.clientWidth||0,cn=It?.clientHeight||0,zt=wn+ln/2,Er=kn+cn/2,Ft=Math.abs(re.shift?.y||0),tt=oe.reference.height/2,Sn=typeof s=="function"?s(wc(De,r,N)):s,ps=Ft>Sn,Co={top:`${zt}px calc(100% + ${Sn}px)`,bottom:`${zt}px ${-Sn}px`,left:`calc(100% + ${Sn}px) ${Er}px`,right:`${-Sn}px ${Er}px`}[xe],lt=`${zt}px ${oe.reference.y+tt-de}px`;return Ye.floating.style.setProperty("--transform-origin",L&&fe==="y"&&ps?lt:Co),{}}},nv,x),Te(()=>{!p&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[p,h]);const Me=m.useMemo(()=>({elementResize:!d&&typeof ResizeObserver<"u",layoutShift:!d&&typeof IntersectionObserver<"u"}),[d]),{refs:H,elements:se,x:ie,y:me,middlewareData:ge,update:J,placement:ne,context:Ie,isPositioned:be,floatingStyles:_e}=Mx({rootContext:h,placement:U,middleware:Ee,strategy:n,whileElementsMounted:f?void 0:(...De)=>mc(...De,Me),nodeId:w,externalTree:k}),{sideX:Ge,sideY:ot}=ge.adaptiveOrigin||js,Oe=be?n:"fixed",ye=m.useMemo(()=>x?{position:Oe,[Ge]:ie,[ot]:me}:{position:Oe,..._e},[x,Oe,Ge,ie,ot,me,_e]),Fe=m.useRef(null);Te(()=>{if(!p)return;const De=E.current,Ye=typeof De=="function"?De():De,G=(kc(Ye)?Ye.current:Ye)||null||null;G!==Fe.current&&(H.setPositionReference(G),Fe.current=G)},[p,H,A,E]),m.useEffect(()=>{if(!p)return;const De=E.current;typeof De!="function"&&kc(De)&&De.current!==Fe.current&&(H.setPositionReference(De.current),Fe.current=De.current)},[p,H,A,E]),m.useEffect(()=>{if(f&&p&&se.domReference&&se.floating)return mc(se.domReference,se.floating,J,Me)},[f,p,se,J,Me]);const $e=it(ne),Nt=kf(r,$e,N),kt=xn(ne)||"center",et=!!ge.hide?.referenceHidden;Te(()=>{v&&p&&be&&C($e)},[v,p,be,$e]);const an=m.useMemo(()=>({position:"absolute",top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),at=ge.arrow?.centerOffset!==0;return m.useMemo(()=>({positionerStyles:ye,arrowStyles:an,arrowRef:z,arrowUncentered:at,side:Nt,align:kt,physicalSide:$e,anchorHidden:et,refs:H,context:Ie,isPositioned:be,update:J}),[ye,an,z,at,Nt,kt,$e,et,H,Ie,be,J])}function kc(e){return e!=null&&"current"in e}const Sf=m.forwardRef(function(t,n){const{cutout:r,...s}=t;let o;if(r){const i=r?.getBoundingClientRect();o=`polygon(
|
|
1
|
+
import{r as m,u as bn,i as Ng,a as nt,g as Ig,b as yr,c as br,d as Wt,e as Ei,f as ks,h as fo,j as ia,k as cr,t as xt,l as _,T as Fg,m as b,n as Te,o as Bn,p as id,q as ad,s as he,N as ld,v as ts,w as ns,x as pn,y as Ve,z as Hr,E as Nn,A as jg,B as sn,C as Vl,D as ut,F as cd,G as vt,H as At,I as mn,J as or,K as Ae,L as on,M as _l,O as aa,P as la,Q as ur,R as In,S as Lg,U as ud,V as Vg,W as rs,X as ho,Y as dd,Z as _g,_ as fd,$ as Wg,a0 as hd,a1 as md,a2 as q,a3 as ca,a4 as pd,a5 as Bg,a6 as $g,a7 as Yg,a8 as Hg,a9 as Ug,aa as Gg,ab as Kg,ac as zg,ad as Qt,ae as qg,af as Xg,ag as Io}from"./main-DQ7YU0WX.js";import{g as Zg,a as ua,b as Qg,c as Jg,d as ey,e as Fo,f as ty,r as ny,h as Wl,i as ry,j as sy,t as oy,s as iy}from"./vibeusage-api-BkDJCLN3.js";const ay=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ly=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Bl=e=>{const t=ly(e);return t.charAt(0).toUpperCase()+t.slice(1)},gd=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),cy=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var uy={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const dy=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...a},l)=>m.createElement("svg",{ref:l,...uy,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:gd("lucide",s),...!o&&!cy(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,u])=>m.createElement(c,u)),...Array.isArray(o)?o:[o]]));const fy=(e,t)=>{const n=m.forwardRef(({className:r,...s},o)=>m.createElement(dy,{ref:o,iconNode:t,className:gd(`lucide-${ay(Bl(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Bl(e),n};const hy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],my=fy("info",hy),py=500,gy={style:{transition:"none"}},yd="data-base-ui-click-trigger",yy={fallbackAxisSide:"end"},by={clipPath:"inset(50%)",position:"fixed",top:0,left:0},xy=[];function da(e){m.useEffect(e,xy)}const Rr=0;class gn{static create(){return new gn}currentId=Rr;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Rr,n()},t)}isStarted(){return this.currentId!==Rr}clear=()=>{this.currentId!==Rr&&(clearTimeout(this.currentId),this.currentId=Rr)};disposeEffect=()=>this.clear}function Vn(){const e=bn(gn.create).current;return da(e.disposeEffect),e}function $n(e){return e?.ownerDocument||document}const xr=typeof navigator<"u",jo=Sy(),bd=Cy(),xd=Ty(),vy=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),vd=jo.platform==="MacIntel"&&jo.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(jo.platform),wy=xr&&/apple/i.test(navigator.vendor),Mi=xr&&/android/i.test(bd)||/android/i.test(xd);xr&&bd.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const ky=xd.includes("jsdom/");function Sy(){if(!xr)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function Ty(){if(!xr)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Cy(){if(!xr)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Di="data-base-ui-focusable",wd="active",kd="selected",Sd="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Qn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function we(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Ng(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function dt(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Ct(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Ey(e){return e.matches("html,body")}function qe(e){return e?.ownerDocument||document}function Td(e){return nt(e)&&e.matches(Sd)}function $l(e){return e?e.getAttribute("role")==="combobox"&&Td(e):!1}function Pi(e){return e?e.hasAttribute(Di)?e:e.querySelector(`[${Di}]`)||e:null}function Fn(e,t,n=!0){return e.filter(s=>s.parentId===t&&(!n||s.context?.open)).flatMap(s=>[s,...Fn(e,s.id,n)])}function Yl(e,t){let n=[],r=e.find(s=>s.id===t)?.parentId;for(;r;){const s=e.find(o=>o.id===r);r=s?.parentId,s&&(n=n.concat(s))}return n}function My(e){e.preventDefault(),e.stopPropagation()}function Dy(e){return"nativeEvent"in e}function Py(e){return e.mozInputSource===0&&e.isTrusted?!0:Mi&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Ry(e){return ky?!1:!Mi&&e.width===0&&e.height===0||Mi&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function dr(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Cd(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Oy=["top","right","bottom","left"],fr=Math.min,ft=Math.max,Gs=Math.round,Ss=Math.floor,Ht=e=>({x:e,y:e}),Ay={left:"right",right:"left",bottom:"top",top:"bottom"};function Ri(e,t,n){return ft(e,fr(t,n))}function nn(e,t){return typeof e=="function"?e(t):e}function it(e){return e.split("-")[0]}function xn(e){return e.split("-")[1]}function fa(e){return e==="x"?"y":"x"}function ha(e){return e==="y"?"height":"width"}function yt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ma(e){return fa(yt(e))}function Ny(e,t,n){n===void 0&&(n=!1);const r=xn(e),s=ma(e),o=ha(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=Ks(i)),[i,Ks(i)]}function Iy(e){const t=Ks(e);return[Oi(e),t,Oi(t)]}function Oi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Hl=["left","right"],Ul=["right","left"],Fy=["top","bottom"],jy=["bottom","top"];function Ly(e,t,n){switch(e){case"top":case"bottom":return n?t?Ul:Hl:t?Hl:Ul;case"left":case"right":return t?Fy:jy;default:return[]}}function Vy(e,t,n,r){const s=xn(e);let o=Ly(it(e),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),t&&(o=o.concat(o.map(Oi)))),o}function Ks(e){const t=it(e);return Ay[t]+e.slice(t.length)}function _y(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ed(e){return typeof e!="number"?_y(e):{top:e,right:e,bottom:e,left:e}}function zs(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}var Wy=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],qs=Wy.join(","),Md=typeof Element>"u",hr=Md?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Xs=!Md&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Zs=function(t,n){var r;n===void 0&&(n=!0);var s=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),o=s===""||s==="true",i=o||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Zs(t.parentNode));return i},By=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Dd=function(t,n,r){if(Zs(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(qs));return n&&hr.call(t,qs)&&s.unshift(t),s=s.filter(r),s},Qs=function(t,n,r){for(var s=[],o=Array.from(t);o.length;){var i=o.shift();if(!Zs(i,!1))if(i.tagName==="SLOT"){var a=i.assignedElements(),l=a.length?a:i.children,c=Qs(l,!0,r);r.flatten?s.push.apply(s,c):s.push({scopeParent:i,candidates:c})}else{var u=hr.call(i,qs);u&&r.filter(i)&&(n||!t.includes(i))&&s.push(i);var d=i.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(i),f=!Zs(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(i));if(d&&f){var h=Qs(d===!0?i.children:d.children,!0,r);r.flatten?s.push.apply(s,h):s.push({scopeParent:i,candidates:h})}else o.unshift.apply(o,i.children)}}return s},Pd=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Rd=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||By(t))&&!Pd(t)?0:t.tabIndex},$y=function(t,n){var r=Rd(t);return r<0&&n&&!Pd(t)?0:r},Yy=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Od=function(t){return t.tagName==="INPUT"},Hy=function(t){return Od(t)&&t.type==="hidden"},Uy=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},Gy=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},Ky=function(t){if(!t.name)return!0;var n=t.form||Xs(t),r=function(a){return n.querySelectorAll('input[type="radio"][name="'+a+'"]')},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(i){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",i.message),!1}var o=Gy(s,t.form);return!o||o===t},zy=function(t){return Od(t)&&t.type==="radio"},qy=function(t){return zy(t)&&!Ky(t)},Xy=function(t){var n,r=t&&Xs(t),s=(n=r)===null||n===void 0?void 0:n.host,o=!1;if(r&&r!==t){var i,a,l;for(o=!!((i=s)!==null&&i!==void 0&&(a=i.ownerDocument)!==null&&a!==void 0&&a.contains(s)||t!=null&&(l=t.ownerDocument)!==null&&l!==void 0&&l.contains(t));!o&&s;){var c,u,d;r=Xs(s),s=(c=r)===null||c===void 0?void 0:c.host,o=!!((u=s)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(s))}}return o},Gl=function(t){var n=t.getBoundingClientRect(),r=n.width,s=n.height;return r===0&&s===0},Zy=function(t,n){var r=n.displayCheck,s=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var o=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(t).visibility==="hidden")return!0;var i=hr.call(t,"details>summary:first-of-type"),a=i?t.parentElement:t;if(hr.call(a,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof s=="function"){for(var l=t;t;){var c=t.parentElement,u=Xs(t);if(c&&!c.shadowRoot&&s(c)===!0)return Gl(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(Xy(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Gl(t);return!1},Qy=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var s=n.children.item(r);if(s.tagName==="LEGEND")return hr.call(n,"fieldset[disabled] *")?!0:!s.contains(t)}return!0}n=n.parentElement}return!1},Ai=function(t,n){return!(n.disabled||Hy(n)||Zy(n,t)||Uy(n)||Qy(n))},Ni=function(t,n){return!(qy(n)||Rd(n)<0||!Ai(t,n))},Jy=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Ad=function(t){var n=[],r=[];return t.forEach(function(s,o){var i=!!s.scopeParent,a=i?s.scopeParent:s,l=$y(a,i),c=i?Ad(s.candidates):a;l===0?i?n.push.apply(n,c):n.push(a):r.push({documentOrder:o,tabIndex:l,item:s,isScope:i,content:c})}),r.sort(Yy).reduce(function(s,o){return o.isScope?s.push.apply(s,o.content):s.push(o.content),s},[]).concat(n)},ss=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Qs([t],n.includeContainer,{filter:Ni.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:Jy}):r=Dd(t,n.includeContainer,Ni.bind(null,n)),Ad(r)},eb=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Qs([t],n.includeContainer,{filter:Ai.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Dd(t,n.includeContainer,Ai.bind(null,n)),r},Nd=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return hr.call(t,qs)===!1?!1:Ni(n,t)};const vr=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Id(e,t){const n=ss(e,vr()),r=n.length;if(r===0)return;const s=Qn(qe(e)),o=n.indexOf(s),i=o===-1?t===1?0:r-1:o+t;return n[i]}function pa(e){return Id(qe(e).body,1)||e}function Fd(e){return Id(qe(e).body,-1)||e}function jd(e,t){if(!e)return null;const n=ss(qe(e).body,vr()),r=n.length;if(r===0)return null;const s=n.indexOf(e);if(s===-1)return null;const o=(s+t+r)%r;return n[o]}function tb(e){return jd(e,1)}function nb(e){return jd(e,-1)}function ir(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!we(n,r)}function rb(e){ss(e,vr()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Kl(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function sb({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:s="sun",cacheKey:o,timeZone:i,tzOffsetMinutes:a,now:l}={}){const c=m.useMemo(()=>Ig({weeks:r,weekStartsOn:s,now:l}),[l,r,s]),[u,d]=m.useState([]),[f,h]=m.useState(null),[p,g]=m.useState("edge"),[y,w]=m.useState(!1),[x,v]=m.useState(null),k=yr(),S=br(t),C=!n,M=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),D=m.useMemo(()=>{if(!o)return null;const j=fo({timeZone:i,offsetMinutes:a});return`vibeusage.heatmap.${o}.${r}.${s}.${j}`},[o,i,a,r,s]),F=m.useCallback(()=>{if(!D||typeof window>"u")return null;try{const j=window.localStorage.getItem(D);if(!j)return null;const N=JSON.parse(j);return!N||!N.heatmap?null:N}catch{return null}},[D]),T=m.useCallback(j=>{if(!(!D||typeof window>"u"))try{window.localStorage.setItem(D,JSON.stringify(j))}catch{}},[D]),R=m.useCallback(()=>{if(!(!D||typeof window>"u"))try{window.localStorage.removeItem(D)}catch{}},[D]),A=m.useCallback(async()=>{const j=await Wt(t);if(!(!j&&!k&&!M)){w(!0),v(null);try{try{const P=await Zg({baseUrl:e,accessToken:j,weeks:r,to:c.to,weekStartsOn:s,timeZone:i,tzOffsetMinutes:a}),I=Array.isArray(P?.weeks)?P.weeks:[];if(!I.length&&C){const W=F();if(W?.heatmap){h(W.heatmap),d(W.daily||[]),g("cache");return}}if(!I.some(W=>(Array.isArray(W)?W:[]).some(Q=>Q&&Number.isFinite(Number(Q.level))))&&I.length){const W=[];for(const Y of I)for(const $ of Array.isArray(Y)?Y:[])$?.day&&W.push({day:$.day,total_tokens:$.total_tokens??$.value??0,billable_total_tokens:$.billable_total_tokens??$.value??$.total_tokens??0});const Q=Ei({dailyRows:W,weeks:r,to:P?.to||c.to,weekStartsOn:s});d(W),h({...Q,week_starts_on:s,active_days:W.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:ks({dailyRows:W,to:P?.to||c.to})}),g("client"),C?T({heatmap:{...Q,week_starts_on:s,active_days:W.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:ks({dailyRows:W,to:P?.to||c.to})},daily:W,fetchedAt:new Date().toISOString()}):R();return}h(P||null),d([]),g("edge"),P&&C?T({heatmap:P,daily:[],fetchedAt:new Date().toISOString()}):C||R();return}catch(P){const I=P,B=I?.status??I?.statusCode;if(B===401||B===403)throw P}const N=await ua({baseUrl:e,accessToken:j,from:c.from,to:c.to,timeZone:i,tzOffsetMinutes:a}),V=Array.isArray(N?.data)?N.data:[];d(V);const U=Ei({dailyRows:V,weeks:r,to:c.to,weekStartsOn:s});h({...U,week_starts_on:s,active_days:V.filter(P=>Number(P?.billable_total_tokens??P?.total_tokens)>0).length,streak_days:ks({dailyRows:V,to:c.to})}),g("client"),C?T({heatmap:{...U,week_starts_on:s,active_days:V.filter(P=>Number(P?.billable_total_tokens??P?.total_tokens)>0).length,streak_days:ks({dailyRows:V,to:c.to})},daily:V,fetchedAt:new Date().toISOString()}):R()}catch(N){if(C){const V=F();if(V?.heatmap)h(V.heatmap),d(V.daily||[]),g("cache"),v(null);else{const U=N;v(U?.message||String(U)),d([]),h(null),g("edge")}}else{const V=N;v(V?.message||String(V)),d([]),h(null),g("edge")}}finally{w(!1)}}},[t,e,k,n,C,c.from,c.to,F,S,i,a,s,r,R,T,M]);return m.useEffect(()=>{if(!S&&!n&&!k&&!M){d([]),w(!1),v(null),h(null),g("edge");return}if(!C)R(),d([]),v(null),h(null),g("edge");else{const j=F();j?.heatmap&&(h(j.heatmap),d(j.daily||[]),g("cache"))}A()},[t,k,F,A,S,n,C,R,M]),{range:c,daily:u,heatmap:f,source:k?"mock":p==="client"?"edge":p,loading:y,error:x,refresh:A}}function ob({baseUrl:e,accessToken:t,limit:n=3,from:r,to:s,source:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=m.useState([]),[u,d]=m.useState(!1),[f,h]=m.useState(null),p=yr(),g=br(t),y=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),w=m.useCallback(async()=>{const x=await Wt(t);if(!x&&!p&&!y){c([]),h(null),d(!1);return}d(!0),h(null);try{const v=await Qg({baseUrl:e,accessToken:x,limit:n,from:r,to:s,source:o,timeZone:i,tzOffsetMinutes:a});c(Array.isArray(v?.entries)?v.entries:[])}catch(v){const k=v?.message||String(v);h(k),c([])}finally{d(!1)}},[t,e,r,n,p,o,i,s,a,y]);return m.useEffect(()=>{if(!g&&!p&&!y){c([]),h(null),d(!1);return}w()},[p,w,g,y]),{entries:l,loading:u,error:f,refresh:w}}const ib=24;function ab({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:s,to:o,months:i=ib,cacheKey:a,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:d,sharedRange:f}={}){const[h,p]=m.useState([]),[g,y]=m.useState(()=>({from:s,to:o})),[w,x]=m.useState("edge"),[v,k]=m.useState(null),[S,C]=m.useState(!1),[M,D]=m.useState(null),F=yr(),T=br(t),R=!n,A=Array.isArray(d),E=f?.from||s,j=f?.to||o,N=m.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),V=(()=>{if(!a)return null;const Y=lb(e)||"default",$=fo({timeZone:l,offsetMinutes:c});if(N==="hourly")return`vibeusage.trend.${a}.${Y}.hourly.${o||s||"day"}.${$}`;if(N==="monthly")return`vibeusage.trend.${a}.${Y}.monthly.${i}.${o||"today"}.${$}`;const z=`${s||""}.${o||""}`;return`vibeusage.trend.${a}.${Y}.daily.${z}.${$}`})(),U=m.useCallback(()=>{if(!V||typeof window>"u")return null;try{const Y=window.localStorage.getItem(V);if(!Y)return null;const $=JSON.parse(Y);return!$||!Array.isArray($.rows)?null:$}catch{return null}},[V]),P=m.useCallback(Y=>{if(!(!V||typeof window>"u"))try{window.localStorage.setItem(V,JSON.stringify(Y))}catch{}},[V]),I=m.useCallback(()=>{if(!(!V||typeof window>"u"))try{window.localStorage.removeItem(V)}catch{}},[V]),B=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),W=m.useCallback(async()=>{if(A){p(Array.isArray(d)?d:[]),y({from:E,to:j}),x("shared"),k(null),C(!1),D(null);return}const Y=await Wt(t);if(!(!Y&&!F&&!B)){C(!0),D(null);try{let $;N==="hourly"?$=await Jg({baseUrl:e,accessToken:Y,day:o||s,timeZone:l,tzOffsetMinutes:c}):N==="monthly"?$=await ey({baseUrl:e,accessToken:Y,months:i,to:o,timeZone:l,tzOffsetMinutes:c}):$=await ua({baseUrl:e,accessToken:Y,from:s,to:o,timeZone:l,tzOffsetMinutes:c});const z=$?.from||s||$?.day||null,Z=$?.to||o||$?.day||null;let ce=Array.isArray($?.data)?$.data:[];N==="daily"?ce=Vo(ce,z||s,Z||o,{timeZone:l,offsetMinutes:c,now:u}):N==="hourly"?ce=_o(ce,{timeZone:l,offsetMinutes:c,now:u}):N==="monthly"&&(ce=Wo(ce,{timeZone:l,offsetMinutes:c,now:u}));const Se=new Date().toISOString();p(ce),y({from:z,to:Z}),x("edge"),k(Se),R?P({rows:ce,from:z,to:Z,mode:N,fetchedAt:Se}):I()}catch($){if(R){const z=U();if(z?.rows){let Z=N==="daily"?Vo(z.rows||[],z.from||s,z.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(z.rows)?z.rows:[];N==="hourly"?Z=_o(Z,{timeZone:l,offsetMinutes:c,now:u}):N==="monthly"&&(Z=Wo(Z,{timeZone:l,offsetMinutes:c,now:u})),p(Z),y({from:z.from||s,to:z.to||o}),x("cache"),k(z.fetchedAt||null),D(null)}else{p([]),y({from:s,to:o}),x("edge"),k(null);const Z=$;D(Z?.message||String(Z))}}else{p([]),y({from:s,to:o}),x("edge"),k(null);const z=$;D(z?.message||String(z))}}finally{C(!1)}}},[t,e,s,F,n,R,N,i,U,T,A,E,d,j,l,o,c,u,I,P,B]);m.useEffect(()=>{if(A){p(Array.isArray(d)?d:[]),y({from:E,to:j}),x("shared"),k(null),C(!1),D(null);return}if(!T&&!n&&!F&&!B){p([]),y({from:s,to:o}),D(null),C(!1),x("edge"),k(null);return}if(!R)I(),p([]),y({from:s,to:o}),D(null),x("edge"),k(null);else{const Y=U();if(Y?.rows){let $=N==="daily"?Vo(Y.rows||[],Y.from||s,Y.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(Y.rows)?Y.rows:[];N==="hourly"?$=_o($,{timeZone:l,offsetMinutes:c,now:u}):N==="monthly"&&($=Wo($,{timeZone:l,offsetMinutes:c,now:u})),p($),y({from:Y.from||s,to:Y.to||o}),x("cache"),k(Y.fetchedAt||null)}}W()},[t,F,U,W,A,E,d,j,T,n,R,I,B]);const Q=F?"mock":w;return{rows:h,from:g.from||s,to:g.to||o,source:Q,fetchedAt:v,loading:S,error:M,refresh:W}}function lb(e){try{return new URL(e).host}catch{return null}}function Lo(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),s=Number(n[1])-1,o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(r,s,o));return Number.isFinite(i.getTime())&&cr(i)===t?i:null}function cb(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Vo(e,t,n,{timeZone:r,offsetMinutes:s,now:o}={}){const i=Lo(t),a=Lo(n);if(!i||!a||a<i)return Array.isArray(e)?e:[];const l=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,c=ia({timeZone:r,offsetMinutes:s,date:l}),u=Lo(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const h=[];for(let p=i;p<=a;p=cb(p,1)){const g=cr(p),y=f.get(g),w=p.getTime()>d;if(y){h.push({...y,missing:!1,future:w});continue}h.push({day:g,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return h}function _o(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Ld({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.hour||o?.label||"",a=ub(i);if(!a)return{...o,future:!1};const l=a.dayNum>s.dayNum||a.dayNum===s.dayNum&&a.slot>s.slot;return{...o,future:l}}):e}function Wo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Ld({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.month||o?.label||"",a=db(i);if(!a)return{...o,future:!1};const l=a.year>s.year||a.year===s.year&&a.month>s.month;return{...o,future:l}}):e}function Ld({timeZone:e,offsetMinutes:t,now:n}={}){const r=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const f=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(r).reduce((x,v)=>(v.type&&v.value&&(x[v.type]=v.value),x),{}),h=Number(f.year),p=Number(f.month),g=Number(f.day),y=Number(f.hour),w=Number(f.minute);if(Number.isFinite(h)&&Number.isFinite(p)&&Number.isFinite(g)&&Number.isFinite(y)&&Number.isFinite(w)){const x=y*2+(w>=30?1:0);return{year:h,month:p,day:g,hour:y,minute:w,dayNum:h*1e4+p*100+g,slot:x}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),d=u.getUTCFullYear(),f=u.getUTCMonth()+1,h=u.getUTCDate(),p=u.getUTCHours(),g=u.getUTCMinutes(),y=p*2+(g>=30?1:0);return{year:d,month:f,day:h,hour:p,minute:g,dayNum:d*1e4+f*100+h,slot:y}}const s=r.getFullYear(),o=r.getMonth()+1,i=r.getDate(),a=r.getHours(),l=r.getMinutes(),c=a*2+(l>=30?1:0);return{year:s,month:o,day:i,hour:a,minute:l,dayNum:s*1e4+o*100+i,slot:c}}function ub(e){if(!e)return null;const t=String(e).trim(),[n,r]=t.split("T");if(!n||!r)return null;const s=n.split("-");if(s.length!==3)return null;const o=Number(s[0]),i=Number(s[1]),a=Number(s[2]);if(!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(a))return null;const l=r.split(":"),c=Number(l[0]),u=Number(l[1]);if(!Number.isFinite(c)||c<0||c>23||!Number.isFinite(u)||u<0||u>59)return null;const d=c*2+(u>=30?1:0);return{dayNum:o*1e4+i*100+a,slot:d}}function db(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const r=Number(n[0]),s=Number(n[1]);return!Number.isFinite(r)||!Number.isFinite(s)||s<1||s>12?null:{year:r,month:s}}function zl({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:s,includeDaily:o=!0,cacheKey:i,timeZone:a,tzOffsetMinutes:l,now:c}={}){const[u,d]=m.useState([]),[f,h]=m.useState(null),[p,g]=m.useState(null),[y,w]=m.useState("edge"),[x,v]=m.useState(null),[k,S]=m.useState(!1),[C,M]=m.useState(null),D=yr(),F=br(t),T=!n,R=(()=>{if(!i)return null;const P=fb(e)||"default",I=o?"daily":"summary",B=fo({timeZone:a,offsetMinutes:l});return`vibeusage.usage.${i}.${P}.${r}.${s}.${I}.${B}`})(),A=m.useCallback(()=>{if(!R||typeof window>"u")return null;try{const P=window.localStorage.getItem(R);if(!P)return null;const I=JSON.parse(P);return!I||!I.summary?null:I}catch{return null}},[R]),E=m.useCallback(P=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(P))}catch{}},[R]),j=m.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),N=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),V=m.useCallback(async()=>{const P=await Wt(t);if(!(!P&&!D&&!N)){S(!0),M(null);try{let I=null,B=null;if(o){const[z,Z]=await Promise.allSettled([ua({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l}),Fo({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0})]);if(z.status==="rejected")throw z.reason;I=z.value,B=Z.status==="fulfilled"?Z.value:null}else B=await Fo({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0});let W=o&&Array.isArray(I?.data)?I.data:[];o&&(W=$o(W,r,s,{timeZone:a,offsetMinutes:l,now:c}));let Q=B?.totals||I?.summary?.totals||null,Y=B?.rolling||I?.summary?.rolling||null;if(o&&!Q&&!B)try{const z=await Fo({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0});Q=z?.totals||null,Y=z?.rolling||Y}catch{}const $=new Date().toISOString();d(W),h(Q),g(Y),w("edge"),v($),Q&&T?E({summary:Q,rolling:Y,daily:W,from:r,to:s,includeDaily:o,fetchedAt:$}):T||j()}catch(I){if(T){const B=A();if(B?.summary){h(B.summary),g(B.rolling||null);const W=Array.isArray(B.daily)?B.daily:[],Q=o?$o(W,B.from||r,B.to||s,{timeZone:a,offsetMinutes:l,now:c}):W;d(Q),w("cache"),v(B.fetchedAt||null),M(null)}else{const W=I;M(W?.message||String(W)),d([]),h(null),g(null),w("edge"),v(null)}}else{const B=I;M(B?.message||String(B)),d([]),h(null),g(null),w("edge"),v(null)}}finally{S(!1)}}},[t,e,r,o,D,n,T,c,A,F,a,s,l,j,E,N]);return m.useEffect(()=>{const P=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!F&&!n&&!D&&!P){d([]),h(null),g(null),M(null),S(!1),w("edge"),v(null);return}if(!T)j(),d([]),h(null),g(null),M(null),w("edge"),v(null);else{const I=A();if(I?.summary){h(I.summary),g(I.rolling||null);const B=Array.isArray(I.daily)?I.daily:[],W=o?$o(B,I.from||r,I.to||s,{timeZone:a,offsetMinutes:l,now:c}):B;d(W),w("cache"),v(I.fetchedAt||null)}}V()},[t,D,A,V,F,n,T,j,N]),{daily:u,summary:f,rolling:p,source:D?"mock":y,fetchedAt:x,loading:k,error:C,refresh:V}}function fb(e){try{return new URL(e).host}catch{return null}}function Bo(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),s=Number(n[1])-1,o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(r,s,o));return Number.isFinite(i.getTime())&&cr(i)===t?i:null}function hb(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function $o(e,t,n,{timeZone:r,offsetMinutes:s,now:o}={}){const i=Bo(t),a=Bo(n);if(!i||!a||a<i)return Array.isArray(e)?e:[];const l=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,c=ia({timeZone:r,offsetMinutes:s,date:l}),u=Bo(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const h=[];for(let p=i;p<=a;p=hb(p,1)){const g=cr(p),y=f.get(g),w=p.getTime()>d;if(y){h.push({...y,missing:!1,future:w});continue}h.push({day:g,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return h}function mb({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:s,cacheKey:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=m.useState(null),[u,d]=m.useState("edge"),[f,h]=m.useState(!1),[p,g]=m.useState(null),y=yr(),w=br(t),x=!n,v=m.useMemo(()=>{if(!o)return null;const T=pb(e)||"default",R=fo({timeZone:i,offsetMinutes:a});return`vibeusage.modelBreakdown.${o}.${T}.${r}.${s}.${R}`},[e,o,r,i,s,a]),k=m.useCallback(()=>{if(!v||typeof window>"u")return null;try{const T=window.localStorage.getItem(v);if(!T)return null;const R=JSON.parse(T);return!R||!R.breakdown?null:R}catch{return null}},[v]),S=m.useCallback(T=>{if(!(!v||typeof window>"u"))try{window.localStorage.setItem(v,JSON.stringify(T))}catch{}},[v]),C=m.useCallback(()=>{if(!(!v||typeof window>"u"))try{window.localStorage.removeItem(v)}catch{}},[v]),M=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),D=m.useCallback(async()=>{const T=await Wt(t);if(!(!T&&!y&&!M)){h(!0),g(null);try{const R=await ty({baseUrl:e,accessToken:T,from:r,to:s,timeZone:i,tzOffsetMinutes:a});c(R||null),d("edge"),R&&x?S({breakdown:R,fetchedAt:new Date().toISOString()}):x||C()}catch(R){if(x){const A=k();if(A?.breakdown)c(A.breakdown),d("cache"),g(null);else{c(null),d("edge");const E=R;g(E?.message||String(E))}}else{c(null),d("edge");const A=R;g(A?.message||String(A))}}finally{h(!1)}}},[t,e,r,y,n,x,k,i,s,w,a,C,S,M]);return m.useEffect(()=>{if(!w&&!n&&!y&&!M){c(null),d("edge"),g(null),h(!1);return}if(!x)C(),c(null),d("edge"),g(null);else{const T=k();T?.breakdown&&(c(T.breakdown),d("cache"))}D()},[t,y,k,D,w,n,x,C,M]),{breakdown:l,source:y?"mock":u,loading:f,error:p,refresh:D}}function pb(e){try{return new URL(e).host}catch{return null}}const Vd=new Set(["day","hour","month"]);function gb(e){return Vd.has(e)}function ql(e){if(e==null)return null;const t=String(e).trim();if(!/^[0-9]+$/.test(t))return null;const n=t.replace(/^0+/,"");return n.length===0?"0":n}function yb(e,t){const n=ql(e),r=ql(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const s=xt(e),o=xt(t);return s==null&&o==null?0:s==null?1:o==null?-1:s===o?0:s<o?-1:1}function bb(e,t){const n=typeof e=="string"?e:String(e||""),r=typeof t=="string"?t:String(t||"");return n===r?0:n<r?-1:1}function xb(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),s=Number(n[2]),o=Number(n[3]);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(r,s-1,o));return!Number.isFinite(i.getTime())||i.getUTCFullYear()!==r||i.getUTCMonth()+1!==s||i.getUTCDate()!==o?null:i.getTime()}function vb(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(s)||s<1||s>12)return null;const o=new Date(Date.UTC(r,s-1,1));return Number.isFinite(o.getTime())?o.getTime():null}function wb(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!n)return null;const r=Number(n[1]),s=Number(n[2]),o=Number(n[3]),i=Number(n[4]),a=Number(n[5]),l=Number(n[6]||0);if(!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(a)||!Number.isFinite(l)||s<1||s>12||o<1||o>31||i<0||i>23||a<0||a>59||l<0||l>59)return null;const c=new Date(Date.UTC(r,s-1,o,i,a,l));return Number.isFinite(c.getTime())?c.getTime():null}function kb(e,t,n){const r=n==="hour"?wb:n==="month"?vb:xb,s=r(e),o=r(t);return s!=null&&o!=null?s===o?0:s<o?-1:1:bb(e,t)}function _d(e,{key:t,dir:n}){const r=n==="asc"?1:-1,s=Array.isArray(e)?e:[],o=Vd.has(t)?(a,l)=>kb(a,l,t):yb,i=a=>t==="total_tokens"&&a?.billable_total_tokens!=null?a.billable_total_tokens:a?.[t];return s.map((a,l)=>({row:a,index:l})).sort((a,l)=>{const c=i(a.row),u=i(l.row),d=c==null,f=u==null;if(d&&f)return a.index-l.index;if(d)return 1;if(f)return-1;const h=o(c,u);return h!==0?h*r:a.index-l.index}).map(a=>a.row)}const Sb=[{key:"day",label:_("daily.sort.date.label"),title:_("daily.sort.date.title")},{key:"total_tokens",label:_("daily.sort.total.label"),title:_("daily.sort.total.title")},{key:"input_tokens",label:_("daily.sort.input.label"),title:_("daily.sort.input.title")},{key:"output_tokens",label:_("daily.sort.output.label"),title:_("daily.sort.output.title")},{key:"cached_input_tokens",label:_("daily.sort.cached.label"),title:_("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:_("daily.sort.reasoning.label"),title:_("daily.sort.reasoning.title")},{key:"conversation_count",label:_("daily.sort.conversations.label"),title:_("daily.sort.conversations.title")}];function Xl(e){const t=gb(e)?e:"day";return Sb.map((n,r)=>r===0?{...n,key:t}:n)}function Zl(e,{key:t,dir:n}){return _d(e,{key:t,dir:n})}const Js=12,Tb=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Cb(e){if(typeof e=="bigint")return e!==0n;if(typeof e=="number")return Number.isFinite(e)&&e!==0;if(e==null)return!1;const t=String(e).trim();if(!t||!/^-?\d+$/.test(t))return!1;const n=t.startsWith("-")?t.slice(1):t;return/[1-9]/.test(n)}function Eb(e){return Tb.some(t=>Cb(e?.[t]))}function Mb(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=_d(t,{key:"month",dir:"asc"}),r=n.findIndex(s=>s?.month&&Eb(s));return r===-1?t:n.slice(r)}function Db(e,t,n=Js){const r=Array.isArray(e)?e:[],s=Number.isFinite(n)&&n>0?n:Js,i=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*s;return r.slice(i,i+s)}function Pb({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:r,heatmapLoading:s,activeDays:o,hasActiveDeviceToken:i}={}){return e||t?!1:n?!0:r&&!s&&o===0&&!i}function Wd(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Rb(e){const t=Wd(e?.model_id);return t||null}function Bd(e,t){return e?.model?String(e.model):t}function Ob(e,{copyFn:t}={}){const n=typeof t=="function"?t:i=>i,s=(Array.isArray(e?.sources)?e.sources:[]).map(i=>{const a=xt(i?.totals?.billable_total_tokens??i?.totals?.total_tokens)??0,l=xt(i?.totals?.total_cost_usd)??0;return{source:i?.source,totalTokens:Number.isFinite(a)?a:0,totalCost:Number.isFinite(l)?l:0,models:Array.isArray(i?.models)?i.models:[]}}).filter(i=>i.totalTokens>0);if(!s.length)return[];const o=s.reduce((i,a)=>i+a.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),s.slice().sort((i,a)=>a.totalTokens-i.totalTokens).map(i=>{const a=i.source?String(i.source).toUpperCase():n("shared.placeholder.short"),l=o>0?i.totalTokens/o*100:0,c=Number.isFinite(l)?l.toFixed(1):"0.0",u=i.models.map(d=>{const f=xt(d?.totals?.billable_total_tokens??d?.totals?.total_tokens)??0;if(!Number.isFinite(f)||f<=0)return null;const h=i.totalTokens>0?Math.round(f/i.totalTokens*1e3)/10:0,p=Bd(d,n("shared.placeholder.short")),g=Rb(d),y=i.totalCost>0&&i.totalTokens>0?f/i.totalTokens*i.totalCost:null;return{id:g,name:p,share:h,usage:f,cost:y}}).filter(Boolean);return{label:a,totalPercent:String(c),usd:i.totalCost,usage:i.totalTokens,models:u}})}function Ab(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:f=>f,s=Array.isArray(e?.sources)?e.sources:[];if(!s.length)return[];const o=new Map,i=new Map,a=new Map;let l=0;for(const f of s){const h=Array.isArray(f?.models)?f.models:[];for(const p of h){const g=xt(p?.totals?.billable_total_tokens)??0;if(!Number.isFinite(g)||g<=0)continue;l+=g;const y=Bd(p,r("shared.placeholder.short")),w=Wd(y);if(!w)continue;o.set(w,(o.get(w)||0)+g);const x=a.get(w)||0;g>=x&&(a.set(w,g),i.set(w,y))}}if(!o.size)return[];const c=Array.from(o.values()).reduce((f,h)=>f+h,0),u=l>0?l:c,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(o.entries()).map(([f,h])=>{const p=u>0?(h/u*100).toFixed(1):"0.0";return{id:f,name:i.get(f)||r("shared.placeholder.short"),tokens:h,percent:String(p)}}).sort((f,h)=>h.tokens!==f.tokens?h.tokens-f.tokens:String(f.name).localeCompare(String(h.name))).slice(0,d)}function ga(){const e=m.useContext(Fg);if(e===null)throw new Error("useTheme must be used within a ThemeProvider");return e}const En=12,Or=3,Yo=26,Nb=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],Ib=["#064e3b","#065f46","#059669","#10b981","#34d399"],Fb=[_("heatmap.month.jan"),_("heatmap.month.feb"),_("heatmap.month.mar"),_("heatmap.month.apr"),_("heatmap.month.may"),_("heatmap.month.jun"),_("heatmap.month.jul"),_("heatmap.month.aug"),_("heatmap.month.sep"),_("heatmap.month.oct"),_("heatmap.month.nov"),_("heatmap.month.dec")];function jb(e){if(typeof e=="bigint")return e.toLocaleString();if(typeof e=="number")return Number.isFinite(e)?Math.round(e).toLocaleString():"0";if(typeof e=="string"){const t=Number(e);return Number.isFinite(t)?Math.round(t).toLocaleString():e}return"0"}function Lb(e){if(typeof e!="string")return null;const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;const n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return Number.isFinite(n.getTime())?n:null}function $d(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Vb(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function _b(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return $d(e,-((r-n+7)%7))}function Wb(e,t,n){if(!e)return[];const r=Lb(t)||new Date,s=[];for(let c=11;c>=0;c-=1)s.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-c,1)));const o=_b(r,n),i=$d(o,-(e-1)*7),a=[],l=new Set;for(const c of s){const u=Math.floor(Vb(i,c)/7);u<0||u>=e||l.has(u)||(l.add(u),a.push({label:Fb[c.getUTCMonth()],index:u}))}return a}function Bb({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:s}=ga(),i=s==="dark"?Ib:Nb,a=m.useRef(null);m.useEffect(()=>{const p=a.current;p&&(p.scrollLeft=p.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=m.useMemo(()=>{const p=Array.isArray(e?.weeks)?e.weeks:[];if(!p.length)return{weeks:[]};const g=[];for(const y of p)for(const w of Array.isArray(y)?y:[])w?.day&&g.push({day:w.day,total_tokens:w.total_tokens??w.value??0,billable_total_tokens:w.billable_total_tokens??w.value??w.total_tokens??0});return Ei({dailyRows:g,weeks:Math.max(52,p.length),to:e?.to,weekStartsOn:l})},[e?.to,e?.weeks,l]),u=c?.weeks||[],d=l==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(p=>_(`heatmap.day.${p.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(p=>_(`heatmap.day.${p.toLowerCase()}`)),f=m.useMemo(()=>Wb(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return b.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:_("heatmap.empty")});const h=Yo+u.length*En+Math.max(0,u.length-1)*Or;return b.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[b.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[b.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:_("heatmap.title")}),b.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||_("heatmap.legend.utc")})]}),b.jsx("div",{ref:a,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:b.jsxs("div",{style:{minWidth:h},children:[b.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${Yo}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[b.jsx("span",{}),f.map(p=>b.jsx("span",{style:{gridColumnStart:p.index+2},className:"whitespace-nowrap",children:p.label},`${p.label}-${p.index}`))]}),b.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${Yo}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[b.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${En}px)`,rowGap:Or},children:d.map(p=>b.jsx("span",{className:"leading-none",children:p},p))}),b.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${En}px)`,gap:Or},children:u.map((p,g)=>(Array.isArray(p)?p:[]).map((y,w)=>{if(!y)return null;const x=y.day||`e-${g}-${w}`,v=Number(y.level)||0,k=i[v]||i[0],S=t||n||_("heatmap.legend.utc");return b.jsx("span",{title:_("heatmap.tooltip",{day:y.day,value:jb(y.value),unit:_("heatmap.unit.tokens"),tz:S}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:En,height:En,background:k}},x)}))})]})]})}),!r&&b.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[b.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.less")}),b.jsx("div",{className:"flex gap-0.5",children:i.map((p,g)=>b.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:p}},g))}),b.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.more")})]})]})}const $b={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Yd={...$b,position:"fixed",top:0,left:0};function Bt(e){const t=bn(Yb,e).current;return t.next=e,Te(t.effect),t}function Yb(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var eo=Symbol("NOT_FOUND");function Hb(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Ub(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function Gb(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var Ql=e=>Array.isArray(e)?e:[e];function Kb(e){const t=Array.isArray(e[0])?e[0]:e;return Gb(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function zb(e,t){const n=[],{length:r}=e;for(let s=0;s<r;s++)n.push(e[s].apply(null,t));return n}function qb(e){let t;return{get(n){return t&&e(t.key,n)?t.value:eo},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function Xb(e,t){let n=[];function r(a){const l=n.findIndex(c=>t(a,c.key));if(l>-1){const c=n[l];return l>0&&(n.splice(l,1),n.unshift(c)),c.value}return eo}function s(a,l){r(a)===eo&&(n.unshift({key:a,value:l}),n.length>e&&n.pop())}function o(){return n}function i(){n=[]}return{get:r,put:s,getEntries:o,clear:i}}var Zb=(e,t)=>e===t;function Qb(e){return function(n,r){if(n===null||r===null||n.length!==r.length)return!1;const{length:s}=n;for(let o=0;o<s;o++)if(!e(n[o],r[o]))return!1;return!0}}function Jb(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=Zb,maxSize:s=1,resultEqualityCheck:o}=n,i=Qb(r);let a=0;const l=s<=1?qb(i):Xb(s,i);function c(){let u=l.get(arguments);if(u===eo){if(u=e.apply(null,arguments),a++,o){const f=l.getEntries().find(h=>o(h.value,u));f&&(u=f.value,a!==0&&a--)}l.put(arguments,u)}return u}return c.clearCache=()=>{l.clear(),c.resetResultsCount()},c.resultsCount=()=>a,c.resetResultsCount=()=>{a=0},c}var e0=class{constructor(e){this.value=e}deref(){return this.value}},t0=typeof WeakRef<"u"?WeakRef:e0,n0=0,Jl=1;function Ts(){return{s:n0,v:void 0,o:null,p:null}}function Hd(e,t={}){let n=Ts();const{resultEqualityCheck:r}=t;let s,o=0;function i(){let a=n;const{length:l}=arguments;for(let d=0,f=l;d<f;d++){const h=arguments[d];if(typeof h=="function"||typeof h=="object"&&h!==null){let p=a.o;p===null&&(a.o=p=new WeakMap);const g=p.get(h);g===void 0?(a=Ts(),p.set(h,a)):a=g}else{let p=a.p;p===null&&(a.p=p=new Map);const g=p.get(h);g===void 0?(a=Ts(),p.set(h,a)):a=g}}const c=a;let u;if(a.s===Jl)u=a.v;else if(u=e.apply(null,arguments),o++,r){const d=s?.deref?.()??s;d!=null&&r(d,u)&&(u=d,o!==0&&o--),s=typeof u=="object"&&u!==null||typeof u=="function"?new t0(u):u}return c.s=Jl,c.v=u,u}return i.clearCache=()=>{n=Ts(),i.resetResultsCount()},i.resultsCount=()=>o,i.resetResultsCount=()=>{o=0},i}function Ud(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...s)=>{let o=0,i=0,a,l={},c=s.pop();typeof c=="object"&&(l=c,c=s.pop()),Hb(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:d,memoizeOptions:f=[],argsMemoize:h=Hd,argsMemoizeOptions:p=[]}=u,g=Ql(f),y=Ql(p),w=Kb(s),x=d(function(){return o++,c.apply(null,arguments)},...g),v=h(function(){i++;const S=zb(w,arguments);return a=x.apply(null,S),a},...y);return Object.assign(v,{resultFunc:c,memoizedResultFunc:x,dependencies:w,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>a,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:d,argsMemoize:h})};return Object.assign(r,{withTypes:()=>r}),r}var r0=Ud(Hd),s0=Object.assign((e,t=r0)=>{Ub(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(o=>e[o]);return t(r,(...o)=>o.reduce((i,a,l)=>(i[n[l]]=a,i),{}))},{withTypes:()=>s0});Ud({memoize:Jb,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const pe=(e,t,n,r,s,o,...i)=>{if(i.length>0)throw new Error(Bn(1));let a;if(e)a=e;else throw new Error("Missing arguments");return a};var Ho={exports:{}},Uo={};var ec;function o0(){if(ec)return Uo;ec=1;var e=id();function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function a(d,f){var h=f(),p=r({inst:{value:h,getSnapshot:f}}),g=p[0].inst,y=p[1];return o(function(){g.value=h,g.getSnapshot=f,l(g)&&y({inst:g})},[d,h,f]),s(function(){return l(g)&&y({inst:g}),d(function(){l(g)&&y({inst:g})})},[d]),i(h),h}function l(d){var f=d.getSnapshot;d=d.value;try{var h=f();return!n(d,h)}catch{return!0}}function c(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Uo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Uo}var tc;function Gd(){return tc||(tc=1,Ho.exports=o0()),Ho.exports}var i0=Gd(),Go={exports:{}},Ko={};var nc;function a0(){if(nc)return Ko;nc=1;var e=id(),t=Gd();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;return Ko.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var p=o(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=a(function(){function w(C){if(!x){if(x=!0,v=C,C=f(C),h!==void 0&&g.hasValue){var M=g.value;if(h(M,C))return k=M}return k=C}if(M=k,r(v,C))return M;var D=f(C);return h!==void 0&&h(M,D)?(v=C,M):(v=C,k=D)}var x=!1,v,k,S=d===void 0?null:d;return[function(){return w(u())},S===null?void 0:function(){return w(S())}]},[u,d,f,h]);var y=s(c,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=y},[y]),l(y),y},Ko}var rc;function l0(){return rc||(rc=1,Go.exports=a0()),Go.exports}var c0=l0();const u0=ad(19),d0=u0?h0:m0;function f0(e,t,n,r,s){return d0(e,t,n,r,s)}function h0(e,t,n,r,s){const o=m.useCallback(()=>t(e.getSnapshot(),n,r,s),[e,t,n,r,s]);return i0.useSyncExternalStore(e.subscribe,o,o)}function m0(e,t,n,r,s){return c0.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,r,s))}class Vr{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){Vr.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Vr.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Vr.prototype.setState.call(this,t)}}class ya extends Vr{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){m.useDebugValue(t),Te(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Te(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this,r=Object.values(t);Te(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){m.useDebugValue(t);const s=this,o=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,o),!o&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})),Te(()=>{o&&!Object.is(s.state[t],n)&&super.setState({...s.state,[t]:n})},[s,t,n,r,o])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.update(n)}setState(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.setState({...this.state,...n})}select=(t,n,r,s)=>{const o=this.selectors[t];return o(this.state,n,r,s)};useState=(t,n,r,s)=>{m.useDebugValue(t);const o=this.selectors[t];return f0(this,o,n,r,s)};useContextCallback(t,n){m.useDebugValue(t);const r=he(n??ld);this.context[t]=r}useStateSetter(t){const n=m.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let s=r(this.state);return n(s,s,this),this.subscribe(o=>{const i=r(o);if(!Object.is(s,i)){const a=s;s=i,n(i,a,this)}})}}const Cs=null;class p0{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s<n.length;s+=1)n[s]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Es=new p0;class Vt{static create(){return new Vt}static request(t){return Es.request(t)}static cancel(t){return Es.cancel(t)}currentId=Cs;request(t){this.cancel(),this.currentId=Es.request(()=>{this.currentId=Cs,t()})}cancel=()=>{this.currentId!==Cs&&(Es.cancel(this.currentId),this.currentId=Cs)};disposeEffect=()=>this.cancel}function ba(){const e=bn(Vt.create).current;return da(e.disposeEffect),e}function Kd(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class g0{nodesRef={current:[]};events=Kd();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const zd=m.createContext(null),qd=m.createContext(null),Yn=()=>m.useContext(zd)?.id||null,wr=e=>{const t=m.useContext(qd);return e??t};function y0(e){const t=ts(),n=wr(e),r=Yn();return Te(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function b0(e){const{children:t,id:n}=e,r=Yn();return b.jsx(zd.Provider,{value:m.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function x0(e){const{children:t,externalTree:n}=e,r=bn(()=>n??new g0).current;return b.jsx(qd.Provider,{value:r,children:t})}function Ur(e){return`data-base-ui-${e}`}function zo(e,t,n){if(n&&!dr(n))return 0;if(typeof e=="number")return e;if(typeof e=="function"){const r=e();return typeof r=="number"?r:r?.[t]}return e?.[t]}const mr=m.forwardRef(function(t,n){const[r,s]=m.useState();Te(()=>{wy&&s("button")},[]);const o={tabIndex:0,role:r};return b.jsx("span",{...t,ref:n,style:Yd,"aria-hidden":r?void 0:!0,...o,"data-base-ui-focus-guard":""})});let sc=0;function qo(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:s=!1}=t;r&&cancelAnimationFrame(sc);const o=()=>e?.focus({preventScroll:n});s?o():sc=requestAnimationFrame(o)}const ar={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function oc(e){return e==="inert"?ar.inert:e==="aria-hidden"?ar["aria-hidden"]:ar.none}let Ms=new WeakSet,Ds={},Xo=0;const Xd=e=>e&&(e.host||Xd(e.parentNode)),v0=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=Xd(n);return e.contains(r)?r:null}).filter(n=>n!=null);function w0(e,t,n,r){const s="data-base-ui-inert",o=r?"inert":n?"aria-hidden":null,i=v0(t,e),a=new Set,l=new Set(i),c=[];Ds[s]||(Ds[s]=new WeakMap);const u=Ds[s];i.forEach(d),f(t),a.clear();function d(h){!h||a.has(h)||(a.add(h),h.parentNode&&d(h.parentNode))}function f(h){!h||l.has(h)||[].forEach.call(h.children,p=>{if(ns(p)!=="script")if(a.has(p))f(p);else{const g=o?p.getAttribute(o):null,y=g!==null&&g!=="false",w=oc(o),x=(w.get(p)||0)+1,v=(u.get(p)||0)+1;w.set(p,x),u.set(p,v),c.push(p),x===1&&y&&Ms.add(p),v===1&&p.setAttribute(s,""),!y&&o&&p.setAttribute(o,o==="inert"?"":"true")}})}return Xo+=1,()=>{c.forEach(h=>{const p=oc(o),y=(p.get(h)||0)-1,w=(u.get(h)||0)-1;p.set(h,y),u.set(h,w),y||(!Ms.has(h)&&o&&h.removeAttribute(o),Ms.delete(h)),w||h.removeAttribute(s)}),Xo-=1,Xo||(ar.inert=new WeakMap,ar["aria-hidden"]=new WeakMap,ar.none=new WeakMap,Ms=new WeakSet,Ds={})}}function k0(e,t=!1,n=!1){const r=qe(e[0]).body;return w0(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const Zd=m.createContext(null),Qd=()=>m.useContext(Zd),S0=Ur("portal");function T0(e={}){const{ref:t,container:n,componentProps:r=Nn,elementProps:s,elementState:o}=e,i=ts(),l=Qd()?.portalNode,[c,u]=m.useState(null),[d,f]=m.useState(null),h=he(w=>{w!==null&&f(w)}),p=m.useRef(null);Te(()=>{if(n===null){p.current&&(p.current=null,f(null),u(null));return}if(i==null)return;const w=(n&&(jg(n)?n:n.current))??l??document.body;if(w==null){p.current&&(p.current=null,f(null),u(null));return}p.current!==w&&(p.current=w,f(null),u(w))},[n,l,i]);const g=sn("div",r,{ref:[t,h],state:o,props:[{id:i,[S0]:""},s]});return{portalNode:d,portalSubtree:c&&g?pn.createPortal(g,c):null}}const Jd=m.forwardRef(function(t,n){const{children:r,container:s,className:o,render:i,renderGuards:a,...l}=t,{portalNode:c,portalSubtree:u}=T0({container:s,ref:n,componentProps:t,elementProps:l}),d=m.useRef(null),f=m.useRef(null),h=m.useRef(null),p=m.useRef(null),[g,y]=m.useState(null),w=g?.modal,x=g?.open,v=typeof a=="boolean"?a:!!g&&!g.modal&&g.open&&!!c;m.useEffect(()=>{if(!c||w)return;function S(C){c&&C.relatedTarget&&ir(C)&&(C.type==="focusin"?Kl:rb)(c)}return c.addEventListener("focusin",S,!0),c.addEventListener("focusout",S,!0),()=>{c.removeEventListener("focusin",S,!0),c.removeEventListener("focusout",S,!0)}},[c,w]),m.useEffect(()=>{!c||x||Kl(c)},[x,c]);const k=m.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:h,afterInsideRef:p,portalNode:c,setFocusManagerState:y}),[c]);return b.jsxs(m.Fragment,{children:[u,b.jsxs(Zd.Provider,{value:k,children:[v&&c&&b.jsx(mr,{"data-type":"outside",ref:d,onFocus:S=>{if(ir(S,c))h.current?.focus();else{const C=g?g.domReference:null;Fd(C)?.focus()}}}),v&&c&&b.jsx("span",{"aria-owns":c.id,style:by}),c&&pn.createPortal(r,c),v&&c&&b.jsx(mr,{"data-type":"outside",ref:f,onFocus:S=>{if(ir(S,c))p.current?.focus();else{const C=g?g.domReference:null;pa(C)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Ve(Hr,S.nativeEvent))}}})]})]})});function Jt(e){return e==null?e:"current"in e?e.current:e}function C0(e,t){const n=vt(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const ic=20;let fn=[];function xa(){fn=fn.filter(e=>e.isConnected)}function E0(e){xa(),e&&ns(e)!=="body"&&(fn.push(e),fn.length>ic&&(fn=fn.slice(-ic)))}function Zo(){return xa(),fn[fn.length-1]}function M0(e){if(!e)return null;const t=vr();return Nd(e,t)?e:ss(e,t)[0]||e}function D0(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():At(e).display!=="none"}function ac(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=vr(),s=eb(e,n).filter(i=>{const a=i.getAttribute("data-tabindex")||"";return Nd(i,n)||i.hasAttribute("data-tabindex")&&!a.startsWith("-")}),o=e.getAttribute("tabindex");t.current.includes("floating")||s.length===0?o!=="0"&&e.setAttribute("tabindex","0"):(o!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function ef(e){const{context:t,children:n,disabled:r=!1,order:s=["content"],initialFocus:o=!0,returnFocus:i=!0,restoreFocus:a=!1,modal:l=!0,closeOnFocusOut:c=!0,openInteractionType:u="",getInsideElements:d=()=>[],nextFocusableElement:f,previousFocusableElement:h,beforeContentFocusGuardRef:p,externalTree:g}=e,y="rootStore"in t?t.rootStore:t,w=y.useState("open"),x=y.useState("domReferenceElement"),v=y.useState("floatingElement"),{events:k,dataRef:S}=y.context,C=he(()=>S.current.floatingContext?.nodeId),M=he(d),D=o===!1,F=$l(x)&&D,T=Bt(s),R=Bt(o),A=Bt(i),E=Bt(u),j=wr(g),N=Qd(),V=m.useRef(null),U=m.useRef(null),P=m.useRef(!1),I=m.useRef(!1),B=m.useRef(!1),W=m.useRef(-1),Q=m.useRef(""),Y=m.useRef(""),$=m.useRef(null),z=m.useRef(null),Z=Vl($,p,N?.beforeInsideRef),ce=Vl(z,N?.afterInsideRef),Se=Vn(),Re=Vn(),Ee=ba(),Je=N!=null,L=Pi(v),ue=he((H=L)=>H?ss(H,vr()):[]),te=he(H=>{const se=ue(H);return T.current.map(()=>se).filter(Boolean).flat()});m.useEffect(()=>{if(r||!l)return;function H(ie){ie.key==="Tab"&&we(L,Qn(qe(L)))&&ue().length===0&&!F&&My(ie)}const se=qe(L);return se.addEventListener("keydown",H),()=>{se.removeEventListener("keydown",H)}},[r,x,L,l,T,F,ue,te]),m.useEffect(()=>{if(r||!v)return;function H(se){const ie=dt(se),ge=ue().indexOf(ie);ge!==-1&&(W.current=ge)}return v.addEventListener("focusin",H),()=>{v.removeEventListener("focusin",H)}},[r,v,ue]),m.useEffect(()=>{if(r||!w)return;const H=qe(L);function se(){B.current=!1}function ie(ge){const J=dt(ge),ne=we(v,J)||we(x,J)||we(N?.portalNode,J);B.current=!ne,Y.current=ge.pointerType||"keyboard"}function me(){Y.current="keyboard"}return H.addEventListener("pointerdown",ie,!0),H.addEventListener("pointerup",se,!0),H.addEventListener("pointercancel",se,!0),H.addEventListener("keydown",me,!0),()=>{H.removeEventListener("pointerdown",ie,!0),H.removeEventListener("pointerup",se,!0),H.removeEventListener("pointercancel",se,!0),H.removeEventListener("keydown",me,!0)}},[r,v,x,L,w,N]),m.useEffect(()=>{if(r||!c)return;function H(){I.current=!0,Re.start(0,()=>{I.current=!1})}function se(J){const ne=J.relatedTarget,Ie=J.currentTarget,be=dt(J);queueMicrotask(()=>{const _e=C(),Ge=y.context.triggerElements,ot=ne?.hasAttribute(Ur("focus-guard"))&&[$.current,z.current,N?.beforeInsideRef.current,N?.afterInsideRef.current,N?.beforeOutsideRef.current,N?.afterOutsideRef.current,Jt(h),Jt(f)].includes(ne),Oe=!(we(x,ne)||we(v,ne)||we(ne,v)||we(N?.portalNode,ne)||ne!=null&&Ge.hasElement(ne)||Ge.hasMatchingElement(ye=>we(ye,ne))||ot||j&&(Fn(j.nodesRef.current,_e).find(ye=>we(ye.context?.elements.floating,ne)||we(ye.context?.elements.domReference,ne))||Yl(j.nodesRef.current,_e).find(ye=>[ye.context?.elements.floating,Pi(ye.context?.elements.floating)].includes(ne)||ye.context?.elements.domReference===ne)));if(Ie===x&&L&&ac(L,T),a&&Ie!==x&&!D0(be)&&Qn(qe(L))===qe(L).body){if(nt(L)&&(L.focus(),a==="popup")){Ee.request(()=>{L.focus()});return}const ye=W.current,Fe=ue(),$e=Fe[ye]||Fe[Fe.length-1]||L;nt($e)&&$e.focus()}if(S.current.insideReactTree){S.current.insideReactTree=!1;return}(F||!l)&&ne&&Oe&&!I.current&&(F||ne!==Zo())&&(P.current=!0,y.setOpen(!1,Ve(Hr,J)))})}function ie(){B.current||(S.current.insideReactTree=!0,Se.start(0,()=>{S.current.insideReactTree=!1}))}const me=nt(x)?x:null,ge=[];if(!(!v&&!me))return me&&(me.addEventListener("focusout",se),me.addEventListener("pointerdown",H),ge.push(()=>{me.removeEventListener("focusout",se),me.removeEventListener("pointerdown",H)})),v&&(v.addEventListener("focusout",se),N&&(v.addEventListener("focusout",ie,!0),ge.push(()=>{v.removeEventListener("focusout",ie,!0)})),ge.push(()=>{v.removeEventListener("focusout",se)})),()=>{ge.forEach(J=>{J()})}},[r,x,v,L,l,j,N,y,c,a,ue,F,C,T,S,Se,Re,Ee,f,h]),m.useEffect(()=>{if(r||!v||!w)return;const H=Array.from(N?.portalNode?.querySelectorAll(`[${Ur("portal")}]`)||[]),ie=(j?Yl(j.nodesRef.current,C()):[]).find(J=>$l(J.context?.elements.domReference||null))?.context?.elements.domReference,me=[v,ie,...H,...M(),V.current,U.current,$.current,z.current,N?.beforeOutsideRef.current,N?.afterOutsideRef.current,Jt(h),Jt(f),F?x:null].filter(J=>J!=null),ge=k0(me,l||F);return()=>{ge()}},[w,r,x,v,l,T,N,F,j,C,M,f,h]),Te(()=>{if(!w||r||!nt(L))return;const H=qe(L),se=Qn(H);queueMicrotask(()=>{const ie=te(L),me=R.current,ge=typeof me=="function"?me(E.current||""):me;if(ge===void 0||ge===!1)return;let J;ge===!0||ge===null?J=ie[0]||L:J=Jt(ge),J=J||ie[0]||L,!we(L,se)&&qo(J,{preventScroll:J===L})})},[r,w,L,D,te,R,E]),Te(()=>{if(r||!L)return;const H=qe(L),se=Qn(H);E0(se);function ie(J){if(J.open||(Q.current=C0(J.nativeEvent,Y.current)),J.reason===ut&&J.nativeEvent.type==="mouseleave"&&(P.current=!0),J.reason===cd)if(J.nested)P.current=!1;else if(Py(J.nativeEvent)||Ry(J.nativeEvent))P.current=!1;else{let ne=!1;document.createElement("div").focus({get preventScroll(){return ne=!0,!1}}),ne?P.current=!1:P.current=!0}}k.on("openchange",ie);const me=H.createElement("span");me.setAttribute("tabindex","-1"),me.setAttribute("aria-hidden","true"),Object.assign(me.style,Yd),Je&&x&&x.insertAdjacentElement("afterend",me);function ge(){const J=A.current;let ne=typeof J=="function"?J(Q.current):J;if(ne===void 0||ne===!1)return null;if(ne===null&&(ne=!0),typeof ne=="boolean"){const be=x||Zo();return be&&be.isConnected?be:me}const Ie=x||Zo()||me;return Jt(ne)||Ie}return()=>{k.off("openchange",ie);const J=Qn(H),ne=we(v,J)||j&&Fn(j.nodesRef.current,C(),!1).some(be=>we(be.context?.elements.floating,J)),Ie=ge();queueMicrotask(()=>{const be=M0(Ie),_e=typeof A.current!="boolean";A.current&&!P.current&&nt(be)&&(!(!_e&&be!==J&&J!==H.body)||ne)&&be.focus({preventScroll:!0}),me.remove()})}},[r,v,L,A,S,k,j,Je,x,C]),m.useEffect(()=>{queueMicrotask(()=>{P.current=!1})},[r]),m.useEffect(()=>{if(r||!w)return;function H(ie){dt(ie)?.closest(`[${yd}]`)&&(I.current=!0)}const se=qe(L);return se.addEventListener("pointerdown",H,!0),()=>{se.removeEventListener("pointerdown",H,!0)}},[r,w,L]),Te(()=>{if(!r&&N)return N.setFocusManagerState({modal:l,closeOnFocusOut:c,open:w,onOpenChange:y.setOpen,domReference:x}),()=>{N.setFocusManagerState(null)}},[r,N,l,w,y,c,x]),Te(()=>{if(!(r||!L))return ac(L,T),()=>{queueMicrotask(xa)}},[r,L,T]);const Me=!r&&(l?!F:!0)&&(Je||l);return b.jsxs(m.Fragment,{children:[Me&&b.jsx(mr,{"data-type":"inside",ref:Z,onFocus:H=>{if(l){const se=te();qo(se[se.length-1])}else N?.portalNode&&(P.current=!1,ir(H,N.portalNode)?pa(x)?.focus():Jt(h??N.beforeOutsideRef)?.focus())}}),n,Me&&b.jsx(mr,{"data-type":"inside",ref:ce,onFocus:H=>{l?qo(te()[0]):N?.portalNode&&(c&&(P.current=!0),ir(H,N.portalNode)?Fd(x)?.focus():Jt(f??N.afterOutsideRef)?.focus())}})]})}function P0(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:s=!0,event:o="click",toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:l=!0,touchOpenDelay:c=0}=t,u=m.useRef(void 0),d=ba(),f=Vn(),h=m.useMemo(()=>({onPointerDown(p){u.current=p.pointerType},onMouseDown(p){const g=u.current,y=p.nativeEvent,w=n.select("open");if(p.button!==0||o==="click"||dr(g,!0)&&a)return;const x=r.current.openEvent,v=x?.type,k=n.select("domReferenceElement")!==p.currentTarget,S=w&&k||!(w&&i&&(!(x&&l)||v==="click"||v==="mousedown"));if(Td(y.target)){const M=Ve(mn,y,y.target);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,M)}):n.setOpen(S,M);return}const C=p.currentTarget;d.request(()=>{const M=Ve(mn,y,C);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,M)}):n.setOpen(S,M)})},onClick(p){if(o==="mousedown-only")return;const g=u.current;if(o==="mousedown"&&g){u.current=void 0;return}if(dr(g,!0)&&a)return;const y=n.select("open"),w=r.current.openEvent,x=n.select("domReferenceElement")!==p.currentTarget,v=y&&x||!(y&&i&&(!(w&&l)||Cd(w))),k=Ve(mn,p.nativeEvent,p.currentTarget);v&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,k)}):n.setOpen(v,k)},onKeyDown(){u.current=void 0}}),[r,o,a,n,l,i,d,f,c]);return m.useMemo(()=>s?{reference:h}:Nn,[s,h])}function lc(e,t,n){let{reference:r,floating:s}=e;const o=yt(t),i=ma(t),a=ha(i),l=it(t),c=o==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[a]/2-s[a]/2;let h;switch(l){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-s.width,y:d};break;default:h={x:r.x,y:r.y}}switch(xn(t)){case"start":h[i]-=f*(n&&c?-1:1);break;case"end":h[i]+=f*(n&&c?-1:1);break}return h}async function R0(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=nn(t,e),p=Ed(h),y=a[f?d==="floating"?"reference":"floating":d],w=zs(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(y)))==null||n?y:y.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=d==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),k=await(o.isElement==null?void 0:o.isElement(v))?await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1}:{x:1,y:1},S=zs(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:v,strategy:l}):x);return{top:(w.top-S.top+p.top)/k.y,bottom:(S.bottom-w.bottom+p.bottom)/k.y,left:(w.left-S.left+p.left)/k.x,right:(S.right-w.right+p.right)/k.x}}const O0=50,A0=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:R0},l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:d}=lc(c,r,l),f=r,h=0;const p={};for(let g=0;g<o.length;g++){const y=o[g];if(!y)continue;const{name:w,fn:x}=y,{x:v,y:k,data:S,reset:C}=await x({x:u,y:d,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:a,elements:{reference:e,floating:t}});u=v??u,d=k??d,p[w]={...p[w],...S},C&&h<O0&&(h++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:u,y:d}=lc(c,f,l)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}},N0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=nn(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const w=it(s),x=yt(a),v=it(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(v||!g?[Ks(a)]:Iy(a)),C=p!=="none";!f&&C&&S.push(...Vy(a,g,p,k));const M=[a,...S],D=await l.detectOverflow(t,y),F=[];let T=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&F.push(D[w]),d){const j=Ny(s,i,k);F.push(D[j[0]],D[j[1]])}if(T=[...T,{placement:s,overflows:F}],!F.every(j=>j<=0)){var R,A;const j=(((R=o.flip)==null?void 0:R.index)||0)+1,N=M[j];if(N&&(!(d==="alignment"?x!==yt(N):!1)||T.every(P=>yt(P.placement)===x?P.overflows[0]>0:!0)))return{data:{index:j,overflows:T},reset:{placement:N}};let V=(A=T.filter(U=>U.overflows[0]<=0).sort((U,P)=>U.overflows[1]-P.overflows[1])[0])==null?void 0:A.placement;if(!V)switch(h){case"bestFit":{var E;const U=(E=T.filter(P=>{if(C){const I=yt(P.placement);return I===x||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,B)=>I+B,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:E[0];U&&(V=U);break}case"initialPlacement":V=a;break}if(s!==V)return{reset:{placement:V}}}return{}}}};function cc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function uc(e){return Oy.some(t=>e[t]>=0)}const I0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...o}=nn(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...o,elementContext:"reference"}),a=cc(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:uc(a)}}}case"escaped":{const i=await r.detectOverflow(t,{...o,altBoundary:!0}),a=cc(i,n.floating);return{data:{escapedOffsets:a,escaped:uc(a)}}}default:return{}}}}},tf=new Set(["left","top"]);async function F0(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=it(n),a=xn(n),l=yt(n)==="y",c=tf.has(i)?-1:1,u=o&&l?-1:1,d=nn(t,e);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const j0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:i,middlewareData:a}=t,l=await F0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:i}}}}},L0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:o}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x,y:v}=w;return{x,y:v}}},...c}=nn(e,t),u={x:n,y:r},d=await o.detectOverflow(t,c),f=yt(it(s)),h=fa(f);let p=u[h],g=u[f];if(i){const w=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=p+d[w],k=p-d[x];p=Ri(v,p,k)}if(a){const w=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=g+d[w],k=g-d[x];g=Ri(v,g,k)}const y=l.fn({...t,[h]:p,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:i,[f]:a}}}}}},V0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:o,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=nn(e,t),u={x:n,y:r},d=yt(s),f=fa(d);let h=u[f],p=u[d];const g=nn(a,t),y=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const v=f==="y"?"height":"width",k=o.reference[f]-o.floating[v]+y.mainAxis,S=o.reference[f]+o.reference[v]-y.mainAxis;h<k?h=k:h>S&&(h=S)}if(c){var w,x;const v=f==="y"?"width":"height",k=tf.has(it(s)),S=o.reference[d]-o.floating[v]+(k&&((w=i.offset)==null?void 0:w[d])||0)+(k?0:y.crossAxis),C=o.reference[d]+o.reference[v]+(k?0:((x=i.offset)==null?void 0:x[d])||0)-(k?y.crossAxis:0);p<S?p=S:p>C&&(p=C)}return{[f]:h,[d]:p}}}},_0=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:o,platform:i,elements:a}=t,{apply:l=()=>{},...c}=nn(e,t),u=await i.detectOverflow(t,c),d=it(s),f=xn(s),h=yt(s)==="y",{width:p,height:g}=o.floating;let y,w;d==="top"||d==="bottom"?(y=d,w=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=d,y=f==="end"?"top":"bottom");const x=g-u.top-u.bottom,v=p-u.left-u.right,k=fr(g-u[y],x),S=fr(p-u[w],v),C=!t.middlewareData.shift;let M=k,D=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(D=v),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(M=x),C&&!f){const T=ft(u.left,0),R=ft(u.right,0),A=ft(u.top,0),E=ft(u.bottom,0);h?D=p-2*(T!==0||R!==0?T+R:ft(u.left,u.right)):M=g-2*(A!==0||E!==0?A+E:ft(u.top,u.bottom))}await l({...t,availableWidth:D,availableHeight:M});const F=await i.getDimensions(a.floating);return p!==F.width||g!==F.height?{reset:{rects:!0}}:{}}}};function nf(e){const t=At(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=nt(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,a=Gs(n)!==o||Gs(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function va(e){return Ae(e)?e:e.contextElement}function lr(e){const t=va(e);if(!nt(t))return Ht(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=nf(t);let i=(o?Gs(n.width):n.width)/r,a=(o?Gs(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const W0=Ht(0);function rf(e){const t=vt(e);return!aa()||!t.visualViewport?W0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function B0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vt(e)?!1:t}function _n(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=va(e);let i=Ht(1);t&&(r?Ae(r)&&(i=lr(r)):i=lr(e));const a=B0(o,n,r)?rf(o):Ht(0);let l=(s.left+a.x)/i.x,c=(s.top+a.y)/i.y,u=s.width/i.x,d=s.height/i.y;if(o){const f=vt(o),h=r&&Ae(r)?vt(r):r;let p=f,g=_l(p);for(;g&&r&&h!==p;){const y=lr(g),w=g.getBoundingClientRect(),x=At(g),v=w.left+(g.clientLeft+parseFloat(x.paddingLeft))*y.x,k=w.top+(g.clientTop+parseFloat(x.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,d*=y.y,l+=v,c+=k,p=vt(g),g=_l(p)}}return zs({width:u,height:d,x:l,y:c})}function mo(e,t){const n=ho(e).scrollLeft;return t?t.left+n:_n(on(e)).left+n}function sf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-mo(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function $0(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",i=on(r),a=t?la(t.floating):!1;if(r===i||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Ht(1);const u=Ht(0),d=nt(r);if((d||!d&&!o)&&((ns(r)!=="body"||rs(i))&&(l=ho(r)),d)){const h=_n(r);c=lr(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=i&&!d&&!o?sf(i,l):Ht(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function Y0(e){return Array.from(e.getClientRects())}function H0(e){const t=on(e),n=ho(e),r=e.ownerDocument.body,s=ft(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ft(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+mo(e);const a=-n.scrollTop;return At(r).direction==="rtl"&&(i+=ft(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}const dc=25;function U0(e,t){const n=vt(e),r=on(e),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,a=0,l=0;if(s){o=s.width,i=s.height;const u=aa();(!u||u&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=mo(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=dc&&(o-=p)}else c<=dc&&(o+=c);return{width:o,height:i,x:a,y:l}}function G0(e,t){const n=_n(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=nt(e)?lr(e):Ht(1),i=e.clientWidth*o.x,a=e.clientHeight*o.y,l=s*o.x,c=r*o.y;return{width:i,height:a,x:l,y:c}}function fc(e,t,n){let r;if(t==="viewport")r=U0(e,n);else if(t==="document")r=H0(on(e));else if(Ae(t))r=G0(t,n);else{const s=rf(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return zs(r)}function of(e,t){const n=ur(e);return n===t||!Ae(n)||In(n)?!1:At(n).position==="fixed"||of(n,t)}function K0(e,t){const n=t.get(e);if(n)return n;let r=or(e,[],!1).filter(a=>Ae(a)&&ns(a)!=="body"),s=null;const o=At(e).position==="fixed";let i=o?ur(e):e;for(;Ae(i)&&!In(i);){const a=At(i),l=ud(i);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||rs(i)&&!l&&of(e,i))?r=r.filter(u=>u!==i):s=a,i=ur(i)}return t.set(e,r),r}function z0(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?la(t)?[]:K0(t,this._c):[].concat(n),r],a=fc(t,i[0],s);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<i.length;f++){const h=fc(t,i[f],s);l=ft(h.top,l),c=fr(h.right,c),u=fr(h.bottom,u),d=ft(h.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function q0(e){const{width:t,height:n}=nf(e);return{width:t,height:n}}function X0(e,t,n){const r=nt(t),s=on(t),o=n==="fixed",i=_n(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=Ht(0);function c(){l.x=mo(s)}if(r||!r&&!o)if((ns(t)!=="body"||rs(s))&&(a=ho(t)),r){const h=_n(t,!0,o,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else s&&c();o&&!r&&s&&c();const u=s&&!r&&!o?sf(s,a):Ht(0),d=i.left+a.scrollLeft-l.x-u.x,f=i.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function Qo(e){return At(e).position==="static"}function hc(e,t){if(!nt(e)||At(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return on(e)===n&&(n=n.ownerDocument.body),n}function af(e,t){const n=vt(e);if(la(e))return n;if(!nt(e)){let s=ur(e);for(;s&&!In(s);){if(Ae(s)&&!Qo(s))return s;s=ur(s)}return n}let r=hc(e,t);for(;r&&Lg(r)&&Qo(r);)r=hc(r,t);return r&&In(r)&&Qo(r)&&!ud(r)?n:r||Vg(e)||n}const Z0=async function(e){const t=this.getOffsetParent||af,n=this.getDimensions,r=await n(e.floating);return{reference:X0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Q0(e){return At(e).direction==="rtl"}const J0={convertOffsetParentRelativeRectToViewportRelativeRect:$0,getDocumentElement:on,getClippingRect:z0,getOffsetParent:af,getElementRects:Z0,getClientRects:Y0,getDimensions:q0,getScale:lr,isElement:Ae,isRTL:Q0};function lf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ex(e,t){let n=null,r;const s=on(e);function o(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),o();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:h}=c;if(a||t(),!f||!h)return;const p=Ss(d),g=Ss(s.clientWidth-(u+f)),y=Ss(s.clientHeight-(d+h)),w=Ss(u),v={rootMargin:-p+"px "+-g+"px "+-y+"px "+-w+"px",threshold:ft(0,fr(1,l))||1};let k=!0;function S(C){const M=C[0].intersectionRatio;if(M!==l){if(!k)return i();M?i(!1,M):r=setTimeout(()=>{i(!1,1e-7)},1e3)}M===1&&!lf(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...v,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,v)}n.observe(e)}return i(!0),o}function mc(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=va(e),u=s||o?[...c?or(c):[],...t?or(t):[]]:[];u.forEach(w=>{s&&w.addEventListener("scroll",n,{passive:!0}),o&&w.addEventListener("resize",n)});const d=c&&a?ex(c,n):null;let f=-1,h=null;i&&(h=new ResizeObserver(w=>{let[x]=w;x&&x.target===c&&h&&t&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(t)})),n()}),c&&!l&&h.observe(c),t&&h.observe(t));let p,g=l?_n(e):null;l&&y();function y(){const w=_n(e);g&&!lf(g,w)&&n(),g=w,p=requestAnimationFrame(y)}return n(),()=>{var w;u.forEach(x=>{s&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),d?.(),(w=h)==null||w.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const tx=j0,nx=L0,rx=N0,sx=_0,ox=I0,ix=V0,ax=(e,t,n)=>{const r=new Map,s={platform:J0,...n},o={...s.platform,_c:r};return A0(e,t,{...s,platform:o})};var lx=typeof document<"u",cx=function(){},Fs=lx?m.useLayoutEffect:cx;function to(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!to(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!to(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function cf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pc(e,t){const n=cf(e);return Math.round(t*n)/n}function Jo(e){const t=m.useRef(e);return Fs(()=>{t.current=e}),t}function ux(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=m.useState(r);to(f,r)||h(r);const[p,g]=m.useState(null),[y,w]=m.useState(null),x=m.useCallback(P=>{P!==C.current&&(C.current=P,g(P))},[]),v=m.useCallback(P=>{P!==M.current&&(M.current=P,w(P))},[]),k=o||p,S=i||y,C=m.useRef(null),M=m.useRef(null),D=m.useRef(u),F=l!=null,T=Jo(l),R=Jo(s),A=Jo(c),E=m.useCallback(()=>{if(!C.current||!M.current)return;const P={placement:t,strategy:n,middleware:f};R.current&&(P.platform=R.current),ax(C.current,M.current,P).then(I=>{const B={...I,isPositioned:A.current!==!1};j.current&&!to(D.current,B)&&(D.current=B,pn.flushSync(()=>{d(B)}))})},[f,t,n,R,A]);Fs(()=>{c===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,d(P=>({...P,isPositioned:!1})))},[c]);const j=m.useRef(!1);Fs(()=>(j.current=!0,()=>{j.current=!1}),[]),Fs(()=>{if(k&&(C.current=k),S&&(M.current=S),k&&S){if(T.current)return T.current(k,S,E);E()}},[k,S,E,T,F]);const N=m.useMemo(()=>({reference:C,floating:M,setReference:x,setFloating:v}),[x,v]),V=m.useMemo(()=>({reference:k,floating:S}),[k,S]),U=m.useMemo(()=>{const P={position:n,left:0,top:0};if(!V.floating)return P;const I=pc(V.floating,u.x),B=pc(V.floating,u.y);return a?{...P,transform:"translate("+I+"px, "+B+"px)",...cf(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:B}},[n,a,V.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:E,refs:N,elements:V,floatingStyles:U}),[u,E,N,V,U])}const dx=(e,t)=>{const n=tx(e);return{name:n.name,fn:n.fn,options:[e,t]}},fx=(e,t)=>{const n=nx(e);return{name:n.name,fn:n.fn,options:[e,t]}},hx=(e,t)=>({fn:ix(e).fn,options:[e,t]}),mx=(e,t)=>{const n=rx(e);return{name:n.name,fn:n.fn,options:[e,t]}},px=(e,t)=>{const n=sx(e);return{name:n.name,fn:n.fn,options:[e,t]}},gx=(e,t)=>{const n=ox(e);return{name:n.name,fn:n.fn,options:[e,t]}},yx={intentional:"onClick",sloppy:"onPointerDown"};function bx(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function uf(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingElement"),o=n.useState("referenceElement"),i=n.useState("domReferenceElement"),{onOpenChange:a,dataRef:l}=n.context,{enabled:c=!0,escapeKey:u=!0,outsidePress:d=!0,outsidePressEvent:f="sloppy",referencePress:h=!1,referencePressEvent:p="sloppy",ancestorScroll:g=!1,bubbles:y,externalTree:w}=t,x=wr(w),v=he(typeof d=="function"?d:()=>!1),k=typeof d=="function"?v:d,S=m.useRef(!1),{escapeKey:C,outsidePress:M}=bx(y),D=m.useRef(null),F=Vn(),T=Vn(),R=he(()=>{T.clear(),l.current.insideReactTree=!1}),A=m.useRef(!1),E=m.useRef(""),j=he(L=>{E.current=L.pointerType}),N=he(()=>{const L=E.current,ue=L==="pen"||!L?"mouse":L,te=typeof f=="function"?f():f;return typeof te=="string"?te:te[ue]}),V=he(L=>{if(!r||!c||!u||L.key!=="Escape"||A.current)return;const ue=l.current.floatingContext?.nodeId,te=x?Fn(x.nodesRef.current,ue):[];if(!C&&te.length>0){let se=!0;if(te.forEach(ie=>{ie.context?.open&&!ie.context.dataRef.current.__escapeKeyBubbles&&(se=!1)}),!se)return}const Me=Dy(L)?L.nativeEvent:L,H=Ve(dd,Me);n.setOpen(!1,H),!C&&!H.isPropagationAllowed&&L.stopPropagation()}),U=he(L=>{const ue=N();return ue==="intentional"&&L.type!=="click"||ue==="sloppy"&&L.type==="click"}),P=he(()=>{l.current.insideReactTree=!0,T.start(0,R)}),I=he((L,ue=!1)=>{if(U(L)){R();return}if(l.current.insideReactTree){R();return}if(N()==="intentional"&&ue||typeof k=="function"&&!k(L))return;const te=dt(L),Me=`[${Ur("inert")}]`,H=qe(n.select("floatingElement")).querySelectorAll(Me),se=n.context.triggerElements;if(te&&(se.hasElement(te)||se.hasMatchingElement(ne=>we(ne,te))))return;let ie=Ae(te)?te:null;for(;ie&&!In(ie);){const ne=ur(ie);if(In(ne)||!Ae(ne))break;ie=ne}if(H.length&&Ae(te)&&!Ey(te)&&!we(te,n.select("floatingElement"))&&Array.from(H).every(ne=>!we(ie,ne)))return;if(nt(te)&&!("touches"in L)){const ne=In(te),Ie=At(te),be=/auto|scroll/,_e=ne||be.test(Ie.overflowX),Ge=ne||be.test(Ie.overflowY),ot=_e&&te.clientWidth>0&&te.scrollWidth>te.clientWidth,Oe=Ge&&te.clientHeight>0&&te.scrollHeight>te.clientHeight,ye=Ie.direction==="rtl",Fe=Oe&&(ye?L.offsetX<=te.offsetWidth-te.clientWidth:L.offsetX>te.clientWidth),$e=ot&&L.offsetY>te.clientHeight;if(Fe||$e)return}const me=l.current.floatingContext?.nodeId,ge=x&&Fn(x.nodesRef.current,me).some(ne=>Ct(L,ne.context?.elements.floating));if(Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||ge)return;const J=x?Fn(x.nodesRef.current,me):[];if(J.length>0){let ne=!0;if(J.forEach(Ie=>{Ie.context?.open&&!Ie.context.dataRef.current.__outsidePressBubbles&&(ne=!1)}),!ne)return}n.setOpen(!1,Ve(cd,L)),R()}),B=he(L=>{N()!=="sloppy"||L.pointerType==="touch"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||I(L)}),W=he(L=>{if(N()!=="sloppy"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement")))return;const ue=L.touches[0];ue&&(D.current={startTime:Date.now(),startX:ue.clientX,startY:ue.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},F.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}),Q=he(L=>{const ue=dt(L);function te(){W(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Y=he(L=>{const ue=S.current;if(S.current=!1,F.clear(),L.type==="mousedown"&&D.current&&!D.current.dismissOnMouseDown)return;const te=dt(L);function Me(){L.type==="pointerdown"?B(L):I(L,ue),te?.removeEventListener(L.type,Me)}te?.addEventListener(L.type,Me)}),$=he(L=>{if(N()!=="sloppy"||!D.current||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement")))return;const ue=L.touches[0];if(!ue)return;const te=Math.abs(ue.clientX-D.current.startX),Me=Math.abs(ue.clientY-D.current.startY),H=Math.sqrt(te*te+Me*Me);H>5&&(D.current.dismissOnTouchEnd=!0),H>10&&(I(L),F.clear(),D.current=null)}),z=he(L=>{const ue=dt(L);function te(){$(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Z=he(L=>{N()!=="sloppy"||!D.current||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||(D.current.dismissOnTouchEnd&&I(L),F.clear(),D.current=null)}),ce=he(L=>{const ue=dt(L);function te(){Z(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)});m.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=C,l.current.__outsidePressBubbles=M;const L=new gn;function ue(ie){n.setOpen(!1,Ve(_g,ie))}function te(){L.clear(),A.current=!0}function Me(){L.start(aa()?5:0,()=>{A.current=!1})}const H=qe(s);H.addEventListener("pointerdown",j,!0),u&&(H.addEventListener("keydown",V),H.addEventListener("compositionstart",te),H.addEventListener("compositionend",Me)),k&&(H.addEventListener("click",Y,!0),H.addEventListener("pointerdown",Y,!0),H.addEventListener("touchstart",Q,!0),H.addEventListener("touchmove",z,!0),H.addEventListener("touchend",ce,!0),H.addEventListener("mousedown",Y,!0));let se=[];return g&&(Ae(i)&&(se=or(i)),Ae(s)&&(se=se.concat(or(s))),!Ae(o)&&o&&o.contextElement&&(se=se.concat(or(o.contextElement)))),se=se.filter(ie=>ie!==H.defaultView?.visualViewport),se.forEach(ie=>{ie.addEventListener("scroll",ue,{passive:!0})}),()=>{H.removeEventListener("pointerdown",j,!0),u&&(H.removeEventListener("keydown",V),H.removeEventListener("compositionstart",te),H.removeEventListener("compositionend",Me)),k&&(H.removeEventListener("click",Y,!0),H.removeEventListener("pointerdown",Y,!0),H.removeEventListener("touchstart",Q,!0),H.removeEventListener("touchmove",z,!0),H.removeEventListener("touchend",ce,!0),H.removeEventListener("mousedown",Y,!0)),se.forEach(ie=>{ie.removeEventListener("scroll",ue)}),L.clear(),S.current=!1}},[l,s,o,i,u,k,r,a,g,c,C,M,V,I,Y,B,Q,z,ce,j,n]),m.useEffect(R,[k,R]);const Se=m.useMemo(()=>({onKeyDown:V,...h&&{[yx[p]]:L=>{n.setOpen(!1,Ve(mn,L.nativeEvent))},...p!=="intentional"&&{onClick(L){n.setOpen(!1,Ve(mn,L.nativeEvent))}}}}),[V,n,h,p]),Re=he(L=>{const ue=dt(L.nativeEvent);!we(n.select("floatingElement"),ue)||L.button!==0||(S.current=!0)}),Ee=he(L=>{!r||!c||L.button!==0||(S.current=!0)}),Je=m.useMemo(()=>({onKeyDown:V,onPointerDown:Re,onMouseDown:Re,onMouseUp:Re,onClickCapture:P,onMouseDownCapture(L){P(),Ee(L)},onPointerDownCapture(L){P(),Ee(L)},onMouseUpCapture:P,onTouchEndCapture:P,onTouchMoveCapture:P}),[V,Re,P,Ee]);return m.useMemo(()=>c?{reference:Se,floating:Je,trigger:Se}:{},[c,Se,Je])}const xx={open:pe(e=>e.open),domReferenceElement:pe(e=>e.domReferenceElement),referenceElement:pe(e=>e.positionReference??e.referenceElement),floatingElement:pe(e=>e.floatingElement),floatingId:pe(e=>e.floatingId)};class wa extends ya{constructor(t){const{nested:n,noEmit:r,onOpenChange:s,triggerElements:o,...i}=t;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:Kd(),nested:n,noEmit:r,triggerElements:o},xx)}setOpen=(t,n)=>{if((!t||!this.state.open||Cd(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)}this.context.onOpenChange?.(t,n)}}function vx(e,t=!1,n=!1){const[r,s]=m.useState(e&&t?"idle":void 0),[o,i]=m.useState(e);return e&&!o&&(i(!0),s("starting")),!e&&o&&r!=="ending"&&!n&&s("ending"),!e&&!o&&r==="ending"&&s(void 0),Te(()=>{if(!e&&o&&r!=="ending"&&n){const a=Vt.request(()=>{s("ending")});return()=>{Vt.cancel(a)}}},[e,o,r,n]),Te(()=>{if(!e||t)return;const a=Vt.request(()=>{s(void 0)});return()=>{Vt.cancel(a)}},[t,e]),Te(()=>{if(!e||!t)return;e&&o&&r!=="idle"&&s("starting");const a=Vt.request(()=>{s("idle")});return()=>{Vt.cancel(a)}},[t,e,o,s,r]),m.useMemo(()=>({mounted:o,setMounted:i,transitionStatus:r}),[o,r])}let Gr=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const wx={[Gr.startingStyle]:""},kx={[Gr.endingStyle]:""},po={transitionStatus(e){return e==="starting"?wx:e==="ending"?kx:null}};function df(e,t=!1,n=!0){const r=ba();return he((s,o=null)=>{r.cancel();function i(){pn.flushSync(s)}const a=Jt(e);if(a==null)return;const l=a;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)s();else{let c=function(){const d=Gr.startingStyle;if(!l.hasAttribute(d)){r.request(u);return}const f=new MutationObserver(()=>{l.hasAttribute(d)||(f.disconnect(),u())});f.observe(l,{attributes:!0,attributeFilter:[d]}),o?.addEventListener("abort",()=>f.disconnect(),{once:!0})},u=function(){Promise.all(l.getAnimations().map(d=>d.finished)).then(()=>{o?.aborted||i()}).catch(()=>{const d=l.getAnimations();if(n){if(o?.aborted)return;i()}else d.length>0&&d.some(f=>f.pending||f.playState!=="finished")&&u()})};if(t){c();return}r.request(u)}})}function ka(e){const{enabled:t=!0,open:n,ref:r,onComplete:s}=e,o=he(s),i=df(r,n,!1);m.useEffect(()=>{if(!t)return;const a=new AbortController;return i(o,a.signal),()=>{a.abort()}},[t,n,o,i])}function Sx(e,t){const n=m.useRef(null),r=m.useRef(null);return m.useCallback(s=>{if(e!==void 0){if(n.current!==null){const o=n.current,i=r.current,a=t.context.triggerElements.getById(o);i&&a===i&&t.context.triggerElements.delete(o),n.current=null,r.current=null}s!==null&&(n.current=e,r.current=s,t.context.triggerElements.add(e,s))}},[t,e])}function Tx(e,t,n,r){const s=n.useState("isMountedByTrigger",e),o=Sx(e,n),i=he(a=>{if(o(a),!a||!n.select("open"))return;const l=n.select("activeTriggerId");if(l===e){n.update({activeTriggerElement:a,...r});return}l==null&&n.update({activeTriggerId:e,activeTriggerElement:a,...r})});return Te(()=>{s&&n.update({activeTriggerElement:t.current,...r})},[s,n,t,...Object.values(r)]),{registerTrigger:i,isMountedByThisTrigger:s}}function ff(e){const t=e.useState("open");Te(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,s]=n.value;e.update({activeTriggerId:r,activeTriggerElement:s})}}},[t,e])}function hf(e,t,n){const{mounted:r,setMounted:s,transitionStatus:o}=vx(e);t.useSyncedValues({mounted:r,transitionStatus:o});const i=he(()=>{s(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),a=t.useState("preventUnmountingOnClose");return ka({enabled:!a,open:e,ref:t.context.popupRef,onComplete(){e||i()}}),{forceUnmount:i,transitionStatus:o}}class go{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elements.delete(r),this.elements.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elements.delete(n),this.idMap.delete(t))}hasElement(t){return this.elements.has(t)}hasMatchingElement(t){for(const n of this.elements)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function Cx(){return new wa({open:!1,floatingElement:null,referenceElement:null,triggerElements:new go,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function mf(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Cx(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Nn,inactiveTriggerProps:Nn,popupProps:Nn}}const pf={open:pe(e=>e.open),mounted:pe(e=>e.mounted),transitionStatus:pe(e=>e.transitionStatus),floatingRootContext:pe(e=>e.floatingRootContext),preventUnmountingOnClose:pe(e=>e.preventUnmountingOnClose),payload:pe(e=>e.payload),activeTriggerId:pe(e=>e.activeTriggerId),activeTriggerElement:pe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:pe((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:pe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:pe(e=>e.popupProps),popupElement:pe(e=>e.popupElement),positionerElement:pe(e=>e.positionerElement)};function Ex(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=ts(),o=Yn()!=null,i=bn(()=>new wa({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new go,floatingId:s,nested:o,noEmit:e.noEmit||!1})).current;return Te(()=>{const a={open:t,floatingId:s};r.reference!==void 0&&(a.referenceElement=r.reference,a.domReferenceElement=Ae(r.reference)?r.reference:null),r.floating!==void 0&&(a.floatingElement=r.floating),i.update(a)},[t,s,r.reference,r.floating,i]),i.context.onOpenChange=n,i.context.nested=o,i.context.noEmit=e.noEmit||!1,i}function Mx(e={}){const{nodeId:t,externalTree:n}=e,r=Ex(e),s=e.rootContext||r,o={reference:s.useState("referenceElement"),floating:s.useState("floatingElement"),domReference:s.useState("domReferenceElement")},[i,a]=m.useState(null),l=m.useRef(null),c=wr(n);Te(()=>{o.domReference&&(l.current=o.domReference)},[o.domReference]);const u=ux({...e,elements:{...o,...i&&{reference:i}}}),d=m.useCallback(M=>{const D=Ae(M)?{getBoundingClientRect:()=>M.getBoundingClientRect(),getClientRects:()=>M.getClientRects(),contextElement:M}:M;a(D),u.refs.setReference(D)},[u.refs]),[f,h]=m.useState(null),[p,g]=m.useState(null);s.useSyncedValue("referenceElement",f),s.useSyncedValue("domReferenceElement",Ae(f)?f:null),s.useSyncedValue("floatingElement",p);const y=m.useCallback(M=>{(Ae(M)||M===null)&&(l.current=M,h(M)),(Ae(u.refs.reference.current)||u.refs.reference.current===null||M!==null&&!Ae(M))&&u.refs.setReference(M)},[u.refs,h]),w=m.useCallback(M=>{g(M),u.refs.setFloating(M)},[u.refs]),x=m.useMemo(()=>({...u.refs,setReference:y,setFloating:w,setPositionReference:d,domReference:l}),[u.refs,y,w,d]),v=m.useMemo(()=>({...u.elements,domReference:o.domReference}),[u.elements,o.domReference]),k=s.useState("open"),S=s.useState("floatingId"),C=m.useMemo(()=>({...u,dataRef:s.context.dataRef,open:k,onOpenChange:s.setOpen,events:s.context.events,floatingId:S,refs:x,elements:v,nodeId:t,rootStore:s}),[u,x,v,t,s,k,S]);return Te(()=>{s.context.dataRef.current.floatingContext=C;const M=c?.nodesRef.current.find(D=>D.id===t);M&&(M.context=C)}),m.useMemo(()=>({...u,context:C,refs:x,elements:v,rootStore:s}),[u,x,v,C,s])}function gf(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:s}=e,o=ts(),i=Yn()!=null,a=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=bn(()=>new wa({open:a,referenceElement:l,floatingElement:c,triggerElements:u,onOpenChange:s,floatingId:o,nested:i,noEmit:n})).current;return Te(()=>{const f={open:a,floatingId:o,referenceElement:l,floatingElement:c};Ae(l)&&(f.domReferenceElement=l),d.state.positionReference===d.state.referenceElement&&(f.positionReference=l),d.update(f)},[a,o,l,c,d]),d.context.onOpenChange=s,d.context.nested=i,d.context.noEmit=n,d}const Ii=Ur("safe-polygon"),Dx=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Sd}`;function Px(e){return e?!!e.closest(Dx):!1}function yf(e){const t=m.useRef(void 0),n=m.useRef(!1),r=m.useRef(void 0),s=m.useRef(!0),o=m.useRef(!1),i=m.useRef(()=>{}),a=m.useRef(!1),l=Vn(),c=Vn(),u=m.useRef(void 0);return m.useMemo(()=>{const d=e.context.dataRef.current;return d.hoverInteractionState||(d.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:s,performedPointerEventsMutationRef:o,unbindMouseMoveRef:i,restTimeoutPendingRef:a,openChangeTimeout:l,restTimeout:c,handleCloseOptionsRef:u}),d.hoverInteractionState},[e,t,n,r,s,o,i,a,l,c,u])}const Rx=new Set(["click","mousedown"]);function Ox(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingElement"),o=n.useState("domReferenceElement"),{dataRef:i}=n.context,{enabled:a=!0,closeDelay:l=0,externalTree:c}=t,{pointerTypeRef:u,interactedInsideRef:d,handlerRef:f,performedPointerEventsMutationRef:h,unbindMouseMoveRef:p,restTimeoutPendingRef:g,openChangeTimeout:y,handleCloseOptionsRef:w}=yf(n),x=wr(c),v=Yn(),k=he(()=>d.current?!0:i.current.openEvent?Rx.has(i.current.openEvent.type):!1),S=he(()=>{const T=i.current.openEvent?.type;return T?.includes("mouse")&&T!=="mousedown"}),C=m.useCallback((T,R=!0)=>{const A=Ax(l,u.current);A&&!f.current?y.start(A,()=>n.setOpen(!1,Ve(ut,T))):R&&(y.clear(),n.setOpen(!1,Ve(ut,T)))},[l,f,n,u,y]),M=he(()=>{p.current(),f.current=void 0}),D=he(()=>{if(h.current){const T=qe(s).body;T.style.pointerEvents="",T.removeAttribute(Ii),h.current=!1}}),F=he(T=>{const R=dt(T);if(!Px(R)){d.current=!1;return}d.current=!0});Te(()=>{r||(u.current=void 0,g.current=!1,d.current=!1,M(),D())},[r,u,g,d,M,D]),m.useEffect(()=>()=>{M()},[M]),m.useEffect(()=>D,[D]),Te(()=>{if(a&&r&&w.current?.blockPointerEvents&&S()&&Ae(o)&&s){h.current=!0;const T=qe(s).body;T.setAttribute(Ii,"");const R=o,A=s,E=x?.nodesRef.current.find(j=>j.id===v)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),T.style.pointerEvents="none",R.style.pointerEvents="auto",A.style.pointerEvents="auto",()=>{T.style.pointerEvents="",R.style.pointerEvents="",A.style.pointerEvents=""}}},[a,r,o,s,w,S,x,v,h]),m.useEffect(()=>{if(!a)return;function T(j){if(k()||!i.current.floatingContext||!n.select("open"))return;const N=n.context.triggerElements;j.relatedTarget&&N.hasElement(j.relatedTarget)||(D(),M(),k()||C(j))}function R(j){y.clear(),D(),f.current?.(j),M()}function A(j){k()||C(j,!1)}const E=s;return E&&(E.addEventListener("mouseleave",T),E.addEventListener("mouseenter",R),E.addEventListener("mouseleave",A),E.addEventListener("pointerdown",F,!0)),()=>{E&&(E.removeEventListener("mouseleave",T),E.removeEventListener("mouseenter",R),E.removeEventListener("mouseleave",A),E.removeEventListener("pointerdown",F,!0))}})}function Ax(e,t){return t&&!dr(t)?0:typeof e=="function"?e():e}function ei(e){return typeof e=="function"?e():e}const Nx={current:null};function Ix(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:r,events:s}=n.context,{enabled:o=!0,delay:i=0,handleClose:a=null,mouseOnly:l=!1,restMs:c=0,move:u=!0,triggerElementRef:d=Nx,externalTree:f,isActiveTrigger:h=!0}=t,p=wr(f),{pointerTypeRef:g,interactedInsideRef:y,handlerRef:w,blockMouseMoveRef:x,performedPointerEventsMutationRef:v,unbindMouseMoveRef:k,restTimeoutPendingRef:S,openChangeTimeout:C,restTimeout:M,handleCloseOptionsRef:D}=yf(n),F=Bt(a),T=Bt(i),R=Bt(c);h&&(D.current=F.current?.__options);const A=he(()=>y.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=m.useCallback((U,P=!0)=>{const I=zo(T.current,"close",g.current);I&&!w.current?C.start(I,()=>n.setOpen(!1,Ve(ut,U))):P&&(C.clear(),n.setOpen(!1,Ve(ut,U)))},[T,w,n,g,C]),j=he(()=>{k.current(),w.current=void 0}),N=he(()=>{if(v.current){const U=qe(n.select("domReferenceElement")).body;U.style.pointerEvents="",U.removeAttribute(Ii),v.current=!1}});m.useEffect(()=>{if(!o)return;function U(P){P.open||(C.clear(),M.clear(),x.current=!0,S.current=!1)}return s.on("openchange",U),()=>{s.off("openchange",U)}},[o,s,C,M,x,S]);const V=he(U=>{if(A()||!r.current.floatingContext)return;const P=n.context.triggerElements;if(U.relatedTarget&&P.hasElement(U.relatedTarget))return;const I=d.current;F.current?.({...r.current.floatingContext,tree:p,x:U.clientX,y:U.clientY,onClose(){N(),j(),!A()&&I===n.select("domReferenceElement")&&E(U)}})(U)});return m.useEffect(()=>{if(!o)return;const U=d.current??(h?n.select("domReferenceElement"):null);if(!Ae(U))return;function P(W){if(C.clear(),x.current=!1,l&&!dr(g.current)||ei(R.current)>0&&!zo(T.current,"open"))return;const Q=zo(T.current,"open",g.current),Y=n.select("domReferenceElement"),$=n.context.triggerElements,z=($.hasElement(W.target)||$.hasMatchingElement(Re=>we(Re,W.target)))&&(!Y||!we(Y,W.target)),Z=W.currentTarget??null,ce=n.select("open"),Se=!ce||z;z&&ce?n.setOpen(!0,Ve(ut,W,Z)):Q?C.start(Q,()=>{Se&&n.setOpen(!0,Ve(ut,W,Z))}):Se&&n.setOpen(!0,Ve(ut,W,Z))}function I(W){if(A()){N();return}k.current();const Q=n.select("domReferenceElement"),Y=qe(Q);M.clear(),S.current=!1;const $=n.context.triggerElements;if(W.relatedTarget&&$.hasElement(W.relatedTarget))return;if(F.current&&r.current.floatingContext){n.select("open")||C.clear();const Z=d.current;w.current=F.current({...r.current.floatingContext,tree:p,x:W.clientX,y:W.clientY,onClose(){N(),j(),!A()&&Z===n.select("domReferenceElement")&&E(W,!0)}});const ce=w.current;ce(W),Y.addEventListener("mousemove",ce),k.current=()=>{Y.removeEventListener("mousemove",ce)};return}(g.current!=="touch"||!we(n.select("floatingElement"),W.relatedTarget))&&E(W)}function B(W){V(W)}return n.select("open")&&U.addEventListener("mouseleave",B),u&&U.addEventListener("mousemove",P,{once:!0}),U.addEventListener("mouseenter",P),U.addEventListener("mouseleave",I),()=>{U.removeEventListener("mouseleave",B),u&&U.removeEventListener("mousemove",P),U.removeEventListener("mouseenter",P),U.removeEventListener("mouseleave",I)}},[j,N,x,r,T,E,n,o,F,V,h,A,l,u,g,R,M,S,C,d,p,k,w]),m.useMemo(()=>{function U(P){g.current=P.pointerType}return{onPointerDown:U,onPointerEnter:U,onMouseMove(P){const{nativeEvent:I}=P,B=P.currentTarget,W=n.select("domReferenceElement"),Q=n.context.triggerElements,Y=n.select("open"),$=(Q.hasElement(P.target)||Q.hasMatchingElement(Z=>we(Z,P.target)))&&(!W||!we(W,P.target));if(l&&!dr(g.current)||Y&&!$||ei(R.current)===0||!$&&S.current&&P.movementX**2+P.movementY**2<2)return;M.clear();function z(){if(S.current=!1,A())return;const Z=n.select("open");!x.current&&(!Z||$)&&n.setOpen(!0,Ve(ut,I,B))}g.current==="touch"?pn.flushSync(()=>{z()}):$&&Y?z():(S.current=!0,M.start(ei(R.current),z))}}},[x,A,l,n,g,R,M,S])}function Sa(e=[]){const t=e.map(c=>c?.reference),n=e.map(c=>c?.floating),r=e.map(c=>c?.item),s=e.map(c=>c?.trigger),o=m.useCallback(c=>Ps(c,e,"reference"),t),i=m.useCallback(c=>Ps(c,e,"floating"),n),a=m.useCallback(c=>Ps(c,e,"item"),r),l=m.useCallback(c=>Ps(c,e,"trigger"),s);return m.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:a,getTriggerProps:l}),[o,i,a,l])}function Ps(e,t,n){const r=new Map,s=n==="item",o={};n==="floating"&&(o.tabIndex=-1,o[Di]="");for(const i in e)s&&e&&(i===wd||i===kd)||(o[i]=e[i]);for(let i=0;i<t.length;i+=1){let a;const l=t[i]?.[n];typeof l=="function"?a=e?l(e):null:a=l,a&&gc(o,a,s,r)}return gc(o,e,s,r),o}function gc(e,t,n,r){for(const s in t){const o=t[s];n&&(s===wd||s===kd)||(s.startsWith("on")?(r.has(s)||r.set(s,[]),typeof o=="function"&&(r.get(s)?.push(o),e[s]=(...i)=>r.get(s)?.map(a=>a(...i)).find(a=>a!==void 0))):e[s]=o)}}const Fx=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function bf(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingId"),o=n.useState("domReferenceElement"),i=n.useState("floatingElement"),{enabled:a=!0,role:l="dialog"}=t,c=ts(),u=o?.id||c,d=m.useMemo(()=>Pi(i)?.id||s,[i,s]),f=Fx.get(l)??l,p=Yn()!=null,g=m.useMemo(()=>f==="tooltip"||l==="label"?Nn:{"aria-haspopup":f==="alertdialog"?"dialog":f,"aria-expanded":"false",...f==="listbox"&&{role:"combobox"},...f==="menu"&&p&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[f,p,l]),y=m.useMemo(()=>f==="tooltip"||l==="label"?{[`aria-${l==="label"?"labelledby":"describedby"}`]:r?d:void 0}:{...g,"aria-expanded":r?"true":"false","aria-controls":r?d:void 0,...f==="menu"&&{id:u}},[f,d,r,u,l,g]),w=m.useMemo(()=>{const v={id:d,...f&&{role:f}};return f==="tooltip"||l==="label"?v:{...v,...f==="menu"&&{"aria-labelledby":u}}},[f,d,u,l]),x=m.useCallback(({active:v,selected:k})=>{const S={role:"option",...v&&{id:`${d}-fui-option`}};switch(l){case"select":case"combobox":return{...S,"aria-selected":k}}return{}},[d,l]);return m.useMemo(()=>a?{reference:y,floating:w,item:x,trigger:g}:{},[a,y,w,g,x])}function yc(e,t){const[n,r]=e;let s=!1;const o=t.length;for(let i=0,a=o-1;i<o;a=i++){const[l,c]=t[i]||[0,0],[u,d]=t[a]||[0,0];c>=r!=d>=r&&n<=(u-l)*(r-c)/(d-c)+l&&(s=!s)}return s}function jx(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Lx(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,s=new gn;let o=!1,i=null,a=null,l=typeof performance<"u"?performance.now():0;function c(d,f){const h=performance.now(),p=h-l;if(i===null||a===null||p===0)return i=d,a=f,l=h,null;const g=d-i,y=f-a,x=Math.sqrt(g*g+y*y)/p;return i=d,a=f,l=h,x}const u=({x:d,y:f,placement:h,elements:p,onClose:g,nodeId:y,tree:w})=>function(v){function k(){s.clear(),g()}if(s.clear(),!p.domReference||!p.floating||h==null||d==null||f==null)return;const{clientX:S,clientY:C}=v,M=[S,C],D=dt(v),F=v.type==="mouseleave",T=we(p.floating,D),R=we(p.domReference,D),A=p.domReference.getBoundingClientRect(),E=p.floating.getBoundingClientRect(),j=h.split("-")[0],N=d>E.right-E.width/2,V=f>E.bottom-E.height/2,U=jx(M,A),P=E.width>A.width,I=E.height>A.height,B=(P?A:E).left,W=(P?A:E).right,Q=(I?A:E).top,Y=(I?A:E).bottom;if(T&&(o=!0,!F))return;if(R&&(o=!1),R&&!F){o=!0;return}if(F&&Ae(v.relatedTarget)&&we(p.floating,v.relatedTarget)||w&&Fn(w.nodesRef.current,y).some(({context:Z})=>Z?.open))return;if(j==="top"&&f>=A.bottom-1||j==="bottom"&&f<=A.top+1||j==="left"&&d>=A.right-1||j==="right"&&d<=A.left+1)return k();let $=[];switch(j){case"top":$=[[B,A.top+1],[B,E.bottom-1],[W,E.bottom-1],[W,A.top+1]];break;case"bottom":$=[[B,E.top+1],[B,A.bottom-1],[W,A.bottom-1],[W,E.top+1]];break;case"left":$=[[E.right-1,Y],[E.right-1,Q],[A.left+1,Q],[A.left+1,Y]];break;case"right":$=[[A.right-1,Y],[A.right-1,Q],[E.left+1,Q],[E.left+1,Y]];break}function z([Z,ce]){switch(j){case"top":{const Se=[P?Z+t/2:N?Z+t*4:Z-t*4,ce+t+1],Re=[P?Z-t/2:N?Z+t*4:Z-t*4,ce+t+1],Ee=[[E.left,N||P?E.bottom-t:E.top],[E.right,N?P?E.bottom-t:E.top:E.bottom-t]];return[Se,Re,...Ee]}case"bottom":{const Se=[P?Z+t/2:N?Z+t*4:Z-t*4,ce-t],Re=[P?Z-t/2:N?Z+t*4:Z-t*4,ce-t],Ee=[[E.left,N||P?E.top+t:E.bottom],[E.right,N?P?E.top+t:E.bottom:E.top+t]];return[Se,Re,...Ee]}case"left":{const Se=[Z+t+1,I?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z+t+1,I?ce-t/2:V?ce+t*4:ce-t*4];return[...[[V||I?E.right-t:E.left,E.top],[V?I?E.right-t:E.left:E.right-t,E.bottom]],Se,Re]}case"right":{const Se=[Z-t,I?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z-t,I?ce-t/2:V?ce+t*4:ce-t*4],Ee=[[V||I?E.left+t:E.right,E.top],[V?I?E.left+t:E.right:E.left+t,E.bottom]];return[Se,Re,...Ee]}default:return[]}}if(!yc([S,C],$)){if(o&&!U)return k();if(!F&&r){const Z=c(v.clientX,v.clientY);if(Z!==null&&Z<.1)return k()}yc([S,C],z([d,f]))?!o&&r&&s.start(40,k):k()}};return u.__options={blockPointerEvents:n},u}function Vx(e){const t=m.useRef(""),n=m.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:m.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s&&e(s,s.pointerType),e(s,t.current),t.current=""},[e]),onPointerDown:n}}function xf(e){const[t,n]=m.useState(null),r=he((a,l)=>{e||n(l||(vd?"touch":""))}),s=m.useCallback(()=>{n(null)},[]),{onClick:o,onPointerDown:i}=Vx(r);return m.useMemo(()=>({openMethod:t,reset:s,triggerProps:{onClick:o,onPointerDown:i}}),[t,s,o,i])}let Pt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Gr.startingStyle]="startingStyle",e[e.endingStyle=Gr.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),Fi=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const _x={[Fi.popupOpen]:""},Wx={[Fi.popupOpen]:"",[Fi.pressed]:""},Bx={[Pt.open]:""},$x={[Pt.closed]:""},Yx={[Pt.anchorHidden]:""},Hx={open(e){return e?_x:null}},Ux={open(e){return e?Wx:null}},os={open(e){return e?Bx:$x},anchorHidden(e){return e?Yx:null}};function vf(e){return ad(19)?e:e?"true":void 0}let bc={},xc={},vc="";function Gx(e){if(typeof document>"u")return!1;const t=$n(e);return vt(t).innerWidth-t.documentElement.clientWidth>0}function Kx(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=$n(e).documentElement,s={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY};r.style.scrollbarGutter="stable",r.style.overflowY="scroll";const o=r.offsetWidth;r.style.overflowY="hidden";const i=r.offsetWidth;return Object.assign(r.style,s),o===i}function zx(e){const t=$n(e),n=t.documentElement,r=t.body,s=rs(n)?n:r,o=s.style.overflow;return s.style.overflow="hidden",()=>{s.style.overflow=o}}function qx(e){const t=$n(e),n=t.documentElement,r=t.body,s=vt(n);let o=0,i=0,a=!1;const l=Vt.create();if(vy&&(s.visualViewport?.scale??1)!==1)return()=>{};function c(){const f=s.getComputedStyle(n),h=s.getComputedStyle(r),y=(f.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,bc={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},vc=n.style.scrollBehavior,xc={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const w=n.scrollHeight>n.clientHeight,x=n.scrollWidth>n.clientWidth,v=f.overflowY==="scroll"||h.overflowY==="scroll",k=f.overflowX==="scroll"||h.overflowX==="scroll",S=Math.max(0,s.innerWidth-r.clientWidth),C=Math.max(0,s.innerHeight-r.clientHeight),M=parseFloat(h.marginTop)+parseFloat(h.marginBottom),D=parseFloat(h.marginLeft)+parseFloat(h.marginRight),F=rs(n)?n:r;if(a=Kx(e),a){n.style.scrollbarGutter=y,F.style.overflowY="hidden",F.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:y,overflowY:"hidden",overflowX:"hidden"}),(w||v)&&(n.style.overflowY="scroll"),(x||k)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:M||C?`calc(100dvh - ${M+C}px)`:"100dvh",width:D||S?`calc(100vw - ${D+S}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,bc),Object.assign(r.style,xc),a||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=vc)}function d(){u(),l.request(c)}return c(),s.addEventListener("resize",d),()=>{l.cancel(),u(),typeof s.removeEventListener=="function"&&s.removeEventListener("resize",d)}}class Xx{lockCount=0;restore=null;timeoutLock=gn.create();timeoutUnlock=gn.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=$n(t).documentElement,s=vt(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ld;return}const o=vd||!Gx(t);this.restore=o?zx(t):qx(t)}}const Zx=new Xx;function wf(e=!0,t=null){Te(()=>{if(e)return Zx.acquire(t)},[e,t])}const Qx=m.createContext(void 0);function Jx(){return m.useContext(Qx)?.direction??"ltr"}const ev=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0,offsetParent:d="real"}=nn(e,t)||{};if(c==null)return{};const f=Ed(u),h={x:n,y:r},p=ma(s),g=ha(p),y=await i.getDimensions(c),w=p==="y",x=w?"top":"left",v=w?"bottom":"right",k=w?"clientHeight":"clientWidth",S=o.reference[g]+o.reference[p]-h[p]-o.floating[g],C=h[p]-o.reference[p],M=d==="real"?await i.getOffsetParent?.(c):a.floating;let D=a.floating[k]||o.floating[g];(!D||!await i.isElement?.(M))&&(D=a.floating[k]||o.floating[g]);const F=S/2-C/2,T=D/2-y[g]/2-1,R=Math.min(f[x],T),A=Math.min(f[v],T),E=R,j=D-y[g]-A,N=D/2-y[g]/2+F,V=Ri(E,N,j),U=!l.arrow&&xn(s)!=null&&N!==V&&o.reference[g]/2-(N<E?R:A)-y[g]/2<0,P=U?N<E?N-E:N-j:0;return{[p]:h[p]+P,data:{[p]:V,centerOffset:N-V-P,...U&&{alignmentOffset:P}},reset:U}}}),tv=(e,t)=>({...ev(e),options:[e,t]}),nv={name:"hide",async fn(e){const{width:t,height:n,x:r,y:s}=e.rects.reference,o=t===0&&n===0&&r===0&&s===0;return{data:{referenceHidden:(await gx().fn(e)).data?.referenceHidden||o}}}},js={sideX:"left",sideY:"top"},rv={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:s},platform:o,strategy:i,placement:a}=e,l=vt(s),c=l.getComputedStyle(s);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:t,y:n,data:js};const d=await o.getOffsetParent?.(s);let f={width:0,height:0};if(i==="fixed"&&l?.visualViewport)f={width:l.visualViewport.width,height:l.visualViewport.height};else if(d===l){const x=$n(s);f={width:x.documentElement.clientWidth,height:x.documentElement.clientHeight}}else await o.isElement?.(d)&&(f=await o.getDimensions(d));const h=it(a);let p=t,g=n;h==="left"&&(p=f.width-(t+r.width)),h==="top"&&(g=f.height-(n+r.height));const y=h==="left"?"right":js.sideX,w=h==="top"?"bottom":js.sideY;return{x:p,y:g,data:{sideX:y,sideY:w}}}};function kf(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function wc(e,t,n){const{rects:r,placement:s}=e;return{side:kf(t,it(s),n),align:xn(s)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function sv(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:s=0,align:o="center",alignOffset:i=0,collisionBoundary:a,collisionPadding:l=5,sticky:c=!1,arrowPadding:u=5,disableAnchorTracking:d=!1,keepMounted:f=!1,floatingRootContext:h,mounted:p,collisionAvoidance:g,shiftCrossAxis:y=!1,nodeId:w,adaptiveOrigin:x,lazyFlip:v=!1,externalTree:k}=e,[S,C]=m.useState(null);!p&&S!==null&&C(null);const M=g.side||"flip",D=g.align||"flip",F=g.fallbackAxisSide||"end",T=typeof t=="function"?t:void 0,R=he(T),A=T?R:t,E=Bt(t),N=Jx()==="rtl",V=S||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":N?"left":"right","inline-start":N?"right":"left"}[r],U=o==="center"?V:`${V}-${o}`;let P=l;const I=1,B=r==="bottom"?I:0,W=r==="top"?I:0,Q=r==="right"?I:0,Y=r==="left"?I:0;typeof P=="number"?P={top:P+B,right:P+Y,bottom:P+W,left:P+Q}:P&&(P={top:(P.top||0)+B,right:(P.right||0)+Y,bottom:(P.bottom||0)+W,left:(P.left||0)+Q});const $={boundary:a==="clipping-ancestors"?"clippingAncestors":a,padding:P},z=m.useRef(null),Z=Bt(s),ce=Bt(i),Ee=[dx(De=>{const Ye=wc(De,r,N),re=typeof Z.current=="function"?Z.current(Ye):Z.current,G=typeof ce.current=="function"?ce.current(Ye):ce.current;return{mainAxis:re,crossAxis:G,alignmentAxis:G}},[typeof s!="function"?s:0,typeof i!="function"?i:0,N,r])],Je=D==="none"&&M!=="shift",L=!Je&&(c||y||M==="shift"),ue=M==="none"?null:mx({...$,padding:{top:P.top+I,right:P.right+I,bottom:P.bottom+I,left:P.left+I},mainAxis:!y&&M==="flip",crossAxis:D==="flip"?"alignment":!1,fallbackAxisSideDirection:F}),te=Je?null:fx(De=>{const Ye=$n(De.elements.floating).documentElement;return{...$,rootBoundary:y?{x:0,y:0,width:Ye.clientWidth,height:Ye.clientHeight}:void 0,mainAxis:D!=="none",crossAxis:L,limiter:c||y?void 0:hx(re=>{if(!z.current)return{};const{width:G,height:oe}=z.current.getBoundingClientRect(),de=yt(it(re.placement)),xe=de==="y"?G:oe,fe=de==="y"?P.left+P.right:P.top+P.bottom;return{offset:xe/2+fe/2}})}},[$,c,y,P,D]);M==="shift"||D==="shift"||o==="center"?Ee.push(te,ue):Ee.push(ue,te),Ee.push(px({...$,apply({elements:{floating:De},rects:{reference:Ye},availableWidth:re,availableHeight:G}){Object.entries({"--available-width":`${re}px`,"--available-height":`${G}px`,"--anchor-width":`${Ye.width}px`,"--anchor-height":`${Ye.height}px`}).forEach(([oe,de])=>{De.style.setProperty(oe,de)})}}),tv(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(De){const{elements:Ye,middlewareData:re,placement:G,rects:oe,y:de}=De,xe=it(G),fe=yt(xe),It=z.current,wn=re.arrow?.x||0,kn=re.arrow?.y||0,ln=It?.clientWidth||0,cn=It?.clientHeight||0,zt=wn+ln/2,Er=kn+cn/2,Ft=Math.abs(re.shift?.y||0),tt=oe.reference.height/2,Sn=typeof s=="function"?s(wc(De,r,N)):s,ps=Ft>Sn,Co={top:`${zt}px calc(100% + ${Sn}px)`,bottom:`${zt}px ${-Sn}px`,left:`calc(100% + ${Sn}px) ${Er}px`,right:`${-Sn}px ${Er}px`}[xe],lt=`${zt}px ${oe.reference.y+tt-de}px`;return Ye.floating.style.setProperty("--transform-origin",L&&fe==="y"&&ps?lt:Co),{}}},nv,x),Te(()=>{!p&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[p,h]);const Me=m.useMemo(()=>({elementResize:!d&&typeof ResizeObserver<"u",layoutShift:!d&&typeof IntersectionObserver<"u"}),[d]),{refs:H,elements:se,x:ie,y:me,middlewareData:ge,update:J,placement:ne,context:Ie,isPositioned:be,floatingStyles:_e}=Mx({rootContext:h,placement:U,middleware:Ee,strategy:n,whileElementsMounted:f?void 0:(...De)=>mc(...De,Me),nodeId:w,externalTree:k}),{sideX:Ge,sideY:ot}=ge.adaptiveOrigin||js,Oe=be?n:"fixed",ye=m.useMemo(()=>x?{position:Oe,[Ge]:ie,[ot]:me}:{position:Oe,..._e},[x,Oe,Ge,ie,ot,me,_e]),Fe=m.useRef(null);Te(()=>{if(!p)return;const De=E.current,Ye=typeof De=="function"?De():De,G=(kc(Ye)?Ye.current:Ye)||null||null;G!==Fe.current&&(H.setPositionReference(G),Fe.current=G)},[p,H,A,E]),m.useEffect(()=>{if(!p)return;const De=E.current;typeof De!="function"&&kc(De)&&De.current!==Fe.current&&(H.setPositionReference(De.current),Fe.current=De.current)},[p,H,A,E]),m.useEffect(()=>{if(f&&p&&se.domReference&&se.floating)return mc(se.domReference,se.floating,J,Me)},[f,p,se,J,Me]);const $e=it(ne),Nt=kf(r,$e,N),kt=xn(ne)||"center",et=!!ge.hide?.referenceHidden;Te(()=>{v&&p&&be&&C($e)},[v,p,be,$e]);const an=m.useMemo(()=>({position:"absolute",top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),at=ge.arrow?.centerOffset!==0;return m.useMemo(()=>({positionerStyles:ye,arrowStyles:an,arrowRef:z,arrowUncentered:at,side:Nt,align:kt,physicalSide:$e,anchorHidden:et,refs:H,context:Ie,isPositioned:be,update:J}),[ye,an,z,at,Nt,kt,$e,et,H,Ie,be,J])}function kc(e){return e!=null&&"current"in e}const Sf=m.forwardRef(function(t,n){const{cutout:r,...s}=t;let o;if(r){const i=r?.getBoundingClientRect();o=`polygon(
|
|
2
2
|
0% 0%,
|
|
3
3
|
100% 0%,
|
|
4
4
|
100% 100%,
|