tokentracker-cli 0.92.0 → 0.93.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +3 -1
- package/README.ja.md +3 -1
- package/README.ko.md +3 -1
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/dashboard/dist/assets/{AchievementBadge-o8hl3my2.js → AchievementBadge-D10CA0Yt.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-CjDEyZfD.js → AchievementsPage-Koc-RixX.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-Cwv1Zmyf.js → AchievementsSection-BhPN_8G6.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-BDxTgOvT.js → BadgeDetailModal-CFgdS3Ew.js} +1 -1
- package/dashboard/dist/assets/BotAnimated-CW81QSQu.js +1 -0
- package/dashboard/dist/assets/{Card-Cp5v7Y19.js → Card-DzYuh963.js} +1 -1
- package/dashboard/dist/assets/ClawdAnimated-CxR9qig7.js +2 -0
- package/dashboard/dist/assets/{CommandPalette-CIf9oAqq.js → CommandPalette-DbvccFuj.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-UwiOPFu0.js → CommunityStatsModal-zROYUuhI.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-xkYsrh0v.js → ConfirmModal-nOBxWc3T.js} +1 -1
- package/dashboard/dist/assets/{Controls-C2Z2X0ZQ.js → Controls-NQMc-XyF.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-Do_NMUFK.js → DashboardPage-Cr7YjFQE.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-DL5OjugJ.js → DevicePage-hg5EX6lW.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-D0w08oR2.js → DialogClose-B7AyVJn4.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-2f8ReZgl.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-IKAPm5Pk.js → DialogTitle-IGUG8ZLp.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-Dve77aEj.js → FadeIn-DT4BeINx.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-BVYbLWDi.js → HeaderGithubStar-DrG9OXEl.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BrF9-z7f.js → HoverTooltip-DkHxleW2.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BZ1VyVsm.js → IpCheckPage-Btl87yWo.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-jkjtQl58.js → LandingPage-BM2GFoSc.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardAvatar-D9kUudjQ.js → LeaderboardAvatar-AqGMcFFx.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-DXg7Qv8T.js → LeaderboardPage-B9UnLIPA.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProfileModal-jTlaOi-j.js → LeaderboardProfileModal-D0PZMJOW.js} +4 -4
- package/dashboard/dist/assets/{LeaderboardProfilePage-DsKQ_Of8.js → LeaderboardProfilePage-D9bu_0cf.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-LLP2azzT.js +5 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-CkLs3CF_.js → LocalOnlyNotice-D3wCg6qv.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-SmOXM_PX.js → LoginCard-D4lzOeYM.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-CvtEBkrO.js → LoginModal-_ycwz7uZ.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-Zm-dRt_Y.js → LoginPage-gSnn_di7.js} +1 -1
- package/dashboard/dist/assets/PetPage-Duo8f2YU.js +1 -0
- package/dashboard/dist/assets/{PopoverPopup-CnteSROW.js → PopoverPopup-BDL1MCfN.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-DcQmGbfz.js → ProviderIcon-B_aNMi3s.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-zMb_m3Cx.js → ResetPasswordPage-DPF1GjA6.js} +1 -1
- package/dashboard/dist/assets/{SegmentedControl-D3KkbQ7T.js → SegmentedControl-BSSEziQX.js} +1 -1
- package/dashboard/dist/assets/{Select-0RiFEISo.js → Select-DI8Duz98.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-BRV3DFEB.js → SelectItemText-DxwgRTwt.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-CWF_vKOC.js → ServiceStatusPage-8mc6tf7h.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-DIqoT7MU.js → SessionsPage-BCIo-bEx.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-DQZIqiE5.js → SettingsPage-BXpBCDMC.js} +2 -2
- package/dashboard/dist/assets/{SkillsPage-BIIOUHnq.js → SkillsPage-CaXfpR8T.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-Bulaqjbm.js → TokenGalaxy-CO7rFK4W.js} +1 -1
- package/dashboard/dist/assets/{ToolbarRootContext-Dg-zL8fE.js → ToolbarRootContext-Dql3cfna.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-DfafDX6b.js → TrendMonitor-C09fR8ct.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-F_2yLE7n.js → WidgetsPage-CC00HOab.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-BFxYKGQs.js → WrappedPage-CepwPa8x.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-CZMdPW0g.js → __vite-browser-external-B-XC2p3L.js} +19 -10
- package/dashboard/dist/assets/__vite-browser-external-CiR9-j4L.css +1 -0
- package/dashboard/dist/assets/{agent-logos-DjyCpabA.js → agent-logos-BDjHZ9FJ.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-CIAd6sXA.js → arrow-up-right-C3b1UqgX.js} +1 -1
- package/dashboard/dist/assets/{check-Bt3Yu07t.js → check-m09S3gbL.js} +1 -1
- package/dashboard/dist/assets/{chevron-right-BiXULxma.js → chevron-right-CpDzo_UN.js} +1 -1
- package/dashboard/dist/assets/{copy-D3k1Xbfl.js → copy-Da10tbbX.js} +1 -1
- package/dashboard/dist/assets/{download-co2WHJvo.js → download-qOQt6utK.js} +1 -1
- package/dashboard/dist/assets/{external-link-D5az2QwL.js → external-link-8c_9vEXT.js} +1 -1
- package/dashboard/dist/assets/{flame-CSCUyn3Z.js → flame-DwuGtbCi.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-BebRLYzr.js → format-tokens-5SefoHr1.js} +1 -1
- package/dashboard/dist/assets/{icons-C_y5qr6T.js → icons-JyXD7jwQ.js} +1 -1
- package/dashboard/dist/assets/{index-DP3XlgDm.js → index-BAH8DvZw.js} +1 -1
- package/dashboard/dist/assets/{index-R488h3mD.js → index-CN7zY-iZ.js} +1 -1
- package/dashboard/dist/assets/{index-CXOOOeSl.js → index-QKdHEBW3.js} +1 -1
- package/dashboard/dist/assets/{info-CD_G_DZp.js → info-BeIuHjVl.js} +1 -1
- package/dashboard/dist/assets/{limits-providers-BlAlATd7.js → limits-providers-C2LxotEb.js} +1 -1
- package/dashboard/dist/assets/{link-2-DIn-EC5g.js → link-2-NF0onc-H.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-B5Az_VQe.js → loader-circle-CP259tjS.js} +1 -1
- package/dashboard/dist/assets/{maximize-2-ptnkCbEN.js → maximize-2-DngHuDpS.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-DEN3VPKe.js → modifiers.esm-Bp3mFth-.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-Dqr_CnOQ.js → monitor-smartphone-DW17JpTX.js} +1 -1
- package/dashboard/dist/assets/{provider-display-BOAoggwg.js → provider-display-DiZUmcnX.js} +1 -1
- package/dashboard/dist/assets/{react-B3eL33ha.js → react-C681nojo.js} +1 -1
- package/dashboard/dist/assets/{search-CNNSHW9P.js → search-pNfEa7Lu.js} +1 -1
- package/dashboard/dist/assets/{skills-api-BShLlV2m.js → skills-api-0vmNGWLW.js} +1 -1
- package/dashboard/dist/assets/skins-C8EyB85e.js +1 -0
- package/dashboard/dist/assets/{sortable.esm-C6kDS9DZ.js → sortable.esm-BmpxivFO.js} +1 -1
- package/dashboard/dist/assets/{store-B4atnDzu.js → store-B0QLXu7j.js} +1 -1
- package/dashboard/dist/assets/{terminal-CXMttuiJ.js → terminal-D7ntwa3W.js} +1 -1
- package/dashboard/dist/assets/{trash-2-aXKBjf5M.js → trash-2-BneBo2xu.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-rGR2J-Vi.js → use-community-stats-B4FMrIyX.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-CazeqdNI.js → use-limits-display-prefs-B3o8C_zQ.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-Bx-enbl8.js → use-ordered-list-CA_j8ox3.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-DITgKHoW.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-B7RHUtup.js → use-session-efficiency-pref-DwO-VjQ3.js} +1 -1
- package/dashboard/dist/assets/{use-transform-CWVOY76a.js → use-transform-DQhhQUmO.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-C9XRiYNi.js → use-usage-limits-BFtGha1X.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-D7ICju5j.js → useCurrency-BpARhxK3.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-DXWPQF_D.js → useScrollLock-CPs_4XCs.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-wDhHrsAL.js → useTokenFormat-BT2luita.js} +1 -1
- package/dashboard/dist/assets/{zap-BZDqgZR1.js → zap-DbgbtlBE.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +4 -2
- package/src/commands/status.js +5 -1
- package/src/lib/opencode-go-limits.js +33 -15
- package/src/lib/pet-packages.js +45 -1
- package/src/lib/pricing/index.js +17 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/dashboard/dist/assets/ClawdAnimated-6Ibb4qCZ.js +0 -1
- package/dashboard/dist/assets/DialogDescription-rhGVm7N2.js +0 -1
- package/dashboard/dist/assets/LimitsPage-CMqZAQCa.js +0 -5
- package/dashboard/dist/assets/PetPage-Bcj7hzNz.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-CRYifSM4.css +0 -1
- package/dashboard/dist/assets/use-reduced-motion-2NcjtyzY.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v,V as u,z as w,j as e,e as m}from"./__vite-browser-external-
|
|
1
|
+
import{r as v,V as u,z as w,j as e,e as m}from"./__vite-browser-external-B-XC2p3L.js";import{C as k}from"./ToolbarRootContext-Dql3cfna.js";import{C as j}from"./check-m09S3gbL.js";import{u as N,a as C,L as E,s as x,b as I,S as R,c as T,d as L,e as A,f as P,g as V,h as _,i as z,j as D}from"./SelectItemText-DxwgRTwt.js";const G=v.forwardRef(function(t,s){const{render:i,className:y,style:o,...l}=t,{store:r,scrollHandlerRef:n,multiple:c}=N(),{alignItemWithTriggerActive:d}=C(),g=u(r,x.hasScrollArrows),a=u(r,x.openMethod),h={id:`${u(r,x.id)}-list`,role:"listbox","aria-multiselectable":c||void 0,onScroll(S){n.current?.(S.currentTarget)},...d&&{style:E},className:g&&a!=="touch"?I.className:void 0},p=r.useStateSetter("listElement");return w("div",t,{ref:[s,p],props:[h,l]})}),M="relative inline-flex items-center justify-between gap-2 rounded-lg border border-oai-gray-200 bg-white text-oai-black transition-colors hover:border-oai-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:border-oai-gray-700";function U({value:b,onValueChange:t,options:s=[],ariaLabel:i,id:y,disabled:o=!1,leadingIcon:l=null,className:r="",popupClassName:n="",align:c="start",matchTriggerWidth:d=!1}){const g=s.map(a=>({value:a.value,label:a.label}));return e.jsxs(R,{value:b,items:g,disabled:o,onValueChange:a=>{!o&&a!=null&&t?.(a)},children:[e.jsxs(T,{id:y,"aria-label":i,className:m(M,o&&"cursor-not-allowed opacity-50 hover:border-oai-gray-200 dark:hover:border-oai-gray-800",r),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l,e.jsx(L,{className:"truncate"})]}),e.jsx(k,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsx(A,{children:e.jsx(P,{align:c,side:"bottom",sideOffset:4,className:"z-50",children:e.jsx(V,{className:m("max-h-[min(18rem,var(--available-height))] origin-[var(--transform-origin)] overflow-y-auto","rounded-xl border border-oai-gray-200 bg-white p-1 shadow-lg ring-1 ring-black/[0.04]","dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:ring-white/[0.05]","transition-[opacity,transform] duration-150 ease-out","data-[starting-style]:scale-95 data-[starting-style]:opacity-0","data-[ending-style]:scale-95 data-[ending-style]:opacity-0",d&&"min-w-[var(--anchor-width)]",n),children:e.jsx(G,{role:"listbox","aria-label":i,children:s.map(a=>e.jsxs(_,{value:a.value,disabled:a.disabled,className:({selected:f,disabled:h})=>m("flex w-full cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg py-1.5 pl-1.5 pr-6","text-left text-xs outline-none transition-colors",f?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800/70 dark:text-white":"text-oai-gray-600 hover:bg-oai-gray-50 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800/60",h&&"cursor-not-allowed opacity-50 hover:bg-transparent dark:hover:bg-transparent"),children:[e.jsx("span",{className:"flex w-3.5 shrink-0 items-center justify-center text-oai-gray-500 dark:text-oai-gray-300",children:e.jsx(z,{children:e.jsx(j,{className:"h-3 w-3","aria-hidden":!0})})}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.jsx(D,{children:a.label})})]},String(a.value)))})})})})]})}export{U as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bT as xn,aI as $e,aF as Z,bd as Yt,bW as $t,bU as bn,r as o,bc as Q,bx as vt,cg as Ht,ch as Et,ci as kt,b_ as Ct,be as tt,aE as De,A as Ie,cj as Ut,bw as Bt,ck as st,aD as Rn,bn as Gt,c0 as Xt,cl as ht,cm as xt,cn as Jt,co as Ot,bb as ft,c2 as yn,cp as In,cq as wt,ay as bt,aJ as xe,$ as Qt,j as Re,V as A,aA as Vt,aL as Pt,aK as Sn,aO as En,aP as Cn,aQ as gt,aG as Tn,b$ as Mn,aN as dt,bQ as vn,y as Zt,z as Xe,cr as wn,aB as Pn,cs as An,aC as On,bg as Vn,ct as Fn,az as en,cu as Tt}from"./__vite-browser-external-CZMdPW0g.js";import{q as tn,F as Ln,P as Dn,v as ke,o as Nn,E as Hn,G as we,H as nn,D as kn,u as Un,m as rn,e as Bn,d as _n,z as Wn,I as jn,b as zn,a as Kn,C as qn}from"./useScrollLock-DXWPQF_D.js";import{h as Yn,u as $n,a as Gn,d as Xn,c as Jn,e as Qn,f as Zn,i as er,p as tr,r as nr,g as rr}from"./ToolbarRootContext-Dg-zL8fE.js";function Ze(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function or(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,c=xn(),i=tn()!=null,s=$e(()=>new Ln({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Dn,floatingId:c,syncOnly:!1,nested:i})).current;return Z(()=>{const a={open:t,floatingId:c};r.reference!==void 0&&(a.referenceElement=r.reference,a.domReferenceElement=Yt(r.reference)?r.reference:null),r.floating!==void 0&&(a.floatingElement=r.floating),s.update(a)},[t,c,r.reference,r.floating,s]),s.context.onOpenChange=n,s.context.nested=i,s}const sr="Escape";function _t(e){return Xt&&e.movementX===0&&e.movementY===0}function Rt(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function it(e,t){return Rt(t,e===Jt||e===Ot,e===ht||e===xt)}function Mt(e,t,n){return Rt(t,e===Ot,n?e===ht:e===xt)||e==="Enter"||e===" "||e===""}function ir(e,t,n){return Rt(t,n?e===ht:e===xt,e===Ot)}function lr(e,t,n,r){const c=n?e===xt:e===ht,i=e===Jt;return t==="both"||t==="horizontal"&&r?e===sr:Rt(t,c,i)}function cr(e,t){const{listRef:n,activeIndex:r,onNavigate:c=()=>{},enabled:i=!0,selectedIndex:s=null,allowEscape:a=!1,loopFocus:d=!1,nested:m=!1,rtl:C=!1,virtual:p=!1,focusItemOnOpen:g="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:T=!0,disabledIndices:U=void 0,orientation:u="vertical",parentOrientation:z,id:K,resetOnPointerLeave:V=!0,externalTree:R,grid:I}=t,j=I!=null,h="rootStore"in e?e.rootStore:e,y=h.useState("open"),O=h.useState("floatingElement"),X=h.useState("domReferenceElement"),ee=h.context.dataRef,me=$t(O),te=bn(X),w=ke(me),N=tn(),ne=Nn(R),B=o.useRef(g),P=o.useRef(s??-1),q=o.useRef(null),F=o.useRef(!0),l=Q(f=>{c(P.current===-1?null:P.current,f)}),M=o.useRef(!!O),ce=o.useRef(y),_=o.useRef(!1),ue=o.useRef(!1),E=o.useRef(null),L=ke(U),Y=ke(y),ie=ke(s),ye=ke(V),H=vt(),re=vt(),J=Q(()=>{function f(k){p?ne?.events.emit("virtualfocus",k):E.current=Hn(k,{sync:_.current,preventScroll:!0})}const b=n.current[P.current],$=ue.current;b&&f(b),(_.current?k=>k():k=>H.request(k))(()=>{const k=n.current[P.current]||b;if(!k)return;b||f(k),he&&($||!F.current)&&k.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Z(()=>{ee.current.orientation=u},[ee,u]),Z(()=>{i&&(y&&O?(P.current=s??-1,B.current&&s!=null&&(ue.current=!0,l())):M.current&&(P.current=-1,l()))},[i,y,O,s,l]),Z(()=>{if(i){if(!y){_.current=!1;return}if(O)if(r==null){if(_.current=!1,ie.current!=null)return;if(M.current&&(P.current=-1,J()),(!ce.current||!M.current)&&B.current&&(q.current!=null||B.current===!0&&q.current==null)){let f=0;const b=()=>{n.current[0]==null?(f<2&&(f?x=>re.request(x):queueMicrotask)(b),f+=1):(P.current=q.current==null||Mt(q.current,u,C)||m?Et(n):kt(n),q.current=null,l())};b()}}else Ht(n.current,r)||(P.current=r,J(),ue.current=!1)}},[i,y,O,r,ie,m,n,u,C,l,J,re]),Z(()=>{if(!i||O||!ne||p||!M.current)return;const f=ne.nodesRef.current,b=f.find(k=>k.id===N)?.context?.elements.floating,$=Ct(tt(X??b??null)),x=f.some(k=>k.context&&De(k.context.elements.floating,$));b&&!x&&F.current&&b.focus({preventScroll:!0})},[i,O,X,ne,N,p]),Z(()=>{ce.current=y,M.current=!!O}),Z(()=>{y||(q.current=null,B.current=g)},[y,g]);const be=r!=null,le=Q(f=>{if(!Y.current)return;const b=n.current.indexOf(f.currentTarget);b!==-1&&(P.current!==b||r!==b)&&(P.current=b,l(f))}),ae=Q(()=>z??ne?.nodesRef.current.find(f=>f.id===N)?.context?.dataRef?.current.orientation),ge=Q(()=>Et(n,L.current)),fe=Q(f=>{if(F.current=!1,_.current=!0,f.which===229||!Y.current&&f.currentTarget===w.current)return;if(m&&lr(f.key,u,C,j)){it(f.key,ae())||we(f),h.setOpen(!1,Ie(Ut,f.nativeEvent)),Bt(X)&&(p?ne?.events.emit("virtualfocus",X):X.focus());return}const b=P.current,$=Et(n,U),x=kt(n,U);if(te||(f.key==="Home"&&(we(f),P.current=$,l(f)),f.key==="End"&&(we(f),P.current=x,l(f))),I!=null){const k=I(f,P.current,n,u,d,C,U,$,x);if(k!=null&&(P.current=k,l(f)),u==="both")return}if(it(f.key,u)){if(we(f),y&&!p&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){P.current=Mt(f.key,u,C)?$:x,l(f);return}Mt(f.key,u,C)?d?b>=x?a&&b!==n.current.length?P.current=-1:(_.current=!1,P.current=$):P.current=st(n.current,{startingIndex:b,disabledIndices:U}):P.current=Math.min(x,st(n.current,{startingIndex:b,disabledIndices:U})):d?b<=$?a&&b!==-1?P.current=n.current.length:(_.current=!1,P.current=x):P.current=st(n.current,{startingIndex:b,decrement:!0,disabledIndices:U}):P.current=Math.max($,st(n.current,{startingIndex:b,decrement:!0,disabledIndices:U})),Ht(n.current,P.current)&&(P.current=-1),l(f)}}),he=o.useMemo(()=>({onFocus(b){_.current=!0,le(b)},onClick:({currentTarget:b})=>b.focus({preventScroll:!0}),onMouseMove(b){_t(b)||(_.current=!0,ue.current=!1,S&&le(b))},onPointerLeave(b){if(!Y.current||!F.current||b.pointerType==="touch")return;_.current=!0;const $=b.relatedTarget;if(!(!S||n.current.includes($))&&ye.current&&(E.current?.(),E.current=null,P.current=-1,l(b),!p)){const x=w.current,k=Ct(tt(x));x&&De(x,k)&&x.focus({preventScroll:!0})}}}),[le,Y,w,S,n,l,ye,p]),G=o.useMemo(()=>p&&y&&be&&{"aria-activedescendant":`${K}-${r}`},[p,y,be,K,r]),oe=o.useMemo(()=>({"aria-orientation":u==="both"?void 0:u,...te?{}:G,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&y&&!p){const b=Rn(f.nativeEvent);if(b&&!De(w.current,b))return;we(f),h.setOpen(!1,Ie(Gt,f.nativeEvent)),Bt(X)&&X.focus();return}fe(f)},onPointerMove(f){_t(f)||(F.current=!0)}}),[G,fe,w,u,te,h,y,p,X]),pe=o.useMemo(()=>{function f(x){h.setOpen(!0,Ie(Ut,x.nativeEvent,x.currentTarget))}function b(x){g==="auto"&&nn(x.nativeEvent)&&(B.current=!p)}function $(x){B.current=g,g==="auto"&&kn(x.nativeEvent)&&(B.current=!0)}return{onKeyDown(x){const k=h.select("open");F.current=!1;const Ce=x.key.startsWith("Arrow"),de=ir(x.key,ae(),C),Be=it(x.key,u),_e=(m?de:Be)||x.key==="Enter"||x.key.trim()==="";if(p&&k)return fe(x);if(!(!k&&!T&&Ce)){if(_e){const Se=it(x.key,ae());q.current=m&&Se?null:x.key}if(m){de&&(we(x),k?(P.current=ge(),l(x)):f(x));return}Be&&(ie.current!=null&&(P.current=ie.current),we(x),!k&&T?f(x):fe(x),k&&l(x))}},onFocus(x){h.select("open")&&!p&&(P.current=-1,l(x))},onPointerDown:$,onPointerEnter:$,onMouseDown:b,onClick:b}},[fe,g,ge,m,l,h,T,u,ae,C,ie,p]),D=o.useMemo(()=>({...G,...pe}),[G,pe]);return o.useMemo(()=>i?{reference:D,floating:oe,item:he,trigger:pe}:{},[i,D,oe,pe,he])}function ur(e,t){const{listRef:n,elementsRef:r,activeIndex:c,onMatch:i,disabledIndices:s,onTyping:a,enabled:d=!0,resetMs:m=750,selectedIndex:C=null}=t,p="rootStore"in e?e.rootStore:e,g=p.useState("open"),S=ft(),T=o.useRef(""),U=o.useRef(C??c??-1),u=o.useRef(null),z=Q(R=>{function I(w){return r?.current[w]}function j(w){const N=I(w);return N&&!yn(N)||N?.matches(":disabled")?!1:s==null||!In(wt,w,s)}function h(w,N,ne=0){if(w.length===0)return-1;const B=(ne%w.length+w.length)%w.length,P=N.toLowerCase();for(let q=0;q<w.length;q+=1){const F=(B+q)%w.length;if(!(!w[F]?.toLowerCase().startsWith(P)||!j(F)))return F}return-1}const y=n.current;if(T.current.length>0&&R.key===" "&&(we(R),a?.(!0)),T.current.length>0&&T.current[0]!==" "&&h(y,T.current)===-1&&R.key!==" "&&a?.(!1),y==null||R.key.length!==1||R.ctrlKey||R.metaKey||R.altKey)return;g&&R.key!==" "&&(we(R),a?.(!0));const O=T.current==="";O&&(U.current=C??c??-1),y.every((w,N)=>w&&j(N)?w[0]?.toLowerCase()!==w[1]?.toLowerCase():!0)&&T.current===R.key&&(T.current="",U.current=u.current),T.current+=R.key,S.start(m,()=>{T.current="",U.current=u.current,a?.(!1)});const me=((O?C??c??-1:U.current)??0)+1,te=h(y,T.current,me);te!==-1?(i?.(te),u.current=te):R.key!==" "&&(T.current="",a?.(!1))}),K=Q(R=>{const I=R.relatedTarget,j=p.select("domReferenceElement"),h=p.select("floatingElement");De(j,I)||De(h,I)||(S.clear(),T.current="",U.current=u.current,a?.(!1))});Z(()=>{!g&&C!==null||(S.clear(),u.current=null,T.current!==""&&(T.current=""))},[g,C,S]);const V=o.useMemo(()=>({onKeyDown:z,onBlur:K}),[z,K]);return o.useMemo(()=>d?{reference:V,floating:V}:{},[d,V])}function ar(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function fr(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function dr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:r="value"}){const{current:c}=o.useRef(e!==void 0),[i,s]=o.useState(t),a=c?e:i,d=o.useCallback(m=>{c||s(m)},[]);return[a,d]}const on=o.createContext(null);function Ue(){const e=o.useContext(on);if(e===null)throw new Error(bt(60));return e}const pr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},gr={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},mr={disabled:!1,...gr},hr={valid(e){return e===null?null:e?{"data-valid":""}:{"data-invalid":""}}},xr={invalid:void 0,name:void 0,validityData:{state:pr,errors:[],error:"",value:"",initialValue:null},setValidityData:xe,disabled:void 0,setTouched:xe,setDirty:xe,setFilled:xe,setFocused:xe,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:mr,registerFieldControl:xe,validation:{getValidationProps:(e,t=Qt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:xe,getInputControl:()=>null,commit:async()=>{},change:xe}},br=o.createContext(xr);function Ft(e=!0){const t=o.useContext(br);if(t.setValidityData===xe&&!e)throw new Error(bt(28));return t}function Rr(e,t,n,r,c=!0,i){const{registerFieldControl:s}=Ft(),a=$e(()=>Symbol());Z(()=>{const d=a.current;if(!c){s(d,void 0);return}s(d,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,c,r,t,i,s,a,n]),Z(()=>{const d=a.current;return()=>{s(d,void 0)}},[s,a])}const yr=o.createContext({controlId:void 0,registerControlId:xe,labelId:void 0,setLabelId:xe,messageIds:[],setMessageIds:xe,getDescriptionProps:e=>e});function sn(){return o.useContext(yr)}function ln(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:c,registerControlId:i}=sn(),s=Un(t),a=n?c:void 0,d=$e(()=>Symbol()),m=o.useRef(!1),C=o.useRef(t!=null),p=Q(()=>{!m.current||i===xe||(m.current=!1,i(d.current,void 0))});return Z(()=>{if(i===xe)return;let g;if(n){const S=r?.current;Yt(S)&&S.closest("label")!=null?g=t??null:g=a??s}else if(t!=null)C.current=!0,g=t;else if(C.current)g=s;else{p();return}if(g===void 0){p();return}m.current=!0,i(d.current,g)},[t,r,a,i,n,s,d,p]),o.useEffect(()=>p,[p]),c??s}const Ir=(e,t)=>Object.is(e,t);function Ge(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function pt(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Ge(r,t,n))}function Sr(e,t,n){return e.filter(r=>!Ge(t,r,n))}function At(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function cn(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Er(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(cn(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function un(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return At(e)}function Ye(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?At(e.value):At(e)}function an(e,t,n){function r(){return un(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const c=t,i=cn(c)?c.flatMap(s=>s.items):c;if(e==null||typeof e!="object"){const s=i.find(a=>a.value===e);return s&&s.label!=null?s.label:r()}if("value"in e){const s=i.find(a=>a&&a.value===e.value);if(s&&s.label!=null)return s.label}}return r()}function Cr(e,t,n){return e.reduce((r,c,i)=>(i>0&&r.push(", "),r.push(Re.jsx(o.Fragment,{children:an(c,t,n)},i)),r),[])}const v={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ye(t,r)!==""},hasNullItemLabel:(e,t)=>t?Er(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(c=>Ge(t,c,n)):Ge(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},Tr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:xe,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function Mr(){return o.useContext(Tr)}function vr(e,t,n=(r,c)=>r===c){return e.length===t.length&&e.every((r,c)=>n(r,t[c]))}const Pe=1;function fn(e,t){return Math.max(0,e-t)}function wr(e,t){if(t<=0)return 0;const n=Ze(e,0,t),r=n,c=t-n,i=r<=Pe,s=c<=Pe;return i&&s?r<=c?0:t:i?0:s?t:n}function to(e){const{id:t,value:n,defaultValue:r=null,onValueChange:c,open:i,defaultOpen:s=!1,onOpenChange:a,name:d,form:m,autoComplete:C,disabled:p=!1,readOnly:g=!1,required:S=!1,modal:T=!0,actionsRef:U,inputRef:u,onOpenChangeComplete:z,items:K,multiple:V=!1,itemToStringLabel:R,itemToStringValue:I,isItemEqualToValue:j=Ir,highlightItemOnHover:h=!0,children:y}=e,{clearErrors:O}=Mr(),{setDirty:X,setTouched:ee,setFocused:me,validityData:te,setFilled:w,name:N,disabled:ne,validation:B,validationMode:P}=Ft(),q=ln({id:t}),F=ne||p,l=N??d,[M,ce]=Wt({controlled:n,default:V?r??wt:r,name:"Select",state:"value"}),[_,ue]=Wt({controlled:i,default:s,name:"Select",state:"open"}),E=o.useRef([]),L=o.useRef([]),Y=o.useRef(null),ie=o.useRef(null),ye=o.useRef(0),H=o.useRef(null),re=o.useRef([]),J=o.useRef(!1),be=o.useRef(null),le=o.useRef(null),ae=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ge=o.useRef(!1),{mounted:fe,setMounted:he,transitionStatus:G}=rn(_),{openMethod:oe,triggerProps:pe}=Yn(_),D=$e(()=>new Tn({id:q,labelId:void 0,modal:T,multiple:V,itemToStringLabel:R,itemToStringValue:I,isItemEqualToValue:j,value:M,open:_,mounted:fe,transitionStatus:G,items:K,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,f=A(D,v.activeIndex),b=A(D,v.selectedIndex),$=A(D,v.triggerElement),x=A(D,v.positionerElement),k=fr(oe),Ce=oe??k,de=o.useMemo(()=>V?"":Ye(M,I),[V,M,I]),Be=o.useMemo(()=>V&&Array.isArray(M)?M.map(W=>Ye(W,I)):Ye(M,I),[V,M,I]),_e=ke($),Se=Q(()=>Be);Rr(_e,q,M,Se,!F,d);const yt=o.useRef(M),Je=V?Array.isArray(M)&&M.length>0:M!=null&&de!=="";Z(()=>{w(Je)},[Je,w]),Z(function(){let se=M,ve=!1;if(V){const He=Array.isArray(M)?M:[];ve=He.length===0,se=He[He.length-1]}const Fe=ve?-1:pt(re.current,se,j),Le=Fe===-1?null:Fe;Le===null&&(le.current=null),!_&&D.set("selectedIndex",Le)},[V,_,M,j,D]);function Te(W){const se=te.initialValue;return Array.isArray(W)&&Array.isArray(se)?!vr(W,se,(ve,Fe)=>Ge(ve,Fe,j)):W!==se}$n(M,()=>{O(l),X(Te(M)),B.change(M)});const We=Q((W,se)=>{a?.(W,se),!se.isCanceled&&(ue(W),!W&&(se.reason===Gt||se.reason===Mn)&&(ee(!0),me(!1),P==="onBlur"&&B.commit(M)))}),je=Q(()=>{he(!1),D.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),z?.(!1)});Vt({enabled:!U,open:_,ref:Y,onComplete(){_||je()}}),o.useImperativeHandle(U,()=>({unmount:je}),[je]);const Ae=Q((W,se)=>{c?.(W,se),!se.isCanceled&&ce(W)}),Me=Q(W=>{const se=fn(W.scrollHeight,W.clientHeight),ve=wr(W.scrollTop,se),Fe=ve>0,Le=ve<se;D.set("scrollUpArrowVisible",Fe),D.set("scrollDownArrowVisible",Le)}),Oe=or({open:_,onOpenChange:We,elements:{reference:$,floating:x}}),ze=Gn(Oe,{enabled:!g&&!F,event:"mousedown"}),Ke=Bn(Oe),Ve=cr(Oe,{enabled:!g&&!F,listRef:E,activeIndex:f,selectedIndex:b,disabledIndices:wt,onNavigate(W){W===null&&!_||D.set("activeIndex",W)},focusItemOnHover:h}),Ne=ur(Oe,{enabled:!g&&!F&&(_||!V),listRef:L,activeIndex:f,selectedIndex:b,disabledIndices:W=>dr(E.current[W]),onMatch(W){_?D.set("activeIndex",W):Ae(re.current[W],Ie(gt))},onTyping(W){J.current=W}}),nt=o.useMemo(()=>Pt(Ne.reference,Ve.reference,Ke.reference,ze.reference,pe),[ze.reference,Ne.reference,Ve.reference,Ke.reference,pe]),rt=o.useMemo(()=>Pt(_n,Ne.floating,Ve.floating,Ke.floating),[Ne.floating,Ve.floating,Ke.floating]),ot=Ve.item??Qt;ar(()=>{D.update({popupProps:rt,triggerProps:nt})}),D.useSyncedValues({id:q,modal:T,multiple:V,value:M,open:_,mounted:fe,transitionStatus:G,popupProps:rt,triggerProps:nt,items:K,itemToStringLabel:R,itemToStringValue:I,isItemEqualToValue:j,openMethod:Ce});const Ee=o.useMemo(()=>({store:D,floatingContext:Oe,required:S,disabled:F,readOnly:g,multiple:V,highlightItemOnHover:h,setValue:Ae,setOpen:We,listRef:E,popupRef:Y,scrollHandlerRef:ie,handleScrollArrowVisibility:Me,scrollArrowsMountedCountRef:ye,itemProps:ot,valueRef:H,valuesRef:re,labelsRef:L,typingRef:J,selectionRef:ae,firstItemTextRef:be,selectedItemTextRef:le,validation:B,onOpenChangeComplete:z,alignItemWithTriggerActiveRef:ge,initialValueRef:yt}),[D,Oe,S,F,g,V,h,Ae,We,ot,B,z,Me]),qe=Sn(u,B.inputRef),Qe=V?void 0:l,It=o.useMemo(()=>!V||!Array.isArray(M)||!l?null:M.map(W=>{const se=Ye(W,I);return Re.jsx("input",{type:"hidden",form:m,name:l,value:se,disabled:F},se)}),[V,M,m,l,I,F]);return Re.jsxs(on.Provider,{value:Ee,children:[y,Re.jsx("input",{...B.getValidationProps(F,{onFocus(){D.state.triggerElement?.focus({focusVisible:!0})},onChange(W){if(W.nativeEvent.defaultPrevented||F||g)return;const se=W.currentTarget.value,ve=Ie(gt,W.nativeEvent);function Fe(){if(V)return;const Le=se.toLowerCase();let He=re.current.findIndex(St=>Ye(St,I).toLowerCase()===Le||un(St,R).toLowerCase()===Le);He===-1&&(He=re.current.findIndex((St,hn)=>{const Nt=L.current[hn];return Nt!=null&&Nt.toLowerCase()===Le}));const Dt=re.current[He];Dt!=null&&Ae(Dt,ve)}D.set("forceMount",!0),queueMicrotask(Fe)}}),id:q&&Qe==null?`${q}-hidden-input`:void 0,form:m,name:Qe,autoComplete:C,value:de,disabled:F,required:S&&!(V&&Je),readOnly:g,ref:qe,style:l?En:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),It]})}function Pr(e,t){return e??t}const lt=5;function Ar(e,t){const n=Or(t);return e.clientX>=n.left-lt&&e.clientX<=n.right+lt&&e.clientY>=n.top-lt&&e.clientY<=n.bottom+lt}function Or(e){const t=e.getBoundingClientRect(),n=dt(e);if(vn)return t;const r=n.getComputedStyle(e,"::before"),c=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||c.content!=="none"))return t;const s=parseFloat(r.width)||0,a=parseFloat(r.height)||0,d=parseFloat(c.width)||0,m=parseFloat(c.height)||0,C=Math.max(t.width,s,d),p=Math.max(t.height,a,m),g=C-t.width,S=p-t.height;return{left:t.left-g/2,right:t.right+g/2,top:t.top-S/2,bottom:t.bottom+S/2}}const Vr=400,Fr={...Wn,...hr,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=o.forwardRef(function(t,n){const{render:r,className:c,id:i,disabled:s=!1,nativeButton:a=!0,style:d,...m}=t,{setTouched:C,setFocused:p,validationMode:g,state:S,disabled:T}=Ft(),{labelId:U}=sn(),{store:u,setOpen:z,selectionRef:K,validation:V,readOnly:R,required:I,alignItemWithTriggerActiveRef:j,disabled:h}=Ue(),y=T||h||s,O=A(u,v.open),X=A(u,v.mounted),ee=A(u,v.value),me=A(u,v.triggerProps),te=A(u,v.positionerElement),w=A(u,v.listElement),N=A(u,v.popupSide),ne=A(u,v.id),B=A(u,v.labelId),P=A(u,v.hasSelectedValue),q=X&&te?N:null,F=i??ne,l=Pr(U,B);ln({id:F});const M=ke(te),ce=o.useRef(null),{getButtonProps:_,buttonRef:ue}=Zt({disabled:y,native:a}),E=u.useStateSetter("triggerElement"),L=ft(),Y=ft(),ie=ft();o.useEffect(()=>{if(O)return ie.start(Vr,()=>{K.current.allowUnselectedMouseUp=!0,K.current.allowSelectedMouseUp=!0}),()=>{ie.clear()};K.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},Y.clear()},[O,K,Y,ie]);const ye=Pt(me,{id:F,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?w?.id??$t(te)?.id:void 0,"aria-labelledby":l,"aria-readonly":R||void 0,"aria-required":I||void 0,tabIndex:y?-1:0,onFocus(J){p(!0),O&&j.current&&z(!1,Ie(gt,J.nativeEvent)),L.start(0,()=>{u.set("forceMount",!0)})},onBlur(J){De(te,J.relatedTarget)||(C(!0),p(!1),g==="onBlur"&&V.commit(ee))},onMouseDown(J){if(O)return;const be=tt(J.currentTarget);function le(ae){if(!ce.current)return;const ge=ae.target;De(ce.current,ge)||De(M.current,ge)||Ar(ae,ce.current)||z(!1,Ie(wn,ae))}Y.start(0,()=>{be.addEventListener("mouseup",le,{once:!0})})}},m,_),H=V.getValidationProps(y,ye);H.role="combobox";const re={...S,open:O,disabled:y,value:ee,readOnly:R,popupSide:q,placeholder:!P};return Xe("button",t,{ref:[n,ce,ue,E],state:re,stateAttributesMapping:Fr,props:H})}),Lr={value:()=>null},ro=o.forwardRef(function(t,n){const{className:r,render:c,children:i,placeholder:s,style:a,...d}=t,{store:m,valueRef:C}=Ue(),p=A(m,v.value),g=A(m,v.items),S=A(m,v.itemToStringLabel),T=A(m,v.hasSelectedValue),U=!T&&s!=null&&i==null,u=A(m,v.hasNullItemLabel,U),z={value:p,placeholder:!T};let K=null;return typeof i=="function"?K=i(p):i!=null?K=i:U&&!u?K=s:Array.isArray(p)?K=Cr(p,g,S):K=an(p,g,S),Xe("span",t,{state:z,ref:[n,C],props:[{children:K},d],stateAttributesMapping:Lr})}),oo=o.forwardRef(function(t,n){const{store:r}=Ue(),c=A(r,v.mounted),i=A(r,v.forceMount);return c||i?Re.jsx(Pn,{ref:n,...t}):null}),dn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Dr(){return o.useContext(dn)}function Nr(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:c}=e,i=Q(c),[,s]=o.useState(!1),a=$e(kr).current,d=$e(Hr).current,m=o.useRef(0),C=o.useRef(!0),p=o.useRef([]),g=o.useRef(null),S=Q(()=>{C.current||(C.current=!0,s(I=>!I))}),T=Q((I,j)=>{d.set(I,j),S()}),U=Q(I=>{d.delete(I),S()}),u=Q(I=>{const j=new Map;return n.current.length=0,r&&(r.current.length=0),I.forEach(h=>{j.set(h.element,{...h.registration.metadata??{},index:h.index}),n.current[h.index]=h.element,r&&(r.current[h.index]=h.registration.label!==void 0?h.registration.label:h.registration.textRef?.current?.textContent??h.element.textContent)}),m.current=n.current.length,j});function z(I){if(g.current?.disconnect(),g.current=null,typeof MutationObserver!="function"||I.length<2)return;const j=new MutationObserver(y=>{if(!_r(y))return;let O=null;for(const X of I)if(X.isConnected){if(O&&pn(O,X)>0){j.disconnect(),S();return}O=X}});g.current=j;const h=new Set;for(let y=1;y<I.length;y+=1){const O=Br(I[y-1],I[y]);O&&h.add(O)}h.forEach(y=>j.observe(y,{childList:!0}))}const K=Q(()=>{const[I,j]=Ur(d),h=u(I);z(j),p.current=I,C.current=!1,a.forEach(y=>y(h)),i(h)});Z(()=>(C.current||u(p.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,u]),Z(()=>{C.current&&K()}),Z(()=>()=>{g.current?.disconnect(),C.current=!0},[]);const V=Q(I=>(a.add(I),()=>{a.delete(I)})),R=o.useMemo(()=>({register:T,unregister:U,subscribeMapChange:V,nextIndexRef:m}),[T,U,V,m]);return Re.jsx(dn.Provider,{value:R,children:t})}function Hr(){return new Map}function kr(){return new Set}function Ur(e){const t=new Set,n=[],r=[];e.forEach((i,s)=>{if(!s.isConnected)return;const a=i.index,d={index:a??-1,element:s,registration:i};a===null?r.push(d):a>=0&&(t.add(a),n.push(d))});let c=0;return r.sort((i,s)=>pn(i.element,s.element)),r.forEach(i=>{for(;t.has(c);)c+=1;i.index=c,n.push(i),c+=1}),t.size>0&&n.sort((i,s)=>i.index-s.index),[n,r.map(i=>i.element)]}function Br(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function _r(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function pn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const gn=o.createContext(void 0);function Wr(){const e=o.useContext(gn);if(!e)throw new Error(bt(59));return e}function mt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},zr={position:"fixed"},so=o.forwardRef(function(t,n){const{anchor:r,className:c,render:i,positionMethod:s,side:a,align:d,sideOffset:m,alignOffset:C,collisionBoundary:p="clipping-ancestors",collisionPadding:g,arrowPadding:S,sticky:T,disableAnchorTracking:U,alignItemWithTrigger:u=!0,collisionAvoidance:z=An,style:K,...V}=t,{store:R,listRef:I,labelsRef:j,alignItemWithTriggerActiveRef:h,selectedItemTextRef:y,valuesRef:O,initialValueRef:X,popupRef:ee,setValue:me,floatingContext:te}=Ue(),w=A(R,v.open),N=A(R,v.mounted),ne=A(R,v.modal),B=A(R,v.value),P=A(R,v.openMethod),q=A(R,v.positionerElement),F=A(R,v.triggerElement),l=A(R,v.isItemEqualToValue),M=A(R,v.transitionStatus),ce=o.useRef(null),_=o.useRef(null),[ue,E]=o.useState(u),L=N&&ue&&P!=="touch";!N&&ue!==u&&E(u),o.useImperativeHandle(h,()=>L),Xn((L||ne)&&w,P==="touch",q,F);const Y=Jn({anchor:r,floatingRootContext:te,positionMethod:s,mounted:N,side:a,sideOffset:m,align:d,alignOffset:C,arrowPadding:S,collisionBoundary:p,collisionPadding:g,sticky:T,disableAnchorTracking:U??L,collisionAvoidance:z,keepMounted:!0}),ie=L?"none":Y.side,ye=L?zr:Y.positionerStyles,H={open:w,side:ie,align:Y.align,anchorHidden:Y.anchorHidden};Z(()=>{R.set("popupSide",Y.side)},[R,Y.side]);const re=R.useStateSetter("positionerElement"),J=Qn(t,H,{styles:ye,transitionStatus:M,props:V,refs:[n,re],hidden:!N,inert:!w}),be=o.useRef(0),le=Q(ge=>{if(O.current.length===0)return;const fe=be.current;if(be.current=ge.size,ge.size===fe)return;const he=Ie(gt);if(fe!==0&&!R.state.multiple&&B!==null&&pt(O.current,B,l)===-1){const oe=X.current,D=oe!=null&&pt(O.current,oe,l)!==-1?oe:null;me(D,he),D===null&&(R.set("selectedIndex",null),y.current=null)}if(fe!==0&&R.state.multiple&&Array.isArray(B)){const G=B.filter(oe=>pt(O.current,oe,l)!==-1);G.length!==B.length&&(me(G,he),G.length===0&&(R.set("selectedIndex",null),y.current=null))}if(w&&L){R.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const G={height:""};mt(q,G),mt(ee.current,G)}}),ae=o.useMemo(()=>({...Y,side:ie,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:E,scrollUpArrowRef:ce,scrollDownArrowRef:_}),[Y,ie,L,E]);return Re.jsx(Nr,{elementsRef:I,labelsRef:j,onMapChange:le,children:Re.jsxs(gn.Provider,{value:ae,children:[N&&ne&&Re.jsx(jn,{inert:On(!w),cutout:F}),J]})})}),ct="base-ui-disable-scrollbar",jt={className:ct,getElement(e){return Re.jsx("style",{nonce:e,href:ct,precedence:"base-ui:low",children:`.${ct}{scrollbar-width:none}.${ct}::-webkit-scrollbar{display:none}`})}},Kr=o.createContext(void 0),qr={disableStyleElements:!1};function Yr(){return o.useContext(Kr)??qr}const $r={...Kn,...en},io=o.forwardRef(function(t,n){const{render:r,className:c,style:i,finalFocus:s,...a}=t,{store:d,popupRef:m,onOpenChangeComplete:C,setOpen:p,valueRef:g,firstItemTextRef:S,selectedItemTextRef:T,multiple:U,handleScrollArrowVisibility:u,scrollHandlerRef:z,listRef:K,highlightItemOnHover:V,floatingContext:R}=Ue(),{side:I,align:j,alignItemWithTriggerActive:h,isPositioned:y,setControlledAlignItemWithTrigger:O}=Wr(),X=Zn()!=null,ee=er(),{nonce:me,disableStyleElements:te}=Yr(),w=A(d,v.id),N=A(d,v.open),ne=A(d,v.openMethod),B=A(d,v.mounted),P=A(d,v.popupProps),q=A(d,v.transitionStatus),F=A(d,v.triggerElement),l=A(d,v.positionerElement),M=A(d,v.listElement),ce=o.useRef(!1),_=o.useRef(!1),ue=o.useRef({}),E=vt(),L=Q(H=>{if(!l||!m.current||!_.current)return;const re=l.style.top==="0px",J=l.style.bottom==="0px";if(ce.current||!h||!re&&!J){u(H);return}const be=Kt(l),le=et(l.getBoundingClientRect().height,"y",be),ae=tt(l),ge=dt(l),fe=ge.getComputedStyle(l),he=parseFloat(fe.marginTop),G=parseFloat(fe.marginBottom),oe=zt(ge.getComputedStyle(m.current)),pe=Math.min(ae.documentElement.clientHeight-he-G,oe),D=H.scrollTop,f=ut(H);let b=null;const $=de=>{l.style.height=`${de}px`},x=re?f-D:D,k=Math.min(le+x,pe);if(x<=Pe){const de=Ze(x,0,pe-le);de>0&&$(le+de),H.scrollTop=re?f:0,pe-(le+de)<=Pe&&(ce.current=!0),u(H);return}if(pe-k>Pe)b=re?1/0:0;else if(J&&D<f){const de=le+x-pe;b=D-(x-de)}const Ce=Math.ceil(k);if(Ce!==0&&$(Ce),b!=null){const de=Ze(b,0,ut(H));Math.abs(H.scrollTop-de)>Pe&&(H.scrollTop=de)}Ce>=pe-Pe&&(ce.current=!0),u(H)});o.useImperativeHandle(z,()=>L,[L]),Vt({open:N,ref:m,onComplete(){N&&C?.(!0)}});const Y={open:N,transitionStatus:q,side:I,align:j};Z(()=>{!l||!m.current||Object.keys(ue.current).length||(ue.current={top:l.style.top||"0",left:l.style.left||"0",right:l.style.right,height:l.style.height,bottom:l.style.bottom,minHeight:l.style.minHeight,maxHeight:l.style.maxHeight,marginTop:l.style.marginTop,marginBottom:l.style.marginBottom})},[m,l]),Z(()=>{N||h||(_.current=!1,ce.current=!1,mt(l,ue.current))},[N,h,l,m]),Z(()=>{const H=m.current;if(!N||!F||!l||!H||h&&!y||d.state.transitionStatus==="ending")return;if(_.current=!0,H.style.removeProperty("--transform-origin"),!h){E.request(()=>u(M||H));return}const re=Gr(H);try{let J=T.current;J?.isConnected||(J=!v.hasSelectedValue(d.state)&&S.current?.isConnected?S.current:null);const be=g.current,le=dt(l),ae=le.getComputedStyle(l),ge=le.getComputedStyle(H),fe=tt(F),he=Kt(F),G=at(F.getBoundingClientRect(),he),oe=at(l.getBoundingClientRect(),he),pe=G.height,D=M||H,f=D.scrollHeight,b=parseFloat(ge.borderBottomWidth),$=parseFloat(ae.marginTop)||10,x=parseFloat(ae.marginBottom)||10,k=parseFloat(ae.minHeight)||100,Ce=zt(ge),de=5,Be=5,_e=20,Se=fe.documentElement.clientHeight-$-x,yt=fe.documentElement.clientWidth,Je=Se-G.bottom+pe;let Te,We=ee==="rtl"?G.right-oe.width:G.left,je=0;if(J&&be){const Ee=at(be.getBoundingClientRect(),he);Te=at(J.getBoundingClientRect(),he),We=oe.left+(ee==="rtl"?Ee.right-Te.right:Ee.left-Te.left);const qe=Ee.top-G.top+Ee.height/2;je=Te.top-oe.top+Te.height/2-qe}const Ae=Je+je+x+b;let Me=Math.min(Se,Ae);const Oe=Se-$-x,ze=Ae-Me,Ke=yt-Be;l.style.left=`${Ze(We,de,Ke-oe.width)}px`,l.style.height=`${Me}px`,l.style.maxHeight="none",l.style.marginTop=`${$}px`,l.style.marginBottom=`${x}px`,H.style.height="100%";const Ve=ut(D),Ne=ze>=Ve-Pe;Ne&&(Me=Math.min(Se,oe.height)-(ze-Ve));const nt=G.top<_e||G.bottom>Se-_e||Math.ceil(Me)+Pe<Math.min(f,k),rt=(le.visualViewport?.scale??1)!==1&&Xt;if(nt||rt){mt(l,ue.current),O(!1);return}const ot=Math.max(k,Me);if(Ne){const Ee=Math.max(0,Se-Ae);l.style.top=oe.height>=Oe?"0":`${Ee}px`,l.style.height=`${Me}px`,D.scrollTop=ut(D)}else l.style.bottom="0",D.scrollTop=ze;if(Te){const Ee=oe.top,qe=oe.height,Qe=Te.top+Te.height/2,It=Ze(qe>0?(Qe-Ee)/qe*100:50,0,100);H.style.setProperty("--transform-origin",`50% ${It}%`)}(ot===Se||Me>=Ce)&&(ce.current=!0),u(D),V&&d.state.selectedIndex===null&&d.state.activeIndex===null&&K.current[0]!=null&&d.set("activeIndex",0)}finally{re()}},[d,N,l,F,g,S,T,m,u,h,O,E,M,K,V,ee,y]),o.useEffect(()=>{if(!h||!l||!N)return;const H=dt(l);function re(J){p(!1,Ie(Fn,J))}return Vn(H,"resize",re)},[p,h,l,N]);const ie={...M?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":U||void 0,id:`${w}-list`},onKeyDown(H){X&&qn.has(H.key)&&H.stopPropagation()},onScroll(H){M||L(H.currentTarget)},...h&&{style:M?{height:"100%"}:jr},className:!M&&h?jt.className:void 0},ye=Xe("div",t,{ref:[n,m],state:Y,stateAttributesMapping:$r,props:[P,ie,rr(q),a]});return Re.jsxs(o.Fragment,{children:[!te&&jt.getElement(me),Re.jsx(zn,{context:R,modal:!1,disabled:!B,openInteractionType:ne,returnFocus:s,restoreFocus:!0,children:ye})]})});function zt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function ut(e){return fn(e.scrollHeight,e.clientHeight)}function Kt(e){return tr.getScale(e)}function et(e,t,n){return e/n[t]}function at(e,t){return nr({x:et(e.x,"x",t),y:et(e.y,"y",t),width:et(e.width,"x",t),height:et(e.height,"y",t)})}const qt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[r,c]of qt)n[r]=t.getPropertyValue(r),t.setProperty(r,c,"important");return()=>{for(const[r]of qt){const c=n[r];c?t.setProperty(r,c):t.removeProperty(r)}}}function Xr(e={}){const{guess:t,label:n,metadata:r,textRef:c,index:i}=e,{register:s,unregister:a,subscribeMapChange:d,nextIndexRef:m}=Dr(),C=o.useRef(-1),[p,g]=o.useState(i==null&&t?()=>{if(C.current===-1){const u=m.current;m.current+=1,C.current=u}return C.current}:-1),S=i??p,T=o.useRef(null),U=o.useCallback(u=>{const z=T.current;z&&a(z),T.current=u,u&&s(u,{metadata:r??null,index:i??null,label:n,textRef:c})},[i,s,a,r,n,c]);return Z(()=>{if(i==null)return d(u=>{const z=T.current?u.get(T.current)?.index:null;z!=null&&g(z)})},[i,d]),{ref:U,index:S}}const mn=o.createContext(void 0);function Lt(){const e=o.useContext(mn);if(!e)throw new Error(bt(57));return e}const lo=o.memo(o.forwardRef(function(t,n){const{render:r,className:c,style:i,value:s=null,label:a,disabled:d=!1,nativeButton:m=!1,...C}=t,p=o.useRef(null),g=Xr({guess:!0,label:a,textRef:p}),{store:S,itemProps:T,setOpen:U,setValue:u,selectionRef:z,typingRef:K,valuesRef:V,multiple:R,selectedItemTextRef:I,disabled:j,readOnly:h}=Ue(),y=j||d,O=A(S,v.isActive,g.index),X=A(S,v.open),ee=A(S,v.isSelected,s),me=A(S,v.isSelectedByFocus,g.index),te=A(S,v.isItemEqualToValue),w=g.index,N=o.useRef(null);Z(()=>{const E=V.current;return E[w]=s,()=>{delete E[w]}},[w,s,V]),Z(()=>{const E=S.state.value;let L=E;R&&Array.isArray(E)&&(L=E.length>0?E[E.length-1]:void 0),L!==void 0&&Ge(s,L,te)&&(S.set("selectedIndex",w),p.current&&(I.current=p.current))},[w,R,te,S,s,I]);const ne=o.useRef("mouse"),B=o.useRef(!1),{getButtonProps:P,buttonRef:q}=Zt({disabled:y,focusableWhenDisabled:!0,native:m,composite:!0}),F={disabled:y,selected:ee,highlighted:O};function l(E){if(j||h)return;const L=S.state.value;if(R){const Y=Array.isArray(L)?L:[],ie=ee?Sr(Y,s,te):[...Y,s];u(ie,Ie(Tt,E))}else u(s,Ie(Tt,E)),U(!1,Ie(Tt,E))}function M(){z.current.dragY=0}const ce={role:"option","aria-selected":ee,tabIndex:X&&O?0:-1,onKeyDown(E){S.set("activeIndex",w),E.key===" "&&K.current&&E.preventDefault()},onClick(E){const L=ne.current!=="touch",Y=E.nativeEvent.pointerType,ie=L&&nn(E.nativeEvent)&&(Y!==void 0||O),ye=L&&!ie&&!B.current;B.current=!1,!(y||ye)&&l(E.nativeEvent)},onPointerEnter(E){ne.current=E.pointerType},onPointerMove(E){if(E.pointerType==="mouse"&&E.buttons===1){const L=z.current;L.dragY+=E.movementY,L.dragY**2>=64&&(L.allowUnselectedMouseUp=!0)}},onPointerDown(E){ne.current=E.pointerType,B.current=!0,M()},onMouseUp(){if(M(),y||ne.current==="touch"||B.current)return;const E=!z.current.allowSelectedMouseUp&&ee,L=!z.current.allowUnselectedMouseUp&&!ee;E||L||(B.current=!0,N.current?.click(),B.current=!1)}},_=Xe("div",t,{ref:[q,n,g.ref,N],state:F,props:[T,ce,C,P]}),ue=o.useMemo(()=>({selected:ee,index:w,textRef:p,selectedByFocus:me}),[ee,w,p,me]);return Re.jsx(mn.Provider,{value:ue,children:_})})),co=o.forwardRef(function(t,n){const{selected:r}=Lt();return t.keepMounted||r?Re.jsx(Jr,{...t,ref:n}):null}),Jr=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:c,keepMounted:i,...s}=e,{selected:a}=Lt(),d=o.useRef(null),{transitionStatus:m,setMounted:C}=rn(a),g=Xe("span",e,{ref:[t,d],state:{selected:a,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:en});return Vt({open:a,ref:d,onComplete(){a||C(!1)}}),g})),uo=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:c,selectedByFocus:i}=Lt(),{firstItemTextRef:s,selectedItemTextRef:a}=Ue(),{render:d,className:m,style:C,...p}=t,g=o.useCallback(T=>{T&&(r===0&&(s.current=T),i&&(a.current=T))},[s,a,r,i]);return Xe("div",t,{ref:[g,n,c],props:p})}));export{jr as L,to as S,Wr as a,jt as b,no as c,ro as d,oo as e,so as f,io as g,lo as h,co as i,uo as j,hr as k,Mr as l,Ft as m,sn as n,Wt as o,Rr as p,v as s,Ue as u};
|
|
1
|
+
import{bT as xn,aI as $e,aF as Z,bd as Yt,bW as $t,bU as bn,r as o,bc as Q,bx as vt,cg as Ht,ch as Et,ci as kt,b_ as Ct,be as tt,aE as De,A as Ie,cj as Ut,bw as Bt,ck as st,aD as Rn,bn as Gt,c0 as Xt,cl as ht,cm as xt,cn as Jt,co as Ot,bb as ft,c2 as yn,cp as In,cq as wt,ay as bt,aJ as xe,Z as Qt,j as Re,V as A,aA as Vt,aL as Pt,aK as Sn,aO as En,aP as Cn,aQ as gt,aG as Tn,b$ as Mn,aN as dt,bQ as vn,y as Zt,z as Xe,cr as wn,aB as Pn,cs as An,aC as On,bg as Vn,ct as Fn,az as en,cu as Tt}from"./__vite-browser-external-B-XC2p3L.js";import{q as tn,F as Ln,P as Dn,v as ke,o as Nn,E as Hn,G as we,H as nn,D as kn,u as Un,m as rn,e as Bn,d as _n,z as Wn,I as jn,b as zn,a as Kn,C as qn}from"./useScrollLock-CPs_4XCs.js";import{h as Yn,u as $n,a as Gn,d as Xn,c as Jn,e as Qn,f as Zn,i as er,p as tr,r as nr,g as rr}from"./ToolbarRootContext-Dql3cfna.js";function Ze(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function or(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,c=xn(),i=tn()!=null,s=$e(()=>new Ln({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Dn,floatingId:c,syncOnly:!1,nested:i})).current;return Z(()=>{const a={open:t,floatingId:c};r.reference!==void 0&&(a.referenceElement=r.reference,a.domReferenceElement=Yt(r.reference)?r.reference:null),r.floating!==void 0&&(a.floatingElement=r.floating),s.update(a)},[t,c,r.reference,r.floating,s]),s.context.onOpenChange=n,s.context.nested=i,s}const sr="Escape";function _t(e){return Xt&&e.movementX===0&&e.movementY===0}function Rt(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function it(e,t){return Rt(t,e===Jt||e===Ot,e===ht||e===xt)}function Mt(e,t,n){return Rt(t,e===Ot,n?e===ht:e===xt)||e==="Enter"||e===" "||e===""}function ir(e,t,n){return Rt(t,n?e===ht:e===xt,e===Ot)}function lr(e,t,n,r){const c=n?e===xt:e===ht,i=e===Jt;return t==="both"||t==="horizontal"&&r?e===sr:Rt(t,c,i)}function cr(e,t){const{listRef:n,activeIndex:r,onNavigate:c=()=>{},enabled:i=!0,selectedIndex:s=null,allowEscape:a=!1,loopFocus:d=!1,nested:m=!1,rtl:C=!1,virtual:p=!1,focusItemOnOpen:g="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:T=!0,disabledIndices:U=void 0,orientation:u="vertical",parentOrientation:z,id:K,resetOnPointerLeave:V=!0,externalTree:R,grid:I}=t,j=I!=null,h="rootStore"in e?e.rootStore:e,y=h.useState("open"),O=h.useState("floatingElement"),X=h.useState("domReferenceElement"),ee=h.context.dataRef,me=$t(O),te=bn(X),w=ke(me),N=tn(),ne=Nn(R),B=o.useRef(g),P=o.useRef(s??-1),q=o.useRef(null),F=o.useRef(!0),l=Q(f=>{c(P.current===-1?null:P.current,f)}),M=o.useRef(!!O),ce=o.useRef(y),_=o.useRef(!1),ue=o.useRef(!1),E=o.useRef(null),L=ke(U),Y=ke(y),ie=ke(s),ye=ke(V),H=vt(),re=vt(),J=Q(()=>{function f(k){p?ne?.events.emit("virtualfocus",k):E.current=Hn(k,{sync:_.current,preventScroll:!0})}const b=n.current[P.current],$=ue.current;b&&f(b),(_.current?k=>k():k=>H.request(k))(()=>{const k=n.current[P.current]||b;if(!k)return;b||f(k),he&&($||!F.current)&&k.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Z(()=>{ee.current.orientation=u},[ee,u]),Z(()=>{i&&(y&&O?(P.current=s??-1,B.current&&s!=null&&(ue.current=!0,l())):M.current&&(P.current=-1,l()))},[i,y,O,s,l]),Z(()=>{if(i){if(!y){_.current=!1;return}if(O)if(r==null){if(_.current=!1,ie.current!=null)return;if(M.current&&(P.current=-1,J()),(!ce.current||!M.current)&&B.current&&(q.current!=null||B.current===!0&&q.current==null)){let f=0;const b=()=>{n.current[0]==null?(f<2&&(f?x=>re.request(x):queueMicrotask)(b),f+=1):(P.current=q.current==null||Mt(q.current,u,C)||m?Et(n):kt(n),q.current=null,l())};b()}}else Ht(n.current,r)||(P.current=r,J(),ue.current=!1)}},[i,y,O,r,ie,m,n,u,C,l,J,re]),Z(()=>{if(!i||O||!ne||p||!M.current)return;const f=ne.nodesRef.current,b=f.find(k=>k.id===N)?.context?.elements.floating,$=Ct(tt(X??b??null)),x=f.some(k=>k.context&&De(k.context.elements.floating,$));b&&!x&&F.current&&b.focus({preventScroll:!0})},[i,O,X,ne,N,p]),Z(()=>{ce.current=y,M.current=!!O}),Z(()=>{y||(q.current=null,B.current=g)},[y,g]);const be=r!=null,le=Q(f=>{if(!Y.current)return;const b=n.current.indexOf(f.currentTarget);b!==-1&&(P.current!==b||r!==b)&&(P.current=b,l(f))}),ae=Q(()=>z??ne?.nodesRef.current.find(f=>f.id===N)?.context?.dataRef?.current.orientation),ge=Q(()=>Et(n,L.current)),fe=Q(f=>{if(F.current=!1,_.current=!0,f.which===229||!Y.current&&f.currentTarget===w.current)return;if(m&&lr(f.key,u,C,j)){it(f.key,ae())||we(f),h.setOpen(!1,Ie(Ut,f.nativeEvent)),Bt(X)&&(p?ne?.events.emit("virtualfocus",X):X.focus());return}const b=P.current,$=Et(n,U),x=kt(n,U);if(te||(f.key==="Home"&&(we(f),P.current=$,l(f)),f.key==="End"&&(we(f),P.current=x,l(f))),I!=null){const k=I(f,P.current,n,u,d,C,U,$,x);if(k!=null&&(P.current=k,l(f)),u==="both")return}if(it(f.key,u)){if(we(f),y&&!p&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){P.current=Mt(f.key,u,C)?$:x,l(f);return}Mt(f.key,u,C)?d?b>=x?a&&b!==n.current.length?P.current=-1:(_.current=!1,P.current=$):P.current=st(n.current,{startingIndex:b,disabledIndices:U}):P.current=Math.min(x,st(n.current,{startingIndex:b,disabledIndices:U})):d?b<=$?a&&b!==-1?P.current=n.current.length:(_.current=!1,P.current=x):P.current=st(n.current,{startingIndex:b,decrement:!0,disabledIndices:U}):P.current=Math.max($,st(n.current,{startingIndex:b,decrement:!0,disabledIndices:U})),Ht(n.current,P.current)&&(P.current=-1),l(f)}}),he=o.useMemo(()=>({onFocus(b){_.current=!0,le(b)},onClick:({currentTarget:b})=>b.focus({preventScroll:!0}),onMouseMove(b){_t(b)||(_.current=!0,ue.current=!1,S&&le(b))},onPointerLeave(b){if(!Y.current||!F.current||b.pointerType==="touch")return;_.current=!0;const $=b.relatedTarget;if(!(!S||n.current.includes($))&&ye.current&&(E.current?.(),E.current=null,P.current=-1,l(b),!p)){const x=w.current,k=Ct(tt(x));x&&De(x,k)&&x.focus({preventScroll:!0})}}}),[le,Y,w,S,n,l,ye,p]),G=o.useMemo(()=>p&&y&&be&&{"aria-activedescendant":`${K}-${r}`},[p,y,be,K,r]),oe=o.useMemo(()=>({"aria-orientation":u==="both"?void 0:u,...te?{}:G,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&y&&!p){const b=Rn(f.nativeEvent);if(b&&!De(w.current,b))return;we(f),h.setOpen(!1,Ie(Gt,f.nativeEvent)),Bt(X)&&X.focus();return}fe(f)},onPointerMove(f){_t(f)||(F.current=!0)}}),[G,fe,w,u,te,h,y,p,X]),pe=o.useMemo(()=>{function f(x){h.setOpen(!0,Ie(Ut,x.nativeEvent,x.currentTarget))}function b(x){g==="auto"&&nn(x.nativeEvent)&&(B.current=!p)}function $(x){B.current=g,g==="auto"&&kn(x.nativeEvent)&&(B.current=!0)}return{onKeyDown(x){const k=h.select("open");F.current=!1;const Ce=x.key.startsWith("Arrow"),de=ir(x.key,ae(),C),Be=it(x.key,u),_e=(m?de:Be)||x.key==="Enter"||x.key.trim()==="";if(p&&k)return fe(x);if(!(!k&&!T&&Ce)){if(_e){const Se=it(x.key,ae());q.current=m&&Se?null:x.key}if(m){de&&(we(x),k?(P.current=ge(),l(x)):f(x));return}Be&&(ie.current!=null&&(P.current=ie.current),we(x),!k&&T?f(x):fe(x),k&&l(x))}},onFocus(x){h.select("open")&&!p&&(P.current=-1,l(x))},onPointerDown:$,onPointerEnter:$,onMouseDown:b,onClick:b}},[fe,g,ge,m,l,h,T,u,ae,C,ie,p]),D=o.useMemo(()=>({...G,...pe}),[G,pe]);return o.useMemo(()=>i?{reference:D,floating:oe,item:he,trigger:pe}:{},[i,D,oe,pe,he])}function ur(e,t){const{listRef:n,elementsRef:r,activeIndex:c,onMatch:i,disabledIndices:s,onTyping:a,enabled:d=!0,resetMs:m=750,selectedIndex:C=null}=t,p="rootStore"in e?e.rootStore:e,g=p.useState("open"),S=ft(),T=o.useRef(""),U=o.useRef(C??c??-1),u=o.useRef(null),z=Q(R=>{function I(w){return r?.current[w]}function j(w){const N=I(w);return N&&!yn(N)||N?.matches(":disabled")?!1:s==null||!In(wt,w,s)}function h(w,N,ne=0){if(w.length===0)return-1;const B=(ne%w.length+w.length)%w.length,P=N.toLowerCase();for(let q=0;q<w.length;q+=1){const F=(B+q)%w.length;if(!(!w[F]?.toLowerCase().startsWith(P)||!j(F)))return F}return-1}const y=n.current;if(T.current.length>0&&R.key===" "&&(we(R),a?.(!0)),T.current.length>0&&T.current[0]!==" "&&h(y,T.current)===-1&&R.key!==" "&&a?.(!1),y==null||R.key.length!==1||R.ctrlKey||R.metaKey||R.altKey)return;g&&R.key!==" "&&(we(R),a?.(!0));const O=T.current==="";O&&(U.current=C??c??-1),y.every((w,N)=>w&&j(N)?w[0]?.toLowerCase()!==w[1]?.toLowerCase():!0)&&T.current===R.key&&(T.current="",U.current=u.current),T.current+=R.key,S.start(m,()=>{T.current="",U.current=u.current,a?.(!1)});const me=((O?C??c??-1:U.current)??0)+1,te=h(y,T.current,me);te!==-1?(i?.(te),u.current=te):R.key!==" "&&(T.current="",a?.(!1))}),K=Q(R=>{const I=R.relatedTarget,j=p.select("domReferenceElement"),h=p.select("floatingElement");De(j,I)||De(h,I)||(S.clear(),T.current="",U.current=u.current,a?.(!1))});Z(()=>{!g&&C!==null||(S.clear(),u.current=null,T.current!==""&&(T.current=""))},[g,C,S]);const V=o.useMemo(()=>({onKeyDown:z,onBlur:K}),[z,K]);return o.useMemo(()=>d?{reference:V,floating:V}:{},[d,V])}function ar(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function fr(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function dr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:r="value"}){const{current:c}=o.useRef(e!==void 0),[i,s]=o.useState(t),a=c?e:i,d=o.useCallback(m=>{c||s(m)},[]);return[a,d]}const on=o.createContext(null);function Ue(){const e=o.useContext(on);if(e===null)throw new Error(bt(60));return e}const pr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},gr={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},mr={disabled:!1,...gr},hr={valid(e){return e===null?null:e?{"data-valid":""}:{"data-invalid":""}}},xr={invalid:void 0,name:void 0,validityData:{state:pr,errors:[],error:"",value:"",initialValue:null},setValidityData:xe,disabled:void 0,setTouched:xe,setDirty:xe,setFilled:xe,setFocused:xe,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:mr,registerFieldControl:xe,validation:{getValidationProps:(e,t=Qt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:xe,getInputControl:()=>null,commit:async()=>{},change:xe}},br=o.createContext(xr);function Ft(e=!0){const t=o.useContext(br);if(t.setValidityData===xe&&!e)throw new Error(bt(28));return t}function Rr(e,t,n,r,c=!0,i){const{registerFieldControl:s}=Ft(),a=$e(()=>Symbol());Z(()=>{const d=a.current;if(!c){s(d,void 0);return}s(d,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,c,r,t,i,s,a,n]),Z(()=>{const d=a.current;return()=>{s(d,void 0)}},[s,a])}const yr=o.createContext({controlId:void 0,registerControlId:xe,labelId:void 0,setLabelId:xe,messageIds:[],setMessageIds:xe,getDescriptionProps:e=>e});function sn(){return o.useContext(yr)}function ln(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:c,registerControlId:i}=sn(),s=Un(t),a=n?c:void 0,d=$e(()=>Symbol()),m=o.useRef(!1),C=o.useRef(t!=null),p=Q(()=>{!m.current||i===xe||(m.current=!1,i(d.current,void 0))});return Z(()=>{if(i===xe)return;let g;if(n){const S=r?.current;Yt(S)&&S.closest("label")!=null?g=t??null:g=a??s}else if(t!=null)C.current=!0,g=t;else if(C.current)g=s;else{p();return}if(g===void 0){p();return}m.current=!0,i(d.current,g)},[t,r,a,i,n,s,d,p]),o.useEffect(()=>p,[p]),c??s}const Ir=(e,t)=>Object.is(e,t);function Ge(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function pt(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Ge(r,t,n))}function Sr(e,t,n){return e.filter(r=>!Ge(t,r,n))}function At(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function cn(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Er(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(cn(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function un(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return At(e)}function Ye(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?At(e.value):At(e)}function an(e,t,n){function r(){return un(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const c=t,i=cn(c)?c.flatMap(s=>s.items):c;if(e==null||typeof e!="object"){const s=i.find(a=>a.value===e);return s&&s.label!=null?s.label:r()}if("value"in e){const s=i.find(a=>a&&a.value===e.value);if(s&&s.label!=null)return s.label}}return r()}function Cr(e,t,n){return e.reduce((r,c,i)=>(i>0&&r.push(", "),r.push(Re.jsx(o.Fragment,{children:an(c,t,n)},i)),r),[])}const v={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ye(t,r)!==""},hasNullItemLabel:(e,t)=>t?Er(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(c=>Ge(t,c,n)):Ge(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},Tr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:xe,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function Mr(){return o.useContext(Tr)}function vr(e,t,n=(r,c)=>r===c){return e.length===t.length&&e.every((r,c)=>n(r,t[c]))}const Pe=1;function fn(e,t){return Math.max(0,e-t)}function wr(e,t){if(t<=0)return 0;const n=Ze(e,0,t),r=n,c=t-n,i=r<=Pe,s=c<=Pe;return i&&s?r<=c?0:t:i?0:s?t:n}function to(e){const{id:t,value:n,defaultValue:r=null,onValueChange:c,open:i,defaultOpen:s=!1,onOpenChange:a,name:d,form:m,autoComplete:C,disabled:p=!1,readOnly:g=!1,required:S=!1,modal:T=!0,actionsRef:U,inputRef:u,onOpenChangeComplete:z,items:K,multiple:V=!1,itemToStringLabel:R,itemToStringValue:I,isItemEqualToValue:j=Ir,highlightItemOnHover:h=!0,children:y}=e,{clearErrors:O}=Mr(),{setDirty:X,setTouched:ee,setFocused:me,validityData:te,setFilled:w,name:N,disabled:ne,validation:B,validationMode:P}=Ft(),q=ln({id:t}),F=ne||p,l=N??d,[M,ce]=Wt({controlled:n,default:V?r??wt:r,name:"Select",state:"value"}),[_,ue]=Wt({controlled:i,default:s,name:"Select",state:"open"}),E=o.useRef([]),L=o.useRef([]),Y=o.useRef(null),ie=o.useRef(null),ye=o.useRef(0),H=o.useRef(null),re=o.useRef([]),J=o.useRef(!1),be=o.useRef(null),le=o.useRef(null),ae=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ge=o.useRef(!1),{mounted:fe,setMounted:he,transitionStatus:G}=rn(_),{openMethod:oe,triggerProps:pe}=Yn(_),D=$e(()=>new Tn({id:q,labelId:void 0,modal:T,multiple:V,itemToStringLabel:R,itemToStringValue:I,isItemEqualToValue:j,value:M,open:_,mounted:fe,transitionStatus:G,items:K,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,f=A(D,v.activeIndex),b=A(D,v.selectedIndex),$=A(D,v.triggerElement),x=A(D,v.positionerElement),k=fr(oe),Ce=oe??k,de=o.useMemo(()=>V?"":Ye(M,I),[V,M,I]),Be=o.useMemo(()=>V&&Array.isArray(M)?M.map(W=>Ye(W,I)):Ye(M,I),[V,M,I]),_e=ke($),Se=Q(()=>Be);Rr(_e,q,M,Se,!F,d);const yt=o.useRef(M),Je=V?Array.isArray(M)&&M.length>0:M!=null&&de!=="";Z(()=>{w(Je)},[Je,w]),Z(function(){let se=M,ve=!1;if(V){const He=Array.isArray(M)?M:[];ve=He.length===0,se=He[He.length-1]}const Fe=ve?-1:pt(re.current,se,j),Le=Fe===-1?null:Fe;Le===null&&(le.current=null),!_&&D.set("selectedIndex",Le)},[V,_,M,j,D]);function Te(W){const se=te.initialValue;return Array.isArray(W)&&Array.isArray(se)?!vr(W,se,(ve,Fe)=>Ge(ve,Fe,j)):W!==se}$n(M,()=>{O(l),X(Te(M)),B.change(M)});const We=Q((W,se)=>{a?.(W,se),!se.isCanceled&&(ue(W),!W&&(se.reason===Gt||se.reason===Mn)&&(ee(!0),me(!1),P==="onBlur"&&B.commit(M)))}),je=Q(()=>{he(!1),D.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),z?.(!1)});Vt({enabled:!U,open:_,ref:Y,onComplete(){_||je()}}),o.useImperativeHandle(U,()=>({unmount:je}),[je]);const Ae=Q((W,se)=>{c?.(W,se),!se.isCanceled&&ce(W)}),Me=Q(W=>{const se=fn(W.scrollHeight,W.clientHeight),ve=wr(W.scrollTop,se),Fe=ve>0,Le=ve<se;D.set("scrollUpArrowVisible",Fe),D.set("scrollDownArrowVisible",Le)}),Oe=or({open:_,onOpenChange:We,elements:{reference:$,floating:x}}),ze=Gn(Oe,{enabled:!g&&!F,event:"mousedown"}),Ke=Bn(Oe),Ve=cr(Oe,{enabled:!g&&!F,listRef:E,activeIndex:f,selectedIndex:b,disabledIndices:wt,onNavigate(W){W===null&&!_||D.set("activeIndex",W)},focusItemOnHover:h}),Ne=ur(Oe,{enabled:!g&&!F&&(_||!V),listRef:L,activeIndex:f,selectedIndex:b,disabledIndices:W=>dr(E.current[W]),onMatch(W){_?D.set("activeIndex",W):Ae(re.current[W],Ie(gt))},onTyping(W){J.current=W}}),nt=o.useMemo(()=>Pt(Ne.reference,Ve.reference,Ke.reference,ze.reference,pe),[ze.reference,Ne.reference,Ve.reference,Ke.reference,pe]),rt=o.useMemo(()=>Pt(_n,Ne.floating,Ve.floating,Ke.floating),[Ne.floating,Ve.floating,Ke.floating]),ot=Ve.item??Qt;ar(()=>{D.update({popupProps:rt,triggerProps:nt})}),D.useSyncedValues({id:q,modal:T,multiple:V,value:M,open:_,mounted:fe,transitionStatus:G,popupProps:rt,triggerProps:nt,items:K,itemToStringLabel:R,itemToStringValue:I,isItemEqualToValue:j,openMethod:Ce});const Ee=o.useMemo(()=>({store:D,floatingContext:Oe,required:S,disabled:F,readOnly:g,multiple:V,highlightItemOnHover:h,setValue:Ae,setOpen:We,listRef:E,popupRef:Y,scrollHandlerRef:ie,handleScrollArrowVisibility:Me,scrollArrowsMountedCountRef:ye,itemProps:ot,valueRef:H,valuesRef:re,labelsRef:L,typingRef:J,selectionRef:ae,firstItemTextRef:be,selectedItemTextRef:le,validation:B,onOpenChangeComplete:z,alignItemWithTriggerActiveRef:ge,initialValueRef:yt}),[D,Oe,S,F,g,V,h,Ae,We,ot,B,z,Me]),qe=Sn(u,B.inputRef),Qe=V?void 0:l,It=o.useMemo(()=>!V||!Array.isArray(M)||!l?null:M.map(W=>{const se=Ye(W,I);return Re.jsx("input",{type:"hidden",form:m,name:l,value:se,disabled:F},se)}),[V,M,m,l,I,F]);return Re.jsxs(on.Provider,{value:Ee,children:[y,Re.jsx("input",{...B.getValidationProps(F,{onFocus(){D.state.triggerElement?.focus({focusVisible:!0})},onChange(W){if(W.nativeEvent.defaultPrevented||F||g)return;const se=W.currentTarget.value,ve=Ie(gt,W.nativeEvent);function Fe(){if(V)return;const Le=se.toLowerCase();let He=re.current.findIndex(St=>Ye(St,I).toLowerCase()===Le||un(St,R).toLowerCase()===Le);He===-1&&(He=re.current.findIndex((St,hn)=>{const Nt=L.current[hn];return Nt!=null&&Nt.toLowerCase()===Le}));const Dt=re.current[He];Dt!=null&&Ae(Dt,ve)}D.set("forceMount",!0),queueMicrotask(Fe)}}),id:q&&Qe==null?`${q}-hidden-input`:void 0,form:m,name:Qe,autoComplete:C,value:de,disabled:F,required:S&&!(V&&Je),readOnly:g,ref:qe,style:l?En:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),It]})}function Pr(e,t){return e??t}const lt=5;function Ar(e,t){const n=Or(t);return e.clientX>=n.left-lt&&e.clientX<=n.right+lt&&e.clientY>=n.top-lt&&e.clientY<=n.bottom+lt}function Or(e){const t=e.getBoundingClientRect(),n=dt(e);if(vn)return t;const r=n.getComputedStyle(e,"::before"),c=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||c.content!=="none"))return t;const s=parseFloat(r.width)||0,a=parseFloat(r.height)||0,d=parseFloat(c.width)||0,m=parseFloat(c.height)||0,C=Math.max(t.width,s,d),p=Math.max(t.height,a,m),g=C-t.width,S=p-t.height;return{left:t.left-g/2,right:t.right+g/2,top:t.top-S/2,bottom:t.bottom+S/2}}const Vr=400,Fr={...Wn,...hr,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=o.forwardRef(function(t,n){const{render:r,className:c,id:i,disabled:s=!1,nativeButton:a=!0,style:d,...m}=t,{setTouched:C,setFocused:p,validationMode:g,state:S,disabled:T}=Ft(),{labelId:U}=sn(),{store:u,setOpen:z,selectionRef:K,validation:V,readOnly:R,required:I,alignItemWithTriggerActiveRef:j,disabled:h}=Ue(),y=T||h||s,O=A(u,v.open),X=A(u,v.mounted),ee=A(u,v.value),me=A(u,v.triggerProps),te=A(u,v.positionerElement),w=A(u,v.listElement),N=A(u,v.popupSide),ne=A(u,v.id),B=A(u,v.labelId),P=A(u,v.hasSelectedValue),q=X&&te?N:null,F=i??ne,l=Pr(U,B);ln({id:F});const M=ke(te),ce=o.useRef(null),{getButtonProps:_,buttonRef:ue}=Zt({disabled:y,native:a}),E=u.useStateSetter("triggerElement"),L=ft(),Y=ft(),ie=ft();o.useEffect(()=>{if(O)return ie.start(Vr,()=>{K.current.allowUnselectedMouseUp=!0,K.current.allowSelectedMouseUp=!0}),()=>{ie.clear()};K.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},Y.clear()},[O,K,Y,ie]);const ye=Pt(me,{id:F,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?w?.id??$t(te)?.id:void 0,"aria-labelledby":l,"aria-readonly":R||void 0,"aria-required":I||void 0,tabIndex:y?-1:0,onFocus(J){p(!0),O&&j.current&&z(!1,Ie(gt,J.nativeEvent)),L.start(0,()=>{u.set("forceMount",!0)})},onBlur(J){De(te,J.relatedTarget)||(C(!0),p(!1),g==="onBlur"&&V.commit(ee))},onMouseDown(J){if(O)return;const be=tt(J.currentTarget);function le(ae){if(!ce.current)return;const ge=ae.target;De(ce.current,ge)||De(M.current,ge)||Ar(ae,ce.current)||z(!1,Ie(wn,ae))}Y.start(0,()=>{be.addEventListener("mouseup",le,{once:!0})})}},m,_),H=V.getValidationProps(y,ye);H.role="combobox";const re={...S,open:O,disabled:y,value:ee,readOnly:R,popupSide:q,placeholder:!P};return Xe("button",t,{ref:[n,ce,ue,E],state:re,stateAttributesMapping:Fr,props:H})}),Lr={value:()=>null},ro=o.forwardRef(function(t,n){const{className:r,render:c,children:i,placeholder:s,style:a,...d}=t,{store:m,valueRef:C}=Ue(),p=A(m,v.value),g=A(m,v.items),S=A(m,v.itemToStringLabel),T=A(m,v.hasSelectedValue),U=!T&&s!=null&&i==null,u=A(m,v.hasNullItemLabel,U),z={value:p,placeholder:!T};let K=null;return typeof i=="function"?K=i(p):i!=null?K=i:U&&!u?K=s:Array.isArray(p)?K=Cr(p,g,S):K=an(p,g,S),Xe("span",t,{state:z,ref:[n,C],props:[{children:K},d],stateAttributesMapping:Lr})}),oo=o.forwardRef(function(t,n){const{store:r}=Ue(),c=A(r,v.mounted),i=A(r,v.forceMount);return c||i?Re.jsx(Pn,{ref:n,...t}):null}),dn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Dr(){return o.useContext(dn)}function Nr(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:c}=e,i=Q(c),[,s]=o.useState(!1),a=$e(kr).current,d=$e(Hr).current,m=o.useRef(0),C=o.useRef(!0),p=o.useRef([]),g=o.useRef(null),S=Q(()=>{C.current||(C.current=!0,s(I=>!I))}),T=Q((I,j)=>{d.set(I,j),S()}),U=Q(I=>{d.delete(I),S()}),u=Q(I=>{const j=new Map;return n.current.length=0,r&&(r.current.length=0),I.forEach(h=>{j.set(h.element,{...h.registration.metadata??{},index:h.index}),n.current[h.index]=h.element,r&&(r.current[h.index]=h.registration.label!==void 0?h.registration.label:h.registration.textRef?.current?.textContent??h.element.textContent)}),m.current=n.current.length,j});function z(I){if(g.current?.disconnect(),g.current=null,typeof MutationObserver!="function"||I.length<2)return;const j=new MutationObserver(y=>{if(!_r(y))return;let O=null;for(const X of I)if(X.isConnected){if(O&&pn(O,X)>0){j.disconnect(),S();return}O=X}});g.current=j;const h=new Set;for(let y=1;y<I.length;y+=1){const O=Br(I[y-1],I[y]);O&&h.add(O)}h.forEach(y=>j.observe(y,{childList:!0}))}const K=Q(()=>{const[I,j]=Ur(d),h=u(I);z(j),p.current=I,C.current=!1,a.forEach(y=>y(h)),i(h)});Z(()=>(C.current||u(p.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,u]),Z(()=>{C.current&&K()}),Z(()=>()=>{g.current?.disconnect(),C.current=!0},[]);const V=Q(I=>(a.add(I),()=>{a.delete(I)})),R=o.useMemo(()=>({register:T,unregister:U,subscribeMapChange:V,nextIndexRef:m}),[T,U,V,m]);return Re.jsx(dn.Provider,{value:R,children:t})}function Hr(){return new Map}function kr(){return new Set}function Ur(e){const t=new Set,n=[],r=[];e.forEach((i,s)=>{if(!s.isConnected)return;const a=i.index,d={index:a??-1,element:s,registration:i};a===null?r.push(d):a>=0&&(t.add(a),n.push(d))});let c=0;return r.sort((i,s)=>pn(i.element,s.element)),r.forEach(i=>{for(;t.has(c);)c+=1;i.index=c,n.push(i),c+=1}),t.size>0&&n.sort((i,s)=>i.index-s.index),[n,r.map(i=>i.element)]}function Br(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function _r(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function pn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const gn=o.createContext(void 0);function Wr(){const e=o.useContext(gn);if(!e)throw new Error(bt(59));return e}function mt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},zr={position:"fixed"},so=o.forwardRef(function(t,n){const{anchor:r,className:c,render:i,positionMethod:s,side:a,align:d,sideOffset:m,alignOffset:C,collisionBoundary:p="clipping-ancestors",collisionPadding:g,arrowPadding:S,sticky:T,disableAnchorTracking:U,alignItemWithTrigger:u=!0,collisionAvoidance:z=An,style:K,...V}=t,{store:R,listRef:I,labelsRef:j,alignItemWithTriggerActiveRef:h,selectedItemTextRef:y,valuesRef:O,initialValueRef:X,popupRef:ee,setValue:me,floatingContext:te}=Ue(),w=A(R,v.open),N=A(R,v.mounted),ne=A(R,v.modal),B=A(R,v.value),P=A(R,v.openMethod),q=A(R,v.positionerElement),F=A(R,v.triggerElement),l=A(R,v.isItemEqualToValue),M=A(R,v.transitionStatus),ce=o.useRef(null),_=o.useRef(null),[ue,E]=o.useState(u),L=N&&ue&&P!=="touch";!N&&ue!==u&&E(u),o.useImperativeHandle(h,()=>L),Xn((L||ne)&&w,P==="touch",q,F);const Y=Jn({anchor:r,floatingRootContext:te,positionMethod:s,mounted:N,side:a,sideOffset:m,align:d,alignOffset:C,arrowPadding:S,collisionBoundary:p,collisionPadding:g,sticky:T,disableAnchorTracking:U??L,collisionAvoidance:z,keepMounted:!0}),ie=L?"none":Y.side,ye=L?zr:Y.positionerStyles,H={open:w,side:ie,align:Y.align,anchorHidden:Y.anchorHidden};Z(()=>{R.set("popupSide",Y.side)},[R,Y.side]);const re=R.useStateSetter("positionerElement"),J=Qn(t,H,{styles:ye,transitionStatus:M,props:V,refs:[n,re],hidden:!N,inert:!w}),be=o.useRef(0),le=Q(ge=>{if(O.current.length===0)return;const fe=be.current;if(be.current=ge.size,ge.size===fe)return;const he=Ie(gt);if(fe!==0&&!R.state.multiple&&B!==null&&pt(O.current,B,l)===-1){const oe=X.current,D=oe!=null&&pt(O.current,oe,l)!==-1?oe:null;me(D,he),D===null&&(R.set("selectedIndex",null),y.current=null)}if(fe!==0&&R.state.multiple&&Array.isArray(B)){const G=B.filter(oe=>pt(O.current,oe,l)!==-1);G.length!==B.length&&(me(G,he),G.length===0&&(R.set("selectedIndex",null),y.current=null))}if(w&&L){R.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const G={height:""};mt(q,G),mt(ee.current,G)}}),ae=o.useMemo(()=>({...Y,side:ie,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:E,scrollUpArrowRef:ce,scrollDownArrowRef:_}),[Y,ie,L,E]);return Re.jsx(Nr,{elementsRef:I,labelsRef:j,onMapChange:le,children:Re.jsxs(gn.Provider,{value:ae,children:[N&&ne&&Re.jsx(jn,{inert:On(!w),cutout:F}),J]})})}),ct="base-ui-disable-scrollbar",jt={className:ct,getElement(e){return Re.jsx("style",{nonce:e,href:ct,precedence:"base-ui:low",children:`.${ct}{scrollbar-width:none}.${ct}::-webkit-scrollbar{display:none}`})}},Kr=o.createContext(void 0),qr={disableStyleElements:!1};function Yr(){return o.useContext(Kr)??qr}const $r={...Kn,...en},io=o.forwardRef(function(t,n){const{render:r,className:c,style:i,finalFocus:s,...a}=t,{store:d,popupRef:m,onOpenChangeComplete:C,setOpen:p,valueRef:g,firstItemTextRef:S,selectedItemTextRef:T,multiple:U,handleScrollArrowVisibility:u,scrollHandlerRef:z,listRef:K,highlightItemOnHover:V,floatingContext:R}=Ue(),{side:I,align:j,alignItemWithTriggerActive:h,isPositioned:y,setControlledAlignItemWithTrigger:O}=Wr(),X=Zn()!=null,ee=er(),{nonce:me,disableStyleElements:te}=Yr(),w=A(d,v.id),N=A(d,v.open),ne=A(d,v.openMethod),B=A(d,v.mounted),P=A(d,v.popupProps),q=A(d,v.transitionStatus),F=A(d,v.triggerElement),l=A(d,v.positionerElement),M=A(d,v.listElement),ce=o.useRef(!1),_=o.useRef(!1),ue=o.useRef({}),E=vt(),L=Q(H=>{if(!l||!m.current||!_.current)return;const re=l.style.top==="0px",J=l.style.bottom==="0px";if(ce.current||!h||!re&&!J){u(H);return}const be=Kt(l),le=et(l.getBoundingClientRect().height,"y",be),ae=tt(l),ge=dt(l),fe=ge.getComputedStyle(l),he=parseFloat(fe.marginTop),G=parseFloat(fe.marginBottom),oe=zt(ge.getComputedStyle(m.current)),pe=Math.min(ae.documentElement.clientHeight-he-G,oe),D=H.scrollTop,f=ut(H);let b=null;const $=de=>{l.style.height=`${de}px`},x=re?f-D:D,k=Math.min(le+x,pe);if(x<=Pe){const de=Ze(x,0,pe-le);de>0&&$(le+de),H.scrollTop=re?f:0,pe-(le+de)<=Pe&&(ce.current=!0),u(H);return}if(pe-k>Pe)b=re?1/0:0;else if(J&&D<f){const de=le+x-pe;b=D-(x-de)}const Ce=Math.ceil(k);if(Ce!==0&&$(Ce),b!=null){const de=Ze(b,0,ut(H));Math.abs(H.scrollTop-de)>Pe&&(H.scrollTop=de)}Ce>=pe-Pe&&(ce.current=!0),u(H)});o.useImperativeHandle(z,()=>L,[L]),Vt({open:N,ref:m,onComplete(){N&&C?.(!0)}});const Y={open:N,transitionStatus:q,side:I,align:j};Z(()=>{!l||!m.current||Object.keys(ue.current).length||(ue.current={top:l.style.top||"0",left:l.style.left||"0",right:l.style.right,height:l.style.height,bottom:l.style.bottom,minHeight:l.style.minHeight,maxHeight:l.style.maxHeight,marginTop:l.style.marginTop,marginBottom:l.style.marginBottom})},[m,l]),Z(()=>{N||h||(_.current=!1,ce.current=!1,mt(l,ue.current))},[N,h,l,m]),Z(()=>{const H=m.current;if(!N||!F||!l||!H||h&&!y||d.state.transitionStatus==="ending")return;if(_.current=!0,H.style.removeProperty("--transform-origin"),!h){E.request(()=>u(M||H));return}const re=Gr(H);try{let J=T.current;J?.isConnected||(J=!v.hasSelectedValue(d.state)&&S.current?.isConnected?S.current:null);const be=g.current,le=dt(l),ae=le.getComputedStyle(l),ge=le.getComputedStyle(H),fe=tt(F),he=Kt(F),G=at(F.getBoundingClientRect(),he),oe=at(l.getBoundingClientRect(),he),pe=G.height,D=M||H,f=D.scrollHeight,b=parseFloat(ge.borderBottomWidth),$=parseFloat(ae.marginTop)||10,x=parseFloat(ae.marginBottom)||10,k=parseFloat(ae.minHeight)||100,Ce=zt(ge),de=5,Be=5,_e=20,Se=fe.documentElement.clientHeight-$-x,yt=fe.documentElement.clientWidth,Je=Se-G.bottom+pe;let Te,We=ee==="rtl"?G.right-oe.width:G.left,je=0;if(J&&be){const Ee=at(be.getBoundingClientRect(),he);Te=at(J.getBoundingClientRect(),he),We=oe.left+(ee==="rtl"?Ee.right-Te.right:Ee.left-Te.left);const qe=Ee.top-G.top+Ee.height/2;je=Te.top-oe.top+Te.height/2-qe}const Ae=Je+je+x+b;let Me=Math.min(Se,Ae);const Oe=Se-$-x,ze=Ae-Me,Ke=yt-Be;l.style.left=`${Ze(We,de,Ke-oe.width)}px`,l.style.height=`${Me}px`,l.style.maxHeight="none",l.style.marginTop=`${$}px`,l.style.marginBottom=`${x}px`,H.style.height="100%";const Ve=ut(D),Ne=ze>=Ve-Pe;Ne&&(Me=Math.min(Se,oe.height)-(ze-Ve));const nt=G.top<_e||G.bottom>Se-_e||Math.ceil(Me)+Pe<Math.min(f,k),rt=(le.visualViewport?.scale??1)!==1&&Xt;if(nt||rt){mt(l,ue.current),O(!1);return}const ot=Math.max(k,Me);if(Ne){const Ee=Math.max(0,Se-Ae);l.style.top=oe.height>=Oe?"0":`${Ee}px`,l.style.height=`${Me}px`,D.scrollTop=ut(D)}else l.style.bottom="0",D.scrollTop=ze;if(Te){const Ee=oe.top,qe=oe.height,Qe=Te.top+Te.height/2,It=Ze(qe>0?(Qe-Ee)/qe*100:50,0,100);H.style.setProperty("--transform-origin",`50% ${It}%`)}(ot===Se||Me>=Ce)&&(ce.current=!0),u(D),V&&d.state.selectedIndex===null&&d.state.activeIndex===null&&K.current[0]!=null&&d.set("activeIndex",0)}finally{re()}},[d,N,l,F,g,S,T,m,u,h,O,E,M,K,V,ee,y]),o.useEffect(()=>{if(!h||!l||!N)return;const H=dt(l);function re(J){p(!1,Ie(Fn,J))}return Vn(H,"resize",re)},[p,h,l,N]);const ie={...M?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":U||void 0,id:`${w}-list`},onKeyDown(H){X&&qn.has(H.key)&&H.stopPropagation()},onScroll(H){M||L(H.currentTarget)},...h&&{style:M?{height:"100%"}:jr},className:!M&&h?jt.className:void 0},ye=Xe("div",t,{ref:[n,m],state:Y,stateAttributesMapping:$r,props:[P,ie,rr(q),a]});return Re.jsxs(o.Fragment,{children:[!te&&jt.getElement(me),Re.jsx(zn,{context:R,modal:!1,disabled:!B,openInteractionType:ne,returnFocus:s,restoreFocus:!0,children:ye})]})});function zt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function ut(e){return fn(e.scrollHeight,e.clientHeight)}function Kt(e){return tr.getScale(e)}function et(e,t,n){return e/n[t]}function at(e,t){return nr({x:et(e.x,"x",t),y:et(e.y,"y",t),width:et(e.width,"x",t),height:et(e.height,"y",t)})}const qt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[r,c]of qt)n[r]=t.getPropertyValue(r),t.setProperty(r,c,"important");return()=>{for(const[r]of qt){const c=n[r];c?t.setProperty(r,c):t.removeProperty(r)}}}function Xr(e={}){const{guess:t,label:n,metadata:r,textRef:c,index:i}=e,{register:s,unregister:a,subscribeMapChange:d,nextIndexRef:m}=Dr(),C=o.useRef(-1),[p,g]=o.useState(i==null&&t?()=>{if(C.current===-1){const u=m.current;m.current+=1,C.current=u}return C.current}:-1),S=i??p,T=o.useRef(null),U=o.useCallback(u=>{const z=T.current;z&&a(z),T.current=u,u&&s(u,{metadata:r??null,index:i??null,label:n,textRef:c})},[i,s,a,r,n,c]);return Z(()=>{if(i==null)return d(u=>{const z=T.current?u.get(T.current)?.index:null;z!=null&&g(z)})},[i,d]),{ref:U,index:S}}const mn=o.createContext(void 0);function Lt(){const e=o.useContext(mn);if(!e)throw new Error(bt(57));return e}const lo=o.memo(o.forwardRef(function(t,n){const{render:r,className:c,style:i,value:s=null,label:a,disabled:d=!1,nativeButton:m=!1,...C}=t,p=o.useRef(null),g=Xr({guess:!0,label:a,textRef:p}),{store:S,itemProps:T,setOpen:U,setValue:u,selectionRef:z,typingRef:K,valuesRef:V,multiple:R,selectedItemTextRef:I,disabled:j,readOnly:h}=Ue(),y=j||d,O=A(S,v.isActive,g.index),X=A(S,v.open),ee=A(S,v.isSelected,s),me=A(S,v.isSelectedByFocus,g.index),te=A(S,v.isItemEqualToValue),w=g.index,N=o.useRef(null);Z(()=>{const E=V.current;return E[w]=s,()=>{delete E[w]}},[w,s,V]),Z(()=>{const E=S.state.value;let L=E;R&&Array.isArray(E)&&(L=E.length>0?E[E.length-1]:void 0),L!==void 0&&Ge(s,L,te)&&(S.set("selectedIndex",w),p.current&&(I.current=p.current))},[w,R,te,S,s,I]);const ne=o.useRef("mouse"),B=o.useRef(!1),{getButtonProps:P,buttonRef:q}=Zt({disabled:y,focusableWhenDisabled:!0,native:m,composite:!0}),F={disabled:y,selected:ee,highlighted:O};function l(E){if(j||h)return;const L=S.state.value;if(R){const Y=Array.isArray(L)?L:[],ie=ee?Sr(Y,s,te):[...Y,s];u(ie,Ie(Tt,E))}else u(s,Ie(Tt,E)),U(!1,Ie(Tt,E))}function M(){z.current.dragY=0}const ce={role:"option","aria-selected":ee,tabIndex:X&&O?0:-1,onKeyDown(E){S.set("activeIndex",w),E.key===" "&&K.current&&E.preventDefault()},onClick(E){const L=ne.current!=="touch",Y=E.nativeEvent.pointerType,ie=L&&nn(E.nativeEvent)&&(Y!==void 0||O),ye=L&&!ie&&!B.current;B.current=!1,!(y||ye)&&l(E.nativeEvent)},onPointerEnter(E){ne.current=E.pointerType},onPointerMove(E){if(E.pointerType==="mouse"&&E.buttons===1){const L=z.current;L.dragY+=E.movementY,L.dragY**2>=64&&(L.allowUnselectedMouseUp=!0)}},onPointerDown(E){ne.current=E.pointerType,B.current=!0,M()},onMouseUp(){if(M(),y||ne.current==="touch"||B.current)return;const E=!z.current.allowSelectedMouseUp&&ee,L=!z.current.allowUnselectedMouseUp&&!ee;E||L||(B.current=!0,N.current?.click(),B.current=!1)}},_=Xe("div",t,{ref:[q,n,g.ref,N],state:F,props:[T,ce,C,P]}),ue=o.useMemo(()=>({selected:ee,index:w,textRef:p,selectedByFocus:me}),[ee,w,p,me]);return Re.jsx(mn.Provider,{value:ue,children:_})})),co=o.forwardRef(function(t,n){const{selected:r}=Lt();return t.keepMounted||r?Re.jsx(Jr,{...t,ref:n}):null}),Jr=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:c,keepMounted:i,...s}=e,{selected:a}=Lt(),d=o.useRef(null),{transitionStatus:m,setMounted:C}=rn(a),g=Xe("span",e,{ref:[t,d],state:{selected:a,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:en});return Vt({open:a,ref:d,onComplete(){a||C(!1)}}),g})),uo=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:c,selectedByFocus:i}=Lt(),{firstItemTextRef:s,selectedItemTextRef:a}=Ue(),{render:d,className:m,style:C,...p}=t,g=o.useCallback(T=>{T&&(r===0&&(s.current=T),i&&(a.current=T))},[s,a,r,i]);return Xe("div",t,{ref:[g,n,c],props:p})}));export{jr as L,to as S,Wr as a,jt as b,no as c,ro as d,oo as e,so as f,io as g,lo as h,co as i,uo as j,hr as k,Mr as l,Ft as m,sn as n,Wt as o,Rr as p,v as s,Ue as u};
|
package/dashboard/dist/assets/{ServiceStatusPage-CWF_vKOC.js → ServiceStatusPage-8mc6tf7h.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-
|
|
1
|
+
import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-B-XC2p3L.js";import{P as f}from"./ProviderIcon-B_aNMi3s.js";import{E as b}from"./external-link-8c_9vEXT.js";const x=[{id:"claude",name:"Claude",icon:"CLAUDE",apiUrl:"https://status.claude.com/api/v2/status.json",pageUrl:"https://status.claude.com"},{id:"openai",name:"OpenAI / Codex",icon:"CODEX",apiUrl:"https://status.openai.com/api/v2/status.json",pageUrl:"https://status.openai.com"},{id:"cursor",name:"Cursor",icon:"CURSOR",apiUrl:"https://status.cursor.com/api/v2/status.json",pageUrl:"https://status.cursor.com"},{id:"github",name:"GitHub / Copilot",icon:"GITHUB",apiUrl:"https://www.githubstatus.com/api/v2/status.json",pageUrl:"https://www.githubstatus.com"},{id:"gemini",name:"Gemini",icon:"GEMINI",kind:"google",serviceName:"Gemini",apiUrl:"https://www.google.com/appsstatus/dashboard/incidents.json",pageUrl:"https://www.google.com/appsstatus/dashboard"},{id:"kimi",name:"Kimi / Moonshot",icon:"KIMI",apiUrl:"https://status.moonshot.cn/api/v2/status.json",pageUrl:"https://status.moonshot.cn"},{id:"minimax",name:"MiniMax",icon:"MINIMAX",apiUrl:"https://status.minimaxi.com/api/v2/status.json",pageUrl:"https://status.minimaxi.com"},{id:"zed",name:"Zed",icon:"ZED",kind:"instatus",apiUrl:"https://status.zed.dev/summary.json",pageUrl:"https://status.zed.dev"}],w=6e4,y=8e3,j=new Set(["none","minor","major","critical"]),g={none:{dot:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"},minor:{dot:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"},major:{dot:"bg-orange-500",text:"text-orange-600 dark:text-orange-400"},critical:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400"},unknown:{dot:"bg-oai-gray-400",text:"text-oai-gray-500 dark:text-oai-gray-400"}};function k(e){switch(e){case"none":return n("status.state.none");case"minor":return n("status.state.minor");case"major":return n("status.state.major");case"critical":return n("status.state.critical");default:return n("status.state.unknown")}}const v={low:"minor",medium:"major",high:"critical"},N={MAJOROUTAGE:"critical",PARTIALOUTAGE:"major",DEGRADEDPERFORMANCE:"minor"};function A(e){const a=e?.page?.status;if(typeof a!="string")throw new Error("Unexpected payload");if(a==="UP")return{indicator:"none",description:"",updatedAt:null};const s=Array.isArray(e?.activeIncidents)?e.activeIncidents:[],r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=N[i?.impact]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i?.name||"",updatedAt:i?.updated||null})}return o||{indicator:"minor",description:"",updatedAt:null}}function I(e,a){if(!Array.isArray(e))throw new Error("Unexpected payload");const s=e.filter(i=>i&&!i.end&&(i.service_name===a||Array.isArray(i.affected_products)&&i.affected_products.some(c=>c?.title===a)));if(s.length===0)return{indicator:"none",description:"",updatedAt:null};const r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=v[i.severity]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i.external_desc||"",updatedAt:i.modified||null})}return o}async function E(e){try{const a=await fetch(e.apiUrl,{cache:"no-store",signal:AbortSignal.timeout(y)});if(!a.ok)throw new Error(`HTTP ${a.status}`);const s=await a.json();if(e.kind==="google")return I(s,e.serviceName);if(e.kind==="instatus")return A(s);const r=s?.status?.indicator;if(!j.has(r))throw new Error("Unexpected payload");return{indicator:r,description:typeof s?.status?.description=="string"?s.status.description:"",updatedAt:typeof s?.page?.updated_at=="string"?s.page.updated_at:null}}catch{return{indicator:"unknown",description:"",updatedAt:null}}}function U({provider:e,result:a}){const s=g[a?.indicator]||g.unknown,r=a==null;return t.jsxs("a",{href:e.pageUrl,target:"_blank",rel:"noreferrer","aria-label":n("status.open_page",{provider:e.name}),title:n("status.open_page",{provider:e.name}),className:"group block no-underline text-inherit rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4 sm:p-5 transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(f,{provider:e.icon,size:20}),t.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:e.name})]}),t.jsx("span",{"aria-hidden":!0,className:"shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-lg text-oai-gray-400 transition-colors group-hover:text-oai-black dark:group-hover:text-white",children:t.jsx(b,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[r?t.jsx("span",{className:"h-2 w-2 rounded-full bg-oai-gray-300 dark:bg-oai-gray-700 animate-pulse","aria-hidden":!0}):t.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":!0,children:[a.indicator!=="none"&&a.indicator!=="unknown"?t.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 ${s.dot}`}):null,t.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${s.dot}`})]}),t.jsx("span",{className:`text-sm font-medium ${r?"text-oai-gray-400":s.text}`,children:r?n("status.state.checking"):k(a.indicator)})]}),!r&&a.description&&a.indicator!=="none"?t.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400 break-words",children:a.description}):null]})}function T(){const[e,a]=d.useState({}),[s,r]=d.useState(null),[o,i]=d.useState(!1),c=d.useRef(!0),u=d.useCallback(async()=>{i(!0);const l=await Promise.all(x.map(async p=>[p.id,await E(p)]));c.current&&(a(Object.fromEntries(l)),r(new Date),i(!1))},[]);d.useEffect(()=>{c.current=!0,u();const l=setInterval(()=>{u()},w);return()=>{c.current=!1,clearInterval(l)}},[u]);const m=d.useMemo(()=>s?n("status.last_checked",{time:s.toLocaleTimeString()}):null,[s]);return t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:n("nav.service_status")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:n("status.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[m?t.jsx("span",{className:"hidden sm:inline text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null,t.jsx("button",{type:"button",onClick:()=>{u()},disabled:o,"aria-label":n("status.refresh"),title:n("status.refresh"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:t.jsx(h,{className:`h-4 w-4 ${o?"animate-spin":""}`,"aria-hidden":!0})})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:x.map(l=>t.jsx(U,{provider:l,result:e[l.id]??null},l.id))}),t.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n("status.page.source_note")})]})})})}export{x as STATUS_PROVIDERS,T as ServiceStatusPage,T as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{m as K,r as o,j as e,e as E,c as a,M as W,J as H,R as X,X as Y,d as ee,l as $,a4 as te,a5 as R}from"./__vite-browser-external-
|
|
1
|
+
import{m as K,r as o,j as e,e as E,c as a,M as W,J as H,R as X,X as Y,d as ee,l as $,a4 as te,a5 as R}from"./__vite-browser-external-B-XC2p3L.js";import{S as U,I as ae}from"./SegmentedControl-BSSEziQX.js";import{C as re}from"./ToolbarRootContext-Dql3cfna.js";import{S as z}from"./search-pNfEa7Lu.js";import{C as se}from"./check-m09S3gbL.js";import{P as oe,a as ie,b as ne,c as le,d as ce}from"./PopoverPopup-BDL1MCfN.js";import{P as de}from"./ProviderIcon-B_aNMi3s.js";import{H as ue}from"./HoverTooltip-DkHxleW2.js";import{L as xe}from"./LocalOnlyNotice-D3wCg6qv.js";import{u as me}from"./useCurrency-BpARhxK3.js";import{i as he}from"./host-mode-Bc_iTzHk.js";import{L as fe}from"./loader-circle-CP259tjS.js";import{T as pe}from"./terminal-D7ntwa3W.js";import"./useScrollLock-CPs_4XCs.js";import"./store-B0QLXu7j.js";import"./arrow-up-right-C3b1UqgX.js";import"./download-qOQt6utK.js";const ge=[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]],ye=K("calendar",ge);const be=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ke=K("folder",be),ve="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function je({options:r,value:t,onChange:s,allValue:d="all",allLabel:h,searchPlaceholder:k,emptyLabel:S,ariaLabel:u,disabled:x=!1,className:T=""}){const[p,D]=o.useState(!1),[g,w]=o.useState(""),[c,m]=o.useState(-1),F=o.useRef(null),C=`${o.useId()}-listbox`,I=t===d?h:r.find(n=>n.value===t)?.label??t,N=g.trim().toLowerCase(),v=o.useMemo(()=>N?r.filter(n=>n.label.toLowerCase().includes(N)):r,[r,N]),y=o.useMemo(()=>[{value:d,label:h},...v],[d,h,v]),O=c>=0&&c<y.length?y[c]:null,P=n=>{s(n),D(!1),w(""),m(-1)};o.useEffect(()=>{p&&F.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[p,c]);const L=n=>{if(n.key==="ArrowDown"||n.key==="ArrowUp"){n.preventDefault();const f=n.key==="ArrowDown";m(_=>{const M=y.length;return M?f?_>=M-1?0:_+1:_<=0?M-1:_-1:-1});return}if(n.key==="Enter"){const f=O||(N&&v.length?v[0]:null);if(!f)return;n.preventDefault(),P(f.value)}};return e.jsxs(oe,{open:p,onOpenChange:n=>{D(n),m(-1),n||w("")},children:[e.jsxs(ie,{disabled:x,"aria-label":u,className:E("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==d?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",T),children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:I}),e.jsx(re,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ne,{children:e.jsx(le,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(ce,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(z,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":O?`${C}-${c}`:void 0,value:g,onChange:n=>{w(n.target.value),m(-1)},onKeyDown:L,placeholder:k,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:F,id:C,role:"listbox","aria-label":u,className:"max-h-64 overflow-y-auto",children:[y.map((n,f)=>e.jsxs("button",{id:`${C}-${f}`,type:"button",role:"option","aria-selected":t===n.value,"data-active":f===c?"true":void 0,onMouseEnter:()=>m(f),onClick:()=>P(n.value),className:E(ve,t===n.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",f===c&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:n.label}),t===n.value?e.jsx(se,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},n.value)),v.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:S}):null]})]})})})]})}const we="tokentracker-sessions";async function Ne(r={}){const t=new URL(`/functions/${we}`,window.location.origin);r.from&&t.searchParams.set("from",r.from),r.to&&t.searchParams.set("to",r.to),r.limit&&t.searchParams.set("limit",String(r.limit)),r.refresh&&t.searchParams.set("refresh","1");const s=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),d=await s.json().catch(()=>null);if(!s.ok){const h=s.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${s.status}`,k=new Error(d?.error||h);throw k.status=s.status,k}return d}const G=he(),_e=[],A=100,Se=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],Z=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Ce(r){const t=Z.find(d=>d.id===r)?.days||0;if(!t)return 0;const s=new Date;return s.setDate(s.getDate()-(t-1)),s.setHours(0,0,0,0),s.getTime()}function Le(r,t){if(!t)return!0;const s=Date.parse(r.ended_at||r.started_at||"");return Number.isFinite(s)?s>=t:!0}function Me(r,t){if(!r)return"—";const s=Date.parse(r);if(!Number.isFinite(s))return"—";try{return new Date(s).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(s).toISOString().slice(0,16).replace("T"," ")}}function De(r){const t=Number(r);if(!Number.isFinite(t)||t<=0)return null;const s=Math.round(t/6e4);if(s<60)return a("sessions.duration.minutes",{minutes:s});const d=Math.floor(s/60),h=s%60;return a("sessions.duration.hours",{hours:d,minutes:h})}async function Q(r){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(r),!0;const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),s}const Ie=ee.memo(function({session:t,locale:s}){const{currency:d,rate:h}=me(),k=String(t.source||"").toUpperCase(),S=De(t.duration_ms),u=t.resume_command,x=t.project_key||a("sessions.project.unknown"),T=t.title||x,p=!!(t.title&&t.project_key),D=t.project_ref?`${t.project_ref}
|
|
2
2
|
${a("sessions.project.copy_hint")}`:void 0,g=async()=>{if(t.project_ref)try{await Q(t.project_ref)?R({title:a("sessions.project.copied")}):R({title:a("sessions.project.copy_failed")})}catch{R({title:a("sessions.project.copy_failed")})}},w=m=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(ue,{text:D,placement:"bottom"}),e.jsx("button",{type:"button",onClick:g,"aria-label":a("sessions.project.copy_aria",{project:x}),className:E("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",m),children:x})]}),c=async()=>{if(u)try{await Q(u)?R({title:a("sessions.resume.copied")}):R({title:a("sessions.resume.copy_failed")})}catch{R({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:"flex flex-col gap-3 py-4 sm:flex-row sm:items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(de,{provider:k,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!t.title&&t.project_ref?w("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:T}),t.first_pass?e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:a("sessions.badge.first_pass")}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[p?e.jsxs(e.Fragment,{children:[t.project_ref?w("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:x}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:t.model||a("sessions.model.unknown")}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Me(t.started_at,s)}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:S})]}):null]})]})]}),e.jsxs("div",{className:"flex items-start gap-5 pl-[30px] sm:pl-0",children:[e.jsxs("dl",{className:"flex items-start gap-6 text-right",children:[e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.tokens")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:$(t.total_tokens)})]}),e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.cost")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:te(t.cost_usd,{currency:d,rate:h})})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.turns")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:$(t.turns)})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.edits")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:$(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:c,disabled:!u,title:u||a("sessions.resume.unavailable"),"aria-label":u?a("sessions.resume.copy_aria",{command:u}):a("sessions.resume.unavailable"),className:E("-mt-0.5 inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u?"text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white":"cursor-not-allowed text-oai-gray-300 dark:text-oai-gray-600"),children:[e.jsx(pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function Je(){const[r,t]=o.useState(null),[s,d]=o.useState(null),[h,k]=o.useState(!0),[S,u]=o.useState(!1),[x,T]=o.useState("all"),[p,D]=o.useState("all"),[g,w]=o.useState("all"),[c,m]=o.useState(""),[F,C]=o.useState(A),I=o.useRef(0),{resolvedLocale:N}=W(),v=o.useCallback(async(i=!1)=>{const b=++I.current;i?u(!0):k(!0),d(null);try{const l=await Ne({refresh:i});b===I.current&&t(l)}catch(l){b===I.current&&d(l?.message||String(l))}finally{b===I.current&&(k(!1),u(!1))}},[]);o.useEffect(()=>{G||H()?v(!1):k(!1)},[v]);const y=r?.sessions||_e,O=o.useMemo(()=>{const i=new Set,b=[];for(const l of y){const j=l.project_key;!j||i.has(j)||(i.add(j),b.push({value:j,label:j}))}return b.sort((l,j)=>l.label.localeCompare(j.label))},[y]),P=o.useDeferredValue(c),L=o.useMemo(()=>{const i=P.trim().toLowerCase(),b=Ce(p);return y.filter(l=>x!=="all"&&l.source!==x||g!=="all"&&l.project_key!==g||!Le(l,b)?!1:i?`${l.title||""} ${l.project_key||""} ${l.model||""} ${l.project_ref||""} ${l.session_id||""}`.toLowerCase().includes(i):!0)},[y,x,g,p,P]),n=x!=="all"||p!=="all"||g!=="all"||c.trim()!=="";o.useEffect(()=>{C(A)},[x,g,p,P,y]);const f=o.useMemo(()=>L.slice(0,F),[L,F]),_=L.length>f.length,M=o.useCallback(()=>C(i=>i+A),[]),q=o.useRef(null);o.useEffect(()=>{if(!_||typeof IntersectionObserver>"u")return;const i=q.current;if(!i)return;const b=new IntersectionObserver(l=>{l.some(j=>j.isIntersecting)&&M()},{rootMargin:"400px"});return b.observe(i),()=>b.disconnect()},[_,M]);const B=o.useMemo(()=>Se.map(i=>({id:i.id,label:i.label()})),[N]),J=o.useMemo(()=>Z.map(i=>({id:i.id,label:i.label()})),[N]),V=Number(r?.session_count)>Number(r?.returned_count);return!G&&!H()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(xe,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("sessions.page.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>{v(!0)},disabled:S||h,"aria-label":a("sessions.page.refresh"),title:a("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(X,{className:E("h-4 w-4",S&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(U,{ariaLabel:a("sessions.filter.source_aria"),options:B,value:x,onChange:T}),e.jsx(U,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:J,value:p,onChange:D}),e.jsx(je,{options:O,value:g,onChange:w,allLabel:a("sessions.filter.project_all"),searchPlaceholder:a("sessions.filter.project_search"),emptyLabel:a("sessions.filter.project_empty"),ariaLabel:a("sessions.filter.project_aria")}),e.jsxs("div",{className:"relative w-72 max-w-full",children:[e.jsx(z,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(ae,{type:"search",value:c,onChange:i=>m(i.target.value),onKeyDown:i=>{i.key==="Escape"&&c&&(i.preventDefault(),m(""))},"aria-label":a("sessions.action.search_aria"),placeholder:a("sessions.search.placeholder"),className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:i=>i.preventDefault(),onClick:()=>m(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:E("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Y,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.filter.result_count",{filtered:L.length,total:y.length})})]}),V?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.truncated",{shown:r.returned_count,total:r.session_count})}):null,s&&!r?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:a("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx("button",{type:"button",onClick:()=>{v(!1)},className:"mt-4 inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.error.retry")})]}):h?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(fe,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):L.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:n?a("sessions.empty.filtered_title"):a("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n?a("sessions.empty.filtered_body"):a("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[s?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:a("shared.error.prefix",{error:s})}):null,e.jsx("ul",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:f.map(i=>e.jsx(Ie,{session:i,locale:N},i.session_hash))}),_?e.jsx("div",{ref:q,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:M,className:"inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.privacy")})]})})})}export{Je as SessionsPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-
|
|
2
|
-
import{m as O,j as t,e as A,c as n,a as ce,r as d,aq as ue,aT as de,aw as ge,ax as pe,a8 as W,aU as he,aV as me,u as be,d as R,a0 as fe,M as Z,n as M,aW as xe,aX as ye,U as Y,aY as ve,x as ke,aZ as je,a_ as Se,a$ as we,b0 as Ne,b1 as Ce,b2 as Ee,b3 as Ae,L as Le,R as Oe,b4 as Pe,b5 as _e,a5 as H,_ as Te,h as Ie,b6 as Ge,b7 as Re}from"./__vite-browser-external-CZMdPW0g.js";import{a as Ue,b as F,s as De,K as Me,P as He,D as Fe,c as $e,S as Be,v as Ve,u as Ke,C as ze}from"./sortable.esm-C6kDS9DZ.js";import{a as qe}from"./modifiers.esm-DEN3VPKe.js";import{u as We,L as $}from"./use-limits-display-prefs-CazeqdNI.js";import{P as Ze}from"./ProviderIcon-DcQmGbfz.js";import{a as B,l as V}from"./limits-providers-BlAlATd7.js";import{m as J}from"./react-B3eL33ha.js";import{a as E,T as k,b,S as _,u as T}from"./Controls-C2Z2X0ZQ.js";import{P as Ye,u as Je,a as Xe}from"./use-session-efficiency-pref-B7RHUtup.js";import{C as Qe}from"./check-Bt3Yu07t.js";import{C as et}from"./copy-D3k1Xbfl.js";import{A as X}from"./index-CXOOOeSl.js";import{u as tt}from"./useCurrency-D7ICju5j.js";import{u as nt}from"./useTokenFormat-wDhHrsAL.js";import{S as U}from"./Select-0RiFEISo.js";import{I as at}from"./info-CD_G_DZp.js";import{C as st}from"./ConfirmModal-xkYsrh0v.js";import{A as it}from"./arrow-up-right-CIAd6sXA.js";import{D as ot}from"./download-co2WHJvo.js";import{i as rt}from"./host-mode-Bc_iTzHk.js";import"./Card-Cp5v7Y19.js";import"./ToolbarRootContext-Dg-zL8fE.js";import"./useScrollLock-DXWPQF_D.js";import"./SelectItemText-BRV3DFEB.js";import"./DialogTitle-IKAPm5Pk.js";import"./store-B4atnDzu.js";import"./DialogDescription-rhGVm7N2.js";const lt=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],ct=O("flask-conical",lt);const ut=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dt=O("grip-vertical",ut);const gt=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],pt=O("languages",gt);const ht=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],mt=O("log-out",ht);const bt=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],ft=O("palette",bt);const xt=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],yt=O("user-round",xt),vt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function kt({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:A("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:A("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function jt({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=Ke({id:e}),m={transform:ze.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:m,className:A("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(dt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),B(e)?t.jsx(Ze,{provider:B(e),size:18,className:A("pointer-events-none",vt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:V(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(kt,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${V(e)}`})})]})}function St({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Ue(F(He,{activationConstraint:{distance:6}}),F(Me,{coordinateGetter:De})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Fe,{sensors:r,collisionDetection:$e,modifiers:[qe],onDragEnd:l,children:t.jsx(Be,{items:a,strategy:Ve,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(jt,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function wt(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Nt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Ct(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function D(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Et(e,a,s){const[i,o]=d.useState(()=>ue()),r=a&&s&&de(),l=d.useCallback(async()=>{const c=!i;if(ge(c),o(c),!!c)try{await pe(()=>e())}catch(u){D("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function At(e){const[a,s]=d.useState(!1),[i,o]=d.useState(!1),[r,l]=d.useState(!1),[c,u]=d.useState(!1),[m,p]=d.useState(null),[g,f]=d.useState(!1),[v,j]=d.useState(""),[h,y]=d.useState(!1),[S,N]=d.useState(""),[L,P]=d.useState(""),[I,x]=d.useState(!1),[C,se]=d.useState(null),ie=d.useMemo(()=>wt(e),[e]),oe=d.useMemo(()=>Nt(e),[e]),re=d.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),le=d.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:m,displayName:ie,editingGithub:I,editingName:g,email:oe,githubError:C,githubInput:L,githubUrl:S,loadSetters:le,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:f,setGithubError:se,setGithubInput:P,setGithubUrl:N,setNameInput:j,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:h,userId:re}}function Lt(e,a,s){d.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await W({getAccessToken:e});if(!i||!o)return;const r=await he({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){D("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function Ot(e,a){return d.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await W({getAccessToken:e});if(!l)return!1;const c=await me({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):D(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Pt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function _t(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Tt(e,a){const s=d.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:d.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function It(e,a,s){const i=d.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=d.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Gt(e,a){const s=d.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=d.useCallback(async()=>{const r=Ct(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=d.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Rt(){const e=ce(),a=At(e.user),s=Et(e.getAccessToken,e.enabled,e.signedIn);Lt(e.getAccessToken,e.signedIn,a.loadSetters);const i=Ot(e.getAccessToken,a),o=Tt(a,i),r=It(a,i,e.refreshDisplayName),l=Gt(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Pt(a,{...o,...r}),github:_t(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function Q({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Ut({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(Q,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Dt({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(Q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ee({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function te({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function Mt({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function Ht({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:m,setEditingName:p,setNameInput:g,startEditingName:f}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(te,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx(Ut,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:m,handleSaveName:l}),actions:t.jsx(Mt,{name:e})})}function Ft({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:m,setGithubError:p,setGithubInput:g,showGithubOn:f,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(te,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Dt,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:m,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{label:n("settings.account.edit"),onClick:v}),t.jsx(k,{checked:f,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function $t(){const{openLoginModal:e}=be();return t.jsx(E,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Bt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(Ht,{name:e}),t.jsx(Ft,{github:a})]})}function Vt(){const e=Rt();return e.enabled?e.signedIn?t.jsxs(E,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(zt,{onSignOut:e.signOut}),children:[t.jsx(Kt,{userId:e.userId}),t.jsx(qt,{settings:e}),t.jsx(Wt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Zt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx($t,{}):null}function Kt({userId:e}){const[a,s]=R.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(Qe,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(et,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function zt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(mt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function qt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Wt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function Zt({visible:e,name:a,github:s}){return t.jsx(X,{initial:!1,children:e?t.jsx(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Bt,{name:a,github:s})},"public-profile-fields"):null})}function Yt(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:xe},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:ye},{value:"system",label:n("settings.appearance.theme.system"),Icon:Y}]}function Jt(){return[{value:je,label:n("settings.appearance.language.system")},{value:Se,label:n("settings.appearance.language.english")},{value:we,label:n("settings.appearance.language.chinese")},{value:Ne,label:n("settings.appearance.language.traditional_chinese")},{value:Ce,label:n("settings.appearance.language.japanese")},{value:Ee,label:n("settings.appearance.language.korean")},{value:Ae,label:n("settings.appearance.language.german")}]}function Xt(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function Qt(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=Xt(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function en({locale:e,setLocale:a}){const s=Jt();return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(pt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function tn({currency:e,setCurrency:a}){const s=ve().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function nn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===ke)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=Qt(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(at,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function an(){const{theme:e,setTheme:a}=fe(),{locale:s,setLocale:i}=Z(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=tt(),{mode:m,setMode:p}=nt();return t.jsxs(E,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(_,{options:Yt(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(en,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(nn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(tn,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(_,{options:[{value:M.COMPACT,label:n("settings.appearance.token_format.compact")},{value:M.FULL,label:n("settings.appearance.token_format.full")}],value:m,onChange:p})})]})}function G({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function sn(){const{enabled:e,toggle:a}=Je(),{enabled:s,toggle:i}=Xe(),{available:o,settings:r,setSetting:l}=T(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(E,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(k,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(k,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function on(){const{available:e,settings:a,setSetting:s,runAction:i}=T();if(!e)return null;const o=!!a?.launchAtLogin,r=a?.toastOnReset!==!1,l=a?.confettiOnReset!==!1,c=a?.launchAtLoginSupported!==!1,u=a?.autoUpdateEnabled!==!1,m=a?.updateStatus||null,p=!!a?.updateBusy,g=!!a?.isSyncing;return t.jsxs(E,{title:n("settings.section.menubar"),children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Le,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(it,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:n("settings.menubar.confettiOnReset")})}),c?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Oe,{className:A("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(k,{checked:u,onChange:()=>s("autoUpdateEnabled",!u),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:m||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:p,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(ot,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function rn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function ln(){const{available:e,settings:a,runAction:s}=T(),i=e&&a?.version,[o,r]=R.useState(!1),[l,c]=R.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=Z(),m="0.92.0",p=async()=>{r(!0);try{const h=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!h.ok)throw new Error("Failed to fetch");const y=await h.json(),S=y.tag_name;rn(m,S)?c({open:!0,latestVersion:S,htmlUrl:y.html_url}):H({title:n("settings.menubar.updates.upToDate")})}catch(h){console.error("Check updates failed:",h),H({title:n("settings.menubar.updates.failed")})}finally{r(!1)}},g=n("settings.menubar.updates.modalTitle"),f=n("settings.menubar.updates.modalDescription",{version:l.latestVersion}),v=n("settings.menubar.updates.modalConfirm"),j=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:m})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:m})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:p,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Pe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(st,{open:l.open,title:g,description:f,confirmLabel:v,cancelLabel:j,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(h=>({...h,open:!1}))},onCancel:()=>c(h=>({...h,open:!1}))})]})}const cn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],un=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],K="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function z(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function dn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=d.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=d.useState({}),[u,m]=d.useState(!1),[p,g]=d.useState(""),[f,v]=d.useState(null),[j,h]=d.useState(!1),[y,S]=d.useState(null);d.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=d.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),L=x=>{r(C=>({...C,...x})),c({}),g(""),v(null),S(null)},P=async()=>{if(o.mode==="manual"){const x=z(o);if(Object.keys(x).length){c(x);return}}m(!0),g(""),v(null);try{await s(o),g("saved")}catch(x){g("error"),v(x)}finally{m(!1)}},I=async()=>{const x=z(o);if(Object.keys(x).length){c(x);return}h(!0),S(null);try{const C=await i(o);S(C)}catch(C){S({ok:!1,error:C?.message||String(C)})}finally{h(!1)}};return t.jsxs(E,{title:n("settings.section.network"),subtitle:N,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(_,{options:cn(),value:o.mode,onChange:x=>L({mode:x})})}),t.jsx(X,{initial:!1,children:o.mode==="manual"?t.jsxs(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(U,{value:o.protocol,onValueChange:x=>L({protocol:x}),options:un(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:x=>L({host:x.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:K})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:x=>L({port:x.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:K})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:I,disabled:j||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:j?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:P,disabled:u||j,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:P,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:f?.unprotected?n("settings.network.save_error_unprotected",{error:f?.message||String(f||"")}):n("settings.network.save_error",{error:f?.message||String(f||"")})}):null]})}const ne="/functions/tokentracker-proxy-config",gn="/functions/tokentracker-proxy-test",pn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function ae(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function hn(){const e=await fetch(ne,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return ae(a)}async function q(){const{getLocalApiAuthHeaders:e}=await Te(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-CZMdPW0g.js").then(s=>s.d6);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function mn(){const[e,a]=d.useState(!1),[s,i]=d.useState(!0),[o,r]=d.useState(pn);d.useEffect(()=>{if(!rt()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const m=await hn();if(u)return;if(!m){a(!1),i(!1);return}r(m),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=d.useCallback(async u=>{const m=await q(),p=await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...m},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const f=ae(g);if(f&&r(f),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,j=new Error(v);throw g.unprotected===!0&&(j.unprotected=!0),j}return f||g},[]),c=d.useCallback(async u=>{const m=await q(),p=await fetch(gn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...m},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const w={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function bn({prefs:e}){return t.jsx(_,{options:[{value:$.USED,label:n("limits.settings.display_mode_used")},{value:$.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Vn(){const e=We(),{available:a,settings:s,setSetting:i}=T(),o=mn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,[u,m]=Ie(),p=u.get("section"),f=Object.values(w).includes(p)&&(p!==w.NATIVE_APP||a)&&(p!==w.NETWORK||r)?p:w.APPEARANCE,v=h=>{const y=new URLSearchParams(u);h===w.APPEARANCE?y.delete("section"):y.set("section",h),m(y,{replace:!0})},j=[{id:w.APPEARANCE,label:n("settings.section.appearance"),Icon:ft,content:t.jsx(an,{})},...a?[{id:w.NATIVE_APP,label:n("settings.section.menubar"),Icon:Y,content:t.jsx(on,{})}]:[],...r?[{id:w.NETWORK,label:n("settings.section.network"),Icon:Ge,content:t.jsx(dn,{proxySettings:o})}]:[],{id:w.ACCOUNT,label:n("settings.section.account"),Icon:yt,content:t.jsx(Vt,{})},{id:w.LIMITS,label:n("settings.section.limits"),Icon:Re,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(E,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(bn,{prefs:e})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(E,{title:n("settings.limits.providers"),children:t.jsx(St,{prefs:e})})]})},{id:w.LABS,label:n("settings.section.labs"),Icon:ct,content:t.jsx(sn,{})}];return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:j.map(({id:h,label:y,Icon:S})=>{const N=f===h;return t.jsxs("button",{id:`settings-nav-${h}`,type:"button","aria-current":N?"page":void 0,"aria-controls":`settings-panel-${h}`,onClick:()=>v(h),className:A("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",N?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(S,{className:A("h-4 w-4 shrink-0",N?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:y})]},h)})})}),t.jsxs("div",{className:"min-w-0",children:[j.map(({id:h,label:y,content:S})=>t.jsx("section",{id:`settings-panel-${h}`,"aria-labelledby":`settings-nav-${h}`,"aria-label":y,"data-settings-panel":h,hidden:f!==h,children:S},h)),t.jsx(ln,{})]})]})]})})})}export{Vn as SettingsPage};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-B-XC2p3L.js","assets/__vite-browser-external-CiR9-j4L.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{m as O,j as t,e as A,c as n,a as ce,r as d,aq as ue,aT as de,aw as ge,ax as pe,a8 as W,aU as he,aV as me,u as be,d as R,a0 as fe,M as Z,n as M,aW as xe,aX as ye,U as Y,aY as ve,x as ke,aZ as je,a_ as Se,a$ as we,b0 as Ne,b1 as Ce,b2 as Ee,b3 as Ae,L as Le,R as Oe,b4 as Pe,b5 as _e,a5 as H,_ as Te,h as Ie,b6 as Ge,b7 as Re}from"./__vite-browser-external-B-XC2p3L.js";import{a as Ue,b as F,s as De,K as Me,P as He,D as Fe,c as $e,S as Be,v as Ve,u as Ke,C as ze}from"./sortable.esm-BmpxivFO.js";import{a as qe}from"./modifiers.esm-Bp3mFth-.js";import{u as We,L as $}from"./use-limits-display-prefs-B3o8C_zQ.js";import{P as Ze}from"./ProviderIcon-B_aNMi3s.js";import{a as B,l as V}from"./limits-providers-C2LxotEb.js";import{m as J}from"./react-C681nojo.js";import{a as E,T as k,b,S as _,u as T}from"./Controls-NQMc-XyF.js";import{P as Ye,u as Je,a as Xe}from"./use-session-efficiency-pref-DwO-VjQ3.js";import{C as Qe}from"./check-m09S3gbL.js";import{C as et}from"./copy-Da10tbbX.js";import{A as X}from"./index-QKdHEBW3.js";import{u as tt}from"./useCurrency-BpARhxK3.js";import{u as nt}from"./useTokenFormat-BT2luita.js";import{S as U}from"./Select-DI8Duz98.js";import{I as at}from"./info-BeIuHjVl.js";import{C as st}from"./ConfirmModal-nOBxWc3T.js";import{A as it}from"./arrow-up-right-C3b1UqgX.js";import{D as ot}from"./download-qOQt6utK.js";import{i as rt}from"./host-mode-Bc_iTzHk.js";import"./Card-DzYuh963.js";import"./ToolbarRootContext-Dql3cfna.js";import"./useScrollLock-CPs_4XCs.js";import"./SelectItemText-DxwgRTwt.js";import"./DialogTitle-IGUG8ZLp.js";import"./store-B0QLXu7j.js";import"./DialogDescription-2f8ReZgl.js";const lt=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],ct=O("flask-conical",lt);const ut=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dt=O("grip-vertical",ut);const gt=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],pt=O("languages",gt);const ht=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],mt=O("log-out",ht);const bt=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],ft=O("palette",bt);const xt=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],yt=O("user-round",xt),vt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function kt({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:A("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:A("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function jt({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=Ke({id:e}),m={transform:ze.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:m,className:A("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(dt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),B(e)?t.jsx(Ze,{provider:B(e),size:18,className:A("pointer-events-none",vt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:V(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(kt,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${V(e)}`})})]})}function St({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Ue(F(He,{activationConstraint:{distance:6}}),F(Me,{coordinateGetter:De})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Fe,{sensors:r,collisionDetection:$e,modifiers:[qe],onDragEnd:l,children:t.jsx(Be,{items:a,strategy:Ve,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(jt,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function wt(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Nt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Ct(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function D(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Et(e,a,s){const[i,o]=d.useState(()=>ue()),r=a&&s&&de(),l=d.useCallback(async()=>{const c=!i;if(ge(c),o(c),!!c)try{await pe(()=>e())}catch(u){D("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function At(e){const[a,s]=d.useState(!1),[i,o]=d.useState(!1),[r,l]=d.useState(!1),[c,u]=d.useState(!1),[m,p]=d.useState(null),[g,f]=d.useState(!1),[v,j]=d.useState(""),[h,y]=d.useState(!1),[S,N]=d.useState(""),[L,P]=d.useState(""),[I,x]=d.useState(!1),[C,se]=d.useState(null),ie=d.useMemo(()=>wt(e),[e]),oe=d.useMemo(()=>Nt(e),[e]),re=d.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),le=d.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:m,displayName:ie,editingGithub:I,editingName:g,email:oe,githubError:C,githubInput:L,githubUrl:S,loadSetters:le,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:f,setGithubError:se,setGithubInput:P,setGithubUrl:N,setNameInput:j,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:h,userId:re}}function Lt(e,a,s){d.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await W({getAccessToken:e});if(!i||!o)return;const r=await he({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){D("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function Ot(e,a){return d.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await W({getAccessToken:e});if(!l)return!1;const c=await me({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):D(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Pt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function _t(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Tt(e,a){const s=d.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:d.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function It(e,a,s){const i=d.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=d.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Gt(e,a){const s=d.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=d.useCallback(async()=>{const r=Ct(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=d.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Rt(){const e=ce(),a=At(e.user),s=Et(e.getAccessToken,e.enabled,e.signedIn);Lt(e.getAccessToken,e.signedIn,a.loadSetters);const i=Ot(e.getAccessToken,a),o=Tt(a,i),r=It(a,i,e.refreshDisplayName),l=Gt(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Pt(a,{...o,...r}),github:_t(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function Q({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Ut({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(Q,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Dt({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(Q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ee({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function te({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function Mt({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function Ht({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:m,setEditingName:p,setNameInput:g,startEditingName:f}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(te,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx(Ut,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:m,handleSaveName:l}),actions:t.jsx(Mt,{name:e})})}function Ft({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:m,setGithubError:p,setGithubInput:g,showGithubOn:f,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(te,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Dt,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:m,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{label:n("settings.account.edit"),onClick:v}),t.jsx(k,{checked:f,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function $t(){const{openLoginModal:e}=be();return t.jsx(E,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Bt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(Ht,{name:e}),t.jsx(Ft,{github:a})]})}function Vt(){const e=Rt();return e.enabled?e.signedIn?t.jsxs(E,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(zt,{onSignOut:e.signOut}),children:[t.jsx(Kt,{userId:e.userId}),t.jsx(qt,{settings:e}),t.jsx(Wt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Zt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx($t,{}):null}function Kt({userId:e}){const[a,s]=R.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(Qe,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(et,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function zt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(mt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function qt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Wt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function Zt({visible:e,name:a,github:s}){return t.jsx(X,{initial:!1,children:e?t.jsx(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Bt,{name:a,github:s})},"public-profile-fields"):null})}function Yt(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:xe},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:ye},{value:"system",label:n("settings.appearance.theme.system"),Icon:Y}]}function Jt(){return[{value:je,label:n("settings.appearance.language.system")},{value:Se,label:n("settings.appearance.language.english")},{value:we,label:n("settings.appearance.language.chinese")},{value:Ne,label:n("settings.appearance.language.traditional_chinese")},{value:Ce,label:n("settings.appearance.language.japanese")},{value:Ee,label:n("settings.appearance.language.korean")},{value:Ae,label:n("settings.appearance.language.german")}]}function Xt(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function Qt(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=Xt(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function en({locale:e,setLocale:a}){const s=Jt();return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(pt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function tn({currency:e,setCurrency:a}){const s=ve().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function nn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===ke)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=Qt(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(at,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function an(){const{theme:e,setTheme:a}=fe(),{locale:s,setLocale:i}=Z(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=tt(),{mode:m,setMode:p}=nt();return t.jsxs(E,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(_,{options:Yt(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(en,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(nn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(tn,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(_,{options:[{value:M.COMPACT,label:n("settings.appearance.token_format.compact")},{value:M.FULL,label:n("settings.appearance.token_format.full")}],value:m,onChange:p})})]})}function G({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function sn(){const{enabled:e,toggle:a}=Je(),{enabled:s,toggle:i}=Xe(),{available:o,settings:r,setSetting:l}=T(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(E,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(k,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(k,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function on(){const{available:e,settings:a,setSetting:s,runAction:i}=T();if(!e)return null;const o=!!a?.launchAtLogin,r=a?.toastOnReset!==!1,l=a?.confettiOnReset!==!1,c=a?.launchAtLoginSupported!==!1,u=a?.autoUpdateEnabled!==!1,m=a?.updateStatus||null,p=!!a?.updateBusy,g=!!a?.isSyncing;return t.jsxs(E,{title:n("settings.section.menubar"),children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Le,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(it,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:n("settings.menubar.confettiOnReset")})}),c?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Oe,{className:A("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(k,{checked:u,onChange:()=>s("autoUpdateEnabled",!u),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:m||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:p,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(ot,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function rn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function ln(){const{available:e,settings:a,runAction:s}=T(),i=e&&a?.version,[o,r]=R.useState(!1),[l,c]=R.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=Z(),m="0.93.2",p=async()=>{r(!0);try{const h=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!h.ok)throw new Error("Failed to fetch");const y=await h.json(),S=y.tag_name;rn(m,S)?c({open:!0,latestVersion:S,htmlUrl:y.html_url}):H({title:n("settings.menubar.updates.upToDate")})}catch(h){console.error("Check updates failed:",h),H({title:n("settings.menubar.updates.failed")})}finally{r(!1)}},g=n("settings.menubar.updates.modalTitle"),f=n("settings.menubar.updates.modalDescription",{version:l.latestVersion}),v=n("settings.menubar.updates.modalConfirm"),j=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:m})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:m})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:p,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Pe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(st,{open:l.open,title:g,description:f,confirmLabel:v,cancelLabel:j,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(h=>({...h,open:!1}))},onCancel:()=>c(h=>({...h,open:!1}))})]})}const cn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],un=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],K="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function z(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function dn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=d.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=d.useState({}),[u,m]=d.useState(!1),[p,g]=d.useState(""),[f,v]=d.useState(null),[j,h]=d.useState(!1),[y,S]=d.useState(null);d.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=d.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),L=x=>{r(C=>({...C,...x})),c({}),g(""),v(null),S(null)},P=async()=>{if(o.mode==="manual"){const x=z(o);if(Object.keys(x).length){c(x);return}}m(!0),g(""),v(null);try{await s(o),g("saved")}catch(x){g("error"),v(x)}finally{m(!1)}},I=async()=>{const x=z(o);if(Object.keys(x).length){c(x);return}h(!0),S(null);try{const C=await i(o);S(C)}catch(C){S({ok:!1,error:C?.message||String(C)})}finally{h(!1)}};return t.jsxs(E,{title:n("settings.section.network"),subtitle:N,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(_,{options:cn(),value:o.mode,onChange:x=>L({mode:x})})}),t.jsx(X,{initial:!1,children:o.mode==="manual"?t.jsxs(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(U,{value:o.protocol,onValueChange:x=>L({protocol:x}),options:un(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:x=>L({host:x.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:K})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:x=>L({port:x.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:K})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:I,disabled:j||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:j?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:P,disabled:u||j,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:P,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:f?.unprotected?n("settings.network.save_error_unprotected",{error:f?.message||String(f||"")}):n("settings.network.save_error",{error:f?.message||String(f||"")})}):null]})}const ne="/functions/tokentracker-proxy-config",gn="/functions/tokentracker-proxy-test",pn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function ae(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function hn(){const e=await fetch(ne,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return ae(a)}async function q(){const{getLocalApiAuthHeaders:e}=await Te(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-B-XC2p3L.js").then(s=>s.d6);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function mn(){const[e,a]=d.useState(!1),[s,i]=d.useState(!0),[o,r]=d.useState(pn);d.useEffect(()=>{if(!rt()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const m=await hn();if(u)return;if(!m){a(!1),i(!1);return}r(m),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=d.useCallback(async u=>{const m=await q(),p=await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...m},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const f=ae(g);if(f&&r(f),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,j=new Error(v);throw g.unprotected===!0&&(j.unprotected=!0),j}return f||g},[]),c=d.useCallback(async u=>{const m=await q(),p=await fetch(gn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...m},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const w={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function bn({prefs:e}){return t.jsx(_,{options:[{value:$.USED,label:n("limits.settings.display_mode_used")},{value:$.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Vn(){const e=We(),{available:a,settings:s,setSetting:i}=T(),o=mn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,[u,m]=Ie(),p=u.get("section"),f=Object.values(w).includes(p)&&(p!==w.NATIVE_APP||a)&&(p!==w.NETWORK||r)?p:w.APPEARANCE,v=h=>{const y=new URLSearchParams(u);h===w.APPEARANCE?y.delete("section"):y.set("section",h),m(y,{replace:!0})},j=[{id:w.APPEARANCE,label:n("settings.section.appearance"),Icon:ft,content:t.jsx(an,{})},...a?[{id:w.NATIVE_APP,label:n("settings.section.menubar"),Icon:Y,content:t.jsx(on,{})}]:[],...r?[{id:w.NETWORK,label:n("settings.section.network"),Icon:Ge,content:t.jsx(dn,{proxySettings:o})}]:[],{id:w.ACCOUNT,label:n("settings.section.account"),Icon:yt,content:t.jsx(Vt,{})},{id:w.LIMITS,label:n("settings.section.limits"),Icon:Re,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(E,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(bn,{prefs:e})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(E,{title:n("settings.limits.providers"),children:t.jsx(St,{prefs:e})})]})},{id:w.LABS,label:n("settings.section.labs"),Icon:ct,content:t.jsx(sn,{})}];return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:j.map(({id:h,label:y,Icon:S})=>{const N=f===h;return t.jsxs("button",{id:`settings-nav-${h}`,type:"button","aria-current":N?"page":void 0,"aria-controls":`settings-panel-${h}`,onClick:()=>v(h),className:A("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",N?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(S,{className:A("h-4 w-4 shrink-0",N?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:y})]},h)})})}),t.jsxs("div",{className:"min-w-0",children:[j.map(({id:h,label:y,content:S})=>t.jsx("section",{id:`settings-panel-${h}`,"aria-labelledby":`settings-nav-${h}`,"aria-label":y,"data-settings-panel":h,hidden:f!==h,children:S},h)),t.jsx(ln,{})]})]})]})})})}export{Vn as SettingsPage};
|