@nextclaw/ui 0.5.34 → 0.5.35
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.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/dist/assets/ChannelsList-DGoIQT1t.js +1 -0
- package/dist/assets/{ChatPage-BSD-DBqC.js → ChatPage-C_wANEY9.js} +1 -1
- package/dist/assets/{CronConfig-JLIc66HM.js → CronConfig-Q7faThLl.js} +1 -1
- package/dist/assets/{DocBrowser-BCJjJTr9.js → DocBrowser-CdX5oDgu.js} +1 -1
- package/dist/assets/{MarketplacePage-ftvI9vFu.js → MarketplacePage-DXoPkFYk.js} +1 -1
- package/dist/assets/{ModelConfig-iD7V4upL.js → ModelConfig-DagIPD4R.js} +1 -1
- package/dist/assets/{ProvidersList-moYj5oBN.js → ProvidersList-2aHarRNe.js} +1 -1
- package/dist/assets/{RuntimeConfig-CvWztear.js → RuntimeConfig-BDyqfVSA.js} +1 -1
- package/dist/assets/{SecretsConfig-Ds5xip01.js → SecretsConfig-De2IZ7GX.js} +1 -1
- package/dist/assets/{SessionsConfig-CCbracj_.js → SessionsConfig-BK0xx6EF.js} +1 -1
- package/dist/assets/{card-CB1zsVbS.js → card-CWG4Tz0Y.js} +1 -1
- package/dist/assets/{dialog-BgbSAXFu.js → dialog-ssdjbutm.js} +1 -1
- package/dist/assets/{index-O1Kus7pd.js → index-q2B1bssI.js} +2 -2
- package/dist/assets/{label-d0bFiiuu.js → label-LbWa2Yzc.js} +1 -1
- package/dist/assets/{logos-gjlYO0d_.js → logos-DncMldHC.js} +1 -1
- package/dist/assets/{page-layout-Cf2nfjrs.js → page-layout-Bz8CAEiD.js} +1 -1
- package/dist/assets/{switch-CfELV89t.js → switch-BwbfObfA.js} +1 -1
- package/dist/assets/{tabs-custom-CJdhCvOt.js → tabs-custom-VeX6BYro.js} +1 -1
- package/dist/assets/{useConfig-DnBXFnGL.js → useConfig-CFFZ66EV.js} +1 -1
- package/dist/assets/{useConfirmDialog-c4_c0EGk.js → useConfirmDialog-ClpvgpHh.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/api/types.ts +5 -0
- package/src/components/config/ChannelForm.tsx +15 -2
- package/src/components/config/ChannelsList.tsx +4 -4
- package/src/lib/channel-tutorials.ts +8 -0
- package/dist/assets/ChannelsList-DvhJoVmJ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as c,F as Q,g as V,m as X,s as Z,J as H,O as ee,U as se}from"./vendor-CmqkRoMs.js";import{P as te,a as ae,B as re}from"./page-layout-
|
|
1
|
+
import{j as e,r as c,F as Q,g as V,m as X,s as Z,J as H,O as ee,U as se}from"./vendor-CmqkRoMs.js";import{P as te,a as ae,B as re}from"./page-layout-Bz8CAEiD.js";import{C as _}from"./card-CWG4Tz0Y.js";import{I as q,u as ne,a as le,b as oe,c as ie}from"./useConfig-CFFZ66EV.js";import{L as $}from"./label-LbWa2Yzc.js";import{c as B,t as x,S as ce,a as de,b as me,d as xe,e as ue,D as he,f as fe}from"./index-q2B1bssI.js";import{h as A}from"./config-hints-CApS3K_7.js";function u({className:a,...n}){return e.jsx("div",{className:B("animate-pulse rounded-md bg-slate-200",a),...n})}function pe(a){const n=new Set;for(const r of a){const l=r.trim();l.length>0&&n.add(l)}return[...n]}function ge({id:a,value:n,onChange:r,options:l,placeholder:d,className:j,inputClassName:m,emptyText:S,createText:b,maxItems:C=Number.POSITIVE_INFINITY,onEnter:k}){const[v,h]=c.useState(!1),N=c.useMemo(()=>pe(l),[l]),i=n.trim().toLowerCase(),f=c.useMemo(()=>{const t=N.map((o,w)=>({option:o,index:w}));i.length>0&&t.sort((o,w)=>{const y=o.option.toLowerCase(),M=w.option.toLowerCase(),L=y===i?0:y.startsWith(i)?1:y.includes(i)?2:3,I=M===i?0:M.startsWith(i)?1:M.includes(i)?2:3;return L!==I?L-I:o.index-w.index});const g=t.map(o=>o.option);return Number.isFinite(C)?g.slice(0,Math.max(1,C)):g},[N,i,C]),P=n.trim().length>0&&N.some(t=>t===n.trim());return e.jsxs("div",{className:B("relative",j),onBlur:()=>{setTimeout(()=>h(!1),120)},children:[e.jsx(q,{id:a,value:n,onFocus:()=>h(!0),onChange:t=>{r(t.target.value),v||h(!0)},onKeyDown:t=>{t.key==="Enter"&&(k&&(t.preventDefault(),k()),h(!1))},placeholder:d,className:B("pr-10",m)}),e.jsx("button",{type:"button",onMouseDown:t=>t.preventDefault(),onClick:()=>h(t=>!t),className:"absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center text-gray-400 hover:text-gray-600","aria-label":"toggle model options",children:e.jsx(Q,{className:"h-4 w-4"})}),v&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!P&&n.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:t=>t.preventDefault(),onClick:()=>{r(n.trim()),h(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(V,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:b?b.replace("{value}",n.trim()):n.trim()})]}),f.map(t=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{r(t),h(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(V,{className:B("h-4 w-4",t===n.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:t})]},t)),f.length===0&&n.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:S??"No models available"})]})})]})}function z(a){if(!a||a.length===0)return[];const n=new Set;for(const r of a){const l=r.trim();l&&n.add(l)}return[...n]}function je(a,n){const r=a.trim(),l=n.trim();if(!r||!l)return r;const d=`${l}/`;return r.startsWith(d)?r.slice(d.length):r}function T(a,n){let r=a.trim();if(!r)return"";for(const l of n)r=je(r,l);return r.trim()}function Ne(a,n){const r=a.trim();if(!r)return null;let l=null;for(const d of n)for(const j of d.aliases){const m=j.trim();m&&(r===m||r.startsWith(`${m}/`))&&(!l||m.length>l.score)&&(l={name:d.name,score:m.length})}return(l==null?void 0:l.name)??null}function ke(){const{data:a,isLoading:n}=ne(),{data:r}=le(),{data:l}=oe(),d=ie(),[j,m]=c.useState(""),[S,b]=c.useState(""),[C,k]=c.useState(""),[v,h]=c.useState(8192),N=l==null?void 0:l.uiHints,i=A("agents.defaults.model",N),f=A("agents.defaults.workspace",N),P=A("agents.defaults.maxTokens",N),t=c.useMemo(()=>((r==null?void 0:r.providers)??[]).map(s=>{var D,R;const O=(s.modelPrefix||s.name||"").trim(),p=z([s.modelPrefix||"",s.name||""]),U=z((s.defaultModels??[]).map(W=>T(W,p))),F=z((((R=(D=a==null?void 0:a.providers)==null?void 0:D[s.name])==null?void 0:R.models)??[]).map(W=>T(W,p))),E=z([...U,...F]);return{name:s.name,displayName:s.displayName||s.name,prefix:O,aliases:p,models:E}}),[r,a]),g=c.useMemo(()=>new Map(t.map(s=>[s.name,s])),[t]),o=g.get(j)??t[0],w=(o==null?void 0:o.name)??"",y=c.useMemo(()=>(o==null?void 0:o.aliases)??[],[o]),M=c.useMemo(()=>(o==null?void 0:o.models)??[],[o]);c.useEffect(()=>{j||t.length===0||m(t[0].name)},[j,t]),c.useEffect(()=>{var F,E,D;if(!((F=a==null?void 0:a.agents)!=null&&F.defaults))return;const s=(a.agents.defaults.model||"").trim(),p=Ne(s,t)??((E=t[0])==null?void 0:E.name)??"",U=((D=g.get(p))==null?void 0:D.aliases)??[];m(p),b(T(s,U)),k(a.agents.defaults.workspace||""),h(a.agents.defaults.maxTokens||8192)},[a,t,g]);const L=c.useMemo(()=>{const s=new Set;for(const O of M){const p=O.trim();p&&s.add(p)}return[...s]},[M]),I=c.useMemo(()=>{const s=T(S,y);return s?!o||!o.prefix?s:`${o.prefix}/${s}`:""},[S,o,y]),G=(i==null?void 0:i.help)??"",J=s=>{m(s),b("")},K=s=>{b(T(s,y))},Y=s=>{s.preventDefault(),d.mutate({model:I,maxTokens:v})};return n?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(_,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(_,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-3 w-40 mb-6"}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx(u,{className:"h-4 w-28 mb-3"}),e.jsx(u,{className:"h-2 w-full rounded-full"})]})})]})]}):e.jsxs(te,{children:[e.jsx(ae,{title:x("modelPageTitle"),description:x("modelPageDescription")}),e.jsxs("form",{onSubmit:Y,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(X,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:x("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(i==null?void 0:i.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(ce,{value:w,onValueChange:J,children:[e.jsx(de,{className:"h-10 w-full rounded-xl",children:e.jsx(me,{placeholder:x("providersSelectPlaceholder")})}),e.jsx(xe,{children:t.map(s=>e.jsx(ue,{value:s.name,children:s.displayName},s.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(ge,{id:"model",value:S,onChange:K,options:L,placeholder:(i==null?void 0:i.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:x("modelPickerNoOptions"),createText:x("modelPickerUseCustom")},w)]}),e.jsx("p",{className:"text-xs text-gray-400",children:G}),e.jsxs("a",{href:`${he}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(Z,{className:"h-3.5 w-3.5"}),x("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(H,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:x("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(f==null?void 0:f.label)??"Default Path"}),e.jsx(q,{id:"workspace",value:C,onChange:s=>k(s.target.value),placeholder:(f==null?void 0:f.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-10",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(ee,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:x("generationParameters")})]}),e.jsx("div",{className:"grid grid-cols-1 gap-12",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx($,{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(P==null?void 0:P.label)??x("maxTokens")}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:fe(v)})]}),e.jsx("input",{type:"range",min:"1000",max:"32000",step:"1000",value:v,onChange:s=>h(parseInt(s.target.value)),className:"w-full h-1 bg-gray-200 rounded-full appearance-none cursor-pointer accent-primary"})]})})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(re,{type:"submit",disabled:d.isPending,size:"lg",children:d.isPending?e.jsx(se,{className:"h-5 w-5 animate-spin"}):x("saveChanges")})})]})]})}export{ke as ModelConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,aa as ue,ab as he,a8 as pe,a6 as te,K as ae,a1 as fe,ac as ee,m as ye,ad as ge,ae as je,af as be,ag as U,a0 as we}from"./vendor-CmqkRoMs.js";import{I as B,u as re,a as ne,b as le,g as ve,h as Ne}from"./useConfig-DnBXFnGL.js";import{B as K,P as Ae,a as Pe}from"./page-layout-Cf2nfjrs.js";import{L as W}from"./label-d0bFiiuu.js";import{t as a,c as V,S as Ce,a as Ee,b as Me,d as Ke,e as Le}from"./index-O1Kus7pd.js";import{S as ie,L as Se,g as Te}from"./logos-gjlYO0d_.js";import{h as O}from"./config-hints-CApS3K_7.js";import{T as Be}from"./tabs-custom-CJdhCvOt.js";function $e({maskedValue:s,isSet:t,className:n,...i}){const[u,g]=p.useState(!1);return e.jsxs("div",{className:"relative",children:[e.jsx(B,{type:u?"text":"password",className:V("pr-20",n),placeholder:t?`${a("apiKeySet")} (${a("unchanged")})`:"",...i}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||s)&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g(!u),children:u?e.jsx(ue,{className:"h-4 w-4"}):e.jsx(he,{className:"h-4 w-4"})})})]})}function ke({value:s,onChange:t,className:n}){const i=s?Object.entries(s):[],u=(m,f,j)=>{const y=[...i];y[m]=[f,j],t(Object.fromEntries(y))},g=()=>{t({...s,"":""})},h=m=>{const f=i.filter((j,y)=>y!==m);t(Object.fromEntries(f))};return e.jsxs("div",{className:V("space-y-2",n),children:[i.map(([m,f],j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{type:"text",value:m,onChange:y=>u(j,y.target.value,f),placeholder:a("headerName"),className:"flex-1"}),e.jsx(B,{type:"text",value:f,onChange:y=>u(j,m,y.target.value),placeholder:a("headerValue"),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>h(j),children:e.jsx(pe,{className:"h-4 w-4 text-red-500"})})]},j)),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(te,{className:"h-4 w-4 mr-2"}),a("add")]})]})}function z(s){if(!s)return null;const t=Object.entries(s).map(([n,i])=>[n.trim(),i]).filter(([n])=>n.length>0);return t.length===0?null:Object.fromEntries(t)}function se(s,t){const n=z(s),i=z(t);if(n===null&&i===null)return!0;if(!n||!i)return!1;const u=Object.entries(n).sort(([h],[m])=>h.localeCompare(m)),g=Object.entries(i).sort(([h],[m])=>h.localeCompare(m));return u.length!==g.length?!1:u.every(([h,m],f)=>h===g[f][0]&&m===g[f][1])}function _(s){if(!s||s.length===0)return[];const t=new Set;for(const n of s){const i=n.trim();i&&t.add(i)}return[...t]}function De(s,t){const n=s.trim();if(!n||!t.trim())return n;const i=`${t.trim()}/`;return n.startsWith(i)?n.slice(i.length):n}function G(s,t){let n=s.trim();if(!n)return"";for(const i of t){const u=i.trim();u&&(n=De(n,u))}return n.trim()}function Q(s,t){return s.length!==t.length?!1:s.every((n,i)=>n===t[i])}function Fe(s,t){const n=[...s];for(const i of t)n.includes(i)||n.push(i);return n}function We(s,t){return t.length===0?s:t.every(i=>!s.includes(i))?Fe(s,t):t}function Oe(s,t){return Q(s,t)?[]:s}function ze({providerName:s}){const{data:t}=re(),{data:n}=ne(),{data:i}=le(),u=ve(),g=Ne(),[h,m]=p.useState(""),[f,j]=p.useState(""),[y,L]=p.useState(null),[A,S]=p.useState("auto"),[b,P]=p.useState([]),[d,x]=p.useState(""),r=n==null?void 0:n.providers.find(l=>l.name===s),c=s?t==null?void 0:t.providers[s]:null,w=i==null?void 0:i.uiHints,C=s?O(`providers.${s}.apiKey`,w):void 0,N=s?O(`providers.${s}.apiBase`,w):void 0,E=s?O(`providers.${s}.extraHeaders`,w):void 0,M=s?O(`providers.${s}.wireApi`,w):void 0,ce=(r==null?void 0:r.displayName)||s||a("providersSelectPlaceholder"),X=(r==null?void 0:r.modelPrefix)||s||"",$=p.useMemo(()=>_([X,s||""]),[X,s]),R=(r==null?void 0:r.defaultApiBase)||"",k=(c==null?void 0:c.apiBase)||R,q=z((c==null?void 0:c.extraHeaders)||null),D=(c==null?void 0:c.wireApi)||(r==null?void 0:r.defaultWireApi)||"auto",I=p.useMemo(()=>_(((r==null?void 0:r.defaultModels)??[]).map(l=>G(l,$))),[r==null?void 0:r.defaultModels,$]),J=p.useMemo(()=>_(((c==null?void 0:c.models)??[]).map(l=>G(l,$))),[c==null?void 0:c.models,$]),F=p.useMemo(()=>We(I,J),[I,J]);p.useEffect(()=>{if(!s){m(""),j(""),L(null),S("auto"),P([]),x("");return}m(""),j(k),L((c==null?void 0:c.extraHeaders)||null),S(D),P(F),x("")},[s,k,c==null?void 0:c.extraHeaders,D,F]);const Y=p.useMemo(()=>{if(!s)return!1;const l=h.trim().length>0,o=f.trim()!==k.trim(),v=!se(y,q),T=r!=null&&r.supportsWireApi?A!==D:!1,H=!Q(b,F);return l||o||v||T||H},[s,h,f,k,y,q,r==null?void 0:r.supportsWireApi,A,D,b,F]),oe=()=>{m(""),j(R),L(null),S((r==null?void 0:r.defaultWireApi)||"auto"),P(I),x("")},Z=()=>{const l=G(d,$);if(l){if(b.includes(l)){x("");return}P(o=>[...o,l]),x("")}},de=l=>{if(l.preventDefault(),!s)return;const o={},v=h.trim(),T=f.trim(),H=z(y);v.length>0&&(o.apiKey=v),T!==k.trim()&&(o.apiBase=T.length>0&&T!==R?T:null),se(H,q)||(o.extraHeaders=H),r!=null&&r.supportsWireApi&&A!==D&&(o.wireApi=A),Q(b,F)||(o.models=Oe(b,I)),u.mutate({provider:s,data:o})},me=async()=>{if(!s)return;const l={apiBase:f.trim(),extraHeaders:z(y),model:(t==null?void 0:t.agents.defaults.model)??null};h.trim().length>0&&(l.apiKey=h.trim()),r!=null&&r.supportsWireApi&&(l.wireApi=A);try{const o=await g.mutateAsync({provider:s,data:l});if(o.success){U.success(`${a("providerTestConnectionSuccess")} (${o.latencyMs}ms)`);return}const v=[`provider=${o.provider}`,`latency=${o.latencyMs}ms`];o.model&&v.push(`model=${o.model}`),U.error(`${a("providerTestConnectionFailed")}: ${o.message} | ${v.join(" | ")}`)}catch(o){const v=o instanceof Error?o.message:String(o);U.error(`${a("providerTestConnectionFailed")}: ${v}`)}};if(!s||!r||!c)return e.jsx("div",{className:"flex min-h-[520px] items-center justify-center rounded-2xl border border-gray-200/70 bg-white px-6 text-center xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:a("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:a("providersSelectDescription")})]})});const xe=c.apiKeySet?a("statusReady"):a("statusSetup");return e.jsxs("div",{className:"flex min-h-[520px] flex-col rounded-2xl border border-gray-200/70 bg-white shadow-card xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-5",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:ce}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:a("providerFormDescription")})]}),e.jsx(ie,{status:c.apiKeySet?"ready":"setup",label:xe})]})}),e.jsxs("form",{onSubmit:de,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-y-auto px-6 py-5",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{htmlFor:"apiKey",className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ae,{className:"h-3.5 w-3.5 text-gray-500"}),(C==null?void 0:C.label)??a("apiKey")]}),e.jsx($e,{id:"apiKey",value:h,isSet:c.apiKeySet,onChange:l=>m(l.target.value),placeholder:c.apiKeySet?a("apiKeySet"):(C==null?void 0:C.placeholder)??a("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:a("leaveBlankToKeepUnchanged")})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{htmlFor:"apiBase",className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(fe,{className:"h-3.5 w-3.5 text-gray-500"}),(N==null?void 0:N.label)??a("apiBase")]}),e.jsx(B,{id:"apiBase",type:"text",value:f,onChange:l=>j(l.target.value),placeholder:R||(N==null?void 0:N.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:(N==null?void 0:N.help)||a("providerApiBaseHelp")})]}),r.supportsWireApi&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{htmlFor:"wireApi",className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ee,{className:"h-3.5 w-3.5 text-gray-500"}),(M==null?void 0:M.label)??a("wireApi")]}),e.jsxs(Ce,{value:A,onValueChange:l=>S(l),children:[e.jsx(Ee,{className:"rounded-xl",children:e.jsx(Me,{})}),e.jsx(Ke,{children:(r.wireApiOptions||["auto","chat","responses"]).map(l=>e.jsx(Le,{value:l,children:l==="chat"?a("wireApiChat"):l==="responses"?a("wireApiResponses"):a("wireApiAuto")},l))})]}),(M==null?void 0:M.help)&&e.jsx("p",{className:"text-xs text-gray-500",children:M.help})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ee,{className:"h-3.5 w-3.5 text-gray-500"}),(E==null?void 0:E.label)??a("extraHeaders")]}),e.jsx(ke,{value:y,onChange:L}),e.jsx("p",{className:"text-xs text-gray-500",children:(E==null?void 0:E.help)||a("providerExtraHeadersHelp")})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ye,{className:"h-3.5 w-3.5 text-gray-500"}),a("providerModelsTitle")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{value:d,onChange:l=>x(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),Z())},placeholder:a("providerModelInputPlaceholder"),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",onClick:Z,disabled:d.trim().length===0,children:[e.jsx(te,{className:"mr-1.5 h-4 w-4"}),a("providerAddModel")]})]}),b.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:a("providerModelsEmpty")}):e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(l=>e.jsxs("div",{className:"group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5",children:[e.jsx("span",{className:"max-w-[180px] truncate text-sm text-gray-800 sm:max-w-[240px]",children:l}),e.jsx("button",{type:"button",onClick:()=>P(o=>o.filter(v=>v!==l)),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":a("remove"),children:e.jsx(ge,{className:"h-3 w-3"})})]},l))}),e.jsx("p",{className:"text-xs text-gray-500",children:a("providerModelsHelp")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-gray-100 px-6 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:oe,children:[e.jsx(je,{className:"mr-2 h-4 w-4"}),a("resetToDefault")]}),e.jsxs(K,{type:"button",variant:"outline",onClick:me,disabled:g.isPending,children:[e.jsx(be,{className:"mr-2 h-4 w-4"}),g.isPending?a("providerTestingConnection"):a("providerTestConnection")]})]}),e.jsx(K,{type:"submit",disabled:u.isPending||!Y,children:u.isPending?a("saving"):Y?a("save"):a("unchanged")})]})]})]})}function Re(s){if(!s)return null;try{const t=new URL(s),n=t.pathname&&t.pathname!=="/"?t.pathname:"";return`${t.host}${n}`}catch{return s.replace(/^https?:\/\//,"")}}function Xe(){const{data:s}=re(),{data:t}=ne(),{data:n}=le(),[i,u]=p.useState("installed"),[g,h]=p.useState(),[m,f]=p.useState(""),j=n==null?void 0:n.uiHints,y=(t==null?void 0:t.providers)??[],L=(s==null?void 0:s.providers)??{},A=y.filter(d=>{var x;return(x=L[d.name])==null?void 0:x.apiKeySet}).length,S=[{id:"installed",label:a("providersTabConfigured"),count:A},{id:"all",label:a("providersTabAll"),count:y.length}],b=p.useMemo(()=>{const d=(t==null?void 0:t.providers)??[],x=(s==null?void 0:s.providers)??{},r=m.trim().toLowerCase();return d.filter(c=>{var w;return i==="installed"?!!((w=x[c.name])!=null&&w.apiKeySet):!0}).filter(c=>r?(c.displayName||c.name).toLowerCase().includes(r)||c.name.toLowerCase().includes(r):!0)},[t,s,i,m]);p.useEffect(()=>{if(b.length===0){h(void 0);return}b.some(x=>x.name===g)||h(b[0].name)},[b,g]);const P=g;return!s||!t?e.jsx("div",{className:"p-8",children:a("providersLoading")}):e.jsxs(Ae,{children:[e.jsx(Pe,{title:a("providersPageTitle"),description:a("providersPageDescription")}),e.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-[340px_minmax(0,1fr)]",children:[e.jsxs("section",{className:"flex min-h-[520px] flex-col rounded-2xl border border-gray-200/70 bg-white shadow-card xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",children:[e.jsx("div",{className:"border-b border-gray-100 px-4 pt-4",children:e.jsx(Be,{tabs:S,activeTab:i,onChange:u,className:"mb-0"})}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(we,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(B,{value:m,onChange:d=>f(d.target.value),placeholder:a("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[b.map(d=>{const x=s.providers[d.name],r=!!(x!=null&&x.apiKeySet),c=P===d.name,w=O(`providers.${d.name}`,j),C=(x==null?void 0:x.apiBase)||d.defaultApiBase||"",E=Re(C)||(w==null?void 0:w.help)||a("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>h(d.name),className:V("w-full rounded-xl border p-2.5 text-left transition-all",c?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Se,{name:d.name,src:Te(d.name),className:V("h-10 w-10 rounded-lg border",r?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:d.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:d.displayName||d.name}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:E})]})]}),e.jsx(ie,{status:r?"ready":"setup",label:r?a("statusReady"):a("statusSetup"),className:"min-w-[56px] justify-center"})]})},d.name)}),b.length===0&&e.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(ae,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:a("providersNoMatch")})]})]})]}),e.jsx(ze,{providerName:P})]})]})}export{Xe as ProvidersList};
|
|
1
|
+
import{r as p,j as e,aa as ue,ab as he,a8 as pe,a6 as te,K as ae,a1 as fe,ac as ee,m as ye,ad as ge,ae as je,af as be,ag as U,a0 as we}from"./vendor-CmqkRoMs.js";import{I as B,u as re,a as ne,b as le,g as ve,h as Ne}from"./useConfig-CFFZ66EV.js";import{B as K,P as Ae,a as Pe}from"./page-layout-Bz8CAEiD.js";import{L as W}from"./label-LbWa2Yzc.js";import{t as a,c as V,S as Ce,a as Ee,b as Me,d as Ke,e as Le}from"./index-q2B1bssI.js";import{S as ie,L as Se,g as Te}from"./logos-DncMldHC.js";import{h as O}from"./config-hints-CApS3K_7.js";import{T as Be}from"./tabs-custom-VeX6BYro.js";function $e({maskedValue:s,isSet:t,className:n,...i}){const[u,g]=p.useState(!1);return e.jsxs("div",{className:"relative",children:[e.jsx(B,{type:u?"text":"password",className:V("pr-20",n),placeholder:t?`${a("apiKeySet")} (${a("unchanged")})`:"",...i}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||s)&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g(!u),children:u?e.jsx(ue,{className:"h-4 w-4"}):e.jsx(he,{className:"h-4 w-4"})})})]})}function ke({value:s,onChange:t,className:n}){const i=s?Object.entries(s):[],u=(m,f,j)=>{const y=[...i];y[m]=[f,j],t(Object.fromEntries(y))},g=()=>{t({...s,"":""})},h=m=>{const f=i.filter((j,y)=>y!==m);t(Object.fromEntries(f))};return e.jsxs("div",{className:V("space-y-2",n),children:[i.map(([m,f],j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{type:"text",value:m,onChange:y=>u(j,y.target.value,f),placeholder:a("headerName"),className:"flex-1"}),e.jsx(B,{type:"text",value:f,onChange:y=>u(j,m,y.target.value),placeholder:a("headerValue"),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>h(j),children:e.jsx(pe,{className:"h-4 w-4 text-red-500"})})]},j)),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(te,{className:"h-4 w-4 mr-2"}),a("add")]})]})}function z(s){if(!s)return null;const t=Object.entries(s).map(([n,i])=>[n.trim(),i]).filter(([n])=>n.length>0);return t.length===0?null:Object.fromEntries(t)}function se(s,t){const n=z(s),i=z(t);if(n===null&&i===null)return!0;if(!n||!i)return!1;const u=Object.entries(n).sort(([h],[m])=>h.localeCompare(m)),g=Object.entries(i).sort(([h],[m])=>h.localeCompare(m));return u.length!==g.length?!1:u.every(([h,m],f)=>h===g[f][0]&&m===g[f][1])}function _(s){if(!s||s.length===0)return[];const t=new Set;for(const n of s){const i=n.trim();i&&t.add(i)}return[...t]}function De(s,t){const n=s.trim();if(!n||!t.trim())return n;const i=`${t.trim()}/`;return n.startsWith(i)?n.slice(i.length):n}function G(s,t){let n=s.trim();if(!n)return"";for(const i of t){const u=i.trim();u&&(n=De(n,u))}return n.trim()}function Q(s,t){return s.length!==t.length?!1:s.every((n,i)=>n===t[i])}function Fe(s,t){const n=[...s];for(const i of t)n.includes(i)||n.push(i);return n}function We(s,t){return t.length===0?s:t.every(i=>!s.includes(i))?Fe(s,t):t}function Oe(s,t){return Q(s,t)?[]:s}function ze({providerName:s}){const{data:t}=re(),{data:n}=ne(),{data:i}=le(),u=ve(),g=Ne(),[h,m]=p.useState(""),[f,j]=p.useState(""),[y,L]=p.useState(null),[A,S]=p.useState("auto"),[b,P]=p.useState([]),[d,x]=p.useState(""),r=n==null?void 0:n.providers.find(l=>l.name===s),c=s?t==null?void 0:t.providers[s]:null,w=i==null?void 0:i.uiHints,C=s?O(`providers.${s}.apiKey`,w):void 0,N=s?O(`providers.${s}.apiBase`,w):void 0,E=s?O(`providers.${s}.extraHeaders`,w):void 0,M=s?O(`providers.${s}.wireApi`,w):void 0,ce=(r==null?void 0:r.displayName)||s||a("providersSelectPlaceholder"),X=(r==null?void 0:r.modelPrefix)||s||"",$=p.useMemo(()=>_([X,s||""]),[X,s]),R=(r==null?void 0:r.defaultApiBase)||"",k=(c==null?void 0:c.apiBase)||R,q=z((c==null?void 0:c.extraHeaders)||null),D=(c==null?void 0:c.wireApi)||(r==null?void 0:r.defaultWireApi)||"auto",I=p.useMemo(()=>_(((r==null?void 0:r.defaultModels)??[]).map(l=>G(l,$))),[r==null?void 0:r.defaultModels,$]),J=p.useMemo(()=>_(((c==null?void 0:c.models)??[]).map(l=>G(l,$))),[c==null?void 0:c.models,$]),F=p.useMemo(()=>We(I,J),[I,J]);p.useEffect(()=>{if(!s){m(""),j(""),L(null),S("auto"),P([]),x("");return}m(""),j(k),L((c==null?void 0:c.extraHeaders)||null),S(D),P(F),x("")},[s,k,c==null?void 0:c.extraHeaders,D,F]);const Y=p.useMemo(()=>{if(!s)return!1;const l=h.trim().length>0,o=f.trim()!==k.trim(),v=!se(y,q),T=r!=null&&r.supportsWireApi?A!==D:!1,H=!Q(b,F);return l||o||v||T||H},[s,h,f,k,y,q,r==null?void 0:r.supportsWireApi,A,D,b,F]),oe=()=>{m(""),j(R),L(null),S((r==null?void 0:r.defaultWireApi)||"auto"),P(I),x("")},Z=()=>{const l=G(d,$);if(l){if(b.includes(l)){x("");return}P(o=>[...o,l]),x("")}},de=l=>{if(l.preventDefault(),!s)return;const o={},v=h.trim(),T=f.trim(),H=z(y);v.length>0&&(o.apiKey=v),T!==k.trim()&&(o.apiBase=T.length>0&&T!==R?T:null),se(H,q)||(o.extraHeaders=H),r!=null&&r.supportsWireApi&&A!==D&&(o.wireApi=A),Q(b,F)||(o.models=Oe(b,I)),u.mutate({provider:s,data:o})},me=async()=>{if(!s)return;const l={apiBase:f.trim(),extraHeaders:z(y),model:(t==null?void 0:t.agents.defaults.model)??null};h.trim().length>0&&(l.apiKey=h.trim()),r!=null&&r.supportsWireApi&&(l.wireApi=A);try{const o=await g.mutateAsync({provider:s,data:l});if(o.success){U.success(`${a("providerTestConnectionSuccess")} (${o.latencyMs}ms)`);return}const v=[`provider=${o.provider}`,`latency=${o.latencyMs}ms`];o.model&&v.push(`model=${o.model}`),U.error(`${a("providerTestConnectionFailed")}: ${o.message} | ${v.join(" | ")}`)}catch(o){const v=o instanceof Error?o.message:String(o);U.error(`${a("providerTestConnectionFailed")}: ${v}`)}};if(!s||!r||!c)return e.jsx("div",{className:"flex min-h-[520px] items-center justify-center rounded-2xl border border-gray-200/70 bg-white px-6 text-center xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:a("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:a("providersSelectDescription")})]})});const xe=c.apiKeySet?a("statusReady"):a("statusSetup");return e.jsxs("div",{className:"flex min-h-[520px] flex-col rounded-2xl border border-gray-200/70 bg-white shadow-card xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-5",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:ce}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:a("providerFormDescription")})]}),e.jsx(ie,{status:c.apiKeySet?"ready":"setup",label:xe})]})}),e.jsxs("form",{onSubmit:de,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-y-auto px-6 py-5",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{htmlFor:"apiKey",className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ae,{className:"h-3.5 w-3.5 text-gray-500"}),(C==null?void 0:C.label)??a("apiKey")]}),e.jsx($e,{id:"apiKey",value:h,isSet:c.apiKeySet,onChange:l=>m(l.target.value),placeholder:c.apiKeySet?a("apiKeySet"):(C==null?void 0:C.placeholder)??a("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:a("leaveBlankToKeepUnchanged")})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{htmlFor:"apiBase",className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(fe,{className:"h-3.5 w-3.5 text-gray-500"}),(N==null?void 0:N.label)??a("apiBase")]}),e.jsx(B,{id:"apiBase",type:"text",value:f,onChange:l=>j(l.target.value),placeholder:R||(N==null?void 0:N.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:(N==null?void 0:N.help)||a("providerApiBaseHelp")})]}),r.supportsWireApi&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{htmlFor:"wireApi",className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ee,{className:"h-3.5 w-3.5 text-gray-500"}),(M==null?void 0:M.label)??a("wireApi")]}),e.jsxs(Ce,{value:A,onValueChange:l=>S(l),children:[e.jsx(Ee,{className:"rounded-xl",children:e.jsx(Me,{})}),e.jsx(Ke,{children:(r.wireApiOptions||["auto","chat","responses"]).map(l=>e.jsx(Le,{value:l,children:l==="chat"?a("wireApiChat"):l==="responses"?a("wireApiResponses"):a("wireApiAuto")},l))})]}),(M==null?void 0:M.help)&&e.jsx("p",{className:"text-xs text-gray-500",children:M.help})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ee,{className:"h-3.5 w-3.5 text-gray-500"}),(E==null?void 0:E.label)??a("extraHeaders")]}),e.jsx(ke,{value:y,onChange:L}),e.jsx("p",{className:"text-xs text-gray-500",children:(E==null?void 0:E.help)||a("providerExtraHeadersHelp")})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(W,{className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[e.jsx(ye,{className:"h-3.5 w-3.5 text-gray-500"}),a("providerModelsTitle")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{value:d,onChange:l=>x(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),Z())},placeholder:a("providerModelInputPlaceholder"),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",onClick:Z,disabled:d.trim().length===0,children:[e.jsx(te,{className:"mr-1.5 h-4 w-4"}),a("providerAddModel")]})]}),b.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:a("providerModelsEmpty")}):e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(l=>e.jsxs("div",{className:"group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5",children:[e.jsx("span",{className:"max-w-[180px] truncate text-sm text-gray-800 sm:max-w-[240px]",children:l}),e.jsx("button",{type:"button",onClick:()=>P(o=>o.filter(v=>v!==l)),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":a("remove"),children:e.jsx(ge,{className:"h-3 w-3"})})]},l))}),e.jsx("p",{className:"text-xs text-gray-500",children:a("providerModelsHelp")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-gray-100 px-6 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:oe,children:[e.jsx(je,{className:"mr-2 h-4 w-4"}),a("resetToDefault")]}),e.jsxs(K,{type:"button",variant:"outline",onClick:me,disabled:g.isPending,children:[e.jsx(be,{className:"mr-2 h-4 w-4"}),g.isPending?a("providerTestingConnection"):a("providerTestConnection")]})]}),e.jsx(K,{type:"submit",disabled:u.isPending||!Y,children:u.isPending?a("saving"):Y?a("save"):a("unchanged")})]})]})]})}function Re(s){if(!s)return null;try{const t=new URL(s),n=t.pathname&&t.pathname!=="/"?t.pathname:"";return`${t.host}${n}`}catch{return s.replace(/^https?:\/\//,"")}}function Xe(){const{data:s}=re(),{data:t}=ne(),{data:n}=le(),[i,u]=p.useState("installed"),[g,h]=p.useState(),[m,f]=p.useState(""),j=n==null?void 0:n.uiHints,y=(t==null?void 0:t.providers)??[],L=(s==null?void 0:s.providers)??{},A=y.filter(d=>{var x;return(x=L[d.name])==null?void 0:x.apiKeySet}).length,S=[{id:"installed",label:a("providersTabConfigured"),count:A},{id:"all",label:a("providersTabAll"),count:y.length}],b=p.useMemo(()=>{const d=(t==null?void 0:t.providers)??[],x=(s==null?void 0:s.providers)??{},r=m.trim().toLowerCase();return d.filter(c=>{var w;return i==="installed"?!!((w=x[c.name])!=null&&w.apiKeySet):!0}).filter(c=>r?(c.displayName||c.name).toLowerCase().includes(r)||c.name.toLowerCase().includes(r):!0)},[t,s,i,m]);p.useEffect(()=>{if(b.length===0){h(void 0);return}b.some(x=>x.name===g)||h(b[0].name)},[b,g]);const P=g;return!s||!t?e.jsx("div",{className:"p-8",children:a("providersLoading")}):e.jsxs(Ae,{children:[e.jsx(Pe,{title:a("providersPageTitle"),description:a("providersPageDescription")}),e.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-[340px_minmax(0,1fr)]",children:[e.jsxs("section",{className:"flex min-h-[520px] flex-col rounded-2xl border border-gray-200/70 bg-white shadow-card xl:h-[calc(100vh-180px)] xl:min-h-[600px] xl:max-h-[860px]",children:[e.jsx("div",{className:"border-b border-gray-100 px-4 pt-4",children:e.jsx(Be,{tabs:S,activeTab:i,onChange:u,className:"mb-0"})}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(we,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(B,{value:m,onChange:d=>f(d.target.value),placeholder:a("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[b.map(d=>{const x=s.providers[d.name],r=!!(x!=null&&x.apiKeySet),c=P===d.name,w=O(`providers.${d.name}`,j),C=(x==null?void 0:x.apiBase)||d.defaultApiBase||"",E=Re(C)||(w==null?void 0:w.help)||a("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>h(d.name),className:V("w-full rounded-xl border p-2.5 text-left transition-all",c?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Se,{name:d.name,src:Te(d.name),className:V("h-10 w-10 rounded-lg border",r?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:d.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:d.displayName||d.name}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:E})]})]}),e.jsx(ie,{status:r?"ready":"setup",label:r?a("statusReady"):a("statusSetup"),className:"min-w-[56px] justify-center"})]})},d.name)}),b.length===0&&e.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(ae,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:a("providersNoMatch")})]})]})]}),e.jsx(ze,{providerName:P})]})]})}export{Xe as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,a8 as Y,a6 as Z,ao as le,ag as H}from"./vendor-CmqkRoMs.js";import{u as oe,b as ce,k as de,I as d}from"./useConfig-
|
|
1
|
+
import{r as p,j as e,a8 as Y,a6 as Z,ao as le,ag as H}from"./vendor-CmqkRoMs.js";import{u as oe,b as ce,k as de,I as d}from"./useConfig-CFFZ66EV.js";import{P as ie,a as me,B as N}from"./page-layout-Bz8CAEiD.js";import{C as B,a as M,b as O,c as R,d as $}from"./card-CWG4Tz0Y.js";import{S as he}from"./switch-BwbfObfA.js";import{t,S as ee,a as ae,b as se,d as te,e as P}from"./index-q2B1bssI.js";import{h as I}from"./config-hints-CApS3K_7.js";const ue=[{value:"main",label:"main"},{value:"per-peer",label:"per-peer"},{value:"per-channel-peer",label:"per-channel-peer"},{value:"per-account-channel-peer",label:"per-account-channel-peer"}];function pe(){return{id:"",default:!1,workspace:"",model:"",maxTokens:void 0,contextTokens:void 0,maxToolIterations:void 0}}function xe(){return{agentId:"",match:{channel:"",accountId:""}}}function z(i){const w=i.trim();if(!w)return;const x=Number.parseInt(w,10);return Number.isFinite(x)?x:void 0}function ye(){const{data:i,isLoading:w}=oe(),{data:x}=ce(),_=de(),[S,y]=p.useState([]),[D,b]=p.useState([]),[L,q]=p.useState("per-channel-peer"),[K,F]=p.useState(0),[V,U]=p.useState(2e5);p.useEffect(()=>{var a,r,n;i&&(y((i.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",maxTokens:s.maxTokens,contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),b((i.bindings??[]).map(s=>{var o,l,c;return{agentId:s.agentId??"",match:{channel:((o=s.match)==null?void 0:o.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(c=s.match)!=null&&c.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),q(((a=i.session)==null?void 0:a.dmScope)??"per-channel-peer"),F(((n=(r=i.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),U(i.agents.defaults.contextTokens??2e5))},[i]);const g=x==null?void 0:x.uiHints,h=I("session.dmScope",g),j=I("session.agentToAgent.maxPingPongTurns",g),f=I("agents.defaults.contextTokens",g),A=I("agents.list.*.contextTokens",g),v=I("agents.list",g),k=I("bindings",g),re=p.useMemo(()=>{const a=new Set(["main"]);return S.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[S]),u=(a,r)=>{y(n=>n.map((s,o)=>o===a?{...s,...r}:s))},T=(a,r)=>{b(n=>n.map((s,o)=>o===a?r:s))},ne=()=>{try{const a=S.map((s,o)=>{var m,C;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(o)));const c={id:l};return s.default&&(c.default=!0),(m=s.workspace)!=null&&m.trim()&&(c.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(c.model=s.model.trim()),typeof s.maxTokens=="number"&&(c.maxTokens=s.maxTokens),typeof s.contextTokens=="number"&&(c.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(c.maxToolIterations=s.maxToolIterations),c}),r=a.map(s=>s.id).filter((s,o,l)=>l.indexOf(s)!==o);if(r.length>0){H.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=D.map((s,o)=>{var J,Q,W,X;const l=s.agentId.trim(),c=s.match.channel.trim(),m=((J=s.match.accountId)==null?void 0:J.trim())??"",C=(Q=s.match.peer)==null?void 0:Q.kind,G=((X=(W=s.match.peer)==null?void 0:W.id)==null?void 0:X.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(o)));if(!re.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(o))}: ${l}`);if(!c)throw new Error(t("bindingChannelRequired").replace("{index}",String(o)));const E={agentId:l,match:{channel:c}};if(m&&(E.match.accountId=m),C){if(!G)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(o)));E.match.peer={kind:C,id:G}}return E});_.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,V)},list:a},bindings:n,session:{dmScope:L,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,K))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);H.error(r)}};return w||!i?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(ie,{className:"space-y-6",children:[e.jsx(me,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(R,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(f==null?void 0:f.label)??t("defaultContextTokens")}),e.jsx(d,{type:"number",min:1e3,step:1e3,value:V,onChange:a=>U(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("defaultContextTokensHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(h==null?void 0:h.label)??t("dmScope")}),e.jsxs(ee,{value:L,onValueChange:a=>q(a),children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsx(te,{children:ue.map(a=>e.jsx(P,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(j==null?void 0:j.label)??t("maxPingPongTurns")}),e.jsx(d,{type:"number",min:0,max:5,value:K,onChange:a=>F(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(j==null?void 0:j.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(v==null?void 0:v.label)??t("agentList")}),e.jsx(R,{children:(v==null?void 0:v.help)??t("agentListHelp")})]}),e.jsxs($,{className:"space-y-3",children:[S.map((a,r)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(d,{value:a.id,onChange:n=>u(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(d,{value:a.workspace??"",onChange:n=>u(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(d,{value:a.model??"",onChange:n=>u(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsx(d,{type:"number",min:1,value:a.maxTokens??"",onChange:n=>u(r,{maxTokens:z(n.target.value)}),placeholder:t("maxTokensPlaceholder")}),e.jsx(d,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>u(r,{contextTokens:z(n.target.value)}),placeholder:(A==null?void 0:A.label)??t("contextTokensPlaceholder")}),e.jsx(d,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>u(r,{maxToolIterations:z(n.target.value)}),placeholder:t("maxToolsPlaceholder")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(he,{checked:!!a.default,onCheckedChange:n=>{if(!n){u(r,{default:!1});return}y(s=>s.map((o,l)=>({...o,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>y(n=>n.filter((s,o)=>o!==r)),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(N,{type:"button",variant:"outline",onClick:()=>y(a=>[...a,pe()]),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(B,{children:[e.jsxs(M,{children:[e.jsx(O,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(R,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs($,{className:"space-y-3",children:[D.map((a,r)=>{var s,o;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(d,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(d,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(d,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(ee,{value:n||"__none__",onValueChange:l=>{var m;const c=l==="__none__"?"":l;if(!c){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:c,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsxs(te,{children:[e.jsx(P,{value:"__none__",children:t("peerKindOptional")}),e.jsx(P,{value:"direct",children:"direct"}),e.jsx(P,{value:"group",children:"group"}),e.jsx(P,{value:"channel",children:"channel"})]})]}),e.jsx(d,{value:((o=a.match.peer)==null?void 0:o.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>b(l=>l.filter((c,m)=>m!==r)),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(N,{type:"button",variant:"outline",onClick:()=>b(a=>[...a,xe()]),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{type:"button",onClick:ne,disabled:_.isPending,children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),_.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{ye as RuntimeConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as u,j as e,a8 as H,a6 as L,ao as G,ag as J}from"./vendor-CmqkRoMs.js";import{u as K,q as Q,I as h}from"./useConfig-
|
|
1
|
+
import{r as u,j as e,a8 as H,a6 as L,ao as G,ag as J}from"./vendor-CmqkRoMs.js";import{u as K,q as Q,I as h}from"./useConfig-CFFZ66EV.js";import{P as W,a as X,B as _}from"./page-layout-Bz8CAEiD.js";import{C as R,a as T,b as M,c as O,d as A}from"./card-CWG4Tz0Y.js";import{L as k}from"./label-LbWa2Yzc.js";import{t as a,S as x,a as m,b as p,d as j,e as o}from"./index-q2B1bssI.js";import{S as Y}from"./switch-BwbfObfA.js";const U=["env","file","exec"];function N(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function Z(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...N(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...N(n),source:"file",path:l.path}:{...N(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
|
|
2
2
|
`),cwd:l.cwd??"",timeoutMs:l.timeoutMs??5e3}}function se(n){return n.source==="env"?{source:"env",...n.prefix.trim()?{prefix:n.prefix.trim()}:{}}:n.source==="file"?{source:"file",path:n.path.trim(),format:"json"}:{source:"exec",command:n.command.trim(),args:n.argsText.split(`
|
|
3
3
|
`).map(l=>l.trim()).filter(Boolean),...n.cwd.trim()?{cwd:n.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(n.timeoutMs||5e3))}}function oe(){const{data:n,isLoading:l}=K(),P=Q(),[D,y]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[q,$]=u.useState(""),[C,f]=u.useState([]),[F,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){y(!0),E(""),S(""),$(""),f([]),v([]);return}y(!!s.enabled),E(s.defaults.env??""),S(s.defaults.file??""),$(s.defaults.exec??"");const t=Object.entries(s.providers).map(([c,i])=>ee(c,i)),r=Object.entries(s.refs).map(([c,i])=>({path:c,source:i.source,provider:i.provider??"",id:i.id}));f(t),v(r)},[n==null?void 0:n.secrets]);const w=u.useMemo(()=>{const s=C.map(t=>t.alias.trim()).filter(Boolean);return Array.from(new Set(s))},[C]),d=(s,t)=>{f(r=>r.map((c,i)=>i===s?{...c,...t}:c))},b=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},z=()=>{try{const s={};for(const[r,c]of C.entries()){const i=c.alias.trim();if(!i)throw new Error(`${a("providerAlias")} #${r+1} ${a("isRequired")}`);if(s[i])throw new Error(`${a("providerAlias")}: ${i} (${a("duplicate")})`);if(c.source==="file"&&!c.path.trim())throw new Error(`${a("secretFilePath")} #${r+1} ${a("isRequired")}`);if(c.source==="exec"&&!c.command.trim())throw new Error(`${a("secretExecCommand")} #${r+1} ${a("isRequired")}`);s[i]=se(c)}const t={};for(const[r,c]of F.entries()){const i=c.path.trim(),B=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!B)throw new Error(`${a("secretId")} #${r+1} ${a("isRequired")}`);const g=c.provider.trim();if(g&&!s[g])throw new Error(`${a("secretProviderAlias")}: ${g} ${a("notFound")}`);t[i]={source:c.source,...g?{provider:g}:{},id:B}}P.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:q.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);J.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(W,{className:"space-y-6",children:[e.jsx(X,{title:a("secretsPageTitle"),description:a("secretsPageDescription")}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secrets")}),e.jsx(O,{children:a("secretsEnabledHelp")})]}),e.jsxs(A,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:a("enabled")}),e.jsx("p",{className:"text-xs text-gray-500",children:a("secretsEnabledHelp")})]}),e.jsx(Y,{checked:D,onCheckedChange:y})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultEnvProvider")}),e.jsxs(x,{value:I||"__none__",onValueChange:s=>E(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultFileProvider")}),e.jsxs(x,{value:V||"__none__",onValueChange:s=>S(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultExecProvider")}),e.jsxs(x,{value:q||"__none__",onValueChange:s=>$(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretProvidersTitle")}),e.jsx(O,{children:a("secretProvidersDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[C.map((s,t)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(h,{value:s.alias,onChange:r=>d(t,{alias:r.target.value}),placeholder:a("providerAlias")}),e.jsxs(x,{value:s.source,onValueChange:r=>d(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(r=>r.filter((c,i)=>i!==t)),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),a("removeProvider")]})]}),s.source==="env"&&e.jsx(h,{value:s.prefix,onChange:r=>d(t,{prefix:r.target.value}),placeholder:a("envPrefix")}),s.source==="file"&&e.jsx(h,{value:s.path,onChange:r=>d(t,{path:r.target.value}),placeholder:a("secretFilePath")}),s.source==="exec"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{value:s.command,onChange:r=>d(t,{command:r.target.value}),placeholder:a("secretExecCommand")}),e.jsx("textarea",{className:"min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono",value:s.argsText,onChange:r=>d(t,{argsText:r.target.value}),placeholder:a("secretExecArgs")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(h,{value:s.cwd,onChange:r=>d(t,{cwd:r.target.value}),placeholder:a("secretExecCwd")}),e.jsx(h,{type:"number",min:1,value:s.timeoutMs,onChange:r=>d(t,{timeoutMs:Number.parseInt(r.target.value,10)||5e3}),placeholder:a("secretExecTimeoutMs")})]})]})]},`provider-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(s=>[...s,N()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretProvider")]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretRefsTitle")}),e.jsx(O,{children:a("secretRefsDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[F.map((s,t)=>e.jsx("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(h,{value:s.path,onChange:r=>b(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>b(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>b(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsxs(x,{value:s.provider||"__none__",onValueChange:r=>b(t,{provider:r==="__none__"?"":r}),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("secretProviderAlias")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(r=>e.jsx(o,{value:r,children:r},r))]})]}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(r=>r.filter((c,i)=>i!==t)),children:e.jsx(H,{className:"h-4 w-4"})})]})]})},`ref-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>v(s=>[...s,Z()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretRef")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(_,{type:"button",onClick:z,disabled:P.isPending,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),P.isPending?a("saving"):a("save")]})})]})}export{oe as SecretsConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as l,j as e,a5 as T,a0 as Y,ap as A,ac as $,aj as W,M as U,aq as X,X as G,Y as J}from"./vendor-CmqkRoMs.js";import{u as Z}from"./useConfirmDialog-
|
|
1
|
+
import{r as l,j as e,a5 as T,a0 as Y,ap as A,ac as $,aj as W,M as U,aq as X,X as G,Y as J}from"./vendor-CmqkRoMs.js";import{u as Z}from"./useConfirmDialog-ClpvgpHh.js";import{d as ee,e as se,l as te,f as ae,I as S}from"./useConfig-CFFZ66EV.js";import{P as re,a as le,B as g}from"./page-layout-Bz8CAEiD.js";import{t,c as o,S as ne,a as ie,b as oe,d as de,e as K,i as ce,g as xe}from"./index-q2B1bssI.js";import{e as me}from"./chat-message-D0s61C4e.js";import"./dialog-ssdjbutm.js";const u="__unknown_channel__";function he(a){return xe(a)}function j(a){const n=a.indexOf(":");return n<=0?u:a.slice(0,n).trim()||u}function C(a){return a===u?t("sessionsUnknownChannel"):a}function ge({session:a,channel:n,isSelected:i,onSelect:f}){const r=C(n),p=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:f,className:o("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",i?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:o("font-semibold truncate pr-2 flex-1 text-sm",i?"text-brand-800":"text-gray-900"),children:p}),e.jsx("div",{className:o("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",i?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:r})]}),e.jsxs("div",{className:o("flex items-center text-xs justify-between mt-2 font-medium",i?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(X,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ce(a.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:a.messageCount})]})]})]})}function ue({message:a}){const n=a.role.toLowerCase()==="user",i=me(a.content).trim();return e.jsx("div",{className:o("flex w-full mb-6",n?"justify-end":"justify-start"),children:e.jsxs("div",{className:o("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",n?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:n?e.jsx(G,{className:"w-4 h-4 text-primary-100"}):e.jsx(J,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 space-y-1 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4 mb-2",children:[e.jsx("span",{className:o("font-semibold text-xs",n?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:o("text-[10px]",n?"text-primary-200":"text-gray-400"),children:he(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:i||"-"})]})]})})}function we(){var z,H,E;const[a,n]=l.useState(""),[i]=l.useState(100),[f]=l.useState(0),[r,p]=l.useState(null),[y,B]=l.useState("all"),[M,v]=l.useState(""),[L,N]=l.useState(""),[w,k]=l.useState(!1),q=l.useMemo(()=>({q:a.trim()||void 0,limit:i,activeMinutes:f}),[a,i,f]),h=ee(q),x=se(r,200),b=te(),D=ae(),{confirm:_,ConfirmDialog:F}=Z(),c=l.useMemo(()=>{var s;return((s=h.data)==null?void 0:s.sessions)??[]},[(z=h.data)==null?void 0:z.sessions]),d=l.useMemo(()=>c.find(s=>s.key===r),[c,r]),Q=l.useMemo(()=>{const s=new Set;for(const m of c)s.add(j(m.key));return Array.from(s).sort((m,I)=>m===u?1:I===u?-1:m.localeCompare(I))},[c]),P=l.useMemo(()=>y==="all"?c:c.filter(s=>j(s.key)===y),[c,y]);l.useEffect(()=>{d?(v(d.label||""),N(d.preferredModel||"")):(v(""),N("")),k(!1)},[d]);const O=()=>{r&&(b.mutate({key:r,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),k(!1))},R=async()=>{if(!r)return;await _({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&b.mutate({key:r,data:{clearHistory:!0}})},V=async()=>{if(!r)return;await _({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&D.mutate({key:r},{onSuccess:()=>p(null)})};return e.jsxs(re,{fullHeight:!0,children:[e.jsx(le,{title:t("sessionsPageTitle"),description:t("sessionsPageDescription")}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 relative",children:[e.jsxs("div",{className:"w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:[c.length," ",t("sessionsListTitle")]}),e.jsx(g,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>h.refetch(),children:e.jsx(T,{className:o("h-3.5 w-3.5",h.isFetching&&"animate-spin")})})]}),e.jsxs(ne,{value:y,onValueChange:B,children:[e.jsx(ie,{className:"w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700",children:e.jsx(oe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(de,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(K,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),Q.map(s=>e.jsx(K,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(Y,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(S,{value:a,onChange:s=>n(s.target.value),placeholder:t("sessionsSearchPlaceholder"),className:"pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative",children:h.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):P.length===0?e.jsxs("div",{className:"text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4",children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):P.map(s=>e.jsx(ge,{session:s,channel:j(s.key),isSelected:r===s.key,onSelect:()=>p(s.key)},s.key))})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200",children:[(b.isPending||D.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),r&&d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0",children:e.jsx($,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:d.label||d.key.split(":").pop()||d.key}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:C(j(d.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:r,children:r})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>k(!w),className:o("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(W,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(g,{variant:"outline",size:"sm",onClick:R,className:"h-8.5 rounded-lg shadow-none hover:bg-gray-50 hover:text-gray-900 border-gray-200 text-xs font-semibold text-gray-500",children:t("sessionsClearHistory")}),e.jsx(g,{variant:"outline",size:"sm",onClick:V,className:"h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500",children:t("delete")})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in",children:[e.jsx(S,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(S,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(g,{size:"sm",onClick:O,className:"h-8 px-4 shrink-0 shadow-none",disabled:b.isPending,children:t("sessionsSaveMeta")})]})]}),e.jsxs("div",{className:`flex-1 overflow-y-auto p-6 relative
|
|
2
2
|
[&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[x.isLoading&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx(T,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),x.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:x.error.message}),!x.isLoading&&((H=x.data)==null?void 0:H.messages.length)===0&&e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(U,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm",children:t("sessionsEmpty")})]}),e.jsx("div",{className:"max-w-3xl mx-auto",children:(((E=x.data)==null?void 0:E.messages)??[]).map((s,m)=>e.jsx(ue,{message:s},`${s.timestamp}-${m}`))})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3",children:e.jsx(A,{className:"h-8 w-8 text-gray-300 -rotate-3"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:t("sessionsNoSelectionTitle")}),e.jsx("p",{className:"text-sm text-center max-w-sm leading-relaxed",children:t("sessionsNoSelectionDescription")})]})]})]}),e.jsx(F,{})]})}export{we as SessionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-CmqkRoMs.js";import{c as d}from"./index-
|
|
1
|
+
import{r as s,j as t}from"./vendor-CmqkRoMs.js";import{c as d}from"./index-q2B1bssI.js";const i=s.forwardRef(({className:a,hover:e=!0,...r},o)=>t.jsx("div",{ref:o,className:d("rounded-2xl border border-gray-200/50 bg-white text-card-foreground shadow-card transition-all duration-base",e&&"hover:shadow-card-hover hover:border-gray-200",a),...r}));i.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const l=s.forwardRef(({className:a,...e},r)=>t.jsx("h3",{ref:r,className:d("text-[15px] font-semibold leading-tight tracking-tight text-gray-900",a),...e}));l.displayName="CardTitle";const n=s.forwardRef(({className:a,...e},r)=>t.jsx("p",{ref:r,className:d("text-[13px] text-gray-400 leading-relaxed",a),...e}));n.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-6 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center justify-between p-6 pt-0",a),...e}));x.displayName="CardFooter";export{i as C,c as a,l as b,n as c,p as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,az as C,aO as I,ax as ee,j as s,aw as A,aE as te,aB as D,aC as v,aF as ne,aP as oe,aQ as ae,aR as re,aS as se,aG as ie,aT as ce,aU as le,ad as de}from"./vendor-CmqkRoMs.js";import{c as x}from"./index-
|
|
1
|
+
import{r as i,az as C,aO as I,ax as ee,j as s,aw as A,aE as te,aB as D,aC as v,aF as ne,aP as oe,aQ as ae,aR as re,aS as se,aG as ie,aT as ce,aU as le,ad as de}from"./vendor-CmqkRoMs.js";import{c as x}from"./index-q2B1bssI.js";function ue(e,t){return i.useReducer((n,o)=>t[n][o]??n,e)}var E=e=>{const{present:t,children:n}=e,o=fe(t),a=typeof n=="function"?n({present:o.isPresent}):i.Children.only(n),r=C(o.ref,ge(a));return typeof n=="function"||o.isPresent?i.cloneElement(a,{ref:r}):null};E.displayName="Presence";function fe(e){const[t,n]=i.useState(),o=i.useRef(null),a=i.useRef(e),r=i.useRef("none"),c=e?"mounted":"unmounted",[d,u]=ue(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const l=R(o.current);r.current=d==="mounted"?l:"none"},[d]),I(()=>{const l=o.current,g=a.current;if(g!==e){const y=r.current,p=R(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(g&&y!==p?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,u]),I(()=>{if(t){let l;const g=t.ownerDocument.defaultView??window,m=p=>{const Z=R(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&Z&&(u("ANIMATION_END"),!a.current)){const J=t.style.animationFillMode;t.style.animationFillMode="forwards",l=g.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=J)})}},y=p=>{p.target===t&&(r.current=R(o.current))};return t.addEventListener("animationstart",y),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{g.clearTimeout(l),t.removeEventListener("animationstart",y),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:i.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function R(e){return(e==null?void 0:e.animationName)||"none"}function ge(e){var o,a;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var O="Dialog",[w]=ne(O),[me,f]=w(O),M=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:a,onOpenChange:r,modal:c=!0}=e,d=i.useRef(null),u=i.useRef(null),[l,g]=ee({prop:o,defaultProp:a??!1,onChange:r,caller:O});return s.jsx(me,{scope:t,triggerRef:d,contentRef:u,contentId:A(),titleId:A(),descriptionId:A(),open:l,onOpenChange:g,onOpenToggle:i.useCallback(()=>g(m=>!m),[g]),modal:c,children:n})};M.displayName=O;var T="DialogTrigger",pe=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(T,n),r=C(t,a.triggerRef);return s.jsx(D.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":b(a.open),...o,ref:r,onClick:v(e.onClick,a.onOpenToggle)})});pe.displayName=T;var P="DialogPortal",[Ne,j]=w(P,{forceMount:void 0}),S=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:a}=e,r=f(P,t);return s.jsx(Ne,{scope:t,forceMount:n,children:i.Children.map(o,c=>s.jsx(E,{present:n||r.open,children:s.jsx(te,{asChild:!0,container:a,children:c})}))})};S.displayName=P;var h="DialogOverlay",F=i.forwardRef((e,t)=>{const n=j(h,e.__scopeDialog),{forceMount:o=n.forceMount,...a}=e,r=f(h,e.__scopeDialog);return r.modal?s.jsx(E,{present:o||r.open,children:s.jsx(ve,{...a,ref:t})}):null});F.displayName=h;var xe=ce("DialogOverlay.RemoveScroll"),ve=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(h,n);return s.jsx(ae,{as:xe,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(D.div,{"data-state":b(a.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),N="DialogContent",W=i.forwardRef((e,t)=>{const n=j(N,e.__scopeDialog),{forceMount:o=n.forceMount,...a}=e,r=f(N,e.__scopeDialog);return s.jsx(E,{present:o||r.open,children:r.modal?s.jsx(De,{...a,ref:t}):s.jsx(ye,{...a,ref:t})})});W.displayName=N;var De=i.forwardRef((e,t)=>{const n=f(N,e.__scopeDialog),o=i.useRef(null),a=C(t,n.contentRef,o);return i.useEffect(()=>{const r=o.current;if(r)return oe(r)},[]),s.jsx(L,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:v(e.onCloseAutoFocus,r=>{var c;r.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:v(e.onPointerDownOutside,r=>{const c=r.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&r.preventDefault()}),onFocusOutside:v(e.onFocusOutside,r=>r.preventDefault())})}),ye=i.forwardRef((e,t)=>{const n=f(N,e.__scopeDialog),o=i.useRef(!1),a=i.useRef(!1);return s.jsx(L,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var c,d;(c=e.onCloseAutoFocus)==null||c.call(e,r),r.defaultPrevented||(o.current||(d=n.triggerRef.current)==null||d.focus(),r.preventDefault()),o.current=!1,a.current=!1},onInteractOutside:r=>{var u,l;(u=e.onInteractOutside)==null||u.call(e,r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=r.target;((l=n.triggerRef.current)==null?void 0:l.contains(c))&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&a.current&&r.preventDefault()}})}),L=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:r,...c}=e,d=f(N,n),u=i.useRef(null),l=C(t,u);return re(),s.jsxs(s.Fragment,{children:[s.jsx(se,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:a,onUnmountAutoFocus:r,children:s.jsx(ie,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":b(d.open),...c,ref:l,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Re,{titleId:d.titleId}),s.jsx(Ce,{contentRef:u,descriptionId:d.descriptionId})]})]})}),_="DialogTitle",U=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(_,n);return s.jsx(D.h2,{id:a.titleId,...o,ref:t})});U.displayName=_;var k="DialogDescription",$=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(k,n);return s.jsx(D.p,{id:a.descriptionId,...o,ref:t})});$.displayName=k;var G="DialogClose",z=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(G,n);return s.jsx(D.button,{type:"button",...o,ref:t,onClick:v(e.onClick,()=>a.onOpenChange(!1))})});z.displayName=G;function b(e){return e?"open":"closed"}var B="DialogTitleWarning",[Se,H]=le(B,{contentName:N,titleName:_,docsSlug:"dialog"}),Re=({titleId:e})=>{const t=H(B),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
2
|
|
|
3
3
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
4
|
|