1"use strict";!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},l=(new e.Error).stack;l&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[l]="e0a11a9d-2309-47fe-95cb-852a9367ddb6",e._sentryDebugIdIdentifier="sentry-dbid-e0a11a9d-2309-47fe-95cb-852a9367ddb6")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4386],{1202:(e,l,t)=>{t.d(l,{tq:()=>u,yq:()=>c});var n=t(37876),i=t(14232),a=t(14483),s=t(9304),r=t(26522);let d=(0,i.createContext)(null);function o({runtime:e,children:l}){return(0,n.jsx)(d.Provider,{value:e,children:l})}function u({children:e}){let l=(0,i.useContext)(d),t=(0,r.hk)(null===l);return null!==l?e:t.data?(0,n.jsx)(o,{runtime:t.data,children:e}):t.isError?(0,n.jsx)(s.T,{error:t.error,onRetry:()=>void t.refetch()}):(0,n.jsx)(a.E,{className:"m-6 h-64"})}function c(){let e=(0,i.useContext)(d);if(null===e)throw Error("Workflow editors require the loaded definition contract");return e}},6240:(e,l,t)=>{t.d(l,{sB:()=>s,xP:()=>i,y_:()=>a});var n=t(84443);function i(e,l){return`${e}_${"add_entity"===l?"canonical":"any"}`}function a(e,l,t){return e.filter(e=>{if(!e.isActive||"reference"!==e.type||!e.referenceKind)return!1;let i=n.vs[e.referenceKind];return i.side===l&&("add_entity"!==t||i.usesPicker)})}function s(e,l,t,n){let i=a(e,t,n);return l&&i.some(e=>e.id===l)?{ok:!0,columnId:l}:l||1!==i.length?{ok:!1,eligible:i.map(e=>({id:e.id,name:e.name,kind:e.referenceKind}))}:{ok:!0,columnId:i[0].id}}},7260:(e,l,t)=>{function n(e,l,t,i=""){let s=e.nodePropertySchema(l,t);if("integer"!==s.type)throw Error(`Workflow property ${l}.${t} is not an integer`);return{...a(s),help:i}}function i(e){return"number"==typeof e.maxItems?e.maxItems:void 0}function a(e){let l={required:!0,nullable:!1,default:null,help:""};if("string"===e.type)return{...l,type:{kind:"string",minimum_length:"number"==typeof e.minLength?e.minLength:0,maximum_length:"number"==typeof e.maxLength?e.maxLength:Number.MAX_SAFE_INTEGER}};if("integer"===e.type)return{...l,type:{kind:"integer",minimum:String(Math.max(Number.MIN_SAFE_INTEGER,"number"==typeof e.minimum?Math.ceil(e.minimum):"number"==typeof e.exclusiveMinimum?Math.floor(e.exclusiveMinimum)+1:Number.MIN_SAFE_INTEGER)),maximum:String(Math.min(Number.MAX_SAFE_INTEGER,"number"==typeof e.maximum?Math.floor(e.maximum):"number"==typeof e.exclusiveMaximum?Math.ceil(e.exclusiveMaximum)-1:Number.MAX_SAFE_INTEGER))}};if("number"===e.type)return{...l,type:{kind:"number",minimum:"number"==typeof e.minimum?e.minimum:-Number.MAX_VALUE,maximum:"number"==typeof e.maximum?e.maximum:Number.MAX_VALUE}};if("array"===e.type&&null!==e.items&&"object"==typeof e.items&&!Array.isArray(e.items))return{...l,type:{kind:"list",item:a(e.items),minimum_length:"number"==typeof e.minItems?e.minItems:0,maximum_length:"number"==typeof e.maxItems?e.maxItems:Number.MAX_SAFE_INTEGER}};throw Error("This workflow property has no supported value editor")}t.d(l,{Cd:()=>n,P1:()=>a,lu:()=>i})},7845:(e,l,t)=>{t.d(l,{z:()=>u});var n=t(37876),i=t(46752),a=t(9314),s=t(19357),r=t(9510);function d(e,l,t){return e?.kind==="field"?e.draft.find(e=>1===e.path.length&&e.path[0]===l)?.text??t:t}function o(e){return/^\d+$/.test(e)&&Number.isSafeInteger(Number(e))?Number(e):void 0}function u(e){let{node:l,retryBounds:t,timeoutBounds:u,enclosingSeconds:c=null,fields:m,disabled:p,onChange:f}=e,h=`${l.id}:retry`,b=`${l.id}:timeout`,x=m[h],v=m[b],y=l.retry?.backoff?l.retry:null,k=d(x,"maximum_retries",String(l.retry?.maximum_retries??1)),g=d(x,"backoff",y?.backoff??"fixed"),j=d(x,"backoff_seconds",String(y?.backoff_seconds??t?.minimum_backoff_seconds??1)),_=d(v,"timeout_seconds",String(l.timeout?.timeout_seconds??u?.minimum_seconds??1)),w=i.JB.safeParse({maximum_retries:o(k),backoff:g,backoff_seconds:o(j)}),N=w.success&&t?(0,i.fz)(w.data,t):"Enter a whole number of retries and a whole delay in seconds.",C=i.YC.safeParse({timeout_seconds:o(_)}),$=C.success&&u?(0,i.uR)(C.data,u,c):u?`Enter a whole number between ${u.minimum_seconds} and ${null===c?u.maximum_seconds:Math.min(u.maximum_seconds,c)} seconds.`:"Enter a whole number of seconds.",I=null===$,S=(e,n)=>{let a={maximum_retries:k,backoff:g,backoff_seconds:j,[e]:n},s=i.JB.safeParse({maximum_retries:o(a.maximum_retries),backoff:a.backoff,backoff_seconds:o(a.backoff_seconds)}),r=s.success&&null!==t&&null===(0,i.fz)(s.data,t);f(r?{...l,retry:s.data}:l,{key:h,buffer:{kind:"field",valid:r,draft:Object.entries(a).map(([e,l])=>({path:[e],text:l,source:void 0,touched:!0}))}})};return(0,n.jsxs)("section",{"aria-label":"Retries and timeout",className:"space-y-6",children:[t?(0,n.jsxs)(a.D0,{children:[(0,n.jsx)(a.dh,{children:"Automatic retries"}),(0,n.jsx)(r.i8,{label:"Automatic retries",disabled:p,value:l.retry?0===l.retry.maximum_retries?"none":"custom":"default",options:[{value:"default",label:"Use the registered retry policy"},{value:"none",label:"Do not retry"},...t.maximum_retries>0?[{value:"custom",label:"Set retry limits"}]:[]],onChange:e=>f({...l,retry:"default"===e?null:"none"===e?{maximum_retries:0}:{maximum_retries:1,backoff:"fixed",backoff_seconds:t.minimum_backoff_seconds}}
1,void 0,[h])}),y?(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)(a.D0,{children:[(0,n.jsx)(a.dh,{htmlFor:`${l.id}-retry-count`,children:"Retries after the first attempt"}),(0,n.jsx)(s.p,{id:`${l.id}-retry-count`,type:"number",min:1,max:t.maximum_retries,step:1,value:k,disabled:p,onChange:e=>S("maximum_retries",e.target.value)})]}),(0,n.jsxs)(a.D0,{children:[(0,n.jsx)(a.dh,{children:"Delay between retries"}),(0,n.jsx)(r.i8,{label:"Delay between retries",disabled:p,value:g,options:[{value:"fixed",label:"Same delay each time"},{value:"exponential",label:"Double the delay each time"}],onChange:e=>S("backoff",e)}),(0,n.jsx)(a.dh,{htmlFor:`${l.id}-retry-delay`,children:"First delay in seconds"}),(0,n.jsx)(s.p,{id:`${l.id}-retry-delay`,type:"number",step:1,min:t.minimum_backoff_seconds,max:t.maximum_backoff_seconds,value:j,disabled:p,onChange:e=>S("backoff_seconds",e.target.value)})]}),N?(0,n.jsx)(a.bg,{children:N}):null]}):null,(0,n.jsxs)(a.ry,{children:[(0,i.w6)(l.retry),". Only errors the task marks as retryable can retry."]})]}):null,u?(0,n.jsxs)(a.D0,{children:[(0,n.jsx)(a.dh,{children:"Time limit"}),(0,n.jsx)(r.i8,{label:"Time limit",disabled:p,value:l.timeout?"limited":"none",options:[{value:"none",label:"No added time limit"},{value:"limited",label:"Set a time limit"}],onChange:e=>f({...l,timeout:"limited"===e?{timeout_seconds:u.minimum_seconds}:null},void 0,[b])}),l.timeout?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.dh,{htmlFor:`${l.id}-timeout`,children:"Time limit in seconds"}),(0,n.jsx)(s.p,{id:`${l.id}-timeout`,type:"number",step:1,min:u.minimum_seconds,max:u.maximum_seconds,value:_,disabled:p,"aria-invalid":!I,onChange:e=>{let t=e.target.value,n=i.YC.safeParse({timeout_seconds:o(t)}),a=n.success&&null!==u&&null===(0,i.uR)(n.data,u,c);f(a?{...l,timeout:n.data}:l,{key:b,buffer:{kind:"field",valid:a,draft:[{path:["timeout_seconds"],text:t,source:void 0,touched:!0}]}})}}),I?null:(0,n.jsx)(a.bg,{children:$}),(0,n.jsx)(a.ry,{children:"The clock starts when this step starts. Retry and repair keep the same deadline. Use its Timeout path to handle expiry."})]}):null]}):null]})}},8282:(e,l,t)=>{t.d(l,{X:()=>b});var n=t(37876),i=t(14232),a=t(41946),s=t.n(a),r=t(57195),d=t(7260),o=t(9516),u=t(14748),c=t(66810),m=t(59867),p=t(1202),f=t(9330),h=t(9510);function b(e){let{value:l,draft:t,onChange:i}=e,a=t&&s()(t.source,l)?t:null,r=a?.memberships??l.memberships.map(l=>(0,u.e0)(e,l)),d=a?.consumers??l.consumers.map(l=>(0,u.e0)(e,l));return(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsx)(x,{...e,rows:r,consumer:!1,onRowsChange:e=>i((0,u.zD)(l,e,d))}),(0,n.jsx)(x,{...e,rows:d,consumer:!0,onRowsChange:e=>i((0,u.zD)(l,r,e))}),(0,u.NL)(e).map(e=>(0,n.jsxs)("section",{className:"space-y-3 border-t pt-3",children:[(0,n.jsxs)("h4",{className:"text-sm font-medium",children:["Inherited from ",e.label]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Edit the enclosing loop to change these links."}),e.value.memberships.length?(0,n.jsx)(x,{...e.context,rows:e.value.memberships.map(l=>(0,u.e0)(e.context,l)),consumer:!1,disabled:!0,inherited:!0}):null,e.value.consumers.length?(0,n.jsx)(x,{...e.context,rows:e.value.consumers.map(l=>(0,u.e0)(e.context,l)),consumer:!0,disabled:!0,inherited:!0}):null]},e.ownerId))]})}function x(e){let l=(0,p.yq)(),{rows:t,consumer:a,onRowsChange:s,disabled:m=!1,inherited:f=!1}=e,h=(0,o.di)(e.definition,e.scopePath)?.nodes.find(l=>l.id===e.currentNodeId),b=a?"consumers":"memberships",x=(0,d.lu)(h?l.nodePropertySchema(h.kind,b):l.modelPropertySchema("RoutingBranch",b)),y=(0,r.RN)(e);return(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-3",children:[(0,n.jsx)("legend",{className:"mb-2 text-sm font-medium",children:a?"Needed by":"In groups"}),f?null:(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:a?"List the groups that need this work. One active group permits admission; all paused groups make it wait, and no remaining group stops new work.":"Pause or cancel for a selected group key applies to this step. A loopâs groups also apply to its body. Each entry names one key."}),t.length?null:(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:a?"No groups need this work.":"This step is in no groups directly."}),t.map((l,n)=>(0,i.createElement)(v,{...e,scopes:y,key:n,row:l,index:n,onRowChange:e=>s?.(t.map((l,t)=>t===n?e:l)),onRemove:()=>s?.(t.filter((e,l)=>l!==n))})),f?null:(0,n.jsx)(c.$,{type:"button",variant:"outline",disabled:m||t.length>=(x??1/0),onClick:()=>s?.([...t,(0,u.uq)()]),children:a?"Add Needed Group":"Add Group"})]})}function v(e){let{row:l,index:t,consumer:a,onRowChange:s,onRemove:d,disabled:o=!1,inherited:b=!1}=e,x=(0,p.yq)(),[v,y]=(0,i.useState)(!l.scopeId||!l.key||!l.keyValid),k=`${a?"Needed by":"Group"} ${t+1}`,g=e.scopes,j=g.find(e=>e.id===l.scopeId),_=j?.field,w=_?.kind==="available"?(0,u.ls)(x,_.field,a&&l.many):null,N=(0,u.hp)(e,l,a),C=(0,f.j)({value:l.key,buffer:{draft:l.keyDraft}
1,emptyDraft:null,onChange:(t,n,i)=>{let a=null===t?null:(0,r.jv)(t)?t:l.key,d=a?(0,r.xJ)(e,a):null;s({...l,key:a,keyDraft:n,keyValid:i&&(null===t||(0,r.jv)(t)),inferredMany:d?.kind==="available"&&"list"===d.field.type.kind})}});return(0,n.jsxs)("section",{"aria-label":k,className:"min-w-0 space-y-3 border-b pb-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsx)(c.$,{type:"button",variant:"ghost",size:"sm","aria-expanded":v,onClick:()=>y(!v),children:v?`Close ${k}`:o?`View ${k}`:`Edit ${k}`}),b?null:(0,n.jsx)(c.$,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:d,children:a?"Remove Needed Group":"Remove Group"})]}),N?(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[N," Repair this link before publishing; the draft keeps it."]}):null,v?(0,n.jsxs)("fieldset",{className:"space-y-3",children:[(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"Group"}),(0,n.jsx)(h.Hq,{label:`${k} group`,disabled:o,value:l.scopeId??"",options:[{value:"",label:"Cho
1ose a groupâ¦"},...l.scopeId&&!j?[{value:l.scopeId,label:`Missing group \xb7 ${l.scopeId}`,disabled:!0}]:[],...g.map(l=>({value:l.id,label:`${l.label} \xb7 ${l.scopePath.length===e.scopePath.length?"Current body":"Ancestor body"}`}))],onChange:e=>{let t=g.find(l=>l.id===e);t&&s({...l,scopeId:t.id})}})]}),_?.kind==="unavailable"?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:_.reason}):null,a?(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"Group keys"}),(0,n.jsx)(h.i8,{label:`${k} key count`,disabled:o,value:l.many?"many":"one",options:[{value:"one",label:"One Key"},{value:"many",label:"A List of Keys"}],onChange:e=>{("one"===e||"many"===e)&&s({...l,many:"many"===e})}})]}):null,(0,n.jsx)(m.e,{...e,target:w,sourceKinds:["literal","workflow_input","iteration_item","node_output"],value:l.key,draft:l.keyDraft,label:`${k} ${a&&l.many?"keys":"key"}`,disabled:o||null===w,...C})]}):(0,n.jsxs)("p",{className:"truncate text-sm",children:[j?.label??"Missing scope"," \xb7"," ",a&&l.many?"List of keys":"One key",l.keyValid?"":" â unfinished edits"]})]})}},9330:(e,l,t)=>{t.d(l,{j:()=>i});var n=t(14232);function i({value:e,buffer:l,emptyDraft:t,onChange:a}){let s=(0,n.useRef)(null);return{onDraftChange(t){s.current={buffer:l,value:e,draft:t}},onChange(n,i){let r=s.current;s.current=null,a(n,null!==r&&r.buffer===l&&r.value===e?r.draft:l?.draft??t,i)}}}},14748:(e,l,t)=>{t.d(l,{LE:()=>m,NL:()=>h,Z8:()=>r,e0:()=>o,hp:()=>p,ls:()=>f,uq:()=>d,y4:()=>s,zD:()=>c});var n=t(57195),i=t(7260),a=t(9516);function s(e){return{value:e,label:{draft:[],valid:!0},keysDraft:null,keysValid:!0}}function r(e,l,t){let n=t.length<=((0,i.lu)(e.definitionPropertySchema("scopes"))??1/0)&&t.every(e=>e.label.valid&&e.keysValid),a=n?t.map(e=>e.value):l;return{value:a,valid:n,draft:!n||t.some(e=>e.label.draft.length||e.keysDraft)?{source:a,rows:t}:null}}function d(){return{scopeId:null,key:null,keyDraft:null,keyValid:!0,many:!1,inferredMany:!1}}function o(e,l){let t=(0,n.xJ)(e,l.key),i="available"===t.kind&&"list"===t.field.type.kind;return{scopeId:l.scope_id,consumer:l.consumer,key:l.key,keyDraft:null,keyValid:!0,many:i,inferredMany:i}}function u(e){let l=[];for(let t of e){if(!t.scopeId||!t.key||!t.keyValid)return null;l.push({scope_id:t.scopeId,key:t.key,...void 0!==t.consumer?{consumer:t.consumer}:{}})}return l}function c(e,l,t){let n=u(l),i=u(t),a=null!==n&&null!==i,s=n&&i?{memberships:n,consumers:i}:e;return{value:s,valid:a,draft:!a||[...l,...t].some(e=>e.keyDraft||e.many!==e.inferredMany)?{source:s,memberships:l,consumers:t}:null}}function m(e,l){let{keys:t}=l;if(!t)return"Choose the bounded key collection before publishing.";let i=(0,n.xJ)(e,t);if("unavailable"===i.kind)return i.reason;let a=(0,n.df)(e,i.field);if("unavailable"===a.kind)return a.reason;let s=(0,n.Sd)(a.field,l.key_path);return"unavailable"===s.kind?s.reason:(0,n.J1)(s.field)?null:"Scope keys must be non-null text, exact integers, choices or nominal references."}function p(e,l,t){if(!l.scopeId||!l.key)return null;let i=(0,n.ng)(e,l.scopeId);if("unavailable"===i.kind)return i.reason;let a=(0,n.xJ)(e,l.key);if("unavailable"===a.kind)return a.reason;if(null!=l.consumer&&(!t||"list"===a.field.type.kind))return"A named consumer needs one scope key, not a list of keys.";let s=t&&"list"===a.field.type.kind?a.field.type.item:a.field;return(0,n.J1)(s)&&(0,n.bD)(s,i.field)?null:"Choose a key with the scopeâs non-null type and identity. Only consumers may supply a list of keys."}function f(e,l,t){let n=e.fieldTypePropertySchema("list","maximum_length").maximum;return t?{type:{kind:"list",item:l,minimum_length:0,maximum_length:"number"==typeof n?n:Number.MAX_SAFE_INTEGER},required:!0,nullable:!1,default:null,help:""}:l}function h(e){return e.scopePath.flatMap((l,t)=>{let n=e.scopePath.slice(0,t),i=(0,a.di)(e.definition,n),s=i?.nodes.find(e=>e.id===l);return s&&(s.memberships.length||s.consumers.length)?[{ownerId:s.id,label:s.label,context:{...e,scopePath:n,currentNodeId:s.id}
1,value:{memberships:s.memberships,consumers:s.consumers}}]:[]})}},18384:(e,l,t)=>{t.d(l,{N:()=>h,i:()=>f});var n=t(37876),i=t(7260),a=t(1202),s=t(36937),r=t(60230),d=t(14232),o=t(57195),u=t(63492),c=t(9510);function m({node:e,context:l,buffer:t,disabled:i,onChange:a}){let r=(0,d.useId)(),p=(0,o.fP)(l,e),f="available"===p.kind?(0,o.wN)(p.field).filter(({field:e})=>(0,o.J1)(e)):[],h=JSON.stringify(e.key_path),b=f.some(({path:e})=>JSON.stringify(e)===h);return(0,n.jsxs)("section",{"aria-label":"Iteration source",className:"space-y-3",children:[(0,n.jsx)(s.A,{...l,label:"Collection",target:null,sourcePurpose:"collection",value:e.collection,buffer:t?.kind==="binding"?t:void 0,disabled:i,onChange:(l,t)=>a({...e,collection:l},{key:`${e.id}:collection`,buffer:t})}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(u.J,{htmlFor:r,children:"Stable item key"}),(0,n.jsx)(c.Hq,{id:r,label:"Stable item key",value:h,disabled:i||0===f.length,describedBy:`${r}-help`,options:[...b?[]:[{value:h,label:`Unavailable key: ${e.key_path.join(" ⺠")||"Whole item"}`,disabled:!0}],...f.map(({path:e})=>({value:JSON.stringify(e),label:e.length?e.join(" ⺠"):"Whole item"}))],onChange:l=>{let t=f.find(({path:e})=>JSON.stringify(e)===l);t&&a({...e,key_path:t.path})}}),(0,n.jsx)("p",{id:`${r}-help`,className:"text-sm text-muted-foreground",children:"Use an ID that stays the same for each item, not its label or position. Duplicate keys fail the run; items never disappear silently."}),"unavailable"===p.kind?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:p.reason}):b?null:(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Choose a non-null text, integer, enum or reference key before running. You can save this draft while fixing the source."})]})]})}function p({node:e,field:l,label:t,help:s,value:d,props:o}){let u=(0,a.yq)(),c=(0,i.Cd)(u,e.kind,l,s),m="concurrency"===l&&"integer"===c.type.kind?{...c,type:{...c.type,minimum:String(Math.max(2,Number(c.type.minimum)))}}:c,f=`${e.id}:${l}`,h=o.fields[f];return(0,n.jsx)(r.j,{field:m,label:t,value:String(d),buffer:h?.kind==="field"?h:void 0,disabled:o.disabled,onChange:(t,n)=>o.onChange({...e,[l]:n.valid?Number(t):d},{key:f,buffer:{...n,kind:"field"}})})}function f(e){let l=(0,a.yq)(),{node:t}=e;if("repeat_n"!==t.kind)return(0,n.jsx)(m,{node:t,context:e.context,buffer:e.fields[`${t.id}:collection`],disabled:e.disabled,onChange:(l,t)=>e.onChange(l,t)});let r=`${t.id}:count`,d=e.fields[r];return(0,n.jsxs)("section",{"aria-label":"Repeat source",className:"space-y-3",children:[(0,n.jsx)(s.A,{...e.context,label:"Repeat count",target:null,literalField:(0,i.Cd)(l,t.kind,"maximum_iterations"),sourcePurpose:"repeat_count",value:t.count,buffer:d?.kind==="binding"?d:void 0,disabled:e.disabled,onChange:(l,n)=>e.onChange({...t,count:l},{key:r,buffer:n})}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose a whole number. The loop reads it when it starts. Zero skips the body."})]})}function h(e){let{node:l}=e,t=`${l.id}:concurrency`;return(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(c.i8,{label:"Iteration mode",value:1===l.concurrency?"sequential":"concurrent",options:[{value:"sequential",label:"Sequential"},{value:"concurrent",label:"Concurrent"}],disabled:e.disabled,onChange:n=>{let i="concurrent"===n?2:1;i!==l.concurrency&&e.onChange({...l,concurrency:i},void 0,[t])}}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:1===l.concurrency?`Runs one ${"for_each_batch"===l.kind?"batch":"repeat_n"===l.kind?"repetition":"item"} at a time.`:`Runs several ${"for_each_batch"===l.kind?"batches":"repeat_n"===l.kind?"repetitions":"items"} at the same time.`})]}),"for_each_batch"===l.kind?(0,n.jsx)(p,{node:l,field:"batch_size",label:"Batch size",help:"Each batch holds up to this many items; the last may be smaller.",value:l.batch_size,props:e}):null,"repeat_n"===l.kind?(0,n.jsx)(p,{node:l,field:"maximum_iterations",label:"Maximum repetitions",help:"The loop fails if the repeat count exceeds this limit.",value:l.maximum_iterations,props:e}):(0,n.jsx)(p,{node:l,field:"maximum_items",label:"for_each_batch"===l.kind?"Maximum input items":"Maximum items",help:"The loop fails if the collection contains more items.",value:l.maximum_items,props:e}),l.concurrency>1?(0,n.jsx)(p,{node:l,field:"concurrency",label:`Maximum ${"for_each_batch"===l.kind?"batches":"repeat_n"===l.kind?"repetitions":"items"} at once`,help:"Maximum number of loop bodies that can run at once.",value:l.concurrency,props:e}):null]})}},22502:(e,l,t)=>{t.d(l,{u:()=>_});var n=t(37876),i=t(14232),a=t(41946),s=t.n(a),r=t(57195),d=t(7260),o=t(48416),u=t(39675),c=t(9516);function m(){return{kind:"node",callNodeId:null,exitId:null,nodeId:null,loopNodeId:null,collection:null,collectionDraft:null,collectionValid:!0,completionId:null}}function p(e){return{...m(),kind:e.failure.kind,callNodeId:"call_exit_failure"===e.failure.kind?e.failure.call_node_id:null,exitId:"call_exit_failure"===e.failure.kind?e.failure.exit_id:null,nodeId:"node"===e.failure.kind?e.failure.node_id:null,loopNodeId:"loop_limit"===e.failure.kind?e.failure.loop_node_id:null,collection:"collection"===e.failure.kind?e.failure.collection:null,completionId:e.recovery_node_id}}function f(e){return"call_exit_failure"===e.kind?e.callNodeId&&e.exitId?{kind:"call_exit_failure",call_node_id:e.callNodeId,exit_id:e.exitId}:null:"node"===e.kind?e.nodeId?{kind:"node",node_id:e.nodeId}:null:"loop_limit"===e.kind?e.loopNodeId?{kind:"loop_limit",loop_node_id:e.loopNodeId}:null:e.collection&&e.collectionValid?{kind:"collection",collection:e.collection}:null}function h(e){let l=f(e);return l&&e.completionId?{failure:l,recovery_node_id:e.completionId}:null}function b(e){return(0,r.Rk)(e).filter(e=>"collection_outcomes"===e.kind)}function x(e){return[..."task"===e.kind||"workflow"===e.kind?e.inputs.map(e=>e.source):(0,o.lQ)(e)?["repeat_n"===e.kind?e.count:e.collection].filter(e=>null!==e):(0,o.bm)(e)?[e.state.initial,e.state.next,...e.condition?(0,r.gt)(e.condition):[]].filter(e=>null!==e):[],...(0,o.cs)(e)?e.branches.flatMap(e=>e.condition?(0,r.gt)(e.condition):[]):[]]}function v(e,l,t){let n=(0,c.di)(e.definition,e.scopePath);if(!n)return"This body no longer exists.";let i=n.nodes.find(e=>e.id===t);if(!i)return"The completion node is missing or belongs to another body.";if("fail_workflow"===i.kind)return"Fail workflow cannot complete a recovery successfully.";let a=l=>l===t||(0,r.aG)(e.definition,l).has(t);if("call_exit_failure"===l.kind){let i=n.nodes.find(e=>e.id===l.call_node_id);if(i?.kind!=="workflow")return"The source workflow call is missing or belongs to another body.";let s=(0,r.by)(e.catalogue,i)?.exits.find(e=>e.id===l.exit_id);return s?.failure?i.id===t?"A workflow call cannot recover its own failure.":n.order_links.some(e=>e.upstream_node_id===i.id&&a(e.downstream_node_id))||n.nodes.some(e=>a(e.id)&&x(e).flatMap(r.Rk).some(e=>("node_output"===e.kind||"node_outcome"===e.kind)&&e.node_id===i.id))?"This recovery waits for the workflow it must recover. Remove the whole-workflow wait or result source; use the failure exit instead.":n.execution_links.filter(e=>"call_exit"===e.source.kind&&e.source.call_node_id===l.call_node_id&&e.source.exit_id===l.exit_id).some(e=>a(e.target_node_id))?null:"The recovery must run from this exact failure exit. Connect its execution path first.":"Choose a published exit that exposes one failed step."}if("node"===l.kind){let i=n.nodes.find(e=>e.id===l.node_id);if(!i)return"The failed node is missing or belongs to another body.";if(l.node_id===t)return"A node cannot recover its own failure.";if("workflow"===i.kind){let l=new Set((0,r.by)(e.catalogue,i)?.exits.filter(e=>e.failure).map(e=>e.id));if(n.execution_links.some(e=>
1"call_exit"===e.source.kind&&e.source.call_node_id===i.id&&l.has(e.source.exit_id)&&a(e.target_node_id)))return"This path handles one failed step inside the workflow. Choose its exact failure exit as the recovery source."}return(0,r.aG)(e.definition,l.node_id).has(t)?null:"The completion node must depend on the failed node. Add an outcome condition, mapping or order link first."}if("loop_limit"===l.kind){let i=n.nodes.find(e=>e.id===l.loop_node_id);return i&&(0,o.bm)(i)?l.loop_node_id===t?"A loop cannot recover its own limit.":n.execution_links.some(e=>"loop_exit"===e.source.kind&&e.source.loop_node_id===l.loop_node_id&&"limit_reached"===e.source.exit&&(e.target_node_id===t||a(e.target_node_id)))||(0,r.aG)(e.definition,l.loop_node_id).has(t)?null:"The recovery must run from this loopâs Limit reached exit, or depend on the loop.":"A loop limit recovery must name a While or Until loop in this body."}let d=(0,r.xJ)(e,l.collection);return"unavailable"===d.kind?d.reason:n.nodes.some(n=>x(n).flatMap(b).some(e=>s()(e,l.collection))&&(n.id===t||(0,r.aG)(e.definition,n.id).has(t)))?null:"The completion node, or one of its dependencies, must read this exact outcome collection and selection."}var y=t(66810),k=t(59867),g=t(1202),j=t(9510);function _(e){let l=(0,g.yq)(),t=(0,d.lu)(l.definitionPropertySchema("recoveries")),{value:a,draft:r,onChange:o,disabled:f=!1,filterNodeId:b=null}=e,x=(0,c.di)(e.definition,e.scopePath),v=b?a.filter(e=>{var l,t;return l=e,t=b,l.recovery_node_id===t||(0,u.Tg)(l.failure)===t}):a,k=!b&&r&&s()(r.source,a)?r.rows:v.map(p),j=e=>o(function(e,l,t){let n=[],i=t.length<=((0,d.lu)(e.definitionPropertySchema("recoveries"))??1/0);for(let e of t){let l=h(e);l?n.push(l):i=!1}let a=i?n:l,s=t.some(e=>e.collectionDraft||("node"===e.kind?e.collection:e.nodeId));return{value:a,valid:i,draft:!i||s?{source:a,rows:t}:null}}(l,a,e));return x?(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-3",children:[(0,n.jsx)("legend",{className:"sr-only",children:"Error Handling"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"A failure is handled only when its linked completion node runs and succeeds. Sending an email alone does not declare recovery. Required replacement outputs still need their own mappings; the original task stays failed."}),k.length?null:(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:b?"No error handling links for this step.":"No error handling links. Terminal failures remain unhandled, including steps with no output."}),k.map((l,t)=>(0,i.createElement)(w,{...e,key:t,row:l,index:t,disabled:f||!!b,onRowChange:e=>j(k.map((l,n)=>n===t?e:l)),onRemove:b?void 0:()=>j(k.filter((e,l)=>l!==t))})),b?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Edit all error handling links in Workflow settings."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(y.$,{type:"button",variant:"outline",disabled:f||void 0!==t&&k.length>=t,onClick:()=>j([...k,m()]),children:"Add Error Handling Link"}),void 0!==t&&k.length>=t?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Each body allows up to ",t," error handling links. Remove a link before adding another."]}):null]})]}):(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"This body no longer exists. Reopen the definition before editing recovery links."})}function w(e){let{row:l,index:t,onRowChange:a,onRemove:s,disabled:d}=e,[u,m]=(0,i.useState)(()=>null===h(l)),p=(0,i.useRef)(null),b=(0,c.di)(e.definition,e.scopePath),x=b?.nodes??[],g=x.find(e=>e.id===l.nodeId),_=x.find(e=>e.id===l.completionId),w=f(l),N=x.find(e=>e.id===l.callNodeId),C=x.find(e=>e.id===l.loopNodeId),$=N?.kind==="workflow"?(0,r.by)(e.catalogue,N)?.exits.filter(e=>e.failure)??[]:[],I=w&&l.completionId?v(e,w,l.completionId):null,S=`Recovery ${t+1}`,A=l.collection?x.find(e=>e.id===l.collection?.for_each_node_id):null,D="call_exit_failure"===l.kind?`${N?.label??"Missing workflow"} \xb7 ${$.find(e=>e.id===l.exitId)?.label??"Missing failure exit"}`:"node"===l.kind?g?.label??"Missing failed node":"loop_limit"===l.kind?`${C?.label??"Missing loop"} \xb7 Limit reached`:`${A?.label??"Outcome collection"} \xb7 ${l.collection?.selection.kind==="scope"?"Selected control scope":"Whole collection"}`;return(0,n.jsxs)("section",{"aria-label":S,className:"min-w-0 space-y-3 border-b pb-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsx)(y.$,{type:"button",variant:"ghost",size:"sm","aria-expanded":u,onClick:()=>m(!u),children:u?`Close ${S}`:d?`View ${S}`:`Edit ${S}`}),s?(0,n.jsx)(y.$,{type:"button",variant:"ghost",size:"sm",disabled:d,onClick:s,children:"Remove Link"}):null]}),I?(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[I," The saved link stays until you repair or remove it."]}):null,u?(0,n.jsxs)("fieldset",{className:"space-y-3",children:[(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"Failure source"}),(0,n.jsx)(j.i8,{label:`${S} failure source`,disabled:d,value:l.kind,options:[{value:"node",label:"One Node Instance"}
1,{value:"call_exit_failure",label:"Workflow Failure Exit"},{value:"collection",label:"Selected Collection Outcomes"},{value:"loop_limit",label:"Loop Limit"}],onChange:e=>{("node"===e||"collection"===e||"call_exit_failure"===e||"loop_limit"===e)&&a({...l,kind:e})}})]}),"call_exit_failure"===l.kind?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"Source workflow"}),(0,n.jsx)(j.Hq,{label:`${S} source workflow`,value:l.callNodeId??"",disabled:d,options:[{value:"",label:"Choose a workflowâ¦"},...x.filter(e=>"workflow"===e.kind).map(e=>({value:e.id,label:e.label}))],onChange:e=>{let t=x.find(l=>"workflow"===l.kind&&l.id===e);t&&a({...l,callNodeId:t.id,exitId:null})}})]}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"Failed step exposed by"}),(0,n.jsx)(j.Hq,{label:`${S} failure exit`,value:l.exitId??"",disabled:d||!N,options:[{value:"",label:"Choose a failure exitâ¦"},...l.exitId&&!$.some(e=>e.id===l.exitId)?[{value:l.exitId,label:"Missing failure exit",disabled:!0}]:[],...$.map(e=>({value:e.id,label:e.label}))],onChange:e=>{let t=$.find(l=>l.id===e);t&&a({...l,exitId:t.id})}})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"This handles only the failed step exposed by this exit. Other failures in the workflow remain separate."})]}):"node"===l.kind?(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"Failed node"}),(0,n.jsx)(j.Hq,{label:`${S} failed node`,disabled:d,value:l.nodeId??"",options:[{value:"",label:"Cho
1ose a failed nodeâ¦"},...l.nodeId&&!g?[{value:l.nodeId,label:`Missing node \xb7 ${l.nodeId}`,disabled:!0}]:[],...x.map(e=>({value:e.id,label:`${e.label}${e.id===l.completionId?" â Cannot recover itself":""}`,disabled:e.id===l.completionId}))],onChange:e=>{let t=x.find(l=>l.id===e);t&&a({...l,nodeId:t.id})}})]}):"loop_limit"===l.kind?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"While or Until loop"}),(0,n.jsx)(j.Hq,{label:`${S} loop`,disabled:d,value:l.loopNodeId??"",options:[{value:"",label:"Choose a loopâ¦"},...l.loopNodeId&&!C?[{value:l.loopNodeId,label:`Missing loop \xb7 ${l.loopNodeId}`,disabled:!0}]:[],...x.filter(o.bm).map(e=>({value:e.id,label:`${e.label}${e.id===l.completionId?" â Cannot recover itself":""}`,disabled:e.id===l.completionId}))],onChange:e=>{let t=x.find(l=>(0,o.bm)(l)&&l.id===e);t&&a({...l,loopNodeId:t.id})}})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"This handles only that loopâs Limit reached exit. A later body failure still needs its own recovery."})]}):(0,n.jsx)(k.e,{...e,currentNodeId:l.completionId,label:`${S} outcome collection`,target:e.catalogue.collection_outcomes,sourceKinds:["collection_outcomes"],value:l.collection,draft:l.collectionDraft,disabled:d,onDraftChange:e=>
1{p.current={base:l,draft:e}},onChange:(e,t)=>a({...l,collection:null===e?null:"collection_outcomes"===e.kind?e:l.collection,collectionValid:t&&(null===e||"collection_outcomes"===e.kind),collectionDraft:p.current&&p.current.base===l?p.current.draft:l.collectionDraft})}),(0,n.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,n.jsx)("span",{children:"Successful completion node"}),(0,n.jsx)(j.Hq,{label:`${S} completion node`,disabled:d,value:l.completionId??"",options:[{value:"",label:"Choose a completion nodeâ¦"},...l.completionId&&!_?[{value:l.completionId,label:`Missing node \xb7 ${l.completionId}`,disabled:!0}]:[],...x.map(l=>{let t=w?v(e,w,l.id):"Choose a failure source first.";return{value:l.id,label:`${l.label}${t?` â ${t}`:""}`,disabled:null!==t}})],onChange:t=>{let n=x.find(e=>e.id===t);n&&w&&null===v(e,w,n.id)&&a({...l,completionId:n.id})}})]}),h(l)?null:(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Choose both ends of this link before saving, or remove it."})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"text-sm break-words whitespace-normal",title:`${D} â ${_?.label??"Missing completion node"}`,children:[D," â ",_?.label??"Missing completion node"]}),h(l)?null:(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Unfinished link â open it to finish your changes."})]})]})}},26489:(e,l,t)=>{t.d(l,{q:()=>d});var n=t(37876),i=t(48416),a=t(45445),s=t(9314),r=t(19357);function d({id:e,label:l,field:t,value:o,disabled:u,onChange:c}){let m="integer"===t.type.kind?Number(t.type.minimum):0,p="integer"===t.type.kind?Number(t.type.maximum):i.tS,f=(0,a.xk)(o),h="string"==typeof o||"number"==typeof o?o:"",b=null===f&&(void 0!==o||t.required)?"Enter a whole number of seconds.":null!==f&&(Number(f)<m||Number(f)>p)?`${m} to ${p} seconds.`:null;return(0,n.jsxs)(s.D0,{children:[(0,n.jsx)(s.dh,{htmlFor:e,children:l}),(0,n.jsx)(r.p,{id:e,type:"number",inputMode:"numeric",step:1,min:m,max:p,value:h,disabled:u,"aria-invalid":!!b,onChange:e=>{let l=e.currentTarget.value;if(""===l)return void c(void 0,!1);let t=(0,a.xk)(l);c(t??l,null!==t&&Number(t)>=m&&Number(t)<=p)}}),(0,n.jsx)(s.ry,{children:t.help}),b?(0,n.jsx)(s.bg,{children:b}):null]})}},26514:(e,l,t)=>{t.d(l,{Q:()=>c,o:()=>u});var n=t(37876),i=t(14232),a=t(78392),s=t(48327),r=t(66810),d=t(9314),o=t(36937);function u({target:e,field:l,label:t,noun:i,mapping:m,buffer:p,disabled:f,overlap:h,askedLabel:b,onAsk:x,onChange:v,onClear:y,...k}){let g=c(l),j=m||p?.draft?p:g??p,_=m?(0,n.jsx)(r.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Clear ${t}`,disabled:f,onClick:y,children:(0,n.jsx)(a.IeJ,{})}):null,w=(0,n.jsxs)(d.o7,{children:[(0,n.jsxs)(d.d$,{className:"flex flex-wrap items-baseline gap-x-1",children:[(0,n.jsx)("span",{className:"min-w-0 wrap-break-word",children:t})," ",(0,n.jsxs)("span",{className:"font-normal text-muted-foreground",children:["\xb7"," ",l?l.required&&null===l.default?"Required":"Optional":"No longer available"]})]}),l?.help?(0,n.jsx)(d.ry,{children:l.help}):null,l?null:(0,n.jsxs)("p",{role:"status",className:"text-sm text-muted-foreground",children:["The current ",i," contract no longer describes this input. Inspect its saved source here; edit the draft to repair or remove the mapping."]}),null!==h?(0,n.jsxs)("p",{role:"status",className:"text-sm text-muted-foreground",children:["This overlaps the mapping for ",h.join(" ⺠")||"all inputs",". Remove that mapping before assigning this input."]}):null]});return null!==b?(0,n.jsx)(d.D0,{"data-testid":`step-input-${JSON.stringify(e)}`,children:(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:w}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,n.jsxs)(s.E,{variant:"secondary",children:["Asked when running: ",b]}),_]})]})}):(0,n.jsx)(d.D0,{"data-testid":`step-input-${JSON.stringify(e)}`,children:(0,n.jsx)(o.A,{...k,compact:!0,pristine:j===g,target:l,value:m,buffer:j,label:t,disabled:f||null===l||null!==h,onChange:v,title:w,actions:(0,n.jsxs)(n.Fragment,{children:[x?(0,n.jsx)(r.$,{type:"button",variant:"ghost",size:"sm",disabled:f||null!==h,"aria-label":`Ask for ${t} when running`,onClick:x,children:"Ask When Running"}):null,_]})})})}function c(e){return(0,i.useMemo)(()=>e?{kind:"binding",valid:!0,draft:{source:null,editor:{kind:"literal",field:e,value:e.default?e.default.value:void 0,fieldDraft:[],contractDraft:[],contractValid:!0}}}:void 0,[e])}},26882:(e,l,t)=>{t.d(l,{X:()=>y});var n=t(37876),i=t(14232),a=t(41946),s=t.n(a),r=t(33004),d=t(57195),o=t(7260),u=t(14748),c=t(66810),m=t(14534),p=t(63492),f=t(59867),h=t(1202),b=t(60230),x=t(9330),v=t(9510);function y(e){let l=(0,h.yq)(),t=(0,o.lu)(l.definitionPropertySchema("scopes")),{value:a,draft:d,onChange:p,disabled:f=!1}=e,b=d&&s()(d.source,a)?d.rows:a.map(u.y4),[x,v]=(0,i.useState)(null),y=b.find(e=>e.value.id===x),g=e=>p((0,u.Z8)(l,a,e));return(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-3",children:[(0,n.jsx)("legend",{className:"mb-2 text-sm font-medium",children:"Groups"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Name a group and declare its typed key collection. Nodes join a selected key through membership; shared work lists the groups that need it. Changes apply to new runs."}),b.length?null:(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"No groups in this body. Add one to control selected work by a shared key."}),b.map((l,t)=>(0,i.createElement)(k,{...e,key:l.value.id,row:l,index:t,onChange:e=>g(b.map(t=>t.value.id===l.value.id?e:t)),onRemove:()=>v(l.value.id)})),(0,n.jsx)(c.$,{type:"button",variant:"outline",disabled:f||void 0!==t&&b.length>=t,onClick:()=>g([...b,(0,u.y4)({id:(0,r.eq)(crypto.randomUUID()),label:"New scope",keys:null,key_path:[]})]),children:"Add Group"}),void 0!==t&&b.length>=t?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Each body allows up to ",t," groups."]}):null,y?(0,n.jsx)(m.lG,{open:!0,onOpenChange:e=>{e||v(null)},children:(0,n.jsxs)(m.Cf,{children:[(0,n.jsxs)(m.c7,{children:[(0,n.jsxs)(m.L3,{children:["Remove ",y.value.label,"?"]}),(0,n.jsx)(m.rr,{children:"Node memberships, needed groups and collection selectors will keep this groupâs ID. Repair or remove those references before publishing; removing this declaration does not change active runs."})]}),(0,n.jsxs)(m.Es,{children:[(0,n.jsx)(c.$,{type:"button",variant:"outline",onClick:()=>v(null),children:"Keep Group"}),(0,n.jsx)(c.$,{type:"button",variant:"destructive",disabled:f,onClick:()=>{g(b.filter(e=>e.value.id!==y.value.id)),v(null)},children:"Remove Group"})]})]})}):null]})}function k(e){let l=(0,h.yq)(),{row:t,index:a,onChange:s,onRemove:r,disabled:m=!1}=e,[y,k]=(0,i.useState)(null===t.value.keys),g=(0,i.useId)(),j=`Scope ${a+1}`,_=(0,x.j)({value:t.value.keys,buffer:{draft:t.keysDraft}
1,emptyDraft:null,onChange:(e,l,n)=>s({...t,value:{...t.value,keys:e},keysDraft:l,keysValid:n})}),w=(0,u.LE)(e,t.value),N=t.value.keys?(0,d.xJ)(e,t.value.keys):null,C=N?.kind==="available"?(0,d.df)(e,N.field):null,$=C?.kind==="available"?(0,d.wN)(C.field).filter(({field:e})=>(0,d.J1)(e)):[],I=JSON.stringify(t.value.key_path),S=$.some(({path:e})=>JSON.stringify(e)===I);return(0,n.jsxs)("section",{"aria-label":j,className:"min-w-0 space-y-3 border-b pb-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsx)(c.$,{type:"button",variant:"ghost",size:"sm","aria-expanded":y,onClick:()=>k(!y),children:y?`Close ${j}`:m?`View ${j}`:`Edit ${j}`}),(0,n.jsx)(c.$,{type:"button",variant:"ghost",size:"sm",disabled:m,onClick:r,children:"Remove Scope"})]}),w?(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[w," The draft keeps this declaration for repair."]}):null,y?(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)(b.j,{field:(0,o.P1)(l.modelPropertySchema("ControlScopeDefinition","label")),label:`${j} name`,value:t.value.label,buffer:t.label,disabled:m,onChange:(e,l)=>s({...t,value:{...t.value,label:"string"==typeof e?e:t.value.label},label:l})}),(0,n.jsx)(f.e,{...e,currentNodeId:null,target:null,sourcePurpose:"scope_keys",label:`${j} key collection`,value:t.value.keys,draft:t.keysDraft,disabled:m,..._}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)(p.J,{htmlFor:g,children:[j," stable key"]}),(0,n.jsx)(v.Hq,{id:g,label:`${j} stable key`,value:I,disabled:m||!$.length,describedBy:`${g}-help`,options:[...S?[]:[{value:I,label:`Unavailable key: ${t.value.key_path.join(" ⺠")||"Whole item"}`,disabled:!0}],...$.map(({path:e})=>({value:JSON.stringify(e),label:e.length?e.join(" ⺠"):"Whole item"}))],onChange:e=>{let l=$.find(({path:l})=>JSON.stringify(l)===e);l&&s({...t,value:{...t.value,key_path:l.path}})}}),(0,n.jsx)("p",{id:`${g}-help`,className:"text-xs text-muted-foreground",children:"Select a stable key from each item. Membership and consumer keys must match this field; changing the collection keeps your selected path for repair."})]})]}):(0,n.jsxs)("p",{className:"truncate text-sm",title:t.value.label,children:[t.value.label,t.label.valid&&t.keysValid?"":" â unfinished edits"]})]})}},34216:(e,l,t)=>{t.d(l,{d:()=>h});var n=t(37876),i=t(78392),a=t(7260),s=t(66810),r=t(98405),d=t(9314),o=t(28907),u=t(53840),c=t(1202),m=t(60230),p=t(81286),f=t(9510);function h({field:e,draft:l,onChange:t,label:i="Field",disabled:a=!1}){let s=(0,c.yq)(),r=(e,l)=>t({field:e,draft:l,valid:l.every(e=>e.valid)&&0===(0,u.qG)(s,e).length}),o=(0,u.qG)(s,e);return(0,n.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,n.jsx)(x,{field:e,draft:l,path:[],label:i,disabled:a,onChange:r,confirm:(e,l,t)=>r(l,t)}),o.length?(0,n.jsxs)(d.bg,{children:[o[0].path.length?`${o[0].path.join(" / ")}: `:"",o[0].message]}):null]})}function b({draft:e,path:l,label:t,field:i,value:a,disabled:s,formatHint:r,parseValue:d,onChange:o}){return(0,n.jsx)(m.j,{field:i,label:t,value:a,disabled:s,formatHint:r,buffer:(0,u.bq)(e,l),onChange:(t,n)=>{if(void 0===t)return;let i=d?d(t):t,s=n.valid&&void 0!==i,r=s?i:a,c=d&&(void 0===i||i!==t)?[{path:[],source:r,text:String(t),touched:!0}]:n.draft;o(r,(0,u.wP)(e,l,{draft:c,valid:s}))}})}function x(e){let l=(0,c.yq)(),{field:t,draft:m,path:h,label:y,disabled:k,onChange:g,confirm:j,allowedKinds:_=u.PE,typeOnly:w=!1}=e,N=t.type,C=(e,l=m)=>g({...t,type:e},l),$=(e,l,t,i,a)=>(0,n.jsx)(b,{draft:m,path:[...h,..."string"==typeof e?[e]:e],label:l,field:i,value:t,disabled:k,onChange:(e,l)=>{"string"==typeof e&&g(a(e),l)}},JSON.stringify(e)),I=(e,t,i,s)=>(0,n.jsx)(b,{draft:m,path:[...h,"type",e],label:t,field:(0,a.P1)(l.fieldTypePropertySchema(N.kind,e)),value:String(i),disabled:k,onChange:(e,l)=>{"string"==typeof e&&C(s(Number(e)),l)}},e),S=(e,l,t,i,a)=>(0,n.jsx)(x,{...a,field:e,draft:m,path:l,label:t,disabled:k,onChange:(e,l)=>g(i(e),l),confirm:(e,l,t)=>j(e,i(l),t)});return(0,n.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,n.jsxs)(d.D0,{children:[(0,n.jsxs)(d.dh,{children:[y," t
1ype"]}),(0,n.jsx)(f.i8,{label:`${y} type`,value:N.kind,disabled:k,options:_.map(e=>({value:e,label:u.tM[e]})),onChange:e=>{let l=_.find(l=>l===e);l&&l!==N.kind&&j(`Change ${y} type?`,{...t,type:(0,u.Ed)(l)},(0,u.j4)(m,[...h,"type"]))}})]}),w?null:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex flex-wrap gap-x-5 gap-y-3",children:[(0,n.jsxs)(d.D0,{orientation:"horizontal",children:[(0,n.jsx)(r.S,{"aria-label":`${y} required`,checked:t.required,disabled:k,onCheckedChange:e=>g({...t,required:e},m)}),(0,n.jsx)(d.dh,{children:"Required"})]}),(0,n.jsxs)(d.D0,{orientation:"horizontal",children:[(0,n.jsx)(r.S,{"aria-label":`${y} nullable`,checked:t.nullable,disabled:k,onCheckedChange:e=>g({...t,nullable:e},m)}),(0,n.jsx)(d.dh,{children:"Allow null"})]})]}),$("help",`${y} help`,t.help,(0,a.P1)(l.modelPropertySchema("FieldContract","help")),e=>({...t,help:e}))]}),"string"===N.kind||"list"===N.kind?(0,n.jsxs)("div",{className:"grid gap-3 @md:grid-cols-2",children:[I("minimum_length","Minimum length",N.minimum_length,e=>({...N,minimum_length:e})),I("maximum_length","Maximum length",N.maximum_length,e=>({...N,maximum_length:e}))]}):null,"integer"===N.kind||"decimal"===N.kind||"number"===N.kind?(0,n.jsx)("div",{className:"grid gap-3 @md:grid-cols-2",children:["minimum","maximum"].map(e=>(0,n.jsx)(b,{draft:m,path:[...h,"type",e],label:"minimum"===e?"Minimum":"Maximum",field:(0,a.P1)(l.fieldTypePropertySchema(N.kind,e)),parseValue:"number"===N.kind?void 0:t=>{if("string"!=typeof t)return;let n=l.fieldTypePropertySchema(N.kind,e).maxLength,i="integer"===N.kind?(0,o.zW)(t):(0,o.E)(t,"number"==typeof n?n:null),a=("integer"===N.kind?l.workflowIntegerSchema:l.workflowDecimalSchema).safeParse(i);return a.success?a.data:void 0},formatHint:"decimal"===N.kind?"Exact decimal; no exponent notation.":void 0,value:N[e],disabled:k,onChange:(l,t)=>{"number"===N.kind&&"number"==typeof l&&C({...N,[e]:l},t),("integer"===N.kind||"decimal"===N.kind)&&"string"==typeof l&&C({...N,[e]:l},t)}},e))}):null,"decimal"===N.kind?(0,n.jsxs)("div",{className:"grid gap-3 @md:grid-cols-2",children:[I("precision","Total digits",N.precision,e=>({...N,precision:e})),I("scale","Decimal places",N.scale,e=>({...N,scale:e}))]}):null,"enum"===N.kind?(0,n.jsx)(b,{draft:m,path:[...h,"type","values"],label:"Choices",field:(0,a.P1)(l.fieldTypePropertySchema("enum","values")),value:N.values,disabled:k,onChange:(e,l)=>{Array.isArray(e)&&e.every(e=>"string"==typeof e)&&C({...N,values:e},l)}}):null,"datetime"===N.kind?(0,n.jsx)(d.ry,{children:"Values use UTC with up to six fractional second digits."}):null,"list"===N.kind?(0,n.jsx)("div",{className:"border-l border-border pl-3",children:S(N.item,[...h,"type","item"],"List item",e=>({...t,type:{...N,item:e}}))}):null,"reference"===N.kind?(0,n.jsxs)(n.Fragment,{children:[$(["type","reference_kind"],"Reference kind",N.reference_kind,(0,a.P1)(l.fieldTypePropertySchema("reference","reference_kind")),e=>({...t,type:{...N,reference_kind:e}})),(0,n.jsx)(d.ry,{children:"Use the ownerâs registered reference kind. A reference does not grant access."}),(0,n.jsx)("div",{className:"border-l border-border pl-3",children:S((0,u.iO)(N.storage),[...h,"type","storage"],"Reference value",e=>"string"===e.type.kind||"integer"===e.type.kind||"object"===e.type.kind?{...t,type:{...N,storage:e.type}}:t,{typeOnly:!0,allowedKinds:["string","integer","object"]})})]}):null,"object"===N.kind?(0,n.jsxs)("div",{className:"space-y-4 border-l border-border pl-3",children:[N.members.map((e,r)=>(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:$(["type","members",r,"name"],"Field name",e.name,(0,a.P1)(l.modelPropertySchema("ObjectMember","name")),e=>({...t,type:{...N,members:N.members.map((l,t)=>t===r?{...l,name:e}:l)}}))}),(0,n.jsx)(s.$,{type:"button",variant:"ghost",size:"icon",disabled:k,"aria-label":`Remove ${e.name}`,onClick:()=>j(`Remove ${e.name}?`,{...t,type:{...N,members:N.members.filter((e,l)=>l!==r)}},(0,u.j4)(m,[...h,"type","members"],r)),children:(0,n.jsx)(i.WeY,{})})]}),S(e.field,[...h,"type","members",r],e.name,e=>({...t,type:{...N,members:N.members.map((l,t)=>t===r?{...l,field:e}:l)}}))]},r)),(0,n.jsxs)(s.$,{type:"button",variant:"outline",size:"sm",disabled:k||N.members.length>=((0,a.lu)(l.fieldTypePropertySchema("object","members"))??1/0),onClick:()=>{let e=N.members.length+1;for(;N.members.some(l=>l.name===`field_${e}`);)e++;C({...N,members:[...N.members,{name:`field_${e}`,field:(0,u.iO)()}]})},children:[(0,n.jsx)(i.QCG,{}),"Add Object Field"]})]}):null,"union"===N.kind?(0,n.jsx)(v,{...e,type:N}):null,w?null:(0,n.jsxs)("div",{className:"space-y-3 border-t border-border pt-3",children:[(0,n.jsxs)(d.D0,{orientation:"horizontal",children:[(0,n.jsx)(r.S,{"aria-label":`${y} default`,checked:null!==t.default,disabled:k,onCheckedChange:e=>g({...t,default:e?{value:(0,p.H6)({...t,default:null})}:null},(0,u.j4)(m,[...h,"default"]))}),(0,n.jsx)(d.dh,{children:"Use a default when omitted"})]}),null!==t.default?(0,n.jsx)(b,{draft:m,path:[...h,"default"],label:`${y} default value`,field:{...t,required:!0,default:null},value:t.default.value,disabled:k,onChange:(e,l)=>g({...t,default:{...t.default,value:e}},l)}):null]})]})}function v({field:e,draft:l,path:t,disabled:r,onChange:d,confirm:o,type:m}){let p=(0,c.yq)(),f=(t,n=l)=>d({...e,type:t},n);return(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)(b,{draft:l,path:[...t,"type","discriminator"],label:"Type field name",field:(0,a.P1)(p.fieldTypePropertySchema("union","discriminator")),value:m.discriminator,disabled:r,onChange:(e,l)=>
1{"string"==typeof e&&f({...m,discriminator:e,cases:m.cases.map(l=>({...l,field:{...l.field,members:l.field.members.map(l=>l.name===m.discriminator?{...l,name:e}:l)}}))},l)}}),m.cases.map((d,c)=>(0,n.jsxs)("div",{className:"space-y-3 border-l border-border pl-3",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsx)(b,{draft:l,path:[...t,"type","cases",c,"tag"],label:"Type choice",field:(0,a.P1)(p.modelPropertySchema("UnionCase","tag")),value:d.tag,disabled:r,onChange:(e,l)=>{"string"==typeof e&&f({...m,cases:m.cases.map((l,t)=>t===c?{...l,tag:e,field:{...l.field,members:l.field.members.map(l=>l.name===m.discriminator?{...l,field:{...l.field,type:"enum"===l.field.type.kind?{...l.field.type,values:[e]}:{kind:"enum",values:[e]}}}:l)}}:l)},l)}})}),(0,n.jsx)(s.$,{type:"button",variant:"ghost",size:"icon",disabled:r||m.cases.length<=2,"aria-label":`Remove ${d.tag}`,onClick:()=>o(`Remove ${d.tag}?`,{...e,type:{...m,cases:m.cases.filter((e,l)=>l!==c)}},(0,u.j4)(l,[...t,"type","cases"],c)),children:(0,n.jsx)(i.WeY,{})})]}),(0,n.jsx)(x,{field:(0,u.iO)({...d.field,members:d.field.members.filter(e=>e.name!==m.discriminator)}),draft:l,path:[...t,"type","cases",c,"field"],label:`${d.tag} fields`,disabled:r,typeOnly:!0,allowedKinds:["object"],onChange:(e,l)=>{if("object"===e.type.kind){let t=e.type.members;f({...m,cases:m.cases.map((e,l)=>l===c?{...e,field:{...e.field,kind:"object",members:[e.field.members.find(e=>e.name===m.discriminator)??(0,u.qV)(m.discriminator,d.tag),...t]}}:e)},l)}},confirm:(l,t,n)=>{if("object"===t.type.kind){let i=t.type.members;o(l,{...e,type:{...m,cases:m.cases.map((e,l)=>l===c?{...e,field:{...e.field,kind:"object",members:[e.field.members.find(e=>e.name===m.discriminator)??(0,u.qV)(m.discriminator,d.tag),...i]}}:e)}},n)}}})]},c)),(0,n.jsxs)(s.$,{type:"button",variant:"outline",size:"sm",disabled:r||m.cases.length>=((0,a.lu)(p.fieldTypePropertySchema("union","cases"))??1/0),onClick:()=>{let e=m.cases.length+1;for(;m.cases.some(l=>l.tag===`type_${e}`);)e++;let l=`type_${e}`;f({...m,cases:[...m.cases,{tag:l,field:{kind:"object",members:[(0,u.qV)(m.discriminator,l)]}}]})},children:[(0,n.jsx)(i.QCG,{}),"Add Type Choice"]})]})}},36937:(e,l,t)=>{t.d(l,{A:()=>s});var n=t(37876),i=t(59867),a=t(9330);function s({buffer:e,onChange:l,...t}){let r=(0,a.j)({buffer:e,value:t.value,emptyDraft:null,onChange:(e,t,n)=>l(e,{kind:"binding",draft:t,valid:n})});return(0,n.jsx)(i.e,{...t,draft:e?.draft,...r})}},39036:(e,l,t)=>{t.d(l,{D2:()=>a,Jj:()=>s,R7:()=>r});var n=t(41946),i=t.n(n);function a(e,l){return`${e.id}:inputs:${JSON.stringify(l)}`}function s(e,l,t){let n=e.inputs.findIndex(e=>i()(e.target,l));return -1===n?null===t?e:{...e,inputs:[...e.inputs,{target:l,source:t}]}:{...e,inputs:null===t?e.inputs.filter((e,l)=>l!==n):e.inputs.map((e,i)=>i===n?{target:l,source:t}:e)}}function r(e,l){return e.inputs.find(e=>!i()(e.target,l)&&(e.target.every((e,t)=>l[t]===e)||l.every((l,t)=>e.target[t]===l)))?.target??null}},40410:(e,l,t)=>{t.d(l,{V:()=>g,a:()=>k});var n=t(37876),i=t(14232),a=t(33004),s=t(57195),r=t(4141),d=t(30258),o=t(88717),u=t(66810),c=t(19357),m=t(63492),p=t(53840),f=t(60230),h=t(9510);let b=["wait_all_selected","wait_all_outcomes","first_success","n_successes"],x=(0,p.iO)({kind:"string",minimum_length:1,maximum_length:255});function v(e){return e.map(e=>({kind:"path_end",path_id:e}))}function y(e){let[l]=(0,i.useState)(()=>new Map(e.map(e=>[(0,r.K6)(e.source),e.id]))),[t]=(0,i.useState)(()=>new Map(e.map(e=>[(0,r.K6)(e.source),e.source])));return(e,n)=>{let i=new Map(n.map(e=>[e.key,e]));return e.flatMap(e=>{let n=i.get(e)?.source??t.get(e);if(!n)return[];let s=l.get(e);return s||(s=(0,a.b9)(crypto.randomUUID()),l.set(e,s)),[{id:s,source:n}]})}}function k({context:e,kind:l,initialSelectorId:t,disabled:a=!1,onCreate:p}){let f=(0,s.d7)(e),b=(0,r.Lj)(e,null),x=f.selectors.find(e=>e.id===t),[g,j]=(0,i.useState)(x?"selector":f.paths.length?"paths":"endpoints"),[_,w]=(0,i.useState)(x?.id??""),[N,C]=(0,i.useState)([]),[$,I]=(0,i.useState)([]),S=y([]),[A,D]=(0,i.useState)("1"),R=f.selectors.find(e=>e.id===_),O=f.paths.filter(e=>N.includes(e.id)),q="selector"===g?R?.pathIds??[]:N,M=b.filter(e=>
1$.includes(e.key)),P="endpoints"===g?$.length:q.length,E=/^\d+$/u.test(A)?Number(A):0,F=P>0&&P<=100&&("n_successes"!==l||E>=1&&E<=P),T="endpoints"===g?M.map(e=>e.source):v(q),J="n_successes"===l?(0,o.E)(e.definition,T,E,e.catalogue.callInterfaces??[]):null,z="endpoints"===g?"Events required":"Required successes",V="selector"===g?f.paths.filter(e=>q.includes(e.id)):"paths"===g?O:M;return(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:(0,d.sF)(l,g)}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose the exact path, task, join, or workflow events this shared continuation observes."})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{children:"Source type"}),(0,n.jsx)(h.i8,{label:"New join source type",value:g,disabled:a,options:[{value:"selector",label:"All paths from one decision"},{value:"paths",label:"Chosen paths"},{value:"endpoints",label:"Exact events"}],onChange:e=>{("selector"===e||"paths"===e||"endpoints"===e)&&j(e)}})]}),"selector"===g?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{children:"Decision"}),(0,n.jsx)(h.Hq,{label:"New join decision",value:_,options:f.selectors.map(e=>({value:e.id,label:e.label})),disabled:a,placeholder:"Choose a decisionâ¦",onChange:w})]}):"paths"===g?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{children:"Paths"}),(0,n.jsx)(h.km,{label:"New join paths",value:N,options:f.paths.map(e=>({value:e.id,label:e.label})),disabled:a,placeholder:"Choose sibling pathsâ¦",onChange:e=>{C(e.map(e=>f.paths.find(l=>l.id===e)).filter(e=>void 0!==e).slice(0,100).map(e=>e.id))}})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{children:"Events"}),(0,n.jsx)(h.km,{label:"New join events",value:$,options:b.map(e=>({value:e.key,label:e.label})),disabled:a,placeholder:"Choose task, path, join, or workflow eventsâ¦",onChange:e=>I(e.slice(0,100))})]}),"n_successes"===l?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{htmlFor:"new-join-threshold",children:z}),(0,n.jsx)(c.p,{id:"new-join-threshold","aria-label":`New join ${z.toLocaleLowerCase()}`,type:"number",inputMode:"numeric",min:1,max:Math.max(1,P),value:A,disabled:a,onChange:e=>D(e.target.value)}),(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Choose 1 to ",Math.max(1,P),"."]})]}):null,J?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:J}):null,(0,n.jsxs)("section",{"aria-label":"Join preview",className:"space-y-2 rounded-lg border p-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Shared continuation preview"}),V.length?(0,n.jsx)("ul",{className:"space-y-1 text-sm",children:V.map(e=>(0,n.jsx)("li",{children:e.label},"id"in e?e.id:e.key))}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose at least one source before adding this join."}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"One continuation runs under this rule. The join observes these sources and does not stop them."})]}),(0,n.jsx)(u.$,{type:"button",disabled:a||!F||null!==J,onClick:()=>{let e="selector"===g&&R?{kind:"selector",selector_id:R.id}:"paths"===g&&N.length?{kind:"paths",path_ids:N}:"endpoints"===g&&$.length?{kind:"endpoints",endpoints:S($,b)}:null;e&&p(e,E)},children:"Add Shared Continuation"})]})}function g(e){let{node:l,fields:t,disabled:a=!1,onChange:c,onOpenBody:p}=e,k=(0,i.useId)(),g=(0,i.useId)(),j=l.source,_=(0,s.d7)(e,l),w=(0,r.Lj)(e,l.id),N="endpoints"===j.kind?j.endpoints:[],C=y(N),$=N.map(e=>(0,r.K6)(e.source)),[I,S]=(0,i.useState)(j.kind),[A,D]=(0,i.useState)($),R="n_successes"===l.kind?{...l,minimum_successes:1}:l,O=(0,s.et)(e,R),q=(0,s.Y3)(e,R),M="endpoints"===I?A.length:"available"===O.kind?O.candidates.length:"paths"===j.kind?j.path_ids.length:0,P=new Map("available"===O.kind?O.candidates.map(e=>[e.id,e.label]):[]),E=`${l.continuation.id}:label`,F=t[E],T=`${l.id}:minimum-successes`,J=t[T],z=_.selectors.some(e=>"selector"===l.source.kind&&e.id===l.source.selector_id),V=new Set(_.paths.map(e=>e.id)),L="paths"===j.kind?j.path_ids.filter(e=>!V.has(e)):[],K="selector"===j.kind?_.selectors.find(e=>e.id===j.selector_id):"paths"===j.kind?_.selectors.find(e=>j.path_ids.every(l=>e.pathIds.includes(l))):void 0,U=new Map(N.map(e=>[(0,r.K6)(e.source),e])),B=new Set(w.map(e=>e.key)),G=A.filter(e=>!B.has(e)).map(e=>{let l=U.get(e);return{value:e,label:l?P.get(l.id)??"Unavailable event":"Unavailable event",disabled:!0}}),W=C(A,w),H="endpoints"===I?W.map(e=>e.source):"selector"===j.kind?v(_.selectors.find(e=>e.id===j.selector_id)?.pathIds??[]):"paths"===j.kind?v(j.path_ids):[],Y="n_successes"===l.kind?(0,o.E)(e.definition,H,l.minimum_successes,e.catalogue.callInterfaces??[]):null,X="endpoints"===I?"Events required":"Required successes",Q=(e,t)=>{if(t<1)return;let n=(0,d.$$)(l,e);if("n_successes"===l.kind){let i=l.minimum_successes>t;c({...l,source:e,label:n.label,minimum_successes:i?t:l.minimum_successes},void 0,i?[T]:void 0);return}c({...l,source:e,label:n.label})};return(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-5",children:[(0,n.jsx)("legend",{className:"text-sm font-medium",children:"Join sources"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"A join observes chosen events or paths, then opens one governed continuation."}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{htmlFor:`${k}-kind`,children:"Join rule"}),(0,n.jsx)(h.i8,{id:`${k}-kind`,label:"Join rule",value:l.kind,disabled:a,options:b.map(e=>({value:e,label:(0,d.l9)(e,I)})),onChange:e=>{(0,d.Wf)(e)&&c((0,d.iD)(l,e),void 0,"n_successes"===e?void 0:[T])}})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{htmlFor:`${k}-source`,children:"Source type"}),(0,n.jsx)(h.i8,{id:`${k}-source`,label:"Source type",value:I,disabled:a,options:[{value:"selector",label:"All paths from one decision",disabled:"selector"!==j.kind&&!K},{value:"paths",label:"Chosen paths",disabled:"endpoints"===j.kind},{value:"endpoints",label:"Exact events"}],onChange:e=>{"endpoints"===e?(S("endpoints"),A.length&&Q({kind:"endpoints",endpoints:W},A.length)):"paths"===e&&"available"===q.kind?(S("paths"),Q({kind:"paths",path_ids:q.paths.map(e=>e.id)},q.paths.length)):"selector"===e&&K&&(S("selector"),Q({kind:"selector",selector_id:K.id},K.pathIds.length))}})]}),"selector"===I&&"selector"===j.kind?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{htmlFor:g,children:"Decision"}),(0,n.jsx)(h.Hq,{id:g,label:"Decision",value:j.selector_id,options:[...z?[]:[{value:j.selector_id,label:"Unavailable decision",disabled:!0}],..._.selectors.map(e=>({value:e.id,label:e.label}))],disabled:a,placeholder:"Choose a decisionâ¦",onChange:e=>{let l=_.selectors.find(l=>l.id===e);l&&Q({kind:"selector",selector_id:l.id},l.pathIds.length)}})]}):"paths"===I&&"paths"===j.kind?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{children:"Paths"}),(0,n.jsx)(h.km,{label:"Paths",value:j.path_ids,options:[...L.map(e=>({value:e,label:"Unavailable path",disabled:!0})),..._.paths.map(e=>({value:e.id,label:e.label}))],disabled:a,placeholder:"Choose sibling pathsâ¦",onChange:e=>{let l=e.map(e=>_.paths.find(l=>l.id===e)).filter(e=>void 0!==e).slice(0,100);Q({kind:"paths",path_ids:l.map(e=>e.id)},l.length)}})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(m.J,{children:"Events"}),(0,n.jsx)(h.km,{label:"Events",value:A,options:[...G,...w.map(e=>({value:e.key,label:e.label}))],disabled:a,placeholder:"Choose task, path, join, or workflow eventsâ¦",onChange:e=>{let l=e.slice(0,100);D(l);let t=C(l,w);t.length&&Q({kind:"endpoints",endpoints:t},t.length)}}),0===A.length?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Choose at least one event."}):null]}),"n_successes"===l.kind?(0,n.jsx)(f.j,{field:{type:{kind:"integer",minimum:"1",maximum:String(Math.max(1,Math.min(100,M)))},required:!0,nullable:!1,default:null,help:"endpoints"===I?"Open the continuation after this many source events are reached.":"Open the continuation after this many source paths succeed."},label:X,value:String(l.minimum_successes),buffer:J?.kind==="field"?J:void 0,disabled:a||0===M,onChange:(e,t)=>
1c({...l,minimum_successes:t.valid&&"string"==typeof e?Number(e):l.minimum_successes},{key:T,buffer:{...t,kind:"field"}})}):null,"unavailable"===O.kind?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:O.reason}):(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[M," ","endpoints"===j.kind?1===M?"candidate":"candidates":1===M?"path":"paths"," ","governed by this join."]}),Y?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Y}):null,(0,n.jsxs)("section",{"aria-label":"Governed continuation",className:"space-y-3 border-t pt-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Governed continuation"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"These steps run only when the join rule releases them. They can use the joined result."})]}),(0,n.jsx)(f.j,{field:x,label:"Continuation name",value:l.continuation.label,buffer:F?.kind==="field"?F:void 0,disabled:a,onChange:(e,t)=>c({...l,continuation:{...l.continuation,condition:null,label:"string"==typeof e?e:l.continuation.label}},{key:E,buffer:{...t,kind:"field"}})}),p?(0,n.jsxs)(u.$,{type:"button",variant:"outline",disabled:a,onClick:()=>p(l.continuation),children:["Edit ",l.continuation.label," Body"]}):null]})]})}},53292:(e,l,t)=>{t.d(l,{f:()=>c});var n=t(37876),i=t(14232),a=t(7260),s=t(68714),r=t(66810),d=t(1202),o=t(60230),u=t(64308);function c(e){let l=(0,d.yq)(),{node:t,fields:o,onChange:u,onOpenBody:c,disabled:h=!1}=e,b=(0,a.lu)(l.nodePropertySchema(t.kind,"branches")),x="first_match"===t.kind,v="parallel"!==t.kind,y="filter"===t.kind||"if_else"===t.kind,k="first_match"===t.kind||"all_matches"===t.kind,g="first_match"===t.kind?"First match paths":"all_matches"===t.kind?"All matches paths":"parallel"===t.kind?"Parallel paths":"filter"===t.kind?"Filter path":"If / Else paths",j="first_match"===t.kind?"Checks paths from top to bottom. The first matching path runs, and later paths do not. A waiting path holds later paths; an unavailable path is skipped.":"all_matches"===t.kind?"Each matching path runs. More than one path can run, and a waiting path does not hold back another path that is ready.":"parallel"===t.kind?"Every path runs once its inputs are ready. Paths do not wait for one another.":"filter"===t.kind?"Continue runs when the condition is true. If it is false or unavailable, this decision ends without running the path.":"Yes runs when the condition is true. No runs when it is false. If the condition is unavailable, neither path runs.",_="filter"===t.kind?"Set the condition for Continue.":"if_else"===t.kind?"Set the condition used to choose Yes or No.":void 0,w=(e,l)=>{let n="parallel"===t.kind?{...e,condition:null}:e;u({...t,branches:t.branches.map(e=>e.id===n.id?n:e)},l)};return(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-4",children:[(0,n.jsx)("legend",{className:"text-sm font-medium",children:g}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:j}),t.branches.length?null:(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["No paths yet. Add a path and name it",v?", then set its condition":"","."]}),t.branches.map((l,n)=>{let a="filter"===t.kind?"Continue":"if_else"===t.kind?"Yes":`Path ${n+1}`;return(0,i.createElement)(m,{...e,key:l.id,branch:l,selectorId:t.id,title:a,order:x?`Priority ${n+1}`:null,nameEditable:!y,conditionEditable:v,conditionDescription:_,actionsEditable:!y,focusOnSelect:e.focusedBranchId===l.id,fields:o,disabled:h,onChange:w,onMoveUp:()=>{let e=[...t.branches];[e[n-1],e[n]]=[e[n],e[n-1]],u({...t,branches:e})},onMoveDown:()=>{let e=[...t.branches];[e[n+1],e[n]]=[e[n],e[n+1]],u({...t,branches:e})},moveUpDisabled:0===n,moveDownDisabled:n===t.branches.length-1,onRemove:()=>u({...t,branches:t.branches.filter(e=>e.id!==l.id)},void 0,[`${l.id}:label`,`${l.id}:condition`]),onOpenBody:c})}),y?null:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.$,{type:"button",variant:"outline",disabled:h||t.branches.length>=(b??1/0),onClick:()=>u({...t,branches:[...t.branches,(0,s.c)(l,`Path ${t.branches.length+1}`)]}),children:"Add Path"}),void 0!==b?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Use up to ",b," paths."]}):null]}),k?(0,n.jsxs)("section",{"aria-label":"Otherwise",className:"space-y-3 border-t pt-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Otherwise"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Runs after all path conditions settle when no named path matches."})]}),t.otherwise?(0,n.jsx)(p,{branch:t.otherwise,fields:o,disabled:h,onChange:(e,l)=>u({...t,otherwise:{...e,condition:null}},l),onRemove:()=>u({...t,otherwise:null},void 0,[`${t.otherwise?.id}:label`]),onOpenBody:c}):(0,n.jsx)(r.$,{type:"button",variant:"outline",disabled:h,onClick:()=>u({...t,otherwise:(0,s.c)(l,"Otherwise")}),children:"Add Otherwise"})]}):null,"if_else"===t.kind&&t.otherwise?(0,n.jsxs)("section",{"aria-label":"No",className:"space-y-3 border-t pt-4",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"No"}),(0,n.jsx)(f,{branch:t.otherwise,title:"No",disabled:h,onOpenBody:c})]}):null]})}function m(e){let l=(0,d.yq)(),{branch:t,selectorId:s,title:c,order:m,nameEditable:p,conditionEditable:h,conditionDescription:b,actionsEditable:x,focusOnSelect:v,fields:y,disabled:k,onChange:g,onMoveUp:j,onMoveDown:_,moveUpDisabled:w,moveDownDisabled:N,onRemove:C,onOpenBody:$,renderConditionPreview:I}=e,S=`${t.id}:label`,A=`${t.id}:condition`,D=y[S],R=y[A],O=(0,i.useRef)(null);return(0,i.useEffect)(()=>{v&&O.current?.focus({preventScroll:!0})},[v]),(0,n.jsxs)("section",{ref:O,"aria-label":c,className:"min-w-0 space-y-3 border-b pb-4 outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:v?-1:void 0,children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:c}),m?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:m}):null]}),x?(0,n.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(0,n.jsx)(r.$,{type:"button",size:"sm",variant:"ghost","aria-label":`Move ${c} Up`,disabled:k||w,onClick:j,children:"Move Up"}),(0,n.jsx)(r.$,{type:"button",size:"sm",variant:"ghost","aria-label":`Move ${c} Down`,disabled:k||N,onClick:_,children:"Move Down"}),(0,n.jsx)(r.$,{type:"button",size:"sm",variant:"ghost",disabled:k,onClick:C,children:"Remove Path"})]}):null]}),p?(0,n.jsx)(o.j,{field:(0,a.P1)(l.modelPropertySchema("RoutingBranch","label")),label:`${c} name`,value:t.label,buffer:D?.kind==="field"?D:void 0,disabled:k,onChange:(e,l)=>g({...t,label:"string"==typeof e?e:t.label},{key:S,buffer:{...l,kind:"field"}})}):null,h?(0,n.jsx)(u.b,{...e,currentNodeId:s,label:`${c} condition`,description:b,value:t.condition,buffer:R?.kind==="rule"?R:void 0,disabled:k,onChange:(e,l)=>g({...t,condition:e},{key:A,buffer:l})}):null,h&&t.condition&&I?I(t):null,(0,n.jsx)(f,{branch:t,title:c,disabled:k,onOpenBody:$})]})}function p({branch:e,fields:l,disabled:t,onChange:i,onRemove:s,onOpenBody:u}){let c=(0,d.yq)(),m=`${e.id}:label`,h=l[m];return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)(o.j,{field:(0,a.P1)(c.modelPropertySchema("RoutingBranch","label")),label:"Otherwise name",value:e.label,buffer:h?.kind==="field"?h:void 0,disabled:t,onChange:(l,t)=>
1i({...e,label:"string"==typeof l?l:e.label,condition:null},{key:m,buffer:{...t,kind:"field"}})}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)(f,{branch:e,title:"Otherwise",disabled:t,onOpenBody:u}),(0,n.jsx)(r.$,{type:"button",variant:"ghost",disabled:t,onClick:s,children:"Remove Otherwise"})]})]})}function f({branch:e,title:l,disabled:t,onOpenBody:i}){if(!i)return null;let a=e.label.trim()||l;return(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.body.nodes.length," step",1===e.body.nodes.length?"":"s"," in this path"]}),(0,n.jsxs)(r.$,{type:"button",size:"sm",variant:"outline",onClick:()=>i(e),children:[t?"View":"Edit"," ",a," Body"]})]})}},57148:(e,l,t)=>{t.d(l,{a:()=>p,h:()=>u});var n=t(37876),i=t(7260),a=t(34216),s=t(1202),r=t(36937),d=t(60230),o=t(64308);let u={type:{kind:"boolean"},required:!0,nullable:!1,default:null,help:""};function c(e,l){return`${e}:${l}`}function m(e,l){return`${e}:inputs:${JSON.stringify(l)}`}function p(e){let l=(0,s.yq)(),{node:t}=e,u=c(t.id,"maximum_iterations"),p=c(t.id,"maximum_duration_seconds"),f=m(t.id,["state","initial"]),h=m(t.id,["state","next"]),b=`${t.id}:condition`,x=e.fields[u],v=e.fields[p],y=e.fields[f],k=e.fields[h],g=e.fields[b],j={...e.context,currentNodeId:t.id},_={...e.context,scopePath:[...e.context.scopePath,t.id],currentNodeId:t.id},w={...j,conditionLoopId:t.id},N=(l,n,i)=>{let a=c(t.id,l);e.onChange({...t,[l]:i.valid?Number(n):t[l]},{key:a,buffer:i})},C=(l,n,i,a)=>e.onChange({...t,state:{...t.state,[n]:i}},{key:m(t.id,l),buffer:a});return(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"while"===t.kind?"Checks the condition before each body. If it is false at the start, the body does not run.":"Runs the body once, then checks. The first iteration always runs."}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Loop state"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Each iteration receives a typed value. Name the type as an integer, text, true or false, or a record â not a storage format."}),(0,n.jsx)(a.d,{label:"State type",field:t.state.field,draft:[],disabled:e.disabled,onChange:l=>e.onChange({...t,state:{...t.state,field:l.field}})}),(0,n.jsx)(r.A,{...j,label:"Initial state",target:t.state.field,literalField:t.state.field,sourcePurpose:"value",value:t.state.initial,buffer:y?.kind==="binding"?y:void 0,disabled:e.disabled,onChange:(e,l)=>C(["state","initial"],"initial",e,l)}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"while"===t.kind?"The first check receives this value. It cannot read this loopâs later state. If the condition is false here, the body does not run.":"The first body receives this value. It cannot read this loopâs later state. The first iteration always runs."}),e.lockNext?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"text-sm",children:"Next state is this waitâs Read output. A frozen workflow input cannot be polled."}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Delay runs only when the Filterâs Continue path matches: the read is not yet ready. Until still checks after the body, so a ready read does not wait out the delay."})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.A,{..._,label:"Next state",target:t.state.field,literalField:t.state.field,sourcePurpose:"value",value:t.state.next,buffer:k?.kind==="binding"?k:void 0,disabled:e.disabled,onChange:(e,l)=>C(["state","next"],"next",e,l)}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose the value the next iteration receives from this loopâs body."})]})]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Condition"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"while"===t.kind?"Checked before each body. False at the start means zero bodies.":"Checked after each body. The body always runs once before this check."}),(0,n.jsx)(o.b,{...w,label:"Loop condition",disabled:e.disabled,value:t.condition,buffer:g?.kind==="rule"?g:void 0,description:"while"===t.kind?"The body runs only while this is true. False at the start means zero bodies.":"The body always runs once, then this check decides whether to repeat.",onChange:(l,n)=>e.onChange({...t,condition:l},{key:b,buffer:n}
1)})]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Limits"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"The loop stops on the first limit it reaches. An unhandled Limit reached exit fails the loop."}),(0,n.jsx)(d.j,{field:(0,i.Cd)(l,t.kind,"maximum_iterations","The loop takes Limit reached if it would start another body after this many completed iterations."),label:"Maximum iterations",value:String(t.maximum_iterations),buffer:x?.kind==="field"?x:void 0,disabled:e.disabled,onChange:(e,l)=>N("maximum_iterations",e,{...l,kind:"field"})}),(0,n.jsx)(d.j,{field:(0,i.Cd)(l,t.kind,"maximum_duration_seconds","The loop takes Limit reached at or after this many seconds, even with a body still running."),label:"Maximum duration in seconds",value:String(t.maximum_duration_seconds),buffer:v?.kind==="field"?v:void 0,disabled:e.disabled,onChange:(e,l)=>N("maximum_duration_seconds",e,{...l,kind:"field"})})]})]})}},58439:(e,l,t)=>{t.d(l,{$S:()=>A,J5:()=>R,dA:()=>D,po:()=>N,tm:()=>S});var n=t(41946),i=t.n(n),a=t(48416),s=t(88113),r=t(65752),d=t(9516),o=t(43374),u=t(71793);let c="workflow-editor-draft-v1";function m(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function p(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e||"number"==typeof e)}function f(e){return Array.isArray(e)&&e.every(e=>m(e)&&p(e.path)&&"string"==typeof e.text&&"boolean"==typeof e.touched&&(void 0===e.source||a.Ws.safeParse(e.source).success))}function h(e){return Array.isArray(e)&&e.every(e=>m(e)&&p(e.path)&&f(e.draft)&&"boolean"==typeof e.valid)}function b(e,l){return m(l)&&(null===l.value||e.workflowBindingSchema.safeParse(l.value).success)&&(null===l.draft||x(e,l.draft))}function x(e,l){if(!m(l)||!m(l.editor)||null!==l.source&&!e.workflowBindingSchema.safeParse(l.source).success)return!1;let t=l.editor;switch(t.kind){case"fold":return("any"===t.operation||"append_unique"===t.operation)&&e.workflowFieldContractSchema.safeParse(t.field).success&&h(t.contractDraft)&&"boolean"==typeof t.contractValid&&Array.isArray(t.sources)&&t.sources.length>0&&t.sources.every(l=>b(e,l));case"conditional":return[t.operand,t.match,t.whenEqual,t.otherwise].every(l=>b(e,l));case"project":return("first"===t.operation||"non_null"===t.operation)&&b(e,t.source);case"object_value":return e.workflowFieldContractSchema.safeParse(t.field).success&&Array.isArray(t.members)&&t.members.every(l=>m(l)&&"string"==typeof l.name&&(null===l.value||e.workflowBindingSchema.safeParse(l.value).success)&&(null===l.draft||x(e,l.draft)));case"list_value":return e.workflowFieldContractSchema.safeParse(t.field).success&&Array.isArray(t.items)&&t.items.every(l=>m(l)&&(null===l.value||e.workflowBindingSchema.safeParse(l.value).success)&&(null===l.draft||x(e,l.draft)));case"reference":return["workflow_input","iteration_item","loop_state","loop_iteration","loop_exit_output","join_result","node_output","call_exit_output","node_outcome"].includes("string"==typeof t.source?t.source:"")&&(null===t.value||e.workflowBindingSchema.safeParse(t.value).success);case"literal":return e.workflowFieldContractSchema.safeParse(t.field).success&&(void 0===t.value||a.Ws.safeParse(t.value).success)&&f(t.fieldDraft)&&h(t.contractDraft)&&"boolean"==typeof t.contractValid;case"keyed_output":return(null===t.producerId||"string"==typeof t.producerId)&&(null===t.outputId||"string"==typeof t.outputId)&&(null===t.key||e.workflowScalarBindingSchema.safeParse(t.key).success)&&(null===t.keyDraft||x(e,t.keyDraft))&&(null===t.path||p(t.path));case"collection_outcomes":return(null===t.producerId||"string"==typeof t.producerId)&&(null===t.outputId||"string"==typeof t.outputId)&&("whole_collection"===t.selection||"scope"===t.selection)&&(null===t.scopeId||"string"==typeof t.scopeId)&&(null===t.key||e.workflowScalarBindingSchema.safeParse(t.key).success)&&(null===t.keyDraft||x(e,t.keyDraft));case"first_available":return Array.isArray(t.alternatives)&&t.alternatives.every(l=>m(l)&&(null===l.value||e.workflowBindingSchema.safeParse(l.value).success)&&(null===l.draft||x(e,l.draft)));default:return!1}}let v=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;function y(e){return null===e||"string"==typeof e&&v.test(e)}function k(e){return"string"==typeof e&&v.test(e)}function g(e,l){var t;return m(l)&&k(l.id)&&"string"==typeof l.label&&(null===l.keys||e.workflowBindingSchema.safeParse(l.keys).success)&&Array.isArray(t=l.key_path)&&t.every(e=>"string"==typeof e)}function j(e,l){return m(l)&&k(l.scope_id)&&e.workflowScalarBindingSchema.safeParse(l.key).success&&(void 0===l.consumer||null===l.consumer||"string"==typeof l.consumer)}function _(e,l){return m(l)&&(void 0===l.consumer||null===l.consumer||"string"==typeof l.consumer)&&y(l.scopeId)&&(null===l.key||e.workflowScalarBindingSchema.safeParse(l.key).success)&&(null===l.keyDraft||x(e,l.keyDraft))&&"boolean"==typeof l.keyValid&&"boolean"==typeof l.many&&"boolean"==typeof l.inferredMany}function w(e){if(m(e.raw)&&e.raw.format===c)return e.raw.draft}function N(e,l){return`${e}:set-values:${JSON.stringify(l)}`}function C(e,l=[]){let t=[l.slice()];for(let n of e.nodes)for(let e of(0,d.RX)(n))t.push(...C(e.definition,[...l,...e.path]));return t}function $(e,l){if("scope_recoveries"===l.kind||"scope_definitions"===l.kind)return e.scopePaths.some(e=>{var t;return t=l.scope_path,e.length===t.length&&e.every((e,l)=>e===t[l])});if("path_condition"===l.kind)return e.pathIds.has(l.path_id);if("node_field"===l.kind&&"timeout"===l.field&&e.timeoutOwnerIds.has(l.node_id))return!0;let t=e.nodes.get(l.node_id);if(!t)return!1;if("node_input"===l.kind)return"task"===t.kind||"workflow"===t.kind||"stop_branch"===t.kind||"return"===t.kind||"resume"===t.kind||"respond"===t.kind||"compensate"===t.kind||(0,a.bm)(t)||(0,a.lP)(t);if("node_scope_links"===l.kind)return!0;
1if("node_field"===l.kind)return"wait_schema"===l.field?"task"===t.kind:"label"===l.field||("retry"===l.field?"task"===t.kind||"workflow"===t.kind:"timeout"===l.field?(0,s.tH)(t):"reason"===l.field?"fail_workflow"===t.kind||"stop_branch"===t.kind:"minimum_successes"===l.field?"n_successes"===t.kind:"count"===l.field?"repeat_n"===t.kind:"batch_size"===l.field?"for_each_batch"===t.kind:"maximum_iterations"===l.field?"repeat_n"===t.kind||(0,a.bm)(t):"maximum_duration_seconds"===l.field?(0,a.bm)(t):"collection"===l.field||"maximum_items"===l.field?"for_each"===t.kind||"for_each_batch"===t.kind:"key"===l.field?(0,a.$j)(t):"requests"===l.field||"interval_seconds"===l.field?"rate_limit"===t.kind:"window_seconds"===l.field?"item_deduplicate"===t.kind:"exit_label"===l.field?"return"===t.kind:"concurrency"===l.field&&((0,a.lQ)(t)||"concurrency_limit"===t.kind));if("set_values_field"===l.kind){if("return"===t.kind||"resume"===t.kind||"respond"===t.kind)return(0,u.nZ)(t).some(e=>e.declaration.id===l.field_name);if("task"!==t.kind)return!1;let e=t.inputs.find(e=>0===e.target.length)?.source;return e?.kind==="object_value"&&"object"===e.field.type.kind&&e.field.type.members.some(e=>e.name===l.field_name)}return!1}function I(e,l,t){let n;return{target:e,edit_kind:l,raw:(n=JSON.parse(JSON.stringify(t)),{format:c,draft:
1a.Ws.parse(n)})}}function S(e,l,t=[]){let n=[...t];for(let[t,i]of Object.entries(l)){let l=function(e,l,t){let n=l.match(/^([0-9a-f-]{36}):inputs:(\[.*\])$/u);if(n&&v.test(n[1])){let e;try{e=JSON.parse(n[2])}catch{return null}if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return{kind:"node_input",node_id:n[1],path:e}}let i=l.match(/^([0-9a-f-]{36}):(label|collection|count|batch_size|maximum_iterations|maximum_duration_seconds|maximum_items|concurrency|minimum-successes|wait_schema|reason|retry|timeout|key|requests|interval_seconds|window_seconds|exit_label)$/u);if(i&&v.test(i[1])){let e="minimum-successes"===i[2]?"minimum_successes":i[2];return"label"!==e&&"collection"!==e&&"count"!==e&&"batch_size"!==e&&"maximum_iterations"!==e&&"maximum_duration_seconds"!==e&&"maximum_items"!==e&&"concurrency"!==e&&"minimum_successes"!==e&&"retry"!==e&&"timeout"!==e&&"wait_schema"!==e&&"reason"!==e&&"key"!==e&&"requests"!==e&&"interval_seconds"!==e&&"window_seconds"!==e&&"exit_label"!==e?null:{kind:"node_field",node_id:i[1],field:e}}let a=l.match(/^([0-9a-f-]{36}):condition$/u);if(a&&v.test(a[1]))return{kind:"path_condition",path_id:a[1]};let s=l.match(/^([0-9a-f-]{36}):scope-links$/u);if(s&&v.test(s[1]))return{kind:"node_scope_links",node_id:s[1]};let r=l.match(/^([0-9a-f-]{36}):set-values:(.+)$/u);if(r&&v.test(r[1])&&"set_values_field"===t.kind){let e;try{e=JSON.parse(r[2])}catch{return null}if("string"==typeof e)return{kind:"set_values_field",node_id:r[1],field_name:e,part:"name"}}for(let t of["recoveries","scopes"]){let n=function(e,l){if(e===l)return[];let t=`:${l}`;return e.endsWith(t)?e.slice(0,-t.length):null}(l,t);if(null===n)continue;let i=n?C(e).find(e=>e.at(-1)===n):[];if(!i)break;return"recoveries"===t?{kind:"scope_recoveries",scope_path:i}:{kind:"scope_definitions",scope_path:i}}return null}(e,t,i);if(l&&!i.valid){if("set_values_field"===i.kind){if("set_values_field"!==l.kind)continue;i.draft.nameValid||n.push(I({...l,part:"name"},"field_name",i.draft.name)),i.draft.contractValid||n.push(I({...l,part:"contract"},"contract",i.draft.contract)),!i.draft.bindingValid&&i.draft.binding&&n.push(I({kind:"node_input",node_id:l.node_id,path:[l.field_name]},"binding",i.draft.binding));continue}n.push(I(l,"node-scopes"===i.kind?"node_scopes":i.kind,i.draft))}}for(let l of e.nodes)(function e(l,t,n,i){for(let s of((0,a.lP)(t)&&!(0,o.$5)(l,n,t.loop_node_id)&&i.push(I({kind:"node_input",node_id:t.id,path:["loop_node_id"]},"field",[{path:[],text:t.loop_node_id,touched:!0}])),(0,d.RX)(t)))for(let t of s.definition.nodes)e(l,t,[...n,...s.path],i)})(e,l,[],n),function e(l,t,n,i){for(let a of("stop_branch"!==t.kind||(0,r.g9)(l,n,t.branch_id)||i.push(I({kind:"node_input",node_id:t.id,path:["branch_id"]},"field",[{path:[],text:t.branch_id,touched:!0}])),(0,d.RX)(t)))for(let t of a.definition.nodes)e(l,t,[...n,...a.path],i)}(e,l,[],n),function e(l,t,n,i){for(let a of("compensate"!==t.kind||(0,u.l$)(l,t,n)||i.push(I({kind:"node_input",node_id:t.id,path:["original_node_id"]},"field",[{path:[],text:t.original_node_id,touched:!0}])),(0,d.RX)(t)))for(let t of a.definition.nodes)e(l,t,[...n,...a.path],i)}(e,l,[],n),function e(l,t){if((0,a.md)(l))for(let e of(0,d.Up)(l))e.condition&&t.push(I({kind:"path_condition",path_id:e.id},"rule",e.condition));for(let n of(0,d.RX)(l))for(let l of n.definition.nodes)e(l,t)}(l,n),function e(l,t){for(let n of((0,a.$j)(l)&&null===l.key&&!t.some(e=>"node_field"===e.target.kind&&e.target.node_id===l.id&&"key"===e.target.field)&&t.push(I({kind:"node_field",node_id:l.id,field:"key"},"binding",null)),(0,d.RX)(l)))for(let l of n.definition.nodes)e(l,t)}(l,n);return n}function A(e){switch(e.kind){case"node_input":return`${e.node_id}:inputs:${JSON.stringify(e.path)}`;case"node_field":return`${e.node_id}:${"minimum_successes"===e.field?"minimum-successes":e.field}`;case"path_condition":return`${e.path_id}:condition`;case"node_scope_links":return`${e.node_id}:scope-links`;case"set_values_field":return N(e.node_id,e.field_name);case"scope_recoveries":return`${e.scope_path.at(-1)?`${e.scope_path.at(-1)}:`:""}recoveries`;case"scope_definitions":return`${e.scope_path.at(-1)?`${e.scope_path.at(-1)}:`:""}scopes`}}function D(e,l,t){let n,i,r={},o=[],u=new Map,c={nodes:new Map((function e(l){let t=[];for(let n of l.nodes)for(let l of(t.push(n),(0,d.RX)(n)))t.push(...e(l.definition));return t})(l).map(e=>[e.id,e])),pathIds:function e(l){let t=new Set;for(let n of l.nodes)if((0,a.gW)(n)||(0,a.$j)(n))for(let l of((0,a.bm)(n)&&t.add(n.id),e(n.body)))t.add(l);else if("first_match"===n.kind||"all_matches"===n.kind||"filter"===n.kind||"if_else"===n.kind||"parallel"===n.kind)for(let l of[...n.branches,...n.otherwise?[n.otherwise]:[]])for(let i of("parallel"!==n.kind&&n.branches.includes(l)&&t.add(l.id),e(l.body)))t.add(i);else if((0,a.md)(n))for(let l of(0,d.Up)(n))for(let n of(t.add(l.id),e(l.body)))t.add(n);else if("wait_all_selected"===n.kind||"wait_all_outcomes"===n.kind||"first_success"===n.kind||"n_successes"===n.kind)for(let l of e(n.continuation.body))t.add(l);return t}(l),timeoutOwnerIds:(n=new Set,(i=e=>{for(let l of e.nodes){for(let e of((0,s.tH)(l)&&n.add(l.id),(0,d.Up)(l)))n.add(e.id);for(let e of(0,d.RX)(l))i(e.definition)}})(l),n),scopePaths:C(l)};for(let e of t){let l=e.target;if("set_values_field"===l.kind){if(!$(c,l)){o.push(e);continue}let t=N(l.node_id,l.field_name),n=u.get(t)??{name:l.field_name,nameValid:!0,contract:[],contractValid:!0,binding:null,bindingValid:!0},i=w(e);"field_name"===e.edit_kind&&"string"==typeof i?u.set(t,{...n,name:i,nameValid:!1}):"contract"===e.edit_kind&&h(i)?u.set(t,{...n,contract:i,contractValid:!1}):o.push(e)}}for(let l of t){let t=l.target;if("set_values_field"===t.kind)continue;if(!$(c,t)){o.push(l);continue}if("node_input"===t.kind&&1===t.path.length&&"binding"===l.edit_kind){let n=N(t.node_id,t.path[0]),i=u.get(n),a=w(l);if(i&&x(e,a)){u.set(n,{...i,binding:a,bindingValid:!1});continue}}let n=function(e,l){let t=w(l);return void 0===t?null:"contract"===l.edit_kind&&h(t)?{kind:"contract",draft:t,valid:!1}:"field"===l.edit_kind&&f(t)?{kind:"field",draft:t,valid:!1}:"binding"===l.edit_kind&&null===t?{kind:"binding",draft:null,valid:!1}:"binding"===l.edit_kind&&x(e,t)?{kind:"binding",draft:t,valid:!1}:"rule"===l.edit_kind&&null===t?{kind:"rule",draft:null,valid:!1}:"rule"===l.edit_kind&&m(t)&&(null===t.source||e.workflowRuleSchema.safeParse(t.source).success)&&function e(l,t){return!!m(t)&&("predicate"===t.kind?(null===t.operator||["is_available","is_unavailable","is_null","is_not_null","is_true","is_false","is_empty","is_not_empty","eq","ne","lt","lte","gt","gte","contains","not_contains","starts_with","not_starts_with","ends_with","not_ends_with","in","not_in","between","outside","count_eq","count_ne","count_lt","count_lte","count_gt","count_gte"].includes("string"==typeof t.operator?t.operator:""))&&[t.left,t.right].every(e=>m(e)&&(null===e.value||l.workflowBindingSchema.safeParse(e.value).success)&&(null===e.draft||x(l,e.draft))&&"boolean"==typeof e.valid):"not"===t.kind?e(l,t.child):("all"===t.kind||"any"===t.kind)&&Array.isArray(t.children)&&t.children.every(t=>e(l,t)))}(e,t.editor)?{kind:"rule",draft:t,valid:!1}:"recovery"===l.edit_kind&&null===t?{kind:"recovery",draft:null,valid:!1}:"recovery"===l.edit_kind&&m(t)&&Array.isArray(t.source)&&t.source.every(l=>(function(e,l){if(!m(l)||!k(l.recovery_node_id))return!1;let t=l.failure;return!!m(t)&&("node"===t.kind?k(t.node_id):"call_exit_failure"===t.kind?k(t.call_node_id)&&k(t.exit_id):"loop_limit"===t.kind?k(t.loop_node_id):"collection"===t.kind&&e.workflowCollectionOutcomesBindingSchema.safeParse(t.collection).success)})(e,l))&&Array.isArray(t.rows)&&t.rows.every(l=>!!m(l)&&("node"===l.kind||"collection"===l.kind||"call_exit_failure"===l.kind||"loop_limit"===l.kind)&&y(l.callNodeId)&&y(l.exitId)&&y(l.nodeId)&&y(l.loopNodeId)&&(null===l.collection||e.workflowCollectionOutcomesBindingSchema.safeParse(l.collection).success)&&(null===l.collectionDraft||x(e,l.collectionDraft))&&"boolean"==typeof l.collectionValid&&y(l.completionId))?{kind:"recovery",draft:t,valid:!1}:"scopes"===l.edit_kind&&null===t?{kind:"scopes",draft:null,valid:!1}:"scopes"===l.edit_kind&&m(t)&&Array.isArray(t.source)&&t.source.every(l=>g(e,l))&&Array.isArray(t.rows)&&t.rows.every(l=>m(l)&&m(l.value)&&g(e,l.value)&&m(l.label)&&f(l.label.draft)&&"boolean"==typeof l.label.valid&&(null===l.keysDraft||x(e,l.keysDraft))&&"boolean"==typeof l.keysValid)?{kind:"scopes",draft:t,valid:!1}:"node_scopes"===l.edit_kind&&null===t?{kind:"node-scopes",draft:null,valid:!1}:"node_scopes"===l.edit_kind&&m(t)&&m(t.source)&&Array.isArray(t.source.memberships)&&t.source.memberships.every(l=>j(e,l))&&Array.isArray(t.source.consumers)&&t.source.consumers.every(l=>j(e,l))&&Array.isArray(t.memberships)&&t.memberships.every(l=>_(e,l))&&Array.isArray(t.consumers)&&t.consumers.every(l=>_(e,l))?{kind:"node-scopes",draft:t,valid:!1}:null}(e,l);n?r[A(t)]=n:o.push(l)}for(let[e,l]of u)r[e]={kind:"set_values_field",draft:l,valid:l.nameValid&&l.contractValid&&l.bindingValid};return{fields:r,incompatible:o}}function R(e,l){let t=e=>[...e].sort((e,l)=>{let t=`${JSON.stringify(e.target)}:${e.edit_kind}`,n=`${JSON.stringify(l.target)}:${l.edit_kind}`;return t.localeCompare(n)});return i()(t(e),t(l))}},59e3:(e,l,t)=>{t.d(l,{w:()=>d});var n=t(37876),i=t(43374),a=t(39463),s=t(63492),r=t(33552);function d({node:e,definition:l,scopePath:t,disabled:o,onChange:u}){let c=(0,i.E1)(l,t),m=c.map(e=>({value:e.id,label:e.label.trim()||a.HP[e.kind]})),p=(0,i.$5)(l,t,e.loop_node_id);return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("p",{className:"text-sm leading-5 text-muted-foreground",children:(0,i.Jc)(e)}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(s.J,{htmlFor:`${e.id}:loop-target`,children:"Loop"}),(0,n.jsxs)(r.l6,{items:m,value:p?e.loop_node_id:"",disabled:o||0===c.length,onValueChange:l=>u({...e,loop_node_id:l},void 0,[`${e.id}:inputs:${JSON.stringify(["loop_node_id"])}`]),children:[(0,n.jsx)(r.bq,{id:`${e.id}:loop-target`,children:(0,n.jsx)(r.yv,{placeholder:"Choose an enclosing loop"})}),(0,n.jsx)(r.gC,{children:c.map(e=>(0,n.jsx)(r.eb,{value:e.id,children:e.label.trim()||a.HP[e.kind]},e.id))})]}),0===c.length?(0,n.jsx)("p",{className:"text-sm text-destructive",children:"Break and Continue belong inside a loop."}):null]})]})}},59312:(e,l,t)=>{t.d(l,{lh:()=>r,me:()=>
1o,ql:()=>d});var n=t(33004),i=t(57195),a=t(48416),s=t(9516);function r(e,l,t){let i={id:(0,n.UT)(crypto.randomUUID()),label:function(e,l){if(!l.includes(e))return e;let t=2;for(;l.includes(`${e} ${t}`);)t+=1;return`${e} ${t}`}(t,e.inputs.map(e=>e.label)),field:l};return{scope:{...e,inputs:[...e.inputs,i]},binding:{kind:"workflow_input",field_id:i.id,path:[]}}}function d(e,l){var t;let r,d,o=(t=e,r=new Set,(d=e=>{Array.isArray(e)?e.forEach(d):e&&"object"==typeof e&&("workflow_input"===e.kind&&"string"==typeof e.field_id&&r.add(e.field_id),Object.values(e).forEach(d))})(t),r);return function e(l,t,r){var d,o;let u=l.nodes.map(l=>{let n=(0,s.xr)(l,l=>e(l,t,r));return(0,a.bm)(n)?{...n,body:{...n.body,outputs:[]}}:n}),c=l.inputs.filter(e=>r.has(e.id)),m=function(e,l){let t=e.nodes.find(e=>"return"===e.kind);if(t)return t.outputs.map(e=>({...e}));let r=new Set((0,i.Y4)(e).filter(e=>!e.kinds.every(e=>"recovery"===e)).map(e=>e.source));for(let l of e.nodes)(0,a.cs)(l)&&(0,s.Op)(l).some(e=>r.has(e.id))&&r.add(l.id);return e.nodes.filter(e=>!r.has(e.id)).flatMap(t=>{if("resume"===t.kind||"respond"===t.kind||"compensate"===t.kind||"try_catch"===t.kind||"finally"===t.kind)return[];if((0,a.cs)(t))return(0,s.Op)(t).flatMap(e=>e.body.outputs.map(l=>({nodeId:e.id,path:[l.declaration.id],label:`${e.label} \xb7 ${l.declaration.label}`,field:"parallel"===t.kind?l.declaration.field:{...l.declaration.field,required:!1,default:null}})));let n=function(e,l,t){if("task"===e.kind)return(0,i.Lk)(l,e,"outputs");if("resume"===e.kind)return(0,i.Mu)(e.values.map(e=>e.declaration));if("respond"===e.kind||"return"===e.kind)return(0,i.Mu)(e.outputs.map(e=>e.declaration));if("workflow"===e.kind){let t=(0,i.by)(l,e);return t?(0,i.Mu)(t.outputs):null}if((0,a.yE)(e)){let n=(0,i.Ao)({definition:t,scopePath:[],currentNodeId:null,catalogue:l},e);return"available"===n.kind?n.field:null}return null}(t,l,e);return n?[{nodeId:t.id,path:[],label:t.label,field:n}]:[]}).map(l=>{let t=e.outputs.find(e=>e.source?.kind==="node_output"&&e.source.node_id===l.nodeId&&JSON.stringify(e.source.path)===JSON.stringify(l.path));return{declaration:{id:t?.declaration.id??(0,n.UT)(crypto.randomUUID()),label:l.label,field:l.field},source:{kind:"node_output",node_id:l.nodeId,path:l.path}}})}({...l,nodes:u},t);return c.length===l.inputs.length&&(d=m,o=l.outputs,d.length===o.length&&d.every((e,l)=>{let t=o[l];return e.declaration.id===t.declaration.id&&e.declaration.label===t.declaration.label&&e.declaration.field===t.declaration.field&&JSON.stringify(e.source)===JSON.stringify(t.source)}))&&u.every((e,t)=>e===l.nodes[t])?l:{...l,nodes:u,inputs:c,outputs:m}}(e,l,o)}function o(e,l,t){let n=e.nodes.find(e=>e.id===l);if(!n||"task"!==n.kind&&"workflow"!==n.kind)return;let i=n.inputs.find(e=>JSON.stringify(e.target)===JSON.stringify(t));if(i?.source.kind!=="workflow_input")return;let a=i.source.field_id;return e.inputs.find(e=>e.id===a)}},59867:(e,l,t)=>{t.d(l,{e:()=>v});var n=t(37876),i=t(14232),a=t(41946),s=t.n(a),r=t(57195),d=t(7260),o=t(48416),u=t(66810),c=t(63492),m=t(34216),p=t(53840),f=t(1202),h=t(20978),b=t(63373),x=t(9510);function v(e){return(0,n.jsx)(k,{...e})}function y(e,l,t=null){let n=l=>{let n=e.workflowBindingSchema.safeParse(t?.kind===l.kind?{...t,...l}:l);return n.success?n.data:null};switch(l.kind){case"fold":case"conditional":case"project":{let t=l=>l.draft&&!y(e,l.draft.editor,l.draft.source)?null:l.value;if("fold"===l.kind&&!l.contractValid)return null;return n("fold"===l.kind?{kind:l.kind,operation:l.operation,field:l.field,sources:l.sources.map(t)}:"project"===l.kind?{...l,source:t(l.source)}:{kind:"conditional",operand:t(l.operand),match:t(l.match),when_equal:t(l.whenEqual),otherwise:t(l.otherwise)})}case"object_value":{let i=[];for(let n of l.members){if(n.draft&&!y(e,n.draft.editor,n.draft.source))return null;n.value&&i.push({...t?.kind==="object_value"?t.members.find(e=>e.name===n.name):void 0,name:n.name,source:n.value})}let a=n({kind:"object_value",field:l.field,members:i});return a?.kind==="object_value"&&null===(0,o.J7)(a)?a:null}case"list_value":{if("list"!==l.field.type.kind||l.items.length<l.field.type.minimum_length||l.items.length>l.field.type.maximum_length)return null;let t=[];for(let n of l.items){if(!n.value||n.draft&&!y(e,n.draft.editor,n.draft.source))return null;t.push(n.value)}return n({kind:"list_value",field:l.field,items:t})}case"reference":return l.value;case"literal":return l.contractValid&&void 0!==l.value&&0===(0,h.L)(l.field,l.value).length&&0===(0,h.Pb)(l.field,l.value,l.fieldDraft).length?n({kind:"literal",field:l.field,value:l.value}):null;case"keyed_output":return l.producerId&&l.outputId&&null!==l.path&&l.key&&(!l.keyDraft||y(e,l.keyDraft.editor,l.keyDraft.source))?n({kind:"keyed_output",for_each_node_id:l.producerId,output_field_id:l.outputId,key:l.key,path:l.path}):null;case"collection_outcomes":{let i=(0,r.q9)(l);return l.producerId&&l.outputId&&i&&("whole_collection"===i.kind||!l.keyDraft||y(e,l.keyDraft.editor,l.keyDraft.source))?n({kind:"collection_outcomes",for_each_node_id:l.producerId,output_field_id:l.outputId,selection:t?.kind==="collection_outcomes"&&t.selection.kind===i.kind?{...t.selection,...i}:i}):null}case"first_available":{let t=[];
1for(let n of l.alternatives){if(!n.value||n.draft&&!y(e,n.draft.editor,n.draft.source))return null;t.push(n.value)}return n({kind:"first_available",alternatives:t})}}}function k(e){let l=(0,f.yq)(),{target:t,sourcePurpose:a="value",value:o,onChange:b,disabled:v=!1,label:k="Input mapping",scalarOnly:N=!1,allowFallback:C=!0,compact:$=!1,pristine:I=!1,title:S,actions:A}=e,D=(0,i.useId)(),[R,O]=(0,i.useState)(null),q=e.onDraftChange?e.draft:R,M=q&&s()(q.source,o)?q.editor:null,P=M??function(e){if(!e)return null;switch(e.kind){case"fold":return{...e,sources:e.sources.map(e=>({value:e,draft:null})),contractDraft:[],contractValid:!0};case"conditional":return{kind:"conditional",operand:{value:e.operand,draft:null},match:{value:e.match,draft:null},whenEqual:{value:e.when_equal,draft:null},otherwise:{value:e.otherwise,draft:null}};case"project":return{...e,source:{value:e.source,draft:null}};case"object_value":return{kind:"object_value",field:e.field,members:e.members.map(e=>({name:e.name,value:e.source,draft:null}))};case"list_value":return{kind:"list_value",field:e.field,items:e.items.map(e=>({value:e,draft:null}))};case"literal":return{kind:"literal",field:e.field,value:e.value,fieldDraft:[],contractDraft:[],contractValid:!0};case"keyed_output":return{kind:"keyed_output",producerId:e.for_each_node_id,outputId:e.output_field_id,key:e.key,keyDraft:null,path:e.path};case"collection_outcomes":return{kind:"collection_outcomes",producerId:e.for_each_node_id,outputId:e.output_field_id,selection:e.selection.kind,scopeId:"scope"===e.selection.kind?e.selection.scope_id:null,key:"scope"===e.selection.kind?e.selection.key:null,keyDraft:null};case"first_available":return{kind:"first_available",alternatives:e.alternatives.map(e=>({value:e,draft:null}))};default:return{kind:"reference",source:e.kind,value:e}}}(o),E=(0,i.useRef)(null),F=l=>{e.onDraftChange?e.onDraftChange(l):O(l)},T=e=>{let t=y(l,e,o);F(!t||function(e){switch(e.kind){case"fold":return e.contractDraft.length>0||e.sources.some(e=>null!==e.draft);case"project":return null!==e.source.draft;case"conditional":return[e.operand,e.match,e.whenEqual,e.otherwise].some(e=>null!==e.draft);case"object_value":return e.members.some(e=>null!==e.draft);case"list_value":return e.items.some(e=>null!==e.draft);case"reference":return!1;case"literal":return e.fieldDraft.length>0||e.contractDraft.length>0;case"keyed_output":case"collection_outcomes":return null!==e.keyDraft;case"first_available":return e.alternatives.some(e=>null!==e.draft)}}(e)?{source:t??o,editor:e}:null),b(t??o,null!==t)},J=P?.kind==="reference"?P.source:P?.kind??"",z=$?(0,r.Ph)(e,t,a):null,V=P?.kind==="reference"?(z??(0,r.Ph)(e,t,a)).filter(e=>e.binding.kind===J):[],L=P?.kind==="reference"&&P.value?JSON.stringify(P.value):"",K=o?(0,r._4)(e,o,t,a):null,U=P?.kind==="keyed_output"||P?.kind==="collection_outcomes"?(0,r.OU)(e).find(e=>e.node.id===P.producerId):void 0,B=U?.node.body.outputs??[],G=P?.kind==="keyed_output"||P?.kind==="collection_outcomes"?B.find(e=>e.declaration.id===P.outputId):void 0,W=U?(0,r._N)({...e,scopePath:U.scopePath},U.node):null,H=P?.kind==="collection_outcomes"&&"scope"===P.selection&&P.scopeId?(0,r.ng)(e,P.scopeId):null,Y=P?.kind==="keyed_output"?W:H,X=G?(0,r.wN)(G.declaration.field):[],Q=l=>(0,r.CA)(e,l,t,a),Z=Q(e.catalogue.collection_outcomes),ee=[{value:"",label:"Cho
1ose a sourceâ¦"}];if(!N&&t&&("object"===t.type.kind||"union"===t.type.kind)&&(!e.sourceKinds||e.sourceKinds.includes("object_value"))&&ee.push({value:"object_value",label:$?"Fill in Fields":"Build Object"}),!N&&t?.type.kind==="list"&&(!e.sourceKinds||e.sourceKinds.includes("list_value"))&&ee.push({value:"list_value",label:$?"Make a List":"Build List"}),!N)for(let l of[{value:"conditional",label:"Conditional Value"},{value:"project",label:"Project Value"},{value:"fold",label:"Combine Values"}])(!e.sourceKinds||e.sourceKinds.includes(l.value))&&ee.push(l);(!e.sourceKinds||e.sourceKinds.includes("loop_iteration"))&&ee.push({value:"loop_iteration",label:"Iteration Position"}),(!e.sourceKinds||e.sourceKinds.includes("literal"))&&ee.push({value:"literal",label:$?"Enter a Value":"Fixed Value"}),(!e.sourceKinds||e.sourceKinds.includes("workflow_input"))&&ee.push({value:"workflow_input",label:$?"Value Asked When Running":"Workflow Input"}),(!e.sourceKinds||e.sourceKinds.includes("iteration_item"))&&ee.push({value:"iteration_item",label:"Iteration Item"}),(!e.sourceKinds||e.sourceKinds.includes("loop_state"))&&ee.push({value:"loop_state",label:"Loop State"}),(!e.sourceKinds||e.sourceKinds.includes("loop_exit_output"))&&ee.push({value:"loop_exit_output",label:"Loop Exit Output"}),(!e.sourceKinds||e.sourceKinds.includes("node_output"))&&ee.push({value:"node_output",label:$?"Use an Earlier Result":"Earlier Step Output"}),(!e.sourceKinds||e.sourceKinds.includes("call_exit_output"))&&ee.push({value:"call_exit_output",label:"Workflow Exit Output"}),(!e.sourceKinds||e.sourceKinds.includes("join_result"))&&ee.push({value:"join_result",label:"Joined Result"}),!N&&(!e.sourceKinds||e.sourceKinds.includes("node_outcome"))&&ee.push({value:"node_outcome",label:"Terminal Outcome"}),!N&&(!e.sourceKinds||e.sourceKinds.includes("keyed_output"))&&ee.push({value:"keyed_output",label:"Keyed Body Output"}),!N&&(!e.sourceKinds||e.sourceKinds.includes("collection_outcomes"))&&ee.push({value:"collection_outcomes",label:`Collection Outcomes${Z?` â ${Z}`:""}`,disabled:null!==Z}),!N&&C&&(!e.sourceKinds||e.sourceKinds.includes("first_available"))&&ee.push({value:"first_available",label:"First Available"});let el=new Set(["workflow_input","iteration_item","loop_state","loop_iteration","loop_exit_output","node_output","call_exit_output","join_result","node_outcome"]),et=z?ee.filter(e=>e.value===J||!el.has(e.value)||z.some(l=>l.binding.kind===e.value&&null===l.disabledReason)):ee,en=(0,n.jsx)(x.i8,{id:`${D}-source`,label:k,disabled:v,value:J,size:$?"sm":"default",className:$?"w-auto":void 0,options:et,onChange:l=>{switch(l){case"conditional":T({kind:"conditional",operand:{value:null,draft:null},match:{value:null,draft:null},whenEqual:{value:null,draft:null},otherwise:{value:null,draft:null}});break;case"project":T({kind:"project",operation:"first",source:{value:null,draft:null}});break;case"fold":T({kind:"fold",operation:t?.type.kind==="list"?"append_unique":"any",field:t?.type.kind==="list"?t:(0,p.iO)((0,p.Ed)("boolean")),sources:[{value:null,draft:null}],contractDraft:[],contractValid:!0});break;case"object_value":t&&("object"===t.type.kind||"union"===t.type.kind)&&T({kind:"object_value",field:t,members:[]});break;case"list_value":t?.type.kind==="list"&&T({kind:"list_value",field:t,items:[]});break;case"literal":T({kind:"literal",field:t??e.literalField??(0,p.iO)("value"!==a&&"key"!==a?(0,p.Ed)("list"):void 0),value:void 0,fieldDraft:[],contractDraft:[],contractValid:!0});break;case"workflow_input":case"iteration_item":case"loop_state":case"loop_iteration":case"loop_exit_output":case"node_output":case"call_exit_output":case"join_result":case"node_outcome":T({kind:"reference",source:l,value:null});break;case"keyed_output":T({kind:"keyed_output",producerId:null,outputId:null,key:null,keyDraft:null,path:[]});break;case"collection_outcomes":T({kind:"collection_outcomes",producerId:null,outputId:null,selection:"whole_collection",scopeId:null,key:null,keyDraft:null});break;case"first_available":T({kind:"first_available",alternatives:[{value:null,draft:null}]})}}});return(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-3",children:[(0,n.jsx)("legend",{className:"sr-only",children:k}),$?(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,n.jsx)("div",{className:"min-w-0 basis-full",children:S}),(0,n.jsxs)("div",{className:"flex max-w-full min-w-0 flex-wrap items-center gap-1",children:[en,A]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-2",children:[(0,n.jsxs)("div",{className:"min-w-0 space-y-1.5",children:[(0,n.jsx)(c.J,{htmlFor:`${D}-source`,children:k}),en]}),o||P?(0,n.jsx)(u.$,{type:"button",variant:"ghost",size:"sm",disabled:v,onClick:()=>{F(null),b(null,!0)},children:"Remove Mapping"}):null]}),t?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Destination: ",(0,r.oS)(t),"."," ",t.required&&null===t.default?"A value is required at runtime.":"Removing the mapping uses the fieldâs omission/default rules."]}):(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"key"===a?"Choose a non-null text, exact integer, choice or reference.":"repeat_count"===a?"Choose a non-null integer. The saved maximum rejects a larger runtime count.":"value"!==a?"Choose a bounded list or a registered collection reference.":"Choose a source to set this valueâs type."})]}),K?(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[K," The saved mapping stays here until you repair or remove it."]}):null,!M||y(l,M)||I?null:(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Finish this mapping before saving, or remove it to keep an incomplete draft."}),P?.kind==="object_value"||P?.kind==="list_value"?(0,n.jsx)(g,{...e,editor:P,update:T}):null,P?.kind==="fold"||P?.kind==="conditional"||P?.kind==="project"?(0,n.jsx)(w,{...e,editor:P,update:T}):null,P?.kind==="literal"?(0,n.jsxs)("div",{className:"space-y-3",children:[t?null:(0,n.jsx)(m.d,{field:P.field,draft:P.contractDraft,label:`${k} fixed value type`,disabled:v,onChange:e=>T({...P,field:e.field,contractDraft:e.draft,contractValid:e.valid})}),(0,n.jsx)(h.Oe,{field:{...P.field,required:!0,default:null},label:`${k} fixed value`,hideLabel:$,value:P.value,disabled:v,draft:P.fieldDraft,onDraftChange:e=>
1{E.current={base:P,next:e}},onChange:e=>T({...P,value:e,fieldDraft:E.current?.base===P?E.current.next:P.fieldDraft})})]}):null,P?.kind==="reference"?(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(c.J,{htmlFor:`${D}-field`,children:"Source field"}),(0,n.jsx)(x.Hq,{id:`${D}-field`,label:"Source field",disabled:v,value:L,options:[{value:"",label:"Choose a fieldâ¦"},...L&&!V.some(e=>JSON.stringify(e.binding)===L)?[{value:L,label:"Saved reference is unavailable",disabled:!0}]:[],...V.map(e=>({value:JSON.stringify(e.binding),label:`${e.label} \xb7 ${e.field?(0,r.oS)(e.field):"Unavailable"}${e.disabledReason?` â ${e.disabledReason}`:""}`,disabled:null!==e.disabledReason}))],onChange:e=>{let l=V.find(l=>JSON.stringify(l.binding)===e);l&&!l.disabledReason&&T({...P,value:l.binding})}}),0===V.length?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:$?"Thereâs no value to choose here yet. Enter a value, or add an earlier step whose result you want to use.":"No sources of this kind exist in this body or its ancestors."}):null]}):null,P?.kind==="keyed_output"||P?.kind==="collection_outcomes"?(0,n.jsxs)("div",{className:"space-y-3 border-l pl-3",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(c.J,{htmlFor:`${D}-producer`,children:"Loop producer"}),(0,n.jsx)(x.Hq,{id:`${D}-producer`,label:"Loop producer",disabled:v,value:P.producerId??"",options:[{value:"",label:"Cho
1ose a loopâ¦"},...P.producerId&&!U?[{value:P.producerId,label:"Saved loop is unavailable",disabled:!0}]:[],...(0,r.OU)(e).map(e=>({value:e.node.id,label:`${e.node.label}${e.disabledReason?` â ${e.disabledReason}`:""}`,disabled:!!e.disabledReason}))],onChange:l=>{let t=(0,r.OU)(e).find(e=>e.node.id===l);t&&!t.disabledReason&&T({...P,producerId:t.node.id,outputId:null,key:null,keyDraft:null,..."keyed_output"===P.kind?{path:null}:{}})}})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(c.J,{htmlFor:`${D}-output`,children:"Body output"}),(0,n.jsx)(x.Hq,{id:`${D}-output`,label:"Body output",value:P.outputId??"",disabled:v||!U,options:[{value:"",label:"Choose a named outputâ¦"},...P.outputId&&!G?[{value:P.outputId,label:"Saved body output is unavailable",disabled:!0}]:[],...B.map(e=>{let l="keyed_output"===P.kind&&!(0,r.wN)(e.declaration.field).some(e=>null===Q(e.field));return{value:e.declaration.id,label:`${e.declaration.label} \xb7 ${(0,r.oS)(e.declaration.field)}${l?" â No compatible field":""}`,disabled:l}})],onChange:e=>{let l=B.find(l=>l.declaration.id===e);l&&T({...P,outputId:l.declaration.id,..."keyed_output"===P.kind?{path:null===Q(l.declaration.field)?[]:null}:{}})}}),U&&0===B.length?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Define a named output inside this loop body first."}):null]}),"keyed_output"===P.kind&&G?(0,n.jsx)(_,{id:`${D}-path`,label:"Output field",disabled:v,paths:X,value:P.path,sourceIssue:Q,onChange:e=>T({...P,path:e})}):null,"collection_outcomes"===P.kind?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(c.J,{htmlFor:`${D}-selection`,children:"Collection selection"}),(0,n.jsx)(x.i8,{id:`${D}-selection`,label:"Collection selection",disabled:v,value:P.selection,options:[{value:"whole_collection",label:"Whole Collection"},{value:"scope",label:"One Group"}],onChange:e=>{("whole_collection"===e||"scope"===e)&&T({...P,selection:e})}})]}),"scope"===P.selection?(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(c.J,{htmlFor:`${D}-scope`,children:"Group"}),(0,n.jsx)(x.Hq,{id:`${D}-scope`,label:"Group",disabled:v,value:P.scopeId??"",options:[{value:"",label:"Cho
1ose a groupâ¦"},...P.scopeId&&!(0,r.RN)(e).some(e=>e.id===P.scopeId)?[{value:P.scopeId,label:"Saved group is unavailable",disabled:!0}]:[],...(0,r.RN)(e).map(e=>({value:e.id,label:`${e.label}${"unavailable"===e.field.kind?` â ${e.field.reason}`:""}`,disabled:"unavailable"===e.field.kind}))],onChange:l=>{let t=(0,r.RN)(e).find(e=>e.id===l);t?.field.kind==="available"&&T({...P,scopeId:t.id,key:null,keyDraft:null})}})]}):null,(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Passes an access-checked outcome reference, not a copied list of results. Collection readers page only the selected members."})]}):null,Y?.kind==="unavailable"?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Y.reason}):null,Y?.kind==="available"&&("keyed_output"===P.kind||"scope"===P.selection)?(0,n.jsx)(j,{...e,target:Y.field,sourcePurpose:"value",value:P.key,draft:P.keyDraft,scalarOnly:!0,allowFallback:!1,label:"keyed_output"===P.kind?"Item key":"Group key",onNestedChange:(e,l)=>T({...P,key:(0,r.jv)(e)?e:null,keyDraft:l})},`${P.producerId}:${"collection_outcomes"===P.kind?P.scopeId:"key"}`):null]}):null,P?.kind==="first_available"?(0,n.jsxs)("div",{className:"space-y-4 border-l pl-3",children:[(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Tries sources in this order, waiting for an earlier source to settle before choosing a later one. Null remains available; this mapping does not declare recovery by itself."}),P.alternatives.map((l,t)=>(0,n.jsxs)("div",{className:"space-y-2 border-b pb-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsxs)("p",{className:"text-sm font-medium",children:["Alternative ",t+1]}),(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)(u.$,{type:"button",variant:"ghost",size:"sm",disabled:v||0===t,onClick:()=>{let e=[...P.alternatives];[e[t-1],e[t]]=[e[t],e[t-1]],T({...P,alternatives:e})},children:"Move Up"}),(0,n.jsx)(u.$,{type:"button",variant:"ghost",size:"sm",disabled:v||t===P.alternatives.length-1,onClick:()=>{let e=[...P.alternatives];[e[t],e[t+1]]=[e[t+1],e[t]],T({...P,alternatives:e})},children:"Move Down"}),(0,n.jsx)(u.$,{type:"button",variant:"ghost",size:"sm",disabled:v||1===P.alternatives.length,onClick:()=>T({...P,alternatives:P.alternatives.filter((e,l)=>l!==t)}),children:"Remove Alternative"})]})]}),(0,n.jsx)(j,{...e,value:l.value,draft:l.draft,scalarOnly:!1,allowFallback:!1,label:`Alternative ${t+1} source`,onNestedChange:(e,l)=>T({...P,alternatives:P.alternatives.map((n,i)=>i===t?{value:e?.kind==="first_available"?null:e,draft:l}:n)})})]},t)),(0,n.jsx)(u.$,{type:"button",variant:"outline",disabled:v||P.alternatives.length>=((0,d.lu)(l.modelPropertySchema("FirstAvailableBinding","alternatives"))??1/0),onClick:()=>T({...P,alternatives:[...P.alternatives,{value:null,draft:null}]}),children:"Add Alternative"})]}):null]})}function g({editor:e,update:l,...t}){let a=(0,f.yq)(),[r,m]=(0,i.useState)(20),p=(0,i.useContext)(b.E5),{disabled:h=!1,label:v="Value"}=t;if("list_value"===e.kind){let i=e.field.type;return"list"!==i.kind?(0,n.jsx)("p",{role:"alert",children:"Build list needs a list field."}):(0,n.jsxs)("div",{className:"space-y-3 border-l pl-3",children:[(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.items.length," items \xb7 ",i.minimum_length,"â",i.maximum_length," allowed"]}),e.items.slice(0,r).map((a,s)=>(0,n.jsxs)("div",{className:"space-y-2 border-b pb-3",children:[(0,n.jsx)(j,{...t,target:{...i.item,required:!0,default:null},sourcePurpose:"value",scalarOnly:!1,allowFallback:!0,value:a.value,draft:a.draft,label:`${v} item ${s+1}`,onNestedChange:(t,n)=>l({...e,items:e.items.map((e,l)=>l===s?{value:t,draft:n}:e)})}),(0,n.jsxs)(u.$,{type:"button",variant:"ghost",size:"sm",disabled:h,onClick:()=>l({...e,items:e.items.filter((e,l)=>l!==s)}),children:["Remove Item ",s+1]})]},s)),e.items.length>r?(0,n.jsx)(u.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>m(e=>e+20),children:"Show More Items"}):null,(0,n.jsx)(u.$,{type:"button",variant:"outline",size:"sm",disabled:h||e.items.length>=Math.min(i.maximum_length,(0,d.lu)(a.modelPropertySchema("ListV
1alueBinding","items"))??1/0),onClick:()=>{m(e.items.length+1),l({...e,items:[...e.items,{value:null,draft:null}]})},children:"Add Item"})]})}let y=e.members.flatMap(e=>e.value?[{name:e.name,source:e.value}]:[]),k=(0,o.Zy)({kind:"object_value",field:e.field,members:y}),_=e.field.type,w="union"===_.kind?_.discriminator:null,N=y.find(e=>e.name===w)?.source,C=[...k?.members??[]],$={...p,...(0,b.Pg)({...e.field,type:{kind:"object",members:C}},Object.fromEntries(e.members.flatMap(e=>e.value?.kind==="literal"?[[e.name,e.value.value]]:[])))};return(0,n.jsx)(b.E5.Provider,{value:$,children:(0,n.jsxs)("div",{className:"space-y-3 border-l pl-3",children:["union"===_.kind?(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)(c.J,{children:[v," type"]}),(0,n.jsx)(x.i8,{label:`${v} type`,value:N?.kind==="literal"&&"string"==typeof N.value?N.value:"",disabled:h,options:[{value:"",label:"Choose a typeâ¦",disabled:!0},..._.cases.map(e=>({value:e.tag,label:e.tag}))],onChange:t=>{let n=_.cases.find(e=>e.tag===t),i=n?.field.members.find(e=>e.name===_.discriminator)?.field;n&&i&&l({...e,members:[{name:_.discriminator,value:{kind:"literal",field:i,value:n.tag},draft:null}]})}})]}):null,C.filter(e=>e.name!==w).map(i=>{let a=e.members.find(e=>e.name===i.name);return(0,n.jsx)(j,{...t,target:i.field,sourcePurpose:"value",scalarOnly:!1,allowFallback:!0,value:a?.value??null,draft:a?.draft??null,label:i.name,onNestedChange:(t,n)=>{let r=i.field.type,d="reference"===r.kind&&("table"===r.reference_kind||"board"===r.reference_kind)&&!s()(a?.value,t);l({...e,members:[...e.members.filter(e=>e.name!==i.name&&!(d&&C.some(l=>l.name===e.name&&(0,b.$s)(l.field,r.reference_kind)))),...t||n?[{name:i.name,value:t,draft:n}]:[]]})}},i.name)}),k?.members.length===0?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"No fields to configure."}):null]})})}function j({onNestedChange:e,nestedSourceKinds:l,...t}){let a=(0,i.useRef)(null);return(0,n.jsx)(k,{...t,sourceKinds:l,compact:!1,pristine:!1,title:void 0,actions:void 0,onDraftChange:e=>
1{a.current={base:t.draft,next:e}},onChange:l=>e(l,a.current&&a.current.base===t.draft?a.current.next:t.draft??null)})}function _({id:e,label:l,disabled:t,paths:i,value:a,sourceIssue:s,onChange:d}){let o=null===a?"":JSON.stringify(a);return(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(c.J,{htmlFor:e,children:l}),(0,n.jsx)(x.Hq,{id:e,label:l,disabled:t,value:o,options:[...null===a?[{value:"",label:"Choose a compatible fieldâ¦",disabled:!0}]:[],...null===a||i.some(e=>JSON.stringify(e.path)===o)?[]:[{value:o,label:"Saved field path is unavailable",disabled:!0}],...i.map(e=>({value:JSON.stringify(e.path),label:`${e.path.length?e.path.join(" ⺠"):"Whole output"} \xb7 ${(0,r.oS)(e.field)}${s(e.field)?` â ${s(e.field)}`:""}`,disabled:null!==s(e.field)}))],onChange:e=>{let l=i.find(l=>JSON.stringify(l.path)===e);l&&null===s(l.field)&&d(l.path)}})]})}function w(e){let l=(0,f.yq)(),{editor:t,update:a}=e,s=(0,i.useId)(),o=(l,t,i,a={})=>(0,n.jsx)(j,{...e,compact:!1,title:void 0,actions:void 0,label:l,sourcePurpose:"value",sourceKinds:void 0,scalarOnly:!1,allowFallback:!0,target:null,value:t.value,draft:t.draft,onNestedChange:(e,l)=>i({value:e,draft:l}),nestedSourceKinds:a.sourceKinds,...a});if("project"===t.kind)return(0,n.jsxs)("div",{className:"space-y-3 border-l pl-3",children:[(0,n.jsx)(x.i8,{id:`${s}-projection`,label:"Projection",value:t.operation,disabled:e.disabled,options:[{value:"first",label:"First Item"},{value:"non_null",label:"Non-null Value"}],onChange:e=>{("first"===e||"non_null"===e)&&a({...t,operation:e})}}),o("Source value",t.source,e=>a({...t,source:e}))]});if("conditional"===t.kind){let l=t.operand.value?(0,r.xJ)(e,t.operand.value):null,i={...e,nonNullBindings:new Set([...e.nonNullBindings??[],...t.operand.value?[JSON.stringify(t.operand.value)]:[]])},s=t.match.value?.kind==="literal"&&null===t.match.value.value;return(0,n.jsxs)("div",{className:"space-y-3 border-l pl-3",children:[o("Compare value",t.operand,e=>a({...t,operand:e})),o("Equals",t.match,e=>a({...t,match:e}),{sourceKinds:["literal"],literalField:l?.kind==="available"?l.field:void 0}),o("When equal",t.whenEqual,e=>a({...t,whenEqual:e}),{target:e.target,nonNullBindings:s?e.nonNullBindings:i.nonNullBindings}),o("Otherwise",t.otherwise,e=>a({...t,otherwise:e}),{target:e.target,nonNullBindings:s?i.nonNullBindings:e.nonNullBindings})]})}return(0,n.jsxs)("div",{className:"space-y-3 border-l pl-3",children:[(0,n.jsx)(x.i8,{id:`${s}-fold`,label:"Combine values",value:t.operation,disabled:e.disabled,options:[{value:"any",label:"Any True"},{value:"append_unique",label:"Append Distinct"}],onChange:l=>{("any"===l||"append_unique"===l)&&a({...t,operation:l,contractDraft:[],contractValid:!0,field:"any"===l?(0,p.iO)((0,p.Ed)("boolean")):e.target?.type.kind==="list"?e.target:(0,p.iO)((0,p.Ed)("list"))})}}),e.target?null:(0,n.jsx)(m.d,{label:"Combined value type",field:t.field,draft:t.contractDraft,disabled:e.disabled,onChange:e=>{a({...t,field:e.field,contractDraft:e.draft,contractValid:e.valid})}}),t.sources.map((l,i)=>(0,n.jsxs)("div",{className:"space-y-2",children:[o(`Source ${i+1}`,l,e=>a({...t,sources:t.sources.map((l,t)=>t===i?e:l)})),(0,n.jsx)(u.$,{type:"button",variant:"outline",disabled:e.disabled||1===t.sources.length,onClick:()=>a({...t,sources:t.sources.filter((e,l)=>l!==i)}),children:"Remove Source"})]},i)),(0,n.jsx)(u.$,{type:"button",variant:"outline",disabled:e.disabled||t.sources.length>=((0,d.lu)(l.modelPropertySchema("FoldBinding","sources"))??1/0),onClick:()=>a({...t,sources:[...t.sources,{value:null,draft:null}]}),children:"Add Source"})]})}},60230:(e,l,t)=>{t.d(l,{j:()=>s});var n=t(37876),i=t(20978),a=t(9330);function s({field:e,label:l,value:t,buffer:r,disabled:d,formatHint:o,textRows:u,onChange:c}){let m=(0,a.j)({buffer:r,value:t,emptyDraft:[],onChange:(e,l,t)=>c(e,{draft:l,valid:t})});return(0,n.jsx)(i.Oe,{field:e,label:l,value:t,disabled:d,formatHint:o,textRows:u,draft:r?.draft,...m})}},64308:(e,l,t)=>{t.d(l,{b:()=>y});var n=t(37876),i=t(14232),a=t(41946),s=t.n(a),r=t(57195),d=t(35160),o=t(66810),u=t(59867),c=t(9510);function m(e){return{kind:e,children:[(0,d.zf)()]}}function p(e,l){let t=l.map(e=>e+1).join(".");return"predicate"===e.kind?t?`Condition ${t}`:"Condition":"not"===e.kind?t?`NOT ${t}`:"NOT":t?`Group ${t}`:"Condition group"}function f(e){let{value:l,draft:t,onDraftChange:i,onChange:a,label:r="Condition",description:u,disabled:c=!1}=e,p=t&&s()(t.source,l)?t.editor:l?(0,d.aU)(l):null,f=e.catalogue.rule_limits,b=e=>{if(!e){i(null),a(null,!0);return}let t=(0,d.VN)(e),n=null!==t&&(0,d.h4)(e,f),s=n?t:l;i(!n||(0,d.$p)(e)?{source:s,editor:e}:null),a(s,n)},x=p?(0,d.EQ)(p):null;return(0,n.jsxs)("fieldset",{className:"min-w-0 space-y-3",children:[(0,n.jsx)("legend",{className:"sr-only",children:r}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:u??(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"font-medium text-foreground",children:"Run this path only ifâ¦"})," ","the condition below matches. If it does not match, this path does not run. Other ready paths may still run."]})}),p?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[x?.predicates," / ",f.maximum_predicates," conditions \xb7"," ",x?.depth," / ",f.maximum_depth," levels"]}),(0,d.h4)(p,f)?null:(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:["Reduce this condition to ",f.maximum_depth," levels and"," ",f.maximum_predicates," conditions before saving."]}),(0,n.jsx)(h,{...e,editor:p,path:[],onChange:b,onRemove:()=>b(null),canChange:(e,l)=>(0,d.h4)(function e(l,t,n){return t.length?"not"===l.kind?{...l,child:e(l.child,t.slice(1),n)}:"predicate"===l.kind?l:{...l,children:l.children.map((l,i)=>i===t[0]?e(l,t.slice(1),n):l)}:n}(p,e,l),f)})]}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)(o.$,{type:"button",variant:"outline",disabled:c,onClick:()=>b((0,d.zf)()),children:"Add Condition"}),(0,n.jsx)(o.$,{type:"button",variant:"outline",disabled:c,onClick:()=>b(m("all")),children:"Add AND Group"}),(0,n.jsx)(o.$,{type:"button",variant:"outline",disabled:c,onClick:()=>b(m("any")),children:"Add OR Group"})]})]})}function h(e){let{editor:l,path:t,onChange:i,onRemove:a,canChange:s,disabled:u}=e,f=p(l,t),v="predicate"===l.kind&&l.left.value?(0,r.xJ)(e,l.left.value):null,y="predicate"===l.kind?(0,d.AI)(e,l):null;return(0,n.jsxs)("section",{"aria-label":f,className:"predicate"===l.kind?"min-w-0 space-y-3 border-l pl-3":"min-w-0 space-y-3 rounded-md border p-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,n.jsx)("span",{className:"mr-2 text-xs font-medium",children:f}),["all","any","not"].map(e=>(0,n.jsx)(o.$,{type:"button",size:"sm",variant:"ghost",disabled:u||!s(t,"not"===e?{kind:e,child:l}:{kind:e,children:[l]}),onClick:()=>i("not"===e?{kind:e,child:l}:{kind:e,children:[l]}),children:"all"===e?"Wrap in AND":"any"===e?"Wrap in OR":"Wrap in NOT"},e)),(0,n.jsx)(o.$,{type:"button",size:"sm",variant:"ghost",disabled:u,onClick:a,children:"predicate"===l.kind?"Remove Condition":"not"===l.kind?"Remove NOT Rule":"Remove Group"})]}),"predicate"===l.kind?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x,{...e,label:`${f} source`,value:l.left,onChange:e=>i({...l,left:e})}),(0,n.jsx)("div",{className:"space-y-1.5",children:(0,n.jsxs)("label",{className:"text-sm font-medium",children:[(0,n.jsxs)("span",{className:"mb-1.5 block",children:[f," check"]}),(0,n.jsx)(c.i8,{disabled:u,label:`${f}
1 check`,value:l.operator??"",options:[{value:"",label:"Choose a checkâ¦",disabled:!0},...d.Nj.map(e=>{let l=v?.kind==="available"?(0,d.HH)(e.value,v.field):"Choose an available source first.";return{value:e.value,label:`${v?.kind==="available"?(0,d.Qp)(e.value,v.field):e.label}${l?` â ${l}`:""}`,disabled:null!==l}})],onChange:e=>{let t=d.Nj.find(l=>l.value===e);t&&v?.kind==="available"&&!(0,d.HH)(t.value,v.field)&&i({...l,operator:t.value})}})]})}),l.operator&&!(0,d.rM)(l.operator)?(0,n.jsx)(x,{...e,label:`${f} comparison`,value:l.right,literalField:v?.kind==="available"?(0,d.R)(v.field,l.operator):void 0,onChange:e=>i({...l,right:e})}):null,l.operator&&(0,d.rM)(l.operator)&&(l.right.value||l.right.draft)?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Your comparison value is kept if you switch back to a two-value check."}):null,y?(0,n.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[y," Repair this condition before publishing; the draft keeps it."]}):null]}):"not"===l.kind?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsx)("p",{className:"text-sm",children:"NOT reverses the result of the condition or group below."}),(0,n.jsx)(o.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(l.child),disabled:u,children:"Remove NOT"})]}),(0,n.jsx)(h,{...e,editor:l.child,path:[...t,0],onChange:e=>i({...l,child:e}),onRemove:a})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"text-sm font-medium",children:[(0,n.jsx)("span",{className:"mb-1.5 block",children:"Group logic"}),(0,n.jsx)(c.i8,{disabled:u,label:`${f} match`,value:l.kind,options:[{value:"all",label:"AND (all conditions)"},{value:"any",label:"OR (any condition)"}],onChange:e=>{("all"===e||"any"===e)&&i({...l,kind:e})}})]}),(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["all"===l.kind?"Every condition in this group must be true.":"At least one condition in this group must be true."," ","Conditions run in order and stop once the result is known."]}),0===l.children.length?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Add a condition or remove this empty group before saving."}):null,l.children.map((a,s)=>(0,n.jsxs)("div",{className:"space-y-2 border-b pb-3",children:[s>0?(0,n.jsx)("p",{"aria-hidden":"true",className:"text-xs font-semibold text-muted-foreground",children:"all"===l.kind?"AND":"OR"}):null,(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)(o.$,{type:"button",size:"sm",variant:"ghost",disabled:u||0===s,"aria-label":`Move Condition ${[...t,s].map(e=>e+1).join(".")} Up`,onClick:()=>{let e=[...l.children];[e[s-1],e[s]]=[e[s],e[s-1]],i({...l,children:e})},children:"Move Condition Up"}),(0,n.jsx)(o.$,{type:"button",size:"sm",variant:"ghost",disabled:u||s===l.children.length-1,"aria-label":`Move Condition ${[...t,s].map(e=>e+1).join(".")} Down`,onClick:()=>{let e=[...l.children];[e[s+1],e[s]]=[e[s],e[s+1]],i({...l,children:e})},children:"Move Condition Down"})]}),(0,n.jsx)(b,{...e,editor:a,path:[...t,s],onChange:e=>i({...l,children:l.children.map((l,t)=>t===s?e:l)}),onRemove:()=>i({...l,children:l.children.filter((e,l)=>l!==s)})})]},s)),(0,n.jsx)("div",{className:"flex flex-wrap gap-2",children:[["Add Condition",(0,d.zf)()],["Add AND Group",m("all")],["Add OR Group",m("any")]].map(([e,a])=>(0,n.jsx)(o.$,{type:"button",variant:"outline",disabled:u||!s(t,{...l,children:[...l.children,a]}),onClick:()=>i({...l,children:[...l.children,a]}),children:e},e))})]})]})}function b(e){let[l,t]=(0,i.useState)(()=>"predicate"!==e.editor.kind||null===(0,d.VN)(e.editor)),a=e.editor,s=p(a,e.path),r="predicate"===a.kind?a.left.value:null,u=r?.kind==="workflow_input"?e.definition.inputs.find(e=>e.id===r.field_id)?.label??"Workflow input":r?.kind==="literal"?"object"==typeof r.value?"Fixed value":String(r.value):r?.kind.replaceAll("_"," ")??"Choose a source",c="predicate"===a.kind?`${d.Nj.find(e=>e.value===a.operator)?.label??"Choose a check"} \xb7 ${u}`:"not"===a.kind?"NOT \xb7 reverses the rule below":"all"===a.kind?`AN
1D (all) \xb7 ${a.children.length} ${1===a.children.length?"item":"items"}`:`OR (any) \xb7 ${a.children.length} ${1===a.children.length?"item":"items"}`,m="predicate"===a.kind?(0,d.AI)(e,a):null;return(0,n.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,n.jsx)(o.$,{type:"button",variant:"ghost",size:"sm","aria-expanded":l,"aria-label":`${l?"Close":e.disabled?"View":"Edit"} ${s}`,onClick:()=>t(!l),children:l?`Close ${s}`:e.disabled?`View ${s}`:`Edit ${s}`}),l?null:(0,n.jsx)(o.$,{type:"button",variant:"ghost",size:"sm","aria-label":`Remove ${s}`,disabled:e.disabled,onClick:e.onRemove,children:"Remove Condition"})]}),l?(0,n.jsx)(h,{...e}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"truncate text-sm",title:c,children:c}),(0,d.VN)(a)?null:(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Unfinished condition â open it to finish your changes."}),m?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:m}):null]})]})}function x({value:e,onChange:l,label:t,literalField:a,...s}){let r=(0,i.useRef)(null);return(0,n.jsx)(u.e,{...s,target:null,literalField:a,value:e.value,draft:e.draft,label:t,onDraftChange:l=>
1{r.current={base:e,draft:l}},onChange:(t,n)=>l({value:t,valid:n,draft:r.current&&r.current.base===e?r.current.draft:e.draft})})}var v=t(9330);function y({buffer:e,onChange:l,...t}){let i=(0,v.j)({buffer:e,value:t.value,emptyDraft:null,onChange:(e,t,n)=>l(e,{kind:"rule",draft:t,valid:n})});return(0,n.jsx)(f,{...t,draft:e?.draft??null,...i})}},78029:(e,l,t)=>{t.d(l,{_:()=>eG});var n=t(37876),i=t(41946),a=t.n(i),s=t(57195),r=t(9516),d=t(39036),o=t(59312),u=t(63373);function c(e,l){var t;if(l?.type.kind==="object"){let t=e.inputs.find(e=>0===e.target.length)?.source,n={};if(t?.kind!=="literal"||null===t.value||"object"!=typeof t.value||Array.isArray(t.value)||Object.assign(n,t.value),t?.kind==="object_value")for(let e of t.members)"literal"===e.source.kind&&(n[e.name]=e.source.value);for(let l of e.inputs)1===l.target.length&&"literal"===l.source.kind&&(n[l.target[0]]=l.source.value);return(0,u.Pg)(l,n)}return t=e.inputs.flatMap(({source:e})=>(function(e){if("literal"===e.kind){let l=e.field.type;if("object"===l.kind&&null!==e.value&&"object"==typeof e.value&&!Array.isArray(e.value)){let t=e.value;return l.members.map(e=>({field:e.field,value:t[e.name]}))}return[{field:e.field,value:e.value}]}return"object_value"===e.kind?e.members.flatMap(e=>"literal"===e.source.kind?[{field:e.source.field,value:e.source.value}]:[]):[]})(e)),(0,u.Pg)({type:{kind:"object",members:t.map(({field:e},l)=>({name:String(l),field:e}))},required:!0,nullable:!1,default:null,help:""},Object.fromEntries(t.flatMap(({value:e},l)=>void 0===e?[]:[[String(l),e]])))}var m=t(3112),p=t(27660),f=t(33004),h=t(57151),b=t(6423),x=t(81286);function v(e){let l=e.clauses??[];if(!Array.isArray(l))throw Error("Invalid saved filters");return l.length?(0,b.TV)((0,h.Ht)({version:1,filter:{type:"group",combinator:"any"===e.match?"or":"and",children:l.map(e=>{if(!(0,x.qt)(e))throw Error("Invalid saved filter");return{type:"condition",field:e.field,operator:e.operator,value:function(e){if(!(0,x.qt)(e))throw Error("Invalid saved filter value");if("integer"===e.kind){let l=Number(e.value);if(!Number.isSafeInteger(l))throw Error("This whole number needs the exact value editor");return l}return"resources"===e.kind&&Array.isArray(e.value)?e.value.map(e=>{if(!(0,x.qt)(e))throw Error("Invalid saved resource");let{kind:l,...t}=e;return t}):e.value??""}(e.value)}})}})):(0,b._6)("any"===e.match?"or":"and")}let y=m.YOg(m.Ikc({field:m.YjP(),direction:m.k5n(["asc","desc"]),nulls:m.k5n(["first","last"]).default("last")})),k=m.Ikc({table_id:m.YjP().uuid().transform(f.LM),column_id:m.YjP().uuid().transform(f.rX).nullish()}).transform(({table_id:e,column_id:l})=>({table_id:e,...l?{column_id:l}:{}})),g=m.Ikc({documents:m.YOg(m.vkY(e=>{if("object"!=typeof e||null===e||!("version"in e))return e;let{version:l,...t}=e;return{...t,...null==l?{}:{version:Number(l)}}},p.j7)).default([]),include_tables:m.YOg(k).default([]),exclude_tables:m.YOg(k).default([]),only_tables:m.zMY().default(!0)});function j(e){return{...e,documents:e.documents.map(e=>({document_id:e.document_id,version:void 0===e.version?null:String(e.version)})),include_tables:e.include_tables.map(e=>({...e})),exclude_tables:e.exclude_tables.map(e=>({...e}))}}var _=t(45445),w=t(66810),N=t(13768),C=t(9314),$=t(14232),I=t(78392),S=t(51361),A=t(35160),D=t(39229),R=t(19357),O=t(60230),q=t(9510);let M=e=>({type:{kind:"enum",values:e},required:!0,nullable:!1,default:null,help:""}),P=(0,S.Km)(S.vr,0,32);function E(e,l){return{kind:"literal",field:l,value:e}}function F(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function T(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:[]}function J(e,l=!0){return(0,s.wN)(e).filter(({field:e})=>!l||null!==(0,S.y7)(e))}function z(e,l){return e.type.kind===l.type.kind&&("reference"!==e.type.kind||"reference"===l.type.kind&&e.type.reference_kind===l.type.reference_kind)}function V(e){return["integer","decimal","number","string","enum","datetime"].includes(e.type.kind)}function L(e){return JSON.stringify(e)}let K={filter_items:{label:"List to filter",prompt:"Choose a list, then set the conditions for keeping items."}
1,select_items:{label:"List to sort or limit",prompt:"Choose a list, then sort it, remove duplicates or limit its size."},aggregate_items:{label:"List to calculate from",prompt:"Choose a list, then count items or calculate values from its fields."}};function U({kind:e,node:l,fields:t,disabled:i,onChange:a,...s}){let r,o,u=(0,S._E)(l),c=function(e){if(!e||"object"!==e.field.type.kind)return[];let l=e.field.type;return e.members.flatMap(e=>{let t=l.members.find(l=>l.name===e.name)?.field;return t?[{name:e.name,field:t,source:e.source}]:[]})}(u),m={...s,currentNodeId:l.id},p=(e,t,n)=>{let i=e.length?{kind:"object_value",field:(0,S.TD)(e.map(({name:e,field:l})=>({name:e,field:l}))),members:e.map(({name:e,source:l})=>({name:e,source:l}))}:null;a((0,d.Jj)(l,[],i).inputs,t,n)},f=(e,l,t,n)=>{let i=c.filter(l=>l.name!==e);p(l&&t?[...i,{name:e,source:l,field:t}]:i,n)},h=e=>c.find(l=>l.name===e),b=(e,l,t,n)=>f(e,void 0===l?null:E(l,t),void 0===l?null:t,n),x=h("items")?.field,v=x?.type.kind==="list"?x.type.item:null;return(0,n.jsx)("div",{className:"space-y-4","data-testid":`data-task-${e}`,children:"append_lists"===e?(0,n.jsx)(ee,{...m,root:u,disabled:i,onChange:(e,l)=>f("lists",e,l)}):"join_lists"===e?(0,n.jsx)(el,{...m,root:u,disabled:i,left:h("left")??null,right:h("right")??null,onMember:f,onMembers:e=>{let l=new Set(e.map(e=>e.name));p([...c.filter(e=>!l.has(e.name)),...e])}}):(0,n.jsxs)(n.Fragment,{children:[(r="items",o=K[e],(0,n.jsx)(B,{...m,...o,value:h(r)?.source??null,disabled:i,filter:e=>"list"===e.type.kind,onChange:(e,l)=>f(r,e,l)})),v&&"filter_items"===e?(0,n.jsx)(X,{root:u,item:v,limits:s.catalogue.rule_limits,disabled:i,fields:t,node:l,onMember:f}):v&&"aggregate_items"===e?(0,n.jsx)(et,{root:u,item:v,disabled:i,onFixed:b}):v&&"select_items"===e?(0,n.jsx)(en,{root:u,item:v,disabled:i,fields:t,node:l,onFixed:b}):null]})})}function B({label:e,prompt:l,value:t,disabled:i,filter:d,onChange:o,...u}){let c=(0,$.useId)(),m=(0,$.useId)(),p=(0,s.Ph)(u,null).filter(e=>e.field&&d(e.field)),f=t?p.find(e=>a()(e.binding,t)):null,h=t&&!f?L(t):null,b=p.some(e=>null===e.disabledReason),x=h?"The saved list source is no longer available. Choose another source.":f?.disabledReason?`${f.disabledReason} Choose another source.`:null,v=f?.field&&!x?function(e){if("list"!==e.type.kind)return"";let l=e.type.item.type;if("object"===l.kind){let e=l.members.map(e=>e.name);return e.length?`Expects a list of records with ${e.slice(0,3).join(", ")}${e.length>3?" and other fields":""}.`:"Expects a list of records."}let t="string"===l.kind||"enum"===l.kind?"text values":["integer","decimal","number"].includes(l.kind)?"numbers":"boolean"===l.kind?"yes or no values":"datetime"===l.kind?"dates and times":"list"===l.kind?"lists":"values";return`Expects a list of ${t}.`}(f.field):b?l:"No list is available here. Add a step that returns a list, then choose its result.";return(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{children:e}),(0,n.jsx)(q.Hq,{label:e,describedBy:[v?c:null,x?m:null].filter(Boolean).join(" ")||void 0,value:f?L(f.binding):h??"",disabled:i,options:[{value:"",label:"Cho
1ose a listâ¦",disabled:!0},...h?[{value:h,label:"Saved source \xb7 unavailable",disabled:!0}]:[],...p.map(e=>({value:L(e.binding),label:function(e,l){let t=l.binding;if("node_output"!==t.kind)return l.label;let n=(0,r.nb)(e.definition,t.node_id),i=null!==n?(0,r.di)(e.definition,n)?.nodes.find(e=>e.id===t.node_id):void 0;return i?.kind!=="task"?l.label:`${i.label}${t.path.length?` \xb7 ${t.path.join(" ⺠")}`:""}`}(u,e),disabled:null!==e.disabledReason}))],onChange:e=>{let l=p.find(l=>L(l.binding)===e);l?.field&&!l.disabledReason&&o(l.binding,l.field)}}),v?(0,n.jsx)(C.ry,{id:c,children:v}):null,x?(0,n.jsx)(C.bg,{id:m,children:x}):null]})}function G({label:e,item:l,value:t,disabled:i,accept:a,onChange:s,onClear:r}){let d=J(l,!1).filter(({field:e})=>a?a(e):null!==(0,S.y7)(e)),o=JSON.stringify(t);return(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{children:e}),(0,n.jsx)(q.Hq,{label:e,value:d.some(e=>JSON.stringify(e.path)===o)?o:"",disabled:i,options:[{value:"",label:r?"None":"Choose a fieldâ¦",disabled:!r},...d.map(e=>({value:JSON.stringify(e.path),label:e.path.length?e.path.join(" ⺠"):"Item"}))],onChange:e=>{if(!e&&r)return void r();let l=d.find(l=>JSON.stringify(l.path)===e);l&&s(l.path,l.field)}})]})}function W(){return{kind:"predicate",path:[],operator:"is_available"}}function H(e){return{kind:e,left:W(),right:W()}}function Y(e){if("predicate"===e.kind)return{depth:1,predicates:1};if("not"===e.kind){let l=Y(e.child);return{depth:l.depth+1,predicates:l.predicates}}let l=Y(e.left),t=Y(e.right);return{depth:Math.max(l.depth,t.depth)+1,predicates:l.predicates+t.predicates}}function X({root:e,item:l,limits:t,disabled:i,fields:a,node:s,onMember:r}){let d=function e(l){let t=F(l);if("predicate"===t.kind&&Array.isArray(t.path)&&t.path.every(e=>"string"==typeof e)&&"string"==typeof t.operator){let e=A.Nj.find(e=>e.value===t.operator)?.value;return e?{kind:"predicate",path:t.path,operator:e,...void 0===t.scalar_kind?{}:{scalar_kind:t.scalar_kind},...void 0===t.value?{}:{value:t.value}}:null}if("all"===t.kind||"any"===t.kind){let l=e(t.left),n=e(t.right);return l&&n?{kind:t.kind,left:l,right:n}:null}if("not"===t.kind){let l=e(t.child);return l?{kind:"not",child:l}:null}return null}((0,S.Zj)(e,"predicate")),o=(e,t)=>{let n=e?function e(l,t){let n=M([l.kind]),i=[{name:"kind",field:n,source:E(l.kind,n)}];if("predicate"===l.kind){let e=M(A.Nj.map(e=>e.value));i.push({name:"path",field:P,source:E(l.path,P)},{name:"operator",field:e,source:E(l.operator,e)}),void 0!==l.scalar_kind&&i.push({name:"scalar_kind",field:S.vr,source:E(l.scalar_kind,S.vr)});let n=(0,S.wy)(t,l.path),a=A.Nj.find(e=>e.value===l.operator)?.value;if(void 0!==l.value&&n&&a&&!(0,A.rM)(a)){let e=(0,A.R)(n,a);i.push({name:"value",field:e,source:E(l.value,e)})}}else if("not"===l.kind){let n=e(l.child,t);i.push({name:"child",field:n.field,source:n})}else{let n=e(l.left,t),a=e(l.right,t);i.push({name:"left",field:n.field,source:n},{name:"right",field:a.field,source:a})}return{kind:"object_value",field:(0,S.TD)(i.map(({name:e,field:l})=>({name:e,field:l}))),members:i.map(({name:e,source:l})=>({name:e,source:l}))}}(e,l):null;r("predicate",n,n?.field??null,t)};return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:"Keep items when"}),d&&Y(d).predicates>=t.maximum_predicates?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Limit of ",t.maximum_predicates," conditions reached"]}):null]}),d?(0,n.jsx)(Q,{rule:d,item:l,path:[],node:s,fields:a,disabled:i,canSave:e=>{let l=Y(e);return l.depth<=t.maximum_depth&&l.predicates<=t.maximum_predicates},onChange:o,onRemove:()=>o(null)}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)(w.$,{type:"button",variant:"outline",disabled:i,onClick:()=>o(W()),children:"Add Condition"}),(0,n.jsxs)(D.rI,{children:[(0,n.jsx)(D.ty,{render:(0,n.jsx)(w.$,{variant:"ghost",disabled:i}),children:"More Options"}),(0,n.jsx)(D.SQ,{children:(0,n.jsxs)(D.I,{children:[(0,n.jsx)(D._2,{onClick:()=>o(H("all")),children:"Match All Conditions"}),(0,n.jsx)(D._2,{onClick:()=>o(H("any")),children:"Match Any Condition"})]})})]})]})]})}function Q({rule:e,item:l,path:t,node:i,fields:a,disabled:s,canSave:r,onChange:d,onRemove:o}){let u=t.map(e=>e+1).join(".");return(0,n.jsxs)("section",{"aria-label":u?`Filter ${u}`:"Filter",className:t.length?"flex flex-col gap-3 border-l pl-3":"flex flex-col gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:"all"===e.kind?"All conditions":"any"===e.kind?"Any condition":"not"===e.kind?"Does not match":"Condition"}),(0,n.jsxs)(D.rI,{children:[(0,n.jsx)(D.ty,{render:(0,n.jsx)(w.$,{type:"button",size:"icon-sm",variant:"ghost",disabled:s,"aria-label":"Condition Options"}),children:(0,n.jsx)(I.Ym0,{})}),(0,n.jsx)(D.SQ,{align:"end",children:(0,n.jsxs)(D.I,{children:[["all","any","not"].map(l=>{let t="not"===l?{kind:l,child:e}:{kind:l,left:e,right:W()};return(0,n.jsx)(D._2,{disabled:s||!r(t),onClick:()=>{let t;r(t="not"===l?{kind:l,child:e}:{kind:l,left:e,right:W()})&&d(t)},children:"all"===l?"Add Condition":"any"===l?"Add Alternative":"Reverse Match"},l)}),(0,n.jsx)(D._2,{variant:"destructive",disabled:s,onClick:o,children:"Remove Condition"})]})})]})]}),"predicate"===e.kind?(0,n.jsx)(Z,{predicate:e,item:l,node:i,fields:a,bufferName:`predicate-value-${u||"root"}`,disabled:s,onChange:d}):"not"===e.kind?(0,n.jsx)(Q,{item:l,node:i,fields:a,disabled:s,canSave:r,rule:e.child,path:[...t,0],onChange:(e,l)=>
1d({kind:"not",child:e},l),onRemove:()=>d(e.child)}):(0,n.jsxs)(C.M_,{children:[(0,n.jsx)(Q,{item:l,node:i,fields:a,disabled:s,canSave:r,rule:e.left,path:[...t,0],onChange:(l,t)=>d({...e,left:l},t),onRemove:()=>d(e.right)}),(0,n.jsx)(Q,{item:l,node:i,fields:a,disabled:s,canSave:r,rule:e.right,path:[...t,1],onChange:(l,t)=>d({...e,right:l},t),onRemove:()=>d(e.left)})]})]})}function Z({predicate:e,item:l,disabled:t,fields:i,node:s,bufferName:r,onChange:d}){let o=e.path,u=J(l,!1).find(e=>a()(e.path,o))?.field??null,c=e.operator,m=A.Nj.find(e=>e.value===c),p=u?A.Nj.filter(e=>!(0,A.HH)(e.value,u)):[];return(0,n.jsxs)(C.M_,{children:[(0,n.jsx)(G,{label:"Field to check",item:l,value:o,disabled:t,accept:()=>!0,onChange:(e,l)=>d({kind:"predicate",path:e,scalar_kind:(0,S.y7)(l)??void 0,operator:"is_available"})}),u?(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{children:"Check"}),(0,n.jsx)(q.i8,{label:"Filter check",value:p.some(e=>e.value===c)?c:"",disabled:t,options:[{value:"",label:"Choose a checkâ¦",disabled:!0},...p.map(e=>({value:e.value,label:(0,A.Qp)(e.value,u)}))],onChange:e=>{let l=A.Nj.find(l=>l.value===e);l&&d((0,A.rM)(l.value)?{kind:"predicate",path:o,operator:l.value}:{kind:"predicate",path:o,scalar_kind:function(e,l){if(l.startsWith("count_"))return"integer";let t="list"===e.type.kind?e.type.item:e;return(0,S.y7)(t)??void 0}(u,l.value),operator:l.value})}})]}):null,u&&c&&m&&!(0,A.rM)(m.value)?(0,n.jsx)(ei,{node:s,name:"Filter value",textRows:1,formatHint:"",bufferName:r,field:(0,A.R)(u,m.value),value:e.value,fields:i,disabled:t,onChange:(l,t)=>d({...e,value:l??null},t)}):null]})}function ee({root:e,disabled:l,onChange:t,...i}){let a=e?.members.find(e=>"lists"===e.name)?.source,r=a?.kind==="list_value"?a:null,d=r?.field.type.kind==="list"?r.field.type.item:null,o=(e,l)=>t(e.length&&l?{kind:"list_value",field:(0,S.Km)(l,1,100),items:e}:null,e.length&&l?(0,S.Km)(l,1,100):null);return(0,n.jsxs)(C.M_,{children:[r?.items.map((e,t)=>(0,n.jsxs)("div",{className:"flex items-end gap-2",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsx)(B,{...i,label:`List ${t+1}`,value:e,disabled:l,filter:e=>"list"===e.type.kind&&(!d||(0,s.bD)(e,d)),onChange:e=>e&&o(r.items.map((l,n)=>n===t?e:l),d)})}),(0,n.jsx)(w.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Remove list ${t+1}`,disabled:l,onClick:()=>o(r.items.filter((e,l)=>l!==t),d),children:(0,n.jsx)(I.WeY,{})})]},`${t}-${L(e)}`)),(0,n.jsx)(B,{...i,label:r?.items.length?"Add another list":"First list",value:null,disabled:l,filter:e=>"list"===e.type.kind&&(!d||(0,s.bD)(e,d)),onChange:(e,l)=>e&&l&&o([...r?.items??[],e],d??l)})]})}function el({root:e,disabled:l,left:t,right:i,onMember:a,onMembers:s,...r}){let d="key"===(0,S.hz)(e,"match_by")?"key":"position",o=String((0,S.hz)(e,"join_kind")??"inner"),u=String((0,S.hz)(e,"duplicate_keys")??"error"),c=t?.field.type.kind==="list"?t.field.type.item:null,m=i?.field.type.kind==="list"?i.field.type.item:null,p=T((0,S.hz)(e,"left_key")),f=T((0,S.hz)(e,"right_key")),h=c?(0,S.wy)(c,p):null,b=m?(0,S.wy)(m,f):null,x=(e,l,t)=>a(e,E(l,M(t)),M(t)),v=(e,l,t)=>{var n,i;let a,r=F((n={path:l,scalar_kind:(0,S.y7)(t)},i={path:P,scalar_kind:S.vr},a=Object.keys(n).map(e=>({name:e,field:i[e]})),E(n,(0,S.TD)(a))).value);s([{name:`${e}_key`,source:E(r.path,P),field:P},{name:"scalar_kind",source:E(r.scalar_kind,S.vr),field:S.vr}])},y=(l,t,n)=>{let i=[{name:l,source:t,field:n}];void 0===(0,S.hz)(e,"match_by")&&i.push({name:"match_by",source:E("position",M(["position","key"])),field:M(["position","key"])}),void 0===(0,S.hz)(e,"join_kind")&&i.push({name:"join_kind",source:E("inner",M(["inner","left","full"])),field:M(["inner","left","full"])}),s(i)};return(0,n.jsxs)(C.M_,{children:[(0,n.jsx)(B,{...r,label:"Left list",value:t?.source??null,disabled:l,filter:e=>"list"===e.type.kind,onChange:(e,l)=>e&&l?y("left",e,l):a("left",null,null)}),(0,n.jsx)(B,{...r,label:"Right list",value:i?.source??null,disabled:l,filter:e=>"list"===e.type.kind,onChange:(e,l)=>e&&l?y("right",e,l):a("right",null,null)}),(0,n.jsx)(ea,{label:"Match rows by",value:d,disabled:l,options:[{value:"position",label:"Position"},{value:"key",label:"Matching fields"}],onChange:e=>x("match_by",e,["position","key"])}),"key"===d&&c&&m?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(G,{label:"Left match field",item:c,value:p,disabled:l,accept:e=>null!==(0,S.y7)(e)&&(!b||z(e,b)),onChange:(e,l)=>v("left",e,l)}),(0,n.jsx)(G,{label:"Right match field",item:m,value:f,disabled:l,accept:e=>null!==(0,S.y7)(e)&&(!h||z(h,e)),onChange:(e,l)=>v("right",e,l)}),(0,n.jsx)(ea,{label:"Duplicate keys",value:u,disabled:l,options:[{value:"error",label:"Stop with an error"},{value:"all",label:"Include every match"}],onChange:e=>x("duplicate_keys",e,["error","all"])})]}):null,(0,n.jsx)(ea,{label:"Rows to keep",value:o,disabled:l,options:[{value:"inner",label:"Matches only"},{value:"left",label:"Every left row"},{value:"full",label:"Every row"}],onChange:e=>x("join_kind",e,["inner","left","full"])})]})}function et({root:e,item:l,disabled:t,onFixed:i}){let a=(0,S.hz)(e,"aggregates"),s=Array.isArray(a)?a.map(F):[],r=(0,S.TD)([{name:"id",field:S.vr},{name:"label",field:S.vr},{name:"kind",field:M(["count","sum","min","max"])},{name:"path",field:{...P,required:!1}},{name:"scalar_kind",field:{...S.vr,required:!1}}]),d=e=>i("aggregates",e,(0,S.Km)(r,1,20)),o=F((0,S.hz)(e,"group_by"));return(0,n.jsxs)(C.M_,{children:[s.map((e,i)=>{let a=String(e.kind??"count");return(0,n.jsxs)(C.D0,{className:"space-y-2 border-l pl-3",children:[(0,n.jsxs)("div",{className:"flex items-end gap-2",children:[(0,n.jsxs)("label",{className:"min-w-0 flex-1 text-sm font-medium",children:["Result name",(0,n.jsx)(R.p,{"aria-label":`Aggregate ${i+1} name`,value:String(e.label??""),disabled:t,onChange:e=>d(s.map((l,t)=>t===i?{...l,label:e.target.value}:l))})]}),(0,n.jsx)(w.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Remove aggregate ${i+1}`,disabled:t,onClick:()=>d(s.filter((e,l)=>l!==i)),children:(0,n.jsx)(I.WeY,{})})]}),(0,n.jsx)(ea,{label:`Aggregate ${i+1} calculation`,value:a,disabled:t,options:[{value:"count",label:"Count rows"},{value:"sum",label:"Sum"},{value:"min",label:"Minimum"},{value:"max",label:"Maximum"}],onChange:e=>d(s.map((l,t)=>t===i?{id:l.id,label:l.label,kind:e}:l))}),"count"!==a?(0,n.jsx)(G,{label:`Aggregate ${i+1} field`,item:l,value:T(e.path),disabled:t,accept:e=>"sum"===a?["integer","decimal","number"].includes(e.type.kind):V(e),onChange:(e,l)=>
1d(s.map((t,n)=>n===i?{...t,path:e,scalar_kind:(0,S.y7)(l)}:t))}):null]},String(e.id))}),(0,n.jsxs)(w.$,{type:"button",variant:"outline",disabled:t||s.length>=20,onClick:()=>d([...s,{id:crypto.randomUUID(),label:`Result ${s.length+1}`,kind:"count"}]),children:[(0,n.jsx)(I.QCG,{})," Add Calculation"]}),(0,n.jsx)(G,{label:"Group by (optional)",item:l,value:T(o.path),disabled:t,accept:e=>e.required&&null!==(0,S.y7)(e),onClear:()=>i("group_by",void 0,(0,S.TD)([])),onChange:(e,l)=>i("group_by",{path:e,scalar_kind:(0,S.y7)(l)},(0,S.TD)([{name:"path",field:P},{name:"scalar_kind",field:S.vr}]))})]})}function en({root:e,item:l,disabled:t,fields:i,node:a,onFixed:s}){let r=F((0,S.hz)(e,"sort")),d=F((0,S.hz)(e,"unique")),o=(e,l)=>s(e,l,(0,S.TD)(Object.entries(l).map(([e])=>({name:e,field:"path"===e?P:S.vr}))));return(0,n.jsxs)(C.M_,{children:[(0,n.jsx)(G,{label:"Sort by (optional)",item:l,value:T(r.path),disabled:t,accept:e=>e.required&&V(e),onClear:()=>s("sort",void 0,(0,S.TD)([])),onChange:(e,l)=>o("sort",{path:e,scalar_kind:(0,S.y7)(l),direction:"asc",nulls:"last"})}),r.path?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ea,{label:"Sort direction",value:String(r.direction??"asc"),disabled:t,options:[{value:"asc",label:"Ascending"},{value:"desc",label:"Descending"}],onChange:e=>o("sort",{...r,direction:e})}),(0,n.jsx)(ea,{label:"Null values",value:String(r.nulls??"last"),disabled:t,options:[{value:"last",label:"Last"},{value:"first",label:"First"}],onChange:e=>o("sort",{...r,nulls:e})})]}):null,(0,n.jsx)(G,{label:"Remove duplicates by (optional)",item:l,value:T(d.path),disabled:t,accept:e=>e.required&&null!==(0,S.y7)(e),onClear:()=>s("unique",void 0,(0,S.TD)([])),onChange:(e,l)=>o("unique",{path:e,scalar_kind:(0,S.y7)(l),keep:"first"})}),d.path?(0,n.jsx)(ea,{label:"Duplicate to keep",value:String(d.keep??"first"),disabled:t,options:[{value:"first",label:"First"},{value:"last",label:"Last"}],onChange:e=>o("unique",{...d,keep:e})}):null,(0,n.jsx)(ei,{node:a,name:"Limit (optional)",bufferName:"limit",field:{...S.cm,required:!1},value:(0,S.hz)(e,"limit"),fields:i,disabled:t,onChange:(e,l)=>s("limit",e,S.cm,l)})]})}function ei({node:e,name:l,bufferName:t,field:i,value:a,fields:s,disabled:r,textRows:o,formatHint:u,onChange:c}){let m=(0,d.D2)(e,[t]),p=s[m];return(0,n.jsx)(O.j,{field:i,label:l,value:a,buffer:p?.kind==="field"?p:void 0,disabled:r,textRows:o,formatHint:u,onChange:(e,l)=>c(e,{key:m,buffer:{kind:"field",...l}})})}function ea({label:e,value:l,disabled:t,options:i,onChange:a}){return(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{children:e}),(0,n.jsx)(q.i8,{label:e,value:l,disabled:t,options:i,onChange:a})]})}var es=t(27148),er=t(65221),ed=t(56931),eo=t(58699),eu=t(13910),ec=t(75166),em=t(63492),ep=t(79104),ef=t(26265),eh=t(71172),eb=t(40177);function ex({kind:e,field:l,value:t,buffer:i,disabled:a,onChange:s}){let r,d=i?.draft?.editor,o=d?.kind==="literal"?d.value:t?.kind==="literal"?t.value:void 0,u=(0,x.qt)(o)?o:"plus"===e?{search:{kind:"person",query:"",total_results:"20"}}:{},c=(0,x.qt)(u.search)?u.search:{kind:"person",query:"",total_results:"20"},m="plus"===e?"org"===c.kind?"organisations":"people":e,p=(0,ed.QP)((0,eo.hk)(m),{}),f=(0,ed.qd)((0,eu._4)(m),{});try{var h,k,_,w;h=u,k=e,r={tree:v("plus"===k?{}:h),sorting:(_="plus"===k?void 0:h.sorting,y.parse(_??[])),sources:(w="plus"===k?h.sources:void 0,g.parse(w??{}))}}catch{return(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"This saved search needs repair. Use input mappings below to inspect its values."})}let N="plus"===e?[]:(0,b.Jm)(r.tree,m,p),C=n=>{if(a)return;let i="plus"===e?[]:(0,b.Jm)(v(n),m,p),r=0===(0,x.L)(l,n).length&&0===i.length&&("plus"!==e||(0,x.qt)(n.search)&&"string"==typeof n.search.query&&n.search.query.trim().length>0),d=r?{kind:"literal",field:l,value:n}:t;s(d,{kind:"binding",valid:r,draft:{source:d,editor:{kind:"literal",field:l,value:n,fieldDraft:[],contractDraft:[],contractValid:!0}}})},$=d?.kind==="literal"?(0,x.L)(l,u):[];return(0,n.jsxs)("fieldset",{disabled:a,className:"min-w-0 space-y-3","aria-label":"Search settings",children:[(0,n.jsx)("div",{inert:a,className:"min-w-0 space-y-3",children:"plus"===e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(em.J,{children:"Find"}),(0,n.jsx)(q.i8,{label:"Search for",value:"org"===c.kind?"org":"person",options:[{value:"person",label:"People"},{value:"org",label:"Organisations"}],onChange:e=>{let{candidate_person_ids:l,candidate_org_ids:t,include_company_connections:n,...i}=c;C({...u,search:{...i,kind:e},sources:j({...r.sources,include_tables:[],exclude_tables:[]})})}}),(0,n.jsx)(em.J,{children:"Describe who to find"}),(0,n.jsx)(ep.T,{"aria-label":"Search query",placeholder:"For example, founders of climate technology companies in Europe",value:"string"==typeof c.query?c.query:"",onCh
1ange:e=>C({...u,search:{...c,query:e.target.value}})}),(0,n.jsx)(em.J,{children:"Results"}),(0,n.jsx)(R.p,{"aria-label":"Search result count",inputMode:"numeric",value:"string"==typeof c.total_results?c.total_results:"20",onChange:e=>C({...u,search:{...c,total_results:e.target.value}})}),(0,n.jsx)(eb.R,{queryType:"org"===c.kind?"companies":"people",sources:r.sources,disabled:a,onChange:e=>C({...u,search:c,sources:j(e)})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ev,{entity:m,draft:r.tree,sort:r.sorting,availableFields:p,availableSortFields:f,allowNestedGroups:!1,validationErrors:Object.fromEntries(N.map(e=>[e.nodeId,e.message])),onDraftChange:e=>C({...u,clauses:e.children.map(e=>{if("condition"!==e.type)throw Error("Workflow searches support one group of conditions");return{field:e.field,operator:e.operator,value:function(e,l){if("string"==typeof e)return{kind:"text",value:e};if("boolean"==typeof e)return{kind:"boolean",value:e};if("number"==typeof e)return{kind:"number",value:e};if(Array.isArray(e))return e.every(e=>"string"==typeof e)?{kind:"texts",value:e}:e.every(e=>"number"==typeof e)?{kind:"numbers",value:e}:{kind:"resources",value:e.map(e=>{if(null===e||"object"!=typeof e)throw Error("Choose a table or board");return{...e,kind:l.startsWith("board.")?"board":"table"}})};throw Error("This filter value cannot be used in a workflow")}(e.value,e.field)}}),match:"or"===e.combinator?"any":"all"}),onSortChange:e=>C({...u,sorting:e.map(e=>({...e}))})}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Match all or any conditions. This workflow task reads one page of results."}),(0,n.jsx)(em.J,{children:"Results per page"}),(0,n.jsx)(R.p,{"aria-label":"Results per page",inputMode:"numeric",value:"string"==typeof u.limit?u.limit:String("object"===l.type.kind?l.type.members.find(e=>"limit"===e.name)?.field.default?.value??"50":"50"),onChange:e=>C({...u,limit:e.target.value})})]})}),$.length?(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:$[0]?.message}):null,i?.valid!==!1||$.length||N.length?null:(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Finish the search settings before saving."})]})}function ev(e){let l=[...new Set(e.draft.children.flatMap(e=>"condition"===e.type&&"table.member_of"===e.field?(0,ec.xN)(e.value).map(ec.fO):[]))],t=(0,es.E)({queries:l.map(e=>({queryKey:eh.v.byId((0,f.LM)(e)),queryFn:({signal:l})=>er.T0.getTableById(e,{},l),retry:!1}))}),i=l.map((e,l)=>({id:e,name:t[l]?.data?.table.name??(t[l]?.isPending?"Loading tableâ¦":t[l]?.isError?"Couldnât load table":"Unavailable table")}));return(0,n.jsx)(ef.K9,{...e,lists:i})}var ey=t(58439),ek=t(34216),eg=t(1202),ej=t(36937),e_=t(26514);let ew={type:{kind:"object",members:[]},required:!0,nullable:!1,default:null,help:""};function eN({node:e,fields:l,disabled:t,onChange:i,...a}){let r=(0,eg.yq)(),o=(0,s.A1)(e)??ew,u=e.inputs.find(e=>0===e.target.length)?.source,c=u?.kind==="object_value"?u.members:[],m="object"===o.type.kind?o.type.members.map(e=>({name:e.name,field:e.field,member:e,sourceMember:c.find(l=>l.name===e.name),source:c.find(l=>l.name===e.name)?.source??null})):[],p=l=>(0,d.D2)(e,[l]),f=l=>(0,ey.po)(e.id,l),h=e=>{let t=l[f(e.name)],n=l[p(e.name)];return t?.kind==="set_values_field"?t.draft:{name:e.name,nameValid:!0,contract:[],contractValid:!0,binding:n?.kind==="binding"?n.draft:null,bindingValid:n?.kind!=="binding"||n.valid}},b=e=>({kind:"set_values_field",draft:e,valid:e.nameValid&&e.contractValid&&e.bindingValid}),x=(l,t,n)=>{let a=l.length?{...u?.kind==="object_value"?u:void 0,kind:"object_value",field:{...o,type:{..."object"===o.type.kind?o.type:void 0,kind:"object",members:l.map(e=>({...e.member,name:e.name,field:e.field}))}},members:l.flatMap(e=>e.source?[{...e.sourceMember,name:e.name,source:e.source}]:[])}:null;i((0,d.Jj)(e,[],a).inputs,t,n)},v=(e,l,t,n)=>x(m.map((t,n)=>n===e?l:t),t,n);return(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("h3",{className:"sr-only",children:"Fields"}),m.length?(0,n.jsx)(C.M_,{"aria-label":"Fields",children:m.map((e,l)=>(0,n.jsx)(eC,{...a,row:e,index:l,rawName:h(e).name,duplicate:m.some((t,n)=>n!==l&&h(t).name===h(e).name),contractDraft:h(e).contract,buffer:h(e),disabled:t,onRename:e=>{let t,n,i,a;return n=h(t=m[l]),i=r.workflowFieldNameSchema.safeParse(e).success&&!m.some((t,n)=>n!==l&&h(t).name===e),a={...n,name:e,nameValid:i},void(!i||e===t.name?v(l,t,{key:f(t.name),buffer:b(a)}):v(l,{...t,name:e},{key:f(e),buffer:b(a)}
1,[f(t.name),p(t.name)]))},onRemove:()=>{let e;return e=m[l],void x(m.filter((e,t)=>t!==l),{key:f(e.name),buffer:b({...h(e),nameValid:!0,contractValid:!0,bindingValid:!0})},[p(e.name)])},onSource:(t,n)=>v(l,{...e,source:t},{key:f(e.name),buffer:b({...h(e),binding:n.draft,bindingValid:n.valid})},[p(e.name)]),onContract:(t,n,i)=>{v(l,i?{...e,field:t}:e,{key:f(e.name),buffer:b({...h(e),contract:n,contractValid:i})})}},l))}):(0,n.jsx)(C.ry,{children:"Add a field to shape this stepâs result."}),(0,n.jsx)(w.$,{type:"button",variant:"outline",disabled:t,onClick:()=>{let e=m.map(e=>e.name),l="field";for(let t=2;e.includes(l);t+=1)l=`field_${t}`;x([...m,{name:l,field:{type:{kind:"string",minimum_length:0,maximum_length:262144},required:!0,nullable:!1,default:null,help:""},source:null}])},children:"Add Field"})]})}function eC({row:e,index:l,rawName:t,duplicate:i,contractDraft:a,buffer:s,disabled:r,onRename:d,onRemove:o,onSource:u,onContract:c,...m}){let p=(0,eg.yq)(),f=(0,e_.Q)(e.field),h={kind:"binding",draft:s.binding,valid:s.bindingValid},b=e.source||h?.draft?h:f??h,x=t!==e.name&&!p.workflowFieldNameSchema.safeParse(t).success;return(0,n.jsxs)(C.D0,{"data-testid":`set-values-field-${l}`,children:[(0,n.jsx)(ej.A,{...m,compact:!0,pristine:b===f,target:e.field,value:e.source,buffer:b,label:e.name,disabled:r,onChange:u,title:(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(R.p,{"aria-label":`Field ${l+1} name`,value:t,disabled:r,onChange:e=>d(e.target.value)}),i?(0,n.jsx)(C.bg,{children:"Another field already uses this name."}):x?(0,n.jsx)(C.bg,{children:"Enter a valid field name."}):null]}),actions:(0,n.jsxs)(n.Fragment,{children:[e.source?(0,n.jsx)(w.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Clear ${e.name}`,disabled:r,onClick:()=>u(null,{kind:"binding",draft:null,valid:!0}),children:(0,n.jsx)(I.IeJ,{})}):null,(0,n.jsx)(w.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Remove ${e.name}`,disabled:r,onClick:o,children:(0,n.jsx)(I.WeY,{})})]})}),(0,n.jsxs)(N.Nt,{children:[(0,n.jsx)(N.R6,{render:(0,n.jsx)(w.$,{type:"button",variant:"ghost",size:"sm",className:"px-0"}),children:`Type and Settings: ${e.name}`}),(0,n.jsx)(N.Ke,{children:(0,n.jsx)("div",{className:"pt-3",children:(0,n.jsx)(ek.d,{field:e.field,draft:a,label:e.name,disabled:r,onChange:e=>c(e.field,e.draft,e.valid)})})})]})]})}var e$=t(88332),eI=t(68661);function eS({namespace:e,taskKey:l,graphKey:t,children:i}){return(0,n.jsx)(eI.A,{href:(0,e$.MF)(e,l,t),className:(0,w.r)({variant:"outline",size:"sm"}),children:i})}function eA({task:e}){return(e.workflow_inspections??[]).length?(0,n.jsxs)("section",{"aria-label":`${e.title} internal workflow`,className:"space-y-3 border-b pb-3",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Inspect the steps inside ",e.title," on a full page. These steps are not separate actions you can add or edit."]}),(0,n.jsx)(eS,{namespace:e.identity.namespace,taskKey:e.identity.key,children:"Open Internal Workflow"})]}):null}var eD=t(48416),eR=t(79246);function eO({id:e,value:l,disabled:t,onChange:i}){let a=(0,$.useMemo)(()=>(function(){let e=new Set(["UTC"]);if("function"==typeof Intl.supportedValuesOf)for(let l of Intl.supportedValuesOf("timeZone"))e.add(l);return[...e]})(),[]),[s,r]=(0,$.useState)("UTC"),d={timezone_mode:"fixed",timezone:s},o=l?(0,eR.Xu)(l,d).slice(0,19):"",u=o?(0,eR.C0)(o,d,l):void 0;return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{htmlFor:e,children:"Continue at"}),(0,n.jsx)(R.p,{id:e,type:"datetime-local",step:1,value:o,disabled:t,onChange:e=>{let t=e.currentTarget.value;if(!t)return void i(void 0,!1);let n=(0,eR.C0)(t,d,l);i(n,void 0!==n)}}),(0,n.jsx)(C.ry,{children:"A past time continues immediately when the step starts."}),l&&!u?(0,n.jsx)(C.bg,{children:"Enter a real local date and time."}):null]}),(0,n.jsx)(q.i8,{id:`${e}-timezone`,label:"Timezone",value:s,options:a.map(e=>({value:e,label:e})),disabled:t,onChange:e=>{if(r(e),!o)return;let t=(0,eR.C0)(o,{timezone_mode:"fixed",timezone:e},l);i(t,void 0!==t)}})]})}var eq=t(26489),eM=t(17632),eP=t(13172),eE=t(75982),eF=t(64304);function eT({value:e,disabled:l,onChange:t}){let{current:i}=(0,eP.k9)(),a=(0,eM.ur)(),s=a.user?.id?(0,f.OZ)(a.user.id):null,r=(0,eF.sp)(i?.slug??null),d=[...new Set([...s?[s]:[],...(0,$.useMemo)(()=>(r.data?.pages??[]).flatMap(e=>e.items.map(e=>e.user_id)),[r.data]),...e])],o=(0,eE.Ww)(d.filter(e=>e!==s)),u=d.map(e=>{let l=o.dataByAuth0Id.get(e),t=l?.target?.name?.trim()||l?.emails?.[0];return{value:e,label:e===s?a.user?.name||a.user?.email?`${a.user.n
1ame||a.user.email} (you)`:"You":t||e}}),c=[...new Set(e)],m=0===c.length?"Name at least one person who may answer.":c.length>_.RT?`Name at most ${_.RT} people.`:c.length!==e.length?"Each person can appear only once.":null;return(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{children:"People who may answer"}),(0,n.jsx)(q.km,{label:"People who may answer",value:c,options:u,disabled:l,placeholder:"Choose people",onChange:e=>{let l=[...new Set(e)].map(f.OZ);t(l,l.length>=1&&l.length<=_.RT)}}),(0,n.jsx)(C.ry,{children:"Each person also needs access to this workflow run. Naming them here does not grant access."}),a.isLoading||i&&r.isLoading||o.isLoading?(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading peopleâ¦"}):null,a.isError||r.isError||o.isError?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Some people could not be loaded. Your selected people are kept."}),(0,n.jsx)(w.$,{type:"button",size:"sm",variant:"outline",disabled:l,onClick:()=>{a.isError&&a.refreshUser(),r.isError&&r.refetch(),o.isError&&o.retry()},children:"Retry Loading People"})]}):null,r.hasNextPage?(0,n.jsx)(w.$,{type:"button",size:"sm",variant:"outline",disabled:l||r.isFetchingNextPage,onClick:()=>{r.fetchNextPage()},children:r.isFetchingNextPage?"Loading Peopleâ¦":"Load More People"}):null,m?(0,n.jsx)(C.bg,{children:m}):null]})}var eJ=t(93448);function ez(e,l,t,n,i,a=void 0===n?"":"string"==typeof n?n:JSON.stringify(n)){let s=(0,d.D2)(e.node,[...l]);e.onChange((0,_.aJ)(e.node,l,t,n),{key:s,buffer:{kind:"field",draft:[{path:[],source:n,text:a,touched:!0}],valid:i}})}function eV({node:e,disabled:l,onChange:t}){let i=(0,_.ay)(e,["event_type"]),a="string"==typeof i?i:"",s=eD.DG.safeParse(a);return(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{htmlFor:`${e.id}-event-type`,children:"Event type"}),(0,n.jsx)(R.p,{id:`${e.id}-event-type`,value:a,disabled:l,"aria-invalid":!s.success,onChange:e=>{let l=e.currentTarget.value;t(l,eD.DG.safeParse(l).success)}}),(0,n.jsx)(C.ry,{children:_.xH.help}),a&&!s.success?(0,n.jsx)(C.bg,{children:"Use a lower-case type of letters, numbers and underscores."}):null]})}function eL({node:e,disabled:l,onChange:t}){let i=(0,_.ay)(e,["request_content"]),a="string"==typeof i?i:"",s=a.length>=1&&a.length<=_.lr;return(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{htmlFor:`${e.id}-request-content`,children:"Request"}),(0,n.jsx)(ep.T,{id:`${e.id}-request-content`,value:a,disabled:l,"aria-invalid":!s,onChange:e=>{let l=e.currentTarget.value;t(l,l.length>=1&&l.length<=_.lr)}}),(0,n.jsx)(C.ry,{children:_.xv.help}),s?null:(0,n.jsxs)(C.bg,{children:["Write 1â",_.lr," characters of request text."]})]})}function eK({node:e,disabled:l,onChange:t}){let i=(0,_.ay)(e,["authorized_actor_id"]);return(0,n.jsxs)(C.D0,{children:[(0,n.jsx)(C.dh,{htmlFor:`${e.id}-actor`,children:"Allowed actor"}),(0,n.jsx)(R.p,{id:`${e.id}-actor`,value:"string"==typeof i?i:"",disabled:l,onChange:e=>{let l=e.currentTarget.value.trim();t(""===l?null:l,!0)}}),(0,n.jsx)(C.ry,{children:_.Hh.help})]})}function eU({props:e,label:l}){let t=`${e.node.id}:wait_schema`,i=e.fields[t];return(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:l}),e.node.wait_schema?null:(0,n.jsx)(C.bg,{children:"Choose the type this wait accepts."}),(0,n.jsx)(ek.d,{label:l,field:e.node.wait_schema??_.qk,draft:i?.kind==="contract"?i.draft:[],disabled:e.disabled,onChange:l=>e.onChange({...e.node,wait_schema:l.field},{key:t,buffer:{kind:"contract",draft:l.draft,valid:l.valid}})})]})}function eB(e){let{node:l,waitKey:t}=e,i=(0,_.ay)(l,["duration_seconds"]),a=(0,_.ay)(l,["timeout_seconds"]),s=(0,_.ay)(l,["wake_at"]),r="delay"===t?{duration_seconds:(0,_.xk)(i)??""}:"wait_until"===t?{wake_at:"string"==typeof s?s:""}:{timeout_seconds:(0,_.xk)(a)??""};return(0,n.jsxs)("div",{className:"space-y-6",children:["delay"===t?(0,n.jsx)(eq.q,{id:`${l.id}-duration`,label:"Duration in seconds",field:_.eF,value:i,disabled:e.disabled,onChange:(l,t)=>ez(e,["duration_seconds"],_.eF,l,t,l??"")}):null,"wait_until"===t?(0,n.jsx)(eO,{id:`${l.id}-wake-at`,value:"string"==typeof(0,_.ay)(l,["wake_at"])?String((0,_.ay)(l,["wake_at"])):void 0,disabled:e.disabled,onChange:(l,t)=>
1ez(e,["wake_at"],{type:{kind:"datetime"},required:!0,nullable:!1,default:null,help:""},l,t)}):null,"wait_for_event"===t||"request_approval"===t||"request_input"===t?(0,n.jsx)(eq.q,{id:`${l.id}-timeout`,label:"Timeout in seconds",field:_.pv,value:a,disabled:e.disabled,onChange:(l,t)=>ez(e,["timeout_seconds"],_.pv,l,t,l??"")}):null,"wait_for_event"===t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eV,{node:l,disabled:e.disabled,onChange:(l,t)=>ez(e,["event_type"],_.xH,l,t)}),(0,n.jsx)(eK,{node:l,disabled:e.disabled,onChange:(l,t)=>ez(e,["authorized_actor_id"],_.Hh,l,t)}),(0,n.jsx)(eU,{props:e,label:"Payload schema"})]}):null,"request_approval"===t||"request_input"===t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eT,{value:(0,_.Si)(l),disabled:e.disabled,onChange:(l,t)=>ez(e,["respondents"],_.N1,l,t)}),(0,n.jsx)(eL,{node:l,disabled:e.disabled,onChange:(l,t)=>ez(e,["request_content"],_.xv,l,t)})]}):null,"request_input"===t?(0,n.jsx)(eU,{props:e,label:"Answer schema"}):null,"delay"===t&&"0"===(0,_.ay)(l,["duration_seconds"])?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Finishes immediately"}):null,e.workflowId?(0,n.jsx)(eJ.E9,{workflowId:e.workflowId,request:r}):null]})}function eG({node:e,fields:l,onChange:t,disabled:i,onAskWhenRunning:m,workflowId:p,...f}){let h=(l,n,i)=>{let a,s,r,o=(a=c(e),s=c(l),r=[],(a.tableId!==s.tableId&&r.push("table"),a.boardId!==s.boardId&&r.push("board"),r.length)?{...l,inputs:l.inputs.filter(({source:e})=>"literal"!==e.kind||!r.some(l=>(0,u.$s)(e.field,l)))}:l),m=[...l.inputs.filter(e=>!o.inputs.includes(e)).map(l=>(0,d.D2)(e,l.target)),...i??[]];m.length?t(o,n,m):t(o,n)},b="task"===e.kind?f.catalogue.items.find(l=>l.identity.id===e.task_id):void 0,x="workflow"===e.kind?(0,s.by)(f.catalogue,e):void 0,v=b?.inputs??(x?(0,s.Mu)(x.inputs):void 0),y=b?.outputs??(x?(0,s.Mu)(x.outputs):void 0),k=(0,r.di)(f.definition,f.scopePath),g=e=>{let l;return x?x.inputs.find(l=>l.id===e)?.label??e:(l=e.replace(/_/g," ")).charAt(0).toUpperCase()+l.slice(1)},j=v?(0,s.wN)(v).filter(e=>1===e.path.length):[],$=v?.type.kind==="object"&&0===v.type.members.length&&!v.nullable,I=j.length?j:v&&!$?[{path:[],field:v}]:[],S=e=>e.required&&null===e.default,A=I.filter(e=>S(e.field)),D=I.filter(e=>!S(e.field)),R=D.some(l=>e.inputs.some(e=>a()(e.target,l.path))),O=j.length&&v?v:null,q=e.inputs.find(e=>0===e.target.length),M=(0,d.D2)(e,[]),P=l[M],E=e.inputs.filter(e=>!I.some(l=>a()(l.path,e.target))&&!(O&&0===e.target.length)),F=(0,_.Ly)(b);if(F&&b&&"task"===e.kind)return(0,n.jsxs)("section",{"aria-label":"Step input mappings",className:"flex flex-col gap-4",children:[(0,n.jsx)(eA,{task:b},b.identity.id),(0,n.jsx)(eB,{workflowId:p,node:e,waitKey:F,fields:l,disabled:i,onChange:(l,t,n
1)=>h({...e,inputs:l.inputs,wait_schema:l.wait_schema},t,n)})]});if(b?.authored_contract==="set_values"&&"task"===e.kind)return(0,n.jsxs)("section",{"aria-label":"Step input mappings",className:"flex flex-col gap-4",children:[(0,n.jsx)(eA,{task:b},b.identity.id),(0,n.jsx)(eN,{...f,currentNodeId:e.id,node:e,fields:l,disabled:i,onChange:(l,t,n)=>h({...e,inputs:l},t,n)})]});if(b?.authored_contract&&"set_values"!==b.authored_contract&&"task"===e.kind)return(0,n.jsxs)("section",{"aria-label":"Step input mappings",className:"flex flex-col gap-4",children:[(0,n.jsx)(eA,{task:b},b.identity.id),(0,n.jsx)(U,{...f,currentNodeId:e.id,kind:b.authored_contract,node:e,fields:l,disabled:i,onChange:(l,t,n)=>h({...e,inputs:l},t,n)})]});let T=b?function(e){if("first_party"!==e.identity.owner.kind)return null;let{namespace:l,key:t}=e.identity;return"search"===l&&("people"===t||"organisations"===t)?t:"search_plus"===l&&"search"===t?"plus":null}(b):null,J=null!==T&&e.inputs.every(e=>0===e.target.length&&"literal"===e.source.kind)&&(!P||"binding"===P.kind&&(!P.draft||"literal"===P.draft.editor.kind)),z=(t,s,r)=>{let u=(0,d.D2)(e,t),c=l[u],p=e.inputs.find(e=>a()(e.target,t)),b=p?.source.kind==="workflow_input"&&k?(0,o.me)(k,e.id,t)?.label??"Workflow input":null;return(0,n.jsx)(e_.o,{...f,currentNodeId:e.id,target:t,field:s,label:r,noun:"workflow"===e.kind?"workflow":"task",mapping:p?.source??null,buffer:c?.kind==="binding"?c:void 0,disabled:i,overlap:(0,d.R7)(e,t),askedLabel:b,onAsk:m&&s?()=>m(t,s,r):void 0,onChange:(l,n)=>h((0,d.Jj)(e,t,l),{key:u,buffer:n}),onClear:()=>h({...e,inputs:e.inputs.filter(e=>!a()(e.target,t))},{key:u,buffer:{kind:"binding",draft:null,valid:!0}})},JSON.stringify(t))};return(0,n.jsx)(u.E5.Provider,{value:c(e,v),children:(0,n.jsxs)("section",{"aria-label":"workflow"===e.kind?"Workflow call input mappings":"Step input mappings",className:"flex flex-col gap-4",children:[b?(0,n.jsx)(eA,{task:b},b.identity.id):null,J&&T&&v?(0,n.jsx)(ex,{kind:T,field:v,value:q?.source??null,buffer:P?.kind==="binding"?P:void 0,disabled:i,onChange:(l,t)=>h((0,d.Jj)(e,[],l),{key:M,buffer:t})}):T?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"This search uses mapped inputs. Edit their sources below."}):null,(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("h3",{className:"sr-only",children:"Inputs"}),I.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.M_,{"aria-label":"Inputs",children:(A.length?A:D).map(e=>z(e.path,e.field,e.path.length?g(String(e.path[0])):"All inputs"))}),A.length&&D.length?(0,n.jsxs)(N.Nt,{defaultOpen:R,children:[(0,n.jsxs)(N.R6,{render:(0,n.jsx)(w.$,{type:"button",variant:"ghost",size:"sm",className:"px-0"}),children:["Optional inputs (",D.length,")"]}),(0,n.jsx)(N.Ke,{children:(0,n.jsx)(C.M_,{"aria-label":"Optional inputs",className:"pt-3",children:D.map(e=>z(e.path,e.field,g(String(e.path[0]))))})})]}):null]}):$?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"This step doesnât need any values from you."}):(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Choose a current ","workflow"===e.kind?"workflow":"task"," ","to configure its inputs. Existing mappings stay here for repair."]}),O?(0,n.jsxs)(N.Nt,{defaultOpen:!!q,children:[(0,n.jsx)(N.R6,{render:(0,n.jsx)(w.$,{type:"button",variant:"ghost",size:"sm",className:"px-0"}),children:"Map all inputs from one source"}),(0,n.jsx)(N.Ke,{children:(0,n.jsx)("div",{className:"pt-3",children:z([],O,"All inputs")})})]}):null,E.length?(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("h4",{className:"text-sm font-medium",children:"Unavailable inputs"}),(0,n.jsx)(C.M_,{"aria-label":"Unavailable inputs",children:E.map(e=>z(e.target,null,e.target.join(" ⺠")||"All inputs"))})]}):null,I.length?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Fill in the required values before trying this step. You can leave optional values as they are."}):null]}),y?(0,n.jsxs)(N.Nt,{className:"border-t pt-3",children:[(0,n.jsx)(N.R6,{render:(0,n.jsx)(w.$,{variant:"ghost",size:"sm"}),children:"What This Step Returns"}),(0,n.jsxs)(N.Ke,{className:"pt-3 text-sm",children:[(0,n.jsx)("h3",{className:"font-medium",children:"Output fields"}),(0,n.jsx)("dl",{className:"mt-2 space-y-2",children:(0,s.wN)(y).map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:[x?.outputs.find(l=>
1l.id===e.path[0])?.label??e.path[0],...e.path.slice(1)].filter(Boolean).join(" ⺠")||"Complete output"}),(0,n.jsxs)("dd",{className:"text-muted-foreground",children:[(0,s.oS)(e.field),e.field.nullable?" \xb7 nullable":"",e.field.required?"":" \xb7 optional"]})]},JSON.stringify(e.path)))})]})]}):null]})})}},88113:(e,l,t)=>{t.d(l,{FE:()=>o,GK:()=>u,OP:()=>d,tH:()=>r});var n=t(48416),i=t(9516),a=t(45445);let s=new Set(["task","workflow","for_each","for_each_batch","repeat_n","first_match","all_matches","filter","if_else","parallel","wait_all_selected","wait_all_outcomes","first_success","n_successes","try_catch","finally"]);function r(e){return s.has(e.kind)}function d(e,l){let t=[];if(!function e(l,t,a,s){if(a.push(s),l.nodes.some(e=>e.id===t))return!0;for(let s of l.nodes){if((0,i.Up)(s).some(e=>e.id===t))return a.push({owner:s,branchId:t}),!0;for(let l of(0,i.RX)(s)){let i=(0,n.YO)(s)?{owner:s,branchId:l.path[1]??null}:{owner:s,branchId:null};if(e(l.definition,t,a,i))return!0}}return a.pop(),!1}(e,l,t,{owner:null,branchId:null}))return null;let a=[];for(let e of t)if(e.owner?.id!==l&&(e.owner?.timeout&&a.push(e.owner.timeout.timeout_seconds),e.branchId&&e.branchId!==l&&e.owner)){let l=(0,i.Up)(e.owner).find(l=>l.id===e.branchId);l?.timeout&&a.push(l.timeout.timeout_seconds)}return a.length?Math.min(...a):null}function o(e,l,t=null){let n=("kind"in e?e.kind:null)?e:null,i=n?.kind==="task"?l.items.find(e=>e.identity.id===n.task_id):null,s=!!n&&("task"===n.kind||"workflow"===n.kind),d=!n||r(n)&&!(0,a.Nx)((0,a.B3)(l,n)),u=s?n?.kind==="workflow"?l.call_retry:i?.retry??null:null,c=n?.kind==="task"?i?.timeout??null:l.timeout;return{retryBounds:u,timeoutBounds:d&&c?null===t?c:{...c,maximum_seconds:Math.min(c.maximum_seconds,t)}:null,enclosingSeconds:t}}function u(e,l,t){if(e.id===l)return{...e,retry:t.retry,timeout:t.timeout};if((0,n.yE)(e)&&e.continuation.id===l)return{...e,continuation:{...e.continuation,timeout:t.timeout}};let i=e=>e.id===l?{...e,timeout:t.timeout}:e;return(0,n.cs)(e)?{...e,branches:e.branches.map(i),otherwise:e.otherwise?i(e.otherwise):e.otherwise}:(0,n.y2)(e)?{...e,body:i(e.body),catch:i(e.catch)}:(0,n.LO)(e)?{...e,body:i(e.body),cleanup:i(e.cleanup)}:e}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.