tokentracker-cli 0.29.2 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.ja.md +3 -1
  2. package/README.ko.md +3 -1
  3. package/README.md +3 -1
  4. package/README.zh-CN.md +3 -1
  5. package/dashboard/dist/assets/ActivityHeatmap-D8lXQtTi.js +42 -0
  6. package/dashboard/dist/assets/{Card-DSgpCS30.js → Card-CzL-eInd.js} +1 -1
  7. package/dashboard/dist/assets/DashboardPage-CsR8XWxj.js +19 -0
  8. package/dashboard/dist/assets/{DevicePage-CvrCNfjD.js → DevicePage-XTngLOwj.js} +1 -1
  9. package/dashboard/dist/assets/DialogTitle-Csg36lAf.js +12 -0
  10. package/dashboard/dist/assets/FadeIn-Db32waF2.js +1 -0
  11. package/dashboard/dist/assets/{HeaderGithubStar-B98VaHbR.js → HeaderGithubStar-DliHDaOa.js} +1 -1
  12. package/dashboard/dist/assets/{IpCheckPage-CJxv_Sd8.js → IpCheckPage-F5CeRlub.js} +1 -1
  13. package/dashboard/dist/assets/LandingPage-2_sEF9mN.js +4356 -0
  14. package/dashboard/dist/assets/{LeaderboardAvatar-D6qRteef.js → LeaderboardAvatar-C9VP8195.js} +1 -1
  15. package/dashboard/dist/assets/{LeaderboardPage-CgtoFmMi.js → LeaderboardPage-Za_4Qq0N.js} +3 -3
  16. package/dashboard/dist/assets/{LeaderboardProfileModal-OTLhvzV6.js → LeaderboardProfileModal-BGDd6bjd.js} +2 -2
  17. package/dashboard/dist/assets/LeaderboardProfilePage-CuGbG8_n.js +1 -0
  18. package/dashboard/dist/assets/LimitsPage-DlcSiBHP.js +2 -0
  19. package/dashboard/dist/assets/{LocalOnlyNotice-3LPVUJ2h.js → LocalOnlyNotice-BNFZWAB2.js} +1 -1
  20. package/dashboard/dist/assets/LoginPage-UkyGRtTz.js +1 -0
  21. package/dashboard/dist/assets/PopoverPopup-Bg0LqxYF.js +1 -0
  22. package/dashboard/dist/assets/SettingsPage-D3gNWvI6.js +1 -0
  23. package/dashboard/dist/assets/SkillsPage-ChO2jmQM.js +1 -0
  24. package/dashboard/dist/assets/WidgetsPage-BzPEEeI3.js +1 -0
  25. package/dashboard/dist/assets/{WrappedPage-Cp8uyLbu.js → WrappedPage-DpP5X0ug.js} +1 -1
  26. package/dashboard/dist/assets/agent-logos-BgjfCDVs.js +1 -0
  27. package/dashboard/dist/assets/{arrow-up-right-CBzDSqD7.js → arrow-up-right-BTb5Q4za.js} +1 -1
  28. package/dashboard/dist/assets/check-L6OoQyFg.js +1 -0
  29. package/dashboard/dist/assets/{chevron-down--Hb5e71i.js → chevron-down-DaLDjB50.js} +1 -1
  30. package/dashboard/dist/assets/{download-BaVXaxbw.js → download-B3izgOD2.js} +1 -1
  31. package/dashboard/dist/assets/{info-WGRGGnfx.js → info-D9m3SBry.js} +1 -1
  32. package/dashboard/dist/assets/main-CvZdsRCc.css +1 -0
  33. package/dashboard/dist/assets/main-y2PTR9Ni.js +959 -0
  34. package/dashboard/dist/assets/{use-limits-display-prefs-C1AkRZcO.js → use-limits-display-prefs--sTkiVYR.js} +1 -1
  35. package/dashboard/dist/assets/{use-native-settings-DdooJHwm.js → use-native-settings-CI8nzpC4.js} +1 -1
  36. package/dashboard/dist/assets/{use-usage-limits-D1mepldk.js → use-usage-limits-DHoQOqOL.js} +1 -1
  37. package/dashboard/dist/assets/useCurrency-DyV36y25.js +1 -0
  38. package/dashboard/dist/dashboard-dark.png +0 -0
  39. package/dashboard/dist/index.html +2 -2
  40. package/dashboard/dist/share.html +2 -2
  41. package/package.json +1 -1
  42. package/src/lib/local-api.js +67 -0
  43. package/src/lib/pricing/seed-snapshot.json +1 -1
  44. package/src/lib/skill-usage.js +267 -0
  45. package/src/lib/skills-manager.js +371 -13
  46. package/dashboard/dist/assets/ActivityHeatmap-C7-tnMYf.js +0 -42
  47. package/dashboard/dist/assets/DashboardPage-CB6VzM2W.js +0 -1
  48. package/dashboard/dist/assets/DialogTitle-B-afswln.js +0 -12
  49. package/dashboard/dist/assets/FadeIn-D1-QPLIW.js +0 -1
  50. package/dashboard/dist/assets/LandingPage-CIOqWNDm.js +0 -4356
  51. package/dashboard/dist/assets/LeaderboardProfilePage-C7OaZcf2.js +0 -1
  52. package/dashboard/dist/assets/LimitsPage-pyyJbh3F.js +0 -2
  53. package/dashboard/dist/assets/LoginPage-CDLz8PnP.js +0 -1
  54. package/dashboard/dist/assets/PopoverPopup-97Rik7mb.js +0 -1
  55. package/dashboard/dist/assets/ProviderIcon-XOgnf2pw.js +0 -1
  56. package/dashboard/dist/assets/SettingsPage-KVjKUepK.js +0 -1
  57. package/dashboard/dist/assets/SkillsPage-DyIY1U9O.js +0 -1
  58. package/dashboard/dist/assets/WidgetsPage-BU7ejAYd.js +0 -1
  59. package/dashboard/dist/assets/check-Bsgzg2T8.js +0 -1
  60. package/dashboard/dist/assets/main-ClqhPPd3.css +0 -1
  61. package/dashboard/dist/assets/main-DDTfmaoo.js +0 -854
  62. package/dashboard/dist/assets/use-reduced-motion-wvh7iFTi.js +0 -1
  63. package/dashboard/dist/assets/useCurrency-C3szwbkj.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{u as r,N as g,s as n,r as j,i as v,L as k,as as N}from"./main-y2PTR9Ni.js";import{u as L}from"./use-usage-limits-DHoQOqOL.js";import{u as E}from"./use-limits-display-prefs--sTkiVYR.js";import{C as h}from"./Card-CzL-eInd.js";import{F as O}from"./FadeIn-Db32waF2.js";import{L as P}from"./LocalOnlyNotice-BNFZWAB2.js";import"./arrow-up-right-BTb5Q4za.js";import"./download-B3izgOD2.js";const C=[3,2,3,3,2,2,3];function m({className:s}){return r.jsx("div",{className:g("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",s)})}function T(){return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(m,{className:"h-3 w-12 shrink-0"}),r.jsx(m,{className:"flex-1 h-1.5 rounded-full min-w-0"}),r.jsx(m,{className:"h-3 w-[30px] shrink-0"}),r.jsx(m,{className:"h-3 w-6 shrink-0"})]})}function R({bars:s,index:e}){const i=e%3===0?"w-24":e%3===1?"w-20":"w-[4.5rem]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(m,{className:"h-[14px] w-[14px] rounded shrink-0"}),r.jsx(m,{className:g("h-4",i)})]}),Array.from({length:s},(l,a)=>r.jsx(T,{},a))]})}function S(){return r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(m,{className:"h-3.5 w-28"}),C.map((s,e)=>r.jsx(R,{bars:s,index:e},e))]})})}function t(s){if(!s)return null;const e=typeof s=="number"?s*1e3:Date.parse(s);if(!Number.isFinite(e))return null;const i=e-Date.now();if(i<=0)return n("shared.time.now");const l=Math.floor(i/6e4);if(l<60)return`${l}m`;const a=Math.floor(l/60);return a<24?`${a}h`:`${Math.floor(a/24)}d`}function I(s){return s>=90?"bg-red-500":s>=70?"bg-amber-500":"bg-emerald-500"}function o({label:s,pct:e,reset:i}){const l=Math.max(0,Math.min(100,Number(e)||0)),a=Math.round(l),u=l>0&&a===0?Math.max(l,.35):l,x=l>0&&a===0?"<1":String(a);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:s}),r.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:r.jsx("div",{className:`${I(a)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${u}%`,minWidth:l>0?"3px":0}})}),r.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-[30px] text-right shrink-0",children:[x,"%"]}),i?r.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i}):null]})}function d({name:s,icon:e,children:i}){const a=e==="/brand-logos/cursor.svg"||e==="/brand-logos/kiro.svg"||e==="/brand-logos/copilot.svg"||e==="/brand-logos/kimi.svg"?"w-[14px] h-[14px] dark:invert":"w-[14px] h-[14px]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[e?r.jsx("img",{src:e,alt:"",className:a}):null,r.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:s})]}),i]})}const A=["claude","codex","cursor","gemini","kimi","kiro","copilot","antigravity"],M={claude:{name:"Claude",icon:"/brand-logos/claude-code.svg"},codex:{name:"Codex",icon:"/brand-logos/codex.svg"},cursor:{name:"Cursor",icon:"/brand-logos/cursor.svg"},gemini:{name:"Gemini",icon:"/brand-logos/gemini.svg"},kimi:{name:"Kimi",icon:"/brand-logos/kimi.svg"},kiro:{name:"Kiro",icon:"/brand-logos/kiro.svg"},copilot:{name:"GitHub Copilot",icon:"/brand-logos/copilot.svg"},antigravity:{name:"Antigravity",icon:"/brand-logos/antigravity.svg"}};function c({children:s,tone:e="neutral"}){const i=e==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return r.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:s})}function D(s,e){const i=M[s];if(!i)return null;if(!e?.configured)return r.jsx(d,{name:i.name,icon:i.icon,children:r.jsx(c,{children:n("limits.status.not_connected")})},s);if(e.error)return r.jsx(d,{name:i.name,icon:i.icon,children:r.jsx(c,{tone:"error",children:n("shared.error.prefix",{error:e.error})})},s);switch(s){case"claude":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.five_hour?r.jsx(o,{label:"5h",pct:e.five_hour.utilization,reset:t(e.five_hour.resets_at)}):null,e.seven_day?r.jsx(o,{label:"7d",pct:e.seven_day.utilization,reset:t(e.seven_day.resets_at)}):null,e.seven_day_opus?r.jsx(o,{label:"Opus",pct:e.seven_day_opus.utilization,reset:t(e.seven_day_opus.resets_at)}):null,!e.five_hour&&!e.seven_day&&!e.seven_day_opus?r.jsx(c,{children:n("limits.status.no_data")}):null]},"claude");case"codex":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.primary_window?r.jsx(o,{label:"5h",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(o,{label:"7d",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?r.jsx(c,{children:n("limits.status.no_data")}):null]},"codex");case"cursor":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.primary_window?r.jsx(o,{label:n("limits.label.cursor_plan"),pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(o,{label:n("limits.label.cursor_auto"),pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(o,{label:n("limits.label.cursor_api"),pct:e.tertiary_window.used_percent,reset:t(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?r.jsx(c,{children:n("limits.status.no_data")}):null]},"cursor");case"gemini":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.primary_window?r.jsx(o,{label:"Pro",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(o,{label:"Flash",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(o,{label:"Lite",pct:e.tertiary_window.used_percent,reset:t(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?r.jsx(c,{children:n("limits.status.no_data")}):null]},"gemini");case"kimi":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.primary_window?r.jsx(o,{label:n("limits.label.kimi_weekly"),pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(o,{label:n("limits.label.kimi_5h"),pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(o,{label:n("limits.label.kimi_total"),pct:e.tertiary_window.used_percent,reset:t(e.tertiary_window.reset_at)}):null,e.parallel_limit?r.jsx(c,{children:n("limits.label.kimi_parallel",{count:e.parallel_limit})}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?r.jsx(c,{children:n("limits.status.no_data")}):null]},"kimi");case"kiro":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.primary_window?r.jsx(o,{label:n("limits.label.kiro_month"),pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(o,{label:n("limits.label.kiro_bonus"),pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?r.jsx(c,{children:n("limits.status.no_data")}):null]},"kiro");case"antigravity":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.primary_window?r.jsx(o,{label:"Claude",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(o,{label:"G Pro",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(o,{label:"Flash",pct:e.tertiary_window.used_percent,reset:t(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?r.jsx(c,{children:n("limits.status.no_data")}):null]},"antigravity");case"copilot":return r.jsxs(d,{name:i.name,icon:i.icon,children:[e.primary_window?r.jsx(o,{label:n("limits.label.copilot_premium"),pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(o,{label:n("limits.label.copilot_chat"),pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?r.jsx(c,{children:n("limits.status.no_data")}):null,e.otel_has_files||e.otel_enabled?null:r.jsx(H,{defaultDir:e.otel_default_dir})]},"copilot");default:return null}}function H({defaultDir:s}){const[e,i]=j.useState(!1),a=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${s||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
2
+ `),u=async()=>{try{await navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return r.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[r.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:n("limits.copilot.otelHint.title")}),r.jsx("div",{className:"mt-0.5 leading-snug",children:n("limits.copilot.otelHint.body")}),r.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:a}),r.jsx("button",{type:"button",onClick:u,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:e?n("limits.copilot.otelHint.copied"):n("limits.copilot.otelHint.copy")})]})}function $({claude:s,codex:e,cursor:i,gemini:l,kimi:a,kiro:u,antigravity:x,copilot:b,order:p,visibility:_}){const f={claude:s,codex:e,cursor:i,gemini:l,kimi:a,kiro:u,antigravity:x,copilot:b},y=(Array.isArray(p)&&p.length>0?p:A).filter(w=>!_||_[w]!==!1).map(w=>D(w,f[w])).filter(Boolean);return r.jsx(O,{delay:.15,children:r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:n("limits.panel.title")}),y.length>0?y:r.jsx(c,{children:n("limits.status.all_hidden")})]})})})}const F=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");function q(){const{data:s,error:e,isLoading:i}=L({initialRefresh:!0}),l=E();return!F&&!v()?r.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:r.jsx(P,{})}):r.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:r.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:r.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[r.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:n("nav.limits")}),r.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:n("limits.page.subtitle")})]}),r.jsx(k,{to:"/settings","aria-label":n("limits.page.openSettings"),title:n("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:r.jsx(N,{className:"h-4 w-4","aria-hidden":!0})})]}),i?r.jsx(S,{}):r.jsxs(r.Fragment,{children:[e?r.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:n("shared.error.prefix",{error:e})}):null,r.jsx($,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kimi:s?.kimi,kiro:s?.kiro,antigravity:s?.antigravity,copilot:s?.copilot,order:l.order,visibility:l.visibility})]})]})})})}export{q as LimitsPage};
@@ -1 +1 @@
1
- import{C as e,B as t}from"./main-DDTfmaoo.js";import{A as r}from"./arrow-up-right-CBzDSqD7.js";import{D as o}from"./download-BaVXaxbw.js";const i="https://github.com/mm7894215/TokenTracker/releases/latest";function c(){const a=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:t("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:t("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:a,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:t("local_only.open_app")}),e.jsx(r,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(o,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t("local_only.download")})]})]})]})})}export{c as L};
1
+ import{u as e,s as t}from"./main-y2PTR9Ni.js";import{A as r}from"./arrow-up-right-BTb5Q4za.js";import{D as o}from"./download-B3izgOD2.js";const i="https://github.com/mm7894215/TokenTracker/releases/latest";function c(){const a=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:t("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:t("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:a,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:t("local_only.open_app")}),e.jsx(r,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(o,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:t("local_only.download")})]})]})]})})}export{c as L};
@@ -0,0 +1 @@
1
+ import{aj as Y,au as Z,Q as ee,r,s,u as e,L as G,N as v}from"./main-y2PTR9Ni.js";function te(n){const a=new URLSearchParams(n).get("next");return typeof a!="string"||a.length===0||!a.startsWith("/")||a.startsWith("//")?"/dashboard":a}const Q={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function V(n){const a=String(n||"").trim();return Q[a]?Q[a]:a.replace(/-/g," ")}function ie(){const n=Y(),[a,A]=Z(),{enabled:o,loading:g,signedIn:f,refreshUser:C,signInWithPassword:E,signUp:M,signInWithOAuth:I,getPublicAuthConfig:F}=ee(),m=r.useMemo(()=>te(a.toString()),[a]),[l,j]=r.useState("signin"),[x,$]=r.useState(""),[h,H]=r.useState(""),[N,X]=r.useState(""),[k,p]=r.useState(!1),[O,c]=r.useState(null),[U,b]=r.useState(null),[S,B]=r.useState(!0),[_,R]=r.useState([]),[P,T]=r.useState([]),[W,z]=r.useState(8);r.useEffect(()=>{const t=a.get("insforge_status"),i=a.get("insforge_type"),u=a.get("insforge_error");t==="success"&&i==="verify_email"?b(s("login.verify_email_success")):t==="error"&&i==="verify_email"&&u&&b(s("shared.error.prefix",{error:u}))},[a]),r.useEffect(()=>{if(!o){B(!1);return}let t=!0;return(async()=>{const{data:i,error:u}=await F();t&&(u||!i?(R(["google","github"]),T([])):(R(Array.isArray(i.oAuthProviders)?i.oAuthProviders:[]),T(Array.isArray(i.customOAuthProviders)?i.customOAuthProviders:[]),typeof i.passwordMinLength=="number"&&i.passwordMinLength>0&&z(i.passwordMinLength)),B(!1))})(),()=>{t=!1}},[o,F]);const d=r.useMemo(()=>a.get("native")==="1",[a]),y=r.useMemo(()=>a.get("provider")||null,[a]);r.useEffect(()=>{if(!(!o||g)&&f){if(d){window.location.href="/auth/native-callback";return}n(m,{replace:!0})}},[o,g,f,n,m,d]),r.useEffect(()=>{o&&C()},[o,C]);const q=r.useMemo(()=>typeof window>"u"||d?"":`${window.location.origin}/`,[d]),D=r.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),J=r.useCallback(async t=>{t.preventDefault(),c(null),p(!0);try{if(l==="signup"){const{data:u,error:L}=await M({email:x.trim(),password:h,name:N.trim()||void 0,redirectTo:D});if(L){c(L.message||String(L));return}if(u?.requireEmailVerification){b(s("login.verify_email_pending")),j("signin");return}n(m,{replace:!0});return}const{error:i}=await E({email:x.trim(),password:h});if(i){c(i.message||String(i));return}n(m,{replace:!0})}finally{p(!1)}},[l,x,h,N,M,E,n,m,D]),w=r.useCallback(async t=>{c(null),p(!0);try{const{error:i}=await I(t,q);i&&c(i.message||String(i))}finally{p(!1)}},[I,q]);r.useEffect(()=>{if(d&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[d]),r.useEffect(()=>{if(!o||g||f||S||!d||!y)return;[..._,...P].includes(y)&&w(y)},[o,g,f,S,d,y,_,P,w]);const K=r.useCallback(()=>{A(t=>{const i=new URLSearchParams(t);return i.delete("insforge_status"),i.delete("insforge_type"),i.delete("insforge_error"),i},{replace:!0}),b(null)},[A]);return o?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(G,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:s("login.title")}),e.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:s("login.subtitle")})]}),U?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:U}),e.jsx("button",{type:"button",onClick:K,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,O?e.jsx("p",{className:"text-sm text-red-400",role:"alert",children:s("shared.error.prefix",{error:O})}):null,e.jsx("div",{className:"space-y-3",children:S?e.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):e.jsxs(e.Fragment,{children:[_.map(t=>e.jsx("button",{type:"button",disabled:k,onClick:()=>w(t),className:v("w-full h-11 rounded-lg border border-oai-gray-700 bg-oai-gray-900 text-sm font-medium text-white","hover:bg-oai-gray-800 transition-colors disabled:opacity-50"),children:s("login.oauth.continue",{provider:V(t)})},t)),P.map(t=>e.jsx("button",{type:"button",disabled:k,onClick:()=>w(t),className:v("w-full h-11 rounded-lg border border-oai-gray-700 bg-oai-gray-900 text-sm font-medium text-white","hover:bg-oai-gray-800 transition-colors disabled:opacity-50"),children:s("login.oauth.continue",{provider:V(t)})},t))]})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:e.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:s("login.divider")})})]}),e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[e.jsx("button",{type:"button",className:v("flex-1 py-2 text-sm font-medium rounded-md transition-colors",l==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{j("signin"),c(null)},children:s("login.tab.sign_in")}),e.jsx("button",{type:"button",className:v("flex-1 py-2 text-sm font-medium rounded-md transition-colors",l==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{j("signup"),c(null)},children:s("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:J,className:"space-y-4",children:[l==="signup"?e.jsxs("div",{children:[e.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:s("login.field.name")}),e.jsx("input",{id:"login-name",type:"text",autoComplete:"name",value:N,onChange:t=>X(t.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:s("login.field.name_placeholder")})]}):null,e.jsxs("div",{children:[e.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:s("login.field.email")}),e.jsx("input",{id:"login-email",type:"email",autoComplete:"email",required:!0,value:x,onChange:t=>$(t.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:s("login.field.password")}),e.jsx("input",{id:"login-password",type:"password",autoComplete:l==="signup"?"new-password":"current-password",required:!0,minLength:l==="signup"?W:void 0,value:h,onChange:t=>H(t.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),l==="signup"?e.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:s("login.password_hint",{min:String(W)})}):null]}),e.jsx("button",{type:"submit",disabled:k||g,className:"w-full h-11 rounded-lg bg-white text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:l==="signup"?s("login.submit.sign_up"):s("login.submit.sign_in")})]})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(G,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:s("login.cloud_only")})})]})}export{ie as LoginPage};
@@ -0,0 +1 @@
1
+ import{c as en,r as x,bh as Hn,a_ as nt,x as K,bE as be,bF as Bn,b2 as tn,bG as ot,b3 as z,bH as de,bi as ge,bI as $t,bJ as fe,aX as pe,bK as nn,bL as at,bM as Me,bN as Ve,bO as $n,bP as on,bQ as Vn,bR as lt,bS as ft,bT as Xe,M as Ie,bU as _n,b4 as rn,aQ as le,bV as Wn,bW as Nn,aS as ee,bX as Z,aU as _e,aY as sn,aV as ae,bY as cn,bc as an,bZ as jn,b0 as ze,b_ as Yn,b$ as Xn,aZ as rt,c0 as zn,u as U,c1 as Un,v as Gn,w as ut,c2 as Kn,c3 as Vt,c4 as qn,c5 as Jn,c6 as Qn,c7 as Zn,be as eo,c8 as to,c9 as no,bg as oo,b5 as ro,bl as so}from"./main-y2PTR9Ni.js";import{y as Ce,z as io,g as dt,A as co,P as ln,h as gt,f as we,B as ao,R as lo,E as fo,G as uo,m as re,H as go,o as po,J as mo,K as ho,w as xo,L as yo,q as vo,M as Ro,r as fn,l as bo,N as wo,t as Eo,v as Co,O as Oo,I as To,Q as So,x as un,F as Po,C as Ao}from"./DialogTitle-Csg36lAf.js";const Mo=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],os=en("chevron-right",Mo);const Io=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],rs=en("loader-circle",Io),ko=["top","right","bottom","left"],Oe=Math.min,J=Math.max,We=Math.round,He=Math.floor,ce=e=>({x:e,y:e}),Lo={left:"right",right:"left",bottom:"top",top:"bottom"};function st(e,t,n){return J(e,Oe(t,n))}function ue(e,t){return typeof e=="function"?e(t):e}function q(e){return e.split("-")[0]}function me(e){return e.split("-")[1]}function pt(e){return e==="x"?"y":"x"}function mt(e){return e==="y"?"height":"width"}function te(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ht(e){return pt(te(e))}function Fo(e,t,n){n===void 0&&(n=!1);const o=me(e),r=ht(e),s=mt(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ne(i)),[i,Ne(i)]}function Do(e){const t=Ne(e);return[it(e),t,it(t)]}function it(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const _t=["left","right"],Wt=["right","left"],Ho=["top","bottom"],Bo=["bottom","top"];function $o(e,t,n){switch(e){case"top":case"bottom":return n?t?Wt:_t:t?_t:Wt;case"left":case"right":return t?Ho:Bo;default:return[]}}function Vo(e,t,n,o){const r=me(e);let s=$o(q(e),n==="start",o);return r&&(s=s.map(i=>i+"-"+r),t&&(s=s.concat(s.map(it)))),s}function Ne(e){const t=q(e);return Lo[t]+e.slice(t.length)}function _o(e){return{top:0,right:0,bottom:0,left:0,...e}}function dn(e){return typeof e!="number"?_o(e):{top:e,right:e,bottom:e,left:e}}function je(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function Qe(e,t,n){if(n&&!Ce(n))return 0;if(typeof e=="number")return e;if(typeof e=="function"){const o=e();return typeof o=="number"?o:o?.[t]}return e?.[t]}function Wo(e,t={}){const n="rootStore"in e?e.rootStore:e,o=n.context.dataRef,{enabled:r=!0,event:s="click",toggle:i=!0,ignoreMouse:l=!1,stickIfOpen:a=!0,touchOpenDelay:d=0}=t,c=x.useRef(void 0),f=Hn(),m=nt(),p=x.useMemo(()=>({onPointerDown(u){c.current=u.pointerType},onMouseDown(u){const g=c.current,R=u.nativeEvent,w=n.select("open");if(u.button!==0||s==="click"||Ce(g,!0)&&l)return;const y=o.current.openEvent,C=y?.type,E=n.select("domReferenceElement")!==u.currentTarget,O=w&&E||!(w&&i&&(!(y&&a)||C==="click"||C==="mousedown"));if(Bn(R.target)){const b=K(be,R,R.target);O&&g==="touch"&&d>0?m.start(d,()=>{n.setOpen(!0,b)}):n.setOpen(O,b);return}const T=u.currentTarget;f.request(()=>{const b=K(be,R,T);O&&g==="touch"&&d>0?m.start(d,()=>{n.setOpen(!0,b)}):n.setOpen(O,b)})},onClick(u){if(s==="mousedown-only")return;const g=c.current;if(s==="mousedown"&&g){c.current=void 0;return}if(Ce(g,!0)&&l)return;const R=n.select("open"),w=o.current.openEvent,y=n.select("domReferenceElement")!==u.currentTarget,C=R&&y||!(R&&i&&(!(w&&a)||io(w))),E=K(be,u.nativeEvent,u.currentTarget);C&&g==="touch"&&d>0?m.start(d,()=>{n.setOpen(!0,E)}):n.setOpen(C,E)},onKeyDown(){c.current=void 0}}),[o,s,l,n,a,i,f,m,d]);return x.useMemo(()=>r?{reference:p}:tn,[r,p])}function Nt(e,t,n){let{reference:o,floating:r}=e;const s=te(t),i=ht(t),l=mt(i),a=q(t),d=s==="y",c=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,m=o[l]/2-r[l]/2;let p;switch(a){case"top":p={x:c,y:o.y-r.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:f};break;case"left":p={x:o.x-r.width,y:f};break;default:p={x:o.x,y:o.y}}switch(me(t)){case"start":p[i]-=m*(n&&d?-1:1);break;case"end":p[i]+=m*(n&&d?-1:1);break}return p}async function No(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:s,rects:i,elements:l,strategy:a}=e,{boundary:d="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=ue(t,e),u=dn(p),R=l[m?f==="floating"?"reference":"floating":f],w=je(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(R)))==null||n?R:R.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:c,strategy:a})),y=f==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),E=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},O=je(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:C,strategy:a}):y);return{top:(w.top-O.top+u.top)/E.y,bottom:(O.bottom-w.bottom+u.bottom)/E.y,left:(w.left-O.left+u.left)/E.x,right:(O.right-w.right+u.right)/E.x}}const jo=50,Yo=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:s=[],platform:i}=n,l=i.detectOverflow?i:{...i,detectOverflow:No},a=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:c,y:f}=Nt(d,o,a),m=o,p=0;const u={};for(let g=0;g<s.length;g++){const R=s[g];if(!R)continue;const{name:w,fn:y}=R,{x:C,y:E,data:O,reset:T}=await y({x:c,y:f,initialPlacement:o,placement:m,strategy:r,middlewareData:u,rects:d,platform:l,elements:{reference:e,floating:t}});c=C??c,f=E??f,u[w]={...u[w],...O},T&&p<jo&&(p++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(d=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):T.rects),{x:c,y:f}=Nt(d,m,a)),g=-1)}return{x:c,y:f,placement:m,strategy:r,middlewareData:u}},Xo=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:s,rects:i,initialPlacement:l,platform:a,elements:d}=t,{mainAxis:c=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:u="none",flipAlignment:g=!0,...R}=ue(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=q(r),y=te(l),C=q(l)===l,E=await(a.isRTL==null?void 0:a.isRTL(d.floating)),O=m||(C||!g?[Ne(l)]:Do(l)),T=u!=="none";!m&&T&&O.push(...Vo(l,g,u,E));const b=[l,...O],k=await a.detectOverflow(t,R),$=[];let A=((o=s.flip)==null?void 0:o.overflows)||[];if(c&&$.push(k[w]),f){const L=Fo(r,i,E);$.push(k[L[0]],k[L[1]])}if(A=[...A,{placement:r,overflows:$}],!$.every(L=>L<=0)){var F,S;const L=(((F=s.flip)==null?void 0:F.index)||0)+1,I=b[L];if(I&&(!(f==="alignment"?y!==te(I):!1)||A.every(v=>te(v.placement)===y?v.overflows[0]>0:!0)))return{data:{index:L,overflows:A},reset:{placement:I}};let D=(S=A.filter(M=>M.overflows[0]<=0).sort((M,v)=>M.overflows[1]-v.overflows[1])[0])==null?void 0:S.placement;if(!D)switch(p){case"bestFit":{var h;const M=(h=A.filter(v=>{if(T){const P=te(v.placement);return P===y||P==="y"}return!0}).map(v=>[v.placement,v.overflows.filter(P=>P>0).reduce((P,N)=>P+N,0)]).sort((v,P)=>v[1]-P[1])[0])==null?void 0:h[0];M&&(D=M);break}case"initialPlacement":D=l;break}if(r!==D)return{reset:{placement:D}}}return{}}}};function jt(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Yt(e){return ko.some(t=>e[t]>=0)}const zo=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:o}=t,{strategy:r="referenceHidden",...s}=ue(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...s,elementContext:"reference"}),l=jt(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Yt(l)}}}case"escaped":{const i=await o.detectOverflow(t,{...s,altBoundary:!0}),l=jt(i,n.floating);return{data:{escapedOffsets:l,escaped:Yt(l)}}}default:return{}}}}},gn=new Set(["left","top"]);async function Uo(e,t){const{placement:n,platform:o,elements:r}=e,s=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=q(n),l=me(n),a=te(n)==="y",d=gn.has(i)?-1:1,c=s&&a?-1:1,f=ue(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:u}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof u=="number"&&(p=l==="end"?u*-1:u),a?{x:p*c,y:m*d}:{x:m*d,y:p*c}}const Go=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:s,placement:i,middlewareData:l}=t,a=await Uo(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:r+a.x,y:s+a.y,data:{...a,placement:i}}}}},Ko=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r,platform:s}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:a={fn:w=>{let{x:y,y:C}=w;return{x:y,y:C}}},...d}=ue(e,t),c={x:n,y:o},f=await s.detectOverflow(t,d),m=te(q(r)),p=pt(m);let u=c[p],g=c[m];if(i){const w=p==="y"?"top":"left",y=p==="y"?"bottom":"right",C=u+f[w],E=u-f[y];u=st(C,u,E)}if(l){const w=m==="y"?"top":"left",y=m==="y"?"bottom":"right",C=g+f[w],E=g-f[y];g=st(C,g,E)}const R=a.fn({...t,[p]:u,[m]:g});return{...R,data:{x:R.x-n,y:R.y-o,enabled:{[p]:i,[m]:l}}}}}},qo=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:o,placement:r,rects:s,middlewareData:i}=t,{offset:l=0,mainAxis:a=!0,crossAxis:d=!0}=ue(e,t),c={x:n,y:o},f=te(r),m=pt(f);let p=c[m],u=c[f];const g=ue(l,t),R=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(a){const C=m==="y"?"height":"width",E=s.reference[m]-s.floating[C]+R.mainAxis,O=s.reference[m]+s.reference[C]-R.mainAxis;p<E?p=E:p>O&&(p=O)}if(d){var w,y;const C=m==="y"?"width":"height",E=gn.has(q(r)),O=s.reference[f]-s.floating[C]+(E&&((w=i.offset)==null?void 0:w[f])||0)+(E?0:R.crossAxis),T=s.reference[f]+s.reference[C]+(E?0:((y=i.offset)==null?void 0:y[f])||0)-(E?R.crossAxis:0);u<O?u=O:u>T&&(u=T)}return{[m]:p,[f]:u}}}},Jo=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,o;const{placement:r,rects:s,platform:i,elements:l}=t,{apply:a=()=>{},...d}=ue(e,t),c=await i.detectOverflow(t,d),f=q(r),m=me(r),p=te(r)==="y",{width:u,height:g}=s.floating;let R,w;f==="top"||f==="bottom"?(R=f,w=m===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(w=f,R=m==="end"?"top":"bottom");const y=g-c.top-c.bottom,C=u-c.left-c.right,E=Oe(g-c[R],y),O=Oe(u-c[w],C),T=!t.middlewareData.shift;let b=E,k=O;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=C),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(b=y),T&&!m){const A=J(c.left,0),F=J(c.right,0),S=J(c.top,0),h=J(c.bottom,0);p?k=u-2*(A!==0||F!==0?A+F:J(c.left,c.right)):b=g-2*(S!==0||h!==0?S+h:J(c.top,c.bottom))}await a({...t,availableWidth:k,availableHeight:b});const $=await i.getDimensions(l.floating);return u!==$.width||g!==$.height?{reset:{rects:!0}}:{}}}};function pn(e){const t=fe(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=pe(e),s=r?e.offsetWidth:n,i=r?e.offsetHeight:o,l=We(n)!==s||We(o)!==i;return l&&(n=s,o=i),{width:n,height:o,$:l}}function xt(e){return z(e)?e:e.contextElement}function Ee(e){const t=xt(e);if(!pe(t))return ce(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:s}=pn(t);let i=(s?We(n.width):n.width)/o,l=(s?We(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Qo=ce(0);function mn(e){const t=ge(e);return!nn()||!t.visualViewport?Qo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Zo(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ge(e)?!1:t}function he(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),s=xt(e);let i=ce(1);t&&(o?z(o)&&(i=Ee(o)):i=Ee(e));const l=Zo(s,n,o)?mn(s):ce(0);let a=(r.left+l.x)/i.x,d=(r.top+l.y)/i.y,c=r.width/i.x,f=r.height/i.y;if(s){const m=ge(s),p=o&&z(o)?ge(o):o;let u=m,g=$t(u);for(;g&&o&&p!==u;){const R=Ee(g),w=g.getBoundingClientRect(),y=fe(g),C=w.left+(g.clientLeft+parseFloat(y.paddingLeft))*R.x,E=w.top+(g.clientTop+parseFloat(y.paddingTop))*R.y;a*=R.x,d*=R.y,c*=R.x,f*=R.y,a+=C,d+=E,u=ge(g),g=$t(u)}}return je({width:c,height:f,x:a,y:d})}function Ue(e,t){const n=Xe(e).scrollLeft;return t?t.left+n:he(de(e)).left+n}function hn(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Ue(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function er(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const s=r==="fixed",i=de(o),l=t?at(t.floating):!1;if(o===i||l&&s)return n;let a={scrollLeft:0,scrollTop:0},d=ce(1);const c=ce(0),f=pe(o);if((f||!f&&!s)&&((lt(o)!=="body"||ft(i))&&(a=Xe(o)),f)){const p=he(o);d=Ee(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const m=i&&!f&&!s?hn(i,a):ce(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-a.scrollLeft*d.x+c.x+m.x,y:n.y*d.y-a.scrollTop*d.y+c.y+m.y}}function tr(e){return Array.from(e.getClientRects())}function nr(e){const t=de(e),n=Xe(e),o=e.ownerDocument.body,r=J(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),s=J(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+Ue(e);const l=-n.scrollTop;return fe(o).direction==="rtl"&&(i+=J(t.clientWidth,o.clientWidth)-r),{width:r,height:s,x:i,y:l}}const Xt=25;function or(e,t){const n=ge(e),o=de(e),r=n.visualViewport;let s=o.clientWidth,i=o.clientHeight,l=0,a=0;if(r){s=r.width,i=r.height;const c=nn();(!c||c&&t==="fixed")&&(l=r.offsetLeft,a=r.offsetTop)}const d=Ue(o);if(d<=0){const c=o.ownerDocument,f=c.body,m=getComputedStyle(f),p=c.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,u=Math.abs(o.clientWidth-f.clientWidth-p);u<=Xt&&(s-=u)}else d<=Xt&&(s+=d);return{width:s,height:i,x:l,y:a}}function rr(e,t){const n=he(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,s=pe(e)?Ee(e):ce(1),i=e.clientWidth*s.x,l=e.clientHeight*s.y,a=r*s.x,d=o*s.y;return{width:i,height:l,x:a,y:d}}function zt(e,t,n){let o;if(t==="viewport")o=or(e,n);else if(t==="document")o=nr(de(e));else if(z(t))o=rr(t,n);else{const r=mn(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return je(o)}function xn(e,t){const n=Me(e);return n===t||!z(n)||Ve(n)?!1:fe(n).position==="fixed"||xn(n,t)}function sr(e,t){const n=t.get(e);if(n)return n;let o=ot(e,[],!1).filter(l=>z(l)&&lt(l)!=="body"),r=null;const s=fe(e).position==="fixed";let i=s?Me(e):e;for(;z(i)&&!Ve(i);){const l=fe(i),a=on(i);!a&&l.position==="fixed"&&(r=null),(s?!a&&!r:!a&&l.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||ft(i)&&!a&&xn(e,i))?o=o.filter(c=>c!==i):r=l,i=Me(i)}return t.set(e,o),o}function ir(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?at(t)?[]:sr(t,this._c):[].concat(n),o],l=zt(t,i[0],r);let a=l.top,d=l.right,c=l.bottom,f=l.left;for(let m=1;m<i.length;m++){const p=zt(t,i[m],r);a=J(p.top,a),d=Oe(p.right,d),c=Oe(p.bottom,c),f=J(p.left,f)}return{width:d-f,height:c-a,x:f,y:a}}function cr(e){const{width:t,height:n}=pn(e);return{width:t,height:n}}function ar(e,t,n){const o=pe(t),r=de(t),s=n==="fixed",i=he(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const a=ce(0);function d(){a.x=Ue(r)}if(o||!o&&!s)if((lt(t)!=="body"||ft(r))&&(l=Xe(t)),o){const p=he(t,!0,s,t);a.x=p.x+t.clientLeft,a.y=p.y+t.clientTop}else r&&d();s&&!o&&r&&d();const c=r&&!o&&!s?hn(r,l):ce(0),f=i.left+l.scrollLeft-a.x-c.x,m=i.top+l.scrollTop-a.y-c.y;return{x:f,y:m,width:i.width,height:i.height}}function Ze(e){return fe(e).position==="static"}function Ut(e,t){if(!pe(e)||fe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return de(e)===n&&(n=n.ownerDocument.body),n}function yn(e,t){const n=ge(e);if(at(e))return n;if(!pe(e)){let r=Me(e);for(;r&&!Ve(r);){if(z(r)&&!Ze(r))return r;r=Me(r)}return n}let o=Ut(e,t);for(;o&&$n(o)&&Ze(o);)o=Ut(o,t);return o&&Ve(o)&&Ze(o)&&!on(o)?n:o||Vn(e)||n}const lr=async function(e){const t=this.getOffsetParent||yn,n=this.getDimensions,o=await n(e.floating);return{reference:ar(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function fr(e){return fe(e).direction==="rtl"}const ur={convertOffsetParentRelativeRectToViewportRelativeRect:er,getDocumentElement:de,getClippingRect:ir,getOffsetParent:yn,getElementRects:lr,getClientRects:tr,getDimensions:cr,getScale:Ee,isElement:z,isRTL:fr};function vn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dr(e,t){let n=null,o;const r=de(e);function s(){var l;clearTimeout(o),(l=n)==null||l.disconnect(),n=null}function i(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),s();const d=e.getBoundingClientRect(),{left:c,top:f,width:m,height:p}=d;if(l||t(),!m||!p)return;const u=He(f),g=He(r.clientWidth-(c+m)),R=He(r.clientHeight-(f+p)),w=He(c),C={rootMargin:-u+"px "+-g+"px "+-R+"px "+-w+"px",threshold:J(0,Oe(1,a))||1};let E=!0;function O(T){const b=T[0].intersectionRatio;if(b!==a){if(!E)return i();b?i(!1,b):o=setTimeout(()=>{i(!1,1e-7)},1e3)}b===1&&!vn(d,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(O,{...C,root:r.ownerDocument})}catch{n=new IntersectionObserver(O,C)}n.observe(e)}return i(!0),s}function Gt(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=o,d=xt(e),c=r||s?[...d?ot(d):[],...t?ot(t):[]]:[];c.forEach(w=>{r&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const f=d&&l?dr(d,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(w=>{let[y]=w;y&&y.target===d&&p&&t&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),d&&!a&&p.observe(d),t&&p.observe(t));let u,g=a?he(e):null;a&&R();function R(){const w=he(e);g&&!vn(g,w)&&n(),g=w,u=requestAnimationFrame(R)}return n(),()=>{var w;c.forEach(y=>{r&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),f?.(),(w=p)==null||w.disconnect(),p=null,a&&cancelAnimationFrame(u)}}const gr=Go,pr=Ko,mr=Xo,hr=Jo,xr=zo,yr=qo,vr=(e,t,n)=>{const o=new Map,r={platform:ur,...n},s={...r.platform,_c:o};return Yo(e,t,{...r,platform:s})};var Rr=typeof document<"u",br=function(){},Be=Rr?x.useLayoutEffect:br;function Ye(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!Ye(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const s=r[o];if(!(s==="_owner"&&e.$$typeof)&&!Ye(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Rn(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Kt(e,t){const n=Rn(e);return Math.round(t*n)/n}function et(e){const t=x.useRef(e);return Be(()=>{t.current=e}),t}function wr(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:s,floating:i}={},transform:l=!0,whileElementsMounted:a,open:d}=e,[c,f]=x.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=x.useState(o);Ye(m,o)||p(o);const[u,g]=x.useState(null),[R,w]=x.useState(null),y=x.useCallback(v=>{v!==T.current&&(T.current=v,g(v))},[]),C=x.useCallback(v=>{v!==b.current&&(b.current=v,w(v))},[]),E=s||u,O=i||R,T=x.useRef(null),b=x.useRef(null),k=x.useRef(c),$=a!=null,A=et(a),F=et(r),S=et(d),h=x.useCallback(()=>{if(!T.current||!b.current)return;const v={placement:t,strategy:n,middleware:m};F.current&&(v.platform=F.current),vr(T.current,b.current,v).then(P=>{const N={...P,isPositioned:S.current!==!1};L.current&&!Ye(k.current,N)&&(k.current=N,Ie.flushSync(()=>{f(N)}))})},[m,t,n,F,S]);Be(()=>{d===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,f(v=>({...v,isPositioned:!1})))},[d]);const L=x.useRef(!1);Be(()=>(L.current=!0,()=>{L.current=!1}),[]),Be(()=>{if(E&&(T.current=E),O&&(b.current=O),E&&O){if(A.current)return A.current(E,O,h);h()}},[E,O,h,A,$]);const I=x.useMemo(()=>({reference:T,floating:b,setReference:y,setFloating:C}),[y,C]),D=x.useMemo(()=>({reference:E,floating:O}),[E,O]),M=x.useMemo(()=>{const v={position:n,left:0,top:0};if(!D.floating)return v;const P=Kt(D.floating,c.x),N=Kt(D.floating,c.y);return l?{...v,transform:"translate("+P+"px, "+N+"px)",...Rn(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:P,top:N}},[n,l,D.floating,c.x,c.y]);return x.useMemo(()=>({...c,update:h,refs:I,elements:D,floatingStyles:M}),[c,h,I,D,M])}const Er=(e,t)=>{const n=gr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cr=(e,t)=>{const n=pr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Or=(e,t)=>({fn:yr(e).fn,options:[e,t]}),Tr=(e,t)=>{const n=mr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sr=(e,t)=>{const n=hr(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pr=(e,t)=>{const n=xr(e);return{name:n.name,fn:n.fn,options:[e,t]}};function Ar(e){const{open:t=!1,onOpenChange:n,elements:o={}}=e,r=_n(),s=dt()!=null,i=rn(()=>new co({open:t,onOpenChange:n,referenceElement:o.reference??null,floatingElement:o.floating??null,triggerElements:o.triggers??new ln,floatingId:r,nested:s,noEmit:e.noEmit||!1})).current;return le(()=>{const l={open:t,floatingId:r};o.reference!==void 0&&(l.referenceElement=o.reference,l.domReferenceElement=z(o.reference)?o.reference:null),o.floating!==void 0&&(l.floatingElement=o.floating),i.update(l)},[t,r,o.reference,o.floating,i]),i.context.onOpenChange=n,i.context.nested=s,i.context.noEmit=e.noEmit||!1,i}function Mr(e={}){const{nodeId:t,externalTree:n}=e,o=Ar(e),r=e.rootContext||o,s={reference:r.useState("referenceElement"),floating:r.useState("floatingElement"),domReference:r.useState("domReferenceElement")},[i,l]=x.useState(null),a=x.useRef(null),d=gt(n);le(()=>{s.domReference&&(a.current=s.domReference)},[s.domReference]);const c=wr({...e,elements:{...s,...i&&{reference:i}}}),f=x.useCallback(b=>{const k=z(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;l(k),c.refs.setReference(k)},[c.refs]),[m,p]=x.useState(null),[u,g]=x.useState(null);r.useSyncedValue("referenceElement",m),r.useSyncedValue("domReferenceElement",z(m)?m:null),r.useSyncedValue("floatingElement",u);const R=x.useCallback(b=>{(z(b)||b===null)&&(a.current=b,p(b)),(z(c.refs.reference.current)||c.refs.reference.current===null||b!==null&&!z(b))&&c.refs.setReference(b)},[c.refs,p]),w=x.useCallback(b=>{g(b),c.refs.setFloating(b)},[c.refs]),y=x.useMemo(()=>({...c.refs,setReference:R,setFloating:w,setPositionReference:f,domReference:a}),[c.refs,R,w,f]),C=x.useMemo(()=>({...c.elements,domReference:s.domReference}),[c.elements,s.domReference]),E=r.useState("open"),O=r.useState("floatingId"),T=x.useMemo(()=>({...c,dataRef:r.context.dataRef,open:E,onOpenChange:r.setOpen,events:r.context.events,floatingId:O,refs:y,elements:C,nodeId:t,rootStore:r}),[c,y,C,t,r,E,O]);return le(()=>{r.context.dataRef.current.floatingContext=T;const b=d?.nodesRef.current.find(k=>k.id===t);b&&(b.context=T)}),x.useMemo(()=>({...c,context:T,refs:y,elements:C,rootStore:r}),[c,y,C,T,r])}const ct=Wn("safe-polygon"),Ir=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Nn}`;function kr(e){return e?!!e.closest(Ir):!1}function bn(e){const t=x.useRef(void 0),n=x.useRef(!1),o=x.useRef(void 0),r=x.useRef(!0),s=x.useRef(!1),i=x.useRef(()=>{}),l=x.useRef(!1),a=nt(),d=nt(),c=x.useRef(void 0);return x.useMemo(()=>{const f=e.context.dataRef.current;return f.hoverInteractionState||(f.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:o,blockMouseMoveRef:r,performedPointerEventsMutationRef:s,unbindMouseMoveRef:i,restTimeoutPendingRef:l,openChangeTimeout:a,restTimeout:d,handleCloseOptionsRef:c}),f.hoverInteractionState},[e,t,n,o,r,s,i,l,a,d,c])}const Lr=new Set(["click","mousedown"]);function Fr(e,t={}){const n="rootStore"in e?e.rootStore:e,o=n.useState("open"),r=n.useState("floatingElement"),s=n.useState("domReferenceElement"),{dataRef:i}=n.context,{enabled:l=!0,closeDelay:a=0,externalTree:d}=t,{pointerTypeRef:c,interactedInsideRef:f,handlerRef:m,performedPointerEventsMutationRef:p,unbindMouseMoveRef:u,restTimeoutPendingRef:g,openChangeTimeout:R,handleCloseOptionsRef:w}=bn(n),y=gt(d),C=dt(),E=ee(()=>f.current?!0:i.current.openEvent?Lr.has(i.current.openEvent.type):!1),O=ee(()=>{const A=i.current.openEvent?.type;return A?.includes("mouse")&&A!=="mousedown"}),T=x.useCallback((A,F=!0)=>{const S=Dr(a,c.current);S&&!m.current?R.start(S,()=>n.setOpen(!1,K(Z,A))):F&&(R.clear(),n.setOpen(!1,K(Z,A)))},[a,m,n,c,R]),b=ee(()=>{u.current(),m.current=void 0}),k=ee(()=>{if(p.current){const A=_e(r).body;A.style.pointerEvents="",A.removeAttribute(ct),p.current=!1}}),$=ee(A=>{const F=sn(A);if(!kr(F)){f.current=!1;return}f.current=!0});le(()=>{o||(c.current=void 0,g.current=!1,f.current=!1,b(),k())},[o,c,g,f,b,k]),x.useEffect(()=>()=>{b()},[b]),x.useEffect(()=>k,[k]),le(()=>{if(l&&o&&w.current?.blockPointerEvents&&O()&&z(s)&&r){p.current=!0;const A=_e(r).body;A.setAttribute(ct,"");const F=s,S=r,h=y?.nodesRef.current.find(L=>L.id===C)?.context?.elements.floating;return h&&(h.style.pointerEvents=""),A.style.pointerEvents="none",F.style.pointerEvents="auto",S.style.pointerEvents="auto",()=>{A.style.pointerEvents="",F.style.pointerEvents="",S.style.pointerEvents=""}}},[l,o,s,r,w,O,y,C,p]),x.useEffect(()=>{if(!l)return;function A(L){if(E()||!i.current.floatingContext||!n.select("open"))return;const I=n.context.triggerElements;L.relatedTarget&&I.hasElement(L.relatedTarget)||(k(),b(),E()||T(L))}function F(L){R.clear(),k(),m.current?.(L),b()}function S(L){E()||T(L,!1)}const h=r;return h&&(h.addEventListener("mouseleave",A),h.addEventListener("mouseenter",F),h.addEventListener("mouseleave",S),h.addEventListener("pointerdown",$,!0)),()=>{h&&(h.removeEventListener("mouseleave",A),h.removeEventListener("mouseenter",F),h.removeEventListener("mouseleave",S),h.removeEventListener("pointerdown",$,!0))}})}function Dr(e,t){return t&&!Ce(t)?0:typeof e=="function"?e():e}function tt(e){return typeof e=="function"?e():e}const Hr={current:null};function Br(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:o,events:r}=n.context,{enabled:s=!0,delay:i=0,handleClose:l=null,mouseOnly:a=!1,restMs:d=0,move:c=!0,triggerElementRef:f=Hr,externalTree:m,isActiveTrigger:p=!0}=t,u=gt(m),{pointerTypeRef:g,interactedInsideRef:R,handlerRef:w,blockMouseMoveRef:y,performedPointerEventsMutationRef:C,unbindMouseMoveRef:E,restTimeoutPendingRef:O,openChangeTimeout:T,restTimeout:b,handleCloseOptionsRef:k}=bn(n),$=we(l),A=we(i),F=we(d);p&&(k.current=$.current?.__options);const S=ee(()=>R.current?!0:o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1),h=x.useCallback((M,v=!0)=>{const P=Qe(A.current,"close",g.current);P&&!w.current?T.start(P,()=>n.setOpen(!1,K(Z,M))):v&&(T.clear(),n.setOpen(!1,K(Z,M)))},[A,w,n,g,T]),L=ee(()=>{E.current(),w.current=void 0}),I=ee(()=>{if(C.current){const M=_e(n.select("domReferenceElement")).body;M.style.pointerEvents="",M.removeAttribute(ct),C.current=!1}});x.useEffect(()=>{if(!s)return;function M(v){v.open||(T.clear(),b.clear(),y.current=!0,O.current=!1)}return r.on("openchange",M),()=>{r.off("openchange",M)}},[s,r,T,b,y,O]);const D=ee(M=>{if(S()||!o.current.floatingContext)return;const v=n.context.triggerElements;if(M.relatedTarget&&v.hasElement(M.relatedTarget))return;const P=f.current;$.current?.({...o.current.floatingContext,tree:u,x:M.clientX,y:M.clientY,onClose(){I(),L(),!S()&&P===n.select("domReferenceElement")&&h(M)}})(M)});return x.useEffect(()=>{if(!s)return;const M=f.current??(p?n.select("domReferenceElement"):null);if(!z(M))return;function v(V){if(T.clear(),y.current=!1,a&&!Ce(g.current)||tt(F.current)>0&&!Qe(A.current,"open"))return;const _=Qe(A.current,"open",g.current),j=n.select("domReferenceElement"),H=n.context.triggerElements,Y=(H.hasElement(V.target)||H.hasMatchingElement(se=>ae(se,V.target)))&&(!j||!ae(j,V.target)),B=V.currentTarget??null,W=n.select("open"),ne=!W||Y;Y&&W?n.setOpen(!0,K(Z,V,B)):_?T.start(_,()=>{ne&&n.setOpen(!0,K(Z,V,B))}):ne&&n.setOpen(!0,K(Z,V,B))}function P(V){if(S()){I();return}E.current();const _=n.select("domReferenceElement"),j=_e(_);b.clear(),O.current=!1;const H=n.context.triggerElements;if(V.relatedTarget&&H.hasElement(V.relatedTarget))return;if($.current&&o.current.floatingContext){n.select("open")||T.clear();const B=f.current;w.current=$.current({...o.current.floatingContext,tree:u,x:V.clientX,y:V.clientY,onClose(){I(),L(),!S()&&B===n.select("domReferenceElement")&&h(V,!0)}});const W=w.current;W(V),j.addEventListener("mousemove",W),E.current=()=>{j.removeEventListener("mousemove",W)};return}(g.current!=="touch"||!ae(n.select("floatingElement"),V.relatedTarget))&&h(V)}function N(V){D(V)}return n.select("open")&&M.addEventListener("mouseleave",N),c&&M.addEventListener("mousemove",v,{once:!0}),M.addEventListener("mouseenter",v),M.addEventListener("mouseleave",P),()=>{M.removeEventListener("mouseleave",N),c&&M.removeEventListener("mousemove",v),M.removeEventListener("mouseenter",v),M.removeEventListener("mouseleave",P)}},[L,I,y,o,A,h,n,s,$,D,p,S,a,c,g,F,b,O,T,f,u,E,w]),x.useMemo(()=>{function M(v){g.current=v.pointerType}return{onPointerDown:M,onPointerEnter:M,onMouseMove(v){const{nativeEvent:P}=v,N=v.currentTarget,V=n.select("domReferenceElement"),_=n.context.triggerElements,j=n.select("open"),H=(_.hasElement(v.target)||_.hasMatchingElement(B=>ae(B,v.target)))&&(!V||!ae(V,v.target));if(a&&!Ce(g.current)||j&&!H||tt(F.current)===0||!H&&O.current&&v.movementX**2+v.movementY**2<2)return;b.clear();function Y(){if(O.current=!1,S())return;const B=n.select("open");!y.current&&(!B||H)&&n.setOpen(!0,K(Z,P,N))}g.current==="touch"?Ie.flushSync(()=>{Y()}):H&&j?Y():(O.current=!0,b.start(tt(F.current),Y))}}},[y,S,a,n,g,F,b,O])}function qt(e,t){const[n,o]=e;let r=!1;const s=t.length;for(let i=0,l=s-1;i<s;l=i++){const[a,d]=t[i]||[0,0],[c,f]=t[l]||[0,0];d>=o!=f>=o&&n<=(c-a)*(o-d)/(f-d)+a&&(r=!r)}return r}function $r(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Vr(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:o=!0}=e,r=new cn;let s=!1,i=null,l=null,a=typeof performance<"u"?performance.now():0;function d(f,m){const p=performance.now(),u=p-a;if(i===null||l===null||u===0)return i=f,l=m,a=p,null;const g=f-i,R=m-l,y=Math.sqrt(g*g+R*R)/u;return i=f,l=m,a=p,y}const c=({x:f,y:m,placement:p,elements:u,onClose:g,nodeId:R,tree:w})=>function(C){function E(){r.clear(),g()}if(r.clear(),!u.domReference||!u.floating||p==null||f==null||m==null)return;const{clientX:O,clientY:T}=C,b=[O,T],k=sn(C),$=C.type==="mouseleave",A=ae(u.floating,k),F=ae(u.domReference,k),S=u.domReference.getBoundingClientRect(),h=u.floating.getBoundingClientRect(),L=p.split("-")[0],I=f>h.right-h.width/2,D=m>h.bottom-h.height/2,M=$r(b,S),v=h.width>S.width,P=h.height>S.height,N=(v?S:h).left,V=(v?S:h).right,_=(P?S:h).top,j=(P?S:h).bottom;if(A&&(s=!0,!$))return;if(F&&(s=!1),F&&!$){s=!0;return}if($&&z(C.relatedTarget)&&ae(u.floating,C.relatedTarget)||w&&ao(w.nodesRef.current,R).some(({context:B})=>B?.open))return;if(L==="top"&&m>=S.bottom-1||L==="bottom"&&m<=S.top+1||L==="left"&&f>=S.right-1||L==="right"&&f<=S.left+1)return E();let H=[];switch(L){case"top":H=[[N,S.top+1],[N,h.bottom-1],[V,h.bottom-1],[V,S.top+1]];break;case"bottom":H=[[N,h.top+1],[N,S.bottom-1],[V,S.bottom-1],[V,h.top+1]];break;case"left":H=[[h.right-1,j],[h.right-1,_],[S.left+1,_],[S.left+1,j]];break;case"right":H=[[S.right-1,j],[S.right-1,_],[h.left+1,_],[h.left+1,j]];break}function Y([B,W]){switch(L){case"top":{const ne=[v?B+t/2:I?B+t*4:B-t*4,W+t+1],se=[v?B-t/2:I?B+t*4:B-t*4,W+t+1],oe=[[h.left,I||v?h.bottom-t:h.top],[h.right,I?v?h.bottom-t:h.top:h.bottom-t]];return[ne,se,...oe]}case"bottom":{const ne=[v?B+t/2:I?B+t*4:B-t*4,W-t],se=[v?B-t/2:I?B+t*4:B-t*4,W-t],oe=[[h.left,I||v?h.top+t:h.bottom],[h.right,I?v?h.top+t:h.bottom:h.top+t]];return[ne,se,...oe]}case"left":{const ne=[B+t+1,P?W+t/2:D?W+t*4:W-t*4],se=[B+t+1,P?W-t/2:D?W+t*4:W-t*4];return[...[[D||P?h.right-t:h.left,h.top],[D?P?h.right-t:h.left:h.right-t,h.bottom]],ne,se]}case"right":{const ne=[B-t,P?W+t/2:D?W+t*4:W-t*4],se=[B-t,P?W-t/2:D?W+t*4:W-t*4],oe=[[D||P?h.left+t:h.right,h.top],[D?P?h.left+t:h.right:h.left+t,h.bottom]];return[ne,se,...oe]}default:return[]}}if(!qt([O,T],H)){if(s&&!M)return E();if(!$&&o){const B=d(C.clientX,C.clientY);if(B!==null&&B<.1)return E()}qt([O,T],Y([f,m]))?!s&&o&&r.start(40,E):E()}};return c.__options={blockPointerEvents:n},c}const _r=x.createContext(void 0);function Wr(){return x.useContext(_r)?.direction??"ltr"}const Nr=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:s,platform:i,elements:l,middlewareData:a}=t,{element:d,padding:c=0,offsetParent:f="real"}=ue(e,t)||{};if(d==null)return{};const m=dn(c),p={x:n,y:o},u=ht(r),g=mt(u),R=await i.getDimensions(d),w=u==="y",y=w?"top":"left",C=w?"bottom":"right",E=w?"clientHeight":"clientWidth",O=s.reference[g]+s.reference[u]-p[u]-s.floating[g],T=p[u]-s.reference[u],b=f==="real"?await i.getOffsetParent?.(d):l.floating;let k=l.floating[E]||s.floating[g];(!k||!await i.isElement?.(b))&&(k=l.floating[E]||s.floating[g]);const $=O/2-T/2,A=k/2-R[g]/2-1,F=Math.min(m[y],A),S=Math.min(m[C],A),h=F,L=k-R[g]-S,I=k/2-R[g]/2+$,D=st(h,I,L),M=!a.arrow&&me(r)!=null&&I!==D&&s.reference[g]/2-(I<h?F:S)-R[g]/2<0,v=M?I<h?I-h:I-L:0;return{[u]:p[u]+v,data:{[u]:D,centerOffset:I-D-v,...M&&{alignmentOffset:v}},reset:M}}}),jr=(e,t)=>({...Nr(e),options:[e,t]}),Yr={name:"hide",async fn(e){const{width:t,height:n,x:o,y:r}=e.rects.reference,s=t===0&&n===0&&o===0&&r===0;return{data:{referenceHidden:(await Pr().fn(e)).data?.referenceHidden||s}}}},$e={sideX:"left",sideY:"top"},Xr={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:o},elements:{floating:r},platform:s,strategy:i,placement:l}=e,a=ge(r),d=a.getComputedStyle(r);if(!(d.transitionDuration!=="0s"&&d.transitionDuration!==""))return{x:t,y:n,data:$e};const f=await s.getOffsetParent?.(r);let m={width:0,height:0};if(i==="fixed"&&a?.visualViewport)m={width:a.visualViewport.width,height:a.visualViewport.height};else if(f===a){const y=an(r);m={width:y.documentElement.clientWidth,height:y.documentElement.clientHeight}}else await s.isElement?.(f)&&(m=await s.getDimensions(f));const p=q(l);let u=t,g=n;p==="left"&&(u=m.width-(t+o.width)),p==="top"&&(g=m.height-(n+o.height));const R=p==="left"?"right":$e.sideX,w=p==="top"?"bottom":$e.sideY;return{x:u,y:g,data:{sideX:R,sideY:w}}}};function wn(e,t,n){const o=e==="inline-start"||e==="inline-end";return{top:"top",right:o?n?"inline-start":"inline-end":"right",bottom:"bottom",left:o?n?"inline-end":"inline-start":"left"}[t]}function Jt(e,t,n){const{rects:o,placement:r}=e;return{side:wn(t,q(r),n),align:me(r)||"center",anchor:{width:o.reference.width,height:o.reference.height},positioner:{width:o.floating.width,height:o.floating.height}}}function zr(e){const{anchor:t,positionMethod:n="absolute",side:o="bottom",sideOffset:r=0,align:s="center",alignOffset:i=0,collisionBoundary:l,collisionPadding:a=5,sticky:d=!1,arrowPadding:c=5,disableAnchorTracking:f=!1,keepMounted:m=!1,floatingRootContext:p,mounted:u,collisionAvoidance:g,shiftCrossAxis:R=!1,nodeId:w,adaptiveOrigin:y,lazyFlip:C=!1,externalTree:E}=e,[O,T]=x.useState(null);!u&&O!==null&&T(null);const b=g.side||"flip",k=g.align||"flip",$=g.fallbackAxisSide||"end",A=typeof t=="function"?t:void 0,F=ee(A),S=A?F:t,h=we(t),I=Wr()==="rtl",D=O||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":I?"left":"right","inline-start":I?"right":"left"}[o],M=s==="center"?D:`${D}-${s}`;let v=a;const P=1,N=o==="bottom"?P:0,V=o==="top"?P:0,_=o==="right"?P:0,j=o==="left"?P:0;typeof v=="number"?v={top:v+N,right:v+j,bottom:v+V,left:v+_}:v&&(v={top:(v.top||0)+N,right:(v.right||0)+j,bottom:(v.bottom||0)+V,left:(v.left||0)+_});const H={boundary:l==="clipping-ancestors"?"clippingAncestors":l,padding:v},Y=x.useRef(null),B=we(r),W=we(i),oe=[Er(X=>{const G=Jt(X,o,I),ie=typeof B.current=="function"?B.current(G):B.current,Q=typeof W.current=="function"?W.current(G):W.current;return{mainAxis:ie,crossAxis:Q,alignmentAxis:Q}},[typeof r!="function"?r:0,typeof i!="function"?i:0,I,o])],vt=k==="none"&&b!=="shift",Rt=!vt&&(d||R||b==="shift"),bt=b==="none"?null:Tr({...H,padding:{top:v.top+P,right:v.right+P,bottom:v.bottom+P,left:v.left+P},mainAxis:!R&&b==="flip",crossAxis:k==="flip"?"alignment":!1,fallbackAxisSideDirection:$}),wt=vt?null:Cr(X=>{const G=an(X.elements.floating).documentElement;return{...H,rootBoundary:R?{x:0,y:0,width:G.clientWidth,height:G.clientHeight}:void 0,mainAxis:k!=="none",crossAxis:Rt,limiter:d||R?void 0:Or(ie=>{if(!Y.current)return{};const{width:Q,height:ve}=Y.current.getBoundingClientRect(),Re=te(q(ie.placement)),De=Re==="y"?Q:ve,qe=Re==="y"?v.left+v.right:v.top+v.bottom;return{offset:De/2+qe/2}})}},[H,d,R,v,k]);b==="shift"||k==="shift"||s==="center"?oe.push(wt,bt):oe.push(bt,wt),oe.push(Sr({...H,apply({elements:{floating:X},rects:{reference:G},availableWidth:ie,availableHeight:Q}){Object.entries({"--available-width":`${ie}px`,"--available-height":`${Q}px`,"--anchor-width":`${G.width}px`,"--anchor-height":`${G.height}px`}).forEach(([ve,Re])=>{X.style.setProperty(ve,Re)})}}),jr(()=>({element:Y.current||document.createElement("div"),padding:c,offsetParent:"floating"}),[c]),{name:"transformOrigin",fn(X){const{elements:G,middlewareData:ie,placement:Q,rects:ve,y:Re}=X,De=q(Q),qe=te(De),Ht=Y.current,Sn=ie.arrow?.x||0,Pn=ie.arrow?.y||0,An=Ht?.clientWidth||0,Mn=Ht?.clientHeight||0,Je=Sn+An/2,Bt=Pn+Mn/2,In=Math.abs(ie.shift?.y||0),kn=ve.reference.height/2,Ae=typeof r=="function"?r(Jt(X,o,I)):r,Ln=In>Ae,Fn={top:`${Je}px calc(100% + ${Ae}px)`,bottom:`${Je}px ${-Ae}px`,left:`calc(100% + ${Ae}px) ${Bt}px`,right:`${-Ae}px ${Bt}px`}[De],Dn=`${Je}px ${ve.reference.y+kn-Re}px`;return G.floating.style.setProperty("--transform-origin",Rt&&qe==="y"&&Ln?Dn:Fn),{}}},Yr,y),le(()=>{!u&&p&&p.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[u,p]);const Ge=x.useMemo(()=>({elementResize:!f&&typeof ResizeObserver<"u",layoutShift:!f&&typeof IntersectionObserver<"u"}),[f]),{refs:xe,elements:Te,x:Et,y:Ct,middlewareData:ye,update:Le,placement:Ot,context:Tt,isPositioned:Se,floatingStyles:St}=Mr({rootContext:p,placement:M,middleware:oe,strategy:n,whileElementsMounted:m?void 0:(...X)=>Gt(...X,Ge),nodeId:w,externalTree:E}),{sideX:Pt,sideY:At}=ye.adaptiveOrigin||$e,Ke=Se?n:"fixed",Mt=x.useMemo(()=>y?{position:Ke,[Pt]:Et,[At]:Ct}:{position:Ke,...St},[y,Ke,Pt,Et,At,Ct,St]),Fe=x.useRef(null);le(()=>{if(!u)return;const X=h.current,G=typeof X=="function"?X():X,Q=(Qt(G)?G.current:G)||null||null;Q!==Fe.current&&(xe.setPositionReference(Q),Fe.current=Q)},[u,xe,S,h]),x.useEffect(()=>{if(!u)return;const X=h.current;typeof X!="function"&&Qt(X)&&X.current!==Fe.current&&(xe.setPositionReference(X.current),Fe.current=X.current)},[u,xe,S,h]),x.useEffect(()=>{if(m&&u&&Te.domReference&&Te.floating)return Gt(Te.domReference,Te.floating,Le,Ge)},[m,u,Te,Le,Ge]);const Pe=q(Ot),It=wn(o,Pe,I),kt=me(Ot)||"center",Lt=!!ye.hide?.referenceHidden;le(()=>{C&&u&&Se&&T(Pe)},[C,u,Se,Pe]);const Ft=x.useMemo(()=>({position:"absolute",top:ye.arrow?.y,left:ye.arrow?.x}),[ye.arrow]),Dt=ye.arrow?.centerOffset!==0;return x.useMemo(()=>({positionerStyles:Mt,arrowStyles:Ft,arrowRef:Y,arrowUncentered:Dt,side:It,align:kt,physicalSide:Pe,anchorHidden:Lt,refs:xe,context:Tt,isPositioned:Se,update:Le}),[Mt,Ft,Y,Dt,It,kt,Pe,Lt,xe,Tt,Se,Le])}function Qt(e){return e!=null&&"current"in e}const Ur=x.createContext(void 0);function Gr(e){return x.useContext(Ur)}function En(e){return e==="starting"?jn:tn}const Cn=x.createContext(void 0);function ke(e){const t=x.useContext(Cn);if(t===void 0&&!e)throw new Error(ze(47));return t}function Kr(){return{...uo(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const qr={...fo,disabled:re(e=>e.disabled),instantType:re(e=>e.instantType),openMethod:re(e=>e.openMethod),openChangeReason:re(e=>e.openChangeReason),modal:re(e=>e.modal),stickIfOpen:re(e=>e.stickIfOpen),titleElementId:re(e=>e.titleElementId),descriptionElementId:re(e=>e.descriptionElementId),openOnHover:re(e=>e.openOnHover),closeDelay:re(e=>e.closeDelay),hasViewport:re(e=>e.hasViewport)};class yt extends lo{constructor(t){const n={...Kr(),...t};n.open&&t?.mounted===void 0&&(n.mounted=!0),super(n,{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:x.createRef(),beforeContentFocusGuardRef:x.createRef(),stickIfOpenTimeout:new cn,triggerElements:new ln},qr)}setOpen=(t,n)=>{const o=n.reason===Z,r=n.reason===be&&n.event.detail===0,s=!t&&(n.reason===Yn||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(t,n),n.isCanceled)return;const i={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger};this.state.floatingRootContext.context.events?.emit("openchange",i);const a=()=>{const d={open:t,openChangeReason:n.reason},c=n.trigger?.id??null;(c||t)&&(d.activeTriggerId=c,d.activeTriggerElement=n.trigger??null),this.update(d)};o?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(Xn,()=>{this.set("stickIfOpen",!1)}),Ie.flushSync(a)):a(),r||s?this.set("instantType",r?"click":"dismiss"):n.reason===rt?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(t,n){const o=rn(()=>new yt(n)).current,r=t??o;return zn(o.disposeEffect),r}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function Zt({props:e}){const{children:t,open:n,defaultOpen:o=!1,onOpenChange:r,onOpenChangeComplete:s,modal:i=!1,handle:l,triggerId:a,defaultTriggerId:d=null}=e,c=yt.useStore(l?.store,{open:n??o,modal:i,activeTriggerId:a!==void 0?a:d});c.useControlledProp("open",n,o),c.useControlledProp("activeTriggerId",a,d);const f=c.useState("open"),m=c.useState("positionerElement"),p=c.useState("payload"),u=c.useState("openChangeReason");c.useContextCallback("onOpenChange",r),c.useContextCallback("onOpenChangeComplete",s);const{openMethod:g,triggerProps:R,reset:w}=po(f);mo(c);const{forceUnmount:y}=ho(f,c,()=>{c.update({stickIfOpen:!0,openChangeReason:null}),w()});xo(f&&i===!0&&u!==Z&&g!=="touch",m),x.useEffect(()=>{f||c.context.stickIfOpenTimeout.clear()},[c,f]);const C=x.useCallback(I=>{const D=K(I);return D.preventUnmountOnClose=()=>{c.set("preventUnmountingOnClose",!0)},D},[c]),E=x.useCallback(()=>{c.setOpen(!1,C(Un))},[c,C]);x.useImperativeHandle(e.actionsRef,()=>({unmount:y,close:E}),[y,E]);const O=yo({popupStore:c,onOpenChange:c.setOpen}),T=vo(O,{outsidePressEvent:{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),b=Ro(O),{getReferenceProps:k,getFloatingProps:$,getTriggerProps:A}=fn([T,b]),F=x.useMemo(()=>k(R),[k,R]),S=x.useMemo(()=>A(R),[A,R]),h=x.useMemo(()=>$(),[$]);c.useSyncedValues({modal:i,openMethod:g,activeTriggerProps:F,inactiveTriggerProps:S,popupProps:h,floatingRootContext:O,nested:dt()!=null});const L=x.useMemo(()=>({store:c}),[c]);return U.jsx(Cn.Provider,{value:L,children:typeof t=="function"?t({payload:p}):t})}function ss(e){return ke(!0)?U.jsx(Zt,{props:e}):U.jsx(go,{children:U.jsx(Zt,{props:e})})}const Jr=300,is=x.forwardRef(function(t,n){const{render:o,className:r,disabled:s=!1,nativeButton:i=!0,handle:l,payload:a,openOnHover:d=!1,delay:c=Jr,closeDelay:f=0,id:m,...p}=t,u=ke(!0),g=l?.store??u?.store;if(!g)throw new Error(ze(74));const R=bo(m),w=g.useState("isTriggerActive",R),y=g.useState("floatingRootContext"),C=g.useState("isOpenedByTrigger",R),E=x.useRef(null),{registerTrigger:O,isMountedByThisTrigger:T}=wo(R,E,g,{payload:a,disabled:s,openOnHover:d,closeDelay:f}),b=g.useState("openChangeReason"),k=g.useState("stickIfOpen"),$=g.useState("openMethod"),A=Br(y,{enabled:y!=null&&d&&($!=="touch"||b!==be),mouseOnly:!0,move:!1,handleClose:Vr(),restMs:c,delay:{close:f},triggerElementRef:E,isActiveTrigger:w}),F=Wo(y,{enabled:y!=null,stickIfOpen:k}),S=fn([F]),h=g.useState("triggerProps",T),L=x.useMemo(()=>({disabled:s,open:C}),[s,C]),{getButtonProps:I,buttonRef:D}=Gn({disabled:s,native:i}),M=x.useMemo(()=>({open(_){return _&&b===be?Eo.open(_):Co.open(_)}}),[b]),v=ut("button",t,{state:L,ref:[D,n,O,E],props:[S.getReferenceProps(),A,h,{[Kn]:"",id:R},p,I],stateAttributesMapping:M}),P=x.useRef(null),N=ee(_=>{Ie.flushSync(()=>{g.setOpen(!1,K(rt,_.nativeEvent,_.currentTarget))}),qn(P.current)?.focus()}),V=ee(_=>{const j=g.select("positionerElement");if(j&&Jn(_,j))g.context.beforeContentFocusGuardRef.current?.focus();else{Ie.flushSync(()=>{g.setOpen(!1,K(rt,_.nativeEvent,_.currentTarget))});let H=Qn(g.context.triggerFocusTargetRef.current||E.current);for(;H!==null&&ae(j,H);){const Y=H;if(H=Zn(H),H===Y)break}H?.focus()}});return w?U.jsxs(x.Fragment,{children:[U.jsx(Vt,{ref:P,onFocus:N}),U.jsx(x.Fragment,{children:v},R),U.jsx(Vt,{ref:g.context.triggerFocusTargetRef,onFocus:V})]}):U.jsx(x.Fragment,{children:v},R)}),On=x.createContext(void 0);function Qr(){const e=x.useContext(On);if(e===void 0)throw new Error(ze(45));return e}const cs=x.forwardRef(function(t,n){const{keepMounted:o=!1,...r}=t,{store:s}=ke();return s.useState("mounted")||o?U.jsx(On.Provider,{value:o,children:U.jsx(eo,{ref:n,...r,renderGuards:!1})}):null}),Tn=x.createContext(void 0);function Zr(){const e=x.useContext(Tn);if(!e)throw new Error(ze(46));return e}const as=x.forwardRef(function(t,n){const{render:o,className:r,anchor:s,positionMethod:i="absolute",side:l="bottom",align:a="center",sideOffset:d=0,alignOffset:c=0,collisionBoundary:f="clipping-ancestors",collisionPadding:m=5,arrowPadding:p=5,sticky:u=!1,disableAnchorTracking:g=!1,collisionAvoidance:R=to,...w}=t,{store:y}=ke(),C=Qr(),E=Oo(),O=y.useState("floatingRootContext"),T=y.useState("mounted"),b=y.useState("open"),k=y.useState("openChangeReason"),$=y.useState("activeTriggerElement"),A=y.useState("modal"),F=y.useState("positionerElement"),S=y.useState("instantType"),h=y.useState("transitionStatus"),L=y.useState("hasViewport"),I=x.useRef(null),D=no(F,!1,!1),M=zr({anchor:s,floatingRootContext:O,positionMethod:i,mounted:T,side:l,sideOffset:d,align:a,alignOffset:c,arrowPadding:p,collisionBoundary:f,collisionPadding:m,sticky:u,disableAnchorTracking:g,keepMounted:C,nodeId:E,collisionAvoidance:R,adaptiveOrigin:L?Xr:void 0}),v=x.useMemo(()=>{const H={};return b||(H.pointerEvents="none"),{role:"presentation",hidden:!T,style:{...M.positionerStyles,...H}}},[b,T,M.positionerStyles]),P=x.useMemo(()=>({props:v,...M}),[v,M]),N=O?.select("domReferenceElement");le(()=>{const H=N,Y=I.current;if(H&&(I.current=H),Y&&H&&H!==Y){y.set("instantType",void 0);const B=new AbortController;return D(()=>{y.set("instantType","trigger-change")},B.signal),()=>{B.abort()}}},[N,D,y]);const V=x.useMemo(()=>({open:b,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:S}),[b,P.side,P.align,P.anchorHidden,S]),_=x.useCallback(H=>{y.set("positionerElement",H)},[y]),j=ut("div",t,{state:V,props:[P.props,En(h),w],ref:[n,_],stateAttributesMapping:un});return U.jsxs(Tn.Provider,{value:P,children:[T&&A===!0&&k!==Z&&U.jsx(To,{ref:y.context.internalBackdropRef,inert:oo(!b),cutout:$}),U.jsx(So,{id:E,children:j})]})}),es={...un,...so},ls=x.forwardRef(function(t,n){const{className:o,render:r,initialFocus:s,finalFocus:i,...l}=t,{store:a}=ke(),d=Zr(),c=Gr()!=null,f=a.useState("open"),m=a.useState("openMethod"),p=a.useState("instantType"),u=a.useState("transitionStatus"),g=a.useState("popupProps"),R=a.useState("titleElementId"),w=a.useState("descriptionElementId"),y=a.useState("modal"),C=a.useState("mounted"),E=a.useState("openChangeReason"),O=a.useState("activeTriggerElement"),T=a.useState("floatingRootContext");ro({open:f,ref:a.context.popupRef,onComplete(){f&&a.context.onOpenChangeComplete?.(!0)}});const b=a.useState("disabled"),k=a.useState("openOnHover"),$=a.useState("closeDelay");Fr(T,{enabled:k&&!b,closeDelay:$});function A(I){return I==="touch"?a.context.popupRef.current:!0}const F=s===void 0?A:s,S=x.useMemo(()=>({open:f,side:d.side,align:d.align,instant:p,transitionStatus:u}),[f,d.side,d.align,p,u]),h=x.useCallback(I=>{a.set("popupElement",I)},[a]),L=ut("div",t,{state:S,ref:[n,a.context.popupRef,h],props:[g,{"aria-labelledby":R,"aria-describedby":w,onKeyDown(I){c&&Ao.has(I.key)&&I.stopPropagation()}},En(u),l],stateAttributesMapping:es});return U.jsx(Po,{context:T,openInteractionType:m,modal:y==="trap-focus",disabled:!C||E===Z,initialFocus:F,returnFocus:i,restoreFocus:"popup",previousFocusableElement:pe(O)?O:void 0,nextFocusableElement:a.context.triggerFocusTargetRef,beforeContentFocusGuardRef:a.context.beforeContentFocusGuardRef,children:L})});export{os as C,rs as L,ss as P,is as a,cs as b,as as c,ls as d,Wo as e,He as f,zr as g,Gr as h,En as i,Ar as u};
@@ -0,0 +1 @@
1
+ import{c as v,r as l,af as J,a9 as Y,aw as L,u as t,A,N as x,s,Q,al as q,ax as X,am as ee,an as te,ao as O,ay as ne,az as ae,O as ie,R as se,J as oe,K as re,V as le,aA as ce,aB as ue,aC as de,aD as ge,E as he,aE as pe,aF as be,aG as me,aH as fe,aI as xe,aJ as ye,aK as ve,a7 as ke}from"./main-y2PTR9Ni.js";import{L as je,a as G,u as Ne}from"./use-limits-display-prefs--sTkiVYR.js";import{S as k,T as j,a as m,b as Se,u as I}from"./use-native-settings-CI8nzpC4.js";import{C as we}from"./check-L6OoQyFg.js";import{u as Ce}from"./useCurrency-DyV36y25.js";import{C as P}from"./chevron-down-DaLDjB50.js";import{I as Le}from"./info-D9m3SBry.js";import{D as Ge}from"./download-B3izgOD2.js";import"./Card-CzL-eInd.js";const Ee=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ae=v("activity",Ee);const Oe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ie=v("copy",Oe);const Pe=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],_e=v("grip-vertical",Pe);const De=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],Te=v("languages",De);const Me=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ue=v("log-out",Me);const Re=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Fe=v("pencil",Re),He=e=>!e.isLayoutDirty&&e.willUpdate(!1);function E(){const e=new Set,n=new WeakMap,i=()=>e.forEach(He);return{add:a=>{e.add(a),n.set(a,a.addEventListener("willUpdate",i))},remove:a=>{e.delete(a);const o=n.get(a);o&&(o(),n.delete(a)),i()},dirty:i}}const $e=l.createContext(null);function Be(){const e=l.useRef(!1);return J(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function ze(){const e=Be(),[n,i]=l.useState(0),a=l.useCallback(()=>{e.current&&i(n+1)},[n]);return[l.useCallback(()=>Y.postRender(a),[a]),n]}const _=e=>e===!0,Ve=e=>_(e===!0)||e==="id",Ke=({children:e,id:n,inherit:i=!0})=>{const a=l.useContext(L),o=l.useContext($e),[r,c]=ze(),u=l.useRef(null),g=a.id||o;u.current===null&&(Ve(i)&&g&&(n=n?g+"-"+n:g),u.current={id:n,group:_(i)&&a.group||E()});const h=l.useMemo(()=>({...u.current,forceRender:r}),[c]);return t.jsx(L.Provider,{value:h,children:e})},Ze=new Set(["cursor","kiro","copilot","kimi"]);function We({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:x("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:x("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Je({prefs:e}){const{order:n,visibility:i,toggle:a,moveToward:o}=e,[r,c]=l.useState(null),[u,g]=l.useState(null),h=d=>p=>{c(d),p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",d)},b=d=>p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},f=()=>{c(null),g(null)},y=d=>{d.preventDefault(),c(null),g(null)};return t.jsx(Ke,{children:t.jsx("div",{className:"flex flex-col",children:n.map(d=>{const p=i[d]!==!1,N=r===d;return t.jsxs(A.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:b(d),onDragEnd:f,onDrop:y,className:x("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",N&&"opacity-40"),style:{cursor:N?"grabbing":"grab"},children:[t.jsx(_e,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),t.jsx("img",{src:je[d],alt:"",width:18,height:18,className:x("h-[18px] w-[18px] shrink-0 pointer-events-none",Ze.has(d)&&"dark:invert"),draggable:!1}),t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:G[d]}),t.jsx("div",{onMouseDown:S=>S.stopPropagation(),draggable:!1,children:t.jsx(We,{checked:p,onChange:()=>a(d),ariaLabel:`${s("limits.settings.toggle_visible")}: ${G[d]}`})})]},d)})})})}function Ye(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},a=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof a=="string"&&a.trim()?a.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Qe(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function qe(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),a=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||a?.[1];return o?`https://github.com/${o}`:null}function w(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function Xe(e,n,i){const[a,o]=l.useState(()=>q()),r=n&&i&&X(),c=l.useCallback(async()=>{const u=!a;if(ee(u),o(u),!!u)try{await te(()=>e())}catch(g){w("cloud sync",g)}},[a,e]);return{cloudSyncOn:a,handleCloudSyncToggle:c,showLocalCloudSync:r}}function et(e){const[n,i]=l.useState(!1),[a,o]=l.useState(!1),[r,c]=l.useState(!1),[u,g]=l.useState(!1),[h,b]=l.useState(null),[f,y]=l.useState(!1),[d,p]=l.useState(""),[N,S]=l.useState(!1),[U,C]=l.useState(""),[R,F]=l.useState(""),[H,$]=l.useState(!1),[B,z]=l.useState(null),V=l.useMemo(()=>Ye(e),[e]),K=l.useMemo(()=>Qe(e),[e]),Z=l.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),W=l.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:b,setGithubUrl:C,setProfileLoading:c,setPublicProfileOn:i,setShowGithubOn:S}),[]);return{anonymousOn:a,customDisplayName:h,displayName:V,editingGithub:H,editingName:f,email:K,githubError:B,githubInput:R,githubUrl:U,loadSetters:W,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:b,setEditingGithub:$,setEditingName:y,setGithubError:z,setGithubInput:F,setGithubUrl:C,setNameInput:p,setProfileLoading:c,setProfileSaving:g,setPublicProfileOn:i,setShowGithubOn:S,showGithubOn:N,userId:Z}}function tt(e,n,i){l.useEffect(()=>{if(!n)return;let a=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await O({getAccessToken:e});if(!a||!o)return;const r=await ne({accessToken:o});if(!a)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){w("load public profile",o)}finally{a&&i.setProfileLoading(!1)}})(),()=>{a=!1}},[e,n,i])}function nt(e,n){return l.useCallback(async(i,{label:a,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const c=await O({getAccessToken:e});if(!c)return!1;const u=await ae({accessToken:c,...i});return r?.(u),!0}catch(c){return o?o(c):w(a||"mutate profile",c),!1}finally{n.setProfileSaving(!1)}},[e,n])}function at(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function it(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function st(e,n){const i=l.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:l.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function ot(e,n){const i=l.useCallback(async()=>{const o=e.nameInput.trim().slice(0,50);o&&await n({display_name:o},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(o),e.setEditingName(!1)}})},[n,e]),a=l.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:a}}function rt(e,n){const i=l.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),a=l.useCallback(async()=>{const r=qe(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(s("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:c=>e.setGithubError(c?.message||s("settings.account.githubUrlInvalid")),onSuccess:c=>{e.setGithubUrl(c?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=l.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:a,handleShowGithubToggle:i,startEditingGithub:o}}function lt(){const e=Q(),n=et(e.user),i=Xe(e.getAccessToken,e.enabled,e.signedIn);tt(e.getAccessToken,e.signedIn,n.loadSetters);const a=nt(e.getAccessToken,n),o=st(n,a),r=ot(n,a),c=rt(n,a);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:at(n,{...o,...r}),github:it(n,c),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function D({disabled:e,onCancel:n,onSave:i,saveLabel:a=s("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:a}),t.jsx("button",{type:"button",onClick:n,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:s("settings.account.cancel")})]})}function ct({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:a,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:s("settings.account.displayName")}),t.jsx(D,{disabled:a||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:a?s("settings.account.saving"):void 0})]})}function ut({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:a,setEditingGithub:o,setGithubError:r,setGithubInput:c}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:n,onChange:u=>{c(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&i(),u.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:s("settings.account.githubUrlPlaceholder")}),t.jsx(D,{disabled:a,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:a?s("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function T({disabled:e=!1,label:n,onClick:i,title:a}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:a,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function M({actions:e,editing:n,editor:i,hint:a,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a})]}),n?null:e]})})}function dt({name:e}){const n=e.anonymousOn?s("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(T,{disabled:e.anonymousOn,label:s("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:s("settings.account.displayName")})]})}function gt({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:a,editingName:o,handleAnonymousToggle:r,handleSaveName:c,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:b,setNameInput:f,startEditingName:y}=e,d=n?s("settings.account.displayNameAnonymousHint"):i||a;return t.jsx(M,{label:s("settings.account.displayName"),editing:o,hint:d,editor:t.jsx(ct,{nameInput:u,setEditingName:b,setNameInput:f,profileSaving:h,handleSaveName:c}),actions:t.jsx(dt,{name:e})})}function ht({github:e}){const{editingGithub:n,githubError:i,githubInput:a,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:c,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:b,setGithubInput:f,showGithubOn:y,startEditingGithub:d}=e;return t.jsx(M,{label:s("settings.account.githubUrl"),editing:n,hint:o||s("settings.account.githubUrlHint"),editor:t.jsx(ut,{githubError:i,githubInput:a,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:b,setGithubInput:f}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(T,{label:s("settings.account.edit"),onClick:d}),t.jsx(j,{checked:y,onChange:c,disabled:u||g,ariaLabel:s("settings.account.githubUrl")})]})})}function pt(){const{openLoginModal:e}=ie();return t.jsx(k,{title:s("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:s("settings.account.signIn")})]})})}function bt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(gt,{name:e}),t.jsx(ht,{github:n})]})}function mt(){const e=lt();return e.enabled?e.signedIn?t.jsxs(k,{title:s("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(xt,{onSignOut:e.signOut}),children:[t.jsx(ft,{userId:e.userId}),t.jsx(yt,{settings:e}),t.jsx(vt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(kt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(pt,{}):null}function ft({userId:e}){const[n,i]=se.useState(!1);if(!e)return null;const a=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:a,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":s("settings.account.copyUserId"),children:[n?t.jsx(we,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?s("settings.account.copied"):s("settings.account.copy")]})]})}function xt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(Ue,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.signOut")]})}function yt({settings:e}){return e.showLocalCloudSync?t.jsx(m,{label:s("settings.account.cloudSync"),hint:s("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:s("settings.account.cloudSync")})}):null}function vt({checked:e,disabled:n,onChange:i}){return t.jsx(m,{label:s("settings.account.publicProfile"),hint:s("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:i,disabled:n,ariaLabel:s("settings.account.publicProfile")})})}function kt({visible:e,name:n,github:i}){return t.jsx(oe,{initial:!1,children:e?t.jsx(A.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(bt,{name:n,github:i})},"public-profile-fields"):null})}function jt(){return[{value:"light",label:s("settings.appearance.theme.light"),Icon:ce},{value:"dark",label:s("settings.appearance.theme.dark"),Icon:ue},{value:"system",label:s("settings.appearance.theme.system"),Icon:de}]}function Nt(){return[{value:pe,label:s("settings.appearance.language.system")},{value:be,label:s("settings.appearance.language.english")},{value:me,label:s("settings.appearance.language.chinese")},{value:fe,label:s("settings.appearance.language.traditional_chinese")},{value:xe,label:s("settings.appearance.language.japanese")},{value:ye,label:s("settings.appearance.language.korean")}]}function St(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function wt(e,n){const i=s(`settings.appearance.currency.rate_source.${e}`),a=St(n),o=a?s("settings.appearance.currency.rate_updated",{when:a}):s("settings.appearance.currency.rate_never");return`${i} · ${o}`}function Ct({locale:e,setLocale:n}){const i=Nt();return t.jsxs("div",{className:"relative inline-flex",children:[t.jsx(Te,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),t.jsx("select",{value:e,onChange:a=>n(a.target.value),"aria-label":s("settings.appearance.language.label"),className:x("appearance-none rounded-lg border border-oai-gray-200 bg-white py-1.5 pl-8 pr-8 text-xs font-medium text-oai-black","transition-colors hover:bg-oai-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500","dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:bg-oai-gray-800"),children:i.map(a=>t.jsx("option",{value:a.value,children:a.label},a.value))}),t.jsx(P,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]})}function Lt({currency:e,setCurrency:n}){const i=ge();return t.jsxs("div",{className:"relative inline-flex",children:[t.jsx("select",{value:e,onChange:a=>n(a.target.value),"aria-label":s("settings.appearance.currency.label"),className:x("appearance-none rounded-lg border border-oai-gray-200 bg-white py-1.5 pl-3 pr-8 text-xs font-medium text-oai-black","transition-colors hover:bg-oai-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500","dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:bg-oai-gray-800"),children:i.map(a=>t.jsx("option",{value:a.code,children:s(a.labelKey)},a.code))}),t.jsx(P,{className:"pointer-events-none absolute right-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]})}function Gt({currency:e,rate:n,rateSource:i,rateFetchedAt:a}){if(e===he)return t.jsx(t.Fragment,{children:s("settings.appearance.currency.hint")});const o=wt(i,a);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Et(){const{theme:e,setTheme:n}=re(),{locale:i,setLocale:a}=le(),{currency:o,rate:r,rateSource:c,rateFetchedAt:u,setCurrency:g}=Ce();return t.jsxs(k,{title:s("settings.section.appearance"),children:[t.jsx(m,{label:s("settings.appearance.theme.label"),hint:s("settings.appearance.theme.hint"),control:t.jsx(Se,{options:jt(),value:e,onChange:n})}),t.jsx(m,{label:s("settings.appearance.language.label"),hint:s("settings.appearance.language.hint"),control:t.jsx(Ct,{locale:i,setLocale:a})}),t.jsx(m,{label:s("settings.appearance.currency.label"),hint:t.jsx(Gt,{currency:o,rate:r,rateSource:c,rateFetchedAt:u}),control:t.jsx(Lt,{currency:o,setCurrency:g})})]})}function At(){const{available:e,settings:n,setSetting:i,runAction:a}=I();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.launchAtLoginSupported!==!1,c=n?.updateStatus||null,u=!!n?.updateBusy,g=!!n?.isSyncing;return t.jsxs(k,{title:s("settings.section.menubar"),children:[r?t.jsx(m,{label:s("settings.menubar.launchAtLogin"),hint:s("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:s("settings.menubar.launchAtLogin")})}):null,t.jsx(m,{label:s("settings.menubar.syncNow"),hint:s("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>a("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(ve,{className:x("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?s("settings.menubar.syncing"):s("settings.menubar.syncNow")]})}),t.jsx(m,{label:s("settings.menubar.updates"),hint:c||void 0,control:t.jsxs("button",{type:"button",onClick:()=>a("checkForUpdates"),disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.menubar.checkUpdates")]})})]})}function Ot(){const{available:e,settings:n,runAction:i}=I(),a=e&&n?.version;return t.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-2 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[a?t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:["TokenTrackerBar v",n.version]}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,t.jsxs("a",{href:ke,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.footer.statusPage")]})]})}function Ht(){const e=Ne();return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.page.subtitle")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Et,{}),t.jsx(At,{}),t.jsx(mt,{}),t.jsx(k,{title:s("settings.section.limits"),children:t.jsx(Je,{prefs:e})})]}),t.jsx(Ot,{})]})})})}export{Ht as SettingsPage};
@@ -0,0 +1 @@
1
+ import{c as kt,aL as tr,aM as wt,aN as et,aO as tt,aP as _r,aQ as ne,aR as vn,r as n,aS as Ce,aT as gr,aU as jn,aV as xt,x as Ue,aW as Ft,aX as mr,aY as Nn,aZ as Or,a_ as at,a$ as qt,b0 as ot,b1 as We,b2 as Mt,b3 as Sn,u as t,M as Ar,b4 as Gt,b5 as At,b6 as rr,b7 as nr,b8 as Lr,b9 as Vr,ba as Lt,bb as Cn,v as ar,w as qe,bc as Yt,bd as Rn,be as In,bf as Mn,bg as En,bh as Tn,bi as hr,bj as Pn,bk as _n,bl as sr,bm as Bt,F as He,N as Ye,X as vt,s as m,J as On,z as An,A as pr,a4 as Ln,C as Vn,P as st,bn as Dn,bo as Un,bp as Fn,bq as Bn,br as $n,bs as Hn,i as zn,aK as Kn,bt as xr,R as Wn,bu as qn,bv as yr,bw as ct,bx as br,by as kr,bz as Gn,bA as wr,bB as vr,bC as Yn,bD as Xn}from"./main-y2PTR9Ni.js";import{L as Qn}from"./LocalOnlyNotice-BNFZWAB2.js";import{C as Jn}from"./Card-CzL-eInd.js";import{s as Le,f as Qe,g as Zn,h as ea,i as ta,j as ra,k as na,l as Et,m as de,n as or,o as aa,p as W,q as sa,r as oa,S as ia,t as la,v as ca,w as da,I as ua,x as Dr,F as fa,C as ga,u as ma,D as ha,a as pa,b as xa,c as ya,d as ba,e as ka}from"./DialogTitle-Csg36lAf.js";import{I as Ur}from"./info-D9m3SBry.js";import{u as wa}from"./useCurrency-DyV36y25.js";import{f as jr,u as va,e as ja,g as Na,h as Sa,i as Ca,L as Xe,P as Fr,a as Br,b as $r,c as Hr,d as zr,C as Ra}from"./PopoverPopup-Bg0LqxYF.js";import{C as ut}from"./check-L6OoQyFg.js";import{C as ir}from"./chevron-down-DaLDjB50.js";import{D as Kr}from"./download-B3izgOD2.js";import"./arrow-up-right-BTb5Q4za.js";const Ia=[["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"}]],Wr=kt("circle-arrow-up",Ia);const Ma=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Xt=kt("external-link",Ma);const Ea=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],Ta=kt("flame",Ea);const Pa=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],qr=kt("plus",Pa);const _a=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],lr=kt("trash-2",_a);function Nt(e,r,a){return Math.floor(e/r)!==a}function yt(e,r){return r<0||r>=e.current.length}function $t(e,r){return Ae(e,{disabledIndices:r})}function Nr(e,r){return Ae(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:r})}function Ae(e,{startingIndex:r=-1,decrement:a=!1,disabledIndices:o,amount:d=1}={}){let i=r;do i+=a?-d:d;while(i>=0&&i<=e.current.length-1&&bt(e,i,o));return i}function Oa(e,{event:r,orientation:a,loopFocus:o,rtl:d,cols:i,disabledIndices:c,minIndex:l,maxIndex:x,prevIndex:k,stopEvent:u=!1}){let g=k;const y=[],v={};let S=!1;{let f=null,R=-1;e.current.forEach((b,j)=>{if(b==null)return;const A=b.closest('[role="row"]');A&&(S=!0),(A!==f||R===-1)&&(f=A,R+=1,y[R]=[]),y[R].push(j),v[j]=R})}const w=S&&y.length>0&&y.some(f=>f.length!==i);function C(f){if(!w||k===-1)return;const R=v[k];if(R==null)return;const b=y[R].indexOf(k);let j=f==="up"?R-1:R+1;o&&(j<0?j=y.length-1:j>=y.length&&(j=0));const A=new Set;for(;j>=0&&j<y.length&&!A.has(j);){A.add(j);const O=y[j];if(O.length===0){j=f==="up"?j-1:j+1;continue}const $=Math.min(b,O.length-1);for(let _=$;_>=0;_-=1){const q=O[_];if(!bt(e,q,c))return q}j=f==="up"?j-1:j+1,o&&(j<0?j=y.length-1:j>=y.length&&(j=0))}}if(r.key===tr){const f=C("up");if(f!==void 0)u&&Le(r),g=f;else{if(u&&Le(r),k===-1)g=x;else if(g=Ae(e,{startingIndex:g,amount:i,decrement:!0,disabledIndices:c}),o&&(k-i<l||g<0)){const R=k%i,b=x%i,j=x-(b-R);b===R?g=x:g=b>R?j:j-i}yt(e,g)&&(g=k)}}if(r.key===wt){const f=C("down");f!==void 0?(u&&Le(r),g=f):(u&&Le(r),k===-1?g=l:(g=Ae(e,{startingIndex:k,amount:i,disabledIndices:c}),o&&k+i>x&&(g=Ae(e,{startingIndex:k%i-i,amount:i,disabledIndices:c}))),yt(e,g)&&(g=k))}if(a==="both"){const f=jr(k/i);r.key===(d?et:tt)&&(u&&Le(r),k%i!==i-1?(g=Ae(e,{startingIndex:k,disabledIndices:c}),o&&Nt(g,i,f)&&(g=Ae(e,{startingIndex:k-k%i-1,disabledIndices:c}))):o&&(g=Ae(e,{startingIndex:k-k%i-1,disabledIndices:c})),Nt(g,i,f)&&(g=k)),r.key===(d?tt:et)&&(u&&Le(r),k%i!==0?(g=Ae(e,{startingIndex:k,decrement:!0,disabledIndices:c}),o&&Nt(g,i,f)&&(g=Ae(e,{startingIndex:k+(i-k%i),decrement:!0,disabledIndices:c}))):o&&(g=Ae(e,{startingIndex:k+(i-k%i),decrement:!0,disabledIndices:c})),Nt(g,i,f)&&(g=k));const R=jr(x/i)===f;yt(e,g)&&(o&&R?g=r.key===(d?tt:et)?x:Ae(e,{startingIndex:k-k%i-1,disabledIndices:c}):g=k)}return g}function Aa(e,r,a){const o=[];let d=0;return e.forEach(({width:i,height:c},l)=>{let x=!1;for(a&&(d=0);!x;){const k=[];for(let u=0;u<i;u+=1)for(let g=0;g<c;g+=1)k.push(d+u+g*r);d%r+i<=r&&k.every(u=>o[u]==null)?(k.forEach(u=>{o[u]=l}),x=!0):d+=1}}),[...o]}function La(e,r,a,o,d){if(e===-1)return-1;const i=a.indexOf(e),c=r[e];switch(d){case"tl":return i;case"tr":return c?i+c.width-1:i;case"bl":return c?i+(c.height-1)*o:i;case"br":return a.lastIndexOf(e);default:return-1}}function Va(e,r){return r.flatMap((a,o)=>e.includes(a)?[o]:[])}function bt(e,r,a){if(typeof a=="function")return a(r);if(a)return a.includes(r);const o=e.current[r];return o?o.hasAttribute("disabled")||o.getAttribute("aria-disabled")==="true":!1}const Da="Escape";function Vt(e,r,a){switch(e){case"vertical":return r;case"horizontal":return a;default:return r||a}}function St(e,r){return Vt(r,e===tr||e===wt,e===et||e===tt)}function Ht(e,r,a){return Vt(r,e===wt,a?e===et:e===tt)||e==="Enter"||e===" "||e===""}function Ua(e,r,a){return Vt(r,a?e===et:e===tt,e===wt)}function Fa(e,r,a,o){const d=a?e===tt:e===et,i=e===tr;return r==="both"||r==="horizontal"&&o&&o>1?e===Da:Vt(r,d,i)}function Ba(e,r){const a="rootStore"in e?e.rootStore:e,o=a.useState("open"),d=a.useState("floatingElement"),i=a.useState("domReferenceElement"),c=a.context.dataRef,{listRef:l,activeIndex:x,onNavigate:k=()=>{},enabled:u=!0,selectedIndex:g=null,allowEscape:y=!1,loopFocus:v=!1,nested:S=!1,rtl:w=!1,virtual:C=!1,focusItemOnOpen:f="auto",focusItemOnHover:R=!0,openOnArrowKeyDown:b=!0,disabledIndices:j=void 0,orientation:A="vertical",parentOrientation:O,cols:$=1,scrollItemIntoView:_=!0,itemSizes:q,dense:pe=!1,id:J,resetOnPointerLeave:ae=!0,externalTree:X}=r,ue=_r(d),Y=Qe(ue),U=Zn(),se=ea(X);ne(()=>{c.current.orientation=A},[c,A]);const P=vn(i),H=n.useRef(f),I=n.useRef(g??-1),N=n.useRef(null),fe=n.useRef(!0),L=Ce(h=>{k(I.current===-1?null:I.current,h)}),le=n.useRef(L),Q=n.useRef(!!d),T=n.useRef(o),z=n.useRef(!1),xe=n.useRef(!1),ke=Qe(j),V=Qe(o),ye=Qe(_),Z=Qe(g),ge=Qe(ae),we=Ce(()=>{function h(re){C?se?.events.emit("virtualfocus",re):ta(re,{sync:z.current,preventScroll:!0})}const D=l.current[I.current],M=xe.current;D&&h(D),(z.current?re=>re():requestAnimationFrame)(()=>{const re=l.current[I.current]||D;if(!re)return;D||h(re);const me=ye.current;me&&K&&(M||!fe.current)&&re.scrollIntoView?.(typeof me=="boolean"?{block:"nearest",inline:"nearest"}:me)})});ne(()=>{u&&(o&&d?(I.current=g??-1,H.current&&g!=null&&(xe.current=!0,L())):Q.current&&(I.current=-1,le.current()))},[u,o,d,g,L]),ne(()=>{if(u){if(!o){z.current=!1;return}if(d)if(x==null){if(z.current=!1,Z.current!=null)return;if(Q.current&&(I.current=-1,we()),(!T.current||!Q.current)&&H.current&&(N.current!=null||H.current===!0&&N.current==null)){let h=0;const D=()=>{l.current[0]==null?(h<2&&(h?requestAnimationFrame:queueMicrotask)(D),h+=1):(I.current=N.current==null||Ht(N.current,A,w)||S?$t(l):Nr(l),N.current=null,L())};D()}}else yt(l,x)||(I.current=x,we(),xe.current=!1)}},[u,o,d,x,Z,S,l,A,w,L,we,ke]),ne(()=>{if(!u||d||!se||C||!Q.current)return;const h=se.nodesRef.current,D=h.find(re=>re.id===U)?.context?.elements.floating,M=gr(jn(d)),te=h.some(re=>re.context&&xt(re.context.elements.floating,M));D&&!te&&fe.current&&D.focus({preventScroll:!0})},[u,d,se,U,C]),ne(()=>{le.current=L,T.current=o,Q.current=!!d}),ne(()=>{o||(N.current=null,H.current=f)},[o,f]);const be=x!=null,K=n.useMemo(()=>{function h(M){if(!V.current)return;const te=l.current.indexOf(M.currentTarget);te!==-1&&I.current!==te&&(I.current=te,L(M))}return{onFocus(M){z.current=!0,h(M)},onClick:({currentTarget:M})=>M.focus({preventScroll:!0}),onMouseMove(M){z.current=!0,xe.current=!1,R&&h(M)},onPointerLeave(M){if(!V.current||!fe.current||M.pointerType==="touch")return;z.current=!0;const te=M.relatedTarget;!R||l.current.includes(te)||ge.current&&(I.current=-1,L(M),C||Y.current?.focus({preventScroll:!0}))}}},[V,Y,R,l,L,ge,C]),ee=n.useCallback(()=>O??se?.nodesRef.current.find(h=>h.id===U)?.context?.dataRef?.current.orientation,[U,se,O]),ve=Ce(h=>{if(fe.current=!1,z.current=!0,h.which===229||!V.current&&h.currentTarget===Y.current)return;if(S&&Fa(h.key,A,w,$)){St(h.key,ee())||Le(h),a.setOpen(!1,Ue(Ft,h.nativeEvent)),mr(i)&&(C?se?.events.emit("virtualfocus",i):i.focus());return}const D=I.current,M=$t(l,j),te=Nr(l,j);if(P||(h.key==="Home"&&(Le(h),I.current=M,L(h)),h.key==="End"&&(Le(h),I.current=te,L(h))),$>1){const re=q||Array.from({length:l.current.length},()=>({width:1,height:1})),me=Aa(re,$,pe),Ne=me.findIndex(Re=>Re!=null&&!bt(l,Re,j)),Se=me.reduce((Re,je,Ee)=>je!=null&&!bt(l,je,j)?Ee:Re,-1),Fe=me[Oa({current:me.map(Re=>Re!=null?l.current[Re]:null)},{event:h,orientation:A,loopFocus:v,rtl:w,cols:$,disabledIndices:Va([...(typeof j!="function"?j:null)||l.current.map((Re,je)=>bt(l,je,j)?je:void 0),void 0],me),minIndex:Ne,maxIndex:Se,prevIndex:La(I.current>te?M:I.current,re,me,$,h.key===wt?"bl":h.key===(w?et:tt)?"tr":"tl"),stopEvent:!0})];if(Fe!=null&&(I.current=Fe,L(h)),A==="both")return}if(St(h.key,A)){if(Le(h),o&&!C&&gr(h.currentTarget.ownerDocument)===h.currentTarget){I.current=Ht(h.key,A,w)?M:te,L(h);return}Ht(h.key,A,w)?v?D>=te?y&&D!==l.current.length?I.current=-1:(z.current=!1,I.current=M):I.current=Ae(l,{startingIndex:D,disabledIndices:j}):I.current=Math.min(te,Ae(l,{startingIndex:D,disabledIndices:j})):v?D<=M?y&&D!==-1?I.current=l.current.length:(z.current=!1,I.current=te):I.current=Ae(l,{startingIndex:D,decrement:!0,disabledIndices:j}):I.current=Math.max(M,Ae(l,{startingIndex:D,decrement:!0,disabledIndices:j})),yt(l,I.current)&&(I.current=-1),L(h)}}),oe=n.useMemo(()=>C&&o&&be&&{"aria-activedescendant":`${J}-${x}`},[C,o,be,J,x]),ie=n.useMemo(()=>({"aria-orientation":A==="both"?void 0:A,...P?{}:oe,onKeyDown(h){if(h.key==="Tab"&&h.shiftKey&&o&&!C){const D=Nn(h.nativeEvent);if(D&&!xt(Y.current,D))return;Le(h),a.setOpen(!1,Ue(Or,h.nativeEvent)),mr(i)&&i.focus();return}ve(h)},onPointerMove(){fe.current=!0}}),[oe,ve,Y,A,P,a,o,C,i]),Me=n.useMemo(()=>{function h(M){f==="auto"&&ra(M.nativeEvent)&&(H.current=!C)}function D(M){H.current=f,f==="auto"&&na(M.nativeEvent)&&(H.current=!0)}return{onKeyDown(M){const te=a.select("open");fe.current=!1;const re=M.key.startsWith("Arrow"),me=Ua(M.key,ee(),w),Ne=St(M.key,A),Se=(S?me:Ne)||M.key==="Enter"||M.key.trim()==="";if(C&&te)return ve(M);if(!(!te&&!b&&re)){if(Se){const Fe=St(M.key,ee());N.current=S&&Fe?null:M.key}if(S){me&&(Le(M),te?(I.current=$t(l,ke.current),L(M)):a.setOpen(!0,Ue(Ft,M.nativeEvent,M.currentTarget)));return}Ne&&(Z.current!=null&&(I.current=Z.current),Le(M),!te&&b?a.setOpen(!0,Ue(Ft,M.nativeEvent,M.currentTarget)):ve(M),te&&L(M))}},onFocus(M){a.select("open")&&!C&&(I.current=-1,L(M))},onPointerDown:D,onPointerEnter:D,onMouseDown:h,onClick:h}},[ve,ke,f,l,S,L,a,b,A,ee,w,Z,C]),ce=n.useMemo(()=>({...oe,...Me}),[oe,Me]);return n.useMemo(()=>u?{reference:ce,floating:ie,item:K,trigger:Me}:{},[u,ce,ie,Me,K])}function $a(e,r){const a="rootStore"in e?e.rootStore:e,o=a.useState("open"),d=a.context.dataRef,{listRef:i,activeIndex:c,onMatch:l,onTypingChange:x,enabled:k=!0,findMatch:u=null,resetMs:g=750,ignoreKeys:y=qt,selectedIndex:v=null}=r,S=at(),w=n.useRef(""),C=n.useRef(v??c??-1),f=n.useRef(null);ne(()=>{o&&(S.clear(),f.current=null,w.current="")},[o,S]),ne(()=>{o&&w.current===""&&(C.current=v??c??-1)},[o,v,c]);const R=Ce(O=>{O?d.current.typing||(d.current.typing=O,x?.(O)):d.current.typing&&(d.current.typing=O,x?.(O))}),b=Ce(O=>{function $(ae,X,ue){const Y=u?u(X,ue):X.find(U=>U?.toLocaleLowerCase().indexOf(ue.toLocaleLowerCase())===0);return Y?ae.indexOf(Y):-1}const _=i.current;if(w.current.length>0&&w.current[0]!==" "&&($(_,_,w.current)===-1?R(!1):O.key===" "&&Le(O)),_==null||y.includes(O.key)||O.key.length!==1||O.ctrlKey||O.metaKey||O.altKey)return;o&&O.key!==" "&&(Le(O),R(!0)),_.every(ae=>ae?ae[0]?.toLocaleLowerCase()!==ae[1]?.toLocaleLowerCase():!0)&&w.current===O.key&&(w.current="",C.current=f.current),w.current+=O.key,S.start(g,()=>{w.current="",C.current=f.current,R(!1)});const pe=C.current,J=$(_,[..._.slice((pe||0)+1),..._.slice(0,(pe||0)+1)],w.current);J!==-1?(l?.(J),f.current=J):O.key!==" "&&(w.current="",R(!1))}),j=n.useMemo(()=>({onKeyDown:b}),[b]),A=n.useMemo(()=>({onKeyDown:b,onKeyUp(O){O.key===" "&&R(!1)}}),[b,R]);return n.useMemo(()=>k?{reference:j,floating:A}:{},[k,j,A])}function Ha(e){const r=n.useRef(!0);r.current&&(r.current=!1,e())}function Qt({controlled:e,default:r,name:a,state:o="value"}){const{current:d}=n.useRef(e!==void 0),[i,c]=n.useState(r),l=d?e:i,x=n.useCallback(k=>{d||c(k)},[]);return[l,x]}const Gr=n.createContext(null),Yr=n.createContext(null);function rt(){const e=n.useContext(Gr);if(e===null)throw new Error(ot(60));return e}function Xr(){const e=n.useContext(Yr);if(e===null)throw new Error(ot(61));return e}let Sr=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const za={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},cr={valid(e){return e===null?null:e?{[Sr.valid]:""}:{[Sr.invalid]:""}}},Ka=n.createContext({invalid:void 0,name:void 0,validityData:{state:za,errors:[],error:"",value:"",initialValue:null},setValidityData:We,disabled:void 0,touched:!1,setTouched:We,dirty:!1,setDirty:We,filled:!1,setFilled:We,focused:!1,setFocused:We,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Mt)=>e,getInputValidationProps:(e=Mt)=>e,inputRef:{current:null},commit:async()=>{}}});function Dt(e=!0){const r=n.useContext(Ka);if(r.setValidityData===We&&!e)throw new Error(ot(28));return r}const Wa=n.createContext({controlId:void 0,setControlId:We,labelId:void 0,setLabelId:We,messageIds:[],setMessageIds:We,getDescriptionProps:e=>e});function dr(){return n.useContext(Wa)}function Qr(e={}){const{id:r,implicit:a=!1,controlRef:o}=e,{controlId:d,setControlId:i}=dr(),c=Et(r);return ne(()=>{if(!(!a&&!r||i===We)){if(a){const l=o?.current;Sn(l)&&l.closest("label")!=null?i(r??null):i(d??c)}else r&&i(r);return()=>{r&&i(void 0)}}},[r,o,d,i,a,c]),d??c}const qa=(e,r)=>Object.is(e,r);function ft(e,r,a){return e==null||r==null?Object.is(e,r):a(e,r)}function zt(e,r,a){return!e||e.length===0?!1:e.some(o=>o===void 0?!1:ft(o,r,a))}function Jt(e,r,a){return!e||e.length===0?-1:e.findIndex(o=>o===void 0?!1:ft(o,r,a))}function Ga(e,r,a){return e.filter(o=>!ft(o,r,a))}function Zt(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Jr(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Ya(e){if(!Array.isArray(e))return e!=null&&!("null"in e);if(Jr(e)){for(const r of e)for(const a of r.items)if(a&&a.value==null&&a.label!=null)return!0;return!1}for(const r of e)if(r&&r.value==null&&r.label!=null)return!0;return!1}function Xa(e,r){if(r&&e!=null)return r(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return Zt(e)}function dt(e,r){return r&&e!=null?r(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Zt(e.value):Zt(e)}function Zr(e,r,a){function o(){return Xa(e,a)}if(a&&e!=null)return a(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(r&&!Array.isArray(r))return r[e]??o();if(Array.isArray(r)){const d=Jr(r)?r.flatMap(i=>i.items):r;if(e==null||typeof e!="object"){const i=d.find(c=>c.value===e);return i&&i.label!=null?i.label:o()}if("value"in e){const i=d.find(c=>c&&c.value===e.value);if(i&&i.label!=null)return i.label}}return o()}function Qa(e,r,a){return e.reduce((o,d,i)=>(i>0&&o.push(", "),o.push(t.jsx(n.Fragment,{children:Zr(d,r,a)},i)),o),[])}const B={id:de(e=>e.id),modal:de(e=>e.modal),multiple:de(e=>e.multiple),items:de(e=>e.items),itemToStringLabel:de(e=>e.itemToStringLabel),itemToStringValue:de(e=>e.itemToStringValue),isItemEqualToValue:de(e=>e.isItemEqualToValue),value:de(e=>e.value),hasSelectedValue:de(e=>{const{value:r,multiple:a,itemToStringValue:o}=e;return r==null?!1:a&&Array.isArray(r)?r.length>0:dt(r,o)!==""}),hasNullItemLabel:de((e,r)=>r?Ya(e.items):!1),open:de(e=>e.open),mounted:de(e=>e.mounted),forceMount:de(e=>e.forceMount),transitionStatus:de(e=>e.transitionStatus),openMethod:de(e=>e.openMethod),activeIndex:de(e=>e.activeIndex),selectedIndex:de(e=>e.selectedIndex),isActive:de((e,r)=>e.activeIndex===r),isSelected:de((e,r,a)=>{const o=e.isItemEqualToValue,d=e.value;return e.multiple?Array.isArray(d)&&d.some(i=>ft(i,a,o)):e.selectedIndex===r&&e.selectedIndex!==null?!0:ft(d,a,o)}),isSelectedByFocus:de((e,r)=>e.selectedIndex===r),popupProps:de(e=>e.popupProps),triggerProps:de(e=>e.triggerProps),triggerElement:de(e=>e.triggerElement),positionerElement:de(e=>e.positionerElement),listElement:de(e=>e.listElement),scrollUpArrowVisible:de(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:de(e=>e.scrollDownArrowVisible),hasScrollArrows:de(e=>e.hasScrollArrows)},Ja=n.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:We,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function ur(){return n.useContext(Ja)}function Za(e,r){return{...e,state:{...e.state,valid:!r&&e.state.valid}}}function en(e){const{enabled:r=!0,value:a,id:o,name:d,controlRef:i,commit:c}=e,{formRef:l}=ur(),{invalid:x,markedDirtyRef:k,validityData:u,setValidityData:g}=Dt(),y=Ce(e.getValue);ne(()=>{if(!r)return;let v=a;v===void 0&&(v=y()),u.initialValue===null&&v!==null&&g(S=>({...S,initialValue:v}))},[r,g,a,u.initialValue,y]),ne(()=>{!r||!o||l.current.fields.set(o,{getValue:y,name:d,controlRef:i,validityData:Za(u,x),validate(v=!0){let S=a;S===void 0&&(S=y()),k.current=!0,v?Ar.flushSync(()=>c(S)):c(S)}})},[c,i,r,l,y,o,x,k,d,u,a]),ne(()=>{const v=l.current.fields;return()=>{o&&v.delete(o)}},[l,o])}function tn(e,r){const a=n.useRef(e),o=Ce(r);ne(()=>{a.current!==e&&o(a.current)},[e,o]),ne(()=>{a.current=e},[e])}function rn(e){const{id:r,value:a,defaultValue:o=null,onValueChange:d,open:i,defaultOpen:c=!1,onOpenChange:l,name:x,disabled:k=!1,readOnly:u=!1,required:g=!1,modal:y=!0,actionsRef:v,inputRef:S,onOpenChangeComplete:w,items:C,multiple:f=!1,itemToStringLabel:R,itemToStringValue:b,isItemEqualToValue:j=qa,highlightItemOnHover:A=!0,children:O}=e,{clearErrors:$}=ur(),{setDirty:_,setTouched:q,setFocused:pe,shouldValidateOnChange:J,validityData:ae,setFilled:X,name:ue,disabled:Y,validation:U,validationMode:se}=Dt(),P=Qr({id:r}),H=Y||k,I=ue??x,[N,fe]=Qt({controlled:a,default:f?o??qt:o,name:"Select",state:"value"}),[L,le]=Qt({controlled:i,default:c,name:"Select",state:"open"}),Q=n.useRef([]),T=n.useRef([]),z=n.useRef(null),xe=n.useRef(null),ke=n.useRef(0),V=n.useRef(null),ye=n.useRef([]),Z=n.useRef(!1),ge=n.useRef(!1),we=n.useRef(null),be=n.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),K=n.useRef(!1),{mounted:ee,setMounted:ve,transitionStatus:oe}=or(L),{openMethod:ie,triggerProps:Me,reset:ce}=aa(L),h=Gt(()=>new ia({id:P,modal:y,multiple:f,itemToStringLabel:R,itemToStringValue:b,isItemEqualToValue:j,value:N,open:L,mounted:ee,transitionStatus:oe,items:C,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,D=W(h,B.activeIndex),M=W(h,B.selectedIndex),te=W(h,B.triggerElement),re=W(h,B.positionerElement),me=n.useMemo(()=>f&&Array.isArray(N)&&N.length===0?"":dt(N,b),[f,N,b]),Ne=n.useMemo(()=>f&&Array.isArray(N)?N.map(F=>dt(F,b)):dt(N,b),[f,N,b]),Se=Qe(h.state.triggerElement);en({id:P,commit:U.commit,value:N,controlRef:Se,name:I,getValue:()=>Ne});const Fe=n.useRef(N);ne(()=>{N!==Fe.current&&h.set("forceMount",!0)},[h,N]),ne(()=>{X(f?Array.isArray(N)&&N.length>0:N!=null)},[f,N,X]),ne(function(){if(L)return;const he=ye.current;if(f){const p=Array.isArray(N)?N:[];if(p.length===0){h.set("selectedIndex",null);return}const E=p[p.length-1],G=Jt(he,E,j);h.set("selectedIndex",G===-1?null:G);return}const s=Jt(he,N,j);h.set("selectedIndex",s===-1?null:s)},[f,L,N,ye,j,h]),tn(N,()=>{$(I),_(N!==ae.initialValue),J()?U.commit(N):U.commit(N,!0)});const Re=Ce((F,he)=>{if(l?.(F,he),!he.isCanceled&&(le(F),!F&&(he.reason===Or||he.reason===Cn)&&(q(!0),pe(!1),se==="onBlur"&&U.commit(N)),!F&&h.state.activeIndex!==null)){const s=Q.current[h.state.activeIndex];queueMicrotask(()=>{s?.setAttribute("tabindex","-1")})}}),je=Ce(()=>{ve(!1),h.set("activeIndex",null),ce(),w?.(!1)});At({enabled:!v,open:L,ref:z,onComplete(){L||je()}}),n.useImperativeHandle(v,()=>({unmount:je}),[je]);const Ee=Ce((F,he)=>{d?.(F,he),!he.isCanceled&&fe(F)}),Te=Ce(()=>{const F=h.state.listElement||z.current;if(!F)return;const he=F.scrollTop,s=F.scrollTop+F.clientHeight,p=he>1,E=s<F.scrollHeight-1;h.state.scrollUpArrowVisible!==p&&h.set("scrollUpArrowVisible",p),h.state.scrollDownArrowVisible!==E&&h.set("scrollDownArrowVisible",E)}),Ve=va({open:L,onOpenChange:Re,elements:{reference:te,floating:re}}),_e=ja(Ve,{enabled:!u&&!H,event:"mousedown"}),Be=sa(Ve,{bubbles:!1}),ze=Ba(Ve,{enabled:!u&&!H,listRef:Q,activeIndex:D,selectedIndex:M,disabledIndices:qt,onNavigate(F){F===null&&!L||h.set("activeIndex",F)},focusItemOnHover:!1}),gt=$a(Ve,{enabled:!u&&!H&&(L||!f),listRef:T,activeIndex:D,selectedIndex:M,onMatch(F){L?h.set("activeIndex",F):Ee(ye.current[F],Ue("none"))},onTypingChange(F){Z.current=F}}),{getReferenceProps:Pe,getFloatingProps:Je,getItemProps:it}=oa([_e,Be,ze,gt]),nt=n.useMemo(()=>rr(Pe(),Me,P?{id:P}:Mt),[Pe,Me,P]);Ha(()=>{h.update({popupProps:Je(),triggerProps:nt})}),ne(()=>{h.update({id:P,modal:y,multiple:f,value:N,open:L,mounted:ee,transitionStatus:oe,popupProps:Je(),triggerProps:nt,items:C,itemToStringLabel:R,itemToStringValue:b,isItemEqualToValue:j,openMethod:ie})},[h,P,y,f,N,L,ee,oe,Je,nt,C,R,b,j,ie]);const lt=n.useMemo(()=>({store:h,name:I,required:g,disabled:H,readOnly:u,multiple:f,itemToStringLabel:R,itemToStringValue:b,highlightItemOnHover:A,setValue:Ee,setOpen:Re,listRef:Q,popupRef:z,scrollHandlerRef:xe,handleScrollArrowVisibility:Te,scrollArrowsMountedCountRef:ke,getItemProps:it,events:Ve.context.events,valueRef:V,valuesRef:ye,labelsRef:T,typingRef:Z,selectionRef:be,selectedItemTextRef:we,validation:U,onOpenChangeComplete:w,keyboardActiveRef:ge,alignItemWithTriggerActiveRef:K,initialValueRef:Fe}),[h,I,g,H,u,f,R,b,A,Ee,Re,it,Ve.context.events,U,w,Te]),Ge=nr(S,U.inputRef),mt=f&&Array.isArray(N)&&N.length>0,ht=n.useMemo(()=>!f||!Array.isArray(N)||!I?null:N.map(F=>{const he=dt(F,b);return t.jsx("input",{type:"hidden",name:I,value:he},he)}),[f,N,I,b]);return t.jsx(Gr.Provider,{value:lt,children:t.jsxs(Yr.Provider,{value:Ve,children:[O,t.jsx("input",{...U.getInputValidationProps({onFocus(){h.state.triggerElement?.focus({focusVisible:!0})},onChange(F){if(F.nativeEvent.defaultPrevented)return;const he=F.target.value,s=Ue(Lt,F.nativeEvent);function p(){if(f)return;const E=ye.current.find(G=>dt(G,b).toLowerCase()===he.toLowerCase());E!=null&&(_(E!==ae.initialValue),Ee(E,s),J()&&U.commit(E))}h.set("forceMount",!0),queueMicrotask(p)}}),name:f?void 0:I,value:me,disabled:H,required:g&&!mt,readOnly:u,ref:Ge,style:I?Lr:Vr,tabIndex:-1,"aria-hidden":!0}),ht]})})}function es(e){const r=e.getBoundingClientRect(),a=window.getComputedStyle(e,"::before"),o=window.getComputedStyle(e,"::after");if(!(a.content!=="none"||o.content!=="none"))return r;const i=parseFloat(a.width)||0,c=parseFloat(a.height)||0,l=parseFloat(o.width)||0,x=parseFloat(o.height)||0,k=Math.max(r.width,i,l),u=Math.max(r.height,c,x),g=k-r.width,y=u-r.height;return{left:r.left-g/2,right:r.right+g/2,top:r.top-y/2,bottom:r.bottom+y/2}}const Ct=2,ts=400,Cr=200,rs={...la,...cr,value:()=>null},nn=n.forwardRef(function(r,a){const{render:o,className:d,id:i,disabled:c=!1,nativeButton:l=!0,...x}=r,{setTouched:k,setFocused:u,validationMode:g,state:y,disabled:v}=Dt(),{labelId:S}=dr(),{store:w,setOpen:C,selectionRef:f,validation:R,readOnly:b,required:j,alignItemWithTriggerActiveRef:A,disabled:O,keyboardActiveRef:$}=rt(),_=v||O||c,q=W(w,B.open),pe=W(w,B.value),J=W(w,B.triggerProps),ae=W(w,B.positionerElement),X=W(w,B.listElement),ue=W(w,B.id),Y=W(w,B.hasSelectedValue),U=!Y&&q,se=W(w,B.hasNullItemLabel,U),P=i??ue;Qr({id:P});const H=Qe(ae),I=n.useRef(null),{getButtonProps:N,buttonRef:fe}=ar({disabled:_,native:l}),L=Ce(Z=>{w.set("triggerElement",Z)}),le=nr(a,I,fe,L),Q=at(),T=at(),z=at(),xe=at();n.useEffect(()=>{if(q)return!(Y||se)?z.start(ts,()=>{f.current.allowUnselectedMouseUp=!0,f.current.allowSelectedMouseUp=!0}):xe.start(Cr,()=>{f.current.allowUnselectedMouseUp=!0,z.start(Cr,()=>{f.current.allowSelectedMouseUp=!0})}),()=>{z.clear(),xe.clear()};f.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},T.clear()},[q,Y,se,f,T,z,xe]);const ke=n.useMemo(()=>X?.id??_r(ae)?.id,[X,ae]),V=rr(J,{id:P,role:"combobox","aria-expanded":q?"true":"false","aria-haspopup":"listbox","aria-controls":q?ke:void 0,"aria-labelledby":S,"aria-readonly":b||void 0,"aria-required":j||void 0,tabIndex:_?-1:0,ref:le,onFocus(Z){u(!0),q&&A.current&&C(!1,Ue(Lt,Z.nativeEvent)),Q.start(0,()=>{w.set("forceMount",!0)})},onBlur(Z){xt(ae,Z.relatedTarget)||(k(!0),u(!1),g==="onBlur"&&R.commit(pe))},onPointerMove(){$.current=!1},onKeyDown(){$.current=!0},onMouseDown(Z){if(q)return;const ge=Yt(Z.currentTarget);function we(be){if(!I.current)return;const K=be.target;if(xt(I.current,K)||xt(H.current,K)||K===I.current)return;const ee=es(I.current);be.clientX>=ee.left-Ct&&be.clientX<=ee.right+Ct&&be.clientY>=ee.top-Ct&&be.clientY<=ee.bottom+Ct||C(!1,Ue(Rn,be))}T.start(0,()=>{ge.addEventListener("mouseup",we,{once:!0})})}},R.getValidationProps,x,N);V.role="combobox";const ye=n.useMemo(()=>({...y,open:q,disabled:_,value:pe,readOnly:b,placeholder:!Y}),[y,q,_,pe,b,Y]);return qe("button",r,{ref:[a,I],state:ye,stateAttributesMapping:rs,props:V})}),ns={value:()=>null},an=n.forwardRef(function(r,a){const{className:o,render:d,children:i,placeholder:c,...l}=r,{store:x,valueRef:k}=rt(),u=W(x,B.value),g=W(x,B.items),y=W(x,B.itemToStringLabel),v=W(x,B.hasSelectedValue),S=!v&&c!=null&&i==null,w=W(x,B.hasNullItemLabel,S),C=n.useMemo(()=>({value:u,placeholder:!v}),[u,v]);let f=null;return typeof i=="function"?f=i(u):i!=null?f=i:!v&&c!=null&&!w?f=c:Array.isArray(u)?f=Qa(u,g,y):f=Zr(u,g,y),qe("span",r,{state:C,ref:[a,k],props:[{children:f},l],stateAttributesMapping:ns})}),sn=n.forwardRef(function(r,a){const{className:o,render:d,...i}=r,{store:c}=rt(),l=W(c,B.open),x=n.useMemo(()=>({open:l}),[l]);return qe("span",r,{state:x,ref:a,props:[{"aria-hidden":!0,children:"▼"},i],stateAttributesMapping:ca})}),as=n.createContext(void 0),on=n.forwardRef(function(r,a){const{store:o}=rt(),d=W(o,B.mounted),i=W(o,B.forceMount);return d||i?t.jsx(as.Provider,{value:!0,children:t.jsx(In,{ref:a,...r})}):null}),ln=n.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function ss(){return n.useContext(ln)}function os(e){const{children:r,elementsRef:a,labelsRef:o,onMapChange:d}=e,i=Ce(d),c=n.useRef(0),l=Gt(ls).current,x=Gt(is).current,[k,u]=n.useState(0),g=n.useRef(k),y=Ce((f,R)=>{x.set(f,R??null),g.current+=1,u(g.current)}),v=Ce(f=>{x.delete(f),g.current+=1,u(g.current)}),S=n.useMemo(()=>{const f=new Map;return Array.from(x.keys()).filter(b=>b.isConnected).sort(cs).forEach((b,j)=>{const A=x.get(b)??{};f.set(b,{...A,index:j})}),f},[x,k]);ne(()=>{if(typeof MutationObserver!="function"||S.size===0)return;const f=new MutationObserver(R=>{const b=new Set,j=A=>b.has(A)?b.delete(A):b.add(A);R.forEach(A=>{A.removedNodes.forEach(j),A.addedNodes.forEach(j)}),b.size===0&&(g.current+=1,u(g.current))});return S.forEach((R,b)=>{b.parentElement&&f.observe(b.parentElement,{childList:!0})}),()=>{f.disconnect()}},[S]),ne(()=>{g.current===k&&(a.current.length!==S.size&&(a.current.length=S.size),o&&o.current.length!==S.size&&(o.current.length=S.size),c.current=S.size),i(S)},[i,S,a,o,k]),ne(()=>()=>{a.current=[]},[a]),ne(()=>()=>{o&&(o.current=[])},[o]);const w=Ce(f=>(l.add(f),()=>{l.delete(f)}));ne(()=>{l.forEach(f=>f(S))},[l,S]);const C=n.useMemo(()=>({register:y,unregister:v,subscribeMapChange:w,elementsRef:a,labelsRef:o,nextIndexRef:c}),[y,v,w,a,o,c]);return t.jsx(ln.Provider,{value:C,children:r})}function is(){return new Map}function ls(){return new Set}function cs(e,r){const a=e.compareDocumentPosition(r);return a&Node.DOCUMENT_POSITION_FOLLOWING||a&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:a&Node.DOCUMENT_POSITION_PRECEDING||a&Node.DOCUMENT_POSITION_CONTAINS?1:0}const cn=n.createContext(void 0);function ds(){const e=n.useContext(cn);if(!e)throw new Error(ot(59));return e}function Tt(e,r){e&&Object.assign(e.style,r)}const us={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},fs={position:"fixed"},dn=n.forwardRef(function(r,a){const{anchor:o,positionMethod:d="absolute",className:i,render:c,side:l="bottom",align:x="center",sideOffset:k=0,alignOffset:u=0,collisionBoundary:g="clipping-ancestors",collisionPadding:y,arrowPadding:v=5,sticky:S=!1,disableAnchorTracking:w,alignItemWithTrigger:C=!0,collisionAvoidance:f=Mn,...R}=r,{store:b,listRef:j,labelsRef:A,alignItemWithTriggerActiveRef:O,selectedItemTextRef:$,valuesRef:_,initialValueRef:q,popupRef:pe,setValue:J}=rt(),ae=Xr(),X=W(b,B.open),ue=W(b,B.mounted),Y=W(b,B.modal),U=W(b,B.value),se=W(b,B.openMethod),P=W(b,B.positionerElement),H=W(b,B.triggerElement),I=W(b,B.isItemEqualToValue),N=n.useRef(null),fe=n.useRef(null),[L,le]=n.useState(C),Q=ue&&L&&se!=="touch";!ue&&L!==C&&le(C),ne(()=>{ue||(B.scrollUpArrowVisible(b.state)&&b.set("scrollUpArrowVisible",!1),B.scrollDownArrowVisible(b.state)&&b.set("scrollDownArrowVisible",!1))},[b,ue]),n.useImperativeHandle(O,()=>Q),da((Q||Y)&&X&&se!=="touch",H);const T=Na({anchor:o,floatingRootContext:ae,positionMethod:d,mounted:ue,side:l,sideOffset:k,align:x,alignOffset:u,arrowPadding:v,collisionBoundary:g,collisionPadding:y,sticky:S,disableAnchorTracking:w??Q,collisionAvoidance:f,keepMounted:!0}),z=Q?"none":T.side,xe=Q?fs:T.positionerStyles,ke=n.useMemo(()=>{const K={};return X||(K.pointerEvents="none"),{role:"presentation",hidden:!ue,style:{...xe,...K}}},[X,ue,xe]),V=n.useMemo(()=>({open:X,side:z,align:T.align,anchorHidden:T.anchorHidden}),[X,z,T.align,T.anchorHidden]),ye=Ce(K=>{b.set("positionerElement",K)}),Z=qe("div",r,{ref:[a,ye],state:V,stateAttributesMapping:Dr,props:[ke,R]}),ge=n.useRef(0),we=Ce(K=>{if(K.size===0&&ge.current===0||_.current.length===0)return;const ee=ge.current;if(ge.current=K.size,K.size===ee)return;const ve=Ue(Lt);if(ee!==0&&!b.state.multiple&&U!==null&&Jt(_.current,U,I)===-1){const ie=q.current,ce=ie!=null&&zt(_.current,ie,I)?ie:null;J(ce,ve),ce===null&&(b.set("selectedIndex",null),$.current=null)}if(ee!==0&&b.state.multiple&&Array.isArray(U)){const oe=U.filter(ie=>zt(_.current,ie,I));(oe.length!==U.length||oe.some(ie=>!zt(U,ie,I)))&&(J(oe,ve),oe.length===0&&(b.set("selectedIndex",null),$.current=null))}if(X&&Q){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const oe={height:""};Tt(P,oe),Tt(pe.current,oe)}}),be=n.useMemo(()=>({...T,side:z,alignItemWithTriggerActive:Q,setControlledAlignItemWithTrigger:le,scrollUpArrowRef:N,scrollDownArrowRef:fe}),[T,z,Q,le]);return t.jsx(os,{elementsRef:j,labelsRef:A,onMapChange:we,children:t.jsxs(cn.Provider,{value:be,children:[ue&&Y&&t.jsx(ua,{inert:En(!X),cutout:H}),Z]})})});function un(e){const r=e.currentTarget.getBoundingClientRect();return r.top+1<=e.clientY&&e.clientY<=r.bottom-1&&r.left+1<=e.clientX&&e.clientX<=r.right-1}const Rt="base-ui-disable-scrollbar",Rr={className:Rt,getElement(e){return t.jsx("style",{nonce:e,href:Rt,precedence:"base-ui:low",children:`.${Rt}{scrollbar-width:none}.${Rt}::-webkit-scrollbar{display:none}`})}};function gs(e,r=Number.MIN_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,a))}const ms=n.createContext(void 0),hs={disableStyleElements:!1};function ps(){return n.useContext(ms)??hs}const xs={...Dr,...sr},fn=n.forwardRef(function(r,a){const{render:o,className:d,...i}=r,{store:c,popupRef:l,onOpenChangeComplete:x,setOpen:k,valueRef:u,selectedItemTextRef:g,keyboardActiveRef:y,multiple:v,handleScrollArrowVisibility:S,scrollHandlerRef:w,highlightItemOnHover:C}=rt(),{side:f,align:R,alignItemWithTriggerActive:b,setControlledAlignItemWithTrigger:j,scrollDownArrowRef:A,scrollUpArrowRef:O}=ds(),$=Sa()!=null,_=Xr(),{nonce:q,disableStyleElements:pe}=ps(),J=at(),ae=W(c,B.id),X=W(c,B.open),ue=W(c,B.mounted),Y=W(c,B.popupProps),U=W(c,B.transitionStatus),se=W(c,B.triggerElement),P=W(c,B.positionerElement),H=W(c,B.listElement),I=n.useRef(0),N=n.useRef(!1),fe=n.useRef(0),L=n.useRef(!1),le=n.useRef({}),Q=Tn(),T=Ce(V=>{if(!P||!l.current||!L.current)return;if(N.current||!b){S();return}const ye=P.style.top==="0px",Z=P.style.bottom==="0px",ge=P.getBoundingClientRect().height,we=Yt(P),be=getComputedStyle(P),K=parseFloat(be.marginTop),ee=parseFloat(be.marginBottom),ve=Ir(getComputedStyle(l.current)),oe=we.documentElement.clientHeight-K-ee,ie=V.scrollTop,Me=V.scrollHeight,ce=V.clientHeight,h=Me-ce;let D=0,M=null,te=!1;if(ye){const re=h-ie,me=ge+re,Ne=Math.min(me,oe);D=Ne,Ne!==oe?M=h:te=!0}else if(Z){const re=ie-0,me=ge+re,Ne=Math.min(me,oe),Se=me-oe;D=Ne,Ne!==oe?M=0:(te=!0,ie<h&&(M=ie-(re-Se)))}D!==0&&(P.style.height=`${D}px`),M!=null&&(V.scrollTop=M),(te||D>=ve)&&(N.current=!0),S()});n.useImperativeHandle(w,()=>T,[T]),At({open:X,ref:l,onComplete(){X&&x?.(!0)}});const z=n.useMemo(()=>({open:X,transitionStatus:U,side:f,align:R}),[X,U,f,R]);ne(()=>{!P||!l.current||Object.keys(le.current).length||(le.current={top:P.style.top||"0",left:P.style.left||"0",right:P.style.right,height:P.style.height,bottom:P.style.bottom,minHeight:P.style.minHeight,maxHeight:P.style.maxHeight,marginTop:P.style.marginTop,marginBottom:P.style.marginBottom})},[l,P]),ne(()=>{X||b||(L.current=!1,N.current=!1,I.current=0,fe.current=0,Tt(P,le.current))},[X,b,P,l]),ne(()=>{const V=l.current;if(!(!X||!se||!P||!V||c.state.transitionStatus==="ending")){if(!b){L.current=!0,Q.request(S),V.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const ye=bs(V);V.style.removeProperty("--transform-origin");try{const Z=getComputedStyle(P),ge=getComputedStyle(V),we=Yt(se),be=hr(P),K=se.getBoundingClientRect(),ee=P.getBoundingClientRect(),ve=K.left,oe=K.height,ie=H||V,Me=ie.scrollHeight,ce=parseFloat(ge.borderBottomWidth),h=parseFloat(Z.marginTop)||10,D=parseFloat(Z.marginBottom)||10,M=parseFloat(Z.minHeight)||100,te=Ir(ge),re=5,me=5,Ne=20,Se=we.documentElement.clientHeight-h-D,Fe=we.documentElement.clientWidth,Re=Se-K.bottom+oe,je=g.current,Ee=u.current;let Te,Ve=0,_e=0;if(je&&Ee){const F=Ee.getBoundingClientRect();Te=je.getBoundingClientRect();const he=F.left-ve,s=Te.left-ee.left,p=F.top-K.top+F.height/2,E=Te.top-ee.top+Te.height/2;Ve=he-s,_e=E-p}const Be=Re+_e+D+ce;let ze=Math.min(Se,Be);const gt=Se-h-D,Pe=Be-ze,Je=Math.max(re,ve+Ve),it=Fe-me,nt=Math.max(0,Je+ee.width-it);P.style.left=`${Je-nt}px`,P.style.height=`${ze}px`,P.style.maxHeight="auto",P.style.marginTop=`${h}px`,P.style.marginBottom=`${D}px`,V.style.height="100%";const lt=ie.scrollHeight-ie.clientHeight,Ge=Pe>=lt;Ge&&(ze=Math.min(Se,ee.height)-(Pe-lt));const mt=K.top<Ne||K.bottom>Se-Ne||ze<Math.min(Me,M),ht=(be.visualViewport?.scale??1)!==1&&Pn;if(mt||ht){L.current=!0,Tt(P,le.current),Ar.flushSync(()=>j(!1));return}if(Ge){const F=Math.max(0,Se-Be);P.style.top=ee.height>=gt?"0":`${F}px`,P.style.height=`${ze}px`,ie.scrollTop=ie.scrollHeight-ie.clientHeight,I.current=Math.max(M,ze)}else P.style.bottom="0",I.current=Math.max(M,ze),ie.scrollTop=Pe;if(Te){const F=ee.top,he=ee.height,s=Te.top+Te.height/2,p=he>0?(s-F)/he*100:50,E=gs(p,0,100);V.style.setProperty("--transform-origin",`50% ${E}%`)}(I.current===Se||ze>=te)&&(N.current=!0),S(),setTimeout(()=>{L.current=!0})}finally{ye()}})}},[c,X,P,se,u,g,l,S,b,j,Q,A,O,H]),n.useEffect(()=>{if(!b||!P||!X)return;const V=hr(P);function ye(Z){k(!1,Ue(_n,Z))}return V.addEventListener("resize",ye),()=>{V.removeEventListener("resize",ye)}},[k,b,P,X]);const xe={...H?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":v||void 0,id:`${ae}-list`},onKeyDown(V){y.current=!0,$&&ga.has(V.key)&&V.stopPropagation()},onMouseMove(){y.current=!1},onPointerLeave(V){if(!C||un(V)||V.pointerType==="touch")return;const ye=V.currentTarget;J.start(0,()=>{c.set("activeIndex",null),ye.focus({preventScroll:!0})})},onScroll(V){H||w.current?.(V.currentTarget)},...b&&{style:H?{height:"100%"}:us}},ke=qe("div",r,{ref:[a,l],state:z,stateAttributesMapping:xs,props:[Y,xe,Ca(U),{className:!H&&b?Rr.className:void 0},i]});return t.jsxs(n.Fragment,{children:[!pe&&Rr.getElement(q),t.jsx(fa,{context:_,modal:!1,disabled:!ue,restoreFocus:!0,children:ke})]})});function Ir(e){const r=e.maxHeight||"";return r.endsWith("px")&&parseFloat(r)||1/0}const Mr={transform:"none",scale:"1",translate:"0 0"};function ys(e,r,a){a?e.setProperty(r,a):e.removeProperty(r)}function bs(e){const{style:r}=e,a={},o=Object.keys(Mr);for(const d of o)a[d]=r.getPropertyValue(d),r.setProperty(d,Mr[d]);return()=>{for(const d of o)ys(r,d,a[d])}}let gn=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function ks(e={}){const{label:r,metadata:a,textRef:o,indexGuessBehavior:d,index:i}=e,{register:c,unregister:l,subscribeMapChange:x,elementsRef:k,labelsRef:u,nextIndexRef:g}=ss(),y=n.useRef(-1),[v,S]=n.useState(i??(d===gn.GuessFromOrder?()=>{if(y.current===-1){const f=g.current;g.current+=1,y.current=f}return y.current}:-1)),w=n.useRef(null),C=n.useCallback(f=>{if(w.current=f,v!==-1&&f!==null&&(k.current[v]=f,u)){const R=r!==void 0;u.current[v]=R?r:o?.current?.textContent??f.textContent}},[v,k,u,r,o]);return ne(()=>{if(i!=null)return;const f=w.current;if(f)return c(f,a),()=>{l(f)}},[i,c,l,a]),ne(()=>{if(i==null)return x(f=>{const R=w.current?f.get(w.current)?.index:null;R!=null&&S(R)})},[i,x,S]),n.useMemo(()=>({ref:C,index:v}),[v,C])}const mn=n.createContext(void 0);function fr(){const e=n.useContext(mn);if(!e)throw new Error(ot(57));return e}const Pt=n.memo(n.forwardRef(function(r,a){const{render:o,className:d,value:i=null,label:c,disabled:l=!1,nativeButton:x=!1,...k}=r,u=n.useRef(null),g=ks({label:c,textRef:u,indexGuessBehavior:gn.GuessFromOrder}),{store:y,getItemProps:v,setOpen:S,setValue:w,selectionRef:C,typingRef:f,valuesRef:R,keyboardActiveRef:b,multiple:j,highlightItemOnHover:A}=rt(),O=at(),$=W(y,B.isActive,g.index),_=W(y,B.isSelected,g.index,i),q=W(y,B.isSelectedByFocus,g.index),pe=W(y,B.isItemEqualToValue),J=g.index,ae=J!==-1,X=n.useRef(null),ue=Qe(J);ne(()=>{if(!ae)return;const T=R.current;return T[J]=i,()=>{delete T[J]}},[ae,J,i,R]),ne(()=>{if(!ae)return;const T=y.state.value;let z=T;j&&Array.isArray(T)&&T.length>0&&(z=T[T.length-1]),z!==void 0&&ft(z,i,pe)&&y.set("selectedIndex",J)},[ae,J,j,pe,y,i]);const Y=n.useMemo(()=>({disabled:l,selected:_,highlighted:$}),[l,_,$]),U=v({active:$,selected:_});U.onFocus=void 0,U.id=void 0;const se=n.useRef(null),P=n.useRef("mouse"),H=n.useRef(!1),{getButtonProps:I,buttonRef:N}=ar({disabled:l,focusableWhenDisabled:!0,native:x});function fe(T){const z=y.state.value;if(j){const xe=Array.isArray(z)?z:[],ke=_?Ga(xe,i,pe):[...xe,i];w(ke,Ue(Bt,T))}else w(i,Ue(Bt,T)),S(!1,Ue(Bt,T))}const L={role:"option","aria-selected":_,tabIndex:$?0:-1,onFocus(){y.set("activeIndex",J)},onMouseEnter(){!b.current&&y.state.selectedIndex===null&&y.set("activeIndex",J)},onMouseMove(){A&&y.set("activeIndex",J)},onMouseLeave(T){!A||b.current||un(T)||O.start(0,()=>{y.state.activeIndex===J&&y.set("activeIndex",null)})},onTouchStart(){C.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(T){se.current=T.key,y.set("activeIndex",J)},onClick(T){H.current=!1,!(T.type==="keydown"&&se.current===null)&&(l||se.current===" "&&f.current||P.current!=="touch"&&!$||(se.current=null,fe(T.nativeEvent)))},onPointerEnter(T){P.current=T.pointerType},onPointerDown(T){P.current=T.pointerType,H.current=!0},onMouseUp(T){if(l)return;if(H.current){H.current=!1;return}const z=!C.current.allowSelectedMouseUp&&_,xe=!C.current.allowUnselectedMouseUp&&!_;z||xe||P.current!=="touch"&&!$||fe(T.nativeEvent)}},le=qe("div",r,{ref:[N,a,g.ref,X],state:Y,props:[U,L,k,I]}),Q=n.useMemo(()=>({selected:_,indexRef:ue,textRef:u,selectedByFocus:q,hasRegistered:ae}),[_,ue,u,q,ae]);return t.jsx(mn.Provider,{value:Q,children:le})})),_t=n.forwardRef(function(r,a){const o=r.keepMounted??!1,{selected:d}=fr();return o||d?t.jsx(ws,{...r,ref:a}):null}),ws=n.memo(n.forwardRef((e,r)=>{const{render:a,className:o,keepMounted:d,...i}=e,{selected:c}=fr(),l=n.useRef(null),{transitionStatus:x,setMounted:k}=or(c),u=n.useMemo(()=>({selected:c,transitionStatus:x}),[c,x]),g=qe("span",e,{ref:[r,l],state:u,props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:sr});return At({open:c,ref:l,onComplete(){c||k(!1)}}),g})),Ot=n.memo(n.forwardRef(function(r,a){const{indexRef:o,textRef:d,selectedByFocus:i,hasRegistered:c}=fr(),{selectedItemTextRef:l}=rt(),{className:x,render:k,...u}=r,g=n.useCallback(v=>{if(!v||!c)return;const S=l.current===null||!l.current.isConnected;(i||S&&o.current===0)&&(l.current=v)},[l,o,i,c]);return qe("div",r,{ref:[g,a,d],props:u})})),vs=n.forwardRef(function(r,a){const{render:o,className:d,id:i,...c}=r,{store:l}=ma(),x=Et(i);return l.useSyncedValueWithCleanup("descriptionElementId",x),qe("p",r,{ref:a,props:[{id:x},c]})});function Er({open:e,title:r,description:a,confirmLabel:o,cancelLabel:d,destructive:i=!1,busy:c=!1,onConfirm:l,onCancel:x}){return t.jsx(ha,{open:e,onOpenChange:k=>{!k&&!c&&x?.()},children:t.jsxs(pa,{children:[t.jsx(xa,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),t.jsx(ya,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:t.jsxs(ba,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[t.jsx(ka,{className:"text-base font-semibold text-oai-black dark:text-white",children:r}),a?t.jsx(vs,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a}):null,t.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[t.jsx(He,{type:"button",variant:"secondary",size:"sm",disabled:c,onClick:()=>x?.(),children:d}),t.jsx(He,{type:"button",size:"sm",disabled:c,onClick:()=>l?.(),className:Ye(i&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:o})]})]})})]})})}function hn({id:e,value:r,onChange:a,placeholder:o,disabled:d=!1,type:i="text",label:c,error:l,className:x="",...k}){const u=n.useId(),g=e||u,y=l?`${g}-error`:void 0,C=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${d?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${l?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${x}`;return t.jsxs("div",{className:"w-full",children:[c&&t.jsx("label",{htmlFor:g,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:c}),t.jsx("input",{id:g,type:i,value:r,onChange:a,placeholder:o,disabled:d,"aria-invalid":l?!0:void 0,"aria-describedby":y,className:C,...k}),l&&t.jsx("p",{id:y,className:"mt-1.5 text-sm text-oai-error",children:l})]})}const js="tt:hint:dismissed:";function pn(e){return js+e}function Ns(e){if(typeof window>"u")return!1;try{return window.localStorage.getItem(pn(e))==="1"}catch{return!1}}function Ss({id:e,children:r,className:a,ariaLabel:o}){const[d,i]=n.useState(()=>Ns(e)),c=n.useCallback(()=>{if(typeof window<"u")try{window.localStorage.setItem(pn(e),"1")}catch{}i(!0)},[e]);return d?null:t.jsxs("div",{role:"note","aria-label":o||m("hint.dismissible_aria"),className:Ye("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",a),children:[t.jsx("button",{type:"button",onClick:c,"aria-label":m("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:t.jsx(vt,{className:"h-4 w-4","aria-hidden":"true"})}),t.jsxs("div",{className:"flex items-start gap-2 pr-8",children:[t.jsx(Ur,{className:"mt-0.5 h-4 w-4 shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":"true"}),t.jsx("div",{className:"min-w-0 flex-1",children:r})]})]})}let Tr=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});function xn(e){return n.useMemo(()=>({checked(r){return e.indeterminate?{}:r?{[Tr.checked]:""}:{[Tr.unchecked]:""}},...cr}),[e.indeterminate])}const Cs=n.createContext({disabled:!1});function Rs(){return n.useContext(Cs)}const Is=n.createContext(void 0);function Ms(e=!0){const r=n.useContext(Is);if(r===void 0&&!e)throw new Error(ot(3));return r}const yn=n.createContext(void 0);function Es(){const e=n.useContext(yn);if(e===void 0)throw new Error(ot(14));return e}const Ts="data-parent",Ps=n.forwardRef(function(r,a){const{checked:o,className:d,defaultChecked:i=!1,disabled:c=!1,id:l,indeterminate:x=!1,inputRef:k,name:u,onCheckedChange:g,parent:y=!1,readOnly:v=!1,render:S,required:w=!1,uncheckedValue:C,value:f,nativeButton:R=!1,...b}=r,{clearErrors:j}=ur(),{disabled:A,name:O,setDirty:$,setFilled:_,setFocused:q,setTouched:pe,state:J,validationMode:ae,validityData:X,shouldValidateOnChange:ue,validation:Y}=Dt(),U=Rs(),{labelId:se,controlId:P,setControlId:H,getDescriptionProps:I}=dr(),N=Ms(),fe=N?.parent,L=fe&&N.allValues,le=A||U.disabled||N?.disabled||c,Q=O??u,T=f??Q,z=Et(),xe=Et();let ke=P;L?ke=y?xe:`${fe.id}-${T}`:l&&(ke=l);let V={};L&&(y?V=N.parent.getParentProps():T&&(V=N.parent.getChildProps(T)));const ye=Ce(g),{checked:Z=o,indeterminate:ge=x,onCheckedChange:we,...be}=V,K=N?.value,ee=N?.setValue,ve=N?.defaultValue,oe=n.useRef(null),{getButtonProps:ie,buttonRef:Me}=ar({disabled:le,native:R}),ce=N?.validation??Y,[h,D]=Qt({controlled:T&&K&&!y?K.includes(T):Z,default:T&&ve&&!y?ve.includes(T):i,name:"Checkbox",state:"checked"});ne(()=>{if(H!==We)return H(ke),()=>{H(void 0)}},[ke,N,H,y]),en({enabled:!N,id:z,commit:ce.commit,value:h,controlRef:oe,name:Q,getValue:()=>h});const M=n.useRef(null),te=nr(k,M,ce.inputRef);ne(()=>{M.current&&(M.current.indeterminate=ge,h&&_(!0))},[h,ge,_]),tn(h,()=>{N&&!y||(j(Q),_(h),$(h!==X.initialValue),ue()?ce.commit(h):ce.commit(h,!0))});const re=rr({checked:h,disabled:le,name:y?void 0:Q,id:R?void 0:ke??void 0,required:w,ref:te,style:Q?Lr:Vr,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(je){if(je.nativeEvent.defaultPrevented)return;const Ee=je.target.checked,Te=Ue(Lt,je.nativeEvent);if(we?.(Ee,Te),ye(Ee,Te),!Te.isCanceled&&(D(Ee),T&&K&&ee&&!y)){const Ve=Ee?[...K,T]:K.filter(_e=>_e!==T);ee(Ve,Te)}},onFocus(){oe.current?.focus()}},f!==void 0?{value:(N?h&&f:f)||""}:Mt,I,N?ce.getValidationProps:ce.getInputValidationProps),me=L?!!Z:h,Ne=L&&ge||x;n.useEffect(()=>{fe&&T&&fe.disabledStatesRef.current.set(T,le)},[fe,le,T]);const Se=n.useMemo(()=>({...J,checked:me,disabled:le,readOnly:v,required:w,indeterminate:Ne}),[J,me,le,v,w,Ne]),Fe=xn(Se),Re=qe("span",r,{state:Se,ref:[Me,oe,a,N?.registerControlRef],props:[{id:R?ke??void 0:z,role:"checkbox","aria-checked":ge?"mixed":h,"aria-readonly":v||void 0,"aria-required":w||void 0,"aria-labelledby":se,[Ts]:y?"":void 0,onFocus(){q(!0)},onBlur(){const je=M.current;je&&(pe(!0),q(!1),ae==="onBlur"&&ce.commit(N?K:je.checked))},onClick(je){v||le||(je.preventDefault(),M.current?.click())}},I,ce.getValidationProps,b,be,ie],stateAttributesMapping:Fe});return t.jsxs(yn.Provider,{value:Se,children:[Re,!h&&!N&&Q&&!y&&C!==void 0&&t.jsx("input",{type:"hidden",name:Q,value:C}),t.jsx("input",{...re})]})}),_s=n.forwardRef(function(r,a){const{render:o,className:d,keepMounted:i=!1,...c}=r,l=Es(),x=l.checked||l.indeterminate,{transitionStatus:k,setMounted:u}=or(x),g=n.useRef(null),y=n.useMemo(()=>({...l,transitionStatus:k}),[l,k]);At({open:x,ref:g,onComplete(){x||u(!1)}});const v=xn(l),S=n.useMemo(()=>({...v,...sr,...cr}),[v]),w=i||x,C=qe("span",r,{enabled:w,ref:[a,g],state:y,stateAttributesMapping:S,props:c});return w?C:null});function Os(e,r){return`target:${e}:${r}`}function As(e){return`remove:${e.id||e.directory}`}function bn(e){if(!e)return null;const r=new Date(e).getTime();return Number.isFinite(r)?Math.floor((Date.now()-r)/864e5):null}function Ls(e){const r=bn(e);if(r==null)return null;if(r<=0)return m("skills.usage.today");if(r<30)return m("skills.usage.days_ago",{days:r});const a=Math.max(1,Math.floor(r/30));return m("skills.usage.months_ago",{months:a})}function Vs(e){const r=bn(e);return r==null?"bg-oai-gray-300 dark:bg-oai-gray-600":r<=7?"bg-emerald-500":r<=30?"bg-amber-500":"bg-oai-gray-300 dark:bg-oai-gray-600"}function Kt({label:e,children:r}){return t.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 text-sm",children:[t.jsx("dt",{className:"flex items-center gap-1 text-oai-gray-500 dark:text-oai-gray-400",children:e}),t.jsx("dd",{className:"text-right font-medium tabular-nums text-oai-black dark:text-white",children:r})]})}function Ds({skill:e,targets:r,busyKey:a,usage:o,hasUpdate:d,updating:i,onUpdate:c,onClose:l,onToggleTarget:x,onRemove:k}){return t.jsx(On,{children:e?t.jsx(Us,{skill:e,targets:r,busyKey:a,usage:o,hasUpdate:d,updating:i,onUpdate:c,onClose:l,onToggleTarget:x,onRemove:k},e.id||e.directory):null})}function Us({skill:e,targets:r,busyKey:a,usage:o,hasUpdate:d,updating:i,onUpdate:c,onClose:l,onToggleTarget:x,onRemove:k}){const u=An(),{currency:g,rate:y}=wa(),v=n.useRef(null);n.useEffect(()=>{const O=_=>{_.key==="Escape"&&(_.stopPropagation(),l?.())},$=_=>{const q=_.target;q instanceof Element&&(v.current?.contains(q)||q.closest('[data-skill-row="1"]')||l?.())};return document.addEventListener("keydown",O),document.addEventListener("mousedown",$),()=>{document.removeEventListener("keydown",O),document.removeEventListener("mousedown",$)}},[l]);const S=e.name||e.directory,w=!!(e.repoOwner&&e.repoName),C=w?`https://github.com/${e.repoOwner}/${e.repoName}`:null,f=new Set(e.targets||[]),R=a===As(e),b=Ls(o?.lastUsedAt),j=!!(o&&o.invocations>0),A=u?{duration:0}:{type:"spring",stiffness:320,damping:30,mass:.7};return t.jsxs(t.Fragment,{children:[t.jsx(pr.div,{className:"fixed inset-0 z-20 bg-oai-black/30 backdrop-blur-[2px] lg:hidden",initial:u?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:u?0:.15},onClick:l,"aria-hidden":!0}),t.jsxs(pr.aside,{ref:v,role:"complementary","aria-label":S,initial:u?!1:{opacity:0,x:24,scale:.98},animate:{opacity:1,x:0,scale:1},exit:u?{opacity:0}:{opacity:0,x:24,scale:.98},transition:A,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:[t.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:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",title:S,children:S}),w?t.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:[t.jsxs("span",{className:"truncate",children:[e.repoOwner,"/",e.repoName]}),t.jsx(Xt,{className:"h-3 w-3 shrink-0","aria-hidden":!0})]}):e.directory&&e.directory!==S?t.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",title:e.directory,children:e.directory}):null]}),t.jsx("button",{type:"button",onClick:l,"aria-label":m("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:t.jsx(vt,{className:"h-4 w-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5",children:[d?t.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:[t.jsx(Wr,{className:"h-4 w-4 shrink-0 text-sky-600 dark:text-sky-300","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 text-xs text-sky-800 dark:text-sky-200",children:m("skills.update.available")}),t.jsxs("button",{type:"button",onClick:()=>c?.(e),disabled:i,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:[i?t.jsx(Xe,{className:"h-3 w-3 animate-spin","aria-hidden":!0}):null,m("skills.update.action")]})]}):null,e.description?t.jsx("p",{className:"text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:e.description}):null,t.jsxs("section",{className:"mt-6",children:[t.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:m("skills.usage.section_title")}),t.jsxs("dl",{className:"divide-y divide-oai-gray-200/60 dark:divide-white/[0.06]",children:[t.jsx(Kt,{label:m("skills.usage.invocations"),children:Ln(o?.invocations||0)}),t.jsx(Kt,{label:m("skills.usage.last_used"),children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:Ye("h-1.5 w-1.5 rounded-full",Vs(o?.lastUsedAt)),"aria-hidden":!0}),j?b||m("skills.usage.unknown"):m("skills.usage.never")]})}),t.jsx(Kt,{label:t.jsxs(t.Fragment,{children:[m("skills.usage.cost"),t.jsx("span",{title:m("skills.usage.disclaimer"),className:"inline-flex cursor-help text-oai-gray-400 dark:text-oai-gray-500",children:t.jsx(Ur,{className:"h-3 w-3","aria-label":m("skills.usage.disclaimer")})})]}),children:Vn(o?.cost||0,{currency:g,rate:y})})]}),j?null:t.jsx("p",{className:"mt-2 text-[11px] leading-4 text-oai-gray-400 dark:text-oai-gray-500",children:m("skills.usage.unused")})]}),t.jsxs("section",{className:"mt-6",children:[t.jsx("h3",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-400",children:m("skills.detail.sync_section_title")}),t.jsx("div",{children:(r||[]).map(O=>{const $=f.has(O.id),_=a===Os(e.id,O.id),q=`skill-detail-sync-${e.id||e.directory}-${O.id}`;return t.jsxs("label",{htmlFor:q,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:[t.jsx(Ps,{id:q,checked:$,disabled:_,onCheckedChange:pe=>x?.(e,O.id,!!pe),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:t.jsx(_s,{className:"flex items-center justify-center text-white dark:text-oai-black",children:t.jsx(ut,{className:"h-3 w-3",strokeWidth:3.5,"aria-hidden":!0})})}),t.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center","aria-hidden":!0,children:t.jsx(st,{provider:O.id,size:16})}),t.jsx("span",{className:"flex-1",children:O.label}),_?t.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin text-oai-gray-400","aria-hidden":!0}):null]},O.id)})})]})]}),t.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:[t.jsxs("button",{type:"button",onClick:()=>k?.(e),disabled:R,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:[R?t.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):t.jsx(lr,{className:"h-3.5 w-3.5","aria-hidden":!0}),m("skills.detail.remove_button")]}),t.jsx("p",{className:"mt-2 text-center text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:m("skills.detail.remove_confirm_hint")})]})]})]})}const Fs=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Wt=["claude","codex"],$e="popular",Bs={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"},Ze="all",De="skillssh";function er(e){return`${e.repoOwner||"local"}/${e.repoName||"local"}:${e.directory}`}function It(e){return`install:${er(e)}`}function Pr(e){return`remove:${e.id||e.directory}`}function kn(e,r){return`target:${e}:${r}`}function $s({target:e,state:r,busy:a,onToggle:o}){const d=r==="synced",i=r==="orphan",c=i?m("skills.dot.orphan_aria",{agent:e.label}):d?m("skills.dot.synced_aria",{agent:e.label}):m("skills.dot.off_aria",{agent:e.label});return t.jsxs("button",{type:"button",title:c,"aria-label":c,"aria-pressed":d,disabled:a,onClick:l=>{l.stopPropagation(),o?.(e.id,!d)},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:[a?t.jsx(Xe,{className:"h-4 w-4 animate-spin text-oai-gray-400","aria-hidden":!0}):t.jsx("span",{className:Ye("flex h-[18px] w-[18px] items-center justify-center transition",d&&Bs[e.id],!d&&!i&&"opacity-35 grayscale"),"aria-hidden":!0,children:t.jsx(st,{provider:e.id,size:18})}),i&&!a?t.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 Hs({skill:e,targets:r,onToggleTarget:a,busyKey:o}){return t.jsx("div",{className:"flex items-center gap-1",onClick:d=>d.stopPropagation(),children:r.map(d=>t.jsx($s,{target:d,state:e.targetStates?.[d.id]||"off",busy:o===kn(e.id,d.id),onToggle:(i,c)=>a?.(e,i,c)},d.id))})}function zs({skill:e,targets:r,selected:a,onSelect:o,selectable:d,checked:i,onToggleSelect:c,onToggleTarget:l,hasUpdate:x,busyKey:k}){const u=e.repoOwner&&e.repoName?`${e.repoOwner}/${e.repoName}`:null,g=u?`${e.directory} · ${u}`:e.directory,y=v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),o?.(e))};return t.jsxs("div",{"data-skill-row":"1",role:"button",tabIndex:0,"aria-pressed":a,"aria-label":m("skills.row.open_details",{name:e.name||e.directory}),onClick:()=>o?.(e),onKeyDown:y,className:Ye("cursor-pointer rounded-md py-3 pr-2 transition focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30",a?"bg-oai-gray-100 ring-1 ring-oai-gray-200 dark:bg-oai-gray-800/60 dark:ring-oai-gray-800":i?"bg-oai-gray-50 dark:bg-oai-gray-900/40":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[d?t.jsx("label",{className:"flex shrink-0 items-center",onClick:v=>v.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:i,onChange:v=>c?.(e,v.target.checked),"aria-label":m("skills.select.row_aria",{name:e.name||e.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,t.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-oai-black dark:text-white",title:g,children:e.name||e.directory}),x?t.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:[t.jsx(Wr,{className:"h-2.5 w-2.5","aria-hidden":!0}),m("skills.update.badge")]}):null,t.jsx(Hs,{skill:e,targets:r,onToggleTarget:l,busyKey:k}),t.jsx(Ra,{className:Ye("hidden h-4 w-4 shrink-0 text-oai-gray-300 transition-colors dark:text-oai-gray-600 lg:block",a&&"text-oai-gray-500 dark:text-oai-gray-300"),"aria-hidden":!0})]}),e.description?t.jsx("p",{className:Ye("mt-1 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",d&&"pl-7"),children:e.description}):null]})}function Ks({agentFilter:e,agentOptions:r,onAgentFilter:a,filteredCount:o,totalCount:d,anyFilter:i,onClearFilters:c}){return t.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:[t.jsxs(rn,{value:e,onValueChange:a,children:[t.jsxs(nn,{"aria-label":m("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:[t.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:[m("skills.filter.agent_label"),":"]}),t.jsx(an,{children:l=>l==="all"?m("skills.filter.agent_all"):r.find(x=>x.id===l)?.label||l}),t.jsx(sn,{className:"text-oai-gray-400",children:t.jsx(ir,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),t.jsx(on,{children:t.jsx(dn,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:t.jsxs(fn,{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:[t.jsxs(Pt,{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:[t.jsx(Ot,{children:m("skills.filter.agent_all")}),t.jsx(_t,{children:t.jsx(ut,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),r.map(l=>t.jsxs(Pt,{value:l.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(st,{provider:l.id,size:14}),t.jsx(Ot,{children:l.label})]}),t.jsx(_t,{children:t.jsx(ut,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},l.id))]})})})]}),t.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:m("skills.filter.result_count",{filtered:o,total:d})}),i?t.jsxs("button",{type:"button",onClick:c,className:"ml-auto inline-flex h-7 items-center gap-1 rounded-full bg-oai-gray-100 px-2.5 text-[11px] font-medium text-oai-gray-700 transition hover:bg-oai-gray-200 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 dark:bg-oai-gray-800/70 dark:text-oai-gray-200 dark:hover:bg-oai-gray-700",children:[t.jsx(vt,{className:"h-3 w-3","aria-hidden":!0}),m("skills.filter.clear")]}):null]})}function Ws({count:e,targets:r,busy:a,onBulkSync:o,onBulkRemove:d,onClear:i}){return t.jsxs("div",{role:"toolbar","aria-label":m("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:[t.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200","aria-live":"polite",children:m("skills.select.count",{count:e})}),t.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[t.jsxs(Fr,{children:[t.jsxs(Br,{disabled:a,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:[t.jsx(Kr,{className:"h-3.5 w-3.5","aria-hidden":!0}),m("skills.select.bulk_sync"),t.jsx(ir,{className:"h-3 w-3","aria-hidden":!0})]}),t.jsx($r,{children:t.jsx(Hr,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:t.jsxs(zr,{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:[t.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:m("skills.select.bulk_sync_hint")}),r.map(c=>t.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:[t.jsx(st,{provider:c.id,size:16}),t.jsx("span",{className:"flex-1",children:c.label})]},c.id))]})})})]}),t.jsxs(He,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:d,children:[t.jsx(lr,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),m("skills.select.bulk_remove")]}),t.jsxs("button",{type:"button",onClick:i,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:[t.jsx(vt,{className:"h-3 w-3","aria-hidden":!0}),m("skills.select.clear")]})]})]})}function qs({items:e,totalCount:r,targets:a,agentOptions:o,agentFilter:d,onAgentFilter:i,anyFilter:c,onClearFilters:l,selectedId:x,onSelect:k,onToggleTarget:u,busyKey:g,updates:y,selectedIds:v,onToggleSelect:S,onClearSelection:w,onBulkSync:C,onBulkRemove:f}){const R=v.size;return t.jsxs("div",{children:[R>0?t.jsx(Ws,{count:R,targets:a,busy:g==="batch",onBulkSync:C,onBulkRemove:f,onClear:w}):t.jsx(Ks,{agentFilter:d,agentOptions:o,onAgentFilter:i,filteredCount:e.length,totalCount:r,anyFilter:c,onClearFilters:l}),e.length===0?t.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:[t.jsx("p",{children:m("skills.empty.no_match")}),t.jsx(He,{type:"button",variant:"secondary",size:"sm",onClick:l,children:m("skills.filter.clear")})]}):t.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:e.map(b=>t.jsx(zs,{skill:b,targets:a,selected:x===(b.id||b.directory),onSelect:k,selectable:!0,checked:v.has(b.id),onToggleSelect:S,onToggleTarget:u,hasUpdate:!!(b.id&&y?.[b.id]),busyKey:g},b.id||b.key))})]})}const Gs={contentVisibility:"auto",containIntrinsicSize:"0 240px"},Ys=Wn.memo(function({skill:r,installed:a,installing:o,allTargets:d,defaultTargets:i,onInstall:c,onManage:l}){const[x,k]=n.useState(()=>(i||[]).filter(w=>d.some(C=>C.id===w))),u=w=>{k(C=>C.includes(w)?C.filter(f=>f!==w):[...C,w])},g=r.repoOwner&&r.repoName?`${r.repoOwner}/${r.repoName}`:null,y=g?`https://github.com/${r.repoOwner}/${r.repoName}`:null,v=r.installs!=null?m("skills.card.installs",{count:Number(r.installs||0).toLocaleString()}):null,S=x.length?x.map(w=>d.find(C=>C.id===w)?.label||w).join(", "):m("skills.action.choose_targets");return t.jsxs(Jn,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[t.jsx("div",{className:"flex items-start justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[r.readmeUrl?t.jsxs("a",{href:r.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:r.readmeUrl,children:[t.jsx("span",{className:"truncate",children:r.name||r.directory}),t.jsx(Xt,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):t.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:r.name||r.directory}),g||v?t.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:[y?t.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",onClick:w=>w.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:y,children:[t.jsx("span",{className:"truncate",children:g}),t.jsx(Xt,{className:"h-2.5 w-2.5 shrink-0","aria-hidden":!0})]}):null,g&&v?t.jsx("span",{"aria-hidden":!0,children:"·"}):null,v?t.jsx("span",{className:"truncate",children:v}):null]}):null]})}),r.description?t.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:r.description}):null,t.jsx("div",{className:"mt-auto pt-5",children:a?t.jsxs(He,{type:"button",variant:"secondary",size:"sm",onClick:()=>l?.(r),className:"w-full",children:[t.jsx(ut,{className:"mr-1.5 h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400","aria-hidden":!0}),m("skills.card.manage")]}):t.jsxs("div",{className:"space-y-2",children:[t.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:[t.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:m("skills.card.targets_prefix")}),t.jsx("span",{className:"min-w-0 truncate font-medium text-oai-black dark:text-white",children:x.length?S:m("skills.target.none")}),t.jsxs(Fr,{children:[t.jsx(Br,{disabled:o,"aria-label":m("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:m("skills.card.targets_change")}),t.jsx($r,{children:t.jsx(Hr,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:t.jsxs(zr,{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:[t.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:m("skills.target.menu_label")}),d.map(w=>{const C=x.includes(w.id);return t.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:[t.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:()=>u(w.id)}),t.jsx(st,{provider:w.id,size:16}),t.jsx("span",{className:"flex-1 text-left",children:w.label})]},w.id)})]})})})]})]}),t.jsxs(He,{type:"button",size:"sm",onClick:()=>c(r,x),disabled:o||x.length===0,className:"w-full",children:[o?t.jsx(Xe,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):t.jsx(Kr,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),m("skills.action.install")]})]})})]})});function Xs({repos:e,repoInput:r,onRepoInput:a,busyKey:o,onAdd:d,onRemove:i}){return t.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:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[t.jsx(hn,{value:r,onChange:c=>a(c.target.value),placeholder:m("skills.repo.placeholder"),className:"min-w-0 flex-1"}),t.jsxs(He,{type:"button",variant:"secondary",size:"md",onClick:d,disabled:o==="repo:add",className:"shrink-0 whitespace-nowrap",children:[o==="repo:add"?t.jsx(Xe,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):t.jsx(qr,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),m("skills.repo.add")]})]}),e.length?t.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:e.map(c=>{const l=o===`repo:${c.owner}/${c.name}`;return t.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[c.owner,"/",c.name]}),t.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:c.branch})]}),t.jsxs(He,{type:"button",variant:"ghost",size:"sm",disabled:l,onClick:()=>i(c),className:"shrink-0",children:[l?t.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):t.jsx(lr,{className:"h-3.5 w-3.5","aria-hidden":!0}),t.jsx("span",{className:"sr-only",children:m("skills.repo.remove")})]})]},`${c.owner}/${c.name}`)})}):null]})}function Qs(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function co(){const[e,r]=n.useState(Qs),[a,o]=n.useState({skills:[],targets:[]}),[d,i]=n.useState([]),[c,l]=n.useState([]),[x,k]=n.useState([]),[u,g]=n.useState(Ze),[y,v]=n.useState(""),[S,w]=n.useState(""),[C,f]=n.useState(""),[R,b]=n.useState(!1),[j,A]=n.useState("all"),[O,$]=n.useState(null),[_,q]=n.useState(""),[pe,J]=n.useState(!0),[ae,X]=n.useState(!1),[ue,Y]=n.useState(""),[U,se]=n.useState(null),[P,H]=n.useState(null),[I,N]=n.useState(()=>new Set),[fe,L]=n.useState({}),[le,Q]=n.useState({}),[T,z]=n.useState([]),[xe,ke]=n.useState(!1),V=n.useRef(!1),ye=n.useMemo(()=>{const s=new Set;for(const p of a.skills||[]){s.add(er(p).toLowerCase()),p.repoOwner&&p.repoName&&s.add(`${p.repoOwner}/${p.repoName}:${p.sourceDirectory||p.directory}`.toLowerCase());const E=String(p.directory||"").split(/[\\/]/).pop().toLowerCase();E&&s.add(`dir:${E}`)}return s},[a.skills]),Z=n.useCallback(async()=>{const s=await Dn();o({skills:s.skills||[],targets:s.targets||[]})},[]),ge=n.useCallback(async()=>{const s=await Un();k(s.repos||[])},[]),we=n.useCallback(async({force:s=!1}={})=>{X(!0);try{const p=await Fn({force:s});i(p.skills||[])}finally{X(!1)}},[]),be=n.useCallback(async({force:s=!1}={})=>{ke(!0);try{const p=await Bn({force:s});z(p.skills||[])}finally{ke(!1)}},[]),K=n.useCallback(async()=>{try{const s=await $n();L(s?.updates||{})}catch{L({})}},[]),ee=n.useCallback(async()=>{try{const s=await Hn(),p={};for(const E of s?.skills||[])E.installed&&(E.directory&&(p[String(E.directory).toLowerCase()]=E),p[String(E.skill).toLowerCase()]=E);Q(p)}catch{Q({})}},[]),ve=n.useCallback(async()=>{J(!0),Y("");try{await Promise.all([Z(),ge()])}catch(s){Y(s?.message||m("skills.error.generic"))}finally{J(!1)}},[Z,ge]),oe=n.useCallback(async()=>{await ve();const s=p=>Y(p?.message||m("skills.error.generic"));e==="my"?(K(),ee()):u===$e?be({force:!0}).catch(s):u!==De&&we({force:!0}).catch(s)},[we,ve,be,K,ee,u,e]);n.useEffect(()=>{ve()},[ve]),n.useEffect(()=>{if(V.current||typeof window>"u")return;const s=new URLSearchParams(window.location.search),p=s.get("skill");if(!p){V.current=!0;return}const E=a.skills||[];if(!E.length)return;const G=E.find(Ie=>Ie.directory===p||Ie.id===p);G&&(r("my"),$(G.id||G.directory)),V.current=!0,s.delete("skill");const Oe=s.toString();window.history.replaceState({},"",`${window.location.pathname}${Oe?`?${Oe}`:""}${window.location.hash}`)},[a.skills]),n.useEffect(()=>{e==="browse"&&(u===De||u===$e||d.length===0&&we().catch(s=>Y(s?.message||m("skills.error.generic"))))},[d.length,we,u,e]),n.useEffect(()=>{e!=="browse"||u!==$e||T.length===0&&be().catch(s=>Y(s?.message||m("skills.error.generic")))},[be,T.length,u,e]);const ie=Object.keys(fe).length>0,Me=Object.keys(le).length>0;if(n.useEffect(()=>{e==="my"&&(ie||K(),Me||ee())},[e,ie,Me,K,ee]),n.useEffect(()=>{const s=setTimeout(()=>w(y),200);return()=>clearTimeout(s)},[y]),n.useEffect(()=>{if(typeof window>"u")return;const s=new URLSearchParams(window.location.search),p=s.get("tab");if(e==="my"){if(!p)return;s.delete("tab")}else{if(p===e)return;s.set("tab",e)}const E=s.toString(),G=`${window.location.pathname}${E?`?${E}`:""}${window.location.hash}`;window.history.replaceState({},"",G)},[e]),!Fs&&!zn())return t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx(Qn,{})});const ce=async(s,p)=>{q(s),Y("");try{await p(),await Z()}catch(E){Y(E?.message||m("skills.error.generic"))}finally{q("")}},h=(s,p)=>{const E=(p&&p.length?p:Wt).filter(G=>(a.targets||[]).some(Oe=>Oe.id===G));ce(It(s),async()=>{await yr(s,E);const G=E.map(Oe=>(a.targets||[]).find(Ie=>Ie.id===Oe)?.label||Oe).join(", ");ct({title:m("skills.toast.installed",{name:s.name||s.directory,targets:G||m("skills.target.none")}),timeout:4e3})})},D=s=>{se(s)},M=()=>{const s=U;s&&(se(null),ce(Pr(s),async()=>{let p=null;s.managed?p=await br(s.id):await kr(s.directory,s.targets||[]);const E=!!(p?.trashed&&s.managed&&s.id);ct({title:m("skills.toast.removed",{name:s.name||s.directory}),timeout:6e3,data:E?{onUndo:async()=>{try{await Gn(s.id),await Z()}catch(G){Y(G?.message||m("skills.error.generic"))}}}:void 0})}))},te=(s,p,E)=>ce(kn(s.id,p),async()=>{const G=new Set(s.targets||[]);E?G.add(p):G.delete(p),s.managed?await wr(s.id,Array.from(G)):await vr(s.directory,Array.from(G));const Oe={name:s.name||s.directory,agent:Ne(p)};ct({title:E?m("skills.toast.synced_one",Oe):m("skills.toast.unsynced_one",Oe),timeout:3e3})}),re=n.useCallback(()=>N(new Set),[]),me=n.useCallback((s,p)=>{N(E=>{const G=new Set(E);return p?G.add(s.id):G.delete(s.id),G})},[]),Ne=s=>(a.targets||[]).find(p=>p.id===s)?.label||s,Se=s=>{const p=(a.skills||[]).filter(E=>I.has(E.id));p.length&&ce("batch",async()=>{for(const E of p){const G=new Set(E.targets||[]);G.add(s),E.managed?await wr(E.id,Array.from(G)):await vr(E.directory,Array.from(G))}re(),ct({title:m("skills.toast.bulk_synced",{count:p.length,agent:Ne(s)}),timeout:4e3})})},Fe=()=>{const s=(a.skills||[]).filter(p=>I.has(p.id));s.length&&H(s)},Re=()=>{const s=P;s&&(H(null),ce("batch",async()=>{for(const p of s)p.managed?await br(p.id):await kr(p.directory,p.targets||[]);re(),ct({title:m("skills.toast.bulk_removed",{count:s.length}),timeout:4e3})}))},je=s=>{!s?.repoOwner||!s?.repoName||ce(It(s),async()=>{await yr({key:s.key,name:s.name,description:s.description,directory:s.sourceDirectory||s.directory,repoOwner:s.repoOwner,repoName:s.repoName,repoBranch:s.repoBranch,readmeUrl:s.readmeUrl},s.targets&&s.targets.length?s.targets:Wt),await K(),ct({title:m("skills.toast.updated",{name:s.name||s.directory}),timeout:4e3})})},Ee=async()=>{const s=y.trim();if(!(s.length<2)){q("search"),Y("");try{const p=await qn(s);l(p.skills||[])}catch(p){Y(p?.message||m("skills.error.generic"))}finally{q("")}}},Te=async()=>{const s=C.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[p,E]=s.split("/");if(!p||!E){Y(m("skills.repo.invalid"));return}await ce("repo:add",async()=>{await Xn({owner:p,name:E,branch:"main",enabled:!0}),f(""),await ge(),await we()})},Ve=async s=>{await ce(`repo:${s.owner}/${s.name}`,async()=>{await Yn(s.owner,s.name),await ge(),await we()})},_e=a.targets||[],Be=a.skills||[],ze=n.useMemo(()=>j==="all"?Be:Be.filter(s=>(s.targets||[]).includes(j)),[Be,j]),gt=j!=="all",Pe=n.useMemo(()=>O&&Be.find(s=>(s.id||s.directory)===O)||null,[Be,O]),Je=n.useCallback(()=>{A("all")},[]),it=n.useCallback(s=>{$(p=>{const E=s?.id||s?.directory||null;return p===E?null:E})},[]),nt=n.useCallback(()=>$(null),[]),lt=n.useCallback(s=>{const p=String(s.directory||"").split(/[\\/]/).pop().toLowerCase(),E=(a.skills||[]).find(G=>String(G.directory||"").toLowerCase()===p);E&&$(E.id||E.directory)},[a.skills]);n.useEffect(()=>{e!=="my"&&I.size&&N(new Set)},[e,I.size]),n.useEffect(()=>{O&&!Pe&&$(null)},[Pe,O]);const Ge=n.useMemo(()=>{const s=u===De?c:u===$e?T:d,E=u===De||u===$e||u===Ze?s:s.filter(Ie=>`${Ie.repoOwner}/${Ie.repoName}`===u),G=S.trim().toLowerCase();return(u===De||!G?E:E.filter(Ie=>(Ie.name||"").toLowerCase().includes(G)||(Ie.directory||"").toLowerCase().includes(G)||(Ie.description||"").toLowerCase().includes(G))).map(Ie=>{const Ut=er(Ie).toLowerCase(),Ke=String(Ie.directory||"").split(/[\\/]/).pop().toLowerCase(),jt=Ke?`dir:${Ke}`:"";return{...Ie,installed:ye.has(Ut)||jt&&ye.has(jt)}})},[S,d,ye,T,c,u]),mt=t.jsx("div",{className:"flex h-64 items-center justify-center",children:t.jsx(Xe,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),ht=t.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(Xe,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),t.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:m("skills.browse.loading_hint")})]}),F=(s,p=null)=>t.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:[t.jsx("p",{children:m(s)}),p]});let he;if(pe)he=mt;else if(e==="my")he=Be.length?t.jsx(qs,{items:ze,totalCount:Be.length,targets:_e,agentOptions:_e,agentFilter:j,onAgentFilter:A,anyFilter:gt,onClearFilters:Je,selectedId:O,onSelect:it,onToggleTarget:te,busyKey:_,updates:fe,selectedIds:I,onToggleSelect:me,onClearSelection:re,onBulkSync:Se,onBulkRemove:Fe}):t.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:[_e.length>0?t.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[t.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:t.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[..._e,..._e].map((s,p)=>t.jsx("span",{className:"shrink-0 px-3",children:t.jsx(st,{provider:s.id,size:30})},`b-${p}`))})}),t.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:t.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[..._e,..._e].map((s,p)=>t.jsx("span",{className:"shrink-0 px-3",children:t.jsx(st,{provider:s.id,size:30})},`c-${p}`))})}),t.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"}),t.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,t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:m("skills.empty.my")}),t.jsx(He,{type:"button",size:"sm",onClick:()=>r("browse"),children:m("skills.empty.my_cta")})]});else{const s=u===De,p=u===$e,E=x.length===0&&!s&&!p,G=ae&&!s&&!p||p&&xe,Oe=!s&&!p&&(S.trim()!==""||u!==Ze),Ie=()=>{v(""),g(Ze)},Ut=!E&&!G&&(Ge.length>0||Oe)?t.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:[t.jsx("span",{children:m("skills.filter.result_count_browse",{count:Ge.length})}),Oe?t.jsxs("button",{type:"button",onClick:Ie,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:[t.jsx(vt,{className:"h-3 w-3","aria-hidden":!0}),m("skills.filter.clear")]}):null]}):null;let Ke;E?Ke=t.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:t.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:m("skills.browse.empty_sources")})}):G?Ke=ht:s&&y.trim().length<2?Ke=t.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:m("skills.browse.hint_skillssh")}):Ge.length?Ke=t.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:Ge.map(pt=>t.jsx("div",{style:Gs,children:t.jsx(Ys,{skill:pt,installed:!!pt.installed,installing:_===It(pt),allTargets:_e,defaultTargets:Wt,onInstall:h,onManage:lt})},pt.id||pt.key))}):Oe?Ke=F("skills.empty.no_match",t.jsx(He,{type:"button",variant:"secondary",size:"sm",onClick:Ie,children:m("skills.filter.clear")})):s?Ke=F("skills.empty.search"):p?Ke=F("skills.empty.popular"):Ke=F("skills.empty.browse");const jt=E||R?t.jsx("div",{className:"mb-5",children:t.jsx(Xs,{repos:x,repoInput:C,onRepoInput:f,busyKey:_,onAdd:Te,onRemove:Ve})}):null,wn=!R&&!s&&!p&&x.length<=1&&Ge.length>0?t.jsx(Ss,{id:"skills-browse-intro",className:"mt-6",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{children:m("skills.browse.add_repo_hint")}),t.jsx("button",{type:"button",onClick:()=>b(!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:m("skills.browse.manage_sources")})]})}):null;he=t.jsxs(t.Fragment,{children:[jt,Ut,Ke,wn]})}return t.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:m("skills.page.title")}),t.jsxs(He,{type:"button",variant:"secondary",size:"sm",onClick:oe,disabled:pe||ae||xe,children:[t.jsx(Kn,{className:Ye("mr-1.5 h-3.5 w-3.5",(pe||ae||xe)&&"animate-spin"),"aria-hidden":!0}),m("skills.action.refresh")]})]}),t.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",m("skills.tab.my")],["browse",m("skills.tab.browse")]].map(([s,p])=>t.jsx("button",{type:"button","aria-pressed":e===s,onClick:()=>r(s),className:Ye("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",e===s?"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:p},s))}),ue?t.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:ue}):null,e==="browse"?t.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[t.jsx("div",{role:"tablist","aria-label":m("skills.source.label"),className:"inline-flex h-10 shrink-0 items-center rounded-md border border-oai-gray-200 bg-oai-white p-1 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[["repo",m("skills.mode.repo"),u!==De&&u!==$e],["popular",m("skills.mode.popular"),u===$e],["skillssh",m("skills.mode.skillssh"),u===De]].map(([s,p,E])=>t.jsxs("button",{type:"button",role:"tab","aria-selected":E,onClick:()=>{s==="skillssh"?g(De):s==="popular"?g($e):(u===De||u===$e)&&g(Ze)},className:Ye("inline-flex items-center gap-1.5 rounded px-3 py-1 text-sm font-medium transition-colors",E?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-700 dark:text-white":"text-oai-gray-500 hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"),children:[s==="popular"?t.jsx(Ta,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,p]},s))}),u!==De&&u!==$e?t.jsxs(rn,{value:u,onValueChange:g,children:[t.jsxs(nn,{"aria-label":m("skills.source.label"),className:"inline-flex h-10 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-3 text-sm 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:[t.jsx(an,{children:s=>s===Ze?m("skills.source.all"):s}),t.jsx(sn,{className:"text-oai-gray-400",children:t.jsx(ir,{className:"h-4 w-4","aria-hidden":!0})})]}),t.jsx(on,{children:t.jsx(dn,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:t.jsxs(fn,{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:[t.jsxs(Pt,{value:Ze,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:[t.jsx(Ot,{children:m("skills.source.all")}),t.jsx(_t,{children:t.jsx(ut,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),x.map(s=>{const p=`${s.owner}/${s.name}`;return t.jsxs(Pt,{value:p,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:[t.jsx(Ot,{children:p}),t.jsx(_t,{children:t.jsx(ut,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},p)})]})})})]}):null,t.jsxs("div",{className:"relative flex-1",children:[t.jsx(xr,{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}),t.jsx(hn,{type:"search",value:y,onChange:s=>v(s.target.value),onKeyDown:s=>{s.key==="Enter"&&u===De&&Ee()},"aria-label":m("skills.action.search_aria"),placeholder:u===De?m("skills.browse.placeholder_skillssh"):u===$e?m("skills.browse.placeholder_popular"):u===Ze?m("skills.browse.placeholder_all"):m("skills.browse.placeholder_repo",{repo:u}),className:"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===De?t.jsxs(He,{type:"button",onClick:Ee,disabled:y.trim().length<2||_==="search",className:"focus:!ring-oai-gray-400/30",children:[_==="search"?t.jsx(Xe,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):t.jsx(xr,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),m("skills.action.search")]}):u===$e?null:t.jsxs(He,{type:"button",variant:"secondary",size:"sm",onClick:()=>b(s=>!s),"aria-expanded":R,className:"!h-10 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:[t.jsx(qr,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),m("skills.browse.manage_sources"),t.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:x.length})]})]}):null,he,t.jsx(Ds,{skill:Pe,targets:_e,busyKey:_,usage:Pe&&(le[String(Pe.directory||"").toLowerCase()]||le[String(Pe.name||"").toLowerCase()])||null,hasUpdate:!!(Pe?.id&&fe?.[Pe.id]),updating:Pe?_===It(Pe):!1,onUpdate:je,onClose:nt,onToggleTarget:te,onRemove:D})]})}),t.jsx(Er,{open:!!U,title:m("skills.confirm.remove_title",{name:U?.name||U?.directory||""}),description:U?U.managed?m("skills.confirm.remove_managed"):m("skills.confirm.remove_local"):"",confirmLabel:m("skills.action.remove"),cancelLabel:m("shared.action.cancel"),destructive:!0,busy:_===Pr(U||{}),onCancel:()=>se(null),onConfirm:M}),t.jsx(Er,{open:!!P,title:m("skills.confirm.bulk_remove_title",{count:P?.length||0}),description:m("skills.confirm.bulk_remove_desc"),confirmLabel:m("skills.action.remove"),cancelLabel:m("shared.action.cancel"),destructive:!0,busy:_==="batch",onCancel:()=>H(null),onConfirm:Re})]})}export{co as SkillsPage};