nextclaw 0.8.22 → 0.8.24
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/package.json +2 -2
- package/ui-dist/assets/{ChannelsList-Cq5-YX03.js → ChannelsList-DHBUkGsA.js} +1 -1
- package/ui-dist/assets/{CronConfig-CmAlEwgb.js → CronConfig-9YgJQTmP.js} +1 -1
- package/ui-dist/assets/{DocBrowser-BPQ0AwpS.js → DocBrowser-CBY75a92.js} +1 -1
- package/ui-dist/assets/MarketplacePage-Dw_0TLNd.js +1 -0
- package/ui-dist/assets/{ModelConfig-Ius4pGSn.js → ModelConfig-CBmc0ERp.js} +1 -1
- package/ui-dist/assets/{ProvidersList-inCyPXqz.js → ProvidersList-CZfmOr6_.js} +1 -1
- package/ui-dist/assets/{RuntimeConfig-BNMCl0Ei.js → RuntimeConfig-DX6nI_b5.js} +1 -1
- package/ui-dist/assets/{SessionsConfig-Dm2kRLTa.js → SessionsConfig-wH-647_6.js} +1 -1
- package/ui-dist/assets/{action-link-C9ahVCKx.js → action-link-DNRpMv1A.js} +1 -1
- package/ui-dist/assets/{card-C1ZzMnWw.js → card-KMt_4CgV.js} +1 -1
- package/ui-dist/assets/{dialog-Mk2G1dFX.js → dialog-CqY6jnQm.js} +2 -2
- package/ui-dist/assets/{index-tnzkPnqh.js → index-CVOQiX2_.js} +2 -2
- package/ui-dist/assets/{label-BROtAvYK.js → label-C7WCjHWk.js} +1 -1
- package/ui-dist/assets/{page-layout-DtdQjybK.js → page-layout-CMuYE4DA.js} +1 -1
- package/ui-dist/assets/{switch-CAm3AWPT.js → switch-DQmUTN4L.js} +1 -1
- package/ui-dist/assets/{tabs-custom-FChgJMG3.js → tabs-custom-C5xYS25o.js} +1 -1
- package/ui-dist/assets/{useConfig-K-hQK2hv.js → useConfig-Bv2DQ4BE.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-04G_ys9F.js → useConfirmDialog-BOcIsqiA.js} +1 -1
- package/ui-dist/assets/{vendor-CiFdXYu3.js → vendor-Dkx07DIh.js} +53 -53
- package/ui-dist/index.html +2 -2
- package/ui-dist/assets/MarketplacePage-DF0gJ8nx.js +0 -1
package/ui-dist/index.html
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>NextClaw - 系统配置</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CVOQiX2_.js"></script>
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-Dkx07DIh.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-DdpR1fdj.css">
|
|
12
12
|
</head>
|
|
13
13
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as a,ak as Me,al as Re,am as Le,an as pe,ao as De,ap as Ae,aq as E,ar as me,as as _e,at as Fe,au as Oe,av as qe,aw as $e,ax as He,ay as Ke,ah as xe,ai as ge,aj as fe,a1 as F,az as Ue}from"./vendor-CiFdXYu3.js";import{c as V,i as O,t as c,S as ze,a as Qe,b as Be,d as Ge,e as de}from"./index-tnzkPnqh.js";import{T as Ve}from"./tabs-custom-FChgJMG3.js";import{P as he}from"./dialog-Mk2G1dFX.js";import{u as Ye}from"./useConfirmDialog-04G_ys9F.js";import{P as Xe,a as We}from"./page-layout-DtdQjybK.js";var[q]=Fe("Tooltip",[me]),$=me(),ye="TooltipProvider",Ze=700,Q="tooltip.open",[Je,Y]=q(ye),be=e=>{const{__scopeTooltip:t,delayDuration:n=Ze,skipDelayDuration:s=300,disableHoverableContent:r=!1,children:o}=e,i=l.useRef(!0),h=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),a.jsx(Je,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:l.useCallback(()=>{window.clearTimeout(d.current),i.current=!1},[]),onClose:l.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,s)},[s]),isPointerInTransitRef:h,onPointerInTransitChange:l.useCallback(f=>{h.current=f},[]),disableHoverableContent:r,children:o})};be.displayName=ye;var L="Tooltip",[et,D]=q(L),ve=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:r,onOpenChange:o,disableHoverableContent:i,delayDuration:h}=e,d=Y(L,e.__scopeTooltip),f=$(t),[m,g]=l.useState(null),x=Me(),u=l.useRef(0),y=i??d.disableHoverableContent,b=h??d.delayDuration,T=l.useRef(!1),[w,k]=Re({prop:s,defaultProp:r??!1,onChange:R=>{R?(d.onOpen(),document.dispatchEvent(new CustomEvent(Q))):d.onClose(),o==null||o(R)},caller:L}),C=l.useMemo(()=>w?T.current?"delayed-open":"instant-open":"closed",[w]),j=l.useCallback(()=>{window.clearTimeout(u.current),u.current=0,T.current=!1,k(!0)},[k]),N=l.useCallback(()=>{window.clearTimeout(u.current),u.current=0,k(!1)},[k]),P=l.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>{T.current=!0,k(!0),u.current=0},b)},[b,k]);return l.useEffect(()=>()=>{u.current&&(window.clearTimeout(u.current),u.current=0)},[]),a.jsx(Le,{...f,children:a.jsx(et,{scope:t,contentId:x,open:w,stateAttribute:C,trigger:m,onTriggerChange:g,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?P():j()},[d.isOpenDelayedRef,P,j]),onTriggerLeave:l.useCallback(()=>{y?N():(window.clearTimeout(u.current),u.current=0)},[N,y]),onOpen:j,onClose:N,disableHoverableContent:y,children:n})})};ve.displayName=L;var B="TooltipTrigger",ke=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,r=D(B,n),o=Y(B,n),i=$(n),h=l.useRef(null),d=pe(t,h,r.onTriggerChange),f=l.useRef(!1),m=l.useRef(!1),g=l.useCallback(()=>f.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),a.jsx(De,{asChild:!0,...i,children:a.jsx(Ae.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...s,ref:d,onPointerMove:E(e.onPointerMove,x=>{x.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:E(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:E(e.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:E(e.onFocus,()=>{f.current||r.onOpen()}),onBlur:E(e.onBlur,r.onClose),onClick:E(e.onClick,r.onClose)})})});ke.displayName=B;var X="TooltipPortal",[tt,nt]=q(X,{forceMount:void 0}),Te=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:r}=e,o=D(X,t);return a.jsx(tt,{scope:t,forceMount:n,children:a.jsx(he,{present:n||o.open,children:a.jsx(_e,{asChild:!0,container:r,children:s})})})};Te.displayName=X;var M="TooltipContent",Ce=l.forwardRef((e,t)=>{const n=nt(M,e.__scopeTooltip),{forceMount:s=n.forceMount,side:r="top",...o}=e,i=D(M,e.__scopeTooltip);return a.jsx(he,{present:s||i.open,children:i.disableHoverableContent?a.jsx(we,{side:r,...o,ref:t}):a.jsx(at,{side:r,...o,ref:t})})}),at=l.forwardRef((e,t)=>{const n=D(M,e.__scopeTooltip),s=Y(M,e.__scopeTooltip),r=l.useRef(null),o=pe(t,r),[i,h]=l.useState(null),{trigger:d,onClose:f}=n,m=r.current,{onPointerInTransitChange:g}=s,x=l.useCallback(()=>{h(null),g(!1)},[g]),u=l.useCallback((y,b)=>{const T=y.currentTarget,w={x:y.clientX,y:y.clientY},k=it(w,T.getBoundingClientRect()),C=ct(w,k),j=dt(b.getBoundingClientRect()),N=pt([...C,...j]);h(N),g(!0)},[g]);return l.useEffect(()=>()=>x(),[x]),l.useEffect(()=>{if(d&&m){const y=T=>u(T,m),b=T=>u(T,d);return d.addEventListener("pointerleave",y),m.addEventListener("pointerleave",b),()=>{d.removeEventListener("pointerleave",y),m.removeEventListener("pointerleave",b)}}},[d,m,u,x]),l.useEffect(()=>{if(i){const y=b=>{const T=b.target,w={x:b.clientX,y:b.clientY},k=(d==null?void 0:d.contains(T))||(m==null?void 0:m.contains(T)),C=!ut(w,i);k?x():C&&(x(),f())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[d,m,i,f,x]),a.jsx(we,{...e,ref:o})}),[rt,st]=q(L,{isInside:!1}),ot=He("TooltipContent"),we=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":r,onEscapeKeyDown:o,onPointerDownOutside:i,...h}=e,d=D(M,n),f=$(n),{onClose:m}=d;return l.useEffect(()=>(document.addEventListener(Q,m),()=>document.removeEventListener(Q,m)),[m]),l.useEffect(()=>{if(d.trigger){const g=x=>{const u=x.target;u!=null&&u.contains(d.trigger)&&m()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,m]),a.jsx(Oe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:g=>g.preventDefault(),onDismiss:m,children:a.jsxs(qe,{"data-state":d.stateAttribute,...f,...h,ref:t,style:{...h.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:[a.jsx(ot,{children:s}),a.jsx(rt,{scope:n,isInside:!0,children:a.jsx($e,{id:d.contentId,role:"tooltip",children:r||s})})]})})});Ce.displayName=M;var je="TooltipArrow",lt=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,r=$(n);return st(je,n).isInside?null:a.jsx(Ke,{...r,...s,ref:t})});lt.displayName=je;function it(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,s,r,o)){case o:return"left";case r:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function ct(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function dt(e){const{top:t,right:n,bottom:s,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:s},{x:r,y:s}]}function ut(e,t){const{x:n,y:s}=e;let r=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const h=t[o],d=t[i],f=h.x,m=h.y,g=d.x,x=d.y;m>s!=x>s&&n<(g-f)*(s-m)/(x-m)+f&&(r=!r)}return r}function pt(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),mt(t)}function mt(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const r=e[s];for(;t.length>=2;){const o=t[t.length-1],i=t[t.length-2];if((o.x-i.x)*(r.y-i.y)>=(o.y-i.y)*(r.x-i.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const r=e[s];for(;n.length>=2;){const o=n[n.length-1],i=n[n.length-2];if((o.x-i.x)*(r.y-i.y)>=(o.y-i.y)*(r.x-i.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xt=be,gt=ve,ft=ke,ht=Te,Pe=Ce;const yt=xt,U=gt,z=ft,_=l.forwardRef(({className:e,sideOffset:t=4,...n},s)=>a.jsx(ht,{children:a.jsx(Pe,{ref:s,sideOffset:t,className:V("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),...n})}));_.displayName=Pe.displayName;async function bt(e={}){var r,o;const t=new URLSearchParams;(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),e.type&&t.set("type",e.type),(o=e.tag)!=null&&o.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(),s=await O.get(n?`/api/marketplace/items?${n}`:"/api/marketplace/items");if(!s.ok)throw new Error(s.error.message);return s.data}async function vt(e){const t=await O.post("/api/marketplace/install",e);if(!t.ok)throw new Error(t.error.message);return t.data}async function kt(){const e=await O.get("/api/marketplace/installed");if(!e.ok)throw new Error(e.error.message);return e.data}async function Tt(e){const t=await O.post("/api/marketplace/manage",e);if(!t.ok)throw new Error(t.error.message);return t.data}function Ct(e){return xe({queryKey:["marketplace-items",e],queryFn:()=>bt(e),staleTime:15e3})}function wt(){return xe({queryKey:["marketplace-installed"],queryFn:kt,staleTime:1e4})}function jt(){const e=ge();return fe({mutationFn:t=>vt(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed"]}),e.refetchQueries({queryKey:["marketplace-installed"],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"}),F.success(t.message||`${t.type} ${c("marketplaceInstalledCountSuffix")}`)},onError:t=>{F.error(t.message||c("marketplaceInstallFailed"))}})}function Pt(){const e=ge();return fe({mutationFn:t=>Tt(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed"]}),e.invalidateQueries({queryKey:["marketplace-items"]}),e.refetchQueries({queryKey:["marketplace-installed"],type:"active"}),e.refetchQueries({queryKey:["marketplace-items"],type:"active"}),F.success(t.message||`${t.action} success`)},onError:t=>{F.error(t.message||c("marketplaceOperationFailed"))}})}const Nt=12;function G(e){return(e??"").trim().toLowerCase()}function I(e,t){const n=G(t);return n.length>0?`${e}:${n}`:""}function St(e){const t=new Map;for(const n of e){const s=[n.install.spec,n.slug,n.id];for(const r of s){const o=I(n.type,r);!o||t.has(o)||t.set(o,n)}}return t}function Et(e){const t=new Map;for(const n of e){const s=[n.spec,n.id,n.label];for(const r of s){const o=I(n.type,r);!o||t.has(o)||t.set(o,n)}}return t}function It(e,t){const n=[e.install.spec,e.slug,e.id];for(const s of n){const r=I(e.type,s);if(!r)continue;const o=t.get(r);if(o)return o}}function Mt(e,t){const n=t.get(I(e.type,e.spec));if(n)return n;const s=t.get(I(e.type,e.id));return s||t.get(I(e.type,e.label))}function Rt(e,t,n){const s=G(n);return s?[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(o=>G(o)).filter(Boolean).some(o=>o.includes(s)):!0}function Lt(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 n=0;for(let s=0;s<e.length;s++)n=e.charCodeAt(s)+((n<<5)-n);return t[Math.abs(n)%t.length]}function Dt({name:e,fallback:t}){const n=e||t,s=n.substring(0,2).toUpperCase(),r=Lt(n);return a.jsx("div",{className:V("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:s})}function At(e){return a.jsx("div",{className:"mb-4",children:a.jsxs("div",{className:"flex gap-3 items-center",children:[a.jsxs("div",{className:"flex-1 min-w-0 relative",children:[a.jsx(Ue,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),a.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:c("marketplaceSearchPlaceholder"),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"})]}),a.jsx("div",{className:"inline-flex h-9 rounded-xl bg-gray-100/80 p-1 shrink-0",children:[{value:"all",label:c("marketplaceFilterAll")},{value:"plugin",label:c("marketplaceFilterPlugins")},{value:"skill",label:c("marketplaceFilterSkills")}].map(t=>a.jsx("button",{type:"button",onClick:()=>e.onTypeFilterChange(t.value),className:V("px-3 rounded-lg text-sm font-medium transition-all whitespace-nowrap",e.typeFilter===t.value?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-700"),children:t.label},t.value))}),e.scope==="all"&&a.jsxs(ze,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[a.jsx(Qe,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:a.jsx(Be,{})}),a.jsxs(Ge,{children:[a.jsx(de,{value:"relevance",children:c("marketplaceSortRelevance")}),a.jsx(de,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function ue(e){var T,w,k,C;const t=e.record,n=(t==null?void 0:t.type)==="plugin"?t:void 0,s=((T=e.item)==null?void 0:T.type)??(t==null?void 0:t.type),r=((w=e.item)==null?void 0:w.name)??(t==null?void 0:t.label)??(t==null?void 0:t.id)??(t==null?void 0:t.spec)??c("marketplaceUnknownItem"),o=((k=e.item)==null?void 0:k.summary)??(t?c("marketplaceInstalledLocalSummary"):""),i=((C=e.item)==null?void 0:C.install.spec)??(t==null?void 0:t.spec)??"",h=(t==null?void 0:t.id)||(t==null?void 0:t.spec),d=!!h&&e.manageState.isPending&&e.manageState.targetId===h,f=!!n,m=(t==null?void 0:t.type)==="plugin"&&t.origin!=="bundled",g=(t==null?void 0:t.type)==="skill"&&t.source==="workspace",x=!!(m||g),u=t?t.enabled===!1||t.runtimeStatus==="disabled":!1,y=e.installState.isPending&&e.item&&e.installState.installingSpec===e.item.install.spec,b=s==="plugin"?c("marketplaceTypePlugin"):s==="skill"?c("marketplaceTypeSkill"):c("marketplaceTypeExtension");return a.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:[a.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[a.jsx(Dt,{name:r,fallback:i||c("marketplaceTypeExtension")}),a.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:a.jsxs(yt,{delayDuration:400,children:[a.jsxs(U,{children:[a.jsx(z,{asChild:!0,children:a.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight cursor-default",children:r})}),a.jsx(_,{className:"max-w-[300px] text-xs",children:r})]}),a.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:[a.jsx("span",{className:"text-[11px] text-gray-500 font-medium",children:b}),i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[10px] text-gray-300",children:"•"}),a.jsxs(U,{children:[a.jsx(z,{asChild:!0,children:a.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono cursor-default",children:i})}),a.jsx(_,{className:"max-w-[300px] text-xs font-mono break-all",children:i})]})]})]}),a.jsxs(U,{children:[a.jsx(z,{asChild:!0,children:a.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left cursor-default",children:o})}),o&&a.jsx(_,{className:"max-w-[400px] text-xs leading-relaxed",children:o})]})]})})]}),a.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[e.item&&!t&&a.jsx("button",{onClick:()=>e.onInstall(e.item),disabled:e.installState.isPending,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")}),n&&f&&a.jsx("button",{disabled:e.manageState.isPending,onClick:()=>e.onManage(u?"enable":"disable",n),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"):u?c("marketplaceEnable"):c("marketplaceDisable")}),t&&x&&a.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 _t(e){return a.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[a.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")}),a.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),a.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 Ut(){var te,ne,ae,re,se,oe,le,ie,ce;const[e,t]=l.useState(""),[n,s]=l.useState(""),[r,o]=l.useState("all"),[i,h]=l.useState("all"),[d,f]=l.useState("relevance"),[m,g]=l.useState(1);l.useEffect(()=>{const p=setTimeout(()=>{g(1),s(e.trim())},250);return()=>clearTimeout(p)},[e]);const x=wt(),u=Ct({q:n||void 0,type:i==="all"?void 0:i,sort:d,page:m,pageSize:Nt}),y=jt(),b=Pt(),{confirm:T,ConfirmDialog:w}=Ye(),k=l.useMemo(()=>{var p;return((p=x.data)==null?void 0:p.records)??[]},[(te=x.data)==null?void 0:te.records]),C=l.useMemo(()=>{var p;return((p=u.data)==null?void 0:p.items)??[]},[(ne=u.data)==null?void 0:ne.items]),j=l.useMemo(()=>St(C),[C]),N=l.useMemo(()=>Et(k),[k]),P=l.useMemo(()=>{const p=k.filter(v=>i==="all"?!0:v.type===i).map(v=>({key:`${v.type}:${v.spec}:${v.id??""}`,record:v,item:Mt(v,j)})).filter(v=>Rt(v.record,v.item,n));return p.sort((v,S)=>{const A=v.record.installedAt?Date.parse(v.record.installedAt):Number.NaN,K=S.record.installedAt?Date.parse(S.record.installedAt):Number.NaN,Ee=!Number.isNaN(A),Ie=!Number.isNaN(K);return Ee&&Ie&&A!==K?K-A:v.record.spec.localeCompare(S.record.spec)}),p},[k,i,j,n]),R=r==="installed"?P.length:((ae=u.data)==null?void 0:ae.total)??0,H=r==="installed"?1:((re=u.data)==null?void 0:re.totalPages)??0,Ne=l.useMemo(()=>r==="installed"?x.isLoading?c("loading"):`${P.length} ${c("marketplaceInstalledCountSuffix")}`:u.data?`${C.length} / ${R}`:c("loading"),[r,x.isLoading,P.length,u.data,C.length,R]),W={isPending:y.isPending,installingSpec:(se=y.variables)==null?void 0:se.spec},Z={isPending:b.isPending,targetId:((oe=b.variables)==null?void 0:oe.id)||((le=b.variables)==null?void 0:le.spec),action:(ie=b.variables)==null?void 0:ie.action},Se=[{id:"all",label:c("marketplaceTabMarketplace")},{id:"installed",label:c("marketplaceTabInstalled"),count:((ce=x.data)==null?void 0:ce.total)??0}],J=p=>{y.isPending||y.mutate({type:p.type,spec:p.install.spec,kind:p.install.kind})},ee=async(p,v)=>{if(b.isPending)return;const S=v.id||v.spec;S&&(p==="uninstall"&&!await T({title:`${c("marketplaceUninstallTitle")} ${S}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"})||b.mutate({type:v.type,action:p,id:S,spec:v.spec}))};return a.jsxs(Xe,{children:[a.jsx(We,{title:c("marketplacePageTitle"),description:c("marketplacePageDescription")}),a.jsx(Ve,{tabs:Se,activeTab:r,onChange:p=>{o(p),g(1)},className:"mb-4"}),a.jsx(At,{scope:r,searchText:e,typeFilter:i,sort:d,onSearchTextChange:t,onTypeFilterChange:p=>{g(1),h(p)},onSortChange:p=>{g(1),f(p)}}),a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:r==="installed"?c("marketplaceSectionInstalled"):c("marketplaceSectionExtensions")}),a.jsx("span",{className:"text-[12px] text-gray-500",children:Ne})]}),r==="all"&&u.isError&&a.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c("marketplaceErrorLoadingData"),": ",u.error.message]}),r==="installed"&&x.isError&&a.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c("marketplaceErrorLoadingInstalled"),": ",x.error.message]}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-3",children:[r==="all"&&C.map(p=>a.jsx(ue,{item:p,record:It(p,N),installState:W,manageState:Z,onInstall:J,onManage:ee},p.id)),r==="installed"&&P.map(p=>a.jsx(ue,{item:p.item,record:p.record,installState:W,manageState:Z,onInstall:J,onManage:ee},p.key))]}),r==="all"&&!u.isLoading&&!u.isError&&C.length===0&&a.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c("marketplaceNoItems")}),r==="installed"&&!x.isLoading&&!x.isError&&P.length===0&&a.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c("marketplaceNoInstalledItems")})]}),r==="all"&&a.jsx(_t,{page:m,totalPages:H,busy:u.isFetching,onPrev:()=>g(p=>Math.max(1,p-1)),onNext:()=>g(p=>H>0?Math.min(H,p+1):p+1)}),a.jsx(w,{})]})}export{Ut as MarketplacePage};
|