nextclaw 0.8.30 → 0.8.32
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/dist/cli/index.js +27 -2
- package/package.json +4 -4
- package/ui-dist/assets/ChannelsList-DqgRRdUH.js +1 -0
- package/ui-dist/assets/ChatPage-BQyomkth.js +1 -0
- package/ui-dist/assets/CronConfig-Bmg449JI.js +1 -0
- package/ui-dist/assets/{DocBrowser-j7niXd-r.js → DocBrowser-C35MebbI.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-wwHgdVC2.js → MarketplacePage-HjEQ8sFt.js} +1 -1
- package/ui-dist/assets/{ModelConfig-DYsAYZmK.js → ModelConfig-BpBoi1sz.js} +1 -1
- package/ui-dist/assets/ProvidersList-0tYTV40v.js +1 -0
- package/ui-dist/assets/{RuntimeConfig-Cyitquqb.js → RuntimeConfig-B_WI-DHf.js} +1 -1
- package/ui-dist/assets/SessionsConfig-BEt-f6WS.js +2 -0
- package/ui-dist/assets/{action-link-idlbumT9.js → action-link-CSScZ_id.js} +1 -1
- package/ui-dist/assets/{card-D-p-as8W.js → card-Cj58-DCd.js} +1 -1
- package/ui-dist/assets/dialog-Ce8jNftN.js +5 -0
- package/ui-dist/assets/index-CPFSdkyQ.css +1 -0
- package/ui-dist/assets/index-C_z1Na9N.js +2 -0
- package/ui-dist/assets/{label-DyVIs28I.js → label-CQdP2NhF.js} +1 -1
- package/ui-dist/assets/{page-layout-BuYR443L.js → page-layout-Byyxptub.js} +1 -1
- package/ui-dist/assets/{switch-QRLVAehj.js → switch-ChJzdp0x.js} +1 -1
- package/ui-dist/assets/{tabs-custom-tbDoqtk2.js → tabs-custom-DWlAbbCy.js} +1 -1
- package/ui-dist/assets/useConfig-8lC_4LwH.js +1 -0
- package/ui-dist/assets/{useConfirmDialog-Dj945N0Y.js → useConfirmDialog-B7iWHb5k.js} +1 -1
- package/ui-dist/assets/{vendor-Bhv7yx8z.js → vendor-Dz2q6Qmc.js} +67 -57
- package/ui-dist/index.html +3 -3
- package/ui-dist/assets/ChannelsList-B7XLKy6l.js +0 -1
- package/ui-dist/assets/CronConfig-CDv1eiLK.js +0 -1
- package/ui-dist/assets/ProvidersList-DcojGhjs.js +0 -1
- package/ui-dist/assets/SessionsConfig-2RYUIeki.js +0 -2
- package/ui-dist/assets/dialog-DJSdVlnI.js +0 -5
- package/ui-dist/assets/index-DFfB9XKS.js +0 -2
- package/ui-dist/assets/index-DdpR1fdj.css +0 -1
- package/ui-dist/assets/useConfig-DgIVFToQ.js +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -2692,7 +2692,7 @@ var ServiceCommands = class {
|
|
|
2692
2692
|
} else {
|
|
2693
2693
|
console.log("Warning: No channels enabled");
|
|
2694
2694
|
}
|
|
2695
|
-
this.startUiIfEnabled(uiConfig, uiStaticDir, cron2);
|
|
2695
|
+
this.startUiIfEnabled(uiConfig, uiStaticDir, cron2, runtimePool);
|
|
2696
2696
|
const cronStatus = cron2.status();
|
|
2697
2697
|
if (cronStatus.jobs > 0) {
|
|
2698
2698
|
console.log(`\u2713 Cron: ${cronStatus.jobs} scheduled jobs`);
|
|
@@ -3064,7 +3064,7 @@ var ServiceCommands = class {
|
|
|
3064
3064
|
console.log(`Public UI (if firewall/NAT allows): ${publicBase}`);
|
|
3065
3065
|
console.log(`Public API (if firewall/NAT allows): ${publicBase}/api`);
|
|
3066
3066
|
}
|
|
3067
|
-
startUiIfEnabled(uiConfig, uiStaticDir, cronService) {
|
|
3067
|
+
startUiIfEnabled(uiConfig, uiStaticDir, cronService, runtimePool) {
|
|
3068
3068
|
if (!uiConfig.enabled) {
|
|
3069
3069
|
return;
|
|
3070
3070
|
}
|
|
@@ -3084,6 +3084,31 @@ var ServiceCommands = class {
|
|
|
3084
3084
|
uninstallPlugin: (id) => this.uninstallMarketplacePlugin(id),
|
|
3085
3085
|
uninstallSkill: (slug) => this.uninstallMarketplaceSkill(slug)
|
|
3086
3086
|
}
|
|
3087
|
+
},
|
|
3088
|
+
chatRuntime: {
|
|
3089
|
+
processTurn: async (params) => {
|
|
3090
|
+
const sessionKey = typeof params.sessionKey === "string" && params.sessionKey.trim().length > 0 ? params.sessionKey.trim() : `ui:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 8)}`;
|
|
3091
|
+
const inferredAgentId = typeof params.agentId === "string" && params.agentId.trim().length > 0 ? params.agentId.trim() : parseAgentScopedSessionKey2(sessionKey)?.agentId;
|
|
3092
|
+
const model = typeof params.model === "string" && params.model.trim().length > 0 ? params.model.trim() : void 0;
|
|
3093
|
+
const metadata = params.metadata && typeof params.metadata === "object" && !Array.isArray(params.metadata) ? { ...params.metadata } : {};
|
|
3094
|
+
if (model) {
|
|
3095
|
+
metadata.model = model;
|
|
3096
|
+
}
|
|
3097
|
+
const reply = await runtimePool.processDirect({
|
|
3098
|
+
content: params.message,
|
|
3099
|
+
sessionKey,
|
|
3100
|
+
channel: typeof params.channel === "string" && params.channel.trim().length > 0 ? params.channel : "ui",
|
|
3101
|
+
chatId: typeof params.chatId === "string" && params.chatId.trim().length > 0 ? params.chatId : "web-ui",
|
|
3102
|
+
agentId: inferredAgentId,
|
|
3103
|
+
metadata
|
|
3104
|
+
});
|
|
3105
|
+
return {
|
|
3106
|
+
reply,
|
|
3107
|
+
sessionKey,
|
|
3108
|
+
...inferredAgentId ? { agentId: inferredAgentId } : {},
|
|
3109
|
+
...model ? { model } : {}
|
|
3110
|
+
};
|
|
3111
|
+
}
|
|
3087
3112
|
}
|
|
3088
3113
|
});
|
|
3089
3114
|
const uiUrl = `http://${uiServer.host}:${uiServer.port}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextclaw",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.32",
|
|
4
4
|
"description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"chokidar": "^3.6.0",
|
|
40
40
|
"commander": "^12.1.0",
|
|
41
|
-
"@nextclaw/core": "^0.6.
|
|
42
|
-
"@nextclaw/server": "^0.5.
|
|
43
|
-
"@nextclaw/openclaw-compat": "^0.1.
|
|
41
|
+
"@nextclaw/core": "^0.6.34",
|
|
42
|
+
"@nextclaw/server": "^0.5.16",
|
|
43
|
+
"@nextclaw/openclaw-compat": "^0.1.28"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^20.17.6",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as v,j as a,a6 as ae,M as S,a7 as M,a8 as N,a3 as te,a4 as ne,a5 as le,a9 as se,aa as oe,n as H,ab as re,ac as ce,ad as ie}from"./vendor-Dz2q6Qmc.js";import{u as _,a as q,i as me,j as pe,I as D,g as de}from"./useConfig-8lC_4LwH.js";import{t as e,c as G,u as J,S as be,b as ue,d as ye,e as ge,g as xe}from"./index-C_z1Na9N.js";import{D as he,a as fe,b as we,c as je,d as ve,e as ke}from"./dialog-Ce8jNftN.js";import{B as F,P as Ce,a as Pe}from"./page-layout-Byyxptub.js";import{L as Ne}from"./label-CQdP2NhF.js";import{S as Se}from"./switch-ChJzdp0x.js";import{h as T}from"./config-hints-CApS3K_7.js";import{T as Ie}from"./tabs-custom-DWlAbbCy.js";import{C as De,a as Fe,L as Te,d as Me,S as Ae,b as Le,c as Ue,A as Ee}from"./action-link-CSScZ_id.js";function Be({value:n,onChange:d,className:i,placeholder:m=""}){const[c,g]=v.useState(""),b=u=>{u.key==="Enter"&&c.trim()?(u.preventDefault(),d([...n,c.trim()]),g("")):u.key==="Backspace"&&!c&&n.length>0&&d(n.slice(0,-1))},f=u=>{d(n.filter((o,y)=>y!==u))};return a.jsxs("div",{className:G("flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px]",i),children:[n.map((u,o)=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary text-primary-foreground rounded text-sm",children:[u,a.jsx("button",{type:"button",onClick:()=>f(o),className:"hover:text-red-300 transition-colors",children:a.jsx(ae,{className:"h-3 w-3"})})]},o)),a.jsx("input",{type:"text",value:c,onChange:u=>g(u.target.value),onKeyDown:b,className:"flex-1 outline-none min-w-[100px] bg-transparent text-sm",placeholder:m||e("enterTag")})]})}const U=[{value:"pairing",label:"pairing"},{value:"allowlist",label:"allowlist"},{value:"open",label:"open"},{value:"disabled",label:"disabled"}],E=[{value:"open",label:"open"},{value:"allowlist",label:"allowlist"},{value:"disabled",label:"disabled"}],Oe=[{value:"off",label:"off"},{value:"partial",label:"partial"},{value:"block",label:"block"},{value:"progress",label:"progress"}],$e=n=>n.includes("token")||n.includes("secret")||n.includes("password")?a.jsx(te,{className:"h-3.5 w-3.5 text-gray-500"}):n.includes("url")||n.includes("host")?a.jsx(ne,{className:"h-3.5 w-3.5 text-gray-500"}):n.includes("email")||n.includes("mail")?a.jsx(M,{className:"h-3.5 w-3.5 text-gray-500"}):n.includes("id")||n.includes("from")?a.jsx(le,{className:"h-3.5 w-3.5 text-gray-500"}):n==="enabled"||n==="consentGranted"?a.jsx(se,{className:"h-3.5 w-3.5 text-gray-500"}):a.jsx(oe,{className:"h-3.5 w-3.5 text-gray-500"});function B(){return{telegram:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"token",type:"password",label:e("botToken")},{name:"allowFrom",type:"tags",label:e("allowFrom")},{name:"proxy",type:"text",label:e("proxy")},{name:"accountId",type:"text",label:e("accountId")},{name:"dmPolicy",type:"select",label:e("dmPolicy"),options:U},{name:"groupPolicy",type:"select",label:e("groupPolicy"),options:E},{name:"groupAllowFrom",type:"tags",label:e("groupAllowFrom")},{name:"requireMention",type:"boolean",label:e("requireMention")},{name:"mentionPatterns",type:"tags",label:e("mentionPatterns")},{name:"groups",type:"json",label:e("groupRulesJson")}],discord:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"token",type:"password",label:e("botToken")},{name:"allowBots",type:"boolean",label:e("allowBotMessages")},{name:"allowFrom",type:"tags",label:e("allowFrom")},{name:"gatewayUrl",type:"text",label:e("gatewayUrl")},{name:"intents",type:"number",label:e("intents")},{name:"proxy",type:"text",label:e("proxy")},{name:"mediaMaxMb",type:"number",label:e("attachmentMaxSizeMb")},{name:"streaming",type:"select",label:e("streamingMode"),options:Oe},{name:"draftChunk",type:"json",label:e("draftChunkingJson")},{name:"textChunkLimit",type:"number",label:e("textChunkLimit")},{name:"accountId",type:"text",label:e("accountId")},{name:"dmPolicy",type:"select",label:e("dmPolicy"),options:U},{name:"groupPolicy",type:"select",label:e("groupPolicy"),options:E},{name:"groupAllowFrom",type:"tags",label:e("groupAllowFrom")},{name:"requireMention",type:"boolean",label:e("requireMention")},{name:"mentionPatterns",type:"tags",label:e("mentionPatterns")},{name:"groups",type:"json",label:e("groupRulesJson")}],whatsapp:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"bridgeUrl",type:"text",label:e("bridgeUrl")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],feishu:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"appId",type:"text",label:e("appId")},{name:"appSecret",type:"password",label:e("appSecret")},{name:"encryptKey",type:"password",label:e("encryptKey")},{name:"verificationToken",type:"password",label:e("verificationToken")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],dingtalk:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"clientId",type:"text",label:e("clientId")},{name:"clientSecret",type:"password",label:e("clientSecret")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],wecom:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"corpId",type:"text",label:e("corpId")},{name:"agentId",type:"text",label:e("agentId")},{name:"secret",type:"password",label:e("secret")},{name:"token",type:"password",label:e("token")},{name:"callbackPort",type:"number",label:e("callbackPort")},{name:"callbackPath",type:"text",label:e("callbackPath")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],slack:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"mode",type:"text",label:e("mode")},{name:"webhookPath",type:"text",label:e("webhookPath")},{name:"allowBots",type:"boolean",label:e("allowBotMessages")},{name:"botToken",type:"password",label:e("botToken")},{name:"appToken",type:"password",label:e("appToken")}],email:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"consentGranted",type:"boolean",label:e("consentGranted")},{name:"imapHost",type:"text",label:e("imapHost")},{name:"imapPort",type:"number",label:e("imapPort")},{name:"imapUsername",type:"text",label:e("imapUsername")},{name:"imapPassword",type:"password",label:e("imapPassword")},{name:"fromAddress",type:"email",label:e("fromAddress")}],mochat:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"baseUrl",type:"text",label:e("baseUrl")},{name:"clawToken",type:"password",label:e("clawToken")},{name:"agentUserId",type:"text",label:e("agentUserId")},{name:"allowFrom",type:"tags",label:e("allowFrom")}],qq:[{name:"enabled",type:"boolean",label:e("enabled")},{name:"appId",type:"text",label:e("appId")},{name:"secret",type:"password",label:e("appSecret")},{name:"markdownSupport",type:"boolean",label:e("markdownSupport")},{name:"allowFrom",type:"tags",label:e("allowFrom")}]}}const O={telegram:S,slack:S,email:M,default:S},$={telegram:"from-primary-300 to-primary-600",slack:"from-primary-200 to-primary-500",email:"from-primary-100 to-primary-400",default:"from-gray-300 to-gray-500"};function I(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function K(n,d){const i={...n};for(const[m,c]of Object.entries(d)){const g=i[m];if(I(g)&&I(c)){i[m]=K(g,c);continue}i[m]=c}return i}function Re(n,d){const i=n.split("."),m={};let c=m;for(let g=0;g<i.length-1;g+=1){const b=i[g];c[b]={},c=c[b]}return c[i[i.length-1]]=d,m}function He(){var A,L;const{channelModal:n,closeChannelModal:d}=J(),{data:i}=_(),{data:m}=q(),c=me(),g=pe(),[b,f]=v.useState({}),[u,o]=v.useState({}),[y,x]=v.useState(null),l=n.channel,w=l?i==null?void 0:i.channels[l]:null,k=l?B()[l]??[]:[],C=m==null?void 0:m.uiHints,P=l?`channels.${l}`:null,z=((A=m==null?void 0:m.actions)==null?void 0:A.filter(t=>t.scope===P))??[],V=l&&(((L=T(`channels.${l}`,C))==null?void 0:L.label)??l);v.useEffect(()=>{if(w){f({...w});const t={};(l?B()[l]??[]:[]).filter(r=>r.type==="json").forEach(r=>{const h=w[r.name];t[r.name]=JSON.stringify(h??{},null,2)}),o(t)}else f({}),o({})},[w,l]);const j=(t,s)=>{f(r=>({...r,[t]:s}))},Y=t=>{if(t.preventDefault(),!l)return;const s={...b};for(const r of k){if(r.type!=="json")continue;const h=u[r.name]??"";try{s[r.name]=h.trim()?JSON.parse(h):{}}catch{N.error(`${e("invalidJson")}: ${r.name}`);return}}c.mutate({channel:l,data:s},{onSuccess:()=>d()})},W=t=>{if(!t||!l)return;const s=t.channels;if(!I(s))return;const r=s[l];I(r)&&f(h=>K(h,r))},X=async t=>{if(!(!l||!P)){x(t.id);try{let s={...b};t.saveBeforeRun&&(s={...s,...t.savePatch??{}},f(s),await c.mutateAsync({channel:l,data:s}));const r=await g.mutateAsync({actionId:t.id,data:{scope:P,draftConfig:Re(P,s)}});W(r.patch),r.ok?N.success(r.message||e("success")):N.error(r.message||e("error"))}catch(s){const r=s instanceof Error?s.message:String(s);N.error(`${e("error")}: ${r}`)}finally{x(null)}}},Q=O[l||""]||O.default,Z=$[l||""]||$.default;return a.jsx(he,{open:n.open,onOpenChange:d,children:a.jsxs(fe,{className:"sm:max-w-[550px] max-h-[85vh] overflow-hidden flex flex-col",children:[a.jsx(we,{children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`h-10 w-10 rounded-xl bg-gradient-to-br ${Z} flex items-center justify-center`,children:a.jsx(Q,{className:"h-5 w-5 text-white"})}),a.jsxs("div",{children:[a.jsx(je,{className:"capitalize",children:V}),a.jsx(ve,{children:e("configureMessageChannelParameters")})]})]})}),a.jsxs("form",{onSubmit:Y,className:"flex flex-col flex-1 overflow-hidden",children:[a.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar py-2 pr-2 space-y-5",children:k.map(t=>{const s=l?T(`channels.${l}.${t.name}`,C):void 0,r=(s==null?void 0:s.label)??t.label,h=s==null?void 0:s.placeholder;return a.jsxs("div",{className:"space-y-2.5",children:[a.jsxs(Ne,{htmlFor:t.name,className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[$e(t.name),r]}),t.type==="boolean"&&a.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-gray-50",children:[a.jsx("span",{className:"text-sm text-gray-500",children:b[t.name]?e("enabled"):e("disabled")}),a.jsx(Se,{id:t.name,checked:b[t.name]||!1,onCheckedChange:p=>j(t.name,p),className:"data-[state=checked]:bg-emerald-500"})]}),(t.type==="text"||t.type==="email")&&a.jsx(D,{id:t.name,type:t.type,value:b[t.name]||"",onChange:p=>j(t.name,p.target.value),placeholder:h,className:"rounded-xl"}),t.type==="password"&&a.jsx(D,{id:t.name,type:"password",value:b[t.name]||"",onChange:p=>j(t.name,p.target.value),placeholder:h??e("leaveBlankToKeepUnchanged"),className:"rounded-xl"}),t.type==="number"&&a.jsx(D,{id:t.name,type:"number",value:b[t.name]||0,onChange:p=>j(t.name,parseInt(p.target.value)||0),placeholder:h,className:"rounded-xl"}),t.type==="tags"&&a.jsx(Be,{value:b[t.name]||[],onChange:p=>j(t.name,p)}),t.type==="select"&&a.jsxs(be,{value:b[t.name]||"",onValueChange:p=>j(t.name,p),children:[a.jsx(ue,{className:"rounded-xl",children:a.jsx(ye,{})}),a.jsx(ge,{children:(t.options??[]).map(p=>a.jsx(xe,{value:p.value,children:p.label},p.value))})]}),t.type==="json"&&a.jsx("textarea",{id:t.name,value:u[t.name]??"{}",onChange:p=>o(ee=>({...ee,[t.name]:p.target.value})),className:"min-h-[120px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono"})]},t.name)})}),a.jsxs(ke,{className:"pt-4 flex-shrink-0",children:[a.jsx(F,{type:"button",variant:"outline",onClick:d,children:e("cancel")}),a.jsx(F,{type:"submit",disabled:c.isPending||!!y,children:c.isPending?e("saving"):e("save")}),z.filter(t=>t.trigger==="manual").map(t=>a.jsx(F,{type:"button",onClick:()=>X(t),disabled:c.isPending||!!y,variant:"secondary",children:y===t.id?e("connecting"):t.title},t.id))]})]})]})})}const R={telegram:S,slack:ce,email:M,webhook:re,default:H},_e={telegram:"channelDescTelegram",slack:"channelDescSlack",email:"channelDescEmail",webhook:"channelDescWebhook",discord:"channelDescDiscord",feishu:"channelDescFeishu"};function Ze(){const{data:n}=_(),{data:d}=de(),{data:i}=q(),{openChannelModal:m}=J(),[c,g]=v.useState("active"),b=i==null?void 0:i.uiHints;if(!n||!d)return a.jsx("div",{className:"p-8 text-gray-400",children:e("channelsLoading")});const f=[{id:"active",label:e("channelsTabEnabled"),count:d.channels.filter(o=>{var y;return(y=n.channels[o.name])==null?void 0:y.enabled}).length},{id:"all",label:e("channelsTabAll"),count:d.channels.length}],u=d.channels.filter(o=>{var x;const y=((x=n.channels[o.name])==null?void 0:x.enabled)||!1;return c==="all"||y});return a.jsxs(Ce,{children:[a.jsx(Pe,{title:e("channelsPageTitle")}),a.jsx(Ie,{tabs:f,activeTab:c,onChange:g}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:u.map(o=>{const y=n.channels[o.name],x=(y==null?void 0:y.enabled)||!1,l=R[o.name]||R.default,w=T(`channels.${o.name}`,b),k=(w==null?void 0:w.help)||e(_e[o.name]||"channelDescriptionDefault");return a.jsxs(De,{onClick:()=>m(o.name),children:[a.jsxs(Fe,{children:[a.jsx(Te,{name:o.name,src:Me(o.name),className:G("h-11 w-11 rounded-xl border transition-all",x?"bg-white border-primary/30":"bg-white border-gray-200/60 group-hover:border-gray-300"),imgClassName:"h-5 w-5",fallback:a.jsx(l,{className:"h-5 w-5"})}),a.jsx(Ae,{status:x?"active":"inactive",label:x?e("statusActive"):e("statusInactive")})]}),a.jsx(Le,{title:o.displayName||o.name,description:k}),a.jsxs(Ue,{children:[a.jsx(Ee,{label:x?e("actionConfigure"):e("actionEnable")}),o.tutorialUrl&&a.jsx("a",{href:o.tutorialUrl,target:"_blank",rel:"noreferrer",onClick:C=>C.stopPropagation(),className:"flex items-center justify-center h-6 w-6 rounded-md text-gray-300 hover:text-gray-500 hover:bg-gray-100/60 transition-colors",title:e("channelsGuideTitle"),children:a.jsx(ie,{className:"h-3.5 w-3.5"})})]})]},o.name)})}),u.length===0&&a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[a.jsx("div",{className:"h-14 w-14 flex items-center justify-center rounded-xl bg-gray-100/80 mb-4",children:a.jsx(H,{className:"h-6 w-6 text-gray-300"})}),a.jsx("h3",{className:"text-[14px] font-semibold text-gray-900 mb-1.5",children:e("channelsEmptyTitle")}),a.jsx("p",{className:"text-[13px] text-gray-400 max-w-sm",children:e("channelsEmptyDescription")})]}),a.jsx(He,{})]})}export{Ze as ChannelsList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n,j as e,O as T,U as L,W as F,X as H,Y as Q,Z as _,_ as V,a0 as Y}from"./vendor-Dz2q6Qmc.js";import{u as G,c as W,d as X,e as Z,f as J,I as ee}from"./useConfig-8lC_4LwH.js";import{u as se}from"./useConfirmDialog-B7iWHb5k.js";import{P as te,a as ae,B as p}from"./page-layout-Byyxptub.js";import{c as j,t,a as R,S as re,b as ne,d as ie,e as le,g as ce}from"./index-C_z1Na9N.js";import"./dialog-Ce8jNftN.js";const S="nextclaw.ui.chat.activeSession";function oe(){if(typeof window>"u")return null;try{const a=window.localStorage.getItem(S);return a&&a.trim().length>0?a:null}catch{return null}}function de(a){if(!(typeof window>"u"))try{if(!a){window.localStorage.removeItem(S);return}window.localStorage.setItem(S,a)}catch{}}function me(a){var x;const i=/^agent:([^:]+):/i.exec(a.trim());if(!i)return null;const l=(x=i[1])==null?void 0:x.trim();return l||null}function z(a){const i=Math.random().toString(36).slice(2,8);return`agent:${a}:ui:direct:web-${Date.now().toString(36)}${i}`}function xe(a){if(a.label&&a.label.trim())return a.label.trim();const i=a.key.split(":");return i[i.length-1]||a.key}function he({message:a}){const l=a.role.toLowerCase()==="user";return e.jsx("div",{className:j("flex w-full",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:j("max-w-[88%] rounded-2xl px-4 py-3 shadow-sm border",l?"bg-primary text-white border-primary rounded-br-md":"bg-white text-gray-800 border-gray-200 rounded-bl-md"),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[11px] opacity-80",children:[l?e.jsx(V,{className:"h-3.5 w-3.5"}):e.jsx(Y,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-semibold",children:a.role}),e.jsx("span",{children:R(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:a.content})]})})}function je(){var K,A,E;const[a,i]=n.useState(""),[l,x]=n.useState(""),[r,h]=n.useState(()=>oe()),[u,C]=n.useState("main"),[w,b]=n.useState(null),{confirm:O,ConfirmDialog:$}=se(),k=n.useRef(null),P=G(),o=W({q:a.trim()||void 0,limit:120,activeMinutes:0}),g=X(r,300),I=Z(),d=J(),B=n.useMemo(()=>{var f;const s=((f=P.data)==null?void 0:f.agents.list)??[],c=new Set(["main"]);for(const y of s)typeof y.id=="string"&&y.id.trim().length>0&&c.add(y.id.trim().toLowerCase());return Array.from(c)},[(K=P.data)==null?void 0:K.agents.list]),m=n.useMemo(()=>{var s;return((s=o.data)==null?void 0:s.sessions)??[]},[(A=o.data)==null?void 0:A.sessions]),U=n.useMemo(()=>m.find(s=>s.key===r)??null,[r,m]),N=n.useMemo(()=>{var s;return((s=g.data)==null?void 0:s.messages)??[]},[(E=g.data)==null?void 0:E.messages]),v=n.useMemo(()=>w?[...N,w]:N,[N,w]);n.useEffect(()=>{!r&&m.length>0&&h(m[0].key)},[r,m]),n.useEffect(()=>{de(r)},[r]),n.useEffect(()=>{const s=r?me(r):null;s&&u!==s&&C(s)},[u,r]),n.useEffect(()=>{const s=k.current;s&&(s.scrollTop=s.scrollHeight)},[v.length,d.isPending,r]);const D=()=>{const s=z(u);h(s),b(null)},q=async()=>{!r||!await O({title:t("chatDeleteSessionConfirm"),variant:"destructive",confirmLabel:t("delete")})||I.mutate({key:r},{onSuccess:async()=>{h(null),b(null),await o.refetch()}})},M=async()=>{const s=l.trim();if(!s||d.isPending)return;const c=!!r,f=r??z(u);r||h(f),x(""),b({role:"user",content:s,timestamp:new Date().toISOString()});try{const y=await d.mutateAsync({data:{message:s,sessionKey:f,agentId:u,channel:"ui",chatId:"web-ui"}});b(null),y.sessionKey!==f&&h(y.sessionKey),await o.refetch(),c&&await g.refetch()}catch{b(null),x(s)}};return e.jsxs(te,{fullHeight:!0,children:[e.jsx(ae,{title:t("chatPageTitle"),description:t("chatPageDescription"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>g.refetch(),className:"rounded-lg",children:[e.jsx(T,{className:j("h-3.5 w-3.5 mr-1.5",g.isFetching&&"animate-spin")}),t("chatRefresh")]}),e.jsxs(p,{variant:"primary",size:"sm",onClick:D,className:"rounded-lg",children:[e.jsx(L,{className:"h-3.5 w-3.5 mr-1.5"}),t("chatNewSession")]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex gap-4 max-lg:flex-col",children:[e.jsxs("aside",{className:"w-[320px] max-lg:w-full shrink-0 rounded-2xl border border-gray-200 bg-white shadow-card flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(F,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(ee,{value:a,onChange:s=>i(s.target.value),placeholder:t("chatSearchSessionPlaceholder"),className:"pl-8 h-9 rounded-lg text-xs"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",className:"rounded-lg",onClick:()=>o.refetch(),children:[e.jsx(T,{className:j("h-3.5 w-3.5 mr-1.5",o.isFetching&&"animate-spin")}),t("chatRefresh")]}),e.jsxs(p,{variant:"subtle",size:"sm",className:"rounded-lg",onClick:D,children:[e.jsx(L,{className:"h-3.5 w-3.5 mr-1.5"}),t("chatNewSession")]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar p-2",children:o.isLoading?e.jsx("div",{className:"text-sm text-gray-500 p-4",children:t("sessionsLoading")}):m.length===0?e.jsxs("div",{className:"p-5 m-2 rounded-xl border border-dashed border-gray-200 text-center text-sm text-gray-500",children:[e.jsx(H,{className:"h-7 w-7 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):e.jsx("div",{className:"space-y-1",children:m.map(s=>{const c=r===s.key;return e.jsxs("button",{onClick:()=>h(s.key),className:j("w-full rounded-xl border px-3 py-2.5 text-left transition-all",c?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-50"),children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 truncate",children:xe(s)}),e.jsx("div",{className:"mt-1 text-[11px] text-gray-500 truncate",children:s.key}),e.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:[s.messageCount," · ",R(s.updatedAt)]})]},s.key)})})})]}),e.jsxs("section",{className:"flex-1 min-h-0 rounded-2xl border border-gray-200 bg-gradient-to-b from-gray-50/60 to-white shadow-card flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-200/80 bg-white/80 backdrop-blur-sm flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"min-w-[220px] max-w-[320px]",children:[e.jsx("div",{className:"text-[11px] text-gray-500 mb-1",children:t("chatAgentLabel")}),e.jsxs(re,{value:u,onValueChange:C,children:[e.jsx(ne,{className:"h-9 rounded-lg",children:e.jsx(ie,{placeholder:t("chatSelectAgent")})}),e.jsx(le,{children:B.map(s=>e.jsx(ce,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"flex-1 min-w-[260px]",children:[e.jsx("div",{className:"text-[11px] text-gray-500 mb-1",children:t("chatSessionLabel")}),e.jsx("div",{className:"h-9 rounded-lg border border-gray-200 bg-white px-3 text-xs text-gray-600 flex items-center truncate",children:r??t("chatNoSession")})]}),e.jsxs(p,{variant:"outline",size:"sm",className:"rounded-lg self-end",onClick:q,disabled:!U||I.isPending,children:[e.jsx(Q,{className:"h-3.5 w-3.5 mr-1.5"}),t("chatDeleteSession")]})]}),e.jsx("div",{ref:k,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar px-5 py-5 space-y-3",children:r?g.isLoading?e.jsx("div",{className:"text-sm text-gray-500",children:t("chatHistoryLoading")}):e.jsxs(e.Fragment,{children:[v.length===0?e.jsx("div",{className:"text-sm text-gray-500",children:t("chatNoMessages")}):v.map((s,c)=>e.jsx(he,{message:s},`${s.timestamp}-${s.role}-${c}`)),d.isPending&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"rounded-2xl rounded-bl-md border border-gray-200 bg-white px-4 py-3 text-sm text-gray-500",children:t("chatTyping")})})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500",children:[e.jsx(H,{className:"h-8 w-8 mx-auto mb-2 text-gray-300"}),e.jsx("div",{className:"text-sm font-medium",children:t("chatNoSession")}),e.jsx("div",{className:"text-xs mt-1",children:t("chatNoSessionHint")})]})})}),e.jsx("div",{className:"border-t border-gray-200 bg-white p-4",children:e.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-2",children:[e.jsx("textarea",{value:l,onChange:s=>x(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),M())},placeholder:t("chatInputPlaceholder"),className:"w-full min-h-[68px] max-h-[220px] resize-y bg-transparent outline-none text-sm px-2 py-1.5 text-gray-800 placeholder:text-gray-400",disabled:d.isPending}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-1",children:[e.jsx("div",{className:"text-[11px] text-gray-400",children:t("chatInputHint")}),e.jsxs(p,{size:"sm",className:"rounded-lg",onClick:()=>void M(),disabled:d.isPending||l.trim().length===0,children:[e.jsx(_,{className:"h-3.5 w-3.5 mr-1.5"}),d.isPending?t("chatSending"):t("chatSend")]})]})]})})]})]}),e.jsx($,{})]})}export{je as ChatPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as x,j as e,O as j,A as D,ai as L,aj as R,Y as k}from"./vendor-Dz2q6Qmc.js";import{u as E}from"./useConfirmDialog-B7iWHb5k.js";import{m as M,n as P,o as T,p as J,I as A}from"./useConfig-8lC_4LwH.js";import{P as F,a as z,B as o}from"./page-layout-Byyxptub.js";import{c as p,t,S as B,b as I,d as Q,e as q,g as f,a as y}from"./index-C_z1Na9N.js";import{C as H,d as O}from"./card-Cj58-DCd.js";import"./dialog-Ce8jNftN.js";function g(s){return y(s??void 0)}function V(s){return typeof s!="number"||!Number.isFinite(s)?"-":y(new Date(s))}function Y(s){if(typeof s!="number"||!Number.isFinite(s))return"-";const r=Math.round(s/1e3);if(r<60)return`${r}s`;const n=Math.round(r/60);if(n<60)return`${n}m`;const c=Math.round(n/60);return c<24?`${c}h`:`${Math.round(c/24)}d`}function G(s){const r=s.schedule;return r.kind==="cron"?r.expr?`cron ${r.expr}`:"cron":r.kind==="every"?`every ${Y(r.everyMs)}`:r.kind==="at"?`at ${V(r.atMs)}`:"-"}function K(s){if(!s.payload.deliver)return"-";const r=s.payload.channel??"-",n=s.payload.to??"-";return`${r}:${n}`}function U(s,r){const n=r.trim().toLowerCase();return n?[s.id,s.name,s.payload.message,s.payload.channel??"",s.payload.to??""].join(" ").toLowerCase().includes(n):!0}function W(s,r){return r==="all"?!0:r==="enabled"?s.enabled:!s.enabled}function re(){var h;const[s,r]=x.useState(""),[n,c]=x.useState("all"),i=M({all:!0}),v=P(),N=T(),w=J(),{confirm:m,ConfirmDialog:C}=E(),u=x.useMemo(()=>{var l;return(((l=i.data)==null?void 0:l.jobs)??[]).filter(d=>U(d,s)).filter(d=>W(d,n))},[i.data,s,n]),b=async a=>{await m({title:`${t("cronDeleteConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,variant:"destructive",confirmLabel:t("delete")})&&v.mutate({id:a.id})},S=async a=>{const l=!a.enabled;await m({title:l?`${t("cronEnableConfirm")}?`:`${t("cronDisableConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,variant:l?"default":"destructive",confirmLabel:l?t("cronEnable"):t("cronDisable")})&&N.mutate({id:a.id,enabled:l})},$=async a=>{const l=!a.enabled;await m({title:l?`${t("cronRunForceConfirm")}?`:`${t("cronRunConfirm")}?`,description:a.name?`${a.name} (${a.id})`:a.id,confirmLabel:t("cronRunNow")})&&w.mutate({id:a.id,force:l})};return e.jsxs(F,{fullHeight:!0,children:[e.jsx(z,{title:t("cronPageTitle"),description:t("cronPageDescription"),actions:e.jsx(o,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>i.refetch(),children:e.jsx(j,{className:p("h-4 w-4",i.isFetching&&"animate-spin")})})}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(A,{value:s,onChange:a=>r(a.target.value),placeholder:t("cronSearchPlaceholder"),className:"pl-9"}),e.jsx(D,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),e.jsx("div",{className:"min-w-[180px]",children:e.jsxs(B,{value:n,onValueChange:a=>c(a),children:[e.jsx(I,{className:"w-full",children:e.jsx(Q,{placeholder:t("cronStatusLabel")})}),e.jsxs(q,{children:[e.jsx(f,{value:"all",children:t("cronStatusAll")}),e.jsx(f,{value:"enabled",children:t("cronStatusEnabled")}),e.jsx(f,{value:"disabled",children:t("cronStatusDisabled")})]})]})}),e.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[t("cronTotalLabel"),": ",((h=i.data)==null?void 0:h.total)??0," / ",u.length]})]})}),e.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("cronLoading")}):u.length===0?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("cronEmpty")}):e.jsx("div",{className:"space-y-4",children:u.map(a=>e.jsx(H,{className:"border border-gray-200",children:e.jsx(O,{className:"pt-5 pb-5",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-[220px] flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:a.name||a.id}),e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:a.id}),e.jsx("span",{className:p("text-[10px] font-semibold px-2 py-0.5 rounded-full",a.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:a.enabled?t("enabled"):t("disabled")}),a.deleteAfterRun&&e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:t("cronOneShot")})]}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[t("cronScheduleLabel"),": ",G(a)]}),e.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:a.payload.message}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[t("cronDeliverTo"),": ",K(a)]})]}),e.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronNextRun"),":"]})," ",g(a.state.nextRunAt)]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronLastRun"),":"]})," ",g(a.state.lastRunAt)]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[t("cronLastStatus"),":"]})," ",a.state.lastStatus??"-"]}),a.state.lastError&&e.jsx("div",{className:"text-[11px] text-red-500 break-words",children:a.state.lastError})]}),e.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[e.jsxs(o,{variant:"subtle",size:"sm",onClick:()=>$(a),className:"gap-1",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),t("cronRunNow")]}),e.jsxs(o,{variant:a.enabled?"outline":"primary",size:"sm",onClick:()=>S(a),className:"gap-1",children:[e.jsx(R,{className:"h-3.5 w-3.5"}),a.enabled?t("cronDisable"):t("cronEnable")]}),e.jsxs(o,{variant:"destructive",size:"sm",onClick:()=>b(a),className:"gap-1",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),t("delete")]})]})]})})},a.id))})}),e.jsx(C,{})]})}export{re as CronConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t,
|
|
1
|
+
import{r as s,j as t,s as J,aM as K,aN as Q,a6 as Z,aO as ee,ae as te,W as re,ad as se,aP as oe}from"./vendor-Dz2q6Qmc.js";import{j as ae,D as W,t as x,c as C}from"./index-C_z1Na9N.js";function ce(){const{isOpen:P,mode:h,currentUrl:i,navVersion:f,close:B,toggleMode:U,goBack:Y,goForward:F,canGoBack:O,canGoForward:I,navigate:v,syncUrl:M}=ae(),[b,y]=s.useState(""),[j,z]=s.useState(!1),[A,m]=s.useState(!1),[l,N]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[a,R]=s.useState({w:480,h:600}),[E,_]=s.useState(420),c=s.useRef(null),d=s.useRef(null),p=s.useRef(null),k=s.useRef(null),X=s.useRef(f);s.useEffect(()=>{try{const e=new URL(i);y(e.pathname)}catch{y(i)}},[i]),s.useEffect(()=>{var e;if(f!==X.current){X.current=f;return}if((e=k.current)!=null&&e.contentWindow)try{const r=new URL(i).pathname;k.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}},[i,f]),s.useEffect(()=>{h==="floating"&&N(e=>({x:Math.max(40,window.innerWidth-a.w-40),y:e.y}))},[h,a.w]),s.useEffect(()=>{const e=r=>{var o;((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&M(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[M]);const $=s.useCallback(e=>{e.preventDefault();const r=b.trim();r&&(r.startsWith("/")?v(`${W}${r}`):r.startsWith("http")?v(r):v(`${W}/${r}`))},[b,v]),G=s.useCallback(e=>{h==="floating"&&(z(!0),c.current={startX:e.clientX,startY:e.clientY,startPosX:l.x,startPosY:l.y})},[h,l]);s.useEffect(()=>{if(!j)return;const e=o=>{c.current&&N({x:c.current.startPosX+(o.clientX-c.current.startX),y:c.current.startPosY+(o.clientY-c.current.startY)})},r=()=>{z(!1),c.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[j]);const L=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),m(!0);const r=e.currentTarget.dataset.axis;d.current={startX:e.clientX,startY:e.clientY,startW:a.w,startH:a.h};const o=u=>{d.current&&R(g=>({w:r==="y"?g.w:Math.max(360,d.current.startW+(u.clientX-d.current.startX)),h:r==="x"?g.h:Math.max(400,d.current.startH+(u.clientY-d.current.startY))}))},w=()=>{m(!1),d.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",w)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",w)},[a]),T=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),m(!0),p.current={startX:e.clientX,startW:E};const r=w=>{if(!p.current)return;const u=p.current.startX-w.clientX;_(Math.max(320,Math.min(800,p.current.startW+u)))},o=()=>{m(!1),p.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[E]),V=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),m(!0);const r=e.clientX,o=a.w,w=l.x,u=H=>{const q=r-H.clientX,S=Math.max(360,o+q);R(D=>({...D,w:S})),N(D=>({...D,x:w-(S-o)}))},g=()=>{m(!1),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",g)};window.addEventListener("mousemove",u),window.addEventListener("mouseup",g)},[a.w,l.x]);if(!P)return null;const n=h==="docked";return t.jsxs("div",{className:C("flex flex-col bg-white overflow-hidden relative",n?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:n?{width:E}:{position:"fixed",left:l.x,top:l.y,width:a.w,height:a.h,zIndex:9999},children:[n&&t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:T}),t.jsxs("div",{className:C("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!n&&"cursor-grab active:cursor-grabbing"),onMouseDown:n?void 0:G,children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(J,{className:"w-4 h-4 text-primary"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900",children:x("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:U,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:n?x("docBrowserFloatMode"):x("docBrowserDockMode"),children:n?t.jsx(K,{className:"w-3.5 h-3.5"}):t.jsx(Q,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:B,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:x("docBrowserClose"),children:t.jsx(Z,{className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:Y,disabled:!O,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ee,{className:"w-4 h-4"})}),t.jsx("button",{onClick:F,disabled:!I,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(te,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:$,className:"flex-1 relative",children:[t.jsx(re,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:b,onChange:e=>y(e.target.value),placeholder:x("docBrowserSearchPlaceholder"),className:"w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:k,src:i,className:"absolute inset-0 w-full h-full border-0",title:"NextClaw Documentation",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},f),(A||j)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","data-doc-external":!0,className:"flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors",children:[x("docBrowserOpenExternal"),t.jsx(se,{className:"w-3 h-3"})]})}),!n&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:V}),t.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:L,"data-axis":"x"}),t.jsx("div",{className:"absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:L,"data-axis":"y"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors",onMouseDown:L,children:t.jsx(oe,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{ce as DocBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as s,al as Oe,am as $e,an as Fe,ao as xe,ap as qe,aq as He,ar as E,as as he,at as Ke,au as Ue,av as ze,aw as Qe,ax as Be,ay as Ge,az as Ve,ai as ye,aj as be,ak as ke,a2 as q,aA as Ye,aB as Xe,aC as We}from"./vendor-Bhv7yx8z.js";import{c as ve,i as H,t as c,S as Ze,a as Je,b as et,d as tt,e as ge}from"./index-DFfB9XKS.js";import{T as at}from"./tabs-custom-tbDoqtk2.js";import{P as Te}from"./dialog-DJSdVlnI.js";import{u as nt}from"./useConfirmDialog-Dj945N0Y.js";import{P as st,a as rt}from"./page-layout-BuYR443L.js";var[K]=Ue("Tooltip",[he]),U=he(),Ce="TooltipProvider",lt=700,Y="tooltip.open",[ot,Z]=K(Ce),Se=e=>{const{__scopeTooltip:t,delayDuration:a=lt,skipDelayDuration:n=300,disableHoverableContent:l=!1,children:r}=e,u=o.useRef(!0),b=o.useRef(!1),d=o.useRef(0);return o.useEffect(()=>{const x=d.current;return()=>window.clearTimeout(x)},[]),s.jsx(ot,{scope:t,isOpenDelayedRef:u,delayDuration:a,onOpen:o.useCallback(()=>{window.clearTimeout(d.current),u.current=!1},[]),onClose:o.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u.current=!0,n)},[n]),isPointerInTransitRef:b,onPointerInTransitChange:o.useCallback(x=>{b.current=x},[]),disableHoverableContent:l,children:r})};Se.displayName=Ce;var L="Tooltip",[it,A]=K(L),Pe=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:l,onOpenChange:r,disableHoverableContent:u,delayDuration:b}=e,d=Z(L,e.__scopeTooltip),x=U(t),[i,h]=o.useState(null),k=Oe(),m=o.useRef(0),T=u??d.disableHoverableContent,y=b??d.delayDuration,C=o.useRef(!1),[P,f]=$e({prop:n,defaultProp:l??!1,onChange:O=>{O?(d.onOpen(),document.dispatchEvent(new CustomEvent(Y))):d.onClose(),r==null||r(O)},caller:L}),v=o.useMemo(()=>P?C.current?"delayed-open":"instant-open":"closed",[P]),j=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,C.current=!1,f(!0)},[f]),S=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,f(!1)},[f]),_=o.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{C.current=!0,f(!0),m.current=0},y)},[y,f]);return o.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(Fe,{...x,children:s.jsx(it,{scope:t,contentId:k,open:P,stateAttribute:v,trigger:i,onTriggerChange:h,onTriggerEnter:o.useCallback(()=>{d.isOpenDelayedRef.current?_():j()},[d.isOpenDelayedRef,_,j]),onTriggerLeave:o.useCallback(()=>{T?S():(window.clearTimeout(m.current),m.current=0)},[S,T]),onOpen:j,onClose:S,disableHoverableContent:T,children:a})})};Pe.displayName=L;var X="TooltipTrigger",we=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=A(X,a),r=Z(X,a),u=U(a),b=o.useRef(null),d=xe(t,b,l.onTriggerChange),x=o.useRef(!1),i=o.useRef(!1),h=o.useCallback(()=>x.current=!1,[]);return o.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(qe,{asChild:!0,...u,children:s.jsx(He.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...n,ref:d,onPointerMove:E(e.onPointerMove,k=>{k.pointerType!=="touch"&&!i.current&&!r.isPointerInTransitRef.current&&(l.onTriggerEnter(),i.current=!0)}),onPointerLeave:E(e.onPointerLeave,()=>{l.onTriggerLeave(),i.current=!1}),onPointerDown:E(e.onPointerDown,()=>{l.open&&l.onClose(),x.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:E(e.onFocus,()=>{x.current||l.onOpen()}),onBlur:E(e.onBlur,l.onClose),onClick:E(e.onClick,l.onClose)})})});we.displayName=X;var J="TooltipPortal",[ct,ut]=K(J,{forceMount:void 0}),je=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:l}=e,r=A(J,t);return s.jsx(ct,{scope:t,forceMount:a,children:s.jsx(Te,{present:a||r.open,children:s.jsx(Ke,{asChild:!0,container:l,children:n})})})};je.displayName=J;var R="TooltipContent",Ie=o.forwardRef((e,t)=>{const a=ut(R,e.__scopeTooltip),{forceMount:n=a.forceMount,side:l="top",...r}=e,u=A(R,e.__scopeTooltip);return s.jsx(Te,{present:n||u.open,children:u.disableHoverableContent?s.jsx(Ne,{side:l,...r,ref:t}):s.jsx(dt,{side:l,...r,ref:t})})}),dt=o.forwardRef((e,t)=>{const a=A(R,e.__scopeTooltip),n=Z(R,e.__scopeTooltip),l=o.useRef(null),r=xe(t,l),[u,b]=o.useState(null),{trigger:d,onClose:x}=a,i=l.current,{onPointerInTransitChange:h}=n,k=o.useCallback(()=>{b(null),h(!1)},[h]),m=o.useCallback((T,y)=>{const C=T.currentTarget,P={x:T.clientX,y:T.clientY},f=xt(P,C.getBoundingClientRect()),v=ht(P,f),j=yt(y.getBoundingClientRect()),S=kt([...v,...j]);b(S),h(!0)},[h]);return o.useEffect(()=>()=>k(),[k]),o.useEffect(()=>{if(d&&i){const T=C=>m(C,i),y=C=>m(C,d);return d.addEventListener("pointerleave",T),i.addEventListener("pointerleave",y),()=>{d.removeEventListener("pointerleave",T),i.removeEventListener("pointerleave",y)}}},[d,i,m,k]),o.useEffect(()=>{if(u){const T=y=>{const C=y.target,P={x:y.clientX,y:y.clientY},f=(d==null?void 0:d.contains(C))||(i==null?void 0:i.contains(C)),v=!bt(P,u);f?k():v&&(k(),x())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[d,i,u,x,k]),s.jsx(Ne,{...e,ref:r})}),[pt,mt]=K(L,{isInside:!1}),gt=Ge("TooltipContent"),Ne=o.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":l,onEscapeKeyDown:r,onPointerDownOutside:u,...b}=e,d=A(R,a),x=U(a),{onClose:i}=d;return o.useEffect(()=>(document.addEventListener(Y,i),()=>document.removeEventListener(Y,i)),[i]),o.useEffect(()=>{if(d.trigger){const h=k=>{const m=k.target;m!=null&&m.contains(d.trigger)&&i()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,i]),s.jsx(ze,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:u,onFocusOutside:h=>h.preventDefault(),onDismiss:i,children:s.jsxs(Qe,{"data-state":d.stateAttribute,...x,...b,ref:t,style:{...b.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(gt,{children:n}),s.jsx(pt,{scope:a,isInside:!0,children:s.jsx(Be,{id:d.contentId,role:"tooltip",children:l||n})})]})})});Ie.displayName=R;var Ee="TooltipArrow",ft=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=U(a);return mt(Ee,a).isInside?null:s.jsx(Ve,{...l,...n,ref:t})});ft.displayName=Ee;function xt(e,t){const a=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),l=Math.abs(t.right-e.x),r=Math.abs(t.left-e.x);switch(Math.min(a,n,l,r)){case r:return"left";case l:return"right";case a:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function ht(e,t,a=5){const n=[];switch(t){case"top":n.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":n.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":n.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":n.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return n}function yt(e){const{top:t,right:a,bottom:n,left:l}=e;return[{x:l,y:t},{x:a,y:t},{x:a,y:n},{x:l,y:n}]}function bt(e,t){const{x:a,y:n}=e;let l=!1;for(let r=0,u=t.length-1;r<t.length;u=r++){const b=t[r],d=t[u],x=b.x,i=b.y,h=d.x,k=d.y;i>n!=k>n&&a<(h-x)*(n-i)/(k-i)+x&&(l=!l)}return l}function kt(e){const t=e.slice();return t.sort((a,n)=>a.x<n.x?-1:a.x>n.x?1:a.y<n.y?-1:a.y>n.y?1:0),vt(t)}function vt(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const l=e[n];for(;t.length>=2;){const r=t[t.length-1],u=t[t.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))t.pop();else break}t.push(l)}t.pop();const a=[];for(let n=e.length-1;n>=0;n--){const l=e[n];for(;a.length>=2;){const r=a[a.length-1],u=a[a.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))a.pop();else break}a.push(l)}return a.pop(),t.length===1&&a.length===1&&t[0].x===a[0].x&&t[0].y===a[0].y?t:t.concat(a)}var Tt=Se,Ct=Pe,St=we,Pt=je,Me=Ie;const wt=Tt,G=Ct,V=St,F=o.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(Pt,{children:s.jsx(Me,{ref:n,sideOffset:t,className:ve("z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...a})}));F.displayName=Me.displayName;function z(e){return e==="plugin"?"plugins":"skills"}async function jt(e){var r,u;const t=new URLSearchParams,a=z(e.type);(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),(u=e.tag)!=null&&u.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const n=t.toString(),l=await H.get(n?`/api/marketplace/${a}/items?${n}`:`/api/marketplace/${a}/items`);if(!l.ok)throw new Error(l.error.message);return l.data}async function It(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function Nt(e){const t=z(e),a=await H.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function Et(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Mt(e){return ye({queryKey:["marketplace-items",e],queryFn:()=>jt(e),staleTime:15e3})}function Rt(e){return ye({queryKey:["marketplace-installed",e],queryFn:()=>Nt(e),staleTime:1e4})}function Dt(){const e=be();return ke({mutationFn:t=>It(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.type==="plugin"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceInstallFailed"))}})}function Lt(){const e=be();return ke({mutationFn:t=>Et(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.action==="enable"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceOperationFailed"))}})}const At=12;function W(e){return(e??"").trim().toLowerCase()}function M(e,t){const a=W(t);return a.length>0?`${e}:${a}`:""}function _t(e){const t=new Map;for(const a of e){const n=[a.install.spec,a.slug,a.id];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function Ot(e){const t=new Map;for(const a of e){const n=[a.spec,a.id,a.label];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function $t(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const l=M(e.type,n);if(!l)continue;const r=t.get(l);if(r)return r}}function Ft(e,t){const a=t.get(M(e.type,e.spec));if(a)return a;const n=t.get(M(e.type,e.id));return n||t.get(M(e.type,e.label))}function qt(e,t,a){const n=W(a);return n?[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,...(t==null?void 0:t.tags)??[]].map(r=>W(r)).filter(Boolean).some(r=>r.includes(n)):!0}function Ht(e){const t=["bg-amber-600","bg-orange-500","bg-yellow-600","bg-emerald-600","bg-teal-600","bg-cyan-600","bg-stone-600","bg-rose-500","bg-violet-500"];let a=0;for(let n=0;n<e.length;n++)a=e.charCodeAt(n)+((a<<5)-a);return t[Math.abs(a)%t.length]}function Kt({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),l=Ht(a);return s.jsx("div",{className:ve("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",l),children:n})}function Ut(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(We,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(Ze,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(Je,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(et,{})}),s.jsxs(tt,{children:[s.jsx(ge,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(ge,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function fe(e){var P,f,v,j,S;const t=e.record,a=(t==null?void 0:t.type)==="plugin"?t:void 0,n=((P=e.item)==null?void 0:P.type)??(t==null?void 0:t.type),l=((f=e.item)==null?void 0:f.name)??(t==null?void 0:t.label)??(t==null?void 0:t.id)??(t==null?void 0:t.spec)??c("marketplaceUnknownItem"),r=((v=e.item)==null?void 0:v.summary)??(t?c("marketplaceInstalledLocalSummary"):""),u=((j=e.item)==null?void 0:j.install.spec)??(t==null?void 0:t.spec)??"",b=(t==null?void 0:t.id)||(t==null?void 0:t.spec),d=!!b&&e.manageState.isPending&&e.manageState.targetId===b,x=!!a,i=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",h=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",k=!!(i||h),m=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,T=(S=e.item)==null?void 0:S.install.spec,y=typeof T=="string"&&e.installState.installingSpecs.has(T),C=n==="plugin"?c("marketplaceTypePlugin"):n==="skill"?c("marketplaceTypeSkill"):c("marketplaceTypeExtension");return s.jsxs("article",{className:"group bg-white border border-gray-200/40 hover:border-gray-200/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-default",children:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(Kt,{name:l,fallback:u||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(wt,{delayDuration:400,children:[s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight cursor-default",children:l})}),s.jsx(F,{className:"max-w-[300px] text-xs",children:l})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:C}),u&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono cursor-default",children:u})}),s.jsx(F,{className:"max-w-[300px] text-xs font-mono break-all",children:u})]})]})]}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left cursor-default",children:r})}),r&&s.jsx(F,{className:"max-w-[400px] text-xs leading-relaxed",children:r})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[e.item&&!t&&s.jsx("button",{onClick:()=>e.onInstall(e.item),disabled:y,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:y?c("marketplaceInstalling"):c("marketplaceInstall")}),a&&x&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage(m?"enable":"disable",a),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:d&&e.manageState.action!=="uninstall"?e.manageState.action==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):m?c("marketplaceEnable"):c("marketplaceDisable")}),t&&k&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage("uninstall",t),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:d&&e.manageState.action==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function zt(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}function Wt(){var le,oe,ie,ce,ue,de,pe,me;const e=Ye(),t=Xe(),a=o.useMemo(()=>t.type==="plugins"||t.type==="skills"?t.type:null,[t.type]);o.useEffect(()=>{a||e("/marketplace/plugins",{replace:!0})},[a,e]);const n=a==="skills"?"skill":"plugin",r=n==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[u,b]=o.useState(""),[d,x]=o.useState(""),[i,h]=o.useState("all"),[k,m]=o.useState("relevance"),[T,y]=o.useState(1),[C,P]=o.useState(new Set);o.useEffect(()=>{const p=setTimeout(()=>{y(1),x(u.trim())},250);return()=>clearTimeout(p)},[u]),o.useEffect(()=>{y(1)},[n]);const f=Rt(n),v=Mt({q:d||void 0,type:n,sort:k,page:T,pageSize:At}),j=Dt(),S=Lt(),{confirm:_,ConfirmDialog:O}=nt(),$=o.useMemo(()=>{var p;return((p=f.data)==null?void 0:p.records)??[]},[(le=f.data)==null?void 0:le.records]),N=o.useMemo(()=>{var p;return((p=v.data)==null?void 0:p.items)??[]},[(oe=v.data)==null?void 0:oe.items]),ee=o.useMemo(()=>_t(N),[N]),Re=o.useMemo(()=>Ot($),[$]),D=o.useMemo(()=>{const p=$.filter(g=>g.type===n).map(g=>({key:`${g.type}:${g.spec}:${g.id??""}`,record:g,item:Ft(g,ee)})).filter(g=>qt(g.record,g.item,d));return p.sort((g,w)=>{const I=g.record.installedAt?Date.parse(g.record.installedAt):Number.NaN,B=w.record.installedAt?Date.parse(w.record.installedAt):Number.NaN,Ae=!Number.isNaN(I),_e=!Number.isNaN(B);return Ae&&_e&&I!==B?B-I:g.record.spec.localeCompare(w.record.spec)}),p},[$,n,ee,d]),te=i==="installed"?D.length:((ie=v.data)==null?void 0:ie.total)??0,Q=i==="installed"?1:((ce=v.data)==null?void 0:ce.totalPages)??0,De=o.useMemo(()=>i==="installed"?f.isLoading?c("loading"):`${D.length} ${c(r.installedCountSuffix)}`:v.data?`${N.length} / ${te}`:c("loading"),[i,f.isLoading,D.length,v.data,N.length,te,r.installedCountSuffix]),ae={installingSpecs:C},ne={isPending:S.isPending,targetId:((ue=S.variables)==null?void 0:ue.id)||((de=S.variables)==null?void 0:de.spec),action:(pe=S.variables)==null?void 0:pe.action},Le=[{id:"all",label:c(r.tabMarketplace)},{id:"installed",label:c(r.tabInstalled),count:((me=f.data)==null?void 0:me.total)??0}],se=async p=>{const g=p.install.spec;if(!C.has(g)){P(w=>{const I=new Set(w);return I.add(g),I});try{await j.mutateAsync({type:p.type,spec:g,kind:p.install.kind,...p.type==="skill"?{skill:p.slug,installPath:`skills/${p.slug}`}:{}})}catch{}finally{P(w=>{if(!w.has(g))return w;const I=new Set(w);return I.delete(g),I})}}},re=async(p,g)=>{if(S.isPending)return;const w=g.id||g.spec;w&&(p==="uninstall"&&!await _({title:`${c("marketplaceUninstallTitle")} ${w}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"})||S.mutate({type:g.type,action:p,id:w,spec:g.spec}))};return s.jsxs(st,{children:[s.jsx(rt,{title:c(r.pageTitle),description:c(r.pageDescription)}),s.jsx(at,{tabs:Le,activeTab:i,onChange:p=>{h(p),y(1)},className:"mb-4"}),s.jsx(Ut,{scope:i,searchText:u,searchPlaceholder:c(r.searchPlaceholder),sort:k,onSearchTextChange:b,onSortChange:p=>{y(1),m(p)}}),s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:i==="installed"?c(r.sectionInstalled):c(r.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:De})]}),i==="all"&&v.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadData),": ",v.error.message]}),i==="installed"&&f.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadInstalled),": ",f.error.message]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[i==="all"&&N.map(p=>s.jsx(fe,{item:p,record:$t(p,Re),installState:ae,manageState:ne,onInstall:se,onManage:re},p.id)),i==="installed"&&D.map(p=>s.jsx(fe,{item:p.item,record:p.record,installState:ae,manageState:ne,onInstall:se,onManage:re},p.key))]}),i==="all"&&!v.isLoading&&!v.isError&&N.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyData)}),i==="installed"&&!f.isLoading&&!f.isError&&D.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyInstalled)})]}),i==="all"&&s.jsx(zt,{page:T,totalPages:Q,busy:v.isFetching,onPrev:()=>y(p=>Math.max(1,p-1)),onNext:()=>y(p=>Q>0?Math.min(Q,p+1):p+1)}),s.jsx(O,{})]})}export{Wt as MarketplacePage};
|
|
1
|
+
import{r as o,j as s,an as Oe,ao as $e,ap as Fe,aq as xe,ar as qe,as as He,at as E,au as he,av as Ke,aw as Ue,ax as ze,ay as Qe,az as Be,aA as Ge,aB as Ve,ak as ye,al as be,am as ke,a8 as q,aC as Ye,aD as Xe,aE as We}from"./vendor-Dz2q6Qmc.js";import{c as ve,i as H,t as c,S as Ze,b as Je,d as et,e as tt,g as ge}from"./index-C_z1Na9N.js";import{T as at}from"./tabs-custom-DWlAbbCy.js";import{P as Te}from"./dialog-Ce8jNftN.js";import{u as nt}from"./useConfirmDialog-B7iWHb5k.js";import{P as st,a as rt}from"./page-layout-Byyxptub.js";var[K]=Ue("Tooltip",[he]),U=he(),Ce="TooltipProvider",lt=700,Y="tooltip.open",[ot,Z]=K(Ce),Se=e=>{const{__scopeTooltip:t,delayDuration:a=lt,skipDelayDuration:n=300,disableHoverableContent:l=!1,children:r}=e,u=o.useRef(!0),b=o.useRef(!1),d=o.useRef(0);return o.useEffect(()=>{const x=d.current;return()=>window.clearTimeout(x)},[]),s.jsx(ot,{scope:t,isOpenDelayedRef:u,delayDuration:a,onOpen:o.useCallback(()=>{window.clearTimeout(d.current),u.current=!1},[]),onClose:o.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u.current=!0,n)},[n]),isPointerInTransitRef:b,onPointerInTransitChange:o.useCallback(x=>{b.current=x},[]),disableHoverableContent:l,children:r})};Se.displayName=Ce;var L="Tooltip",[it,A]=K(L),Pe=e=>{const{__scopeTooltip:t,children:a,open:n,defaultOpen:l,onOpenChange:r,disableHoverableContent:u,delayDuration:b}=e,d=Z(L,e.__scopeTooltip),x=U(t),[i,h]=o.useState(null),k=Oe(),m=o.useRef(0),T=u??d.disableHoverableContent,y=b??d.delayDuration,C=o.useRef(!1),[P,f]=$e({prop:n,defaultProp:l??!1,onChange:O=>{O?(d.onOpen(),document.dispatchEvent(new CustomEvent(Y))):d.onClose(),r==null||r(O)},caller:L}),v=o.useMemo(()=>P?C.current?"delayed-open":"instant-open":"closed",[P]),j=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,C.current=!1,f(!0)},[f]),S=o.useCallback(()=>{window.clearTimeout(m.current),m.current=0,f(!1)},[f]),_=o.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{C.current=!0,f(!0),m.current=0},y)},[y,f]);return o.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(Fe,{...x,children:s.jsx(it,{scope:t,contentId:k,open:P,stateAttribute:v,trigger:i,onTriggerChange:h,onTriggerEnter:o.useCallback(()=>{d.isOpenDelayedRef.current?_():j()},[d.isOpenDelayedRef,_,j]),onTriggerLeave:o.useCallback(()=>{T?S():(window.clearTimeout(m.current),m.current=0)},[S,T]),onOpen:j,onClose:S,disableHoverableContent:T,children:a})})};Pe.displayName=L;var X="TooltipTrigger",we=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=A(X,a),r=Z(X,a),u=U(a),b=o.useRef(null),d=xe(t,b,l.onTriggerChange),x=o.useRef(!1),i=o.useRef(!1),h=o.useCallback(()=>x.current=!1,[]);return o.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(qe,{asChild:!0,...u,children:s.jsx(He.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...n,ref:d,onPointerMove:E(e.onPointerMove,k=>{k.pointerType!=="touch"&&!i.current&&!r.isPointerInTransitRef.current&&(l.onTriggerEnter(),i.current=!0)}),onPointerLeave:E(e.onPointerLeave,()=>{l.onTriggerLeave(),i.current=!1}),onPointerDown:E(e.onPointerDown,()=>{l.open&&l.onClose(),x.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:E(e.onFocus,()=>{x.current||l.onOpen()}),onBlur:E(e.onBlur,l.onClose),onClick:E(e.onClick,l.onClose)})})});we.displayName=X;var J="TooltipPortal",[ct,ut]=K(J,{forceMount:void 0}),je=e=>{const{__scopeTooltip:t,forceMount:a,children:n,container:l}=e,r=A(J,t);return s.jsx(ct,{scope:t,forceMount:a,children:s.jsx(Te,{present:a||r.open,children:s.jsx(Ke,{asChild:!0,container:l,children:n})})})};je.displayName=J;var R="TooltipContent",Ie=o.forwardRef((e,t)=>{const a=ut(R,e.__scopeTooltip),{forceMount:n=a.forceMount,side:l="top",...r}=e,u=A(R,e.__scopeTooltip);return s.jsx(Te,{present:n||u.open,children:u.disableHoverableContent?s.jsx(Ne,{side:l,...r,ref:t}):s.jsx(dt,{side:l,...r,ref:t})})}),dt=o.forwardRef((e,t)=>{const a=A(R,e.__scopeTooltip),n=Z(R,e.__scopeTooltip),l=o.useRef(null),r=xe(t,l),[u,b]=o.useState(null),{trigger:d,onClose:x}=a,i=l.current,{onPointerInTransitChange:h}=n,k=o.useCallback(()=>{b(null),h(!1)},[h]),m=o.useCallback((T,y)=>{const C=T.currentTarget,P={x:T.clientX,y:T.clientY},f=xt(P,C.getBoundingClientRect()),v=ht(P,f),j=yt(y.getBoundingClientRect()),S=kt([...v,...j]);b(S),h(!0)},[h]);return o.useEffect(()=>()=>k(),[k]),o.useEffect(()=>{if(d&&i){const T=C=>m(C,i),y=C=>m(C,d);return d.addEventListener("pointerleave",T),i.addEventListener("pointerleave",y),()=>{d.removeEventListener("pointerleave",T),i.removeEventListener("pointerleave",y)}}},[d,i,m,k]),o.useEffect(()=>{if(u){const T=y=>{const C=y.target,P={x:y.clientX,y:y.clientY},f=(d==null?void 0:d.contains(C))||(i==null?void 0:i.contains(C)),v=!bt(P,u);f?k():v&&(k(),x())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[d,i,u,x,k]),s.jsx(Ne,{...e,ref:r})}),[pt,mt]=K(L,{isInside:!1}),gt=Ge("TooltipContent"),Ne=o.forwardRef((e,t)=>{const{__scopeTooltip:a,children:n,"aria-label":l,onEscapeKeyDown:r,onPointerDownOutside:u,...b}=e,d=A(R,a),x=U(a),{onClose:i}=d;return o.useEffect(()=>(document.addEventListener(Y,i),()=>document.removeEventListener(Y,i)),[i]),o.useEffect(()=>{if(d.trigger){const h=k=>{const m=k.target;m!=null&&m.contains(d.trigger)&&i()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,i]),s.jsx(ze,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:u,onFocusOutside:h=>h.preventDefault(),onDismiss:i,children:s.jsxs(Qe,{"data-state":d.stateAttribute,...x,...b,ref:t,style:{...b.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(gt,{children:n}),s.jsx(pt,{scope:a,isInside:!0,children:s.jsx(Be,{id:d.contentId,role:"tooltip",children:l||n})})]})})});Ie.displayName=R;var Ee="TooltipArrow",ft=o.forwardRef((e,t)=>{const{__scopeTooltip:a,...n}=e,l=U(a);return mt(Ee,a).isInside?null:s.jsx(Ve,{...l,...n,ref:t})});ft.displayName=Ee;function xt(e,t){const a=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),l=Math.abs(t.right-e.x),r=Math.abs(t.left-e.x);switch(Math.min(a,n,l,r)){case r:return"left";case l:return"right";case a:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function ht(e,t,a=5){const n=[];switch(t){case"top":n.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":n.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":n.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":n.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return n}function yt(e){const{top:t,right:a,bottom:n,left:l}=e;return[{x:l,y:t},{x:a,y:t},{x:a,y:n},{x:l,y:n}]}function bt(e,t){const{x:a,y:n}=e;let l=!1;for(let r=0,u=t.length-1;r<t.length;u=r++){const b=t[r],d=t[u],x=b.x,i=b.y,h=d.x,k=d.y;i>n!=k>n&&a<(h-x)*(n-i)/(k-i)+x&&(l=!l)}return l}function kt(e){const t=e.slice();return t.sort((a,n)=>a.x<n.x?-1:a.x>n.x?1:a.y<n.y?-1:a.y>n.y?1:0),vt(t)}function vt(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const l=e[n];for(;t.length>=2;){const r=t[t.length-1],u=t[t.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))t.pop();else break}t.push(l)}t.pop();const a=[];for(let n=e.length-1;n>=0;n--){const l=e[n];for(;a.length>=2;){const r=a[a.length-1],u=a[a.length-2];if((r.x-u.x)*(l.y-u.y)>=(r.y-u.y)*(l.x-u.x))a.pop();else break}a.push(l)}return a.pop(),t.length===1&&a.length===1&&t[0].x===a[0].x&&t[0].y===a[0].y?t:t.concat(a)}var Tt=Se,Ct=Pe,St=we,Pt=je,Me=Ie;const wt=Tt,G=Ct,V=St,F=o.forwardRef(({className:e,sideOffset:t=4,...a},n)=>s.jsx(Pt,{children:s.jsx(Me,{ref:n,sideOffset:t,className:ve("z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...a})}));F.displayName=Me.displayName;function z(e){return e==="plugin"?"plugins":"skills"}async function jt(e){var r,u;const t=new URLSearchParams,a=z(e.type);(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),(u=e.tag)!=null&&u.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const n=t.toString(),l=await H.get(n?`/api/marketplace/${a}/items?${n}`:`/api/marketplace/${a}/items`);if(!l.ok)throw new Error(l.error.message);return l.data}async function It(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function Nt(e){const t=z(e),a=await H.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function Et(e){const t=z(e.type),a=await H.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Mt(e){return ye({queryKey:["marketplace-items",e],queryFn:()=>jt(e),staleTime:15e3})}function Rt(e){return ye({queryKey:["marketplace-installed",e],queryFn:()=>Nt(e),staleTime:1e4})}function Dt(){const e=be();return ke({mutationFn:t=>It(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.type==="plugin"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceInstallFailed"))}})}function Lt(){const e=be();return ke({mutationFn:t=>Et(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),e.refetchQueries({queryKey:["marketplace-installed",t.type],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"});const a=t.action==="enable"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");q.success(t.message||a)},onError:t=>{q.error(t.message||c("marketplaceOperationFailed"))}})}const At=12;function W(e){return(e??"").trim().toLowerCase()}function M(e,t){const a=W(t);return a.length>0?`${e}:${a}`:""}function _t(e){const t=new Map;for(const a of e){const n=[a.install.spec,a.slug,a.id];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function Ot(e){const t=new Map;for(const a of e){const n=[a.spec,a.id,a.label];for(const l of n){const r=M(a.type,l);!r||t.has(r)||t.set(r,a)}}return t}function $t(e,t){const a=[e.install.spec,e.slug,e.id];for(const n of a){const l=M(e.type,n);if(!l)continue;const r=t.get(l);if(r)return r}}function Ft(e,t){const a=t.get(M(e.type,e.spec));if(a)return a;const n=t.get(M(e.type,e.id));return n||t.get(M(e.type,e.label))}function qt(e,t,a){const n=W(a);return n?[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,...(t==null?void 0:t.tags)??[]].map(r=>W(r)).filter(Boolean).some(r=>r.includes(n)):!0}function Ht(e){const t=["bg-amber-600","bg-orange-500","bg-yellow-600","bg-emerald-600","bg-teal-600","bg-cyan-600","bg-stone-600","bg-rose-500","bg-violet-500"];let a=0;for(let n=0;n<e.length;n++)a=e.charCodeAt(n)+((a<<5)-a);return t[Math.abs(a)%t.length]}function Kt({name:e,fallback:t}){const a=e||t,n=a.substring(0,2).toUpperCase(),l=Ht(a);return s.jsx("div",{className:ve("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",l),children:n})}function Ut(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(We,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(Ze,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(Je,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(et,{})}),s.jsxs(tt,{children:[s.jsx(ge,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(ge,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function fe(e){var P,f,v,j,S;const t=e.record,a=(t==null?void 0:t.type)==="plugin"?t:void 0,n=((P=e.item)==null?void 0:P.type)??(t==null?void 0:t.type),l=((f=e.item)==null?void 0:f.name)??(t==null?void 0:t.label)??(t==null?void 0:t.id)??(t==null?void 0:t.spec)??c("marketplaceUnknownItem"),r=((v=e.item)==null?void 0:v.summary)??(t?c("marketplaceInstalledLocalSummary"):""),u=((j=e.item)==null?void 0:j.install.spec)??(t==null?void 0:t.spec)??"",b=(t==null?void 0:t.id)||(t==null?void 0:t.spec),d=!!b&&e.manageState.isPending&&e.manageState.targetId===b,x=!!a,i=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",h=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",k=!!(i||h),m=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,T=(S=e.item)==null?void 0:S.install.spec,y=typeof T=="string"&&e.installState.installingSpecs.has(T),C=n==="plugin"?c("marketplaceTypePlugin"):n==="skill"?c("marketplaceTypeSkill"):c("marketplaceTypeExtension");return s.jsxs("article",{className:"group bg-white border border-gray-200/40 hover:border-gray-200/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-default",children:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(Kt,{name:l,fallback:u||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(wt,{delayDuration:400,children:[s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight cursor-default",children:l})}),s.jsx(F,{className:"max-w-[300px] text-xs",children:l})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:C}),u&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono cursor-default",children:u})}),s.jsx(F,{className:"max-w-[300px] text-xs font-mono break-all",children:u})]})]})]}),s.jsxs(G,{children:[s.jsx(V,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left cursor-default",children:r})}),r&&s.jsx(F,{className:"max-w-[400px] text-xs leading-relaxed",children:r})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[e.item&&!t&&s.jsx("button",{onClick:()=>e.onInstall(e.item),disabled:y,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:y?c("marketplaceInstalling"):c("marketplaceInstall")}),a&&x&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage(m?"enable":"disable",a),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:d&&e.manageState.action!=="uninstall"?e.manageState.action==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):m?c("marketplaceEnable"):c("marketplaceDisable")}),t&&k&&s.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage("uninstall",t),className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:d&&e.manageState.action==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function zt(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}function Wt(){var le,oe,ie,ce,ue,de,pe,me;const e=Ye(),t=Xe(),a=o.useMemo(()=>t.type==="plugins"||t.type==="skills"?t.type:null,[t.type]);o.useEffect(()=>{a||e("/marketplace/plugins",{replace:!0})},[a,e]);const n=a==="skills"?"skill":"plugin",r=n==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[u,b]=o.useState(""),[d,x]=o.useState(""),[i,h]=o.useState("all"),[k,m]=o.useState("relevance"),[T,y]=o.useState(1),[C,P]=o.useState(new Set);o.useEffect(()=>{const p=setTimeout(()=>{y(1),x(u.trim())},250);return()=>clearTimeout(p)},[u]),o.useEffect(()=>{y(1)},[n]);const f=Rt(n),v=Mt({q:d||void 0,type:n,sort:k,page:T,pageSize:At}),j=Dt(),S=Lt(),{confirm:_,ConfirmDialog:O}=nt(),$=o.useMemo(()=>{var p;return((p=f.data)==null?void 0:p.records)??[]},[(le=f.data)==null?void 0:le.records]),N=o.useMemo(()=>{var p;return((p=v.data)==null?void 0:p.items)??[]},[(oe=v.data)==null?void 0:oe.items]),ee=o.useMemo(()=>_t(N),[N]),Re=o.useMemo(()=>Ot($),[$]),D=o.useMemo(()=>{const p=$.filter(g=>g.type===n).map(g=>({key:`${g.type}:${g.spec}:${g.id??""}`,record:g,item:Ft(g,ee)})).filter(g=>qt(g.record,g.item,d));return p.sort((g,w)=>{const I=g.record.installedAt?Date.parse(g.record.installedAt):Number.NaN,B=w.record.installedAt?Date.parse(w.record.installedAt):Number.NaN,Ae=!Number.isNaN(I),_e=!Number.isNaN(B);return Ae&&_e&&I!==B?B-I:g.record.spec.localeCompare(w.record.spec)}),p},[$,n,ee,d]),te=i==="installed"?D.length:((ie=v.data)==null?void 0:ie.total)??0,Q=i==="installed"?1:((ce=v.data)==null?void 0:ce.totalPages)??0,De=o.useMemo(()=>i==="installed"?f.isLoading?c("loading"):`${D.length} ${c(r.installedCountSuffix)}`:v.data?`${N.length} / ${te}`:c("loading"),[i,f.isLoading,D.length,v.data,N.length,te,r.installedCountSuffix]),ae={installingSpecs:C},ne={isPending:S.isPending,targetId:((ue=S.variables)==null?void 0:ue.id)||((de=S.variables)==null?void 0:de.spec),action:(pe=S.variables)==null?void 0:pe.action},Le=[{id:"all",label:c(r.tabMarketplace)},{id:"installed",label:c(r.tabInstalled),count:((me=f.data)==null?void 0:me.total)??0}],se=async p=>{const g=p.install.spec;if(!C.has(g)){P(w=>{const I=new Set(w);return I.add(g),I});try{await j.mutateAsync({type:p.type,spec:g,kind:p.install.kind,...p.type==="skill"?{skill:p.slug,installPath:`skills/${p.slug}`}:{}})}catch{}finally{P(w=>{if(!w.has(g))return w;const I=new Set(w);return I.delete(g),I})}}},re=async(p,g)=>{if(S.isPending)return;const w=g.id||g.spec;w&&(p==="uninstall"&&!await _({title:`${c("marketplaceUninstallTitle")} ${w}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"})||S.mutate({type:g.type,action:p,id:w,spec:g.spec}))};return s.jsxs(st,{children:[s.jsx(rt,{title:c(r.pageTitle),description:c(r.pageDescription)}),s.jsx(at,{tabs:Le,activeTab:i,onChange:p=>{h(p),y(1)},className:"mb-4"}),s.jsx(Ut,{scope:i,searchText:u,searchPlaceholder:c(r.searchPlaceholder),sort:k,onSearchTextChange:b,onSortChange:p=>{y(1),m(p)}}),s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:i==="installed"?c(r.sectionInstalled):c(r.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:De})]}),i==="all"&&v.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadData),": ",v.error.message]}),i==="installed"&&f.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(r.errorLoadInstalled),": ",f.error.message]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[i==="all"&&N.map(p=>s.jsx(fe,{item:p,record:$t(p,Re),installState:ae,manageState:ne,onInstall:se,onManage:re},p.id)),i==="installed"&&D.map(p=>s.jsx(fe,{item:p.item,record:p.record,installState:ae,manageState:ne,onInstall:se,onManage:re},p.key))]}),i==="all"&&!v.isLoading&&!v.isError&&N.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyData)}),i==="installed"&&!f.isLoading&&!f.isError&&D.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(r.emptyInstalled)})]}),i==="all"&&s.jsx(zt,{page:T,totalPages:Q,busy:v.isFetching,onPrev:()=>y(p=>Math.max(1,p-1)),onNext:()=>y(p=>Q>0?Math.min(Q,p+1):p+1)}),s.jsx(O,{})]})}export{Wt as MarketplacePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as c,m as M,F as k,
|
|
1
|
+
import{j as e,r as c,m as M,F as k,J as C,K as P}from"./vendor-Dz2q6Qmc.js";import{P as S,a as F,B as L}from"./page-layout-Byyxptub.js";import{C as b}from"./card-Cj58-DCd.js";import{u as T,a as E,b as D,I as w}from"./useConfig-8lC_4LwH.js";import{L as p}from"./label-CQdP2NhF.js";import{c as I,t,f as B}from"./index-C_z1Na9N.js";import{h as u}from"./config-hints-CApS3K_7.js";function s({className:l,...i}){return e.jsx("div",{className:I("animate-pulse rounded-md bg-slate-200",l),...i})}function q(){const{data:l,isLoading:i}=T(),{data:n}=E(),o=D(),[g,j]=c.useState(""),[y,f]=c.useState(""),[m,N]=c.useState(8192),x=n==null?void 0:n.uiHints,r=u("agents.defaults.model",x),d=u("agents.defaults.workspace",x),h=u("agents.defaults.maxTokens",x);c.useEffect(()=>{var a;(a=l==null?void 0:l.agents)!=null&&a.defaults&&(j(l.agents.defaults.model||""),f(l.agents.defaults.workspace||""),N(l.agents.defaults.maxTokens||8192))},[l]);const v=a=>{a.preventDefault(),o.mutate({model:g,maxTokens:m})};return i?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{className:"h-8 w-32"}),e.jsx(s,{className:"h-4 w-48"})]}),e.jsxs(b,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(s,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{className:"h-5 w-24"}),e.jsx(s,{className:"h-3 w-32"})]})]}),e.jsx(s,{className:"h-4 w-20 mb-2"}),e.jsx(s,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(b,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(s,{className:"h-5 w-24 mb-2"}),e.jsx(s,{className:"h-3 w-40 mb-6"}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx(s,{className:"h-4 w-28 mb-3"}),e.jsx(s,{className:"h-2 w-full rounded-full"})]})})]})]}):e.jsxs(S,{children:[e.jsx(F,{title:t("modelPageTitle"),description:t("modelPageDescription")}),e.jsxs("form",{onSubmit:v,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(M,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(r==null?void 0:r.label)??"Model Name"}),e.jsx(w,{id:"model",value:g,onChange:a=>j(a.target.value),placeholder:(r==null?void 0:r.placeholder)??"minimax/MiniMax-M2.1",className:"h-12 px-4 rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-400",children:(r==null?void 0:r.help)??"Examples: minimax/MiniMax-M2.5 · minimax/MiniMax-M2.1 · openrouter/anthropic/claude-3.5-sonnet · openrouter/openai/gpt-4o-mini"})]})]}),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(k,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(d==null?void 0:d.label)??"Default Path"}),e.jsx(w,{id:"workspace",value:y,onChange:a=>f(a.target.value),placeholder:(d==null?void 0:d.placeholder)??"/path/to/workspace",className:"h-12 px-4 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(C,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t("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(p,{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(h==null?void 0:h.label)??t("maxTokens")}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:B(m)})]}),e.jsx("input",{type:"range",min:"1000",max:"32000",step:"1000",value:m,onChange:a=>N(parseInt(a.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(L,{type:"submit",disabled:o.isPending,size:"lg",children:o.isPending?e.jsx(P,{className:"h-5 w-5 animate-spin"}):t("saveChanges")})})]})]})}export{q as ModelConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as v,j as e,a1 as I,a2 as R,Y as V,U as z,a3 as k,a4 as U,a5 as B}from"./vendor-Dz2q6Qmc.js";import{I as K,u as L,g as F,a as O,h as H}from"./useConfig-8lC_4LwH.js";import{t as s,c as S,u as W,S as G,b as Y,d as _,e as q,g as J}from"./index-C_z1Na9N.js";import{D as Q,a as X,b as Z,c as ee,d as se,e as ae}from"./dialog-Ce8jNftN.js";import{B as A,P as te,a as re}from"./page-layout-Byyxptub.js";import{L as E}from"./label-CQdP2NhF.js";import{h as w}from"./config-hints-CApS3K_7.js";import{T as ie}from"./tabs-custom-DWlAbbCy.js";import{C as le,a as ne,L as oe,g as ce,S as de,b as xe,c as me,A as pe}from"./action-link-CSScZ_id.js";function he({maskedValue:l,isSet:n,className:m,...p}){const[x,g]=v.useState(!1);return e.jsxs("div",{className:"relative",children:[e.jsx(K,{type:x?"text":"password",className:S("pr-20",m),placeholder:n?`${s("apiKeySet")} (${s("unchanged")})`:"",...p}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(n||l)&&e.jsx(A,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>g(!x),children:x?e.jsx(I,{className:"h-4 w-4"}):e.jsx(R,{className:"h-4 w-4"})})})]})}function ue({value:l,onChange:n,className:m}){const p=l?Object.entries(l):[],x=(h,o,a)=>{const r=[...p];r[h]=[o,a],n(Object.fromEntries(r))},g=()=>{n({...l,"":""})},f=h=>{const o=p.filter((a,r)=>r!==h);n(Object.fromEntries(o))};return e.jsxs("div",{className:S("space-y-2",m),children:[p.map(([h,o],a)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"text",value:h,onChange:r=>x(a,r.target.value,o),placeholder:s("headerName"),className:"flex-1"}),e.jsx(K,{type:"text",value:o,onChange:r=>x(a,h,r.target.value),placeholder:s("headerValue"),className:"flex-1"}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(a),children:e.jsx(V,{className:"h-4 w-4 text-red-500"})})]},a)),e.jsxs(A,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(z,{className:"h-4 w-4 mr-2"}),s("add")]})]})}function ge(){const{providerModal:l,closeProviderModal:n}=W(),{data:m}=L(),{data:p}=F(),{data:x}=O(),g=H(),[f,h]=v.useState(""),[o,a]=v.useState(""),[r,j]=v.useState(null),[y,C]=v.useState("auto"),c=l.provider,t=p==null?void 0:p.providers.find(i=>i.name===c),d=c?m==null?void 0:m.providers[c]:null,P=x==null?void 0:x.uiHints,N=c?w(`providers.${c}.apiKey`,P):void 0,u=c?w(`providers.${c}.apiBase`,P):void 0,D=c?w(`providers.${c}.extraHeaders`,P):void 0,T=c?w(`providers.${c}.wireApi`,P):void 0;v.useEffect(()=>{if(d){a(d.apiBase||(t==null?void 0:t.defaultApiBase)||""),j(d.extraHeaders||null),h("");const i=d.wireApi||(t==null?void 0:t.defaultWireApi)||"auto";C(i)}},[d,t]);const $=i=>{i.preventDefault();const b={};if(f!==""&&(b.apiKey=f),o&&o!==(t==null?void 0:t.defaultApiBase)&&(b.apiBase=o),r&&Object.keys(r).length>0&&(b.extraHeaders=r),t!=null&&t.supportsWireApi){const M=(d==null?void 0:d.wireApi)||t.defaultWireApi||"auto";y!==M&&(b.wireApi=y)}c&&g.mutate({provider:c,data:b},{onSuccess:()=>n()})};return e.jsx(Q,{open:l.open,onOpenChange:n,children:e.jsxs(X,{className:"sm:max-w-[500px]",children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center",children:e.jsx(k,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx(ee,{children:(t==null?void 0:t.displayName)||c}),e.jsx(se,{children:s("providerFormDescription")})]})]})}),e.jsxs("form",{onSubmit:$,className:"flex flex-col pt-2",children:[e.jsxs("div",{className:"space-y-5 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(E,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(k,{className:"h-3.5 w-3.5 text-gray-500"}),(N==null?void 0:N.label)??s("apiKey")]}),e.jsx(he,{id:"apiKey",value:f,isSet:d==null?void 0:d.apiKeySet,onChange:i=>h(i.target.value),placeholder:d!=null&&d.apiKeySet?s("apiKeySet"):(N==null?void 0:N.placeholder)??s("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(E,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(U,{className:"h-3.5 w-3.5 text-gray-500"}),(u==null?void 0:u.label)??s("apiBase")]}),e.jsx(K,{id:"apiBase",type:"text",value:o,onChange:i=>a(i.target.value),placeholder:(t==null?void 0:t.defaultApiBase)||(u==null?void 0:u.placeholder)||"https://api.example.com",className:"rounded-xl"}),(u==null?void 0:u.help)&&e.jsx("p",{className:"text-xs text-gray-500",children:u.help})]}),(t==null?void 0:t.supportsWireApi)&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(E,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 text-gray-500"}),(T==null?void 0:T.label)??s("wireApi")]}),e.jsxs(G,{value:y,onValueChange:i=>C(i),children:[e.jsx(Y,{className:"rounded-xl",children:e.jsx(_,{})}),e.jsx(q,{children:(t.wireApiOptions||["auto","chat","responses"]).map(i=>e.jsx(J,{value:i,children:i==="chat"?s("wireApiChat"):i==="responses"?s("wireApiResponses"):s("wireApiAuto")},i))})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(E,{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 text-gray-500"}),(D==null?void 0:D.label)??s("extraHeaders")]}),e.jsx(ue,{value:r,onChange:j})]})]}),e.jsxs(ae,{className:"pt-4 flex-shrink-0",children:[e.jsx(A,{type:"button",variant:"outline",onClick:n,children:s("cancel")}),e.jsx(A,{type:"submit",disabled:g.isPending,children:g.isPending?s("saving"):s("save")})]})]})]})})}function Pe(){const{data:l}=L(),{data:n}=F(),{data:m}=O(),{openProviderModal:p}=W(),[x,g]=v.useState("installed"),f=m==null?void 0:m.uiHints;if(!l||!n)return e.jsx("div",{className:"p-8",children:s("providersLoading")});const h=[{id:"installed",label:s("providersTabConfigured"),count:l.providers?Object.keys(l.providers).filter(a=>l.providers[a].apiKeySet).length:0},{id:"all",label:s("providersTabAll"),count:n.providers.length}],o=x==="installed"?n.providers.filter(a=>{var r;return(r=l.providers[a.name])==null?void 0:r.apiKeySet}):n.providers;return e.jsxs(te,{children:[e.jsx(re,{title:s("providersPageTitle")}),e.jsx(ie,{tabs:h,activeTab:x,onChange:g}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:o.map(a=>{const r=l.providers[a.name],j=r==null?void 0:r.apiKeySet,y=w(`providers.${a.name}`,f),C=(y==null?void 0:y.help)||s("providersDefaultDescription");return e.jsxs(le,{onClick:()=>p(a.name),children:[e.jsxs(ne,{children:[e.jsx(oe,{name:a.name,src:ce(a.name),className:S("h-11 w-11 rounded-xl border transition-all",j?"bg-white border-primary/30":"bg-white border-gray-200/60 group-hover:border-gray-300"),imgClassName:"h-6 w-6",fallback:e.jsx("span",{className:S("text-base font-semibold uppercase",j?"text-gray-800":"text-gray-400"),children:a.name[0]})}),e.jsx(de,{status:j?"ready":"setup",label:j?s("statusReady"):s("statusSetup")})]}),e.jsx(xe,{title:a.displayName||a.name,description:C}),e.jsx(me,{children:e.jsx(pe,{label:j?s("actionConfigure"):s("actionAddProvider")})})]},a.name)})}),o.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"h-14 w-14 flex items-center justify-center rounded-xl bg-gray-100/80 mb-4",children:e.jsx(k,{className:"h-6 w-6 text-gray-300"})}),e.jsx("h3",{className:"text-[14px] font-semibold text-gray-900 mb-1.5",children:s("providersEmptyTitle")}),e.jsx("p",{className:"text-[13px] text-gray-400 max-w-sm",children:s("providersEmptyDescription")})]}),e.jsx(ge,{})]})}export{Pe as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,
|
|
1
|
+
import{r as p,j as e,Y as X,U as Z,af as le,a8 as H}from"./vendor-Dz2q6Qmc.js";import{u as oe,a as ce,k as de,I as d}from"./useConfig-8lC_4LwH.js";import{P as ie,a as me,B as N}from"./page-layout-Byyxptub.js";import{C as B,a as M,b as O,c as R,d as $}from"./card-Cj58-DCd.js";import{S as he}from"./switch-ChJzdp0x.js";import{t,S as ee,b as ae,d as se,e as te,g as P}from"./index-C_z1Na9N.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 G,J,Q,W;const l=s.agentId.trim(),c=s.match.channel.trim(),m=((G=s.match.accountId)==null?void 0:G.trim())??"",C=(J=s.match.peer)==null?void 0:J.kind,Y=((W=(Q=s.match.peer)==null?void 0:Q.id)==null?void 0:W.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(!Y)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(o)));E.match.peer={kind:C,id:Y}}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(X,{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(X,{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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as l,j as e,O as A,W,ag as K,a5 as $,aa as Y,M as U,ah as G,_ as J,a0 as X}from"./vendor-Dz2q6Qmc.js";import{u as Z}from"./useConfirmDialog-B7iWHb5k.js";import{c as ee,d as se,l as te,e as ae,I as S}from"./useConfig-8lC_4LwH.js";import{P as re,a as le,B as g}from"./page-layout-Byyxptub.js";import{t,c as i,S as ne,b as ie,d as oe,e as de,g as T,h as ce,a as xe}from"./index-C_z1Na9N.js";import"./dialog-Ce8jNftN.js";const u="__unknown_channel__";function me(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 he({session:a,channel:n,isSelected:d,onSelect:f}){const r=C(n),p=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:f,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",d?"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:i("font-semibold truncate pr-2 flex-1 text-sm",d?"text-brand-800":"text-gray-900"),children:p}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",d?"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:i("flex items-center text-xs justify-between mt-2 font-medium",d?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(G,{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 ge({message:a}){const n=a.role.toLowerCase()==="user";return e.jsx("div",{className:i("flex w-full mb-6",n?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("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(J,{className:"w-4 h-4 text-primary-100"}):e.jsx(X,{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:i("font-semibold text-xs",n?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",n?"text-primary-200":"text-gray-400"),children:me(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:a.content})]})]})})}function ve(){var z,H,E;const[a,n]=l.useState(""),[d]=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),F=l.useMemo(()=>({q:a.trim()||void 0,limit:d,activeMinutes:f}),[a,d,f]),h=ee(F),x=se(r,200),b=te(),_=ae(),{confirm:D,ConfirmDialog:O}=Z(),c=l.useMemo(()=>{var s;return((s=h.data)==null?void 0:s.sessions)??[]},[(z=h.data)==null?void 0:z.sessions]),o=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(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),k(!1)},[o]);const q=()=>{r&&(b.mutate({key:r,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),k(!1))},R=async()=>{if(!r)return;await D({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&b.mutate({key:r,data:{clearHistory:!0}})},V=async()=>{if(!r)return;await D({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.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(A,{className:i("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(T,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),Q.map(s=>e.jsx(T,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(W,{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(K,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):P.map(s=>e.jsx(he,{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||_.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&&o?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:o.label||o.key.split(":").pop()||o.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(o.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:i("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(Y,{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:q,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
|
+
[&::-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(A,{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(ge,{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(K,{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(O,{})]})}export{ve as SessionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as s,
|
|
1
|
+
import{r as d,j as s,ae as m}from"./vendor-Dz2q6Qmc.js";import{c as r}from"./index-C_z1Na9N.js";function v({name:e,src:t,className:a,imgClassName:o,fallback:i}){const[g,l]=d.useState(!1),c=!!t&&!g;return s.jsx("div",{className:r("flex items-center justify-center",a),children:c?s.jsx("img",{src:t,alt:`${e} logo`,className:r("h-6 w-6 object-contain",o),onError:()=>l(!0),draggable:!1}):i??s.jsx("span",{className:"text-lg font-bold uppercase",children:e.slice(0,1)})})}const x={openrouter:"openrouter.svg",aihubmix:"aihubmix.png",anthropic:"anthropic.svg",openai:"openai.svg",gemini:"gemini.svg",deepseek:"deepseek.png",zhipu:"zhipu.svg",dashscope:"dashscope.png",moonshot:"moonshot.png",minimax:"minimax.svg",vllm:"vllm.svg",groq:"groq.svg"},u={telegram:"telegram.svg",slack:"slack.svg",discord:"discord.svg",whatsapp:"whatsapp.svg",qq:"qq.svg",feishu:"feishu.svg",dingtalk:"dingtalk.svg",wecom:"wecom.svg",mochat:"mochat.svg",email:"email.svg"};function n(e,t){const a=t.toLowerCase(),o=e[a];return o?`/logos/${o}`:null}function b(e){return n(x,e)}function y(e){return n(u,e)}function j({children:e,onClick:t,className:a}){return s.jsx("div",{onClick:t,className:r("group relative flex flex-col p-6 rounded-2xl border border-gray-200/50 bg-white shadow-card","transition-all duration-base cursor-pointer","hover:shadow-card-hover hover:border-gray-200",a),children:e})}function w({children:e,className:t}){return s.jsx("div",{className:r("flex items-start justify-between mb-4",t),children:e})}function N({title:e,description:t,className:a}){return s.jsxs("div",{className:r("flex-1",a),children:[s.jsx("h3",{className:"text-[14px] font-bold text-gray-900 mb-0.5",children:e}),t&&s.jsx("p",{className:"text-[12px] text-gray-400 leading-relaxed line-clamp-2",children:t})]})}function C({children:e,className:t}){return s.jsx("div",{className:r("mt-4 pt-3 flex items-center justify-between",t),children:e})}const p={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function L({status:e,label:t,className:a}){const o=p[e];return s.jsxs("div",{className:r("flex items-center gap-1.5 px-2 py-0.5 rounded-full",o.bg,a),children:[s.jsx("span",{className:r("h-1.5 w-1.5 rounded-full",o.dot)}),s.jsx("span",{className:r("text-[11px] font-medium",o.text),children:t})]})}function k({label:e,className:t,onClick:a}){return s.jsxs("span",{onClick:a,className:r("inline-flex items-center gap-1 text-[13px] font-medium text-gray-600 hover:text-primary transition-colors cursor-pointer group/action",t),children:[e,s.jsx(m,{className:"h-3 w-3 transition-transform group-hover/action:translate-x-0.5"})]})}export{k as A,j as C,v as L,L as S,w as a,N as b,C as c,y as d,b as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-
|
|
1
|
+
import{r as s,j as t}from"./vendor-Dz2q6Qmc.js";import{c as d}from"./index-C_z1Na9N.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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as i,aq as C,aF as b,ao as ee,j as s,an as A,av as te,as as D,at as v,aw as ne,aG as oe,aH as ae,aI as re,aJ as se,ax as ie,aK as ce,aL as le,a6 as de}from"./vendor-Dz2q6Qmc.js";import{c as x}from"./index-C_z1Na9N.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=h(o.current);r.current=d==="mounted"?l:"none"},[d]),b(()=>{const l=o.current,g=a.current;if(g!==e){const y=r.current,p=h(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]),b(()=>{if(t){let l;const g=t.ownerDocument.defaultView??window,m=p=>{const Z=h(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&Z&&(u("ANIMATION_END"),!a.current)){const Q=t.style.animationFillMode;t.style.animationFillMode="forwards",l=g.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=Q)})}},y=p=>{p.target===t&&(r.current=h(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 h(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":I(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 R="DialogOverlay",F=i.forwardRef((e,t)=>{const n=j(R,e.__scopeDialog),{forceMount:o=n.forceMount,...a}=e,r=f(R,e.__scopeDialog);return r.modal?s.jsx(E,{present:o||r.open,children:s.jsx(ve,{...a,ref:t})}):null});F.displayName=R;var xe=ce("DialogOverlay.RemoveScroll"),ve=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(R,n);return s.jsx(ae,{as:xe,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(D.div,{"data-state":I(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":I(d.open),...c,ref:l,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(he,{titleId:d.titleId}),s.jsx(Ce,{contentRef:u,descriptionId:d.descriptionId})]})]})}),_="DialogTitle",k=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(_,n);return s.jsx(D.h2,{id:a.titleId,...o,ref:t})});k.displayName=_;var U="DialogDescription",$=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,a=f(U,n);return s.jsx(D.p,{id:a.descriptionId,...o,ref:t})});$.displayName=U;var G="DialogClose",H=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))})});H.displayName=G;function I(e){return e?"open":"closed"}var z="DialogTitleWarning",[Se,B]=le(z,{contentName:N,titleName:_,docsSlug:"dialog"}),he=({titleId:e})=>{const t=B(z),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
|
+
|
|
3
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
|
+
|
|
5
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Re="DialogDescriptionWarning",Ce=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${B(Re).contentName}}.`;return i.useEffect(()=>{var r;const a=(r=e.current)==null?void 0:r.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},Ee=M,Oe=S,V=F,q=W,K=k,J=$,Ae=H;const Fe=Ee,Pe=Oe,X=i.forwardRef(({className:e,...t},n)=>s.jsx(V,{ref:n,className:x("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));X.displayName=V.displayName;const _e=i.forwardRef(({className:e,children:t,...n},o)=>s.jsxs(Pe,{children:[s.jsx(X,{}),s.jsxs(q,{ref:o,className:x("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200/50 bg-white p-6 shadow-xl duration-base data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-2xl",e),...n,children:[t,s.jsxs(Ae,{className:"absolute right-4 top-4 rounded-lg p-1 opacity-70 ring-offset-white transition-all duration-fast hover:opacity-100 hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(de,{className:"h-4 w-4 text-gray-500"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_e.displayName=q.displayName;const Ie=({className:e,...t})=>s.jsx("div",{className:x("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ie.displayName="DialogHeader";const be=({className:e,...t})=>s.jsx("div",{className:x("flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-3",e),...t});be.displayName="DialogFooter";const we=i.forwardRef(({className:e,...t},n)=>s.jsx(K,{ref:n,className:x("text-lg font-semibold leading-tight tracking-tight text-gray-900",e),...t}));we.displayName=K.displayName;const Me=i.forwardRef(({className:e,...t},n)=>s.jsx(J,{ref:n,className:x("text-sm text-gray-500 leading-relaxed",e),...t}));Me.displayName=J.displayName;export{Fe as D,E as P,_e as a,Ie as b,we as c,Me as d,be as e};
|