tokentracker-cli 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/DashboardPage-C025vDYN.js +12 -0
- package/dashboard/dist/assets/LandingExtras-BDqTHI3x.js +1 -0
- package/dashboard/dist/assets/{LeaderboardPage-ZIRnfiXX.js → LeaderboardPage-BWJsZZGo.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-CoLDY-lR.js → LeaderboardProfilePage-Fm0S6umm.js} +1 -1
- package/dashboard/dist/assets/MatrixRain-_cKLHK44.js +1 -0
- package/dashboard/dist/assets/MatrixShell-DyMWapvD.js +1 -0
- package/dashboard/dist/assets/main-ByQlanyj.css +1 -0
- package/dashboard/dist/assets/{main-C3QpHBOP.js → main-DSjEYl46.js} +25 -25
- package/dashboard/dist/assets/vibeusage-api-B9iVLrJk.js +1 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +2 -2
- package/dashboard/dist/assets/DashboardPage-DwwjNQP7.js +0 -12
- package/dashboard/dist/assets/LandingExtras-BsrCd4pK.js +0 -1
- package/dashboard/dist/assets/MatrixRain-B2DIJ0ID.js +0 -1
- package/dashboard/dist/assets/MatrixShell-Byc-iwIr.js +0 -1
- package/dashboard/dist/assets/main-DJvWJCv5.css +0 -1
- package/dashboard/dist/assets/vibeusage-api-EQ444MvB.js +0 -1
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{r as h,u as Dn,i as Yf,a as Rt,g as zf,b as en,c as tn,d as ot,e as Br,f as Yn,h as js,j as pi,k as Xt,t as Ue,l as P,T as qf,m as g,n as Pe,o as gi,p as Al,q as Pl,s as ie,N as Rl,v as Ml,w as yi,x as pt,y as Dl,E as yn,z as bi,A as Xf,B as nn,C as jo,D as Zf,F as Nl,G as Ls,H as jl,I as Jf,J as At,K as tr,L as Qf,M as nr,O as Lo,P as eh,Q as th,R as Ll,S as nh,U as sh,V as rh,W as ih,X as oh,Y as xi,Z as Vl,_ as ah,$ as lh,a0 as ch,a1 as uh,a2 as dh,a3 as fh,a4 as hh,a5 as mh,a6 as ht,a7 as ph,a8 as gh,a9 as sr}from"./main-C3QpHBOP.js";import{g as yh,a as vi,b as bh,c as xh,d as vh,e as rr,f as wh,r as Sh,h as Vo,i as kh,j as Th,t as Ch,s as Eh}from"./vibeusage-api-EQ444MvB.js";const Ah=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ph=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase()),Io=e=>{const t=Ph(e);return t.charAt(0).toUpperCase()+t.slice(1)},Il=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim(),Rh=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Mh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Dh=h.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:r="",children:i,iconNode:o,...a},l)=>h.createElement("svg",{ref:l,...Mh,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:Il("lucide",r),...!i&&!Rh(a)&&{"aria-hidden":"true"},...a},[...o.map(([c,u])=>h.createElement(c,u)),...Array.isArray(i)?i:[i]]));const Nh=(e,t)=>{const n=h.forwardRef(({className:s,...r},i)=>h.createElement(Dh,{ref:i,iconNode:t,className:Il(`lucide-${Ah(Io(e))}`,`lucide-${e}`,s),...r}));return n.displayName=Io(e),n};const jh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Lh=Nh("info",jh),Vh="data-base-ui-click-trigger",Ih={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Fh=[];function Fl(e){h.useEffect(e,Fh)}const fn=0;class Zt{static create(){return new Zt}currentId=fn;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=fn,n()},t)}isStarted(){return this.currentId!==fn}clear=()=>{this.currentId!==fn&&(clearTimeout(this.currentId),this.currentId=fn)};disposeEffect=()=>this.clear}function ps(){const e=Dn(Zt.create).current;return Fl(e.disposeEffect),e}function Nn(e){return e?.ownerDocument||document}const sn=typeof navigator<"u",ir=$h(),_l=Wh(),Ol=Uh(),_h=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Bl=ir.platform==="MacIntel"&&ir.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(ir.platform),Oh=sn&&/apple/i.test(navigator.vendor),$r=sn&&/android/i.test(_l)||/android/i.test(Ol);sn&&_l.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Bh=Ol.includes("jsdom/");function $h(){if(!sn)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 Uh(){if(!sn)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Wh(){if(!sn)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Ur="data-base-ui-focusable",$l="active",Ul="selected",Kh="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Ut(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function we(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Yf(n)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function Xe(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Ye(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 Hh(e){return e.matches("html,body")}function Ve(e){return e?.ownerDocument||document}function Gh(e){return Rt(e)&&e.matches(Kh)}function Fo(e){return e?e.getAttribute("role")==="combobox"&&Gh(e):!1}function Wr(e){return e?e.hasAttribute(Ur)?e:e.querySelector(`[${Ur}]`)||e:null}function zt(e,t,n=!0){return e.filter(r=>r.parentId===t&&(!n||r.context?.open)).flatMap(r=>[r,...zt(e,r.id,n)])}function _o(e,t){let n=[],s=e.find(r=>r.id===t)?.parentId;for(;s;){const r=e.find(i=>i.id===s);s=r?.parentId,r&&(n=n.concat(r))}return n}function Yh(e){e.preventDefault(),e.stopPropagation()}function zh(e){return"nativeEvent"in e}function qh(e){return e.mozInputSource===0&&e.isTrusted?!0:$r&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Xh(e){return Bh?!1:!$r&&e.width===0&&e.height===0||$r&&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 Zh(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}var Jh=["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] *)"],gs=Jh.join(","),Wl=typeof Element>"u",Jt=Wl?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,ys=!Wl&&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},bs=function(t,n){var s;n===void 0&&(n=!0);var r=t==null||(s=t.getAttribute)===null||s===void 0?void 0:s.call(t,"inert"),i=r===""||r==="true",o=i||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):bs(t.parentNode));return o},Qh=function(t){var n,s=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return s===""||s==="true"},Kl=function(t,n,s){if(bs(t))return[];var r=Array.prototype.slice.apply(t.querySelectorAll(gs));return n&&Jt.call(t,gs)&&r.unshift(t),r=r.filter(s),r},xs=function(t,n,s){for(var r=[],i=Array.from(t);i.length;){var o=i.shift();if(!bs(o,!1))if(o.tagName==="SLOT"){var a=o.assignedElements(),l=a.length?a:o.children,c=xs(l,!0,s);s.flatten?r.push.apply(r,c):r.push({scopeParent:o,candidates:c})}else{var u=Jt.call(o,gs);u&&s.filter(o)&&(n||!t.includes(o))&&r.push(o);var d=o.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(o),f=!bs(d,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(o));if(d&&f){var m=xs(d===!0?o.children:d.children,!0,s);s.flatten?r.push.apply(r,m):r.push({scopeParent:o,candidates:m})}else i.unshift.apply(i,o.children)}}return r},Hl=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Gl=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Qh(t))&&!Hl(t)?0:t.tabIndex},em=function(t,n){var s=Gl(t);return s<0&&n&&!Hl(t)?0:s},tm=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Yl=function(t){return t.tagName==="INPUT"},nm=function(t){return Yl(t)&&t.type==="hidden"},sm=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(s){return s.tagName==="SUMMARY"});return n},rm=function(t,n){for(var s=0;s<t.length;s++)if(t[s].checked&&t[s].form===n)return t[s]},im=function(t){if(!t.name)return!0;var n=t.form||ys(t),s=function(a){return n.querySelectorAll('input[type="radio"][name="'+a+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=s(window.CSS.escape(t.name));else try{r=s(t.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var i=rm(r,t.form);return!i||i===t},om=function(t){return Yl(t)&&t.type==="radio"},am=function(t){return om(t)&&!im(t)},lm=function(t){var n,s=t&&ys(t),r=(n=s)===null||n===void 0?void 0:n.host,i=!1;if(s&&s!==t){var o,a,l;for(i=!!((o=r)!==null&&o!==void 0&&(a=o.ownerDocument)!==null&&a!==void 0&&a.contains(r)||t!=null&&(l=t.ownerDocument)!==null&&l!==void 0&&l.contains(t));!i&&r;){var c,u,d;s=ys(r),r=(c=s)===null||c===void 0?void 0:c.host,i=!!((u=r)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(r))}}return i},Oo=function(t){var n=t.getBoundingClientRect(),s=n.width,r=n.height;return s===0&&r===0},cm=function(t,n){var s=n.displayCheck,r=n.getShadowRoot;if(s==="full-native"&&"checkVisibility"in t){var i=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(t).visibility==="hidden")return!0;var o=Jt.call(t,"details>summary:first-of-type"),a=o?t.parentElement:t;if(Jt.call(a,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof r=="function"){for(var l=t;t;){var c=t.parentElement,u=ys(t);if(c&&!c.shadowRoot&&r(c)===!0)return Oo(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(lm(t))return!t.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return Oo(t);return!1},um=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var s=0;s<n.children.length;s++){var r=n.children.item(s);if(r.tagName==="LEGEND")return Jt.call(n,"fieldset[disabled] *")?!0:!r.contains(t)}return!0}n=n.parentElement}return!1},Kr=function(t,n){return!(n.disabled||nm(n)||cm(n,t)||sm(n)||um(n))},Hr=function(t,n){return!(am(n)||Gl(n)<0||!Kr(t,n))},dm=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},zl=function(t){var n=[],s=[];return t.forEach(function(r,i){var o=!!r.scopeParent,a=o?r.scopeParent:r,l=em(a,o),c=o?zl(r.candidates):a;l===0?o?n.push.apply(n,c):n.push(a):s.push({documentOrder:i,tabIndex:l,item:r,isScope:o,content:c})}),s.sort(tm).reduce(function(r,i){return i.isScope?r.push.apply(r,i.content):r.push(i.content),r},[]).concat(n)},Vs=function(t,n){n=n||{};var s;return n.getShadowRoot?s=xs([t],n.includeContainer,{filter:Hr.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:dm}):s=Kl(t,n.includeContainer,Hr.bind(null,n)),zl(s)},fm=function(t,n){n=n||{};var s;return n.getShadowRoot?s=xs([t],n.includeContainer,{filter:Kr.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):s=Kl(t,n.includeContainer,Kr.bind(null,n)),s},ql=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Jt.call(t,gs)===!1?!1:Hr(n,t)};const jn=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Xl(e,t){const n=Vs(e,jn()),s=n.length;if(s===0)return;const r=Ut(Ve(e)),i=n.indexOf(r),o=i===-1?t===1?0:s-1:i+t;return n[o]}function Zl(e){return Xl(Ve(e).body,1)||e}function Jl(e){return Xl(Ve(e).body,-1)||e}function bn(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!we(n,s)}function hm(e){Vs(e,jn()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Bo(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}function mm({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:s=52,weekStartsOn:r="sun",cacheKey:i,timeZone:o,tzOffsetMinutes:a,now:l}={}){const c=h.useMemo(()=>zf({weeks:s,weekStartsOn:r,now:l}),[l,s,r]),[u,d]=h.useState([]),[f,m]=h.useState(null),[p,y]=h.useState("edge"),[b,x]=h.useState(!1),[w,v]=h.useState(null),T=en(),S=tn(t),R=!n,N=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),C=h.useMemo(()=>{if(!i)return null;const $=js({timeZone:o,offsetMinutes:a});return`vibeusage.heatmap.${i}.${s}.${r}.${$}`},[i,o,a,s,r]),I=h.useCallback(()=>{if(!C||typeof window>"u")return null;try{const $=window.localStorage.getItem(C);if(!$)return null;const j=JSON.parse($);return!j||!j.heatmap?null:j}catch{return null}},[C]),A=h.useCallback($=>{if(!(!C||typeof window>"u"))try{window.localStorage.setItem(C,JSON.stringify($))}catch{}},[C]),M=h.useCallback(()=>{if(!(!C||typeof window>"u"))try{window.localStorage.removeItem(C)}catch{}},[C]),U=h.useCallback(async()=>{const $=await ot(t);if(!(!$&&!T&&!N)){x(!0),v(null);try{try{const D=await yh({baseUrl:e,accessToken:$,weeks:s,to:c.to,weekStartsOn:r,timeZone:o,tzOffsetMinutes:a}),_=Array.isArray(D?.weeks)?D.weeks:[];if(!_.length&&R){const X=I();if(X?.heatmap){m(X.heatmap),d(X.daily||[]),y("cache");return}}if(!_.some(X=>(Array.isArray(X)?X:[]).some(se=>se&&Number.isFinite(Number(se.level))))&&_.length){const X=[];for(const H of _)for(const Q of Array.isArray(H)?H:[])Q?.day&&X.push({day:Q.day,total_tokens:Q.total_tokens??Q.value??0,billable_total_tokens:Q.billable_total_tokens??Q.value??Q.total_tokens??0});const se=Br({dailyRows:X,weeks:s,to:D?.to||c.to,weekStartsOn:r});d(X),m({...se,week_starts_on:r,active_days:X.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:Yn({dailyRows:X,to:D?.to||c.to})}),y("client"),R?A({heatmap:{...se,week_starts_on:r,active_days:X.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:Yn({dailyRows:X,to:D?.to||c.to})},daily:X,fetchedAt:new Date().toISOString()}):M();return}m(D||null),d([]),y("edge"),D&&R?A({heatmap:D,daily:[],fetchedAt:new Date().toISOString()}):R||M();return}catch(D){const _=D,z=_?.status??_?.statusCode;if(z===401||z===403)throw D}const j=await vi({baseUrl:e,accessToken:$,from:c.from,to:c.to,timeZone:o,tzOffsetMinutes:a}),W=Array.isArray(j?.data)?j.data:[];d(W);const pe=Br({dailyRows:W,weeks:s,to:c.to,weekStartsOn:r});m({...pe,week_starts_on:r,active_days:W.filter(D=>Number(D?.billable_total_tokens??D?.total_tokens)>0).length,streak_days:Yn({dailyRows:W,to:c.to})}),y("client"),R?A({heatmap:{...pe,week_starts_on:r,active_days:W.filter(D=>Number(D?.billable_total_tokens??D?.total_tokens)>0).length,streak_days:Yn({dailyRows:W,to:c.to})},daily:W,fetchedAt:new Date().toISOString()}):M()}catch(j){if(R){const W=I();if(W?.heatmap)m(W.heatmap),d(W.daily||[]),y("cache"),v(null);else{const pe=j;v(pe?.message||String(pe)),d([]),m(null),y("edge")}}else{const W=j;v(W?.message||String(W)),d([]),m(null),y("edge")}}finally{x(!1)}}},[t,e,T,n,R,c.from,c.to,I,S,o,a,r,s,M,A,N]);return h.useEffect(()=>{if(!S&&!n&&!T&&!N){d([]),x(!1),v(null),m(null),y("edge");return}if(!R)M(),d([]),v(null),m(null),y("edge");else{const $=I();$?.heatmap&&(m($.heatmap),d($.daily||[]),y("cache"))}U()},[t,T,I,U,S,n,R,M,N]),{range:c,daily:u,heatmap:f,source:T?"mock":p==="client"?"edge":p,loading:b,error:w,refresh:U}}function pm({baseUrl:e,accessToken:t,limit:n=3,from:s,to:r,source:i,timeZone:o,tzOffsetMinutes:a}={}){const[l,c]=h.useState([]),[u,d]=h.useState(!1),[f,m]=h.useState(null),p=en(),y=tn(t),b=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),x=h.useCallback(async()=>{const w=await ot(t);if(!w&&!p&&!b){c([]),m(null),d(!1);return}d(!0),m(null);try{const v=await bh({baseUrl:e,accessToken:w,limit:n,from:s,to:r,source:i,timeZone:o,tzOffsetMinutes:a});c(Array.isArray(v?.entries)?v.entries:[])}catch(v){const T=v?.message||String(v);m(T),c([])}finally{d(!1)}},[t,e,s,n,p,i,o,r,a,b]);return h.useEffect(()=>{if(!y&&!p&&!b){c([]),m(null),d(!1);return}x()},[p,x,y,b]),{entries:l,loading:u,error:f,refresh:x}}const gm=24;function ym({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:s,from:r,to:i,months:o=gm,cacheKey:a,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:d,sharedRange:f}={}){const[m,p]=h.useState([]),[y,b]=h.useState(()=>({from:r,to:i})),[x,w]=h.useState("edge"),[v,T]=h.useState(null),[S,R]=h.useState(!1),[N,C]=h.useState(null),I=en(),A=tn(t),M=!n,U=Array.isArray(d),L=f?.from||r,$=f?.to||i,j=h.useMemo(()=>s==="day"?"hourly":s==="total"?"monthly":"daily",[s]),W=(()=>{if(!a)return null;const H=bm(e)||"default",Q=js({timeZone:l,offsetMinutes:c});if(j==="hourly")return`vibeusage.trend.${a}.${H}.hourly.${i||r||"day"}.${Q}`;if(j==="monthly")return`vibeusage.trend.${a}.${H}.monthly.${o}.${i||"today"}.${Q}`;const ee=`${r||""}.${i||""}`;return`vibeusage.trend.${a}.${H}.daily.${ee}.${Q}`})(),pe=h.useCallback(()=>{if(!W||typeof window>"u")return null;try{const H=window.localStorage.getItem(W);if(!H)return null;const Q=JSON.parse(H);return!Q||!Array.isArray(Q.rows)?null:Q}catch{return null}},[W]),D=h.useCallback(H=>{if(!(!W||typeof window>"u"))try{window.localStorage.setItem(W,JSON.stringify(H))}catch{}},[W]),_=h.useCallback(()=>{if(!(!W||typeof window>"u"))try{window.localStorage.removeItem(W)}catch{}},[W]),z=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),X=h.useCallback(async()=>{if(U){p(Array.isArray(d)?d:[]),b({from:L,to:$}),w("shared"),T(null),R(!1),C(null);return}const H=await ot(t);if(!(!H&&!I&&!z)){R(!0),C(null);try{let Q;j==="hourly"?Q=await xh({baseUrl:e,accessToken:H,day:i||r,timeZone:l,tzOffsetMinutes:c}):j==="monthly"?Q=await vh({baseUrl:e,accessToken:H,months:o,to:i,timeZone:l,tzOffsetMinutes:c}):Q=await vi({baseUrl:e,accessToken:H,from:r,to:i,timeZone:l,tzOffsetMinutes:c});const ee=Q?.from||r||Q?.day||null,de=Q?.to||i||Q?.day||null;let be=Array.isArray(Q?.data)?Q.data:[];j==="daily"?be=ar(be,ee||r,de||i,{timeZone:l,offsetMinutes:c,now:u}):j==="hourly"?be=lr(be,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(be=cr(be,{timeZone:l,offsetMinutes:c,now:u}));const Ne=new Date().toISOString();p(be),b({from:ee,to:de}),w("edge"),T(Ne),M?D({rows:be,from:ee,to:de,mode:j,fetchedAt:Ne}):_()}catch(Q){if(M){const ee=pe();if(ee?.rows){let de=j==="daily"?ar(ee.rows||[],ee.from||r,ee.to||i,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(ee.rows)?ee.rows:[];j==="hourly"?de=lr(de,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(de=cr(de,{timeZone:l,offsetMinutes:c,now:u})),p(de),b({from:ee.from||r,to:ee.to||i}),w("cache"),T(ee.fetchedAt||null),C(null)}else{p([]),b({from:r,to:i}),w("edge"),T(null);const de=Q;C(de?.message||String(de))}}else{p([]),b({from:r,to:i}),w("edge"),T(null);const ee=Q;C(ee?.message||String(ee))}}finally{R(!1)}}},[t,e,r,I,n,M,j,o,pe,A,U,L,d,$,l,i,c,u,_,D,z]);h.useEffect(()=>{if(U){p(Array.isArray(d)?d:[]),b({from:L,to:$}),w("shared"),T(null),R(!1),C(null);return}if(!A&&!n&&!I&&!z){p([]),b({from:r,to:i}),C(null),R(!1),w("edge"),T(null);return}if(!M)_(),p([]),b({from:r,to:i}),C(null),w("edge"),T(null);else{const H=pe();if(H?.rows){let Q=j==="daily"?ar(H.rows||[],H.from||r,H.to||i,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(H.rows)?H.rows:[];j==="hourly"?Q=lr(Q,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(Q=cr(Q,{timeZone:l,offsetMinutes:c,now:u})),p(Q),b({from:H.from||r,to:H.to||i}),w("cache"),T(H.fetchedAt||null)}}X()},[t,I,pe,X,U,L,d,$,A,n,M,_,z]);const se=I?"mock":x;return{rows:m,from:y.from||r,to:y.to||i,source:se,fetchedAt:v,loading:S,error:N,refresh:X}}function bm(e){try{return new URL(e).host}catch{return null}}function or(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const s=Number(n[0]),r=Number(n[1])-1,i=Number(n[2]);if(!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(i))return null;const o=new Date(Date.UTC(s,r,i));return Number.isFinite(o.getTime())&&Xt(o)===t?o:null}function xm(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function ar(e,t,n,{timeZone:s,offsetMinutes:r,now:i}={}){const o=or(t),a=or(n);if(!o||!a||a<o)return Array.isArray(e)?e:[];const l=i instanceof Date&&Number.isFinite(i.getTime())?i:new Date,c=pi({timeZone:s,offsetMinutes:r,date:l}),u=or(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const m=[];for(let p=o;p<=a;p=xm(p,1)){const y=Xt(p),b=f.get(y),x=p.getTime()>d;if(b){m.push({...b,missing:!1,future:x});continue}m.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:!x,future:x})}return m}function lr(e,{timeZone:t,offsetMinutes:n,now:s}={}){if(!Array.isArray(e))return[];const r=Ql({timeZone:t,offsetMinutes:n,now:s});return r?e.map(i=>{const o=i?.hour||i?.label||"",a=vm(o);if(!a)return{...i,future:!1};const l=a.dayNum>r.dayNum||a.dayNum===r.dayNum&&a.slot>r.slot;return{...i,future:l}}):e}function cr(e,{timeZone:t,offsetMinutes:n,now:s}={}){if(!Array.isArray(e))return[];const r=Ql({timeZone:t,offsetMinutes:n,now:s});return r?e.map(i=>{const o=i?.month||i?.label||"",a=wm(o);if(!a)return{...i,future:!1};const l=a.year>r.year||a.year===r.year&&a.month>r.month;return{...i,future:l}}):e}function Ql({timeZone:e,offsetMinutes:t,now:n}={}){const s=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const f=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(s).reduce((w,v)=>(v.type&&v.value&&(w[v.type]=v.value),w),{}),m=Number(f.year),p=Number(f.month),y=Number(f.day),b=Number(f.hour),x=Number(f.minute);if(Number.isFinite(m)&&Number.isFinite(p)&&Number.isFinite(y)&&Number.isFinite(b)&&Number.isFinite(x)){const w=b*2+(x>=30?1:0);return{year:m,month:p,day:y,hour:b,minute:x,dayNum:m*1e4+p*100+y,slot:w}}}catch{}if(Number.isFinite(t)){const u=new Date(s.getTime()+t*60*1e3),d=u.getUTCFullYear(),f=u.getUTCMonth()+1,m=u.getUTCDate(),p=u.getUTCHours(),y=u.getUTCMinutes(),b=p*2+(y>=30?1:0);return{year:d,month:f,day:m,hour:p,minute:y,dayNum:d*1e4+f*100+m,slot:b}}const r=s.getFullYear(),i=s.getMonth()+1,o=s.getDate(),a=s.getHours(),l=s.getMinutes(),c=a*2+(l>=30?1:0);return{year:r,month:i,day:o,hour:a,minute:l,dayNum:r*1e4+i*100+o,slot:c}}function vm(e){if(!e)return null;const t=String(e).trim(),[n,s]=t.split("T");if(!n||!s)return null;const r=n.split("-");if(r.length!==3)return null;const i=Number(r[0]),o=Number(r[1]),a=Number(r[2]);if(!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(a))return null;const l=s.split(":"),c=Number(l[0]),u=Number(l[1]);if(!Number.isFinite(c)||c<0||c>23||!Number.isFinite(u)||u<0||u>59)return null;const d=c*2+(u>=30?1:0);return{dayNum:i*1e4+o*100+a,slot:d}}function wm(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const s=Number(n[0]),r=Number(n[1]);return!Number.isFinite(s)||!Number.isFinite(r)||r<1||r>12?null:{year:s,month:r}}function $o({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:s,to:r,includeDaily:i=!0,cacheKey:o,timeZone:a,tzOffsetMinutes:l,now:c}={}){const[u,d]=h.useState([]),[f,m]=h.useState(null),[p,y]=h.useState(null),[b,x]=h.useState("edge"),[w,v]=h.useState(null),[T,S]=h.useState(!1),[R,N]=h.useState(null),C=en(),I=tn(t),A=!n,M=(()=>{if(!o)return null;const D=Sm(e)||"default",_=i?"daily":"summary",z=js({timeZone:a,offsetMinutes:l});return`vibeusage.usage.${o}.${D}.${s}.${r}.${_}.${z}`})(),U=h.useCallback(()=>{if(!M||typeof window>"u")return null;try{const D=window.localStorage.getItem(M);if(!D)return null;const _=JSON.parse(D);return!_||!_.summary?null:_}catch{return null}},[M]),L=h.useCallback(D=>{if(!(!M||typeof window>"u"))try{window.localStorage.setItem(M,JSON.stringify(D))}catch{}},[M]),$=h.useCallback(()=>{if(!(!M||typeof window>"u"))try{window.localStorage.removeItem(M)}catch{}},[M]),j=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),W=h.useCallback(async()=>{const D=await ot(t);if(!(!D&&!C&&!j)){S(!0),N(null);try{let _=null,z=null;if(i){const[ee,de]=await Promise.allSettled([vi({baseUrl:e,accessToken:D,from:s,to:r,timeZone:a,tzOffsetMinutes:l}),rr({baseUrl:e,accessToken:D,from:s,to:r,timeZone:a,tzOffsetMinutes:l,rolling:!0})]);if(ee.status==="rejected")throw ee.reason;_=ee.value,z=de.status==="fulfilled"?de.value:null}else z=await rr({baseUrl:e,accessToken:D,from:s,to:r,timeZone:a,tzOffsetMinutes:l,rolling:!0});let X=i&&Array.isArray(_?.data)?_.data:[];i&&(X=dr(X,s,r,{timeZone:a,offsetMinutes:l,now:c}));let se=z?.totals||_?.summary?.totals||null,H=z?.rolling||_?.summary?.rolling||null;if(i&&!se&&!z)try{const ee=await rr({baseUrl:e,accessToken:D,from:s,to:r,timeZone:a,tzOffsetMinutes:l,rolling:!0});se=ee?.totals||null,H=ee?.rolling||H}catch{}const Q=new Date().toISOString();d(X),m(se),y(H),x("edge"),v(Q),se&&A?L({summary:se,rolling:H,daily:X,from:s,to:r,includeDaily:i,fetchedAt:Q}):A||$()}catch(_){if(A){const z=U();if(z?.summary){m(z.summary),y(z.rolling||null);const X=Array.isArray(z.daily)?z.daily:[],se=i?dr(X,z.from||s,z.to||r,{timeZone:a,offsetMinutes:l,now:c}):X;d(se),x("cache"),v(z.fetchedAt||null),N(null)}else{const X=_;N(X?.message||String(X)),d([]),m(null),y(null),x("edge"),v(null)}}else{const z=_;N(z?.message||String(z)),d([]),m(null),y(null),x("edge"),v(null)}}finally{S(!1)}}},[t,e,s,i,C,n,A,c,U,I,a,r,l,$,L,j]);return h.useEffect(()=>{const D=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!I&&!n&&!C&&!D){d([]),m(null),y(null),N(null),S(!1),x("edge"),v(null);return}if(!A)$(),d([]),m(null),y(null),N(null),x("edge"),v(null);else{const _=U();if(_?.summary){m(_.summary),y(_.rolling||null);const z=Array.isArray(_.daily)?_.daily:[],X=i?dr(z,_.from||s,_.to||r,{timeZone:a,offsetMinutes:l,now:c}):z;d(X),x("cache"),v(_.fetchedAt||null)}}W()},[t,C,U,W,I,n,A,$,j]),{daily:u,summary:f,rolling:p,source:C?"mock":b,fetchedAt:w,loading:T,error:R,refresh:W}}function Sm(e){try{return new URL(e).host}catch{return null}}function ur(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const s=Number(n[0]),r=Number(n[1])-1,i=Number(n[2]);if(!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(i))return null;const o=new Date(Date.UTC(s,r,i));return Number.isFinite(o.getTime())&&Xt(o)===t?o:null}function km(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function dr(e,t,n,{timeZone:s,offsetMinutes:r,now:i}={}){const o=ur(t),a=ur(n);if(!o||!a||a<o)return Array.isArray(e)?e:[];const l=i instanceof Date&&Number.isFinite(i.getTime())?i:new Date,c=pi({timeZone:s,offsetMinutes:r,date:l}),u=ur(c),d=u?u.getTime():l.getTime(),f=new Map;for(const p of e||[])p?.day&&f.set(p.day,p);const m=[];for(let p=o;p<=a;p=km(p,1)){const y=Xt(p),b=f.get(y),x=p.getTime()>d;if(b){m.push({...b,missing:!1,future:x});continue}m.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:!x,future:x})}return m}function Tm({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:s,to:r,cacheKey:i,timeZone:o,tzOffsetMinutes:a}={}){const[l,c]=h.useState(null),[u,d]=h.useState("edge"),[f,m]=h.useState(!1),[p,y]=h.useState(null),b=en(),x=tn(t),w=!n,v=h.useMemo(()=>{if(!i)return null;const A=Cm(e)||"default",M=js({timeZone:o,offsetMinutes:a});return`vibeusage.modelBreakdown.${i}.${A}.${s}.${r}.${M}`},[e,i,s,o,r,a]),T=h.useCallback(()=>{if(!v||typeof window>"u")return null;try{const A=window.localStorage.getItem(v);if(!A)return null;const M=JSON.parse(A);return!M||!M.breakdown?null:M}catch{return null}},[v]),S=h.useCallback(A=>{if(!(!v||typeof window>"u"))try{window.localStorage.setItem(v,JSON.stringify(A))}catch{}},[v]),R=h.useCallback(()=>{if(!(!v||typeof window>"u"))try{window.localStorage.removeItem(v)}catch{}},[v]),N=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),C=h.useCallback(async()=>{const A=await ot(t);if(!(!A&&!b&&!N)){m(!0),y(null);try{const M=await wh({baseUrl:e,accessToken:A,from:s,to:r,timeZone:o,tzOffsetMinutes:a});c(M||null),d("edge"),M&&w?S({breakdown:M,fetchedAt:new Date().toISOString()}):w||R()}catch(M){if(w){const U=T();if(U?.breakdown)c(U.breakdown),d("cache"),y(null);else{c(null),d("edge");const L=M;y(L?.message||String(L))}}else{c(null),d("edge");const U=M;y(U?.message||String(U))}}finally{m(!1)}}},[t,e,s,b,n,w,T,o,r,x,a,R,S,N]);return h.useEffect(()=>{if(!x&&!n&&!b&&!N){c(null),d("edge"),y(null),m(!1);return}if(!w)R(),c(null),d("edge"),y(null);else{const A=T();A?.breakdown&&(c(A.breakdown),d("cache"))}C()},[t,b,T,C,x,n,w,R,N]),{breakdown:l,source:b?"mock":u,loading:f,error:p,refresh:C}}function Cm(e){try{return new URL(e).host}catch{return null}}const ec=new Set(["day","hour","month"]);function Em(e){return ec.has(e)}function Uo(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 Am(e,t){const n=Uo(e),s=Uo(t);if(n&&s)return n.length!==s.length?n.length<s.length?-1:1:n===s?0:n<s?-1:1;const r=Ue(e),i=Ue(t);return r==null&&i==null?0:r==null?1:i==null?-1:r===i?0:r<i?-1:1}function Pm(e,t){const n=typeof e=="string"?e:String(e||""),s=typeof t=="string"?t:String(t||"");return n===s?0:n<s?-1:1}function Rm(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const s=Number(n[1]),r=Number(n[2]),i=Number(n[3]);if(!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(i))return null;const o=new Date(Date.UTC(s,r-1,i));return!Number.isFinite(o.getTime())||o.getUTCFullYear()!==s||o.getUTCMonth()+1!==r||o.getUTCDate()!==i?null:o.getTime()}function Mm(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const s=Number(n[1]),r=Number(n[2]);if(!Number.isFinite(s)||!Number.isFinite(r)||r<1||r>12)return null;const i=new Date(Date.UTC(s,r-1,1));return Number.isFinite(i.getTime())?i.getTime():null}function Dm(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 s=Number(n[1]),r=Number(n[2]),i=Number(n[3]),o=Number(n[4]),a=Number(n[5]),l=Number(n[6]||0);if(!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(l)||r<1||r>12||i<1||i>31||o<0||o>23||a<0||a>59||l<0||l>59)return null;const c=new Date(Date.UTC(s,r-1,i,o,a,l));return Number.isFinite(c.getTime())?c.getTime():null}function Nm(e,t,n){const s=n==="hour"?Dm:n==="month"?Mm:Rm,r=s(e),i=s(t);return r!=null&&i!=null?r===i?0:r<i?-1:1:Pm(e,t)}function tc(e,{key:t,dir:n}){const s=n==="asc"?1:-1,r=Array.isArray(e)?e:[],i=ec.has(t)?(a,l)=>Nm(a,l,t):Am,o=a=>t==="total_tokens"&&a?.billable_total_tokens!=null?a.billable_total_tokens:a?.[t];return r.map((a,l)=>({row:a,index:l})).sort((a,l)=>{const c=o(a.row),u=o(l.row),d=c==null,f=u==null;if(d&&f)return a.index-l.index;if(d)return 1;if(f)return-1;const m=i(c,u);return m!==0?m*s:a.index-l.index}).map(a=>a.row)}const jm=[{key:"day",label:P("daily.sort.date.label"),title:P("daily.sort.date.title")},{key:"total_tokens",label:P("daily.sort.total.label"),title:P("daily.sort.total.title")},{key:"input_tokens",label:P("daily.sort.input.label"),title:P("daily.sort.input.title")},{key:"output_tokens",label:P("daily.sort.output.label"),title:P("daily.sort.output.title")},{key:"cached_input_tokens",label:P("daily.sort.cached.label"),title:P("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:P("daily.sort.reasoning.label"),title:P("daily.sort.reasoning.title")},{key:"conversation_count",label:P("daily.sort.conversations.label"),title:P("daily.sort.conversations.title")}];function Wo(e){const t=Em(e)?e:"day";return jm.map((n,s)=>s===0?{...n,key:t}:n)}function Ko(e,{key:t,dir:n}){return tc(e,{key:t,dir:n})}const vs=12,Lm=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Vm(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 Im(e){return Lm.some(t=>Vm(e?.[t]))}function Fm(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=tc(t,{key:"month",dir:"asc"}),s=n.findIndex(r=>r?.month&&Im(r));return s===-1?t:n.slice(s)}function _m(e,t,n=vs){const s=Array.isArray(e)?e:[],r=Number.isFinite(n)&&n>0?n:vs,o=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*r;return s.slice(o,o+r)}function Om({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:s,heatmapLoading:r,activeDays:i,hasActiveDeviceToken:o}={}){return e||t?!1:n?!0:s&&!r&&i===0&&!o}function nc(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Bm(e){const t=nc(e?.model_id);return t||null}function sc(e,t){return e?.model?String(e.model):t}function $m(e,{copyFn:t}={}){const n=typeof t=="function"?t:o=>o,r=(Array.isArray(e?.sources)?e.sources:[]).map(o=>{const a=Ue(o?.totals?.billable_total_tokens??o?.totals?.total_tokens)??0,l=Ue(o?.totals?.total_cost_usd)??0;return{source:o?.source,totalTokens:Number.isFinite(a)?a:0,totalCost:Number.isFinite(l)?l:0,models:Array.isArray(o?.models)?o.models:[]}}).filter(o=>o.totalTokens>0);if(!r.length)return[];const i=r.reduce((o,a)=>o+a.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),r.slice().sort((o,a)=>a.totalTokens-o.totalTokens).map(o=>{const a=o.source?String(o.source).toUpperCase():n("shared.placeholder.short"),l=i>0?o.totalTokens/i*100:0,c=Number.isFinite(l)?l.toFixed(1):"0.0",u=o.models.map(d=>{const f=Ue(d?.totals?.billable_total_tokens??d?.totals?.total_tokens)??0;if(!Number.isFinite(f)||f<=0)return null;const m=o.totalTokens>0?Math.round(f/o.totalTokens*1e3)/10:0,p=sc(d,n("shared.placeholder.short")),y=Bm(d),b=o.totalCost>0&&o.totalTokens>0?f/o.totalTokens*o.totalCost:null;return{id:y,name:p,share:m,usage:f,cost:b}}).filter(Boolean);return{label:a,totalPercent:String(c),usd:o.totalCost,usage:o.totalTokens,models:u}})}function Um(e,{limit:t=3,copyFn:n}={}){const s=typeof n=="function"?n:f=>f,r=Array.isArray(e?.sources)?e.sources:[];if(!r.length)return[];const i=new Map,o=new Map,a=new Map;let l=0;for(const f of r){const m=Array.isArray(f?.models)?f.models:[];for(const p of m){const y=Ue(p?.totals?.billable_total_tokens)??0;if(!Number.isFinite(y)||y<=0)continue;l+=y;const b=sc(p,s("shared.placeholder.short")),x=nc(b);if(!x)continue;i.set(x,(i.get(x)||0)+y);const w=a.get(x)||0;y>=w&&(a.set(x,y),o.set(x,b))}}if(!i.size)return[];const c=Array.from(i.values()).reduce((f,m)=>f+m,0),u=l>0?l:c,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(i.entries()).map(([f,m])=>{const p=u>0?(m/u*100).toFixed(1):"0.0";return{id:f,name:o.get(f)||s("shared.placeholder.short"),tokens:m,percent:String(p)}}).sort((f,m)=>m.tokens!==f.tokens?m.tokens-f.tokens:String(f.name).localeCompare(String(m.name))).slice(0,d)}function wi(){const e=h.useContext(qf);if(e===null)throw new Error("useTheme must be used within a ThemeProvider");return e}const Ct=12,hn=3,fr=26,Wm=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],Km=["#064e3b","#065f46","#059669","#10b981","#34d399"],Hm=[P("heatmap.month.jan"),P("heatmap.month.feb"),P("heatmap.month.mar"),P("heatmap.month.apr"),P("heatmap.month.may"),P("heatmap.month.jun"),P("heatmap.month.jul"),P("heatmap.month.aug"),P("heatmap.month.sep"),P("heatmap.month.oct"),P("heatmap.month.nov"),P("heatmap.month.dec")];function Gm(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 Ym(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 rc(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function zm(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function qm(e,t){const n=t==="mon"?1:0,s=e.getUTCDay();return rc(e,-((s-n+7)%7))}function Xm(e,t,n){if(!e)return[];const s=Ym(t)||new Date,r=[];for(let c=11;c>=0;c-=1)r.push(new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()-c,1)));const i=qm(s,n),o=rc(i,-(e-1)*7),a=[],l=new Set;for(const c of r){const u=Math.floor(zm(o,c)/7);u<0||u>=e||l.has(u)||(l.add(u),a.push({label:Hm[c.getUTCMonth()],index:u}))}return a}function Zm({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:s=!1}){const{resolvedTheme:r}=wi(),o=r==="dark"?Km:Wm,a=h.useRef(null);h.useEffect(()=>{const p=a.current;p&&(p.scrollLeft=p.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=h.useMemo(()=>{const p=Array.isArray(e?.weeks)?e.weeks:[];if(!p.length)return{weeks:[]};const y=[];for(const b of p)for(const x of Array.isArray(b)?b:[])x?.day&&y.push({day:x.day,total_tokens:x.total_tokens??x.value??0,billable_total_tokens:x.billable_total_tokens??x.value??x.total_tokens??0});return Br({dailyRows:y,weeks:Math.max(52,p.length),to:e?.to,weekStartsOn:l})},[e?.to,e?.weeks,l]),u=c?.weeks||[],d=l==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(p=>P(`heatmap.day.${p.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(p=>P(`heatmap.day.${p.toLowerCase()}`)),f=h.useMemo(()=>Xm(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return g.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:P("heatmap.empty")});const m=fr+u.length*Ct+Math.max(0,u.length-1)*hn;return g.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:[g.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[g.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:P("heatmap.title")}),g.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||P("heatmap.legend.utc")})]}),g.jsx("div",{ref:a,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:g.jsxs("div",{style:{minWidth:m},children:[g.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${fr}px repeat(${u.length}, ${Ct}px)`,columnGap:hn},children:[g.jsx("span",{}),f.map(p=>g.jsx("span",{style:{gridColumnStart:p.index+2},className:"whitespace-nowrap",children:p.label},`${p.label}-${p.index}`))]}),g.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${fr}px repeat(${u.length}, ${Ct}px)`,columnGap:hn},children:[g.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, ${Ct}px)`,rowGap:hn},children:d.map(p=>g.jsx("span",{className:"leading-none",children:p},p))}),g.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Ct}px)`,gap:hn},children:u.map((p,y)=>(Array.isArray(p)?p:[]).map((b,x)=>{if(!b)return null;const w=b.day||`e-${y}-${x}`,v=Number(b.level)||0,T=o[v]||o[0],S=t||n||P("heatmap.legend.utc");return g.jsx("span",{title:P("heatmap.tooltip",{day:b.day,value:Gm(b.value),unit:P("heatmap.unit.tokens"),tz:S}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:Ct,height:Ct,background:T}},w)}))})]})]})}),!s&&g.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[g.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:P("heatmap.legend.less")}),g.jsx("div",{className:"flex gap-0.5",children:o.map((p,y)=>g.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:p}},y))}),g.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:P("heatmap.legend.more")})]})]})}const Jm={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},ic={...Jm,position:"fixed",top:0,left:0};function zn(e){const t=Dn(Qm,e).current;return t.next=e,Pe(t.effect),t}function Qm(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var ws=Symbol("NOT_FOUND");function ep(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function tp(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function np(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(s=>typeof s=="function"?`function ${s.name||"unnamed"}()`:typeof s).join(", ");throw new TypeError(`${t}[${n}]`)}}var Ho=e=>Array.isArray(e)?e:[e];function sp(e){const t=Array.isArray(e[0])?e[0]:e;return np(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function rp(e,t){const n=[],{length:s}=e;for(let r=0;r<s;r++)n.push(e[r].apply(null,t));return n}function ip(e){let t;return{get(n){return t&&e(t.key,n)?t.value:ws},put(n,s){t={key:n,value:s}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function op(e,t){let n=[];function s(a){const l=n.findIndex(c=>t(a,c.key));if(l>-1){const c=n[l];return l>0&&(n.splice(l,1),n.unshift(c)),c.value}return ws}function r(a,l){s(a)===ws&&(n.unshift({key:a,value:l}),n.length>e&&n.pop())}function i(){return n}function o(){n=[]}return{get:s,put:r,getEntries:i,clear:o}}var ap=(e,t)=>e===t;function lp(e){return function(n,s){if(n===null||s===null||n.length!==s.length)return!1;const{length:r}=n;for(let i=0;i<r;i++)if(!e(n[i],s[i]))return!1;return!0}}function cp(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:s=ap,maxSize:r=1,resultEqualityCheck:i}=n,o=lp(s);let a=0;const l=r<=1?ip(o):op(r,o);function c(){let u=l.get(arguments);if(u===ws){if(u=e.apply(null,arguments),a++,i){const f=l.getEntries().find(m=>i(m.value,u));f&&(u=f.value,a!==0&&a--)}l.put(arguments,u)}return u}return c.clearCache=()=>{l.clear(),c.resetResultsCount()},c.resultsCount=()=>a,c.resetResultsCount=()=>{a=0},c}var up=class{constructor(e){this.value=e}deref(){return this.value}},dp=typeof WeakRef<"u"?WeakRef:up,fp=0,Go=1;function qn(){return{s:fp,v:void 0,o:null,p:null}}function oc(e,t={}){let n=qn();const{resultEqualityCheck:s}=t;let r,i=0;function o(){let a=n;const{length:l}=arguments;for(let d=0,f=l;d<f;d++){const m=arguments[d];if(typeof m=="function"||typeof m=="object"&&m!==null){let p=a.o;p===null&&(a.o=p=new WeakMap);const y=p.get(m);y===void 0?(a=qn(),p.set(m,a)):a=y}else{let p=a.p;p===null&&(a.p=p=new Map);const y=p.get(m);y===void 0?(a=qn(),p.set(m,a)):a=y}}const c=a;let u;if(a.s===Go)u=a.v;else if(u=e.apply(null,arguments),i++,s){const d=r?.deref?.()??r;d!=null&&s(d,u)&&(u=d,i!==0&&i--),r=typeof u=="object"&&u!==null||typeof u=="function"?new dp(u):u}return c.s=Go,c.v=u,u}return o.clearCache=()=>{n=qn(),o.resetResultsCount()},o.resultsCount=()=>i,o.resetResultsCount=()=>{i=0},o}function ac(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,s=(...r)=>{let i=0,o=0,a,l={},c=r.pop();typeof c=="object"&&(l=c,c=r.pop()),ep(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:d,memoizeOptions:f=[],argsMemoize:m=oc,argsMemoizeOptions:p=[]}=u,y=Ho(f),b=Ho(p),x=sp(r),w=d(function(){return i++,c.apply(null,arguments)},...y),v=m(function(){o++;const S=rp(x,arguments);return a=w.apply(null,S),a},...b);return Object.assign(v,{resultFunc:c,memoizedResultFunc:w,dependencies:x,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>a,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:d,argsMemoize:m})};return Object.assign(s,{withTypes:()=>s}),s}var hp=ac(oc),mp=Object.assign((e,t=hp)=>{tp(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),s=n.map(i=>e[i]);return t(s,(...i)=>i.reduce((o,a,l)=>(o[n[l]]=a,o),{}))},{withTypes:()=>mp});ac({memoize:cp,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const oe=(e,t,n,s,r,i,...o)=>{if(o.length>0)throw new Error(gi(1));let a;if(e)a=e;else throw new Error("Missing arguments");return a};var hr={exports:{}},mr={};var Yo;function pp(){if(Yo)return mr;Yo=1;var e=Al();function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,r=e.useEffect,i=e.useLayoutEffect,o=e.useDebugValue;function a(d,f){var m=f(),p=s({inst:{value:m,getSnapshot:f}}),y=p[0].inst,b=p[1];return i(function(){y.value=m,y.getSnapshot=f,l(y)&&b({inst:y})},[d,m,f]),r(function(){return l(y)&&b({inst:y}),d(function(){l(y)&&b({inst:y})})},[d]),o(m),m}function l(d){var f=d.getSnapshot;d=d.value;try{var m=f();return!n(d,m)}catch{return!0}}function c(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return mr.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,mr}var zo;function lc(){return zo||(zo=1,hr.exports=pp()),hr.exports}var gp=lc(),pr={exports:{}},gr={};var qo;function yp(){if(qo)return gr;qo=1;var e=Al(),t=lc();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var s=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,o=e.useEffect,a=e.useMemo,l=e.useDebugValue;return gr.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var p=i(null);if(p.current===null){var y={hasValue:!1,value:null};p.current=y}else y=p.current;p=a(function(){function x(R){if(!w){if(w=!0,v=R,R=f(R),m!==void 0&&y.hasValue){var N=y.value;if(m(N,R))return T=N}return T=R}if(N=T,s(v,R))return N;var C=f(R);return m!==void 0&&m(N,C)?(v=R,N):(v=R,T=C)}var w=!1,v,T,S=d===void 0?null:d;return[function(){return x(u())},S===null?void 0:function(){return x(S())}]},[u,d,f,m]);var b=r(c,p[0],p[1]);return o(function(){y.hasValue=!0,y.value=b},[b]),l(b),b},gr}var Xo;function bp(){return Xo||(Xo=1,pr.exports=yp()),pr.exports}var xp=bp();const vp=Pl(19),wp=vp?kp:Tp;function Sp(e,t,n,s,r){return wp(e,t,n,s,r)}function kp(e,t,n,s,r){const i=h.useCallback(()=>t(e.getSnapshot(),n,s,r),[e,t,n,s,r]);return gp.useSyncExternalStore(e.subscribe,i,i)}function Tp(e,t,n,s,r){return xp.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,i=>t(i,n,s,r))}class xn{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 s of this.listeners){if(n!==this.updateTick)return;s(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){xn.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||xn.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};xn.prototype.setState.call(this,t)}}class cc extends xn{constructor(t,n={},s){super(t),this.context=n,this.selectors=s}controlledValues=new Map;useSyncedValue(t,n){h.useDebugValue(t),Pe(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const s=this;Pe(()=>(s.state[t]!==n&&s.set(t,n),()=>{s.set(t,void 0)}),[s,t,n])}useSyncedValues(t){const n=this,s=Object.values(t);Pe(()=>{n.update(t)},[n,...s])}useControlledProp(t,n,s){h.useDebugValue(t);const r=this,i=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,i),!i&&!Object.is(this.state[t],s)&&super.setState({...this.state,[t]:s})),Pe(()=>{i&&!Object.is(r.state[t],n)&&super.setState({...r.state,[t]:n})},[r,t,n,s,i])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const s in n)if(Object.hasOwn(n,s)&&this.controlledValues.get(s)===!0){delete n[s];continue}super.update(n)}setState(t){const n={...t};for(const s in n)if(Object.hasOwn(n,s)&&this.controlledValues.get(s)===!0){delete n[s];continue}super.setState({...this.state,...n})}select=(t,n,s,r)=>{const i=this.selectors[t];return i(this.state,n,s,r)};useState=(t,n,s,r)=>{h.useDebugValue(t);const i=this.selectors[t];return Sp(this,i,n,s,r)};useContextCallback(t,n){h.useDebugValue(t);const s=ie(n??Rl);this.context[t]=s}useStateSetter(t){const n=h.useRef(void 0);return n.current===void 0&&(n.current=s=>{this.set(t,s)}),n.current}observe(t,n){let s;typeof t=="function"?s=t:s=this.selectors[t];let r=s(this.state);return n(r,r,this),this.subscribe(i=>{const o=s(i);if(!Object.is(r,o)){const a=r;r=o,n(o,a,this)}})}}const Xn=null;class Cp{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,s=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,s>0)for(let r=0;r<n.length;r+=1)n[r]?.(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 Zn=new Cp;class rt{static create(){return new rt}static request(t){return Zn.request(t)}static cancel(t){return Zn.cancel(t)}currentId=Xn;request(t){this.cancel(),this.currentId=Zn.request(()=>{this.currentId=Xn,t()})}cancel=()=>{this.currentId!==Xn&&(Zn.cancel(this.currentId),this.currentId=Xn)};disposeEffect=()=>this.cancel}function uc(){const e=Dn(rt.create).current;return Fl(e.disposeEffect),e}function Ep(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(s=>s(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)}}}const Ap=h.createContext(null),Pp=h.createContext(null),dc=()=>h.useContext(Ap)?.id||null,fc=e=>{const t=h.useContext(Pp);return e??t};function Ss(e){return`data-base-ui-${e}`}const ks=h.forwardRef(function(t,n){const[s,r]=h.useState();Pe(()=>{Oh&&r("button")},[]);const i={tabIndex:0,role:s};return g.jsx("span",{...t,ref:n,style:ic,"aria-hidden":s?void 0:!0,...i,"data-base-ui-focus-guard":""})});let Zo=0;function yr(e,t={}){const{preventScroll:n=!1,cancelPrevious:s=!0,sync:r=!1}=t;s&&cancelAnimationFrame(Zo);const i=()=>e?.focus({preventScroll:n});r?i():Zo=requestAnimationFrame(i)}const qt={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function Jo(e){return e==="inert"?qt.inert:e==="aria-hidden"?qt["aria-hidden"]:qt.none}let Jn=new WeakSet,Qn={},br=0;const hc=e=>e&&(e.host||hc(e.parentNode)),Rp=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=hc(n);return e.contains(s)?s:null}).filter(n=>n!=null);function Mp(e,t,n,s){const r="data-base-ui-inert",i=s?"inert":n?"aria-hidden":null,o=Rp(t,e),a=new Set,l=new Set(o),c=[];Qn[r]||(Qn[r]=new WeakMap);const u=Qn[r];o.forEach(d),f(t),a.clear();function d(m){!m||a.has(m)||(a.add(m),m.parentNode&&d(m.parentNode))}function f(m){!m||l.has(m)||[].forEach.call(m.children,p=>{if(Ml(p)!=="script")if(a.has(p))f(p);else{const y=i?p.getAttribute(i):null,b=y!==null&&y!=="false",x=Jo(i),w=(x.get(p)||0)+1,v=(u.get(p)||0)+1;x.set(p,w),u.set(p,v),c.push(p),w===1&&b&&Jn.add(p),v===1&&p.setAttribute(r,""),!b&&i&&p.setAttribute(i,i==="inert"?"":"true")}})}return br+=1,()=>{c.forEach(m=>{const p=Jo(i),b=(p.get(m)||0)-1,x=(u.get(m)||0)-1;p.set(m,b),u.set(m,x),b||(!Jn.has(m)&&i&&m.removeAttribute(i),Jn.delete(m)),x||m.removeAttribute(r)}),br-=1,br||(qt.inert=new WeakMap,qt["aria-hidden"]=new WeakMap,qt.none=new WeakMap,Jn=new WeakSet,Qn={})}}function Dp(e,t=!1,n=!1){const s=Ve(e[0]).body;return Mp(e.concat(Array.from(s.querySelectorAll("[aria-live]"))),s,t,n)}const mc=h.createContext(null),pc=()=>h.useContext(mc),Np=Ss("portal");function jp(e={}){const{ref:t,container:n,componentProps:s=yn,elementProps:r,elementState:i}=e,o=bi(),l=pc()?.portalNode,[c,u]=h.useState(null),[d,f]=h.useState(null),m=ie(x=>{x!==null&&f(x)}),p=h.useRef(null);Pe(()=>{if(n===null){p.current&&(p.current=null,f(null),u(null));return}if(o==null)return;const x=(n&&(Xf(n)?n:n.current))??l??document.body;if(x==null){p.current&&(p.current=null,f(null),u(null));return}p.current!==x&&(p.current=x,f(null),u(x))},[n,l,o]);const y=nn("div",s,{ref:[t,m],state:i,props:[{id:o,[Np]:""},r]});return{portalNode:d,portalSubtree:c&&y?yi.createPortal(y,c):null}}const Lp=h.forwardRef(function(t,n){const{children:s,container:r,className:i,render:o,renderGuards:a,...l}=t,{portalNode:c,portalSubtree:u}=jp({container:r,ref:n,componentProps:t,elementProps:l}),d=h.useRef(null),f=h.useRef(null),m=h.useRef(null),p=h.useRef(null),[y,b]=h.useState(null),x=y?.modal,w=y?.open,v=typeof a=="boolean"?a:!!y&&!y.modal&&y.open&&!!c;h.useEffect(()=>{if(!c||x)return;function S(R){c&&R.relatedTarget&&bn(R)&&(R.type==="focusin"?Bo:hm)(c)}return c.addEventListener("focusin",S,!0),c.addEventListener("focusout",S,!0),()=>{c.removeEventListener("focusin",S,!0),c.removeEventListener("focusout",S,!0)}},[c,x]),h.useEffect(()=>{!c||w||Bo(c)},[w,c]);const T=h.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:m,afterInsideRef:p,portalNode:c,setFocusManagerState:b}),[c]);return g.jsxs(h.Fragment,{children:[u,g.jsxs(mc.Provider,{value:T,children:[v&&c&&g.jsx(ks,{"data-type":"outside",ref:d,onFocus:S=>{if(bn(S,c))m.current?.focus();else{const R=y?y.domReference:null;Jl(R)?.focus()}}}),v&&c&&g.jsx("span",{"aria-owns":c.id,style:Ih}),c&&yi.createPortal(s,c),v&&c&&g.jsx(ks,{"data-type":"outside",ref:f,onFocus:S=>{if(bn(S,c))p.current?.focus();else{const R=y?y.domReference:null;Zl(R)?.focus(),y?.closeOnFocusOut&&y?.onOpenChange(!1,pt(Dl,S.nativeEvent))}}})]})]})});function mt(e){return e==null?e:"current"in e?e.current:e}function Vp(e,t){const n=Ls(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 Qo=20;let xt=[];function Si(){xt=xt.filter(e=>e.isConnected)}function Ip(e){Si(),e&&Ml(e)!=="body"&&(xt.push(e),xt.length>Qo&&(xt=xt.slice(-Qo)))}function xr(){return Si(),xt[xt.length-1]}function Fp(e){if(!e)return null;const t=jn();return ql(e,t)?e:Vs(e,t)[0]||e}function _p(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():jl(e).display!=="none"}function ea(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=jn(),r=fm(e,n).filter(o=>{const a=o.getAttribute("data-tabindex")||"";return ql(o,n)||o.hasAttribute("data-tabindex")&&!a.startsWith("-")}),i=e.getAttribute("tabindex");t.current.includes("floating")||r.length===0?i!=="0"&&e.setAttribute("tabindex","0"):(i!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Op(e){const{context:t,children:n,disabled:s=!1,order:r=["content"],initialFocus:i=!0,returnFocus:o=!0,restoreFocus:a=!1,modal:l=!0,closeOnFocusOut:c=!0,openInteractionType:u="",getInsideElements:d=()=>[],nextFocusableElement:f,previousFocusableElement:m,beforeContentFocusGuardRef:p,externalTree:y}=e,b="rootStore"in t?t.rootStore:t,x=b.useState("open"),w=b.useState("domReferenceElement"),v=b.useState("floatingElement"),{events:T,dataRef:S}=b.context,R=ie(()=>S.current.floatingContext?.nodeId),N=ie(d),C=i===!1,I=Fo(w)&&C,A=zn(r),M=zn(i),U=zn(o),L=zn(u),$=fc(y),j=pc(),W=h.useRef(null),pe=h.useRef(null),D=h.useRef(!1),_=h.useRef(!1),z=h.useRef(!1),X=h.useRef(-1),se=h.useRef(""),H=h.useRef(""),Q=h.useRef(null),ee=h.useRef(null),de=jo(Q,p,j?.beforeInsideRef),be=jo(ee,j?.afterInsideRef),Ne=ps(),Be=ps(),Qe=uc(),et=j!=null,E=Wr(v),te=ie((V=E)=>V?Vs(V,jn()):[]),G=ie(V=>{const J=te(V);return A.current.map(()=>J).filter(Boolean).flat()});h.useEffect(()=>{if(s||!l)return;function V(Z){Z.key==="Tab"&&we(E,Ut(Ve(E)))&&te().length===0&&!I&&Yh(Z)}const J=Ve(E);return J.addEventListener("keydown",V),()=>{J.removeEventListener("keydown",V)}},[s,w,E,l,A,I,te,G]),h.useEffect(()=>{if(s||!v)return;function V(J){const Z=Xe(J),ce=te().indexOf(Z);ce!==-1&&(X.current=ce)}return v.addEventListener("focusin",V),()=>{v.removeEventListener("focusin",V)}},[s,v,te]),h.useEffect(()=>{if(s||!x)return;const V=Ve(E);function J(){z.current=!1}function Z(ce){const K=Xe(ce),Y=we(v,K)||we(w,K)||we(j?.portalNode,K);z.current=!Y,H.current=ce.pointerType||"keyboard"}function ne(){H.current="keyboard"}return V.addEventListener("pointerdown",Z,!0),V.addEventListener("pointerup",J,!0),V.addEventListener("pointercancel",J,!0),V.addEventListener("keydown",ne,!0),()=>{V.removeEventListener("pointerdown",Z,!0),V.removeEventListener("pointerup",J,!0),V.removeEventListener("pointercancel",J,!0),V.removeEventListener("keydown",ne,!0)}},[s,v,w,E,x,j]),h.useEffect(()=>{if(s||!c)return;function V(){_.current=!0,Be.start(0,()=>{_.current=!1})}function J(K){const Y=K.relatedTarget,Ee=K.currentTarget,he=Xe(K);queueMicrotask(()=>{const je=R(),Le=b.context.triggerElements,ct=Y?.hasAttribute(Ss("focus-guard"))&&[Q.current,ee.current,j?.beforeInsideRef.current,j?.afterInsideRef.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,mt(m),mt(f)].includes(Y),ve=!(we(w,Y)||we(v,Y)||we(Y,v)||we(j?.portalNode,Y)||Y!=null&&Le.hasElement(Y)||Le.hasMatchingElement(re=>we(re,Y))||ct||$&&(zt($.nodesRef.current,je).find(re=>we(re.context?.elements.floating,Y)||we(re.context?.elements.domReference,Y))||_o($.nodesRef.current,je).find(re=>[re.context?.elements.floating,Wr(re.context?.elements.floating)].includes(Y)||re.context?.elements.domReference===Y)));if(Ee===w&&E&&ea(E,A),a&&Ee!==w&&!_p(he)&&Ut(Ve(E))===Ve(E).body){if(Rt(E)&&(E.focus(),a==="popup")){Qe.request(()=>{E.focus()});return}const re=X.current,Re=te(),Ie=Re[re]||Re[Re.length-1]||E;Rt(Ie)&&Ie.focus()}if(S.current.insideReactTree){S.current.insideReactTree=!1;return}(I||!l)&&Y&&ve&&!_.current&&(I||Y!==xr())&&(D.current=!0,b.setOpen(!1,pt(Dl,K)))})}function Z(){z.current||(S.current.insideReactTree=!0,Ne.start(0,()=>{S.current.insideReactTree=!1}))}const ne=Rt(w)?w:null,ce=[];if(!(!v&&!ne))return ne&&(ne.addEventListener("focusout",J),ne.addEventListener("pointerdown",V),ce.push(()=>{ne.removeEventListener("focusout",J),ne.removeEventListener("pointerdown",V)})),v&&(v.addEventListener("focusout",J),j&&(v.addEventListener("focusout",Z,!0),ce.push(()=>{v.removeEventListener("focusout",Z,!0)})),ce.push(()=>{v.removeEventListener("focusout",J)})),()=>{ce.forEach(K=>{K()})}},[s,w,v,E,l,$,j,b,c,a,te,I,R,A,S,Ne,Be,Qe,f,m]),h.useEffect(()=>{if(s||!v||!x)return;const V=Array.from(j?.portalNode?.querySelectorAll(`[${Ss("portal")}]`)||[]),Z=($?_o($.nodesRef.current,R()):[]).find(K=>Fo(K.context?.elements.domReference||null))?.context?.elements.domReference,ne=[v,Z,...V,...N(),W.current,pe.current,Q.current,ee.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,mt(m),mt(f),I?w:null].filter(K=>K!=null),ce=Dp(ne,l||I);return()=>{ce()}},[x,s,w,v,l,A,j,I,$,R,N,f,m]),Pe(()=>{if(!x||s||!Rt(E))return;const V=Ve(E),J=Ut(V);queueMicrotask(()=>{const Z=G(E),ne=M.current,ce=typeof ne=="function"?ne(L.current||""):ne;if(ce===void 0||ce===!1)return;let K;ce===!0||ce===null?K=Z[0]||E:K=mt(ce),K=K||Z[0]||E,!we(E,J)&&yr(K,{preventScroll:K===E})})},[s,x,E,C,G,M,L]),Pe(()=>{if(s||!E)return;const V=Ve(E),J=Ut(V);Ip(J);function Z(K){if(K.open||(se.current=Vp(K.nativeEvent,H.current)),K.reason===Zf&&K.nativeEvent.type==="mouseleave"&&(D.current=!0),K.reason===Nl)if(K.nested)D.current=!1;else if(qh(K.nativeEvent)||Xh(K.nativeEvent))D.current=!1;else{let Y=!1;document.createElement("div").focus({get preventScroll(){return Y=!0,!1}}),Y?D.current=!1:D.current=!0}}T.on("openchange",Z);const ne=V.createElement("span");ne.setAttribute("tabindex","-1"),ne.setAttribute("aria-hidden","true"),Object.assign(ne.style,ic),et&&w&&w.insertAdjacentElement("afterend",ne);function ce(){const K=U.current;let Y=typeof K=="function"?K(se.current):K;if(Y===void 0||Y===!1)return null;if(Y===null&&(Y=!0),typeof Y=="boolean"){const he=w||xr();return he&&he.isConnected?he:ne}const Ee=w||xr()||ne;return mt(Y)||Ee}return()=>{T.off("openchange",Z);const K=Ut(V),Y=we(v,K)||$&&zt($.nodesRef.current,R(),!1).some(he=>we(he.context?.elements.floating,K)),Ee=ce();queueMicrotask(()=>{const he=Fp(Ee),je=typeof U.current!="boolean";U.current&&!D.current&&Rt(he)&&(!(!je&&he!==K&&K!==V.body)||Y)&&he.focus({preventScroll:!0}),ne.remove()})}},[s,v,E,U,S,T,$,et,w,R]),h.useEffect(()=>{queueMicrotask(()=>{D.current=!1})},[s]),h.useEffect(()=>{if(s||!x)return;function V(Z){Xe(Z)?.closest(`[${Vh}]`)&&(_.current=!0)}const J=Ve(E);return J.addEventListener("pointerdown",V,!0),()=>{J.removeEventListener("pointerdown",V,!0)}},[s,x,E]),Pe(()=>{if(!s&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:c,open:x,onOpenChange:b.setOpen,domReference:w}),()=>{j.setFocusManagerState(null)}},[s,j,l,x,b,c,w]),Pe(()=>{if(!(s||!E))return ea(E,A),()=>{queueMicrotask(Si)}},[s,E,A]);const xe=!s&&(l?!I:!0)&&(et||l);return g.jsxs(h.Fragment,{children:[xe&&g.jsx(ks,{"data-type":"inside",ref:de,onFocus:V=>{if(l){const J=G();yr(J[J.length-1])}else j?.portalNode&&(D.current=!1,bn(V,j.portalNode)?Zl(w)?.focus():mt(m??j.beforeOutsideRef)?.focus())}}),n,xe&&g.jsx(ks,{"data-type":"inside",ref:be,onFocus:V=>{l?yr(G()[0]):j?.portalNode&&(c&&(D.current=!0),bn(V,j.portalNode)?Jl(w)?.focus():mt(f??j.afterOutsideRef)?.focus())}})]})}const Bp={intentional:"onClick",sloppy:"onPointerDown"};function $p(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function Up(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),r=n.useState("floatingElement"),i=n.useState("referenceElement"),o=n.useState("domReferenceElement"),{onOpenChange:a,dataRef:l}=n.context,{enabled:c=!0,escapeKey:u=!0,outsidePress:d=!0,outsidePressEvent:f="sloppy",referencePress:m=!1,referencePressEvent:p="sloppy",ancestorScroll:y=!1,bubbles:b,externalTree:x}=t,w=fc(x),v=ie(typeof d=="function"?d:()=>!1),T=typeof d=="function"?v:d,S=h.useRef(!1),{escapeKey:R,outsidePress:N}=$p(b),C=h.useRef(null),I=ps(),A=ps(),M=ie(()=>{A.clear(),l.current.insideReactTree=!1}),U=h.useRef(!1),L=h.useRef(""),$=ie(E=>{L.current=E.pointerType}),j=ie(()=>{const E=L.current,te=E==="pen"||!E?"mouse":E,G=typeof f=="function"?f():f;return typeof G=="string"?G:G[te]}),W=ie(E=>{if(!s||!c||!u||E.key!=="Escape"||U.current)return;const te=l.current.floatingContext?.nodeId,G=w?zt(w.nodesRef.current,te):[];if(!R&&G.length>0){let J=!0;if(G.forEach(Z=>{Z.context?.open&&!Z.context.dataRef.current.__escapeKeyBubbles&&(J=!1)}),!J)return}const xe=zh(E)?E.nativeEvent:E,V=pt(Jf,xe);n.setOpen(!1,V),!R&&!V.isPropagationAllowed&&E.stopPropagation()}),pe=ie(E=>{const te=j();return te==="intentional"&&E.type!=="click"||te==="sloppy"&&E.type==="click"}),D=ie(()=>{l.current.insideReactTree=!0,A.start(0,M)}),_=ie((E,te=!1)=>{if(pe(E)){M();return}if(l.current.insideReactTree){M();return}if(j()==="intentional"&&te||typeof T=="function"&&!T(E))return;const G=Xe(E),xe=`[${Ss("inert")}]`,V=Ve(n.select("floatingElement")).querySelectorAll(xe),J=n.context.triggerElements;if(G&&(J.hasElement(G)||J.hasMatchingElement(Y=>we(Y,G))))return;let Z=At(G)?G:null;for(;Z&&!tr(Z);){const Y=Qf(Z);if(tr(Y)||!At(Y))break;Z=Y}if(V.length&&At(G)&&!Hh(G)&&!we(G,n.select("floatingElement"))&&Array.from(V).every(Y=>!we(Z,Y)))return;if(Rt(G)&&!("touches"in E)){const Y=tr(G),Ee=jl(G),he=/auto|scroll/,je=Y||he.test(Ee.overflowX),Le=Y||he.test(Ee.overflowY),ct=je&&G.clientWidth>0&&G.scrollWidth>G.clientWidth,ve=Le&&G.clientHeight>0&&G.scrollHeight>G.clientHeight,re=Ee.direction==="rtl",Re=ve&&(re?E.offsetX<=G.offsetWidth-G.clientWidth:E.offsetX>G.clientWidth),Ie=ct&&E.offsetY>G.clientHeight;if(Re||Ie)return}const ne=l.current.floatingContext?.nodeId,ce=w&&zt(w.nodesRef.current,ne).some(Y=>Ye(E,Y.context?.elements.floating));if(Ye(E,n.select("floatingElement"))||Ye(E,n.select("domReferenceElement"))||ce)return;const K=w?zt(w.nodesRef.current,ne):[];if(K.length>0){let Y=!0;if(K.forEach(Ee=>{Ee.context?.open&&!Ee.context.dataRef.current.__outsidePressBubbles&&(Y=!1)}),!Y)return}n.setOpen(!1,pt(Nl,E)),M()}),z=ie(E=>{j()!=="sloppy"||E.pointerType==="touch"||!n.select("open")||!c||Ye(E,n.select("floatingElement"))||Ye(E,n.select("domReferenceElement"))||_(E)}),X=ie(E=>{if(j()!=="sloppy"||!n.select("open")||!c||Ye(E,n.select("floatingElement"))||Ye(E,n.select("domReferenceElement")))return;const te=E.touches[0];te&&(C.current={startTime:Date.now(),startX:te.clientX,startY:te.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},I.start(1e3,()=>{C.current&&(C.current.dismissOnTouchEnd=!1,C.current.dismissOnMouseDown=!1)}))}),se=ie(E=>{const te=Xe(E);function G(){X(E),te?.removeEventListener(E.type,G)}te?.addEventListener(E.type,G)}),H=ie(E=>{const te=S.current;if(S.current=!1,I.clear(),E.type==="mousedown"&&C.current&&!C.current.dismissOnMouseDown)return;const G=Xe(E);function xe(){E.type==="pointerdown"?z(E):_(E,te),G?.removeEventListener(E.type,xe)}G?.addEventListener(E.type,xe)}),Q=ie(E=>{if(j()!=="sloppy"||!C.current||Ye(E,n.select("floatingElement"))||Ye(E,n.select("domReferenceElement")))return;const te=E.touches[0];if(!te)return;const G=Math.abs(te.clientX-C.current.startX),xe=Math.abs(te.clientY-C.current.startY),V=Math.sqrt(G*G+xe*xe);V>5&&(C.current.dismissOnTouchEnd=!0),V>10&&(_(E),I.clear(),C.current=null)}),ee=ie(E=>{const te=Xe(E);function G(){Q(E),te?.removeEventListener(E.type,G)}te?.addEventListener(E.type,G)}),de=ie(E=>{j()!=="sloppy"||!C.current||Ye(E,n.select("floatingElement"))||Ye(E,n.select("domReferenceElement"))||(C.current.dismissOnTouchEnd&&_(E),I.clear(),C.current=null)}),be=ie(E=>{const te=Xe(E);function G(){de(E),te?.removeEventListener(E.type,G)}te?.addEventListener(E.type,G)});h.useEffect(()=>{if(!s||!c)return;l.current.__escapeKeyBubbles=R,l.current.__outsidePressBubbles=N;const E=new Zt;function te(Z){n.setOpen(!1,pt(th,Z))}function G(){E.clear(),U.current=!0}function xe(){E.start(eh()?5:0,()=>{U.current=!1})}const V=Ve(r);V.addEventListener("pointerdown",$,!0),u&&(V.addEventListener("keydown",W),V.addEventListener("compositionstart",G),V.addEventListener("compositionend",xe)),T&&(V.addEventListener("click",H,!0),V.addEventListener("pointerdown",H,!0),V.addEventListener("touchstart",se,!0),V.addEventListener("touchmove",ee,!0),V.addEventListener("touchend",be,!0),V.addEventListener("mousedown",H,!0));let J=[];return y&&(At(o)&&(J=nr(o)),At(r)&&(J=J.concat(nr(r))),!At(i)&&i&&i.contextElement&&(J=J.concat(nr(i.contextElement)))),J=J.filter(Z=>Z!==V.defaultView?.visualViewport),J.forEach(Z=>{Z.addEventListener("scroll",te,{passive:!0})}),()=>{V.removeEventListener("pointerdown",$,!0),u&&(V.removeEventListener("keydown",W),V.removeEventListener("compositionstart",G),V.removeEventListener("compositionend",xe)),T&&(V.removeEventListener("click",H,!0),V.removeEventListener("pointerdown",H,!0),V.removeEventListener("touchstart",se,!0),V.removeEventListener("touchmove",ee,!0),V.removeEventListener("touchend",be,!0),V.removeEventListener("mousedown",H,!0)),J.forEach(Z=>{Z.removeEventListener("scroll",te)}),E.clear(),S.current=!1}},[l,r,i,o,u,T,s,a,y,c,R,N,W,_,H,z,se,ee,be,$,n]),h.useEffect(M,[T,M]);const Ne=h.useMemo(()=>({onKeyDown:W,...m&&{[Bp[p]]:E=>{n.setOpen(!1,pt(Lo,E.nativeEvent))},...p!=="intentional"&&{onClick(E){n.setOpen(!1,pt(Lo,E.nativeEvent))}}}}),[W,n,m,p]),Be=ie(E=>{const te=Xe(E.nativeEvent);!we(n.select("floatingElement"),te)||E.button!==0||(S.current=!0)}),Qe=ie(E=>{!s||!c||E.button!==0||(S.current=!0)}),et=h.useMemo(()=>({onKeyDown:W,onPointerDown:Be,onMouseDown:Be,onMouseUp:Be,onClickCapture:D,onMouseDownCapture(E){D(),Qe(E)},onPointerDownCapture(E){D(),Qe(E)},onMouseUpCapture:D,onTouchEndCapture:D,onTouchMoveCapture:D}),[W,Be,D,Qe]);return h.useMemo(()=>c?{reference:Ne,floating:et,trigger:Ne}:{},[c,Ne,et])}const Wp={open:oe(e=>e.open),domReferenceElement:oe(e=>e.domReferenceElement),referenceElement:oe(e=>e.positionReference??e.referenceElement),floatingElement:oe(e=>e.floatingElement),floatingId:oe(e=>e.floatingId)};class gc extends cc{constructor(t){const{nested:n,noEmit:s,onOpenChange:r,triggerElements:i,...o}=t;super({...o,positionReference:o.referenceElement,domReferenceElement:o.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:Ep(),nested:n,noEmit:s,triggerElements:i},Wp)}setOpen=(t,n)=>{if((!t||!this.state.open||Zh(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const s={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",s)}this.context.onOpenChange?.(t,n)}}function Kp(e,t=!1,n=!1){const[s,r]=h.useState(e&&t?"idle":void 0),[i,o]=h.useState(e);return e&&!i&&(o(!0),r("starting")),!e&&i&&s!=="ending"&&!n&&r("ending"),!e&&!i&&s==="ending"&&r(void 0),Pe(()=>{if(!e&&i&&s!=="ending"&&n){const a=rt.request(()=>{r("ending")});return()=>{rt.cancel(a)}}},[e,i,s,n]),Pe(()=>{if(!e||t)return;const a=rt.request(()=>{r(void 0)});return()=>{rt.cancel(a)}},[t,e]),Pe(()=>{if(!e||!t)return;e&&i&&s!=="idle"&&r("starting");const a=rt.request(()=>{r("idle")});return()=>{rt.cancel(a)}},[t,e,i,r,s]),h.useMemo(()=>({mounted:i,setMounted:o,transitionStatus:s}),[i,s])}let Cn=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const Hp={[Cn.startingStyle]:""},Gp={[Cn.endingStyle]:""},ki={transitionStatus(e){return e==="starting"?Hp:e==="ending"?Gp:null}};function Yp(e,t=!1,n=!0){const s=uc();return ie((r,i=null)=>{s.cancel();function o(){yi.flushSync(r)}const a=mt(e);if(a==null)return;const l=a;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)r();else{let c=function(){const d=Cn.startingStyle;if(!l.hasAttribute(d)){s.request(u);return}const f=new MutationObserver(()=>{l.hasAttribute(d)||(f.disconnect(),u())});f.observe(l,{attributes:!0,attributeFilter:[d]}),i?.addEventListener("abort",()=>f.disconnect(),{once:!0})},u=function(){Promise.all(l.getAnimations().map(d=>d.finished)).then(()=>{i?.aborted||o()}).catch(()=>{const d=l.getAnimations();if(n){if(i?.aborted)return;o()}else d.length>0&&d.some(f=>f.pending||f.playState!=="finished")&&u()})};if(t){c();return}s.request(u)}})}function yc(e){const{enabled:t=!0,open:n,ref:s,onComplete:r}=e,i=ie(r),o=Yp(s,n,!1);h.useEffect(()=>{if(!t)return;const a=new AbortController;return o(i,a.signal),()=>{a.abort()}},[t,n,i,o])}function zp(e){const t=e.useState("open");Pe(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[s,r]=n.value;e.update({activeTriggerId:s,activeTriggerElement:r})}}},[t,e])}function qp(e,t,n){const{mounted:s,setMounted:r,transitionStatus:i}=Kp(e);t.useSyncedValues({mounted:s,transitionStatus:i});const o=ie(()=>{r(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),a=t.useState("preventUnmountingOnClose");return yc({enabled:!a,open:e,ref:t.context.popupRef,onComplete(){e||o()}}),{forceUnmount:o,transitionStatus:i}}class bc{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const s=this.idMap.get(t);s!==n&&(s!==void 0&&this.elements.delete(s),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 Xp(){return new gc({open:!1,floatingElement:null,referenceElement:null,triggerElements:new bc,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function Zp(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Xp(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:yn,inactiveTriggerProps:yn,popupProps:yn}}const Jp={open:oe(e=>e.open),mounted:oe(e=>e.mounted),transitionStatus:oe(e=>e.transitionStatus),floatingRootContext:oe(e=>e.floatingRootContext),preventUnmountingOnClose:oe(e=>e.preventUnmountingOnClose),payload:oe(e=>e.payload),activeTriggerId:oe(e=>e.activeTriggerId),activeTriggerElement:oe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:oe((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:oe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:oe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:oe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:oe(e=>e.popupProps),popupElement:oe(e=>e.popupElement),positionerElement:oe(e=>e.positionerElement)};function Qp(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:s=!1,onOpenChange:r}=e,i=bi(),o=dc()!=null,a=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(s?"popupElement":"positionerElement"),u=t.context.triggerElements,d=Dn(()=>new gc({open:a,referenceElement:l,floatingElement:c,triggerElements:u,onOpenChange:r,floatingId:i,nested:o,noEmit:n})).current;return Pe(()=>{const f={open:a,floatingId:i,referenceElement:l,floatingElement:c};At(l)&&(f.domReferenceElement=l),d.state.positionReference===d.state.referenceElement&&(f.positionReference=l),d.update(f)},[a,i,l,c,d]),d.context.onOpenChange=r,d.context.nested=o,d.context.noEmit=n,d}function eg(e=[]){const t=e.map(c=>c?.reference),n=e.map(c=>c?.floating),s=e.map(c=>c?.item),r=e.map(c=>c?.trigger),i=h.useCallback(c=>es(c,e,"reference"),t),o=h.useCallback(c=>es(c,e,"floating"),n),a=h.useCallback(c=>es(c,e,"item"),s),l=h.useCallback(c=>es(c,e,"trigger"),r);return h.useMemo(()=>({getReferenceProps:i,getFloatingProps:o,getItemProps:a,getTriggerProps:l}),[i,o,a,l])}function es(e,t,n){const s=new Map,r=n==="item",i={};n==="floating"&&(i.tabIndex=-1,i[Ur]="");for(const o in e)r&&e&&(o===$l||o===Ul)||(i[o]=e[o]);for(let o=0;o<t.length;o+=1){let a;const l=t[o]?.[n];typeof l=="function"?a=e?l(e):null:a=l,a&&ta(i,a,r,s)}return ta(i,e,r,s),i}function ta(e,t,n,s){for(const r in t){const i=t[r];n&&(r===$l||r===Ul)||(r.startsWith("on")?(s.has(r)||s.set(r,[]),typeof i=="function"&&(s.get(r)?.push(i),e[r]=(...o)=>s.get(r)?.map(a=>a(...o)).find(a=>a!==void 0))):e[r]=i)}}const tg=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function ng(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),r=n.useState("floatingId"),i=n.useState("domReferenceElement"),o=n.useState("floatingElement"),{enabled:a=!0,role:l="dialog"}=t,c=bi(),u=i?.id||c,d=h.useMemo(()=>Wr(o)?.id||r,[o,r]),f=tg.get(l)??l,p=dc()!=null,y=h.useMemo(()=>f==="tooltip"||l==="label"?yn:{"aria-haspopup":f==="alertdialog"?"dialog":f,"aria-expanded":"false",...f==="listbox"&&{role:"combobox"},...f==="menu"&&p&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[f,p,l]),b=h.useMemo(()=>f==="tooltip"||l==="label"?{[`aria-${l==="label"?"labelledby":"describedby"}`]:s?d:void 0}:{...y,"aria-expanded":s?"true":"false","aria-controls":s?d:void 0,...f==="menu"&&{id:u}},[f,d,s,u,l,y]),x=h.useMemo(()=>{const v={id:d,...f&&{role:f}};return f==="tooltip"||l==="label"?v:{...v,...f==="menu"&&{"aria-labelledby":u}}},[f,d,u,l]),w=h.useCallback(({active:v,selected:T})=>{const S={role:"option",...v&&{id:`${d}-fui-option`}};switch(l){case"select":case"combobox":return{...S,"aria-selected":T}}return{}},[d,l]);return h.useMemo(()=>a?{reference:b,floating:x,item:w,trigger:y}:{},[a,b,x,y,w])}function sg(e){const t=h.useRef(""),n=h.useCallback(r=>{r.defaultPrevented||(t.current=r.pointerType,e(r,r.pointerType))},[e]);return{onClick:h.useCallback(r=>{if(r.detail===0){e(r,"keyboard");return}"pointerType"in r&&e(r,r.pointerType),e(r,t.current),t.current=""},[e]),onPointerDown:n}}function rg(e){const[t,n]=h.useState(null),s=ie((a,l)=>{e||n(l||(Bl?"touch":""))}),r=h.useCallback(()=>{n(null)},[]),{onClick:i,onPointerDown:o}=sg(s);return h.useMemo(()=>({openMethod:t,reset:r,triggerProps:{onClick:i,onPointerDown:o}}),[t,r,i,o])}let Ze=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Cn.startingStyle]="startingStyle",e[e.endingStyle=Cn.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({});const ig={[Ze.open]:""},og={[Ze.closed]:""},ag={[Ze.anchorHidden]:""},Ti={open(e){return e?ig:og},anchorHidden(e){return e?ag:null}};function lg(e){return Pl(19)?e:e?"true":void 0}let na={},sa={},ra="";function cg(e){if(typeof document>"u")return!1;const t=Nn(e);return Ls(t).innerWidth-t.documentElement.clientWidth>0}function ug(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const s=Nn(e).documentElement,r={scrollbarGutter:s.style.scrollbarGutter,overflowY:s.style.overflowY};s.style.scrollbarGutter="stable",s.style.overflowY="scroll";const i=s.offsetWidth;s.style.overflowY="hidden";const o=s.offsetWidth;return Object.assign(s.style,r),i===o}function dg(e){const t=Nn(e),n=t.documentElement,s=t.body,r=Ll(n)?n:s,i=r.style.overflow;return r.style.overflow="hidden",()=>{r.style.overflow=i}}function fg(e){const t=Nn(e),n=t.documentElement,s=t.body,r=Ls(n);let i=0,o=0,a=!1;const l=rt.create();if(_h&&(r.visualViewport?.scale??1)!==1)return()=>{};function c(){const f=r.getComputedStyle(n),m=r.getComputedStyle(s),b=(f.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";i=n.scrollTop,o=n.scrollLeft,na={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ra=n.style.scrollBehavior,sa={position:s.style.position,height:s.style.height,width:s.style.width,boxSizing:s.style.boxSizing,overflowY:s.style.overflowY,overflowX:s.style.overflowX,scrollBehavior:s.style.scrollBehavior};const x=n.scrollHeight>n.clientHeight,w=n.scrollWidth>n.clientWidth,v=f.overflowY==="scroll"||m.overflowY==="scroll",T=f.overflowX==="scroll"||m.overflowX==="scroll",S=Math.max(0,r.innerWidth-s.clientWidth),R=Math.max(0,r.innerHeight-s.clientHeight),N=parseFloat(m.marginTop)+parseFloat(m.marginBottom),C=parseFloat(m.marginLeft)+parseFloat(m.marginRight),I=Ll(n)?n:s;if(a=ug(e),a){n.style.scrollbarGutter=b,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(x||v)&&(n.style.overflowY="scroll"),(w||T)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:N||R?`calc(100dvh - ${N+R}px)`:"100dvh",width:C||S?`calc(100vw - ${C+S}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),s.scrollTop=i,s.scrollLeft=o,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,na),Object.assign(s.style,sa),a||(n.scrollTop=i,n.scrollLeft=o,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=ra)}function d(){u(),l.request(c)}return c(),r.addEventListener("resize",d),()=>{l.cancel(),u(),typeof r.removeEventListener=="function"&&r.removeEventListener("resize",d)}}class hg{lockCount=0;restore=null;timeoutLock=Zt.create();timeoutUnlock=Zt.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 s=Nn(t).documentElement,r=Ls(s).getComputedStyle(s).overflowY;if(r==="hidden"||r==="clip"){this.restore=Rl;return}const i=Bl||!cg(t);this.restore=i?dg(t):fg(t)}}const mg=new hg;function pg(e=!0,t=null){Pe(()=>{if(e)return mg.acquire(t)},[e,t])}const gg=h.forwardRef(function(t,n){const{cutout:s,...r}=t;let i;if(s){const o=s?.getBoundingClientRect();i=`polygon(
|
|
2
|
-
0% 0%,
|
|
3
|
-
100% 0%,
|
|
4
|
-
100% 100%,
|
|
5
|
-
0% 100%,
|
|
6
|
-
0% 0%,
|
|
7
|
-
${o.left}px ${o.top}px,
|
|
8
|
-
${o.left}px ${o.bottom}px,
|
|
9
|
-
${o.right}px ${o.bottom}px,
|
|
10
|
-
${o.right}px ${o.top}px,
|
|
11
|
-
${o.left}px ${o.top}px
|
|
12
|
-
)`}return g.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...r,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:i}})}),xc="ArrowUp",vc="ArrowDown",wc="ArrowLeft",Sc="ArrowRight",kc="Home",Tc="End",yg=new Set([wc,Sc]),bg=new Set([xc,vc]),xg=new Set([...yg,...bg]);[...xg];const vg=new Set([xc,vc,wc,Sc,kc,Tc]),Cc=h.createContext({});function Ci(e){const t=h.useRef(null);return t.current===null&&(t.current=e()),t.current}const wg=typeof window<"u",Ec=wg?h.useLayoutEffect:h.useEffect,Ei=h.createContext(null);function Ai(e,t){e.indexOf(t)===-1&&e.push(t)}function Ts(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const lt=(e,t,n)=>n>t?t:n<e?e:n;let Pi=()=>{};const wt={},Ac=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Pc(e){return typeof e=="object"&&e!==null}const Rc=e=>/^0[^.\s]+$/u.test(e);function Mc(e){let t;return()=>(t===void 0&&(t=e()),t)}const We=e=>e,Sg=(e,t)=>n=>t(e(n)),Ln=(...e)=>e.reduce(Sg),En=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class Ri{constructor(){this.subscriptions=[]}add(t){return Ai(this.subscriptions,t),()=>Ts(this.subscriptions,t)}notify(t,n,s){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,s);else for(let i=0;i<r;i++){const o=this.subscriptions[i];o&&o(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Oe=e=>e*1e3,$e=e=>e/1e3;function Dc(e,t){return t?e*(1e3/t):0}const Nc=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,kg=1e-7,Tg=12;function Cg(e,t,n,s,r){let i,o,a=0;do o=t+(n-t)/2,i=Nc(o,s,r)-e,i>0?n=o:t=o;while(Math.abs(i)>kg&&++a<Tg);return o}function Vn(e,t,n,s){if(e===t&&n===s)return We;const r=i=>Cg(i,0,1,e,n);return i=>i===0||i===1?i:Nc(r(i),t,s)}const jc=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Lc=e=>t=>1-e(1-t),Vc=Vn(.33,1.53,.69,.99),Mi=Lc(Vc),Ic=jc(Mi),Fc=e=>e>=1?1:(e*=2)<1?.5*Mi(e):.5*(2-Math.pow(2,-10*(e-1))),Di=e=>1-Math.sin(Math.acos(e)),_c=Lc(Di),Oc=jc(Di),Eg=Vn(.42,0,1,1),Ag=Vn(0,0,.58,1),Bc=Vn(.42,0,.58,1),Pg=e=>Array.isArray(e)&&typeof e[0]!="number",$c=e=>Array.isArray(e)&&typeof e[0]=="number",Rg={linear:We,easeIn:Eg,easeInOut:Bc,easeOut:Ag,circIn:Di,circInOut:Oc,circOut:_c,backIn:Mi,backInOut:Ic,backOut:Vc,anticipate:Fc},Mg=e=>typeof e=="string",ia=e=>{if($c(e)){Pi(e.length===4);const[t,n,s,r]=e;return Vn(t,n,s,r)}else if(Mg(e))return Rg[e];return e},ts=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Dg(e,t){let n=new Set,s=new Set,r=!1,i=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(u){o.has(u)&&(c.schedule(u),e()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const p=f&&r?n:s;return d&&o.add(u),p.add(u),u},cancel:u=>{s.delete(u),o.delete(u)},process:u=>{if(a=u,r){i=!0;return}r=!0;const d=n;n=s,s=d,n.forEach(l),n.clear(),r=!1,i&&(i=!1,c.process(u))}};return c}const Ng=40;function Uc(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,o=ts.reduce((v,T)=>(v[T]=Dg(i),v),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:f,render:m,postRender:p}=o,y=()=>{const v=wt.useManualTiming,T=v?r.timestamp:performance.now();n=!1,v||(r.delta=s?1e3/60:Math.max(Math.min(T-r.timestamp,Ng),1)),r.timestamp=T,r.isProcessing=!0,a.process(r),l.process(r),c.process(r),u.process(r),d.process(r),f.process(r),m.process(r),p.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(y))},b=()=>{n=!0,s=!0,r.isProcessing||e(y)};return{schedule:ts.reduce((v,T)=>{const S=o[T];return v[T]=(R,N=!1,C=!1)=>(n||b(),S.schedule(R,N,C)),v},{}),cancel:v=>{for(let T=0;T<ts.length;T++)o[ts[T]].cancel(v)},state:r,steps:o}}const{schedule:ae,cancel:gt,state:Ae,steps:vr}=Uc(typeof requestAnimationFrame<"u"?requestAnimationFrame:We,!0);let os;function jg(){os=void 0}const Me={now:()=>(os===void 0&&Me.set(Ae.isProcessing||wt.useManualTiming?Ae.timestamp:performance.now()),os),set:e=>{os=e,queueMicrotask(jg)}},Wc=e=>t=>typeof t=="string"&&t.startsWith(e),Kc=Wc("--"),Lg=Wc("var(--"),Ni=e=>Lg(e)?Vg.test(e.split("/*")[0].trim()):!1,Vg=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function oa(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const rn={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},An={...rn,transform:e=>lt(0,1,e)},ns={...rn,default:1},vn=e=>Math.round(e*1e5)/1e5,ji=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ig(e){return e==null}const Fg=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Li=(e,t)=>n=>!!(typeof n=="string"&&Fg.test(n)&&n.startsWith(e)||t&&!Ig(n)&&Object.prototype.hasOwnProperty.call(n,t)),Hc=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,i,o,a]=s.match(ji);return{[e]:parseFloat(r),[t]:parseFloat(i),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},_g=e=>lt(0,255,e),wr={...rn,transform:e=>Math.round(_g(e))},Mt={test:Li("rgb","red"),parse:Hc("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+wr.transform(e)+", "+wr.transform(t)+", "+wr.transform(n)+", "+vn(An.transform(s))+")"};function Og(e){let t="",n="",s="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,s+=s,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}}const Gr={test:Li("#"),parse:Og,transform:Mt.transform},In=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),bt=In("deg"),at=In("%"),B=In("px"),Bg=In("vh"),$g=In("vw"),aa={...at,parse:e=>at.parse(e)/100,transform:e=>at.transform(e*100)},Kt={test:Li("hsl","hue"),parse:Hc("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+at.transform(vn(t))+", "+at.transform(vn(n))+", "+vn(An.transform(s))+")"},Se={test:e=>Mt.test(e)||Gr.test(e)||Kt.test(e),parse:e=>Mt.test(e)?Mt.parse(e):Kt.test(e)?Kt.parse(e):Gr.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Mt.transform(e):Kt.transform(e),getAnimatableNone:e=>{const t=Se.parse(e);return t.alpha=0,Se.transform(t)}},Ug=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Wg(e){return isNaN(e)&&typeof e=="string"&&(e.match(ji)?.length||0)+(e.match(Ug)?.length||0)>0}const Gc="number",Yc="color",Kg="var",Hg="var(",la="${}",Gg=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Qt(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let i=0;const a=t.replace(Gg,l=>(Se.test(l)?(s.color.push(i),r.push(Yc),n.push(Se.parse(l))):l.startsWith(Hg)?(s.var.push(i),r.push(Kg),n.push(l)):(s.number.push(i),r.push(Gc),n.push(parseFloat(l))),++i,la)).split(la);return{values:n,split:a,indexes:s,types:r}}function Yg(e){return Qt(e).values}function zc({split:e,types:t}){const n=e.length;return s=>{let r="";for(let i=0;i<n;i++)if(r+=e[i],s[i]!==void 0){const o=t[i];o===Gc?r+=vn(s[i]):o===Yc?r+=Se.transform(s[i]):r+=s[i]}return r}}function zg(e){return zc(Qt(e))}const qg=e=>typeof e=="number"?0:Se.test(e)?Se.getAnimatableNone(e):e,Xg=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:qg(e);function Zg(e){const t=Qt(e);return zc(t)(t.values.map((s,r)=>Xg(s,t.split[r])))}const Je={test:Wg,parse:Yg,createTransformer:zg,getAnimatableNone:Zg};function Sr(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Jg({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let r=0,i=0,o=0;if(!t)r=i=o=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=Sr(l,a,e+1/3),i=Sr(l,a,e),o=Sr(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:s}}function Cs(e,t){return n=>n>0?t:e}const fe=(e,t,n)=>e+(t-e)*n,kr=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Qg=[Gr,Mt,Kt],ey=e=>Qg.find(t=>t.test(e));function ca(e){const t=ey(e);if(!t)return!1;let n=t.parse(e);return t===Kt&&(n=Jg(n)),n}const ua=(e,t)=>{const n=ca(e),s=ca(t);if(!n||!s)return Cs(e,t);const r={...n};return i=>(r.red=kr(n.red,s.red,i),r.green=kr(n.green,s.green,i),r.blue=kr(n.blue,s.blue,i),r.alpha=fe(n.alpha,s.alpha,i),Mt.transform(r))},Yr=new Set(["none","hidden"]);function ty(e,t){return Yr.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function ny(e,t){return n=>fe(e,t,n)}function Vi(e){return typeof e=="number"?ny:typeof e=="string"?Ni(e)?Cs:Se.test(e)?ua:iy:Array.isArray(e)?qc:typeof e=="object"?Se.test(e)?ua:sy:Cs}function qc(e,t){const n=[...e],s=n.length,r=e.map((i,o)=>Vi(i)(i,t[o]));return i=>{for(let o=0;o<s;o++)n[o]=r[o](i);return n}}function sy(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=Vi(e[r])(e[r],t[r]));return r=>{for(const i in s)n[i]=s[i](r);return n}}function ry(e,t){const n=[],s={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const i=t.types[r],o=e.indexes[i][s[i]],a=e.values[o]??0;n[r]=a,s[i]++}return n}const iy=(e,t)=>{const n=Je.createTransformer(t),s=Qt(e),r=Qt(t);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?Yr.has(e)&&!r.values.length||Yr.has(t)&&!s.values.length?ty(e,t):Ln(qc(ry(s,r),r.values),n):Cs(e,t)};function Xc(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?fe(e,t,n):Vi(e)(e,t)}const oy=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ae.update(t,n),stop:()=>gt(t),now:()=>Ae.isProcessing?Ae.timestamp:Me.now()}},Zc=(e,t,n=10)=>{let s="";const r=Math.max(Math.round(t/n),2);for(let i=0;i<r;i++)s+=Math.round(e(i/(r-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Es=2e4;function Ii(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<Es;)t+=n,s=e.next(t);return t>=Es?1/0:t}function ay(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(Ii(s),Es);return{type:"keyframes",ease:i=>s.next(r*i).value/t,duration:$e(r)}}const ye={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function zr(e,t){return e*Math.sqrt(1-t*t)}const ly=12;function cy(e,t,n){let s=n;for(let r=1;r<ly;r++)s=s-e(s)/t(s);return s}const Tr=.001;function uy({duration:e=ye.duration,bounce:t=ye.bounce,velocity:n=ye.velocity,mass:s=ye.mass}){let r,i,o=1-t;o=lt(ye.minDamping,ye.maxDamping,o),e=lt(ye.minDuration,ye.maxDuration,$e(e)),o<1?(r=c=>{const u=c*o,d=u*e,f=u-n,m=zr(c,o),p=Math.exp(-d);return Tr-f/m*p},i=c=>{const d=c*o*e,f=d*n+n,m=Math.pow(o,2)*Math.pow(c,2)*e,p=Math.exp(-d),y=zr(Math.pow(c,2),o);return(-r(c)+Tr>0?-1:1)*((f-m)*p)/y}):(r=c=>{const u=Math.exp(-c*e),d=(c-n)*e+1;return-Tr+u*d},i=c=>{const u=Math.exp(-c*e),d=(n-c)*(e*e);return u*d});const a=5/e,l=cy(r,i,a);if(e=Oe(e),isNaN(l))return{stiffness:ye.stiffness,damping:ye.damping,duration:e};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:o*2*Math.sqrt(s*c),duration:e}}}const dy=["duration","bounce"],fy=["stiffness","damping","mass"];function da(e,t){return t.some(n=>e[n]!==void 0)}function hy(e){let t={velocity:ye.velocity,stiffness:ye.stiffness,damping:ye.damping,mass:ye.mass,isResolvedFromDuration:!1,...e};if(!da(e,fy)&&da(e,dy))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,i=2*lt(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:ye.mass,stiffness:r,damping:i}}else{const n=uy({...e,velocity:0});t={...t,...n,mass:ye.mass},t.isResolvedFromDuration=!0}return t}function As(e=ye.visualDuration,t=ye.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:r}=n;const i=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:i},{stiffness:l,damping:c,mass:u,duration:d,velocity:f,isResolvedFromDuration:m}=hy({...n,velocity:-$e(n.velocity||0)}),p=f||0,y=c/(2*Math.sqrt(l*u)),b=o-i,x=$e(Math.sqrt(l/u)),w=Math.abs(b)<5;s||(s=w?ye.restSpeed.granular:ye.restSpeed.default),r||(r=w?ye.restDelta.granular:ye.restDelta.default);let v,T,S,R,N,C;if(y<1)S=zr(x,y),R=(p+y*x*b)/S,v=A=>{const M=Math.exp(-y*x*A);return o-M*(R*Math.sin(S*A)+b*Math.cos(S*A))},N=y*x*R+b*S,C=y*x*b-R*S,T=A=>Math.exp(-y*x*A)*(N*Math.sin(S*A)+C*Math.cos(S*A));else if(y===1){v=M=>o-Math.exp(-x*M)*(b+(p+x*b)*M);const A=p+x*b;T=M=>Math.exp(-x*M)*(x*A*M-p)}else{const A=x*Math.sqrt(y*y-1);v=$=>{const j=Math.exp(-y*x*$),W=Math.min(A*$,300);return o-j*((p+y*x*b)*Math.sinh(W)+A*b*Math.cosh(W))/A};const M=(p+y*x*b)/A,U=y*x*M-b*A,L=y*x*b-M*A;T=$=>{const j=Math.exp(-y*x*$),W=Math.min(A*$,300);return j*(U*Math.sinh(W)+L*Math.cosh(W))}}const I={calculatedDuration:m&&d||null,velocity:A=>Oe(T(A)),next:A=>{if(!m&&y<1){const U=Math.exp(-y*x*A),L=Math.sin(S*A),$=Math.cos(S*A),j=o-U*(R*L+b*$),W=Oe(U*(N*L+C*$));return a.done=Math.abs(W)<=s&&Math.abs(o-j)<=r,a.value=a.done?o:j,a}const M=v(A);if(m)a.done=A>=d;else{const U=Oe(T(A));a.done=Math.abs(U)<=s&&Math.abs(o-M)<=r}return a.value=a.done?o:M,a},toString:()=>{const A=Math.min(Ii(I),Es),M=Zc(U=>I.next(A*U).value,A,30);return A+"ms "+M},toTransition:()=>{}};return I}As.applyToOptions=e=>{const t=ay(e,100,As);return e.ease=t.ease,e.duration=Oe(t.duration),e.type="keyframes",e};const my=5;function Jc(e,t,n){const s=Math.max(t-my,0);return Dc(n-e(s),t-s)}function qr({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:i=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=e[0],f={done:!1,value:d},m=C=>a!==void 0&&C<a||l!==void 0&&C>l,p=C=>a===void 0?l:l===void 0||Math.abs(a-C)<Math.abs(l-C)?a:l;let y=n*t;const b=d+y,x=o===void 0?b:o(b);x!==b&&(y=x-d);const w=C=>-y*Math.exp(-C/s),v=C=>x+w(C),T=C=>{const I=w(C),A=v(C);f.done=Math.abs(I)<=c,f.value=f.done?x:A};let S,R;const N=C=>{m(f.value)&&(S=C,R=As({keyframes:[f.value,p(f.value)],velocity:Jc(v,C,f.value),damping:r,stiffness:i,restDelta:c,restSpeed:u}))};return N(0),{calculatedDuration:null,next:C=>{let I=!1;return!R&&S===void 0&&(I=!0,T(C),N(C)),S!==void 0&&C>=S?R.next(C-S):(!I&&T(C),f)}}}function py(e,t,n){const s=[],r=n||wt.mix||Xc,i=e.length-1;for(let o=0;o<i;o++){let a=r(e[o],e[o+1]);if(t){const l=Array.isArray(t)?t[o]||We:t;a=Ln(l,a)}s.push(a)}return s}function Qc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const i=e.length;if(Pi(i===t.length),i===1)return()=>t[0];if(i===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[i-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=py(t,s,r),l=a.length,c=u=>{if(o&&u<e[0])return t[0];let d=0;if(l>1)for(;d<e.length-2&&!(u<e[d+1]);d++);const f=En(e[d],e[d+1],u);return a[d](f)};return n?u=>c(lt(e[0],e[i-1],u)):c}function gy(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=En(0,t,s);e.push(fe(n,1,r))}}function yy(e){const t=[0];return gy(t,e.length-1),t}function by(e,t){return e.map(n=>n*t)}function xy(e,t){return e.map(()=>t||Bc).splice(0,e.length-1)}function wn({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=Pg(s)?s.map(ia):ia(s),i={done:!1,value:t[0]},o=by(n&&n.length===t.length?n:yy(t),e),a=Qc(o,t,{ease:Array.isArray(r)?r:xy(t,r)});return{calculatedDuration:e,next:l=>(i.value=a(l),i.done=l>=e,i)}}const vy=e=>e!==null;function Is(e,{repeat:t,repeatType:n="loop"},s,r=1){const i=e.filter(vy),a=r<0||t&&n!=="loop"&&t%2===1?0:i.length-1;return!a||s===void 0?i[a]:s}const wy={decay:qr,inertia:qr,tween:wn,keyframes:wn,spring:As};function eu(e){typeof e.type=="string"&&(e.type=wy[e.type])}class Fi{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Sy=e=>e/100;class Pn extends Fi{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Me.now()&&this.tick(Me.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;eu(t);const{type:n=wn,repeat:s=0,repeatDelay:r=0,repeatType:i,velocity:o=0}=t;let{keyframes:a}=t;const l=n||wn;l!==wn&&typeof a[0]!="number"&&(this.mixKeyframes=Ln(Sy,Xc(a[0],a[1])),a=[0,100]);const c=l({...t,keyframes:a});i==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-o})),c.calculatedDuration===null&&(c.calculatedDuration=Ii(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=c}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:r,mixKeyframes:i,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:c=0,keyframes:u,repeat:d,repeatType:f,repeatDelay:m,type:p,onUpdate:y,finalKeyframe:b}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-r/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const x=this.currentTime-c*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?x<0:x>r;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,T=s;if(d){const C=Math.min(this.currentTime,r)/a;let I=Math.floor(C),A=C%1;!A&&C>=1&&(A=1),A===1&&I--,I=Math.min(I,d+1),I%2&&(f==="reverse"?(A=1-A,m&&(A-=m/a)):f==="mirror"&&(T=o)),v=lt(0,1,A)*a}let S;w?(this.delayState.value=u[0],S=this.delayState):S=T.next(v),i&&!w&&(S.value=i(S.value));let{done:R}=S;!w&&l!==null&&(R=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&R);return N&&p!==qr&&(S.value=Is(u,this.options,b,this.speed)),y&&y(S.value),N&&this.finish(),S}then(t,n){return this.finished.then(t,n)}get duration(){return $e(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(this.currentTime)}set time(t){t=Oe(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return Jc(s=>this.generator.next(s).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Me.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=$e(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=oy,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Me.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function ky(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Dt=e=>e*180/Math.PI,Xr=e=>{const t=Dt(Math.atan2(e[1],e[0]));return Zr(t)},Ty={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Xr,rotateZ:Xr,skewX:e=>Dt(Math.atan(e[1])),skewY:e=>Dt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Zr=e=>(e=e%360,e<0&&(e+=360),e),fa=Xr,ha=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ma=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Cy={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ha,scaleY:ma,scale:e=>(ha(e)+ma(e))/2,rotateX:e=>Zr(Dt(Math.atan2(e[6],e[5]))),rotateY:e=>Zr(Dt(Math.atan2(-e[2],e[0]))),rotateZ:fa,rotate:fa,skewX:e=>Dt(Math.atan(e[4])),skewY:e=>Dt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Jr(e){return e.includes("scale")?1:0}function Qr(e,t){if(!e||e==="none")return Jr(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=Cy,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Ty,r=a}if(!r)return Jr(t);const i=s[t],o=r[1].split(",").map(Ay);return typeof i=="function"?i(o):o[i]}const Ey=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Qr(n,t)};function Ay(e){return parseFloat(e.trim())}const on=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],an=new Set(on),pa=e=>e===rn||e===B,Py=new Set(["x","y","z"]),Ry=on.filter(e=>!Py.has(e));function My(e){const t=[];return Ry.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const vt={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:s})=>{const r=e.max-e.min;return s==="border-box"?r:r-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:s})=>{const r=e.max-e.min;return s==="border-box"?r:r-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Qr(t,"x"),y:(e,{transform:t})=>Qr(t,"y")};vt.translateX=vt.x;vt.translateY=vt.y;const Nt=new Set;let ei=!1,ti=!1,ni=!1;function tu(){if(ti){const e=Array.from(Nt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=My(s);r.length&&(n.set(s,r),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const r=n.get(s);r&&r.forEach(([i,o])=>{s.getValue(i)?.set(o)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ti=!1,ei=!1,Nt.forEach(e=>e.complete(ni)),Nt.clear()}function nu(){Nt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(ti=!0)})}function Dy(){ni=!0,nu(),tu(),ni=!1}class _i{constructor(t,n,s,r,i,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=r,this.element=i,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Nt.add(this),ei||(ei=!0,ae.read(nu),ae.resolveKeyframes(tu))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:r}=this;if(t[0]===null){const i=r?.get(),o=t[t.length-1];if(i!==void 0)t[0]=i;else if(s&&n){const a=s.readValue(n,o);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=o),r&&i===void 0&&r.set(t[0])}ky(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Nt.delete(this)}cancel(){this.state==="scheduled"&&(Nt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Ny=e=>e.startsWith("--");function su(e,t,n){Ny(t)?e.style.setProperty(t,n):e.style[t]=n}const jy={};function ru(e,t){const n=Mc(e);return()=>jy[t]??n()}const Ly=ru(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),iu=ru(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),gn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,ga={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:gn([0,.65,.55,1]),circOut:gn([.55,0,1,.45]),backIn:gn([.31,.01,.66,-.59]),backOut:gn([.33,1.53,.69,.99])};function ou(e,t){if(e)return typeof e=="function"?iu()?Zc(e,t):"ease-out":$c(e)?gn(e):Array.isArray(e)?e.map(n=>ou(n,t)||ga.easeOut):ga[e]}function Vy(e,t,n,{delay:s=0,duration:r=300,repeat:i=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[t]:n};l&&(u.offset=l);const d=ou(a,r);Array.isArray(d)&&(u.easing=d);const f={delay:s,duration:r,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:i+1,direction:o==="reverse"?"alternate":"normal"};return c&&(f.pseudoElement=c),e.animate(u,f)}function au(e){return typeof e=="function"&&"applyToOptions"in e}function Iy({type:e,...t}){return au(e)&&iu()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class lu extends Fi{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:s,keyframes:r,pseudoElement:i,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!i,this.allowFlatten=o,this.options=t,Pi(typeof t.type!="string");const c=Iy(t);this.animation=Vy(n,s,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const u=Is(r,this.options,a,this.speed);this.updateMotionValue&&this.updateMotionValue(u),su(n,s,u),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const t=this.options?.element;!this.isPseudoElement&&t?.isConnected&&this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return $e(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Oe(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:s,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&Ly()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),s&&(this.animation.rangeEnd=s),We):r(this)}}const cu={anticipate:Fc,backInOut:Ic,circInOut:Oc};function Fy(e){return e in cu}function _y(e){typeof e.ease=="string"&&Fy(e.ease)&&(e.ease=cu[e.ease])}const Cr=10;class Oy extends lu{constructor(t){_y(t),eu(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:r,element:i,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new Pn({...o,autoplay:!1}),l=Math.max(Cr,Me.now()-this.startTime),c=lt(0,Cr,l-Cr),u=a.sample(l).value,{name:d}=this.options;i&&d&&su(i,d,u),n.setWithVelocity(a.sample(Math.max(0,l-c)).value,u,c),a.stop()}}const ya=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Je.test(e)||e==="0")&&!e.startsWith("url("));function By(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function $y(e,t,n,s){const r=e[0];if(r===null)return!1;if(t==="display"||t==="visibility")return!0;const i=e[e.length-1],o=ya(r,t),a=ya(i,t);return!o||!a?!1:By(e)||(n==="spring"||au(n))&&s}function si(e){e.duration=0,e.type="keyframes"}const uu=new Set(["opacity","clipPath","filter","transform"]),Uy=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Wy(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&Uy.test(e[t]))return!0;return!1}const Ky=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),Hy=Mc(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Gy(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:r,damping:i,type:o,keyframes:a}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=t.owner.getProps();return Hy()&&n&&(uu.has(n)||Ky.has(n)&&Wy(a))&&(n!=="transform"||!u)&&!c&&!s&&r!=="mirror"&&i!==0&&o!=="inertia"}const Yy=40;class zy extends Fi{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:o="loop",keyframes:a,name:l,motionValue:c,element:u,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Me.now();const f={autoplay:t,delay:n,type:s,repeat:r,repeatDelay:i,repeatType:o,name:l,motionValue:c,element:u,...d},m=u?.KeyframeResolver||_i;this.keyframeResolver=new m(a,(p,y,b)=>this.onKeyframesResolved(p,y,f,!b),l,c,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,r){this.keyframeResolver=void 0;const{name:i,type:o,velocity:a,delay:l,isHandoff:c,onUpdate:u}=s;this.resolvedAt=Me.now();let d=!0;$y(t,i,o,a)||(d=!1,(wt.instantAnimations||!l)&&u?.(Is(t,s,n)),t[0]=t[t.length-1],si(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Yy?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=d&&!c&&Gy(m),y=m.motionValue?.owner?.current;let b;if(p)try{b=new Oy({...m,element:y})}catch{b=new Pn(m)}else b=new Pn(m);b.finished.then(()=>{this.notifyFinished()}).catch(We),this.pendingTimeline&&(this.stopTimeline=b.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=b}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Dy()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function du(e,t,n,s=0,r=1){const i=Array.from(e).sort((c,u)=>c.sortNodePosition(u)).indexOf(t),o=e.size,a=(o-1)*s;return typeof n=="function"?n(i,o):r===1?i*s:a-i*s}const qy=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Xy(e){const t=qy.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}function fu(e,t,n=1){const[s,r]=Xy(e);if(!s)return;const i=window.getComputedStyle(t).getPropertyValue(s);if(i){const o=i.trim();return Ac(o)?parseFloat(o):o}return Ni(r)?fu(r,t,n+1):r}const Zy={type:"spring",stiffness:500,damping:25,restSpeed:10},Jy=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Qy={type:"keyframes",duration:.8},eb={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},tb=(e,{keyframes:t})=>t.length>2?Qy:an.has(e)?e.startsWith("scale")?Jy(t[1]):Zy:eb;function hu(e,t){if(e?.inherit&&t){const{inherit:n,...s}=e;return{...t,...s}}return e}function Oi(e,t){const n=e?.[t]??e?.default??e;return n!==e?hu(n,e):n}const nb=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function sb(e){for(const t in e)if(!nb.has(t))return!0;return!1}const Bi=(e,t,n,s={},r,i)=>o=>{const a=Oi(s,e)||{},l=a.delay||s.delay||0;let{elapsed:c=0}=s;c=c-Oe(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:f=>{t.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:i?void 0:r};sb(a)||Object.assign(u,tb(e,u)),u.duration&&(u.duration=Oe(u.duration)),u.repeatDelay&&(u.repeatDelay=Oe(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(si(u),u.delay===0&&(d=!0)),(wt.instantAnimations||wt.skipAnimations||r?.shouldSkipAnimations)&&(d=!0,si(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!i&&t.get()!==void 0){const f=Is(u.keyframes,a);if(f!==void 0){ae.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new Pn(u):new zy(u)};function ba(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function $i(e,t,n,s){if(typeof t=="function"){const[r,i]=ba(s);t=t(n!==void 0?n:e.custom,r,i)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,i]=ba(s);t=t(n!==void 0?n:e.custom,r,i)}return t}function jt(e,t,n){const s=e.getProps();return $i(s,t,n!==void 0?n:s.custom,e)}const mu=new Set(["width","height","top","left","right","bottom",...on]),xa=30,rb=e=>!isNaN(parseFloat(e)),Sn={current:void 0};class ib{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Me.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const i of this.dependents)i.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Me.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=rb(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Ri);const s=this.events[t].add(n);return t==="change"?()=>{s(),ae.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return Sn.current&&Sn.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const t=Me.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>xa)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,xa);return Dc(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Lt(e,t){return new ib(e,t)}const ri=e=>Array.isArray(e);function ob(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Lt(n))}function ab(e){return ri(e)?e[e.length-1]||0:e}function lb(e,t){const n=jt(e,t);let{transitionEnd:s={},transition:r={},...i}=n||{};i={...i,...s};for(const o in i){const a=ab(i[o]);ob(e,o,a)}}const Ce=e=>!!(e&&e.getVelocity);function cb(e){return!!(Ce(e)&&e.add)}function ii(e,t){const n=e.getValue("willChange");if(cb(n))return n.add(t);if(!n&&wt.WillChange){const s=new wt.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Ui(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const ub="framerAppearId",pu="data-"+Ui(ub);function gu(e){return e.props[pu]}function db({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function yu(e,t,{delay:n=0,transitionOverride:s,type:r}={}){let{transition:i,transitionEnd:o,...a}=t;const l=e.getDefaultTransition();i=i?hu(i,l):l;const c=i?.reduceMotion;s&&(i=s);const u=[],d=r&&e.animationState&&e.animationState.getState()[r];for(const f in a){const m=e.getValue(f,e.latestValues[f]??null),p=a[f];if(p===void 0||d&&db(d,f))continue;const y={delay:n,...Oi(i||{},f)},b=m.get();if(b!==void 0&&!m.isAnimating()&&!Array.isArray(p)&&p===b&&!y.velocity){ae.update(()=>m.set(p));continue}let x=!1;if(window.MotionHandoffAnimation){const T=gu(e);if(T){const S=window.MotionHandoffAnimation(T,f,ae);S!==null&&(y.startTime=S,x=!0)}}ii(e,f);const w=c??e.shouldReduceMotion;m.start(Bi(f,m,p,w&&mu.has(f)?{type:!1}:y,e,x));const v=m.animation;v&&u.push(v)}if(o){const f=()=>ae.update(()=>{o&&lb(e,o)});u.length?Promise.all(u).then(f):f()}return u}function oi(e,t,n={}){const s=jt(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(r=n.transitionOverride);const i=s?()=>Promise.all(yu(e,s,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:d}=r;return fb(e,t,l,c,u,d,n)}:()=>Promise.resolve(),{when:a}=r;if(a){const[l,c]=a==="beforeChildren"?[i,o]:[o,i];return l().then(()=>c())}else return Promise.all([i(),o(n.delay)])}function fb(e,t,n=0,s=0,r=0,i=1,o){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(oi(l,t,{...o,delay:n+(typeof s=="function"?0:s)+du(e.variantChildren,l,s,r,i)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function hb(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(i=>oi(e,i,n));s=Promise.all(r)}else if(typeof t=="string")s=oi(e,t,n);else{const r=typeof t=="function"?jt(e,t,n.custom):t;s=Promise.all(yu(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}const mb={test:e=>e==="auto",parse:e=>e},bu=e=>t=>t.test(e),xu=[rn,B,at,bt,$g,Bg,mb],va=e=>xu.find(bu(e));function pb(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Rc(e):!0}const gb=new Set(["brightness","contrast","saturate","opacity"]);function yb(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(ji)||[];if(!s)return e;const r=n.replace(s,"");let i=gb.has(t)?1:0;return s!==n&&(i*=100),t+"("+i+r+")"}const bb=/\b([a-z-]*)\(.*?\)/gu,ai={...Je,getAnimatableNone:e=>{const t=e.match(bb);return t?t.map(yb).join(" "):e}},li={...Je,getAnimatableNone:e=>{const t=Je.parse(e);return Je.createTransformer(e)(t.map(s=>typeof s=="number"?0:typeof s=="object"?{...s,alpha:1}:s))}},wa={...rn,transform:Math.round},xb={rotate:bt,rotateX:bt,rotateY:bt,rotateZ:bt,scale:ns,scaleX:ns,scaleY:ns,scaleZ:ns,skew:bt,skewX:bt,skewY:bt,distance:B,translateX:B,translateY:B,translateZ:B,x:B,y:B,z:B,perspective:B,transformPerspective:B,opacity:An,originX:aa,originY:aa,originZ:B},Wi={borderWidth:B,borderTopWidth:B,borderRightWidth:B,borderBottomWidth:B,borderLeftWidth:B,borderRadius:B,borderTopLeftRadius:B,borderTopRightRadius:B,borderBottomRightRadius:B,borderBottomLeftRadius:B,width:B,maxWidth:B,height:B,maxHeight:B,top:B,right:B,bottom:B,left:B,inset:B,insetBlock:B,insetBlockStart:B,insetBlockEnd:B,insetInline:B,insetInlineStart:B,insetInlineEnd:B,padding:B,paddingTop:B,paddingRight:B,paddingBottom:B,paddingLeft:B,paddingBlock:B,paddingBlockStart:B,paddingBlockEnd:B,paddingInline:B,paddingInlineStart:B,paddingInlineEnd:B,margin:B,marginTop:B,marginRight:B,marginBottom:B,marginLeft:B,marginBlock:B,marginBlockStart:B,marginBlockEnd:B,marginInline:B,marginInlineStart:B,marginInlineEnd:B,fontSize:B,backgroundPositionX:B,backgroundPositionY:B,...xb,zIndex:wa,fillOpacity:An,strokeOpacity:An,numOctaves:wa},vb={...Wi,color:Se,backgroundColor:Se,outlineColor:Se,fill:Se,stroke:Se,borderColor:Se,borderTopColor:Se,borderRightColor:Se,borderBottomColor:Se,borderLeftColor:Se,filter:ai,WebkitFilter:ai,mask:li,WebkitMask:li},vu=e=>vb[e],wb=new Set([ai,li]);function wu(e,t){let n=vu(e);return wb.has(n)||(n=Je),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Sb=new Set(["auto","none","0"]);function kb(e,t,n){let s=0,r;for(;s<e.length&&!r;){const i=e[s];typeof i=="string"&&!Sb.has(i)&&Qt(i).values.length&&(r=e[s]),s++}if(r&&n)for(const i of t)e[i]=wu(n,r)}class Tb extends _i{constructor(t,n,s,r,i){super(t,n,s,r,i,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let u=0;u<t.length;u++){let d=t[u];if(typeof d=="string"&&(d=d.trim(),Ni(d))){const f=fu(d,n.current);f!==void 0&&(t[u]=f),u===t.length-1&&(this.finalKeyframe=d)}}if(this.resolveNoneKeyframes(),!mu.has(s)||t.length!==2)return;const[r,i]=t,o=va(r),a=va(i),l=oa(r),c=oa(i);if(l!==c&&vt[s]){this.needsMeasurement=!0;return}if(o!==a)if(pa(o)&&pa(a))for(let u=0;u<t.length;u++){const d=t[u];typeof d=="string"&&(t[u]=parseFloat(d))}else vt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||pb(t[r]))&&s.push(r);s.length&&kb(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=vt[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(s,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const i=s.length-1,o=s[i];s[i]=vt[n](t.measureViewportBox(),window.getComputedStyle(t.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Su(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const r=n?.[e]??s.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e).filter(s=>s!=null)}const ku=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Cb(e){return Pc(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:Ki}=Uc(queueMicrotask,!1),qe={x:!1,y:!1};function Tu(){return qe.x||qe.y}function Eb(e){return e==="x"||e==="y"?qe[e]?null:(qe[e]=!0,()=>{qe[e]=!1}):qe.x||qe.y?null:(qe.x=qe.y=!0,()=>{qe.x=qe.y=!1})}function Cu(e,t){const n=Su(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function Ab(e){return!(e.pointerType==="touch"||Tu())}function Pb(e,t,n={}){const[s,r,i]=Cu(e,n);return s.forEach(o=>{let a=!1,l=!1,c;const u=()=>{o.removeEventListener("pointerleave",p)},d=b=>{c&&(c(b),c=void 0),u()},f=b=>{a=!1,window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),l&&(l=!1,d(b))},m=()=>{a=!0,window.addEventListener("pointerup",f,r),window.addEventListener("pointercancel",f,r)},p=b=>{if(b.pointerType!=="touch"){if(a){l=!0;return}d(b)}},y=b=>{if(!Ab(b))return;l=!1;const x=t(o,b);typeof x=="function"&&(c=x,o.addEventListener("pointerleave",p,r))};o.addEventListener("pointerenter",y,r),o.addEventListener("pointerdown",m,r)}),i}const Eu=(e,t)=>t?e===t?!0:Eu(e,t.parentElement):!1,Hi=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Rb=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Mb(e){return Rb.has(e.tagName)||e.isContentEditable===!0}const Db=new Set(["INPUT","SELECT","TEXTAREA"]);function Nb(e){return Db.has(e.tagName)||e.isContentEditable===!0}const as=new WeakSet;function Sa(e){return t=>{t.key==="Enter"&&e(t)}}function Er(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const jb=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Sa(()=>{if(as.has(n))return;Er(n,"down");const r=Sa(()=>{Er(n,"up")}),i=()=>Er(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",i,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function ka(e){return Hi(e)&&!Tu()}const Ta=new WeakSet;function Lb(e,t,n={}){const[s,r,i]=Cu(e,n),o=a=>{const l=a.currentTarget;if(!ka(a)||Ta.has(a))return;as.add(l),n.stopPropagation&&Ta.add(a);const c=t(l,a),u=(m,p)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),as.has(l)&&as.delete(l),ka(m)&&typeof c=="function"&&c(m,{success:p})},d=m=>{u(m,l===window||l===document||n.useGlobalTarget||Eu(l,m.target))},f=m=>{u(m,!1)};window.addEventListener("pointerup",d,r),window.addEventListener("pointercancel",f,r)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,r),Cb(a)&&(a.addEventListener("focus",c=>jb(c,r)),!Mb(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),i}function Gi(e){return Pc(e)&&"ownerSVGElement"in e}const ls=new WeakMap;let cs;const Au=(e,t,n)=>(s,r)=>r&&r[0]?r[0][e+"Size"]:Gi(s)&&"getBBox"in s?s.getBBox()[t]:s[n],Vb=Au("inline","width","offsetWidth"),Ib=Au("block","height","offsetHeight");function Fb({target:e,borderBoxSize:t}){ls.get(e)?.forEach(n=>{n(e,{get width(){return Vb(e,t)},get height(){return Ib(e,t)}})})}function _b(e){e.forEach(Fb)}function Ob(){typeof ResizeObserver>"u"||(cs=new ResizeObserver(_b))}function Bb(e,t){cs||Ob();const n=Su(e);return n.forEach(s=>{let r=ls.get(s);r||(r=new Set,ls.set(s,r)),r.add(t),cs?.observe(s)}),()=>{n.forEach(s=>{const r=ls.get(s);r?.delete(t),r?.size||cs?.unobserve(s)})}}const us=new Set;let Ht;function $b(){Ht=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};us.forEach(t=>t(e))},window.addEventListener("resize",Ht)}function Ub(e){return us.add(e),Ht||$b(),()=>{us.delete(e),!us.size&&typeof Ht=="function"&&(window.removeEventListener("resize",Ht),Ht=void 0)}}function Ca(e,t){return typeof e=="function"?Ub(e):Bb(e,t)}function Wb(e){return Gi(e)&&e.tagName==="svg"}function Kb(...e){const t=!Array.isArray(e[0]),n=t?0:-1,s=e[0+n],r=e[1+n],i=e[2+n],o=e[3+n],a=Qc(r,i,o);return t?a(s):a}function Hb(e,t,n={}){const s=e.get();let r=null,i=s,o;const a=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,l=()=>{r&&(r.stop(),r=null),e.animation=void 0},c=()=>{const d=Ea(e.get()),f=Ea(i);if(d===f){l();return}const m=r?r.getGeneratorVelocity():e.getVelocity();l(),r=new Pn({keyframes:[d,f],velocity:m,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:o})},u=()=>{c(),e.animation=r??void 0,e.events.animationStart?.notify(),r?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((d,f)=>{i=d,o=m=>f(Ar(m,a)),ae.postRender(u)},l),Ce(t)){let d=n.skipInitialAnimation===!0;const f=t.on("change",p=>{d?(d=!1,e.jump(Ar(p,a),!1)):e.set(Ar(p,a))}),m=e.on("destroy",f);return()=>{f(),m()}}return l}function Ar(e,t){return t?e+t:e}function Ea(e){return typeof e=="number"?e:parseFloat(e)}const Gb=[...xu,Se,Je],Yb=e=>Gb.find(bu(e)),Aa=()=>({translate:0,scale:1,origin:0,originPoint:0}),Gt=()=>({x:Aa(),y:Aa()}),Pa=()=>({min:0,max:0}),Te=()=>({x:Pa(),y:Pa()}),zb=new WeakMap;function Fs(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Rn(e){return typeof e=="string"||Array.isArray(e)}const Yi=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],zi=["initial",...Yi];function _s(e){return Fs(e.animate)||zi.some(t=>Rn(e[t]))}function Pu(e){return!!(_s(e)||e.variants)}function qb(e,t,n){for(const s in t){const r=t[s],i=n[s];if(Ce(r))e.addValue(s,r);else if(Ce(i))e.addValue(s,Lt(r,{owner:e}));else if(i!==r)if(e.hasValue(s)){const o=e.getValue(s);o.liveStyle===!0?o.jump(r):o.hasAnimated||o.set(r)}else{const o=e.getStaticValue(s);e.addValue(s,Lt(o!==void 0?o:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Ps={current:null},qi={current:!1},Xb=typeof window<"u";function Ru(){if(qi.current=!0,!!Xb)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Ps.current=e.matches;e.addEventListener("change",t),t()}else Ps.current=!1}const Ra=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Rs={};function Mu(e){Rs=e}function Zb(){return Rs}class Jb{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:o,visualState:a},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=_i,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Me.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,ae.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=a;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=l,this.blockInitialAnimation=!!o,this.isControllingVariants=_s(n),this.isVariantNode=Pu(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in f){const p=f[m];c[m]!==void 0&&Ce(p)&&p.set(c[m])}}mount(t){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=t,zb.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(qi.current||Ru(),this.shouldReduceMotion=Ps.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),gt(this.notifyUpdate),gt(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&uu.has(t)&&this.current instanceof HTMLElement){const{factory:o,keyframes:a,times:l,ease:c,duration:u}=n.accelerate,d=new lu({element:this.current,name:t,keyframes:a,times:l,ease:c,duration:Oe(u)}),f=o(d);this.valueSubscriptions.set(t,()=>{f(),d.cancel()});return}const s=an.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&ae.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),i&&i(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Rs){const n=Rs[t];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[t]&&r&&s(this.props)&&(this.features[t]=new r(this)),this.features[t]){const i=this.features[t];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Te()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Ra.length;s++){const r=Ra[s];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const i="on"+r,o=t[i];o&&(this.propEventSubscriptions[r]=this.on(r,o))}this.prevMotionValues=qb(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Lt(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(Ac(s)||Rc(s))?s=parseFloat(s):!Yb(s)&&Je.test(n)&&(s=wu(t,n)),this.setBaseTarget(t,Ce(s)?s.get():s)),Ce(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const i=$i(this.props,n,this.presenceContext?.custom);i&&(s=i[t])}if(n&&s!==void 0)return s;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!Ce(r)?r:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Ri),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Ki.render(this.render)}}class Du extends Jb{constructor(){super(...arguments),this.KeyframeResolver=Tb}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const s=t.style;return s?s[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Ce(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class St{constructor(t){this.isMounted=!1,this.node=t}update(){}}function Nu({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Qb({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function e0(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Pr(e){return e===void 0||e===1}function ci({scale:e,scaleX:t,scaleY:n}){return!Pr(e)||!Pr(t)||!Pr(n)}function Pt(e){return ci(e)||ju(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ju(e){return Ma(e.x)||Ma(e.y)}function Ma(e){return e&&e!=="0%"}function Ms(e,t,n){const s=e-n,r=t*s;return n+r}function Da(e,t,n,s,r){return r!==void 0&&(e=Ms(e,r,s)),Ms(e,n,s)+t}function ui(e,t=0,n=1,s,r){e.min=Da(e.min,t,n,s,r),e.max=Da(e.max,t,n,s,r)}function Lu(e,{x:t,y:n}){ui(e.x,t.translate,t.scale,t.originPoint),ui(e.y,n.translate,n.scale,n.originPoint)}const Na=.999999999999,ja=1.0000000000001;function t0(e,t,n,s=!1){const r=n.length;if(!r)return;t.x=t.y=1;let i,o;for(let a=0;a<r;a++){i=n[a],o=i.projectionDelta;const{visualElement:l}=i.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&i.options.layoutScroll&&i.scroll&&i!==i.root&&(it(e.x,-i.scroll.offset.x),it(e.y,-i.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Lu(e,o)),s&&Pt(i.latestValues)&&ds(e,i.latestValues,i.layout?.layoutBox))}t.x<ja&&t.x>Na&&(t.x=1),t.y<ja&&t.y>Na&&(t.y=1)}function it(e,t){e.min+=t,e.max+=t}function La(e,t,n,s,r=.5){const i=fe(e.min,e.max,r);ui(e,t,n,i,s)}function Va(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function ds(e,t,n){const s=n??e;La(e.x,Va(t.x,s.x),t.scaleX,t.scale,t.originX),La(e.y,Va(t.y,s.y),t.scaleY,t.scale,t.originY)}function Vu(e,t){return Nu(e0(e.getBoundingClientRect(),t))}function n0(e,t,n){const s=Vu(e,n),{scroll:r}=t;return r&&(it(s.x,r.offset.x),it(s.y,r.offset.y)),s}const s0={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},r0=on.length;function i0(e,t,n){let s="",r=!0;for(let i=0;i<r0;i++){const o=on[i],a=e[o];if(a===void 0)continue;let l=!0;if(typeof a=="number")l=a===(o.startsWith("scale")?1:0);else{const c=parseFloat(a);l=o.startsWith("scale")?c===1:c===0}if(!l||n){const c=ku(a,Wi[o]);if(!l){r=!1;const u=s0[o]||o;s+=`${u}(${c}) `}n&&(t[o]=c)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function Xi(e,t,n){const{style:s,vars:r,transformOrigin:i}=e;let o=!1,a=!1;for(const l in t){const c=t[l];if(an.has(l)){o=!0;continue}else if(Kc(l)){r[l]=c;continue}else{const u=ku(c,Wi[l]);l.startsWith("origin")?(a=!0,i[l]=u):s[l]=u}}if(t.transform||(o||n?s.transform=i0(t,e.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=i;s.transformOrigin=`${l} ${c} ${u}`}}function Iu(e,{style:t,vars:n},s,r){const i=e.style;let o;for(o in t)i[o]=t[o];r?.applyProjectionStyles(i,s);for(o in n)i.setProperty(o,n[o])}function Ia(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const mn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(B.test(e))e=parseFloat(e);else return e;const n=Ia(e,t.target.x),s=Ia(e,t.target.y);return`${n}% ${s}%`}},o0={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=Je.parse(e);if(r.length>5)return s;const i=Je.createTransformer(e),o=typeof r[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;r[0+o]/=a,r[1+o]/=l;const c=fe(a,l,.5);return typeof r[2+o]=="number"&&(r[2+o]/=c),typeof r[3+o]=="number"&&(r[3+o]/=c),i(r)}},di={borderRadius:{...mn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:mn,borderTopRightRadius:mn,borderBottomLeftRadius:mn,borderBottomRightRadius:mn,boxShadow:o0};function Fu(e,{layout:t,layoutId:n}){return an.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!di[e]||e==="opacity")}function Zi(e,t,n){const s=e.style,r=t?.style,i={};if(!s)return i;for(const o in s)(Ce(s[o])||r&&Ce(r[o])||Fu(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}function a0(e){return window.getComputedStyle(e)}class l0 extends Du{constructor(){super(...arguments),this.type="html",this.renderInstance=Iu}readValueFromInstance(t,n){if(an.has(n))return this.projection?.isProjecting?Jr(n):Ey(t,n);{const s=a0(t),r=(Kc(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Vu(t,n)}build(t,n,s){Xi(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Zi(t,n,s)}}const c0={offset:"stroke-dashoffset",array:"stroke-dasharray"},u0={offset:"strokeDashoffset",array:"strokeDasharray"};function d0(e,t,n=1,s=0,r=!0){e.pathLength=1;const i=r?c0:u0;e[i.offset]=`${-s}`,e[i.array]=`${t} ${n}`}const f0=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function _u(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:i=1,pathOffset:o=0,...a},l,c,u){if(Xi(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??"fill-box",delete d.transformBox);for(const m of f0)d[m]!==void 0&&(f[m]=d[m],delete d[m]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),r!==void 0&&d0(d,r,i,o,!1)}const Ou=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),Bu=e=>typeof e=="string"&&e.toLowerCase()==="svg";function h0(e,t,n,s){Iu(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Ou.has(r)?r:Ui(r),t.attrs[r])}function $u(e,t,n){const s=Zi(e,t,n);for(const r in e)if(Ce(e[r])||Ce(t[r])){const i=on.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[i]=e[r]}return s}class m0 extends Du{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Te}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(an.has(n)){const s=vu(n);return s&&s.default||0}return n=Ou.has(n)?n:Ui(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return $u(t,n,s)}build(t,n,s){_u(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){h0(t,n,s,r)}mount(t){this.isSVGTag=Bu(t.tagName),super.mount(t)}}const p0=zi.length;function Uu(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Uu(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<p0;n++){const s=zi[n],r=e.props[s];(Rn(r)||r===!1)&&(t[s]=r)}return t}function Wu(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const g0=[...Yi].reverse(),y0=Yi.length;function b0(e){return t=>Promise.all(t.map(({animation:n,options:s})=>hb(e,n,s)))}function x0(e){let t=b0(e),n=Fa(),s=!0,r=!1;const i=c=>(u,d)=>{const f=jt(e,d,c==="exit"?e.presenceContext?.custom:void 0);if(f){const{transition:m,transitionEnd:p,...y}=f;u={...u,...y,...p}}return u};function o(c){t=c(e)}function a(c){const{props:u}=e,d=Uu(e.parent)||{},f=[],m=new Set;let p={},y=1/0;for(let x=0;x<y0;x++){const w=g0[x],v=n[w],T=u[w]!==void 0?u[w]:d[w],S=Rn(T),R=w===c?v.isActive:null;R===!1&&(y=x);let N=T===d[w]&&T!==u[w]&&S;if(N&&(s||r)&&e.manuallyAnimateOnMount&&(N=!1),v.protectedKeys={...p},!v.isActive&&R===null||!T&&!v.prevProp||Fs(T)||typeof T=="boolean")continue;if(w==="exit"&&v.isActive&&R!==!0){v.prevResolvedValues&&(p={...p,...v.prevResolvedValues});continue}const C=v0(v.prevProp,T);let I=C||w===c&&v.isActive&&!N&&S||x>y&&S,A=!1;const M=Array.isArray(T)?T:[T];let U=M.reduce(i(w),{});R===!1&&(U={});const{prevResolvedValues:L={}}=v,$={...L,...U},j=D=>{I=!0,m.has(D)&&(A=!0,m.delete(D)),v.needsAnimating[D]=!0;const _=e.getValue(D);_&&(_.liveStyle=!1)};for(const D in $){const _=U[D],z=L[D];if(p.hasOwnProperty(D))continue;let X=!1;ri(_)&&ri(z)?X=!Wu(_,z):X=_!==z,X?_!=null?j(D):m.add(D):_!==void 0&&m.has(D)?j(D):v.protectedKeys[D]=!0}v.prevProp=T,v.prevResolvedValues=U,v.isActive&&(p={...p,...U}),(s||r)&&e.blockInitialAnimation&&(I=!1);const W=N&&C;I&&(!W||A)&&f.push(...M.map(D=>{const _={type:w};if(typeof D=="string"&&(s||r)&&!W&&e.manuallyAnimateOnMount&&e.parent){const{parent:z}=e,X=jt(z,D);if(z.enteringChildren&&X){const{delayChildren:se}=X.transition||{};_.delay=du(z.enteringChildren,e,se)}}return{animation:D,options:_}}))}if(m.size){const x={};if(typeof u.initial!="boolean"){const w=jt(e,Array.isArray(u.initial)?u.initial[0]:u.initial);w&&w.transition&&(x.transition=w.transition)}m.forEach(w=>{const v=e.getBaseTarget(w),T=e.getValue(w);T&&(T.liveStyle=!0),x[w]=v??null}),f.push({animation:x})}let b=!!f.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(b=!1),s=!1,r=!1,b?t(f):Promise.resolve()}function l(c,u){if(n[c].isActive===u)return Promise.resolve();e.variantChildren?.forEach(f=>f.animationState?.setActive(c,u)),n[c].isActive=u;const d=a(c);for(const f in n)n[f].protectedKeys={};return d}return{animateChanges:a,setActive:l,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Fa(),r=!0}}}function v0(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Wu(t,e):!1}function Et(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Fa(){return{animate:Et(!0),whileInView:Et(),whileHover:Et(),whileTap:Et(),whileDrag:Et(),whileFocus:Et(),exit:Et()}}function fi(e,t){e.min=t.min,e.max=t.max}function ze(e,t){fi(e.x,t.x),fi(e.y,t.y)}function _a(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const Ku=1e-4,w0=1-Ku,S0=1+Ku,Hu=.01,k0=0-Hu,T0=0+Hu;function De(e){return e.max-e.min}function C0(e,t,n){return Math.abs(e-t)<=n}function Oa(e,t,n,s=.5){e.origin=s,e.originPoint=fe(t.min,t.max,e.origin),e.scale=De(n)/De(t),e.translate=fe(n.min,n.max,e.origin)-e.originPoint,(e.scale>=w0&&e.scale<=S0||isNaN(e.scale))&&(e.scale=1),(e.translate>=k0&&e.translate<=T0||isNaN(e.translate))&&(e.translate=0)}function kn(e,t,n,s){Oa(e.x,t.x,n.x,s?s.originX:void 0),Oa(e.y,t.y,n.y,s?s.originY:void 0)}function Ba(e,t,n,s=0){const r=s?fe(n.min,n.max,s):n.min;e.min=r+t.min,e.max=e.min+De(t)}function E0(e,t,n,s){Ba(e.x,t.x,n.x,s?.x),Ba(e.y,t.y,n.y,s?.y)}function $a(e,t,n,s=0){const r=s?fe(n.min,n.max,s):n.min;e.min=t.min-r,e.max=e.min+De(t)}function Ds(e,t,n,s){$a(e.x,t.x,n.x,s?.x),$a(e.y,t.y,n.y,s?.y)}function Ua(e,t,n,s,r){return e-=t,e=Ms(e,1/n,s),r!==void 0&&(e=Ms(e,1/r,s)),e}function A0(e,t=0,n=1,s=.5,r,i=e,o=e){if(at.test(t)&&(t=parseFloat(t),t=fe(o.min,o.max,t/100)-o.min),typeof t!="number")return;let a=fe(i.min,i.max,s);e===i&&(a-=t),e.min=Ua(e.min,t,n,a,r),e.max=Ua(e.max,t,n,a,r)}function Wa(e,t,[n,s,r],i,o){A0(e,t[n],t[s],t[r],t.scale,i,o)}const P0=["x","scaleX","originX"],R0=["y","scaleY","originY"];function Ka(e,t,n,s){Wa(e.x,t,P0,n?n.x:void 0,s?s.x:void 0),Wa(e.y,t,R0,n?n.y:void 0,s?s.y:void 0)}function Ha(e){return e.translate===0&&e.scale===1}function Gu(e){return Ha(e.x)&&Ha(e.y)}function Ga(e,t){return e.min===t.min&&e.max===t.max}function M0(e,t){return Ga(e.x,t.x)&&Ga(e.y,t.y)}function Ya(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Yu(e,t){return Ya(e.x,t.x)&&Ya(e.y,t.y)}function za(e){return De(e.x)/De(e.y)}function qa(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function st(e){return[e("x"),e("y")]}function D0(e,t,n){let s="";const r=e.x.translate/t.x,i=e.y.translate/t.y,o=n?.z||0;if((r||i||o)&&(s=`translate3d(${r}px, ${i}px, ${o}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:c,rotate:u,rotateX:d,rotateY:f,skewX:m,skewY:p}=n;c&&(s=`perspective(${c}px) ${s}`),u&&(s+=`rotate(${u}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),m&&(s+=`skewX(${m}deg) `),p&&(s+=`skewY(${p}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const zu=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],N0=zu.length,Xa=e=>typeof e=="string"?parseFloat(e):e,Za=e=>typeof e=="number"||B.test(e);function j0(e,t,n,s,r,i){r?(e.opacity=fe(0,n.opacity??1,L0(s)),e.opacityExit=fe(t.opacity??1,0,V0(s))):i&&(e.opacity=fe(t.opacity??1,n.opacity??1,s));for(let o=0;o<N0;o++){const a=zu[o];let l=Ja(t,a),c=Ja(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||Za(l)===Za(c)?(e[a]=Math.max(fe(Xa(l),Xa(c),s),0),(at.test(c)||at.test(l))&&(e[a]+="%")):e[a]=c}(t.rotate||n.rotate)&&(e.rotate=fe(t.rotate||0,n.rotate||0,s))}function Ja(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const L0=qu(0,.5,_c),V0=qu(.5,.95,We);function qu(e,t,n){return s=>s<e?0:s>t?1:n(En(e,t,s))}function I0(e,t,n){const s=Ce(e)?e:Lt(e);return s.start(Bi("",s,t,n)),s.animation}function Mn(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}const F0=(e,t)=>e.depth-t.depth;class _0{constructor(){this.children=[],this.isDirty=!1}add(t){Ai(this.children,t),this.isDirty=!0}remove(t){Ts(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(F0),this.isDirty=!1,this.children.forEach(t)}}function O0(e,t){const n=Me.now(),s=({timestamp:r})=>{const i=r-n;i>=t&&(gt(s),e(i-t))};return ae.setup(s,!0),()=>gt(s)}function fs(e){return Ce(e)?e.get():e}class B0{constructor(){this.members=[]}add(t){Ai(this.members,t);for(let n=this.members.length-1;n>=0;n--){const s=this.members[n];if(s===t||s===this.lead||s===this.prevLead)continue;const r=s.instance;(!r||r.isConnected===!1)&&!s.snapshot&&(Ts(this.members,s),s.unmount())}t.scheduleRender()}remove(t){if(Ts(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){for(let n=this.members.indexOf(t)-1;n>=0;n--){const s=this.members[n];if(s.isPresent!==!1&&s.instance?.isConnected!==!1)return this.promote(s),!0}return!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.updateSnapshot(),t.scheduleRender();const{layoutDependency:r}=s.options,{layoutDependency:i}=t.options;(r===void 0||r!==i)&&(t.resumeFrom=s,n&&(s.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root?.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{t.options.onExitComplete?.(),t.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const hs={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Rr=["","X","Y","Z"],$0=1e3;let U0=0;function Mr(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function Xu(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=gu(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:i}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ae,!(r||i))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&Xu(s)}function Zu({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(o={},a=t?.()){this.id=U0++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(H0),this.nodes.forEach(Z0),this.nodes.forEach(J0),this.nodes.forEach(G0)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new _0)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Ri),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=Gi(o)&&!Wb(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;ae.read(()=>{d=window.innerWidth}),e(o,()=>{const m=window.innerWidth;m!==d&&(d=m,this.root.updateBlockedByResize=!0,u&&u(),u=O0(f,250),hs.hasAnimatedSinceResize&&(hs.hasAnimatedSinceResize=!1,this.nodes.forEach(tl)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:m})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const p=this.options.transition||c.getDefaultTransition()||sx,{onLayoutAnimationStart:y,onLayoutAnimationComplete:b}=c.getProps(),x=!this.targetLayout||!Yu(this.targetLayout,m),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const v={...Oi(p,"layout"),onPlay:y,onComplete:b};(c.shouldReduceMotion||this.options.layoutRoot)&&(v.delay=0,v.type=!1),this.startAnimation(v),this.setAnimationOrigin(u,w)}else d||tl(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=m})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),gt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Q0),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Xu(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];d.shouldResetTransform=!0,(typeof d.latestValues.x=="string"||typeof d.latestValues.y=="string")&&(d.isLayoutDirty=!0),d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const l=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),l&&this.nodes.forEach(z0),this.nodes.forEach(Qa);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(el);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(q0),this.nodes.forEach(X0),this.nodes.forEach(W0),this.nodes.forEach(K0)):this.nodes.forEach(el),this.clearAllSnapshots();const a=Me.now();Ae.delta=lt(0,1e3/60,a-Ae.timestamp),Ae.timestamp=a,Ae.isProcessing=!0,vr.update.process(Ae),vr.preRender.process(Ae),vr.render.process(Ae),Ae.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ki.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Y0),this.sharedNodes.forEach(ex)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ae.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ae.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!De(this.snapshot.measuredBox.x)&&!De(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=Te()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Gu(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||Pt(this.latestValues)||u)&&(r(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),rx(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return Te();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(ix))){const{scroll:c}=this.root;c&&(it(a.x,c.offset.x),it(a.y,c.offset.y))}return a}removeElementScroll(o){const a=Te();if(ze(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:d}=c;c!==this.root&&u&&d.layoutScroll&&(u.wasRoot&&ze(a,o),it(a.x,u.offset.x),it(a.y,u.offset.y))}return a}applyTransform(o,a=!1,l){const c=l||Te();ze(c,o);for(let u=0;u<this.path.length;u++){const d=this.path[u];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&(it(c.x,-d.scroll.offset.x),it(c.y,-d.scroll.offset.y)),Pt(d.latestValues)&&ds(c,d.latestValues,d.layout?.layoutBox)}return Pt(this.latestValues)&&ds(c,this.latestValues,this.layout?.layoutBox),c}removeTransform(o){const a=Te();ze(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!Pt(c.latestValues))continue;let u;c.instance&&(ci(c.latestValues)&&c.updateSnapshot(),u=Te(),ze(u,c.measurePageBox())),Ka(a,c.latestValues,c.snapshot?.layoutBox,u)}return Pt(this.latestValues)&&Ka(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ae.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:d}=this.options;if(!this.layout||!(u||d))return;this.resolvedRelativeTargetAt=Ae.timestamp;const f=this.getClosestProjectingParent();f&&this.linkedParentVersion!==f.layoutVersion&&!f.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&f&&f.layout?this.createRelativeTarget(f,this.layout.layoutBox,f.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Te(),this.targetWithTransforms=Te()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),E0(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):ze(this.target,this.layout.layoutBox),Lu(this.target,this.targetDelta)):ze(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?this.createRelativeTarget(f,this.target,f.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||ci(this.parent.latestValues)||ju(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,a,l){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Te(),this.relativeTargetOrigin=Te(),Ds(this.relativeTargetOrigin,a,l,this.options.layoutAnchor||void 0),ze(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Ae.timestamp&&(l=!1),l)return;const{layout:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;ze(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;t0(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=Te());const{target:m}=o;if(!m){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(_a(this.prevProjectionDelta.x,this.projectionDelta.x),_a(this.prevProjectionDelta.y,this.projectionDelta.y)),kn(this.projectionDelta,this.layoutCorrected,m,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!qa(this.projectionDelta.x,this.prevProjectionDelta.x)||!qa(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",m))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Gt(),this.projectionDelta=Gt(),this.projectionDeltaWithTransform=Gt()}setAnimationOrigin(o,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},d=Gt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=Te(),m=l?l.source:void 0,p=this.layout?this.layout.source:void 0,y=m!==p,b=this.getStack(),x=!b||b.members.length<=1,w=!!(y&&!x&&this.options.crossfade===!0&&!this.path.some(nx));this.animationProgress=0;let v;this.mixTargetDelta=T=>{const S=T/1e3;nl(d.x,o.x,S),nl(d.y,o.y,S),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ds(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),tx(this.relativeTarget,this.relativeTargetOrigin,f,S),v&&M0(this.relativeTarget,v)&&(this.isProjectionDirty=!1),v||(v=Te()),ze(v,this.relativeTarget)),y&&(this.animationValues=u,j0(u,c,this.latestValues,S,w,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=S},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(gt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ae.update(()=>{hs.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Lt(0)),this.motionValue.jump(0,!1),this.currentAnimation=I0(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta($0),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&Ju(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||Te();const d=De(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=De(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}ze(a,l),ds(a,u),kn(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new B0),this.sharedNodes.get(o).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const c={};l.z&&Mr("z",o,c,this.animationValues);for(let u=0;u<Rr.length;u++)Mr(`rotate${Rr[u]}`,o,c,this.animationValues),Mr(`skew${Rr[u]}`,o,c,this.animationValues);o.render();for(const u in c)o.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=fs(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=fs(a?.pointerEvents)||""),this.hasProjected&&!Pt(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=D0(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),o.transform=d;const{x:f,y:m}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${m.origin*100}% 0`,c.animationValues?o.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const p in di){if(u[p]===void 0)continue;const{correct:y,applyTo:b,isCSSVariable:x}=di[p],w=d==="none"?u[p]:y(u[p],c);if(b){const v=b.length;for(let T=0;T<v;T++)o[b[T]]=w}else x?this.options.visualElement.renderState.vars[p]=w:o[p]=w}this.options.layoutId&&(o.pointerEvents=c===this?fs(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Qa),this.root.sharedNodes.clear()}}}function W0(e){e.updateLayout()}function K0(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:r}=e.options,i=t.source!==e.layout.source;if(r==="size")st(u=>{const d=i?t.measuredBox[u]:t.layoutBox[u],f=De(d);d.min=n[u].min,d.max=d.min+f});else if(r==="x"||r==="y"){const u=r==="x"?"y":"x";fi(i?t.measuredBox[u]:t.layoutBox[u],n[u])}else Ju(r,t.layoutBox,n)&&st(u=>{const d=i?t.measuredBox[u]:t.layoutBox[u],f=De(n[u]);d.max=d.min+f,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+f)});const o=Gt();kn(o,n,t.layoutBox);const a=Gt();i?kn(a,e.applyTransform(s,!0),t.measuredBox):kn(a,n,t.layoutBox);const l=!Gu(o);let c=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:d,layout:f}=u;if(d&&f){const m=e.options.layoutAnchor||void 0,p=Te();Ds(p,t.layoutBox,d.layoutBox,m);const y=Te();Ds(y,n,f.layoutBox,m),Yu(p,y)||(c=!0),u.options.layoutRoot&&(e.relativeTarget=y,e.relativeTargetOrigin=p,e.relativeParent=u)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function H0(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function G0(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Y0(e){e.clearSnapshot()}function Qa(e){e.clearMeasurements()}function z0(e){e.isLayoutDirty=!0,e.updateLayout()}function el(e){e.isLayoutDirty=!1}function q0(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function X0(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function tl(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Z0(e){e.resolveTargetDelta()}function J0(e){e.calcProjection()}function Q0(e){e.resetSkewAndRotation()}function ex(e){e.removeLeadSnapshot()}function nl(e,t,n){e.translate=fe(t.translate,0,n),e.scale=fe(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function sl(e,t,n,s){e.min=fe(t.min,n.min,s),e.max=fe(t.max,n.max,s)}function tx(e,t,n,s){sl(e.x,t.x,n.x,s),sl(e.y,t.y,n.y,s)}function nx(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const sx={duration:.45,ease:[.4,0,.1,1]},rl=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),il=rl("applewebkit/")&&!rl("chrome/")?Math.round:We;function ol(e){e.min=il(e.min),e.max=il(e.max)}function rx(e){ol(e.x),ol(e.y)}function Ju(e,t,n){return e==="position"||e==="preserve-aspect"&&!C0(za(t),za(n),.2)}function ix(e){return e!==e.root&&e.scroll?.wasRoot}const ox=Zu({attachResizeListener:(e,t)=>Mn(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Dr={current:void 0},Qu=Zu({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Dr.current){const e=new ox({});e.mount(window),e.setOptions({layoutScroll:!0}),Dr.current=e}return Dr.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Os=h.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function ax(e=!0){const t=h.useContext(Ei);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,i=h.useId();h.useEffect(()=>{if(e)return r(i)},[e]);const o=h.useCallback(()=>e&&s&&s(i),[i,s,e]);return!n&&s?[!1,o]:[!0]}const ed=h.createContext({strict:!1}),al={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let ll=!1;function lx(){if(ll)return;const e={};for(const t in al)e[t]={isEnabled:n=>al[t].some(s=>!!n[s])};Mu(e),ll=!0}function td(){return lx(),Zb()}function cx(e){const t=td();for(const n in e)t[n]={...t[n],...e[n]};Mu(t)}const ux=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Ns(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||ux.has(e)}let nd=e=>!Ns(e);function dx(e){typeof e=="function"&&(nd=t=>t.startsWith("on")?!Ns(t):e(t))}try{dx(require("@emotion/is-prop-valid").default)}catch{}function fx(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||Ce(e[r])||(nd(r)||n===!0&&Ns(r)||!t&&!Ns(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const Bs=h.createContext({});function hx(e,t){if(_s(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Rn(n)?n:void 0,animate:Rn(s)?s:void 0}}return e.inherit!==!1?t:{}}function mx(e){const{initial:t,animate:n}=hx(e,h.useContext(Bs));return h.useMemo(()=>({initial:t,animate:n}),[cl(t),cl(n)])}function cl(e){return Array.isArray(e)?e.join(" "):e}const Ji=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function sd(e,t,n){for(const s in t)!Ce(t[s])&&!Fu(s,n)&&(e[s]=t[s])}function px({transformTemplate:e},t){return h.useMemo(()=>{const n=Ji();return Xi(n,t,e),Object.assign({},n.vars,n.style)},[t])}function gx(e,t){const n=e.style||{},s={};return sd(s,n,e),Object.assign(s,px(e,t)),s}function yx(e,t){const n={},s=gx(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const rd=()=>({...Ji(),attrs:{}});function bx(e,t,n,s){const r=h.useMemo(()=>{const i=rd();return _u(i,t,Bu(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};sd(i,e.style,e),r.style={...i,...r.style}}return r}const xx=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Qi(e){return typeof e!="string"||e.includes("-")?!1:!!(xx.indexOf(e)>-1||/[A-Z]/u.test(e))}function vx(e,t,n,{latestValues:s},r,i=!1,o){const l=(o??Qi(e)?bx:yx)(t,s,r,e),c=fx(t,typeof e=="string",i),u=e!==h.Fragment?{...c,...l,ref:n}:{},{children:d}=t,f=h.useMemo(()=>Ce(d)?d.get():d,[d]);return h.createElement(e,{...u,children:f})}function wx({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:Sx(n,s,r,e),renderState:t()}}function Sx(e,t,n,s){const r={},i=s(e,{});for(const f in i)r[f]=fs(i[f]);let{initial:o,animate:a}=e;const l=_s(e),c=Pu(e);t&&c&&!l&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const d=u?a:o;if(d&&typeof d!="boolean"&&!Fs(d)){const f=Array.isArray(d)?d:[d];for(let m=0;m<f.length;m++){const p=$i(e,f[m]);if(p){const{transitionEnd:y,transition:b,...x}=p;for(const w in x){let v=x[w];if(Array.isArray(v)){const T=u?v.length-1:0;v=v[T]}v!==null&&(r[w]=v)}for(const w in y)r[w]=y[w]}}}return r}const id=e=>(t,n)=>{const s=h.useContext(Bs),r=h.useContext(Ei),i=()=>wx(e,t,s,r);return n?i():Ci(i)},kx=id({scrapeMotionValuesFromProps:Zi,createRenderState:Ji}),Tx=id({scrapeMotionValuesFromProps:$u,createRenderState:rd}),Cx=Symbol.for("motionComponentSymbol");function Ex(e,t,n){const s=h.useRef(n);h.useInsertionEffect(()=>{s.current=n});const r=h.useRef(null);return h.useCallback(i=>{i&&e.onMount?.(i);const o=s.current;if(typeof o=="function")if(i){const a=o(i);typeof a=="function"&&(r.current=a)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i);t&&(i?t.mount(i):t.unmount())},[t])}const od=h.createContext({});function Wt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Ax(e,t,n,s,r,i){const{visualElement:o}=h.useContext(Bs),a=h.useContext(ed),l=h.useContext(Ei),c=h.useContext(Os),u=c.reducedMotion,d=c.skipAnimations,f=h.useRef(null),m=h.useRef(!1);s=s||a.renderer,!f.current&&s&&(f.current=s(e,{visualState:t,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:i}),m.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const p=f.current,y=h.useContext(od);p&&!p.projection&&r&&(p.type==="html"||p.type==="svg")&&Px(f.current,n,r,y);const b=h.useRef(!1);h.useInsertionEffect(()=>{p&&b.current&&p.update(n,l)});const x=n[pu],w=h.useRef(!!x&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(x)&&window.MotionHasOptimisedAnimation?.(x));return Ec(()=>{m.current=!0,p&&(b.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),w.current&&p.animationState&&p.animationState.animateChanges())}),h.useEffect(()=>{p&&(!w.current&&p.animationState&&p.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(x)}),w.current=!1),p.enteringChildren=void 0)}),p}function Px(e,t,n,s){const{layoutId:r,layout:i,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:ad(e.parent)),e.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||a&&Wt(a),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:c,layoutAnchor:u})}function ad(e){if(e)return e.options.allowProjection!==!1?e.projection:ad(e.parent)}function Nr(e,{forwardMotionProps:t=!1,type:n}={},s,r){s&&cx(s);const i=n?n==="svg":Qi(e),o=i?Tx:kx;function a(c,u){let d;const f={...h.useContext(Os),...c,layoutId:Rx(c)},{isStatic:m}=f,p=mx(c),y=o(c,m);if(!m&&typeof window<"u"){Mx();const b=Dx(f);d=b.MeasureLayout,p.visualElement=Ax(e,y,f,r,b.ProjectionNode,i)}return g.jsxs(Bs.Provider,{value:p,children:[d&&p.visualElement?g.jsx(d,{visualElement:p.visualElement,...f}):null,vx(e,c,Ex(y,p.visualElement,u),y,m,t,i)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const l=h.forwardRef(a);return l[Cx]=e,l}function Rx({layoutId:e}){const t=h.useContext(Cc).id;return t&&e!==void 0?t+"-"+e:e}function Mx(e,t){h.useContext(ed).strict}function Dx(e){const t=td(),{drag:n,layout:s}=t;if(!n&&!s)return{};const r={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Nx(e,t){if(typeof Proxy>"u")return Nr;const n=new Map,s=(i,o)=>Nr(i,o,e,t),r=(i,o)=>s(i,o);return new Proxy(r,{get:(i,o)=>o==="create"?s:(n.has(o)||n.set(o,Nr(o,void 0,e,t)),n.get(o))})}const jx=(e,t)=>t.isSVG??Qi(e)?new m0(t):new l0(t,{allowProjection:e!==h.Fragment});class Lx extends St{constructor(t){super(t),t.animationState||(t.animationState=x0(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Fs(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Vx=0;class Ix extends St{constructor(){super(...arguments),this.id=Vx++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;if(t&&s===!1){if(this.isExitComplete){const{initial:i,custom:o}=this.node.getProps();if(typeof i=="string"){const a=jt(this.node,i,o);if(a){const{transition:l,transitionEnd:c,...u}=a;for(const d in u)this.node.getValue(d)?.jump(u[d])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Fx={animation:{Feature:Lx},exit:{Feature:Ix}};function Fn(e){return{point:{x:e.pageX,y:e.pageY}}}const _x=e=>t=>Hi(t)&&e(t,Fn(t));function Tn(e,t,n,s){return Mn(e,t,_x(n),s)}const ld=({current:e})=>e?e.ownerDocument.defaultView:null,ul=(e,t)=>Math.abs(e-t);function Ox(e,t){const n=ul(e.x,t.x),s=ul(e.y,t.y);return Math.sqrt(n**2+s**2)}const dl=new Set(["auto","scroll"]);class cd{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=m=>{this.handleScroll(m.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ss(this.lastRawMoveEventInfo,this.transformPagePoint));const m=jr(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,y=Ox(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!y)return;const{point:b}=m,{timestamp:x}=Ae;this.history.push({...b,timestamp:x});const{onStart:w,onMove:v}=this.handlers;p||(w&&w(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),v&&v(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=p,this.lastMoveEventInfo=ss(p,this.transformPagePoint),ae.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:y,onSessionEnd:b,resumeAnimation:x}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=jr(m.type==="pointercancel"?this.lastMoveEventInfo:ss(p,this.transformPagePoint),this.history);this.startEvent&&y&&y(m,w),b&&b(m,w)},!Hi(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=r||window;const l=Fn(t),c=ss(l,this.transformPagePoint),{point:u}=c,{timestamp:d}=Ae;this.history=[{...u,timestamp:d}];const{onSessionStart:f}=n;f&&f(t,jr(c,this.history)),this.removeListeners=Ln(Tn(this.contextWindow,"pointermove",this.handlePointerMove),Tn(this.contextWindow,"pointerup",this.handlePointerUp),Tn(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(dl.has(s.overflowX)||dl.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const s=t===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:r.x-n.x,y:r.y-n.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,r),ae.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),gt(this.updatePoint)}}function ss(e,t){return t?{point:t(e.point)}:e}function fl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function jr({point:e},t){return{point:e,delta:fl(e,ud(t)),offset:fl(e,Bx(t)),velocity:$x(t,.1)}}function Bx(e){return e[0]}function ud(e){return e[e.length-1]}function $x(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=ud(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>Oe(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&r.timestamp-s.timestamp>Oe(t)*2&&(s=e[1]);const i=$e(r.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const o={x:(r.x-s.x)/i,y:(r.y-s.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Ux(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?fe(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?fe(n,e,s.max):Math.min(e,n)),e}function hl(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Wx(e,{top:t,left:n,bottom:s,right:r}){return{x:hl(e.x,n,r),y:hl(e.y,t,s)}}function ml(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function Kx(e,t){return{x:ml(e.x,t.x),y:ml(e.y,t.y)}}function Hx(e,t){let n=.5;const s=De(e),r=De(t);return r>s?n=En(t.min,t.max-s,e.min):s>r&&(n=En(e.min,e.max-r,t.min)),lt(0,1,n)}function Gx(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const hi=.35;function Yx(e=hi){return e===!1?e=0:e===!0&&(e=hi),{x:pl(e,"left","right"),y:pl(e,"top","bottom")}}function pl(e,t,n){return{min:gl(e,t),max:gl(e,n)}}function gl(e,t){return typeof e=="number"?e:e[t]||0}const zx=new WeakMap;class qx{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Te(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=d=>{n&&this.snapToCursor(Fn(d).point),this.stopAnimation()},o=(d,f)=>{const{drag:m,dragPropagation:p,onDragStart:y}=this.getProps();if(m&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Eb(m),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),st(x=>{let w=this.getAxisMotionValue(x).get()||0;if(at.test(w)){const{projection:v}=this.visualElement;if(v&&v.layout){const T=v.layout.layoutBox[x];T&&(w=De(T)*(parseFloat(w)/100))}}this.originPoint[x]=w}),y&&ae.update(()=>y(d,f),!1,!0),ii(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:m,dragDirectionLock:p,onDirectionLock:y,onDrag:b}=this.getProps();if(!m&&!this.openDragLock)return;const{offset:x}=f;if(p&&this.currentDirection===null){this.currentDirection=Zx(x),this.currentDirection!==null&&y&&y(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),b&&ae.update(()=>b(d,f),!1,!0)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{const{dragSnapToOrigin:d}=this.getProps();(d||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new cd(t,{onSessionStart:i,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:ld(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!s)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&ae.postRender(()=>a(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!rs(t,r,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=Ux(o,this.constraints[t],this.elastic[t])),i.set(o)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&Wt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Wx(s.layoutBox,t):this.constraints=!1,this.elastic=Yx(n),r!==this.constraints&&!Wt(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&st(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=Gx(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Wt(t))return!1;const s=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const i=n0(s,r.root,this.visualElement.getTransformPagePoint());let o=Kx(r.layout.layoutBox,i);if(n){const a=n(Qb(o));this.hasMutatedConstraints=!!a,a&&(o=Nu(a))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=st(u=>{if(!rs(u,n,this.currentDirection))return;let d=l&&l[u]||{};(o===!0||o===u)&&(d={min:0,max:0});const f=r?200:1e6,m=r?40:1e7,p={type:"inertia",velocity:s?t[u]:0,bounceStiffness:f,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...i,...d};return this.startAxisValueAnimation(u,p)});return Promise.all(c).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ii(this.visualElement,t),s.start(Bi(t,s,0,n,this.visualElement,!1))}stopAnimation(){st(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),r=s[n];return r||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){st(n=>{const{drag:s}=this.getProps();if(!rs(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:a}=r.layout.layoutBox[n],l=i.get()||0;i.set(t[n]-fe(o,a,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Wt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};st(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();r[o]=Hx({min:l,max:l},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),st(o=>{if(!rs(o,t,null))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=this.constraints[o];a.set(fe(l,c,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;zx.set(this.visualElement,this);const t=this.visualElement.current,n=Tn(t,"pointerdown",c=>{const{drag:u,dragListener:d=!0}=this.getProps(),f=c.target,m=f!==t&&Nb(f);u&&d&&!m&&this.start(c)});let s;const r=()=>{const{dragConstraints:c}=this.getProps();Wt(c)&&c.current&&(this.constraints=this.resolveRefConstraints(),s||(s=Xx(t,c.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),ae.read(r);const a=Mn(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(st(d=>{const f=this.getAxisMotionValue(d);f&&(this.originPoint[d]+=c[d].translate,f.set(f.get()+c[d].translate))}),this.visualElement.render())}));return()=>{a(),n(),o(),l&&l(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:o=hi,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:a}}}function yl(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Xx(e,t,n){const s=Ca(e,yl(n)),r=Ca(t,yl(n));return()=>{s(),r()}}function rs(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Zx(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Jx extends St{constructor(t){super(t),this.removeGroupControls=We,this.removeListeners=We,this.controls=new qx(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||We}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Lr=e=>(t,n)=>{e&&ae.update(()=>e(t,n),!1,!0)};class Qx extends St{constructor(){super(...arguments),this.removePointerDownListener=We}onPointerDown(t){this.session=new cd(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ld(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Lr(t),onStart:Lr(n),onMove:Lr(s),onEnd:(i,o)=>{delete this.session,r&&ae.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=Tn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Vr=!1;class ev extends h.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),s&&s.register&&r&&s.register(i),Vr&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),hs.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:i}=this.props,{projection:o}=s;return o&&(o.isPresent=i,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),Vr=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==i?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||ae.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Ki.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;Vr=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function dd(e){const[t,n]=ax(),s=h.useContext(Cc);return g.jsx(ev,{...e,layoutGroup:s,switchLayoutGroup:h.useContext(od),isPresent:t,safeToRemove:n})}const tv={pan:{Feature:Qx},drag:{Feature:Jx,ProjectionNode:Qu,MeasureLayout:dd}};function bl(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,i=s[r];i&&ae.postRender(()=>i(t,Fn(t)))}class nv extends St{mount(){const{current:t}=this.node;t&&(this.unmount=Pb(t,(n,s)=>(bl(this.node,s,"Start"),r=>bl(this.node,r,"End"))))}unmount(){}}class sv extends St{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ln(Mn(this.node.current,"focus",()=>this.onFocus()),Mn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function xl(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),i=s[r];i&&ae.postRender(()=>i(t,Fn(t)))}class rv extends St{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Lb(t,(r,i)=>(xl(this.node,i,"Start"),(o,{success:a})=>xl(this.node,o,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const mi=new WeakMap,Ir=new WeakMap,iv=e=>{const t=mi.get(e.target);t&&t(e)},ov=e=>{e.forEach(iv)};function av({root:e,...t}){const n=e||document;Ir.has(n)||Ir.set(n,{});const s=Ir.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(ov,{root:e,...t})),s[r]}function lv(e,t,n){const s=av(t);return mi.set(e,n),s.observe(e),()=>{mi.delete(e),s.unobserve(e)}}const cv={some:0,all:1};class uv extends St{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:i}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:cv[r]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,i&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=c?u:d;f&&f(l)};this.stopObserver=lv(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(dv(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function dv({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const fv={inView:{Feature:uv},tap:{Feature:rv},focus:{Feature:sv},hover:{Feature:nv}},hv={layout:{ProjectionNode:Qu,MeasureLayout:dd}},mv={...Fx,...fv,...tv,...hv},_e=Nx(mv,jx);function eo(e){const t=Ci(()=>Lt(e)),{isStatic:n}=h.useContext(Os);if(n){const[,s]=h.useState(e);h.useEffect(()=>t.on("change",s),[])}return t}function fd(e,t){const n=eo(t()),s=()=>n.set(t());return s(),Ec(()=>{const r=()=>ae.preRender(s,!1,!0),i=e.map(o=>o.on("change",r));return()=>{i.forEach(o=>o()),gt(s)}}),n}function pv(e){Sn.current=[],e();const t=fd(Sn.current,e);return Sn.current=void 0,t}function hd(e,t,n,s){if(typeof e=="function")return pv(e);const i=typeof t=="function"?t:Kb(t,n,s),o=Array.isArray(e)?vl(e,i):vl([e],([l])=>i(l)),a=Array.isArray(e)?void 0:e.accelerate;return a&&!a.isTransformed&&typeof t!="function"&&Array.isArray(n)&&s?.clamp!==!1&&(o.accelerate={...a,times:t,keyframes:n,isTransformed:!0}),o}function vl(e,t){const n=Ci(()=>[]);return fd(e,()=>{n.length=0;const s=e.length;for(let r=0;r<s;r++)n[r]=e[r].get();return t(n)})}function gv(e,t={}){const{isStatic:n}=h.useContext(Os),s=()=>Ce(e)?e.get():e;if(n)return hd(s);const r=eo(s());return h.useInsertionEffect(()=>Hb(r,e,t),[r,JSON.stringify(t)]),r}function yv(e,t={}){return gv(e,{type:"spring",...t})}function _n(){!qi.current&&Ru();const[e]=h.useState(Ps.current);return e}function to({children:e,variant:t="primary",size:n="md",onClick:s,disabled:r=!1,className:i="",as:o="button",...a}){const l="inline-flex items-center justify-center font-medium transition-all duration-200 rounded-md focus:outline-none focus:ring-2 focus:ring-oai-blue/30 active:scale-[0.98] active:duration-100",c={primary:"bg-oai-black dark:bg-oai-white text-white dark:text-oai-black border border-transparent hover:bg-oai-gray-800 dark:hover:bg-oai-gray-200 active:bg-oai-gray-900 dark:active:bg-oai-gray-300 disabled:bg-oai-gray-300 dark:disabled:bg-oai-gray-700 disabled:text-oai-gray-500 dark:disabled:text-oai-gray-400 focus:ring-oai-brand/30 transition-colors duration-200",secondary:"bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white border border-oai-gray-300 dark:border-oai-gray-700 hover:border-oai-brand hover:text-oai-brand active:bg-oai-gray-50 dark:active:bg-oai-gray-800 active:border-oai-brand-dark disabled:text-oai-gray-400 dark:disabled:text-oai-gray-500 disabled:border-oai-gray-200 dark:disabled:border-oai-gray-700 focus:ring-oai-brand/30 transition-colors duration-200",ghost:"bg-transparent text-oai-gray-600 dark:text-oai-gray-300 border border-transparent hover:text-oai-brand hover:bg-oai-brand-50/50 dark:hover:bg-oai-brand-950/30 active:bg-oai-brand-50 dark:active:bg-oai-brand-900/50 disabled:text-oai-gray-400 dark:disabled:text-oai-gray-500 focus:ring-oai-brand/30 transition-colors duration-200"},u={sm:"h-8 px-3 text-sm",md:"h-10 px-4 text-sm",lg:"h-12 px-6 text-base"},d=r?"cursor-not-allowed opacity-60":"cursor-pointer",f=`${l} ${c[t]} ${u[n]} ${d} ${i}`;return g.jsx(o,{className:f,onClick:s,disabled:r,...a,children:e})}function $s({children:e,title:t,subtitle:n,className:s="",bodyClassName:r=""}){return g.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${s}`,children:[(t||n)&&g.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[t&&g.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:t}),n&&g.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:n})]}),g.jsx("div",{className:`p-5 ${r}`,children:e})]})}function bv({theme:e,onToggle:t,className:n="",size:s=36,iconSize:r=20}){const i=_n(),o=e==="dark",a=()=>{t?.(o?"light":"dark")},l={width:s,height:s,borderRadius:8,background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--oai-gray-600)",transition:"background-color 150ms ease, color 150ms ease"},c={backgroundColor:"var(--oai-gray-100)",color:"var(--oai-black)"},u=()=>g.jsxs("svg",{"aria-hidden":"true",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("circle",{cx:"12",cy:"12",r:"4"}),g.jsx("path",{d:"M12 2v2"}),g.jsx("path",{d:"M12 20v2"}),g.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),g.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),g.jsx("path",{d:"M2 12h2"}),g.jsx("path",{d:"M20 12h2"}),g.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),g.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]}),d=()=>g.jsx("svg",{"aria-hidden":"true",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})});return i?g.jsx("button",{type:"button","aria-label":o?"Switch to light mode":"Switch to dark mode",onClick:a,className:`oai-button-ghost oai-button-sm ${n}`,style:{...l,width:s,height:s,padding:0},title:o?"切换到亮色模式":"切换到暗色模式",onMouseEnter:f=>{f.currentTarget.style.backgroundColor=c.backgroundColor,f.currentTarget.style.color=c.color},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent",f.currentTarget.style.color="var(--oai-gray-600)"},children:o?g.jsx(d,{}):g.jsx(u,{})}):g.jsx(_e.button,{type:"button","aria-label":o?"Switch to light mode":"Switch to dark mode",onClick:a,className:`oai-button-ghost oai-button-sm ${n}`,style:{...l,width:s,height:s,padding:0},title:o?"切换到亮色模式":"切换到暗色模式",whileHover:{backgroundColor:"var(--oai-gray-100)",color:"var(--oai-black)"},whileTap:{scale:.95},transition:{type:"spring",stiffness:400,damping:25},children:g.jsx(_e.div,{initial:{scale:.8,opacity:0,rotate:-20},animate:{scale:1,opacity:1,rotate:0},exit:{scale:.8,opacity:0,rotate:20},transition:{type:"spring",stiffness:400,damping:25},children:o?g.jsx(d,{}):g.jsx(u,{})},o?"moon":"sun")})}function xv(){return g.jsxs("div",{className:"flex items-center gap-2.5",children:[g.jsx("div",{className:"w-8 h-8 rounded-lg bg-oai-black dark:bg-oai-white flex items-center justify-center",children:g.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",className:"text-oai-white dark:text-oai-black",children:[g.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),g.jsx("path",{d:"M2 17l10 5 10-5M2 12l10 5 10-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),g.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function vv({children:e,header:t,footer:n,className:s="",hideHeader:r=!1,hideFooter:i=!1}){const{resolvedTheme:o,toggleTheme:a}=wi();return g.jsxs("div",{className:`min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-sans flex flex-col transition-colors duration-200 ${s}`,children:[!r&&g.jsxs("header",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 flex items-center justify-between transition-colors duration-200",children:[g.jsx(xv,{}),g.jsx("div",{className:"flex-1 flex justify-center",children:t}),g.jsx(bv,{theme:o,onToggle:a})]}),g.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!i&&n&&g.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]})}function wv({children:e,variant:t="info",size:n="md",className:s=""}){const r="inline-flex items-center font-medium",i={success:"bg-oai-brand-100 dark:bg-oai-brand-900/30 text-oai-brand-700 dark:text-oai-brand-400 rounded-full",warning:"bg-oai-amber-50 dark:bg-oai-amber-900/30 text-oai-amber-dark dark:text-oai-amber-400 rounded-full",error:"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded-full",info:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 rounded-full",secondary:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-500 dark:text-oai-gray-300 rounded-md"},o={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},a=`${r} ${i[t]} ${o[n]} ${s}`.trim();return g.jsx("span",{className:a,children:e})}var Sv={};function kv(e,t){return e==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:e===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:t}}function Tv({mv:e,digit:t,height:n}){const s=hd(e,r=>{const i=(r%10+10)%10,o=(10+t-i)%10;let a=o*n;return o>5&&(a-=10*n),a});return g.jsx(_e.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:s},children:t})}function Cv(e){const t=Math.round(e),n=1e-9*Math.max(1,Math.abs(e));return Math.abs(e-t)<n?t:e}function Ev(e,t){const n=e/t;return Math.floor(Cv(n))}function Av(e){const t=String(e??""),n=Array.from(t),s=n.indexOf(".");let r=n.filter((a,l)=>/\d/.test(a)&&(s===-1||l<s)).length,i=0,o=!1;return n.map(a=>{if(!/\d/.test(a))return a==="."&&(o=!0),a;if(!o){const l=10**Math.max(r-1,0);return r-=1,l}return i+=1,10**-i})}function Pv({place:e,value:t,height:n,digitStyle:s,shouldReduceMotion:r}){if(typeof e!="number"){const l=kv(e,n);return g.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:n,...l,...s},children:e})}const i=Ev(t,e),o=eo(0),a=yv(o,{stiffness:220,damping:26,mass:.8});return h.useEffect(()=>{o.set(i)},[o,i]),r?g.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...s},children:Math.abs(i)%10}):g.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...s},children:Array.from({length:10},(l,c)=>g.jsx(Tv,{mv:a,digit:c,height:n},c))})}function Rv({value:e,displayValue:t,fontSize:n=72,padding:s=0,places:r,gap:i=6,borderRadius:o=4,horizontalPadding:a=0,textColor:l="inherit",fontWeight:c="inherit",containerStyle:u,counterStyle:d,digitStyle:f,gradientHeight:m=14,gradientFrom:p="rgba(255,255,255,0.95)",gradientTo:y="rgba(255,255,255,0)",topGradientStyle:b,bottomGradientStyle:x}){const w=String(t??e??""),v=h.useMemo(()=>Array.isArray(r)&&r.length?r:Av(w),[r,w]),T=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Sv?.VITEST==="true",S=_n()||T,R=Number.isFinite(Number(e))?Math.abs(Number(e)):0,N=n+s;return S?g.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:l,fontSize:n,fontWeight:c,lineHeight:1,...u,...d},children:w}):g.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...u},children:[g.jsx("span",{style:{fontSize:n,display:"flex",gap:i,overflow:"hidden",borderRadius:o,paddingLeft:a,paddingRight:a,lineHeight:1,color:l,fontWeight:c,...d},children:v.map((C,I)=>g.jsx(Pv,{place:C,value:R,height:N,digitStyle:f,shouldReduceMotion:S},`${String(C)}-${I}`))}),g.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[g.jsx("span",{style:b??{height:m,background:`linear-gradient(to bottom, ${p}, ${y})`}}),g.jsx("span",{style:x??{height:m,background:`linear-gradient(to top, ${p}, ${y})`}})]})]})}const md=h.createContext(void 0);function Vt(e){const t=h.useContext(md);if(e===!1&&t===void 0)throw new Error(gi(27));return t}const Mv={...Ti,...ki},Dv=h.forwardRef(function(t,n){const{render:s,className:r,forceRender:i=!1,...o}=t,{store:a}=Vt(),l=a.useState("open"),c=a.useState("nested"),u=a.useState("mounted"),d=a.useState("transitionStatus"),f=h.useMemo(()=>({open:l,transitionStatus:d}),[l,d]);return nn("div",t,{state:f,ref:[a.context.backdropRef,n],stateAttributesMapping:Mv,props:[{role:"presentation",hidden:!u,style:{userSelect:"none",WebkitUserSelect:"none"}},o],enabled:i||!c})}),wl=h.forwardRef(function(t,n){const{render:s,className:r,disabled:i=!1,nativeButton:o=!0,...a}=t,{store:l}=Vt(),c=l.useState("open");function u(p){c&&l.setOpen(!1,pt(sh,p.nativeEvent))}const{getButtonProps:d,buttonRef:f}=nh({disabled:i,native:o}),m=h.useMemo(()=>({disabled:i}),[i]);return nn("button",t,{state:m,ref:[n,f],props:[{onClick:u},a,d]})});let Nv=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),jv=(function(e){return e[e.open=Ze.open]="open",e[e.closed=Ze.closed]="closed",e[e.startingStyle=Ze.startingStyle]="startingStyle",e[e.endingStyle=Ze.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const pd=h.createContext(void 0);function gd(){const e=h.useContext(pd);if(e===void 0)throw new Error(gi(26));return e}const Lv={...Ti,...ki,nestedDialogOpen(e){return e?{[jv.nestedDialogOpen]:""}:null}},Vv=h.forwardRef(function(t,n){const{className:s,finalFocus:r,initialFocus:i,render:o,...a}=t,{store:l}=Vt(),c=l.useState("descriptionElementId"),u=l.useState("disablePointerDismissal"),d=l.useState("floatingRootContext"),f=l.useState("popupProps"),m=l.useState("modal"),p=l.useState("mounted"),y=l.useState("nested"),b=l.useState("nestedOpenDialogCount"),x=l.useState("open"),w=l.useState("openMethod"),v=l.useState("titleElementId"),T=l.useState("transitionStatus"),S=l.useState("role");gd(),yc({open:x,ref:l.context.popupRef,onComplete(){x&&l.context.onOpenChangeComplete?.(!0)}});function R(M){return M==="touch"?l.context.popupRef.current:!0}const N=i===void 0?R:i,C=b>0,I=h.useMemo(()=>({open:x,nested:y,transitionStatus:T,nestedDialogOpen:C}),[x,y,T,C]),A=nn("div",t,{state:I,props:[f,{"aria-labelledby":v??void 0,"aria-describedby":c??void 0,role:S,tabIndex:-1,hidden:!p,onKeyDown(M){vg.has(M.key)&&M.stopPropagation()},style:{[Nv.nestedDialogs]:b}},a],ref:[n,l.context.popupRef,l.useStateSetter("popupElement")],stateAttributesMapping:Lv});return g.jsx(Op,{context:d,openInteractionType:w,disabled:!p,closeOnFocusOut:!u,initialFocus:N,returnFocus:r,modal:m!==!1,restoreFocus:"popup",children:A})}),Iv=h.forwardRef(function(t,n){const{keepMounted:s=!1,...r}=t,{store:i}=Vt(),o=i.useState("mounted"),a=i.useState("modal"),l=i.useState("open");return o||s?g.jsx(pd.Provider,{value:s,children:g.jsxs(Lp,{ref:n,...r,children:[o&&a===!0&&g.jsx(gg,{ref:i.context.internalBackdropRef,inert:lg(!l)}),t.children]})}):null});function Fv(e){const{store:t,parentContext:n,actionsRef:s}=e,r=t.useState("open"),i=t.useState("disablePointerDismissal"),o=t.useState("modal"),a=t.useState("popupElement"),{openMethod:l,triggerProps:c,reset:u}=rg(r);zp(t);const{forceUnmount:d}=qp(r,t,()=>{u()}),f=ie(A=>{const M=pt(A);return M.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},M}),m=h.useCallback(()=>{t.setOpen(!1,f(rh))},[t,f]);h.useImperativeHandle(s,()=>({unmount:d,close:m}),[d,m]);const p=Qp({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[y,b]=h.useState(0),x=y===0,w=ng(p),v=Up(p,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(A){if("button"in A&&A.button!==0||"touches"in A&&A.touches.length!==1)return!1;const M=Xe(A);if(x&&!i){const U=M;return o&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===U||t.context.backdropRef.current===U||we(U,a)&&!U?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:x});pg(r&&o===!0,a);const{getReferenceProps:T,getFloatingProps:S,getTriggerProps:R}=eg([w,v]);t.useContextCallback("onNestedDialogOpen",A=>{b(A+1)}),t.useContextCallback("onNestedDialogClose",()=>{b(0)}),h.useEffect(()=>(n?.onNestedDialogOpen&&r&&n.onNestedDialogOpen(y),n?.onNestedDialogClose&&!r&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&r&&n.onNestedDialogClose()}),[r,n,y]);const N=h.useMemo(()=>T(c),[T,c]),C=h.useMemo(()=>R(c),[R,c]),I=h.useMemo(()=>S(),[S]);t.useSyncedValues({openMethod:l,activeTriggerProps:N,inactiveTriggerProps:C,popupProps:I,floatingRootContext:p,nestedOpenDialogCount:y})}const _v={...Jp,modal:oe(e=>e.modal),nested:oe(e=>e.nested),nestedOpenDialogCount:oe(e=>e.nestedOpenDialogCount),disablePointerDismissal:oe(e=>e.disablePointerDismissal),openMethod:oe(e=>e.openMethod),descriptionElementId:oe(e=>e.descriptionElementId),titleElementId:oe(e=>e.titleElementId),viewportElement:oe(e=>e.viewportElement),role:oe(e=>e.role)};class Ov extends cc{constructor(t){super(Bv(t),{popupRef:h.createRef(),backdropRef:h.createRef(),internalBackdropRef:h.createRef(),triggerElements:new bc,onOpenChange:void 0,onOpenChangeComplete:void 0},_v)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const s={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",s);const r={open:t},i=n.trigger?.id??null;(i||t)&&(r.activeTriggerId=i,r.activeTriggerElement=n.trigger??null),this.update(r)}}function Bv(e={}){return{...Zp(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function $v(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:r,onOpenChangeComplete:i,disablePointerDismissal:o=!1,modal:a=!0,actionsRef:l,handle:c,triggerId:u,defaultTriggerId:d=null}=e,f=Vt(!0),m=!!f,p=Dn(()=>c?.store??new Ov({open:n??s,activeTriggerId:u!==void 0?u:d,modal:a,disablePointerDismissal:o,nested:m})).current;p.useControlledProp("open",n,s),p.useControlledProp("activeTriggerId",u,d),p.useSyncedValues({disablePointerDismissal:o,nested:m,modal:a}),p.useContextCallback("onOpenChange",r),p.useContextCallback("onOpenChangeComplete",i);const y=p.useState("payload");Fv({store:p,actionsRef:l,parentContext:f?.store.context});const b=h.useMemo(()=>({store:p}),[p]);return g.jsx(md.Provider,{value:b,children:typeof t=="function"?t({payload:y}):t})}let Sl=(function(e){return e[e.open=Ze.open]="open",e[e.closed=Ze.closed]="closed",e[e.startingStyle=Ze.startingStyle]="startingStyle",e[e.endingStyle=Ze.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Uv={...Ti,...ki,nested(e){return e?{[Sl.nested]:""}:null},nestedDialogOpen(e){return e?{[Sl.nestedDialogOpen]:""}:null}},Wv=h.forwardRef(function(t,n){const{className:s,render:r,children:i,...o}=t,a=gd(),{store:l}=Vt(),c=l.useState("open"),u=l.useState("nested"),d=l.useState("transitionStatus"),f=l.useState("nestedOpenDialogCount"),m=l.useState("mounted"),p=f>0,y=h.useMemo(()=>({open:c,nested:u,transitionStatus:d,nestedDialogOpen:p}),[c,u,d,p]);return nn("div",t,{enabled:a||m,state:y,ref:[n,l.useStateSetter("viewportElement")],stateAttributesMapping:Uv,props:[{role:"presentation",hidden:!m,children:i},o]})}),Kv=h.forwardRef(function(t,n){const{render:s,className:r,id:i,...o}=t,{store:a}=Vt(),l=ih(i);return a.useSyncedValueWithCleanup("titleElementId",l),nn("h2",t,{ref:n,props:[{id:l},o]})});function kl(e){if(!Number.isFinite(e))return P("shared.placeholder.short");const t=xi(e.toFixed(6));return t==="-"?P("shared.placeholder.short"):t}function Hv(e){return!Number.isFinite(e)||e<=0?null:e<.01?"<$0.01":xi(e.toFixed(2))}const Gv=oh.memo(function({isOpen:t,onClose:n,fleetData:s=[]}){if(!t)return null;const r=P("shared.unit.percent"),i=(Array.isArray(s)?s:[]).map(l=>{const c=Ue(l?.usd),u=Number.isFinite(c)?c:0,d=Array.isArray(l?.models)?l.models:[];return{label:l?.label?String(l.label):"",usdValue:u,usdLabel:kl(u),models:d.map(f=>{const m=Ue(f?.share),p=Number.isFinite(m)?`${m}${r}`:P("shared.placeholder.short"),y=Ue(f?.cost),b=Hv(y);return{id:f?.id?String(f.id):"",name:f?.name?String(f.name):"",shareLabel:p,costLabel:b}})}}),o=i.reduce((l,c)=>l+c.usdValue,0),a=kl(o);return g.jsx($v,{open:t,onOpenChange:l=>{l||n?.()},children:g.jsxs(Iv,{children:[g.jsx(Dv,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),g.jsx(Wv,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:g.jsxs(Vv,{className:"cost-modal-popup w-full max-w-xl rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-oai-lg overflow-hidden",children:[g.jsxs("div",{className:"px-6 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 flex items-center justify-between",children:[g.jsx(Kv,{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:P("dashboard.cost_breakdown.title")}),g.jsx(wl,{type:"button",className:"w-7 h-7 flex items-center justify-center rounded-md text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors","aria-label":P("dashboard.cost_breakdown.close"),children:"✕"})]}),g.jsxs("div",{className:"px-6 py-6 text-center border-b border-oai-gray-100 dark:border-oai-gray-800",children:[g.jsx("div",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 uppercase tracking-wide mb-2",children:P("dashboard.cost_breakdown.total_label")}),g.jsx("div",{className:"text-3xl font-bold text-oai-brand tabular-nums tracking-tight",children:a})]}),g.jsx("div",{className:"px-6 py-4 max-h-[45vh] overflow-y-auto oai-scrollbar",children:g.jsx("div",{className:"space-y-5",children:i.map((l,c)=>g.jsxs("div",{children:[g.jsxs("div",{className:"flex justify-between items-baseline pb-2 mb-2 border-b border-oai-gray-100 dark:border-oai-gray-800",children:[g.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:l.label}),g.jsx("span",{className:"text-sm font-semibold text-oai-brand tabular-nums",children:l.usdLabel})]}),g.jsx("div",{className:"space-y-1",children:l.models.map((u,d)=>{const f=u?.id||`${u.name}-${d}`;return g.jsxs("div",{className:"flex justify-between items-center py-1 text-xs",children:[g.jsxs("span",{className:"text-oai-gray-600 dark:text-oai-gray-300",children:[u.name,g.jsx("span",{className:"ml-1.5 text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:u.shareLabel})]}),u.costLabel?g.jsx("span",{className:"text-oai-gray-600 dark:text-oai-gray-300 font-medium tabular-nums",children:u.costLabel}):null]},f)})})]},`${l.label}-${c}`))})}),g.jsxs("div",{className:"px-6 py-4 border-t border-oai-gray-200 dark:border-oai-gray-800 flex justify-between items-center",children:[g.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500",children:P("dashboard.cost_breakdown.footer")}),g.jsx(wl,{render:g.jsx(to,{variant:"secondary",size:"sm"}),children:P("dashboard.cost_breakdown.close")})]})]})})]})})});function Yv({projectEntries:e=[],projectLimit:t=3,onProjectLimitChange:n,copy:s,hasDetailsActual:r,dailyEmptyPrefix:i,installSyncCmd:o,dailyEmptySuffix:a,detailsColumns:l,ariaSortFor:c,toggleSort:u,sortIconFor:d,pagedDetails:f,dailyBreakdownRows:m=[],dailyBreakdownColumns:p=[],dailyBreakdownAriaSortFor:y,dailyBreakdownSortIconFor:b,dailyBreakdownDateKey:x="day",detailsDateKey:w,renderDetailDate:v,renderDailyBreakdownDate:T,renderDetailCell:S,DETAILS_PAGED_PERIODS:R,period:N,detailsPageCount:C,detailsPage:I,setDetailsPage:A}){const[M,U]=h.useState("daily");return g.jsxs($s,{children:[g.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[g.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[g.jsx("button",{role:"tab","aria-selected":M==="daily",type:"button",onClick:()=>U("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${M==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:s("dashboard.daily.title")}),g.jsx("button",{role:"tab","aria-selected":M==="projects",type:"button",onClick:()=>U("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${M==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:s("dashboard.projects.title")})]}),M==="projects"&&g.jsxs("select",{"aria-label":"Number of projects to display",value:t,onChange:L=>n?.(Number(L.target.value)),className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded px-2 py-1 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 focus:border-oai-brand dark:focus:border-oai-brand focus:outline-none transition-colors",children:[g.jsx("option",{value:3,children:s("dashboard.projects.limit_top_3")}),g.jsx("option",{value:6,children:s("dashboard.projects.limit_top_6")}),g.jsx("option",{value:10,children:s("dashboard.projects.limit_top_10")})]})]}),M==="projects"&&g.jsx("div",{className:"space-y-1",children:e.slice(0,t).map(L=>g.jsxs("a",{href:L?.project_ref||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-2 rounded-lg hover:oai-bg-elevated transition-colors",children:[g.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300",children:(L?.project_key?.[0]||"?").toUpperCase()}),g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:L?.project_key||L?.project_ref?.split("/")?.pop()||"—"})}),g.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:L?.billable_total_tokens?.toLocaleString?.()||L?.total_tokens?.toLocaleString?.()||"—"})]},L?.project_key||L?.project_ref))}),M==="daily"&&g.jsxs("div",{children:[m?.length===0?g.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[i,g.jsx("code",{className:"mx-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 font-mono oai-text-caption",children:o}),a]}):g.jsx("div",{className:"overflow-auto max-h-[320px] -mx-4 oai-scrollbar",children:g.jsxs("table",{className:"w-full border-collapse",children:[g.jsx("thead",{className:"sticky top-0 z-10",children:g.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.map(L=>g.jsx("th",{"aria-sort":y?.(L.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:g.jsx("button",{type:"button",onClick:()=>u(L.key),className:"flex w-full items-center justify-start px-4 py-2 text-left oai-text-caption font-semibold text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white transition-colors",children:g.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.jsx("span",{children:L.label}),g.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:b?.(L.key)||""})]})})},L.key))})}),g.jsx("tbody",{children:m.map(L=>g.jsxs("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 hover:bg-oai-gray-50/50 dark:hover:bg-oai-gray-800/50 transition-colors ${L.missing?"text-oai-gray-400 dark:text-oai-gray-400":L.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[g.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:T?T(L):v(L)}),g.jsx("td",{className:"px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:S(L,"total_tokens")}),g.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:S(L,"input_tokens")}),g.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:S(L,"output_tokens")}),g.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:S(L,"cached_input_tokens")}),g.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:S(L,"reasoning_output_tokens")}),g.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:S(L,"conversation_count")})]},String(L?.[x]||L?.day||L?.hour||L?.month||"")))})]})}),M!=="daily"&&R.has(N)&&C>1?g.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[g.jsx("button",{type:"button",onClick:()=>A(L=>Math.max(0,L-1)),disabled:I===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:s("details.pagination.prev")}),g.jsxs("span",{className:"oai-text-muted",children:[I+1," / ",C]}),g.jsx("button",{type:"button",onClick:()=>A(L=>Math.min(C-1,L+1)),disabled:I+1>=C,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:s("details.pagination.next")})]}):null]})]})}function Yt({children:e,delay:t=0,duration:n=.4,y:s=20,className:r="",once:i=!0}){return _n()?g.jsx("div",{className:r,children:e}):g.jsx(_e.div,{initial:{opacity:0,y:s},animate:{opacity:1,y:0},transition:{duration:n,delay:t,ease:[.25,.1,.25,1]},className:r,children:e})}function ms(e){return typeof e!="string"?"":e.trim()}function Tl(e){const t=ms(e);return t?t.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function zv(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!n||typeof n!="object")continue;const s=ms(n.tool),r=ms(n.planType)||ms(n.plan_type);if(!s||!r)continue;const i=Tl(s)||s,o=Tl(r)||r;t.set(`${s.toLowerCase()}::${r.toLowerCase()}`,{tool:i,plan:o})}return Array.from(t.values())}function qv({period:e="month",rankLabel:t,streakDays:n,subscriptions:s=[],periodConversations:r,rolling:i,topModels:o=[],className:a=""}){const l=P("shared.placeholder.short"),c=P("shared.unit.percent"),u=t??P("identity_card.rank_placeholder"),d=Number.isFinite(Number(n))?Number(n):0,f=d?P("identity_card.streak_value",{days:d}):P("identity_card.rank_placeholder"),m=zv(s),p={thousandSuffix:P("shared.unit.thousand_abbrev"),millionSuffix:P("shared.unit.million_abbrev"),billionSuffix:P("shared.unit.billion_abbrev")},y=w=>{if(w==null)return l;const v=Vl(w,p);return v==="-"?l:v},b=(()=>{switch(e){case"day":return"today convs";case"week":return"week convs";case"month":return"month convs";case"total":return"all convs";default:return"convs"}})(),x=o.slice(0,3);return g.jsx(Yt,{delay:.1,children:g.jsxs($s,{className:`h-full ${a}`,children:[g.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[g.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[g.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(i?.last_7d?.totals?.billable_total_tokens)}),g.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:"7d"})]}),g.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[g.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(i?.last_30d?.totals?.billable_total_tokens)}),g.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:"30d"})]}),g.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[g.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(i?.last_30d?.avg_per_active_day)}),g.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:"avg"})]}),g.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[g.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(r)}),g.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:b})]})]}),x.length>0&&g.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:x.map((w,v)=>{const T=w?.name?String(w.name):l,S=w?.percent?String(w.percent):"",R=v===x.length-1,N=v+1;return g.jsxs("div",{className:`flex items-center py-2 ${R?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[g.jsx("span",{className:"w-5 h-5 flex items-center justify-center rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 text-[10px] font-semibold text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0",children:N}),g.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:T,children:T}),g.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[S,c]})]},w.id||T)})}),m.length>0&&g.jsx("div",{className:"mt-3 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex flex-wrap gap-1.5",children:m.map((w,v)=>g.jsxs(wv,{variant:"secondary",size:"sm",children:[w.tool," ",w.plan]},`${w.tool}:${w.plan}:${v}`))}),g.jsxs("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx("span",{children:P("identity_card.rank_label")}),g.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:u})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("span",{children:P("identity_card.streak_label")}),g.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:f})]})]})]})})}function Xv(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{key:t,label:t.toUpperCase()}:{key:t.key,label:t.label||String(t.key).toUpperCase()}):[]}function Zv(e){if(typeof e!="string")return null;const t=e.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!t)return null;const n=Number(t[0]);return Number.isFinite(n)?n:null}const Jv={CODEX:"#10b981",CLAUDE:"#8b5cf6",OPENCODE:"#f59e0b",GEMINI:"#3b82f6"};function Fr(e,t){const n=e?.toUpperCase?.()||"";return Jv[n]||`hsl(${150+t*40}, 60%, 45%)`}function Qv({loading:e,onClick:t}){const n=_n();return g.jsx(to,{variant:"secondary",size:"sm",disabled:e,onClick:t,"aria-label":"Refresh data",className:"w-8 p-0",children:g.jsx(_e.span,{"aria-hidden":"true",animate:e?{rotate:360}:{rotate:0},transition:e&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function ew({period:e,periods:t,onPeriodChange:n,summaryValue:s,summaryLabel:r,summaryCostValue:i,onCostInfo:o,fleetData:a=[],onRefresh:l,loading:c,className:u=""}){const d=Xv(t),f=Zv(String(s??"")),m=f!=null,[p,y]=h.useState(null),{resolvedTheme:b}=wi(),x=b==="dark",w=x?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",v=x?"rgba(10,10,10,0)":"rgba(255,255,255,0)",T=a.filter(S=>S.models?.length>0);return g.jsx(Yt,{delay:.2,children:g.jsxs($s,{className:u,children:[g.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[g.jsx("div",{role:"tablist","aria-label":"Time period",className:"flex gap-1",children:d.map(S=>g.jsx("button",{role:"tab","aria-selected":e===S.key,type:"button",className:`text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${e===S.key?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800"}`,onClick:()=>n?.(S.key),children:S.label},S.key))}),l&&g.jsx(Qv,{loading:c,onClick:l})]}),g.jsxs("div",{className:"text-center mb-8",children:[g.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:r}),g.jsx("div",{className:"text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:m?g.jsx(Rv,{value:f,displayValue:s,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:x?0:8,gradientFrom:w,gradientTo:v,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):s}),i&&g.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:o?g.jsxs("button",{type:"button",onClick:o,className:"inline-flex items-center gap-1.5 text-xl font-bold text-oai-brand hover:text-oai-brand-dark dark:hover:text-oai-brand-light transition-colors cursor-pointer","aria-label":"View cost breakdown",children:[i,g.jsx(Lh,{size:16,strokeWidth:2,className:"text-oai-gray-400 dark:text-oai-gray-500"})]}):g.jsx("span",{className:"text-xl font-bold text-oai-brand",children:i})})]}),T.length>0&&g.jsxs("div",{className:"space-y-6",children:[g.jsx("div",{role:"img","aria-label":`Provider distribution: ${T.map(S=>`${S.label} ${S.totalPercent}%`).join(", ")}`,className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:T.map((S,R)=>{const N=Fr(S.label,R);return g.jsx(_e.div,{initial:{width:0},animate:{width:`${S.totalPercent}%`},transition:{duration:.6,delay:.3+R*.1},className:"h-full",style:{backgroundColor:N},title:`${S.label}: ${S.totalPercent}%`},S.label)})}),g.jsx("div",{className:"flex flex-wrap gap-3",children:T.map((S,R)=>{const N=Fr(S.label,R),C=p===S.label;return g.jsxs("button",{"aria-expanded":C,"aria-controls":`provider-details-${S.label}`,"aria-label":`${S.label}: ${S.totalPercent}%. Click to ${C?"collapse":"expand"} details`,onClick:()=>y(C?null:S.label),className:`flex-1 min-w-[140px] text-left p-3 rounded-lg border transition-colors duration-200 ${C?"border-oai-gray-300 dark:border-oai-gray-600 bg-oai-gray-50 dark:bg-oai-gray-800":"border-oai-gray-200 dark:border-oai-gray-700 hover:border-oai-gray-300 dark:hover:border-oai-gray-600"}`,children:[g.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N}}),g.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:S.label})]}),g.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[S.totalPercent,"%"]}),g.jsxs("div",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:[S.models.length," models"]})]},S.label)})}),p&&g.jsx("div",{id:`provider-details-${p}`,role:"region","aria-label":`${p} model details`,className:"border border-oai-gray-200 dark:border-oai-gray-700 rounded-lg p-4 bg-oai-gray-50/30 dark:bg-oai-gray-800/30 overflow-hidden",children:T.filter(S=>S.label===p).map(S=>{const R=Fr(S.label,0),N=[...S.models].sort((C,I)=>(I.share||0)-(C.share||0));return g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:R}}),g.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:S.label}),g.jsxs("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[S.totalPercent,"%"]})]}),g.jsx("div",{className:"space-y-2",children:N.map(C=>g.jsx("div",{className:"flex items-center gap-3",children:g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[g.jsx("span",{className:"text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",children:C.name}),g.jsxs("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white tabular-nums shrink-0",children:[C.share,"%"]})]}),g.jsx("div",{className:"h-1 bg-oai-gray-200 dark:bg-oai-gray-700 rounded-full overflow-hidden",children:g.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${C.share}%`,backgroundColor:R,opacity:.7}})})]})},C.id||C.name))})]},S.label)})})]})]})})}function Cl(e,t){if(!Array.isArray(e)||e.length===0)return 0;if(e.length===1)return e[0];const n=(e.length-1)*t,s=Math.floor(n),r=Math.ceil(n);if(s===r)return e[s];const i=n-s;return e[s]+(e[r]-e[s])*i}function tw(e){const t=Array.isArray(e)?e.filter(r=>Number.isFinite(r)&&r>0).sort((r,i)=>r-i):[];if(t.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(e)?e.map(()=>0):[]};const n=t.at(-1)??0;let s=n;if(t.length>=4){const r=Cl(t,.25),i=Cl(t,.75),o=Math.max(i-r,0),a=i+o*1.5;n>a&&(s=Math.max(a,i,1))}return{rawMax:n,effectiveMax:Math.max(s,1),clippedValues:Array.isArray(e)?e.map(r=>!Number.isFinite(r)||r<=0?0:Math.min(r,Math.max(s,1))):[]}}function nw({value:e,displayValue:t,scale:n,index:s,row:r,totalBars:i}){const o=_n(),a=n.effectiveMax>0?t/n.effectiveMax*100:0,l=`${Math.max(a,2)}%`,c=r?.missing,u=r?.future,d=i<=7?"6px":i<=14?"4px":"3px";return g.jsx(_e.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:o?0:.3,delay:o?0:s*.02,ease:[.25,.1,.25,1]},style:{originY:1},children:g.jsxs("div",{className:"absolute inset-x-0 bottom-0",style:{height:l},children:[g.jsx("div",{"data-trend-bar":"true",className:"h-full w-full cursor-pointer transition-all duration-200 group-hover:brightness-110",style:{minHeight:e>0?"4px":"2px",opacity:c||u?.2:1,borderRadius:`${d} ${d} 0 0`,background:e>0?"#10b981":"var(--oai-gray-100)"},title:`${e.toLocaleString()}`}),g.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-oai-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-20",children:e.toLocaleString()})]})})}function sw({rows:e,from:t,to:n,period:s,timeZoneLabel:r,showTimeZoneLabel:i=!0,className:o=""}){const a=Array.isArray(e)&&e.length?e:[],l=a.map(u=>{if(u?.missing||u?.future)return 0;const d=u?.billable_total_tokens??u?.total_tokens??u?.value;if(d==null)return 0;const f=Number(d);return Number.isFinite(f)?f:0}),c=tw(l);return g.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 ${o}`,children:[g.jsxs("div",{className:"mb-3",children:[g.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:P("trend.monitor.label")}),i&&r&&g.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:r})]}),g.jsxs("div",{className:"space-y-3",children:[g.jsxs("div",{className:"relative",children:[g.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(u=>g.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-u}%`}},u))}),g.jsx("div",{className:"h-40 flex items-end gap-1 relative z-0",children:l.length>0?l.map((u,d)=>g.jsx(nw,{value:u,displayValue:c.clippedValues[d]??0,scale:c,index:d,row:a[d],totalBars:l.length},d)):g.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:g.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]}),t&&n&&g.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[g.jsx("span",{children:t}),g.jsx("span",{children:n})]})]})]})}function rw(e){const{copy:t,screenshotMode:n,publicViewInvalid:s,publicViewInvalidTitle:r,publicViewInvalidBody:i,showExpiredGate:o,showAuthGate:a,screenshotTitleLine1:l,screenshotTitleLine2:c,identityDisplayName:u,identityStartDate:d,activeDays:f,identitySubscriptions:m,identityScrambleDurationMs:p,projectUsageEntries:y,projectUsageLimit:b,setProjectUsageLimit:x,topModels:w,signedIn:v,publicMode:T,shouldShowInstall:S,installPrompt:R,handleCopyInstall:N,installCopied:C,installInitCmdDisplay:I,publicViewTitle:A,handleTogglePublicView:M,publicViewBusy:U,publicViewEnabled:L,publicViewCopyButtonLabel:$,handleCopyPublicView:j,trendRowsForDisplay:W,trendFromForDisplay:pe,trendToForDisplay:D,period:_,trendTimeZoneLabel:z,activityHeatmapBlock:X,isCapturing:se,handleShareToX:H,screenshotTwitterButton:Q,screenshotTwitterHint:ee,periodsForDisplay:de,setSelectedPeriod:be,summaryLabel:Ne,summaryValue:Be,summaryCostValue:Qe,summaryConversationsValue:et,rollingUsage:E,costInfoEnabled:te,openCostModal:G,costModalOpen:xe,closeCostModal:V,allowBreakdownToggle:J,refreshAll:Z,usageLoadingState:ne,fleetData:ce,hasDetailsActual:K,dailyEmptyPrefix:Y,installSyncCmd:Ee,dailyEmptySuffix:he,detailsColumns:je,ariaSortFor:Le,toggleSort:ct,sortIconFor:ve,pagedDetails:re,dailyBreakdownRows:Re,dailyBreakdownColumns:Ie,dailyBreakdownAriaSortFor:Us,dailyBreakdownSortIconFor:Ws,dailyBreakdownDateKey:le,detailsDateKey:On,renderDetailDate:tt,renderDailyBreakdownDate:nt,renderDetailCell:Bn,DETAILS_PAGED_PERIODS:ln,detailsPageCount:Ks,detailsPage:Hs,setDetailsPage:Gs}=e;return g.jsxs(g.Fragment,{children:[g.jsxs(vv,{hideHeader:n,header:null,footer:n?null:null,className:n?"screenshot-mode":"",children:[s?g.jsx("div",{className:"mb-6",children:g.jsx($s,{title:r,className:"border-oai-gray-200 dark:border-oai-gray-800",children:g.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-0",children:i})})}):null,o||a?null:g.jsx(g.Fragment,{children:g.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[g.jsxs("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0",children:[n?g.jsx("div",{className:"flex items-start justify-between gap-4",children:g.jsxs("div",{className:"flex flex-col gap-1",children:[g.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:l}),g.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:c})]})}):null,g.jsx(qv,{title:t("dashboard.identity.title"),subtitle:t("dashboard.identity.subtitle"),period:_,rankLabel:d??t("identity_card.rank_placeholder"),streakDays:f,subscriptions:m,periodConversations:et,rolling:E,topModels:w}),S?g.jsx(Yt,{delay:.25,children:g.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3",children:[g.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:R}),g.jsxs(_e.button,{onClick:N,whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full flex items-center justify-between px-3 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 rounded-lg transition-colors",children:[g.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:I}),g.jsx(_e.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:C?"Copied ✓":"Copy"},C?"copied":"copy")]})]})}):null,!n&&v&&!T?g.jsx(Yt,{delay:.3,children:g.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3 flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(_e.button,{type:"button",onClick:M,disabled:U,whileTap:{scale:.95},className:`relative inline-flex h-4 w-7 items-center px-0.5 transition-colors rounded-full ${L?"bg-oai-brand":"bg-oai-gray-300 dark:bg-oai-gray-600"} disabled:opacity-50`,children:g.jsx(_e.span,{initial:!1,animate:{x:L?12:0},transition:{type:"spring",stiffness:500,damping:30},className:"inline-block h-3 w-3 bg-white rounded-full"})}),g.jsx(_e.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:L?"Public":"Private"},L?"public":"private")]}),g.jsx(_e.button,{onClick:j,disabled:!L||U,whileHover:{scale:L?1.05:1},whileTap:{scale:L?.95:1},className:"text-xs text-oai-brand hover:text-oai-brand-dark disabled:text-oai-gray-300 dark:disabled:text-oai-gray-600 transition-colors",children:$})]})}):null,X&&g.jsx(Yt,{delay:.4,children:X}),n?null:g.jsx(sw,{rows:W,from:pe,to:D,period:_,timeZoneLabel:z,showTimeZoneLabel:!1}),n?g.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2","data-screenshot-exclude":"true",style:se?{display:"none"}:void 0,children:[g.jsx(to,{type:"button",onClick:H,variant:"primary",size:"lg",disabled:se,children:Q}),g.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300",children:ee})]}):null]}),g.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0",children:[g.jsx(ew,{period:_,periods:de,onPeriodChange:be,summaryLabel:Ne,summaryValue:Be,summaryCostValue:Qe,onCostInfo:te?G:null,fleetData:ce,onRefresh:n?null:Z,loading:ne}),n?null:g.jsx(Yt,{delay:.5,children:g.jsx(Yv,{projectEntries:y,projectLimit:b,onProjectLimitChange:x,copy:t,hasDetailsActual:K,dailyEmptyPrefix:Y,installSyncCmd:Ee,dailyEmptySuffix:he,detailsColumns:je,ariaSortFor:Le,toggleSort:ct,sortIconFor:ve,pagedDetails:re,dailyBreakdownRows:Re,dailyBreakdownColumns:Ie,dailyBreakdownAriaSortFor:Us,dailyBreakdownSortIconFor:Ws,dailyBreakdownDateKey:le,detailsDateKey:On,renderDetailDate:tt,renderDailyBreakdownDate:nt,renderDetailCell:Bn,DETAILS_PAGED_PERIODS:ln,period:_,detailsPageCount:Ks,detailsPage:Hs,setDetailsPage:Gs})})]})]})})]}),g.jsx(Gv,{isOpen:xe,onClose:V,fleetData:ce})]})}const iw=["day","week","month","total"],_r=new Set(["day","hour","month"]),pn=new Set(["day","total"]);function Or(e,t){if(typeof t=="number"&&t>0)return!0;if(typeof e=="bigint")return e>0n;if(typeof e=="number")return Number.isFinite(e)&&e>0;if(typeof e=="string"){const n=e.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const s=Number(n);return Number.isFinite(s)&&s>0}return!1}function is(e){return e?e?.billable_total_tokens??e?.total_tokens:null}function El(e){return e?e?.billable_total_tokens??e?.value??e?.total_tokens:null}function ow(e){if(typeof e!="string"||!e)return null;const t=e.split("-");if(t.length!==3)return null;const n=Number(t[0]),s=Number(t[1])-1,r=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(r))return null;const i=new Date(Date.UTC(n,s,r));return Number.isFinite(i.getTime())?i:null}function aw(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function lw(e){return e?e==="www.tokentracker.cc":!1}function cw(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search),t=String(e.get("force_install")||"").toLowerCase();return t!=="1"&&t!=="true"?!1:!lw(window.location.hostname)}function pw({baseUrl:e,auth:t,signedIn:n,sessionSoftExpired:s,signOut:r,publicMode:i=!1,publicToken:o=null,signInUrl:a="/sign-in",signUpUrl:l="/sign-up"}){const[c,u]=h.useState(!1),[d,f]=h.useState(null),[m,p]=h.useState(null),[y,b]=h.useState(!1),[x,w]=h.useState(null),[v,T]=h.useState(0),[S,R]=h.useState(0),[N,C]=h.useState(!1),[I,A]=h.useState(null),[M,U]=h.useState(!1),[L,$]=h.useState(!1),[j,W]=h.useState(!1),[pe,D]=h.useState(null),[_,z]=h.useState(null),[X,se]=h.useState(null),[H,Q]=h.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),ee=h.useMemo(()=>typeof window>"u"?!1:ah(window.location.search),[]),de=h.useMemo(()=>cw(),[]),[be,Ne]=h.useState(!1),Be=2200,[Qe,et]=h.useState(!0),[E,te]=h.useState(!1),[G,xe]=h.useState(!1),[V,J]=h.useState(!1),Z=en(),ne=n&&!s,ce=h.useMemo(()=>ne&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,ne]),K=ne?ce:null,Y=i?lh(o):K,Ee=n||Z||i,he=ne&&tn(K),je=n&&s&&!i;h.useEffect(()=>{if(!n||Z){f(null),p(null),b(!1),w(null);return}if(i)return;if(!he){f(null),p(null),b(!1),w(null);return}let k=!0;const O=()=>{f(null),p(null),b(!1),w(null)};return b(!0),w(null),(async()=>{let F=null;try{F=await ot(K)}catch{F=null}if(k){if(!F){O();return}try{const q=await Sh({baseUrl:e,accessToken:F});if(!k)return;f(typeof q?.link_code=="string"?q.link_code:null),p(typeof q?.expires_at=="string"?q.expires_at:null)}catch(q){if(!k)return;f(null),p(null),w(q?.message||"Failed to load link code")}finally{if(!k)return;b(!1)}}})(),()=>{k=!1}},[e,Z,n,i,he,K,S]),h.useEffect(()=>{if(!n||Z||i){C(!1),A(null),U(!1),$(!1),W(!1);return}if(!he){C(!1),A(null),U(!1),$(!1),W(!1);return}let k=!0;return U(!0),(async()=>{let O=null;try{O=await ot(K)}catch{O=null}if(k){if(!O){C(!1),A(null),U(!1);return}try{const F=await Vo({baseUrl:e,accessToken:O});if(!k)return;const q=!!F?.enabled;C(q),A(F?.share_token||null)}catch{if(!k)return;C(!1),A(null)}finally{if(!k)return;U(!1)}}})(),()=>{k=!1}},[e,Z,n,i,he,K]),h.useEffect(()=>{if(!i){D(null),z(null);return}if(!o){D(null),z(null);return}D(null),z(null);let k=!0;return kh({baseUrl:e,accessToken:o}).then(O=>{k&&(D(typeof O?.display_name=="string"?O.display_name:null),z(typeof O?.avatar_url=="string"?O.avatar_url:null))}).catch(()=>{k&&(D(null),z(null))}),()=>{k=!1}},[e,i,o]);const Le=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");h.useEffect(()=>{if(!Le&&(!n||Z||i)){se(null);return}if(!Le&&!he){se(null);return}let k=!0;return(async()=>{let O=null;try{O=await ot(K)}catch{O=null}if(k){if(!O&&!Le){se(null);return}try{const F=await Th({baseUrl:e,accessToken:O});if(!k)return;se(F&&typeof F=="object"?F:null)}catch{if(!k)return;se(null)}}})(),()=>{k=!1}},[he,e,K,Z,i,n]);const ct=h.useMemo(()=>{if(!m)return!1;const k=Date.parse(m);if(!Number.isFinite(k))return!1;const O=v||Date.now();return k<=O},[m,v]);h.useEffect(()=>{!n||Z||i||!m||!ct||y||(f(null),p(null),w(null),R(k=>k+1))},[ct,m,y,Z,n]),h.useEffect(()=>{if(!m||i)return;const k=Date.parse(m);if(!Number.isFinite(k))return;const O=Date.now();if(T(O),k<=O)return;const F=window.setTimeout(()=>T(Date.now()),k-O),q=()=>{typeof document>"u"||document.visibilityState==="visible"&&T(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",q),window.addEventListener("focus",q),()=>{window.clearTimeout(F),typeof document<"u"&&document.removeEventListener("visibilitychange",q),window.removeEventListener("focus",q)}},[m]),h.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const k=window.matchMedia("(max-width: 640px)"),O=()=>Q(k.matches);return O(),k.addEventListener?(k.addEventListener("change",O),()=>k.removeEventListener("change",O)):(k.addListener(O),()=>k.removeListener(O))},[]);const ve=h.useMemo(()=>ch(),[]),re=h.useMemo(()=>uh(),[]),Re=h.useMemo(()=>dh(),[]),Ie=i?null:t?.userId||t?.email||"default",[Us,Ws]=h.useState("month"),le=ee?"total":Us,On=h.useMemo(()=>fh(le,{timeZone:ve,offsetMinutes:re,now:Re}),[Re,le,ve,re]),tt=On.from,nt=On.to,Bn=h.useMemo(()=>hh({timeZone:ve,offsetMinutes:re}),[ve,re]),ln=h.useMemo(()=>mh({timeZone:ve,offsetMinutes:re}),[ve,re]),Ks=h.useMemo(()=>`Local time (${ln})`,[ln]),Hs=ve,Gs=re,no=Bn,It=h.useMemo(()=>pi({timeZone:ve,offsetMinutes:re,date:Re||new Date}),[Re,ve,re]),so=h.useMemo(()=>{const k=ow(It)||new Date,O=aw(k,-29);return{from:Xt(O),to:Xt(k)}},[It]),{daily:yt,summary:Fe,rolling:yd,source:ro,loading:bd,error:Ke,refresh:io}=$o({baseUrl:e,accessToken:Y,guestAllowed:je,from:tt,to:nt,includeDaily:le!=="total",cacheKey:Ie,timeZone:ve,tzOffsetMinutes:re,now:Re}),{daily:oo,loading:xd,refresh:ao}=$o({baseUrl:e,accessToken:Y,guestAllowed:je,from:so.from,to:so.to,includeDaily:!0,cacheKey:Ie?`${Ie}.daily-breakdown`:"daily-breakdown",timeZone:ve,tzOffsetMinutes:re,now:Re}),{breakdown:kt,loading:vd,refresh:lo}=Tm({baseUrl:e,accessToken:Y,guestAllowed:je,from:tt,to:nt,cacheKey:Ie,timeZone:ve,tzOffsetMinutes:re}),[co,wd]=h.useState(3),{entries:Sd,loading:kd,refresh:uo}=pm({baseUrl:e,accessToken:Y,limit:co,from:tt,to:nt,timeZone:ve,tzOffsetMinutes:re}),fo=le==="week"||le==="month",$n=le==="week"||le==="month",ho=h.useMemo(()=>yt.filter(k=>k?.future?!1:!k?.day||!It?!0:String(k.day)<=String(It)),[yt,It]),{rows:ut,from:Td,to:Cd,loading:Ed,refresh:mo}=ym({baseUrl:e,accessToken:Y,guestAllowed:je,period:le,from:tt,to:nt,months:24,cacheKey:Ie,timeZone:Hs,tzOffsetMinutes:Gs,now:Re,sharedRows:fo?yt:null,sharedRange:fo?{from:tt,to:nt}:null}),{daily:Ft,heatmap:dt,loading:po,refresh:go}=mm({baseUrl:e,accessToken:Y,guestAllowed:je,weeks:52,cacheKey:Ie,timeZone:ve,tzOffsetMinutes:re,now:Re}),He=h.useMemo(()=>le==="day"?"hour":le==="total"?"month":"day",[le]),Ad=h.useMemo(()=>Wo(He),[He]),Un="day",Pd=h.useMemo(()=>Wo(Un),[]),[Ge,yo]=h.useState(()=>({key:"day",dir:"desc"}));h.useEffect(()=>{yo(k=>!_r.has(k.key)||k.key===He?k:{key:He,dir:k.dir})},[He]);const _t=h.useMemo(()=>_r.has(Ge.key)&&Ge.key!==He?{...Ge,key:He}:Ge,[He,Ge]),Wn=h.useMemo(()=>{if(le==="day")return Array.isArray(ut)?ut.filter(F=>F?.hour&&!F?.future):[];if(le==="total"){const F=Array.isArray(ut)?ut.filter(q=>q?.month&&!q?.future):[];return Fm(F)}const k=ho;return!k.some(F=>!F?.missing&&!F?.future)&&yt.length>0?yt.filter(F=>!F?.future).slice(-30).filter(F=>F?.day):k},[le,ut,ho,yt]),cn=h.useMemo(()=>Ko(Wn,_t),[Wn,_t]),Rd=h.useMemo(()=>Wn.some(k=>!k?.missing&&!k?.future),[Wn]),Ys=h.useMemo(()=>{if(!pn.has(le))return 1;const k=Math.ceil(cn.length/vs);return k>0?k:1},[le,cn.length]),[zs,Kn]=h.useState(0);h.useEffect(()=>{if(!pn.has(le)){Kn(0);return}Kn(k=>Math.min(k,Ys-1))},[Ys,le]),h.useEffect(()=>{pn.has(le)&&Kn(0)},[le,Ge.dir,Ge.key]);const Md=h.useMemo(()=>pn.has(le)?_m(cn,zs,vs):cn,[zs,le,cn]),bo=h.useMemo(()=>oo.filter(k=>!k?.future&&k?.day).slice(-30),[oo]),Ot=h.useMemo(()=>_r.has(Ge.key)?{...Ge,key:Un}:Ge,[Ge]),Dd=h.useMemo(()=>Ko(bo,Ot),[bo,Ot]),Nd=h.useMemo(()=>$n?yt:le==="day"?Array.isArray(ut)?ut.filter(k=>k?.hour):[]:ut,[yt,le,ut,$n]),jd=$n?tt:Td,Ld=$n?nt:Cd;function Vd(k,O){return k?.future?"—":k?.missing?P("shared.status.unsynced"):O==="total_tokens"?ht(is(k)):ht(k?.[O])}function Id(k){const O=k?.[He];if(O==null)return"";const F=String(O);if(He==="hour"){const[q,me]=F.split("T");if(q&&me)return`${q} ${me.slice(0,5)}`}return F}function Fd(k){const O=k?.[Un];return O==null?"":String(O)}function _d(k){yo(O=>O.key===k?{key:k,dir:O.dir==="asc"?"desc":"asc"}:{key:k,dir:"desc"})}function Od(k){return _t.key!==k?"none":_t.dir==="asc"?"ascending":"descending"}function Bd(k){return _t.key!==k?"":_t.dir==="asc"?"▲":"▼"}function $d(k){return Ot.key!==k?"none":Ot.dir==="asc"?"ascending":"descending"}function Ud(k){return Ot.key!==k?"":Ot.dir==="asc"?"▲":"▼"}const xo=h.useMemo(()=>{if(!n&&!Z&&!i&&!Le)return 0;const k=Number(dt?.active_days);if(Number.isFinite(k))return k;let O=0;const F=new Set,q=(ue,ge,ke)=>{typeof ue!="string"||!ue||F.has(ue)||Or(ge,ke)&&(F.add(ue),O+=1)};if(Array.isArray(Ft))for(const ue of Ft)q(ue?.day,is(ue));const me=Array.isArray(dt?.weeks)?dt.weeks:[];for(const ue of me)for(const ge of Array.isArray(ue)?ue:[]){const ke=El(ge);q(ge?.day,ke,ge?.level)}return O},[n,Z,dt?.active_days,dt?.weeks,Ft]),vo=h.useCallback(async()=>{await Promise.all([io(),go(),mo(),lo(),uo(),ao()])},[ao,go,lo,uo,mo,io]),Wd=h.useCallback(async()=>{J(!0);try{Le&&await Ch(),await vo()}catch(k){console.error("[DashboardPage] Refresh failed:",k)}finally{J(!1)}},[Le,vo]),Kd=V||bd||xd||po||Ed||vd||kd,Hd=h.useMemo(()=>P("shared.data_source",{source:String(ro||"edge").toUpperCase()}),[ro]),Gd=h.useMemo(()=>{if(!i||!Ke)return!1;if((typeof Ke=="object"&&Ke?Ke?.status??Ke?.statusCode:null)===401)return!0;const O=typeof Ke=="string"?Ke:String(Ke?.message||Ke||"");return/unauthorized|invalid|token|revoked|401/i.test(O)},[i,Ke]),Hn=h.useMemo(()=>typeof t?.name!="string"?"":t.name.trim(),[t?.name]),wo=h.useMemo(()=>typeof pe!="string"?"":pe.trim(),[pe]),So=h.useMemo(()=>!Hn||Hn.includes("@")?P("dashboard.identity.fallback"):Hn,[Hn]),ko=h.useMemo(()=>So.replace(/[^a-zA-Z0-9._-]/g,"_"),[So]),Yd=h.useMemo(()=>i?wo||P("dashboard.identity.fallback"):ko,[ko,wo,i]),zd=h.useMemo(()=>{let k=null;const O=q=>{typeof q!="string"||!q||(!k||q<k)&&(k=q)};if(Array.isArray(Ft))for(const q of Ft)q?.day&&Or(is(q))&&O(q.day);const F=Array.isArray(dt?.weeks)?dt.weeks:[];for(const q of F)for(const me of Array.isArray(q)?q:[]){if(!me?.day)continue;const ue=El(me),ge=me?.level;Or(ue,ge)&&O(me.day)}return k},[dt?.weeks,Ft]),qd=h.useMemo(()=>i?[]:(Array.isArray(X?.subscriptions?.items)?X.subscriptions.items:[]).map(F=>{const q=typeof F?.tool=="string"?F.tool.trim():"",ue=(typeof F?.plan_type=="string"?F.plan_type:typeof F?.planType=="string"?F.planType:"").trim();return!q||!ue?null:{tool:q,planType:ue,provider:typeof F?.provider=="string"?F.provider.trim():"",product:typeof F?.product=="string"?F.product.trim():"",rateLimitTier:typeof F?.rate_limit_tier=="string"?F.rate_limit_tier.trim():typeof F?.rateLimitTier=="string"?F.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[i,X]),Xd=g.jsx(Zm,{heatmap:dt,timeZoneLabel:Bn,timeZoneShortLabel:ln,hideLegend:ee,defaultToLatestMonth:ee}),Zd=h.useMemo(()=>`${tt}..${nt}`,[tt,le,nt]),Jd=P("usage.summary.total"),Bt=is(Fe),To=P("shared.unit.thousand_abbrev"),Co=P("shared.unit.million_abbrev"),Eo=P("shared.unit.billion_abbrev"),Gn=Ue(Bt),Ao=H&&Gn!=null&&Math.abs(Gn)>=1e9,Qd=h.useMemo(()=>Ao?Vl(Gn,{thousandSuffix:To,millionSuffix:Co,billionSuffix:Eo,decimals:1}):ht(Bt),[Eo,Co,Bt,Gn,To,Ao]),ef=P("dashboard.core_index.collapse_label"),tf=P("dashboard.core_index.expand_label"),nf=P("dashboard.core_index.collapse_aria"),sf=P("dashboard.core_index.expand_aria"),rf=!ee,of=P("dashboard.screenshot.title_line1"),af=P("dashboard.screenshot.title_line2"),lf=P("dashboard.screenshot.twitter_label"),cf=P("dashboard.screenshot.twitter_button"),uf=P("dashboard.screenshot.twitter_hint"),$t=P("shared.placeholder.short"),qs=h.useMemo(()=>{const k=Array.isArray(kt?.sources)?kt.sources:[];let O=null,F=0;for(const ge of k){const ke=Ue(ge?.totals?.billable_total_tokens??ge?.totals?.total_tokens);!Number.isFinite(ke)||ke<=0||ke>F&&(F=ke,O=ge)}let q=$t,me=$t,ue="0.0";if(O&&F>0){q=O?.source?String(O.source).toUpperCase():$t;const ge=Array.isArray(O?.models)?O.models:[];let ke=0;for(const ft of ge){const dn=Ue(ft?.totals?.billable_total_tokens??ft?.totals?.total_tokens);!Number.isFinite(dn)||dn<=0||dn>ke&&(ke=dn,me=ft?.model?String(ft.model):$t)}ke>0&&(ue=(ke/F*100).toFixed(1))}return{agentName:q,modelName:me,modelPercent:ue}},[kt,$t]),Po=ht(Bt),Ro=P("dashboard.screenshot.twitter_text",{total_tokens:Po==="-"?$t:Po,agent_name:qs.agentName,model_name:qs.modelName,model_percent:qs.modelPercent}),Xs=h.useMemo(()=>{if(typeof window>"u")return"";const k=new URL("https://twitter.com/intent/tweet");return k.searchParams.set("text",Ro),k.toString()},[Ro]),Mo=h.useCallback(async()=>{if(typeof window>"u")return null;const k=async()=>{const ge=performance.now();for(;performance.now()-ge<2e3;){const ke=document.querySelector("[data-heatmap-scroll='true']");if(!ke||ke.dataset.latestMonthReady==="true")return;await new Promise(ft=>requestAnimationFrame(ft))}},O=document.querySelector("#root")||document.body,F=document.documentElement,{scrollWidth:q,scrollHeight:me}=document.documentElement;F?.classList.add("screenshot-capture"),document.body?.classList.add("screenshot-capture"),await new Promise(ue=>requestAnimationFrame(ue)),await k();try{const{toBlob:ue,toPng:ge}=await ph(async()=>{const{toBlob:Tt,toPng:Gf}=await import("./index-BeoRn2gJ.js");return{toBlob:Tt,toPng:Gf}},[]),ke=await ue(O,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:q,height:me,style:{width:`${q}px`,height:`${me}px`},filter:Tt=>!(Tt instanceof HTMLElement)||Tt.dataset?.screenshotExclude!=="true"});if(ke)return ke;const ft=await ge(O,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:q,height:me,style:{width:`${q}px`,height:`${me}px`},filter:Tt=>!(Tt instanceof HTMLElement)||Tt.dataset?.screenshotExclude!=="true"});return ft?await(await fetch(ft)).blob():null}finally{F?.classList.remove("screenshot-capture"),document.body?.classList.remove("screenshot-capture")}},[]),df=h.useCallback(async()=>{if(typeof window>"u"||be)return;Ne(!0);const k=navigator?.userAgent||"",O=/iP(hone|od|ad)/i.test(k),F=/Safari/i.test(k)&&!/Chrome|Chromium|Edg|OPR|CriOS|FxiOS/i.test(k),q=typeof navigator<"u"&&!!navigator.clipboard?.write&&typeof window<"u"&&!!window.ClipboardItem;let ue=!q||O||F;try{const ge=await Mo();ge&&q&&(typeof document<"u"&&!document.hasFocus()&&window.focus?.(),ue=await gh(ge))}catch(ge){console.error("Failed to capture screenshot",ge)}finally{if(Ne(!1),!ue){console.warn("Failed to write screenshot to clipboard.");return}Xs&&(window.location.href=Xs)}},[Mo,be,Xs]),ff=h.useMemo(()=>ee?[]:iw,[ee]),hf=h.useMemo(()=>[{label:P("usage.metric.total"),value:ht(Bt),valueClassName:"text-white"},{label:P("usage.metric.input"),value:ht(Fe?.input_tokens)},{label:P("usage.metric.output"),value:ht(Fe?.output_tokens)},{label:P("usage.metric.cached_input"),value:ht(Fe?.cached_input_tokens)},{label:P("usage.metric.reasoning_output"),value:ht(Fe?.reasoning_output_tokens)}],[Fe?.cached_input_tokens,Fe?.input_tokens,Fe?.output_tokens,Fe?.reasoning_output_tokens,Bt]),Zs=h.useMemo(()=>{const k=xi(Fe?.total_cost_usd);return!k||k==="-"||k.startsWith("$")?k:`$${k}`},[Fe?.total_cost_usd]),mf=h.useMemo(()=>Fe?.conversation_count??null,[Fe?.conversation_count]),Do=h.useMemo(()=>$m(kt,{copyFn:P}),[kt]),pf=h.useMemo(()=>Um(kt,{limit:3,copyFn:P}),[kt]),gf=h.useCallback(()=>u(!0),[]),yf=h.useCallback(()=>u(!1),[]),bf=Zs&&Zs!=="-"&&Do.length>0,un=P("dashboard.install.cmd.init"),Js=ct?null:d,Qs=Js?P("dashboard.install.cmd.init_link_code",{link_code:Js}):un,xf=un,vf=P("dashboard.install.cmd.sync"),wf=Js?P("dashboard.install.copy"):P("dashboard.install.copy_base"),Sf=P("dashboard.install.copied");P("dashboard.session_expired.copy_label"),P("dashboard.session_expired.copied");const kf=!!(X?.install?.has_active_device_token??X?.install?.hasActiveDeviceToken),Tf=Om({publicMode:i,screenshotMode:ee,forceInstall:de,accessEnabled:Ee,heatmapLoading:po,activeDays:xo,hasActiveDeviceToken:kf}),Cf=P("dashboard.install.prompt"),Ef=P("dashboard.public_view.title"),Af=P("dashboard.public_view.status.enabled"),Pf=P("dashboard.public_view.status.disabled"),Rf=P("dashboard.public_view.action.copy"),Mf=P("dashboard.public_view.action.copied"),Df=P("dashboard.public_view.action.enable"),Nf=P("dashboard.public_view.action.disable"),jf=P("dashboard.public_view.invalid.title"),Lf=P("dashboard.public_view.invalid.body"),Vf=M||L,If=N?Af:Pf,No=h.useMemo(()=>!I||typeof window>"u"?"":new URL(`/share/${I}`,window.location.origin).toString(),[I]),Ff=j?Mf:Rf,_f=N?Nf:Df,Of=h.useCallback(async()=>{!Qs||!await sr(Qs)||(te(!0),window.setTimeout(()=>te(!1),2e3))},[Qs]);h.useCallback(async()=>{!un||!await sr(un)||(xe(!0),window.setTimeout(()=>xe(!1),2e3))},[un]);const Bf=h.useCallback(async()=>{if(L||!N)return;let k=No;if(!k){$(!0);try{const F=await ot(K);if(!F){$(!1);return}const q=await Vo({baseUrl:e,accessToken:F}),me=typeof q?.share_token=="string"?q.share_token:null;A(me),me&&typeof window<"u"&&(k=new URL(`/share/${me}`,window.location.origin).toString())}catch{}finally{$(!1)}}!k||!await sr(k)||(W(!0),window.setTimeout(()=>W(!1),2e3))},[K,e,L,N,No]),$f=h.useCallback(async()=>{if(!L){W(!1),$(!0);try{const k=await ot(K);if(!k){$(!1);return}const F=await Eh({baseUrl:e,accessToken:k,enabled:!N}),q=!!F?.enabled;C(q),A(F?.share_token||null)}catch{}finally{$(!1)}}},[K,e,L,N]),er=h.useMemo(()=>P("dashboard.daily.empty",{cmd:"{{cmd}}"}),[]),[Uf,Wf]=h.useMemo(()=>{const k=er.split("{{cmd}}");return k.length===1?[er,""]:[k[0],k.slice(1).join("{{cmd}}")]},[er]),Kf=s&&!i,Hf=!n&&!Z&&!s&&!Le&&!i;return g.jsx(rw,{copy:P,screenshotMode:ee,publicViewInvalid:Gd,publicViewInvalidTitle:jf,publicViewInvalidBody:Lf,showExpiredGate:Kf,showAuthGate:Hf,screenshotTitleLine1:of,screenshotTitleLine2:af,identityDisplayName:Yd,identityStartDate:zd,activeDays:xo,identitySubscriptions:qd,identityScrambleDurationMs:Be,projectUsageEntries:Sd,projectUsageLimit:co,setProjectUsageLimit:wd,topModels:pf,signedIn:n,publicMode:i,shouldShowInstall:Tf,installPrompt:Cf,handleCopyInstall:Of,installCopied:E,installCopiedLabel:Sf,installCopyLabel:wf,installInitCmdDisplay:xf,linkCodeLoading:y,linkCodeError:x,publicViewTitle:Ef,handleTogglePublicView:$f,publicViewBusy:Vf,publicViewEnabled:N,publicViewToggleLabel:_f,publicViewStatusLabel:If,publicViewCopyButtonLabel:Ff,handleCopyPublicView:Bf,trendRowsForDisplay:Nd,trendFromForDisplay:jd,trendToForDisplay:Ld,period:le,trendTimeZoneLabel:no,activityHeatmapBlock:Xd,isCapturing:be,handleShareToX:df,screenshotTwitterLabel:lf,screenshotTwitterButton:cf,screenshotTwitterHint:uf,periodsForDisplay:ff,setSelectedPeriod:Ws,metricsRows:hf,summaryLabel:Jd,summaryValue:Qd,summaryCostValue:Zs,summaryConversationsValue:mf,rollingUsage:yd,costInfoEnabled:bf,openCostModal:gf,allowBreakdownToggle:rf,coreIndexCollapsed:Qe,setCoreIndexCollapsed:et,coreIndexCollapseLabel:ef,coreIndexExpandLabel:tf,coreIndexCollapseAria:nf,coreIndexExpandAria:sf,refreshAll:Wd,usageLoadingState:Kd,usageError:Ke,rangeLabel:Zd,timeZoneRangeLabel:Ks,usageSourceLabel:Hd,fleetData:Do,hasDetailsActual:Rd,dailyEmptyPrefix:Uf,installSyncCmd:vf,dailyEmptySuffix:Wf,detailsColumns:Ad,ariaSortFor:Od,toggleSort:_d,sortIconFor:Bd,pagedDetails:Md,dailyBreakdownRows:Dd,dailyBreakdownColumns:Pd,dailyBreakdownAriaSortFor:$d,dailyBreakdownSortIconFor:Ud,dailyBreakdownDateKey:Un,detailsDateKey:He,renderDetailDate:Id,renderDailyBreakdownDate:Fd,renderDetailCell:Vd,DETAILS_PAGED_PERIODS:pn,detailsPageCount:Ys,detailsPage:zs,setDetailsPage:Kn,costModalOpen:c,closeCostModal:yf})}export{pw as DashboardPage};
|