UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 6.94 kB
import{c as g,j as d,b as R,r as E,bf as j,t as C,m as k,B as $}from"./index-ztdGKvBm.js";import{S as B,n as I,U as z,p as O,V as F,a as H}from"./category-tree-DGOo1BAt.js";import{u as L}from"./use-move-blocks-Bu_TrzH9.js";import{H as K}from"./hosted-reconcile-rjhKNGnc.js";import{Z as M}from"./agent-icon-BYWtutu9.js";import{s as _}from"./Plus-DWySsEmB.js";import{s as D}from"./Trash01-BxBhF2b8.js";function ee(s){const e=g.c(12),{state:n,claimPhase:t,lifecycle:a,onStart:r,connectionsHref:i}=s;switch(n.kind){case"starting":{let o;e[0]!==t||e[1]!==a?(o=I({claimPhase:t,lifecycle:a}),e[0]=t,e[1]=a,e[2]=o):o=e[2];let c;return e[3]!==t||e[4]!==o?(c=d.jsx(B,{kind:"starting",progress:o,claimPhase:t}),e[3]=t,e[4]=o,e[5]=c):c=e[5],c}case"suspended":{let o;return e[6]!==r?(o=d.jsx(B,{kind:"suspended",onResume:r}),e[6]=r,e[7]=o):o=e[7],o}case"errored":{let o;return e[8]!==i||e[9]!==r||e[10]!==n.error?(o=d.jsx(B,{kind:"errored",error:n.error,onRetry:r,connectionsHref:i}),e[8]=i,e[9]=r,e[10]=n.error,e[11]=o):o=e[11],o}}}const J=new Set(["clone-failed","install-failed","start-failed","crashed"]);function te(s){if(s.fastPreviewActive)return{kind:"ready",devServerReady:!1,sandboxWarming:!1};if(s.previewState.kind!=="iframe")return{kind:"sandbox-card",state:s.previewState};const e=s.lifecyclePhase==="running",n=!e&&!J.has(s.lifecyclePhase);return{kind:"ready",devServerReady:e,sandboxWarming:n}}const re={draft:"sandbox.postBoard.laneDraft",generating:"sandbox.postBoard.laneGenerating",awaiting_review:"sandbox.postBoard.laneAwaitingReview",scheduled:"sandbox.postBoard.laneScheduled",published:"sandbox.postBoard.lanePublished",archived:"sandbox.postBoard.laneArchived"};function se({orgSlug:s,virtualMcpId:e,branch:n,decofile:t,onMoved:a}){const r=R(),i=L({orgSlug:s,virtualMcpId:e,branch:n}),[o,c]=E.useState(new Set),p=l=>H(t[l],"posts"),f=(l,u,m=p(l))=>u==="generating"?{kind:"not-a-target"}:o.has(j(l))?{kind:"in-flight"}:z(m,u)?{kind:"incomplete"}:null,x=l=>{switch(l.kind){case"incomplete":return r("sandbox.postBoard.moveBlocked");case"in-flight":return r("sandbox.postBoard.moveInFlight");case"not-a-target":return r("sandbox.postBoard.moveNotATarget");default:return String(l)}};return{apply:async(l,u,m,y)=>{const S=m??p(l);if(O(S)===u)return null;const w=f(l,u,S);if(w)return w.kind!=="in-flight"&&C.error(x(w)),null;const N=j(l);c(h=>new Set(h).add(N));const A=F({key:l,payload:S},u,new Date),b=Object.keys(A.writes)[0]??l;b!==l&&a?.(l,b);try{return await i.move(A,{shown:y}),b}catch(h){return b!==l&&a?.(b,l),h instanceof K||C.error(h instanceof Error?h.message:r("sandbox.postBoard.moveFailed")),null}finally{c(h=>{const P=new Set(h);return P.delete(N),P})}},refuse:f,reasonText:x,isMoving:l=>o.has(j(l))}}function G(s){const e=g.c(15),{value:n,onChange:t,placeholder:a,className:r,onFocus:i,onBlur:o,onKeyDown:c,spellCheck:p,readOnly:f,inputRef:x}=s,v=p===void 0?!0:p;let l;e[0]!==t?(l=y=>t(y.target.value),e[0]=t,e[1]=l):l=e[1];let u;e[2]!==r?(u=k("w-full resize-none border-0 bg-transparent p-0 outline-none [field-sizing:content] placeholder:text-muted-foreground/50 focus:ring-0",r),e[2]=r,e[3]=u):u=e[3];let m;return e[4]!==x||e[5]!==o||e[6]!==i||e[7]!==c||e[8]!==a||e[9]!==f||e[10]!==v||e[11]!==l||e[12]!==u||e[13]!==n?(m=d.jsx("textarea",{ref:x,value:n,onChange:l,onInput:U,onFocus:i,onBlur:o,onKeyDown:c,placeholder:a,spellCheck:v,readOnly:f,rows:1,className:u}),e[4]=x,e[5]=o,e[6]=i,e[7]=c,e[8]=a,e[9]=f,e[10]=v,e[11]=l,e[12]=u,e[13]=n,e[14]=m):m=e[14],m}function U(s){const e=s.currentTarget;e.style.height="auto",e.style.height=`${e.scrollHeight}px`}function ne(s){return typeof s=="string"?s:""}function oe(s){const e=g.c(11);let n,t;e[0]!==s?({className:n,...t}=s,e[0]=s,e[1]=n,e[2]=t):(n=e[1],t=e[2]);let a;e[3]!==n?(a=k(n,"pr-9"),e[3]=n,e[4]=a):a=e[4];let r;e[5]!==t||e[6]!==a?(r=d.jsx(G,{...t,className:a}),e[5]=t,e[6]=a,e[7]=r):r=e[7];let i;e[8]===Symbol.for("react.memo_cache_sentinel")?(i=d.jsx(M,{size:18,"aria-hidden":!0,className:"pointer-events-none absolute right-2 top-3 text-muted-foreground/40 transition-opacity group-hover/editable:text-muted-foreground group-focus-within/editable:text-muted-foreground"}),e[8]=i):i=e[8];let o;return e[9]!==r?(o=d.jsxs("div",{className:"group/editable relative -mx-2 rounded-md px-2 transition-colors hover:bg-accent focus-within:bg-muted/50",children:[r,i]}),e[9]=r,e[10]=o):o=e[10],o}function ae(s){const e=g.c(5),{label:n,onClick:t,disabled:a}=s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=d.jsx(_,{size:13}),e[0]=r):r=e[0];let i;return e[1]!==a||e[2]!==n||e[3]!==t?(i=d.jsxs("button",{type:"button",onClick:t,disabled:a,className:"flex items-center gap-1.5 rounded-lg border border-dashed px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:border-foreground/30 hover:text-foreground disabled:opacity-40 disabled:hover:border-dashed disabled:hover:text-muted-foreground cursor-pointer",children:[r,n]}),e[1]=a,e[2]=n,e[3]=t,e[4]=i):i=e[4],i}function ie(s){const e=g.c(4),{label:n,onClick:t}=s;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=d.jsx(D,{className:"size-3.25"}),e[0]=a):a=e[0];let r;return e[1]!==n||e[2]!==t?(r=d.jsx($,{variant:"ghost-destructive",size:"icon-xs",type:"button","aria-label":n,onClick:t,className:"opacity-0 transition-opacity group-hover/item:opacity-100",children:a}),e[1]=n,e[2]=t,e[3]=r):r=e[3],r}function le(s){const e=g.c(2),{children:n}=s;let t;return e[0]!==n?(t=d.jsx("div",{className:"absolute -top-9 left-0 z-10 flex items-center gap-0.5 rounded-md bg-popover p-0.5 shadow-soft",children:n}),e[0]=n,e[1]=t):t=e[1],t}function ce(s){if(Array.isArray(s))return s;if(typeof s!="string"||s.trim()==="")return[];try{const e=JSON.parse(s);return Array.isArray(e)?e:[]}catch{return[]}}function de(s){const e=g.c(14),{options:n,value:t,emptyLabel:a,onChange:r}=s;let i;e[0]!==a||e[1]!==r||e[2]!==t?(i=a&&d.jsx(T,{active:!t,onClick:()=>r(""),children:a}),e[0]=a,e[1]=r,e[2]=t,e[3]=i):i=e[3];let o;if(e[4]!==r||e[5]!==n||e[6]!==t){let p;e[8]!==r||e[9]!==t?(p=f=>d.jsx(T,{active:f===t,onClick:()=>r(f),children:f},f),e[8]=r,e[9]=t,e[10]=p):p=e[10],o=n.filter(Boolean).map(p),e[4]=r,e[5]=n,e[6]=t,e[7]=o}else o=e[7];let c;return e[11]!==i||e[12]!==o?(c=d.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i,o]}),e[11]=i,e[12]=o,e[13]=c):c=e[13],c}function T(s){const e=g.c(7),{active:n,onClick:t,children:a}=s,r=n?"border-primary bg-primary text-primary-foreground":"bg-card hover:bg-accent";let i;e[0]!==r?(i=k("cursor-pointer rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",r),e[0]=r,e[1]=i):i=e[1];let o;return e[2]!==n||e[3]!==a||e[4]!==t||e[5]!==i?(o=d.jsx("button",{type:"button","aria-pressed":n,onClick:t,className:i,children:a}),e[2]=n,e[3]=a,e[4]=t,e[5]=i,e[6]=o):o=e[6],o}function ue(s,e=[]){return typeof s=="string"?s:JSON.stringify(s??e)}export{ae as A,oe as E,le as F,G as I,de as P,ie as R,ee as S,re as a,ue as j,ce as p,te as r,ne as s,se as u};