@yuriai/web 0.3.3 → 0.3.4

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 (93) hide show
  1. package/dist/assets/{AgentSelector-DpOQ7dyw.js → AgentSelector-uBoLtut8.js} +1 -1
  2. package/dist/assets/{ArchivedSessionsDialog-nqnWb-Vc.js → ArchivedSessionsDialog-DZcicxVO.js} +1 -1
  3. package/dist/assets/{AssistantConversationSurface-CKXgty02.js → AssistantConversationSurface-36aP0hRf.js} +3 -3
  4. package/dist/assets/{AssistantSessionCard-C2-2fJul.js → AssistantSessionCard-CZ-1oJiE.js} +2 -2
  5. package/dist/assets/{AssistantView-BR8hsjOv.js → AssistantView-8fyAae7J.js} +1 -1
  6. package/dist/assets/{AssistantsSettingsPage-Bwid1xE0.js → AssistantsSettingsPage-DD6spbXz.js} +1 -1
  7. package/dist/assets/{BinaryFileFallback-Cb3uP7y1.js → BinaryFileFallback-DgYaMG9f.js} +1 -1
  8. package/dist/assets/{BtwPanel-9VAdk_qa.js → BtwPanel-BkobGcf3.js} +1 -1
  9. package/dist/assets/{BusyDots-DeDkh4Ke.js → BusyDots-COTTwItx.js} +1 -1
  10. package/dist/assets/{ChatContainer-wP6o_O4K.js → ChatContainer-BfQ7RXwY.js} +8 -8
  11. package/dist/assets/{ChatView-DU_2-cfD.js → ChatView-ByMRjY1h.js} +1 -1
  12. package/dist/assets/{DiagramView-CaefmjA4.js → DiagramView-DGnmjS2b.js} +1 -1
  13. package/dist/assets/{DiffView-BaqthIvq.js → DiffView-Bbit6OZ8.js} +1 -1
  14. package/dist/assets/{ErrorBoundary-_5B1xjgZ.js → ErrorBoundary-D7QcwhmL.js} +1 -1
  15. package/dist/assets/{FadeInOnReveal-BYHr1gqj.js → FadeInOnReveal-B3uT04YJ.js} +1 -1
  16. package/dist/assets/{GuiPluginMount-Btp3mJT2.js → GuiPluginMount-TC5FELtQ.js} +1 -1
  17. package/dist/assets/{GuiPluginPage-DM_RLx6u.js → GuiPluginPage-BPjU8N49.js} +1 -1
  18. package/dist/assets/{GuiPluginSurface-KiyqqEKU.js → GuiPluginSurface-CYPH6XzX.js} +1 -1
  19. package/dist/assets/{MarkdownRenderer-D7p9Iflj.js → MarkdownRenderer-VvziwyJB.js} +2 -2
  20. package/dist/assets/{MarkdownRendererImpl-BZc_jUrV.js → MarkdownRendererImpl-D8q0FMnr.js} +1 -1
  21. package/dist/assets/{MarkstreamRendererImpl-BUk_c3g1.js → MarkstreamRendererImpl-U_m_ZKG7.js} +1 -1
  22. package/dist/assets/{MobileAssistantSettingsPage-BBIiFN2g.js → MobileAssistantSettingsPage-Dgq5FMho.js} +1 -1
  23. package/dist/assets/{MobileBtwPage-DVZm5hrZ.js → MobileBtwPage-DQUkSO6N.js} +1 -1
  24. package/dist/assets/{MobileChangesSurface-CiqsGZsg.js → MobileChangesSurface-DsYNmAuM.js} +1 -1
  25. package/dist/assets/{MobileChatScreen-DDenVTX8.js → MobileChatScreen-p356_BCN.js} +1 -1
  26. package/dist/assets/{MobileFilesSurface-DIVH9aPV.js → MobileFilesSurface-CF3EW_SK.js} +2 -2
  27. package/dist/assets/{MobileHtmlNetworkBoundary-TBxrF4jJ.js → MobileHtmlNetworkBoundary-DlPF4iPS.js} +2 -2
  28. package/dist/assets/{MobileSettingsTab-MmDnxG47.js → MobileSettingsTab-DaTtRHo1.js} +1 -1
  29. package/dist/assets/{MobileShareBridge-DAlGSXoj.js → MobileShareBridge-CZpFYmiy.js} +1 -1
  30. package/dist/assets/{ModelSelector-HJmXcB3j.js → ModelSelector-EmtltPnd.js} +1 -1
  31. package/dist/assets/{MultiRunWindow-BmxVnblA.js → MultiRunWindow-CeSxAB8w.js} +1 -1
  32. package/dist/assets/{OnboardingScreen-DnEtIaxG.js → OnboardingScreen-BubjTNcy.js} +1 -1
  33. package/dist/assets/{PierreDiffViewer-B1e1H6br.js → PierreDiffViewer-DVKsdwJR.js} +1 -1
  34. package/dist/assets/{RemoteAssistantSessionCard-BgL7oxAK.js → RemoteAssistantSessionCard-DAoFvZht.js} +1 -1
  35. package/dist/assets/{RemoteDesktopPanel-DBrEQwpr.js → RemoteDesktopPanel-f3vRj4ZP.js} +1 -1
  36. package/dist/assets/{ScheduledTasksDialog-BVh0yaZR.js → ScheduledTasksDialog-D_hBP47Y.js} +1 -1
  37. package/dist/assets/{SettingsView-CLE6ra3s.js → SettingsView-DEU94-h1.js} +1 -1
  38. package/dist/assets/{SettingsWindow-DpzeOekS.js → SettingsWindow-DMVAV_el.js} +1 -1
  39. package/dist/assets/{SetupTourDialog-CY_CU5qU.js → SetupTourDialog-BlR7FJvd.js} +1 -1
  40. package/dist/assets/{TerminalView-mO5f0Axl.js → TerminalView-Xcwp3SG1.js} +1 -1
  41. package/dist/assets/{TextSelectionMenu-VsKriqtT.js → TextSelectionMenu-h8iUeNzE.js} +1 -1
  42. package/dist/assets/{ToolOutputDialog-DqCCsC-N.js → ToolOutputDialog-DpaaQ1uZ.js} +1 -1
  43. package/dist/assets/{auto-read-context-DVGIDEr6.js → auto-read-context-ClBUErN2.js} +1 -1
  44. package/dist/assets/{capgoAdapter-94K243Zv.js → capgoAdapter-pfQJmvW2.js} +1 -1
  45. package/dist/assets/{chatUpwardIntent-tvLWGs9Q.js → chatUpwardIntent-B2NrGMm-.js} +1 -1
  46. package/dist/assets/{gitApi-BWsBS_2N.js → gitApi-CoVwjIDy.js} +1 -1
  47. package/dist/assets/{insertionBoundaries-BSDUOMHN.js → insertionBoundaries-Btqgsu1M.js} +1 -1
  48. package/dist/assets/{main-DAbyAg5_.js → main-CXH2hObl.js} +4 -4
  49. package/dist/assets/{main-CHO9s_kb.js → main-ClH7cLKr.js} +2 -2
  50. package/dist/assets/{mcpQueries-1WNtiFYh.js → mcpQueries-Rmp1BKeo.js} +1 -1
  51. package/dist/assets/{miniChat-BZMkNMht.js → miniChat-B_Bw6udu.js} +2 -2
  52. package/dist/assets/{mobile-C9XDDOHq.js → mobile-BR73yoNi.js} +2 -2
  53. package/dist/assets/{mobileBackNavigation-DF_uhF-i.js → mobileBackNavigation-C94n2eLT.js} +1 -1
  54. package/dist/assets/{mobileConnections-DjT1L-_m.js → mobileConnections-x07fHO_5.js} +2 -2
  55. package/dist/assets/{multirun-D34EMeEj.js → multirun-CKQymP08.js} +1 -1
  56. package/dist/assets/{native-config-DSpTDz3F.js → native-config-DVg8_Zx1.js} +1 -1
  57. package/dist/assets/{nativeComposerCover-DXFy97OQ.js → nativeComposerCover-Bhv1EKPT.js} +1 -1
  58. package/dist/assets/{navigation-jU0HUH9s.js → navigation-D1klsD7k.js} +1 -1
  59. package/dist/assets/{openRemoteProjectSession-Bm_nafYw.js → openRemoteProjectSession-DNr74gHD.js} +1 -1
  60. package/dist/assets/{pluginPresentation-DexqrdQ0.js → pluginPresentation-DtyC8NF2.js} +1 -1
  61. package/dist/assets/{pwa-BaWpUiOR.js → pwa-CtDladgB.js} +1 -1
  62. package/dist/assets/{queue-abort-optimistic-UwpgXn4g.js → queue-abort-optimistic-DFbWDRKT.js} +1 -1
  63. package/dist/assets/{reference-history-DBxnA_fF.js → reference-history-IEuzG8KC.js} +1 -1
  64. package/dist/assets/{remoteSessionReference-Cug8RfIG.js → remoteSessionReference-ex07CtrZ.js} +1 -1
  65. package/dist/assets/{renderElectronMiniChatApp-CqrlQAsJ.js → renderElectronMiniChatApp-DM9y9qXo.js} +2 -2
  66. package/dist/assets/{renderMobileApp-CwcwGOox.js → renderMobileApp-DqpPYtZI.js} +4 -4
  67. package/dist/assets/{runtimeConfig-zzeYHX6k.js → runtimeConfig-CyvlrO58.js} +1 -1
  68. package/dist/assets/{runtimeEndpointReset-DUD-TCLY.js → runtimeEndpointReset-C0zNrsI9.js} +3 -3
  69. package/dist/assets/{sessionLookup-4zOaVAuF.js → sessionLookup-DQOiycHr.js} +1 -1
  70. package/dist/assets/{sessionOwnership-CEkPFbS4.js → sessionOwnership-BjhXe6pi.js} +1 -1
  71. package/dist/assets/{speechSettingsQueries-DQnPLEf3.js → speechSettingsQueries-BmkXNn4w.js} +1 -1
  72. package/dist/assets/{types-s_oc_LRs.js → types-DpcA-uDW.js} +1 -1
  73. package/dist/assets/{ui-DrAJTWV6.js → ui-ee2iN869.js} +12 -12
  74. package/dist/assets/{useAppFontEffects-nvkTSYHB.js → useAppFontEffects-rbTKcF0f.js} +2 -2
  75. package/dist/assets/{useDesktopWindowControlsLayout-i6qqpMbd.js → useDesktopWindowControlsLayout-BOkRz-p9.js} +1 -1
  76. package/dist/assets/{useEffectiveDirectory-BxolHzt4.js → useEffectiveDirectory-DiJBIfai.js} +1 -1
  77. package/dist/assets/{useGitStore-B641o_o0.js → useGitStore-Bv8xmXDa.js} +1 -1
  78. package/dist/assets/{useMcpConfigStore-BUSvv0Bl.js → useMcpConfigStore-DKTl0PvE.js} +1 -1
  79. package/dist/assets/{useMobileTranscriptSyncHint-86i3xO8J.js → useMobileTranscriptSyncHint-DM8WG7kz.js} +1 -1
  80. package/dist/assets/{useModelLists-Ca085-di.js → useModelLists-Bf60FIJu.js} +1 -1
  81. package/dist/assets/{useOpenCodeReadiness-CsNcdsCJ.js → useOpenCodeReadiness-Dm6BjA1T.js} +1 -1
  82. package/dist/assets/{usePluginsStore-ZHQOW-R5.js → usePluginsStore-Du4WlceO.js} +1 -1
  83. package/dist/assets/{useProjectGitActions-1QRsD7Rb.js → useProjectGitActions-D3B9ma9z.js} +1 -1
  84. package/dist/assets/{useProjectGitStore-C1K6WpCe.js → useProjectGitStore-DzU2pvrH.js} +1 -1
  85. package/dist/assets/{useProjectRuntimeAPIs-BItoD9Bt.js → useProjectRuntimeAPIs-tjGuODhu.js} +1 -1
  86. package/dist/assets/{useSessionBtwStore-BCHq3UOB.js → useSessionBtwStore-CwvlMabN.js} +1 -1
  87. package/dist/assets/{useStreamingTextThrottle-DGAjmaMZ.js → useStreamingTextThrottle-C9SaKeil.js} +1 -1
  88. package/dist/assets/{worktreeManager-QmahFqHc.js → worktreeManager-DGu8M01Z.js} +1 -1
  89. package/dist/assets/{worktreeSourceBranchPreference-B5Fldnhm.js → worktreeSourceBranchPreference-CuLKwxkx.js} +1 -1
  90. package/dist/index.html +5 -5
  91. package/dist/mini-chat.html +5 -5
  92. package/dist/mobile.html +1 -1
  93. package/package.json +1 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Y as t,j as n,k as r,ot as i}from"./platform-CiUKDeXd.js";import{H as a,ot as o,st as s}from"./vendor-base-ui-wXsskyKm.js";import{dr as c}from"./client-B_907PBv.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{s as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as d}from"./yuriEvents-BFrD5fMU.js";import{D as f,P as p}from"./runtime-file-resource-Bc_ss-sW.js";import{r as m}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as h}from"./useUIStore-C3ewjGgP.js";import{i as g,o as _}from"./session-startup-barrier-DT-hIBRf.js";import{n as v}from"./Icon-DmykXZL1.js";import{G as y,Ia as b,Mi as x,Na as S,Oi as C,Rr as w,Ti as T,f as E,qn as D,t as O}from"./ui-DrAJTWV6.js";import{m as k,n as A,p as j}from"./remoteProjectQueries-C8382jM8.js";import{t as ee}from"./i18n-DXc6czdR.js";import{i as M,n as N,t as P}from"./tooltip-CpTbxEOE.js";import{c as F,n as I,t as L}from"./dropdown-menu-BblI9sN2.js";import{s as R}from"./useGitStore-B641o_o0.js";import{b as z,h as B,p as V}from"./pwa-BaWpUiOR.js";import{t as te}from"./MobileOverlayPanel-C36VWWmN.js";import{l as ne,r as re}from"./quota-CqWNkFzw.js";import{a as H,i as U}from"./sessionLookup-4zOaVAuF.js";import{n as W}from"./openRemoteProjectSession-Bm_nafYw.js";var G=l(),K=e(s(),1),q=o(),J=e=>{let t=(0,G.c)(179),{pending:n,totalTokens:r,percentage:i,colorPercentage:a,contextLimit:o,outputLimit:s,size:c,isMobile:l,hideIcon:u,showPercentIcon:d,appearance:f,className:p,valueClassName:m,percentIconClassName:h,onClick:g,pressed:y}=e,b=n!==void 0&&n,x=c===void 0?`default`:c,S=l!==void 0&&l,C=u!==void 0&&u,w=d!==void 0&&d,T=f===void 0?`default`:f,E=y!==void 0&&y,{t:D}=ee(),[O,k]=K.useState(!1),A=typeof a==`number`?a:i,j,F,I,L,R,z,B,V,H,U,W,J,oe,Y,X,se,ce,Z,le,Q,$;if(t[0]!==T||t[1]!==A||t[2]!==o||t[3]!==S||t[4]!==g||t[5]!==s||t[6]!==b||t[7]!==h||t[8]!==i||t[9]!==D||t[10]!==r){let e=b?0:re(i)??0;U=T===`subtle`;let n=ne(A);W=U||b?`var(--surface-muted-foreground)`:n===`critical`?`var(--status-error)`:n===`warn`?`var(--status-warning)`:`var(--status-success)`,B=ie;let a;t[32]===b?a=t[33]:(a=e=>b?`text-muted-foreground`:e>=90?`text-status-error`:e>=75?`text-status-warning`:`text-status-success`,t[32]=b,t[33]=a),V=a,L=U?18:20,R=U?2:3,I=(L-R)/2,j=2*Math.PI*I,F=j*(1-e/100),J=typeof s==`number`?Math.max(s,0):0;let c;t[34]!==o||t[35]!==b||t[36]!==i||t[37]!==J||t[38]!==D||t[39]!==r?(Q=b?D(`contextUsage.pending`):`${Math.min(i,999).toFixed(1)}%`,$=b?`—`:B(r),z=B(o),c=b?[D(`contextUsage.pendingDescription`)]:[D(`contextUsage.tooltip.usage`,{percent:Q}),D(`contextUsage.tooltip.usedOfLimit`,{used:$,limit:z}),D(`contextUsage.tooltip.outputLimit`,{tokens:B(J)})],t[34]=o,t[35]=b,t[36]=i,t[37]=J,t[38]=D,t[39]=r,t[40]=z,t[41]=c,t[42]=Q,t[43]=$):(z=t[40],c=t[41],Q=t[42],$=t[43]),le=c,H=!S&&typeof g==`function`,ce=`0 0 ${L} ${L}`;let l=U?`h-4 w-4 shrink-0 -rotate-90 text-muted-foreground/70`:`h-3.5 w-3.5 -rotate-90`;t[44]!==h||t[45]!==l?(Z=_(l,h),t[44]=h,t[45]=l,t[46]=Z):Z=t[46],oe=`progressbar`,t[47]===D?Y=t[48]:(Y=D(`contextUsage.aria.label`),t[47]=D,t[48]=Y),t[49]!==b||t[50]!==D?(X=b?D(`contextUsage.pending`):void 0,t[49]=b,t[50]=D,t[51]=X):X=t[51],se=b?void 0:Math.round(e),t[0]=T,t[1]=A,t[2]=o,t[3]=S,t[4]=g,t[5]=s,t[6]=b,t[7]=h,t[8]=i,t[9]=D,t[10]=r,t[11]=j,t[12]=F,t[13]=I,t[14]=L,t[15]=R,t[16]=z,t[17]=B,t[18]=V,t[19]=H,t[20]=U,t[21]=W,t[22]=J,t[23]=oe,t[24]=Y,t[25]=X,t[26]=se,t[27]=ce,t[28]=Z,t[29]=le,t[30]=Q,t[31]=$}else j=t[11],F=t[12],I=t[13],L=t[14],R=t[15],z=t[16],B=t[17],V=t[18],H=t[19],U=t[20],W=t[21],J=t[22],oe=t[23],Y=t[24],X=t[25],se=t[26],ce=t[27],Z=t[28],le=t[29],Q=t[30],$=t[31];let ue=L/2,de=L/2,fe;t[52]!==I||t[53]!==R||t[54]!==ue||t[55]!==de?(fe=(0,q.jsx)(`circle`,{cx:ue,cy:de,r:I,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:R}),t[52]=I,t[53]=R,t[54]=ue,t[55]=de,t[56]=fe):fe=t[56];let pe=L/2,me=L/2,he;t[57]!==j||t[58]!==F||t[59]!==I||t[60]!==R||t[61]!==W||t[62]!==pe||t[63]!==me?(he=(0,q.jsx)(`circle`,{cx:pe,cy:me,r:I,fill:`none`,stroke:W,strokeWidth:R,strokeLinecap:`round`,strokeDasharray:j,strokeDashoffset:F,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[57]=j,t[58]=F,t[59]=I,t[60]=R,t[61]=W,t[62]=pe,t[63]=me,t[64]=he):he=t[64];let ge;t[65]!==oe||t[66]!==Y||t[67]!==X||t[68]!==se||t[69]!==fe||t[70]!==he||t[71]!==ce||t[72]!==Z?(ge=(0,q.jsxs)(`svg`,{viewBox:ce,className:Z,role:oe,"aria-label":Y,"aria-valuetext":X,"aria-valuenow":se,"aria-valuemin":0,"aria-valuemax":100,children:[fe,he]}),t[65]=oe,t[66]=Y,t[67]=X,t[68]=se,t[69]=fe,t[70]=he,t[71]=ce,t[72]=Z,t[73]=ge):ge=t[73];let _e=ge,ve=E||b?`ml-1 max-w-[14rem] opacity-100`:`ml-0 max-w-0 opacity-0 group-hover:ml-1 group-hover:max-w-[14rem] group-hover:opacity-100 group-focus-visible:ml-1 group-focus-visible:max-w-[14rem] group-focus-visible:opacity-100`,ye;t[74]===ve?ye=t[75]:(ye=_(`inline-flex items-center gap-1.5 overflow-hidden whitespace-nowrap typography-micro font-medium text-foreground transition-[max-width,opacity,margin] duration-200`,ve),t[74]=ve,t[75]=ye);let be;t[76]===Q?be=t[77]:(be=(0,q.jsx)(`span`,{children:Q}),t[76]=Q,t[77]=be);let xe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,q.jsx)(`span`,{className:`mx-0.5 text-muted-foreground/60`,children:`/`}),t[78]=xe):xe=t[78];let Se;t[79]!==z||t[80]!==$?(Se=(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[$,xe,z]}),t[79]=z,t[80]=$,t[81]=Se):Se=t[81];let Ce;t[82]!==ye||t[83]!==be||t[84]!==Se?(Ce=(0,q.jsxs)(`span`,{className:ye,children:[be,Se]}),t[82]=ye,t[83]=be,t[84]=Se,t[85]=Ce):Ce=t[85];let we=Ce,Te;t[86]!==A||t[87]!==V||t[88]!==C||t[89]!==S||t[90]!==U||t[91]!==b||t[92]!==i||t[93]!==_e||t[94]!==w||t[95]!==we||t[96]!==Q||t[97]!==m?(Te=U?(0,q.jsxs)(q.Fragment,{children:[_e,we]}):(0,q.jsxs)(q.Fragment,{children:[!S&&!C&&(0,q.jsx)(v,{name:`donut-chart`,className:`h-4 w-4 flex-shrink-0`}),(0,q.jsx)(`span`,{className:_(`font-medium inline-flex items-center gap-1.5`,m),children:b?(0,q.jsxs)(q.Fragment,{children:[w&&_e,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:Q})]}):w?(0,q.jsxs)(q.Fragment,{children:[_e,(0,q.jsx)(`span`,{className:`text-foreground`,children:Q})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:V(A),children:Math.min(i,999).toFixed(1)}),`%`]})})]}),t[86]=A,t[87]=V,t[88]=C,t[89]=S,t[90]=U,t[91]=b,t[92]=i,t[93]=_e,t[94]=w,t[95]=we,t[96]=Q,t[97]=m,t[98]=Te):Te=t[98];let Ee=Te,De=U?`gap-0`:`gap-1.5`,Oe=x===`compact`?`typography-micro`:`typography-meta`,ke;t[99]!==p||t[100]!==H||t[101]!==U||t[102]!==E||t[103]!==De||t[104]!==Oe?(ke=_(`app-region-no-drag flex items-center select-none`,De,Oe,H?_(`group rounded-md text-foreground transition-colors`,U?_(`p-1.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50`,E&&`bg-interactive-hover/50 text-foreground`):`px-2 py-1.5 hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`):`text-muted-foreground/60`,p),t[99]=p,t[100]=H,t[101]=U,t[102]=E,t[103]=De,t[104]=Oe,t[105]=ke):ke=t[105];let Ae=ke,je;t[106]!==Ee||t[107]!==H||t[108]!==S||t[109]!==g||t[110]!==E||t[111]!==Ae||t[112]!==D?(je=H?(0,q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":D(`contextUsage.aria.label`),"aria-pressed":E,onClick:g,children:Ee}):(0,q.jsx)(`div`,{className:Ae,"aria-label":D(`contextUsage.aria.label`),onClick:S?()=>k(!0):void 0,children:Ee}),t[106]=Ee,t[107]=H,t[108]=S,t[109]=g,t[110]=E,t[111]=Ae,t[112]=D,t[113]=je):je=t[113];let Me=je;if(S){let e;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>k(!1),t[114]=e):e=t[114];let n;t[115]===D?n=t[116]:(n=D(`contextUsage.mobile.title`),t[115]=D,t[116]=n);let r;t[117]===D?r=t[118]:(r=D(`contextUsage.mobile.usedTokens`),t[117]=D,t[118]=r);let i;t[119]===r?i=t[120]:(i=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[119]=r,t[120]=i);let a;t[121]===$?a=t[122]:(a=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:$}),t[121]=$,t[122]=a);let o;t[123]!==i||t[124]!==a?(o=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[i,a]}),t[123]=i,t[124]=a,t[125]=o):o=t[125];let s;t[126]===D?s=t[127]:(s=D(`contextUsage.mobile.contextLimit`),t[126]=D,t[127]=s);let c;t[128]===s?c=t[129]:(c=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s}),t[128]=s,t[129]=c);let l;t[130]===z?l=t[131]:(l=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:z}),t[130]=z,t[131]=l);let u;t[132]!==c||t[133]!==l?(u=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[c,l]}),t[132]=c,t[133]=l,t[134]=u):u=t[134];let d;t[135]===D?d=t[136]:(d=D(`contextUsage.mobile.outputLimit`),t[135]=D,t[136]=d);let f;t[137]===d?f=t[138]:(f=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d}),t[137]=d,t[138]=f);let p;t[139]!==B||t[140]!==J?(p=B(J),t[139]=B,t[140]=J,t[141]=p):p=t[141];let m;t[142]===p?m=t[143]:(m=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:p}),t[142]=p,t[143]=m);let h;t[144]!==f||t[145]!==m?(h=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[f,m]}),t[144]=f,t[145]=m,t[146]=h):h=t[146];let g;t[147]===D?g=t[148]:(g=D(`contextUsage.mobile.usage`),t[147]=D,t[148]=g);let v;t[149]===g?v=t[150]:(v=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:g}),t[149]=g,t[150]=v);let y;t[151]!==A||t[152]!==V?(y=_(`typography-meta font-semibold`,V(A)),t[151]=A,t[152]=V,t[153]=y):y=t[153];let b;t[154]!==y||t[155]!==Q?(b=(0,q.jsx)(`span`,{className:y,children:Q}),t[154]=y,t[155]=Q,t[156]=b):b=t[156];let x;t[157]!==v||t[158]!==b?(x=(0,q.jsxs)(`div`,{className:`flex justify-between items-center pt-1 border-t border-border/40`,children:[v,b]}),t[157]=v,t[158]=b,t[159]=x):x=t[159];let S;t[160]!==o||t[161]!==u||t[162]!==h||t[163]!==x?(S=(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1`,children:[o,u,h,x]})}),t[160]=o,t[161]=u,t[162]=h,t[163]=x,t[164]=S):S=t[164];let C;t[165]!==O||t[166]!==n||t[167]!==S?(C=(0,q.jsx)(te,{open:O,onClose:e,title:n,children:S}),t[165]=O,t[166]=n,t[167]=S,t[168]=C):C=t[168];let w;return t[169]!==Me||t[170]!==C?(w=(0,q.jsxs)(q.Fragment,{children:[Me,C]}),t[169]=Me,t[170]=C,t[171]=w):w=t[171],w}if(U)return Me;let Ne;t[172]===Me?Ne=t[173]:(Ne=(0,q.jsx)(M,{asChild:!0,children:Me}),t[172]=Me,t[173]=Ne);let Pe;t[174]===le?Pe=t[175]:(Pe=(0,q.jsx)(N,{children:(0,q.jsx)(`div`,{className:`space-y-0.5`,children:le.map(ae)})}),t[174]=le,t[175]=Pe);let Fe;return t[176]!==Ne||t[177]!==Pe?(Fe=(0,q.jsxs)(P,{children:[Ne,Pe]}),t[176]=Ne,t[177]=Pe,t[178]=Fe):Fe=t[178],Fe};function ie(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(1).replace(/\.0$/,``)}function ae(e){return(0,q.jsx)(`p`,{className:`typography-micro leading-tight`,children:e},e)}var oe=7,Y=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},X=e=>{if(!e)return null;let t=e.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},se=(e,t)=>{let n=(0,G.c)(32),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{scopeProjectId:i}=r,a=i===void 0?null:i,o=C(ce),s=S(Z),c=x(),l;n[2]===s?l=n[3]:(l=s.map(le).filter(Q),n[2]=s,n[3]=l);let u=l,d;n[4]===u?d=n[5]:(d=e=>e?u.filter(t=>z(e,t.normalizedPath)).sort($)[0]??null:null,n[4]=u,n[5]=d);let f=d,p;bb0:{if(!e){let e;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[6]=e):e=n[6],p=e;break bb0}let t;if(n[7]!==o||n[8]!==f||n[9]!==c||n[10]!==a){let e;n[12]!==f||n[13]!==a?(e=e=>!a||f(T(e))?.id===a,n[12]=f,n[13]=a,n[14]=e):e=n[14];let r;n[15]===c?r=n[16]:(r=(e,t)=>V(e,t,c),n[15]=c,n[16]=r),t=Array.from(new Set(o.filter(ue).filter(de).filter(e).sort(r).slice(0,oe).map(fe).filter(pe))),n[7]=o,n[8]=f,n[9]=c,n[10]=a,n[11]=t}else t=n[11];p=t}let m=p,h;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,n[17]=h):h=n[17];let g=K.useRef(h),_;n[18]===m?_=n[19]:(_=e=>{let t=g.current,n=t.size===m.length;if(n){for(let r of m)if(t.get(r)!==(e.directories.get(r)?.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;return m.forEach(t=>r.set(t,e.directories.get(t)?.status?.current??null)),g.current=r,r},n[18]=m,n[19]=_);let v=R(_),y;bb1:{if(!e){let e;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[20]=e):e=n[20],y=e;break bb1}let t;if(n[21]!==o||n[22]!==v||n[23]!==f||n[24]!==c||n[25]!==a){let e=new Map;for(let t of o){let n=t.parentID;if(!n||t.time?.archived)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}e.forEach(e=>{e.sort((e,t)=>V(e,t,c))});let r;n[27]!==f||n[28]!==a?(r=e=>{if(!a)return!0;let t=T(e);return f(t)?.id===a},n[27]=f,n[28]=a,n[29]=r):r=n[29];let i;n[30]===c?i=n[31]:(i=(e,t)=>V(e,t,c),n[30]=c,n[31]=i);let s=o.filter(me).filter(he).filter(r).sort(i).slice(0,oe),l=t=>({session:t,children:(e.get(t.id)??[]).map(e=>l(e)),worktree:null});t=s.map(e=>{let t=T(e),n=f(t),r=X(n),i=t?v.get(t)??null:null;return{node:l(e),projectId:n?.id??null,groupDirectory:t,secondaryMeta:{projectLabel:r,branchLabel:i&&i!==r?i:null}}}),n[21]=o,n[22]=v,n[23]=f,n[24]=c,n[25]=a,n[26]=t}else t=n[26];y=t}return y};function ce(e){return e.activeSessions}function Z(e){return e.projects}function le(e){return{...e,normalizedPath:Y(e.path)}}function Q(e){return e.normalizedPath}function $(e,t){return(t.normalizedPath?.length??0)-(e.normalizedPath?.length??0)}function ue(e){return!e.time?.archived}function de(e){return!e.parentID}function fe(e){return T(e)}function pe(e){return!!e}function me(e){return!e.time?.archived}function he(e){return!e.parentID}function ge(e){let t=(0,G.c)(18),{children:n,variant:r,scopeProjectId:i,align:a}=e,o=r===void 0?`default`:r,s=i===void 0?null:i,c=a===void 0?`start`:a,l=h(ve),u=h(_e),d;t[0]===n?d=t[1]:(d=(0,q.jsx)(F,{asChild:!0,children:n}),t[0]=n,t[1]=d);let f=o===`compact`?`w-[280px]`:`w-[360px]`,p;t[2]===f?p=t[3]:(p=_(`overflow-hidden p-1 max-w-[calc(100vw-32px)]`,f),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==s||t[6]!==u||t[7]!==o?(m=l?(0,q.jsx)(ye,{onSelect:()=>u(!1),variant:o,scopeProjectId:s}):null,t[4]=l,t[5]=s,t[6]=u,t[7]=o,t[8]=m):m=t[8];let g;t[9]!==c||t[10]!==p||t[11]!==m?(g=(0,q.jsx)(I,{align:c,sideOffset:6,className:p,children:m}),t[9]=c,t[10]=p,t[11]=m,t[12]=g):g=t[12];let v;return t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==g?(v=(0,q.jsxs)(L,{open:l,onOpenChange:u,modal:!1,children:[d,g]}),t[13]=l,t[14]=u,t[15]=d,t[16]=g,t[17]=v):v=t[17],v}function _e(e){return e.setSessionDropdownOpen}function ve(e){return e.isSessionDropdownOpen}function ye(e){let t=(0,G.c)(7),{onSelect:n,variant:r,scopeProjectId:i}=e,a;t[0]===i?a=t[1]:(a=e=>e.projects.find(t=>t.id===(i??e.activeProjectId)),t[0]=i,t[1]=a);let o=S(a),s;return t[2]!==n||t[3]!==o||t[4]!==i||t[5]!==r?(s=o?.hostId?(0,q.jsx)(Ce,{projectId:o.id,hostId:o.hostId,hubId:o.hubId,onSelect:n,variant:r},`${o.hubId}:${o.hostId}:${o.id}`):(0,q.jsx)(be,{onSelect:n,variant:r,scopeProjectId:i}),t[2]=n,t[3]=o,t[4]=i,t[5]=r,t[6]=s):s=t[6],s}function be(e){let t=(0,G.c)(27),{onSelect:n,variant:r,scopeProjectId:i}=e,o;t[0]===i?o=t[1]:(o={scopeProjectId:i},t[0]=i,t[1]=o);let s=se(!0,o),c=E(Se),l=h(xe),{t:u}=ee(),d;t[2]!==n||t[3]!==c||t[4]!==l?(d=()=>{l(`chat`),n(),c()},t[2]=n,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=m(d),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=new Set,t[6]=p):p=t[6];let[g,y]=K.useState(p),b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[7]=b):b=t[7];let x=m(b),S,C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=_(`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),C=(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),t[8]=S,t[9]=C):(S=t[8],C=t[9]);let w;t[10]===u?w=t[11]:(w=u(`sessions.sidebar.header.actions.newSession`),t[10]=u,t[11]=w);let T;t[12]===w?T=t[13]:(T=(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:w}),t[12]=w,t[13]=T);let D;t[14]!==f||t[15]!==T?(D=(0,q.jsxs)(a,{onClick:f,className:S,children:[C,T]}),t[14]=f,t[15]=T,t[16]=D):D=t[16];let O;t[17]!==g||t[18]!==s||t[19]!==n||t[20]!==u||t[21]!==x||t[22]!==r?(O=s.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:u(`sessions.switcher.empty`)}):s.map(e=>(0,q.jsx)(De,{item:e,depth:0,variant:r,expandedParents:g,toggleParent:x,closeDropdown:n},e.node.session.id)),t[17]=g,t[18]=s,t[19]=n,t[20]=u,t[21]=x,t[22]=r,t[23]=O):O=t[23];let k;return t[24]!==O||t[25]!==D?(k=(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[D,O]})}),t[24]=O,t[25]=D,t[26]=k):k=t[26],k}function xe(e){return e.setActiveMainTab}function Se(e){return e.openNewSessionDraft}function Ce(e){let t=(0,G.c)(24),{projectId:n,hostId:r,hubId:i,onSelect:a,variant:o}=e,s=k(!0),c;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==s.catalog?.hubId||t[4]!==s.catalog?.projects?(c=!i||i===s.catalog?.hubId?s.catalog?.projects.find(e=>e.id===n&&e.hostId===r):void 0,t[0]=r,t[1]=i,t[2]=n,t[3]=s.catalog?.hubId,t[4]=s.catalog?.projects,t[5]=c):c=t[5];let l=c,{t:u}=ee(),d=m(we),f;t[6]!==l||t[7]!==s.error?.message||t[8]!==s.isPending||t[9]!==s.registry||t[10]!==u?(f=s.error?.message??(!s.isPending&&(!s.registry||!l)?u(`remoteProjects.host-unavailable`):void 0),t[6]=l,t[7]=s.error?.message,t[8]=s.isPending,t[9]=s.registry,t[10]=u,t[11]=f):f=t[11];let p=f,h,_;t[12]!==p||t[13]!==r||t[14]!==i?(h=()=>{p&&O.error(p,{id:`remote-switcher:${i}:${r}:catalog`})},_=[p,i,r],t[12]=p,t[13]=r,t[14]=i,t[15]=h,t[16]=_):(h=t[15],_=t[16]),K.useEffect(h,_);let v;return t[17]!==a||t[18]!==l||t[19]!==d||t[20]!==s.registry||t[21]!==u||t[22]!==o?(v=s.registry&&l?(0,q.jsx)(Te,{registry:s.registry,project:l,onSelect:a,variant:o}):(0,q.jsx)(`div`,{className:`px-3 py-4`,children:(0,q.jsx)(g,{size:`xs`,variant:`ghost`,onClick:()=>void d(),children:u(`remoteProjects.retry`)})}),t[17]=a,t[18]=l,t[19]=d,t[20]=s.registry,t[21]=u,t[22]=o,t[23]=v):v=t[23],v}async function we(){try{await A()}catch(e){let t=e;O.error(t instanceof Error?t.message:String(t))}}function Te({registry:e,project:t,onSelect:n,variant:r}){let{t:i}=ee(),o=f(e,t.hostId),s=j(e,t.hostId),c=S(e=>e.projects),l=b(e=>e.remoteSession),u=h(e=>e.isMobile),d=s.data,g=o?.state===`connected`&&t.remoteState===`ok`&&!d?.stale,_=K.useMemo(()=>{let n=new Set(d?.pinnedSessionIds??[]),r=new Map,i=n=>(r.has(n)||r.set(n,p(c,e.hubId,t.hostId,n,d?.worktrees)?.id===t.id),r.get(n));return(d?.directories??[]).flatMap(({directory:e,sessions:t})=>t.filter(e=>!e.parentID&&!e.time.archived).map(t=>({session:t,directory:t.directory||e}))).filter(({directory:e})=>i(e)).sort((e,t)=>V(e.session,t.session,n)).slice(0,7)},[d,c,t.hostId,t.id,e.hubId]),y=s.error?.message,{refetch:x}=s;K.useEffect(()=>{y&&O.error(y,{id:`remote-project:${t.id}:load`,action:{label:i(`remoteProjects.retry`),onClick:()=>void x()}})},[y,t.id,x,i]);let C=m((r,a)=>{try{if(p(c,e.hubId,t.hostId,a,d?.worktrees)?.id!==t.id)throw Error(i(`remoteProjects.host-unavailable`));W(t,e,r,a,u),n()}catch(e){O.error(e instanceof Error?e.message:String(e))}}),w=l?.projectId===t.id&&l.location.hostId===t.hostId&&l.location.hubId===e.hubId?l.location.directory:t.path;return(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsxs)(a,{onClick:()=>C(null,w),className:`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`,children:[(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:i(`sessions.sidebar.header.actions.newSession`)})]}),g?null:(0,q.jsxs)(`div`,{role:`status`,className:`px-3 typography-meta text-muted-foreground`,children:[i(`remoteProjects.state.${o?.state??`offline`}`),` · `,i(`remoteProjects.unknown`)]}),!_.length&&d?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`sessions.switcher.empty`)}):null,_.map(({session:n,directory:i})=>(0,q.jsx)(Ee,{registry:e,project:t,projects:c,session:n,directory:i,variant:r,snapshot:d,online:g,navigate:C,selected:l,depth:0,ancestors:[]},`${i}:${n.id}`))]})})}function Ee({registry:e,project:t,projects:n,session:r,directory:i,variant:a,snapshot:o,online:s,navigate:l,selected:f,depth:h,ancestors:_}){let{t:v}=ee(),[y,b]=K.useState(!1),[x,S]=K.useState(30),C=e.resolve({hubId:e.hubId,hostId:t.hostId,directory:i}),w=K.useMemo(()=>({...D(i,void 0,void 0,void 0,C),enabled:!1,staleTime:1/0,gcTime:1/0}),[C,i]),T=u(w,d).data?.current,E=u({queryKey:[...C.queryScope,`navigation-children`,r.id,x],enabled:y&&s,staleTime:3e4,gcTime:1/0,placeholderData:(e,t)=>t&&C.queryScope.every((e,n)=>t.queryKey[n]===e)&&t.queryKey[C.queryScope.length+1]===r.id?e:void 0,queryFn:async({signal:t})=>{let n=[],a,o=!1;for(let s=0;s<Math.ceil(x/30);s++){let s=await C.sdk().session.list({directory:i,parentID:r.id,limit:30,...a?{cursor:a}:{}},{signal:t});if(e.assertCurrent(),C.sdk(),!Array.isArray(s.data))throw Error(`Remote child session list returned no data`);n.push(...s.data.map(c).filter(e=>!e.time?.archived).map(e=>({...e,directory:e.directory||i,time:e.time??{}})));let l=s.cursor?.next||void 0;if(o=!!(l&&l!==a),!o)break;a=l}return{sessions:n,hasMore:o}}},d),{error:k,refetch:A}=E;K.useEffect(()=>{k&&O.error(k.message,{id:`remote-children:${C.key}:${r.id}`,action:{label:v(`remoteProjects.retry`),onClick:()=>void A()}})},[k,C.key,r.id,A,v]);let j=m(({directory:e,payload:t})=>{e&&e!==i||t&&typeof t==`object`&&`type`in t&&typeof t.type==`string`&&/^(session\.(created|updated|deleted|status)|yuri:session-metadata)$/.test(t.type)&&d.invalidateQueries({queryKey:[...C.queryScope,`navigation-children`,r.id,x],exact:!0})});K.useEffect(()=>{if(y&&s)return e.subscribeEvents(t.hostId,j)},[e,t.hostId,i,y,s,j]);let M=o?.directories.flatMap(e=>e.sessions.filter(e=>e.parentID===r.id).map(t=>({...t,directory:t.directory||e.directory})))??[],N=(E.data?.sessions??M).filter(a=>a.id!==r.id&&!_.includes(a.id)&&p(n,e.hubId,t.hostId,a.directory||i,o?.worktrees)?.id===t.id),P=r.metadata?.yuri?.sessionStatus?.type,F=f?.projectId===t.id&&f.location.hubId===e.hubId&&f.location.hostId===t.hostId&&f.location.directory===i&&f.sessionId===r.id;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(je,{session:r,depth:h,variant:a,secondaryMeta:{projectLabel:t.label??t.path.split(/[\\/]/).filter(Boolean).at(-1),branchLabel:T},hasChildren:!!(r.hasChildren||N.length||h>0),isExpanded:y,onToggleExpand:()=>b(e=>!e),isActive:F,unseenCount:o?.unread?.sessions[r.id]?.unreadCount??0,statusType:s?P??`idle`:`unknown`,handleSelect:()=>l(r.id,i)}),y?(0,q.jsxs)(q.Fragment,{children:[N.map(c=>(0,q.jsx)(Ee,{registry:e,project:t,projects:n,variant:a,snapshot:o,online:s,navigate:l,selected:f,directory:c.directory||i,session:c,depth:h+1,ancestors:[..._,r.id]},c.id)),E.data?.hasMore?(0,q.jsx)(g,{size:`xs`,variant:`ghost`,disabled:!s||E.isFetching,onClick:()=>S(e=>e+30),children:v(`remoteProjects.showMore`)}):null]}):null]})}function De(e){let t=(0,G.c)(31),{item:n,depth:r,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s}=e,{node:c,secondaryMeta:l}=n,u=c.session,d=c.children.length>0,f;t[0]!==a||t[1]!==u.id?(f=a.has(u.id),t[0]=a,t[1]=u.id,t[2]=f):f=t[2];let p=f,m;t[3]!==d||t[4]!==u.id||t[5]!==o?(m=d?()=>o(u.id):void 0,t[3]=d,t[4]=u.id,t[5]=o,t[6]=m):m=t[6];let h;t[7]!==s||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==u||t[13]!==m||t[14]!==i?(h=(0,q.jsx)(Oe,{session:u,depth:r,variant:i,secondaryMeta:l,hasChildren:d,isExpanded:p,onToggleExpand:m,closeDropdown:s}),t[7]=s,t[8]=r,t[9]=d,t[10]=p,t[11]=l,t[12]=u,t[13]=m,t[14]=i,t[15]=h):h=t[15];let g;t[16]!==s||t[17]!==r||t[18]!==a||t[19]!==d||t[20]!==p||t[21]!==n.groupDirectory||t[22]!==n.projectId||t[23]!==c.children||t[24]!==l||t[25]!==o||t[26]!==i?(g=d&&p?c.children.map(e=>(0,q.jsx)(De,{item:{node:e,projectId:n.projectId,groupDirectory:n.groupDirectory,secondaryMeta:l},depth:r+1,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s},e.session.id)):null,t[16]=s,t[17]=r,t[18]=a,t[19]=d,t[20]=p,t[21]=n.groupDirectory,t[22]=n.projectId,t[23]=c.children,t[24]=l,t[25]=o,t[26]=i,t[27]=g):g=t[27];let _;return t[28]!==h||t[29]!==g?(_=(0,q.jsxs)(q.Fragment,{children:[h,g]}),t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function Oe(e){let t=(0,G.c)(17),{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,closeDropdown:l}=e,u=E(Ae),d=E(ke),f=y(n.id),p=w(n.id),h=u===n.id,g;t[0]!==l||t[1]!==h||t[2]!==n||t[3]!==d?(g=()=>{h||d(n.id,T(n)??null),l()},t[0]=l,t[1]=h,t[2]=n,t[3]=d,t[4]=g):g=t[4];let _=m(g),v=f?.type??`idle`,b;return t[5]!==r||t[6]!==_||t[7]!==o||t[8]!==h||t[9]!==s||t[10]!==c||t[11]!==a||t[12]!==n||t[13]!==v||t[14]!==p||t[15]!==i?(b=(0,q.jsx)(je,{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,isActive:h,unseenCount:p,statusType:v,handleSelect:_}),t[5]=r,t[6]=_,t[7]=o,t[8]=h,t[9]=s,t[10]=c,t[11]=a,t[12]=n,t[13]=v,t[14]=p,t[15]=i,t[16]=b):b=t[16],b}function ke(e){return e.setCurrentSession}function Ae(e){return e.currentSessionId}function je(e){let t=(0,G.c)(57),{session:n,depth:r,variant:i,secondaryMeta:o,hasChildren:s,isExpanded:c,onToggleExpand:l,isActive:u,unseenCount:d,statusType:f,handleSelect:p}=e,{t:m}=ee(),h;t[0]!==n.title||t[1]!==m?(h=n.title?.trim()||m(`sessions.sidebar.session.untitled`),t[0]=n.title,t[1]=m,t[2]=h):h=t[2];let g=h,y;t[3]===n?y=t[4]:(y=U(H(n)),t[3]=n,t[4]=y);let b=y,x=!!n.parentID,S=d>0&&!x,C=f===`busy`||f===`retry`,w=!C&&S,T;t[5]!==n.time?.created||t[6]!==n.time?.updated?(T=n.time?.updated||n.time?.created||Date.now(),t[5]=n.time?.created,t[6]=n.time?.updated,t[7]=T):T=t[7];let E=T,D;t[8]===E?D=t[9]:(D=B(E),t[8]=E,t[9]=D);let O=D,k;t[10]===o?.projectLabel?k=t[11]:(k=o?.projectLabel?.trim()||null,t[10]=o?.projectLabel,t[11]=k);let A=k,j;t[12]===o?.branchLabel?j=t[13]:(j=o?.branchLabel?.trim()||null,t[12]=o?.branchLabel,t[13]=j);let M=j,N=M&&M!==`HEAD`?M:null,P;t[14]===p?P=t[15]:(P=e=>{if(e.target?.closest(`[data-switcher-expand]`)){e.preventDefault();return}p()},t[14]=p,t[15]=P);let F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=_(`group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),t[16]=F):F=t[16];let I=8+r*12,L;t[17]===I?L=t[18]:(L={paddingLeft:I},t[17]=I,t[18]=L);let R;t[19]!==s||t[20]!==c||t[21]!==l||t[22]!==m||t[23]!==i?(R=i===`compact`&&s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3.5 w-3.5`})}):null,t[19]=s,t[20]=c,t[21]=l,t[22]=m,t[23]=i,t[24]=R):R=t[24];let z=u?`text-primary`:`text-foreground`,V;t[25]===z?V=t[26]:(V=_(`min-w-0 truncate text-[14px] font-normal leading-tight`,z),t[25]=z,t[26]=V);let te;t[27]!==g||t[28]!==V?(te=(0,q.jsx)(`span`,{className:V,children:g}),t[27]=g,t[28]=V,t[29]=te):te=t[29];let ne;t[30]===b?ne=t[31]:(ne=b?(0,q.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-muted-foreground`,children:b}):null,t[30]=b,t[31]=ne);let re;t[32]!==R||t[33]!==te||t[34]!==ne?(re=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,te,ne]}),t[32]=R,t[33]=te,t[34]=ne,t[35]=re):re=t[35];let W;t[36]!==N||t[37]!==s||t[38]!==c||t[39]!==l||t[40]!==A||t[41]!==m||t[42]!==O||t[43]!==i?(W=i==="default"?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:[s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,q.jsx)(`span`,{className:`flex-shrink-0`,children:O}),A?(0,q.jsx)(`span`,{className:`truncate`,children:A}):null,N?(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,q.jsx)(v,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,q.jsx)(`span`,{className:`truncate`,children:N})]}):null]}):null,t[36]=N,t[37]=s,t[38]=c,t[39]=l,t[40]=A,t[41]=m,t[42]=O,t[43]=i,t[44]=W):W=t[44];let K;t[45]!==re||t[46]!==W?(K=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[re,W]}),t[45]=re,t[46]=W,t[47]=K):K=t[47];let J;t[48]!==C||t[49]!==w||t[50]!==m?(J=C||w?(0,q.jsx)(`span`,{className:`flex h-3 w-3 flex-shrink-0 items-center justify-center self-center`,children:C?(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse`,"aria-label":m(`sessions.sidebar.session.status.active`),title:m(`sessions.sidebar.session.status.active`)}):(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`,"aria-label":m(`sessions.sidebar.session.status.unread`),title:m(`sessions.sidebar.session.status.unread`)})}):null,t[48]=C,t[49]=w,t[50]=m,t[51]=J):J=t[51];let ie;return t[52]!==L||t[53]!==K||t[54]!==J||t[55]!==P?(ie=(0,q.jsxs)(a,{onClick:P,"data-slot":`session-switcher-item`,className:F,style:L,children:[K,J]}),t[52]=L,t[53]=K,t[54]=J,t[55]=P,t[56]=ie):ie=t[56],ie}var Me=K.memo(function(e){let t=(0,G.c)(45),{visible:i,position:a}=e,o=a===void 0?`right`:a,{t:s}=ee(),[c,l]=K.useState(!1),u,d;if(t[0]===i?(u=t[1],d=t[2]):(u=()=>{if(!i)return;let e=!1;n(`desktop_get_current_window_state`).then(t=>{e||l(!!t?.maximized)}).catch(Ne);let t=e=>{let t=e.detail;l(!!t?.maximized)};return window.addEventListener(`yuri:window-maximized-changed`,t),()=>{e=!0,window.removeEventListener(`yuri:window-maximized-changed`,t)}},d=[i],t[0]=i,t[1]=u,t[2]=d),(0,K.useEffect)(u,d),!i)return null;let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=r(),t[3]=f):f=t[3];let p=f===`win32`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=_(`app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[4]=m):m=t[4];let h=m,g=o===`left`?`app-region-no-drag -ml-3 mr-2 flex h-12 shrink-0 items-center`:`app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center`,y;t[5]===g?y=t[6]:(y=_(g,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[5]=g,t[6]=y);let b=y,x;t[7]===s?x=t[8]:(x=s(`header.windowControls.groupAria`),t[7]=s,t[8]=x);let S;t[9]===s?S=t[10]:(S=s(`header.windowControls.minimize`),t[9]=s,t[10]=S);let C;t[11]===s?C=t[12]:(C=s(`header.windowControls.minimize`),t[11]=s,t[12]=C);let w;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,q.jsx)(v,{name:`subtract`,className:`h-4 w-4`}),t[13]=w):w=t[13];let T;t[14]!==C||t[15]!==S?(T=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:Pe,title:S,"aria-label":C,children:w}),t[14]=C,t[15]=S,t[16]=T):T=t[16];let E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{n(`desktop_toggle_current_window_maximized`).then(e=>l(!!e?.maximized)).catch(Fe)},t[17]=E):E=t[17];let D;t[18]!==c||t[19]!==s?(D=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[18]=c,t[19]=s,t[20]=D):D=t[20];let O;t[21]!==c||t[22]!==s?(O=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[21]=c,t[22]=s,t[23]=O):O=t[23];let k=c?`fullscreen-exit`:`checkbox-blank`,A;t[24]===k?A=t[25]:(A=(0,q.jsx)(v,{name:k,className:`h-3.5 w-3.5`}),t[24]=k,t[25]=A);let j;t[26]!==D||t[27]!==O||t[28]!==A?(j=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:E,title:D,"aria-label":O,children:A}),t[26]=D,t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=_(h,`hover:bg-status-error hover:text-status-error-foreground`),t[30]=M):M=t[30];let N;t[31]===s?N=t[32]:(N=s(`header.windowControls.close`),t[31]=s,t[32]=N);let P;t[33]===s?P=t[34]:(P=s(`header.windowControls.close`),t[33]=s,t[34]=P);let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,q.jsx)(v,{name:`close`,className:`h-4 w-4`}),t[35]=F):F=t[35];let I;t[36]!==N||t[37]!==P?(I=(0,q.jsx)(`button`,{type:`button`,className:M,onClick:Ie,title:N,"aria-label":P,children:F}),t[36]=N,t[37]=P,t[38]=I):I=t[38];let L;return t[39]!==b||t[40]!==T||t[41]!==j||t[42]!==I||t[43]!==x?(L=(0,q.jsxs)(`div`,{className:b,"aria-label":x,children:[T,j,I]}),t[39]=b,t[40]=T,t[41]=j,t[42]=I,t[43]=x,t[44]=L):L=t[44],L});function Ne(){}function Pe(){n(`desktop_minimize_current_window`)}function Fe(){}function Ie(){n(`desktop_close_current_window`)}function Le(){let e=(0,G.c)(5),n=h(Re),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),e[0]=r):r=e[0];let a=r,o;e[1]===n?o=e[2]:(o=t(n),e[1]=n,e[2]=o);let s=o,c;return e[3]===s?c=e[4]:(c={usesFramelessChrome:a,side:s},e[3]=s,e[4]=c),c}function Re(e){return e.desktopWindowControlsPosition}export{J as i,Me as n,ge as r,Le as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Y as t,j as n,k as r,ot as i}from"./platform-CiUKDeXd.js";import{H as a,ot as o,st as s}from"./vendor-base-ui-wXsskyKm.js";import{dr as c}from"./client-B_907PBv.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{s as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as d}from"./yuriEvents-BFrD5fMU.js";import{D as f,P as p}from"./runtime-file-resource-Bc_ss-sW.js";import{r as m}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as h}from"./useUIStore-C3ewjGgP.js";import{i as g,o as _}from"./session-startup-barrier-DT-hIBRf.js";import{n as v}from"./Icon-DmykXZL1.js";import{G as y,Ia as b,Mi as x,Na as S,Oi as C,Rr as w,Ti as T,f as E,qn as D,t as O}from"./ui-ee2iN869.js";import{m as k,n as A,p as j}from"./remoteProjectQueries-C8382jM8.js";import{t as ee}from"./i18n-DXc6czdR.js";import{i as M,n as N,t as P}from"./tooltip-CpTbxEOE.js";import{c as F,n as I,t as L}from"./dropdown-menu-BblI9sN2.js";import{s as R}from"./useGitStore-Bv8xmXDa.js";import{b as z,h as B,p as V}from"./pwa-CtDladgB.js";import{t as te}from"./MobileOverlayPanel-C36VWWmN.js";import{l as ne,r as re}from"./quota-CqWNkFzw.js";import{a as H,i as U}from"./sessionLookup-DQOiycHr.js";import{n as W}from"./openRemoteProjectSession-DNr74gHD.js";var G=l(),K=e(s(),1),q=o(),J=e=>{let t=(0,G.c)(179),{pending:n,totalTokens:r,percentage:i,colorPercentage:a,contextLimit:o,outputLimit:s,size:c,isMobile:l,hideIcon:u,showPercentIcon:d,appearance:f,className:p,valueClassName:m,percentIconClassName:h,onClick:g,pressed:y}=e,b=n!==void 0&&n,x=c===void 0?`default`:c,S=l!==void 0&&l,C=u!==void 0&&u,w=d!==void 0&&d,T=f===void 0?`default`:f,E=y!==void 0&&y,{t:D}=ee(),[O,k]=K.useState(!1),A=typeof a==`number`?a:i,j,F,I,L,R,z,B,V,H,U,W,J,oe,Y,X,se,ce,Z,le,Q,$;if(t[0]!==T||t[1]!==A||t[2]!==o||t[3]!==S||t[4]!==g||t[5]!==s||t[6]!==b||t[7]!==h||t[8]!==i||t[9]!==D||t[10]!==r){let e=b?0:re(i)??0;U=T===`subtle`;let n=ne(A);W=U||b?`var(--surface-muted-foreground)`:n===`critical`?`var(--status-error)`:n===`warn`?`var(--status-warning)`:`var(--status-success)`,B=ie;let a;t[32]===b?a=t[33]:(a=e=>b?`text-muted-foreground`:e>=90?`text-status-error`:e>=75?`text-status-warning`:`text-status-success`,t[32]=b,t[33]=a),V=a,L=U?18:20,R=U?2:3,I=(L-R)/2,j=2*Math.PI*I,F=j*(1-e/100),J=typeof s==`number`?Math.max(s,0):0;let c;t[34]!==o||t[35]!==b||t[36]!==i||t[37]!==J||t[38]!==D||t[39]!==r?(Q=b?D(`contextUsage.pending`):`${Math.min(i,999).toFixed(1)}%`,$=b?`—`:B(r),z=B(o),c=b?[D(`contextUsage.pendingDescription`)]:[D(`contextUsage.tooltip.usage`,{percent:Q}),D(`contextUsage.tooltip.usedOfLimit`,{used:$,limit:z}),D(`contextUsage.tooltip.outputLimit`,{tokens:B(J)})],t[34]=o,t[35]=b,t[36]=i,t[37]=J,t[38]=D,t[39]=r,t[40]=z,t[41]=c,t[42]=Q,t[43]=$):(z=t[40],c=t[41],Q=t[42],$=t[43]),le=c,H=!S&&typeof g==`function`,ce=`0 0 ${L} ${L}`;let l=U?`h-4 w-4 shrink-0 -rotate-90 text-muted-foreground/70`:`h-3.5 w-3.5 -rotate-90`;t[44]!==h||t[45]!==l?(Z=_(l,h),t[44]=h,t[45]=l,t[46]=Z):Z=t[46],oe=`progressbar`,t[47]===D?Y=t[48]:(Y=D(`contextUsage.aria.label`),t[47]=D,t[48]=Y),t[49]!==b||t[50]!==D?(X=b?D(`contextUsage.pending`):void 0,t[49]=b,t[50]=D,t[51]=X):X=t[51],se=b?void 0:Math.round(e),t[0]=T,t[1]=A,t[2]=o,t[3]=S,t[4]=g,t[5]=s,t[6]=b,t[7]=h,t[8]=i,t[9]=D,t[10]=r,t[11]=j,t[12]=F,t[13]=I,t[14]=L,t[15]=R,t[16]=z,t[17]=B,t[18]=V,t[19]=H,t[20]=U,t[21]=W,t[22]=J,t[23]=oe,t[24]=Y,t[25]=X,t[26]=se,t[27]=ce,t[28]=Z,t[29]=le,t[30]=Q,t[31]=$}else j=t[11],F=t[12],I=t[13],L=t[14],R=t[15],z=t[16],B=t[17],V=t[18],H=t[19],U=t[20],W=t[21],J=t[22],oe=t[23],Y=t[24],X=t[25],se=t[26],ce=t[27],Z=t[28],le=t[29],Q=t[30],$=t[31];let ue=L/2,de=L/2,fe;t[52]!==I||t[53]!==R||t[54]!==ue||t[55]!==de?(fe=(0,q.jsx)(`circle`,{cx:ue,cy:de,r:I,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:R}),t[52]=I,t[53]=R,t[54]=ue,t[55]=de,t[56]=fe):fe=t[56];let pe=L/2,me=L/2,he;t[57]!==j||t[58]!==F||t[59]!==I||t[60]!==R||t[61]!==W||t[62]!==pe||t[63]!==me?(he=(0,q.jsx)(`circle`,{cx:pe,cy:me,r:I,fill:`none`,stroke:W,strokeWidth:R,strokeLinecap:`round`,strokeDasharray:j,strokeDashoffset:F,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[57]=j,t[58]=F,t[59]=I,t[60]=R,t[61]=W,t[62]=pe,t[63]=me,t[64]=he):he=t[64];let ge;t[65]!==oe||t[66]!==Y||t[67]!==X||t[68]!==se||t[69]!==fe||t[70]!==he||t[71]!==ce||t[72]!==Z?(ge=(0,q.jsxs)(`svg`,{viewBox:ce,className:Z,role:oe,"aria-label":Y,"aria-valuetext":X,"aria-valuenow":se,"aria-valuemin":0,"aria-valuemax":100,children:[fe,he]}),t[65]=oe,t[66]=Y,t[67]=X,t[68]=se,t[69]=fe,t[70]=he,t[71]=ce,t[72]=Z,t[73]=ge):ge=t[73];let _e=ge,ve=E||b?`ml-1 max-w-[14rem] opacity-100`:`ml-0 max-w-0 opacity-0 group-hover:ml-1 group-hover:max-w-[14rem] group-hover:opacity-100 group-focus-visible:ml-1 group-focus-visible:max-w-[14rem] group-focus-visible:opacity-100`,ye;t[74]===ve?ye=t[75]:(ye=_(`inline-flex items-center gap-1.5 overflow-hidden whitespace-nowrap typography-micro font-medium text-foreground transition-[max-width,opacity,margin] duration-200`,ve),t[74]=ve,t[75]=ye);let be;t[76]===Q?be=t[77]:(be=(0,q.jsx)(`span`,{children:Q}),t[76]=Q,t[77]=be);let xe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,q.jsx)(`span`,{className:`mx-0.5 text-muted-foreground/60`,children:`/`}),t[78]=xe):xe=t[78];let Se;t[79]!==z||t[80]!==$?(Se=(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[$,xe,z]}),t[79]=z,t[80]=$,t[81]=Se):Se=t[81];let Ce;t[82]!==ye||t[83]!==be||t[84]!==Se?(Ce=(0,q.jsxs)(`span`,{className:ye,children:[be,Se]}),t[82]=ye,t[83]=be,t[84]=Se,t[85]=Ce):Ce=t[85];let we=Ce,Te;t[86]!==A||t[87]!==V||t[88]!==C||t[89]!==S||t[90]!==U||t[91]!==b||t[92]!==i||t[93]!==_e||t[94]!==w||t[95]!==we||t[96]!==Q||t[97]!==m?(Te=U?(0,q.jsxs)(q.Fragment,{children:[_e,we]}):(0,q.jsxs)(q.Fragment,{children:[!S&&!C&&(0,q.jsx)(v,{name:`donut-chart`,className:`h-4 w-4 flex-shrink-0`}),(0,q.jsx)(`span`,{className:_(`font-medium inline-flex items-center gap-1.5`,m),children:b?(0,q.jsxs)(q.Fragment,{children:[w&&_e,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:Q})]}):w?(0,q.jsxs)(q.Fragment,{children:[_e,(0,q.jsx)(`span`,{className:`text-foreground`,children:Q})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:V(A),children:Math.min(i,999).toFixed(1)}),`%`]})})]}),t[86]=A,t[87]=V,t[88]=C,t[89]=S,t[90]=U,t[91]=b,t[92]=i,t[93]=_e,t[94]=w,t[95]=we,t[96]=Q,t[97]=m,t[98]=Te):Te=t[98];let Ee=Te,De=U?`gap-0`:`gap-1.5`,Oe=x===`compact`?`typography-micro`:`typography-meta`,ke;t[99]!==p||t[100]!==H||t[101]!==U||t[102]!==E||t[103]!==De||t[104]!==Oe?(ke=_(`app-region-no-drag flex items-center select-none`,De,Oe,H?_(`group rounded-md text-foreground transition-colors`,U?_(`p-1.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50`,E&&`bg-interactive-hover/50 text-foreground`):`px-2 py-1.5 hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`):`text-muted-foreground/60`,p),t[99]=p,t[100]=H,t[101]=U,t[102]=E,t[103]=De,t[104]=Oe,t[105]=ke):ke=t[105];let Ae=ke,je;t[106]!==Ee||t[107]!==H||t[108]!==S||t[109]!==g||t[110]!==E||t[111]!==Ae||t[112]!==D?(je=H?(0,q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":D(`contextUsage.aria.label`),"aria-pressed":E,onClick:g,children:Ee}):(0,q.jsx)(`div`,{className:Ae,"aria-label":D(`contextUsage.aria.label`),onClick:S?()=>k(!0):void 0,children:Ee}),t[106]=Ee,t[107]=H,t[108]=S,t[109]=g,t[110]=E,t[111]=Ae,t[112]=D,t[113]=je):je=t[113];let Me=je;if(S){let e;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>k(!1),t[114]=e):e=t[114];let n;t[115]===D?n=t[116]:(n=D(`contextUsage.mobile.title`),t[115]=D,t[116]=n);let r;t[117]===D?r=t[118]:(r=D(`contextUsage.mobile.usedTokens`),t[117]=D,t[118]=r);let i;t[119]===r?i=t[120]:(i=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[119]=r,t[120]=i);let a;t[121]===$?a=t[122]:(a=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:$}),t[121]=$,t[122]=a);let o;t[123]!==i||t[124]!==a?(o=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[i,a]}),t[123]=i,t[124]=a,t[125]=o):o=t[125];let s;t[126]===D?s=t[127]:(s=D(`contextUsage.mobile.contextLimit`),t[126]=D,t[127]=s);let c;t[128]===s?c=t[129]:(c=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s}),t[128]=s,t[129]=c);let l;t[130]===z?l=t[131]:(l=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:z}),t[130]=z,t[131]=l);let u;t[132]!==c||t[133]!==l?(u=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[c,l]}),t[132]=c,t[133]=l,t[134]=u):u=t[134];let d;t[135]===D?d=t[136]:(d=D(`contextUsage.mobile.outputLimit`),t[135]=D,t[136]=d);let f;t[137]===d?f=t[138]:(f=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d}),t[137]=d,t[138]=f);let p;t[139]!==B||t[140]!==J?(p=B(J),t[139]=B,t[140]=J,t[141]=p):p=t[141];let m;t[142]===p?m=t[143]:(m=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:p}),t[142]=p,t[143]=m);let h;t[144]!==f||t[145]!==m?(h=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[f,m]}),t[144]=f,t[145]=m,t[146]=h):h=t[146];let g;t[147]===D?g=t[148]:(g=D(`contextUsage.mobile.usage`),t[147]=D,t[148]=g);let v;t[149]===g?v=t[150]:(v=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:g}),t[149]=g,t[150]=v);let y;t[151]!==A||t[152]!==V?(y=_(`typography-meta font-semibold`,V(A)),t[151]=A,t[152]=V,t[153]=y):y=t[153];let b;t[154]!==y||t[155]!==Q?(b=(0,q.jsx)(`span`,{className:y,children:Q}),t[154]=y,t[155]=Q,t[156]=b):b=t[156];let x;t[157]!==v||t[158]!==b?(x=(0,q.jsxs)(`div`,{className:`flex justify-between items-center pt-1 border-t border-border/40`,children:[v,b]}),t[157]=v,t[158]=b,t[159]=x):x=t[159];let S;t[160]!==o||t[161]!==u||t[162]!==h||t[163]!==x?(S=(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1`,children:[o,u,h,x]})}),t[160]=o,t[161]=u,t[162]=h,t[163]=x,t[164]=S):S=t[164];let C;t[165]!==O||t[166]!==n||t[167]!==S?(C=(0,q.jsx)(te,{open:O,onClose:e,title:n,children:S}),t[165]=O,t[166]=n,t[167]=S,t[168]=C):C=t[168];let w;return t[169]!==Me||t[170]!==C?(w=(0,q.jsxs)(q.Fragment,{children:[Me,C]}),t[169]=Me,t[170]=C,t[171]=w):w=t[171],w}if(U)return Me;let Ne;t[172]===Me?Ne=t[173]:(Ne=(0,q.jsx)(M,{asChild:!0,children:Me}),t[172]=Me,t[173]=Ne);let Pe;t[174]===le?Pe=t[175]:(Pe=(0,q.jsx)(N,{children:(0,q.jsx)(`div`,{className:`space-y-0.5`,children:le.map(ae)})}),t[174]=le,t[175]=Pe);let Fe;return t[176]!==Ne||t[177]!==Pe?(Fe=(0,q.jsxs)(P,{children:[Ne,Pe]}),t[176]=Ne,t[177]=Pe,t[178]=Fe):Fe=t[178],Fe};function ie(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(1).replace(/\.0$/,``)}function ae(e){return(0,q.jsx)(`p`,{className:`typography-micro leading-tight`,children:e},e)}var oe=7,Y=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},X=e=>{if(!e)return null;let t=e.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},se=(e,t)=>{let n=(0,G.c)(32),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{scopeProjectId:i}=r,a=i===void 0?null:i,o=C(ce),s=S(Z),c=x(),l;n[2]===s?l=n[3]:(l=s.map(le).filter(Q),n[2]=s,n[3]=l);let u=l,d;n[4]===u?d=n[5]:(d=e=>e?u.filter(t=>z(e,t.normalizedPath)).sort($)[0]??null:null,n[4]=u,n[5]=d);let f=d,p;bb0:{if(!e){let e;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[6]=e):e=n[6],p=e;break bb0}let t;if(n[7]!==o||n[8]!==f||n[9]!==c||n[10]!==a){let e;n[12]!==f||n[13]!==a?(e=e=>!a||f(T(e))?.id===a,n[12]=f,n[13]=a,n[14]=e):e=n[14];let r;n[15]===c?r=n[16]:(r=(e,t)=>V(e,t,c),n[15]=c,n[16]=r),t=Array.from(new Set(o.filter(ue).filter(de).filter(e).sort(r).slice(0,oe).map(fe).filter(pe))),n[7]=o,n[8]=f,n[9]=c,n[10]=a,n[11]=t}else t=n[11];p=t}let m=p,h;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,n[17]=h):h=n[17];let g=K.useRef(h),_;n[18]===m?_=n[19]:(_=e=>{let t=g.current,n=t.size===m.length;if(n){for(let r of m)if(t.get(r)!==(e.directories.get(r)?.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;return m.forEach(t=>r.set(t,e.directories.get(t)?.status?.current??null)),g.current=r,r},n[18]=m,n[19]=_);let v=R(_),y;bb1:{if(!e){let e;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[20]=e):e=n[20],y=e;break bb1}let t;if(n[21]!==o||n[22]!==v||n[23]!==f||n[24]!==c||n[25]!==a){let e=new Map;for(let t of o){let n=t.parentID;if(!n||t.time?.archived)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}e.forEach(e=>{e.sort((e,t)=>V(e,t,c))});let r;n[27]!==f||n[28]!==a?(r=e=>{if(!a)return!0;let t=T(e);return f(t)?.id===a},n[27]=f,n[28]=a,n[29]=r):r=n[29];let i;n[30]===c?i=n[31]:(i=(e,t)=>V(e,t,c),n[30]=c,n[31]=i);let s=o.filter(me).filter(he).filter(r).sort(i).slice(0,oe),l=t=>({session:t,children:(e.get(t.id)??[]).map(e=>l(e)),worktree:null});t=s.map(e=>{let t=T(e),n=f(t),r=X(n),i=t?v.get(t)??null:null;return{node:l(e),projectId:n?.id??null,groupDirectory:t,secondaryMeta:{projectLabel:r,branchLabel:i&&i!==r?i:null}}}),n[21]=o,n[22]=v,n[23]=f,n[24]=c,n[25]=a,n[26]=t}else t=n[26];y=t}return y};function ce(e){return e.activeSessions}function Z(e){return e.projects}function le(e){return{...e,normalizedPath:Y(e.path)}}function Q(e){return e.normalizedPath}function $(e,t){return(t.normalizedPath?.length??0)-(e.normalizedPath?.length??0)}function ue(e){return!e.time?.archived}function de(e){return!e.parentID}function fe(e){return T(e)}function pe(e){return!!e}function me(e){return!e.time?.archived}function he(e){return!e.parentID}function ge(e){let t=(0,G.c)(18),{children:n,variant:r,scopeProjectId:i,align:a}=e,o=r===void 0?`default`:r,s=i===void 0?null:i,c=a===void 0?`start`:a,l=h(ve),u=h(_e),d;t[0]===n?d=t[1]:(d=(0,q.jsx)(F,{asChild:!0,children:n}),t[0]=n,t[1]=d);let f=o===`compact`?`w-[280px]`:`w-[360px]`,p;t[2]===f?p=t[3]:(p=_(`overflow-hidden p-1 max-w-[calc(100vw-32px)]`,f),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==s||t[6]!==u||t[7]!==o?(m=l?(0,q.jsx)(ye,{onSelect:()=>u(!1),variant:o,scopeProjectId:s}):null,t[4]=l,t[5]=s,t[6]=u,t[7]=o,t[8]=m):m=t[8];let g;t[9]!==c||t[10]!==p||t[11]!==m?(g=(0,q.jsx)(I,{align:c,sideOffset:6,className:p,children:m}),t[9]=c,t[10]=p,t[11]=m,t[12]=g):g=t[12];let v;return t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==g?(v=(0,q.jsxs)(L,{open:l,onOpenChange:u,modal:!1,children:[d,g]}),t[13]=l,t[14]=u,t[15]=d,t[16]=g,t[17]=v):v=t[17],v}function _e(e){return e.setSessionDropdownOpen}function ve(e){return e.isSessionDropdownOpen}function ye(e){let t=(0,G.c)(7),{onSelect:n,variant:r,scopeProjectId:i}=e,a;t[0]===i?a=t[1]:(a=e=>e.projects.find(t=>t.id===(i??e.activeProjectId)),t[0]=i,t[1]=a);let o=S(a),s;return t[2]!==n||t[3]!==o||t[4]!==i||t[5]!==r?(s=o?.hostId?(0,q.jsx)(Ce,{projectId:o.id,hostId:o.hostId,hubId:o.hubId,onSelect:n,variant:r},`${o.hubId}:${o.hostId}:${o.id}`):(0,q.jsx)(be,{onSelect:n,variant:r,scopeProjectId:i}),t[2]=n,t[3]=o,t[4]=i,t[5]=r,t[6]=s):s=t[6],s}function be(e){let t=(0,G.c)(27),{onSelect:n,variant:r,scopeProjectId:i}=e,o;t[0]===i?o=t[1]:(o={scopeProjectId:i},t[0]=i,t[1]=o);let s=se(!0,o),c=E(Se),l=h(xe),{t:u}=ee(),d;t[2]!==n||t[3]!==c||t[4]!==l?(d=()=>{l(`chat`),n(),c()},t[2]=n,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=m(d),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=new Set,t[6]=p):p=t[6];let[g,y]=K.useState(p),b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[7]=b):b=t[7];let x=m(b),S,C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=_(`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),C=(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),t[8]=S,t[9]=C):(S=t[8],C=t[9]);let w;t[10]===u?w=t[11]:(w=u(`sessions.sidebar.header.actions.newSession`),t[10]=u,t[11]=w);let T;t[12]===w?T=t[13]:(T=(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:w}),t[12]=w,t[13]=T);let D;t[14]!==f||t[15]!==T?(D=(0,q.jsxs)(a,{onClick:f,className:S,children:[C,T]}),t[14]=f,t[15]=T,t[16]=D):D=t[16];let O;t[17]!==g||t[18]!==s||t[19]!==n||t[20]!==u||t[21]!==x||t[22]!==r?(O=s.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:u(`sessions.switcher.empty`)}):s.map(e=>(0,q.jsx)(De,{item:e,depth:0,variant:r,expandedParents:g,toggleParent:x,closeDropdown:n},e.node.session.id)),t[17]=g,t[18]=s,t[19]=n,t[20]=u,t[21]=x,t[22]=r,t[23]=O):O=t[23];let k;return t[24]!==O||t[25]!==D?(k=(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[D,O]})}),t[24]=O,t[25]=D,t[26]=k):k=t[26],k}function xe(e){return e.setActiveMainTab}function Se(e){return e.openNewSessionDraft}function Ce(e){let t=(0,G.c)(24),{projectId:n,hostId:r,hubId:i,onSelect:a,variant:o}=e,s=k(!0),c;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==s.catalog?.hubId||t[4]!==s.catalog?.projects?(c=!i||i===s.catalog?.hubId?s.catalog?.projects.find(e=>e.id===n&&e.hostId===r):void 0,t[0]=r,t[1]=i,t[2]=n,t[3]=s.catalog?.hubId,t[4]=s.catalog?.projects,t[5]=c):c=t[5];let l=c,{t:u}=ee(),d=m(we),f;t[6]!==l||t[7]!==s.error?.message||t[8]!==s.isPending||t[9]!==s.registry||t[10]!==u?(f=s.error?.message??(!s.isPending&&(!s.registry||!l)?u(`remoteProjects.host-unavailable`):void 0),t[6]=l,t[7]=s.error?.message,t[8]=s.isPending,t[9]=s.registry,t[10]=u,t[11]=f):f=t[11];let p=f,h,_;t[12]!==p||t[13]!==r||t[14]!==i?(h=()=>{p&&O.error(p,{id:`remote-switcher:${i}:${r}:catalog`})},_=[p,i,r],t[12]=p,t[13]=r,t[14]=i,t[15]=h,t[16]=_):(h=t[15],_=t[16]),K.useEffect(h,_);let v;return t[17]!==a||t[18]!==l||t[19]!==d||t[20]!==s.registry||t[21]!==u||t[22]!==o?(v=s.registry&&l?(0,q.jsx)(Te,{registry:s.registry,project:l,onSelect:a,variant:o}):(0,q.jsx)(`div`,{className:`px-3 py-4`,children:(0,q.jsx)(g,{size:`xs`,variant:`ghost`,onClick:()=>void d(),children:u(`remoteProjects.retry`)})}),t[17]=a,t[18]=l,t[19]=d,t[20]=s.registry,t[21]=u,t[22]=o,t[23]=v):v=t[23],v}async function we(){try{await A()}catch(e){let t=e;O.error(t instanceof Error?t.message:String(t))}}function Te({registry:e,project:t,onSelect:n,variant:r}){let{t:i}=ee(),o=f(e,t.hostId),s=j(e,t.hostId),c=S(e=>e.projects),l=b(e=>e.remoteSession),u=h(e=>e.isMobile),d=s.data,g=o?.state===`connected`&&t.remoteState===`ok`&&!d?.stale,_=K.useMemo(()=>{let n=new Set(d?.pinnedSessionIds??[]),r=new Map,i=n=>(r.has(n)||r.set(n,p(c,e.hubId,t.hostId,n,d?.worktrees)?.id===t.id),r.get(n));return(d?.directories??[]).flatMap(({directory:e,sessions:t})=>t.filter(e=>!e.parentID&&!e.time.archived).map(t=>({session:t,directory:t.directory||e}))).filter(({directory:e})=>i(e)).sort((e,t)=>V(e.session,t.session,n)).slice(0,7)},[d,c,t.hostId,t.id,e.hubId]),y=s.error?.message,{refetch:x}=s;K.useEffect(()=>{y&&O.error(y,{id:`remote-project:${t.id}:load`,action:{label:i(`remoteProjects.retry`),onClick:()=>void x()}})},[y,t.id,x,i]);let C=m((r,a)=>{try{if(p(c,e.hubId,t.hostId,a,d?.worktrees)?.id!==t.id)throw Error(i(`remoteProjects.host-unavailable`));W(t,e,r,a,u),n()}catch(e){O.error(e instanceof Error?e.message:String(e))}}),w=l?.projectId===t.id&&l.location.hostId===t.hostId&&l.location.hubId===e.hubId?l.location.directory:t.path;return(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsxs)(a,{onClick:()=>C(null,w),className:`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`,children:[(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:i(`sessions.sidebar.header.actions.newSession`)})]}),g?null:(0,q.jsxs)(`div`,{role:`status`,className:`px-3 typography-meta text-muted-foreground`,children:[i(`remoteProjects.state.${o?.state??`offline`}`),` · `,i(`remoteProjects.unknown`)]}),!_.length&&d?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`sessions.switcher.empty`)}):null,_.map(({session:n,directory:i})=>(0,q.jsx)(Ee,{registry:e,project:t,projects:c,session:n,directory:i,variant:r,snapshot:d,online:g,navigate:C,selected:l,depth:0,ancestors:[]},`${i}:${n.id}`))]})})}function Ee({registry:e,project:t,projects:n,session:r,directory:i,variant:a,snapshot:o,online:s,navigate:l,selected:f,depth:h,ancestors:_}){let{t:v}=ee(),[y,b]=K.useState(!1),[x,S]=K.useState(30),C=e.resolve({hubId:e.hubId,hostId:t.hostId,directory:i}),w=K.useMemo(()=>({...D(i,void 0,void 0,void 0,C),enabled:!1,staleTime:1/0,gcTime:1/0}),[C,i]),T=u(w,d).data?.current,E=u({queryKey:[...C.queryScope,`navigation-children`,r.id,x],enabled:y&&s,staleTime:3e4,gcTime:1/0,placeholderData:(e,t)=>t&&C.queryScope.every((e,n)=>t.queryKey[n]===e)&&t.queryKey[C.queryScope.length+1]===r.id?e:void 0,queryFn:async({signal:t})=>{let n=[],a,o=!1;for(let s=0;s<Math.ceil(x/30);s++){let s=await C.sdk().session.list({directory:i,parentID:r.id,limit:30,...a?{cursor:a}:{}},{signal:t});if(e.assertCurrent(),C.sdk(),!Array.isArray(s.data))throw Error(`Remote child session list returned no data`);n.push(...s.data.map(c).filter(e=>!e.time?.archived).map(e=>({...e,directory:e.directory||i,time:e.time??{}})));let l=s.cursor?.next||void 0;if(o=!!(l&&l!==a),!o)break;a=l}return{sessions:n,hasMore:o}}},d),{error:k,refetch:A}=E;K.useEffect(()=>{k&&O.error(k.message,{id:`remote-children:${C.key}:${r.id}`,action:{label:v(`remoteProjects.retry`),onClick:()=>void A()}})},[k,C.key,r.id,A,v]);let j=m(({directory:e,payload:t})=>{e&&e!==i||t&&typeof t==`object`&&`type`in t&&typeof t.type==`string`&&/^(session\.(created|updated|deleted|status)|yuri:session-metadata)$/.test(t.type)&&d.invalidateQueries({queryKey:[...C.queryScope,`navigation-children`,r.id,x],exact:!0})});K.useEffect(()=>{if(y&&s)return e.subscribeEvents(t.hostId,j)},[e,t.hostId,i,y,s,j]);let M=o?.directories.flatMap(e=>e.sessions.filter(e=>e.parentID===r.id).map(t=>({...t,directory:t.directory||e.directory})))??[],N=(E.data?.sessions??M).filter(a=>a.id!==r.id&&!_.includes(a.id)&&p(n,e.hubId,t.hostId,a.directory||i,o?.worktrees)?.id===t.id),P=r.metadata?.yuri?.sessionStatus?.type,F=f?.projectId===t.id&&f.location.hubId===e.hubId&&f.location.hostId===t.hostId&&f.location.directory===i&&f.sessionId===r.id;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(je,{session:r,depth:h,variant:a,secondaryMeta:{projectLabel:t.label??t.path.split(/[\\/]/).filter(Boolean).at(-1),branchLabel:T},hasChildren:!!(r.hasChildren||N.length||h>0),isExpanded:y,onToggleExpand:()=>b(e=>!e),isActive:F,unseenCount:o?.unread?.sessions[r.id]?.unreadCount??0,statusType:s?P??`idle`:`unknown`,handleSelect:()=>l(r.id,i)}),y?(0,q.jsxs)(q.Fragment,{children:[N.map(c=>(0,q.jsx)(Ee,{registry:e,project:t,projects:n,variant:a,snapshot:o,online:s,navigate:l,selected:f,directory:c.directory||i,session:c,depth:h+1,ancestors:[..._,r.id]},c.id)),E.data?.hasMore?(0,q.jsx)(g,{size:`xs`,variant:`ghost`,disabled:!s||E.isFetching,onClick:()=>S(e=>e+30),children:v(`remoteProjects.showMore`)}):null]}):null]})}function De(e){let t=(0,G.c)(31),{item:n,depth:r,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s}=e,{node:c,secondaryMeta:l}=n,u=c.session,d=c.children.length>0,f;t[0]!==a||t[1]!==u.id?(f=a.has(u.id),t[0]=a,t[1]=u.id,t[2]=f):f=t[2];let p=f,m;t[3]!==d||t[4]!==u.id||t[5]!==o?(m=d?()=>o(u.id):void 0,t[3]=d,t[4]=u.id,t[5]=o,t[6]=m):m=t[6];let h;t[7]!==s||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==u||t[13]!==m||t[14]!==i?(h=(0,q.jsx)(Oe,{session:u,depth:r,variant:i,secondaryMeta:l,hasChildren:d,isExpanded:p,onToggleExpand:m,closeDropdown:s}),t[7]=s,t[8]=r,t[9]=d,t[10]=p,t[11]=l,t[12]=u,t[13]=m,t[14]=i,t[15]=h):h=t[15];let g;t[16]!==s||t[17]!==r||t[18]!==a||t[19]!==d||t[20]!==p||t[21]!==n.groupDirectory||t[22]!==n.projectId||t[23]!==c.children||t[24]!==l||t[25]!==o||t[26]!==i?(g=d&&p?c.children.map(e=>(0,q.jsx)(De,{item:{node:e,projectId:n.projectId,groupDirectory:n.groupDirectory,secondaryMeta:l},depth:r+1,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s},e.session.id)):null,t[16]=s,t[17]=r,t[18]=a,t[19]=d,t[20]=p,t[21]=n.groupDirectory,t[22]=n.projectId,t[23]=c.children,t[24]=l,t[25]=o,t[26]=i,t[27]=g):g=t[27];let _;return t[28]!==h||t[29]!==g?(_=(0,q.jsxs)(q.Fragment,{children:[h,g]}),t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function Oe(e){let t=(0,G.c)(17),{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,closeDropdown:l}=e,u=E(Ae),d=E(ke),f=y(n.id),p=w(n.id),h=u===n.id,g;t[0]!==l||t[1]!==h||t[2]!==n||t[3]!==d?(g=()=>{h||d(n.id,T(n)??null),l()},t[0]=l,t[1]=h,t[2]=n,t[3]=d,t[4]=g):g=t[4];let _=m(g),v=f?.type??`idle`,b;return t[5]!==r||t[6]!==_||t[7]!==o||t[8]!==h||t[9]!==s||t[10]!==c||t[11]!==a||t[12]!==n||t[13]!==v||t[14]!==p||t[15]!==i?(b=(0,q.jsx)(je,{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,isActive:h,unseenCount:p,statusType:v,handleSelect:_}),t[5]=r,t[6]=_,t[7]=o,t[8]=h,t[9]=s,t[10]=c,t[11]=a,t[12]=n,t[13]=v,t[14]=p,t[15]=i,t[16]=b):b=t[16],b}function ke(e){return e.setCurrentSession}function Ae(e){return e.currentSessionId}function je(e){let t=(0,G.c)(57),{session:n,depth:r,variant:i,secondaryMeta:o,hasChildren:s,isExpanded:c,onToggleExpand:l,isActive:u,unseenCount:d,statusType:f,handleSelect:p}=e,{t:m}=ee(),h;t[0]!==n.title||t[1]!==m?(h=n.title?.trim()||m(`sessions.sidebar.session.untitled`),t[0]=n.title,t[1]=m,t[2]=h):h=t[2];let g=h,y;t[3]===n?y=t[4]:(y=U(H(n)),t[3]=n,t[4]=y);let b=y,x=!!n.parentID,S=d>0&&!x,C=f===`busy`||f===`retry`,w=!C&&S,T;t[5]!==n.time?.created||t[6]!==n.time?.updated?(T=n.time?.updated||n.time?.created||Date.now(),t[5]=n.time?.created,t[6]=n.time?.updated,t[7]=T):T=t[7];let E=T,D;t[8]===E?D=t[9]:(D=B(E),t[8]=E,t[9]=D);let O=D,k;t[10]===o?.projectLabel?k=t[11]:(k=o?.projectLabel?.trim()||null,t[10]=o?.projectLabel,t[11]=k);let A=k,j;t[12]===o?.branchLabel?j=t[13]:(j=o?.branchLabel?.trim()||null,t[12]=o?.branchLabel,t[13]=j);let M=j,N=M&&M!==`HEAD`?M:null,P;t[14]===p?P=t[15]:(P=e=>{if(e.target?.closest(`[data-switcher-expand]`)){e.preventDefault();return}p()},t[14]=p,t[15]=P);let F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=_(`group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),t[16]=F):F=t[16];let I=8+r*12,L;t[17]===I?L=t[18]:(L={paddingLeft:I},t[17]=I,t[18]=L);let R;t[19]!==s||t[20]!==c||t[21]!==l||t[22]!==m||t[23]!==i?(R=i===`compact`&&s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3.5 w-3.5`})}):null,t[19]=s,t[20]=c,t[21]=l,t[22]=m,t[23]=i,t[24]=R):R=t[24];let z=u?`text-primary`:`text-foreground`,V;t[25]===z?V=t[26]:(V=_(`min-w-0 truncate text-[14px] font-normal leading-tight`,z),t[25]=z,t[26]=V);let te;t[27]!==g||t[28]!==V?(te=(0,q.jsx)(`span`,{className:V,children:g}),t[27]=g,t[28]=V,t[29]=te):te=t[29];let ne;t[30]===b?ne=t[31]:(ne=b?(0,q.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-muted-foreground`,children:b}):null,t[30]=b,t[31]=ne);let re;t[32]!==R||t[33]!==te||t[34]!==ne?(re=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,te,ne]}),t[32]=R,t[33]=te,t[34]=ne,t[35]=re):re=t[35];let W;t[36]!==N||t[37]!==s||t[38]!==c||t[39]!==l||t[40]!==A||t[41]!==m||t[42]!==O||t[43]!==i?(W=i==="default"?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:[s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,q.jsx)(`span`,{className:`flex-shrink-0`,children:O}),A?(0,q.jsx)(`span`,{className:`truncate`,children:A}):null,N?(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,q.jsx)(v,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,q.jsx)(`span`,{className:`truncate`,children:N})]}):null]}):null,t[36]=N,t[37]=s,t[38]=c,t[39]=l,t[40]=A,t[41]=m,t[42]=O,t[43]=i,t[44]=W):W=t[44];let K;t[45]!==re||t[46]!==W?(K=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[re,W]}),t[45]=re,t[46]=W,t[47]=K):K=t[47];let J;t[48]!==C||t[49]!==w||t[50]!==m?(J=C||w?(0,q.jsx)(`span`,{className:`flex h-3 w-3 flex-shrink-0 items-center justify-center self-center`,children:C?(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse`,"aria-label":m(`sessions.sidebar.session.status.active`),title:m(`sessions.sidebar.session.status.active`)}):(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`,"aria-label":m(`sessions.sidebar.session.status.unread`),title:m(`sessions.sidebar.session.status.unread`)})}):null,t[48]=C,t[49]=w,t[50]=m,t[51]=J):J=t[51];let ie;return t[52]!==L||t[53]!==K||t[54]!==J||t[55]!==P?(ie=(0,q.jsxs)(a,{onClick:P,"data-slot":`session-switcher-item`,className:F,style:L,children:[K,J]}),t[52]=L,t[53]=K,t[54]=J,t[55]=P,t[56]=ie):ie=t[56],ie}var Me=K.memo(function(e){let t=(0,G.c)(45),{visible:i,position:a}=e,o=a===void 0?`right`:a,{t:s}=ee(),[c,l]=K.useState(!1),u,d;if(t[0]===i?(u=t[1],d=t[2]):(u=()=>{if(!i)return;let e=!1;n(`desktop_get_current_window_state`).then(t=>{e||l(!!t?.maximized)}).catch(Ne);let t=e=>{let t=e.detail;l(!!t?.maximized)};return window.addEventListener(`yuri:window-maximized-changed`,t),()=>{e=!0,window.removeEventListener(`yuri:window-maximized-changed`,t)}},d=[i],t[0]=i,t[1]=u,t[2]=d),(0,K.useEffect)(u,d),!i)return null;let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=r(),t[3]=f):f=t[3];let p=f===`win32`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=_(`app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[4]=m):m=t[4];let h=m,g=o===`left`?`app-region-no-drag -ml-3 mr-2 flex h-12 shrink-0 items-center`:`app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center`,y;t[5]===g?y=t[6]:(y=_(g,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[5]=g,t[6]=y);let b=y,x;t[7]===s?x=t[8]:(x=s(`header.windowControls.groupAria`),t[7]=s,t[8]=x);let S;t[9]===s?S=t[10]:(S=s(`header.windowControls.minimize`),t[9]=s,t[10]=S);let C;t[11]===s?C=t[12]:(C=s(`header.windowControls.minimize`),t[11]=s,t[12]=C);let w;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,q.jsx)(v,{name:`subtract`,className:`h-4 w-4`}),t[13]=w):w=t[13];let T;t[14]!==C||t[15]!==S?(T=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:Pe,title:S,"aria-label":C,children:w}),t[14]=C,t[15]=S,t[16]=T):T=t[16];let E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{n(`desktop_toggle_current_window_maximized`).then(e=>l(!!e?.maximized)).catch(Fe)},t[17]=E):E=t[17];let D;t[18]!==c||t[19]!==s?(D=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[18]=c,t[19]=s,t[20]=D):D=t[20];let O;t[21]!==c||t[22]!==s?(O=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[21]=c,t[22]=s,t[23]=O):O=t[23];let k=c?`fullscreen-exit`:`checkbox-blank`,A;t[24]===k?A=t[25]:(A=(0,q.jsx)(v,{name:k,className:`h-3.5 w-3.5`}),t[24]=k,t[25]=A);let j;t[26]!==D||t[27]!==O||t[28]!==A?(j=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:E,title:D,"aria-label":O,children:A}),t[26]=D,t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=_(h,`hover:bg-status-error hover:text-status-error-foreground`),t[30]=M):M=t[30];let N;t[31]===s?N=t[32]:(N=s(`header.windowControls.close`),t[31]=s,t[32]=N);let P;t[33]===s?P=t[34]:(P=s(`header.windowControls.close`),t[33]=s,t[34]=P);let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,q.jsx)(v,{name:`close`,className:`h-4 w-4`}),t[35]=F):F=t[35];let I;t[36]!==N||t[37]!==P?(I=(0,q.jsx)(`button`,{type:`button`,className:M,onClick:Ie,title:N,"aria-label":P,children:F}),t[36]=N,t[37]=P,t[38]=I):I=t[38];let L;return t[39]!==b||t[40]!==T||t[41]!==j||t[42]!==I||t[43]!==x?(L=(0,q.jsxs)(`div`,{className:b,"aria-label":x,children:[T,j,I]}),t[39]=b,t[40]=T,t[41]=j,t[42]=I,t[43]=x,t[44]=L):L=t[44],L});function Ne(){}function Pe(){n(`desktop_minimize_current_window`)}function Fe(){}function Ie(){n(`desktop_close_current_window`)}function Le(){let e=(0,G.c)(5),n=h(Re),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),e[0]=r):r=e[0];let a=r,o;e[1]===n?o=e[2]:(o=t(n),e[1]=n,e[2]=o);let s=o,c;return e[3]===s?c=e[4]:(c={usesFramelessChrome:a,side:s},e[3]=s,e[4]=c),c}function Re(e){return e.desktopWindowControlsPosition}export{J as i,Me as n,ge as r,Le as t};
@@ -1 +1 @@
1
- import{St as e}from"./gitApiHttp-Dd-FwgCq.js";import{n as t}from"./vendor-react-BkccXcWz.js";import{E as n}from"./runtime-file-resource-Bc_ss-sW.js";import{Ia as r,Na as i,_ as a,b as o,f as s,tt as c}from"./ui-DrAJTWV6.js";var l=t(),u=()=>{let t=i.getState(),n=t.projects.find(e=>e.id===t.activeProjectId);if(n?.hostId){let e=r.getState().remoteSession;return e?.projectId===n.id&&e.location.hostId===n.hostId&&(!n.hubId||e.location.hubId===n.hubId)?e.location.directory:n.path}let c=s.getState(),l=c.currentSessionId,u=c.newSessionDraft,d=c.worktreeMetadata,f=e.getState().currentDirectory;if(l){let e=o.getState().getAttachment(l),t=a(e);if(t)return t;let n=d.get(l);if(n?.path)return n.path;let r=c.getDirectoryForSession(l);if(r)return r}return u?.open&&(u.bootstrapPendingDirectory||u.directoryOverride)?(u.bootstrapPendingDirectory||u.directoryOverride)??void 0:f??void 0},d=()=>{let t=(0,l.c)(15),u=n(),d=i(f),m=r(p),h=!!(u?.entry.location.hostId||d?.hostId),g;t[0]===h?g=t[1]:(g=e=>h?null:e.currentSessionId,t[0]=h,t[1]=g);let _=s(g),v;t[2]===h?v=t[3]:(v=e=>h?null:e.newSessionDraft,t[2]=h,t[3]=v);let y=s(v),b=c(_),x;t[4]===_?x=t[5]:(x=e=>_?e.getAttachment(_):void 0,t[4]=_,t[5]=x);let S=o(x),C;t[6]===h?C=t[7]:(C=e=>h?void 0:e.worktreeMetadata,t[6]=h,t[7]=C);let w=s(C),T;t[8]===h?T=t[9]:(T=e=>h?void 0:e.currentDirectory,t[8]=h,t[9]=T);let E=e(T);if(u?.entry.location.hostId)return m&&m.projectId===d?.id&&m.location.hostId===u.entry.location.hostId&&m.location.hubId===u.entry.location.hubId?m.location.directory:u.entry.location.directory;if(d?.hostId)return m?.projectId===d.id&&m.location.hostId===d.hostId&&(!d.hubId||m.location.hubId===d.hubId)?m.location.directory:d.path;if(_){let e;t[10]===S?e=t[11]:(e=a(S),t[10]=S,t[11]=e);let n=e;if(n)return n;let r;t[12]!==_||t[13]!==w?(r=w?.get(_),t[12]=_,t[13]=w,t[14]=r):r=t[14];let i=r;if(i?.path)return i.path;if(b)return b}return y?.open&&(y.bootstrapPendingDirectory||y.directoryOverride)?(y.bootstrapPendingDirectory||y.directoryOverride)??void 0:E??void 0};function f(e){return e.projects.find(t=>t.id===e.activeProjectId)}function p(e){return e.remoteSession}export{d as n,u as t};
1
+ import{St as e}from"./gitApiHttp-Dd-FwgCq.js";import{n as t}from"./vendor-react-BkccXcWz.js";import{E as n}from"./runtime-file-resource-Bc_ss-sW.js";import{Ia as r,Na as i,_ as a,b as o,f as s,tt as c}from"./ui-ee2iN869.js";var l=t(),u=()=>{let t=i.getState(),n=t.projects.find(e=>e.id===t.activeProjectId);if(n?.hostId){let e=r.getState().remoteSession;return e?.projectId===n.id&&e.location.hostId===n.hostId&&(!n.hubId||e.location.hubId===n.hubId)?e.location.directory:n.path}let c=s.getState(),l=c.currentSessionId,u=c.newSessionDraft,d=c.worktreeMetadata,f=e.getState().currentDirectory;if(l){let e=o.getState().getAttachment(l),t=a(e);if(t)return t;let n=d.get(l);if(n?.path)return n.path;let r=c.getDirectoryForSession(l);if(r)return r}return u?.open&&(u.bootstrapPendingDirectory||u.directoryOverride)?(u.bootstrapPendingDirectory||u.directoryOverride)??void 0:f??void 0},d=()=>{let t=(0,l.c)(15),u=n(),d=i(f),m=r(p),h=!!(u?.entry.location.hostId||d?.hostId),g;t[0]===h?g=t[1]:(g=e=>h?null:e.currentSessionId,t[0]=h,t[1]=g);let _=s(g),v;t[2]===h?v=t[3]:(v=e=>h?null:e.newSessionDraft,t[2]=h,t[3]=v);let y=s(v),b=c(_),x;t[4]===_?x=t[5]:(x=e=>_?e.getAttachment(_):void 0,t[4]=_,t[5]=x);let S=o(x),C;t[6]===h?C=t[7]:(C=e=>h?void 0:e.worktreeMetadata,t[6]=h,t[7]=C);let w=s(C),T;t[8]===h?T=t[9]:(T=e=>h?void 0:e.currentDirectory,t[8]=h,t[9]=T);let E=e(T);if(u?.entry.location.hostId)return m&&m.projectId===d?.id&&m.location.hostId===u.entry.location.hostId&&m.location.hubId===u.entry.location.hubId?m.location.directory:u.entry.location.directory;if(d?.hostId)return m?.projectId===d.id&&m.location.hostId===d.hostId&&(!d.hubId||m.location.hubId===d.hubId)?m.location.directory:d.path;if(_){let e;t[10]===S?e=t[11]:(e=a(S),t[10]=S,t[11]=e);let n=e;if(n)return n;let r;t[12]!==_||t[13]!==w?(r=w?.get(_),t[12]=_,t[13]=w,t[14]=r):r=t[14];let i=r;if(i?.path)return i.path;if(b)return b}return y?.open&&(y.bootstrapPendingDirectory||y.directoryOverride)?(y.bootstrapPendingDirectory||y.directoryOverride)??void 0:E??void 0};function f(e){return e.projects.find(t=>t.id===e.activeProjectId)}function p(e){return e.remoteSession}export{d as n,u as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEPKHgdL.js";import{a as r,r as i}from"./vendor-zustand-CTekDqaS.js";import{st as a}from"./vendor-base-ui-wXsskyKm.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{Jn as s,Kn as c}from"./ui-DrAJTWV6.js";var l=o(),u=e(a(),1),d=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,f=1e4,p=6e4,m=5e3,h=3e4,g=6e4,_=25,v=40,y=2,b=15e3,x=500,S=30,C=20971520,w=new Map,T=new Map,E=new Map,D=new Map,O=new Map,k=new Map,A=new WeakMap,j=e=>{let t=A.get(e);return t||(t=new Set(e.files.map(e=>e.path)),A.set(e,t)),t},M=(e,t)=>`${t}:${e}`,N=e=>T.get(e)??0,P=e=>{let t=N(e)+1;return T.set(e,t),t},F=e=>{let t=(E.get(e)??0)+1;return E.set(e,t),t},I=e=>{let t=w.get(e);if(t)return t;let n=new Set;return w.set(e,n),n},L=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),R=(e,t=S,n=C)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},z=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,B=e=>{let t=e?.trim()??``;return t===`?`?``:t},V=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&z(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),B(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&B(t.index)!==B(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),B(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},H=e=>!e||e.trim().length===0,U=e=>(e||``).trim()===`U`,W=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},G=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},K=e=>H(e.index)&&H(e.working_dir),q=r()(i((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&P(r),n&&P(n),n&&!i.has(n)){let t=new Map(i);t.set(n,L()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=M(n,a),s=D.get(o)??(a===`light`?D.get(M(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=L(),!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>p,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0),d=t().directories.get(n)??L(),f=k.get(n),m=f?.received===u&&f.stored===d.status?null:V(d.status,u);if(m?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??L(),{changedPaths:s,indexChanged:l}=m,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&P(n);let p={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:p,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),k.set(n,{received:u,stored:p})}else{k.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();D.set(o,c);try{return await c}finally{D.get(o)===c&&D.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?W(e):G(e);t!==e&&(l=!0),K(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),l=F(r);{let n=new Map(t().directories),i=n.get(r)??L();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let u=a.force?await s(r,i,void 0,o):await c(r,i,void 0,o);if(l!==E.get(r)||o!==n())return;let d=new Map(t().directories),f=d.get(r)??L();d.set(r,{...f,branches:u,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:d})}catch(i){if(d(i)||console.error(`Failed to fetch git branches:`,i),l!==E.get(r)||o!==n())return;let a=new Map(t().directories),s=a.get(r)??L();a.set(r,{...s,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=L();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>f||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??L(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=R(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{P(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,_);await t().prefetchDiffs(e,n,i,{maxFiles:_})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=v}=a,c=Math.min(Math.max(1,s),S),l=j(o.status),u=o.status.diffStats,d=I(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>x||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=N(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],C=()=>{let e=g;return g+=1,e<m.length?m[e]:null},w=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${b}ms`)),b)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},T=async()=>{for(;;){if(h!==N(n))return;let e=C();if(!e)return;try{_.push(await w(e))}catch{}finally{d.delete(e)}}},E=Math.min(y,m.length);if(await Promise.allSettled(Array.from({length:E},()=>T())),m.forEach(e=>d.delete(e)),h!==N(n))return;let D=new Map(t().directories),O=D.get(n);if(!O)return;let k=new Map(O.diffCache),A=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||k.set(e.path,{...e.diff,fetchedAt:A})});let M=R(k);D.set(n,{...O,diffCache:M}),e({directories:D})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<m||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=O.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=m)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=h)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=f)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=g)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return O.set(e,i),i.finally(()=>{O.get(e)===i&&O.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),J=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),q(n)},Y=e=>{let r=(0,l.c)(3),i=u.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],q(a)},X=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),q(n)},Z=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),q(n)},Q=e=>{let t=(0,l.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=u.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),q(i)},$=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),q(n)},ee=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),q(n)};export{Q as a,X as c,$ as i,Y as n,J as o,ee as r,q as s,Z as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEPKHgdL.js";import{a as r,r as i}from"./vendor-zustand-CTekDqaS.js";import{st as a}from"./vendor-base-ui-wXsskyKm.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{Jn as s,Kn as c}from"./ui-ee2iN869.js";var l=o(),u=e(a(),1),d=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,f=1e4,p=6e4,m=5e3,h=3e4,g=6e4,_=25,v=40,y=2,b=15e3,x=500,S=30,C=20971520,w=new Map,T=new Map,E=new Map,D=new Map,O=new Map,k=new Map,A=new WeakMap,j=e=>{let t=A.get(e);return t||(t=new Set(e.files.map(e=>e.path)),A.set(e,t)),t},M=(e,t)=>`${t}:${e}`,N=e=>T.get(e)??0,P=e=>{let t=N(e)+1;return T.set(e,t),t},F=e=>{let t=(E.get(e)??0)+1;return E.set(e,t),t},I=e=>{let t=w.get(e);if(t)return t;let n=new Set;return w.set(e,n),n},L=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),R=(e,t=S,n=C)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},z=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,B=e=>{let t=e?.trim()??``;return t===`?`?``:t},V=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&z(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),B(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&B(t.index)!==B(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),B(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},H=e=>!e||e.trim().length===0,U=e=>(e||``).trim()===`U`,W=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},G=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},K=e=>H(e.index)&&H(e.working_dir),q=r()(i((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&P(r),n&&P(n),n&&!i.has(n)){let t=new Map(i);t.set(n,L()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=M(n,a),s=D.get(o)??(a===`light`?D.get(M(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=L(),!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>p,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0),d=t().directories.get(n)??L(),f=k.get(n),m=f?.received===u&&f.stored===d.status?null:V(d.status,u);if(m?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??L(),{changedPaths:s,indexChanged:l}=m,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&P(n);let p={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:p,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),k.set(n,{received:u,stored:p})}else{k.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();D.set(o,c);try{return await c}finally{D.get(o)===c&&D.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?W(e):G(e);t!==e&&(l=!0),K(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),l=F(r);{let n=new Map(t().directories),i=n.get(r)??L();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let u=a.force?await s(r,i,void 0,o):await c(r,i,void 0,o);if(l!==E.get(r)||o!==n())return;let d=new Map(t().directories),f=d.get(r)??L();d.set(r,{...f,branches:u,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:d})}catch(i){if(d(i)||console.error(`Failed to fetch git branches:`,i),l!==E.get(r)||o!==n())return;let a=new Map(t().directories),s=a.get(r)??L();a.set(r,{...s,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=L();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>f||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??L(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=R(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{P(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,_);await t().prefetchDiffs(e,n,i,{maxFiles:_})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=v}=a,c=Math.min(Math.max(1,s),S),l=j(o.status),u=o.status.diffStats,d=I(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>x||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=N(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],C=()=>{let e=g;return g+=1,e<m.length?m[e]:null},w=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${b}ms`)),b)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},T=async()=>{for(;;){if(h!==N(n))return;let e=C();if(!e)return;try{_.push(await w(e))}catch{}finally{d.delete(e)}}},E=Math.min(y,m.length);if(await Promise.allSettled(Array.from({length:E},()=>T())),m.forEach(e=>d.delete(e)),h!==N(n))return;let D=new Map(t().directories),O=D.get(n);if(!O)return;let k=new Map(O.diffCache),A=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||k.set(e.path,{...e.diff,fetchedAt:A})});let M=R(k);D.set(n,{...O,diffCache:M}),e({directories:D})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<m||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=O.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=m)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=h)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=f)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=g)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return O.set(e,i),i.finally(()=>{O.get(e)===i&&O.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),J=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),q(n)},Y=e=>{let r=(0,l.c)(3),i=u.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],q(a)},X=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),q(n)},Z=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),q(n)},Q=e=>{let t=(0,l.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=u.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),q(i)},$=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),q(n)},ee=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),q(n)};export{Q as a,X as c,$ as i,Y as n,J as o,ee as r,q as s,Z as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEPKHgdL.js";import{n as i}from"./runtime-fetch-V-iMWR8t.js";import{I as a,P as o,n as s,y as c}from"./platform-CiUKDeXd.js";import{a as l,i as u,r as d,t as ee}from"./vendor-zustand-CTekDqaS.js";import{ot as f,st as p}from"./vendor-base-ui-wXsskyKm.js";import{t as m}from"./safeStorage-DTOhKN0V.js";import{n as h}from"./client-B_907PBv.js";import{s as g}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as _}from"./yuriEvents-BFrD5fMU.js";import{r as v}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as y}from"./useUIStore-C3ewjGgP.js";import{a as te,i as ne,n as re}from"./types-s_oc_LRs.js";import{t as ie}from"./native-config-DSpTDz3F.js";import{i as b}from"./session-startup-barrier-DT-hIBRf.js";import{n as x}from"./Icon-DmykXZL1.js";import{Na as S,Sr as ae,_r as oe,gr as se,t as C}from"./ui-DrAJTWV6.js";import{t as ce}from"./i18n-DXc6czdR.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./dialog-BeFBA6ja.js";import{t as he}from"./YuriLogo-Cp6vWDWp.js";import{_ as w,f as ge,p as _e,v as ve}from"./sessionOwnership-CEkPFbS4.js";import{a as T,c as E,s as D}from"./mcpQueries-1WNtiFYh.js";import{i as ye,n as be,r as O}from"./SettingsGroup-CvaPYznp.js";var k=e(p(),1),A=f(),xe=`https://github.com/yee94/yuri`,Se=`${xe}/issues/new`,Ce=800,we={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},j=e=>typeof e==`string`&&e.trim()?e.trim():null,M=(e,t,a)=>({queryKey:[t,`about`,a,e],queryFn:async({signal:o})=>{if(t!==n()||a!==r())throw Error(`Stale About runtime`);let s=await i(e,{method:`GET`,headers:{Accept:`application/json`},signal:o});if(!s.ok)throw Error(`About snapshot: ${s.status}`);let c=await s.json();if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid About snapshot`);if(o.aborted||t!==n()||a!==r())throw Error(`Stale About runtime`);return c},retry:!1,staleTime:3e4}),N=({initialUpdateDialogOpen:e=!1})=>{let{t:i}=ce(),[l,u]=k.useState(e),[d,f]=k.useState(!1),[p,m]=k.useState(!1),[h,_]=k.useState(null),[S,ve]=k.useState(null),T=k.useSyncExternalStore(t,n,n),E=k.useSyncExternalStore(t,r,r),D=g(M(`/api/system/info`,T,E)),N=g(M(`/api/opencode/upgrade-status`,T,E)),P=j(D.data?.yuriVersion),F=N.data,I=j(F?.serveVersion)??j(F?.currentVersion),L=j(F?.management),R=L&&Object.hasOwn(we,L)?we[L]:null,z=F?.canManage===!1&&R?i(R):null,B=I&&z?i(`settings.yuri.about.opencodeVersionWithManagement`,{version:I,management:z}):I,Te=F?.canManage===!1?L===`manual-global`?i(`settings.yuri.about.opencodeGuidance.manualGlobal`):L===`manual-external`?i(`settings.yuri.about.opencodeGuidance.manualExternal`):L===`bundled`?i(`settings.yuri.about.opencodeGuidance.bundled`):null:null,V=w(ee(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),H=y(e=>e.otaChannelOverride),U=y(e=>e.setOtaChannelOverride),W=s(),[Ee,De]=k.useState(`stable`);k.useEffect(()=>{a()&&c().then(e=>De(e?.includes(`-`)?`beta`:`stable`))},[]);let G=g({queryKey:[`native-update-config`],queryFn:ie,enabled:W,staleTime:1/0,retry:!1}),K=G.data?.channel,q=H===`beta`||H===null&&(a()?Ee:K)===`beta`,[J,Y]=k.useState(!1),[X,Z]=k.useState(()=>oe()),Oe=v(e=>{ae(e),Z(e)}),ke=v(async e=>{if(e){U(`beta`),await w.getState().checkForUpdates();return}U(`stable`),await w.getState().checkForUpdates();let{info:t,otaDecision:n}=w.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&f(!0)}),Ae=v(()=>{f(!1),U(`beta`),w.getState().checkForUpdates()}),je=v(()=>{f(!1),u(!0),w.getState().downloadUpdate()}),Me=v(e=>{e||Ae()}),Ne=h||i(`settings.yuri.about.state.unknown`),Pe=v(async()=>{if(!J){Y(!0);try{let{outcome:e,eventCount:t}=await se();if(e===`cancelled`)return;if(e===`failed`){C.error(i(`settings.yuri.about.diagnostics.toast.failed`));return}C.success(i(t>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{C.error(i(`settings.yuri.about.diagnostics.toast.failed`))}finally{Y(!1)}}});k.useEffect(()=>{let e=!1;return te().then(t=>{e||_(t)}),ne().then(t=>{e||ve(t)}),()=>{e=!0}},[]);let Fe=re(h,S)??Ne,Q=k.useRef(!1);k.useEffect(()=>{if(V.checking)m(!0),Q.current=!0;else if(p){let e=setTimeout(()=>{m(!1),Q.current&&V.error?(C.error(i(`settings.yuri.about.toast.checkFailed`),{description:V.error}),Q.current=!1):Q.current&&!V.available&&!V.error&&(C.success(i(`settings.yuri.about.toast.latestVersion`)),Q.current=!1)},Ce);return()=>clearTimeout(e)}},[i,V.checking,p,V.available,V.error]);let $=V.checking||p;return(0,A.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,A.jsx)(he,{width:72,height:72}),(0,A.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,A.jsxs)(be,{className:`yuri-settings-about`,children:[(0,A.jsx)(O,{label:i(`settings.yuri.about.field.clientVersion`),children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:Fe})}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceYuriVersion`),children:o()?(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:P||i(`settings.yuri.about.state.unknown`)}):(0,A.jsx)(ge,{transport:T,generation:E,itemId:`about.host-update`,channel:q?`beta`:`stable`,version:P||i(`settings.yuri.about.state.unknown`)},`${T}:${E}`)}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceOpenCodeVersion`),description:Te,children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:B||i(`settings.yuri.about.state.unknown`)})}),(0,A.jsx)(O,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,A.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,A.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,A.jsxs)(`a`,{href:Se,target:`_blank`,rel:`noopener noreferrer`,children:[(0,A.jsx)(x,{name:`question`,className:`size-4`}),i(`settings.yuri.about.actions.submitFeedback`)]})}),!$&&V.available?(0,A.jsxs)(b,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>u(!0),"data-settings-item":`about.check-updates`,children:[(0,A.jsx)(x,{name:`download`,className:`size-4`}),V.info?.inAppApply?i(`settings.yuri.about.actions.applyOtaToVersion`,{version:V.info?.version||``}):V.info?.manualUpdate?i(`settings.yuri.about.actions.installNativeToVersion`,{version:V.info?.version||``}):i(`settings.yuri.about.actions.updateToVersion`,{version:V.info?.version||``})]}):(0,A.jsxs)(b,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>V.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:$,children:[$?(0,A.jsx)(x,{name:`loader`,className:`size-4 animate-spin`}):(0,A.jsx)(x,{name:`refresh`,className:`size-4`}),i($?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),V.error&&(0,A.jsx)(O,{children:(0,A.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:V.error})}),(W||a())&&(0,A.jsx)(ye,{itemId:`about.beta-updates`,checked:q,onChange:ke,label:i(`settings.yuri.about.betaUpdates.label`),description:i(`settings.yuri.about.betaUpdates.description`),ariaLabel:i(`settings.yuri.about.betaUpdates.label`),disabled:$||W&&!G.data}),(0,A.jsx)(ye,{itemId:`about.diagnostics`,checked:X,onChange:Oe,label:i(`settings.yuri.about.diagnostics.label`),ariaLabel:i(`settings.yuri.about.diagnostics.label`)}),X&&(0,A.jsx)(O,{itemId:`about.export-diagnostics`,label:i(`settings.yuri.about.diagnostics.export`),children:(0,A.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,disabled:J,onClick:()=>void Pe(),children:i(J?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,A.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,A.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,A.jsxs)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,A.jsx)(x,{name:`github-fill`,className:`size-5`}),(0,A.jsx)(`span`,{children:`GitHub`})]})})}),(0,A.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:i(`aboutDialog.footerNote`)}),(0,A.jsx)(_e,{open:l,onOpenChange:u,info:V.info,downloading:V.downloading,downloaded:V.downloaded,progress:V.progress,error:V.error,onDownload:V.downloadUpdate,onRestart:V.restartToUpdate,runtimeType:V.runtimeType}),(0,A.jsx)(me,{open:d,onOpenChange:Me,children:(0,A.jsxs)(de,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,A.jsxs)(le,{children:[(0,A.jsx)(fe,{children:i(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,A.jsx)(pe,{children:i(`settings.yuri.about.betaUpdates.rollback.description`,{version:V.info?.version||``})})]}),(0,A.jsxs)(ue,{children:[(0,A.jsx)(b,{type:`button`,size:`sm`,variant:`ghost`,onClick:Ae,children:i(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,A.jsx)(b,{type:`button`,size:`sm`,onClick:je,children:i(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},P=16384,F=globalThis,I=e=>{if(F.Buffer)return F.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},L=e=>{try{if(F.Buffer)return F.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},R=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},z=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},B=e=>typeof e==`string`&&e.length>0,Te=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!B(t.x)||!B(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},V=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,H=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=V(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=R(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=z(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Te(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},U=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(H).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},W=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Ee=e=>{let t=U(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,I(JSON.stringify(t))),`yuri://connect?${n.toString()}`},De=e=>{let t=e.trim();if(!t||t.length>P)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>P)return null;let a=L(i);if(!a||a.length>P)return null;try{return U(JSON.parse(a))}catch{return null}},G=e=>{let t=e.trim();if(!t||t.length>P)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>P)return null;let n=L(t);return!n||n.length>P?null:U(JSON.parse(n))}}catch{}return De(t)},K=()=>{try{let e=S.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=h.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},q=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],J=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Y=e=>{if(typeof e==`string`)return e.trim()||void 0},X=l()(d(u((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=K();try{return!e?.force&&T(_,t).length>0||await D(_,t,n()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let r=`directory`in(t??{})?t?.directory?.trim()||null:K(),a=t?.transportIdentity??n();try{let t=Z(e),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await i(`/api/config/mcp/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(t)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to create MCP server`);return n()===a?(await D(_,r,a),await E(_,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:K(),o=r?.transportIdentity??n();try{let r=Z(t),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to update MCP server`);return n()===o?(await D(_,a,o),await E(_,a,o),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(r,a)=>{let o=`directory`in(a??{})?a?.directory?.trim()||null:K(),s=a?.transportIdentity??n();try{let a=o?`?directory=${encodeURIComponent(o)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(r)}${a}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to delete MCP server`);return ve.getState().clearDiagnostic(r,o,s),n()===s?(t().selectedMcpName===r&&e({selectedMcpName:null}),await D(_,o,s),await E(_,o,s),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:m(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Z(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=J(e.environment)??{}),e.headers!==void 0&&(t.headers=J(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Y(e.oauthClientId),clientSecret:Y(e.oauthClientSecret),scope:Y(e.oauthScope),redirectUri:Y(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}export{G as a,Ee as i,X as n,N as o,W as r,q as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEPKHgdL.js";import{n as i}from"./runtime-fetch-V-iMWR8t.js";import{I as a,P as o,n as s,y as c}from"./platform-CiUKDeXd.js";import{a as l,i as u,r as d,t as ee}from"./vendor-zustand-CTekDqaS.js";import{ot as f,st as p}from"./vendor-base-ui-wXsskyKm.js";import{t as m}from"./safeStorage-DTOhKN0V.js";import{n as h}from"./client-B_907PBv.js";import{s as g}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as _}from"./yuriEvents-BFrD5fMU.js";import{r as v}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as y}from"./useUIStore-C3ewjGgP.js";import{a as te,i as ne,n as re}from"./types-DpcA-uDW.js";import{t as ie}from"./native-config-DVg8_Zx1.js";import{i as b}from"./session-startup-barrier-DT-hIBRf.js";import{n as x}from"./Icon-DmykXZL1.js";import{Na as S,Sr as ae,_r as oe,gr as se,t as C}from"./ui-ee2iN869.js";import{t as ce}from"./i18n-DXc6czdR.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./dialog-BeFBA6ja.js";import{t as he}from"./YuriLogo-Cp6vWDWp.js";import{_ as w,f as ge,p as _e,v as ve}from"./sessionOwnership-BjhXe6pi.js";import{a as T,c as E,s as D}from"./mcpQueries-Rmp1BKeo.js";import{i as ye,n as be,r as O}from"./SettingsGroup-CvaPYznp.js";var k=e(p(),1),A=f(),xe=`https://github.com/yee94/yuri`,Se=`${xe}/issues/new`,Ce=800,we={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},j=e=>typeof e==`string`&&e.trim()?e.trim():null,M=(e,t,a)=>({queryKey:[t,`about`,a,e],queryFn:async({signal:o})=>{if(t!==n()||a!==r())throw Error(`Stale About runtime`);let s=await i(e,{method:`GET`,headers:{Accept:`application/json`},signal:o});if(!s.ok)throw Error(`About snapshot: ${s.status}`);let c=await s.json();if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid About snapshot`);if(o.aborted||t!==n()||a!==r())throw Error(`Stale About runtime`);return c},retry:!1,staleTime:3e4}),N=({initialUpdateDialogOpen:e=!1})=>{let{t:i}=ce(),[l,u]=k.useState(e),[d,f]=k.useState(!1),[p,m]=k.useState(!1),[h,_]=k.useState(null),[S,ve]=k.useState(null),T=k.useSyncExternalStore(t,n,n),E=k.useSyncExternalStore(t,r,r),D=g(M(`/api/system/info`,T,E)),N=g(M(`/api/opencode/upgrade-status`,T,E)),P=j(D.data?.yuriVersion),F=N.data,I=j(F?.serveVersion)??j(F?.currentVersion),L=j(F?.management),R=L&&Object.hasOwn(we,L)?we[L]:null,z=F?.canManage===!1&&R?i(R):null,B=I&&z?i(`settings.yuri.about.opencodeVersionWithManagement`,{version:I,management:z}):I,Te=F?.canManage===!1?L===`manual-global`?i(`settings.yuri.about.opencodeGuidance.manualGlobal`):L===`manual-external`?i(`settings.yuri.about.opencodeGuidance.manualExternal`):L===`bundled`?i(`settings.yuri.about.opencodeGuidance.bundled`):null:null,V=w(ee(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),H=y(e=>e.otaChannelOverride),U=y(e=>e.setOtaChannelOverride),W=s(),[Ee,De]=k.useState(`stable`);k.useEffect(()=>{a()&&c().then(e=>De(e?.includes(`-`)?`beta`:`stable`))},[]);let G=g({queryKey:[`native-update-config`],queryFn:ie,enabled:W,staleTime:1/0,retry:!1}),K=G.data?.channel,q=H===`beta`||H===null&&(a()?Ee:K)===`beta`,[J,Y]=k.useState(!1),[X,Z]=k.useState(()=>oe()),Oe=v(e=>{ae(e),Z(e)}),ke=v(async e=>{if(e){U(`beta`),await w.getState().checkForUpdates();return}U(`stable`),await w.getState().checkForUpdates();let{info:t,otaDecision:n}=w.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&f(!0)}),Ae=v(()=>{f(!1),U(`beta`),w.getState().checkForUpdates()}),je=v(()=>{f(!1),u(!0),w.getState().downloadUpdate()}),Me=v(e=>{e||Ae()}),Ne=h||i(`settings.yuri.about.state.unknown`),Pe=v(async()=>{if(!J){Y(!0);try{let{outcome:e,eventCount:t}=await se();if(e===`cancelled`)return;if(e===`failed`){C.error(i(`settings.yuri.about.diagnostics.toast.failed`));return}C.success(i(t>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{C.error(i(`settings.yuri.about.diagnostics.toast.failed`))}finally{Y(!1)}}});k.useEffect(()=>{let e=!1;return te().then(t=>{e||_(t)}),ne().then(t=>{e||ve(t)}),()=>{e=!0}},[]);let Fe=re(h,S)??Ne,Q=k.useRef(!1);k.useEffect(()=>{if(V.checking)m(!0),Q.current=!0;else if(p){let e=setTimeout(()=>{m(!1),Q.current&&V.error?(C.error(i(`settings.yuri.about.toast.checkFailed`),{description:V.error}),Q.current=!1):Q.current&&!V.available&&!V.error&&(C.success(i(`settings.yuri.about.toast.latestVersion`)),Q.current=!1)},Ce);return()=>clearTimeout(e)}},[i,V.checking,p,V.available,V.error]);let $=V.checking||p;return(0,A.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,A.jsx)(he,{width:72,height:72}),(0,A.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,A.jsxs)(be,{className:`yuri-settings-about`,children:[(0,A.jsx)(O,{label:i(`settings.yuri.about.field.clientVersion`),children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:Fe})}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceYuriVersion`),children:o()?(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:P||i(`settings.yuri.about.state.unknown`)}):(0,A.jsx)(ge,{transport:T,generation:E,itemId:`about.host-update`,channel:q?`beta`:`stable`,version:P||i(`settings.yuri.about.state.unknown`)},`${T}:${E}`)}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceOpenCodeVersion`),description:Te,children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:B||i(`settings.yuri.about.state.unknown`)})}),(0,A.jsx)(O,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,A.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,A.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,A.jsxs)(`a`,{href:Se,target:`_blank`,rel:`noopener noreferrer`,children:[(0,A.jsx)(x,{name:`question`,className:`size-4`}),i(`settings.yuri.about.actions.submitFeedback`)]})}),!$&&V.available?(0,A.jsxs)(b,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>u(!0),"data-settings-item":`about.check-updates`,children:[(0,A.jsx)(x,{name:`download`,className:`size-4`}),V.info?.inAppApply?i(`settings.yuri.about.actions.applyOtaToVersion`,{version:V.info?.version||``}):V.info?.manualUpdate?i(`settings.yuri.about.actions.installNativeToVersion`,{version:V.info?.version||``}):i(`settings.yuri.about.actions.updateToVersion`,{version:V.info?.version||``})]}):(0,A.jsxs)(b,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>V.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:$,children:[$?(0,A.jsx)(x,{name:`loader`,className:`size-4 animate-spin`}):(0,A.jsx)(x,{name:`refresh`,className:`size-4`}),i($?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),V.error&&(0,A.jsx)(O,{children:(0,A.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:V.error})}),(W||a())&&(0,A.jsx)(ye,{itemId:`about.beta-updates`,checked:q,onChange:ke,label:i(`settings.yuri.about.betaUpdates.label`),description:i(`settings.yuri.about.betaUpdates.description`),ariaLabel:i(`settings.yuri.about.betaUpdates.label`),disabled:$||W&&!G.data}),(0,A.jsx)(ye,{itemId:`about.diagnostics`,checked:X,onChange:Oe,label:i(`settings.yuri.about.diagnostics.label`),ariaLabel:i(`settings.yuri.about.diagnostics.label`)}),X&&(0,A.jsx)(O,{itemId:`about.export-diagnostics`,label:i(`settings.yuri.about.diagnostics.export`),children:(0,A.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,disabled:J,onClick:()=>void Pe(),children:i(J?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,A.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,A.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,A.jsxs)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,A.jsx)(x,{name:`github-fill`,className:`size-5`}),(0,A.jsx)(`span`,{children:`GitHub`})]})})}),(0,A.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:i(`aboutDialog.footerNote`)}),(0,A.jsx)(_e,{open:l,onOpenChange:u,info:V.info,downloading:V.downloading,downloaded:V.downloaded,progress:V.progress,error:V.error,onDownload:V.downloadUpdate,onRestart:V.restartToUpdate,runtimeType:V.runtimeType}),(0,A.jsx)(me,{open:d,onOpenChange:Me,children:(0,A.jsxs)(de,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,A.jsxs)(le,{children:[(0,A.jsx)(fe,{children:i(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,A.jsx)(pe,{children:i(`settings.yuri.about.betaUpdates.rollback.description`,{version:V.info?.version||``})})]}),(0,A.jsxs)(ue,{children:[(0,A.jsx)(b,{type:`button`,size:`sm`,variant:`ghost`,onClick:Ae,children:i(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,A.jsx)(b,{type:`button`,size:`sm`,onClick:je,children:i(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},P=16384,F=globalThis,I=e=>{if(F.Buffer)return F.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},L=e=>{try{if(F.Buffer)return F.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},R=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},z=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},B=e=>typeof e==`string`&&e.length>0,Te=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!B(t.x)||!B(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},V=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,H=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=V(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=R(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=z(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Te(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},U=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(H).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},W=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Ee=e=>{let t=U(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,I(JSON.stringify(t))),`yuri://connect?${n.toString()}`},De=e=>{let t=e.trim();if(!t||t.length>P)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>P)return null;let a=L(i);if(!a||a.length>P)return null;try{return U(JSON.parse(a))}catch{return null}},G=e=>{let t=e.trim();if(!t||t.length>P)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>P)return null;let n=L(t);return!n||n.length>P?null:U(JSON.parse(n))}}catch{}return De(t)},K=()=>{try{let e=S.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=h.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},q=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],J=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Y=e=>{if(typeof e==`string`)return e.trim()||void 0},X=l()(d(u((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=K();try{return!e?.force&&T(_,t).length>0||await D(_,t,n()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let r=`directory`in(t??{})?t?.directory?.trim()||null:K(),a=t?.transportIdentity??n();try{let t=Z(e),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await i(`/api/config/mcp/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(t)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to create MCP server`);return n()===a?(await D(_,r,a),await E(_,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:K(),o=r?.transportIdentity??n();try{let r=Z(t),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to update MCP server`);return n()===o?(await D(_,a,o),await E(_,a,o),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(r,a)=>{let o=`directory`in(a??{})?a?.directory?.trim()||null:K(),s=a?.transportIdentity??n();try{let a=o?`?directory=${encodeURIComponent(o)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(r)}${a}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to delete MCP server`);return ve.getState().clearDiagnostic(r,o,s),n()===s?(t().selectedMcpName===r&&e({selectedMcpName:null}),await D(_,o,s),await E(_,o,s),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:m(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Z(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=J(e.environment)??{}),e.headers!==void 0&&(t.headers=J(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Y(e.oauthClientId),clientSecret:Y(e.oauthClientSecret),scope:Y(e.oauthScope),redirectUri:Y(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}export{G as a,Ee as i,X as n,N as o,W as r,q as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-DEPKHgdL.js";import{s as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{St as a}from"./gitApiHttp-Dd-FwgCq.js";import{Rt as o,Xt as s,Zt as c,an as l,ln as u,on as d,un as f,zt as p}from"./client-B_907PBv.js";import{n as m}from"./vendor-react-BkccXcWz.js";import{c as h,o as g,s as _}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as v,o as y}from"./yuriEvents-BFrD5fMU.js";import{D as b,E as x,I as S,R as C}from"./runtime-file-resource-Bc_ss-sW.js";import{r as w}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as T}from"./useUIStore-C3ewjGgP.js";import{i as ee,o as E}from"./session-startup-barrier-DT-hIBRf.js";import{n as D}from"./Icon-DmykXZL1.js";import{Ea as O,Hi as k,Ia as A,Ji as j,Qn as M,at as N,et as te,f as P,hr as F,lt as I,mr as L,st as R}from"./ui-DrAJTWV6.js";import{t as ne}from"./i18n-DXc6czdR.js";import{c as z,o as re,s as B}from"./useGitStore-B641o_o0.js";import{t as ie}from"./connection-hint-B-kOWome.js";import{n as ae,t as V}from"./ProviderLogo-DA98yu7M.js";import{a as oe,l as se,n as H,r as U,u as ce}from"./useQuotaStore-CSn2pk3T.js";import{a as le,i as ue,l as W,r as G,s as K}from"./quota-CqWNkFzw.js";import{i as de,r as q}from"./icons-Bd-INsoy.js";var J=e(i(),1),Y=m(),X=r();function fe(e){let t=(0,Y.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=ne(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:G(n)??0;let e=W(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,X.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}var Z=(e,t,n)=>g({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function pe(e){let t=S(e);return Z(e,`git`,async n=>{let r={signal:n,query:{directory:e.location.directory},headers:{"x-opencode-directory":e.location.directory}};return(await t.json(`/api/git/check`,r)).isGitRepository?{isGitRepository:!0,current:(await t.json(`/api/git/status`,{...r,query:{...r.query,mode:`light`}})).current}:{isGitRepository:!1,current:null}})}function me(e){let t=S(e);return Z(e,`quota-settings`,async e=>{let n=await t.json(`/api/config/settings`,{signal:e}),r=se.map(e=>e.id),i=Array.isArray(n.usageDropdownProviders)?n.usageDropdownProviders.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||r.includes(e))):r,a={};if(n.usageSelectedModels&&typeof n.usageSelectedModels==`object`)for(let[e,t]of Object.entries(n.usageSelectedModels))Array.isArray(t)&&(a[e]=t.filter(e=>typeof e==`string`));return{providerIds:i,selectedModels:a,displayMode:n.usageDisplayMode===`remaining`?`remaining`:`usage`,autoRefresh:n.usageAutoRefresh===!0,refreshIntervalMs:typeof n.usageRefreshIntervalMs==`number`&&Number.isFinite(n.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(n.usageRefreshIntervalMs))):6e4}})}function he(e,t){let n=S(e);return Z(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!y(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function ge(e){let t=S(e);return Z(e,`magpie`,async n=>{let r=await t.json(`/api/quota/magpie`,{signal:n,query:{directory:e.location.directory}});if(!Array.isArray(r.sources)||!r.sources.every(e=>e&&typeof e.id==`string`&&Array.isArray(e.results)&&e.results.every(t=>y(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return r.sources.flatMap(e=>e.results)})}var _e=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ve=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),ye=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,be=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${ve(t)}/${ve(n)}`,colorClass:ye(i)}},xe=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},Se=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function Ce(e,t,n){let r=(0,Y.c)(7),{t:i}=ne(),a;if(r[0]!==t||r[1]!==e||r[2]!==n||r[3]!==i){let o=new Map(e.map(Q)),s;r[5]===t?s=r[6]:(s=e=>t.includes(e.id),r[5]=t,r[6]=s),a=ce(e).filter(s).filter(e=>o.get(e.id)?.configured===!0).map(e=>{let t=o.get(e.id),r=[];for(let[e,n]of de(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:K(n.label??e),window:n});let a=Object.entries(t?.usage?.models??{}),s=n[e.id]??[];for(let[e,t]of s.length>0?a.filter(e=>{let[t]=e;return s.includes(t)}):a){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:K(a.label??i),subtitle:oe(e),window:a})}return{providerId:e.id,providerName:e.name,rows:r,status:!t.ok&&t.error?t.error:r.length===0?i(`header.services.noRateLimitsReported`):null}}),r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a}else a=r[4];return a}function Q(e){return[e?.providerId,e]}var we=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Te=e=>{let t=(0,Y.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,X.jsx)(D,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},$=e=>{let t=(0,Y.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ne(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(D,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,X.jsx)(D,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,X.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(V,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,X.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=q(e.rows.map(Xe),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=le(t.window.valueLabel,o),c=ue(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,X.jsxs)(J.Fragment,{children:[i?(0,X.jsx)(`div`,{className:E(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,X.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,X.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,X.jsx)(`span`,{className:E(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,we(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,X.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,X.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Ee=e=>{let t=(0,Y.c)(52),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l,error:u,onRetry:d}=e,{t:f}=ne(),p=J.useRef(null),[m,h]=J.useState(n),[g,_]=J.useState(!1),v,y;t[0]!==n||t[1]!==m?(v=()=>{if(n){h(!0),_(!1);return}if(!m)return;_(!0);let e=window.setTimeout(()=>{h(!1),_(!1)},140);return()=>window.clearTimeout(e)},y=[n,m],t[0]=n,t[1]=m,t[2]=v,t[3]=y):(v=t[2],y=t[3]),J.useEffect(v,y);let b,x;if(t[4]!==r||t[5]!==n?(b=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},x=[r,n],t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),J.useEffect(b,x),!m)return null;let S;t[8]===f?S=t[9]:(S=f(`mobile.surface.closeAria`),t[8]=f,t[9]=S);let C;t[10]===r?C=t[11]:(C=e=>{e.preventDefault(),r()},t[10]=r,t[11]=C);let w;t[12]!==S||t[13]!==C?(w=(0,X.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":S,onPointerDown:C}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===f?T=t[16]:(T=f(`mobile.header.openMetadataAria`),t[15]=f,t[16]=T);let D=g&&`pointer-events-none`,O;t[17]===D?O=t[18]:(O=E(`pointer-events-auto absolute inset-x-3 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent p-2 will-change-transform`,D),t[17]=D,t[18]=O);let k=`${g?`session-metadata-out`:`session-metadata-in`} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,A;t[19]===k?A=t[20]:(A={animation:k,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=k,t[20]=A);let j;t[21]===f?j=t[22]:(j=f(`mobile.header.metadata.branch`),t[21]=f,t[22]=j);let M;t[23]!==a||t[24]!==j?(M=(0,X.jsx)(Te,{iconName:`git-branch`,label:j,children:a}),t[23]=a,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==i||t[27]!==f?(N=i?(0,X.jsx)(Te,{iconNode:(0,X.jsx)(fe,{percentage:i.percentage,pending:i.pending}),label:f(`mobile.header.metadata.context`),children:(0,X.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,X.jsx)(`span`,{className:E(`font-semibold`,i.colorClass),children:i.pending?f(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=f,t[28]=N):N=t[28];let te;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(te=(0,X.jsx)($,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=te):te=t[33];let P;t[34]!==u||t[35]!==d||t[36]!==f?(P=u?(0,X.jsxs)(`div`,{role:`alert`,className:`px-2.5 py-2 typography-ui-label text-[var(--status-error)]`,children:[u,(0,X.jsx)(ee,{variant:`ghost`,size:`sm`,onClick:d,children:f(`contextPanel.preview.actions.retry`)})]}):null,t[34]=u,t[35]=d,t[36]=f,t[37]=P):P=t[37];let F;t[38]!==M||t[39]!==N||t[40]!==te||t[41]!==P?(F=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[M,N,te,P]}),t[38]=M,t[39]=N,t[40]=te,t[41]=P,t[42]=F):F=t[42];let I;t[43]!==O||t[44]!==A||t[45]!==F||t[46]!==T?(I=(0,X.jsx)(`div`,{ref:p,role:`dialog`,"aria-label":T,className:O,style:A,onPointerDown:Ze,children:F}),t[43]=O,t[44]=A,t[45]=F,t[46]=T,t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(`style`,{children:`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-DEPKHgdL.js";import{s as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{St as a}from"./gitApiHttp-Dd-FwgCq.js";import{Rt as o,Xt as s,Zt as c,an as l,ln as u,on as d,un as f,zt as p}from"./client-B_907PBv.js";import{n as m}from"./vendor-react-BkccXcWz.js";import{c as h,o as g,s as _}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as v,o as y}from"./yuriEvents-BFrD5fMU.js";import{D as b,E as x,I as S,R as C}from"./runtime-file-resource-Bc_ss-sW.js";import{r as w}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as T}from"./useUIStore-C3ewjGgP.js";import{i as ee,o as E}from"./session-startup-barrier-DT-hIBRf.js";import{n as D}from"./Icon-DmykXZL1.js";import{Ea as O,Hi as k,Ia as A,Ji as j,Qn as M,at as N,et as te,f as P,hr as F,lt as I,mr as L,st as R}from"./ui-ee2iN869.js";import{t as ne}from"./i18n-DXc6czdR.js";import{c as z,o as re,s as B}from"./useGitStore-Bv8xmXDa.js";import{t as ie}from"./connection-hint-B-kOWome.js";import{n as ae,t as V}from"./ProviderLogo-DA98yu7M.js";import{a as oe,l as se,n as H,r as U,u as ce}from"./useQuotaStore-CSn2pk3T.js";import{a as le,i as ue,l as W,r as G,s as K}from"./quota-CqWNkFzw.js";import{i as de,r as q}from"./icons-Bd-INsoy.js";var J=e(i(),1),Y=m(),X=r();function fe(e){let t=(0,Y.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=ne(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:G(n)??0;let e=W(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,X.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}var Z=(e,t,n)=>g({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function pe(e){let t=S(e);return Z(e,`git`,async n=>{let r={signal:n,query:{directory:e.location.directory},headers:{"x-opencode-directory":e.location.directory}};return(await t.json(`/api/git/check`,r)).isGitRepository?{isGitRepository:!0,current:(await t.json(`/api/git/status`,{...r,query:{...r.query,mode:`light`}})).current}:{isGitRepository:!1,current:null}})}function me(e){let t=S(e);return Z(e,`quota-settings`,async e=>{let n=await t.json(`/api/config/settings`,{signal:e}),r=se.map(e=>e.id),i=Array.isArray(n.usageDropdownProviders)?n.usageDropdownProviders.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||r.includes(e))):r,a={};if(n.usageSelectedModels&&typeof n.usageSelectedModels==`object`)for(let[e,t]of Object.entries(n.usageSelectedModels))Array.isArray(t)&&(a[e]=t.filter(e=>typeof e==`string`));return{providerIds:i,selectedModels:a,displayMode:n.usageDisplayMode===`remaining`?`remaining`:`usage`,autoRefresh:n.usageAutoRefresh===!0,refreshIntervalMs:typeof n.usageRefreshIntervalMs==`number`&&Number.isFinite(n.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(n.usageRefreshIntervalMs))):6e4}})}function he(e,t){let n=S(e);return Z(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!y(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function ge(e){let t=S(e);return Z(e,`magpie`,async n=>{let r=await t.json(`/api/quota/magpie`,{signal:n,query:{directory:e.location.directory}});if(!Array.isArray(r.sources)||!r.sources.every(e=>e&&typeof e.id==`string`&&Array.isArray(e.results)&&e.results.every(t=>y(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return r.sources.flatMap(e=>e.results)})}var _e=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ve=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),ye=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,be=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${ve(t)}/${ve(n)}`,colorClass:ye(i)}},xe=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},Se=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function Ce(e,t,n){let r=(0,Y.c)(7),{t:i}=ne(),a;if(r[0]!==t||r[1]!==e||r[2]!==n||r[3]!==i){let o=new Map(e.map(Q)),s;r[5]===t?s=r[6]:(s=e=>t.includes(e.id),r[5]=t,r[6]=s),a=ce(e).filter(s).filter(e=>o.get(e.id)?.configured===!0).map(e=>{let t=o.get(e.id),r=[];for(let[e,n]of de(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:K(n.label??e),window:n});let a=Object.entries(t?.usage?.models??{}),s=n[e.id]??[];for(let[e,t]of s.length>0?a.filter(e=>{let[t]=e;return s.includes(t)}):a){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:K(a.label??i),subtitle:oe(e),window:a})}return{providerId:e.id,providerName:e.name,rows:r,status:!t.ok&&t.error?t.error:r.length===0?i(`header.services.noRateLimitsReported`):null}}),r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a}else a=r[4];return a}function Q(e){return[e?.providerId,e]}var we=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Te=e=>{let t=(0,Y.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,X.jsx)(D,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},$=e=>{let t=(0,Y.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ne(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(D,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,X.jsx)(D,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,X.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(V,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,X.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=q(e.rows.map(Xe),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=le(t.window.valueLabel,o),c=ue(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,X.jsxs)(J.Fragment,{children:[i?(0,X.jsx)(`div`,{className:E(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,X.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,X.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,X.jsx)(`span`,{className:E(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,we(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,X.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,X.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Ee=e=>{let t=(0,Y.c)(52),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l,error:u,onRetry:d}=e,{t:f}=ne(),p=J.useRef(null),[m,h]=J.useState(n),[g,_]=J.useState(!1),v,y;t[0]!==n||t[1]!==m?(v=()=>{if(n){h(!0),_(!1);return}if(!m)return;_(!0);let e=window.setTimeout(()=>{h(!1),_(!1)},140);return()=>window.clearTimeout(e)},y=[n,m],t[0]=n,t[1]=m,t[2]=v,t[3]=y):(v=t[2],y=t[3]),J.useEffect(v,y);let b,x;if(t[4]!==r||t[5]!==n?(b=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},x=[r,n],t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),J.useEffect(b,x),!m)return null;let S;t[8]===f?S=t[9]:(S=f(`mobile.surface.closeAria`),t[8]=f,t[9]=S);let C;t[10]===r?C=t[11]:(C=e=>{e.preventDefault(),r()},t[10]=r,t[11]=C);let w;t[12]!==S||t[13]!==C?(w=(0,X.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":S,onPointerDown:C}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===f?T=t[16]:(T=f(`mobile.header.openMetadataAria`),t[15]=f,t[16]=T);let D=g&&`pointer-events-none`,O;t[17]===D?O=t[18]:(O=E(`pointer-events-auto absolute inset-x-3 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent p-2 will-change-transform`,D),t[17]=D,t[18]=O);let k=`${g?`session-metadata-out`:`session-metadata-in`} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,A;t[19]===k?A=t[20]:(A={animation:k,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=k,t[20]=A);let j;t[21]===f?j=t[22]:(j=f(`mobile.header.metadata.branch`),t[21]=f,t[22]=j);let M;t[23]!==a||t[24]!==j?(M=(0,X.jsx)(Te,{iconName:`git-branch`,label:j,children:a}),t[23]=a,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==i||t[27]!==f?(N=i?(0,X.jsx)(Te,{iconNode:(0,X.jsx)(fe,{percentage:i.percentage,pending:i.pending}),label:f(`mobile.header.metadata.context`),children:(0,X.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,X.jsx)(`span`,{className:E(`font-semibold`,i.colorClass),children:i.pending?f(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=f,t[28]=N):N=t[28];let te;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(te=(0,X.jsx)($,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=te):te=t[33];let P;t[34]!==u||t[35]!==d||t[36]!==f?(P=u?(0,X.jsxs)(`div`,{role:`alert`,className:`px-2.5 py-2 typography-ui-label text-[var(--status-error)]`,children:[u,(0,X.jsx)(ee,{variant:`ghost`,size:`sm`,onClick:d,children:f(`contextPanel.preview.actions.retry`)})]}):null,t[34]=u,t[35]=d,t[36]=f,t[37]=P):P=t[37];let F;t[38]!==M||t[39]!==N||t[40]!==te||t[41]!==P?(F=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[M,N,te,P]}),t[38]=M,t[39]=N,t[40]=te,t[41]=P,t[42]=F):F=t[42];let I;t[43]!==O||t[44]!==A||t[45]!==F||t[46]!==T?(I=(0,X.jsx)(`div`,{ref:p,role:`dialog`,"aria-label":T,className:O,style:A,onPointerDown:Ze,children:F}),t[43]=O,t[44]=A,t[45]=F,t[46]=T,t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(`style`,{children:`
2
2
  @keyframes session-metadata-in {
3
3
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
4
4
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,i as n}from"./vendor-zustand-CTekDqaS.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{r as o}from"./useUIStore-C3ewjGgP.js";import{i as s,o as c}from"./session-startup-barrier-DT-hIBRf.js";import{n as l}from"./Icon-DmykXZL1.js";import{Hi as u,Ja as d,t as f,ta as p}from"./ui-DrAJTWV6.js";import{n as m,t as h}from"./i18n-DXc6czdR.js";import{t as g}from"./ScrollableOverlay-stxT7gLf.js";import{t as _}from"./vendor-tanstack-react-virtual-qsd3nvZb.js";import{i as v,n as y,t as b}from"./tooltip-CpTbxEOE.js";import{t as x}from"./input-Cf16qJ6g.js";import{t as S}from"./ModelLogo-BkbD514M.js";import{_ as C,l as w,o as T,s as ee,t as te,v as ne,y as re}from"./vendor-dnd-kit-core-qy5stxu5.js";import{n as ie,o as ae,s as oe,t as se}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as ce}from"./ProviderLogo-DA98yu7M.js";var E=e(i(),1),D=a(),le={compact:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0},compactTokensShort:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1},usd:{style:`currency`,currency:`USD`,maximumFractionDigits:4,minimumFractionDigits:2}},ue=null,O={},de=(e,t)=>{ue!==t&&(ue=t,O.compact=void 0,O.compactTokensShort=void 0,O.usd=void 0);let n=O[e];if(n)return n;let r=new Intl.NumberFormat(t,le[e]);return O[e]=r,r},fe=(e,t=m())=>de(`compact`,t).format(e),pe=(e,t=m())=>de(`compactTokensShort`,t).format(e),me=(e,t=m())=>de(`usd`,t).format(e),he=(e,t=m())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),ge=(e,t=m())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),_e=(e,t=m())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),ve=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ye=(e,t,n)=>{let r=ve(t.limit,`context`),i=ve(t.limit,`output`),a=r??n?.limit?.context,o=i??n?.limit?.output;return a===void 0&&o===void 0?n:{...n??{id:typeof t.id==`string`?t.id:``,providerId:e,name:typeof t.name==`string`?t.name:void 0},limit:{...n?.limit,...a===void 0?{}:{context:a},...o===void 0?{}:{output:o}}}};function k(e){let t=e.toLowerCase().trim();return{lower:t,compact:t.replace(/[^a-z0-9]/g,``),tokens:t.split(/[^a-z0-9]+/).filter(Boolean)}}function be(e,t){if(xe(e,t))return!0;let n=t.trim().split(/\s+/).filter(Boolean);return n.length>1&&n.every(t=>xe(e,t))}function xe(e,t){let n=k(t);if(!n.lower)return!0;let r=k(e);return r.lower.includes(n.lower)||n.compact.length>=2&&r.compact.includes(n.compact)?!0:n.tokens.length!==0&&n.tokens.every(e=>r.tokens.some(t=>t.startsWith(e)||t.includes(e)))}var Se=40,Ce=8,we=8,A=6,Te=e=>{try{return decodeURIComponent(e)}catch{return e}};function Ee(e){let t=Te(e.providerID);return[e.providerName,e.providerID,t===e.providerID?``:t,e.modelName,e.modelID].filter(Boolean).join(` `)}function De(e,t,n,r={}){let i=k(n),a=k(e),o=i.compact.length>=2,s;if(!i.lower)s=1;else if(a.compact!==``&&a.compact===i.compact)s=100;else if(a.lower.startsWith(i.lower)||o&&a.compact.startsWith(i.compact))s=80;else if(i.tokens.length>0&&i.tokens.every(e=>a.tokens.some(t=>t.startsWith(e))))s=65;else if(a.lower.includes(i.lower)||o&&a.compact.includes(i.compact))s=50;else if(be(r.searchText??`${t} ${e}`,n))s=20;else return 0;let c=r.recencyRank,l=c===void 0||c<0?0:Math.max(0,Se-c*Ce);return s+l+(r.favorite?we:0)+(r.selectedProvider?A:0)}var j=(e,t)=>`${e}:${t}`;function Oe(e,t){if(!t)return e;let n=e.find(e=>e.id===t);return!n||e[0]===n?e:[n,...e.filter(e=>e!==n)]}function ke(e){let{candidates:t,query:n,recencyOrder:r,recentModels:i,favoriteModels:a,selectedModel:o}=e,s=new Map;(o?[o,...r]:r).forEach(({providerID:e,modelID:t},n)=>{let r=j(e,t);s.has(r)||s.set(r,n)});let c=new Set(a.map(({providerID:e,modelID:t})=>j(e,t))),l=new Map;[...i,...a].forEach(({providerID:e,modelID:t,variant:n})=>{n!==void 0&&l.set(j(e,t),n)});let u=[];for(let{entry:e,providerName:r,modelName:i}of t){let t=j(e.providerID,e.modelID),a=De(i,r,n,{recencyRank:s.get(t),favorite:c.has(t),selectedProvider:o?.providerID===e.providerID,searchText:Ee({providerName:r,providerID:e.providerID,modelName:i,modelID:e.modelID})});if(a<=0)continue;let d=l.get(t);u.push({entry:d===void 0?e:{...e,variant:d},score:a})}return u.sort((e,t)=>t.score-e.score).map(({entry:e})=>e)}var Ae=t()(n(e=>({collapsedSections:{},toggleSection:t=>e(e=>{let n={...e.collapsedSections};return n[t]?delete n[t]:n[t]=!0,{collapsedSections:n}})}),{name:`model-picker-collapsed-sections`,version:1})),M=r(),je={image:{icon:`file-image`,labelKey:`modalityImage`},video:{icon:`file-video`,labelKey:`modalityVideo`},audio:{icon:`file-music`,labelKey:`modalityAudio`}},Me=e=>e.trim().toLowerCase(),N=e=>{let t=(0,D.c)(5),{iconName:n,label:r}=e,i;t[0]===n?i=t[1]:(i=(0,M.jsx)(l,{name:n,className:`size-3.5`}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,M.jsx)(`span`,{className:`flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,title:r,"aria-label":r,role:`img`,children:i}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},Ne=(e,t)=>{let n=[];e?.tool_call&&t.capabilityToolCalling&&n.push({key:`tool_call`,icon:`tools`,label:t.capabilityToolCalling}),e?.reasoning&&t.capabilityReasoning&&n.push({key:`reasoning`,icon:`brain-ai-3`,label:t.capabilityReasoning});let r=[...e?.modalities?.input??[],...e?.modalities?.output??[]],i=Array.from(new Set(r.map(Me).filter(Boolean)));for(let e of i){let r=je[e];if(!r)continue;let i=t[r.labelKey];i&&n.push({key:`modality-${e}`,icon:r.icon,label:i})}return n},P=e=>p(e,void 0,{maxLength:40}),Pe=e=>{if(typeof e!=`number`||Number.isNaN(e))return``;if(e===0)return`0`;let t=fe(e);return t.endsWith(`.0`)?t.slice(0,-2):t},Fe=e=>typeof e!=`number`||!Number.isFinite(e)?`—`:me(e),F=(e,t)=>t?!0:e?!!(e.tool_call||e.reasoning||e.cost?.input!==void 0||e.cost?.output!==void 0||(e.modalities?.input?.length??0)>0||(e.modalities?.output?.length??0)>0):!1,Ie=e=>{let t=(0,D.c)(21),{metadata:n,providerName:r,providerID:i,modelID:a,active:o,anchor:c,labels:l,children:u}=e,{t:p}=h(),[m,g]=E.useState(!1),_=`${i}/${a}`,v,x;t[0]===o?(v=t[1],x=t[2]):(v=()=>{if(!o){g(!1);return}let e=window.setTimeout(()=>g(!0),450);return()=>window.clearTimeout(e)},x=[o],t[0]=o,t[1]=v,t[2]=x),E.useEffect(v,x);let S;t[3]!==o||t[4]!==m||t[5]!==n||t[6]!==r?(S=o&&m&&F(n,r),t[3]=o,t[4]=m,t[5]=n,t[6]=r,t[7]=S):S=t[7];let C=S,w,T;if(t[8]!==c||t[9]!==u||t[10]!==l||t[11]!==n||t[12]!==_||t[13]!==r||t[14]!==C||t[15]!==p){let e=C?Ne(n,l):[],i=n?.cost?.input!==void 0||n?.cost?.output!==void 0;w=u,T=C?(0,M.jsx)(b,{open:!0,onOpenChange:L,children:(0,M.jsx)(y,{anchor:c,side:`right`,sideOffset:8,className:`min-w-52 max-w-xs text-left transition-none data-[starting-style]:opacity-100 data-[starting-style]:scale-100 data-[ending-style]:opacity-100 data-[ending-style]:scale-100`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 text-left text-xs`,children:[r&&l.provider?(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground`,children:[(0,M.jsx)(`span`,{className:`typography-meta font-medium`,children:l.provider}),(0,M.jsx)(`span`,{className:`typography-meta text-foreground`,children:r})]}):null,e.length>0?(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground`,children:[(0,M.jsx)(`span`,{className:`typography-meta font-medium shrink-0`,children:l.capabilities}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:e.map(R)})]}):null,i?(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-muted-foreground`,children:[l.costPerMillion?(0,M.jsx)(`span`,{className:`typography-meta font-medium shrink-0`,children:l.costPerMillion}):null,(0,M.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 min-w-0`,children:[l.costInput?(0,M.jsx)(`span`,{className:`typography-meta shrink-0`,children:l.costInput}):null,(0,M.jsx)(`span`,{className:`typography-meta text-foreground tabular-nums`,children:Fe(n?.cost?.input)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 min-w-0`,children:[l.costOutput?(0,M.jsx)(`span`,{className:`typography-meta shrink-0`,children:l.costOutput}):null,(0,M.jsx)(`span`,{className:`typography-meta text-foreground tabular-nums`,children:Fe(n?.cost?.output)})]})]})]}):null,(0,M.jsx)(s,{variant:`ghost`,size:`xs`,className:`h-auto min-h-0 w-full min-w-0 justify-end gap-0 rounded-none p-0 text-right cursor-copy font-normal text-muted-foreground hover:bg-transparent active:bg-transparent`,"aria-label":p(`onboarding.common.copyToClipboard`),title:_,onClick:async e=>{e.stopPropagation();try{(await d(_)).ok?f.success(p(`contextSidebar.actions.copied`)):f.error(p(`filesView.toast.copyFailed`))}catch{f.error(p(`filesView.toast.copyFailed`))}},children:(0,M.jsx)(`span`,{className:`block w-full min-w-0 truncate text-right text-[10px] leading-tight`,children:_})})]})})}):null,t[8]=c,t[9]=u,t[10]=l,t[11]=n,t[12]=_,t[13]=r,t[14]=C,t[15]=p,t[16]=w,t[17]=T}else w=t[16],T=t[17];let ee;return t[18]!==w||t[19]!==T?(ee=(0,M.jsxs)(M.Fragment,{children:[w,T]}),t[18]=w,t[19]=T,t[20]=ee):ee=t[20],ee},Le=()=>{let e=0,t=new Set,n=new Map,r=e=>{let t=n.get(e);if(t)for(let e of t)e()};return{getSnapshot:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),subscribeIndex:(e,t)=>{let r=n.get(e);return r||(r=new Set,n.set(e,r)),r.add(t),()=>{r.delete(t),r.size===0&&n.delete(e)}},set:n=>{if(e===n)return;let i=e;e=n,r(i),r(n);for(let e of t)e()}}},Re=E.memo(e=>{let t=(0,D.c)(12),{store:n,index:r,children:i}=e,a;t[0]!==r||t[1]!==n?(a=()=>n.getSnapshot()===r,t[0]=r,t[1]=n,t[2]=a):a=t[2];let[o,s]=E.useState(a),c,l;t[3]!==r||t[4]!==n?(c=()=>{let e=()=>s(n.getSnapshot()===r);return e(),n.subscribeIndex(r,e)},l=[r,n],t[3]=r,t[4]=n,t[5]=c,t[6]=l):(c=t[5],l=t[6]),E.useEffect(c,l);let u;t[7]!==i||t[8]!==o?(u=i(o),t[7]=i,t[8]=o,t[9]=u):u=t[9];let d;return t[10]===u?d=t[11]:(d=(0,M.jsx)(M.Fragment,{children:u}),t[10]=u,t[11]=d),d}),ze=e=>{let t=(0,D.c)(11),{store:n,flatModelList:r,footerContent:i,fallback:a}=e,o;t[0]===n?o=t[1]:(o=()=>n.getSnapshot(),t[0]=n,t[1]=o);let[s,c]=E.useState(o),l,u;t[2]===n?(l=t[3],u=t[4]):(l=()=>n.subscribe(()=>c(n.getSnapshot())),u=[n],t[2]=n,t[3]=l,t[4]=u),E.useEffect(l,u);let d=r[s],f;t[5]!==d||t[6]!==a||t[7]!==i?(f=typeof i==`function`?i(d):i??a,t[5]=d,t[6]=a,t[7]=i,t[8]=f):f=t[8];let p;return t[9]===f?p=t[10]:(p=(0,M.jsx)(M.Fragment,{children:f}),t[9]=f,t[10]=p),p},Be=e=>{let t=(0,D.c)(21),{id:n,disabled:r,children:i}=e,a=r!==void 0&&r,o;t[0]!==a||t[1]!==n?(o={id:n,disabled:a},t[0]=a,t[1]=n,t[2]=o):o=t[2];let{attributes:s,listeners:l,setNodeRef:u,setActivatorNodeRef:d,transform:f,transition:p,isDragging:m}=ae(o),h;t[3]===f?h=t[4]:(h=re.Transform.toString(f),t[3]=f,t[4]=h);let g;t[5]!==h||t[6]!==p?(g={transform:h,transition:p},t[5]=h,t[6]=p,t[7]=g):g=t[7];let _=m&&`opacity-60`,v;t[8]===_?v=t[9]:(v=c(_),t[8]=_,t[9]=v);let y;t[10]!==s||t[11]!==i||t[12]!==m||t[13]!==l||t[14]!==d?(y=i({attributes:s,listeners:l,setActivatorNodeRef:d,isDragging:m}),t[10]=s,t[11]=i,t[12]=m,t[13]=l,t[14]=d,t[15]=y):y=t[15];let b;return t[16]!==u||t[17]!==g||t[18]!==v||t[19]!==y?(b=(0,M.jsx)(`div`,{ref:u,style:g,className:v,children:y}),t[16]=u,t[17]=g,t[18]=v,t[19]=y,t[20]=b):b=t[20],b},Ve=e=>{let t=(0,D.c)(21),{id:n,disabled:r,children:i}=e,a=r!==void 0&&r,o;t[0]!==a||t[1]!==n?(o={id:n,disabled:a},t[0]=a,t[1]=n,t[2]=o):o=t[2];let{attributes:s,listeners:l,setNodeRef:u,setActivatorNodeRef:d,transform:f,transition:p,isDragging:m}=ae(o),h;t[3]===f?h=t[4]:(h=re.Translate.toString(f),t[3]=f,t[4]=h);let g;t[5]!==h||t[6]!==p?(g={transform:h,transition:p},t[5]=h,t[6]=p,t[7]=g):g=t[7];let _=m&&`opacity-60`,v;t[8]===_?v=t[9]:(v=c(_),t[8]=_,t[9]=v);let y;t[10]!==s||t[11]!==i||t[12]!==m||t[13]!==l||t[14]!==d?(y=i({attributes:s,listeners:l,setActivatorNodeRef:d,isDragging:m}),t[10]=s,t[11]=i,t[12]=m,t[13]=l,t[14]=d,t[15]=y):y=t[15];let b;return t[16]!==u||t[17]!==g||t[18]!==v||t[19]!==y?(b=(0,M.jsx)(`div`,{ref:u,style:g,className:v,children:y}),t[16]=u,t[17]=g,t[18]=v,t[19]=y,t[20]=b):b=t[20],b},He=new Set,Ue=32,We=(e,t)=>{if(!t)return;if(!e){t.scrollIntoView({block:`nearest`});return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-n.top+e.scrollTop,a=i+r.height,o=e.scrollTop,s=o+e.clientHeight,c=i<o+Ue?i-Ue:a>s?a-e.clientHeight:o,l=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop=Math.max(0,Math.min(c,l))},I=({providers:e,favoriteModels:t,recentModels:n,getMetadata:r,searchQuery:i,onSearchQueryChange:a,onSelect:o,labels:u,selectedModel:d,hiddenModels:f=[],allowedProviderIds:p,allowedModelIdsByProvider:m,includeNotSelected:h=!1,onSelectNone:re,selectionCount:ae,disabled:D=!1,maxHeightClassName:le=`max-h-[min(400px,calc(100dvh-12rem))] flex-1`,maxHeightStyle:ue,sectionHeaderClassName:O,rowClassName:de,stickyHeaders:fe=!0,autoFocus:pe=!0,onEscape:me,isFavorite:he,onToggleFavorite:ge,renderRowEnd:_e,onActiveKeyDown:ve,onActiveEntryChange:k,onVariantKey:xe,onReorderFavorite:Se,reorderFavoriteAriaLabel:Ce,reorderFavoriteTitle:we,providerOrder:A,onReorderProvider:Te,reorderProviderTitle:De,footerContent:j,renderVersion:je,tooltipsEnabled:Me=!0,virtualize:N=!1,stairs:Ne=!1,recencyOrder:Fe})=>{let F=Ne&&N,Ue=E.useRef(null);Ue.current||=Le();let I=Ue.current,L=E.useRef([]),R=E.useRef(null),z=E.useRef(!1),Ge=E.useRef(null),Ke=Ae(e=>e.collapsedSections),qe=Ae(e=>e.toggleSection),Je=E.useMemo(()=>new Set(Object.keys(Ke).filter(e=>Ke[e])),[Ke]),B=i.trim().length>0,[Ye,Xe]=E.useState(()=>new Set),V=F?He:B?Ye:Je,Ze=ne(C(ee,{activationConstraint:{distance:8}})),Qe=ne(C(T,{activationConstraint:{distance:8}})),H=E.useMemo(()=>!p||p.length===0?null:new Set(p),[p]),$e=E.useMemo(()=>m?new Map(Object.entries(m).map(([e,t])=>[e,new Set(t)])):null,[m]),U=E.useCallback((e,t)=>!$e||$e.get(e)?.has(t)===!0,[$e]),et=E.useMemo(()=>new Map(e.map(e=>[e.id,e])),[e]),W=E.useCallback((e,t)=>f.some(n=>n.providerID===e&&n.modelID===t),[f]),G=E.useCallback((e,t,n,r)=>{let a=i.trim();return!a||be(Ee({providerName:t,providerID:n,modelName:e,modelID:r}),a)},[i]),K=E.useMemo(()=>t.filter(({model:e,providerID:t,modelID:n})=>{if(H&&!H.has(t)||!U(t,n)||W(t,n))return!1;let r=et.get(t)?.name||t;return G(P(e),r,t,n)}),[H,t,U,W,G,et]),q=E.useMemo(()=>n.filter(({model:e,providerID:t,modelID:n})=>{if(H&&!H.has(t)||!U(t,n)||W(t,n))return!1;let r=et.get(t)?.name||t;return G(P(e),r,t,n)}),[H,U,W,G,et,n]),tt=d?.providerID,nt=E.useMemo(()=>{let t=e;if(A&&A.length>0){let n=new Map(A.map((e,t)=>[e,t])),r=e.filter(e=>n.has(e.id)).sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0)),i=e.filter(e=>!n.has(e.id));t=[...r,...i]}return F?Oe(t,tt):t},[A,e,tt,F]),J=E.useMemo(()=>nt.filter(e=>!H||H.has(e.id)).map(e=>{let t=(Array.isArray(e.models)?e.models:[]).filter(t=>{let n=typeof t.id==`string`?t.id:``;return!n||W(e.id,n)||!U(e.id,n)?!1:G(P(t),e.name||e.id,e.id,n)});return{...e,models:t}}).filter(e=>e.models.length>0),[H,U,W,G,nt]),Y=E.useMemo(()=>!F||!B?null:ke({candidates:J.flatMap(e=>e.models.map(t=>({entry:{model:t,providerID:e.id,modelID:t.id},providerName:e.name||e.id,modelName:P(t)}))),query:i.trim(),recencyOrder:Fe??n,recentModels:n,favoriteModels:t,selectedModel:d}),[t,J,B,Fe,n,i,d,F]),rt=E.useMemo(()=>nt.filter(e=>!H||H.has(e.id)).filter(e=>(Array.isArray(e.models)?e.models:[]).some(t=>{let n=typeof t.id==`string`?t.id:``;return!!n&&!W(e.id,n)&&U(e.id,n)})),[H,U,W,nt]),{flatModelList:X,modelRowIndices:it}=E.useMemo(()=>{let e=[],t=new Map,n=(n,r)=>{t.set(`${r}:${n.providerID}:${n.modelID}`,e.length),e.push(n)};return Y?(Y.forEach(e=>n(e,`search`)),{flatModelList:e,modelRowIndices:t}):(V.has(`favorites`)||K.forEach(e=>n(e,`fav`)),V.has(`recent`)||q.forEach(e=>n(e,`recent`)),J.forEach(e=>{V.has(`provider:${e.id}`)||e.models.forEach(t=>n({model:t,providerID:e.id,modelID:t.id},`provider`))}),{flatModelList:e,modelRowIndices:t})},[V,K,J,q,Y]),[Z,at]=E.useState(16);E.useLayoutEffect(()=>{N&&at(Number.parseFloat(getComputedStyle(document.documentElement).fontSize)||16)},[N]);let Q=E.useMemo(()=>{if(!N)return[];let e=[],t=0,n=(n,r,i,a)=>{if(e.push({key:n,height:(1.5+(a?.625:0))*Z,modelIndex:-1}),!V.has(n))for(let a of r)e.push({key:`${n}:${a.providerID}:${a.modelID}`,height:i*Z,modelIndex:t++})};if(Y){for(let n of Y)e.push({key:`search:${n.providerID}:${n.modelID}`,height:2.5*Z,modelIndex:t++});return e}return K.length&&n(`favorites`,K,2.5,!1),q.length&&n(`recent`,q,2.5,K.length>0),J.forEach((e,t)=>n(`provider:${e.id}`,e.models.map(t=>({model:t,providerID:e.id,modelID:t.id})),2,t>0||K.length>0||q.length>0)),e},[V,K,J,q,Z,Y,N]),ot=E.useMemo(()=>{if(!F||Y)return[];let e=1.5*Z,t=[],n=.375*Z;for(let r of Q)r.modelIndex===-1&&r.key.startsWith(`provider:`)&&t.push({id:r.key.slice(9),top:n+r.height-e}),n+=r.height;return t},[Z,Y,F,Q]),st=E.useRef(null),[ct,lt]=E.useState(null),ut=E.useMemo(()=>({estimateSize:e=>Q[e].height,getItemKey:e=>Q[e].key}),[Q]),dt=_({enabled:N,count:Q.length,getScrollElement:()=>R.current,...ut,paddingStart:.375*Z,paddingEnd:.375*Z,overscan:6,initialRect:{width:400,height:400}}),ft=dt.getVirtualItems(),pt=new Set(ft.map(e=>Q[e.index].modelIndex)),mt=dt.scrollOffset??0,ht=(()=>{if(ct&&Math.abs(mt-ct.offset)<2)return ct.id;let e=`all`;for(let t of ot)t.top<=mt+4&&(e=t.id);return e})();E.useEffect(()=>{let e=st.current,t=e?.querySelector(`[aria-current="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.top<n.top?e.scrollTop+=r.top-n.top-4:r.bottom>n.bottom&&(e.scrollTop+=r.bottom-n.bottom+4)},[ht,F]);let gt=e=>{let t=R.current;if(!t)return;let n=e===`all`?0:ot.find(t=>t.id===e)?.top;if(n===void 0)return;let r=Math.max(0,Math.min(n,t.scrollHeight-t.clientHeight));t.scrollTop=r,lt({id:e,offset:r})},_t=X.length>0,vt=!!Se&&i.trim().length===0&&K.length>1,yt=!!Te&&i.trim().length===0&&!H&&J.length>1,bt=E.useMemo(()=>new Map(K.map(e=>[`${e.providerID}:${e.modelID}`,e])),[K]);E.useEffect(()=>{I.set(0)},[i,I]),E.useEffect(()=>{B||Xe(e=>e.size===0?e:new Set)},[B]);let xt=E.useCallback(e=>{I.set(e),k?.(X[e])},[X,k,I]),St=E.useCallback(e=>{let t=X.length;if(t===0)return;z.current=!0,Ge.current=null;let n=(I.getSnapshot()+e+t)%t;I.set(n),k?.(X[n]),requestAnimationFrame(()=>We(R.current,L.current[n]))},[X,k,I]);E.useEffect(()=>{k?.(X[I.getSnapshot()])},[X,k,I]);let Ct=E.useCallback(e=>{if(!e.defaultPrevented){if(e.stopPropagation(),e.key===`ArrowLeft`||e.key===`ArrowRight`){let t=X[I.getSnapshot()];if(t&&xe?.(e,t))return}if(ve?.(e,X[I.getSnapshot()]),!e.defaultPrevented){if(e.key===`ArrowDown`){e.preventDefault(),St(1);return}if(e.key===`ArrowUp`){e.preventDefault(),St(-1);return}if(e.key===`Enter`){e.preventDefault();let t=X[I.getSnapshot()];t&&!D&&o(t);return}e.key===`Escape`&&(e.preventDefault(),me?.())}}},[D,X,St,ve,me,o,xe,I]),wt=c(`model-picker-section-header typography-micro font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2 px-2 py-1.5`,fe&&`sticky top-0 z-10 [background:linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))]`,O),$=(e,t,n,i)=>{let a=it.get(`${t}:${e.providerID}:${e.modelID}`);if(a===void 0)return null;if(N&&!i?.isDragging&&!(ft.length?pt.has(a):a<12))return(0,M.jsx)(`div`,{ref:e=>{L.current[a]=e},className:`model-picker-row-placeholder`,"data-model-section":t,"aria-hidden":`true`},`${t}-${e.providerID}-${e.modelID}`);let s=ye(e.providerID,e.model,r?.(e.providerID,e.modelID)),f=et.get(e.providerID)?.name||e.providerID,p=Pe(s?.limit?.context),m=ae?.(e)??0,h=d?.providerID===e.providerID&&d.modelID===e.modelID,g=he?.(e)??!1,_=e=>{let t={x:e.clientX,y:e.clientY},n=Ge.current,r=!n||n.x!==t.x||n.y!==t.y;Ge.current=t,!(z.current&&!n)&&(z.current&&!r||(z.current&&r&&(z.current=!1),xt(a)))};return(0,M.jsx)(Re,{store:I,index:a,renderVersion:je,children:r=>{let d=(0,M.jsxs)(`div`,{ref:e=>{L.current[a]=e},role:`option`,"data-model-section":t,"aria-selected":h,"aria-setsize":N?X.length:void 0,"aria-posinset":N?a+1:void 0,"aria-disabled":D||void 0,tabIndex:-1,onClick:()=>{D||o(e)},onKeyDown:t=>{D||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e))},onMouseEnter:_,onMouseMove:_,className:c(`model-picker-row w-full text-left px-2 py-1.5 rounded-md typography-meta flex items-center gap-2 cursor-pointer`,!D&&(r?`bg-interactive-selection`:`hover:bg-interactive-hover/50`),D&&`cursor-not-allowed opacity-60`,de),children:[(0,M.jsxs)(`div`,{className:`model-picker-row-main flex items-center gap-1.5 flex-1 min-w-0`,children:[i?(0,M.jsx)(`button`,{type:`button`,ref:i.setActivatorNodeRef,...i.attributes,...i.listeners,disabled:D,onClick:e=>{e.preventDefault(),e.stopPropagation()},className:`model-favorite-drag-handle flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground hover:text-foreground disabled:pointer-events-none`,"aria-label":Ce,title:we,children:(0,M.jsx)(l,{name:`draggable`,className:`size-3.5`})}):null,n?(0,M.jsx)(S,{modelId:e.modelID,providerId:e.providerID,className:`h-3.5 w-3.5 flex-shrink-0`}):null,(0,M.jsxs)(`span`,{className:`model-picker-row-labels contents`,children:[(0,M.jsx)(`span`,{className:`model-picker-row-name font-medium truncate`,children:P(e.model)}),(0,M.jsxs)(`span`,{className:`model-picker-row-meta contents`,children:[t===`provider`?null:(0,M.jsx)(`span`,{className:`model-picker-row-provider hidden truncate`,children:f}),p?(0,M.jsx)(`span`,{className:`model-picker-row-context typography-micro text-muted-foreground flex-shrink-0`,children:p}):null]})]})]}),m>0?(0,M.jsxs)(`span`,{className:`typography-micro text-muted-foreground flex-shrink-0`,children:[`x`,m]}):null,_e?.(e,{isHighlighted:r,isSelected:h}),(0,M.jsx)(`span`,{className:c(`model-picker-row-selection size-4 shrink-0`,!h&&`hidden`),children:h?(0,M.jsx)(l,{name:`check`,className:`h-4 w-4 text-primary`}):null}),ge?(0,M.jsx)(`button`,{type:`button`,disabled:D,onClick:t=>{t.preventDefault(),t.stopPropagation(),ge(e)},className:c(`model-favorite-button flex h-4 w-4 items-center justify-center hover:text-primary/80 flex-shrink-0 disabled:pointer-events-none`,g?`text-primary`:`text-muted-foreground`),"aria-label":g?u.unfavorite:u.favorite,title:g?u.unfavorite:u.favorite,children:(0,M.jsx)(l,{name:g?`star-fill`:`star`,className:`h-3.5 w-3.5`})}):null]});return(0,M.jsx)(Ie,{metadata:s,providerName:f,providerID:e.providerID,modelID:e.modelID,active:Me&&r,anchor:()=>L.current[a],labels:u,children:d})}},`${t}-${e.providerID}-${e.modelID}`)},Tt=e=>{if(!Se)return;let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=bt.get(String(t.id)),i=bt.get(String(n.id));!r||!i||Se(r,i)},Et=e=>{if(!Te)return;let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=nt.map(e=>e.id),i=r.indexOf(String(t.id)),a=r.indexOf(String(n.id));i!==-1&&a!==-1&&Te(ie(r,i,a))},Dt=e=>V.has(e),Ot=e=>{if(!B){qe(e);return}Xe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},kt=(e,t,n,r)=>{let i=Dt(e),a=t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Ot(e))};return F?(0,M.jsx)(`div`,{ref:r?.setActivatorNodeRef,...r?.attributes,...r?.listeners,title:r?De:void 0,className:c(wt,r&&`cursor-grab select-none active:cursor-grabbing`),children:(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:n})}):r?(0,M.jsxs)(`div`,{ref:r.setActivatorNodeRef,...r.attributes,...r.listeners,role:`button`,tabIndex:0,"aria-expanded":!i,title:De,className:c(wt,`w-full text-left cursor-grab select-none active:cursor-grabbing`),onClick:()=>Ot(e),onKeyDown:a,children:[(0,M.jsx)(l,{name:`draggable`,className:`size-3.5 flex-shrink-0 text-muted-foreground/70`}),t,(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),(0,M.jsx)(`span`,{className:`ml-auto flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,children:(0,M.jsx)(l,{name:i?`arrow-right-s`:`arrow-down-s`,className:`size-4`})})]}):(0,M.jsxs)(`button`,{type:`button`,className:c(wt,`w-full text-left cursor-pointer`),onClick:()=>Ot(e),"aria-expanded":!i,children:[t,(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),(0,M.jsx)(`span`,{className:`ml-auto flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,children:(0,M.jsx)(l,{name:i?`arrow-right-s`:`arrow-down-s`,className:`size-4`})})]})},At=(e,t,n)=>(0,M.jsxs)(M.Fragment,{children:[t>0?(0,M.jsx)(`div`,{className:`model-picker-section-divider h-px bg-border/40 my-1`}):null,kt(`provider:${e.id}`,(0,M.jsx)(ce,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),e.name||e.id,n),Dt(`provider:${e.id}`)?null:e.models.map(t=>$({model:t,providerID:e.id,modelID:t.id},`provider`,!0))]}),jt=(0,M.jsx)(g,{ref:R,outerClassName:F?`min-w-0 flex-1`:le,className:`overlay-scrollbar-target--no-gutter`,style:F?void 0:ue,children:(0,M.jsxs)(`div`,{className:`model-picker-list px-1`,children:[h?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 typography-meta text-muted-foreground hover:bg-interactive-hover/50`,onClick:re,children:[(0,M.jsx)(l,{name:`close`,className:`h-3.5 w-3.5`}),(0,M.jsx)(`span`,{children:u.notSelected}),d?null:(0,M.jsx)(l,{name:`check`,className:`h-4 w-4 text-primary ml-auto`})]}),(0,M.jsx)(`div`,{className:`h-px bg-border/40 my-1`})]}):null,_t?null:(0,M.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:u.noResults}),Y?Y.map(e=>$(e,`search`,!0)):(0,M.jsxs)(M.Fragment,{children:[K.length>0?(0,M.jsxs)(`div`,{className:`model-picker-section`,children:[kt(`favorites`,(0,M.jsx)(l,{name:`star-fill`,className:`h-4 w-4 text-primary`}),u.favorites),!Dt(`favorites`)&&(vt?(0,M.jsx)(te,{sensors:Ze,collisionDetection:w,onDragEnd:Tt,children:(0,M.jsx)(se,{items:K.map(e=>`${e.providerID}:${e.modelID}`),strategy:oe,children:K.map(e=>(0,M.jsx)(Be,{id:`${e.providerID}:${e.modelID}`,disabled:D,children:t=>$(e,`fav`,!0,t)},`fav-sortable-${e.providerID}-${e.modelID}`))})}):K.map(e=>$(e,`fav`,!0)))]}):null,q.length>0?(0,M.jsxs)(`div`,{className:`model-picker-section`,children:[K.length>0?(0,M.jsx)(`div`,{className:`model-picker-section-divider h-px bg-border/40 my-1`}):null,kt(`recent`,(0,M.jsx)(l,{name:`time`,className:`h-4 w-4`}),u.recent),Dt(`recent`)?null:q.map(e=>$(e,`recent`,!0))]}):null,(K.length>0||q.length>0)&&J.length>0?(0,M.jsx)(`div`,{className:`model-picker-section-divider h-px bg-border/40 my-1`}):null,yt?(0,M.jsx)(te,{sensors:Qe,collisionDetection:w,onDragEnd:Et,children:(0,M.jsx)(se,{items:J.map(e=>e.id),strategy:oe,children:J.map((e,t)=>(0,M.jsx)(Ve,{id:e.id,disabled:D,children:n=>At(e,t,n)},e.id))})}):J.map((e,t)=>(0,M.jsx)(`div`,{children:At(e,t)},e.id))]})]})}),Mt=F?(0,M.jsx)(`nav`,{ref:st,className:c(`model-picker-rail`,B&&`pointer-events-none opacity-40`),"aria-label":u.provider,"aria-disabled":B||void 0,children:[{id:`all`,name:u.all},...rt.map(e=>({id:e.id,name:e.name||e.id}))].map(e=>(0,M.jsxs)(b,{children:[(0,M.jsx)(v,{asChild:!0,children:(0,M.jsx)(s,{variant:`ghost`,size:`icon`,tabIndex:B?-1:void 0,"aria-label":e.name,"aria-current":!B&&ht===e.id?`true`:void 0,onClick:()=>gt(e.id),className:c(`model-picker-rail-item size-8`,!B&&ht===e.id&&`bg-interactive-selection`),children:e.id===`all`?(0,M.jsx)(l,{name:`list-unordered`,className:`size-4`}):(0,M.jsx)(ce,{providerId:e.id,className:`size-4 flex-shrink-0`})})}),(0,M.jsx)(y,{side:`right`,sideOffset:6,children:e.name})]},e.id))}):null;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`model-picker-search-area p-1.5 pb-1`,children:(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(l,{name:`search`,className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,M.jsx)(x,{type:`text`,placeholder:u.searchPlaceholder,value:i,onChange:e=>a(e.target.value),onKeyDown:Ct,className:`model-picker-search h-8 pl-8 typography-meta`,autoFocus:pe})]})}),F?(0,M.jsxs)(`div`,{className:c(`model-picker-stairs flex min-h-0`,le),style:ue,children:[Mt,jt]}):jt,(0,M.jsx)(`div`,{className:`model-picker-footer px-3 pt-1 pb-1.5 border-t border-border/40 typography-micro text-muted-foreground`,children:(0,M.jsx)(ze,{store:I,flatModelList:X,footerContent:j,fallback:u.keyboardHint})})]})};function L(){}function R(e){let{key:t,icon:n,label:r}=e;return(0,M.jsx)(N,{iconName:n,label:r},t)}function z(e,t,n,r,i){let a=e.find(e=>e.id===n);if(!a)return null;let o=(Array.isArray(a.models)?a.models:[]).find(e=>e.id===r);return!o||t.some(e=>e.providerID===n&&e.modelID===r)?null:i===void 0?{provider:a,model:o,providerID:n,modelID:r}:{provider:a,model:o,providerID:n,modelID:r,variant:i}}var Ge=e=>{let t=(0,D.c)(30),n=u(Ke),r=o(qe),i=o(Je),a=o(B),s=e?.currentProviderID??null,c=e?.currentModelID??null,l;if(t[0]!==r||t[1]!==a||t[2]!==n){let e;t[4]!==a||t[5]!==n?(e=e=>{let{providerID:t,modelID:r,variant:i}=e;return z(n,a,t,r,i)},t[4]=a,t[5]=n,t[6]=e):e=t[6],l=r.map(e).filter(Ye),t[0]=r,t[1]=a,t[2]=n,t[3]=l}else l=t[3];let d=l,f;if(t[7]!==c||t[8]!==s||t[9]!==r||t[10]!==a||t[11]!==n||t[12]!==i){bb0:{let e;t[14]!==a||t[15]!==n?(e=e=>{let{providerID:t,modelID:r,variant:i}=e;return z(n,a,t,r,i)},t[14]=a,t[15]=n,t[16]=e):e=t[16];let o;t[17]===r?o=t[18]:(o=e=>{let{providerID:t,modelID:n}=e;return!r.some(e=>e.providerID===t&&e.modelID===n)},t[17]=r,t[18]=o);let l=i.map(e).filter(Xe).filter(o);if(!s||!c){f=l;break bb0}if(r.some(e=>e.providerID===s&&e.modelID===c)){f=l;break bb0}let u;t[19]!==c||t[20]!==s?(u=e=>e.providerID===s&&e.modelID===c,t[19]=c,t[20]=s,t[21]=u):u=t[21];let d=l.findIndex(u);if(d===0){f=l;break bb0}if(d>0){let e=l.slice(),[t]=e.splice(d,1);e.unshift(t),f=e;break bb0}let p;t[22]!==c||t[23]!==s||t[24]!==a||t[25]!==n?(p=z(n,a,s,c),t[22]=c,t[23]=s,t[24]=a,t[25]=n,t[26]=p):p=t[26];let m=p;if(!m){f=l;break bb0}f=[m,...l]}t[7]=c,t[8]=s,t[9]=r,t[10]=a,t[11]=n,t[12]=i,t[13]=f}else f=t[13];let p=f,m;return t[27]!==d||t[28]!==p?(m={favoriteModelsList:d,recentModelsList:p},t[27]=d,t[28]=p,t[29]=m):m=t[29],m};function Ke(e){return e.providers}function qe(e){return e.favoriteModels}function Je(e){return e.recentModels}function B(e){return e.hiddenModels}function Ye(e){return e!==null}function Xe(e){return e!==null}export{Ee as a,fe as c,ge as d,_e as f,ke as i,pe as l,I as n,be as o,me as p,Oe as r,ye as s,Ge as t,he as u};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,i as n}from"./vendor-zustand-CTekDqaS.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{r as o}from"./useUIStore-C3ewjGgP.js";import{i as s,o as c}from"./session-startup-barrier-DT-hIBRf.js";import{n as l}from"./Icon-DmykXZL1.js";import{Hi as u,Ja as d,t as f,ta as p}from"./ui-ee2iN869.js";import{n as m,t as h}from"./i18n-DXc6czdR.js";import{t as g}from"./ScrollableOverlay-stxT7gLf.js";import{t as _}from"./vendor-tanstack-react-virtual-qsd3nvZb.js";import{i as v,n as y,t as b}from"./tooltip-CpTbxEOE.js";import{t as x}from"./input-Cf16qJ6g.js";import{t as S}from"./ModelLogo-BkbD514M.js";import{_ as C,l as w,o as T,s as ee,t as te,v as ne,y as re}from"./vendor-dnd-kit-core-qy5stxu5.js";import{n as ie,o as ae,s as oe,t as se}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as ce}from"./ProviderLogo-DA98yu7M.js";var E=e(i(),1),D=a(),le={compact:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0},compactTokensShort:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1},usd:{style:`currency`,currency:`USD`,maximumFractionDigits:4,minimumFractionDigits:2}},ue=null,O={},de=(e,t)=>{ue!==t&&(ue=t,O.compact=void 0,O.compactTokensShort=void 0,O.usd=void 0);let n=O[e];if(n)return n;let r=new Intl.NumberFormat(t,le[e]);return O[e]=r,r},fe=(e,t=m())=>de(`compact`,t).format(e),pe=(e,t=m())=>de(`compactTokensShort`,t).format(e),me=(e,t=m())=>de(`usd`,t).format(e),he=(e,t=m())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),ge=(e,t=m())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),_e=(e,t=m())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),ve=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ye=(e,t,n)=>{let r=ve(t.limit,`context`),i=ve(t.limit,`output`),a=r??n?.limit?.context,o=i??n?.limit?.output;return a===void 0&&o===void 0?n:{...n??{id:typeof t.id==`string`?t.id:``,providerId:e,name:typeof t.name==`string`?t.name:void 0},limit:{...n?.limit,...a===void 0?{}:{context:a},...o===void 0?{}:{output:o}}}};function k(e){let t=e.toLowerCase().trim();return{lower:t,compact:t.replace(/[^a-z0-9]/g,``),tokens:t.split(/[^a-z0-9]+/).filter(Boolean)}}function be(e,t){if(xe(e,t))return!0;let n=t.trim().split(/\s+/).filter(Boolean);return n.length>1&&n.every(t=>xe(e,t))}function xe(e,t){let n=k(t);if(!n.lower)return!0;let r=k(e);return r.lower.includes(n.lower)||n.compact.length>=2&&r.compact.includes(n.compact)?!0:n.tokens.length!==0&&n.tokens.every(e=>r.tokens.some(t=>t.startsWith(e)||t.includes(e)))}var Se=40,Ce=8,we=8,A=6,Te=e=>{try{return decodeURIComponent(e)}catch{return e}};function Ee(e){let t=Te(e.providerID);return[e.providerName,e.providerID,t===e.providerID?``:t,e.modelName,e.modelID].filter(Boolean).join(` `)}function De(e,t,n,r={}){let i=k(n),a=k(e),o=i.compact.length>=2,s;if(!i.lower)s=1;else if(a.compact!==``&&a.compact===i.compact)s=100;else if(a.lower.startsWith(i.lower)||o&&a.compact.startsWith(i.compact))s=80;else if(i.tokens.length>0&&i.tokens.every(e=>a.tokens.some(t=>t.startsWith(e))))s=65;else if(a.lower.includes(i.lower)||o&&a.compact.includes(i.compact))s=50;else if(be(r.searchText??`${t} ${e}`,n))s=20;else return 0;let c=r.recencyRank,l=c===void 0||c<0?0:Math.max(0,Se-c*Ce);return s+l+(r.favorite?we:0)+(r.selectedProvider?A:0)}var j=(e,t)=>`${e}:${t}`;function Oe(e,t){if(!t)return e;let n=e.find(e=>e.id===t);return!n||e[0]===n?e:[n,...e.filter(e=>e!==n)]}function ke(e){let{candidates:t,query:n,recencyOrder:r,recentModels:i,favoriteModels:a,selectedModel:o}=e,s=new Map;(o?[o,...r]:r).forEach(({providerID:e,modelID:t},n)=>{let r=j(e,t);s.has(r)||s.set(r,n)});let c=new Set(a.map(({providerID:e,modelID:t})=>j(e,t))),l=new Map;[...i,...a].forEach(({providerID:e,modelID:t,variant:n})=>{n!==void 0&&l.set(j(e,t),n)});let u=[];for(let{entry:e,providerName:r,modelName:i}of t){let t=j(e.providerID,e.modelID),a=De(i,r,n,{recencyRank:s.get(t),favorite:c.has(t),selectedProvider:o?.providerID===e.providerID,searchText:Ee({providerName:r,providerID:e.providerID,modelName:i,modelID:e.modelID})});if(a<=0)continue;let d=l.get(t);u.push({entry:d===void 0?e:{...e,variant:d},score:a})}return u.sort((e,t)=>t.score-e.score).map(({entry:e})=>e)}var Ae=t()(n(e=>({collapsedSections:{},toggleSection:t=>e(e=>{let n={...e.collapsedSections};return n[t]?delete n[t]:n[t]=!0,{collapsedSections:n}})}),{name:`model-picker-collapsed-sections`,version:1})),M=r(),je={image:{icon:`file-image`,labelKey:`modalityImage`},video:{icon:`file-video`,labelKey:`modalityVideo`},audio:{icon:`file-music`,labelKey:`modalityAudio`}},Me=e=>e.trim().toLowerCase(),N=e=>{let t=(0,D.c)(5),{iconName:n,label:r}=e,i;t[0]===n?i=t[1]:(i=(0,M.jsx)(l,{name:n,className:`size-3.5`}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,M.jsx)(`span`,{className:`flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,title:r,"aria-label":r,role:`img`,children:i}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},Ne=(e,t)=>{let n=[];e?.tool_call&&t.capabilityToolCalling&&n.push({key:`tool_call`,icon:`tools`,label:t.capabilityToolCalling}),e?.reasoning&&t.capabilityReasoning&&n.push({key:`reasoning`,icon:`brain-ai-3`,label:t.capabilityReasoning});let r=[...e?.modalities?.input??[],...e?.modalities?.output??[]],i=Array.from(new Set(r.map(Me).filter(Boolean)));for(let e of i){let r=je[e];if(!r)continue;let i=t[r.labelKey];i&&n.push({key:`modality-${e}`,icon:r.icon,label:i})}return n},P=e=>p(e,void 0,{maxLength:40}),Pe=e=>{if(typeof e!=`number`||Number.isNaN(e))return``;if(e===0)return`0`;let t=fe(e);return t.endsWith(`.0`)?t.slice(0,-2):t},Fe=e=>typeof e!=`number`||!Number.isFinite(e)?`—`:me(e),F=(e,t)=>t?!0:e?!!(e.tool_call||e.reasoning||e.cost?.input!==void 0||e.cost?.output!==void 0||(e.modalities?.input?.length??0)>0||(e.modalities?.output?.length??0)>0):!1,Ie=e=>{let t=(0,D.c)(21),{metadata:n,providerName:r,providerID:i,modelID:a,active:o,anchor:c,labels:l,children:u}=e,{t:p}=h(),[m,g]=E.useState(!1),_=`${i}/${a}`,v,x;t[0]===o?(v=t[1],x=t[2]):(v=()=>{if(!o){g(!1);return}let e=window.setTimeout(()=>g(!0),450);return()=>window.clearTimeout(e)},x=[o],t[0]=o,t[1]=v,t[2]=x),E.useEffect(v,x);let S;t[3]!==o||t[4]!==m||t[5]!==n||t[6]!==r?(S=o&&m&&F(n,r),t[3]=o,t[4]=m,t[5]=n,t[6]=r,t[7]=S):S=t[7];let C=S,w,T;if(t[8]!==c||t[9]!==u||t[10]!==l||t[11]!==n||t[12]!==_||t[13]!==r||t[14]!==C||t[15]!==p){let e=C?Ne(n,l):[],i=n?.cost?.input!==void 0||n?.cost?.output!==void 0;w=u,T=C?(0,M.jsx)(b,{open:!0,onOpenChange:L,children:(0,M.jsx)(y,{anchor:c,side:`right`,sideOffset:8,className:`min-w-52 max-w-xs text-left transition-none data-[starting-style]:opacity-100 data-[starting-style]:scale-100 data-[ending-style]:opacity-100 data-[ending-style]:scale-100`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 text-left text-xs`,children:[r&&l.provider?(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground`,children:[(0,M.jsx)(`span`,{className:`typography-meta font-medium`,children:l.provider}),(0,M.jsx)(`span`,{className:`typography-meta text-foreground`,children:r})]}):null,e.length>0?(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground`,children:[(0,M.jsx)(`span`,{className:`typography-meta font-medium shrink-0`,children:l.capabilities}),(0,M.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:e.map(R)})]}):null,i?(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-muted-foreground`,children:[l.costPerMillion?(0,M.jsx)(`span`,{className:`typography-meta font-medium shrink-0`,children:l.costPerMillion}):null,(0,M.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 min-w-0`,children:[l.costInput?(0,M.jsx)(`span`,{className:`typography-meta shrink-0`,children:l.costInput}):null,(0,M.jsx)(`span`,{className:`typography-meta text-foreground tabular-nums`,children:Fe(n?.cost?.input)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 min-w-0`,children:[l.costOutput?(0,M.jsx)(`span`,{className:`typography-meta shrink-0`,children:l.costOutput}):null,(0,M.jsx)(`span`,{className:`typography-meta text-foreground tabular-nums`,children:Fe(n?.cost?.output)})]})]})]}):null,(0,M.jsx)(s,{variant:`ghost`,size:`xs`,className:`h-auto min-h-0 w-full min-w-0 justify-end gap-0 rounded-none p-0 text-right cursor-copy font-normal text-muted-foreground hover:bg-transparent active:bg-transparent`,"aria-label":p(`onboarding.common.copyToClipboard`),title:_,onClick:async e=>{e.stopPropagation();try{(await d(_)).ok?f.success(p(`contextSidebar.actions.copied`)):f.error(p(`filesView.toast.copyFailed`))}catch{f.error(p(`filesView.toast.copyFailed`))}},children:(0,M.jsx)(`span`,{className:`block w-full min-w-0 truncate text-right text-[10px] leading-tight`,children:_})})]})})}):null,t[8]=c,t[9]=u,t[10]=l,t[11]=n,t[12]=_,t[13]=r,t[14]=C,t[15]=p,t[16]=w,t[17]=T}else w=t[16],T=t[17];let ee;return t[18]!==w||t[19]!==T?(ee=(0,M.jsxs)(M.Fragment,{children:[w,T]}),t[18]=w,t[19]=T,t[20]=ee):ee=t[20],ee},Le=()=>{let e=0,t=new Set,n=new Map,r=e=>{let t=n.get(e);if(t)for(let e of t)e()};return{getSnapshot:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),subscribeIndex:(e,t)=>{let r=n.get(e);return r||(r=new Set,n.set(e,r)),r.add(t),()=>{r.delete(t),r.size===0&&n.delete(e)}},set:n=>{if(e===n)return;let i=e;e=n,r(i),r(n);for(let e of t)e()}}},Re=E.memo(e=>{let t=(0,D.c)(12),{store:n,index:r,children:i}=e,a;t[0]!==r||t[1]!==n?(a=()=>n.getSnapshot()===r,t[0]=r,t[1]=n,t[2]=a):a=t[2];let[o,s]=E.useState(a),c,l;t[3]!==r||t[4]!==n?(c=()=>{let e=()=>s(n.getSnapshot()===r);return e(),n.subscribeIndex(r,e)},l=[r,n],t[3]=r,t[4]=n,t[5]=c,t[6]=l):(c=t[5],l=t[6]),E.useEffect(c,l);let u;t[7]!==i||t[8]!==o?(u=i(o),t[7]=i,t[8]=o,t[9]=u):u=t[9];let d;return t[10]===u?d=t[11]:(d=(0,M.jsx)(M.Fragment,{children:u}),t[10]=u,t[11]=d),d}),ze=e=>{let t=(0,D.c)(11),{store:n,flatModelList:r,footerContent:i,fallback:a}=e,o;t[0]===n?o=t[1]:(o=()=>n.getSnapshot(),t[0]=n,t[1]=o);let[s,c]=E.useState(o),l,u;t[2]===n?(l=t[3],u=t[4]):(l=()=>n.subscribe(()=>c(n.getSnapshot())),u=[n],t[2]=n,t[3]=l,t[4]=u),E.useEffect(l,u);let d=r[s],f;t[5]!==d||t[6]!==a||t[7]!==i?(f=typeof i==`function`?i(d):i??a,t[5]=d,t[6]=a,t[7]=i,t[8]=f):f=t[8];let p;return t[9]===f?p=t[10]:(p=(0,M.jsx)(M.Fragment,{children:f}),t[9]=f,t[10]=p),p},Be=e=>{let t=(0,D.c)(21),{id:n,disabled:r,children:i}=e,a=r!==void 0&&r,o;t[0]!==a||t[1]!==n?(o={id:n,disabled:a},t[0]=a,t[1]=n,t[2]=o):o=t[2];let{attributes:s,listeners:l,setNodeRef:u,setActivatorNodeRef:d,transform:f,transition:p,isDragging:m}=ae(o),h;t[3]===f?h=t[4]:(h=re.Transform.toString(f),t[3]=f,t[4]=h);let g;t[5]!==h||t[6]!==p?(g={transform:h,transition:p},t[5]=h,t[6]=p,t[7]=g):g=t[7];let _=m&&`opacity-60`,v;t[8]===_?v=t[9]:(v=c(_),t[8]=_,t[9]=v);let y;t[10]!==s||t[11]!==i||t[12]!==m||t[13]!==l||t[14]!==d?(y=i({attributes:s,listeners:l,setActivatorNodeRef:d,isDragging:m}),t[10]=s,t[11]=i,t[12]=m,t[13]=l,t[14]=d,t[15]=y):y=t[15];let b;return t[16]!==u||t[17]!==g||t[18]!==v||t[19]!==y?(b=(0,M.jsx)(`div`,{ref:u,style:g,className:v,children:y}),t[16]=u,t[17]=g,t[18]=v,t[19]=y,t[20]=b):b=t[20],b},Ve=e=>{let t=(0,D.c)(21),{id:n,disabled:r,children:i}=e,a=r!==void 0&&r,o;t[0]!==a||t[1]!==n?(o={id:n,disabled:a},t[0]=a,t[1]=n,t[2]=o):o=t[2];let{attributes:s,listeners:l,setNodeRef:u,setActivatorNodeRef:d,transform:f,transition:p,isDragging:m}=ae(o),h;t[3]===f?h=t[4]:(h=re.Translate.toString(f),t[3]=f,t[4]=h);let g;t[5]!==h||t[6]!==p?(g={transform:h,transition:p},t[5]=h,t[6]=p,t[7]=g):g=t[7];let _=m&&`opacity-60`,v;t[8]===_?v=t[9]:(v=c(_),t[8]=_,t[9]=v);let y;t[10]!==s||t[11]!==i||t[12]!==m||t[13]!==l||t[14]!==d?(y=i({attributes:s,listeners:l,setActivatorNodeRef:d,isDragging:m}),t[10]=s,t[11]=i,t[12]=m,t[13]=l,t[14]=d,t[15]=y):y=t[15];let b;return t[16]!==u||t[17]!==g||t[18]!==v||t[19]!==y?(b=(0,M.jsx)(`div`,{ref:u,style:g,className:v,children:y}),t[16]=u,t[17]=g,t[18]=v,t[19]=y,t[20]=b):b=t[20],b},He=new Set,Ue=32,We=(e,t)=>{if(!t)return;if(!e){t.scrollIntoView({block:`nearest`});return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-n.top+e.scrollTop,a=i+r.height,o=e.scrollTop,s=o+e.clientHeight,c=i<o+Ue?i-Ue:a>s?a-e.clientHeight:o,l=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop=Math.max(0,Math.min(c,l))},I=({providers:e,favoriteModels:t,recentModels:n,getMetadata:r,searchQuery:i,onSearchQueryChange:a,onSelect:o,labels:u,selectedModel:d,hiddenModels:f=[],allowedProviderIds:p,allowedModelIdsByProvider:m,includeNotSelected:h=!1,onSelectNone:re,selectionCount:ae,disabled:D=!1,maxHeightClassName:le=`max-h-[min(400px,calc(100dvh-12rem))] flex-1`,maxHeightStyle:ue,sectionHeaderClassName:O,rowClassName:de,stickyHeaders:fe=!0,autoFocus:pe=!0,onEscape:me,isFavorite:he,onToggleFavorite:ge,renderRowEnd:_e,onActiveKeyDown:ve,onActiveEntryChange:k,onVariantKey:xe,onReorderFavorite:Se,reorderFavoriteAriaLabel:Ce,reorderFavoriteTitle:we,providerOrder:A,onReorderProvider:Te,reorderProviderTitle:De,footerContent:j,renderVersion:je,tooltipsEnabled:Me=!0,virtualize:N=!1,stairs:Ne=!1,recencyOrder:Fe})=>{let F=Ne&&N,Ue=E.useRef(null);Ue.current||=Le();let I=Ue.current,L=E.useRef([]),R=E.useRef(null),z=E.useRef(!1),Ge=E.useRef(null),Ke=Ae(e=>e.collapsedSections),qe=Ae(e=>e.toggleSection),Je=E.useMemo(()=>new Set(Object.keys(Ke).filter(e=>Ke[e])),[Ke]),B=i.trim().length>0,[Ye,Xe]=E.useState(()=>new Set),V=F?He:B?Ye:Je,Ze=ne(C(ee,{activationConstraint:{distance:8}})),Qe=ne(C(T,{activationConstraint:{distance:8}})),H=E.useMemo(()=>!p||p.length===0?null:new Set(p),[p]),$e=E.useMemo(()=>m?new Map(Object.entries(m).map(([e,t])=>[e,new Set(t)])):null,[m]),U=E.useCallback((e,t)=>!$e||$e.get(e)?.has(t)===!0,[$e]),et=E.useMemo(()=>new Map(e.map(e=>[e.id,e])),[e]),W=E.useCallback((e,t)=>f.some(n=>n.providerID===e&&n.modelID===t),[f]),G=E.useCallback((e,t,n,r)=>{let a=i.trim();return!a||be(Ee({providerName:t,providerID:n,modelName:e,modelID:r}),a)},[i]),K=E.useMemo(()=>t.filter(({model:e,providerID:t,modelID:n})=>{if(H&&!H.has(t)||!U(t,n)||W(t,n))return!1;let r=et.get(t)?.name||t;return G(P(e),r,t,n)}),[H,t,U,W,G,et]),q=E.useMemo(()=>n.filter(({model:e,providerID:t,modelID:n})=>{if(H&&!H.has(t)||!U(t,n)||W(t,n))return!1;let r=et.get(t)?.name||t;return G(P(e),r,t,n)}),[H,U,W,G,et,n]),tt=d?.providerID,nt=E.useMemo(()=>{let t=e;if(A&&A.length>0){let n=new Map(A.map((e,t)=>[e,t])),r=e.filter(e=>n.has(e.id)).sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0)),i=e.filter(e=>!n.has(e.id));t=[...r,...i]}return F?Oe(t,tt):t},[A,e,tt,F]),J=E.useMemo(()=>nt.filter(e=>!H||H.has(e.id)).map(e=>{let t=(Array.isArray(e.models)?e.models:[]).filter(t=>{let n=typeof t.id==`string`?t.id:``;return!n||W(e.id,n)||!U(e.id,n)?!1:G(P(t),e.name||e.id,e.id,n)});return{...e,models:t}}).filter(e=>e.models.length>0),[H,U,W,G,nt]),Y=E.useMemo(()=>!F||!B?null:ke({candidates:J.flatMap(e=>e.models.map(t=>({entry:{model:t,providerID:e.id,modelID:t.id},providerName:e.name||e.id,modelName:P(t)}))),query:i.trim(),recencyOrder:Fe??n,recentModels:n,favoriteModels:t,selectedModel:d}),[t,J,B,Fe,n,i,d,F]),rt=E.useMemo(()=>nt.filter(e=>!H||H.has(e.id)).filter(e=>(Array.isArray(e.models)?e.models:[]).some(t=>{let n=typeof t.id==`string`?t.id:``;return!!n&&!W(e.id,n)&&U(e.id,n)})),[H,U,W,nt]),{flatModelList:X,modelRowIndices:it}=E.useMemo(()=>{let e=[],t=new Map,n=(n,r)=>{t.set(`${r}:${n.providerID}:${n.modelID}`,e.length),e.push(n)};return Y?(Y.forEach(e=>n(e,`search`)),{flatModelList:e,modelRowIndices:t}):(V.has(`favorites`)||K.forEach(e=>n(e,`fav`)),V.has(`recent`)||q.forEach(e=>n(e,`recent`)),J.forEach(e=>{V.has(`provider:${e.id}`)||e.models.forEach(t=>n({model:t,providerID:e.id,modelID:t.id},`provider`))}),{flatModelList:e,modelRowIndices:t})},[V,K,J,q,Y]),[Z,at]=E.useState(16);E.useLayoutEffect(()=>{N&&at(Number.parseFloat(getComputedStyle(document.documentElement).fontSize)||16)},[N]);let Q=E.useMemo(()=>{if(!N)return[];let e=[],t=0,n=(n,r,i,a)=>{if(e.push({key:n,height:(1.5+(a?.625:0))*Z,modelIndex:-1}),!V.has(n))for(let a of r)e.push({key:`${n}:${a.providerID}:${a.modelID}`,height:i*Z,modelIndex:t++})};if(Y){for(let n of Y)e.push({key:`search:${n.providerID}:${n.modelID}`,height:2.5*Z,modelIndex:t++});return e}return K.length&&n(`favorites`,K,2.5,!1),q.length&&n(`recent`,q,2.5,K.length>0),J.forEach((e,t)=>n(`provider:${e.id}`,e.models.map(t=>({model:t,providerID:e.id,modelID:t.id})),2,t>0||K.length>0||q.length>0)),e},[V,K,J,q,Z,Y,N]),ot=E.useMemo(()=>{if(!F||Y)return[];let e=1.5*Z,t=[],n=.375*Z;for(let r of Q)r.modelIndex===-1&&r.key.startsWith(`provider:`)&&t.push({id:r.key.slice(9),top:n+r.height-e}),n+=r.height;return t},[Z,Y,F,Q]),st=E.useRef(null),[ct,lt]=E.useState(null),ut=E.useMemo(()=>({estimateSize:e=>Q[e].height,getItemKey:e=>Q[e].key}),[Q]),dt=_({enabled:N,count:Q.length,getScrollElement:()=>R.current,...ut,paddingStart:.375*Z,paddingEnd:.375*Z,overscan:6,initialRect:{width:400,height:400}}),ft=dt.getVirtualItems(),pt=new Set(ft.map(e=>Q[e.index].modelIndex)),mt=dt.scrollOffset??0,ht=(()=>{if(ct&&Math.abs(mt-ct.offset)<2)return ct.id;let e=`all`;for(let t of ot)t.top<=mt+4&&(e=t.id);return e})();E.useEffect(()=>{let e=st.current,t=e?.querySelector(`[aria-current="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.top<n.top?e.scrollTop+=r.top-n.top-4:r.bottom>n.bottom&&(e.scrollTop+=r.bottom-n.bottom+4)},[ht,F]);let gt=e=>{let t=R.current;if(!t)return;let n=e===`all`?0:ot.find(t=>t.id===e)?.top;if(n===void 0)return;let r=Math.max(0,Math.min(n,t.scrollHeight-t.clientHeight));t.scrollTop=r,lt({id:e,offset:r})},_t=X.length>0,vt=!!Se&&i.trim().length===0&&K.length>1,yt=!!Te&&i.trim().length===0&&!H&&J.length>1,bt=E.useMemo(()=>new Map(K.map(e=>[`${e.providerID}:${e.modelID}`,e])),[K]);E.useEffect(()=>{I.set(0)},[i,I]),E.useEffect(()=>{B||Xe(e=>e.size===0?e:new Set)},[B]);let xt=E.useCallback(e=>{I.set(e),k?.(X[e])},[X,k,I]),St=E.useCallback(e=>{let t=X.length;if(t===0)return;z.current=!0,Ge.current=null;let n=(I.getSnapshot()+e+t)%t;I.set(n),k?.(X[n]),requestAnimationFrame(()=>We(R.current,L.current[n]))},[X,k,I]);E.useEffect(()=>{k?.(X[I.getSnapshot()])},[X,k,I]);let Ct=E.useCallback(e=>{if(!e.defaultPrevented){if(e.stopPropagation(),e.key===`ArrowLeft`||e.key===`ArrowRight`){let t=X[I.getSnapshot()];if(t&&xe?.(e,t))return}if(ve?.(e,X[I.getSnapshot()]),!e.defaultPrevented){if(e.key===`ArrowDown`){e.preventDefault(),St(1);return}if(e.key===`ArrowUp`){e.preventDefault(),St(-1);return}if(e.key===`Enter`){e.preventDefault();let t=X[I.getSnapshot()];t&&!D&&o(t);return}e.key===`Escape`&&(e.preventDefault(),me?.())}}},[D,X,St,ve,me,o,xe,I]),wt=c(`model-picker-section-header typography-micro font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2 px-2 py-1.5`,fe&&`sticky top-0 z-10 [background:linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))]`,O),$=(e,t,n,i)=>{let a=it.get(`${t}:${e.providerID}:${e.modelID}`);if(a===void 0)return null;if(N&&!i?.isDragging&&!(ft.length?pt.has(a):a<12))return(0,M.jsx)(`div`,{ref:e=>{L.current[a]=e},className:`model-picker-row-placeholder`,"data-model-section":t,"aria-hidden":`true`},`${t}-${e.providerID}-${e.modelID}`);let s=ye(e.providerID,e.model,r?.(e.providerID,e.modelID)),f=et.get(e.providerID)?.name||e.providerID,p=Pe(s?.limit?.context),m=ae?.(e)??0,h=d?.providerID===e.providerID&&d.modelID===e.modelID,g=he?.(e)??!1,_=e=>{let t={x:e.clientX,y:e.clientY},n=Ge.current,r=!n||n.x!==t.x||n.y!==t.y;Ge.current=t,!(z.current&&!n)&&(z.current&&!r||(z.current&&r&&(z.current=!1),xt(a)))};return(0,M.jsx)(Re,{store:I,index:a,renderVersion:je,children:r=>{let d=(0,M.jsxs)(`div`,{ref:e=>{L.current[a]=e},role:`option`,"data-model-section":t,"aria-selected":h,"aria-setsize":N?X.length:void 0,"aria-posinset":N?a+1:void 0,"aria-disabled":D||void 0,tabIndex:-1,onClick:()=>{D||o(e)},onKeyDown:t=>{D||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e))},onMouseEnter:_,onMouseMove:_,className:c(`model-picker-row w-full text-left px-2 py-1.5 rounded-md typography-meta flex items-center gap-2 cursor-pointer`,!D&&(r?`bg-interactive-selection`:`hover:bg-interactive-hover/50`),D&&`cursor-not-allowed opacity-60`,de),children:[(0,M.jsxs)(`div`,{className:`model-picker-row-main flex items-center gap-1.5 flex-1 min-w-0`,children:[i?(0,M.jsx)(`button`,{type:`button`,ref:i.setActivatorNodeRef,...i.attributes,...i.listeners,disabled:D,onClick:e=>{e.preventDefault(),e.stopPropagation()},className:`model-favorite-drag-handle flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground hover:text-foreground disabled:pointer-events-none`,"aria-label":Ce,title:we,children:(0,M.jsx)(l,{name:`draggable`,className:`size-3.5`})}):null,n?(0,M.jsx)(S,{modelId:e.modelID,providerId:e.providerID,className:`h-3.5 w-3.5 flex-shrink-0`}):null,(0,M.jsxs)(`span`,{className:`model-picker-row-labels contents`,children:[(0,M.jsx)(`span`,{className:`model-picker-row-name font-medium truncate`,children:P(e.model)}),(0,M.jsxs)(`span`,{className:`model-picker-row-meta contents`,children:[t===`provider`?null:(0,M.jsx)(`span`,{className:`model-picker-row-provider hidden truncate`,children:f}),p?(0,M.jsx)(`span`,{className:`model-picker-row-context typography-micro text-muted-foreground flex-shrink-0`,children:p}):null]})]})]}),m>0?(0,M.jsxs)(`span`,{className:`typography-micro text-muted-foreground flex-shrink-0`,children:[`x`,m]}):null,_e?.(e,{isHighlighted:r,isSelected:h}),(0,M.jsx)(`span`,{className:c(`model-picker-row-selection size-4 shrink-0`,!h&&`hidden`),children:h?(0,M.jsx)(l,{name:`check`,className:`h-4 w-4 text-primary`}):null}),ge?(0,M.jsx)(`button`,{type:`button`,disabled:D,onClick:t=>{t.preventDefault(),t.stopPropagation(),ge(e)},className:c(`model-favorite-button flex h-4 w-4 items-center justify-center hover:text-primary/80 flex-shrink-0 disabled:pointer-events-none`,g?`text-primary`:`text-muted-foreground`),"aria-label":g?u.unfavorite:u.favorite,title:g?u.unfavorite:u.favorite,children:(0,M.jsx)(l,{name:g?`star-fill`:`star`,className:`h-3.5 w-3.5`})}):null]});return(0,M.jsx)(Ie,{metadata:s,providerName:f,providerID:e.providerID,modelID:e.modelID,active:Me&&r,anchor:()=>L.current[a],labels:u,children:d})}},`${t}-${e.providerID}-${e.modelID}`)},Tt=e=>{if(!Se)return;let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=bt.get(String(t.id)),i=bt.get(String(n.id));!r||!i||Se(r,i)},Et=e=>{if(!Te)return;let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=nt.map(e=>e.id),i=r.indexOf(String(t.id)),a=r.indexOf(String(n.id));i!==-1&&a!==-1&&Te(ie(r,i,a))},Dt=e=>V.has(e),Ot=e=>{if(!B){qe(e);return}Xe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},kt=(e,t,n,r)=>{let i=Dt(e),a=t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Ot(e))};return F?(0,M.jsx)(`div`,{ref:r?.setActivatorNodeRef,...r?.attributes,...r?.listeners,title:r?De:void 0,className:c(wt,r&&`cursor-grab select-none active:cursor-grabbing`),children:(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:n})}):r?(0,M.jsxs)(`div`,{ref:r.setActivatorNodeRef,...r.attributes,...r.listeners,role:`button`,tabIndex:0,"aria-expanded":!i,title:De,className:c(wt,`w-full text-left cursor-grab select-none active:cursor-grabbing`),onClick:()=>Ot(e),onKeyDown:a,children:[(0,M.jsx)(l,{name:`draggable`,className:`size-3.5 flex-shrink-0 text-muted-foreground/70`}),t,(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),(0,M.jsx)(`span`,{className:`ml-auto flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,children:(0,M.jsx)(l,{name:i?`arrow-right-s`:`arrow-down-s`,className:`size-4`})})]}):(0,M.jsxs)(`button`,{type:`button`,className:c(wt,`w-full text-left cursor-pointer`),onClick:()=>Ot(e),"aria-expanded":!i,children:[t,(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),(0,M.jsx)(`span`,{className:`ml-auto flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,children:(0,M.jsx)(l,{name:i?`arrow-right-s`:`arrow-down-s`,className:`size-4`})})]})},At=(e,t,n)=>(0,M.jsxs)(M.Fragment,{children:[t>0?(0,M.jsx)(`div`,{className:`model-picker-section-divider h-px bg-border/40 my-1`}):null,kt(`provider:${e.id}`,(0,M.jsx)(ce,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),e.name||e.id,n),Dt(`provider:${e.id}`)?null:e.models.map(t=>$({model:t,providerID:e.id,modelID:t.id},`provider`,!0))]}),jt=(0,M.jsx)(g,{ref:R,outerClassName:F?`min-w-0 flex-1`:le,className:`overlay-scrollbar-target--no-gutter`,style:F?void 0:ue,children:(0,M.jsxs)(`div`,{className:`model-picker-list px-1`,children:[h?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 typography-meta text-muted-foreground hover:bg-interactive-hover/50`,onClick:re,children:[(0,M.jsx)(l,{name:`close`,className:`h-3.5 w-3.5`}),(0,M.jsx)(`span`,{children:u.notSelected}),d?null:(0,M.jsx)(l,{name:`check`,className:`h-4 w-4 text-primary ml-auto`})]}),(0,M.jsx)(`div`,{className:`h-px bg-border/40 my-1`})]}):null,_t?null:(0,M.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:u.noResults}),Y?Y.map(e=>$(e,`search`,!0)):(0,M.jsxs)(M.Fragment,{children:[K.length>0?(0,M.jsxs)(`div`,{className:`model-picker-section`,children:[kt(`favorites`,(0,M.jsx)(l,{name:`star-fill`,className:`h-4 w-4 text-primary`}),u.favorites),!Dt(`favorites`)&&(vt?(0,M.jsx)(te,{sensors:Ze,collisionDetection:w,onDragEnd:Tt,children:(0,M.jsx)(se,{items:K.map(e=>`${e.providerID}:${e.modelID}`),strategy:oe,children:K.map(e=>(0,M.jsx)(Be,{id:`${e.providerID}:${e.modelID}`,disabled:D,children:t=>$(e,`fav`,!0,t)},`fav-sortable-${e.providerID}-${e.modelID}`))})}):K.map(e=>$(e,`fav`,!0)))]}):null,q.length>0?(0,M.jsxs)(`div`,{className:`model-picker-section`,children:[K.length>0?(0,M.jsx)(`div`,{className:`model-picker-section-divider h-px bg-border/40 my-1`}):null,kt(`recent`,(0,M.jsx)(l,{name:`time`,className:`h-4 w-4`}),u.recent),Dt(`recent`)?null:q.map(e=>$(e,`recent`,!0))]}):null,(K.length>0||q.length>0)&&J.length>0?(0,M.jsx)(`div`,{className:`model-picker-section-divider h-px bg-border/40 my-1`}):null,yt?(0,M.jsx)(te,{sensors:Qe,collisionDetection:w,onDragEnd:Et,children:(0,M.jsx)(se,{items:J.map(e=>e.id),strategy:oe,children:J.map((e,t)=>(0,M.jsx)(Ve,{id:e.id,disabled:D,children:n=>At(e,t,n)},e.id))})}):J.map((e,t)=>(0,M.jsx)(`div`,{children:At(e,t)},e.id))]})]})}),Mt=F?(0,M.jsx)(`nav`,{ref:st,className:c(`model-picker-rail`,B&&`pointer-events-none opacity-40`),"aria-label":u.provider,"aria-disabled":B||void 0,children:[{id:`all`,name:u.all},...rt.map(e=>({id:e.id,name:e.name||e.id}))].map(e=>(0,M.jsxs)(b,{children:[(0,M.jsx)(v,{asChild:!0,children:(0,M.jsx)(s,{variant:`ghost`,size:`icon`,tabIndex:B?-1:void 0,"aria-label":e.name,"aria-current":!B&&ht===e.id?`true`:void 0,onClick:()=>gt(e.id),className:c(`model-picker-rail-item size-8`,!B&&ht===e.id&&`bg-interactive-selection`),children:e.id===`all`?(0,M.jsx)(l,{name:`list-unordered`,className:`size-4`}):(0,M.jsx)(ce,{providerId:e.id,className:`size-4 flex-shrink-0`})})}),(0,M.jsx)(y,{side:`right`,sideOffset:6,children:e.name})]},e.id))}):null;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`model-picker-search-area p-1.5 pb-1`,children:(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(l,{name:`search`,className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,M.jsx)(x,{type:`text`,placeholder:u.searchPlaceholder,value:i,onChange:e=>a(e.target.value),onKeyDown:Ct,className:`model-picker-search h-8 pl-8 typography-meta`,autoFocus:pe})]})}),F?(0,M.jsxs)(`div`,{className:c(`model-picker-stairs flex min-h-0`,le),style:ue,children:[Mt,jt]}):jt,(0,M.jsx)(`div`,{className:`model-picker-footer px-3 pt-1 pb-1.5 border-t border-border/40 typography-micro text-muted-foreground`,children:(0,M.jsx)(ze,{store:I,flatModelList:X,footerContent:j,fallback:u.keyboardHint})})]})};function L(){}function R(e){let{key:t,icon:n,label:r}=e;return(0,M.jsx)(N,{iconName:n,label:r},t)}function z(e,t,n,r,i){let a=e.find(e=>e.id===n);if(!a)return null;let o=(Array.isArray(a.models)?a.models:[]).find(e=>e.id===r);return!o||t.some(e=>e.providerID===n&&e.modelID===r)?null:i===void 0?{provider:a,model:o,providerID:n,modelID:r}:{provider:a,model:o,providerID:n,modelID:r,variant:i}}var Ge=e=>{let t=(0,D.c)(30),n=u(Ke),r=o(qe),i=o(Je),a=o(B),s=e?.currentProviderID??null,c=e?.currentModelID??null,l;if(t[0]!==r||t[1]!==a||t[2]!==n){let e;t[4]!==a||t[5]!==n?(e=e=>{let{providerID:t,modelID:r,variant:i}=e;return z(n,a,t,r,i)},t[4]=a,t[5]=n,t[6]=e):e=t[6],l=r.map(e).filter(Ye),t[0]=r,t[1]=a,t[2]=n,t[3]=l}else l=t[3];let d=l,f;if(t[7]!==c||t[8]!==s||t[9]!==r||t[10]!==a||t[11]!==n||t[12]!==i){bb0:{let e;t[14]!==a||t[15]!==n?(e=e=>{let{providerID:t,modelID:r,variant:i}=e;return z(n,a,t,r,i)},t[14]=a,t[15]=n,t[16]=e):e=t[16];let o;t[17]===r?o=t[18]:(o=e=>{let{providerID:t,modelID:n}=e;return!r.some(e=>e.providerID===t&&e.modelID===n)},t[17]=r,t[18]=o);let l=i.map(e).filter(Xe).filter(o);if(!s||!c){f=l;break bb0}if(r.some(e=>e.providerID===s&&e.modelID===c)){f=l;break bb0}let u;t[19]!==c||t[20]!==s?(u=e=>e.providerID===s&&e.modelID===c,t[19]=c,t[20]=s,t[21]=u):u=t[21];let d=l.findIndex(u);if(d===0){f=l;break bb0}if(d>0){let e=l.slice(),[t]=e.splice(d,1);e.unshift(t),f=e;break bb0}let p;t[22]!==c||t[23]!==s||t[24]!==a||t[25]!==n?(p=z(n,a,s,c),t[22]=c,t[23]=s,t[24]=a,t[25]=n,t[26]=p):p=t[26];let m=p;if(!m){f=l;break bb0}f=[m,...l]}t[7]=c,t[8]=s,t[9]=r,t[10]=a,t[11]=n,t[12]=i,t[13]=f}else f=t[13];let p=f,m;return t[27]!==d||t[28]!==p?(m={favoriteModelsList:d,recentModelsList:p},t[27]=d,t[28]=p,t[29]=m):m=t[29],m};function Ke(e){return e.providers}function qe(e){return e.favoriteModels}function Je(e){return e.recentModels}function B(e){return e.hiddenModels}function Ye(e){return e!==null}function Xe(e){return e!==null}export{Ee as a,fe as c,ge as d,_e as f,ke as i,pe as l,I as n,be as o,me as p,Oe as r,ye as s,Ge as t,he as u};