tokentracker-cli 0.94.0 → 0.95.0

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.
Files changed (130) hide show
  1. package/README.de.md +9 -7
  2. package/README.ja.md +8 -6
  3. package/README.ko.md +8 -6
  4. package/README.md +23 -10
  5. package/README.zh-CN.md +8 -6
  6. package/dashboard/dist/assets/{AchievementBadge-DPqwk2zI.js → AchievementBadge-Pi3Gvbm8.js} +1 -1
  7. package/dashboard/dist/assets/{AchievementsPage-CELHoMQt.js → AchievementsPage-C4WLT8Rl.js} +2 -2
  8. package/dashboard/dist/assets/{AchievementsSection-DdAC0VCb.js → AchievementsSection-ilvR2ssr.js} +1 -1
  9. package/dashboard/dist/assets/{BadgeDetailModal-Dd4I1SpM.js → BadgeDetailModal-CjEeToxa.js} +1 -1
  10. package/dashboard/dist/assets/{BotAnimated-DL2-4mnm.js → BotAnimated-DDf9pBuK.js} +1 -1
  11. package/dashboard/dist/assets/{Card-B_MpSRse.js → Card-DNous84-.js} +1 -1
  12. package/dashboard/dist/assets/{ClawdAnimated-BLZZ4rG6.js → ClawdAnimated-BLMIRntb.js} +2 -2
  13. package/dashboard/dist/assets/{CommandPalette-B-vfdIbH.js → CommandPalette-vVekhoFO.js} +1 -1
  14. package/dashboard/dist/assets/CommunityStatsModal-C0Kp_J8B.js +1 -0
  15. package/dashboard/dist/assets/{ConfirmModal-DLnRwUXC.js → ConfirmModal-DFdpcx12.js} +1 -1
  16. package/dashboard/dist/assets/{Controls-FZ8wEN5w.js → Controls-RNhqybmE.js} +1 -1
  17. package/dashboard/dist/assets/DashboardPage-BQjQh1IQ.js +1 -0
  18. package/dashboard/dist/assets/{DevicePage-D2IzPc5o.js → DevicePage-DIhh-YAk.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-BaqQaUUk.js → DialogClose-ZqxYVIzl.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-DDM4aanX.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-DrbKjtuS.js → DialogTitle-BiRcejlu.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-GddKDE8i.js → FadeIn-BDBQpeGe.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-DUu-Z5mE.js → HeaderGithubStar-CztIwtKT.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-BmDkY35A.js → HoverTooltip-Cfso7LTC.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-CGJyqWk2.js → IpCheckPage-CNE7dLs3.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-Bd91ALUj.js → LandingPage-B2a3cweM.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardAvatar-BGGUwXFd.js → LeaderboardAvatar-CwmZnIji.js} +1 -1
  28. package/dashboard/dist/assets/{LeaderboardPage-BMEqHwif.js → LeaderboardPage-DkTHj3fB.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-BSweJqm2.js → LeaderboardProfileModal-CefTO3Zh.js} +3 -3
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-CRrI3RFz.js → LeaderboardProfilePage-CnOXlQ3L.js} +1 -1
  31. package/dashboard/dist/assets/{LimitsPage-XIRDv46K.js → LimitsPage-BIZ1-6BB.js} +2 -2
  32. package/dashboard/dist/assets/{LocalOnlyNotice-CCD-lGWG.js → LocalOnlyNotice-CdHQiPhy.js} +1 -1
  33. package/dashboard/dist/assets/{LoginCard-lDuqSv4f.js → LoginCard-yXLA9geu.js} +1 -1
  34. package/dashboard/dist/assets/{LoginModal-DStt5VXN.js → LoginModal-BF2Pfkqa.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-dmVPSL72.js → LoginPage-DuOypZap.js} +1 -1
  36. package/dashboard/dist/assets/{PetPage-ybcZRctF.js → PetPage-BH3xDVV9.js} +1 -1
  37. package/dashboard/dist/assets/{PopoverPopup-Dar_UjxF.js → PopoverPopup-CewF_cGz.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-Ct9tILpz.js → ProviderIcon-Dg0K0RPn.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-B4yLh5zx.js → ResetPasswordPage-CYwt85O3.js} +1 -1
  40. package/dashboard/dist/assets/{SegmentedControl-BOE1CEzq.js → SegmentedControl-BJkXXomQ.js} +1 -1
  41. package/dashboard/dist/assets/{Select-D-bSh7Zz.js → Select-B3_WH0Qe.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-DMYjXXq4.js → SelectItemText-BUby_DUu.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-CaleS-6_.js → ServiceStatusPage-BDlVZk4i.js} +1 -1
  44. package/dashboard/dist/assets/SessionsPage-TaC9nahK.js +2 -0
  45. package/dashboard/dist/assets/{SettingsPage-iJH0Yyah.js → SettingsPage-CudcQh6m.js} +2 -2
  46. package/dashboard/dist/assets/SkillsPage-iDLQ8lpZ.js +1 -0
  47. package/dashboard/dist/assets/{TokenGalaxy-CuXKoMPg.js → TokenGalaxy-DtYzUsXU.js} +1 -1
  48. package/dashboard/dist/assets/{ToolbarRootContext-Dx5GB7F5.js → ToolbarRootContext-PC8Tg1Jz.js} +1 -1
  49. package/dashboard/dist/assets/TrendMonitor-r8n8YO_9.js +19 -0
  50. package/dashboard/dist/assets/{WidgetsPage-DUaIyGtu.js → WidgetsPage-vzfGccWb.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-BzqlcAUC.js → WrappedPage-DaKuIkYE.js} +1 -1
  52. package/dashboard/dist/assets/{__vite-browser-external-BHz2N7Ih.css → __vite-browser-external-CCMdjCX2.css} +1 -1
  53. package/dashboard/dist/assets/__vite-browser-external-Dnxl50k1.js +45 -0
  54. package/dashboard/dist/assets/{agent-logos-BdWWxza6.js → agent-logos-B7nzn3n2.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-CANSzmm-.js → arrow-up-right-CsxyvCER.js} +1 -1
  56. package/dashboard/dist/assets/{check-BnJpzXRZ.js → check-hYcC7MdH.js} +1 -1
  57. package/dashboard/dist/assets/{composite-Ccj6KQmh.js → composite-C79LNbex.js} +1 -1
  58. package/dashboard/dist/assets/{copy-C2Yc8Evu.js → copy-Cz4qzE62.js} +1 -1
  59. package/dashboard/dist/assets/{download-B52JTk6Y.js → download-CUaSNE2E.js} +1 -1
  60. package/dashboard/dist/assets/{external-link-DayTwZx-.js → external-link-vq7kIyKK.js} +1 -1
  61. package/dashboard/dist/assets/{flame-B8GEX2yT.js → flame-CB6K4eR6.js} +1 -1
  62. package/dashboard/dist/assets/{format-tokens-mhkbohkb.js → format-tokens-KI-e_JQ-.js} +1 -1
  63. package/dashboard/dist/assets/{icons-o8bPXqRP.js → icons-3maItkrp.js} +1 -1
  64. package/dashboard/dist/assets/{index-MBVWUKpA.js → index-BRXoZ7Jj.js} +1 -1
  65. package/dashboard/dist/assets/{index-CK_CduLm.js → index-C5WrfmLB.js} +1 -1
  66. package/dashboard/dist/assets/{index-Bp0ZHDtz.js → index-CUbC50Zp.js} +1 -1
  67. package/dashboard/dist/assets/{info-D94QM_vX.js → info-r0yGihUe.js} +1 -1
  68. package/dashboard/dist/assets/{limits-providers-BLzMyCiy.js → limits-providers-BN_94oe9.js} +1 -1
  69. package/dashboard/dist/assets/{link-2-CqBmFaDI.js → link-2-J9t0VXWM.js} +1 -1
  70. package/dashboard/dist/assets/{loader-circle-SaxUpDR6.js → loader-circle-DCvOsPze.js} +1 -1
  71. package/dashboard/dist/assets/{maximize-2-BoXqARks.js → maximize-2-CZ9JhGjf.js} +1 -1
  72. package/dashboard/dist/assets/{modifiers.esm-Conh_-BD.js → modifiers.esm-DJ0_WKg0.js} +1 -1
  73. package/dashboard/dist/assets/module-xpSFyNBK.js +3 -0
  74. package/dashboard/dist/assets/{monitor-smartphone-D6qLR9qd.js → monitor-smartphone-nqbWjJx_.js} +1 -1
  75. package/dashboard/dist/assets/{plus-D51mjIc2.js → plus-Cg7wd2jK.js} +1 -1
  76. package/dashboard/dist/assets/{provider-display-DpHPjd_s.js → provider-display-B9L1nRY9.js} +2 -2
  77. package/dashboard/dist/assets/{react-D_AcI466.js → react-D2AD6Pk2.js} +1 -1
  78. package/dashboard/dist/assets/{search-CwLcNdvZ.js → search-uNiWba1h.js} +1 -1
  79. package/dashboard/dist/assets/{skills-api-Dqi7Mjgo.js → skills-api-BBYuAhiL.js} +1 -1
  80. package/dashboard/dist/assets/{sortable.esm-BPDlUxPb.js → sortable.esm-CzPxc949.js} +1 -1
  81. package/dashboard/dist/assets/{store-ikeRIRGd.js → store-D4A7EUwE.js} +1 -1
  82. package/dashboard/dist/assets/{terminal-BfeX3L5T.js → terminal-Crmm_yKF.js} +1 -1
  83. package/dashboard/dist/assets/{trash-2-5_Qlp1k7.js → trash-2-ia9VjRnU.js} +1 -1
  84. package/dashboard/dist/assets/{use-community-stats-D90Fy2_j.js → use-community-stats-KaGCAxaF.js} +1 -1
  85. package/dashboard/dist/assets/use-latest-request-guard-Dy8gSDkk.js +1 -0
  86. package/dashboard/dist/assets/{use-limits-display-prefs-D4BYFaa-.js → use-limits-display-prefs-JSTYlbTD.js} +1 -1
  87. package/dashboard/dist/assets/{use-ordered-list-DJxLNdXY.js → use-ordered-list-C4JnHdE0.js} +1 -1
  88. package/dashboard/dist/assets/use-reduced-motion-AQE0ummK.js +1 -0
  89. package/dashboard/dist/assets/{use-session-efficiency-pref-CAX_GqXc.js → use-session-efficiency-pref-CgyUz5Gc.js} +1 -1
  90. package/dashboard/dist/assets/{use-transform-CeW6Z5R0.js → use-transform-C7-jSJ9k.js} +1 -1
  91. package/dashboard/dist/assets/use-usage-limits-B3YYqn-v.js +1 -0
  92. package/dashboard/dist/assets/{useCurrency-BarGeFyK.js → useCurrency-CK_gcb3J.js} +1 -1
  93. package/dashboard/dist/assets/{useTokenFormat-DUJ9iT9H.js → useTokenFormat-C_a-UkCA.js} +1 -1
  94. package/dashboard/dist/assets/{zap--m0IWoI3.js → zap-BIJNn-Ic.js} +1 -1
  95. package/dashboard/dist/brand-logos/lmstudio.svg +12 -0
  96. package/dashboard/dist/brand-logos/unsloth.svg +1 -0
  97. package/dashboard/dist/index.html +16 -12
  98. package/dashboard/dist/ip-check.html +2 -2
  99. package/dashboard/dist/leaderboard.html +2 -2
  100. package/dashboard/dist/llms.txt +4 -2
  101. package/dashboard/dist/share.html +2 -2
  102. package/package.json +2 -2
  103. package/src/commands/device-login.js +5 -10
  104. package/src/commands/init.js +28 -1
  105. package/src/commands/serve.js +6 -0
  106. package/src/commands/status.js +24 -0
  107. package/src/commands/sync.js +114 -18
  108. package/src/lib/cloud-account.js +102 -29
  109. package/src/lib/fs.js +30 -0
  110. package/src/lib/grok-context-breakdown.js +24 -33
  111. package/src/lib/grok-usage.js +95 -0
  112. package/src/lib/local-api.js +101 -13
  113. package/src/lib/pricing/index.js +15 -0
  114. package/src/lib/pricing/matcher.js +15 -0
  115. package/src/lib/pricing/seed-snapshot.json +1 -1
  116. package/src/lib/rollout.js +1094 -72
  117. package/src/lib/session-analytics.js +100 -40
  118. package/src/lib/usage-limits.js +507 -55
  119. package/src/lib/zcode-limits.js +65 -8
  120. package/dashboard/dist/assets/CommunityStatsModal-aAico565.js +0 -1
  121. package/dashboard/dist/assets/DashboardPage-BByRBsbt.js +0 -1
  122. package/dashboard/dist/assets/DialogDescription-BUrh0Jod.js +0 -1
  123. package/dashboard/dist/assets/SessionsPage-DOaY6_E9.js +0 -2
  124. package/dashboard/dist/assets/SkillsPage-BkzJOBLk.js +0 -1
  125. package/dashboard/dist/assets/TrendMonitor-BuKmsznP.js +0 -19
  126. package/dashboard/dist/assets/__vite-browser-external-CVIGknXl.js +0 -45
  127. package/dashboard/dist/assets/chevron-right-DJm0mbG0.js +0 -1
  128. package/dashboard/dist/assets/module-D2D5r9gC.js +0 -3
  129. package/dashboard/dist/assets/use-reduced-motion-yE3T3cat.js +0 -1
  130. package/dashboard/dist/assets/use-usage-limits-5HP8k9a3.js +0 -1
@@ -1,2 +0,0 @@
1
- import{m as Y,r as i,j as e,e as D,c as a,M as ce,J as Z,R as de,X as ue,d as ee,l as L,a4 as xe,a5 as U}from"./__vite-browser-external-CVIGknXl.js";import{L as me,I as he}from"./LocalOnlyNotice-CCD-lGWG.js";import{S as J}from"./SegmentedControl-BOE1CEzq.js";import{C as fe}from"./ToolbarRootContext-Dx5GB7F5.js";import{S as te}from"./search-CwLcNdvZ.js";import{C as ge}from"./check-BnJpzXRZ.js";import{P as be,a as pe,b as ye,c as ke,d as ve}from"./PopoverPopup-Dar_UjxF.js";import{P as je}from"./ProviderIcon-Ct9tILpz.js";import{H as we}from"./HoverTooltip-BmDkY35A.js";import{u as _e}from"./useCurrency-BarGeFyK.js";import{i as Ne}from"./host-mode-Bc_iTzHk.js";import{L as Se}from"./loader-circle-SaxUpDR6.js";import{T as Ce}from"./terminal-BfeX3L5T.js";import"./arrow-up-right-CANSzmm-.js";import"./download-B52JTk6Y.js";import"./composite-Ccj6KQmh.js";import"./store-ikeRIRGd.js";const Me=[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]],Le=Y("calendar",Me);const Te=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Re=Y("folder",Te),De="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function Ie({options:r,value:t,onChange:o,allValue:x="all",allLabel:h,searchPlaceholder:y,emptyLabel:u,ariaLabel:_,disabled:f=!1,className:k=""}){const[b,g]=i.useState(!1),[p,S]=i.useState(""),[m,v]=i.useState(-1),I=i.useRef(null),C=`${i.useId()}-listbox`,O=t===x?h:r.find(l=>l.value===t)?.label??t,M=p.trim().toLowerCase(),j=i.useMemo(()=>M?r.filter(l=>l.label.toLowerCase().includes(M)):r,[r,M]),E=i.useMemo(()=>[{value:x,label:h},...j],[x,h,j]),P=m>=0&&m<E.length?E[m]:null,F=l=>{o(l),g(!1),S(""),v(-1)};i.useEffect(()=>{b&&I.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[b,m]);const A=l=>{if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();const w=l.key==="ArrowDown";v(T=>{const N=E.length;return N?w?T>=N-1?0:T+1:T<=0?N-1:T-1:-1});return}if(l.key==="Enter"){const w=P||(M&&j.length?j[0]:null);if(!w)return;l.preventDefault(),F(w.value)}};return e.jsxs(be,{open:b,onOpenChange:l=>{g(l),v(-1),l||S("")},children:[e.jsxs(pe,{disabled:f,"aria-label":_,className:D("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==x?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",k),children:[e.jsx(Re,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:O}),e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ye,{children:e.jsx(ke,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(ve,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(te,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":P?`${C}-${m}`:void 0,value:p,onChange:l=>{S(l.target.value),v(-1)},onKeyDown:A,placeholder:y,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:I,id:C,role:"listbox","aria-label":_,className:"max-h-64 overflow-y-auto",children:[E.map((l,w)=>e.jsxs("button",{id:`${C}-${w}`,type:"button",role:"option","aria-selected":t===l.value,"data-active":w===m?"true":void 0,onMouseEnter:()=>v(w),onClick:()=>F(l.value),className:D(De,t===l.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",w===m&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:l.label}),t===l.value?e.jsx(ge,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},l.value)),j.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:u}):null]})]})})})]})}const Ee="tokentracker-sessions";async function Pe(r={}){const t=new URL(`/functions/${Ee}`,window.location.origin);r.from&&t.searchParams.set("from",r.from),r.to&&t.searchParams.set("to",r.to),r.limit&&t.searchParams.set("limit",String(r.limit)),r.refresh&&t.searchParams.set("refresh","1");const o=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),x=await o.json().catch(()=>null);if(!o.ok){const h=o.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${o.status}`,y=new Error(x?.error||h);throw y.status=o.status,y}return x}const V=Ne(),Fe=[],Q=100,$e=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],ae=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Oe(r){const t=ae.find(x=>x.id===r)?.days||0;if(!t)return 0;const o=new Date;return o.setDate(o.getDate()-(t-1)),o.setHours(0,0,0,0),o.getTime()}function Ae(r,t){if(!t)return!0;const o=Date.parse(r.ended_at||r.started_at||"");return Number.isFinite(o)?o>=t:!0}function qe(r,t){if(!r)return"—";const o=Date.parse(r);if(!Number.isFinite(o))return"—";try{return new Date(o).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(o).toISOString().slice(0,16).replace("T"," ")}}function Ue(r){const t=Number(r);if(!Number.isFinite(t)||t<=0)return null;const o=Math.round(t/6e4);if(o<60)return a("sessions.duration.minutes",{minutes:o});const x=Math.floor(o/60),h=o%60;return a("sessions.duration.hours",{hours:x,minutes:h})}async function W(r){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(r),!0;const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const o=document.execCommand("copy");return document.body.removeChild(t),o}const X=ee.memo(function({session:t,locale:o,nested:x=!1,childCount:h=0,expanded:y=!1,onToggle:u}){const{currency:_,rate:f}=_e(),k=String(t.source||"").toUpperCase(),b=Ue(t.duration_ms),g=t.resume_command,p=t.project_key||a("sessions.project.unknown"),S=x||t.thread_kind==="subagent",m=S?t.agent_nickname||t.agent_role||t.title||p:t.title||p,v=!!(t.title&&t.project_key),I=t.project_ref?`${t.project_ref}
2
- ${a("sessions.project.copy_hint")}`:void 0,C=async()=>{if(t.project_ref)try{await W(t.project_ref)?U({title:a("sessions.project.copied")}):U({title:a("sessions.project.copy_failed")})}catch{U({title:a("sessions.project.copy_failed")})}},O=j=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(we,{text:I,placement:"bottom"}),e.jsx("button",{type:"button",onClick:C,"aria-label":a("sessions.project.copy_aria",{project:p}),className:D("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",j),children:p})]}),M=async()=>{if(g)try{await W(g)?U({title:a("sessions.resume.copied")}):U({title:a("sessions.resume.copy_failed")})}catch{U({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:D("flex flex-col gap-3 py-4 sm:flex-row sm:items-start",x&&"ml-6 border-l-2 border-oai-gray-200 pl-4 dark:border-oai-gray-800"),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(je,{provider:k,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!S&&!t.title&&t.project_ref?O("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:m}),S?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:bg-sky-500/10 dark:text-sky-300",children:[a("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:a("sessions.badge.first_pass")}):null,h?e.jsx("button",{type:"button",onClick:u,"aria-expanded":y,className:"inline-flex items-center rounded-full border border-oai-gray-200 px-2 py-0.5 text-[11px] font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:y?a("sessions.thread.collapse",{count:h}):a("sessions.thread.expand",{count:h})}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[v?e.jsxs(e.Fragment,{children:[t.project_ref?O("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:p}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:t.model||a("sessions.model.unknown")}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:qe(t.started_at,o)}),b?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:b})]}):null]})]})]}),e.jsxs("div",{className:"flex items-start gap-5 pl-[30px] sm:pl-0",children:[e.jsxs("dl",{className:"flex items-start gap-6 text-right",children:[e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?a("sessions.thread.tokens_summary",{own:L(t.own_total_tokens),subagents:L(t.subagent_total_tokens),combined:L(t.combined_total_tokens)}):void 0,className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:[L(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"block text-[9px] font-normal text-oai-gray-400 dark:text-oai-gray-500",children:["Σ ",L(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.cost")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:xe(t.cost_usd,{currency:_,rate:f})})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.turns")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:L(t.turns)})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.edits")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:L(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:M,disabled:!g,title:g||a("sessions.resume.unavailable"),"aria-label":g?a("sessions.resume.copy_aria",{command:g}):a("sessions.resume.unavailable"),className:D("-mt-0.5 inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",g?"text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white":"cursor-not-allowed text-oai-gray-300 dark:text-oai-gray-600"),children:[e.jsx(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function He({sessions:r,selectedModel:t,onSelect:o}){const{groups:x,totalTokens:h}=i.useMemo(()=>{const u=new Map;let _=0;for(const f of r){const k=f.model||a("sessions.model.unknown"),b=Number(f.own_total_tokens||f.total_tokens||0),g=u.get(k)||{model:k,count:0,tokens:0};g.count+=1,g.tokens+=b,_+=b,u.set(k,g)}return{groups:[...u.values()].sort((f,k)=>k.tokens-f.tokens),totalTokens:_}},[r]);function y(u){return D("rounded-full border px-2.5 py-1 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"ml-6 border-l-2 border-oai-gray-200 py-3 pl-4 dark:border-oai-gray-800",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"mr-1 text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>o("all"),className:y(t==="all"),children:a("sessions.thread.model_all",{count:r.length,tokens:L(h)})}),x.map(u=>e.jsx("button",{type:"button","aria-pressed":t===u.model,onClick:()=>o(u.model),className:y(t===u.model),children:a("sessions.thread.model_item",{model:u.model,count:u.count,tokens:L(u.tokens)})},u.model))]})})}function nt(){const[r,t]=i.useState(null),[o,x]=i.useState(null),[h,y]=i.useState(!0),[u,_]=i.useState(!1),[f,k]=i.useState("all"),[b,g]=i.useState("all"),[p,S]=i.useState("all"),[m,v]=i.useState(""),[I,C]=i.useState(Q),[O,M]=i.useState(()=>new Set),[j,E]=i.useState(()=>new Map),P=i.useRef(0),{resolvedLocale:F}=ce(),A=i.useCallback(async(s=!1)=>{const c=++P.current;s?_(!0):y(!0),x(null);try{const n=await Pe({refresh:s});c===P.current&&t(n)}catch(n){c===P.current&&x(n?.message||String(n))}finally{c===P.current&&(y(!1),_(!1))}},[]);i.useEffect(()=>{V||Z()?A(!1):y(!1)},[A]);const l=r?.sessions||Fe,w=i.useMemo(()=>{const s=new Set,c=[];for(const n of l){const d=n.project_key;!d||s.has(d)||(s.add(d),c.push({value:d,label:d}))}return c.sort((n,d)=>n.label.localeCompare(d.label))},[l]),T=i.useDeferredValue(m),N=i.useMemo(()=>{const s=T.trim().toLowerCase(),c=Oe(b);return l.filter(n=>f!=="all"&&n.source!==f||p!=="all"&&n.project_key!==p||!Ae(n,c)?!1:s?`${n.title||""} ${n.project_key||""} ${n.model||""} ${n.agent_nickname||""} ${n.agent_role||""} ${n.project_ref||""} ${n.session_id||""}`.toLowerCase().includes(s):!0)},[l,f,p,b,T]),$=i.useMemo(()=>{const s=new Set(N.map(d=>d.session_hash)),c=new Map,n=[];for(const d of N){const q=d.root_session_hash||d.parent_session_hash;if(d.parent_session_hash&&q&&s.has(q)){const R=c.get(q)||[];R.push(d),c.set(q,R)}else n.push(d)}return{roots:n,childrenByRoot:c,foldedCount:N.length-n.length}},[N]),B=f!=="all"||b!=="all"||p!=="all"||m.trim()!=="";i.useEffect(()=>{C(Q),M(new Set),E(new Map)},[f,p,b,T,l]);const K=i.useMemo(()=>$.roots.slice(0,I),[$.roots,I]),H=$.roots.length>K.length,G=i.useCallback(()=>C(s=>s+Q),[]),se=i.useCallback(s=>{M(c=>{const n=new Set(c);return n.has(s)?n.delete(s):n.add(s),n})},[]),re=i.useCallback((s,c)=>{E(n=>{const d=new Map(n);return c==="all"?d.delete(s):d.set(s,c),d})},[]),z=i.useRef(null);i.useEffect(()=>{if(!H||typeof IntersectionObserver>"u")return;const s=z.current;if(!s)return;const c=new IntersectionObserver(n=>{n.some(d=>d.isIntersecting)&&G()},{rootMargin:"400px"});return c.observe(s),()=>c.disconnect()},[H,G]);const oe=i.useMemo(()=>$e.map(s=>({id:s.id,label:s.label()})),[F]),ne=i.useMemo(()=>ae.map(s=>({id:s.id,label:s.label()})),[F]),ie=Number(r?.session_count)>Number(r?.returned_count);return!V&&!Z()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(me,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("sessions.page.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>{A(!0)},disabled:u||h,"aria-label":a("sessions.page.refresh"),title:a("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(de,{className:D("h-4 w-4",u&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(J,{ariaLabel:a("sessions.filter.source_aria"),options:oe,value:f,onChange:k}),e.jsx(J,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(Le,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:ne,value:b,onChange:g}),e.jsx(Ie,{options:w,value:p,onChange:S,allLabel:a("sessions.filter.project_all"),searchPlaceholder:a("sessions.filter.project_search"),emptyLabel:a("sessions.filter.project_empty"),ariaLabel:a("sessions.filter.project_aria")}),e.jsxs("div",{className:"relative w-72 max-w-full",children:[e.jsx(te,{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(he,{type:"search",value:m,onChange:s=>v(s.target.value),onKeyDown:s=>{s.key==="Escape"&&m&&(s.preventDefault(),v(""))},"aria-label":a("sessions.action.search_aria"),placeholder:a("sessions.search.placeholder"),className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>v(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!m,tabIndex:m?0:-1,className:D("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",m?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(ue,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:$.foldedCount>0?a("sessions.thread.result_count",{roots:$.roots.length,subagents:$.foldedCount}):a("sessions.filter.result_count",{filtered:N.length,total:l.length})})]}),ie?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.truncated",{shown:r.returned_count,total:r.session_count})}):null,o&&!r?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:a("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:o}),e.jsx("button",{type:"button",onClick:()=>{A(!1)},className:"mt-4 inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.error.retry")})]}):h?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Se,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):N.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:B?a("sessions.empty.filtered_title"):a("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:B?a("sessions.empty.filtered_body"):a("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:a("shared.error.prefix",{error:o})}):null,e.jsx("ul",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:K.map(s=>{const c=$.childrenByRoot.get(s.session_hash)||[],n=O.has(s.session_hash),d=j.get(s.session_hash)||"all",q=d==="all"?c:c.filter(function(le){return(le.model||a("sessions.model.unknown"))===d});return e.jsxs(ee.Fragment,{children:[e.jsx(X,{session:s,locale:F,childCount:c.length,expanded:n,onToggle:()=>se(s.session_hash)}),n&&c.length?e.jsx(He,{sessions:c,selectedModel:d,onSelect:R=>re(s.session_hash,R)}):null,n?q.map(R=>e.jsx(X,{session:R,locale:F,nested:!0},R.session_hash)):null]},s.session_hash)})}),H?e.jsx("div",{ref:z,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:G,className:"inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.privacy")})]})})})}export{nt as SessionsPage};
@@ -1 +0,0 @@
1
- import{m as dt,r as i,V as ct,z as ga,j as e,X as De,c as r,e as ae,aF as da,ay as ut,aI as mt,y as gt,aJ as ya,aK as xt,aL as ht,Z as pt,aM as ft,aN as yt,aO as bt,aP as kt,A as wt,aQ as vt,aA as jt,az as Nt,aR as Ct,a4 as St,a as _t,aS as Rt,ao as It,J as Lt,B as J,R as Pt,d as Dt,a5 as Pe}from"./__vite-browser-external-CVIGknXl.js";import{L as Bt,I as xa}from"./LocalOnlyNotice-CCD-lGWG.js";import{C as Tt}from"./Card-B_MpSRse.js";import{C as ba}from"./ConfirmModal-DLnRwUXC.js";import{S as Et}from"./SegmentedControl-BOE1CEzq.js";import{I as Ra}from"./info-D94QM_vX.js";import{P as Ne}from"./ProviderIcon-Ct9tILpz.js";import{m as ka}from"./react-D_AcI466.js";import{u as Ot}from"./useCurrency-BarGeFyK.js";import{E as ca}from"./external-link-DayTwZx-.js";import{L as te}from"./loader-circle-SaxUpDR6.js";import{M as Ia}from"./monitor-smartphone-D6qLR9qd.js";import{C as Be}from"./check-BnJpzXRZ.js";import{T as ha}from"./trash-2-5_Qlp1k7.js";import{A as At}from"./index-Bp0ZHDtz.js";import{u as $t}from"./use-reduced-motion-yE3T3cat.js";import{u as Mt,s as Ut,k as Ft,l as zt,m as Kt,n as Vt,o as Wt,p as qt,S as La,c as Pa,d as Da,e as Ba,f as Ta,g as Ea,h as Ye,j as Ze,i as ea}from"./SelectItemText-DMYjXXq4.js";import{t as Ht,u as ua,m as Gt}from"./composite-Ccj6KQmh.js";import{u as Qt,C as pa}from"./ToolbarRootContext-Dx5GB7F5.js";import{g as Jt,a as Xt,p as Yt,m as Zt,b as er,d as ar,c as tr,e as rr,f as sr,s as nr,i as wa,u as va,h as ja,r as ir,j as Na,k as Ca,l as or,n as lr}from"./skills-api-Dqi7Mjgo.js";import{F as dr}from"./flame-B8GEX2yT.js";import{S as ma}from"./search-CwLcNdvZ.js";import{P as Oa}from"./plus-D51mjIc2.js";import{D as Aa}from"./download-B52JTk6Y.js";import{C as cr}from"./chevron-right-DJm0mbG0.js";import{P as $a,a as Ma,b as Ua,c as Fa,d as za}from"./PopoverPopup-Dar_UjxF.js";import"./arrow-up-right-CANSzmm-.js";import"./DialogTitle-DrbKjtuS.js";import"./store-ikeRIRGd.js";import"./DialogDescription-BUrh0Jod.js";const ur=[["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"}]],Ka=dt("circle-arrow-up",ur),Va=i.forwardRef(function(s,d){const{render:o,className:h,style:x,...g}=s,{store:c}=Mt(),k={open:ct(c,Ut.open)};return ga("span",s,{state:k,ref:d,props:[{"aria-hidden":!0,children:"▼"},g],stateAttributesMapping:Ht})}),mr="tt:hint:dismissed:";function Wa(a){return mr+a}function gr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Wa(a))==="1"}catch{return!1}}function xr({id:a,children:s,className:d,ariaLabel:o}){const[h,x]=i.useState(()=>gr(a)),g=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Wa(a),"1")}catch{}x(!0)},[a]);return h?null:e.jsxs("div",{role:"note","aria-label":o||r("hint.dismissible_aria"),className:ae("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:g,"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(De,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ra,{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 hr(a){if(!a)return null;for(const s of a.elements){const d=s.tagName;if(d==="BUTTON"||d==="INPUT"){const o=s;if(o.type==="submit")return o}}return null}function qa(a){return{checked(s){return a.indeterminate?{}:s?{"data-checked":""}:{"data-unchecked":""}},...Ft}}const pr=i.createContext({disabled:!1});function fr(){return i.useContext(pr)}function yr(a,s,d,o=!0,h){const[x,g]=i.useState(),c=ua(h?`${h}-label`:void 0),y=a??s??x;return da(()=>{const k=a||s||!o?void 0:br(d.current,c);x!==k&&g(k)}),y}function br(a,s){const d=kr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function kr(a){if(!a)return;const s=a.parentElement;if(s&&s.tagName==="LABEL")return s;const d=a.id;if(d){const h=a.nextElementSibling;if(h&&h.htmlFor===d)return h}const o=a.labels;return o&&o[0]}const wr=i.createContext(void 0);function vr(){return i.useContext(wr)}const Ha=i.createContext(void 0);function jr(){const a=i.useContext(Ha);if(a===void 0)throw new Error(ut(14));return a}const Nr="data-parent",Cr=i.forwardRef(function(s,d){const{checked:o,className:h,defaultChecked:x=!1,"aria-labelledby":g,disabled:c=!1,form:y,id:k,indeterminate:p=!1,inputRef:C,name:R,onCheckedChange:u,parent:w=!1,readOnly:m=!1,render:S,required:L=!1,uncheckedValue:A,value:$,nativeButton:F=!1,style:de,...D}=s,{clearErrors:Ce}=zt(),{disabled:he,name:pe,setDirty:_,setFilled:E,setFocused:M,setTouched:T,state:X,validationMode:q,validityData:Se,validation:Te}=Kt(),Ve=fr(),{labelId:Ee,controlId:We,registerControlId:re,getDescriptionProps:O}=Vt(),N=vr(),H=N?.allValues===void 0?void 0:N.parent,se=H!==void 0,B=he||Ve.disabled||N?.disabled||c,z=pe??R,I=$??z,_e=ua(),Oe=ua();let K=k||We;se&&(w?K=Oe:I!==void 0?K=`${H.id}-${I}`:K||=Oe);let Re={};se&&(w?Re=H.getParentProps():I!==void 0&&(Re=H.getChildProps(I)));const{checked:fe=o,indeterminate:ta=p,onCheckedChange:Ae,...qe}=Re,ye=N?.value,ne=i.useRef(null),ce=mt(()=>Symbol()),ue=i.useRef(!1),{getButtonProps:Ie,buttonRef:me}=gt({disabled:B,native:F}),Y=N?.validation??Te,[P,Le]=Wt({controlled:I!==void 0&&ye!==void 0&&!w?ye.includes(I):fe,default:x,name:"Checkbox",state:"checked"}),ge=se?!!fe:P,be=se&&ta||p;da(()=>{re!==ya&&(ue.current=!0,re(ce.current,K))},[K,re,ce]),i.useEffect(()=>{const b=ce.current;return()=>{!ue.current||re===ya||(ue.current=!1,re(b,void 0))}},[re,ce]),qt(ne,_e,P,void 0,!N&&!B,R);const Z=i.useRef(null),$e=Y.registerInput,G=N?I:void 0,ra=i.useCallback(b=>$e(b,{controlRef:ne,value:G}),[$e,G]),sa=xt(C,Z,w?void 0:ra),na=yr(g,Ee,Z,!F,K??void 0);da(()=>{Z.current&&(Z.current.indeterminate=be,P&&E(!0))},[P,be,E]),Qt(P,()=>{N||(Ce(z),E(P),_(P!==Se.initialValue),Y.change(P))});const He=ht({checked:P,disabled:B,form:y,name:w?void 0:z,id:F?void 0:K??void 0,required:L,ref:sa,style:z?bt:kt,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(b){if(b.nativeEvent.defaultPrevented)return;if(m){b.preventDefault();return}const Q=b.currentTarget.checked,ie=wt(vt,b.nativeEvent);if(u?.(Q,ie),!ie.isCanceled&&(Ae?.(Q,ie),!ie.isCanceled&&(Le(Q),I!==void 0&&N!==void 0&&!w&&!se))){const oe=Q?[...N.value,I]:N.value.filter(we=>we!==I);N.setValue(oe,ie)}},onClick(b){b.stopPropagation()},onFocus(){ne.current?.focus()}},$!==void 0?{value:(N?P&&$:$)||""}:pt,O,b=>Y.getValidationProps(B,b));i.useEffect(()=>{if(!H||I===void 0)return;const b=H.disabledStatesRef.current;return b.set(I,B),()=>{b.delete(I)}},[H,B,I]);const ke=i.useMemo(()=>({...X,checked:ge,disabled:B,readOnly:m,required:L,indeterminate:be}),[X,ge,B,m,L,be]),ia=qa(ke),Ge=ga("span",s,{state:ke,ref:[me,ne,d],props:[{id:F?K??void 0:_e,role:"checkbox","aria-checked":be?"mixed":ge,"aria-readonly":m||void 0,"aria-required":L||void 0,"aria-labelledby":na,[Nr]:w?"":void 0,onFocus(){B||M(!0)},onBlur(){const b=Z.current;b&&(T(!0),M(!1),q==="onBlur"&&Y.commit(N?ye:b.checked))},onKeyDown(b){if(b.key!=="Enter"||(b.preventBaseUIHandler(),b.defaultPrevented))return;const Q=Z.current?.form??null,ie=b.currentTarget,oe=b.nativeEvent,we=b.preventDefault,Me=oe.preventDefault;let Ue=!1;b.preventDefault=()=>{Ue=!0,we.call(b)},oe.preventDefault=()=>{Ue=!0,Me.call(oe)},Me.call(oe),yt(ie).queueMicrotask(()=>{b.preventDefault=we,oe.preventDefault=Me,Ue||hr(Q)?.click()})},onClick(b){if(m||B)return;b.preventDefault();const Q=Z.current;Q&&ft(Q,b)}},D,qe,Ie,O,b=>Y.getValidationProps(B,b)],stateAttributesMapping:ia});return e.jsxs(Ha.Provider,{value:ke,children:[Ge,!P&&!N&&z&&!w&&A!==void 0&&e.jsx("input",{type:"hidden",form:y,name:z,value:A,disabled:B}),e.jsx("input",{...He,suppressHydrationWarning:!0})]})}),Sr=i.forwardRef(function(s,d){const{render:o,className:h,style:x,keepMounted:g=!1,...c}=s,y=jr(),k=y.checked||y.indeterminate,{mounted:p,transitionStatus:C,setMounted:R}=Gt(k),u=i.useRef(null),w={...y,transitionStatus:C};jt({open:k,ref:u,onComplete(){k||R(!1)}});const S={...qa(y),...Nt},L=g||p,A=ga("span",s,{ref:[d,u],state:w,stateAttributesMapping:S,props:c});return L?A:null});function _r(a,s){return`target:${a}:${s}`}function Rr(a){return`remove:${a.id||a.directory}`}function Ga(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function Ir(a){const s=Ga(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 Lr(a){const s=Ga(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 oa({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 Pr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){return e.jsx(At,{children:a?e.jsx(Dr,{skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k},a.id||a.directory):null})}function Dr({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){const p=$t(),{currency:C,rate:R}=Ot(),u=i.useRef(null);i.useEffect(()=>{const _=M=>{M.key==="Escape"&&(M.stopPropagation(),c?.())},E=M=>{const T=M.target;T instanceof Element&&(u.current?.contains(T)||T.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",E),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",E)}},[c]);const w=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),S=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,L=new Set(a.targets||[]),A=!!(a.readOnly||a.remote),$=!!a.remote,F=Array.isArray(a.deviceSources)?a.deviceSources:[],de=!$&&(!A||L.has("claude")),D=d===Rr(a),Ce=Ir(o?.lastUsedAt),he=!!(o&&o.invocations>0),pe=p?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return e.jsxs(e.Fragment,{children:[e.jsx(ka.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:p?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:p?0:.15},onClick:c,"aria-hidden":!0}),e.jsxs(ka.aside,{ref:u,role:"complementary","aria-label":w,initial:p?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:p?{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:w,children:w}),m?e.jsxs("a",{href:S,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:S,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(ca,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):a.directory&&a.directory!==w?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:c,"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(De,{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:[h?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(Ka,{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:()=>g?.(a),disabled:x,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:[x?e.jsx(te,{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,A?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($?"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,F.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:F.map(_=>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(Ia,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:_.name})]},_.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(oa,{label:r("skills.usage.invocations"),children:Ct(o?.invocations||0)}),e.jsx(oa,{label:r("skills.usage.last_used"),children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:ae("h-1.5 w-1.5 rounded-full",Lr(o?.lastUsedAt)),"aria-hidden":!0}),he?Ce||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(oa,{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(Ra,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:St(o?.cost||0,{currency:C,rate:R})})]}),he?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,A?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(_=>_.manageable!==!1).map(_=>{const E=L.has(_.id),M=d===_r(a.id||a.directory,_.id),T=`skill-detail-sync-${a.id||a.directory}-${_.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(Cr,{id:T,checked:E,disabled:M,onCheckedChange:X=>y?.(a,_.id,!!X),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(Sr,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Be,{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(Ne,{provider:_.id,size:16})}),e.jsx("span",{className:"flex-1",children:_.label}),M?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},_.id)})})]})]}),A?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:()=>k?.(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:[D?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ha,{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 Br=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),la=["claude","codex"],W="popular",Tr={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",U="skillssh";function aa(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Qa(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function Er(a){return Qa(a).split("/").filter(Boolean).pop()||""}function Or(a){if(a.repoOwner||a.repoName)return"";const s=Qa(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function Sa(a){const s=Er(a.directory);return s?`dir:${s}`:""}function Ja(a){const s=new Set([aa(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Or(a);return d&&s.add(d),s}function Ar(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function $r(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Ar(d))for(const o of Ja(d))s.add(o);return s}function Xe(a){return`install:${aa(a)}`}function _a(a){return`remove:${a.id||a.directory}`}function Xa(a,s){return`target:${a}:${s}`}function je(a){return a.id||a.directory}function fa(a){return a.manageable!==!1}function Mr({target:a,state:s,busy:d,disabled:o,disabledLabel:h,onToggle:x}){const g=s==="synced",c=s==="orphan",y=c?r("skills.dot.orphan_aria",{agent:a.label}):g?r("skills.dot.synced_aria",{agent:a.label}):r("skills.dot.off_aria",{agent:a.label}),k=o&&h?`${y} — ${h}`:y;return e.jsxs("button",{type:"button",title:k,"aria-label":k,"aria-pressed":g,disabled:d||o,onClick:p=>{p.stopPropagation(),x?.(a.id,!g)},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(te,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):e.jsx("span",{className:ae("flex h-[18px] w-[18px] items-center justify-center transition",g&&Tr[a.id],!g&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(Ne,{provider:a.id,size:18})}),c&&!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 Ur({skill:a,targets:s,onToggleTarget:d,busyKey:o}){const h=new Set(a.targets||[]),x=!!(a.readOnly||a.remote),g=[];for(const c of s)(x?h.has(c.id):fa(c))&&g.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:g.map(c=>e.jsx(Mr,{target:c,state:a.targetStates?.[c.id]||"off",busy:o===Xa(je(a),c.id),disabled:x||c.manageable===!1,disabledLabel:r(a.remote?"skills.inventory.read_only_remote":"skills.inventory.read_only_managed"),onToggle:(y,k)=>d?.(a,y,k)},c.id))})}function Fr({skill:a,targets:s,selected:d,onSelect:o,selectable:h,checked:x,onToggleSelect:g,onToggleTarget:c,hasUpdate:y,busyKey:k}){const p=a.repoOwner&&a.repoName?`${a.repoOwner}/${a.repoName}`:null,C=[a.directory,p,a.sourceName].filter(Boolean).join(" · "),R=Array.isArray(a.deviceSources)?a.deviceSources:[],u=[a.remote?r("skills.inventory.remote"):null,a.scope==="plugin"?r("skills.inventory.plugin"):null].filter(Boolean),w=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),o?.(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:()=>o?.(a),onKeyDown:w,className:ae("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":x?"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:[h?e.jsx("label",{className:"flex shrink-0 items-center",onClick:m=>m.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:x,onChange:m=>g?.(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:C,children:a.name||a.directory}),u.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(Ka,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Ur,{skill:a,targets:s,onToggleTarget:c,busyKey:k}),e.jsx(cr,{className:ae("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:ae("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",h&&"pl-7"),children:a.description}):null,a.sourceName||R.length?e.jsxs("div",{className:ae("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",h&&"pl-7"),children:[a.sourceName?e.jsx("span",{className:"truncate",children:a.sourceName}):null,R.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:R.map(m=>m.name).join(", "),children:[e.jsx(Ia,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:R.map(m=>m.name).join(", ")})})]}):null]}):null]})}function zr({agentFilter:a,agentOptions:s,onAgentFilter:d,filteredCount:o,totalCount:h,anyFilter:x,onClearFilters:g,searchQuery:c,onSearchQuery:y,searchPlaceholder:k}){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(La,{value:a,onValueChange:d,children:[e.jsxs(Pa,{"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(Da,{children:p=>p==="all"?r("skills.filter.agent_all"):s.find(C=>C.id===p)?.label||p}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ba,{children:e.jsx(Ta,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ea,{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(Ye,{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(Ze,{children:r("skills.filter.agent_all")}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(p=>e.jsxs(Ye,{value:p.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(Ne,{provider:p.id,size:14}),e.jsx(Ze,{children:p.label})]}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},p.id))]})})})]}),e.jsxs("div",{className:"relative w-56 max-w-full",children:[e.jsx(ma,{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:c,onChange:p=>y(p.target.value),onKeyDown:p=>{p.key==="Escape"&&c&&(p.preventDefault(),y(""))},"aria-label":r("skills.action.search_aria"),placeholder:k,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:p=>p.preventDefault(),onClick:()=>y(""),"aria-label":r("skills.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:ae("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",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(De,{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:o,total:h})}),x?e.jsxs("button",{type:"button",onClick:g,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(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Kr({count:a,targets:s,busy:d,onBulkSync:o,onBulkRemove:h,onClear:x}){const g=s.filter(fa);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($a,{children:[e.jsxs(Ma,{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(Aa,{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(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),g.map(c=>e.jsxs("button",{type:"button",onClick:()=>o(c.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(Ne,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:h,children:[e.jsx(ha,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_remove")]}),e.jsxs("button",{type:"button",onClick:x,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(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function Vr({items:a,totalCount:s,targets:d,agentOptions:o,agentFilter:h,onAgentFilter:x,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p,selectedId:C,onSelect:R,onToggleTarget:u,busyKey:w,updates:m,selectedIds:S,onToggleSelect:L,onClearSelection:A,onBulkSync:$,onBulkRemove:F}){const de=S.size;return e.jsxs("div",{children:[de>0?e.jsx(Kr,{count:de,targets:d,busy:w==="batch",onBulkSync:$,onBulkRemove:F,onClear:A}):e.jsx(zr,{agentFilter:h,agentOptions:o,onAgentFilter:x,filteredCount:a.length,totalCount:s,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p}),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:c,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(Fr,{skill:D,targets:d,selected:C===(D.id||D.directory),onSelect:R,selectable:!D.readOnly&&!D.remote,checked:S.has(je(D)),onToggleSelect:L,onToggleTarget:u,hasUpdate:!!(D.id&&m?.[D.id]),busyKey:w},je(D)))})]})}const Wr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},qr=Dt.memo(function({skill:s,installed:d,installing:o,allTargets:h,defaultTargets:x,onInstall:g,onManage:c}){const[y,k]=i.useState(()=>(x||[]).filter(m=>h.some(S=>S.id===m))),p=m=>{k(S=>S.includes(m)?S.filter(L=>L!==m):[...S,m])},C=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,R=C?`https://github.com/${s.repoOwner}/${s.repoName}`:null,u=s.installs!=null?r("skills.card.installs",{count:Number(s.installs||0).toLocaleString()}):null,w=y.length?y.map(m=>h.find(S=>S.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Tt,{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(ca,{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}),C||u?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:[R?e.jsxs("a",{href:R,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:R,children:[e.jsx("span",{className:"truncate",children:C}),e.jsx(ca,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,C&&u?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,u?e.jsx("span",{className:"truncate",children:u}):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:()=>c?.(s),className:"w-full",children:[e.jsx(Be,{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?w:r("skills.target.none")}),e.jsxs($a,{children:[e.jsx(Ma,{disabled:o,"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(Ua,{children:e.jsx(Fa,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(za,{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")}),h.map(m=>{const S=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:S,onChange:()=>p(m.id)}),e.jsx(Ne,{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:()=>g(s,y),disabled:o||y.length===0,className:"w-full",children:[o?e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Aa,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Hr({repos:a,repoInput:s,onRepoInput:d,busyKey:o,onAdd:h,onRemove:x}){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:g=>d(g.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(J,{type:"button",variant:"secondary",size:"md",onClick:h,disabled:o==="repo:add",className:"shrink-0 whitespace-nowrap",children:[o==="repo:add"?e.jsx(te,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Oa,{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(g=>{const c=o===`repo:${g.owner}/${g.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:[g.owner,"/",g.name]}),e.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:g.branch})]}),e.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>x(g),className:"shrink-0",children:[c?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:r("skills.repo.remove")})]})]},`${g.owner}/${g.name}`)})}):null]})}function Gr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Cs(){const a=_t()||{},s=!!a.signedIn,d=a.getAccessToken,[o,h]=i.useState(Gr),[x,g]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[k,p]=i.useState([]),[C,R]=i.useState([]),[u,w]=i.useState(xe),[m,S]=i.useState(""),[L,A]=i.useState(""),[$,F]=i.useState(""),[de,D]=i.useState(""),[Ce,he]=i.useState(""),[pe,_]=i.useState(!1),[E,M]=i.useState("all"),[T,X]=i.useState(null),[q,Se]=i.useState(""),[Te,Ve]=i.useState(!0),[Ee,We]=i.useState(!1),[re,O]=i.useState(""),[N,H]=i.useState(null),[se,B]=i.useState(null),[z,I]=i.useState(()=>new Set),[_e,Oe]=i.useState({}),[K,Re]=i.useState({}),[fe,ta]=i.useState([]),[Ae,qe]=i.useState(!1),ye=i.useRef(!1),ne=i.useRef(0),ce=i.useMemo(()=>$r(x.skills),[x.skills]),ue=i.useCallback(async()=>{const t=++ne.current,n=await Jt();if(ne.current!==t)return;const l={skills:n.skills||[],targets:n.targets||[]};g(l);const f=Rt();!s||!It()||!f||typeof d!="function"||(async()=>{try{const v=await d();if(!v||ne.current!==t)return;const[j]=await Promise.allSettled([Xt(v),Yt({accessToken:v,deviceId:f,skills:l.skills})]);if(j.status!=="fulfilled")return;const ze=j.value;if(ne.current!==t)return;g({targets:l.targets,skills:Zt(l.skills,ze,f)})}catch{}})()},[d,s]),Ie=i.useCallback(async()=>{const t=await er();R(t.repos||[])},[]),me=i.useCallback(async({force:t=!1}={})=>{We(!0);try{const n=await ar({force:t});y(n.skills||[])}finally{We(!1)}},[]),Y=i.useCallback(async({force:t=!1}={})=>{qe(!0);try{const n=await tr({force:t});ta(n.skills||[])}finally{qe(!1)}},[]),P=i.useCallback(async()=>{try{const t=await rr();Oe(t?.updates||{})}catch{Oe({})}},[]),Le=i.useCallback(async()=>{try{const t=await sr(),n={};for(const l of t?.skills||[])l.installed&&(l.directory&&(n[String(l.directory).toLowerCase()]=l),n[String(l.skill).toLowerCase()]=l);Re(n)}catch{Re({})}},[]),ge=i.useCallback(async()=>{Ve(!0),O("");try{await Promise.all([ue(),Ie()])}catch(t){O(t?.message||r("skills.error.generic"))}finally{Ve(!1)}},[ue,Ie]),be=i.useCallback(async()=>{await ge();const t=n=>O(n?.message||r("skills.error.generic"));o==="my"?(P(),Le()):u===W?Y({force:!0}).catch(t):u!==U&&me({force:!0}).catch(t)},[me,ge,Y,P,Le,u,o]);i.useEffect(()=>{ge()},[ge]),i.useEffect(()=>{if(ye.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){ye.current=!0;return}const l=x.skills||[];if(!l.length)return;const f=l.find(j=>j.directory===n||j.id===n);f&&(h("my"),X(f.id||f.directory)),ye.current=!0,t.delete("skill");const v=t.toString();window.history.replaceState({},"",`${window.location.pathname}${v?`?${v}`:""}${window.location.hash}`)},[x.skills]),i.useEffect(()=>{o==="browse"&&(u===U||u===W||c.length===0&&me().catch(t=>O(t?.message||r("skills.error.generic"))))},[c.length,me,u,o]),i.useEffect(()=>{o!=="browse"||u!==W||fe.length===0&&Y().catch(t=>O(t?.message||r("skills.error.generic")))},[Y,fe.length,u,o]);const Z=Object.keys(_e).length>0,$e=Object.keys(K).length>0;if(i.useEffect(()=>{o==="my"&&(Z||P(),$e||Le())},[o,Z,$e,P,Le]),i.useEffect(()=>{const t=setTimeout(()=>A(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>D($),120);return()=>clearTimeout(t)},[$]),i.useEffect(()=>{if(typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("tab");if(o==="my"){if(!n)return;t.delete("tab")}else{if(n===o)return;t.set("tab",o)}const l=t.toString(),f=`${window.location.pathname}${l?`?${l}`:""}${window.location.hash}`;window.history.replaceState({},"",f)},[o]),!Br&&!Lt())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Bt,{})});const G=async(t,n)=>{Se(t),O("");try{await n(),await ue()}catch(l){O(l?.message||r("skills.error.generic"))}finally{Se("")}},ra=(t,n)=>{const l=(n&&n.length?n:la).filter(f=>(x.targets||[]).some(v=>v.id===f));G(Xe(t),async()=>{await wa(t,l);const f=l.map(v=>(x.targets||[]).find(j=>j.id===v)?.label||v).join(", ");Pe({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},sa=t=>{t?.readOnly||t?.remote||H(t)},na=()=>{const t=N;t&&(H(null),G(_a(t),async()=>{let n=null;t.managed?n=await va(t.id):await ja(t.directory,t.targets||[]);const l=!!(n?.trashed&&t.managed&&t.id);Pe({title:r("skills.toast.removed",{name:t.name||t.directory}),timeout:6e3,data:l?{onUndo:async()=>{try{await ir(t.id),await ue()}catch(f){O(f?.message||r("skills.error.generic"))}}}:void 0})}))},He=(t,n,l)=>t?.readOnly||t?.remote?Promise.resolve():G(Xa(je(t),n),async()=>{const f=new Set(t.targets||[]);l?f.add(n):f.delete(n),t.managed?await Na(t.id,Array.from(f)):await Ca(t.directory,Array.from(f));const v={name:t.name||t.directory,agent:Ge(n)};Pe({title:l?r("skills.toast.synced_one",v):r("skills.toast.unsynced_one",v),timeout:3e3})}),ke=i.useCallback(()=>I(new Set),[]),ia=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const l=je(t);I(f=>{const v=new Set(f);return n?v.add(l):v.delete(l),v})},[]),Ge=t=>(x.targets||[]).find(n=>n.id===t)?.label||t,b=t=>{const n=(x.skills||[]).filter(l=>z.has(je(l))&&!l.readOnly&&!l.remote);n.length&&G("batch",async()=>{for(const l of n){const f=new Set(l.targets||[]);f.add(t),l.managed?await Na(l.id,Array.from(f)):await Ca(l.directory,Array.from(f))}ke(),Pe({title:r("skills.toast.bulk_synced",{count:n.length,agent:Ge(t)}),timeout:4e3})})},Q=()=>{const t=(x.skills||[]).filter(n=>z.has(je(n))&&!n.readOnly&&!n.remote);t.length&&B(t)},ie=()=>{const t=se;t&&(B(null),G("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);ke(),Pe({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},oe=t=>{!t?.repoOwner||!t?.repoName||G(Xe(t),async()=>{await wa({key:t.key,name:t.name,description:t.description,directory:t.sourceDirectory||t.directory,repoOwner:t.repoOwner,repoName:t.repoName,repoBranch:t.repoBranch,readmeUrl:t.readmeUrl},t.targets&&t.targets.length?t.targets:la),await P(),Pe({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},we=async()=>{const t=m.trim();if(!(t.length<2)){Se("search"),O("");try{const n=await nr(t);p(n.skills||[])}catch(n){O(n?.message||r("skills.error.generic"))}finally{Se("")}}},Me=async()=>{const t=Ce.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,l]=t.split("/");if(!n||!l){O(r("skills.repo.invalid"));return}await G("repo:add",async()=>{await lr({owner:n,name:l,branch:"main",enabled:!0}),he(""),await Ie(),await me()})},Ue=async t=>{await G(`repo:${t.owner}/${t.name}`,async()=>{await or(t.owner,t.name),await Ie(),await me()})},le=x.targets||[],Ya=le.filter(fa),ve=x.skills||[],Za=i.useMemo(()=>{const t=E==="all"?ve:ve.filter(l=>(l.targets||[]).includes(E)),n=de.trim().toLowerCase();return n?t.filter(l=>(l.name||"").toLowerCase().includes(n)||(l.directory||"").toLowerCase().includes(n)||(l.description||"").toLowerCase().includes(n)):t},[ve,E,de]),et=E!=="all",ee=i.useMemo(()=>T&&ve.find(t=>(t.id||t.directory)===T)||null,[ve,T]),at=i.useCallback(()=>{M("all"),F("")},[]),tt=i.useCallback(t=>{X(n=>{const l=t?.id||t?.directory||null;return n===l?null:l})},[]),rt=i.useCallback(()=>X(null),[]),st=i.useCallback(t=>{const n=aa(t).toLowerCase(),l=Sa(t),f=(x.skills||[]).find(v=>{const j=Ja(v);return j.has(n)||l&&j.has(l)});f&&X(f.id||f.directory)},[x.skills]);i.useEffect(()=>{o!=="my"&&z.size&&I(new Set)},[o,z.size]),i.useEffect(()=>{T&&!ee&&X(null)},[ee,T]);const Fe=i.useMemo(()=>{const t=u===U?k:u===W?fe:c,l=u===U||u===W||u===xe?t:t.filter(j=>`${j.repoOwner}/${j.repoName}`===u),f=L.trim().toLowerCase();return(u===U||!f?l:l.filter(j=>(j.name||"").toLowerCase().includes(f)||(j.directory||"").toLowerCase().includes(f)||(j.description||"").toLowerCase().includes(f))).map(j=>{const ze=aa(j).toLowerCase(),V=Sa(j);return{...j,installed:ce.has(ze)||V&&ce.has(V)}})},[L,c,ce,fe,k,u]),nt=e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(te,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),it=e.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[e.jsx(te,{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")})]}),Qe=(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 Je;if(Te)Je=nt;else if(o==="my")Je=ve.length?e.jsx(Vr,{items:Za,totalCount:ve.length,targets:le,agentOptions:le,agentFilter:E,onAgentFilter:M,anyFilter:et,onClearFilters:at,searchQuery:$,onSearchQuery:F,searchPlaceholder:r("skills.my.placeholder"),selectedId:T,onSelect:tt,onToggleTarget:He,busyKey:q,updates:_e,selectedIds:z,onToggleSelect:ia,onClearSelection:ke,onBulkSync:b,onBulkRemove:Q}):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(Ne,{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(Ne,{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:()=>h("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===U,n=u===W,l=C.length===0&&!t&&!n,f=Ee&&!t&&!n||n&&Ae,v=!t&&!n&&(L.trim()!==""||u!==xe),j=()=>{S(""),w(xe)},ze=!l&&!f&&(Fe.length>0||v)?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:Fe.length})}),v?e.jsxs("button",{type:"button",onClick:j,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(De,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let V;l?V=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?V=it:t&&m.trim().length<2?V=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")}):Fe.length?V=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Fe.map(Ke=>e.jsx("div",{style:Wr,children:e.jsx(qr,{skill:Ke,installed:!!Ke.installed,installing:q===Xe(Ke),allTargets:Ya,defaultTargets:la,onInstall:ra,onManage:st})},Ke.id||Ke.key))}):v?V=Qe("skills.empty.no_match",e.jsx(J,{type:"button",variant:"secondary",size:"sm",onClick:j,children:r("skills.filter.clear")})):t?V=Qe("skills.empty.search"):n?V=Qe("skills.empty.popular"):V=Qe("skills.empty.browse");const ot=l||pe?e.jsx("div",{className:"mb-5",children:e.jsx(Hr,{repos:C,repoInput:Ce,onRepoInput:he,busyKey:q,onAdd:Me,onRemove:Ue})}):null,lt=!pe&&!t&&!n&&C.length<=1&&Fe.length>0?e.jsx(xr,{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:()=>_(!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;Je=e.jsxs(e.Fragment,{children:[ot,ze,V,lt]})}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:be,disabled:Te||Ee||Ae,children:[e.jsx(Pt,{className:ae("mr-1.5 h-3.5 w-3.5",(Te||Ee||Ae)&&"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":o===t,onClick:()=>h(t),className:ae("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",o===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))}),re?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:re}):null,o==="browse"?e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx(Et,{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(dr,{className:"h-3.5 w-3.5","aria-hidden":!0})},{id:"skillssh",label:r("skills.mode.skillssh")}],value:u===U?"skillssh":u===W?"popular":"repo",onChange:t=>{t==="skillssh"?w(U):t==="popular"?w(W):(u===U||u===W)&&w(xe)}}),u!==U&&u!==W?e.jsxs(La,{value:u,onValueChange:w,children:[e.jsxs(Pa,{"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(Da,{children:t=>t===xe?r("skills.source.all"):t}),e.jsx(Va,{className:"text-oai-gray-400",children:e.jsx(pa,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Ba,{children:e.jsx(Ta,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Ea,{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(Ye,{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(Ze,{children:r("skills.source.all")}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),C.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(Ye,{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(Ze,{children:n}),e.jsx(ea,{children:e.jsx(Be,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ma,{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=>S(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===U&&we()},"aria-label":r("skills.action.search_aria"),placeholder:u===U?r("skills.browse.placeholder_skillssh"):u===W?r("skills.browse.placeholder_popular"):u===xe?r("skills.browse.placeholder_all"):r("skills.browse.placeholder_repo",{repo:u}),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"})]}),u===U?e.jsxs(J,{type:"button",size:"sm",onClick:we,disabled:m.trim().length<2||q==="search",className:"focus:!ring-oai-gray-400/30",children:[q==="search"?e.jsx(te,{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.action.search")]}):u===W?null:e.jsxs(J,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(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(Oa,{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:C.length})]})]}):null,Je,e.jsx(Pr,{skill:ee,targets:le,busyKey:q,usage:ee&&(K[String(ee.directory||"").toLowerCase()]||K[String(ee.name||"").toLowerCase()])||null,hasUpdate:!!(ee?.id&&_e?.[ee.id]),updating:ee?q===Xe(ee):!1,onUpdate:oe,onClose:rt,onToggleTarget:He,onRemove:sa})]})}),e.jsx(ba,{open:!!N,title:r("skills.confirm.remove_title",{name:N?.name||N?.directory||""}),description:N?N.managed?r("skills.confirm.remove_managed"):r("skills.confirm.remove_local"):"",confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:q===_a(N||{}),onCancel:()=>H(null),onConfirm:na}),e.jsx(ba,{open:!!se,title:r("skills.confirm.bulk_remove_title",{count:se?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:q==="batch",onCancel:()=>B(null),onConfirm:ie})]})}export{Cs as SkillsPage,$r as buildLocallyInstalledKeys};