tokentracker-cli 1.3.16 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +5 -4
- package/README.ja.md +5 -4
- package/README.ko.md +5 -4
- package/README.md +5 -4
- package/README.zh-CN.md +5 -4
- package/dashboard/dist/assets/{AchievementBadge-D5sRTMmp.js → AchievementBadge-WGbdoboF.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-CaiCfchd.js → AchievementsPage-BvybbsXv.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-D6dTxdUd.js → AchievementsSection-ChNzTFSR.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-C0UrWb9m.js → BadgeDetailModal-DhI9Ejz3.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-CgpBB5FZ.js → BotAnimated-Bch0Yxej.js} +1 -1
- package/dashboard/dist/assets/{Card-CuwBiIYz.js → Card-DWdL7d1T.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-BNCnBR0h.js → CloudCheckoutPage-BjGoOz6P.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-CuYXUQnv.js → CloudPage-Btb6a97x.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-CV6a_7yK.js → CommandPalette-DwP3k7LE.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-Dw-64Tig.js → CommunityStatsModal-mzqLxpwE.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-CoFO1Nas.js → ConfirmModal-Dm76q4EX.js} +1 -1
- package/dashboard/dist/assets/{Controls-DB9eQ_rg.js → Controls-ClZjOBoD.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-Doc8f4NL.js +1 -0
- package/dashboard/dist/assets/{DateRangePopover-DgZEnn4X.js → DateRangePopover-vfTUePPg.js} +1 -1
- package/dashboard/dist/assets/DevicePage-Jjg5q0C2.js +1 -0
- package/dashboard/dist/assets/{DialogClose-BR9QrB34.js → DialogClose-Ci5mPZ6X.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-Di5ev5K6.js +1 -0
- package/dashboard/dist/assets/DialogTitle-DI21oZxH.js +1 -0
- package/dashboard/dist/assets/{ElectricLogo-nrlBy-l9.js → ElectricLogo-DfeZBwPZ.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-CyJJ3l_P.js → FadeIn-C7SIILTc.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-C7BX7loS.js → HeaderGithubStar-RStLbadn.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-KGluh6sO.js → HoverTooltip-DI7uAp1_.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-Ci2ybTDg.js → IpCheckPage-DTZNTJVh.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-C9N17IpV.js → LandingPage-Df5scNlw.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-Cco7iFen.js → LeaderboardPage-Ck3SqtnI.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-tmm5NN8p.js → LeaderboardProBadge-CGx6m7R6.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-WhjsvZ9Q.js → LeaderboardProfileModal-DuP7rgfv.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-Ba3oVu5z.js → LeaderboardProfilePage-B5qUJkZX.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-CUa46XJy.js → LimitsPage-Bv_Lcvcz.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-BSewrWlY.js → LocalOnlyNotice-Cg4y02JM.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-CUWn0Tz4.js → LoginCard-Wz0uJKXx.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-UKk3xCsV.js → LoginModal-C13v_Gs0.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-BhxiWgc5.js → LoginPage-COH9xXtd.js} +1 -1
- package/dashboard/dist/assets/{PetPage-BRyxC-Iu.js → PetPage-BWCnURub.js} +2 -2
- package/dashboard/dist/assets/PopoverPopup-Dw811N-_.js +1 -0
- package/dashboard/dist/assets/{ProviderIcon-htNu1RTN.js → ProviderIcon-CHxhYzK-.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-DawMNiM1.js → ResetPasswordPage-Ll6jshqg.js} +1 -1
- package/dashboard/dist/assets/Select-BbooQ3sa.js +1 -0
- package/dashboard/dist/assets/SelectItemText-DBiW70wi.js +1 -0
- package/dashboard/dist/assets/{SelfHostPage-BMCMrt5I.js → SelfHostPage-BMHJxz5q.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-e_7xC0RY.js → ServiceStatusPage-D6LH0ac-.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-Xr2FJa6E.js → SessionsPage-Mrer6v17.js} +2 -2
- package/dashboard/dist/assets/SettingsPage-D_7P_y_l.js +5 -0
- package/dashboard/dist/assets/SkillsPage-Ka7xm-1v.js +1 -0
- package/dashboard/dist/assets/{TokenGalaxy--6ijNK6P.js → TokenGalaxy-BEURDPFq.js} +1 -1
- package/dashboard/dist/assets/TooltipPopup-ZiuFFARC.js +1 -0
- package/dashboard/dist/assets/{TrendMonitor-DjIZyzxp.js → TrendMonitor-H73lyGEf.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-CzCqGbb4.js → WidgetsPage-_7iCvyTk.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-B0RMtpvr.js → WrappedPage-DEXNb6-k.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-BkNP5Ecj.js +45 -0
- package/dashboard/dist/assets/{agent-logos-CSlyeabY.js → agent-logos-OVBc_0cF.js} +1 -1
- package/dashboard/dist/assets/{arrow-left-DaqMiXTO.js → arrow-left-DDphsclm.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-B1p9R8vH.js → arrow-right-B1aNq0Ki.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-CK_9HuEh.js → arrow-up-right-yTM9azz_.js} +1 -1
- package/dashboard/dist/assets/{calendar-days-BVyCx4dJ.js → calendar-days-D22ithNF.js} +1 -1
- package/dashboard/dist/assets/{check-DIfCVsPJ.js → check-Dk7tknvE.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-DrWxRBXX.js → chevron-down-DdyEzQ4f.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-DOxBG7oS.js → cloud-checkout-BJjbipnH.js} +1 -1
- package/dashboard/dist/assets/composite-DEqP00XV.js +1 -0
- package/dashboard/dist/assets/{download-CEXAmejX.js → download-C9ixNyzn.js} +1 -1
- package/dashboard/dist/assets/{external-link-tDBZy6QP.js → external-link-DL4HSsLw.js} +1 -1
- package/dashboard/dist/assets/{flame-86y9Xf0g.js → flame-DqNH65nB.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-BNN9k5mV.js → format-tokens-CyVjKz4I.js} +1 -1
- package/dashboard/dist/assets/{gift-BEOvq2zc.js → gift-ChJQQe_G.js} +1 -1
- package/dashboard/dist/assets/{host-mode-UjbNKxFB.js → host-mode-DpUDpoOz.js} +1 -1
- package/dashboard/dist/assets/{icons-DJmZD0si.js → icons-CJiHeOaU.js} +1 -1
- package/dashboard/dist/assets/{index-BwUwnqE0.js → index-72LQsAaf.js} +1 -1
- package/dashboard/dist/assets/{index-B8kizz-s.js → index-BucEg3fu.js} +1 -1
- package/dashboard/dist/assets/{index-Ci3CZ-2g.js → index-CrFlTSra.js} +1 -1
- package/dashboard/dist/assets/{info-ynVg8RzK.js → info-DReYqxC7.js} +1 -1
- package/dashboard/dist/assets/{link-2-B9SLPcBg.js → link-2-kIZbhK2S.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-FTE9k7Sk.js → loader-circle-1An-X85y.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-B4babCm_.js → modifiers.esm-FoVheEKT.js} +1 -1
- package/dashboard/dist/assets/module-DOCYJaxl.js +3 -0
- package/dashboard/dist/assets/{monitor-smartphone-CNzgbo-M.js → monitor-smartphone-Ch6lr_P2.js} +1 -1
- package/dashboard/dist/assets/{play-9W4Ua21o.js → play-CbJ6ZF1K.js} +1 -1
- package/dashboard/dist/assets/{plus-BA85lApI.js → plus-C-5ID3a9.js} +1 -1
- package/dashboard/dist/assets/{provider-display-D1ETarsz.js → provider-display-BFzRtoL2.js} +2 -2
- package/dashboard/dist/assets/{react-VsHxeqq7.js → react-D4CR_fLQ.js} +1 -1
- package/dashboard/dist/assets/safePolygon-DP21Ibqj.js +1 -0
- package/dashboard/dist/assets/{search-Svi--7CN.js → search-CaznkY7U.js} +1 -1
- package/dashboard/dist/assets/{server-CgHdX6TE.js → server-CUOmC6xZ.js} +1 -1
- package/dashboard/dist/assets/{shield-check-Cjv-T4aT.js → shield-check-Dr2KBMmA.js} +1 -1
- package/dashboard/dist/assets/{skills-api-Cn8hEYL4.js → skills-api-BAz_fblS.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-g3UcmvFU.js → sortable.esm-knEfm5hE.js} +1 -1
- package/dashboard/dist/assets/store-CL97jcij.js +1 -0
- package/dashboard/dist/assets/{terminal-o0jvDfI0.js → terminal-EjFyreWj.js} +1 -1
- package/dashboard/dist/assets/{trash-0cqpTyN6.js → trash-ByqaZXkQ.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-BFgORaJS.js → use-community-stats-Bs4RDJZE.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-9eZP_jA5.js → use-latest-request-guard-CG3Ir1cP.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-BjO3hsmw.js → use-limits-display-prefs-tACgCxeR.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-YKn-htVo.js → use-native-settings-CWjXyJXi.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-D5h4UwhF.js → use-ordered-list-DsuC9JQa.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-CwFguzkm.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-BShLuIbk.js → use-session-efficiency-pref-NeoJE8BL.js} +1 -1
- package/dashboard/dist/assets/{use-transform-DVZHJPVD.js → use-transform-BWGKOsya.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-BhJbW76K.js → use-usage-limits-CFWFNwHS.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-BmEbDVaa.js → useCurrency-B_C4_P5x.js} +1 -1
- package/dashboard/dist/assets/usePositioner-B0L5_o38.js +1 -0
- package/dashboard/dist/assets/{useTokenFormat-CBlBP2aA.js → useTokenFormat-DH1GWHSU.js} +1 -1
- package/dashboard/dist/assets/{zap-cML2-Nx4.js → zap-Chv1p7pS.js} +1 -1
- package/dashboard/dist/index.html +13 -11
- package/dashboard/dist/ip-check.html +1 -1
- package/dashboard/dist/leaderboard.html +1 -1
- package/dashboard/dist/llms.txt +3 -2
- package/dashboard/dist/share.html +1 -1
- package/package.json +3 -3
- package/src/commands/doctor.js +15 -1
- package/src/commands/init.js +9 -0
- package/src/commands/status.js +21 -3
- package/src/commands/sync.js +59 -4
- package/src/lib/cloud-device-token.js +77 -10
- package/src/lib/cloud-usage-reset.js +115 -0
- package/src/lib/diagnostics.js +5 -2
- package/src/lib/kimi-model-repair.js +173 -0
- package/src/lib/kimi-session.js +216 -0
- package/src/lib/local-api.js +46 -1
- package/src/lib/pricing/index.js +2 -1
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/qoder-cn-cli-limits.js +9 -7
- package/src/lib/qoder-limits.js +45 -15
- package/src/lib/rollout.js +408 -4
- package/src/lib/session-analytics.js +47 -9
- package/dashboard/dist/assets/DashboardPage-sZKijU6h.js +0 -1
- package/dashboard/dist/assets/DevicePage-YCnJnsmz.js +0 -1
- package/dashboard/dist/assets/DialogDescription-Cx1R3WT7.js +0 -1
- package/dashboard/dist/assets/DialogTitle-ck8f1qeP.js +0 -1
- package/dashboard/dist/assets/PopoverPopup-D-Tpl294.js +0 -1
- package/dashboard/dist/assets/Select-6WChWtqK.js +0 -1
- package/dashboard/dist/assets/SelectItemText-DRmxMwo5.js +0 -1
- package/dashboard/dist/assets/SettingsPage-Bxq2Mhxz.js +0 -5
- package/dashboard/dist/assets/SkillsPage-CEIBW63c.js +0 -1
- package/dashboard/dist/assets/TooltipPopup--TLYUg0c.js +0 -1
- package/dashboard/dist/assets/__vite-browser-external-BsOjTB8Q.js +0 -45
- package/dashboard/dist/assets/composite-W1R1XwoE.js +0 -1
- package/dashboard/dist/assets/module-BNnaKM__.js +0 -3
- package/dashboard/dist/assets/safePolygon-CCDOsx-z.js +0 -1
- package/dashboard/dist/assets/store-D2gn9bSV.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-C83gmg0F.js +0 -1
- package/dashboard/dist/assets/usePositioner-nY0YNa-6.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,bm as V,bn as re,b6 as X,bo as z,bp as ae,O as ie,bq as ce,ar as J,br as Q,a_ as ue,j as d,bs as le,N as W,bt as pe,bu as de,bv as ge,ba as fe,bw as me,bx as Pe,by as he,M as Ce,K as te,bz as Se,bA as $,bB as be,bC as Te,bD as ve,b1 as xe,bE as Re,b0 as Ie,bF as Ee,bG as Oe}from"./__vite-browser-external-BsOjTB8Q.js";import{p as ye,c as Fe}from"./store-D2gn9bSV.js";import{d as Me,e as ke,P as Ae,f as we,h as je,j as He,k as Be,l as Ge,m as Ne,n as _e,o as Le,u as Ke,p as Ue,q as De,t as Ve,r as qe,I as Ye,s as ze,v as Je,w as Qe,x as We,C as Xe,y as Ze}from"./composite-W1R1XwoE.js";import{k as $e,l as et,m as tt,n as ot}from"./SelectItemText-DRmxMwo5.js";import{u as nt,a as st,s as rt,b as at}from"./safePolygon-CCDOsx-z.js";import{u as it,a as ct,g as ut}from"./usePositioner-nY0YNa-6.js";const oe=a.createContext(void 0);function K(e){const o=a.useContext(oe);if(o===void 0&&!e)throw new Error(V(47));return o}const lt={...ye,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class pt extends re{constructor(o,t,i){const s=new Ae;super(dt(o,s,t,i),gt(s),lt)}setOpen=(o,t)=>{const i=t.reason===X,s=t.reason===z&&t.event.detail===0,g=!o&&(t.reason===ae||t.reason==null),l=Me(t),c=this.select("activeTriggerId");if(!o&&t.reason===ie&&t.trigger==null&&c!=null&&(t.trigger=this.context.triggerElements.getById(c)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(o,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(o,t);const f=()=>{const m=ke(this.state,o,t.trigger,l());m.openChangeReason=t.reason,this.update(m)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(ce,()=>{this.set("stickIfOpen",!1)}),J.flushSync(f)):f();let n;s?n="click":g?n="dismiss":t.reason===Q&&(n="focus"),this.set("instantType",n)}}function dt(e,o,t,i=!1){const s={...Fe(o,t,i),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return s.open&&e?.mounted===void 0&&(s.mounted=!0),s}function gt(e){return{popupRef:a.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:a.createRef(),beforeContentFocusGuardRef:a.createRef(),stickIfOpenTimeout:new ue,triggerElements:e}}const ee=le(function({props:o}){const{children:t,open:i,defaultOpen:s=!1,onOpenChange:g,onOpenChangeComplete:l,modal:c=!1,handle:f,triggerId:n,defaultTriggerId:m=null}=o,r=ft(f,{modal:c,open:s,openProp:i,activeTriggerId:m,triggerIdProp:n});r.useControlledProp("openProp",i),r.useControlledProp("triggerIdProp",n);const P=r.useState("open"),I=r.useState("mounted"),b=r.useState("payload");r.useContextCallback("onOpenChange",g),r.useContextCallback("onOpenChangeComplete",l),je(r,P),He(r);const{forceUnmount:v}=Be(P,r,()=>{r.update({stickIfOpen:!0,openChangeReason:null})});r.useSyncedValues({modal:c}),a.useEffect(()=>{P||r.context.stickIfOpenTimeout.clear()},[r,P]),a.useImperativeHandle(o.actionsRef,()=>({unmount:v,close:()=>r.setOpen(!1,W(pe))}),[v,r]);const y=P||I;return d.jsxs(oe.Provider,{value:r,children:[f&&d.jsx(Ge,{handle:f,store:r}),y&&d.jsx(mt,{store:r,modal:c}),typeof t=="function"?t({payload:b}):t]})});function yt(e){return K(!0)?d.jsx(ee,{props:e}):d.jsx(we,{children:d.jsx(ee,{props:e})})}function ft(e,o){const t=Ne((i,s)=>new pt(o,i,s));return a.useEffect(()=>t.context.stickIfOpenTimeout.disposeEffect(),[t]),t}function mt({store:e,modal:o}){const t=e.useState("floatingRootContext"),i=_e(t,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),s=i.reference,g=i.floating;return Le(e,{activeTriggerProps:s,inactiveTriggerProps:s,popupProps:g}),null}const Pt=300;function ht(e,o){const t=a.useRef(null);function i(g){J.flushSync(()=>{e.setOpen(!1,W(Q,g.nativeEvent,g.currentTarget))}),Pe(t.current)?.focus()}function s(g){const l=e.select("positionerElement");if(l&&de(g,l))e.context.beforeContentFocusGuardRef.current?.focus();else{J.flushSync(()=>{e.setOpen(!1,W(Q,g.nativeEvent,g.currentTarget))});let c=ge(e.context.triggerFocusTargetRef.current||o.current);for(;c!==null&&fe(l,c);){const f=c;if(c=me(c),c===f)break}c?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:i,handleFocusTargetFocus:s}}const Ft=he(function(o,t){const{render:i,className:s,style:g,disabled:l=!1,nativeButton:c=!0,handle:f,payload:n,openOnHover:m=!1,delay:r=Pt,closeDelay:P=0,id:I,...b}=o,v=K(!0),u=nt(f)??v;if(!u)throw new Error(V(74));const h=Ke(I),p=u.useState("isTriggerActive",h),F=u.useState("floatingRootContext"),E=u.useState("isOpenedByTrigger",h),M=u.useState("triggerPopupId",h),C=a.useRef(null),{registerTrigger:T,isMountedByThisTrigger:x}=Ue(h,C,u,{payload:n,disabled:l,openOnHover:m,closeDelay:P}),O=u.useState("openChangeReason"),B=u.useState("stickIfOpen"),G=u.useState("openMethod"),k=u.useState("focusManagerModal"),N=st(F,{enabled:!l&&m&&(G!=="touch"||O!==z),mouseOnly:!0,move:!1,handleClose:rt(),restMs:r,delay:{close:P},triggerElementRef:C,isActiveTrigger:p,isClosing:()=>u.select("transitionStatus")==="ending"}),A=$e(F,{stickIfOpen:B}),_=et(()=>u.select("open"),R=>{u.set("openMethod",R)}),w=u.useState("triggerProps",x),{getButtonProps:j,buttonRef:S}=Ce({disabled:l,native:c}),U={open(R){return R&&O===z?De.open(R):Ve.open(R)}},{preFocusGuardRef:D,handlePreFocusGuardFocus:q,handleFocusTargetFocus:Y}=ht(u,C),H=te("button",o,{state:{disabled:l,open:E},ref:[S,t,T,C],props:[A.reference,N,w,_,{[Se]:"",id:h,"aria-haspopup":"dialog","aria-expanded":E,"aria-controls":M},b,j],stateAttributesMapping:U}),L=d.jsx(a.Fragment,{children:H},h);return x&&!k?d.jsxs(a.Fragment,{children:[d.jsx($,{ref:D,onFocus:q}),L,d.jsx($,{ref:u.context.triggerFocusTargetRef,onFocus:Y})]}):L}),ne=a.createContext(void 0);function Ct(){const e=a.useContext(ne);if(e===void 0)throw new Error(V(45));return e}const Mt=a.forwardRef(function(o,t){const{keepMounted:i=!1,...s}=o;return K().useState("mounted")||i?d.jsx(ne.Provider,{value:i,children:d.jsx(be,{ref:t,...s})}):null}),se=a.createContext(void 0);function St(){const e=a.useContext(se);if(!e)throw new Error(V(46));return e}const kt=a.forwardRef(function(o,t){const{render:i,className:s,style:g,anchor:l,positionMethod:c,side:f,align:n,sideOffset:m,alignOffset:r,collisionBoundary:P="clipping-ancestors",collisionPadding:I,arrowPadding:b,sticky:v,disableAnchorTracking:y=!1,collisionAvoidance:u=Te,...h}=o,p=K(),F=Ct(),E=qe(),M=p.useState("floatingRootContext"),C=p.useState("mounted"),T=p.useState("open"),x=p.useState("openChangeReason"),O=p.useState("activeTriggerElement"),B=p.useState("modal"),G=p.useState("openMethod"),k=p.useState("positionerElement"),N=p.useState("instantType"),A=p.useState("transitionStatus"),_=p.useState("adaptiveOrigin"),w=a.useRef(null),j=ve(k),S=it({anchor:l,floatingRootContext:M,positionMethod:c,mounted:C,side:f,sideOffset:m,align:n,alignOffset:r,arrowPadding:b,collisionBoundary:P,collisionPadding:I,sticky:v,disableAnchorTracking:y,keepMounted:F,nodeId:E,collisionAvoidance:u,adaptiveOrigin:_}),U=M.useState("domReferenceElement");xe(()=>{const H=U,L=w.current;if(H&&(w.current=H),L&&H&&H!==L){p.set("instantType",void 0);const R=new AbortController;return j(()=>{p.set("instantType","trigger-change")},R.signal),()=>{R.abort()}}},[U,j,p]);const D=B===!0&&x!==X;tt(T&&D,G==="touch",k,O);const q=p.useStateSetter("positionerElement"),Y={open:T,side:S.side,align:S.align,anchorHidden:S.anchorHidden,instant:N},Z=ct(o,Y,{styles:S.positionerStyles,transitionStatus:A,props:h,refs:[t,q],hidden:!C,inert:!T});return d.jsxs(se.Provider,{value:S,children:[C&&D&&d.jsx(Ye,{inert:Re(!T),cutout:O}),d.jsx(ze,{id:E,children:Z})]})}),bt=a.createContext(void 0);function Tt(){const[e,o]=a.useState(0),t=Ie(()=>(o(s=>s+1),()=>{o(s=>Math.max(0,s-1))}));return{context:a.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}const At=a.forwardRef(function(o,t){const{render:i,className:s,style:g,initialFocus:l,finalFocus:c,...f}=o,n=K(),m=St(),r=ot()!=null,{context:P,hasClosePart:I}=Tt(),b=n.useState("open"),v=n.useState("openMethod"),y=n.useState("instantType"),u=n.useState("transitionStatus"),h=n.useState("popupProps"),p=n.useState("titleElementId"),F=n.useState("descriptionElementId"),E=n.useState("modal"),M=n.useState("mounted"),C=n.useState("openChangeReason"),T=n.useState("activeTriggerElement"),x=n.useState("floatingRootContext"),O=x.useState("floatingId"),B=n.useState("disabled"),G=n.useState("openOnHover"),k=n.useState("closeDelay");Ee({open:b,ref:n.context.popupRef,onComplete(){b&&n.context.onOpenChangeComplete?.(!0)}}),at(x,{enabled:G&&!B,closeDelay:k});const N=l===void 0?Je(n.context.popupRef):l,A=E!==!1&&I;n.useSyncedValue("focusManagerModal",A);const _=n.useStateSetter("popupElement"),w={open:b,side:m.side,align:m.align,instant:y,transitionStatus:u},j=te("div",o,{state:w,ref:[t,n.context.popupRef,_],props:[h,{id:O,role:"dialog",...We,"aria-labelledby":p,"aria-describedby":F,onKeyDown(S){r&&Xe.has(S.key)&&S.stopPropagation()}},ut(u),f],stateAttributesMapping:Ze});return d.jsx(Qe,{context:x,openInteractionType:v,modal:A,disabled:!M||C===X,initialFocus:N,returnFocus:c,restoreFocus:"popup",previousFocusableElement:Oe(T)?T:void 0,nextFocusableElement:n.context.triggerFocusTargetRef,beforeContentFocusGuardRef:n.context.beforeContentFocusGuardRef,children:d.jsx(bt.Provider,{value:P,children:j})})});export{yt as P,Ft as a,Mt as b,kt as c,At as d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as p,K as S,j as e,y as h}from"./__vite-browser-external-BsOjTB8Q.js";import{C as v}from"./chevron-down-DrWxRBXX.js";import{C as w}from"./check-DIfCVsPJ.js";import{u as k,a as j,b as N,L as C,s as R,S as E,c as I,d as T,e as L,f as P,g as A,h as O,i as _,j as D}from"./SelectItemText-DRmxMwo5.js";const G=p.forwardRef(function(t,s){const{render:i,className:x,style:o,...l}=t,r=k(),{multiple:n,readOnly:c}=j(),{alignItemWithTriggerActive:d}=N(),g=r.useState("hasScrollArrows"),a=r.useState("openMethod"),u={id:`${r.useState("id")}-list`,role:"listbox","aria-multiselectable":n||void 0,"aria-readonly":c||void 0,onScroll(f){r.context.scrollHandlerRef.current?.(f.currentTarget)},...d&&{style:C},className:g&&a!=="touch"?R.className:void 0},y=r.useStateSetter("listElement");return S("div",t,{ref:[s,y],props:[u,l]})}),M="relative inline-flex items-center justify-between gap-2 rounded-lg border border-oai-gray-200 bg-white text-oai-black transition-colors hover:border-oai-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:border-oai-gray-700";function H({value:m,onValueChange:t,options:s=[],ariaLabel:i,id:x,disabled:o=!1,leadingIcon:l=null,className:r="",popupClassName:n="",align:c="start",matchTriggerWidth:d=!1}){const g=s.map(a=>({value:a.value,label:a.label}));return e.jsxs(E,{value:m,items:g,disabled:o,onValueChange:a=>{!o&&a!=null&&t?.(a)},children:[e.jsxs(I,{id:x,"aria-label":i,className:h(M,o&&"cursor-not-allowed opacity-50 hover:border-oai-gray-200 dark:hover:border-oai-gray-800",r),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l,e.jsx(T,{className:"truncate"})]}),e.jsx(v,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsx(L,{children:e.jsx(P,{align:c,side:"bottom",sideOffset:4,className:"z-50",children:e.jsx(A,{className:h("max-h-[min(18rem,var(--available-height))] origin-[var(--transform-origin)] overflow-y-auto","rounded-xl border border-oai-gray-200 bg-white p-1 shadow-lg ring-1 ring-black/[0.04]","dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:ring-white/[0.05]","transition-[opacity,transform] duration-150 ease-out","data-[starting-style]:scale-95 data-[starting-style]:opacity-0","data-[ending-style]:scale-95 data-[ending-style]:opacity-0",d&&"min-w-[var(--anchor-width)]",n),children:e.jsx(G,{role:"listbox","aria-label":i,children:s.map(a=>e.jsxs(O,{value:a.value,disabled:a.disabled,className:({selected:b,disabled:u})=>h("flex w-full cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg py-1.5 pl-1.5 pr-6","text-left text-xs outline-none transition-colors",b?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800/70 dark:text-white":"text-oai-gray-600 hover:bg-oai-gray-50 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800/60",u&&"cursor-not-allowed opacity-50 hover:bg-transparent dark:hover:bg-transparent"),children:[e.jsx("span",{className:"flex w-3.5 shrink-0 items-center justify-center text-oai-gray-500 dark:text-oai-gray-300",children:e.jsx(_,{children:e.jsx(w,{className:"h-3 w-3","aria-hidden":!0})})}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.jsx(D,{children:a.label})})]},String(a.value)))})})})})]})}export{H as S};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bo as Tn,r as o,cw as st,a$ as $e,b7 as Kt,c1 as wn,J as Ge,N as pe,ct as vn,aY as ke,b1 as z,b2 as Mn,cx as Yt,cu as Pn,b0 as Y,dg as Dt,dh as mt,di as kt,b$ as ht,b3 as Ne,ba as Te,dj as Nt,bG as Ht,dk as Je,br as $t,bZ as Gt,dl as ct,dm as ut,dn as Xt,dp as Et,cE as On,dq as An,dr as bt,cJ as Ln,bm as He,aW as te,j as ae,bF as Tt,c3 as yt,c8 as Vn,ca as Fn,cb as Dn,bX as it,bn as kn,cz as Nn,bJ as rt,cr as Hn,M as Jt,K as _e,ds as _n,bB as Un,dt as Bn,bE as Wn,b5 as jn,du as qn,c7 as Zt,dv as xt}from"./__vite-browser-external-BsOjTB8Q.js";import{i as St,E as Qt,b as en,F as zn,P as Kn,c as Oe,a as Yn,G as $n,H as Ie,J as tn,B as Gn,u as Xn,D as nn,n as Jn,x as Zn,q as Qn,I as er,w as tr,z as nr,C as rr}from"./composite-W1R1XwoE.js";import{u as or,a as sr,b as ir,p as lr,r as cr,g as ur}from"./usePositioner-nY0YNa-6.js";function Ke(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function ar(e,t={}){const{enabled:n=!0,event:r="click",toggle:s=!0,ignoreMouse:i=!1,stickIfOpen:l=!0,touchOpenDelay:f=0,reason:c=Tn}=t,y="rootStore"in e?e.rootStore:e,b=y.context.dataRef,x=o.useRef(void 0),w=st(),m=$e(),V=o.useMemo(()=>{function v(d,_,E,p){const a=pe(c,_,E);d&&p==="touch"&&f>0?m.start(f,()=>{y.setOpen(!0,a)}):y.setOpen(d,a)}function C(d,_,E){const p=b.current.openEvent,a=y.select("domReferenceElement")!==_;return d&&a||!d||!s?!0:p&&l?!E(p.type):!1}return{onPointerDown(d){x.current=St(d.pointerType,!0)&&Qt(d.nativeEvent)?"virtual":d.pointerType},onMouseDown(d){const _=x.current,E=d.nativeEvent,p=y.select("open");if(d.button!==0||r==="click"||St(_,!0)&&i)return;const a=C(p,d.currentTarget,S=>S==="click"||S==="mousedown"),O=Kt(E);if(wn(O)){v(a,E,O,_);return}const h=d.currentTarget;w.request(()=>{v(a,E,h,_)})},onClick(d){if(r==="mousedown-only")return;const _=x.current;if(r==="mousedown"&&_){x.current=void 0;return}if(St(_,!0)&&i)return;const E=y.select("open"),p=C(E,d.currentTarget,a=>a==="click"||a==="mousedown"||a==="keydown"||a==="keyup");v(p,d.nativeEvent,d.currentTarget,_)},onKeyDown(){x.current=void 0}}},[b,r,i,c,y,l,s,w,m,f]);return o.useMemo(()=>n?{reference:V}:Ge,[n,V])}function fr(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=vn(),i=en()!=null,l=ke(()=>new zn({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Kn,floatingId:s,syncOnly:!1,nested:i})).current;return z(()=>{const f={open:t,floatingId:s};r.reference!==void 0&&(f.referenceElement=r.reference,f.domReferenceElement=Mn(r.reference)?r.reference:null),r.floating!==void 0&&(f.floatingElement=r.floating),l.update(f)},[t,s,r.reference,r.floating,l]),l.context.onOpenChange=n,l.context.nested=i,l}const dr="Escape";function _t(e){return Gt&&e.movementX===0&&e.movementY===0}function at(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Ze(e,t){return at(t,e===Xt||e===Et,e===ct||e===ut)}function Rt(e,t,n){return at(t,e===Et,n?e===ct:e===ut)||e==="Enter"||e===" "||e===""}function pr(e,t,n){return at(t,n?e===ct:e===ut,e===Et)}function gr(e,t,n,r){const s=n?e===ut:e===ct,i=e===Xt;return t==="both"||t==="horizontal"&&r?e===dr:at(t,s,i)}function mr(e,t){const{listRef:n,activeIndex:r,onNavigate:s=()=>{},enabled:i=!0,selectedIndex:l=null,allowEscape:f=!1,loopFocus:c=!1,nested:y=!1,rtl:b=!1,virtual:x=!1,focusItemOnOpen:w="auto",focusItemOnHover:m=!0,openOnArrowKeyDown:V=!0,disabledIndices:v=void 0,orientation:C="vertical",parentOrientation:d,id:_,resetOnPointerLeave:E=!0,externalTree:p,grid:a}=t,O=a!=null,h="rootStore"in e?e.rootStore:e,S=h.useState("open"),H=h.useState("floatingElement"),D=h.useState("domReferenceElement"),G=h.context.dataRef,$=Yt(H),R=Pn(D),F=Oe($),K=en(),J=Yn(p),q=o.useRef(w),M=o.useRef(l??-1),U=o.useRef(null),g=o.useRef(!0),T=Y(u=>{s(M.current===-1?null:M.current,u)}),A=o.useRef(!!H),L=o.useRef(S),k=o.useRef(!1),X=o.useRef(!1),ne=o.useRef(null),re=Oe(v),se=Oe(S),le=Oe(l),oe=Oe(E),fe=st(),B=st(),j=Y(()=>{function u(N){x?J?.events.emit("virtualfocus",N):ne.current=$n(N,{sync:k.current,preventScroll:!0})}const I=n.current[M.current],Q=X.current;I&&u(I),(k.current?N=>N():N=>fe.request(N))(()=>{const N=n.current[M.current]||I;if(!N)return;I||u(N),ue&&(Q||!g.current)&&N.scrollIntoView?.({block:"nearest",inline:"nearest"})})});z(()=>{G.current.orientation=C},[G,C]),z(()=>{i&&(S&&H?(M.current=l??-1,q.current&&l!=null&&(X.current=!0,T())):A.current&&(M.current=-1,T()))},[i,S,H,l,T]),z(()=>{if(i){if(!S){k.current=!1;return}if(H)if(r==null){if(k.current=!1,le.current!=null)return;if(A.current&&(M.current=-1,j()),(!L.current||!A.current)&&q.current&&(U.current!=null||q.current===!0&&U.current==null)){let u=0;const I=()=>{n.current[0]==null?(u<2&&(u?P=>B.request(P):queueMicrotask)(I),u+=1):(M.current=U.current==null||Rt(U.current,C,b)||y?mt(n):kt(n),U.current=null,T())};I()}}else Dt(n.current,r)||(M.current=r,j(),X.current=!1)}},[i,S,H,r,le,y,n,C,b,T,j,B]),z(()=>{if(!i||H||!J||x||!A.current)return;const u=J.nodesRef.current,I=u.find(N=>N.id===K)?.context?.elements.floating,Q=ht(Ne(D??I??null)),P=u.some(N=>N.context&&Te(N.context.elements.floating,Q));I&&!P&&g.current&&I.focus({preventScroll:!0})},[i,H,D,J,K,x]),z(()=>{L.current=S,A.current=!!H}),z(()=>{S||(U.current=null,q.current=w)},[S,w]);const ce=r!=null,Z=Y(u=>{if(!se.current)return;const I=n.current.indexOf(u.currentTarget);I!==-1&&(M.current!==I||r!==I)&&(M.current=I,T(u))}),ge=Y(()=>d??J?.nodesRef.current.find(u=>u.id===K)?.context?.dataRef?.current.orientation),xe=Y(()=>mt(n,re.current)),de=Y(u=>{if(g.current=!1,k.current=!0,u.which===229||!se.current&&u.currentTarget===F.current)return;if(y&&gr(u.key,C,b,O)){Ze(u.key,ge())||Ie(u),h.setOpen(!1,pe(Nt,u.nativeEvent)),Ht(D)&&(x?J?.events.emit("virtualfocus",D):D.focus());return}const I=M.current,Q=mt(n,v),P=kt(n,v);if(R||(u.key==="Home"&&(Ie(u),M.current=Q,T(u)),u.key==="End"&&(Ie(u),M.current=P,T(u))),a!=null){const N=a(u,M.current,n,C,c,b,v,Q,P);if(N!=null&&(M.current=N,T(u)),C==="both")return}if(Ze(u.key,C)){if(Ie(u),S&&!x&&ht(u.currentTarget.ownerDocument)===u.currentTarget){M.current=Rt(u.key,C,b)?Q:P,T(u);return}Rt(u.key,C,b)?c?I>=P?f&&I!==n.current.length?M.current=-1:(k.current=!1,M.current=Q):M.current=Je(n.current,{startingIndex:I,disabledIndices:v}):M.current=Math.min(P,Je(n.current,{startingIndex:I,disabledIndices:v})):c?I<=Q?f&&I!==-1?M.current=n.current.length:(k.current=!1,M.current=P):M.current=Je(n.current,{startingIndex:I,decrement:!0,disabledIndices:v}):M.current=Math.max(Q,Je(n.current,{startingIndex:I,decrement:!0,disabledIndices:v})),Dt(n.current,M.current)&&(M.current=-1),T(u)}}),ue=o.useMemo(()=>({onFocus(I){k.current=!0,Z(I)},onClick:({currentTarget:I})=>I.focus({preventScroll:!0}),onMouseMove(I){_t(I)||(k.current=!0,X.current=!1,m&&Z(I))},onPointerLeave(I){if(!se.current||!g.current||I.pointerType==="touch")return;k.current=!0;const Q=I.relatedTarget;if(!(!m||n.current.includes(Q))&&oe.current&&(ne.current?.(),ne.current=null,M.current=-1,T(I),!x)){const P=F.current,N=ht(Ne(P));P&&Te(P,N)&&P.focus({preventScroll:!0})}}}),[Z,se,F,m,n,T,oe,x]),me=o.useMemo(()=>x&&S&&ce&&{"aria-activedescendant":`${_}-${r}`},[x,S,ce,_,r]),Se=o.useMemo(()=>({...R?{}:me,onKeyDown(u){if(u.key==="Tab"&&u.shiftKey&&S&&!x){const I=Kt(u.nativeEvent);if(I&&!Te(F.current,I))return;Ie(u),h.setOpen(!1,pe($t,u.nativeEvent)),Ht(D)&&D.focus();return}de(u)},onPointerMove(u){_t(u)||(g.current=!0)}}),[me,de,F,R,h,S,x,D]),ee=o.useMemo(()=>{function u(P){h.setOpen(!0,pe(Nt,P.nativeEvent,P.currentTarget))}function I(P){w==="auto"&&tn(P.nativeEvent)&&(q.current=!x)}function Q(P){q.current=w,w==="auto"&&Qt(P.nativeEvent)&&(q.current=!0)}return{onKeyDown(P){const N=h.select("open");g.current=!1;const ve=P.key.startsWith("Arrow"),Me=pr(P.key,ge(),b),be=Ze(P.key,C),Re=(y?Me:be)||P.key==="Enter"||P.key.trim()==="";if(x&&N)return de(P);if(!(!N&&!V&&ve)){if(Re){const Ue=Ze(P.key,ge());U.current=y&&Ue?null:P.key}if(y){Me&&(Ie(P),N?(M.current=xe(),T(P)):u(P));return}be&&(le.current!=null&&(M.current=le.current),Ie(P),!N&&V?u(P):de(P),N&&T(P))}},onFocus(P){h.select("open")&&!x&&(M.current=-1,T(P))},onPointerDown:Q,onPointerEnter:Q,onMouseDown:I,onClick:I}},[de,w,xe,y,T,h,V,C,ge,b,le,x]),we=o.useMemo(()=>({...me,...ee}),[me,ee]);return o.useMemo(()=>i?{reference:we,floating:Se,item:ue,trigger:ee}:{},[i,we,Se,ee,ue])}function hr(e,t){const{listRef:n,elementsRef:r,activeIndex:s,onMatch:i,disabledIndices:l,onTyping:f,enabled:c=!0,resetMs:y=750,selectedIndex:b=null}=t,x="rootStore"in e?e.rootStore:e,w=x.useState("open"),m=$e(),V=o.useRef(""),v=o.useRef(b??s??-1),C=o.useRef(null),d=Y(p=>{function a(F){return r?.current[F]}function O(F){const K=a(F);return K&&!On(K)||K?.matches(":disabled")?!1:l==null||!An(bt,F,l)}function h(F,K,J=0){if(F.length===0)return-1;const q=(J%F.length+F.length)%F.length,M=K.toLowerCase();for(let U=0;U<F.length;U+=1){const g=(q+U)%F.length;if(!(!F[g]?.toLowerCase().startsWith(M)||!O(g)))return g}return-1}const S=n.current;if(V.current.length>0&&p.key===" "&&(Ie(p),f?.(!0)),V.current.length>0&&V.current[0]!==" "&&h(S,V.current)===-1&&p.key!==" "&&f?.(!1),S==null||p.key.length!==1||p.ctrlKey||p.metaKey||p.altKey)return;w&&p.key!==" "&&(Ie(p),f?.(!0));const H=V.current==="";H&&(v.current=b??s??-1),S.every((F,K)=>F&&O(K)?F[0]?.toLowerCase()!==F[1]?.toLowerCase():!0)&&V.current===p.key&&(V.current="",v.current=C.current),V.current+=p.key,m.start(y,()=>{V.current="",v.current=C.current,f?.(!1)});const $=((H?b??s??-1:v.current)??0)+1,R=h(S,V.current,$);R!==-1?(i?.(R),C.current=R):p.key!==" "&&(V.current="",f?.(!1))}),_=Y(p=>{const a=p.relatedTarget,O=x.select("domReferenceElement"),h=x.select("floatingElement");Te(O,a)||Te(h,a)||(m.clear(),V.current="",v.current=C.current,f?.(!1))});z(()=>{!w&&b!==null||(m.clear(),C.current=null,V.current!==""&&(V.current=""))},[w,b,m]);const E=o.useMemo(()=>({onKeyDown:d,onBlur:_}),[d,_]);return o.useMemo(()=>c?{reference:E,floating:E}:{},[c,E])}function xr(e){const t=o.useRef(""),n=o.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:o.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function rn(e,t){const n=o.useRef(e),r=Y(t);z(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Sr(e,t){const n=Y((i,l)=>{(typeof e=="function"?e():e)||t(l||(Ln?"touch":""))}),{onClick:r,onPointerDown:s}=xr(n);return o.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function Rr(e){const[t,n]=o.useState(null),r=Sr(e,n);return rn(e,s=>{s&&!e&&n(null)}),o.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const br=20;function yr(e,t,n,r){const[s,i]=o.useState(!1);z(()=>{if(!e||!t||n==null){i(!1);return}const l=Ne(n).documentElement.clientWidth,f=n.offsetWidth;i(l>0&&f>0&&f>=l-br)},[e,t,n]),Gn(e&&(!t||s),r)}const Ir=o.createContext(void 0);function Cr(e){return o.useContext(Ir)}function Er(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function Tr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function wr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Ut({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=o.useRef(e!==void 0),[i,l]=o.useState(t),f=s&&e!==void 0?e:i,c=o.useCallback(y=>{s||l(y)},[]);return[f,c]}const on=o.createContext(void 0),sn=o.createContext(void 0),ln=o.createContext(void 0);function Le(){const e=o.useContext(on);if(e===void 0)throw new Error(He(60));return e}function wt(){const e=o.useContext(sn);if(e===void 0)throw new Error(He(101));return e}function cn(){const e=o.useContext(ln);if(e===void 0)throw new Error(He(61));return e}const vr="data-valid",Mr="data-invalid",Pr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Or={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Ar={disabled:!1,...Or},Lr={valid(e){return e===null?null:e?{[vr]:""}:{[Mr]:""}}},Vr={invalid:void 0,name:void 0,validityData:{state:Pr,errors:[],error:"",value:"",initialValue:null},setValidityData:te,disabled:void 0,setTouched:te,setDirty:te,setFilled:te,setFocused:te,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Ar,registerFieldControl:te,validation:{getValidationProps:(e,t=Ge)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:te,getInputControl:()=>null,commit:async()=>{},change:te}},Fr=o.createContext(Vr);function vt(e=!0){const t=o.useContext(Fr);if(t.setValidityData===te&&!e)throw new Error(He(28));return t}function Dr(e,t,n,r,s=!0,i){const{registerFieldControl:l}=vt(),f=ke(()=>Symbol());z(()=>{const c=f.current;if(!s){l(c,void 0);return}l(c,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,s,r,t,i,l,f,n]),z(()=>{const c=f.current;return()=>{l(c,void 0)}},[l,f])}const kr=o.createContext({controlId:void 0,registerControlId:te,resetControlId:te,labelId:void 0,setLabelId:te,messageIds:[],setMessageIds:te,getDescriptionProps:e=>e});function un(){return o.useContext(kr)}function an(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:s,resetControlId:i}=un(),l=Xn(),f=ke(()=>Symbol()),c=o.useRef(!1),y=o.useRef(!1),b=Y(()=>{!c.current||s===te||(c.current=!1,s(f.current,void 0))});return z(()=>{if(!n||s===te){b();return}let x;if(t!==void 0)y.current=!0,x=t;else if(y.current)x=l;else{i();return}if(x===void 0){b();return}c.current=!0,s(f.current,x)},[t,n,s,i,l,f,b]),z(()=>b,[b]),(n?r:void 0)??t??l}function Nr(e,t,n=Object.is){const{length:r}=e;if(r!==t.length)return!1;for(let s=0;s<r;s+=1)if(!n(e[s],t[s]))return!1;return!0}const fn=(e,t)=>Object.is(e,t);function Ae(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Hr(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Nr(e,t,(r,s)=>Ae(r,s,n)):e!==t}function It(e,t,n){return e?e.some(r=>r===void 0?!1:Ae(t,r,n)):!1}function ot(e,t,n){return e?e.findIndex(r=>r===void 0?!1:Ae(r,t,n)):-1}function _r(e,t){if(t!==fn)return r=>It(e,r,t);const n=new Set(e);return n.delete(void 0),r=>n.has(r)&&(r!==0||e.some(s=>Object.is(r,s)))}function dn(e,t,n,r){const s=r&&Array.isArray(t)?e.findIndex(_r(t,n)):ot(e,t,n);return s===-1?null:s}function Ur(e,t,n,r,s,i){return It(r,t,s)?i!=null&&e>i&&It(r,n[i],s)?i:e:e===i?dn(n,r,s,!0):i}function Br(e,t,n){return e.filter(r=>!Ae(t,r,n))}function Ct(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Wr(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function pn(e){return Wr(e?.[0])}function jr(e){return pn(e)?e.flatMap(t=>t.items):e}function qr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(pn(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function gn(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 Ct(e)}function De(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Ct(e.value):Ct(e)}function mn(e,t,n){function r(){return gn(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(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){const i=jr(t);if(e==null||typeof e!="object"){const l=i.find(f=>f.value===e);return l&&l.label!=null?l.label:r()}if("value"in e){const l=i.find(f=>f&&f.value===e.value);if(l&&l.label!=null)return l.label}}return r()}function zr(e,t,n){return e.reduce((r,s,i)=>(i>0&&r.push(", "),r.push(ae.jsx(o.Fragment,{children:mn(s,t,n)},i)),r),[])}const Kr={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:De(t,r)!==""},hasNullItemLabel:(e,t)=>t?qr(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(s=>Ae(t,s,n)):Ae(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},Yr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:te,validationMode:"onSubmit",submitCountRef:{current:0}});function $r(){return o.useContext(Yr)}const Ce=1;function hn(e,t){return Math.max(0,e-t)}function Gr(e,t){if(t<=0)return 0;const n=Ke(e,0,t),r=n,s=t-n,i=r<=Ce,l=s<=Ce;return i&&l?r<=s?0:t:i?0:l?t:n}function Eo(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:i,defaultOpen:l=!1,onOpenChange:f,name:c,form:y,autoComplete:b,disabled:x=!1,readOnly:w=!1,required:m=!1,modal:V=!0,actionsRef:v,inputRef:C,onOpenChangeComplete:d,items:_,multiple:E=!1,itemToStringLabel:p,itemToStringValue:a,isItemEqualToValue:O=fn,highlightItemOnHover:h=!0,children:S}=e,{clearErrors:H}=$r(),{setDirty:D,setTouched:G,setFocused:$,validityData:R,setFilled:F,name:K,disabled:J,validation:q,validationMode:M}=vt(),U=an({id:t}),g=J||x,T=K??c,[A,L]=Ut({controlled:n,default:E?r??bt:r,name:"Select",state:"value"}),[k,X]=Ut({controlled:i,default:l,name:"Select",state:"open"}),ne=o.useRef([]),re=o.useRef([]),se=o.useRef(null),le=o.useRef(null),oe=o.useRef(0),fe=o.useRef(null),B=o.useRef([]),j=o.useRef(!1),ce=o.useRef(null),Z=o.useRef(null),ge=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),xe=o.useRef(!1),de=o.useRef(A),{mounted:ue,setMounted:me,transitionStatus:Se}=nn(k),{openMethod:ee,triggerProps:we}=Rr(k),u=ke(()=>new kn({id:U,labelId:void 0,modal:V,multiple:E,itemToStringLabel:p,itemToStringValue:a,isItemEqualToValue:O,value:A,open:k,mounted:ue,transitionStatus:Se,items:_,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ge,triggerProps:Ge,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:te,setOpen:te,handleScrollArrowVisibility:te,onOpenChangeComplete:te,listRef:ne,popupRef:se,scrollHandlerRef:le,scrollArrowsMountedCountRef:oe,valueRef:fe,valuesRef:B,labelsRef:re,typingRef:j,selectionRef:ge,firstItemTextRef:ce,selectedItemTextRef:Z,alignItemWithTriggerActiveRef:xe,initialValueRef:de},Kr)).current,I=u.useState("activeIndex"),Q=u.useState("selectedIndex"),P=u.useState("triggerElement"),N=u.useState("positionerElement"),ve=Er(ee),Me=ee??ve,be=o.useMemo(()=>E?"":De(A,a),[E,A,a]),Re=o.useMemo(()=>E&&Array.isArray(A)?A.map(W=>De(W,a)):De(A,a),[E,A,a]),Ue=Oe(P),Be=Y(()=>Re);Dr(Ue,U,A,Be,!g,c);const We=E?Array.isArray(A)&&A.length>0:A!=null&&be!=="";z(()=>{F(We)},[We,F]),z(function(){const ie=dn(B.current,A,O,E);ie===null&&(Z.current=null),!k&&u.set("selectedIndex",ie)},[E,k,A,O,u]),rn(A,()=>{H(T),D(Hr(A,R.initialValue,O)),q.change(A)});const je=Y((W,ie)=>{f?.(W,ie),!ie.isCanceled&&(X(W),!W&&(ie.reason===$t||ie.reason===Nn)&&(G(!0),$(!1),M==="onBlur"&&q.commit(A)))}),Ve=Y(()=>{me(!1),u.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),d?.(!1)});Tt({enabled:!v,open:k,ref:se,onComplete(){k||Ve()}}),o.useImperativeHandle(v,()=>({unmount:Ve}),[Ve]);const qe=Y((W,ie)=>{s?.(W,ie),!ie.isCanceled&&L(W)}),ft=Y(W=>{const ie=hn(W.scrollHeight,W.clientHeight),Xe=Gr(W.scrollTop,ie),dt=Xe>0,ze=Xe<ie;u.set("scrollUpArrowVisible",dt),u.set("scrollDownArrowVisible",ze)}),Pe=fr({open:k,onOpenChange:je,elements:{reference:P,floating:N}}),he=ar(Pe,{enabled:!g,event:"mousedown"}),ye=Jn(Pe),Ee=mr(Pe,{enabled:!g,listRef:ne,activeIndex:I,selectedIndex:Q,disabledIndices:bt,onNavigate(W){W===null&&!k||u.set("activeIndex",W)},focusItemOnHover:h}),Fe=hr(Pe,{enabled:!g&&(k||!w&&!E),listRef:re,activeIndex:I,selectedIndex:Q,disabledIndices:W=>wr(ne.current[W]),onMatch(W){k?u.set("activeIndex",W):qe(B.current[W],pe(it))},onTyping(W){j.current=W}}),Pt=o.useMemo(()=>yt(Fe.reference,Ee.reference,ye.reference,he.reference,we),[he.reference,Fe.reference,Ee.reference,ye.reference,we]),Ot=o.useMemo(()=>yt(Zn,Fe.floating,Ee.floating,ye.floating),[Fe.floating,Ee.floating,ye.floating]),At=Ee.item??Ge;u.useContextCallback("setValue",qe),u.useContextCallback("setOpen",je),u.useContextCallback("handleScrollArrowVisibility",ft),u.useContextCallback("onOpenChangeComplete",d),Tr(()=>{u.update({popupProps:Ot,triggerProps:Pt})}),u.useSyncedValues({id:U,modal:V,multiple:E,value:A,open:k,mounted:ue,transitionStatus:Se,popupProps:Ot,triggerProps:Pt,items:_,itemToStringLabel:p,itemToStringValue:a,isItemEqualToValue:O,openMethod:Me});const yn=o.useMemo(()=>({disabled:g,readOnly:w,required:m,multiple:E,highlightItemOnHover:h,itemProps:At}),[g,w,m,E,h,At]),In=Vn(C,q.inputRef),Lt=E?void 0:T,Cn=o.useMemo(()=>!E||!Array.isArray(A)||!T?null:A.map(W=>{const ie=De(W,a);return ae.jsx("input",{type:"hidden",form:y,name:T,value:ie,disabled:g},ie)}),[E,A,y,T,a,g]);return ae.jsxs(on.Provider,{value:u,children:[ae.jsx(sn.Provider,{value:yn,children:ae.jsx(ln.Provider,{value:Pe,children:S})}),ae.jsx("input",{...q.getValidationProps(g,{onFocus(){u.state.triggerElement?.focus({focusVisible:!0})},onChange(W){if(W.nativeEvent.defaultPrevented||g||w)return;const ie=W.currentTarget.value,Xe=pe(it,W.nativeEvent);function dt(){if(E)return;const ze=ie.toLowerCase();let pt=B.current.findIndex(gt=>De(gt,a).toLowerCase()===ze||gn(gt,p).toLowerCase()===ze);pt===-1&&(pt=B.current.findIndex((gt,En)=>{const Ft=re.current[En];return Ft!=null&&Ft.toLowerCase()===ze}));const Vt=B.current[pt];Vt!=null&&qe(Vt,Xe)}u.set("forceMount",!0),queueMicrotask(dt)}}),id:U&&Lt==null?`${U}-hidden-input`:void 0,form:y,name:Lt,autoComplete:b,value:be,disabled:g,required:m&&!(E&&We),readOnly:w,ref:In,style:T?Fn:Dn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Cn]})}function Xr(e,t){return e??t}const Qe=5;function Jr(e,t){const n=Zr(t);return e.clientX>=n.left-Qe&&e.clientX<=n.right+Qe&&e.clientY>=n.top-Qe&&e.clientY<=n.bottom+Qe}function Zr(e){const t=e.getBoundingClientRect(),n=rt(e);if(Hn)return t;const r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const l=parseFloat(r.width)||0,f=parseFloat(r.height)||0,c=parseFloat(s.width)||0,y=parseFloat(s.height)||0,b=Math.max(t.width,l,c),x=Math.max(t.height,f,y),w=b-t.width,m=x-t.height;return{left:t.left-w/2,right:t.right+w/2,top:t.top-m/2,bottom:t.bottom+m/2}}const Qr="data-popup-side",eo=400,to={...Qn,...Lr,popupSide:e=>e?{[Qr]:e}:null,value:()=>null},To=o.forwardRef(function(t,n){const{render:r,className:s,id:i,disabled:l=!1,nativeButton:f=!0,style:c,...y}=t,{setTouched:b,setFocused:x,validationMode:w,validation:m,state:V,disabled:v}=vt(),{labelId:C}=un(),d=Le(),{readOnly:_,required:E,disabled:p}=wt(),a=v||p||l,O=d.useState("open"),h=d.useState("mounted"),S=d.useState("value"),H=d.useState("triggerProps"),D=d.useState("positionerElement"),G=d.useState("listElement"),$=d.useState("popupSide"),R=d.useState("id"),F=d.useState("labelId"),K=d.useState("hasSelectedValue"),J=h&&D?$:null,q=i??R,M=Xr(C,F);an({id:i});const U=Oe(D),g=o.useRef(null),{getButtonProps:T,buttonRef:A}=Jt({disabled:a,native:f}),L=d.useStateSetter("triggerElement"),k=$e(),X=$e(),ne=$e();o.useEffect(()=>{if(O)return ne.start(eo,()=>{d.context.selectionRef.current.allowUnselectedMouseUp=!0,d.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{ne.clear()};d.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},X.clear()},[O,d,X,ne]);const re=yt(H,{id:q,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?G?.id??Yt(D)?.id:void 0,"aria-labelledby":M,"aria-readonly":_||void 0,"aria-required":E||void 0,tabIndex:a?-1:0,onFocus(oe){x(!0),O&&d.context.alignItemWithTriggerActiveRef.current&&d.context.setOpen(!1,pe(it,oe.nativeEvent)),k.start(0,()=>{d.set("forceMount",!0)})},onBlur(oe){Te(D,oe.relatedTarget)||(b(!0),x(!1),w==="onBlur"&&m.commit(S))},onMouseDown(oe){if(O)return;const fe=Ne(oe.currentTarget);function B(j){if(!g.current)return;const ce=j.target;Te(g.current,ce)||Te(U.current,ce)||Jr(j,g.current)||d.context.setOpen(!1,pe(_n,j))}X.start(0,()=>{fe.addEventListener("mouseup",B,{once:!0})})}},y,T),se=m.getValidationProps(a,re);se.role="combobox";const le={...V,open:O,disabled:a,value:S,readOnly:_,popupSide:J,placeholder:!K};return _e("button",t,{ref:[n,g,A,L],state:le,stateAttributesMapping:to,props:se})}),no={value:()=>null},wo=o.forwardRef(function(t,n){const{className:r,render:s,children:i,placeholder:l,style:f,...c}=t,y=Le(),b=y.useState("value"),x=y.useState("items"),w=y.useState("itemToStringLabel"),m=y.useState("hasSelectedValue"),V=!m&&l!=null&&i==null,v=y.useState("hasNullItemLabel",V),C={value:b,placeholder:!m};let d=null;return typeof i=="function"?d=i(b):i!=null?d=i:V&&!v?d=l:Array.isArray(b)?d=zr(b,x,w):d=mn(b,x,w),_e("span",t,{state:C,ref:[n,y.context.valueRef],props:[{children:d},c],stateAttributesMapping:no})}),vo=o.forwardRef(function(t,n){const r=Le(),s=r.useState("mounted"),i=r.useState("forceMount");return s||i?ae.jsx(Un,{ref:n,...t}):null}),xn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function ro(){return o.useContext(xn)}function oo(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,i=Y(s),[,l]=o.useState(!1),f=ke(io).current,c=ke(so).current,y=o.useRef(0),b=o.useRef(!0),x=o.useRef(null),w=o.useRef(null),m=Y(()=>{b.current||(b.current=!0,l(a=>!a))}),V=Y((a,O)=>{c.set(a,O),m()}),v=Y(a=>{c.delete(a),m()}),C=Y(a=>{const O=new Map;return n.current.length=0,r&&(r.current.length=0),a.forEach(h=>{O.set(h.element,{...h.registration.metadata??{},index:h.index}),n.current[h.index]=h.element,r&&(r.current[h.index]=h.registration.label!==void 0?h.registration.label:h.registration.textRef?.current?.textContent??h.element.textContent)}),y.current=n.current.length,O});function d(a){if(w.current?.disconnect(),w.current=null,typeof MutationObserver!="function"||a.length<2)return;const O=new MutationObserver(S=>{if(!uo(S))return;let H=null;for(const D of a)if(D.isConnected){if(H&&Sn(H,D)>0){O.disconnect(),m();return}H=D}});w.current=O;const h=new Set;for(let S=1;S<a.length;S+=1){const H=co(a[S-1],a[S]);H&&h.add(H)}h.forEach(S=>O.observe(S,{childList:!0}))}const _=Y(()=>{const[a,O]=lo(c),h=C(a),S=x.current,H=!S||S.length!==a.length||a.some((D,G)=>{const $=S[G];return D.index!==$.index||D.element!==$.element||D.registration.index!==$.registration.index||D.registration.metadata!==$.registration.metadata});d(O),x.current=a,b.current=!1,H&&(f.forEach(D=>D(h)),i(h))});z(()=>(!b.current&&x.current&&C(x.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,C]),z(()=>{b.current&&_()}),z(()=>()=>{w.current?.disconnect(),b.current=!0},[]);const E=Y(a=>(f.add(a),()=>{f.delete(a)})),p=o.useMemo(()=>({register:V,unregister:v,subscribeMapChange:E,nextIndexRef:y}),[V,v,E,y]);return ae.jsx(xn.Provider,{value:p,children:t})}function so(){return new Map}function io(){return new Set}function lo(e){const t=new Set,n=[],r=[];e.forEach((i,l)=>{if(!l.isConnected)return;const f=i.index,c={index:f??-1,element:l,registration:i};f===null?r.push(c):f>=0&&(t.add(f),n.push(c))});let s=0;return r.sort((i,l)=>Sn(i.element,l.element)),r.forEach(i=>{for(;t.has(s);)s+=1;i.index=s,n.push(i),s+=1}),t.size>0&&n.sort((i,l)=>i.index-l.index),[n,r.map(i=>i.element)]}function co(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function uo(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function Sn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const Rn=o.createContext(void 0);function ao(){const e=o.useContext(Rn);if(!e)throw new Error(He(59));return e}function lt(e,t){e&&Object.assign(e.style,t)}const fo={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},po={position:"fixed"},Mo=o.forwardRef(function(t,n){const{anchor:r,className:s,render:i,positionMethod:l,side:f,align:c,sideOffset:y,alignOffset:b,collisionBoundary:x="clipping-ancestors",collisionPadding:w,arrowPadding:m,sticky:V,disableAnchorTracking:v,alignItemWithTrigger:C=!0,collisionAvoidance:d=Bn,style:_,...E}=t,p=Le(),a=cn(),O=p.useState("open"),h=p.useState("mounted"),S=p.useState("modal"),H=p.useState("value"),D=p.useState("openMethod"),G=p.useState("positionerElement"),$=p.useState("triggerElement"),R=p.useState("isItemEqualToValue"),F=p.useState("transitionStatus"),K=o.useRef(null),J=o.useRef(null),[q,M]=o.useState(C),U=h&&q&&D!=="touch";!h&&q!==C&&M(C),o.useImperativeHandle(p.context.alignItemWithTriggerActiveRef,()=>U),yr((U||S)&&O,D==="touch",G,$);const g=or({anchor:r,floatingRootContext:a,positionMethod:l,mounted:h,side:f,sideOffset:y,align:c,alignOffset:b,arrowPadding:m,collisionBoundary:x,collisionPadding:w,sticky:V,disableAnchorTracking:v??U,collisionAvoidance:d,keepMounted:!0}),T=U?"none":g.side,A=U?po:g.positionerStyles,L={open:O,side:T,align:g.align,anchorHidden:g.anchorHidden};z(()=>{p.set("popupSide",g.side)},[p,g.side]);const k=p.useStateSetter("positionerElement"),X=sr(t,L,{styles:A,transitionStatus:F,props:E,refs:[n,k],hidden:!h,inert:!O}),ne=o.useRef(0),re=Y(le=>{if(p.context.valuesRef.current.length===0)return;const oe=ne.current;ne.current=le.size;const fe=pe(it);if(oe!==0&&!p.state.multiple&&H!==null&&ot(p.context.valuesRef.current,H,R)===-1){const j=p.context.initialValueRef.current,Z=j!=null&&ot(p.context.valuesRef.current,j,R)!==-1?j:null;p.context.setValue(Z,fe),Z===null&&(p.set("selectedIndex",null),p.context.selectedItemTextRef.current=null)}if(oe!==0&&p.state.multiple&&Array.isArray(H)){const B=H.filter(j=>ot(p.context.valuesRef.current,j,R)!==-1);B.length!==H.length&&(p.context.setValue(B,fe),B.length===0&&(p.set("selectedIndex",null),p.context.selectedItemTextRef.current=null))}if(O&&U){p.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const B={height:""};lt(G,B),lt(p.context.popupRef.current,B)}}),se=o.useMemo(()=>({...g,side:T,alignItemWithTriggerActive:U,setControlledAlignItemWithTrigger:M,scrollUpArrowRef:K,scrollDownArrowRef:J}),[g,T,U,M]);return ae.jsx(oo,{elementsRef:p.context.listRef,labelsRef:p.context.labelsRef,onMapChange:re,children:ae.jsxs(Rn.Provider,{value:se,children:[h&&S&&ae.jsx(er,{inert:Wn(!O),cutout:$}),X]})})}),et="base-ui-disable-scrollbar",Bt={className:et,getElement(e){return ae.jsx("style",{nonce:e,href:et,precedence:"base-ui:low",children:`.${et}{scrollbar-width:none}.${et}::-webkit-scrollbar{display:none}`})}},go=o.createContext(void 0),mo={disableStyleElements:!1};function ho(){return o.useContext(go)??mo}const Wt="--transform-origin",xo={...nr,...Zt},Po=o.forwardRef(function(t,n){const{render:r,className:s,style:i,finalFocus:l,...f}=t,c=Le(),{multiple:y,readOnly:b,highlightItemOnHover:x}=wt(),w=cn(),{side:m,align:V,alignItemWithTriggerActive:v,isPositioned:C,setControlledAlignItemWithTrigger:d}=ao(),_=Cr()!=null,E=ir(),{nonce:p,disableStyleElements:a}=ho(),O=c.useState("id"),h=c.useState("open"),S=c.useState("openMethod"),H=c.useState("mounted"),D=c.useState("popupProps"),G=c.useState("transitionStatus"),$=c.useState("triggerElement"),R=c.useState("positionerElement"),F=c.useState("listElement"),K=o.useRef(!1),J=o.useRef(!1),q=o.useRef({}),M=st(),U=Y(L=>{if(!R||!c.context.popupRef.current||!J.current)return;const k=R.style.top==="0px",X=R.style.bottom==="0px";if(K.current||!v||!k&&!X){c.context.handleScrollArrowVisibility(L);return}const ne=qt(R),re=Ye(R.getBoundingClientRect().height,"y",ne),se=Ne(R),le=rt(R),oe=le.getComputedStyle(R),fe=parseFloat(oe.marginTop),B=parseFloat(oe.marginBottom),j=jt(le.getComputedStyle(c.context.popupRef.current)),ce=Math.min(se.documentElement.clientHeight-fe-B,j),Z=L.scrollTop,ge=tt(L);let xe=null;const de=ee=>{R.style.height=`${ee}px`},ue=k?ge-Z:Z,me=Math.min(re+ue,ce);if(ue<=Ce){const ee=Ke(ue,0,ce-re);ee>0&&de(re+ee),L.scrollTop=k?ge:0,ce-(re+ee)<=Ce&&(K.current=!0),c.context.handleScrollArrowVisibility(L);return}if(ce-me>Ce)xe=k?1/0:0;else if(X&&Z<ge){const ee=re+ue-ce;xe=Z-(ue-ee)}const Se=Math.ceil(me);if(Se!==0&&de(Se),xe!=null){const ee=Ke(xe,0,tt(L));Math.abs(L.scrollTop-ee)>Ce&&(L.scrollTop=ee)}Se>=ce-Ce&&(K.current=!0),c.context.handleScrollArrowVisibility(L)});o.useImperativeHandle(c.context.scrollHandlerRef,()=>U,[U]),Tt({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete(!0)}});const g={open:h,transitionStatus:G,side:m,align:V};z(()=>{!R||!c.context.popupRef.current||Object.keys(q.current).length||(q.current={top:R.style.top||"0",left:R.style.left||"0",right:R.style.right,height:R.style.height,bottom:R.style.bottom,minHeight:R.style.minHeight,maxHeight:R.style.maxHeight,marginTop:R.style.marginTop,marginBottom:R.style.marginBottom})},[c,R]),z(()=>{h||v||(J.current=!1,K.current=!1,lt(R,q.current))},[h,v,R]),z(()=>{const L=c.context.popupRef.current;if(!h||!$||!R||!L||v&&!C||c.state.transitionStatus==="ending")return;if(J.current=!0,L.style.removeProperty(Wt),!v){M.request(()=>c.context.handleScrollArrowVisibility(F||L));return}const k=So(L);try{let X=c.context.selectedItemTextRef.current;X?.isConnected||(X=!c.select("hasSelectedValue")&&c.context.firstItemTextRef.current?.isConnected?c.context.firstItemTextRef.current:null);const ne=c.context.valueRef.current,re=rt(R),se=re.getComputedStyle(R),le=re.getComputedStyle(L),oe=Ne($),fe=qt($),B=nt($.getBoundingClientRect(),fe),j=nt(R.getBoundingClientRect(),fe),ce=B.height,Z=F||L,ge=Z.scrollHeight,xe=parseFloat(le.borderBottomWidth),de=parseFloat(se.marginTop)||10,ue=parseFloat(se.marginBottom)||10,me=parseFloat(se.minHeight)||100,Se=jt(le),ee=5,we=5,u=20,I=oe.documentElement.clientHeight-de-ue,Q=oe.documentElement.clientWidth,P=I-B.bottom+ce;let N,ve=E==="rtl"?B.right-j.width:B.left,Me=0;if(X&&ne){const he=nt(ne.getBoundingClientRect(),fe);N=nt(X.getBoundingClientRect(),fe),ve=j.left+(E==="rtl"?he.right-N.right:he.left-N.left);const ye=he.top-B.top+he.height/2;Me=N.top-j.top+N.height/2-ye}const be=P+Me+ue+xe;let Re=Math.min(I,be);const Ue=I-de-ue,Be=be-Re,We=Q-we;R.style.left=`${Ke(ve,ee,We-j.width)}px`,R.style.height=`${Re}px`,R.style.maxHeight="none",R.style.marginTop=`${de}px`,R.style.marginBottom=`${ue}px`,L.style.height="100%";const je=tt(Z),Ve=Be>=je-Ce;Ve&&(Re=Math.min(I,j.height)-(Be-je));const qe=B.top<u||B.bottom>I-u||Math.ceil(Re)+Ce<Math.min(ge,me),ft=(re.visualViewport?.scale??1)!==1&≫if(qe||ft){lt(R,q.current),d(!1);return}const Pe=Math.max(me,Re);if(Ve){const he=Math.max(0,I-be);R.style.top=j.height>=Ue?"0":`${he}px`,R.style.height=`${Re}px`,Z.scrollTop=tt(Z)}else R.style.bottom="0",Z.scrollTop=Be;if(N){const he=j.top,ye=j.height,Ee=N.top+N.height/2,Fe=Ke(ye>0?(Ee-he)/ye*100:50,0,100);L.style.setProperty(Wt,`50% ${Fe}%`)}(Pe===I||Re>=Se)&&(K.current=!0),c.context.handleScrollArrowVisibility(Z),x&&c.state.selectedIndex===null&&c.state.activeIndex===null&&c.context.listRef.current[0]!=null&&c.set("activeIndex",0)}finally{k()}},[c,h,R,$,v,d,M,F,x,E,C]),o.useEffect(()=>{if(!v||!R||!h)return;const L=rt(R);function k(X){c.context.setOpen(!1,pe(qn,X))}return jn(L,"resize",k)},[c,v,R,h]);const T={...F?{role:"presentation"}:{role:"listbox","aria-multiselectable":y||void 0,"aria-readonly":b||void 0,id:`${O}-list`},onKeyDown(L){_&&rr.has(L.key)&&L.stopPropagation()},onScroll(L){F||U(L.currentTarget)},...v&&{style:F?{height:"100%"}:fo},className:!F&&v?Bt.className:void 0},A=_e("div",t,{ref:[n,c.context.popupRef],state:g,stateAttributesMapping:xo,props:[D,T,ur(G),f]});return ae.jsxs(o.Fragment,{children:[!a&&Bt.getElement(p),ae.jsx(tr,{context:w,modal:!1,disabled:!H,openInteractionType:S,returnFocus:l,restoreFocus:!0,children:A})]})});function jt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function tt(e){return hn(e.scrollHeight,e.clientHeight)}function qt(e){return lr.getScale(e)}function Ye(e,t,n){return e/n[t]}function nt(e,t){return cr({x:Ye(e.x,"x",t),y:Ye(e.y,"y",t),width:Ye(e.width,"x",t),height:Ye(e.height,"y",t)})}const zt=[["transform","none"],["scale","1"],["translate","0 0"]];function So(e){const{style:t}=e,n={};for(const[r,s]of zt)n[r]=t.getPropertyValue(r),t.setProperty(r,s,"important");return()=>{for(const[r]of zt){const s=n[r];s?t.setProperty(r,s):t.removeProperty(r)}}}function Ro(e={}){const{guess:t,label:n,metadata:r,textRef:s,index:i}=e,{register:l,unregister:f,subscribeMapChange:c,nextIndexRef:y}=ro(),b=o.useRef(-1),[x,w]=o.useState(i==null&&t?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1),m=i??x,V=o.useRef(null),v=o.useCallback(C=>{const d=V.current;d&&f(d),V.current=C,C&&l(C,{metadata:r??null,index:i??null,label:n,textRef:s})},[i,l,f,r,n,s]);return z(()=>{if(i==null)return c(C=>{const d=V.current?C.get(V.current)?.index:null;d!=null&&w(d)})},[i,c]),{ref:v,index:m}}const bn=o.createContext(void 0);function Mt(){const e=o.useContext(bn);if(!e)throw new Error(He(57));return e}const Oo=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,value:l=null,label:f,disabled:c=!1,nativeButton:y=!1,...b}=t,x=o.useRef(null),w=Ro({guess:!0,label:f,textRef:x}),m=Le(),{itemProps:V,multiple:v,disabled:C,readOnly:d}=wt(),_=C||c,E=m.useState("isActive",w.index),p=m.useState("open"),a=m.useState("isSelected",l),O=m.useState("isSelectedByFocus",w.index),h=m.useState("isItemEqualToValue"),S=w.index,H=o.useRef(null);z(()=>{const g=m.context.valuesRef.current;return g[S]=l,()=>{delete g[S]}},[S,l,m]),z(()=>{const g=m.state.value,T=m.state.selectedIndex;let A=T,L;v&&Array.isArray(g)?(A=Ur(S,l,m.context.valuesRef.current,g,h,T),L=A===S,S===T&&!L&&(m.context.selectedItemTextRef.current=null)):(L=g!==void 0&&Ae(l,g,h),L&&(A=S)),m.set("selectedIndex",A),L&&x.current&&(m.context.selectedItemTextRef.current=x.current)},[S,v,h,m,l]);const D=o.useRef("mouse"),G=o.useRef(!1),{getButtonProps:$,buttonRef:R}=Jt({disabled:_,focusableWhenDisabled:!0,native:y,composite:!0}),F={disabled:_,selected:a,highlighted:E};function K(g){if(C||d)return;const T=m.state.value;if(v){const A=Array.isArray(T)?T:[],L=a?Br(A,l,h):[...A,l];m.context.setValue(L,pe(xt,g))}else m.context.setValue(l,pe(xt,g)),m.context.setOpen(!1,pe(xt,g))}function J(){m.context.selectionRef.current.dragY=0}const q={role:"option","aria-selected":a,tabIndex:p&&E?0:-1,onKeyDown(g){m.set("activeIndex",S),g.key===" "&&m.context.typingRef.current&&g.preventDefault()},onClick(g){const T=D.current!=="touch",A=g.nativeEvent.pointerType,L=T&&tn(g.nativeEvent)&&(A!==void 0||E),k=T&&!L&&!G.current;G.current=!1,!(_||k)&&K(g.nativeEvent)},onPointerEnter(g){D.current=g.pointerType},onPointerMove(g){if(g.pointerType==="mouse"&&g.buttons===1){const T=m.context.selectionRef.current;T.dragY+=g.movementY,T.dragY**2>=64&&(T.allowUnselectedMouseUp=!0)}},onPointerDown(g){D.current=g.pointerType,G.current=!0,J()},onMouseUp(){if(J(),_||D.current==="touch"||G.current)return;const g=!m.context.selectionRef.current.allowSelectedMouseUp&&a,T=!m.context.selectionRef.current.allowUnselectedMouseUp&&!a;g||T||(G.current=!0,H.current?.click(),G.current=!1)}},M=_e("div",t,{ref:[R,n,w.ref,H],state:F,props:[V,q,b,$]}),U=o.useMemo(()=>({selected:a,index:S,textRef:x,selectedByFocus:O}),[a,S,x,O]);return ae.jsx(bn.Provider,{value:U,children:M})})),Ao=o.forwardRef(function(t,n){const{selected:r}=Mt();return t.keepMounted||r?ae.jsx(bo,{...t,ref:n}):null}),bo=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:i,...l}=e,{selected:f}=Mt(),c=o.useRef(null),{transitionStatus:y,setMounted:b}=nn(f),w=_e("span",e,{ref:[t,c],state:{selected:f,transitionStatus:y},props:[{"aria-hidden":!0,children:"✔️"},l],stateAttributesMapping:Zt});return Tt({batch:!0,enabled:!f,open:f,ref:c,onComplete(){f||b(!1)}}),w})),Lo=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:s,selectedByFocus:i}=Mt(),l=Le(),{render:f,className:c,style:y,...b}=t,x=o.useCallback(m=>{m&&(r===0&&(l.context.firstItemTextRef.current=m),i&&(l.context.selectedItemTextRef.current=m))},[l,r,i]);return _e("div",t,{ref:[x,n,s],props:b})}));export{fo as L,Eo as S,wt as a,ao as b,To as c,wo as d,vo as e,Mo as f,Po as g,Oo as h,Ao as i,Lo as j,ar as k,Sr as l,yr as m,Cr as n,Lr as o,$r as p,vt as q,un as r,Bt as s,an as t,Le as u,Ut as v,Dr as w,rn as x};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-BsOjTB8Q.js","assets/__vite-browser-external-B0m8a6Te.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as ne,by as Dt,bm as Ut,r as o,M as zt,K as Gt,bz as Mt,j as e,c as a,y as le,a as lt,cK as $t,cL as Ft,cM as Bt,cN as Ht,a7 as me,cO as Be,bi as Vt,cP as qt,bh as He,cQ as we,aP as ct,cR as Kt,cS as Wt,ag as dt,u as ut,B as A,V as Pe,aM as mt,X as Yt,x as Oe,a8 as H,cT as Zt,a9 as ee,ar as gt,cU as Ne,a5 as ce,aB as pt,ai as Ve,cV as Jt,ak as Xt,aj as Qt,ah as ea,cW as qe,cX as ta,a1 as aa,af as sa,au as fe,av as Ae,cY as na,R as De,L as ye,al as ia,am as Ue,ac as ra,d as ht,aa as Le,ab as ft,cZ as Ke,c_ as We,c$ as Ye,d0 as oa,d1 as la,ao as ca,Z as xt,l as Se,d2 as Ze,k as Je,d3 as da,d4 as ua,d5 as ma,z as ga,d6 as pa,d7 as ha,d8 as fa,d9 as xa,da as ba,db as ya,dc as va,v as bt,cn as ja,dd as ka,bj as Xe,_ as _a,e as wa,de as Na,df as Sa,bl as Ca}from"./__vite-browser-external-BsOjTB8Q.js";import{a as Ea,b as Qe,s as Pa,K as Oa,P as Aa,D as La,c as Ta,S as Ra,v as Ia,u as Da,C as Ua}from"./sortable.esm-g3UcmvFU.js";import{a as za}from"./modifiers.esm-B4babCm_.js";import{d as et,l as tt,u as Ga,b as at}from"./use-limits-display-prefs-BjO3hsmw.js";import{P as Ma}from"./ProviderIcon-htNu1RTN.js";import{a as R,S as se,T as z,b as Z,c as ve}from"./Controls-DB9eQ_rg.js";import{m as yt}from"./react-VsHxeqq7.js";import{P as $a,u as Fa,a as Ba}from"./use-session-efficiency-pref-BShLuIbk.js";import{C as Ha}from"./check-DIfCVsPJ.js";import{C as Va,i as qa}from"./host-mode-UjbNKxFB.js";import{A as vt}from"./index-Ci3CZ-2g.js";import{r as Ka,C as Ce,o as Wa}from"./cloud-checkout-DOxBG7oS.js";import{u as Ya,D as Za,a as Ja,b as Xa,c as Qa,d as es,e as ts}from"./DialogTitle-ck8f1qeP.js";import{u as as,p as ss,t as ns}from"./composite-W1R1XwoE.js";import{k as is,l as rs}from"./SelectItemText-DRmxMwo5.js";import{u as os}from"./safePolygon-CCDOsx-z.js";import{D as ls}from"./DialogClose-BR9QrB34.js";import{G as Te}from"./gift-BEOvq2zc.js";import{C as Re}from"./chevron-down-DrWxRBXX.js";import{D as cs}from"./DateRangePopover-DgZEnn4X.js";import{C as ds}from"./calendar-days-BVyCx4dJ.js";import{D as Ie}from"./download-CEXAmejX.js";import{P as us,a as ms,b as gs,c as ps,d as hs}from"./PopoverPopup-D-Tpl294.js";import{C as st}from"./Card-CuwBiIYz.js";import{E as nt}from"./external-link-tDBZy6QP.js";import{a as fs,P as xs}from"./play-9W4Ua21o.js";import{I as jt}from"./info-ynVg8RzK.js";import{a as bs,b as ys,c as vs,d as js,e as ks}from"./TooltipPopup--TLYUg0c.js";import{L as xe}from"./loader-circle-FTE9k7Sk.js";import{u as _s}from"./useCurrency-BmEbDVaa.js";import{u as ws}from"./useTokenFormat-CBlBP2aA.js";import{S as ze}from"./Select-6WChWtqK.js";import{u as je}from"./use-native-settings-YKn-htVo.js";import{C as Ns}from"./ConfirmModal-CoFO1Nas.js";import{A as Ss}from"./arrow-up-right-CK_9HuEh.js";import"./store-D2gn9bSV.js";import"./usePositioner-nY0YNa-6.js";import"./DialogDescription-Cx1R3WT7.js";const kt={name:"credit-card",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}],["path",{d:"M6 14h2",key:"mk7k0u"}]]};kt.node;const Cs=ne(kt);const _t={name:"flask-conical",size:24,node:[["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"}]]};_t.node;const Es=ne(_t);const wt={name:"grip-vertical",size:24,node:[["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"}]]};wt.node;const Ps=ne(wt);const Nt={name:"languages",size:24,node:[["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"}]]};Nt.node;const Os=ne(Nt);const St={name:"log-out",size:24,node:[["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"}]]};St.node;const As=ne(St);const Ct={name:"palette",size:24,node:[["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"}]]};Ct.node;const Ls=ne(Ct);const Et={name:"user-round",size:24,node:[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],aliases:["user-2"]};Et.node;const Ts=ne(Et),Rs=Dt(function(s,n){const{render:r,className:i,style:c,disabled:g=!1,nativeButton:l=!0,id:d,payload:p,handle:h,...m}=s,j=Ya(!0),x=os(h)??j;if(!x)throw new Error(Ut(79));const _=as(d),b=x.useState("floatingRootContext"),u=x.useState("isOpenedByTrigger",_),y=x.useState("triggerPopupId",_),k=o.useRef(null),{registerTrigger:f,isMountedByThisTrigger:N}=ss(_,k,x,{payload:p}),{getButtonProps:E,buttonRef:v}=zt({disabled:g,native:l}),C=is(b),O=rs(()=>x.select("open"),M=>{x.set("openMethod",M)}),S={disabled:g,open:u},P=x.useState("triggerProps",N);return Gt("button",s,{state:S,ref:[v,n,f,k],props:[C.reference,P,O,{[Mt]:"",id:_,"aria-haspopup":"dialog","aria-expanded":u,"aria-controls":y},m,E],stateAttributesMapping:ns})}),Is="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Ds({id:t,visible:s,onToggle:n}){const{attributes:r,listeners:i,setNodeRef:c,transform:g,transition:l,isDragging:d}=Da({id:t}),p={transform:Ua.Transform.toString(g)||void 0,transition:l,zIndex:d?20:void 0};return e.jsxs("div",{ref:c,style:p,className:le("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",d&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...r,...i,children:[e.jsx(Ps,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),et(t)?e.jsx(Ma,{provider:et(t),size:18,className:le("pointer-events-none",Is)}):null,e.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:tt(t)}),e.jsx("div",{onPointerDown:h=>h.stopPropagation(),children:e.jsx(z,{checked:s,onChange:n,ariaLabel:`${a("limits.settings.toggle_visible")}: ${tt(t)}`})})]})}function Us({prefs:t}){const{order:s,visibility:n,toggle:r,setAllVisible:i,moveToward:c}=t,g=s.every(m=>n[m]!==!1),l=s.every(m=>n[m]===!1),d=s.filter(m=>n[m]!==!1).length,p=Ea(Qe(Aa,{activationConstraint:{distance:6}}),Qe(Oa,{coordinateGetter:Pa})),h=({active:m,over:j})=>{j&&m.id!==j.id&&c(m.id,j.id)};return e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("limits.settings.bulk_visibility"),hint:a("limits.settings.enabled_count",{enabled:d,total:s.length}),control:e.jsx(se,{options:[{value:"enabled",label:a("limits.settings.enable_all")},{value:"disabled",label:a("limits.settings.disable_all")}],value:g?"enabled":l?"disabled":null,onChange:m=>i(m==="enabled")})}),e.jsx(La,{sensors:p,collisionDetection:Ta,modifiers:[za],onDragEnd:h,children:e.jsx(Ra,{items:s,strategy:Ia,children:e.jsx("div",{className:"flex flex-col",children:s.map(m=>e.jsx(Ds,{id:m,visible:n[m]!==!1,onToggle:()=>r(m)},m))})})})]})}function zs(t){if(!t||typeof t!="object")return"";const s=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},r=s.full_name||s.name||n.name||s.user_name||s.preferred_username;return typeof r=="string"&&r.trim()?r.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Gs(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function Ms(t){const s=typeof t=="string"?t.trim():"";if(!s)return null;const n=s.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),r=s.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),i=n?.[1]||r?.[1];return i?`https://github.com/${i}`:null}function Ge(t,s){console.warn(`[tokentracker] settings ${t}:`,s)}function $s(t,s,n,r){const[i,c]=o.useState(()=>me()),g=s&&n&&dt(),l=o.useMemo(()=>({active:!0,busy:!1}),[t,s,n,r]),d=o.useRef(l);d.current=l;const[p,h]=o.useState(null),m=p?.scope===l?p:null;o.useEffect(()=>{l.active=!0;const _=()=>{const u=me();c(u),u||h(y=>y?.scope===l?{...y,error:null}:y)},b=()=>{h(u=>u?.scope===l?{...u,error:null}:u),we(r,"cloud-sync")};return _(),window.addEventListener("tt.cloudSyncChanged",_),window.addEventListener("storage",_),window.addEventListener(Be,b),()=>{l.active=!1,window.removeEventListener("tt.cloudSyncChanged",_),window.removeEventListener("storage",_),window.removeEventListener(Be,b)}},[l,r]);const j=o.useCallback(async()=>{if(!g||!me()||l.busy||!l.active||d.current!==l)return;l.busy=!0,h({scope:l,pending:!0,error:null});const _=()=>l.active&&d.current===l&&me();try{await Vt(()=>t())}catch(b){if(!_())return;["cloud_membership_required","cloud_read_only_expired","cloud_history_window_exceeded","cloud_machine_limit","machine_limit_exceeded","cloud_machine_paused"].includes(b?.code)?qt(r,b.code,b.membership,"cloud-sync"):h({scope:l,pending:!0,error:{code:"billing_network_error"}}),Ge("cloud sync",b)}finally{l.busy=!1,l.active&&d.current===l&&h(b=>b?.scope===l?{...b,pending:!1}:b)}},[g,l,t,r]),w=o.useCallback(async()=>{if(!g||l.busy||!l.active||d.current!==l)return;const _=!me();h({scope:l,pending:!1,error:null}),He(_),c(_),_?await j():we(r,"cloud-sync")},[g,l,j,r]),x=o.useCallback(()=>{!g||!l.active||d.current!==l||(He(!1),c(!1),h(_=>_?.scope===l?{..._,error:null}:_),we(r,"cloud-sync"))},[g,l,r]);return{cloudSyncOn:i,cloudSyncPending:!!m?.pending,cloudSyncError:m?.error,handleCloudSyncToggle:w,handleCloudSyncRetry:j,handleCloudSyncDisable:x,showLocalCloudSync:g}}function Fs(t){const[s,n]=o.useState(!1),[r,i]=o.useState(!1),[c,g]=o.useState(!1),[l,d]=o.useState(!1),[p,h]=o.useState(null),[m,j]=o.useState(!1),[w,x]=o.useState(""),[_,b]=o.useState(!1),[u,y]=o.useState(""),[k,f]=o.useState(""),[N,E]=o.useState(!1),[v,C]=o.useState(null),O=o.useMemo(()=>zs(t),[t]),S=o.useMemo(()=>Gs(t),[t]),P=o.useMemo(()=>typeof t?.id=="string"?t.id.trim():"",[t]),M=o.useMemo(()=>({setAnonymousOn:i,setCustomDisplayName:h,setGithubUrl:y,setProfileLoading:g,setPublicProfileOn:n,setShowGithubOn:b}),[]);return{anonymousOn:r,customDisplayName:p,displayName:O,editingGithub:N,editingName:m,email:S,githubError:v,githubInput:k,githubUrl:u,loadSetters:M,nameInput:w,profileLoading:c,profileSaving:l,publicProfileOn:s,setAnonymousOn:i,setCustomDisplayName:h,setEditingGithub:E,setEditingName:j,setGithubError:C,setGithubInput:f,setGithubUrl:y,setNameInput:x,setProfileLoading:g,setProfileSaving:d,setPublicProfileOn:n,setShowGithubOn:b,showGithubOn:_,userId:P}}function Bs(t,s,n){o.useEffect(()=>{if(!s)return;let r=!0;return n.setProfileLoading(!0),(async()=>{try{const i=await ct({getAccessToken:t});if(!r||!i)return;const c=await Kt({accessToken:i});if(!r)return;n.setPublicProfileOn(!!c?.enabled),n.setAnonymousOn(!!c?.anonymous),c?.display_name&&n.setCustomDisplayName(c.display_name),n.setShowGithubOn(!!c?.show_github_url),n.setGithubUrl(c?.github_url||"")}catch(i){Ge("load public profile",i)}finally{r&&n.setProfileLoading(!1)}})(),()=>{r=!1}},[t,s,n])}function Hs(t,s,n){return o.useCallback(async(r,{label:i,onError:c,onSuccess:g}={})=>{if(!n||s.profileSaving)return!1;s.setProfileSaving(!0);try{const l=await ct({getAccessToken:t});if(!l)return!1;const d=await Wt({accessToken:l,...r});return g?.(d),!0}catch(l){return c?c(l):Ge(i||"mutate profile",l),!1}finally{s.setProfileSaving(!1)}},[t,s,n])}function Vs(t,s){return{anonymousOn:t.anonymousOn,customDisplayName:t.customDisplayName,displayName:t.displayName,editingName:t.editingName,handleAnonymousToggle:s.handleAnonymousToggle,handleSaveName:s.handleSaveName,nameInput:t.nameInput,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingName:t.setEditingName,setNameInput:t.setNameInput,startEditingName:s.startEditingName}}function qs(t,s){return{editingGithub:t.editingGithub,githubError:t.githubError,githubInput:t.githubInput,githubUrl:t.githubUrl,handleSaveGithub:s.handleSaveGithub,handleShowGithubToggle:s.handleShowGithubToggle,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingGithub:t.setEditingGithub,setGithubError:t.setGithubError,setGithubInput:t.setGithubInput,showGithubOn:t.showGithubOn,startEditingGithub:s.startEditingGithub}}function Ks(t,s){const n=o.useCallback(async()=>{const i=!t.publicProfileOn;await s({enabled:i},{label:"toggle public profile",onSuccess:()=>t.setPublicProfileOn(i)})},[s,t]);return{handleAnonymousToggle:o.useCallback(async()=>{const i=!t.anonymousOn;await s({anonymous:i},{label:"toggle anonymous",onSuccess:()=>t.setAnonymousOn(i)})},[s,t]),handlePublicProfileToggle:n}}function Ws(t,s,n){const r=o.useCallback(async()=>{const c=t.nameInput.trim().slice(0,50);c&&await s({display_name:c},{label:"save display name",onSuccess:()=>{t.setCustomDisplayName(c),t.setEditingName(!1),n?.()}})},[s,t,n]),i=o.useCallback(()=>{t.setNameInput(t.customDisplayName||t.displayName),t.setEditingName(!0)},[t]);return{handleSaveName:r,startEditingName:i}}function Ys(t,s){const n=o.useCallback(async()=>{if(!t.showGithubOn&&!t.githubUrl){t.setEditingGithub(!0),t.setGithubInput(""),t.setGithubError(null);return}const c=!t.showGithubOn;await s({show_github_url:c},{label:"toggle GitHub profile",onSuccess:()=>t.setShowGithubOn(c)})},[s,t]),r=o.useCallback(async()=>{const c=Ms(t.githubInput);if(t.githubInput.trim()&&!c){t.setGithubError(a("settings.account.githubUrlInvalid"));return}t.setGithubError(null),await s({github_url:c,show_github_url:!!c},{label:"save GitHub profile",onError:g=>t.setGithubError(g?.message||a("settings.account.githubUrlInvalid")),onSuccess:g=>{t.setGithubUrl(g?.github_url||c||""),t.setShowGithubOn(!!c),t.setEditingGithub(!1)}})},[s,t]),i=o.useCallback(()=>{t.setGithubInput(t.githubUrl),t.setGithubError(null),t.setEditingGithub(!0)},[t]);return{handleSaveGithub:r,handleShowGithubToggle:n,startEditingGithub:i}}function Me(){const t=lt();o.useSyncExternalStore($t,Ft,()=>0);const s=Bt(t.user?.id),r=!(s.membership?.status==="self_hosted"||s.catalog?.policy?.hosting_mode==="self_hosted")&&(Ht()||s.membership?.hosting_mode==="hosted"),i=Fs(t.user),c=$s(t.getAccessToken,t.enabled,t.signedIn,t.user?.id);Bs(t.getAccessToken,t.signedIn&&r,i.loadSetters);const g=Hs(t.getAccessToken,i,r),l=Ks(i,g),d=Ws(i,g,t.refreshDisplayName),p=Ys(i,g);return{...t,...c,email:i.email,handlePublicProfileToggle:l.handlePublicProfileToggle,userId:i.userId,name:Vs(i,{...l,...d}),github:qs(i,p),profileLoading:i.profileLoading,profileSaving:i.profileSaving,publicProfileOn:r&&i.publicProfileOn,publicProfileAvailable:r}}function Pt({disabled:t,onCancel:s,onSave:n,saveLabel:r=a("settings.account.save")}){return e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"primary",size:"sm",onClick:n,disabled:t,children:r}),e.jsx(A,{variant:"ghost",size:"sm",onClick:s,className:"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:a("settings.account.cancel")})]})}function Zs({nameInput:t,setEditingName:s,setNameInput:n,profileSaving:r,handleSaveName:i}){return e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:c=>n(c.target.value),onKeyDown:c=>{c.key==="Enter"&&i(),c.key==="Escape"&&s(!1)},maxLength:50,autoFocus:!0,className:`flex-1 ${ve}`,placeholder:a("settings.account.displayName")}),e.jsx(Pt,{disabled:r||!t.trim(),onCancel:()=>s(!1),onSave:i,saveLabel:r?a("settings.account.saving"):void 0})]})}function Js({githubError:t,githubInput:s,handleSaveGithub:n,profileSaving:r,setEditingGithub:i,setGithubError:c,setGithubInput:g}){return e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:s,onChange:l=>{g(l.target.value),t&&c(null)},onKeyDown:l=>{l.key==="Enter"&&n(),l.key==="Escape"&&(i(!1),c(null))},maxLength:100,autoFocus:!0,className:`flex-1 ${ve}`,placeholder:a("settings.account.githubUrlPlaceholder")}),e.jsx(Pt,{disabled:r,onCancel:()=>{i(!1),c(null)},onSave:n,saveLabel:r?a("settings.account.saving"):void 0})]}),t?e.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:t}):null]})}function Ot({disabled:t=!1,label:s,onClick:n,title:r}){return e.jsxs(A,{variant:"secondary",size:"sm",onClick:n,disabled:t,title:r,className:"gap-1.5",children:[e.jsx($a,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s})]})}function At({actions:t,editing:s,editor:n,hint:r,label:i}){return e.jsx("div",{className:"py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:i}),s?n:e.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r})]}),s?null:t]})})}function Xs({name:t}){const s=t.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Ot,{disabled:t.anonymousOn,label:a("settings.account.edit"),onClick:t.startEditingName,title:s}),e.jsx(z,{checked:!t.anonymousOn,onChange:t.handleAnonymousToggle,disabled:t.profileLoading||t.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function Qs({name:t}){const{anonymousOn:s,customDisplayName:n,displayName:r,editingName:i,handleAnonymousToggle:c,handleSaveName:g,nameInput:l,profileLoading:d,profileSaving:p,setEditingName:h,setNameInput:m,startEditingName:j}=t,w=s?a("settings.account.displayNameAnonymousHint"):n||r;return e.jsx(At,{label:a("settings.account.displayName"),editing:i,hint:w,editor:e.jsx(Zs,{nameInput:l,setEditingName:h,setNameInput:m,profileSaving:p,handleSaveName:g}),actions:e.jsx(Xs,{name:t})})}function en({github:t}){const{editingGithub:s,githubError:n,githubInput:r,githubUrl:i,handleSaveGithub:c,handleShowGithubToggle:g,profileLoading:l,profileSaving:d,setEditingGithub:p,setGithubError:h,setGithubInput:m,showGithubOn:j,startEditingGithub:w}=t;return e.jsx(e.Fragment,{children:e.jsx(At,{label:a("settings.account.githubUrl"),editing:s,hint:i||a("settings.account.githubUrlHint"),editor:e.jsx(Js,{githubError:n,githubInput:r,handleSaveGithub:c,profileSaving:d,setEditingGithub:p,setGithubError:h,setGithubInput:m}),actions:e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Ot,{label:a("settings.account.edit"),onClick:w}),e.jsx(z,{checked:j,onChange:g,disabled:l||d,ariaLabel:a("settings.account.githubUrl")})]})})})}function tn(){const{openLoginModal:t}=ut();return e.jsx(Z,{title:a("settings.section.account"),children:e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.account.signedOutHint")}),e.jsx(A,{variant:"primary",size:"sm",onClick:t,children:a("settings.account.signIn")})]})})}function an({name:t,github:s}){return e.jsxs(e.Fragment,{children:[e.jsx(Qs,{name:t}),e.jsx(en,{github:s})]})}function sn({settings:t}={}){return t?e.jsx(Lt,{settings:t}):e.jsx(nn,{})}function nn(){const t=Me();return e.jsx(Lt,{settings:t})}function Lt({settings:t}){return t.enabled?t.signedIn?e.jsxs(Z,{title:a("settings.section.account"),subtitle:t.email||t.name.customDisplayName||t.name.displayName,action:e.jsx(on,{onSignOut:t.signOut}),children:[e.jsx(rn,{userId:t.userId}),e.jsx(ln,{checked:t.publicProfileOn,disabled:t.profileLoading||t.profileSaving||t.publicProfileAvailable===!1,onChange:t.handlePublicProfileToggle,unavailable:t.publicProfileAvailable===!1}),e.jsx(cn,{visible:t.publicProfileOn,name:t.name,github:t.github})]}):e.jsx(tn,{}):null}function rn({userId:t}){const[s,n]=Pe.useState(!1);if(!t)return null;const r=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(t),n(!0),globalThis.setTimeout(()=>n(!1),1200)}catch{n(!1)}};return e.jsx(R,{label:a("settings.account.userId"),hint:e.jsx("span",{className:"font-mono",children:t}),control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:r,"aria-label":a("settings.account.copyUserId"),className:"gap-1.5",children:[s?e.jsx(Ha,{className:"h-3.5 w-3.5","aria-hidden":!0}):e.jsx(Va,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s?a("settings.account.copied"):a("settings.account.copy")})]})})}function on({onSignOut:t}){return e.jsxs(A,{variant:"ghost",size:"sm",onClick:()=>t(),className:"!h-7 !px-2 text-xs text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[e.jsx(As,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":!0}),e.jsx("span",{children:a("settings.account.signOut")})]})}function ln({checked:t,disabled:s,onChange:n,unavailable:r}){return e.jsx(R,{label:a("settings.account.publicProfile"),hint:a(r?"cloud.self_host.public_profile_disabled":"settings.account.publicProfileHint"),control:e.jsx(z,{checked:t,onChange:n,disabled:s,ariaLabel:a("settings.account.publicProfile")})})}function cn({visible:t,name:s,github:n}){return e.jsx(vt,{initial:!1,children:t?e.jsx(yt.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:e.jsx(an,{name:s,github:n})},"public-profile-fields"):null})}function $e({open:t,onOpenChange:s,title:n,triggerLabel:r=n,icon:i,wide:c=!1,preventClose:g=!1,initialFocus:l,children:d}){return e.jsxs(Za,{open:t,onOpenChange:(p,h)=>{if(!p&&g){h.cancel();return}s(p)},children:[e.jsxs(Rs,{className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[i?e.jsx(i,{size:16,className:"shrink-0","aria-hidden":!0}):null,e.jsx("span",{className:"min-w-0 flex-1",children:r}),e.jsx(mt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsxs(Ja,{children:[e.jsx(Xa,{className:"tt-cloud-action-backdrop fixed inset-0 z-[100] bg-black/40 dark:bg-black/60"}),e.jsx(Qa,{className:"tt-cloud-settings fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:e.jsxs(es,{initialFocus:l,"aria-modal":"true",className:`tt-cloud-action-popup tt-cloud-theme relative max-h-[calc(100dvh-2rem)] w-full ${c?"max-w-2xl":"max-w-lg"} overflow-y-auto overscroll-contain rounded-xl bg-white p-5 shadow-xl outline-none dark:bg-oai-gray-900`,children:[e.jsxs("div",{className:"mb-3 flex min-h-11 items-center justify-between gap-4",children:[e.jsx(ts,{className:"min-w-0 text-lg font-semibold text-oai-black dark:text-oai-white",children:n}),e.jsx(ls,{disabled:g,"aria-label":a("shared.dialog.close"),className:"inline-flex size-11 min-h-11 min-w-11 shrink-0 items-center justify-center rounded-md border-0 bg-transparent p-0 text-oai-gray-500 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 disabled:cursor-wait disabled:opacity-40 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-oai-white",children:e.jsx(Yt,{size:18,"aria-hidden":!0})})]}),e.jsx("div",{"data-settings-panel":"cloud",className:"min-w-0",children:d})]})})]})]})}function he(t){return t.replace(/[\t\n\r\f\v -]/g,"").toUpperCase()}function dn({account:t,auth:s,refresh:n,compact:r=!1,panelContainer:i=null,layout:c="default",dialogOpen:g,onDialogOpenChange:l}){const d=c==="settings-row",[p,h]=o.useState(!1),m=d&&typeof g=="boolean"?g:p,[j,w]=o.useState(""),[x,_]=o.useState(!1),[b,u]=o.useState(null),[y,k]=o.useState(null),[f,N]=o.useState(!1),E=o.useId(),v=o.useRef(null),C=o.useRef(null),O=o.useRef(!1),S=o.useRef(!1),P=o.useRef(0),M=`${Oe()}.${t?.environment||"unknown"}.${s?.signedIn?s.user?.id:""}`,G=o.useRef(M);G.current=M,o.useEffect(()=>(S.current=!0,P.current+=1,C.current=null,O.current=!1,h(!1),w(""),_(!1),u(null),k(null),N(!1),()=>{S.current=!1,P.current+=1}),[M]);const J=t?.membership?.status==="self_hosted"||t?.membership?.hosting_mode==="self_hosted",V=t?.gift_redemption_available===!0,te=d?t?.gifts||[]:[];if(!s?.signedIn||J||!V&&!te.length)return null;const $=t.redemption_restriction,F=T=>{!T&&O.current||(typeof g!="boolean"&&h(T),l?.(T))},K=async(T,ie)=>{const re=await n();ie()&&N(!!re?.gifts?.some(W=>W.id===T?.id))},q=async T=>{if(O.current||T&&(!V||!j.trim()))return;if(T&&$&&$!=="gift_checkout_pending"){u(new Ne($));return}O.current=!0;const ie=++P.current,re=M,W=()=>S.current&&P.current===ie&&G.current===re;_(!0),u(null);try{if(T){const ae=j.trim();(!C.current||he(C.current.code)!==he(ae))&&(C.current={code:ae,request_id:crypto.randomUUID()});const oe=await ce("redeem-gift",{auth:async()=>{const de=await pt(s.getAccessToken);if(!W())throw new Ne("authentication_required",401);return de},body:C.current});if(!W())return;if(!oe?.gift?.id)throw new Ne("billing_operation_failed");k(oe),N(!1),w(""),C.current=null,await K(oe.gift,W)}else await K(y?.gift,W)}catch(ae){W()&&u(ae)}finally{W()&&(O.current=!1,_(!1))}};let L=null;return(d||m)&&(L=e.jsxs("div",{id:`${E}-panel`,className:d?"space-y-3":r?"w-full space-y-3 rounded-lg bg-oai-gray-50 p-4 dark:bg-oai-gray-950/50":"mt-3 space-y-3",children:[V?e.jsxs(e.Fragment,{children:[e.jsx("p",{id:`${E}-detail`,className:d?"sr-only":"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.gift.detail")}),y?e.jsxs("div",{role:"status",className:"space-y-2 text-sm leading-6",children:[d&&f?null:e.jsx("p",{children:a(f?y.already_redeemed?"cloud.gift.already_redeemed":"cloud.gift.redeemed":"cloud.gift.refresh_needed")}),y.gift?d&&f?e.jsxs("div",{className:"py-1",children:[e.jsx("p",{className:"text-base font-medium text-oai-black dark:text-oai-white",children:a("cloud.gift.duration",{days:y.gift.duration_days})}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.history.term",{start:H(y.gift.starts_at),end:H(y.gift.ends_at)})})]}):e.jsx("p",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.gift.term",{days:y.gift.duration_days,start:H(y.gift.starts_at),end:H(y.gift.ends_at)})}):null,f?e.jsxs("div",{className:"flex flex-wrap justify-end gap-2 pt-3",children:[e.jsx(A,{type:"button",variant:"secondary",size:"sm",onClick:()=>{k(null),N(!1),requestAnimationFrame(()=>v.current?.focus())},children:a("cloud.gift.redeem_another")}),d?e.jsx(A,{type:"button",size:"sm",className:"min-w-20",disabled:x,onClick:()=>F(!1),children:a("cloud.gift.done")}):null]}):e.jsx(A,{type:"button",variant:"secondary",disabled:x,onClick:()=>{q(!1)},children:a("cloud.action.refresh_membership")})]}):e.jsxs("form",{onSubmit:T=>{T.preventDefault(),q(!0)},"aria-busy":x,children:[e.jsx("label",{htmlFor:E,className:d?"sr-only":"text-sm font-medium",children:a("cloud.gift.code_label")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:E,ref:v,value:j,disabled:x,maxLength:128,autoComplete:"off",spellCheck:!1,autoCapitalize:"characters","data-ph-no-capture":"true","aria-describedby":`${E}-detail${b?` ${E}-error`:""}`,"aria-invalid":!!b,onChange:T=>{he(T.target.value)!==he(j)&&(C.current=null),w(T.target.value),u(null)},className:"min-h-10 min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-transparent px-3 font-mono text-sm outline-none focus:border-oai-brand focus:ring-2 focus:ring-inset focus:ring-oai-brand/30 dark:border-oai-gray-700"}),e.jsx(A,{type:"submit",variant:"secondary",disabled:x||!j.trim(),children:a(x?"cloud.gift.redeeming":"cloud.gift.confirm")})]})]}),b?e.jsx("div",{id:`${E}-error`,children:["gift_checkout_pending","gift_requires_renewal_cancel"].includes(b.code)?e.jsx("p",{role:"alert",className:"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:Zt(b,"gift")}):e.jsx(ee,{error:b,context:"gift"})}):null]}):null,te.length&&!y?e.jsx("ul",{"aria-label":a("cloud.gift.history_title"),className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:te.map(T=>e.jsxs("li",{className:"py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[e.jsx("span",{children:a("cloud.gift.duration",{days:T.duration_days})}),e.jsx("span",{children:a(["active","pending","expired","revoked"].includes(T.state)?`cloud.gift.state_${T.state}`:"cloud.status.unknown")})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.history.term",{start:H(T.starts_at),end:H(T.ends_at)})})]},T.id))}):null]})),d?e.jsx($e,{open:m,onOpenChange:F,title:a(y&&f?"cloud.gift.redeemed":V?"cloud.gift.redeem_action":"cloud.gift.history_title"),triggerLabel:a(V?"cloud.gift.redeem_action":"cloud.gift.history_title"),icon:Te,preventClose:x,initialFocus:V&&!y?v:void 0,children:L}):e.jsxs("div",{className:d?void 0:r?"contents":"mt-4",children:[e.jsxs(A,{type:"button",variant:"ghost",size:r||d?"sm":"md",className:d?"!h-11 !w-full !justify-start !px-0 !text-oai-black dark:!text-oai-white hover:!bg-oai-gray-100 dark:hover:!bg-oai-gray-800 active:!scale-100":r?"!h-10 !px-0":void 0,"aria-expanded":m,"aria-controls":d||m?`${E}-panel`:void 0,onClick:()=>h(T=>!T),disabled:x,children:[r||d?e.jsx(Te,{size:16,className:`${d?"mr-3":"mr-2"} shrink-0`,"aria-hidden":!0}):null,a(V?"cloud.gift.redeem_action":"cloud.gift.history_title"),d?e.jsx(Re,{size:16,className:`ml-auto shrink-0 transition-transform motion-reduce:transition-none ${m?"rotate-180":""}`,"aria-hidden":!0}):null]}),!d&&i&&L?gt.createPortal(L,i):L]})}const be=["total_tokens","billable_total_tokens","input_tokens","output_tokens","cached_input_tokens","cache_creation_input_tokens","reasoning_output_tokens","conversation_count","total_cost_usd"];class U extends Error{constructor(s,n=0){super(s),this.code=s,this.status=n}code;status}function ge(t){return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(Date.parse(t+"T00:00:00Z"))&&new Date(t+"T00:00:00Z").toISOString().slice(0,10)===t}function un(t,s){if(!ea(t))throw new U("export_auth_required",401);try{const n=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=JSON.parse(atob(n.padEnd(Math.ceil(n.length/4)*4,"=")));if((r.sub||r.user_id)!==s||r.role!=="authenticated"||!Number.isFinite(r.exp)||r.exp*1e3<=Date.now())throw Error()}catch{throw new U("export_auth_required",401)}}function it(t){if(typeof t?.membership?.can_read_cloud!="boolean")throw new U("export_invalid_data",503);if(!t.membership.can_read_cloud)throw new U("export_access_denied",402);const s=t.membership;return JSON.stringify([t.environment,s.phase,s.status,s.hosting_mode,s.expires_at,s.trial_ends_at,s.transition_ends_at,s.read_only_until])}async function mn({userId:t,auth:s,from:n,to:r,deviceId:i=null,signal:c,assertCurrent:g=()=>{},fetchImpl:l=fetch}){if(!ge(n)||!ge(r)||n>r)throw new U("export_invalid_dates",400);if(typeof s!="function")throw new U("export_auth_required",401);if(!t||i&&!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(i))throw new U("export_invalid_scope",400);const d=Oe(),p=Ve();if(!d)throw new U("export_instance_changed",409);const h=()=>{if(c?.aborted)throw new U("export_cancelled",409);if(g(),d!==Oe()||p!==Ve())throw new U("export_instance_changed",409)};async function m(u,y){h();const k=await pt(s);h(),un(k||"",t);const f=new URL(Xt(d,u));for(const[C,O]of Object.entries(y))f.searchParams.set(C,O);const N=new AbortController,E=()=>N.abort();c?.addEventListener("abort",E,{once:!0});const v=setTimeout(E,25e3);try{const C=await Qt(f.toString(),{method:"GET",cache:"no-store",redirect:"error",signal:N.signal,headers:{Accept:"application/json",Authorization:"Bearer "+k,...p?{apikey:p}:{}}},l);if(h(),!C.ok)throw new U(C.status===401?"export_auth_required":C.status===402||C.status===403?"export_access_denied":"export_failed",C.status);const O=await C.json();return h(),O}finally{clearTimeout(v),c?.removeEventListener("abort",E)}}const j=it(await m("tokentracker-billing",{action:"account"})),w={from:n,to:r,tz_offset_minutes:"0",...i?{device_id:i}:{}};if(await m("tokentracker-account-daily",w),it(await m("tokentracker-billing",{action:"account"}))!==j)throw new U("export_access_changed",409);const x=await m("tokentracker-account-daily",w);if(!ge(x?.from)||!ge(x?.to)||x.from<n||x.to>r||x.from>x.to||!Array.isArray(x.data)||x.data.length>1096)throw new U("export_invalid_data",503);const _=new Set,b=x.data.map(u=>{if(!ge(u?.day)||u.day<x.from||u.day>x.to||_.has(u.day))throw new U("export_invalid_data",503);_.add(u.day);const y={day:u.day};for(const k of be){const f=u[k];if(typeof f!="number"||!Number.isFinite(f)||f<0||k!=="total_cost_usd"&&!Number.isSafeInteger(f))throw new U("export_invalid_data",503);y[k==="total_cost_usd"?"estimated_cost_usd":k]=f}return y}).sort((u,y)=>u.day.localeCompare(y.day));return h(),{schema:"tokentracker.cloud-usage.v1",metadata:{source:"cloud",backend_origin:new URL(d).origin,exported_at:new Date().toISOString(),timezone:"UTC",requested_range:{from:n,to:r},effective_range:{from:x.from,to:x.to},device_scope:i?"selected":"all",aggregation:"daily_all_providers",cost_currency:"USD",cost_basis:"estimated",row_count:b.length},rows:b}}function gn(t){const s=String(t??"");return'"'+(/^[\s]*[=+\-@]/.test(s)?"'"+s:s).replace(/"/g,'""')+'"'}function pn(t,s){if(s==="json")return JSON.stringify(t,null,2)+`
|
|
3
|
-
`;const n=t.metadata,r=["row_type","source","backend_origin","exported_at","timezone","cost_currency","cost_basis","requested_from","requested_to","effective_from","effective_to","device_scope","aggregation","row_count","day",...be.map(c=>c==="total_cost_usd"?"estimated_cost_usd":c)],i=[n.source,n.backend_origin,n.exported_at,n.timezone,n.cost_currency,n.cost_basis,n.requested_range.from,n.requested_range.to,n.effective_range.from,n.effective_range.to,n.device_scope,n.aggregation,n.row_count];return[r,["metadata",...i,"",...be.map(()=>"")],...t.rows.map(c=>["usage",...i,c.day,...be.map(g=>c[g==="total_cost_usd"?"estimated_cost_usd":g])])].map(c=>c.map(gn).join(",")).join(`\r
|
|
4
|
-
`)+`\r
|
|
5
|
-
`}async function hn(t,s,{signal:n,assertCurrent:r=()=>{}}={}){const i=pn(t,s),c=`tokentracker-cloud-usage-${t.metadata.effective_range.from}-${t.metadata.effective_range.to}.${s}`,g=()=>{if(n?.aborted)throw new U("export_cancelled",409);r()};g();const l=await Jt({filename:c,content:i,format:s,signal:n});if(g(),l?.saved===!0)return;if(l!==null)throw new U("export_failed",503);const d=new Blob([i],{type:s==="csv"?"text/csv;charset=utf-8":"application/json;charset=utf-8"}),p=URL.createObjectURL(d);try{const h=document.createElement("a");h.href=p,h.download=c,document.body.appendChild(h);try{h.click()}finally{h.remove()}}finally{setTimeout(()=>URL.revokeObjectURL(p),1e3)}}function fn(t){return t?.status===401?a("cloud.export.error_auth"):t?.status===402||t?.status===403?a("cloud.export.error_access"):t?.code==="export_invalid_dates"?a("cloud.export.error_dates"):t?.status===409?a("cloud.export.error_changed"):a("cloud.export.error_failed")}function xn({from:t,to:s,deviceId:n=null,auth:r,compact:i=!1,panelContainer:c=null,layout:g="default",dialogOpen:l,onDialogOpenChange:d}){const p=g==="settings-row",h=lt(),m=r||h,j=m?.signedIn?m.user?.id:null,w=new Date().toISOString().slice(0,10),x=new Date(Date.now()-29*864e5).toISOString().slice(0,10),[_,b]=o.useState(t||x),[u,y]=o.useState(s||w),[k,f]=o.useState(!1),N=p&&typeof l=="boolean"?l:k,[E,v]=o.useState(!1),[C,O]=o.useState(null),[S,P]=o.useState(null),[M,G]=o.useState(!1),[J,V]=o.useState(2),te=o.useId(),$=o.useRef(null),F=o.useRef(0),K=o.useRef(null),q=o.useRef(!1),L=o.useRef(!1),T=o.useRef(N);T.current=N;const ie=o.useRef(N);if($.current={userId:j,client:m?.client,start:_,end:u,deviceId:n,from:t,to:s},o.useEffect(()=>{L.current=!0;const I=()=>{++F.current,K.current?.abort(),q.current=!1,v(!1),P(null),O(null),G(!1)};return window.addEventListener(qe,I),()=>{L.current=!1,++F.current,K.current?.abort(),window.removeEventListener(qe,I)}},[]),o.useEffect(()=>{++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),G(!1),t&&b(t),s&&y(s)},[j,m?.client,t,s,n]),o.useEffect(()=>{p&&ie.current&&!N&&re(),ie.current=N},[N,p]),o.useEffect(()=>{const I=window.matchMedia?.("(max-width: 639px)");if(!I)return;const D=()=>V(I.matches?1:2);return D(),I.addEventListener("change",D),()=>I.removeEventListener("change",D)},[]),!j||m?.enabled===!1)return null;function re(){++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),G(!1)}function W(I){I||re(),typeof l!="boolean"&&f(I),d?.(I)}function ae(I,D){++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),I(D)}async function oe(I){if(q.current)return;q.current=!0;const D=$.current,ke=++F.current,_e=new AbortController;K.current=_e,v(!0),O(null),P(null);const pe=()=>{const X=$.current;if(!L.current||ke!==F.current||p&&!T.current||!X||Object.keys(D).some(Q=>D[Q]!==X[Q])||D.client&&!ta(D.client))throw new U("export_cancelled",409)};try{const X=await mn({userId:D.userId,auth:m.getAccessToken,from:D.start,to:D.end,deviceId:D.deviceId,signal:_e.signal,assertCurrent:pe});pe(),await hn(X,I,{signal:_e.signal,assertCurrent:pe}),pe();const Q=X.metadata.effective_range,Fe=X.rows.length?a("cloud.export.success",{count:X.rows.length,from:Q.from,to:Q.to}):a("cloud.export.empty");P(Q.from!==D.start||Q.to!==D.end?`${Fe} ${a("cloud.export.truncated",{from:Q.from,to:Q.to})}`:Fe)}catch(X){L.current&&ke===F.current&&O(fn(X))}finally{ke===F.current&&(q.current=!1,L.current&&v(!1))}}const de="hover:!text-oai-black dark:hover:!text-oai-white hover:!bg-oai-gray-100 dark:hover:!bg-oai-gray-800 focus:!ring-oai-gray-500/40";let ue=null;return(p||N)&&(ue=e.jsxs("div",{id:te,className:p?void 0:i?"w-full rounded-lg bg-oai-gray-50 p-4 dark:bg-oai-gray-950/50":"mt-2 border-l-2 border-oai-gray-200 pl-3 dark:border-oai-gray-700","aria-busy":E,children:[p?null:e.jsx("p",{className:"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.export.description")}),e.jsxs("div",{className:p?"space-y-4":"mt-3 flex flex-wrap items-end gap-3",children:[p?e.jsxs(us,{open:M,onOpenChange:G,children:[e.jsxs(ms,{disabled:E,"aria-label":a("trend.zoom.pick_range"),className:"inline-flex h-10 min-h-10 w-full items-center gap-2 rounded-md border border-oai-gray-300 bg-transparent px-3 text-sm text-oai-black transition-colors hover:bg-oai-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-oai-gray-500 disabled:opacity-50 dark:border-oai-gray-700 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(ds,{size:16,className:"shrink-0 text-oai-gray-500","aria-hidden":!0}),e.jsxs("span",{className:"flex-1 text-left tabular-nums",children:[_," → ",u]}),e.jsx(Re,{size:14,className:"shrink-0 text-oai-gray-500","aria-hidden":!0})]}),e.jsx(gs,{children:e.jsx(ps,{sideOffset:8,side:"bottom",align:"start",className:"z-[110]",children:e.jsx(hs,{className:"max-w-[calc(100vw-2rem)] rounded-xl border border-oai-gray-200 bg-white shadow-lg outline-none dark:border-oai-gray-700 dark:bg-oai-gray-900",children:e.jsx(cs,{from:_,to:u,numberOfMonths:J,onApply:(I,D)=>{ae(b,I),y(D),G(!1)},onCancel:()=>G(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-700 dark:text-oai-gray-200",children:[a("cloud.export.from"),e.jsx("input",{type:"date",value:_,onChange:I=>ae(b,I.target.value),className:`${p?"min-h-10 min-w-0 w-full ":""}mt-1 block rounded-md border border-oai-gray-300 bg-white px-2 py-1.5 text-sm text-oai-black focus:outline-none focus:ring-2 focus:ring-inset focus:ring-oai-gray-500/40 dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-white`})]}),e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-700 dark:text-oai-gray-200",children:[a("cloud.export.to"),e.jsx("input",{type:"date",value:u,onChange:I=>ae(y,I.target.value),className:`${p?"min-h-10 min-w-0 w-full ":""}mt-1 block rounded-md border border-oai-gray-300 bg-white px-2 py-1.5 text-sm text-oai-black focus:outline-none focus:ring-2 focus:ring-inset focus:ring-oai-gray-500/40 dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-white`})]})]}),e.jsxs("div",{className:p?"flex justify-end gap-2":"flex gap-2",children:[e.jsx(A,{type:"button",variant:p?"secondary":"ghost",size:"sm",className:`${de} ${p?"!min-h-8 !h-8":""}`,disabled:E,onClick:()=>oe("csv"),children:a("cloud.export.csv")}),e.jsx(A,{type:"button",variant:p?"secondary":"ghost",size:"sm",className:`${de} ${p?"!min-h-8 !h-8":""}`,disabled:E,onClick:()=>oe("json"),children:a("cloud.export.json")})]})]}),E?e.jsx("p",{role:"status",className:"mt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.export.busy")}):null,C?e.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-700 dark:text-red-300",children:C}):null,S?e.jsx("p",{role:"status",className:"mt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:S}):null]})),p?e.jsx($e,{open:N,onOpenChange:W,title:a("cloud.export.open"),icon:Ie,children:ue}):e.jsxs("section",{className:i&&!p?"tt-cloud-theme contents":"tt-cloud-theme","aria-label":a("cloud.export.open"),children:[e.jsxs(A,{type:"button",variant:"ghost",size:"sm",className:`${de} ${p?"!h-11 !w-full !justify-start !px-0 !text-oai-black dark:!text-oai-white active:!scale-100":i?"!h-10 !px-0":""}`,"aria-expanded":N,"aria-controls":te,onClick:()=>f(I=>!I),children:[e.jsx(Ie,{className:`${p?"mr-3":"mr-2"} h-4 w-4 shrink-0`,"aria-hidden":"true"}),a("cloud.export.open"),p?e.jsx(Re,{size:16,className:`ml-auto shrink-0 transition-transform motion-reduce:transition-none ${N?"rotate-180":""}`,"aria-hidden":!0}):null]}),!p&&c&&ue?gt.createPortal(ue,c):ue]})}function bn({text:t,label:s}){const[n,r]=o.useState(!1);return e.jsxs(bs,{open:n,onOpenChange:r,children:[e.jsx(ys,{delay:0,closeOnClick:!1,"aria-label":s,onClick:()=>r(!0),className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:bg-oai-gray-100 hover:text-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-500/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",children:e.jsx(jt,{size:14,"aria-hidden":!0})}),e.jsx(vs,{children:e.jsx(js,{side:"bottom",sideOffset:6,className:"z-[110]",children:e.jsx(ks,{role:"tooltip",className:"max-w-[min(320px,calc(100vw-2rem))] rounded-lg border border-oai-gray-200 bg-white px-3 py-2 text-xs leading-5 text-oai-gray-600 shadow-lg dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-300",children:t})})})]})}function yn(t){return typeof t!="string"||!t.trim()?a("cloud.devices.platform_unknown"):/^(mac|darwin)/i.test(t)?a("leaderboard.community.modal.platform.darwin"):/^win/i.test(t)?a("leaderboard.community.modal.platform.win32"):/^linux/i.test(t)?a("leaderboard.community.modal.platform.linux"):t}function vn(t,s){if(!t)return null;const n=t.status==="active"&&t.access_source==="gift";if(s&&Number.isFinite(Date.parse(s))){const r=t.status==="transition"?"cloud.membership.transition_until":t.status==="trial"?"cloud.membership.trial_until":t.status==="active"?n?"cloud.membership.gift_until":"cloud.membership.active_until":t.status==="expired"&&Date.parse(s)<=Date.now()?"cloud.membership.expired_on":null;if(r)return a(r,{date:H(s)})}return n?a("cloud.gift.membership_label"):Ae(t.status)}function jn({auth:t,machineLimit:s,accountRevision:n,selfHosted:r=!1}){const[i,c]=o.useState(null),[g,l]=o.useState(null),[d,p]=o.useState(null),[h,m]=o.useState(!1),[j,w]=o.useState(null),x=o.useRef(!1),_=o.useRef(0),b=o.useRef(!0),u=t?.user?.id,y=t?.getAccessToken,k=o.useCallback(async()=>{const S=++_.current;try{let P;if(dt())try{const G=await ia(),J=await fetch("/functions/tokentracker-machine-id",{headers:G});J.ok&&(P=(await J.json())?.machineId)}catch{}const M=await ce("devices",{auth:y,params:P?{current_machine_id:P}:{}});S===_.current&&(c(M),l(null))}catch(P){S===_.current&&l({...P,code:"billing_devices_unavailable"})}},[y,u]);o.useEffect(()=>(b.current=!0,k(),()=>{b.current=!1,_.current+=1}),[k,n]);const f=async S=>{if(!x.current){x.current=!0,m(!0),l(null),w(null);try{if(await ce("remove-device",{auth:y,body:{machine_id:S}}),!b.current)return;i?.machines?.find(P=>P.machine_id===S)?.is_current&&We(),p(null),await k()}catch(P){b.current&&l(P)}finally{x.current=!1,m(!1)}}},N=async S=>{if(!x.current){x.current=!0,m(!0),l(null),w(null);try{if(await ce("resume-device",{auth:y,body:{machine_id:S.machine_id}}),!b.current)return;S.is_current&&We(),w(a("cloud.devices.resumed")),await k()}catch(P){b.current&&l(P)}finally{x.current=!1,m(!1)}}},E=i?.machines||[],v=i?.machine_count??E.filter(S=>S.status!=="paused").length,C=i?.machine_limit??s,O=C==null||v<C;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("h3",{className:"text-sm font-semibold",children:a("cloud.devices.title")}),e.jsx(bn,{label:a("cloud.devices.detail"),text:a("cloud.devices.detail")})]}),e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:i?C==null?a(r?"cloud.devices.unlimited_self_hosted":"cloud.devices.unlimited",{count:v}):a("cloud.devices.count",{count:v,limit:C}):g?a("cloud.devices.count_unknown"):a("cloud.catalog.loading")})]}),i?.over_machine_limit||C!=null&&C<v?e.jsx("div",{className:"mb-4",children:e.jsx(ee,{children:a("cloud.devices.over_limit")})}):null,g?e.jsx(ee,{error:g,onRetry:k,context:"account"}):null,j?e.jsx("div",{className:"mb-3",children:e.jsx(ee,{children:j})}):null,!g&&i&&E.length===0?e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.devices.empty")}):null,E.length!==0?e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:E.map(S=>e.jsxs("li",{className:"py-1.5",children:[e.jsxs("div",{className:"grid grid-cols-[17px_minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(Ue,{size:17,className:"col-start-1 row-start-1 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{title:S.name||a("cloud.devices.unnamed"),className:"col-start-2 row-start-1 min-w-0 truncate text-sm font-medium",children:S.name||a("cloud.devices.unnamed")}),e.jsxs("div",{className:"col-span-2 col-start-2 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 sm:col-span-1 sm:col-start-2",children:[e.jsx("span",{children:yn(S.platform)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S.last_seen_at?a("cloud.devices.last_seen",{date:ra(S.last_seen_at)}):a("cloud.devices.last_seen_unknown")}),S.is_current?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.devices.current")})]}):null,S.status==="paused"?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.devices.paused")})]}):null]}),S.status==="paused"&&!O?e.jsx("p",{className:"col-start-2 row-start-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.devices.no_slot")}):null,e.jsxs(A,{variant:"ghost",size:"sm",className:"col-start-3 row-start-1 !min-h-10 !px-2 sm:row-span-2","aria-expanded":S.status!=="paused"?d===S.machine_id:void 0,"aria-controls":d===S.machine_id?`cloud-machine-confirm-${S.machine_id}`:void 0,onClick:()=>S.status==="paused"?N(S):p(P=>P===S.machine_id?null:S.machine_id),disabled:h||S.status==="paused"&&!O,children:[S.status==="paused"?e.jsx(fs,{size:14,className:"mr-1.5 shrink-0","aria-hidden":!0}):e.jsx(xs,{size:14,className:"mr-1.5 shrink-0","aria-hidden":!0}),S.status==="paused"?a("cloud.devices.resume"):a("cloud.devices.remove")]})]}),d===S.machine_id?e.jsxs("div",{id:`cloud-machine-confirm-${S.machine_id}`,className:"mt-3 rounded-lg bg-oai-gray-50 p-3 dark:bg-oai-gray-800",children:[e.jsx("p",{className:"text-xs leading-5",children:a("cloud.devices.remove_detail")}),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(A,{variant:"secondary",onClick:()=>f(S.machine_id),disabled:h,children:a("cloud.devices.confirm_remove")}),e.jsx(A,{variant:"ghost",onClick:()=>p(null),disabled:h,children:a("cloud.action.keep")})]})]}):null]},S.machine_id))}):null]})}function kn({recent:t,pendingOrders:s,conflictOrders:n,userId:r,payments:i=[],footerActions:c}){const g=ht(),[l,d]=o.useState(t?.order_id&&Ce.test(t.order_id)?t.order_id:""),[p,h]=o.useState(!1),[m,j]=o.useState(!1),w=o.useId(),x=o.useRef(null);o.useEffect(()=>{m&&x.current?.focus()},[m]);const _=new Set([...i.map(u=>u.order_id).filter(u=>typeof u=="string"),...(s||[]).filter(u=>u.status==="paid"||["paid","partially_refunded","refunded"].includes(u.payment_state)).map(u=>u.id)].map(u=>u.toLowerCase())),b=[...n||[],...(s||[]).filter(u=>u.retry_payment_conflict_at||!_.has(u.id.toLowerCase()))].filter((u,y,k)=>k.findIndex(f=>f.id===u.id)===y);return e.jsxs("div",{className:"mt-2 space-y-3",children:[t?.request_id&&!t.order_id?e.jsx(ye,{to:`/billing/checkout?sku=${encodeURIComponent(t.sku)}`,className:"mt-3 inline-flex min-h-10 items-center text-sm text-oai-brand underline underline-offset-4",children:a("cloud.action.resume_purchase")}):null,b.length||i.length?e.jsxs("div",{className:"sm:grid sm:grid-cols-[minmax(0,1fr)_auto_minmax(7rem,auto)] sm:gap-x-4",children:[e.jsxs("div",{"aria-hidden":!0,className:"hidden gap-x-4 pb-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 sm:col-span-3 sm:grid sm:grid-cols-subgrid",children:[e.jsx("span",{children:a("cloud.history.date")}),e.jsx("span",{className:"text-right",children:a("cloud.history.amount")}),e.jsx("span",{className:"text-right",children:a("cloud.history.status")})]}),e.jsxs("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800 sm:col-span-3 sm:grid sm:grid-cols-subgrid",children:[b.map(u=>{const y=typeof u.created_at=="string"&&Number.isFinite(Date.parse(u.created_at))?H(u.created_at):null;let k=null;Number.isInteger(u.amount_cents)&&u.amount_cents>=0&&["USD","CNY"].includes(u.currency)&&(k=Le(u.amount_cents,u.currency));const f=a(u.retry_payment_conflict_at?"cloud.action.review_duplicate_payment":"cloud.history.pending");return e.jsxs("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 py-3 sm:col-span-3 sm:grid-cols-subgrid",children:[e.jsx("p",{className:"col-start-1 row-start-1 text-sm tabular-nums",children:y||f}),e.jsx("p",{className:"col-start-2 row-start-1 text-right text-sm font-medium tabular-nums",children:k}),u.provider||y?e.jsxs("div",{className:"col-start-1 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[u.provider?e.jsx("span",{children:ft(u.provider)}):null,y?e.jsxs(e.Fragment,{children:[u.provider?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,e.jsx("span",{children:f})]}):null]}):null,e.jsx(ye,{to:`/billing/checkout?order=${encodeURIComponent(u.id)}`,onClick:N=>{u.retry_payment_conflict_at||N.button!==0||N.metaKey||N.ctrlKey||N.shiftKey||N.altKey||!Ce.test(u.id)||(N.preventDefault(),g(Ke({orderId:u.id,userId:r})))},className:"col-start-2 row-start-2 inline-flex min-h-10 items-center justify-end rounded-sm text-right text-sm underline-offset-4 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 sm:col-start-3 sm:row-span-2 sm:row-start-1 sm:self-start sm:items-start",children:e.jsx("span",{children:u.retry_payment_conflict_at?a("cloud.action.review_duplicate_payment"):a("cloud.action.resume_order")})})]},u.id)}),e.jsx(_n,{payments:i})]})]}):e.jsx(e.Fragment,{children:(!t?.request_id||t.order_id)&&e.jsx("p",{className:"py-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.history.empty")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1",children:[e.jsx(A,{variant:"ghost",size:"sm",className:"!h-10 !px-0","aria-expanded":m,"aria-controls":`${w}-panel`,onClick:()=>j(u=>!u),children:a("cloud.restore.title")}),c]}),m?e.jsxs("div",{id:`${w}-panel`,className:"mt-2",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.restore.detail")}),e.jsxs("form",{className:"mt-4",onSubmit:u=>{if(u.preventDefault(),!Ce.test(l.trim())){h(!0);return}const y=l.trim(),k=b.some(f=>f.id.toLowerCase()===y.toLowerCase()&&f.retry_payment_conflict_at);g(k?`/billing/checkout?order=${encodeURIComponent(y)}`:Ke({orderId:y,userId:r}))},children:[e.jsx("label",{htmlFor:`${w}-input`,className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.checkout.order_id")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:`${w}-input`,ref:x,value:l,onChange:u=>{d(u.target.value),h(!1)},placeholder:a("cloud.restore.placeholder"),className:"min-h-10 min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-transparent px-3 text-sm outline-none focus:border-oai-brand focus:ring-2 focus:ring-inset focus:ring-oai-brand/30 dark:border-oai-gray-700","aria-invalid":p,"aria-describedby":p?`${w}-error`:void 0}),e.jsx(A,{type:"submit",variant:"secondary",children:a("cloud.action.restore")})]}),p?e.jsx("p",{id:`${w}-error`,role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:a("cloud.restore.invalid")}):null]})]}):null]})]})}function _n({payments:t}){return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 py-3 sm:col-span-3 sm:grid-cols-subgrid",children:[e.jsx("p",{className:"col-start-1 row-start-1 text-sm tabular-nums",children:H(s.paid_at)}),e.jsx("p",{className:"col-start-2 row-start-1 text-right text-sm font-medium tabular-nums",children:Le(s.amount_cents,s.currency)}),e.jsxs("div",{className:"col-start-1 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:ft(s.provider)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.history.term",{start:H(s.starts_at),end:H(s.ends_at)})})]}),e.jsx("p",{className:`col-start-2 row-start-2 text-right text-sm font-medium sm:col-start-3 sm:row-span-1 sm:row-start-1 sm:self-start ${s.refunded_cents>0?"text-amber-700 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-300"}`,children:s.refunded_cents>0?a("cloud.history.refunded",{amount:Le(s.refunded_cents,s.currency)}):a("cloud.history.paid")})]},s.id))})}function wn({showTitle:t=!0,heading:s,syncControl:n,active:r=!0}){const i=aa();return e.jsx(Nn,{showTitle:t,heading:s,syncControl:n,active:r,...i},i.auth?.signedIn?i.auth.user?.id:"signed-out")}function Nn({account:t,auth:s,loading:n,error:r,refresh:i,showTitle:c,heading:g,syncControl:l,active:d=!0}){const{openLoginModal:p}=ut(),[h,m]=o.useState(null),[j,w]=o.useState(null),[x,_]=o.useState(!1),[b,u]=o.useState(null),y=o.useRef(!1),k=o.useRef(!0);o.useEffect(()=>{d||m(null)},[d]),o.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const f=t?.membership,N=f?.status==="self_hosted"||f?.hosting_mode==="self_hosted",E=[...t?.conflict_orders||[],...t?.pending_orders||[]].some(L=>L.retry_payment_conflict_at),v=!N&&t?.subscriptions?.find(L=>["active","trialing","past_due","paused","canceling"].includes(L.status)),C=!N&&(v?v.provider==="waffo":t?.payments?.some(L=>L.provider==="waffo")),O=v&&!v.cancel_at_period_end&&v.status!=="canceling",S=O&&v.status!=="paused",P=v?.next_billed_at,M=P&&Number.isFinite(Date.parse(P));o.useEffect(()=>{b&&t&&!O&&(u(null),w(null))},[t,b,O]);const G=N?null:f?.status==="trial"?f.trial_ends_at:f?.status==="transition"?f.transition_ends_at:f?.expires_at,J=async L=>{if(!y.current){y.current=!0,_(!0),w(null);try{await L()}catch(T){k.current&&w(T)}finally{y.current=!1,_(!1)}}},V=()=>J(async()=>{const L=await ce("portal",{auth:s.getAccessToken,body:v?{subscription_id:v.provider_subscription_id}:{}});k.current&&await Wa(L.url||L.portal_url)}),te=()=>J(async()=>{await ce("cancel",{auth:s.getAccessToken,body:{subscription_id:b}}),k.current&&(u(null),await i())}),$=vn(f,G),F=f?.status==="active"&&f?.access_source==="gift",K=C&&!v||f?.can_read_cloud||!N&&t?.gift_redemption_available===!0;if(!s?.signedIn)return e.jsx("div",{className:"space-y-4",children:e.jsx(Z,{title:g||(c?a("cloud.membership.title"):a("settings.section.cloud")),children:e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.membership.signed_out")}),e.jsx(A,{variant:"primary",size:"sm",onClick:()=>p({subtitle:a("cloud.membership.signed_out")}),children:a("cloud.action.sign_in_continue")})]})})});const q=g||(c?a("cloud.membership.title"):a("settings.section.cloud"));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{"aria-label":a("cloud.membership.title"),className:"tt-cloud-theme space-y-3",children:[t?.environment==="sandbox"?e.jsx(ee,{children:a("cloud.catalog.sandbox")}):null,E?e.jsx(sa,{showBillingLink:!1}):null,e.jsxs(Z,{title:q,action:e.jsx(A,{onClick:i,variant:"ghost",size:"sm",className:"!h-8 !w-8 shrink-0 !p-0 text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white",disabled:n,"aria-label":a("cloud.action.refresh_membership"),children:e.jsx(De,{size:14,className:n?"motion-safe:animate-spin":void 0,"aria-hidden":!0})}),children:[e.jsx("div",{className:"pt-0.5 pb-2.5",children:F?e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:e.jsx(Te,{className:"h-[30px] w-[30px]","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-white",children:a("cloud.gift.membership_label")}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-oai-gray-200 bg-oai-gray-50 px-2 py-0.5 text-[11px] font-medium text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400"}),a("cloud.gift.state_active")]})]}),$&&$!==a("cloud.gift.membership_label")?e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:$}):null]})]}):e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:e.jsx(fe,{className:"h-[30px] w-[30px]","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-white",children:Ae(f?.status)}),f?.status==="active"?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-oai-gray-200 bg-oai-gray-50 px-2 py-0.5 text-[11px] font-medium text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400"}),a("cloud.gift.state_active")]}):null]}),$&&$!==Ae(f?.status)?e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:$}):null]})]})}),f?.status==="expired"?e.jsx("p",{className:"py-2.5 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:f.can_read_cloud?a("cloud.membership.read_only",{date:H(f.read_only_until)}):a("cloud.membership.expired_detail")}):null,f?e.jsx(na,{userId:s.user?.id,membership:f,subscriptions:t?.subscriptions,className:"py-2.5"}):null,!f&&n?e.jsx("p",{role:"status",className:"py-2.5 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.catalog.loading")}):null,v?e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 py-2.5",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:v.status==="paused"?a("cloud.membership.renewal_paused"):v.status==="past_due"?a("cloud.membership.payment_due"):S?M?a("cloud.membership.renews",{date:H(P)}):a("cloud.membership.renewal_unknown"):a("cloud.membership.renewal_off")}),O?e.jsx(A,{"aria-expanded":!!b,"aria-controls":b?"cloud-cancel-confirm":void 0,onClick:()=>u(L=>L===v.provider_subscription_id?null:v.provider_subscription_id),variant:"ghost",size:"sm",className:"!h-8 !px-2 text-xs",disabled:x,children:a("cloud.action.cancel_renewal")}):null]})}):null,b?e.jsxs("div",{id:"cloud-cancel-confirm",className:"my-3 rounded-lg border border-oai-gray-200 p-4 dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm leading-6",children:G?a("cloud.cancel.detail",{date:H(G)}):a("cloud.cancel.no_term")}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(A,{onClick:te,variant:"secondary",disabled:x,children:a("cloud.cancel.confirm")}),e.jsx(A,{onClick:()=>u(null),variant:"ghost",disabled:x,children:a("cloud.action.keep")})]})]}):null,r?e.jsx("div",{className:"py-2.5",children:e.jsx(ee,{error:r,onRetry:i,context:"account"})}):null,j&&h!=="billing"?e.jsx("div",{className:"py-2.5",children:e.jsx(ee,{error:j,context:"account"})}):null]})]}),f?e.jsx(st,{className:"tt-cloud-theme !rounded-lg",bodyClassName:"!py-3",children:e.jsx(jn,{auth:s,machineLimit:f.machine_limit,accountRevision:t,selfHosted:N})}):null,K||t&&!N||l?e.jsx(st,{className:"tt-cloud-theme !rounded-lg",bodyClassName:"!py-2",children:e.jsxs("section",{"aria-label":a("cloud.membership.tools_title"),className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:[N?null:v?e.jsxs("button",{type:"button",onClick:V,disabled:x,className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 disabled:opacity-50 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(fe,{size:16,className:"shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1",children:a("cloud.action.manage_subscription")}),e.jsx(nt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}):e.jsxs(ye,{to:"/cloud",className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(fe,{size:16,className:"shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1",children:a("cloud.action.subscribe")}),e.jsx(mt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),t&&!N?e.jsxs($e,{open:h==="billing",onOpenChange:L=>m(L?"billing":null),title:a("cloud.billing.title"),icon:Cs,wide:!0,children:[j?e.jsx("div",{className:"mb-3",children:e.jsx(ee,{error:j,context:"account"})}):null,e.jsx(kn,{userId:s.user?.id,recent:Ka(s.user?.id),pendingOrders:t?.pending_orders,conflictOrders:t?.conflict_orders,payments:t.payments,footerActions:C&&!v?e.jsx("div",{className:"flex items-center gap-0.5",children:e.jsxs(A,{onClick:V,variant:"ghost",size:"sm",className:"!h-10 !px-0",disabled:x,children:[a("cloud.action.view_bills"),e.jsx(nt,{size:14,className:"ml-2","aria-hidden":!0})]})}):null})]}):null,f?.can_read_cloud?e.jsx(xn,{auth:s,layout:"settings-row",dialogOpen:h==="export",onDialogOpenChange:L=>m(L?"export":null)}):null,e.jsx(dn,{account:t,auth:s,refresh:i,layout:"settings-row",dialogOpen:h==="redeem",onDialogOpenChange:L=>m(L?"redeem":null)}),l?e.jsx("section",{children:l}):null]})}):null]})}function Sn({settings:t,active:s=!0}={}){return t?e.jsx(Tt,{settings:t,active:s}):e.jsx(Cn,{active:s})}function Cn({active:t}){const s=Me();return e.jsx(Tt,{settings:s,active:t})}function Tt({settings:t,active:s}){return e.jsx(wn,{showTitle:!1,active:s,syncControl:t.showLocalCloudSync?e.jsx(En,{settings:t}):null})}function En({settings:t}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-3 text-sm font-medium",children:[e.jsx(De,{size:16,className:"shrink-0","aria-hidden":!0}),a("settings.account.cloudSync")]}),e.jsx("span",{className:"tt-cloud-theme tt-cloud-sync-control inline-flex","aria-busy":t.cloudSyncPending||void 0,children:e.jsx(z,{checked:t.cloudSyncOn,disabled:t.cloudSyncPending,onChange:()=>(t.cloudSyncOn?Ye(t.userId):oa(t.userId,"sync"),t.handleCloudSyncToggle()),ariaLabel:a("settings.account.cloudSync")})})]}),t.cloudSyncOn&&t.cloudSyncPending?e.jsxs("p",{role:"status",className:"flex items-center gap-2 py-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(xe,{size:14,className:"motion-safe:animate-spin","aria-hidden":!0}),a("settings.account.cloudSyncPending")]}):null,t.cloudSyncOn&&t.cloudSyncError&&!t.cloudSyncPending?e.jsx("div",{className:"tt-cloud-theme py-3",children:e.jsx(ee,{role:"alert",onRetry:t.handleCloudSyncRetry,children:a("settings.account.cloudSyncError")})}):null,e.jsx(la,{userId:t.userId,panel:"sync",localHost:!0,className:"py-3",onContinueLocal:()=>{Ye(t.userId),t.cloudSyncOn&&t.handleCloudSyncDisable()}})]})}function Pn(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:da},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:ua},{value:"system",label:a("settings.appearance.theme.system"),Icon:Ue}]}function On(){return[{value:pa,label:a("settings.appearance.language.system")},{value:ha,label:a("settings.appearance.language.english")},{value:fa,label:a("settings.appearance.language.chinese")},{value:xa,label:a("settings.appearance.language.traditional_chinese")},{value:ba,label:a("settings.appearance.language.japanese")},{value:ya,label:a("settings.appearance.language.korean")},{value:va,label:a("settings.appearance.language.german")}]}function An(t){if(!t)return null;try{const s=new Date(t);return Number.isNaN(s.getTime())?null:s.toLocaleString()}catch{return null}}function Ln(t,s){const n=a(`settings.appearance.currency.rate_source.${t}`),r=An(s),i=r?a("settings.appearance.currency.rate_updated",{when:r}):a("settings.appearance.currency.rate_never");return`${n} · ${i}`}function Tn({locale:t,setLocale:s}){const n=On();return e.jsx(ze,{value:t,onValueChange:s,options:n,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:e.jsx(Os,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Rn({currency:t,setCurrency:s}){const n=ma().map(r=>({value:r.code,label:a(r.labelKey)}));return e.jsx(ze,{value:t,onValueChange:s,options:n,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function In({currency:t,rate:s,rateSource:n,rateFetchedAt:r}){if(t===ga)return e.jsx(e.Fragment,{children:a("settings.appearance.currency.hint")});const i=Ln(n,r);return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:`1 USD = ${s.toFixed(4)} ${t}`}),e.jsx("span",{role:"img","aria-label":i,title:i,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:e.jsx(jt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Dn(){const{theme:t,setTheme:s}=ca(),{locale:n,setLocale:r}=xt(),{currency:i,rate:c,rateSource:g,rateFetchedAt:l,setCurrency:d}=_s(),{mode:p,setMode:h,unitSystem:m,setUnitSystem:j,grouping:w,setGrouping:x}=ws();return e.jsxs(Z,{title:a("settings.section.appearance"),children:[e.jsx(R,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:e.jsx(se,{options:Pn(),value:t,onChange:s})}),e.jsx(R,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:e.jsx(Tn,{locale:n,setLocale:r})}),e.jsx(R,{label:a("settings.appearance.currency.label"),hint:e.jsx(In,{currency:i,rate:c,rateSource:g,rateFetchedAt:l}),control:e.jsx(Rn,{currency:i,setCurrency:d})}),e.jsx(R,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:e.jsx(se,{options:[{value:Se.COMPACT,label:a("settings.appearance.token_format.compact")},{value:Se.FULL,label:a("settings.appearance.token_format.full")}],value:p,onChange:h})}),e.jsx(R,{label:a("settings.appearance.token_unit.label"),hint:a("settings.appearance.token_unit.hint"),control:e.jsx(se,{disabled:p!==Se.COMPACT,options:[{value:Ze.ENGLISH,label:a("settings.appearance.token_unit.english")},{value:Ze.CHINESE,label:a("settings.appearance.token_unit.chinese")}],value:m,onChange:j})}),e.jsx(R,{label:a("settings.appearance.token_grouping.label"),hint:a("settings.appearance.token_grouping.hint"),control:e.jsx(se,{options:[{value:Je.THOUSAND,label:a("settings.appearance.token_grouping.thousand")},{value:Je.WAN,label:a("settings.appearance.token_grouping.wan")}],value:w,onChange:x})})]})}function Ee({labelKey:t}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:a(t)}),e.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 Un(){const{enabled:t,toggle:s}=Fa(),{enabled:n,toggle:r}=Ba(),{available:i,settings:c,setSetting:g}=je(),l=i&&!!c?.dynamicIslandSupported,d=!!c?.dynamicIslandEnabled;return e.jsxs(Z,{title:a("settings.section.labs"),children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.island.label"}),hint:a("settings.labs.island.hint"),control:e.jsx(z,{checked:d,onChange:()=>g("dynamicIslandEnabled",!d),ariaLabel:a("settings.labs.island.aria")})}),d&&e.jsx(R,{label:a("settings.labs.island_hide_menubar.label"),hint:a("settings.labs.island_hide_menubar.hint"),control:e.jsx(z,{checked:!!c?.hideMenuBarIcon,onChange:()=>g("hideMenuBarIcon",!c?.hideMenuBarIcon),ariaLabel:a("settings.labs.island_hide_menubar.aria")})})]}),e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:e.jsx(z,{checked:t,onChange:s,ariaLabel:a("settings.labs.qpd.aria")})}),e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:e.jsx(z,{checked:n,onChange:r,ariaLabel:a("settings.labs.sessions.aria")})})]})}function zn(){const{available:t,settings:s,setSetting:n,runAction:r}=je();if(!t)return null;const i=bt(),c=!!s?.launchAtLogin,g=s?.toastOnReset!==!1,l=s?.confettiOnReset!==!1,d=s?.launchAtLoginSupported!==!1,p=s?.autoUpdateEnabled!==!1,h=s?.updateStatus||null,m=!!s?.updateBusy,j=!!s?.isSyncing;return e.jsxs(Z,{title:a("settings.section.menubar"),children:[i?null:e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:e.jsxs(A,{as:ye,to:"/widgets",variant:"secondary",size:"sm",className:"gap-1.5 no-underline",children:[e.jsx("span",{children:a("settings.menubar.appearanceLink")}),e.jsx(Ss,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),e.jsx(R,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:e.jsx(z,{checked:g,onChange:()=>n("toastOnReset",!g),ariaLabel:a("settings.menubar.toastOnReset")})}),e.jsx(R,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:e.jsx(z,{checked:l,onChange:()=>n("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),d?e.jsx(R,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:e.jsx(z,{checked:c,onChange:()=>n("launchAtLogin",!c),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,e.jsx(R,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:()=>r("syncNow"),disabled:j,className:"gap-1.5",children:[e.jsx(De,{className:le("h-3.5 w-3.5",j&&"animate-spin"),"aria-hidden":!0}),e.jsx("span",{children:j?a("settings.menubar.syncing"):a("settings.menubar.syncNow")})]})}),e.jsx(R,{label:a("settings.menubar.autoUpdate"),hint:a("settings.menubar.autoUpdateHint"),control:e.jsx(z,{checked:p,onChange:()=>n("autoUpdateEnabled",!p),ariaLabel:a("settings.menubar.autoUpdate")})}),e.jsx(R,{label:a("settings.menubar.updates"),hint:h||void 0,control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:()=>r("checkForUpdates"),disabled:m,className:"gap-1.5",children:[e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:a("settings.menubar.checkUpdates")})]})})]})}function Gn(t,s){function n(c){return c.replace(/^v/,"").split(".").map(Number)}const r=n(t),i=n(s);for(let c=0;c<Math.max(r.length,i.length);c++){const g=r[c]||0,l=i[c]||0;if(g<l)return!0;if(g>l)return!1}return!1}function Mn(){const{available:t,settings:s,runAction:n}=je(),r=t&&s?.version,i=s?.platform||"macos",[c,g]=Pe.useState(!1),[l,d]=Pe.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:p}=xt(),h="1.3.16",m=async()=>{g(!0);try{const b=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!b.ok)throw new Error("Failed to fetch");const u=await b.json(),y=u.tag_name;Gn(h,y)?d({open:!0,latestVersion:y,htmlUrl:u.html_url}):Xe({title:a("settings.menubar.updates.upToDate")})}catch(b){console.error("Check updates failed:",b),Xe({title:a("settings.menubar.updates.failed")})}finally{g(!1)}},j=a("settings.menubar.updates.modalTitle"),w=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),x=a("settings.menubar.updates.modalConfirm"),_=a("settings.menubar.updates.modalCancel");return e.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:[e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[r?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:i==="windows"?a("settings.menubar.updates.footerCore",{version:s.version}):a("settings.menubar.updates.footerCombined",{barVersion:s.version,coreVersion:h})}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:()=>n("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:h})}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:m,disabled:c,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:c?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}),e.jsxs("a",{href:ja,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:[e.jsx(ka,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),e.jsx(Ns,{open:l.open,title:j,description:w,confirmLabel:x,cancelLabel:_,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),d(b=>({...b,open:!1}))},onCancel:()=>d(b=>({...b,open:!1}))})]})}const $n=()=>[{value:"system",label:a("settings.network.mode.system")},{value:"manual",label:a("settings.network.mode.manual")},{value:"off",label:a("settings.network.mode.off")}],Fn=()=>[{value:"http",label:a("settings.network.protocol.http")},{value:"https",label:a("settings.network.protocol.https")},{value:"socks5",label:a("settings.network.protocol.socks5")}];function rt(t){const s={},n=String(t.host||"").trim();(!n||/:\/\//.test(n)||n.includes("/"))&&(s.host=a("settings.network.error.host"));const r=String(t.port??"").trim(),i=Number(r);return(!r||!/^\d+$/.test(r)||!Number.isInteger(i)||i<1||i>65535)&&(s.port=a("settings.network.error.port")),s}function Bn({proxySettings:t}){const{config:s,save:n,testConnection:r}=t,[i,c]=o.useState(()=>({mode:s.mode,protocol:s.protocol||"http",host:s.host||"",port:s.port||""})),[g,l]=o.useState({}),[d,p]=o.useState(!1),[h,m]=o.useState(""),[j,w]=o.useState(null),[x,_]=o.useState(!1),[b,u]=o.useState(null);o.useEffect(()=>{c({mode:s.mode,protocol:s.protocol||"http",host:s.host||"",port:s.port||""})},[s.mode,s.protocol,s.host,s.port]);const y=o.useMemo(()=>s.effective==="manual"?a("settings.network.effective.manual"):s.effective==="env"?a("settings.network.effective.env"):s.effective==="system"?a("settings.network.effective.system"):s.effective==="blocked"?a("settings.network.effective.blocked"):a("settings.network.effective.none"),[s.effective]),k=o.useMemo(()=>i.mode!==s.mode?!0:i.mode==="manual"?(i.protocol||"http")!==(s.protocol||"http")||(i.host||"")!==(s.host||"")||String(i.port??"")!==String(s.port??""):!1,[i,s]),f=v=>{c(C=>({...C,...v})),l({}),m(""),w(null),u(null)},N=async()=>{if(i.mode==="manual"){const v=rt(i);if(Object.keys(v).length){l(v);return}}p(!0),m(""),w(null);try{await n(i),m("saved")}catch(v){m("error"),w(v)}finally{p(!1)}},E=async()=>{const v=rt(i);if(Object.keys(v).length){l(v);return}_(!0),u(null);try{const C=await r(i);u(C)}catch(C){u({ok:!1,error:C?.message||String(C)})}finally{_(!1)}};return e.jsxs(Z,{title:a("settings.section.network"),subtitle:y,children:[s.applyError?e.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:a("settings.network.apply_error",{error:s.applyError})}):null,e.jsx(R,{label:a("settings.network.mode.label"),hint:a("settings.network.mode.hint"),control:e.jsx(se,{options:$n(),value:i.mode,onChange:v=>f({mode:v})})}),e.jsx(vt,{initial:!1,children:i.mode==="manual"?e.jsxs(yt.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:[e.jsx(R,{label:a("settings.network.protocol.label"),control:e.jsx(ze,{value:i.protocol,onValueChange:v=>f({protocol:v}),options:Fn(),ariaLabel:a("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),e.jsx(R,{label:a("settings.network.host.label"),hint:g.host,control:e.jsx("input",{type:"text",value:i.host,onChange:v=>f({host:v.target.value}),placeholder:a("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":g.host?!0:void 0,"aria-label":a("settings.network.host.label"),className:ve})}),e.jsx(R,{label:a("settings.network.port.label"),hint:g.port,control:e.jsx("input",{type:"text",inputMode:"numeric",value:i.port,onChange:v=>f({port:v.target.value}),placeholder:a("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":g.port?!0:void 0,"aria-label":a("settings.network.port.label"),className:ve})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:E,disabled:x||d,className:"gap-1.5",children:x?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.test.testing")})]}):a("settings.network.test")}),e.jsx(A,{variant:"primary",size:"sm",onClick:N,disabled:d||x,className:"gap-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.saving")})]}):a("settings.network.save")})]}),b?e.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:b.ok?a("settings.network.test.ok",{status:String(b.status??"")}):a("settings.network.test.fail",{error:b.error||""})}):null]},"manual-proxy-fields"):null}),i.mode!=="manual"&&(k||d)?e.jsx("div",{className:"flex justify-end py-3",children:e.jsx(A,{variant:"primary",size:"sm",onClick:N,disabled:d,className:"gap-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.saving")})]}):a("settings.network.save")})},"non-manual-save"):null,h==="saved"?e.jsx("p",{className:"py-2 text-xs text-emerald-600 dark:text-emerald-400",children:a("settings.network.saved")}):null,h==="error"?e.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:j?.unprotected?a("settings.network.save_error_unprotected",{error:j?.message||String(j||"")}):a("settings.network.save_error",{error:j?.message||String(j||"")})}):null]})}const Rt="/functions/tokentracker-proxy-config",Hn="/functions/tokentracker-proxy-test",Vn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function It(t){return!t||typeof t.mode!="string"?null:{mode:t.mode,protocol:typeof t.protocol=="string"?t.protocol:"http",host:typeof t.host=="string"?t.host:"",port:t.port==null||t.port===0?"":String(t.port),effective:typeof t.effective=="string"?t.effective:"none",applyError:typeof t.applyError=="string"&&t.applyError.trim()?t.applyError:null}}async function qn(){const t=await fetch(Rt,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!t.ok)return null;const s=await t.json().catch(()=>null);return It(s)}async function ot(){const{getLocalApiAuthHeaders:t}=await _a(async()=>{const{getLocalApiAuthHeaders:s}=await import("./__vite-browser-external-BsOjTB8Q.js").then(n=>n.dY);return{getLocalApiAuthHeaders:s}},__vite__mapDeps([0,1]));return t()}function Kn(){const[t,s]=o.useState(!1),[n,r]=o.useState(!0),[i,c]=o.useState(Vn);o.useEffect(()=>{if(!qa()){s(!1),r(!1);return}let d=!1;return(async()=>{try{const p=await qn();if(d)return;if(!p){s(!1),r(!1);return}c(p),s(!0),r(!1)}catch{d||(s(!1),r(!1))}})(),()=>{d=!0}},[]);const g=o.useCallback(async d=>{const p=await ot(),h=await fetch(Rt,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({mode:d.mode,protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),m=await h.json().catch(()=>null);if(!h.ok){const w=m&&typeof m.error=="string"?m.error:`HTTP ${h.status}`;throw new Error(w)}const j=It(m);if(j&&c(j),m&&m.ok===!1){const w=m&&typeof m.applyError=="string"&&m.applyError||m&&typeof m.error=="string"&&m.error||`HTTP ${h.status}`,x=new Error(w);throw m.unprotected===!0&&(x.unprotected=!0),x}return j||m},[]),l=o.useCallback(async d=>{const p=await ot(),h=await fetch(Hn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),m=await h.json().catch(()=>null);if(!m||typeof m.ok!="boolean")throw new Error(m&&typeof m.error=="string"?m.error:`HTTP ${h.status}`);return m},[]);return{available:t,loading:n,config:i,save:g,testConnection:l}}const B={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",CLOUD:"cloud",LIMITS:"limits",LABS:"labs"},Y={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function Wn({prefs:t}){return e.jsx(se,{options:[{value:at.USED,label:a("limits.settings.display_mode_used")},{value:at.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:t.displayMode,onChange:t.setDisplayMode})}function Ti(){const t=Me(),s=Ga(),{available:n,settings:r,setSetting:i}=je(),c=Kn(),{available:g}=c,l=r?.toastOnReset!==!1,d=r?.confettiOnReset!==!1,p=bt()||r?.platform==="windows",[h,m]=wa(),j=ht(),w=h.get("section"),_=Object.values(B).includes(w)&&(w!==B.NATIVE_APP||n)&&(w!==B.NETWORK||g)?w:B.APPEARANCE,b=k=>{const f=new URLSearchParams(h);k===B.APPEARANCE?f.delete("section"):f.set("section",k),m(f,{replace:!0})},u=[{id:B.APPEARANCE,label:a("settings.section.appearance"),description:a("settings.section.appearance.description"),group:Y.PERSONAL,Icon:Ls,content:e.jsx(Dn,{})},...n?[{id:B.NATIVE_APP,label:a("settings.section.menubar"),description:a("settings.section.menubar.description"),group:Y.APP,Icon:Ue,content:e.jsx(zn,{})}]:[],...g?[{id:B.NETWORK,label:a("settings.section.network"),description:a("settings.section.network.description"),group:Y.APP,Icon:Na,content:e.jsx(Bn,{proxySettings:c})}]:[],{id:B.ACCOUNT,label:a("settings.section.account"),description:a("settings.section.account.description"),group:Y.PERSONAL,Icon:Ts,content:e.jsx(sn,{settings:t})},{id:B.CLOUD,label:a("settings.section.cloud"),description:a("settings.section.cloud.description"),group:Y.PERSONAL,Icon:fe,content:e.jsx(Sn,{settings:t,active:_===B.CLOUD})},{id:B.LIMITS,label:a("settings.section.limits"),description:a("settings.section.limits.description"),group:Y.APP,Icon:Sa,content:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Z,{title:a("settings.section.limits"),children:[e.jsx(R,{label:a("limits.settings.display_mode_label"),control:e.jsx(Wn,{prefs:s})}),p?null:e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:e.jsx(z,{checked:l,disabled:!n,onChange:()=>i("toastOnReset",!l),ariaLabel:a("settings.menubar.toastOnReset")})}),e.jsx(R,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:e.jsx(z,{checked:d,disabled:!n,onChange:()=>i("confettiOnReset",!d),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),e.jsx(R,{label:a("settings.limits.showSubscriptions"),hint:a("settings.limits.showSubscriptionsHint"),control:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>j("/limits?openSubscriptions=1"),"aria-label":a("limits.page.openSubscriptions"),title:a("limits.page.openSubscriptions"),className:"!h-7 !w-7 !p-0 text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white",children:e.jsx(Ca,{size:14,"aria-hidden":!0})}),e.jsx(z,{checked:s.showSubscriptions!==!1,onChange:()=>s.setShowSubscriptions(!s.showSubscriptions),ariaLabel:a("settings.limits.showSubscriptions")})]})})]}),e.jsx(Z,{title:a("settings.limits.providers"),children:e.jsx(Us,{prefs:s})})]})},{id:B.LABS,label:a("settings.section.labs"),description:a("settings.section.labs.description"),group:Y.DEVELOPER,Icon:Es,content:e.jsx(Un,{})}],y=[{id:Y.PERSONAL,label:a("settings.nav.group.personal")},{id:Y.APP,label:a("settings.nav.group.app")},{id:Y.DEVELOPER,label:a("settings.nav.group.developer")}].map(k=>({...k,sections:u.filter(f=>f.group===k.id)})).filter(k=>k.sections.length>0);return e.jsx("div",{className:le("flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",_===B.CLOUD&&"tt-cloud-settings"),children:e.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-7 max-w-2xl",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("settings.page.subtitle")})]}),e.jsxs("div",{className:"tt-settings-sections grid min-w-0 gap-6 md:grid-cols-[11rem_minmax(0,1fr)] md:gap-8",children:[e.jsx("aside",{className:"min-w-0 rounded-xl border border-oai-gray-200 bg-oai-gray-50/70 p-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 md:border-0 md:bg-transparent md:p-0 md:dark:bg-transparent",children:e.jsx("nav",{"aria-label":a("settings.page.title"),className:"flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-4 md:overflow-visible",children:y.map(({id:k,label:f,sections:N})=>e.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[e.jsx("div",{className:"hidden px-3 pb-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-oai-gray-400 dark:text-oai-gray-500 md:block",children:f}),e.jsx("div",{className:"flex gap-1 md:flex-col",children:N.map(({id:E,label:v,Icon:C})=>{const O=_===E;return e.jsxs("button",{id:`settings-nav-${E}`,type:"button","aria-current":O?"page":void 0,"aria-controls":`settings-panel-${E}`,onClick:()=>b(E),className:le("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",O?"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:[e.jsx(C,{className:le("h-4 w-4 shrink-0",O?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:v})]},E)})})]},k))})}),e.jsxs("div",{className:"min-w-0",children:[u.map(({id:k,label:f,content:N})=>e.jsx("section",{id:`settings-panel-${k}`,"aria-labelledby":`settings-nav-${k}`,"aria-label":f,"data-settings-panel":k,hidden:_!==k,children:N},k)),e.jsx(Mn,{})]})]})]})})})}export{Ti as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as yt,r as i,K as ha,j as e,y as Q,X as Ie,c as r,b1 as ua,bm as bt,M as kt,c8 as wt,c3 as vt,J as jt,c9 as Nt,bJ as Ct,ca as St,cb as _t,N as Rt,bX as It,bF as Lt,c7 as Pt,cc as Dt,az as Bt,a as Tt,cd as At,a7 as Et,W as Ot,B as J,R as $t,V as Mt,aM as Ut,bj as G}from"./__vite-browser-external-BsOjTB8Q.js";import{L as zt,I as xa}from"./LocalOnlyNotice-BSewrWlY.js";import{C as Ft}from"./Card-CuwBiIYz.js";import{C as da}from"./ConfirmModal-CoFO1Nas.js";import{I as La}from"./info-ynVg8RzK.js";import{P as ve}from"./ProviderIcon-htNu1RTN.js";import{m as wa}from"./react-VsHxeqq7.js";import{u as Vt}from"./useCurrency-BmEbDVaa.js";import{E as ma}from"./external-link-tDBZy6QP.js";import{L as Z}from"./loader-circle-FTE9k7Sk.js";import{M as Pa}from"./monitor-smartphone-CNzgbo-M.js";import{C as Le}from"./check-DIfCVsPJ.js";import{T as fa}from"./trash-0cqpTyN6.js";import{A as Kt}from"./index-Ci3CZ-2g.js";import{u as Wt}from"./use-reduced-motion-C83gmg0F.js";import{u as Ht,o as qt,p as Gt,q as Xt,r as Jt,t as Qt,v as Yt,w as Zt,x as er,S as Da,c as Ba,d as Ta,e as Aa,f as Ea,g as Oa,h as ta,j as ra,i as sa}from"./SelectItemText-DRmxMwo5.js";import{t as ar,u as $a,D as tr}from"./composite-W1R1XwoE.js";import{g as rr,a as sr,p as nr,m as ir,b as or,d as lr,c as dr,e as cr,f as ur,s as mr,i as gr,u as va,h as ja,r as hr,j as Na,k as Ca,l as Sa,n as xr,o as fr}from"./skills-api-Cn8hEYL4.js";import{F as pr}from"./flame-86y9Xf0g.js";import{C as pa}from"./chevron-down-DrWxRBXX.js";import{S as ga}from"./search-Svi--7CN.js";import{P as Ma}from"./plus-BA85lApI.js";import{D as Ua}from"./download-CEXAmejX.js";import{P as za,a as Fa,b as Va,c as Ka,d as Wa}from"./PopoverPopup-D-Tpl294.js";import"./arrow-up-right-CK_9HuEh.js";import"./DialogTitle-ck8f1qeP.js";import"./store-D2gn9bSV.js";import"./DialogDescription-Cx1R3WT7.js";import"./usePositioner-nY0YNa-6.js";import"./safePolygon-CCDOsx-z.js";const Ha={name:"circle-arrow-up",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],aliases:["arrow-up-circle"]};Ha.node;const ya=yt(Ha),qa=i.forwardRef(function(s,d){const{render:l,className:p,style:h,...x}=s,w={open:Ht().useState("open")};return ha("span",s,{state:w,ref:d,props:[{"aria-hidden":!0,children:"▼"},x],stateAttributesMapping:ar})});function yr({options:a,value:s,onChange:d,leading:l=null,disabled:p=!1,ariaLabel:h,className:x=""}){const u=i.useRef(null),y=i.useRef(new Map),[w,b]=i.useState(null),S=(k,c)=>{const g=a.filter(_=>!p&&!_.disabled),m=g.findIndex(_=>_.id===c);if(m<0)return;let v=null;k.key==="ArrowRight"||k.key==="ArrowDown"?v=g[(m+1)%g.length]:k.key==="ArrowLeft"||k.key==="ArrowUp"?v=g[(m-1+g.length)%g.length]:k.key==="Home"?v=g[0]:k.key==="End"&&(v=g[g.length-1]),!(!v||v.id===c)&&(k.preventDefault(),d(v.id),y.current.get(v.id)?.focus())};return i.useLayoutEffect(()=>{const k=()=>{const g=y.current.get(s);if(!g||g.offsetWidth===0)return;const m={left:g.offsetLeft,top:g.offsetTop,width:g.offsetWidth,height:g.offsetHeight};b(v=>v&&v.left===m.left&&v.top===m.top&&v.width===m.width&&v.height===m.height?v:m)};if(k(),typeof ResizeObserver>"u"||!u.current)return;const c=new ResizeObserver(k);c.observe(u.current);for(const g of y.current.values())c.observe(g);return()=>c.disconnect()},[s,a]),e.jsxs("div",{ref:u,role:"tablist","aria-label":h,className:Q("relative inline-flex h-8 items-center gap-1 rounded-md border border-oai-gray-200 bg-oai-gray-100 p-[3px] dark:border-oai-gray-700 dark:bg-oai-gray-800",x),children:[l,w?e.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute left-0 top-0 rounded-sm bg-white shadow-sm transition-[transform,width] duration-200 ease-out motion-reduce:transition-none dark:bg-oai-gray-700",style:{transform:`translate(${w.left}px, ${w.top}px)`,width:`${w.width}px`,height:`${w.height}px`}}):null,a.map(k=>{const c=k.id===s;return e.jsxs("button",{ref:g=>{g?y.current.set(k.id,g):y.current.delete(k.id)},type:"button",role:"tab","aria-selected":c,tabIndex:c?0:-1,disabled:p||k.disabled,onClick:()=>d(k.id),onKeyDown:g=>S(g,k.id),className:Q("relative z-10 inline-flex h-6 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors disabled:opacity-50",c?"text-oai-black dark:text-white":"text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[k.icon,k.label]},k.id)})]})}const br="tt:hint:dismissed:";function Ga(a){return br+a}function kr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ga(a))==="1"}catch{return!1}}function wr({id:a,children:s,className:d,ariaLabel:l}){const[p,h]=i.useState(()=>kr(a)),x=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Ga(a),"1")}catch{}h(!0)},[a]);return p?null:e.jsxs("div",{role:"note","aria-label":l||r("hint.dismissible_aria"),className:Q("relative rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700","dark:border-oai-gray-800 dark:bg-oai-gray-900/40 dark:text-oai-gray-300",d),children:[e.jsx("button",{type:"button",onClick:x,"aria-label":r("hint.dismiss"),className:"absolute top-2 right-2 inline-flex h-7 w-7 items-center justify-center rounded-md text-oai-gray-500 transition-colors hover:bg-oai-gray-200/70 hover:text-oai-gray-700 focus:outline-none focus:ring-2 focus:ring-oai-blue/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800/70 dark:hover:text-oai-gray-200",children:e.jsx(Ie,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(La,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})]})}function vr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const l=s;if(l.type==="submit")return l}}return null}const jr="data-checked",Nr="data-unchecked";function Xa(a){return{checked(s){return a.indeterminate?{}:s?{[jr]:""}:{[Nr]:""}},...qt}}const Cr=i.createContext({disabled:!1});function Sr(){return i.useContext(Cr)}function _r(a,s,d,l=!0,p){const[h,x]=i.useState(),u=$a(p?`${p}-label`:void 0),y=a??s??h;return ua(()=>{const w=a||s||!l?void 0:Rr(d.current,u);h!==w&&x(w)}),y}function Rr(a,s){const d=Ir(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function Ir(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const p=a.nextElementSibling;if(p&&p.htmlFor===d)return p}const l=a.labels;return l&&l[0]}const Lr=i.createContext(void 0);function Pr(){return i.useContext(Lr)}const Ja=i.createContext(void 0);function Dr(){const a=i.useContext(Ja);if(a===void 0)throw new Error(bt(14));return a}const Br="data-parent",Tr=i.forwardRef(function(s,d){const{checked:l,className:p,defaultChecked:h=!1,"aria-labelledby":x,disabled:u=!1,form:y,id:w,indeterminate:b=!1,inputRef:S,name:k,onCheckedChange:c,parent:g=!1,readOnly:m=!1,render:v,required:_=!1,uncheckedValue:$,value:M,nativeButton:K=!1,style:de,...fe}=s,{clearErrors:ne}=Gt(),{disabled:D,name:pe,setDirty:I,setFilled:U,setFocused:W,setTouched:T,state:ee,validationMode:Y,validityData:je,validation:ce}=Xt(),Pe=Sr(),{labelId:He,registerControlId:De,getDescriptionProps:Be}=Jt(),R=Pr(),L=R?.allValues===void 0?void 0:R.parent,H=L!==void 0,B=D||Pe.disabled||R?.disabled||u,ae=pe??k,P=M??ae,Ne=$a(),Te=R?.registerControlId!==De,ie=Qt({id:w||void 0,enabled:Te}),Ae=K?ie:Ne;let ue={};H&&(g?ue=L.getParentProps():P!==void 0&&(ue=L.getChildProps(P)));const{checked:Ee=l,indeterminate:Oe=b,onCheckedChange:qe,...Ce}=ue,$e=R?.value,me=i.useRef(null),{getButtonProps:Ge,buttonRef:Me}=kt({disabled:B,native:K}),te=R?.validation??ce,[A,Se]=Yt({controlled:P!==void 0&&$e!==void 0&&!g?$e.includes(P):Ee,default:h,name:"Checkbox",state:"checked"}),ge=H?!!Ee:A,q=H&&Oe||b;Zt(me,Ne,A,void 0,!R&&!B,k);const he=L?.registerChildId,E=i.useRef(null),Ue=te.registerInput,ye=R?P:void 0,_e=i.useCallback(N=>Ue(N,{controlRef:me,value:ye}),[Ue,ye]),ia=wt(S,E,g?void 0:_e),Xe=_r(x,He,E,!K,ie);ua(()=>{E.current&&(E.current.indeterminate=q),R||U(A)},[A,q,R,U]),er(A,()=>{R||(ne(ae),I(A!==je.initialValue),te.change(A))});const Je=vt({checked:A,disabled:B,form:y,name:g?void 0:ae,id:K?void 0:ie,required:_,ref:ia,style:ae?St:_t,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(N){if(N.nativeEvent.defaultPrevented)return;if(m){N.preventDefault();return}const F=N.currentTarget.checked,oe=Rt(It,N.nativeEvent);if(c?.(F,oe),!oe.isCanceled&&(qe?.(F,oe),!oe.isCanceled&&(Se(F),P!==void 0&&R!==void 0&&!g&&!H))){const re=F?[...R.value,P]:R.value.filter(Re=>Re!==P);R.setValue(re,oe)}},onClick(N){N.stopPropagation()},onFocus(){me.current?.focus()}},M!==void 0?{value:(R?A&&M:M)||""}:jt,Be,N=>te.getValidationProps(B,N));i.useEffect(()=>{if(!L||P===void 0)return;const N=L.disabledStatesRef.current;return N.set(P,B),()=>{N.delete(P)}},[L,B,P]);const z=i.useMemo(()=>({...ee,checked:ge,disabled:B,readOnly:m,required:_,indeterminate:q}),[ee,ge,B,m,_,q]),oa=Xa(z),Qe=ha("span",s,{state:z,ref:[Me,me,d],props:[{id:Ae,role:"checkbox","aria-checked":q?"mixed":ge,"aria-readonly":m||void 0,"aria-required":_||void 0,"aria-labelledby":Xe,[Br]:g?"":void 0,onFocus(){B||W(!0)},onBlur(){const N=E.current;N&&(T(!0),W(!1),Y==="onBlur"&&te.commit(R?$e:N.checked))},onKeyDown(N){if(N.key!=="Enter"||(N.preventBaseUIHandler(),N.defaultPrevented))return;const F=E.current?.form??null,oe=N.currentTarget,re=N.nativeEvent,Re=N.preventDefault,Fe=re.preventDefault;let Ve=!1;N.preventDefault=()=>{Ve=!0,Re.call(N)},re.preventDefault=()=>{Ve=!0,Fe.call(re)},Fe.call(re),Ct(oe).queueMicrotask(()=>{N.preventDefault=Re,re.preventDefault=Fe,Ve||vr(F)?.click()})},onClick(N){if(m||B)return;N.preventDefault();const F=E.current;F&&Nt(F,N)}},fe,Ce,Ge,Be,N=>te.getValidationProps(B,N)],stateAttributesMapping:oa}),ze=Qe.props.id;return ua(()=>{if(!(!he||g||P===void 0||ze===void 0))return he(P,ze)},[he,g,P,ze]),e.jsxs(Ja.Provider,{value:z,children:[Qe,!A&&!R&&ae&&!g&&$!==void 0&&e.jsx("input",{type:"hidden",form:y,name:ae,value:$,disabled:B}),e.jsx("input",{...Je,suppressHydrationWarning:!0})]})}),Ar=i.forwardRef(function(s,d){const{render:l,className:p,style:h,keepMounted:x=!1,...u}=s,y=Dr(),w=y.checked||y.indeterminate,{mounted:b,transitionStatus:S,setMounted:k}=tr(w),c=i.useRef(null),g={...y,transitionStatus:S};Lt({batch:!0,enabled:!w,open:w,ref:c,onComplete(){w||k(!1)}});const v={...Xa(y),...Pt},_=x||b,$=ha("span",s,{ref:[d,c],state:g,stateAttributesMapping:v,props:u});return _?$:null});function Er(a,s){return`target:${a}:${s}`}function Or(a){return`remove:${a.id||a.directory}`}function Qa(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function $r(a){const s=Qa(a);if(s==null)return null;if(s<=0)return r("skills.usage.today");if(s<30)return r("skills.usage.days_ago",{days:s});const d=Math.max(1,Math.floor(s/30));return r("skills.usage.months_ago",{months:d})}function Mr(a){const s=Qa(a);return s==null?"bg-oai-gray-300 dark:bg-oai-gray-600":s<=7?"bg-emerald-500":s<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function ca({label:a,children:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[e.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:s})]})}function Ur({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:h,onUpdate:x,onClose:u,onToggleTarget:y,onRemove:w}){return e.jsx(Kt,{children:a?e.jsx(zr,{skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:h,onUpdate:x,onClose:u,onToggleTarget:y,onRemove:w},a.id||a.directory):null})}function zr({skill:a,targets:s,busyKey:d,usage:l,hasUpdate:p,updating:h,onUpdate:x,onClose:u,onToggleTarget:y,onRemove:w}){const b=Wt(),{currency:S,rate:k}=Vt(),c=i.useRef(null);i.useEffect(()=>{const I=W=>{W.key==="Escape"&&(W.stopPropagation(),u?.())},U=W=>{const T=W.target;T instanceof Element&&(c.current?.contains(T)||T.closest('[data-skill-row="1"]')||u?.())};return document.addEventListener("keydown",I),document.addEventListener("pointerdown",U),()=>{document.removeEventListener("keydown",I),document.removeEventListener("pointerdown",U)}},[u]);const g=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),v=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,_=new Set(a.targets||[]),$=!!(a.readOnly||a.remote),M=!!a.remote,K=Array.isArray(a.deviceSources)?a.deviceSources:[],de=!M&&(!$||_.has("claude")),fe=d===Or(a),ne=$r(l?.lastUsedAt),D=!!(l&&l.invocations>0),pe=b?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(wa.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:b?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:b?0:.15},onClick:u,"aria-hidden":!0}),e.jsxs(wa.aside,{ref:c,role:"complementary","aria-label":g,initial:b?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:b?{opacity:0}:{opacity:0,x:24,scale:.98},transition:pe,className:"fixed inset-x-3 bottom-3 top-20 z-30 flex flex-col overflow-hidden rounded-2xl border border-white/40 bg-white/75 shadow-[0_24px_60px_-20px_rgba(15,23,42,0.25)] backdrop-blur-xl backdrop-saturate-150 supports-[backdrop-filter]:bg-white/65 dark:border-white/10 dark:bg-oai-gray-950/70 dark:shadow-[0_24px_60px_-20px_rgba(0,0,0,0.7)] dark:supports-[backdrop-filter]:bg-oai-gray-950/55 lg:inset-auto lg:right-6 lg:top-24 lg:bottom-6 lg:w-[22rem] lg:max-h-[calc(100vh-7.5rem)]",children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-white/40 bg-gradient-to-b from-white/30 to-transparent px-5 pb-4 pt-5 dark:border-white/10 dark:from-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:g,children:g}),m?e.jsxs("a",{href:v,target:"_blank",rel:"noreferrer noopener",className:"mt-1 inline-flex max-w-full items-center gap-1 truncate text-xs text-oai-gray-500 transition-colors hover:text-oai-black hover:underline dark:text-oai-gray-400 dark:hover:text-white",title:v,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ma,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==g?e.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:a.directory,children:a.directory}):null]}),e.jsx("button",{type:"button",onClick:u,"aria-label":r("skills.detail.close"),className:"-mr-1 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-oai-gray-500 transition hover:bg-oai-gray-100 hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(Ie,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5",children:[p?e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-sky-50/80 px-3 py-2.5 ring-1 ring-sky-200 dark:bg-sky-950/30 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-4 w-4 shrink-0 text-sky-600 dark:text-sky-300","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 text-xs text-sky-800 dark:text-sky-200",children:r("skills.update.available")}),e.jsxs("button",{type:"button",onClick:()=>x?.(a),disabled:h||!!d,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-sky-600 px-2.5 text-xs font-semibold text-white transition hover:bg-sky-700 focus:outline-none focus:ring-2 focus:ring-sky-400/40 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-sky-500 dark:hover:bg-sky-400",children:[h?e.jsx(Z,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,r("skills.update.action")]})]}):null,a.description?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a.description}):null,$?e.jsx("div",{className:"mt-4 rounded-xl bg-oai-gray-50 px-3 py-2.5 text-xs leading-5 text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-900/60 dark:text-oai-gray-300 dark:ring-oai-gray-800",children:r(M?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed")}):null,a.sourceName?e.jsx("div",{className:"mt-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.source",{source:a.sourceName})}):null,K.length?e.jsxs("section",{className:"mt-5",children:[e.jsx("h3",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.inventory.devices_title")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(I=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 rounded-full bg-oai-gray-100 px-2.5 py-1 text-xs text-oai-gray-700 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-200 dark:ring-oai-gray-700",children:[e.jsx(Pa,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:I.name})]},I.id))})]}):null,de?e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.usage.section_title")}),e.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[e.jsx(ca,{label:r("skills.usage.invocations"),children:Dt(l?.invocations||0)}),e.jsx(ca,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",Mr(l?.lastUsedAt)),"aria-hidden":!0}),D?ne||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ca,{label:e.jsxs(e.Fragment,{children:[r("skills.usage.cost"),e.jsx("span",{title:r("skills.usage.disclaimer"),className:"inline-flex cursor-help text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(La,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:Bt(l?.cost||0,{currency:S,rate:k})})]}),D?null:e.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:r("skills.usage.unused")})]}):null,$?null:e.jsxs("section",{className:"mt-6",children:[e.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.sync_section_title")}),e.jsx("div",{children:(s||[]).filter(I=>I.manageable!==!1).map(I=>{const U=_.has(I.id),W=d===Er(a.id||a.directory,I.id),T=`skill-detail-sync-${a.id||a.directory}-${I.id}`;return e.jsxs("label",{htmlFor:T,className:"-mx-2 flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-sm text-oai-black transition-colors hover:bg-oai-gray-100/70 dark:text-white dark:hover:bg-white/[0.05]",children:[e.jsx(Tr,{id:T,checked:U,disabled:!!d,onCheckedChange:ee=>y?.(a,I.id,!!ee),className:"peer flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border border-oai-gray-300/80 bg-white/80 shadow-sm transition-colors hover:border-oai-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:border-oai-black data-[checked]:bg-oai-black dark:border-oai-gray-500/60 dark:bg-oai-gray-900/60 dark:hover:border-oai-gray-400 dark:data-[checked]:border-white dark:data-[checked]:bg-white",children:e.jsx(Ar,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Le,{className:"h-3 w-3",strokeWidth:3.5,"aria-hidden":!0})})}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center","aria-hidden":!0,children:e.jsx(ve,{provider:I.id,size:16})}),e.jsx("span",{className:"flex-1",children:I.label}),W?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},I.id)})})]})]}),$?null:e.jsxs("footer",{className:"border-t border-white/40 bg-white/30 px-5 py-4 dark:border-white/10 dark:bg-white/[0.02]",children:[e.jsxs("button",{type:"button",onClick:()=>w?.(a),disabled:!!d,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-white px-3 py-2 text-sm font-medium text-red-600 transition hover:border-red-300 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-900/60 dark:bg-oai-gray-950 dark:text-red-300 dark:hover:border-red-800 dark:hover:bg-red-950/30",children:[fe?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.detail.remove_button")]}),e.jsx("p",{className:"mt-2 text-center text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.detail.remove_confirm_hint")})]})]})]})}const Fr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),_a=["claude","codex"],X="popular",Vr={claude:"text-orange-500 dark:text-orange-300",codex:"text-emerald-600 dark:text-emerald-300",grok:"text-zinc-700 dark:text-zinc-200",antigravity:"text-violet-600 dark:text-violet-300",gemini:"text-sky-600 dark:text-sky-300",opencode:"text-amber-600 dark:text-amber-300",hermes:"text-indigo-500 dark:text-indigo-300"},xe="all",V="skillssh";function na(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Ya(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Kr(a){return Ya(a).split("/").filter(Boolean).pop()||""}function Wr(a){if(a.repoOwner||a.repoName)return"";const s=Ya(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Ra(a){const s=Kr(a.directory);return s?`dir:${s}`:""}function Za(a){const s=new Set([na(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Wr(a);return d&&s.add(d),s}function Hr(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function qr(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Hr(d))for(const l of Za(d))s.add(l);return s}function aa(a){return`install:${na(a)}`}function Ia(a){return`remove:${a.id||a.directory}`}function et(a,s){return`target:${a}:${s}`}function we(a){return a.id||a.directory}function ba(a){return a.manageable!==!1}function Gr({target:a,state:s,busy:d,disabled:l,disabledLabel:p,onToggle:h}){const x=s==="synced",u=s==="orphan",y=u?r("skills.dot.orphan_aria",{agent:a.label}):x?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),w=l&&p?`${y} — ${p}`:y;return e.jsxs("button",{type:"button",title:w,"aria-label":w,"aria-pressed":x,disabled:d||l,onClick:b=>{b.stopPropagation(),h?.(a.id,!x)},className:"relative flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/40 disabled:cursor-not-allowed dark:hover:bg-oai-gray-800/60",children:[d?e.jsx(Z,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:Q("flex h-[18px] w-[18px] items-center justify-center transition",x&&Vr[a.id],!x&&!u&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(ve,{provider:a.id,size:18})}),u&&!d?e.jsx("span",{className:"absolute -bottom-px -right-px h-2 w-2 rounded-full bg-amber-500 ring-2 ring-oai-white dark:ring-oai-gray-900","aria-hidden":!0}):null]})}function Xr({skill:a,targets:s,onToggleTarget:d,busyKey:l}){const p=new Set(a.targets||[]),h=!!(a.readOnly||a.remote),x=[];for(const u of s)(h?p.has(u.id):ba(u))&&x.push(u);return e.jsx("div",{className:"flex items-center gap-1",onClick:u=>u.stopPropagation(),children:x.map(u=>e.jsx(Gr,{target:u,state:a.targetStates?.[u.id]||"off",busy:l===et(we(a),u.id),disabled:h||u.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,w)=>d?.(a,y,w)},u.id))})}function Jr({skill:a,targets:s,selected:d,onSelect:l,selectable:p,checked:h,onToggleSelect:x,onToggleTarget:u,hasUpdate:y,busyKey:w}){const b=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,S=[a.directory,b,a.sourceName].filter(Boolean).join(" · "),k=Array.isArray(a.deviceSources)?a.deviceSources:[],c=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),g=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l?.(a))};return e.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":d,"aria-label":r("skills.row.open_details",{name:a.name||a.directory}),onClick:()=>l?.(a),onKeyDown:g,className:Q("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",d?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":h?"bg-oai-gray-50 dark:bg-oai-gray-900/40":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[p?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:h,onChange:m=>x?.(a,m.target.checked),"aria-label":r("skills.select.row_aria",{name:a.name||a.directory}),className:"h-4 w-4 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white"})}):null,e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:S,children:a.name||a.directory}),c.map(m=>e.jsx("span",{className:"inline-flex shrink-0 rounded-full bg-oai-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-oai-gray-600 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800 dark:text-oai-gray-300 dark:ring-oai-gray-700",children:m},m)),y?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-semibold text-sky-700 ring-1 ring-sky-200 dark:bg-sky-950/40 dark:text-sky-300 dark:ring-sky-800/60",children:[e.jsx(ya,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Xr,{skill:a,targets:s,onToggleTarget:u,busyKey:w}),e.jsx(Ut,{className:Q("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",d&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),a.description?e.jsx("p",{className:Q("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",p&&"pl-7"),children:a.description}):null,a.sourceName||k.length?e.jsxs("div",{className:Q("mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",p&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,k.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:k.map(m=>m.name).join(", "),children:[e.jsx(Pa,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:k.map(m=>m.name).join(", ")})})]}):null]}):null]})}function Qr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:l,totalCount:p,anyFilter:h,onClearFilters:x,searchQuery:u,onSearchQuery:y,searchPlaceholder:w}){return 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.jsxs(Da,{value:a,onValueChange:d,children:[e.jsxs(Ba,{"aria-label":r("skills.filter.agent_label"),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200 dark:hover:border-oai-gray-700",children:[e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:[r("skills.filter.agent_label"),":"]}),e.jsx(Ta,{children:b=>b==="all"?r("skills.filter.agent_all"):s.find(S=>S.id===b)?.label||b}),e.jsx(qa,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Aa,{children:e.jsx(Ea,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] 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(ta,{value:"all",className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.filter.agent_all")}),e.jsx(sa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(b=>e.jsxs(ta,{value:b.id,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{provider:b.id,size:14}),e.jsx(ra,{children:b.label})]}),e.jsx(sa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},b.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ga,{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(xa,{type:"search",value:u,onChange:b=>y(b.target.value),onKeyDown:b=>{b.key==="Escape"&&u&&(b.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:w,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:b=>b.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!u,tabIndex:u?0:-1,className:Q("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 before:absolute before:-inset-1.5 before:content-[''] 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 motion-reduce:transition-none dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",u?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{role:"status","aria-live":"polite",className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.filter.result_count",{filtered:l,total:p})}),h?e.jsxs("button",{type:"button",onClick:x,className:"shrink-0 inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Ie,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Yr({count:a,targets:s,busy:d,onBulkSync:l,onBulkRemove:p,onClear:h}){const x=s.filter(ba);return e.jsxs("div",{role:"toolbar","aria-label":r("skills.select.toolbar_aria"),className:"mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/50",children:[e.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:r("skills.select.count",{count:a})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(za,{children:[e.jsxs(Fa,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Ua,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(pa,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Wa,{className:"min-w-[200px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.select.bulk_sync_hint")}),x.map(u=>e.jsxs("button",{type:"button",onClick:()=>l(u.id),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx(ve,{provider:u.id,size:16}),e.jsx("span",{className:"flex-1",children:u.label})]},u.id))]})})})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:p,children:[e.jsx(fa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex h-7 items-center gap-1 rounded-full px-2 text-[11px] font-medium text-oai-gray-500 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",children:[e.jsx(Ie,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Zr({items:a,totalCount:s,targets:d,agentOptions:l,agentFilter:p,onAgentFilter:h,anyFilter:x,onClearFilters:u,searchQuery:y,onSearchQuery:w,searchPlaceholder:b,selectedId:S,onSelect:k,onToggleTarget:c,busyKey:g,updates:m,selectedIds:v,onToggleSelect:_,onClearSelection:$,onBulkSync:M,onBulkRemove:K,updateCount:de,onUpdateAll:fe}){const ne=v.size;return e.jsxs("div",{children:[ne>0?e.jsx(Yr,{count:ne,targets:d,busy:g==="batch",onBulkSync:M,onBulkRemove:K,onClear:$}):e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx(Qr,{agentFilter:p,agentOptions:l,onAgentFilter:h,filteredCount:a.length,totalCount:s,anyFilter:x,onClearFilters:u,searchQuery:y,onSearchQuery:w,searchPlaceholder:b}),de?e.jsxs(J,{type:"button",variant:"secondary",size:"sm",className:"mb-2 shrink-0",disabled:!!g,onClick:fe,children:[g==="update-all"?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ya,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.update.all_action",{count:de})]}):null]}),a.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r("skills.empty.no_match")}),e.jsx(J,{type:"button",variant:"secondary",size:"sm",onClick:u,children:r("skills.filter.clear")})]}):e.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(D=>e.jsx(Jr,{skill:D,targets:d,selected:S===(D.id||D.directory),onSelect:k,selectable:!D.readOnly&&!D.remote,checked:v.has(we(D)),onToggleSelect:_,onToggleTarget:c,hasUpdate:!!(D.id&&m?.[D.id]),busyKey:g},we(D)))})]})}const es={contentVisibility:"auto",containIntrinsicSize:"0 240px"},as=Mt.memo(function({skill:s,installed:d,installing:l,allTargets:p,defaultTargets:h,onInstall:x,onManage:u}){const[y,w]=i.useState(()=>(h||[]).filter(m=>p.some(v=>v.id===m))),b=m=>{w(v=>v.includes(m)?v.filter(_=>_!==m):[...v,m])},S=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,k=S?`https://github.com/${s.repoOwner}/${s.repoName}`:null,c=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,g=y.length?y.map(m=>p.find(v=>v.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Ft,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[s.readmeUrl?e.jsxs("a",{href:s.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:s.readmeUrl,children:[e.jsx("span",{className:"truncate",children:s.name||s.directory}),e.jsx(ma,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),S||c?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[k?e.jsxs("a",{href:k,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"inline-flex items-center gap-1 truncate rounded text-oai-gray-500 hover:text-oai-black hover:underline focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-400 dark:hover:text-white",title:k,children:[e.jsx("span",{className:"truncate",children:S}),e.jsx(ma,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,S&&c?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,c?e.jsx("span",{className:"truncate",children:c}):null]}):null]})}),s.description?e.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:s.description}):null,e.jsx("div",{className:"mt-auto pt-5",children:d?e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:()=>u?.(s),className:"w-full",children:[e.jsx(Le,{className:"mr-1.5 h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400","aria-hidden":!0}),r("skills.card.manage")]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.card.targets_prefix")}),e.jsx("span",{className:"min-w-0 truncate font-medium text-oai-black dark:text-white",children:y.length?g:r("skills.target.none")}),e.jsxs(za,{children:[e.jsx(Fa,{disabled:l,"aria-label":r("skills.action.choose_targets"),className:"rounded text-xs font-medium text-oai-gray-500 underline decoration-oai-gray-300 decoration-dotted underline-offset-2 transition hover:text-oai-black hover:decoration-oai-gray-500 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:cursor-not-allowed disabled:opacity-60 dark:text-oai-gray-400 dark:decoration-oai-gray-600 dark:hover:text-white dark:hover:decoration-oai-gray-400",children:r("skills.card.targets_change")}),e.jsx(Va,{children:e.jsx(Ka,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(Wa,{className:"min-w-[220px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[e.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.target.menu_label")}),p.map(m=>{const v=y.includes(m.id);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm text-oai-black hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-oai-gray-300 text-oai-black focus:ring-oai-gray-400 dark:border-oai-gray-600 dark:bg-oai-gray-900 dark:text-white",checked:v,onChange:()=>b(m.id)}),e.jsx(ve,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(J,{type:"button",size:"sm",onClick:()=>x(s,y),disabled:l||y.length===0,className:"w-full",children:[l?e.jsx(Z,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Ua,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function ts({repos:a,repoInput:s,onRepoInput:d,busyKey:l,onAdd:p,onRemove:h}){return e.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(xa,{value:s,onChange:x=>d(x.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(J,{type:"button",variant:"secondary",size:"md",onClick:p,disabled:l==="repo:add",className:"shrink-0 whitespace-nowrap",children:[l==="repo:add"?e.jsx(Z,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ma,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.repo.add")]})]}),a.length?e.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:a.map(x=>{const u=l===`repo:${x.owner}/${x.name}`;return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[x.owner,"/",x.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:x.branch})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:u,onClick:()=>h(x),className:"shrink-0",children:[u?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(fa,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${x.owner}/${x.name}`)})}):null]})}function rs(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ts(){const a=Tt()||{},s=!!a.signedIn,d=a.getAccessToken,[l,p]=i.useState(rs),[h,x]=i.useState({skills:[],targets:[]}),[u,y]=i.useState([]),[w,b]=i.useState([]),[S,k]=i.useState([]),[c,g]=i.useState(xe),[m,v]=i.useState(""),[_,$]=i.useState(""),[M,K]=i.useState(""),[de,fe]=i.useState(""),[ne,D]=i.useState(""),[pe,I]=i.useState(!1),[U,W]=i.useState("all"),[T,ee]=i.useState(null),[Y,je]=i.useState(""),ce=i.useRef(!1),[Pe,He]=i.useState(!0),[De,Be]=i.useState(!1),[R,L]=i.useState(""),[H,B]=i.useState(null),[ae,P]=i.useState(null),[Ne,Te]=i.useState(null),[ie,Ae]=i.useState(()=>new Set),[ue,Ee]=i.useState({}),[Oe,qe]=i.useState({}),[Ce,$e]=i.useState([]),[me,Ge]=i.useState(!1),Me=i.useRef(!1),te=i.useRef(0),A=i.useMemo(()=>qr(h.skills),[h.skills]),Se=i.useCallback(async()=>{const t=++te.current,n=await rr();if(te.current!==t)return;const o={skills:n.skills||[],targets:n.targets||[]};x(o);const f=At();!s||!Et()||!f||typeof d!="function"||(async()=>{try{const j=await d();if(!j||te.current!==t)return;const[C]=await Promise.allSettled([sr(j),nr({accessToken:j,deviceId:f,skills:o.skills})]);if(C.status!=="fulfilled")return;const ke=C.value;if(te.current!==t)return;x({targets:o.targets,skills:ir(o.skills,ke,f)})}catch{}})()},[d,s]),ge=i.useCallback(async()=>{const t=await or();k(t.repos||[])},[]),q=i.useCallback(async({force:t=!1}={})=>{Be(!0);try{const n=await lr({force:t});y(n.skills||[])}finally{Be(!1)}},[]),he=i.useCallback(async({force:t=!1}={})=>{Ge(!0);try{const n=await dr({force:t});$e(n.skills||[])}finally{Ge(!1)}},[]),E=i.useCallback(async()=>{try{const t=await cr();Ee(t?.updates||{})}catch{}},[]),Ue=i.useCallback(t=>{const n=new Set((t||[]).filter(Boolean));n.size&&Ee(o=>{if(!Object.keys(o).some(j=>n.has(j)))return o;const f={};for(const[j,C]of Object.entries(o))n.has(j)||(f[j]=C);return f})},[]),ye=i.useCallback(async()=>{try{const t=await ur(),n={};for(const o of t?.skills||[])o.installed&&(o.directory&&(n[String(o.directory).toLowerCase()]=o),n[String(o.skill).toLowerCase()]=o);qe(n)}catch{qe({})}},[]),_e=i.useCallback(async()=>{He(!0),L("");try{await Promise.all([Se(),ge()])}catch(t){L(t?.message||r("skills.error.generic"))}finally{He(!1)}},[Se,ge]),ia=i.useCallback(async()=>{await _e();const t=n=>L(n?.message||r("skills.error.generic"));l==="my"?(E(),ye()):c===X?he({force:!0}).catch(t):c!==V&&q({force:!0}).catch(t)},[q,_e,he,E,ye,c,l]);i.useEffect(()=>{_e()},[_e]),i.useEffect(()=>{if(Me.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){Me.current=!0;return}const o=h.skills||[];if(!o.length)return;const f=o.find(C=>C.directory===n||C.id===n);f&&(p("my"),ee(f.id||f.directory)),Me.current=!0,t.delete("skill");const j=t.toString();window.history.replaceState({},"",`${window.location.pathname}${j?`?${j}`:""}${window.location.hash}`)},[h.skills]),i.useEffect(()=>{l==="browse"&&(c===V||c===X||u.length===0&&q().catch(t=>L(t?.message||r("skills.error.generic"))))},[u.length,q,c,l]),i.useEffect(()=>{l!=="browse"||c!==X||Ce.length===0&&he().catch(t=>L(t?.message||r("skills.error.generic")))},[he,Ce.length,c,l]);const Xe=Object.keys(ue).length>0,Je=Object.keys(Oe).length>0;if(i.useEffect(()=>{l==="my"&&(Xe||E(),Je||ye())},[l,Xe,Je,E,ye]),i.useEffect(()=>{const t=setTimeout(()=>$(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>fe(M),120);return()=>clearTimeout(t)},[M]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(l==="my"){if(!n)return;t.delete("tab")}else{if(n===l)return;t.set("tab",l)}const o=t.toString(),f=`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`;window.history.replaceState({},"",f)},[l]),!Fr&&!Ot())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(zt,{})});const z=async(t,n)=>{if(!ce.current){ce.current=!0,je(t),L("");try{await n(),await Se()}catch(o){L(o?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},oa=(t,n)=>{const o=(n&&n.length?n:_a).filter(f=>(h.targets||[]).some(j=>j.id===f));z(aa(t),async()=>{await gr(t,o);const f=o.map(j=>(h.targets||[]).find(C=>C.id===j)?.label||j).join(", ");G({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},Qe=t=>{t?.readOnly||t?.remote||B(t)},ze=()=>{const t=H;t&&(B(null),z(Ia(t),async()=>{let n=null;t.managed?n=await va(t.id):await ja(t.directory,t.targets||[]),Ue([t.id]);const o=!!(n?.trashed&&t.managed&&t.id);G({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:o?{onUndo:async()=>{try{await hr(t.id),await Se()}catch(f){L(f?.message||r("skills.error.generic"))}}}:void 0})}))},N=(t,n,o)=>t?.readOnly||t?.remote?Promise.resolve():z(et(we(t),n),async()=>{const f=new Set(t.targets||[]);o?f.add(n):f.delete(n),t.managed?await Na(t.id,Array.from(f)):await Ca(t.directory,Array.from(f));const j={name:t.name||t.directory,agent:re(n)};G({title:o?r("skills.toast.synced_one",j):r("skills.toast.unsynced_one",j),timeout:3e3})}),F=i.useCallback(()=>Ae(new Set),[]),oe=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const o=we(t);Ae(f=>{const j=new Set(f);return n?j.add(o):j.delete(o),j})},[]),re=t=>(h.targets||[]).find(n=>n.id===t)?.label||t,Re=t=>{const n=(h.skills||[]).filter(o=>ie.has(we(o))&&!o.readOnly&&!o.remote);n.length&&z("batch",async()=>{for(const o of n){const f=new Set(o.targets||[]);f.add(t),o.managed?await Na(o.id,Array.from(f)):await Ca(o.directory,Array.from(f))}F(),G({title:r("skills.toast.bulk_synced",{count:n.length,agent:re(t)}),timeout:4e3})})},Fe=()=>{const t=(h.skills||[]).filter(n=>ie.has(we(n))&&!n.readOnly&&!n.remote);t.length&&P(t)},Ve=()=>{const t=ae;t&&(P(null),z("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);Ue(t.map(n=>n.id)),F(),G({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},at=t=>{!t?.id||!t?.repoOwner||!t?.repoName||z(aa(t),async()=>{const n=await Sa([t.id]);await E();const{results:o=[],rateLimited:f=null,updated:j=0}=n||{};if(f){G({title:r("skills.update.rate_limited",{count:j}),timeout:6e3});return}const C=o[0];if(!C||!C.ok)throw new Error(C?.error||r("skills.error.generic"));G({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},tt=new Set((h.skills||[]).map(t=>t.id).filter(Boolean)),la=Object.entries(ue).filter(([t,n])=>n&&tt.has(t)).map(([t])=>t),rt=la.length,st=()=>{la.length&&Te(la)},nt=()=>{const t=Ne;Te(null),!(!t||!t.length)&&z("update-all",async()=>{const n=await Sa(t);await E();const{updated:o=0,failed:f=0,rateLimited:j=null,results:C=[]}=n||{},ke=C.length;if(j)G({title:r("skills.update.rate_limited",{count:o}),timeout:6e3});else if(f>0)G({title:r("skills.toast.updated_partial",{count:o,total:ke,failed:f}),timeout:6e3});else if(o===0)G({title:r("skills.toast.updated_none"),timeout:4e3});else if(o===1){const O=C.find(ea=>ea.ok&&!ea.skipped);G({title:r("skills.toast.updated",{name:O?.name||""}),timeout:4e3})}else G({title:r("skills.toast.updated_many",{count:o}),timeout:4e3})})},ka=async()=>{const t=m.trim();if(!(t.length<2||ce.current)){ce.current=!0,je("search"),L("");try{const n=await mr(t);b(n.skills||[])}catch(n){L(n?.message||r("skills.error.generic"))}finally{ce.current=!1,je("")}}},it=async()=>{const t=ne.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,o]=t.split("/");if(!n||!o){L(r("skills.repo.invalid"));return}await z("repo:add",async()=>{await fr({owner:n,name:o,branch:"main",enabled:!0}),D(""),await ge(),await q()})},ot=async t=>{await z(`repo:${t.owner}/${t.name}`,async()=>{await xr(t.owner,t.name),await ge(),await q()})},le=h.targets||[],lt=le.filter(ba),be=h.skills||[],dt=i.useMemo(()=>{const t=U==="all"?be:be.filter(o=>(o.targets||[]).includes(U)),n=de.trim().toLowerCase();return n?t.filter(o=>(o.name||"").toLowerCase().includes(n)||(o.directory||"").toLowerCase().includes(n)||(o.description||"").toLowerCase().includes(n)):t},[be,U,de]),ct=U!=="all",se=i.useMemo(()=>T&&be.find(t=>(t.id||t.directory)===T)||null,[be,T]),ut=i.useCallback(()=>{W("all"),K("")},[]),mt=i.useCallback(t=>{ee(n=>{const o=t?.id||t?.directory||null;return n===o?null:o})},[]),gt=i.useCallback(()=>ee(null),[]),ht=i.useCallback(t=>{const n=na(t).toLowerCase(),o=Ra(t),f=(h.skills||[]).find(j=>{const C=Za(j);return C.has(n)||o&&C.has(o)});f&&ee(f.id||f.directory)},[h.skills]);i.useEffect(()=>{l!=="my"&&ie.size&&Ae(new Set)},[l,ie.size]),i.useEffect(()=>{T&&!se&&ee(null)},[se,T]);const Ke=i.useMemo(()=>{const t=c===V?w:c===X?Ce:u,o=c===V||c===X||c===xe?t:t.filter(C=>`${C.repoOwner}/${C.repoName}`===c),f=_.trim().toLowerCase();return(c===V||!f?o:o.filter(C=>(C.name||"").toLowerCase().includes(f)||(C.directory||"").toLowerCase().includes(f)||(C.description||"").toLowerCase().includes(f))).map(C=>{const ke=na(C).toLowerCase(),O=Ra(C);return{...C,installed:A.has(ke)||O&&A.has(O)}})},[_,u,A,Ce,w,c]),xt=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Z,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),ft=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(Z,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.browse.loading_hint")})]}),Ye=(t,n=null)=>e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[e.jsx("p",{children:r(t)}),n]});let Ze;if(Pe)Ze=xt;else if(l==="my")Ze=be.length?e.jsx(Zr,{items:dt,totalCount:be.length,targets:le,agentOptions:le,agentFilter:U,onAgentFilter:W,anyFilter:ct,onClearFilters:ut,searchQuery:M,onSearchQuery:K,searchPlaceholder:r("skills.my.placeholder"),selectedId:T,onSelect:mt,onToggleTarget:N,busyKey:Y,updates:ue,selectedIds:ie,onToggleSelect:oe,onClearSelection:F,onBulkSync:Re,onBulkRemove:Fe,updateCount:rt,onUpdateAll:st}):e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[le.length>0?e.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`b-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:e.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...le,...le].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(ve,{provider:t.id,size:30})},`c-${n}`))})}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:r("skills.empty.my")}),e.jsx(J,{type:"button",size:"sm",onClick:()=>p("browse"),children:r("skills.empty.my_cta")})]});else{const t=c===V,n=c===X,o=S.length===0&&!t&&!n,f=De&&!t&&!n||n&&me,j=!t&&!n&&(_.trim()!==""||c!==xe),C=()=>{v(""),g(xe)},ke=!o&&!f&&(Ke.length>0||j)?e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 px-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("skills.filter.result_count_browse",{count:Ke.length})}),j?e.jsxs("button",{type:"button",onClick:C,className:"ml-auto inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[e.jsx(Ie,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let O;o?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:e.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:r("skills.browse.empty_sources")})}):f?O=ft:t&&m.trim().length<2?O=e.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 px-4 py-6 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:r("skills.browse.hint_skillssh")}):Ke.length?O=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ke.map(We=>e.jsx("div",{style:es,children:e.jsx(as,{skill:We,installed:!!We.installed,installing:Y===aa(We),allTargets:lt,defaultTargets:_a,onInstall:oa,onManage:ht})},We.id||We.key))}):j?O=Ye("skills.empty.no_match",e.jsx(J,{type:"button",variant:"secondary",size:"sm",onClick:C,children:r("skills.filter.clear")})):t?O=Ye("skills.empty.search"):n?O=Ye("skills.empty.popular"):O=Ye("skills.empty.browse");const ea=o||pe?e.jsx("div",{className:"mb-5",children:e.jsx(ts,{repos:S,repoInput:ne,onRepoInput:D,busyKey:Y,onAdd:it,onRemove:ot})}):null,pt=!pe&&!t&&!n&&S.length<=1&&Ke.length>0?e.jsx(wr,{id:"skills-browse-intro",className:"mt-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{children:r("skills.browse.add_repo_hint")}),e.jsx("button",{type:"button",onClick:()=>I(!0),className:"rounded font-medium text-oai-gray-700 underline decoration-dotted underline-offset-2 transition hover:text-oai-black focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:text-oai-gray-200 dark:hover:text-white",children:r("skills.browse.manage_sources")})]})}):null;Ze=e.jsxs(e.Fragment,{children:[ea,ke,O,pt]})}return e.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[e.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:r("skills.page.title")}),e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:ia,disabled:Pe||De||me,children:[e.jsx($t,{className:Q("mr-1.5 h-3.5 w-3.5",(Pe||De||me)&&"animate-spin"),"aria-hidden":!0}),r("skills.action.refresh")]})]}),e.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",r("skills.tab.my")],["browse",r("skills.tab.browse")]].map(([t,n])=>e.jsx("button",{type:"button","aria-pressed":l===t,onClick:()=>p(t),className:Q("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",l===t?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:n},t))}),R?e.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-200",children:R}):null,l==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(yr,{className:"shrink-0",ariaLabel:r("skills.source.label"),options:[{id:"repo",label:r("skills.mode.repo")},{id:"popular",label:r("skills.mode.popular"),icon:e.jsx(pr,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:c===V?"skillssh":c===X?"popular":"repo",onChange:t=>{t==="skillssh"?g(V):t==="popular"?g(X):(c===V||c===X)&&g(xe)}}),c!==V&&c!==X?e.jsxs(Da,{value:c,onValueChange:g,children:[e.jsxs(Ba,{"aria-label":r("skills.source.label"),className:"inline-flex h-8 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[e.jsx(Ta,{children:t=>t===xe?r("skills.source.all"):t}),e.jsx(qa,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Aa,{children:e.jsx(Ea,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Oa,{className:"min-w-[var(--anchor-width)] 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 transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-[0.97] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0 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(ta,{value:xe,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:r("skills.source.all")}),e.jsx(sa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),S.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(ta,{value:n,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[e.jsx(ra,{children:n}),e.jsx(sa,{children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ga,{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(xa,{type:"search",value:m,onChange:t=>v(t.target.value),onKeyDown:t=>{t.key==="Enter"&&c===V&&ka()},"aria-label":r("skills.action.search_aria"),placeholder:c===V?r("skills.browse.placeholder_skillssh"):c===X?r("skills.browse.placeholder_popular"):c===xe?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:c}),className:"h-8 pl-9 !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"})]}),c===V?e.jsxs(J,{type:"button",size:"sm",onClick:ka,disabled:m.trim().length<2||Y==="search",className:"focus:!ring-oai-gray-400/30",children:[Y==="search"?e.jsx(Z,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ga,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):c===X?null:e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:()=>I(t=>!t),"aria-expanded":pe,className:"!h-8 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[e.jsx(Ma,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.browse.manage_sources"),e.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:S.length})]})]}):null,Ze,e.jsx(Ur,{skill:se,targets:le,busyKey:Y,usage:se&&(Oe[String(se.directory||"").toLowerCase()]||Oe[String(se.name||"").toLowerCase()])||null,hasUpdate:!!(se?.id&&ue?.[se.id]),updating:se?Y===aa(se):!1,onUpdate:at,onClose:gt,onToggleTarget:N,onRemove:Qe})]})}),e.jsx(da,{open:!!H,title:r("skills.confirm.remove_title",{name:H?.name||H?.directory||""}),description:H?H.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:Y===Ia(H||{}),onCancel:()=>B(null),onConfirm:ze}),e.jsx(da,{open:!!ae,title:r("skills.confirm.bulk_remove_title",{count:ae?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:Y==="batch",onCancel:()=>P(null),onConfirm:Ve}),e.jsx(da,{open:!!Ne,title:r("skills.confirm.update_all_title",{count:Ne?.length||0}),description:r("skills.confirm.update_all_desc"),confirmLabel:r("skills.update.action"),cancelLabel:r("shared.action.cancel"),onCancel:()=>Te(null),onConfirm:nt})]})}export{Ts as SkillsPage,qr as buildLocallyInstalledKeys};
|