@onescience/onecode-web 1.14.50-202607151040 → 1.14.50-202607151639

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 (60) hide show
  1. package/assets/{alert-01-RynQqvac.js → alert-01-CN74ACII.js} +1 -1
  2. package/assets/{alert-02-BVZuMTuQ.js → alert-02-CFjp5yj4.js} +1 -1
  3. package/assets/{alert-04-wkf4HQhJ.js → alert-04-273ZCD_p.js} +1 -1
  4. package/assets/{alert-05-DK7Vx14A.js → alert-05-UWpeSIHQ.js} +1 -1
  5. package/assets/alert-06-B-rvL24q.js +1 -0
  6. package/assets/alert-07-Bx1rcJ0U.js +1 -0
  7. package/assets/alert-08-D5x0Svtw.js +1 -0
  8. package/assets/alert-10-DUwoIiwF.js +1 -0
  9. package/assets/{bip-bop-03-7w01XXhW.js → bip-bop-03-CfbkmA6P.js} +1 -1
  10. package/assets/{bip-bop-04-iVHvrSkt.js → bip-bop-04-DLEfkHSN.js} +1 -1
  11. package/assets/{bip-bop-06-BQXPGT9X.js → bip-bop-06-TzbRU2Xg.js} +1 -1
  12. package/assets/{bip-bop-08-DIASxYR7.js → bip-bop-08-Cdyav0UR.js} +1 -1
  13. package/assets/bip-bop-09-XnijQin2.js +1 -0
  14. package/assets/{dialog-create-project-folder-BPnBRqLI.js → dialog-create-project-folder-WcApRUV6.js} +1 -1
  15. package/assets/{dialog-edit-project-DZQVWxP0.js → dialog-edit-project-C3JwjxER.js} +1 -1
  16. package/assets/{dialog-fork-BOp0oMTT.js → dialog-fork-Bie5bPtQ.js} +1 -1
  17. package/assets/{dialog-manage-models-CYmZvBPB.js → dialog-manage-models-BnaOhkF4.js} +1 -1
  18. package/assets/{dialog-select-directory-BEkdqztO.js → dialog-select-directory-xR7wkhy8.js} +3 -3
  19. package/assets/{dialog-select-file-Bq7znuZG.js → dialog-select-file-CNrCbKRY.js} +1 -1
  20. package/assets/{dialog-select-mcp-Cn_lGSvW.js → dialog-select-mcp-DTLxg6Rb.js} +1 -1
  21. package/assets/dialog-select-model-CQbpTmP9.js +2 -0
  22. package/assets/dialog-select-provider-DjM-NV2S.js +1 -0
  23. package/assets/{dialog-select-server-CiLp-Z_w.js → dialog-select-server-2N6NtWOg.js} +1 -1
  24. package/assets/{dialog-select-ssh-5D8MlzFy.js → dialog-select-ssh-Bzzua3AT.js} +1 -1
  25. package/assets/dialog-settings-DN7fS_E2.js +1 -0
  26. package/assets/{ghostty-web-C7egHi4m.js → ghostty-web-vVVKxtcd.js} +1 -1
  27. package/assets/{index-MSBmeR2-.css → index-CzxfzwcV.css} +1 -1
  28. package/assets/{index-t6AoWpnz.js → index-DqutAOLe.js} +55 -55
  29. package/assets/{list-DsM_Q7VB.js → list-Cnpbqmww.js} +1 -1
  30. package/assets/{nope-02-DKLslHiV.js → nope-02-D-DITfss.js} +1 -1
  31. package/assets/{nope-05-BS0FppDj.js → nope-05-DU1CpOun.js} +1 -1
  32. package/assets/{nope-08-DJb6jgMB.js → nope-08-B7BUpisx.js} +1 -1
  33. package/assets/{nope-11-vHSLdTLm.js → nope-11-CbTkbcCI.js} +1 -1
  34. package/assets/nope-12-UdozVdal.js +1 -0
  35. package/assets/{prompt-helper-dialog-Bhyg3lnF.js → prompt-helper-dialog-ClgrgYXf.js} +1 -1
  36. package/assets/{server-row-C7_f8oim.js → server-row-CsHpppFM.js} +1 -1
  37. package/assets/{staplebops-03-BygLjhaP.js → staplebops-03-BPpGCWi1.js} +1 -1
  38. package/assets/{staplebops-04-Dl_R6OdJ.js → staplebops-04-CmCipUi7.js} +1 -1
  39. package/assets/{staplebops-06-LKg8Q0OA.js → staplebops-06-BUTjO7At.js} +1 -1
  40. package/assets/{staplebops-07-C5mcibQs.js → staplebops-07-wSxmSyFz.js} +1 -1
  41. package/assets/{status-popover-body-CFky-2rw.js → status-popover-body-Bk1WJf8x.js} +2 -2
  42. package/assets/{switch-Bmpibkz9.js → switch-DPKITECj.js} +1 -1
  43. package/assets/{tag-BZ3GCcfY.js → tag-B_xDskei.js} +1 -1
  44. package/assets/{yup-01-K4H0K_ec.js → yup-01-CQIL5TFM.js} +1 -1
  45. package/assets/{yup-03-DKuBn-V4.js → yup-03-C568rQ9h.js} +1 -1
  46. package/assets/{yup-04-Da_sP3ql.js → yup-04-B4OZC7Ie.js} +1 -1
  47. package/assets/{yup-05-C_WMvSm3.js → yup-05-BP2afvBX.js} +1 -1
  48. package/assets/{zh-bvUwvaYy.js → zh-BTQQMfM9.js} +2 -2
  49. package/assets/{zht-BSCJPWqY.js → zht-ndsOFK5l.js} +2 -2
  50. package/index.html +9 -9
  51. package/package.json +2 -2
  52. package/assets/alert-06-BPwMDNtm.js +0 -1
  53. package/assets/alert-07-BhbktPeS.js +0 -1
  54. package/assets/alert-08-BL_2xaq4.js +0 -1
  55. package/assets/alert-10-CLsK6fwe.js +0 -1
  56. package/assets/bip-bop-09-D4qLXkLX.js +0 -1
  57. package/assets/dialog-select-model-Bb7ztMes.js +0 -2
  58. package/assets/dialog-select-provider-ClN7-Dpf.js +0 -1
  59. package/assets/dialog-settings-DixvMcoV.js +0 -1
  60. package/assets/nope-12-Cbt38XaD.js +0 -1
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/alert-01-BuOD_o_q.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-01-BuOD_o_q.aac";export{e as default};
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/alert-02-CS75AsoP.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-02-CS75AsoP.aac";export{e as default};
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/alert-04-CaGsIGFP.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-04-CaGsIGFP.aac";export{e as default};
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/alert-05-D2gbGoRH.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-05-D2gbGoRH.aac";export{e as default};
@@ -0,0 +1 @@
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-06-GK5Tqy6u.aac";export{e as default};
@@ -0,0 +1 @@
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-07-0r0kiLGz.aac";export{e as default};
@@ -0,0 +1 @@
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-08-CZowNquU.aac";export{e as default};
@@ -0,0 +1 @@
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/alert-10-Ck5hR7zH.aac";export{e as default};
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/bip-bop-03-DXp7Zb0f.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/bip-bop-03-DXp7Zb0f.aac";export{e as default};
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/bip-bop-04-CfVtpI7z.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/bip-bop-04-CfVtpI7z.aac";export{e as default};
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/bip-bop-06-BuvNosjK.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/bip-bop-06-BuvNosjK.aac";export{e as default};
@@ -1 +1 @@
1
- const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151040/assets/bip-bop-08-DBf7Bwjz.aac";export{e as default};
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/bip-bop-08-DBf7Bwjz.aac";export{e as default};
@@ -0,0 +1 @@
1
+ const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/assets/bip-bop-09-CxEgoAHQ.aac";export{e as default};
@@ -1 +1 @@
1
- import{b as F,e as w,c as _,f as $,k as y,h as i,aU as P,aV as C,z as D,n as o,i as r,T as k,E as z,B as p,p as E,D as M,t as h}from"./index-t6AoWpnz.js";var B=h('<p class="text-12-regular text-text-critical-base">'),G=h('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><p class="text-12-regular text-text-weak"></p></div><div class="flex justify-end gap-2">');function L(f){const c=F(),x=w(),b=_(),t=$(),[l,v]=y({name:""}),u=i(()=>b.data.path.project_data_root||"/data"),S=i(()=>{const e=P(l.name,u());return e?`${e}/`:`${u()}/`}),d=i(()=>!!C(l.name)),n=D(()=>({mutationFn:async()=>{const a=(await x.client.path.mkdir({name:l.name.trim()})).data?.path;if(!a)throw new Error("missing path");return a},onSuccess:e=>{f.onCreated(e),c.close()}}));function j(e){e.preventDefault(),!(n.isPending||!d())&&n.mutate()}return o(M,{get title(){return t.t("command.project.createFolder")},class:"w-full max-w-[480px] mx-auto",get children(){var e=G(),a=e.firstChild,m=a.firstChild,g=a.nextSibling;return e.addEventListener("submit",j),r(a,o(k,{autofocus:!0,type:"text",get label(){return t.t("dialog.project.createFolder.name")},get placeholder(){return t.t("dialog.project.createFolder.placeholder")},get value(){return l.name},onChange:s=>v("name",s)}),m),r(m,()=>t.t("dialog.project.createFolder.path",{path:S()})),r(a,o(z,{get when(){return n.isError},get children(){var s=B();return r(s,()=>t.t("dialog.project.createFolder.failed")),s}}),null),r(g,o(p,{type:"button",variant:"ghost",size:"large",onClick:()=>c.close(),get children(){return t.t("common.cancel")}}),null),r(g,o(p,{type:"submit",variant:"primary",size:"large",get disabled(){return n.isPending||!d()},get children(){return E(()=>!!n.isPending)()?t.t("common.confirming"):t.t("common.confirm")}}),null),e}})}export{L as DialogCreateProjectFolder};
1
+ import{b as F,e as w,c as _,f as $,k as y,h as i,aV as P,aW as C,z as D,n as o,i as r,T as k,E as z,B as p,p as E,D as M,t as h}from"./index-DqutAOLe.js";var B=h('<p class="text-12-regular text-text-critical-base">'),G=h('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><p class="text-12-regular text-text-weak"></p></div><div class="flex justify-end gap-2">');function L(f){const c=F(),x=w(),b=_(),t=$(),[l,v]=y({name:""}),u=i(()=>b.data.path.project_data_root||"/data"),S=i(()=>{const e=P(l.name,u());return e?`${e}/`:`${u()}/`}),d=i(()=>!!C(l.name)),n=D(()=>({mutationFn:async()=>{const a=(await x.client.path.mkdir({name:l.name.trim()})).data?.path;if(!a)throw new Error("missing path");return a},onSuccess:e=>{f.onCreated(e),c.close()}}));function j(e){e.preventDefault(),!(n.isPending||!d())&&n.mutate()}return o(M,{get title(){return t.t("command.project.createFolder")},class:"w-full max-w-[480px] mx-auto",get children(){var e=G(),a=e.firstChild,m=a.firstChild,g=a.nextSibling;return e.addEventListener("submit",j),r(a,o(k,{autofocus:!0,type:"text",get label(){return t.t("dialog.project.createFolder.name")},get placeholder(){return t.t("dialog.project.createFolder.placeholder")},get value(){return l.name},onChange:s=>v("name",s)}),m),r(m,()=>t.t("dialog.project.createFolder.path",{path:S()})),r(a,o(z,{get when(){return n.isError},get children(){var s=B();return r(s,()=>t.t("dialog.project.createFolder.failed")),s}}),null),r(g,o(p,{type:"button",variant:"ghost",size:"large",onClick:()=>c.close(),get children(){return t.t("common.cancel")}}),null),r(g,o(p,{type:"submit",variant:"primary",size:"large",get disabled(){return n.isPending||!d()},get children(){return E(()=>!!n.isPending)()?t.t("common.confirming"):t.t("common.confirm")}}),null),e}})}export{L as DialogCreateProjectFolder};
@@ -1 +1 @@
1
- import{b as te,e as re,c as ae,f as ie,h as F,aQ as oe,k as ne,z as le,n as c,i,T as I,E as P,r as $,A as j,aR as R,m as T,aS as K,aT as se,I as M,N as ce,F as de,L as N,B,p as ue,D as ve,t as p,d as ge}from"./index-t6AoWpnz.js";var fe=p('<div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-1.5">'),me=p('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-3 items-start"><div class=relative><div class="relative size-16 rounded-md transition-colors cursor-pointer"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div></div><input id=icon-upload type=file accept=image/* class=hidden><div class="flex flex-col gap-1.5 text-12-regular text-text-weak self-center"><span></span><span></span></div></div></div></div><div class="flex justify-end gap-2">'),pe=p('<div class="size-full flex items-center justify-center">'),be=p('<img class="size-full object-cover">'),he=p("<button type=button>");const xe=["pink","mint","orange","purple","cyan","lime"];function we(o){const w=te(),G=re(),L=ae(),n=ie(),y=F(()=>oe(o.project.worktree)),O=F(()=>o.project.name||y()),[e,d]=ne({name:O(),color:o.project.icon?.color,iconOverride:o.project.icon?.override,startup:o.project.commands?.start??"",dragOver:!1,iconHover:!1});let _;function z(r){if(!r.type.startsWith("image/"))return;const a=new FileReader;a.onload=f=>{d("iconOverride",f.target?.result),d("iconHover",!1)},a.readAsDataURL(r)}function Q(r){r.preventDefault(),d("dragOver",!1);const a=r.dataTransfer?.files[0];a&&z(a)}function U(r){r.preventDefault(),d("dragOver",!0)}function V(){d("dragOver",!1)}function W(r){const f=r.target.files?.[0];f&&z(f)}function Y(){d("iconOverride","")}const b=le(()=>({mutationFn:async()=>{const r=e.name.trim()===y()?"":e.name.trim(),a=e.startup.trim();if(o.project.id&&o.project.id!=="global"){await G.client.project.update({projectID:o.project.id,directory:o.project.worktree,name:r,icon:{color:e.color||"",override:e.iconOverride||""},commands:{start:a}}),L.project.icon(o.project.worktree,e.iconOverride||void 0),w.close();return}L.project.meta(o.project.worktree,{name:r,icon:{color:e.color||void 0,override:e.iconOverride||void 0},commands:{start:a||void 0}}),w.close()}}));function q(r){r.preventDefault(),!b.isPending&&b.mutate()}return c(ve,{get title(){return n.t("dialog.project.edit.title")},class:"w-full max-w-[480px] mx-auto",get children(){var r=me(),a=r.firstChild,f=a.firstChild,C=f.firstChild,J=C.nextSibling,h=J.firstChild,m=h.firstChild,x=m.nextSibling,k=x.nextSibling,S=h.nextSibling,X=S.nextSibling,D=X.firstChild,Z=D.nextSibling,E=a.nextSibling;return r.addEventListener("submit",q),i(a,c(I,{autofocus:!0,type:"text",get label(){return n.t("dialog.project.edit.name")},get placeholder(){return y()},get value(){return e.name},onChange:t=>d("name",t)}),f),i(C,()=>n.t("dialog.project.edit.icon")),h.addEventListener("mouseleave",()=>d("iconHover",!1)),h.addEventListener("mouseenter",()=>d("iconHover",!0)),m.$$click=()=>{e.iconOverride&&e.iconHover?Y():_?.click()},m.addEventListener("dragleave",V),m.addEventListener("dragover",U),m.addEventListener("drop",Q),i(m,c(P,{get when(){return se(o.project.id,{color:e.color,url:o.project.icon?.url,override:e.iconOverride})},get fallback(){return(()=>{var t=pe();return i(t,c(R,T({get fallback(){return e.name||O()}},()=>K(e.color),{class:"size-full text-[32px]"}))),t})()},children:t=>(()=>{var g=be();return $(u=>{var l=t(),s=n.t("dialog.project.edit.icon.alt");return l!==u.e&&j(g,"src",u.e=l),s!==u.t&&j(g,"alt",u.t=s),u},{e:void 0,t:void 0}),g})()})),i(x,c(M,{name:"cloud-upload",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),i(k,c(M,{name:"trash",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),S.addEventListener("change",W),ce(t=>{_=t},S),i(D,()=>n.t("dialog.project.edit.icon.hint")),i(Z,()=>n.t("dialog.project.edit.icon.recommended")),i(a,c(P,{get when(){return!e.iconOverride},get children(){var t=fe(),g=t.firstChild,u=g.nextSibling;return i(g,()=>n.t("dialog.project.edit.color")),i(u,c(de,{each:xe,children:l=>(()=>{var s=he();return s.$$click=()=>{e.color===l&&!o.project.icon?.url||d("color",e.color===l?void 0:l)},i(s,c(R,T({get fallback(){return e.name||O()}},()=>K(l),{class:"size-full rounded"}))),$(v=>{var A=n.t("dialog.project.edit.color.select",{color:l}),H=e.color===l,ee={"flex items-center justify-center size-10 p-0.5 rounded-lg overflow-hidden transition-colors cursor-default":!0,"bg-transparent border-2 border-icon-strong-base hover:bg-surface-base-hover":e.color===l,"bg-transparent border border-transparent hover:bg-surface-base-hover hover:border-border-weak-base":e.color!==l};return A!==v.e&&j(s,"aria-label",v.e=A),H!==v.t&&j(s,"aria-pressed",v.t=H),v.a=N(s,ee,v.a),v},{e:void 0,t:void 0,a:void 0}),s})()})),t}}),null),i(a,c(I,{multiline:!0,get label(){return n.t("dialog.project.edit.worktree.startup")},get description(){return n.t("dialog.project.edit.worktree.startup.description")},get placeholder(){return n.t("dialog.project.edit.worktree.startup.placeholder")},get value(){return e.startup},onChange:t=>d("startup",t),spellcheck:!1,class:"max-h-14 w-full overflow-y-auto font-mono text-xs"}),null),i(E,c(B,{type:"button",variant:"ghost",size:"large",onClick:()=>w.close(),get children(){return n.t("common.cancel")}}),null),i(E,c(B,{type:"submit",variant:"primary",size:"large",get disabled(){return b.isPending},get children(){return ue(()=>!!b.isPending)()?n.t("common.saving"):n.t("common.save")}}),null),$(t=>{var g={"border-text-interactive-base bg-surface-info-base/20":e.dragOver,"border-border-base hover:border-border-strong":!e.dragOver,"overflow-hidden":!!e.iconOverride},u=!!(e.iconHover&&!e.iconOverride),l=!(e.iconHover&&!e.iconOverride),s=!!(e.iconHover&&e.iconOverride),v=!(e.iconHover&&e.iconOverride);return t.e=N(m,g,t.e),u!==t.t&&x.classList.toggle("opacity-100",t.t=u),l!==t.a&&x.classList.toggle("opacity-0",t.a=l),s!==t.o&&k.classList.toggle("opacity-100",t.o=s),v!==t.i&&k.classList.toggle("opacity-0",t.i=v),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r}})}ge(["click"]);export{we as DialogEditProject};
1
+ import{b as te,e as re,c as ae,f as ie,h as F,aR as oe,k as ne,z as le,n as c,i,T as I,E as P,r as $,A as j,aS as R,m as T,aT as K,aU as se,I as M,N as ce,F as de,L as N,B,p as ue,D as ve,t as p,d as ge}from"./index-DqutAOLe.js";var fe=p('<div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-1.5">'),me=p('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-3 items-start"><div class=relative><div class="relative size-16 rounded-md transition-colors cursor-pointer"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div></div><input id=icon-upload type=file accept=image/* class=hidden><div class="flex flex-col gap-1.5 text-12-regular text-text-weak self-center"><span></span><span></span></div></div></div></div><div class="flex justify-end gap-2">'),pe=p('<div class="size-full flex items-center justify-center">'),be=p('<img class="size-full object-cover">'),he=p("<button type=button>");const xe=["pink","mint","orange","purple","cyan","lime"];function we(o){const w=te(),G=re(),L=ae(),n=ie(),y=F(()=>oe(o.project.worktree)),O=F(()=>o.project.name||y()),[e,d]=ne({name:O(),color:o.project.icon?.color,iconOverride:o.project.icon?.override,startup:o.project.commands?.start??"",dragOver:!1,iconHover:!1});let _;function z(r){if(!r.type.startsWith("image/"))return;const a=new FileReader;a.onload=f=>{d("iconOverride",f.target?.result),d("iconHover",!1)},a.readAsDataURL(r)}function U(r){r.preventDefault(),d("dragOver",!1);const a=r.dataTransfer?.files[0];a&&z(a)}function V(r){r.preventDefault(),d("dragOver",!0)}function W(){d("dragOver",!1)}function Y(r){const f=r.target.files?.[0];f&&z(f)}function q(){d("iconOverride","")}const b=le(()=>({mutationFn:async()=>{const r=e.name.trim()===y()?"":e.name.trim(),a=e.startup.trim();if(o.project.id&&o.project.id!=="global"){await G.client.project.update({projectID:o.project.id,directory:o.project.worktree,name:r,icon:{color:e.color||"",override:e.iconOverride||""},commands:{start:a}}),L.project.icon(o.project.worktree,e.iconOverride||void 0),w.close();return}L.project.meta(o.project.worktree,{name:r,icon:{color:e.color||void 0,override:e.iconOverride||void 0},commands:{start:a||void 0}}),w.close()}}));function J(r){r.preventDefault(),!b.isPending&&b.mutate()}return c(ve,{get title(){return n.t("dialog.project.edit.title")},class:"w-full max-w-[480px] mx-auto",get children(){var r=me(),a=r.firstChild,f=a.firstChild,C=f.firstChild,Q=C.nextSibling,h=Q.firstChild,m=h.firstChild,x=m.nextSibling,k=x.nextSibling,S=h.nextSibling,X=S.nextSibling,D=X.firstChild,Z=D.nextSibling,E=a.nextSibling;return r.addEventListener("submit",J),i(a,c(I,{autofocus:!0,type:"text",get label(){return n.t("dialog.project.edit.name")},get placeholder(){return y()},get value(){return e.name},onChange:t=>d("name",t)}),f),i(C,()=>n.t("dialog.project.edit.icon")),h.addEventListener("mouseleave",()=>d("iconHover",!1)),h.addEventListener("mouseenter",()=>d("iconHover",!0)),m.$$click=()=>{e.iconOverride&&e.iconHover?q():_?.click()},m.addEventListener("dragleave",W),m.addEventListener("dragover",V),m.addEventListener("drop",U),i(m,c(P,{get when(){return se(o.project.id,{color:e.color,url:o.project.icon?.url,override:e.iconOverride})},get fallback(){return(()=>{var t=pe();return i(t,c(R,T({get fallback(){return e.name||O()}},()=>K(e.color),{class:"size-full text-[32px]"}))),t})()},children:t=>(()=>{var g=be();return $(u=>{var l=t(),s=n.t("dialog.project.edit.icon.alt");return l!==u.e&&j(g,"src",u.e=l),s!==u.t&&j(g,"alt",u.t=s),u},{e:void 0,t:void 0}),g})()})),i(x,c(M,{name:"cloud-upload",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),i(k,c(M,{name:"trash",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),S.addEventListener("change",Y),ce(t=>{_=t},S),i(D,()=>n.t("dialog.project.edit.icon.hint")),i(Z,()=>n.t("dialog.project.edit.icon.recommended")),i(a,c(P,{get when(){return!e.iconOverride},get children(){var t=fe(),g=t.firstChild,u=g.nextSibling;return i(g,()=>n.t("dialog.project.edit.color")),i(u,c(de,{each:xe,children:l=>(()=>{var s=he();return s.$$click=()=>{e.color===l&&!o.project.icon?.url||d("color",e.color===l?void 0:l)},i(s,c(R,T({get fallback(){return e.name||O()}},()=>K(l),{class:"size-full rounded"}))),$(v=>{var A=n.t("dialog.project.edit.color.select",{color:l}),H=e.color===l,ee={"flex items-center justify-center size-10 p-0.5 rounded-lg overflow-hidden transition-colors cursor-default":!0,"bg-transparent border-2 border-icon-strong-base hover:bg-surface-base-hover":e.color===l,"bg-transparent border border-transparent hover:bg-surface-base-hover hover:border-border-weak-base":e.color!==l};return A!==v.e&&j(s,"aria-label",v.e=A),H!==v.t&&j(s,"aria-pressed",v.t=H),v.a=N(s,ee,v.a),v},{e:void 0,t:void 0,a:void 0}),s})()})),t}}),null),i(a,c(I,{multiline:!0,get label(){return n.t("dialog.project.edit.worktree.startup")},get description(){return n.t("dialog.project.edit.worktree.startup.description")},get placeholder(){return n.t("dialog.project.edit.worktree.startup.placeholder")},get value(){return e.startup},onChange:t=>d("startup",t),spellcheck:!1,class:"max-h-14 w-full overflow-y-auto font-mono text-xs"}),null),i(E,c(B,{type:"button",variant:"ghost",size:"large",onClick:()=>w.close(),get children(){return n.t("common.cancel")}}),null),i(E,c(B,{type:"submit",variant:"primary",size:"large",get disabled(){return b.isPending},get children(){return ue(()=>!!b.isPending)()?n.t("common.saving"):n.t("common.save")}}),null),$(t=>{var g={"border-text-interactive-base bg-surface-info-base/20":e.dragOver,"border-border-base hover:border-border-strong":!e.dragOver,"overflow-hidden":!!e.iconOverride},u=!!(e.iconHover&&!e.iconOverride),l=!(e.iconHover&&!e.iconOverride),s=!!(e.iconHover&&e.iconOverride),v=!(e.iconHover&&e.iconOverride);return t.e=N(m,g,t.e),u!==t.t&&x.classList.toggle("opacity-100",t.t=u),l!==t.a&&x.classList.toggle("opacity-0",t.a=l),s!==t.o&&k.classList.toggle("opacity-100",t.o=s),v!==t.i&&k.classList.toggle("opacity-0",t.i=v),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r}})}ge(["click"]);export{we as DialogEditProject};
@@ -1 +1 @@
1
- import{a6 as D,b4 as v,Q as S,bd as k,be as P,bj as _,b as w,f as F,h as L,n as d,i as u,D as $,bk as I,ba as T,y as g,b9 as q,t as C}from"./index-t6AoWpnz.js";import{L as E}from"./list-DsM_Q7VB.js";var K=C('<div class="w-full flex items-center gap-2"><span class="truncate flex-1 min-w-0 text-left font-normal"></span><span class="text-text-weak shrink-0 font-normal">');function M(i){return i.toLocaleTimeString(void 0,{timeStyle:"short"})}const H=()=>{const i=D(),p=v(),f=S(),c=k(),l=P(),h=_(),x=w(),n=F(),y=L(()=>{const t=i.id;if(!t)return[];const a=c.data.message[t]??[],o=[];for(const s of a){if(s.role!=="user")continue;const e=(c.data.part[s.id]??[]).find(r=>r.type==="text"&&!r.synthetic&&!r.ignored);e&&o.push({id:s.id,text:e.text.replace(/\n/g," ").slice(0,200),time:M(new Date(s.time.created))})}return o.reverse()}),b=t=>{if(!t)return;const a=i.id;if(!a)return;const o=c.data.part[t.id]??[],s=I(o,{directory:l.directory,attachmentName:n.t("common.attachment")}),m=T(l.directory);l.client.session.fork({sessionID:a,messageID:t.id}).then(e=>{if(!e.data){g({title:n.t("common.requestFailed")});return}x.close(),h.set(s,void 0,{dir:m,id:e.data.id}),f(q(p.pathname,m,e.data.id))}).catch(e=>{const r=e instanceof Error?e.message:String(e);g({title:n.t("common.requestFailed"),description:r})})};return d($,{get title(){return n.t("command.session.fork")},get children(){return d(E,{class:"flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0",get search(){return{placeholder:n.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return n.t("dialog.fork.empty")},key:t=>t.id,items:y,filterKeys:["text"],onSelect:b,children:t=>(()=>{var a=K(),o=a.firstChild,s=o.nextSibling;return u(o,()=>t.text),u(s,()=>t.time),a})()})}})};export{H as DialogFork};
1
+ import{a6 as D,b4 as v,Q as S,bd as k,be as P,bj as _,b as w,f as F,h as L,n as d,i as u,D as $,bk as I,ba as T,y as g,b9 as q,t as C}from"./index-DqutAOLe.js";import{L as E}from"./list-Cnpbqmww.js";var K=C('<div class="w-full flex items-center gap-2"><span class="truncate flex-1 min-w-0 text-left font-normal"></span><span class="text-text-weak shrink-0 font-normal">');function M(i){return i.toLocaleTimeString(void 0,{timeStyle:"short"})}const H=()=>{const i=D(),p=v(),f=S(),c=k(),l=P(),h=_(),x=w(),n=F(),y=L(()=>{const t=i.id;if(!t)return[];const a=c.data.message[t]??[],o=[];for(const s of a){if(s.role!=="user")continue;const e=(c.data.part[s.id]??[]).find(r=>r.type==="text"&&!r.synthetic&&!r.ignored);e&&o.push({id:s.id,text:e.text.replace(/\n/g," ").slice(0,200),time:M(new Date(s.time.created))})}return o.reverse()}),b=t=>{if(!t)return;const a=i.id;if(!a)return;const o=c.data.part[t.id]??[],s=I(o,{directory:l.directory,attachmentName:n.t("common.attachment")}),m=T(l.directory);l.client.session.fork({sessionID:a,messageID:t.id}).then(e=>{if(!e.data){g({title:n.t("common.requestFailed")});return}x.close(),h.set(s,void 0,{dir:m,id:e.data.id}),f(q(p.pathname,m,e.data.id))}).catch(e=>{const r=e instanceof Error?e.message:String(e);g({title:n.t("common.requestFailed"),description:r})})};return d($,{get title(){return n.t("command.session.fork")},get children(){return d(E,{class:"flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0",get search(){return{placeholder:n.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return n.t("dialog.fork.empty")},key:t=>t.id,items:y,filterKeys:["text"],onSelect:b,children:t=>(()=>{var a=K(),o=a.firstChild,s=o.nextSibling;return u(o,()=>t.text),u(s,()=>t.time),a})()})}})};export{H as DialogFork};
@@ -1 +1 @@
1
- import{bc as f,f as y,b as D,n as o,i as l,a3 as I,B as k,D as $,t as g,G as C,d as P}from"./index-t6AoWpnz.js";import{L}from"./list-DsM_Q7VB.js";import{S as c}from"./switch-Bmpibkz9.js";import{b as _}from"./dialog-select-provider-ClN7-Dpf.js";import"./tag-BZ3GCcfY.js";var B=g("<span>"),S=g('<div class="w-full flex items-center justify-between gap-x-3"><span></span><div>');const E=()=>{const t=f(),d=y(),u=D(),v=()=>{u.show(()=>o(_,{}))},s=e=>C.indexOf(e),m=e=>t.model.list().filter(r=>r.provider.id===e),h=e=>m(e).every(r=>t.model.visible({modelID:r.id,providerID:r.provider.id})),b=(e,r)=>{m(e).forEach(i=>{t.model.setVisibility({modelID:i.id,providerID:i.provider.id},r)})};return o($,{get title(){return d.t("dialog.model.manage")},get description(){return d.t("dialog.model.manage.description")},get action(){return o(k,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:v,get children(){return d.t("command.provider.connect")}})},get children(){return o(L,{get search(){return{placeholder:d.t("dialog.model.search.placeholder"),autofocus:!0}},get emptyMessage(){return d.t("dialog.model.empty")},key:e=>`${e?.provider?.id}:${e?.id}`,get items(){return t.model.list()},filterKeys:["provider.name","name","id"],sortBy:(e,r)=>e.name.localeCompare(r.name),groupBy:e=>e.provider.id,groupHeader:e=>{const r=e.items[0].provider;return[(()=>{var i=B();return l(i,()=>r.name),i})(),o(I,{placement:"top",get value(){return d.t("dialog.model.manage.provider.toggle",{provider:r.name})},get children(){return o(c,{class:"-mr-1",get checked(){return h(r.id)},onChange:i=>b(r.id,i),hideLabel:!0,get children(){return r.name}})}})]},sortGroupsBy:(e,r)=>{const i=s(e.items[0].provider.id),a=s(r.items[0].provider.id),n=i>=0,p=a>=0;return n&&!p?-1:!n&&p?1:i-a},onSelect:e=>{if(!e)return;const r={modelID:e.id,providerID:e.provider.id};t.model.setVisibility(r,!t.model.visible(r))},children:e=>(()=>{var r=S(),i=r.firstChild,a=i.nextSibling;return l(i,()=>e.name),a.$$click=n=>n.stopPropagation(),l(a,o(c,{get checked(){return!!t.model.visible({modelID:e.id,providerID:e.provider.id})},onChange:n=>{t.model.setVisibility({modelID:e.id,providerID:e.provider.id},n)}})),r})()})}})};P(["click"]);export{E as DialogManageModels};
1
+ import{bc as f,f as y,b as D,n as o,i as l,a3 as I,B as k,D as $,t as g,G as C,d as P}from"./index-DqutAOLe.js";import{L}from"./list-Cnpbqmww.js";import{S as c}from"./switch-DPKITECj.js";import{b as _}from"./dialog-select-provider-DjM-NV2S.js";import"./tag-B_xDskei.js";var B=g("<span>"),S=g('<div class="w-full flex items-center justify-between gap-x-3"><span></span><div>');const E=()=>{const t=f(),d=y(),u=D(),v=()=>{u.show(()=>o(_,{}))},s=e=>C.indexOf(e),m=e=>t.model.list().filter(r=>r.provider.id===e),h=e=>m(e).every(r=>t.model.visible({modelID:r.id,providerID:r.provider.id})),b=(e,r)=>{m(e).forEach(i=>{t.model.setVisibility({modelID:i.id,providerID:i.provider.id},r)})};return o($,{get title(){return d.t("dialog.model.manage")},get description(){return d.t("dialog.model.manage.description")},get action(){return o(k,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:v,get children(){return d.t("command.provider.connect")}})},get children(){return o(L,{get search(){return{placeholder:d.t("dialog.model.search.placeholder"),autofocus:!0}},get emptyMessage(){return d.t("dialog.model.empty")},key:e=>`${e?.provider?.id}:${e?.id}`,get items(){return t.model.list()},filterKeys:["provider.name","name","id"],sortBy:(e,r)=>e.name.localeCompare(r.name),groupBy:e=>e.provider.id,groupHeader:e=>{const r=e.items[0].provider;return[(()=>{var i=B();return l(i,()=>r.name),i})(),o(I,{placement:"top",get value(){return d.t("dialog.model.manage.provider.toggle",{provider:r.name})},get children(){return o(c,{class:"-mr-1",get checked(){return h(r.id)},onChange:i=>b(r.id,i),hideLabel:!0,get children(){return r.name}})}})]},sortGroupsBy:(e,r)=>{const i=s(e.items[0].provider.id),a=s(r.items[0].provider.id),n=i>=0,p=a>=0;return n&&!p?-1:!n&&p?1:i-a},onSelect:e=>{if(!e)return;const r={modelID:e.id,providerID:e.provider.id};t.model.setVisibility(r,!t.model.visible(r))},children:e=>(()=>{var r=S(),i=r.firstChild,a=i.nextSibling;return l(i,()=>e.name),a.$$click=n=>n.stopPropagation(),l(a,o(c,{get checked(){return!!t.model.visible({modelID:e.id,providerID:e.provider.id})},onChange:n=>{t.model.setVisibility({modelID:e.id,providerID:e.provider.id},n)}})),r})()})}})};P(["click"]);export{E as DialogManageModels};
@@ -1,4 +1,4 @@
1
- import{am as q,c as Q,e as V,aW as N,b as U,f as tt,u as et,R as rt,Z as nt,h as j,j as st,aX as at,aQ as B,n as S,E as ot,i as R,B as it,aY as L,aZ as ct,D as lt,t as E,a_ as M,a$ as ut,b0 as O,b1 as ft,b2 as ht}from"./index-t6AoWpnz.js";import{L as dt}from"./list-DsM_Q7VB.js";const pt=8;async function X(e,t,s,n){const d=await e(t);return s?q.go(s,d,{key:"name",limit:n}).map(i=>i.obj.absolute):d.slice(0,n).map(i=>i.absolute)}async function mt(e,t,s,n){const d=n?.limit,i=n?.maxDepth??pt;if(!s)return X(e,t,"",d);const y=[],x=new Set;let f=[t];for(let c=0;c<i&&f.length>0&&y.length<d;c++){const o=[];for(const p of f){const m=await e(p);for(const u of m)if(!x.has(u.absolute)){if(x.add(u.absolute),q.single(s,u.name)&&(y.push(u.absolute),y.length>=d))return y;o.push(u.absolute)}}f=o}return y}var wt=E('<div class="px-4 pb-3">'),gt=E('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-strong whitespace-nowrap">~</span><span class="text-text-weak whitespace-nowrap">/'),yt=E('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap"></span><span class="text-text-weak whitespace-nowrap">/');function T(e){return((e??"").split(/\r?\n/)[0]??"").replace(/[\u0000-\u001F\u007F]/g,"").trim()}function bt(e){const t=e.replaceAll("\\","/");return t.startsWith("//")&&!t.startsWith("///")?"//"+t.slice(2).replace(/\/+/g,"/"):t.replace(/\/+/g,"/")}function k(e){const t=bt(e);return/^[A-Za-z]:$/.test(t)?t+"/":t}function g(e){const t=k(e);return t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t)?t:t.replace(/\/+$/,"")}function vt(e,t){const s=g(e??""),n=g(t).replace(/^\/+/,"");return s?n?s.endsWith("/")?s+n:s+"/"+n:s:n}function Z(e){const t=k(e);return t.startsWith("//")?"//":t.startsWith("/")?"/":/^[A-Za-z]:\//.test(t)?t.slice(0,3):""}function xt(e){const t=g(e);if(t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t))return t;const s=t.lastIndexOf("/");return s<=0?"/":s===2&&/^[A-Za-z]:/.test(t)?t.slice(0,3):t.slice(0,s)}function Pt(e){const t=k(e.trim());return t?t.startsWith("~")?"tilde":Z(t)?"absolute":"relative":"relative"}function Y(e,t){const s=g(e);if(!t)return"";const n=g(t),d=s.toLowerCase(),i=n.toLowerCase();return d===i?"~":d.startsWith(i+"/")?"~"+s.slice(n.length):""}function K(e,t,s){const n=g(e);return Pt(t)==="absolute"?n:Y(n,s)||n}function G(e,t,s){const n=g(e),d=Y(n,t),i=x=>x?x.endsWith("/")?x:x+"/":"",y=Array.from(new Set([n,i(n),d,i(d),B(n)].filter(Boolean))).join(`
2
- `);return{absolute:n,search:y,group:s}}function $t(e){const t=new Set;return e.filter(s=>t.has(s.absolute)?!1:(t.add(s.absolute),!0))}function H(e,t){const s=O(t,t),n=O(e,t);return n===s?{directory:s,path:""}:{directory:s,path:n.slice(s.length+1)}}function kt(e){const t=new Map;let s=0;const n=f=>O(f,e.root()),d=f=>{const c=e.start();if(!c)return;const o=e.root(),p=k(f);if(!p)return{directory:n(g(c)),path:""};const m=e.home();if(p==="~")return{directory:n(g(m||c)),path:""};if(p.startsWith("~/")){const b=vt(m||c,p.slice(2));return M(b,o)?H(b,o):{directory:n(g(c)),path:""}}if(Z(p)){const b=g(p);return M(b,o)?H(b,o):{directory:n(g(c)),path:""}}return{directory:n(g(c)),path:p}},i=async f=>{const c=n(g(f)),o=t.get(c);if(o)return o;const p=ft(e.root(),c)??"",m=ht(e.sdk,p,{fetch:e.fetch,headers:e.headers?.()}).then(u=>u.map(b=>({name:b.name,absolute:g(k(b.absolute))})));return t.set(c,m),m},y=async(f,c,o)=>X(i,n(f),c,o),x=async(f,c,o)=>mt(i,n(f),c,{limit:o});return async f=>{const c=++s,o=()=>c===s,p=T(f),m=d(p);if(!m)return[];const u=k(p),b=u.startsWith("~")||!!Z(u)||u.includes("/"),_=k(m.path);if(!b){const h=_?await x(m.directory,_,50):await y(m.directory,"",50);return o()?h.slice(0,50):[]}const W=u.endsWith("/"),D=_.replace(/^\/+/,"").replace(/\/+$/,"").split("/").filter(h=>h&&h!=="."),C=12,z=4,r=async(h,A)=>{let $=A;for(const I of h){if(!o())return[];if(I===".."){$=$.map(F=>n(xt(F)));continue}const J=(await Promise.all($.map(F=>y(F,I,z)))).flat();if(!o())return[];if($=Array.from(new Set(J)).slice(0,C),$.length===0)return[]}return $},l=[m.directory];if(W){const h=await r(D,l);if(h.length===0)return[];const A=(await Promise.all(h.map($=>y($,"",50)))).flat();return o()?Array.from(new Set(A)).slice(0,50):[]}const a=D.slice(0,-1),w=D[D.length-1]??"",v=await r(a,l);if(v.length===0)return[];const P=(await Promise.all(v.map(h=>y(h,w,50)))).flat();return o()?Array.from(new Set(P)).slice(0,50):[]}}function _t(e){const t=Q(),s=V(),n=N(),d=U(),i=tt(),y=et(),x=rt(),[f,c]=nt("");let o;const p=j(()=>!(t.data.path.home||t.data.path.directory)),[m]=st(()=>p()?!0:void 0,async()=>s.client.path.get().then(r=>r.data).catch(()=>{}),{initialValue:void 0}),u=j(()=>t.data.path.home||m()?.home||""),b=j(()=>{const r=t.data.path.project_data_root?t.data.path:m();return at(r)}),_=j(()=>b()),W=kt({sdk:s,home:u,start:_,root:b,fetch:y.fetch,headers:()=>{const r=x.current?.http;if(r?.password)return{Authorization:`Basic ${ut({username:r.username,password:r.password})}`}}}),D=j(()=>{const r=n.projects.list(),l=new Map(t.data.project.map(a=>[a.worktree,a]));return r.map((a,w)=>({project:a,at:l.get(a.worktree)?.time?.updated??l.get(a.worktree)?.time?.created??0,index:w})).sort((a,w)=>w.at-a.at||a.index-w.index).slice(0,5).map(({project:a})=>{const w=l.get(a.worktree),v=G(a.worktree,u(),"recent"),P=a.name||w?.name||B(a.worktree);return{...v,search:`${v.search}
1
+ import{am as q,c as V,e as N,aX as Q,b as U,f as tt,u as et,R as rt,Z as nt,h as R,j as st,aY as at,aR as B,n as S,E as ot,i as j,B as it,aZ as L,a_ as ct,D as lt,t as E,a$ as M,ap as ut,b0 as O,b1 as ft,b2 as ht}from"./index-DqutAOLe.js";import{L as dt}from"./list-Cnpbqmww.js";const pt=8;async function X(e,t,s,n){const d=await e(t);return s?q.go(s,d,{key:"name",limit:n}).map(i=>i.obj.absolute):d.slice(0,n).map(i=>i.absolute)}async function mt(e,t,s,n){const d=n?.limit,i=n?.maxDepth??pt;if(!s)return X(e,t,"",d);const y=[],x=new Set;let f=[t];for(let c=0;c<i&&f.length>0&&y.length<d;c++){const o=[];for(const p of f){const m=await e(p);for(const u of m)if(!x.has(u.absolute)){if(x.add(u.absolute),q.single(s,u.name)&&(y.push(u.absolute),y.length>=d))return y;o.push(u.absolute)}}f=o}return y}var wt=E('<div class="px-4 pb-3">'),gt=E('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-strong whitespace-nowrap">~</span><span class="text-text-weak whitespace-nowrap">/'),yt=E('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap"></span><span class="text-text-weak whitespace-nowrap">/');function T(e){return((e??"").split(/\r?\n/)[0]??"").replace(/[\u0000-\u001F\u007F]/g,"").trim()}function bt(e){const t=e.replaceAll("\\","/");return t.startsWith("//")&&!t.startsWith("///")?"//"+t.slice(2).replace(/\/+/g,"/"):t.replace(/\/+/g,"/")}function k(e){const t=bt(e);return/^[A-Za-z]:$/.test(t)?t+"/":t}function g(e){const t=k(e);return t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t)?t:t.replace(/\/+$/,"")}function vt(e,t){const s=g(e??""),n=g(t).replace(/^\/+/,"");return s?n?s.endsWith("/")?s+n:s+"/"+n:s:n}function Z(e){const t=k(e);return t.startsWith("//")?"//":t.startsWith("/")?"/":/^[A-Za-z]:\//.test(t)?t.slice(0,3):""}function xt(e){const t=g(e);if(t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t))return t;const s=t.lastIndexOf("/");return s<=0?"/":s===2&&/^[A-Za-z]:/.test(t)?t.slice(0,3):t.slice(0,s)}function Pt(e){const t=k(e.trim());return t?t.startsWith("~")?"tilde":Z(t)?"absolute":"relative":"relative"}function Y(e,t){const s=g(e);if(!t)return"";const n=g(t),d=s.toLowerCase(),i=n.toLowerCase();return d===i?"~":d.startsWith(i+"/")?"~"+s.slice(n.length):""}function K(e,t,s){const n=g(e);return Pt(t)==="absolute"?n:Y(n,s)||n}function G(e,t,s){const n=g(e),d=Y(n,t),i=x=>x?x.endsWith("/")?x:x+"/":"",y=Array.from(new Set([n,i(n),d,i(d),B(n)].filter(Boolean))).join(`
2
+ `);return{absolute:n,search:y,group:s}}function $t(e){const t=new Set;return e.filter(s=>t.has(s.absolute)?!1:(t.add(s.absolute),!0))}function H(e,t){const s=O(t,t),n=O(e,t);return n===s?{directory:s,path:""}:{directory:s,path:n.slice(s.length+1)}}function kt(e){const t=new Map;let s=0;const n=f=>O(f,e.root()),d=f=>{const c=e.start();if(!c)return;const o=e.root(),p=k(f);if(!p)return{directory:n(g(c)),path:""};const m=e.home();if(p==="~")return{directory:n(g(m||c)),path:""};if(p.startsWith("~/")){const b=vt(m||c,p.slice(2));return M(b,o)?H(b,o):{directory:n(g(c)),path:""}}if(Z(p)){const b=g(p);return M(b,o)?H(b,o):{directory:n(g(c)),path:""}}return{directory:n(g(c)),path:p}},i=async f=>{const c=n(g(f)),o=t.get(c);if(o)return o;const p=ft(e.root(),c)??"",m=ht(e.sdk,p,{fetch:e.fetch,headers:e.headers?.()}).then(u=>u.map(b=>({name:b.name,absolute:g(k(b.absolute))})));return t.set(c,m),m},y=async(f,c,o)=>X(i,n(f),c,o),x=async(f,c,o)=>mt(i,n(f),c,{limit:o});return async f=>{const c=++s,o=()=>c===s,p=T(f),m=d(p);if(!m)return[];const u=k(p),b=u.startsWith("~")||!!Z(u)||u.includes("/"),_=k(m.path);if(!b){const h=_?await x(m.directory,_,50):await y(m.directory,"",50);return o()?h.slice(0,50):[]}const W=u.endsWith("/"),D=_.replace(/^\/+/,"").replace(/\/+$/,"").split("/").filter(h=>h&&h!=="."),C=12,z=4,r=async(h,A)=>{let $=A;for(const I of h){if(!o())return[];if(I===".."){$=$.map(F=>n(xt(F)));continue}const J=(await Promise.all($.map(F=>y(F,I,z)))).flat();if(!o())return[];if($=Array.from(new Set(J)).slice(0,C),$.length===0)return[]}return $},l=[m.directory];if(W){const h=await r(D,l);if(h.length===0)return[];const A=(await Promise.all(h.map($=>y($,"",50)))).flat();return o()?Array.from(new Set(A)).slice(0,50):[]}const a=D.slice(0,-1),w=D[D.length-1]??"",v=await r(a,l);if(v.length===0)return[];const P=(await Promise.all(v.map(h=>y(h,w,50)))).flat();return o()?Array.from(new Set(P)).slice(0,50):[]}}function _t(e){const t=V(),s=N(),n=Q(),d=U(),i=tt(),y=et(),x=rt(),[f,c]=nt("");let o;const p=R(()=>!(t.data.path.home||t.data.path.directory)),[m]=st(()=>p()?!0:void 0,async()=>s.client.path.get().then(r=>r.data).catch(()=>{}),{initialValue:void 0}),u=R(()=>t.data.path.home||m()?.home||""),b=R(()=>{const r=t.data.path.project_data_root?t.data.path:m();return at(r)}),_=R(()=>b()),W=kt({sdk:s,home:u,start:_,root:b,fetch:y.fetch,headers:()=>{const r=x.current?.http;if(r?.password)return{Authorization:`Basic ${ut({username:r.username,password:r.password})}`}}}),D=R(()=>{const r=n.projects.list(),l=new Map(t.data.project.map(a=>[a.worktree,a]));return r.map((a,w)=>({project:a,at:l.get(a.worktree)?.time?.updated??l.get(a.worktree)?.time?.created??0,index:w})).sort((a,w)=>w.at-a.at||a.index-w.index).slice(0,5).map(({project:a})=>{const w=l.get(a.worktree),v=G(a.worktree,u(),"recent"),P=a.name||w?.name||B(a.worktree);return{...v,search:`${v.search}
3
3
  ${P}`}})}),C=async r=>{const l=T(r),a=await W(l),w=l.endsWith("/"),v=a.map(P=>{const h=G(P,u(),"folders");return w?{...h,search:`${h.search}
4
- ${l}`}:h});return $t([...D(),...v])};function z(r){e.onSelect(e.multiple?[r]:r),d.close()}return S(lt,{get title(){return e.title??i.t("command.project.open")},get children(){return[S(ot,{get when(){return e.onCreateFolder},children:r=>(()=>{var l=wt();return R(l,S(it,{size:"normal",variant:"ghost",icon:"folder-add-left",class:"w-full justify-start",onClick:()=>r()(),get children(){return i.t("command.project.createFolder")}})),l})()}),S(dt,{get search(){return{placeholder:i.t("dialog.directory.search.placeholder"),autofocus:!0}},get emptyMessage(){return i.t("dialog.directory.empty")},get loadingMessage(){return i.t("common.loading")},items:C,key:r=>r.absolute,filterKeys:["search"],groupBy:r=>r.group,sortGroupsBy:(r,l)=>r.category===l.category?0:r.category==="recent"?-1:1,groupHeader:r=>r.category==="recent"?i.t("home.recentProjects"):i.t("command.project.open"),ref:r=>o=r,onFilter:r=>c(T(r)),onKeyEvent:(r,l)=>{if(r.key!=="Tab"||r.shiftKey||!l)return;r.preventDefault(),r.stopPropagation();const a=K(l.absolute,f(),u());o?.setFilter(a.endsWith("/")?a:a+"/")},onSelect:r=>{r&&z(r.absolute)},children:r=>{const l=K(r.absolute,f(),u());return l==="~"?(()=>{var a=gt(),w=a.firstChild,v=w.firstChild;return R(w,S(L,{get node(){return{path:r.absolute,type:"directory"}},class:"shrink-0 size-4"}),v),a})():(()=>{var a=yt(),w=a.firstChild,v=w.firstChild,P=v.firstChild,h=P.nextSibling;return R(w,S(L,{get node(){return{path:r.absolute,type:"directory"}},class:"shrink-0 size-4"}),v),R(P,()=>ct(l)),R(h,()=>B(l)),a})()}})]}})}export{_t as DialogSelectDirectory};
4
+ ${l}`}:h});return $t([...D(),...v])};function z(r){e.onSelect(e.multiple?[r]:r),d.close()}return S(lt,{get title(){return e.title??i.t("command.project.open")},get children(){return[S(ot,{get when(){return e.onCreateFolder},children:r=>(()=>{var l=wt();return j(l,S(it,{size:"normal",variant:"ghost",icon:"folder-add-left",class:"w-full justify-start",onClick:()=>r()(),get children(){return i.t("command.project.createFolder")}})),l})()}),S(dt,{get search(){return{placeholder:i.t("dialog.directory.search.placeholder"),autofocus:!0}},get emptyMessage(){return i.t("dialog.directory.empty")},get loadingMessage(){return i.t("common.loading")},items:C,key:r=>r.absolute,filterKeys:["search"],groupBy:r=>r.group,sortGroupsBy:(r,l)=>r.category===l.category?0:r.category==="recent"?-1:1,groupHeader:r=>r.category==="recent"?i.t("home.recentProjects"):i.t("command.project.open"),ref:r=>o=r,onFilter:r=>c(T(r)),onKeyEvent:(r,l)=>{if(r.key!=="Tab"||r.shiftKey||!l)return;r.preventDefault(),r.stopPropagation();const a=K(l.absolute,f(),u());o?.setFilter(a.endsWith("/")?a:a+"/")},onSelect:r=>{r&&z(r.absolute)},children:r=>{const l=K(r.absolute,f(),u());return l==="~"?(()=>{var a=gt(),w=a.firstChild,v=w.firstChild;return j(w,S(L,{get node(){return{path:r.absolute,type:"directory"}},class:"shrink-0 size-4"}),v),a})():(()=>{var a=yt(),w=a.firstChild,v=w.firstChild,P=v.firstChild,h=P.nextSibling;return j(w,S(L,{get node(){return{path:r.absolute,type:"directory"}},class:"shrink-0 size-4"}),v),j(P,()=>ct(l)),j(h,()=>B(l)),a})()}})]}})}export{_t as DialogSelectDirectory};
@@ -1 +1 @@
1
- import{al as U,f as V,aW as X,b3 as ee,b as te,b4 as ne,Q as se,e as re,c as ae,b5 as oe,Z as ie,h as v,a8 as ce,o as le,n as w,S as de,M as P,i as g,E as F,b6 as ue,ao as ge,I as fe,r as j,b7 as he,aY as pe,aZ as me,aQ as K,D as we,b8 as ye,b9 as be,ba as ve,t as _}from"./index-t6AoWpnz.js";import{L as xe}from"./list-DsM_Q7VB.js";var q=_('<span class="text-14-regular text-text-weak truncate">'),ke=_('<div class="w-full flex items-center justify-between gap-4"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">'),Se=_('<span class="text-12-regular text-text-weak whitespace-nowrap ml-2">'),$e=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong truncate">'),_e=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap">');const T=5,Ce=["session.new","workspace.new","session.previous","session.next","terminal.toggle","review.toggle"],N=t=>{const n=new Set,o=[];for(const f of t)n.has(f.id)||(n.add(f.id),o.push(f));return o},z=(t,n)=>({id:"command:"+t.id,type:"command",title:t.title,description:t.description,keybind:t.keybind,category:n,option:t}),E=(t,n)=>({id:"file:"+t,type:"file",title:t,category:n,path:t}),De=(t,n)=>({id:`session:${t.directory}:${t.id}`,type:"session",title:t.title,description:t.description,category:n,directory:t.directory,sessionID:t.id,archived:t.archived,updated:t.updated});function Fe(t){const n=v(()=>t.filesOnly()?[]:t.command.options.filter(r=>!r.disabled&&!r.hidden&&!r.id.startsWith("suggested.")&&r.id!=="file.open")),o=v(()=>{const r=t.language.t("palette.group.commands");return n().map(d=>z(d,r))}),f=v(()=>{const r=n(),d=new Map(Ce.map((a,c)=>[a,c])),y=r.filter(a=>d.has(a.id)),i=y.length?y:r.slice(0,T),h=y.length?[...i].sort((a,c)=>(d.get(a.id)??0)-(d.get(c.id)??0)):i,b=t.language.t("palette.group.commands");return h.map(a=>z(a,b))});return{allowed:n,list:o,picks:f}}function Ee(t){const n=ye({tabs:t.tabs,pathFromTab:t.file.pathFromTab,normalizeTab:r=>r.startsWith("file://")?t.file.tab(r):r}),o=v(()=>{const r=n.openedTabs(),d=n.activeFileTab(),y=d?[d,...r.filter(a=>a!==d)]:r,i=new Set,h=t.language.t("palette.group.files"),b=[];for(const a of y){const c=t.file.pathFromTab(a);c&&(i.has(c)||(i.add(c),b.push(E(c,h))))}return b.slice(0,T)}),f=v(()=>{const r=t.language.t("palette.group.files");return t.file.tree.children("").filter(i=>i.type==="file").map(i=>i.path).sort((i,h)=>i.localeCompare(h)).slice(0,T).map(i=>E(i,r))});return{recent:o,root:f}}function Me(t){const n={token:0,inflight:void 0,cached:void 0};return{sessions:f=>{if(!f.trim())return n.token+=1,n.inflight=void 0,n.cached=void 0,[];if(n.cached)return n.cached;if(n.inflight)return n.inflight;const d=n.token,y=t.workspaces();return y.length===0?[]:(n.inflight=Promise.all(y.map(i=>{const h=t.label(i);return t.globalSDK.client.session.list({directory:i,roots:!0}).then(b=>(b.data??[]).filter(a=>!!a?.id).map(a=>({id:a.id,title:a.title??t.language.t("command.session.new"),description:h,directory:i,archived:a.time?.archived,updated:a.time?.updated}))).catch(()=>[])})).then(i=>{if(n.token!==d)return[];const h=new Set,b=t.language.t("command.category.session"),a=i.flat().filter(c=>{const S=`${c.directory}:${c.id}`;return h.has(S)?!1:(h.add(S),!0)}).map(c=>De(c,b));return n.cached=a,a}).catch(()=>[]).finally(()=>{n.inflight=void 0}),n.inflight)}}}function Le(t){const n=U(),o=V(),f=X(),r=ee(),d=te(),y=ne(),i=se(),h=re(),b=ae(),{params:a,tabs:c,view:S}=oe(),C=()=>t.mode==="files",k={cleanup:void 0,committed:!1},[G,R]=ie(!1),I=Fe({filesOnly:C,command:n,language:o}),$=Ee({file:r,tabs:c,language:o}),L=v(()=>ce(a.dir)??""),O=v(()=>{const e=L();if(e)return f.projects.list().find(s=>s.worktree===e||s.sandboxes?.includes(e))}),W=v(()=>{const e=L(),s=O();if(!s)return e?[e]:[];const l=[s.worktree,...s.sandboxes??[]];return e&&!l.includes(e)?[...l,e]:l}),A=v(()=>b.data.path.home),H=e=>{const s=O(),l=s&&e===s.worktree?o.t("workspace.type.local"):o.t("workspace.type.sandbox"),[p]=b.child(e,{bootstrap:!1}),u=A(),m=u?e.replace(u,"~"):e,x=p.vcs?.branch??K(e);return`${l} : ${x||m}`},{sessions:Q}=Me({workspaces:W,label:H,globalSDK:h,language:o}),Y=async e=>{const s=e.trim();if(R(s.length>0),!s&&C()){const x=r.tree.state("")?.loaded,M=x?Promise.resolve():r.tree.list(""),D=N([...$.recent(),...$.root()]);return x||D.length>0?D:(await M,N([...$.recent(),...$.root()]))}if(!s)return[...I.picks(),...$.recent()];if(C()){const x=await r.searchFiles(s),M=o.t("palette.group.files");return x.map(D=>E(D,M))}const[l,p]=await Promise.all([r.searchFiles(s),Promise.resolve(Q(s))]),u=o.t("palette.group.files"),m=l.map(x=>E(x,u));return[...I.list(),...p,...m]},Z=e=>{k.cleanup?.(),e&&e.type==="command"&&(k.cleanup=e.option?.onHighlight?.())},B=e=>{const s=r.tab(e);c().open(s),r.load(e),S().reviewPanel.opened()||S().reviewPanel.open(),f.fileTree.setTab("all"),t.onOpenFile?.(e),c().setActive(s)},J=e=>{if(e){if(k.committed=!0,k.cleanup=void 0,d.close(),e.type==="command"){e.option?.onSelect?.("palette");return}if(e.type==="session"){if(!e.directory||!e.sessionID)return;i(be(y.pathname,ve(e.directory),e.sessionID));return}e.path&&B(e.path)}};return le(()=>{k.committed||k.cleanup?.()}),w(we,{class:"pt-3 pb-0 !max-h-[480px]",transition:!0,get children(){return w(xe,{get search(){return{placeholder:C()?o.t("session.header.searchFiles"):o.t("palette.search.placeholder"),autofocus:!0,hideIcon:!0}},get emptyMessage(){return o.t("palette.empty")},get loadingMessage(){return o.t("common.loading")},items:Y,key:e=>e.id,filterKeys:["title","description","category"],get groupBy(){return G()?e=>e.category:()=>""},onMove:Z,onSelect:J,children:e=>w(de,{get fallback(){return(()=>{var s=_e(),l=s.firstChild,p=l.firstChild,u=p.firstChild,m=u.nextSibling;return g(l,w(pe,{get node(){return{path:e.path??"",type:"file"}},class:"shrink-0 size-4"}),p),g(u,()=>me(e.path??"")),g(m,()=>K(e.path??"")),s})()},get children(){return[w(P,{get when(){return e.type==="command"},get children(){var s=ke(),l=s.firstChild,p=l.firstChild;return g(p,()=>e.title),g(l,w(F,{get when(){return e.description},get children(){var u=q();return g(u,()=>e.description),u}}),null),g(s,w(F,{get when(){return e.keybind},get children(){return w(ue,{class:"rounded-[4px]",get children(){return ge(e.keybind??"",o.t)}})}}),null),s}}),w(P,{get when(){return e.type==="session"},get children(){var s=$e(),l=s.firstChild,p=l.firstChild,u=p.firstChild;return g(l,w(fe,{name:"bubble-5",size:"small",class:"shrink-0 text-icon-weak"}),p),g(u,()=>e.title),g(p,w(F,{get when(){return e.description},get children(){var m=q();return g(m,()=>e.description),j(()=>m.classList.toggle("opacity-70",!!e.archived)),m}}),null),g(s,w(F,{get when(){return e.updated},get children(){var m=Se();return g(m,()=>he(new Date(e.updated).toISOString(),o.t)),m}}),null),j(()=>u.classList.toggle("opacity-70",!!e.archived)),s}})]}})})}})}export{Le as DialogSelectFile};
1
+ import{al as J,f as U,aX as V,b3 as ee,b as te,b4 as ne,Q as se,e as re,c as ae,b5 as oe,Z as ie,h as v,a8 as ce,o as le,n as w,S as de,M as P,i as g,E as F,b6 as ue,ao as ge,I as fe,r as j,b7 as he,aZ as pe,a_ as me,aR as K,D as we,b8 as ye,b9 as be,ba as ve,t as _}from"./index-DqutAOLe.js";import{L as xe}from"./list-Cnpbqmww.js";var q=_('<span class="text-14-regular text-text-weak truncate">'),ke=_('<div class="w-full flex items-center justify-between gap-4"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">'),Se=_('<span class="text-12-regular text-text-weak whitespace-nowrap ml-2">'),$e=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong truncate">'),_e=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap">');const T=5,Ce=["session.new","workspace.new","session.previous","session.next","terminal.toggle","review.toggle"],N=t=>{const n=new Set,o=[];for(const f of t)n.has(f.id)||(n.add(f.id),o.push(f));return o},R=(t,n)=>({id:"command:"+t.id,type:"command",title:t.title,description:t.description,keybind:t.keybind,category:n,option:t}),E=(t,n)=>({id:"file:"+t,type:"file",title:t,category:n,path:t}),De=(t,n)=>({id:`session:${t.directory}:${t.id}`,type:"session",title:t.title,description:t.description,category:n,directory:t.directory,sessionID:t.id,archived:t.archived,updated:t.updated});function Fe(t){const n=v(()=>t.filesOnly()?[]:t.command.options.filter(r=>!r.disabled&&!r.hidden&&!r.id.startsWith("suggested.")&&r.id!=="file.open")),o=v(()=>{const r=t.language.t("palette.group.commands");return n().map(d=>R(d,r))}),f=v(()=>{const r=n(),d=new Map(Ce.map((a,c)=>[a,c])),y=r.filter(a=>d.has(a.id)),i=y.length?y:r.slice(0,T),h=y.length?[...i].sort((a,c)=>(d.get(a.id)??0)-(d.get(c.id)??0)):i,b=t.language.t("palette.group.commands");return h.map(a=>R(a,b))});return{allowed:n,list:o,picks:f}}function Ee(t){const n=ye({tabs:t.tabs,pathFromTab:t.file.pathFromTab,normalizeTab:r=>r.startsWith("file://")?t.file.tab(r):r}),o=v(()=>{const r=n.openedTabs(),d=n.activeFileTab(),y=d?[d,...r.filter(a=>a!==d)]:r,i=new Set,h=t.language.t("palette.group.files"),b=[];for(const a of y){const c=t.file.pathFromTab(a);c&&(i.has(c)||(i.add(c),b.push(E(c,h))))}return b.slice(0,T)}),f=v(()=>{const r=t.language.t("palette.group.files");return t.file.tree.children("").filter(i=>i.type==="file").map(i=>i.path).sort((i,h)=>i.localeCompare(h)).slice(0,T).map(i=>E(i,r))});return{recent:o,root:f}}function Me(t){const n={token:0,inflight:void 0,cached:void 0};return{sessions:f=>{if(!f.trim())return n.token+=1,n.inflight=void 0,n.cached=void 0,[];if(n.cached)return n.cached;if(n.inflight)return n.inflight;const d=n.token,y=t.workspaces();return y.length===0?[]:(n.inflight=Promise.all(y.map(i=>{const h=t.label(i);return t.globalSDK.client.session.list({directory:i,roots:!0}).then(b=>(b.data??[]).filter(a=>!!a?.id).map(a=>({id:a.id,title:a.title??t.language.t("command.session.new"),description:h,directory:i,archived:a.time?.archived,updated:a.time?.updated}))).catch(()=>[])})).then(i=>{if(n.token!==d)return[];const h=new Set,b=t.language.t("command.category.session"),a=i.flat().filter(c=>{const S=`${c.directory}:${c.id}`;return h.has(S)?!1:(h.add(S),!0)}).map(c=>De(c,b));return n.cached=a,a}).catch(()=>[]).finally(()=>{n.inflight=void 0}),n.inflight)}}}function Le(t){const n=J(),o=U(),f=V(),r=ee(),d=te(),y=ne(),i=se(),h=re(),b=ae(),{params:a,tabs:c,view:S}=oe(),C=()=>t.mode==="files",k={cleanup:void 0,committed:!1},[z,G]=ie(!1),I=Fe({filesOnly:C,command:n,language:o}),$=Ee({file:r,tabs:c,language:o}),L=v(()=>ce(a.dir)??""),O=v(()=>{const e=L();if(e)return f.projects.list().find(s=>s.worktree===e||s.sandboxes?.includes(e))}),A=v(()=>{const e=L(),s=O();if(!s)return e?[e]:[];const l=[s.worktree,...s.sandboxes??[]];return e&&!l.includes(e)?[...l,e]:l}),H=v(()=>b.data.path.home),W=e=>{const s=O(),l=s&&e===s.worktree?o.t("workspace.type.local"):o.t("workspace.type.sandbox"),[p]=b.child(e,{bootstrap:!1}),u=H(),m=u?e.replace(u,"~"):e,x=p.vcs?.branch??K(e);return`${l} : ${x||m}`},{sessions:Z}=Me({workspaces:A,label:W,globalSDK:h,language:o}),B=async e=>{const s=e.trim();if(G(s.length>0),!s&&C()){const x=r.tree.state("")?.loaded,M=x?Promise.resolve():r.tree.list(""),D=N([...$.recent(),...$.root()]);return x||D.length>0?D:(await M,N([...$.recent(),...$.root()]))}if(!s)return[...I.picks(),...$.recent()];if(C()){const x=await r.searchFiles(s),M=o.t("palette.group.files");return x.map(D=>E(D,M))}const[l,p]=await Promise.all([r.searchFiles(s),Promise.resolve(Z(s))]),u=o.t("palette.group.files"),m=l.map(x=>E(x,u));return[...I.list(),...p,...m]},Q=e=>{k.cleanup?.(),e&&e.type==="command"&&(k.cleanup=e.option?.onHighlight?.())},X=e=>{const s=r.tab(e);c().open(s),r.load(e),S().reviewPanel.opened()||S().reviewPanel.open(),f.fileTree.setTab("all"),t.onOpenFile?.(e),c().setActive(s)},Y=e=>{if(e){if(k.committed=!0,k.cleanup=void 0,d.close(),e.type==="command"){e.option?.onSelect?.("palette");return}if(e.type==="session"){if(!e.directory||!e.sessionID)return;i(be(y.pathname,ve(e.directory),e.sessionID));return}e.path&&X(e.path)}};return le(()=>{k.committed||k.cleanup?.()}),w(we,{class:"pt-3 pb-0 !max-h-[480px]",transition:!0,get children(){return w(xe,{get search(){return{placeholder:C()?o.t("session.header.searchFiles"):o.t("palette.search.placeholder"),autofocus:!0,hideIcon:!0}},get emptyMessage(){return o.t("palette.empty")},get loadingMessage(){return o.t("common.loading")},items:B,key:e=>e.id,filterKeys:["title","description","category"],get groupBy(){return z()?e=>e.category:()=>""},onMove:Q,onSelect:Y,children:e=>w(de,{get fallback(){return(()=>{var s=_e(),l=s.firstChild,p=l.firstChild,u=p.firstChild,m=u.nextSibling;return g(l,w(pe,{get node(){return{path:e.path??"",type:"file"}},class:"shrink-0 size-4"}),p),g(u,()=>me(e.path??"")),g(m,()=>K(e.path??"")),s})()},get children(){return[w(P,{get when(){return e.type==="command"},get children(){var s=ke(),l=s.firstChild,p=l.firstChild;return g(p,()=>e.title),g(l,w(F,{get when(){return e.description},get children(){var u=q();return g(u,()=>e.description),u}}),null),g(s,w(F,{get when(){return e.keybind},get children(){return w(ue,{class:"rounded-[4px]",get children(){return ge(e.keybind??"",o.t)}})}}),null),s}}),w(P,{get when(){return e.type==="session"},get children(){var s=$e(),l=s.firstChild,p=l.firstChild,u=p.firstChild;return g(l,w(fe,{name:"bubble-5",size:"small",class:"shrink-0 text-icon-weak"}),p),g(u,()=>e.title),g(p,w(F,{get when(){return e.description},get children(){var m=q();return g(m,()=>e.description),j(()=>m.classList.toggle("opacity-70",!!e.archived)),m}}),null),g(s,w(F,{get when(){return e.updated},get children(){var m=Se();return g(m,()=>he(new Date(e.updated).toISOString(),o.t)),m}}),null),j(()=>u.classList.toggle("opacity-70",!!e.archived)),s}})]}})})}})}export{Le as DialogSelectFile};
@@ -1,2 +1,2 @@
1
- import{bd as Z,c as ee,be as te,f as re,bf as ne,bg as ae,k as le,h as C,z as Q,y as O,i as n,n as c,v as ie,p as F,E as w,B as T,T as j,bh as oe,D as se,bi as ce,t as v,d as de}from"./index-t6AoWpnz.js";import{L as me}from"./list-DsM_Q7VB.js";import{S as A}from"./switch-Bmpibkz9.js";function M(a){return{name:"",transport:"local",command:"",environment:"",url:"",headers:"",enabled:!0,...a}}function R(a){const r=[],g=/"([^"]*)"|'([^']*)'|(\S+)/g;let d;for(;d=g.exec(a.trim());)r.push(d[1]??d[2]??d[3]??"");return r.filter(t=>t.length>0)}function ue(a){return a.map(r=>/[\s"']/.test(r)?`"${r.replaceAll('"','\\"')}"`:r).join(" ")}function G(a){const r={};for(const g of a.split(/\r?\n/)){const d=g.trim();if(!d||d.startsWith("#"))continue;const t=d.indexOf("=");if(t<=0)continue;const k=d.slice(0,t).trim(),K=d.slice(t+1).trim();k&&(r[k]=K)}return Object.keys(r).length>0?r:void 0}function V(a){return a?Object.entries(a).map(([r,g])=>`${r}=${g}`).join(`
1
+ import{bd as Z,c as ee,be as te,f as re,bf as ne,bg as ae,k as le,h as C,z as Q,y as O,i as n,n as c,v as ie,p as F,E as w,B as T,T as j,bh as oe,D as se,bi as ce,t as v,d as de}from"./index-DqutAOLe.js";import{L as me}from"./list-Cnpbqmww.js";import{S as A}from"./switch-DPKITECj.js";function M(a){return{name:"",transport:"local",command:"",environment:"",url:"",headers:"",enabled:!0,...a}}function R(a){const r=[],g=/"([^"]*)"|'([^']*)'|(\S+)/g;let d;for(;d=g.exec(a.trim());)r.push(d[1]??d[2]??d[3]??"");return r.filter(t=>t.length>0)}function ue(a){return a.map(r=>/[\s"']/.test(r)?`"${r.replaceAll('"','\\"')}"`:r).join(" ")}function G(a){const r={};for(const g of a.split(/\r?\n/)){const d=g.trim();if(!d||d.startsWith("#"))continue;const t=d.indexOf("=");if(t<=0)continue;const k=d.slice(0,t).trim(),K=d.slice(t+1).trim();k&&(r[k]=K)}return Object.keys(r).length>0?r:void 0}function V(a){return a?Object.entries(a).map(([r,g])=>`${r}=${g}`).join(`
2
2
  `):""}function ge(a,r){return r.type==="remote"?M({name:a,transport:"remote",url:r.url??"",headers:V(r.headers),enabled:r.enabled!==!1}):M({name:a,transport:"local",command:ue(r.command??[]),environment:V(r.environment),enabled:r.enabled!==!1})}function pe(a,r,g){const d=a.name.trim();if(!d)return"name";if(d!==g&&r.includes(d))return"duplicate";if(a.transport==="local")return R(a.command).length===0?"command":void 0;if(!a.url.trim())return"url"}function fe(a){const r=a.enabled;return a.transport==="remote"?{type:"remote",url:a.url.trim(),enabled:r,headers:G(a.headers)}:{type:"local",command:R(a.command),enabled:r,environment:G(a.environment)}}var he=v('<div class="flex items-center gap-2 -ml-2"><span>'),ve=v('<div class="flex flex-col gap-3 min-h-0 px-5 pb-5"><div class=shrink-0>'),I=v('<div class="flex flex-col gap-5">'),be=v('<p class="text-12-regular text-text-critical-base">'),xe=v('<div class="flex h-full min-h-0 flex-col px-5 pb-5"><div class="min-h-0 flex-1 overflow-y-auto pr-1"><div class="flex flex-col gap-5 rounded-md bg-surface-base p-5"><div class="flex flex-col gap-2"><span class="text-12-medium text-text-strong"></span></div><div class="flex items-center justify-between gap-3 rounded-md border border-border-weak-base px-3 py-3"><div class="flex flex-col gap-1"><span class="text-13-medium text-text-strong"></span><span class="text-12-regular text-text-weak"></span></div></div></div></div><div class="shrink-0 flex justify-end gap-2 pt-4">'),ye=v('<span class="text-11-regular text-text-weaker">'),$e=v('<span class="text-11-regular text-text-weak">'),_e=v('<span class="text-11-regular text-text-weaker truncate">'),Ce=v('<div class="w-full flex items-center justify-between gap-x-3"><div class="flex flex-col gap-0.5 min-w-0"><div class="flex items-center gap-2"><span class=truncate></span></div></div><div class="flex items-center gap-2 shrink-0">');const we={connected:"mcp.status.connected",failed:"mcp.status.failed",needs_auth:"mcp.status.needs_auth",disabled:"mcp.status.disabled"},N={name:"dialog.mcp.error.name",command:"dialog.mcp.error.command",url:"dialog.mcp.error.url",duplicate:"dialog.mcp.error.duplicate"},Fe=a=>{const r=Z(),g=ee(),d=te(),t=re(),k=ne(),K=ae(),[s,y]=le({mode:a.initialMode==="add"?"form":"list",editing:void 0,form:M(),error:""}),S=C(()=>g.data.config.mcp??{}),B=C(()=>{const e=new Set([...Object.keys(S()),...Object.keys(r.data.mcp??{})]);return Array.from(e).map(o=>({name:o,status:r.data.mcp?.[o]?.status??(S()[o]?"disabled":void 0)})).sort((o,l)=>o.name.localeCompare(l.name))}),W=C(()=>Object.keys(S())),x=e=>y("form",e),D=()=>k.refetchQueries(K.mcp(ce(r.directory))),b=Q(()=>({mutationFn:async e=>{r.data.mcp[e]?.status==="connected"?await d.client.mcp.disconnect({name:e}):await d.client.mcp.connect({name:e})},onSuccess:()=>D(),onError:e=>{O({variant:"error",title:t.t("common.requestFailed"),description:e instanceof Error?e.message:String(e)})}})),u=Q(()=>({mutationFn:async()=>{const e=pe(s.form,W(),s.editing);if(e)throw y("error",t.t(N[e])),new Error(e);y("error","");const o=s.form.name.trim(),l=fe(s.form),m={...S()};return s.editing&&s.editing!==o&&delete m[s.editing],m[o]=l,await g.updateConfig({mcp:m}),l.enabled!==!1&&await d.client.mcp.add({name:o,config:l}).catch(()=>{}),o},onSuccess:async()=>{O({title:t.t("dialog.mcp.toast.saved")});const e=async()=>{await Promise.all([D(),k.invalidateQueries({queryKey:["config"]})])};await e(),setTimeout(()=>void e(),500),setTimeout(()=>void e(),1500),q()},onError:e=>{e instanceof Error&&e.message in N||O({variant:"error",title:t.t("common.requestFailed"),description:e instanceof Error?e.message:String(e)})}})),H=C(()=>B().filter(e=>e.status==="connected").length),J=C(()=>B().length);function q(){y({mode:"list",editing:void 0,form:M(),error:""})}function U(){y({mode:"form",editing:void 0,form:M(),error:""})}function X(e){const o=S()[e];if(!o||!("type"in o)){O({variant:"error",title:t.t("dialog.mcp.error.missingConfig")});return}y({mode:"form",editing:e,form:ge(e,o),error:""})}const Y=C(()=>s.mode!=="form"?t.t("dialog.mcp.title"):(()=>{var e=he(),o=e.firstChild;return n(e,c(ie,{icon:"arrow-left",variant:"ghost",onClick:q,get"aria-label"(){return t.t("common.goBack")}}),o),n(o,(()=>{var l=F(()=>!!s.editing);return()=>l()?t.t("dialog.mcp.editTitle"):t.t("dialog.mcp.addTitle")})()),e})());return c(se,{size:"large",get title(){return Y()},get description(){return F(()=>s.mode==="list")()?t.t("dialog.mcp.description",{enabled:H(),total:J()}):t.t("dialog.mcp.form.hint")},class:"overflow-hidden [&_[data-slot=dialog-body]]:h-full [&_[data-slot=dialog-body]]:min-h-0",get children(){return c(w,{get when(){return s.mode==="list"},get fallback(){return(()=>{var e=xe(),o=e.firstChild,l=o.firstChild,m=l.firstChild,P=m.firstChild,$=m.nextSibling,E=$.firstChild,L=E.firstChild,p=L.nextSibling,_=o.nextSibling;return n(l,c(j,{get label(){return t.t("dialog.mcp.form.name")},get placeholder(){return t.t("dialog.mcp.form.namePlaceholder")},get value(){return s.form.name},get disabled(){return u.isPending||!!s.editing},onChange:i=>x({name:i})}),m),n(P,()=>t.t("dialog.mcp.form.transport")),n(m,c(oe,{options:["local","remote"],get current(){return s.form.transport},value:i=>i,label:i=>i==="local"?t.t("dialog.mcp.form.transport.local"):t.t("dialog.mcp.form.transport.remote"),onSelect:i=>{!i||u.isPending||x({transport:i})}}),null),n(l,c(w,{get when(){return s.form.transport==="local"},get fallback(){return(()=>{var i=I();return n(i,c(j,{get label(){return t.t("dialog.mcp.form.url")},get placeholder(){return t.t("dialog.mcp.form.urlPlaceholder")},get value(){return s.form.url},get disabled(){return u.isPending},onChange:h=>x({url:h})}),null),n(i,c(j,{multiline:!0,get label(){return t.t("dialog.mcp.form.headers")},get placeholder(){return t.t("dialog.mcp.form.headersPlaceholder")},get value(){return s.form.headers},get disabled(){return u.isPending},onChange:h=>x({headers:h}),class:"min-h-24"}),null),i})()},get children(){var i=I();return n(i,c(j,{get label(){return t.t("dialog.mcp.form.command")},get placeholder(){return t.t("dialog.mcp.form.commandPlaceholder")},get value(){return s.form.command},get disabled(){return u.isPending},onChange:h=>x({command:h})}),null),n(i,c(j,{multiline:!0,get label(){return t.t("dialog.mcp.form.environment")},get placeholder(){return t.t("dialog.mcp.form.environmentPlaceholder")},get value(){return s.form.environment},get disabled(){return u.isPending},onChange:h=>x({environment:h}),class:"min-h-24"}),null),i}}),$),n(L,()=>t.t("dialog.mcp.form.enabled")),n(p,()=>t.t("dialog.mcp.form.enabledDescription")),n($,c(A,{get checked(){return s.form.enabled},get disabled(){return u.isPending},onChange:i=>x({enabled:i})}),null),n(l,c(w,{get when(){return s.error},get children(){var i=be();return n(i,()=>s.error),i}}),null),n(_,c(T,{variant:"ghost",size:"large",onClick:q,get disabled(){return u.isPending},get children(){return t.t("common.cancel")}}),null),n(_,c(T,{variant:"primary",size:"large",get disabled(){return u.isPending},onClick:()=>{u.isPending||u.mutate()},get children(){return F(()=>!!u.isPending)()?t.t("common.saving"):t.t("common.save")}}),null),e})()},get children(){var e=ve(),o=e.firstChild;return n(e,c(me,{get search(){return{placeholder:t.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return t.t("dialog.mcp.empty")},key:l=>l?.name??"",items:B,filterKeys:["name","status"],sortBy:(l,m)=>l.name.localeCompare(m.name),onSelect:l=>{!l||b.isPending||b.mutate(l.name)},children:l=>{const m=()=>r.data.mcp[l.name],P=()=>m()?.status??l.status,$=()=>{const p=P()?we[P()]:void 0;if(p)return t.t(p)},E=()=>{const p=m();return p?.status==="failed"?p.error:void 0},L=()=>P()==="connected";return(()=>{var p=Ce(),_=p.firstChild,i=_.firstChild,h=i.firstChild,z=_.nextSibling;return n(h,()=>l.name),n(i,c(w,{get when(){return $()},get children(){var f=ye();return n(f,$),f}}),null),n(i,c(w,{get when(){return F(()=>!!b.isPending)()&&b.variables===l.name},get children(){var f=$e();return n(f,()=>t.t("common.loading.ellipsis")),f}}),null),n(_,c(w,{get when(){return E()},get children(){var f=_e();return n(f,E),f}}),null),z.$$click=f=>f.stopPropagation(),n(z,c(T,{variant:"ghost",class:"h-7 px-2 text-12-regular",onClick:()=>X(l.name),get children(){return t.t("common.edit")}}),null),n(z,c(A,{get checked(){return L()},get disabled(){return F(()=>!!b.isPending)()&&b.variables===l.name},onChange:()=>{b.isPending||b.mutate(l.name)}}),null),p})()}}),o),n(o,c(T,{variant:"secondary",icon:"plus-small",size:"large",onClick:U,class:"py-1.5 pl-1.5 pr-3",get children(){return t.t("dialog.mcp.addButton")}})),e}})}})};de(["click"]);export{Fe as DialogSelectMcp};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-manage-models-BnaOhkF4.js","assets/index-DqutAOLe.js","assets/index-CzxfzwcV.css","assets/list-Cnpbqmww.js","assets/switch-DPKITECj.js","assets/dialog-select-provider-DjM-NV2S.js","assets/tag-B_xDskei.js"])))=>i.map(i=>d[i]);
2
+ import{f as x,i as s,n as i,E as f,t as b,b as y,B as C,D as E,k as I,bb as v,m as T,a3 as P,v as L,bc as O,h as k,G as p,_}from"./index-DqutAOLe.js";import{T as $}from"./tag-B_xDskei.js";import{L as A}from"./list-Cnpbqmww.js";var B=b('<div class="flex flex-col gap-1 py-1"><div class=text-13-medium></div><div class="text-12-regular text-text-invert-base"></div><div class="text-12-regular text-text-invert-base">'),z=b('<div class="text-12-regular text-text-invert-base">');const j=n=>{const o=x(),a=e=>{const l=`${e.id} ${e.name}`.toLowerCase();return/claude|anthropic/.test(l)?o.t("model.provider.anthropic"):/gpt|o[1-4]|codex|openai/.test(l)?o.t("model.provider.openai"):/gemini|palm|bard|google/.test(l)?o.t("model.provider.google"):/grok|xai/.test(l)?o.t("model.provider.xai"):/llama|meta/.test(l)?o.t("model.provider.meta"):e.provider.name},c=e=>e==="text"?o.t("model.input.text"):e==="image"?o.t("model.input.image"):e==="audio"?o.t("model.input.audio"):e==="video"?o.t("model.input.video"):e==="pdf"?o.t("model.input.pdf"):e,r=()=>{const e=[];n.latest&&e.push(o.t("model.tag.latest")),n.free&&e.push(o.t("model.tag.free")),n.limited&&e.push(o.t("model.tag.limited"));const l=e.length?` (${e.join(", ")})`:"";return`${a(n.model)} ${n.model.name}${l}`},t=()=>{if(n.model.capabilities){const g=n.model.capabilities.input,h=["text","image","audio","video","pdf"].filter(m=>g[m]).map(m=>c(m));return h.length?h.join(", "):void 0}const e=n.model.modalities?.input;if(!e)return;const l=e.map(g=>c(g));return l.length?l.join(", "):void 0},u=()=>n.model.capabilities?n.model.capabilities.reasoning?o.t("model.tooltip.reasoning.allowed"):o.t("model.tooltip.reasoning.none"):n.model.reasoning?o.t("model.tooltip.reasoning.allowed"):o.t("model.tooltip.reasoning.none"),d=()=>o.t("model.tooltip.context",{limit:n.model.limit.context.toLocaleString()});return(()=>{var e=B(),l=e.firstChild,g=l.nextSibling,S=g.nextSibling;return s(l,r),s(e,i(f,{get when(){return t()},children:h=>(()=>{var m=z();return s(m,()=>o.t("model.tooltip.allows",{inputs:h()})),m})()}),g),s(g,u),s(S,d),e})()};var F=b('<div class="w-full flex items-center gap-x-2 text-13-regular"><span class=truncate>'),R=b('<div class="flex items-center gap-1">');const w=(n,o)=>n==="opencode"&&(!o||o.input===0),D=n=>n==="onescience",M=n=>{const o=n.model??O().model,a=x(),c=k(()=>o.list().filter(t=>n.provider?t.provider.id===n.provider:!0).filter(t=>o.visible({modelID:t.id,providerID:t.provider.id})).map(t=>({...t,search:[t.provider.name,t.provider.id,t.name,t.id,t.family,w(t.provider.id,t.cost)?"free 免费":"",D(t.provider.id)?"limited 限免":"",t.latest?"latest 最新":""].join(" ")})));return i(A,{get class(){return`flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0 ${n.class??""}`},get search(){return{placeholder:a.t("dialog.model.search.placeholder"),autofocus:!0,action:n.action}},get emptyMessage(){return a.t("dialog.model.empty")},key:r=>`${r.provider.id}:${r.id}`,items:c,get current(){return o.current()},filterKeys:["search"],sortBy:(r,t)=>r.name.localeCompare(t.name),groupBy:r=>r.provider.name,sortGroupsBy:(r,t)=>{const u=r.items[0].provider.id,d=t.items[0].provider.id;return p.includes(u)&&!p.includes(d)?-1:!p.includes(u)&&p.includes(d)?1:p.indexOf(u)-p.indexOf(d)},itemWrapper:(r,t)=>i(P,{class:"w-full",placement:"right-start",gutter:12,get value(){return i(j,{model:r,get latest(){return r.latest},get free(){return w(r.provider.id,r.cost)},get limited(){return D(r.provider.id)}})},children:t}),onSelect:r=>{o.set(r?{modelID:r.id,providerID:r.provider.id}:void 0,{recent:!0}),n.onSelect()},children:r=>(()=>{var t=F(),u=t.firstChild;return s(u,()=>r.name),s(t,i(f,{get when(){return w(r.provider.id,r.cost)},get children(){return i($,{get children(){return a.t("model.tag.free")}})}}),null),s(t,i(f,{get when(){return D(r.provider.id)},get children(){return i($,{get children(){return a.t("model.tag.limited")}})}}),null),s(t,i(f,{get when(){return r.latest},get children(){return i($,{get children(){return a.t("model.tag.latest")}})}}),null),t})()})};function N(n){const[o,a]=I({open:!1,dismiss:null}),c=y(),r=e=>{a("dismiss",e),a("open",!1)},t=()=>{r("manage"),_(()=>import("./dialog-manage-models-BnaOhkF4.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>{c.show(()=>i(e.DialogManageModels,{}))})},u=()=>{r("provider"),_(()=>import("./dialog-select-provider-DjM-NV2S.js").then(e=>e.d),__vite__mapDeps([5,1,2,3,6])).then(e=>{c.show(()=>i(e.DialogSelectProvider,{}))})},d=x();return i(v,{get open(){return o.open},onOpenChange:e=>{e&&a("dismiss",null),a("open",e)},modal:!1,placement:"top-start",gutter:4,get children(){return[i(v.Trigger,T({get as(){return n.triggerAs??"div"}},()=>n.triggerProps,{get children(){return n.children}})),i(v.Portal,{get children(){return i(v.Content,{class:"w-72 h-80 flex flex-col p-2 rounded-md border border-border-base bg-surface-raised-stronger-non-alpha shadow-md z-50 outline-none overflow-hidden",onEscapeKeyDown:e=>{r("escape"),e.preventDefault(),e.stopPropagation()},onPointerDownOutside:()=>r("outside"),onFocusOutside:()=>r("outside"),onCloseAutoFocus:e=>{const l=o.dismiss;l==="outside"&&e.preventDefault(),(l==="escape"||l==="select")&&(e.preventDefault(),n.onClose?.(l)),a("dismiss",null)},get children(){return[i(v.Title,{class:"sr-only",get children(){return d.t("dialog.model.select.title")}}),i(M,{get provider(){return n.provider},get model(){return n.model},onSelect:()=>r("select"),class:"p-1",get action(){return(()=>{var e=R();return s(e,i(P,{placement:"top",get value(){return d.t("command.provider.connect")},get children(){return i(L,{icon:"plus-small",variant:"ghost",iconSize:"normal",class:"size-6",get"aria-label"(){return d.t("command.provider.connect")},onClick:u})}}),null),s(e,i(P,{placement:"top",get value(){return d.t("dialog.model.manage")},get children(){return i(L,{icon:"sliders",variant:"ghost",iconSize:"normal",class:"size-6",get"aria-label"(){return d.t("dialog.model.manage")},onClick:t})}}),null),e})()}})]}})}})]}})}const W=n=>{const o=y(),a=x(),c=()=>{_(()=>import("./dialog-select-provider-DjM-NV2S.js").then(t=>t.d),__vite__mapDeps([5,1,2,3,6])).then(t=>{o.show(()=>i(t.DialogSelectProvider,{}))})},r=()=>{_(()=>import("./dialog-manage-models-BnaOhkF4.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>{o.show(()=>i(t.DialogManageModels,{}))})};return i(E,{get title(){return a.t("dialog.model.select.title")},get action(){return i(C,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:c,get children(){return a.t("command.provider.connect")}})},get children(){return[i(M,{get provider(){return n.provider},get model(){return n.model},onSelect:()=>o.close()}),i(C,{variant:"ghost",class:"ml-3 mt-5 mb-6 text-text-base self-start",onClick:r,get children(){return a.t("dialog.model.manage")}})]}})};export{W as DialogSelectModel,N as ModelSelectorPopover};
@@ -0,0 +1 @@
1
+ import{d as Ee,u as Te,s as qe,a as Fe,m as Ue,i as o,t as D,b as xe,c as Pe,e as ze,f as be,g as Ke,o as je,h as j,j as Ae,k as ne,l as Be,n as t,P as ye,S as ee,M as P,p as me,q as ce,I as Ve,r as ge,v as ae,D as _e,T as q,B as W,w as Ge,x as ie,y as he,_ as He,z as Ze,F as $e,A as ke,C as ue,E as re,G as te}from"./index-DqutAOLe.js";import{L as fe}from"./list-Cnpbqmww.js";import{T as pe}from"./tag-B_xDskei.js";var Ne=D("<a>");function le(l){const I=Te(),[d,k]=qe(l,["href","children","class"]);return(()=>{var e=Ne();return e.$$click=g=>{d.href&&(g.preventDefault(),I.openLink(d.href))},Fe(e,Ue({get href(){return d.href},get class(){return`text-text-strong underline ${d.class??""}`}},k),!1,!0),o(e,()=>d.children),e})()}Ee(["click"]);var We=D('<div class="w-full flex flex-col gap-1.5"><div class="text-14-regular text-text-base"></div><div>'),Je=D('<form class="flex flex-col items-start gap-4">'),Qe=D('<div class="w-full flex items-center gap-x-2"><div class="w-4 h-2 rounded-[1px] bg-input-base shadow-xs-border-base flex items-center justify-center"><div class="w-2.5 h-0.5 ml-0 bg-icon-strong-base hidden"data-slot=list-item-extra-icon></div></div><span></span><span class="text-14-regular text-text-weak">'),Se=D('<div class="text-14-regular text-text-base">'),Xe=D("<div>"),Ye=D('<div class="w-full flex items-center gap-x-2"><div class="w-4 h-2 rounded-[1px] bg-input-base shadow-xs-border-base flex items-center justify-center"><div class="w-2.5 h-0.5 ml-0 bg-icon-strong-base hidden"data-slot=list-item-extra-icon></div></div><span>'),er=D('<div class="flex flex-col gap-4"><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base">'),rr=D('<div class="flex flex-col gap-6"><form class="flex flex-col items-start gap-4">'),tr=D('<div class="flex flex-col gap-6"><div class="text-14-regular text-text-base"></div><form class="flex flex-col items-start gap-4">'),or=D('<div class="flex flex-col gap-6"><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base flex items-center gap-4"><span>'),ve=D('<div class="text-14-regular text-text-base"><div class="flex items-center gap-x-2"><span>'),nr=D('<div class="flex flex-col gap-6 px-2.5 pb-3"><div class="px-2.5 flex gap-4 items-center"><div class="text-16-medium text-text-strong"></div></div><div class="px-2.5 pb-10 flex flex-col gap-6"><div tabindex=0>');function ir(l){const I=xe(),d=Pe(),k=ze(),e=be(),g=Ke(),w=()=>{He(()=>Promise.resolve().then(()=>vr),void 0).then(r=>{I.show(()=>t(r.DialogSelectProvider,{}))})},s={value:!0},u={current:void 0};je(()=>{s.value=!1,u.current!==void 0&&(clearTimeout(u.current),u.current=void 0)});const _=j(()=>g.all().find(r=>r.id===l.provider)??d.data.provider.all.find(r=>r.id===l.provider)),R=j(()=>[{type:"api",label:e.t("provider.connect.method.apiKey")}]),[A]=Ae(()=>l.provider,async()=>{const r=d.data.provider_auth[l.provider];if(r)return r;const n=await k.client.provider.auth();return s.value?(d.set("provider_auth",n.data??{}),n.data?.[l.provider]??R()):R()}),B=j(()=>A.loading&&!d.data.provider_auth[l.provider]),M=j(()=>A.latest??d.data.provider_auth[l.provider]??R()),[y,J]=ne({methodIndex:void 0,authorization:void 0,state:"pending",error:void 0});function C(r){J(ie(n=>{if(r.type==="method.select"){n.methodIndex=r.index,n.authorization=void 0,n.state=void 0,n.error=void 0;return}if(r.type==="method.reset"){n.methodIndex=void 0,n.authorization=void 0,n.state=void 0,n.error=void 0;return}if(r.type==="auth.prompt"){n.state="prompt",n.error=void 0;return}if(r.type==="auth.pending"){n.state="pending",n.error=void 0;return}if(r.type==="auth.complete"){n.state="complete",n.authorization=r.authorization,n.error=void 0;return}n.state="error",n.error=r.error}))}const F=j(()=>y.methodIndex!==void 0?M().at(y.methodIndex):void 0),a=r=>r?r.type==="api"?e.t("provider.connect.method.apiKey"):r.label??"":"";function c(r,n){if(r&&typeof r=="object"&&"data"in r){const i=r.data;if(typeof i?.message=="string"&&i.message)return i.message}if(r&&typeof r=="object"&&"error"in r){const i=c(r.error,"");if(i)return i}if(r&&typeof r=="object"&&"message"in r){const i=r.message;if(typeof i=="string"&&i)return i}return r instanceof Error&&r.message?r.message:typeof r=="string"&&r?r:n}async function $(r,n){u.current!==void 0&&(clearTimeout(u.current),u.current=void 0);const i=M()[r];if(C({type:"method.select",index:r}),i.type==="oauth"){if(i.prompts?.length&&!n){C({type:"auth.prompt"});return}C({type:"auth.pending"});const x=Date.now();await k.client.provider.oauth.authorize({providerID:l.provider,method:r,inputs:n},{throwOnError:!0}).then(v=>{if(!s.value)return;const b=1e3-(Date.now()-x);if(b>0){u.current!==void 0&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=void 0,s.value&&C({type:"auth.complete",authorization:v.data})},b);return}C({type:"auth.complete",authorization:v.data})}).catch(v=>{s.value&&C({type:"auth.error",error:c(v,e.t("common.requestFailed"))})})}}function H(){const[r,n]=ne({value:{},index:0}),i=j(()=>{const m=F();return m?.type!=="oauth"?[]:m.prompts??[]}),x=(m,S)=>{if(!m.when)return!0;const K=S[m.when.key];return K===void 0?!1:m.when.op==="eq"?K===m.when.value:K!==m.when.value},v=j(()=>{const m=i(),S=m.findIndex((K,Y)=>Y>=r.index&&x(K,r.value));if(S!==-1)return{index:S,prompt:m[S]}}),h=j(()=>{const m=v();return!m||m.prompt.type!=="text"?!1:(r.value[m.prompt.key]??"").trim().length>0});async function b(m,S){if(y.methodIndex===void 0)return;const K=i().findIndex((Y,T)=>T>m&&x(Y,S));if(K!==-1){n("index",K);return}await $(y.methodIndex,S)}async function E(m){m.preventDefault();const S=v();!S||S.prompt.type!=="text"||h()&&await b(S.index,r.value)}const z=()=>v(),Q=j(()=>{const m=z()?.prompt;if(!(!m||m.type!=="text"))return m}),X=j(()=>{const m=z()?.prompt;if(!(!m||m.type!=="select"))return m});return(()=>{var m=Je();return m.addEventListener("submit",E),o(m,t(ee,{get children(){return[t(P,{get when(){return z()?.prompt.type==="text"},get children(){return[t(q,{type:"text",get label(){return Q()?.message??""},get placeholder(){return Q()?.placeholder},get value(){return me(()=>!!Q())()?r.value[Q().key]??"":""},onChange:S=>{const K=Q();K&&n("value",K.key,S)}}),t(W,{class:"w-auto",type:"submit",size:"large",variant:"primary",get disabled(){return!h()},get children(){return e.t("common.continue")}})]}}),t(P,{get when(){return z()?.prompt.type==="select"},get children(){var S=We(),K=S.firstChild,Y=K.nextSibling;return o(K,()=>X()?.message),o(Y,t(fe,{get items(){return X()?.options??[]},key:T=>T.value,get current(){return X()?.options.find(T=>T.value===r.value[X().key])},onSelect:T=>{if(!T)return;const N=X();if(!N)return;const de={...r.value,[N.key]:T.value};n("value",N.key,T.value),b(z().index,de)},children:T=>(()=>{var N=Qe(),de=N.firstChild,we=de.nextSibling,Oe=we.nextSibling;return o(we,()=>T.label),o(Oe,()=>T.hint),N})()})),S}})]}})),m})()}let p;function L(r){r.key==="Enter"&&r.target instanceof HTMLInputElement||r.key!=="Escape"&&p?.onKeyDown(r)}let O=!1;Be(()=>{O||B()||M().length===1&&(O=!0,$(0))});async function V(){await k.client.global.dispose(),await d.reload(),I.close(),he({variant:"success",icon:"circle-check",title:e.t("provider.connect.toast.connected.title",{provider:_().name}),description:e.t("provider.connect.toast.connected.description",{provider:_().name})})}function Z(){if(M().length===1){w();return}if(y.authorization){C({type:"method.reset"});return}if(y.methodIndex!==void 0){C({type:"method.reset"});return}w()}function se(){return[(()=>{var r=Se();return o(r,()=>e.t("provider.connect.selectMethod",{provider:_().name})),r})(),(()=>{var r=Xe();return o(r,t(fe,{ref:n=>{p=n},items:M,key:n=>n?.label,onSelect:async(n,i)=>{n&&$(i)},children:n=>(()=>{var i=Ye(),x=i.firstChild,v=x.nextSibling;return o(v,()=>a(n)),i})()})),r})()]}function f(){const[r,n]=ne({value:"",error:void 0});async function i(x){x.preventDefault();const v=x.currentTarget,b=new FormData(v).get("apiKey");if(!b?.trim()){n("error",e.t("provider.connect.apiKey.required"));return}n("error",void 0),await k.client.auth.set({providerID:l.provider,auth:{type:"api",key:b}}),await V()}return(()=>{var x=rr(),v=x.firstChild;return o(x,t(ee,{get children(){return[t(P,{get when(){return _().id==="opencode"},get children(){var h=er(),b=h.firstChild,E=b.nextSibling,z=E.nextSibling;return o(b,()=>e.t("provider.connect.opencodeZen.line1")),o(E,()=>e.t("provider.connect.opencodeZen.line2")),o(z,()=>e.t("provider.connect.opencodeZen.visit.prefix"),null),o(z,t(le,{href:"https://opencode.ai/zen",tabIndex:-1,get children(){return e.t("provider.connect.opencodeZen.visit.link")}}),null),o(z,()=>e.t("provider.connect.opencodeZen.visit.suffix"),null),h}}),t(P,{when:!0,get children(){var h=Se();return o(h,()=>e.t("provider.connect.apiKey.description",{provider:_().name})),h}})]}}),v),v.addEventListener("submit",i),o(v,t(q,{autofocus:!0,type:"text",get label(){return e.t("provider.connect.apiKey.label",{provider:_().name})},get placeholder(){return e.t("provider.connect.apiKey.placeholder")},name:"apiKey",get value(){return r.value},onChange:h=>n("value",h),get validationState(){return r.error?"invalid":void 0},get error(){return r.error}}),null),o(v,t(W,{class:"w-auto",type:"submit",size:"large",variant:"primary",get children(){return e.t("common.continue")}}),null),x})()}function G(){const[r,n]=ne({value:"",error:void 0});async function i(x){x.preventDefault();const v=x.currentTarget,b=new FormData(v).get("code");if(!b?.trim()){n("error",e.t("provider.connect.oauth.code.required"));return}n("error",void 0);const E=await k.client.provider.oauth.callback({providerID:l.provider,method:y.methodIndex,code:b}).then(z=>z.error?{ok:!1,error:z.error}:{ok:!0}).catch(z=>({ok:!1,error:z}));if(E.ok){await V();return}n("error",c(E.error,e.t("provider.connect.oauth.code.invalid")))}return(()=>{var x=tr(),v=x.firstChild,h=v.nextSibling;return o(v,()=>e.t("provider.connect.oauth.code.visit.prefix"),null),o(v,t(le,{get href(){return y.authorization.url},get children(){return e.t("provider.connect.oauth.code.visit.link")}}),null),o(v,()=>e.t("provider.connect.oauth.code.visit.suffix",{provider:_().name}),null),h.addEventListener("submit",i),o(h,t(q,{autofocus:!0,type:"text",get label(){return e.t("provider.connect.oauth.code.label",{method:F()?.label??""})},get placeholder(){return e.t("provider.connect.oauth.code.placeholder")},name:"code",get value(){return r.value},onChange:b=>n("value",b),get validationState(){return r.error?"invalid":void 0},get error(){return r.error}}),null),o(h,t(W,{class:"w-auto",type:"submit",size:"large",variant:"primary",get children(){return e.t("common.continue")}}),null),x})()}function U(){const r=j(()=>{const n=y.authorization?.instructions;return n?.includes(":")?n.split(":")[1]?.trim():n});return Ge(()=>{(async()=>{const n=await k.client.provider.oauth.callback({providerID:l.provider,method:y.methodIndex}).then(i=>i.error?{ok:!1,error:i.error}:{ok:!0}).catch(i=>({ok:!1,error:i}));if(s.value){if(!n.ok){const i=c(n.error,e.t("common.requestFailed"));C({type:"auth.error",error:i});return}await V()}})()}),(()=>{var n=or(),i=n.firstChild,x=i.nextSibling,v=x.firstChild;return o(i,()=>e.t("provider.connect.oauth.auto.visit.prefix"),null),o(i,t(le,{get href(){return y.authorization.url},get children(){return e.t("provider.connect.oauth.auto.visit.link")}}),null),o(i,()=>e.t("provider.connect.oauth.auto.visit.suffix",{provider:_().name}),null),o(n,t(q,{get label(){return e.t("provider.connect.oauth.auto.confirmationCode")},class:"font-mono",get value(){return r()},readOnly:!0,copyable:!0}),x),o(x,t(ce,{}),v),o(v,()=>e.t("provider.connect.status.waiting")),n})()}return t(_e,{get title(){return t(ae,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:Z,get"aria-label"(){return e.t("common.goBack")}})},get children(){var r=nr(),n=r.firstChild,i=n.firstChild,x=n.nextSibling,v=x.firstChild;return o(n,t(ye,{get id(){return l.provider},class:"size-5 shrink-0 icon-strong-base"}),i),o(i,t(ee,{get children(){return[t(P,{get when(){return me(()=>l.provider==="anthropic")()&&F()?.label?.toLowerCase().includes("max")},get children(){return e.t("provider.connect.title.anthropicProMax")}}),t(P,{when:!0,get children(){return e.t("provider.connect.title",{provider:_().name})}})]}})),v.$$keydown=L,o(v,t(ee,{get children(){return[t(P,{get when(){return B()},get children(){var h=ve(),b=h.firstChild,E=b.firstChild;return o(b,t(ce,{}),E),o(E,()=>e.t("provider.connect.status.inProgress")),h}}),t(P,{get when(){return y.methodIndex===void 0},get children(){return t(se,{})}}),t(P,{get when(){return y.state==="pending"},get children(){var h=ve(),b=h.firstChild,E=b.firstChild;return o(b,t(ce,{}),E),o(E,()=>e.t("provider.connect.status.inProgress")),h}}),t(P,{get when(){return y.state==="prompt"},get children(){return t(H,{})}}),t(P,{get when(){return y.state==="error"},get children(){var h=ve(),b=h.firstChild,E=b.firstChild;return o(b,t(Ve,{name:"circle-ban-sign",class:"text-icon-critical-base"}),E),o(E,()=>e.t("provider.connect.status.failed",{error:y.error??""})),h}}),t(P,{get when(){return F()?.type==="api"},get children(){return t(f,{})}}),t(P,{get when(){return F()?.type==="oauth"},get children(){return t(ee,{get children(){return[t(P,{get when(){return y.authorization?.method==="code"},get children(){return t(G,{})}}),t(P,{get when(){return y.authorization?.method==="auto"},get children(){return t(U,{})}})]}})}})]}})),ge(()=>v.autofocus=y.methodIndex===void 0?!0:void 0),r}})}Ee(["keydown"]);const ar=/^[a-z0-9][a-z0-9-_]*$/,lr="@ai-sdk/openai-compatible";function sr(l){const I=l.form.providerID.trim(),d=l.form.name.trim(),k=l.form.baseURL.trim(),e=l.form.apiKey.trim(),g=e.match(/^\{env:([^}]+)\}$/)?.[1]?.trim(),w=e&&!g?e:void 0,s=I?ar.test(I)?void 0:l.t("provider.custom.error.providerID.format"):l.t("provider.custom.error.providerID.required"),u=d?void 0:l.t("provider.custom.error.name.required"),_=k?/^https?:\/\//.test(k)?void 0:l.t("provider.custom.error.baseURL.format"):l.t("provider.custom.error.baseURL.required"),R=l.disabledProviders.includes(I),A=s?void 0:l.existingProviderIDs.has(I)&&!R?l.t("provider.custom.error.providerID.exists"):void 0,B=new Set,M=l.form.models.map(p=>{const L=p.id.trim(),O=L?B.has(L)?l.t("provider.custom.error.duplicate"):(()=>{B.add(L)})():l.t("provider.custom.error.required"),V=p.name.trim()?void 0:l.t("provider.custom.error.required");return{id:O,name:V}}),y=M.every(p=>!p.id&&!p.name),J=Object.fromEntries(l.form.models.map(p=>[p.id.trim(),{name:p.name.trim()}])),C=new Set,F=l.form.headers.map(p=>{const L=p.key.trim(),O=p.value.trim();if(!L&&!O)return{};const V=L?C.has(L.toLowerCase())?l.t("provider.custom.error.duplicate"):(()=>{C.add(L.toLowerCase())})():l.t("provider.custom.error.required"),Z=O?void 0:l.t("provider.custom.error.required");return{key:V,value:Z}}),a=F.every(p=>!p.key&&!p.value),c=Object.fromEntries(l.form.headers.map(p=>({key:p.key.trim(),value:p.value.trim()})).filter(p=>!!p.key&&!!p.value).map(p=>[p.key,p.value])),$={providerID:s??A,name:u,baseURL:_};return!s&&!A&&!u&&!_&&y&&a?{err:$,models:M,headers:F,result:{providerID:I,name:d,key:w,config:{npm:lr,name:d,...g?{env:[g]}:{},options:{baseURL:k,...Object.keys(c).length?{headers:c}:{}},models:J}}}:{err:$,models:M,headers:F}}let dr=0;const Re=()=>`row-${dr++}`,Ce=()=>({row:Re(),id:"",name:"",err:{}}),De=()=>({row:Re(),key:"",value:"",err:{}});var cr=D('<div class="flex flex-col gap-6 px-2.5 pb-3 overflow-y-auto max-h-[60vh]"><div class="px-2.5 flex gap-4 items-center"><div class="text-16-medium text-text-strong"></div></div><form class="px-2.5 pb-6 flex flex-col gap-6"><p class="text-14-regular text-text-base"></p><div class="flex flex-col gap-4"></div><div class="flex flex-col gap-3"><label class="text-12-medium text-text-weak"></label></div><div class="flex flex-col gap-3"><label class="text-12-medium text-text-weak">'),Ie=D('<div class="flex gap-2 items-start"><div class=flex-1></div><div class=flex-1>');function ur(l){const I=xe(),d=Pe(),k=ze(),e=be(),[g,w]=ne({providerID:"",name:"",baseURL:"",apiKey:"",models:[Ce()],headers:[De()],err:{}}),s=()=>{if(l.back==="close"){I.close();return}I.show(()=>t(Me,{}))},u=()=>{w("models",ie(a=>{a.push(Ce())}))},_=a=>{g.models.length<=1||w("models",ie(c=>{c.splice(a,1)}))},R=()=>{w("headers",ie(a=>{a.push(De())}))},A=a=>{g.headers.length<=1||w("headers",ie(c=>{c.splice(a,1)}))},B=(a,c)=>{w(a,c),a!=="apiKey"&&w("err",a,void 0)},M=(a,c,$)=>{ue(()=>{w("models",a,c,$),w("models",a,"err",c,void 0)})},y=(a,c,$)=>{ue(()=>{w("headers",a,c,$),w("headers",a,"err",c,void 0)})},J=()=>{const a=sr({form:g,t:e.t,disabledProviders:d.data.config.disabled_providers??[],existingProviderIDs:new Set(d.data.provider.all.map(c=>c.id))});return ue(()=>{w("err",a.err),a.models.forEach((c,$)=>w("models",$,"err",c)),a.headers.forEach((c,$)=>w("headers",$,"err",c))}),a.result},C=Ze(()=>({mutationFn:async a=>{const $=(d.data.config.disabled_providers??[]).filter(H=>H!==a.providerID);return a.key&&await k.client.auth.set({providerID:a.providerID,auth:{type:"api",key:a.key}}),await d.updateConfig({provider:{[a.providerID]:a.config},disabled_providers:$}),await k.client.global.dispose(),await d.reload(),a},onSuccess:a=>{I.close(),he({variant:"success",icon:"circle-check",title:e.t("provider.connect.toast.connected.title",{provider:a.name}),description:e.t("provider.connect.toast.connected.description",{provider:a.name})})},onError:a=>{const c=a instanceof Error?a.message:String(a);he({title:e.t("common.requestFailed"),description:c})}})),F=a=>{if(a.preventDefault(),C.isPending)return;const c=J();c&&C.mutate(c)};return t(_e,{get title(){return t(ae,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:s,get"aria-label"(){return e.t("common.goBack")}})},transition:!0,get children(){var a=cr(),c=a.firstChild,$=c.firstChild,H=c.nextSibling,p=H.firstChild,L=p.nextSibling,O=L.nextSibling,V=O.firstChild,Z=O.nextSibling,se=Z.firstChild;return o(c,t(ye,{id:"synthetic",class:"size-5 shrink-0 icon-strong-base"}),$),o($,()=>e.t("provider.custom.title")),H.addEventListener("submit",F),o(p,()=>e.t("provider.custom.description.prefix"),null),o(p,t(le,{href:"https://opencode.ai/docs/providers/#custom-provider",tabIndex:-1,get children(){return e.t("provider.custom.description.link")}}),null),o(p,()=>e.t("provider.custom.description.suffix"),null),o(L,t(q,{autofocus:!0,get label(){return e.t("provider.custom.field.providerID.label")},get placeholder(){return e.t("provider.custom.field.providerID.placeholder")},get description(){return e.t("provider.custom.field.providerID.description")},get value(){return g.providerID},onChange:f=>B("providerID",f),get validationState(){return g.err.providerID?"invalid":void 0},get error(){return g.err.providerID}}),null),o(L,t(q,{get label(){return e.t("provider.custom.field.name.label")},get placeholder(){return e.t("provider.custom.field.name.placeholder")},get value(){return g.name},onChange:f=>B("name",f),get validationState(){return g.err.name?"invalid":void 0},get error(){return g.err.name}}),null),o(L,t(q,{get label(){return e.t("provider.custom.field.baseURL.label")},get placeholder(){return e.t("provider.custom.field.baseURL.placeholder")},get value(){return g.baseURL},onChange:f=>B("baseURL",f),get validationState(){return g.err.baseURL?"invalid":void 0},get error(){return g.err.baseURL}}),null),o(L,t(q,{get label(){return e.t("provider.custom.field.apiKey.label")},get placeholder(){return e.t("provider.custom.field.apiKey.placeholder")},get description(){return e.t("provider.custom.field.apiKey.description")},get value(){return g.apiKey},onChange:f=>B("apiKey",f)}),null),o(V,()=>e.t("provider.custom.models.label")),o(O,t($e,{get each(){return g.models},children:(f,G)=>(()=>{var U=Ie(),r=U.firstChild,n=r.nextSibling;return o(r,t(q,{get label(){return e.t("provider.custom.models.id.label")},hideLabel:!0,get placeholder(){return e.t("provider.custom.models.id.placeholder")},get value(){return f.id},onChange:i=>M(G(),"id",i),get validationState(){return f.err.id?"invalid":void 0},get error(){return f.err.id}})),o(n,t(q,{get label(){return e.t("provider.custom.models.name.label")},hideLabel:!0,get placeholder(){return e.t("provider.custom.models.name.placeholder")},get value(){return f.name},onChange:i=>M(G(),"name",i),get validationState(){return f.err.name?"invalid":void 0},get error(){return f.err.name}})),o(U,t(ae,{type:"button",icon:"trash",variant:"ghost",class:"mt-1.5",onClick:()=>_(G()),get disabled(){return g.models.length<=1},get"aria-label"(){return e.t("provider.custom.models.remove")}}),null),ge(()=>ke(U,"data-row",f.row)),U})()}),null),o(O,t(W,{type:"button",size:"small",variant:"ghost",icon:"plus-small",onClick:u,class:"self-start",get children(){return e.t("provider.custom.models.add")}}),null),o(se,()=>e.t("provider.custom.headers.label")),o(Z,t($e,{get each(){return g.headers},children:(f,G)=>(()=>{var U=Ie(),r=U.firstChild,n=r.nextSibling;return o(r,t(q,{get label(){return e.t("provider.custom.headers.key.label")},hideLabel:!0,get placeholder(){return e.t("provider.custom.headers.key.placeholder")},get value(){return f.key},onChange:i=>y(G(),"key",i),get validationState(){return f.err.key?"invalid":void 0},get error(){return f.err.key}})),o(n,t(q,{get label(){return e.t("provider.custom.headers.value.label")},hideLabel:!0,get placeholder(){return e.t("provider.custom.headers.value.placeholder")},get value(){return f.value},onChange:i=>y(G(),"value",i),get validationState(){return f.err.value?"invalid":void 0},get error(){return f.err.value}})),o(U,t(ae,{type:"button",icon:"trash",variant:"ghost",class:"mt-1.5",onClick:()=>A(G()),get disabled(){return g.headers.length<=1},get"aria-label"(){return e.t("provider.custom.headers.remove")}}),null),ge(()=>ke(U,"data-row",f.row)),U})()}),null),o(Z,t(W,{type:"button",size:"small",variant:"ghost",icon:"plus-small",onClick:R,class:"self-start",get children(){return e.t("provider.custom.headers.add")}}),null),o(H,t(W,{class:"w-auto self-start",type:"submit",size:"large",variant:"primary",get disabled(){return C.isPending},get children(){return me(()=>!!C.isPending)()?e.t("common.saving"):e.t("common.submit")}}),null),a}})}var Le=D('<div class="text-14-regular text-text-weak">'),pr=D('<div class="px-1.25 w-full flex items-center gap-x-3"><span>');const oe="_custom",Me=()=>{const l=xe(),I=Ke(),d=be(),k=()=>d.t("dialog.provider.group.popular"),e=()=>d.t("dialog.provider.group.other"),g=()=>d.t("settings.providers.tag.custom"),w=s=>{if(s==="anthropic")return d.t("dialog.provider.anthropic.note");if(s==="openai")return d.t("dialog.provider.openai.note");if(s.startsWith("github-copilot"))return d.t("dialog.provider.copilot.note");if(s==="opencode-go")return d.t("dialog.provider.opencodeGo.tagline")};return t(_e,{get title(){return d.t("command.provider.connect")},transition:!0,get children(){return t(fe,{get search(){return{placeholder:d.t("dialog.provider.search.placeholder"),autofocus:!0}},get emptyMessage(){return d.t("dialog.provider.empty")},activeIcon:"plus-small",key:s=>s?.id,items:()=>(d.locale(),[{id:oe,name:g()},...I.all()]),filterKeys:["id","name"],groupBy:s=>te.includes(s.id)?k():e(),sortBy:(s,u)=>s.id===oe?-1:u.id===oe?1:te.includes(s.id)&&te.includes(u.id)?te.indexOf(s.id)-te.indexOf(u.id):s.name.localeCompare(u.name),sortGroupsBy:(s,u)=>{const _=k();return s.category===_&&u.category!==_?-1:u.category===_&&s.category!==_?1:0},onSelect:s=>{if(s){if(s.id===oe){l.show(()=>t(ur,{back:"providers"}));return}l.show(()=>t(ir,{get provider(){return s.id}}))}},children:s=>(()=>{var u=pr(),_=u.firstChild;return o(u,t(ye,{"data-slot":"list-item-extra-icon",get id(){return s.id}}),_),o(_,()=>s.name),o(u,t(re,{get when(){return s.id==="opencode"},get children(){var R=Le();return o(R,()=>d.t("dialog.provider.opencode.tagline")),R}}),null),o(u,t(re,{get when(){return s.id===oe},get children(){return t(pe,{get children(){return d.t("settings.providers.tag.custom")}})}}),null),o(u,t(re,{get when(){return s.id==="opencode"},get children(){return t(pe,{get children(){return d.t("dialog.provider.tag.recommended")}})}}),null),o(u,t(re,{get when(){return w(s.id)},children:R=>(()=>{var A=Le();return o(A,R),A})()}),null),o(u,t(re,{get when(){return s.id==="opencode-go"},get children(){return t(pe,{get children(){return d.t("dialog.provider.tag.recommended")}})}}),null),u})()})}})},vr=Object.freeze(Object.defineProperty({__proto__:null,DialogSelectProvider:Me},Symbol.toStringTag,{value:"Module"}));export{ir as D,le as L,ur as a,Me as b,vr as d};
@@ -1 +1 @@
1
- import{Q as he,b as me,R as fe,u as O,f as K,U as Z,k as pe,z as Q,V as z,W as f,h as x,l as X,o as Se,i as m,n,v as Y,p as w,E as $,I as we,X as S,B as G,D as ye,j as ke,Y as be,t as A,T as N,y as xe}from"./index-t6AoWpnz.js";import{L as Ce}from"./list-DsM_Q7VB.js";import{S as _e,a as De}from"./server-row-C7_f8oim.js";var Pe=A('<div class=px-5><div class="bg-surface-base rounded-md p-5 flex flex-col gap-3"><div class="flex-1 min-w-0 [&amp;_[data-slot=input-wrapper]]:relative"></div><p class="text-12-regular text-text-weak leading-snug">'),$e=A('<div class="flex items-center gap-2 -ml-2"><span>'),Ie=A('<p class="px-5 text-13-regular text-text-weak">'),Ee=A('<div class="flex flex-1 min-h-0 flex-col gap-2"><div class="shrink-0 px-5 pb-5">'),Ae=A('<div class="flex items-center gap-3 min-w-0 flex-1 w-full group/item"><div class="flex flex-col h-full items-start w-5"></div><div class="flex items-center justify-center gap-4 pl-4">'),Fe=A('<span class="text-text-base bg-surface-base text-14-regular px-1.5 rounded-xs">');const R="";function J(i,l){xe({variant:"error",title:i.t("common.requestFailed"),description:l instanceof Error?l.message:String(l)})}function Me(){const i=K(),l=O(),[c,u]=ke(async()=>{try{const h=await l.getDefaultServer?.();return h||null}catch(h){return J(i,h),null}},{initialValue:null}),s=x(()=>!!l.getDefaultServer&&!!l.setDefaultServer);return{defaultKey:c,canDefault:s,setDefault:async h=>{try{await l.setDefaultServer?.(h),u.mutate(h)}catch(C){J(i,C)}}}}function Ne(){const i=Z(),l=u=>{const s=z(u);if(!s)return!1;const v=s.replace(/^https?:\/\//,"").split("/")[0];return v?v.includes("localhost")||v.startsWith("127.0.0.1")?!0:v.includes(".")||v.includes(":"):!1};return{previewStatus:async(u,s,v,h)=>{if(h(void 0),!l(u))return;const C=z(u);if(!C)return;const y={url:C};s&&(y.username=s),v&&(y.password=v);const F=await i(y);h(F.healthy)}}}function ze(i){const l=K(),c=u=>{if(u.stopPropagation(),u.key==="Escape"){u.preventDefault(),i.onBack();return}u.key!=="Enter"||u.isComposing||(u.preventDefault(),i.onSubmit())};return(()=>{var u=Pe(),s=u.firstChild,v=s.firstChild,h=v.nextSibling;return m(v,n(N,{type:"text",get label(){return l.t("dialog.server.add.url")},get placeholder(){return i.placeholder},get value(){return i.value},autofocus:!0,get validationState(){return i.error?"invalid":"valid"},get error(){return i.error},get disabled(){return i.busy},get onChange(){return i.onChange},onKeyDown:c})),m(s,n(N,{type:"text",get label(){return l.t("dialog.server.add.name")},get placeholder(){return l.t("dialog.server.add.namePlaceholder")},get value(){return i.name},get disabled(){return i.busy},get onChange(){return i.onNameChange},onKeyDown:c}),h),m(h,()=>l.t("dialog.server.add.auth.hint")),m(s,n(N,{type:"password",get label(){return l.t("dialog.server.add.password")},get placeholder(){return l.t("dialog.server.add.passwordPlaceholder")},get value(){return i.password},get disabled(){return i.busy},get onChange(){return i.onPasswordChange},onKeyDown:c}),null),m(s,n(N,{type:"text",get label(){return l.t("dialog.server.add.username")},get placeholder(){return l.t("dialog.server.add.usernamePlaceholder")},get value(){return i.username},get disabled(){return i.busy},get onChange(){return i.onUsernameChange},onKeyDown:c}),null),u})()}function Re(){const i=he(),l=me(),c=fe(),u=O(),s=K(),{defaultKey:v,canDefault:h,setDefault:C}=Me(),{previewStatus:y}=Ne(),F=Z(),[r,d]=pe({status:{},addServer:{url:"",name:"",username:R,password:"",error:"",showForm:!1,status:void 0},editServer:{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0}}),M=()=>{d("addServer",{url:"",name:"",username:R,password:"",error:"",showForm:!1,status:void 0})},I=()=>{d("editServer",{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0})},_=Q(()=>({mutationFn:async e=>{const t=z(e);if(!t){M();return}const a={type:"http",http:{url:t}};if(r.addServer.name.trim()&&(a.displayName=r.addServer.name.trim()),r.addServer.password&&(a.http.password=r.addServer.password),r.addServer.password&&r.addServer.username&&(a.http.username=r.addServer.username),!(await F(a.http)).healthy){d("addServer",{error:s.t("dialog.server.add.error")});return}M(),await q(a,!0)}})),D=Q(()=>({mutationFn:async e=>{if(e.original.type!=="http")return;const t=z(e.value);if(!t){I();return}const a=r.editServer.name.trim()||void 0,g=r.editServer.username||void 0,o=r.editServer.password||void 0,k=e.original.displayName;if(t===e.original.http.url&&a===k&&g===e.original.http.username&&o===e.original.http.password){I();return}const b={type:"http",displayName:a,http:{url:t,username:g,password:o}};if(!(await F(b.http)).healthy){d("editServer",{error:s.t("dialog.server.add.error")});return}t===e.original.http.url?c.add(b):ee(e.original,b),I()}})),ee=(e,t)=>{const a=c.key,g=c.add(t);if(!g)return;const o=a===f.key(e)?f.key(g):a;o&&c.setActive(o),c.remove(f.key(e))},E=x(()=>{const e=c.current,t=c.list;return e?t.includes(e)?[e,...t.filter(a=>a!==e)]:[e,...t]:t}),T=x(()=>E().find(e=>f.key(e)===c.key)??E()[0]),re=x(()=>{const e=E().filter(o=>o.type==="http"||o.type==="sidecar");if(!e.length)return e;const t=T(),a=new Map(e.map((o,k)=>[o,k])),g=o=>o?.healthy===!0?0:o?.healthy===!1?2:1;return e.slice().sort((o,k)=>{if(o===t)return-1;if(k===t)return 1;const b=g(r.status[f.key(o)])-g(r.status[f.key(k)]);return b!==0?b:(a.get(o)??0)-(a.get(k)??0)})});async function H(){const e={};await Promise.all(E().map(async t=>{e[f.key(t)]=await F(t.http)})),d("status",be(e))}X(()=>{E(),H();const e=setInterval(H,1e4);Se(()=>clearInterval(e))});async function q(e,t){if(!(!t&&r.status[f.key(e)]?.healthy===!1)){if(l.close(),t&&e.type==="http"){c.add(e),i("/");return}i("/"),queueMicrotask(()=>c.setActive(f.key(e)))}}const te=e=>{_.isPending||(d("addServer",{url:e,error:""}),y(e,r.addServer.username,r.addServer.password,t=>d("addServer",{status:t})))},ae=e=>{_.isPending||d("addServer",{name:e,error:""})},ne=e=>{_.isPending||(d("addServer",{username:e,error:""}),y(r.addServer.url,e,r.addServer.password,t=>d("addServer",{status:t})))},se=e=>{_.isPending||(d("addServer",{password:e,error:""}),y(r.addServer.url,r.addServer.username,e,t=>d("addServer",{status:t})))},ie=e=>{D.isPending||(d("editServer",{value:e,error:""}),y(e,r.editServer.username,r.editServer.password,t=>d("editServer",{status:t})))},de=e=>{D.isPending||d("editServer",{name:e,error:""})},le=e=>{D.isPending||(d("editServer",{username:e,error:""}),y(r.editServer.value,e,r.editServer.password,t=>d("editServer",{status:t})))},oe=e=>{D.isPending||(d("editServer",{password:e,error:""}),y(r.editServer.value,r.editServer.username,e,t=>d("editServer",{status:t})))},U=x(()=>r.editServer.id?"edit":r.addServer.showForm?"add":"list"),j=x(()=>{if(r.editServer.id)return E().find(e=>e.type==="http"&&e.http.url===r.editServer.id)}),V=()=>{M(),I()},ue=()=>{I(),d("addServer",{showForm:!0,url:"",name:"",username:R,password:"",error:"",status:void 0})},ce=e=>{M(),d("editServer",{id:e.http.url,value:e.http.url,name:e.displayName??"",username:e.http.username??"",password:e.http.password??"",error:"",status:r.status[f.key(e)]?.healthy})},W=()=>{if(U()==="add"){if(_.isPending)return;d("addServer",{error:""}),_.mutate(r.addServer.url);return}const e=j();e&&(D.isPending||(d("editServer",{error:""}),D.mutate({original:e,value:r.editServer.value})))},L=x(()=>U()!=="list"),p=x(()=>U()==="add"),B=x(()=>p()?_.isPending:D.isPending),ge=x(()=>L()?(()=>{var e=$e(),t=e.firstChild;return m(e,n(Y,{icon:"arrow-left",variant:"ghost",onClick:V,get"aria-label"(){return s.t("common.goBack")}}),t),m(t,(()=>{var a=w(()=>!!p());return()=>a()?s.t("dialog.server.add.title"):s.t("dialog.server.edit.title")})()),e})():s.t("dialog.server.title"));X(()=>{r.editServer.id&&(j()||I())});async function ve(e){await u.sshDisconnect?.(e),c.remove(e),await u.getDefaultServer?.()===e&&u.setDefaultServer?.(null)}return n(ye,{get title(){return ge()},get children(){var e=Ee(),t=e.firstChild;return m(e,n($,{get when(){return!L()},get fallback(){return n(ze,{get value(){return w(()=>!!p())()?r.addServer.url:r.editServer.value},get name(){return w(()=>!!p())()?r.addServer.name:r.editServer.name},get username(){return w(()=>!!p())()?r.addServer.username:r.editServer.username},get password(){return w(()=>!!p())()?r.addServer.password:r.editServer.password},get placeholder(){return s.t("dialog.server.add.placeholder")},get busy(){return B()},get error(){return w(()=>!!p())()?r.addServer.error:r.editServer.error},get status(){return w(()=>!!p())()?r.addServer.status:r.editServer.status},get onChange(){return p()?te:ie},get onNameChange(){return p()?ae:de},get onUsernameChange(){return p()?ne:le},get onPasswordChange(){return p()?se:oe},onSubmit:W,onBack:V})},get children(){return[(()=>{var a=Ie();return m(a,()=>s.t("dialog.server.description")),a})(),n(Ce,{get search(){return{placeholder:s.t("dialog.server.search.placeholder"),autofocus:!1}},noInitialSelection:!0,get emptyMessage(){return s.t("dialog.server.empty")},items:re,key:a=>a.http.url,onSelect:a=>{a&&q(a)},divider:!0,class:"flex-1 min-h-0 px-5 [&_[data-slot=list-search-wrapper]]:w-full [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:overflow-y-auto [&_[data-slot=list-items]]:bg-surface-base [&_[data-slot=list-items]]:rounded-md [&_[data-slot=list-item]]:min-h-14 [&_[data-slot=list-item]]:p-3 [&_[data-slot=list-item]]:!bg-transparent",children:a=>{const g=f.key(a);return(()=>{var o=Ae(),k=o.firstChild,b=k.nextSibling;return m(k,n(_e,{get health(){return r.status[g]}})),m(o,n(De,{conn:a,get dimmed(){return r.status[g]?.healthy===!1},get status(){return r.status[g]},class:"flex items-center gap-3 min-w-0 flex-1",get badge(){return n($,{get when(){return v()===f.key(a)},get children(){var P=Fe();return m(P,()=>s.t("dialog.server.status.default")),P}})},showCredentials:!0}),b),m(b,n($,{get when(){return f.key(T())===g},get children(){return n(we,{name:"check",class:"h-6"})}}),null),m(b,n($,{get when(){return a.type==="http"},get children(){return n(S,{get children(){return[n(S.Trigger,{as:Y,icon:"dot-grid",variant:"ghost",class:"shrink-0 size-8 hover:bg-surface-base-hover data-[expanded]:bg-surface-base-active",onClick:P=>P.stopPropagation(),onPointerDown:P=>P.stopPropagation()}),n(S.Portal,{get children(){return n(S.Content,{class:"mt-1",get children(){return[n(S.Item,{onSelect:()=>{a.type==="http"&&ce(a)},get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.edit")}})}}),n($,{get when(){return w(()=>!!h())()&&v()!==g},get children(){return n(S.Item,{onSelect:()=>C(g),get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.default")}})}})}}),n($,{get when(){return w(()=>!!h())()&&v()===g},get children(){return n(S.Item,{onSelect:()=>C(null),get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.defaultRemove")}})}})}}),n(S.Separator,{}),n(S.Item,{onSelect:()=>ve(f.key(a)),class:"text-text-on-critical-base hover:bg-surface-critical-weak",get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.delete")}})}})]}})}})]}})}}),null),o})()}})]}}),t),m(t,n($,{get when(){return L()},get fallback(){return n(G,{variant:"secondary",icon:"plus-small",size:"large",onClick:ue,class:"py-1.5 pl-1.5 pr-3 flex items-center gap-1.5",get children(){return s.t("dialog.server.add.button")}})},get children(){return n(G,{variant:"primary",size:"large",onClick:W,get disabled(){return B()},class:"px-3 py-1.5",get children(){return w(()=>!!B())()?s.t("dialog.server.add.checking"):w(()=>!!p())()?s.t("dialog.server.add.button"):s.t("common.save")}})}})),e}})}export{Re as DialogSelectServer};
1
+ import{Q as he,b as me,R as fe,u as O,f as K,U as Z,k as pe,z as Q,V as z,W as f,h as x,l as X,o as Se,i as m,n,v as Y,p as w,E as $,I as we,X as S,B as G,D as ye,j as ke,Y as be,t as A,T as N,y as xe}from"./index-DqutAOLe.js";import{L as Ce}from"./list-Cnpbqmww.js";import{S as _e,a as De}from"./server-row-CsHpppFM.js";var Pe=A('<div class=px-5><div class="bg-surface-base rounded-md p-5 flex flex-col gap-3"><div class="flex-1 min-w-0 [&amp;_[data-slot=input-wrapper]]:relative"></div><p class="text-12-regular text-text-weak leading-snug">'),$e=A('<div class="flex items-center gap-2 -ml-2"><span>'),Ie=A('<p class="px-5 text-13-regular text-text-weak">'),Ee=A('<div class="flex flex-1 min-h-0 flex-col gap-2"><div class="shrink-0 px-5 pb-5">'),Ae=A('<div class="flex items-center gap-3 min-w-0 flex-1 w-full group/item"><div class="flex flex-col h-full items-start w-5"></div><div class="flex items-center justify-center gap-4 pl-4">'),Fe=A('<span class="text-text-base bg-surface-base text-14-regular px-1.5 rounded-xs">');const R="";function J(i,l){xe({variant:"error",title:i.t("common.requestFailed"),description:l instanceof Error?l.message:String(l)})}function Me(){const i=K(),l=O(),[c,u]=ke(async()=>{try{const h=await l.getDefaultServer?.();return h||null}catch(h){return J(i,h),null}},{initialValue:null}),s=x(()=>!!l.getDefaultServer&&!!l.setDefaultServer);return{defaultKey:c,canDefault:s,setDefault:async h=>{try{await l.setDefaultServer?.(h),u.mutate(h)}catch(C){J(i,C)}}}}function Ne(){const i=Z(),l=u=>{const s=z(u);if(!s)return!1;const v=s.replace(/^https?:\/\//,"").split("/")[0];return v?v.includes("localhost")||v.startsWith("127.0.0.1")?!0:v.includes(".")||v.includes(":"):!1};return{previewStatus:async(u,s,v,h)=>{if(h(void 0),!l(u))return;const C=z(u);if(!C)return;const y={url:C};s&&(y.username=s),v&&(y.password=v);const F=await i(y);h(F.healthy)}}}function ze(i){const l=K(),c=u=>{if(u.stopPropagation(),u.key==="Escape"){u.preventDefault(),i.onBack();return}u.key!=="Enter"||u.isComposing||(u.preventDefault(),i.onSubmit())};return(()=>{var u=Pe(),s=u.firstChild,v=s.firstChild,h=v.nextSibling;return m(v,n(N,{type:"text",get label(){return l.t("dialog.server.add.url")},get placeholder(){return i.placeholder},get value(){return i.value},autofocus:!0,get validationState(){return i.error?"invalid":"valid"},get error(){return i.error},get disabled(){return i.busy},get onChange(){return i.onChange},onKeyDown:c})),m(s,n(N,{type:"text",get label(){return l.t("dialog.server.add.name")},get placeholder(){return l.t("dialog.server.add.namePlaceholder")},get value(){return i.name},get disabled(){return i.busy},get onChange(){return i.onNameChange},onKeyDown:c}),h),m(h,()=>l.t("dialog.server.add.auth.hint")),m(s,n(N,{type:"password",get label(){return l.t("dialog.server.add.password")},get placeholder(){return l.t("dialog.server.add.passwordPlaceholder")},get value(){return i.password},get disabled(){return i.busy},get onChange(){return i.onPasswordChange},onKeyDown:c}),null),m(s,n(N,{type:"text",get label(){return l.t("dialog.server.add.username")},get placeholder(){return l.t("dialog.server.add.usernamePlaceholder")},get value(){return i.username},get disabled(){return i.busy},get onChange(){return i.onUsernameChange},onKeyDown:c}),null),u})()}function Re(){const i=he(),l=me(),c=fe(),u=O(),s=K(),{defaultKey:v,canDefault:h,setDefault:C}=Me(),{previewStatus:y}=Ne(),F=Z(),[r,d]=pe({status:{},addServer:{url:"",name:"",username:R,password:"",error:"",showForm:!1,status:void 0},editServer:{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0}}),M=()=>{d("addServer",{url:"",name:"",username:R,password:"",error:"",showForm:!1,status:void 0})},I=()=>{d("editServer",{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0})},_=Q(()=>({mutationFn:async e=>{const t=z(e);if(!t){M();return}const a={type:"http",http:{url:t}};if(r.addServer.name.trim()&&(a.displayName=r.addServer.name.trim()),r.addServer.password&&(a.http.password=r.addServer.password),r.addServer.password&&r.addServer.username&&(a.http.username=r.addServer.username),!(await F(a.http)).healthy){d("addServer",{error:s.t("dialog.server.add.error")});return}M(),await q(a,!0)}})),D=Q(()=>({mutationFn:async e=>{if(e.original.type!=="http")return;const t=z(e.value);if(!t){I();return}const a=r.editServer.name.trim()||void 0,g=r.editServer.username||void 0,o=r.editServer.password||void 0,k=e.original.displayName;if(t===e.original.http.url&&a===k&&g===e.original.http.username&&o===e.original.http.password){I();return}const b={type:"http",displayName:a,http:{url:t,username:g,password:o}};if(!(await F(b.http)).healthy){d("editServer",{error:s.t("dialog.server.add.error")});return}t===e.original.http.url?c.add(b):ee(e.original,b),I()}})),ee=(e,t)=>{const a=c.key,g=c.add(t);if(!g)return;const o=a===f.key(e)?f.key(g):a;o&&c.setActive(o),c.remove(f.key(e))},E=x(()=>{const e=c.current,t=c.list;return e?t.includes(e)?[e,...t.filter(a=>a!==e)]:[e,...t]:t}),T=x(()=>E().find(e=>f.key(e)===c.key)??E()[0]),re=x(()=>{const e=E().filter(o=>o.type==="http"||o.type==="sidecar");if(!e.length)return e;const t=T(),a=new Map(e.map((o,k)=>[o,k])),g=o=>o?.healthy===!0?0:o?.healthy===!1?2:1;return e.slice().sort((o,k)=>{if(o===t)return-1;if(k===t)return 1;const b=g(r.status[f.key(o)])-g(r.status[f.key(k)]);return b!==0?b:(a.get(o)??0)-(a.get(k)??0)})});async function H(){const e={};await Promise.all(E().map(async t=>{e[f.key(t)]=await F(t.http)})),d("status",be(e))}X(()=>{E(),H();const e=setInterval(H,1e4);Se(()=>clearInterval(e))});async function q(e,t){if(!(!t&&r.status[f.key(e)]?.healthy===!1)){if(l.close(),t&&e.type==="http"){c.add(e),i("/");return}i("/"),queueMicrotask(()=>c.setActive(f.key(e)))}}const te=e=>{_.isPending||(d("addServer",{url:e,error:""}),y(e,r.addServer.username,r.addServer.password,t=>d("addServer",{status:t})))},ae=e=>{_.isPending||d("addServer",{name:e,error:""})},ne=e=>{_.isPending||(d("addServer",{username:e,error:""}),y(r.addServer.url,e,r.addServer.password,t=>d("addServer",{status:t})))},se=e=>{_.isPending||(d("addServer",{password:e,error:""}),y(r.addServer.url,r.addServer.username,e,t=>d("addServer",{status:t})))},ie=e=>{D.isPending||(d("editServer",{value:e,error:""}),y(e,r.editServer.username,r.editServer.password,t=>d("editServer",{status:t})))},de=e=>{D.isPending||d("editServer",{name:e,error:""})},le=e=>{D.isPending||(d("editServer",{username:e,error:""}),y(r.editServer.value,e,r.editServer.password,t=>d("editServer",{status:t})))},oe=e=>{D.isPending||(d("editServer",{password:e,error:""}),y(r.editServer.value,r.editServer.username,e,t=>d("editServer",{status:t})))},U=x(()=>r.editServer.id?"edit":r.addServer.showForm?"add":"list"),j=x(()=>{if(r.editServer.id)return E().find(e=>e.type==="http"&&e.http.url===r.editServer.id)}),V=()=>{M(),I()},ue=()=>{I(),d("addServer",{showForm:!0,url:"",name:"",username:R,password:"",error:"",status:void 0})},ce=e=>{M(),d("editServer",{id:e.http.url,value:e.http.url,name:e.displayName??"",username:e.http.username??"",password:e.http.password??"",error:"",status:r.status[f.key(e)]?.healthy})},W=()=>{if(U()==="add"){if(_.isPending)return;d("addServer",{error:""}),_.mutate(r.addServer.url);return}const e=j();e&&(D.isPending||(d("editServer",{error:""}),D.mutate({original:e,value:r.editServer.value})))},L=x(()=>U()!=="list"),p=x(()=>U()==="add"),B=x(()=>p()?_.isPending:D.isPending),ge=x(()=>L()?(()=>{var e=$e(),t=e.firstChild;return m(e,n(Y,{icon:"arrow-left",variant:"ghost",onClick:V,get"aria-label"(){return s.t("common.goBack")}}),t),m(t,(()=>{var a=w(()=>!!p());return()=>a()?s.t("dialog.server.add.title"):s.t("dialog.server.edit.title")})()),e})():s.t("dialog.server.title"));X(()=>{r.editServer.id&&(j()||I())});async function ve(e){await u.sshDisconnect?.(e),c.remove(e),await u.getDefaultServer?.()===e&&u.setDefaultServer?.(null)}return n(ye,{get title(){return ge()},get children(){var e=Ee(),t=e.firstChild;return m(e,n($,{get when(){return!L()},get fallback(){return n(ze,{get value(){return w(()=>!!p())()?r.addServer.url:r.editServer.value},get name(){return w(()=>!!p())()?r.addServer.name:r.editServer.name},get username(){return w(()=>!!p())()?r.addServer.username:r.editServer.username},get password(){return w(()=>!!p())()?r.addServer.password:r.editServer.password},get placeholder(){return s.t("dialog.server.add.placeholder")},get busy(){return B()},get error(){return w(()=>!!p())()?r.addServer.error:r.editServer.error},get status(){return w(()=>!!p())()?r.addServer.status:r.editServer.status},get onChange(){return p()?te:ie},get onNameChange(){return p()?ae:de},get onUsernameChange(){return p()?ne:le},get onPasswordChange(){return p()?se:oe},onSubmit:W,onBack:V})},get children(){return[(()=>{var a=Ie();return m(a,()=>s.t("dialog.server.description")),a})(),n(Ce,{get search(){return{placeholder:s.t("dialog.server.search.placeholder"),autofocus:!1}},noInitialSelection:!0,get emptyMessage(){return s.t("dialog.server.empty")},items:re,key:a=>a.http.url,onSelect:a=>{a&&q(a)},divider:!0,class:"flex-1 min-h-0 px-5 [&_[data-slot=list-search-wrapper]]:w-full [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:overflow-y-auto [&_[data-slot=list-items]]:bg-surface-base [&_[data-slot=list-items]]:rounded-md [&_[data-slot=list-item]]:min-h-14 [&_[data-slot=list-item]]:p-3 [&_[data-slot=list-item]]:!bg-transparent",children:a=>{const g=f.key(a);return(()=>{var o=Ae(),k=o.firstChild,b=k.nextSibling;return m(k,n(_e,{get health(){return r.status[g]}})),m(o,n(De,{conn:a,get dimmed(){return r.status[g]?.healthy===!1},get status(){return r.status[g]},class:"flex items-center gap-3 min-w-0 flex-1",get badge(){return n($,{get when(){return v()===f.key(a)},get children(){var P=Fe();return m(P,()=>s.t("dialog.server.status.default")),P}})},showCredentials:!0}),b),m(b,n($,{get when(){return f.key(T())===g},get children(){return n(we,{name:"check",class:"h-6"})}}),null),m(b,n($,{get when(){return a.type==="http"},get children(){return n(S,{get children(){return[n(S.Trigger,{as:Y,icon:"dot-grid",variant:"ghost",class:"shrink-0 size-8 hover:bg-surface-base-hover data-[expanded]:bg-surface-base-active",onClick:P=>P.stopPropagation(),onPointerDown:P=>P.stopPropagation()}),n(S.Portal,{get children(){return n(S.Content,{class:"mt-1",get children(){return[n(S.Item,{onSelect:()=>{a.type==="http"&&ce(a)},get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.edit")}})}}),n($,{get when(){return w(()=>!!h())()&&v()!==g},get children(){return n(S.Item,{onSelect:()=>C(g),get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.default")}})}})}}),n($,{get when(){return w(()=>!!h())()&&v()===g},get children(){return n(S.Item,{onSelect:()=>C(null),get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.defaultRemove")}})}})}}),n(S.Separator,{}),n(S.Item,{onSelect:()=>ve(f.key(a)),class:"text-text-on-critical-base hover:bg-surface-critical-weak",get children(){return n(S.ItemLabel,{get children(){return s.t("dialog.server.menu.delete")}})}})]}})}})]}})}}),null),o})()}})]}}),t),m(t,n($,{get when(){return L()},get fallback(){return n(G,{variant:"secondary",icon:"plus-small",size:"large",onClick:ue,class:"py-1.5 pl-1.5 pr-3 flex items-center gap-1.5",get children(){return s.t("dialog.server.add.button")}})},get children(){return n(G,{variant:"primary",size:"large",onClick:W,get disabled(){return B()},class:"px-3 py-1.5",get children(){return w(()=>!!B())()?s.t("dialog.server.add.checking"):w(()=>!!p())()?s.t("dialog.server.add.button"):s.t("common.save")}})}})),e}})}export{Re as DialogSelectServer};
@@ -1,4 +1,4 @@
1
- import{b as ce,c as ue,e as ge,f as me,R as he,k as pe,h as W,i as r,n as o,v as Q,p as x,z as I,y as k,a$ as fe,E as F,T as v,B as z,a9 as be,r as X,L as ve,X as _,D as ye,t as $}from"./index-t6AoWpnz.js";import{L as xe}from"./list-DsM_Q7VB.js";import{S as ke}from"./switch-Bmpibkz9.js";function G(){return{name:"",host:"",hostName:"",username:"",remotePath:"",port:"",keyPath:"",authType:"config",options:"",submitCommand:"",submitWorkdir:"",environment:"",enabled:!0}}function _e(d){const n=d.split(`
1
+ import{b as ce,c as ue,e as ge,f as me,R as he,k as pe,h as W,i as r,n as o,v as Q,p as x,z as I,y as k,ap as fe,E as F,T as v,B as z,a9 as be,r as X,L as ve,X as _,D as ye,t as $}from"./index-DqutAOLe.js";import{L as xe}from"./list-Cnpbqmww.js";import{S as ke}from"./switch-DPKITECj.js";function G(){return{name:"",host:"",hostName:"",username:"",remotePath:"",port:"",keyPath:"",authType:"config",options:"",submitCommand:"",submitWorkdir:"",environment:"",enabled:!0}}function _e(d){const n=d.split(`
2
2
  `).map(c=>{const w=c.trim(),S=w.startsWith("#")?w.slice(1).trim():w;if(w.startsWith("#")&&!/^RemoteWorkDir\s+/i.test(S))return;const M=S.match(/^([A-Za-z][A-Za-z0-9]*)\s+(.+)$/);if(M)return[M[1].toLowerCase(),M[2].trim().replace(/^["']|["']$/g,"")]}).filter(c=>!!c),g=c=>n.find(w=>w[0]===c)?.[1],t=g("host"),D=g("identityfile"),i=new Set(["host","hostname","port","user","identityfile","remoteworkdir"]);return{name:t,host:t,hostName:g("hostname"),username:g("user"),remotePath:g("remoteworkdir"),port:g("port"),keyPath:D,authType:D?"key":void 0,options:n.filter(c=>!i.has(c[0])).map(c=>`${c[0]}=${c[1]}`).join(`
3
3
  `)}}function we(d){const n=d.trim();return!!(!n||/^[a-zA-Z]:[\\/]/.test(n)||n.startsWith("\\\\")||n.startsWith("//"))}function V(d){if(!d.name.trim()||!d.host.trim()||!d.remotePath.trim())return"required";const n=Number(d.port.trim());if(d.port.trim()&&(!Number.isInteger(n)||n<1||n>65535))return"portInvalid"}function $e(d){return Object.fromEntries(d.split(`
4
4
  `).map(n=>n.trim()).filter(Boolean).map(n=>{const g=n.indexOf("=");return g===-1?[n,""]:[n.slice(0,g).trim(),n.slice(g+1).trim()]}).filter(n=>n[0]))}function Pe(d){return Object.fromEntries(d.split(`
@@ -0,0 +1 @@
1
+ import{i as r,t as h,a4 as We,f as se,a5 as Ge,u as Ce,a6 as qe,a7 as Pe,k as xe,h as N,a8 as Ve,c as we,e as ye,j as ve,w as Te,n as t,a3 as He,I as Q,E as j,p as W,a9 as X,T as V,aa as Je,ab as Ye,ac as Ze,ad as Qe,ae as Xe,af as et,m as ge,B as H,ag as tt,ah as nt,ai as rt,aj as st,y as R,ak as it,d as De,al as at,o as lt,v as $e,F as re,A as ot,r as Ae,L as ct,am as dt,an as gt,O as ut,ao as pt,b as Ee,R as Ne,Z as le,S as ft,M as ue,D as Ke,ap as Fe,g as ht,G as de,P as ce,aq as mt,J as vt,ar as U}from"./index-DqutAOLe.js";import{S as O}from"./switch-DPKITECj.js";import{L as bt,D as xt,a as wt,b as yt}from"./dialog-select-provider-DjM-NV2S.js";import{T as oe}from"./tag-B_xDskei.js";import"./list-Cnpbqmww.js";var $t=h('<div class="bg-surface-base px-4 rounded-lg">');const q=n=>(()=>{var e=$t();return r(e,()=>n.children),e})(),_t={BASE_URL:"https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202607151639/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};var kt=h("<div data-action=settings-auto-accept-permissions>"),St=h("<div data-action=settings-feed-reasoning-summaries>"),Ct=h("<div data-action=settings-feed-shell-tool-parts-expanded>"),Pt=h("<div data-action=settings-feed-edit-tool-parts-expanded>"),Tt=h("<div data-action=settings-show-session-progress-bar>"),Dt=h('<div class="flex flex-col gap-1">'),At=h("<div data-action=settings-show-file-tree>"),Et=h("<div data-action=settings-show-navigation>"),Nt=h("<div data-action=settings-show-search>"),Kt=h("<div data-action=settings-show-terminal>"),Ft=h("<div data-action=settings-show-status>"),te=h('<div class="flex flex-col gap-1"><h3 class="text-14-medium text-text-strong pb-2">'),pe=h('<div class="w-full sm:w-[220px]">'),Lt=h("<div data-action=settings-notifications-agent>"),It=h("<div data-action=settings-notifications-permissions>"),zt=h("<div data-action=settings-notifications-errors>"),Ot=h("<div data-action=settings-updates-startup>"),jt=h("<div data-action=settings-release-notes>"),Rt=h("<div data-action=settings-wayland>"),Bt=h('<div class="flex flex-col h-full overflow-y-auto no-scrollbar px-4 pb-10 sm:px-10 sm:pb-10"><div class="sticky top-0 z-10 bg-[linear-gradient(to_bottom,var(--surface-stronger-non-alpha)_calc(100%_-_24px),transparent)]"><div class="flex flex-col gap-1 pt-6 pb-8"><h2 class="text-16-medium text-text-strong"></h2></div></div><div class="flex flex-col gap-8 w-full">'),Mt=h("<span class=text-text-weak>"),Ut=h('<div class="flex items-center gap-2"><span>'),Wt=h('<div class="flex flex-wrap items-center gap-4 py-3 border-b border-border-weak-base last:border-none sm:flex-nowrap"><div class="flex min-w-0 flex-1 flex-col gap-0.5"><span class="text-14-medium text-text-strong"></span><span class="text-12-regular text-text-weak"></span></div><div class="flex w-full justify-end sm:w-auto sm:shrink-0">');let J={cleanup:void 0,timeout:void 0,run:0};const Le=()=>{J.run+=1,J.cleanup&&J.cleanup(),clearTimeout(J.timeout),J.cleanup=void 0},ke=n=>{if(Le(),!n)return;const e=++J.run;J.timeout=setTimeout(()=>{it(n).then(l=>{if(J.run!==e){l?.();return}J.cleanup=l})},100)},Gt=()=>{const n=We(),e=se(),l=Ge(),s=Ce(),g=qe(),a=Pe(),[k,_]=xe({checking:!1}),$=N(()=>s.platform==="desktop"&&s.os==="linux"),x=N(()=>Ve(g.dir)),C=N(()=>{const p=x();return p?g.id?l.isAutoAccepting(g.id,p):l.isAutoAcceptingDirectory(p):!1}),K=p=>{const o=x();if(o){if(!g.id){if(l.isAutoAcceptingDirectory(o)===p)return;l.toggleAutoAcceptDirectory(o);return}if(p){l.enableAutoAccept(g.id,o);return}l.disableAutoAccept(g.id,o)}},G=N(()=>s.platform==="desktop"),T=()=>{s.checkUpdate&&(_("checking",!0),s.checkUpdate().then(p=>{if(!p.updateAvailable){R({variant:"success",icon:"circle-check",title:e.t("settings.updates.toast.latest.title"),description:e.t("settings.updates.toast.latest.description",{version:s.version??""})});return}const o=s.updateAndRestart?[{label:e.t("toast.update.action.installRestart"),onClick:async()=>{await s.updateAndRestart()}},{label:e.t("toast.update.action.notYet"),onClick:"dismiss"}]:[{label:e.t("toast.update.action.notYet"),onClick:"dismiss"}];R({persistent:!0,icon:"download",title:e.t("toast.update.title"),description:e.t("toast.update.description",{version:p.version??""}),actions:o})}).catch(p=>{const o=p instanceof Error?p.message:String(p);R({title:e.t("common.requestFailed"),description:o})}).finally(()=>_("checking",!1)))},F=N(()=>n.ids().map(p=>({id:p,name:n.name(p)}))),B=we(),m=ye(),[c]=ve(()=>m.client.pty.shells().then(p=>p.data??[]).catch(()=>[]),{initialValue:[]}),[b,{refetch:E}]=ve(()=>!!($()&&s.getDisplayBackend),()=>Promise.resolve(s.getDisplayBackend?.()??null).catch(()=>null),{initialValue:null});Te(()=>{n.loadThemes()});const z={id:"auto",value:"",label:e.t("settings.general.row.shell.autoDefault")},P=N(()=>B.data.config.shell??""),L=N(()=>{const p=c.latest,o=B.data.config.shell,i=new Map;for(const v of p)i.set(v.name,(i.get(v.name)||0)+1);const w=[z,...p.map(v=>{const ee=(i.get(v.name)||0)>1,ae=ee?v.path:v.name,Z=v.acceptable?ae:`${ae} (${e.t("settings.general.row.shell.terminalOnly")})`;return{id:v.path,value:ee?v.path:v.name,label:Z}})];return o&&!w.some(v=>v.value===o)&&w.push({id:o,value:o,label:o}),w}),d=p=>{const o=s.setDisplayBackend?.(p?"wayland":"auto");o&&o.finally(()=>{E()})},f=N(()=>[{value:"system",label:e.t("theme.scheme.system")},{value:"light",label:e.t("theme.scheme.light")},{value:"dark",label:e.t("theme.scheme.dark")}]),u=N(()=>e.locales.map(p=>({value:p,label:e.label(p)}))),D={id:"none",label:"sound.option.none"},y=[D,...st],A=()=>nt(a.appearance.font()),I=()=>tt(a.appearance.uiFont()),M=()=>rt(a.appearance.terminalFont()),Y=(p,o,i,w)=>({options:y,current:p()?y.find(v=>v.id===o())??D:D,value:v=>v.id,label:v=>e.t(v.label),onHighlight:v=>{v&&ke(v.id==="none"?void 0:v.id)},onSelect:v=>{if(v){if(v.id==="none"){i(!1),Le();return}i(!0),w(v.id),ke(v.id)}},variant:"secondary",size:"small",triggerVariant:"settings"}),ze=()=>(()=>{var p=Dt();return r(p,t(q,{get children(){return[t(S,{get title(){return e.t("settings.general.row.language.title")},get description(){return e.t("settings.general.row.language.description")},get children(){return t(X,{"data-action":"settings-language",get options(){return u()},get current(){return u().find(o=>o.value===e.locale())},value:o=>o.value,label:o=>o.label,onSelect:o=>o&&e.setLocale(o.value),variant:"secondary",size:"small",triggerVariant:"settings"})}}),t(S,{get title(){return e.t("command.permissions.autoaccept.enable")},get description(){return e.t("toast.permissions.autoaccept.on.description")},get children(){var o=kt();return r(o,t(O,{get checked(){return C()},get disabled(){return!x()},onChange:K})),o}}),t(S,{get title(){return e.t("settings.general.row.shell.title")},get description(){return e.t("settings.general.row.shell.description")},get children(){return t(X,{"data-action":"settings-shell",get options(){return L()},get current(){return L().find(o=>o.value===P())??z},value:o=>o.id,label:o=>o.label,onSelect:o=>{o&&o.value!==P()&&B.updateConfig({shell:o.value})},variant:"secondary",size:"small",triggerVariant:"settings",triggerStyle:{"min-width":"180px"}})}}),t(S,{get title(){return e.t("settings.general.row.reasoningSummaries.title")},get description(){return e.t("settings.general.row.reasoningSummaries.description")},get children(){var o=St();return r(o,t(O,{get checked(){return a.general.showReasoningSummaries()},onChange:i=>a.general.setShowReasoningSummaries(i)})),o}}),t(S,{get title(){return e.t("settings.general.row.shellToolPartsExpanded.title")},get description(){return e.t("settings.general.row.shellToolPartsExpanded.description")},get children(){var o=Ct();return r(o,t(O,{get checked(){return a.general.shellToolPartsExpanded()},onChange:i=>a.general.setShellToolPartsExpanded(i)})),o}}),t(S,{get title(){return e.t("settings.general.row.editToolPartsExpanded.title")},get description(){return e.t("settings.general.row.editToolPartsExpanded.description")},get children(){var o=Pt();return r(o,t(O,{get checked(){return a.general.editToolPartsExpanded()},onChange:i=>a.general.setEditToolPartsExpanded(i)})),o}}),t(S,{get title(){return e.t("settings.general.row.showSessionProgressBar.title")},get description(){return e.t("settings.general.row.showSessionProgressBar.description")},get children(){var o=Tt();return r(o,t(O,{get checked(){return a.general.showSessionProgressBar()},onChange:i=>a.general.setShowSessionProgressBar(i)})),o}})]}})),p})(),Oe=()=>(()=>{var p=te(),o=p.firstChild;return r(o,()=>e.t("settings.general.section.advanced")),r(p,t(q,{get children(){return[t(S,{get title(){return e.t("settings.general.row.showFileTree.title")},get description(){return e.t("settings.general.row.showFileTree.description")},get children(){var i=At();return r(i,t(O,{get checked(){return a.general.showFileTree()},onChange:w=>a.general.setShowFileTree(w)})),i}}),t(S,{get title(){return e.t("settings.general.row.showNavigation.title")},get description(){return e.t("settings.general.row.showNavigation.description")},get children(){var i=Et();return r(i,t(O,{get checked(){return a.general.showNavigation()},onChange:w=>a.general.setShowNavigation(w)})),i}}),t(S,{get title(){return e.t("settings.general.row.showSearch.title")},get description(){return e.t("settings.general.row.showSearch.description")},get children(){var i=Nt();return r(i,t(O,{get checked(){return a.general.showSearch()},onChange:w=>a.general.setShowSearch(w)})),i}}),t(S,{get title(){return e.t("settings.general.row.showTerminal.title")},get description(){return e.t("settings.general.row.showTerminal.description")},get children(){var i=Kt();return r(i,t(O,{get checked(){return a.general.showTerminal()},onChange:w=>a.general.setShowTerminal(w)})),i}}),t(S,{get title(){return e.t("settings.general.row.showStatus.title")},get description(){return e.t("settings.general.row.showStatus.description")},get children(){var i=Ft();return r(i,t(O,{get checked(){return a.general.showStatus()},onChange:w=>a.general.setShowStatus(w)})),i}})]}}),null),p})(),je=()=>(()=>{var p=te(),o=p.firstChild;return r(o,()=>e.t("settings.general.section.appearance")),r(p,t(q,{get children(){return[t(S,{get title(){return e.t("settings.general.row.colorScheme.title")},get description(){return e.t("settings.general.row.colorScheme.description")},get children(){return t(X,{"data-action":"settings-color-scheme",get options(){return f()},get current(){return f().find(i=>i.value===n.colorScheme())},value:i=>i.value,label:i=>i.label,onSelect:i=>i&&n.setColorScheme(i.value),onHighlight:i=>{if(i)return n.previewColorScheme(i.value),()=>n.cancelPreview()},variant:"secondary",size:"small",triggerVariant:"settings",triggerStyle:{"min-width":"220px"}})}}),t(S,{get title(){return e.t("settings.general.row.theme.title")},get description(){return[W(()=>e.t("settings.general.row.theme.description"))," ",t(bt,{href:"https://opencode.ai/docs/themes/",get children(){return e.t("common.learnMore")}})]},get children(){return t(X,{"data-action":"settings-theme",get options(){return F()},get current(){return F().find(i=>i.id===n.themeId())},value:i=>i.id,label:i=>i.name,onSelect:i=>{i&&n.setTheme(i.id)},onHighlight:i=>{if(i)return n.previewTheme(i.id),()=>n.cancelPreview()},variant:"secondary",size:"small",triggerVariant:"settings"})}}),t(S,{get title(){return e.t("settings.general.row.uiFont.title")},get description(){return e.t("settings.general.row.uiFont.description")},get children(){var i=pe();return r(i,t(V,{"data-action":"settings-ui-font",get label(){return e.t("settings.general.row.uiFont.title")},hideLabel:!0,type:"text",get value(){return I()},onChange:w=>a.appearance.setUIFont(w),placeholder:Je,spellcheck:!1,autocorrect:"off",autocomplete:"off",autocapitalize:"off",class:"text-12-regular",get style(){return{"font-family":Ye(a.appearance.uiFont())}}})),i}}),t(S,{get title(){return e.t("settings.general.row.font.title")},get description(){return e.t("settings.general.row.font.description")},get children(){var i=pe();return r(i,t(V,{"data-action":"settings-code-font",get label(){return e.t("settings.general.row.font.title")},hideLabel:!0,type:"text",get value(){return A()},onChange:w=>a.appearance.setFont(w),placeholder:Ze,spellcheck:!1,autocorrect:"off",autocomplete:"off",autocapitalize:"off",class:"text-12-regular",get style(){return{"font-family":Qe(a.appearance.font())}}})),i}}),t(S,{get title(){return e.t("settings.general.row.terminalFont.title")},get description(){return e.t("settings.general.row.terminalFont.description")},get children(){var i=pe();return r(i,t(V,{"data-action":"settings-terminal-font",get label(){return e.t("settings.general.row.terminalFont.title")},hideLabel:!0,type:"text",get value(){return M()},onChange:w=>a.appearance.setTerminalFont(w),placeholder:Xe,spellcheck:!1,autocorrect:"off",autocomplete:"off",autocapitalize:"off",class:"text-12-regular",get style(){return{"font-family":et(a.appearance.terminalFont())}}})),i}})]}}),null),p})(),Re=()=>(()=>{var p=te(),o=p.firstChild;return r(o,()=>e.t("settings.general.section.notifications")),r(p,t(q,{get children(){return[t(S,{get title(){return e.t("settings.general.notifications.agent.title")},get description(){return e.t("settings.general.notifications.agent.description")},get children(){var i=Lt();return r(i,t(O,{get checked(){return a.notifications.agent()},onChange:w=>a.notifications.setAgent(w)})),i}}),t(S,{get title(){return e.t("settings.general.notifications.permissions.title")},get description(){return e.t("settings.general.notifications.permissions.description")},get children(){var i=It();return r(i,t(O,{get checked(){return a.notifications.permissions()},onChange:w=>a.notifications.setPermissions(w)})),i}}),t(S,{get title(){return e.t("settings.general.notifications.errors.title")},get description(){return e.t("settings.general.notifications.errors.description")},get children(){var i=zt();return r(i,t(O,{get checked(){return a.notifications.errors()},onChange:w=>a.notifications.setErrors(w)})),i}})]}}),null),p})(),Be=()=>(()=>{var p=te(),o=p.firstChild;return r(o,()=>e.t("settings.general.section.sounds")),r(p,t(q,{get children(){return[t(S,{get title(){return e.t("settings.general.sounds.agent.title")},get description(){return e.t("settings.general.sounds.agent.description")},get children(){return t(X,ge({"data-action":"settings-sounds-agent"},()=>Y(()=>a.sounds.agentEnabled(),()=>a.sounds.agent(),i=>a.sounds.setAgentEnabled(i),i=>a.sounds.setAgent(i))))}}),t(S,{get title(){return e.t("settings.general.sounds.permissions.title")},get description(){return e.t("settings.general.sounds.permissions.description")},get children(){return t(X,ge({"data-action":"settings-sounds-permissions"},()=>Y(()=>a.sounds.permissionsEnabled(),()=>a.sounds.permissions(),i=>a.sounds.setPermissionsEnabled(i),i=>a.sounds.setPermissions(i))))}}),t(S,{get title(){return e.t("settings.general.sounds.errors.title")},get description(){return e.t("settings.general.sounds.errors.description")},get children(){return t(X,ge({"data-action":"settings-sounds-errors"},()=>Y(()=>a.sounds.errorsEnabled(),()=>a.sounds.errors(),i=>a.sounds.setErrorsEnabled(i),i=>a.sounds.setErrors(i))))}})]}}),null),p})(),Me=()=>(()=>{var p=te(),o=p.firstChild;return r(o,()=>e.t("settings.general.section.updates")),r(p,t(q,{get children(){return[t(S,{get title(){return e.t("settings.updates.row.startup.title")},get description(){return e.t("settings.updates.row.startup.description")},get children(){var i=Ot();return r(i,t(O,{get checked(){return a.updates.startup()},get disabled(){return!s.checkUpdate},onChange:w=>a.updates.setStartup(w)})),i}}),t(S,{get title(){return e.t("settings.general.row.releaseNotes.title")},get description(){return e.t("settings.general.row.releaseNotes.description")},get children(){var i=jt();return r(i,t(O,{get checked(){return a.general.releaseNotes()},onChange:w=>a.general.setReleaseNotes(w)})),i}}),t(S,{get title(){return e.t("settings.updates.row.check.title")},get description(){return e.t("settings.updates.row.check.description")},get children(){return t(H,{size:"small",variant:"secondary",get disabled(){return k.checking||!s.checkUpdate},onClick:T,get children(){return W(()=>!!k.checking)()?e.t("settings.updates.action.checking"):e.t("settings.updates.action.checkNow")}})}})]}}),null),p})();return console.log(_t),(()=>{var p=Bt(),o=p.firstChild,i=o.firstChild,w=i.firstChild,v=o.nextSibling;return r(w,()=>e.t("settings.tab.general")),r(v,t(ze,{}),null),r(v,t(je,{}),null),r(v,t(Re,{}),null),r(v,t(Be,{}),null),r(v,t(Me,{}),null),r(v,t(j,{get when(){return $()},get children(){var ee=te(),ae=ee.firstChild;return r(ae,()=>e.t("settings.general.section.display")),r(ee,t(q,{get children(){return t(S,{get title(){return(()=>{var Z=Ut(),Ue=Z.firstChild;return r(Ue,()=>e.t("settings.general.row.wayland.title")),r(Z,t(He,{get value(){return e.t("settings.general.row.wayland.tooltip")},placement:"top",get children(){var _e=Mt();return r(_e,t(Q,{name:"help",size:"small"})),_e}}),null),Z})()},get description(){return e.t("settings.general.row.wayland.description")},get children(){var Z=Rt();return r(Z,t(O,{get checked(){return b.latest==="wayland"},onChange:d})),Z}})}}),null),ee}}),null),r(v,t(j,{get when(){return W(()=>!!G())()&&!1},get children(){return t(Oe,{})}}),null),p})()},S=n=>(()=>{var e=Wt(),l=e.firstChild,s=l.firstChild,g=s.nextSibling,a=l.nextSibling;return r(s,()=>n.title),r(g,()=>n.description),r(a,()=>n.children),e})();var qt=h('<span class="text-14-regular text-text-strong mt-1">"<!>"'),Vt=h('<div class="flex flex-col items-center justify-center py-12 text-center"><span class="text-14-regular text-text-weak">'),Ht=h('<div class="flex flex-col h-full overflow-y-auto no-scrollbar px-4 pb-10 sm:px-10 sm:pb-10"><div class="sticky top-0 z-10 bg-[linear-gradient(to_bottom,var(--surface-stronger-non-alpha)_calc(100%_-_24px),transparent)]"><div class="flex flex-col gap-4 pt-6 pb-6 max-w-[720px]"><div class="flex items-center justify-between gap-4"><h2 class="text-16-medium text-text-strong"></h2></div><div class="flex items-center gap-2 px-3 h-9 rounded-lg bg-surface-base"></div></div></div><div class="flex flex-col gap-8 max-w-[720px]">'),Jt=h('<div class="flex flex-col gap-1"><h3 class="text-14-medium text-text-strong pb-2">'),Yt=h('<div class="flex items-center justify-between gap-4 py-3 border-b border-border-weak-base last:border-none"><span class="text-14-regular text-text-strong"></span><button type=button>');const fe=typeof navigator=="object"&&/(Mac|iPod|iPhone|iPad)/.test(navigator.platform),ne="command.palette",Zt="mod+shift+p",ie=["General","Session","Navigation","Model and agent","Terminal","Prompt"],Qt={General:"settings.shortcuts.group.general",Session:"settings.shortcuts.group.session",Navigation:"settings.shortcuts.group.navigation","Model and agent":"settings.shortcuts.group.modelAndAgent",Terminal:"settings.shortcuts.group.terminal",Prompt:"settings.shortcuts.group.prompt"};function he(n){return n===ne?"General":n.startsWith("terminal.")?"Terminal":n.startsWith("model.")||n.startsWith("agent.")||n.startsWith("mcp.")?"Model and agent":n.startsWith("file.")||n.startsWith("fileTree.")?"Navigation":n.startsWith("prompt.")?"Prompt":n.startsWith("session.")||n.startsWith("message.")||n.startsWith("permissions.")||n.startsWith("steps.")||n.startsWith("review.")?"Session":"General"}function Xt(n){return n==="Shift"||n==="Control"||n==="Alt"||n==="Meta"}function en(n){return n===","?"comma":n==="+"?"plus":n===" "?"space":n.toLowerCase()}function tn(n){if(Xt(n.key))return;const e=[];(fe?n.metaKey:n.ctrlKey)&&e.push("mod"),fe&&n.ctrlKey&&e.push("ctrl"),!fe&&n.metaKey&&e.push("meta"),n.altKey&&e.push("alt"),n.shiftKey&&e.push("shift");const s=en(n.key);if(s)return e.push(s),e.join("+")}function be(n){if(!n)return[];const e=[];for(const l of gt(n)){const s=[];l.ctrl&&s.push("ctrl"),l.alt&&s.push("alt"),l.shift&&s.push("shift"),l.meta&&s.push("meta"),l.key&&s.push(l.key),s.length!==0&&e.push(s.join("+"))}return e}function nn(n){return!n||typeof n!="object"||Array.isArray(n)?{}:n}function rn(n,e,l){const s=new Map;s.set(ne,{title:l,group:"General"});for(const g of n.catalog)g.id.startsWith("suggested.")||g.hidden||s.set(g.id,{title:g.title,group:he(g.id)});for(const g of n.options)g.id.startsWith("suggested.")||g.hidden||s.set(g.id,{title:g.title,group:he(g.id)});for(const[g,a]of Object.entries(e))typeof a=="string"&&(s.has(g)||s.set(g,{title:g,group:he(g)}));return s}function sn(n){const e=new Map;for(const l of ie)e.set(l,[]);for(const[l,s]of n){const g=e.get(s.group);g&&g.push(l)}for(const l of ie){const s=e.get(l);s&&s.sort((g,a)=>(n.get(g)?.title??"").localeCompare(n.get(a)?.title??""))}return e}function an(n,e,l,s){const g=n.toLowerCase().trim();if(!g)return l;const a=new Map;for(const $ of ie)a.set($,[]);const k=Array.from(e.entries()).map(([$,x])=>({id:$,title:x.title,group:x.group,keybind:s($)})),_=dt.go(g,k,{keys:["title","keybind"],threshold:-1e4});for(const $ of _){const x=a.get($.obj.group);x&&x.push($.obj.id)}return a}function ln(n){Te(()=>{ut(document,"keydown",l=>{const s=n.active();if(!s)return;if(l.preventDefault(),l.stopPropagation(),l.stopImmediatePropagation(),l.key==="Escape"){n.stop();return}if((l.key==="Backspace"||l.key==="Delete")&&!l.ctrlKey&&!l.metaKey&&!l.altKey&&!l.shiftKey){n.set(s,"none"),n.stop();return}const a=tn(l);if(!a)return;const k=new Map;for(const _ of be(a))for(const $ of n.used().get(_)??[])$.id!==s&&k.set($.id,$.title);if(k.size>0){R({title:n.language.t("settings.shortcuts.conflict.title"),description:n.language.t("settings.shortcuts.conflict.description",{keybind:pt(a,n.language.t),titles:[...k.values()].join(", ")})});return}n.set(s,a),n.stop()},{capture:!0})})}const on=()=>{const n=at(),e=se(),l=Pe(),[s,g]=xe({active:null,filter:""}),a=()=>{s.active&&(g("active",null),n.keybinds(!0))},k=c=>{if(s.active===c){a();return}s.active&&a(),g("active",c),n.keybinds(!1)},_=N(()=>nn(l.current.keybinds)),$=N(()=>Object.values(_()).some(c=>typeof c=="string")),x=()=>{a(),l.keybinds.resetAll(),R({title:e.t("settings.shortcuts.reset.toast.title"),description:e.t("settings.shortcuts.reset.toast.description")})},C=N(()=>(e.locale(),rn(n,_(),e.t("command.palette")))),K=c=>C().get(c)?.title??"",G=N(()=>sn(C())),T=N(()=>an(s.filter,C(),G(),c=>n.keybind(c)||"")),F=N(()=>{for(const c of ie)if((T().get(c)??[]).length>0)return!0;return!1}),B=N(()=>{const c=new Map,b=(P,L)=>{const d=c.get(P);if(!d){c.set(P,[L]);return}d.push(L)},E=l.keybinds.get(ne)??Zt;for(const P of be(E))b(P,{id:ne,title:K(ne)});const z=P=>{const L=l.keybinds.get(P);if(typeof L=="string")return L;const d=n.options.find(u=>u.id===P);return d?.keybind?d.keybind:n.catalog.find(u=>u.id===P)?.keybind};for(const P of C().keys())if(P!==ne)for(const L of be(z(P)))b(L,{id:P,title:K(P)});return c});return ln({active:()=>s.active,stop:a,set:(c,b)=>l.keybinds.set(c,b),used:B,language:e}),lt(()=>{s.active&&n.keybinds(!0)}),(()=>{var c=Ht(),b=c.firstChild,E=b.firstChild,z=E.firstChild,P=z.firstChild,L=z.nextSibling,d=b.nextSibling;return r(P,()=>e.t("settings.shortcuts.title")),r(z,t(H,{size:"small",variant:"secondary",onClick:x,get disabled(){return!$()},get children(){return e.t("settings.shortcuts.reset.button")}}),null),r(L,t(Q,{name:"magnifying-glass",class:"text-icon-weak-base flex-shrink-0"}),null),r(L,t(V,{variant:"ghost",type:"text",get value(){return s.filter},onChange:f=>g("filter",f),get placeholder(){return e.t("settings.shortcuts.search.placeholder")},spellcheck:!1,autocorrect:"off",autocomplete:"off",autocapitalize:"off",class:"flex-1"}),null),r(L,t(j,{get when(){return s.filter},get children(){return t($e,{icon:"circle-x",variant:"ghost",onClick:()=>g("filter","")})}}),null),r(d,t(re,{each:ie,children:f=>t(j,{get when(){return(T().get(f)??[]).length>0},get children(){var u=Jt(),D=u.firstChild;return r(D,()=>e.t(Qt[f])),r(u,t(q,{get children(){return t(re,{get each(){return T().get(f)??[]},children:y=>(()=>{var A=Yt(),I=A.firstChild,M=I.nextSibling;return r(I,()=>K(y)),M.$$click=()=>k(y),ot(M,"data-keybind-id",y),r(M,t(j,{get when(){return s.active===y},get fallback(){return n.keybind(y)||e.t("settings.shortcuts.unassigned")},get children(){return e.t("settings.shortcuts.pressKeys")}})),Ae(Y=>ct(M,{"h-8 px-3 rounded-md text-12-regular":!0,"bg-surface-base text-text-subtle hover:bg-surface-raised-base-hover active:bg-surface-raised-base-active":s.active!==y,"border border-border-weak-base bg-surface-inset-base text-text-weak":s.active===y},Y)),A})()})}}),null),u}})}),null),r(d,t(j,{get when(){return W(()=>!!s.filter)()&&!F()},get children(){var f=Vt(),u=f.firstChild;return r(u,()=>e.t("settings.shortcuts.search.empty")),r(f,t(j,{get when(){return s.filter},get children(){var D=qt(),y=D.firstChild,A=y.nextSibling;return A.nextSibling,r(D,()=>s.filter,A),D}}),null),f}}),null),c})()};De(["click"]);var Se=h('<div class="flex justify-end pt-1">'),cn=h('<p class="text-14-regular text-text-base">'),dn=h('<div class="flex flex-col rounded-lg border border-border-weak-base overflow-hidden"><button type=button class="flex items-center justify-between gap-3 w-full px-3.5 py-3 text-left hover:bg-surface-base-hover transition-colors disabled:opacity-50"><div class="flex flex-col gap-0.5 min-w-0"><span class="text-14-medium text-text-strong"></span><span class="text-12-regular text-text-weak">'),gn=h('<div class="flex flex-col gap-4 max-h-[min(60vh,420px)] overflow-y-auto pr-0.5">'),un=h('<div class="flex gap-2 justify-end pt-1">'),pn=h('<div class="w-full px-5 pb-5 flex flex-col gap-4">'),fn=h('<div class="flex items-center gap-2 min-w-0"><span class=truncate>');function hn(){const n=Ee(),e=se(),l=ye(),s=we(),g=Ne(),[a,k]=le("password"),[_,$]=le(""),[x,C]=le(!1),[K,G]=le(""),[T,F]=xe({baseURL:"",modelID:"",modelName:"",providerName:"",apiKey:"",hasApiKey:!1}),B=N(()=>a()==="model"?e.t("settings.providers.onescience.admin.model.title"):e.t("settings.providers.onescience.admin.title"));async function m(d,f){const u={"Content-Type":"application/json"},D=g.current;D?.http.password&&(u.Authorization=`Basic ${Fe({username:D.http.username,password:D.http.password})}`);const y=await fetch(`${l.url}${d}`,{method:f.method,headers:u,body:f.body===void 0?void 0:JSON.stringify(f.body)}),A=await y.text(),I=A?JSON.parse(A):void 0;if(!y.ok){const M=I&&typeof I=="object"&&"message"in I?String(I.message):A;throw new Error(M||y.statusText)}return I}async function c(){await l.client.global.dispose().catch(()=>{}),await s.reload()}async function b(d){const f=await m("/global/onescience-preset/admin/config",{method:"POST",body:{token:d}});F({baseURL:f.baseURL,modelID:f.modelID,modelName:f.modelName,providerName:f.providerName,apiKey:"",hasApiKey:f.hasApiKey})}async function E(){if(!x()){C(!0);try{const d=await m("/global/onescience-preset/admin/login",{method:"POST",body:{password:K()}});if(!d.ok||!d.token){R({title:e.t("settings.providers.onescience.admin.passwordInvalid")});return}$(d.token),G(""),k("menu")}catch(d){R({title:e.t("common.requestFailed"),description:d instanceof Error?d.message:String(d)})}finally{C(!1)}}}async function z(){if(!x()){C(!0);try{await b(_()),k("model")}catch(d){R({title:e.t("common.requestFailed"),description:d instanceof Error?d.message:String(d)})}finally{C(!1)}}}async function P(){if(!x()){C(!0);try{const d=await m("/global/onescience-preset/admin/config",{method:"PATCH",body:{token:_(),baseURL:T.baseURL,modelID:T.modelID,modelName:T.modelName,providerName:T.providerName,apiKey:T.apiKey||void 0}});F({baseURL:d.baseURL,modelID:d.modelID,modelName:d.modelName,providerName:d.providerName,apiKey:"",hasApiKey:d.hasApiKey}),await c(),R({variant:"success",icon:"circle-check",title:e.t("settings.providers.onescience.admin.saved")}),k("menu")}catch(d){R({title:e.t("common.requestFailed"),description:d instanceof Error?d.message:String(d)})}finally{C(!1)}}}async function L(){if(!x()){C(!0);try{const d=await m("/global/onescience-preset/admin/reset",{method:"POST",body:{token:_()}});F({baseURL:d.baseURL,modelID:d.modelID,modelName:d.modelName,providerName:d.providerName,apiKey:"",hasApiKey:d.hasApiKey}),await c(),R({variant:"success",icon:"circle-check",title:e.t("settings.providers.onescience.admin.reset")})}catch(d){R({title:e.t("common.requestFailed"),description:d instanceof Error?d.message:String(d)})}finally{C(!1)}}}return t(Ke,{get title(){return W(()=>a()==="model")()?(()=>{var d=fn(),f=d.firstChild;return r(d,t($e,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:()=>k("menu"),get"aria-label"(){return e.t("common.goBack")}}),f),r(f,B),d})():B()},get description(){return W(()=>a()==="password")()?e.t("settings.providers.onescience.admin.passwordHint"):void 0},fit:!0,transition:!0,class:"w-full max-w-[420px]",get children(){var d=pn();return r(d,t(ft,{get children(){return[t(ue,{get when(){return a()==="password"},get children(){return[t(V,{autofocus:!0,type:"password",get label(){return e.t("settings.providers.onescience.admin.password")},get value(){return K()},onChange:G,get placeholder(){return e.t("settings.providers.onescience.admin.passwordPlaceholder")},onKeyDown:f=>{f.key==="Enter"&&K().trim()&&!x()&&E()}}),(()=>{var f=Se();return r(f,t(H,{variant:"primary",get disabled(){return x()||!K().trim()},onClick:()=>void E(),get children(){return e.t("settings.providers.onescience.admin.unlock")}})),f})()]}}),t(ue,{get when(){return a()==="menu"},get children(){return[(()=>{var f=cn();return r(f,()=>e.t("settings.providers.onescience.admin.menu.hint")),f})(),(()=>{var f=dn(),u=f.firstChild,D=u.firstChild,y=D.firstChild,A=y.nextSibling;return u.$$click=()=>void z(),r(y,()=>e.t("settings.providers.onescience.admin.menu.model")),r(A,()=>e.t("settings.providers.onescience.admin.menu.model.description")),r(u,t(Q,{name:"chevron-right",size:"small",class:"shrink-0 text-icon-base"}),null),Ae(()=>u.disabled=x()),f})(),(()=>{var f=Se();return r(f,t(H,{variant:"ghost",get disabled(){return x()},onClick:()=>n.close(),get children(){return e.t("common.close")}})),f})()]}}),t(ue,{get when(){return a()==="model"},get children(){return[(()=>{var f=gn();return r(f,t(V,{get label(){return e.t("settings.providers.onescience.admin.providerName")},get value(){return T.providerName},onChange:u=>F("providerName",u)}),null),r(f,t(V,{get label(){return e.t("settings.providers.onescience.admin.baseURL")},get value(){return T.baseURL},onChange:u=>F("baseURL",u)}),null),r(f,t(V,{get label(){return e.t("settings.providers.onescience.admin.modelID")},get value(){return T.modelID},onChange:u=>F("modelID",u)}),null),r(f,t(V,{get label(){return e.t("settings.providers.onescience.admin.modelName")},get value(){return T.modelName},onChange:u=>F("modelName",u)}),null),r(f,t(V,{type:"password",get label(){return e.t("settings.providers.onescience.admin.apiKey")},get value(){return T.apiKey},onChange:u=>F("apiKey",u),get placeholder(){return W(()=>!!T.hasApiKey)()?e.t("settings.providers.onescience.admin.apiKeyKeep"):e.t("settings.providers.onescience.admin.apiKeyPlaceholder")}}),null),f})(),(()=>{var f=un();return r(f,t(H,{variant:"ghost",get disabled(){return x()},onClick:()=>void L(),get children(){return e.t("settings.providers.onescience.admin.resetAction")}}),null),r(f,t(H,{variant:"primary",get disabled(){return x()},onClick:()=>void P(),get children(){return e.t("common.save")}}),null),f})()]}})]}})),d}})}De(["click"]);var mn=h('<div class="flex items-center justify-between gap-4 min-h-16 border-b border-border-weak-base last:border-none flex-wrap py-3"data-component=custom-provider-section><div class="flex flex-col min-w-0"><div class="flex flex-wrap items-center gap-x-3 gap-y-1"><span class="text-14-medium text-text-strong"></span></div><span class="text-12-regular text-text-weak pl-8">'),vn=h('<div class="flex flex-col gap-2 pt-2 border-t border-border-weak-base">'),bn=h('<div class="flex flex-col h-full overflow-y-auto no-scrollbar px-4 pb-10 sm:px-10 sm:pb-10"><div class="sticky top-0 z-10 bg-[linear-gradient(to_bottom,var(--surface-stronger-non-alpha)_calc(100%_-_24px),transparent)]"><div class="flex flex-col gap-1 pt-6 pb-8 max-w-[720px]"><h2 class="text-16-medium text-text-strong"></h2></div></div><div class="flex flex-col gap-8 max-w-[720px]"><div class="flex flex-col gap-1"data-component=connected-providers-section><h3 class="text-14-medium text-text-strong pb-2"></h3></div><div class="flex flex-col gap-1"><h3 class="text-14-medium text-text-strong pb-2">'),xn=h('<div class="py-4 text-14-regular text-text-weak">'),wn=h('<div class="group flex flex-wrap items-center justify-between gap-4 min-h-16 py-3 border-b border-border-weak-base last:border-none"><div class="flex items-center gap-3 min-w-0"><span class="text-14-medium text-text-strong truncate">'),yn=h('<span class="text-14-regular text-text-base opacity-0 group-hover:opacity-100 transition-opacity duration-200 pr-3 cursor-default">'),$n=h('<div class="flex flex-wrap items-center justify-between gap-4 min-h-16 py-3 border-b border-border-weak-base last:border-none"><div class="flex flex-col min-w-0"><div class="flex items-center gap-x-3"><span class="text-14-medium text-text-strong">'),_n=h('<span class="text-12-regular text-text-weak pl-8">');const me="onescience",kn=[{match:n=>n==="opencode",key:"dialog.provider.opencode.note"},{match:n=>n==="opencode-go",key:"dialog.provider.opencodeGo.tagline"},{match:n=>n==="anthropic",key:"dialog.provider.anthropic.note"},{match:n=>n.startsWith("github-copilot"),key:"dialog.provider.copilot.note"},{match:n=>n==="openai",key:"dialog.provider.openai.note"},{match:n=>n==="google",key:"dialog.provider.google.note"},{match:n=>n==="openrouter",key:"dialog.provider.openrouter.note"},{match:n=>n==="vercel",key:"dialog.provider.vercel.note"}],Sn=()=>{const n=Ee(),e=se(),l=ye(),s=we(),g=ht(),a=Ne(),[k]=ve(async()=>{const m={},c=a.current;c?.http.password&&(m.Authorization=`Basic ${Fe({username:c.http.username,password:c.http.password})}`);const b=await fetch(`${l.url}/global/onescience-preset/status`,{headers:m});return b.ok?await b.json():{adminEnabled:!1,modelEnabled:!1}}),_=N(()=>g.connected().filter(m=>m.id!=="opencode"||Object.values(m.models).find(c=>c.cost?.input))),$=N(()=>{const m=new Set(_().map(b=>b.id)),c=g.popular().filter(b=>!m.has(b.id)).slice();return c.sort((b,E)=>de.indexOf(b.id)-de.indexOf(E.id)),c}),x=m=>{if(!("source"in m))return;const c=m.source;if(c==="env"||c==="api"||c==="config"||c==="custom")return c},C=m=>{if(m.id===me)return e.t("settings.providers.tag.limited");const c=x(m);return c==="env"?e.t("settings.providers.tag.environment"):c==="api"?e.t("provider.connect.method.apiKey"):c==="config"?T(m.id)?e.t("settings.providers.tag.custom"):e.t("settings.providers.tag.config"):c==="custom"?e.t("settings.providers.tag.custom"):e.t("settings.providers.tag.other")},K=m=>m.id!==me&&x(m)!=="env",G=m=>kn.find(c=>c.match(m))?.key,T=m=>{const c=s.data.config.provider?.[m];return!(!c||c.npm!=="@ai-sdk/openai-compatible"||!c.models||Object.keys(c.models).length===0)},F=async(m,c)=>{const b=s.data.config.disabled_providers??[],E=b.includes(m)?b:[...b,m];s.set("config","disabled_providers",E),await s.updateConfig({disabled_providers:E}).then(()=>{R({variant:"success",icon:"circle-check",title:e.t("provider.disconnect.toast.disconnected.title",{provider:c}),description:e.t("provider.disconnect.toast.disconnected.description",{provider:c})})}).catch(z=>{s.set("config","disabled_providers",b);const P=z instanceof Error?z.message:String(z);R({title:e.t("common.requestFailed"),description:P})})},B=async(m,c)=>{if(T(m)){await l.client.auth.remove({providerID:m}).catch(()=>{}),await F(m,c),await l.client.global.dispose().catch(()=>{}),await s.reload();return}await l.client.auth.remove({providerID:m}).then(async()=>{await l.client.global.dispose(),await s.reload(),R({variant:"success",icon:"circle-check",title:e.t("provider.disconnect.toast.disconnected.title",{provider:c}),description:e.t("provider.disconnect.toast.disconnected.description",{provider:c})})}).catch(b=>{const E=b instanceof Error?b.message:String(b);R({title:e.t("common.requestFailed"),description:E})})};return(()=>{var m=bn(),c=m.firstChild,b=c.firstChild,E=b.firstChild,z=c.nextSibling,P=z.firstChild,L=P.firstChild,d=P.nextSibling,f=d.firstChild;return r(E,()=>e.t("settings.providers.title")),r(L,()=>e.t("settings.providers.section.connected")),r(P,t(q,{get children(){return t(j,{get when(){return _().length>0},get fallback(){return(()=>{var u=xn();return r(u,()=>e.t("settings.providers.connected.empty")),u})()},get children(){return t(re,{get each(){return _()},children:u=>(()=>{var D=wn(),y=D.firstChild,A=y.firstChild;return r(y,t(ce,{get id(){return u.id},class:"size-5 shrink-0 icon-strong-base"}),A),r(A,()=>u.name),r(y,t(oe,{get children(){return C(u)}}),null),r(D,t(j,{get when(){return K(u)},get fallback(){return(()=>{var I=yn();return r(I,(()=>{var M=W(()=>u.id===me);return()=>M()?e.t("settings.providers.onescience.readonlyHint"):e.t("settings.providers.connected.environmentDescription")})()),I})()},get children(){return t(H,{size:"large",variant:"ghost",onClick:()=>void B(u.id,u.name),get children(){return e.t("common.disconnect")}})}}),null),D})()})}})}}),null),r(f,()=>e.t("settings.providers.section.popular")),r(d,t(q,{get children(){return[t(re,{get each(){return $()},children:u=>(()=>{var D=$n(),y=D.firstChild,A=y.firstChild,I=A.firstChild;return r(A,t(ce,{get id(){return u.id},class:"size-5 shrink-0 icon-strong-base"}),I),r(I,()=>u.name),r(A,t(j,{get when(){return u.id==="opencode"},get children(){return t(oe,{get children(){return e.t("dialog.provider.tag.recommended")}})}}),null),r(A,t(j,{get when(){return u.id==="opencode-go"},get children(){return t(oe,{get children(){return e.t("dialog.provider.tag.recommended")}})}}),null),r(y,t(j,{get when(){return G(u.id)},children:M=>(()=>{var Y=_n();return r(Y,()=>e.t(M())),Y})()}),null),r(D,t(H,{size:"large",variant:"secondary",icon:"plus-small",onClick:()=>{n.show(()=>t(xt,{get provider(){return u.id}}))},get children(){return e.t("common.connect")}}),null),D})()}),(()=>{var u=mn(),D=u.firstChild,y=D.firstChild,A=y.firstChild,I=y.nextSibling;return r(y,t(ce,{id:"synthetic",class:"size-5 shrink-0 icon-strong-base"}),A),r(A,()=>e.t("provider.custom.title")),r(y,t(oe,{get children(){return e.t("settings.providers.tag.custom")}}),null),r(I,()=>e.t("settings.providers.custom.description")),r(u,t(H,{size:"large",variant:"secondary",icon:"plus-small",onClick:()=>{n.show(()=>t(wt,{back:"close"}))},get children(){return e.t("common.connect")}}),null),u})()]}}),null),r(d,t(H,{variant:"ghost",class:"px-0 py-0 mt-5 text-14-medium text-text-interactive-base text-left justify-start hover:bg-transparent active:bg-transparent",onClick:()=>{n.show(()=>t(yt,{}))},get children(){return e.t("dialog.provider.viewAll")}}),null),r(z,t(j,{get when(){return k()?.adminEnabled},get children(){var u=vn();return r(u,t(H,{size:"large",variant:"secondary",onClick:()=>n.show(()=>t(hn,{})),get children(){return e.t("settings.providers.onescience.admin.button")}})),u}}),null),m})()};var Ie=h('<div class="flex flex-col items-center justify-center py-12 text-center"><span class="text-14-regular text-text-weak">'),Cn=h('<span class="text-14-regular text-text-strong mt-1">&quot;<!>&quot;'),Pn=h('<div class="flex flex-col h-full overflow-y-auto no-scrollbar px-4 pb-10 sm:px-10 sm:pb-10"><div class="sticky top-0 z-10 bg-[linear-gradient(to_bottom,var(--surface-stronger-non-alpha)_calc(100%_-_24px),transparent)]"><div class="flex flex-col gap-4 pt-6 pb-6 max-w-[720px]"><h2 class="text-16-medium text-text-strong"></h2><div class="flex items-center gap-2 px-3 h-9 rounded-lg bg-surface-base"></div></div></div><div class="flex flex-col gap-8 max-w-[720px]">'),Tn=h('<div class="flex flex-col gap-1"><div class="flex items-center gap-2 pb-2"><span class="text-14-medium text-text-strong">'),Dn=h('<div class="flex flex-wrap items-center justify-between gap-4 py-3 border-b border-border-weak-base last:border-none"><div class=min-w-0><span class="text-14-regular text-text-strong truncate block"></span></div><div class=flex-shrink-0>');const An=n=>(()=>{var e=Ie(),l=e.firstChild;return r(l,()=>n.label),e})(),En=n=>(()=>{var e=Ie(),l=e.firstChild;return r(l,()=>n.message),r(e,t(j,{get when(){return n.filter},get children(){var s=Cn(),g=s.firstChild,a=g.nextSibling;return a.nextSibling,r(s,()=>n.filter,a),s}}),null),e})(),Nn=()=>{const n=se(),e=mt(),l=vt({items:s=>e.list(),key:s=>`${s.provider.id}:${s.id}`,filterKeys:["provider.name","name","id"],sortBy:(s,g)=>s.name.localeCompare(g.name),groupBy:s=>s.provider.id,sortGroupsBy:(s,g)=>{const a=de.indexOf(s.category),k=de.indexOf(g.category),_=a>=0,$=k>=0;if(_&&!$)return-1;if(!_&&$)return 1;if(_&&$)return a-k;const x=s.items[0].provider.name,C=g.items[0].provider.name;return x.localeCompare(C)}});return(()=>{var s=Pn(),g=s.firstChild,a=g.firstChild,k=a.firstChild,_=k.nextSibling,$=g.nextSibling;return r(k,()=>n.t("settings.models.title")),r(_,t(Q,{name:"magnifying-glass",class:"text-icon-weak-base flex-shrink-0"}),null),r(_,t(V,{variant:"ghost",type:"text",get value(){return l.filter()},get onChange(){return l.onInput},get placeholder(){return n.t("dialog.model.search.placeholder")},spellcheck:!1,autocorrect:"off",autocomplete:"off",autocapitalize:"off",class:"flex-1"}),null),r(_,t(j,{get when(){return l.filter()},get children(){return t($e,{icon:"circle-x",variant:"ghost",get onClick(){return l.clear}})}}),null),r($,t(j,{get when(){return!l.grouped.loading},get fallback(){return t(An,{get label(){return`${n.t("common.loading")}${n.t("common.loading.ellipsis")}`}})},get children(){return t(j,{get when(){return l.flat().length>0},get fallback(){return t(En,{get message(){return n.t("dialog.model.empty")},get filter(){return l.filter()}})},get children(){return t(re,{get each(){return l.grouped.latest},children:x=>(()=>{var C=Tn(),K=C.firstChild,G=K.firstChild;return r(K,t(ce,{get id(){return x.category},class:"size-5 shrink-0 icon-strong-base"}),G),r(G,()=>x.items[0].provider.name),r(C,t(q,{get children(){return t(re,{get each(){return x.items},children:T=>{const F={providerID:T.provider.id,modelID:T.id};return(()=>{var B=Dn(),m=B.firstChild,c=m.firstChild,b=m.nextSibling;return r(c,()=>T.name),r(b,t(O,{get checked(){return e.visible(F)},onChange:E=>{e.setVisibility(F,E)},hideLabel:!0,get children(){return T.name}})),B})()}})}}),null),C})()})}})}})),s})()};var Kn=h('<div class="flex flex-col justify-between h-full w-full"><div class="flex flex-col gap-3 w-full pt-3"><div class="flex flex-col gap-3"><div class="flex flex-col gap-1.5"><div class="flex flex-col gap-1.5 w-full"></div></div><div class="flex flex-col gap-1.5"><div class="flex flex-col gap-1.5 w-full"></div></div></div></div><div class="flex flex-col gap-1 pl-1 py-1 text-12-medium text-text-weak"><span></span><span class=text-11-regular>v');const jn=()=>{const n=se(),e=Ce();return t(Ke,{size:"x-large",transition:!0,get children(){return t(U,{orientation:"vertical",variant:"settings",defaultValue:"general",class:"h-full settings-dialog",get children(){return[t(U.List,{get children(){var l=Kn(),s=l.firstChild,g=s.firstChild,a=g.firstChild,k=a.firstChild,_=a.nextSibling,$=_.firstChild,x=s.nextSibling,C=x.firstChild,K=C.nextSibling;return K.firstChild,r(a,t(U.SectionTitle,{get children(){return n.t("settings.section.desktop")}}),k),r(k,t(U.Trigger,{value:"general",get children(){return[t(Q,{name:"sliders"}),W(()=>n.t("settings.tab.general"))]}}),null),r(k,t(U.Trigger,{value:"shortcuts",get children(){return[t(Q,{name:"keyboard"}),W(()=>n.t("settings.tab.shortcuts"))]}}),null),r(_,t(U.SectionTitle,{get children(){return n.t("settings.section.server")}}),$),r($,t(U.Trigger,{value:"providers",get children(){return[t(Q,{name:"providers"}),W(()=>n.t("settings.providers.title"))]}}),null),r($,t(U.Trigger,{value:"models",get children(){return[t(Q,{name:"models"}),W(()=>n.t("settings.models.title"))]}}),null),r(C,()=>n.t("app.name.desktop")),r(K,()=>e.version,null),l}}),t(U.Content,{value:"general",class:"no-scrollbar",get children(){return t(Gt,{})}}),t(U.Content,{value:"shortcuts",class:"no-scrollbar",get children(){return t(on,{})}}),t(U.Content,{value:"providers",class:"no-scrollbar",get children(){return t(Sn,{})}}),t(U.Content,{value:"models",class:"no-scrollbar",get children(){return t(Nn,{})}})]}})}})};export{jn as DialogSettings};