decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 15.3 kB
JavaScript
import{c as jt,j as t,b as St,r as k,B as et,a9 as Et,I as ot,aR as vt,aQ as Nt,aN as Ct,aL as wt,aM as Pt,aP as kt,aO as Bt,bc as Dt,h as Tt,t as B}from"./index-DoEtSiIe.js";import{u as Ft}from"./chat-context-vJ6R-Clt.js";import{i as L}from"./AlertCircle-GoAGGV0G.js";import{i as At}from"./ArrowRight-CMJyKdyB.js";import{i as st}from"./File02-Y4Nh84qP.js";import{e as Rt}from"./UserSquare-dgrNjiXb.js";import{L as O}from"./label-G4Rj_cXa.js";import{S as _t,b as Lt,a as Ot,d as zt,c as z}from"./select-OlcoUSVg.js";import{b as It,C as Ht,a as Mt,c as $t}from"./blog-schema-CGys1Vfw.js";import{H as Wt,u as Vt}from"./held-block-view-CRIGJWyy.js";import{a as Gt,b as I,R as Qt,s as Yt,aM as qt,o as Ut,aN as Xt,a7 as Jt,aO as Zt,m as rt,ab as Kt,a3 as te,u as ee,l as oe,aP as se,d as re,f as ie,I as ae,aQ as ne}from"./category-tree-CW0acTf_.js";import{e as le}from"./blog-preview-url-BGp0zYxW.js";import{u as me}from"./use-never-published-C4cAqdmZ.js";import{u as ce}from"./use-move-blocks-CCDsEu9Z.js";import{H as it}from"./hosted-reconcile-CTronLZo.js";import{u as de}from"./use-fast-preview-draft-url-DQSkfUDT.js";import{u as pe}from"./use-autosave-CwP_nadT.js";import{S as ue}from"./save-status-CQe-z40L.js";import{B as ge,a as xe}from"./block-document-Dlll0MPP.js";import{s as p,E as he}from"./primitives-DCeh9ZFM.js";import{c as fe,T as ye,a as be}from"./tooltip-DhlWzeQv.js";import"./use-panel-navigate-DHff9CS9.js";import"./thread-route-D-UE3Db_.js";import"./use-project-scope-AMUoXt2c.js";import"./repository-binding-BAQCDq-W.js";import"./use-mcp-client-86j-Nolb.js";import"./auth-IBAsOARn.js";import"./use-view-draft-kind-hbAZo1QG.js";import"./use-blog-view-DJnS2ipo.js";import"./use-organization-settings-CgKOO7Ms.js";import"./schema-CG6ylG0z.js";import"./task-board-BRF3ZwKz.js";import"./thread-intent-R2KI8ie_.js";import"./delay-CnY5UFtP.js";import"./backoff-CrEUbyZT.js";import"./watch-sse-pool-C0me6Edt.js";import"./session-runtime-CZKHty5X.js";import"./use-entitlements-4v7LU4jM.js";import"./use-ai-providers-BwkzkRi2.js";import"./use-current-view-C2fbVQ-O.js";import"./use-in-settings-LMUeu63D.js";import"./use-decopilot-events-DwNDOIa1.js";import"./use-org-fs-C62_MbqW.js";import"./useInfiniteQuery-9vIAXgqG.js";import"./infiniteQueryObserver-BRGiYBJv.js";import"./index-BdQq_4o_.js";import"./index-BFFHlwFA.js";import"./ChevronDown-Dm2xO7jf.js";import"./ChevronUp-BKdcyIOm.js";import"./UserCheck01-CA8kXGn8.js";import"./collapsible-BdVp5Lcb.js";import"./utils-CzRFs-0R.js";import"./agent-icon-DoabtHNW.js";import"./Tool01-D90Wr5xR.js";import"./ArrowUp-s5a8DQxj.js";import"./ArrowLeft-DuGHc_Gh.js";import"./BookOpen01-DZs1-yi9.js";import"./Globe04-5yHQa01g.js";import"./CheckCircle-vIQcB0iT.js";import"./ChevronSelectorVertical-Cvgyclsz.js";import"./LinkBroken01-CyjdgWmP.js";import"./CreditCard01-BUXydXso.js";import"./MessageCircle01-zc37Krdu.js";import"./SwitchHorizontal01-CHtrDs50.js";import"./Eye-DwRCQHLk.js";import"./Fingerprint04-DlIWxzRc.js";import"./Image01-BRABRo3v.js";import"./Key01-DfLmV_su.js";import"./LayoutLeft-owMYqid0.js";import"./Minus-CFYZtYi9.js";import"./Monitor01-DUhT2Mcw.js";import"./Sun-uwKn4QPm.js";import"./Play-C_9Fb_Ik.js";import"./Plus-BoPsX_T8.js";import"./SearchMd-BGRe_18c.js";import"./ShoppingBag01-CoN4FBW5.js";import"./Trash01-Ctp9Olbr.js";import"./Upload01-DgxprpI7.js";import"./Users01-BasqfwpC.js";import"./XClose-BUxhnZ3x.js";import"./Zap-CxPsn4FS.js";import"./blocks-tab-states-CTy1iAF5.js";import"./site-editor-toast-B-FDGvtN.js";import"./content-changes-DXqxs3Wb.js";import"./sandbox-url-D3mC8qhT.js";import"./use-sandbox-events-A8aB0HnP.js";import"./use-blocks-v8-project-BLAijVCk.js";import"./use-voice-input-DJjQBO4e.js";import"./popover-mrQ4T9ru.js";import"./drawer-DO0sMAej.js";import"./use-mobile-BjsAkqwr.js";import"./index-BVDmO57n.js";import"./checkbox-CkODjqKt.js";import"./ai-providers-logos-DD3qZ33J.js";import"./openai-compatible-presets-BKGfVqEx.js";import"./sandbox-git-api-DiUyKbJU.js";import"./empty-state-C4MgLcBg.js";import"./calendar-BRx4DiEx.js";import"./textarea-CP9TQ5HN.js";import"./usage-stats-CLeyhHyT.js";import"./utils-CVEq3hMx.js";import"./markdown-DeZATUv_.js";import"./use-copy-CjEnyhFT.js";import"./gateway-client-C5MrdR_p.js";import"./form-DwGozYbG.js";import"./editor-classes-DMpdrv32.js";import"./switch-C5tCt-1T.js";import"./task-key-CajjdR3t.js";import"./sortable.esm-B0hCRAsX.js";import"./toggle-group-CtXgLS7e.js";import"./active-indicator-CCMhAsc_.js";import"./section-array-field-yz7QHNSD.js";import"./command-D5O7M-Cf.js";import"./index-DRuy-mDa.js";import"./named-rule-step-BAentWbs.js";import"./slider-c-3WdQpH.js";import"./index-D4CqkEu4.js";import"./tooltipContext-BkLzQGib.js";import"./CategoricalChart-iNQ2kTf5.js";import"./index-C_NkXLoh.js";import"./combobox-B9eEiOM0.js";import"./scroll-area-KLotig-P.js";import"./match-site-slug-config-B47_xZCi.js";import"./use-file-configs-J6lDtEfO.js";import"./asset-utils-D7ZsoUjl.js";import"./sandbox-start-errors-BK_aDCyt.js";import"./pair-C9Fumckp.js";import"./use-task-board-items-BVQx7Wft.js";import"./config-BOn4tvAD.js";import"./task-route-DltlnXMA.js";import"./project-index-BcbyhrUz.js";import"./shell-layout-596_q4a1.js";import"./use-deployment-admin-Bh76rlF7.js";import"./admin-fetch-BhTJlAsX.js";import"./use-org-notice-BzvGZbQ2.js";import"./integration-icon-DvT6X8cI.js";import"./project-icon-BxqBM24K.js";import"./use-navigate-to-agent-C-BC28kE.js";import"./use-debounced-value-DqHSmPMR.js";import"./new-project-dialog-CT39WKMt.js";import"./repository-picker-BBkgoOlP.js";import"./github-icon-YYYF_UPl.js";import"./collection-search-DL8nJQx4.js";import"./new-project-store-DYc4RZIM.js";import"./legacy-admin-welcome-dialog-BYL3pyxT.js";import"./required-auth-layout-DPL2sBE1.js";import"./use-org-sso-CypQjzG8.js";import"./content-blocks-o63cs2vh.js";import"./mcp-app-renderer-pvE5c1WF.js";import"./types-rurFGFZy.js";import"./omit-server-managed-metadata-L5IhjRZB.js";import"./sheet-De8qzGNI.js";import"./use-connection-BO-ZUzee.js";import"./use-mcp-prompts-CPXLXWTp.js";import"./use-thread-outputs-BnMyEJ2l.js";import"./file-type-icon-R4tsODq6.js";import"./search-input-wk0beNbE.js";import"./tabs-Bh3jtZIY.js";import"./delete-copy-rajlpHzK.js";import"./index-DJ-fS83G.js";import"./suggestion-CIik1sqO.js";import"./product-picker-dialog-BuD1Uiqo.js";import"./index-B9Qs-0Gp.js";const H="__none__";function je({orgSlug:r,virtualMcpId:s,branch:u,blockKey:n,block:y,decofile:x,meta:D,onManagePosts:at,onOpenPost:nt,previewBaseUrl:M,fastPreviewActive:lt=!0}){const o=St(),$=Ft()?.taskId??null,b=me({orgSlug:r,virtualMcpId:s,branch:u},{holdsCopy:!0}),v=ce({orgSlug:r,virtualMcpId:s,branch:u}),mt=de({orgSlug:r,virtualMcpId:s,branch:u}),W=Gt(y,"categories"),V=e=>{const a=b.shown(e);return a?{[e]:a}:{}},[m,G,Q]=pe(W,e=>{b.mutate({blockKey:n,data:I(n,"categories",e)})},{isSaving:b.isPending||v.isPending,onSeed:()=>b.hold(n)}),N=(e,a)=>G({...m,[e]:a}),ct=It("categories",D,$t),_=Vt({orgSlug:r,virtualMcpId:s,branch:u},x),Y=_.save,q=le({decofile:x,category:m,previewBaseUrl:M,draftPointer:lt?mt:null,meta:D}),i=p(m.slug),[U,f]=k.useState(i),[X,j]=k.useState(null),[dt,pt]=k.useState(i);dt!==i&&(pt(i),f(i));const[d,T]=k.useState(null),[S,F]=k.useState(!1),J=i?Qt(x).filter(e=>e.categorySlugs.includes(i)):[],A=J.length,R=Yt(x).categories,Z=(i?R.filter(e=>e.parentSlug===i):[]).length,ut=i?qt(i,R).add(i):new Set,K=Ut(R).filter(({entry:e,depth:a})=>e.slug&&!ut.has(e.slug)&&a+1<Xt).map(({entry:e,depth:a})=>({slug:e.slug,label:e.label,depth:a})),C=p(m.parentSlug),gt=Jt(x,"categories",n,p(m.name)),E=Zt(m),xt=E.length===1?o("sandbox.postEditor.missingFieldSingular",{fields:rt(E,o)}):o("sandbox.postEditor.missingFieldPlural",{fields:rt(E,o)}),ht=e=>N("slug",e),tt=(e,a)=>{const c={name:p(a.name),slug:p(a.slug)},l={[n]:I(n,"categories",a)};let h=0;for(const{key:g,payload:w}of oe(x)){const P=se(w,e,c);P!==w&&(l[g]=re(g,ie(P)),h+=1)}if(e!==c.slug)for(const{key:g,payload:w}of ae(x,"categories")){if(g===n)continue;const P=ne(w,e,c.slug);P!==w&&(l[g]=I(g,"categories",P))}return{writes:l,posts:h}},ft=async()=>{if(!i||S)return;const e=p(m.name),a={...m,name:e},{writes:c,posts:l}=tt(i,a);if(!(l===0&&e===p(W.name))){F(!0);try{Q(a),await v.move({writes:c,deletes:[]},{shown:()=>V(n)}),l>0&&B.success(o("sandbox.categoryEditor.renameNameSuccess",{count:String(l)}))}catch(h){if(h instanceof it)return;B.error(h instanceof Error?h.message:o("sandbox.categoryEditor.renameFailed"))}finally{F(!1)}}},yt=async(e,a)=>{const c={...m,slug:a},{writes:l,posts:h}=tt(e,c);F(!0);try{Q(c),await v.move({writes:l,deletes:[]},{shown:()=>V(n)}),B.success(h>0?o("sandbox.categoryEditor.renameSuccessWithPosts",{count:String(h)}):o("sandbox.categoryEditor.renameSuccessNoPosts")),T(null)}catch(g){if(f(e),j(null),T(null),g instanceof it)return;B.error(g instanceof Error?g.message:o("sandbox.categoryEditor.renameFailed"))}finally{F(!1)}},bt=()=>{const e=te(U);if(f(e),e===i)return;if(!e){f(i),j(null);return}const a=R.filter(l=>l.key!==n).map(l=>p(l.slug)).filter(Boolean);let c=e;if(a.includes(e)){c=ee(e,a);const l=o("sandbox.categoryEditor.slugDeduped",{slug:c});f(c),j(l),B.info(l)}else j(null);if(A===0&&Z===0){ht(c);return}T({oldSlug:i,newSlug:c,count:A,children:Z})};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between border-b px-6",children:[t.jsx("span",{className:"truncate text-sm font-medium",children:p(m.name)||o("sandbox.categoryEditor.untitledCategory")}),t.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[t.jsx(ue,{isPending:b.isPending||_.isPending||v.isPending,isError:b.isError||_.isError||v.isError}),E.length>0&&t.jsxs(fe,{children:[t.jsx(ye,{asChild:!0,children:t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[t.jsx(L,{size:14}),E.length," ",E.length===1?o("sandbox.postEditor.issueSingular"):o("sandbox.postEditor.issuePlural")]})}),t.jsx(be,{side:"bottom",children:xt})]}),q&&t.jsxs(et,{type:"button",variant:"outline",size:"sm",title:o("sandbox.categoryEditor.previewTooltip"),onClick:()=>window.open(q,"_blank","noopener,noreferrer"),children:[t.jsx(Et,{size:14}),o("sandbox.categoryEditor.seeCategoryPreview")]})]})]}),t.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:t.jsxs("div",{className:"mx-auto max-w-4xl px-8 py-8",children:[t.jsx(he,{value:p(m.name),onChange:e=>N("name",e),readOnly:S,onBlur:()=>{ft()},placeholder:o("sandbox.categoryEditor.categoryNamePlaceholder"),className:"py-1 text-3xl font-bold text-foreground"}),gt&&t.jsxs("p",{className:"mt-2 flex items-start gap-1.5 text-xs text-warning",children:[t.jsx(L,{size:14,className:"mt-px shrink-0"}),o("sandbox.categoryEditor.duplicateNameWarning")]}),t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsx(O,{htmlFor:"category-slug",children:o("sandbox.categoryEditor.slugLabel")}),t.jsx(ot,{id:"category-slug",value:U,onChange:e=>{j(null),f(Kt(e.target.value))},onBlur:bt,placeholder:o("sandbox.categoryEditor.slugPlaceholder"),maxLength:80,className:"h-10"}),X&&t.jsxs("p",{className:"flex items-start gap-1.5 text-xs text-warning",children:[t.jsx(L,{size:14,className:"mt-px shrink-0"}),X]})]}),t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsx(O,{htmlFor:"category-parent",children:o("sandbox.categoryEditor.parentLabel")}),t.jsxs(_t,{value:C||H,onValueChange:e=>N("parentSlug",e===H?void 0:e),children:[t.jsx(Lt,{id:"category-parent",className:"h-10 w-full",children:t.jsx(Ot,{})}),t.jsxs(zt,{children:[t.jsx(z,{value:H,children:o("sandbox.categoryEditor.parentNone")}),C&&!K.some(e=>e.slug===C)&&t.jsx(z,{value:C,children:C}),K.map(e=>t.jsx(z,{value:e.slug,children:t.jsx("span",{style:{paddingLeft:e.depth*12},children:e.label})},e.slug))]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("sandbox.categoryEditor.parentDescription")})]}),t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsx(O,{htmlFor:"category-description",children:o("sandbox.categoryEditor.descriptionLabel")}),t.jsx(ot,{id:"category-description",value:p(m.description),onChange:e=>N("description",e.target.value),placeholder:o("sandbox.categoryEditor.descriptionPlaceholder"),className:"h-10"})]}),t.jsx(Ht,{schema:ct,value:m,onChange:G,basePath:"category",meta:D,decofile:x,sandbox:{orgSlug:r,virtualMcpId:s,branch:u,threadId:$},onSaveReferencedBlock:Y}),t.jsx(Mt,{icon:Rt,title:o("sandbox.categoryEditor.contentTitle"),defaultOpen:!0,children:t.jsx(ge,{value:xe(m.sections),onChange:e=>N("sections",e),meta:D,decofile:x,sandboxRef:{orgSlug:r,virtualMcpId:s,branch:u,threadId:$},previewBaseUrl:M,onSaveReferencedBlock:Y,emptyMessage:o("sandbox.categoryEditor.noContentEmpty")})}),t.jsxs("div",{className:"mt-6 overflow-hidden rounded-lg border bg-muted/30",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(st,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"text-sm",children:o("sandbox.categoryEditor.postsInCategory",{count:String(A)})})]}),t.jsxs(et,{type:"button",variant:"outline",size:"sm",disabled:!i,title:o(i?"sandbox.categoryEditor.pickPostsTooltip":"sandbox.categoryEditor.setSlugTooltip"),onClick:()=>at(i),children:[o("sandbox.categoryEditor.addPostsButton"),t.jsx(At,{size:14})]})]}),A>0&&t.jsx("ul",{className:"divide-y border-t bg-background",children:J.map(e=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>nt(e.key),className:"flex w-full items-center gap-2.5 px-4 py-2.5 text-left transition-colors hover:bg-accent cursor-pointer",children:[t.jsx(st,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm",children:e.title||o("sandbox.categoryEditor.untitledPost")}),e.slug&&t.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:e.slug})]})]})},e.key))})]})]})})]}),t.jsx(vt,{open:!!d,onOpenChange:e=>{e||S||(f(i),j(null),T(null))},children:t.jsxs(Nt,{children:[t.jsxs(Ct,{children:[t.jsx(wt,{children:o("sandbox.categoryEditor.renameDialogTitle")}),t.jsxs(Pt,{children:[d?o("sandbox.categoryEditor.renameDialogDescription",{oldSlug:d.oldSlug,newSlug:d.newSlug,count:String(d.count)}):null,d&&d.children>0?` ${o("sandbox.categoryEditor.renameDialogChildren",{count:String(d.children)})}`:null]})]}),t.jsxs(kt,{children:[t.jsx(Bt,{disabled:S,children:o("sandbox.categoryEditor.cancelButton")}),t.jsx(Dt,{onClick:e=>{e.preventDefault(),d&&yt(d.oldSlug,d.newSlug)},disabled:S,children:S?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{className:"size-3.5"}),o("sandbox.categoryEditor.renamingLabel")]}):o("sandbox.categoryEditor.renameActionButton")})]})]})})]})}function Nr(r){const s=jt.c(10),u=r.block!==void 0;let n;s[0]!==r?(n=t.jsx(je,{...r}),s[0]=r,s[1]=n):n=s[1];let y;return s[2]!==r.blockKey||s[3]!==r.branch||s[4]!==r.decofile||s[5]!==r.orgSlug||s[6]!==r.virtualMcpId||s[7]!==u||s[8]!==n?(y=t.jsx(Wt,{listing:r.decofile,orgSlug:r.orgSlug,virtualMcpId:r.virtualMcpId,branch:r.branch,blockKey:r.blockKey,present:u,children:n}),s[2]=r.blockKey,s[3]=r.branch,s[4]=r.decofile,s[5]=r.orgSlug,s[6]=r.virtualMcpId,s[7]=u,s[8]=n,s[9]=y):y=s[9],y}export{Nr as CategoryEditor};