tokentracker-cli 0.5.45 → 0.5.46
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/{Card-CVdRLQXL.js → Card-CDFJQidU.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-B81lr9NT.js → DashboardPage-D1EzBOEu.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-DGKuFrwh.js → FadeIn-Dt-Uvlsi.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-fIC8UBdE.js → LeaderboardPage-J30TJsOU.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-D85BszWk.js → LeaderboardProfilePage-BK44ZoMl.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-BTq4-dNq.js → LimitsPage-C6ExO6Rp.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-il3gO5ET.js → SettingsPage-z4P35tTJ.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-DieOEfKf.js → WidgetsPage-DGHOfwdN.js} +1 -1
- package/dashboard/dist/assets/{download-KyrJclzH.js → download-DsypqQx5.js} +1 -1
- package/dashboard/dist/assets/{leaderboard-columns-Chfc5tar.js → leaderboard-columns-VBGLNKay.js} +1 -1
- package/dashboard/dist/assets/{main-BPrBAU5E.js → main-DQ3-Wn2t.js} +2 -2
- package/dashboard/dist/assets/{use-limits-display-prefs-D5GxufF1.js → use-limits-display-prefs-B1qdCsIA.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-D3wh10do.js → use-usage-limits-DiPkCZg-.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as Tu,f as ni,a as ri,J as Ou,u as oi,m as Nu,r as f,M as si,b as Ru,c as Du,d as no,e as Pu,g as Au,h as Rn,j as Dn,k as tn,l as _u,n as _o,o as pr,p as Vo,q as Lr,s as Iu,t as ju,v as Fu,w as qo,x as Sn,y as ro,z as Wu,A as et,B as L,C as ai,D as p,E as Ut,F as Ee,G as on,H as ii,I as ci,K as me,N as li,L as Lu,O as Ge,R as $u,P as $t,Q as tr,S as Yt,T as Bu,U as Dt,V as Bs,W as st,X as ft,Y as xn,Z as Re,_ as Pt,$ as Ys,a0 as Go,a1 as zo,a2 as Cn,a3 as Zt,a4 as Yu,a5 as ui,a6 as Hu,a7 as nr,a8 as $r,a9 as di,aa as Ko,ab as bt,ac as fi,ad as G,ae as Xo,af as mi,ag as Uu,ah as Vu,ai as qu,aj as hi,ak as Gu,al as zu,am as Ku,an as Xu,ao as Ju,ap as Qu,aq as Zu,ar as ed,as as td,at as nd,au as Mt,av as rd,aw as od,ax as Hs}from"./main-BPrBAU5E.js";import{u as sd}from"./use-usage-limits-D3wh10do.js";import{C as Jo}from"./Card-CVdRLQXL.js";import{F as Gn}from"./FadeIn-DGKuFrwh.js";const ad=500,id={style:{transition:"none"}},gi="data-base-ui-click-trigger",cd={fallbackAxisSide:"end"},ld={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function ud(...e){const t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],o=e[1+n],s=e[2+n],a=e[3+n],i=Tu(o,s,a);return t?i(r):i}function dd(e,t,n={}){const r=e.get();let o=null,s=r,a;const i=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,c=()=>{o&&(o.stop(),o=null),e.animation=void 0},l=()=>{const d=Us(e.get()),m=Us(s);if(d===m){c();return}const h=o?o.getGeneratorVelocity():e.getVelocity();c(),o=new Ou({keyframes:[d,m],velocity:h,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:a})},u=()=>{l(),e.animation=o??void 0,e.events.animationStart?.notify(),o?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((d,m)=>{s=d,a=h=>m(oo(h,i)),ni.postRender(u)},c),ri(t)){let d=n.skipInitialAnimation===!0;const m=t.on("change",g=>{d?(d=!1,e.jump(oo(g,i),!1)):e.set(oo(g,i))}),h=e.on("destroy",m);return()=>{m(),h()}}return c}function oo(e,t){return t?e+t:e}function Us(e){return typeof e=="number"?e:parseFloat(e)}function Qo(e){const t=oi(()=>Nu(e)),{isStatic:n}=f.useContext(si);if(n){const[,r]=f.useState(e);f.useEffect(()=>t.on("change",r),[])}return t}function pi(e,t){const n=Qo(t()),r=()=>n.set(t());return r(),Ru(()=>{const o=()=>ni.preRender(r,!1,!0),s=e.map(a=>a.on("change",o));return()=>{s.forEach(a=>a()),Du(r)}}),n}function fd(e){no.current=[],e();const t=pi(no.current,e);return no.current=void 0,t}function yi(e,t,n,r){if(typeof e=="function")return fd(e);const s=typeof t=="function"?t:ud(t,n,r),a=Array.isArray(e)?Vs(e,s):Vs([e],([c])=>s(c)),i=Array.isArray(e)?void 0:e.accelerate;return i&&!i.isTransformed&&typeof t!="function"&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...i,times:t,keyframes:n,isTransformed:!0}),a}function Vs(e,t){const n=oi(()=>[]);return pi(e,()=>{n.length=0;const r=e.length;for(let o=0;o<r;o++)n[o]=e[o].get();return t(n)})}function md(e,t={}){const{isStatic:n}=f.useContext(si),r=()=>ri(e)?e.get():e;if(n)return yi(r);const o=Qo(r());return f.useInsertionEffect(()=>dd(o,e,t),[o,JSON.stringify(t)]),o}function hd(e,t={}){return md(e,{type:"spring",...t})}const gd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],pd=Pu("info",gd);function yd({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:o="sun",cacheKey:s,timeZone:a,tzOffsetMinutes:i,now:c}={}){const l=f.useMemo(()=>Au({weeks:r,weekStartsOn:o,now:c}),[c,r,o]),[u,d]=f.useState([]),[m,h]=f.useState(null),[g,y]=f.useState("edge"),[x,v]=f.useState(!1),[b,w]=f.useState(null),S=Rn(),C=Dn(t),k=!n,T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=f.useMemo(()=>{if(!s)return null;const F=Lr({timeZone:a,offsetMinutes:i});return`tokentracker.heatmap.${s}.${r}.${o}.${F}`},[s,a,i,r,o]),j=f.useCallback(()=>{if(!N||typeof window>"u")return null;try{const F=window.localStorage.getItem(N);if(!F)return null;const P=JSON.parse(F);return!P||!P.heatmap?null:P}catch{return null}},[N]),M=f.useCallback(F=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(F))}catch{}},[N]),R=f.useCallback(()=>{if(!(!N||typeof window>"u"))try{window.localStorage.removeItem(N)}catch{}},[N]),_=f.useCallback(async()=>{const F=await tn(t);if(!(!F&&!S&&!T)){v(!0),w(null);try{try{const O=await _u({baseUrl:e,accessToken:F,weeks:r,to:l.to,weekStartsOn:o,timeZone:a,tzOffsetMinutes:i}),A=Array.isArray(O?.weeks)?O.weeks:[];if(!A.length&&k){const Y=j();if(Y?.heatmap){h(Y.heatmap),d(Y.daily||[]),y("cache");return}}if(!A.some(Y=>(Array.isArray(Y)?Y:[]).some(Z=>Z&&Number.isFinite(Number(Z.level))))&&A.length){const Y=[];for(const H of A)for(const W of Array.isArray(H)?H:[])W?.day&&Y.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});const Z=_o({dailyRows:Y,weeks:r,to:O?.to||l.to,weekStartsOn:o});d(Y),h({...Z,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:pr({dailyRows:Y,to:O?.to||l.to})}),y("client"),k?M({heatmap:{...Z,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:pr({dailyRows:Y,to:O?.to||l.to})},daily:Y,fetchedAt:new Date().toISOString()}):R();return}h(O||null),d([]),y("edge"),O&&k?M({heatmap:O,daily:[],fetchedAt:new Date().toISOString()}):k||R();return}catch(O){const A=O,U=A?.status??A?.statusCode;if(U===401||U===403)throw O}const P=await Vo({baseUrl:e,accessToken:F,from:l.from,to:l.to,timeZone:a,tzOffsetMinutes:i}),B=Array.isArray(P?.data)?P.data:[];d(B);const V=_o({dailyRows:B,weeks:r,to:l.to,weekStartsOn:o});h({...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:pr({dailyRows:B,to:l.to})}),y("client"),k?M({heatmap:{...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:pr({dailyRows:B,to:l.to})},daily:B,fetchedAt:new Date().toISOString()}):R()}catch(P){if(k){const B=j();if(B?.heatmap)h(B.heatmap),d(B.daily||[]),y("cache"),w(null);else{const V=P;w(V?.message||String(V)),d([]),h(null),y("edge")}}else{const B=P;w(B?.message||String(B)),d([]),h(null),y("edge")}}finally{v(!1)}}},[t,e,S,n,k,l.from,l.to,j,C,a,i,o,r,R,M,T]);return f.useEffect(()=>{if(!C&&!n&&!S&&!T){d([]),v(!1),w(null),h(null),y("edge");return}if(!k)R(),d([]),w(null),h(null),y("edge");else{const F=j();F?.heatmap&&(h(F.heatmap),d(F.daily||[]),y("cache"))}_()},[t,S,j,_,C,n,k,R,T]),{range:l,daily:u,heatmap:m,source:S?"mock":g==="client"?"edge":g,loading:x,error:b,refresh:_}}function bd({baseUrl:e,accessToken:t,limit:n=3,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i}={}){const[c,l]=f.useState([]),[u,d]=f.useState(!1),[m,h]=f.useState(null),g=Rn(),y=Dn(t),x=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=f.useCallback(async()=>{const b=await tn(t);if(!b&&!g&&!x){l([]),h(null),d(!1);return}d(!0),h(null);try{const w=await Iu({baseUrl:e,accessToken:b,limit:n,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i});l(Array.isArray(w?.entries)?w.entries:[])}catch(w){const S=w?.message||String(w);h(S),l([])}finally{d(!1)}},[t,e,r,n,g,s,a,o,i,x]);return f.useEffect(()=>{if(!y&&!g&&!x){l([]),h(null),d(!1);return}v()},[g,v,y,x]),{entries:c,loading:u,error:m,refresh:v}}const xd=24;function wd({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:o,to:s,months:a=xd,cacheKey:i,timeZone:c,tzOffsetMinutes:l,now:u,sharedRows:d,sharedRange:m}={}){const[h,g]=f.useState([]),[y,x]=f.useState(()=>({from:o,to:s})),[v,b]=f.useState("edge"),[w,S]=f.useState(null),[C,k]=f.useState(!1),[T,N]=f.useState(null),j=Rn(),M=Dn(t),R=!n,_=Array.isArray(d),E=m?.from||o,F=m?.to||s,P=f.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),B=(()=>{if(!i)return null;const H=vd(e)||"default",W=Lr({timeZone:c,offsetMinutes:l});if(P==="hourly")return`tokentracker.trend.${i}.${H}.hourly.${s||o||"day"}.${W}`;if(P==="monthly")return`tokentracker.trend.${i}.${H}.monthly.${a}.${s||"today"}.${W}`;const z=`${o||""}.${s||""}`;return`tokentracker.trend.${i}.${H}.daily.${z}.${W}`})(),V=f.useCallback(()=>{if(!B||typeof window>"u")return null;try{const H=window.localStorage.getItem(B);if(!H)return null;const W=JSON.parse(H);return!W||!Array.isArray(W.rows)?null:W}catch{return null}},[B]),O=f.useCallback(H=>{if(!(!B||typeof window>"u"))try{window.localStorage.setItem(B,JSON.stringify(H))}catch{}},[B]),A=f.useCallback(()=>{if(!(!B||typeof window>"u"))try{window.localStorage.removeItem(B)}catch{}},[B]),U=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Y=f.useCallback(async()=>{if(_){g(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}const H=await tn(t);if(!(!H&&!j&&!U)){k(!0),N(null);try{let W;P==="hourly"?W=await ju({baseUrl:e,accessToken:H,day:s||o,timeZone:c,tzOffsetMinutes:l}):P==="monthly"?W=await Fu({baseUrl:e,accessToken:H,months:a,to:s,timeZone:c,tzOffsetMinutes:l}):W=await Vo({baseUrl:e,accessToken:H,from:o,to:s,timeZone:c,tzOffsetMinutes:l});const z=W?.from||o||W?.day||null,X=W?.to||s||W?.day||null;let oe=Array.isArray(W?.data)?W.data:[];P==="daily"?oe=ao(oe,z||o,X||s,{timeZone:c,offsetMinutes:l,now:u}):P==="hourly"?oe=io(oe,{timeZone:c,offsetMinutes:l,now:u}):P==="monthly"&&(oe=co(oe,{timeZone:c,offsetMinutes:l,now:u}));const be=new Date().toISOString();g(oe),x({from:z,to:X}),b("edge"),S(be),R?O({rows:oe,from:z,to:X,mode:P,fetchedAt:be}):A()}catch(W){if(R){const z=V();if(z?.rows){let X=P==="daily"?ao(z.rows||[],z.from||o,z.to||s,{timeZone:c,offsetMinutes:l,now:u}):Array.isArray(z.rows)?z.rows:[];P==="hourly"?X=io(X,{timeZone:c,offsetMinutes:l,now:u}):P==="monthly"&&(X=co(X,{timeZone:c,offsetMinutes:l,now:u})),g(X),x({from:z.from||o,to:z.to||s}),b("cache"),S(z.fetchedAt||null),N(null)}else{g([]),x({from:o,to:s}),b("edge"),S(null);const X=W;N(X?.message||String(X))}}else{g([]),x({from:o,to:s}),b("edge"),S(null);const z=W;N(z?.message||String(z))}}finally{k(!1)}}},[t,e,o,j,n,R,P,a,V,M,_,E,d,F,c,s,l,u,A,O,U]);f.useEffect(()=>{if(_){g(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}if(!M&&!n&&!j&&!U){g([]),x({from:o,to:s}),N(null),k(!1),b("edge"),S(null);return}if(!R)A(),g([]),x({from:o,to:s}),N(null),b("edge"),S(null);else{const H=V();if(H?.rows){let W=P==="daily"?ao(H.rows||[],H.from||o,H.to||s,{timeZone:c,offsetMinutes:l,now:u}):Array.isArray(H.rows)?H.rows:[];P==="hourly"?W=io(W,{timeZone:c,offsetMinutes:l,now:u}):P==="monthly"&&(W=co(W,{timeZone:c,offsetMinutes:l,now:u})),g(W),x({from:H.from||o,to:H.to||s}),b("cache"),S(H.fetchedAt||null)}}Y()},[t,j,V,Y,_,E,d,F,M,n,R,A,U]);const Z=j?"mock":v;return{rows:h,from:y.from||o,to:y.to||s,source:Z,fetchedAt:w,loading:C,error:T,refresh:Y}}function vd(e){try{return new URL(e).host}catch{return null}}function so(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&Sn(a)===t?a:null}function kd(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function ao(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=so(t),i=so(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,l=qo({timeZone:r,offsetMinutes:o,date:c}),u=so(l),d=u?u.getTime():c.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const h=[];for(let g=a;g<=i;g=kd(g,1)){const y=Sn(g),x=m.get(y),v=g.getTime()>d;if(x){h.push({...x,missing:!1,future:v});continue}h.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return h}function io(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=bi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.hour||s?.label||"",i=Sd(a);if(!i)return{...s,future:!1};const c=i.dayNum>o.dayNum||i.dayNum===o.dayNum&&i.slot>o.slot;return{...s,future:c}}):e}function co(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=bi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.month||s?.label||"",i=Cd(a);if(!i)return{...s,future:!1};const c=i.year>o.year||i.year===o.year&&i.month>o.month;return{...s,future:c}}):e}function bi({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 m=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((b,w)=>(w.type&&w.value&&(b[w.type]=w.value),b),{}),h=Number(m.year),g=Number(m.month),y=Number(m.day),x=Number(m.hour),v=Number(m.minute);if(Number.isFinite(h)&&Number.isFinite(g)&&Number.isFinite(y)&&Number.isFinite(x)&&Number.isFinite(v)){const b=x*2+(v>=30?1:0);return{year:h,month:g,day:y,hour:x,minute:v,dayNum:h*1e4+g*100+y,slot:b}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),d=u.getUTCFullYear(),m=u.getUTCMonth()+1,h=u.getUTCDate(),g=u.getUTCHours(),y=u.getUTCMinutes(),x=g*2+(y>=30?1:0);return{year:d,month:m,day:h,hour:g,minute:y,dayNum:d*1e4+m*100+h,slot:x}}const o=r.getFullYear(),s=r.getMonth()+1,a=r.getDate(),i=r.getHours(),c=r.getMinutes(),l=i*2+(c>=30?1:0);return{year:o,month:s,day:a,hour:i,minute:c,dayNum:o*1e4+s*100+a,slot:l}}function Sd(e){if(!e)return null;const t=String(e).trim(),[n,r]=t.split("T");if(!n||!r)return null;const o=n.split("-");if(o.length!==3)return null;const s=Number(o[0]),a=Number(o[1]),i=Number(o[2]);if(!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i))return null;const c=r.split(":"),l=Number(c[0]),u=Number(c[1]);if(!Number.isFinite(l)||l<0||l>23||!Number.isFinite(u)||u<0||u>59)return null;const d=l*2+(u>=30?1:0);return{dayNum:s*1e4+a*100+i,slot:d}}function Cd(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const r=Number(n[0]),o=Number(n[1]);return!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12?null:{year:r,month:o}}function qs({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,includeDaily:s=!0,cacheKey:a,timeZone:i,tzOffsetMinutes:c,now:l}={}){const[u,d]=f.useState([]),[m,h]=f.useState(null),[g,y]=f.useState(null),[x,v]=f.useState("edge"),[b,w]=f.useState(null),[S,C]=f.useState(!1),[k,T]=f.useState(null),N=Rn(),j=Dn(t),M=!n,R=(()=>{if(!a)return null;const O=Ed(e)||"default",A=s?"daily":"summary",U=Lr({timeZone:i,offsetMinutes:c});return`tokentracker.usage.${a}.${O}.${r}.${o}.${A}.${U}`})(),_=f.useCallback(()=>{if(!R||typeof window>"u")return null;try{const O=window.localStorage.getItem(R);if(!O)return null;const A=JSON.parse(O);return!A||!A.summary?null:A}catch{return null}},[R]),E=f.useCallback(O=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(O))}catch{}},[R]),F=f.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),P=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=f.useCallback(async()=>{const O=await tn(t);if(!(!O&&!N&&!P)){C(!0),T(null);try{let A=null,U=null;if(s){const[z,X]=await Promise.allSettled([Vo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c}),ro({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c,rolling:!0})]);if(z.status==="rejected")throw z.reason;A=z.value,U=X.status==="fulfilled"?X.value:null}else U=await ro({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c,rolling:!0});let Y=s&&Array.isArray(A?.data)?A.data:[];s&&(Y=uo(Y,r,o,{timeZone:i,offsetMinutes:c,now:l}));let Z=U?.totals||A?.summary?.totals||null,H=U?.rolling||A?.summary?.rolling||null;if(s&&!Z&&!U)try{const z=await ro({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c,rolling:!0});Z=z?.totals||null,H=z?.rolling||H}catch{}const W=new Date().toISOString();d(Y),h(Z),y(H),v("edge"),w(W),Z&&M?E({summary:Z,rolling:H,daily:Y,from:r,to:o,includeDaily:s,fetchedAt:W}):M||F()}catch(A){if(M){const U=_();if(U?.summary){h(U.summary),y(U.rolling||null);const Y=Array.isArray(U.daily)?U.daily:[],Z=s?uo(Y,U.from||r,U.to||o,{timeZone:i,offsetMinutes:c,now:l}):Y;d(Z),v("cache"),w(U.fetchedAt||null),T(null)}else{const Y=A;T(Y?.message||String(Y)),d([]),h(null),y(null),v("edge"),w(null)}}else{const U=A;T(U?.message||String(U)),d([]),h(null),y(null),v("edge"),w(null)}}finally{C(!1)}}},[t,e,r,s,N,n,M,l,_,j,i,o,c,F,E,P]);return f.useEffect(()=>{const O=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!j&&!n&&!N&&!O){d([]),h(null),y(null),T(null),C(!1),v("edge"),w(null);return}if(!M)F(),d([]),h(null),y(null),T(null),v("edge"),w(null);else{const A=_();if(A?.summary){h(A.summary),y(A.rolling||null);const U=Array.isArray(A.daily)?A.daily:[],Y=s?uo(U,A.from||r,A.to||o,{timeZone:i,offsetMinutes:c,now:l}):U;d(Y),v("cache"),w(A.fetchedAt||null)}}B()},[t,N,_,B,j,n,M,F,P]),{daily:u,summary:m,rolling:g,source:N?"mock":x,fetchedAt:b,loading:S,error:k,refresh:B}}function Ed(e){try{return new URL(e).host}catch{return null}}function lo(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&Sn(a)===t?a:null}function Md(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function uo(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=lo(t),i=lo(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,l=qo({timeZone:r,offsetMinutes:o,date:c}),u=lo(l),d=u?u.getTime():c.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const h=[];for(let g=a;g<=i;g=Md(g,1)){const y=Sn(g),x=m.get(y),v=g.getTime()>d;if(x){h.push({...x,missing:!1,future:v});continue}h.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return h}function Td({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,cacheKey:s,timeZone:a,tzOffsetMinutes:i}={}){const[c,l]=f.useState(null),[u,d]=f.useState("edge"),[m,h]=f.useState(!1),[g,y]=f.useState(null),x=Rn(),v=Dn(t),b=!n,w=f.useMemo(()=>{if(!s)return null;const M=Od(e)||"default",R=Lr({timeZone:a,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${M}.${r}.${o}.${R}`},[e,s,r,a,o,i]),S=f.useCallback(()=>{if(!w||typeof window>"u")return null;try{const M=window.localStorage.getItem(w);if(!M)return null;const R=JSON.parse(M);return!R||!R.breakdown?null:R}catch{return null}},[w]),C=f.useCallback(M=>{if(!(!w||typeof window>"u"))try{window.localStorage.setItem(w,JSON.stringify(M))}catch{}},[w]),k=f.useCallback(()=>{if(!(!w||typeof window>"u"))try{window.localStorage.removeItem(w)}catch{}},[w]),T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=f.useCallback(async()=>{const M=await tn(t);if(!(!M&&!x&&!T)){h(!0),y(null);try{const R=await Wu({baseUrl:e,accessToken:M,from:r,to:o,timeZone:a,tzOffsetMinutes:i});l(R||null),d("edge"),R&&b?C({breakdown:R,fetchedAt:new Date().toISOString()}):b||k()}catch(R){if(b){const _=S();if(_?.breakdown)l(_.breakdown),d("cache"),y(null);else{l(null),d("edge");const E=R;y(E?.message||String(E))}}else{l(null),d("edge");const _=R;y(_?.message||String(_))}}finally{h(!1)}}},[t,e,r,x,n,b,S,a,o,v,i,k,C,T]);return f.useEffect(()=>{if(!v&&!n&&!x&&!T){l(null),d("edge"),y(null),h(!1);return}if(!b)k(),l(null),d("edge"),y(null);else{const M=S();M?.breakdown&&(l(M.breakdown),d("cache"))}N()},[t,x,S,N,v,n,b,k,T]),{breakdown:c,source:x?"mock":u,loading:m,error:g,refresh:N}}function Od(e){try{return new URL(e).host}catch{return null}}const xi=new Set(["day","hour","month"]);function Nd(e){return xi.has(e)}function Gs(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 Rd(e,t){const n=Gs(e),r=Gs(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const o=et(e),s=et(t);return o==null&&s==null?0:o==null?1:s==null?-1:o===s?0:o<s?-1:1}function Dd(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 Pd(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]),o=Number(n[2]),s=Number(n[3]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o-1,s));return!Number.isFinite(a.getTime())||a.getUTCFullYear()!==r||a.getUTCMonth()+1!==o||a.getUTCDate()!==s?null:a.getTime()}function Ad(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12)return null;const s=new Date(Date.UTC(r,o-1,1));return Number.isFinite(s.getTime())?s.getTime():null}function _d(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]),o=Number(n[2]),s=Number(n[3]),a=Number(n[4]),i=Number(n[5]),c=Number(n[6]||0);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i)||!Number.isFinite(c)||o<1||o>12||s<1||s>31||a<0||a>23||i<0||i>59||c<0||c>59)return null;const l=new Date(Date.UTC(r,o-1,s,a,i,c));return Number.isFinite(l.getTime())?l.getTime():null}function Id(e,t,n){const r=n==="hour"?_d:n==="month"?Ad:Pd,o=r(e),s=r(t);return o!=null&&s!=null?o===s?0:o<s?-1:1:Dd(e,t)}function wi(e,{key:t,dir:n}){const r=n==="asc"?1:-1,o=Array.isArray(e)?e:[],s=xi.has(t)?(i,c)=>Id(i,c,t):Rd,a=i=>t==="total_tokens"&&i?.billable_total_tokens!=null?i.billable_total_tokens:i?.[t];return o.map((i,c)=>({row:i,index:c})).sort((i,c)=>{const l=a(i.row),u=a(c.row),d=l==null,m=u==null;if(d&&m)return i.index-c.index;if(d)return 1;if(m)return-1;const h=s(l,u);return h!==0?h*r:i.index-c.index}).map(i=>i.row)}const jd=[{key:"day",label:L("daily.sort.date.label"),title:L("daily.sort.date.title")},{key:"total_tokens",label:L("daily.sort.total.label"),title:L("daily.sort.total.title")},{key:"input_tokens",label:L("daily.sort.input.label"),title:L("daily.sort.input.title")},{key:"output_tokens",label:L("daily.sort.output.label"),title:L("daily.sort.output.title")},{key:"cached_input_tokens",label:L("daily.sort.cached.label"),title:L("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:L("daily.sort.reasoning.label"),title:L("daily.sort.reasoning.title")},{key:"conversation_count",label:L("daily.sort.conversations.label"),title:L("daily.sort.conversations.title")}];function zs(e){const t=Nd(e)?e:"day";return jd.map((n,r)=>r===0?{...n,key:t}:n)}function Ks(e,{key:t,dir:n}){return wi(e,{key:t,dir:n})}const Nr=12,Fd=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Wd(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 Ld(e){return Fd.some(t=>Wd(e?.[t]))}function $d(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=wi(t,{key:"month",dir:"asc"}),r=n.findIndex(o=>o?.month&&Ld(o));return r===-1?t:n.slice(r)}function Bd(e,t,n=Nr){const r=Array.isArray(e)?e:[],o=Number.isFinite(n)&&n>0?n:Nr,a=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*o;return r.slice(a,a+o)}function Yd({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:r,heatmapLoading:o,activeDays:s,hasActiveDeviceToken:a}={}){return e||t?!1:n?!0:r&&!o&&s===0&&!a}function vi(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Hd(e){const t=vi(e?.model_id);return t||null}function ki(e,t){return e?.model?String(e.model):t}function Ud(e,{copyFn:t}={}){const n=typeof t=="function"?t:a=>a,o=(Array.isArray(e?.sources)?e.sources:[]).map(a=>{const i=et(a?.totals?.billable_total_tokens??a?.totals?.total_tokens)??0,c=et(a?.totals?.total_cost_usd)??0;return{source:a?.source,totalTokens:Number.isFinite(i)?i:0,totalCost:Number.isFinite(c)?c:0,models:Array.isArray(a?.models)?a.models:[]}}).filter(a=>a.totalTokens>0);if(!o.length)return[];const s=o.reduce((a,i)=>a+i.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),o.slice().sort((a,i)=>i.totalTokens-a.totalTokens).map(a=>{const i=a.source?String(a.source).toUpperCase():n("shared.placeholder.short"),c=s>0?a.totalTokens/s*100:0,l=Number.isFinite(c)?c.toFixed(1):"0.0",u=a.models.map(d=>{const m=et(d?.totals?.billable_total_tokens??d?.totals?.total_tokens)??0;if(!Number.isFinite(m)||m<=0)return null;const h=a.totalTokens>0?Math.round(m/a.totalTokens*1e3)/10:0,g=ki(d,n("shared.placeholder.short")),y=Hd(d),x=a.totalCost>0&&a.totalTokens>0?m/a.totalTokens*a.totalCost:null;return{id:y,name:g,share:h,usage:m,cost:x}}).filter(Boolean);return{label:i,totalPercent:String(l),usd:a.totalCost,usage:a.totalTokens,models:u}})}function Vd(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:m=>m,o=Array.isArray(e?.sources)?e.sources:[];if(!o.length)return[];const s=new Map,a=new Map,i=new Map;let c=0;for(const m of o){const h=Array.isArray(m?.models)?m.models:[];for(const g of h){const y=et(g?.totals?.billable_total_tokens)??0;if(!Number.isFinite(y)||y<=0)continue;c+=y;const x=ki(g,r("shared.placeholder.short")),v=vi(x);if(!v)continue;s.set(v,(s.get(v)||0)+y);const b=i.get(v)||0;y>=b&&(i.set(v,y),a.set(v,x))}}if(!s.size)return[];const l=Array.from(s.values()).reduce((m,h)=>m+h,0),u=c>0?c:l,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(s.entries()).map(([m,h])=>{const g=u>0?(h/u*100).toFixed(1):"0.0";return{id:m,name:a.get(m)||r("shared.placeholder.short"),tokens:h,percent:String(g)}}).sort((m,h)=>h.tokens!==m.tokens?h.tokens-m.tokens:String(m.name).localeCompare(String(h.name))).slice(0,d)}const Xt=12,Bn=3,fo=26,qd=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],Gd=["#064e3b","#065f46","#059669","#10b981","#34d399"],zd=[L("heatmap.month.jan"),L("heatmap.month.feb"),L("heatmap.month.mar"),L("heatmap.month.apr"),L("heatmap.month.may"),L("heatmap.month.jun"),L("heatmap.month.jul"),L("heatmap.month.aug"),L("heatmap.month.sep"),L("heatmap.month.oct"),L("heatmap.month.nov"),L("heatmap.month.dec")];function Kd(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 Xd(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 Si(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Jd(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function Qd(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return Si(e,-((r-n+7)%7))}function Zd(e,t,n){if(!e)return[];const r=Xd(t)||new Date,o=[];for(let l=11;l>=0;l-=1)o.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-l,1)));const s=Qd(r,n),a=Si(s,-(e-1)*7),i=[],c=new Set;for(const l of o){const u=Math.floor(Jd(a,l)/7);u<0||u>=e||c.has(u)||(c.add(u),i.push({label:zd[l.getUTCMonth()],index:u}))}return i}function ef({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:o}=ai(),a=o==="dark"?Gd:qd,i=f.useRef(null);f.useEffect(()=>{const g=i.current;g&&(g.scrollLeft=g.scrollWidth)},[e?.weeks]);const c=e?.week_starts_on==="mon"?"mon":"sun",l=f.useMemo(()=>{const g=Array.isArray(e?.weeks)?e.weeks:[];if(!g.length)return{weeks:[]};const y=[];for(const x of g)for(const v of Array.isArray(x)?x:[])v?.day&&y.push({day:v.day,total_tokens:v.total_tokens??v.value??0,billable_total_tokens:v.billable_total_tokens??v.value??v.total_tokens??0});return _o({dailyRows:y,weeks:Math.max(52,g.length),to:e?.to,weekStartsOn:c})},[e?.to,e?.weeks,c]),u=l?.weeks||[],d=c==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(g=>L(`heatmap.day.${g.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(g=>L(`heatmap.day.${g.toLowerCase()}`)),m=f.useMemo(()=>Zd(u.length,l?.to,c),[l?.to,u.length,c]);if(!u.length)return p.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:L("heatmap.empty")});const h=fo+u.length*Xt+Math.max(0,u.length-1)*Bn;return p.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:[p.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:L("heatmap.title")}),p.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||L("heatmap.legend.utc")})]}),p.jsx("div",{ref:i,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:p.jsxs("div",{style:{minWidth:h},children:[p.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${fo}px repeat(${u.length}, ${Xt}px)`,columnGap:Bn},children:[p.jsx("span",{}),m.map(g=>p.jsx("span",{style:{gridColumnStart:g.index+2},className:"whitespace-nowrap",children:g.label},`${g.label}-${g.index}`))]}),p.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${fo}px repeat(${u.length}, ${Xt}px)`,columnGap:Bn},children:[p.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, ${Xt}px)`,rowGap:Bn},children:d.map(g=>p.jsx("span",{className:"leading-none",children:g},g))}),p.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Xt}px)`,gap:Bn},children:u.map((g,y)=>(Array.isArray(g)?g:[]).map((x,v)=>{if(!x)return null;const b=x.day||`e-${y}-${v}`,w=Number(x.level)||0,S=a[w]||a[0],C=t||n||L("heatmap.legend.utc");return p.jsx("span",{title:L("heatmap.tooltip",{day:x.day,value:Kd(x.value),unit:L("heatmap.unit.tokens"),tz:C}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:Xt,height:Xt,background:S}},b)}))})]})]})}),!r&&p.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:L("heatmap.legend.less")}),p.jsx("div",{className:"flex gap-0.5",children:a.map((g,y)=>p.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:g}},y))}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:L("heatmap.legend.more")})]})]})}const tf={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Ci={...tf,position:"fixed",top:0,left:0};function gt(e){const t=Ut(nf,e).current;return t.next=e,Ee(t.effect),t}function nf(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Rr=Symbol("NOT_FOUND");function rf(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function of(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function sf(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 Xs=e=>Array.isArray(e)?e:[e];function af(e){const t=Array.isArray(e[0])?e[0]:e;return sf(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function cf(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}function lf(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Rr},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function uf(e,t){let n=[];function r(i){const c=n.findIndex(l=>t(i,l.key));if(c>-1){const l=n[c];return c>0&&(n.splice(c,1),n.unshift(l)),l.value}return Rr}function o(i,c){r(i)===Rr&&(n.unshift({key:i,value:c}),n.length>e&&n.pop())}function s(){return n}function a(){n=[]}return{get:r,put:o,getEntries:s,clear:a}}var df=(e,t)=>e===t;function ff(e){return function(n,r){if(n===null||r===null||n.length!==r.length)return!1;const{length:o}=n;for(let s=0;s<o;s++)if(!e(n[s],r[s]))return!1;return!0}}function mf(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=df,maxSize:o=1,resultEqualityCheck:s}=n,a=ff(r);let i=0;const c=o<=1?lf(a):uf(o,a);function l(){let u=c.get(arguments);if(u===Rr){if(u=e.apply(null,arguments),i++,s){const m=c.getEntries().find(h=>s(h.value,u));m&&(u=m.value,i!==0&&i--)}c.put(arguments,u)}return u}return l.clearCache=()=>{c.clear(),l.resetResultsCount()},l.resultsCount=()=>i,l.resetResultsCount=()=>{i=0},l}var hf=class{constructor(e){this.value=e}deref(){return this.value}},gf=typeof WeakRef<"u"?WeakRef:hf,pf=0,Js=1;function yr(){return{s:pf,v:void 0,o:null,p:null}}function Ei(e,t={}){let n=yr();const{resultEqualityCheck:r}=t;let o,s=0;function a(){let i=n;const{length:c}=arguments;for(let d=0,m=c;d<m;d++){const h=arguments[d];if(typeof h=="function"||typeof h=="object"&&h!==null){let g=i.o;g===null&&(i.o=g=new WeakMap);const y=g.get(h);y===void 0?(i=yr(),g.set(h,i)):i=y}else{let g=i.p;g===null&&(i.p=g=new Map);const y=g.get(h);y===void 0?(i=yr(),g.set(h,i)):i=y}}const l=i;let u;if(i.s===Js)u=i.v;else if(u=e.apply(null,arguments),s++,r){const d=o?.deref?.()??o;d!=null&&r(d,u)&&(u=d,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new gf(u):u}return l.s=Js,l.v=u,u}return a.clearCache=()=>{n=yr(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function Mi(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...o)=>{let s=0,a=0,i,c={},l=o.pop();typeof l=="object"&&(c=l,l=o.pop()),rf(l,`createSelector expects an output function after the inputs, but received: [${typeof l}]`);const u={...n,...c},{memoize:d,memoizeOptions:m=[],argsMemoize:h=Ei,argsMemoizeOptions:g=[]}=u,y=Xs(m),x=Xs(g),v=af(o),b=d(function(){return s++,l.apply(null,arguments)},...y),w=h(function(){a++;const C=cf(v,arguments);return i=b.apply(null,C),i},...x);return Object.assign(w,{resultFunc:l,memoizedResultFunc:b,dependencies:v,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>i,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:d,argsMemoize:h})};return Object.assign(r,{withTypes:()=>r}),r}var yf=Mi(Ei),bf=Object.assign((e,t=yf)=>{of(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(s=>e[s]);return t(r,(...s)=>s.reduce((a,i,c)=>(a[n[c]]=i,a),{}))},{withTypes:()=>bf});Mi({memoize:mf,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const ge=(e,t,n,r,o,s,...a)=>{if(a.length>0)throw new Error(on(1));let i;if(e)i=e;else throw new Error("Missing arguments");return i};var mo={exports:{}},ho={};var Qs;function xf(){if(Qs)return ho;Qs=1;var e=ii();function t(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function i(d,m){var h=m(),g=r({inst:{value:h,getSnapshot:m}}),y=g[0].inst,x=g[1];return s(function(){y.value=h,y.getSnapshot=m,c(y)&&x({inst:y})},[d,h,m]),o(function(){return c(y)&&x({inst:y}),d(function(){c(y)&&x({inst:y})})},[d]),a(h),h}function c(d){var m=d.getSnapshot;d=d.value;try{var h=m();return!n(d,h)}catch{return!0}}function l(d,m){return m()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:i;return ho.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,ho}var Zs;function Ti(){return Zs||(Zs=1,mo.exports=xf()),mo.exports}var wf=Ti(),go={exports:{}},po={};var ea;function vf(){if(ea)return po;ea=1;var e=ii(),t=Ti();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,i=e.useMemo,c=e.useDebugValue;return po.useSyncExternalStoreWithSelector=function(l,u,d,m,h){var g=s(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=i(function(){function v(k){if(!b){if(b=!0,w=k,k=m(k),h!==void 0&&y.hasValue){var T=y.value;if(h(T,k))return S=T}return S=k}if(T=S,r(w,k))return T;var N=m(k);return h!==void 0&&h(T,N)?(w=k,T):(w=k,S=N)}var b=!1,w,S,C=d===void 0?null:d;return[function(){return v(u())},C===null?void 0:function(){return v(C())}]},[u,d,m,h]);var x=o(l,g[0],g[1]);return a(function(){y.hasValue=!0,y.value=x},[x]),c(x),x},po}var ta;function kf(){return ta||(ta=1,go.exports=vf()),go.exports}var Sf=kf();const Cf=ci(19),Ef=Cf?Tf:Of;function Mf(e,t,n,r,o){return Ef(e,t,n,r,o)}function Tf(e,t,n,r,o){const s=f.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return wf.useSyncExternalStore(e.subscribe,s,s)}function Of(e,t,n,r,o){return Sf.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class zn{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])){zn.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||zn.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};zn.prototype.setState.call(this,t)}}class Zo extends zn{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){f.useDebugValue(t),Ee(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ee(()=>(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);Ee(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){f.useDebugValue(t);const o=this,s=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,s),!s&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})),Ee(()=>{s&&!Object.is(o.state[t],n)&&super.setState({...o.state,[t]:n})},[o,t,n,r,s])}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,o)=>{const s=this.selectors[t];return s(this.state,n,r,o)};useState=(t,n,r,o)=>{f.useDebugValue(t);const s=this.selectors[t];return Mf(this,s,n,r,o)};useContextCallback(t,n){f.useDebugValue(t);const r=me(n??li);this.context[t]=r}useStateSetter(t){const n=f.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 o=r(this.state);return n(o,o,this),this.subscribe(s=>{const a=r(s);if(!Object.is(o,a)){const i=o;o=a,n(a,i,this)}})}}const Nf=[];function es(e){f.useEffect(e,Nf)}const br=null;class Rf{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 o=0;o<n.length;o+=1)n[o]?.(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 xr=new Rf;class ht{static create(){return new ht}static request(t){return xr.request(t)}static cancel(t){return xr.cancel(t)}currentId=br;request(t){this.cancel(),this.currentId=xr.request(()=>{this.currentId=br,t()})}cancel=()=>{this.currentId!==br&&(xr.cancel(this.currentId),this.currentId=br)};disposeEffect=()=>this.cancel}function ts(){const e=Ut(ht.create).current;return es(e.disposeEffect),e}const Yn=0;class Ht{static create(){return new Ht}currentId=Yn;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Yn,n()},t)}isStarted(){return this.currentId!==Yn}clear=()=>{this.currentId!==Yn&&(clearTimeout(this.currentId),this.currentId=Yn)};disposeEffect=()=>this.clear}function nn(){const e=Ut(Ht.create).current;return es(e.disposeEffect),e}const Pn=typeof navigator<"u",yo=_f(),Oi=jf(),Ni=If(),Df=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Ri=yo.platform==="MacIntel"&&yo.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(yo.platform),Pf=Pn&&/apple/i.test(navigator.vendor),Io=Pn&&/android/i.test(Oi)||/android/i.test(Ni);Pn&&Oi.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Af=Ni.includes("jsdom/");function _f(){if(!Pn)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 If(){if(!Pn)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function jf(){if(!Pn)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const jo="data-base-ui-focusable",Di="active",Pi="selected",Ai="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function yn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function ve(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Lu(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Je(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 Ff(e){return e.matches("html,body")}function Ye(e){return e?.ownerDocument||document}function _i(e){return Ge(e)&&e.matches(Ai)}function na(e){return e?e.getAttribute("role")==="combobox"&&_i(e):!1}function Fo(e){return e?e.hasAttribute(jo)?e:e.querySelector(`[${jo}]`)||e:null}function en(e,t,n=!0){return e.filter(o=>o.parentId===t&&(!n||o.context?.open)).flatMap(o=>[o,...en(e,o.id,n)])}function ra(e,t){let n=[],r=e.find(o=>o.id===t)?.parentId;for(;r;){const o=e.find(s=>s.id===r);r=o?.parentId,o&&(n=n.concat(o))}return n}function Wf(e){e.preventDefault(),e.stopPropagation()}function Lf(e){return"nativeEvent"in e}function $f(e){return e.mozInputSource===0&&e.isTrusted?!0:Io&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Bf(e){return Af?!1:!Io&&e.width===0&&e.height===0||Io&&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 En(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Ii(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Yf=["top","right","bottom","left"],Mn=Math.min,Qe=Math.max,Dr=Math.round,wr=Math.floor,xt=e=>({x:e,y:e}),Hf={left:"right",right:"left",bottom:"top",top:"bottom"};function Wo(e,t,n){return Qe(e,Mn(t,n))}function Rt(e,t){return typeof e=="function"?e(t):e}function ze(e){return e.split("-")[0]}function Vt(e){return e.split("-")[1]}function ns(e){return e==="x"?"y":"x"}function rs(e){return e==="y"?"height":"width"}function ot(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function os(e){return ns(ot(e))}function Uf(e,t,n){n===void 0&&(n=!1);const r=Vt(e),o=os(e),s=rs(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Pr(a)),[a,Pr(a)]}function Vf(e){const t=Pr(e);return[Lo(e),t,Lo(t)]}function Lo(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const oa=["left","right"],sa=["right","left"],qf=["top","bottom"],Gf=["bottom","top"];function zf(e,t,n){switch(e){case"top":case"bottom":return n?t?sa:oa:t?oa:sa;case"left":case"right":return t?qf:Gf;default:return[]}}function Kf(e,t,n,r){const o=Vt(e);let s=zf(ze(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Lo)))),s}function Pr(e){const t=ze(e);return Hf[t]+e.slice(t.length)}function Xf(e){return{top:0,right:0,bottom:0,left:0,...e}}function ji(e){return typeof e!="number"?Xf(e):{top:e,right:e,bottom:e,left:e}}function Ar(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}var Jf=["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] *)"],_r=Jf.join(","),Fi=typeof Element>"u",Tn=Fi?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ir=!Fi&&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},jr=function(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),s=o===""||o==="true",a=s||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):jr(t.parentNode));return a},Qf=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Wi=function(t,n,r){if(jr(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(_r));return n&&Tn.call(t,_r)&&o.unshift(t),o=o.filter(r),o},Fr=function(t,n,r){for(var o=[],s=Array.from(t);s.length;){var a=s.shift();if(!jr(a,!1))if(a.tagName==="SLOT"){var i=a.assignedElements(),c=i.length?i:a.children,l=Fr(c,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:a,candidates:l})}else{var u=Tn.call(a,_r);u&&r.filter(a)&&(n||!t.includes(a))&&o.push(a);var d=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),m=!jr(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(d&&m){var h=Fr(d===!0?a.children:d.children,!0,r);r.flatten?o.push.apply(o,h):o.push({scopeParent:a,candidates:h})}else s.unshift.apply(s,a.children)}}return o},Li=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},$i=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Qf(t))&&!Li(t)?0:t.tabIndex},Zf=function(t,n){var r=$i(t);return r<0&&n&&!Li(t)?0:r},em=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Bi=function(t){return t.tagName==="INPUT"},tm=function(t){return Bi(t)&&t.type==="hidden"},nm=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},rm=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},om=function(t){if(!t.name)return!0;var n=t.form||Ir(t),r=function(i){return n.querySelectorAll('input[type="radio"][name="'+i+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(a){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",a.message),!1}var s=rm(o,t.form);return!s||s===t},sm=function(t){return Bi(t)&&t.type==="radio"},am=function(t){return sm(t)&&!om(t)},im=function(t){var n,r=t&&Ir(t),o=(n=r)===null||n===void 0?void 0:n.host,s=!1;if(r&&r!==t){var a,i,c;for(s=!!((a=o)!==null&&a!==void 0&&(i=a.ownerDocument)!==null&&i!==void 0&&i.contains(o)||t!=null&&(c=t.ownerDocument)!==null&&c!==void 0&&c.contains(t));!s&&o;){var l,u,d;r=Ir(o),o=(l=r)===null||l===void 0?void 0:l.host,s=!!((u=o)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(o))}}return s},aa=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},cm=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var s=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!s}if(getComputedStyle(t).visibility==="hidden")return!0;var a=Tn.call(t,"details>summary:first-of-type"),i=a?t.parentElement:t;if(Tn.call(i,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof o=="function"){for(var c=t;t;){var l=t.parentElement,u=Ir(t);if(l&&!l.shadowRoot&&o(l)===!0)return aa(t);t.assignedSlot?t=t.assignedSlot:!l&&u!==t.ownerDocument?t=u.host:t=l}t=c}if(im(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return aa(t);return!1},lm=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 o=n.children.item(r);if(o.tagName==="LEGEND")return Tn.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},$o=function(t,n){return!(n.disabled||tm(n)||cm(n,t)||nm(n)||lm(n))},Bo=function(t,n){return!(am(n)||$i(n)<0||!$o(t,n))},um=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Yi=function(t){var n=[],r=[];return t.forEach(function(o,s){var a=!!o.scopeParent,i=a?o.scopeParent:o,c=Zf(i,a),l=a?Yi(o.candidates):i;c===0?a?n.push.apply(n,l):n.push(i):r.push({documentOrder:s,tabIndex:c,item:o,isScope:a,content:l})}),r.sort(em).reduce(function(o,s){return s.isScope?o.push.apply(o,s.content):o.push(s.content),o},[]).concat(n)},rr=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Fr([t],n.includeContainer,{filter:Bo.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:um}):r=Wi(t,n.includeContainer,Bo.bind(null,n)),Yi(r)},dm=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Fr([t],n.includeContainer,{filter:$o.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Wi(t,n.includeContainer,$o.bind(null,n)),r},Hi=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Tn.call(t,_r)===!1?!1:Bo(n,t)};const An=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Ui(e,t){const n=rr(e,An()),r=n.length;if(r===0)return;const o=yn(Ye(e)),s=n.indexOf(o),a=s===-1?t===1?0:r-1:s+t;return n[a]}function ss(e){return Ui(Ye(e).body,1)||e}function Vi(e){return Ui(Ye(e).body,-1)||e}function qi(e,t){if(!e)return null;const n=rr(Ye(e).body,An()),r=n.length;if(r===0)return null;const o=n.indexOf(e);if(o===-1)return null;const s=(o+t+r)%r;return n[s]}function fm(e){return qi(e,1)}function mm(e){return qi(e,-1)}function wn(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ve(n,r)}function hm(e){rr(e,An()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function ia(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const gm={...$u};let ca=0;function pm(e,t="mui"){const[n,r]=f.useState(e),o=e||n;return f.useEffect(()=>{n==null&&(ca+=1,r(`${t}-${ca}`))},[n,t]),o}const la=gm.useId;function _n(e,t){if(la!==void 0){const n=la();return e??(t?`${t}-${n}`:n)}return pm(e,t)}function Gi(){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 ym{nodesRef={current:[]};events=Gi();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 zi=f.createContext(null),Ki=f.createContext(null),sn=()=>f.useContext(zi)?.id||null,In=e=>{const t=f.useContext(Ki);return e??t};function bm(e){const t=_n(),n=In(e),r=sn();return Ee(()=>{if(!t)return;const o={id:t,parentId:r};return n?.addNode(o),()=>{n?.removeNode(o)}},[n,t,r]),t}function xm(e){const{children:t,id:n}=e,r=sn();return p.jsx(zi.Provider,{value:f.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function wm(e){const{children:t,externalTree:n}=e,r=Ut(()=>n??new ym).current;return p.jsx(Ki.Provider,{value:r,children:t})}const vm="none",Bt="trigger-press",Ze="trigger-hover",Xi="outside-press",km="close-press",Kn="focus-out",Ji="escape-key",Qi="imperative-action";function _e(e,t,n,r){let o=!1,s=!1;const a=$t;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){s=!0},get isCanceled(){return o},get isPropagationAllowed(){return s},trigger:n,...a}}function Xn(e){return`data-base-ui-${e}`}function bo(e,t,n){if(n&&!En(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]}function an(e){return e?.ownerDocument||document}const On=f.forwardRef(function(t,n){const[r,o]=f.useState();Ee(()=>{Pf&&o("button")},[]);const s={tabIndex:0,role:r};return p.jsx("span",{...t,ref:n,style:Ci,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});let ua=0;function xo(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(ua);const s=()=>e?.focus({preventScroll:n});o?s():ua=requestAnimationFrame(s)}const vn={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function da(e){return e==="inert"?vn.inert:e==="aria-hidden"?vn["aria-hidden"]:vn.none}let vr=new WeakSet,kr={},wo=0;const Zi=e=>e&&(e.host||Zi(e.parentNode)),Sm=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=Zi(n);return e.contains(r)?r:null}).filter(n=>n!=null);function Cm(e,t,n,r){const o="data-base-ui-inert",s=r?"inert":n?"aria-hidden":null,a=Sm(t,e),i=new Set,c=new Set(a),l=[];kr[o]||(kr[o]=new WeakMap);const u=kr[o];a.forEach(d),m(t),i.clear();function d(h){!h||i.has(h)||(i.add(h),h.parentNode&&d(h.parentNode))}function m(h){!h||c.has(h)||[].forEach.call(h.children,g=>{if(tr(g)!=="script")if(i.has(g))m(g);else{const y=s?g.getAttribute(s):null,x=y!==null&&y!=="false",v=da(s),b=(v.get(g)||0)+1,w=(u.get(g)||0)+1;v.set(g,b),u.set(g,w),l.push(g),b===1&&x&&vr.add(g),w===1&&g.setAttribute(o,""),!x&&s&&g.setAttribute(s,s==="inert"?"":"true")}})}return wo+=1,()=>{l.forEach(h=>{const g=da(s),x=(g.get(h)||0)-1,v=(u.get(h)||0)-1;g.set(h,x),u.set(h,v),x||(!vr.has(h)&&s&&h.removeAttribute(s),vr.delete(h)),v||h.removeAttribute(o)}),wo-=1,wo||(vn.inert=new WeakMap,vn["aria-hidden"]=new WeakMap,vn.none=new WeakMap,vr=new WeakSet,kr={})}}function Em(e,t=!1,n=!1){const r=Ye(e[0]).body;return Cm(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const ec=f.createContext(null),tc=()=>f.useContext(ec),Mm=Xn("portal");function Tm(e={}){const{ref:t,container:n,componentProps:r=$t,elementProps:o,elementState:s}=e,a=_n(),c=tc()?.portalNode,[l,u]=f.useState(null),[d,m]=f.useState(null),h=me(v=>{v!==null&&m(v)}),g=f.useRef(null);Ee(()=>{if(n===null){g.current&&(g.current=null,m(null),u(null));return}if(a==null)return;const v=(n&&(Bu(n)?n:n.current))??c??document.body;if(v==null){g.current&&(g.current=null,m(null),u(null));return}g.current!==v&&(g.current=v,m(null),u(v))},[n,c,a]);const y=Dt("div",r,{ref:[t,h],state:s,props:[{id:a,[Mm]:""},o]});return{portalNode:d,portalSubtree:l&&y?Yt.createPortal(y,l):null}}const nc=f.forwardRef(function(t,n){const{children:r,container:o,className:s,render:a,renderGuards:i,...c}=t,{portalNode:l,portalSubtree:u}=Tm({container:o,ref:n,componentProps:t,elementProps:c}),d=f.useRef(null),m=f.useRef(null),h=f.useRef(null),g=f.useRef(null),[y,x]=f.useState(null),v=y?.modal,b=y?.open,w=typeof i=="boolean"?i:!!y&&!y.modal&&y.open&&!!l;f.useEffect(()=>{if(!l||v)return;function C(k){l&&k.relatedTarget&&wn(k)&&(k.type==="focusin"?ia:hm)(l)}return l.addEventListener("focusin",C,!0),l.addEventListener("focusout",C,!0),()=>{l.removeEventListener("focusin",C,!0),l.removeEventListener("focusout",C,!0)}},[l,v]),f.useEffect(()=>{!l||b||ia(l)},[b,l]);const S=f.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:m,beforeInsideRef:h,afterInsideRef:g,portalNode:l,setFocusManagerState:x}),[l]);return p.jsxs(f.Fragment,{children:[u,p.jsxs(ec.Provider,{value:S,children:[w&&l&&p.jsx(On,{"data-type":"outside",ref:d,onFocus:C=>{if(wn(C,l))h.current?.focus();else{const k=y?y.domReference:null;Vi(k)?.focus()}}}),w&&l&&p.jsx("span",{"aria-owns":l.id,style:ld}),l&&Yt.createPortal(r,l),w&&l&&p.jsx(On,{"data-type":"outside",ref:m,onFocus:C=>{if(wn(C,l))g.current?.focus();else{const k=y?y.domReference:null;ss(k)?.focus(),y?.closeOnFocusOut&&y?.onOpenChange(!1,_e(Kn,C.nativeEvent))}}})]})]})});function Tt(e){return e==null?e:"current"in e?e.current:e}function Om(e,t){const n=st(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 fa=20;let Lt=[];function as(){Lt=Lt.filter(e=>e.isConnected)}function Nm(e){as(),e&&tr(e)!=="body"&&(Lt.push(e),Lt.length>fa&&(Lt=Lt.slice(-fa)))}function vo(){return as(),Lt[Lt.length-1]}function Rm(e){if(!e)return null;const t=An();return Hi(e,t)?e:rr(e,t)[0]||e}function Dm(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():ft(e).display!=="none"}function ma(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=An(),o=dm(e,n).filter(a=>{const i=a.getAttribute("data-tabindex")||"";return Hi(a,n)||a.hasAttribute("data-tabindex")&&!i.startsWith("-")}),s=e.getAttribute("tabindex");t.current.includes("floating")||o.length===0?s!=="0"&&e.setAttribute("tabindex","0"):(s!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function rc(e){const{context:t,children:n,disabled:r=!1,order:o=["content"],initialFocus:s=!0,returnFocus:a=!0,restoreFocus:i=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u="",getInsideElements:d=()=>[],nextFocusableElement:m,previousFocusableElement:h,beforeContentFocusGuardRef:g,externalTree:y}=e,x="rootStore"in t?t.rootStore:t,v=x.useState("open"),b=x.useState("domReferenceElement"),w=x.useState("floatingElement"),{events:S,dataRef:C}=x.context,k=me(()=>C.current.floatingContext?.nodeId),T=me(d),N=s===!1,j=na(b)&&N,M=gt(o),R=gt(s),_=gt(a),E=gt(u),F=In(y),P=tc(),B=f.useRef(null),V=f.useRef(null),O=f.useRef(!1),A=f.useRef(!1),U=f.useRef(!1),Y=f.useRef(-1),Z=f.useRef(""),H=f.useRef(""),W=f.useRef(null),z=f.useRef(null),X=Bs(W,g,P?.beforeInsideRef),oe=Bs(z,P?.afterInsideRef),be=nn(),Oe=nn(),xe=ts(),Le=P!=null,D=Fo(w),ae=me(($=D)=>$?rr($,An()):[]),q=me($=>{const J=ae($);return M.current.map(()=>J).filter(Boolean).flat()});f.useEffect(()=>{if(r||!c)return;function $(ie){ie.key==="Tab"&&ve(D,yn(Ye(D)))&&ae().length===0&&!j&&Wf(ie)}const J=Ye(D);return J.addEventListener("keydown",$),()=>{J.removeEventListener("keydown",$)}},[r,b,D,c,M,j,ae,q]),f.useEffect(()=>{if(r||!w)return;function $(J){const ie=Je(J),de=ae().indexOf(ie);de!==-1&&(Y.current=de)}return w.addEventListener("focusin",$),()=>{w.removeEventListener("focusin",$)}},[r,w,ae]),f.useEffect(()=>{if(r||!v)return;const $=Ye(D);function J(){U.current=!1}function ie(de){const se=Je(de),Q=ve(w,se)||ve(b,se)||ve(P?.portalNode,se);U.current=!Q,H.current=de.pointerType||"keyboard"}function he(){H.current="keyboard"}return $.addEventListener("pointerdown",ie,!0),$.addEventListener("pointerup",J,!0),$.addEventListener("pointercancel",J,!0),$.addEventListener("keydown",he,!0),()=>{$.removeEventListener("pointerdown",ie,!0),$.removeEventListener("pointerup",J,!0),$.removeEventListener("pointercancel",J,!0),$.removeEventListener("keydown",he,!0)}},[r,w,b,D,v,P]),f.useEffect(()=>{if(r||!l)return;function $(){A.current=!0,Oe.start(0,()=>{A.current=!1})}function J(se){const Q=se.relatedTarget,De=se.currentTarget,ke=Je(se);queueMicrotask(()=>{const je=k(),pe=x.context.triggerElements,Ke=Q?.hasAttribute(Xn("focus-guard"))&&[W.current,z.current,P?.beforeInsideRef.current,P?.afterInsideRef.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,Tt(h),Tt(m)].includes(Q),Fe=!(ve(b,Q)||ve(w,Q)||ve(Q,w)||ve(P?.portalNode,Q)||Q!=null&&pe.hasElement(Q)||pe.hasMatchingElement(Se=>ve(Se,Q))||Ke||F&&(en(F.nodesRef.current,je).find(Se=>ve(Se.context?.elements.floating,Q)||ve(Se.context?.elements.domReference,Q))||ra(F.nodesRef.current,je).find(Se=>[Se.context?.elements.floating,Fo(Se.context?.elements.floating)].includes(Q)||Se.context?.elements.domReference===Q)));if(De===b&&D&&ma(D,M),i&&De!==b&&!Dm(ke)&&yn(Ye(D))===Ye(D).body){if(Ge(D)&&(D.focus(),i==="popup")){xe.request(()=>{D.focus()});return}const Se=Y.current,Ue=ae(),He=Ue[Se]||Ue[Ue.length-1]||D;Ge(He)&&He.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(j||!c)&&Q&&Fe&&!A.current&&(j||Q!==vo())&&(O.current=!0,x.setOpen(!1,_e(Kn,se)))})}function ie(){U.current||(C.current.insideReactTree=!0,be.start(0,()=>{C.current.insideReactTree=!1}))}const he=Ge(b)?b:null,de=[];if(!(!w&&!he))return he&&(he.addEventListener("focusout",J),he.addEventListener("pointerdown",$),de.push(()=>{he.removeEventListener("focusout",J),he.removeEventListener("pointerdown",$)})),w&&(w.addEventListener("focusout",J),P&&(w.addEventListener("focusout",ie,!0),de.push(()=>{w.removeEventListener("focusout",ie,!0)})),de.push(()=>{w.removeEventListener("focusout",J)})),()=>{de.forEach(se=>{se()})}},[r,b,w,D,c,F,P,x,l,i,ae,j,k,M,C,be,Oe,xe,m,h]),f.useEffect(()=>{if(r||!w||!v)return;const $=Array.from(P?.portalNode?.querySelectorAll(`[${Xn("portal")}]`)||[]),ie=(F?ra(F.nodesRef.current,k()):[]).find(se=>na(se.context?.elements.domReference||null))?.context?.elements.domReference,he=[w,ie,...$,...T(),B.current,V.current,W.current,z.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,Tt(h),Tt(m),j?b:null].filter(se=>se!=null),de=Em(he,c||j);return()=>{de()}},[v,r,b,w,c,M,P,j,F,k,T,m,h]),Ee(()=>{if(!v||r||!Ge(D))return;const $=Ye(D),J=yn($);queueMicrotask(()=>{const ie=q(D),he=R.current,de=typeof he=="function"?he(E.current||""):he;if(de===void 0||de===!1)return;let se;de===!0||de===null?se=ie[0]||D:se=Tt(de),se=se||ie[0]||D,!ve(D,J)&&xo(se,{preventScroll:se===D})})},[r,v,D,N,q,R,E]),Ee(()=>{if(r||!D)return;const $=Ye(D),J=yn($);Nm(J);function ie(se){if(se.open||(Z.current=Om(se.nativeEvent,H.current)),se.reason===Ze&&se.nativeEvent.type==="mouseleave"&&(O.current=!0),se.reason===Xi)if(se.nested)O.current=!1;else if($f(se.nativeEvent)||Bf(se.nativeEvent))O.current=!1;else{let Q=!1;document.createElement("div").focus({get preventScroll(){return Q=!0,!1}}),Q?O.current=!1:O.current=!0}}S.on("openchange",ie);const he=$.createElement("span");he.setAttribute("tabindex","-1"),he.setAttribute("aria-hidden","true"),Object.assign(he.style,Ci),Le&&b&&b.insertAdjacentElement("afterend",he);function de(){const se=_.current;let Q=typeof se=="function"?se(Z.current):se;if(Q===void 0||Q===!1)return null;if(Q===null&&(Q=!0),typeof Q=="boolean"){const ke=b||vo();return ke&&ke.isConnected?ke:he}const De=b||vo()||he;return Tt(Q)||De}return()=>{S.off("openchange",ie);const se=yn($),Q=ve(w,se)||F&&en(F.nodesRef.current,k(),!1).some(ke=>ve(ke.context?.elements.floating,se)),De=de();queueMicrotask(()=>{const ke=Rm(De),je=typeof _.current!="boolean";_.current&&!O.current&&Ge(ke)&&(!(!je&&ke!==se&&se!==$.body)||Q)&&ke.focus({preventScroll:!0}),he.remove()})}},[r,w,D,_,C,S,F,Le,b,k]),f.useEffect(()=>{queueMicrotask(()=>{O.current=!1})},[r]),f.useEffect(()=>{if(r||!v)return;function $(ie){Je(ie)?.closest(`[${gi}]`)&&(A.current=!0)}const J=Ye(D);return J.addEventListener("pointerdown",$,!0),()=>{J.removeEventListener("pointerdown",$,!0)}},[r,v,D]),Ee(()=>{if(!r&&P)return P.setFocusManagerState({modal:c,closeOnFocusOut:l,open:v,onOpenChange:x.setOpen,domReference:b}),()=>{P.setFocusManagerState(null)}},[r,P,c,v,x,l,b]),Ee(()=>{if(!(r||!D))return ma(D,M),()=>{queueMicrotask(as)}},[r,D,M]);const ye=!r&&(c?!j:!0)&&(Le||c);return p.jsxs(f.Fragment,{children:[ye&&p.jsx(On,{"data-type":"inside",ref:X,onFocus:$=>{if(c){const J=q();xo(J[J.length-1])}else P?.portalNode&&(O.current=!1,wn($,P.portalNode)?ss(b)?.focus():Tt(h??P.beforeOutsideRef)?.focus())}}),n,ye&&p.jsx(On,{"data-type":"inside",ref:oe,onFocus:$=>{c?xo(q()[0]):P?.portalNode&&(l&&(O.current=!0),wn($,P.portalNode)?Vi(b)?.focus():Tt(m??P.afterOutsideRef)?.focus())}})]})}function Pm(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:o=!0,event:s="click",toggle:a=!0,ignoreMouse:i=!1,stickIfOpen:c=!0,touchOpenDelay:l=0}=t,u=f.useRef(void 0),d=ts(),m=nn(),h=f.useMemo(()=>({onPointerDown(g){u.current=g.pointerType},onMouseDown(g){const y=u.current,x=g.nativeEvent,v=n.select("open");if(g.button!==0||s==="click"||En(y,!0)&&i)return;const b=r.current.openEvent,w=b?.type,S=n.select("domReferenceElement")!==g.currentTarget,C=v&&S||!(v&&a&&(!(b&&c)||w==="click"||w==="mousedown"));if(_i(x.target)){const T=_e(Bt,x,x.target);C&&y==="touch"&&l>0?m.start(l,()=>{n.setOpen(!0,T)}):n.setOpen(C,T);return}const k=g.currentTarget;d.request(()=>{const T=_e(Bt,x,k);C&&y==="touch"&&l>0?m.start(l,()=>{n.setOpen(!0,T)}):n.setOpen(C,T)})},onClick(g){if(s==="mousedown-only")return;const y=u.current;if(s==="mousedown"&&y){u.current=void 0;return}if(En(y,!0)&&i)return;const x=n.select("open"),v=r.current.openEvent,b=n.select("domReferenceElement")!==g.currentTarget,w=x&&b||!(x&&a&&(!(v&&c)||Ii(v))),S=_e(Bt,g.nativeEvent,g.currentTarget);w&&y==="touch"&&l>0?m.start(l,()=>{n.setOpen(!0,S)}):n.setOpen(w,S)},onKeyDown(){u.current=void 0}}),[r,s,i,n,c,a,d,m,l]);return f.useMemo(()=>o?{reference:h}:$t,[o,h])}function ha(e,t,n){let{reference:r,floating:o}=e;const s=ot(t),a=os(t),i=rs(a),c=ze(t),l=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,m=r[i]/2-o[i]/2;let h;switch(c){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Vt(t)){case"start":h[a]-=m*(n&&l?-1:1);break;case"end":h[a]+=m*(n&&l?-1:1);break}return h}async function Am(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=Rt(t,e),g=ji(h),x=i[m?d==="floating"?"reference":"floating":d],v=Ar(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:l,rootBoundary:u,strategy:c})),b=d==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),S=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},C=Ar(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:b,offsetParent:w,strategy:c}):b);return{top:(v.top-C.top+g.top)/S.y,bottom:(C.bottom-v.bottom+g.bottom)/S.y,left:(v.left-C.left+g.left)/S.x,right:(C.right-v.right+g.right)/S.x}}const _m=50,Im=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:Am},c=await(a.isRTL==null?void 0:a.isRTL(t));let l=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=ha(l,r,c),m=r,h=0;const g={};for(let y=0;y<s.length;y++){const x=s[y];if(!x)continue;const{name:v,fn:b}=x,{x:w,y:S,data:C,reset:k}=await b({x:u,y:d,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:l,platform:i,elements:{reference:e,floating:t}});u=w??u,d=S??d,g[v]={...g[v],...C},k&&h<_m&&(h++,typeof k=="object"&&(k.placement&&(m=k.placement),k.rects&&(l=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:u,y:d}=ha(l,m,c)),y=-1)}return{x:u,y:d,placement:m,strategy:o,middlewareData:g}},jm=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...x}=Rt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=ze(o),b=ot(i),w=ze(i)===i,S=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=m||(w||!y?[Pr(i)]:Vf(i)),k=g!=="none";!m&&k&&C.push(...Kf(i,y,g,S));const T=[i,...C],N=await c.detectOverflow(t,x),j=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&j.push(N[v]),d){const F=Uf(o,a,S);j.push(N[F[0]],N[F[1]])}if(M=[...M,{placement:o,overflows:j}],!j.every(F=>F<=0)){var R,_;const F=(((R=s.flip)==null?void 0:R.index)||0)+1,P=T[F];if(P&&(!(d==="alignment"?b!==ot(P):!1)||M.every(O=>ot(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:F,overflows:M},reset:{placement:P}};let B=(_=M.filter(V=>V.overflows[0]<=0).sort((V,O)=>V.overflows[1]-O.overflows[1])[0])==null?void 0:_.placement;if(!B)switch(h){case"bestFit":{var E;const V=(E=M.filter(O=>{if(k){const A=ot(O.placement);return A===b||A==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(A=>A>0).reduce((A,U)=>A+U,0)]).sort((O,A)=>O[1]-A[1])[0])==null?void 0:E[0];V&&(B=V);break}case"initialPlacement":B=i;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function ga(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pa(e){return Yf.some(t=>e[t]>=0)}const Fm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=Rt(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),i=ga(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pa(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=ga(a,n.floating);return{data:{escapedOffsets:i,escaped:pa(i)}}}default:return{}}}}},oc=new Set(["left","top"]);async function Wm(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=ze(n),i=Vt(n),c=ot(n)==="y",l=oc.has(a)?-1:1,u=s&&c?-1:1,d=Rt(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof g=="number"&&(h=i==="end"?g*-1:g),c?{x:h*u,y:m*l}:{x:m*l,y:h*u}}const Lm=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,c=await Wm(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:a}}}}},$m=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:b,y:w}=v;return{x:b,y:w}}},...l}=Rt(e,t),u={x:n,y:r},d=await s.detectOverflow(t,l),m=ot(ze(o)),h=ns(m);let g=u[h],y=u[m];if(a){const v=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=g+d[v],S=g-d[b];g=Wo(w,g,S)}if(i){const v=m==="y"?"top":"left",b=m==="y"?"bottom":"right",w=y+d[v],S=y-d[b];y=Wo(w,y,S)}const x=c.fn({...t,[h]:g,[m]:y});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:a,[m]:i}}}}}},Bm=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:c=!0,crossAxis:l=!0}=Rt(e,t),u={x:n,y:r},d=ot(o),m=ns(d);let h=u[m],g=u[d];const y=Rt(i,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const w=m==="y"?"height":"width",S=s.reference[m]-s.floating[w]+x.mainAxis,C=s.reference[m]+s.reference[w]-x.mainAxis;h<S?h=S:h>C&&(h=C)}if(l){var v,b;const w=m==="y"?"width":"height",S=oc.has(ze(o)),C=s.reference[d]-s.floating[w]+(S&&((v=a.offset)==null?void 0:v[d])||0)+(S?0:x.crossAxis),k=s.reference[d]+s.reference[w]+(S?0:((b=a.offset)==null?void 0:b[d])||0)-(S?x.crossAxis:0);g<C?g=C:g>k&&(g=k)}return{[m]:h,[d]:g}}}},Ym=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:c=()=>{},...l}=Rt(e,t),u=await a.detectOverflow(t,l),d=ze(o),m=Vt(o),h=ot(o)==="y",{width:g,height:y}=s.floating;let x,v;d==="top"||d==="bottom"?(x=d,v=m===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(v=d,x=m==="end"?"top":"bottom");const b=y-u.top-u.bottom,w=g-u.left-u.right,S=Mn(y-u[x],b),C=Mn(g-u[v],w),k=!t.middlewareData.shift;let T=S,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=b),k&&!m){const M=Qe(u.left,0),R=Qe(u.right,0),_=Qe(u.top,0),E=Qe(u.bottom,0);h?N=g-2*(M!==0||R!==0?M+R:Qe(u.left,u.right)):T=y-2*(_!==0||E!==0?_+E:Qe(u.top,u.bottom))}await c({...t,availableWidth:N,availableHeight:T});const j=await a.getDimensions(i.floating);return g!==j.width||y!==j.height?{reset:{rects:!0}}:{}}}};function sc(e){const t=ft(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ge(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=Dr(n)!==s||Dr(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function is(e){return Re(e)?e:e.contextElement}function kn(e){const t=is(e);if(!Ge(t))return xt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sc(t);let a=(s?Dr(n.width):n.width)/r,i=(s?Dr(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const Hm=xt(0);function ac(e){const t=st(e);return!Go()||!t.visualViewport?Hm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Um(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==st(e)?!1:t}function rn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=is(e);let a=xt(1);t&&(r?Re(r)&&(a=kn(r)):a=kn(e));const i=Um(s,n,r)?ac(s):xt(0);let c=(o.left+i.x)/a.x,l=(o.top+i.y)/a.y,u=o.width/a.x,d=o.height/a.y;if(s){const m=st(s),h=r&&Re(r)?st(r):r;let g=m,y=Ys(g);for(;y&&r&&h!==g;){const x=kn(y),v=y.getBoundingClientRect(),b=ft(y),w=v.left+(y.clientLeft+parseFloat(b.paddingLeft))*x.x,S=v.top+(y.clientTop+parseFloat(b.paddingTop))*x.y;c*=x.x,l*=x.y,u*=x.x,d*=x.y,c+=w,l+=S,g=st(y),y=Ys(g)}}return Ar({width:u,height:d,x:c,y:l})}function Br(e,t){const n=$r(e).scrollLeft;return t?t.left+n:rn(Pt(e)).left+n}function ic(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Br(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Vm(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=Pt(r),i=t?zo(t.floating):!1;if(r===a||i&&s)return n;let c={scrollLeft:0,scrollTop:0},l=xt(1);const u=xt(0),d=Ge(r);if((d||!d&&!s)&&((tr(r)!=="body"||nr(a))&&(c=$r(r)),d)){const h=rn(r);l=kn(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const m=a&&!d&&!s?ic(a,c):xt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+m.x,y:n.y*l.y-c.scrollTop*l.y+u.y+m.y}}function qm(e){return Array.from(e.getClientRects())}function Gm(e){const t=Pt(e),n=$r(e),r=e.ownerDocument.body,o=Qe(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Qe(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Br(e);const i=-n.scrollTop;return ft(r).direction==="rtl"&&(a+=Qe(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const ya=25;function zm(e,t){const n=st(e),r=Pt(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,c=0;if(o){s=o.width,a=o.height;const u=Go();(!u||u&&t==="fixed")&&(i=o.offsetLeft,c=o.offsetTop)}const l=Br(r);if(l<=0){const u=r.ownerDocument,d=u.body,m=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-d.clientWidth-h);g<=ya&&(s-=g)}else l<=ya&&(s+=l);return{width:s,height:a,x:i,y:c}}function Km(e,t){const n=rn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ge(e)?kn(e):xt(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,c=o*s.x,l=r*s.y;return{width:a,height:i,x:c,y:l}}function ba(e,t,n){let r;if(t==="viewport")r=zm(e,n);else if(t==="document")r=Gm(Pt(e));else if(Re(t))r=Km(t,n);else{const o=ac(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ar(r)}function cc(e,t){const n=Cn(e);return n===t||!Re(n)||Zt(n)?!1:ft(n).position==="fixed"||cc(n,t)}function Xm(e,t){const n=t.get(e);if(n)return n;let r=xn(e,[],!1).filter(i=>Re(i)&&tr(i)!=="body"),o=null;const s=ft(e).position==="fixed";let a=s?Cn(e):e;for(;Re(a)&&!Zt(a);){const i=ft(a),c=ui(a);!c&&i.position==="fixed"&&(o=null),(s?!c&&!o:!c&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||nr(a)&&!c&&cc(e,a))?r=r.filter(u=>u!==a):o=i,a=Cn(a)}return t.set(e,r),r}function Jm(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?zo(t)?[]:Xm(t,this._c):[].concat(n),r],i=ba(t,a[0],o);let c=i.top,l=i.right,u=i.bottom,d=i.left;for(let m=1;m<a.length;m++){const h=ba(t,a[m],o);c=Qe(h.top,c),l=Mn(h.right,l),u=Mn(h.bottom,u),d=Qe(h.left,d)}return{width:l-d,height:u-c,x:d,y:c}}function Qm(e){const{width:t,height:n}=sc(e);return{width:t,height:n}}function Zm(e,t,n){const r=Ge(t),o=Pt(t),s=n==="fixed",a=rn(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const c=xt(0);function l(){c.x=Br(o)}if(r||!r&&!s)if((tr(t)!=="body"||nr(o))&&(i=$r(t)),r){const h=rn(t,!0,s,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&l();s&&!r&&o&&l();const u=o&&!r&&!s?ic(o,i):xt(0),d=a.left+i.scrollLeft-c.x-u.x,m=a.top+i.scrollTop-c.y-u.y;return{x:d,y:m,width:a.width,height:a.height}}function ko(e){return ft(e).position==="static"}function xa(e,t){if(!Ge(e)||ft(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Pt(e)===n&&(n=n.ownerDocument.body),n}function lc(e,t){const n=st(e);if(zo(e))return n;if(!Ge(e)){let o=Cn(e);for(;o&&!Zt(o);){if(Re(o)&&!ko(o))return o;o=Cn(o)}return n}let r=xa(e,t);for(;r&&Yu(r)&&ko(r);)r=xa(r,t);return r&&Zt(r)&&ko(r)&&!ui(r)?n:r||Hu(e)||n}const eh=async function(e){const t=this.getOffsetParent||lc,n=this.getDimensions,r=await n(e.floating);return{reference:Zm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function th(e){return ft(e).direction==="rtl"}const nh={convertOffsetParentRelativeRectToViewportRelativeRect:Vm,getDocumentElement:Pt,getClippingRect:Jm,getOffsetParent:lc,getElementRects:eh,getClientRects:qm,getDimensions:Qm,getScale:kn,isElement:Re,isRTL:th};function uc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rh(e,t){let n=null,r;const o=Pt(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),s();const l=e.getBoundingClientRect(),{left:u,top:d,width:m,height:h}=l;if(i||t(),!m||!h)return;const g=wr(d),y=wr(o.clientWidth-(u+m)),x=wr(o.clientHeight-(d+h)),v=wr(u),w={rootMargin:-g+"px "+-y+"px "+-x+"px "+-v+"px",threshold:Qe(0,Mn(1,c))||1};let S=!0;function C(k){const T=k[0].intersectionRatio;if(T!==c){if(!S)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!uc(l,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),s}function wa(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=is(e),u=o||s?[...l?xn(l):[],...t?xn(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=l&&i?rh(l,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(v=>{let[b]=v;b&&b.target===l&&h&&t&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),l&&!c&&h.observe(l),t&&h.observe(t));let g,y=c?rn(e):null;c&&x();function x(){const v=rn(e);y&&!uc(y,v)&&n(),y=v,g=requestAnimationFrame(x)}return n(),()=>{var v;u.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),d?.(),(v=h)==null||v.disconnect(),h=null,c&&cancelAnimationFrame(g)}}const oh=Lm,sh=$m,ah=jm,ih=Ym,ch=Fm,lh=Bm,uh=(e,t,n)=>{const r=new Map,o={platform:nh,...n},s={...o.platform,_c:r};return Im(e,t,{...o,platform:s})};var dh=typeof document<"u",fh=function(){},Mr=dh?f.useLayoutEffect:fh;function Wr(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,o;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(!Wr(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Wr(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function dc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function va(e,t){const n=dc(e);return Math.round(t*n)/n}function So(e){const t=f.useRef(e);return Mr(()=>{t.current=e}),t}function mh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:c,open:l}=e,[u,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=f.useState(r);Wr(m,r)||h(r);const[g,y]=f.useState(null),[x,v]=f.useState(null),b=f.useCallback(O=>{O!==k.current&&(k.current=O,y(O))},[]),w=f.useCallback(O=>{O!==T.current&&(T.current=O,v(O))},[]),S=s||g,C=a||x,k=f.useRef(null),T=f.useRef(null),N=f.useRef(u),j=c!=null,M=So(c),R=So(o),_=So(l),E=f.useCallback(()=>{if(!k.current||!T.current)return;const O={placement:t,strategy:n,middleware:m};R.current&&(O.platform=R.current),uh(k.current,T.current,O).then(A=>{const U={...A,isPositioned:_.current!==!1};F.current&&!Wr(N.current,U)&&(N.current=U,Yt.flushSync(()=>{d(U)}))})},[m,t,n,R,_]);Mr(()=>{l===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(O=>({...O,isPositioned:!1})))},[l]);const F=f.useRef(!1);Mr(()=>(F.current=!0,()=>{F.current=!1}),[]),Mr(()=>{if(S&&(k.current=S),C&&(T.current=C),S&&C){if(M.current)return M.current(S,C,E);E()}},[S,C,E,M,j]);const P=f.useMemo(()=>({reference:k,floating:T,setReference:b,setFloating:w}),[b,w]),B=f.useMemo(()=>({reference:S,floating:C}),[S,C]),V=f.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const A=va(B.floating,u.x),U=va(B.floating,u.y);return i?{...O,transform:"translate("+A+"px, "+U+"px)",...dc(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:U}},[n,i,B.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:E,refs:P,elements:B,floatingStyles:V}),[u,E,P,B,V])}const hh=(e,t)=>{const n=oh(e);return{name:n.name,fn:n.fn,options:[e,t]}},gh=(e,t)=>{const n=sh(e);return{name:n.name,fn:n.fn,options:[e,t]}},ph=(e,t)=>({fn:lh(e).fn,options:[e,t]}),yh=(e,t)=>{const n=ah(e);return{name:n.name,fn:n.fn,options:[e,t]}},bh=(e,t)=>{const n=ih(e);return{name:n.name,fn:n.fn,options:[e,t]}},xh=(e,t)=>{const n=ch(e);return{name:n.name,fn:n.fn,options:[e,t]}},wh={intentional:"onClick",sloppy:"onPointerDown"};function vh(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function fc(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("referenceElement"),a=n.useState("domReferenceElement"),{onOpenChange:i,dataRef:c}=n.context,{enabled:l=!0,escapeKey:u=!0,outsidePress:d=!0,outsidePressEvent:m="sloppy",referencePress:h=!1,referencePressEvent:g="sloppy",ancestorScroll:y=!1,bubbles:x,externalTree:v}=t,b=In(v),w=me(typeof d=="function"?d:()=>!1),S=typeof d=="function"?w:d,C=f.useRef(!1),{escapeKey:k,outsidePress:T}=vh(x),N=f.useRef(null),j=nn(),M=nn(),R=me(()=>{M.clear(),c.current.insideReactTree=!1}),_=f.useRef(!1),E=f.useRef(""),F=me(D=>{E.current=D.pointerType}),P=me(()=>{const D=E.current,ae=D==="pen"||!D?"mouse":D,q=typeof m=="function"?m():m;return typeof q=="string"?q:q[ae]}),B=me(D=>{if(!r||!l||!u||D.key!=="Escape"||_.current)return;const ae=c.current.floatingContext?.nodeId,q=b?en(b.nodesRef.current,ae):[];if(!k&&q.length>0){let J=!0;if(q.forEach(ie=>{ie.context?.open&&!ie.context.dataRef.current.__escapeKeyBubbles&&(J=!1)}),!J)return}const ye=Lf(D)?D.nativeEvent:D,$=_e(Ji,ye);n.setOpen(!1,$),!k&&!$.isPropagationAllowed&&D.stopPropagation()}),V=me(D=>{const ae=P();return ae==="intentional"&&D.type!=="click"||ae==="sloppy"&&D.type==="click"}),O=me(()=>{c.current.insideReactTree=!0,M.start(0,R)}),A=me((D,ae=!1)=>{if(V(D)){R();return}if(c.current.insideReactTree){R();return}if(P()==="intentional"&&ae||typeof S=="function"&&!S(D))return;const q=Je(D),ye=`[${Xn("inert")}]`,$=Ye(n.select("floatingElement")).querySelectorAll(ye),J=n.context.triggerElements;if(q&&(J.hasElement(q)||J.hasMatchingElement(Q=>ve(Q,q))))return;let ie=Re(q)?q:null;for(;ie&&!Zt(ie);){const Q=Cn(ie);if(Zt(Q)||!Re(Q))break;ie=Q}if($.length&&Re(q)&&!Ff(q)&&!ve(q,n.select("floatingElement"))&&Array.from($).every(Q=>!ve(ie,Q)))return;if(Ge(q)&&!("touches"in D)){const Q=Zt(q),De=ft(q),ke=/auto|scroll/,je=Q||ke.test(De.overflowX),pe=Q||ke.test(De.overflowY),Ke=je&&q.clientWidth>0&&q.scrollWidth>q.clientWidth,Fe=pe&&q.clientHeight>0&&q.scrollHeight>q.clientHeight,Se=De.direction==="rtl",Ue=Fe&&(Se?D.offsetX<=q.offsetWidth-q.clientWidth:D.offsetX>q.clientWidth),He=Ke&&D.offsetY>q.clientHeight;if(Ue||He)return}const he=c.current.floatingContext?.nodeId,de=b&&en(b.nodesRef.current,he).some(Q=>ct(D,Q.context?.elements.floating));if(ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement"))||de)return;const se=b?en(b.nodesRef.current,he):[];if(se.length>0){let Q=!0;if(se.forEach(De=>{De.context?.open&&!De.context.dataRef.current.__outsidePressBubbles&&(Q=!1)}),!Q)return}n.setOpen(!1,_e(Xi,D)),R()}),U=me(D=>{P()!=="sloppy"||D.pointerType==="touch"||!n.select("open")||!l||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement"))||A(D)}),Y=me(D=>{if(P()!=="sloppy"||!n.select("open")||!l||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement")))return;const ae=D.touches[0];ae&&(N.current={startTime:Date.now(),startX:ae.clientX,startY:ae.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},j.start(1e3,()=>{N.current&&(N.current.dismissOnTouchEnd=!1,N.current.dismissOnMouseDown=!1)}))}),Z=me(D=>{const ae=Je(D);function q(){Y(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),H=me(D=>{const ae=C.current;if(C.current=!1,j.clear(),D.type==="mousedown"&&N.current&&!N.current.dismissOnMouseDown)return;const q=Je(D);function ye(){D.type==="pointerdown"?U(D):A(D,ae),q?.removeEventListener(D.type,ye)}q?.addEventListener(D.type,ye)}),W=me(D=>{if(P()!=="sloppy"||!N.current||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement")))return;const ae=D.touches[0];if(!ae)return;const q=Math.abs(ae.clientX-N.current.startX),ye=Math.abs(ae.clientY-N.current.startY),$=Math.sqrt(q*q+ye*ye);$>5&&(N.current.dismissOnTouchEnd=!0),$>10&&(A(D),j.clear(),N.current=null)}),z=me(D=>{const ae=Je(D);function q(){W(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),X=me(D=>{P()!=="sloppy"||!N.current||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement"))||(N.current.dismissOnTouchEnd&&A(D),j.clear(),N.current=null)}),oe=me(D=>{const ae=Je(D);function q(){X(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)});f.useEffect(()=>{if(!r||!l)return;c.current.__escapeKeyBubbles=k,c.current.__outsidePressBubbles=T;const D=new Ht;function ae(ie){n.setOpen(!1,_e(vm,ie))}function q(){D.clear(),_.current=!0}function ye(){D.start(Go()?5:0,()=>{_.current=!1})}const $=Ye(o);$.addEventListener("pointerdown",F,!0),u&&($.addEventListener("keydown",B),$.addEventListener("compositionstart",q),$.addEventListener("compositionend",ye)),S&&($.addEventListener("click",H,!0),$.addEventListener("pointerdown",H,!0),$.addEventListener("touchstart",Z,!0),$.addEventListener("touchmove",z,!0),$.addEventListener("touchend",oe,!0),$.addEventListener("mousedown",H,!0));let J=[];return y&&(Re(a)&&(J=xn(a)),Re(o)&&(J=J.concat(xn(o))),!Re(s)&&s&&s.contextElement&&(J=J.concat(xn(s.contextElement)))),J=J.filter(ie=>ie!==$.defaultView?.visualViewport),J.forEach(ie=>{ie.addEventListener("scroll",ae,{passive:!0})}),()=>{$.removeEventListener("pointerdown",F,!0),u&&($.removeEventListener("keydown",B),$.removeEventListener("compositionstart",q),$.removeEventListener("compositionend",ye)),S&&($.removeEventListener("click",H,!0),$.removeEventListener("pointerdown",H,!0),$.removeEventListener("touchstart",Z,!0),$.removeEventListener("touchmove",z,!0),$.removeEventListener("touchend",oe,!0),$.removeEventListener("mousedown",H,!0)),J.forEach(ie=>{ie.removeEventListener("scroll",ae)}),D.clear(),C.current=!1}},[c,o,s,a,u,S,r,i,y,l,k,T,B,A,H,U,Z,z,oe,F,n]),f.useEffect(R,[S,R]);const be=f.useMemo(()=>({onKeyDown:B,...h&&{[wh[g]]:D=>{n.setOpen(!1,_e(Bt,D.nativeEvent))},...g!=="intentional"&&{onClick(D){n.setOpen(!1,_e(Bt,D.nativeEvent))}}}}),[B,n,h,g]),Oe=me(D=>{const ae=Je(D.nativeEvent);!ve(n.select("floatingElement"),ae)||D.button!==0||(C.current=!0)}),xe=me(D=>{!r||!l||D.button!==0||(C.current=!0)}),Le=f.useMemo(()=>({onKeyDown:B,onPointerDown:Oe,onMouseDown:Oe,onMouseUp:Oe,onClickCapture:O,onMouseDownCapture(D){O(),xe(D)},onPointerDownCapture(D){O(),xe(D)},onMouseUpCapture:O,onTouchEndCapture:O,onTouchMoveCapture:O}),[B,Oe,O,xe]);return f.useMemo(()=>l?{reference:be,floating:Le,trigger:be}:{},[l,be,Le])}const kh={open:ge(e=>e.open),domReferenceElement:ge(e=>e.domReferenceElement),referenceElement:ge(e=>e.positionReference??e.referenceElement),floatingElement:ge(e=>e.floatingElement),floatingId:ge(e=>e.floatingId)};class cs extends Zo{constructor(t){const{nested:n,noEmit:r,onOpenChange:o,triggerElements:s,...a}=t;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:Gi(),nested:n,noEmit:r,triggerElements:s},kh)}setOpen=(t,n)=>{if((!t||!this.state.open||Ii(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 Sh(e,t=!1,n=!1){const[r,o]=f.useState(e&&t?"idle":void 0),[s,a]=f.useState(e);return e&&!s&&(a(!0),o("starting")),!e&&s&&r!=="ending"&&!n&&o("ending"),!e&&!s&&r==="ending"&&o(void 0),Ee(()=>{if(!e&&s&&r!=="ending"&&n){const i=ht.request(()=>{o("ending")});return()=>{ht.cancel(i)}}},[e,s,r,n]),Ee(()=>{if(!e||t)return;const i=ht.request(()=>{o(void 0)});return()=>{ht.cancel(i)}},[t,e]),Ee(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&o("starting");const i=ht.request(()=>{o("idle")});return()=>{ht.cancel(i)}},[t,e,s,o,r]),f.useMemo(()=>({mounted:s,setMounted:a,transitionStatus:r}),[s,r])}let Jn=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const Ch={[Jn.startingStyle]:""},Eh={[Jn.endingStyle]:""},Yr={transitionStatus(e){return e==="starting"?Ch:e==="ending"?Eh:null}};function mc(e,t=!1,n=!0){const r=ts();return me((o,s=null)=>{r.cancel();function a(){Yt.flushSync(o)}const i=Tt(e);if(i==null)return;const c=i;if(typeof c.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)o();else{let l=function(){const d=Jn.startingStyle;if(!c.hasAttribute(d)){r.request(u);return}const m=new MutationObserver(()=>{c.hasAttribute(d)||(m.disconnect(),u())});m.observe(c,{attributes:!0,attributeFilter:[d]}),s?.addEventListener("abort",()=>m.disconnect(),{once:!0})},u=function(){Promise.all(c.getAnimations().map(d=>d.finished)).then(()=>{s?.aborted||a()}).catch(()=>{const d=c.getAnimations();if(n){if(s?.aborted)return;a()}else d.length>0&&d.some(m=>m.pending||m.playState!=="finished")&&u()})};if(t){l();return}r.request(u)}})}function ls(e){const{enabled:t=!0,open:n,ref:r,onComplete:o}=e,s=me(o),a=mc(r,n,!1);f.useEffect(()=>{if(!t)return;const i=new AbortController;return a(s,i.signal),()=>{i.abort()}},[t,n,s,a])}function Mh(e,t){const n=f.useRef(null),r=f.useRef(null);return f.useCallback(o=>{if(e!==void 0){if(n.current!==null){const s=n.current,a=r.current,i=t.context.triggerElements.getById(s);a&&i===a&&t.context.triggerElements.delete(s),n.current=null,r.current=null}o!==null&&(n.current=e,r.current=o,t.context.triggerElements.add(e,o))}},[t,e])}function Th(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Mh(e,n),a=me(i=>{if(s(i),!i||!n.select("open"))return;const c=n.select("activeTriggerId");if(c===e){n.update({activeTriggerElement:i,...r});return}c==null&&n.update({activeTriggerId:e,activeTriggerElement:i,...r})});return Ee(()=>{o&&n.update({activeTriggerElement:t.current,...r})},[o,n,t,...Object.values(r)]),{registerTrigger:a,isMountedByThisTrigger:o}}function hc(e){const t=e.useState("open");Ee(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,o]=n.value;e.update({activeTriggerId:r,activeTriggerElement:o})}}},[t,e])}function gc(e,t,n){const{mounted:r,setMounted:o,transitionStatus:s}=Sh(e);t.useSyncedValues({mounted:r,transitionStatus:s});const a=me(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),i=t.useState("preventUnmountingOnClose");return ls({enabled:!i,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:s}}class Hr{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 Oh(){return new cs({open:!1,floatingElement:null,referenceElement:null,triggerElements:new Hr,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function pc(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Oh(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:$t,inactiveTriggerProps:$t,popupProps:$t}}const yc={open:ge(e=>e.open),mounted:ge(e=>e.mounted),transitionStatus:ge(e=>e.transitionStatus),floatingRootContext:ge(e=>e.floatingRootContext),preventUnmountingOnClose:ge(e=>e.preventUnmountingOnClose),payload:ge(e=>e.payload),activeTriggerId:ge(e=>e.activeTriggerId),activeTriggerElement:ge(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:ge((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:ge((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:ge(e=>e.popupProps),popupElement:ge(e=>e.popupElement),positionerElement:ge(e=>e.positionerElement)};function Nh(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,o=_n(),s=sn()!=null,a=Ut(()=>new cs({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new Hr,floatingId:o,nested:s,noEmit:e.noEmit||!1})).current;return Ee(()=>{const i={open:t,floatingId:o};r.reference!==void 0&&(i.referenceElement=r.reference,i.domReferenceElement=Re(r.reference)?r.reference:null),r.floating!==void 0&&(i.floatingElement=r.floating),a.update(i)},[t,o,r.reference,r.floating,a]),a.context.onOpenChange=n,a.context.nested=s,a.context.noEmit=e.noEmit||!1,a}function Rh(e={}){const{nodeId:t,externalTree:n}=e,r=Nh(e),o=e.rootContext||r,s={reference:o.useState("referenceElement"),floating:o.useState("floatingElement"),domReference:o.useState("domReferenceElement")},[a,i]=f.useState(null),c=f.useRef(null),l=In(n);Ee(()=>{s.domReference&&(c.current=s.domReference)},[s.domReference]);const u=mh({...e,elements:{...s,...a&&{reference:a}}}),d=f.useCallback(T=>{const N=Re(T)?{getBoundingClientRect:()=>T.getBoundingClientRect(),getClientRects:()=>T.getClientRects(),contextElement:T}:T;i(N),u.refs.setReference(N)},[u.refs]),[m,h]=f.useState(null),[g,y]=f.useState(null);o.useSyncedValue("referenceElement",m),o.useSyncedValue("domReferenceElement",Re(m)?m:null),o.useSyncedValue("floatingElement",g);const x=f.useCallback(T=>{(Re(T)||T===null)&&(c.current=T,h(T)),(Re(u.refs.reference.current)||u.refs.reference.current===null||T!==null&&!Re(T))&&u.refs.setReference(T)},[u.refs,h]),v=f.useCallback(T=>{y(T),u.refs.setFloating(T)},[u.refs]),b=f.useMemo(()=>({...u.refs,setReference:x,setFloating:v,setPositionReference:d,domReference:c}),[u.refs,x,v,d]),w=f.useMemo(()=>({...u.elements,domReference:s.domReference}),[u.elements,s.domReference]),S=o.useState("open"),C=o.useState("floatingId"),k=f.useMemo(()=>({...u,dataRef:o.context.dataRef,open:S,onOpenChange:o.setOpen,events:o.context.events,floatingId:C,refs:b,elements:w,nodeId:t,rootStore:o}),[u,b,w,t,o,S,C]);return Ee(()=>{o.context.dataRef.current.floatingContext=k;const T=l?.nodesRef.current.find(N=>N.id===t);T&&(T.context=k)}),f.useMemo(()=>({...u,context:k,refs:b,elements:w,rootStore:o}),[u,b,w,k,o])}function bc(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:o}=e,s=_n(),a=sn()!=null,i=t.useState("open"),c=t.useState("activeTriggerElement"),l=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=Ut(()=>new cs({open:i,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:o,floatingId:s,nested:a,noEmit:n})).current;return Ee(()=>{const m={open:i,floatingId:s,referenceElement:c,floatingElement:l};Re(c)&&(m.domReferenceElement=c),d.state.positionReference===d.state.referenceElement&&(m.positionReference=c),d.update(m)},[i,s,c,l,d]),d.context.onOpenChange=o,d.context.nested=a,d.context.noEmit=n,d}const Yo=Xn("safe-polygon"),Dh=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Ai}`;function Ph(e){return e?!!e.closest(Dh):!1}function xc(e){const t=f.useRef(void 0),n=f.useRef(!1),r=f.useRef(void 0),o=f.useRef(!0),s=f.useRef(!1),a=f.useRef(()=>{}),i=f.useRef(!1),c=nn(),l=nn(),u=f.useRef(void 0);return f.useMemo(()=>{const d=e.context.dataRef.current;return d.hoverInteractionState||(d.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:o,performedPointerEventsMutationRef:s,unbindMouseMoveRef:a,restTimeoutPendingRef:i,openChangeTimeout:c,restTimeout:l,handleCloseOptionsRef:u}),d.hoverInteractionState},[e,t,n,r,o,s,a,i,c,l,u])}const Ah=new Set(["click","mousedown"]);function _h(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("domReferenceElement"),{dataRef:a}=n.context,{enabled:i=!0,closeDelay:c=0,externalTree:l}=t,{pointerTypeRef:u,interactedInsideRef:d,handlerRef:m,performedPointerEventsMutationRef:h,unbindMouseMoveRef:g,restTimeoutPendingRef:y,openChangeTimeout:x,handleCloseOptionsRef:v}=xc(n),b=In(l),w=sn(),S=me(()=>d.current?!0:a.current.openEvent?Ah.has(a.current.openEvent.type):!1),C=me(()=>{const M=a.current.openEvent?.type;return M?.includes("mouse")&&M!=="mousedown"}),k=f.useCallback((M,R=!0)=>{const _=Ih(c,u.current);_&&!m.current?x.start(_,()=>n.setOpen(!1,_e(Ze,M))):R&&(x.clear(),n.setOpen(!1,_e(Ze,M)))},[c,m,n,u,x]),T=me(()=>{g.current(),m.current=void 0}),N=me(()=>{if(h.current){const M=Ye(o).body;M.style.pointerEvents="",M.removeAttribute(Yo),h.current=!1}}),j=me(M=>{const R=Je(M);if(!Ph(R)){d.current=!1;return}d.current=!0});Ee(()=>{r||(u.current=void 0,y.current=!1,d.current=!1,T(),N())},[r,u,y,d,T,N]),f.useEffect(()=>()=>{T()},[T]),f.useEffect(()=>N,[N]),Ee(()=>{if(i&&r&&v.current?.blockPointerEvents&&C()&&Re(s)&&o){h.current=!0;const M=Ye(o).body;M.setAttribute(Yo,"");const R=s,_=o,E=b?.nodesRef.current.find(F=>F.id===w)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),M.style.pointerEvents="none",R.style.pointerEvents="auto",_.style.pointerEvents="auto",()=>{M.style.pointerEvents="",R.style.pointerEvents="",_.style.pointerEvents=""}}},[i,r,s,o,v,C,b,w,h]),f.useEffect(()=>{if(!i)return;function M(F){if(S()||!a.current.floatingContext||!n.select("open"))return;const P=n.context.triggerElements;F.relatedTarget&&P.hasElement(F.relatedTarget)||(N(),T(),S()||k(F))}function R(F){x.clear(),N(),m.current?.(F),T()}function _(F){S()||k(F,!1)}const E=o;return E&&(E.addEventListener("mouseleave",M),E.addEventListener("mouseenter",R),E.addEventListener("mouseleave",_),E.addEventListener("pointerdown",j,!0)),()=>{E&&(E.removeEventListener("mouseleave",M),E.removeEventListener("mouseenter",R),E.removeEventListener("mouseleave",_),E.removeEventListener("pointerdown",j,!0))}})}function Ih(e,t){return t&&!En(t)?0:typeof e=="function"?e():e}function Co(e){return typeof e=="function"?e():e}const jh={current:null};function Fh(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:r,events:o}=n.context,{enabled:s=!0,delay:a=0,handleClose:i=null,mouseOnly:c=!1,restMs:l=0,move:u=!0,triggerElementRef:d=jh,externalTree:m,isActiveTrigger:h=!0}=t,g=In(m),{pointerTypeRef:y,interactedInsideRef:x,handlerRef:v,blockMouseMoveRef:b,performedPointerEventsMutationRef:w,unbindMouseMoveRef:S,restTimeoutPendingRef:C,openChangeTimeout:k,restTimeout:T,handleCloseOptionsRef:N}=xc(n),j=gt(i),M=gt(a),R=gt(l);h&&(N.current=j.current?.__options);const _=me(()=>x.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=f.useCallback((V,O=!0)=>{const A=bo(M.current,"close",y.current);A&&!v.current?k.start(A,()=>n.setOpen(!1,_e(Ze,V))):O&&(k.clear(),n.setOpen(!1,_e(Ze,V)))},[M,v,n,y,k]),F=me(()=>{S.current(),v.current=void 0}),P=me(()=>{if(w.current){const V=Ye(n.select("domReferenceElement")).body;V.style.pointerEvents="",V.removeAttribute(Yo),w.current=!1}});f.useEffect(()=>{if(!s)return;function V(O){O.open||(k.clear(),T.clear(),b.current=!0,C.current=!1)}return o.on("openchange",V),()=>{o.off("openchange",V)}},[s,o,k,T,b,C]);const B=me(V=>{if(_()||!r.current.floatingContext)return;const O=n.context.triggerElements;if(V.relatedTarget&&O.hasElement(V.relatedTarget))return;const A=d.current;j.current?.({...r.current.floatingContext,tree:g,x:V.clientX,y:V.clientY,onClose(){P(),F(),!_()&&A===n.select("domReferenceElement")&&E(V)}})(V)});return f.useEffect(()=>{if(!s)return;const V=d.current??(h?n.select("domReferenceElement"):null);if(!Re(V))return;function O(Y){if(k.clear(),b.current=!1,c&&!En(y.current)||Co(R.current)>0&&!bo(M.current,"open"))return;const Z=bo(M.current,"open",y.current),H=n.select("domReferenceElement"),W=n.context.triggerElements,z=(W.hasElement(Y.target)||W.hasMatchingElement(Oe=>ve(Oe,Y.target)))&&(!H||!ve(H,Y.target)),X=Y.currentTarget??null,oe=n.select("open"),be=!oe||z;z&&oe?n.setOpen(!0,_e(Ze,Y,X)):Z?k.start(Z,()=>{be&&n.setOpen(!0,_e(Ze,Y,X))}):be&&n.setOpen(!0,_e(Ze,Y,X))}function A(Y){if(_()){P();return}S.current();const Z=n.select("domReferenceElement"),H=Ye(Z);T.clear(),C.current=!1;const W=n.context.triggerElements;if(Y.relatedTarget&&W.hasElement(Y.relatedTarget))return;if(j.current&&r.current.floatingContext){n.select("open")||k.clear();const X=d.current;v.current=j.current({...r.current.floatingContext,tree:g,x:Y.clientX,y:Y.clientY,onClose(){P(),F(),!_()&&X===n.select("domReferenceElement")&&E(Y,!0)}});const oe=v.current;oe(Y),H.addEventListener("mousemove",oe),S.current=()=>{H.removeEventListener("mousemove",oe)};return}(y.current!=="touch"||!ve(n.select("floatingElement"),Y.relatedTarget))&&E(Y)}function U(Y){B(Y)}return n.select("open")&&V.addEventListener("mouseleave",U),u&&V.addEventListener("mousemove",O,{once:!0}),V.addEventListener("mouseenter",O),V.addEventListener("mouseleave",A),()=>{V.removeEventListener("mouseleave",U),u&&V.removeEventListener("mousemove",O),V.removeEventListener("mouseenter",O),V.removeEventListener("mouseleave",A)}},[F,P,b,r,M,E,n,s,j,B,h,_,c,u,y,R,T,C,k,d,g,S,v]),f.useMemo(()=>{function V(O){y.current=O.pointerType}return{onPointerDown:V,onPointerEnter:V,onMouseMove(O){const{nativeEvent:A}=O,U=O.currentTarget,Y=n.select("domReferenceElement"),Z=n.context.triggerElements,H=n.select("open"),W=(Z.hasElement(O.target)||Z.hasMatchingElement(X=>ve(X,O.target)))&&(!Y||!ve(Y,O.target));if(c&&!En(y.current)||H&&!W||Co(R.current)===0||!W&&C.current&&O.movementX**2+O.movementY**2<2)return;T.clear();function z(){if(C.current=!1,_())return;const X=n.select("open");!b.current&&(!X||W)&&n.setOpen(!0,_e(Ze,A,U))}y.current==="touch"?Yt.flushSync(()=>{z()}):W&&H?z():(C.current=!0,T.start(Co(R.current),z))}}},[b,_,c,n,y,R,T,C])}function us(e=[]){const t=e.map(l=>l?.reference),n=e.map(l=>l?.floating),r=e.map(l=>l?.item),o=e.map(l=>l?.trigger),s=f.useCallback(l=>Sr(l,e,"reference"),t),a=f.useCallback(l=>Sr(l,e,"floating"),n),i=f.useCallback(l=>Sr(l,e,"item"),r),c=f.useCallback(l=>Sr(l,e,"trigger"),o);return f.useMemo(()=>({getReferenceProps:s,getFloatingProps:a,getItemProps:i,getTriggerProps:c}),[s,a,i,c])}function Sr(e,t,n){const r=new Map,o=n==="item",s={};n==="floating"&&(s.tabIndex=-1,s[jo]="");for(const a in e)o&&e&&(a===Di||a===Pi)||(s[a]=e[a]);for(let a=0;a<t.length;a+=1){let i;const c=t[a]?.[n];typeof c=="function"?i=e?c(e):null:i=c,i&&ka(s,i,o,r)}return ka(s,e,o,r),s}function ka(e,t,n,r){for(const o in t){const s=t[o];n&&(o===Di||o===Pi)||(o.startsWith("on")?(r.has(o)||r.set(o,[]),typeof s=="function"&&(r.get(o)?.push(s),e[o]=(...a)=>r.get(o)?.map(i=>i(...a)).find(i=>i!==void 0))):e[o]=s)}}const Wh=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function wc(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingId"),s=n.useState("domReferenceElement"),a=n.useState("floatingElement"),{enabled:i=!0,role:c="dialog"}=t,l=_n(),u=s?.id||l,d=f.useMemo(()=>Fo(a)?.id||o,[a,o]),m=Wh.get(c)??c,g=sn()!=null,y=f.useMemo(()=>m==="tooltip"||c==="label"?$t:{"aria-haspopup":m==="alertdialog"?"dialog":m,"aria-expanded":"false",...m==="listbox"&&{role:"combobox"},...m==="menu"&&g&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[m,g,c]),x=f.useMemo(()=>m==="tooltip"||c==="label"?{[`aria-${c==="label"?"labelledby":"describedby"}`]:r?d:void 0}:{...y,"aria-expanded":r?"true":"false","aria-controls":r?d:void 0,...m==="menu"&&{id:u}},[m,d,r,u,c,y]),v=f.useMemo(()=>{const w={id:d,...m&&{role:m}};return m==="tooltip"||c==="label"?w:{...w,...m==="menu"&&{"aria-labelledby":u}}},[m,d,u,c]),b=f.useCallback(({active:w,selected:S})=>{const C={role:"option",...w&&{id:`${d}-fui-option`}};switch(c){case"select":case"combobox":return{...C,"aria-selected":S}}return{}},[d,c]);return f.useMemo(()=>i?{reference:x,floating:v,item:b,trigger:y}:{},[i,x,v,y,b])}function Sa(e,t){const[n,r]=e;let o=!1;const s=t.length;for(let a=0,i=s-1;a<s;i=a++){const[c,l]=t[a]||[0,0],[u,d]=t[i]||[0,0];l>=r!=d>=r&&n<=(u-c)*(r-l)/(d-l)+c&&(o=!o)}return o}function Lh(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function $h(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,o=new Ht;let s=!1,a=null,i=null,c=typeof performance<"u"?performance.now():0;function l(d,m){const h=performance.now(),g=h-c;if(a===null||i===null||g===0)return a=d,i=m,c=h,null;const y=d-a,x=m-i,b=Math.sqrt(y*y+x*x)/g;return a=d,i=m,c=h,b}const u=({x:d,y:m,placement:h,elements:g,onClose:y,nodeId:x,tree:v})=>function(w){function S(){o.clear(),y()}if(o.clear(),!g.domReference||!g.floating||h==null||d==null||m==null)return;const{clientX:C,clientY:k}=w,T=[C,k],N=Je(w),j=w.type==="mouseleave",M=ve(g.floating,N),R=ve(g.domReference,N),_=g.domReference.getBoundingClientRect(),E=g.floating.getBoundingClientRect(),F=h.split("-")[0],P=d>E.right-E.width/2,B=m>E.bottom-E.height/2,V=Lh(T,_),O=E.width>_.width,A=E.height>_.height,U=(O?_:E).left,Y=(O?_:E).right,Z=(A?_:E).top,H=(A?_:E).bottom;if(M&&(s=!0,!j))return;if(R&&(s=!1),R&&!j){s=!0;return}if(j&&Re(w.relatedTarget)&&ve(g.floating,w.relatedTarget)||v&&en(v.nodesRef.current,x).some(({context:X})=>X?.open))return;if(F==="top"&&m>=_.bottom-1||F==="bottom"&&m<=_.top+1||F==="left"&&d>=_.right-1||F==="right"&&d<=_.left+1)return S();let W=[];switch(F){case"top":W=[[U,_.top+1],[U,E.bottom-1],[Y,E.bottom-1],[Y,_.top+1]];break;case"bottom":W=[[U,E.top+1],[U,_.bottom-1],[Y,_.bottom-1],[Y,E.top+1]];break;case"left":W=[[E.right-1,H],[E.right-1,Z],[_.left+1,Z],[_.left+1,H]];break;case"right":W=[[_.right-1,H],[_.right-1,Z],[E.left+1,Z],[E.left+1,H]];break}function z([X,oe]){switch(F){case"top":{const be=[O?X+t/2:P?X+t*4:X-t*4,oe+t+1],Oe=[O?X-t/2:P?X+t*4:X-t*4,oe+t+1],xe=[[E.left,P||O?E.bottom-t:E.top],[E.right,P?O?E.bottom-t:E.top:E.bottom-t]];return[be,Oe,...xe]}case"bottom":{const be=[O?X+t/2:P?X+t*4:X-t*4,oe-t],Oe=[O?X-t/2:P?X+t*4:X-t*4,oe-t],xe=[[E.left,P||O?E.top+t:E.bottom],[E.right,P?O?E.top+t:E.bottom:E.top+t]];return[be,Oe,...xe]}case"left":{const be=[X+t+1,A?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X+t+1,A?oe-t/2:B?oe+t*4:oe-t*4];return[...[[B||A?E.right-t:E.left,E.top],[B?A?E.right-t:E.left:E.right-t,E.bottom]],be,Oe]}case"right":{const be=[X-t,A?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X-t,A?oe-t/2:B?oe+t*4:oe-t*4],xe=[[B||A?E.left+t:E.right,E.top],[B?A?E.left+t:E.right:E.left+t,E.bottom]];return[be,Oe,...xe]}default:return[]}}if(!Sa([C,k],W)){if(s&&!V)return S();if(!j&&r){const X=l(w.clientX,w.clientY);if(X!==null&&X<.1)return S()}Sa([C,k],z([d,m]))?!s&&r&&o.start(40,S):S()}};return u.__options={blockPointerEvents:n},u}function vc(e){return _n(e,"base-ui")}function Bh(e){const t=f.useRef(""),n=f.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:f.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o&&e(o,o.pointerType),e(o,t.current),t.current=""},[e]),onPointerDown:n}}function kc(e){const[t,n]=f.useState(null),r=me((i,c)=>{e||n(c||(Ri?"touch":""))}),o=f.useCallback(()=>{n(null)},[]),{onClick:s,onPointerDown:a}=Bh(r);return f.useMemo(()=>({openMethod:t,reset:o,triggerProps:{onClick:s,onPointerDown:a}}),[t,o,s,a])}let ut=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Jn.startingStyle]="startingStyle",e[e.endingStyle=Jn.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),Ho=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Yh={[Ho.popupOpen]:""},Hh={[Ho.popupOpen]:"",[Ho.pressed]:""},Uh={[ut.open]:""},Vh={[ut.closed]:""},qh={[ut.anchorHidden]:""},Gh={open(e){return e?Yh:null}},zh={open(e){return e?Hh:null}},or={open(e){return e?Uh:Vh},anchorHidden(e){return e?qh:null}};function Sc(e){return ci(19)?e:e?"true":void 0}let Ca={},Ea={},Ma="";function Kh(e){if(typeof document>"u")return!1;const t=an(e);return st(t).innerWidth-t.documentElement.clientWidth>0}function Xh(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=an(e).documentElement,o={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY};r.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return Object.assign(r.style,o),s===a}function Jh(e){const t=an(e),n=t.documentElement,r=t.body,o=nr(n)?n:r,s=o.style.overflow;return o.style.overflow="hidden",()=>{o.style.overflow=s}}function Qh(e){const t=an(e),n=t.documentElement,r=t.body,o=st(n);let s=0,a=0,i=!1;const c=ht.create();if(Df&&(o.visualViewport?.scale??1)!==1)return()=>{};function l(){const m=o.getComputedStyle(n),h=o.getComputedStyle(r),x=(m.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=n.scrollTop,a=n.scrollLeft,Ca={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ma=n.style.scrollBehavior,Ea={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 v=n.scrollHeight>n.clientHeight,b=n.scrollWidth>n.clientWidth,w=m.overflowY==="scroll"||h.overflowY==="scroll",S=m.overflowX==="scroll"||h.overflowX==="scroll",C=Math.max(0,o.innerWidth-r.clientWidth),k=Math.max(0,o.innerHeight-r.clientHeight),T=parseFloat(h.marginTop)+parseFloat(h.marginBottom),N=parseFloat(h.marginLeft)+parseFloat(h.marginRight),j=nr(n)?n:r;if(i=Xh(e),i){n.style.scrollbarGutter=x,j.style.overflowY="hidden",j.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:x,overflowY:"hidden",overflowX:"hidden"}),(v||w)&&(n.style.overflowY="scroll"),(b||S)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||k?`calc(100dvh - ${T+k}px)`:"100dvh",width:N||C?`calc(100vw - ${N+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=s,r.scrollLeft=a,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,Ca),Object.assign(r.style,Ea),i||(n.scrollTop=s,n.scrollLeft=a,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Ma)}function d(){u(),c.request(l)}return l(),o.addEventListener("resize",d),()=>{c.cancel(),u(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",d)}}class Zh{lockCount=0;restore=null;timeoutLock=Ht.create();timeoutUnlock=Ht.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=an(t).documentElement,o=st(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=li;return}const s=Ri||!Kh(t);this.restore=s?Jh(t):Qh(t)}}const eg=new Zh;function Cc(e=!0,t=null){Ee(()=>{if(e)return eg.acquire(t)},[e,t])}const tg=f.createContext(void 0);function ng(){return f.useContext(tg)?.direction??"ltr"}const rg=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d="real"}=Rt(e,t)||{};if(l==null)return{};const m=ji(u),h={x:n,y:r},g=os(o),y=rs(g),x=await a.getDimensions(l),v=g==="y",b=v?"top":"left",w=v?"bottom":"right",S=v?"clientHeight":"clientWidth",C=s.reference[y]+s.reference[g]-h[g]-s.floating[y],k=h[g]-s.reference[g],T=d==="real"?await a.getOffsetParent?.(l):i.floating;let N=i.floating[S]||s.floating[y];(!N||!await a.isElement?.(T))&&(N=i.floating[S]||s.floating[y]);const j=C/2-k/2,M=N/2-x[y]/2-1,R=Math.min(m[b],M),_=Math.min(m[w],M),E=R,F=N-x[y]-_,P=N/2-x[y]/2+j,B=Wo(E,P,F),V=!c.arrow&&Vt(o)!=null&&P!==B&&s.reference[y]/2-(P<E?R:_)-x[y]/2<0,O=V?P<E?P-E:P-F:0;return{[g]:h[g]+O,data:{[g]:B,centerOffset:P-B-O,...V&&{alignmentOffset:O}},reset:V}}}),og=(e,t)=>({...rg(e),options:[e,t]}),sg={name:"hide",async fn(e){const{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0;return{data:{referenceHidden:(await xh().fn(e)).data?.referenceHidden||s}}}},Tr={sideX:"left",sideY:"top"},ag={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:o},platform:s,strategy:a,placement:i}=e,c=st(o),l=c.getComputedStyle(o);if(!(l.transitionDuration!=="0s"&&l.transitionDuration!==""))return{x:t,y:n,data:Tr};const d=await s.getOffsetParent?.(o);let m={width:0,height:0};if(a==="fixed"&&c?.visualViewport)m={width:c.visualViewport.width,height:c.visualViewport.height};else if(d===c){const b=an(o);m={width:b.documentElement.clientWidth,height:b.documentElement.clientHeight}}else await s.isElement?.(d)&&(m=await s.getDimensions(d));const h=ze(i);let g=t,y=n;h==="left"&&(g=m.width-(t+r.width)),h==="top"&&(y=m.height-(n+r.height));const x=h==="left"?"right":Tr.sideX,v=h==="top"?"bottom":Tr.sideY;return{x:g,y,data:{sideX:x,sideY:v}}}};function Ec(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 Ta(e,t,n){const{rects:r,placement:o}=e;return{side:Ec(t,ze(o),n),align:Vt(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function ig(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,collisionBoundary:i,collisionPadding:c=5,sticky:l=!1,arrowPadding:u=5,disableAnchorTracking:d=!1,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:y,shiftCrossAxis:x=!1,nodeId:v,adaptiveOrigin:b,lazyFlip:w=!1,externalTree:S}=e,[C,k]=f.useState(null);!g&&C!==null&&k(null);const T=y.side||"flip",N=y.align||"flip",j=y.fallbackAxisSide||"end",M=typeof t=="function"?t:void 0,R=me(M),_=M?R:t,E=gt(t),P=ng()==="rtl",B=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":P?"left":"right","inline-start":P?"right":"left"}[r],V=s==="center"?B:`${B}-${s}`;let O=c;const A=1,U=r==="bottom"?A:0,Y=r==="top"?A:0,Z=r==="right"?A:0,H=r==="left"?A:0;typeof O=="number"?O={top:O+U,right:O+H,bottom:O+Y,left:O+Z}:O&&(O={top:(O.top||0)+U,right:(O.right||0)+H,bottom:(O.bottom||0)+Y,left:(O.left||0)+Z});const W={boundary:i==="clipping-ancestors"?"clippingAncestors":i,padding:O},z=f.useRef(null),X=gt(o),oe=gt(a),xe=[hh(Ce=>{const Te=Ta(Ce,r,P),K=typeof X.current=="function"?X.current(Te):X.current,ce=typeof oe.current=="function"?oe.current(Te):oe.current;return{mainAxis:K,crossAxis:ce,alignmentAxis:ce}},[typeof o!="function"?o:0,typeof a!="function"?a:0,P,r])],Le=N==="none"&&T!=="shift",D=!Le&&(l||x||T==="shift"),ae=T==="none"?null:yh({...W,padding:{top:O.top+A,right:O.right+A,bottom:O.bottom+A,left:O.left+A},mainAxis:!x&&T==="flip",crossAxis:N==="flip"?"alignment":!1,fallbackAxisSideDirection:j}),q=Le?null:gh(Ce=>{const Te=an(Ce.elements.floating).documentElement;return{...W,rootBoundary:x?{x:0,y:0,width:Te.clientWidth,height:Te.clientHeight}:void 0,mainAxis:N!=="none",crossAxis:D,limiter:l||x?void 0:ph(K=>{if(!z.current)return{};const{width:ce,height:te}=z.current.getBoundingClientRect(),fe=ot(ze(K.placement)),Pe=fe==="y"?ce:te,ue=fe==="y"?O.left+O.right:O.top+O.bottom;return{offset:Pe/2+ue/2}})}},[W,l,x,O,N]);T==="shift"||N==="shift"||s==="center"?xe.push(q,ae):xe.push(ae,q),xe.push(bh({...W,apply({elements:{floating:Ce},rects:{reference:Te},availableWidth:K,availableHeight:ce}){Object.entries({"--available-width":`${K}px`,"--available-height":`${ce}px`,"--anchor-width":`${Te.width}px`,"--anchor-height":`${Te.height}px`}).forEach(([te,fe])=>{Ce.style.setProperty(te,fe)})}}),og(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Ce){const{elements:Te,middlewareData:K,placement:ce,rects:te,y:fe}=Ce,Pe=ze(ce),ue=ot(Pe),vt=z.current,Ft=K.arrow?.x||0,kt=K.arrow?.y||0,qe=vt?.clientWidth||0,qt=vt?.clientHeight||0,ln=Ft+qe/2,Fn=kt+qt/2,qr=Math.abs(K.shift?.y||0),Gr=te.reference.height/2,Gt=typeof o=="function"?o(Ta(Ce,r,P)):o,lr=qr>Gt,ur={top:`${ln}px calc(100% + ${Gt}px)`,bottom:`${ln}px ${-Gt}px`,left:`calc(100% + ${Gt}px) ${Fn}px`,right:`${-Gt}px ${Fn}px`}[Pe],un=`${ln}px ${te.reference.y+Gr-fe}px`;return Te.floating.style.setProperty("--transform-origin",D&&ue==="y"&&lr?un:ur),{}}},sg,b),Ee(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[g,h]);const ye=f.useMemo(()=>({elementResize:!d&&typeof ResizeObserver<"u",layoutShift:!d&&typeof IntersectionObserver<"u"}),[d]),{refs:$,elements:J,x:ie,y:he,middlewareData:de,update:se,placement:Q,context:De,isPositioned:ke,floatingStyles:je}=Rh({rootContext:h,placement:V,middleware:xe,strategy:n,whileElementsMounted:m?void 0:(...Ce)=>wa(...Ce,ye),nodeId:v,externalTree:S}),{sideX:pe,sideY:Ke}=de.adaptiveOrigin||Tr,Fe=ke?n:"fixed",Se=f.useMemo(()=>b?{position:Fe,[pe]:ie,[Ke]:he}:{position:Fe,...je},[b,Fe,pe,ie,Ke,he,je]),Ue=f.useRef(null);Ee(()=>{if(!g)return;const Ce=E.current,Te=typeof Ce=="function"?Ce():Ce,ce=(Oa(Te)?Te.current:Te)||null||null;ce!==Ue.current&&($.setPositionReference(ce),Ue.current=ce)},[g,$,_,E]),f.useEffect(()=>{if(!g)return;const Ce=E.current;typeof Ce!="function"&&Oa(Ce)&&Ce.current!==Ue.current&&($.setPositionReference(Ce.current),Ue.current=Ce.current)},[g,$,_,E]),f.useEffect(()=>{if(m&&g&&J.domReference&&J.floating)return wa(J.domReference,J.floating,se,ye)},[m,g,J,se,ye]);const He=ze(Q),At=Ec(r,He,P),_t=Vt(Q)||"center",It=!!de.hide?.referenceHidden;Ee(()=>{w&&g&&ke&&k(He)},[w,g,ke,He]);const jt=f.useMemo(()=>({position:"absolute",top:de.arrow?.y,left:de.arrow?.x}),[de.arrow]),nt=de.arrow?.centerOffset!==0;return f.useMemo(()=>({positionerStyles:Se,arrowStyles:jt,arrowRef:z,arrowUncentered:nt,side:At,align:_t,physicalSide:He,anchorHidden:It,refs:$,context:De,isPositioned:ke,update:se}),[Se,jt,z,nt,At,_t,He,It,$,De,ke,se])}function Oa(e){return e!=null&&"current"in e}const Mc=f.forwardRef(function(t,n){const{cutout:r,...o}=t;let s;if(r){const a=r?.getBoundingClientRect();s=`polygon(
|
|
1
|
+
import{i as Tu,f as ni,a as ri,J as Ou,u as oi,m as Nu,r as f,M as si,b as Ru,c as Du,d as no,e as Pu,g as Au,h as Rn,j as Dn,k as tn,l as _u,n as _o,o as pr,p as Vo,q as Lr,s as Iu,t as ju,v as Fu,w as qo,x as Sn,y as ro,z as Wu,A as et,B as L,C as ai,D as p,E as Ut,F as Ee,G as on,H as ii,I as ci,K as me,N as li,L as Lu,O as Ge,R as $u,P as $t,Q as tr,S as Yt,T as Bu,U as Dt,V as Bs,W as st,X as ft,Y as xn,Z as Re,_ as Pt,$ as Ys,a0 as Go,a1 as zo,a2 as Cn,a3 as Zt,a4 as Yu,a5 as ui,a6 as Hu,a7 as nr,a8 as $r,a9 as di,aa as Ko,ab as bt,ac as fi,ad as G,ae as Xo,af as mi,ag as Uu,ah as Vu,ai as qu,aj as hi,ak as Gu,al as zu,am as Ku,an as Xu,ao as Ju,ap as Qu,aq as Zu,ar as ed,as as td,at as nd,au as Mt,av as rd,aw as od,ax as Hs}from"./main-DQ3-Wn2t.js";import{u as sd}from"./use-usage-limits-DiPkCZg-.js";import{C as Jo}from"./Card-CDFJQidU.js";import{F as Gn}from"./FadeIn-Dt-Uvlsi.js";const ad=500,id={style:{transition:"none"}},gi="data-base-ui-click-trigger",cd={fallbackAxisSide:"end"},ld={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function ud(...e){const t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],o=e[1+n],s=e[2+n],a=e[3+n],i=Tu(o,s,a);return t?i(r):i}function dd(e,t,n={}){const r=e.get();let o=null,s=r,a;const i=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,c=()=>{o&&(o.stop(),o=null),e.animation=void 0},l=()=>{const d=Us(e.get()),m=Us(s);if(d===m){c();return}const h=o?o.getGeneratorVelocity():e.getVelocity();c(),o=new Ou({keyframes:[d,m],velocity:h,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:a})},u=()=>{l(),e.animation=o??void 0,e.events.animationStart?.notify(),o?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((d,m)=>{s=d,a=h=>m(oo(h,i)),ni.postRender(u)},c),ri(t)){let d=n.skipInitialAnimation===!0;const m=t.on("change",g=>{d?(d=!1,e.jump(oo(g,i),!1)):e.set(oo(g,i))}),h=e.on("destroy",m);return()=>{m(),h()}}return c}function oo(e,t){return t?e+t:e}function Us(e){return typeof e=="number"?e:parseFloat(e)}function Qo(e){const t=oi(()=>Nu(e)),{isStatic:n}=f.useContext(si);if(n){const[,r]=f.useState(e);f.useEffect(()=>t.on("change",r),[])}return t}function pi(e,t){const n=Qo(t()),r=()=>n.set(t());return r(),Ru(()=>{const o=()=>ni.preRender(r,!1,!0),s=e.map(a=>a.on("change",o));return()=>{s.forEach(a=>a()),Du(r)}}),n}function fd(e){no.current=[],e();const t=pi(no.current,e);return no.current=void 0,t}function yi(e,t,n,r){if(typeof e=="function")return fd(e);const s=typeof t=="function"?t:ud(t,n,r),a=Array.isArray(e)?Vs(e,s):Vs([e],([c])=>s(c)),i=Array.isArray(e)?void 0:e.accelerate;return i&&!i.isTransformed&&typeof t!="function"&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...i,times:t,keyframes:n,isTransformed:!0}),a}function Vs(e,t){const n=oi(()=>[]);return pi(e,()=>{n.length=0;const r=e.length;for(let o=0;o<r;o++)n[o]=e[o].get();return t(n)})}function md(e,t={}){const{isStatic:n}=f.useContext(si),r=()=>ri(e)?e.get():e;if(n)return yi(r);const o=Qo(r());return f.useInsertionEffect(()=>dd(o,e,t),[o,JSON.stringify(t)]),o}function hd(e,t={}){return md(e,{type:"spring",...t})}const gd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],pd=Pu("info",gd);function yd({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:o="sun",cacheKey:s,timeZone:a,tzOffsetMinutes:i,now:c}={}){const l=f.useMemo(()=>Au({weeks:r,weekStartsOn:o,now:c}),[c,r,o]),[u,d]=f.useState([]),[m,h]=f.useState(null),[g,y]=f.useState("edge"),[x,v]=f.useState(!1),[b,w]=f.useState(null),S=Rn(),C=Dn(t),k=!n,T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=f.useMemo(()=>{if(!s)return null;const F=Lr({timeZone:a,offsetMinutes:i});return`tokentracker.heatmap.${s}.${r}.${o}.${F}`},[s,a,i,r,o]),j=f.useCallback(()=>{if(!N||typeof window>"u")return null;try{const F=window.localStorage.getItem(N);if(!F)return null;const P=JSON.parse(F);return!P||!P.heatmap?null:P}catch{return null}},[N]),M=f.useCallback(F=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(F))}catch{}},[N]),R=f.useCallback(()=>{if(!(!N||typeof window>"u"))try{window.localStorage.removeItem(N)}catch{}},[N]),_=f.useCallback(async()=>{const F=await tn(t);if(!(!F&&!S&&!T)){v(!0),w(null);try{try{const O=await _u({baseUrl:e,accessToken:F,weeks:r,to:l.to,weekStartsOn:o,timeZone:a,tzOffsetMinutes:i}),A=Array.isArray(O?.weeks)?O.weeks:[];if(!A.length&&k){const Y=j();if(Y?.heatmap){h(Y.heatmap),d(Y.daily||[]),y("cache");return}}if(!A.some(Y=>(Array.isArray(Y)?Y:[]).some(Z=>Z&&Number.isFinite(Number(Z.level))))&&A.length){const Y=[];for(const H of A)for(const W of Array.isArray(H)?H:[])W?.day&&Y.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});const Z=_o({dailyRows:Y,weeks:r,to:O?.to||l.to,weekStartsOn:o});d(Y),h({...Z,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:pr({dailyRows:Y,to:O?.to||l.to})}),y("client"),k?M({heatmap:{...Z,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:pr({dailyRows:Y,to:O?.to||l.to})},daily:Y,fetchedAt:new Date().toISOString()}):R();return}h(O||null),d([]),y("edge"),O&&k?M({heatmap:O,daily:[],fetchedAt:new Date().toISOString()}):k||R();return}catch(O){const A=O,U=A?.status??A?.statusCode;if(U===401||U===403)throw O}const P=await Vo({baseUrl:e,accessToken:F,from:l.from,to:l.to,timeZone:a,tzOffsetMinutes:i}),B=Array.isArray(P?.data)?P.data:[];d(B);const V=_o({dailyRows:B,weeks:r,to:l.to,weekStartsOn:o});h({...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:pr({dailyRows:B,to:l.to})}),y("client"),k?M({heatmap:{...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:pr({dailyRows:B,to:l.to})},daily:B,fetchedAt:new Date().toISOString()}):R()}catch(P){if(k){const B=j();if(B?.heatmap)h(B.heatmap),d(B.daily||[]),y("cache"),w(null);else{const V=P;w(V?.message||String(V)),d([]),h(null),y("edge")}}else{const B=P;w(B?.message||String(B)),d([]),h(null),y("edge")}}finally{v(!1)}}},[t,e,S,n,k,l.from,l.to,j,C,a,i,o,r,R,M,T]);return f.useEffect(()=>{if(!C&&!n&&!S&&!T){d([]),v(!1),w(null),h(null),y("edge");return}if(!k)R(),d([]),w(null),h(null),y("edge");else{const F=j();F?.heatmap&&(h(F.heatmap),d(F.daily||[]),y("cache"))}_()},[t,S,j,_,C,n,k,R,T]),{range:l,daily:u,heatmap:m,source:S?"mock":g==="client"?"edge":g,loading:x,error:b,refresh:_}}function bd({baseUrl:e,accessToken:t,limit:n=3,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i}={}){const[c,l]=f.useState([]),[u,d]=f.useState(!1),[m,h]=f.useState(null),g=Rn(),y=Dn(t),x=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=f.useCallback(async()=>{const b=await tn(t);if(!b&&!g&&!x){l([]),h(null),d(!1);return}d(!0),h(null);try{const w=await Iu({baseUrl:e,accessToken:b,limit:n,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i});l(Array.isArray(w?.entries)?w.entries:[])}catch(w){const S=w?.message||String(w);h(S),l([])}finally{d(!1)}},[t,e,r,n,g,s,a,o,i,x]);return f.useEffect(()=>{if(!y&&!g&&!x){l([]),h(null),d(!1);return}v()},[g,v,y,x]),{entries:c,loading:u,error:m,refresh:v}}const xd=24;function wd({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:o,to:s,months:a=xd,cacheKey:i,timeZone:c,tzOffsetMinutes:l,now:u,sharedRows:d,sharedRange:m}={}){const[h,g]=f.useState([]),[y,x]=f.useState(()=>({from:o,to:s})),[v,b]=f.useState("edge"),[w,S]=f.useState(null),[C,k]=f.useState(!1),[T,N]=f.useState(null),j=Rn(),M=Dn(t),R=!n,_=Array.isArray(d),E=m?.from||o,F=m?.to||s,P=f.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),B=(()=>{if(!i)return null;const H=vd(e)||"default",W=Lr({timeZone:c,offsetMinutes:l});if(P==="hourly")return`tokentracker.trend.${i}.${H}.hourly.${s||o||"day"}.${W}`;if(P==="monthly")return`tokentracker.trend.${i}.${H}.monthly.${a}.${s||"today"}.${W}`;const z=`${o||""}.${s||""}`;return`tokentracker.trend.${i}.${H}.daily.${z}.${W}`})(),V=f.useCallback(()=>{if(!B||typeof window>"u")return null;try{const H=window.localStorage.getItem(B);if(!H)return null;const W=JSON.parse(H);return!W||!Array.isArray(W.rows)?null:W}catch{return null}},[B]),O=f.useCallback(H=>{if(!(!B||typeof window>"u"))try{window.localStorage.setItem(B,JSON.stringify(H))}catch{}},[B]),A=f.useCallback(()=>{if(!(!B||typeof window>"u"))try{window.localStorage.removeItem(B)}catch{}},[B]),U=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Y=f.useCallback(async()=>{if(_){g(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}const H=await tn(t);if(!(!H&&!j&&!U)){k(!0),N(null);try{let W;P==="hourly"?W=await ju({baseUrl:e,accessToken:H,day:s||o,timeZone:c,tzOffsetMinutes:l}):P==="monthly"?W=await Fu({baseUrl:e,accessToken:H,months:a,to:s,timeZone:c,tzOffsetMinutes:l}):W=await Vo({baseUrl:e,accessToken:H,from:o,to:s,timeZone:c,tzOffsetMinutes:l});const z=W?.from||o||W?.day||null,X=W?.to||s||W?.day||null;let oe=Array.isArray(W?.data)?W.data:[];P==="daily"?oe=ao(oe,z||o,X||s,{timeZone:c,offsetMinutes:l,now:u}):P==="hourly"?oe=io(oe,{timeZone:c,offsetMinutes:l,now:u}):P==="monthly"&&(oe=co(oe,{timeZone:c,offsetMinutes:l,now:u}));const be=new Date().toISOString();g(oe),x({from:z,to:X}),b("edge"),S(be),R?O({rows:oe,from:z,to:X,mode:P,fetchedAt:be}):A()}catch(W){if(R){const z=V();if(z?.rows){let X=P==="daily"?ao(z.rows||[],z.from||o,z.to||s,{timeZone:c,offsetMinutes:l,now:u}):Array.isArray(z.rows)?z.rows:[];P==="hourly"?X=io(X,{timeZone:c,offsetMinutes:l,now:u}):P==="monthly"&&(X=co(X,{timeZone:c,offsetMinutes:l,now:u})),g(X),x({from:z.from||o,to:z.to||s}),b("cache"),S(z.fetchedAt||null),N(null)}else{g([]),x({from:o,to:s}),b("edge"),S(null);const X=W;N(X?.message||String(X))}}else{g([]),x({from:o,to:s}),b("edge"),S(null);const z=W;N(z?.message||String(z))}}finally{k(!1)}}},[t,e,o,j,n,R,P,a,V,M,_,E,d,F,c,s,l,u,A,O,U]);f.useEffect(()=>{if(_){g(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}if(!M&&!n&&!j&&!U){g([]),x({from:o,to:s}),N(null),k(!1),b("edge"),S(null);return}if(!R)A(),g([]),x({from:o,to:s}),N(null),b("edge"),S(null);else{const H=V();if(H?.rows){let W=P==="daily"?ao(H.rows||[],H.from||o,H.to||s,{timeZone:c,offsetMinutes:l,now:u}):Array.isArray(H.rows)?H.rows:[];P==="hourly"?W=io(W,{timeZone:c,offsetMinutes:l,now:u}):P==="monthly"&&(W=co(W,{timeZone:c,offsetMinutes:l,now:u})),g(W),x({from:H.from||o,to:H.to||s}),b("cache"),S(H.fetchedAt||null)}}Y()},[t,j,V,Y,_,E,d,F,M,n,R,A,U]);const Z=j?"mock":v;return{rows:h,from:y.from||o,to:y.to||s,source:Z,fetchedAt:w,loading:C,error:T,refresh:Y}}function vd(e){try{return new URL(e).host}catch{return null}}function so(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&Sn(a)===t?a:null}function kd(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function ao(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=so(t),i=so(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,l=qo({timeZone:r,offsetMinutes:o,date:c}),u=so(l),d=u?u.getTime():c.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const h=[];for(let g=a;g<=i;g=kd(g,1)){const y=Sn(g),x=m.get(y),v=g.getTime()>d;if(x){h.push({...x,missing:!1,future:v});continue}h.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return h}function io(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=bi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.hour||s?.label||"",i=Sd(a);if(!i)return{...s,future:!1};const c=i.dayNum>o.dayNum||i.dayNum===o.dayNum&&i.slot>o.slot;return{...s,future:c}}):e}function co(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=bi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.month||s?.label||"",i=Cd(a);if(!i)return{...s,future:!1};const c=i.year>o.year||i.year===o.year&&i.month>o.month;return{...s,future:c}}):e}function bi({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 m=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((b,w)=>(w.type&&w.value&&(b[w.type]=w.value),b),{}),h=Number(m.year),g=Number(m.month),y=Number(m.day),x=Number(m.hour),v=Number(m.minute);if(Number.isFinite(h)&&Number.isFinite(g)&&Number.isFinite(y)&&Number.isFinite(x)&&Number.isFinite(v)){const b=x*2+(v>=30?1:0);return{year:h,month:g,day:y,hour:x,minute:v,dayNum:h*1e4+g*100+y,slot:b}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),d=u.getUTCFullYear(),m=u.getUTCMonth()+1,h=u.getUTCDate(),g=u.getUTCHours(),y=u.getUTCMinutes(),x=g*2+(y>=30?1:0);return{year:d,month:m,day:h,hour:g,minute:y,dayNum:d*1e4+m*100+h,slot:x}}const o=r.getFullYear(),s=r.getMonth()+1,a=r.getDate(),i=r.getHours(),c=r.getMinutes(),l=i*2+(c>=30?1:0);return{year:o,month:s,day:a,hour:i,minute:c,dayNum:o*1e4+s*100+a,slot:l}}function Sd(e){if(!e)return null;const t=String(e).trim(),[n,r]=t.split("T");if(!n||!r)return null;const o=n.split("-");if(o.length!==3)return null;const s=Number(o[0]),a=Number(o[1]),i=Number(o[2]);if(!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i))return null;const c=r.split(":"),l=Number(c[0]),u=Number(c[1]);if(!Number.isFinite(l)||l<0||l>23||!Number.isFinite(u)||u<0||u>59)return null;const d=l*2+(u>=30?1:0);return{dayNum:s*1e4+a*100+i,slot:d}}function Cd(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const r=Number(n[0]),o=Number(n[1]);return!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12?null:{year:r,month:o}}function qs({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,includeDaily:s=!0,cacheKey:a,timeZone:i,tzOffsetMinutes:c,now:l}={}){const[u,d]=f.useState([]),[m,h]=f.useState(null),[g,y]=f.useState(null),[x,v]=f.useState("edge"),[b,w]=f.useState(null),[S,C]=f.useState(!1),[k,T]=f.useState(null),N=Rn(),j=Dn(t),M=!n,R=(()=>{if(!a)return null;const O=Ed(e)||"default",A=s?"daily":"summary",U=Lr({timeZone:i,offsetMinutes:c});return`tokentracker.usage.${a}.${O}.${r}.${o}.${A}.${U}`})(),_=f.useCallback(()=>{if(!R||typeof window>"u")return null;try{const O=window.localStorage.getItem(R);if(!O)return null;const A=JSON.parse(O);return!A||!A.summary?null:A}catch{return null}},[R]),E=f.useCallback(O=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(O))}catch{}},[R]),F=f.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),P=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=f.useCallback(async()=>{const O=await tn(t);if(!(!O&&!N&&!P)){C(!0),T(null);try{let A=null,U=null;if(s){const[z,X]=await Promise.allSettled([Vo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c}),ro({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c,rolling:!0})]);if(z.status==="rejected")throw z.reason;A=z.value,U=X.status==="fulfilled"?X.value:null}else U=await ro({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c,rolling:!0});let Y=s&&Array.isArray(A?.data)?A.data:[];s&&(Y=uo(Y,r,o,{timeZone:i,offsetMinutes:c,now:l}));let Z=U?.totals||A?.summary?.totals||null,H=U?.rolling||A?.summary?.rolling||null;if(s&&!Z&&!U)try{const z=await ro({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:c,rolling:!0});Z=z?.totals||null,H=z?.rolling||H}catch{}const W=new Date().toISOString();d(Y),h(Z),y(H),v("edge"),w(W),Z&&M?E({summary:Z,rolling:H,daily:Y,from:r,to:o,includeDaily:s,fetchedAt:W}):M||F()}catch(A){if(M){const U=_();if(U?.summary){h(U.summary),y(U.rolling||null);const Y=Array.isArray(U.daily)?U.daily:[],Z=s?uo(Y,U.from||r,U.to||o,{timeZone:i,offsetMinutes:c,now:l}):Y;d(Z),v("cache"),w(U.fetchedAt||null),T(null)}else{const Y=A;T(Y?.message||String(Y)),d([]),h(null),y(null),v("edge"),w(null)}}else{const U=A;T(U?.message||String(U)),d([]),h(null),y(null),v("edge"),w(null)}}finally{C(!1)}}},[t,e,r,s,N,n,M,l,_,j,i,o,c,F,E,P]);return f.useEffect(()=>{const O=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!j&&!n&&!N&&!O){d([]),h(null),y(null),T(null),C(!1),v("edge"),w(null);return}if(!M)F(),d([]),h(null),y(null),T(null),v("edge"),w(null);else{const A=_();if(A?.summary){h(A.summary),y(A.rolling||null);const U=Array.isArray(A.daily)?A.daily:[],Y=s?uo(U,A.from||r,A.to||o,{timeZone:i,offsetMinutes:c,now:l}):U;d(Y),v("cache"),w(A.fetchedAt||null)}}B()},[t,N,_,B,j,n,M,F,P]),{daily:u,summary:m,rolling:g,source:N?"mock":x,fetchedAt:b,loading:S,error:k,refresh:B}}function Ed(e){try{return new URL(e).host}catch{return null}}function lo(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&Sn(a)===t?a:null}function Md(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function uo(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=lo(t),i=lo(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,l=qo({timeZone:r,offsetMinutes:o,date:c}),u=lo(l),d=u?u.getTime():c.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const h=[];for(let g=a;g<=i;g=Md(g,1)){const y=Sn(g),x=m.get(y),v=g.getTime()>d;if(x){h.push({...x,missing:!1,future:v});continue}h.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return h}function Td({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,cacheKey:s,timeZone:a,tzOffsetMinutes:i}={}){const[c,l]=f.useState(null),[u,d]=f.useState("edge"),[m,h]=f.useState(!1),[g,y]=f.useState(null),x=Rn(),v=Dn(t),b=!n,w=f.useMemo(()=>{if(!s)return null;const M=Od(e)||"default",R=Lr({timeZone:a,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${M}.${r}.${o}.${R}`},[e,s,r,a,o,i]),S=f.useCallback(()=>{if(!w||typeof window>"u")return null;try{const M=window.localStorage.getItem(w);if(!M)return null;const R=JSON.parse(M);return!R||!R.breakdown?null:R}catch{return null}},[w]),C=f.useCallback(M=>{if(!(!w||typeof window>"u"))try{window.localStorage.setItem(w,JSON.stringify(M))}catch{}},[w]),k=f.useCallback(()=>{if(!(!w||typeof window>"u"))try{window.localStorage.removeItem(w)}catch{}},[w]),T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=f.useCallback(async()=>{const M=await tn(t);if(!(!M&&!x&&!T)){h(!0),y(null);try{const R=await Wu({baseUrl:e,accessToken:M,from:r,to:o,timeZone:a,tzOffsetMinutes:i});l(R||null),d("edge"),R&&b?C({breakdown:R,fetchedAt:new Date().toISOString()}):b||k()}catch(R){if(b){const _=S();if(_?.breakdown)l(_.breakdown),d("cache"),y(null);else{l(null),d("edge");const E=R;y(E?.message||String(E))}}else{l(null),d("edge");const _=R;y(_?.message||String(_))}}finally{h(!1)}}},[t,e,r,x,n,b,S,a,o,v,i,k,C,T]);return f.useEffect(()=>{if(!v&&!n&&!x&&!T){l(null),d("edge"),y(null),h(!1);return}if(!b)k(),l(null),d("edge"),y(null);else{const M=S();M?.breakdown&&(l(M.breakdown),d("cache"))}N()},[t,x,S,N,v,n,b,k,T]),{breakdown:c,source:x?"mock":u,loading:m,error:g,refresh:N}}function Od(e){try{return new URL(e).host}catch{return null}}const xi=new Set(["day","hour","month"]);function Nd(e){return xi.has(e)}function Gs(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 Rd(e,t){const n=Gs(e),r=Gs(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const o=et(e),s=et(t);return o==null&&s==null?0:o==null?1:s==null?-1:o===s?0:o<s?-1:1}function Dd(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 Pd(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]),o=Number(n[2]),s=Number(n[3]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o-1,s));return!Number.isFinite(a.getTime())||a.getUTCFullYear()!==r||a.getUTCMonth()+1!==o||a.getUTCDate()!==s?null:a.getTime()}function Ad(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12)return null;const s=new Date(Date.UTC(r,o-1,1));return Number.isFinite(s.getTime())?s.getTime():null}function _d(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]),o=Number(n[2]),s=Number(n[3]),a=Number(n[4]),i=Number(n[5]),c=Number(n[6]||0);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i)||!Number.isFinite(c)||o<1||o>12||s<1||s>31||a<0||a>23||i<0||i>59||c<0||c>59)return null;const l=new Date(Date.UTC(r,o-1,s,a,i,c));return Number.isFinite(l.getTime())?l.getTime():null}function Id(e,t,n){const r=n==="hour"?_d:n==="month"?Ad:Pd,o=r(e),s=r(t);return o!=null&&s!=null?o===s?0:o<s?-1:1:Dd(e,t)}function wi(e,{key:t,dir:n}){const r=n==="asc"?1:-1,o=Array.isArray(e)?e:[],s=xi.has(t)?(i,c)=>Id(i,c,t):Rd,a=i=>t==="total_tokens"&&i?.billable_total_tokens!=null?i.billable_total_tokens:i?.[t];return o.map((i,c)=>({row:i,index:c})).sort((i,c)=>{const l=a(i.row),u=a(c.row),d=l==null,m=u==null;if(d&&m)return i.index-c.index;if(d)return 1;if(m)return-1;const h=s(l,u);return h!==0?h*r:i.index-c.index}).map(i=>i.row)}const jd=[{key:"day",label:L("daily.sort.date.label"),title:L("daily.sort.date.title")},{key:"total_tokens",label:L("daily.sort.total.label"),title:L("daily.sort.total.title")},{key:"input_tokens",label:L("daily.sort.input.label"),title:L("daily.sort.input.title")},{key:"output_tokens",label:L("daily.sort.output.label"),title:L("daily.sort.output.title")},{key:"cached_input_tokens",label:L("daily.sort.cached.label"),title:L("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:L("daily.sort.reasoning.label"),title:L("daily.sort.reasoning.title")},{key:"conversation_count",label:L("daily.sort.conversations.label"),title:L("daily.sort.conversations.title")}];function zs(e){const t=Nd(e)?e:"day";return jd.map((n,r)=>r===0?{...n,key:t}:n)}function Ks(e,{key:t,dir:n}){return wi(e,{key:t,dir:n})}const Nr=12,Fd=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Wd(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 Ld(e){return Fd.some(t=>Wd(e?.[t]))}function $d(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=wi(t,{key:"month",dir:"asc"}),r=n.findIndex(o=>o?.month&&Ld(o));return r===-1?t:n.slice(r)}function Bd(e,t,n=Nr){const r=Array.isArray(e)?e:[],o=Number.isFinite(n)&&n>0?n:Nr,a=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*o;return r.slice(a,a+o)}function Yd({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:r,heatmapLoading:o,activeDays:s,hasActiveDeviceToken:a}={}){return e||t?!1:n?!0:r&&!o&&s===0&&!a}function vi(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Hd(e){const t=vi(e?.model_id);return t||null}function ki(e,t){return e?.model?String(e.model):t}function Ud(e,{copyFn:t}={}){const n=typeof t=="function"?t:a=>a,o=(Array.isArray(e?.sources)?e.sources:[]).map(a=>{const i=et(a?.totals?.billable_total_tokens??a?.totals?.total_tokens)??0,c=et(a?.totals?.total_cost_usd)??0;return{source:a?.source,totalTokens:Number.isFinite(i)?i:0,totalCost:Number.isFinite(c)?c:0,models:Array.isArray(a?.models)?a.models:[]}}).filter(a=>a.totalTokens>0);if(!o.length)return[];const s=o.reduce((a,i)=>a+i.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),o.slice().sort((a,i)=>i.totalTokens-a.totalTokens).map(a=>{const i=a.source?String(a.source).toUpperCase():n("shared.placeholder.short"),c=s>0?a.totalTokens/s*100:0,l=Number.isFinite(c)?c.toFixed(1):"0.0",u=a.models.map(d=>{const m=et(d?.totals?.billable_total_tokens??d?.totals?.total_tokens)??0;if(!Number.isFinite(m)||m<=0)return null;const h=a.totalTokens>0?Math.round(m/a.totalTokens*1e3)/10:0,g=ki(d,n("shared.placeholder.short")),y=Hd(d),x=a.totalCost>0&&a.totalTokens>0?m/a.totalTokens*a.totalCost:null;return{id:y,name:g,share:h,usage:m,cost:x}}).filter(Boolean);return{label:i,totalPercent:String(l),usd:a.totalCost,usage:a.totalTokens,models:u}})}function Vd(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:m=>m,o=Array.isArray(e?.sources)?e.sources:[];if(!o.length)return[];const s=new Map,a=new Map,i=new Map;let c=0;for(const m of o){const h=Array.isArray(m?.models)?m.models:[];for(const g of h){const y=et(g?.totals?.billable_total_tokens)??0;if(!Number.isFinite(y)||y<=0)continue;c+=y;const x=ki(g,r("shared.placeholder.short")),v=vi(x);if(!v)continue;s.set(v,(s.get(v)||0)+y);const b=i.get(v)||0;y>=b&&(i.set(v,y),a.set(v,x))}}if(!s.size)return[];const l=Array.from(s.values()).reduce((m,h)=>m+h,0),u=c>0?c:l,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(s.entries()).map(([m,h])=>{const g=u>0?(h/u*100).toFixed(1):"0.0";return{id:m,name:a.get(m)||r("shared.placeholder.short"),tokens:h,percent:String(g)}}).sort((m,h)=>h.tokens!==m.tokens?h.tokens-m.tokens:String(m.name).localeCompare(String(h.name))).slice(0,d)}const Xt=12,Bn=3,fo=26,qd=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],Gd=["#064e3b","#065f46","#059669","#10b981","#34d399"],zd=[L("heatmap.month.jan"),L("heatmap.month.feb"),L("heatmap.month.mar"),L("heatmap.month.apr"),L("heatmap.month.may"),L("heatmap.month.jun"),L("heatmap.month.jul"),L("heatmap.month.aug"),L("heatmap.month.sep"),L("heatmap.month.oct"),L("heatmap.month.nov"),L("heatmap.month.dec")];function Kd(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 Xd(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 Si(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Jd(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function Qd(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return Si(e,-((r-n+7)%7))}function Zd(e,t,n){if(!e)return[];const r=Xd(t)||new Date,o=[];for(let l=11;l>=0;l-=1)o.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-l,1)));const s=Qd(r,n),a=Si(s,-(e-1)*7),i=[],c=new Set;for(const l of o){const u=Math.floor(Jd(a,l)/7);u<0||u>=e||c.has(u)||(c.add(u),i.push({label:zd[l.getUTCMonth()],index:u}))}return i}function ef({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:o}=ai(),a=o==="dark"?Gd:qd,i=f.useRef(null);f.useEffect(()=>{const g=i.current;g&&(g.scrollLeft=g.scrollWidth)},[e?.weeks]);const c=e?.week_starts_on==="mon"?"mon":"sun",l=f.useMemo(()=>{const g=Array.isArray(e?.weeks)?e.weeks:[];if(!g.length)return{weeks:[]};const y=[];for(const x of g)for(const v of Array.isArray(x)?x:[])v?.day&&y.push({day:v.day,total_tokens:v.total_tokens??v.value??0,billable_total_tokens:v.billable_total_tokens??v.value??v.total_tokens??0});return _o({dailyRows:y,weeks:Math.max(52,g.length),to:e?.to,weekStartsOn:c})},[e?.to,e?.weeks,c]),u=l?.weeks||[],d=c==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(g=>L(`heatmap.day.${g.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(g=>L(`heatmap.day.${g.toLowerCase()}`)),m=f.useMemo(()=>Zd(u.length,l?.to,c),[l?.to,u.length,c]);if(!u.length)return p.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:L("heatmap.empty")});const h=fo+u.length*Xt+Math.max(0,u.length-1)*Bn;return p.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:[p.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:L("heatmap.title")}),p.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||L("heatmap.legend.utc")})]}),p.jsx("div",{ref:i,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:p.jsxs("div",{style:{minWidth:h},children:[p.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${fo}px repeat(${u.length}, ${Xt}px)`,columnGap:Bn},children:[p.jsx("span",{}),m.map(g=>p.jsx("span",{style:{gridColumnStart:g.index+2},className:"whitespace-nowrap",children:g.label},`${g.label}-${g.index}`))]}),p.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${fo}px repeat(${u.length}, ${Xt}px)`,columnGap:Bn},children:[p.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, ${Xt}px)`,rowGap:Bn},children:d.map(g=>p.jsx("span",{className:"leading-none",children:g},g))}),p.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Xt}px)`,gap:Bn},children:u.map((g,y)=>(Array.isArray(g)?g:[]).map((x,v)=>{if(!x)return null;const b=x.day||`e-${y}-${v}`,w=Number(x.level)||0,S=a[w]||a[0],C=t||n||L("heatmap.legend.utc");return p.jsx("span",{title:L("heatmap.tooltip",{day:x.day,value:Kd(x.value),unit:L("heatmap.unit.tokens"),tz:C}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:Xt,height:Xt,background:S}},b)}))})]})]})}),!r&&p.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:L("heatmap.legend.less")}),p.jsx("div",{className:"flex gap-0.5",children:a.map((g,y)=>p.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:g}},y))}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:L("heatmap.legend.more")})]})]})}const tf={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Ci={...tf,position:"fixed",top:0,left:0};function gt(e){const t=Ut(nf,e).current;return t.next=e,Ee(t.effect),t}function nf(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Rr=Symbol("NOT_FOUND");function rf(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function of(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function sf(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 Xs=e=>Array.isArray(e)?e:[e];function af(e){const t=Array.isArray(e[0])?e[0]:e;return sf(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function cf(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}function lf(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Rr},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function uf(e,t){let n=[];function r(i){const c=n.findIndex(l=>t(i,l.key));if(c>-1){const l=n[c];return c>0&&(n.splice(c,1),n.unshift(l)),l.value}return Rr}function o(i,c){r(i)===Rr&&(n.unshift({key:i,value:c}),n.length>e&&n.pop())}function s(){return n}function a(){n=[]}return{get:r,put:o,getEntries:s,clear:a}}var df=(e,t)=>e===t;function ff(e){return function(n,r){if(n===null||r===null||n.length!==r.length)return!1;const{length:o}=n;for(let s=0;s<o;s++)if(!e(n[s],r[s]))return!1;return!0}}function mf(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=df,maxSize:o=1,resultEqualityCheck:s}=n,a=ff(r);let i=0;const c=o<=1?lf(a):uf(o,a);function l(){let u=c.get(arguments);if(u===Rr){if(u=e.apply(null,arguments),i++,s){const m=c.getEntries().find(h=>s(h.value,u));m&&(u=m.value,i!==0&&i--)}c.put(arguments,u)}return u}return l.clearCache=()=>{c.clear(),l.resetResultsCount()},l.resultsCount=()=>i,l.resetResultsCount=()=>{i=0},l}var hf=class{constructor(e){this.value=e}deref(){return this.value}},gf=typeof WeakRef<"u"?WeakRef:hf,pf=0,Js=1;function yr(){return{s:pf,v:void 0,o:null,p:null}}function Ei(e,t={}){let n=yr();const{resultEqualityCheck:r}=t;let o,s=0;function a(){let i=n;const{length:c}=arguments;for(let d=0,m=c;d<m;d++){const h=arguments[d];if(typeof h=="function"||typeof h=="object"&&h!==null){let g=i.o;g===null&&(i.o=g=new WeakMap);const y=g.get(h);y===void 0?(i=yr(),g.set(h,i)):i=y}else{let g=i.p;g===null&&(i.p=g=new Map);const y=g.get(h);y===void 0?(i=yr(),g.set(h,i)):i=y}}const l=i;let u;if(i.s===Js)u=i.v;else if(u=e.apply(null,arguments),s++,r){const d=o?.deref?.()??o;d!=null&&r(d,u)&&(u=d,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new gf(u):u}return l.s=Js,l.v=u,u}return a.clearCache=()=>{n=yr(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function Mi(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...o)=>{let s=0,a=0,i,c={},l=o.pop();typeof l=="object"&&(c=l,l=o.pop()),rf(l,`createSelector expects an output function after the inputs, but received: [${typeof l}]`);const u={...n,...c},{memoize:d,memoizeOptions:m=[],argsMemoize:h=Ei,argsMemoizeOptions:g=[]}=u,y=Xs(m),x=Xs(g),v=af(o),b=d(function(){return s++,l.apply(null,arguments)},...y),w=h(function(){a++;const C=cf(v,arguments);return i=b.apply(null,C),i},...x);return Object.assign(w,{resultFunc:l,memoizedResultFunc:b,dependencies:v,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>i,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:d,argsMemoize:h})};return Object.assign(r,{withTypes:()=>r}),r}var yf=Mi(Ei),bf=Object.assign((e,t=yf)=>{of(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(s=>e[s]);return t(r,(...s)=>s.reduce((a,i,c)=>(a[n[c]]=i,a),{}))},{withTypes:()=>bf});Mi({memoize:mf,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const ge=(e,t,n,r,o,s,...a)=>{if(a.length>0)throw new Error(on(1));let i;if(e)i=e;else throw new Error("Missing arguments");return i};var mo={exports:{}},ho={};var Qs;function xf(){if(Qs)return ho;Qs=1;var e=ii();function t(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function i(d,m){var h=m(),g=r({inst:{value:h,getSnapshot:m}}),y=g[0].inst,x=g[1];return s(function(){y.value=h,y.getSnapshot=m,c(y)&&x({inst:y})},[d,h,m]),o(function(){return c(y)&&x({inst:y}),d(function(){c(y)&&x({inst:y})})},[d]),a(h),h}function c(d){var m=d.getSnapshot;d=d.value;try{var h=m();return!n(d,h)}catch{return!0}}function l(d,m){return m()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:i;return ho.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,ho}var Zs;function Ti(){return Zs||(Zs=1,mo.exports=xf()),mo.exports}var wf=Ti(),go={exports:{}},po={};var ea;function vf(){if(ea)return po;ea=1;var e=ii(),t=Ti();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,i=e.useMemo,c=e.useDebugValue;return po.useSyncExternalStoreWithSelector=function(l,u,d,m,h){var g=s(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=i(function(){function v(k){if(!b){if(b=!0,w=k,k=m(k),h!==void 0&&y.hasValue){var T=y.value;if(h(T,k))return S=T}return S=k}if(T=S,r(w,k))return T;var N=m(k);return h!==void 0&&h(T,N)?(w=k,T):(w=k,S=N)}var b=!1,w,S,C=d===void 0?null:d;return[function(){return v(u())},C===null?void 0:function(){return v(C())}]},[u,d,m,h]);var x=o(l,g[0],g[1]);return a(function(){y.hasValue=!0,y.value=x},[x]),c(x),x},po}var ta;function kf(){return ta||(ta=1,go.exports=vf()),go.exports}var Sf=kf();const Cf=ci(19),Ef=Cf?Tf:Of;function Mf(e,t,n,r,o){return Ef(e,t,n,r,o)}function Tf(e,t,n,r,o){const s=f.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return wf.useSyncExternalStore(e.subscribe,s,s)}function Of(e,t,n,r,o){return Sf.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class zn{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])){zn.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||zn.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};zn.prototype.setState.call(this,t)}}class Zo extends zn{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){f.useDebugValue(t),Ee(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ee(()=>(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);Ee(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){f.useDebugValue(t);const o=this,s=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,s),!s&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})),Ee(()=>{s&&!Object.is(o.state[t],n)&&super.setState({...o.state,[t]:n})},[o,t,n,r,s])}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,o)=>{const s=this.selectors[t];return s(this.state,n,r,o)};useState=(t,n,r,o)=>{f.useDebugValue(t);const s=this.selectors[t];return Mf(this,s,n,r,o)};useContextCallback(t,n){f.useDebugValue(t);const r=me(n??li);this.context[t]=r}useStateSetter(t){const n=f.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 o=r(this.state);return n(o,o,this),this.subscribe(s=>{const a=r(s);if(!Object.is(o,a)){const i=o;o=a,n(a,i,this)}})}}const Nf=[];function es(e){f.useEffect(e,Nf)}const br=null;class Rf{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 o=0;o<n.length;o+=1)n[o]?.(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 xr=new Rf;class ht{static create(){return new ht}static request(t){return xr.request(t)}static cancel(t){return xr.cancel(t)}currentId=br;request(t){this.cancel(),this.currentId=xr.request(()=>{this.currentId=br,t()})}cancel=()=>{this.currentId!==br&&(xr.cancel(this.currentId),this.currentId=br)};disposeEffect=()=>this.cancel}function ts(){const e=Ut(ht.create).current;return es(e.disposeEffect),e}const Yn=0;class Ht{static create(){return new Ht}currentId=Yn;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Yn,n()},t)}isStarted(){return this.currentId!==Yn}clear=()=>{this.currentId!==Yn&&(clearTimeout(this.currentId),this.currentId=Yn)};disposeEffect=()=>this.clear}function nn(){const e=Ut(Ht.create).current;return es(e.disposeEffect),e}const Pn=typeof navigator<"u",yo=_f(),Oi=jf(),Ni=If(),Df=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Ri=yo.platform==="MacIntel"&&yo.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(yo.platform),Pf=Pn&&/apple/i.test(navigator.vendor),Io=Pn&&/android/i.test(Oi)||/android/i.test(Ni);Pn&&Oi.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Af=Ni.includes("jsdom/");function _f(){if(!Pn)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 If(){if(!Pn)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function jf(){if(!Pn)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const jo="data-base-ui-focusable",Di="active",Pi="selected",Ai="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function yn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function ve(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Lu(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Je(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 Ff(e){return e.matches("html,body")}function Ye(e){return e?.ownerDocument||document}function _i(e){return Ge(e)&&e.matches(Ai)}function na(e){return e?e.getAttribute("role")==="combobox"&&_i(e):!1}function Fo(e){return e?e.hasAttribute(jo)?e:e.querySelector(`[${jo}]`)||e:null}function en(e,t,n=!0){return e.filter(o=>o.parentId===t&&(!n||o.context?.open)).flatMap(o=>[o,...en(e,o.id,n)])}function ra(e,t){let n=[],r=e.find(o=>o.id===t)?.parentId;for(;r;){const o=e.find(s=>s.id===r);r=o?.parentId,o&&(n=n.concat(o))}return n}function Wf(e){e.preventDefault(),e.stopPropagation()}function Lf(e){return"nativeEvent"in e}function $f(e){return e.mozInputSource===0&&e.isTrusted?!0:Io&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Bf(e){return Af?!1:!Io&&e.width===0&&e.height===0||Io&&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 En(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Ii(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Yf=["top","right","bottom","left"],Mn=Math.min,Qe=Math.max,Dr=Math.round,wr=Math.floor,xt=e=>({x:e,y:e}),Hf={left:"right",right:"left",bottom:"top",top:"bottom"};function Wo(e,t,n){return Qe(e,Mn(t,n))}function Rt(e,t){return typeof e=="function"?e(t):e}function ze(e){return e.split("-")[0]}function Vt(e){return e.split("-")[1]}function ns(e){return e==="x"?"y":"x"}function rs(e){return e==="y"?"height":"width"}function ot(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function os(e){return ns(ot(e))}function Uf(e,t,n){n===void 0&&(n=!1);const r=Vt(e),o=os(e),s=rs(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Pr(a)),[a,Pr(a)]}function Vf(e){const t=Pr(e);return[Lo(e),t,Lo(t)]}function Lo(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const oa=["left","right"],sa=["right","left"],qf=["top","bottom"],Gf=["bottom","top"];function zf(e,t,n){switch(e){case"top":case"bottom":return n?t?sa:oa:t?oa:sa;case"left":case"right":return t?qf:Gf;default:return[]}}function Kf(e,t,n,r){const o=Vt(e);let s=zf(ze(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Lo)))),s}function Pr(e){const t=ze(e);return Hf[t]+e.slice(t.length)}function Xf(e){return{top:0,right:0,bottom:0,left:0,...e}}function ji(e){return typeof e!="number"?Xf(e):{top:e,right:e,bottom:e,left:e}}function Ar(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}var Jf=["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] *)"],_r=Jf.join(","),Fi=typeof Element>"u",Tn=Fi?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ir=!Fi&&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},jr=function(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),s=o===""||o==="true",a=s||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):jr(t.parentNode));return a},Qf=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Wi=function(t,n,r){if(jr(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(_r));return n&&Tn.call(t,_r)&&o.unshift(t),o=o.filter(r),o},Fr=function(t,n,r){for(var o=[],s=Array.from(t);s.length;){var a=s.shift();if(!jr(a,!1))if(a.tagName==="SLOT"){var i=a.assignedElements(),c=i.length?i:a.children,l=Fr(c,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:a,candidates:l})}else{var u=Tn.call(a,_r);u&&r.filter(a)&&(n||!t.includes(a))&&o.push(a);var d=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),m=!jr(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(d&&m){var h=Fr(d===!0?a.children:d.children,!0,r);r.flatten?o.push.apply(o,h):o.push({scopeParent:a,candidates:h})}else s.unshift.apply(s,a.children)}}return o},Li=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},$i=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Qf(t))&&!Li(t)?0:t.tabIndex},Zf=function(t,n){var r=$i(t);return r<0&&n&&!Li(t)?0:r},em=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Bi=function(t){return t.tagName==="INPUT"},tm=function(t){return Bi(t)&&t.type==="hidden"},nm=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},rm=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},om=function(t){if(!t.name)return!0;var n=t.form||Ir(t),r=function(i){return n.querySelectorAll('input[type="radio"][name="'+i+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(a){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",a.message),!1}var s=rm(o,t.form);return!s||s===t},sm=function(t){return Bi(t)&&t.type==="radio"},am=function(t){return sm(t)&&!om(t)},im=function(t){var n,r=t&&Ir(t),o=(n=r)===null||n===void 0?void 0:n.host,s=!1;if(r&&r!==t){var a,i,c;for(s=!!((a=o)!==null&&a!==void 0&&(i=a.ownerDocument)!==null&&i!==void 0&&i.contains(o)||t!=null&&(c=t.ownerDocument)!==null&&c!==void 0&&c.contains(t));!s&&o;){var l,u,d;r=Ir(o),o=(l=r)===null||l===void 0?void 0:l.host,s=!!((u=o)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(o))}}return s},aa=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},cm=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var s=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!s}if(getComputedStyle(t).visibility==="hidden")return!0;var a=Tn.call(t,"details>summary:first-of-type"),i=a?t.parentElement:t;if(Tn.call(i,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof o=="function"){for(var c=t;t;){var l=t.parentElement,u=Ir(t);if(l&&!l.shadowRoot&&o(l)===!0)return aa(t);t.assignedSlot?t=t.assignedSlot:!l&&u!==t.ownerDocument?t=u.host:t=l}t=c}if(im(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return aa(t);return!1},lm=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 o=n.children.item(r);if(o.tagName==="LEGEND")return Tn.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},$o=function(t,n){return!(n.disabled||tm(n)||cm(n,t)||nm(n)||lm(n))},Bo=function(t,n){return!(am(n)||$i(n)<0||!$o(t,n))},um=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Yi=function(t){var n=[],r=[];return t.forEach(function(o,s){var a=!!o.scopeParent,i=a?o.scopeParent:o,c=Zf(i,a),l=a?Yi(o.candidates):i;c===0?a?n.push.apply(n,l):n.push(i):r.push({documentOrder:s,tabIndex:c,item:o,isScope:a,content:l})}),r.sort(em).reduce(function(o,s){return s.isScope?o.push.apply(o,s.content):o.push(s.content),o},[]).concat(n)},rr=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Fr([t],n.includeContainer,{filter:Bo.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:um}):r=Wi(t,n.includeContainer,Bo.bind(null,n)),Yi(r)},dm=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Fr([t],n.includeContainer,{filter:$o.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Wi(t,n.includeContainer,$o.bind(null,n)),r},Hi=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Tn.call(t,_r)===!1?!1:Bo(n,t)};const An=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Ui(e,t){const n=rr(e,An()),r=n.length;if(r===0)return;const o=yn(Ye(e)),s=n.indexOf(o),a=s===-1?t===1?0:r-1:s+t;return n[a]}function ss(e){return Ui(Ye(e).body,1)||e}function Vi(e){return Ui(Ye(e).body,-1)||e}function qi(e,t){if(!e)return null;const n=rr(Ye(e).body,An()),r=n.length;if(r===0)return null;const o=n.indexOf(e);if(o===-1)return null;const s=(o+t+r)%r;return n[s]}function fm(e){return qi(e,1)}function mm(e){return qi(e,-1)}function wn(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ve(n,r)}function hm(e){rr(e,An()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function ia(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const gm={...$u};let ca=0;function pm(e,t="mui"){const[n,r]=f.useState(e),o=e||n;return f.useEffect(()=>{n==null&&(ca+=1,r(`${t}-${ca}`))},[n,t]),o}const la=gm.useId;function _n(e,t){if(la!==void 0){const n=la();return e??(t?`${t}-${n}`:n)}return pm(e,t)}function Gi(){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 ym{nodesRef={current:[]};events=Gi();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 zi=f.createContext(null),Ki=f.createContext(null),sn=()=>f.useContext(zi)?.id||null,In=e=>{const t=f.useContext(Ki);return e??t};function bm(e){const t=_n(),n=In(e),r=sn();return Ee(()=>{if(!t)return;const o={id:t,parentId:r};return n?.addNode(o),()=>{n?.removeNode(o)}},[n,t,r]),t}function xm(e){const{children:t,id:n}=e,r=sn();return p.jsx(zi.Provider,{value:f.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function wm(e){const{children:t,externalTree:n}=e,r=Ut(()=>n??new ym).current;return p.jsx(Ki.Provider,{value:r,children:t})}const vm="none",Bt="trigger-press",Ze="trigger-hover",Xi="outside-press",km="close-press",Kn="focus-out",Ji="escape-key",Qi="imperative-action";function _e(e,t,n,r){let o=!1,s=!1;const a=$t;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){s=!0},get isCanceled(){return o},get isPropagationAllowed(){return s},trigger:n,...a}}function Xn(e){return`data-base-ui-${e}`}function bo(e,t,n){if(n&&!En(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]}function an(e){return e?.ownerDocument||document}const On=f.forwardRef(function(t,n){const[r,o]=f.useState();Ee(()=>{Pf&&o("button")},[]);const s={tabIndex:0,role:r};return p.jsx("span",{...t,ref:n,style:Ci,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});let ua=0;function xo(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(ua);const s=()=>e?.focus({preventScroll:n});o?s():ua=requestAnimationFrame(s)}const vn={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function da(e){return e==="inert"?vn.inert:e==="aria-hidden"?vn["aria-hidden"]:vn.none}let vr=new WeakSet,kr={},wo=0;const Zi=e=>e&&(e.host||Zi(e.parentNode)),Sm=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=Zi(n);return e.contains(r)?r:null}).filter(n=>n!=null);function Cm(e,t,n,r){const o="data-base-ui-inert",s=r?"inert":n?"aria-hidden":null,a=Sm(t,e),i=new Set,c=new Set(a),l=[];kr[o]||(kr[o]=new WeakMap);const u=kr[o];a.forEach(d),m(t),i.clear();function d(h){!h||i.has(h)||(i.add(h),h.parentNode&&d(h.parentNode))}function m(h){!h||c.has(h)||[].forEach.call(h.children,g=>{if(tr(g)!=="script")if(i.has(g))m(g);else{const y=s?g.getAttribute(s):null,x=y!==null&&y!=="false",v=da(s),b=(v.get(g)||0)+1,w=(u.get(g)||0)+1;v.set(g,b),u.set(g,w),l.push(g),b===1&&x&&vr.add(g),w===1&&g.setAttribute(o,""),!x&&s&&g.setAttribute(s,s==="inert"?"":"true")}})}return wo+=1,()=>{l.forEach(h=>{const g=da(s),x=(g.get(h)||0)-1,v=(u.get(h)||0)-1;g.set(h,x),u.set(h,v),x||(!vr.has(h)&&s&&h.removeAttribute(s),vr.delete(h)),v||h.removeAttribute(o)}),wo-=1,wo||(vn.inert=new WeakMap,vn["aria-hidden"]=new WeakMap,vn.none=new WeakMap,vr=new WeakSet,kr={})}}function Em(e,t=!1,n=!1){const r=Ye(e[0]).body;return Cm(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const ec=f.createContext(null),tc=()=>f.useContext(ec),Mm=Xn("portal");function Tm(e={}){const{ref:t,container:n,componentProps:r=$t,elementProps:o,elementState:s}=e,a=_n(),c=tc()?.portalNode,[l,u]=f.useState(null),[d,m]=f.useState(null),h=me(v=>{v!==null&&m(v)}),g=f.useRef(null);Ee(()=>{if(n===null){g.current&&(g.current=null,m(null),u(null));return}if(a==null)return;const v=(n&&(Bu(n)?n:n.current))??c??document.body;if(v==null){g.current&&(g.current=null,m(null),u(null));return}g.current!==v&&(g.current=v,m(null),u(v))},[n,c,a]);const y=Dt("div",r,{ref:[t,h],state:s,props:[{id:a,[Mm]:""},o]});return{portalNode:d,portalSubtree:l&&y?Yt.createPortal(y,l):null}}const nc=f.forwardRef(function(t,n){const{children:r,container:o,className:s,render:a,renderGuards:i,...c}=t,{portalNode:l,portalSubtree:u}=Tm({container:o,ref:n,componentProps:t,elementProps:c}),d=f.useRef(null),m=f.useRef(null),h=f.useRef(null),g=f.useRef(null),[y,x]=f.useState(null),v=y?.modal,b=y?.open,w=typeof i=="boolean"?i:!!y&&!y.modal&&y.open&&!!l;f.useEffect(()=>{if(!l||v)return;function C(k){l&&k.relatedTarget&&wn(k)&&(k.type==="focusin"?ia:hm)(l)}return l.addEventListener("focusin",C,!0),l.addEventListener("focusout",C,!0),()=>{l.removeEventListener("focusin",C,!0),l.removeEventListener("focusout",C,!0)}},[l,v]),f.useEffect(()=>{!l||b||ia(l)},[b,l]);const S=f.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:m,beforeInsideRef:h,afterInsideRef:g,portalNode:l,setFocusManagerState:x}),[l]);return p.jsxs(f.Fragment,{children:[u,p.jsxs(ec.Provider,{value:S,children:[w&&l&&p.jsx(On,{"data-type":"outside",ref:d,onFocus:C=>{if(wn(C,l))h.current?.focus();else{const k=y?y.domReference:null;Vi(k)?.focus()}}}),w&&l&&p.jsx("span",{"aria-owns":l.id,style:ld}),l&&Yt.createPortal(r,l),w&&l&&p.jsx(On,{"data-type":"outside",ref:m,onFocus:C=>{if(wn(C,l))g.current?.focus();else{const k=y?y.domReference:null;ss(k)?.focus(),y?.closeOnFocusOut&&y?.onOpenChange(!1,_e(Kn,C.nativeEvent))}}})]})]})});function Tt(e){return e==null?e:"current"in e?e.current:e}function Om(e,t){const n=st(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 fa=20;let Lt=[];function as(){Lt=Lt.filter(e=>e.isConnected)}function Nm(e){as(),e&&tr(e)!=="body"&&(Lt.push(e),Lt.length>fa&&(Lt=Lt.slice(-fa)))}function vo(){return as(),Lt[Lt.length-1]}function Rm(e){if(!e)return null;const t=An();return Hi(e,t)?e:rr(e,t)[0]||e}function Dm(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():ft(e).display!=="none"}function ma(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=An(),o=dm(e,n).filter(a=>{const i=a.getAttribute("data-tabindex")||"";return Hi(a,n)||a.hasAttribute("data-tabindex")&&!i.startsWith("-")}),s=e.getAttribute("tabindex");t.current.includes("floating")||o.length===0?s!=="0"&&e.setAttribute("tabindex","0"):(s!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function rc(e){const{context:t,children:n,disabled:r=!1,order:o=["content"],initialFocus:s=!0,returnFocus:a=!0,restoreFocus:i=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u="",getInsideElements:d=()=>[],nextFocusableElement:m,previousFocusableElement:h,beforeContentFocusGuardRef:g,externalTree:y}=e,x="rootStore"in t?t.rootStore:t,v=x.useState("open"),b=x.useState("domReferenceElement"),w=x.useState("floatingElement"),{events:S,dataRef:C}=x.context,k=me(()=>C.current.floatingContext?.nodeId),T=me(d),N=s===!1,j=na(b)&&N,M=gt(o),R=gt(s),_=gt(a),E=gt(u),F=In(y),P=tc(),B=f.useRef(null),V=f.useRef(null),O=f.useRef(!1),A=f.useRef(!1),U=f.useRef(!1),Y=f.useRef(-1),Z=f.useRef(""),H=f.useRef(""),W=f.useRef(null),z=f.useRef(null),X=Bs(W,g,P?.beforeInsideRef),oe=Bs(z,P?.afterInsideRef),be=nn(),Oe=nn(),xe=ts(),Le=P!=null,D=Fo(w),ae=me(($=D)=>$?rr($,An()):[]),q=me($=>{const J=ae($);return M.current.map(()=>J).filter(Boolean).flat()});f.useEffect(()=>{if(r||!c)return;function $(ie){ie.key==="Tab"&&ve(D,yn(Ye(D)))&&ae().length===0&&!j&&Wf(ie)}const J=Ye(D);return J.addEventListener("keydown",$),()=>{J.removeEventListener("keydown",$)}},[r,b,D,c,M,j,ae,q]),f.useEffect(()=>{if(r||!w)return;function $(J){const ie=Je(J),de=ae().indexOf(ie);de!==-1&&(Y.current=de)}return w.addEventListener("focusin",$),()=>{w.removeEventListener("focusin",$)}},[r,w,ae]),f.useEffect(()=>{if(r||!v)return;const $=Ye(D);function J(){U.current=!1}function ie(de){const se=Je(de),Q=ve(w,se)||ve(b,se)||ve(P?.portalNode,se);U.current=!Q,H.current=de.pointerType||"keyboard"}function he(){H.current="keyboard"}return $.addEventListener("pointerdown",ie,!0),$.addEventListener("pointerup",J,!0),$.addEventListener("pointercancel",J,!0),$.addEventListener("keydown",he,!0),()=>{$.removeEventListener("pointerdown",ie,!0),$.removeEventListener("pointerup",J,!0),$.removeEventListener("pointercancel",J,!0),$.removeEventListener("keydown",he,!0)}},[r,w,b,D,v,P]),f.useEffect(()=>{if(r||!l)return;function $(){A.current=!0,Oe.start(0,()=>{A.current=!1})}function J(se){const Q=se.relatedTarget,De=se.currentTarget,ke=Je(se);queueMicrotask(()=>{const je=k(),pe=x.context.triggerElements,Ke=Q?.hasAttribute(Xn("focus-guard"))&&[W.current,z.current,P?.beforeInsideRef.current,P?.afterInsideRef.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,Tt(h),Tt(m)].includes(Q),Fe=!(ve(b,Q)||ve(w,Q)||ve(Q,w)||ve(P?.portalNode,Q)||Q!=null&&pe.hasElement(Q)||pe.hasMatchingElement(Se=>ve(Se,Q))||Ke||F&&(en(F.nodesRef.current,je).find(Se=>ve(Se.context?.elements.floating,Q)||ve(Se.context?.elements.domReference,Q))||ra(F.nodesRef.current,je).find(Se=>[Se.context?.elements.floating,Fo(Se.context?.elements.floating)].includes(Q)||Se.context?.elements.domReference===Q)));if(De===b&&D&&ma(D,M),i&&De!==b&&!Dm(ke)&&yn(Ye(D))===Ye(D).body){if(Ge(D)&&(D.focus(),i==="popup")){xe.request(()=>{D.focus()});return}const Se=Y.current,Ue=ae(),He=Ue[Se]||Ue[Ue.length-1]||D;Ge(He)&&He.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(j||!c)&&Q&&Fe&&!A.current&&(j||Q!==vo())&&(O.current=!0,x.setOpen(!1,_e(Kn,se)))})}function ie(){U.current||(C.current.insideReactTree=!0,be.start(0,()=>{C.current.insideReactTree=!1}))}const he=Ge(b)?b:null,de=[];if(!(!w&&!he))return he&&(he.addEventListener("focusout",J),he.addEventListener("pointerdown",$),de.push(()=>{he.removeEventListener("focusout",J),he.removeEventListener("pointerdown",$)})),w&&(w.addEventListener("focusout",J),P&&(w.addEventListener("focusout",ie,!0),de.push(()=>{w.removeEventListener("focusout",ie,!0)})),de.push(()=>{w.removeEventListener("focusout",J)})),()=>{de.forEach(se=>{se()})}},[r,b,w,D,c,F,P,x,l,i,ae,j,k,M,C,be,Oe,xe,m,h]),f.useEffect(()=>{if(r||!w||!v)return;const $=Array.from(P?.portalNode?.querySelectorAll(`[${Xn("portal")}]`)||[]),ie=(F?ra(F.nodesRef.current,k()):[]).find(se=>na(se.context?.elements.domReference||null))?.context?.elements.domReference,he=[w,ie,...$,...T(),B.current,V.current,W.current,z.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,Tt(h),Tt(m),j?b:null].filter(se=>se!=null),de=Em(he,c||j);return()=>{de()}},[v,r,b,w,c,M,P,j,F,k,T,m,h]),Ee(()=>{if(!v||r||!Ge(D))return;const $=Ye(D),J=yn($);queueMicrotask(()=>{const ie=q(D),he=R.current,de=typeof he=="function"?he(E.current||""):he;if(de===void 0||de===!1)return;let se;de===!0||de===null?se=ie[0]||D:se=Tt(de),se=se||ie[0]||D,!ve(D,J)&&xo(se,{preventScroll:se===D})})},[r,v,D,N,q,R,E]),Ee(()=>{if(r||!D)return;const $=Ye(D),J=yn($);Nm(J);function ie(se){if(se.open||(Z.current=Om(se.nativeEvent,H.current)),se.reason===Ze&&se.nativeEvent.type==="mouseleave"&&(O.current=!0),se.reason===Xi)if(se.nested)O.current=!1;else if($f(se.nativeEvent)||Bf(se.nativeEvent))O.current=!1;else{let Q=!1;document.createElement("div").focus({get preventScroll(){return Q=!0,!1}}),Q?O.current=!1:O.current=!0}}S.on("openchange",ie);const he=$.createElement("span");he.setAttribute("tabindex","-1"),he.setAttribute("aria-hidden","true"),Object.assign(he.style,Ci),Le&&b&&b.insertAdjacentElement("afterend",he);function de(){const se=_.current;let Q=typeof se=="function"?se(Z.current):se;if(Q===void 0||Q===!1)return null;if(Q===null&&(Q=!0),typeof Q=="boolean"){const ke=b||vo();return ke&&ke.isConnected?ke:he}const De=b||vo()||he;return Tt(Q)||De}return()=>{S.off("openchange",ie);const se=yn($),Q=ve(w,se)||F&&en(F.nodesRef.current,k(),!1).some(ke=>ve(ke.context?.elements.floating,se)),De=de();queueMicrotask(()=>{const ke=Rm(De),je=typeof _.current!="boolean";_.current&&!O.current&&Ge(ke)&&(!(!je&&ke!==se&&se!==$.body)||Q)&&ke.focus({preventScroll:!0}),he.remove()})}},[r,w,D,_,C,S,F,Le,b,k]),f.useEffect(()=>{queueMicrotask(()=>{O.current=!1})},[r]),f.useEffect(()=>{if(r||!v)return;function $(ie){Je(ie)?.closest(`[${gi}]`)&&(A.current=!0)}const J=Ye(D);return J.addEventListener("pointerdown",$,!0),()=>{J.removeEventListener("pointerdown",$,!0)}},[r,v,D]),Ee(()=>{if(!r&&P)return P.setFocusManagerState({modal:c,closeOnFocusOut:l,open:v,onOpenChange:x.setOpen,domReference:b}),()=>{P.setFocusManagerState(null)}},[r,P,c,v,x,l,b]),Ee(()=>{if(!(r||!D))return ma(D,M),()=>{queueMicrotask(as)}},[r,D,M]);const ye=!r&&(c?!j:!0)&&(Le||c);return p.jsxs(f.Fragment,{children:[ye&&p.jsx(On,{"data-type":"inside",ref:X,onFocus:$=>{if(c){const J=q();xo(J[J.length-1])}else P?.portalNode&&(O.current=!1,wn($,P.portalNode)?ss(b)?.focus():Tt(h??P.beforeOutsideRef)?.focus())}}),n,ye&&p.jsx(On,{"data-type":"inside",ref:oe,onFocus:$=>{c?xo(q()[0]):P?.portalNode&&(l&&(O.current=!0),wn($,P.portalNode)?Vi(b)?.focus():Tt(m??P.afterOutsideRef)?.focus())}})]})}function Pm(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:o=!0,event:s="click",toggle:a=!0,ignoreMouse:i=!1,stickIfOpen:c=!0,touchOpenDelay:l=0}=t,u=f.useRef(void 0),d=ts(),m=nn(),h=f.useMemo(()=>({onPointerDown(g){u.current=g.pointerType},onMouseDown(g){const y=u.current,x=g.nativeEvent,v=n.select("open");if(g.button!==0||s==="click"||En(y,!0)&&i)return;const b=r.current.openEvent,w=b?.type,S=n.select("domReferenceElement")!==g.currentTarget,C=v&&S||!(v&&a&&(!(b&&c)||w==="click"||w==="mousedown"));if(_i(x.target)){const T=_e(Bt,x,x.target);C&&y==="touch"&&l>0?m.start(l,()=>{n.setOpen(!0,T)}):n.setOpen(C,T);return}const k=g.currentTarget;d.request(()=>{const T=_e(Bt,x,k);C&&y==="touch"&&l>0?m.start(l,()=>{n.setOpen(!0,T)}):n.setOpen(C,T)})},onClick(g){if(s==="mousedown-only")return;const y=u.current;if(s==="mousedown"&&y){u.current=void 0;return}if(En(y,!0)&&i)return;const x=n.select("open"),v=r.current.openEvent,b=n.select("domReferenceElement")!==g.currentTarget,w=x&&b||!(x&&a&&(!(v&&c)||Ii(v))),S=_e(Bt,g.nativeEvent,g.currentTarget);w&&y==="touch"&&l>0?m.start(l,()=>{n.setOpen(!0,S)}):n.setOpen(w,S)},onKeyDown(){u.current=void 0}}),[r,s,i,n,c,a,d,m,l]);return f.useMemo(()=>o?{reference:h}:$t,[o,h])}function ha(e,t,n){let{reference:r,floating:o}=e;const s=ot(t),a=os(t),i=rs(a),c=ze(t),l=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,m=r[i]/2-o[i]/2;let h;switch(c){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Vt(t)){case"start":h[a]-=m*(n&&l?-1:1);break;case"end":h[a]+=m*(n&&l?-1:1);break}return h}async function Am(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=Rt(t,e),g=ji(h),x=i[m?d==="floating"?"reference":"floating":d],v=Ar(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:l,rootBoundary:u,strategy:c})),b=d==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),S=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},C=Ar(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:b,offsetParent:w,strategy:c}):b);return{top:(v.top-C.top+g.top)/S.y,bottom:(C.bottom-v.bottom+g.bottom)/S.y,left:(v.left-C.left+g.left)/S.x,right:(C.right-v.right+g.right)/S.x}}const _m=50,Im=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:Am},c=await(a.isRTL==null?void 0:a.isRTL(t));let l=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=ha(l,r,c),m=r,h=0;const g={};for(let y=0;y<s.length;y++){const x=s[y];if(!x)continue;const{name:v,fn:b}=x,{x:w,y:S,data:C,reset:k}=await b({x:u,y:d,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:l,platform:i,elements:{reference:e,floating:t}});u=w??u,d=S??d,g[v]={...g[v],...C},k&&h<_m&&(h++,typeof k=="object"&&(k.placement&&(m=k.placement),k.rects&&(l=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:u,y:d}=ha(l,m,c)),y=-1)}return{x:u,y:d,placement:m,strategy:o,middlewareData:g}},jm=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...x}=Rt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=ze(o),b=ot(i),w=ze(i)===i,S=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=m||(w||!y?[Pr(i)]:Vf(i)),k=g!=="none";!m&&k&&C.push(...Kf(i,y,g,S));const T=[i,...C],N=await c.detectOverflow(t,x),j=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&j.push(N[v]),d){const F=Uf(o,a,S);j.push(N[F[0]],N[F[1]])}if(M=[...M,{placement:o,overflows:j}],!j.every(F=>F<=0)){var R,_;const F=(((R=s.flip)==null?void 0:R.index)||0)+1,P=T[F];if(P&&(!(d==="alignment"?b!==ot(P):!1)||M.every(O=>ot(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:F,overflows:M},reset:{placement:P}};let B=(_=M.filter(V=>V.overflows[0]<=0).sort((V,O)=>V.overflows[1]-O.overflows[1])[0])==null?void 0:_.placement;if(!B)switch(h){case"bestFit":{var E;const V=(E=M.filter(O=>{if(k){const A=ot(O.placement);return A===b||A==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(A=>A>0).reduce((A,U)=>A+U,0)]).sort((O,A)=>O[1]-A[1])[0])==null?void 0:E[0];V&&(B=V);break}case"initialPlacement":B=i;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function ga(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pa(e){return Yf.some(t=>e[t]>=0)}const Fm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=Rt(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),i=ga(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pa(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=ga(a,n.floating);return{data:{escapedOffsets:i,escaped:pa(i)}}}default:return{}}}}},oc=new Set(["left","top"]);async function Wm(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=ze(n),i=Vt(n),c=ot(n)==="y",l=oc.has(a)?-1:1,u=s&&c?-1:1,d=Rt(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof g=="number"&&(h=i==="end"?g*-1:g),c?{x:h*u,y:m*l}:{x:m*l,y:h*u}}const Lm=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,c=await Wm(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:a}}}}},$m=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:b,y:w}=v;return{x:b,y:w}}},...l}=Rt(e,t),u={x:n,y:r},d=await s.detectOverflow(t,l),m=ot(ze(o)),h=ns(m);let g=u[h],y=u[m];if(a){const v=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=g+d[v],S=g-d[b];g=Wo(w,g,S)}if(i){const v=m==="y"?"top":"left",b=m==="y"?"bottom":"right",w=y+d[v],S=y-d[b];y=Wo(w,y,S)}const x=c.fn({...t,[h]:g,[m]:y});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:a,[m]:i}}}}}},Bm=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:c=!0,crossAxis:l=!0}=Rt(e,t),u={x:n,y:r},d=ot(o),m=ns(d);let h=u[m],g=u[d];const y=Rt(i,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const w=m==="y"?"height":"width",S=s.reference[m]-s.floating[w]+x.mainAxis,C=s.reference[m]+s.reference[w]-x.mainAxis;h<S?h=S:h>C&&(h=C)}if(l){var v,b;const w=m==="y"?"width":"height",S=oc.has(ze(o)),C=s.reference[d]-s.floating[w]+(S&&((v=a.offset)==null?void 0:v[d])||0)+(S?0:x.crossAxis),k=s.reference[d]+s.reference[w]+(S?0:((b=a.offset)==null?void 0:b[d])||0)-(S?x.crossAxis:0);g<C?g=C:g>k&&(g=k)}return{[m]:h,[d]:g}}}},Ym=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:c=()=>{},...l}=Rt(e,t),u=await a.detectOverflow(t,l),d=ze(o),m=Vt(o),h=ot(o)==="y",{width:g,height:y}=s.floating;let x,v;d==="top"||d==="bottom"?(x=d,v=m===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(v=d,x=m==="end"?"top":"bottom");const b=y-u.top-u.bottom,w=g-u.left-u.right,S=Mn(y-u[x],b),C=Mn(g-u[v],w),k=!t.middlewareData.shift;let T=S,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=b),k&&!m){const M=Qe(u.left,0),R=Qe(u.right,0),_=Qe(u.top,0),E=Qe(u.bottom,0);h?N=g-2*(M!==0||R!==0?M+R:Qe(u.left,u.right)):T=y-2*(_!==0||E!==0?_+E:Qe(u.top,u.bottom))}await c({...t,availableWidth:N,availableHeight:T});const j=await a.getDimensions(i.floating);return g!==j.width||y!==j.height?{reset:{rects:!0}}:{}}}};function sc(e){const t=ft(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ge(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=Dr(n)!==s||Dr(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function is(e){return Re(e)?e:e.contextElement}function kn(e){const t=is(e);if(!Ge(t))return xt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sc(t);let a=(s?Dr(n.width):n.width)/r,i=(s?Dr(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const Hm=xt(0);function ac(e){const t=st(e);return!Go()||!t.visualViewport?Hm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Um(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==st(e)?!1:t}function rn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=is(e);let a=xt(1);t&&(r?Re(r)&&(a=kn(r)):a=kn(e));const i=Um(s,n,r)?ac(s):xt(0);let c=(o.left+i.x)/a.x,l=(o.top+i.y)/a.y,u=o.width/a.x,d=o.height/a.y;if(s){const m=st(s),h=r&&Re(r)?st(r):r;let g=m,y=Ys(g);for(;y&&r&&h!==g;){const x=kn(y),v=y.getBoundingClientRect(),b=ft(y),w=v.left+(y.clientLeft+parseFloat(b.paddingLeft))*x.x,S=v.top+(y.clientTop+parseFloat(b.paddingTop))*x.y;c*=x.x,l*=x.y,u*=x.x,d*=x.y,c+=w,l+=S,g=st(y),y=Ys(g)}}return Ar({width:u,height:d,x:c,y:l})}function Br(e,t){const n=$r(e).scrollLeft;return t?t.left+n:rn(Pt(e)).left+n}function ic(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Br(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Vm(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=Pt(r),i=t?zo(t.floating):!1;if(r===a||i&&s)return n;let c={scrollLeft:0,scrollTop:0},l=xt(1);const u=xt(0),d=Ge(r);if((d||!d&&!s)&&((tr(r)!=="body"||nr(a))&&(c=$r(r)),d)){const h=rn(r);l=kn(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const m=a&&!d&&!s?ic(a,c):xt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+m.x,y:n.y*l.y-c.scrollTop*l.y+u.y+m.y}}function qm(e){return Array.from(e.getClientRects())}function Gm(e){const t=Pt(e),n=$r(e),r=e.ownerDocument.body,o=Qe(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Qe(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Br(e);const i=-n.scrollTop;return ft(r).direction==="rtl"&&(a+=Qe(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const ya=25;function zm(e,t){const n=st(e),r=Pt(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,c=0;if(o){s=o.width,a=o.height;const u=Go();(!u||u&&t==="fixed")&&(i=o.offsetLeft,c=o.offsetTop)}const l=Br(r);if(l<=0){const u=r.ownerDocument,d=u.body,m=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-d.clientWidth-h);g<=ya&&(s-=g)}else l<=ya&&(s+=l);return{width:s,height:a,x:i,y:c}}function Km(e,t){const n=rn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ge(e)?kn(e):xt(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,c=o*s.x,l=r*s.y;return{width:a,height:i,x:c,y:l}}function ba(e,t,n){let r;if(t==="viewport")r=zm(e,n);else if(t==="document")r=Gm(Pt(e));else if(Re(t))r=Km(t,n);else{const o=ac(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ar(r)}function cc(e,t){const n=Cn(e);return n===t||!Re(n)||Zt(n)?!1:ft(n).position==="fixed"||cc(n,t)}function Xm(e,t){const n=t.get(e);if(n)return n;let r=xn(e,[],!1).filter(i=>Re(i)&&tr(i)!=="body"),o=null;const s=ft(e).position==="fixed";let a=s?Cn(e):e;for(;Re(a)&&!Zt(a);){const i=ft(a),c=ui(a);!c&&i.position==="fixed"&&(o=null),(s?!c&&!o:!c&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||nr(a)&&!c&&cc(e,a))?r=r.filter(u=>u!==a):o=i,a=Cn(a)}return t.set(e,r),r}function Jm(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?zo(t)?[]:Xm(t,this._c):[].concat(n),r],i=ba(t,a[0],o);let c=i.top,l=i.right,u=i.bottom,d=i.left;for(let m=1;m<a.length;m++){const h=ba(t,a[m],o);c=Qe(h.top,c),l=Mn(h.right,l),u=Mn(h.bottom,u),d=Qe(h.left,d)}return{width:l-d,height:u-c,x:d,y:c}}function Qm(e){const{width:t,height:n}=sc(e);return{width:t,height:n}}function Zm(e,t,n){const r=Ge(t),o=Pt(t),s=n==="fixed",a=rn(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const c=xt(0);function l(){c.x=Br(o)}if(r||!r&&!s)if((tr(t)!=="body"||nr(o))&&(i=$r(t)),r){const h=rn(t,!0,s,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&l();s&&!r&&o&&l();const u=o&&!r&&!s?ic(o,i):xt(0),d=a.left+i.scrollLeft-c.x-u.x,m=a.top+i.scrollTop-c.y-u.y;return{x:d,y:m,width:a.width,height:a.height}}function ko(e){return ft(e).position==="static"}function xa(e,t){if(!Ge(e)||ft(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Pt(e)===n&&(n=n.ownerDocument.body),n}function lc(e,t){const n=st(e);if(zo(e))return n;if(!Ge(e)){let o=Cn(e);for(;o&&!Zt(o);){if(Re(o)&&!ko(o))return o;o=Cn(o)}return n}let r=xa(e,t);for(;r&&Yu(r)&&ko(r);)r=xa(r,t);return r&&Zt(r)&&ko(r)&&!ui(r)?n:r||Hu(e)||n}const eh=async function(e){const t=this.getOffsetParent||lc,n=this.getDimensions,r=await n(e.floating);return{reference:Zm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function th(e){return ft(e).direction==="rtl"}const nh={convertOffsetParentRelativeRectToViewportRelativeRect:Vm,getDocumentElement:Pt,getClippingRect:Jm,getOffsetParent:lc,getElementRects:eh,getClientRects:qm,getDimensions:Qm,getScale:kn,isElement:Re,isRTL:th};function uc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rh(e,t){let n=null,r;const o=Pt(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),s();const l=e.getBoundingClientRect(),{left:u,top:d,width:m,height:h}=l;if(i||t(),!m||!h)return;const g=wr(d),y=wr(o.clientWidth-(u+m)),x=wr(o.clientHeight-(d+h)),v=wr(u),w={rootMargin:-g+"px "+-y+"px "+-x+"px "+-v+"px",threshold:Qe(0,Mn(1,c))||1};let S=!0;function C(k){const T=k[0].intersectionRatio;if(T!==c){if(!S)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!uc(l,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),s}function wa(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=is(e),u=o||s?[...l?xn(l):[],...t?xn(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=l&&i?rh(l,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(v=>{let[b]=v;b&&b.target===l&&h&&t&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),l&&!c&&h.observe(l),t&&h.observe(t));let g,y=c?rn(e):null;c&&x();function x(){const v=rn(e);y&&!uc(y,v)&&n(),y=v,g=requestAnimationFrame(x)}return n(),()=>{var v;u.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),d?.(),(v=h)==null||v.disconnect(),h=null,c&&cancelAnimationFrame(g)}}const oh=Lm,sh=$m,ah=jm,ih=Ym,ch=Fm,lh=Bm,uh=(e,t,n)=>{const r=new Map,o={platform:nh,...n},s={...o.platform,_c:r};return Im(e,t,{...o,platform:s})};var dh=typeof document<"u",fh=function(){},Mr=dh?f.useLayoutEffect:fh;function Wr(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,o;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(!Wr(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Wr(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function dc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function va(e,t){const n=dc(e);return Math.round(t*n)/n}function So(e){const t=f.useRef(e);return Mr(()=>{t.current=e}),t}function mh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:c,open:l}=e,[u,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=f.useState(r);Wr(m,r)||h(r);const[g,y]=f.useState(null),[x,v]=f.useState(null),b=f.useCallback(O=>{O!==k.current&&(k.current=O,y(O))},[]),w=f.useCallback(O=>{O!==T.current&&(T.current=O,v(O))},[]),S=s||g,C=a||x,k=f.useRef(null),T=f.useRef(null),N=f.useRef(u),j=c!=null,M=So(c),R=So(o),_=So(l),E=f.useCallback(()=>{if(!k.current||!T.current)return;const O={placement:t,strategy:n,middleware:m};R.current&&(O.platform=R.current),uh(k.current,T.current,O).then(A=>{const U={...A,isPositioned:_.current!==!1};F.current&&!Wr(N.current,U)&&(N.current=U,Yt.flushSync(()=>{d(U)}))})},[m,t,n,R,_]);Mr(()=>{l===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(O=>({...O,isPositioned:!1})))},[l]);const F=f.useRef(!1);Mr(()=>(F.current=!0,()=>{F.current=!1}),[]),Mr(()=>{if(S&&(k.current=S),C&&(T.current=C),S&&C){if(M.current)return M.current(S,C,E);E()}},[S,C,E,M,j]);const P=f.useMemo(()=>({reference:k,floating:T,setReference:b,setFloating:w}),[b,w]),B=f.useMemo(()=>({reference:S,floating:C}),[S,C]),V=f.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const A=va(B.floating,u.x),U=va(B.floating,u.y);return i?{...O,transform:"translate("+A+"px, "+U+"px)",...dc(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:U}},[n,i,B.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:E,refs:P,elements:B,floatingStyles:V}),[u,E,P,B,V])}const hh=(e,t)=>{const n=oh(e);return{name:n.name,fn:n.fn,options:[e,t]}},gh=(e,t)=>{const n=sh(e);return{name:n.name,fn:n.fn,options:[e,t]}},ph=(e,t)=>({fn:lh(e).fn,options:[e,t]}),yh=(e,t)=>{const n=ah(e);return{name:n.name,fn:n.fn,options:[e,t]}},bh=(e,t)=>{const n=ih(e);return{name:n.name,fn:n.fn,options:[e,t]}},xh=(e,t)=>{const n=ch(e);return{name:n.name,fn:n.fn,options:[e,t]}},wh={intentional:"onClick",sloppy:"onPointerDown"};function vh(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function fc(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("referenceElement"),a=n.useState("domReferenceElement"),{onOpenChange:i,dataRef:c}=n.context,{enabled:l=!0,escapeKey:u=!0,outsidePress:d=!0,outsidePressEvent:m="sloppy",referencePress:h=!1,referencePressEvent:g="sloppy",ancestorScroll:y=!1,bubbles:x,externalTree:v}=t,b=In(v),w=me(typeof d=="function"?d:()=>!1),S=typeof d=="function"?w:d,C=f.useRef(!1),{escapeKey:k,outsidePress:T}=vh(x),N=f.useRef(null),j=nn(),M=nn(),R=me(()=>{M.clear(),c.current.insideReactTree=!1}),_=f.useRef(!1),E=f.useRef(""),F=me(D=>{E.current=D.pointerType}),P=me(()=>{const D=E.current,ae=D==="pen"||!D?"mouse":D,q=typeof m=="function"?m():m;return typeof q=="string"?q:q[ae]}),B=me(D=>{if(!r||!l||!u||D.key!=="Escape"||_.current)return;const ae=c.current.floatingContext?.nodeId,q=b?en(b.nodesRef.current,ae):[];if(!k&&q.length>0){let J=!0;if(q.forEach(ie=>{ie.context?.open&&!ie.context.dataRef.current.__escapeKeyBubbles&&(J=!1)}),!J)return}const ye=Lf(D)?D.nativeEvent:D,$=_e(Ji,ye);n.setOpen(!1,$),!k&&!$.isPropagationAllowed&&D.stopPropagation()}),V=me(D=>{const ae=P();return ae==="intentional"&&D.type!=="click"||ae==="sloppy"&&D.type==="click"}),O=me(()=>{c.current.insideReactTree=!0,M.start(0,R)}),A=me((D,ae=!1)=>{if(V(D)){R();return}if(c.current.insideReactTree){R();return}if(P()==="intentional"&&ae||typeof S=="function"&&!S(D))return;const q=Je(D),ye=`[${Xn("inert")}]`,$=Ye(n.select("floatingElement")).querySelectorAll(ye),J=n.context.triggerElements;if(q&&(J.hasElement(q)||J.hasMatchingElement(Q=>ve(Q,q))))return;let ie=Re(q)?q:null;for(;ie&&!Zt(ie);){const Q=Cn(ie);if(Zt(Q)||!Re(Q))break;ie=Q}if($.length&&Re(q)&&!Ff(q)&&!ve(q,n.select("floatingElement"))&&Array.from($).every(Q=>!ve(ie,Q)))return;if(Ge(q)&&!("touches"in D)){const Q=Zt(q),De=ft(q),ke=/auto|scroll/,je=Q||ke.test(De.overflowX),pe=Q||ke.test(De.overflowY),Ke=je&&q.clientWidth>0&&q.scrollWidth>q.clientWidth,Fe=pe&&q.clientHeight>0&&q.scrollHeight>q.clientHeight,Se=De.direction==="rtl",Ue=Fe&&(Se?D.offsetX<=q.offsetWidth-q.clientWidth:D.offsetX>q.clientWidth),He=Ke&&D.offsetY>q.clientHeight;if(Ue||He)return}const he=c.current.floatingContext?.nodeId,de=b&&en(b.nodesRef.current,he).some(Q=>ct(D,Q.context?.elements.floating));if(ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement"))||de)return;const se=b?en(b.nodesRef.current,he):[];if(se.length>0){let Q=!0;if(se.forEach(De=>{De.context?.open&&!De.context.dataRef.current.__outsidePressBubbles&&(Q=!1)}),!Q)return}n.setOpen(!1,_e(Xi,D)),R()}),U=me(D=>{P()!=="sloppy"||D.pointerType==="touch"||!n.select("open")||!l||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement"))||A(D)}),Y=me(D=>{if(P()!=="sloppy"||!n.select("open")||!l||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement")))return;const ae=D.touches[0];ae&&(N.current={startTime:Date.now(),startX:ae.clientX,startY:ae.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},j.start(1e3,()=>{N.current&&(N.current.dismissOnTouchEnd=!1,N.current.dismissOnMouseDown=!1)}))}),Z=me(D=>{const ae=Je(D);function q(){Y(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),H=me(D=>{const ae=C.current;if(C.current=!1,j.clear(),D.type==="mousedown"&&N.current&&!N.current.dismissOnMouseDown)return;const q=Je(D);function ye(){D.type==="pointerdown"?U(D):A(D,ae),q?.removeEventListener(D.type,ye)}q?.addEventListener(D.type,ye)}),W=me(D=>{if(P()!=="sloppy"||!N.current||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement")))return;const ae=D.touches[0];if(!ae)return;const q=Math.abs(ae.clientX-N.current.startX),ye=Math.abs(ae.clientY-N.current.startY),$=Math.sqrt(q*q+ye*ye);$>5&&(N.current.dismissOnTouchEnd=!0),$>10&&(A(D),j.clear(),N.current=null)}),z=me(D=>{const ae=Je(D);function q(){W(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),X=me(D=>{P()!=="sloppy"||!N.current||ct(D,n.select("floatingElement"))||ct(D,n.select("domReferenceElement"))||(N.current.dismissOnTouchEnd&&A(D),j.clear(),N.current=null)}),oe=me(D=>{const ae=Je(D);function q(){X(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)});f.useEffect(()=>{if(!r||!l)return;c.current.__escapeKeyBubbles=k,c.current.__outsidePressBubbles=T;const D=new Ht;function ae(ie){n.setOpen(!1,_e(vm,ie))}function q(){D.clear(),_.current=!0}function ye(){D.start(Go()?5:0,()=>{_.current=!1})}const $=Ye(o);$.addEventListener("pointerdown",F,!0),u&&($.addEventListener("keydown",B),$.addEventListener("compositionstart",q),$.addEventListener("compositionend",ye)),S&&($.addEventListener("click",H,!0),$.addEventListener("pointerdown",H,!0),$.addEventListener("touchstart",Z,!0),$.addEventListener("touchmove",z,!0),$.addEventListener("touchend",oe,!0),$.addEventListener("mousedown",H,!0));let J=[];return y&&(Re(a)&&(J=xn(a)),Re(o)&&(J=J.concat(xn(o))),!Re(s)&&s&&s.contextElement&&(J=J.concat(xn(s.contextElement)))),J=J.filter(ie=>ie!==$.defaultView?.visualViewport),J.forEach(ie=>{ie.addEventListener("scroll",ae,{passive:!0})}),()=>{$.removeEventListener("pointerdown",F,!0),u&&($.removeEventListener("keydown",B),$.removeEventListener("compositionstart",q),$.removeEventListener("compositionend",ye)),S&&($.removeEventListener("click",H,!0),$.removeEventListener("pointerdown",H,!0),$.removeEventListener("touchstart",Z,!0),$.removeEventListener("touchmove",z,!0),$.removeEventListener("touchend",oe,!0),$.removeEventListener("mousedown",H,!0)),J.forEach(ie=>{ie.removeEventListener("scroll",ae)}),D.clear(),C.current=!1}},[c,o,s,a,u,S,r,i,y,l,k,T,B,A,H,U,Z,z,oe,F,n]),f.useEffect(R,[S,R]);const be=f.useMemo(()=>({onKeyDown:B,...h&&{[wh[g]]:D=>{n.setOpen(!1,_e(Bt,D.nativeEvent))},...g!=="intentional"&&{onClick(D){n.setOpen(!1,_e(Bt,D.nativeEvent))}}}}),[B,n,h,g]),Oe=me(D=>{const ae=Je(D.nativeEvent);!ve(n.select("floatingElement"),ae)||D.button!==0||(C.current=!0)}),xe=me(D=>{!r||!l||D.button!==0||(C.current=!0)}),Le=f.useMemo(()=>({onKeyDown:B,onPointerDown:Oe,onMouseDown:Oe,onMouseUp:Oe,onClickCapture:O,onMouseDownCapture(D){O(),xe(D)},onPointerDownCapture(D){O(),xe(D)},onMouseUpCapture:O,onTouchEndCapture:O,onTouchMoveCapture:O}),[B,Oe,O,xe]);return f.useMemo(()=>l?{reference:be,floating:Le,trigger:be}:{},[l,be,Le])}const kh={open:ge(e=>e.open),domReferenceElement:ge(e=>e.domReferenceElement),referenceElement:ge(e=>e.positionReference??e.referenceElement),floatingElement:ge(e=>e.floatingElement),floatingId:ge(e=>e.floatingId)};class cs extends Zo{constructor(t){const{nested:n,noEmit:r,onOpenChange:o,triggerElements:s,...a}=t;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:Gi(),nested:n,noEmit:r,triggerElements:s},kh)}setOpen=(t,n)=>{if((!t||!this.state.open||Ii(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 Sh(e,t=!1,n=!1){const[r,o]=f.useState(e&&t?"idle":void 0),[s,a]=f.useState(e);return e&&!s&&(a(!0),o("starting")),!e&&s&&r!=="ending"&&!n&&o("ending"),!e&&!s&&r==="ending"&&o(void 0),Ee(()=>{if(!e&&s&&r!=="ending"&&n){const i=ht.request(()=>{o("ending")});return()=>{ht.cancel(i)}}},[e,s,r,n]),Ee(()=>{if(!e||t)return;const i=ht.request(()=>{o(void 0)});return()=>{ht.cancel(i)}},[t,e]),Ee(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&o("starting");const i=ht.request(()=>{o("idle")});return()=>{ht.cancel(i)}},[t,e,s,o,r]),f.useMemo(()=>({mounted:s,setMounted:a,transitionStatus:r}),[s,r])}let Jn=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const Ch={[Jn.startingStyle]:""},Eh={[Jn.endingStyle]:""},Yr={transitionStatus(e){return e==="starting"?Ch:e==="ending"?Eh:null}};function mc(e,t=!1,n=!0){const r=ts();return me((o,s=null)=>{r.cancel();function a(){Yt.flushSync(o)}const i=Tt(e);if(i==null)return;const c=i;if(typeof c.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)o();else{let l=function(){const d=Jn.startingStyle;if(!c.hasAttribute(d)){r.request(u);return}const m=new MutationObserver(()=>{c.hasAttribute(d)||(m.disconnect(),u())});m.observe(c,{attributes:!0,attributeFilter:[d]}),s?.addEventListener("abort",()=>m.disconnect(),{once:!0})},u=function(){Promise.all(c.getAnimations().map(d=>d.finished)).then(()=>{s?.aborted||a()}).catch(()=>{const d=c.getAnimations();if(n){if(s?.aborted)return;a()}else d.length>0&&d.some(m=>m.pending||m.playState!=="finished")&&u()})};if(t){l();return}r.request(u)}})}function ls(e){const{enabled:t=!0,open:n,ref:r,onComplete:o}=e,s=me(o),a=mc(r,n,!1);f.useEffect(()=>{if(!t)return;const i=new AbortController;return a(s,i.signal),()=>{i.abort()}},[t,n,s,a])}function Mh(e,t){const n=f.useRef(null),r=f.useRef(null);return f.useCallback(o=>{if(e!==void 0){if(n.current!==null){const s=n.current,a=r.current,i=t.context.triggerElements.getById(s);a&&i===a&&t.context.triggerElements.delete(s),n.current=null,r.current=null}o!==null&&(n.current=e,r.current=o,t.context.triggerElements.add(e,o))}},[t,e])}function Th(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Mh(e,n),a=me(i=>{if(s(i),!i||!n.select("open"))return;const c=n.select("activeTriggerId");if(c===e){n.update({activeTriggerElement:i,...r});return}c==null&&n.update({activeTriggerId:e,activeTriggerElement:i,...r})});return Ee(()=>{o&&n.update({activeTriggerElement:t.current,...r})},[o,n,t,...Object.values(r)]),{registerTrigger:a,isMountedByThisTrigger:o}}function hc(e){const t=e.useState("open");Ee(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,o]=n.value;e.update({activeTriggerId:r,activeTriggerElement:o})}}},[t,e])}function gc(e,t,n){const{mounted:r,setMounted:o,transitionStatus:s}=Sh(e);t.useSyncedValues({mounted:r,transitionStatus:s});const a=me(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),i=t.useState("preventUnmountingOnClose");return ls({enabled:!i,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:s}}class Hr{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 Oh(){return new cs({open:!1,floatingElement:null,referenceElement:null,triggerElements:new Hr,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function pc(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Oh(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:$t,inactiveTriggerProps:$t,popupProps:$t}}const yc={open:ge(e=>e.open),mounted:ge(e=>e.mounted),transitionStatus:ge(e=>e.transitionStatus),floatingRootContext:ge(e=>e.floatingRootContext),preventUnmountingOnClose:ge(e=>e.preventUnmountingOnClose),payload:ge(e=>e.payload),activeTriggerId:ge(e=>e.activeTriggerId),activeTriggerElement:ge(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:ge((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:ge((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:ge(e=>e.popupProps),popupElement:ge(e=>e.popupElement),positionerElement:ge(e=>e.positionerElement)};function Nh(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,o=_n(),s=sn()!=null,a=Ut(()=>new cs({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new Hr,floatingId:o,nested:s,noEmit:e.noEmit||!1})).current;return Ee(()=>{const i={open:t,floatingId:o};r.reference!==void 0&&(i.referenceElement=r.reference,i.domReferenceElement=Re(r.reference)?r.reference:null),r.floating!==void 0&&(i.floatingElement=r.floating),a.update(i)},[t,o,r.reference,r.floating,a]),a.context.onOpenChange=n,a.context.nested=s,a.context.noEmit=e.noEmit||!1,a}function Rh(e={}){const{nodeId:t,externalTree:n}=e,r=Nh(e),o=e.rootContext||r,s={reference:o.useState("referenceElement"),floating:o.useState("floatingElement"),domReference:o.useState("domReferenceElement")},[a,i]=f.useState(null),c=f.useRef(null),l=In(n);Ee(()=>{s.domReference&&(c.current=s.domReference)},[s.domReference]);const u=mh({...e,elements:{...s,...a&&{reference:a}}}),d=f.useCallback(T=>{const N=Re(T)?{getBoundingClientRect:()=>T.getBoundingClientRect(),getClientRects:()=>T.getClientRects(),contextElement:T}:T;i(N),u.refs.setReference(N)},[u.refs]),[m,h]=f.useState(null),[g,y]=f.useState(null);o.useSyncedValue("referenceElement",m),o.useSyncedValue("domReferenceElement",Re(m)?m:null),o.useSyncedValue("floatingElement",g);const x=f.useCallback(T=>{(Re(T)||T===null)&&(c.current=T,h(T)),(Re(u.refs.reference.current)||u.refs.reference.current===null||T!==null&&!Re(T))&&u.refs.setReference(T)},[u.refs,h]),v=f.useCallback(T=>{y(T),u.refs.setFloating(T)},[u.refs]),b=f.useMemo(()=>({...u.refs,setReference:x,setFloating:v,setPositionReference:d,domReference:c}),[u.refs,x,v,d]),w=f.useMemo(()=>({...u.elements,domReference:s.domReference}),[u.elements,s.domReference]),S=o.useState("open"),C=o.useState("floatingId"),k=f.useMemo(()=>({...u,dataRef:o.context.dataRef,open:S,onOpenChange:o.setOpen,events:o.context.events,floatingId:C,refs:b,elements:w,nodeId:t,rootStore:o}),[u,b,w,t,o,S,C]);return Ee(()=>{o.context.dataRef.current.floatingContext=k;const T=l?.nodesRef.current.find(N=>N.id===t);T&&(T.context=k)}),f.useMemo(()=>({...u,context:k,refs:b,elements:w,rootStore:o}),[u,b,w,k,o])}function bc(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:o}=e,s=_n(),a=sn()!=null,i=t.useState("open"),c=t.useState("activeTriggerElement"),l=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=Ut(()=>new cs({open:i,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:o,floatingId:s,nested:a,noEmit:n})).current;return Ee(()=>{const m={open:i,floatingId:s,referenceElement:c,floatingElement:l};Re(c)&&(m.domReferenceElement=c),d.state.positionReference===d.state.referenceElement&&(m.positionReference=c),d.update(m)},[i,s,c,l,d]),d.context.onOpenChange=o,d.context.nested=a,d.context.noEmit=n,d}const Yo=Xn("safe-polygon"),Dh=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Ai}`;function Ph(e){return e?!!e.closest(Dh):!1}function xc(e){const t=f.useRef(void 0),n=f.useRef(!1),r=f.useRef(void 0),o=f.useRef(!0),s=f.useRef(!1),a=f.useRef(()=>{}),i=f.useRef(!1),c=nn(),l=nn(),u=f.useRef(void 0);return f.useMemo(()=>{const d=e.context.dataRef.current;return d.hoverInteractionState||(d.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:o,performedPointerEventsMutationRef:s,unbindMouseMoveRef:a,restTimeoutPendingRef:i,openChangeTimeout:c,restTimeout:l,handleCloseOptionsRef:u}),d.hoverInteractionState},[e,t,n,r,o,s,a,i,c,l,u])}const Ah=new Set(["click","mousedown"]);function _h(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("domReferenceElement"),{dataRef:a}=n.context,{enabled:i=!0,closeDelay:c=0,externalTree:l}=t,{pointerTypeRef:u,interactedInsideRef:d,handlerRef:m,performedPointerEventsMutationRef:h,unbindMouseMoveRef:g,restTimeoutPendingRef:y,openChangeTimeout:x,handleCloseOptionsRef:v}=xc(n),b=In(l),w=sn(),S=me(()=>d.current?!0:a.current.openEvent?Ah.has(a.current.openEvent.type):!1),C=me(()=>{const M=a.current.openEvent?.type;return M?.includes("mouse")&&M!=="mousedown"}),k=f.useCallback((M,R=!0)=>{const _=Ih(c,u.current);_&&!m.current?x.start(_,()=>n.setOpen(!1,_e(Ze,M))):R&&(x.clear(),n.setOpen(!1,_e(Ze,M)))},[c,m,n,u,x]),T=me(()=>{g.current(),m.current=void 0}),N=me(()=>{if(h.current){const M=Ye(o).body;M.style.pointerEvents="",M.removeAttribute(Yo),h.current=!1}}),j=me(M=>{const R=Je(M);if(!Ph(R)){d.current=!1;return}d.current=!0});Ee(()=>{r||(u.current=void 0,y.current=!1,d.current=!1,T(),N())},[r,u,y,d,T,N]),f.useEffect(()=>()=>{T()},[T]),f.useEffect(()=>N,[N]),Ee(()=>{if(i&&r&&v.current?.blockPointerEvents&&C()&&Re(s)&&o){h.current=!0;const M=Ye(o).body;M.setAttribute(Yo,"");const R=s,_=o,E=b?.nodesRef.current.find(F=>F.id===w)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),M.style.pointerEvents="none",R.style.pointerEvents="auto",_.style.pointerEvents="auto",()=>{M.style.pointerEvents="",R.style.pointerEvents="",_.style.pointerEvents=""}}},[i,r,s,o,v,C,b,w,h]),f.useEffect(()=>{if(!i)return;function M(F){if(S()||!a.current.floatingContext||!n.select("open"))return;const P=n.context.triggerElements;F.relatedTarget&&P.hasElement(F.relatedTarget)||(N(),T(),S()||k(F))}function R(F){x.clear(),N(),m.current?.(F),T()}function _(F){S()||k(F,!1)}const E=o;return E&&(E.addEventListener("mouseleave",M),E.addEventListener("mouseenter",R),E.addEventListener("mouseleave",_),E.addEventListener("pointerdown",j,!0)),()=>{E&&(E.removeEventListener("mouseleave",M),E.removeEventListener("mouseenter",R),E.removeEventListener("mouseleave",_),E.removeEventListener("pointerdown",j,!0))}})}function Ih(e,t){return t&&!En(t)?0:typeof e=="function"?e():e}function Co(e){return typeof e=="function"?e():e}const jh={current:null};function Fh(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:r,events:o}=n.context,{enabled:s=!0,delay:a=0,handleClose:i=null,mouseOnly:c=!1,restMs:l=0,move:u=!0,triggerElementRef:d=jh,externalTree:m,isActiveTrigger:h=!0}=t,g=In(m),{pointerTypeRef:y,interactedInsideRef:x,handlerRef:v,blockMouseMoveRef:b,performedPointerEventsMutationRef:w,unbindMouseMoveRef:S,restTimeoutPendingRef:C,openChangeTimeout:k,restTimeout:T,handleCloseOptionsRef:N}=xc(n),j=gt(i),M=gt(a),R=gt(l);h&&(N.current=j.current?.__options);const _=me(()=>x.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=f.useCallback((V,O=!0)=>{const A=bo(M.current,"close",y.current);A&&!v.current?k.start(A,()=>n.setOpen(!1,_e(Ze,V))):O&&(k.clear(),n.setOpen(!1,_e(Ze,V)))},[M,v,n,y,k]),F=me(()=>{S.current(),v.current=void 0}),P=me(()=>{if(w.current){const V=Ye(n.select("domReferenceElement")).body;V.style.pointerEvents="",V.removeAttribute(Yo),w.current=!1}});f.useEffect(()=>{if(!s)return;function V(O){O.open||(k.clear(),T.clear(),b.current=!0,C.current=!1)}return o.on("openchange",V),()=>{o.off("openchange",V)}},[s,o,k,T,b,C]);const B=me(V=>{if(_()||!r.current.floatingContext)return;const O=n.context.triggerElements;if(V.relatedTarget&&O.hasElement(V.relatedTarget))return;const A=d.current;j.current?.({...r.current.floatingContext,tree:g,x:V.clientX,y:V.clientY,onClose(){P(),F(),!_()&&A===n.select("domReferenceElement")&&E(V)}})(V)});return f.useEffect(()=>{if(!s)return;const V=d.current??(h?n.select("domReferenceElement"):null);if(!Re(V))return;function O(Y){if(k.clear(),b.current=!1,c&&!En(y.current)||Co(R.current)>0&&!bo(M.current,"open"))return;const Z=bo(M.current,"open",y.current),H=n.select("domReferenceElement"),W=n.context.triggerElements,z=(W.hasElement(Y.target)||W.hasMatchingElement(Oe=>ve(Oe,Y.target)))&&(!H||!ve(H,Y.target)),X=Y.currentTarget??null,oe=n.select("open"),be=!oe||z;z&&oe?n.setOpen(!0,_e(Ze,Y,X)):Z?k.start(Z,()=>{be&&n.setOpen(!0,_e(Ze,Y,X))}):be&&n.setOpen(!0,_e(Ze,Y,X))}function A(Y){if(_()){P();return}S.current();const Z=n.select("domReferenceElement"),H=Ye(Z);T.clear(),C.current=!1;const W=n.context.triggerElements;if(Y.relatedTarget&&W.hasElement(Y.relatedTarget))return;if(j.current&&r.current.floatingContext){n.select("open")||k.clear();const X=d.current;v.current=j.current({...r.current.floatingContext,tree:g,x:Y.clientX,y:Y.clientY,onClose(){P(),F(),!_()&&X===n.select("domReferenceElement")&&E(Y,!0)}});const oe=v.current;oe(Y),H.addEventListener("mousemove",oe),S.current=()=>{H.removeEventListener("mousemove",oe)};return}(y.current!=="touch"||!ve(n.select("floatingElement"),Y.relatedTarget))&&E(Y)}function U(Y){B(Y)}return n.select("open")&&V.addEventListener("mouseleave",U),u&&V.addEventListener("mousemove",O,{once:!0}),V.addEventListener("mouseenter",O),V.addEventListener("mouseleave",A),()=>{V.removeEventListener("mouseleave",U),u&&V.removeEventListener("mousemove",O),V.removeEventListener("mouseenter",O),V.removeEventListener("mouseleave",A)}},[F,P,b,r,M,E,n,s,j,B,h,_,c,u,y,R,T,C,k,d,g,S,v]),f.useMemo(()=>{function V(O){y.current=O.pointerType}return{onPointerDown:V,onPointerEnter:V,onMouseMove(O){const{nativeEvent:A}=O,U=O.currentTarget,Y=n.select("domReferenceElement"),Z=n.context.triggerElements,H=n.select("open"),W=(Z.hasElement(O.target)||Z.hasMatchingElement(X=>ve(X,O.target)))&&(!Y||!ve(Y,O.target));if(c&&!En(y.current)||H&&!W||Co(R.current)===0||!W&&C.current&&O.movementX**2+O.movementY**2<2)return;T.clear();function z(){if(C.current=!1,_())return;const X=n.select("open");!b.current&&(!X||W)&&n.setOpen(!0,_e(Ze,A,U))}y.current==="touch"?Yt.flushSync(()=>{z()}):W&&H?z():(C.current=!0,T.start(Co(R.current),z))}}},[b,_,c,n,y,R,T,C])}function us(e=[]){const t=e.map(l=>l?.reference),n=e.map(l=>l?.floating),r=e.map(l=>l?.item),o=e.map(l=>l?.trigger),s=f.useCallback(l=>Sr(l,e,"reference"),t),a=f.useCallback(l=>Sr(l,e,"floating"),n),i=f.useCallback(l=>Sr(l,e,"item"),r),c=f.useCallback(l=>Sr(l,e,"trigger"),o);return f.useMemo(()=>({getReferenceProps:s,getFloatingProps:a,getItemProps:i,getTriggerProps:c}),[s,a,i,c])}function Sr(e,t,n){const r=new Map,o=n==="item",s={};n==="floating"&&(s.tabIndex=-1,s[jo]="");for(const a in e)o&&e&&(a===Di||a===Pi)||(s[a]=e[a]);for(let a=0;a<t.length;a+=1){let i;const c=t[a]?.[n];typeof c=="function"?i=e?c(e):null:i=c,i&&ka(s,i,o,r)}return ka(s,e,o,r),s}function ka(e,t,n,r){for(const o in t){const s=t[o];n&&(o===Di||o===Pi)||(o.startsWith("on")?(r.has(o)||r.set(o,[]),typeof s=="function"&&(r.get(o)?.push(s),e[o]=(...a)=>r.get(o)?.map(i=>i(...a)).find(i=>i!==void 0))):e[o]=s)}}const Wh=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function wc(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingId"),s=n.useState("domReferenceElement"),a=n.useState("floatingElement"),{enabled:i=!0,role:c="dialog"}=t,l=_n(),u=s?.id||l,d=f.useMemo(()=>Fo(a)?.id||o,[a,o]),m=Wh.get(c)??c,g=sn()!=null,y=f.useMemo(()=>m==="tooltip"||c==="label"?$t:{"aria-haspopup":m==="alertdialog"?"dialog":m,"aria-expanded":"false",...m==="listbox"&&{role:"combobox"},...m==="menu"&&g&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[m,g,c]),x=f.useMemo(()=>m==="tooltip"||c==="label"?{[`aria-${c==="label"?"labelledby":"describedby"}`]:r?d:void 0}:{...y,"aria-expanded":r?"true":"false","aria-controls":r?d:void 0,...m==="menu"&&{id:u}},[m,d,r,u,c,y]),v=f.useMemo(()=>{const w={id:d,...m&&{role:m}};return m==="tooltip"||c==="label"?w:{...w,...m==="menu"&&{"aria-labelledby":u}}},[m,d,u,c]),b=f.useCallback(({active:w,selected:S})=>{const C={role:"option",...w&&{id:`${d}-fui-option`}};switch(c){case"select":case"combobox":return{...C,"aria-selected":S}}return{}},[d,c]);return f.useMemo(()=>i?{reference:x,floating:v,item:b,trigger:y}:{},[i,x,v,y,b])}function Sa(e,t){const[n,r]=e;let o=!1;const s=t.length;for(let a=0,i=s-1;a<s;i=a++){const[c,l]=t[a]||[0,0],[u,d]=t[i]||[0,0];l>=r!=d>=r&&n<=(u-c)*(r-l)/(d-l)+c&&(o=!o)}return o}function Lh(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function $h(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,o=new Ht;let s=!1,a=null,i=null,c=typeof performance<"u"?performance.now():0;function l(d,m){const h=performance.now(),g=h-c;if(a===null||i===null||g===0)return a=d,i=m,c=h,null;const y=d-a,x=m-i,b=Math.sqrt(y*y+x*x)/g;return a=d,i=m,c=h,b}const u=({x:d,y:m,placement:h,elements:g,onClose:y,nodeId:x,tree:v})=>function(w){function S(){o.clear(),y()}if(o.clear(),!g.domReference||!g.floating||h==null||d==null||m==null)return;const{clientX:C,clientY:k}=w,T=[C,k],N=Je(w),j=w.type==="mouseleave",M=ve(g.floating,N),R=ve(g.domReference,N),_=g.domReference.getBoundingClientRect(),E=g.floating.getBoundingClientRect(),F=h.split("-")[0],P=d>E.right-E.width/2,B=m>E.bottom-E.height/2,V=Lh(T,_),O=E.width>_.width,A=E.height>_.height,U=(O?_:E).left,Y=(O?_:E).right,Z=(A?_:E).top,H=(A?_:E).bottom;if(M&&(s=!0,!j))return;if(R&&(s=!1),R&&!j){s=!0;return}if(j&&Re(w.relatedTarget)&&ve(g.floating,w.relatedTarget)||v&&en(v.nodesRef.current,x).some(({context:X})=>X?.open))return;if(F==="top"&&m>=_.bottom-1||F==="bottom"&&m<=_.top+1||F==="left"&&d>=_.right-1||F==="right"&&d<=_.left+1)return S();let W=[];switch(F){case"top":W=[[U,_.top+1],[U,E.bottom-1],[Y,E.bottom-1],[Y,_.top+1]];break;case"bottom":W=[[U,E.top+1],[U,_.bottom-1],[Y,_.bottom-1],[Y,E.top+1]];break;case"left":W=[[E.right-1,H],[E.right-1,Z],[_.left+1,Z],[_.left+1,H]];break;case"right":W=[[_.right-1,H],[_.right-1,Z],[E.left+1,Z],[E.left+1,H]];break}function z([X,oe]){switch(F){case"top":{const be=[O?X+t/2:P?X+t*4:X-t*4,oe+t+1],Oe=[O?X-t/2:P?X+t*4:X-t*4,oe+t+1],xe=[[E.left,P||O?E.bottom-t:E.top],[E.right,P?O?E.bottom-t:E.top:E.bottom-t]];return[be,Oe,...xe]}case"bottom":{const be=[O?X+t/2:P?X+t*4:X-t*4,oe-t],Oe=[O?X-t/2:P?X+t*4:X-t*4,oe-t],xe=[[E.left,P||O?E.top+t:E.bottom],[E.right,P?O?E.top+t:E.bottom:E.top+t]];return[be,Oe,...xe]}case"left":{const be=[X+t+1,A?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X+t+1,A?oe-t/2:B?oe+t*4:oe-t*4];return[...[[B||A?E.right-t:E.left,E.top],[B?A?E.right-t:E.left:E.right-t,E.bottom]],be,Oe]}case"right":{const be=[X-t,A?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X-t,A?oe-t/2:B?oe+t*4:oe-t*4],xe=[[B||A?E.left+t:E.right,E.top],[B?A?E.left+t:E.right:E.left+t,E.bottom]];return[be,Oe,...xe]}default:return[]}}if(!Sa([C,k],W)){if(s&&!V)return S();if(!j&&r){const X=l(w.clientX,w.clientY);if(X!==null&&X<.1)return S()}Sa([C,k],z([d,m]))?!s&&r&&o.start(40,S):S()}};return u.__options={blockPointerEvents:n},u}function vc(e){return _n(e,"base-ui")}function Bh(e){const t=f.useRef(""),n=f.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:f.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o&&e(o,o.pointerType),e(o,t.current),t.current=""},[e]),onPointerDown:n}}function kc(e){const[t,n]=f.useState(null),r=me((i,c)=>{e||n(c||(Ri?"touch":""))}),o=f.useCallback(()=>{n(null)},[]),{onClick:s,onPointerDown:a}=Bh(r);return f.useMemo(()=>({openMethod:t,reset:o,triggerProps:{onClick:s,onPointerDown:a}}),[t,o,s,a])}let ut=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Jn.startingStyle]="startingStyle",e[e.endingStyle=Jn.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),Ho=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Yh={[Ho.popupOpen]:""},Hh={[Ho.popupOpen]:"",[Ho.pressed]:""},Uh={[ut.open]:""},Vh={[ut.closed]:""},qh={[ut.anchorHidden]:""},Gh={open(e){return e?Yh:null}},zh={open(e){return e?Hh:null}},or={open(e){return e?Uh:Vh},anchorHidden(e){return e?qh:null}};function Sc(e){return ci(19)?e:e?"true":void 0}let Ca={},Ea={},Ma="";function Kh(e){if(typeof document>"u")return!1;const t=an(e);return st(t).innerWidth-t.documentElement.clientWidth>0}function Xh(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=an(e).documentElement,o={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY};r.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return Object.assign(r.style,o),s===a}function Jh(e){const t=an(e),n=t.documentElement,r=t.body,o=nr(n)?n:r,s=o.style.overflow;return o.style.overflow="hidden",()=>{o.style.overflow=s}}function Qh(e){const t=an(e),n=t.documentElement,r=t.body,o=st(n);let s=0,a=0,i=!1;const c=ht.create();if(Df&&(o.visualViewport?.scale??1)!==1)return()=>{};function l(){const m=o.getComputedStyle(n),h=o.getComputedStyle(r),x=(m.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=n.scrollTop,a=n.scrollLeft,Ca={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ma=n.style.scrollBehavior,Ea={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 v=n.scrollHeight>n.clientHeight,b=n.scrollWidth>n.clientWidth,w=m.overflowY==="scroll"||h.overflowY==="scroll",S=m.overflowX==="scroll"||h.overflowX==="scroll",C=Math.max(0,o.innerWidth-r.clientWidth),k=Math.max(0,o.innerHeight-r.clientHeight),T=parseFloat(h.marginTop)+parseFloat(h.marginBottom),N=parseFloat(h.marginLeft)+parseFloat(h.marginRight),j=nr(n)?n:r;if(i=Xh(e),i){n.style.scrollbarGutter=x,j.style.overflowY="hidden",j.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:x,overflowY:"hidden",overflowX:"hidden"}),(v||w)&&(n.style.overflowY="scroll"),(b||S)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||k?`calc(100dvh - ${T+k}px)`:"100dvh",width:N||C?`calc(100vw - ${N+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=s,r.scrollLeft=a,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,Ca),Object.assign(r.style,Ea),i||(n.scrollTop=s,n.scrollLeft=a,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Ma)}function d(){u(),c.request(l)}return l(),o.addEventListener("resize",d),()=>{c.cancel(),u(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",d)}}class Zh{lockCount=0;restore=null;timeoutLock=Ht.create();timeoutUnlock=Ht.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=an(t).documentElement,o=st(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=li;return}const s=Ri||!Kh(t);this.restore=s?Jh(t):Qh(t)}}const eg=new Zh;function Cc(e=!0,t=null){Ee(()=>{if(e)return eg.acquire(t)},[e,t])}const tg=f.createContext(void 0);function ng(){return f.useContext(tg)?.direction??"ltr"}const rg=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d="real"}=Rt(e,t)||{};if(l==null)return{};const m=ji(u),h={x:n,y:r},g=os(o),y=rs(g),x=await a.getDimensions(l),v=g==="y",b=v?"top":"left",w=v?"bottom":"right",S=v?"clientHeight":"clientWidth",C=s.reference[y]+s.reference[g]-h[g]-s.floating[y],k=h[g]-s.reference[g],T=d==="real"?await a.getOffsetParent?.(l):i.floating;let N=i.floating[S]||s.floating[y];(!N||!await a.isElement?.(T))&&(N=i.floating[S]||s.floating[y]);const j=C/2-k/2,M=N/2-x[y]/2-1,R=Math.min(m[b],M),_=Math.min(m[w],M),E=R,F=N-x[y]-_,P=N/2-x[y]/2+j,B=Wo(E,P,F),V=!c.arrow&&Vt(o)!=null&&P!==B&&s.reference[y]/2-(P<E?R:_)-x[y]/2<0,O=V?P<E?P-E:P-F:0;return{[g]:h[g]+O,data:{[g]:B,centerOffset:P-B-O,...V&&{alignmentOffset:O}},reset:V}}}),og=(e,t)=>({...rg(e),options:[e,t]}),sg={name:"hide",async fn(e){const{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0;return{data:{referenceHidden:(await xh().fn(e)).data?.referenceHidden||s}}}},Tr={sideX:"left",sideY:"top"},ag={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:o},platform:s,strategy:a,placement:i}=e,c=st(o),l=c.getComputedStyle(o);if(!(l.transitionDuration!=="0s"&&l.transitionDuration!==""))return{x:t,y:n,data:Tr};const d=await s.getOffsetParent?.(o);let m={width:0,height:0};if(a==="fixed"&&c?.visualViewport)m={width:c.visualViewport.width,height:c.visualViewport.height};else if(d===c){const b=an(o);m={width:b.documentElement.clientWidth,height:b.documentElement.clientHeight}}else await s.isElement?.(d)&&(m=await s.getDimensions(d));const h=ze(i);let g=t,y=n;h==="left"&&(g=m.width-(t+r.width)),h==="top"&&(y=m.height-(n+r.height));const x=h==="left"?"right":Tr.sideX,v=h==="top"?"bottom":Tr.sideY;return{x:g,y,data:{sideX:x,sideY:v}}}};function Ec(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 Ta(e,t,n){const{rects:r,placement:o}=e;return{side:Ec(t,ze(o),n),align:Vt(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function ig(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,collisionBoundary:i,collisionPadding:c=5,sticky:l=!1,arrowPadding:u=5,disableAnchorTracking:d=!1,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:y,shiftCrossAxis:x=!1,nodeId:v,adaptiveOrigin:b,lazyFlip:w=!1,externalTree:S}=e,[C,k]=f.useState(null);!g&&C!==null&&k(null);const T=y.side||"flip",N=y.align||"flip",j=y.fallbackAxisSide||"end",M=typeof t=="function"?t:void 0,R=me(M),_=M?R:t,E=gt(t),P=ng()==="rtl",B=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":P?"left":"right","inline-start":P?"right":"left"}[r],V=s==="center"?B:`${B}-${s}`;let O=c;const A=1,U=r==="bottom"?A:0,Y=r==="top"?A:0,Z=r==="right"?A:0,H=r==="left"?A:0;typeof O=="number"?O={top:O+U,right:O+H,bottom:O+Y,left:O+Z}:O&&(O={top:(O.top||0)+U,right:(O.right||0)+H,bottom:(O.bottom||0)+Y,left:(O.left||0)+Z});const W={boundary:i==="clipping-ancestors"?"clippingAncestors":i,padding:O},z=f.useRef(null),X=gt(o),oe=gt(a),xe=[hh(Ce=>{const Te=Ta(Ce,r,P),K=typeof X.current=="function"?X.current(Te):X.current,ce=typeof oe.current=="function"?oe.current(Te):oe.current;return{mainAxis:K,crossAxis:ce,alignmentAxis:ce}},[typeof o!="function"?o:0,typeof a!="function"?a:0,P,r])],Le=N==="none"&&T!=="shift",D=!Le&&(l||x||T==="shift"),ae=T==="none"?null:yh({...W,padding:{top:O.top+A,right:O.right+A,bottom:O.bottom+A,left:O.left+A},mainAxis:!x&&T==="flip",crossAxis:N==="flip"?"alignment":!1,fallbackAxisSideDirection:j}),q=Le?null:gh(Ce=>{const Te=an(Ce.elements.floating).documentElement;return{...W,rootBoundary:x?{x:0,y:0,width:Te.clientWidth,height:Te.clientHeight}:void 0,mainAxis:N!=="none",crossAxis:D,limiter:l||x?void 0:ph(K=>{if(!z.current)return{};const{width:ce,height:te}=z.current.getBoundingClientRect(),fe=ot(ze(K.placement)),Pe=fe==="y"?ce:te,ue=fe==="y"?O.left+O.right:O.top+O.bottom;return{offset:Pe/2+ue/2}})}},[W,l,x,O,N]);T==="shift"||N==="shift"||s==="center"?xe.push(q,ae):xe.push(ae,q),xe.push(bh({...W,apply({elements:{floating:Ce},rects:{reference:Te},availableWidth:K,availableHeight:ce}){Object.entries({"--available-width":`${K}px`,"--available-height":`${ce}px`,"--anchor-width":`${Te.width}px`,"--anchor-height":`${Te.height}px`}).forEach(([te,fe])=>{Ce.style.setProperty(te,fe)})}}),og(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Ce){const{elements:Te,middlewareData:K,placement:ce,rects:te,y:fe}=Ce,Pe=ze(ce),ue=ot(Pe),vt=z.current,Ft=K.arrow?.x||0,kt=K.arrow?.y||0,qe=vt?.clientWidth||0,qt=vt?.clientHeight||0,ln=Ft+qe/2,Fn=kt+qt/2,qr=Math.abs(K.shift?.y||0),Gr=te.reference.height/2,Gt=typeof o=="function"?o(Ta(Ce,r,P)):o,lr=qr>Gt,ur={top:`${ln}px calc(100% + ${Gt}px)`,bottom:`${ln}px ${-Gt}px`,left:`calc(100% + ${Gt}px) ${Fn}px`,right:`${-Gt}px ${Fn}px`}[Pe],un=`${ln}px ${te.reference.y+Gr-fe}px`;return Te.floating.style.setProperty("--transform-origin",D&&ue==="y"&&lr?un:ur),{}}},sg,b),Ee(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[g,h]);const ye=f.useMemo(()=>({elementResize:!d&&typeof ResizeObserver<"u",layoutShift:!d&&typeof IntersectionObserver<"u"}),[d]),{refs:$,elements:J,x:ie,y:he,middlewareData:de,update:se,placement:Q,context:De,isPositioned:ke,floatingStyles:je}=Rh({rootContext:h,placement:V,middleware:xe,strategy:n,whileElementsMounted:m?void 0:(...Ce)=>wa(...Ce,ye),nodeId:v,externalTree:S}),{sideX:pe,sideY:Ke}=de.adaptiveOrigin||Tr,Fe=ke?n:"fixed",Se=f.useMemo(()=>b?{position:Fe,[pe]:ie,[Ke]:he}:{position:Fe,...je},[b,Fe,pe,ie,Ke,he,je]),Ue=f.useRef(null);Ee(()=>{if(!g)return;const Ce=E.current,Te=typeof Ce=="function"?Ce():Ce,ce=(Oa(Te)?Te.current:Te)||null||null;ce!==Ue.current&&($.setPositionReference(ce),Ue.current=ce)},[g,$,_,E]),f.useEffect(()=>{if(!g)return;const Ce=E.current;typeof Ce!="function"&&Oa(Ce)&&Ce.current!==Ue.current&&($.setPositionReference(Ce.current),Ue.current=Ce.current)},[g,$,_,E]),f.useEffect(()=>{if(m&&g&&J.domReference&&J.floating)return wa(J.domReference,J.floating,se,ye)},[m,g,J,se,ye]);const He=ze(Q),At=Ec(r,He,P),_t=Vt(Q)||"center",It=!!de.hide?.referenceHidden;Ee(()=>{w&&g&&ke&&k(He)},[w,g,ke,He]);const jt=f.useMemo(()=>({position:"absolute",top:de.arrow?.y,left:de.arrow?.x}),[de.arrow]),nt=de.arrow?.centerOffset!==0;return f.useMemo(()=>({positionerStyles:Se,arrowStyles:jt,arrowRef:z,arrowUncentered:nt,side:At,align:_t,physicalSide:He,anchorHidden:It,refs:$,context:De,isPositioned:ke,update:se}),[Se,jt,z,nt,At,_t,He,It,$,De,ke,se])}function Oa(e){return e!=null&&"current"in e}const Mc=f.forwardRef(function(t,n){const{cutout:r,...o}=t;let s;if(r){const a=r?.getBoundingClientRect();s=`polygon(
|
|
2
2
|
0% 0%,
|
|
3
3
|
100% 0%,
|
|
4
4
|
100% 100%,
|