tokentracker-cli 0.84.4 → 0.84.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{AchievementBadge-C29PwsK_.js → AchievementBadge-CKIvD3lG.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-BlZODLp8.js → AchievementsPage-CZWCUiS5.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-Bc6NMnIa.js → AchievementsSection-BSk_fR8P.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-BUy4636q.js → BadgeDetailModal-CjHkcmuq.js} +1 -1
- package/dashboard/dist/assets/{Card-CqxuFMAN.js → Card-D6hdzwvI.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-BG3m8BgW.js → ClawdAnimated-Cl6gmF7u.js} +1 -1
- package/dashboard/dist/assets/{CommandPalette-Dcwtom2b.js → CommandPalette-B0rcodcF.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-dBjHrgjE.js → CommunityStatsModal-BtlTJbf4.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-DncQkptq.js → ConfirmModal-tJCWVZQH.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-CdF5WNHN.js → DashboardPage-Dtxq8dzI.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-B-PO4s-r.js → DevicePage-9USuEsRu.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-DGtj17VY.js → DialogClose-DxHdqMcl.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-DgUSe6A1.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-DLkuu1Iw.js → DialogTitle-C1ZeQgf2.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-Dd5RBmXd.js → FadeIn-Cx4jLl9G.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-BBCOpHqO.js → HeaderGithubStar-BOyuGkoA.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BbigYxdC.js → HoverTooltip-BDhqMR3L.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BBpZYjSC.js → IpCheckPage-DTvA9Wmx.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-ttXnt_s9.js → LandingPage-k1271lWV.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardAvatar-DOl_cOO9.js → LeaderboardAvatar-3ibNg6If.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-BYIyoLkB.js → LeaderboardPage-Byww5UpT.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProfileModal-BO2n4LSQ.js → LeaderboardProfileModal-DeGbJtvi.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-CqwW5yMw.js → LeaderboardProfilePage-DEPzO6hW.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-B-w771Tl.js → LimitsPage-DPtqL0PS.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-Cqc_diwF.js → LocalOnlyNotice-C76LAT_3.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-D6zc1JKY.js → LoginCard-DEyCJT67.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-udN3TqoF.js → LoginModal-CueMQgAZ.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-BucPr3_X.js → LoginPage-CwqBb5Fd.js} +1 -1
- package/dashboard/dist/assets/{PetPage-6_nmMXWp.js → PetPage--xQAjW4_.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-DntczBmH.js → PopoverPopup-Dt9VY2VQ.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-Z6qlwSj1.js → ProviderIcon-CHx4ohfx.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-WqQwsQC1.js → ResetPasswordPage-DB6R7fjf.js} +1 -1
- package/dashboard/dist/assets/{SegmentedControl-D3NM3dOv.js → SegmentedControl-BINOpXIY.js} +1 -1
- package/dashboard/dist/assets/{Select-DCpwSFK7.js → Select-DcYXcsKv.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-DICaclqa.js → SelectItemText-BDv2Kb3x.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-COHoSjPP.js → SessionsPage-cL_w0ytB.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-nzbrBo_U.js → SettingsPage-CHGA0bQS.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-DE8mK1lS.js → SkillsPage-I29SqkXO.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-BSWGbByr.js → TokenGalaxy-BHq4YSv2.js} +1 -1
- package/dashboard/dist/assets/{ToolbarRootContext-CxxXTuTT.js → ToolbarRootContext-akXaaKb6.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-DillSTMV.js → TrendMonitor-DPhFXzQc.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-LqyxKYAt.js → WidgetsPage-Nf0UEz7s.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-DNDuRKjf.js → WrappedPage-D4zOSsqD.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-DEhUaWQY.js → __vite-browser-external-UqlSqI-1.js} +2 -2
- package/dashboard/dist/assets/{agent-logos-D34B25op.js → agent-logos-Bja3VCAa.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-BYWbL4WV.js → arrow-up-right-CzcCNJJ2.js} +1 -1
- package/dashboard/dist/assets/{check-DkfaR6JX.js → check-DUHSZCYn.js} +1 -1
- package/dashboard/dist/assets/{chevron-right-D2cpt_J3.js → chevron-right-jLvhaNUy.js} +1 -1
- package/dashboard/dist/assets/{copy-Cv5Ix0Pn.js → copy-ChyH-ynx.js} +1 -1
- package/dashboard/dist/assets/{download-5nr9Tl80.js → download-CgwvXrUe.js} +1 -1
- package/dashboard/dist/assets/{flame-B6M-msYH.js → flame-ysf1F8uB.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-DiRRwgY8.js → format-tokens-DAa2cubl.js} +1 -1
- package/dashboard/dist/assets/{icons-DQHoG48j.js → icons-DccoWQq9.js} +1 -1
- package/dashboard/dist/assets/{index-hSxFduER.js → index-CAycNPQf.js} +1 -1
- package/dashboard/dist/assets/{index-BoH_HaYH.js → index-CxExExXh.js} +1 -1
- package/dashboard/dist/assets/{index-vFee2-sp.js → index-kkQrDRat.js} +1 -1
- package/dashboard/dist/assets/{info-CM5MR8lk.js → info-DWQQIq9M.js} +1 -1
- package/dashboard/dist/assets/{limits-providers-BV4Y9nI4.js → limits-providers-B_18X9Rp.js} +1 -1
- package/dashboard/dist/assets/{link-2-Bd5jF09Z.js → link-2-CKeVVq4P.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-B5oZJSYV.js → loader-circle-Dw0tu6IN.js} +1 -1
- package/dashboard/dist/assets/{maximize-2-CiYy9Kri.js → maximize-2-BMU0YzEF.js} +1 -1
- package/dashboard/dist/assets/{provider-display-lzLynfde.js → provider-display-Cf9I-VLS.js} +1 -1
- package/dashboard/dist/assets/{react-CllryaXi.js → react-BhbcISKy.js} +1 -1
- package/dashboard/dist/assets/{search-DDdsotHp.js → search-BoY8EW1z.js} +1 -1
- package/dashboard/dist/assets/{skills-api-487vZmwI.js → skills-api-KVH21GJw.js} +1 -1
- package/dashboard/dist/assets/{store-CYaTRd_k.js → store-BL7rSajG.js} +1 -1
- package/dashboard/dist/assets/{terminal-OyeOY0tb.js → terminal-CeMuITdm.js} +1 -1
- package/dashboard/dist/assets/{trash-2-COI9stXJ.js → trash-2-jVUCKqrR.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-DkzinngC.js → use-community-stats-uWK0fE6l.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-CiMETU5Y.js → use-limits-display-prefs-DWsF4ShM.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-qzpxm9Bh.js → use-native-settings-SEbqWDvc.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-BI-Qh9xR.js → use-ordered-list-D4UhrPvw.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-C3UrOh55.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-1WyhIjeG.js → use-session-efficiency-pref-DbysyUTJ.js} +1 -1
- package/dashboard/dist/assets/{use-transform-D5i_ArzG.js → use-transform-DaEssGaZ.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-Drcnt7__.js → use-usage-limits-CmmQ34Ov.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-KWJo1GIr.js → useCurrency-DvBEn4rx.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-K0FPky1Y.js → useScrollLock-QozsdFng.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-CwG4ck8v.js → useTokenFormat-BTLrL7Mi.js} +1 -1
- package/dashboard/dist/assets/{zap-wZ6IQAyU.js → zap-Dp_aJ1q6.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/ip-check.html +1 -1
- package/dashboard/dist/leaderboard.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/status.js +17 -7
- package/src/commands/sync.js +333 -5
- package/src/lib/codex-rollout-parser.js +17 -39
- package/src/lib/codex-token-usage.js +195 -0
- package/src/lib/pricing/curated-overrides.json +536 -101
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +732 -163
- package/src/lib/usage-limits.js +211 -41
- package/dashboard/dist/assets/DialogDescription-wStLk8Br.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-DrsPn1ux.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bP as Xt,bN as Rn,r,P as le,bc as Pt,aG as G,c8 as _t,c9 as Mt,ca as Bt,bT as Ct,aU as st,aE as He,A as Me,cb as zt,ba as jt,cc as at,aD as bn,b1 as Jt,cd as bt,ce as St,cf as Qt,cg as Lt,aS as ht,ch as Sn,bX as In,ci as At,ax as it,aI as be,W as Zt,aH as xt,aT as En,j as ye,V as Y,O as w,az as Ft,aK as Ot,aJ as Tn,aM as Mn,aN as Cn,aO as Dt,cj as vn,bU as wn,aL as yt,bL as Pn,y as en,z as Qe,ck as An,aA as On,cl as Vn,aB as Ln,bV as Fn,aW as Dn,cm as Nn,ay as tn,cn as vt}from"./__vite-browser-external-DEhUaWQY.js";import{v as We,q as kn,o as Un,E as Hn,G as Le,H as nn,J as _n,u as Bn,m as rn,h as zn,a as jn,l as Wn,A as Kn,I as Yn,d as qn,p as $n,b as Gn}from"./useScrollLock-K0FPky1Y.js";import{i as Xn,u as Jn,j as Qn,a as Zn,d as er,c as tr,e as nr,g as rr,k as or,p as sr,r as ir,h as lr}from"./ToolbarRootContext-CxxXTuTT.js";function tt(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const cr="Escape";function It(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function ft(e,t){return It(t,e===Qt||e===Lt,e===bt||e===St)}function wt(e,t,n){return It(t,e===Lt,n?e===bt:e===St)||e==="Enter"||e===" "||e===""}function ur(e,t,n){return It(t,n?e===bt:e===St,e===Lt)}function ar(e,t,n,o){const l=n?e===St:e===bt,c=e===Qt;return t==="both"||t==="horizontal"&&o?e===cr:It(t,l,c)}function fr(e,t){const{listRef:n,activeIndex:o,onNavigate:l=()=>{},enabled:c=!0,selectedIndex:i=null,allowEscape:R=!1,loopFocus:u=!1,nested:m=!1,rtl:v=!1,virtual:a=!1,focusItemOnOpen:p="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:O=void 0,orientation:g="vertical",parentOrientation:S,id:V,resetOnPointerLeave:E=!0,externalTree:d,grid:L}=t,j=L!=null,q="rootStore"in e?e.rootStore:e,D=q.useState("open"),W=q.useState("floatingElement"),J=q.useState("domReferenceElement"),me=q.context.dataRef,he=Xt(W),$=Rn(J),P=We(he),H=kn(),oe=Un(d),z=r.useRef(p),T=r.useRef(i??-1),K=r.useRef(null),k=r.useRef(!0),s=le(f=>{l(T.current===-1?null:T.current,f)}),M=r.useRef(!!W),ae=r.useRef(D),U=r.useRef(!1),pe=r.useRef(!1),ge=r.useRef(null),h=We(O),F=We(D),se=We(i),Se=We(E),B=Pt(),ne=Pt(),Q=le(()=>{function f(_){a?oe?.events.emit("virtualfocus",_):ge.current=Hn(_,{sync:U.current,preventScroll:!0})}const x=n.current[T.current],X=pe.current;x&&f(x),(U.current?_=>_():_=>B.request(_))(()=>{const _=n.current[T.current]||x;if(!_)return;x||f(_),Re&&(X||!k.current)&&_.scrollIntoView?.({block:"nearest",inline:"nearest"})})});G(()=>{me.current.orientation=g},[me,g]),G(()=>{c&&(D&&W?(T.current=i??-1,z.current&&i!=null&&(pe.current=!0,s())):M.current&&(T.current=-1,s()))},[c,D,W,i,s]),G(()=>{if(c){if(!D){U.current=!1;return}if(W)if(o==null){if(U.current=!1,se.current!=null)return;if(M.current&&(T.current=-1,Q()),(!ae.current||!M.current)&&z.current&&(K.current!=null||z.current===!0&&K.current==null)){let f=0;const x=()=>{n.current[0]==null?(f<2&&(f?I=>ne.request(I):queueMicrotask)(x),f+=1):(T.current=K.current==null||wt(K.current,g,v)||m?Mt(n):Bt(n),K.current=null,s())};x()}}else _t(n.current,o)||(T.current=o,Q(),pe.current=!1)}},[c,D,W,o,se,m,n,g,v,s,Q,ne]),G(()=>{if(!c||W||!oe||a||!M.current)return;const f=oe.nodesRef.current,x=f.find(_=>_.id===H)?.context?.elements.floating,X=Ct(st(J??x??null)),I=f.some(_=>_.context&&He(_.context.elements.floating,X));x&&!I&&k.current&&x.focus({preventScroll:!0})},[c,W,J,oe,H,a]),G(()=>{ae.current=D,M.current=!!W}),G(()=>{D||(K.current=null,z.current=p)},[D,p]);const xe=o!=null,ce=le(f=>{if(!F.current)return;const x=n.current.indexOf(f.currentTarget);x!==-1&&(T.current!==x||o!==x)&&(T.current=x,s(f))}),ue=le(()=>S??oe?.nodesRef.current.find(f=>f.id===H)?.context?.dataRef?.current.orientation),de=le(()=>Mt(n,h.current)),ee=le(f=>{if(k.current=!1,U.current=!0,f.which===229||!F.current&&f.currentTarget===P.current)return;if(m&&ar(f.key,g,v,j)){ft(f.key,ue())||Le(f),q.setOpen(!1,Me(zt,f.nativeEvent)),jt(J)&&(a?oe?.events.emit("virtualfocus",J):J.focus());return}const x=T.current,X=Mt(n,O),I=Bt(n,O);if($||(f.key==="Home"&&(Le(f),T.current=X,s(f)),f.key==="End"&&(Le(f),T.current=I,s(f))),L!=null){const _=L(f,T.current,n,g,u,v,O,X,I);if(_!=null&&(T.current=_,s(f)),g==="both")return}if(ft(f.key,g)){if(Le(f),D&&!a&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){T.current=wt(f.key,g,v)?X:I,s(f);return}wt(f.key,g,v)?u?x>=I?R&&x!==n.current.length?T.current=-1:(U.current=!1,T.current=X):T.current=at(n.current,{startingIndex:x,disabledIndices:O}):T.current=Math.min(I,at(n.current,{startingIndex:x,disabledIndices:O})):u?x<=X?R&&x!==-1?T.current=n.current.length:(U.current=!1,T.current=I):T.current=at(n.current,{startingIndex:x,decrement:!0,disabledIndices:O}):T.current=Math.max(X,at(n.current,{startingIndex:x,decrement:!0,disabledIndices:O})),_t(n.current,T.current)&&(T.current=-1),s(f)}}),Re=r.useMemo(()=>({onFocus(x){U.current=!0,ce(x)},onClick:({currentTarget:x})=>x.focus({preventScroll:!0}),onMouseMove(x){U.current=!0,pe.current=!1,b&&ce(x)},onPointerLeave(x){if(!F.current||!k.current||x.pointerType==="touch")return;U.current=!0;const X=x.relatedTarget;if(!(!b||n.current.includes(X))&&Se.current&&(ge.current?.(),ge.current=null,T.current=-1,s(x),!a)){const I=P.current,_=Ct(st(I));I&&He(I,_)&&I.focus({preventScroll:!0})}}}),[ce,F,P,b,n,s,Se,a]),te=r.useMemo(()=>a&&D&&xe&&{"aria-activedescendant":`${V}-${o}`},[a,D,xe,V,o]),Z=r.useMemo(()=>({"aria-orientation":g==="both"?void 0:g,...$?{}:te,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&D&&!a){const x=bn(f.nativeEvent);if(x&&!He(P.current,x))return;Le(f),q.setOpen(!1,Me(Jt,f.nativeEvent)),jt(J)&&J.focus();return}ee(f)},onPointerMove(){k.current=!0}}),[te,ee,P,g,$,q,D,a,J]),re=r.useMemo(()=>{function f(I){q.setOpen(!0,Me(zt,I.nativeEvent,I.currentTarget))}function x(I){p==="auto"&&nn(I.nativeEvent)&&(z.current=!a)}function X(I){z.current=p,p==="auto"&&_n(I.nativeEvent)&&(z.current=!0)}return{onKeyDown(I){const _=q.select("open");k.current=!1;const ve=I.key.startsWith("Arrow"),De=ur(I.key,ue(),v),Ee=ft(I.key,g),Ae=(m?De:Ee)||I.key==="Enter"||I.key.trim()==="";if(a&&_)return ee(I);if(!(!_&&!y&&ve)){if(Ae){const fe=ft(I.key,ue());K.current=m&&fe?null:I.key}if(m){De&&(Le(I),_?(T.current=de(),s(I)):f(I));return}Ee&&(se.current!=null&&(T.current=se.current),Le(I),!_&&y?f(I):ee(I),_&&s(I))}},onFocus(I){q.select("open")&&!a&&(T.current=-1,s(I))},onPointerDown:X,onPointerEnter:X,onMouseDown:x,onClick:x}},[ee,p,de,m,s,q,y,g,ue,v,se,a]),A=r.useMemo(()=>({...te,...re}),[te,re]);return r.useMemo(()=>c?{reference:A,floating:Z,item:Re,trigger:re}:{},[c,A,Z,re,Re])}function dr(e,t){const{listRef:n,elementsRef:o,activeIndex:l,onMatch:c,disabledIndices:i,onTyping:R,enabled:u=!0,resetMs:m=750,selectedIndex:v=null}=t,a="rootStore"in e?e.rootStore:e,p=a.useState("open"),b=ht(),y=r.useRef(""),O=r.useRef(v??l??-1),g=r.useRef(null),S=le(d=>{function L(P){const H=o?.current[P];return!H||In(H)}function j(P){return L(P)?i==null||!Sn(At,P,i):!1}function q(P,H,oe=0){if(P.length===0)return-1;const z=(oe%P.length+P.length)%P.length,T=H.toLowerCase();for(let K=0;K<P.length;K+=1){const k=(z+K)%P.length;if(!(!P[k]?.toLowerCase().startsWith(T)||!j(k)))return k}return-1}const D=n.current;if(y.current.length>0&&d.key===" "&&(Le(d),R?.(!0)),y.current.length>0&&y.current[0]!==" "&&q(D,y.current)===-1&&d.key!==" "&&R?.(!1),D==null||d.key.length!==1||d.ctrlKey||d.metaKey||d.altKey)return;p&&d.key!==" "&&(Le(d),R?.(!0));const W=y.current==="";W&&(O.current=v??l??-1),D.every((P,H)=>P&&j(H)?P[0]?.toLowerCase()!==P[1]?.toLowerCase():!0)&&y.current===d.key&&(y.current="",O.current=g.current),y.current+=d.key,b.start(m,()=>{y.current="",O.current=g.current,R?.(!1)});const he=((W?v??l??-1:O.current)??0)+1,$=q(D,y.current,he);$!==-1?(c?.($),g.current=$):d.key!==" "&&(y.current="",R?.(!1))}),V=le(d=>{const L=d.relatedTarget,j=a.select("domReferenceElement"),q=a.select("floatingElement");He(j,L)||He(q,L)||(b.clear(),y.current="",O.current=g.current,R?.(!1))});G(()=>{!p&&v!==null||(b.clear(),g.current=null,y.current!==""&&(y.current=""))},[p,v,b]),G(()=>{p&&y.current===""&&(O.current=v??l??-1)},[p,v,l]);const E=r.useMemo(()=>({onKeyDown:S,onBlur:V}),[S,V]);return r.useMemo(()=>u?{reference:E,floating:E}:{},[u,E])}function pr(e){const[t,n]=r.useState({current:e,previous:null});return e!==t.current&&n({current:e,previous:t.current}),t.previous}function gr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:o="value"}){const{current:l}=r.useRef(e!==void 0),[c,i]=r.useState(t),R=l?e:c,u=r.useCallback(m=>{l||i(m)},[]);return[R,u]}const on=r.createContext(null),sn=r.createContext(null);function Ye(){const e=r.useContext(on);if(e===null)throw new Error(it(60));return e}function ln(){const e=r.useContext(sn);if(e===null)throw new Error(it(61));return e}let Kt=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const mr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},nt={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},hr={disabled:!1,...nt},yr={valid(e){return e===null?null:e?{[Kt.valid]:""}:{[Kt.invalid]:""}}},xr={invalid:void 0,name:void 0,validityData:{state:mr,errors:[],error:"",value:"",initialValue:null},setValidityData:be,disabled:void 0,touched:nt.touched,setTouched:be,dirty:nt.dirty,setDirty:be,filled:nt.filled,setFilled:be,focused:nt.focused,setFocused:be,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:hr,markedDirtyRef:{current:!1},registerFieldControl:be,validation:{getValidationProps:(e,t=Zt)=>t,inputRef:{current:null},registerInput:be,commit:async()=>{},change:be}},Rr=r.createContext(xr);function Nt(e=!0){const t=r.useContext(Rr);if(t.setValidityData===be&&!e)throw new Error(it(28));return t}function br(e,t,n,o,l=!0,c){const{registerFieldControl:i}=Nt(),R=r.useRef(null);R.current||(R.current=Symbol()),G(()=>{const u=R.current;return!u||!l?void 0:(i(u,{controlRef:e,getValue:o,id:t,name:c,value:n}),()=>{i(u,void 0)})},[e,l,o,t,c,i,n])}const Sr=r.createContext({controlId:void 0,registerControlId:be,labelId:void 0,setLabelId:be,messageIds:[],setMessageIds:be,getDescriptionProps:e=>e});function cn(){return r.useContext(Sr)}function un(e={}){const{id:t,implicit:n=!1,controlRef:o}=e,{controlId:l,registerControlId:c}=cn(),i=Bn(t),R=n?l:void 0,u=xt(()=>Symbol("labelable-control")),m=r.useRef(!1),v=r.useRef(t!=null),a=le(()=>{!m.current||c===be||(m.current=!1,c(u.current,void 0))});return G(()=>{if(c===be)return;let p;if(n){const b=o?.current;En(b)&&b.closest("label")!=null?p=t??null:p=R??i}else if(t!=null)v.current=!0,p=t;else if(v.current)p=i;else{a();return}if(p===void 0){a();return}m.current=!0,c(u.current,p)},[t,o,R,c,n,i,u,a]),r.useEffect(()=>a,[a]),l??i}const Ir=(e,t)=>Object.is(e,t);function Ke(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Er(e,t,n){return!e||e.length===0?!1:e.some(o=>o===void 0?!1:Ke(t,o,n))}function ot(e,t,n){return!e||e.length===0?-1:e.findIndex(o=>o===void 0?!1:Ke(o,t,n))}function Tr(e,t,n){return e.filter(o=>!Ke(t,o,n))}function Vt(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function an(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Mr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(an(t)){for(const n of t)for(const o of n.items)if(o&&o.value==null&&o.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function fn(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 Vt(e)}function je(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Vt(e.value):Vt(e)}function dn(e,t,n){function o(){return fn(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]??o();if(Array.isArray(t)){const l=t,c=an(l)?l.flatMap(i=>i.items):l;if(e==null||typeof e!="object"){const i=c.find(R=>R.value===e);return i&&i.label!=null?i.label:o()}if("value"in e){const i=c.find(R=>R&&R.value===e.value);if(i&&i.label!=null)return i.label}}return o()}function Cr(e,t,n){return e.reduce((o,l,c)=>(c>0&&o.push(", "),o.push(ye.jsx(r.Fragment,{children:dn(l,t,n)},c)),o),[])}const C={id:Y(e=>e.id),labelId:Y(e=>e.labelId),modal:Y(e=>e.modal),multiple:Y(e=>e.multiple),items:Y(e=>e.items),itemToStringLabel:Y(e=>e.itemToStringLabel),itemToStringValue:Y(e=>e.itemToStringValue),isItemEqualToValue:Y(e=>e.isItemEqualToValue),value:Y(e=>e.value),hasSelectedValue:Y(e=>{const{value:t,multiple:n,itemToStringValue:o}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:je(t,o)!==""}),hasNullItemLabel:Y((e,t)=>t?Mr(e.items):!1),open:Y(e=>e.open),mounted:Y(e=>e.mounted),forceMount:Y(e=>e.forceMount),transitionStatus:Y(e=>e.transitionStatus),openMethod:Y(e=>e.openMethod),activeIndex:Y(e=>e.activeIndex),selectedIndex:Y(e=>e.selectedIndex),isActive:Y((e,t)=>e.activeIndex===t),isSelected:Y((e,t)=>{const n=e.isItemEqualToValue,o=e.value;return e.multiple?Array.isArray(o)&&o.some(l=>Ke(t,l,n)):Ke(t,o,n)}),isSelectedByFocus:Y((e,t)=>e.selectedIndex===t),popupProps:Y(e=>e.popupProps),triggerProps:Y(e=>e.triggerProps),triggerElement:Y(e=>e.triggerElement),positionerElement:Y(e=>e.positionerElement),listElement:Y(e=>e.listElement),popupSide:Y(e=>e.popupSide),scrollUpArrowVisible:Y(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:Y(e=>e.scrollDownArrowVisible),hasScrollArrows:Y(e=>e.hasScrollArrows)},vr=r.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:be,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function wr(){return r.useContext(vr)}function Pr(e,t,n=(o,l)=>o===l){return e.length===t.length&&e.every((o,l)=>n(o,t[l]))}const Fe=1;function pn(e,t){return Math.max(0,e-t)}function Ar(e,t){if(t<=0)return 0;const n=tt(e,0,t),o=n,l=t-n,c=o<=Fe,i=l<=Fe;return c&&i?o<=l?0:t:c?0:i?t:n}function to(e){const{id:t,value:n,defaultValue:o=null,onValueChange:l,open:c,defaultOpen:i=!1,onOpenChange:R,name:u,form:m,autoComplete:v,disabled:a=!1,readOnly:p=!1,required:b=!1,modal:y=!0,actionsRef:O,inputRef:g,onOpenChangeComplete:S,items:V,multiple:E=!1,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j=Ir,highlightItemOnHover:q=!0,children:D}=e,{clearErrors:W}=wr(),{setDirty:J,setTouched:me,setFocused:he,validityData:$,setFilled:P,name:H,disabled:oe,validation:z,validationMode:T}=Nt(),K=un({id:t}),k=oe||a,s=H??u,[M,ae]=Wt({controlled:n,default:E?o??At:o,name:"Select",state:"value"}),[U,pe]=Wt({controlled:c,default:i,name:"Select",state:"open"}),ge=r.useRef([]),h=r.useRef([]),F=r.useRef(null),se=r.useRef(null),Se=r.useRef(0),B=r.useRef(null),ne=r.useRef([]),Q=r.useRef(!1),xe=r.useRef(null),ce=r.useRef(null),ue=r.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),de=r.useRef(!1),{mounted:ee,setMounted:Re,transitionStatus:te}=rn(U),{openMethod:Z,triggerProps:re}=Xn(U),A=xt(()=>new vn({id:K,labelId:void 0,modal:y,multiple:E,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,value:M,open:U,mounted:ee,transitionStatus:te,items:V,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=w(A,C.activeIndex),x=w(A,C.selectedIndex),X=w(A,C.triggerElement),I=w(A,C.positionerElement),_=pr(Z),ve=Z??_??null,De=r.useMemo(()=>E?"":je(M,L),[E,M,L]),Ee=r.useMemo(()=>E&&Array.isArray(M)?M.map(N=>je(N,L)):je(M,L),[E,M,L]),Ae=We(A.state.triggerElement),fe=le(()=>Ee);br(Ae,K,M,fe,!k,u);const Oe=r.useRef(M),Ve=E?Array.isArray(M)&&M.length>0:M!=null&&je(M,L)!=="";G(()=>{M!==Oe.current&&A.set("forceMount",!0)},[A,M]),G(()=>{P(Ve)},[Ve,P]),G(function(){const ie=ne.current;let Te;if(E){const Ie=Array.isArray(M)?M:[];if(Ie.length===0)Te=null;else{const Ue=Ie[Ie.length-1],ze=ot(ie,Ue,j);Te=ze===-1?null:ze}}else{const Ie=ot(ie,M,j);Te=Ie===-1?null:Ie}Te===null&&(ce.current=null),!U&&A.set("selectedIndex",Te)},[Ve,E,U,M,ne,j,A,ce]);function we(N){const ie=$.initialValue;return Array.isArray(N)&&Array.isArray(ie)?!Pr(N,ie,(Te,Ie)=>Ke(Te,Ie,j)):N!==ie}Jn(M,()=>{W(s),J(we(M)),z.change(M)});const qe=le((N,ie)=>{R?.(N,ie),!ie.isCanceled&&(pe(N),!N&&(ie.reason===Jt||ie.reason===wn)&&(me(!0),he(!1),T==="onBlur"&&z.commit(M)))}),$e=le(()=>{Re(!1),A.update({activeIndex:null,openMethod:null}),S?.(!1)});Ft({enabled:!O,open:U,ref:F,onComplete(){U||$e()}}),r.useImperativeHandle(O,()=>({unmount:$e}),[$e]);const Ne=le((N,ie)=>{l?.(N,ie),!ie.isCanceled&&ae(N)}),Pe=le(()=>{const N=A.state.listElement||F.current;if(!N)return;const ie=pn(N.scrollHeight,N.clientHeight),Te=Ar(N.scrollTop,ie),Ie=Te>0,Ue=Te<ie;A.state.scrollUpArrowVisible!==Ie&&A.set("scrollUpArrowVisible",Ie),A.state.scrollDownArrowVisible!==Ue&&A.set("scrollDownArrowVisible",Ue)}),_e=Qn({open:U,onOpenChange:qe,elements:{reference:X,floating:I}}),Ge=Zn(_e,{enabled:!p&&!k,event:"mousedown"}),Xe=zn(_e),ke=fr(_e,{enabled:!p&&!k,listRef:ge,activeIndex:f,selectedIndex:x,disabledIndices:At,onNavigate(N){N===null&&!U||A.set("activeIndex",N)},focusItemOnHover:q}),Be=dr(_e,{enabled:!p&&!k&&(U||!E),listRef:h,activeIndex:f,selectedIndex:x,disabledIndices:N=>gr(ge.current[N]),onMatch(N){U?A.set("activeIndex",N):Ne(ne.current[N],Me("none"))},onTyping(N){Q.current=N}}),Ze=r.useMemo(()=>{const N=Ot(Be.reference,ke.reference,Xe.reference,Ge.reference,re);return K&&(N.id=K),N},[Ge.reference,Be.reference,ke.reference,Xe.reference,re,K]),et=r.useMemo(()=>Ot(jn,Be.floating,ke.floating,Xe.floating),[Be.floating,ke.floating,Xe.floating]),lt=ke.item??Zt;Wn(()=>{A.update({popupProps:et,triggerProps:Ze})}),G(()=>{A.update({id:K,modal:y,multiple:E,value:M,open:U,mounted:ee,transitionStatus:te,popupProps:et,triggerProps:Ze,items:V,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,openMethod:ve})},[A,K,y,E,M,U,ee,te,et,Ze,V,d,L,j,ve]);const Ce=r.useMemo(()=>({store:A,name:s,required:b,disabled:k,readOnly:p,multiple:E,highlightItemOnHover:q,setValue:Ne,setOpen:qe,listRef:ge,popupRef:F,scrollHandlerRef:se,handleScrollArrowVisibility:Pe,scrollArrowsMountedCountRef:Se,itemProps:lt,valueRef:B,valuesRef:ne,labelsRef:h,typingRef:Q,selectionRef:ue,firstItemTextRef:xe,selectedItemTextRef:ce,validation:z,onOpenChangeComplete:S,alignItemWithTriggerActiveRef:de,initialValueRef:Oe}),[A,s,b,k,p,E,q,Ne,qe,lt,z,S,Pe]),Je=Tn(g,z.inputRef),ct=E&&Array.isArray(M)&&M.length>0,ut=E?void 0:s,Et=r.useMemo(()=>!E||!Array.isArray(M)||!s?null:M.map(N=>{const ie=je(N,L);return ye.jsx("input",{type:"hidden",form:m,name:s,value:ie,disabled:k},ie)}),[E,M,m,s,L,k]);return ye.jsx(on.Provider,{value:Ce,children:ye.jsxs(sn.Provider,{value:_e,children:[D,ye.jsx("input",{...z.getValidationProps(k,{onFocus(){A.state.triggerElement?.focus({focusVisible:!0})},onChange(N){if(N.nativeEvent.defaultPrevented||k||p)return;const ie=N.currentTarget.value,Te=Me(Dt,N.nativeEvent);function Ie(){if(E)return;const Ue=ie.toLowerCase();let ze=ne.current.findIndex(Tt=>je(Tt,L).toLowerCase()===Ue||fn(Tt,d).toLowerCase()===Ue);ze===-1&&(ze=ne.current.findIndex((Tt,xn)=>{const Ht=h.current[xn];return Ht!=null&&Ht.toLowerCase()===Ue}));const Ut=ze===-1?void 0:ne.current[ze];Ut!=null&&Ne(Ut,Te)}A.set("forceMount",!0),queueMicrotask(Ie)}}),id:K&&ut==null?`${K}-hidden-input`:void 0,form:m,name:ut,autoComplete:v,value:De,disabled:k,required:b&&!ct,readOnly:p,ref:Je,style:s?Mn:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Et]})})}function Or(e,t){return e??t}function Vr(e){const t=e.getBoundingClientRect(),n=yt(e);if(Pn)return t;const o=n.getComputedStyle(e,"::before"),l=n.getComputedStyle(e,"::after");if(!(o.content!=="none"||l.content!=="none"))return t;const i=parseFloat(o.width)||0,R=parseFloat(o.height)||0,u=parseFloat(l.width)||0,m=parseFloat(l.height)||0,v=Math.max(t.width,i,u),a=Math.max(t.height,R,m),p=v-t.width,b=a-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-b/2,bottom:t.bottom+b/2}}const dt=2,Lr=400,Fr={...Kn,...yr,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=r.forwardRef(function(t,n){const{render:o,className:l,id:c,disabled:i=!1,nativeButton:R=!0,style:u,...m}=t,{setTouched:v,setFocused:a,validationMode:p,state:b,disabled:y}=Nt(),{labelId:O}=cn(),{store:g,setOpen:S,selectionRef:V,validation:E,readOnly:d,required:L,alignItemWithTriggerActiveRef:j,disabled:q}=Ye(),D=y||q||i,W=w(g,C.open),J=w(g,C.mounted),me=w(g,C.value),he=w(g,C.triggerProps),$=w(g,C.positionerElement),P=w(g,C.listElement),H=w(g,C.popupSide),oe=w(g,C.id),z=w(g,C.labelId),T=w(g,C.hasSelectedValue),K=J&&$?H:null,k=c??oe,s=Or(O,z);un({id:k});const M=We($),ae=r.useRef(null),{getButtonProps:U,buttonRef:pe}=en({disabled:D,native:R}),ge=le(Q=>{g.set("triggerElement",Q)}),h=ht(),F=ht(),se=ht();r.useEffect(()=>{if(W)return se.start(Lr,()=>{V.current.allowUnselectedMouseUp=!0,V.current.allowSelectedMouseUp=!0}),()=>{se.clear()};V.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},F.clear()},[W,V,F,se]);const Se=Ot(he,{id:k,role:"combobox","aria-expanded":W?"true":"false","aria-haspopup":"listbox","aria-controls":W?P?.id??Xt($)?.id:void 0,"aria-labelledby":s,"aria-readonly":d||void 0,"aria-required":L||void 0,tabIndex:D?-1:0,onFocus(Q){a(!0),W&&j.current&&S(!1,Me(Dt,Q.nativeEvent)),h.start(0,()=>{g.set("forceMount",!0)})},onBlur(Q){He($,Q.relatedTarget)||(v(!0),a(!1),p==="onBlur"&&E.commit(me))},onMouseDown(Q){if(W)return;const xe=st(Q.currentTarget);function ce(ue){if(!ae.current)return;const de=ue.target;if(He(ae.current,de)||He(M.current,de))return;const ee=Vr(ae.current);ue.clientX>=ee.left-dt&&ue.clientX<=ee.right+dt&&ue.clientY>=ee.top-dt&&ue.clientY<=ee.bottom+dt||S(!1,Me(An,ue))}F.start(0,()=>{xe.addEventListener("mouseup",ce,{once:!0})})}},m,U),B=E.getValidationProps(D,Se);B.role="combobox";const ne={...b,open:W,disabled:D,value:me,readOnly:d,popupSide:K,placeholder:!T};return Qe("button",t,{ref:[n,ae,pe,ge],state:ne,stateAttributesMapping:Fr,props:B})}),Dr={value:()=>null},ro=r.forwardRef(function(t,n){const{className:o,render:l,children:c,placeholder:i,style:R,...u}=t,{store:m,valueRef:v}=Ye(),a=w(m,C.value),p=w(m,C.items),b=w(m,C.itemToStringLabel),y=w(m,C.hasSelectedValue),O=!y&&i!=null&&c==null,g=w(m,C.hasNullItemLabel,O),S={value:a,placeholder:!y};let V=null;return typeof c=="function"?V=c(a):c!=null?V=c:!y&&i!=null&&!g?V=i:Array.isArray(a)?V=Cr(a,p,b):V=dn(a,p,b),Qe("span",t,{state:S,ref:[n,v],props:[{children:V},u],stateAttributesMapping:Dr})}),Nr=r.createContext(void 0),oo=r.forwardRef(function(t,n){const{store:o}=Ye(),l=w(o,C.mounted),c=w(o,C.forceMount);return l||c?ye.jsx(Nr.Provider,{value:!0,children:ye.jsx(On,{ref:n,...t})}):null}),gn=r.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function kr(){return r.useContext(gn)}function Ur(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:l}=e,c=le(l),i=r.useRef(0),R=xt(_r).current,u=xt(Hr).current,[m,v]=r.useState(0),a=r.useRef(m),p=le((S,V)=>{u.set(S,V??null),a.current+=1,v(a.current)}),b=le(S=>{u.delete(S),a.current+=1,v(a.current)}),y=r.useMemo(()=>{const S=new Map;return Array.from(u.keys()).filter(E=>E.isConnected).sort(Br).forEach((E,d)=>{const L=u.get(E)??{};S.set(E,{...L,index:d})}),S},[u,m]);G(()=>{if(typeof MutationObserver!="function"||y.size===0)return;const S=new MutationObserver(V=>{const E=new Set,d=L=>E.has(L)?E.delete(L):E.add(L);V.forEach(L=>{L.removedNodes.forEach(d),L.addedNodes.forEach(d)}),E.size===0&&(a.current+=1,v(a.current))});return y.forEach((V,E)=>{E.parentElement&&S.observe(E.parentElement,{childList:!0})}),()=>{S.disconnect()}},[y]),G(()=>{a.current===m&&(n.current.length!==y.size&&(n.current.length=y.size),o&&o.current.length!==y.size&&(o.current.length=y.size),i.current=y.size),c(y)},[c,y,n,o,m]),G(()=>()=>{n.current=[]},[n]),G(()=>()=>{o&&(o.current=[])},[o]);const O=le(S=>(R.add(S),()=>{R.delete(S)}));G(()=>{R.forEach(S=>S(y))},[R,y]);const g=r.useMemo(()=>({register:p,unregister:b,subscribeMapChange:O,elementsRef:n,labelsRef:o,nextIndexRef:i}),[p,b,O,n,o,i]);return ye.jsx(gn.Provider,{value:g,children:t})}function Hr(){return new Map}function _r(){return new Set}function Br(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const mn=r.createContext(void 0);function zr(){const e=r.useContext(mn);if(!e)throw new Error(it(59));return e}function Rt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Wr={position:"fixed"},so=r.forwardRef(function(t,n){const{anchor:o,positionMethod:l="absolute",className:c,render:i,side:R="bottom",align:u="center",sideOffset:m=0,alignOffset:v=0,collisionBoundary:a="clipping-ancestors",collisionPadding:p,arrowPadding:b=5,sticky:y=!1,disableAnchorTracking:O,alignItemWithTrigger:g=!0,collisionAvoidance:S=Vn,style:V,...E}=t,{store:d,listRef:L,labelsRef:j,alignItemWithTriggerActiveRef:q,selectedItemTextRef:D,valuesRef:W,initialValueRef:J,popupRef:me,setValue:he}=Ye(),$=ln(),P=w(d,C.open),H=w(d,C.mounted),oe=w(d,C.modal),z=w(d,C.value),T=w(d,C.openMethod),K=w(d,C.positionerElement),k=w(d,C.triggerElement),s=w(d,C.isItemEqualToValue),M=w(d,C.transitionStatus),ae=r.useRef(null),U=r.useRef(null),[pe,ge]=r.useState(g),h=H&&pe&&T!=="touch";!H&&pe!==g&&ge(g),G(()=>{H||(C.scrollUpArrowVisible(d.state)&&d.set("scrollUpArrowVisible",!1),C.scrollDownArrowVisible(d.state)&&d.set("scrollDownArrowVisible",!1))},[d,H]),r.useImperativeHandle(q,()=>h),er((h||oe)&&P,T==="touch",K,k);const F=tr({anchor:o,floatingRootContext:$,positionMethod:l,mounted:H,side:R,sideOffset:m,align:u,alignOffset:v,arrowPadding:b,collisionBoundary:a,collisionPadding:p,sticky:y,disableAnchorTracking:O??h,collisionAvoidance:S,keepMounted:!0}),se=h?"none":F.side,Se=h?Wr:F.positionerStyles,B={open:P,side:se,align:F.align,anchorHidden:F.anchorHidden};G(()=>{d.set("popupSide",F.side)},[d,F.side]);const ne=le(de=>{d.set("positionerElement",de)}),Q=nr(t,B,{styles:Se,transitionStatus:M,props:E,refs:[n,ne],hidden:!H,inert:!P}),xe=r.useRef(0),ce=le(de=>{if(de.size===0&&xe.current===0||W.current.length===0)return;const ee=xe.current;if(xe.current=de.size,de.size===ee)return;const Re=Me(Dt);if(ee!==0&&!d.state.multiple&&z!==null&&ot(W.current,z,s)===-1){const Z=J.current,A=Z!=null&&ot(W.current,Z,s)!==-1?Z:null;he(A,Re),A===null&&(d.set("selectedIndex",null),D.current=null)}if(ee!==0&&d.state.multiple&&Array.isArray(z)){const te=re=>ot(W.current,re,s)!==-1,Z=z.filter(re=>te(re));(Z.length!==z.length||Z.some(re=>!Er(z,re,s)))&&(he(Z,Re),Z.length===0&&(d.set("selectedIndex",null),D.current=null))}if(P&&h){d.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const te={height:""};Rt(K,te),Rt(me.current,te)}}),ue=r.useMemo(()=>({...F,side:se,alignItemWithTriggerActive:h,setControlledAlignItemWithTrigger:ge,scrollUpArrowRef:ae,scrollDownArrowRef:U}),[F,se,h,ge]);return ye.jsx(Ur,{elementsRef:L,labelsRef:j,onMapChange:ce,children:ye.jsxs(mn.Provider,{value:ue,children:[H&&oe&&ye.jsx(Yn,{inert:Ln(!P),cutout:k}),Q]})})}),pt="base-ui-disable-scrollbar",Yt={className:pt,getElement(e){return ye.jsx("style",{nonce:e,href:pt,precedence:"base-ui:low",children:`.${pt}{scrollbar-width:none}.${pt}::-webkit-scrollbar{display:none}`})}},Kr=r.createContext(void 0),Yr={disableStyleElements:!1};function qr(){return r.useContext(Kr)??Yr}const $r={...$n,...tn},io=r.forwardRef(function(t,n){const{render:o,className:l,style:c,finalFocus:i,...R}=t,{store:u,popupRef:m,onOpenChangeComplete:v,setOpen:a,valueRef:p,firstItemTextRef:b,selectedItemTextRef:y,multiple:O,handleScrollArrowVisibility:g,scrollHandlerRef:S,listRef:V,highlightItemOnHover:E}=Ye(),{side:d,align:L,alignItemWithTriggerActive:j,isPositioned:q,setControlledAlignItemWithTrigger:D}=zr(),W=rr()!=null,J=ln(),me=or(),{nonce:he,disableStyleElements:$}=qr(),P=w(u,C.id),H=w(u,C.open),oe=w(u,C.openMethod),z=w(u,C.mounted),T=w(u,C.popupProps),K=w(u,C.transitionStatus),k=w(u,C.triggerElement),s=w(u,C.positionerElement),M=w(u,C.listElement),ae=r.useRef(!1),U=r.useRef(!1),pe=r.useRef({}),ge=Pt(),h=le(B=>{if(!s||!m.current||!U.current)return;if(ae.current||!j){g();return}const ne=s.style.top==="0px",Q=s.style.bottom==="0px";if(!ne&&!Q){g();return}const xe=$t(s),ce=rt(s.getBoundingClientRect().height,"y",xe),ue=st(s),de=yt(s),ee=de.getComputedStyle(s),Re=parseFloat(ee.marginTop),te=parseFloat(ee.marginBottom),Z=qt(de.getComputedStyle(m.current)),re=Math.min(ue.documentElement.clientHeight-Re-te,Z),A=B.scrollTop,f=gt(B);let x=0,X=null,I=!1,_=!1;const ve=fe=>{s.style.height=`${fe}px`},De=(fe,Oe)=>{const Ve=tt(fe,0,re-ce);Ve>0&&ve(ce+Ve),B.scrollTop=Oe,re-(ce+Ve)<=Fe&&(ae.current=!0),g()},Ee=ne?f-A:A,Ae=Math.min(ce+Ee,re);if(x=Ae,Ee<=Fe){De(Ee,ne?f:0);return}if(re-Ae>Fe)ne?_=!0:X=0;else if(I=!0,Q&&A<f){const fe=ce+Ee-re;X=A-(Ee-fe)}if(x=Math.ceil(x),x!==0&&ve(x),_||X!=null){const fe=gt(B),Oe=_?fe:tt(X,0,fe);Math.abs(B.scrollTop-Oe)>Fe&&(B.scrollTop=Oe)}(I||x>=re-Fe)&&(ae.current=!0),g()});r.useImperativeHandle(S,()=>h,[h]),Ft({open:H,ref:m,onComplete(){H&&v?.(!0)}});const F={open:H,transitionStatus:K,side:d,align:L};G(()=>{!s||!m.current||Object.keys(pe.current).length||(pe.current={top:s.style.top||"0",left:s.style.left||"0",right:s.style.right,height:s.style.height,bottom:s.style.bottom,minHeight:s.style.minHeight,maxHeight:s.style.maxHeight,marginTop:s.style.marginTop,marginBottom:s.style.marginBottom})},[m,s]),G(()=>{H||j||(U.current=!1,ae.current=!1,Rt(s,pe.current))},[H,j,s,m]),G(()=>{const B=m.current;if(!H||!k||!s||!B||j&&!q||u.state.transitionStatus==="ending")return;if(!j){U.current=!0,ge.request(g),B.style.removeProperty("--transform-origin");return}const ne=Gr(B);B.style.removeProperty("--transform-origin");try{let Q=y.current;Q?.isConnected||(Q=!C.hasSelectedValue(u.state)&&b.current?.isConnected?b.current:null);const xe=p.current,ce=yt(s),ue=ce.getComputedStyle(s),de=ce.getComputedStyle(B),ee=st(k),Re=$t(k),te=mt(k.getBoundingClientRect(),Re),Z=mt(s.getBoundingClientRect(),Re),re=te.height,A=M||B,f=A.scrollHeight,x=parseFloat(de.borderBottomWidth),X=parseFloat(ue.marginTop)||10,I=parseFloat(ue.marginBottom)||10,_=parseFloat(ue.minHeight)||100,ve=qt(de),De=5,Ee=5,Ae=20,fe=ee.documentElement.clientHeight-X-I,Oe=ee.documentElement.clientWidth,Ve=fe-te.bottom+re;let we,qe=me==="rtl"?te.right-Z.width:te.left,$e=0;if(Q&&xe){const Ce=mt(xe.getBoundingClientRect(),Re);we=mt(Q.getBoundingClientRect(),Re),qe=Z.left+(me==="rtl"?Ce.right-we.right:Ce.left-we.left);const Je=Ce.top-te.top+Ce.height/2;$e=we.top-Z.top+we.height/2-Je}const Ne=Ve+$e+I+x;let Pe=Math.min(fe,Ne);const _e=fe-X-I,Ge=Ne-Pe,Xe=Oe-Ee;s.style.left=`${tt(qe,De,Xe-Z.width)}px`,s.style.height=`${Pe}px`,s.style.maxHeight="none",s.style.marginTop=`${X}px`,s.style.marginBottom=`${I}px`,B.style.height="100%";const ke=gt(A),Be=Ge>=ke-Fe;Be&&(Pe=Math.min(fe,Z.height)-(Ge-ke));const Ze=te.top<Ae||te.bottom>fe-Ae||Math.ceil(Pe)+Fe<Math.min(f,_),et=(ce.visualViewport?.scale??1)!==1&&Fn;if(Ze||et){U.current=!0,Rt(s,pe.current),D(!1);return}const lt=Math.max(_,Pe);if(Be){const Ce=Math.max(0,fe-Ne);s.style.top=Z.height>=_e?"0":`${Ce}px`,s.style.height=`${Pe}px`,A.scrollTop=gt(A)}else s.style.bottom="0",A.scrollTop=Ge;if(we){const Ce=Z.top,Je=Z.height,ct=we.top+we.height/2,ut=Je>0?(ct-Ce)/Je*100:50,Et=tt(ut,0,100);B.style.setProperty("--transform-origin",`50% ${Et}%`)}(lt===fe||Pe>=ve)&&(ae.current=!0),g(),E&&u.state.selectedIndex===null&&u.state.activeIndex===null&&V.current[0]!=null&&u.set("activeIndex",0),U.current=!0}finally{ne()}},[u,H,s,k,p,b,y,m,g,j,D,ge,M,V,E,me,q]),r.useEffect(()=>{if(!j||!s||!H)return;const B=yt(s);function ne(Q){a(!1,Me(Nn,Q))}return Dn(B,"resize",ne)},[a,j,s,H]);const se={...M?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":O||void 0,id:`${P}-list`},onKeyDown(B){W&&Gn.has(B.key)&&B.stopPropagation()},onScroll(B){M||h(B.currentTarget)},...j&&{style:M?{height:"100%"}:jr}},Se=Qe("div",t,{ref:[n,m],state:F,stateAttributesMapping:$r,props:[T,se,lr(K),{className:!M&&j?Yt.className:void 0},R]});return ye.jsxs(r.Fragment,{children:[!$&&Yt.getElement(he),ye.jsx(qn,{context:J,modal:!1,disabled:!z,openInteractionType:oe,returnFocus:i,restoreFocus:!0,children:Se})]})});function qt(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function gt(e){return pn(e.scrollHeight,e.clientHeight)}function $t(e){return sr.getScale(e)}function rt(e,t,n){return e/n[t]}function mt(e,t){return ir({x:rt(e.x,"x",t),y:rt(e.y,"y",t),width:rt(e.width,"x",t),height:rt(e.height,"y",t)})}const Gt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[o,l]of Gt)n[o]=t.getPropertyValue(o),t.setProperty(o,l,"important");return()=>{for(const[o]of Gt){const l=n[o];l?t.setProperty(o,l):t.removeProperty(o)}}}let hn=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Xr(e={}){const{label:t,metadata:n,textRef:o,indexGuessBehavior:l,index:c}=e,{register:i,unregister:R,subscribeMapChange:u,elementsRef:m,labelsRef:v,nextIndexRef:a}=kr(),p=r.useRef(-1),[b,y]=r.useState(c??(l===hn.GuessFromOrder?()=>{if(p.current===-1){const S=a.current;a.current+=1,p.current=S}return p.current}:-1)),O=r.useRef(null),g=r.useCallback(S=>{if(O.current=S,b!==-1&&S!==null&&(m.current[b]=S,v)){const V=t!==void 0;v.current[b]=V?t:o?.current?.textContent??S.textContent}},[b,m,v,t,o]);return G(()=>{if(c!=null)return;const S=O.current;if(S)return i(S,n),()=>{R(S)}},[c,i,R,n]),G(()=>{if(c==null)return u(S=>{const V=O.current?S.get(O.current)?.index:null;V!=null&&y(V)})},[c,u,y]),{ref:g,index:b}}const yn=r.createContext(void 0);function kt(){const e=r.useContext(yn);if(!e)throw new Error(it(57));return e}const lo=r.memo(r.forwardRef(function(t,n){const{render:o,className:l,style:c,value:i=null,label:R,disabled:u=!1,nativeButton:m=!1,...v}=t,a=r.useRef(null),p=Xr({label:R,textRef:a,indexGuessBehavior:hn.GuessFromOrder}),{store:b,itemProps:y,setOpen:O,setValue:g,selectionRef:S,typingRef:V,valuesRef:E,multiple:d,selectedItemTextRef:L,disabled:j,readOnly:q}=Ye(),D=w(b,C.isActive,p.index),W=w(b,C.open),J=w(b,C.isSelected,i),me=w(b,C.isSelectedByFocus,p.index),he=w(b,C.isItemEqualToValue),$=p.index,P=$!==-1,H=r.useRef(null);G(()=>{if(!P)return;const h=E.current;return h[$]=i,()=>{delete h[$]}},[P,$,i,E]),G(()=>{if(!P)return;const h=b.state.value;let F=h;d&&Array.isArray(h)&&(F=h.length>0?h[h.length-1]:void 0),F!==void 0&&Ke(i,F,he)&&(b.set("selectedIndex",$),a.current&&(L.current=a.current))},[P,$,d,he,b,i,L]);const oe=r.useRef(null),z=r.useRef("mouse"),T=r.useRef(!1),{getButtonProps:K,buttonRef:k}=en({disabled:u,focusableWhenDisabled:!0,native:m,composite:!0}),s={disabled:u,selected:J,highlighted:D};function M(h){if(j||q)return;const F=b.state.value;if(d){const se=Array.isArray(F)?F:[],Se=J?Tr(se,i,he):[...se,i];g(Se,Me(vt,h))}else g(i,Me(vt,h)),O(!1,Me(vt,h))}function ae(){S.current.dragY=0}const U={role:"option","aria-selected":J,tabIndex:W&&D?0:-1,onKeyDown(h){oe.current=h.key,b.set("activeIndex",$),h.key===" "&&V.current&&h.preventDefault()},onClick(h){const F=h.type==="click"&&z.current!=="touch",se=h.nativeEvent.pointerType,Se=F&&nn(h.nativeEvent)&&(se!==void 0||D),B=F&&!Se&&!T.current;T.current=!1,!(h.type==="keydown"&&oe.current===null)&&(u||h.type==="keydown"&&oe.current===" "&&V.current||B||(oe.current=null,M(h.nativeEvent)))},onPointerEnter(h){z.current=h.pointerType},onPointerMove(h){if(h.pointerType==="mouse"&&h.buttons===1){const F=S.current;F.dragY+=h.movementY,F.dragY**2>=64&&(F.allowUnselectedMouseUp=!0)}},onPointerDown(h){z.current=h.pointerType,T.current=!0,ae()},onMouseUp(){if(ae(),u||z.current==="touch"||T.current)return;const h=!S.current.allowSelectedMouseUp&&J,F=!S.current.allowUnselectedMouseUp&&!J;h||F||(T.current=!0,H.current?.click(),T.current=!1)}},pe=Qe("div",t,{ref:[k,n,p.ref,H],state:s,props:[y,U,v,K]}),ge=r.useMemo(()=>({selected:J,index:$,textRef:a,selectedByFocus:me,hasRegistered:P}),[J,$,a,me,P]);return ye.jsx(yn.Provider,{value:ge,children:pe})})),co=r.forwardRef(function(t,n){const o=t.keepMounted??!1,{selected:l}=kt();return o||l?ye.jsx(Jr,{...t,ref:n}):null}),Jr=r.memo(r.forwardRef((e,t)=>{const{render:n,className:o,style:l,keepMounted:c,...i}=e,{selected:R}=kt(),u=r.useRef(null),{transitionStatus:m,setMounted:v}=rn(R),p=Qe("span",e,{ref:[t,u],state:{selected:R,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:tn});return Ft({open:R,ref:u,onComplete(){R||v(!1)}}),p})),uo=r.memo(r.forwardRef(function(t,n){const{index:o,textRef:l,selectedByFocus:c,hasRegistered:i}=kt(),{firstItemTextRef:R,selectedItemTextRef:u}=Ye(),{render:m,className:v,style:a,...p}=t,b=r.useCallback(O=>{O&&(i&&o===0&&(R.current=O),i&&c&&(u.current=O))},[R,u,o,c,i]);return Qe("div",t,{ref:[b,n,l],props:p})}));export{jr as L,to as S,zr as a,Yt 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,yr as k,wr as l,Nt as m,cn as n,Wt as o,br as p,C as s,Ye as u};
|
|
1
|
+
import{bP as Xt,bN as Rn,r,P as le,bc as Pt,aG as G,c8 as _t,c9 as Mt,ca as Bt,bT as Ct,aU as st,aE as He,A as Me,cb as zt,ba as jt,cc as at,aD as bn,b1 as Jt,cd as bt,ce as St,cf as Qt,cg as Lt,aS as ht,ch as Sn,bX as In,ci as At,ax as it,aI as be,W as Zt,aH as xt,aT as En,j as ye,V as Y,O as w,az as Ft,aK as Ot,aJ as Tn,aM as Mn,aN as Cn,aO as Dt,cj as vn,bU as wn,aL as yt,bL as Pn,y as en,z as Qe,ck as An,aA as On,cl as Vn,aB as Ln,bV as Fn,aW as Dn,cm as Nn,ay as tn,cn as vt}from"./__vite-browser-external-UqlSqI-1.js";import{v as We,q as kn,o as Un,E as Hn,G as Le,H as nn,J as _n,u as Bn,m as rn,h as zn,a as jn,l as Wn,A as Kn,I as Yn,d as qn,p as $n,b as Gn}from"./useScrollLock-QozsdFng.js";import{i as Xn,u as Jn,j as Qn,a as Zn,d as er,c as tr,e as nr,g as rr,k as or,p as sr,r as ir,h as lr}from"./ToolbarRootContext-akXaaKb6.js";function tt(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const cr="Escape";function It(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function ft(e,t){return It(t,e===Qt||e===Lt,e===bt||e===St)}function wt(e,t,n){return It(t,e===Lt,n?e===bt:e===St)||e==="Enter"||e===" "||e===""}function ur(e,t,n){return It(t,n?e===bt:e===St,e===Lt)}function ar(e,t,n,o){const l=n?e===St:e===bt,c=e===Qt;return t==="both"||t==="horizontal"&&o?e===cr:It(t,l,c)}function fr(e,t){const{listRef:n,activeIndex:o,onNavigate:l=()=>{},enabled:c=!0,selectedIndex:i=null,allowEscape:R=!1,loopFocus:u=!1,nested:m=!1,rtl:v=!1,virtual:a=!1,focusItemOnOpen:p="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:O=void 0,orientation:g="vertical",parentOrientation:S,id:V,resetOnPointerLeave:E=!0,externalTree:d,grid:L}=t,j=L!=null,q="rootStore"in e?e.rootStore:e,D=q.useState("open"),W=q.useState("floatingElement"),J=q.useState("domReferenceElement"),me=q.context.dataRef,he=Xt(W),$=Rn(J),P=We(he),H=kn(),oe=Un(d),z=r.useRef(p),T=r.useRef(i??-1),K=r.useRef(null),k=r.useRef(!0),s=le(f=>{l(T.current===-1?null:T.current,f)}),M=r.useRef(!!W),ae=r.useRef(D),U=r.useRef(!1),pe=r.useRef(!1),ge=r.useRef(null),h=We(O),F=We(D),se=We(i),Se=We(E),B=Pt(),ne=Pt(),Q=le(()=>{function f(_){a?oe?.events.emit("virtualfocus",_):ge.current=Hn(_,{sync:U.current,preventScroll:!0})}const x=n.current[T.current],X=pe.current;x&&f(x),(U.current?_=>_():_=>B.request(_))(()=>{const _=n.current[T.current]||x;if(!_)return;x||f(_),Re&&(X||!k.current)&&_.scrollIntoView?.({block:"nearest",inline:"nearest"})})});G(()=>{me.current.orientation=g},[me,g]),G(()=>{c&&(D&&W?(T.current=i??-1,z.current&&i!=null&&(pe.current=!0,s())):M.current&&(T.current=-1,s()))},[c,D,W,i,s]),G(()=>{if(c){if(!D){U.current=!1;return}if(W)if(o==null){if(U.current=!1,se.current!=null)return;if(M.current&&(T.current=-1,Q()),(!ae.current||!M.current)&&z.current&&(K.current!=null||z.current===!0&&K.current==null)){let f=0;const x=()=>{n.current[0]==null?(f<2&&(f?I=>ne.request(I):queueMicrotask)(x),f+=1):(T.current=K.current==null||wt(K.current,g,v)||m?Mt(n):Bt(n),K.current=null,s())};x()}}else _t(n.current,o)||(T.current=o,Q(),pe.current=!1)}},[c,D,W,o,se,m,n,g,v,s,Q,ne]),G(()=>{if(!c||W||!oe||a||!M.current)return;const f=oe.nodesRef.current,x=f.find(_=>_.id===H)?.context?.elements.floating,X=Ct(st(J??x??null)),I=f.some(_=>_.context&&He(_.context.elements.floating,X));x&&!I&&k.current&&x.focus({preventScroll:!0})},[c,W,J,oe,H,a]),G(()=>{ae.current=D,M.current=!!W}),G(()=>{D||(K.current=null,z.current=p)},[D,p]);const xe=o!=null,ce=le(f=>{if(!F.current)return;const x=n.current.indexOf(f.currentTarget);x!==-1&&(T.current!==x||o!==x)&&(T.current=x,s(f))}),ue=le(()=>S??oe?.nodesRef.current.find(f=>f.id===H)?.context?.dataRef?.current.orientation),de=le(()=>Mt(n,h.current)),ee=le(f=>{if(k.current=!1,U.current=!0,f.which===229||!F.current&&f.currentTarget===P.current)return;if(m&&ar(f.key,g,v,j)){ft(f.key,ue())||Le(f),q.setOpen(!1,Me(zt,f.nativeEvent)),jt(J)&&(a?oe?.events.emit("virtualfocus",J):J.focus());return}const x=T.current,X=Mt(n,O),I=Bt(n,O);if($||(f.key==="Home"&&(Le(f),T.current=X,s(f)),f.key==="End"&&(Le(f),T.current=I,s(f))),L!=null){const _=L(f,T.current,n,g,u,v,O,X,I);if(_!=null&&(T.current=_,s(f)),g==="both")return}if(ft(f.key,g)){if(Le(f),D&&!a&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){T.current=wt(f.key,g,v)?X:I,s(f);return}wt(f.key,g,v)?u?x>=I?R&&x!==n.current.length?T.current=-1:(U.current=!1,T.current=X):T.current=at(n.current,{startingIndex:x,disabledIndices:O}):T.current=Math.min(I,at(n.current,{startingIndex:x,disabledIndices:O})):u?x<=X?R&&x!==-1?T.current=n.current.length:(U.current=!1,T.current=I):T.current=at(n.current,{startingIndex:x,decrement:!0,disabledIndices:O}):T.current=Math.max(X,at(n.current,{startingIndex:x,decrement:!0,disabledIndices:O})),_t(n.current,T.current)&&(T.current=-1),s(f)}}),Re=r.useMemo(()=>({onFocus(x){U.current=!0,ce(x)},onClick:({currentTarget:x})=>x.focus({preventScroll:!0}),onMouseMove(x){U.current=!0,pe.current=!1,b&&ce(x)},onPointerLeave(x){if(!F.current||!k.current||x.pointerType==="touch")return;U.current=!0;const X=x.relatedTarget;if(!(!b||n.current.includes(X))&&Se.current&&(ge.current?.(),ge.current=null,T.current=-1,s(x),!a)){const I=P.current,_=Ct(st(I));I&&He(I,_)&&I.focus({preventScroll:!0})}}}),[ce,F,P,b,n,s,Se,a]),te=r.useMemo(()=>a&&D&&xe&&{"aria-activedescendant":`${V}-${o}`},[a,D,xe,V,o]),Z=r.useMemo(()=>({"aria-orientation":g==="both"?void 0:g,...$?{}:te,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&D&&!a){const x=bn(f.nativeEvent);if(x&&!He(P.current,x))return;Le(f),q.setOpen(!1,Me(Jt,f.nativeEvent)),jt(J)&&J.focus();return}ee(f)},onPointerMove(){k.current=!0}}),[te,ee,P,g,$,q,D,a,J]),re=r.useMemo(()=>{function f(I){q.setOpen(!0,Me(zt,I.nativeEvent,I.currentTarget))}function x(I){p==="auto"&&nn(I.nativeEvent)&&(z.current=!a)}function X(I){z.current=p,p==="auto"&&_n(I.nativeEvent)&&(z.current=!0)}return{onKeyDown(I){const _=q.select("open");k.current=!1;const ve=I.key.startsWith("Arrow"),De=ur(I.key,ue(),v),Ee=ft(I.key,g),Ae=(m?De:Ee)||I.key==="Enter"||I.key.trim()==="";if(a&&_)return ee(I);if(!(!_&&!y&&ve)){if(Ae){const fe=ft(I.key,ue());K.current=m&&fe?null:I.key}if(m){De&&(Le(I),_?(T.current=de(),s(I)):f(I));return}Ee&&(se.current!=null&&(T.current=se.current),Le(I),!_&&y?f(I):ee(I),_&&s(I))}},onFocus(I){q.select("open")&&!a&&(T.current=-1,s(I))},onPointerDown:X,onPointerEnter:X,onMouseDown:x,onClick:x}},[ee,p,de,m,s,q,y,g,ue,v,se,a]),A=r.useMemo(()=>({...te,...re}),[te,re]);return r.useMemo(()=>c?{reference:A,floating:Z,item:Re,trigger:re}:{},[c,A,Z,re,Re])}function dr(e,t){const{listRef:n,elementsRef:o,activeIndex:l,onMatch:c,disabledIndices:i,onTyping:R,enabled:u=!0,resetMs:m=750,selectedIndex:v=null}=t,a="rootStore"in e?e.rootStore:e,p=a.useState("open"),b=ht(),y=r.useRef(""),O=r.useRef(v??l??-1),g=r.useRef(null),S=le(d=>{function L(P){const H=o?.current[P];return!H||In(H)}function j(P){return L(P)?i==null||!Sn(At,P,i):!1}function q(P,H,oe=0){if(P.length===0)return-1;const z=(oe%P.length+P.length)%P.length,T=H.toLowerCase();for(let K=0;K<P.length;K+=1){const k=(z+K)%P.length;if(!(!P[k]?.toLowerCase().startsWith(T)||!j(k)))return k}return-1}const D=n.current;if(y.current.length>0&&d.key===" "&&(Le(d),R?.(!0)),y.current.length>0&&y.current[0]!==" "&&q(D,y.current)===-1&&d.key!==" "&&R?.(!1),D==null||d.key.length!==1||d.ctrlKey||d.metaKey||d.altKey)return;p&&d.key!==" "&&(Le(d),R?.(!0));const W=y.current==="";W&&(O.current=v??l??-1),D.every((P,H)=>P&&j(H)?P[0]?.toLowerCase()!==P[1]?.toLowerCase():!0)&&y.current===d.key&&(y.current="",O.current=g.current),y.current+=d.key,b.start(m,()=>{y.current="",O.current=g.current,R?.(!1)});const he=((W?v??l??-1:O.current)??0)+1,$=q(D,y.current,he);$!==-1?(c?.($),g.current=$):d.key!==" "&&(y.current="",R?.(!1))}),V=le(d=>{const L=d.relatedTarget,j=a.select("domReferenceElement"),q=a.select("floatingElement");He(j,L)||He(q,L)||(b.clear(),y.current="",O.current=g.current,R?.(!1))});G(()=>{!p&&v!==null||(b.clear(),g.current=null,y.current!==""&&(y.current=""))},[p,v,b]),G(()=>{p&&y.current===""&&(O.current=v??l??-1)},[p,v,l]);const E=r.useMemo(()=>({onKeyDown:S,onBlur:V}),[S,V]);return r.useMemo(()=>u?{reference:E,floating:E}:{},[u,E])}function pr(e){const[t,n]=r.useState({current:e,previous:null});return e!==t.current&&n({current:e,previous:t.current}),t.previous}function gr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:o="value"}){const{current:l}=r.useRef(e!==void 0),[c,i]=r.useState(t),R=l?e:c,u=r.useCallback(m=>{l||i(m)},[]);return[R,u]}const on=r.createContext(null),sn=r.createContext(null);function Ye(){const e=r.useContext(on);if(e===null)throw new Error(it(60));return e}function ln(){const e=r.useContext(sn);if(e===null)throw new Error(it(61));return e}let Kt=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const mr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},nt={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},hr={disabled:!1,...nt},yr={valid(e){return e===null?null:e?{[Kt.valid]:""}:{[Kt.invalid]:""}}},xr={invalid:void 0,name:void 0,validityData:{state:mr,errors:[],error:"",value:"",initialValue:null},setValidityData:be,disabled:void 0,touched:nt.touched,setTouched:be,dirty:nt.dirty,setDirty:be,filled:nt.filled,setFilled:be,focused:nt.focused,setFocused:be,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:hr,markedDirtyRef:{current:!1},registerFieldControl:be,validation:{getValidationProps:(e,t=Zt)=>t,inputRef:{current:null},registerInput:be,commit:async()=>{},change:be}},Rr=r.createContext(xr);function Nt(e=!0){const t=r.useContext(Rr);if(t.setValidityData===be&&!e)throw new Error(it(28));return t}function br(e,t,n,o,l=!0,c){const{registerFieldControl:i}=Nt(),R=r.useRef(null);R.current||(R.current=Symbol()),G(()=>{const u=R.current;return!u||!l?void 0:(i(u,{controlRef:e,getValue:o,id:t,name:c,value:n}),()=>{i(u,void 0)})},[e,l,o,t,c,i,n])}const Sr=r.createContext({controlId:void 0,registerControlId:be,labelId:void 0,setLabelId:be,messageIds:[],setMessageIds:be,getDescriptionProps:e=>e});function cn(){return r.useContext(Sr)}function un(e={}){const{id:t,implicit:n=!1,controlRef:o}=e,{controlId:l,registerControlId:c}=cn(),i=Bn(t),R=n?l:void 0,u=xt(()=>Symbol("labelable-control")),m=r.useRef(!1),v=r.useRef(t!=null),a=le(()=>{!m.current||c===be||(m.current=!1,c(u.current,void 0))});return G(()=>{if(c===be)return;let p;if(n){const b=o?.current;En(b)&&b.closest("label")!=null?p=t??null:p=R??i}else if(t!=null)v.current=!0,p=t;else if(v.current)p=i;else{a();return}if(p===void 0){a();return}m.current=!0,c(u.current,p)},[t,o,R,c,n,i,u,a]),r.useEffect(()=>a,[a]),l??i}const Ir=(e,t)=>Object.is(e,t);function Ke(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Er(e,t,n){return!e||e.length===0?!1:e.some(o=>o===void 0?!1:Ke(t,o,n))}function ot(e,t,n){return!e||e.length===0?-1:e.findIndex(o=>o===void 0?!1:Ke(o,t,n))}function Tr(e,t,n){return e.filter(o=>!Ke(t,o,n))}function Vt(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function an(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Mr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(an(t)){for(const n of t)for(const o of n.items)if(o&&o.value==null&&o.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function fn(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 Vt(e)}function je(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Vt(e.value):Vt(e)}function dn(e,t,n){function o(){return fn(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]??o();if(Array.isArray(t)){const l=t,c=an(l)?l.flatMap(i=>i.items):l;if(e==null||typeof e!="object"){const i=c.find(R=>R.value===e);return i&&i.label!=null?i.label:o()}if("value"in e){const i=c.find(R=>R&&R.value===e.value);if(i&&i.label!=null)return i.label}}return o()}function Cr(e,t,n){return e.reduce((o,l,c)=>(c>0&&o.push(", "),o.push(ye.jsx(r.Fragment,{children:dn(l,t,n)},c)),o),[])}const C={id:Y(e=>e.id),labelId:Y(e=>e.labelId),modal:Y(e=>e.modal),multiple:Y(e=>e.multiple),items:Y(e=>e.items),itemToStringLabel:Y(e=>e.itemToStringLabel),itemToStringValue:Y(e=>e.itemToStringValue),isItemEqualToValue:Y(e=>e.isItemEqualToValue),value:Y(e=>e.value),hasSelectedValue:Y(e=>{const{value:t,multiple:n,itemToStringValue:o}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:je(t,o)!==""}),hasNullItemLabel:Y((e,t)=>t?Mr(e.items):!1),open:Y(e=>e.open),mounted:Y(e=>e.mounted),forceMount:Y(e=>e.forceMount),transitionStatus:Y(e=>e.transitionStatus),openMethod:Y(e=>e.openMethod),activeIndex:Y(e=>e.activeIndex),selectedIndex:Y(e=>e.selectedIndex),isActive:Y((e,t)=>e.activeIndex===t),isSelected:Y((e,t)=>{const n=e.isItemEqualToValue,o=e.value;return e.multiple?Array.isArray(o)&&o.some(l=>Ke(t,l,n)):Ke(t,o,n)}),isSelectedByFocus:Y((e,t)=>e.selectedIndex===t),popupProps:Y(e=>e.popupProps),triggerProps:Y(e=>e.triggerProps),triggerElement:Y(e=>e.triggerElement),positionerElement:Y(e=>e.positionerElement),listElement:Y(e=>e.listElement),popupSide:Y(e=>e.popupSide),scrollUpArrowVisible:Y(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:Y(e=>e.scrollDownArrowVisible),hasScrollArrows:Y(e=>e.hasScrollArrows)},vr=r.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:be,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function wr(){return r.useContext(vr)}function Pr(e,t,n=(o,l)=>o===l){return e.length===t.length&&e.every((o,l)=>n(o,t[l]))}const Fe=1;function pn(e,t){return Math.max(0,e-t)}function Ar(e,t){if(t<=0)return 0;const n=tt(e,0,t),o=n,l=t-n,c=o<=Fe,i=l<=Fe;return c&&i?o<=l?0:t:c?0:i?t:n}function to(e){const{id:t,value:n,defaultValue:o=null,onValueChange:l,open:c,defaultOpen:i=!1,onOpenChange:R,name:u,form:m,autoComplete:v,disabled:a=!1,readOnly:p=!1,required:b=!1,modal:y=!0,actionsRef:O,inputRef:g,onOpenChangeComplete:S,items:V,multiple:E=!1,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j=Ir,highlightItemOnHover:q=!0,children:D}=e,{clearErrors:W}=wr(),{setDirty:J,setTouched:me,setFocused:he,validityData:$,setFilled:P,name:H,disabled:oe,validation:z,validationMode:T}=Nt(),K=un({id:t}),k=oe||a,s=H??u,[M,ae]=Wt({controlled:n,default:E?o??At:o,name:"Select",state:"value"}),[U,pe]=Wt({controlled:c,default:i,name:"Select",state:"open"}),ge=r.useRef([]),h=r.useRef([]),F=r.useRef(null),se=r.useRef(null),Se=r.useRef(0),B=r.useRef(null),ne=r.useRef([]),Q=r.useRef(!1),xe=r.useRef(null),ce=r.useRef(null),ue=r.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),de=r.useRef(!1),{mounted:ee,setMounted:Re,transitionStatus:te}=rn(U),{openMethod:Z,triggerProps:re}=Xn(U),A=xt(()=>new vn({id:K,labelId:void 0,modal:y,multiple:E,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,value:M,open:U,mounted:ee,transitionStatus:te,items:V,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=w(A,C.activeIndex),x=w(A,C.selectedIndex),X=w(A,C.triggerElement),I=w(A,C.positionerElement),_=pr(Z),ve=Z??_??null,De=r.useMemo(()=>E?"":je(M,L),[E,M,L]),Ee=r.useMemo(()=>E&&Array.isArray(M)?M.map(N=>je(N,L)):je(M,L),[E,M,L]),Ae=We(A.state.triggerElement),fe=le(()=>Ee);br(Ae,K,M,fe,!k,u);const Oe=r.useRef(M),Ve=E?Array.isArray(M)&&M.length>0:M!=null&&je(M,L)!=="";G(()=>{M!==Oe.current&&A.set("forceMount",!0)},[A,M]),G(()=>{P(Ve)},[Ve,P]),G(function(){const ie=ne.current;let Te;if(E){const Ie=Array.isArray(M)?M:[];if(Ie.length===0)Te=null;else{const Ue=Ie[Ie.length-1],ze=ot(ie,Ue,j);Te=ze===-1?null:ze}}else{const Ie=ot(ie,M,j);Te=Ie===-1?null:Ie}Te===null&&(ce.current=null),!U&&A.set("selectedIndex",Te)},[Ve,E,U,M,ne,j,A,ce]);function we(N){const ie=$.initialValue;return Array.isArray(N)&&Array.isArray(ie)?!Pr(N,ie,(Te,Ie)=>Ke(Te,Ie,j)):N!==ie}Jn(M,()=>{W(s),J(we(M)),z.change(M)});const qe=le((N,ie)=>{R?.(N,ie),!ie.isCanceled&&(pe(N),!N&&(ie.reason===Jt||ie.reason===wn)&&(me(!0),he(!1),T==="onBlur"&&z.commit(M)))}),$e=le(()=>{Re(!1),A.update({activeIndex:null,openMethod:null}),S?.(!1)});Ft({enabled:!O,open:U,ref:F,onComplete(){U||$e()}}),r.useImperativeHandle(O,()=>({unmount:$e}),[$e]);const Ne=le((N,ie)=>{l?.(N,ie),!ie.isCanceled&&ae(N)}),Pe=le(()=>{const N=A.state.listElement||F.current;if(!N)return;const ie=pn(N.scrollHeight,N.clientHeight),Te=Ar(N.scrollTop,ie),Ie=Te>0,Ue=Te<ie;A.state.scrollUpArrowVisible!==Ie&&A.set("scrollUpArrowVisible",Ie),A.state.scrollDownArrowVisible!==Ue&&A.set("scrollDownArrowVisible",Ue)}),_e=Qn({open:U,onOpenChange:qe,elements:{reference:X,floating:I}}),Ge=Zn(_e,{enabled:!p&&!k,event:"mousedown"}),Xe=zn(_e),ke=fr(_e,{enabled:!p&&!k,listRef:ge,activeIndex:f,selectedIndex:x,disabledIndices:At,onNavigate(N){N===null&&!U||A.set("activeIndex",N)},focusItemOnHover:q}),Be=dr(_e,{enabled:!p&&!k&&(U||!E),listRef:h,activeIndex:f,selectedIndex:x,disabledIndices:N=>gr(ge.current[N]),onMatch(N){U?A.set("activeIndex",N):Ne(ne.current[N],Me("none"))},onTyping(N){Q.current=N}}),Ze=r.useMemo(()=>{const N=Ot(Be.reference,ke.reference,Xe.reference,Ge.reference,re);return K&&(N.id=K),N},[Ge.reference,Be.reference,ke.reference,Xe.reference,re,K]),et=r.useMemo(()=>Ot(jn,Be.floating,ke.floating,Xe.floating),[Be.floating,ke.floating,Xe.floating]),lt=ke.item??Zt;Wn(()=>{A.update({popupProps:et,triggerProps:Ze})}),G(()=>{A.update({id:K,modal:y,multiple:E,value:M,open:U,mounted:ee,transitionStatus:te,popupProps:et,triggerProps:Ze,items:V,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,openMethod:ve})},[A,K,y,E,M,U,ee,te,et,Ze,V,d,L,j,ve]);const Ce=r.useMemo(()=>({store:A,name:s,required:b,disabled:k,readOnly:p,multiple:E,highlightItemOnHover:q,setValue:Ne,setOpen:qe,listRef:ge,popupRef:F,scrollHandlerRef:se,handleScrollArrowVisibility:Pe,scrollArrowsMountedCountRef:Se,itemProps:lt,valueRef:B,valuesRef:ne,labelsRef:h,typingRef:Q,selectionRef:ue,firstItemTextRef:xe,selectedItemTextRef:ce,validation:z,onOpenChangeComplete:S,alignItemWithTriggerActiveRef:de,initialValueRef:Oe}),[A,s,b,k,p,E,q,Ne,qe,lt,z,S,Pe]),Je=Tn(g,z.inputRef),ct=E&&Array.isArray(M)&&M.length>0,ut=E?void 0:s,Et=r.useMemo(()=>!E||!Array.isArray(M)||!s?null:M.map(N=>{const ie=je(N,L);return ye.jsx("input",{type:"hidden",form:m,name:s,value:ie,disabled:k},ie)}),[E,M,m,s,L,k]);return ye.jsx(on.Provider,{value:Ce,children:ye.jsxs(sn.Provider,{value:_e,children:[D,ye.jsx("input",{...z.getValidationProps(k,{onFocus(){A.state.triggerElement?.focus({focusVisible:!0})},onChange(N){if(N.nativeEvent.defaultPrevented||k||p)return;const ie=N.currentTarget.value,Te=Me(Dt,N.nativeEvent);function Ie(){if(E)return;const Ue=ie.toLowerCase();let ze=ne.current.findIndex(Tt=>je(Tt,L).toLowerCase()===Ue||fn(Tt,d).toLowerCase()===Ue);ze===-1&&(ze=ne.current.findIndex((Tt,xn)=>{const Ht=h.current[xn];return Ht!=null&&Ht.toLowerCase()===Ue}));const Ut=ze===-1?void 0:ne.current[ze];Ut!=null&&Ne(Ut,Te)}A.set("forceMount",!0),queueMicrotask(Ie)}}),id:K&&ut==null?`${K}-hidden-input`:void 0,form:m,name:ut,autoComplete:v,value:De,disabled:k,required:b&&!ct,readOnly:p,ref:Je,style:s?Mn:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Et]})})}function Or(e,t){return e??t}function Vr(e){const t=e.getBoundingClientRect(),n=yt(e);if(Pn)return t;const o=n.getComputedStyle(e,"::before"),l=n.getComputedStyle(e,"::after");if(!(o.content!=="none"||l.content!=="none"))return t;const i=parseFloat(o.width)||0,R=parseFloat(o.height)||0,u=parseFloat(l.width)||0,m=parseFloat(l.height)||0,v=Math.max(t.width,i,u),a=Math.max(t.height,R,m),p=v-t.width,b=a-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-b/2,bottom:t.bottom+b/2}}const dt=2,Lr=400,Fr={...Kn,...yr,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=r.forwardRef(function(t,n){const{render:o,className:l,id:c,disabled:i=!1,nativeButton:R=!0,style:u,...m}=t,{setTouched:v,setFocused:a,validationMode:p,state:b,disabled:y}=Nt(),{labelId:O}=cn(),{store:g,setOpen:S,selectionRef:V,validation:E,readOnly:d,required:L,alignItemWithTriggerActiveRef:j,disabled:q}=Ye(),D=y||q||i,W=w(g,C.open),J=w(g,C.mounted),me=w(g,C.value),he=w(g,C.triggerProps),$=w(g,C.positionerElement),P=w(g,C.listElement),H=w(g,C.popupSide),oe=w(g,C.id),z=w(g,C.labelId),T=w(g,C.hasSelectedValue),K=J&&$?H:null,k=c??oe,s=Or(O,z);un({id:k});const M=We($),ae=r.useRef(null),{getButtonProps:U,buttonRef:pe}=en({disabled:D,native:R}),ge=le(Q=>{g.set("triggerElement",Q)}),h=ht(),F=ht(),se=ht();r.useEffect(()=>{if(W)return se.start(Lr,()=>{V.current.allowUnselectedMouseUp=!0,V.current.allowSelectedMouseUp=!0}),()=>{se.clear()};V.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},F.clear()},[W,V,F,se]);const Se=Ot(he,{id:k,role:"combobox","aria-expanded":W?"true":"false","aria-haspopup":"listbox","aria-controls":W?P?.id??Xt($)?.id:void 0,"aria-labelledby":s,"aria-readonly":d||void 0,"aria-required":L||void 0,tabIndex:D?-1:0,onFocus(Q){a(!0),W&&j.current&&S(!1,Me(Dt,Q.nativeEvent)),h.start(0,()=>{g.set("forceMount",!0)})},onBlur(Q){He($,Q.relatedTarget)||(v(!0),a(!1),p==="onBlur"&&E.commit(me))},onMouseDown(Q){if(W)return;const xe=st(Q.currentTarget);function ce(ue){if(!ae.current)return;const de=ue.target;if(He(ae.current,de)||He(M.current,de))return;const ee=Vr(ae.current);ue.clientX>=ee.left-dt&&ue.clientX<=ee.right+dt&&ue.clientY>=ee.top-dt&&ue.clientY<=ee.bottom+dt||S(!1,Me(An,ue))}F.start(0,()=>{xe.addEventListener("mouseup",ce,{once:!0})})}},m,U),B=E.getValidationProps(D,Se);B.role="combobox";const ne={...b,open:W,disabled:D,value:me,readOnly:d,popupSide:K,placeholder:!T};return Qe("button",t,{ref:[n,ae,pe,ge],state:ne,stateAttributesMapping:Fr,props:B})}),Dr={value:()=>null},ro=r.forwardRef(function(t,n){const{className:o,render:l,children:c,placeholder:i,style:R,...u}=t,{store:m,valueRef:v}=Ye(),a=w(m,C.value),p=w(m,C.items),b=w(m,C.itemToStringLabel),y=w(m,C.hasSelectedValue),O=!y&&i!=null&&c==null,g=w(m,C.hasNullItemLabel,O),S={value:a,placeholder:!y};let V=null;return typeof c=="function"?V=c(a):c!=null?V=c:!y&&i!=null&&!g?V=i:Array.isArray(a)?V=Cr(a,p,b):V=dn(a,p,b),Qe("span",t,{state:S,ref:[n,v],props:[{children:V},u],stateAttributesMapping:Dr})}),Nr=r.createContext(void 0),oo=r.forwardRef(function(t,n){const{store:o}=Ye(),l=w(o,C.mounted),c=w(o,C.forceMount);return l||c?ye.jsx(Nr.Provider,{value:!0,children:ye.jsx(On,{ref:n,...t})}):null}),gn=r.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function kr(){return r.useContext(gn)}function Ur(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:l}=e,c=le(l),i=r.useRef(0),R=xt(_r).current,u=xt(Hr).current,[m,v]=r.useState(0),a=r.useRef(m),p=le((S,V)=>{u.set(S,V??null),a.current+=1,v(a.current)}),b=le(S=>{u.delete(S),a.current+=1,v(a.current)}),y=r.useMemo(()=>{const S=new Map;return Array.from(u.keys()).filter(E=>E.isConnected).sort(Br).forEach((E,d)=>{const L=u.get(E)??{};S.set(E,{...L,index:d})}),S},[u,m]);G(()=>{if(typeof MutationObserver!="function"||y.size===0)return;const S=new MutationObserver(V=>{const E=new Set,d=L=>E.has(L)?E.delete(L):E.add(L);V.forEach(L=>{L.removedNodes.forEach(d),L.addedNodes.forEach(d)}),E.size===0&&(a.current+=1,v(a.current))});return y.forEach((V,E)=>{E.parentElement&&S.observe(E.parentElement,{childList:!0})}),()=>{S.disconnect()}},[y]),G(()=>{a.current===m&&(n.current.length!==y.size&&(n.current.length=y.size),o&&o.current.length!==y.size&&(o.current.length=y.size),i.current=y.size),c(y)},[c,y,n,o,m]),G(()=>()=>{n.current=[]},[n]),G(()=>()=>{o&&(o.current=[])},[o]);const O=le(S=>(R.add(S),()=>{R.delete(S)}));G(()=>{R.forEach(S=>S(y))},[R,y]);const g=r.useMemo(()=>({register:p,unregister:b,subscribeMapChange:O,elementsRef:n,labelsRef:o,nextIndexRef:i}),[p,b,O,n,o,i]);return ye.jsx(gn.Provider,{value:g,children:t})}function Hr(){return new Map}function _r(){return new Set}function Br(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const mn=r.createContext(void 0);function zr(){const e=r.useContext(mn);if(!e)throw new Error(it(59));return e}function Rt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Wr={position:"fixed"},so=r.forwardRef(function(t,n){const{anchor:o,positionMethod:l="absolute",className:c,render:i,side:R="bottom",align:u="center",sideOffset:m=0,alignOffset:v=0,collisionBoundary:a="clipping-ancestors",collisionPadding:p,arrowPadding:b=5,sticky:y=!1,disableAnchorTracking:O,alignItemWithTrigger:g=!0,collisionAvoidance:S=Vn,style:V,...E}=t,{store:d,listRef:L,labelsRef:j,alignItemWithTriggerActiveRef:q,selectedItemTextRef:D,valuesRef:W,initialValueRef:J,popupRef:me,setValue:he}=Ye(),$=ln(),P=w(d,C.open),H=w(d,C.mounted),oe=w(d,C.modal),z=w(d,C.value),T=w(d,C.openMethod),K=w(d,C.positionerElement),k=w(d,C.triggerElement),s=w(d,C.isItemEqualToValue),M=w(d,C.transitionStatus),ae=r.useRef(null),U=r.useRef(null),[pe,ge]=r.useState(g),h=H&&pe&&T!=="touch";!H&&pe!==g&&ge(g),G(()=>{H||(C.scrollUpArrowVisible(d.state)&&d.set("scrollUpArrowVisible",!1),C.scrollDownArrowVisible(d.state)&&d.set("scrollDownArrowVisible",!1))},[d,H]),r.useImperativeHandle(q,()=>h),er((h||oe)&&P,T==="touch",K,k);const F=tr({anchor:o,floatingRootContext:$,positionMethod:l,mounted:H,side:R,sideOffset:m,align:u,alignOffset:v,arrowPadding:b,collisionBoundary:a,collisionPadding:p,sticky:y,disableAnchorTracking:O??h,collisionAvoidance:S,keepMounted:!0}),se=h?"none":F.side,Se=h?Wr:F.positionerStyles,B={open:P,side:se,align:F.align,anchorHidden:F.anchorHidden};G(()=>{d.set("popupSide",F.side)},[d,F.side]);const ne=le(de=>{d.set("positionerElement",de)}),Q=nr(t,B,{styles:Se,transitionStatus:M,props:E,refs:[n,ne],hidden:!H,inert:!P}),xe=r.useRef(0),ce=le(de=>{if(de.size===0&&xe.current===0||W.current.length===0)return;const ee=xe.current;if(xe.current=de.size,de.size===ee)return;const Re=Me(Dt);if(ee!==0&&!d.state.multiple&&z!==null&&ot(W.current,z,s)===-1){const Z=J.current,A=Z!=null&&ot(W.current,Z,s)!==-1?Z:null;he(A,Re),A===null&&(d.set("selectedIndex",null),D.current=null)}if(ee!==0&&d.state.multiple&&Array.isArray(z)){const te=re=>ot(W.current,re,s)!==-1,Z=z.filter(re=>te(re));(Z.length!==z.length||Z.some(re=>!Er(z,re,s)))&&(he(Z,Re),Z.length===0&&(d.set("selectedIndex",null),D.current=null))}if(P&&h){d.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const te={height:""};Rt(K,te),Rt(me.current,te)}}),ue=r.useMemo(()=>({...F,side:se,alignItemWithTriggerActive:h,setControlledAlignItemWithTrigger:ge,scrollUpArrowRef:ae,scrollDownArrowRef:U}),[F,se,h,ge]);return ye.jsx(Ur,{elementsRef:L,labelsRef:j,onMapChange:ce,children:ye.jsxs(mn.Provider,{value:ue,children:[H&&oe&&ye.jsx(Yn,{inert:Ln(!P),cutout:k}),Q]})})}),pt="base-ui-disable-scrollbar",Yt={className:pt,getElement(e){return ye.jsx("style",{nonce:e,href:pt,precedence:"base-ui:low",children:`.${pt}{scrollbar-width:none}.${pt}::-webkit-scrollbar{display:none}`})}},Kr=r.createContext(void 0),Yr={disableStyleElements:!1};function qr(){return r.useContext(Kr)??Yr}const $r={...$n,...tn},io=r.forwardRef(function(t,n){const{render:o,className:l,style:c,finalFocus:i,...R}=t,{store:u,popupRef:m,onOpenChangeComplete:v,setOpen:a,valueRef:p,firstItemTextRef:b,selectedItemTextRef:y,multiple:O,handleScrollArrowVisibility:g,scrollHandlerRef:S,listRef:V,highlightItemOnHover:E}=Ye(),{side:d,align:L,alignItemWithTriggerActive:j,isPositioned:q,setControlledAlignItemWithTrigger:D}=zr(),W=rr()!=null,J=ln(),me=or(),{nonce:he,disableStyleElements:$}=qr(),P=w(u,C.id),H=w(u,C.open),oe=w(u,C.openMethod),z=w(u,C.mounted),T=w(u,C.popupProps),K=w(u,C.transitionStatus),k=w(u,C.triggerElement),s=w(u,C.positionerElement),M=w(u,C.listElement),ae=r.useRef(!1),U=r.useRef(!1),pe=r.useRef({}),ge=Pt(),h=le(B=>{if(!s||!m.current||!U.current)return;if(ae.current||!j){g();return}const ne=s.style.top==="0px",Q=s.style.bottom==="0px";if(!ne&&!Q){g();return}const xe=$t(s),ce=rt(s.getBoundingClientRect().height,"y",xe),ue=st(s),de=yt(s),ee=de.getComputedStyle(s),Re=parseFloat(ee.marginTop),te=parseFloat(ee.marginBottom),Z=qt(de.getComputedStyle(m.current)),re=Math.min(ue.documentElement.clientHeight-Re-te,Z),A=B.scrollTop,f=gt(B);let x=0,X=null,I=!1,_=!1;const ve=fe=>{s.style.height=`${fe}px`},De=(fe,Oe)=>{const Ve=tt(fe,0,re-ce);Ve>0&&ve(ce+Ve),B.scrollTop=Oe,re-(ce+Ve)<=Fe&&(ae.current=!0),g()},Ee=ne?f-A:A,Ae=Math.min(ce+Ee,re);if(x=Ae,Ee<=Fe){De(Ee,ne?f:0);return}if(re-Ae>Fe)ne?_=!0:X=0;else if(I=!0,Q&&A<f){const fe=ce+Ee-re;X=A-(Ee-fe)}if(x=Math.ceil(x),x!==0&&ve(x),_||X!=null){const fe=gt(B),Oe=_?fe:tt(X,0,fe);Math.abs(B.scrollTop-Oe)>Fe&&(B.scrollTop=Oe)}(I||x>=re-Fe)&&(ae.current=!0),g()});r.useImperativeHandle(S,()=>h,[h]),Ft({open:H,ref:m,onComplete(){H&&v?.(!0)}});const F={open:H,transitionStatus:K,side:d,align:L};G(()=>{!s||!m.current||Object.keys(pe.current).length||(pe.current={top:s.style.top||"0",left:s.style.left||"0",right:s.style.right,height:s.style.height,bottom:s.style.bottom,minHeight:s.style.minHeight,maxHeight:s.style.maxHeight,marginTop:s.style.marginTop,marginBottom:s.style.marginBottom})},[m,s]),G(()=>{H||j||(U.current=!1,ae.current=!1,Rt(s,pe.current))},[H,j,s,m]),G(()=>{const B=m.current;if(!H||!k||!s||!B||j&&!q||u.state.transitionStatus==="ending")return;if(!j){U.current=!0,ge.request(g),B.style.removeProperty("--transform-origin");return}const ne=Gr(B);B.style.removeProperty("--transform-origin");try{let Q=y.current;Q?.isConnected||(Q=!C.hasSelectedValue(u.state)&&b.current?.isConnected?b.current:null);const xe=p.current,ce=yt(s),ue=ce.getComputedStyle(s),de=ce.getComputedStyle(B),ee=st(k),Re=$t(k),te=mt(k.getBoundingClientRect(),Re),Z=mt(s.getBoundingClientRect(),Re),re=te.height,A=M||B,f=A.scrollHeight,x=parseFloat(de.borderBottomWidth),X=parseFloat(ue.marginTop)||10,I=parseFloat(ue.marginBottom)||10,_=parseFloat(ue.minHeight)||100,ve=qt(de),De=5,Ee=5,Ae=20,fe=ee.documentElement.clientHeight-X-I,Oe=ee.documentElement.clientWidth,Ve=fe-te.bottom+re;let we,qe=me==="rtl"?te.right-Z.width:te.left,$e=0;if(Q&&xe){const Ce=mt(xe.getBoundingClientRect(),Re);we=mt(Q.getBoundingClientRect(),Re),qe=Z.left+(me==="rtl"?Ce.right-we.right:Ce.left-we.left);const Je=Ce.top-te.top+Ce.height/2;$e=we.top-Z.top+we.height/2-Je}const Ne=Ve+$e+I+x;let Pe=Math.min(fe,Ne);const _e=fe-X-I,Ge=Ne-Pe,Xe=Oe-Ee;s.style.left=`${tt(qe,De,Xe-Z.width)}px`,s.style.height=`${Pe}px`,s.style.maxHeight="none",s.style.marginTop=`${X}px`,s.style.marginBottom=`${I}px`,B.style.height="100%";const ke=gt(A),Be=Ge>=ke-Fe;Be&&(Pe=Math.min(fe,Z.height)-(Ge-ke));const Ze=te.top<Ae||te.bottom>fe-Ae||Math.ceil(Pe)+Fe<Math.min(f,_),et=(ce.visualViewport?.scale??1)!==1&&Fn;if(Ze||et){U.current=!0,Rt(s,pe.current),D(!1);return}const lt=Math.max(_,Pe);if(Be){const Ce=Math.max(0,fe-Ne);s.style.top=Z.height>=_e?"0":`${Ce}px`,s.style.height=`${Pe}px`,A.scrollTop=gt(A)}else s.style.bottom="0",A.scrollTop=Ge;if(we){const Ce=Z.top,Je=Z.height,ct=we.top+we.height/2,ut=Je>0?(ct-Ce)/Je*100:50,Et=tt(ut,0,100);B.style.setProperty("--transform-origin",`50% ${Et}%`)}(lt===fe||Pe>=ve)&&(ae.current=!0),g(),E&&u.state.selectedIndex===null&&u.state.activeIndex===null&&V.current[0]!=null&&u.set("activeIndex",0),U.current=!0}finally{ne()}},[u,H,s,k,p,b,y,m,g,j,D,ge,M,V,E,me,q]),r.useEffect(()=>{if(!j||!s||!H)return;const B=yt(s);function ne(Q){a(!1,Me(Nn,Q))}return Dn(B,"resize",ne)},[a,j,s,H]);const se={...M?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":O||void 0,id:`${P}-list`},onKeyDown(B){W&&Gn.has(B.key)&&B.stopPropagation()},onScroll(B){M||h(B.currentTarget)},...j&&{style:M?{height:"100%"}:jr}},Se=Qe("div",t,{ref:[n,m],state:F,stateAttributesMapping:$r,props:[T,se,lr(K),{className:!M&&j?Yt.className:void 0},R]});return ye.jsxs(r.Fragment,{children:[!$&&Yt.getElement(he),ye.jsx(qn,{context:J,modal:!1,disabled:!z,openInteractionType:oe,returnFocus:i,restoreFocus:!0,children:Se})]})});function qt(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function gt(e){return pn(e.scrollHeight,e.clientHeight)}function $t(e){return sr.getScale(e)}function rt(e,t,n){return e/n[t]}function mt(e,t){return ir({x:rt(e.x,"x",t),y:rt(e.y,"y",t),width:rt(e.width,"x",t),height:rt(e.height,"y",t)})}const Gt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[o,l]of Gt)n[o]=t.getPropertyValue(o),t.setProperty(o,l,"important");return()=>{for(const[o]of Gt){const l=n[o];l?t.setProperty(o,l):t.removeProperty(o)}}}let hn=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Xr(e={}){const{label:t,metadata:n,textRef:o,indexGuessBehavior:l,index:c}=e,{register:i,unregister:R,subscribeMapChange:u,elementsRef:m,labelsRef:v,nextIndexRef:a}=kr(),p=r.useRef(-1),[b,y]=r.useState(c??(l===hn.GuessFromOrder?()=>{if(p.current===-1){const S=a.current;a.current+=1,p.current=S}return p.current}:-1)),O=r.useRef(null),g=r.useCallback(S=>{if(O.current=S,b!==-1&&S!==null&&(m.current[b]=S,v)){const V=t!==void 0;v.current[b]=V?t:o?.current?.textContent??S.textContent}},[b,m,v,t,o]);return G(()=>{if(c!=null)return;const S=O.current;if(S)return i(S,n),()=>{R(S)}},[c,i,R,n]),G(()=>{if(c==null)return u(S=>{const V=O.current?S.get(O.current)?.index:null;V!=null&&y(V)})},[c,u,y]),{ref:g,index:b}}const yn=r.createContext(void 0);function kt(){const e=r.useContext(yn);if(!e)throw new Error(it(57));return e}const lo=r.memo(r.forwardRef(function(t,n){const{render:o,className:l,style:c,value:i=null,label:R,disabled:u=!1,nativeButton:m=!1,...v}=t,a=r.useRef(null),p=Xr({label:R,textRef:a,indexGuessBehavior:hn.GuessFromOrder}),{store:b,itemProps:y,setOpen:O,setValue:g,selectionRef:S,typingRef:V,valuesRef:E,multiple:d,selectedItemTextRef:L,disabled:j,readOnly:q}=Ye(),D=w(b,C.isActive,p.index),W=w(b,C.open),J=w(b,C.isSelected,i),me=w(b,C.isSelectedByFocus,p.index),he=w(b,C.isItemEqualToValue),$=p.index,P=$!==-1,H=r.useRef(null);G(()=>{if(!P)return;const h=E.current;return h[$]=i,()=>{delete h[$]}},[P,$,i,E]),G(()=>{if(!P)return;const h=b.state.value;let F=h;d&&Array.isArray(h)&&(F=h.length>0?h[h.length-1]:void 0),F!==void 0&&Ke(i,F,he)&&(b.set("selectedIndex",$),a.current&&(L.current=a.current))},[P,$,d,he,b,i,L]);const oe=r.useRef(null),z=r.useRef("mouse"),T=r.useRef(!1),{getButtonProps:K,buttonRef:k}=en({disabled:u,focusableWhenDisabled:!0,native:m,composite:!0}),s={disabled:u,selected:J,highlighted:D};function M(h){if(j||q)return;const F=b.state.value;if(d){const se=Array.isArray(F)?F:[],Se=J?Tr(se,i,he):[...se,i];g(Se,Me(vt,h))}else g(i,Me(vt,h)),O(!1,Me(vt,h))}function ae(){S.current.dragY=0}const U={role:"option","aria-selected":J,tabIndex:W&&D?0:-1,onKeyDown(h){oe.current=h.key,b.set("activeIndex",$),h.key===" "&&V.current&&h.preventDefault()},onClick(h){const F=h.type==="click"&&z.current!=="touch",se=h.nativeEvent.pointerType,Se=F&&nn(h.nativeEvent)&&(se!==void 0||D),B=F&&!Se&&!T.current;T.current=!1,!(h.type==="keydown"&&oe.current===null)&&(u||h.type==="keydown"&&oe.current===" "&&V.current||B||(oe.current=null,M(h.nativeEvent)))},onPointerEnter(h){z.current=h.pointerType},onPointerMove(h){if(h.pointerType==="mouse"&&h.buttons===1){const F=S.current;F.dragY+=h.movementY,F.dragY**2>=64&&(F.allowUnselectedMouseUp=!0)}},onPointerDown(h){z.current=h.pointerType,T.current=!0,ae()},onMouseUp(){if(ae(),u||z.current==="touch"||T.current)return;const h=!S.current.allowSelectedMouseUp&&J,F=!S.current.allowUnselectedMouseUp&&!J;h||F||(T.current=!0,H.current?.click(),T.current=!1)}},pe=Qe("div",t,{ref:[k,n,p.ref,H],state:s,props:[y,U,v,K]}),ge=r.useMemo(()=>({selected:J,index:$,textRef:a,selectedByFocus:me,hasRegistered:P}),[J,$,a,me,P]);return ye.jsx(yn.Provider,{value:ge,children:pe})})),co=r.forwardRef(function(t,n){const o=t.keepMounted??!1,{selected:l}=kt();return o||l?ye.jsx(Jr,{...t,ref:n}):null}),Jr=r.memo(r.forwardRef((e,t)=>{const{render:n,className:o,style:l,keepMounted:c,...i}=e,{selected:R}=kt(),u=r.useRef(null),{transitionStatus:m,setMounted:v}=rn(R),p=Qe("span",e,{ref:[t,u],state:{selected:R,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:tn});return Ft({open:R,ref:u,onComplete(){R||v(!1)}}),p})),uo=r.memo(r.forwardRef(function(t,n){const{index:o,textRef:l,selectedByFocus:c,hasRegistered:i}=kt(),{firstItemTextRef:R,selectedItemTextRef:u}=Ye(),{render:m,className:v,style:a,...p}=t,b=r.useCallback(O=>{O&&(i&&o===0&&(R.current=O),i&&c&&(u.current=O))},[R,u,o,c,i]);return Qe("div",t,{ref:[b,n,l],props:p})}));export{jr as L,to as S,zr as a,Yt 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,yr as k,wr as l,Nt as m,cn as n,Wt as o,br as p,C as s,Ye as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as K,r as o,j as e,d as E,c as a,a0 as W,J as H,a2 as X,X as Y,R as ee,k as $,a3 as te,a4 as R}from"./__vite-browser-external-
|
|
1
|
+
import{l as K,r as o,j as e,d as E,c as a,a0 as W,J as H,a2 as X,X as Y,R as ee,k as $,a3 as te,a4 as R}from"./__vite-browser-external-UqlSqI-1.js";import{S as U,I as ae}from"./SegmentedControl-BINOpXIY.js";import{C as re}from"./ToolbarRootContext-akXaaKb6.js";import{S as z}from"./search-BoY8EW1z.js";import{C as se}from"./check-DUHSZCYn.js";import{P as oe,a as ie,b as ne,c as le,d as ce}from"./PopoverPopup-Dt9VY2VQ.js";import{P as de}from"./ProviderIcon-CHx4ohfx.js";import{H as ue}from"./HoverTooltip-BDhqMR3L.js";import{L as xe}from"./LocalOnlyNotice-C76LAT_3.js";import{u as me}from"./useCurrency-DvBEn4rx.js";import{i as he}from"./host-mode-Bc_iTzHk.js";import{L as fe}from"./loader-circle-Dw0tu6IN.js";import{T as pe}from"./terminal-CeMuITdm.js";import"./useScrollLock-QozsdFng.js";import"./store-BL7rSajG.js";import"./arrow-up-right-CzcCNJJ2.js";import"./download-CgwvXrUe.js";const ge=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],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,I]=o.useState(!1),[g,w]=o.useState(""),[c,m]=o.useState(-1),F=o.useRef(null),C=`${o.useId()}-listbox`,M=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),I(!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 D=y.length;return D?f?_>=D-1?0:_+1:_<=0?D-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=>{I(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:M}),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 Q=he(),_e=[],A=100,Se=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"}],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 De(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 Ie(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 G(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 Me=ee.memo(function({session:t,locale:s}){const{currency:d,rate:h}=me(),k=String(t.source||"").toUpperCase(),S=Ie(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),I=t.project_ref?`${t.project_ref}
|
|
2
2
|
${a("sessions.project.copy_hint")}`:void 0,g=async()=>{if(t.project_ref)try{await G(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:I,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 G(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:De(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,I]=o.useState("all"),[g,w]=o.useState("all"),[c,m]=o.useState(""),[F,C]=o.useState(A),M=o.useRef(0),{resolvedLocale:N}=W(),v=o.useCallback(async(i=!1)=>{const b=++M.current;i?u(!0):k(!0),d(null);try{const l=await Ne({refresh:i});b===M.current&&t(l)}catch(l){b===M.current&&d(l?.message||String(l))}finally{b===M.current&&(k(!1),u(!1))}},[]);o.useEffect(()=>{Q||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,D=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)&&D()},{rootMargin:"400px"});return b.observe(i),()=>b.disconnect()},[_,D]);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!Q&&!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:I}),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(Me,{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:D,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 +1 @@
|
|
|
1
|
-
import{l as C,r as u,j as t,d as N,c as a,a as ie,ap as oe,bv as re,av as le,aw as ce,a7 as F,bw as ue,bx as de,u as ge,R as L,Y as me,a0 as H,m as I,by as he,bz as pe,N as $,bA as be,x as fe,bB as xe,bC as ye,bD as ve,bE as ke,bF as je,bG as Ne,bH as Se,L as Ce,a2 as we,bI as Le,a4 as _,f as Ae,bJ as Oe}from"./__vite-browser-external-DEhUaWQY.js";import{b as Ee,g as Pe,L as G,m as V}from"./react-CllryaXi.js";import{u as Ie,L as T}from"./use-limits-display-prefs-CiMETU5Y.js";import{P as _e}from"./ProviderIcon-Z6qlwSj1.js";import{a as D,l as R}from"./limits-providers-BV4Y9nI4.js";import{a as S,T as k,b as f,S as A,u as O}from"./use-native-settings-qzpxm9Bh.js";import{P as Ge,u as Te,a as De}from"./use-session-efficiency-pref-1WyhIjeG.js";import{C as Re}from"./check-DkfaR6JX.js";import{C as Me}from"./copy-Cv5Ix0Pn.js";import{A as Ue}from"./index-BoH_HaYH.js";import{u as Fe}from"./useCurrency-KWJo1GIr.js";import{u as He}from"./useTokenFormat-CwG4ck8v.js";import{S as B}from"./Select-DCpwSFK7.js";import{I as $e}from"./info-CM5MR8lk.js";import{C as Ve}from"./ConfirmModal-DncQkptq.js";import{A as Be}from"./arrow-up-right-BYWbL4WV.js";import{D as ze}from"./download-5nr9Tl80.js";import"./Card-CqxuFMAN.js";import"./ToolbarRootContext-CxxXTuTT.js";import"./useScrollLock-K0FPky1Y.js";import"./SelectItemText-DICaclqa.js";import"./DialogTitle-DLkuu1Iw.js";import"./store-CYaTRd_k.js";import"./DialogDescription-wStLk8Br.js";const qe=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ke=C("activity",qe);const Ze=[["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"}]],We=C("flask-conical",Ze);const Ye=[["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"}]],Je=C("grip-vertical",Ye);const Qe=[["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"}]],Xe=C("languages",Qe);const et=[["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"}]],tt=C("log-out",et);const nt=[["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"}]],at=C("palette",nt);const st=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],it=C("user-round",st),ot=e=>!e.isLayoutDirty&&e.willUpdate(!1);function M(){const e=new Set,n=new WeakMap,s=()=>e.forEach(ot);return{add:i=>{e.add(i),n.set(i,i.addEventListener("willUpdate",s))},remove:i=>{e.delete(i);const o=n.get(i);o&&(o(),n.delete(i)),s()},dirty:s}}const rt=u.createContext(null);function lt(){const e=u.useRef(!1);return Ee(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function ct(){const e=lt(),[n,s]=u.useState(0),i=u.useCallback(()=>{e.current&&s(n+1)},[n]);return[u.useCallback(()=>Pe.postRender(i),[i]),n]}const z=e=>e===!0,ut=e=>z(e===!0)||e==="id",dt=({children:e,id:n,inherit:s=!0})=>{const i=u.useContext(G),o=u.useContext(rt),[r,l]=ct(),d=u.useRef(null),g=i.id||o;d.current===null&&(ut(s)&&g&&(n=n?g+"-"+n:g),d.current={id:n,group:z(s)&&i.group||M()});const p=u.useMemo(()=>({...d.current,forceRender:r}),[l]);return t.jsx(G.Provider,{value:p,children:e})},gt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function mt({checked:e,onChange:n,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:n,className:N("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:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function ht({prefs:e}){const{order:n,visibility:s,toggle:i,moveToward:o}=e,[r,l]=u.useState(null),[d,g]=u.useState(null),p=c=>h=>{l(c),h.dataTransfer.effectAllowed="move",h.dataTransfer.setData("text/plain",c)},m=c=>h=>{h.preventDefault(),h.dataTransfer.dropEffect="move",r&&r!==c&&d!==c&&(g(c),o(r,c))},x=()=>{l(null),g(null)},y=c=>{c.preventDefault(),l(null),g(null)};return t.jsx(dt,{children:t.jsx("div",{className:"flex flex-col",children:n.map(c=>{const h=s[c]!==!1,b=r===c;return t.jsxs(V.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:p(c),onDragOver:m(c),onDragEnd:x,onDrop:y,className:N("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",b&&"opacity-40"),style:{cursor:b?"grabbing":"grab"},children:[t.jsx(Je,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),D(c)?t.jsx(_e,{provider:D(c),size:18,className:N("pointer-events-none",gt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:R(c)}),t.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:t.jsx(mt,{checked:h,onChange:()=>i(c),ariaLabel:`${a("limits.settings.toggle_visible")}: ${R(c)}`})})]},c)})})})}function pt(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=n.full_name||n.name||s.name||n.user_name||n.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 bt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function ft(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const s=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=n.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 E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function xt(e,n,s){const[i,o]=u.useState(()=>oe()),r=n&&s&&re(),l=u.useCallback(async()=>{const d=!i;if(le(d),o(d),!!d)try{await ce(()=>e())}catch(g){E("cloud sync",g)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function yt(e){const[n,s]=u.useState(!1),[i,o]=u.useState(!1),[r,l]=u.useState(!1),[d,g]=u.useState(!1),[p,m]=u.useState(null),[x,y]=u.useState(!1),[c,h]=u.useState(""),[b,v]=u.useState(!1),[w,P]=u.useState(""),[W,Y]=u.useState(""),[J,Q]=u.useState(!1),[X,ee]=u.useState(null),te=u.useMemo(()=>pt(e),[e]),ne=u.useMemo(()=>bt(e),[e]),ae=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),se=u.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:P,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:v}),[]);return{anonymousOn:i,customDisplayName:p,displayName:te,editingGithub:J,editingName:x,email:ne,githubError:X,githubInput:W,githubUrl:w,loadSetters:se,nameInput:c,profileLoading:r,profileSaving:d,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:Q,setEditingName:y,setGithubError:ee,setGithubInput:Y,setGithubUrl:P,setNameInput:h,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:s,setShowGithubOn:v,showGithubOn:b,userId:ae}}function vt(e,n,s){u.useEffect(()=>{if(!n)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await F({getAccessToken:e});if(!i||!o)return;const r=await ue({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){E("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,n,s])}function kt(e,n){return u.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await F({getAccessToken:e});if(!l)return!1;const d=await de({accessToken:l,...s});return r?.(d),!0}catch(l){return o?o(l):E(i||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function jt(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function Nt(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function St(e,n){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:s}}function Ct(e,n,s){const i=u.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[n,e,s]),o=u.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function wt(e,n){const s=u.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),i=u.useCallback(async()=>{const r=ft(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=u.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Lt(){const e=ie(),n=yt(e.user),s=xt(e.getAccessToken,e.enabled,e.signedIn);vt(e.getAccessToken,e.signedIn,n.loadSetters);const i=kt(e.getAccessToken,n),o=St(n,i),r=Ct(n,i,e.refreshDisplayName),l=wt(n,i);return{...e,...s,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:jt(n,{...o,...r}),github:Nt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function q({disabled:e,onCancel:n,onSave:s,saveLabel:i=a("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:n,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:a("settings.account.cancel")})]})}function At({nameInput:e,setEditingName:n,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"&&n(!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:a("settings.account.displayName")}),t.jsx(q,{disabled:i||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:i?a("settings.account.saving"):void 0})]})}function Ot({githubError:e,githubInput:n,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:n,onChange:d=>{l(d.target.value),e&&r(null)},onKeyDown:d=>{d.key==="Enter"&&s(),d.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:a("settings.account.githubUrlPlaceholder")}),t.jsx(q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?a("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 K({disabled:e=!1,label:n,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(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function Z({actions:e,editing:n,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}),n?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),n?null:e]})})}function Et({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(K,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function Pt({name:e}){const{anonymousOn:n,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:d,profileLoading:g,profileSaving:p,setEditingName:m,setNameInput:x,startEditingName:y}=e,c=n?a("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(Z,{label:a("settings.account.displayName"),editing:o,hint:c,editor:t.jsx(At,{nameInput:d,setEditingName:m,setNameInput:x,profileSaving:p,handleSaveName:l}),actions:t.jsx(Et,{name:e})})}function It({github:e}){const{editingGithub:n,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:d,profileSaving:g,setEditingGithub:p,setGithubError:m,setGithubInput:x,showGithubOn:y,startEditingGithub:c}=e;return t.jsx(t.Fragment,{children:t.jsx(Z,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(Ot,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:g,setEditingGithub:p,setGithubError:m,setGithubInput:x}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(K,{label:a("settings.account.edit"),onClick:c}),t.jsx(k,{checked:y,onChange:l,disabled:d||g,ariaLabel:a("settings.account.githubUrl")})]})})})}function _t(){const{openLoginModal:e}=ge();return t.jsx(S,{title:a("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:a("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:a("settings.account.signIn")})]})})}function Gt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(Pt,{name:e}),t.jsx(It,{github:n})]})}function Tt(){const e=Lt();return e.enabled?e.signedIn?t.jsxs(S,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Rt,{onSignOut:e.signOut}),children:[t.jsx(Dt,{userId:e.userId}),t.jsx(Mt,{settings:e}),t.jsx(Ut,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Ft,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(_t,{}):null}function Dt({userId:e}){const[n,s]=L.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:a("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":a("settings.account.copyUserId"),children:[n?t.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Me,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Rt({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(tt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function Mt({settings:e}){return e.showLocalCloudSync?t.jsx(f,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Ut({checked:e,disabled:n,onChange:s}){return t.jsx(f,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function Ft({visible:e,name:n,github:s}){return t.jsx(Ue,{initial:!1,children:e?t.jsx(V.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(Gt,{name:n,github:s})},"public-profile-fields"):null})}function Ht(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:he},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:pe},{value:"system",label:a("settings.appearance.theme.system"),Icon:$}]}function $t(){return[{value:xe,label:a("settings.appearance.language.system")},{value:ye,label:a("settings.appearance.language.english")},{value:ve,label:a("settings.appearance.language.chinese")},{value:ke,label:a("settings.appearance.language.traditional_chinese")},{value:je,label:a("settings.appearance.language.japanese")},{value:Ne,label:a("settings.appearance.language.korean")},{value:Se,label:a("settings.appearance.language.german")}]}function Vt(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function Bt(e,n){const s=a(`settings.appearance.currency.rate_source.${e}`),i=Vt(n),o=i?a("settings.appearance.currency.rate_updated",{when:i}):a("settings.appearance.currency.rate_never");return`${s} · ${o}`}function zt({locale:e,setLocale:n}){const s=$t();return t.jsx(B,{value:e,onValueChange:n,options:s,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(Xe,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function qt({currency:e,setCurrency:n}){const s=be().map(i=>({value:i.code,label:a(i.labelKey)}));return t.jsx(B,{value:e,onValueChange:n,options:s,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Kt({currency:e,rate:n,rateSource:s,rateFetchedAt:i}){if(e===fe)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=Bt(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.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($e,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Zt(){const{theme:e,setTheme:n}=me(),{locale:s,setLocale:i}=H(),{currency:o,rate:r,rateSource:l,rateFetchedAt:d,setCurrency:g}=Fe(),{mode:p,setMode:m}=He();return t.jsxs(S,{title:a("settings.section.appearance"),children:[t.jsx(f,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(A,{options:Ht(),value:e,onChange:n})}),t.jsx(f,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(zt,{locale:s,setLocale:i})}),t.jsx(f,{label:a("settings.appearance.currency.label"),hint:t.jsx(Kt,{currency:o,rate:r,rateSource:l,rateFetchedAt:d}),control:t.jsx(qt,{currency:o,setCurrency:g})}),t.jsx(f,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(A,{options:[{value:I.COMPACT,label:a("settings.appearance.token_format.compact")},{value:I.FULL,label:a("settings.appearance.token_format.full")}],value:p,onChange:m})})]})}function U({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(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:a("qpd.card.badge")})]})}function Wt(){const{enabled:e,toggle:n}=Te(),{enabled:s,toggle:i}=De();return t.jsxs(S,{title:a("settings.section.labs"),children:[t.jsx(f,{label:t.jsx(U,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(f,{label:t.jsx(U,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Yt(){const{available:e,settings:n,setSetting:s,runAction:i}=O();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.toastOnReset!==!1,l=n?.confettiOnReset!==!1,d=n?.launchAtLoginSupported!==!1,g=n?.updateStatus||null,p=!!n?.updateBusy,m=!!n?.isSyncing;return t.jsxs(S,{title:a("settings.section.menubar"),children:[t.jsx(f,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(Ce,{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:[a("settings.menubar.appearanceLink"),t.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(f,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(f,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})}),d?t.jsx(f,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(f,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,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(we,{className:N("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(f,{label:a("settings.menubar.updates"),hint:g||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(ze,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function Jt(e,n){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(n);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,d=o[r]||0;if(l<d)return!0;if(l>d)return!1}return!1}function Qt(){const{available:e,settings:n,runAction:s}=O(),i=e&&n?.version,[o,r]=L.useState(!1),[l,d]=L.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=H(),p="0.84.4",m=async()=>{r(!0);try{const b=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!b.ok)throw new Error("Failed to fetch");const v=await b.json(),w=v.tag_name;Jt(p,w)?d({open:!0,latestVersion:w,htmlUrl:v.html_url}):_({title:a("settings.menubar.updates.upToDate")})}catch(b){console.error("Check updates failed:",b),_({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},x=a("settings.menubar.updates.modalTitle"),y=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),c=a("settings.menubar.updates.modalConfirm"),h=a("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:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:p})}),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:a("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,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?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Le,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(Ke,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Ve,{open:l.open,title:x,description:y,confirmLabel:c,cancelLabel:h,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),d(b=>({...b,open:!1}))},onCancel:()=>d(b=>({...b,open:!1}))})]})}const j={APPEARANCE:"appearance",NATIVE_APP:"native-app",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function Xt({prefs:e}){return t.jsx(A,{options:[{value:T.USED,label:a("limits.settings.display_mode_used")},{value:T.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Cn(){const e=Ie(),{available:n,settings:s,setSetting:i}=O(),o=s?.toastOnReset!==!1,r=s?.confettiOnReset!==!1,[l,d]=Ae(),g=l.get("section"),m=Object.values(j).includes(g)&&(g!==j.NATIVE_APP||n)?g:j.APPEARANCE,x=c=>{const h=new URLSearchParams(l);c===j.APPEARANCE?h.delete("section"):h.set("section",c),d(h,{replace:!0})},y=[{id:j.APPEARANCE,label:a("settings.section.appearance"),Icon:at,content:t.jsx(Zt,{})},...n?[{id:j.NATIVE_APP,label:a("settings.section.menubar"),Icon:$,content:t.jsx(Yt,{})}]:[],{id:j.ACCOUNT,label:a("settings.section.account"),Icon:it,content:t.jsx(Tt,{})},{id:j.LIMITS,label:a("settings.section.limits"),Icon:Oe,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(S,{title:a("settings.section.limits"),children:[t.jsx(f,{label:a("limits.settings.display_mode_label"),control:t.jsx(Xt,{prefs:e})}),t.jsx(f,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:o,disabled:!n,onChange:()=>i("toastOnReset",!o),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(f,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:r,disabled:!n,onChange:()=>i("confettiOnReset",!r),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),t.jsx(S,{title:a("settings.limits.providers"),children:t.jsx(ht,{prefs:e})})]})},{id:j.LABS,label:a("settings.section.labs"),Icon:We,content:t.jsx(Wt,{})}];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:a("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":a("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:y.map(({id:c,label:h,Icon:b})=>{const v=m===c;return t.jsxs("button",{id:`settings-nav-${c}`,type:"button","aria-current":v?"page":void 0,"aria-controls":`settings-panel-${c}`,onClick:()=>x(c),className:N("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",v?"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(b,{className:N("h-4 w-4 shrink-0",v?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:h})]},c)})})}),t.jsxs("div",{className:"min-w-0",children:[y.map(({id:c,label:h,content:b})=>t.jsx("section",{id:`settings-panel-${c}`,"aria-labelledby":`settings-nav-${c}`,"aria-label":h,"data-settings-panel":c,hidden:m!==c,children:b},c)),t.jsx(Qt,{})]})]})]})})})}export{Cn as SettingsPage};
|
|
1
|
+
import{l as C,r as u,j as t,d as N,c as a,a as ie,ap as oe,bv as re,av as le,aw as ce,a7 as F,bw as ue,bx as de,u as ge,R as L,Y as me,a0 as H,m as I,by as he,bz as pe,N as $,bA as be,x as fe,bB as xe,bC as ye,bD as ve,bE as ke,bF as je,bG as Ne,bH as Se,L as Ce,a2 as we,bI as Le,a4 as _,f as Ae,bJ as Oe}from"./__vite-browser-external-UqlSqI-1.js";import{b as Ee,g as Pe,L as G,m as V}from"./react-BhbcISKy.js";import{u as Ie,L as T}from"./use-limits-display-prefs-DWsF4ShM.js";import{P as _e}from"./ProviderIcon-CHx4ohfx.js";import{a as D,l as R}from"./limits-providers-B_18X9Rp.js";import{a as S,T as k,b as f,S as A,u as O}from"./use-native-settings-SEbqWDvc.js";import{P as Ge,u as Te,a as De}from"./use-session-efficiency-pref-DbysyUTJ.js";import{C as Re}from"./check-DUHSZCYn.js";import{C as Me}from"./copy-ChyH-ynx.js";import{A as Ue}from"./index-CxExExXh.js";import{u as Fe}from"./useCurrency-DvBEn4rx.js";import{u as He}from"./useTokenFormat-BTLrL7Mi.js";import{S as B}from"./Select-DcYXcsKv.js";import{I as $e}from"./info-DWQQIq9M.js";import{C as Ve}from"./ConfirmModal-tJCWVZQH.js";import{A as Be}from"./arrow-up-right-CzcCNJJ2.js";import{D as ze}from"./download-CgwvXrUe.js";import"./Card-D6hdzwvI.js";import"./ToolbarRootContext-akXaaKb6.js";import"./useScrollLock-QozsdFng.js";import"./SelectItemText-BDv2Kb3x.js";import"./DialogTitle-C1ZeQgf2.js";import"./store-BL7rSajG.js";import"./DialogDescription-DgUSe6A1.js";const qe=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ke=C("activity",qe);const Ze=[["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"}]],We=C("flask-conical",Ze);const Ye=[["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"}]],Je=C("grip-vertical",Ye);const Qe=[["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"}]],Xe=C("languages",Qe);const et=[["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"}]],tt=C("log-out",et);const nt=[["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"}]],at=C("palette",nt);const st=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],it=C("user-round",st),ot=e=>!e.isLayoutDirty&&e.willUpdate(!1);function M(){const e=new Set,n=new WeakMap,s=()=>e.forEach(ot);return{add:i=>{e.add(i),n.set(i,i.addEventListener("willUpdate",s))},remove:i=>{e.delete(i);const o=n.get(i);o&&(o(),n.delete(i)),s()},dirty:s}}const rt=u.createContext(null);function lt(){const e=u.useRef(!1);return Ee(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function ct(){const e=lt(),[n,s]=u.useState(0),i=u.useCallback(()=>{e.current&&s(n+1)},[n]);return[u.useCallback(()=>Pe.postRender(i),[i]),n]}const z=e=>e===!0,ut=e=>z(e===!0)||e==="id",dt=({children:e,id:n,inherit:s=!0})=>{const i=u.useContext(G),o=u.useContext(rt),[r,l]=ct(),d=u.useRef(null),g=i.id||o;d.current===null&&(ut(s)&&g&&(n=n?g+"-"+n:g),d.current={id:n,group:z(s)&&i.group||M()});const p=u.useMemo(()=>({...d.current,forceRender:r}),[l]);return t.jsx(G.Provider,{value:p,children:e})},gt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function mt({checked:e,onChange:n,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:n,className:N("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:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function ht({prefs:e}){const{order:n,visibility:s,toggle:i,moveToward:o}=e,[r,l]=u.useState(null),[d,g]=u.useState(null),p=c=>h=>{l(c),h.dataTransfer.effectAllowed="move",h.dataTransfer.setData("text/plain",c)},m=c=>h=>{h.preventDefault(),h.dataTransfer.dropEffect="move",r&&r!==c&&d!==c&&(g(c),o(r,c))},x=()=>{l(null),g(null)},y=c=>{c.preventDefault(),l(null),g(null)};return t.jsx(dt,{children:t.jsx("div",{className:"flex flex-col",children:n.map(c=>{const h=s[c]!==!1,b=r===c;return t.jsxs(V.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:p(c),onDragOver:m(c),onDragEnd:x,onDrop:y,className:N("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",b&&"opacity-40"),style:{cursor:b?"grabbing":"grab"},children:[t.jsx(Je,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),D(c)?t.jsx(_e,{provider:D(c),size:18,className:N("pointer-events-none",gt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:R(c)}),t.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:t.jsx(mt,{checked:h,onChange:()=>i(c),ariaLabel:`${a("limits.settings.toggle_visible")}: ${R(c)}`})})]},c)})})})}function pt(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=n.full_name||n.name||s.name||n.user_name||n.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 bt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function ft(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const s=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=n.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 E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function xt(e,n,s){const[i,o]=u.useState(()=>oe()),r=n&&s&&re(),l=u.useCallback(async()=>{const d=!i;if(le(d),o(d),!!d)try{await ce(()=>e())}catch(g){E("cloud sync",g)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function yt(e){const[n,s]=u.useState(!1),[i,o]=u.useState(!1),[r,l]=u.useState(!1),[d,g]=u.useState(!1),[p,m]=u.useState(null),[x,y]=u.useState(!1),[c,h]=u.useState(""),[b,v]=u.useState(!1),[w,P]=u.useState(""),[W,Y]=u.useState(""),[J,Q]=u.useState(!1),[X,ee]=u.useState(null),te=u.useMemo(()=>pt(e),[e]),ne=u.useMemo(()=>bt(e),[e]),ae=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),se=u.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:P,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:v}),[]);return{anonymousOn:i,customDisplayName:p,displayName:te,editingGithub:J,editingName:x,email:ne,githubError:X,githubInput:W,githubUrl:w,loadSetters:se,nameInput:c,profileLoading:r,profileSaving:d,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:Q,setEditingName:y,setGithubError:ee,setGithubInput:Y,setGithubUrl:P,setNameInput:h,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:s,setShowGithubOn:v,showGithubOn:b,userId:ae}}function vt(e,n,s){u.useEffect(()=>{if(!n)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await F({getAccessToken:e});if(!i||!o)return;const r=await ue({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){E("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,n,s])}function kt(e,n){return u.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await F({getAccessToken:e});if(!l)return!1;const d=await de({accessToken:l,...s});return r?.(d),!0}catch(l){return o?o(l):E(i||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function jt(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function Nt(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function St(e,n){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:s}}function Ct(e,n,s){const i=u.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[n,e,s]),o=u.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function wt(e,n){const s=u.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),i=u.useCallback(async()=>{const r=ft(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=u.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Lt(){const e=ie(),n=yt(e.user),s=xt(e.getAccessToken,e.enabled,e.signedIn);vt(e.getAccessToken,e.signedIn,n.loadSetters);const i=kt(e.getAccessToken,n),o=St(n,i),r=Ct(n,i,e.refreshDisplayName),l=wt(n,i);return{...e,...s,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:jt(n,{...o,...r}),github:Nt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function q({disabled:e,onCancel:n,onSave:s,saveLabel:i=a("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:n,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:a("settings.account.cancel")})]})}function At({nameInput:e,setEditingName:n,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"&&n(!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:a("settings.account.displayName")}),t.jsx(q,{disabled:i||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:i?a("settings.account.saving"):void 0})]})}function Ot({githubError:e,githubInput:n,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:n,onChange:d=>{l(d.target.value),e&&r(null)},onKeyDown:d=>{d.key==="Enter"&&s(),d.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:a("settings.account.githubUrlPlaceholder")}),t.jsx(q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?a("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 K({disabled:e=!1,label:n,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(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function Z({actions:e,editing:n,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}),n?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),n?null:e]})})}function Et({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(K,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function Pt({name:e}){const{anonymousOn:n,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:d,profileLoading:g,profileSaving:p,setEditingName:m,setNameInput:x,startEditingName:y}=e,c=n?a("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(Z,{label:a("settings.account.displayName"),editing:o,hint:c,editor:t.jsx(At,{nameInput:d,setEditingName:m,setNameInput:x,profileSaving:p,handleSaveName:l}),actions:t.jsx(Et,{name:e})})}function It({github:e}){const{editingGithub:n,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:d,profileSaving:g,setEditingGithub:p,setGithubError:m,setGithubInput:x,showGithubOn:y,startEditingGithub:c}=e;return t.jsx(t.Fragment,{children:t.jsx(Z,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(Ot,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:g,setEditingGithub:p,setGithubError:m,setGithubInput:x}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(K,{label:a("settings.account.edit"),onClick:c}),t.jsx(k,{checked:y,onChange:l,disabled:d||g,ariaLabel:a("settings.account.githubUrl")})]})})})}function _t(){const{openLoginModal:e}=ge();return t.jsx(S,{title:a("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:a("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:a("settings.account.signIn")})]})})}function Gt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(Pt,{name:e}),t.jsx(It,{github:n})]})}function Tt(){const e=Lt();return e.enabled?e.signedIn?t.jsxs(S,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Rt,{onSignOut:e.signOut}),children:[t.jsx(Dt,{userId:e.userId}),t.jsx(Mt,{settings:e}),t.jsx(Ut,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Ft,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(_t,{}):null}function Dt({userId:e}){const[n,s]=L.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:a("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":a("settings.account.copyUserId"),children:[n?t.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Me,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Rt({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(tt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function Mt({settings:e}){return e.showLocalCloudSync?t.jsx(f,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Ut({checked:e,disabled:n,onChange:s}){return t.jsx(f,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function Ft({visible:e,name:n,github:s}){return t.jsx(Ue,{initial:!1,children:e?t.jsx(V.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(Gt,{name:n,github:s})},"public-profile-fields"):null})}function Ht(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:he},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:pe},{value:"system",label:a("settings.appearance.theme.system"),Icon:$}]}function $t(){return[{value:xe,label:a("settings.appearance.language.system")},{value:ye,label:a("settings.appearance.language.english")},{value:ve,label:a("settings.appearance.language.chinese")},{value:ke,label:a("settings.appearance.language.traditional_chinese")},{value:je,label:a("settings.appearance.language.japanese")},{value:Ne,label:a("settings.appearance.language.korean")},{value:Se,label:a("settings.appearance.language.german")}]}function Vt(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function Bt(e,n){const s=a(`settings.appearance.currency.rate_source.${e}`),i=Vt(n),o=i?a("settings.appearance.currency.rate_updated",{when:i}):a("settings.appearance.currency.rate_never");return`${s} · ${o}`}function zt({locale:e,setLocale:n}){const s=$t();return t.jsx(B,{value:e,onValueChange:n,options:s,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(Xe,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function qt({currency:e,setCurrency:n}){const s=be().map(i=>({value:i.code,label:a(i.labelKey)}));return t.jsx(B,{value:e,onValueChange:n,options:s,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Kt({currency:e,rate:n,rateSource:s,rateFetchedAt:i}){if(e===fe)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=Bt(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.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($e,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Zt(){const{theme:e,setTheme:n}=me(),{locale:s,setLocale:i}=H(),{currency:o,rate:r,rateSource:l,rateFetchedAt:d,setCurrency:g}=Fe(),{mode:p,setMode:m}=He();return t.jsxs(S,{title:a("settings.section.appearance"),children:[t.jsx(f,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(A,{options:Ht(),value:e,onChange:n})}),t.jsx(f,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(zt,{locale:s,setLocale:i})}),t.jsx(f,{label:a("settings.appearance.currency.label"),hint:t.jsx(Kt,{currency:o,rate:r,rateSource:l,rateFetchedAt:d}),control:t.jsx(qt,{currency:o,setCurrency:g})}),t.jsx(f,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(A,{options:[{value:I.COMPACT,label:a("settings.appearance.token_format.compact")},{value:I.FULL,label:a("settings.appearance.token_format.full")}],value:p,onChange:m})})]})}function U({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(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:a("qpd.card.badge")})]})}function Wt(){const{enabled:e,toggle:n}=Te(),{enabled:s,toggle:i}=De();return t.jsxs(S,{title:a("settings.section.labs"),children:[t.jsx(f,{label:t.jsx(U,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(f,{label:t.jsx(U,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Yt(){const{available:e,settings:n,setSetting:s,runAction:i}=O();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.toastOnReset!==!1,l=n?.confettiOnReset!==!1,d=n?.launchAtLoginSupported!==!1,g=n?.updateStatus||null,p=!!n?.updateBusy,m=!!n?.isSyncing;return t.jsxs(S,{title:a("settings.section.menubar"),children:[t.jsx(f,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(Ce,{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:[a("settings.menubar.appearanceLink"),t.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(f,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(f,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})}),d?t.jsx(f,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(f,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,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(we,{className:N("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(f,{label:a("settings.menubar.updates"),hint:g||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(ze,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function Jt(e,n){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(n);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,d=o[r]||0;if(l<d)return!0;if(l>d)return!1}return!1}function Qt(){const{available:e,settings:n,runAction:s}=O(),i=e&&n?.version,[o,r]=L.useState(!1),[l,d]=L.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=H(),p="0.84.6",m=async()=>{r(!0);try{const b=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!b.ok)throw new Error("Failed to fetch");const v=await b.json(),w=v.tag_name;Jt(p,w)?d({open:!0,latestVersion:w,htmlUrl:v.html_url}):_({title:a("settings.menubar.updates.upToDate")})}catch(b){console.error("Check updates failed:",b),_({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},x=a("settings.menubar.updates.modalTitle"),y=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),c=a("settings.menubar.updates.modalConfirm"),h=a("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:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:p})}),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:a("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,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?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Le,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(Ke,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Ve,{open:l.open,title:x,description:y,confirmLabel:c,cancelLabel:h,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),d(b=>({...b,open:!1}))},onCancel:()=>d(b=>({...b,open:!1}))})]})}const j={APPEARANCE:"appearance",NATIVE_APP:"native-app",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function Xt({prefs:e}){return t.jsx(A,{options:[{value:T.USED,label:a("limits.settings.display_mode_used")},{value:T.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Cn(){const e=Ie(),{available:n,settings:s,setSetting:i}=O(),o=s?.toastOnReset!==!1,r=s?.confettiOnReset!==!1,[l,d]=Ae(),g=l.get("section"),m=Object.values(j).includes(g)&&(g!==j.NATIVE_APP||n)?g:j.APPEARANCE,x=c=>{const h=new URLSearchParams(l);c===j.APPEARANCE?h.delete("section"):h.set("section",c),d(h,{replace:!0})},y=[{id:j.APPEARANCE,label:a("settings.section.appearance"),Icon:at,content:t.jsx(Zt,{})},...n?[{id:j.NATIVE_APP,label:a("settings.section.menubar"),Icon:$,content:t.jsx(Yt,{})}]:[],{id:j.ACCOUNT,label:a("settings.section.account"),Icon:it,content:t.jsx(Tt,{})},{id:j.LIMITS,label:a("settings.section.limits"),Icon:Oe,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(S,{title:a("settings.section.limits"),children:[t.jsx(f,{label:a("limits.settings.display_mode_label"),control:t.jsx(Xt,{prefs:e})}),t.jsx(f,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:o,disabled:!n,onChange:()=>i("toastOnReset",!o),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(f,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:r,disabled:!n,onChange:()=>i("confettiOnReset",!r),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),t.jsx(S,{title:a("settings.limits.providers"),children:t.jsx(ht,{prefs:e})})]})},{id:j.LABS,label:a("settings.section.labs"),Icon:We,content:t.jsx(Wt,{})}];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:a("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":a("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:y.map(({id:c,label:h,Icon:b})=>{const v=m===c;return t.jsxs("button",{id:`settings-nav-${c}`,type:"button","aria-current":v?"page":void 0,"aria-controls":`settings-panel-${c}`,onClick:()=>x(c),className:N("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",v?"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(b,{className:N("h-4 w-4 shrink-0",v?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:h})]},c)})})}),t.jsxs("div",{className:"min-w-0",children:[y.map(({id:c,label:h,content:b})=>t.jsx("section",{id:`settings-panel-${c}`,"aria-labelledby":`settings-nav-${c}`,"aria-label":h,"data-settings-panel":c,hidden:m!==c,children:b},c)),t.jsx(Qt,{})]})]})]})})})}export{Cn as SettingsPage};
|