tokentracker-cli 0.4.1 → 0.4.2
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-CSL_afwz.js → DashboardPage-Z2qqLFsJ.js} +1 -1
- package/dashboard/dist/assets/{LandingExtras-C8i8_OxM.js → LandingExtras-6NtvaOYM.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-T8OluU3F.js → LeaderboardPage-BV3NE1hK.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-D5ICOqlT.js → LeaderboardProfilePage-DM1XAgY4.js} +1 -1
- package/dashboard/dist/assets/{MatrixRain-DNKwhCXo.js → MatrixRain-B9PMNiTr.js} +1 -1
- package/dashboard/dist/assets/{MatrixShell-BZu61EY7.js → MatrixShell-Bjpqen-T.js} +1 -1
- package/dashboard/dist/assets/{main-DGPBnxuf.js → main-Bo8e66-R.js} +4 -4
- package/dashboard/dist/assets/{vibeusage-api-BpxQVR5V.js → vibeusage-api-CXScOK2G.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +24 -1
- package/src/commands/sync.js +5 -2
- package/src/lib/browser-auth.js +108 -4
- package/src/lib/rollout.js +102 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,u as bn,i as _g,a as rt,g as Wg,b as yr,c as br,d as Bt,e as Oi,f as Ts,h as go,j as da,k as cr,t as xt,l as _,T as Bg,m as y,n as Te,o as $n,p as hd,q as md,s as he,N as pd,v as ts,w as ns,x as pn,y as Le,z as Hr,E as jn,A as $g,B as on,C as Yl,D as dt,F as gd,G as vt,H as At,I as mn,J as or,K as Ae,L as an,M as Hl,O as fa,P as ha,Q as ur,R as In,S as Yg,U as yd,V as Hg,W as rs,X as yo,Y as bd,Z as Ug,_ as xd,$ as Gg,a0 as vd,a1 as wd,a2 as q,a3 as ma,a4 as kd,a5 as Kg,a6 as zg,a7 as qg,a8 as Xg,a9 as Zg,aa as Qg,ab as Jg,ac as ey,ad as Jt,ae as ty,af as ny,ag as Vo}from"./main-DGPBnxuf.js";import{g as ry,a as pa,b as sy,c as oy,d as iy,e as _o,f as ay,r as ly,h as Ul,i as cy,j as uy,t as dy,s as fy}from"./vibeusage-api-BpxQVR5V.js";const hy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),my=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Gl=e=>{const t=my(e);return t.charAt(0).toUpperCase()+t.slice(1)},Sd=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),py=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var gy={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 yy=h.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...a},l)=>h.createElement("svg",{ref:l,...gy,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Sd("lucide",s),...!o&&!py(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,u])=>h.createElement(c,u)),...Array.isArray(o)?o:[o]]));const by=(e,t)=>{const n=h.forwardRef(({className:r,...s},o)=>h.createElement(yy,{ref:o,iconNode:t,className:Sd(`lucide-${hy(Gl(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Gl(e),n};const xy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],vy=by("info",xy),wy=500,ky={style:{transition:"none"}},Td="data-base-ui-click-trigger",Sy={fallbackAxisSide:"end"},Ty={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Cy=[];function ga(e){h.useEffect(e,Cy)}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 _n(){const e=bn(gn.create).current;return ga(e.disposeEffect),e}function Yn(e){return e?.ownerDocument||document}const xr=typeof navigator<"u",Wo=Py(),Cd=Oy(),Ed=Ry(),Ey=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Md=Wo.platform==="MacIntel"&&Wo.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Wo.platform),My=xr&&/apple/i.test(navigator.vendor),Ai=xr&&/android/i.test(Cd)||/android/i.test(Ed);xr&&Cd.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Dy=Ed.includes("jsdom/");function Py(){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 Ry(){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 Oy(){if(!xr)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Ni="data-base-ui-focusable",Dd="active",Pd="selected",Rd="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Jn(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&&_g(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function ft(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 Ay(e){return e.matches("html,body")}function qe(e){return e?.ownerDocument||document}function Od(e){return rt(e)&&e.matches(Rd)}function Kl(e){return e?e.getAttribute("role")==="combobox"&&Od(e):!1}function ji(e){return e?e.hasAttribute(Ni)?e:e.querySelector(`[${Ni}]`)||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 zl(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 Ny(e){e.preventDefault(),e.stopPropagation()}function jy(e){return"nativeEvent"in e}function Iy(e){return e.mozInputSource===0&&e.isTrusted?!0:Ai&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Fy(e){return Dy?!1:!Ai&&e.width===0&&e.height===0||Ai&&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 Ad(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Ly=["top","right","bottom","left"],fr=Math.min,ht=Math.max,Xs=Math.round,Cs=Math.floor,Ut=e=>({x:e,y:e}),Vy={left:"right",right:"left",bottom:"top",top:"bottom"};function Ii(e,t,n){return ht(e,fr(t,n))}function rn(e,t){return typeof e=="function"?e(t):e}function at(e){return e.split("-")[0]}function xn(e){return e.split("-")[1]}function ya(e){return e==="x"?"y":"x"}function ba(e){return e==="y"?"height":"width"}function yt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function xa(e){return ya(yt(e))}function _y(e,t,n){n===void 0&&(n=!1);const r=xn(e),s=xa(e),o=ba(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=Zs(i)),[i,Zs(i)]}function Wy(e){const t=Zs(e);return[Fi(e),t,Fi(t)]}function Fi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ql=["left","right"],Xl=["right","left"],By=["top","bottom"],$y=["bottom","top"];function Yy(e,t,n){switch(e){case"top":case"bottom":return n?t?Xl:ql:t?ql:Xl;case"left":case"right":return t?By:$y;default:return[]}}function Hy(e,t,n,r){const s=xn(e);let o=Yy(at(e),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),t&&(o=o.concat(o.map(Fi)))),o}function Zs(e){const t=at(e);return Vy[t]+e.slice(t.length)}function Uy(e){return{top:0,right:0,bottom:0,left:0,...e}}function Nd(e){return typeof e!="number"?Uy(e):{top:e,right:e,bottom:e,left:e}}function Qs(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 Gy=["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] *)"],Js=Gy.join(","),jd=typeof Element>"u",hr=jd?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,eo=!jd&&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},to=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]"):to(t.parentNode));return i},Ky=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Id=function(t,n,r){if(to(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(Js));return n&&hr.call(t,Js)&&s.unshift(t),s=s.filter(r),s},no=function(t,n,r){for(var s=[],o=Array.from(t);o.length;){var i=o.shift();if(!to(i,!1))if(i.tagName==="SLOT"){var a=i.assignedElements(),l=a.length?a:i.children,c=no(l,!0,r);r.flatten?s.push.apply(s,c):s.push({scopeParent:i,candidates:c})}else{var u=hr.call(i,Js);u&&r.filter(i)&&(n||!t.includes(i))&&s.push(i);var d=i.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(i),f=!to(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(i));if(d&&f){var m=no(d===!0?i.children:d.children,!0,r);r.flatten?s.push.apply(s,m):s.push({scopeParent:i,candidates:m})}else o.unshift.apply(o,i.children)}}return s},Fd=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Ld=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Ky(t))&&!Fd(t)?0:t.tabIndex},zy=function(t,n){var r=Ld(t);return r<0&&n&&!Fd(t)?0:r},qy=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Vd=function(t){return t.tagName==="INPUT"},Xy=function(t){return Vd(t)&&t.type==="hidden"},Zy=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},Qy=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},Jy=function(t){if(!t.name)return!0;var n=t.form||eo(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=Qy(s,t.form);return!o||o===t},eb=function(t){return Vd(t)&&t.type==="radio"},tb=function(t){return eb(t)&&!Jy(t)},nb=function(t){var n,r=t&&eo(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=eo(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},Zl=function(t){var n=t.getBoundingClientRect(),r=n.width,s=n.height;return r===0&&s===0},rb=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=eo(t);if(c&&!c.shadowRoot&&s(c)===!0)return Zl(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(nb(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Zl(t);return!1},sb=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},Li=function(t,n){return!(n.disabled||Xy(n)||rb(n,t)||Zy(n)||sb(n))},Vi=function(t,n){return!(tb(n)||Ld(n)<0||!Li(t,n))},ob=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},_d=function(t){var n=[],r=[];return t.forEach(function(s,o){var i=!!s.scopeParent,a=i?s.scopeParent:s,l=zy(a,i),c=i?_d(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(qy).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=no([t],n.includeContainer,{filter:Vi.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:ob}):r=Id(t,n.includeContainer,Vi.bind(null,n)),_d(r)},ib=function(t,n){n=n||{};var r;return n.getShadowRoot?r=no([t],n.includeContainer,{filter:Li.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Id(t,n.includeContainer,Li.bind(null,n)),r},Wd=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return hr.call(t,Js)===!1?!1:Vi(n,t)};const vr=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Bd(e,t){const n=ss(e,vr()),r=n.length;if(r===0)return;const s=Jn(qe(e)),o=n.indexOf(s),i=o===-1?t===1?0:r-1:o+t;return n[i]}function va(e){return Bd(qe(e).body,1)||e}function $d(e){return Bd(qe(e).body,-1)||e}function Yd(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 ab(e){return Yd(e,1)}function lb(e){return Yd(e,-1)}function ir(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!we(n,r)}function cb(e){ss(e,vr()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Ql(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 ub({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:s="sun",cacheKey:o,timeZone:i,tzOffsetMinutes:a,now:l}={}){const c=h.useMemo(()=>Wg({weeks:r,weekStartsOn:s,now:l}),[l,r,s]),[u,d]=h.useState([]),[f,m]=h.useState(null),[p,g]=h.useState("edge"),[b,w]=h.useState(!1),[x,v]=h.useState(null),k=yr(),S=br(t),C=!n,D=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),E=h.useMemo(()=>{if(!o)return null;const I=go({timeZone:i,offsetMinutes:a});return`vibeusage.heatmap.${o}.${r}.${s}.${I}`},[o,i,a,r,s]),O=h.useCallback(()=>{if(!E||typeof window>"u")return null;try{const I=window.localStorage.getItem(E);if(!I)return null;const j=JSON.parse(I);return!j||!j.heatmap?null:j}catch{return null}},[E]),T=h.useCallback(I=>{if(!(!E||typeof window>"u"))try{window.localStorage.setItem(E,JSON.stringify(I))}catch{}},[E]),R=h.useCallback(()=>{if(!(!E||typeof window>"u"))try{window.localStorage.removeItem(E)}catch{}},[E]),A=h.useCallback(async()=>{const I=await Bt(t);if(!(!I&&!k&&!D)){w(!0),v(null);try{try{const P=await ry({baseUrl:e,accessToken:I,weeks:r,to:c.to,weekStartsOn:s,timeZone:i,tzOffsetMinutes:a}),F=Array.isArray(P?.weeks)?P.weeks:[];if(!F.length&&C){const B=O();if(B?.heatmap){m(B.heatmap),d(B.daily||[]),g("cache");return}}if(!F.some(B=>(Array.isArray(B)?B:[]).some(Q=>Q&&Number.isFinite(Number(Q.level))))&&F.length){const B=[];for(const Y of F)for(const $ of Array.isArray(Y)?Y:[])$?.day&&B.push({day:$.day,total_tokens:$.total_tokens??$.value??0,billable_total_tokens:$.billable_total_tokens??$.value??$.total_tokens??0});const Q=Oi({dailyRows:B,weeks:r,to:P?.to||c.to,weekStartsOn:s});d(B),m({...Q,week_starts_on:s,active_days:B.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:Ts({dailyRows:B,to:P?.to||c.to})}),g("client"),C?T({heatmap:{...Q,week_starts_on:s,active_days:B.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:Ts({dailyRows:B,to:P?.to||c.to})},daily:B,fetchedAt:new Date().toISOString()}):R();return}m(P||null),d([]),g("edge"),P&&C?T({heatmap:P,daily:[],fetchedAt:new Date().toISOString()}):C||R();return}catch(P){const F=P,W=F?.status??F?.statusCode;if(W===401||W===403)throw P}const j=await pa({baseUrl:e,accessToken:I,from:c.from,to:c.to,timeZone:i,tzOffsetMinutes:a}),V=Array.isArray(j?.data)?j.data:[];d(V);const U=Oi({dailyRows:V,weeks:r,to:c.to,weekStartsOn:s});m({...U,week_starts_on:s,active_days:V.filter(P=>Number(P?.billable_total_tokens??P?.total_tokens)>0).length,streak_days:Ts({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:Ts({dailyRows:V,to:c.to})},daily:V,fetchedAt:new Date().toISOString()}):R()}catch(j){if(C){const V=O();if(V?.heatmap)m(V.heatmap),d(V.daily||[]),g("cache"),v(null);else{const U=j;v(U?.message||String(U)),d([]),m(null),g("edge")}}else{const V=j;v(V?.message||String(V)),d([]),m(null),g("edge")}}finally{w(!1)}}},[t,e,k,n,C,c.from,c.to,O,S,i,a,s,r,R,T,D]);return h.useEffect(()=>{if(!S&&!n&&!k&&!D){d([]),w(!1),v(null),m(null),g("edge");return}if(!C)R(),d([]),v(null),m(null),g("edge");else{const I=O();I?.heatmap&&(m(I.heatmap),d(I.daily||[]),g("cache"))}A()},[t,k,O,A,S,n,C,R,D]),{range:c,daily:u,heatmap:f,source:k?"mock":p==="client"?"edge":p,loading:b,error:x,refresh:A}}function db({baseUrl:e,accessToken:t,limit:n=3,from:r,to:s,source:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=h.useState([]),[u,d]=h.useState(!1),[f,m]=h.useState(null),p=yr(),g=br(t),b=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),w=h.useCallback(async()=>{const x=await Bt(t);if(!x&&!p&&!b){c([]),m(null),d(!1);return}d(!0),m(null);try{const v=await sy({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);m(k),c([])}finally{d(!1)}},[t,e,r,n,p,o,i,s,a,b]);return h.useEffect(()=>{if(!g&&!p&&!b){c([]),m(null),d(!1);return}w()},[p,w,g,b]),{entries:l,loading:u,error:f,refresh:w}}const fb=24;function hb({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:s,to:o,months:i=fb,cacheKey:a,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:d,sharedRange:f}={}){const[m,p]=h.useState([]),[g,b]=h.useState(()=>({from:s,to:o})),[w,x]=h.useState("edge"),[v,k]=h.useState(null),[S,C]=h.useState(!1),[D,E]=h.useState(null),O=yr(),T=br(t),R=!n,A=Array.isArray(d),M=f?.from||s,I=f?.to||o,j=h.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),V=(()=>{if(!a)return null;const Y=mb(e)||"default",$=go({timeZone:l,offsetMinutes:c});if(j==="hourly")return`vibeusage.trend.${a}.${Y}.hourly.${o||s||"day"}.${$}`;if(j==="monthly")return`vibeusage.trend.${a}.${Y}.monthly.${i}.${o||"today"}.${$}`;const z=`${s||""}.${o||""}`;return`vibeusage.trend.${a}.${Y}.daily.${z}.${$}`})(),U=h.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=h.useCallback(Y=>{if(!(!V||typeof window>"u"))try{window.localStorage.setItem(V,JSON.stringify(Y))}catch{}},[V]),F=h.useCallback(()=>{if(!(!V||typeof window>"u"))try{window.localStorage.removeItem(V)}catch{}},[V]),W=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=h.useCallback(async()=>{if(A){p(Array.isArray(d)?d:[]),b({from:M,to:I}),x("shared"),k(null),C(!1),E(null);return}const Y=await Bt(t);if(!(!Y&&!O&&!W)){C(!0),E(null);try{let $;j==="hourly"?$=await oy({baseUrl:e,accessToken:Y,day:o||s,timeZone:l,tzOffsetMinutes:c}):j==="monthly"?$=await iy({baseUrl:e,accessToken:Y,months:i,to:o,timeZone:l,tzOffsetMinutes:c}):$=await pa({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:[];j==="daily"?ce=$o(ce,z||s,Z||o,{timeZone:l,offsetMinutes:c,now:u}):j==="hourly"?ce=Yo(ce,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(ce=Ho(ce,{timeZone:l,offsetMinutes:c,now:u}));const Se=new Date().toISOString();p(ce),b({from:z,to:Z}),x("edge"),k(Se),R?P({rows:ce,from:z,to:Z,mode:j,fetchedAt:Se}):F()}catch($){if(R){const z=U();if(z?.rows){let Z=j==="daily"?$o(z.rows||[],z.from||s,z.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(z.rows)?z.rows:[];j==="hourly"?Z=Yo(Z,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(Z=Ho(Z,{timeZone:l,offsetMinutes:c,now:u})),p(Z),b({from:z.from||s,to:z.to||o}),x("cache"),k(z.fetchedAt||null),E(null)}else{p([]),b({from:s,to:o}),x("edge"),k(null);const Z=$;E(Z?.message||String(Z))}}else{p([]),b({from:s,to:o}),x("edge"),k(null);const z=$;E(z?.message||String(z))}}finally{C(!1)}}},[t,e,s,O,n,R,j,i,U,T,A,M,d,I,l,o,c,u,F,P,W]);h.useEffect(()=>{if(A){p(Array.isArray(d)?d:[]),b({from:M,to:I}),x("shared"),k(null),C(!1),E(null);return}if(!T&&!n&&!O&&!W){p([]),b({from:s,to:o}),E(null),C(!1),x("edge"),k(null);return}if(!R)F(),p([]),b({from:s,to:o}),E(null),x("edge"),k(null);else{const Y=U();if(Y?.rows){let $=j==="daily"?$o(Y.rows||[],Y.from||s,Y.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(Y.rows)?Y.rows:[];j==="hourly"?$=Yo($,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&($=Ho($,{timeZone:l,offsetMinutes:c,now:u})),p($),b({from:Y.from||s,to:Y.to||o}),x("cache"),k(Y.fetchedAt||null)}}B()},[t,O,U,B,A,M,d,I,T,n,R,F,W]);const Q=O?"mock":w;return{rows:m,from:g.from||s,to:g.to||o,source:Q,fetchedAt:v,loading:S,error:D,refresh:B}}function mb(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 pb(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=da({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 m=[];for(let p=i;p<=a;p=pb(p,1)){const g=cr(p),b=f.get(g),w=p.getTime()>d;if(b){m.push({...b,missing:!1,future:w});continue}m.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 m}function Yo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Hd({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.hour||o?.label||"",a=gb(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 Ho(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Hd({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.month||o?.label||"",a=yb(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 Hd({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),{}),m=Number(f.year),p=Number(f.month),g=Number(f.day),b=Number(f.hour),w=Number(f.minute);if(Number.isFinite(m)&&Number.isFinite(p)&&Number.isFinite(g)&&Number.isFinite(b)&&Number.isFinite(w)){const x=b*2+(w>=30?1:0);return{year:m,month:p,day:g,hour:b,minute:w,dayNum:m*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,m=u.getUTCDate(),p=u.getUTCHours(),g=u.getUTCMinutes(),b=p*2+(g>=30?1:0);return{year:d,month:f,day:m,hour:p,minute:g,dayNum:d*1e4+f*100+m,slot:b}}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 gb(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 yb(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 Jl({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]=h.useState([]),[f,m]=h.useState(null),[p,g]=h.useState(null),[b,w]=h.useState("edge"),[x,v]=h.useState(null),[k,S]=h.useState(!1),[C,D]=h.useState(null),E=yr(),O=br(t),T=!n,R=(()=>{if(!i)return null;const P=bb(e)||"default",F=o?"daily":"summary",W=go({timeZone:a,offsetMinutes:l});return`vibeusage.usage.${i}.${P}.${r}.${s}.${F}.${W}`})(),A=h.useCallback(()=>{if(!R||typeof window>"u")return null;try{const P=window.localStorage.getItem(R);if(!P)return null;const F=JSON.parse(P);return!F||!F.summary?null:F}catch{return null}},[R]),M=h.useCallback(P=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(P))}catch{}},[R]),I=h.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),j=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),V=h.useCallback(async()=>{const P=await Bt(t);if(!(!P&&!E&&!j)){S(!0),D(null);try{let F=null,W=null;if(o){const[z,Z]=await Promise.allSettled([pa({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l}),_o({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0})]);if(z.status==="rejected")throw z.reason;F=z.value,W=Z.status==="fulfilled"?Z.value:null}else W=await _o({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0});let B=o&&Array.isArray(F?.data)?F.data:[];o&&(B=Go(B,r,s,{timeZone:a,offsetMinutes:l,now:c}));let Q=W?.totals||F?.summary?.totals||null,Y=W?.rolling||F?.summary?.rolling||null;if(o&&!Q&&!W)try{const z=await _o({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(B),m(Q),g(Y),w("edge"),v($),Q&&T?M({summary:Q,rolling:Y,daily:B,from:r,to:s,includeDaily:o,fetchedAt:$}):T||I()}catch(F){if(T){const W=A();if(W?.summary){m(W.summary),g(W.rolling||null);const B=Array.isArray(W.daily)?W.daily:[],Q=o?Go(B,W.from||r,W.to||s,{timeZone:a,offsetMinutes:l,now:c}):B;d(Q),w("cache"),v(W.fetchedAt||null),D(null)}else{const B=F;D(B?.message||String(B)),d([]),m(null),g(null),w("edge"),v(null)}}else{const W=F;D(W?.message||String(W)),d([]),m(null),g(null),w("edge"),v(null)}}finally{S(!1)}}},[t,e,r,o,E,n,T,c,A,O,a,s,l,I,M,j]);return h.useEffect(()=>{const P=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!O&&!n&&!E&&!P){d([]),m(null),g(null),D(null),S(!1),w("edge"),v(null);return}if(!T)I(),d([]),m(null),g(null),D(null),w("edge"),v(null);else{const F=A();if(F?.summary){m(F.summary),g(F.rolling||null);const W=Array.isArray(F.daily)?F.daily:[],B=o?Go(W,F.from||r,F.to||s,{timeZone:a,offsetMinutes:l,now:c}):W;d(B),w("cache"),v(F.fetchedAt||null)}}V()},[t,E,A,V,O,n,T,I,j]),{daily:u,summary:f,rolling:p,source:E?"mock":b,fetchedAt:x,loading:k,error:C,refresh:V}}function bb(e){try{return new URL(e).host}catch{return null}}function Uo(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 xb(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Go(e,t,n,{timeZone:r,offsetMinutes:s,now:o}={}){const i=Uo(t),a=Uo(n);if(!i||!a||a<i)return Array.isArray(e)?e:[];const l=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,c=da({timeZone:r,offsetMinutes:s,date:l}),u=Uo(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const m=[];for(let p=i;p<=a;p=xb(p,1)){const g=cr(p),b=f.get(g),w=p.getTime()>d;if(b){m.push({...b,missing:!1,future:w});continue}m.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 m}function vb({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:s,cacheKey:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=h.useState(null),[u,d]=h.useState("edge"),[f,m]=h.useState(!1),[p,g]=h.useState(null),b=yr(),w=br(t),x=!n,v=h.useMemo(()=>{if(!o)return null;const T=wb(e)||"default",R=go({timeZone:i,offsetMinutes:a});return`vibeusage.modelBreakdown.${o}.${T}.${r}.${s}.${R}`},[e,o,r,i,s,a]),k=h.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=h.useCallback(T=>{if(!(!v||typeof window>"u"))try{window.localStorage.setItem(v,JSON.stringify(T))}catch{}},[v]),C=h.useCallback(()=>{if(!(!v||typeof window>"u"))try{window.localStorage.removeItem(v)}catch{}},[v]),D=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),E=h.useCallback(async()=>{const T=await Bt(t);if(!(!T&&!b&&!D)){m(!0),g(null);try{const R=await ay({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 M=R;g(M?.message||String(M))}}else{c(null),d("edge");const A=R;g(A?.message||String(A))}}finally{m(!1)}}},[t,e,r,b,n,x,k,i,s,w,a,C,S,D]);return h.useEffect(()=>{if(!w&&!n&&!b&&!D){c(null),d("edge"),g(null),m(!1);return}if(!x)C(),c(null),d("edge"),g(null);else{const T=k();T?.breakdown&&(c(T.breakdown),d("cache"))}E()},[t,b,k,E,w,n,x,C,D]),{breakdown:l,source:b?"mock":u,loading:f,error:p,refresh:E}}function wb(e){try{return new URL(e).host}catch{return null}}const Ud=new Set(["day","hour","month"]);function kb(e){return Ud.has(e)}function ec(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 Sb(e,t){const n=ec(e),r=ec(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 Tb(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 Cb(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 Eb(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 Mb(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 Db(e,t,n){const r=n==="hour"?Mb:n==="month"?Eb:Cb,s=r(e),o=r(t);return s!=null&&o!=null?s===o?0:s<o?-1:1:Tb(e,t)}function Gd(e,{key:t,dir:n}){const r=n==="asc"?1:-1,s=Array.isArray(e)?e:[],o=Ud.has(t)?(a,l)=>Db(a,l,t):Sb,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 m=o(c,u);return m!==0?m*r:a.index-l.index}).map(a=>a.row)}const Pb=[{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 tc(e){const t=kb(e)?e:"day";return Pb.map((n,r)=>r===0?{...n,key:t}:n)}function nc(e,{key:t,dir:n}){return Gd(e,{key:t,dir:n})}const ro=12,Rb=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Ob(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 Ab(e){return Rb.some(t=>Ob(e?.[t]))}function Nb(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=Gd(t,{key:"month",dir:"asc"}),r=n.findIndex(s=>s?.month&&Ab(s));return r===-1?t:n.slice(r)}function jb(e,t,n=ro){const r=Array.isArray(e)?e:[],s=Number.isFinite(n)&&n>0?n:ro,i=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*s;return r.slice(i,i+s)}function Ib({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 Kd(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Fb(e){const t=Kd(e?.model_id);return t||null}function zd(e,t){return e?.model?String(e.model):t}function Lb(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 m=i.totalTokens>0?Math.round(f/i.totalTokens*1e3)/10:0,p=zd(d,n("shared.placeholder.short")),g=Fb(d),b=i.totalCost>0&&i.totalTokens>0?f/i.totalTokens*i.totalCost:null;return{id:g,name:p,share:m,usage:f,cost:b}}).filter(Boolean);return{label:a,totalPercent:String(c),usd:i.totalCost,usage:i.totalTokens,models:u}})}function Vb(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 m=Array.isArray(f?.models)?f.models:[];for(const p of m){const g=xt(p?.totals?.billable_total_tokens)??0;if(!Number.isFinite(g)||g<=0)continue;l+=g;const b=zd(p,r("shared.placeholder.short")),w=Kd(b);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,b))}}if(!o.size)return[];const c=Array.from(o.values()).reduce((f,m)=>f+m,0),u=l>0?l:c,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(o.entries()).map(([f,m])=>{const p=u>0?(m/u*100).toFixed(1):"0.0";return{id:f,name:i.get(f)||r("shared.placeholder.short"),tokens:m,percent:String(p)}}).sort((f,m)=>m.tokens!==f.tokens?m.tokens-f.tokens:String(f.name).localeCompare(String(m.name))).slice(0,d)}function wa(){const e=h.useContext(Bg);if(e===null)throw new Error("useTheme must be used within a ThemeProvider");return e}const En=12,Or=3,Ko=26,_b=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],Wb=["#064e3b","#065f46","#059669","#10b981","#34d399"],Bb=[_("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 $b(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 Yb(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 qd(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Hb(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function Ub(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return qd(e,-((r-n+7)%7))}function Gb(e,t,n){if(!e)return[];const r=Yb(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=Ub(r,n),i=qd(o,-(e-1)*7),a=[],l=new Set;for(const c of s){const u=Math.floor(Hb(i,c)/7);u<0||u>=e||l.has(u)||(l.add(u),a.push({label:Bb[c.getUTCMonth()],index:u}))}return a}function Kb({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:s}=wa(),i=s==="dark"?Wb:_b,a=h.useRef(null);h.useEffect(()=>{const p=a.current;p&&(p.scrollLeft=p.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=h.useMemo(()=>{const p=Array.isArray(e?.weeks)?e.weeks:[];if(!p.length)return{weeks:[]};const g=[];for(const b of p)for(const w of Array.isArray(b)?b:[])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 Oi({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=h.useMemo(()=>Gb(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return y.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:_("heatmap.empty")});const m=Ko+u.length*En+Math.max(0,u.length-1)*Or;return y.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:[y.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[y.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:_("heatmap.title")}),y.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||_("heatmap.legend.utc")})]}),y.jsx("div",{ref:a,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:y.jsxs("div",{style:{minWidth:m},children:[y.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${Ko}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[y.jsx("span",{}),f.map(p=>y.jsx("span",{style:{gridColumnStart:p.index+2},className:"whitespace-nowrap",children:p.label},`${p.label}-${p.index}`))]}),y.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${Ko}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[y.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=>y.jsx("span",{className:"leading-none",children:p},p))}),y.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${En}px)`,gap:Or},children:u.map((p,g)=>(Array.isArray(p)?p:[]).map((b,w)=>{if(!b)return null;const x=b.day||`e-${g}-${w}`,v=Number(b.level)||0,k=i[v]||i[0],S=t||n||_("heatmap.legend.utc");return y.jsx("span",{title:_("heatmap.tooltip",{day:b.day,value:$b(b.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&&y.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[y.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.less")}),y.jsx("div",{className:"flex gap-0.5",children:i.map((p,g)=>y.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:p}},g))}),y.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.more")})]})]})}const zb={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Xd={...zb,position:"fixed",top:0,left:0};function $t(e){const t=bn(qb,e).current;return t.next=e,Te(t.effect),t}function qb(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var so=Symbol("NOT_FOUND");function Xb(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Zb(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function Qb(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 rc=e=>Array.isArray(e)?e:[e];function Jb(e){const t=Array.isArray(e[0])?e[0]:e;return Qb(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function e0(e,t){const n=[],{length:r}=e;for(let s=0;s<r;s++)n.push(e[s].apply(null,t));return n}function t0(e){let t;return{get(n){return t&&e(t.key,n)?t.value:so},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function n0(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 so}function s(a,l){r(a)===so&&(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 r0=(e,t)=>e===t;function s0(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 o0(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=r0,maxSize:s=1,resultEqualityCheck:o}=n,i=s0(r);let a=0;const l=s<=1?t0(i):n0(s,i);function c(){let u=l.get(arguments);if(u===so){if(u=e.apply(null,arguments),a++,o){const f=l.getEntries().find(m=>o(m.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 i0=class{constructor(e){this.value=e}deref(){return this.value}},a0=typeof WeakRef<"u"?WeakRef:i0,l0=0,sc=1;function Es(){return{s:l0,v:void 0,o:null,p:null}}function Zd(e,t={}){let n=Es();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 m=arguments[d];if(typeof m=="function"||typeof m=="object"&&m!==null){let p=a.o;p===null&&(a.o=p=new WeakMap);const g=p.get(m);g===void 0?(a=Es(),p.set(m,a)):a=g}else{let p=a.p;p===null&&(a.p=p=new Map);const g=p.get(m);g===void 0?(a=Es(),p.set(m,a)):a=g}}const c=a;let u;if(a.s===sc)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 a0(u):u}return c.s=sc,c.v=u,u}return i.clearCache=()=>{n=Es(),i.resetResultsCount()},i.resultsCount=()=>o,i.resetResultsCount=()=>{o=0},i}function Qd(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()),Xb(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:d,memoizeOptions:f=[],argsMemoize:m=Zd,argsMemoizeOptions:p=[]}=u,g=rc(f),b=rc(p),w=Jb(s),x=d(function(){return o++,c.apply(null,arguments)},...g),v=m(function(){i++;const S=e0(w,arguments);return a=x.apply(null,S),a},...b);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:m})};return Object.assign(r,{withTypes:()=>r}),r}var c0=Qd(Zd),u0=Object.assign((e,t=c0)=>{Zb(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:()=>u0});Qd({memoize:o0,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const pe=(e,t,n,r,s,o,...i)=>{if(i.length>0)throw new Error($n(1));let a;if(e)a=e;else throw new Error("Missing arguments");return a};var zo={exports:{}},qo={};var oc;function d0(){if(oc)return qo;oc=1;var e=hd();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 m=f(),p=r({inst:{value:m,getSnapshot:f}}),g=p[0].inst,b=p[1];return o(function(){g.value=m,g.getSnapshot=f,l(g)&&b({inst:g})},[d,m,f]),s(function(){return l(g)&&b({inst:g}),d(function(){l(g)&&b({inst:g})})},[d]),i(m),m}function l(d){var f=d.getSnapshot;d=d.value;try{var m=f();return!n(d,m)}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 qo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,qo}var ic;function Jd(){return ic||(ic=1,zo.exports=d0()),zo.exports}var f0=Jd(),Xo={exports:{}},Zo={};var ac;function h0(){if(ac)return Zo;ac=1;var e=hd(),t=Jd();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 Zo.useSyncExternalStoreWithSelector=function(c,u,d,f,m){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),m!==void 0&&g.hasValue){var D=g.value;if(m(D,C))return k=D}return k=C}if(D=k,r(v,C))return D;var E=f(C);return m!==void 0&&m(D,E)?(v=C,D):(v=C,k=E)}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,m]);var b=s(c,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=b},[b]),l(b),b},Zo}var lc;function m0(){return lc||(lc=1,Xo.exports=h0()),Xo.exports}var p0=m0();const g0=md(19),y0=g0?x0:v0;function b0(e,t,n,r,s){return y0(e,t,n,r,s)}function x0(e,t,n,r,s){const o=h.useCallback(()=>t(e.getSnapshot(),n,r,s),[e,t,n,r,s]);return f0.useSyncExternalStore(e.subscribe,o,o)}function v0(e,t,n,r,s){return p0.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 ka extends Vr{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){h.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){h.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)=>{h.useDebugValue(t);const o=this.selectors[t];return b0(this,o,n,r,s)};useContextCallback(t,n){h.useDebugValue(t);const r=he(n??pd);this.context[t]=r}useStateSetter(t){const n=h.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 Ms=null;class w0{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 Ds=new w0;class _t{static create(){return new _t}static request(t){return Ds.request(t)}static cancel(t){return Ds.cancel(t)}currentId=Ms;request(t){this.cancel(),this.currentId=Ds.request(()=>{this.currentId=Ms,t()})}cancel=()=>{this.currentId!==Ms&&(Ds.cancel(this.currentId),this.currentId=Ms)};disposeEffect=()=>this.cancel}function Sa(){const e=bn(_t.create).current;return ga(e.disposeEffect),e}function ef(){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 k0{nodesRef={current:[]};events=ef();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 tf=h.createContext(null),nf=h.createContext(null),Hn=()=>h.useContext(tf)?.id||null,wr=e=>{const t=h.useContext(nf);return e??t};function S0(e){const t=ts(),n=wr(e),r=Hn();return Te(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function T0(e){const{children:t,id:n}=e,r=Hn();return y.jsx(tf.Provider,{value:h.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function C0(e){const{children:t,externalTree:n}=e,r=bn(()=>n??new k0).current;return y.jsx(nf.Provider,{value:r,children:t})}function Ur(e){return`data-base-ui-${e}`}function Qo(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=h.forwardRef(function(t,n){const[r,s]=h.useState();Te(()=>{My&&s("button")},[]);const o={tabIndex:0,role:r};return y.jsx("span",{...t,ref:n,style:Xd,"aria-hidden":r?void 0:!0,...o,"data-base-ui-focus-guard":""})});let cc=0;function Jo(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:s=!1}=t;r&&cancelAnimationFrame(cc);const o=()=>e?.focus({preventScroll:n});s?o():cc=requestAnimationFrame(o)}const ar={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function uc(e){return e==="inert"?ar.inert:e==="aria-hidden"?ar["aria-hidden"]:ar.none}let Ps=new WeakSet,Rs={},ei=0;const rf=e=>e&&(e.host||rf(e.parentNode)),E0=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=rf(n);return e.contains(r)?r:null}).filter(n=>n!=null);function M0(e,t,n,r){const s="data-base-ui-inert",o=r?"inert":n?"aria-hidden":null,i=E0(t,e),a=new Set,l=new Set(i),c=[];Rs[s]||(Rs[s]=new WeakMap);const u=Rs[s];i.forEach(d),f(t),a.clear();function d(m){!m||a.has(m)||(a.add(m),m.parentNode&&d(m.parentNode))}function f(m){!m||l.has(m)||[].forEach.call(m.children,p=>{if(ns(p)!=="script")if(a.has(p))f(p);else{const g=o?p.getAttribute(o):null,b=g!==null&&g!=="false",w=uc(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&&b&&Ps.add(p),v===1&&p.setAttribute(s,""),!b&&o&&p.setAttribute(o,o==="inert"?"":"true")}})}return ei+=1,()=>{c.forEach(m=>{const p=uc(o),b=(p.get(m)||0)-1,w=(u.get(m)||0)-1;p.set(m,b),u.set(m,w),b||(!Ps.has(m)&&o&&m.removeAttribute(o),Ps.delete(m)),w||m.removeAttribute(s)}),ei-=1,ei||(ar.inert=new WeakMap,ar["aria-hidden"]=new WeakMap,ar.none=new WeakMap,Ps=new WeakSet,Rs={})}}function D0(e,t=!1,n=!1){const r=qe(e[0]).body;return M0(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const sf=h.createContext(null),of=()=>h.useContext(sf),P0=Ur("portal");function R0(e={}){const{ref:t,container:n,componentProps:r=jn,elementProps:s,elementState:o}=e,i=ts(),l=of()?.portalNode,[c,u]=h.useState(null),[d,f]=h.useState(null),m=he(w=>{w!==null&&f(w)}),p=h.useRef(null);Te(()=>{if(n===null){p.current&&(p.current=null,f(null),u(null));return}if(i==null)return;const w=(n&&($g(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=on("div",r,{ref:[t,m],state:o,props:[{id:i,[P0]:""},s]});return{portalNode:d,portalSubtree:c&&g?pn.createPortal(g,c):null}}const af=h.forwardRef(function(t,n){const{children:r,container:s,className:o,render:i,renderGuards:a,...l}=t,{portalNode:c,portalSubtree:u}=R0({container:s,ref:n,componentProps:t,elementProps:l}),d=h.useRef(null),f=h.useRef(null),m=h.useRef(null),p=h.useRef(null),[g,b]=h.useState(null),w=g?.modal,x=g?.open,v=typeof a=="boolean"?a:!!g&&!g.modal&&g.open&&!!c;h.useEffect(()=>{if(!c||w)return;function S(C){c&&C.relatedTarget&&ir(C)&&(C.type==="focusin"?Ql:cb)(c)}return c.addEventListener("focusin",S,!0),c.addEventListener("focusout",S,!0),()=>{c.removeEventListener("focusin",S,!0),c.removeEventListener("focusout",S,!0)}},[c,w]),h.useEffect(()=>{!c||x||Ql(c)},[x,c]);const k=h.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:m,afterInsideRef:p,portalNode:c,setFocusManagerState:b}),[c]);return y.jsxs(h.Fragment,{children:[u,y.jsxs(sf.Provider,{value:k,children:[v&&c&&y.jsx(mr,{"data-type":"outside",ref:d,onFocus:S=>{if(ir(S,c))m.current?.focus();else{const C=g?g.domReference:null;$d(C)?.focus()}}}),v&&c&&y.jsx("span",{"aria-owns":c.id,style:Ty}),c&&pn.createPortal(r,c),v&&c&&y.jsx(mr,{"data-type":"outside",ref:f,onFocus:S=>{if(ir(S,c))p.current?.focus();else{const C=g?g.domReference:null;va(C)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Le(Hr,S.nativeEvent))}}})]})]})});function en(e){return e==null?e:"current"in e?e.current:e}function O0(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 dc=20;let fn=[];function Ta(){fn=fn.filter(e=>e.isConnected)}function A0(e){Ta(),e&&ns(e)!=="body"&&(fn.push(e),fn.length>dc&&(fn=fn.slice(-dc)))}function ti(){return Ta(),fn[fn.length-1]}function N0(e){if(!e)return null;const t=vr();return Wd(e,t)?e:ss(e,t)[0]||e}function j0(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():At(e).display!=="none"}function fc(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=vr(),s=ib(e,n).filter(i=>{const a=i.getAttribute("data-tabindex")||"";return Wd(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 lf(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:m,beforeContentFocusGuardRef:p,externalTree:g}=e,b="rootStore"in t?t.rootStore:t,w=b.useState("open"),x=b.useState("domReferenceElement"),v=b.useState("floatingElement"),{events:k,dataRef:S}=b.context,C=he(()=>S.current.floatingContext?.nodeId),D=he(d),E=o===!1,O=Kl(x)&&E,T=$t(s),R=$t(o),A=$t(i),M=$t(u),I=wr(g),j=of(),V=h.useRef(null),U=h.useRef(null),P=h.useRef(!1),F=h.useRef(!1),W=h.useRef(!1),B=h.useRef(-1),Q=h.useRef(""),Y=h.useRef(""),$=h.useRef(null),z=h.useRef(null),Z=Yl($,p,j?.beforeInsideRef),ce=Yl(z,j?.afterInsideRef),Se=_n(),Re=_n(),Ee=Sa(),et=j!=null,L=ji(v),ue=he((H=L)=>H?ss(H,vr()):[]),te=he(H=>{const se=ue(H);return T.current.map(()=>se).filter(Boolean).flat()});h.useEffect(()=>{if(r||!l)return;function H(ie){ie.key==="Tab"&&we(L,Jn(qe(L)))&&ue().length===0&&!O&&Ny(ie)}const se=qe(L);return se.addEventListener("keydown",H),()=>{se.removeEventListener("keydown",H)}},[r,x,L,l,T,O,ue,te]),h.useEffect(()=>{if(r||!v)return;function H(se){const ie=ft(se),ge=ue().indexOf(ie);ge!==-1&&(B.current=ge)}return v.addEventListener("focusin",H),()=>{v.removeEventListener("focusin",H)}},[r,v,ue]),h.useEffect(()=>{if(r||!w)return;const H=qe(L);function se(){W.current=!1}function ie(ge){const J=ft(ge),ne=we(v,J)||we(x,J)||we(j?.portalNode,J);W.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,j]),h.useEffect(()=>{if(r||!c)return;function H(){F.current=!0,Re.start(0,()=>{F.current=!1})}function se(J){const ne=J.relatedTarget,Ve=J.currentTarget,be=ft(J);queueMicrotask(()=>{const Be=C(),$e=b.context.triggerElements,it=ne?.hasAttribute(Ur("focus-guard"))&&[$.current,z.current,j?.beforeInsideRef.current,j?.afterInsideRef.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,en(m),en(f)].includes(ne),Oe=!(we(x,ne)||we(v,ne)||we(ne,v)||we(j?.portalNode,ne)||ne!=null&&$e.hasElement(ne)||$e.hasMatchingElement(ye=>we(ye,ne))||it||I&&(Fn(I.nodesRef.current,Be).find(ye=>we(ye.context?.elements.floating,ne)||we(ye.context?.elements.domReference,ne))||zl(I.nodesRef.current,Be).find(ye=>[ye.context?.elements.floating,ji(ye.context?.elements.floating)].includes(ne)||ye.context?.elements.domReference===ne)));if(Ve===x&&L&&fc(L,T),a&&Ve!==x&&!j0(be)&&Jn(qe(L))===qe(L).body){if(rt(L)&&(L.focus(),a==="popup")){Ee.request(()=>{L.focus()});return}const ye=B.current,je=ue(),Ye=je[ye]||je[je.length-1]||L;rt(Ye)&&Ye.focus()}if(S.current.insideReactTree){S.current.insideReactTree=!1;return}(O||!l)&&ne&&Oe&&!F.current&&(O||ne!==ti())&&(P.current=!0,b.setOpen(!1,Le(Hr,J)))})}function ie(){W.current||(S.current.insideReactTree=!0,Se.start(0,()=>{S.current.insideReactTree=!1}))}const me=rt(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),j&&(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,I,j,b,c,a,ue,O,C,T,S,Se,Re,Ee,f,m]),h.useEffect(()=>{if(r||!v||!w)return;const H=Array.from(j?.portalNode?.querySelectorAll(`[${Ur("portal")}]`)||[]),ie=(I?zl(I.nodesRef.current,C()):[]).find(J=>Kl(J.context?.elements.domReference||null))?.context?.elements.domReference,me=[v,ie,...H,...D(),V.current,U.current,$.current,z.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,en(m),en(f),O?x:null].filter(J=>J!=null),ge=D0(me,l||O);return()=>{ge()}},[w,r,x,v,l,T,j,O,I,C,D,f,m]),Te(()=>{if(!w||r||!rt(L))return;const H=qe(L),se=Jn(H);queueMicrotask(()=>{const ie=te(L),me=R.current,ge=typeof me=="function"?me(M.current||""):me;if(ge===void 0||ge===!1)return;let J;ge===!0||ge===null?J=ie[0]||L:J=en(ge),J=J||ie[0]||L,!we(L,se)&&Jo(J,{preventScroll:J===L})})},[r,w,L,E,te,R,M]),Te(()=>{if(r||!L)return;const H=qe(L),se=Jn(H);A0(se);function ie(J){if(J.open||(Q.current=O0(J.nativeEvent,Y.current)),J.reason===dt&&J.nativeEvent.type==="mouseleave"&&(P.current=!0),J.reason===gd)if(J.nested)P.current=!1;else if(Iy(J.nativeEvent)||Fy(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,Xd),et&&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||ti();return be&&be.isConnected?be:me}const Ve=x||ti()||me;return en(ne)||Ve}return()=>{k.off("openchange",ie);const J=Jn(H),ne=we(v,J)||I&&Fn(I.nodesRef.current,C(),!1).some(be=>we(be.context?.elements.floating,J)),Ve=ge();queueMicrotask(()=>{const be=N0(Ve),Be=typeof A.current!="boolean";A.current&&!P.current&&rt(be)&&(!(!Be&&be!==J&&J!==H.body)||ne)&&be.focus({preventScroll:!0}),me.remove()})}},[r,v,L,A,S,k,I,et,x,C]),h.useEffect(()=>{queueMicrotask(()=>{P.current=!1})},[r]),h.useEffect(()=>{if(r||!w)return;function H(ie){ft(ie)?.closest(`[${Td}]`)&&(F.current=!0)}const se=qe(L);return se.addEventListener("pointerdown",H,!0),()=>{se.removeEventListener("pointerdown",H,!0)}},[r,w,L]),Te(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:c,open:w,onOpenChange:b.setOpen,domReference:x}),()=>{j.setFocusManagerState(null)}},[r,j,l,w,b,c,x]),Te(()=>{if(!(r||!L))return fc(L,T),()=>{queueMicrotask(Ta)}},[r,L,T]);const Me=!r&&(l?!O:!0)&&(et||l);return y.jsxs(h.Fragment,{children:[Me&&y.jsx(mr,{"data-type":"inside",ref:Z,onFocus:H=>{if(l){const se=te();Jo(se[se.length-1])}else j?.portalNode&&(P.current=!1,ir(H,j.portalNode)?va(x)?.focus():en(m??j.beforeOutsideRef)?.focus())}}),n,Me&&y.jsx(mr,{"data-type":"inside",ref:ce,onFocus:H=>{l?Jo(te()[0]):j?.portalNode&&(c&&(P.current=!0),ir(H,j.portalNode)?$d(x)?.focus():en(f??j.afterOutsideRef)?.focus())}})]})}function I0(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=h.useRef(void 0),d=Sa(),f=_n(),m=h.useMemo(()=>({onPointerDown(p){u.current=p.pointerType},onMouseDown(p){const g=u.current,b=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(Od(b.target)){const D=Le(mn,b,b.target);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,D)}):n.setOpen(S,D);return}const C=p.currentTarget;d.request(()=>{const D=Le(mn,b,C);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,D)}):n.setOpen(S,D)})},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 b=n.select("open"),w=r.current.openEvent,x=n.select("domReferenceElement")!==p.currentTarget,v=b&&x||!(b&&i&&(!(w&&l)||Ad(w))),k=Le(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 h.useMemo(()=>s?{reference:m}:jn,[s,m])}function hc(e,t,n){let{reference:r,floating:s}=e;const o=yt(t),i=xa(t),a=ba(i),l=at(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 m;switch(l){case"top":m={x:u,y:r.y-s.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-s.width,y:d};break;default:m={x:r.x,y:r.y}}switch(xn(t)){case"start":m[i]-=f*(n&&c?-1:1);break;case"end":m[i]+=f*(n&&c?-1:1);break}return m}async function F0(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:m=0}=rn(t,e),p=Nd(m),b=a[f?d==="floating"?"reference":"floating":d],w=Qs(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.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=Qs(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 L0=50,V0=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:F0},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}=hc(c,r,l),f=r,m=0;const p={};for(let g=0;g<o.length;g++){const b=o[g];if(!b)continue;const{name:w,fn:x}=b,{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&&m<L0&&(m++,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}=hc(c,f,l)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}},_0=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:m="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...b}=rn(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const w=at(s),x=yt(a),v=at(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(v||!g?[Zs(a)]:Wy(a)),C=p!=="none";!f&&C&&S.push(...Hy(a,g,p,k));const D=[a,...S],E=await l.detectOverflow(t,b),O=[];let T=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&O.push(E[w]),d){const I=_y(s,i,k);O.push(E[I[0]],E[I[1]])}if(T=[...T,{placement:s,overflows:O}],!O.every(I=>I<=0)){var R,A;const I=(((R=o.flip)==null?void 0:R.index)||0)+1,j=D[I];if(j&&(!(d==="alignment"?x!==yt(j):!1)||T.every(P=>yt(P.placement)===x?P.overflows[0]>0:!0)))return{data:{index:I,overflows:T},reset:{placement:j}};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(m){case"bestFit":{var M;const U=(M=T.filter(P=>{if(C){const F=yt(P.placement);return F===x||F==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(F=>F>0).reduce((F,W)=>F+W,0)]).sort((P,F)=>P[1]-F[1])[0])==null?void 0:M[0];U&&(V=U);break}case"initialPlacement":V=a;break}if(s!==V)return{reset:{placement:V}}}return{}}}};function mc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pc(e){return Ly.some(t=>e[t]>=0)}const W0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...o}=rn(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...o,elementContext:"reference"}),a=mc(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:pc(a)}}}case"escaped":{const i=await r.detectOverflow(t,{...o,altBoundary:!0}),a=mc(i,n.floating);return{data:{escapedOffsets:a,escaped:pc(a)}}}default:return{}}}}},cf=new Set(["left","top"]);async function B0(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=at(n),a=xn(n),l=yt(n)==="y",c=cf.has(i)?-1:1,u=o&&l?-1:1,d=rn(t,e);let{mainAxis:f,crossAxis:m,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"&&(m=a==="end"?p*-1:p),l?{x:m*u,y:f*c}:{x:f*c,y:m*u}}const $0=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 B0(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}}}}},Y0=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}=rn(e,t),u={x:n,y:r},d=await o.detectOverflow(t,c),f=yt(at(s)),m=ya(f);let p=u[m],g=u[f];if(i){const w=m==="y"?"top":"left",x=m==="y"?"bottom":"right",v=p+d[w],k=p-d[x];p=Ii(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=Ii(v,g,k)}const b=l.fn({...t,[m]:p,[f]:g});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[m]:i,[f]:a}}}}}},H0=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}=rn(e,t),u={x:n,y:r},d=yt(s),f=ya(d);let m=u[f],p=u[d];const g=rn(a,t),b=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]+b.mainAxis,S=o.reference[f]+o.reference[v]-b.mainAxis;m<k?m=k:m>S&&(m=S)}if(c){var w,x;const v=f==="y"?"width":"height",k=cf.has(at(s)),S=o.reference[d]-o.floating[v]+(k&&((w=i.offset)==null?void 0:w[d])||0)+(k?0:b.crossAxis),C=o.reference[d]+o.reference[v]+(k?0:((x=i.offset)==null?void 0:x[d])||0)-(k?b.crossAxis:0);p<S?p=S:p>C&&(p=C)}return{[f]:m,[d]:p}}}},U0=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}=rn(e,t),u=await i.detectOverflow(t,c),d=at(s),f=xn(s),m=yt(s)==="y",{width:p,height:g}=o.floating;let b,w;d==="top"||d==="bottom"?(b=d,w=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=d,b=f==="end"?"top":"bottom");const x=g-u.top-u.bottom,v=p-u.left-u.right,k=fr(g-u[b],x),S=fr(p-u[w],v),C=!t.middlewareData.shift;let D=k,E=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(E=v),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(D=x),C&&!f){const T=ht(u.left,0),R=ht(u.right,0),A=ht(u.top,0),M=ht(u.bottom,0);m?E=p-2*(T!==0||R!==0?T+R:ht(u.left,u.right)):D=g-2*(A!==0||M!==0?A+M:ht(u.top,u.bottom))}await l({...t,availableWidth:E,availableHeight:D});const O=await i.getDimensions(a.floating);return p!==O.width||g!==O.height?{reset:{rects:!0}}:{}}}};function uf(e){const t=At(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=rt(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,a=Xs(n)!==o||Xs(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function Ca(e){return Ae(e)?e:e.contextElement}function lr(e){const t=Ca(e);if(!rt(t))return Ut(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=uf(t);let i=(o?Xs(n.width):n.width)/r,a=(o?Xs(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const G0=Ut(0);function df(e){const t=vt(e);return!fa()||!t.visualViewport?G0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function K0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vt(e)?!1:t}function Wn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Ca(e);let i=Ut(1);t&&(r?Ae(r)&&(i=lr(r)):i=lr(e));const a=K0(o,n,r)?df(o):Ut(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),m=r&&Ae(r)?vt(r):r;let p=f,g=Hl(p);for(;g&&r&&m!==p;){const b=lr(g),w=g.getBoundingClientRect(),x=At(g),v=w.left+(g.clientLeft+parseFloat(x.paddingLeft))*b.x,k=w.top+(g.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=v,c+=k,p=vt(g),g=Hl(p)}}return Qs({width:u,height:d,x:l,y:c})}function bo(e,t){const n=yo(e).scrollLeft;return t?t.left+n:Wn(an(e)).left+n}function ff(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-bo(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function z0(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",i=an(r),a=t?ha(t.floating):!1;if(r===i||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Ut(1);const u=Ut(0),d=rt(r);if((d||!d&&!o)&&((ns(r)!=="body"||rs(i))&&(l=yo(r)),d)){const m=Wn(r);c=lr(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const f=i&&!d&&!o?ff(i,l):Ut(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 q0(e){return Array.from(e.getClientRects())}function X0(e){const t=an(e),n=yo(e),r=e.ownerDocument.body,s=ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+bo(e);const a=-n.scrollTop;return At(r).direction==="rtl"&&(i+=ht(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}const gc=25;function Z0(e,t){const n=vt(e),r=an(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=fa();(!u||u&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=bo(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),m=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-m);p<=gc&&(o-=p)}else c<=gc&&(o+=c);return{width:o,height:i,x:a,y:l}}function Q0(e,t){const n=Wn(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=rt(e)?lr(e):Ut(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 yc(e,t,n){let r;if(t==="viewport")r=Z0(e,n);else if(t==="document")r=X0(an(e));else if(Ae(t))r=Q0(t,n);else{const s=df(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Qs(r)}function hf(e,t){const n=ur(e);return n===t||!Ae(n)||In(n)?!1:At(n).position==="fixed"||hf(n,t)}function J0(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=yd(i);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||rs(i)&&!l&&hf(e,i))?r=r.filter(u=>u!==i):s=a,i=ur(i)}return t.set(e,r),r}function ex(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?ha(t)?[]:J0(t,this._c):[].concat(n),r],a=yc(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 m=yc(t,i[f],s);l=ht(m.top,l),c=fr(m.right,c),u=fr(m.bottom,u),d=ht(m.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function tx(e){const{width:t,height:n}=uf(e);return{width:t,height:n}}function nx(e,t,n){const r=rt(t),s=an(t),o=n==="fixed",i=Wn(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=Ut(0);function c(){l.x=bo(s)}if(r||!r&&!o)if((ns(t)!=="body"||rs(s))&&(a=yo(t)),r){const m=Wn(t,!0,o,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}else s&&c();o&&!r&&s&&c();const u=s&&!r&&!o?ff(s,a):Ut(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 ni(e){return At(e).position==="static"}function bc(e,t){if(!rt(e)||At(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return an(e)===n&&(n=n.ownerDocument.body),n}function mf(e,t){const n=vt(e);if(ha(e))return n;if(!rt(e)){let s=ur(e);for(;s&&!In(s);){if(Ae(s)&&!ni(s))return s;s=ur(s)}return n}let r=bc(e,t);for(;r&&Yg(r)&&ni(r);)r=bc(r,t);return r&&In(r)&&ni(r)&&!yd(r)?n:r||Hg(e)||n}const rx=async function(e){const t=this.getOffsetParent||mf,n=this.getDimensions,r=await n(e.floating);return{reference:nx(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sx(e){return At(e).direction==="rtl"}const ox={convertOffsetParentRelativeRectToViewportRelativeRect:z0,getDocumentElement:an,getClippingRect:ex,getOffsetParent:mf,getElementRects:rx,getClientRects:q0,getDimensions:tx,getScale:lr,isElement:Ae,isRTL:sx};function pf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ix(e,t){let n=null,r;const s=an(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:m}=c;if(a||t(),!f||!m)return;const p=Cs(d),g=Cs(s.clientWidth-(u+f)),b=Cs(s.clientHeight-(d+m)),w=Cs(u),v={rootMargin:-p+"px "+-g+"px "+-b+"px "+-w+"px",threshold:ht(0,fr(1,l))||1};let k=!0;function S(C){const D=C[0].intersectionRatio;if(D!==l){if(!k)return i();D?i(!1,D):r=setTimeout(()=>{i(!1,1e-7)},1e3)}D===1&&!pf(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 xc(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=Ca(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?ix(c,n):null;let f=-1,m=null;i&&(m=new ResizeObserver(w=>{let[x]=w;x&&x.target===c&&m&&t&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=m)==null||v.observe(t)})),n()}),c&&!l&&m.observe(c),t&&m.observe(t));let p,g=l?Wn(e):null;l&&b();function b(){const w=Wn(e);g&&!pf(g,w)&&n(),g=w,p=requestAnimationFrame(b)}return n(),()=>{var w;u.forEach(x=>{s&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),d?.(),(w=m)==null||w.disconnect(),m=null,l&&cancelAnimationFrame(p)}}const ax=$0,lx=Y0,cx=_0,ux=U0,dx=W0,fx=H0,hx=(e,t,n)=>{const r=new Map,s={platform:ox,...n},o={...s.platform,_c:r};return V0(e,t,{...s,platform:o})};var mx=typeof document<"u",px=function(){},Vs=mx?h.useLayoutEffect:px;function oo(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(!oo(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)&&!oo(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function gf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function vc(e,t){const n=gf(e);return Math.round(t*n)/n}function ri(e){const t=h.useRef(e);return Vs(()=>{t.current=e}),t}function gx(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]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=h.useState(r);oo(f,r)||m(r);const[p,g]=h.useState(null),[b,w]=h.useState(null),x=h.useCallback(P=>{P!==C.current&&(C.current=P,g(P))},[]),v=h.useCallback(P=>{P!==D.current&&(D.current=P,w(P))},[]),k=o||p,S=i||b,C=h.useRef(null),D=h.useRef(null),E=h.useRef(u),O=l!=null,T=ri(l),R=ri(s),A=ri(c),M=h.useCallback(()=>{if(!C.current||!D.current)return;const P={placement:t,strategy:n,middleware:f};R.current&&(P.platform=R.current),hx(C.current,D.current,P).then(F=>{const W={...F,isPositioned:A.current!==!1};I.current&&!oo(E.current,W)&&(E.current=W,pn.flushSync(()=>{d(W)}))})},[f,t,n,R,A]);Vs(()=>{c===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(P=>({...P,isPositioned:!1})))},[c]);const I=h.useRef(!1);Vs(()=>(I.current=!0,()=>{I.current=!1}),[]),Vs(()=>{if(k&&(C.current=k),S&&(D.current=S),k&&S){if(T.current)return T.current(k,S,M);M()}},[k,S,M,T,O]);const j=h.useMemo(()=>({reference:C,floating:D,setReference:x,setFloating:v}),[x,v]),V=h.useMemo(()=>({reference:k,floating:S}),[k,S]),U=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!V.floating)return P;const F=vc(V.floating,u.x),W=vc(V.floating,u.y);return a?{...P,transform:"translate("+F+"px, "+W+"px)",...gf(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:W}},[n,a,V.floating,u.x,u.y]);return h.useMemo(()=>({...u,update:M,refs:j,elements:V,floatingStyles:U}),[u,M,j,V,U])}const yx=(e,t)=>{const n=ax(e);return{name:n.name,fn:n.fn,options:[e,t]}},bx=(e,t)=>{const n=lx(e);return{name:n.name,fn:n.fn,options:[e,t]}},xx=(e,t)=>({fn:fx(e).fn,options:[e,t]}),vx=(e,t)=>{const n=cx(e);return{name:n.name,fn:n.fn,options:[e,t]}},wx=(e,t)=>{const n=ux(e);return{name:n.name,fn:n.fn,options:[e,t]}},kx=(e,t)=>{const n=dx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sx={intentional:"onClick",sloppy:"onPointerDown"};function Tx(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function yf(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:m=!1,referencePressEvent:p="sloppy",ancestorScroll:g=!1,bubbles:b,externalTree:w}=t,x=wr(w),v=he(typeof d=="function"?d:()=>!1),k=typeof d=="function"?v:d,S=h.useRef(!1),{escapeKey:C,outsidePress:D}=Tx(b),E=h.useRef(null),O=_n(),T=_n(),R=he(()=>{T.clear(),l.current.insideReactTree=!1}),A=h.useRef(!1),M=h.useRef(""),I=he(L=>{M.current=L.pointerType}),j=he(()=>{const L=M.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=jy(L)?L.nativeEvent:L,H=Le(bd,Me);n.setOpen(!1,H),!C&&!H.isPropagationAllowed&&L.stopPropagation()}),U=he(L=>{const ue=j();return ue==="intentional"&&L.type!=="click"||ue==="sloppy"&&L.type==="click"}),P=he(()=>{l.current.insideReactTree=!0,T.start(0,R)}),F=he((L,ue=!1)=>{if(U(L)){R();return}if(l.current.insideReactTree){R();return}if(j()==="intentional"&&ue||typeof k=="function"&&!k(L))return;const te=ft(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)&&!Ay(te)&&!we(te,n.select("floatingElement"))&&Array.from(H).every(ne=>!we(ie,ne)))return;if(rt(te)&&!("touches"in L)){const ne=In(te),Ve=At(te),be=/auto|scroll/,Be=ne||be.test(Ve.overflowX),$e=ne||be.test(Ve.overflowY),it=Be&&te.clientWidth>0&&te.scrollWidth>te.clientWidth,Oe=$e&&te.clientHeight>0&&te.scrollHeight>te.clientHeight,ye=Ve.direction==="rtl",je=Oe&&(ye?L.offsetX<=te.offsetWidth-te.clientWidth:L.offsetX>te.clientWidth),Ye=it&&L.offsetY>te.clientHeight;if(je||Ye)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(Ve=>{Ve.context?.open&&!Ve.context.dataRef.current.__outsidePressBubbles&&(ne=!1)}),!ne)return}n.setOpen(!1,Le(gd,L)),R()}),W=he(L=>{j()!=="sloppy"||L.pointerType==="touch"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||F(L)}),B=he(L=>{if(j()!=="sloppy"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement")))return;const ue=L.touches[0];ue&&(E.current={startTime:Date.now(),startX:ue.clientX,startY:ue.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}),Q=he(L=>{const ue=ft(L);function te(){B(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Y=he(L=>{const ue=S.current;if(S.current=!1,O.clear(),L.type==="mousedown"&&E.current&&!E.current.dismissOnMouseDown)return;const te=ft(L);function Me(){L.type==="pointerdown"?W(L):F(L,ue),te?.removeEventListener(L.type,Me)}te?.addEventListener(L.type,Me)}),$=he(L=>{if(j()!=="sloppy"||!E.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-E.current.startX),Me=Math.abs(ue.clientY-E.current.startY),H=Math.sqrt(te*te+Me*Me);H>5&&(E.current.dismissOnTouchEnd=!0),H>10&&(F(L),O.clear(),E.current=null)}),z=he(L=>{const ue=ft(L);function te(){$(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Z=he(L=>{j()!=="sloppy"||!E.current||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||(E.current.dismissOnTouchEnd&&F(L),O.clear(),E.current=null)}),ce=he(L=>{const ue=ft(L);function te(){Z(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)});h.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=C,l.current.__outsidePressBubbles=D;const L=new gn;function ue(ie){n.setOpen(!1,Le(Ug,ie))}function te(){L.clear(),A.current=!0}function Me(){L.start(fa()?5:0,()=>{A.current=!1})}const H=qe(s);H.addEventListener("pointerdown",I,!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",I,!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,D,V,F,Y,W,Q,z,ce,I,n]),h.useEffect(R,[k,R]);const Se=h.useMemo(()=>({onKeyDown:V,...m&&{[Sx[p]]:L=>{n.setOpen(!1,Le(mn,L.nativeEvent))},...p!=="intentional"&&{onClick(L){n.setOpen(!1,Le(mn,L.nativeEvent))}}}}),[V,n,m,p]),Re=he(L=>{const ue=ft(L.nativeEvent);!we(n.select("floatingElement"),ue)||L.button!==0||(S.current=!0)}),Ee=he(L=>{!r||!c||L.button!==0||(S.current=!0)}),et=h.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 h.useMemo(()=>c?{reference:Se,floating:et,trigger:Se}:{},[c,Se,et])}const Cx={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 Ea extends ka{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:ef(),nested:n,noEmit:r,triggerElements:o},Cx)}setOpen=(t,n)=>{if((!t||!this.state.open||Ad(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 Ex(e,t=!1,n=!1){const[r,s]=h.useState(e&&t?"idle":void 0),[o,i]=h.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=_t.request(()=>{s("ending")});return()=>{_t.cancel(a)}}},[e,o,r,n]),Te(()=>{if(!e||t)return;const a=_t.request(()=>{s(void 0)});return()=>{_t.cancel(a)}},[t,e]),Te(()=>{if(!e||!t)return;e&&o&&r!=="idle"&&s("starting");const a=_t.request(()=>{s("idle")});return()=>{_t.cancel(a)}},[t,e,o,s,r]),h.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 Mx={[Gr.startingStyle]:""},Dx={[Gr.endingStyle]:""},xo={transitionStatus(e){return e==="starting"?Mx:e==="ending"?Dx:null}};function bf(e,t=!1,n=!0){const r=Sa();return he((s,o=null)=>{r.cancel();function i(){pn.flushSync(s)}const a=en(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 Ma(e){const{enabled:t=!0,open:n,ref:r,onComplete:s}=e,o=he(s),i=bf(r,n,!1);h.useEffect(()=>{if(!t)return;const a=new AbortController;return i(o,a.signal),()=>{a.abort()}},[t,n,o,i])}function Px(e,t){const n=h.useRef(null),r=h.useRef(null);return h.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 Rx(e,t,n,r){const s=n.useState("isMountedByTrigger",e),o=Px(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 xf(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 vf(e,t,n){const{mounted:r,setMounted:s,transitionStatus:o}=Ex(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 Ma({enabled:!a,open:e,ref:t.context.popupRef,onComplete(){e||i()}}),{forceUnmount:i,transitionStatus:o}}class vo{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 Ox(){return new Ea({open:!1,floatingElement:null,referenceElement:null,triggerElements:new vo,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function wf(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Ox(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:jn,inactiveTriggerProps:jn,popupProps:jn}}const kf={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 Ax(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=ts(),o=Hn()!=null,i=bn(()=>new Ea({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new vo,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 Nx(e={}){const{nodeId:t,externalTree:n}=e,r=Ax(e),s=e.rootContext||r,o={reference:s.useState("referenceElement"),floating:s.useState("floatingElement"),domReference:s.useState("domReferenceElement")},[i,a]=h.useState(null),l=h.useRef(null),c=wr(n);Te(()=>{o.domReference&&(l.current=o.domReference)},[o.domReference]);const u=gx({...e,elements:{...o,...i&&{reference:i}}}),d=h.useCallback(D=>{const E=Ae(D)?{getBoundingClientRect:()=>D.getBoundingClientRect(),getClientRects:()=>D.getClientRects(),contextElement:D}:D;a(E),u.refs.setReference(E)},[u.refs]),[f,m]=h.useState(null),[p,g]=h.useState(null);s.useSyncedValue("referenceElement",f),s.useSyncedValue("domReferenceElement",Ae(f)?f:null),s.useSyncedValue("floatingElement",p);const b=h.useCallback(D=>{(Ae(D)||D===null)&&(l.current=D,m(D)),(Ae(u.refs.reference.current)||u.refs.reference.current===null||D!==null&&!Ae(D))&&u.refs.setReference(D)},[u.refs,m]),w=h.useCallback(D=>{g(D),u.refs.setFloating(D)},[u.refs]),x=h.useMemo(()=>({...u.refs,setReference:b,setFloating:w,setPositionReference:d,domReference:l}),[u.refs,b,w,d]),v=h.useMemo(()=>({...u.elements,domReference:o.domReference}),[u.elements,o.domReference]),k=s.useState("open"),S=s.useState("floatingId"),C=h.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 D=c?.nodesRef.current.find(E=>E.id===t);D&&(D.context=C)}),h.useMemo(()=>({...u,context:C,refs:x,elements:v,rootStore:s}),[u,x,v,C,s])}function Sf(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:s}=e,o=ts(),i=Hn()!=null,a=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=bn(()=>new Ea({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 _i=Ur("safe-polygon"),jx=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Rd}`;function Ix(e){return e?!!e.closest(jx):!1}function Tf(e){const t=h.useRef(void 0),n=h.useRef(!1),r=h.useRef(void 0),s=h.useRef(!0),o=h.useRef(!1),i=h.useRef(()=>{}),a=h.useRef(!1),l=_n(),c=_n(),u=h.useRef(void 0);return h.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 Fx=new Set(["click","mousedown"]);function Lx(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:m,unbindMouseMoveRef:p,restTimeoutPendingRef:g,openChangeTimeout:b,handleCloseOptionsRef:w}=Tf(n),x=wr(c),v=Hn(),k=he(()=>d.current?!0:i.current.openEvent?Fx.has(i.current.openEvent.type):!1),S=he(()=>{const T=i.current.openEvent?.type;return T?.includes("mouse")&&T!=="mousedown"}),C=h.useCallback((T,R=!0)=>{const A=Vx(l,u.current);A&&!f.current?b.start(A,()=>n.setOpen(!1,Le(dt,T))):R&&(b.clear(),n.setOpen(!1,Le(dt,T)))},[l,f,n,u,b]),D=he(()=>{p.current(),f.current=void 0}),E=he(()=>{if(m.current){const T=qe(s).body;T.style.pointerEvents="",T.removeAttribute(_i),m.current=!1}}),O=he(T=>{const R=ft(T);if(!Ix(R)){d.current=!1;return}d.current=!0});Te(()=>{r||(u.current=void 0,g.current=!1,d.current=!1,D(),E())},[r,u,g,d,D,E]),h.useEffect(()=>()=>{D()},[D]),h.useEffect(()=>E,[E]),Te(()=>{if(a&&r&&w.current?.blockPointerEvents&&S()&&Ae(o)&&s){m.current=!0;const T=qe(s).body;T.setAttribute(_i,"");const R=o,A=s,M=x?.nodesRef.current.find(I=>I.id===v)?.context?.elements.floating;return M&&(M.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,m]),h.useEffect(()=>{if(!a)return;function T(I){if(k()||!i.current.floatingContext||!n.select("open"))return;const j=n.context.triggerElements;I.relatedTarget&&j.hasElement(I.relatedTarget)||(E(),D(),k()||C(I))}function R(I){b.clear(),E(),f.current?.(I),D()}function A(I){k()||C(I,!1)}const M=s;return M&&(M.addEventListener("mouseleave",T),M.addEventListener("mouseenter",R),M.addEventListener("mouseleave",A),M.addEventListener("pointerdown",O,!0)),()=>{M&&(M.removeEventListener("mouseleave",T),M.removeEventListener("mouseenter",R),M.removeEventListener("mouseleave",A),M.removeEventListener("pointerdown",O,!0))}})}function Vx(e,t){return t&&!dr(t)?0:typeof e=="function"?e():e}function si(e){return typeof e=="function"?e():e}const _x={current:null};function Wx(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=_x,externalTree:f,isActiveTrigger:m=!0}=t,p=wr(f),{pointerTypeRef:g,interactedInsideRef:b,handlerRef:w,blockMouseMoveRef:x,performedPointerEventsMutationRef:v,unbindMouseMoveRef:k,restTimeoutPendingRef:S,openChangeTimeout:C,restTimeout:D,handleCloseOptionsRef:E}=Tf(n),O=$t(a),T=$t(i),R=$t(c);m&&(E.current=O.current?.__options);const A=he(()=>b.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),M=h.useCallback((U,P=!0)=>{const F=Qo(T.current,"close",g.current);F&&!w.current?C.start(F,()=>n.setOpen(!1,Le(dt,U))):P&&(C.clear(),n.setOpen(!1,Le(dt,U)))},[T,w,n,g,C]),I=he(()=>{k.current(),w.current=void 0}),j=he(()=>{if(v.current){const U=qe(n.select("domReferenceElement")).body;U.style.pointerEvents="",U.removeAttribute(_i),v.current=!1}});h.useEffect(()=>{if(!o)return;function U(P){P.open||(C.clear(),D.clear(),x.current=!0,S.current=!1)}return s.on("openchange",U),()=>{s.off("openchange",U)}},[o,s,C,D,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 F=d.current;O.current?.({...r.current.floatingContext,tree:p,x:U.clientX,y:U.clientY,onClose(){j(),I(),!A()&&F===n.select("domReferenceElement")&&M(U)}})(U)});return h.useEffect(()=>{if(!o)return;const U=d.current??(m?n.select("domReferenceElement"):null);if(!Ae(U))return;function P(B){if(C.clear(),x.current=!1,l&&!dr(g.current)||si(R.current)>0&&!Qo(T.current,"open"))return;const Q=Qo(T.current,"open",g.current),Y=n.select("domReferenceElement"),$=n.context.triggerElements,z=($.hasElement(B.target)||$.hasMatchingElement(Re=>we(Re,B.target)))&&(!Y||!we(Y,B.target)),Z=B.currentTarget??null,ce=n.select("open"),Se=!ce||z;z&&ce?n.setOpen(!0,Le(dt,B,Z)):Q?C.start(Q,()=>{Se&&n.setOpen(!0,Le(dt,B,Z))}):Se&&n.setOpen(!0,Le(dt,B,Z))}function F(B){if(A()){j();return}k.current();const Q=n.select("domReferenceElement"),Y=qe(Q);D.clear(),S.current=!1;const $=n.context.triggerElements;if(B.relatedTarget&&$.hasElement(B.relatedTarget))return;if(O.current&&r.current.floatingContext){n.select("open")||C.clear();const Z=d.current;w.current=O.current({...r.current.floatingContext,tree:p,x:B.clientX,y:B.clientY,onClose(){j(),I(),!A()&&Z===n.select("domReferenceElement")&&M(B,!0)}});const ce=w.current;ce(B),Y.addEventListener("mousemove",ce),k.current=()=>{Y.removeEventListener("mousemove",ce)};return}(g.current!=="touch"||!we(n.select("floatingElement"),B.relatedTarget))&&M(B)}function W(B){V(B)}return n.select("open")&&U.addEventListener("mouseleave",W),u&&U.addEventListener("mousemove",P,{once:!0}),U.addEventListener("mouseenter",P),U.addEventListener("mouseleave",F),()=>{U.removeEventListener("mouseleave",W),u&&U.removeEventListener("mousemove",P),U.removeEventListener("mouseenter",P),U.removeEventListener("mouseleave",F)}},[I,j,x,r,T,M,n,o,O,V,m,A,l,u,g,R,D,S,C,d,p,k,w]),h.useMemo(()=>{function U(P){g.current=P.pointerType}return{onPointerDown:U,onPointerEnter:U,onMouseMove(P){const{nativeEvent:F}=P,W=P.currentTarget,B=n.select("domReferenceElement"),Q=n.context.triggerElements,Y=n.select("open"),$=(Q.hasElement(P.target)||Q.hasMatchingElement(Z=>we(Z,P.target)))&&(!B||!we(B,P.target));if(l&&!dr(g.current)||Y&&!$||si(R.current)===0||!$&&S.current&&P.movementX**2+P.movementY**2<2)return;D.clear();function z(){if(S.current=!1,A())return;const Z=n.select("open");!x.current&&(!Z||$)&&n.setOpen(!0,Le(dt,F,W))}g.current==="touch"?pn.flushSync(()=>{z()}):$&&Y?z():(S.current=!0,D.start(si(R.current),z))}}},[x,A,l,n,g,R,D,S])}function Da(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=h.useCallback(c=>Os(c,e,"reference"),t),i=h.useCallback(c=>Os(c,e,"floating"),n),a=h.useCallback(c=>Os(c,e,"item"),r),l=h.useCallback(c=>Os(c,e,"trigger"),s);return h.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:a,getTriggerProps:l}),[o,i,a,l])}function Os(e,t,n){const r=new Map,s=n==="item",o={};n==="floating"&&(o.tabIndex=-1,o[Ni]="");for(const i in e)s&&e&&(i===Dd||i===Pd)||(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&&wc(o,a,s,r)}return wc(o,e,s,r),o}function wc(e,t,n,r){for(const s in t){const o=t[s];n&&(s===Dd||s===Pd)||(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 Bx=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Cf(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=h.useMemo(()=>ji(i)?.id||s,[i,s]),f=Bx.get(l)??l,p=Hn()!=null,g=h.useMemo(()=>f==="tooltip"||l==="label"?jn:{"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]),b=h.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=h.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=h.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 h.useMemo(()=>a?{reference:b,floating:w,item:x,trigger:g}:{},[a,b,w,g,x])}function kc(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 $x(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Yx(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 m=performance.now(),p=m-l;if(i===null||a===null||p===0)return i=d,a=f,l=m,null;const g=d-i,b=f-a,x=Math.sqrt(g*g+b*b)/p;return i=d,a=f,l=m,x}const u=({x:d,y:f,placement:m,elements:p,onClose:g,nodeId:b,tree:w})=>function(v){function k(){s.clear(),g()}if(s.clear(),!p.domReference||!p.floating||m==null||d==null||f==null)return;const{clientX:S,clientY:C}=v,D=[S,C],E=ft(v),O=v.type==="mouseleave",T=we(p.floating,E),R=we(p.domReference,E),A=p.domReference.getBoundingClientRect(),M=p.floating.getBoundingClientRect(),I=m.split("-")[0],j=d>M.right-M.width/2,V=f>M.bottom-M.height/2,U=$x(D,A),P=M.width>A.width,F=M.height>A.height,W=(P?A:M).left,B=(P?A:M).right,Q=(F?A:M).top,Y=(F?A:M).bottom;if(T&&(o=!0,!O))return;if(R&&(o=!1),R&&!O){o=!0;return}if(O&&Ae(v.relatedTarget)&&we(p.floating,v.relatedTarget)||w&&Fn(w.nodesRef.current,b).some(({context:Z})=>Z?.open))return;if(I==="top"&&f>=A.bottom-1||I==="bottom"&&f<=A.top+1||I==="left"&&d>=A.right-1||I==="right"&&d<=A.left+1)return k();let $=[];switch(I){case"top":$=[[W,A.top+1],[W,M.bottom-1],[B,M.bottom-1],[B,A.top+1]];break;case"bottom":$=[[W,M.top+1],[W,A.bottom-1],[B,A.bottom-1],[B,M.top+1]];break;case"left":$=[[M.right-1,Y],[M.right-1,Q],[A.left+1,Q],[A.left+1,Y]];break;case"right":$=[[A.right-1,Y],[A.right-1,Q],[M.left+1,Q],[M.left+1,Y]];break}function z([Z,ce]){switch(I){case"top":{const Se=[P?Z+t/2:j?Z+t*4:Z-t*4,ce+t+1],Re=[P?Z-t/2:j?Z+t*4:Z-t*4,ce+t+1],Ee=[[M.left,j||P?M.bottom-t:M.top],[M.right,j?P?M.bottom-t:M.top:M.bottom-t]];return[Se,Re,...Ee]}case"bottom":{const Se=[P?Z+t/2:j?Z+t*4:Z-t*4,ce-t],Re=[P?Z-t/2:j?Z+t*4:Z-t*4,ce-t],Ee=[[M.left,j||P?M.top+t:M.bottom],[M.right,j?P?M.top+t:M.bottom:M.top+t]];return[Se,Re,...Ee]}case"left":{const Se=[Z+t+1,F?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z+t+1,F?ce-t/2:V?ce+t*4:ce-t*4];return[...[[V||F?M.right-t:M.left,M.top],[V?F?M.right-t:M.left:M.right-t,M.bottom]],Se,Re]}case"right":{const Se=[Z-t,F?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z-t,F?ce-t/2:V?ce+t*4:ce-t*4],Ee=[[V||F?M.left+t:M.right,M.top],[V?F?M.left+t:M.right:M.left+t,M.bottom]];return[Se,Re,...Ee]}default:return[]}}if(!kc([S,C],$)){if(o&&!U)return k();if(!O&&r){const Z=c(v.clientX,v.clientY);if(Z!==null&&Z<.1)return k()}kc([S,C],z([d,f]))?!o&&r&&s.start(40,k):k()}};return u.__options={blockPointerEvents:n},u}function Hx(e){const t=h.useRef(""),n=h.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:h.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 Ef(e){const[t,n]=h.useState(null),r=he((a,l)=>{e||n(l||(Md?"touch":""))}),s=h.useCallback(()=>{n(null)},[]),{onClick:o,onPointerDown:i}=Hx(r);return h.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})({}),Wi=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Ux={[Wi.popupOpen]:""},Gx={[Wi.popupOpen]:"",[Wi.pressed]:""},Kx={[Pt.open]:""},zx={[Pt.closed]:""},qx={[Pt.anchorHidden]:""},Xx={open(e){return e?Ux:null}},Zx={open(e){return e?Gx:null}},os={open(e){return e?Kx:zx},anchorHidden(e){return e?qx:null}};function Mf(e){return md(19)?e:e?"true":void 0}let Sc={},Tc={},Cc="";function Qx(e){if(typeof document>"u")return!1;const t=Yn(e);return vt(t).innerWidth-t.documentElement.clientWidth>0}function Jx(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=Yn(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 ev(e){const t=Yn(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 tv(e){const t=Yn(e),n=t.documentElement,r=t.body,s=vt(n);let o=0,i=0,a=!1;const l=_t.create();if(Ey&&(s.visualViewport?.scale??1)!==1)return()=>{};function c(){const f=s.getComputedStyle(n),m=s.getComputedStyle(r),b=(f.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,Sc={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Cc=n.style.scrollBehavior,Tc={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"||m.overflowY==="scroll",k=f.overflowX==="scroll"||m.overflowX==="scroll",S=Math.max(0,s.innerWidth-r.clientWidth),C=Math.max(0,s.innerHeight-r.clientHeight),D=parseFloat(m.marginTop)+parseFloat(m.marginBottom),E=parseFloat(m.marginLeft)+parseFloat(m.marginRight),O=rs(n)?n:r;if(a=Jx(e),a){n.style.scrollbarGutter=b,O.style.overflowY="hidden",O.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(w||v)&&(n.style.overflowY="scroll"),(x||k)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:D||C?`calc(100dvh - ${D+C}px)`:"100dvh",width:E||S?`calc(100vw - ${E+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,Sc),Object.assign(r.style,Tc),a||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Cc)}function d(){u(),l.request(c)}return c(),s.addEventListener("resize",d),()=>{l.cancel(),u(),typeof s.removeEventListener=="function"&&s.removeEventListener("resize",d)}}class nv{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=Yn(t).documentElement,s=vt(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=pd;return}const o=Md||!Qx(t);this.restore=o?ev(t):tv(t)}}const rv=new nv;function Df(e=!0,t=null){Te(()=>{if(e)return rv.acquire(t)},[e,t])}const sv=h.createContext(void 0);function ov(){return h.useContext(sv)?.direction??"ltr"}const iv=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"}=rn(e,t)||{};if(c==null)return{};const f=Nd(u),m={x:n,y:r},p=xa(s),g=ba(p),b=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]-m[p]-o.floating[g],C=m[p]-o.reference[p],D=d==="real"?await i.getOffsetParent?.(c):a.floating;let E=a.floating[k]||o.floating[g];(!E||!await i.isElement?.(D))&&(E=a.floating[k]||o.floating[g]);const O=S/2-C/2,T=E/2-b[g]/2-1,R=Math.min(f[x],T),A=Math.min(f[v],T),M=R,I=E-b[g]-A,j=E/2-b[g]/2+O,V=Ii(M,j,I),U=!l.arrow&&xn(s)!=null&&j!==V&&o.reference[g]/2-(j<M?R:A)-b[g]/2<0,P=U?j<M?j-M:j-I:0;return{[p]:m[p]+P,data:{[p]:V,centerOffset:j-V-P,...U&&{alignmentOffset:P}},reset:U}}}),av=(e,t)=>({...iv(e),options:[e,t]}),lv={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 kx().fn(e)).data?.referenceHidden||o}}}},_s={sideX:"left",sideY:"top"},cv={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:_s};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=Yn(s);f={width:x.documentElement.clientWidth,height:x.documentElement.clientHeight}}else await o.isElement?.(d)&&(f=await o.getDimensions(d));const m=at(a);let p=t,g=n;m==="left"&&(p=f.width-(t+r.width)),m==="top"&&(g=f.height-(n+r.height));const b=m==="left"?"right":_s.sideX,w=m==="top"?"bottom":_s.sideY;return{x:p,y:g,data:{sideX:b,sideY:w}}}};function Pf(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 Ec(e,t,n){const{rects:r,placement:s}=e;return{side:Pf(t,at(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 uv(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:m,mounted:p,collisionAvoidance:g,shiftCrossAxis:b=!1,nodeId:w,adaptiveOrigin:x,lazyFlip:v=!1,externalTree:k}=e,[S,C]=h.useState(null);!p&&S!==null&&C(null);const D=g.side||"flip",E=g.align||"flip",O=g.fallbackAxisSide||"end",T=typeof t=="function"?t:void 0,R=he(T),A=T?R:t,M=$t(t),j=ov()==="rtl",V=S||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":j?"left":"right","inline-start":j?"right":"left"}[r],U=o==="center"?V:`${V}-${o}`;let P=l;const F=1,W=r==="bottom"?F:0,B=r==="top"?F:0,Q=r==="right"?F:0,Y=r==="left"?F:0;typeof P=="number"?P={top:P+W,right:P+Y,bottom:P+B,left:P+Q}:P&&(P={top:(P.top||0)+W,right:(P.right||0)+Y,bottom:(P.bottom||0)+B,left:(P.left||0)+Q});const $={boundary:a==="clipping-ancestors"?"clippingAncestors":a,padding:P},z=h.useRef(null),Z=$t(s),ce=$t(i),Ee=[yx(De=>{const He=Ec(De,r,j),re=typeof Z.current=="function"?Z.current(He):Z.current,G=typeof ce.current=="function"?ce.current(He):ce.current;return{mainAxis:re,crossAxis:G,alignmentAxis:G}},[typeof s!="function"?s:0,typeof i!="function"?i:0,j,r])],et=E==="none"&&D!=="shift",L=!et&&(c||b||D==="shift"),ue=D==="none"?null:vx({...$,padding:{top:P.top+F,right:P.right+F,bottom:P.bottom+F,left:P.left+F},mainAxis:!b&&D==="flip",crossAxis:E==="flip"?"alignment":!1,fallbackAxisSideDirection:O}),te=et?null:bx(De=>{const He=Yn(De.elements.floating).documentElement;return{...$,rootBoundary:b?{x:0,y:0,width:He.clientWidth,height:He.clientHeight}:void 0,mainAxis:E!=="none",crossAxis:L,limiter:c||b?void 0:xx(re=>{if(!z.current)return{};const{width:G,height:oe}=z.current.getBoundingClientRect(),de=yt(at(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,b,P,E]);D==="shift"||E==="shift"||o==="center"?Ee.push(te,ue):Ee.push(ue,te),Ee.push(wx({...$,apply({elements:{floating:De},rects:{reference:He},availableWidth:re,availableHeight:G}){Object.entries({"--available-width":`${re}px`,"--available-height":`${G}px`,"--anchor-width":`${He.width}px`,"--anchor-height":`${He.height}px`}).forEach(([oe,de])=>{De.style.setProperty(oe,de)})}}),av(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(De){const{elements:He,middlewareData:re,placement:G,rects:oe,y:de}=De,xe=at(G),fe=yt(xe),jt=z.current,wn=re.arrow?.x||0,kn=re.arrow?.y||0,qt=jt?.clientWidth||0,cn=jt?.clientHeight||0,It=wn+qt/2,Er=kn+cn/2,Ft=Math.abs(re.shift?.y||0),nt=oe.reference.height/2,Sn=typeof s=="function"?s(Ec(De,r,j)):s,ys=Ft>Sn,Po={top:`${It}px calc(100% + ${Sn}px)`,bottom:`${It}px ${-Sn}px`,left:`calc(100% + ${Sn}px) ${Er}px`,right:`${-Sn}px ${Er}px`}[xe],ct=`${It}px ${oe.reference.y+nt-de}px`;return He.floating.style.setProperty("--transform-origin",L&&fe==="y"&&ys?ct:Po),{}}},lv,x),Te(()=>{!p&&m&&m.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[p,m]);const Me=h.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:Ve,isPositioned:be,floatingStyles:Be}=Nx({rootContext:m,placement:U,middleware:Ee,strategy:n,whileElementsMounted:f?void 0:(...De)=>xc(...De,Me),nodeId:w,externalTree:k}),{sideX:$e,sideY:it}=ge.adaptiveOrigin||_s,Oe=be?n:"fixed",ye=h.useMemo(()=>x?{position:Oe,[$e]:ie,[it]:me}:{position:Oe,...Be},[x,Oe,$e,ie,it,me,Be]),je=h.useRef(null);Te(()=>{if(!p)return;const De=M.current,He=typeof De=="function"?De():De,G=(Mc(He)?He.current:He)||null||null;G!==je.current&&(H.setPositionReference(G),je.current=G)},[p,H,A,M]),h.useEffect(()=>{if(!p)return;const De=M.current;typeof De!="function"&&Mc(De)&&De.current!==je.current&&(H.setPositionReference(De.current),je.current=De.current)},[p,H,A,M]),h.useEffect(()=>{if(f&&p&&se.domReference&&se.floating)return xc(se.domReference,se.floating,J,Me)},[f,p,se,J,Me]);const Ye=at(ne),Nt=Pf(r,Ye,j),kt=xn(ne)||"center",tt=!!ge.hide?.referenceHidden;Te(()=>{v&&p&&be&&C(Ye)},[v,p,be,Ye]);const ln=h.useMemo(()=>({position:"absolute",top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),lt=ge.arrow?.centerOffset!==0;return h.useMemo(()=>({positionerStyles:ye,arrowStyles:ln,arrowRef:z,arrowUncentered:lt,side:Nt,align:kt,physicalSide:Ye,anchorHidden:tt,refs:H,context:Ve,isPositioned:be,update:J}),[ye,ln,z,lt,Nt,kt,Ye,tt,H,Ve,be,J])}function Mc(e){return e!=null&&"current"in e}const Rf=h.forwardRef(function(t,n){const{cutout:r,...s}=t;let o;if(r){const i=r?.getBoundingClientRect();o=`polygon(
|
|
1
|
+
import{r as h,u as bn,i as _g,a as rt,g as Wg,b as yr,c as br,d as Bt,e as Oi,f as Ts,h as go,j as da,k as cr,t as xt,l as _,T as Bg,m as y,n as Te,o as $n,p as hd,q as md,s as he,N as pd,v as ts,w as ns,x as pn,y as Le,z as Hr,E as jn,A as $g,B as on,C as Yl,D as dt,F as gd,G as vt,H as At,I as mn,J as or,K as Ae,L as an,M as Hl,O as fa,P as ha,Q as ur,R as In,S as Yg,U as yd,V as Hg,W as rs,X as yo,Y as bd,Z as Ug,_ as xd,$ as Gg,a0 as vd,a1 as wd,a2 as q,a3 as ma,a4 as kd,a5 as Kg,a6 as zg,a7 as qg,a8 as Xg,a9 as Zg,aa as Qg,ab as Jg,ac as ey,ad as Jt,ae as ty,af as ny,ag as Vo}from"./main-Bo8e66-R.js";import{g as ry,a as pa,b as sy,c as oy,d as iy,e as _o,f as ay,r as ly,h as Ul,i as cy,j as uy,t as dy,s as fy}from"./vibeusage-api-CXScOK2G.js";const hy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),my=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Gl=e=>{const t=my(e);return t.charAt(0).toUpperCase()+t.slice(1)},Sd=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),py=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var gy={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 yy=h.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...a},l)=>h.createElement("svg",{ref:l,...gy,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Sd("lucide",s),...!o&&!py(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,u])=>h.createElement(c,u)),...Array.isArray(o)?o:[o]]));const by=(e,t)=>{const n=h.forwardRef(({className:r,...s},o)=>h.createElement(yy,{ref:o,iconNode:t,className:Sd(`lucide-${hy(Gl(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Gl(e),n};const xy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],vy=by("info",xy),wy=500,ky={style:{transition:"none"}},Td="data-base-ui-click-trigger",Sy={fallbackAxisSide:"end"},Ty={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Cy=[];function ga(e){h.useEffect(e,Cy)}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 _n(){const e=bn(gn.create).current;return ga(e.disposeEffect),e}function Yn(e){return e?.ownerDocument||document}const xr=typeof navigator<"u",Wo=Py(),Cd=Oy(),Ed=Ry(),Ey=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Md=Wo.platform==="MacIntel"&&Wo.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Wo.platform),My=xr&&/apple/i.test(navigator.vendor),Ai=xr&&/android/i.test(Cd)||/android/i.test(Ed);xr&&Cd.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Dy=Ed.includes("jsdom/");function Py(){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 Ry(){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 Oy(){if(!xr)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Ni="data-base-ui-focusable",Dd="active",Pd="selected",Rd="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Jn(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&&_g(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function ft(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 Ay(e){return e.matches("html,body")}function qe(e){return e?.ownerDocument||document}function Od(e){return rt(e)&&e.matches(Rd)}function Kl(e){return e?e.getAttribute("role")==="combobox"&&Od(e):!1}function ji(e){return e?e.hasAttribute(Ni)?e:e.querySelector(`[${Ni}]`)||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 zl(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 Ny(e){e.preventDefault(),e.stopPropagation()}function jy(e){return"nativeEvent"in e}function Iy(e){return e.mozInputSource===0&&e.isTrusted?!0:Ai&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Fy(e){return Dy?!1:!Ai&&e.width===0&&e.height===0||Ai&&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 Ad(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Ly=["top","right","bottom","left"],fr=Math.min,ht=Math.max,Xs=Math.round,Cs=Math.floor,Ut=e=>({x:e,y:e}),Vy={left:"right",right:"left",bottom:"top",top:"bottom"};function Ii(e,t,n){return ht(e,fr(t,n))}function rn(e,t){return typeof e=="function"?e(t):e}function at(e){return e.split("-")[0]}function xn(e){return e.split("-")[1]}function ya(e){return e==="x"?"y":"x"}function ba(e){return e==="y"?"height":"width"}function yt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function xa(e){return ya(yt(e))}function _y(e,t,n){n===void 0&&(n=!1);const r=xn(e),s=xa(e),o=ba(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=Zs(i)),[i,Zs(i)]}function Wy(e){const t=Zs(e);return[Fi(e),t,Fi(t)]}function Fi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ql=["left","right"],Xl=["right","left"],By=["top","bottom"],$y=["bottom","top"];function Yy(e,t,n){switch(e){case"top":case"bottom":return n?t?Xl:ql:t?ql:Xl;case"left":case"right":return t?By:$y;default:return[]}}function Hy(e,t,n,r){const s=xn(e);let o=Yy(at(e),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),t&&(o=o.concat(o.map(Fi)))),o}function Zs(e){const t=at(e);return Vy[t]+e.slice(t.length)}function Uy(e){return{top:0,right:0,bottom:0,left:0,...e}}function Nd(e){return typeof e!="number"?Uy(e):{top:e,right:e,bottom:e,left:e}}function Qs(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 Gy=["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] *)"],Js=Gy.join(","),jd=typeof Element>"u",hr=jd?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,eo=!jd&&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},to=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]"):to(t.parentNode));return i},Ky=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Id=function(t,n,r){if(to(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(Js));return n&&hr.call(t,Js)&&s.unshift(t),s=s.filter(r),s},no=function(t,n,r){for(var s=[],o=Array.from(t);o.length;){var i=o.shift();if(!to(i,!1))if(i.tagName==="SLOT"){var a=i.assignedElements(),l=a.length?a:i.children,c=no(l,!0,r);r.flatten?s.push.apply(s,c):s.push({scopeParent:i,candidates:c})}else{var u=hr.call(i,Js);u&&r.filter(i)&&(n||!t.includes(i))&&s.push(i);var d=i.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(i),f=!to(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(i));if(d&&f){var m=no(d===!0?i.children:d.children,!0,r);r.flatten?s.push.apply(s,m):s.push({scopeParent:i,candidates:m})}else o.unshift.apply(o,i.children)}}return s},Fd=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Ld=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Ky(t))&&!Fd(t)?0:t.tabIndex},zy=function(t,n){var r=Ld(t);return r<0&&n&&!Fd(t)?0:r},qy=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Vd=function(t){return t.tagName==="INPUT"},Xy=function(t){return Vd(t)&&t.type==="hidden"},Zy=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},Qy=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},Jy=function(t){if(!t.name)return!0;var n=t.form||eo(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=Qy(s,t.form);return!o||o===t},eb=function(t){return Vd(t)&&t.type==="radio"},tb=function(t){return eb(t)&&!Jy(t)},nb=function(t){var n,r=t&&eo(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=eo(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},Zl=function(t){var n=t.getBoundingClientRect(),r=n.width,s=n.height;return r===0&&s===0},rb=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=eo(t);if(c&&!c.shadowRoot&&s(c)===!0)return Zl(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(nb(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Zl(t);return!1},sb=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},Li=function(t,n){return!(n.disabled||Xy(n)||rb(n,t)||Zy(n)||sb(n))},Vi=function(t,n){return!(tb(n)||Ld(n)<0||!Li(t,n))},ob=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},_d=function(t){var n=[],r=[];return t.forEach(function(s,o){var i=!!s.scopeParent,a=i?s.scopeParent:s,l=zy(a,i),c=i?_d(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(qy).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=no([t],n.includeContainer,{filter:Vi.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:ob}):r=Id(t,n.includeContainer,Vi.bind(null,n)),_d(r)},ib=function(t,n){n=n||{};var r;return n.getShadowRoot?r=no([t],n.includeContainer,{filter:Li.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Id(t,n.includeContainer,Li.bind(null,n)),r},Wd=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return hr.call(t,Js)===!1?!1:Vi(n,t)};const vr=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Bd(e,t){const n=ss(e,vr()),r=n.length;if(r===0)return;const s=Jn(qe(e)),o=n.indexOf(s),i=o===-1?t===1?0:r-1:o+t;return n[i]}function va(e){return Bd(qe(e).body,1)||e}function $d(e){return Bd(qe(e).body,-1)||e}function Yd(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 ab(e){return Yd(e,1)}function lb(e){return Yd(e,-1)}function ir(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!we(n,r)}function cb(e){ss(e,vr()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Ql(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 ub({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:s="sun",cacheKey:o,timeZone:i,tzOffsetMinutes:a,now:l}={}){const c=h.useMemo(()=>Wg({weeks:r,weekStartsOn:s,now:l}),[l,r,s]),[u,d]=h.useState([]),[f,m]=h.useState(null),[p,g]=h.useState("edge"),[b,w]=h.useState(!1),[x,v]=h.useState(null),k=yr(),S=br(t),C=!n,D=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),E=h.useMemo(()=>{if(!o)return null;const I=go({timeZone:i,offsetMinutes:a});return`vibeusage.heatmap.${o}.${r}.${s}.${I}`},[o,i,a,r,s]),O=h.useCallback(()=>{if(!E||typeof window>"u")return null;try{const I=window.localStorage.getItem(E);if(!I)return null;const j=JSON.parse(I);return!j||!j.heatmap?null:j}catch{return null}},[E]),T=h.useCallback(I=>{if(!(!E||typeof window>"u"))try{window.localStorage.setItem(E,JSON.stringify(I))}catch{}},[E]),R=h.useCallback(()=>{if(!(!E||typeof window>"u"))try{window.localStorage.removeItem(E)}catch{}},[E]),A=h.useCallback(async()=>{const I=await Bt(t);if(!(!I&&!k&&!D)){w(!0),v(null);try{try{const P=await ry({baseUrl:e,accessToken:I,weeks:r,to:c.to,weekStartsOn:s,timeZone:i,tzOffsetMinutes:a}),F=Array.isArray(P?.weeks)?P.weeks:[];if(!F.length&&C){const B=O();if(B?.heatmap){m(B.heatmap),d(B.daily||[]),g("cache");return}}if(!F.some(B=>(Array.isArray(B)?B:[]).some(Q=>Q&&Number.isFinite(Number(Q.level))))&&F.length){const B=[];for(const Y of F)for(const $ of Array.isArray(Y)?Y:[])$?.day&&B.push({day:$.day,total_tokens:$.total_tokens??$.value??0,billable_total_tokens:$.billable_total_tokens??$.value??$.total_tokens??0});const Q=Oi({dailyRows:B,weeks:r,to:P?.to||c.to,weekStartsOn:s});d(B),m({...Q,week_starts_on:s,active_days:B.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:Ts({dailyRows:B,to:P?.to||c.to})}),g("client"),C?T({heatmap:{...Q,week_starts_on:s,active_days:B.filter(Y=>Number(Y?.billable_total_tokens??Y?.total_tokens)>0).length,streak_days:Ts({dailyRows:B,to:P?.to||c.to})},daily:B,fetchedAt:new Date().toISOString()}):R();return}m(P||null),d([]),g("edge"),P&&C?T({heatmap:P,daily:[],fetchedAt:new Date().toISOString()}):C||R();return}catch(P){const F=P,W=F?.status??F?.statusCode;if(W===401||W===403)throw P}const j=await pa({baseUrl:e,accessToken:I,from:c.from,to:c.to,timeZone:i,tzOffsetMinutes:a}),V=Array.isArray(j?.data)?j.data:[];d(V);const U=Oi({dailyRows:V,weeks:r,to:c.to,weekStartsOn:s});m({...U,week_starts_on:s,active_days:V.filter(P=>Number(P?.billable_total_tokens??P?.total_tokens)>0).length,streak_days:Ts({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:Ts({dailyRows:V,to:c.to})},daily:V,fetchedAt:new Date().toISOString()}):R()}catch(j){if(C){const V=O();if(V?.heatmap)m(V.heatmap),d(V.daily||[]),g("cache"),v(null);else{const U=j;v(U?.message||String(U)),d([]),m(null),g("edge")}}else{const V=j;v(V?.message||String(V)),d([]),m(null),g("edge")}}finally{w(!1)}}},[t,e,k,n,C,c.from,c.to,O,S,i,a,s,r,R,T,D]);return h.useEffect(()=>{if(!S&&!n&&!k&&!D){d([]),w(!1),v(null),m(null),g("edge");return}if(!C)R(),d([]),v(null),m(null),g("edge");else{const I=O();I?.heatmap&&(m(I.heatmap),d(I.daily||[]),g("cache"))}A()},[t,k,O,A,S,n,C,R,D]),{range:c,daily:u,heatmap:f,source:k?"mock":p==="client"?"edge":p,loading:b,error:x,refresh:A}}function db({baseUrl:e,accessToken:t,limit:n=3,from:r,to:s,source:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=h.useState([]),[u,d]=h.useState(!1),[f,m]=h.useState(null),p=yr(),g=br(t),b=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),w=h.useCallback(async()=>{const x=await Bt(t);if(!x&&!p&&!b){c([]),m(null),d(!1);return}d(!0),m(null);try{const v=await sy({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);m(k),c([])}finally{d(!1)}},[t,e,r,n,p,o,i,s,a,b]);return h.useEffect(()=>{if(!g&&!p&&!b){c([]),m(null),d(!1);return}w()},[p,w,g,b]),{entries:l,loading:u,error:f,refresh:w}}const fb=24;function hb({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:s,to:o,months:i=fb,cacheKey:a,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:d,sharedRange:f}={}){const[m,p]=h.useState([]),[g,b]=h.useState(()=>({from:s,to:o})),[w,x]=h.useState("edge"),[v,k]=h.useState(null),[S,C]=h.useState(!1),[D,E]=h.useState(null),O=yr(),T=br(t),R=!n,A=Array.isArray(d),M=f?.from||s,I=f?.to||o,j=h.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),V=(()=>{if(!a)return null;const Y=mb(e)||"default",$=go({timeZone:l,offsetMinutes:c});if(j==="hourly")return`vibeusage.trend.${a}.${Y}.hourly.${o||s||"day"}.${$}`;if(j==="monthly")return`vibeusage.trend.${a}.${Y}.monthly.${i}.${o||"today"}.${$}`;const z=`${s||""}.${o||""}`;return`vibeusage.trend.${a}.${Y}.daily.${z}.${$}`})(),U=h.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=h.useCallback(Y=>{if(!(!V||typeof window>"u"))try{window.localStorage.setItem(V,JSON.stringify(Y))}catch{}},[V]),F=h.useCallback(()=>{if(!(!V||typeof window>"u"))try{window.localStorage.removeItem(V)}catch{}},[V]),W=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=h.useCallback(async()=>{if(A){p(Array.isArray(d)?d:[]),b({from:M,to:I}),x("shared"),k(null),C(!1),E(null);return}const Y=await Bt(t);if(!(!Y&&!O&&!W)){C(!0),E(null);try{let $;j==="hourly"?$=await oy({baseUrl:e,accessToken:Y,day:o||s,timeZone:l,tzOffsetMinutes:c}):j==="monthly"?$=await iy({baseUrl:e,accessToken:Y,months:i,to:o,timeZone:l,tzOffsetMinutes:c}):$=await pa({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:[];j==="daily"?ce=$o(ce,z||s,Z||o,{timeZone:l,offsetMinutes:c,now:u}):j==="hourly"?ce=Yo(ce,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(ce=Ho(ce,{timeZone:l,offsetMinutes:c,now:u}));const Se=new Date().toISOString();p(ce),b({from:z,to:Z}),x("edge"),k(Se),R?P({rows:ce,from:z,to:Z,mode:j,fetchedAt:Se}):F()}catch($){if(R){const z=U();if(z?.rows){let Z=j==="daily"?$o(z.rows||[],z.from||s,z.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(z.rows)?z.rows:[];j==="hourly"?Z=Yo(Z,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(Z=Ho(Z,{timeZone:l,offsetMinutes:c,now:u})),p(Z),b({from:z.from||s,to:z.to||o}),x("cache"),k(z.fetchedAt||null),E(null)}else{p([]),b({from:s,to:o}),x("edge"),k(null);const Z=$;E(Z?.message||String(Z))}}else{p([]),b({from:s,to:o}),x("edge"),k(null);const z=$;E(z?.message||String(z))}}finally{C(!1)}}},[t,e,s,O,n,R,j,i,U,T,A,M,d,I,l,o,c,u,F,P,W]);h.useEffect(()=>{if(A){p(Array.isArray(d)?d:[]),b({from:M,to:I}),x("shared"),k(null),C(!1),E(null);return}if(!T&&!n&&!O&&!W){p([]),b({from:s,to:o}),E(null),C(!1),x("edge"),k(null);return}if(!R)F(),p([]),b({from:s,to:o}),E(null),x("edge"),k(null);else{const Y=U();if(Y?.rows){let $=j==="daily"?$o(Y.rows||[],Y.from||s,Y.to||o,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(Y.rows)?Y.rows:[];j==="hourly"?$=Yo($,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&($=Ho($,{timeZone:l,offsetMinutes:c,now:u})),p($),b({from:Y.from||s,to:Y.to||o}),x("cache"),k(Y.fetchedAt||null)}}B()},[t,O,U,B,A,M,d,I,T,n,R,F,W]);const Q=O?"mock":w;return{rows:m,from:g.from||s,to:g.to||o,source:Q,fetchedAt:v,loading:S,error:D,refresh:B}}function mb(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 pb(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=da({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 m=[];for(let p=i;p<=a;p=pb(p,1)){const g=cr(p),b=f.get(g),w=p.getTime()>d;if(b){m.push({...b,missing:!1,future:w});continue}m.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 m}function Yo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Hd({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.hour||o?.label||"",a=gb(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 Ho(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const s=Hd({timeZone:t,offsetMinutes:n,now:r});return s?e.map(o=>{const i=o?.month||o?.label||"",a=yb(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 Hd({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),{}),m=Number(f.year),p=Number(f.month),g=Number(f.day),b=Number(f.hour),w=Number(f.minute);if(Number.isFinite(m)&&Number.isFinite(p)&&Number.isFinite(g)&&Number.isFinite(b)&&Number.isFinite(w)){const x=b*2+(w>=30?1:0);return{year:m,month:p,day:g,hour:b,minute:w,dayNum:m*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,m=u.getUTCDate(),p=u.getUTCHours(),g=u.getUTCMinutes(),b=p*2+(g>=30?1:0);return{year:d,month:f,day:m,hour:p,minute:g,dayNum:d*1e4+f*100+m,slot:b}}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 gb(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 yb(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 Jl({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]=h.useState([]),[f,m]=h.useState(null),[p,g]=h.useState(null),[b,w]=h.useState("edge"),[x,v]=h.useState(null),[k,S]=h.useState(!1),[C,D]=h.useState(null),E=yr(),O=br(t),T=!n,R=(()=>{if(!i)return null;const P=bb(e)||"default",F=o?"daily":"summary",W=go({timeZone:a,offsetMinutes:l});return`vibeusage.usage.${i}.${P}.${r}.${s}.${F}.${W}`})(),A=h.useCallback(()=>{if(!R||typeof window>"u")return null;try{const P=window.localStorage.getItem(R);if(!P)return null;const F=JSON.parse(P);return!F||!F.summary?null:F}catch{return null}},[R]),M=h.useCallback(P=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(P))}catch{}},[R]),I=h.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),j=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),V=h.useCallback(async()=>{const P=await Bt(t);if(!(!P&&!E&&!j)){S(!0),D(null);try{let F=null,W=null;if(o){const[z,Z]=await Promise.allSettled([pa({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l}),_o({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0})]);if(z.status==="rejected")throw z.reason;F=z.value,W=Z.status==="fulfilled"?Z.value:null}else W=await _o({baseUrl:e,accessToken:P,from:r,to:s,timeZone:a,tzOffsetMinutes:l,rolling:!0});let B=o&&Array.isArray(F?.data)?F.data:[];o&&(B=Go(B,r,s,{timeZone:a,offsetMinutes:l,now:c}));let Q=W?.totals||F?.summary?.totals||null,Y=W?.rolling||F?.summary?.rolling||null;if(o&&!Q&&!W)try{const z=await _o({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(B),m(Q),g(Y),w("edge"),v($),Q&&T?M({summary:Q,rolling:Y,daily:B,from:r,to:s,includeDaily:o,fetchedAt:$}):T||I()}catch(F){if(T){const W=A();if(W?.summary){m(W.summary),g(W.rolling||null);const B=Array.isArray(W.daily)?W.daily:[],Q=o?Go(B,W.from||r,W.to||s,{timeZone:a,offsetMinutes:l,now:c}):B;d(Q),w("cache"),v(W.fetchedAt||null),D(null)}else{const B=F;D(B?.message||String(B)),d([]),m(null),g(null),w("edge"),v(null)}}else{const W=F;D(W?.message||String(W)),d([]),m(null),g(null),w("edge"),v(null)}}finally{S(!1)}}},[t,e,r,o,E,n,T,c,A,O,a,s,l,I,M,j]);return h.useEffect(()=>{const P=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!O&&!n&&!E&&!P){d([]),m(null),g(null),D(null),S(!1),w("edge"),v(null);return}if(!T)I(),d([]),m(null),g(null),D(null),w("edge"),v(null);else{const F=A();if(F?.summary){m(F.summary),g(F.rolling||null);const W=Array.isArray(F.daily)?F.daily:[],B=o?Go(W,F.from||r,F.to||s,{timeZone:a,offsetMinutes:l,now:c}):W;d(B),w("cache"),v(F.fetchedAt||null)}}V()},[t,E,A,V,O,n,T,I,j]),{daily:u,summary:f,rolling:p,source:E?"mock":b,fetchedAt:x,loading:k,error:C,refresh:V}}function bb(e){try{return new URL(e).host}catch{return null}}function Uo(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 xb(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Go(e,t,n,{timeZone:r,offsetMinutes:s,now:o}={}){const i=Uo(t),a=Uo(n);if(!i||!a||a<i)return Array.isArray(e)?e:[];const l=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,c=da({timeZone:r,offsetMinutes:s,date:l}),u=Uo(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const m=[];for(let p=i;p<=a;p=xb(p,1)){const g=cr(p),b=f.get(g),w=p.getTime()>d;if(b){m.push({...b,missing:!1,future:w});continue}m.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 m}function vb({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:s,cacheKey:o,timeZone:i,tzOffsetMinutes:a}={}){const[l,c]=h.useState(null),[u,d]=h.useState("edge"),[f,m]=h.useState(!1),[p,g]=h.useState(null),b=yr(),w=br(t),x=!n,v=h.useMemo(()=>{if(!o)return null;const T=wb(e)||"default",R=go({timeZone:i,offsetMinutes:a});return`vibeusage.modelBreakdown.${o}.${T}.${r}.${s}.${R}`},[e,o,r,i,s,a]),k=h.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=h.useCallback(T=>{if(!(!v||typeof window>"u"))try{window.localStorage.setItem(v,JSON.stringify(T))}catch{}},[v]),C=h.useCallback(()=>{if(!(!v||typeof window>"u"))try{window.localStorage.removeItem(v)}catch{}},[v]),D=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),E=h.useCallback(async()=>{const T=await Bt(t);if(!(!T&&!b&&!D)){m(!0),g(null);try{const R=await ay({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 M=R;g(M?.message||String(M))}}else{c(null),d("edge");const A=R;g(A?.message||String(A))}}finally{m(!1)}}},[t,e,r,b,n,x,k,i,s,w,a,C,S,D]);return h.useEffect(()=>{if(!w&&!n&&!b&&!D){c(null),d("edge"),g(null),m(!1);return}if(!x)C(),c(null),d("edge"),g(null);else{const T=k();T?.breakdown&&(c(T.breakdown),d("cache"))}E()},[t,b,k,E,w,n,x,C,D]),{breakdown:l,source:b?"mock":u,loading:f,error:p,refresh:E}}function wb(e){try{return new URL(e).host}catch{return null}}const Ud=new Set(["day","hour","month"]);function kb(e){return Ud.has(e)}function ec(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 Sb(e,t){const n=ec(e),r=ec(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 Tb(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 Cb(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 Eb(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 Mb(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 Db(e,t,n){const r=n==="hour"?Mb:n==="month"?Eb:Cb,s=r(e),o=r(t);return s!=null&&o!=null?s===o?0:s<o?-1:1:Tb(e,t)}function Gd(e,{key:t,dir:n}){const r=n==="asc"?1:-1,s=Array.isArray(e)?e:[],o=Ud.has(t)?(a,l)=>Db(a,l,t):Sb,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 m=o(c,u);return m!==0?m*r:a.index-l.index}).map(a=>a.row)}const Pb=[{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 tc(e){const t=kb(e)?e:"day";return Pb.map((n,r)=>r===0?{...n,key:t}:n)}function nc(e,{key:t,dir:n}){return Gd(e,{key:t,dir:n})}const ro=12,Rb=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Ob(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 Ab(e){return Rb.some(t=>Ob(e?.[t]))}function Nb(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=Gd(t,{key:"month",dir:"asc"}),r=n.findIndex(s=>s?.month&&Ab(s));return r===-1?t:n.slice(r)}function jb(e,t,n=ro){const r=Array.isArray(e)?e:[],s=Number.isFinite(n)&&n>0?n:ro,i=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*s;return r.slice(i,i+s)}function Ib({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 Kd(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Fb(e){const t=Kd(e?.model_id);return t||null}function zd(e,t){return e?.model?String(e.model):t}function Lb(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 m=i.totalTokens>0?Math.round(f/i.totalTokens*1e3)/10:0,p=zd(d,n("shared.placeholder.short")),g=Fb(d),b=i.totalCost>0&&i.totalTokens>0?f/i.totalTokens*i.totalCost:null;return{id:g,name:p,share:m,usage:f,cost:b}}).filter(Boolean);return{label:a,totalPercent:String(c),usd:i.totalCost,usage:i.totalTokens,models:u}})}function Vb(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 m=Array.isArray(f?.models)?f.models:[];for(const p of m){const g=xt(p?.totals?.billable_total_tokens)??0;if(!Number.isFinite(g)||g<=0)continue;l+=g;const b=zd(p,r("shared.placeholder.short")),w=Kd(b);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,b))}}if(!o.size)return[];const c=Array.from(o.values()).reduce((f,m)=>f+m,0),u=l>0?l:c,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(o.entries()).map(([f,m])=>{const p=u>0?(m/u*100).toFixed(1):"0.0";return{id:f,name:i.get(f)||r("shared.placeholder.short"),tokens:m,percent:String(p)}}).sort((f,m)=>m.tokens!==f.tokens?m.tokens-f.tokens:String(f.name).localeCompare(String(m.name))).slice(0,d)}function wa(){const e=h.useContext(Bg);if(e===null)throw new Error("useTheme must be used within a ThemeProvider");return e}const En=12,Or=3,Ko=26,_b=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],Wb=["#064e3b","#065f46","#059669","#10b981","#34d399"],Bb=[_("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 $b(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 Yb(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 qd(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Hb(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function Ub(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return qd(e,-((r-n+7)%7))}function Gb(e,t,n){if(!e)return[];const r=Yb(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=Ub(r,n),i=qd(o,-(e-1)*7),a=[],l=new Set;for(const c of s){const u=Math.floor(Hb(i,c)/7);u<0||u>=e||l.has(u)||(l.add(u),a.push({label:Bb[c.getUTCMonth()],index:u}))}return a}function Kb({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:s}=wa(),i=s==="dark"?Wb:_b,a=h.useRef(null);h.useEffect(()=>{const p=a.current;p&&(p.scrollLeft=p.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=h.useMemo(()=>{const p=Array.isArray(e?.weeks)?e.weeks:[];if(!p.length)return{weeks:[]};const g=[];for(const b of p)for(const w of Array.isArray(b)?b:[])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 Oi({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=h.useMemo(()=>Gb(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return y.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:_("heatmap.empty")});const m=Ko+u.length*En+Math.max(0,u.length-1)*Or;return y.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:[y.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[y.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:_("heatmap.title")}),y.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||_("heatmap.legend.utc")})]}),y.jsx("div",{ref:a,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:y.jsxs("div",{style:{minWidth:m},children:[y.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${Ko}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[y.jsx("span",{}),f.map(p=>y.jsx("span",{style:{gridColumnStart:p.index+2},className:"whitespace-nowrap",children:p.label},`${p.label}-${p.index}`))]}),y.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${Ko}px repeat(${u.length}, ${En}px)`,columnGap:Or},children:[y.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=>y.jsx("span",{className:"leading-none",children:p},p))}),y.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${En}px)`,gap:Or},children:u.map((p,g)=>(Array.isArray(p)?p:[]).map((b,w)=>{if(!b)return null;const x=b.day||`e-${g}-${w}`,v=Number(b.level)||0,k=i[v]||i[0],S=t||n||_("heatmap.legend.utc");return y.jsx("span",{title:_("heatmap.tooltip",{day:b.day,value:$b(b.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&&y.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[y.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.less")}),y.jsx("div",{className:"flex gap-0.5",children:i.map((p,g)=>y.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:p}},g))}),y.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:_("heatmap.legend.more")})]})]})}const zb={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Xd={...zb,position:"fixed",top:0,left:0};function $t(e){const t=bn(qb,e).current;return t.next=e,Te(t.effect),t}function qb(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var so=Symbol("NOT_FOUND");function Xb(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Zb(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function Qb(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 rc=e=>Array.isArray(e)?e:[e];function Jb(e){const t=Array.isArray(e[0])?e[0]:e;return Qb(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function e0(e,t){const n=[],{length:r}=e;for(let s=0;s<r;s++)n.push(e[s].apply(null,t));return n}function t0(e){let t;return{get(n){return t&&e(t.key,n)?t.value:so},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function n0(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 so}function s(a,l){r(a)===so&&(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 r0=(e,t)=>e===t;function s0(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 o0(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=r0,maxSize:s=1,resultEqualityCheck:o}=n,i=s0(r);let a=0;const l=s<=1?t0(i):n0(s,i);function c(){let u=l.get(arguments);if(u===so){if(u=e.apply(null,arguments),a++,o){const f=l.getEntries().find(m=>o(m.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 i0=class{constructor(e){this.value=e}deref(){return this.value}},a0=typeof WeakRef<"u"?WeakRef:i0,l0=0,sc=1;function Es(){return{s:l0,v:void 0,o:null,p:null}}function Zd(e,t={}){let n=Es();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 m=arguments[d];if(typeof m=="function"||typeof m=="object"&&m!==null){let p=a.o;p===null&&(a.o=p=new WeakMap);const g=p.get(m);g===void 0?(a=Es(),p.set(m,a)):a=g}else{let p=a.p;p===null&&(a.p=p=new Map);const g=p.get(m);g===void 0?(a=Es(),p.set(m,a)):a=g}}const c=a;let u;if(a.s===sc)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 a0(u):u}return c.s=sc,c.v=u,u}return i.clearCache=()=>{n=Es(),i.resetResultsCount()},i.resultsCount=()=>o,i.resetResultsCount=()=>{o=0},i}function Qd(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()),Xb(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:d,memoizeOptions:f=[],argsMemoize:m=Zd,argsMemoizeOptions:p=[]}=u,g=rc(f),b=rc(p),w=Jb(s),x=d(function(){return o++,c.apply(null,arguments)},...g),v=m(function(){i++;const S=e0(w,arguments);return a=x.apply(null,S),a},...b);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:m})};return Object.assign(r,{withTypes:()=>r}),r}var c0=Qd(Zd),u0=Object.assign((e,t=c0)=>{Zb(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:()=>u0});Qd({memoize:o0,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const pe=(e,t,n,r,s,o,...i)=>{if(i.length>0)throw new Error($n(1));let a;if(e)a=e;else throw new Error("Missing arguments");return a};var zo={exports:{}},qo={};var oc;function d0(){if(oc)return qo;oc=1;var e=hd();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 m=f(),p=r({inst:{value:m,getSnapshot:f}}),g=p[0].inst,b=p[1];return o(function(){g.value=m,g.getSnapshot=f,l(g)&&b({inst:g})},[d,m,f]),s(function(){return l(g)&&b({inst:g}),d(function(){l(g)&&b({inst:g})})},[d]),i(m),m}function l(d){var f=d.getSnapshot;d=d.value;try{var m=f();return!n(d,m)}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 qo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,qo}var ic;function Jd(){return ic||(ic=1,zo.exports=d0()),zo.exports}var f0=Jd(),Xo={exports:{}},Zo={};var ac;function h0(){if(ac)return Zo;ac=1;var e=hd(),t=Jd();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 Zo.useSyncExternalStoreWithSelector=function(c,u,d,f,m){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),m!==void 0&&g.hasValue){var D=g.value;if(m(D,C))return k=D}return k=C}if(D=k,r(v,C))return D;var E=f(C);return m!==void 0&&m(D,E)?(v=C,D):(v=C,k=E)}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,m]);var b=s(c,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=b},[b]),l(b),b},Zo}var lc;function m0(){return lc||(lc=1,Xo.exports=h0()),Xo.exports}var p0=m0();const g0=md(19),y0=g0?x0:v0;function b0(e,t,n,r,s){return y0(e,t,n,r,s)}function x0(e,t,n,r,s){const o=h.useCallback(()=>t(e.getSnapshot(),n,r,s),[e,t,n,r,s]);return f0.useSyncExternalStore(e.subscribe,o,o)}function v0(e,t,n,r,s){return p0.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 ka extends Vr{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){h.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){h.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)=>{h.useDebugValue(t);const o=this.selectors[t];return b0(this,o,n,r,s)};useContextCallback(t,n){h.useDebugValue(t);const r=he(n??pd);this.context[t]=r}useStateSetter(t){const n=h.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 Ms=null;class w0{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 Ds=new w0;class _t{static create(){return new _t}static request(t){return Ds.request(t)}static cancel(t){return Ds.cancel(t)}currentId=Ms;request(t){this.cancel(),this.currentId=Ds.request(()=>{this.currentId=Ms,t()})}cancel=()=>{this.currentId!==Ms&&(Ds.cancel(this.currentId),this.currentId=Ms)};disposeEffect=()=>this.cancel}function Sa(){const e=bn(_t.create).current;return ga(e.disposeEffect),e}function ef(){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 k0{nodesRef={current:[]};events=ef();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 tf=h.createContext(null),nf=h.createContext(null),Hn=()=>h.useContext(tf)?.id||null,wr=e=>{const t=h.useContext(nf);return e??t};function S0(e){const t=ts(),n=wr(e),r=Hn();return Te(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function T0(e){const{children:t,id:n}=e,r=Hn();return y.jsx(tf.Provider,{value:h.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function C0(e){const{children:t,externalTree:n}=e,r=bn(()=>n??new k0).current;return y.jsx(nf.Provider,{value:r,children:t})}function Ur(e){return`data-base-ui-${e}`}function Qo(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=h.forwardRef(function(t,n){const[r,s]=h.useState();Te(()=>{My&&s("button")},[]);const o={tabIndex:0,role:r};return y.jsx("span",{...t,ref:n,style:Xd,"aria-hidden":r?void 0:!0,...o,"data-base-ui-focus-guard":""})});let cc=0;function Jo(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:s=!1}=t;r&&cancelAnimationFrame(cc);const o=()=>e?.focus({preventScroll:n});s?o():cc=requestAnimationFrame(o)}const ar={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function uc(e){return e==="inert"?ar.inert:e==="aria-hidden"?ar["aria-hidden"]:ar.none}let Ps=new WeakSet,Rs={},ei=0;const rf=e=>e&&(e.host||rf(e.parentNode)),E0=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=rf(n);return e.contains(r)?r:null}).filter(n=>n!=null);function M0(e,t,n,r){const s="data-base-ui-inert",o=r?"inert":n?"aria-hidden":null,i=E0(t,e),a=new Set,l=new Set(i),c=[];Rs[s]||(Rs[s]=new WeakMap);const u=Rs[s];i.forEach(d),f(t),a.clear();function d(m){!m||a.has(m)||(a.add(m),m.parentNode&&d(m.parentNode))}function f(m){!m||l.has(m)||[].forEach.call(m.children,p=>{if(ns(p)!=="script")if(a.has(p))f(p);else{const g=o?p.getAttribute(o):null,b=g!==null&&g!=="false",w=uc(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&&b&&Ps.add(p),v===1&&p.setAttribute(s,""),!b&&o&&p.setAttribute(o,o==="inert"?"":"true")}})}return ei+=1,()=>{c.forEach(m=>{const p=uc(o),b=(p.get(m)||0)-1,w=(u.get(m)||0)-1;p.set(m,b),u.set(m,w),b||(!Ps.has(m)&&o&&m.removeAttribute(o),Ps.delete(m)),w||m.removeAttribute(s)}),ei-=1,ei||(ar.inert=new WeakMap,ar["aria-hidden"]=new WeakMap,ar.none=new WeakMap,Ps=new WeakSet,Rs={})}}function D0(e,t=!1,n=!1){const r=qe(e[0]).body;return M0(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const sf=h.createContext(null),of=()=>h.useContext(sf),P0=Ur("portal");function R0(e={}){const{ref:t,container:n,componentProps:r=jn,elementProps:s,elementState:o}=e,i=ts(),l=of()?.portalNode,[c,u]=h.useState(null),[d,f]=h.useState(null),m=he(w=>{w!==null&&f(w)}),p=h.useRef(null);Te(()=>{if(n===null){p.current&&(p.current=null,f(null),u(null));return}if(i==null)return;const w=(n&&($g(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=on("div",r,{ref:[t,m],state:o,props:[{id:i,[P0]:""},s]});return{portalNode:d,portalSubtree:c&&g?pn.createPortal(g,c):null}}const af=h.forwardRef(function(t,n){const{children:r,container:s,className:o,render:i,renderGuards:a,...l}=t,{portalNode:c,portalSubtree:u}=R0({container:s,ref:n,componentProps:t,elementProps:l}),d=h.useRef(null),f=h.useRef(null),m=h.useRef(null),p=h.useRef(null),[g,b]=h.useState(null),w=g?.modal,x=g?.open,v=typeof a=="boolean"?a:!!g&&!g.modal&&g.open&&!!c;h.useEffect(()=>{if(!c||w)return;function S(C){c&&C.relatedTarget&&ir(C)&&(C.type==="focusin"?Ql:cb)(c)}return c.addEventListener("focusin",S,!0),c.addEventListener("focusout",S,!0),()=>{c.removeEventListener("focusin",S,!0),c.removeEventListener("focusout",S,!0)}},[c,w]),h.useEffect(()=>{!c||x||Ql(c)},[x,c]);const k=h.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:m,afterInsideRef:p,portalNode:c,setFocusManagerState:b}),[c]);return y.jsxs(h.Fragment,{children:[u,y.jsxs(sf.Provider,{value:k,children:[v&&c&&y.jsx(mr,{"data-type":"outside",ref:d,onFocus:S=>{if(ir(S,c))m.current?.focus();else{const C=g?g.domReference:null;$d(C)?.focus()}}}),v&&c&&y.jsx("span",{"aria-owns":c.id,style:Ty}),c&&pn.createPortal(r,c),v&&c&&y.jsx(mr,{"data-type":"outside",ref:f,onFocus:S=>{if(ir(S,c))p.current?.focus();else{const C=g?g.domReference:null;va(C)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Le(Hr,S.nativeEvent))}}})]})]})});function en(e){return e==null?e:"current"in e?e.current:e}function O0(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 dc=20;let fn=[];function Ta(){fn=fn.filter(e=>e.isConnected)}function A0(e){Ta(),e&&ns(e)!=="body"&&(fn.push(e),fn.length>dc&&(fn=fn.slice(-dc)))}function ti(){return Ta(),fn[fn.length-1]}function N0(e){if(!e)return null;const t=vr();return Wd(e,t)?e:ss(e,t)[0]||e}function j0(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():At(e).display!=="none"}function fc(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=vr(),s=ib(e,n).filter(i=>{const a=i.getAttribute("data-tabindex")||"";return Wd(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 lf(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:m,beforeContentFocusGuardRef:p,externalTree:g}=e,b="rootStore"in t?t.rootStore:t,w=b.useState("open"),x=b.useState("domReferenceElement"),v=b.useState("floatingElement"),{events:k,dataRef:S}=b.context,C=he(()=>S.current.floatingContext?.nodeId),D=he(d),E=o===!1,O=Kl(x)&&E,T=$t(s),R=$t(o),A=$t(i),M=$t(u),I=wr(g),j=of(),V=h.useRef(null),U=h.useRef(null),P=h.useRef(!1),F=h.useRef(!1),W=h.useRef(!1),B=h.useRef(-1),Q=h.useRef(""),Y=h.useRef(""),$=h.useRef(null),z=h.useRef(null),Z=Yl($,p,j?.beforeInsideRef),ce=Yl(z,j?.afterInsideRef),Se=_n(),Re=_n(),Ee=Sa(),et=j!=null,L=ji(v),ue=he((H=L)=>H?ss(H,vr()):[]),te=he(H=>{const se=ue(H);return T.current.map(()=>se).filter(Boolean).flat()});h.useEffect(()=>{if(r||!l)return;function H(ie){ie.key==="Tab"&&we(L,Jn(qe(L)))&&ue().length===0&&!O&&Ny(ie)}const se=qe(L);return se.addEventListener("keydown",H),()=>{se.removeEventListener("keydown",H)}},[r,x,L,l,T,O,ue,te]),h.useEffect(()=>{if(r||!v)return;function H(se){const ie=ft(se),ge=ue().indexOf(ie);ge!==-1&&(B.current=ge)}return v.addEventListener("focusin",H),()=>{v.removeEventListener("focusin",H)}},[r,v,ue]),h.useEffect(()=>{if(r||!w)return;const H=qe(L);function se(){W.current=!1}function ie(ge){const J=ft(ge),ne=we(v,J)||we(x,J)||we(j?.portalNode,J);W.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,j]),h.useEffect(()=>{if(r||!c)return;function H(){F.current=!0,Re.start(0,()=>{F.current=!1})}function se(J){const ne=J.relatedTarget,Ve=J.currentTarget,be=ft(J);queueMicrotask(()=>{const Be=C(),$e=b.context.triggerElements,it=ne?.hasAttribute(Ur("focus-guard"))&&[$.current,z.current,j?.beforeInsideRef.current,j?.afterInsideRef.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,en(m),en(f)].includes(ne),Oe=!(we(x,ne)||we(v,ne)||we(ne,v)||we(j?.portalNode,ne)||ne!=null&&$e.hasElement(ne)||$e.hasMatchingElement(ye=>we(ye,ne))||it||I&&(Fn(I.nodesRef.current,Be).find(ye=>we(ye.context?.elements.floating,ne)||we(ye.context?.elements.domReference,ne))||zl(I.nodesRef.current,Be).find(ye=>[ye.context?.elements.floating,ji(ye.context?.elements.floating)].includes(ne)||ye.context?.elements.domReference===ne)));if(Ve===x&&L&&fc(L,T),a&&Ve!==x&&!j0(be)&&Jn(qe(L))===qe(L).body){if(rt(L)&&(L.focus(),a==="popup")){Ee.request(()=>{L.focus()});return}const ye=B.current,je=ue(),Ye=je[ye]||je[je.length-1]||L;rt(Ye)&&Ye.focus()}if(S.current.insideReactTree){S.current.insideReactTree=!1;return}(O||!l)&&ne&&Oe&&!F.current&&(O||ne!==ti())&&(P.current=!0,b.setOpen(!1,Le(Hr,J)))})}function ie(){W.current||(S.current.insideReactTree=!0,Se.start(0,()=>{S.current.insideReactTree=!1}))}const me=rt(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),j&&(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,I,j,b,c,a,ue,O,C,T,S,Se,Re,Ee,f,m]),h.useEffect(()=>{if(r||!v||!w)return;const H=Array.from(j?.portalNode?.querySelectorAll(`[${Ur("portal")}]`)||[]),ie=(I?zl(I.nodesRef.current,C()):[]).find(J=>Kl(J.context?.elements.domReference||null))?.context?.elements.domReference,me=[v,ie,...H,...D(),V.current,U.current,$.current,z.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,en(m),en(f),O?x:null].filter(J=>J!=null),ge=D0(me,l||O);return()=>{ge()}},[w,r,x,v,l,T,j,O,I,C,D,f,m]),Te(()=>{if(!w||r||!rt(L))return;const H=qe(L),se=Jn(H);queueMicrotask(()=>{const ie=te(L),me=R.current,ge=typeof me=="function"?me(M.current||""):me;if(ge===void 0||ge===!1)return;let J;ge===!0||ge===null?J=ie[0]||L:J=en(ge),J=J||ie[0]||L,!we(L,se)&&Jo(J,{preventScroll:J===L})})},[r,w,L,E,te,R,M]),Te(()=>{if(r||!L)return;const H=qe(L),se=Jn(H);A0(se);function ie(J){if(J.open||(Q.current=O0(J.nativeEvent,Y.current)),J.reason===dt&&J.nativeEvent.type==="mouseleave"&&(P.current=!0),J.reason===gd)if(J.nested)P.current=!1;else if(Iy(J.nativeEvent)||Fy(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,Xd),et&&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||ti();return be&&be.isConnected?be:me}const Ve=x||ti()||me;return en(ne)||Ve}return()=>{k.off("openchange",ie);const J=Jn(H),ne=we(v,J)||I&&Fn(I.nodesRef.current,C(),!1).some(be=>we(be.context?.elements.floating,J)),Ve=ge();queueMicrotask(()=>{const be=N0(Ve),Be=typeof A.current!="boolean";A.current&&!P.current&&rt(be)&&(!(!Be&&be!==J&&J!==H.body)||ne)&&be.focus({preventScroll:!0}),me.remove()})}},[r,v,L,A,S,k,I,et,x,C]),h.useEffect(()=>{queueMicrotask(()=>{P.current=!1})},[r]),h.useEffect(()=>{if(r||!w)return;function H(ie){ft(ie)?.closest(`[${Td}]`)&&(F.current=!0)}const se=qe(L);return se.addEventListener("pointerdown",H,!0),()=>{se.removeEventListener("pointerdown",H,!0)}},[r,w,L]),Te(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:c,open:w,onOpenChange:b.setOpen,domReference:x}),()=>{j.setFocusManagerState(null)}},[r,j,l,w,b,c,x]),Te(()=>{if(!(r||!L))return fc(L,T),()=>{queueMicrotask(Ta)}},[r,L,T]);const Me=!r&&(l?!O:!0)&&(et||l);return y.jsxs(h.Fragment,{children:[Me&&y.jsx(mr,{"data-type":"inside",ref:Z,onFocus:H=>{if(l){const se=te();Jo(se[se.length-1])}else j?.portalNode&&(P.current=!1,ir(H,j.portalNode)?va(x)?.focus():en(m??j.beforeOutsideRef)?.focus())}}),n,Me&&y.jsx(mr,{"data-type":"inside",ref:ce,onFocus:H=>{l?Jo(te()[0]):j?.portalNode&&(c&&(P.current=!0),ir(H,j.portalNode)?$d(x)?.focus():en(f??j.afterOutsideRef)?.focus())}})]})}function I0(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=h.useRef(void 0),d=Sa(),f=_n(),m=h.useMemo(()=>({onPointerDown(p){u.current=p.pointerType},onMouseDown(p){const g=u.current,b=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(Od(b.target)){const D=Le(mn,b,b.target);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,D)}):n.setOpen(S,D);return}const C=p.currentTarget;d.request(()=>{const D=Le(mn,b,C);S&&g==="touch"&&c>0?f.start(c,()=>{n.setOpen(!0,D)}):n.setOpen(S,D)})},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 b=n.select("open"),w=r.current.openEvent,x=n.select("domReferenceElement")!==p.currentTarget,v=b&&x||!(b&&i&&(!(w&&l)||Ad(w))),k=Le(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 h.useMemo(()=>s?{reference:m}:jn,[s,m])}function hc(e,t,n){let{reference:r,floating:s}=e;const o=yt(t),i=xa(t),a=ba(i),l=at(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 m;switch(l){case"top":m={x:u,y:r.y-s.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-s.width,y:d};break;default:m={x:r.x,y:r.y}}switch(xn(t)){case"start":m[i]-=f*(n&&c?-1:1);break;case"end":m[i]+=f*(n&&c?-1:1);break}return m}async function F0(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:m=0}=rn(t,e),p=Nd(m),b=a[f?d==="floating"?"reference":"floating":d],w=Qs(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.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=Qs(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 L0=50,V0=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:F0},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}=hc(c,r,l),f=r,m=0;const p={};for(let g=0;g<o.length;g++){const b=o[g];if(!b)continue;const{name:w,fn:x}=b,{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&&m<L0&&(m++,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}=hc(c,f,l)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}},_0=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:m="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...b}=rn(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const w=at(s),x=yt(a),v=at(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(v||!g?[Zs(a)]:Wy(a)),C=p!=="none";!f&&C&&S.push(...Hy(a,g,p,k));const D=[a,...S],E=await l.detectOverflow(t,b),O=[];let T=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&O.push(E[w]),d){const I=_y(s,i,k);O.push(E[I[0]],E[I[1]])}if(T=[...T,{placement:s,overflows:O}],!O.every(I=>I<=0)){var R,A;const I=(((R=o.flip)==null?void 0:R.index)||0)+1,j=D[I];if(j&&(!(d==="alignment"?x!==yt(j):!1)||T.every(P=>yt(P.placement)===x?P.overflows[0]>0:!0)))return{data:{index:I,overflows:T},reset:{placement:j}};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(m){case"bestFit":{var M;const U=(M=T.filter(P=>{if(C){const F=yt(P.placement);return F===x||F==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(F=>F>0).reduce((F,W)=>F+W,0)]).sort((P,F)=>P[1]-F[1])[0])==null?void 0:M[0];U&&(V=U);break}case"initialPlacement":V=a;break}if(s!==V)return{reset:{placement:V}}}return{}}}};function mc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pc(e){return Ly.some(t=>e[t]>=0)}const W0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...o}=rn(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...o,elementContext:"reference"}),a=mc(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:pc(a)}}}case"escaped":{const i=await r.detectOverflow(t,{...o,altBoundary:!0}),a=mc(i,n.floating);return{data:{escapedOffsets:a,escaped:pc(a)}}}default:return{}}}}},cf=new Set(["left","top"]);async function B0(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=at(n),a=xn(n),l=yt(n)==="y",c=cf.has(i)?-1:1,u=o&&l?-1:1,d=rn(t,e);let{mainAxis:f,crossAxis:m,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"&&(m=a==="end"?p*-1:p),l?{x:m*u,y:f*c}:{x:f*c,y:m*u}}const $0=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 B0(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}}}}},Y0=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}=rn(e,t),u={x:n,y:r},d=await o.detectOverflow(t,c),f=yt(at(s)),m=ya(f);let p=u[m],g=u[f];if(i){const w=m==="y"?"top":"left",x=m==="y"?"bottom":"right",v=p+d[w],k=p-d[x];p=Ii(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=Ii(v,g,k)}const b=l.fn({...t,[m]:p,[f]:g});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[m]:i,[f]:a}}}}}},H0=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}=rn(e,t),u={x:n,y:r},d=yt(s),f=ya(d);let m=u[f],p=u[d];const g=rn(a,t),b=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]+b.mainAxis,S=o.reference[f]+o.reference[v]-b.mainAxis;m<k?m=k:m>S&&(m=S)}if(c){var w,x;const v=f==="y"?"width":"height",k=cf.has(at(s)),S=o.reference[d]-o.floating[v]+(k&&((w=i.offset)==null?void 0:w[d])||0)+(k?0:b.crossAxis),C=o.reference[d]+o.reference[v]+(k?0:((x=i.offset)==null?void 0:x[d])||0)-(k?b.crossAxis:0);p<S?p=S:p>C&&(p=C)}return{[f]:m,[d]:p}}}},U0=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}=rn(e,t),u=await i.detectOverflow(t,c),d=at(s),f=xn(s),m=yt(s)==="y",{width:p,height:g}=o.floating;let b,w;d==="top"||d==="bottom"?(b=d,w=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=d,b=f==="end"?"top":"bottom");const x=g-u.top-u.bottom,v=p-u.left-u.right,k=fr(g-u[b],x),S=fr(p-u[w],v),C=!t.middlewareData.shift;let D=k,E=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(E=v),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(D=x),C&&!f){const T=ht(u.left,0),R=ht(u.right,0),A=ht(u.top,0),M=ht(u.bottom,0);m?E=p-2*(T!==0||R!==0?T+R:ht(u.left,u.right)):D=g-2*(A!==0||M!==0?A+M:ht(u.top,u.bottom))}await l({...t,availableWidth:E,availableHeight:D});const O=await i.getDimensions(a.floating);return p!==O.width||g!==O.height?{reset:{rects:!0}}:{}}}};function uf(e){const t=At(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=rt(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,a=Xs(n)!==o||Xs(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function Ca(e){return Ae(e)?e:e.contextElement}function lr(e){const t=Ca(e);if(!rt(t))return Ut(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=uf(t);let i=(o?Xs(n.width):n.width)/r,a=(o?Xs(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const G0=Ut(0);function df(e){const t=vt(e);return!fa()||!t.visualViewport?G0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function K0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vt(e)?!1:t}function Wn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Ca(e);let i=Ut(1);t&&(r?Ae(r)&&(i=lr(r)):i=lr(e));const a=K0(o,n,r)?df(o):Ut(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),m=r&&Ae(r)?vt(r):r;let p=f,g=Hl(p);for(;g&&r&&m!==p;){const b=lr(g),w=g.getBoundingClientRect(),x=At(g),v=w.left+(g.clientLeft+parseFloat(x.paddingLeft))*b.x,k=w.top+(g.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=v,c+=k,p=vt(g),g=Hl(p)}}return Qs({width:u,height:d,x:l,y:c})}function bo(e,t){const n=yo(e).scrollLeft;return t?t.left+n:Wn(an(e)).left+n}function ff(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-bo(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function z0(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",i=an(r),a=t?ha(t.floating):!1;if(r===i||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Ut(1);const u=Ut(0),d=rt(r);if((d||!d&&!o)&&((ns(r)!=="body"||rs(i))&&(l=yo(r)),d)){const m=Wn(r);c=lr(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const f=i&&!d&&!o?ff(i,l):Ut(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 q0(e){return Array.from(e.getClientRects())}function X0(e){const t=an(e),n=yo(e),r=e.ownerDocument.body,s=ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+bo(e);const a=-n.scrollTop;return At(r).direction==="rtl"&&(i+=ht(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}const gc=25;function Z0(e,t){const n=vt(e),r=an(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=fa();(!u||u&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=bo(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),m=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-m);p<=gc&&(o-=p)}else c<=gc&&(o+=c);return{width:o,height:i,x:a,y:l}}function Q0(e,t){const n=Wn(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=rt(e)?lr(e):Ut(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 yc(e,t,n){let r;if(t==="viewport")r=Z0(e,n);else if(t==="document")r=X0(an(e));else if(Ae(t))r=Q0(t,n);else{const s=df(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Qs(r)}function hf(e,t){const n=ur(e);return n===t||!Ae(n)||In(n)?!1:At(n).position==="fixed"||hf(n,t)}function J0(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=yd(i);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||rs(i)&&!l&&hf(e,i))?r=r.filter(u=>u!==i):s=a,i=ur(i)}return t.set(e,r),r}function ex(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?ha(t)?[]:J0(t,this._c):[].concat(n),r],a=yc(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 m=yc(t,i[f],s);l=ht(m.top,l),c=fr(m.right,c),u=fr(m.bottom,u),d=ht(m.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function tx(e){const{width:t,height:n}=uf(e);return{width:t,height:n}}function nx(e,t,n){const r=rt(t),s=an(t),o=n==="fixed",i=Wn(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=Ut(0);function c(){l.x=bo(s)}if(r||!r&&!o)if((ns(t)!=="body"||rs(s))&&(a=yo(t)),r){const m=Wn(t,!0,o,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}else s&&c();o&&!r&&s&&c();const u=s&&!r&&!o?ff(s,a):Ut(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 ni(e){return At(e).position==="static"}function bc(e,t){if(!rt(e)||At(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return an(e)===n&&(n=n.ownerDocument.body),n}function mf(e,t){const n=vt(e);if(ha(e))return n;if(!rt(e)){let s=ur(e);for(;s&&!In(s);){if(Ae(s)&&!ni(s))return s;s=ur(s)}return n}let r=bc(e,t);for(;r&&Yg(r)&&ni(r);)r=bc(r,t);return r&&In(r)&&ni(r)&&!yd(r)?n:r||Hg(e)||n}const rx=async function(e){const t=this.getOffsetParent||mf,n=this.getDimensions,r=await n(e.floating);return{reference:nx(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sx(e){return At(e).direction==="rtl"}const ox={convertOffsetParentRelativeRectToViewportRelativeRect:z0,getDocumentElement:an,getClippingRect:ex,getOffsetParent:mf,getElementRects:rx,getClientRects:q0,getDimensions:tx,getScale:lr,isElement:Ae,isRTL:sx};function pf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ix(e,t){let n=null,r;const s=an(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:m}=c;if(a||t(),!f||!m)return;const p=Cs(d),g=Cs(s.clientWidth-(u+f)),b=Cs(s.clientHeight-(d+m)),w=Cs(u),v={rootMargin:-p+"px "+-g+"px "+-b+"px "+-w+"px",threshold:ht(0,fr(1,l))||1};let k=!0;function S(C){const D=C[0].intersectionRatio;if(D!==l){if(!k)return i();D?i(!1,D):r=setTimeout(()=>{i(!1,1e-7)},1e3)}D===1&&!pf(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 xc(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=Ca(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?ix(c,n):null;let f=-1,m=null;i&&(m=new ResizeObserver(w=>{let[x]=w;x&&x.target===c&&m&&t&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=m)==null||v.observe(t)})),n()}),c&&!l&&m.observe(c),t&&m.observe(t));let p,g=l?Wn(e):null;l&&b();function b(){const w=Wn(e);g&&!pf(g,w)&&n(),g=w,p=requestAnimationFrame(b)}return n(),()=>{var w;u.forEach(x=>{s&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),d?.(),(w=m)==null||w.disconnect(),m=null,l&&cancelAnimationFrame(p)}}const ax=$0,lx=Y0,cx=_0,ux=U0,dx=W0,fx=H0,hx=(e,t,n)=>{const r=new Map,s={platform:ox,...n},o={...s.platform,_c:r};return V0(e,t,{...s,platform:o})};var mx=typeof document<"u",px=function(){},Vs=mx?h.useLayoutEffect:px;function oo(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(!oo(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)&&!oo(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function gf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function vc(e,t){const n=gf(e);return Math.round(t*n)/n}function ri(e){const t=h.useRef(e);return Vs(()=>{t.current=e}),t}function gx(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]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=h.useState(r);oo(f,r)||m(r);const[p,g]=h.useState(null),[b,w]=h.useState(null),x=h.useCallback(P=>{P!==C.current&&(C.current=P,g(P))},[]),v=h.useCallback(P=>{P!==D.current&&(D.current=P,w(P))},[]),k=o||p,S=i||b,C=h.useRef(null),D=h.useRef(null),E=h.useRef(u),O=l!=null,T=ri(l),R=ri(s),A=ri(c),M=h.useCallback(()=>{if(!C.current||!D.current)return;const P={placement:t,strategy:n,middleware:f};R.current&&(P.platform=R.current),hx(C.current,D.current,P).then(F=>{const W={...F,isPositioned:A.current!==!1};I.current&&!oo(E.current,W)&&(E.current=W,pn.flushSync(()=>{d(W)}))})},[f,t,n,R,A]);Vs(()=>{c===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(P=>({...P,isPositioned:!1})))},[c]);const I=h.useRef(!1);Vs(()=>(I.current=!0,()=>{I.current=!1}),[]),Vs(()=>{if(k&&(C.current=k),S&&(D.current=S),k&&S){if(T.current)return T.current(k,S,M);M()}},[k,S,M,T,O]);const j=h.useMemo(()=>({reference:C,floating:D,setReference:x,setFloating:v}),[x,v]),V=h.useMemo(()=>({reference:k,floating:S}),[k,S]),U=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!V.floating)return P;const F=vc(V.floating,u.x),W=vc(V.floating,u.y);return a?{...P,transform:"translate("+F+"px, "+W+"px)",...gf(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:W}},[n,a,V.floating,u.x,u.y]);return h.useMemo(()=>({...u,update:M,refs:j,elements:V,floatingStyles:U}),[u,M,j,V,U])}const yx=(e,t)=>{const n=ax(e);return{name:n.name,fn:n.fn,options:[e,t]}},bx=(e,t)=>{const n=lx(e);return{name:n.name,fn:n.fn,options:[e,t]}},xx=(e,t)=>({fn:fx(e).fn,options:[e,t]}),vx=(e,t)=>{const n=cx(e);return{name:n.name,fn:n.fn,options:[e,t]}},wx=(e,t)=>{const n=ux(e);return{name:n.name,fn:n.fn,options:[e,t]}},kx=(e,t)=>{const n=dx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sx={intentional:"onClick",sloppy:"onPointerDown"};function Tx(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function yf(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:m=!1,referencePressEvent:p="sloppy",ancestorScroll:g=!1,bubbles:b,externalTree:w}=t,x=wr(w),v=he(typeof d=="function"?d:()=>!1),k=typeof d=="function"?v:d,S=h.useRef(!1),{escapeKey:C,outsidePress:D}=Tx(b),E=h.useRef(null),O=_n(),T=_n(),R=he(()=>{T.clear(),l.current.insideReactTree=!1}),A=h.useRef(!1),M=h.useRef(""),I=he(L=>{M.current=L.pointerType}),j=he(()=>{const L=M.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=jy(L)?L.nativeEvent:L,H=Le(bd,Me);n.setOpen(!1,H),!C&&!H.isPropagationAllowed&&L.stopPropagation()}),U=he(L=>{const ue=j();return ue==="intentional"&&L.type!=="click"||ue==="sloppy"&&L.type==="click"}),P=he(()=>{l.current.insideReactTree=!0,T.start(0,R)}),F=he((L,ue=!1)=>{if(U(L)){R();return}if(l.current.insideReactTree){R();return}if(j()==="intentional"&&ue||typeof k=="function"&&!k(L))return;const te=ft(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)&&!Ay(te)&&!we(te,n.select("floatingElement"))&&Array.from(H).every(ne=>!we(ie,ne)))return;if(rt(te)&&!("touches"in L)){const ne=In(te),Ve=At(te),be=/auto|scroll/,Be=ne||be.test(Ve.overflowX),$e=ne||be.test(Ve.overflowY),it=Be&&te.clientWidth>0&&te.scrollWidth>te.clientWidth,Oe=$e&&te.clientHeight>0&&te.scrollHeight>te.clientHeight,ye=Ve.direction==="rtl",je=Oe&&(ye?L.offsetX<=te.offsetWidth-te.clientWidth:L.offsetX>te.clientWidth),Ye=it&&L.offsetY>te.clientHeight;if(je||Ye)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(Ve=>{Ve.context?.open&&!Ve.context.dataRef.current.__outsidePressBubbles&&(ne=!1)}),!ne)return}n.setOpen(!1,Le(gd,L)),R()}),W=he(L=>{j()!=="sloppy"||L.pointerType==="touch"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||F(L)}),B=he(L=>{if(j()!=="sloppy"||!n.select("open")||!c||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement")))return;const ue=L.touches[0];ue&&(E.current={startTime:Date.now(),startX:ue.clientX,startY:ue.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}),Q=he(L=>{const ue=ft(L);function te(){B(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Y=he(L=>{const ue=S.current;if(S.current=!1,O.clear(),L.type==="mousedown"&&E.current&&!E.current.dismissOnMouseDown)return;const te=ft(L);function Me(){L.type==="pointerdown"?W(L):F(L,ue),te?.removeEventListener(L.type,Me)}te?.addEventListener(L.type,Me)}),$=he(L=>{if(j()!=="sloppy"||!E.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-E.current.startX),Me=Math.abs(ue.clientY-E.current.startY),H=Math.sqrt(te*te+Me*Me);H>5&&(E.current.dismissOnTouchEnd=!0),H>10&&(F(L),O.clear(),E.current=null)}),z=he(L=>{const ue=ft(L);function te(){$(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)}),Z=he(L=>{j()!=="sloppy"||!E.current||Ct(L,n.select("floatingElement"))||Ct(L,n.select("domReferenceElement"))||(E.current.dismissOnTouchEnd&&F(L),O.clear(),E.current=null)}),ce=he(L=>{const ue=ft(L);function te(){Z(L),ue?.removeEventListener(L.type,te)}ue?.addEventListener(L.type,te)});h.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=C,l.current.__outsidePressBubbles=D;const L=new gn;function ue(ie){n.setOpen(!1,Le(Ug,ie))}function te(){L.clear(),A.current=!0}function Me(){L.start(fa()?5:0,()=>{A.current=!1})}const H=qe(s);H.addEventListener("pointerdown",I,!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",I,!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,D,V,F,Y,W,Q,z,ce,I,n]),h.useEffect(R,[k,R]);const Se=h.useMemo(()=>({onKeyDown:V,...m&&{[Sx[p]]:L=>{n.setOpen(!1,Le(mn,L.nativeEvent))},...p!=="intentional"&&{onClick(L){n.setOpen(!1,Le(mn,L.nativeEvent))}}}}),[V,n,m,p]),Re=he(L=>{const ue=ft(L.nativeEvent);!we(n.select("floatingElement"),ue)||L.button!==0||(S.current=!0)}),Ee=he(L=>{!r||!c||L.button!==0||(S.current=!0)}),et=h.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 h.useMemo(()=>c?{reference:Se,floating:et,trigger:Se}:{},[c,Se,et])}const Cx={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 Ea extends ka{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:ef(),nested:n,noEmit:r,triggerElements:o},Cx)}setOpen=(t,n)=>{if((!t||!this.state.open||Ad(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 Ex(e,t=!1,n=!1){const[r,s]=h.useState(e&&t?"idle":void 0),[o,i]=h.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=_t.request(()=>{s("ending")});return()=>{_t.cancel(a)}}},[e,o,r,n]),Te(()=>{if(!e||t)return;const a=_t.request(()=>{s(void 0)});return()=>{_t.cancel(a)}},[t,e]),Te(()=>{if(!e||!t)return;e&&o&&r!=="idle"&&s("starting");const a=_t.request(()=>{s("idle")});return()=>{_t.cancel(a)}},[t,e,o,s,r]),h.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 Mx={[Gr.startingStyle]:""},Dx={[Gr.endingStyle]:""},xo={transitionStatus(e){return e==="starting"?Mx:e==="ending"?Dx:null}};function bf(e,t=!1,n=!0){const r=Sa();return he((s,o=null)=>{r.cancel();function i(){pn.flushSync(s)}const a=en(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 Ma(e){const{enabled:t=!0,open:n,ref:r,onComplete:s}=e,o=he(s),i=bf(r,n,!1);h.useEffect(()=>{if(!t)return;const a=new AbortController;return i(o,a.signal),()=>{a.abort()}},[t,n,o,i])}function Px(e,t){const n=h.useRef(null),r=h.useRef(null);return h.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 Rx(e,t,n,r){const s=n.useState("isMountedByTrigger",e),o=Px(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 xf(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 vf(e,t,n){const{mounted:r,setMounted:s,transitionStatus:o}=Ex(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 Ma({enabled:!a,open:e,ref:t.context.popupRef,onComplete(){e||i()}}),{forceUnmount:i,transitionStatus:o}}class vo{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 Ox(){return new Ea({open:!1,floatingElement:null,referenceElement:null,triggerElements:new vo,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function wf(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Ox(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:jn,inactiveTriggerProps:jn,popupProps:jn}}const kf={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 Ax(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=ts(),o=Hn()!=null,i=bn(()=>new Ea({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new vo,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 Nx(e={}){const{nodeId:t,externalTree:n}=e,r=Ax(e),s=e.rootContext||r,o={reference:s.useState("referenceElement"),floating:s.useState("floatingElement"),domReference:s.useState("domReferenceElement")},[i,a]=h.useState(null),l=h.useRef(null),c=wr(n);Te(()=>{o.domReference&&(l.current=o.domReference)},[o.domReference]);const u=gx({...e,elements:{...o,...i&&{reference:i}}}),d=h.useCallback(D=>{const E=Ae(D)?{getBoundingClientRect:()=>D.getBoundingClientRect(),getClientRects:()=>D.getClientRects(),contextElement:D}:D;a(E),u.refs.setReference(E)},[u.refs]),[f,m]=h.useState(null),[p,g]=h.useState(null);s.useSyncedValue("referenceElement",f),s.useSyncedValue("domReferenceElement",Ae(f)?f:null),s.useSyncedValue("floatingElement",p);const b=h.useCallback(D=>{(Ae(D)||D===null)&&(l.current=D,m(D)),(Ae(u.refs.reference.current)||u.refs.reference.current===null||D!==null&&!Ae(D))&&u.refs.setReference(D)},[u.refs,m]),w=h.useCallback(D=>{g(D),u.refs.setFloating(D)},[u.refs]),x=h.useMemo(()=>({...u.refs,setReference:b,setFloating:w,setPositionReference:d,domReference:l}),[u.refs,b,w,d]),v=h.useMemo(()=>({...u.elements,domReference:o.domReference}),[u.elements,o.domReference]),k=s.useState("open"),S=s.useState("floatingId"),C=h.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 D=c?.nodesRef.current.find(E=>E.id===t);D&&(D.context=C)}),h.useMemo(()=>({...u,context:C,refs:x,elements:v,rootStore:s}),[u,x,v,C,s])}function Sf(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:s}=e,o=ts(),i=Hn()!=null,a=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=bn(()=>new Ea({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 _i=Ur("safe-polygon"),jx=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Rd}`;function Ix(e){return e?!!e.closest(jx):!1}function Tf(e){const t=h.useRef(void 0),n=h.useRef(!1),r=h.useRef(void 0),s=h.useRef(!0),o=h.useRef(!1),i=h.useRef(()=>{}),a=h.useRef(!1),l=_n(),c=_n(),u=h.useRef(void 0);return h.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 Fx=new Set(["click","mousedown"]);function Lx(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:m,unbindMouseMoveRef:p,restTimeoutPendingRef:g,openChangeTimeout:b,handleCloseOptionsRef:w}=Tf(n),x=wr(c),v=Hn(),k=he(()=>d.current?!0:i.current.openEvent?Fx.has(i.current.openEvent.type):!1),S=he(()=>{const T=i.current.openEvent?.type;return T?.includes("mouse")&&T!=="mousedown"}),C=h.useCallback((T,R=!0)=>{const A=Vx(l,u.current);A&&!f.current?b.start(A,()=>n.setOpen(!1,Le(dt,T))):R&&(b.clear(),n.setOpen(!1,Le(dt,T)))},[l,f,n,u,b]),D=he(()=>{p.current(),f.current=void 0}),E=he(()=>{if(m.current){const T=qe(s).body;T.style.pointerEvents="",T.removeAttribute(_i),m.current=!1}}),O=he(T=>{const R=ft(T);if(!Ix(R)){d.current=!1;return}d.current=!0});Te(()=>{r||(u.current=void 0,g.current=!1,d.current=!1,D(),E())},[r,u,g,d,D,E]),h.useEffect(()=>()=>{D()},[D]),h.useEffect(()=>E,[E]),Te(()=>{if(a&&r&&w.current?.blockPointerEvents&&S()&&Ae(o)&&s){m.current=!0;const T=qe(s).body;T.setAttribute(_i,"");const R=o,A=s,M=x?.nodesRef.current.find(I=>I.id===v)?.context?.elements.floating;return M&&(M.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,m]),h.useEffect(()=>{if(!a)return;function T(I){if(k()||!i.current.floatingContext||!n.select("open"))return;const j=n.context.triggerElements;I.relatedTarget&&j.hasElement(I.relatedTarget)||(E(),D(),k()||C(I))}function R(I){b.clear(),E(),f.current?.(I),D()}function A(I){k()||C(I,!1)}const M=s;return M&&(M.addEventListener("mouseleave",T),M.addEventListener("mouseenter",R),M.addEventListener("mouseleave",A),M.addEventListener("pointerdown",O,!0)),()=>{M&&(M.removeEventListener("mouseleave",T),M.removeEventListener("mouseenter",R),M.removeEventListener("mouseleave",A),M.removeEventListener("pointerdown",O,!0))}})}function Vx(e,t){return t&&!dr(t)?0:typeof e=="function"?e():e}function si(e){return typeof e=="function"?e():e}const _x={current:null};function Wx(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=_x,externalTree:f,isActiveTrigger:m=!0}=t,p=wr(f),{pointerTypeRef:g,interactedInsideRef:b,handlerRef:w,blockMouseMoveRef:x,performedPointerEventsMutationRef:v,unbindMouseMoveRef:k,restTimeoutPendingRef:S,openChangeTimeout:C,restTimeout:D,handleCloseOptionsRef:E}=Tf(n),O=$t(a),T=$t(i),R=$t(c);m&&(E.current=O.current?.__options);const A=he(()=>b.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),M=h.useCallback((U,P=!0)=>{const F=Qo(T.current,"close",g.current);F&&!w.current?C.start(F,()=>n.setOpen(!1,Le(dt,U))):P&&(C.clear(),n.setOpen(!1,Le(dt,U)))},[T,w,n,g,C]),I=he(()=>{k.current(),w.current=void 0}),j=he(()=>{if(v.current){const U=qe(n.select("domReferenceElement")).body;U.style.pointerEvents="",U.removeAttribute(_i),v.current=!1}});h.useEffect(()=>{if(!o)return;function U(P){P.open||(C.clear(),D.clear(),x.current=!0,S.current=!1)}return s.on("openchange",U),()=>{s.off("openchange",U)}},[o,s,C,D,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 F=d.current;O.current?.({...r.current.floatingContext,tree:p,x:U.clientX,y:U.clientY,onClose(){j(),I(),!A()&&F===n.select("domReferenceElement")&&M(U)}})(U)});return h.useEffect(()=>{if(!o)return;const U=d.current??(m?n.select("domReferenceElement"):null);if(!Ae(U))return;function P(B){if(C.clear(),x.current=!1,l&&!dr(g.current)||si(R.current)>0&&!Qo(T.current,"open"))return;const Q=Qo(T.current,"open",g.current),Y=n.select("domReferenceElement"),$=n.context.triggerElements,z=($.hasElement(B.target)||$.hasMatchingElement(Re=>we(Re,B.target)))&&(!Y||!we(Y,B.target)),Z=B.currentTarget??null,ce=n.select("open"),Se=!ce||z;z&&ce?n.setOpen(!0,Le(dt,B,Z)):Q?C.start(Q,()=>{Se&&n.setOpen(!0,Le(dt,B,Z))}):Se&&n.setOpen(!0,Le(dt,B,Z))}function F(B){if(A()){j();return}k.current();const Q=n.select("domReferenceElement"),Y=qe(Q);D.clear(),S.current=!1;const $=n.context.triggerElements;if(B.relatedTarget&&$.hasElement(B.relatedTarget))return;if(O.current&&r.current.floatingContext){n.select("open")||C.clear();const Z=d.current;w.current=O.current({...r.current.floatingContext,tree:p,x:B.clientX,y:B.clientY,onClose(){j(),I(),!A()&&Z===n.select("domReferenceElement")&&M(B,!0)}});const ce=w.current;ce(B),Y.addEventListener("mousemove",ce),k.current=()=>{Y.removeEventListener("mousemove",ce)};return}(g.current!=="touch"||!we(n.select("floatingElement"),B.relatedTarget))&&M(B)}function W(B){V(B)}return n.select("open")&&U.addEventListener("mouseleave",W),u&&U.addEventListener("mousemove",P,{once:!0}),U.addEventListener("mouseenter",P),U.addEventListener("mouseleave",F),()=>{U.removeEventListener("mouseleave",W),u&&U.removeEventListener("mousemove",P),U.removeEventListener("mouseenter",P),U.removeEventListener("mouseleave",F)}},[I,j,x,r,T,M,n,o,O,V,m,A,l,u,g,R,D,S,C,d,p,k,w]),h.useMemo(()=>{function U(P){g.current=P.pointerType}return{onPointerDown:U,onPointerEnter:U,onMouseMove(P){const{nativeEvent:F}=P,W=P.currentTarget,B=n.select("domReferenceElement"),Q=n.context.triggerElements,Y=n.select("open"),$=(Q.hasElement(P.target)||Q.hasMatchingElement(Z=>we(Z,P.target)))&&(!B||!we(B,P.target));if(l&&!dr(g.current)||Y&&!$||si(R.current)===0||!$&&S.current&&P.movementX**2+P.movementY**2<2)return;D.clear();function z(){if(S.current=!1,A())return;const Z=n.select("open");!x.current&&(!Z||$)&&n.setOpen(!0,Le(dt,F,W))}g.current==="touch"?pn.flushSync(()=>{z()}):$&&Y?z():(S.current=!0,D.start(si(R.current),z))}}},[x,A,l,n,g,R,D,S])}function Da(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=h.useCallback(c=>Os(c,e,"reference"),t),i=h.useCallback(c=>Os(c,e,"floating"),n),a=h.useCallback(c=>Os(c,e,"item"),r),l=h.useCallback(c=>Os(c,e,"trigger"),s);return h.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:a,getTriggerProps:l}),[o,i,a,l])}function Os(e,t,n){const r=new Map,s=n==="item",o={};n==="floating"&&(o.tabIndex=-1,o[Ni]="");for(const i in e)s&&e&&(i===Dd||i===Pd)||(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&&wc(o,a,s,r)}return wc(o,e,s,r),o}function wc(e,t,n,r){for(const s in t){const o=t[s];n&&(s===Dd||s===Pd)||(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 Bx=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Cf(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=h.useMemo(()=>ji(i)?.id||s,[i,s]),f=Bx.get(l)??l,p=Hn()!=null,g=h.useMemo(()=>f==="tooltip"||l==="label"?jn:{"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]),b=h.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=h.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=h.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 h.useMemo(()=>a?{reference:b,floating:w,item:x,trigger:g}:{},[a,b,w,g,x])}function kc(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 $x(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Yx(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 m=performance.now(),p=m-l;if(i===null||a===null||p===0)return i=d,a=f,l=m,null;const g=d-i,b=f-a,x=Math.sqrt(g*g+b*b)/p;return i=d,a=f,l=m,x}const u=({x:d,y:f,placement:m,elements:p,onClose:g,nodeId:b,tree:w})=>function(v){function k(){s.clear(),g()}if(s.clear(),!p.domReference||!p.floating||m==null||d==null||f==null)return;const{clientX:S,clientY:C}=v,D=[S,C],E=ft(v),O=v.type==="mouseleave",T=we(p.floating,E),R=we(p.domReference,E),A=p.domReference.getBoundingClientRect(),M=p.floating.getBoundingClientRect(),I=m.split("-")[0],j=d>M.right-M.width/2,V=f>M.bottom-M.height/2,U=$x(D,A),P=M.width>A.width,F=M.height>A.height,W=(P?A:M).left,B=(P?A:M).right,Q=(F?A:M).top,Y=(F?A:M).bottom;if(T&&(o=!0,!O))return;if(R&&(o=!1),R&&!O){o=!0;return}if(O&&Ae(v.relatedTarget)&&we(p.floating,v.relatedTarget)||w&&Fn(w.nodesRef.current,b).some(({context:Z})=>Z?.open))return;if(I==="top"&&f>=A.bottom-1||I==="bottom"&&f<=A.top+1||I==="left"&&d>=A.right-1||I==="right"&&d<=A.left+1)return k();let $=[];switch(I){case"top":$=[[W,A.top+1],[W,M.bottom-1],[B,M.bottom-1],[B,A.top+1]];break;case"bottom":$=[[W,M.top+1],[W,A.bottom-1],[B,A.bottom-1],[B,M.top+1]];break;case"left":$=[[M.right-1,Y],[M.right-1,Q],[A.left+1,Q],[A.left+1,Y]];break;case"right":$=[[A.right-1,Y],[A.right-1,Q],[M.left+1,Q],[M.left+1,Y]];break}function z([Z,ce]){switch(I){case"top":{const Se=[P?Z+t/2:j?Z+t*4:Z-t*4,ce+t+1],Re=[P?Z-t/2:j?Z+t*4:Z-t*4,ce+t+1],Ee=[[M.left,j||P?M.bottom-t:M.top],[M.right,j?P?M.bottom-t:M.top:M.bottom-t]];return[Se,Re,...Ee]}case"bottom":{const Se=[P?Z+t/2:j?Z+t*4:Z-t*4,ce-t],Re=[P?Z-t/2:j?Z+t*4:Z-t*4,ce-t],Ee=[[M.left,j||P?M.top+t:M.bottom],[M.right,j?P?M.top+t:M.bottom:M.top+t]];return[Se,Re,...Ee]}case"left":{const Se=[Z+t+1,F?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z+t+1,F?ce-t/2:V?ce+t*4:ce-t*4];return[...[[V||F?M.right-t:M.left,M.top],[V?F?M.right-t:M.left:M.right-t,M.bottom]],Se,Re]}case"right":{const Se=[Z-t,F?ce+t/2:V?ce+t*4:ce-t*4],Re=[Z-t,F?ce-t/2:V?ce+t*4:ce-t*4],Ee=[[V||F?M.left+t:M.right,M.top],[V?F?M.left+t:M.right:M.left+t,M.bottom]];return[Se,Re,...Ee]}default:return[]}}if(!kc([S,C],$)){if(o&&!U)return k();if(!O&&r){const Z=c(v.clientX,v.clientY);if(Z!==null&&Z<.1)return k()}kc([S,C],z([d,f]))?!o&&r&&s.start(40,k):k()}};return u.__options={blockPointerEvents:n},u}function Hx(e){const t=h.useRef(""),n=h.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:h.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 Ef(e){const[t,n]=h.useState(null),r=he((a,l)=>{e||n(l||(Md?"touch":""))}),s=h.useCallback(()=>{n(null)},[]),{onClick:o,onPointerDown:i}=Hx(r);return h.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})({}),Wi=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Ux={[Wi.popupOpen]:""},Gx={[Wi.popupOpen]:"",[Wi.pressed]:""},Kx={[Pt.open]:""},zx={[Pt.closed]:""},qx={[Pt.anchorHidden]:""},Xx={open(e){return e?Ux:null}},Zx={open(e){return e?Gx:null}},os={open(e){return e?Kx:zx},anchorHidden(e){return e?qx:null}};function Mf(e){return md(19)?e:e?"true":void 0}let Sc={},Tc={},Cc="";function Qx(e){if(typeof document>"u")return!1;const t=Yn(e);return vt(t).innerWidth-t.documentElement.clientWidth>0}function Jx(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=Yn(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 ev(e){const t=Yn(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 tv(e){const t=Yn(e),n=t.documentElement,r=t.body,s=vt(n);let o=0,i=0,a=!1;const l=_t.create();if(Ey&&(s.visualViewport?.scale??1)!==1)return()=>{};function c(){const f=s.getComputedStyle(n),m=s.getComputedStyle(r),b=(f.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,Sc={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Cc=n.style.scrollBehavior,Tc={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"||m.overflowY==="scroll",k=f.overflowX==="scroll"||m.overflowX==="scroll",S=Math.max(0,s.innerWidth-r.clientWidth),C=Math.max(0,s.innerHeight-r.clientHeight),D=parseFloat(m.marginTop)+parseFloat(m.marginBottom),E=parseFloat(m.marginLeft)+parseFloat(m.marginRight),O=rs(n)?n:r;if(a=Jx(e),a){n.style.scrollbarGutter=b,O.style.overflowY="hidden",O.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(w||v)&&(n.style.overflowY="scroll"),(x||k)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:D||C?`calc(100dvh - ${D+C}px)`:"100dvh",width:E||S?`calc(100vw - ${E+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,Sc),Object.assign(r.style,Tc),a||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Cc)}function d(){u(),l.request(c)}return c(),s.addEventListener("resize",d),()=>{l.cancel(),u(),typeof s.removeEventListener=="function"&&s.removeEventListener("resize",d)}}class nv{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=Yn(t).documentElement,s=vt(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=pd;return}const o=Md||!Qx(t);this.restore=o?ev(t):tv(t)}}const rv=new nv;function Df(e=!0,t=null){Te(()=>{if(e)return rv.acquire(t)},[e,t])}const sv=h.createContext(void 0);function ov(){return h.useContext(sv)?.direction??"ltr"}const iv=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"}=rn(e,t)||{};if(c==null)return{};const f=Nd(u),m={x:n,y:r},p=xa(s),g=ba(p),b=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]-m[p]-o.floating[g],C=m[p]-o.reference[p],D=d==="real"?await i.getOffsetParent?.(c):a.floating;let E=a.floating[k]||o.floating[g];(!E||!await i.isElement?.(D))&&(E=a.floating[k]||o.floating[g]);const O=S/2-C/2,T=E/2-b[g]/2-1,R=Math.min(f[x],T),A=Math.min(f[v],T),M=R,I=E-b[g]-A,j=E/2-b[g]/2+O,V=Ii(M,j,I),U=!l.arrow&&xn(s)!=null&&j!==V&&o.reference[g]/2-(j<M?R:A)-b[g]/2<0,P=U?j<M?j-M:j-I:0;return{[p]:m[p]+P,data:{[p]:V,centerOffset:j-V-P,...U&&{alignmentOffset:P}},reset:U}}}),av=(e,t)=>({...iv(e),options:[e,t]}),lv={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 kx().fn(e)).data?.referenceHidden||o}}}},_s={sideX:"left",sideY:"top"},cv={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:_s};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=Yn(s);f={width:x.documentElement.clientWidth,height:x.documentElement.clientHeight}}else await o.isElement?.(d)&&(f=await o.getDimensions(d));const m=at(a);let p=t,g=n;m==="left"&&(p=f.width-(t+r.width)),m==="top"&&(g=f.height-(n+r.height));const b=m==="left"?"right":_s.sideX,w=m==="top"?"bottom":_s.sideY;return{x:p,y:g,data:{sideX:b,sideY:w}}}};function Pf(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 Ec(e,t,n){const{rects:r,placement:s}=e;return{side:Pf(t,at(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 uv(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:m,mounted:p,collisionAvoidance:g,shiftCrossAxis:b=!1,nodeId:w,adaptiveOrigin:x,lazyFlip:v=!1,externalTree:k}=e,[S,C]=h.useState(null);!p&&S!==null&&C(null);const D=g.side||"flip",E=g.align||"flip",O=g.fallbackAxisSide||"end",T=typeof t=="function"?t:void 0,R=he(T),A=T?R:t,M=$t(t),j=ov()==="rtl",V=S||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":j?"left":"right","inline-start":j?"right":"left"}[r],U=o==="center"?V:`${V}-${o}`;let P=l;const F=1,W=r==="bottom"?F:0,B=r==="top"?F:0,Q=r==="right"?F:0,Y=r==="left"?F:0;typeof P=="number"?P={top:P+W,right:P+Y,bottom:P+B,left:P+Q}:P&&(P={top:(P.top||0)+W,right:(P.right||0)+Y,bottom:(P.bottom||0)+B,left:(P.left||0)+Q});const $={boundary:a==="clipping-ancestors"?"clippingAncestors":a,padding:P},z=h.useRef(null),Z=$t(s),ce=$t(i),Ee=[yx(De=>{const He=Ec(De,r,j),re=typeof Z.current=="function"?Z.current(He):Z.current,G=typeof ce.current=="function"?ce.current(He):ce.current;return{mainAxis:re,crossAxis:G,alignmentAxis:G}},[typeof s!="function"?s:0,typeof i!="function"?i:0,j,r])],et=E==="none"&&D!=="shift",L=!et&&(c||b||D==="shift"),ue=D==="none"?null:vx({...$,padding:{top:P.top+F,right:P.right+F,bottom:P.bottom+F,left:P.left+F},mainAxis:!b&&D==="flip",crossAxis:E==="flip"?"alignment":!1,fallbackAxisSideDirection:O}),te=et?null:bx(De=>{const He=Yn(De.elements.floating).documentElement;return{...$,rootBoundary:b?{x:0,y:0,width:He.clientWidth,height:He.clientHeight}:void 0,mainAxis:E!=="none",crossAxis:L,limiter:c||b?void 0:xx(re=>{if(!z.current)return{};const{width:G,height:oe}=z.current.getBoundingClientRect(),de=yt(at(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,b,P,E]);D==="shift"||E==="shift"||o==="center"?Ee.push(te,ue):Ee.push(ue,te),Ee.push(wx({...$,apply({elements:{floating:De},rects:{reference:He},availableWidth:re,availableHeight:G}){Object.entries({"--available-width":`${re}px`,"--available-height":`${G}px`,"--anchor-width":`${He.width}px`,"--anchor-height":`${He.height}px`}).forEach(([oe,de])=>{De.style.setProperty(oe,de)})}}),av(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(De){const{elements:He,middlewareData:re,placement:G,rects:oe,y:de}=De,xe=at(G),fe=yt(xe),jt=z.current,wn=re.arrow?.x||0,kn=re.arrow?.y||0,qt=jt?.clientWidth||0,cn=jt?.clientHeight||0,It=wn+qt/2,Er=kn+cn/2,Ft=Math.abs(re.shift?.y||0),nt=oe.reference.height/2,Sn=typeof s=="function"?s(Ec(De,r,j)):s,ys=Ft>Sn,Po={top:`${It}px calc(100% + ${Sn}px)`,bottom:`${It}px ${-Sn}px`,left:`calc(100% + ${Sn}px) ${Er}px`,right:`${-Sn}px ${Er}px`}[xe],ct=`${It}px ${oe.reference.y+nt-de}px`;return He.floating.style.setProperty("--transform-origin",L&&fe==="y"&&ys?ct:Po),{}}},lv,x),Te(()=>{!p&&m&&m.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[p,m]);const Me=h.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:Ve,isPositioned:be,floatingStyles:Be}=Nx({rootContext:m,placement:U,middleware:Ee,strategy:n,whileElementsMounted:f?void 0:(...De)=>xc(...De,Me),nodeId:w,externalTree:k}),{sideX:$e,sideY:it}=ge.adaptiveOrigin||_s,Oe=be?n:"fixed",ye=h.useMemo(()=>x?{position:Oe,[$e]:ie,[it]:me}:{position:Oe,...Be},[x,Oe,$e,ie,it,me,Be]),je=h.useRef(null);Te(()=>{if(!p)return;const De=M.current,He=typeof De=="function"?De():De,G=(Mc(He)?He.current:He)||null||null;G!==je.current&&(H.setPositionReference(G),je.current=G)},[p,H,A,M]),h.useEffect(()=>{if(!p)return;const De=M.current;typeof De!="function"&&Mc(De)&&De.current!==je.current&&(H.setPositionReference(De.current),je.current=De.current)},[p,H,A,M]),h.useEffect(()=>{if(f&&p&&se.domReference&&se.floating)return xc(se.domReference,se.floating,J,Me)},[f,p,se,J,Me]);const Ye=at(ne),Nt=Pf(r,Ye,j),kt=xn(ne)||"center",tt=!!ge.hide?.referenceHidden;Te(()=>{v&&p&&be&&C(Ye)},[v,p,be,Ye]);const ln=h.useMemo(()=>({position:"absolute",top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),lt=ge.arrow?.centerOffset!==0;return h.useMemo(()=>({positionerStyles:ye,arrowStyles:ln,arrowRef:z,arrowUncentered:lt,side:Nt,align:kt,physicalSide:Ye,anchorHidden:tt,refs:H,context:Ve,isPositioned:be,update:J}),[ye,ln,z,lt,Nt,kt,Ye,tt,H,Ve,be,J])}function Mc(e){return e!=null&&"current"in e}const Rf=h.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%,
|