tokentracker-cli 0.87.7 → 0.87.9

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 (104) hide show
  1. package/README.md +3 -2
  2. package/README.zh-CN.md +3 -2
  3. package/dashboard/dist/assets/{AchievementBadge-4SSFyzNE.js → AchievementBadge-D3_hERkQ.js} +1 -1
  4. package/dashboard/dist/assets/{AchievementsPage-4ASCXja2.js → AchievementsPage-DZGjT92g.js} +2 -2
  5. package/dashboard/dist/assets/{AchievementsSection-CyaMYMol.js → AchievementsSection-CEzq3U3A.js} +1 -1
  6. package/dashboard/dist/assets/{BadgeDetailModal-CUWTCEru.js → BadgeDetailModal-D3_B8E--.js} +1 -1
  7. package/dashboard/dist/assets/{Card-C79yXijL.js → Card-CMXM3-lp.js} +1 -1
  8. package/dashboard/dist/assets/{ClawdAnimated-Cw6J-x_d.js → ClawdAnimated-lQxUKRzw.js} +1 -1
  9. package/dashboard/dist/assets/{CommandPalette-C1RQ58De.js → CommandPalette-BCGdAeFB.js} +1 -1
  10. package/dashboard/dist/assets/{CommunityStatsModal-CycaCGsd.js → CommunityStatsModal-BwE5h2y5.js} +1 -1
  11. package/dashboard/dist/assets/{ConfirmModal-hPuA2aup.js → ConfirmModal-8uhS2ccj.js} +1 -1
  12. package/dashboard/dist/assets/{Controls-DjunxsRS.js → Controls-CBEQTl2X.js} +1 -1
  13. package/dashboard/dist/assets/{DashboardPage-C5H5_EZN.js → DashboardPage-UE_3tGVy.js} +1 -1
  14. package/dashboard/dist/assets/{DevicePage-a1TT-0Bd.js → DevicePage-B06ybHJI.js} +1 -1
  15. package/dashboard/dist/assets/{DialogClose-CCRfnIbO.js → DialogClose-L_t-nrYm.js} +1 -1
  16. package/dashboard/dist/assets/DialogDescription-B7FFtR7A.js +1 -0
  17. package/dashboard/dist/assets/{DialogTitle-2Qa5pApU.js → DialogTitle-Bsft4VvL.js} +1 -1
  18. package/dashboard/dist/assets/{FadeIn-C3mpVy83.js → FadeIn-BNDdLqTu.js} +1 -1
  19. package/dashboard/dist/assets/{HeaderGithubStar-Dn_F7ByX.js → HeaderGithubStar-CvNaKDbl.js} +1 -1
  20. package/dashboard/dist/assets/{HoverTooltip-DaywO0Zz.js → HoverTooltip-D5j5IpNx.js} +1 -1
  21. package/dashboard/dist/assets/{IpCheckPage-oqGfnWb7.js → IpCheckPage-Csf8gMJW.js} +1 -1
  22. package/dashboard/dist/assets/{LandingPage-CX7dYsEX.js → LandingPage-BVSSwM0D.js} +2 -2
  23. package/dashboard/dist/assets/{LeaderboardAvatar-Bl-OMQ2x.js → LeaderboardAvatar-DXxSHqmP.js} +1 -1
  24. package/dashboard/dist/assets/{LeaderboardPage-yeWcgiVo.js → LeaderboardPage-DXj21BBR.js} +2 -2
  25. package/dashboard/dist/assets/{LeaderboardProfileModal-CDmZtQ_m.js → LeaderboardProfileModal-DbEzZGg4.js} +3 -3
  26. package/dashboard/dist/assets/{LeaderboardProfilePage-BqJYxoN1.js → LeaderboardProfilePage-DoIm3jB_.js} +1 -1
  27. package/dashboard/dist/assets/{LimitsPage-D8NFgXbZ.js → LimitsPage-D_tpQrUM.js} +1 -1
  28. package/dashboard/dist/assets/{LocalOnlyNotice-DjdhDEiq.js → LocalOnlyNotice-DBi5iuPr.js} +1 -1
  29. package/dashboard/dist/assets/{LoginCard-jQXAmSQb.js → LoginCard-qDIJgUX1.js} +1 -1
  30. package/dashboard/dist/assets/{LoginModal-q4G6EN7b.js → LoginModal-D4b5p4u1.js} +1 -1
  31. package/dashboard/dist/assets/{LoginPage-BklWSXzs.js → LoginPage-CsSgItFA.js} +1 -1
  32. package/dashboard/dist/assets/{PetPage-DyWuMUTA.js → PetPage-B-wElg5q.js} +1 -1
  33. package/dashboard/dist/assets/{PopoverPopup-Dbxed_FL.js → PopoverPopup-9C_VarUQ.js} +1 -1
  34. package/dashboard/dist/assets/{ProviderIcon-ChYuSSfj.js → ProviderIcon-CciEdEeR.js} +1 -1
  35. package/dashboard/dist/assets/{ResetPasswordPage-DJww1dxo.js → ResetPasswordPage-lsI8qlzE.js} +1 -1
  36. package/dashboard/dist/assets/{SegmentedControl-Dr73_QVm.js → SegmentedControl-BGonMV45.js} +1 -1
  37. package/dashboard/dist/assets/{Select-BMCy_8oY.js → Select-DhRrGrDT.js} +1 -1
  38. package/dashboard/dist/assets/{SelectItemText-BRU7mlBI.js → SelectItemText-ClMYgZsa.js} +1 -1
  39. package/dashboard/dist/assets/{ServiceStatusPage-DDao-oTH.js → ServiceStatusPage-DuzttgL7.js} +1 -1
  40. package/dashboard/dist/assets/{SessionsPage-BjngkrsY.js → SessionsPage-gZbxx0f_.js} +1 -1
  41. package/dashboard/dist/assets/{SettingsPage-Dsftjg5j.js → SettingsPage-NhxTrVNW.js} +1 -1
  42. package/dashboard/dist/assets/{SkillsPage-igML0DOZ.js → SkillsPage-BeXojJqQ.js} +1 -1
  43. package/dashboard/dist/assets/{TokenGalaxy-BBETSYe7.js → TokenGalaxy-DM49zKzo.js} +1 -1
  44. package/dashboard/dist/assets/{ToolbarRootContext-CzEAxfqj.js → ToolbarRootContext-BfvoVNMW.js} +1 -1
  45. package/dashboard/dist/assets/{TrendMonitor-JV6lkw-s.js → TrendMonitor-Bu-dXcrV.js} +1 -1
  46. package/dashboard/dist/assets/{WidgetsPage-GpUmv0hI.js → WidgetsPage-D2Wo7seE.js} +1 -1
  47. package/dashboard/dist/assets/{WrappedPage-SP2r4wf1.js → WrappedPage-BXAwic4D.js} +1 -1
  48. package/dashboard/dist/assets/{__vite-browser-external-AQgdBxou.js → __vite-browser-external-BDEQk--l.js} +4 -3
  49. package/dashboard/dist/assets/{agent-logos-DxwSc05k.js → agent-logos-DMEEHjG7.js} +1 -1
  50. package/dashboard/dist/assets/{arrow-up-right-CDW5zn0Q.js → arrow-up-right-gNviKtY8.js} +1 -1
  51. package/dashboard/dist/assets/{check-CQfDkdqM.js → check-Cvg5pmYP.js} +1 -1
  52. package/dashboard/dist/assets/{chevron-right-DDFSY4w-.js → chevron-right-DxdaNTo8.js} +1 -1
  53. package/dashboard/dist/assets/{copy-hxnyMdBa.js → copy-BNIJL7bf.js} +1 -1
  54. package/dashboard/dist/assets/{download-DOUBKxcf.js → download-C9McJlPa.js} +1 -1
  55. package/dashboard/dist/assets/{external-link-CVipCZOa.js → external-link-C_IU6zDK.js} +1 -1
  56. package/dashboard/dist/assets/{flame-C-QU6mPf.js → flame-CII7X8Je.js} +1 -1
  57. package/dashboard/dist/assets/{format-tokens-DRX15id1.js → format-tokens-DuQbGpPt.js} +1 -1
  58. package/dashboard/dist/assets/{icons-ajxtn_0O.js → icons-B1YTqnxG.js} +1 -1
  59. package/dashboard/dist/assets/{index-DnVXRsqb.js → index-BRMxraNK.js} +1 -1
  60. package/dashboard/dist/assets/{index-OJC-yROZ.js → index-Dc9xsIu2.js} +1 -1
  61. package/dashboard/dist/assets/{index-Bq5VZMkS.js → index-QtcYir6O.js} +1 -1
  62. package/dashboard/dist/assets/{info-eITfPd17.js → info-CIgVqJoj.js} +1 -1
  63. package/dashboard/dist/assets/{limits-providers-TMq74bRy.js → limits-providers-B31NsGar.js} +1 -1
  64. package/dashboard/dist/assets/{link-2-D778MOmL.js → link-2-DTPXzHuB.js} +1 -1
  65. package/dashboard/dist/assets/{loader-circle-uN5rBNIF.js → loader-circle-CgQSyCz8.js} +1 -1
  66. package/dashboard/dist/assets/{maximize-2-C4FBbMpN.js → maximize-2-BL5J4aHZ.js} +1 -1
  67. package/dashboard/dist/assets/{modifiers.esm-DLeiQDTT.js → modifiers.esm-s_rzcEf2.js} +1 -1
  68. package/dashboard/dist/assets/{monitor-smartphone-C-obu2-u.js → monitor-smartphone-C9ei_xde.js} +1 -1
  69. package/dashboard/dist/assets/{provider-display-Bjl8tmYu.js → provider-display-ZgvoJi05.js} +2 -2
  70. package/dashboard/dist/assets/{react-Diah7uAT.js → react-DhfPVGOm.js} +1 -1
  71. package/dashboard/dist/assets/{search-B0bPOquo.js → search-Ba_MWO7q.js} +1 -1
  72. package/dashboard/dist/assets/{skills-api-6otf2Sdl.js → skills-api-BkmJmyg1.js} +1 -1
  73. package/dashboard/dist/assets/{sortable.esm-DcrJaOfF.js → sortable.esm-Bmd5t12E.js} +1 -1
  74. package/dashboard/dist/assets/{store-DOs4omJM.js → store-BxRQs9yc.js} +1 -1
  75. package/dashboard/dist/assets/{terminal-CpMZjaGk.js → terminal-BzUwAs4g.js} +1 -1
  76. package/dashboard/dist/assets/{trash-2-BQYnn3zf.js → trash-2-CCprY7cu.js} +1 -1
  77. package/dashboard/dist/assets/{use-community-stats-CdL4zXXV.js → use-community-stats-TCdPJ_ir.js} +1 -1
  78. package/dashboard/dist/assets/{use-limits-display-prefs-DUh4f8f4.js → use-limits-display-prefs-CNF9luO6.js} +1 -1
  79. package/dashboard/dist/assets/{use-ordered-list-DVs0Ik3O.js → use-ordered-list-BlTuSYJy.js} +1 -1
  80. package/dashboard/dist/assets/use-reduced-motion-CfiR91Eg.js +1 -0
  81. package/dashboard/dist/assets/{use-session-efficiency-pref-CGggPI6Y.js → use-session-efficiency-pref-iHS0O_Fo.js} +1 -1
  82. package/dashboard/dist/assets/{use-transform-DMj91FEL.js → use-transform-CcVfL3mi.js} +1 -1
  83. package/dashboard/dist/assets/{use-usage-limits-xJOXzuZG.js → use-usage-limits-Xdy-Y_1Z.js} +1 -1
  84. package/dashboard/dist/assets/{useCurrency-BQRBx-KO.js → useCurrency-IXccXbmx.js} +1 -1
  85. package/dashboard/dist/assets/{useScrollLock-DuTPOBl8.js → useScrollLock-BEVewfZm.js} +1 -1
  86. package/dashboard/dist/assets/{useTokenFormat-Dd95ph6d.js → useTokenFormat-Cihv3Ghl.js} +1 -1
  87. package/dashboard/dist/assets/{zap-DJMdRI6y.js → zap-zG2Fbb5_.js} +1 -1
  88. package/dashboard/dist/brand-logos/omp.svg +33 -0
  89. package/dashboard/dist/brand-logos/pi.svg +16 -0
  90. package/dashboard/dist/index.html +1 -1
  91. package/dashboard/dist/ip-check.html +1 -1
  92. package/dashboard/dist/leaderboard.html +1 -1
  93. package/dashboard/dist/share.html +1 -1
  94. package/package.json +1 -1
  95. package/src/commands/init.js +49 -8
  96. package/src/commands/status.js +12 -5
  97. package/src/commands/sync.js +245 -1
  98. package/src/commands/uninstall.js +36 -1
  99. package/src/lib/install-resolver.js +22 -6
  100. package/src/lib/omp-hook.js +589 -0
  101. package/src/lib/pricing/seed-snapshot.json +1 -1
  102. package/src/lib/rollout.js +272 -32
  103. package/dashboard/dist/assets/DialogDescription-C99d5K4r.js +0 -1
  104. package/dashboard/dist/assets/use-reduced-motion--_Yc7AWk.js +0 -1
@@ -1 +1 @@
1
- import{m as Ra,r as i,U as xt,z as ma,j as e,X as Ee,c as r,e as ae,aZ as la,aA as Pa,a_ as ht,y as pt,a$ as fa,b0 as ft,b1 as yt,a0 as bt,b2 as ya,b3 as kt,b4 as wt,A as vt,b5 as jt,aC as Nt,aB as St,b6 as Ct,a6 as _t,a as Lt,b7 as Rt,as as Pt,J as It,B as X,R as Bt,d as Et,a7 as Be}from"./__vite-browser-external-AQgdBxou.js";import{L as Tt}from"./LocalOnlyNotice-DjdhDEiq.js";import{C as Ot}from"./Card-C79yXijL.js";import{C as ba}from"./ConfirmModal-hPuA2aup.js";import{S as $t,I as ga}from"./SegmentedControl-Dr73_QVm.js";import{I as Ia}from"./info-eITfPd17.js";import{P as we}from"./ProviderIcon-ChYuSSfj.js";import{m as ka}from"./react-Diah7uAT.js";import{u as Dt}from"./useCurrency-BQRBx-KO.js";import{E as da}from"./external-link-CVipCZOa.js";import{L as te}from"./loader-circle-uN5rBNIF.js";import{M as Ba}from"./monitor-smartphone-C-obu2-u.js";import{C as Te}from"./check-CQfDkdqM.js";import{T as xa}from"./trash-2-BQYnn3zf.js";import{A as Mt}from"./index-OJC-yROZ.js";import{u as At}from"./use-reduced-motion--_Yc7AWk.js";import{u as Ut,s as Ft,k as Ea,l as zt,m as Kt,n as Vt,o as qt,p as Gt,S as Ta,c as Oa,d as $a,e as Da,f as Ma,g as Aa,h as Xe,j as Je,i as Ye}from"./SelectItemText-BRU7mlBI.js";import{t as Ht,u as ca,m as Wt}from"./useScrollLock-DuTPOBl8.js";import{u as Qt,C as ha}from"./ToolbarRootContext-CzEAxfqj.js";import{g as Xt,a as Jt,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 Sa,l as or,n as lr}from"./skills-api-6otf2Sdl.js";import{F as dr}from"./flame-C-QU6mPf.js";import{S as ua}from"./search-B0bPOquo.js";import{D as Ua}from"./download-DOUBKxcf.js";import{C as cr}from"./chevron-right-DDFSY4w-.js";import{P as Fa,a as za,b as Ka,c as Va,d as qa}from"./PopoverPopup-Dbxed_FL.js";import"./arrow-up-right-CDW5zn0Q.js";import"./DialogTitle-2Qa5pApU.js";import"./store-DOs4omJM.js";import"./DialogDescription-C99d5K4r.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"}]],Ga=Ra("circle-arrow-up",ur);const mr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ha=Ra("plus",mr),Wa=i.forwardRef(function(s,d){const{render:o,className:h,style:x,...g}=s,{store:c}=Ut(),k={open:xt(c,Ft.open)};return ma("span",s,{state:k,ref:d,props:[{"aria-hidden":!0,children:"▼"},g],stateAttributesMapping:Ht})}),gr="tt:hint:dismissed:";function Qa(a){return gr+a}function xr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Qa(a))==="1"}catch{return!1}}function hr({id:a,children:s,className:d,ariaLabel:o}){const[h,x]=i.useState(()=>xr(a)),g=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Qa(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(Ee,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ia,{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 pr(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}let Ca=(function(a){return a.checked="data-checked",a.unchecked="data-unchecked",a.indeterminate="data-indeterminate",a.disabled="data-disabled",a.readonly="data-readonly",a.required="data-required",a.valid="data-valid",a.invalid="data-invalid",a.touched="data-touched",a.dirty="data-dirty",a.filled="data-filled",a.focused="data-focused",a})({});function Xa(a){return i.useMemo(()=>({checked(s){return a.indeterminate?{}:s?{[Ca.checked]:""}:{[Ca.unchecked]:""}},...Ea}),[a.indeterminate])}const fr=i.createContext({disabled:!1});function yr(){return i.useContext(fr)}function br(a,s,d,o=!0,h){const[x,g]=i.useState(),c=ca(h?`${h}-label`:void 0),y=a??s??x;return la(()=>{const k=a||s||!o?void 0:kr(d.current,c);x!==k&&g(k)}),y}function kr(a,s){const d=wr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function wr(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 vr=i.createContext(void 0);function jr(a=!0){const s=i.useContext(vr);if(s===void 0&&!a)throw new Error(Pa(3));return s}const Ja=i.createContext(void 0);function Nr(){const a=i.useContext(Ja);if(a===void 0)throw new Error(Pa(14));return a}const Sr="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:S,name:L,onCheckedChange:u,parent:w=!1,readOnly:m=!1,render:C,required:P=!1,uncheckedValue:M,value:A,nativeButton:z=!1,style:ce,...I}=s,{clearErrors:ve}=zt(),{disabled:xe,name:he,setDirty:_,setFilled:$,setFocused:U,setTouched:O,state:J,validationMode:H,validityData:je,validation:Oe}=Kt(),Ke=yr(),{labelId:$e,controlId:Ve,registerControlId:re,getDescriptionProps:D}=Vt(),N=jr(),se=N?.parent,ne=se&&N.allValues,B=xe||Ke.disabled||N?.disabled||c,K=he??L,R=A??K,Ne=ca(),qe=ca();let W=Ve;ne?W=w?qe:`${se.id}-${R}`:k&&(W=k);let Se={};ne&&(w?Se=N.parent.getParentProps():R&&(Se=N.parent.getChildProps(R)));const{checked:pe=o,indeterminate:ea=p,onCheckedChange:De,...Ge}=Se,Y=N?.value,fe=N?.setValue,Ce=N?.defaultValue,ue=i.useRef(null),ie=ht(()=>Symbol("checkbox-control")),Z=i.useRef(!1),{getButtonProps:_e,buttonRef:ye}=pt({disabled:B,native:z}),Q=N?.validation??Oe,[E,aa]=qt({controlled:R&&Y&&!w?Y.includes(R):pe,default:R&&Ce&&!w?Ce.includes(R):x,name:"Checkbox",state:"checked"}),Le=ne?!!pe:E,me=ne&&ea||p;la(()=>{re!==fa&&(Z.current=!0,re(ie.current,W))},[W,re,ie]),i.useEffect(()=>{const b=ie.current;return()=>{!Z.current||re===fa||(Z.current=!1,re(b,void 0))}},[re,ie]),Gt(ue,Ne,E,void 0,!N&&!B,L);const T=i.useRef(null),ta=ft(S,T,Q.inputRef,Q.registerInput),ra=br(g,$e,T,!z,W??void 0);la(()=>{T.current&&(T.current.indeterminate=me,E&&$(!0))},[E,me,$]),Qt(E,()=>{N||(ve(K),$(E),_(E!==je.initialValue),Q.change(E))});const sa=yt({checked:E,disabled:B,form:y,name:w?void 0:K,id:z?void 0:W??void 0,required:P,ref:ta,style:K?kt:wt,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(b){if(b.nativeEvent.defaultPrevented)return;if(m){b.preventDefault();return}const V=b.currentTarget.checked,oe=vt(jt,b.nativeEvent);if(u?.(V,oe),!oe.isCanceled&&(De?.(V,oe),!oe.isCanceled&&(aa(V),R&&Y&&fe&&!w&&!ne))){const le=V?[...Y,R]:Y.filter(Pe=>Pe!==R);fe(le,oe)}},onFocus(){ue.current?.focus()}},A!==void 0?{value:(N?E&&A:A)||""}:bt,D,b=>Q.getValidationProps(B,b));i.useEffect(()=>{if(!se||!R)return;const b=se.disabledStatesRef.current;return b.set(R,B),()=>{b.delete(R)}},[se,B,R]);const Re=i.useMemo(()=>({...J,checked:Le,disabled:B,readOnly:m,required:P,indeterminate:me}),[J,Le,B,m,P,me]),Me=Xa(Re),na=ma("span",s,{state:Re,ref:[ye,ue,d,N?.registerControlRef],props:[{id:z?W??void 0:Ne,role:"checkbox","aria-checked":me?"mixed":Le,"aria-readonly":m||void 0,"aria-required":P||void 0,"aria-labelledby":ra,[Sr]:w?"":void 0,onFocus(){B||U(!0)},onBlur(){const b=T.current;b&&(O(!0),U(!1),H==="onBlur"&&Q.commit(N?Y:b.checked))},onKeyDown(b){if(b.key!=="Enter"||(b.preventBaseUIHandler(),b.defaultPrevented))return;const V=T.current?.form??null,oe=b.currentTarget,le=b.nativeEvent,Pe=b.preventDefault,Ie=le.preventDefault;let Ae=!1;b.preventDefault=()=>{Ae=!0,Pe.call(b)},le.preventDefault=()=>{Ae=!0,Ie.call(le)},Ie.call(le),ya(oe).queueMicrotask(()=>{b.preventDefault=Pe,le.preventDefault=Ie,Ae||pr(V)?.click()})},onClick(b){if(m||B)return;b.preventDefault();const V=T.current;V&&V.dispatchEvent(new(ya(V)).PointerEvent("click",{bubbles:!0,shiftKey:b.shiftKey,ctrlKey:b.ctrlKey,altKey:b.altKey,metaKey:b.metaKey}))}},I,Ge,_e,D,b=>Q.getValidationProps(B,b)],stateAttributesMapping:Me});return e.jsxs(Ja.Provider,{value:Re,children:[na,!E&&!N&&K&&!w&&M!==void 0&&e.jsx("input",{type:"hidden",form:y,name:K,value:M,disabled:B}),e.jsx("input",{...sa,suppressHydrationWarning:!0})]})}),_r=i.forwardRef(function(s,d){const{render:o,className:h,style:x,keepMounted:g=!1,...c}=s,y=Nr(),k=y.checked||y.indeterminate,{mounted:p,transitionStatus:S,setMounted:L}=Wt(k),u=i.useRef(null),w={...y,transitionStatus:S};Nt({open:k,ref:u,onComplete(){k||L(!1)}});const C={...Xa(y),...St,...Ea},P=g||p,M=ma("span",s,{ref:[d,u],state:w,stateAttributesMapping:C,props:c});return P?M:null});function Lr(a,s){return`target:${a}:${s}`}function Rr(a){return`remove:${a.id||a.directory}`}function Ya(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function Pr(a){const s=Ya(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 Ir(a){const s=Ya(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 ia({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 Br({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){return e.jsx(Mt,{children:a?e.jsx(Er,{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 Er({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){const p=At(),{currency:S,rate:L}=Dt(),u=i.useRef(null);i.useEffect(()=>{const _=U=>{U.key==="Escape"&&(U.stopPropagation(),c?.())},$=U=>{const O=U.target;O instanceof Element&&(u.current?.contains(O)||O.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",$),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",$)}},[c]);const w=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),C=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,P=new Set(a.targets||[]),M=!!(a.readOnly||a.remote),A=!!a.remote,z=Array.isArray(a.deviceSources)?a.deviceSources:[],ce=!A&&(!M||P.has("claude")),I=d===Rr(a),ve=Pr(o?.lastUsedAt),xe=!!(o&&o.invocations>0),he=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:he,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:C,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:C,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(da,{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(Ee,{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(Ga,{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,M?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(A?"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,z.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:z.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(Ba,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:_.name})]},_.id))})]}):null,ce?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(ia,{label:r("skills.usage.invocations"),children:Ct(o?.invocations||0)}),e.jsx(ia,{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",Ir(o?.lastUsedAt)),"aria-hidden":!0}),xe?ve||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ia,{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(Ia,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:_t(o?.cost||0,{currency:S,rate:L})})]}),xe?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,M?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 $=P.has(_.id),U=d===Lr(a.id||a.directory,_.id),O=`skill-detail-sync-${a.id||a.directory}-${_.id}`;return e.jsxs("label",{htmlFor:O,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:O,checked:$,disabled:U,onCheckedChange:J=>y?.(a,_.id,!!J),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(_r,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Te,{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(we,{provider:_.id,size:16})}),e.jsx("span",{className:"flex-1",children:_.label}),U?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},_.id)})})]})]}),M?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:I,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:[I?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(xa,{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 Tr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),oa=["claude","codex"],G="popular",Or={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"},ge="all",F="skillssh";function Ze(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Za(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function $r(a){return Za(a).split("/").filter(Boolean).pop()||""}function Dr(a){if(a.repoOwner||a.repoName)return"";const s=Za(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function _a(a){const s=$r(a.directory);return s?`dir:${s}`:""}function et(a){const s=new Set([Ze(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Dr(a);return d&&s.add(d),s}function Mr(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function Ar(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Mr(d))for(const o of et(d))s.add(o);return s}function Qe(a){return`install:${Ze(a)}`}function La(a){return`remove:${a.id||a.directory}`}function at(a,s){return`target:${a}:${s}`}function ke(a){return a.id||a.directory}function pa(a){return a.manageable!==!1}function Ur({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&&Or[a.id],!g&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(we,{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 Fr({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):pa(c))&&g.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:g.map(c=>e.jsx(Ur,{target:c,state:a.targetStates?.[c.id]||"off",busy:o===at(ke(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 zr({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,S=[a.directory,p,a.sourceName].filter(Boolean).join(" · "),L=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:S,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(Ga,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Fr,{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||L.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,L.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:L.map(m=>m.name).join(", "),children:[e.jsx(Ba,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:L.map(m=>m.name).join(", ")})})]}):null]}):null]})}function Kr({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(Ta,{value:a,onValueChange:d,children:[e.jsxs(Oa,{"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($a,{children:p=>p==="all"?r("skills.filter.agent_all"):s.find(S=>S.id===p)?.label||p}),e.jsx(Wa,{className:"text-oai-gray-400",children:e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Da,{children:e.jsx(Ma,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Aa,{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(Xe,{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(Je,{children:r("skills.filter.agent_all")}),e.jsx(Ye,{children:e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(p=>e.jsxs(Xe,{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(we,{provider:p.id,size:14}),e.jsx(Je,{children:p.label})]}),e.jsx(Ye,{children:e.jsx(Te,{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(ua,{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(ga,{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(Ee,{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(Ee,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Vr({count:a,targets:s,busy:d,onBulkSync:o,onBulkRemove:h,onClear:x}){const g=s.filter(pa);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(Fa,{children:[e.jsxs(za,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Ua,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(ha,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Ka,{children:e.jsx(Va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{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(we,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:h,children:[e.jsx(xa,{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(Ee,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function qr({items:a,totalCount:s,targets:d,agentOptions:o,agentFilter:h,onAgentFilter:x,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p,selectedId:S,onSelect:L,onToggleTarget:u,busyKey:w,updates:m,selectedIds:C,onToggleSelect:P,onClearSelection:M,onBulkSync:A,onBulkRemove:z}){const ce=C.size;return e.jsxs("div",{children:[ce>0?e.jsx(Vr,{count:ce,targets:d,busy:w==="batch",onBulkSync:A,onBulkRemove:z,onClear:M}):e.jsx(Kr,{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(X,{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(I=>e.jsx(zr,{skill:I,targets:d,selected:S===(I.id||I.directory),onSelect:L,selectable:!I.readOnly&&!I.remote,checked:C.has(ke(I)),onToggleSelect:P,onToggleTarget:u,hasUpdate:!!(I.id&&m?.[I.id]),busyKey:w},ke(I)))})]})}const Gr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},Hr=Et.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(C=>C.id===m))),p=m=>{k(C=>C.includes(m)?C.filter(P=>P!==m):[...C,m])},S=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,L=S?`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(C=>C.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Ot,{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(da,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),S||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:[L?e.jsxs("a",{href:L,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:L,children:[e.jsx("span",{className:"truncate",children:S}),e.jsx(da,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,S&&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(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>c?.(s),className:"w-full",children:[e.jsx(Te,{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(Fa,{children:[e.jsx(za,{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(Ka,{children:e.jsx(Va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{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 C=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:C,onChange:()=>p(m.id)}),e.jsx(we,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(X,{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(Ua,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Wr({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(ga,{value:s,onChange:g=>d(g.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(X,{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(Ha,{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(X,{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(xa,{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 Qr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ss(){const a=Lt()||{},s=!!a.signedIn,d=a.getAccessToken,[o,h]=i.useState(Qr),[x,g]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[k,p]=i.useState([]),[S,L]=i.useState([]),[u,w]=i.useState(ge),[m,C]=i.useState(""),[P,M]=i.useState(""),[A,z]=i.useState(""),[ce,I]=i.useState(""),[ve,xe]=i.useState(""),[he,_]=i.useState(!1),[$,U]=i.useState("all"),[O,J]=i.useState(null),[H,je]=i.useState(""),[Oe,Ke]=i.useState(!0),[$e,Ve]=i.useState(!1),[re,D]=i.useState(""),[N,se]=i.useState(null),[ne,B]=i.useState(null),[K,R]=i.useState(()=>new Set),[Ne,qe]=i.useState({}),[W,Se]=i.useState({}),[pe,ea]=i.useState([]),[De,Ge]=i.useState(!1),Y=i.useRef(!1),fe=i.useRef(0),Ce=i.useMemo(()=>Ar(x.skills),[x.skills]),ue=i.useCallback(async()=>{const t=++fe.current,n=await Xt();if(fe.current!==t)return;const l={skills:n.skills||[],targets:n.targets||[]};g(l);const f=Rt();!s||!Pt()||!f||typeof d!="function"||(async()=>{try{const v=await d();if(!v||fe.current!==t)return;const[j]=await Promise.allSettled([Jt(v),Yt({accessToken:v,deviceId:f,skills:l.skills})]);if(j.status!=="fulfilled")return;const Fe=j.value;if(fe.current!==t)return;g({targets:l.targets,skills:Zt(l.skills,Fe,f)})}catch{}})()},[d,s]),ie=i.useCallback(async()=>{const t=await er();L(t.repos||[])},[]),Z=i.useCallback(async({force:t=!1}={})=>{Ve(!0);try{const n=await ar({force:t});y(n.skills||[])}finally{Ve(!1)}},[]),_e=i.useCallback(async({force:t=!1}={})=>{Ge(!0);try{const n=await tr({force:t});ea(n.skills||[])}finally{Ge(!1)}},[]),ye=i.useCallback(async()=>{try{const t=await rr();qe(t?.updates||{})}catch{qe({})}},[]),Q=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);Se(n)}catch{Se({})}},[]),E=i.useCallback(async()=>{Ke(!0),D("");try{await Promise.all([ue(),ie()])}catch(t){D(t?.message||r("skills.error.generic"))}finally{Ke(!1)}},[ue,ie]),aa=i.useCallback(async()=>{await E();const t=n=>D(n?.message||r("skills.error.generic"));o==="my"?(ye(),Q()):u===G?_e({force:!0}).catch(t):u!==F&&Z({force:!0}).catch(t)},[Z,E,_e,ye,Q,u,o]);i.useEffect(()=>{E()},[E]),i.useEffect(()=>{if(Y.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){Y.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"),J(f.id||f.directory)),Y.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===F||u===G||c.length===0&&Z().catch(t=>D(t?.message||r("skills.error.generic"))))},[c.length,Z,u,o]),i.useEffect(()=>{o!=="browse"||u!==G||pe.length===0&&_e().catch(t=>D(t?.message||r("skills.error.generic")))},[_e,pe.length,u,o]);const Le=Object.keys(Ne).length>0,me=Object.keys(W).length>0;if(i.useEffect(()=>{o==="my"&&(Le||ye(),me||Q())},[o,Le,me,ye,Q]),i.useEffect(()=>{const t=setTimeout(()=>M(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>I(A),120);return()=>clearTimeout(t)},[A]),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]),!Tr&&!It())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})});const T=async(t,n)=>{je(t),D("");try{await n(),await ue()}catch(l){D(l?.message||r("skills.error.generic"))}finally{je("")}},ta=(t,n)=>{const l=(n&&n.length?n:oa).filter(f=>(x.targets||[]).some(v=>v.id===f));T(Qe(t),async()=>{await wa(t,l);const f=l.map(v=>(x.targets||[]).find(j=>j.id===v)?.label||v).join(", ");Be({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},ra=t=>{t?.readOnly||t?.remote||se(t)},sa=()=>{const t=N;t&&(se(null),T(La(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);Be({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){D(f?.message||r("skills.error.generic"))}}}:void 0})}))},Re=(t,n,l)=>t?.readOnly||t?.remote?Promise.resolve():T(at(ke(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 Sa(t.directory,Array.from(f));const v={name:t.name||t.directory,agent:b(n)};Be({title:l?r("skills.toast.synced_one",v):r("skills.toast.unsynced_one",v),timeout:3e3})}),Me=i.useCallback(()=>R(new Set),[]),na=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const l=ke(t);R(f=>{const v=new Set(f);return n?v.add(l):v.delete(l),v})},[]),b=t=>(x.targets||[]).find(n=>n.id===t)?.label||t,V=t=>{const n=(x.skills||[]).filter(l=>K.has(ke(l))&&!l.readOnly&&!l.remote);n.length&&T("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 Sa(l.directory,Array.from(f))}Me(),Be({title:r("skills.toast.bulk_synced",{count:n.length,agent:b(t)}),timeout:4e3})})},oe=()=>{const t=(x.skills||[]).filter(n=>K.has(ke(n))&&!n.readOnly&&!n.remote);t.length&&B(t)},le=()=>{const t=ne;t&&(B(null),T("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);Me(),Be({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},Pe=t=>{!t?.repoOwner||!t?.repoName||T(Qe(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:oa),await ye(),Be({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},Ie=async()=>{const t=m.trim();if(!(t.length<2)){je("search"),D("");try{const n=await nr(t);p(n.skills||[])}catch(n){D(n?.message||r("skills.error.generic"))}finally{je("")}}},Ae=async()=>{const t=ve.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,l]=t.split("/");if(!n||!l){D(r("skills.repo.invalid"));return}await T("repo:add",async()=>{await lr({owner:n,name:l,branch:"main",enabled:!0}),xe(""),await ie(),await Z()})},tt=async t=>{await T(`repo:${t.owner}/${t.name}`,async()=>{await or(t.owner,t.name),await ie(),await Z()})},de=x.targets||[],rt=de.filter(pa),be=x.skills||[],st=i.useMemo(()=>{const t=$==="all"?be:be.filter(l=>(l.targets||[]).includes($)),n=ce.trim().toLowerCase();return n?t.filter(l=>(l.name||"").toLowerCase().includes(n)||(l.directory||"").toLowerCase().includes(n)||(l.description||"").toLowerCase().includes(n)):t},[be,$,ce]),nt=$!=="all",ee=i.useMemo(()=>O&&be.find(t=>(t.id||t.directory)===O)||null,[be,O]),it=i.useCallback(()=>{U("all"),z("")},[]),ot=i.useCallback(t=>{J(n=>{const l=t?.id||t?.directory||null;return n===l?null:l})},[]),lt=i.useCallback(()=>J(null),[]),dt=i.useCallback(t=>{const n=Ze(t).toLowerCase(),l=_a(t),f=(x.skills||[]).find(v=>{const j=et(v);return j.has(n)||l&&j.has(l)});f&&J(f.id||f.directory)},[x.skills]);i.useEffect(()=>{o!=="my"&&K.size&&R(new Set)},[o,K.size]),i.useEffect(()=>{O&&!ee&&J(null)},[ee,O]);const Ue=i.useMemo(()=>{const t=u===F?k:u===G?pe:c,l=u===F||u===G||u===ge?t:t.filter(j=>`${j.repoOwner}/${j.repoName}`===u),f=P.trim().toLowerCase();return(u===F||!f?l:l.filter(j=>(j.name||"").toLowerCase().includes(f)||(j.directory||"").toLowerCase().includes(f)||(j.description||"").toLowerCase().includes(f))).map(j=>{const Fe=Ze(j).toLowerCase(),q=_a(j);return{...j,installed:Ce.has(Fe)||q&&Ce.has(q)}})},[P,c,Ce,pe,k,u]),ct=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})}),ut=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")})]}),He=(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 We;if(Oe)We=ct;else if(o==="my")We=be.length?e.jsx(qr,{items:st,totalCount:be.length,targets:de,agentOptions:de,agentFilter:$,onAgentFilter:U,anyFilter:nt,onClearFilters:it,searchQuery:A,onSearchQuery:z,searchPlaceholder:r("skills.my.placeholder"),selectedId:O,onSelect:ot,onToggleTarget:Re,busyKey:H,updates:Ne,selectedIds:K,onToggleSelect:na,onClearSelection:Me,onBulkSync:V,onBulkRemove:oe}):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:[de.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:[...de,...de].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(we,{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:[...de,...de].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(we,{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(X,{type:"button",size:"sm",onClick:()=>h("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===F,n=u===G,l=S.length===0&&!t&&!n,f=$e&&!t&&!n||n&&De,v=!t&&!n&&(P.trim()!==""||u!==ge),j=()=>{C(""),w(ge)},Fe=!l&&!f&&(Ue.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:Ue.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(Ee,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let q;l?q=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?q=ut:t&&m.trim().length<2?q=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")}):Ue.length?q=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ue.map(ze=>e.jsx("div",{style:Gr,children:e.jsx(Hr,{skill:ze,installed:!!ze.installed,installing:H===Qe(ze),allTargets:rt,defaultTargets:oa,onInstall:ta,onManage:dt})},ze.id||ze.key))}):v?q=He("skills.empty.no_match",e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:j,children:r("skills.filter.clear")})):t?q=He("skills.empty.search"):n?q=He("skills.empty.popular"):q=He("skills.empty.browse");const mt=l||he?e.jsx("div",{className:"mb-5",children:e.jsx(Wr,{repos:S,repoInput:ve,onRepoInput:xe,busyKey:H,onAdd:Ae,onRemove:tt})}):null,gt=!he&&!t&&!n&&S.length<=1&&Ue.length>0?e.jsx(hr,{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;We=e.jsxs(e.Fragment,{children:[mt,Fe,q,gt]})}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(X,{type:"button",variant:"secondary",size:"sm",onClick:aa,disabled:Oe||$e||De,children:[e.jsx(Bt,{className:ae("mr-1.5 h-3.5 w-3.5",(Oe||$e||De)&&"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($t,{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===F?"skillssh":u===G?"popular":"repo",onChange:t=>{t==="skillssh"?w(F):t==="popular"?w(G):(u===F||u===G)&&w(ge)}}),u!==F&&u!==G?e.jsxs(Ta,{value:u,onValueChange:w,children:[e.jsxs(Oa,{"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($a,{children:t=>t===ge?r("skills.source.all"):t}),e.jsx(Wa,{className:"text-oai-gray-400",children:e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Da,{children:e.jsx(Ma,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Aa,{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(Xe,{value:ge,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(Je,{children:r("skills.source.all")}),e.jsx(Ye,{children:e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),S.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(Xe,{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(Je,{children:n}),e.jsx(Ye,{children:e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ua,{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(ga,{type:"search",value:m,onChange:t=>C(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===F&&Ie()},"aria-label":r("skills.action.search_aria"),placeholder:u===F?r("skills.browse.placeholder_skillssh"):u===G?r("skills.browse.placeholder_popular"):u===ge?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===F?e.jsxs(X,{type:"button",size:"sm",onClick:Ie,disabled:m.trim().length<2||H==="search",className:"focus:!ring-oai-gray-400/30",children:[H==="search"?e.jsx(te,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ua,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):u===G?null:e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(t=>!t),"aria-expanded":he,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(Ha,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.browse.manage_sources"),e.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:S.length})]})]}):null,We,e.jsx(Br,{skill:ee,targets:de,busyKey:H,usage:ee&&(W[String(ee.directory||"").toLowerCase()]||W[String(ee.name||"").toLowerCase()])||null,hasUpdate:!!(ee?.id&&Ne?.[ee.id]),updating:ee?H===Qe(ee):!1,onUpdate:Pe,onClose:lt,onToggleTarget:Re,onRemove:ra})]})}),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:H===La(N||{}),onCancel:()=>se(null),onConfirm:sa}),e.jsx(ba,{open:!!ne,title:r("skills.confirm.bulk_remove_title",{count:ne?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:H==="batch",onCancel:()=>B(null),onConfirm:le})]})}export{Ss as SkillsPage,Ar as buildLocallyInstalledKeys};
1
+ import{m as Ra,r as i,U as xt,z as ma,j as e,X as Ee,c as r,e as ae,aZ as la,aA as Pa,a_ as ht,y as pt,a$ as fa,b0 as ft,b1 as yt,a0 as bt,b2 as ya,b3 as kt,b4 as wt,A as vt,b5 as jt,aC as Nt,aB as St,b6 as Ct,a6 as _t,a as Lt,b7 as Rt,as as Pt,J as It,B as X,R as Bt,d as Et,a7 as Be}from"./__vite-browser-external-BDEQk--l.js";import{L as Tt}from"./LocalOnlyNotice-DBi5iuPr.js";import{C as Ot}from"./Card-CMXM3-lp.js";import{C as ba}from"./ConfirmModal-8uhS2ccj.js";import{S as $t,I as ga}from"./SegmentedControl-BGonMV45.js";import{I as Ia}from"./info-CIgVqJoj.js";import{P as we}from"./ProviderIcon-CciEdEeR.js";import{m as ka}from"./react-DhfPVGOm.js";import{u as Dt}from"./useCurrency-IXccXbmx.js";import{E as da}from"./external-link-C_IU6zDK.js";import{L as te}from"./loader-circle-CgQSyCz8.js";import{M as Ba}from"./monitor-smartphone-C9ei_xde.js";import{C as Te}from"./check-Cvg5pmYP.js";import{T as xa}from"./trash-2-CCprY7cu.js";import{A as Mt}from"./index-Dc9xsIu2.js";import{u as At}from"./use-reduced-motion-CfiR91Eg.js";import{u as Ut,s as Ft,k as Ea,l as zt,m as Kt,n as Vt,o as qt,p as Gt,S as Ta,c as Oa,d as $a,e as Da,f as Ma,g as Aa,h as Xe,j as Je,i as Ye}from"./SelectItemText-ClMYgZsa.js";import{t as Ht,u as ca,m as Wt}from"./useScrollLock-BEVewfZm.js";import{u as Qt,C as ha}from"./ToolbarRootContext-BfvoVNMW.js";import{g as Xt,a as Jt,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 Sa,l as or,n as lr}from"./skills-api-BkmJmyg1.js";import{F as dr}from"./flame-CII7X8Je.js";import{S as ua}from"./search-Ba_MWO7q.js";import{D as Ua}from"./download-C9McJlPa.js";import{C as cr}from"./chevron-right-DxdaNTo8.js";import{P as Fa,a as za,b as Ka,c as Va,d as qa}from"./PopoverPopup-9C_VarUQ.js";import"./arrow-up-right-gNviKtY8.js";import"./DialogTitle-Bsft4VvL.js";import"./store-BxRQs9yc.js";import"./DialogDescription-B7FFtR7A.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"}]],Ga=Ra("circle-arrow-up",ur);const mr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ha=Ra("plus",mr),Wa=i.forwardRef(function(s,d){const{render:o,className:h,style:x,...g}=s,{store:c}=Ut(),k={open:xt(c,Ft.open)};return ma("span",s,{state:k,ref:d,props:[{"aria-hidden":!0,children:"▼"},g],stateAttributesMapping:Ht})}),gr="tt:hint:dismissed:";function Qa(a){return gr+a}function xr(a){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Qa(a))==="1"}catch{return!1}}function hr({id:a,children:s,className:d,ariaLabel:o}){const[h,x]=i.useState(()=>xr(a)),g=i.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(Qa(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(Ee,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[e.jsx(Ia,{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 pr(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}let Ca=(function(a){return a.checked="data-checked",a.unchecked="data-unchecked",a.indeterminate="data-indeterminate",a.disabled="data-disabled",a.readonly="data-readonly",a.required="data-required",a.valid="data-valid",a.invalid="data-invalid",a.touched="data-touched",a.dirty="data-dirty",a.filled="data-filled",a.focused="data-focused",a})({});function Xa(a){return i.useMemo(()=>({checked(s){return a.indeterminate?{}:s?{[Ca.checked]:""}:{[Ca.unchecked]:""}},...Ea}),[a.indeterminate])}const fr=i.createContext({disabled:!1});function yr(){return i.useContext(fr)}function br(a,s,d,o=!0,h){const[x,g]=i.useState(),c=ca(h?`${h}-label`:void 0),y=a??s??x;return la(()=>{const k=a||s||!o?void 0:kr(d.current,c);x!==k&&g(k)}),y}function kr(a,s){const d=wr(a);if(d)return!d.id&&s&&(d.id=s),d.id||void 0}function wr(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 vr=i.createContext(void 0);function jr(a=!0){const s=i.useContext(vr);if(s===void 0&&!a)throw new Error(Pa(3));return s}const Ja=i.createContext(void 0);function Nr(){const a=i.useContext(Ja);if(a===void 0)throw new Error(Pa(14));return a}const Sr="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:S,name:L,onCheckedChange:u,parent:w=!1,readOnly:m=!1,render:C,required:P=!1,uncheckedValue:M,value:A,nativeButton:z=!1,style:ce,...I}=s,{clearErrors:ve}=zt(),{disabled:xe,name:he,setDirty:_,setFilled:$,setFocused:U,setTouched:O,state:J,validationMode:H,validityData:je,validation:Oe}=Kt(),Ke=yr(),{labelId:$e,controlId:Ve,registerControlId:re,getDescriptionProps:D}=Vt(),N=jr(),se=N?.parent,ne=se&&N.allValues,B=xe||Ke.disabled||N?.disabled||c,K=he??L,R=A??K,Ne=ca(),qe=ca();let W=Ve;ne?W=w?qe:`${se.id}-${R}`:k&&(W=k);let Se={};ne&&(w?Se=N.parent.getParentProps():R&&(Se=N.parent.getChildProps(R)));const{checked:pe=o,indeterminate:ea=p,onCheckedChange:De,...Ge}=Se,Y=N?.value,fe=N?.setValue,Ce=N?.defaultValue,ue=i.useRef(null),ie=ht(()=>Symbol("checkbox-control")),Z=i.useRef(!1),{getButtonProps:_e,buttonRef:ye}=pt({disabled:B,native:z}),Q=N?.validation??Oe,[E,aa]=qt({controlled:R&&Y&&!w?Y.includes(R):pe,default:R&&Ce&&!w?Ce.includes(R):x,name:"Checkbox",state:"checked"}),Le=ne?!!pe:E,me=ne&&ea||p;la(()=>{re!==fa&&(Z.current=!0,re(ie.current,W))},[W,re,ie]),i.useEffect(()=>{const b=ie.current;return()=>{!Z.current||re===fa||(Z.current=!1,re(b,void 0))}},[re,ie]),Gt(ue,Ne,E,void 0,!N&&!B,L);const T=i.useRef(null),ta=ft(S,T,Q.inputRef,Q.registerInput),ra=br(g,$e,T,!z,W??void 0);la(()=>{T.current&&(T.current.indeterminate=me,E&&$(!0))},[E,me,$]),Qt(E,()=>{N||(ve(K),$(E),_(E!==je.initialValue),Q.change(E))});const sa=yt({checked:E,disabled:B,form:y,name:w?void 0:K,id:z?void 0:W??void 0,required:P,ref:ta,style:K?kt:wt,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(b){if(b.nativeEvent.defaultPrevented)return;if(m){b.preventDefault();return}const V=b.currentTarget.checked,oe=vt(jt,b.nativeEvent);if(u?.(V,oe),!oe.isCanceled&&(De?.(V,oe),!oe.isCanceled&&(aa(V),R&&Y&&fe&&!w&&!ne))){const le=V?[...Y,R]:Y.filter(Pe=>Pe!==R);fe(le,oe)}},onFocus(){ue.current?.focus()}},A!==void 0?{value:(N?E&&A:A)||""}:bt,D,b=>Q.getValidationProps(B,b));i.useEffect(()=>{if(!se||!R)return;const b=se.disabledStatesRef.current;return b.set(R,B),()=>{b.delete(R)}},[se,B,R]);const Re=i.useMemo(()=>({...J,checked:Le,disabled:B,readOnly:m,required:P,indeterminate:me}),[J,Le,B,m,P,me]),Me=Xa(Re),na=ma("span",s,{state:Re,ref:[ye,ue,d,N?.registerControlRef],props:[{id:z?W??void 0:Ne,role:"checkbox","aria-checked":me?"mixed":Le,"aria-readonly":m||void 0,"aria-required":P||void 0,"aria-labelledby":ra,[Sr]:w?"":void 0,onFocus(){B||U(!0)},onBlur(){const b=T.current;b&&(O(!0),U(!1),H==="onBlur"&&Q.commit(N?Y:b.checked))},onKeyDown(b){if(b.key!=="Enter"||(b.preventBaseUIHandler(),b.defaultPrevented))return;const V=T.current?.form??null,oe=b.currentTarget,le=b.nativeEvent,Pe=b.preventDefault,Ie=le.preventDefault;let Ae=!1;b.preventDefault=()=>{Ae=!0,Pe.call(b)},le.preventDefault=()=>{Ae=!0,Ie.call(le)},Ie.call(le),ya(oe).queueMicrotask(()=>{b.preventDefault=Pe,le.preventDefault=Ie,Ae||pr(V)?.click()})},onClick(b){if(m||B)return;b.preventDefault();const V=T.current;V&&V.dispatchEvent(new(ya(V)).PointerEvent("click",{bubbles:!0,shiftKey:b.shiftKey,ctrlKey:b.ctrlKey,altKey:b.altKey,metaKey:b.metaKey}))}},I,Ge,_e,D,b=>Q.getValidationProps(B,b)],stateAttributesMapping:Me});return e.jsxs(Ja.Provider,{value:Re,children:[na,!E&&!N&&K&&!w&&M!==void 0&&e.jsx("input",{type:"hidden",form:y,name:K,value:M,disabled:B}),e.jsx("input",{...sa,suppressHydrationWarning:!0})]})}),_r=i.forwardRef(function(s,d){const{render:o,className:h,style:x,keepMounted:g=!1,...c}=s,y=Nr(),k=y.checked||y.indeterminate,{mounted:p,transitionStatus:S,setMounted:L}=Wt(k),u=i.useRef(null),w={...y,transitionStatus:S};Nt({open:k,ref:u,onComplete(){k||L(!1)}});const C={...Xa(y),...St,...Ea},P=g||p,M=ma("span",s,{ref:[d,u],state:w,stateAttributesMapping:C,props:c});return P?M:null});function Lr(a,s){return`target:${a}:${s}`}function Rr(a){return`remove:${a.id||a.directory}`}function Ya(a){if(!a)return null;const s=new Date(a).getTime();return Number.isFinite(s)?Math.floor((Date.now()-s)/864e5):null}function Pr(a){const s=Ya(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 Ir(a){const s=Ya(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 ia({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 Br({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){return e.jsx(Mt,{children:a?e.jsx(Er,{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 Er({skill:a,targets:s,busyKey:d,usage:o,hasUpdate:h,updating:x,onUpdate:g,onClose:c,onToggleTarget:y,onRemove:k}){const p=At(),{currency:S,rate:L}=Dt(),u=i.useRef(null);i.useEffect(()=>{const _=U=>{U.key==="Escape"&&(U.stopPropagation(),c?.())},$=U=>{const O=U.target;O instanceof Element&&(u.current?.contains(O)||O.closest('[data-skill-row="1"]')||c?.())};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",$),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",$)}},[c]);const w=a.name||a.directory,m=!!(a.repoOwner&&a.repoName),C=m?`https://github.com/${a.repoOwner}/${a.repoName}`:null,P=new Set(a.targets||[]),M=!!(a.readOnly||a.remote),A=!!a.remote,z=Array.isArray(a.deviceSources)?a.deviceSources:[],ce=!A&&(!M||P.has("claude")),I=d===Rr(a),ve=Pr(o?.lastUsedAt),xe=!!(o&&o.invocations>0),he=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:he,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:C,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:C,children:[e.jsxs("span",{className:"truncate",children:[a.repoOwner,"/",a.repoName]}),e.jsx(da,{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(Ee,{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(Ga,{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,M?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(A?"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,z.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:z.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(Ba,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"max-w-52 truncate",children:_.name})]},_.id))})]}):null,ce?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(ia,{label:r("skills.usage.invocations"),children:Ct(o?.invocations||0)}),e.jsx(ia,{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",Ir(o?.lastUsedAt)),"aria-hidden":!0}),xe?ve||r("skills.usage.unknown"):r("skills.usage.never")]})}),e.jsx(ia,{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(Ia,{className:"h-3 w-3","aria-label":r("skills.usage.disclaimer")})})]}),children:_t(o?.cost||0,{currency:S,rate:L})})]}),xe?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,M?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 $=P.has(_.id),U=d===Lr(a.id||a.directory,_.id),O=`skill-detail-sync-${a.id||a.directory}-${_.id}`;return e.jsxs("label",{htmlFor:O,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:O,checked:$,disabled:U,onCheckedChange:J=>y?.(a,_.id,!!J),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(_r,{className:"flex items-center justify-center text-white dark:text-oai-black",children:e.jsx(Te,{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(we,{provider:_.id,size:16})}),e.jsx("span",{className:"flex-1",children:_.label}),U?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},_.id)})})]})]}),M?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:I,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:[I?e.jsx(te,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(xa,{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 Tr=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),oa=["claude","codex"],G="popular",Or={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"},ge="all",F="skillssh";function Ze(a){return`${a.repoOwner||"local"}/${a.repoName||"local"}:${a.directory}`}function Za(a){return String(a||"").replace(/\\/g,"/").trim().toLowerCase()}function $r(a){return Za(a).split("/").filter(Boolean).pop()||""}function Dr(a){if(a.repoOwner||a.repoName)return"";const s=Za(a.directory);return!s||s.includes("/")?"":`dir:${s}`}function _a(a){const s=$r(a.directory);return s?`dir:${s}`:""}function et(a){const s=new Set([Ze(a).toLowerCase()]);a.repoOwner&&a.repoName&&s.add(`${a.repoOwner}/${a.repoName}:${a.sourceDirectory||a.directory}`.toLowerCase());const d=Dr(a);return d&&s.add(d),s}function Mr(a){return!a?.remote&&!a?.inventoryOnly&&!a?.readOnly}function Ar(a){const s=new Set;for(const d of Array.isArray(a)?a:[])if(Mr(d))for(const o of et(d))s.add(o);return s}function Qe(a){return`install:${Ze(a)}`}function La(a){return`remove:${a.id||a.directory}`}function at(a,s){return`target:${a}:${s}`}function ke(a){return a.id||a.directory}function pa(a){return a.manageable!==!1}function Ur({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&&Or[a.id],!g&&!c&&"opacity-35 grayscale"),"aria-hidden":!0,children:e.jsx(we,{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 Fr({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):pa(c))&&g.push(c);return e.jsx("div",{className:"flex items-center gap-1",onClick:c=>c.stopPropagation(),children:g.map(c=>e.jsx(Ur,{target:c,state:a.targetStates?.[c.id]||"off",busy:o===at(ke(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 zr({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,S=[a.directory,p,a.sourceName].filter(Boolean).join(" · "),L=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:S,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(Ga,{className:"h-2.5 w-2.5","aria-hidden":!0}),r("skills.update.badge")]}):null,e.jsx(Fr,{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||L.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,L.length?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:L.map(m=>m.name).join(", "),children:[e.jsx(Ba,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r("skills.inventory.on_devices",{devices:L.map(m=>m.name).join(", ")})})]}):null]}):null]})}function Kr({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(Ta,{value:a,onValueChange:d,children:[e.jsxs(Oa,{"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($a,{children:p=>p==="all"?r("skills.filter.agent_all"):s.find(S=>S.id===p)?.label||p}),e.jsx(Wa,{className:"text-oai-gray-400",children:e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Da,{children:e.jsx(Ma,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Aa,{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(Xe,{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(Je,{children:r("skills.filter.agent_all")}),e.jsx(Ye,{children:e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),s.map(p=>e.jsxs(Xe,{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(we,{provider:p.id,size:14}),e.jsx(Je,{children:p.label})]}),e.jsx(Ye,{children:e.jsx(Te,{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(ua,{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(ga,{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(Ee,{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(Ee,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]})}function Vr({count:a,targets:s,busy:d,onBulkSync:o,onBulkRemove:h,onClear:x}){const g=s.filter(pa);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(Fa,{children:[e.jsxs(za,{disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium text-oai-gray-700 transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-200",children:[e.jsx(Ua,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("skills.select.bulk_sync"),e.jsx(ha,{className:"h-3 w-3","aria-hidden":!0})]}),e.jsx(Ka,{children:e.jsx(Va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{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(we,{provider:c.id,size:16}),e.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),e.jsxs(X,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:h,children:[e.jsx(xa,{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(Ee,{className:"h-3 w-3","aria-hidden":!0}),r("skills.select.clear")]})]})]})}function qr({items:a,totalCount:s,targets:d,agentOptions:o,agentFilter:h,onAgentFilter:x,anyFilter:g,onClearFilters:c,searchQuery:y,onSearchQuery:k,searchPlaceholder:p,selectedId:S,onSelect:L,onToggleTarget:u,busyKey:w,updates:m,selectedIds:C,onToggleSelect:P,onClearSelection:M,onBulkSync:A,onBulkRemove:z}){const ce=C.size;return e.jsxs("div",{children:[ce>0?e.jsx(Vr,{count:ce,targets:d,busy:w==="batch",onBulkSync:A,onBulkRemove:z,onClear:M}):e.jsx(Kr,{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(X,{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(I=>e.jsx(zr,{skill:I,targets:d,selected:S===(I.id||I.directory),onSelect:L,selectable:!I.readOnly&&!I.remote,checked:C.has(ke(I)),onToggleSelect:P,onToggleTarget:u,hasUpdate:!!(I.id&&m?.[I.id]),busyKey:w},ke(I)))})]})}const Gr={contentVisibility:"auto",containIntrinsicSize:"0 240px"},Hr=Et.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(C=>C.id===m))),p=m=>{k(C=>C.includes(m)?C.filter(P=>P!==m):[...C,m])},S=s.repoOwner&&s.repoName?`${s.repoOwner}/${s.repoName}`:null,L=S?`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(C=>C.id===m)?.label||m).join(", "):r("skills.action.choose_targets");return e.jsxs(Ot,{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(da,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:s.name||s.directory}),S||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:[L?e.jsxs("a",{href:L,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:L,children:[e.jsx("span",{className:"truncate",children:S}),e.jsx(da,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,S&&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(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>c?.(s),className:"w-full",children:[e.jsx(Te,{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(Fa,{children:[e.jsx(za,{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(Ka,{children:e.jsx(Va,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:e.jsxs(qa,{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 C=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:C,onChange:()=>p(m.id)}),e.jsx(we,{provider:m.id,size:16}),e.jsx("span",{className:"flex-1 text-left",children:m.label})]},m.id)})]})})})]})]}),e.jsxs(X,{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(Ua,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.action.install")]})]})})]})});function Wr({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(ga,{value:s,onChange:g=>d(g.target.value),placeholder:r("skills.repo.placeholder"),className:"min-w-0 flex-1"}),e.jsxs(X,{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(Ha,{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(X,{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(xa,{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 Qr(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Ss(){const a=Lt()||{},s=!!a.signedIn,d=a.getAccessToken,[o,h]=i.useState(Qr),[x,g]=i.useState({skills:[],targets:[]}),[c,y]=i.useState([]),[k,p]=i.useState([]),[S,L]=i.useState([]),[u,w]=i.useState(ge),[m,C]=i.useState(""),[P,M]=i.useState(""),[A,z]=i.useState(""),[ce,I]=i.useState(""),[ve,xe]=i.useState(""),[he,_]=i.useState(!1),[$,U]=i.useState("all"),[O,J]=i.useState(null),[H,je]=i.useState(""),[Oe,Ke]=i.useState(!0),[$e,Ve]=i.useState(!1),[re,D]=i.useState(""),[N,se]=i.useState(null),[ne,B]=i.useState(null),[K,R]=i.useState(()=>new Set),[Ne,qe]=i.useState({}),[W,Se]=i.useState({}),[pe,ea]=i.useState([]),[De,Ge]=i.useState(!1),Y=i.useRef(!1),fe=i.useRef(0),Ce=i.useMemo(()=>Ar(x.skills),[x.skills]),ue=i.useCallback(async()=>{const t=++fe.current,n=await Xt();if(fe.current!==t)return;const l={skills:n.skills||[],targets:n.targets||[]};g(l);const f=Rt();!s||!Pt()||!f||typeof d!="function"||(async()=>{try{const v=await d();if(!v||fe.current!==t)return;const[j]=await Promise.allSettled([Jt(v),Yt({accessToken:v,deviceId:f,skills:l.skills})]);if(j.status!=="fulfilled")return;const Fe=j.value;if(fe.current!==t)return;g({targets:l.targets,skills:Zt(l.skills,Fe,f)})}catch{}})()},[d,s]),ie=i.useCallback(async()=>{const t=await er();L(t.repos||[])},[]),Z=i.useCallback(async({force:t=!1}={})=>{Ve(!0);try{const n=await ar({force:t});y(n.skills||[])}finally{Ve(!1)}},[]),_e=i.useCallback(async({force:t=!1}={})=>{Ge(!0);try{const n=await tr({force:t});ea(n.skills||[])}finally{Ge(!1)}},[]),ye=i.useCallback(async()=>{try{const t=await rr();qe(t?.updates||{})}catch{qe({})}},[]),Q=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);Se(n)}catch{Se({})}},[]),E=i.useCallback(async()=>{Ke(!0),D("");try{await Promise.all([ue(),ie()])}catch(t){D(t?.message||r("skills.error.generic"))}finally{Ke(!1)}},[ue,ie]),aa=i.useCallback(async()=>{await E();const t=n=>D(n?.message||r("skills.error.generic"));o==="my"?(ye(),Q()):u===G?_e({force:!0}).catch(t):u!==F&&Z({force:!0}).catch(t)},[Z,E,_e,ye,Q,u,o]);i.useEffect(()=>{E()},[E]),i.useEffect(()=>{if(Y.current||typeof window>"u")return;const t=new URLSearchParams(window.location.search),n=t.get("skill");if(!n){Y.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"),J(f.id||f.directory)),Y.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===F||u===G||c.length===0&&Z().catch(t=>D(t?.message||r("skills.error.generic"))))},[c.length,Z,u,o]),i.useEffect(()=>{o!=="browse"||u!==G||pe.length===0&&_e().catch(t=>D(t?.message||r("skills.error.generic")))},[_e,pe.length,u,o]);const Le=Object.keys(Ne).length>0,me=Object.keys(W).length>0;if(i.useEffect(()=>{o==="my"&&(Le||ye(),me||Q())},[o,Le,me,ye,Q]),i.useEffect(()=>{const t=setTimeout(()=>M(m),200);return()=>clearTimeout(t)},[m]),i.useEffect(()=>{const t=setTimeout(()=>I(A),120);return()=>clearTimeout(t)},[A]),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]),!Tr&&!It())return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})});const T=async(t,n)=>{je(t),D("");try{await n(),await ue()}catch(l){D(l?.message||r("skills.error.generic"))}finally{je("")}},ta=(t,n)=>{const l=(n&&n.length?n:oa).filter(f=>(x.targets||[]).some(v=>v.id===f));T(Qe(t),async()=>{await wa(t,l);const f=l.map(v=>(x.targets||[]).find(j=>j.id===v)?.label||v).join(", ");Be({title:r("skills.toast.installed",{name:t.name||t.directory,targets:f||r("skills.target.none")}),timeout:4e3})})},ra=t=>{t?.readOnly||t?.remote||se(t)},sa=()=>{const t=N;t&&(se(null),T(La(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);Be({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){D(f?.message||r("skills.error.generic"))}}}:void 0})}))},Re=(t,n,l)=>t?.readOnly||t?.remote?Promise.resolve():T(at(ke(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 Sa(t.directory,Array.from(f));const v={name:t.name||t.directory,agent:b(n)};Be({title:l?r("skills.toast.synced_one",v):r("skills.toast.unsynced_one",v),timeout:3e3})}),Me=i.useCallback(()=>R(new Set),[]),na=i.useCallback((t,n)=>{if(t?.readOnly||t?.remote)return;const l=ke(t);R(f=>{const v=new Set(f);return n?v.add(l):v.delete(l),v})},[]),b=t=>(x.targets||[]).find(n=>n.id===t)?.label||t,V=t=>{const n=(x.skills||[]).filter(l=>K.has(ke(l))&&!l.readOnly&&!l.remote);n.length&&T("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 Sa(l.directory,Array.from(f))}Me(),Be({title:r("skills.toast.bulk_synced",{count:n.length,agent:b(t)}),timeout:4e3})})},oe=()=>{const t=(x.skills||[]).filter(n=>K.has(ke(n))&&!n.readOnly&&!n.remote);t.length&&B(t)},le=()=>{const t=ne;t&&(B(null),T("batch",async()=>{for(const n of t)n.managed?await va(n.id):await ja(n.directory,n.targets||[]);Me(),Be({title:r("skills.toast.bulk_removed",{count:t.length}),timeout:4e3})}))},Pe=t=>{!t?.repoOwner||!t?.repoName||T(Qe(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:oa),await ye(),Be({title:r("skills.toast.updated",{name:t.name||t.directory}),timeout:4e3})})},Ie=async()=>{const t=m.trim();if(!(t.length<2)){je("search"),D("");try{const n=await nr(t);p(n.skills||[])}catch(n){D(n?.message||r("skills.error.generic"))}finally{je("")}}},Ae=async()=>{const t=ve.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[n,l]=t.split("/");if(!n||!l){D(r("skills.repo.invalid"));return}await T("repo:add",async()=>{await lr({owner:n,name:l,branch:"main",enabled:!0}),xe(""),await ie(),await Z()})},tt=async t=>{await T(`repo:${t.owner}/${t.name}`,async()=>{await or(t.owner,t.name),await ie(),await Z()})},de=x.targets||[],rt=de.filter(pa),be=x.skills||[],st=i.useMemo(()=>{const t=$==="all"?be:be.filter(l=>(l.targets||[]).includes($)),n=ce.trim().toLowerCase();return n?t.filter(l=>(l.name||"").toLowerCase().includes(n)||(l.directory||"").toLowerCase().includes(n)||(l.description||"").toLowerCase().includes(n)):t},[be,$,ce]),nt=$!=="all",ee=i.useMemo(()=>O&&be.find(t=>(t.id||t.directory)===O)||null,[be,O]),it=i.useCallback(()=>{U("all"),z("")},[]),ot=i.useCallback(t=>{J(n=>{const l=t?.id||t?.directory||null;return n===l?null:l})},[]),lt=i.useCallback(()=>J(null),[]),dt=i.useCallback(t=>{const n=Ze(t).toLowerCase(),l=_a(t),f=(x.skills||[]).find(v=>{const j=et(v);return j.has(n)||l&&j.has(l)});f&&J(f.id||f.directory)},[x.skills]);i.useEffect(()=>{o!=="my"&&K.size&&R(new Set)},[o,K.size]),i.useEffect(()=>{O&&!ee&&J(null)},[ee,O]);const Ue=i.useMemo(()=>{const t=u===F?k:u===G?pe:c,l=u===F||u===G||u===ge?t:t.filter(j=>`${j.repoOwner}/${j.repoName}`===u),f=P.trim().toLowerCase();return(u===F||!f?l:l.filter(j=>(j.name||"").toLowerCase().includes(f)||(j.directory||"").toLowerCase().includes(f)||(j.description||"").toLowerCase().includes(f))).map(j=>{const Fe=Ze(j).toLowerCase(),q=_a(j);return{...j,installed:Ce.has(Fe)||q&&Ce.has(q)}})},[P,c,Ce,pe,k,u]),ct=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})}),ut=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")})]}),He=(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 We;if(Oe)We=ct;else if(o==="my")We=be.length?e.jsx(qr,{items:st,totalCount:be.length,targets:de,agentOptions:de,agentFilter:$,onAgentFilter:U,anyFilter:nt,onClearFilters:it,searchQuery:A,onSearchQuery:z,searchPlaceholder:r("skills.my.placeholder"),selectedId:O,onSelect:ot,onToggleTarget:Re,busyKey:H,updates:Ne,selectedIds:K,onToggleSelect:na,onClearSelection:Me,onBulkSync:V,onBulkRemove:oe}):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:[de.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:[...de,...de].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(we,{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:[...de,...de].map((t,n)=>e.jsx("span",{className:"shrink-0 px-3",children:e.jsx(we,{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(X,{type:"button",size:"sm",onClick:()=>h("browse"),children:r("skills.empty.my_cta")})]});else{const t=u===F,n=u===G,l=S.length===0&&!t&&!n,f=$e&&!t&&!n||n&&De,v=!t&&!n&&(P.trim()!==""||u!==ge),j=()=>{C(""),w(ge)},Fe=!l&&!f&&(Ue.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:Ue.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(Ee,{className:"h-3 w-3","aria-hidden":!0}),r("skills.filter.clear")]}):null]}):null;let q;l?q=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?q=ut:t&&m.trim().length<2?q=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")}):Ue.length?q=e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ue.map(ze=>e.jsx("div",{style:Gr,children:e.jsx(Hr,{skill:ze,installed:!!ze.installed,installing:H===Qe(ze),allTargets:rt,defaultTargets:oa,onInstall:ta,onManage:dt})},ze.id||ze.key))}):v?q=He("skills.empty.no_match",e.jsx(X,{type:"button",variant:"secondary",size:"sm",onClick:j,children:r("skills.filter.clear")})):t?q=He("skills.empty.search"):n?q=He("skills.empty.popular"):q=He("skills.empty.browse");const mt=l||he?e.jsx("div",{className:"mb-5",children:e.jsx(Wr,{repos:S,repoInput:ve,onRepoInput:xe,busyKey:H,onAdd:Ae,onRemove:tt})}):null,gt=!he&&!t&&!n&&S.length<=1&&Ue.length>0?e.jsx(hr,{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;We=e.jsxs(e.Fragment,{children:[mt,Fe,q,gt]})}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(X,{type:"button",variant:"secondary",size:"sm",onClick:aa,disabled:Oe||$e||De,children:[e.jsx(Bt,{className:ae("mr-1.5 h-3.5 w-3.5",(Oe||$e||De)&&"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($t,{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===F?"skillssh":u===G?"popular":"repo",onChange:t=>{t==="skillssh"?w(F):t==="popular"?w(G):(u===F||u===G)&&w(ge)}}),u!==F&&u!==G?e.jsxs(Ta,{value:u,onValueChange:w,children:[e.jsxs(Oa,{"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($a,{children:t=>t===ge?r("skills.source.all"):t}),e.jsx(Wa,{className:"text-oai-gray-400",children:e.jsx(ha,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx(Da,{children:e.jsx(Ma,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:e.jsxs(Aa,{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(Xe,{value:ge,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(Je,{children:r("skills.source.all")}),e.jsx(Ye,{children:e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),S.map(t=>{const n=`${t.owner}/${t.name}`;return e.jsxs(Xe,{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(Je,{children:n}),e.jsx(Ye,{children:e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},n)})]})})})]}):null,e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ua,{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(ga,{type:"search",value:m,onChange:t=>C(t.target.value),onKeyDown:t=>{t.key==="Enter"&&u===F&&Ie()},"aria-label":r("skills.action.search_aria"),placeholder:u===F?r("skills.browse.placeholder_skillssh"):u===G?r("skills.browse.placeholder_popular"):u===ge?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===F?e.jsxs(X,{type:"button",size:"sm",onClick:Ie,disabled:m.trim().length<2||H==="search",className:"focus:!ring-oai-gray-400/30",children:[H==="search"?e.jsx(te,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(ua,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),r("skills.action.search")]}):u===G?null:e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(t=>!t),"aria-expanded":he,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(Ha,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),r("skills.browse.manage_sources"),e.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:S.length})]})]}):null,We,e.jsx(Br,{skill:ee,targets:de,busyKey:H,usage:ee&&(W[String(ee.directory||"").toLowerCase()]||W[String(ee.name||"").toLowerCase()])||null,hasUpdate:!!(ee?.id&&Ne?.[ee.id]),updating:ee?H===Qe(ee):!1,onUpdate:Pe,onClose:lt,onToggleTarget:Re,onRemove:ra})]})}),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:H===La(N||{}),onCancel:()=>se(null),onConfirm:sa}),e.jsx(ba,{open:!!ne,title:r("skills.confirm.bulk_remove_title",{count:ne?.length||0}),description:r("skills.confirm.bulk_remove_desc"),confirmLabel:r("skills.action.remove"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:H==="batch",onCancel:()=>B(null),onConfirm:le})]})}export{Ss as SkillsPage,Ar as buildLocallyInstalledKeys};