decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 36.7 kB
JavaScript
import{bu as z,c as ae,q as xt,K as rt,i as Lt,fJ as Ct,fe as Mt,fr as Xe,fu as It,bB as ne,bC as it,fK as xe,bq as Ut,br as ot,fm as Dt,ff as Nt,bD as st,bE as Kt,fL as Vt,ef as Ft,b as ye,a6 as qt,j as L,B as Le,L as Wt,h as Yt,a9 as zt}from"./index-ztdGKvBm.js";import{c as Qt,x as Gt,u as Ht,v as Xt,ac as Zt,ai as Jt,aj as en,ak as tn,al as nn,C as rn,y as on}from"./site-editor-toast-Dq7SmLyr.js";import{b as sn}from"./sandbox-url-D3mC8qhT.js";import{u as cn}from"./use-voice-input-BMrsODyI.js";import{i as an}from"./AlertCircle-BlMH0XE7.js";import{ar as ct}from"./agent-icon-BYWtutu9.js";import{E as Ce}from"./empty-state-I_cTbW85.js";const K={experiments:{kind:"experiments",blockKey:"experiments",resolveType:"split-traffic",matcher:"experiment",field:"name"},campaigns:{kind:"campaigns",blockKey:"campaigns",resolveType:"calendar",matcher:"campaign",field:"name"}},de=["experiments","campaigns"];function mr(e){return K[e]}const gr=de.map(e=>K[e].blockKey);function fn(e){for(const t of de)if(K[t].matcher===e)return t;return null}function hr(e){for(const t of de)if(K[t].resolveType===e)return t;return null}function _r(e){for(const t of de)if(K[t].blockKey===e)return t;return null}const ln="deco";function vr(e,t){if(!z(e))return"missing";const n=K[t],r=Ze(e,n.resolveType),i=Ze(e,n.matcher);if(!r||!i)return"missing";const o=c=>c.namespace===void 0||c.namespace===ln;return o(r)&&o(i)?"available":"replaced"}function Ze(e,t){const n=e?.manifest?.blocks??{};for(const r of Object.values(n))if(r&&Object.hasOwn(r,t))return r[t]??{};return null}function Je(e,t){const n=K[t],r=Object.hasOwn(e,n.blockKey)?e[n.blockKey]:void 0;if(r==null)return{kind:"absent",block:{__resolveType:n.resolveType},values:Object.create(null),invalid:[]};const i=me(r)?r.__resolveType:void 0;if(i!==n.resolveType)return{kind:"conflict",resolveType:typeof i=="string"?i:""};const o=r,c=Object.create(null),f=[];for(const[l,A]of Object.entries(o)){if(l==="__resolveType")continue;const R=t==="experiments"?un(A):pn(A);R===null?f.push(l):c[l]=R}return{kind:"saved",block:o,values:c,invalid:f}}function br(e,t){return e.kind!=="conflict"&&Object.hasOwn(e.values,t)}function Tr(e){const t=Je(e,"experiments"),n=Je(e,"campaigns");return{experiments:t.kind==="conflict"?{}:t.values,campaigns:n.kind==="conflict"?{}:n.values}}function un(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=100?e:null}function pn(e){if(!me(e))return null;const t={};for(const n of["start","end"]){const r=e[n];if(!(r==null||r==="")){if(typeof r!="string")return null;t[n]=r}}return t}function Ar(e){return e<=0?"off":e>=100?"everyone":"running"}function Sr(e){if(!me(e))return null;const t=fn(e.__resolveType);if(!t)return null;const n=e[K[t].field];return typeof n=="string"?{kind:t,name:n}:null}function Rr(e,t){const n=K[e];return{__resolveType:n.matcher,[n.field]:t}}const yn="date";function Or(e){return me(e)&&e.__resolveType===yn&&(Object.hasOwn(e,"start")||Object.hasOwn(e,"end"))}function Er(e,t,n,r){return{...e,__resolveType:K[t].resolveType,[n]:r}}function kr(e,t){if(t==="__resolveType")return e;const{[t]:n,...r}=e;return r}function me(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function dn(e){const t=[];return e.fastPreviewActive?t.push({kind:"committed"}):(e.fetchEnabled&&e.previewUrl&&t.push({kind:"live",baseUrl:e.previewUrl}),t.push({kind:"committed"})),e.productionUrl&&t.push({kind:"production",baseUrl:e.productionUrl}),t}const mn=5e3;function gn(e,t){return e.kind==="live"?new URL("/live/_meta",e.baseUrl).href:sn(t,"site-meta")}const hn=new Map;async function _n(e,t,n=hn){const r=n.get(e),i=r==="refused"?void 0:t?.etag,o=await fetch(e,{cache:"no-store",headers:i?{"If-None-Match":i}:{}}).catch(()=>null),c=!o&&!!i&&r===void 0,f=c?await fetch(e,{cache:"no-store",headers:{}}).catch(()=>null):o;if(i&&(c&&f?n.set(e,"refused"):o&&n.set(e,"ok")),t&&(!f||f.status===304))return t;if(!f?.ok)return null;try{return await f.json()}catch{return null}}function vn(e){return rt.liveMeta(e.orgSlug,e.virtualMcpId,e.branch,e.previewUrl??"",e.productionUrl??"")}function Pr(e,t){const n=ae.c(30),{url:r}=Qt(e?.virtualMcpId),i=!!r,o=i||(t?.fetchEnabled??!0),c=r??e?.previewUrl,f=Gt(e?.virtualMcpId),{previewServerUrl:l,runtime:A}=cn(e?.virtualMcpId),R=!i&&A==="cms",O=Ht(e?.virtualMcpId,e?.branch),P=O.kind==="protocol"?O:null,Q=xt(),V=Xt(e??null);let q;n[0]!==e||n[1]!==c||n[2]!==l||n[3]!==P?(q=e?P?Zt(e,P):vn({...e,previewUrl:c,productionUrl:l}):rt.liveMeta(""),n[0]=e,n[1]=c,n[2]=l,n[3]=P,n[4]=q):q=n[4];const j=q;let I;n[5]!==O.kind||n[6]!==V||n[7]!==R||n[8]!==o||n[9]!==i||n[10]!==f||n[11]!==e||n[12]!==c||n[13]!==l||n[14]!==P||n[15]!==Q||n[16]!==j?(I=async()=>{if(P){const{meta:d}=await Jt(Q,P,e,V);if(d instanceof Error)throw d;return d}if(O.kind==="unavailable")throw en("live meta");const G=()=>R?nn(e):rn(e,on(f,".deco/meta.gen.json")),s=i&&c?[{kind:"live",baseUrl:c}]:dn({fetchEnabled:o,previewUrl:c,productionUrl:l,fastPreviewActive:R});for(const d of s){if(d.kind==="committed"){const E=await G();if(E.kind==="data")return E.data;continue}const a=Q.getQueryData(j),B=await _n(gn(d,e),i||a?.etag?a:void 0);if(B)return B}const y=new Error("live meta unavailable (dev server down, no committed snapshot, no production fallback)");throw y.status=502,y},n[5]=O.kind,n[6]=V,n[7]=R,n[8]=o,n[9]=i,n[10]=f,n[11]=e,n[12]=c,n[13]=l,n[14]=P,n[15]=Q,n[16]=j,n[17]=I):I=n[17];const W=!!e&&O.kind!=="pending",$=P?!1:i?mn:t?.refetchInterval,ee=P?!1:void 0,ie=P?P.describe.pollIntervalMs:3e5;let F;n[18]!==R||n[19]!==i||n[20]!==P?(F=(G,s)=>(P||R||i||s.status!==502)&&G<3,n[18]=R,n[19]=i,n[20]=P,n[21]=F):F=n[21];let Y;return n[22]!==j||n[23]!==I||n[24]!==W||n[25]!==$||n[26]!==ee||n[27]!==ie||n[28]!==F?(Y={queryKey:j,queryFn:I,enabled:W,refetchInterval:$,refetchIntervalInBackground:!1,refetchOnWindowFocus:ee,staleTime:ie,retry:F,retryDelay:tn},n[22]=j,n[23]=I,n[24]=W,n[25]=$,n[26]=ee,n[27]=ie,n[28]=F,n[29]=Y):Y=n[29],Lt(Y)}const bn=new Set(["split-traffic","calendar"]);function Tn(e){const n=e.properties?.__resolveType?.enum;return Array.isArray(n)&&typeof n[0]=="string"?n[0]:""}const An=12,Sn=8,ke=32,Rn=40,et="__SECTION_REF__";function se(e){const t=e.type;return t==="array"||Array.isArray(t)&&t.includes("array")}function tt(e,t){let n=e.items;if(!n)return!1;if(typeof n.$ref=="string"&&(n=t(n.$ref)),Array.isArray(n.anyOf)||Array.isArray(n.oneOf))return!0;const i=n.properties?.__resolveType?.enum;return Array.isArray(i)&&typeof i[0]=="string"}const On="VideoWidget";function J(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function at(e){return typeof btoa=="function"?btoa(e):Buffer.from(e).toString("base64")}function Me(e){const t=e.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return t?{vendor:t[1],app:t[2]}:null}function Ie(e){const t=e.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return t?{vendor:t[1],app:t[2]}:null}function ft(e,t){return[`site/apps/${e}/${t}.ts`,`site/apps/${e}/${t}.tsx`,`${e}/apps/${t}.ts`,`${e}/apps/${t}.tsx`]}function ge(e,t){const n=t.manifest?.blocks??{};for(const f of Object.values(n))if(f[e])return f[e];const r=Me(e)??Ie(e);if(r){for(const f of ft(r.vendor,r.app))for(const l of Object.values(n))if(l[f])return l[f]}const i=at(e);for(const f of Object.values(n))if(f[i])return f[i];const o=t.schema??{};return(o.$defs??o.definitions??{})[i]?{$ref:`#/definitions/${i}`}:{}}function jr(e,t){return Object.keys(ge(e,t)).length>0}function lt(e,t){if(Ct(e,t))return!0;const n=Me(t)??Ie(t);if(!n)return!1;const r=e.manifest?.blocks?.apps??{};if(ft(n.vendor,n.app).some(c=>c in r))return!0;const i=at(t),o=e.schema?.$defs??e.schema?.definitions??{};return i in o}function En(e){return e==="site/apps/site.ts"?!1:Me(e)!==null||Ie(e)!==null}function kn(e,t){return ut(t,{resolveType:e})}function wr(e,t){return ut(t,{ref:e})}function ut(e,t){const n=e.schema??{},r="resolveType"in t?ge(t.resolveType,e):{},i=n.$defs??n.definitions??{},o=n.root??{},c=s=>{if(s.startsWith("#/root/")){const a=s.slice(7);return o[a]??{}}const y=s.split("/").pop()??"",d=i[y];return d||(y===et?o.sections??{}:{})};let f;typeof r.$ref=="string"?f=c(r.$ref):Object.keys(r).length>0?f=r:f=n;const l=s=>typeof s.$ref=="string"?c(s.$ref):s,A=s=>{const d=l(s).properties?.type;if(d){if(typeof d.const=="string")return d.const;if(typeof d.default=="string")return d.default;if(Array.isArray(d.enum)&&typeof d.enum[0]=="string")return d.enum[0]}},R=(s,y)=>{const d=l(s);return typeof d.title=="string"&&!d.title.startsWith("#")?d.title:y},O=(s,y=new Set)=>{if(typeof s.$ref!="string"||s.properties||s.anyOf||s.allOf||s.oneOf||s.type)return s;const d=s.$ref.split("/").pop()??"";return!d||y.has(d)?s:O(c(s.$ref),new Set([...y,d]))},P=(s,y=new Set)=>{if(typeof s.$ref!="string")return!1;const d=s.$ref.split("/").pop()??"";return s.$ref==="#/root/sections"||d===et?!0:!d||y.has(d)?!1:P(c(s.$ref),new Set([...y,d]))},Q=s=>{const y=s.properties?.__resolveType?.enum;return Array.isArray(y)&&typeof y[0]=="string"?y[0]:void 0},V=s=>Q(s)!==void 0,q=(s,y=new Set)=>{if(typeof s.$ref!="string")return[];const d=s.$ref.split("/").pop()??"";if(!d||y.has(d))return[];const a=c(s.$ref),B=a.anyOf??a.oneOf;if(!Array.isArray(B))return[];const E=new Set([...y,d]);return B.flatMap(x=>V(x)?[x]:q(x,E))},j=s=>{const y=s.hide;return y===!0||y==="true"},I=s=>typeof s=="string"&&(s.includes("://")||!/\s/.test(s)&&(s.includes("|")||s.includes("&")||s.includes("@"))),W=(s,y=new Set,d=0)=>{if(d>An)return{};if(typeof s.$ref=="string"){const B=s.$ref.split("/").pop()??"";return y.has(B)?{}:W(c(s.$ref),new Set([...y,B]),d+1)}let a={};s.properties&&typeof s.properties=="object"&&(a={...a,...s.properties}),Array.isArray(s.required)&&(a.__required=[...J(a.__required),...J(s.required)]);for(const B of["allOf","anyOf","oneOf"]){const E=s[B];if(Array.isArray(E))for(const x of E){const U=J(a.__required),H=W(x,y,d+1);a={...a,...H};const C=B==="allOf"?[...U,...J(H.__required)]:U;C.length>0?a.__required=C:delete a.__required}}return a},$=(s,y=0,d=new Set)=>{let a=s,B;if(typeof s.$ref=="string"){a=c(s.$ref);const k=s.$ref.split("/").pop()??"";B=k,k===On&&!a.format&&(a={...a,format:"video-uri"})}a=O(a);const E=B!==void 0&&d.has(B),x=B!==void 0?new Set([...d,B]):d,U=(k,m,v,T=!0)=>!E&&(!T||v<=Rn)&&m<Sn?$(k,m,x):void 0;let H;{const k=a.anyOf??a.oneOf;if(Array.isArray(k)){const m=k.filter(T=>!(T.type==="null"||T.type===null)),v=T=>{if(typeof T.const=="string"||typeof T.const=="number")return T.const;if(Array.isArray(T.enum)&&T.enum.length===1&&(typeof T.enum[0]=="string"||typeof T.enum[0]=="number"))return T.enum[0]};m.length>0&&m.every(T=>v(T)!==void 0)&&(H=m.map(T=>v(T)))}}let C,oe,Fe,qe=!1;if(a.type)C=Array.isArray(a.type)?String(a.type.find(k=>k!=="null")??a.type[0]):String(a.type);else if(a.anyOf||a.oneOf){const m=(a.anyOf??a.oneOf).filter(v=>!(v.type==="null"||v.type===null));if(m.length===0)C="null";else if(m.length===1){const v=m[0];oe=v;const T=O(v);typeof v.$ref=="string"&&se(T)?(C="array",Fe=T.items):C=v.type?Array.isArray(v.type)?String(v.type[0]):String(v.type):typeof v.$ref=="string"?"object":"string"}else{if(H){const u=p=>typeof s[p]=="string"?s[p]:typeof a[p]=="string"?a[p]:void 0;return{type:"string",title:typeof a.title=="string"?a.title:void 0,description:typeof a.description=="string"?a.description:void 0,enum:H,format:u("format"),options:u("options")}}const v=m.filter(V),T=P(s)||m.some(u=>P(u))||void 0,D=m.map(u=>O(u)).find(se),Se=u=>{if(typeof u.$ref!="string")return;const p=O(u),g=p.anyOf??p.oneOf;if(!Array.isArray(g))return;const h=[...g.filter(V),...g.filter(_=>!V(_)).flatMap(_=>q(_))],w=g.filter(_=>{if(V(_)||_.type==="null")return!1;const M=l(_),N=M.properties;return!N?.__resolveType&&!M.anyOf&&!M.oneOf&&(M.type==="object"||!!N)});return h.length>0&&w.length>0?{data:w,loaders:h}:void 0},le=m.flatMap(u=>{const p=Se(u);return p?[p]:[]}),Pt=le.length===0&&m.filter(u=>!se(O(u))).every(u=>typeof u.$ref=="string"||v.includes(u)),jt=v.some(u=>{const p=u.properties?.__resolveType?.enum;return Array.isArray(p)&&(p[0]===Mt||z(e)&&p[0]==="multivariate")}),Re=(u=[])=>{const p=new Map;for(const S of[...v,...m.filter(b=>!v.includes(b)).flatMap(b=>q(b)),...u]){const b=Q(S);b&&!p.has(b)&&p.set(b,S)}const g=[...p].map(([S,b])=>({resolveType:S,title:typeof b.title=="string"?b.title:ne(S),description:typeof b.description=="string"?b.description:void 0,schema:U(b,y+1,p.size)})),h=[];for(const S of m){if(v.includes(S)||typeof S.$ref!="string")continue;const b=c(S.$ref);let X;const Z=b.properties?.__resolveType;if(Array.isArray(Z?.enum)&&typeof Z.enum[0]=="string"&&(X=Z.enum[0]),!X&&Array.isArray(b.allOf))for(const $t of b.allOf){const Ee=$t.properties?.__resolveType?.enum;if(Array.isArray(Ee)&&typeof Ee[0]=="string"){X=Ee[0];break}}X&&h.push({resolveType:X,title:typeof b.title=="string"&&!b.title.startsWith("#")?b.title:ne(X),description:typeof b.description=="string"?b.description:void 0,schema:U(b,y+1,m.length)})}const w=new Set(g.map(S=>S.resolveType)),_=[...g,...h.filter(S=>!w.has(S.resolveType))],M=m.filter(S=>!v.includes(S)),N=M.length===1&&!E?$(M[0],y+1,x):void 0;return{type:"block-ref",title:typeof s.title=="string"?s.title:typeof a.title=="string"?a.title:void 0,description:typeof s.description=="string"?s.description:typeof a.description=="string"?a.description:void 0,anyOfRefs:_,acceptsAnySection:T,plainSchema:N,hidden:j(a)||j(s)?!0:void 0}};if(D){const u=!tt(D,c);if(u&&le.length>0){const p=typeof s.title=="string"?s.title:typeof a.title=="string"&&!I(a.title)?a.title:void 0,g=typeof s.description=="string"?s.description:typeof a.description=="string"?a.description:void 0,h=m.find(_=>se(O(_))),w=le.flatMap(_=>_.data);return{type:"inline-union",title:p,description:g,inlineUnionBranches:[...w.map((_,M)=>({title:R(_,`Option ${M+1}`),schema:$(_,y+1,x)})),{title:R(h,`Option ${w.length+1}`),schema:$(D,y+1,x)}],loaderRef:{...Re(le.flatMap(_=>_.loaders)),title:p,description:g},hidden:j(a)||j(s)?!0:void 0}}if(u&&m.length>1&&Pt){const p=$(D,y+1,x),g=typeof s.title=="string"?s.title:typeof a.title=="string"?a.title:p.title,h=typeof s.description=="string"?s.description:typeof a.description=="string"?a.description:p.description;return{...p,type:"array",title:g,description:h,loaderRef:v.length>0?{...Re(),title:g,description:h}:void 0}}if(jt){const p=$(D,y+1,x);return{...p,type:"array",title:typeof a.title=="string"?a.title:p.title,description:typeof a.description=="string"?a.description:p.description}}}if(v.length>0)return Re();const ze=u=>{const p=l(u);if(typeof p.title=="string"&&Xe(p.title))return!0;const g=p.properties?.__resolveType?.enum;if(Array.isArray(g)&&typeof g[0]=="string")return!0;if(Array.isArray(p.allOf))for(const h of p.allOf){const w=h.properties?.__resolveType?.enum;if(Array.isArray(w)&&typeof w[0]=="string")return!0}return!1},Qe=m.map(u=>A(u));if(m.length>1&&Qe.every(u=>typeof u=="string")&&!m.some(ze)){const u=m.map((p,g)=>{const h=l(p),w=Qe[g];return{resolveType:w,title:R(p,w),description:typeof h.description=="string"?h.description:void 0,discriminatorValue:w,discriminatorRequired:[h,...h.allOf??[]].some(_=>J(_.required).includes("type")),schema:U(h,y+1,m.length,!1)}});return{type:"block-ref",title:typeof s.title=="string"?s.title:typeof a.title=="string"?a.title:void 0,description:typeof s.description=="string"?s.description:typeof a.description=="string"?a.description:void 0,discriminatorKey:"type",anyOfRefs:u,hidden:j(a)||j(s)?!0:void 0}}const Oe=u=>{if(ze(u))return!1;const p=l(u);return p.type==="object"||!!p.properties},wt=u=>{const p=O(u);return se(p)?!tt(p,c):!1},Ge=y<ke&&m.every(u=>Oe(u)||wt(u))&&m.some(Oe),He=m.every(u=>typeof u.$ref=="string"),Bt=z(e)&&!He&&m.some(u=>typeof u.$ref=="string"&&bn.has(Tn(c(u.$ref))))&&m.every(u=>typeof u.$ref=="string"||Oe(u));if((He||Bt)&&!Ge){const u=[];for(const p of m){if(typeof p.$ref!="string")continue;const g=c(p.$ref);let h,w,_=!1;if(typeof g.title=="string"){const S=Xe(g.title);S&&(h=S.blockId,w=S.blockId)}if(!h&&Array.isArray(g.allOf))for(const S of g.allOf){const Z=((S.properties??{}).__resolveType??{}).enum;if(Array.isArray(Z)&&typeof Z[0]=="string"){h=Z[0],_=!0;break}}if(!h){const b=g.properties?.__resolveType?.enum;Array.isArray(b)&&typeof b[0]=="string"&&(h=b[0],_=!0)}h||(h=p.$ref.split("/").pop()??"");const M=h.includes("/")||_&&!It(h),N=M?void 0:A(p);!N&&!M||_&&h==="lazy"||u.push({resolveType:N??h,title:w??(typeof g.title=="string"&&!g.title.startsWith("#")?g.title:ne(h)),description:typeof g.description=="string"?g.description:void 0,discriminatorValue:N,schema:U(g,y+1,m.length)})}return{type:"block-ref",acceptsAnySection:T,title:typeof s.title=="string"?s.title:typeof a.title=="string"?a.title:void 0,description:typeof s.description=="string"?s.description:typeof a.description=="string"?a.description:void 0,anyOfRefs:u,hidden:j(a)||j(s)?!0:void 0}}if(Ge){const u=g=>{if(typeof g.const=="string"||typeof g.const=="number"||typeof g.const=="boolean")return g.const;if(Array.isArray(g.enum)&&g.enum.length===1&&(typeof g.enum[0]=="string"||typeof g.enum[0]=="number"||typeof g.enum[0]=="boolean"))return g.enum[0]},p=m.map((g,h)=>{const w=l(g).properties??{},_={};for(const[M,N]of Object.entries(w)){const S=u(N);S!==void 0&&(_[M]=S)}return{title:R(g,`Option ${h+1}`),schema:$(g,y+1),discriminators:Object.keys(_).length?_:void 0}});return{type:"inline-union",title:typeof s.title=="string"?s.title:typeof a.title=="string"?a.title:void 0,description:typeof a.description=="string"?a.description:void 0,inlineUnionBranches:p,hidden:j(a)||j(s)?!0:void 0}}C="object"}}else a.allOf?(C="object",qe=I(a.title)):typeof s.$ref=="string"&&(C="object");let fe,We,Ye=!1;if(y<ke&&!E){const k=W(a),m=k.__resolveType?.enum;Ye=Array.isArray(m)&&m.length===1&&m[0]==="lazy";const v=J(k.__required);v.length>0&&(We=v);const T=Object.entries(k).filter(([D])=>!D.startsWith("__")&&D!=="@type");if(T.length>0){fe={};for(const[D,Se]of T)fe[D]=$(Se,y+1,x)}}let Ae;if((C==="array"||a.type==="array")&&y<ke&&!E){const k=a.items??Fe;if(k){Ae=$(k,y+1,x);const m=l(k);typeof m.title=="string"&&m.title.includes("{{")&&(Ae.titleBy=m.title)}}const te=k=>{const m=oe?.[k];return typeof m=="string"?m:void 0},kt=()=>{if("default"in s)return s.default;if("default"in a)return a.default;if(oe&&"default"in oe)return oe.default};return{type:C??"string",title:typeof s.title=="string"?s.title:!qe&&typeof a.title=="string"?a.title:te("title"),description:typeof s.description=="string"?s.description:typeof a.description=="string"?a.description:te("description"),default:kt(),enum:Array.isArray(a.enum)?a.enum:H??void 0,format:typeof s.format=="string"?s.format:typeof a.format=="string"?a.format:te("format"),properties:fe,required:We,items:Ae,lazy:Ye&&fe?.value?!0:void 0,recursiveRef:E&&typeof s.$ref=="string"&&(C==="object"||C==="array"||a.type==="array")?s.$ref:void 0,hidden:j(a)||j(s)?!0:void 0,titleBy:typeof a.titleBy=="string"?a.titleBy:te("titleBy"),image:typeof a.image=="string"?a.image:te("image"),options:typeof s.options=="string"?s.options:typeof a.options=="string"?a.options:te("options")}};if("ref"in t)return $({$ref:t.ref});const ee=f.properties??{},ie=Object.keys(ee).every(s=>s.startsWith("__"));if(Array.isArray(f.allOf)&&f.allOf.length===1&&ie){const s=ee.__resolveType,y=Array.isArray(s?.enum)&&typeof s.enum[0]=="string"?s.enum[0]:typeof s?.const=="string"?s.const:typeof s?.default=="string"?s.default:void 0;for(const d of f.allOf){const a=O(d);if(!(Array.isArray(a.anyOf)||Array.isArray(a.oneOf))||a.properties)continue;const E=$(a,0);if(E.type==="inline-union"&&E.inlineUnionBranches){const x=I(E.title);return{...E,title:x?void 0:E.title,inlineUnionBranches:y?E.inlineUnionBranches.map(U=>({...U,discriminators:{...U.discriminators??{},__resolveType:y}})):E.inlineUnionBranches}}}}const F=W(f),Y={};for(const[s,y]of Object.entries(F))s.startsWith("__")||s==="@type"||(Y[s]=$(y,0));if(Object.keys(Y).length===0)return null;const G=J(F.__required);return{type:"object",title:typeof f.title=="string"?f.title:void 0,properties:Y,required:G.length>0?G:void 0}}function Br(e,t){const n=t.schema??{},r=ge(e,t),i=n.$defs??n.definitions??{},o=typeof r.$ref=="string"?i[r.$ref.split("/").pop()??""]??{}:r,c=o.properties??{};if(Object.keys(c).some(A=>!A.startsWith("__")))return!1;if(o.additionalProperties===!0)return!0;const l=c.__resolveType;return!!l&&Array.isArray(l.enum)&&l.enum[0]===e}function $r(e){const t=r=>{switch(typeof r){case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(r===null)return{type:"string"};if(Array.isArray(r))return{type:"array",items:t(r[0])};const i={};for(const[o,c]of Object.entries(r))o.startsWith("__")||(i[o]=t(c));return{type:"object",properties:i}}default:return{type:"string"}}},n={};for(const[r,i]of Object.entries(e))r.startsWith("__")||(n[r]=t(i));return Object.keys(n).length===0?null:{type:"object",properties:n}}function Ue(e,t){const n=t.schema??{},r=ge(e,t),i=n.$defs??n.definitions??{},o=typeof r.$ref=="string"?i[r.$ref.split("/").pop()??""]??{}:Object.keys(r).length>0?r:{...n,...r},c=o.icon,f=o.logo,l=o,A=O=>O===!0||O==="true",R=A(l.hide)||A(l.ignore)||A(l.unlisted);return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof c=="string"?c:void 0,logo:typeof f=="string"?f:void 0,hidden:R||void 0}}const pt=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],Pn=new Set(pt);function De(e){return Pn.has(e)}function Ne(e,t){return De(e)?!0:Object.hasOwn(t?.manifest?.blocks?.pages??{},e)}function xr(e,t){return Ne(e,z(t)?t:void 0)}function he(e){return e.replace(/\/+$/,"")||"/"}function Lr(e){return e.trim().replace(/^\/+|\/+$/g,"")}function jn(e){const t=e.trim();return!(!t.startsWith("/")||t.startsWith("//")||t.includes("..")||t.includes("\\"))}function Cr(e){const t=e.trim();return t?jn(t)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const Ke=/:([A-Za-z0-9_-]+)|\*/g;function wn(e){const t=[];for(const n of e.matchAll(Ke)){const r=n[1]??"*";t.includes(r)||t.push(r)}return t}function yt(e){return e.replace(/\{([^{}]*)\}\?/g,"$1")}function Mr(e){e=yt(e);const t=[];let n=0;for(const r of e.matchAll(Ke))r.index>n&&t.push({type:"text",text:e.slice(n,r.index)}),t.push({type:"param",name:r[1]??"*"}),n=r.index+r[0].length;return n<e.length&&t.push({type:"text",text:e.slice(n)}),t}function Ir(e,t){return yt(e).replace(Ke,(n,r)=>{const i=t[r??"*"]?.trim();return i?r!==void 0?encodeURIComponent(i):i.split("/").filter(Boolean).map(encodeURIComponent).join("/")||n:n})}const dt=pt[0],Bn=new Set(["site/sections/Theme/Theme.tsx"]);function $n(e,t){return Bn.has(e)?!0:t&&!e.includes("/")&&e.toLowerCase()==="theme"}function _e(e,t){return!!($n(e,z(t))||ot(e)||e.toLowerCase().includes("preview"))}function mt(e){const t=e.manifest?.blocks??{};for(const n of Object.values(t))for(const r of Object.keys(n))if(De(r))return r;return Object.hasOwn(t.pages??{},"page")?"page":dt}function xn(e){return z(e)?Object.hasOwn(e?.manifest?.blocks?.pages??{},"page"):!1}function Ur(e){return e?xn(e)?"page":mt(e):dt}function Pe(e){if(!e)return[];if(e.anyOfRefs?.length)return e.anyOfRefs;if(e.items)return Pe(e.items);if(e.properties){const t=[];for(const n of Object.values(e.properties))t.push(...Pe(n));return t}return[]}function Ln(e){const t=e.manifest?.blocks??{},n=[];for(const[r,i]of Object.entries(t))if(r.includes("sections"))for(const o of Object.keys(i)){if(_e(o,e))continue;const c=Ue(o,e);n.push({resolveType:o,title:c.title??ne(o),description:c.description,previewBlock:o,isSavedBlock:!1})}return n}function Dr(e){const t=e.manifest?.blocks??{},n=new Map;for(const[r,i]of Object.entries(t))if(r.includes("sections"))for(const o of Object.keys(i))_e(o,e)||n.has(o)||n.set(o,{resolveType:o,title:ne(o)});return[...n.values()].sort((r,i)=>r.title.localeCompare(i.title))}function gt(e,t){const n=t.__resolveType;if(typeof n!="string")return"";const r=z(e);if(!ht(n,r))return n;const i=t.variants;if(!Array.isArray(i))return n;for(const o of i){const c=Ut(o,r);if(!c||typeof c!="object")continue;let f=c.__resolveType;if(typeof f=="string"&&ot(f)&&(f=c.section?.__resolveType??f),typeof f=="string"&&xe(e,f))return f}return n}function ht(e,t){return e===Dt||t&&e===Nt}function Cn(e,t){return gt(e,t)!==t.__resolveType}function _t(e,t){const n=[];for(const[r,i]of Object.entries(t)){if(r.includes("/")||it(r)||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,c=o.__resolveType;typeof c!="string"||De(c)||typeof o.path=="string"||_e(c,e)||!(xe(e,c)||ht(c,z(e))&&Cn(e,o))||n.push({resolveType:r,title:r,description:typeof o.name=="string"?o.name:void 0,previewBlock:r,isSavedBlock:!0})}return n}function Mn(e,t){const n=st(t.resolveType,e),r=n?{}:Ue(t.resolveType,e);return{resolveType:t.resolveType,title:t.title||r.title||ne(t.resolveType),description:t.description??r.description,previewBlock:t.resolveType,isSavedBlock:n}}function Nr(e,t){const n=mt(e),r=kn(n,e),i=Pe(r?.properties?.sections),o=new Map,c=f=>{if(!_e(f.resolveType,e)){if(st(f.resolveType,e)){it(f.resolveType)||o.set(f.resolveType,f);return}xe(e,f.resolveType)&&(o.has(f.resolveType)||o.set(f.resolveType,f))}};for(const f of Ln(e))c(f);for(const f of i)c(Mn(e,f));for(const f of _t(e,t))c(f);return[...o.values()].sort((f,l)=>f.title.localeCompare(l.title))}function Kr(e){const t=e.site;if(!t||typeof t!="object"||Array.isArray(t))return;const n=t.theme;if(!(!n||typeof n!="object"||Array.isArray(n)))return n}const ve="website/loaders/redirect.ts",Vr=new Set([ve,"website/loaders/redirects.ts"]),be="redirect",In=[301,302,307,308],Un={temporary:307,permanent:301};function Fr(e){return e.flat&&e.status||Un[e.type]}const ue=e=>typeof e=="string"?e:"",Dn=e=>e==="permanent"?"permanent":"temporary",Nn=e=>In.find(t=>t===e);function vt(e){const t=Nn(e.status);return{from:ue(e.from),to:ue(e.to),type:e.permanent===!0?"permanent":"temporary",discardQueryParameters:e.discardQueryParameters===!0,flat:!0,...t?{status:t}:{}}}function Te(e){if(e?.__resolveType===be)return vt(e);const t=e&&typeof e.redirect=="object"&&e.redirect!==null&&!Array.isArray(e.redirect)?e.redirect:{};return{from:ue(t.from),to:ue(t.to),type:Dn(t.type),discardQueryParameters:t.discardQueryParameters===!0}}function Kn(e){const t=[];for(const[n,r]of Object.entries(e)){if(!r||typeof r!="object"||Array.isArray(r))continue;const i=r;i.__resolveType!==ve&&i.__resolveType!==be||t.push({key:n,...Te(i)})}return t}function qr(e){return Te(e)}function Vn(e,t){if(e.flat){const{status:r,discardQueryParameters:i,...o}=t??{};return{...o,__resolveType:be,from:e.from,to:e.to,permanent:e.type==="permanent",...e.status?{status:e.status}:{},...e.discardQueryParameters?{discardQueryParameters:!0}:{}}}const n={from:e.from,to:e.to,type:e.type};return e.discardQueryParameters&&(n.discardQueryParameters=!0),{redirect:n,__resolveType:ve}}function Fn(e){return(e.split(/[?#]/)[0]??"").replace(/^\/+/,"").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)||"redirect"}const qn=1e3;function Wr(e,t){const n=Fn(t);for(let r=0;r<qn;r++){const i=`redirects-${n}-${crypto.randomUUID()}`;if(!Object.hasOwn(e,i))return i}throw new Error("Could not generate a unique redirect block key")}const Wn="Redirects",bt="redirects";function Tt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&e.__resolveType===bt}function Yn(e){return Object.keys(e).filter(n=>Tt(e[n])).sort()[0]??Wn}function Yr(e,t){const n=e.lastIndexOf("#");if(n<=0)return null;const r=e.slice(0,n),i=e.slice(n+1);return!/^\d+$/.test(i)||!Object.hasOwn(t,r)||!Tt(t[r])?null:{block:r,index:Number(i)}}function re(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=e.redirects;return Array.isArray(t)?t.filter(n=>!!n&&typeof n=="object"&&!Array.isArray(n)):[]}function At(e){return"redirect"in e?Te(e):vt({...e})}function St(e,t){const{__resolveType:n,...r}=Vn(e,{...t});return r}function zr(e,t){return re(t).map((n,r)=>[`${e}#${r}`,"redirect"in n?{...n,__resolveType:ve}:{...n,__resolveType:be}])}function Qr(e,t=Yn(e)){return re(e[t]).map((n,r)=>({key:`${t}#${r}`,...At(n)}))}function Gr(e,t){const n=re(e)[t];return n?At(n):Te(void 0)}function Ve(e,t){return{...e&&typeof e=="object"&&!Array.isArray(e)?e:{},__resolveType:bt,redirects:t}}function Hr(e,t){return Ve(e,[...re(e),St(t)])}function Xr(e,t,n){const r=re(e),i=r.slice();return i[t]=St(n,r[t]),Ve(e,i)}function Zr(e,t){return Ve(e,re(e).filter((n,r)=>r!==t))}function zn(e){let t=e;t.startsWith("pages-")&&(t=t.slice(6)),t=t.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),t=t.replace(/-[0-9a-f]{8,}$/i,""),t=t.replace(/-\d{5,}$/,"");try{return decodeURIComponent(t)}catch{return t}}function Jr(e,t){const{pageId:n,path:r,pathTemplate:i}=t;if(n){const o=e.find(f=>f.key===n);if(o)return o;const c=e.find(f=>f.key.endsWith(`-${n}`));if(c)return c}if(r){const o=je(e,r);if(o)return o}if(i){const o=je(e,i);if(o)return o}return null}function je(e,t,n){const r=he;if(n){const o=e.find(c=>c.key===n);if(o)return o}const i=e.filter(o=>r(o.path)===r(t));return i.length===0?null:i.length===1?i[0]??null:[...i].sort((o,c)=>o.key.localeCompare(c.key))[0]??null}function ei(e,t,n){const r=je(e,t,n);return r||he(t)!=="/"?r:Gn(e)??e[0]??null}function Qn(e){return he(e).split("/").filter(Boolean)}function Gn(e){const t=e.map(n=>Qn(n.path));return e.find((n,r)=>{if(wn(n.path).length>0)return!1;const i=t[r];return t.every(o=>i.every((c,f)=>o[f]===c))})??null}const ce="site",Rt="site/apps/site.ts";function we(e,t){return e===ce?!0:t.__resolveType===Rt}function ti(e,t){return e?Ot(e,t).length>0||Kn(e).length>0?!0:t?tr(e,t).length>0||Jn(e,t)?!0:er(e,t).length>0:!1:!1}function Hn(e,t,n){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=t;return typeof r.__resolveType!="string"||!Ne(r.__resolveType,n)||typeof r.path!="string"?null:{key:e,name:typeof r.name=="string"?r.name:zn(e),path:r.path}}function Ot(e,t){const n=[];for(const[r,i]of Object.entries(e)){const o=Hn(r,i,t);o&&n.push(o)}return n}function Be(e,t,n=0){if(n>64||!e||typeof e!="object")return!1;if(Array.isArray(e))return e.some(i=>Be(i,t,n+1));const r=e;return typeof r.__resolveType=="string"&&t.has(r.__resolveType)?!0:Object.values(r).some(i=>Be(i,t,n+1))}function nt(e,t){return Kt(e)?Vt(e).some(n=>t.has(n)):Be(e,t)}function Xn(e,t,n){const r=Ot(e,n),i=new Set(r.map(c=>c.key)),o=new Set([t]);for(let c=!0;c;){c=!1;for(const[f,l]of Object.entries(e))o.has(f)||i.has(f)||nt(l,o)&&(o.add(f),c=!0)}return r.filter(c=>c.key!==t&&nt(e[c.key],o))}function ni(e,t,n){const r=o=>he(o.path)==="/"?0:/:[A-Za-z0-9_-]|\*/.test(o.path)?2:1,[i]=Xn(e,t,n).sort((o,c)=>r(o)-r(c)||(o.path<c.path?-1:o.path>c.path?1:0));return i??null}function Zn(e,t){if(typeof t.name=="string"){const n=t.name.trim();if(n)return n}return e.replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function $e(e,t,n){const r=typeof t.__resolveType=="string"?t.__resolveType:"",i=r?Ue(r,n):{};if(i.title)return i.title;if(typeof t.name=="string"){const o=t.name.trim();if(o)return o}return e.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function Jn(e,t){const n=e[ce];if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n,i=r.__resolveType;if(typeof i=="string"&&(we(ce,r)||lt(t,i)))return{key:ce,name:$e(ce,r,t),resolveType:i}}for(const[r,i]of Object.entries(e)){if(r.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i;if(!we(r,o))continue;const c=typeof o.__resolveType=="string"?o.__resolveType:Rt;return{key:r,name:$e(r,o,t),resolveType:c}}return null}function er(e,t){const n=[];for(const[r,i]of Object.entries(e)){if(r.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,c=o.__resolveType;typeof c=="string"&&(Ne(c,t)||typeof o.path!="string"&&(we(r,o)||!lt(t,c)&&!En(c)||n.push({key:r,name:$e(r,o,t),resolveType:c})))}return n.sort((r,i)=>r.name.localeCompare(i.name))}function tr(e,t){return _t(t,e).map(n=>{const r=e[n.resolveType],i=gt(t,r);return{key:n.resolveType,name:n.description??Zn(n.resolveType,r),resolveType:i}}).sort((n,r)=>n.name.localeCompare(r.name))}const nr=/^(?:collections\/blog|blog-manager)\/(posts|categories|authors)\//,rr={posts:"post",categories:"category",authors:"author"},Et=["post","category","author"];function pe(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ri(e,...t){const n=e?nr.exec(e)?.[1]:void 0;if(n)return rr[n]??null;for(const r of t){if(!pe(r))continue;const i=r.__resolveType;if(typeof i!="string"||!i.startsWith("blog/"))continue;const o=Et.find(c=>pe(r[c]));if(o)return o}return null}function ir(...e){for(const t of e)if(pe(t))for(const n of Et){const r=t[n];if(pe(r))for(const i of["title","name"]){const o=r[i];if(typeof o=="string"&&o.trim())return o.trim()}}return null}function or(e,t=Ft){return t(`sectionsEditor.blogKind.${e}`)}function ii(e,t,n){return ir(...t)??or(e,n)}const sr="https://github.com/decocms/blocks";function oi(){const e=ae.c(14),t=ye();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=L.jsx(ct,{size:48,className:"text-muted-foreground"}),e[0]=n):n=e[0];let r;e[1]!==t?(r=t("mainPanelTabs.blocksTabStates.emptyStateTitle"),e[1]=t,e[2]=r):r=e[2];let i;e[3]!==t?(i=t("mainPanelTabs.blocksTabStates.emptyStateDescription"),e[3]=t,e[4]=i):i=e[4];let o;e[5]!==t?(o=t("mainPanelTabs.blocksTabStates.setupContentEditing"),e[5]=t,e[6]=o):o=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=L.jsx(zt,{size:14}),e[7]=c):c=e[7];let f;e[8]!==o?(f=L.jsx(Le,{size:"sm",asChild:!0,children:L.jsxs("a",{href:sr,target:"_blank",rel:"noreferrer",children:[o,c]})}),e[8]=o,e[9]=f):f=e[9];let l;return e[10]!==r||e[11]!==i||e[12]!==f?(l=L.jsx(Ce,{className:"h-full w-full",image:n,title:r,description:i,actions:f}),e[10]=r,e[11]=i,e[12]=f,e[13]=l):l=e[13],l}function si(e){const t=ae.c(15),{source:n,onRetry:r}=e,i=ye();let o;t[0]!==n||t[1]!==i?(o=i(n==="sandbox"?"mainPanelTabs.blocksTabStates.errorStateSandbox":"mainPanelTabs.blocksTabStates.errorStateData"),t[0]=n,t[1]=i,t[2]=o):o=t[2];const c=o;let f;t[3]===Symbol.for("react.memo_cache_sentinel")?(f=L.jsx(an,{size:48,className:"text-muted-foreground"}),t[3]=f):f=t[3];let l;t[4]!==i?(l=i("mainPanelTabs.blocksTabStates.errorStateTitle"),t[4]=i,t[5]=l):l=t[5];let A;t[6]!==i?(A=i("mainPanelTabs.blocksTabStates.retry"),t[6]=i,t[7]=A):A=t[7];let R;t[8]!==r||t[9]!==A?(R=L.jsx(Le,{variant:"outline",size:"sm",onClick:r,children:A}),t[8]=r,t[9]=A,t[10]=R):R=t[10];let O;return t[11]!==c||t[12]!==l||t[13]!==R?(O=L.jsx(Ce,{image:f,title:l,description:c,actions:R}),t[11]=c,t[12]=l,t[13]=R,t[14]=O):O=t[14],O}function ci(e){return e.kind==="unavailable"&&e.siteNotOwned===!0}function ai(){const e=ae.c(16),t=ye(),{org:n}=qt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=L.jsx(ct,{size:48,className:"text-muted-foreground"}),e[0]=r):r=e[0];let i;e[1]!==t?(i=t("siteEditor.siteNotOwned.title"),e[1]=t,e[2]=i):i=e[2];let o;e[3]!==t?(o=t("siteEditor.siteNotOwned.body"),e[3]=t,e[4]=o):o=e[4];let c;e[5]!==n.slug?(c={org:n.slug},e[5]=n.slug,e[6]=c):c=e[6];let f;e[7]!==t?(f=t("siteEditor.siteNotOwned.openProjects"),e[7]=t,e[8]=f):f=e[8];let l;e[9]!==c||e[10]!==f?(l=L.jsx(Le,{size:"sm",variant:"outline",asChild:!0,children:L.jsx(Wt,{to:"/$org/projects",params:c,"data-testid":"site-not-owned-projects",children:f})}),e[9]=c,e[10]=f,e[11]=l):l=e[11];let A;return e[12]!==i||e[13]!==o||e[14]!==l?(A=L.jsx(Ce,{className:"h-full w-full",image:r,title:i,description:o,actions:l}),e[12]=i,e[13]=o,e[14]=l,e[15]=A):A=e[15],A}function fi(e){const t=ae.c(6),{backend:n}=e,r=ye(),i=n.kind==="pending"?n.retrying:void 0;let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=L.jsx(Yt,{className:"size-5 text-muted-foreground"}),t[0]=o):o=t[0];let c;t[1]!==i||t[2]!==r?(c=i&&L.jsx("p",{className:"max-w-xs text-center text-sm text-muted-foreground",children:r("siteEditor.retrying.sandbox")}),t[1]=i,t[2]=r,t[3]=c):c=t[3];let f;return t[4]!==c?(f=L.jsxs("div",{"data-testid":"content-backend-waiting",className:"flex h-full w-full flex-col items-center justify-center gap-3",children:[o,c]}),t[4]=c,t[5]=f):f=t[5],f}export{xr as $,Zn as A,si as B,fi as C,bt as D,zr as E,hr as F,gt as G,qr as H,Yr as I,Jr as J,Jn as K,Kn as L,Dr as M,de as N,Vr as O,Yn as P,Zr as Q,Un as R,ai as S,Qr as T,Wr as U,Vn as V,Hr as W,Ur as X,De as Y,Br as Z,$r as _,Lr as a,xn as a0,Pe as a1,_e as a2,Hn as a3,zn as a4,ri as a5,ii as a6,_r as a7,or as a8,dt as a9,me as aa,wr as ab,Nr as ac,Sr as ad,Je as ae,Or as af,Rr as ag,br as ah,Er as ai,mr as aj,ir as ak,Ar as al,kr as am,Kr as an,je as ao,Gr as ap,In as aq,Xr as ar,oi as b,Ot as c,tr as d,wn as e,Ir as f,ei as g,ti as h,ci as i,vr as j,gr as k,mt as l,jr as m,he as n,Rt as o,ni as p,we as q,Tr as r,Mr as s,En as t,Pr as u,Cr as v,$e as w,Ue as x,Fr as y,kn as z};