@collective-intelligence/extensions-sdk-frontend-react 0.1.1 → 0.1.3

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.
@@ -1 +1 @@
1
- import{Component as E,createContext as k,createElement as H,useContext as y,useEffect as C,useLayoutEffect as F,useRef as L,useState as b}from"react";import"react";var v=["admission","resolve","load","render"],h=(q)=>q.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),S=(q)=>{if(typeof q.module==="string")return{exportName:q.exportName,module:q.module};return{exportName:q.exportName,module:q.module.pathname.split("/").pop()??"unknown-module"}},Z=(q)=>{let{declaration:w,phase:Q,message:V,cause:W,sourceMap:X}=q,{target:J}=w,$=["FE",Q.toUpperCase(),J.packageFqn,J.fqn,J.version,J.role].map(h).join("-");return{componentFqn:J.fqn,diagnosticId:$,message:V,packageFqn:J.packageFqn,phase:Q,role:J.role,source:S(w.implementation.render),version:J.version,...X===void 0?void 0:{sourceMap:X},...W===void 0?void 0:{cause:String(W instanceof Error?W.message:W)}}};import{jsx as z,jsxs as x}from"react/jsx-runtime";var d=async(q,w="render")=>{let Q=q.implementation[w]??q.implementation.render;if(Q.load!==void 0)return await Q.load();return await import(/* @vite-ignore */ String(Q.module))},D=(q)=>x("div",{role:"alert","data-diagnostic-id":q.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",q.diagnosticId]}),P=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),U=globalThis,_=U[P]??k(D);U[P]=_;var s=({children:q,render:w})=>z(_.Provider,{value:w,children:q}),A=({diagnostic:q})=>y(_)(q),K=(q,w)=>{console.error(`Hosted extension ${q.diagnosticId}: ${q.message}`,w)};class M extends E{constructor(q){super(q);this.state={error:null}}static getDerivedStateFromError(q){return{error:q}}componentDidCatch(q,w){let Q=Z({cause:q,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(Q)}render(){if(this.state.error!==null){let q=Z({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return z(A,{diagnostic:q})}return this.props.children}}var R=z("output",{children:"Loading extension…"}),l=({componentProps:q,declaration:w,fallback:Q=R,implementationRole:V="render",load:W,onDiagnostic:X})=>{let[J,$]=b(null),G=L({load:W,onDiagnostic:X});F(()=>{G.current={load:W,onDiagnostic:X}},[W,X]),C(()=>{let I=!0;return(async()=>{try{let O=await G.current.load();if(!I)return;let Y=w.implementation[V]??w.implementation.render,B=O[Y.exportName];if(B===void 0){let T=Z({declaration:w,message:`Export "${Y.exportName}" was not a React component.`,phase:"load"});K(T,T),G.current.onDiagnostic?.(T),$({declaration:w,diagnostic:T,implementationRole:V,kind:"failed"});return}$({component:B,declaration:w,implementationRole:V,kind:"ready"})}catch(O){if(!I)return;let Y=Z({cause:O,declaration:w,message:"The hosted component could not be loaded.",phase:"load"});K(Y,O),G.current.onDiagnostic?.(Y),$({declaration:w,diagnostic:Y,implementationRole:V,kind:"failed"})}})(),()=>{I=!1}},[w,V]);let N=J?.declaration===w&&J.implementationRole===V?J:null;if(N===null)return Q;if(N.kind==="failed")return z(A,{diagnostic:N.diagnostic});let j={children:H(N.component,q),declaration:w,...X===void 0?void 0:{onDiagnostic:X}};return z(M,{...j})};export{d as loadDeclarationModule,v as hostedDiagnosticPhases,Z as createHostedDiagnostic,l as HostedExtensionRender,s as HostedExtensionFailureProvider};
1
+ import{Component as k,createContext as b,createElement as S,useContext as L,useEffect as M,useLayoutEffect as N,useRef as w,useState as I}from"react";import"react";var F=["admission","resolve","load","render"],E=(e)=>e.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),v=(e)=>{if(typeof e.module==="string")return{exportName:e.exportName,module:e.module};return{exportName:e.exportName,module:e.module.pathname.split("/").pop()??"unknown-module"}},d=(e)=>{let{declaration:o,phase:n,message:r,cause:s,sourceMap:i}=e,{target:t}=o,c=["FE",n.toUpperCase(),t.packageFqn,t.fqn,t.version,t.role].map(E).join("-");return{componentFqn:t.fqn,diagnosticId:c,message:r,packageFqn:t.packageFqn,phase:n,role:t.role,source:v(o.implementation.render),version:t.version,...i===void 0?void 0:{sourceMap:i},...s===void 0?void 0:{cause:String(s instanceof Error?s.message:s)}}};import{jsx as p,jsxs as B}from"react/jsx-runtime";var K=async(e,o="render")=>{let n=e.implementation[o]??e.implementation.render;if(n.load!==void 0)return await n.load();return await import(/* @vite-ignore */ String(n.module))},q=(e)=>B("div",{role:"alert","data-diagnostic-id":e.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",e.diagnosticId]}),R=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),H=globalThis,f=H[R]??b(q);H[R]=f;var G=({children:e,render:o})=>p(f.Provider,{value:o,children:e}),D=({diagnostic:e})=>L(f)(e),h=(e,o)=>{console.error(`Hosted extension ${e.diagnosticId}: ${e.message}`,o)};class C extends k{constructor(e){super(e);this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,o){let n=d({cause:e,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(n)}render(){if(this.state.error!==null){let e=d({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return p(D,{diagnostic:e})}return this.props.children}}var T=p("output",{children:"Loading extension…"}),O=({componentProps:e,declaration:o,fallback:n=T,implementationRole:r="render",load:s,onDiagnostic:i})=>{let[t,c]=I(null),l=w({load:s,onDiagnostic:i});N(()=>{l.current={load:s,onDiagnostic:i}},[s,i]),M(()=>{let x=!0;return(async()=>{try{let m=await l.current.load();if(!x)return;let a=o.implementation[r]??o.implementation.render,y=m[a.exportName];if(y===void 0){let g=d({declaration:o,message:`Export "${a.exportName}" was not a React component.`,phase:"load"});h(g,g),l.current.onDiagnostic?.(g),c({declaration:o,diagnostic:g,implementationRole:r,kind:"failed"});return}c({component:y,declaration:o,implementationRole:r,kind:"ready"})}catch(m){if(!x)return;let a=d({cause:m,declaration:o,message:"The hosted component could not be loaded.",phase:"load"});h(a,m),l.current.onDiagnostic?.(a),c({declaration:o,diagnostic:a,implementationRole:r,kind:"failed"})}})(),()=>{x=!1}},[o,r]);let u=t?.declaration===o&&t.implementationRole===r?t:null;if(u===null)return n;if(u.kind==="failed")return p(D,{diagnostic:u.diagnostic});let P={children:S(u.component,e),declaration:o,...i===void 0?void 0:{onDiagnostic:i}};return p(C,{...P})};export{G as HostedExtensionFailureProvider,O as HostedExtensionRender,d as createHostedDiagnostic,F as hostedDiagnosticPhases,K as loadDeclarationModule};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export declare const declareStudioApp: (input: import("./studio-declarations").StudioAppDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioAppDeclaration>;
2
- export declare const declareStudioComponent: (input: import("./studio-declarations").StudioComponentDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioComponentDeclaration>;
1
+ import { declareStudioApp as declareStudioAppImplementation, declareStudioComponent as declareStudioComponentImplementation } from "./studio-declarations.js";
2
+ export declare const declareStudioApp: typeof declareStudioAppImplementation;
3
+ export declare const declareStudioComponent: typeof declareStudioComponentImplementation;
3
4
  export type { LocalizedStudioText, StudioAppDeclaration, StudioAppDeclarationInput, StudioAppDefinition, StudioAppPageDefinition, StudioAppSectionDefinition, StudioComponentComposition, StudioComponentDeclaration, StudioComponentDeclarationInput } from "./studio-declarations.js";
4
5
  export type { HostedContributionErrorBoundaryProps, HostedContributionLoadFailure, HostedContributionLoadState, HostedContributionUnavailableProps } from "./load-state.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{assertConsumerProfile as F,canonicalJson as G,normalizePackageSchemaProjection as H}from"@collective-intelligence/extensions-sdk";var B=(q)=>{try{G(q)}catch(w){let x=w instanceof Error?w.message:String(w);throw TypeError(`Studio declaration must be serializable JSON: ${x}`,{cause:w})}},D=(q)=>{let w={...q.definition,...q.presentation,...q.manifest,kind:"studioApp"};return B(w),{manifest:w,schemaSidecars:[]}},E=(q)=>{let w=q.definition.propsSchema,x=`studio_component:${q.manifest.fqn}.propsSchema`,y=H(w.project("input"));F(y,"studio_props",x);let A={category:q.definition.category,...q.definition.composition===void 0?void 0:{composition:q.definition.composition},...q.presentation,...q.manifest,kind:"studioComponent",propsSchema:y,sourceRef:q.definition.sourceRef};return B(A),{manifest:A,schemaSidecars:[{direction:"input",location:x,profile:"studio_props",source:w}]}};var O=D,Q=E;export{Q as declareStudioComponent,O as declareStudioApp};
1
+ import{assertConsumerProfile as s,canonicalJson as d,normalizePackageSchemaProjection as c}from"@collective-intelligence/extensions-sdk";var a=(o)=>{try{d(o)}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`Studio declaration must be serializable JSON: ${t}`,{cause:e})}},r=(o)=>{let e={...o.definition,...o.presentation,...o.manifest,kind:"studioApp"};return a(e),{manifest:e,schemaSidecars:[]}},p=(o)=>{let e=o.definition.propsSchema,t=`studio_component:${o.manifest.fqn}.propsSchema`,n=c(e.project("input"));s(n,"studio_props",t);let i={category:o.definition.category,...o.definition.composition===void 0?void 0:{composition:o.definition.composition},...o.presentation,...o.manifest,kind:"studioComponent",propsSchema:n,sourceRef:o.definition.sourceRef};return a(i),{manifest:i,schemaSidecars:[{direction:"input",location:t,profile:"studio_props",source:e}]}};var f=r,g=p;export{f as declareStudioApp,g as declareStudioComponent};
package/dist/studio.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export declare const declareStudioApp: (input: import("./studio-declarations").StudioAppDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioAppDeclaration>;
2
- export declare const declareStudioComponent: (input: import("./studio-declarations").StudioComponentDeclarationInput) => import("@collective-intelligence/extensions-sdk").DeclaredComponent<import("./studio-declarations").StudioComponentDeclaration>;
1
+ import { declareStudioApp as declareStudioAppImplementation, declareStudioComponent as declareStudioComponentImplementation } from "./studio-declarations.js";
2
+ export declare const declareStudioApp: typeof declareStudioAppImplementation;
3
+ export declare const declareStudioComponent: typeof declareStudioComponentImplementation;
3
4
  export type { HostedContributionErrorBoundaryProps, HostedContributionLoadFailure, HostedContributionLoadState, HostedContributionUnavailableProps } from "./load-state.js";
4
5
  export type { LocalizedStudioText, StudioAppDeclaration, StudioAppDeclarationInput, StudioAppDefinition, StudioAppPageDefinition, StudioAppSectionDefinition, StudioComponentComposition, StudioComponentDeclaration, StudioComponentDeclarationInput } from "./studio-declarations.js";
package/dist/studio.js CHANGED
@@ -1 +1 @@
1
- import{assertConsumerProfile as F,canonicalJson as G,normalizePackageSchemaProjection as H}from"@collective-intelligence/extensions-sdk";var B=(q)=>{try{G(q)}catch(w){let x=w instanceof Error?w.message:String(w);throw TypeError(`Studio declaration must be serializable JSON: ${x}`,{cause:w})}},D=(q)=>{let w={...q.definition,...q.presentation,...q.manifest,kind:"studioApp"};return B(w),{manifest:w,schemaSidecars:[]}},E=(q)=>{let w=q.definition.propsSchema,x=`studio_component:${q.manifest.fqn}.propsSchema`,y=H(w.project("input"));F(y,"studio_props",x);let A={category:q.definition.category,...q.definition.composition===void 0?void 0:{composition:q.definition.composition},...q.presentation,...q.manifest,kind:"studioComponent",propsSchema:y,sourceRef:q.definition.sourceRef};return B(A),{manifest:A,schemaSidecars:[{direction:"input",location:x,profile:"studio_props",source:w}]}};var O=D,Q=E;export{Q as declareStudioComponent,O as declareStudioApp};
1
+ import{assertConsumerProfile as s,canonicalJson as d,normalizePackageSchemaProjection as c}from"@collective-intelligence/extensions-sdk";var a=(o)=>{try{d(o)}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`Studio declaration must be serializable JSON: ${t}`,{cause:e})}},r=(o)=>{let e={...o.definition,...o.presentation,...o.manifest,kind:"studioApp"};return a(e),{manifest:e,schemaSidecars:[]}},p=(o)=>{let e=o.definition.propsSchema,t=`studio_component:${o.manifest.fqn}.propsSchema`,n=c(e.project("input"));s(n,"studio_props",t);let i={category:o.definition.category,...o.definition.composition===void 0?void 0:{composition:o.definition.composition},...o.presentation,...o.manifest,kind:"studioComponent",propsSchema:n,sourceRef:o.definition.sourceRef};return a(i),{manifest:i,schemaSidecars:[{direction:"input",location:t,profile:"studio_props",source:e}]}};var f=r,g=p;export{f as declareStudioApp,g as declareStudioComponent};
package/dist/workflow.js CHANGED
@@ -1 +1 @@
1
- var m0=Object.defineProperty;var v0=(Z)=>Z;function x0(Z,$){this[Z]=v0.bind(null,$)}var p0=(Z,$)=>{for(var U in $)m0(Z,U,{get:$[U],enumerable:!0,configurable:!0,set:x0.bind($,U)})};var A=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var Y$=(Z)=>Boolean(Z)===Z,d0=(Z)=>Object.prototype.toString.call(Z)==="[object Function]",k=(Z)=>Number(Z)===Z,D=(Z)=>Z!==null&&Object(Z)===Z&&!d0(Z),b=(Z)=>{let $=Object.prototype.toString.call(Z);if(Z===null||$==="[object Boolean]"||$==="[object Number]"||$==="[object String]")return!0;if(Array.isArray(Z))return Z.every(b);return D(Z)&&Object.values(Z).every(b)},I=(Z)=>b(Z)&&D(Z)&&!Array.isArray(Z),Q=(Z)=>String(Z)===Z,D6=(Z)=>Z===void 0,T6=(Z)=>{let $=Z;if(Q($))return $;if(Y$($)||k($))return String($);return""};import{ArrowRight as u0,CheckCircle2 as c0,Wrench as r0,Zap as l0}from"@collective-intelligence/ui-react/icons";var F1=function($){switch($){case"trigger":case"trigger_node":return{icon:l0,label:"Trigger",tone:"bg-violet-500/12 text-violet-600 dark:text-violet-400"};case"input_node":return{icon:u0,label:"Input",tone:"bg-sky-500/12 text-sky-600 dark:text-sky-400"};case"output_node":return{icon:c0,label:"Output",tone:"bg-emerald-500/12 text-emerald-600 dark:text-emerald-400"};default:return{icon:r0,label:"Action",tone:"bg-slate-500/12 text-slate-600 dark:text-slate-400"}}};var L1=()=>{};import{AlertTriangle as o0,Plus as s0}from"@collective-intelligence/ui-react/icons";import{Tooltip as i0,TooltipContent as n0,TooltipTrigger as a0}from"@collective-intelligence/ui-react/ui";import{Handle as t0,Position as R1,useNodeId as e0,useUpdateNodeInternals as $4}from"@xyflow/react";import{useEffect as Z4}from"react";import{jsx as F,jsxs as j,Fragment as Y4}from"react/jsx-runtime";var U4,D1=function($){if(Q($))return $;if(D($)&&"kind"in $&&"text"in $){let U=$;if(U.kind==="literal"&&Q(U.text))return U.text}if(D($)&&"en"in $){let U=$.en;return Q(U)?U:""}return""},W4=({issues:Z,title:$})=>{let U=`${Z.length} ${Z.length===1?"issue":"issues"} on ${$}`;return j(i0,{children:[F(a0,{asChild:!0,children:F("button",{type:"button","aria-label":U,className:"nodrag nopan absolute -right-2 -top-2 z-20 flex size-7 items-center justify-center rounded-full border border-[color-mix(in_oklab,var(--warning)_45%,var(--border))] bg-[color-mix(in_oklab,var(--warning)_16%,var(--card))] text-[color-mix(in_oklab,var(--warning)_80%,var(--foreground))] shadow-sm transition hover:bg-[color-mix(in_oklab,var(--warning)_24%,var(--card))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:(W)=>{W.stopPropagation()},onPointerDown:(W)=>{W.stopPropagation()},children:F(o0,{"aria-hidden":"true",className:"size-4"})})}),j(n0,{side:"top",sideOffset:6,className:"max-w-72 p-3",children:[F("p",{className:"font-semibold",children:U}),F("ul",{className:"mt-1.5 space-y-1",children:Z.map((W)=>F("li",{className:"leading-snug",children:W.message},`${W.code}:${W.message}`))})]})]})},T1=({port:Z,side:$,index:U=0,count:W=1})=>{let X=$==="left"?R1.Left:R1.Right,Y={top:`${(U+1)/(W+1)*100}%`},z=Z.maxConnections===null?"unlimited connections":`maximum ${Z.maxConnections??1} connections`,G=[...Array.isArray(Z.allowedTemplateKinds)?Z.allowedTemplateKinds.filter(Q):[],...Array.isArray(Z.allowedTemplateFqns)?Z.allowedTemplateFqns.filter(Q):[]],J=`${Z.key} — ${Z.direction}, ${z}${G.length?`; accepts ${G.join(", ")}`:""}`;return j(Y4,{children:[F(t0,{id:Z.key,type:Z.direction==="input"?"target":"source",position:X,title:J,"aria-label":J,style:Y,className:Z.direction==="input"?"!h-5 !w-5 !rounded-sm !border-2 !border-background !bg-primary":"!h-5 !w-5 !border-2 !border-background !bg-primary"}),F("span",{style:Y,className:`pointer-events-none absolute z-10 -translate-y-full whitespace-nowrap rounded bg-card px-1 text-[10px] text-muted-foreground ${$==="left"?"right-full mr-2":"left-full ml-2"}`,children:Z.key})]})},X4=({signature:Z})=>{let $=e0(),U=$4();return Z4(()=>{if($!==null)U($)},[$,Z,U]),null},$$=({context:Z,accent:$})=>{let U=Z.ports.filter((w)=>w.direction==="input"),W=Z.ports.filter((w)=>w.direction==="output"),X=new Set(Z.chart.connectedOutputPortKeys),Y=Z.chart.fields??[],z=D1(Z.template.label),G=Z.chart.title??z,J=Z.chart.subtitle??(G===z?void 0:z),_=Z.chart.description??D1(Z.template.description),{icon:K}=Z.chart.presentation??F1(Z.template.kind),B=Z.chart.presentation?.tone??U4[$],N=Z.diagnostics.filter((w)=>w.severity!=="info");return j("div",{className:"relative w-[262px]",children:[N.length?F(W4,{issues:N,title:G}):null,j("button",{type:"button","aria-label":`Edit ${G}`,style:{minHeight:(Math.max(U.length,W.length)+1)*28},onDoubleClick:()=>{Z.chart.onOpenDetails()},className:`workflow-node-drag group relative z-10 w-full cursor-pointer rounded-2xl border bg-card p-4 text-left shadow-[0_2px_10px_-4px_rgba(30,29,26,0.12)] transition-[border-color,box-shadow] hover:shadow-[0_8px_24px_-14px_rgba(30,29,26,0.24)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${B}`,children:[Z.ports.length>0?F(X4,{signature:Z.ports.map((w)=>`${w.direction}:${w.key}`).join("|")}):null,U.map((w,H)=>F(T1,{port:w,side:"left",index:H,count:U.length},w.key)),W.map((w,H)=>F(T1,{port:w,side:"right",index:H,count:W.length},w.key)),j("div",{className:"flex items-start gap-3",children:[F("div",{className:`flex size-10 shrink-0 items-center justify-center rounded-xl ${B}`,children:F(K,{className:"size-5"})}),j("div",{className:"min-w-0",children:[F("div",{className:"truncate text-sm font-semibold text-foreground",children:G}),Q(J)&&J.length>0?F("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:J}):null]})]}),(()=>{if(Q(_)&&_.length>0)return j("div",{className:"mt-3 space-y-1 border-t border-border/70 pt-3",children:[Q(_)&&_.length>0?F("p",{className:"text-xs leading-snug text-muted-foreground",children:_}):null,Q(Z.chart.summary)&&Z.chart.summary.length>0?F("p",{className:"text-xs text-muted-foreground",children:Z.chart.summary}):null]});return null})(),Y.length?F("div",{className:"mt-3 space-y-1.5 border-t border-border/70 pt-3",children:Y.slice(0,4).map((w)=>F("div",{className:"truncate rounded-md bg-muted px-2.5 py-1.5 font-mono text-[11px] text-foreground",children:w},w))}):null]}),(()=>{if(W.length)return F("div",{className:`absolute left-full top-0 h-full ${W.length===1?"w-24":"w-36"}`,children:W.map((w,H)=>X.has(w.key)?null:j("div",{className:"absolute left-0 right-0 flex -translate-y-1/2 items-center gap-1.5",style:{top:`${(H+1)/(W.length+1)*100}%`},children:[F("div",{className:"h-px min-w-8 flex-1 bg-foreground/40"}),X.has(w.key)?null:F("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center rounded-md border border-border-strong bg-card text-muted-foreground shadow-sm transition hover:border-primary hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40","aria-label":`Add after ${G} ${w.key}`,title:`Add after ${w.key}`,onClick:(V)=>{V.stopPropagation(),Z.chart.onAddFromPort?.(w)},children:F(s0,{className:"size-3.5"})})]},w.key))});return null})()]})};var g$=A(()=>{L1();U4={emerald:"bg-[color-mix(in_oklab,var(--chart-2)_12%,var(--card))] text-emerald-600 border-emerald-500/30",sky:"bg-[color-mix(in_oklab,var(--chart-4)_12%,var(--card))] text-sky-600 border-sky-500/30",slate:"bg-[color-mix(in_oklab,var(--bg-surface-alt)_55%,var(--card))] text-slate-600 border-slate-500/30",violet:"bg-[color-mix(in_oklab,var(--chart-5)_12%,var(--card))] text-violet-600 border-violet-500/30"}});var z4=(Z)=>Z.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),G4=(Z)=>{if(typeof Z.module==="string")return{exportName:Z.exportName,module:Z.module};return{exportName:Z.exportName,module:Z.module.pathname.split("/").pop()??"unknown-module"}},z$=(Z)=>{let{declaration:$,phase:U,message:W,cause:X,sourceMap:Y}=Z,{target:z}=$,G=["FE",U.toUpperCase(),z.packageFqn,z.fqn,z.version,z.role].map(z4).join("-");return{componentFqn:z.fqn,diagnosticId:G,message:W,packageFqn:z.packageFqn,phase:U,role:z.role,source:G4($.implementation.render),version:z.version,...Y===void 0?void 0:{sourceMap:Y},...X===void 0?void 0:{cause:String(X instanceof Error?X.message:X)}}};var P1=()=>{};import{Component as J4,createContext as _4,createElement as K4,useContext as V4,useEffect as Q4,useLayoutEffect as w4,useRef as H4,useState as q4}from"react";import"react";import{jsx as M$,jsxs as A4}from"react/jsx-runtime";var B4=(Z)=>A4("div",{role:"alert","data-diagnostic-id":Z.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",Z.diagnosticId]}),E1,O1,I1,S1=({diagnostic:Z})=>V4(I1)(Z),C1=(Z,$)=>{console.error(`Hosted extension ${Z.diagnosticId}: ${Z.message}`,$)},k1,M4,Z$=({componentProps:Z,declaration:$,fallback:U=M4,implementationRole:W="render",load:X,onDiagnostic:Y})=>{let[z,G]=q4(null),J=H4({load:X,onDiagnostic:Y});w4(()=>{J.current={load:X,onDiagnostic:Y}},[X,Y]),Q4(()=>{let B=!0;return(async()=>{try{let w=await J.current.load();if(!B)return;let H=$.implementation[W]??$.implementation.render,V=w[H.exportName];if(V===void 0){let L=z$({declaration:$,message:`Export "${H.exportName}" was not a React component.`,phase:"load"});C1(L,L),J.current.onDiagnostic?.(L),G({declaration:$,diagnostic:L,implementationRole:W,kind:"failed"});return}G({component:V,declaration:$,implementationRole:W,kind:"ready"})}catch(w){if(!B)return;let H=z$({cause:w,declaration:$,message:"The hosted component could not be loaded.",phase:"load"});C1(H,w),J.current.onDiagnostic?.(H),G({declaration:$,diagnostic:H,implementationRole:W,kind:"failed"})}})(),()=>{B=!1}},[$,W]);let _=z?.declaration===$&&z.implementationRole===W?z:null;if(_===null)return U;if(_.kind==="failed")return M$(S1,{diagnostic:_.diagnostic});let K={children:K4(_.component,Z),declaration:$,...Y===void 0?void 0:{onDiagnostic:Y}};return M$(k1,{...K})};var A$=A(()=>{P1();E1=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),O1=globalThis,I1=O1[E1]??_4(B4);O1[E1]=I1;k1=class k1 extends J4{constructor(Z){super(Z);this.state={error:null}}static getDerivedStateFromError(Z){return{error:Z}}componentDidCatch(Z,$){let U=z$({cause:Z,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(U)}render(){if(this.state.error!==null){let Z=z$({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return M$(S1,{diagnostic:Z})}return this.props.children}};M4=M$("output",{children:"Loading extension…"})});var U$=async(Z,$="render")=>{let U=Z.implementation[$]??Z.implementation.render;if(U.load===void 0)throw Error(`Workflow contribution "${Z.target.fqn}" requires a retained module loader for "${$}".`);return await U.load()};import{infiniteQueryOptions as N4,queryOptions as F4}from"@tanstack/react-query";var b1,c6=(Z)=>{b1=Z},j1=(Z)=>{let{optionsProvider:$,...U}=Z;return U},f1=(Z)=>["workflow-field-options",j1(Z)],y1=(Z,$)=>{let U=Z.optionsProvider??b1;return U===void 0?Promise.resolve({options:[]}):U(j1(Z),$.signal)},G$=(Z)=>F4({queryFn:async($)=>await y1(Z,$),queryKey:f1(Z)}),r6=(Z)=>N4({getNextPageParam:($)=>$.nextCursor,initialPageParam:null,queryFn:async({pageParam:$,signal:U})=>await y1({...Z,cursor:$},{signal:U}),queryKey:f1({...Z,cursor:null})});var m$=()=>{};import{Combobox as L4,Label as R4}from"@collective-intelligence/ui-react/ui";import{useQuery as D4}from"@tanstack/react-query";import{jsx as h1,jsxs as P4}from"react/jsx-runtime";var T4=(Z)=>{if(Z?.kind==="literal")return Z.text;return Z?.kind==="translation"?Z.default:void 0},g1=({context:Z})=>{let{remoteOptions:$}=Z,U={catalogTemplateId:$?.catalogTemplateId??"",dependencies:$?.dependencies??{},limit:50,organizationId:$?.organizationId??""},W=$?.config===void 0?G$(U):G$({...U,config:$.config}),X=(()=>{if($?.optionsProvider===void 0)return W;if($.config===void 0)return G$({...U,optionsProvider:$.optionsProvider});return G$({...U,config:$.config,optionsProvider:$.optionsProvider})})(),Y=D4({...X,enabled:Boolean($)}),z=Y.data?.options??Z.options,G=T4(Z.field.placeholder);return P4("div",{className:"space-y-2",children:[h1(R4,{htmlFor:`workflow-field-${Z.field.key}`,children:Z.field.label.kind==="literal"?Z.field.label.text:Z.field.label.default}),h1(L4,{className:"w-full",disabled:Z.readOnly||Boolean($&&Y.isPending),emptyMessage:"No options are available.",id:`workflow-field-${Z.field.key}`,modal:!0,onChange:(J)=>Z.onValueChange(J),options:z.map((J)=>({label:J.label,value:String(J.value)})),placeholder:G??"Select an option",searchPlaceholder:"Search options...",value:Z.value===null||!Q(Z.value)&&!k(Z.value)?"":String(Z.value),width:"100%"})]})};var m1=A(()=>{m$()});var d;var v$=A(()=>{d={field:"Field",unavailableConfiguration:(Z)=>`${Z} has configuration that this Dashboard cannot edit. Its saved configuration is preserved.`,unavailableControl:(Z,$)=>`${Z} uses an unavailable ${$} control. Its saved value is preserved.`}});import{Alert as C4,AlertDescription as E4}from"@collective-intelligence/ui-react/ui";import{jsx as f,jsxs as p$,Fragment as I4}from"react/jsx-runtime";var x$=({diagnostics:Z})=>f(I4,{children:Z.map(($)=>f(C4,{variant:"destructive",children:f(E4,{children:$.message})},`${$.code}:${$.message}`))}),O4=(Z)=>{if(Q(Z))return Z;if(Z!==null&&D(Z)&&"text"in Z){let{text:$}=Z;return Q($)?$:d.field}if(Z!==null&&D(Z)&&"default"in Z){let{default:$}=Z;return Q($)?$:d.field}return d.field},d$=({context:Z})=>{let $={widget:Z.field.widget};if(Z.field.fieldFqn!==void 0&&Z.field.fieldFqn!==null)$.fqn=Z.field.fieldFqn;if(Z.field.fieldVersion!==void 0&&Z.field.fieldVersion!==null)$.version=Z.field.fieldVersion;let U=J$($),W=Z.mode??(Z.readOnly?"read_only":"value"),X={...Z,readOnly:W==="read_only"||Z.readOnly};if(U.kind==="resolved"&&U.source==="fallback"&&Z.field.optionSource?.kind==="remote")return p$("div",{className:"space-y-2",children:[f(g1,{context:X}),f(x$,{diagnostics:Z.diagnostics})]});if(U.kind==="resolved")return p$("div",{className:"space-y-2",children:[f(Z$,{componentProps:X,declaration:U.entry.declaration,load:()=>U$(U.entry.declaration)}),v1(U.entry).handlesDiagnostics===!0?null:f(x$,{diagnostics:Z.diagnostics})]});return p$("div",{className:"space-y-2",children:[f("div",{className:"rounded-lg border border-dashed border-border px-3 py-2 text-sm text-muted-foreground",children:d.unavailableControl(O4(Z.field.label),Z.field.fieldFqn??Z.field.widget)}),f(x$,{diagnostics:Z.diagnostics})]})};var u$=A(()=>{A$();_$();m1();v$()});var x1;var p1=A(()=>{x1={noEditableFields:"This template does not expose editable fields."}});import{jsx as c$,jsxs as u1}from"react/jsx-runtime";var S4=function($){if(Q($))return $;if(D($)&&!Array.isArray($)&&"en"in $){let U=$.en;return Q(U)?U:""}return""},d1=function($){return[...$].sort((U,W)=>(U.order??0)-(W.order??0))},k4=function($){return d1($).map((U)=>({...U,fields:d1(U.fields??[])}))},u=({context:Z})=>{let $=k4("editor"in Z.template.contract?Z.template.contract.editor?.form?.sections??[]:[]);return u1("div",{className:"space-y-5",children:[$.map((U)=>u1("section",{className:"space-y-3 rounded-xl border border-border p-4",children:[c$("h3",{className:"text-sm font-semibold text-foreground",children:S4(U.label)}),(U.fields??[]).filter((W)=>Z.isFieldVisible?.(W)??!0).map((W)=>Z.getFieldContext?c$(d$,{context:Z.getFieldContext(W)},W.key):null)]},U.key)),$.length?null:c$("p",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:x1.noEditableFields})]})};var N$=A(()=>{u$();p1()});var b4,c1=(Z)=>b4.has(Z),c=(Z)=>I(Z)?Z:void 0,L$=(Z)=>{let $=Z.anyOf??Z.oneOf;return Array.isArray($)?$.flatMap((U)=>{let W=c(U);return W===void 0?[]:L$(W)}):[Z]},r1=(Z)=>{if(Z===null)return"null";if(Array.isArray(Z))return"array";if(I(Z))return"object";if(Q(Z))return"string";if(k(Z))return Number.isInteger(Z)?"integer":"number";return"boolean"},o1=(Z)=>{let{type:$}=Z;if(Q($))return c1($)?new Set([$]):void 0;if(Array.isArray($))return new Set($.filter(Q).filter(c1));if(Z.const!==void 0)return new Set([r1(Z.const)]);if(Array.isArray(Z.enum))return new Set(Z.enum.map(r1));if(Z.properties!==void 0)return new Set(["object"]);if(Z.items!==void 0)return new Set(["array"]);return},y=(Z)=>{let $=new Set;for(let U of L$(Z)){let W=o1(U);if(W===void 0)return;for(let X of W)$.add(X)}return $},s1=(Z)=>{let[$]=Z;if($===void 0)return{};return Z.length===1?$:{anyOf:[...Z]}},K$=(Z,$)=>L$(Z).filter((U)=>{let W=o1(U);return W===void 0||W.has($)}),F$=(Z)=>s1(K$(Z,"array").map(($)=>c($.items)??{})),j4=(Z,$)=>Z.has($)||$==="integer"&&Z.has("number"),f4=(Z,$)=>{let[U]=K$(Z,"object"),W=c(U?.properties);if(W===void 0)return!0;let X=Array.isArray(U?.required)?U.required.filter(Q):[];return K$($,"object").every((Y)=>{let z=c(Y.properties);if(z===void 0)return!0;return X.every((G)=>(G in z))&&Object.entries(W).every(([G,J])=>{let _=c(z[G]),K=c(J);return _===void 0||K===void 0?!0:r(K,_)})})},r=(Z,$)=>{let U=y(Z),W=y($);if(U===void 0||W===void 0)return!0;for(let X of W)if(!j4(U,X))return!1;if(W.has("array")&&!r(F$(Z),F$($)))return!1;return!W.has("object")||f4(Z,$)},y4=(Z)=>s1(L$(Z).flatMap(($)=>{let{type:U}=$;if(U==="null")return[];if(Array.isArray(U)){let W=U.filter((X)=>X!=="null");return W.length===0?[]:[{...$,type:W}]}return[$]})),h4=(Z)=>{let $=y(Z);if($?.has("string")===!0)return'""';if($?.has("number")===!0||$?.has("integer")===!0)return"0";if($?.has("boolean")===!0)return"false";return},g4=(Z)=>{let $=K$(Z,"array").every((W)=>k(W.minItems)&&W.minItems>=1),U=F$(Z);return $||y(U)?.has("null")===!0?U:{anyOf:[U,{type:"null"}]}},r$=(Z,$)=>{if($===void 0||y($)===void 0||y(Z)===void 0)return{status:"unknown"};if(r($,Z))return{status:"compatible"};let U=h4($),W=(J,_)=>{if(r($,J))return _;return U!==void 0&&r($,y4(J))?[..._,`coalesce(${U})`]:void 0},X=W(Z,[]),Y=y(Z),z=X===void 0&&Y?.has("array")===!0?W(g4(Z),["first"]):void 0,G=X??z;return G===void 0||G.length===0?{status:"incompatible"}:{pipes:G.map((J)=>`| ${J}`).join(" "),status:"fixable"}},l1=4,m4=(Z)=>{let $=K$(Z,"object").flatMap((W)=>Object.keys(c(W.properties)??{}));if($.length===0)return"object";return`{${$.slice(0,l1).join(", ")}${$.length>l1?", …":""}}`},l$=(Z)=>{let $=y(Z);if($===void 0)return"any";return["string","integer","number","boolean","object","array","null"].filter((W)=>$.has(W)).map((W)=>{if(W==="array"){let X=F$(Z),Y=y(X);return`array of ${Y?.size===1&&Y.has("object")?m4(X):l$(X)}`}return W}).join(" | ")};var R$=A(()=>{b4=new Set(["array","boolean","integer","null","number","object","string"])});var A7=function($){let U=$.mode==="fixed"?$.value:null;return{expression:$.mode==="expression"?$.source:"",fixed:U,mode:$.mode}},N7=function($){return $.mode==="fixed"?{mode:"fixed",value:$.fixed}:{languageVersion:1,mode:"expression",source:$.expression}},i1=function($,U){return{availability:U.availability,id:U.id,label:U.label,path:U.path??[],schema:U.schema,sourceId:$}},v4=(Z,$)=>Z.length===$.length&&Z.every((U,W)=>U===$[W]),x4=function($,U,W){let X=W.path??[];if(X.length===0){$.children.push(i1(U,W));return}let Y=$;for(let[z,G]of X.entries()){let J=X.slice(0,z+1),_=Y.children.findIndex((N)=>v4(N.path,J)),K=Y.children[_];if(z===X.length-1){if(!K)Y.children.push(i1(U,W));return}if(K&&"children"in K){Y=K;continue}let B=K?{...K,children:[],conditional:K.availability==="conditional",selectors:[]}:{availability:W.availability,children:[],conditional:W.availability==="conditional",id:`${U}:${J.join(".")}`,label:String(G),path:J,schema:{},selectors:[],sourceId:U};if(K)Y.children[_]=B;else Y.children.push(B);Y=B}},p4=function Z($){return $.flatMap((U)=>[U,...Z(U.children??[])])},d4=function($){let U=$.availability??"guaranteed",W={availability:U,children:[],conditional:U==="conditional",id:$.id,label:$.label,path:[],schema:$.schema,selectors:($.selectors??[]).map((X)=>X.kind),sourceId:$.id};if($.nodeKey!==void 0&&$.nodeKey!==null)W.nodeKey=$.nodeKey;for(let X of p4($.fields??[]))x4(W,$.id,X);return W},u4=function($){return{compatibility:$.targetCompatibility??[],language:$.languageManifest,sources:($.availableSources??[]).map(d4)}},c4=function($){return{canonicalSource:$.canonicalSource??null,diagnostics:($.diagnostics??[]).map((U)=>({actualSchema:U.actualSchema,code:U.code,expectedSchema:U.expectedSchema,message:U.message,remediation:U.remediation,severity:U.severity,span:U.span})),inferredSchema:$.inferredSchema,references:$.references??[]}},F7=function($,U){return r(U,$)},n1=function($,U,W){let X=Math.max(0,Math.min(U,$.length));return{cursor:X+W.length,source:`${$.slice(0,X)}${W}${$.slice(X)}`}};var D$=A(()=>{R$()});var r4=function($){if($.id==="trigger")return"trigger";if($.id==="workflow_input")return"input";let[,U]=$.id.split(":port:");return`nodes[${JSON.stringify($.nodeKey??$.label)}]${U?`.${U}`:""}`},l4=function($){return $.map((U)=>(()=>{if(k(U))return`[${U}]`;if(/^[A-Za-z_$][\w$]*$/u.test(U))return`.${U}`;return`[${JSON.stringify(U)}]`})()).join("")},o4=function($){if($.id==="trigger")return{id:"trigger",label:"Trigger data"};if($.id==="workflow_input")return{id:"workflow_input",label:"Workflow input"};return{id:$.id,label:$.label}},s4=function Z($){let{source:U}=$;return $.nodes.flatMap((W)=>{let X=`${U.id}:${W.id}`,Y=[...$.parentLabels,W.label],z="children"in W?W.children:[],G=`${r4(U)}${l4(W.path)}`;return[{conditional:W.availability==="conditional",depth:$.depth,expandable:z.length>0,group:$.group,id:X,insertion:`{{ ${G} }}`,label:`${U.label} · ${Y.join(".")}`,name:W.label,parentId:$.parentId,pathLabel:Y.join("."),reference:G,schema:W.schema,selectors:U.selectors},...Z({depth:$.depth+1,group:$.group,nodes:z,parentId:X,parentLabels:Y,source:U})]})},i4=function($){let U=$.children.length?$.children:[{availability:$.availability,id:$.id,label:"Output",path:[],schema:$.schema,sourceId:$.id}];return s4({depth:0,group:o4($),nodes:U,parentId:null,parentLabels:[],source:$})},o$=function($){return $.sources.flatMap((U)=>i4(U))},l=function($){return l$($)};var T$=A(()=>{R$()});import{jsx as P,jsxs as t1,Fragment as n4}from"react/jsx-runtime";var O=({title:Z,values:$})=>t1("section",{"aria-label":Z,children:[P("h3",{className:"font-medium",children:Z}),$.length>0?P("ul",{className:"mt-1 list-disc pl-5 font-mono text-xs",children:$.map((U,W)=>P("li",{children:U},`${U}-${W}`))}):P("p",{className:"text-muted-foreground",children:"No entries in this language manifest."})]}),a1=function($){return $.map((U)=>U.example??U.name)},s$=({manifest:Z})=>t1(n4,{children:[P(O,{title:"Syntax overview",values:[Z.grammar]}),P(O,{title:"Interpolation",values:[`Whole value preserves type: ${Z.interpolation.wholeValuePreservesType}`,`Mixed text returns: ${Z.interpolation.mixedTextReturns}`]}),P(O,{title:"References",values:[Z.grammar]}),P(O,{title:"Selectors",values:Z.selectors.map(({kind:$})=>$)}),P(O,{title:"Unavailable-value policies",values:Z.availabilityPolicies}),P(O,{title:"Operators",values:Z.operators}),P(O,{title:"Functions",values:a1(Z.functions)}),P(O,{title:"Casts and pipes",values:Z.pipes}),P(O,{title:"Strings",values:Z.pipes}),P(O,{title:"Collections",values:Z.pipes}),P(O,{title:"Objects",values:Z.pipes}),P(O,{title:"Dates",values:Z.pipes}),P(O,{title:"If conditions",values:Z.ifExamples}),P(O,{title:"Comparators",values:a1(Z.comparators)})]});var i$=()=>{};var o;var e1=A(()=>{o={applyPipes:(Z)=>`Append ${Z}`,expectedType:"Field expects",incompatibleType:"Incompatible type",insertWithPipes:"Insert with the pipes that make this value fit the field",validationFailed:(Z)=>`We couldn't validate this expression: ${Z}`,validationUnavailable:"We couldn't validate this expression right now. Check its syntax and referenced values, then try again."}});import{ChevronRight as a4}from"@collective-intelligence/ui-react/icons";import{Badge as t4,Button as i,Input as $0,Popover as e4,PopoverAnchor as $5,PopoverContent as Z5,Textarea as U5}from"@collective-intelligence/ui-react/ui";import{Fragment as W5,useEffect as X5,useRef as Y5,useState as s}from"react";import{jsx as M,jsxs as C}from"react/jsx-runtime";var Z0=(Z)=>Z!==null&&D(Z)&&!Array.isArray(Z),h=(Z)=>Z!==null&&Z!==void 0&&Z!=="",z5=function Z($){if(Q($))return $;if(Array.isArray($)){let U=$.map(Z).filter((W)=>h(W));return U.length?U.join("; "):void 0}if(!Z0($))return;if(Q($.msg))return $.msg;if(Q($.message))return $.message;if(Q($.detail))return $.detail;return},G5=function($){if($ instanceof Error&&h($.message))return $.message;if(!b($))return;if(!Z0($))return;return[$.detail,$.body,$.error,$.message].map(z5).find((U)=>h(U))},J5=function($){let U=G5($);return h(U)?o.validationFailed(U):o.validationUnavailable},U0,_5,W0=function($,U){return _5.flatMap((W)=>$.filter((X)=>U(X)===W))},K5=function($){let U=new Map;for(let Y of $){let z=U.get(Y.option.parentId)??[];z.push(Y),U.set(Y.option.parentId,z)}let W=new Map,X=(Y)=>{let z=W.get(Y.option.id);if(z!==void 0)return z;let G=Math.min(U0[Y.compatibility.status],...(U.get(Y.option.id)??[]).map(X));return W.set(Y.option.id,G),G};for(let[Y,z]of U)U.set(Y,W0(z,X));return U},X0=({entry:Z,expanded:$,onInsert:U,onToggle:W})=>{let{compatibility:X,option:Y}=Z,z=W===void 0,G=X.status==="incompatible";return C("div",{className:"mt-1 flex items-start gap-1",style:{paddingInlineStart:z?0:`${Y.depth*1.25}rem`},children:[!z&&Y.expandable?M(i,{"aria-expanded":$,"aria-label":`${$?"Collapse":"Expand"} ${Y.label}`,className:"mt-1 size-7 shrink-0",onClick:W,size:"icon",type:"button",variant:"ghost",children:M(a4,{"aria-hidden":!0,className:$?"size-4 rotate-90":"size-4"})}):M("span",{"aria-hidden":!0,className:"size-7 shrink-0"}),C(i,{"aria-label":`Insert ${Y.label}`,className:`block h-auto min-w-0 flex-1 whitespace-normal px-2 py-1.5 text-left ${G?"opacity-60":""}`,onClick:()=>{U(Y.insertion)},type:"button",variant:"ghost",children:[M("span",{className:"block text-sm",children:z?Y.pathLabel:Y.name}),C("span",{className:"flex flex-wrap items-center gap-1.5 font-mono text-xs text-muted-foreground",children:[l(Y.schema),G?M(t4,{className:"font-sans",variant:"outline",children:o.incompatibleType}):null]})]}),X.status==="fixable"?M(i,{"aria-label":`Insert ${Y.label} with ${X.pipes}`,className:"mt-1 h-auto shrink-0 px-1.5 py-0.5 font-mono text-xs",onClick:()=>{U(`{{ ${Y.reference} ${X.pipes} }}`)},size:"sm",title:o.insertWithPipes,type:"button",variant:"outline",children:X.pipes}):null]})},Y0=({tree:Z,expanded:$,onInsert:U,onToggle:W,parentId:X})=>(Z.get(X)??[]).map((Y)=>{let z=$.has(Y.option.id);return C(W5,{children:[M(X0,{entry:Y,expanded:z,onInsert:U,onToggle:()=>{W(Y.option.id)}}),z?M(Y0,{expanded:$,onInsert:U,onToggle:W,parentId:Y.option.id,tree:Z}):null]},Y.option.id)}),V5=({environment:Z,onInsert:$,onQueryChange:U,options:W,query:X,targetSchema:Y})=>{let[z,G]=s(new Set),J=new Map(W.map(({group:V})=>[V.id,V])),_=["trigger","workflow_input"],K=[..._.flatMap((V)=>J.get(V)??[]),...[...J.values()].filter(({id:V})=>!_.includes(V))],B=W.map((V)=>({compatibility:r$(V.schema,Y),option:V})),N=X.trim()!=="",w=B.filter(({option:V})=>[V.label,V.insertion,l(V.schema)].join(" ").toLowerCase().includes(X.trim().toLowerCase())),H=(V)=>{G((L)=>{let R=new Set(L);if(R.has(V))R.delete(V);else R.add(V);return R})};return C("div",{className:"grid h-96 max-h-[calc(100dvh-3rem)] grid-cols-[minmax(0,1fr)_14rem] overflow-hidden",children:[C("div",{className:"min-h-0 touch-pan-y overflow-y-auto overscroll-y-contain border-r p-2",onWheel:(V)=>{V.stopPropagation()},children:[M($0,{"aria-label":"Search expression suggestions",onChange:(V)=>{U(V.target.value)},placeholder:"Search available values",value:X}),K.map((V)=>{let L=(N?w:B).filter(({option:R})=>R.group.id===V.id);if(L.length===0)return null;return C("section",{"aria-label":V.label,className:"mt-3",children:[M("h3",{className:"px-2 text-xs font-semibold text-muted-foreground",children:V.label}),N?W0(L,(R)=>U0[R.compatibility.status]).map((R)=>M(X0,{entry:R,expanded:!1,onInsert:$},R.option.id)):M(Y0,{expanded:z,onInsert:$,onToggle:H,parentId:null,tree:K5(L)})]},V.id)}),(N?w:B).length===0?M("p",{className:"p-3 text-sm text-muted-foreground",children:"No matching workflow sources."}):null]}),C("aside",{className:"space-y-3 p-3","aria-label":"Expression helper",children:[Y===void 0?null:C("p",{className:"text-xs",children:[C("span",{className:"text-muted-foreground",children:[o.expectedType," "]}),M("span",{className:"font-mono",children:l(Y)})]}),M("p",{className:"text-xs text-muted-foreground",children:"Select a typed source. Expand an object to pick one of its fields, or insert the whole object."}),M("h3",{className:"text-xs font-semibold",children:"Pipes"}),Z.language.pipes.map((V)=>C(i,{className:"mr-1 mb-1 h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{$(` | ${V}`)},size:"sm",type:"button",variant:"outline",children:["| ",V]},V))]})]})},Q5,w5=function($,U){let W=Q5.exec($)?.groups?.body;return W===void 0||W.includes("{{")?void 0:`{{ ${W.trim()} ${U} }}`},H5=({diagnostic:Z,onApplyFix:$,source:U,targetSchema:W})=>{let X=Z.expectedSchema??W,Y=Z.code==="incompatible_expression_type"&&Z.actualSchema!==null?r$(Z.actualSchema,X??void 0):void 0,z=Y?.status==="fixable"?w5(U,Y.pipes):void 0;return C("div",{className:"space-y-1 text-sm text-destructive",role:"alert",children:[C("p",{children:[Z.message," (characters ",Z.span.start,"–",Z.span.end,")"]}),h(Z.remediation)?M("p",{className:"text-xs text-muted-foreground",children:Z.remediation}):null,Y?.status==="fixable"&&z!==void 0&&$!==void 0?M(i,{className:"h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{$(z)},size:"sm",type:"button",variant:"outline",children:o.applyPipes(Y.pipes)}):null]})},n$=({describedBy:Z,environment:$,inputLabel:U="Expression",source:W,onChange:X,validate:Y,multiline:z=!1,readOnly:G=!1,targetSchema:J})=>{let _=Y5(null),K=(q)=>{_.current=q},[B,N]=s(W.length),[w,H]=s(!1),[V,L]=s("suggestions"),[R,n]=s(""),[b$,j$]=s(null),[p,a]=s(null),X$=Y===void 0||W===""?null:b$,T=Y===void 0||W===""?null:p,S=[Z,h(T)?"expression-validation":void 0].filter(Boolean).join(" ")||void 0;X5(()=>{let q=new AbortController;if(!Y||W==="");else{let f$=async()=>{try{let y$=await Y(W,q.signal);if(!q.signal.aborted)j$(y$),a(null)}catch(y$){if(!q.signal.aborted)a(J5(y$))}},e=window.setTimeout(()=>{f$()},300);return()=>{q.abort(),window.clearTimeout(e)}}return()=>{q.abort()}},[W,Y]);let m=o$($),t=(q)=>{let f$=_.current?.selectionStart??B,e=n1(W,f$,q);N(e.cursor),X(e.source),queueMicrotask(()=>{_.current?.focus(),_.current?.setSelectionRange(e.cursor,e.cursor)})};return C("div",{className:"space-y-2",children:[C(e4,{onOpenChange:(q)=>{if(H(q),!q)n(""),L("suggestions")},open:w,children:[M($5,{asChild:!0,children:M("div",{children:(()=>{if(z)return M(U5,{"aria-describedby":S,"aria-invalid":h(T)||(X$?.diagnostics.length??0)>0,"aria-label":U,className:"min-h-24 text-sm",disabled:G,onChange:(q)=>{X(q.target.value),N(q.currentTarget.selectionStart??W.length)},onFocus:()=>{H(!0)},onKeyDown:(q)=>{if(q.key==="Escape")H(!1)},onSelect:(q)=>{N(q.currentTarget.selectionStart??W.length)},placeholder:"Choose a source or start typing",ref:K,value:W});return M($0,{"aria-describedby":S,"aria-invalid":h(T)||(X$?.diagnostics.length??0)>0,"aria-label":U,className:"text-sm",disabled:G,onChange:(q)=>{X(q.target.value),N(q.currentTarget.selectionStart??W.length)},onFocus:()=>{H(!0)},onKeyDown:(q)=>{if(q.key==="Escape")H(!1)},onSelect:(q)=>{N(q.currentTarget.selectionStart??W.length)},placeholder:"Choose a source or start typing",ref:K,value:W})})()})}),C(Z5,{align:"start",className:"w-[min(48rem,calc(100vw-3rem))] p-0",onOpenAutoFocus:(q)=>{q.preventDefault()},children:[C("div",{className:"flex border-b p-1",role:"tablist",children:[M(i,{"aria-selected":V==="suggestions",onClick:()=>{L("suggestions")},role:"tab",size:"sm",type:"button",variant:V==="suggestions"?"secondary":"ghost",children:"Suggestions"}),M(i,{"aria-selected":V==="syntax",onClick:()=>{L("syntax")},role:"tab",size:"sm",type:"button",variant:V==="syntax"?"secondary":"ghost",children:"Syntax reference"})]}),V==="suggestions"?M(V5,{environment:$,onInsert:t,onQueryChange:n,options:m,query:R,targetSchema:J}):M("div",{className:"max-h-96 touch-pan-y overflow-y-auto overscroll-y-contain p-4 text-sm",onWheel:(q)=>{q.stopPropagation()},children:M(s$,{manifest:$.language})})]})]}),h(T)?M("p",{id:"expression-validation",role:"alert",children:T}):null,X$?.diagnostics.map((q)=>M(H5,{diagnostic:q,onApplyFix:G?void 0:X,source:W,targetSchema:J},`${q.code}-${q.span.start}`))]})};var z0=A(()=>{D$();R$();T$();i$();e1();U0={compatible:0,fixable:1,incompatible:3,unknown:2},_5=[0,1,2,3],Q5=/^\s*\{\{(?<body>[\s\S]*?)\}\}\s*$/u});var P$=A(()=>{z0();i$();T$()});var g;var G0=A(()=>{g={expression:"Expression",expressionHelp:"Calculates a value from the data available when this step runs.",fixed:"Fixed",fixedHelp:"Uses the saved value as written.",modesHelp:"Fixed uses the saved value as written. Expression calculates a value from the data available when the step runs."}});import{Alert as q5,AlertDescription as B5,Label as M5,ToggleGroup as A5,ToggleGroupItem as J0}from"@collective-intelligence/ui-react/ui";import{useId as N5,useState as _0}from"react";import{jsx as E,jsxs as C$}from"react/jsx-runtime";var F5,K0=function($){return $.mode==="expression"?{expression:$.source,fixed:null,mode:"expression"}:{expression:"",fixed:$.value,mode:"fixed"}},L5=({mode:Z})=>E("span",{className:"shrink-0 text-xs text-muted-foreground",title:Z==="expression"?g.expressionHelp:g.fixedHelp,children:Z==="expression"?g.expression:g.fixed}),V$=({allowExpression:Z=!1,allowFixed:$=!0,controlId:U,diagnostics:W=F5,expressionEditor:X,expressionMultiline:Y=!1,help:z,label:G,onValueChange:J,readOnly:_=!1,renderExpression:K,renderFixed:B,required:N=!1,sensitive:w=!1,value:H})=>{let V=N5(),[L,R]=_0(()=>K0(H)),n=JSON.stringify(H),[b$,j$]=_0(n),p=U===void 0?void 0:`${U}-label`;if(n!==b$)j$(n),R(K0(H));let a=(()=>{if(Z&&!$)return"expression";if($&&!Z)return"fixed";return L.mode})(),X$=_;return C$("section",{className:"space-y-2",children:[C$("div",{className:"flex items-center justify-between gap-3",children:[E("div",{className:"min-w-0",children:C$("div",{className:"flex items-center gap-1",children:[E(M5,{htmlFor:U,id:p,children:G}),N?E("span",{"aria-label":"Required",children:"*"}):null,w?E("span",{className:"ml-1 text-xs text-muted-foreground",children:"Sensitive"}):null]})}),Z&&_?E(L5,{mode:a}):null,Z&&$&&!_?E("div",{"aria-label":`${G} mode controls`,className:"flex shrink-0 items-center gap-1",children:C$(A5,{"aria-label":`${G} mode`,className:"gap-0",disabled:X$,onValueChange:(T)=>{if(T==="fixed"||T==="expression")R((S)=>({...S,mode:T}))},size:"sm",type:"single",value:a,variant:"outline",children:[E(J0,{className:"h-7 px-4 text-xs",title:g.fixedHelp,value:"fixed",children:g.fixed}),E(J0,{className:"h-7 px-4 text-xs",title:g.expressionHelp,value:"expression",children:g.expression})]})}):null]}),z!==void 0&&z!==""?E("p",{id:V,className:"text-xs leading-relaxed text-muted-foreground",children:z}):null,(()=>{if(a==="expression"){if(X?.environment){let m=X.validate===void 0?{}:{validate:X.validate};return E(n$,{...z?{describedBy:V}:{},environment:X.environment,multiline:Y,onChange:(t)=>{R((q)=>({...q,expression:t})),J({languageVersion:1,mode:"expression",source:t})},readOnly:_,source:L.expression,targetSchema:X.targetSchema,...m})}if(X?.loading===!0)return E("output",{children:"Loading expression editor…"});if(X?.error!==void 0&&X.error!=="")return E("p",{role:"alert",children:X.error});let S={disabled:_,onChange:(m)=>{R((t)=>({...t,expression:m})),J({languageVersion:1,mode:"expression",source:m})},value:L.expression};if(z)S.describedBy=V;if(U!==void 0)S.controlId=`${U}-expression`;if(p!==void 0)S.labelledBy=p;return K?.(S)}let T={disabled:_,onChange:(S)=>{R((m)=>({...m,fixed:S})),J({mode:"fixed",value:S})},value:L.fixed};if(z)T.describedBy=V;if(U!==void 0)T.controlId=U;if(p!==void 0)T.labelledBy=p;return B(T)})(),W.map((T)=>E(q5,{variant:"destructive",children:E(B5,{children:T.message})},`${T.code}:${T.message}`))]})};var a$=A(()=>{P$();G0();F5=[]});var t$=A(()=>{a$()});var e$;var V0=A(()=>{e$={inputBindingsDescription:"Map workflow input field names to literal or dynamic expressions.",inputBindingsTitle:"Input adapter bindings"}});var Q$=function($){return I($)?$:{}},$1=function($){return Q$($)},R5=function($,U,W){let X=$.anyOf;if(!Array.isArray(X))return;let Y=X.filter((_)=>Q$(_).type!=="null");if(Y.length!==1||Y.length===X.length)return;let z=$1(W(Y[0],U)),{type:G}=z,J={...z,...Object.fromEntries(Object.entries($).filter(([_])=>_!=="anyOf"&&_!=="$defs"))};if(Q(G))J.type=[G,"null"];return J},D5=function($){let U=Q$($.$defs),W=(X,Y=new Set)=>{if(Array.isArray(X))return X.map((K)=>W(K,Y));if(!I(X))return X;let z=Q$(X),G=z.$ref,J=Q(G)?G:void 0;if(J!==void 0&&J.startsWith("#/$defs/")){let K=J.slice(8),B=U[K];if(B!==void 0&&!Y.has(K))return W(B,new Set(Y).add(K))}let _=R5(z,Y,W);if(_)return _;return Object.fromEntries(Object.entries(z).filter(([K])=>K!=="$defs").map(([K,B])=>[K,W(B,Y)]))};return $1(W($))},T5=function($){let{type:U}=$;return U==="null"||Array.isArray(U)&&U.includes("null")},P5=function($){let{type:U}=$;if(Q(U))return U==="null"?$:{...$,type:[U,"null"]};if(Array.isArray(U))return U.includes("null")?$:{...$,type:[...U,"null"]};return $},C5=function Z($,U=[],W=!1){return Object.entries(Q$($.properties)).map(([X,Y])=>{let z=$1(Y),G=W?P5(z):z,J=[...U,X],_=Z(z,J,W||T5(z)),K={availability:"guaranteed",id:`trigger:${J.join(".")}`,label:X,path:J,schema:G,sourceId:"trigger"};return _.length?{...K,children:_,conditional:!1,selectors:[]}:K})},Q0=function($){let{triggerInput:U}=$;if(!U)return;let W=D5(U.schema);return{compatibility:[],language:U.languageManifest,sources:[{availability:"guaranteed",children:C5(W),conditional:!1,id:"trigger",label:"Trigger data",path:[],schema:W,selectors:[],sourceId:"trigger"}]}};var w0=()=>{};import{Input as E5,Label as O5}from"@collective-intelligence/ui-react/ui";import{jsx as H$,jsxs as H0}from"react/jsx-runtime";var I5=(Z)=>{if(Z===null||Z===void 0||Q(Z)||k(Z)||Y$(Z))return String(Z??"");return JSON.stringify(Z)??""},w$=function($){return I($)?$:{}},S5=function($,U){return $?.length===U.length&&$.every((W,X)=>W===U[X])},k5=function($,U){if(U==="number"||U==="integer"){let W=Number($);return Number.isFinite(W)?W:$}if(U==="boolean")return $==="true";return $},b5=function($){if(!I($))return{mode:"fixed",value:$??null};if($.mode==="expression"&&Q($.source))return{languageVersion:1,mode:"expression",source:$.source};if($.mode==="fixed"&&b($.value))return{mode:"fixed",value:$.value};return{mode:"fixed",value:$}},q0=({context:Z})=>{let $=w$(Z.workflowContracts?.inputContract.jsonSchema.properties),U=Z.trigger?.inputBindings??{},W=Q0(Z.template.contract);return H0("div",{className:"space-y-5",children:[H$(u,{context:Z}),H0("section",{className:"space-y-2 rounded-xl border border-border p-4",children:[H$(O5,{htmlFor:"workflow-trigger-input-bindings",children:e$.inputBindingsTitle}),H$("p",{className:"text-xs text-muted-foreground",children:e$.inputBindingsDescription}),Object.entries($).map(([X,Y])=>{let z=w$(U[X]),G=b5(z?.value),J=Z.triggerInputExpressionValidator?.(X),_=W===void 0?void 0:{environment:W,targetSchema:w$(Y)};if(_!==void 0&&J!==void 0)_.validate=J;return H$(V$,{allowExpression:!0,..._===void 0?{}:{expressionEditor:_},diagnostics:Z.diagnostics.filter((K)=>S5(K.path,["inputBindings",X])),label:`${X} (${l(w$(Y))})`,readOnly:Z.readOnly,value:G,onValueChange:(K)=>Z.commands.updateTriggerConfiguration?.({inputBindings:{...U,[X]:{overridePolicy:"locked",value:K}}}),renderFixed:({value:K,onChange:B})=>H$(E5,{value:I5(K),onChange:(N)=>{B(k5(N.target.value,w$(Y)?.type))}})},X)})]})]})};var B0=A(()=>{P$();t$();N$();V0();w0()});var P0={};p0(P0,{renderDefaultTriggerDetails:()=>F0,renderDefaultTriggerChart:()=>N0,renderDefaultOutputDetails:()=>T0,renderDefaultOutputChart:()=>D0,renderDefaultInputDetails:()=>R0,renderDefaultInputChart:()=>L0,renderDefaultActionDetails:()=>A0,renderDefaultActionChart:()=>M0});import{jsx as v}from"react/jsx-runtime";var M0=(Z)=>v($$,{context:Z,accent:"slate"}),A0=(Z)=>v(u,{context:Z}),N0=(Z)=>v($$,{context:Z,accent:"violet"}),F0=(Z)=>v(q0,{context:Z}),L0=(Z)=>v($$,{context:Z,accent:"sky"}),R0=(Z)=>v(u,{context:Z}),D0=(Z)=>v($$,{context:Z,accent:"emerald"}),T0=(Z)=>v(u,{context:Z});var Z1=A(()=>{g$();N$();B0()});import{declareFrontendComponent as j5}from"@collective-intelligence/extensions-sdk-frontend";var U1=(Z)=>({exportName:Z,load:()=>Promise.resolve().then(() => (Z1(),P0)),module:import.meta.url}),E$=(Z,$,U)=>j5({implementation:{chart:U1($),details:U1(U),render:U1(U)},metadata:{kind:Z,mode:"default"},target:{fqn:`builtin.core.workflows.nodes.${Z.replace(/_node$/u,"")}`,packageFqn:"builtin.core",role:"workflow_template_default",version:"1.0.0"}}),W1;var X1=A(()=>{W1=[E$("action_node","renderDefaultActionChart","renderDefaultActionDetails"),E$("trigger_node","renderDefaultTriggerChart","renderDefaultTriggerDetails"),E$("input_node","renderDefaultInputChart","renderDefaultInputDetails"),E$("output_node","renderDefaultOutputChart","renderDefaultOutputDetails")]});import{WorkflowTemplateKinds as f5}from"@collective-intelligence/extensions-sdk";var q$=(Z)=>f5.find(($)=>$===Z);var Y1=()=>{};import{createFrontendCatalog as y5,declareFrontendPackage as h5}from"@collective-intelligence/extensions-sdk-frontend";var J1,O$,_1=(Z)=>{let{declaration:{metadata:$}}=Z;if(!I($))return{};let U=Q($.kind)?q$($.kind):void 0,W;if(Q($.mode)){if($.mode==="default")W="default";else if($.mode==="override")W="override"}let X={};if(Q($.fqn))X.fqn=$.fqn;if(Y$($.handlesDiagnostics))X.handlesDiagnostics=$.handlesDiagnostics;if(U!==void 0)X.kind=U;if(W!==void 0)X.mode=W;if(Q($.widget))X.widget=$.widget;return X},I$=(Z)=>{let $=Z?.trim().toLowerCase();return $===void 0||$===""?void 0:$},C0=()=>J1.snapshot().entries,E0=(Z,$,U)=>{let W=I$(Z),X=I$($);if(W===void 0||X===void 0)return;return C0().find((Y)=>Y.target.toLowerCase()===W&&Y.version.toLowerCase()===X&&Y.role===U)},z1=(Z,$,U)=>{let W=I$($);return C0().find((X)=>{let Y=_1(X);return I$(Y[Z])===W&&X.role===U})},O0=(Z)=>{O$=[...O$.filter((W)=>!Z.some((X)=>X.manifest.fqn===W.manifest.fqn)),...Z];let U=J1.activate(O$);if(U.kind==="invalid")throw Error(U.errors.map((W)=>W.message).join("; "));if(U.kind!=="activated")throw Error(`Workflow catalog activation became stale (${U.reason}).`)},G1,g5=()=>{if(O$.some((Z)=>Z.manifest.fqn===G1.manifest.fqn))return;O0([G1])},m5=()=>J1.snapshot(),J$=(Z)=>{let $=Q(Z)?{widget:Z}:Z,U=$.fqn??void 0,W=$.version??void 0,X=E0(U,W,"workflow_field");if(X!==void 0)return{entry:X,kind:"resolved",source:"exact"};if(U!==void 0&&W!==void 0){let G=z1("widget",$.widget??"","workflow_field_fallback");if(G!==void 0&&U.toLowerCase().startsWith("builtin."))return{entry:G,kind:"resolved",source:"fallback"};let J={fqn:U,kind:"unavailable"};if($.widget!==void 0)J.widget=$.widget;return J}let Y=z1("widget",$.widget??"","workflow_field_fallback");if(Y!==void 0)return{entry:Y,kind:"resolved",source:"fallback"};let z={kind:"unavailable"};if($.fqn!==void 0&&$.fqn!==null)z.fqn=$.fqn;if($.widget!==void 0)z.widget=$.widget;return z},K1=(Z)=>{let $=q$(Z.kind);if($===void 0)return{fqn:Z.fqn,kind:"unavailable",templateKind:Z.kind};let U=E0(Z.fqn,Z.version??"1.0.0","workflow_template_override");if(U!==void 0&&_1(U).kind===$)return{entry:U,kind:"resolved",source:"override"};let W=z1("kind",$,"workflow_template_default");if(W!==void 0)return{entry:W,kind:"resolved",source:"default"};return{fqn:Z.fqn,kind:"unavailable",templateKind:Z.kind}},v1;var _$=A(()=>{X1();Y1();Y1();J1=y5(),O$=[],G1=h5({components:W1,manifest:{fqn:"builtin.core",name:"Dashboard Workflow UI",version:"1.0.0"}}),v1=_1});_$();A$();_$();v$();import{jsx as I0}from"react/jsx-runtime";var v5=({context:Z})=>{let $=J$(Z.field);if($.kind==="resolved"&&$.entry.declaration.implementation.configuration!==void 0)return I0(Z$,{componentProps:Z,declaration:$.entry.declaration,implementationRole:"configuration",load:()=>U$($.entry.declaration,"configuration")});return I0("div",{className:"rounded-md border border-dashed border-border p-2 text-xs text-muted-foreground",children:d.unavailableConfiguration(Z.field.label)})};u$();D$();t$();a$();import{Textarea as x5}from"@collective-intelligence/ui-react/ui";import{jsx as S0}from"react/jsx-runtime";import{createElement as d5}from"react";var j8=({help:Z,label:$,onValueChange:U,expressionEditor:W,readOnly:X,renderFixed:Y,resetKey:z,slotId:G,value:J})=>S0("div",{"data-expression-slot":G,children:d5(V$,{allowExpression:!0,...Z===void 0?{}:{help:Z},...W===void 0?{}:{expressionEditor:W},key:`${G}:${z??"current"}`,label:$,onValueChange:U,...X===void 0?{}:{readOnly:X},renderExpression:({describedBy:_,disabled:K,onChange:B,value:N})=>S0(x5,{"aria-describedby":_,"aria-label":`${$} expression`,disabled:K,onChange:(w)=>{B(w.target.value)},placeholder:"{{ input.value }}",value:N}),renderFixed:Y,value:J})}),p5=function($){if(!I($))return!1;if($.mode==="fixed")return b($.value);return $.mode==="expression"&&k($.languageVersion)&&$.languageVersion===1&&Q($.source)},f8=function($){if(p5($))return $;return{mode:"fixed",value:$}};var V1=function($,U){let W=[...$];for(let X=0;X<W.length;X+=1)for(let Y=X+1;Y<W.length;Y+=1){let z=W[X],G=W[Y];if(z!==void 0&&G!==void 0&&U(z,G)>0)W[X]=G,W[Y]=z}return W};var b0=function($){return D($)&&!Array.isArray($)},u5=function Z($){return $.flatMap((U)=>[...U.templates??[],...Z(U.children??[])])},Q1=function($){return $.kind==="field_collection"&&"collection"in $.contract},w1=function($){return`${$.fqn}@${$.version}`},k0=function($){return $.kind==="literal"?$.text:$.default},c5=function($){return $.kind==="field"&&"field"in $.contract},r5=function($,U){if(!$.enabled||$.state!=="available")return!1;return U==="input"?$.contract.field.availableForInput!==!1:$.contract.field.availableForOutput!==!1},l5=function($,U){let W=$.find((X)=>Q1(X)&&w1(X.contract.collection)===U);return W&&Q1(W)?W.contract.collection.weight??0:0},S$=function($){return $!==void 0&&b0($)?$:{}},p8=function($,U){let W=u5($?.categories??[]),X=new Map;for(let z of W){if(!Q1(z))continue;X.set(w1(z.contract.collection),k0(z.label))}let Y=new Map;for(let z of W){if(!c5(z)||!r5(z,U))continue;let G=z.contract.field,J=w1({fqn:G.collectionFqn,version:G.collectionVersion}),_=Y.get(J)??{fields:[],key:J,label:X.get(J)??G.collectionFqn,weight:l5(W,J)};_.fields.push({catalogTemplateId:z.id,collectionKey:J,configSchema:S$(G.configSchema),fqn:G.fqn,label:k0(z.label),schema:S$(G.valueSchema),version:G.version}),Y.set(J,_)}return V1([...Y.values()].map((z)=>({...z,fields:V1(z.fields,(G,J)=>G.label.localeCompare(J.label)||G.fqn.localeCompare(J.fqn))})),(z,G)=>z.weight-G.weight||z.label.localeCompare(G.label)||z.key.localeCompare(G.key))},d8=function($){return{key:$.key,label:$.label,options:$.fields.map((U)=>({fqn:U.fqn,label:U.label,searchTerms:[U.fqn],version:U.version}))}},o5=function($){let U=S$($.$defs),W=(X,Y=new Set)=>{if(Array.isArray(X))return X.map((_)=>W(_,Y));if(X===null||!b0(X))return X;let z=X,G=z.$ref,J=Q(G)?G:void 0;if(J!==void 0&&J.startsWith("#/$defs/")){let _=J.slice(8),K=U[_];if(K!==void 0&&K!==null&&!Y.has(_))return W(K,new Set(Y).add(_))}return Object.fromEntries(Object.entries(z).filter(([_])=>_!=="$defs").map(([_,K])=>[_,W(K,Y)]))};return S$(W($))},u8=function($,U){let{title:W,...X}=o5(U.schema),Y={...X};if(Q($.title))Y.title=$.title;return Y};import{useDebouncedCallback as s5}from"@collective-intelligence/ui-react/hooks";import{Check as i5,ChevronsUpDown as n5}from"@collective-intelligence/ui-react/icons";import{Button as a5,Command as t5,CommandGroup as e5,CommandInput as $6,CommandItem as Z6,CommandList as U6,Popover as W6,PopoverContent as X6,PopoverTrigger as Y6}from"@collective-intelligence/ui-react/ui";import{useMemo as z6,useState as H1}from"react";import{jsx as x,jsxs as B$}from"react/jsx-runtime";var G6=250,q1=function($){return`${$.fqn}@${$.version}`},J6=function($,U){let W=U.trim().toLocaleLowerCase();if(!W)return $;return $.flatMap((X)=>{let Y=X.options.filter((z)=>[z.label,z.fqn,...z.searchTerms??[]].join(" ").toLocaleLowerCase().includes(W));return Y.length?[{...X,options:Y}]:[]})},i8=({collections:Z,value:$,onChange:U,ariaLabel:W="Field type"})=>{let[X,Y]=H1(!1),[z,G]=H1(""),[J,_]=H1(""),K=s5(_,G6),B=Z.flatMap((H)=>H.options).find((H)=>q1(H)===$),N=z6(()=>J6(Z,J),[Z,J]),w=N.some((H)=>H.options.length>0);return B$(W6,{modal:!0,open:X,onOpenChange:(H)=>{if(Y(H),!H)K.cancel(),G(""),_("")},children:[x(Y6,{asChild:!0,children:B$(a5,{type:"button",variant:"outline","aria-label":W,"aria-expanded":X,className:"mt-1 w-full justify-between font-normal",children:[x("span",{className:"truncate",children:B?.label??"Select a field type"}),x(n5,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}),x(X6,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0",children:B$(t5,{shouldFilter:!1,children:[x($6,{placeholder:"Search field types...",value:z,onValueChange:(H)=>{G(H),K(H)}}),B$(U6,{children:[w?null:x("p",{className:"py-6 text-center text-sm",children:"No field type found."}),N.map((H)=>x(e5,{heading:H.label,children:H.options.map((V)=>{let L=q1(V);return B$(Z6,{value:q1(V),onSelect:()=>{U(V),Y(!1)},children:[x(i5,{className:$===L?"mr-2 size-4 opacity-100":"mr-2 size-4 opacity-0"}),V.label]},L)})},H.key))]})]})})]})};g$();N$();X1();Z1();A$();_$();import{jsx as j0,jsxs as K6}from"react/jsx-runtime";var _6=({context:Z})=>{let $=K1(Z.template);if($.kind==="resolved")return j0(Z$,{componentProps:Z,declaration:$.entry.declaration,implementationRole:"details",load:()=>U$($.entry.declaration,"details")});return K6("div",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:["No dashboard editor is available for template kind"," ",j0("code",{children:$.templateKind}),". The workflow draft has not been changed."]})};var B1=(Z)=>Z!==void 0&&Z!==null&&D(Z)&&!Array.isArray(Z),f0=function($,U){return Object.fromEntries(Object.entries($).filter(([W])=>W!==U))},y0=function($){if($==="input_binding")return"inputs";if($==="setting")return"settings";if($==="metadata")return"metadata";return"config"},W$=function($){return B1($)?$:void 0},M1=function($){let U=W$($);if(U===void 0||!("value"in U))return $;return U.mode==="fixed"||U.kind==="literal"?U.value:$},k$=function($,U){let W=$[y0(U.target)];for(let X of U.path){let Y=W$(M1(W));if(Y===void 0)return;W=Y[X]}return M1(W)},V6=function($,U){return k$($,U.binding)},Q6=function Z($,U,W){let[X,...Y]=U;if(X===void 0)return $??{};let z=$??{};if(!Y.length)return{...z,[X]:W};let G=W$(z[X]),J=W$(M1(G));if(G?.mode==="fixed")return{...z,[X]:{...G,value:Z(J,Y,W)}};return{...z,[X]:Z(J,Y,W)}},A1=function($,U){return[$==="input_binding"?"inputBinding":$,...U].map((W)=>encodeURIComponent(String(W))).join("/")},w6=function($,U,W){let X={...W$($?.fieldDisplayValues)},Y=A1(U.binding.target,U.binding.path);if(W)X[Y]=W;else return{...$,fieldDisplayValues:f0(X,Y)};return{...$,fieldDisplayValues:X}},H6=function($,U,W,X){let Y=y0(U.binding.target),z={[Y]:Q6($[Y],U.binding.path,W)};if(X!==void 0)z.metadata=w6(Y==="metadata"?z.metadata:$.metadata,U,X);return z},h0=function($,U,W){let X=$.metadata?.fieldDisplayValues;if(X===void 0||X===null||!B1(X))return;let Y=X[A1(U.binding.target,W)];if(Y===void 0||Y===null||!B1(Y))return;return Q(Y.label)&&"value"in Y?{label:Y.label,value:Y.value}:void 0},q6=function($,U){return h0($,U,U.binding.path)},B6=function($,U,W){return h0($,U,[...U.binding.path,...W])},M6=function($,U,W,X){let Y={...W$($?.fieldDisplayValues)},z=A1(U,W);if(X)Y[z]=X;else return{...$,fieldDisplayValues:f0(Y,z)};return{...$,fieldDisplayValues:Y}},A6=function($,U,W,X){return{metadata:M6($.metadata,U.binding.target,[...U.binding.path,...W],X)}};var N1=function Z($,U){if(Array.isArray($)||Array.isArray(U))return Array.isArray($)&&Array.isArray(U)&&$.length===U.length&&$.every((W,X)=>Z(W,U[X]));if($!==null&&U!==null&&$!==void 0&&U!==void 0&&D($)&&D(U)){let W=Object.keys($);return W.length===Object.keys(U).length&&W.every((X)=>Z($[X],U[X]))}return $===U},g0=function($){return $!==void 0&&$!==null&&$!==""},N6=function($,U){if(!Array.isArray(U)||$===void 0)return!1;return(Array.isArray($)?$:[$]).some((X)=>U.some((Y)=>N1(X,Y)))},F6=function($,U){return($.visibleWhen??[]).every((W)=>{let X=k$(U,W.binding);switch(W.operator){case"equals":return N1(X,W.value);case"not_equals":return!N1(X,W.value);case"is_set":return g0(X);case"is_not_set":return!g0(X);case"in":return N6(X,W.value);default:return!1}})};var L6=function($){if(!$)return"";return $.kind==="literal"?$.text:$.default};D$();P$();T$();m$();export{r6 as workflowFieldOptionsInfinite,G$ as workflowFieldOptions,m5 as workflowCatalogSnapshot,d8 as toFieldTypeCollection,T6 as toDisplayString,N7 as serializeExpressionDraft,l as schemaLabel,u8 as schemaForWorkflowField,K1 as resolveWorkflowTemplate,J$ as resolveWorkflowField,F0 as renderDefaultTriggerDetails,N0 as renderDefaultTriggerChart,T0 as renderDefaultOutputDetails,D0 as renderDefaultOutputChart,R0 as renderDefaultInputDetails,L0 as renderDefaultInputChart,A0 as renderDefaultActionDetails,M0 as renderDefaultActionChart,V6 as readWorkflowFieldValue,B6 as readWorkflowFieldPartDisplayValue,q6 as readWorkflowFieldDisplayValue,k$ as readWorkflowBindingValue,H6 as patchWorkflowFieldValue,A6 as patchWorkflowFieldPartDisplayValue,q$ as parseWorkflowTemplateKind,c4 as normalizeExpressionValidation,u4 as normalizeExpressionEnvironment,F6 as isWorkflowFieldVisible,D6 as isUndefined,Q as isString,F7 as isSchemaCompatible,I as isRecord,D as isObject,k as isNumber,b as isJsonValue,d0 as isFunction,Y$ as isBoolean,n1 as insertExpressionAtCursor,q1 as fieldTypeIdentity,p8 as fieldCollectionsFromCatalog,o$ as expressionSourceOptions,W1 as defaultWorkflowTemplateDeclarations,G1 as dashboardWorkflowPackage,A7 as createExpressionDraft,c6 as configureWorkflowFieldOptionsProvider,L6 as catalogText,f8 as asExpressionSlotValue,O0 as activateWorkflowCatalog,g5 as activateDashboardWorkflowCatalog,_6 as WorkflowTemplateDetails,d$ as WorkflowFieldResolver,V$ as WorkflowFieldFrame,v5 as WorkflowFieldConfigurationResolver,i8 as FieldTypeSelect,s$ as ExpressionSyntaxReference,j8 as ExpressionSlot,n$ as ExpressionEditor,u as CatalogNodeDetailsEditor,$$ as CatalogNodeChartBlock};
1
+ var Mn=Object.defineProperty;var Bn=(o)=>o;function Ln(o,e){this[o]=Bn.bind(null,e)}var _n=(o,e)=>{for(var n in e)Mn(o,n,{get:e[n],enumerable:!0,configurable:!0,set:Ln.bind(e,n)})};var b=(o,e,n)=>()=>{if(o)try{e=o(o=0)}catch(t){n=[t]}if(n)throw n[0];return e};var se=(o)=>Boolean(o)===o,Hn=(o)=>Object.prototype.toString.call(o)==="[object Function]",J=(o)=>Number(o)===o,W=(o)=>o!==null&&Object(o)===o&&!Hn(o),P=(o)=>{let e=Object.prototype.toString.call(o);if(o===null||e==="[object Boolean]"||e==="[object Number]"||e==="[object String]")return!0;if(Array.isArray(o))return o.every(P);return W(o)&&Object.values(o).every(P)},T=(o)=>P(o)&&W(o)&&!Array.isArray(o),p=(o)=>String(o)===o,Si=(o)=>o===void 0,Ei=(o)=>{let e=o;if(p(e))return e;if(se(e)||J(e))return String(e);return""};import{ArrowRight as Kn,CheckCircle2 as Un,Wrench as zn,Zap as Qn}from"@collective-intelligence/ui-react/icons";var vo=function(e){switch(e){case"trigger":case"trigger_node":return{icon:Qn,label:"Trigger",tone:"bg-violet-500/12 text-violet-600 dark:text-violet-400"};case"input_node":return{icon:Kn,label:"Input",tone:"bg-sky-500/12 text-sky-600 dark:text-sky-400"};case"output_node":return{icon:Un,label:"Output",tone:"bg-emerald-500/12 text-emerald-600 dark:text-emerald-400"};default:return{icon:zn,label:"Action",tone:"bg-slate-500/12 text-slate-600 dark:text-slate-400"}}};var Wo=()=>{};import{AlertTriangle as Gn,Plus as Yn}from"@collective-intelligence/ui-react/icons";import{Tooltip as Zn,TooltipContent as Xn,TooltipTrigger as et}from"@collective-intelligence/ui-react/ui";import{Handle as ot,Position as Co,useNodeId as nt,useUpdateNodeInternals as tt}from"@xyflow/react";import{useEffect as rt}from"react";import{jsx as w,jsxs as D,Fragment as lt}from"react/jsx-runtime";var it,Fo=function(e){if(p(e))return e;if(W(e)&&"kind"in e&&"text"in e){let n=e;if(n.kind==="literal"&&p(n.text))return n.text}if(W(e)&&"en"in e){let n=e.en;return p(n)?n:""}return""},st=({issues:o,title:e})=>{let n=`${o.length} ${o.length===1?"issue":"issues"} on ${e}`;return D(Zn,{children:[w(et,{asChild:!0,children:w("button",{type:"button","aria-label":n,className:"nodrag nopan absolute -right-2 -top-2 z-20 flex size-7 items-center justify-center rounded-full border border-[color-mix(in_oklab,var(--warning)_45%,var(--border))] bg-[color-mix(in_oklab,var(--warning)_16%,var(--card))] text-[color-mix(in_oklab,var(--warning)_80%,var(--foreground))] shadow-sm transition hover:bg-[color-mix(in_oklab,var(--warning)_24%,var(--card))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:(t)=>{t.stopPropagation()},onPointerDown:(t)=>{t.stopPropagation()},children:w(Gn,{"aria-hidden":"true",className:"size-4"})})}),D(Xn,{side:"top",sideOffset:6,className:"max-w-72 p-3",children:[w("p",{className:"font-semibold",children:n}),w("ul",{className:"mt-1.5 space-y-1",children:o.map((t)=>w("li",{className:"leading-snug",children:t.message},`${t.code}:${t.message}`))})]})]})},So=({port:o,side:e,index:n=0,count:t=1})=>{let r=e==="left"?Co.Left:Co.Right,i={top:`${(n+1)/(t+1)*100}%`},s=o.maxConnections===null?"unlimited connections":`maximum ${o.maxConnections??1} connections`,a=[...Array.isArray(o.allowedTemplateKinds)?o.allowedTemplateKinds.filter(p):[],...Array.isArray(o.allowedTemplateFqns)?o.allowedTemplateFqns.filter(p):[]],l=`${o.key} — ${o.direction}, ${s}${a.length?`; accepts ${a.join(", ")}`:""}`;return D(lt,{children:[w(ot,{id:o.key,type:o.direction==="input"?"target":"source",position:r,title:l,"aria-label":l,style:i,className:o.direction==="input"?"!h-5 !w-5 !rounded-sm !border-2 !border-background !bg-primary":"!h-5 !w-5 !border-2 !border-background !bg-primary"}),w("span",{style:i,className:`pointer-events-none absolute z-10 -translate-y-full whitespace-nowrap rounded bg-card px-1 text-[10px] text-muted-foreground ${e==="left"?"right-full mr-2":"left-full ml-2"}`,children:o.key})]})},at=({signature:o})=>{let e=nt(),n=tt();return rt(()=>{if(e!==null)n(e)},[e,o,n]),null},oe=({context:o,accent:e})=>{let n=o.ports.filter((f)=>f.direction==="input"),t=o.ports.filter((f)=>f.direction==="output"),r=new Set(o.chart.connectedOutputPortKeys),i=o.chart.fields??[],s=Fo(o.template.label),a=o.chart.title??s,l=o.chart.subtitle??(a===s?void 0:s),d=o.chart.description??Fo(o.template.description),{icon:c}=o.chart.presentation??vo(o.template.kind),x=o.chart.presentation?.tone??it[e],k=o.diagnostics.filter((f)=>f.severity!=="info");return D("div",{className:"relative w-[262px]",children:[k.length?w(st,{issues:k,title:a}):null,D("button",{type:"button","aria-label":`Edit ${a}`,style:{minHeight:(Math.max(n.length,t.length)+1)*28},onDoubleClick:()=>{o.chart.onOpenDetails()},className:`workflow-node-drag group relative z-10 w-full cursor-pointer rounded-2xl border bg-card p-4 text-left shadow-[0_2px_10px_-4px_rgba(30,29,26,0.12)] transition-[border-color,box-shadow] hover:shadow-[0_8px_24px_-14px_rgba(30,29,26,0.24)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${x}`,children:[o.ports.length>0?w(at,{signature:o.ports.map((f)=>`${f.direction}:${f.key}`).join("|")}):null,n.map((f,m)=>w(So,{port:f,side:"left",index:m,count:n.length},f.key)),t.map((f,m)=>w(So,{port:f,side:"right",index:m,count:t.length},f.key)),D("div",{className:"flex items-start gap-3",children:[w("div",{className:`flex size-10 shrink-0 items-center justify-center rounded-xl ${x}`,children:w(c,{className:"size-5"})}),D("div",{className:"min-w-0",children:[w("div",{className:"truncate text-sm font-semibold text-foreground",children:a}),p(l)&&l.length>0?w("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:l}):null]})]}),(()=>{if(p(d)&&d.length>0)return D("div",{className:"mt-3 space-y-1 border-t border-border/70 pt-3",children:[p(d)&&d.length>0?w("p",{className:"text-xs leading-snug text-muted-foreground",children:d}):null,p(o.chart.summary)&&o.chart.summary.length>0?w("p",{className:"text-xs text-muted-foreground",children:o.chart.summary}):null]});return null})(),i.length?w("div",{className:"mt-3 space-y-1.5 border-t border-border/70 pt-3",children:i.slice(0,4).map((f)=>w("div",{className:"truncate rounded-md bg-muted px-2.5 py-1.5 font-mono text-[11px] text-foreground",children:f},f))}):null]}),(()=>{if(t.length)return w("div",{className:`absolute left-full top-0 h-full ${t.length===1?"w-24":"w-36"}`,children:t.map((f,m)=>r.has(f.key)?null:D("div",{className:"absolute left-0 right-0 flex -translate-y-1/2 items-center gap-1.5",style:{top:`${(m+1)/(t.length+1)*100}%`},children:[w("div",{className:"h-px min-w-8 flex-1 bg-foreground/40"}),r.has(f.key)?null:w("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center rounded-md border border-border-strong bg-card text-muted-foreground shadow-sm transition hover:border-primary hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40","aria-label":`Add after ${a} ${f.key}`,title:`Add after ${f.key}`,onClick:(u)=>{u.stopPropagation(),o.chart.onAddFromPort?.(f)},children:w(Yn,{className:"size-3.5"})})]},f.key))});return null})()]})};var je=b(()=>{Wo();it={emerald:"bg-[color-mix(in_oklab,var(--chart-2)_12%,var(--card))] text-emerald-600 border-emerald-500/30",sky:"bg-[color-mix(in_oklab,var(--chart-4)_12%,var(--card))] text-sky-600 border-sky-500/30",slate:"bg-[color-mix(in_oklab,var(--bg-surface-alt)_55%,var(--card))] text-slate-600 border-slate-500/30",violet:"bg-[color-mix(in_oklab,var(--chart-5)_12%,var(--card))] text-violet-600 border-violet-500/30"}});var dt=(o)=>o.trim().replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase(),ct=(o)=>{if(typeof o.module==="string")return{exportName:o.exportName,module:o.module};return{exportName:o.exportName,module:o.module.pathname.split("/").pop()??"unknown-module"}},ae=(o)=>{let{declaration:e,phase:n,message:t,cause:r,sourceMap:i}=o,{target:s}=e,a=["FE",n.toUpperCase(),s.packageFqn,s.fqn,s.version,s.role].map(dt).join("-");return{componentFqn:s.fqn,diagnosticId:a,message:t,packageFqn:s.packageFqn,phase:n,role:s.role,source:ct(e.implementation.render),version:s.version,...i===void 0?void 0:{sourceMap:i},...r===void 0?void 0:{cause:String(r instanceof Error?r.message:r)}}};var Eo=()=>{};import{Component as ut,createContext as pt,createElement as ft,useContext as mt,useEffect as gt,useLayoutEffect as xt,useRef as yt,useState as bt}from"react";import"react";import{jsx as be,jsxs as ht}from"react/jsx-runtime";var kt=(o)=>ht("div",{role:"alert","data-diagnostic-id":o.diagnosticId,children:["Hosted extension failed. Diagnostic ID: ",o.diagnosticId]}),To,Oo,Jo,Po=({diagnostic:o})=>mt(Jo)(o),Vo=(o,e)=>{console.error(`Hosted extension ${o.diagnosticId}: ${o.message}`,e)},Do,wt,ne=({componentProps:o,declaration:e,fallback:n=wt,implementationRole:t="render",load:r,onDiagnostic:i})=>{let[s,a]=bt(null),l=yt({load:r,onDiagnostic:i});xt(()=>{l.current={load:r,onDiagnostic:i}},[r,i]),gt(()=>{let x=!0;return(async()=>{try{let f=await l.current.load();if(!x)return;let m=e.implementation[t]??e.implementation.render,u=f[m.exportName];if(u===void 0){let h=ae({declaration:e,message:`Export "${m.exportName}" was not a React component.`,phase:"load"});Vo(h,h),l.current.onDiagnostic?.(h),a({declaration:e,diagnostic:h,implementationRole:t,kind:"failed"});return}a({component:u,declaration:e,implementationRole:t,kind:"ready"})}catch(f){if(!x)return;let m=ae({cause:f,declaration:e,message:"The hosted component could not be loaded.",phase:"load"});Vo(m,f),l.current.onDiagnostic?.(m),a({declaration:e,diagnostic:m,implementationRole:t,kind:"failed"})}})(),()=>{x=!1}},[e,t]);let d=s?.declaration===e&&s.implementationRole===t?s:null;if(d===null)return n;if(d.kind==="failed")return be(Po,{diagnostic:d.diagnostic});let c={children:ft(d.component,o),declaration:e,...i===void 0?void 0:{onDiagnostic:i}};return be(Do,{...c})};var ke=b(()=>{Eo();To=Symbol.for("@collective-intelligence/extensions-sdk-frontend-react/hosted-extension-failure"),Oo=globalThis,Jo=Oo[To]??pt(kt);Oo[To]=Jo;Do=class Do extends ut{constructor(o){super(o);this.state={error:null}}static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,e){let n=ae({cause:o,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});this.props.onDiagnostic?.(n)}render(){if(this.state.error!==null){let o=ae({cause:this.state.error,declaration:this.props.declaration,message:"The hosted component threw while rendering.",phase:"render"});return be(Po,{diagnostic:o})}return this.props.children}};wt=be("output",{children:"Loading extension…"})});var te=async(o,e="render")=>{let n=o.implementation[e]??o.implementation.render;if(n.load===void 0)throw Error(`Workflow contribution "${o.target.fqn}" requires a retained module loader for "${e}".`);return await n.load()};import{infiniteQueryOptions as vt,queryOptions as Wt}from"@tanstack/react-query";var Ro,Ui=(o)=>{Ro=o},No=(o)=>{let{optionsProvider:e,...n}=o;return n},Ao=(o)=>["workflow-field-options",No(o)],Io=(o,e)=>{let n=o.optionsProvider??Ro;return n===void 0?Promise.resolve({options:[]}):n(No(o),e.signal)},le=(o)=>Wt({queryFn:async(e)=>await Io(o,e),queryKey:Ao(o)}),zi=(o)=>vt({getNextPageParam:(e)=>e.nextCursor,initialPageParam:null,queryFn:async({pageParam:e,signal:n})=>await Io({...o,cursor:e},{signal:n}),queryKey:Ao({...o,cursor:null})});var $e=()=>{};import{Combobox as Ct,Label as Ft}from"@collective-intelligence/ui-react/ui";import{useQuery as St}from"@tanstack/react-query";import{jsx as jo,jsxs as Vt}from"react/jsx-runtime";var Et=(o)=>{if(o?.kind==="literal")return o.text;return o?.kind==="translation"?o.default:void 0},$o=({context:o})=>{let{remoteOptions:e}=o,n={catalogTemplateId:e?.catalogTemplateId??"",dependencies:e?.dependencies??{},limit:50,organizationId:e?.organizationId??""},t=e?.config===void 0?le(n):le({...n,config:e.config}),r=(()=>{if(e?.optionsProvider===void 0)return t;if(e.config===void 0)return le({...n,optionsProvider:e.optionsProvider});return le({...n,config:e.config,optionsProvider:e.optionsProvider})})(),i=St({...r,enabled:Boolean(e)}),s=i.data?.options??o.options,a=Et(o.field.placeholder);return Vt("div",{className:"space-y-2",children:[jo(Ft,{htmlFor:`workflow-field-${o.field.key}`,children:o.field.label.kind==="literal"?o.field.label.text:o.field.label.default}),jo(Ct,{className:"w-full",disabled:o.readOnly||Boolean(e&&i.isPending),emptyMessage:"No options are available.",id:`workflow-field-${o.field.key}`,modal:!0,onChange:(l)=>o.onValueChange(l),options:s.map((l)=>({label:l.label,value:String(l.value)})),placeholder:a??"Select an option",searchPlaceholder:"Search options...",value:o.value===null||!p(o.value)&&!J(o.value)?"":String(o.value),width:"100%"})]})};var qo=b(()=>{$e()});var L;var qe=b(()=>{L={field:"Field",unavailableConfiguration:(o)=>`${o} has configuration that this Dashboard cannot edit. Its saved configuration is preserved.`,unavailableControl:(o,e)=>`${o} uses an unavailable ${e} control. Its saved value is preserved.`}});import{Alert as Tt,AlertDescription as Ot}from"@collective-intelligence/ui-react/ui";import{jsx as R,jsxs as Be,Fragment as Pt}from"react/jsx-runtime";var Me=({diagnostics:o})=>R(Pt,{children:o.map((e)=>R(Tt,{variant:"destructive",children:R(Ot,{children:e.message})},`${e.code}:${e.message}`))}),Jt=(o)=>{if(p(o))return o;if(o!==null&&W(o)&&"text"in o){let{text:e}=o;return p(e)?e:L.field}if(o!==null&&W(o)&&"default"in o){let{default:e}=o;return p(e)?e:L.field}return L.field},Le=({context:o})=>{let e={widget:o.field.widget};if(o.field.fieldFqn!==void 0&&o.field.fieldFqn!==null)e.fqn=o.field.fieldFqn;if(o.field.fieldVersion!==void 0&&o.field.fieldVersion!==null)e.version=o.field.fieldVersion;let n=de(e),t=o.mode??(o.readOnly?"read_only":"value"),r={...o,readOnly:t==="read_only"||o.readOnly};if(n.kind==="resolved"&&n.source==="fallback"&&o.field.optionSource?.kind==="remote")return Be("div",{className:"space-y-2",children:[R($o,{context:r}),R(Me,{diagnostics:o.diagnostics})]});if(n.kind==="resolved")return Be("div",{className:"space-y-2",children:[R(ne,{componentProps:r,declaration:n.entry.declaration,load:()=>te(n.entry.declaration)}),Mo(n.entry).handlesDiagnostics===!0?null:R(Me,{diagnostics:o.diagnostics})]});return Be("div",{className:"space-y-2",children:[R("div",{className:"rounded-lg border border-dashed border-border px-3 py-2 text-sm text-muted-foreground",children:L.unavailableControl(Jt(o.field.label),o.field.fieldFqn??o.field.widget)}),R(Me,{diagnostics:o.diagnostics})]})};var _e=b(()=>{ke();ce();qo();qe()});var Bo;var Lo=b(()=>{Bo={noEditableFields:"This template does not expose editable fields."}});import{jsx as He,jsxs as Ho}from"react/jsx-runtime";var Dt=function(e){if(p(e))return e;if(W(e)&&!Array.isArray(e)&&"en"in e){let n=e.en;return p(n)?n:""}return""},_o=function(e){return[...e].sort((n,t)=>(n.order??0)-(t.order??0))},Rt=function(e){return _o(e).map((n)=>({...n,fields:_o(n.fields??[])}))},_=({context:o})=>{let e=Rt("editor"in o.template.contract?o.template.contract.editor?.form?.sections??[]:[]);return Ho("div",{className:"space-y-5",children:[e.map((n)=>Ho("section",{className:"space-y-3 rounded-xl border border-border p-4",children:[He("h3",{className:"text-sm font-semibold text-foreground",children:Dt(n.label)}),(n.fields??[]).filter((t)=>o.isFieldVisible?.(t)??!0).map((t)=>o.getFieldContext?He(Le,{context:o.getFieldContext(t)},t.key):null)]},n.key)),e.length?null:He("p",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:Bo.noEditableFields})]})};var we=b(()=>{_e();Lo()});var Nt,Ko=(o)=>Nt.has(o),H=(o)=>T(o)?o:void 0,ve=(o)=>{let e=o.anyOf??o.oneOf;return Array.isArray(e)?e.flatMap((n)=>{let t=H(n);return t===void 0?[]:ve(t)}):[o]},Uo=(o)=>{if(o===null)return"null";if(Array.isArray(o))return"array";if(T(o))return"object";if(p(o))return"string";if(J(o))return Number.isInteger(o)?"integer":"number";return"boolean"},Qo=(o)=>{let{type:e}=o;if(p(e))return Ko(e)?new Set([e]):void 0;if(Array.isArray(e))return new Set(e.filter(p).filter(Ko));if(o.const!==void 0)return new Set([Uo(o.const)]);if(Array.isArray(o.enum))return new Set(o.enum.map(Uo));if(o.properties!==void 0)return new Set(["object"]);if(o.items!==void 0)return new Set(["array"]);return},N=(o)=>{let e=new Set;for(let n of ve(o)){let t=Qo(n);if(t===void 0)return;for(let r of t)e.add(r)}return e},Go=(o)=>{let[e]=o;if(e===void 0)return{};return o.length===1?e:{anyOf:[...o]}},ue=(o,e)=>ve(o).filter((n)=>{let t=Qo(n);return t===void 0||t.has(e)}),he=(o)=>Go(ue(o,"array").map((e)=>H(e.items)??{})),At=(o,e)=>o.has(e)||e==="integer"&&o.has("number"),It=(o,e)=>{let[n]=ue(o,"object"),t=H(n?.properties);if(t===void 0)return!0;let r=Array.isArray(n?.required)?n.required.filter(p):[];return ue(e,"object").every((i)=>{let s=H(i.properties);if(s===void 0)return!0;return r.every((a)=>(a in s))&&Object.entries(t).every(([a,l])=>{let d=H(s[a]),c=H(l);return d===void 0||c===void 0?!0:K(c,d)})})},K=(o,e)=>{let n=N(o),t=N(e);if(n===void 0||t===void 0)return!0;for(let r of t)if(!At(n,r))return!1;if(t.has("array")&&!K(he(o),he(e)))return!1;return!t.has("object")||It(o,e)},jt=(o)=>Go(ve(o).flatMap((e)=>{let{type:n}=e;if(n==="null")return[];if(Array.isArray(n)){let t=n.filter((r)=>r!=="null");return t.length===0?[]:[{...e,type:t}]}return[e]})),$t=(o)=>{let e=N(o);if(e?.has("string")===!0)return'""';if(e?.has("number")===!0||e?.has("integer")===!0)return"0";if(e?.has("boolean")===!0)return"false";return},qt=(o)=>{let e=ue(o,"array").every((t)=>J(t.minItems)&&t.minItems>=1),n=he(o);return e||N(n)?.has("null")===!0?n:{anyOf:[n,{type:"null"}]}},Ke=(o,e)=>{if(e===void 0||N(e)===void 0||N(o)===void 0)return{status:"unknown"};if(K(e,o))return{status:"compatible"};let n=$t(e),t=(l,d)=>{if(K(e,l))return d;return n!==void 0&&K(e,jt(l))?[...d,`coalesce(${n})`]:void 0},r=t(o,[]),i=N(o),s=r===void 0&&i?.has("array")===!0?t(qt(o),["first"]):void 0,a=r??s;return a===void 0||a.length===0?{status:"incompatible"}:{pipes:a.map((l)=>`| ${l}`).join(" "),status:"fixable"}},zo=4,Mt=(o)=>{let e=ue(o,"object").flatMap((t)=>Object.keys(H(t.properties)??{}));if(e.length===0)return"object";return`{${e.slice(0,zo).join(", ")}${e.length>zo?", …":""}}`},Ue=(o)=>{let e=N(o);if(e===void 0)return"any";return["string","integer","number","boolean","object","array","null"].filter((t)=>e.has(t)).map((t)=>{if(t==="array"){let r=he(o),i=N(r);return`array of ${i?.size===1&&i.has("object")?Mt(r):Ue(r)}`}return t}).join(" | ")};var We=b(()=>{Nt=new Set(["array","boolean","integer","null","number","object","string"])});var hs=function(e){let n=e.mode==="fixed"?e.value:null;return{expression:e.mode==="expression"?e.source:"",fixed:n,mode:e.mode}},vs=function(e){return e.mode==="fixed"?{mode:"fixed",value:e.fixed}:{languageVersion:1,mode:"expression",source:e.expression}},Yo=function(e,n){return{availability:n.availability,id:n.id,label:n.label,path:n.path??[],schema:n.schema,sourceId:e}},Bt=(o,e)=>o.length===e.length&&o.every((n,t)=>n===e[t]),Lt=function(e,n,t){let r=t.path??[];if(r.length===0){e.children.push(Yo(n,t));return}let i=e;for(let[s,a]of r.entries()){let l=r.slice(0,s+1),d=i.children.findIndex((k)=>Bt(k.path,l)),c=i.children[d];if(s===r.length-1){if(!c)i.children.push(Yo(n,t));return}if(c&&"children"in c){i=c;continue}let x=c?{...c,children:[],conditional:c.availability==="conditional",selectors:[]}:{availability:t.availability,children:[],conditional:t.availability==="conditional",id:`${n}:${l.join(".")}`,label:String(a),path:l,schema:{},selectors:[],sourceId:n};if(c)i.children[d]=x;else i.children.push(x);i=x}},_t=function o(e){return e.flatMap((n)=>[n,...o(n.children??[])])},Ht=function(e){let n=e.availability??"guaranteed",t={availability:n,children:[],conditional:n==="conditional",id:e.id,label:e.label,path:[],schema:e.schema,selectors:(e.selectors??[]).map((r)=>r.kind),sourceId:e.id};if(e.nodeKey!==void 0&&e.nodeKey!==null)t.nodeKey=e.nodeKey;for(let r of _t(e.fields??[]))Lt(t,e.id,r);return t},Kt=function(e){return{compatibility:e.targetCompatibility??[],language:e.languageManifest,sources:(e.availableSources??[]).map(Ht)}},Ut=function(e){return{canonicalSource:e.canonicalSource??null,diagnostics:(e.diagnostics??[]).map((n)=>({actualSchema:n.actualSchema,code:n.code,expectedSchema:n.expectedSchema,message:n.message,remediation:n.remediation,severity:n.severity,span:n.span})),inferredSchema:e.inferredSchema,references:e.references??[]}},Ws=function(e,n){return K(n,e)},Zo=function(e,n,t){let r=Math.max(0,Math.min(n,e.length));return{cursor:r+t.length,source:`${e.slice(0,r)}${t}${e.slice(r)}`}};var Ce=b(()=>{We()});var zt=function(e){if(e.id==="trigger")return"trigger";if(e.id==="workflow_input")return"input";let[,n]=e.id.split(":port:");return`nodes[${JSON.stringify(e.nodeKey??e.label)}]${n?`.${n}`:""}`},Qt=function(e){return e.map((n)=>(()=>{if(J(n))return`[${n}]`;if(/^[A-Za-z_$][\w$]*$/u.test(n))return`.${n}`;return`[${JSON.stringify(n)}]`})()).join("")},Gt=function(e){if(e.id==="trigger")return{id:"trigger",label:"Trigger data"};if(e.id==="workflow_input")return{id:"workflow_input",label:"Workflow input"};return{id:e.id,label:e.label}},Yt=function o(e){let{source:n}=e;return e.nodes.flatMap((t)=>{let r=`${n.id}:${t.id}`,i=[...e.parentLabels,t.label],s="children"in t?t.children:[],a=`${zt(n)}${Qt(t.path)}`;return[{conditional:t.availability==="conditional",depth:e.depth,expandable:s.length>0,group:e.group,id:r,insertion:`{{ ${a} }}`,label:`${n.label} · ${i.join(".")}`,name:t.label,parentId:e.parentId,pathLabel:i.join("."),reference:a,schema:t.schema,selectors:n.selectors},...o({depth:e.depth+1,group:e.group,nodes:s,parentId:r,parentLabels:i,source:n})]})},Zt=function(e){let n=e.children.length?e.children:[{availability:e.availability,id:e.id,label:"Output",path:[],schema:e.schema,sourceId:e.id}];return Yt({depth:0,group:Gt(e),nodes:n,parentId:null,parentLabels:[],source:e})},ze=function(e){return e.sources.flatMap((n)=>Zt(n))},U=function(e){return Ue(e)};var Fe=b(()=>{We()});import{jsx as F,jsxs as en,Fragment as Xt}from"react/jsx-runtime";var V=({title:o,values:e})=>en("section",{"aria-label":o,children:[F("h3",{className:"font-medium",children:o}),e.length>0?F("ul",{className:"mt-1 list-disc pl-5 font-mono text-xs",children:e.map((n,t)=>F("li",{children:n},`${n}-${t}`))}):F("p",{className:"text-muted-foreground",children:"No entries in this language manifest."})]}),Xo=function(e){return e.map((n)=>n.example??n.name)},Qe=({manifest:o})=>en(Xt,{children:[F(V,{title:"Syntax overview",values:[o.grammar]}),F(V,{title:"Interpolation",values:[`Whole value preserves type: ${o.interpolation.wholeValuePreservesType}`,`Mixed text returns: ${o.interpolation.mixedTextReturns}`]}),F(V,{title:"References",values:[o.grammar]}),F(V,{title:"Selectors",values:o.selectors.map(({kind:e})=>e)}),F(V,{title:"Unavailable-value policies",values:o.availabilityPolicies}),F(V,{title:"Operators",values:o.operators}),F(V,{title:"Functions",values:Xo(o.functions)}),F(V,{title:"Casts and pipes",values:o.pipes}),F(V,{title:"Strings",values:o.pipes}),F(V,{title:"Collections",values:o.pipes}),F(V,{title:"Objects",values:o.pipes}),F(V,{title:"Dates",values:o.pipes}),F(V,{title:"If conditions",values:o.ifExamples}),F(V,{title:"Comparators",values:Xo(o.comparators)})]});var Ge=()=>{};var z;var on=b(()=>{z={applyPipes:(o)=>`Append ${o}`,expectedType:"Field expects",incompatibleType:"Incompatible type",insertWithPipes:"Insert with the pipes that make this value fit the field",validationFailed:(o)=>`We couldn't validate this expression: ${o}`,validationUnavailable:"We couldn't validate this expression right now. Check its syntax and referenced values, then try again."}});import{ChevronRight as er}from"@collective-intelligence/ui-react/icons";import{Badge as or,Button as G,Input as nn,Popover as nr,PopoverAnchor as tr,PopoverContent as rr,Textarea as ir}from"@collective-intelligence/ui-react/ui";import{Fragment as sr,useEffect as ar,useRef as lr,useState as Q}from"react";import{jsx as y,jsxs as S}from"react/jsx-runtime";var tn=(o)=>o!==null&&W(o)&&!Array.isArray(o),A=(o)=>o!==null&&o!==void 0&&o!=="",dr=function o(e){if(p(e))return e;if(Array.isArray(e)){let n=e.map(o).filter((t)=>A(t));return n.length?n.join("; "):void 0}if(!tn(e))return;if(p(e.msg))return e.msg;if(p(e.message))return e.message;if(p(e.detail))return e.detail;return},cr=function(e){if(e instanceof Error&&A(e.message))return e.message;if(!P(e))return;if(!tn(e))return;return[e.detail,e.body,e.error,e.message].map(dr).find((n)=>A(n))},ur=function(e){let n=cr(e);return A(n)?z.validationFailed(n):z.validationUnavailable},rn,pr,sn=function(e,n){return pr.flatMap((t)=>e.filter((r)=>n(r)===t))},fr=function(e){let n=new Map;for(let i of e){let s=n.get(i.option.parentId)??[];s.push(i),n.set(i.option.parentId,s)}let t=new Map,r=(i)=>{let s=t.get(i.option.id);if(s!==void 0)return s;let a=Math.min(rn[i.compatibility.status],...(n.get(i.option.id)??[]).map(r));return t.set(i.option.id,a),a};for(let[i,s]of n)n.set(i,sn(s,r));return n},an=({entry:o,expanded:e,onInsert:n,onToggle:t})=>{let{compatibility:r,option:i}=o,s=t===void 0,a=r.status==="incompatible";return S("div",{className:"mt-1 flex items-start gap-1",style:{paddingInlineStart:s?0:`${i.depth*1.25}rem`},children:[!s&&i.expandable?y(G,{"aria-expanded":e,"aria-label":`${e?"Collapse":"Expand"} ${i.label}`,className:"mt-1 size-7 shrink-0",onClick:t,size:"icon",type:"button",variant:"ghost",children:y(er,{"aria-hidden":!0,className:e?"size-4 rotate-90":"size-4"})}):y("span",{"aria-hidden":!0,className:"size-7 shrink-0"}),S(G,{"aria-label":`Insert ${i.label}`,className:`block h-auto min-w-0 flex-1 whitespace-normal px-2 py-1.5 text-left ${a?"opacity-60":""}`,onClick:()=>{n(i.insertion)},type:"button",variant:"ghost",children:[y("span",{className:"block text-sm",children:s?i.pathLabel:i.name}),S("span",{className:"flex flex-wrap items-center gap-1.5 font-mono text-xs text-muted-foreground",children:[U(i.schema),a?y(or,{className:"font-sans",variant:"outline",children:z.incompatibleType}):null]})]}),r.status==="fixable"?y(G,{"aria-label":`Insert ${i.label} with ${r.pipes}`,className:"mt-1 h-auto shrink-0 px-1.5 py-0.5 font-mono text-xs",onClick:()=>{n(`{{ ${i.reference} ${r.pipes} }}`)},size:"sm",title:z.insertWithPipes,type:"button",variant:"outline",children:r.pipes}):null]})},ln=({tree:o,expanded:e,onInsert:n,onToggle:t,parentId:r})=>(o.get(r)??[]).map((i)=>{let s=e.has(i.option.id);return S(sr,{children:[y(an,{entry:i,expanded:s,onInsert:n,onToggle:()=>{t(i.option.id)}}),s?y(ln,{expanded:e,onInsert:n,onToggle:t,parentId:i.option.id,tree:o}):null]},i.option.id)}),mr=({environment:o,onInsert:e,onQueryChange:n,options:t,query:r,targetSchema:i})=>{let[s,a]=Q(new Set),l=new Map(t.map(({group:u})=>[u.id,u])),d=["trigger","workflow_input"],c=[...d.flatMap((u)=>l.get(u)??[]),...[...l.values()].filter(({id:u})=>!d.includes(u))],x=t.map((u)=>({compatibility:Ke(u.schema,i),option:u})),k=r.trim()!=="",f=x.filter(({option:u})=>[u.label,u.insertion,U(u.schema)].join(" ").toLowerCase().includes(r.trim().toLowerCase())),m=(u)=>{a((h)=>{let v=new Set(h);if(v.has(u))v.delete(u);else v.add(u);return v})};return S("div",{className:"grid h-96 max-h-[calc(100dvh-3rem)] grid-cols-[minmax(0,1fr)_14rem] overflow-hidden",children:[S("div",{className:"min-h-0 touch-pan-y overflow-y-auto overscroll-y-contain border-r p-2",onWheel:(u)=>{u.stopPropagation()},children:[y(nn,{"aria-label":"Search expression suggestions",onChange:(u)=>{n(u.target.value)},placeholder:"Search available values",value:r}),c.map((u)=>{let h=(k?f:x).filter(({option:v})=>v.group.id===u.id);if(h.length===0)return null;return S("section",{"aria-label":u.label,className:"mt-3",children:[y("h3",{className:"px-2 text-xs font-semibold text-muted-foreground",children:u.label}),k?sn(h,(v)=>rn[v.compatibility.status]).map((v)=>y(an,{entry:v,expanded:!1,onInsert:e},v.option.id)):y(ln,{expanded:s,onInsert:e,onToggle:m,parentId:null,tree:fr(h)})]},u.id)}),(k?f:x).length===0?y("p",{className:"p-3 text-sm text-muted-foreground",children:"No matching workflow sources."}):null]}),S("aside",{className:"space-y-3 p-3","aria-label":"Expression helper",children:[i===void 0?null:S("p",{className:"text-xs",children:[S("span",{className:"text-muted-foreground",children:[z.expectedType," "]}),y("span",{className:"font-mono",children:U(i)})]}),y("p",{className:"text-xs text-muted-foreground",children:"Select a typed source. Expand an object to pick one of its fields, or insert the whole object."}),y("h3",{className:"text-xs font-semibold",children:"Pipes"}),o.language.pipes.map((u)=>S(G,{className:"mr-1 mb-1 h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{e(` | ${u}`)},size:"sm",type:"button",variant:"outline",children:["| ",u]},u))]})]})},gr,xr=function(e,n){let t=gr.exec(e)?.groups?.body;return t===void 0||t.includes("{{")?void 0:`{{ ${t.trim()} ${n} }}`},yr=({diagnostic:o,onApplyFix:e,source:n,targetSchema:t})=>{let r=o.expectedSchema??t,i=o.code==="incompatible_expression_type"&&o.actualSchema!==null?Ke(o.actualSchema,r??void 0):void 0,s=i?.status==="fixable"?xr(n,i.pipes):void 0;return S("div",{className:"space-y-1 text-sm text-destructive",role:"alert",children:[S("p",{children:[o.message," (characters ",o.span.start,"–",o.span.end,")"]}),A(o.remediation)?y("p",{className:"text-xs text-muted-foreground",children:o.remediation}):null,i?.status==="fixable"&&s!==void 0&&e!==void 0?y(G,{className:"h-auto px-1.5 py-0.5 font-mono text-xs",onClick:()=>{e(s)},size:"sm",type:"button",variant:"outline",children:z.applyPipes(i.pipes)}):null]})},Ye=({describedBy:o,environment:e,inputLabel:n="Expression",source:t,onChange:r,validate:i,multiline:s=!1,readOnly:a=!1,targetSchema:l})=>{let d=lr(null),c=(g)=>{d.current=g},[x,k]=Q(t.length),[f,m]=Q(!1),[u,h]=Q("suggestions"),[v,Y]=Q(""),[De,Re]=Q(null),[B,Z]=Q(null),ie=i===void 0||t===""?null:De,C=i===void 0||t===""?null:B,O=[o,A(C)?"expression-validation":void 0].filter(Boolean).join(" ")||void 0;ar(()=>{let g=new AbortController;if(!i||t==="");else{let Ne=async()=>{try{let Ae=await i(t,g.signal);if(!g.signal.aborted)Re(Ae),Z(null)}catch(Ae){if(!g.signal.aborted)Z(ur(Ae))}},ee=window.setTimeout(()=>{Ne()},300);return()=>{g.abort(),window.clearTimeout(ee)}}return()=>{g.abort()}},[t,i]);let j=ze(e),X=(g)=>{let Ne=d.current?.selectionStart??x,ee=Zo(t,Ne,g);k(ee.cursor),r(ee.source),queueMicrotask(()=>{d.current?.focus(),d.current?.setSelectionRange(ee.cursor,ee.cursor)})};return S("div",{className:"space-y-2",children:[S(nr,{onOpenChange:(g)=>{if(m(g),!g)Y(""),h("suggestions")},open:f,children:[y(tr,{asChild:!0,children:y("div",{children:(()=>{if(s)return y(ir,{"aria-describedby":O,"aria-invalid":A(C)||(ie?.diagnostics.length??0)>0,"aria-label":n,className:"min-h-24 text-sm",disabled:a,onChange:(g)=>{r(g.target.value),k(g.currentTarget.selectionStart??t.length)},onFocus:()=>{m(!0)},onKeyDown:(g)=>{if(g.key==="Escape")m(!1)},onSelect:(g)=>{k(g.currentTarget.selectionStart??t.length)},placeholder:"Choose a source or start typing",ref:c,value:t});return y(nn,{"aria-describedby":O,"aria-invalid":A(C)||(ie?.diagnostics.length??0)>0,"aria-label":n,className:"text-sm",disabled:a,onChange:(g)=>{r(g.target.value),k(g.currentTarget.selectionStart??t.length)},onFocus:()=>{m(!0)},onKeyDown:(g)=>{if(g.key==="Escape")m(!1)},onSelect:(g)=>{k(g.currentTarget.selectionStart??t.length)},placeholder:"Choose a source or start typing",ref:c,value:t})})()})}),S(rr,{align:"start",className:"w-[min(48rem,calc(100vw-3rem))] p-0",onOpenAutoFocus:(g)=>{g.preventDefault()},children:[S("div",{className:"flex border-b p-1",role:"tablist",children:[y(G,{"aria-selected":u==="suggestions",onClick:()=>{h("suggestions")},role:"tab",size:"sm",type:"button",variant:u==="suggestions"?"secondary":"ghost",children:"Suggestions"}),y(G,{"aria-selected":u==="syntax",onClick:()=>{h("syntax")},role:"tab",size:"sm",type:"button",variant:u==="syntax"?"secondary":"ghost",children:"Syntax reference"})]}),u==="suggestions"?y(mr,{environment:e,onInsert:X,onQueryChange:Y,options:j,query:v,targetSchema:l}):y("div",{className:"max-h-96 touch-pan-y overflow-y-auto overscroll-y-contain p-4 text-sm",onWheel:(g)=>{g.stopPropagation()},children:y(Qe,{manifest:e.language})})]})]}),A(C)?y("p",{id:"expression-validation",role:"alert",children:C}):null,ie?.diagnostics.map((g)=>y(yr,{diagnostic:g,onApplyFix:a?void 0:r,source:t,targetSchema:l},`${g.code}-${g.span.start}`))]})};var dn=b(()=>{Ce();We();Fe();Ge();on();rn={compatible:0,fixable:1,incompatible:3,unknown:2},pr=[0,1,2,3],gr=/^\s*\{\{(?<body>[\s\S]*?)\}\}\s*$/u});var Se=b(()=>{dn();Ge();Fe()});var I;var cn=b(()=>{I={expression:"Expression",expressionHelp:"Calculates a value from the data available when this step runs.",fixed:"Fixed",fixedHelp:"Uses the saved value as written.",modesHelp:"Fixed uses the saved value as written. Expression calculates a value from the data available when the step runs."}});import{Alert as br,AlertDescription as kr,Label as wr,ToggleGroup as hr,ToggleGroupItem as un}from"@collective-intelligence/ui-react/ui";import{useId as vr,useState as pn}from"react";import{jsx as E,jsxs as Ee}from"react/jsx-runtime";var Wr,fn=function(e){return e.mode==="expression"?{expression:e.source,fixed:null,mode:"expression"}:{expression:"",fixed:e.value,mode:"fixed"}},Cr=({mode:o})=>E("span",{className:"shrink-0 text-xs text-muted-foreground",title:o==="expression"?I.expressionHelp:I.fixedHelp,children:o==="expression"?I.expression:I.fixed}),pe=({allowExpression:o=!1,allowFixed:e=!0,controlId:n,diagnostics:t=Wr,expressionEditor:r,expressionMultiline:i=!1,help:s,label:a,onValueChange:l,readOnly:d=!1,renderExpression:c,renderFixed:x,required:k=!1,sensitive:f=!1,value:m})=>{let u=vr(),[h,v]=pn(()=>fn(m)),Y=JSON.stringify(m),[De,Re]=pn(Y),B=n===void 0?void 0:`${n}-label`;if(Y!==De)Re(Y),v(fn(m));let Z=(()=>{if(o&&!e)return"expression";if(e&&!o)return"fixed";return h.mode})(),ie=d;return Ee("section",{className:"space-y-2",children:[Ee("div",{className:"flex items-center justify-between gap-3",children:[E("div",{className:"min-w-0",children:Ee("div",{className:"flex items-center gap-1",children:[E(wr,{htmlFor:n,id:B,children:a}),k?E("span",{"aria-label":"Required",children:"*"}):null,f?E("span",{className:"ml-1 text-xs text-muted-foreground",children:"Sensitive"}):null]})}),o&&d?E(Cr,{mode:Z}):null,o&&e&&!d?E("div",{"aria-label":`${a} mode controls`,className:"flex shrink-0 items-center gap-1",children:Ee(hr,{"aria-label":`${a} mode`,className:"gap-0",disabled:ie,onValueChange:(C)=>{if(C==="fixed"||C==="expression")v((O)=>({...O,mode:C}))},size:"sm",type:"single",value:Z,variant:"outline",children:[E(un,{className:"h-7 px-4 text-xs",title:I.fixedHelp,value:"fixed",children:I.fixed}),E(un,{className:"h-7 px-4 text-xs",title:I.expressionHelp,value:"expression",children:I.expression})]})}):null]}),s!==void 0&&s!==""?E("p",{id:u,className:"text-xs leading-relaxed text-muted-foreground",children:s}):null,(()=>{if(Z==="expression"){if(r?.environment){let j=r.validate===void 0?{}:{validate:r.validate};return E(Ye,{...s?{describedBy:u}:{},environment:r.environment,multiline:i,onChange:(X)=>{v((g)=>({...g,expression:X})),l({languageVersion:1,mode:"expression",source:X})},readOnly:d,source:h.expression,targetSchema:r.targetSchema,...j})}if(r?.loading===!0)return E("output",{children:"Loading expression editor…"});if(r?.error!==void 0&&r.error!=="")return E("p",{role:"alert",children:r.error});let O={disabled:d,onChange:(j)=>{v((X)=>({...X,expression:j})),l({languageVersion:1,mode:"expression",source:j})},value:h.expression};if(s)O.describedBy=u;if(n!==void 0)O.controlId=`${n}-expression`;if(B!==void 0)O.labelledBy=B;return c?.(O)}let C={disabled:d,onChange:(O)=>{v((j)=>({...j,fixed:O})),l({mode:"fixed",value:O})},value:h.fixed};if(s)C.describedBy=u;if(n!==void 0)C.controlId=n;if(B!==void 0)C.labelledBy=B;return x(C)})(),t.map((C)=>E(br,{variant:"destructive",children:E(kr,{children:C.message})},`${C.code}:${C.message}`))]})};var Ze=b(()=>{Se();cn();Wr=[]});var Xe=b(()=>{Ze()});var eo;var mn=b(()=>{eo={inputBindingsDescription:"Map workflow input field names to literal or dynamic expressions.",inputBindingsTitle:"Input adapter bindings"}});var fe=function(e){return T(e)?e:{}},oo=function(e){return fe(e)},Fr=function(e,n,t){let r=e.anyOf;if(!Array.isArray(r))return;let i=r.filter((d)=>fe(d).type!=="null");if(i.length!==1||i.length===r.length)return;let s=oo(t(i[0],n)),{type:a}=s,l={...s,...Object.fromEntries(Object.entries(e).filter(([d])=>d!=="anyOf"&&d!=="$defs"))};if(p(a))l.type=[a,"null"];return l},Sr=function(e){let n=fe(e.$defs),t=(r,i=new Set)=>{if(Array.isArray(r))return r.map((c)=>t(c,i));if(!T(r))return r;let s=fe(r),a=s.$ref,l=p(a)?a:void 0;if(l!==void 0&&l.startsWith("#/$defs/")){let c=l.slice(8),x=n[c];if(x!==void 0&&!i.has(c))return t(x,new Set(i).add(c))}let d=Fr(s,i,t);if(d)return d;return Object.fromEntries(Object.entries(s).filter(([c])=>c!=="$defs").map(([c,x])=>[c,t(x,i)]))};return oo(t(e))},Er=function(e){let{type:n}=e;return n==="null"||Array.isArray(n)&&n.includes("null")},Vr=function(e){let{type:n}=e;if(p(n))return n==="null"?e:{...e,type:[n,"null"]};if(Array.isArray(n))return n.includes("null")?e:{...e,type:[...n,"null"]};return e},Tr=function o(e,n=[],t=!1){return Object.entries(fe(e.properties)).map(([r,i])=>{let s=oo(i),a=t?Vr(s):s,l=[...n,r],d=o(s,l,t||Er(s)),c={availability:"guaranteed",id:`trigger:${l.join(".")}`,label:r,path:l,schema:a,sourceId:"trigger"};return d.length?{...c,children:d,conditional:!1,selectors:[]}:c})},gn=function(e){let{triggerInput:n}=e;if(!n)return;let t=Sr(n.schema);return{compatibility:[],language:n.languageManifest,sources:[{availability:"guaranteed",children:Tr(t),conditional:!1,id:"trigger",label:"Trigger data",path:[],schema:t,selectors:[],sourceId:"trigger"}]}};var xn=()=>{};import{Input as Or,Label as Jr}from"@collective-intelligence/ui-react/ui";import{jsx as ge,jsxs as yn}from"react/jsx-runtime";var Pr=(o)=>{if(o===null||o===void 0||p(o)||J(o)||se(o))return String(o??"");return JSON.stringify(o)??""},me=function(e){return T(e)?e:{}},Dr=function(e,n){return e?.length===n.length&&e.every((t,r)=>t===n[r])},Rr=function(e,n){if(n==="number"||n==="integer"){let t=Number(e);return Number.isFinite(t)?t:e}if(n==="boolean")return e==="true";return e},Nr=function(e){if(!T(e))return{mode:"fixed",value:e??null};if(e.mode==="expression"&&p(e.source))return{languageVersion:1,mode:"expression",source:e.source};if(e.mode==="fixed"&&P(e.value))return{mode:"fixed",value:e.value};return{mode:"fixed",value:e}},bn=({context:o})=>{let e=me(o.workflowContracts?.inputContract.jsonSchema.properties),n=o.trigger?.inputBindings??{},t=gn(o.template.contract);return yn("div",{className:"space-y-5",children:[ge(_,{context:o}),yn("section",{className:"space-y-2 rounded-xl border border-border p-4",children:[ge(Jr,{htmlFor:"workflow-trigger-input-bindings",children:eo.inputBindingsTitle}),ge("p",{className:"text-xs text-muted-foreground",children:eo.inputBindingsDescription}),Object.entries(e).map(([r,i])=>{let s=me(n[r]),a=Nr(s?.value),l=o.triggerInputExpressionValidator?.(r),d=t===void 0?void 0:{environment:t,targetSchema:me(i)};if(d!==void 0&&l!==void 0)d.validate=l;return ge(pe,{allowExpression:!0,...d===void 0?{}:{expressionEditor:d},diagnostics:o.diagnostics.filter((c)=>Dr(c.path,["inputBindings",r])),label:`${r} (${U(me(i))})`,readOnly:o.readOnly,value:a,onValueChange:(c)=>o.commands.updateTriggerConfiguration?.({inputBindings:{...n,[r]:{overridePolicy:"locked",value:c}}}),renderFixed:({value:c,onChange:x})=>ge(Or,{value:Pr(c),onChange:(k)=>{x(Rr(k.target.value,me(i)?.type))}})},r)})]})]})};var kn=b(()=>{Se();Xe();we();mn();xn()});var Vn={};_n(Vn,{renderDefaultActionChart:()=>wn,renderDefaultActionDetails:()=>hn,renderDefaultInputChart:()=>Cn,renderDefaultInputDetails:()=>Fn,renderDefaultOutputChart:()=>Sn,renderDefaultOutputDetails:()=>En,renderDefaultTriggerChart:()=>vn,renderDefaultTriggerDetails:()=>Wn});import{jsx as q}from"react/jsx-runtime";var wn=(o)=>q(oe,{context:o,accent:"slate"}),hn=(o)=>q(_,{context:o}),vn=(o)=>q(oe,{context:o,accent:"violet"}),Wn=(o)=>q(bn,{context:o}),Cn=(o)=>q(oe,{context:o,accent:"sky"}),Fn=(o)=>q(_,{context:o}),Sn=(o)=>q(oe,{context:o,accent:"emerald"}),En=(o)=>q(_,{context:o});var no=b(()=>{je();we();kn()});import{declareFrontendComponent as Ar}from"@collective-intelligence/extensions-sdk-frontend";var to=(o)=>({exportName:o,load:()=>Promise.resolve().then(() => (no(),Vn)),module:import.meta.url}),Ve=(o,e,n)=>Ar({implementation:{chart:to(e),details:to(n),render:to(n)},metadata:{kind:o,mode:"default"},target:{fqn:`builtin.core.workflows.nodes.${o.replace(/_node$/u,"")}`,packageFqn:"builtin.core",role:"workflow_template_default",version:"1.0.0"}}),ro;var io=b(()=>{ro=[Ve("action_node","renderDefaultActionChart","renderDefaultActionDetails"),Ve("trigger_node","renderDefaultTriggerChart","renderDefaultTriggerDetails"),Ve("input_node","renderDefaultInputChart","renderDefaultInputDetails"),Ve("output_node","renderDefaultOutputChart","renderDefaultOutputDetails")]});import{WorkflowTemplateKinds as Ir}from"@collective-intelligence/extensions-sdk";var xe=(o)=>Ir.find((e)=>e===o);var so=()=>{};import{createFrontendCatalog as jr,declareFrontendPackage as $r}from"@collective-intelligence/extensions-sdk-frontend";var co,Te,uo=(o)=>{let{declaration:{metadata:e}}=o;if(!T(e))return{};let n=p(e.kind)?xe(e.kind):void 0,t;if(p(e.mode)){if(e.mode==="default")t="default";else if(e.mode==="override")t="override"}let r={};if(p(e.fqn))r.fqn=e.fqn;if(se(e.handlesDiagnostics))r.handlesDiagnostics=e.handlesDiagnostics;if(n!==void 0)r.kind=n;if(t!==void 0)r.mode=t;if(p(e.widget))r.widget=e.widget;return r},Oe=(o)=>{let e=o?.trim().toLowerCase();return e===void 0||e===""?void 0:e},Tn=()=>co.snapshot().entries,On=(o,e,n)=>{let t=Oe(o),r=Oe(e);if(t===void 0||r===void 0)return;return Tn().find((i)=>i.target.toLowerCase()===t&&i.version.toLowerCase()===r&&i.role===n)},ao=(o,e,n)=>{let t=Oe(e);return Tn().find((r)=>{let i=uo(r);return Oe(i[o])===t&&r.role===n})},Jn=(o)=>{Te=[...Te.filter((t)=>!o.some((r)=>r.manifest.fqn===t.manifest.fqn)),...o];let n=co.activate(Te);if(n.kind==="invalid")throw Error(n.errors.map((t)=>t.message).join("; "));if(n.kind!=="activated")throw Error(`Workflow catalog activation became stale (${n.reason}).`)},lo,qr=()=>{if(Te.some((o)=>o.manifest.fqn===lo.manifest.fqn))return;Jn([lo])},Mr=()=>co.snapshot(),de=(o)=>{let e=p(o)?{widget:o}:o,n=e.fqn??void 0,t=e.version??void 0,r=On(n,t,"workflow_field");if(r!==void 0)return{entry:r,kind:"resolved",source:"exact"};if(n!==void 0&&t!==void 0){let a=ao("widget",e.widget??"","workflow_field_fallback");if(a!==void 0&&n.toLowerCase().startsWith("builtin."))return{entry:a,kind:"resolved",source:"fallback"};let l={fqn:n,kind:"unavailable"};if(e.widget!==void 0)l.widget=e.widget;return l}let i=ao("widget",e.widget??"","workflow_field_fallback");if(i!==void 0)return{entry:i,kind:"resolved",source:"fallback"};let s={kind:"unavailable"};if(e.fqn!==void 0&&e.fqn!==null)s.fqn=e.fqn;if(e.widget!==void 0)s.widget=e.widget;return s},po=(o)=>{let e=xe(o.kind);if(e===void 0)return{fqn:o.fqn,kind:"unavailable",templateKind:o.kind};let n=On(o.fqn,o.version??"1.0.0","workflow_template_override");if(n!==void 0&&uo(n).kind===e)return{entry:n,kind:"resolved",source:"override"};let t=ao("kind",e,"workflow_template_default");if(t!==void 0)return{entry:t,kind:"resolved",source:"default"};return{fqn:o.fqn,kind:"unavailable",templateKind:o.kind}},Mo;var ce=b(()=>{io();so();so();co=jr(),Te=[],lo=$r({components:ro,manifest:{fqn:"builtin.core",name:"Dashboard Workflow UI",version:"1.0.0"}}),Mo=uo});ce();ke();ce();qe();import{jsx as Pn}from"react/jsx-runtime";var Br=({context:o})=>{let e=de(o.field);if(e.kind==="resolved"&&e.entry.declaration.implementation.configuration!==void 0)return Pn(ne,{componentProps:o,declaration:e.entry.declaration,implementationRole:"configuration",load:()=>te(e.entry.declaration,"configuration")});return Pn("div",{className:"rounded-md border border-dashed border-border p-2 text-xs text-muted-foreground",children:L.unavailableConfiguration(o.field.label)})};_e();Ce();Xe();Ze();import{Textarea as Lr}from"@collective-intelligence/ui-react/ui";import{jsx as Dn}from"react/jsx-runtime";import{createElement as Hr}from"react";var Aa=({help:o,label:e,onValueChange:n,expressionEditor:t,readOnly:r,renderFixed:i,resetKey:s,slotId:a,value:l})=>Dn("div",{"data-expression-slot":a,children:Hr(pe,{allowExpression:!0,...o===void 0?{}:{help:o},...t===void 0?{}:{expressionEditor:t},key:`${a}:${s??"current"}`,label:e,onValueChange:n,...r===void 0?{}:{readOnly:r},renderExpression:({describedBy:d,disabled:c,onChange:x,value:k})=>Dn(Lr,{"aria-describedby":d,"aria-label":`${e} expression`,disabled:c,onChange:(f)=>{x(f.target.value)},placeholder:"{{ input.value }}",value:k}),renderFixed:i,value:l})}),_r=function(e){if(!T(e))return!1;if(e.mode==="fixed")return P(e.value);return e.mode==="expression"&&J(e.languageVersion)&&e.languageVersion===1&&p(e.source)},Ia=function(e){if(_r(e))return e;return{mode:"fixed",value:e}};var fo=function(e,n){let t=[...e];for(let r=0;r<t.length;r+=1)for(let i=r+1;i<t.length;i+=1){let s=t[r],a=t[i];if(s!==void 0&&a!==void 0&&n(s,a)>0)t[r]=a,t[i]=s}return t};var Nn=function(e){return W(e)&&!Array.isArray(e)},Kr=function o(e){return e.flatMap((n)=>[...n.templates??[],...o(n.children??[])])},mo=function(e){return e.kind==="field_collection"&&"collection"in e.contract},go=function(e){return`${e.fqn}@${e.version}`},Rn=function(e){return e.kind==="literal"?e.text:e.default},Ur=function(e){return e.kind==="field"&&"field"in e.contract},zr=function(e,n){if(!e.enabled||e.state!=="available")return!1;return n==="input"?e.contract.field.availableForInput!==!1:e.contract.field.availableForOutput!==!1},Qr=function(e,n){let t=e.find((r)=>mo(r)&&go(r.contract.collection)===n);return t&&mo(t)?t.contract.collection.weight??0:0},Je=function(e){return e!==void 0&&Nn(e)?e:{}},_a=function(e,n){let t=Kr(e?.categories??[]),r=new Map;for(let s of t){if(!mo(s))continue;r.set(go(s.contract.collection),Rn(s.label))}let i=new Map;for(let s of t){if(!Ur(s)||!zr(s,n))continue;let a=s.contract.field,l=go({fqn:a.collectionFqn,version:a.collectionVersion}),d=i.get(l)??{fields:[],key:l,label:r.get(l)??a.collectionFqn,weight:Qr(t,l)};d.fields.push({catalogTemplateId:s.id,collectionKey:l,configSchema:Je(a.configSchema),fqn:a.fqn,label:Rn(s.label),schema:Je(a.valueSchema),version:a.version}),i.set(l,d)}return fo([...i.values()].map((s)=>({...s,fields:fo(s.fields,(a,l)=>a.label.localeCompare(l.label)||a.fqn.localeCompare(l.fqn))})),(s,a)=>s.weight-a.weight||s.label.localeCompare(a.label)||s.key.localeCompare(a.key))},Ha=function(e){return{key:e.key,label:e.label,options:e.fields.map((n)=>({fqn:n.fqn,label:n.label,searchTerms:[n.fqn],version:n.version}))}},Gr=function(e){let n=Je(e.$defs),t=(r,i=new Set)=>{if(Array.isArray(r))return r.map((d)=>t(d,i));if(r===null||!Nn(r))return r;let s=r,a=s.$ref,l=p(a)?a:void 0;if(l!==void 0&&l.startsWith("#/$defs/")){let d=l.slice(8),c=n[d];if(c!==void 0&&c!==null&&!i.has(d))return t(c,new Set(i).add(d))}return Object.fromEntries(Object.entries(s).filter(([d])=>d!=="$defs").map(([d,c])=>[d,t(c,i)]))};return Je(t(e))},Ka=function(e,n){let{title:t,...r}=Gr(n.schema),i={...r};if(p(e.title))i.title=e.title;return i};import{useDebouncedCallback as Yr}from"@collective-intelligence/ui-react/hooks";import{Check as Zr,ChevronsUpDown as Xr}from"@collective-intelligence/ui-react/icons";import{Button as ei,Command as oi,CommandGroup as ni,CommandInput as ti,CommandItem as ri,CommandList as ii,Popover as si,PopoverContent as ai,PopoverTrigger as li}from"@collective-intelligence/ui-react/ui";import{useMemo as di,useState as xo}from"react";import{jsx as M,jsxs as ye}from"react/jsx-runtime";var ci=250,yo=function(e){return`${e.fqn}@${e.version}`},ui=function(e,n){let t=n.trim().toLocaleLowerCase();if(!t)return e;return e.flatMap((r)=>{let i=r.options.filter((s)=>[s.label,s.fqn,...s.searchTerms??[]].join(" ").toLocaleLowerCase().includes(t));return i.length?[{...r,options:i}]:[]})},Za=({collections:o,value:e,onChange:n,ariaLabel:t="Field type"})=>{let[r,i]=xo(!1),[s,a]=xo(""),[l,d]=xo(""),c=Yr(d,ci),x=o.flatMap((m)=>m.options).find((m)=>yo(m)===e),k=di(()=>ui(o,l),[o,l]),f=k.some((m)=>m.options.length>0);return ye(si,{modal:!0,open:r,onOpenChange:(m)=>{if(i(m),!m)c.cancel(),a(""),d("")},children:[M(li,{asChild:!0,children:ye(ei,{type:"button",variant:"outline","aria-label":t,"aria-expanded":r,className:"mt-1 w-full justify-between font-normal",children:[M("span",{className:"truncate",children:x?.label??"Select a field type"}),M(Xr,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}),M(ai,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0",children:ye(oi,{shouldFilter:!1,children:[M(ti,{placeholder:"Search field types...",value:s,onValueChange:(m)=>{a(m),c(m)}}),ye(ii,{children:[f?null:M("p",{className:"py-6 text-center text-sm",children:"No field type found."}),k.map((m)=>M(ni,{heading:m.label,children:m.options.map((u)=>{let h=yo(u);return ye(ri,{value:yo(u),onSelect:()=>{n(u),i(!1)},children:[M(Zr,{className:e===h?"mr-2 size-4 opacity-100":"mr-2 size-4 opacity-0"}),u.label]},h)})},m.key))]})]})})]})};je();we();io();no();ke();ce();import{jsx as An,jsxs as fi}from"react/jsx-runtime";var pi=({context:o})=>{let e=po(o.template);if(e.kind==="resolved")return An(ne,{componentProps:o,declaration:e.entry.declaration,implementationRole:"details",load:()=>te(e.entry.declaration,"details")});return fi("div",{className:"rounded-xl border border-dashed border-border p-4 text-sm text-muted-foreground",children:["No dashboard editor is available for template kind"," ",An("code",{children:e.templateKind}),". The workflow draft has not been changed."]})};var bo=(o)=>o!==void 0&&o!==null&&W(o)&&!Array.isArray(o),In=function(e,n){return Object.fromEntries(Object.entries(e).filter(([t])=>t!==n))},jn=function(e){if(e==="input_binding")return"inputs";if(e==="setting")return"settings";if(e==="metadata")return"metadata";return"config"},re=function(e){return bo(e)?e:void 0},ko=function(e){let n=re(e);if(n===void 0||!("value"in n))return e;return n.mode==="fixed"||n.kind==="literal"?n.value:e},Pe=function(e,n){let t=e[jn(n.target)];for(let r of n.path){let i=re(ko(t));if(i===void 0)return;t=i[r]}return ko(t)},mi=function(e,n){return Pe(e,n.binding)},gi=function o(e,n,t){let[r,...i]=n;if(r===void 0)return e??{};let s=e??{};if(!i.length)return{...s,[r]:t};let a=re(s[r]),l=re(ko(a));if(a?.mode==="fixed")return{...s,[r]:{...a,value:o(l,i,t)}};return{...s,[r]:o(l,i,t)}},wo=function(e,n){return[e==="input_binding"?"inputBinding":e,...n].map((t)=>encodeURIComponent(String(t))).join("/")},xi=function(e,n,t){let r={...re(e?.fieldDisplayValues)},i=wo(n.binding.target,n.binding.path);if(t)r[i]=t;else return{...e,fieldDisplayValues:In(r,i)};return{...e,fieldDisplayValues:r}},yi=function(e,n,t,r){let i=jn(n.binding.target),s={[i]:gi(e[i],n.binding.path,t)};if(r!==void 0)s.metadata=xi(i==="metadata"?s.metadata:e.metadata,n,r);return s},$n=function(e,n,t){let r=e.metadata?.fieldDisplayValues;if(r===void 0||r===null||!bo(r))return;let i=r[wo(n.binding.target,t)];if(i===void 0||i===null||!bo(i))return;return p(i.label)&&"value"in i?{label:i.label,value:i.value}:void 0},bi=function(e,n){return $n(e,n,n.binding.path)},ki=function(e,n,t){return $n(e,n,[...n.binding.path,...t])},wi=function(e,n,t,r){let i={...re(e?.fieldDisplayValues)},s=wo(n,t);if(r)i[s]=r;else return{...e,fieldDisplayValues:In(i,s)};return{...e,fieldDisplayValues:i}},hi=function(e,n,t,r){return{metadata:wi(e.metadata,n.binding.target,[...n.binding.path,...t],r)}};var ho=function o(e,n){if(Array.isArray(e)||Array.isArray(n))return Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((t,r)=>o(t,n[r]));if(e!==null&&n!==null&&e!==void 0&&n!==void 0&&W(e)&&W(n)){let t=Object.keys(e);return t.length===Object.keys(n).length&&t.every((r)=>o(e[r],n[r]))}return e===n},qn=function(e){return e!==void 0&&e!==null&&e!==""},vi=function(e,n){if(!Array.isArray(n)||e===void 0)return!1;return(Array.isArray(e)?e:[e]).some((r)=>n.some((i)=>ho(r,i)))},Wi=function(e,n){return(e.visibleWhen??[]).every((t)=>{let r=Pe(n,t.binding);switch(t.operator){case"equals":return ho(r,t.value);case"not_equals":return!ho(r,t.value);case"is_set":return qn(r);case"is_not_set":return!qn(r);case"in":return vi(r,t.value);default:return!1}})};var Ci=function(e){if(!e)return"";return e.kind==="literal"?e.text:e.default};Ce();Se();Fe();$e();export{oe as CatalogNodeChartBlock,_ as CatalogNodeDetailsEditor,Ye as ExpressionEditor,Aa as ExpressionSlot,Qe as ExpressionSyntaxReference,Za as FieldTypeSelect,Br as WorkflowFieldConfigurationResolver,pe as WorkflowFieldFrame,Le as WorkflowFieldResolver,pi as WorkflowTemplateDetails,qr as activateDashboardWorkflowCatalog,Jn as activateWorkflowCatalog,Ia as asExpressionSlotValue,Ci as catalogText,Ui as configureWorkflowFieldOptionsProvider,hs as createExpressionDraft,lo as dashboardWorkflowPackage,ro as defaultWorkflowTemplateDeclarations,ze as expressionSourceOptions,_a as fieldCollectionsFromCatalog,yo as fieldTypeIdentity,Zo as insertExpressionAtCursor,se as isBoolean,Hn as isFunction,P as isJsonValue,J as isNumber,W as isObject,T as isRecord,Ws as isSchemaCompatible,p as isString,Si as isUndefined,Wi as isWorkflowFieldVisible,Kt as normalizeExpressionEnvironment,Ut as normalizeExpressionValidation,xe as parseWorkflowTemplateKind,hi as patchWorkflowFieldPartDisplayValue,yi as patchWorkflowFieldValue,Pe as readWorkflowBindingValue,bi as readWorkflowFieldDisplayValue,ki as readWorkflowFieldPartDisplayValue,mi as readWorkflowFieldValue,wn as renderDefaultActionChart,hn as renderDefaultActionDetails,Cn as renderDefaultInputChart,Fn as renderDefaultInputDetails,Sn as renderDefaultOutputChart,En as renderDefaultOutputDetails,vn as renderDefaultTriggerChart,Wn as renderDefaultTriggerDetails,de as resolveWorkflowField,po as resolveWorkflowTemplate,Ka as schemaForWorkflowField,U as schemaLabel,vs as serializeExpressionDraft,Ei as toDisplayString,Ha as toFieldTypeCollection,Mr as workflowCatalogSnapshot,le as workflowFieldOptions,zi as workflowFieldOptionsInfinite};
@@ -18,6 +18,7 @@ export type WorkflowCatalogResolution = Readonly<{
18
18
  templateKind?: string | undefined;
19
19
  widget?: string | undefined;
20
20
  }>;
21
+ declare const metadataOf: (entry: CatalogEntry) => WorkflowDeclarationMetadata;
21
22
  /** Publishes the complete package set used by the Workflow UI host. */
22
23
  export declare const activateWorkflowCatalog: (packages: readonly FrontendPackageDeclaration[]) => void;
23
24
  export declare const dashboardWorkflowPackage: Readonly<{
@@ -33,7 +34,7 @@ export declare const resolveWorkflowField: (reference: string | Readonly<{
33
34
  widget?: string;
34
35
  }>) => WorkflowCatalogResolution;
35
36
  export declare const resolveWorkflowTemplate: (template: WorkflowTemplateReference) => WorkflowCatalogResolution;
36
- export declare const workflowDeclarationMetadata: (entry: CatalogEntry) => WorkflowDeclarationMetadata;
37
+ export declare const workflowDeclarationMetadata: typeof metadataOf;
37
38
  export type WorkflowFieldRenderProps = WorkflowFieldComponentContext;
38
39
  export type WorkflowFieldConfigurationRenderProps = WorkflowFieldConfigurationContext;
39
40
  export type WorkflowTemplateRenderProps = WorkflowTemplateUiContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collective-intelligence/extensions-sdk-frontend-react",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Public hosted React contribution contracts for Collective Intelligence extensions.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -59,14 +59,14 @@
59
59
  "lint": "node \"../../../.agents/scripts/managed-lint-runner.mjs\" --scope \"packages/public/extensions-sdk-frontend-react\"",
60
60
  "lint:staged": "oxlint --no-error-on-unmatched-pattern",
61
61
  "prepack": "bun run build",
62
- "type-check": "tsc --noEmit"
62
+ "type-check": "bun check"
63
63
  },
64
64
  "dependencies": {
65
- "@collective-intelligence/extensions-sdk": "0.1.1",
66
- "@collective-intelligence/extensions-sdk-frontend": "0.1.1"
65
+ "@collective-intelligence/extensions-sdk": "0.1.3",
66
+ "@collective-intelligence/extensions-sdk-frontend": "0.1.3"
67
67
  },
68
68
  "peerDependencies": {
69
- "@collective-intelligence/ui-react": "0.1.1",
69
+ "@collective-intelligence/ui-react": "0.1.3",
70
70
  "@tanstack/react-query": ">=5 <6",
71
71
  "@xyflow/react": ">=12 <13",
72
72
  "react": ">=18 <20",
@@ -85,7 +85,7 @@
85
85
  "@oxlint/plugins": "1.85.0",
86
86
  "@tanstack/react-query": "5.101.4",
87
87
  "@testing-library/react": "^16.3.2",
88
- "@types/bun": "1.3.14",
88
+ "@types/bun": "1.4.2",
89
89
  "@types/react": "^19.2.14",
90
90
  "@types/react-dom": "^19.2.3",
91
91
  "@xyflow/react": "^12.10.2",
@@ -95,7 +95,7 @@
95
95
  "oxlint": "1.82.0",
96
96
  "react": "^19.2.8",
97
97
  "react-dom": "^19.2.8",
98
- "typescript": "5.9.3",
98
+ "typescript": "7.0.2",
99
99
  "ultracite": "7.10.7",
100
100
  "vitest": "^3.2.7",
101
101
  "es-module-lexer": "2.3.2"