@w6w/ui 0.2.66 → 0.2.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +5 -3
  3. package/dist/FormBuilder.d.ts +19 -0
  4. package/dist/ManualWebhookPanel.d.ts +34 -0
  5. package/dist/TriggerFillForm.d.ts +3 -0
  6. package/dist/WebhookListenPanel.d.ts +8 -1
  7. package/dist/components/AuthFieldsForm.d.ts +10 -0
  8. package/dist/components/AuthGuide.d.ts +19 -1
  9. package/dist/components/CallableList.d.ts +30 -4
  10. package/dist/components/Combobox.d.ts +5 -0
  11. package/dist/components/ExpressionOptions.d.ts +22 -0
  12. package/dist/{connection-app-meta-CKBbgN7e.js → connection-app-meta-DEC0n4PA.js} +4894 -4211
  13. package/dist/connection-app-meta-DEC0n4PA.js.map +1 -0
  14. package/dist/connection-app-meta-Dk6F3KEH.cjs +29 -0
  15. package/dist/connection-app-meta-Dk6F3KEH.cjs.map +1 -0
  16. package/dist/dynamic-fields.d.ts +3 -0
  17. package/dist/flow-types.d.ts +2 -0
  18. package/dist/flow.cjs +6 -5
  19. package/dist/flow.cjs.map +1 -1
  20. package/dist/flow.mjs +3515 -2436
  21. package/dist/flow.mjs.map +1 -1
  22. package/dist/form-schema.d.ts +236 -0
  23. package/dist/form-trigger.d.ts +8 -0
  24. package/dist/index.cjs +2 -2
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +4 -4
  27. package/dist/index.mjs +1325 -1272
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/provider.d.ts +12 -0
  30. package/dist/resolve-params.d.ts +2 -0
  31. package/dist/types.d.ts +17 -1
  32. package/dist/workflow-connections.d.ts +11 -0
  33. package/package.json +2 -2
  34. package/src/styles/_callable-list.scss +37 -3
  35. package/src/styles/_connections.scss +29 -0
  36. package/src/styles/_expression-modal.scss +7 -0
  37. package/src/styles/_form-builder.scss +232 -0
  38. package/src/styles/_sections.scss +29 -0
  39. package/src/styles.css +386 -3
  40. package/src/styles.scss +1 -0
  41. package/dist/connection-app-meta-CKBbgN7e.js.map +0 -1
  42. package/dist/connection-app-meta-DfA6Yqhh.cjs +0 -28
  43. package/dist/connection-app-meta-DfA6Yqhh.cjs.map +0 -1
@@ -0,0 +1,29 @@
1
+ "use strict";const n=require("react/jsx-runtime"),b=require("react"),ie=require("@w6w/expr"),kn=require("@codemirror/lang-javascript"),Tr=require("@codemirror/lang-python"),Es=require("@codemirror/view"),Or=require("@uiw/react-codemirror"),le=require("./CodeBlock-C1IC5_6O.cjs"),Rr=require("@codemirror/lang-json"),Ro=require("@codemirror/lint"),Nn=require("react-dom"),rs=require("@xyflow/react"),Ji=require("react-markdown");var Yn=typeof document<"u"?document.currentScript:null;const zi={ai:"AI",cms:"CMS",crm:"CRM",hr:"HR",devops:"DevOps"};function Ki(e){if(typeof e!="string"||e.trim()==="")return"";const t=zi[e];return t||e.split(/[-_\s]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function Gi(e){const t=new Map;for(const s of e)for(const o of s.categories??[])t.set(o,(t.get(o)??0)+1);return[...t.entries()].map(([s,o])=>({slug:s,label:Ki(s),count:o})).sort((s,o)=>o.count-s.count||s.label.localeCompare(o.label,void 0,{sensitivity:"base"}))}function Yi(e,t){if(t.length===0)return!0;const s=e.categories??[];return t.some(o=>s.includes(o))}const Xi=["text","textarea","email","number","phone","url","password","date","time","datetime","select","radio","checkboxes","checkbox","rating","file","hidden","heading","paragraph","pageBreak"],Zi=new Set(["heading","paragraph","pageBreak"]),Ts=new Set(["select","radio","checkboxes"]),Qi=new Set(["text","textarea","email","phone","url","password"]);function Ir(e){return!Zi.has(e)}const $r=["equals","notEquals","contains","notContains","isEmpty","isNotEmpty","greaterThan","lessThan"],Xn=200,el=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,tl=new Set(["__proto__","constructor","prototype"]),nl="#4f46e5",sl=[{name:"--bg",light:"#f5f6fa",dark:"#0f1115",use:"page background"},{name:"--card",light:"#ffffff",dark:"#181b21",use:"the box around the form"},{name:"--text",light:"#16181d",dark:"#eceef2",use:"text"},{name:"--muted",light:"#5d6472",dark:"#9aa1ad",use:"descriptions and help text"},{name:"--border",light:"#d9dce3",dark:"#2c313a",use:"borders and empty stars"},{name:"--input",light:"#ffffff",dark:"#11141a",use:"input background"},{name:"--err",light:"#c0262d",dark:"#ff6b6b",use:"errors and the required *"},{name:"--errbg",light:"#fdecec",dark:"#3a1a1c",use:"error banner background"},{name:"--ok",light:"#15803d",dark:"#4ade80",use:"the completion tick"}],ol=[{rule:".wrap { max-width: 680px; }",use:"the form's column"},{rule:".card { border-radius: 14px; padding: 32px; }",use:"the box around the form"},{rule:"h1 { font-size: 1.6rem; }",use:"the title"},{rule:".desc { }",use:"the description"},{rule:".field { }",use:"one question"},{rule:".q { }",use:"a question's label"},{rule:".help { }",use:"a question's help text"},{rule:".choice { }",use:"one radio or checkbox option"},{rule:".drop { }",use:"the file upload area"},{rule:".primary { }",use:"the Submit / Next button"},{rule:".secondary { }",use:"the Back button"},{rule:".foot { }",use:"the footer"}];function rl(){const e=(s,o)=>s+" ".repeat(Math.max(1,o-s.length)),t=s=>sl.map(o=>` ${e(`/* ${o.name}: ${s?o.dark:o.light}; */`,28)}/* ${o.use} */`);return["/* Custom CSS for the form page. Uncomment a line to use it. */","","/* Colours */",":root {",` ${e(`/* --accent: ${nl}; */`,28)}/* buttons, focus rings, progress (or set Accent colour) */`,...t(!1),"}","","/* Dark colours: used when Theme is auto and the visitor's system is dark. */","/* (With Theme dark or light, set the colours in :root above.) */","@media (prefers-color-scheme: dark) {"," :root {",...t(!0).map(s=>` ${s}`)," }","}","","/* Page parts */",...ol.map(s=>`${e(`/* ${s.rule} */`,52)}/* ${s.use} */`),""].join(`
2
+ `)}function _r(){return{version:1,title:"Contact us",description:"We'll get back to you within one business day.",fields:[{id:"f_name",type:"text",name:"name",label:"Name",required:!0,width:"half"},{id:"f_email",type:"email",name:"email",label:"Email",required:!0,width:"half",placeholder:"you@example.com"},{id:"f_message",type:"textarea",name:"message",label:"Message",required:!0}],submitLabel:"Submit",completion:{type:"message",title:"Thank you!",message:"Your response has been recorded."},settings:{allowPrefill:!0,showProgress:!0,theme:"auto"}}}function al(e,t,s){const o={id:t,type:e};if(e==="pageBreak")return{...o,label:""};if(e==="heading")return{...o,label:"Section title"};if(e==="paragraph")return{...o,help:"Some helpful text."};const r=Pr[e],a={...o,label:r,name:Os(Fr(r),s)};return Ts.has(e)&&(a.options=[{label:"Option 1"},{label:"Option 2"}]),e==="rating"&&(a.max=5),e==="checkbox"&&(a.label="I agree"),a}const Pr={text:"Short text",textarea:"Long text",email:"Email",number:"Number",phone:"Phone",url:"Website",password:"Password",date:"Date",time:"Time",datetime:"Date & time",select:"Dropdown",radio:"Single choice",checkboxes:"Multiple choice",checkbox:"Checkbox",rating:"Rating",file:"File upload",hidden:"Hidden value",heading:"Heading",paragraph:"Paragraph",pageBreak:"Page break"};function Fr(e){const t=e.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,48);return t?/^[0-9]/.test(t)?`f_${t}`:t:"field"}function Os(e,t){if(!t.has(e))return e;let s=2;for(;t.has(`${e}_${s}`);)s++;return`${e}_${s}`}const It=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),be=e=>typeof e=="string"?e:void 0,Io=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0;function il(e){var l;let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return null}if(!It(t)||!Array.isArray(t.fields))return null;const s=[],o=[],r=new Set,a=new Set;for(const[c,u]of t.fields.slice(0,Xn).entries()){if(!It(u)){s.push({message:`Field ${c+1} is not an object.`});continue}const d=be(u.type);if(!d||!Xi.includes(d)){s.push({message:`Field ${c+1} has an unknown type "${String(u.type)}".`});continue}let f=be(u.id)||`f_${c+1}`;a.has(f)&&(f=Os(f,a)),a.add(f);const p=ll(u,f,d);if(Ir(d)&&(!p.name||!el.test(p.name)||tl.has(p.name)?s.push({fieldId:f,message:`"${p.label||d}" needs a name made of letters, digits and _ (starting with a letter).`}):r.has(p.name)&&s.push({fieldId:f,message:`Two fields are named "${p.name}".`}),p.name&&r.add(p.name),Ts.has(d)&&!((l=p.options)!=null&&l.length)&&s.push({fieldId:f,message:`"${p.label||p.name}" has no options.`}),p.pattern!==void 0))try{new RegExp(p.pattern)}catch{s.push({fieldId:f,message:`"${p.label||p.name}" has an invalid pattern.`})}const w=p.showIf;if(w&&!o.some(m=>m.name===w.field)){const m=p.label||p.name||d;s.push({fieldId:f,message:`"${m}" depends on "${w.field}", which is not an earlier field.`})}o.push(p)}t.fields.length>Xn&&s.push({message:`A form holds at most ${Xn} fields.`});const i={version:1,title:be(t.title)??"",fields:o};if(i.title.trim()||s.push({message:"The form needs a title."}),be(t.description)&&(i.description=be(t.description)),be(t.submitLabel)&&(i.submitLabel=be(t.submitLabel)),It(t.completion)){const c=t.completion,u={type:c.type==="redirect"?"redirect":"message"};be(c.title)!==void 0&&(u.title=be(c.title)),be(c.message)!==void 0&&(u.message=be(c.message)),be(c.redirectUrl)!==void 0&&(u.redirectUrl=be(c.redirectUrl)),c.allowAnother===!0&&(u.allowAnother=!0),u.type==="redirect"&&!cl(u.redirectUrl)&&s.push({message:"The redirect URL must start with http:// or https://."}),i.completion=u}if(It(t.settings)){const c=t.settings,u={};typeof c.allowPrefill=="boolean"&&(u.allowPrefill=c.allowPrefill),typeof c.showProgress=="boolean"&&(u.showProgress=c.showProgress),(c.theme==="light"||c.theme==="dark"||c.theme==="auto")&&(u.theme=c.theme),typeof c.accentColor=="string"&&/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(c.accentColor)&&(u.accentColor=c.accentColor),be(c.customCss)&&(u.customCss=be(c.customCss)),c.hideBranding===!0&&(u.hideBranding=!0),c.closed===!0&&(u.closed=!0),be(c.closedMessage)&&(u.closedMessage=be(c.closedMessage)),i.settings=u}return{form:i,problems:s}}function ll(e,t,s){const o={id:t,type:s};for(const a of["name","label","help","placeholder","pattern","patternMessage"]){const i=be(e[a]);i!==void 0&&i!==""&&(o[a]=i)}for(const a of["minDate","maxDate","accept"]){const i=be(e[a]);i&&(o[a]=i)}e.required===!0&&(o.required=!0),e.multiple===!0&&(o.multiple=!0),e.allowOther===!0&&(o.allowOther=!0);for(const a of["minLength","maxLength","min","max","step","minSelected","maxSelected","rows","maxFileSizeMb","maxFiles"]){const i=Io(e[a]);i!==void 0&&(o[a]=i)}const r=e.defaultValue;if((typeof r=="string"||typeof r=="boolean"||Io(r)!==void 0||Array.isArray(r)&&r.every(a=>typeof a=="string"))&&(o.defaultValue=r),Array.isArray(e.options)&&(o.options=e.options.flatMap(a=>{if(typeof a=="string")return a?[{label:a}]:[];if(!It(a))return[];const i=be(a.label)??be(a.value);if(!i)return[];const l={label:i};return be(a.value)&&(l.value=be(a.value)),[l]})),e.width==="half"&&(o.width="half"),It(e.showIf)&&be(e.showIf.field)){const a=$r.includes(String(e.showIf.op))?e.showIf.op:"equals";o.showIf={field:String(e.showIf.field),op:a},e.showIf.value!==void 0&&e.showIf.value!==null&&(o.showIf.value=String(e.showIf.value))}return o}function cl(e){return typeof e=="string"&&/^https?:\/\/\S+$/i.test(e.trim())}function on(e,t){const s=e==="error"?{className:"w6w-edge-error",label:"on error"}:e==="each"?{className:"w6w-edge-each"}:{};if(!t)return s;const o=t==="taken"?"w6w-edge-taken":"w6w-edge-skipped";return{className:s.className?`${s.className} ${o}`:o,...s.label?{label:s.label}:{}}}const Rs="out-error",_n="out-each",yt="done",Lr="each";function Is(e){return e==="error"?Rs:e==="each"?_n:void 0}function ul(e){return e===Rs?"error":e===_n?"each":"success"}const dl="@w6w/",We="@w6w/control",Dr="@w6w/script",Yt="@w6w/data",Mt="@w6w/trigger",pl="@w6w/http",He="@w6w/webhook",$s="@w6w/scheduler",at="@w6w/form",fl="@w6w/respond",rn="@w6w/call",_s="@w6w/document",un="@w6w/model",hl="@w6w/template",dn="@w6w/regex",Ye="@w6w/store",Et="@w6w/csv",ml="@w6w/files",Ps="@w6w/stop",Ze="@w6w/router",Wt="@w6w/race",Mr="Continue once with the first arriving path’s output. Later arrivals are ignored for this run. Other paths keep running.";function Fs(e){var t;return e.uses.app!==Ze||!Array.isArray((t=e.with)==null?void 0:t.routes)?[]:e.with.routes.filter(s=>!!s&&typeof s=="object"&&typeof s.id=="string")}const qt=e=>`route:${e}`,wl=e=>e!=null&&e.startsWith("route:")?e.slice(6):void 0,bl=3,gl=16;function yl(e){const t=e.find(r=>r.default),s=r=>({id:r.id,handleId:qt(r.id),label:r.default?"Fallback":r.label||r.id}),o=e.filter(r=>r!==t);return{right:o.map((r,a)=>({...s(r),top:`${(a+.5)/o.length*100}%`})),...t?{bottom:s(t)}:{},...o.length>bl?{minHeight:o.length*gl}:{}}}const Sn="false";function Ls(e){return e.uses.app===We&&e.uses.action==="if"}function xl(){return{right:[{id:"true",label:"True",top:"50%"}],bottom:{id:Sn,handleId:qt(Sn),label:"False"}}}function st(e){return e.startsWith(dl)}function $t(e){return e===We||e===Wt}function Cn(e){return e===Mt||e===He||e===$s||e===at}function vl(e){return Cn(e.app)||e.trigger===!0}const $o={in:1,out:Number.POSITIVE_INFINITY};function _o(e){return e==="many"?Number.POSITIVE_INFINITY:typeof e=="number"?e:void 0}function jl(...e){let t,s;for(const o of e)t??(t=_o(o==null?void 0:o.in)),s??(s=_o(o==null?void 0:o.out));return{in:t??$o.in,out:s??$o.out}}function Xt(e,t){var a;if(e.uses.app===Ze)return{in:1,out:Fs(e).length};const{app:s,action:o}=e.uses,r=e.uses.trigger?{in:0,out:1}:void 0;return jl(e.ports,t==null?void 0:t(s,o),((a=xt(s,o))==null?void 0:a.ports)??r)}const kl='<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',Po='<line x1="6" y1="3" x2="6" y2="15" /><circle cx="18" cy="6" r="3" /><circle cx="6" cy="18" r="3" /><path d="M18 9a9 9 0 0 1-9 9" />',Nl='<polyline points="17 1 21 5 17 9" /><path d="M3 11V9a4 4 0 0 1 4-4h14" /><polyline points="7 23 3 19 7 15" /><path d="M21 13v2a4 4 0 0 1-4 4H3" />',Sl='<line x1="6" y1="4" x2="6" y2="20" /><line x1="12" y1="4" x2="12" y2="20" /><line x1="18" y1="4" x2="18" y2="20" />',Cl='<circle cx="12" cy="12" r="9" /><polyline points="12 7 12 12 15 14" />',Al='<rect x="3" y="4" width="18" height="18" rx="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" /><polyline points="12 13 12 16 14 17" />',El='<polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" />',Fo='<ellipse cx="12" cy="5" rx="9" ry="3" /><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" /><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" />',Tl='<circle cx="12" cy="12" r="10" /><line x1="2" y1="12" x2="22" y2="12" /><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />',Ol='<circle cx="18" cy="5" r="3" /><circle cx="6" cy="12" r="3" /><circle cx="18" cy="19" r="3" /><line x1="8.59" y1="13.51" x2="15.42" y2="17.49" /><line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />',Rl='<rect x="4" y="3" width="16" height="18" rx="2" /><line x1="8" y1="8" x2="16" y2="8" /><rect x="8" y="11" width="8" height="3" rx="1" /><line x1="8" y1="17.5" x2="12" y2="17.5" />',Il='<polyline points="9 17 4 12 9 7" /><path d="M20 18v-2a4 4 0 0 0-4-4H4" />',Lo='<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',$l='<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /><polyline points="15 3 21 3 21 9" /><line x1="10" y1="14" x2="21" y2="3" />',_l='<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" />',Zn='<rect x="4" y="4" width="16" height="16" rx="2" /><rect x="9" y="9" width="6" height="6" /><line x1="9" y1="1" x2="9" y2="4" /><line x1="15" y1="1" x2="15" y2="4" /><line x1="9" y1="20" x2="9" y2="23" /><line x1="15" y1="20" x2="15" y2="23" /><line x1="20" y1="9" x2="23" y2="9" /><line x1="20" y1="14" x2="23" y2="14" /><line x1="1" y1="9" x2="4" y2="9" /><line x1="1" y1="14" x2="4" y2="14" />',Pl='<rect x="4" y="8" width="16" height="12" rx="2" /><line x1="12" y1="4" x2="12" y2="8" /><circle cx="12" cy="3" r="1" /><circle cx="9" cy="14" r="1.2" /><circle cx="15" cy="14" r="1.2" /><line x1="2" y1="13" x2="2" y2="16" /><line x1="22" y1="13" x2="22" y2="16" />',Fl='<path d="M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2h1" /><path d="M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2h-1" />',mt='<ellipse cx="12" cy="5" rx="9" ry="3" /><path d="M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5" /><path d="M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3" />',Tt='<rect x="3" y="4" width="18" height="16" rx="2" /><line x1="3" y1="10" x2="21" y2="10" /><line x1="3" y1="15" x2="21" y2="15" /><line x1="9" y1="4" x2="9" y2="20" />',Ll='<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z" /><polyline points="14 3 14 8 19 8" /><line x1="12" y1="11" x2="12" y2="17" /><polyline points="9.5 14.5 12 17 14.5 14.5" />',Dl=[{app:dn,action:"match",label:"Extract",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"Enter a regular expression without enclosing / delimiters. The extracted value is the first capture group, or the full match if there are no capture groups."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."}],output:[{key:"value",label:"Extracted value"},{key:"matched",label:"Matched"},{key:"matches",label:"Matches"}]},{app:dn,action:"test",label:"Test",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"JavaScript regular expression without / delimiters. An empty pattern matches an empty string."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."}],output:[{key:"matched",label:"Matched"}]},{app:dn,action:"replace",label:"Replace",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"JavaScript regular expression without / delimiters. An empty pattern matches an empty string."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."},{key:"replacement",label:"Replacement",type:"string",config:{multiline:!0},default:"",hint:"Replacement text; supports $1, $<name>, $&, $$, $` and $'. Leave empty to remove matches."}],output:[{key:"result",label:"Result"}]},{app:dn,action:"split",label:"Split",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"JavaScript regular expression without / delimiters. An empty pattern matches an empty string."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."}],output:[{key:"parts",label:"Parts"}]}],Ml=[{app:Et,action:"from-json",label:"From JSON",displayName:"CSV",groupActions:!0,group:"compute",icon:Tt,params:[{key:"items",label:"Items",type:"json",required:!0,hint:"A list of objects, one per row."},{key:"csv",label:"Table",type:"json",hint:"Optional table to append to. Its columns stay first.",required:!1},{key:"columns",label:"Columns",type:"json",hint:"Optional column names, in order. Keys not listed are dropped."}],output:[{key:"columns",label:"Columns"},{key:"rows",label:"Rows"}]},{app:Et,action:"create",label:"Create table",displayName:"CSV",groupActions:!0,group:"compute",icon:Tt,params:[{key:"columns",label:"Columns",type:"json",hint:"Column names, in order. Leave empty to use the keys of the rows."},{key:"rows",label:"Rows",type:"json",hint:"Optional list of row objects."}],output:[{key:"columns",label:"Columns"},{key:"rows",label:"Rows"}]},{app:Et,action:"add-rows",label:"Add rows",displayName:"CSV",groupActions:!0,group:"compute",icon:Tt,params:[{key:"csv",label:"Table",type:"json",hint:"A table: { columns: string[], rows: object[] }. Usually the output of another CSV step.",required:!0},{key:"rows",label:"Rows",type:"json",required:!0,hint:"A list of row objects to append."}],output:[{key:"columns",label:"Columns"},{key:"rows",label:"Rows"}]},{app:Et,action:"remove-rows",label:"Remove rows",displayName:"CSV",groupActions:!0,group:"compute",icon:Tt,params:[{key:"csv",label:"Table",type:"json",hint:"A table: { columns: string[], rows: object[] }. Usually the output of another CSV step.",required:!0},{key:"indexes",label:"Row positions",type:"json",hint:"Zero-based positions to remove. Use this or Match, not both."},{key:"where",label:"Match",type:"json",hint:'An object such as { "status": "done" }. A row is removed when every listed column equals its value exactly ("1" is not 1).'}],output:[{key:"columns",label:"Columns"},{key:"rows",label:"Rows"}]},{app:Et,action:"to-text",label:"To CSV text",displayName:"CSV",groupActions:!0,group:"compute",icon:Tt,params:[{key:"csv",label:"Table",type:"json",hint:"A table: { columns: string[], rows: object[] }. Usually the output of another CSV step.",required:!0},{key:"delimiter",label:"Delimiter",type:"string",default:",",hint:"One of , ; | or a tab."},{key:"header",label:"Header row",type:"boolean",default:!0,hint:"Write the column names as the first line."},{key:"bom",label:"Byte order mark",type:"boolean",default:!1,hint:"Start the text with U+FEFF, which some spreadsheet apps need for UTF-8."},{key:"escapeFormulas",label:"Escape formulas",type:"boolean",default:!1,hint:"Prefix text starting with = + - @ tab or CR with an apostrophe so spreadsheets do not run it. This breaks an exact round trip."},{key:"file",label:"Also create a file",type:"boolean",default:!1,hint:"Create a downloadable text/csv file as well as the text."},{key:"filename",label:"File name",type:"string",default:"data.csv",hint:"Used when a file is created. 1 to 255 characters, no slashes."}],output:[{key:"text",label:"Text"},{key:"file",label:"File"}]},{app:Et,action:"parse",label:"Parse CSV",displayName:"CSV",groupActions:!0,group:"compute",icon:Tt,params:[{key:"text",label:"Text",type:"text",hint:"CSV text. Use this or File."},{key:"file",label:"File",type:"file",hint:"A CSV file from an earlier step. Use this or Text."},{key:"delimiter",label:"Delimiter",type:"string",default:",",hint:"One of , ; | or a tab."},{key:"header",label:"Header row",type:"boolean",default:!0,hint:"Off names the columns column_1, column_2 and so on."},{key:"inferTypes",label:"Detect types",type:"boolean",default:!0,hint:"Off keeps every cell as text."}],output:[{key:"columns",label:"Columns"},{key:"rows",label:"Rows"}]}],it=[...Dl,...Ml,{app:Wt,action:"race",label:"Race",displayName:"Race",group:"control",icon:'<path d="M3 5h4l5 7h9M3 19h4l5-7" /><polyline points="17 8 21 12 17 16" />',ports:{in:"many",out:1},params:[]},{app:Ze,action:"route",label:"Router",displayName:"Router",group:"control",icon:Po,params:[{key:"routes",label:"Routes",type:"json",required:!0,default:[{id:"route_1",label:"Route 1",condition:!1},{id:"default",label:"Default",default:!0}]}],output:[{key:"route",label:"Selected route"}]},{app:Ps,action:"stop",label:"Stop workflow",displayName:"Stop workflow",group:"control",icon:'<rect x="5" y="5" width="14" height="14" rx="2" />',params:[{key:"condition",label:"Condition",type:"json",default:!0,hint:"Stop when this condition is true. Omit it to always stop."}],output:[{key:"stopped",label:"Stopped"}]},{app:Mt,action:"manual",label:"Manual trigger",displayName:"Manual trigger",group:"trigger",icon:kl,ports:{in:0,out:1},params:[{key:"fields",label:"Fields",type:"array",default:[],hint:"The fields this trigger emits into the run. Reference them downstream as {{ nodes.<trigger>.output.<key> }}.",item:{type:"object",fields:[{key:"key",label:"Key",type:"string",placeholder:"e.g. email"},{key:"type",label:"Type",type:"select",default:"string",options:[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"boolean",label:"Boolean"},{value:"json",label:"JSON"}]},{key:"default",label:"Default",type:"string",placeholder:"optional",config:{valueTypeFrom:"type"}},{key:"required",label:"Required",type:"boolean",default:!1}]}}]},{app:He,action:"webhook",label:"Webhook",displayName:"Webhook",group:"trigger",icon:Ol,ports:{in:0,out:1},params:[{key:"methods",label:"HTTP Methods",type:"multiselect",required:!0,default:["POST"],hint:"Which HTTP methods this webhook accepts.",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"PATCH",label:"PATCH"},{value:"DELETE",label:"DELETE"},{value:"HEAD",label:"HEAD"}]},{key:"auth",label:"Authentication",type:"select",default:"none",hint:"How incoming requests are authenticated.",options:[{value:"none",label:"None"},{value:"basic",label:"Basic auth"},{value:"header",label:"Header auth"},{value:"jwt",label:"JWT (HMAC)"}]},{key:"basicUser",label:"Username",type:"string",row:"basic-auth",showIf:{field:"auth",equals:"basic"}},{key:"basicPassword",label:"Password",type:"secret",row:"basic-auth",showIf:{field:"auth",equals:"basic"}},{key:"headerName",label:"Header name",type:"string",row:"header-auth",placeholder:"e.g. X-Api-Key",showIf:{field:"auth",equals:"header"}},{key:"headerValue",label:"Header value",type:"secret",row:"header-auth",showIf:{field:"auth",equals:"header"}},{key:"jwtSecret",label:"JWT secret",type:"secret",showIf:{field:"auth",equals:"jwt"}},{key:"responseMode",label:"Respond",type:"select",default:"onReceived",hint:"When and how to respond to the caller.",options:[{value:"onReceived",label:"Immediately (ASAP)"},{value:"lastNode",label:"When the run finishes"},{value:"responseNode",label:"Using a Response node"},{value:"streaming",label:"Streaming"}]},{key:"responseCode",label:"Response status code",type:"number",default:200,showIf:{field:"responseMode",notIn:["responseNode"]}},{key:"responseData",label:"Response body (immediate)",type:"text",hint:'Body for "Immediately" responses. Empty = { "runId": "run_…", "status": "started" }. Write {{ runId }} to include the run id.',showIf:{field:"responseMode",equals:"onReceived"}},{key:"rawBody",label:"Raw body",type:"boolean",default:!1,advanced:!0},{key:"ignoreBots",label:"Ignore bots",type:"boolean",default:!1,advanced:!0},{key:"ipAllowList",label:"IP allow list",type:"array",advanced:!0,item:{type:"string",placeholder:"e.g. 203.0.113.4"},hint:"Client IPs allowed to call this webhook. Empty = allow all."},{key:"binaryPropertyName",label:"Binary field name",type:"string",advanced:!0},{key:"cors",label:"CORS allowed origin",type:"string",advanced:!0},{key:"responseHeaders",label:"Response headers",type:"array",default:[],advanced:!0,item:{type:"object",fields:[{key:"name",label:"Name",type:"string"},{key:"value",label:"Value",type:"string"}]}}]},{app:at,action:"submission",label:"Form",displayName:"On form submission",group:"trigger",icon:Rl,ports:{in:0,out:1},params:[{key:"form",label:"Form",type:"json",ui:"form-builder",whole:!0,default:_r(),hint:"The form's title, fields, pages and completion screen."},{key:"responseMode",label:"After submit",type:"select",default:"onSubmit",hint:"When the submitter sees the completion screen.",options:[{value:"onSubmit",label:"Show completion screen immediately"},{value:"lastNode",label:"Wait for the workflow to finish"},{value:"responseNode",label:"Using a Respond to Webhook step"}]},{key:"auth",label:"Authentication",type:"select",default:"none",hint:"Who may open and submit the form.",options:[{value:"none",label:"Anyone with the link"},{value:"basic",label:"Basic auth (username and password)"}]},{key:"basicUser",label:"Username",type:"string",row:"basic-auth",showIf:{field:"auth",equals:"basic"}},{key:"basicPassword",label:"Password",type:"secret",row:"basic-auth",showIf:{field:"auth",equals:"basic"}},{key:"ignoreBots",label:"Ignore bots",type:"boolean",default:!0,advanced:!0,hint:"Silently drop submissions from crawlers and link previewers."}]},{app:$s,action:"schedule",label:"Schedule",displayName:"Scheduler",group:"trigger",icon:Al,ports:{in:0,out:1},params:[{key:"mode",label:"Mode",type:"select",required:!0,default:"cron",hint:"How the schedule fires.",options:[{value:"once",label:"Once"},{value:"cron",label:"Cron"},{value:"interval",label:"Interval"}]},{key:"cron",label:"Cron expression",type:"string",placeholder:"e.g. 0 9 * * 1-5",showIf:{field:"mode",equals:"cron"}},{key:"runAt",label:"Run at",type:"string",placeholder:"e.g. 2026-01-01T09:00:00Z",showIf:{field:"mode",equals:"once"}},{key:"intervalSeconds",label:"Interval (seconds)",type:"number",showIf:{field:"mode",equals:"interval"}},{key:"timezone",label:"Timezone",type:"string",default:"UTC",advanced:!0}]},{app:We,action:"if",label:"If",displayName:"If",group:"control",icon:Po,params:[{key:"condition",type:"json",label:"Condition",required:!0,default:!0,hint:"A boolean, or an expression like {{ nodes.x.output.ok }}."}]},{app:We,action:"foreach",label:"For each",displayName:"For each",group:"control",icon:Nl,params:[{key:"items",type:"json",label:"Items",required:!0,whole:!0,hint:"An array to iterate, or an expression binding to one."},{key:"body",type:"json",label:"Body",hidden:!0,hint:"Step ids run per item. The canvas owns it; the engine requires it at run time."},{key:"parallelism",type:"number",label:"Parallelism",hidden:!0,hint:"Concurrent iterations. The engine clamps it to 1."}]},{app:We,action:"parallel",label:"Parallel",displayName:"Parallel",group:"control",icon:Sl,params:[]},{app:We,action:"wait",label:"Wait",displayName:"Wait",group:"control",icon:Cl,params:[{key:"duration",type:"string",label:"Duration",default:"1s",hint:"Use 30s, 1h30m30s, or 3d30s. Units: w, d, h, m, s; uppercase also works."}]},{app:Dr,action:"run",label:"Run script",displayName:"Run script",group:"compute",icon:El,params:[{key:"language",label:"Language",type:"select",default:"javascript",options:[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"python",label:"Python"}],hint:"Execution language for this step's code. TypeScript types are erased before it runs, not checked. Python runs CPython-on-WASM with no network."},{key:"code",type:"code",label:"Script",required:!0,scriptReads:!0,default:`// Runs as a function body. Return the step's output.
3
+ return input;`,hint:"Return the step's output. Read data from state, vars and consts; {{ }} isn't substituted in code. digest(value) returns a stable SHA-256 hex (await it in JavaScript or TypeScript)."},{key:"custom_input",type:"section",section:"collapsible",title:"Custom input (advanced)",openWhenSet:!0,children:[{key:"input",type:"json",label:"Input",whole:!0,hint:"Replaces what the script reads as `input` (by default, the run state). Each bound value keeps its type; a secret goes here, since state never holds one."}]}]},{app:hl,action:"render",label:"Render template",displayName:"Template",group:"compute",icon:Fl,output:[{key:"result"}],params:[{key:"template",label:"Template",type:"json",required:!0,whole:!0,hint:'Enter a JSON string ("Hello {{name}}") or object, or bind one with ƒx. String values render recursively; other values stay unchanged. {{name}} is HTML-escaped; use {{{name}}} for raw output.'},{key:"values",label:"Values",type:"vars",required:!0,whole:!0,default:{},hint:"Enter a JSON object, or use ƒx to bind data from workflow state or variables. Each key becomes a top-level placeholder root."}]},{app:Yt,action:"set",label:"Data",displayName:"Data set",group:"compute",icon:Fo,params:[{key:"vars",type:"vars",label:"Variables",required:!0,default:[],hint:"Set values for downstream steps using individual fields or a JSON object."}]},{app:Yt,action:"update",label:"Update object",displayName:"Update object",group:"compute",icon:Fo,params:[{key:"object",type:"json",label:"Starting object",required:!0,whole:!0,hint:"Use ƒx to choose an object from state or a previous step. The original stays unchanged."},{key:"vars",type:"vars",label:"Fields to set",required:!0,default:[],hint:"Set one or more fields. Use dot paths for nested fields, such as address.city."}]},{app:pl,action:"request",label:"HTTP request",displayName:"HTTP",group:"request",icon:Tl,output:[{key:"status"},{key:"statusText"},{key:"ok"},{key:"headers"},{key:"body"}],params:[{key:"method",type:"string",label:"Method",required:!0,default:"GET",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"PATCH",label:"PATCH"},{value:"DELETE",label:"DELETE"}],hint:"HTTP method for the request."},{key:"url",type:"string",label:"URL",required:!0,default:"",hint:"Full request URL, e.g. https://api.example.com/v1/things."},{key:"headers",type:"json",label:"Headers",default:{},hint:"Object of header name → value."},{key:"query",type:"json",label:"Query params",default:{},hint:"Object of query-string name → value, appended to the URL."},{key:"body",type:"text",label:"Body",default:"",hint:"Request body (raw text or a JSON string). Ignored for GET/HEAD."}]},{app:fl,action:"respond",label:"Respond to Webhook",displayName:"Respond to Webhook",group:"request",icon:Il,params:[{key:"respondWith",label:"Respond with",type:"select",default:"json",hint:"Shape of the response returned to the webhook caller.",options:[{value:"json",label:"JSON"},{value:"text",label:"Text"},{value:"noData",label:"No body"}]},{key:"responseCode",label:"Response status code",type:"number",default:200},{key:"responseBody",label:"Response body",type:"json",default:{},hint:"Body to return (object for JSON, string for Text)."},{key:"responseHeaders",label:"Response headers",type:"array",default:[],item:{type:"object",fields:[{key:"name",label:"Name",type:"string"},{key:"value",label:"Value",type:"string"}]}}]},{app:We,action:"aggregate",label:"Aggregate",displayName:"Aggregate",group:"control",icon:Lo,hidden:!0,ports:{in:10,out:1},params:[{key:"mode",label:"Mode",type:"select",default:"array",hint:"How to combine the inbound branch outputs: an array of results, or an object keyed by source step.",options:[{value:"array",label:"Array"},{value:"object",label:"Object"}]}]},{app:We,action:"merge",label:"Merge",displayName:"Merge",group:"control",icon:Lo,ports:{in:"many",out:1},params:[{key:"mode",label:"Mode",type:"select",default:"array",hint:"Combine the entries into an array, or into an object keyed by each entry's key.",options:[{value:"array",label:"Array"},{value:"object",label:"Object"}]},{key:"entries",label:"Entries",type:"array",default:[],hint:"Each entry's value may be an expression (ƒx) over the inbound branches' outputs.",item:{type:"object",fields:[{key:"key",label:"Key",type:"string"},{key:"value",label:"Value",type:"string"}]}}]},{app:rn,action:"call",label:"Call workflow",displayName:"Call",group:"compute",icon:$l,ports:{in:1,out:1},params:[{key:"targetKind",label:"Target kind",type:"select",required:!0,default:"workflow",hint:"Whether this node calls another Workflow or a Function.",options:[{value:"workflow",label:"Workflow"},{value:"function",label:"Function"}]},{key:"targetId",label:"Target id",type:"string",required:!0,default:"",placeholder:"e.g. wf_… or fn_…",hint:"Id of the Workflow (wf_…) or Function (fn_…) to call, within this project."},{key:"entry",label:"Trigger node",type:"string",hint:"The manual trigger node to start at in the called workflow."},{key:"inputs",label:"Inputs",type:"json",default:{},hint:"Payload passed to the target — an object keyed by the callee's declared inputs. Values may be expressions."},{key:"wait",label:"Wait for completion",type:"boolean",default:!0,hint:"On: block until the sub-run finishes and expose its output. Off: return a run handle and continue."}]},{app:_s,action:"get",label:"Get document",displayName:"Document",group:"compute",icon:_l,ports:{in:1,out:1},params:[{key:"key",label:"Key",type:"string",required:!0,default:"",hint:"Document key to read — may be an expression, e.g. a step output."}]},{app:un,action:"complete",label:"Complete with model",displayName:"Model",group:"compute",icon:Zn,ports:{in:1,out:1},params:[{key:"route",label:"Route",type:"model-route",hint:"Name of a model route (Models → Routes). Use this, or the model + connection pair below — never both."},{key:"model",label:"Model",type:"string",advanced:!0,hint:"Catalog id of a model (`mdl_…`, Models → Catalog), called through `connection`. Ignored when `route` is set."},{key:"connection",label:"Connection",type:"string",advanced:!0,hint:"Id of a model-provider connection on this account. Required by `model`; ignored when `route` is set."},{key:"input",label:"Input",type:"json",required:!0,default:{},hint:`The request body handed to the provider — e.g. { "messages": [{ "role": "user", "content": "hi" }] }, or the provider's native payload.`},{key:"dialect",label:"Dialect",type:"select",advanced:!0,hint:"Rewrite the result into this wire dialect; bridge keeps the baseline unprojected. Leave unset to keep the provider's own.",placeholder:"Provider native",options:[{value:"bridge",label:"Bridge (unprojected)"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"ollama",label:"Ollama"}]},{key:"response",label:"Response",type:"select",advanced:!0,hint:"Output: the dialect-shaped result. Raw: the provider's own response. Leave unset to carry both.",placeholder:"Both",options:[{value:"output",label:"Output"},{value:"raw",label:"Raw"}]}]},{app:un,action:"agent",label:"Run agent",displayName:"Agent",group:"compute",icon:Pl,ports:{in:1,out:1},params:[{key:"agent",label:"Agent",type:"agent",required:!0,hint:"An agent from the Agents dashboard. Its tools run when it calls them."},{key:"message",label:"Message",type:"text",required:!0,hint:"What to tell the agent — text, or an expression such as an earlier step's output (an object is sent as JSON)."}]},{app:un,action:"list-models",label:"List models",displayName:"Model",group:"compute",icon:Zn,ports:{in:1,out:1},params:[{key:"connection",label:"Connection",type:"string",required:!0,hint:"Connection id of the provider to list models for."}]},{app:un,action:"allowance",label:"Model allowance",displayName:"Model",group:"compute",icon:Zn,ports:{in:1,out:1},params:[{key:"connection",label:"Connection",type:"string",required:!0,hint:"Connection id of the provider to read the allowance of."}]},{app:Ye,action:"get",label:"Get entry",displayName:"Store",group:"compute",icon:mt,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."},{key:"required",label:"Required",type:"boolean",default:!1,hint:"Fail the step when the key is missing instead of returning found: false."}],output:[{key:"found"},{key:"key"},{key:"value"},{key:"version"},{key:"expiresAt"}]},{app:Ye,action:"set",label:"Set entry",displayName:"Store",group:"compute",icon:mt,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."},{key:"value",label:"Value",type:"json",required:!0,hint:"The JSON value to store."},{key:"ifVersion",label:"If version",type:"number",hint:"Write only when the stored version equals this number."},{key:"ttlSeconds",label:"TTL (seconds)",type:"number",hint:"Expire the entry after this many seconds. Omit to keep it."}],output:[{key:"key"},{key:"value"},{key:"version"},{key:"expiresAt"}]},{app:Ye,action:"delete",label:"Delete entry",displayName:"Store",group:"compute",icon:mt,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."}],output:[{key:"key"},{key:"deleted"}]},{app:Ye,action:"increment",label:"Increment counter",displayName:"Store",group:"compute",icon:mt,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."},{key:"by",label:"By",type:"number",default:1,hint:"Amount to add; may be negative."}],output:[{key:"key"},{key:"value"},{key:"version"}]},{app:Ye,action:"list",label:"List entries",displayName:"Store",group:"compute",icon:mt,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"prefix",label:"Prefix",type:"string",hint:"Only entries whose key starts with this."},{key:"cursor",label:"Cursor",type:"string",hint:"The nextCursor of a previous page."},{key:"limit",label:"Limit",type:"number",default:50,hint:"Page size, at most 200."}],output:[{key:"items"},{key:"nextCursor"}]},{app:Ye,action:"query",label:"Query rows",displayName:"Store",group:"compute",icon:mt,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"where",label:"Where",type:"json",hint:"Column equality filter."},{key:"order",label:"Order",type:"string",hint:"Column to order by; prefix with - for descending."},{key:"limit",label:"Limit",type:"number",hint:"Maximum rows to return."}],output:[{key:"items"}]},{app:Ye,action:"insert",label:"Insert row",displayName:"Store",group:"compute",icon:mt,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"row",label:"Row",type:"json",required:!0,hint:"The row, keyed by column name."},{key:"ttlSeconds",label:"TTL (seconds)",type:"number",hint:"Expire the entry after this many seconds. Omit to keep it."}],output:[{key:"key"},{key:"value"},{key:"version"}]},{app:ml,action:"save",label:"Save file",displayName:"Files",group:"compute",icon:Ll,ports:{in:1,out:1},params:[{key:"path",label:"Path",type:"string",required:!0,hint:"Where to save the file in this account and project, such as reports/summary.csv. Saving to the same path again adds a version."},{key:"text",label:"Text",type:"text",hint:"Text to save. Use exactly one of Text, CSV or File."},{key:"csv",label:"CSV table",type:"json",hint:"A table from a CSV step, saved as CSV text. Use exactly one of Text, CSV or File."},{key:"file",label:"File",type:"file",hint:"A file from an earlier step. Use exactly one of Text, CSV or File."},{key:"contentType",label:"Content type",type:"string",hint:"Optional media type, such as text/plain. Defaults to one that fits the content."}],output:[{key:"fileId"},{key:"versionId"},{key:"path"},{key:"size"},{key:"sha256"},{key:"contentType"}]}];function xt(e,t){return it.find(s=>s.app===e&&s.action===t)}function Wl(e,t){var s;return((s=xt(e,t))==null?void 0:s.label)??t}function ql(e,t){var s;return((s=xt(e,t))==null?void 0:s.icon)??""}function Wr(e,t){var s;return((s=xt(e,t))==null?void 0:s.params)??[]}function An(e,t){const s={};for(const o of Wr(e,t))o.default!==void 0&&(s[o.key]=o.default);return s}function Bl(e,t){return e.q===t.q&&(e.category??"")===(t.category??"")&&(e.ids??[]).join(",")===(t.ids??[]).join(",")}function qr(e,t=0){return{query:e,generation:t,status:"loading",apps:[],hasMore:!1}}function Ul(e,t){const s=new Set(e.map(r=>r.id)),o=[];for(const r of t)s.has(r.id)||(s.add(r.id),o.push(r));return o.length===0?e:[...e,...o]}function Vl(e,t){switch(t.type){case"query-changed":return t.generation===e.generation&&Bl(t.query,e.query)?e:qr(t.query,t.generation);case"load-more":return e.status!=="ready"||!e.hasMore?e:{...e,status:"loading-more"};case"retry":return e.status!=="error"?e:{...e,status:e.apps.length===0?"loading":"loading-more"};case"page-loaded":{if(t.generation!==e.generation)return e;const s=Ul(e.apps,t.apps),o=t.nextCursor!==void 0&&t.nextCursor===t.requestedCursor,r=!!t.nextCursor&&!o;return{...e,status:"ready",apps:s,cursor:r?t.nextCursor:void 0,hasMore:r,total:typeof t.total=="number"?t.total:e.total,error:void 0}}case"page-failed":return t.generation!==e.generation?e:{...e,status:"error",error:t.error};default:return e}}function Hl(e){return e.filter(t=>!st(t.id))}function Qn(e,t,s){if(s<=0)return[];const o=[];for(const r of e)if(!t.has(r)&&(o.push(r),o.length>=s))break;return o}function Jl(e,t){const s=[];for(const o of e){const r=t.get(o);r&&s.push(r)}return s}const Br=b.createContext(void 0);function Do(e,t){var o;if(e)return e;if(t)return t;if(typeof document>"u")return"light";const s=document.documentElement.getAttribute("data-theme");return s==="dark"||s==="light"?s:(o=window.matchMedia)!=null&&o.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Pn(e){const t=b.useContext(Br),[s,o]=b.useState(()=>Do(e,t));return b.useEffect(()=>{if(e){o(e);return}if(t){o(t);return}if(typeof window>"u")return;const r=()=>o(Do(void 0,t)),a=window.matchMedia("(prefers-color-scheme: dark)");a.addEventListener("change",r);const i=new MutationObserver(r);return i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),r(),()=>{a.removeEventListener("change",r),i.disconnect()}},[e,t]),s}function Nt({src:e,srcDark:t,brandColor:s,name:o,size:r=32,theme:a}){const l=Pn(a)==="dark"?t??e:e,[c,u]=b.useState(void 0);if(l&&l!==c)return n.jsx("img",{src:l,width:r,height:r,alt:"",onError:()=>u(l),style:{width:r,height:r,borderRadius:6,flexShrink:0,objectFit:"contain",padding:Math.max(1,Math.round(r*.06)),boxSizing:"border-box",background:"var(--w6w-icon-swatch, var(--w6w-panel-2))"}});const d=(o??"?").split(/\s+/).slice(0,2).map(f=>{var p;return((p=f[0])==null?void 0:p.toUpperCase())??""}).join("");return n.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:r,height:r,borderRadius:6,background:s??"var(--w6w-accent)",color:"#fff",fontWeight:700,fontSize:Math.round(r*.42),flexShrink:0},children:d})}const zl={w6w:"by W6W",verified:"Verified publisher"};function Ur({publisher:e,className:t,testId:s}){if(!e)return null;const o=e.byW6W?"w6w":e.verified?"verified":"name";return n.jsxs("span",{className:["w6w-publisher-app-badge",`w6w-publisher-app-badge-${o}`,t].filter(Boolean).join(" "),"data-publisher-kind":o,"data-publisher-slug":e.slug,title:e.displayName,"data-testid":s,children:[o==="name"?null:n.jsx("span",{className:"w6w-publisher-app-badge-label",children:zl[o]}),o==="w6w"?null:n.jsx("span",{className:"w6w-publisher-app-badge-name",children:e.displayName})]})}const Ds=b.createContext(null);function Kl({api:e,theme:t,children:s}){const o=n.jsx(Ds.Provider,{value:e,children:n.jsx(Br.Provider,{value:t,children:s})});return t?n.jsx("div",{"data-theme":t,style:{display:"contents"},children:o}):o}function Ce(){const e=b.useContext(Ds);if(!e)throw new Error("useW6WApi must be used inside <W6WUIProvider>. Wrap your app root with <W6WUIProvider api={api}>...</W6WUIProvider>.");return e}function Vt(){return b.useContext(Ds)??void 0}const Vr=b.createContext(void 0),Hr=b.createContext(void 0);function Gl({project:e,workflowId:t,children:s}){return n.jsx(Vr.Provider,{value:e,children:n.jsx(Hr.Provider,{value:t,children:s})})}function Ms(){return b.useContext(Vr)}function Yl(){return b.useContext(Hr)}const es=8,Xl=60,Zl=300;function Mo(e){const t=e.modelProvider;return!t||typeof t!="object"?null:t}function Ql(e){if(!e)return null;if(e.supported)return{text:"Bridge supported",title:"Bridge supported"};const t=typeof e.reason=="string"?e.reason.trim():"";return{text:t===""?"unsupported":`unsupported — ${t}`,title:t===""?"Bridge not supported":t}}function ot({onSelectApp:e,theme:t,filter:s,searchPlaceholder:o,emptyMessage:r,search:a=!0,searchValue:i,onSearchChange:l,emptyAction:c,apps:u,categoryFilter:d=!1,providerFilter:f=!1,bridgeSupport:p,category:w,hasTriggers:m,publisher:h,publisherFilter:y=!1,onPublisherChange:g,ids:x,pageLimit:S=Xl,loadPage:A}){const R=Ce(),j=u!==void 0,N=x&&x.length>0?x.join(","):"",k=!j&&(A!==void 0||typeof R.listAppsPage=="function"),_=b.useRef(A);_.current=A;const[q,O]=b.useState(null),[F,E]=b.useState(null);b.useEffect(()=>{if(j||k)return;const W=R.listApps;if(typeof W!="function"){O([]);return}let ce=!1;return W().then(v=>!ce&&O(v)).catch(v=>!ce&&E(v.message)),()=>{ce=!0}},[R,j,k]);const[I,$]=b.useReducer(Vl,qr({q:"",category:w,ids:x},0)),[V,J]=b.useState(""),P=i??V,T=W=>{i===void 0&&J(W),l==null||l(W)},[Z,K]=b.useState(P.trim()),ne=b.useRef(0),U=b.useRef(null),[G,z]=b.useState(void 0),D=h!==void 0?h:G,te=W=>{h===void 0&&z(W),g==null||g(W)},ee=b.useCallback((W,ce,v)=>{var fe;const L=_.current,B=R.listAppsPage;if(!L&&!B)return;(fe=U.current)==null||fe.abort();const oe=new AbortController;U.current=oe;let me;try{me=L?L({q:W.q||void 0,cursor:v,limit:S,...W.ids?{ids:W.ids}:{},signal:oe.signal}):B({q:W.q||void 0,category:W.category,...m?{hasTriggers:!0}:{},...D?{publisher:D}:{},...W.ids?{ids:W.ids}:{},cursor:v,limit:S,compact:!0,signal:oe.signal})}catch(X){me=Promise.reject(X)}me.then(X=>{if(ne.current===ce){if(!X||!Array.isArray(X.apps)){$({type:"page-failed",generation:ce,error:"The server returned a malformed apps page."});return}$({type:"page-loaded",generation:ce,apps:X.apps,nextCursor:X.nextCursor,requestedCursor:v,total:typeof X.total=="number"?X.total:void 0})}}).catch(X=>{if(ne.current!==ce||X instanceof Error&&X.name==="AbortError")return;const Ae=X==null?void 0:X.code;if(v!==void 0&&(Ae==="snapshot_expired"||Ae==="unknown_snapshot")){const ht=++ne.current;$({type:"query-changed",query:W,generation:ht}),ee(W,ht,void 0);return}$({type:"page-failed",generation:ce,error:X.message})})},[R,S,m,D]);b.useEffect(()=>{if(!k)return;const W=setTimeout(()=>K(P.trim()),Zl);return()=>clearTimeout(W)},[P,k]),b.useEffect(()=>{if(!k)return;const W=++ne.current,ce={q:Z,category:w,...N?{ids:N.split(",")}:{}};return $({type:"query-changed",query:ce,generation:W}),ee(ce,W,void 0),()=>{var v;(v=U.current)==null||v.abort()}},[k,Z,w,N,ee]),b.useEffect(()=>{if(k)return()=>{var W;return(W=U.current)==null?void 0:W.abort()}},[k]);const C=()=>{if(!k||I.status!=="ready"||!I.hasMore)return;const W=ne.current;$({type:"load-more"}),ee(I.query,W,I.cursor)},H=()=>{!k||I.status!=="error"||($({type:"retry"}),ee(I.query,ne.current,I.cursor))},[Q,ae]=b.useState([]),[Y,ke]=b.useState(!1),[we,ge]=b.useState(!1),ye=W=>n.jsx("div",{className:"w6w-apppicker-host",children:W});let xe,ue=null,M=!1,re=!1,he=null,Oe=!1;if(j?xe=u??null:k?(xe=I.apps,Oe=I.status==="loading",M=I.status==="loading-more",re=I.hasMore,I.status==="error"&&(I.apps.length===0?ue=I.error??"Failed to load apps.":he=I.error??"Failed to load apps.")):(xe=q,ue=F),!k&&ue)return ye(n.jsx("div",{className:"w6w-result w6w-error",children:ue}));if(!k&&xe===null)return ye(n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}));xe??(xe=[]);const Re=Hl(xe),_e=s?Re.filter(s):Re;if(!k&&_e.length===0)return ye(n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:r??"No apps registered yet. Register one from the Apps page first."}),c]}));const de=d?Gi(_e):[],Be=de.slice(0,es),Ut=de.slice(es).filter(W=>Q.includes(W.slug)),Ue=[...Be,...Ut],St=de.length-Ue.length,ze=Y?de:Ue,dt=W=>ae(ce=>ce.includes(W)?ce.filter(v=>v!==W):[...ce,W]),Ct=()=>ae([]),pt=_e.filter(W=>Mo(W)!==null).length,Ie=f&&pt>0,ve=Ie&&we,Pe=ve?_e.filter(W=>Mo(W)!==null):_e,At=(()=>{const W=new Map;for(const ce of _e){const v=ce.publisher;v&&typeof v.slug=="string"&&v.slug!==""&&!W.has(v.slug)&&W.set(v.slug,v.displayName||v.slug)}return D&&!W.has(D)&&W.set(D,D),[...W].map(([ce,v])=>({slug:ce,label:v}))})(),Fe=y&&At.length>0,De=Fe&&D!==void 0,Ke=d&&Q.length>0?Pe.filter(W=>Yi(W,Q)):Pe,pe=k?Ke:[...Ke].sort((W,ce)=>W.displayName.localeCompare(ce.displayName,void 0,{sensitivity:"base"})),nt=k?"":P.trim().toLowerCase(),Ve=P.trim().length>0,Me=nt?pe.filter(W=>W.displayName.toLowerCase().includes(nt)||W.id.toLowerCase().includes(nt)):pe,ft=s!==void 0&&_e.length!==Re.length||ve&&Pe.length!==_e.length||d&&Q.length>0&&Ke.length!==Pe.length,se=(d&&Q.length>0||ve||De)&&Me.length===0,Ne=ve&&Q.length===0,$e=()=>{ae([]),ge(!1),D!==void 0&&te(void 0),T("")};return ye(n.jsxs("div",{className:"w6w-stepbuilder-apps",children:[a&&n.jsx("input",{type:"text",className:"w6w-stepbuilder-search",placeholder:o??"Search apps…",value:P,onChange:W=>T(W.target.value),"aria-label":"Search apps"}),(Ie||d&&de.length>0||Fe)&&n.jsxs("div",{className:"w6w-apppicker-cats",children:[Fe&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Publisher"}),At.map(W=>n.jsx("button",{type:"button",className:"w6w-apppicker-chip","aria-pressed":D===W.slug,"aria-label":`Filter by ${W.label}`,onClick:()=>te(D===W.slug?void 0:W.slug),children:W.label},W.slug))]}),Ie&&n.jsxs("button",{type:"button",className:"w6w-apppicker-chip w6w-apppicker-provider-toggle","aria-pressed":we,"aria-label":"Filter to model providers",onClick:()=>ge(W=>!W),children:["Model providers ",n.jsxs("span",{className:"w6w-muted",children:["(",pt,")"]})]}),d&&de.length>0&&n.jsxs(n.Fragment,{children:[ze.map(W=>n.jsxs("button",{type:"button",className:"w6w-apppicker-chip","aria-pressed":Q.includes(W.slug),"aria-label":`Filter by ${W.label}`,onClick:()=>dt(W.slug),children:[W.label," ",n.jsxs("span",{className:"w6w-muted",children:["(",W.count,")"]})]},W.slug)),!Y&&St>0&&n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>ke(!0),children:["+",St," more"]}),Y&&de.length>es&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>ke(!1),children:"Show less"}),Q.length>0&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:Ct,children:"Clear"})]})]}),k&&Oe?n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}):k&&ue?n.jsxs("div",{className:"w6w-result w6w-error",children:[ue," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:H,children:"Retry"})]}):Me.length===0&&!re?se?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:De?Ve?`No apps from this publisher match “${P}”.`:"No apps from this publisher.":Ne?Ve?`No model providers match “${P}”.`:"No apps declare a model provider.":Ve?`No apps match “${P}” in the selected categories.`:"No apps match the selected categories."}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:$e,children:"Clear filters"})]}):k?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:Ve?`No apps match “${P}”.`:r??"No apps registered yet. Register one from the Apps page first."}),!Ve&&c]}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No apps match “",P,"”."]}):n.jsxs(n.Fragment,{children:[Me.length===0&&re?n.jsx("p",{className:"w6w-muted w6w-small",children:"No matching apps on this page yet — try “Load more”."}):n.jsx("div",{className:"w6w-stepbuilder-list w6w-apppicker-grid w6w-stepbuilder-scroll",children:Me.map(W=>{const ce=p==null?void 0:p.get(W.id),v=Ql(ce);return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-apppicker-card",onClick:()=>e(W),children:[n.jsx(Nt,{src:W.iconSvg,srcDark:W.iconSvgDark,brandColor:W.brandColor,name:W.displayName,theme:t,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:W.displayName}),n.jsx("code",{className:"w6w-apppicker-card-id",children:W.id}),W.version&&n.jsxs("span",{className:"w6w-apppicker-card-version",children:["v",W.version]}),W.publisher&&n.jsx(Ur,{publisher:W.publisher,testId:`apppicker-publisher-${W.id}`}),v&&n.jsx("span",{className:ce!=null&&ce.supported?"w6w-chip w6w-apppicker-card-bridge":"w6w-chip w6w-apppicker-card-bridge w6w-apppicker-card-bridge-unsupported",title:v.title,children:v.text})]})]},W.id)})}),k&&typeof I.total=="number"&&n.jsx("div",{className:"w6w-small w6w-apppicker-count",children:ft?`${Me.length} ${Me.length===1?"app":"apps"}`:`${I.apps.length} of ${I.total}`}),k&&he&&n.jsxs("div",{className:"w6w-result w6w-error w6w-small",children:[he," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:H,children:"Retry"})]}),k&&re&&!he&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-apppicker-load-more",onClick:C,disabled:M,children:M?"Loading more…":"Load more"})]})]}))}const Ws={"&":{fontSize:"13px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",backgroundColor:"var(--w6w-panel-2)",color:"var(--w6w-text)",border:"1px solid var(--w6w-border)",borderRadius:"8px"},"&.cm-focused":{outline:"none",borderColor:"var(--w6w-accent)"},".cm-gutters":{backgroundColor:"var(--w6w-panel)",color:"var(--w6w-muted)",border:"none",borderRight:"1px solid var(--w6w-border)"},".cm-scroller":{overflow:"auto",borderRadius:"7px"},".cm-content":{paddingTop:"var(--w6w-sp-2)",paddingBottom:"var(--w6w-sp-2)"},".cm-line":{paddingLeft:"var(--w6w-sp-2)"}};function Wo(e){return{children:Object.create(null),detail:e}}function as(e,t){return Object.hasOwn(e.children,t)?e.children[t]:void 0}function Jr(e={}){var r;const t=Wo(),s=(a,i)=>{var c;let l=t;for(const u of a)l=(c=l.children)[u]??(c[u]=Wo());i&&(l.detail=i)},o=(a,i=[])=>{for(const l of i)s([...a,...l.path?l.key.split("."):[l.key]],l.declaredOnly?"Declared field — test the step to verify":l.label)};for(const a of["nodes","state","consts","trigger","foreach"])s([a]);for(const a of e.vars??[])s(["state",a],"Workflow variable");o(["state"],(r=e.stateShape)==null?void 0:r.fields);for(const a of e.constants??[])s(["consts",a],"Account constant");for(const a of e.steps??[])if(s(["nodes",a.id],a.label??"Earlier step"),s(["nodes",a.id,"output"],a.needsTest?"Test this step to discover fields":"Step output"),o(["nodes",a.id,"output"],a.outputs),a.hasMeta)for(const i of["app","version","action","connectionId"])s(["nodes",a.id,"meta",i]);for(const a of e.nodeConfigs??[])for(const i of a.keys)s(["nodes",a.id,"meta","config",i]);for(const[a,i]of Object.entries(e.nodeMeta??{}))for(const l of Object.keys(i))s(["nodes",a,"meta",l]);if(s(["trigger","type"]),e.loop){s(["foreach","item"]),s(["foreach","index"]),o(["foreach","item"],e.loop.itemOutputs);for(const a of[...e.loop.outer??[],e.loop])s(["foreach","loops",a.foreachId,"item"]),s(["foreach","loops",a.foreachId,"index"]),o(["foreach","loops",a.foreachId,"item"],a.itemOutputs)}return t}const ec=`(?:"(?:[^"\\\\]|\\\\.)*"|'(?:[^'\\\\]|\\\\.)*')`,vt=`(?:${ec}|\\d+)`,tc=`(?:\\s*\\.\\s*[A-Za-z_$][\\w$]*|\\s*\\[\\s*${vt}\\s*\\])`,nc="(?:\\$|ctx|run|state|vars|consts)",sc=`(?:\\$|ctx)\\.get\\(\\s*${vt}(?:\\s*,\\s*${vt})*\\s*\\)`,oc=`(?:${sc}|${nc})${tc}*`,qo=new RegExp(`(?<![\\w$.])(${oc})\\s*$`),rc=new RegExp(`\\.\\s*([A-Za-z_$][\\w$]*)|\\[\\s*(${vt})\\s*\\]`,"g");function is(e){return e[0]==='"'?JSON.parse(e):e[0]!=="'"?e:e.slice(1,-1).replace(/\\(u[0-9a-fA-F]{4}|[\\'"nrtbf])/g,(t,s)=>s.startsWith("u")?String.fromCharCode(Number.parseInt(s.slice(1),16)):{n:`
4
+ `,r:"\r",t:" ",b:"\b",f:"\f"}[s]??s)}function zr(e,t){let s=e;for(const o of t)s=s&&as(s,o);return s}function Bo(e,t,s){var l;const o=/^(\$|ctx)\.get\((.*)\)/s.exec(e);let r,a,i=!1;if(o){if(o[1]==="ctx"!==s)return;const c=o[2].match(new RegExp(vt,"g"))??[];r=zr(t,c.map(is)),a=e.slice(o[0].length)}else{const c=(l=/^(\$|ctx|run|state|vars|consts)/.exec(e))==null?void 0:l[0];if(!c||c==="$"&&s||c==="ctx"&&!s)return;i=c==="$"||c==="ctx",i||c==="run"?r=t:r=as(t,c==="vars"?"state":c),a=e.slice(c.length),c==="run"&&(r={children:Object.fromEntries(["nodes","trigger","foreach"].map(u=>[u,t.children[u]]))})}for(const c of a.matchAll(rc)){if(s&&c[1]&&!i)return;r=r&&as(r,c[1]??is(c[2])),i=!1}return r}function ac(e,t,s){if(e.tokenBefore(["Comment","LineComment","BlockComment"]))return null;const o=s==="python",r=e.state.sliceDoc(0,e.pos),a=e.tokenBefore(["String","TemplateString"]);let i,l=e.pos,c,u=!1,d,f=!1;const p=new RegExp(`(?<![\\w$.])(?:${o?"ctx":"\\$"})\\.get\\(\\s*((?:${vt}\\s*,\\s*)*)(["']?)([^"'\\\\,\\n]*)$`).exec(r),w=/\[\s*(["']?)([^"'\\\]\n]*)$/.exec(r),m=/\.([\w$]*)$/.exec(r);try{if(p)i=zr(t,(p[1].match(new RegExp(vt,"g"))??[]).map(is)),c=p[2],l=e.pos-p[3].length-c.length;else if(w){const g=qo.exec(r.slice(0,w.index));if(!g)return null;i=Bo(g[1],t,o),c=w[1],u=!0,l=e.pos-w[2].length-c.length}else if(m){const g=qo.exec(r.slice(0,m.index));if(!g||o&&g[1]!=="ctx")return null;i=Bo(g[1],t,o),f=g[1]===(o?"ctx":"$"),d=m.index,l=m.index+1}else if(o&&!a){const g=e.matchBefore(/\w*/);return!g||!e.explicit&&g.from===g.to?null:{from:g.from,options:["ctx","input","run","state","vars","consts","digest","print"].map(x=>({label:x,type:"variable"}))}}}catch{return null}if(!i||a&&(c===void 0||!c||a.from!==l))return null;let h=e.pos;if(c!==void 0){const g=e.state.sliceDoc(e.pos),x=c?new RegExp(`^[^${c}\\\\
5
+ ]*${c}`).exec(g):null;x&&(h+=x[0].length),u&&e.state.sliceDoc(h,h+1)==="]"&&h++}const y=Object.entries(i.children).map(([g,x])=>{const S=JSON.stringify(g);return{label:g,type:"property",detail:x.detail,apply:c!==void 0?`${S}${u?"]":""}`:/^[A-Za-z_$][\w$]*$/.test(g)?g:(A,R,j,N)=>{const k=d??j;A.dispatch({changes:{from:k,to:N,insert:`[${S}]`},selection:{anchor:k+S.length+2}})}}});if(f&&y.push({label:"get",type:"function",detail:`Read a path; missing values return ${o?"None":"undefined"}`}),c!==void 0){const g=e.state.sliceDoc(l+c.length,e.pos).trimStart().toLowerCase();return{from:l,to:h,filter:!1,options:y.filter(x=>x.label.toLowerCase().startsWith(g))}}return y.length?{from:l,to:h,options:y}:null}function ic(e="javascript",t=Jr()){let s,o=0,r=!1;const a=new Map,i=()=>{s==null||s.terminate(),s=void 0;for(const c of a.values())c([]);a.clear()},l=async c=>{if(r)return null;const u=ac(c,t,e);if(u||e==="python")return u;const d=c.matchBefore(/[\w$]*/);if(r||!d||!c.explicit&&d.from===d.to&&c.state.sliceDoc(c.pos-1,c.pos)!==".")return null;s||(s=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/script-completion.worker-Bjh2aftZ.js").href:new URL("assets/script-completion.worker-Bjh2aftZ.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:Yn&&Yn.tagName.toUpperCase()==="SCRIPT"&&Yn.src||new URL("connection-app-meta-Dk6F3KEH.cjs",document.baseURI).href),{type:"module"}),s.onmessage=p=>{var w;(w=a.get(p.data.id))==null||w(p.data.options),a.delete(p.data.id)},s.onerror=i);const f=await new Promise(p=>{const w=++o;a.set(w,p),c.addEventListener("abort",()=>{a.delete(w),p([])},{onDocChange:!0}),s==null||s.postMessage({id:w,code:c.state.doc.toString(),position:c.pos,scope:t})});return c.aborted||!f.length?null:{from:d.from,options:f}};return[(e==="python"?Tr.pythonLanguage:e==="typescript"?kn.typescriptLanguage:kn.javascriptLanguage).data.of({autocomplete:l}),Es.ViewPlugin.define(()=>(r=!1,{destroy(){r=!0,i()}}))]}function lc(e){switch(e){case"javascript":return kn.javascript();case"typescript":return kn.javascript({typescript:!0});case"python":return Tr.python()}}function qs(e){const t=Pn(e.theme),{copied:s,copy:o}=le.useCopyToClipboard(e.value),r=b.useMemo(()=>[...e.language?[lc(e.language)]:[],...e.language?[ic(e.language,e.scriptScope)]:[],Es.EditorView.theme(Ws)],[e.language,e.scriptScope]);return n.jsxs("div",{className:"w6w-code-editor","aria-label":e["aria-label"]??"Code editor",children:[n.jsx(Or,{value:e.value,onChange:e.onChange,extensions:r,placeholder:e.placeholder,readOnly:e.readOnly,theme:t,height:e.height,minHeight:e.minHeight??"160px",maxHeight:e.maxHeight,onCreateEditor:e.onCreateEditor,basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLine:!e.readOnly,bracketMatching:!0,closeBrackets:!0}}),e.copyable!==!1&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${s?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void o(),children:s?n.jsx(le.CheckGlyph,{}):n.jsx(le.CopyGlyph,{})}),n.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}function cc(){const e=Rr.jsonParseLinter();return t=>t.state.doc.toString().trim()===""?[]:e(t)}function Xe(e){const t=Pn(e.theme),{copied:s,copy:o}=le.useCopyToClipboard(e.value),r=b.useMemo(()=>[Rr.json(),...e.showDiagnostics===!1?[]:[Ro.linter(cc()),Ro.lintGutter()],Es.EditorView.theme(Ws)],[e.showDiagnostics]);function a(i){var l,c,u,d;if(e.onChange(i),!(!e.onValidChange&&!e.onValidityChange)){if(i.trim().length===0){(l=e.onValidityChange)==null||l.call(e,{valid:!1,error:"Empty"});return}try{const f=JSON.parse(i);(c=e.onValidChange)==null||c.call(e,f),(u=e.onValidityChange)==null||u.call(e,{valid:!0})}catch(f){(d=e.onValidityChange)==null||d.call(e,{valid:!1,error:f.message})}}}return n.jsxs("div",{className:"w6w-json-editor","aria-label":e["aria-label"]??"JSON editor",children:[n.jsx(Or,{value:e.value,onChange:a,extensions:r,placeholder:e.placeholder,readOnly:e.readOnly,editable:!e.readOnly,theme:t,height:e.height,minHeight:e.minHeight??"240px",maxHeight:e.maxHeight,onCreateEditor:e.onCreateEditor,onBlur:e.onBlur,onFocus:e.onFocus,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!e.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),e.overlay,e.copyable!==!1&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${s?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void o(),children:s?n.jsx(le.CheckGlyph,{}):n.jsx(le.CopyGlyph,{})}),n.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}const uc={padding:"8px 8px 2px",fontSize:"0.75em",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",opacity:.6,cursor:"default"};function dc(e){const t=[];for(const s of e){const o=t[t.length-1];o&&o.group===s.group?o.options.push(s):t.push({group:s.group,options:[s]})}return t}function Kr(e,t,s){return e*t>.6*s}function Gr(e,t){const s=t.trim().toLowerCase();return s?e.filter(o=>{var r;return o.label.toLowerCase().includes(s)||o.value.toLowerCase().includes(s)||(((r=o.keywords)==null?void 0:r.toLowerCase().includes(s))??!1)}):e}const Uo={display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"none",width:"1.25em",height:"1.25em",overflow:"hidden"},pc=240,Vo={display:"block",fontSize:"0.85em",opacity:.65,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},fc={position:"absolute",zIndex:50,left:0,right:0,top:"100%",overflowY:"auto",overscrollBehavior:"contain",margin:0,padding:4,listStyle:"none",background:"var(--w6w-panel)",color:"var(--w6w-text)",border:"1px solid var(--w6w-border)",borderRadius:6,boxShadow:"0 4px 12px rgba(0,0,0,0.15)"};function Qe({options:e,value:t,onChange:s,placeholder:o,disabled:r,"aria-label":a,mode:i="auto",forceSelection:l=!0,optionHeight:c=32,listMaxHeight:u=pc,className:d,onInputChange:f,emptyText:p="No matches",footer:w}){const m=i==="combobox"||i==="auto"&&Kr(e.length,c,typeof window>"u"?0:window.innerHeight),h=b.useId(),y=e.find(P=>P.value===t),g=(y==null?void 0:y.label)??(l?"":t),[x,S]=b.useState(g),[A,R]=b.useState(!1),[j,N]=b.useState(!1),[k,_]=b.useState(0),q=b.useRef(null);b.useEffect(()=>{S(g)},[g]);const O=b.useMemo(()=>j?Gr(e,x):e,[e,x,j]),F=b.useMemo(()=>({...fc,maxHeight:u}),[u]);if(!m)return n.jsxs("select",{className:d,value:t,disabled:r,"aria-label":a,onChange:P=>s(P.target.value),children:[o!==void 0&&t===""&&n.jsx("option",{value:"",disabled:!0,children:o}),dc(e).map(P=>P.group===void 0?P.options.map(T=>n.jsx("option",{value:T.value,children:T.label},T.value)):n.jsx("optgroup",{label:P.group,children:P.options.map(T=>n.jsx("option",{value:T.value,children:T.label},T.value))},`${P.group}-${P.options[0].value}`))]});const E=P=>`${h}-opt-${P}`,I=()=>{R(!1),N(!1)},$=P=>{S(P.label),s(P.value),I()},V=P=>{P.key==="ArrowDown"?(P.preventDefault(),A?_(T=>Math.min(T+1,O.length-1)):R(!0)):P.key==="ArrowUp"?(P.preventDefault(),A?_(T=>Math.max(T-1,0)):R(!0)):P.key==="Enter"?A&&O[k]?(P.preventDefault(),$(O[k])):l||(x!==g&&s(x),I()):P.key==="Escape"&&(A&&P.stopPropagation(),S(g),I())},J=()=>{l?S(g):x!==g&&s(x),I()};return n.jsxs("div",{ref:q,className:"w6w-combobox",style:{position:"relative"},children:[(y==null?void 0:y.icon)!==void 0&&!j&&n.jsx("span",{"aria-hidden":"true",className:"w6w-combobox-icon",style:{...Uo,position:"absolute",left:"0.6em",top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:y.icon}),n.jsx("input",{type:"text",role:"combobox",className:d,style:(y==null?void 0:y.icon)!==void 0&&!j?{paddingLeft:"2.2em"}:void 0,value:x,disabled:r,placeholder:o,"aria-label":a,"aria-expanded":A,"aria-controls":`${h}-list`,"aria-autocomplete":"list","aria-activedescendant":A&&O[k]?E(k):void 0,autoComplete:"off",onFocus:()=>R(!0),onChange:P=>{S(P.target.value),f==null||f(P.target.value),N(!0),_(0),R(!0)},onKeyDown:V,onBlur:J}),A&&n.jsxs("div",{id:`${h}-list`,role:"listbox",tabIndex:-1,"aria-label":a,style:F,children:[O.map((P,T)=>{var Z;return n.jsxs(b.Fragment,{children:[P.group!==void 0&&P.group!==((Z=O[T-1])==null?void 0:Z.group)&&n.jsx("div",{role:"presentation",className:"w6w-combobox-group",style:uc,children:P.group}),n.jsx("div",{id:E(T),role:"option",tabIndex:-1,"aria-selected":P.value===t,style:{padding:"6px 8px",cursor:"pointer",borderRadius:4,background:T===k?"var(--w6w-panel-2)":void 0},onMouseDown:K=>{K.preventDefault(),$(P)},onMouseEnter:()=>_(T),children:P.icon!==void 0?n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"0.5em"},children:[n.jsx("span",{"aria-hidden":"true",className:"w6w-combobox-icon",style:Uo,children:P.icon}),n.jsxs("span",{style:{minWidth:0,flex:1},children:[P.label,P.detail!==void 0&&n.jsx("span",{className:"w6w-combobox-detail",style:Vo,children:P.detail})]})]}):n.jsxs(n.Fragment,{children:[P.label,P.detail!==void 0&&n.jsx("span",{className:"w6w-combobox-detail",style:Vo,children:P.detail})]})})]},P.value)}),O.length===0&&n.jsx("div",{role:"presentation",style:{padding:"6px 8px",opacity:.6},children:p}),w!==void 0&&n.jsx("div",{role:"presentation",className:"w6w-combobox-footer",style:{padding:"6px 8px",opacity:.6,fontSize:"0.85em"},children:w})]})]})}function Fn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.source==="resolveFields"}function et(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.type==="expr"&&Array.isArray(e.parts)}function lt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.type==="secret"&&typeof e.ciphertext=="string"&&typeof e.iv=="string"}function Ho(e){return e.kind==="text"?{kind:"text",value:e.value??""}:e.kind==="expr"?{kind:"expr",expr:e.expr}:{kind:e.kind,ref:e.ref??""}}function mn(e){const t=e.filter(o=>o.kind!=="text"||(o.value??"")!=="");if(t.length===0)return"";if(t.some(o=>o.kind==="render"))return{type:"expr",parts:t.map(Ho)};let s="";for(const o of t){if(o.kind==="text"){s+=o.value??"";continue}hc(s)%2===1&&(s+="\\"),s+=ie.serializeTemplate([Ho(o)])}return s}function hc(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t+=1;return t}const Yr={var:!0,vars:!0,state:!0,steps:!0,nodes:!0,trigger:!0,foreach:!0,inputs:!0,output:!0,secrets:!0,documents:!0,connections:!0,const:!0};Object.freeze(Object.keys(Yr));const Jo=e=>Object.prototype.hasOwnProperty.call(Yr,e),zo=["state","var","vars"];function Xr(e){for(const t of zo)if(e===t||e.startsWith(`${t}.`)){const s=e.slice(t.length);return[...new Set([e,...zo.map(o=>o+s)])]}return[e]}function Ko(e){const t=e.indexOf(".");return t===-1?e:e.slice(0,t)}function ct(e){const t=ie.parseTemplate(e,"editor",mc);return t.every(Ln)?t:[{kind:"text",value:e}]}function Ln(e){if(e.kind==="var"){const t=e.ref??"";return!ie.hasRefusedChainToken(t)&&Jo(Ko(t))}if(e.kind==="expr"){const t=ie.coalesceOperandRefs(e.expr);return t===null?!0:t.every(s=>Jo(Ko(s)))}return!0}const mc={isOurs:Ln,backslash:"keep"},Zr={isOurs:Ln,backslash:"strip"};function rt(e){return et(e)?!0:typeof e=="string"&&e.includes("{{")&&ct(e).some(t=>t.kind!=="text")}function Dn(e){if(!e.includes("{{"))return null;const t=ie.parseTemplate(e,"editor",Zr);return t.every(Ln)&&(t.some(s=>s.kind!=="text")||t.map(s=>s.value??"").join("")!==e)?t:null}function wc(e){return e.includes("{{")?ie.parseTemplate(e,"editor",Zr).map(t=>t.kind==="text"?t.value??"":ie.serializeTemplate([t])).join(""):e}function ls(e){if(lt(e))return{parts:[],sealed:e};if(et(e))return{parts:e.parts.map(s=>({...s})),sealed:null};const t=typeof e=="string"?e:"";return{parts:t?ct(t):[],sealed:null}}function bc(e,t){let s="";for(const o of e)switch(o.kind){case"text":s+=wc(o.value??"");break;case"var":case"render":{const r=Xr(o.ref??"").find(a=>a in t);s+=r===void 0?"":t[r];break}case"secret":s+="•••";break;case"expr":s+=ie.serializeTemplate([o]);break}return s}const Pt="var.",Go="vars.",cs="documents.",us="const.",ts="connections.",ds="state.";function Qr(e){return e==="state"||e==="vars"?"var":e.startsWith(Go)?Pt+e.slice(Go.length):e.startsWith(ds)?Pt+e.slice(ds.length):e}function gc(e){return e.startsWith(ds)?3:e.startsWith(Pt)?2:1}function ea(e){return e.rank>0?e.value:Object.fromEntries(Array.from(e.children,([t,s])=>[t,ea(s)]))}function Bs(e,t,s,o){const r={children:new Map,rank:0},a={},i={},l={};for(const[h,y]of Object.entries(e??{})){const g=Qr(h);if(g.startsWith(Pt)){const x=g.slice(Pt.length),S=gc(h);let A=r;for(const R of x.split(".")){let j=A.children.get(R);j||(j={children:new Map,rank:0},A.children.set(R,j)),A=j}S>=A.rank&&(A.value=y,A.rank=S)}else g.startsWith(cs)?a[g.slice(cs.length)]=y:g.startsWith(us)?i[g.slice(us.length)]=y:g.startsWith(ts)&&!g.slice(ts.length).includes(".")&&(l[g.slice(ts.length)]=y)}const c=ea(r),u=(t==null?void 0:t.steps)??{},d=e??{},f=Object.hasOwn(d,"foreach.item"),p=typeof d["foreach.index"]=="number",w=t==null?void 0:t.foreach,m=w?{...w}:f||p?{...f?{item:d["foreach.item"]}:{},...p?{index:d["foreach.index"]}:{}}:void 0;return{...m?{foreach:m}:{},vars:c,state:c,documents:a,connections:l,constants:i,steps:u,nodes:u,trigger:(t==null?void 0:t.trigger)??{},flat:e??{},...s?{config:s}:{},...o?{meta:o}:{}}}function yc(e,t){const s=t.split(".");let o=e;for(const r of s){if(o===null||typeof o!="object")return{present:!1,value:void 0};if(!(r in o))return{present:!1,value:void 0};o=o[r]}return{present:!0,value:o}}const xc=/^(?:nodes|steps)\.[^.]+\.(?:meta\.)?config(?:\.|$)/,vc=/^(?:nodes|steps)\.([^.]+)\.meta(?:\.|$)/;function jc(e,t,s){var r;if(!t&&!s)return e;const o={...e};for(const a of new Set([...Object.keys(s??{}),...Object.keys(t??{})])){const i=t==null?void 0:t[a];o[a]={...e[a],meta:{...s==null?void 0:s[a],...(r=e[a])==null?void 0:r.meta,...i?{config:i}:{}},...i?{config:i}:{}}}return o}function ta(e,t){var p;const s=Qr(e);if(t.flat&&(s.startsWith(Pt)||s.startsWith(cs)||s.startsWith(us))){const w=Xr(e).find(m=>Object.hasOwn(t.flat,m));if(w!==void 0)return{status:"resolved",ref:e,value:t.flat[w]}}const{vars:o,constants:r,config:a,meta:i,...l}=t,c=jc(t.nodes??t.steps,a,i),u={...l,var:o,...r?{const:r}:{},nodes:c,steps:c},d=yc(u,s);if(d.present)return{status:"resolved",ref:e,value:d.value};if(xc.test(s))return{status:"at-run",ref:e};const f=(p=vc.exec(s))==null?void 0:p[1];return f!==void 0&&(i!=null&&i[f])?{status:"at-run",ref:e}:{status:"unresolved",ref:e}}function Yo(e,t){switch(e.kind){case"text":return{status:"resolved",value:e.value??""};case"var":return ta(e.ref??"",t);case"secret":return{status:"masked",ref:e.ref};case"expr":return{status:"not-evaluated"};case"render":return{status:"not-evaluated"};default:return{status:"resolved",value:void 0}}}function Us(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$"in e}function Vs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$expr"in e}function Hs(e,t){if(lt(e))return[{status:"masked"}];if(et(e))return e.parts.map(s=>Yo(s,t));if(typeof e=="string"){const s=Dn(e);if(s)return s.map(o=>Yo(o,t))}return Us(e)?[ta(String(e.$),t)]:Vs(e)?[{status:"not-evaluated"}]:[{status:"resolved",value:e}]}function ps(e,t){if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null||typeof e!="object")return!1;const s=Array.isArray(e),o=Array.isArray(t);if(s!==o)return!1;if(s){const c=e,u=t;return c.length===u.length&&c.every((d,f)=>ps(d,u[f]))}const r=e,a=t,i=Object.keys(r),l=Object.keys(a);return i.length===l.length&&i.every(c=>c in a&&ps(r[c],a[c]))}function na(e){switch(e.status){case"resolved":return e.value===void 0?"<not set>":e.value;case"unresolved":return`<unresolved: ${e.ref}>`;case"at-run":return`<resolved at run: ${e.ref}>`;case"not-evaluated":return"<not evaluated>";case"masked":return e.ref?`<masked: ${e.ref}>`:"<masked>"}}function kc(e){return e.status==="resolved"&&e.value!==void 0?typeof e.value=="string"?e.value:JSON.stringify(e.value):String(na(e))}function Nc(e){return e.length===1?na(e[0]):e.map(kc).join("")}function Zt(e,t){return Nc(Hs(e,t))}function Sc(e,t){const s={};for(const o of e)s[o.key||"(no key)"]=Zt(o.value,t);return s}const Mn=b.forwardRef(function(t,s){const{label:o,children:r,icon:a,iconSize:i,title:l,onClick:c,disabled:u,className:d,danger:f,...p}=t,w=r??(a?n.jsx(le.Icon,{name:a,size:i??16}):null),m=Object.fromEntries(Object.entries(p).filter(([h])=>h.startsWith("data-")));return n.jsx("button",{ref:s,type:"button",className:["w6w-icon-button",f?"w6w-icon-button-danger":"",d??""].filter(Boolean).join(" "),title:l??o,"aria-label":o,"aria-pressed":p["aria-pressed"],"aria-expanded":p["aria-expanded"],"aria-controls":p["aria-controls"],"aria-haspopup":p["aria-haspopup"],disabled:u,onClick:c,...m,children:w})});Mn.displayName="IconButton";const Cc={default:"",wide:" w6w-modal-wide",xl:" w6w-modal-xl",full:" w6w-modal-full",fullscreen:" w6w-modal-fullscreen"};function Ee({title:e,ariaLabel:t,onClose:s,children:o,size:r="default",titleIcon:a,subtitle:i,headerRight:l}){const c=b.useRef(null),u=b.useRef(null);return b.useEffect(()=>()=>{var d;(d=u.current)!=null&&d.isConnected&&u.current.focus({preventScroll:!0})},[]),b.useEffect(()=>{const d=c.current;if(!d)return;d.open||(u.current=document.activeElement,d.showModal());const f=w=>{w.preventDefault(),s()},p=w=>{if(w.target!==d)return;const m=d.getBoundingClientRect();(w.clientX<m.left||w.clientX>m.right||w.clientY<m.top||w.clientY>m.bottom)&&s()};return d.addEventListener("cancel",f),d.addEventListener("click",p),()=>{d.removeEventListener("cancel",f),d.removeEventListener("click",p)}},[s]),n.jsx("div",{className:"w6w-modal-backdrop",children:n.jsxs("dialog",{ref:c,className:`w6w-modal${Cc[r]}`,"aria-label":t??(typeof e=="string"?e:void 0),children:[n.jsxs("div",{className:"w6w-modal-header",children:[n.jsxs("h3",{className:"w6w-modal-title",children:[a,n.jsx("span",{children:e}),i&&n.jsx("span",{className:"w6w-modal-subtitle",children:i})]}),l]}),o]})})}const Js=new Set(["nodes","steps","state","var","vars","const","inputs","output","trigger","foreach","documents","connections"]),Ac=/[=<>]|!=|&&|\|\||\?\?/,wn=e=>Ac.test(e)||/^\s*\(*\s*!/.test(e),fs=e=>ie.expressionReferences(e).some(wn);function Ec(e,t){var a,i,l;const[s,...o]=e.split(".");if(s==="secrets")throw new Error("Secrets can be inserted into text, but cannot be used in comparisons.");if(Js.has(s))return e;const r=[...(a=t.steps)!=null&&a.some(c=>c.id===s)?[`nodes.${s}.output`]:[],...(i=t.vars)!=null&&i.includes(s)?[`var.${s}`]:[],...(l=t.constants)!=null&&l.includes(s)?[`const.${s}`]:[]];if(r.length>1)throw new Error(`“${s}” is ambiguous. Select the field from the sources.`);if(r.length===0)throw new Error(`Unknown field “${s}”. Select a source, or put text values in quotes.`);return[r[0],...o].join(".")}function Ht(e,t){var u,d,f,p,w;const s={parts:e,error:null},o=e.flatMap(m=>m.kind==="text"?ct(m.value??""):[m]);if(o.some(m=>m.kind==="render"))return s;if(o.some(sa))return{parts:o,error:Tc};if(o.some(Oc))return s;if(o.length===1&&o[0].kind==="expr"&&!fs(o[0].expr))return{parts:o,error:null};let r=o.map(m=>{if(m.kind==="text")return m.value??"";if(m.kind==="secret")return`{{ secrets.${m.ref??""} }}`;if(m.kind==="expr"){if(fs(m.expr)){const y=ie.serializeTemplate([m]);if(!y.startsWith("{{ ="))return`(${y.slice(2,-2).trim()})`}const h=ie.formatReadableExpression(m.expr);return h===null?ie.serializeTemplate([m]):`(${h})`}return wn(m.ref??"")?m.ref??"":`{{ ${m.ref??""} }}`}).join("").trim();if(!wn(r))return s;const a=/^\{\{([^{}]+)\}\}$/.exec(r);a&&wn(a[1])&&(r=a[1].trim());const i=r.replace(/^[\s(!]+/,""),l=(u=/^(?:\{\{\s*)?([A-Za-z_$][\w$-]*)/.exec(i))==null?void 0:u[1],c=i.startsWith("{{")||l!==void 0&&(Js.has(l)||l==="secrets"||((d=t.steps)==null?void 0:d.some(m=>m.id===l))||((f=t.vars)==null?void 0:f.includes(l))||((p=t.constants)==null?void 0:p.includes(l)));if(!c&&!/^(?:["']|-?\d|true\b|false\b|null\b)/.test(i))return s;if(c&&!/^\s*\(*\s*!/.test(r)){const m=(w=/^(?:\{\{[^{}]+\}\}|[A-Za-z_$][\w$-]*(?:\.[\w$-]+)*)/.exec(i))==null?void 0:w[0];if(m){const h=i.slice(m.length).replace(/^[\s)]+/,"");if(!/^(?:[=<>(]|!=|&&|\|\||\?\?)/.test(h)||/^<\/?[A-Za-z][^>]*>/.test(h))return s}}try{return{parts:[{kind:"expr",expr:ie.parseReadableExpression(r,h=>Ec(h,t))}],error:null}}catch(m){return{parts:o,error:m instanceof Error?m.message:"Check the expression."}}}const Tc="The JSONLogic after “=” is not valid JSON. Check its quotes, brackets and commas.";function sa(e){return e.kind==="expr"&&typeof e.expr=="string"}function Oc(e){return e.kind==="expr"&&e.expr!==null&&typeof e.expr=="object"&&!fs(e.expr)&&ie.formatReadableExpression(e.expr)===null}function Rc(e){return[...new Set(e.flatMap(t=>t.kind==="expr"?ie.expressionReferences(t.expr):(t.kind==="var"||t.kind==="render")&&t.ref?[t.ref]:[]))]}function Ic(e){return e.replace(/^(?:vars|state)(?=\.|$)/,"var").replace(/^steps(?=\.|$)/,"nodes")}function $c(e){const t=Object.create(null);for(const[s,o]of Object.entries(e).sort(([r],[a])=>r.split(".").length-a.split(".").length)){const r=Ic(s).split(".");if(!Js.has(r[0])||r.some(i=>["__proto__","constructor","prototype"].includes(i)))continue;let a=t;for(const i of r.slice(0,-1)){const l=a[i],c=l&&typeof l=="object"?{...l}:{};a[i]=c,a=c}a[r[r.length-1]]=o}return t.steps=t.nodes,t.vars=t.var,t.state=t.var,t}function _c(e,t={},s={}){const o={...t};for(const[i,l]of Object.entries(s))try{o[i]=JSON.parse(l)}catch{o[i]=l}const r=$c(o),a=Object.fromEntries(Object.entries(o).map(([i,l])=>[i,typeof l=="string"?l:JSON.stringify(l)]));return e.map(i=>{if(i.kind!=="expr"||sa(i))return bc([i],a);if(ie.expressionReferences(i.expr).some(u=>!u||u.split(".")[0]==="secrets"))return"••••";const c=ie.evaluate(i.expr,r);return typeof c=="string"?c:JSON.stringify(c)??""}).join("")}const Pc=/^(?:nodes|steps)\.([^.]+)\.output(?:\.(.+))?$/,Fc=/^(?:nodes|steps)\.([^.]+)\.meta\.(app|version|action|connectionId)$/,bt=e=>{if(e.startsWith("var."))return e.slice(4);if(e.startsWith("vars."))return e.slice(5);if(e.startsWith("const."))return e.slice(6);const t=Pc.exec(e);if(t)return t[2]?`${t[1]}.${t[2]}`:t[1];const s=Fc.exec(e);return s?`${s[1]} meta · ${s[2]}`:e};function Lc(e){if(e===null||typeof e!="object"||Array.isArray(e))return;const t=Object.keys(e);if(t.length!==1||t[0]!=="var")return;const s=e.var;return typeof s=="string"?s:void 0}function Dc(e){const t=e.op==="or"?"||":"??",s=e.operands.map(o=>{const r=Lc(o);return r!==void 0?bt(r):JSON.stringify(o)}).join(` ${t} `);return s.length>40?`${s.slice(0,40)}…`:s}const Mc=/[.{}]/;function Rt(e){return e===""||e!==e.trim()?!1:!Mc.test(e)}function pn(e){return e.split(".").every(Rt)}function Wc(e){const t=new Set(e.filter(s=>s.path).map(s=>s.key));return e.map(s=>{if(!s.path)return{field:s,depth:0,name:s.key,parent:null};const o=s.key.split(".");let r=0,a=0;for(let l=1;l<o.length;l++)t.has(o.slice(0,l).join("."))&&(r++,a=l);const i=a>0?o.slice(0,a).join("."):null;return{field:s,depth:r,name:o.slice(a).join("."),parent:i}})}function Xo(e,t){const s=Wc(e),o=new Map(s.map(i=>[i.field.key,i.parent])),r=new Map;for(const i of s)i.parent!==null&&r.set(i.parent,(r.get(i.parent)??0)+1);const a=i=>{const l=o.get(i)??null;return l===null||t(l)&&a(l)};return s.filter(i=>a(i.field.key)).map(({field:i,depth:l,name:c})=>({field:i,depth:l,name:c,children:r.get(i.key)??0}))}function Qt(e,t,{renderToggle:s}={}){const o=e.createElement("span");o.contentEditable="false",o.className=`w6w-expr-chip w6w-expr-chip-${t.kind}`,o.setAttribute("data-kind",t.kind);const r=e.createElement("span");r.className="w6w-expr-chip-sigil";const a=e.createElement("span");if(a.className="w6w-expr-chip-label",t.kind==="var")o.setAttribute("data-ref",t.ref??""),r.textContent="◆",a.textContent=bt(t.ref??""),o.title=`Variable: ${t.ref??""}`;else if(t.kind==="render")o.setAttribute("data-ref",t.ref??""),r.textContent="▤",a.textContent=bt(t.ref??""),o.title=`Render as template: ${t.ref??""}`;else if(t.kind==="secret")o.setAttribute("data-ref",t.ref??""),r.textContent="🔒",a.textContent=t.ref??"",o.title=`Secret: ${t.ref??""}`;else{const l=typeof t.expr=="string"?t.expr:JSON.stringify(t.expr??"");o.setAttribute("data-expr",l),r.textContent="ƒ";const c=ie.parseCoalesceChain(t.expr);if(c)a.textContent=Dc(c),o.title=`Expression: ${ie.serializeTemplate([t])}`;else{const u=ie.formatReadableExpression(t.expr,bt);a.textContent=u??(l.length>24?`${l.slice(0,24)}…`:l||"expr"),o.title=`Expression: ${u??l}`}}if(o.append(r,a),(t.kind==="var"||t.kind==="render")&&s){const l=e.createElement("span");l.className="w6w-expr-chip-toggle",l.setAttribute("data-render-toggle","1"),l.setAttribute("role","button");const c=t.kind==="render"?"Stop rendering as a template":"Render this as a template";l.setAttribute("aria-label",c),l.title=c,l.textContent="⇄",o.append(l)}const i=e.createElement("span");return i.className="w6w-expr-chip-x",i.setAttribute("data-x","1"),i.setAttribute("role","button"),i.setAttribute("aria-label","Remove"),i.textContent="×",o.append(i),o}const oa=new Set(["div","p"]);function ra(e){const t=e.getAttribute("data-kind");if(t==="var"||t==="secret"||t==="render")return{kind:t,ref:e.getAttribute("data-ref")??""};if(t==="expr"){const s=e.getAttribute("data-expr")??"";let o=s;try{o=JSON.parse(s)}catch{o=s}return{kind:"expr",expr:o}}return null}function Jt(e){const t=[],s=a=>{if(!a)return;const i=t[t.length-1];i&&i.kind==="text"?i.value=(i.value??"")+a:t.push({kind:"text",value:a})},o=(a,i)=>{if(a.nodeType===Node.TEXT_NODE){s(a.textContent??"");return}if(a.nodeType!==Node.ELEMENT_NODE)return;const l=a,c=ra(l);if(c){t.push(c);return}const u=(l.tagName??"").toLowerCase();if(u==="br"){i||s(`
6
+ `);return}const d=oa.has(u);d&&t.length>0&&s(`
7
+ `),r(l,d)},r=(a,i)=>{const l=Array.from(a.childNodes);l.forEach((c,u)=>o(c,i&&u===l.length-1))};return r(e,!0),t}const aa=e=>!!e&&(e.tagName??"").toLowerCase()==="br";function ia(e){aa(e.lastChild)||e.appendChild(e.ownerDocument.createElement("br"))}function qc(e){const t=e.ownerDocument.getSelection(),s=t!=null&&t.rangeCount?t.getRangeAt(0):null;if(!s||!e.contains(s.endContainer))return e;let o=s.endContainer;for(;o&&o!==e;){if(o.nodeType===Node.ELEMENT_NODE){const r=o;if(oa.has((r.tagName??"").toLowerCase()))return r}o=o.parentNode}return e}function zs(e){ia(qc(e))}const la=e=>e.getAttribute("aria-multiline")!=="false";function ca(e,t,s){var a;const o=e.ownerDocument;e.textContent="";for(const i of t)i.kind==="text"?i.value&&e.appendChild(o.createTextNode(i.value)):e.appendChild(Qt(o,i,s));const r=t[t.length-1];(r==null?void 0:r.kind)==="text"&&((a=r.value)!=null&&a.endsWith(`
8
+ `))&&la(e)&&ia(e)}function Ks(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),s.collapse(!1),t.removeAllRanges(),t.addRange(s)}function En(e,t){const s=e.ownerDocument,o=s.getSelection(),r=o!=null&&o.rangeCount?o.getRangeAt(0):null;if(r&&e.contains(r.commonAncestorContainer)){r.deleteContents(),r.insertNode(t);const a=s.createRange();a.setStartAfter(t),a.collapse(!0),o==null||o.removeAllRanges(),o==null||o.addRange(a)}else aa(e.lastChild)?e.insertBefore(t,e.lastChild):e.appendChild(t),Ks(e);e.focus()}function ua(e,t,s={}){const o=la(e),r=o?t.replace(/\r\n?/g,`
9
+ `):t.replace(/\r\n?|\n/g,"");if(!r)return;const a=e.ownerDocument;for(const i of ct(r))En(e,i.kind==="text"?a.createTextNode(i.value??""):Qt(a,i,s));o&&r.endsWith(`
10
+ `)&&zs(e)}function da(e,t={}){const s=e.ownerDocument,o=s.getSelection();if(!o||o.rangeCount===0||!o.isCollapsed)return!1;const r=o.getRangeAt(0),a=r.startContainer;if(a.nodeType!==Node.TEXT_NODE||!e.contains(a))return!1;const i=r.startOffset,l=a.textContent??"";if(i<2||l.slice(i-2,i)!=="}}")return!1;const c=l.lastIndexOf("{{",i-2);if(c===-1)return!1;const u=l.slice(c,i),d=ct(u);if(d.length!==1||d[0].kind==="text")return!1;let f=0;for(;c-1-f>=0&&l[c-1-f]==="\\";)f+=1;if(f%2===1)return!1;const p=s.createRange();p.setStart(a,c),p.setEnd(a,i),p.deleteContents();const w=Qt(s,d[0],t);p.insertNode(w);const m=s.createRange();return m.setStartAfter(w),m.collapse(!0),o.removeAllRanges(),o.addRange(m),!0}function pa(e){const t=ra(e);if(!t)return null;const s=t.kind==="expr"&&!ie.parseCoalesceChain(t.expr)?ie.formatReadableExpression(t.expr):null,o=e.ownerDocument.createTextNode(s??ie.serializeTemplate([t]));return e.replaceWith(o),o}function Bc(e,t){let s=!1;for(let o=0;o<t&&o<e.length;o++){const r=e[o];if(s&&r==="\\"){o++;continue}r==='"'&&(s=!s)}return s}function Uc(e){const t=e.split(".").filter(o=>o!==""),s=t[t.length-1]??"value";return(s==="output"||s==="meta")&&t.length>=3?s==="meta"?`${t[t.length-2]}_meta`:t[t.length-2]:s}function Vc(e,t){const s=[];let o=!1;for(let a=0;a<t&&a<e.length;a++){const i=e[a];if(o){i==="\\"?a++:i==='"'&&(o=!1);continue}i==='"'?o=!0:i==="{"||i==="["?s.push(i):(i==="}"||i==="]")&&s.pop()}const r=s[s.length-1];return r==="{"||r==="["?r:null}function Hc(e,t){if(!e||!Object.hasOwn(e,t))return t;let s=2;for(;Object.hasOwn(e,`${t}_${s}`);)s++;return`${t}_${s}`}function Zo(e,t,s,o){var y;const r=o?JSON.stringify(o.value)??"null":"",a=o?JSON.stringify(typeof o.value=="string"?o.value:r).slice(1,-1):`{{ ${s} }}`,i=o?r:JSON.stringify(a),l=(g,x)=>({text:e.slice(0,g)+x+e.slice(g),caret:g+x.length});if(Bc(e,t))return l(t,a);let c,u=!0;try{c=JSON.parse(e)}catch{u=!1}const d=u&&c!==null&&typeof c=="object"&&!Array.isArray(c)?c:null,f=()=>`${JSON.stringify(Hc(d,Uc(s)))}: ${i}`,p=e.slice(0,t).trimEnd(),w=p[p.length-1],m=e.slice(t).trimStart()[0],h=Vc(e,t);if(w===":"||w==="["||w===","&&h==="[")return l(t,i+(w!==":"&&m!==void 0&&m!=="]"?", ":""));if(w==="{"||w===","&&h==="{"){const g=m!==void 0&&m!=="}"?", ":"";return l(t,(w===","?" ":"")+f()+g)}if(u&&(d||Array.isArray(c))){const g=e.lastIndexOf(d?"}":"]"),x=e.slice(0,g).trimEnd(),S=x.endsWith(d?"{":"["),A=d?f():i,R=e.slice(x.length,g);if(R.includes(`
11
+ `)){const k=S?`${R.slice(R.lastIndexOf(`
12
+ `)+1)} `:((y=/^\s*/.exec(x.slice(x.lastIndexOf(`
13
+ `)+1)))==null?void 0:y[0])??"",_=`${S?"":","}
14
+ ${k}${A}`;return{text:x+_+e.slice(x.length),caret:x.length+_.length}}const j=`${S?"":","} ${A} `,N=x.length;return{text:e.slice(0,N)+j+e.slice(g),caret:N+j.length-1}}return l(t,i)}const Jc=/^\{\{\s*((?:var|vars|const|steps|nodes|trigger|foreach|inputs|output|documents)(?:\.[^\s{}]+)?)\s*\}\}$/;function zc(e){const t=Jc.exec(e.trim());return t?`{{ ${t[1]} }}`:null}function ut(e){if(typeof e=="string"){if(!e.includes("{{"))return null;const t=ct(e);return t.length===1&&t[0].kind==="var"?t[0].ref??null:null}return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===1&&typeof e.$=="string"?e.$:null}function Kc(e){var s;const t={};for(const[o,r]of Object.entries(e??{})){const a=/^(?:steps|nodes)\.([^.]+)\.output$/.exec(o);if(a){t[a[1]]={...t[a[1]],output:r};continue}const i=/^(?:steps|nodes)\.([^.]+)\.meta\.([^.]+)$/.exec(o);if(i){t[s=i[1]]??(t[s]={});const l=t[i[1]];l.meta={...l.meta,[i[2]]:r}}}return{steps:t}}function hs(e,t){if(typeof e=="string"){const s=Dn(e);return s?s.length===1&&s[0].kind==="var"?t({$:s[0].ref}):t({type:"expr",parts:s}):e}if(Array.isArray(e))return e.map(s=>hs(s,t));if(e!==null&&typeof e=="object"){const s=Object.keys(e);return s.length===1&&s[0]==="$"&&typeof e.$=="string"?t(e):Object.fromEntries(Object.entries(e).map(([o,r])=>[o,hs(r,t)]))}return e}function an({value:e,masked:t,multiline:s,options:o,fieldLabel:r,onSave:a,onClose:i,mode:l,jsonValue:c,onSaveJson:u,whole:d,startingState:f,jsonProblem:p,title:w}){var ce;const m=l==="json-binding",h=m&&f===!0,[y,g]=b.useState("ref"),[x,S]=b.useState(()=>c===void 0?"":JSON.stringify(c,null,2)),A=b.useRef(null),R=b.useRef(!1),j=b.useMemo(()=>{if(x.trim()==="")return{ok:!1};try{return{ok:!0,value:JSON.parse(x)}}catch{return{ok:!1}}},[x]),N=h?(p==null?void 0:p(x))??null:null,k=h?(x.trim()===""||j.ok)&&N===null:j.ok,_=()=>Bs(o.sampleValues,Kc(o.sampleValues),o.nodeConfig,o.nodeMeta),q=m?j.ok?JSON.stringify(hs(j.value,v=>Zt(v,_())),null,2):x.trim()===""?"":"Invalid JSON":"",O=v=>{const L=A.current,B=L?L.state.doc.toString():x;if(h){const Ae=y==="value"?{value:Zt(`{{ ${v} }}`,_())??null}:void 0,ht=B.trim()===""?"{}":B,Hi=R.current&&L?L.state.selection.main.head:ht.length,Gn=Zo(ht,Hi,v,Ae);if(!L){S(Gn.text);return}L.dispatch({changes:{from:0,to:B.length,insert:Gn.text},selection:{anchor:Gn.caret}}),L.focus();return}let oe=null;try{oe=B.trim()===""?null:ut(JSON.parse(B))}catch{oe=null}let me=!1;if(d)try{const Ae=JSON.parse(B);me=Array.isArray(Ae)?Ae.length===0:typeof Ae=="object"&&Ae!==null&&Object.keys(Ae).length===0}catch{me=!1}if(B.trim()===""||oe!==null||me){u==null||u(`{{ ${v} }}`),i();return}if(!L)return;const fe=R.current?L.state.selection.main.head:B.length,X=Zo(B,fe,v);L.dispatch({changes:{from:0,to:B.length,insert:X.text},selection:{anchor:X.caret}}),L.focus()},[F,E]=b.useState(()=>Ht(ls(e).parts,o).parts),I=b.useMemo(()=>Ht(F,o),[F,o]),[$,V]=b.useState(0),J=b.useRef(null),P=b.useRef(!1),[T,Z]=b.useState({}),[K,ne]=b.useState(null),[U,G]=b.useState(()=>new Set),z=v=>{G(L=>{const B=new Set(L);return B.has(v)?B.delete(v):B.add(v),B})},[D,te]=b.useState("auto");b.useLayoutEffect(()=>{const v=J.current;v&&(ca(v,F,{renderToggle:!0}),P.current&&(P.current=!1,Ks(v),v.focus()))},[$]);const ee=()=>{const v=J.current;v&&E(Jt(v))},C=v=>{const L=J.current;L&&(En(L,Qt(L.ownerDocument,v,{renderToggle:!0})),E(Jt(L)))},H=F.some(v=>v.kind==="render"),Q=(v,{restoreFocus:L})=>{E(Ht(ct(v),o).parts),V(B=>B+1)},ae=()=>{const v=J.current,L=Ht(v?Jt(v):F,o);L.error||(a==null||a(mn(L.parts)),i())},Y=()=>{ne(null),P.current=!0,V(v=>v+1)},ke=o.vars??[],we=o.constants??[],ge=h?[]:o.connections??[],ye=o.secrets??[],xe=o.inputs??[],ue=o.documents??[],M=o.steps??[],re=o.nodeConfigs??[],he=o.loop,Oe=new Map(re.map(v=>[v.id,v.keys.filter(Rt)]).filter(([,v])=>v.length>0)),Re=o.nodeMeta??{},_e=v=>Gc.filter(([L])=>Yc.has(L)?Be(v):Object.hasOwn(Re[v]??{},L)),de=M.filter(v=>v.hasMeta===!0).map(v=>v.id),Be=v=>{var B;if(de.includes(v))return!0;const L=(B=Re[v])==null?void 0:B.app;return typeof L=="string"&&!st(L)},Ut=v=>_e(v).map(([L,B])=>pe(B,{kind:"var",ref:`nodes.${v}.meta.${L}`},"w6w-exprmodal-field",null)),Ue=[...new Set([...Object.keys(Re),...de,...Oe.keys()])],St=M.length>0,ze=!h&&(St||!!he),dt=h?[]:(((ce=o.stateShape)==null?void 0:ce.fields)??[]).filter(v=>pn(v.key)),Ct=[...ze?["state"]:[],...dt.length>0?["runstate"]:[],...Ue.length>0?["meta"]:[],...ge.length>0?["conns"]:[],...o.inputs!==void 0?["inputs"]:[],"vars",...we.length>0?["consts"]:[],...!m||h?["docs"]:[],...m?[]:["secrets"]],pt=D==="auto"||D!==null&&!Ct.includes(D)?Ct.find(v=>v!=="meta")??null:D,Ie=v=>({open:pt===v,onToggle:()=>te(pt===v?null:v)}),ve=((he==null?void 0:he.itemOutputs)??[]).filter(v=>v.path?pn(v.key):Rt(v.key)),Pe=ie.serializeTemplate(I.parts),At=b.useMemo(()=>{const v={};for(const[L,B]of Object.entries(o.sampleValues??{}))v[L]=typeof B=="string"?B:JSON.stringify(B);return{...v,...T}},[o.sampleValues,T]),Fe=b.useMemo(()=>Rc(I.parts),[I.parts]),De=b.useMemo(()=>{if(I.error)return"";try{return _c(I.parts,o.sampleValues,T)}catch{return Pe}},[I,o.sampleValues,T,Pe]),Ke=b.useMemo(()=>{var L;const v=new Set;for(const B of Fe){if(T[B]!==void 0)continue;const oe=(L=o.valueSources)==null?void 0:L[B];oe==="sample"?v.add("example from the app"):oe==="persisted"&&v.add("from last test")}return[...v]},[Fe,T,o.valueSources]),pe=(v,L,B,oe,me=!1,fe,X)=>n.jsxs("div",{className:"w6w-exprmodal-item",style:{display:"flex",alignItems:"center",gap:4,minWidth:0,...X&&X.depth>0?{paddingLeft:X.depth*14}:{}},children:[n.jsxs("button",{type:"button",className:`w6w-exprmodal-source ${B}${X!=null&&X.declaredOnly?" is-declared-only":""}`,style:{flex:1,minWidth:0,...X!=null&&X.declaredOnly?{opacity:.6}:{}},title:`Insert ${(X==null?void 0:X.name)??v}`,"aria-label":fe,onClick:()=>m?L.kind==="var"&&O(L.ref??""):C(L),children:[oe!==null&&n.jsx("span",{className:"w6w-expr-chip-sigil",children:oe}),n.jsx("span",{className:"w6w-exprmodal-source-label",children:v}),(X==null?void 0:X.declaredOnly)&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-declared-only",style:{marginLeft:6},children:"declared by the app"}),(X==null?void 0:X.somePaths)&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-state-some-paths",title:"Set on some paths into this step, not all",style:{marginLeft:6},children:"some paths"})]}),X==null?void 0:X.toggle,!m&&n.jsx(Mn,{icon:"copy",iconSize:14,label:"Copy to expression editor","data-testid":"expr-copy-to-editor",onClick:()=>C(L)})]},`${L.kind}:${L.ref??v}`),nt=U.has("loop:item"),Ve=pe("Current item",{kind:"var",ref:"foreach.item"},"w6w-expr-chip-var","↻"),Me=(v,L)=>{if(L.length===0)return null;const B=U.has(`mcfg:${v}`);return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-exprmodal-source-row",children:n.jsxs("button",{type:"button",className:"w6w-exprmodal-tree-toggle","data-testid":"expr-config-toggle","aria-expanded":B,title:B?"Hide config":"Show config",onClick:()=>z(`mcfg:${v}`),children:[n.jsx("span",{className:"w6w-exprmodal-tree-caret","aria-hidden":"true",children:B?"▾":"▸"}),"config"]})}),B&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-config-fields",children:L.map(oe=>pe(oe,{kind:"var",ref:`nodes.${v}.meta.config.${oe}`},"w6w-exprmodal-field",null))})]})},ft=(v,L,B=`nodes.${v}.output`)=>Ne(L,B,oe=>({declaredOnly:oe.declaredOnly===!0})),se=v=>Xo(v,()=>!1).length,Ne=(v,L,B=()=>({}))=>Xo(v,oe=>U.has(`tree:${L}.${oe}`)).map(({field:oe,depth:me,name:fe,children:X})=>{const Ae=`${L}.${oe.key}`,ht=U.has(`tree:${Ae}`);return pe(fe,{kind:"var",ref:Ae},"w6w-exprmodal-field",null,!1,void 0,{name:bt(Ae),depth:me,...B(oe),toggle:X>0?n.jsx(Ot,{count:X,open:ht,onToggle:()=>z(`tree:${Ae}`)}):void 0})}),$e=v=>v==="fresh"||v==="persisted"?n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-fields-from-test",children:v==="fresh"?"Fields from the last test run":"Fields from last test"}):v==="declared"||v==="sample"?n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":`expr-fields-from-${v}`,children:v==="declared"?"declared by the app":"example from the app"}):null,W=v=>{const L=`mnode:${v}`,B=U.has(L);return n.jsxs(b.Fragment,{children:[n.jsxs("div",{className:"w6w-exprmodal-source-row","data-testid":"expr-metadata-node",children:[n.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-metadata-node-toggle","aria-expanded":B,"aria-label":B?`Hide ${v} metadata`:`Show ${v} metadata`,title:B?"Hide metadata":"Show metadata",onClick:()=>z(L),children:B?"▾":"▸"}),pe(v,{kind:"var",ref:`nodes.${v}.meta`},"w6w-expr-chip-var w6w-exprmodal-node",null,!0)]}),B&&n.jsxs("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-metadata-fields",children:[Ut(v),Me(v,Oe.get(v)??[])]})]},L)};return n.jsxs(Ee,{title:w??(m?"Edit JSON value":"Edit expression"),subtitle:r?n.jsx("code",{children:r}):void 0,onClose:i,size:"full",headerRight:m?n.jsxs("div",{className:"w6w-exprmodal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn","data-testid":"expr-json-save",disabled:!k,title:k?"Save the composed JSON":N??"Compose valid JSON to save",onClick:()=>{k&&(u==null||u(j.ok?j.value:void 0),i())},children:"Save"})]}):n.jsxs("div",{className:"w6w-exprmodal-actions",children:[!t&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:H,title:H?"Unavailable — a render part has no plain-text form. Flip it back to a variable first.":"Close the expression and keep the text as a literal value",onClick:()=>{a==null||a(ie.serializeTemplate(F)),i()},children:"Use a plain value"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn",onClick:ae,"data-testid":"expr-save",disabled:I.error!==null,children:"Save"})]}),children:[n.jsxs("div",{className:"w6w-exprmodal",children:[n.jsxs("aside",{className:"w6w-exprmodal-sources",children:[h&&n.jsxs("fieldset",{className:"w6w-exprmodal-insert-as","aria-label":"Insert as",style:{display:"flex",gap:4,alignItems:"center",marginBottom:8},children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Insert as"}),[["ref","Reference","Insert {{ ref }}: resolved when each run starts"],["value","Value","Insert the current value, copied in as it is now"]].map(([v,L,B])=>n.jsx("button",{type:"button","aria-pressed":y===v,"data-testid":`expr-insert-as-${v}`,title:B,className:`w6w-btn w6w-btn-sm${y===v?"":" w6w-btn-ghost"}`,onClick:()=>g(v),children:L},v))]}),m&&!h&&!ze&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No upstream steps"}),ze&&n.jsxs(Ge,{label:"Previous steps",...Ie("state"),children:[he&&n.jsxs("div",{className:"w6w-exprmodal-subgroup","data-testid":"expr-loop-group",children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:"Loop"}),ve.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[Ve,n.jsx(Ot,{count:se(ve),open:nt,onToggle:()=>z("loop:item")})]}):Ve,ve.length>0&&nt&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-loop-fields",children:Ne(ve,"foreach.item")}),pe("Index",{kind:"var",ref:"foreach.index"},"w6w-expr-chip-var","#"),(he.outer??[]).map(v=>{const L=v.name??v.foreachId,B=`foreach.loops.${v.foreachId}`;return n.jsxs("div",{className:"w6w-exprmodal-subgroup","data-testid":`expr-loop-outer-${v.foreachId}`,children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:L}),pe(`${L} item`,{kind:"var",ref:`${B}.item`},"w6w-expr-chip-var","↻"),pe(`${L} index`,{kind:"var",ref:`${B}.index`},"w6w-expr-chip-var","#")]},v.foreachId)})]}),M.map(v=>{const L=(v.outputs??[]).filter(fe=>fe.path?pn(fe.key):Rt(fe.key)),B=`step:${v.id}`,oe=U.has(B),me=pe(v.label??v.id,{kind:"var",ref:`nodes.${v.id}.output`},"w6w-expr-chip-var w6w-exprmodal-node",v.trigger?"⚡":null,L.length>0);return m?n.jsxs(b.Fragment,{children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:v.label??v.id}),pe("Entire output",{kind:"var",ref:`nodes.${v.id}.output`},"w6w-expr-chip-var",null,!1,`Entire output of ${v.label??v.id}`),v.needsTest&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-needs-test",children:"Run a test of this step to see its fields"})}),L.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-caret-fields","aria-expanded":oe,"aria-label":oe?"Hide fields":"Show fields",title:oe?"Hide fields":"Show fields",onClick:()=>z(B),children:oe?"▾":"▸"}),n.jsx(Ot,{count:se(L),open:oe,onToggle:()=>z(B)})]}),oe&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[$e(v.outputsFrom),ft(v.id,L)]})]})]},v.id):n.jsxs(b.Fragment,{children:[L.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-caret-fields","aria-expanded":oe,"aria-label":oe?"Hide fields":"Show fields",title:oe?"Hide fields":"Show fields",onClick:()=>z(B),children:oe?"▾":"▸"}),me,n.jsx(Ot,{count:se(L),open:oe,onToggle:()=>z(B)})]}):n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("span",{className:"w6w-exprmodal-caret-spacer","aria-hidden":"true"}),me]}),v.needsTest&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-needs-test",children:"Run a test of this step to see its fields"})}),L.length>0&&oe&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[$e(v.outputsFrom),ft(v.id,L)]})]},v.id)})]}),dt.length>0&&n.jsxs(Ge,{label:"State",testId:"expr-state-group",...Ie("runstate"),children:[pe("state",{kind:"var",ref:"state"},"w6w-expr-chip-var","◇",!0),n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-state-fields",children:Ne(dt,"state",v=>({somePaths:v.paths==="some"}))})]}),Ue.length>0&&n.jsx(Ge,{label:"Metadata",testId:"expr-metadata-group",...Ie("meta"),children:Ue.map(v=>W(v))}),ge.length>0&&n.jsx(Ge,{label:"Connections",testId:"expr-connections-group",...Ie("conns"),children:ge.map(v=>{const L=`connections.${v.name}`,B=`conn:${v.name}`,oe=U.has(B),me=v.fields.filter(X=>X.path?pn(X.key):Rt(X.key)),fe=me.filter(X=>!X.key.includes(".")).length;return n.jsxs(b.Fragment,{children:[n.jsxs("div",{className:"w6w-exprmodal-source-row","data-testid":"expr-connection",children:[pe(v.name,{kind:"var",ref:L},"w6w-expr-chip-var","⚿",!0),n.jsx(Ot,{count:fe,open:oe,onToggle:()=>z(B)})]}),n.jsx("div",{className:"w6w-exprmodal-connection-note w6w-muted w6w-small",children:v.label?`${v.appName} · ${v.label}`:v.appName}),oe&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-connection-fields",children:Ne(me,L)})]},B)})}),n.jsxs(n.Fragment,{children:[o.inputs!==void 0&&n.jsxs(Ge,{label:"Inputs",...Ie("inputs"),children:[xe.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No inputs"}),xe.map(v=>pe(v,{kind:"var",ref:`inputs.${v}`},"w6w-expr-chip-var","⇥"))]}),n.jsxs(Ge,{label:"Variables",...Ie("vars"),action:o.createVar&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-var",onClick:()=>ne("var"),children:"+ Add"}),children:[ke.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No variables"}),ke.map(v=>pe(v,{kind:"var",ref:`var.${v}`},"w6w-expr-chip-var","◆"))]}),we.length>0&&n.jsx(Ge,{label:"Constants",testId:"expr-constants-group",...Ie("consts"),children:we.map(v=>pe(v,{kind:"var",ref:`const.${v}`},"w6w-expr-chip-var","◈"))})]}),(!m||h)&&n.jsxs(Ge,{label:"Documents",...Ie("docs"),children:[ue.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No documents"}),ue.map(v=>{const L=(v.fields??[]).filter(fe=>Rt(fe.key)),B=`doc:${v.key}`,oe=U.has(B),me=pe(v.key,{kind:"var",ref:`documents.${v.key}`},"w6w-expr-chip-var","▦",L.length>0);return n.jsxs(b.Fragment,{children:[L.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[me,n.jsx(Ot,{count:L.length,open:oe,onToggle:()=>z(B)})]}):me,L.length>0&&oe&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:L.map(fe=>{const X=`documents.${v.key}.${fe.key}`;return n.jsxs("div",{className:"w6w-exprmodal-subsource-row",children:[pe(fe.key,{kind:"var",ref:X},"w6w-expr-chip-var","·"),!m&&n.jsx("button",{type:"button",className:"w6w-exprmodal-render-btn","data-testid":"expr-insert-render",title:`Insert ${X} and render its {{ }} placeholders`,"aria-label":`Insert ${X} and render its {{ }} placeholders`,onClick:()=>C({kind:"render",ref:X}),children:"▤"})]},X)})})]},v.key)})]}),!m&&n.jsxs(Ge,{label:"Secrets",...Ie("secrets"),action:o.createSecret&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-secret",onClick:()=>ne("secret"),children:"+ Add"}),children:[ye.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No secrets"}),ye.map(v=>pe(v,{kind:"secret",ref:v},"w6w-expr-chip-secret","🔒"))]})]}),m&&n.jsxs("div",{className:"w6w-exprmodal-main",children:[n.jsxs("div",{className:"w6w-exprmodal-editor",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["JSON",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— type JSON, or click a source on the left to insert it at the cursor"]})]}),n.jsx("div",{className:"w6w-exprmodal-json",onFocus:()=>{R.current=!0},children:n.jsx(Xe,{value:x,onChange:S,height:"100%",minHeight:"0px","aria-label":"Compose JSON",placeholder:h?'{ "region": "us", "template": "{{ documents.welcome }}" }':'{ "key": "{{ nodes.step_1.output }}" }',onCreateEditor:v=>{A.current=v}})})]}),n.jsxs("div",{className:"w6w-exprmodal-preview w6w-exprmodal-result-pane",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Result",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ",h?" — the state each run starts with, against the sample values":" — live preview against the sample values"]})]}),N&&n.jsx("span",{className:"w6w-muted w6w-small",role:"alert","data-testid":"expr-json-problem",children:N}),n.jsx(le.Copyable,{value:q??"",label:"Copy result",children:n.jsx("pre",{className:"w6w-exprmodal-result","data-testid":"expr-json-result",children:q})})]})]}),!m&&n.jsxs("div",{className:"w6w-exprmodal-main",children:[n.jsxs("div",{className:"w6w-exprmodal-editor",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Expression",n.jsx("span",{className:"w6w-muted w6w-small",children:" — click a source on the left, or type"})]}),n.jsx("div",{ref:J,className:`w6w-exprmodal-chips${t?" is-masked":""}${F.length===0?" is-empty":""}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":s?"true":"false","aria-label":"Expression","data-placeholder":'Pick a field, then type == "value"',"aria-invalid":I.error!==null,"aria-describedby":I.error?"expression-problem":void 0,spellCheck:!1,onInput:()=>{const v=J.current;v&&da(v,{renderToggle:!0}),ee()},onDoubleClick:v=>{const L=v.target;if(L.closest("[data-x]")||L.closest("[data-render-toggle]"))return;const B=L.closest(".w6w-expr-chip");if(!B)return;v.preventDefault();const oe=pa(B);if(oe){const me=oe.ownerDocument,fe=me.createRange();fe.setStartAfter(oe),fe.collapse(!0);const X=me.getSelection();X==null||X.removeAllRanges(),X==null||X.addRange(fe)}ee()},onBlur:()=>{const v=J.current;v&&Q(ie.serializeTemplate(Jt(v)),{restoreFocus:!1})},onPaste:v=>{var B;v.preventDefault();const L=J.current;L&&(ua(L,((B=v.clipboardData)==null?void 0:B.getData("text/plain"))??"",{renderToggle:!0}),ee())},onClick:v=>{var me;const L=v.target,B=L.closest("[data-x]");if(B){v.preventDefault(),(me=B.closest(".w6w-expr-chip"))==null||me.remove(),ee();return}const oe=L.closest("[data-render-toggle]");if(oe){v.preventDefault();const fe=oe.closest(".w6w-expr-chip");if(fe){const X=fe.getAttribute("data-ref")??"",Ae=fe.getAttribute("data-kind")==="render"?"var":"render";fe.replaceWith(Qt(fe.ownerDocument,{kind:Ae,ref:X},{renderToggle:!0}))}ee()}},onKeyDown:v=>{if(v.key!=="Enter"||(v.preventDefault(),!s))return;const L=J.current;L&&(En(L,L.ownerDocument.createTextNode(`
15
+ `)),zs(L),ee())}}),n.jsxs("span",{className:"w6w-muted w6w-small",children:["Pick a field, then type ",n.jsx("code",{children:'== "value"'}),". Combine conditions with"," ",n.jsx("code",{children:"&&"})," or ",n.jsx("code",{children:"||"}),". Double-click a chip to edit it."]}),I.error&&n.jsx("span",{id:"expression-problem",role:"alert",className:"w6w-error",children:I.error})]}),Fe.length>0&&n.jsxs("div",{className:"w6w-exprmodal-preview",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Sample values",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— try the expression against example data"]})]}),Fe.map(v=>n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:v}),n.jsx("input",{type:"text",value:T[v]??At[v]??"",placeholder:"sample value",onChange:L=>Z(B=>({...B,[v]:L.target.value}))})]},v))]}),n.jsxs("div",{className:"w6w-exprmodal-preview w6w-exprmodal-result-pane",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Result",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— live preview against the sample values"]})]}),n.jsx(le.Copyable,{value:De,readOnly:!0,children:n.jsx("pre",{className:"w6w-exprmodal-result",children:De||" "})}),Ke.length>0&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-result-source",children:Ke.join(" · ")})]})]})]}),K==="var"&&o.createVar&&n.jsx(Qo,{kind:"var",onCreate:o.createVar,onClose:Y}),K==="secret"&&o.createSecret&&n.jsx(Qo,{kind:"secret",onCreate:o.createSecret,onClose:Y})]})}function Ge({label:e,open:t,onToggle:s,action:o,testId:r,children:a}){const i=b.useId(),l=b.useRef(null);return b.useLayoutEffect(()=>{l.current&&(l.current.inert=!t)},[t]),n.jsxs("div",{className:`w6w-exprmodal-group${t?" is-open":""}`,"data-testid":r,"data-section-open":t?"true":"false",children:[n.jsxs("div",{className:"w6w-exprmodal-group-head",children:[n.jsxs("button",{type:"button",className:"w6w-exprmodal-group-toggle","data-testid":"expr-section-toggle","aria-expanded":t,"aria-controls":i,onClick:s,children:[n.jsx("span",{className:"w6w-exprmodal-group-label",children:e}),n.jsx("span",{className:"w6w-exprmodal-group-caret","aria-hidden":"true",children:"›"})]}),o]}),n.jsx("div",{id:i,ref:l,className:"w6w-exprmodal-group-body","aria-hidden":!t,children:n.jsx("div",{className:"w6w-exprmodal-group-inner",children:a})})]})}function Ot({count:e,open:t,onToggle:s}){return n.jsxs("button",{type:"button",className:"w6w-exprmodal-toggle-btn","data-testid":"expr-toggle-fields","aria-expanded":t,title:t?"Hide fields":"Show fields",onClick:s,children:[e," ",e===1?"field":"fields"," ",t?"⌄":"›"]})}const Gc=[["app","App"],["version","App version"],["action","Action"],["connectionId","Connection ID"],["subscriptionId","Subscription ID"],["url","Webhook URL"]],Yc=new Set(["app","version","action","connectionId"]);function Qo({kind:e,onCreate:t,onClose:s}){const[o,r]=b.useState(""),[a,i]=b.useState(""),[l,c]=b.useState(""),[u,d]=b.useState(null),[f,p]=b.useState(!1),w=e==="var"?"variable":"secret";async function m(){d(null),p(!0);try{await t({name:o,value:a,description:l||void 0}),s()}catch(h){d(h.message)}finally{p(!1)}}return n.jsxs(Ee,{title:`Add ${w}`,onClose:s,children:[n.jsx("div",{className:"w6w-modal-body",children:n.jsxs("div",{className:"w6w-stack",children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Name"}),n.jsx("input",{type:"text",value:o,onChange:h=>r(h.target.value),placeholder:e==="var"?"e.g. api_base_url":"e.g. openai_api_key",autoComplete:"off","data-testid":"expr-add-value-name",autoFocus:!0}),n.jsx("span",{className:"w6w-muted w6w-small",children:"Letters, digits, and underscores. Must start with a letter or underscore. Case-sensitive."})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Value"}),n.jsx("input",{type:e==="secret"?"password":"text",value:a,onChange:h=>i(h.target.value),autoComplete:"off","data-testid":"expr-add-value-value"}),e==="secret"&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Stored encrypted at rest. Once saved, it is not readable through the UI."})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Description"}),n.jsx("input",{type:"text",value:l,onChange:h=>c(h.target.value),placeholder:"Optional",autoComplete:"off"})]}),u&&n.jsx("div",{className:"w6w-result w6w-error",children:u})]})}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"expr-add-value-cancel",onClick:s,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn","data-testid":"expr-add-value-save",disabled:!o||!a||f,onClick:m,children:f?"Saving…":"Save"})]})]})}function Xc(e,t){return t?e.filter(s=>s.id!==t):e}const ms=b.createContext({});function Zc({value:e,children:t}){const s=b.useContext(ms),o=b.useMemo(()=>({...s,...e}),[s,e]);return n.jsx(ms.Provider,{value:o,children:t})}function tt(){return b.useContext(ms)}function en({value:e,onChange:t,placeholder:s,masked:o,multiline:r,readOnly:a,options:i,"aria-label":l}){const[c,u]=b.useState(()=>ls(e)),{parts:d,sealed:f}=c,[p,w]=b.useState(0),[m,h]=b.useState(!1),[y,g]=b.useState(!1),x=b.useRef(!1),S=b.useRef(null),A=b.useRef(null),R=tt(),j={...R,...i??{}},N=R.sealSecret;b.useLayoutEffect(()=>{const F=S.current;!F||f||(ca(F,d),(x.current||F.ownerDocument.activeElement===F)&&(F.focus(),Ks(F),x.current=!1))},[p,f]);const k=()=>{const F=S.current;if(!F)return;const E=Jt(F);u($=>({...$,parts:E}));const I=Ht(E,j);t(mn(I.parts))},_=async F=>{if(!N)return!1;h(!0);try{const E=await N(F);return x.current=!1,u({parts:[],sealed:E}),w(I=>I+1),t(E),!0}catch{return!1}finally{h(!1)}},q=F=>{var $;if(y||!o||a||m)return;const E=F.relatedTarget;if(E&&(($=A.current)!=null&&$.contains(E)))return;const I=mn(d);typeof I=="string"&&I!==""&&!rt(I)&&_(I)},O=F=>{if(o&&typeof F=="string"&&F.trim()!==""&&!rt(F)){_(F);return}x.current=!1,u(ls(F)),w(E=>E+1),t(F)};return f?n.jsxs("div",{className:`w6w-expr-sealed${a?" is-readonly":""}`,"aria-label":l,children:[n.jsxs("span",{className:"w6w-expr-chip w6w-expr-chip-secret",title:"Encrypted secret",children:[n.jsx("span",{className:"w6w-expr-chip-sigil",children:"🔒"}),n.jsx("span",{className:"w6w-expr-chip-label",children:"••••••"})]}),!a&&n.jsx("button",{type:"button",className:"w6w-expr-replace",onClick:()=>{x.current=!0,u({parts:[],sealed:null}),w(F=>F+1),t("")},children:"Replace"})]}):n.jsxs("div",{className:"w6w-expr",ref:A,onBlur:q,children:[n.jsxs("div",{className:"w6w-expr-field",children:[n.jsx("div",{ref:S,className:`w6w-expr-editor${o?" is-masked":""}${d.length===0?" is-empty":""}${a?" is-readonly":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox",tabIndex:a?-1:0,"aria-multiline":r?"true":"false","aria-label":l,"data-placeholder":s??"",spellCheck:!1,onInput:()=>{const F=S.current;F&&da(F),k()},onPaste:F=>{var I;F.preventDefault();const E=S.current;E&&(ua(E,((I=F.clipboardData)==null?void 0:I.getData("text/plain"))??""),k())},onClick:F=>{var I;const E=F.target.closest("[data-x]");E&&(F.preventDefault(),(I=E.closest(".w6w-expr-chip"))==null||I.remove(),k())},onDoubleClick:F=>{const E=F.target;if(E.closest("[data-x]"))return;const I=E.closest(".w6w-expr-chip");if(!I)return;F.preventDefault();const $=pa(I);if($){const V=$.ownerDocument,J=V.createRange();J.setStartAfter($),J.collapse(!0);const P=V.getSelection();P==null||P.removeAllRanges(),P==null||P.addRange(J)}k()},onKeyDown:F=>{if(F.key!=="Enter"||(F.preventDefault(),!r))return;const E=S.current;E&&(En(E,E.ownerDocument.createTextNode(`
16
+ `)),zs(E),k())}}),!a&&n.jsx("button",{type:"button",className:"w6w-expr-edit",title:"Edit expression — browse variables, secrets & step outputs","aria-label":"Edit expression",onClick:()=>g(!0),children:"ƒx"})]}),y&&n.jsx(an,{value:mn(d),masked:o,multiline:r,options:j,fieldLabel:l,onSave:O,onClose:()=>g(!1)})]})}const Qc=/\{\{\s*([^{}]*?)\s*\}\}/g;function fa(e,t="javascript"){const s=t==="python",o=[],r=[];let a=0;for(;a<e.length;){const l=e[a],c=e.slice(a,a+2),u=e.slice(a,a+3);if(s&&l==="#"||!s&&c==="//"){const d=e.indexOf(`
17
+ `,a),f=d===-1?e.length:d;r.push({start:a,end:f}),a=f}else if(!s&&c==="/*"){const d=e.indexOf("*/",a+2),f=d===-1?e.length:d+2;r.push({start:a,end:f}),a=f}else if(s&&(u==='"""'||u==="'''")){const d=e.indexOf(u,a+3),f=d===-1?e.length:d+3;o.push({start:a,end:f,quote:u}),a=f}else if(l==="'"||l==='"'||!s&&l==="`"){let d=a+1;for(;d<e.length&&e[d]!==l;){if(e[d]==="\\")d++;else if(l!=="`"&&e[d]===`
18
+ `)break;d++}const f=Math.min(d+1,e.length);o.push({start:a,end:f,quote:l}),a=f}else a++}const i=[];for(const l of e.matchAll(Qc)){const c=l.index??0,u=c+l[0].length;if(r.some(f=>c>=f.start&&c<f.end))continue;const d=o.find(f=>c>f.start&&c<f.end);i.push({start:c,end:u,ref:l[1],context:d?{kind:"string",...d}:{kind:"code"}})}return i}const eu=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$-]*|\[\d+\]|\["[^"\\]*"\]|\['[^'\\]*'\])*$/,tu=/\.([A-Za-z_$][\w$-]*)|\[(\d+)\]|\["([^"\\]*)"\]|\['([^'\\]*)'\]/g,nu={nodes:["run","nodes"],steps:["run","nodes"],trigger:["run","trigger"],foreach:["run","foreach"],state:["state"],var:["state"],vars:["state"],const:["consts"],consts:["consts"]};function bn(e,t="javascript"){var c;const s=e.trim();if(!eu.test(s))return null;const o=((c=/^[A-Za-z_$][\w$]*/.exec(s))==null?void 0:c[0])??"",r=nu[o];if(!r)return null;const a=[...r.slice(1)];for(const u of s.slice(o.length).matchAll(tu))a.push(u[2]!==void 0?Number(u[2]):u[1]??u[3]??u[4]);const i=r[0]==="run"?a.shift():r[0];return`${t==="python"?"ctx":"$"}.get(${[i,...a].map(u=>JSON.stringify(u)).join(", ")})`}function su(e,t="javascript"){const s=t==="python";let o="",r=0,a=0,i=0;for(const l of fa(e,t)){const c=bn(l.ref,t);if(c===null){i++;continue}const u=l.context;if(u.kind==="code"){o+=e.slice(r,l.start)+c,r=l.end,a++;continue}const d=u.quote,f=l.start===u.start+d.length,p=l.end===u.end-d.length;if(f&&p)o+=e.slice(r,u.start)+c,r=u.end,a++;else if(!s&&d==="`")o+=`${e.slice(r,l.start)}\${${c}}`,r=l.end,a++;else if(d.length===1&&!(s&&/[A-Za-z]/.test(e[u.start-1]??""))){const w=s?`str(${c})`:c;o+=f?`${e.slice(r,u.start)}${w} + ${d}`:`${e.slice(r,l.start)}${d} + ${w}`,p?r=u.end:(f||(o+=` + ${d}`),r=l.end),a++}else i++}return o+=e.slice(r),{code:o,converted:a,left:i}}function ou({param:e,value:t,language:s,label:o,req:r,readOnly:a,onChange:i}){var R;const l=b.useRef(null),[c,u]=b.useState(!1),d=tt(),f=b.useMemo(()=>Jr(d),[d]),p=d.steps??[],w=s==="python",m=j=>{const N=l.current;if(!N){i(t+j);return}N.dispatch(N.state.replaceSelection(j)),N.focus()},h=j=>{const N=ut(j);if(N!==null){const k=bn(N,s);k&&m(k);return}j===void 0||j===""||m(JSON.stringify(j,null,2).replace(/"\{\{\s*([^{}"]*?)\s*\}\}"/g,(k,_)=>bn(_,s)??k))},y=((R=p[0])==null?void 0:R.id)??"<step-id>",g=w?"ctx":"$",x=[[`${g}.get("nodes", ${JSON.stringify(y)}, "output")`,"a step's output"],[`${g}.get("state", "region")`,"a workflow state value"],[`${g}.get("consts", "api_base")`,"a constant"]],S=Math.max(...x.map(([j])=>j.length)),A=w?"#":"//";return n.jsxs("div",{className:"w6w-field w6w-script-code",children:[n.jsxs("span",{children:[o,r]}),n.jsx(qs,{value:t,readOnly:a,minHeight:"180px",language:s,scriptScope:f,"aria-label":`${e.key} code`,onChange:i,onCreateEditor:j=>{l.current=j}}),!a&&n.jsxs("div",{className:"w6w-seed-chips w6w-script-insert",children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Insert"}),p.map(j=>{const N=bn(`nodes[${JSON.stringify(j.id)}].output`,s)??"";return n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Insert ${N}`,onClick:()=>m(N),children:n.jsx("code",{children:j.id})},j.id)}),n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:"Pick a step field, variable or constant to insert as code","aria-label":`Insert a value into ${o}`,onClick:()=>u(!0),children:"ƒx"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint}),n.jsxs("details",{className:"w6w-script-help",children:[n.jsx("summary",{className:"w6w-muted w6w-small",children:"How to read data"}),n.jsx("pre",{className:"w6w-script-help-examples",children:x.map(([j,N])=>`${j.padEnd(S)} ${A} ${N}`).join(`
19
+ `)}),n.jsxs("span",{className:"w6w-hint",children:[n.jsx("code",{children:"input"})," is the same as ",n.jsx("code",{children:"run"})," unless you set Custom input."]}),n.jsx("span",{className:"w6w-hint",children:w?n.jsxs(n.Fragment,{children:["Use ",n.jsx("code",{children:"ctx.state"})," and ",n.jsx("code",{children:"ctx.nodes"})," directly, or"," ",n.jsx("code",{children:"ctx.get(root, *keys)"})," for literal keys. Missing paths return"," ",n.jsx("code",{children:"None"}),". Existing globals still work. Type a bracket or a key in"," ",n.jsx("code",{children:"ctx.get(...)"})," for suggestions, or press Ctrl+Space."]}):n.jsxs(n.Fragment,{children:["Use ",n.jsx("code",{children:"$.state"})," and ",n.jsx("code",{children:"$.nodes"})," directly, or"," ",n.jsx("code",{children:"$.get(root, ...keys)"})," for literal keys. Existing ",n.jsx("code",{children:"run"}),","," ",n.jsx("code",{children:"state"}),", ",n.jsx("code",{children:"vars"})," and ",n.jsx("code",{children:"consts"})," reads still work. Type a dot for suggestions, or press Ctrl+Space."]})})]}),c&&n.jsx(an,{mode:"json-binding",value:void 0,jsonValue:void 0,options:d,fieldLabel:o,whole:!0,onSaveJson:h,onClose:()=>u(!1)})]})}function Wn(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...Wn(s.children));return t}function ha(e){return rt(e)||lt(e)?!0:typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"$")}function Tn(e){var t;return((t=e.config)==null?void 0:t.allowCustom)===!0}function ws(e){return Wn(e).filter(t=>Fn(t.options))}function Gs(e){return Fn(e.options)?e.options.refreshOn??[]:[]}function bs(e,t){const s={},o=[];for(const r of Wn(e)){if(r.type==="section")continue;const a=t[r.key]!==void 0?t[r.key]:r.default;a!==void 0&&(ha(a)?o.push(r.key):s[r.key]=a)}return{form:s,unresolved:o}}function ru(e,t,s,o,r){const{form:a,unresolved:i}=bs(e,t),l=new Set(i),c=ws(e).filter(d=>{const f=Gs(d);return s==="change"&&!(o??[]).some(p=>f.includes(p))?!1:f.every(p=>!l.has(p))}).map(d=>d.key);if(c.length===0)return null;const u={reason:s,form:a,fields:c,unresolved:i};return s==="change"&&(u.changed=[...o??[]],u.previous=bs(e,r??{}).form),u}function er(e,t,s){return JSON.stringify([e.appId,e.version??null,e.kind??"action",e.actionKey,e.connectionId??null,t.key,Gs(t).map(o=>s[o]??null)])}function tr(e){return!(Fn(e.options)&&e.options.cache==="none")}function au(e,t){return e.some(s=>t.includes(s))}function iu(e,t,s,o){var l;if(!o.connectionId)return{reason:"no-connection",hint:"Connect an account to load choices"};const r=new Set(bs(t,s).unresolved),a=Gs(e).find(c=>r.has(c));return a===void 0?null:{reason:"unresolved-dependency",hint:`Options unavailable while ${((l=Wn(t).find(c=>c.key===a))==null?void 0:l.label)??a} is an expression`}}function nr(e,t,s){return e==null||e===""?{action:"keep"}:ha(e)?{action:"keep"}:t.some(o=>o.value===e||String(o.value)===String(e))?{action:"keep"}:s.reason==="change"&&!s.allowCustom?{action:"clear"}:{action:"flag",message:`Not in the list returned by ${s.appLabel}`}}function lu(e,t,s,o){const r=Vt(),a=(s==null?void 0:s.kind)==="trigger"?r==null?void 0:r.resolveTriggerFields:r==null?void 0:r.resolveActionFields,i=!!(s&&a),[l,c]=b.useState({}),u=b.useRef({params:e,values:t,dynamic:s,onChange:o,resolve:a});u.current={params:e,values:t,dynamic:s,onChange:o,resolve:a};const d=b.useRef(new Map),f=b.useRef([]),p=b.useCallback((A,R,j,N,k)=>{const{params:_,values:q,dynamic:O,resolve:F}=u.current,E=k??q;if(!O||!F||!O.connectionId)return;const I=ru(_,E,A,R,j);if(!I)return;const $=new Map(ws(_).map(D=>[D.key,D])),V=[],J={},P=[],T=O.appName??O.appId,Z=(D,te)=>{const ee=$.get(D);if(!ee)return;nr(E[D],te,{allowCustom:Tn(ee),reason:A,appLabel:T}).action==="clear"&&V.push(D)};for(const D of I.fields){if(N!==void 0&&D!==N)continue;const te=$.get(D);if(!te)continue;const ee=N===void 0&&tr(te)?d.current.get(er(O,te,I.form)):void 0;ee?(J[D]={options:ee,loading:!1},Z(D,ee)):P.push(D)}const K=(D=!1)=>{if(V.length===0)return;const te={...D?E:u.current.values};for(const ee of V)delete te[ee];u.current.onChange(te)};if(Object.keys(J).length>0&&c(D=>({...D,...J})),P.length===0){K(!0);return}for(const D of f.current)au(D.fields,P)&&D.controller.abort();const ne=new AbortController,U={fields:P,controller:ne};f.current=[...f.current.filter(D=>!D.controller.signal.aborted),U],c(D=>{var ee;const te={...D};for(const C of P)te[C]={options:(ee=D[C])==null?void 0:ee.options,loading:!0};return te});const G={...I,fields:P,connectionId:O.connectionId,...O.version!==void 0?{version:O.version}:{}},z=D=>{f.current=f.current.filter(te=>te!==U),c(te=>({...te,...D}))};Promise.resolve().then(()=>F(O.appId,O.actionKey,G,{signal:ne.signal})).then(D=>{var ee;if(ne.signal.aborted)return;const te={};for(const C of P){const H=(ee=D==null?void 0:D.fields)==null?void 0:ee[C],Q=$.get(C);if(!H||!Q)te[C]={loading:!1};else if(H.error)te[C]={loading:!1,error:H.error};else{const ae=Array.isArray(H.options)?H.options:[];te[C]={loading:!1,options:ae},tr(Q)&&d.current.set(er(O,Q,I.form),ae),Z(C,ae)}}z(te),K()}).catch(D=>{if(ne.signal.aborted)return;const te=D instanceof Error?D.message:String(D),ee={};for(const C of P)ee[C]={loading:!1,error:te||"Request failed"};z(ee)})},[]),w=s?JSON.stringify([s.appId,s.actionKey,s.version,s.connectionId]):"";b.useEffect(()=>{if(i)return c({}),p("init"),()=>{for(const A of f.current)A.controller.abort();f.current=[]}},[w,i,p]);const m=b.useRef(new Map),h=b.useCallback((A,R)=>{const j=m.current.get(A)??u.current.values;m.current.delete(A),p("change",[A],j,void 0,{...u.current.values,[A]:R})},[p]),y=b.useCallback(A=>{m.current.has(A)||m.current.set(A,u.current.values)},[]),g=b.useCallback(A=>{const R=m.current.get(A);if(m.current.delete(A),!R)return;const j=u.current.values;JSON.stringify(R[A])!==JSON.stringify(j[A])&&p("change",[A],R)},[p]),x=b.useCallback(A=>p("init",void 0,void 0,A),[p]);return{fields:b.useMemo(()=>{const A={};if(!i||!s)return A;const R=s.appName??s.appId;for(const j of ws(e)){const N=iu(j,e,t,s);if(N){A[j.key]={loading:!1,hint:N.hint};continue}const k=l[j.key]??{loading:!0},_={...k};if(k.options){const q=nr(t[j.key],k.options,{allowCustom:Tn(j),reason:"init",appLabel:R});q.action==="flag"&&(_.notInList=q.message)}A[j.key]=_}return A},[i,s,e,t,l]),commit:h,focus:y,blur:g,retry:x}}function ln(e,t){return e.hidden===!0?!1:e.showIf?ie.matchesParamCondition(e.showIf,t):!0}function Ft(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...Ft(s.children));return t}function tn(e,t){const s=[];for(let o=0;o<e.length;){const r=e[o].row;if(r){const a=[];for(;o<e.length&&e[o].row===r;)a.push(e[o++]);s.push(n.jsx("div",{className:"w6w-field-row",children:a.map(t)},`row:${r}`))}else s.push(t(e[o])),o++}return s}function ma(e,t,s,o){const r=a=>a.type==="section"?n.jsx(cu,{param:a,effective:s,renderOne:r},a.key):a.repeat&&a.type!=="array"?n.jsx(fu,{param:a,value:e[a.key],onChange:t,readOnly:o},a.key):a.type==="group"&&a.children&&a.children.length>0?n.jsx(pu,{param:a,value:e[a.key],onChange:t,effective:s,readOnly:o},a.key):n.jsx(mu,{param:a,value:e[a.key],onChange:t,effective:s,readOnly:o},a.key);return r}const qn=b.createContext(null);function qe({params:e,values:t,onChange:s,readOnly:o,dynamic:r}){const a=lu(e,t,r,s),i=Ft(e),l=w=>{var m;return t[w]!==void 0?t[w]:(m=i.find(h=>h.key===w))==null?void 0:m.default},c=e.filter(w=>ln(w,l)).map(w=>ie.effectiveParam(w,l)),u=c.filter(w=>w.required||!w.advanced),d=c.filter(w=>!w.required&&w.advanced),f=(w,m)=>{if(w==="language"){const h={...t,[w]:m};for(const y of i){if(y.type!=="code")continue;const g=t[y.key];(g===void 0||g===y.default||g===gs||hu.includes(g))&&(h[y.key]=m==="python"?gs:y.default)}s(h);return}s({...t,[w]:m})};if(e.length===0)return n.jsx("p",{className:"w6w-muted w6w-small",children:"This action takes no parameters."});const p=ma(t,f,l,o);return n.jsx(qn.Provider,{value:a,children:n.jsxs("div",{className:"w6w-stack",children:[tn(u,p),d.length>0&&n.jsxs("details",{className:"w6w-params-optional",children:[n.jsxs("summary",{className:"w6w-muted w6w-small",children:["Additional parameters (",d.length,")"]}),n.jsx("div",{className:"w6w-stack",style:{marginTop:8},children:tn(d,p)})]})]})})}function cu({param:e,effective:t,renderOne:s}){const o=(e.children??[]).filter(r=>ln(r,t)).map(r=>ie.effectiveParam(r,t));return e.section==="collapsible"?n.jsxs("details",{className:"w6w-section",open:e.collapsed===!1||e.openWhenSet===!0&&o.some(r=>{const a=t(r.key);return a!=null&&a!==""}),children:[n.jsxs("summary",{className:"w6w-section-summary",children:[n.jsx("span",{className:"w6w-section-title",children:e.title??e.label??e.key}),e.subtitle&&n.jsx("span",{className:"w6w-section-subtitle",children:e.subtitle})]}),n.jsx("div",{className:"w6w-stack w6w-section-body",children:tn(o,s)})]}):e.layout==="row"?n.jsx("div",{className:"w6w-field-row",children:o.map(s)}):n.jsx("div",{className:"w6w-stack",children:tn(o,s)})}const uu=new Set(["string","text","number","boolean","select"]);function du(e){return e.length>0&&e.every(t=>uu.has(t.type)&&!t.children)}function pu({param:e,value:t,onChange:s,effective:o,readOnly:r}){const a=e.children??[],i=t??{},l=(p,w)=>s(e.key,{...i,[p]:w}),c=Ft(a),u=p=>{const w=c.find(m=>m.key===p);return w?i[p]!==void 0?i[p]:w.default:o(p)},d=a.filter(p=>ln(p,u)).map(p=>ie.effectiveParam(p,u)),f=ma(i,l,u,r);return n.jsx(qn.Provider,{value:null,children:n.jsxs("div",{className:"w6w-stack",children:[n.jsx("span",{className:"w6w-section-title",children:e.label??e.key}),n.jsx("div",{className:"w6w-stack w6w-section-body",children:tn(d,f)})]})})}function fu({param:e,value:t,onChange:s,readOnly:o}){if(e.type==="group"){const a=e.children??[];if(!du(a))return n.jsx(Ys,{param:e,value:t,onChange:s,readOnly:o});const i={...e,item:{type:"object",fields:a}};return n.jsx(ys,{param:i,value:t,onChange:s,readOnly:o})}const r={...e,item:{type:e.type,options:Array.isArray(e.options)?e.options:void 0}};return n.jsx(ys,{param:r,value:t,onChange:s,readOnly:o})}const gs=`# Runs as a function body. Return the step's output.
20
+ return input`,hu=["// Read `input` (bound under Input), plus `vars`, `consts` and `state.nodes.<step-id>.output`.\n// Runs as a function body. Return the step's output.\nreturn input;",'# Read `input` (bound under Input), plus `vars`, `consts` and `state["nodes"][<step-id>]["output"]`.\n# Runs as a function body. Return the step\'s output.\nreturn input',"// `input` holds the data bound under Input (e.g. an upstream step's output).\n// Runs as a function body. Return the step's output.\nreturn input;","# `input` holds the data bound under Input (e.g. an upstream step's output).\n# Runs as a function body. Return the step's output.\nreturn input"];function mu(e){const t=b.useContext(qn),s=e.param.key;return n.jsx("div",{style:{display:"contents"},onFocusCapture:t?()=>t.focus(s):void 0,onBlurCapture:t?()=>t.blur(s):void 0,children:n.jsx(wu,{...e})})}function wu({param:e,value:t,onChange:s,effective:o,readOnly:r}){var R,j,N,k,_,q;const a=(R=Vt())==null?void 0:R.listModelRoutes,i=(j=Vt())==null?void 0:j.listDataStores,l=(N=Vt())==null?void 0:N.listAgents,c=(k=Vt())==null?void 0:k.listDataStoreEntries,u=Ms(),d=b.useContext(qn),f=d==null?void 0:d.fields[e.key],p=(O,F)=>{s(O,F),d==null||d.commit(O,F)},w=s,m=e.label??e.key,h=e.required&&e.type!=="boolean"?" *":"",y=b.useId();if(e.type==="boolean"){const O=!!(t??e.default??!1);return n.jsx(Le,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,variant:"inline",controlId:y,children:n.jsx("input",{id:y,type:"checkbox",checked:O,disabled:r,onChange:F=>p(e.key,F.target.checked)})})}if(e.type==="json"||e.type==="group")return n.jsx(Ys,{param:e,value:t,onChange:w,readOnly:r});if(e.type==="code"){const O=o==null?void 0:o("language"),F=O==="python"||O==="javascript"||O==="typescript"?O:void 0,E=F==="python"?gs:e.default,I=t??E??"";return e.scriptReads?n.jsx(ou,{param:e,value:String(I),language:O==="python"?"python":"javascript",label:m,req:h,readOnly:r,onChange:$=>w(e.key,$)}):n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[m,h]}),n.jsx(qs,{value:String(I),readOnly:r,minHeight:"180px",language:F,"aria-label":`${e.key} code`,onChange:$=>w(e.key,$)}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}if(e.type==="model-route"&&a)return n.jsx(bu,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,listModelRoutes:a,project:u});if(e.type==="agent"&&l)return n.jsx(gu,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,listAgents:l});if(e.type==="data-store"&&i)return n.jsx(yu,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,listDataStores:i,project:u});const g=o==null?void 0:o("store");if(e.type==="data-store-key"&&c&&typeof g=="string"&&g.trim()!=="")return n.jsx(ku,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,store:g,listDataStoreEntries:c,project:u});if(e.type==="vars")return n.jsx(Iu,{param:e,value:t,onChange:w,readOnly:r});if(e.type==="text"||(_=e.config)!=null&&_.multiline){const O=t??e.default??"";return n.jsx(Le,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,children:n.jsx("textarea",{rows:3,value:String(O),readOnly:r,"aria-label":m,onChange:F=>w(e.key,F.target.value)})})}if(e.type==="multiselect")return n.jsx(Nu,{param:e,value:t,onChange:p,readOnly:r});if(e.type==="array")return n.jsx(ys,{param:e,value:t,onChange:w,readOnly:r});if(d&&f&&!f.hint)return n.jsx(sr,{param:e,value:t,onChange:p,readOnly:r,label:m,req:h,state:f,retry:()=>d.retry(e.key)});if(Array.isArray(e.options)&&e.options.length>0&&Tn(e))return n.jsx(sr,{param:e,value:t,onChange:p,readOnly:r,label:m,req:h,state:{loading:!1,options:e.options}});if(Array.isArray(e.options)&&e.options.length>0){const O=!e.required&&e.default===void 0&&typeof e.placeholder=="string"&&e.placeholder?e.placeholder:void 0,F=t??e.default??(O!==void 0?"":(q=e.options[0])==null?void 0:q.value)??"",E=e.type==="number";return n.jsx(Le,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,children:n.jsxs("select",{value:String(F),disabled:r,"aria-label":m,onChange:I=>{const $=I.target.value;O!==void 0&&$===""?p(e.key,void 0):p(e.key,E?Number($):$)},children:[O!==void 0&&n.jsx("option",{value:"",children:O}),e.options.map(I=>n.jsx("option",{value:String(I.value),children:I.label},String(I.value)))]})})}if(e.type==="secret"){const O=t??e.default;return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[m,h]}),n.jsx(en,{value:O,masked:!0,readOnly:r,"aria-label":m,onChange:F=>w(e.key,F)}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const x=e.type==="number"?"number":"text",S=t??e.default??"",A=typeof S=="object"&&S!==null?JSON.stringify(S):String(S??"");return n.jsxs(Le,{param:e,value:t,onChange:w,readOnly:r,label:m,req:h,children:[n.jsx("input",{type:x,value:A,readOnly:r,"aria-label":m,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",onChange:O=>w(e.key,e.type==="number"?Number(O.target.value):O.target.value)}),(f==null?void 0:f.hint)&&n.jsx("span",{className:"w6w-hint",children:f.hint})]})}function sr({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,state:i,retry:l}){const c=t??e.default??"",u=typeof c=="string"||typeof c=="number"?String(c):"";return n.jsxs(Le,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:[n.jsx("div",{className:"w6w-fx-grow","aria-busy":i.loading?"true":"false",children:n.jsx(Qe,{mode:"combobox",forceSelection:!Tn(e),"aria-label":r,disabled:o,value:u,placeholder:i.loading?"Loading…":e.placeholder,options:(i.options??[]).map(d=>({value:String(d.value),label:d.label})),onChange:d=>s(e.key,d)})}),i.notInList&&n.jsx("span",{className:"w6w-hint",children:i.notInList}),i.error&&n.jsxs("span",{role:"alert",className:"w6w-hint",children:[i.error,l&&n.jsx("button",{type:"button",onClick:l,children:"Retry"})]})]})}function bu({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,listModelRoutes:i,project:l}){const[c,u]=b.useState([]);b.useEffect(()=>{let p=!0;return Promise.resolve().then(()=>i(l)).then(w=>p&&u(Array.isArray(w)?w:[])).catch(()=>p&&u([])),()=>{p=!1}},[i,l]);const d=t??e.default??"",f=typeof d=="string"?d:"";return n.jsx(Le,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Qe,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:f,placeholder:"Select a route…",options:c.map(p=>({value:p.name,label:p.status==="broken"?`${p.name} (broken)`:p.name})),onChange:p=>s(e.key,p)})})}function gu({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,listAgents:i}){const[l,c]=b.useState(null);b.useEffect(()=>{let h=!0;return Promise.resolve().then(()=>i()).then(y=>h&&c(Array.isArray(y)?y:[])).catch(()=>h&&c([])),()=>{h=!1}},[i]);const u=t??e.default??"",d=typeof u=="string"?u:"",f=l??[],p=f.find(h=>h.id===d),w=f.map(h=>({value:h.id,label:h.name||h.id}));d&&!p&&l!==null&&w.unshift({value:d,label:`${d} (not found)`});const m=l!==null&&f.length===0?n.jsx("span",{className:"w6w-muted w6w-small",children:"Create an agent in the Agents dashboard first."}):p!=null&&p.href?n.jsxs("a",{className:"w6w-small",href:p.href,target:"_blank",rel:"noreferrer",children:["Open ",p.name||p.id," in the Agents dashboard ↗"]}):null;return n.jsxs("div",{className:"w6w-agent-field",children:[n.jsx(Le,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Qe,{mode:"combobox","aria-label":r,disabled:o,value:d,placeholder:l===null?"Loading agents…":f.length===0?"No agents yet":"Select an agent…",options:w,onChange:h=>s(e.key,h)})}),m]})}function yu({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,listDataStores:i,project:l}){const[c,u]=b.useState([]);b.useEffect(()=>{let p=!0;return Promise.resolve().then(()=>i(l)).then(w=>p&&u(Array.isArray(w)?w:[])).catch(()=>p&&u([])),()=>{p=!1}},[i,l]);const d=t??e.default??"",f=typeof d=="string"?d:"";return n.jsx(Le,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Qe,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:f,placeholder:"Select a store…",options:c.map(p=>({value:p.name,label:`${p.name} (${p.kind})`})),onChange:p=>s(e.key,p)})})}const xu=25,vu=200,or=60;function ju(e){let t="";if(e.value!==void 0){try{t=typeof e.value=="string"?e.value:JSON.stringify(e.value)}catch{t=String(e.value)}t=t.replace(/\s+/g," "),t.length>or&&(t=`${t.slice(0,or-1)}…`)}const s=typeof e.updatedAt=="string"&&e.updatedAt.length>=16?`updated ${e.updatedAt.slice(0,16).replace("T"," ")}`:"";return[t,s].filter(Boolean).join(" · ")}function ku({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,store:i,listDataStoreEntries:l,project:c}){const[u,d]=b.useState(""),[f,p]=b.useState({items:[]}),[w,m]=b.useState(!0);b.useEffect(()=>{const x=new AbortController;m(!0);const S=u.trim(),A=setTimeout(()=>{Promise.resolve().then(()=>l(i,{project:c,prefix:S===""?void 0:S,limit:xu,signal:x.signal})).then(R=>{x.signal.aborted||(p(R&&Array.isArray(R.items)?R:{items:[]}),m(!1))}).catch(()=>{x.signal.aborted||(p({items:[]}),m(!1))})},S===""?0:vu);return()=>{clearTimeout(A),x.abort()}},[l,i,c,u]);const h=t??e.default??"",y=typeof h=="string"?h:"",g=u.trim();return n.jsx(Le,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Qe,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:y,placeholder:"Search entries or type a key…",options:f.items.map(x=>({value:x.key,label:x.key,detail:ju(x)||void 0})),onInputChange:d,emptyText:w?"Searching…":g!==""?`No key starts with "${g}" — Enter keeps it as typed`:"No entries in this store",footer:f.more?"More entries — type to narrow by key":void 0,onChange:x=>s(e.key,x)})})}function Le({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,bare:i,variant:l="boxed",controlId:c,children:u}){var g;const d=rt(t),f=e.type==="text"||!!((g=e.config)!=null&&g.multiline),[p,w]=b.useState(!1),m=tt(),h=l==="inline"&&!d,y=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:h?"w6w-fx-inline":`w6w-fx-wrap${d?" is-fx":""}`,children:d?n.jsx(en,{value:t,multiline:f,readOnly:o,"aria-label":r,onChange:x=>s(e.key,x)}):n.jsxs(n.Fragment,{children:[u,!o&&n.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Use an expression","aria-label":`Use an expression for ${r}`,onClick:()=>w(!0),children:"ƒx"}),h&&n.jsxs("label",{className:"w6w-fx-inline-label",htmlFor:c,children:[r,a]})]})}),p&&n.jsx(an,{value:t,multiline:f,options:m,fieldLabel:r,onSave:x=>s(e.key,x),onClose:()=>w(!1)})]});return i?y:n.jsxs("div",{className:"w6w-field",children:[!h&&n.jsxs("span",{children:[r,a]}),y,e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}function Ys({param:e,value:t,onChange:s,readOnly:o,headerActions:r,onValidityChange:a}){var q;const i=ut(t)??"",l=i!=="",c=t??e.default,[u,d]=b.useState(()=>l||c===void 0?"":JSON.stringify(c,null,2)),[f,p]=b.useState(!1),[w,m]=b.useState(!1),[h,y]=b.useState(!1),g=tt(),x=g.steps??[],S=(((q=g.stateShape)==null?void 0:q.fields.length)??0)>0;b.useEffect(()=>{if(l)return;let O;try{O=u.trim()===""?void 0:JSON.parse(u)}catch{O=void 0}JSON.stringify(O)!==JSON.stringify(c)&&(d(c===void 0?"":JSON.stringify(c,null,2)),p(!1))},[c,e.key,l]);const A=O=>{d(O)},R=O=>{p(!1),a==null||a(!0),s(e.key,O)},j=({valid:O,error:F})=>{if(a==null||a(O||F==="Empty"),!O&&F==="Empty"){p(!1),s(e.key,void 0);return}p(!O)},N=()=>{const O=zc(u);O&&(p(!1),s(e.key,O))},k=e.label??e.key,_=()=>{let O;try{O=u.trim()===""?void 0:JSON.parse(u)}catch{O=void 0}s(e.key,O)};return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{className:"w6w-field-labelrow",children:[n.jsxs("span",{children:[k,e.required?" *":""]}),r,!l&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-btn-sm",title:"Open in full view","aria-label":`Open ${k} in full view`,onClick:()=>m(!0),children:n.jsx(le.Icon,{name:"maximize",size:14})})]}),l?n.jsx("div",{className:"w6w-fx-wrap is-fx w6w-json-binding",children:n.jsx("div",{className:"w6w-expr",children:n.jsxs("div",{className:"w6w-expr-field",children:[n.jsx("div",{className:`w6w-expr-editor${o?" is-readonly":""}`,"data-testid":"json-binding-ref",children:n.jsxs("span",{className:"w6w-expr-chip w6w-expr-chip-var","data-kind":"var","data-ref":i,title:`Variable: ${i}`,children:[n.jsx("span",{className:"w6w-expr-chip-sigil",children:"◆"}),n.jsx("span",{className:"w6w-expr-chip-label",children:bt(i)}),!o&&n.jsx("button",{type:"button",className:"w6w-expr-chip-x","aria-label":`Remove the reference from ${k}`,style:{border:0,padding:0,font:"inherit"},onClick:_,children:"×"})]})}),!o&&n.jsx("button",{type:"button",className:"w6w-expr-edit",title:"Edit expression — browse step outputs, metadata & variables","aria-label":`Edit expression for ${k}`,onClick:()=>y(!0),children:"ƒx"})]})})}):n.jsx(Xe,{value:u,onChange:A,onBlur:N,readOnly:o,minHeight:"34px",maxHeight:"260px","aria-label":`${e.key} JSON`,onValidChange:R,onValidityChange:j,overlay:o?void 0:n.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Use an expression","aria-label":`Use an expression for ${k}`,onClick:()=>y(!0),children:"ƒx"})}),h&&n.jsx(an,{mode:"json-binding",value:void 0,jsonValue:t,options:g,fieldLabel:k,whole:e.whole,onSaveJson:O=>s(e.key,O),onClose:()=>y(!1)}),!l&&f&&n.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"}),e.whole&&!l&&!o&&(x.length>0||S)&&n.jsxs("div",{className:"w6w-seed-chips w6w-json-quickbind",children:[S&&n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Bind ${k} to {{ state }}, the run state upstream steps wrote`,onClick:()=>s(e.key,"{{ state }}"),children:n.jsx("code",{children:"state"})}),x.length>0&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Use the output of"}),x.map(O=>n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Bind ${k} to {{ nodes.${O.id}.output }}`,onClick:()=>s(e.key,`{{ nodes.${O.id}.output }}`),children:n.jsx("code",{children:O.id})},O.id))]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint}),w&&!l&&n.jsxs(Ee,{title:k,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>m(!1),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Xe,{value:u,onChange:A,readOnly:o,height:"100%",minHeight:"360px","aria-label":`${e.key} JSON (full view)`,onValidChange:R,onValidityChange:j})}),f&&n.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]})}function Nu({param:e,value:t,onChange:s,readOnly:o}){var g;const r=Array.isArray(e.options)?e.options:[],a=((g=e.config)==null?void 0:g.valueFormat)==="csv",i=t??e.default,l=Array.isArray(i)?i:a&&typeof i=="string"?i.split(",").map(x=>x.trim()).filter(Boolean):[],c=new Set(l.map(String)),u=r.filter(x=>!c.has(String(x.value))),d=x=>{var S;return((S=r.find(A=>String(A.value)===String(x)))==null?void 0:S.label)??String(x)},f=x=>s(e.key,a?x.join(","):x),p=x=>{if(!x||c.has(x))return;const S=r.find(A=>String(A.value)===x);f([...l,S?S.value:x])},w=x=>f(l.filter(S=>String(S)!==String(x))),m=typeof e.placeholder=="string"&&e.placeholder?e.placeholder:"Select…",h=e.label??e.key,y=e.required?" *":"";return n.jsx(Le,{param:e,value:t,onChange:s,readOnly:o,label:h,req:y,children:e.ui==="checkboxes"?n.jsxs("div",{className:"w6w-multiselect-checks w6w-fx-grow",children:[n.jsxs("div",{className:"w6w-multiselect-checks-toolbar",children:[n.jsxs("span",{className:"w6w-muted w6w-small",children:[l.length," selected"]}),!o&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"w6w-linkbtn",disabled:u.length===0,onClick:()=>f([...l,...u.map(x=>x.value)]),children:"Select all"}),n.jsx("button",{type:"button",className:"w6w-linkbtn",disabled:l.length===0,onClick:()=>f([]),children:"Clear"})]})]}),n.jsx("fieldset",{className:"w6w-multiselect-checks-options","aria-label":h,children:[...r,...l.filter(x=>!r.some(S=>String(S.value)===String(x))).map(x=>({value:x,label:String(x)}))].map(x=>n.jsxs("label",{className:"w6w-multiselect-check",children:[n.jsx("input",{type:"checkbox",checked:c.has(String(x.value)),disabled:o,onChange:S=>S.target.checked?p(String(x.value)):w(x.value)}),n.jsx("span",{children:x.label})]},String(x.value)))})]}):n.jsx(n.Fragment,{children:n.jsxs("div",{className:`w6w-multiselect${o?" is-readonly":""}`,children:[l.map(x=>n.jsxs("span",{className:"w6w-chip",children:[d(x),!o&&n.jsx("button",{type:"button",className:"w6w-chip-x","aria-label":`Remove ${d(x)}`,title:"Remove",onClick:()=>w(x),children:"×"})]},String(x))),!o&&n.jsxs("select",{className:"w6w-multiselect-add",value:"",disabled:u.length===0,"aria-label":`Add to ${e.label??e.key}`,onChange:x=>p(x.target.value),children:[n.jsx("option",{value:"",children:u.length>0?l.length?"Add more…":m:"All selected"}),u.map(x=>n.jsx("option",{value:String(x.value),children:x.label},String(x.value)))]})]})})})}function Su(e,t){if(t==null||t==="")return!0;const s=String(t);if(e==="boolean")return s==="true"||s==="false";if(e==="number")return s.trim()!==""&&Number.isFinite(Number(s));if(e==="json"){if(typeof t=="object")return!0;try{return JSON.parse(s),!0}catch{return!1}}return!0}function Cu({label:e,value:t,onChange:s,readOnly:o}){const r=typeof t=="string"?t:t==null?"":JSON.stringify(t),[a,i]=b.useState(null),l=()=>{let d=r;try{d=r.trim()?JSON.stringify(JSON.parse(r),null,2):""}catch{}i(d)};let c=!1,u;if(a!==null)if(a.trim()==="")c=!0;else try{u=JSON.parse(a),c=!0}catch{}return n.jsxs("span",{className:"w6w-array-json",children:[n.jsx("input",{className:"w6w-array-input",type:"text",value:r.replace(/\r?\n\s*/g," "),placeholder:"JSON","aria-label":e,readOnly:!0,onClick:l,onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),l())}}),n.jsx("button",{type:"button",className:"w6w-array-x",title:"Open JSON editor","aria-label":`Open ${e} JSON editor`,onClick:l,children:n.jsx(le.Icon,{name:"maximize",size:14})}),a!==null&&n.jsxs(Ee,{title:e,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>i(null),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Xe,{value:a,onChange:i,height:"100%",minHeight:"360px",readOnly:o,"aria-label":`${e} JSON editor`})}),!c&&n.jsx("p",{className:"w6w-field-error",role:"alert",children:"Invalid JSON"}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>i(null),children:o?"Close":"Cancel"}),!o&&n.jsx("button",{type:"button",className:"w6w-btn",disabled:!c,onClick:()=>{c&&(s(a.trim()===""?"":JSON.stringify(u)),i(null))},children:"Apply"})]})]})]})}function Au({field:e,value:t,row:s,onChange:o,readOnly:r}){var u,d;const a=e.placeholder??e.label??e.key,i=(u=e.config)==null?void 0:u.valueTypeFrom,l=e.label??e.key;if(i){const f=String((s==null?void 0:s[i])??"string");if(f==="boolean"){const p=t===!0||t==="true"?"true":t===!1||t==="false"?"false":"";return n.jsxs("select",{className:"w6w-array-input",value:p,disabled:r,"aria-label":l,onChange:w=>o(w.target.value),children:[n.jsx("option",{value:"",children:"(none)"}),n.jsx("option",{value:"true",children:"true"}),n.jsx("option",{value:"false",children:"false"})]})}if(f==="json")return n.jsx(Cu,{label:l,value:t,onChange:o,readOnly:r});if(f==="number")return n.jsx("input",{className:"w6w-array-input",type:"number",value:t==null?"":String(t),placeholder:a,"aria-label":l,readOnly:r,onChange:p=>o(p.target.value)})}if(Array.isArray(e.options)&&e.options.length>0)return n.jsx("select",{className:"w6w-array-input",value:String(t??e.default??((d=e.options[0])==null?void 0:d.value)??""),disabled:r,"aria-label":e.label??e.key,onChange:f=>o(f.target.value),children:e.options.map(f=>n.jsx("option",{value:String(f.value),children:f.label},String(f.value)))});if(e.type==="boolean")return n.jsxs("label",{className:"w6w-array-check",title:e.label??e.key,children:[n.jsx("input",{type:"checkbox",checked:!!(t??e.default??!1),disabled:r,"aria-label":e.label??e.key,onChange:f=>o(f.target.checked)}),n.jsx("span",{children:e.label??e.key})]});const c=e.type==="number";return n.jsx("input",{className:"w6w-array-input",type:c?"number":"text",value:String(t??e.default??""),placeholder:a,"aria-label":e.label??e.key,readOnly:r,onChange:f=>o(c?Number(f.target.value):f.target.value)})}function ys({param:e,value:t,onChange:s,readOnly:o}){const r=e.item??{type:"string"},a=r.type==="object",i=Array.isArray(t)?t:Array.isArray(e.default)?e.default:[],l=p=>s(e.key,p),c=()=>a?Object.fromEntries((r.fields??[]).map(p=>{var w;return[p.key,p.default??(p.type==="boolean"&&!((w=p.config)!=null&&w.valueTypeFrom)?!1:"")]})):r.type==="number"?0:r.type==="boolean"?!1:"",u=(p,w)=>l(i.map((m,h)=>h===p?w:m)),d=p=>{const m={...p??{}};for(const h of r.fields??[])m[h.key]===void 0&&(m[h.key]=h.default);return m},f=(p,w,m)=>{var y;const h={...p??{},[w]:m};for(const g of r.fields??[])((y=g.config)==null?void 0:y.valueTypeFrom)===w&&!Su(String(m??""),h[g.key])&&(h[g.key]="");return h};return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[e.label??e.key,e.required?" *":""]}),n.jsxs("div",{className:"w6w-array",children:[i.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"None yet — add one below."}),a&&i.length>0&&n.jsxs("div",{className:"w6w-array-head","aria-hidden":"true",children:[n.jsx("div",{className:"w6w-array-head-cells",children:(r.fields??[]).map(p=>p.type==="boolean"&&!(Array.isArray(p.options)&&p.options.length>0)?n.jsxs("span",{className:"w6w-array-check w6w-array-head-ghost",children:[n.jsx("span",{className:"w6w-array-head-box"}),n.jsx("span",{children:p.label??p.key})]},p.key):n.jsxs("span",{className:"w6w-array-head-cell",children:[p.label??p.key,p.required?" *":""]},p.key))}),!o&&n.jsx("span",{className:"w6w-array-x w6w-array-head-ghost"})]}),i.map((p,w)=>n.jsxs("div",{className:"w6w-array-row",children:[a?n.jsx("div",{className:"w6w-array-cells",children:(r.fields??[]).map(m=>n.jsx(Au,{field:m,value:p==null?void 0:p[m.key],row:d(p),readOnly:o,onChange:h=>u(w,f(p,m.key,h))},m.key))}):n.jsx("input",{className:"w6w-array-input",type:r.type==="number"?"number":"text",value:String(p??""),placeholder:r.placeholder,readOnly:o,onChange:m=>u(w,r.type==="number"?Number(m.target.value):m.target.value)}),!o&&n.jsx("button",{type:"button",className:"w6w-array-x","aria-label":"Remove item",title:"Remove",onClick:()=>l(i.filter((m,h)=>h!==w)),children:"×"})]},w)),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-array-add",onClick:()=>l([...i,c()]),children:"+ Add"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const Eu=["string","number","boolean","json"],Tu=[];function On(e,t=[]){return Array.isArray(e)?e.every(s=>s&&typeof s=="object"&&typeof s.key=="string")?e:null:!e||typeof e!="object"||rt(e)||ut(e)||"$expr"in e?null:Object.entries(e).map(([s,o])=>{const r=t.find(i=>i.key===s),a=typeof o;return{key:s,type:r&&JSON.stringify(r.value)===JSON.stringify(o)?r.type:a==="string"||a==="number"||a==="boolean"?a:"json",value:o}})}function Ou(e){const t=Array.isArray(e)?On(e):null;return!t||t.some(s=>!s.key)||new Set(t.map(s=>s.key)).size!==t.length?e:Object.fromEntries(t.map(s=>[s.key,s.value]))}function rr(e,t){if(e==="number"){if(t.trim()==="")return"";const s=Number(t);return Number.isNaN(s)?t:s}if(e==="boolean")return t==="true";if(e==="json")try{return JSON.parse(t)}catch{return t}return t}function ar(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function ir(e,t=!1){if(typeof e=="string"&&/^[\[{]/.test(e.trim()))try{JSON.parse(e)}catch{return e}return e===void 0?"":JSON.stringify(e,null,t?2:void 0)}function Ru({param:e,value:t,label:s,onChange:o,readOnly:r}){const[a,i]=b.useState(null),l=()=>i(ir(t,!0));let c=!1,u;if(a!==null)try{u=JSON.parse(a),c=!0}catch{}return n.jsxs(n.Fragment,{children:[n.jsxs(Le,{bare:!0,param:e,value:t,onChange:(d,f)=>o(f),readOnly:r,label:s,req:"",children:[n.jsx("input",{type:"text",className:"w6w-datavar-json-preview",value:ir(t).replace(/\r?\n\s*/g," "),placeholder:"JSON value","aria-label":`${s} JSON preview`,readOnly:!0,onClick:l,onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),l())}}),n.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Open JSON editor","aria-label":`Open ${s} JSON editor`,onClick:l,children:n.jsx(le.Icon,{name:"maximize",size:14})})]}),a!==null&&n.jsxs(Ee,{title:s,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>i(null),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Xe,{value:a,onChange:i,height:"100%",minHeight:"360px",readOnly:r,"aria-label":`${s} JSON editor`})}),!c&&a.trim()&&n.jsx("p",{className:"w6w-field-error",role:"alert",children:"Invalid JSON"}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>i(null),children:r?"Close":"Cancel"}),!r&&n.jsx("button",{type:"button",className:"w6w-btn",disabled:!c,onClick:()=>{c&&(o(u),i(null))},children:"Apply"})]})]})]})}function Iu({param:e,value:t,onChange:s,readOnly:o}){const r=t??e.default??Tu,a=b.useMemo(()=>Ou(r),[r]),[i,l]=b.useState(()=>Array.isArray(r)?"fields":"json"),c=b.useRef([]),[u,d]=b.useState(!1),[f,p]=b.useState(null),w=On(r,c.current),m=w??[],h=i==="json"||w===null,y=e.label??e.key,g=n.jsxs("div",{className:"w6w-view-toggle w6w-datavar-modes",children:[n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${h?"":" active"}`,"aria-label":`Edit ${y} as fields`,"aria-pressed":!h,disabled:u||!!f||w===null,title:w===null?"Use a literal JSON object to edit individual fields":"Edit individual fields",onClick:()=>{!o&&!Array.isArray(r)&&s(e.key,m),l("fields")},children:"Fields"}),n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${h?" active":""}`,"aria-label":`Edit ${y} as JSON`,"aria-pressed":h,onClick:()=>{c.current=m,l("json")},children:"JSON"})]});if(h)return n.jsxs("div",{className:"w6w-datavar-json",children:[n.jsx(Ys,{param:{...e,type:"json",whole:!0,default:{},hint:"Enter a JSON object or use ƒx to bind one. Switch to Fields to edit individual values."},value:a,readOnly:o,headerActions:g,onValidityChange:A=>d(!A),onChange:(A,R)=>{if(R!==void 0&&On(R)===null&&!ut(R)&&!rt(R)&&!(R&&typeof R=="object"&&"$expr"in R)){p("Use a JSON object, a typed key/value array, or an object binding.");return}p(null),d(!1),s(A,R)}}),f&&n.jsx("span",{className:"w6w-hint w6w-datavar-error","aria-live":"polite",children:f})]});const x=A=>s(e.key,A),S=(A,R)=>x(m.map((j,N)=>N===A?{...j,...R}:j));return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{className:"w6w-field-labelrow",children:[n.jsxs("span",{children:[y,e.required?" *":""]}),g]}),n.jsxs("div",{className:"w6w-stack",children:[m.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No variables yet — add one below."}),m.length>0&&n.jsxs("div",{className:"w6w-datavar-head","aria-hidden":"true",children:[n.jsx("span",{children:"Key"}),n.jsx("span",{children:"Type"}),n.jsx("span",{children:"Value"}),!o&&n.jsx("span",{})]}),m.map((A,R)=>n.jsxs("div",{className:"w6w-datavar-row",children:[n.jsx("input",{type:"text",placeholder:"key","aria-label":"Variable key",value:A.key,readOnly:o,onChange:j=>S(R,{key:j.target.value})}),n.jsx("select",{value:A.type,"aria-label":"Variable type",disabled:o,onChange:j=>{const N=j.target.value;S(R,{type:N,value:rr(N,ar(A.value))})},children:Eu.map(j=>n.jsx("option",{value:j,children:j},j))}),A.type==="json"?n.jsx(Ru,{param:e,value:A.value,label:A.key||"value",onChange:j=>S(R,{value:j}),readOnly:o}):n.jsx(Le,{bare:!0,param:e,value:A.value,onChange:(j,N)=>S(R,{value:N}),readOnly:o,label:A.key||"value",req:"",children:A.type==="boolean"?n.jsxs("select",{value:A.value===!0?"true":"false",disabled:o,onChange:j=>S(R,{value:j.target.value==="true"}),children:[n.jsx("option",{value:"true",children:"true"}),n.jsx("option",{value:"false",children:"false"})]}):n.jsx("input",{type:A.type==="number"?"number":"text",placeholder:"value",value:ar(A.value),readOnly:o,onChange:j=>S(R,{value:rr(A.type,j.target.value)})})}),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","aria-label":`Remove variable ${A.key||R+1}`,title:"Remove",onClick:()=>x(m.filter((j,N)=>N!==R)),children:"×"})]},R)),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>x([...m,{key:"",type:"string",value:""}]),children:"+ Add variable"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const xs={onCopy:e=>{lr(e)},onCut:e=>{const t=lr(e);if(!t)return;const s=e.currentTarget;typeof document.execCommand=="function"&&document.execCommand("delete")||(s.setRangeText("",t[0],t[1],"end"),s.dispatchEvent(new Event("input",{bubbles:!0})))}};function lr(e){const t=e.currentTarget,s=t.selectionStart,o=t.selectionEnd;return s===null||o===null||s===o||!e.clipboardData?null:(e.clipboardData.setData("text/plain",t.value.slice(s,o)),e.preventDefault(),[s,o])}function wa(e,t){const s={...t};for(const o of e){const r=t[o.key];if(!(o.type!=="json"||typeof r!="string"||r.trim()===""))try{s[o.key]=JSON.parse(r)}catch{return{error:`${o.label} is not valid JSON. Check it and try again.`}}}return{values:s}}function gn({fields:e,values:t,onChange:s,enterSubmitProps:o,mode:r="create"}){const a=(i,l)=>s({...t,[i]:l});return n.jsxs("div",{className:"w6w-stack",children:[e.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"This auth method declares no fields — nothing to fill in. The credential will be an empty object."}),e.map(i=>{const l=r==="edit",c=t[i.key]??(l?void 0:i.default)??"";if(i.type==="boolean")return n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[n.jsx("input",{type:"checkbox",checked:!!c,onChange:f=>a(i.key,f.target.checked),...o}),i.label,i.required?" *":""]}),i.hint&&n.jsx("span",{className:"w6w-hint",children:i.hint})]},i.key);const u=i.type==="secret"||i.secret===!0;if(i.type==="json"&&u&&!l)return n.jsx(ba,{field:i,value:String(c??""),onChange:f=>a(i.key,f)},i.key);if(i.type==="json"||i.type==="text")return n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[i.label,i.required?" *":""]}),n.jsx("textarea",{className:u&&i.type!=="json"?"w6w-secret-input":void 0,...u&&i.type!=="json"?xs:{},rows:i.type==="json"?6:3,value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:f=>a(i.key,f.target.value),name:`w6w-cred-${i.key}`,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other"}),i.hint&&n.jsx("span",{className:"w6w-hint",children:i.hint})]},i.key);const d=i.type==="number"?"number":"text";return n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[i.label,i.required?" *":""]}),n.jsx("input",{type:d,className:u?"w6w-secret-input":void 0,...u?xs:{},value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:f=>a(i.key,i.type==="number"&&!(l&&f.target.value==="")?Number(f.target.value):f.target.value),name:`w6w-cred-${i.key}`,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...o}),i.hint&&n.jsx("span",{className:"w6w-hint",children:i.hint})]},i.key)})]})}const $u=/(^|_)(private_key|secret|password|token)$/i,cr=["client_email","client_id","project_id","private_key_id","private_key"],_u=["type","universe_domain"];function Pu(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object"||Array.isArray(t))return null;const s=o=>{const r=cr.indexOf(o);return r===-1?cr.length:r};return Object.entries(t).filter(([o,r])=>typeof r=="string"&&r!==""&&!/^https?:\/\//.test(r)&&!_u.includes(o)).sort(([o],[r])=>s(o)-s(r)).map(([o,r])=>({key:o,label:(o.charAt(0).toUpperCase()+o.slice(1)).replace(/_/g," "),value:r,secret:$u.test(o)}))}function ba({field:e,value:t,onChange:s}){const o=b.useRef(null),r=t.trim()===""?null:Pu(t),a=n.jsxs("span",{children:[e.label,e.required?" *":""]}),i=n.jsx("input",{ref:o,type:"file",accept:"application/json,.json",hidden:!0,onChange:async l=>{var u;const c=(u=l.target.files)==null?void 0:u[0];c&&s(await c.text()),l.target.value=""}});return r?n.jsxs("div",{className:"w6w-field",children:[a,n.jsxs("div",{className:"w6w-keyfile","data-testid":`keyfile-${e.key}`,children:[n.jsx("dl",{children:r.map(l=>n.jsxs("div",{children:[n.jsx("dt",{children:l.label}),n.jsx("dd",{children:l.secret?n.jsx("span",{className:"w6w-keyfile-secret",children:"•••••••• encrypted when you save"}):n.jsx("code",{children:l.value})})]},l.key))}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>s(""),children:"Use a different key"})]})]}):n.jsxs("div",{className:"w6w-field",children:[a,n.jsx("textarea",{className:"w6w-keyfile-paste",rows:4,value:t,"aria-label":e.label,placeholder:"Paste the key file's contents here",onChange:l=>s(l.target.value),name:`w6w-cred-${e.key}`,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other"}),n.jsxs("span",{className:"w6w-hint",children:[t.trim()!==""?"That isn't complete JSON yet. ":"","Paste the whole file, or"," ",n.jsx("button",{type:"button",className:"w6w-linkbtn",onClick:()=>{var l;return(l=o.current)==null?void 0:l.click()},children:"choose the .json file"}),"."]}),i]})}function ga({auth:e,scopes:t=!0,clientId:s=""}){const o=e.serviceAccount;return n.jsxs(n.Fragment,{children:[e.description&&n.jsx("p",{className:"w6w-muted w6w-small",children:e.description}),e.setup&&e.setup.length>0?n.jsx(Fu,{steps:e.setup}):null,t&&o&&o.scopes.length>0&&o.impersonation!=="none"?n.jsx(Xs,{scopes:o.scopes,clientId:s,required:o.impersonation==="required"}):t&&o&&o.scopes.length>0?n.jsx(xa,{scopes:o.scopes}):null]})}function Fu({steps:e}){return n.jsxs("details",{className:"w6w-auth-setup",children:[n.jsx("summary",{className:"w6w-auth-setup-title",children:"Where do I get this?"}),n.jsx("ol",{children:e.map(t=>n.jsxs("li",{children:[t.text,t.url&&/^https:\/\//.test(t.url)?n.jsxs(n.Fragment,{children:[" ",n.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:"Open ↗"})]}):null]},t.text))})]})}const Lu="https://admin.google.com/ac/owl/domainwidedelegation";function ya(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return""}const s=t&&typeof t=="object"?t.client_id:void 0;return typeof s=="string"||typeof s=="number"?String(s):""}function Xs({scopes:e,clientId:t,required:s}){return n.jsxs("section",{className:"w6w-delegation","data-testid":"delegation-steps","aria-label":"Allow this key in Google Workspace",children:[n.jsx("h4",{children:s?"Allow this key in Google Workspace":"To act as a Workspace user"}),n.jsxs("ol",{children:[n.jsxs("li",{children:["Sign in to the Google Admin console as a Workspace admin and open"," ",n.jsx("strong",{children:"Security → Access and data control → API controls → Domain-wide delegation"}),"."," ",n.jsx("a",{href:Lu,target:"_blank",rel:"noopener noreferrer",children:"Open ↗"})]}),n.jsxs("li",{children:["Click ",n.jsx("strong",{children:"Add new"})," and paste this Client ID:",t?n.jsx(ur,{label:"Client ID",text:t}):n.jsxs("span",{className:"w6w-muted",children:[" ","the key's Client ID (",n.jsx("code",{children:"client_id"})," in the key file, also on the credential's page). It appears here once a key is chosen or pasted."]})]}),n.jsxs("li",{children:["Paste these OAuth scopes, exactly, then ",n.jsx("strong",{children:"Authorize"}),":",n.jsx(ur,{label:"Scopes",text:e.join(",")})]}),n.jsx("li",{children:"Enter the Workspace user to act as below (an address in that Workspace, not a personal @gmail.com). Google can take a few minutes to apply a new delegation; if Save is refused right away, wait and try again."})]})]})}function ur({label:e,text:t}){const[s,o]=b.useState(!1);return n.jsxs("div",{className:"w6w-scopes",children:[n.jsx("span",{className:"w6w-muted w6w-small",children:e}),n.jsx("code",{children:t}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","aria-label":`Copy ${e}`,onClick:()=>{var r;(r=navigator.clipboard)==null||r.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},children:s?"Copied":"Copy"})]})}function xa({scopes:e}){const[t,s]=b.useState(!1),o=e.join(",");return n.jsxs("div",{className:"w6w-scopes",children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Scopes"}),n.jsx("code",{children:o}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>{var r;(r=navigator.clipboard)==null||r.writeText(o).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},children:t?"Copied":"Copy"})]})}function va({credentials:e,mode:t,onModeChange:s,selectedId:o,onSelect:r,canUseExisting:a=!0,contract:i}){return!a||e.length===0?null:n.jsxs("div",{className:"w6w-stack",children:[n.jsxs("div",{className:"w6w-field",role:"radiogroup","aria-label":"Credential",children:[n.jsxs("span",{children:["Credential",i?` (${i})`:""]}),n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:"w6w-credential-mode",checked:t==="existing",onChange:()=>s("existing")})," ","Use existing"]}),n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:"w6w-credential-mode",checked:t==="new",onChange:()=>s("new")})," ","Enter new"]})]}),t==="existing"&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Stored credential"}),n.jsx("select",{name:"w6w-credential-id",value:o,onChange:l=>r(l.target.value),children:e.map(l=>n.jsx("option",{value:l.id,children:l.name},l.id))})]})]})}function ja(e){const t=(e.bindingFields??[]).filter(r=>r.key!=="delegatedUser");return e.impersonation==="none"?t:[{...(e.bindingFields??[]).find(r=>r.key==="delegatedUser")??{type:"string"},key:"delegatedUser",label:"Workspace user to act as",type:"string",required:e.impersonation==="required"},...t]}function ka(e,t){const s={},o={};for(const r of e){const a=t[r.key];a==null||a===""||(r.key==="delegatedUser"?s.delegatedUser=String(a):o[r.key]=a)}return Object.keys(o).length>0&&(s.settings=o),Object.keys(s).length>0?s:void 0}const Du="width=560,height=720,menubar=no,toolbar=no,location=no";function Na(e){return new Promise((t,s)=>{const o=window.open(e,"w6w-oauth",Du);if(!o){s(new Error("Popup blocked — allow popups for this site and try again."));return}let r=!1;const a=()=>{r=!0,window.removeEventListener("message",i),window.clearInterval(l)},i=c=>{const u=c.data;if((u==null?void 0:u.w6w)==="oauth-result"){a();try{o.close()}catch{}u.ok&&typeof u.connectionId=="string"?t({connectionId:u.connectionId}):s(new Error(u.error??"OAuth flow failed."))}};window.addEventListener("message",i);const l=window.setInterval(()=>{r||o.closed&&(a(),s(new Error("OAuth popup was closed before the flow completed.")))},500)})}const Mu=new Set(["checkbox","radio","button","submit","reset","file","range","color","image","hidden","date","datetime-local","month","week","time"]);function Wu(e){return e.closest('[contenteditable]:not([contenteditable="false"])')!==null}function Sa(e,t){return{onKeyDown:s=>{if((t==null?void 0:t.enabled)===!1||s.key!=="Enter"||s.shiftKey||s.altKey||s.ctrlKey||s.metaKey||s.nativeEvent.isComposing)return;const o=s.target;o.tagName!=="TEXTAREA"&&(Wu(o)||o.tagName==="INPUT"&&Mu.has(o.type)||(s.preventDefault(),e()))}}}function Zs(e){const t=Ce(),[s,o]=b.useState(null),[r,a]=b.useState(!!e.initialAppId);return b.useEffect(()=>{const i=e.initialAppId;if(!i)return;let l=!1;const c=f=>{l||(o(f),a(!1))},u=t.listAppsByIds;if(u)return u([i]).then(f=>c(f.find(p=>p.id===i)??null)).catch(()=>c(null)),()=>{l=!0};const d=t.listApps;return typeof d=="function"?d().then(f=>c(f.find(p=>p.id===i)??null)).catch(()=>c(null)):c(null),()=>{l=!0}},[t,e.initialAppId]),s?n.jsx(Ee,{title:s.displayName,subtitle:n.jsxs(n.Fragment,{children:[n.jsx("code",{children:s.id}),s.version&&` · v${s.version}`]}),onClose:e.onClose,size:"xl",titleIcon:n.jsx(Nt,{src:s.iconSvg,srcDark:s.iconSvgDark,brandColor:s.brandColor,name:s.displayName,theme:e.theme,size:22}),headerRight:e.initialAppId?void 0:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>o(null),children:"← Apps"}),children:n.jsx(Ca,{app:s,onCreated:e.onCreated,onClose:e.onClose})}):r?n.jsx(Ee,{title:"Add connection",onClose:e.onClose,size:"xl",children:n.jsx("div",{className:"w6w-stepbuilder-content",children:n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"})})}):n.jsx(Ee,{title:"Add connection",onClose:e.onClose,size:"xl",children:n.jsx("div",{className:"w6w-stepbuilder-content",children:n.jsx(ot,{onSelectApp:o,theme:e.theme,searchPlaceholder:"Search apps to connect…",categoryFilter:!0})})})}function Ca({app:e,onCreated:t,onClose:s}){var xe,ue;const o=Ce(),[r,a]=b.useState(null),[i,l]=b.useState(""),[c,u]=b.useState(""),[d,f]=b.useState({}),[p,w]=b.useState(null),[m,h]=b.useState(!1),[y,g]=b.useState(null),[x,S]=b.useState(null),[A,R]=b.useState(""),[j,N]=b.useState({}),[k,_]=b.useState("account"),[q,O]=b.useState(!0),[F,E]=b.useState(!1);b.useEffect(()=>{let M=!1;return a(null),o.getAppAuth(e.id).then(re=>!M&&a(re.filter(he=>he.available!==!1))).catch(re=>!M&&w(re.message)),()=>{M=!0}},[o,e.id]);const I=r??[],$=I.find(M=>M.key===i)??I.find(M=>M.default===!0)??I[0],V=($==null?void 0:$.fields)??[],J=($==null?void 0:$.type)==="oauth2",P=$==null?void 0:$.serviceAccount,T=($==null?void 0:$.accepts)??(P==null?void 0:P.accepts)??[],Z=o.listCredentials,K=!J&&T.length>0&&typeof Z=="function",ne=(y??[]).filter(M=>M.status==="active"&&!M.private&&M.accessScope!=="user"&&T.includes(M.contract)),U=($==null?void 0:$.userScope)===!0&&!J&&($==null?void 0:$.key)!=="zero-credential",G=U&&k==="user",z=($==null?void 0:$.refreshable)===!0&&($==null?void 0:$.key)!=="zero-credential",D=z&&!q,te=G||ne.length===0?"new":x??"existing",ee=ne.some(M=>M.id===A)?A:((xe=ne[0])==null?void 0:xe.id)??"",C=K&&P?ja(P):[],H=te==="existing"?((ue=ne.find(M=>M.id===ee))==null?void 0:ue.display.client_id)??"":Object.values(d).map(ya).find(Boolean)??"",Q=($==null?void 0:$.key)??"";b.useEffect(()=>{if(!K||!Z)return;let M=!1;return g(null),S(null),Z.call(o,{appId:e.id,authKey:Q}).then(re=>!M&&g(re)).catch(()=>!M&&g([])),()=>{M=!0}},[o,e.id,K,Q,Z]);const ae=($==null?void 0:$.key)==="zero-credential",Y=M=>M===void 0||M==="",ke=!J&&!ae&&(K?y===null||C.some(M=>M.required&&Y(j[M.key]))||(te==="existing"?ee==="":V.some(M=>M.required&&Y(d[M.key]))):V.some(M=>M.required&&Y(d[M.key]))),we=!$||!J&&!ae&&ke||m;async function ge(){if($){w(null),h(!0);try{if(ae)t({connectionId:`zerocred:${e.id}`});else if(J){const{authorizationUrl:M}=await o.startAppOAuthFlow(e.id,$.key,{displayName:c||void 0,...D?{autoRefresh:!1}:{}}),{connectionId:re}=await Na(M);t({connectionId:re})}else if(K&&te==="existing"){const M=ka(C,j),re={authKey:$.key,credentialId:ee,...M?{binding:M}:{},...c?{displayName:c}:{},...D?{autoRefresh:!1}:{}},he=await o.createConnection(e.id,re);t({connectionId:he.id})}else{const M=wa(V,d);if("error"in M){w(M.error);return}let re=M.values;if(P){re={};for(const Oe of C){const Re=j[Oe.key];Re==null||Re===""||(re[Oe.key]=Oe.key==="delegatedUser"?String(Re):Re)}Object.assign(re,d)}const he=await o.createConnection(e.id,{authKey:$.key,credential:re,displayName:c||void 0,...G?{accessScope:"user"}:{},...D?{autoRefresh:!1}:{}});t({connectionId:he.id})}}catch(M){w(M.message)}finally{h(!1)}}}const ye=Sa(ge,{enabled:!we});return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsx("div",{className:"w6w-modal-body",children:n.jsxs("div",{className:"w6w-stack",children:[r===null&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading auth methods…"}),r!==null&&I.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"This app has no available auth methods. If it uses OAuth, its client credentials may not be configured on the server yet."}),I.length>1&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Auth method"}),n.jsx("select",{value:($==null?void 0:$.key)??"",onChange:M=>{l(M.target.value),f({}),N({}),S(null),_("account"),O(!0),w(null)},children:I.map(M=>n.jsxs("option",{value:M.key,children:[M.displayName??M.key," (",M.type,")"]},M.key))})]}),$&&n.jsxs(n.Fragment,{children:[!ae&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Display name"}),n.jsx("input",{type:"text",value:c,onChange:M=>u(M.target.value),placeholder:"e.g. Production API key",maxLength:80,name:"w6w-connection-label",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...ye})]}),n.jsx(ga,{auth:$,scopes:!1}),ae?null:J?n.jsxs("p",{className:"w6w-muted w6w-small",children:["You'll be redirected to ",n.jsx("strong",{children:$.displayName??$.key})," to authorize this connection."]}):K?n.jsxs(n.Fragment,{children:[y===null&&!G&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading credentials…"}),!G&&n.jsx(va,{credentials:ne,mode:te,onModeChange:S,selectedId:ee,onSelect:R}),te==="existing"&&ne.length>0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Reusable credential · This account"}),te==="new"&&(y!==null||G)&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"w6w-muted w6w-small",children:["Saved for this app only. One connection ·"," ",G?"Only me":"This account"]}),n.jsx(gn,{fields:V,values:d,onChange:f,enterSubmitProps:ye})]}),P&&P.scopes.length>0&&P.impersonation!=="none"?n.jsx(Xs,{scopes:P.scopes,clientId:H,required:P.impersonation==="required"}):P&&P.scopes.length>0?n.jsx(xa,{scopes:P.scopes}):null,C.length>0&&n.jsx(gn,{fields:C,values:j,onChange:N,enterSubmitProps:ye})]}):n.jsx(gn,{fields:V,values:d,onChange:f,enterSubmitProps:ye})]}),(U||z)&&n.jsx(Bu,{open:F,onToggle:()=>E(M=>!M),owner:U?{value:k,onChange:_}:void 0,keepConnected:z?{value:q,onChange:O}:void 0}),p&&n.jsx("div",{className:"w6w-result w6w-error",children:p})]})}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:we,onClick:ge,children:m?ae?"Saving…":J?"Waiting for authorization…":"Saving…":ae?"Use this":J?`Sign in with ${($==null?void 0:$.displayName)??($==null?void 0:$.key)??"provider"}`:"Save connection"})]})]})}const qu=[{value:"account",label:"This account",hint:"Everyone authorized in the account can use it."},{value:"user",label:"Only me",hint:"Only you can use it. Others in the account cannot."}];function Bu({open:e,onToggle:t,owner:s,keepConnected:o}){const r=[(s==null?void 0:s.value)==="user"?"Only me":null,o&&!o.value?"Not kept connected":null].filter(Boolean);return n.jsxs("div",{className:"w6w-advanced","data-testid":"connection-advanced",children:[n.jsxs("button",{type:"button",className:"w6w-advanced-toggle","aria-expanded":e,"aria-controls":"w6w-connection-advanced-panel",onClick:t,children:["Advanced",!e&&r.length>0&&n.jsxs("span",{className:"w6w-muted",children:[" · ",r.join(" · ")]})]}),e&&n.jsxs("div",{id:"w6w-connection-advanced-panel",className:"w6w-advanced-panel",children:[s&&n.jsxs("div",{className:"w6w-advanced-group",role:"radiogroup","aria-label":"Who can use it",children:[n.jsx("span",{className:"w6w-advanced-label",children:"Who can use it"}),qu.map(a=>n.jsxs("label",{className:"w6w-radio",children:[n.jsx("input",{type:"radio",name:"w6w-connection-owner",value:a.value,checked:s.value===a.value,onChange:()=>s.onChange(a.value)}),n.jsxs("span",{children:[n.jsx("strong",{children:a.label}),n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ",a.hint]})]})]},a.value))]}),o&&n.jsxs("label",{className:"w6w-checkbox",children:[n.jsx("input",{type:"checkbox",name:"w6w-connection-keepalive",checked:o.value,onChange:a=>o.onChange(a.target.checked)}),n.jsxs("span",{children:[n.jsx("strong",{children:"Keep connected"}),n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","Refresh the token automatically, even when nothing uses this connection."]})]})]})]})]})}const Uu=Ca,Lt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Qs=[["is-true","is true"],["is-false","is false"],["has-value","has a value"],["is-empty","is empty"],["===","equals"],["!==","does not equal"],[">","greater than"],[">=","at least"],["<","less than"],["<=","at most"],["in","in"],["includes","includes value"],["include-any","includes any of (list)"],["include-all","includes all of (list)"]],fn={"has-value":"True when the field holds something: not missing, null, empty text, an empty list, 0 or false.","is-empty":"True when the field is missing, null, empty text or an empty list (0 and false count as empty too).",in:"The right array contains the left value.",includes:"Check whether a list contains one value, or text contains a substring.","include-any":"Compare two lists for any shared value. For one value on the right, use includes value.","include-all":"Compare two lists: every value in the right list must be in the left list."},Aa=new Set(Qs.map(([e])=>e)),Ea=new Set(["is-true","is-false","has-value","is-empty"]),Vu=new Set(["and","or","xor","!","!!","==","!=",...Aa]);function dr(e){if(!Lt(e))return!0;const t=Object.keys(e);return!(t.length===1&&Vu.has(t[0]))}function pr(e){return Ea.has(e)}const fr={...Object.fromEntries(Qs),"==":"equals","!=":"does not equal",in:"is in"};function Hu(e){return e.startsWith("not:")?`Not (${fr[e.slice(4)]??e.slice(4)})`:fr[e]??e}const Ta=[["and","All of (AND)"],["or","Any of (OR)"],["xor","Exactly one of (XOR)"]],Oa=Object.fromEntries(Ta);function Ju(e){return Oa[e]??e}function eo(e,t=!0){if(!Lt(e))return;const s=Object.entries(e);if(s.length!==1)return;const[o,r]=s[0];if(o==="!!"&&Array.isArray(r)&&r.length===1&&dr(r[0]))return{left:r[0],operator:"has-value",right:!0};if(o==="!"&&Array.isArray(r)&&r.length===1){const a=eo(r[0],!1);return a?t&&!a.negated?{...a,negated:!0}:void 0:dr(r[0])?{left:r[0],operator:"is-empty",right:!0}:void 0}if(!(!Aa.has(o)||!Array.isArray(r)||r.length!==2)){if(o==="==="&&typeof r[1]=="boolean")return{left:r[0],operator:r[1]?"is-true":"is-false",right:r[1]};if(!Ea.has(o))return{left:r[0],operator:o,right:r[1]}}}function zu(e){if(!(!Lt(e)||Object.keys(e).length!==1))return eo(e.$expr)}function Ku(e){const t=zu(e);if(t)return{combinator:"and",rows:[t]};if(!Lt(e)||Object.keys(e).length!==1||!Lt(e.$expr))return;const s=Object.entries(e.$expr);if(s.length!==1)return;const[o,r]=s[0];if(!Object.hasOwn(Oa,o)||!Array.isArray(r)||r.length===0)return;const a=r.map(i=>eo(i));if(!a.some(i=>i===void 0))return{combinator:o,rows:a}}function hr(e){const t=e.rows.filter(s=>s.left!=="").map(s=>{const o=s.operator==="is-true"||s.operator==="is-false"?{"===":[s.left,s.operator==="is-true"]}:s.operator==="has-value"?{"!!":[s.left]}:s.operator==="is-empty"?{"!":[s.left]}:{[s.operator]:[s.left,s.right]};return s.negated?{"!":[o]}:o});return t.length===0?!1:{$expr:t.length===1?t[0]:{[e.combinator]:t}}}function vs(e){if(typeof e=="string")try{const s=JSON.parse(e);if(s===null||Array.isArray(s)||["string","number","boolean"].includes(typeof s))return s}catch{}const t=typeof e=="string"?Dn(e):et(e)?e.parts:null;if(t){const s=t.map(o=>o.kind==="expr"?o.expr:o.kind==="var"?{var:o.ref}:o.kind==="secret"?{var:`secrets.${o.ref}`}:o.value??"");return s.length===1?s[0]:{cat:s}}return e}function mr(e){return typeof e=="string"?vs(e)===e?e:JSON.stringify(e):Lt(e)?Object.keys(e).length===1&&typeof e.var=="string"?ie.serializeTemplate([{kind:"var",ref:e.var}]):ie.serializeTemplate([{kind:"expr",expr:e}]):JSON.stringify(e)??""}const Ra={left:"",operator:"is-true",right:!0},wr={combinator:"and",rows:[Ra]},Gu=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Bn({values:e,onChange:t,readOnly:s,purpose:o="if"}){const r=tt(),a=e.condition===void 0?!0:e.condition,i=Ku(a),[l,c]=b.useState(!1),[u,d]=b.useState(i??wr),f=b.useRef(0),[p,w]=b.useState(()=>u.rows.map(()=>f.current++)),m=i!==void 0||typeof a=="boolean",h=Gu(hr(u),a)?u:i??wr,y=h.rows.map((j,N)=>p[N]??-1-N),g=(j,N=y)=>{d(j),w(N),t({...e,condition:hr(j)})},x=(j,N)=>g({...h,rows:h.rows.map((k,_)=>_===j?{...k,...N}:k)}),S=()=>g({...h,rows:[...h.rows,Ra]},[...y,f.current++]),A=j=>g({...h,rows:h.rows.filter((N,k)=>k!==j)},y.filter((N,k)=>k!==j)),R=h.rows.length>1;return n.jsxs("div",{className:"w6w-condition-editor",children:[l||!m?n.jsx(qe,{params:[{key:"condition",label:"Condition",type:"json",required:!0}],values:e,onChange:t,readOnly:s}):n.jsxs("div",{className:"w6w-condition-rows",children:[R&&n.jsx("select",{className:"w6w-condition-comparison w6w-condition-combinator","aria-label":"Combine conditions",disabled:s,value:h.combinator,onChange:j=>g({...h,combinator:j.target.value}),children:Ta.map(([j,N])=>n.jsx("option",{value:j,children:N},j))}),h.rows.map((j,N)=>{const k=pr(j.operator);return n.jsxs("div",{className:`w6w-condition-row${R?" w6w-condition-row-removable":""}${k?" w6w-condition-row-boolean":""}`,children:[n.jsxs("label",{className:"w6w-condition-negate",title:"Reverse this condition's result",children:[n.jsx("input",{type:"checkbox","aria-label":`Negate condition ${N+1}`,checked:j.negated??!1,disabled:s,onChange:_=>x(N,{negated:_.target.checked})}),"Not"]}),n.jsx(en,{value:mr(j.left),"aria-label":"Condition field",placeholder:"Field or expression",readOnly:s,onChange:_=>x(N,{left:vs(_)})}),n.jsx("select",{className:"w6w-condition-comparison","aria-label":"Condition comparison",title:fn[j.operator],disabled:s,value:j.operator,onChange:_=>x(N,{operator:_.target.value,right:_.target.value==="is-true"?!0:_.target.value==="is-false"?!1:pr(_.target.value)?!0:k?"":j.right}),children:Qs.map(([_,q])=>n.jsx("option",{value:_,title:fn[_],children:q},_))}),!k&&n.jsx(en,{value:mr(j.right),"aria-label":"Condition value",placeholder:"Value or expression",readOnly:s,onChange:_=>x(N,{right:vs(_)})}),R&&!s&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-condition-remove",title:"Remove condition","aria-label":`Remove condition ${N+1}`,onClick:()=>A(N),children:n.jsx(le.Icon,{name:"trash",size:14})})]},y[N])}),!s&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-condition-add",onClick:S,children:"+ Add condition"}),n.jsx("p",{className:"w6w-muted w6w-small",children:"Not reverses a condition. Type true or false without quotes for booleans; use quotes for text."}),[...new Set(h.rows.map(j=>j.operator))].map(j=>fn[j]?n.jsx("p",{className:"w6w-muted w6w-small",children:fn[j]},j):null)]}),m&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-condition-mode",title:l?"Use comparison fields":"Edit condition expression","aria-label":l?"Use comparison fields":"Edit condition expression",onClick:()=>c(!l),children:n.jsx(le.Icon,{name:l?"form":"code",size:14})}),o!=="router"&&n.jsx("p",{className:"w6w-muted w6w-small",children:o==="stop"?"End the workflow when this condition is true.":r.loop?"When false, skip the remaining steps for this item.":"Continue when this condition is true."})]})}const Yu={step:"Re-run this step if it fails, up to N attempts.",function:"Re-run this function call if it fails, up to N attempts.",endpoint:"Re-run this endpoint call if it fails, up to N attempts.",workflow:"Re-run the whole workflow run if it fails, up to N attempts."};function Ia({value:e,onChange:t,readOnly:s,target:o="step"}){const r=!!e,a=(e==null?void 0:e.maxAttempts)??3,i=(e==null?void 0:e.delayMs)??1e3,l=(e==null?void 0:e.backoff)??"fixed",c=u=>t({maxAttempts:a,delayMs:i,backoff:l,...e,...u});return n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[n.jsx("input",{type:"checkbox",checked:r,disabled:s,onChange:u=>t(u.target.checked?{maxAttempts:a,delayMs:i,backoff:l}:void 0)})," ","Retry on failure"]}),n.jsx("span",{className:"w6w-hint",children:Yu[o]})]}),r&&n.jsxs("div",{className:"w6w-field-row",children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Attempts"}),n.jsx("input",{type:"number",min:1,value:a,readOnly:s,onChange:u=>c({maxAttempts:Math.max(1,Number(u.target.value)||1)})})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Delay (ms)"}),n.jsx("input",{type:"number",min:0,value:i,readOnly:s,onChange:u=>c({delayMs:Math.max(0,Number(u.target.value)||0)})})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Backoff"}),n.jsxs("select",{value:l,disabled:s,onChange:u=>c({backoff:u.target.value}),children:[n.jsx("option",{value:"fixed",children:"Fixed"}),n.jsx("option",{value:"exponential",children:"Exponential"})]})]})]})]})}function $a({config:e,onChange:t,readOnly:s,hasGraph:o=!0,failureHandling:r=!0,retryControls:a=!0,reroute:i}){const l=e.onError??"fail";return n.jsxs("div",{className:"w6w-stack",children:[r&&n.jsxs(n.Fragment,{children:[a&&n.jsx(Ia,{value:e.retry,onChange:c=>t({...e,retry:c}),readOnly:s}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"On error"}),n.jsxs("select",{value:l,disabled:s,onChange:c=>{const u=c.target.value;t({...e,onError:u==="fail"?void 0:u})},children:[n.jsx("option",{value:"fail",children:"Stop the run (default)"}),n.jsx("option",{value:"continue",children:"Continue to the next step"}),o&&n.jsx("option",{value:"continue-record",children:"Continue to the next step & record the error"})]}),o?n.jsxs("span",{className:"w6w-muted w6w-small",children:["Retries run first: this policy is reached only once this step's retry attempts (if any) are exhausted — a run that succeeds on a later attempt continues down the normal path instead. Once reached, ",n.jsx("strong",{children:"Continue"})," and"," ",n.jsx("strong",{children:"Continue & record the error"})," both carry on down this step's ordinary outgoing edges despite the failure. If this step has an outgoing"," ",n.jsx("strong",{children:"error"})," edge on the canvas, that edge decides what happens instead and this policy is not consulted — drawn by dragging from the step's error exit port."]}):n.jsxs("span",{className:"w6w-muted w6w-small",children:["Retries run first: this policy (and reroute, below) is only reached once this step's retry attempts (if any) are exhausted — a run that succeeds on a later attempt continues normally. This step has no canvas of its own, so it can't carry an error edge. Set a ",n.jsx("strong",{children:"reroute"})," target below to send a failure somewhere else instead of stopping."]})]})]}),i&&n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Reroute on failure"}),n.jsxs("div",{className:"w6w-field-row",children:[i.picker,i.value&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:s,onClick:()=>i.onChange(void 0),children:"Clear"})]}),n.jsx("span",{className:"w6w-hint",children:"Invoked once, after retry is exhausted, if this step still fails; its output becomes this step's output."})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Notes"}),n.jsx("textarea",{rows:3,value:e.notes??"",readOnly:s,placeholder:"A short description — shown under this step on the canvas. Not executed.",onChange:c=>t({...e,notes:c.target.value||void 0})})]})]})}function Un(e){return e.$merge!==void 0}function _a(e){const t=e.$merge;if(t===void 0)return e;if(!(ut(t)||et(t)||Vs(t)||typeof t=="string"&&Dn(t)))return t&&typeof t=="object"&&!Array.isArray(t)&&!lt(t)&&!("$merge"in t)?{...e,...t}:null}function Pa(e,t,s=[]){if(et(e)||lt(e)||Us(e)||Vs(e)||e===null||typeof e!="object")return Zt(e,t);const o=r=>Pa(r,t);return Array.isArray(e)?e.map(o):Object.fromEntries(Object.entries(e).map(([r,a])=>[r,s.includes(r)?a:o(a)]))}function to({values:e,onChange:t,readOnly:s}){return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Form values are applied first. This object adds or replaces top-level fields, including nested objects. Use ƒx to reuse an object from state or a previous step. You can still edit the form."}),n.jsx(qe,{params:[{key:"$merge",label:"JSON customization",type:"json",required:!0,default:{},whole:!0}],values:e,onChange:t,readOnly:s}),_a(e)===null&&n.jsx("p",{role:"alert",className:"w6w-field-error",children:"JSON customization must be an object or an expression that returns an object."}),!s&&Un(e)&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>{const{$merge:o,...r}=e;t(r)},children:"Remove JSON customization"})]})}function no(e){const{label:t,onClick:s,disabled:o,className:r,...a}=e;return n.jsx(Mn,{label:t,onClick:s,disabled:o,className:r,danger:!0,icon:"delete","data-testid":a["data-testid"]})}function Fa({values:e,onChange:t,readOnly:s}){const o=Array.isArray(e.routes)?e.routes:An(Ze,"route").routes,r=o.filter(g=>!g.default),[a,i]=b.useState(null),[l,c]=b.useState(null),[u,d]=b.useState(null),[f,p]=b.useState(""),w=g=>t({...e,routes:[...g,...o.filter(x=>x.default)]}),m=(g,x)=>w(r.map(S=>S.id===g?{...S,...x}:S)),h=(g,x)=>{const S=r.findIndex(j=>j.id===g);if(S<0||x<0||x>=r.length||S===x)return;const A=[...r],[R]=A.splice(S,1);A.splice(x,0,R),w(A)},y=g=>{f.trim()&&m(g.id,{label:f.trim()}),d(null)};return n.jsxs("div",{className:"w6w-router-editor",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"First match wins. Drag routes to change their order."}),n.jsx("div",{className:"w6w-router-routes",children:r.map((g,x)=>n.jsxs("div",{className:`w6w-router-route${a===g.id?" is-dragging":""}${l===g.id?" is-drop-target":""}`,"data-route-id":g.id,onDragOver:S=>{s||!a||a===g.id||(S.preventDefault(),S.dataTransfer.dropEffect="move",c(g.id))},onDrop:S=>{S.preventDefault(),!s&&a&&h(a,x),i(null),c(null)},children:[n.jsxs("div",{className:"w6w-router-route-heading",children:[n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-router-grip",draggable:!s,disabled:s,"aria-label":`Reorder ${g.label||g.id}`,title:"Drag to reorder · arrow keys to move",onDragStart:S=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",g.id);const A=S.currentTarget.closest(".w6w-router-route");A&&S.dataTransfer.setDragImage(A,16,16),i(g.id)},onDragEnd:()=>{i(null),c(null)},onKeyDown:S=>{S.key!=="ArrowUp"&&S.key!=="ArrowDown"||(S.preventDefault(),h(g.id,x+(S.key==="ArrowUp"?-1:1)))},children:n.jsx(le.Icon,{name:"grip",size:14})}),n.jsx("span",{className:"w6w-step-rename",children:u===g.id&&!s?n.jsx("input",{autoFocus:!0,"aria-label":"Route name",value:f,onChange:S=>p(S.target.value),onBlur:()=>y(g),onKeyDown:S=>{S.key==="Enter"&&y(g),S.key==="Escape"&&d(null)}}):n.jsxs("button",{type:"button",className:"w6w-router-route-name",disabled:s,"aria-label":`Rename ${g.label||g.id}`,onClick:()=>{p(g.label||g.id),d(g.id)},children:[g.label||g.id,!s&&n.jsx(le.Icon,{name:"edit",size:12})]})}),n.jsx(no,{label:`Remove ${g.label||g.id}`,disabled:s,onClick:()=>w(r.filter(S=>S.id!==g.id))})]}),n.jsx(Bn,{values:{condition:g.condition??!1},onChange:S=>m(g.id,{condition:S.condition}),readOnly:s,purpose:"router"})]},g.id))}),n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-router-add",disabled:s,onClick:()=>{let g=1;for(;o.some(x=>x.id===`route_${g}`);)g++;w([...r,{id:`route_${g}`,label:`Route ${g}`,condition:!1}])},children:[n.jsx("span",{"aria-hidden":"true",children:"+"})," Add route"]})]})}function La({value:e,onCommit:t,readOnly:s}){const[o,r]=b.useState(!1),[a,i]=b.useState(e),[l,c]=b.useState(null),u=()=>{const d=a.trim(),f=d&&d!==e?t(d):null;if(f){c(f);return}c(null),r(!1)};return n.jsxs("span",{className:"w6w-step-rename",children:[o&&!s?n.jsx("input",{autoFocus:!0,"aria-label":"Node name",value:a,onChange:d=>{i(d.target.value),c(null)},onBlur:u,onKeyDown:d=>{d.key==="Enter"&&u(),d.key==="Escape"&&(i(e),c(null),r(!1))}}):n.jsxs(n.Fragment,{children:[n.jsx("code",{children:e}),!s&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-btn-sm",title:"Rename node","aria-label":"Rename node",onClick:()=>{i(e),r(!0)},children:n.jsx(le.Icon,{name:"edit",size:15})})]}),l&&n.jsx("span",{className:"w6w-hint",role:"alert",style:{color:"var(--w6w-danger)"},children:l})]})}function Da({values:e,onChange:t,readOnly:s}){const o=e.condition!==void 0&&e.condition!==!0;return n.jsxs("div",{className:"w6w-stack",children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Stop when"}),n.jsxs("select",{"aria-label":"Stop when",disabled:s,value:o?"condition":"always",onChange:r=>{const a=r.target.value==="condition";t({...e,condition:!a})},children:[n.jsx("option",{value:"always",children:"Always"}),n.jsx("option",{value:"condition",children:"A condition matches"})]})]}),o?n.jsx(Bn,{values:e,onChange:t,readOnly:s,purpose:"stop"}):n.jsx("p",{className:"w6w-muted w6w-small",children:"End the whole workflow successfully here, including any remaining loop iterations."})]})}const Xu=["props","code"];function Zu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ma({params:e,values:t,onChange:s,onValidityChange:o,readOnly:r,initialView:a="props"}){const i=e.length>0,[l,c]=b.useState(a),u=!i||l==="code",[d,f]=b.useState(()=>br(t)),[p,w]=b.useState(!0),m=b.useRef(!0),h=x=>{x!==m.current&&(m.current=x,w(x),o==null||o(x))},y=x=>{x==="code"&&f(br(t)),h(!0),c(x)},g=i?"Values (JSON)":"Payload";return n.jsxs("div",{className:"w6w-stack",children:[i&&n.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:n.jsx(Jn,{view:l,views:[...Xu],onChange:x=>y(x)})}),u?n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:g}),n.jsx(Xe,{value:d,onChange:f,readOnly:r,minHeight:"140px","aria-label":`${g} JSON`,onValidChange:x=>{const S=Zu(x);h(S),S&&s(x)},onValidityChange:x=>{x.valid||h(!1)}}),!p&&n.jsx("span",{className:"w6w-hint",children:"This draft isn’t a JSON object yet — the collected values are unchanged until it is."})]}):n.jsx(qe,{params:e,values:t,onChange:s,readOnly:r})]})}function br(e){return JSON.stringify(e??{},null,2)}function Qu(e){return e===null||typeof e!="object"||Array.isArray(e)?null:e}function Wa({app:e,trigger:t,onUse:s}){const o=Ce(),[r,a]=b.useState(null);return b.useEffect(()=>{var l;let i=!1;return a(null),(l=o.getAppTriggers)==null||l.call(o,e).then(c=>{var u;i||a(Qu((u=c.find(d=>d.key===t))==null?void 0:u.sample))}).catch(()=>{}),()=>{i=!0}},[o,e,t]),r?n.jsx("div",{children:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"use-trigger-sample",onClick:()=>s(r),children:"Use sample event"})}):null}const ed=new Set(["http:","https:","mailto:"]);function td(e){try{return ed.has(new URL(e).protocol)?e:""}catch{return""}}const nd=["img"];function sd({node:e,href:t,children:s,...o}){return n.jsx("a",{...o,href:t||void 0,target:"_blank",rel:"noopener noreferrer nofollow",children:s})}function qa(e){const t=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{frontmatter:t[1],body:e.slice(t[0].length)}:{frontmatter:null,body:e}}function od({yaml:e}){return n.jsxs("details",{className:"w6w-md-frontmatter","data-testid":"md-frontmatter",children:[n.jsx("summary",{children:"Frontmatter"}),n.jsx("pre",{children:n.jsx("code",{children:e})})]})}function so({content:e,className:t,copyable:s=!0}){const{frontmatter:o,body:r}=qa(e),a=n.jsxs("div",{className:t,children:[(o==null?void 0:o.trim())&&n.jsx(od,{yaml:o}),n.jsx(Ji,{skipHtml:!0,urlTransform:td,disallowedElements:nd,unwrapDisallowed:!0,components:{a:sd},children:r})]});return s?n.jsx(le.Copyable,{value:e,label:"Copy Markdown",className:"w6w-copyable--document",children:a}):a}const gr="w6w-data-table-actions";function rd(e,t){return e.render?e.render(t):String(t[e.key]??"")}function Ba(e){const{columns:t,rows:s,rowKey:o,onRowClick:r,getRowHref:a,empty:i,loading:l,className:c,testId:u}=e;return s.length===0&&!l&&i!==void 0&&i!==null?n.jsx(n.Fragment,{children:i}):n.jsx("div",{className:"w6w-data-table-frame",children:n.jsxs("table",{className:c?`w6w-data-table ${c}`:"w6w-data-table","data-testid":u,"aria-busy":l?!0:void 0,children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(d=>n.jsx("th",{className:d.actions?gr:void 0,style:{width:d.width,textAlign:d.align},scope:"col",children:d.header},d.key))})}),n.jsx("tbody",{children:s.map(d=>{var p;const f=a==null?void 0:a(d);return n.jsx("tr",{"data-testid":(p=e.rowTestId)==null?void 0:p.call(e,d),className:r?"w6w-data-table-row-clickable":void 0,onClick:r?w=>r(d,w):void 0,children:t.map(w=>{const m=rd(w,d);return n.jsx("td",{className:w.actions?gr:void 0,style:{textAlign:w.align},children:f!==void 0&&w.link!==!1?n.jsx("a",{className:"w6w-data-table-link",href:f,children:m}):w.actions&&m!==null&&m!==void 0?n.jsx("div",{className:"w6w-data-table-actions-row",children:m}):m},w.key)})},o(d))})})]})})}const Ua="default-src 'none'; style-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'";function Va(e){return`<!doctype html><meta http-equiv="Content-Security-Policy" content="${Ua}">${e}`}function Ha({html:e}){return n.jsx("iframe",{title:"HTML preview",className:"w6w-html-preview",sandbox:"",referrerPolicy:"no-referrer",srcDoc:Va(e)})}function Ja(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":"null"}function ad(e){return Ja(e)==="string"?JSON.stringify(e):String(e)}function id(e){return typeof e=="object"&&e!==null}function ld(e,t){return`${t} ${e?"item":"key"}${t===1?"":"s"}`}function cd({value:e,expandDepth:t=2}){return n.jsx(za,{label:void 0,value:e,depth:0,expandDepth:t})}function za(e){const{label:t,value:s,depth:o,expandDepth:r}=e,a=id(s),i=Array.isArray(s),l=a?i?s.map((u,d)=>[d,u]):Object.entries(s):[],c=t===void 0?null:n.jsx("span",{className:"w6w-json-key",children:t});return a&&l.length>0?n.jsxs("details",{className:"w6w-json-node",open:o<r,children:[n.jsxs("summary",{children:[c,i?"[…]":"{…}"," ",n.jsx("span",{className:"w6w-json-count",children:ld(i,l.length)})]}),n.jsx("div",{className:"w6w-json-children",children:l.map(([u,d])=>n.jsx(za,{label:u,value:d,depth:o+1,expandDepth:r},String(u)))})]}):n.jsxs("div",{className:"w6w-json-leaf",children:[c,c===null?null:": ",n.jsx("span",{className:`w6w-json-${a?"null":Ja(s)}`,children:a?i?"[]":"{}":ad(s)})]})}const js=262144,ud=/^#{1,6}\s+\S/,dd=/^```/,pd=/^\s*(?:[-*+]|\d+\.)\s+\S/,fd=/\[[^\]\n]+\]\(https?:\/\/[^)\s]+\)/;function Ka(e){if(e===void 0)return{format:"text",text:""};if(typeof e!="string")return{format:"json",data:e};const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const o=JSON.parse(t);if(o!==null&&typeof o=="object")return{format:"json",data:o}}catch{}if(/^<!doctype html/i.test(t)||/^<html[\s>]/i.test(t))return{format:"html",text:e};if(t.startsWith("<")&&t.endsWith(">"))return{format:"xml",text:e};const s=t.split(`
21
+ `);return s.some(o=>ud.test(o)||dd.test(o))||s.filter(o=>pd.test(o)).length>=2||fd.test(t)?{format:"markdown",text:e}:{format:"text",text:e}}function Ga(e){return e.format==="json"?JSON.stringify(e.data,null,2)??"":e.text}function yr(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function hd(e){if(!yr(e))return!1;const t=Object.keys(e);if(t.length!==2||!t.includes("columns")||!t.includes("rows"))return!1;const{columns:s,rows:o}=e;return Array.isArray(s)&&s.every(r=>typeof r=="string")&&Array.isArray(o)&&o.every(yr)}function md(e){try{return JSON.stringify(e).length}catch{return Number.POSITIVE_INFINITY}}function wd(e){return e===null?n.jsx("span",{className:"w6w-muted w6w-result-viewer-null",children:"null"}):typeof e=="object"?JSON.stringify(e):String(e)}const bd=65536;function ns(e,t){return e.length>bd?n.jsx("pre",{className:"w6w-result-viewer-text",children:e}):n.jsx(le.CodeBlock,{code:e,language:t,copyable:!1,wrap:!0})}function Te(e){const{value:t,format:s="auto",maxHeight:o=320,className:r}=e,a=b.useMemo(()=>s==="json"?{format:"json",data:t}:Ka(t),[t,s]),[i,l]=b.useState("rendered"),[c,u]=b.useState("table"),[d,f]=b.useState(2),[p,w]=b.useState(0),m=a.format==="json"?"":a.text,h=a.format==="html"||a.format==="markdown",y=h&&m.length>js,g=b.useMemo(()=>a.format!=="json"||!hd(a.data)?null:{table:a.data,tooLarge:md(a.data)>js},[a]),x=g!==null&&!g.tooLarge&&c==="table",S=b.useMemo(()=>((g==null?void 0:g.table.columns)??[]).map((k,_)=>({key:`${_}:${k}`,header:k,render:({row:q})=>wd(q[k])})),[g]),A=b.useMemo(()=>((g==null?void 0:g.table.rows)??[]).map((k,_)=>({i:_,row:k})),[g]),R=b.useMemo(()=>{try{return Ga(a)}catch{return typeof t=="string"?t:String(t)}},[a,t]);let j;if(a.format==="json"){const k=n.jsx(cd,{value:a.data,expandDepth:d},p);x?j=n.jsx(Ba,{columns:S,rows:A,rowKey:_=>String(_.i),className:"w6w-result-viewer-table",testId:"result-viewer-table"}):g!=null&&g.tooLarge?j=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small w6w-result-viewer-note",children:"Too large to show as a table — showing JSON."}),k]}):j=k}else if(a.format==="xml")j=ns(a.text,"markup");else if(a.format==="text")j=n.jsx("pre",{className:"w6w-result-viewer-text",children:a.text});else{const k=a.format==="html"?"markup":"markdown";y?j=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small w6w-result-viewer-note",children:"Too large to render — showing source."}),ns(a.text,k)]}):i==="source"?j=ns(a.text,k):a.format==="html"?j=n.jsx(Ha,{html:a.text}):j=n.jsx(so,{content:a.text,copyable:!1})}let N=null;if(a.format==="json"){const k=g!==null&&!g.tooLarge?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-ghost${c==="table"?" active":""}`,"data-mode":"table","aria-pressed":c==="table",onClick:()=>u("table"),children:"Table"}),n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-ghost${c==="json"?" active":""}`,"data-mode":"json","aria-pressed":c==="json",onClick:()=>u("json"),children:"JSON"})]}):null;N=n.jsxs("div",{className:"w6w-result-viewer-bar",children:[k,x?null:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{f(Number.POSITIVE_INFINITY),w(_=>_+1)},children:"Expand all"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{f(1),w(_=>_+1)},children:"Collapse all"})]})]})}else h&&!y&&(N=n.jsxs("div",{className:"w6w-result-viewer-bar",children:[n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-ghost${i==="rendered"?" active":""}`,"data-mode":"rendered","aria-pressed":i==="rendered",onClick:()=>l("rendered"),children:"Rendered"}),n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-ghost${i==="source"?" active":""}`,"data-mode":"source","aria-pressed":i==="source",onClick:()=>l("source"),children:"Source"})]}));return n.jsxs("div",{className:["w6w-result-viewer",r??""].filter(Boolean).join(" "),"data-format":a.format,children:[N,n.jsx(le.Copyable,{value:R,label:"Copy result",className:"w6w-copyable--overlay",children:n.jsx("div",{className:"w6w-result-viewer-body",style:{maxHeight:o,overflow:"auto"},children:j})})]})}function oo(e,t){const s=e.filter(r=>r.appId===at),o=r=>{var a;return typeof((a=r.params)==null?void 0:a.node)=="string"?r.params.node:r.nodeId??null};return s.find(r=>o(r)===t)??s.find(r=>!o(r))??null}function Ya(e,t){const s=e.filter(o=>o.appId===He);return s.find(o=>o.nodeId===t)??s.find(o=>!o.nodeId)??s[0]??null}const gd=/auth|token|secret|passw|cookie|api[-_]?key|signature|session/i,yd="••••••";function xd(e){const t={};for(const[s,o]of Object.entries(e))t[s]=gd.test(s)?yd:o;return t}const vd=20;function jd({workflowId:e,stepId:t,stepWith:s,readOnly:o,onUse:r,using:a,appId:i=He}){const l=Ce(),c=i===at,u=c?"form":"webhook",[d,f]=b.useState(void 0),[p,w]=b.useState(!1),[m,h]=b.useState({phase:"idle"}),[y,g]=b.useState(()=>Date.now()),x=b.useRef(null);b.useEffect(()=>{const _=l.listSubscriptionsForWorkflow;if(!_)return;let q=!1;return _(e).then(O=>!q&&f(c?oo(O,t):Ya(O,t))).catch(O=>!q&&h({phase:"error",message:O.message})),()=>{q=!0}},[l,e,t,c]);const S=b.useCallback(_=>{var O;const q=x.current;x.current=null,q&&(q.abort.abort(),_&&((O=l.stopWebhookListen)==null||O.call(l,q.subId,q.sessionId).catch(()=>{})))},[l]);b.useEffect(()=>()=>S(!0),[S]),b.useEffect(()=>{if(m.phase!=="waiting")return;const _=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(_)},[m.phase]);const A=()=>{const _=l.createSubscription;if(!_)return;w(!0),_(i,c?"submission":"webhook",c?{workflowId:e,connectionId:null,params:{node:t}}:{workflowId:e,connectionId:null,params:s??{}}).then(O=>f(O)).catch(O=>h({phase:"error",message:O.message})).finally(()=>w(!1))},R=async()=>{var I;const _=l.startWebhookListen,q=l.pollWebhookListen;if(!d||!_||!q)return;S(!0),h({phase:"starting"});let O;try{O=(await _(d.id)).session}catch($){h({phase:"error",message:$.message});return}const F=new AbortController,E={subId:d.id,sessionId:O.id,abort:F};for(x.current=E,g(Date.now()),h({phase:"waiting",session:O});;){let $;try{$=await q(d.id,O.id,{waitSeconds:vd,signal:F.signal})}catch(V){if(x.current!==E)return;x.current=null,h({phase:"error",message:V.message});return}if(x.current!==E)return;if($.status==="captured"&&$.request){x.current=null,h({phase:"captured",session:$,request:$.request});return}if($.status==="expired"){x.current=null,(I=l.stopWebhookListen)==null||I.call(l,d.id,O.id).catch(()=>{}),h({phase:"expired"});return}}},j=()=>{S(!0),h({phase:"idle"})};if(!l.startWebhookListen||!l.pollWebhookListen)return null;const N=(d==null?void 0:d.webhookUrl)??(d==null?void 0:d.formUrl),k=m.phase==="waiting"?Math.max(0,Math.ceil((Date.parse(m.session.expiresAt)-y)/1e3)):0;return n.jsxs("div",{className:"w6w-stack w6w-listen","data-testid":"webhook-listen",children:[d===void 0?n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}):N?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"w6w-listen-url",children:[n.jsx(le.Copyable,{value:N,readOnly:!0,children:n.jsx("input",{type:"text",readOnly:!0,value:N,"aria-label":c?"Form URL":"Webhook URL"})}),c&&n.jsx("a",{className:"w6w-btn w6w-btn-ghost w6w-btn-sm",href:N,target:"_blank",rel:"noreferrer","data-testid":"form-open",children:"Open form"})]}),m.phase==="waiting"||m.phase==="starting"?n.jsxs("div",{className:"w6w-listen-waiting",children:[n.jsx("span",{className:"w6w-listen-pulse","aria-hidden":"true"}),n.jsxs("output",{className:"w6w-small",children:[c?"Waiting for a submission on":"Waiting for a request to"," ",n.jsx("code",{children:N}),"…",m.phase==="waiting"&&n.jsxs("span",{className:"w6w-muted",children:[" ",kd(k)," left"]})]}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:j,children:"Stop"})]}):n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn",disabled:o,onClick:()=>void R(),children:m.phase==="captured"?"Listen again":"Listen for test event"}),m.phase==="idle"&&n.jsx("span",{className:"w6w-muted w6w-small",children:c?"Then open the form and submit it — it works before you publish, and the workflow runs on the test submission.":"Send a request to this URL — it works before you publish, and starts no run."})]})]}):n.jsxs("div",{className:"w6w-stack",children:[n.jsxs("p",{className:"w6w-muted w6w-small",children:["This ",u," has no URL yet. Create one, then listen for a test"," ",c?"submission":"request","."]}),!o&&l.createSubscription&&n.jsx("button",{type:"button",className:"w6w-btn",disabled:p,onClick:A,children:p?"Creating…":`Create ${u} URL`})]}),m.phase==="expired"&&n.jsx("p",{className:"w6w-muted w6w-small",children:c?"No submission arrived in time. Listen again, then submit the form.":"No request arrived in time. Listen again, then send the request."}),m.phase==="error"&&n.jsx("div",{className:"w6w-result w6w-error",children:m.message}),m.phase==="captured"&&c&&n.jsx(Sd,{submission:m.request,receivedAt:m.session.receivedAt,readOnly:o,using:a,onUse:()=>r(m.request),stepId:t}),m.phase==="captured"&&!c&&n.jsx(Nd,{request:m.request,receivedAt:m.session.receivedAt,readOnly:o,using:a,onUse:()=>r(m.request),stepId:t})]})}function kd(e){const t=Math.floor(e/60);return t>0?`${t}:${String(e%60).padStart(2,"0")}`:`${e}s`}function Nd({request:e,receivedAt:t,readOnly:s,using:o,onUse:r,stepId:a}){const i=Object.keys(e.query??{}).length>0;return n.jsxs("div",{className:"w6w-testout w6w-listen-captured","data-testid":"webhook-captured",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Request received",t&&n.jsxs("span",{className:"w6w-muted",children:[" · ",new Date(t).toLocaleTimeString()]})]}),n.jsxs("div",{className:"w6w-small",children:[n.jsx("code",{children:e.method})," ",n.jsx("code",{children:e.path})]}),i&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-testout-label",children:"Query"}),n.jsx(Te,{value:e.query,maxHeight:120})]}),n.jsx("div",{className:"w6w-testout-label",children:"Headers"}),n.jsx(Te,{value:xd(e.headers??{}),maxHeight:160}),n.jsx("div",{className:"w6w-testout-label",children:"Body"}),n.jsx(Te,{value:e.body,maxHeight:240}),!s&&n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn",disabled:o,onClick:r,children:o?"Saving…":"Use as test data"}),n.jsxs("span",{className:"w6w-muted w6w-small",children:["Becomes this trigger's output, so later steps can use"," ",n.jsx("code",{children:`{{ nodes.${a}.output.body… }}`}),"."]})]})]})}function Sd({submission:e,receivedAt:t,readOnly:s,using:o,onUse:r,stepId:a}){var l;const i=(l=e.meta)==null?void 0:l.runId;return n.jsxs("div",{className:"w6w-testout w6w-listen-captured","data-testid":"form-captured",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Submission received",t&&n.jsxs("span",{className:"w6w-muted",children:[" · ",new Date(t).toLocaleTimeString()]})]}),i&&n.jsxs("div",{className:"w6w-small","data-testid":"form-captured-run",children:["The workflow is running on it: ",n.jsx("code",{children:i})]}),n.jsx("div",{className:"w6w-testout-label",children:"Answers"}),n.jsx(Te,{value:e.data??{},maxHeight:240}),!s&&n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn",disabled:o,onClick:r,children:o?"Saving…":"Use as test data"}),n.jsxs("span",{className:"w6w-muted w6w-small",children:["Becomes this trigger's output, so later steps can use"," ",n.jsx("code",{children:`{{ nodes.${a}.output.data… }}`}),"."]})]})]})}function ro(e){return Array.isArray(e)?e:[]}function ao(e){return e==="object"||e==="array"?"json":e==="number"||e==="boolean"||e==="json"?e:"string"}function io(e,t){if(!(t==null||t==="")){if(typeof t=="object")return t;if(e==="number"){const s=Number(t);return Number.isFinite(s)?s:void 0}if(e==="boolean")return t===!0||t==="true";if(e==="json")try{return JSON.parse(String(t))}catch{return}return String(t)}}function lo(e){return e.filter(t=>typeof t.key=="string"&&t.key.trim()!=="").map(t=>({key:t.key,label:t.key,type:ao(t.type),required:!!t.required}))}function ks(e){const t={};for(const s of e){if(typeof s.key!="string"||s.key.trim()==="")continue;const o=io(s.type,s.default);o!==void 0&&(t[s.key]=o)}return t}function Xa(e,t){const s=(e??[]).find(r=>r&&r.nodeId===t);if(!s)return;const o=s.input;return o&&typeof o=="object"&&!Array.isArray(o)?o:{}}function Cd(e){return et(e)||typeof e=="string"&&e.includes("{{")}function co(e,t=[]){const s=new Set(t.filter(r=>r.type==="secret").map(r=>r.key)),o={};for(const[r,a]of Object.entries(e))a===void 0||lt(a)||s.has(r)&&!Cd(a)||(o[r]=a);return o}const Ns=new Set;function Za(e){const t=e.then(()=>{},()=>{});return Ns.add(t),t.then(()=>Ns.delete(t)),e}async function Qa(){await Promise.all([...Ns])}function ei(e,t){const s=Ce(),o=typeof s.loadTestInputs=="function"&&!!e&&!!t,[r,a]=b.useState(!o),[i,l]=b.useState(void 0);b.useEffect(()=>{if(!o||!e||!t||!s.loadTestInputs){a(!0);return}let f=!1;return a(!1),Qa().then(()=>{var p;return((p=s.loadTestInputs)==null?void 0:p.call(s,e))??[]}).then(p=>{f||(l(Xa(p,t)),a(!0))}).catch(()=>{f||a(!0)}),()=>{f=!0}},[s,o,e,t]);const c=b.useCallback(f=>{l(f),!(!e||!t||typeof s.saveTestInput!="function")&&Za(s.saveTestInput(e,t,f)).catch(p=>{console.error("test input save failed",p)})},[s,e,t]),u=b.useCallback((f,p)=>c(co(f,p)),[c]),d=b.useCallback(()=>c({}),[c]);return{loaded:r,supported:o,input:i,save:u,clear:d}}function ti({onClear:e}){return n.jsxs("p",{className:"w6w-muted w6w-small","data-testid":"last-used-note",children:["last used values ·"," ",n.jsx("button",{type:"button",className:"w6w-linkbtn",onClick:e,children:"Clear"})]})}const Ad=600;function ni({app:e,action:t,fields:s,persist:o,listen:r,appTrigger:a=!1}){const i=Ce(),l=Ms(),c=b.useMemo(()=>ro(s),[s]),u=b.useMemo(()=>lo(c),[c]),d=u.length>0,[f,p]=b.useState(()=>ks(c)),[w,m]=b.useState(null),h=o==null?void 0:o.workflowId,y=o==null?void 0:o.stepId,g=ei(h,y),[x,S]=b.useState(!1),[A,R]=b.useState(!1),[j,N]=b.useState(!h||!y);b.useEffect(()=>{if(!h||!y){N(!0);return}if(!g.loaded)return;if(g.input!==void 0){const z=g.input;Object.keys(z).length>0&&(p(D=>({...D,...z})),S(!0),R(!0)),N(!0);return}let G=!1;return i.listStepTests(h,y).then(z=>{if(G)return;const D=z.length?z[z.length-1]:null;D!=null&&D.with&&(p(te=>({...te,...D.with})),Object.keys(D.with).length>0&&R(!0)),N(!0)}).catch(()=>{G||N(!0)}),()=>{G=!0}},[i,h,y,g.loaded]);const[k,_]=b.useState(0),q=()=>{clearTimeout(F.current),O.current=null,g.clear(),S(!1),p(ks(c)),_(G=>G+1)},O=b.useRef(null),F=b.useRef(void 0),E=b.useRef(()=>{});E.current=()=>{clearTimeout(F.current);const G=O.current;O.current=null,G&&g.save(G,u)},b.useEffect(()=>()=>E.current(),[]);const I=G=>{p(G),!(!h||!y||!j)&&(O.current=G,clearTimeout(F.current),F.current=setTimeout(()=>E.current(),Ad))},[$,V]=b.useState(!0),J=$&&Dt(u,f),P=async G=>{const z=G??f;clearTimeout(F.current),O.current=null,o&&g.save(z,u),m({status:"running"});let D;if(a)D={status:"done",value:z};else try{const te=await i.invokeAction(e,t,{input:z},{project:l});D={status:"done",value:te.value,logs:te.logs}}catch(te){const ee=te;D={status:"error",error:ee.message??String(te),errorCode:ee.code,logs:ee.logs}}if(m(D),o)try{const te=await i.saveStepTest(o.workflowId,o.stepId,{input:o.input,with:z});await i.recordStepTestRun(o.workflowId,o.stepId,{stepTestId:te.id,status:D.status==="done"?"succeeded":"failed",input:o.input,output:D.status==="done"?D.value:void 0,error:D.status==="error"?D.error:void 0})}catch(te){console.error("step test persist failed",te)}},T=w&&w.status!=="running"?w.logs:void 0,Z=G=>{const z={...G};p(z),P(z)},K=r&&o&&n.jsx(jd,{workflowId:o.workflowId,stepId:o.stepId,stepWith:r.stepWith,readOnly:r.readOnly,appId:r.appId,onUse:Z,using:(w==null?void 0:w.status)==="running"});return n.jsxs("div",{className:"w6w-stack",children:[K,K?n.jsxs("details",{className:"w6w-listen-manual","data-testid":"trigger-sample-payload",open:A,onToggle:G=>R(G.currentTarget.open),children:[n.jsx("summary",{className:"w6w-small",children:"Or test with a sample payload"}),ne()]}):ne(),U()]});function ne(){return n.jsxs("div",{className:"w6w-stack",children:[j?n.jsxs(n.Fragment,{children:[x&&n.jsx(ti,{onClear:q}),n.jsx(Ma,{params:u,values:f,onChange:I,onValidityChange:V},k),a?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"w6w-hint",children:"Paste an example event to test with. It becomes this trigger's output, so the steps after it can be tested and their fields picked. ▶ Run on this trigger uses it too. Publish the workflow to receive real events."}),n.jsx(Wa,{app:e,trigger:t,onUse:G=>{I(G),_(z=>z+1)}})]}):!d&&n.jsxs("span",{className:"w6w-hint",children:["This trigger declares no fields — provide a sample payload to test with. It becomes the trigger's output state (",n.jsx("code",{children:"input"}),")."]})]}):n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading saved values…"}),n.jsx("div",{className:"w6w-steptest",children:n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!j||!J||(w==null?void 0:w.status)==="running",onClick:()=>void P(),children:(w==null?void 0:w.status)==="running"?"Running…":"▶ Test run"}),j&&!J&&n.jsx("span",{className:"w6w-muted w6w-small",children:$?"Fill the required fields to test.":"The payload must be a JSON object to test."})]})})]})}function U(){return n.jsxs("div",{className:"w6w-steptest",children:[(w==null?void 0:w.status)==="error"&&n.jsxs("div",{className:"w6w-result w6w-error",children:[w.errorCode&&n.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:n.jsx("code",{children:w.errorCode})}),w.error]}),(w==null?void 0:w.status)==="done"&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Output state (filled values)"}),n.jsx(Te,{value:w.value,maxHeight:220})]}),T&&T.length>0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Console output"}),n.jsx(le.Copyable,{value:T.join(`
22
+ `),label:"Copy console output",children:n.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:T.join(`
23
+ `)})})]})]})}}const Ed=[["s","Seconds"],["m","Minutes"],["h","Hours"],["d","Days"],["w","Weeks"]],Td=/^(?=\d)(?:\d+w)?(?:\d+d)?(?:\d+h)?(?:\d+m)?(?:\d+(?:\.\d+)?s)?$|^P(?:\d+W)?(?:\d+D)?(?:T(?=\d)(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?$/i;function si({values:e,onChange:t,readOnly:s}){const o=e.duration??"1s",r=typeof o=="string"?o.match(/^(\d+(?:\.\d+)?)([smhdw])$/i):null,[a,i]=b.useState("s"),[l,c]=b.useState("text"),[u,d]=b.useState(e.until?"until":"duration"),f=typeof o=="string"&&(!Td.test(o.trim())||/^P$/i.test(o.trim()));return n.jsxs("div",{className:"w6w-params-form",children:[n.jsxs("label",{children:["Wait for",n.jsxs("select",{"aria-label":"Wait for",disabled:s,value:u,onChange:p=>{const w=p.target.value;d(w),t({...e,duration:w==="duration"?"1s":"",until:""})},children:[n.jsx("option",{value:"duration",children:"A duration"}),n.jsx("option",{value:"until",children:"Until a timestamp"})]})]}),u==="until"?n.jsx(qe,{params:[{key:"until",label:"Until",type:"string",hint:"ISO-8601 timestamp, e.g. 2026-10-08T09:00:00Z."}],values:e,onChange:t,readOnly:s}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{children:["Duration input",n.jsxs("select",{"aria-label":"Duration input",disabled:s,value:l,onChange:p=>{r&&i((r==null?void 0:r[2].toLowerCase())??a),c(p.target.value)},children:[n.jsx("option",{value:"text",children:"Shorthand"}),n.jsx("option",{value:"value",disabled:!r,children:"Value and unit"})]})]}),l==="value"?n.jsxs("div",{className:"w6w-field-row",children:[n.jsxs("label",{children:["Value",n.jsx("input",{"aria-label":"Duration value",type:"number",min:"0",step:((r==null?void 0:r[2].toLowerCase())??a)==="s"?"any":"1",disabled:s,value:(r==null?void 0:r[1])??"",onChange:p=>t({...e,duration:`${p.target.value}${(r==null?void 0:r[2].toLowerCase())??a}`})})]}),n.jsxs("label",{children:["Unit",n.jsx("select",{"aria-label":"Duration unit",disabled:s,value:(r==null?void 0:r[2].toLowerCase())??a,onChange:p=>{i(p.target.value),t({...e,duration:`${(r==null?void 0:r[1])??""}${p.target.value}`})},children:Ed.map(([p,w])=>n.jsx("option",{value:p,children:w},p))})]})]}):n.jsx(qe,{params:[{key:"duration",label:"Duration",type:"string",default:"1s",hint:"Use 30s, 1h30m30s, or 3d30s. Units: w, d, h, m, s, in that order. Uppercase and ISO-8601 also work. Value and unit is available for single-unit durations."}],values:e,onChange:t,readOnly:s}),f&&n.jsx("p",{role:"alert",children:"Enter a duration such as 30s or 1h30m30s, using units w, d, h, m, s in order."})]})]})}function oi({anchorRef:e,onClose:t,children:s}){const o=b.useRef(null),[r,a]=b.useState(null),[i,l]=b.useState(null);return b.useEffect(()=>{const c=e.current;if(!c)return;const u=c.getBoundingClientRect();a({top:u.bottom+6,left:u.left,width:u.width}),l(c.closest("dialog")??document.body)},[e]),b.useEffect(()=>{function c(d){var p,w;const f=d.target;(p=o.current)!=null&&p.contains(f)||(w=e.current)!=null&&w.contains(f)||t()}function u(d){d.key==="Escape"&&t()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[t,e]),!r||!i?null:Nn.createPortal(n.jsx("div",{ref:o,className:"w6w-flyout",style:{top:r.top,left:r.left,width:r.width},children:s}),i)}function ri(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const s=Object.keys(e),o=Object.keys(t);return s.length!==o.length?!1:s.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&ri(e[r],t[r]))}function Od(e,t){return e.map(s=>{const o=t&&Object.hasOwn(t,s.id)?t[s.id]:void 0,r=s.data.stepProblems;if(o===void 0||o.length===0){if(r===void 0&&!("stepProblems"in s.data))return s;const{stepProblems:a,...i}=s.data;return{...s,data:i}}return r&&ri(r,o)?s:{...s,data:{...s.data,stepProblems:structuredClone(o)}}})}const Rd={body_not_literal:"This loop's body is not a list of step ids",body_unknown_step:"This loop's body names a step that doesn't exist",body_self:"This loop's body contains the For each itself",body_duplicate:"This loop's body lists a step twice",body_claimed_twice:"A step in this loop's body is also owned by another control step",body_contains_control:"This loop's body contains a control step (If, For each, Parallel…)",body_step_has_edges:"A step in this loop's body also has its own connections",legacy_not_linear:"The steps after this For each aren't one straight line, so they can't be read as its loop body"};function Id(e){switch(e.code){case"unknown_connection":return`Connection ${e.connection} no longer exists — open the step and choose another on the Setup tab`;case"foreach_wrapped_items":return"Items wraps a list in another list — this loops once";case"foreach_body_refs_output":return`Refers to the For each's output (${e.refs.join(", ")}) from inside its loop — use Current item instead`;case"loop_body_invalid":{const t=Rd[e.reason.reason]??"This loop's body is not valid";return e.reason.stepId?`${t} (${e.reason.stepId})`:t}case"state_parallel_write":return`Writes ${`state${e.path.length?`.${e.path.join(".")}`:""}`} at the same time as ${e.with.join(", ")} — parallel branches don't see each other's writes; the final value follows the workflow's step order`;case"setup_incomplete":return`Setup incomplete — ${e.items.join(", ")}`}}function $d(e,t){return(t==null?void 0:t.some(s=>s.code==="unknown_connection"&&e.uses.connection===s.connection))??!1}function xr(e,t,s){if(!e)return"No connection";if(s)return"Couldn't load connections";if(t===null)return e;const o=t.find(r=>r.id===e);return o?o.builtIn?"Built-in":o.displayName??e:"Missing connection — choose another"}function yn(e,t,s){if(s.type==="update"){const r=yn(e,t,{type:"rename",ref:s.ref,name:s.name}),a=s.name.trim(),i=yn(r.nodes,r.connections,{type:"replace",ref:a,connection:s.connection});return s.nodeIds?yn(i.nodes,i.connections,{type:"assign",ref:a,nodeIds:s.nodeIds}):i}if(s.type==="add"||s.type==="rename"){const r=s.name.trim();if(!r)throw new Error("Give the workflow connection a name.");if(Object.hasOwn(t,r)&&(s.type==="add"||r!==s.ref))throw new Error("A workflow connection already uses that name.");if(s.type==="add")return{nodes:e,connections:{...t,[r]:{app:s.app,connection:s.connection}}}}if(!Object.hasOwn(t,s.ref))throw new Error("This workflow connection no longer exists.");const o=t[s.ref];switch(s.type){case"replace":return{nodes:e,connections:{...t,[s.ref]:{...o,connection:s.connection}}};case"rename":{const r=s.name.trim();return{connections:Object.fromEntries(Object.entries(t).map(([a,i])=>[a===s.ref?r:a,i])),nodes:e.map(a=>a.uses.connectionRef===s.ref?nn(a,r):a)}}case"remove":{if(e.some(i=>i.uses.connectionRef===s.ref))throw new Error("Choose another connection for its nodes before removing this resource.");const{[s.ref]:r,...a}=t;return{nodes:e,connections:a}}case"assign":{const r=new Set(s.nodeIds);if(e.some(a=>r.has(a.id)&&a.uses.app!==o.app))throw new Error("A connection can only be assigned to nodes for the same app.");return{connections:t,nodes:e.map(a=>r.has(a.id)?nn(a,s.ref):a)}}}}function Bt(e,t){const{connectionRef:s,connection:o,app:r}=e.uses;if(s===void 0)return o??void 0;const a=t&&Object.hasOwn(t,s)?t[s]:void 0;return(a==null?void 0:a.app)===r?a.connection??void 0:void 0}function uo(e,t){const o=(e.split(/[./]/).filter(Boolean).at(-1)??"connection").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"connection";let r=1;for(;Object.hasOwn(t,`${o}_${r}`);)r++;return`${o}_${r}`}function ai(e){let t=e.connections??{},s=!1;const o=(e.nodes??[]).map(r=>{if(!r.uses.connection||r.uses.connectionRef!==void 0)return r;const a=Object.hasOwn(t,r.id)?t[r.id]:void 0,i=(a==null?void 0:a.app)===r.uses.app&&a.connection===r.uses.connection?r.id:uo(r.uses.app,t);return t={...t,[i]:{app:r.uses.app,connection:r.uses.connection}},s=!0,nn(r,i)});return s?{...e,nodes:o,connections:t}:e}function nn(e,t){const{connection:s,...o}=e.uses;return{...e,uses:{...o,connectionRef:t}}}function _d(e,t,s,o){if(!t){const{connection:l,connectionRef:c,...u}=e.uses;return{step:{...e,uses:u},connections:o}}const r=e.uses.connectionRef,a=r&&s.some(l=>l.id!==e.id&&l.uses.connectionRef===r),i=r&&!a?r:uo(e.uses.app,o);return{step:nn(e,i),connections:{...o,[i]:{app:e.uses.app,connection:t}}}}function xn(e,t,s,o){return t?s.filter(r=>r.uses.app===e&&Bt(r,o)===t):[]}function ii(e,t,s,o,r){if(r)return{connection:r};for(const l of[...s].reverse()){if(l.id===e.id||l.uses.app!==e.uses.app)continue;const c=Bt(l,o);if(!(!c||!t.some(u=>u.id===c&&u.appId===e.uses.app)))return l.uses.connectionRef?{connectionRef:l.uses.connectionRef}:{connection:c}}for(const[l,c]of Object.entries(o))if(c.app===e.uses.app&&t.some(u=>u.appId===c.app&&u.id===c.connection))return{connectionRef:l};const a=t.filter(l=>l.appId===e.uses.app),i=a.find(l=>l.builtIn)??a[0];return i?{connection:i.id}:{}}function vr(e,t,s){return s.some(r=>r.builtIn)||!t.some(r=>r.available!==!1&&(r.key==="zero-credential"||r.autoSatisfied===!0&&(r.type==="tenantAuth"||r.type==="jit")))?s:[...s,{id:`zerocred:${e}`,appId:e,authKey:"zero-credential",displayName:"Built-in",builtIn:!0,state:"connected"}]}function Pd(e,t,s,o,r){const a=new Set(xn(e,t,o,r).map(i=>i.uses.connectionRef));return Object.fromEntries(Object.entries(r).map(([i,l])=>[i,a.has(i)?{...l,connection:s}:l]))}function li(e,t=""){if(!e||typeof e!="object"||Array.isArray(e))return[];const s=[];for(const[o,r]of Object.entries(e)){const a=t?`${t}.${o}`:o;s.push(a,...li(r,a))}return s}function Fd(e,t,s){var a,i;const o=[],r={};for(const[l,c]of Object.entries(e)){const u=c.connection?t.get(c.connection):void 0,d=(u==null?void 0:u.profile)??{};o.push({name:l,appName:((a=s.get(c.app))==null?void 0:a.displayName)??((i=u==null?void 0:u.app)==null?void 0:i.displayName)??c.app,...u!=null&&u.displayName?{label:u.displayName}:{},fields:[{key:"id"},{key:"app"},{key:"name"},{key:"state"},{key:"profile",path:!0},...li(d,"profile").map(f=>({key:f,path:!0}))]}),u&&(r[`connections.${l}`]={id:u.id,app:u.appId,name:u.displayName??"",state:u.state??"",profile:d})}return{sources:o,sampleValues:r}}const ci=b.createContext(null);function po(){return b.useContext(ci)}function ui({step:e,conns:t,failed:s=!1,readOnly:o,open:r,onOpenChange:a,anchorRef:i,onChangeConnection:l,onChangeConnectionRef:c,onConnectionCreated:u,createSignal:d}){var q,O,F;const f=po(),p=o||(f==null?void 0:f.readOnly),w=(f==null?void 0:f.connections)??{},m=(f==null?void 0:f.nodes)??[],h=(t??[]).map(E=>({conn:E,users:xn(e.uses.app,E.id,m,w)})).sort((E,I)=>+(I.users.length>0)-+(E.users.length>0)),y=Bt(e,w)??(e.uses.connectionRef===void 0?(q=t==null?void 0:t.find(E=>E.builtIn&&E.appId===e.uses.app))==null?void 0:q.id:void 0),g=xn(e.uses.app,y,m,w).filter(E=>E.id!==e.id),[x,S]=b.useState(null),[A,R]=b.useState(!1),j=b.useRef(d);b.useEffect(()=>{const E=j.current;j.current=d,d!==void 0&&E!==void 0&&d>E&&R(!0)},[d]);const N=x||A?((F=(O=i.current)==null?void 0:O.closest("dialog"))==null?void 0:F.parentElement)??document.body:null,k=(E,I)=>{if(!p){if(I&&f&&y){f.setConnections(Pd(e.uses.app,y,E,m,w));const $=m.find(V=>V.id===e.id)??e;$.uses.connectionRef?c($.uses.connectionRef):l(E)}else{const $=xn(e.uses.app,E,m,w).filter(J=>J.id!==e.id&&J.uses.connectionRef).at(-1),V=Object.entries(w).find(([,J])=>J.app===e.uses.app&&J.connection===E);$!=null&&$.uses.connectionRef?c($.uses.connectionRef):V?c(V[0]):l(E)}S(null),a(!1)}},_=E=>{p||(a(!1),E!==y&&(g.length>0&&m.some(I=>I.id===e.id)?S(E):k(E,!1)))};return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"w6w-app-conn-btn","aria-label":"Connection","aria-expanded":r,disabled:p||t===null&&!s,onClick:()=>a(!r),children:n.jsx("span",{className:"w6w-conn-label-name",children:t===null&&!s&&!y?"Loading connections…":xr(y,t,s)})}),r&&n.jsx(oi,{anchorRef:i,onClose:()=>a(!1),children:n.jsxs("div",{className:"w6w-stack",children:[s&&n.jsx("p",{role:"alert",className:"w6w-field-error",children:"Couldn’t load connections."}),Object.entries(w).some(([,E])=>E.app===e.uses.app)&&n.jsxs("div",{className:"w6w-stack",children:[n.jsx("strong",{className:"w6w-small",children:"Workflow connections"}),n.jsx("div",{className:"w6w-stepbuilder-list",children:Object.entries(w).filter(([,E])=>E.app===e.uses.app).map(([E,I])=>n.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:p||!I.connection||!(t!=null&&t.some($=>$.id===I.connection)),"aria-pressed":e.uses.connectionRef===E,"data-connection-ref":E,onClick:()=>{c(E),a(!1)},children:n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:E}),n.jsx("span",{className:"w6w-muted w6w-small",children:xr(I.connection??void 0,t,s)})]})},E))})]}),n.jsx("div",{className:"w6w-stepbuilder-list",children:h.map(({conn:E,users:I})=>n.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:p,"aria-pressed":E.id===y,"data-connection-id":E.id,onClick:()=>_(E.id),children:n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:E.builtIn?"Built-in":E.displayName||E.id}),n.jsx("span",{className:"w6w-muted w6w-small",children:I.length>0?`In use in this workflow · ${I.map($=>$.id).join(", ")}`:E.builtIn?"Built-in connection":E.state})]})},E.id))}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:p,onClick:()=>{a(!1),R(!0)},children:"+ New connection"})]})}),A&&N&&Nn.createPortal(n.jsx(Zs,{initialAppId:e.uses.app,onClose:()=>R(!1),onCreated:({connectionId:E})=>{R(!1),u(),_(E)}}),N),x&&N&&Nn.createPortal(n.jsxs(Ee,{title:"Change connection",onClose:()=>S(null),children:[n.jsxs("div",{className:"w6w-modal-body",children:[n.jsx("p",{children:"Change the connection for all these nodes, or only this node?"}),n.jsxs("ul",{children:[n.jsx("li",{children:e.id||"New node"}),g.map(E=>n.jsx("li",{children:E.id},E.id))]})]}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>S(null),children:"Cancel"}),n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:p,onClick:()=>k(x,!0),children:["All ",g.length+1," nodes"]}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:p,onClick:()=>k(x,!1),children:"Only this node"})]})]}),N)]})}function Ld(e,t){return`${e.method}-${e.url??e.host}-${t}`}function di({calls:e,defaultOpen:t,keyOf:s,title:o}){if(e.length===0)return null;const r=s??Ld;return n.jsxs("div",{className:"w6w-stack",style:{gap:4},children:[o!==!1&&n.jsx("strong",{className:"w6w-small",children:o??n.jsxs(n.Fragment,{children:["API ",e.length===1?"call":"calls"," (",e.length,")"]})}),e.map((a,i)=>n.jsxs("details",{open:t,className:"w6w-result",style:{padding:8},children:[n.jsx("summary",{style:{cursor:"pointer"},children:n.jsxs("span",{className:"w6w-small",children:[a.method," ",a.url??a.host," →"," ",n.jsx("strong",{children:a.error?"failed":a.status}),a.durationMs!==void 0&&n.jsxs("span",{className:"w6w-muted",children:[" · ",a.durationMs,"ms"]})]})}),n.jsxs("div",{className:"w6w-stack",style:{gap:6,marginTop:8},children:[a.error&&n.jsx("div",{className:"w6w-error w6w-small",children:a.error}),n.jsx("div",{className:"w6w-muted w6w-small",children:"Request headers"}),n.jsx(Te,{value:a.requestHeaders??{},maxHeight:240}),a.requestBody&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small",children:"Request body"}),n.jsx(Te,{value:a.requestBody,maxHeight:240})]}),n.jsx("div",{className:"w6w-muted w6w-small",children:"Response headers"}),n.jsx(Te,{value:a.responseHeaders??{},maxHeight:240}),a.responseBody&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small",children:"Response body"}),n.jsx(Te,{value:a.responseBody,maxHeight:240})]}),a.truncated&&n.jsx("div",{className:"w6w-muted w6w-small",children:"A captured body exceeded the size cap and was truncated."})]})]},r(a,i)))]})}function pi({title:e,children:t,action:s,className:o,testId:r}){return n.jsx("div",{className:o?`w6w-empty-state ${o}`:"w6w-empty-state","data-testid":r,children:n.jsxs("div",{className:"w6w-empty-state-inner",children:[e!=null&&n.jsx("div",{className:"w6w-empty-state-title",children:e}),t!=null&&n.jsx("div",{className:"w6w-empty-state-body",children:t}),s!=null&&n.jsx("div",{className:"w6w-empty-state-action",children:s})]})})}function fi({choices:e,onChange:t,readOnly:s}){const o=new Set(e.selected),r=e.options.every(i=>o.has(i.value)),a=[...e.options,...e.selected.filter(i=>!e.options.some(l=>l.value===i)).map(i=>({value:i,label:i}))];return n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Triggers *"}),n.jsxs("div",{className:"w6w-multiselect-checks",children:[n.jsxs("div",{className:"w6w-multiselect-checks-toolbar",children:[n.jsxs("label",{className:"w6w-multiselect-check",children:[n.jsx("input",{type:"checkbox",checked:r,ref:i=>{i&&(i.indeterminate=!r&&o.size>0)},disabled:s,onChange:i=>t(i.target.checked?e.options.map(l=>l.value):[])}),n.jsx("span",{children:"All events"})]}),n.jsxs("span",{className:"w6w-muted w6w-small",children:[o.size," selected"]})]}),n.jsx("fieldset",{className:"w6w-multiselect-checks-options","aria-label":"Eventbrite events",children:a.map(i=>n.jsxs("label",{className:"w6w-multiselect-check",children:[n.jsx("input",{type:"checkbox",checked:o.has(i.value),disabled:s,onChange:l=>t(l.target.checked?[...e.selected,i.value]:e.selected.filter(c=>c!==i.value))}),n.jsx("span",{children:i.label})]},i.value))})]}),n.jsx("span",{className:"w6w-hint",children:"Start this workflow when any selected event occurs."})]})}function Vn({icon:e,size:t=28}){return n.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:t,height:t,borderRadius:6,flexShrink:0,background:"var(--w6w-icon-swatch, var(--w6w-panel-2))",color:"var(--w6w-accent)"},children:n.jsx("svg",{width:Math.round(t*.6),height:Math.round(t*.6),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",dangerouslySetInnerHTML:{__html:e}})})}function hi(e,t,s,o){var c;if(e!=="io.w6w.eventbrite")return null;const r=t==null?void 0:t.find(u=>u.key==="activity"),a=(c=r==null?void 0:r.params)==null?void 0:c.find(u=>u.key==="actions"&&u.type==="multiselect");if(!r||!Array.isArray(a==null?void 0:a.options)||!a.options.length)return null;const i=a.options.map(u=>{var p;const d=String(u.value),f=d.replace(/[._]/g,"-");return{value:d,label:((p=t==null?void 0:t.find(w=>w.key===f))==null?void 0:p.title)??u.label,triggerKey:f}}),l=i.find(u=>u.triggerKey===s);return s&&s!==r.key&&!l||s===r.key&&o.actions!=null&&!Array.isArray(o.actions)?null:{triggerKey:r.key,options:i.sort((u,d)=>u.label.localeCompare(d.label)),selected:l?[l.value]:Array.isArray(o.actions)?o.actions.filter(u=>typeof u=="string"):[]}}const Dd=["off","root","key","pick","append"],Md={off:"Off",root:"Merge at root",key:"Under a key",pick:"Pick fields",append:"Append"};function Wd(e){return ie.effectiveStateConfig(e.uses.app,e.uses.action,e.state)}function qd(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Bd(e,t){const{state:s,...o}=e,r=ie.effectiveStateConfig(e.uses.app,e.uses.action,void 0);return qd(t,r)?o:{...o,state:t}}function Ud(e,t){switch(t){case"key":return{mode:"key",key:e.id};case"pick":return{mode:"pick",map:[{from:"",to:e.id}]};case"append":return{mode:"append",path:e.id};case"root":return{mode:"root"};default:return{mode:"off"}}}function mi(e){return!$t(e.uses.app)}function Se(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===We&&e.uses.action==="foreach"}function wi(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===We}function Ss(e){var s,o;if((e==null?void 0:e.uses.app)===Ze)return!0;if((e==null?void 0:e.uses.app)===Wt)return!1;if(!wi(e))return!0;const t=e==null?void 0:e.uses.action;return t==="foreach"||t==="wait"?!0:t==="if"&&((s=e==null?void 0:e.with)==null?void 0:s.then)===void 0&&((o=e==null?void 0:e.with)==null?void 0:o.else)===void 0}function fo(e){if(!wi(e))return[];const t=e.with??{},s=[],o=r=>{if(typeof r=="string")s.push(r);else if(Array.isArray(r))for(const a of r)o(a)};return o(t.body),o(t.branches),o(t.then),o(t.else),s}function Vd(e){const t=new Set;for(const s of e)for(const o of fo(s))t.add(o);return t}function vn(e,t,s,o){return{id:jt(e,t,"each",o),source:e,target:t,sourceHandle:o!==void 0?qt(o):s?_n:void 0,animated:!1,data:{when:"each",...o===void 0?{}:{route:o}},...on("each",void 0)}}const cn=e=>{var t;return typeof((t=e.data)==null?void 0:t.route)=="string"?e.data.route:void 0};function ho(e,t,s,o){const r=new Set(t.map(h=>h.id)),a=new Set(t.filter(h=>{var y;return Se((y=h.data)==null?void 0:y.step)}).map(h=>h.id)),i=s.filter(h=>je(h)==="each"&&!(h.source!==e&&a.has(h.source)&&cn(h)===void 0)),l=new Set([e]),c=[],u=[e];for(let h=0;h<u.length;h++)for(const y of i)y.source===u[h]&&(!r.has(y.target)||l.has(y.target)||o!=null&&o.has(y.target)||(l.add(y.target),c.push(y.target),u.push(y.target)));const d=new Map(c.map((h,y)=>[h,y])),f=i.filter(h=>h.source!==e&&d.has(h.source)&&d.has(h.target)),p=new Map(c.map(h=>[h,0]));for(const h of f)p.set(h.target,(p.get(h.target)??0)+1);const w=[],m=new Set;for(;;){const h=c.find(y=>!m.has(y)&&p.get(y)===0);if(h===void 0)break;m.add(h),w.push(h);for(const y of f)y.source===h&&p.set(y.target,(p.get(y.target)??0)-1)}for(const h of c)m.has(h)||w.push(h);return w}function bi(e,t){const s=new Set(e);return t.filter(o=>je(o)==="each"&&s.has(o.source)&&s.has(o.target))}function Hd(e,t){const s=bi(e,t),o=new Set;for(const r of s){if(cn(r)!==void 0||o.has(r.source))return!1;o.add(r.source)}return!0}function Jd(e,t){const s=[];for(const o of Hn(e,t).values())if(!Hd(o,t))for(const r of bi(o,t)){const a=cn(r);s.push({from:r.source,to:r.target,...a===void 0?{}:{route:a}})}return s}function Hn(e,t){var r;const s=new Map,o=new Set;for(const a of e){if(!Se((r=a.data)==null?void 0:r.step))continue;const i=ho(a.id,e,t,o);for(const l of i)o.add(l);s.set(a.id,i)}return s}function Je(e,t){const s={};for(const[o,r]of Hn(e,t))for(const a of r)s[a]=o;return s}function gi(e,t,s){const o=Je(t,s),r=[];let a=o[e];for(;a!==void 0&&!r.includes(a);)r.unshift(a),a=o[a];return r}function zd(e,t,s){const o=h=>h.source===e||h.target===e,r=s.filter(h=>!o(h)),i=Se((h=>{var y,g;return(g=(y=t.find(x=>x.id===h))==null?void 0:y.data)==null?void 0:g.step})(e)),l=Je(t,s),c=new Set(i?Object.keys(l).filter(h=>l[h]===e):[]),u=i?r.filter(h=>!(je(h)==="each"&&(h.source===e||c.has(h.source))&&c.has(h.target))):r,d=l[e];if(d===void 0)return u;const f=s.filter(h=>h.target===e&&je(h)==="each"),p=s.filter(h=>h.source===e&&je(h)==="each"&&!c.has(h.target));if(f.length!==1||p.length!==1)return u;const w=f[0].source,m=p[0].target;return u.some(h=>h.source===w&&h.target===m&&je(h)==="each")?u:[...u,vn(w,m,w===d,cn(f[0]))]}function mo(e){if(!Se(e)||!e.with||!("body"in e.with))return e;const{body:t,...s}=e.with;return{...e,with:s}}function yi(e,t,s,o,r,a){const i=Je(o,r);if(s==="error")return i[e]!==void 0||i[t]!==void 0?"error_lane_in_body":null;if(s==="success")return i[t]!==void 0?"outside_inbound":null;const l=f=>{var p,w;return(w=(p=o.find(m=>m.id===f))==null?void 0:p.data)==null?void 0:w.step},u=Se(l(e))&&(a===void 0||i[e]===void 0)?e:i[e];if(u===void 0)return null;if(t===u||gi(u,o,r).includes(t))return"loop_cycle";const d=()=>e!==u||!r.some(f=>f.source===e&&je(f)==="each"&&cn(f)===void 0);return i[t]===u?e===u||Kd(t,e,r)?"loop_cycle":d()?null:"body_branch":i[t]!==void 0?"already_in_loop":Ss(l(t))?d()?r.some(f=>f.source===t||f.target===t)?"body_exit":null:"body_branch":"control_in_body"}function Kd(e,t,s){const o=new Set([e]),r=[e];for(;r.length>0;){const a=r.pop();if(a===t)return!0;for(const i of s)i.source!==a||je(i)!=="each"||o.has(i.target)||(o.add(i.target),r.push(i.target))}return!1}const Gd={error_lane_in_body:"A step inside a loop can't have an error connection. Handle the failure outside the loop.",outside_inbound:"This step is inside a loop, so nothing outside it can connect into it. Connect from the loop's Each item side instead.",loop_cycle:"A loop body can't connect back to its own For each.",already_in_loop:"That step is already inside another loop.",control_in_body:"Parallel, Merge, Aggregate and Race join paths of the main workflow, so they can't run inside a loop body. Use an If, Router, Wait, Stop, Respond or another For each.",body_branch:"A For each's Each item port connects to one first step. Branch inside the loop from that step onward.",body_exit:"That step is already connected elsewhere in the workflow. Use a step with no connections, or disconnect it first."};function Yd(e){return Gd[e]}function Xd(e,t){const s=Je(e,t);let o=!1;const r=e.map(a=>{const i=s[a.id];if(a.data.loopOf===i)return a;if(o=!0,i===void 0){const{loopOf:l,...c}=a.data;return{...a,data:c}}return{...a,data:{...a.data,loopOf:i}}});return o?r:e}function Zd(e,t,s){var i,l;const o=`Delete node "${e}"? Its connections are removed too.`,r=(l=(i=t.find(c=>c.id===e))==null?void 0:i.data)==null?void 0:l.step;if(!Se(r))return o;const a=ho(e,t,s);return a.length===0?o:`${o} Its loop body steps ${a.map(c=>`"${c}"`).join(", ")} stay as standalone steps.`}function wo(e){if(e.edges)return e.edges;const t=Vd(e.nodes),s=e.nodes.filter(r=>!t.has(r.id)),o=[];for(let r=0;r<s.length-1;r++)o.push({from:s[r].id,to:s[r+1].id});return o}const jn=e=>(e.when??"success")==="success",Rn=e=>e.route===Lr&&jn(e);function bo(e){const t=new Map(e.nodes.map(u=>[u.id,u])),s=new Map;for(const u of e.nodes)for(const d of fo(u)){const f=s.get(d)??new Set;f.add(u.id),s.set(d,f)}const o=wo(e),r=e.edges??[],a={};for(const u of e.nodes){if(!Se(u))continue;const d=u.with??{};if("body"in d){a[u.id]=i(u.id,d.body);continue}a[u.id]=c(u.id)}return a;function i(u,d){const f=(y,g)=>({invalid:g===void 0?{reason:y}:{reason:y,stepId:g}});if(!Array.isArray(d)||d.some(y=>typeof y!="string"))return f("body_not_literal");const p=d,w=new Set(p),m=new Set;for(const y of p){if(!t.has(y))return f("body_unknown_step",y);if(y===u)return f("body_self",y);if(m.has(y))return f("body_duplicate",y);if(m.add(y),!Ss(t.get(y)))return f("body_contains_control",y);const g=s.get(y);if(g&&[...g].some(x=>x!==u))return f("body_claimed_twice",y)}const h=[];for(const y of r){if(Rn(y)&&y.from===u&&y.to===p[0]||Rn(y)&&w.has(y.from)&&!w.has(y.to)&&l(y.from,y.to)||!(w.has(y.from)||w.has(y.to)))continue;if(!(w.has(y.from)&&w.has(y.to)&&jn(y)&&y.to!==p[0]))return f("body_step_has_edges",w.has(y.from)?y.from:y.to);h.push(y)}return h.length>0?{body:p,source:"body",edges:h}:{body:p,source:"body"}}function l(u,d){var p,w;const f=(w=(p=t.get(u))==null?void 0:p.with)==null?void 0:w.body;return Se(t.get(u))&&Array.isArray(f)&&f[0]===d}function c(u){var y;const d=o.filter(g=>g.from===u&&jn(g)&&g.route===void 0);if(d.length===0)return{body:[],source:"body"};const f=g=>({invalid:{reason:"legacy_not_linear",stepId:g}});if(d.length>1)return f(u);const p=[],w=new Set([u]);let m=u,h=d[0].to;for(;h!==void 0;){const g=h,x=t.get(g);if(!x||w.has(g)||!Ss(x)||s.has(g))return f(g);const S=o.filter(R=>R.to===g);if(S.length!==1||S[0].from!==m)return f(g);const A=o.filter(R=>R.from===g);if(A.length>1||A.length===1&&!jn(A[0]))return f(g);w.add(g),p.push(g),m=g,h=(y=A[0])==null?void 0:y.to}return{body:p,source:"legacy"}}}function je(e){var s;const t=(s=e.data)==null?void 0:s.when;return t==="error"?"error":t==="each"?"each":"success"}function xi(e,t){var s;return((s=e.find(o=>o.id===t))==null?void 0:s.id)??null}function vi(e,t,s,o,r,a){var d,f;if(!e||!t||e===t||o.some(p=>{var w;return p.source===e&&p.target===t&&((w=p.data)==null?void 0:w.route)===a}))return!1;const i=(d=s.find(p=>p.id===e))==null?void 0:d.data.step,l=(f=s.find(p=>p.id===t))==null?void 0:f.data.step;if(!i||!l)return!1;const c=Xt(i,r),u=Xt(l,r);return c.out>=1&&u.in>=1}function go(e,t,s,o,r,a,i){var R,j,N;const l=r==="success"&&Se((R=s.find(k=>k.id===e))==null?void 0:R.data.step),c=l&&i===void 0?yt:i;if(!vi(e,t,s,o,a,c)||!e||!t)return null;const u=(j=s.find(k=>k.id===e))==null?void 0:j.data.step,d=(N=s.find(k=>k.id===t))==null?void 0:N.data.step;if(!u||!d)return null;const f=Ls(u);if(l){if(c!==yt)return null}else if(u.uses.app===Ze&&r==="success"){if(!Fs(u).some(k=>k.id===c))return null}else if(f&&r==="success"){if(c!==void 0&&c!==Sn)return null}else if(c!==void 0)return null;const p=Je(s,o)[e]!==void 0,w=r==="success"&&p?"each":r;if(w==="each"&&!p&&!Se(u))return null;const m=yi(e,t,w,s,o,c);if(m)return{next:o,conflict:null,refusal:{refused:"loop",reason:m}};const h=Xt(u,a),y=o,g=y.filter(k=>{var _;return k.source===e&&je(k)===w&&((_=k.data)==null?void 0:_.route)===c}),x=c===void 0||f||l?h.out:1;if(g.length>=x)return{next:o,conflict:null,refusal:{refused:"out_cap",cap:x}};const S=jt(e,t,w,c),A=w==="each"&&p&&!Se(u)?void 0:Is(w);return{next:rs.addEdge({source:e,target:t,id:S,sourceHandle:c===void 0?A:qt(c),data:{when:w,...c===void 0?{}:{route:c}},...on(w,void 0)},y),conflict:xi(y,S),refusal:null}}function Qd(e,t,s,o,r="success",a,i){const l=go(e,t,s,o,r,a,i);return!l||l.conflict||l.refusal?null:l.next}function ep(e,t,s,o,r="success",a,i){var l;return((l=go(e,t,s,o,r,a,i))==null?void 0:l.conflict)??null}function tp(e,t,s,o,r="success",a,i){var l;return((l=go(e,t,s,o,r,a,i))==null?void 0:l.refusal)??null}function yo(e,t,s,o,r){var x;const a=e.filter(S=>S.id===t);if(a.length!==1)return null;const i=a[0];if(je(i)==="each")return null;const l=(x=o.find(S=>S.id===i.source))==null?void 0:x.data.step;if(!l||l.uses.app===Ze||l.uses.app===Wt)return null;const c=Xt(l,r).out,u=e.filter(S=>S.id!==t);if((je(i)===s?[]:u.filter(S=>S.source===i.source&&je(S)===s)).length>=c)return{next:e,conflict:null,refusal:{refused:"out_cap",cap:c}};const f=on(s,void 0),p=Se(l),w=p&&s==="success"?yt:void 0,{route:m,...h}=i.data??{},y={...i,id:jt(i.source,i.target,s,w),data:p?{...h,when:s,...w?{route:w}:{}}:{...i.data,when:s},className:f.className,label:f.label,sourceHandle:w?qt(w):Is(s)},g=xi(u,y.id);return{next:e.map(S=>S.id===t?y:S),conflict:g,refusal:null}}function np(e,t,s,o,r){const a=yo(e,t,s,o,r);return!a||a.conflict||a.refusal?null:a.next}function sp(e,t,s,o,r){var a;return((a=yo(e,t,s,o,r))==null?void 0:a.conflict)??null}function op(e,t,s,o,r){var a;return((a=yo(e,t,s,o,r))==null?void 0:a.refusal)??null}function rp(e,t,s){return e.map(o=>{var i;const r=o.source===t?s:o.source,a=o.target===t?s:o.target;return{...o,source:r,target:a,id:jt(r,a,je(o),typeof((i=o.data)==null?void 0:i.route)=="string"?o.data.route:void 0)}})}function jt(e,t,s,o){const r=s==="error"?`${e}->${t}:error`:`${e}->${t}`;return o===void 0?r:`${r}:route:${encodeURIComponent(o)}`}function ap(e){return e.includes(".")?"A step id can't contain a dot (.).":null}function ji(e,t){const s=ap(e);if(s)return s;for(const o of t)if(o===e)return`A step named "${e}" already exists.`;return null}function ip(e,t,s){const o=(f,p)=>!f||!p?void 0:jt(f,p)===t?"success":jt(f,p,"error")===t?"error":void 0,r=o(s[0],s[1]),a=o(s[2],s[3]),i=r!==void 0&&r===a,l=r!==void 0&&a!==void 0&&r!==a,c=r==="success"?s[1]:s[3],u=i?s.find(f=>!!f&&f.includes("->")):l&&(c!=null&&c.endsWith(":error"))?c:void 0,d=u===void 0?"Rename one of the steps it connects, then try again.":i?`A step id containing “->” collides with the edge-id separator, so two different edges mint one id — rename the step “${u}”, then try again.`:`A step id ending in “:error” collides with the error-lane marker, so two different edges mint one id — rename the step “${u}”, then try again.`;return`${e}: the id “${t}” is already taken by another edge. ${d}`}const lp=240,cp=100,up=40,dp=40;function xo(e,t){return{x:up+e*lp,y:dp+t*cp}}function pp(e,t){var l;const s=new Map,o=new Map;for(const c of e)s.set(c.id,0),o.set(c.id,[]);for(const c of t)(l=o.get(c.to))==null||l.push(c.from);const r=e.length+1;let a=0,i=!0;for(;i&&a<r;){a++,i=!1;for(const c of e){const u=o.get(c.id)??[];if(u.length===0)continue;const d=u.reduce((f,p)=>Math.max(f,(s.get(p)??0)+1),0);(s.get(c.id)??0)<d&&(s.set(c.id,d),i=!0)}}if(i){const c=Math.max(0,e.length-1);for(const[u,d]of s)d>c&&s.set(u,c)}return s}function ki(e,t){var c;const s=pp(e,t),o=new Map(e.map((u,d)=>[u.id,d])),r=new Map;for(const{from:u,to:d}of t){const f=s.get(u),p=s.get(d);if(f===void 0||p===void 0||f>=p)continue;const w=r.get(d);(w===void 0||f<(s.get(w)??0)||f===s.get(w)&&(o.get(u)??0)<(o.get(w)??0))&&r.set(d,u)}const a=new Map(e.map(u=>[u.id,[]]));for(const[u,d]of r)(c=a.get(d))==null||c.push(u);for(const u of a.values())u.sort((d,f)=>(s.get(f)??0)-(s.get(d)??0)||(o.get(d)??0)-(o.get(f)??0));const i=new Map;let l=0;for(const u of e.filter(d=>!r.has(d.id))){const d=[u.id];for(;d.length;){const f=d.pop();if(f===void 0)continue;i.set(f,xo(s.get(f)??0,l));const p=a.get(f)??[];if(p.length===0)l++;else for(let w=p.length-1;w>=0;w--)d.push(p[w])}}return i}function fp(e){const t=e.position;if(!(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)))return{x:t.x,y:t.y}}function vo(e){const t=e;if(t.nodes!==void 0&&t.steps!==void 0)throw new Error("workflow carries both nodes and steps");const{steps:s,...o}=e;return{...o,nodes:t.nodes??t.steps??[]}}function hp(e){const t=vo(e),s=t.nodes;let o=wo(t);const r=[],a=new Set(s.filter(Se).map(m=>m.id)),i=new Map,l=new Set,c=new Set;for(const[m,h]of Object.entries(bo(t))){if("invalid"in h)continue;let y=m;if(h.edges&&h.body.length>0){r.push(vn(m,h.body[0],!0));for(const g of h.edges)c.add(g),r.push(vn(g.from,g.to,!1,g.route));for(const g of h.body)i.set(g,m);continue}for(const g of h.body){if(h.source==="legacy"){const x=o.find(S=>S.from===y&&S.to===g&&(S.when??"success")==="success");x&&c.add(x)}r.push(vn(y,g,y===m,y!==m&&a.has(y)?yt:void 0)),i.set(g,m),y=g}h.source==="legacy"&&l.add(m)}const u=new Set(s.filter(Se).map(m=>m.id));for(const m of o)u.has(m.from)&&Rn(m)&&c.add(m);c.size>0&&(o=o.filter(m=>!c.has(m)));const d=ki(s,[...o,...r.map(m=>({from:m.source,to:m.target}))]),f=s.map(m=>{const h=st(m.uses.app);return{id:m.id,type:h?"control":"step",position:fp(m)??d.get(m.id)??xo(0,0),data:{step:m,isInternal:h,...i.has(m.id)?{loopOf:i.get(m.id)}:{},...l.has(m.id)?{legacyLoop:!0}:{}}}}),p=new Set(s.filter(Ls).map(m=>m.id)),w=o.map(m=>{const h=m.when==="error"&&m.route===void 0&&p.has(m.from)?{from:m.from,to:m.to,route:Sn}:u.has(m.from)&&m.route===void 0&&m.when!=="error"?{...m,route:yt}:m,y=h.when??"success";return{id:jt(h.from,h.to,y,h.route),source:h.from,target:h.to,sourceHandle:h.route===void 0?Is(y):`route:${h.route}`,animated:!1,data:{when:y,...h.route===void 0?{}:{route:h.route}},...on(y,void 0)}});return{nodes:f,edges:[...w,...r]}}function mp(e,t){const s=e.map(r=>({...r.data.step,id:r.id})),o=ki(s,t.map(r=>({from:r.source,to:r.target})));return e.map(r=>({...r,position:o.get(r.id)??xo(0,0)}))}function wp(e,t,s){var R,j;const o=vo(e),r=((R=o.settings)==null?void 0:R.savePosition)!==!1,a=new Map(t.map(N=>[N.id,N])),i=N=>{var _;if(!r)return N;const k=(_=a.get(N.id))==null?void 0:_.position;return!k||!Number.isFinite(k.x)||!Number.isFinite(k.y)?N:{...N,position:{x:Math.round(k.x),y:Math.round(k.y)}}},l=new Map;for(const N of o.nodes)l.set(N.id,N);for(const N of t)(j=N.data)!=null&&j.step&&l.set(N.id,N.data.step);const c=Hn(t,s),u=bo(o),d=new Map(o.nodes.map(N=>[N.id,N])),f=new Set;for(const N of s)je(N)==="success"&&f.add(N.source);const p=N=>{if(!Se(N))return N;const k=c.get(N.id)??[],_=d.get(N.id),q=u[N.id];let O;k.length>0?O={value:k}:q&&"invalid"in q&&q.invalid.reason!=="legacy_not_linear"?O=_!=null&&_.with&&"body"in _.with?{value:_.with.body}:null:q&&"invalid"in q?O=null:f.has(N.id)||_!=null&&_.with&&"body"in _.with?O={value:[]}:O=null;const F=N.with??{};return O===null?"body"in F?mo(N):N:{...N,with:{...F,body:O.value}}},w=N=>i(p(N)),m=[],h=new Set;for(const N of o.nodes){const k=l.get(N.id);k&&t.some(_=>_.id===N.id)&&(m.push(w(k)),h.add(N.id))}for(const N of t){if(h.has(N.id))continue;const k=l.get(N.id);k&&m.push(w(k))}const y=new Set;for(const N of c.values())for(const k of N)y.add(k);const g=new Set(t.filter(N=>{var k;return Se((k=N.data)==null?void 0:k.step)}).map(N=>N.id)),x=s.filter(N=>je(N)!=="each"&&!y.has(N.source)&&!y.has(N.target)).map(N=>{var _;const k=typeof((_=N.data)==null?void 0:_.route)=="string"?N.data.route:g.has(N.source)&&je(N)==="success"?yt:void 0;return{from:N.source,to:N.target,...je(N)==="error"?{when:"error"}:{},...k===void 0?{}:{route:k}}}),S=[];for(const[N,k]of c)k.length>0&&S.push({from:N,to:k[0],route:Lr});const A=[...x,...S,...Jd(t,s)];return ai({...o,nodes:m,edges:A})}function Ni(e){var s;const t=(s=e.settings)==null?void 0:s.viewport;if(!(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.zoom)))return{x:t.x,y:t.y,zoom:t.zoom}}function bp(e,t){var i;if(!(((i=e.settings)==null?void 0:i.savePosition)!==!1)||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.zoom))return e;const o={x:Math.round(t.x),y:Math.round(t.y),zoom:Math.round(t.zoom*1e3)/1e3},r=Ni(e);if(r&&r.x===o.x&&r.y===o.y&&r.zoom===o.zoom)return e;const a=typeof e.settings=="object"&&e.settings!==null&&!Array.isArray(e.settings)?e.settings:void 0;return{...e,settings:{...a,viewport:o}}}function gp(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"step"}function yp(e,t){const s=new Set(t.map(o=>o.target));return e.find(o=>!s.has(o.id))}function xp(e,t){const s=new Set(t.map(o=>o.source));for(let o=e.length-1;o>=0;o--)if(!s.has(e[o].id))return e[o]}function vp(e,t="step"){const s=new Set(e);for(let o=1;o<1e3;o++){const r=`${t}_${o}`;if(!s.has(r))return r}return`${t}_${crypto.randomUUID().slice(0,8)}`}function jo(e){return JSON.stringify(mo(e),null,2)}const jp=3,kp=100;function kt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Si(e){if(!Array.isArray(e))return;const t=[],s=new Set,o=r=>{s.has(r.key)||(s.add(r.key),t.push(r))};for(const r of e){if(!kt(r)||typeof r.key!="string"||r.key==="")continue;const a=typeof r.label=="string"&&r.label!==""?r.label:void 0;if(o({key:r.key,...a?{label:a}:{},path:!0}),r.type==="array"&&Array.isArray(r.items))for(const i of r.items){if(!kt(i)||typeof i.key!="string"||i.key==="")continue;const l=typeof i.label=="string"&&i.label!==""?i.label:void 0;o({key:`${r.key}.0.${i.key}`,...l?{label:l}:{},path:!0})}}return t.length>0?t:void 0}function Np(e,t){var o;if(!Array.isArray(e))return;const s=e.find(r=>kt(r)&&r.key===t);if(!(!kt(s)||!Array.isArray(s.items)))return(o=Si([{key:t,type:"array",items:s.items}]))==null?void 0:o.filter(r=>r.key!==t).map(r=>({...r,key:r.key.slice(t.length+3)}))}function gt(e){if(!kt(e))return;const t=[],s=(o,r,a)=>{for(const[i,l]of Object.entries(o)){if(t.length>=kp)return;const c=r?`${r}.${i}`:i;t.push({key:c,path:!0}),kt(l)&&a<jp&&s(l,c,a+1)}};return s(e,"",1),t.length>0?t:void 0}function zt(e,t){let s=e;for(const o of t.split(".")){if(!kt(s)||!(o in s))return;s=s[o]}return s}function wt(e,t,s){const o=Si(e==null?void 0:e.output),r=gt(t),a=r??gt(s);if(a){const l=new Map((o??[]).map(d=>[d.key,d])),c=new Set(a.map(d=>d.key)),u=a.map(d=>{const f=l.get(d.key);return f!=null&&f.label?{...d,label:f.label}:d});for(const d of o??[])c.has(d.key)||u.push({...d,declaredOnly:!0});return{fields:u,from:r?"fresh":"persisted"}}if(o)return{fields:o,from:"declared"};const i=gt(e==null?void 0:e.sample);if(i)return{fields:i,from:"sample"}}function ko(e,t){const s=new Map;for(const a of t){const i=s.get(a.target)??[];i.push(a.source),s.set(a.target,i)}const o=new Set,r=[e];for(;r.length;){const a=r.pop();for(const i of s.get(a)??[])o.has(i)||(o.add(i),r.push(i))}return o}function Ci(e,t,s={}){var i,l,c,u,d,f,p;const o=[];let r=!1,a;for(const w of t){if(!e.has(w.id))continue;const m=w.data.step;if(m.uses.app===Ps)continue;const h=((i=xt(m.uses.app,m.uses.action))==null?void 0:i.group)==="trigger",y=(l=s.testOutputs)==null?void 0:l[m.id],g=(c=s.persistedOutputs)==null?void 0:c[m.id];if(m.uses.trigger===!0){r=!0;const k=wt((u=s.triggerDef)==null?void 0:u.call(s,m.uses.app,m.uses.action),y,g);if(a??(a=k),k){o.push({id:m.id,label:m.id,outputs:k.fields,outputsFrom:k.from,trigger:!0});continue}}h&&(r=!0);const x=h&&m.uses.app===Mt,S=x?lo(ro((d=m.with)==null?void 0:d.fields)).map(k=>({key:k.key,label:k.label})):((f=xt(m.uses.app,m.uses.action))==null?void 0:f.output)??[],A={id:m.id,label:m.id,...m.uses.trigger===!0?{trigger:!0}:{}};if(S.length>0){o.push({...A,outputs:S});continue}if(h){const k=wt(void 0,y,g);k&&!x&&(a??(a=k)),o.push(k?{...A,outputs:k.fields,outputsFrom:k.from}:A);continue}if(st(m.uses.app)){const k=wt(void 0,y,g);o.push(k?{...A,outputs:k.fields,outputsFrom:k.from}:A);continue}const R=(p=s.actionDef)==null?void 0:p.call(s,m.uses.app,m.uses.action),j=wt(R,y,g),N=m.uses.app.trim()!==""?{hasMeta:!0}:{};j?o.push({...A,outputs:j.fields,outputsFrom:j.from,...N}):o.push(R?{...A,needsTest:!0,...N}:{...A,...N})}return{steps:o,hasTrigger:r,...a?{eventOutputs:a.fields,eventOutputsFrom:a.from}:{}}}function Sp(e,t){const s={};for(const[o,r]of Object.entries(t))s[o]={output:r};return Ai(e,{steps:s})}function Ai(e,t){if(ut(e)!==null){const s=Hs(e,Bs(void 0,t)),o=s.length===1?s[0]:void 0;return(o==null?void 0:o.status)==="resolved"&&Array.isArray(o.value)?o.value:void 0}return Array.isArray(e)?e:void 0}const Cp=10;function Ap(e,t){return{input:t,with:{items:e.slice(0,Cp),itemCount:e.length}}}function Ep(e){var s;const t=(s=e==null?void 0:e.with)==null?void 0:s.items;return Array.isArray(t)&&t.length>0?t:void 0}function Ei(e,t,s,o,r={}){const a=Je(s,o),i=new Set;for(const f of e){if(f===t)continue;const p=a[f];p!==void 0&&p!==t||i.add(f)}const l=Ci(i,s,r),c=Hn(s,o),u=[];return{steps:l.steps.map(f=>{var x,S,A;const p=c.get(f.id);if(!p||p.length===0)return f;const w=p[p.length-1],m=(x=s.find(R=>R.id===w))==null?void 0:x.data.step,h=r.testOutputs??{},y=m?wt((S=r.actionDef)==null?void 0:S.call(r,m.uses.app,m.uses.action),h[w],(A=r.persistedOutputs)==null?void 0:A[w]):void 0;u.includes(w)||u.push(w);const g=((y==null?void 0:y.fields)??[]).map(R=>({key:`items.0.${R.key}`,path:!0,...R.declaredOnly?{declaredOnly:!0}:{}}));return{id:f.id,label:f.label,outputs:[{key:"items",path:!0},...g],...y?{outputsFrom:y.from}:{}}}),hasTrigger:l.hasTrigger,extraSampleIds:u,...l.eventOutputs?{eventOutputs:l.eventOutputs,eventOutputsFrom:l.eventOutputsFrom}:{}}}function Tp(e){const t=e.trim().split(".");if(!(t[0]!=="nodes"&&t[0]!=="steps"||t.length<4||t[2]!=="output"))return{id:t[1],path:t.slice(3).join(".")}}function Op(e,t,s){var f,p;const o=ut(e),r=o?Tp(o):void 0,a=r?(f=t.find(w=>w.id===r.id))==null?void 0:f.data.step:void 0;if(!r||!a)return;const i=(p=s.actionDef)==null?void 0:p.call(s,a.uses.app,a.uses.action),l=zt(i==null?void 0:i.sample,r.path),c=Array.isArray(l)&&l.length>0?l[0]:void 0,d=Np(i==null?void 0:i.output,r.path)??gt(c);if(!(c===void 0&&!d))return{...c!==void 0?{itemSample:c}:{},...d?{itemOutputs:d}:{}}}function Ti(e,t,s={},o=[]){const r=jr(e,t,s),a=gi(e,t,o);return a.length===0?r:{...r,outer:a.map(i=>({...jr(i,t,s),name:i}))}}function jr(e,t,s={}){var u,d,f;const o={foreachId:e},r=(d=(u=t.find(p=>p.id===e))==null?void 0:u.data.step.with)==null?void 0:d.items,a={...s.persistedOutputs??{},...s.testOutputs??{}},i=Sp(r,a),l=i&&i.length>0?i:(f=s.loopSamples)==null?void 0:f[e];if(l&&l.length>0){o.itemSample=l[0];const p=gt(l[0]);return p&&(o.itemOutputs=p),o}const c=Op(r,t,s);return(c==null?void 0:c.itemSample)!==void 0&&(o.itemSample=c.itemSample),c!=null&&c.itemOutputs&&(o.itemOutputs=c.itemOutputs),o}function Oi(e,t,s,o){return!e&&!!t&&!o.some(r=>r.target===t)&&Je(s,o)[t]===void 0}function Rp(e,t,s,o,r){let a=e;if(!a&&r&&!Oi(e,r,t,s)&&(a=r),!a)return Ci(new Set(t.map(c=>c.id)),t,o);const i=Je(t,s)[a],l=Ei(ko(a,s),i,t,s,o);return i&&!l.extraSampleIds.includes(i)&&l.extraSampleIds.push(i),{steps:l.steps,hasTrigger:l.hasTrigger,...l.eventOutputs?{eventOutputs:l.eventOutputs,eventOutputsFrom:l.eventOutputsFrom}:{},...i?{loop:Ti(i,t,o,s)}:{},...l.extraSampleIds.length>0?{extraSampleIds:l.extraSampleIds}:{}}}function Ip(e,t,s,o){if(!e||e.handleType==="target")return[];const r=ko(e.nodeId,s);r.add(e.nodeId);const a=Ri(e,t,s);return Ei(r,a,t,s,o).steps}function Ri(e,t,s){const o=t.find(r=>r.id===e.nodeId);return e.lane==="each"&&Se(o==null?void 0:o.data.step)?e.nodeId:Je(t,s)[e.nodeId]}function $p(e,t,s,o){if(!e||e.handleType==="target")return;const r=Ri(e,t,s);return r?Ti(r,t,o,s):void 0}async function _p(e,t){return(await Promise.all(t.map(async o=>{try{const r=await e(o.id),a=r.length?r[r.length-1]:null;return a?{stepId:o.id,label:o.label??o.id,test:a}:null}catch{return null}}))).filter(o=>o!==null)}function No(e,t,s){const o=Pp(e,t);return!s||Object.keys(s).length===0?o:{...o??{},state:s}}function Pp(e,t){const s={};for(const r of e){const a=r.test.lastRunOutput,i=a!=null;if(!i&&r.test.lastRunStatus!=="succeeded")continue;const l=r.test.lastRunMeta;s[r.stepId]={output:i?a:null,...l?{meta:l}:{}}}const o=Object.keys(s).length>0;return t?{...o?{steps:s}:{},foreach:{...t.item!==void 0?{item:t.item}:{},index:t.index??0,...t.loops?{loops:t.loops}:{}}}:o?{steps:s}:void 0}function Ii(e){if(!e)return;const t=o=>({..."itemSample"in o?{item:o.itemSample}:{},index:0}),s=[...e.outer??[],e];return{...t(e),loops:Object.fromEntries(s.map(o=>[o.foreachId,t(o)]))}}function Fp(e){return!e||!("itemSample"in e)?"":JSON.stringify(e.itemSample,null,2)??""}function Lp(e,t){let s;if(e.trim()!=="")try{s=JSON.parse(e)}catch{return{ok:!1,error:"The current item must be valid JSON."}}const o=t.trim()===""?0:Number(t.trim());return!Number.isInteger(o)||o<0?{ok:!1,error:"The index must be a whole number, 0 or more."}:{ok:!0,value:{...s!==void 0?{item:s}:{},index:o}}}function Dp(e,t){if(!t)return{};const s={};for(const o of["nodes","steps"]){const r=`${o}.${e}.meta`;s[`${r}.app`]=t.app,s[`${r}.version`]=t.version,s[`${r}.action`]=t.action,s[`${r}.connectionId`]=t.connectionId}return s}function Mp(e,t,s,o,r){return $i(e,t,s,o,r).values}function Wp(e,t,s,o,r){return $i(e,t,s,o,r).sources}function qp(e,t){var r,a,i,l;const s={};let o;for(const c of e){const u=c.data.step.uses;if(u.trigger===!0){const f=(a=(r=t.triggerDef)==null?void 0:r.call(t,u.app,u.action))==null?void 0:a.sample;o===void 0&&f!==void 0&&(o=f);continue}if(st(u.app))continue;const d=(l=(i=t.actionDef)==null?void 0:i.call(t,u.app,u.action))==null?void 0:l.sample;d!==void 0&&(s[c.id]=d)}return{samples:s,...o!==void 0?{event:o}:{}}}function $i(e,t,s,o,r={}){var l,c;const a={},i={};for(const u of e){Object.assign(a,Dp(u.id,s[u.id]));const d=[["sample",(l=r.samples)==null?void 0:l[u.id]],["persisted",(c=r.persisted)==null?void 0:c[u.id]],["fresh",t[u.id]]];for(const[f,p]of d){if(p===void 0)continue;const w=(m,h)=>{for(const y of["nodes","steps"])a[`${y}.${m}`]=h,i[`${y}.${m}`]=f};if(w(`${u.id}.output`,p),typeof p=="object"&&p!==null&&!Array.isArray(p))for(const[m,h]of Object.entries(p))w(`${u.id}.output.${m}`,h);for(const m of u.outputs??[]){if(!m.path||!m.key.includes("."))continue;const h=zt(p,m.key);h!==void 0&&w(`${u.id}.output.${m.key}`,h)}}}if(r.event!==void 0){const u=(d,f)=>{a[d]=f,i[d]="sample"};if(u("trigger.event",r.event),typeof r.event=="object"&&r.event!==null&&!Array.isArray(r.event))for(const[d,f]of Object.entries(r.event))u(`trigger.event.${d}`,f);for(const d of gt(r.event)??[]){const f=zt(r.event,d.key);f!==void 0&&u(`trigger.event.${d.key}`,f)}}if(o&&"itemSample"in o){a["foreach.item"]=o.itemSample;for(const u of o.itemOutputs??[]){const d=zt(o.itemSample,u.key);d!==void 0&&(a[`foreach.item.${u.key}`]=d)}a["foreach.index"]=0}return{values:a,sources:i}}function Bp(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=e;if(t.type==="secret"||t.type==="expr")return!0;const s=Object.keys(t);return s.length===1&&s[0]==="$"}function Up(e){const t=[];for(const s of e){const o=s.data.step,r=Object.entries(o.with??{}).filter(([,i])=>i!==void 0&&!Bp(i)).map(([i])=>i);(o.uses.app===He||o.uses.app===at||o.uses.trigger===!0)&&!r.includes("url")&&r.unshift("url"),r.length>0&&t.push({id:o.id,keys:r})}return t}function Cs(e){if(!(et(e)||lt(e))){if(Array.isArray(e))return e.map(Cs).filter(t=>t!==void 0);if(typeof e=="object"&&e!==null){const t=e,s=Object.keys(t);if(s.length===1&&s[0]==="$"&&typeof t.$=="string")return;const o={};for(const[r,a]of Object.entries(t)){const i=Cs(a);i!==void 0&&(o[r]=i)}return o}return e}}function Vp(e,t){const s={};for(const o of e){const r=o.data.step,a={...Cs(r.with??{})??{}},i=_i(r,t),l=(i==null?void 0:i.webhookUrl)??(i==null?void 0:i.formUrl);l&&(a.url=l),Object.keys(a).length>0&&(s[r.id]=a)}return s}function _i(e,t){if(e.uses.app===at)return oo(t,e.id)??void 0;if(!(e.uses.app!==He&&e.uses.trigger!==!0))return t.find(s=>s.nodeId===e.id)??(e.uses.app===He?t.find(s=>s.appId===He):void 0)}function Hp(e,t,s,o){var a;const r={};for(const i of e){const l=i.data.step;if(!l.uses.app)continue;const c={app:l.uses.app,action:l.uses.action,connectionId:Bt(l,o)??null},u=(a=s==null?void 0:s.get(l.uses.app))==null?void 0:a.version;u&&(c.version=u);const d=_i(l,t);d&&(c.subscriptionId=d.id),d!=null&&d.webhookUrl&&(c.url=d.webhookUrl),r[l.id]=c}return r}function Jp(e){const t={};for(const[s,o]of Object.entries(e))for(const[r,a]of Object.entries(o))t[`nodes.${s}.meta.${r}`]=a,t[`steps.${s}.meta.${r}`]=a;return t}function zp(e,t){const s={success:0,error:0};for(const r of t){if(r.source!==e)continue;const a=je(r);a!=="each"&&s[a]++}const o=Math.max(s.success,s.error);return{enabled:o>=2,count:o}}function Kp(e,t){const{fanOut:s,...o}=e;return t==="parallel"?{...o,fanOut:"parallel"}:o}function Gp(e,t){return`Runs these ${e} nodes in ${t==="parallel"?"parallel":"sequence"}`}function Pi({step:e,count:t,readOnly:s,onChange:o}){const r=t>=2,a=e.fanOut==="parallel"?"parallel":"sequential";return n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Run next nodes"}),n.jsxs("select",{"aria-label":"Run next nodes",value:a,disabled:s||!r,onChange:i=>o(Kp(e,i.target.value)),children:[n.jsx("option",{value:"sequential",children:"In sequence"}),n.jsx("option",{value:"parallel",children:"In parallel"})]}),!r&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Connect two or more steps after this one to choose how they run."})]})}function kr({to:e}){return n.jsxs("div",{className:"w6w-state-map-row w6w-state-map-head","aria-hidden":"true",children:[n.jsx("span",{children:"From this step output"}),n.jsx("span",{}),n.jsx("span",{children:e})]})}function Nr(){return n.jsx("span",{className:"w6w-state-map-arrow","aria-hidden":"true",children:"→"})}function Sr({label:e,fields:t,value:s,readOnly:o,onChange:r}){const a=b.useMemo(()=>(t??[]).map(i=>({value:i,label:i})),[t]);return n.jsx(Qe,{mode:"combobox",forceSelection:!1,"aria-label":e,placeholder:"Whole output, or e.g. order",options:a,value:s,disabled:o,emptyText:a.length>0?"No matching field — keep typing a path":"Test this step to list its output fields, or type a path",onChange:r})}function Fi({step:e,inLoop:t,outputFields:s,readOnly:o,onChange:r}){const a=Wd(e),i=ie.validateStateConfig(a),l=f=>r(Bd(e,f)),c=a.mode==="pick"&&Array.isArray(a.map)?a.map:[],u=(f,p)=>l({mode:"pick",map:c.map((w,m)=>m===f?{...w,...p}:w)}),d=f=>{if(a.mode!=="append")return;const p=f.path??a.path,w="from"in f?f.from:a.from;l({mode:"append",path:p,...w?{from:w}:{}})};return n.jsxs("div",{className:"w6w-field w6w-stack",children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Write to state"}),n.jsx("select",{"aria-label":"Write to state",value:a.mode,disabled:o,onChange:f=>l(Ud(e,f.target.value)),children:Dd.map(f=>n.jsx("option",{value:f,children:Md[f]},f))})]}),a.mode==="key"&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"To state key"}),n.jsx("input",{type:"text","aria-label":"State key",placeholder:"e.g. order",value:a.key,disabled:o,onChange:f=>l({mode:"key",key:f.target.value})}),n.jsxs("span",{className:"w6w-hint",children:["Copies the whole step output into ",n.jsx("code",{children:"state.<key>"}),". A dotted key such as"," ",n.jsx("code",{children:"order.id"})," nests."]})]}),a.mode==="pick"&&n.jsxs("div",{className:"w6w-stack",children:[n.jsx(kr,{to:"To state key"}),c.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No fields yet — add one below."}),c.map((f,p)=>n.jsxs("div",{className:"w6w-datavar-row w6w-state-map-row",children:[n.jsx(Sr,{label:"From output field",fields:s,value:f.from,readOnly:o,onChange:w=>u(p,{from:w})}),n.jsx(Nr,{}),n.jsx("input",{type:"text","aria-label":"To state path",placeholder:"e.g. order",value:f.to,disabled:o,onChange:w=>u(p,{to:w.target.value})}),!o&&n.jsx(no,{label:"Remove field",onClick:()=>l({mode:"pick",map:c.filter((w,m)=>m!==p)})})]},p)),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-state-map-add","aria-label":"Add field",onClick:()=>l({mode:"pick",map:[...c,{from:"",to:""}]}),children:"+ Add field"}),n.jsxs("span",{className:"w6w-hint",children:["Copies ",n.jsx("code",{children:"output.<path>"})," into ",n.jsx("code",{children:"state.<key>"}),". Leave the left side blank to copy the whole output."]})]}),a.mode==="append"&&n.jsxs("div",{className:"w6w-stack",children:[n.jsx(kr,{to:"Append to state list"}),n.jsxs("div",{className:"w6w-datavar-row w6w-state-map-row",children:[n.jsx(Sr,{label:"Output field to append",fields:s,value:a.from??"",readOnly:o,onChange:f=>d({from:f})}),n.jsx(Nr,{}),n.jsx("input",{type:"text","aria-label":"Append to state path",placeholder:"e.g. orders",value:a.path,disabled:o,onChange:f=>d({path:f.target.value})})]}),n.jsxs("span",{className:"w6w-hint",children:["Appends ",n.jsx("code",{children:"output.<path>"})," to the list at ",n.jsx("code",{children:"state.<key>"}),". Leave the left side blank to append the whole output."]})]}),i.length>0&&n.jsx("div",{role:"alert",className:"w6w-state-write-issues w6w-small",children:i.map(f=>n.jsx("div",{children:f.message},`${f.code}:${f.message}`))}),a.mode!=="off"&&n.jsxs("span",{className:"w6w-muted w6w-small",children:["Writing ",n.jsx("code",{children:"null"})," deletes the key, and secrets are stored masked."]}),t&&n.jsx("span",{className:"w6w-muted w6w-small",children:"This step is inside a For each, so it writes once per item — Append collects one entry per item."})]})}function So(e,t,s){const o=Ce(),[r,a]=b.useState([]),i=JSON.stringify(t.map(l=>[l.id,l.label]));return b.useEffect(()=>{const l=JSON.parse(i);if(!s||l.length===0){a([]);return}let c=!1;return _p(u=>o.listStepTests(e,u),l.map(([u,d])=>({id:u,label:d}))).then(u=>{c||a(u)}),()=>{c=!0}},[o,e,i,s]),r}function Co(e){return(e.nodes??e.steps??[]).filter(t=>t.uses.app===Mt&&t.uses.action==="manual")}function Yp(e,t){var a;const s=Co(e),o=t?s.find(i=>i.id===t):s[0],r=(a=o==null?void 0:o.with)==null?void 0:a.fields;return Array.isArray(r)?r.flatMap(i=>!i||typeof i!="object"||typeof i.key!="string"||!i.key.trim()?[]:[{key:i.key,label:i.key,type:ao(i.type),default:io(i.type,i.default),required:!!i.required}]):[]}const Xp=["function","workflow"],Zp={workflow:'<line x1="6" y1="3" x2="6" y2="15"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/>',function:'<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>'},ss={props:{label:"Form",icon:"form"},code:{label:"JSON",icon:"code"},"params-code":{label:"Params JSON",icon:"braces"},config:{label:"Node settings",icon:"settings-2"}},Qp=["props","code","params-code","config"];function Jn({view:e,onChange:t,disabled:s,views:o=Qp,customized:r=!1}){const a=i=>n.jsx("button",{type:"button",title:ss[i].label,"aria-label":ss[i].label,"aria-pressed":e===i,disabled:s,className:`w6w-icon-btn${e===i&&!s?" active":""}`,onClick:()=>t(i),children:n.jsx(le.Icon,{name:ss[i].icon,size:15})},i);return n.jsxs("div",{className:"w6w-view-toggle",children:[r&&n.jsx("button",{type:"button",className:"w6w-json-customized",disabled:s,onClick:()=>t("params-code"),title:"JSON customization adds or overrides form values",children:"JSON customized"}),o.map(a)]})}function ef({onClose:e,onDone:t,onAdd:s,onDraftChange:o,theme:r,appsOnly:a,callables:i=Xp,initialTab:l,title:c,workflowId:u,stepId:d,upstreamSteps:f=[],loop:p,initialApp:w,initialAction:m,initialConnection:h,initialWith:y,appsFilter:g,appsIds:x,connectionOnly:S,setupOnly:A,addLabel:R,onConnected:j,excludeCallableIds:N,onOpenStep:k,stepIds:_=[]}){const[q,O]=b.useState(null),[F,E]=b.useState(null),I=b.useRef(null),$=M=>{const re=s(M);return typeof re=="string"&&(I.current=M,O(re),E(null)),re},V=o?(M,re)=>{I.current=re,o(M,re)}:void 0,J=()=>{q&&F&&F!==q&&V&&I.current&&V(q,{...I.current,id:F}),(t??e)()},P=M=>q&&o?n.jsxs("span",{className:"w6w-stepbuilder-title",children:[M,n.jsx(La,{value:F??q,onCommit:re=>{const he=ji(re,_.filter(Oe=>Oe!==q));return he||E(re),he}})]}):M,[T,Z]=b.useState(l??"connected"),[K,ne]=b.useState(""),[U,G]=b.useState(!1),z=K.trim()!==""&&!U,D=M=>{Z(M),G(!0)},[te,ee]=b.useState(w??null),[C,H]=b.useState(null),[Q,ae]=b.useState(null),[Y,ke]=b.useState(null),we=M=>{if(!A)return ke(M);s({uses:{app:rn,action:"call"},with:{targetKind:M.family,targetId:M.id}})},ge=!!x&&x.length>0,ye=Mi(i,g,N,x),xe=ye.state!=="empty";if(b.useEffect(()=>{!xe&&T==="connected"&&Z("apps")},[xe,T]),Y)return n.jsx(Ee,{title:P(Y.label),ariaLabel:Y.label,subtitle:n.jsx("code",{children:Y.id}),onClose:e,size:"xl",headerRight:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>ke(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(lf,{family:Y.family,targetId:Y.id,targetLabel:Y.label,onAdd:$,onClose:e,onDone:J,onDraftChange:V})})});if(C)return n.jsx(Ee,{title:P(C.groupActions?C.displayName:C.label),ariaLabel:C.groupActions?C.displayName:C.label,titleIcon:n.jsx(Vn,{icon:C.icon,size:22}),subtitle:n.jsxs("code",{children:[C.app,!C.groupActions&&` · ${C.action}`]}),onClose:e,size:"xl",headerRight:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>H(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(af,{node:C,onAdd:$,onClose:e,onDone:J,onDraftChange:V,onOpenStep:k,workflowId:u,upstreamSteps:f,loop:p})})});const ue=Q??te;if(ue){const M=Q?"trigger":"action",re=()=>{ee(null),ae(null)};return n.jsx(Ee,{title:P(ue.displayName),ariaLabel:ue.displayName,subtitle:n.jsxs(n.Fragment,{children:[n.jsx("code",{children:ue.id}),ue.version&&` · v${ue.version}`]}),onClose:e,size:"xl",titleIcon:n.jsx(Nt,{src:ue.iconSvg,srcDark:ue.iconSvgDark,brandColor:ue.brandColor,name:ue.displayName,theme:r,size:22}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:S&&M==="action"?n.jsx(gf,{appId:ue.id,app:ue,onClose:e,onChangeApp:re,theme:r,initialConnection:h,onConnected:(he,Oe)=>j==null?void 0:j(he,Oe)}):n.jsx(bf,{kind:M,onOpenStep:k,appId:ue.id,app:ue,onAdd:$,onClose:e,onDone:J,onDraftChange:V,onChangeApp:re,theme:r,workflowId:u,stepId:d,upstreamSteps:f,loop:p,...M==="action"?{initialAction:m,initialConnection:h,initialWith:y}:{},setupOnly:A&&M==="action",addLabel:R})})})}return n.jsx(Ee,{title:c??"Add a node",onClose:e,size:"xl",children:n.jsxs("div",{className:"w6w-stepbuilder-picker",children:[n.jsx("input",{type:"search",className:"w6w-stepbuilder-search","aria-label":"Search nodes and apps",placeholder:"Search apps, workflows and nodes…",value:K,onChange:M=>{ne(M.target.value),G(!1)}}),n.jsxs("div",{className:"w6w-stepbuilder",children:[n.jsxs("nav",{className:"w6w-stepbuilder-sidebar",children:[xe&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="connected"?" active":""}`,onClick:()=>D("connected"),children:"Ready to use"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="apps"?" active":""}`,onClick:()=>D("apps"),children:"Apps"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="ai"?" active":""}`,onClick:()=>D("ai"),children:"AI"}),i.includes("workflow")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="workflows"?" active":""}`,onClick:()=>D("workflows"),children:"Workflows"}),i.includes("function")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="functions"?" active":""}`,onClick:()=>D("functions"),children:"Functions"}),!a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="triggers"?" active":""}`,onClick:()=>D("triggers"),children:"Triggers"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="controls"?" active":""}`,onClick:()=>D("controls"),children:"Controls"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="utilities"?" active":""}`,onClick:()=>D("utilities"),children:"Utilities"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="data"?" active":""}`,onClick:()=>D("data"),children:"Data"})]})]}),n.jsx("div",{className:"w6w-stepbuilder-content",children:z?n.jsx(tf,{query:K,builtIns:!a,callables:i,excludeCallableIds:N,appsFilter:g,appsIds:x,theme:r,onSelectNode:H,onSelectApp:ee,onSelectCallable:we}):T==="connected"?n.jsx(mf,{data:ye,query:K,appsFilter:g,onSelectApp:ee,onSelectCallable:we,theme:r}):T==="functions"?n.jsx(In,{family:"function",query:K,excludeIds:N,onSelect:M=>we({family:"function",...M})}):T==="workflows"?n.jsx(In,{family:"workflow",query:K,excludeIds:N,onSelect:M=>we({family:"workflow",...M})}):T==="apps"?n.jsx(ot,{search:!1,searchValue:K,onSelectApp:ee,theme:r,filter:g,ids:x}):T==="ai"?n.jsx(ot,{search:!1,searchValue:K,onSelectApp:ee,theme:r,category:ge?void 0:"ai",ids:x,filter:M=>{var re;return((g==null?void 0:g(M))??!0)&&(ge||(((re=M.categories)==null?void 0:re.includes("ai"))??!1))},emptyMessage:"No AI apps registered yet."}):T==="triggers"?n.jsx(nf,{query:K,onSelect:H,onSelectApp:ae,theme:r,appsFilter:g,appsIds:x}):T==="controls"?n.jsx(sf,{query:K,onSelect:H}):T==="data"?n.jsx(rf,{query:K,onSelect:H}):n.jsx(of,{query:K,onSelect:H})})]})]})})}function Kt(e,...t){const s=t.filter(Boolean).join(" ").toLowerCase();return e.trim().toLowerCase().split(/\s+/).every(o=>s.includes(o))}function Ao(e,t){return Kt(t,e.label,e.displayName,e.app,e.action)}function tf({query:e,builtIns:t,callables:s,excludeCallableIds:o,appsFilter:r,appsIds:a,theme:i,onSelectNode:l,onSelectApp:c,onSelectCallable:u}){const d=new Set,f=t?it.filter(p=>p.hidden||!Ao(p,e)?!1:p.groupActions?d.has(p.app)?!1:(d.add(p.app),!0):!0):[];return n.jsxs("div",{className:"w6w-stepbuilder-results","data-testid":"stepbuilder-search-all",children:[f.length>0?n.jsxs("section",{className:"w6w-stepbuilder-results-section",children:[n.jsx("h4",{children:"Built-in"}),n.jsx("div",{className:"w6w-stepbuilder-list",children:f.map(p=>n.jsx(To,{node:p,onSelect:l},`${p.app}:${p.action}`))})]}):null,n.jsxs("section",{className:"w6w-stepbuilder-results-section",children:[n.jsx("h4",{children:"Apps"}),n.jsx(ot,{search:!1,searchValue:e,onSelectApp:c,theme:i,filter:r,ids:a})]}),s.includes("workflow")?n.jsx(In,{section:!0,family:"workflow",query:e,excludeIds:o,onSelect:p=>u({family:"workflow",...p})}):null,s.includes("function")?n.jsx(In,{section:!0,family:"function",query:e,excludeIds:o,onSelect:p=>u({family:"function",...p})}):null]})}function Eo({nodes:e,onSelect:t,query:s}){const o=new Set,r=e.filter(a=>Ao(a,s)?a.groupActions?o.has(a.app)?!1:(o.add(a.app),!0):!0:!1);return r.length?n.jsx("div",{className:"w6w-stepbuilder-list",children:r.map(a=>n.jsx(To,{node:a,onSelect:t},`${a.app}:${a.action}`))}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No nodes match “",s,"”."]})}function To({node:e,onSelect:t}){return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item",onClick:()=>t(e),children:[n.jsx(Vn,{icon:e.icon,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:e.groupActions?e.displayName:e.label}),n.jsxs("code",{className:"w6w-muted w6w-small",children:[e.app,!e.groupActions&&` · ${e.action}`]})]})]})}function nf({query:e,onSelect:t,onSelectApp:s,theme:o,appsFilter:r,appsIds:a}){var m;const i=Ce(),l=it.filter(h=>h.group==="trigger"&&Ao(h,e)),[c,u]=b.useState(!1),d=Mi([],r,void 0,a,{resolveInline:!0});if(c)return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>u(!1),children:"← Back"}),n.jsx(ot,{onSelectApp:s,theme:o,filter:r,ids:a?[...a]:void 0,hasTriggers:!0,search:!1,searchValue:e,emptyMessage:"No apps declare triggers yet."})]});const p=d.apps.filter(h=>(h.triggerCount??0)>0&&Kt(e,h.displayName,h.id)).sort(Gt(h=>h.displayName)).map(h=>n.jsx(Wi,{app:h,theme:o,onSelect:s},h.id));d.moreApps&&p.push(n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:d.loadMoreApps,children:"Load more"},"__load_more_apps"));let w;return d.state==="error"?w=n.jsx("div",{className:"w6w-result w6w-error",children:d.error}):d.state==="loading"?w=n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}):e.trim()&&((m=d.appIds)!=null&&m.length)&&typeof i.listAppsPage=="function"?w=n.jsx(ot,{search:!1,searchValue:e,ids:d.appIds,hasTriggers:!0,filter:r,onSelectApp:s,theme:o}):p.length===0?w=n.jsxs("p",{className:"w6w-muted w6w-small w6w-readytouse-empty",children:[e.trim()?`No connected apps match “${e}”.`:"No connected apps with triggers yet"," ","·"," ",n.jsx("button",{type:"button",className:"w6w-linkbtn",onClick:()=>u(!0),children:"Search all apps"})]}):w=n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:p}),n.jsxs("div",{className:"w6w-apppicker-host",children:[n.jsxs("div",{className:"w6w-readytouse","data-cols":2,children:[n.jsxs("section",{className:"w6w-readytouse-col","data-col":"your-apps",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:"Your apps"}),w]}),n.jsx("div",{className:"w6w-readytouse-stack",children:n.jsxs("section",{className:"w6w-readytouse-col","data-col":"built-in",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:"Built-in"}),n.jsxs("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:[l.length===0&&n.jsxs("p",{className:"w6w-muted w6w-small",children:["No built-in triggers match “",e,"”."]}),l.map(h=>n.jsx(To,{node:h,onSelect:t},`${h.app}:${h.action}`))]})]})})]}),n.jsx("div",{className:"w6w-readytouse-footer",children:n.jsx("button",{type:"button",className:"w6w-btn",onClick:()=>u(!0),children:"Search all apps"})})]})}function sf({onSelect:e,query:t}){const s=it.filter(o=>o.group==="control"&&!o.hidden);return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Flow-control nodes branch, route, join paths, loop, parallelize, pause, or stop the run."}),n.jsx(Eo,{nodes:s,onSelect:e,query:t})]})}function of({onSelect:e,query:t}){const s=it.filter(o=>o.group!=="control"&&o.group!=="trigger"&&o.app!==Yt&&o.app!==_s&&o.app!==Ye&&!o.hidden);return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Run scripts, work with regular expressions, render templates, call models, or make HTTP requests."}),n.jsx(Eo,{nodes:s,onSelect:e,query:t})]})}function rf({onSelect:e,query:t}){const s=it.filter(o=>(o.app===Yt||o.app===Ye||o.app===_s)&&!o.hidden);return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Set data, read documents, read and write store entries, or query stored rows."}),n.jsx(Eo,{nodes:s,onSelect:e,query:t})]})}function af({node:e,onAdd:t,onClose:s,onDone:o,onDraftChange:r,onOpenStep:a,workflowId:i,upstreamSteps:l=[],loop:c}){var J,P;const[u,d]=b.useState(e),f=e.groupActions?it.filter(T=>T.app===e.app&&!T.hidden):[],[p,w]=b.useState(()=>An(u.app,u.action)),m=!$t(u.app),h=So(i??"",l,m&&!!i),y=(J=tt().stateShape)==null?void 0:J.written,g=No(h,Ii(c),y),[x,S]=b.useState("configure"),[A,R]=b.useState("props"),[j,N]=b.useState("{}"),[k,_]=b.useState({}),q=Dt(u.params,p),[O,F]=b.useState(null),E=()=>({uses:{app:u.app,action:u.action},with:p,...k});b.useEffect(()=>{if(!r)return;const T=t(E());T&&F(T),T&&(u.app===He||u.app===at)&&(a==null||a(T))},[]),b.useEffect(()=>{!r||O===null||r(O,E())},[O,p,k,u]);const I=T=>{T==="code"&&N(jo(E())),R(T)},$=()=>t(E()),V=i&&O!==null?{workflowId:i,stepId:O,input:{}}:void 0;return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsxs("div",{className:"w6w-tabsbar",children:[n.jsxs("div",{className:"w6w-subtabs",children:[n.jsx("button",{type:"button",className:`w6w-subtab${x==="configure"?" active":""}`,onClick:()=>S("configure"),children:"Configure"}),m&&n.jsx("button",{type:"button",disabled:!q,title:q?void 0:"Fill the required fields first",className:`w6w-subtab${x==="test"?" active":""}`,onClick:()=>q&&S("test"),children:"Test"})]}),n.jsx(Jn,{view:A,customized:Un(p),onChange:I,disabled:x!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[x==="configure"&&A==="props"&&f.length>1&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Action"}),n.jsx("select",{className:"w6w-input","aria-label":"Action",value:u.action,onChange:T=>{const Z=f.find(ne=>ne.action===T.target.value);if(!Z)return;const K=An(Z.app,Z.action);w(Object.fromEntries(Z.params.flatMap(ne=>ne.key in p?[[ne.key,p[ne.key]]]:ne.key in K?[[ne.key,K[ne.key]]]:[]))),d(Z)},children:f.map(T=>n.jsx("option",{value:T.action,children:T.label},T.action))})]}),x==="configure"&&(A==="props"?u.app===Wt?n.jsx("p",{className:"w6w-muted w6w-small",children:Mr}):u.action==="wait"&&$t(u.app)?n.jsx(si,{values:p,onChange:w}):u.action==="if"&&$t(u.app)?n.jsx(Bn,{values:p,onChange:w}):u.app===Ps?n.jsx(Da,{values:p,onChange:w}):u.app===Ze?n.jsx(Fa,{values:p,onChange:w}):n.jsx(qe,{params:u.params,values:p,onChange:w}):A==="code"?n.jsx(Xe,{value:j,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):A==="params-code"?n.jsx(to,{values:p,onChange:w}):n.jsx(Di,{step:{id:O??"",...E()},config:k,onChange:_,inLoop:c!==void 0,outputFields:(P=u.output)==null?void 0:P.map(T=>T.key),failureHandling:!Cn(u.app),retryControls:!$t(u.app)&&u.app!==rn})),x==="test"&&m&&(Cn(u.app)?n.jsx(ni,{app:u.app,action:u.action,fields:p.fields,persist:V},(V==null?void 0:V.stepId)??""):n.jsx(Oo,{app:u.app,action:u.action,values:p,canRun:q,state:g,persist:V},(V==null?void 0:V.stepId)??""))]}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),x==="configure"&&m?n.jsx("button",{type:"button",className:"w6w-btn",disabled:!q,onClick:()=>S("test"),children:"Next →"}):n.jsx("button",{type:"button",className:"w6w-btn",onClick:O!==null?o??s:$,children:O!==null?"Done":"Add node"})]})]})}function In({family:e,query:t,excludeIds:s,onSelect:o,section:r=!1}){const a=Ce(),[i,l]=b.useState(null),[c,u]=b.useState(null),d=e==="function"?"Functions":"Workflows";b.useEffect(()=>{let y=!1;return(e==="function"?a.listFunctions():a.listWorkflows()).then(x=>!y&&l(x)).catch(x=>!y&&u(x.message)),()=>{y=!0}},[a,e]);const f=y=>n.jsx("div",{className:"w6w-apppicker-host",children:y});if(r&&(c||i===null||i.length===0))return null;if(c)return f(n.jsx("div",{className:"w6w-result w6w-error",children:c}));if(i===null)return f(n.jsxs("p",{className:"w6w-muted w6w-small",children:["Loading ",d.toLowerCase(),"…"]}));if(i.length===0)return f(n.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",d.toLowerCase()," registered yet."]}));const p=_t,w=t.trim().toLowerCase(),m=As(i,s).sort(Gt(p)),h=w?m.filter(y=>p(y).toLowerCase().includes(w)||y.id.toLowerCase().includes(w)):m;return r?h.length===0?null:n.jsxs("section",{className:"w6w-stepbuilder-results-section",children:[n.jsx("h4",{children:d}),n.jsx("div",{className:"w6w-stepbuilder-list",children:h.map(y=>n.jsx($n,{family:e,item:y,onSelect:o},y.id))})]}):f(n.jsx("div",{className:"w6w-stepbuilder-apps",children:h.length===0?n.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",d.toLowerCase()," match “",t,"”."]}):n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:h.map(y=>n.jsx($n,{family:e,item:y,onSelect:o},y.id))})}))}function lf({family:e,targetId:t,targetLabel:s,onAdd:o,onClose:r,onDone:a,onDraftChange:i}){const[l,c]=b.useState({targetKind:e,targetId:t,inputs:{},wait:!0}),[u,d]=b.useState(!1),[f,p]=b.useState("configure"),[w,m]=b.useState(null),h=()=>({uses:{app:rn,action:"call"},with:l});b.useEffect(()=>{if(!i)return;const g=o(h());g&&m(g)},[]),b.useEffect(()=>{!i||w===null||i(w,h())},[w,l]);const y=()=>o(h());return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsx("div",{className:"w6w-tabsbar",children:n.jsxs("div",{className:"w6w-subtabs",children:[n.jsx("button",{type:"button",className:`w6w-subtab${f==="configure"?" active":""}`,onClick:()=>p("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!u,title:u?void 0:"Fill the required fields first",className:`w6w-subtab${f==="test"?" active":""}`,onClick:()=>u&&p("test"),children:"Test"})]})}),n.jsx("div",{className:"w6w-stepconfig-body",children:f==="configure"?n.jsx(Bi,{fixedTarget:!0,values:l,onChange:c,onValidityChange:d,targetLabel:s}):n.jsx(cf,{family:l.targetKind==="function"?"function":"workflow",targetId:String(l.targetId),inputs:l.inputs,entry:typeof l.entry=="string"?l.entry:void 0,canRun:u})}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:r,children:"Cancel"}),f==="configure"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:!u,onClick:()=>p("test"),children:"Next →"}):n.jsx("button",{type:"button",className:"w6w-btn",onClick:w!==null?a??r:y,children:w!==null?"Done":"Add node"})]})]})}function cf({family:e,targetId:t,inputs:s,entry:o,canRun:r}){const a=Ce(),[i,l]=b.useState(null),c=async()=>{if(!(!r||(i==null?void 0:i.status)==="running")){l({status:"running"});try{if(e==="function"){const u=await a.invokeFunction(t,s);l({status:"done",output:u,terminal:!0})}else{const u=await a.runWorkflow(t,{input:s,variables:s,entry:o});l({status:"done",output:u.output,runId:u.runId,terminal:u.terminal,error:u.error})}}catch(u){l({status:"error",error:u.message??String(u)})}}};return n.jsxs("div",{className:"w6w-steptest",children:[n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!r||(i==null?void 0:i.status)==="running",onClick:c,children:(i==null?void 0:i.status)==="running"?"Running…":"▶ Test run"}),!r&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),(i==null?void 0:i.status)==="error"&&n.jsx("div",{className:"w6w-result w6w-error",children:i.error}),(i==null?void 0:i.status)==="done"&&!i.terminal&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Still running"}),n.jsxs("div",{className:"w6w-result",children:["Run ",n.jsx("code",{children:i.runId})," has not finished yet — check its status from the workflow's run history."]})]}),(i==null?void 0:i.status)==="done"&&i.terminal&&i.error!==void 0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Run failed"}),n.jsx(le.Copyable,{value:JSON.stringify(i.error,null,2),label:"Copy error",children:n.jsx("pre",{className:"w6w-result w6w-error",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(i.error,null,2)})})]}),(i==null?void 0:i.status)==="done"&&i.terminal&&i.error===void 0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Result"}),n.jsx(Te,{value:i.output,maxHeight:220})]})]})}function uf(e){const t={};for(const s of e)rt(s.default)&&(t[s.key]=s.default);return t}function Dt(e,t){const s=_a(t);if(s===null)return!1;if(s===void 0)return!0;const o=Ft(e),r=i=>{var l;return s[i]!==void 0?s[i]:(l=o.find(c=>c.key===i))==null?void 0:l.default},a=(i,l,c)=>i.every(u=>{const d=ie.effectiveParam(u,c);if(d.type==="section")return a(d.children??[],l,c);if(d.type==="group"){const p=d.children??[],w=Ft(p),m=y=>g=>{const x=w.find(S=>S.key===g);return x?y[g]!==void 0?y[g]:x.default:c(g)};if(d.repeat){const y=Array.isArray(l[d.key])?l[d.key]:[];return y.length===0?!d.required:y.every(g=>{const x=g??{};return a(p,x,m(x))})}const h=l[d.key]??{};return a(p,h,m(h))}if(!d.required||!ln(u,c))return!0;const f=l[d.key]??d.default;return f==null?!1:typeof f=="string"?f.trim()!=="":!0});return a(e,s,r)}function Li(e){const t=e==null?void 0:e.testRequired;return typeof t=="boolean"?t:!0}function df(e){const t=e;return(t==null?void 0:t.body)??(t==null?void 0:t.raw)??{error:t==null?void 0:t.code,message:(t==null?void 0:t.message)??String(e)}}function pf(e){const t=e==null?void 0:e.apiCalls;return Array.isArray(t)?t:[]}function ff({log:e,onClose:t}){return n.jsx(Ee,{title:"Test run log",subtitle:e.startedAt,size:"wide",onClose:t,children:n.jsxs("div",{className:"w6w-modal-body w6w-stack",style:{gap:12},children:[n.jsxs("div",{className:"w6w-testout",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Request to w6w · ",e.request.method," ",e.request.path]}),n.jsx(Te,{value:e.request.body,maxHeight:320})]}),n.jsxs("div",{className:"w6w-testout",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Response from w6w ·"," ",e.response.ok?"ok":`failed${e.response.status?` (HTTP ${e.response.status})`:""}`," ","· ",e.durationMs,"ms"]}),n.jsx(Te,{value:e.response.body,maxHeight:320})]}),n.jsxs("div",{className:"w6w-testout",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Outbound API calls (",e.apiCalls.length,")"]}),e.apiCalls.length>0?n.jsx(di,{calls:e.apiCalls,title:!1,defaultOpen:!0}):n.jsxs("div",{className:"w6w-muted w6w-small",children:["No HTTP request reached the vendor API — the action",e.response.ok?" made no outbound call":" failed before sending one","."]})]})]})})}function Di({step:e,config:t,onChange:s,inLoop:o,outputFields:r,failureHandling:a,retryControls:i}){const l=c=>{const{state:u,fanOut:d,...f}=t;s({...f,...c.state!==void 0?{state:c.state}:{},...c.fanOut!==void 0?{fanOut:c.fanOut}:{}})};return n.jsxs("div",{className:"w6w-stack",children:[n.jsx($a,{config:t,onChange:c=>s({...t,...c}),failureHandling:a,retryControls:i}),n.jsx(Pi,{step:e,count:0,onChange:l}),mi(e)&&n.jsx(Fi,{step:e,inLoop:o,outputFields:r,onChange:l})]})}const Oo=b.forwardRef(function({app:t,action:s,connectionId:o,values:r,canRun:a,hideRunButton:i,persist:l,state:c,onBusyChange:u,onResult:d},f){const p=Ce(),w=Ms(),m=Yl(),[h,y]=b.useState(null),[g,x]=b.useState(null),[S,A]=b.useState(!1),R=b.useRef(!1),[j,N]=b.useState(null),k=l==null?void 0:l.workflowId,_=l==null?void 0:l.stepId,q=tt().nodeMeta,O=_?q==null?void 0:q[_]:void 0;b.useEffect(()=>{if(!k||!_)return;let I=!1;return p.listStepTests(k,_).then($=>{let V;for(const J of $)!J.lastRunAt||!J.lastRunStatus||(!V||Date.parse(J.lastRunAt)>Date.parse(V.lastRunAt))&&(V=J);!V||!V.lastRunAt||I||R.current||(V.lastRunStatus==="succeeded"?y({status:"done",value:V.lastRunOutput,...V.lastRunMeta?{meta:V.lastRunMeta}:{}}):y({status:"error",error:typeof V.lastRunError=="string"?V.lastRunError:V.lastRunError==null?"Test failed":JSON.stringify(V.lastRunError)}),N(V.lastRunAt))}).catch(()=>{}),()=>{I=!0}},[p,k,_]);const F=async()=>{var P;if(!a||(h==null?void 0:h.status)==="running")return;R.current=!0,N(null),y({status:"running"}),u==null||u(!0);let I;const $=new Date,V={method:"POST",path:`/apps/${encodeURIComponent(t)}/actions/${encodeURIComponent(s)}/invoke`,body:{params:r,...o?{connectionId:o}:{},...w?{project:w}:{},...c?{state:c}:{},...m?{workflowId:m}:{}}},J=T=>x({startedAt:$.toLocaleString(),durationMs:Date.now()-$.getTime(),request:V,response:T,apiCalls:pf(T.body)});try{const T=await p.invokeAction(t,s,r,{...o?{connectionId:o}:{},project:w,...c?{state:c}:{},...m?{workflowId:m}:{}});J({ok:!0,body:T}),I={status:"done",value:T.value,logs:T.logs,...T.meta?{meta:T.meta}:{}}}catch(T){const Z=T;J({ok:!1,...typeof Z.status=="number"?{status:Z.status}:{},body:df(T)}),I={status:"error",error:Z.message??String(T),errorCode:Z.code,logs:Z.logs}}if(y(I),d==null||d(I.status==="done"),l){(P=p.saveTestInput)==null||P.call(p,l.workflowId,l.stepId,co(l.input)).catch(T=>console.error("test input save failed",T));try{const T=await p.saveStepTest(l.workflowId,l.stepId,{input:l.input,with:r});await p.recordStepTestRun(l.workflowId,l.stepId,{stepTestId:T.id,status:I.status==="done"?"succeeded":"failed",input:l.input,output:I.status==="done"?I.value:void 0,error:I.status==="error"?I.error:void 0,...I.status==="done"&&I.meta?{meta:I.meta}:{}})}catch(T){console.error("step test persist failed",T)}}u==null||u(!1)};b.useImperativeHandle(f,()=>({run:F}));const E=h&&h.status!=="running"?h.logs:void 0;return n.jsxs("div",{className:"w6w-steptest",children:[(!i||g)&&n.jsxs("div",{className:"w6w-steptest-bar",children:[!i&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!a||(h==null?void 0:h.status)==="running",onClick:F,children:(h==null?void 0:h.status)==="running"?"Running…":"▶ Test run"}),g&&(h==null?void 0:h.status)!=="running"&&n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>A(!0),title:"The full request and response of the last test run",children:["Log",g.apiCalls.length>0?` (${g.apiCalls.length})`:""]}),!i&&!a&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),S&&g&&n.jsx(ff,{log:g,onClose:()=>A(!1)}),j&&((h==null?void 0:h.status)==="done"||(h==null?void 0:h.status)==="error")&&n.jsxs("div",{className:"w6w-muted w6w-small w6w-testout-restored",children:["Last run · ",new Date(j).toLocaleString()]}),(h==null?void 0:h.status)==="error"&&n.jsxs("div",{className:"w6w-result w6w-error",children:[h.errorCode&&n.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:n.jsx("code",{children:h.errorCode})}),h.error]}),(h==null?void 0:h.status)==="done"&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Result (return value)"}),n.jsx(Te,{value:h.value,maxHeight:220}),(h.meta||O)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),n.jsx(Te,{value:{...O,...h.meta},maxHeight:220})]})]}),(h==null?void 0:h.status)!=="done"&&(h==null?void 0:h.status)!=="running"&&O&&n.jsxs("div",{className:"w6w-testout","data-testid":"steptest-static-meta",children:[n.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),n.jsx(Te,{value:O,maxHeight:220})]}),E&&E.length>0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Console output"}),n.jsx(le.Copyable,{value:E.join(`
24
+ `),label:"Copy console output",children:n.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:E.join(`
25
+ `)})})]})]})}),Cr=12,hn=new Set;function Mi(e,t,s,o,r){const a=o&&o.length>0?new Set(o):null,i=U=>(a?a.has(U.id):!0)&&((t==null?void 0:t(U))??!0),l=Ce(),[c,u]=b.useState(null),[d,f]=b.useState(null),[p,w]=b.useState(null),[m,h]=b.useState(null),[y,g]=b.useState(null),[x,S]=b.useState(()=>new Map),[A,R]=b.useState(()=>new Set),[j,N]=b.useState(hn),k=b.useRef(hn),_=b.useCallback(U=>{k.current=U,N(U)},[]),q=b.useRef(hn),O=e.includes("function"),F=e.includes("workflow"),E=typeof l.listAppsByIds=="function";b.useEffect(()=>{let U=!1;const G=z=>!U&&g(z.message);return l.listConnections().then(z=>{if(U)return;const D=[],te=new Set,ee=new Map;for(const C of z)st(C.appId)||(E&&!(r!=null&&r.resolveInline)&&C.app&&!ee.has(C.appId)&&ee.set(C.appId,{...C.app,id:C.appId}),!te.has(C.appId)&&(te.add(C.appId),D.push(C.appId)));ee.size>0&&(q.current=new Set(ee.keys()),S(C=>new Map([...C,...ee])),R(C=>new Set([...C,...ee.keys()]))),u(D)}).catch(G),O?l.listFunctions().then(z=>!U&&w(z)).catch(G):w([]),F?l.listWorkflows().then(z=>!U&&h(z)).catch(G):h([]),()=>{U=!0}},[l,E,O,F,r==null?void 0:r.resolveInline]),b.useEffect(()=>{if(E)return;const U=l.listApps;if(typeof U!="function"){f([]);return}let G=!1;return U().then(z=>!G&&f(z)).catch(z=>!G&&g(z.message)),()=>{G=!0}},[l,E]);const I=b.useRef(!0);b.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const $=b.useCallback(U=>{const G=l.listAppsByIds;!G||U.length===0||k.current.size>0||(_(new Set(U)),G(U).then(z=>{I.current&&(_(hn),S(D=>{const te=new Map(D);for(const ee of z)te.set(ee.id,ee);return te}),R(D=>new Set([...D,...U])))}).catch(z=>I.current&&g(z.message)))},[l,_]),V=b.useRef(!1);b.useEffect(()=>{if(!E||c===null||V.current)return;const U=Qn(c,q.current,Cr);U.length!==0&&(V.current=!0,$(U))},[E,c,$]);const J=()=>{if(!E||c===null||k.current.size>0)return;const U=new Set([...A,...k.current]);$(Qn(c,U,Cr))};if(y)return{state:"error",error:y,apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:J};if(p===null||m===null)return{state:"loading",apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:J};const P=As(p,s),T=As(m,s);if(E){if(c===null)return{state:"loading",apps:[],fns:P,wfs:T,moreApps:!1,loadMoreApps:J};if(c.length>0&&A.size===0)return{state:"loading",apps:[],fns:P,wfs:T,moreApps:!1,loadMoreApps:J};const U=Jl(c,x).filter(i),G=j.size===0&&Qn(c,new Set([...A,...j]),1).length>0;return{state:U.length===0&&P.length===0&&T.length===0&&!G?"empty":"ready",apps:U,appIds:c.filter(D=>!a||a.has(D)),fns:P,wfs:T,moreApps:G,loadMoreApps:J}}if(d===null)return{state:"loading",apps:[],fns:P,wfs:T,moreApps:!1,loadMoreApps:J};const Z=new Set(c??[]),K=d.filter(U=>!st(U.id)&&i(U)&&(Z.has(U.id)||U.zeroCredential===!0));return{state:K.length===0&&P.length===0&&T.length===0?"empty":"ready",apps:K,fns:P,wfs:T,moreApps:!1,loadMoreApps:J}}function As(e,t){return t&&t.length>0?e.filter(s=>!t.includes(s.id)):[...e]}function Gt(e){return(t,s)=>e(t).localeCompare(e(s),void 0,{sensitivity:"base"})}function _t(e){const t=e.displayName;return t!=null&&t.trim()?t:"name"in e?e.name:e.id}function $n({family:e,item:t,onSelect:s}){const o=_t(t);return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-stepbuilder-item--callable","data-kind":e,onClick:()=>s({id:t.id,label:o}),children:[n.jsx(Vn,{icon:Zp[e],size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:o}),n.jsx("code",{className:"w6w-muted w6w-small",children:t.id})]})]})}function hf(e,t){return t.length===0?null:n.jsxs("section",{className:"w6w-readytouse-col",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:e}),n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:t})]},e)}function Wi({app:e,theme:t,onSelect:s}){return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item","data-kind":"app",onClick:()=>s(e),children:[n.jsx(Nt,{src:e.iconSvg,srcDark:e.iconSvgDark,brandColor:e.brandColor,name:e.displayName,theme:t,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:e.displayName}),n.jsx("code",{className:"w6w-muted w6w-small",children:e.id})]})]})}function mf({data:e,query:t,appsFilter:s,onSelectApp:o,onSelectCallable:r,theme:a}){var y;const i=Ce(),l=g=>n.jsx("div",{className:"w6w-apppicker-host",children:g});if(e.state==="error")return l(n.jsx("div",{className:"w6w-result w6w-error",children:e.error}));if(e.state==="loading")return l(n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}));const c=e.apps.filter(g=>Kt(t,g.displayName,g.id)).sort(Gt(g=>g.displayName)),u=e.fns.filter(g=>Kt(t,_t(g),g.id)).sort(Gt(_t)),d=e.wfs.filter(g=>Kt(t,_t(g),g.id)).sort(Gt(_t)),f=hf,p=c.map(g=>n.jsx(Wi,{app:g,theme:a,onSelect:o},g.id));e.moreApps&&p.push(n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:e.loadMoreApps,children:"Load more"},"__load_more_apps"));const w=t.trim()&&((y=e.appIds)!=null&&y.length)&&typeof i.listAppsPage=="function"?n.jsxs("section",{className:"w6w-readytouse-col",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:"Connected apps"}),n.jsx(ot,{search:!1,searchValue:t,ids:e.appIds,filter:s,onSelectApp:o,theme:a})]}):f("Connected apps",p),m=[f("Functions",u.map(g=>n.jsx($n,{family:"function",item:g,onSelect:x=>r({family:"function",...x})},g.id))),f("Workflows",d.map(g=>n.jsx($n,{family:"workflow",item:g,onSelect:x=>r({family:"workflow",...x})},g.id)))].filter(Boolean),h=(w?1:0)+(m.length>0?1:0);return l(h?n.jsxs("div",{className:"w6w-readytouse","data-cols":h,children:[w,m.length>0&&n.jsx("div",{className:"w6w-readytouse-stack",children:m})]}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["Nothing ready to use matches “",t,"”."]}))}function qi(e,t){var s;return(((s=e.getAppTriggers)==null?void 0:s.call(e,t))??Promise.resolve([])).then(o=>o.map(r=>({key:r.key,title:r.title,description:r.description,params:r.params??[],...r.webhook?{webhook:r.webhook}:{}})))}function wf({title:e,app:t}){return n.jsxs("p",{className:"w6w-muted w6w-small",children:[n.jsx("strong",{children:e})," runs when ",t," reports it, so there is nothing to run by hand. Publish the workflow to start listening."]})}function bf({kind:e="action",onOpenStep:t,appId:s,app:o,onAdd:r,onClose:a,onDone:i,onDraftChange:l,onChangeApp:c,theme:u,workflowId:d,stepId:f,upstreamSteps:p=[],loop:w,initialAction:m,initialConnection:h,initialWith:y,setupOnly:g=!1,addLabel:x="Add"}){var Me,ft;const S=Ce(),A=e==="trigger",R=A?"a trigger":"an action",[j,N]=b.useState(null),[k,_]=b.useState(null),[q,O]=b.useState(null),[F,E]=b.useState(null),[I,$]=b.useState(h??""),[V,J]=b.useState(),P=po(),T=b.useRef(P);T.current=P;const Z=V?Bt({uses:{app:s,action:"",connectionRef:V}},P==null?void 0:P.connections)??"":I,K=b.useCallback(se=>{J(void 0),$(se)},[]),[ne,U]=b.useState(m??""),[G,z]=b.useState(y??{}),D=b.useRef(null),[te,ee]=b.useState(!1),[C,H]=b.useState(!g&&m&&y?"configure":"setup"),[Q,ae]=b.useState("props"),[Y,ke]=b.useState("{}"),[we,ge]=b.useState({});b.useEffect(()=>{let se=!1;E(null);const Ne=A?qi(S,s):S.getAppActions(s);return Promise.all([S.getAppAuth(s),S.listConnectionsForApp(s),Ne]).then(([$e,W,ce])=>{if(se)return;const v=vr(s,$e,W);N($e),_(v),O(ce);const L=T.current,B=ii({id:f??"",uses:{app:s,action:""}},v,(L==null?void 0:L.nodes)??[],(L==null?void 0:L.connections)??{},h);B.connectionRef?J(B.connectionRef):K(B.connection??"")}).catch($e=>!se&&E($e.message)),()=>{se=!0}},[S,s,A,K,h,f]);const ye=async()=>{const se=await S.listConnectionsForApp(s);_(vr(s,j??[],se))},xe=(j??[]).filter(se=>se.available!==!1),ue=xe.some(se=>se.autoSatisfied===!0&&(se.type==="tenantAuth"||se.type==="jit")),M=ue&&!xe.some(se=>se.autoSatisfied===!0&&se.type==="tenantAuth"),re=xe.length>0&&!ue,he=(k??[]).length>0,Oe=j!==null&&k!==null&&re&&!he,[Re,_e]=b.useState(0),de=(q??[]).find(se=>se.key===ne),Be=A?hi(s,q,ne,G):null,Ut=[...q??[]].sort((se,Ne)=>(se.title??se.key).localeCompare(Ne.title??Ne.key,void 0,{sensitivity:"base"})),Ue=Li(o),[St,ze]=b.useState(!1);b.useEffect(()=>{if(!Ue||!d||!f)return;let se=!1;return S.listStepTests(d,f).then(Ne=>{!se&&Ne.some($e=>$e.lastRunStatus==="succeeded")&&ze(!0)}).catch(()=>{}),()=>{se=!0}},[S,Ue,d,f]);const dt=So(d??"",p,!!d),Ct=(Me=tt().stateShape)==null?void 0:Me.written,pt=No(dt,Ii(w),Ct),ve=!!ne&&(!re||he&&!!Z)&&(!Be||Be.selected.length>0),Pe=ve&&!!de&&Dt(de.params??[],G),At=ve,Fe=(k??[]).find(se=>se.id===Z);function De(){return{uses:{app:s,action:(de==null?void 0:de.key)??ne,...V?{connectionRef:V}:Z?{connection:Z}:{},...A?{trigger:!0}:{}},with:G,...we}}function Ke(){de&&r(De())}const[pe,nt]=b.useState(null);b.useEffect(()=>{if(!l||pe!==null||!ve||Be&&C==="setup")return;const se=r(De());se&&nt(se),se&&A&&(t==null||t(se))},[l,pe,ve,C]),b.useEffect(()=>{!l||pe===null||l(pe,De())},[pe,G,we,Z,V]);const Ve=se=>{se==="code"&&ke(jo(De())),ae(se)};return n.jsxs("div",{className:"w6w-stepconfig",children:[!g&&n.jsxs("div",{className:"w6w-tabsbar",children:[n.jsxs("div",{className:"w6w-subtabs",children:[n.jsx("button",{type:"button",className:`w6w-subtab${C==="setup"?" active":""}`,onClick:()=>H("setup"),children:"Setup"}),n.jsx("button",{type:"button",disabled:!ve,title:ve?void 0:"Complete Setup first",className:`w6w-subtab${C==="configure"?" active":""}`,onClick:()=>ve&&H("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!Pe,title:Pe?void 0:"Fill the required fields first",className:`w6w-subtab${C==="test"?" active":""}`,onClick:()=>Pe&&H("test"),children:"Test"})]}),n.jsx(Jn,{view:Q,customized:Un(G),onChange:Ve,disabled:C!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[C==="setup"&&n.jsxs("div",{className:"w6w-stack",children:[F&&n.jsx("div",{className:"w6w-result w6w-error",children:F}),j===null&&!F&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}),n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"App"}),n.jsxs("div",{className:"w6w-app-conn-row",ref:D,children:[n.jsxs("button",{type:"button",className:"w6w-app-conn-btn","aria-label":"App",onClick:c,disabled:!c,children:[o&&n.jsx(Nt,{src:o.iconSvg,srcDark:o.iconSvgDark,brandColor:o.brandColor,name:o.displayName,theme:u,size:20}),n.jsx("span",{className:"w6w-conn-label-name",children:(o==null?void 0:o.displayName)??s})]}),n.jsx(ui,{step:{id:pe??f??"",uses:{app:s,action:ne,...V?{connectionRef:V}:{connection:Z||void 0}}},conns:k,failed:!!F,open:te,onOpenChange:ee,anchorRef:D,onChangeConnection:K,onChangeConnectionRef:J,onConnectionCreated:()=>{ye()},createSignal:Re})]}),M&&(Fe==null?void 0:Fe.builtIn)&&n.jsx("span",{className:"w6w-hint",children:"Scheduled or queued runs need a stored connection. Choose one from the connection menu."})]}),Oe?n.jsxs(pi,{testId:"step-needs-connection",className:"w6w-sb-connect-gate",action:n.jsxs("button",{type:"button",className:"w6w-btn",onClick:()=>_e(se=>se+1),children:["Connect ",(o==null?void 0:o.displayName)??s]}),children:["Connect ",(o==null?void 0:o.displayName)??s," to choose ",R,"."]}):q!==null&&(q.length===0?n.jsx("p",{className:"w6w-muted w6w-small",children:A?"This app declares no triggers.":"This app exposes no actions."}):Be?n.jsx(fi,{choices:Be,onChange:se=>{U(Be.triggerKey),z(Ne=>({...Ne,actions:se}))}}):n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[A?"Trigger":"Action",ne?"":" *"]}),n.jsx(Qe,{value:ne,placeholder:`— pick ${R} —`,mode:"combobox",listMaxHeight:200,onChange:se=>{var Ne;U(se),z(uf(((Ne=(q??[]).find($e=>$e.key===se))==null?void 0:Ne.params)??[])),ze(!1)},options:Ut.map(se=>({value:se.key,label:`${se.title??se.key} (${se.key})`}))}),(de==null?void 0:de.description)&&n.jsx("span",{className:"w6w-hint",children:de.description})]}))]}),C==="configure"&&(de?Q==="props"?n.jsx(qe,{params:de.params??[],values:G,onChange:z,dynamic:{appId:s,actionKey:de.key,kind:A?"trigger":"action",connectionId:Z||void 0,appName:o==null?void 0:o.displayName}}):Q==="code"?n.jsx(Xe,{value:Y,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):Q==="params-code"?n.jsx(to,{values:G,onChange:z}):n.jsx(Di,{step:{id:f??"",...De()},config:we,onChange:ge,inLoop:w!==void 0,outputFields:(ft=wt(de,void 0))==null?void 0:ft.fields.map(se=>se.key),failureHandling:!A}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["Pick ",R," in Setup first."]})),C==="test"&&(de&&A?n.jsx(wf,{title:de.title??de.key,app:(o==null?void 0:o.displayName)??s}):de?n.jsx(Oo,{app:s,action:de.key,connectionId:Z||void 0,values:G,canRun:ve&&Dt(de.params??[],G),state:pt,onResult:ze}):n.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action in Setup first."}))]}),C==="test"&&n.jsx("div",{className:"w6w-stepconfig-testnote",children:Ue&&!St&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Not yet tested. You can publish without running a test."})}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:a,children:"Cancel"}),g?n.jsx("button",{type:"button",className:"w6w-btn","data-testid":"stepbuilder-setup-add",disabled:!ve,onClick:Ke,children:x}):C==="test"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:pe===null&&!At,onClick:pe!==null?i??a:Ke,children:pe!==null?"Done":"Add node"}):n.jsx("button",{type:"button",className:"w6w-btn",disabled:C==="setup"?!ve:!Pe,onClick:()=>H(C==="setup"?"configure":"test"),children:"Next →"})]})]})}function gf({appId:e,app:t,onClose:s,onChangeApp:o,theme:r,initialConnection:a,onConnected:i}){const l=Ce(),[c,u]=b.useState(null),[d,f]=b.useState(null),[p,w]=b.useState(null),[m,h]=b.useState(a??""),[y,g]=b.useState(!1),[x,S]=b.useState(!1);b.useEffect(()=>{let E=!1;return w(null),Promise.all([l.getAppAuth(e),l.listConnectionsForApp(e)]).then(([I,$])=>{if(E)return;u(I),f($),!(I??[]).some(J=>J.autoSatisfied===!0)&&$.length>0&&h($[0].id)}).catch(I=>!E&&w(I.message)),()=>{E=!0}},[l,e]);const A=async()=>{const E=await l.listConnectionsForApp(e);f(E),E.length>0&&h(I=>I||E[0].id)},R=(c??[]).filter(E=>E.available!==!1),j=R.some(E=>E.autoSatisfied===!0&&(E.type==="tenantAuth"||E.type==="jit")),N=j&&!R.some(E=>E.autoSatisfied===!0&&E.type==="tenantAuth"),k=R.length>0&&!j,_=(d??[]).length>0,q=!k||_&&!!m,O=(d??[]).find(E=>E.id===m),F=x||!m;return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsx("div",{className:"w6w-stepconfig-body",children:n.jsxs("div",{className:"w6w-stack",children:[p&&n.jsx("div",{className:"w6w-result w6w-error",children:p}),c===null&&!p&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}),n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"App"}),n.jsxs("div",{className:"w6w-conn-label",children:[t&&n.jsx(Nt,{src:t.iconSvg,srcDark:t.iconSvgDark,brandColor:t.brandColor,name:t.displayName,theme:r,size:20}),n.jsx("span",{className:"w6w-conn-label-name",children:(t==null?void 0:t.displayName)??e}),o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:o,children:"Change"})]})]}),c!==null&&j&&n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Connection"}),n.jsxs("div",{className:"w6w-conn-label",children:[n.jsx("span",{className:"w6w-conn-label-name",children:"Connected automatically — this app needs no connection for your organization."}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>g(!0),children:"Create connection"})]}),N&&n.jsx("span",{className:"w6w-hint",children:'A scheduled or queued run of this workflow still needs a connection configured on this step — use "Create connection" if this step will run on a schedule.'})]}),c!==null&&k&&(_?F?n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Connection"}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("select",{value:m,onChange:E=>{h(E.target.value),S(!1)},style:{flex:1},children:(d??[]).map(E=>n.jsxs("option",{value:E.id,children:[E.displayName||E.id," ",E.state?`(${E.state})`:""]},E.id))}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>g(!0),children:"+ New"})]})]}):n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Connection"}),n.jsxs("div",{className:"w6w-conn-label",children:[n.jsxs("span",{className:"w6w-conn-label-name",children:[(O==null?void 0:O.displayName)||(O==null?void 0:O.id)||m,O!=null&&O.state?` (${O.state})`:""]}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>S(!0),children:"Change"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>g(!0),children:"+ New"})]})]}):n.jsxs("div",{className:"w6w-result w6w-stepconfig-conn-empty",children:[n.jsx("div",{style:{marginBottom:8},children:"This app needs a connection before its actions can run."}),n.jsx("button",{type:"button",className:"w6w-btn",onClick:()=>g(!0),children:"Create connection"})]}))]})}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:!q||!t,onClick:()=>t&&i(m,t),children:"Next →"})]}),y&&n.jsx(Zs,{theme:r,initialAppId:e,onClose:()=>g(!1),onCreated:async({connectionId:E})=>{g(!1),h(E),S(!1),await A()}})]})}function Bi({values:e,onChange:t,readOnly:s,setupOnly:o,onValidityChange:r,targetLabel:a,fixedTarget:i}){var J,P;const l=Ce(),c=e.targetKind==="function"?"function":"workflow",u=typeof e.targetId=="string"?e.targetId:"",d=typeof e.entry=="string"?e.entry:void 0,f=e.inputs&&typeof e.inputs=="object"&&!Array.isArray(e.inputs)?e.inputs:{},p=rt(e.inputs)||typeof f.$=="string",[w,m]=b.useState([]),[h,y]=b.useState(),[g,x]=b.useState(),[S,A]=b.useState(),R=`${c}:${u}`;b.useEffect(()=>{if(i)return;let T=!1;return m([]),y(void 0),(c==="workflow"?l.listWorkflows():l.listFunctions()).then(Z=>{T||m(Z)}).catch(Z=>{T||y(String(Z.message??Z))}),()=>{T=!0}},[l,c,i]),b.useEffect(()=>{let T=!1;return x(void 0),A(void 0),u?((c==="workflow"?l.getWorkflow(u).then(K=>({key:R,workflow:K,fields:[],label:K.displayName||K.name||u})):l.getFunction(u).then(K=>({key:R,fields:K.inputs,label:K.displayName||K.id}))).then(K=>{T||x(K)}).catch(K=>{T||A(String(K.message??K))}),()=>{T=!0}):void 0},[l,u,c,R]);const j=(g==null?void 0:g.key)===R?g:void 0,N=j!=null&&j.workflow?Co(j.workflow):[],k=d??((J=N[0])==null?void 0:J.id),_=j!=null&&j.workflow?Yp(j.workflow,k):(j==null?void 0:j.fields)??[],O={...Object.fromEntries(_.filter(T=>T.default!==void 0).map(T=>[T.key,T.default])),...f},F=c==="function"||!d||N.some(T=>T.id===d),E=!!j&&F&&(p||Dt(_,O));b.useEffect(()=>{r==null||r(E)},[E,r]),b.useEffect(()=>{if(!j||s||o)return;const T=!p&&_.some(Z=>Z.default!==void 0&&!(Z.key in f));(!d&&k||T)&&t({...e,...k?{entry:k}:{},inputs:p?e.inputs:O})});const I=w.map(T=>({value:T.id,label:T.displayName||("name"in T?T.name:T.id)||T.id})).sort((T,Z)=>T.label.localeCompare(Z.label));u&&!I.some(T=>T.value===u)&&I.unshift({value:u,label:(j==null?void 0:j.label)||a||u});const $=u?(P=l.callableHref)==null?void 0:P.call(l,c,u):void 0,V=(T,Z)=>{const{target:K,entry:ne,...U}=e;t({...U,targetKind:T,targetId:Z,inputs:{}})};return n.jsxs("div",{className:"w6w-stack",children:[!i&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Target kind"}),n.jsxs("select",{className:"w6w-input",value:c,disabled:s,onChange:T=>V(T.target.value,""),children:[n.jsx("option",{value:"workflow",children:"Workflow"}),n.jsx("option",{value:"function",children:"Function"})]})]}),n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:c==="workflow"?"Workflow":"Function"}),i?n.jsx("span",{children:(j==null?void 0:j.label)||a||u}):n.jsx(Qe,{"aria-label":c==="workflow"?"Workflow":"Function",options:I,value:u,disabled:s,placeholder:`Choose a ${c}…`,onChange:T=>V(c,T)}),$&&n.jsxs("a",{className:"w6w-btn w6w-btn-ghost",href:$,target:"_blank",rel:"noopener noreferrer",children:["Open ",c," in new tab ↗"]})]}),h&&n.jsx("div",{className:"w6w-result w6w-error",children:h}),!o&&u&&n.jsxs(n.Fragment,{children:[S?n.jsx("div",{className:"w6w-result w6w-error",children:S}):j?n.jsxs(n.Fragment,{children:[c==="workflow"&&N.length>0&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Trigger"}),n.jsxs("select",{className:"w6w-input","aria-label":"Trigger",value:k,disabled:s,onChange:T=>t({...e,entry:T.target.value,inputs:{}}),children:[d&&!F&&n.jsxs("option",{value:d,children:[d," (unavailable)"]}),N.map(T=>n.jsxs("option",{value:T.id,children:[T.id," (",T.uses.app===Mt?"Manual":T.uses.action,")"]},T.id))]})]}),!F&&n.jsx("div",{className:"w6w-result w6w-error",children:"The selected trigger is unavailable. Choose another trigger."}),c==="workflow"&&N.length===0&&n.jsxs("p",{className:"w6w-muted w6w-small",children:[j.label," has no manual trigger. Add a manual trigger to that workflow to define its input fields."]}),n.jsx("span",{className:"w6w-small",children:"Inputs"}),_.length>0&&!p?n.jsx(qe,{params:_,values:O,readOnly:s,onChange:T=>t({...e,inputs:T})}):n.jsx(qe,{params:[{key:"inputs",label:"Input payload",type:"json"}],values:{inputs:e.inputs??{}},readOnly:s,onChange:T=>t({...e,inputs:T.inputs})})]}):n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading inputs…"}),n.jsx(qe,{params:[{key:"wait",label:"Wait for completion",type:"boolean",default:!0,hint:"On: wait for the workflow or function to finish and return its output. Off: return a run handle and continue."}],values:e,readOnly:s,onChange:t})]})]})}const yf=/^(#{1,6})\s+(.*)$/,xf=new RegExp("\\*\\*(?=\\S)(.+?)(?<=\\S)\\*\\*","g");function vf(e,t){const s=e.ownerDocument;e.replaceChildren();for(const o of t.split(`
26
+ `)){const r=yf.exec(o),a=s.createElement(r?`h${r[1].length}`:"div"),i=r?r[2]:o;let l=0;for(const c of i.matchAll(xf)){c.index>l&&a.append(s.createTextNode(i.slice(l,c.index)));const u=s.createElement("strong");u.textContent=c[1],a.append(u),l=c.index+c[0].length}l<i.length&&a.append(s.createTextNode(i.slice(l))),a.firstChild||a.append(s.createElement("br")),e.append(a)}}function jf(e){var o;const t=(o=e.style)==null?void 0:o.fontWeight;if(!t)return;if(t==="bold"||t==="bolder")return!0;const s=Number(t);return Number.isFinite(s)?s>=600:!1}function kf(e){const t=[];for(const s of e){const o=t[t.length-1];o&&o.bold===s.bold?o.text+=s.text:t.push({...s})}return t.map(({text:s,bold:o})=>{const r=s.trim();if(!o||!r)return s;const a=s.slice(0,s.indexOf(r)),i=s.slice(a.length+r.length);return`${a}**${r}**${i}`}).join("")}function Nf(e){const t=[];let s=null;const o=i=>(s={level:i,runs:[]},t.push(s),s),r=(i,l,c)=>{if(i.nodeType===3){const h=(i.textContent??"").replace(/ /g," ").replace(/\n/g,"");h&&(s??o(l)).runs.push({text:h,bold:c});return}if(i.nodeType!==1)return;const u=i,d=u.tagName.toLowerCase();if(d==="br"){s||o(l),s=null;return}const f=/^h([1-6])$/.exec(d),p=f||["div","p","li","ul","ol","blockquote","pre"].includes(d);p&&(s=null);const w=f?Number(f[1]):l,m=d==="b"||d==="strong"?!0:jf(u)??c;for(const h of u.childNodes)r(h,w,m);p&&(s=null)};for(const i of e.childNodes)r(i,0,!1);const a=t.map(i=>{const l=kf(i.runs);return i.level>0?`${"#".repeat(i.level)} ${l.trimStart()}`:l});for(;a.length&&a[a.length-1].trim()==="";)a.pop();return a.join(`
27
+ `)}function Sf(e){return e.replace(/([^\n])\n(?=[^\n])/g,`$1
28
+ `)}const Cf=-2,Af=-1,Ar=1e3,Ef=["#facc15","#fb923c","#f87171","#f472b6","#a78bfa","#60a5fa","#2dd4bf","#4ade80","#9ca3af"],Tf=[{level:1,label:"Title"},{level:2,label:"Heading"},{level:3,label:"Subheading"},{level:0,label:"Body"}],Of=80,Rf=48,Er=10,If=4,os=e=>e.stopPropagation();function $f(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),t.removeAllRanges(),t.addRange(s)}function _f(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),s.collapse(!1),t.removeAllRanges(),t.addRange(s)}function Ui({canvas:e,className:t,viewport:s,readOnly:o,zoom:r=1,onChange:a,onSectionDrop:i,onRequestDelete:l}){const[c,u]=b.useState({}),[d,f]=b.useState(null),[p,w]=b.useState(null),[m,h]=b.useState(null),[y,g]=b.useState(null),x=b.useRef(null),S=b.useRef(null),A=b.useRef(null);if(b.useEffect(()=>{if(!d&&!p)return;const C=d?`[data-note-id="${d}"], [data-note-toolbar="${d}"]`:`[data-section-label="${p}"], [data-section-toolbar="${p}"]`,H=Q=>{var ke,we;const ae=Q.target;if((ke=ae==null?void 0:ae.closest)!=null&&ke.call(ae,C))return;const Y=document.activeElement;(we=Y==null?void 0:Y.closest)!=null&&we.call(Y,"[data-section-toolbar]")&&Y.blur(),f(null),w(null),g(null)};return window.addEventListener("pointerdown",H,!0),()=>window.removeEventListener("pointerdown",H,!0)},[d,p]),!s)return null;const R=!o&&!!a,j=e.sections??[],N=e.notes??[],k=C=>c[C.id]??{x:C.position.x,y:C.position.y,w:C.size.width,h:C.size.height},_=C=>{const H=k(C);return{left:H.x,top:H.y,width:H.w,height:H.h,"--w6w-canvas-color":C.color}},q=(C,H)=>a==null?void 0:a({...e,notes:N.map(Q=>Q.id===C?{...Q,...H}:Q)}),O=(C,H)=>a==null?void 0:a({...e,sections:j.map(Q=>Q.id===C?{...Q,...H}:Q)}),F=C=>{const H=S.current,Q=N.find(Y=>Y.id===C);if(!(H!=null&&H.isConnected)||!Q)return;const ae=Nf(H);ae!==Q.content&&q(C,{content:ae})},E=C=>{w(null),f(C)},I=C=>{f(null),w(C)},$=(C,H)=>{A.current=H??null,E(C),h(C),g(null)},V=C=>H=>{if(!H||H.dataset.ready==="1")return;H.dataset.ready="1",S.current=H,vf(H,C.content),H.focus();const Q=A.current;A.current=null,Q?($f(H),Q(),F(C.id)):_f(H)},J=(C,H,Q)=>{var Y;g(null);const ae=()=>document.execCommand(H,!1,Q);m===C&&((Y=S.current)!=null&&Y.isConnected)?(ae(),F(C)):$(C,ae)},P=C=>C.mode==="move"?{...C.base,x:C.base.x+C.dx,y:C.base.y+C.dy}:{...C.base,w:Math.max(Of,C.base.w+C.dx),h:Math.max(Rf,C.base.h+C.dy)},T=(C,H,Q,ae)=>{if(!R||C.button!==0)return;C.stopPropagation(),C.preventDefault();const Y={kind:Q,id:H.id,mode:ae,sx:C.clientX,sy:C.clientY,base:k(H),dx:0,dy:0};x.current=Y;const ke=ge=>{Y.dx=(ge.clientX-Y.sx)/(r||1),Y.dy=(ge.clientY-Y.sy)/(r||1),u(ye=>({...ye,[Y.id]:P(Y)}))},we=()=>{if(window.removeEventListener("pointermove",ke),window.removeEventListener("pointerup",we),x.current=null,u(xe=>{const{[Y.id]:ue,...M}=xe;return M}),Y.dx===0&&Y.dy===0)return;const ge=P(Y),ye={position:{x:ge.x,y:ge.y},size:{width:ge.w,height:ge.h}};Y.kind==="section"&&Y.mode==="move"&&i?i(Y.id,{dx:Y.dx,dy:Y.dy}):Y.kind==="note"?q(Y.id,ye):O(Y.id,ye)};window.addEventListener("pointermove",ke),window.addEventListener("pointerup",we)},Z=t?` ${t}`:"",K="nopan nodrag nowheel",ne=R?N.find(C=>C.id===d):void 0,U=R?j.find(C=>C.id===p):void 0,G=r||1,z=C=>{const H=k(C);return{left:H.x+H.w/2,top:H.y,transform:`translate(-50%, calc(-100% - ${Er/G}px)) scale(${1/G})`,transformOrigin:"50% 100%","--w6w-canvas-color":C.color}},D=(C,H)=>{const Q=k(C);return{left:Q.x,top:Q.y,transform:`translate(0, calc(-100% - ${H/G}px)) scale(${1/G})`,transformOrigin:"0 100%","--w6w-canvas-color":C.color}},te=(C,H,Q,ae)=>n.jsxs("div",{className:"w6w-note-menu w6w-note-menu-colors",role:"menu",children:[Ef.map(Y=>n.jsx("button",{type:"button",role:"menuitemradio","aria-checked":Y===C,"aria-label":`Colour ${Y}`,title:Y,className:`w6w-note-swatch-btn${Y===C?" active":""}`,style:{"--w6w-canvas-color":Y},"data-testid":`${Q}-option`,"data-color":Y,onClick:()=>{g(null),Y!==C&&ae(Y)}},Y)),n.jsx("label",{className:"w6w-note-swatch-btn w6w-note-swatch-custom",title:"Custom",children:n.jsx("input",{type:"color","aria-label":`Custom ${H} colour`,"data-testid":`${Q}-input`,value:C,onChange:Y=>ae(Y.currentTarget.value)})})]}),ee=C=>{C.target.closest("input")||C.preventDefault()};return Nn.createPortal(n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`w6w-canvas-layer w6w-canvas-sections${Z}`,style:{zIndex:Cf},"data-testid":"w6w-canvas-sections",children:[j.map(C=>n.jsx("div",{className:`w6w-canvas-section${p===C.id?" selected":""}`,style:_(C),"data-section-id":C.id,"data-testid":"section",children:R&&n.jsx("div",{className:`w6w-note-resize ${K}`,"data-testid":"section-resize",onPointerDown:H=>T(H,C,"section","resize")})},C.id)),j.map(C=>(U==null?void 0:U.id)===C.id?null:n.jsx("div",{className:`w6w-canvas-section-title${R?` editable ${K}`:""}`,style:D(C,If),"data-section-label":C.id,"data-testid":"section-label",title:R?"Click to edit · drag to move":void 0,onPointerDown:R?H=>{I(C.id),T(H,C,"section","move")}:void 0,children:C.title||(R?"Untitled section":"")},C.id))]}),n.jsx("div",{className:`w6w-canvas-layer w6w-canvas-notes${Z}`,style:{zIndex:Af},"data-testid":"w6w-canvas-notes",children:N.map(C=>{const H=R&&m===C.id;return n.jsxs("div",{className:`w6w-canvas-note${d===C.id?" selected":""}`,style:_(C),"data-note-id":C.id,"data-testid":"note",children:[H?n.jsx("div",{ref:V(C),className:`w6w-canvas-note-body w6w-canvas-note-editor ${K}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":"true","aria-label":"Note content","data-testid":"note-content",onPointerDown:os,onBlur:()=>{F(C.id),S.current=null,h(null)},onKeyDown:Q=>{Q.key==="Escape"&&Q.currentTarget.blur()},onPaste:Q=>{Q.preventDefault(),document.execCommand("insertText",!1,Q.clipboardData.getData("text/plain"))}},"editor"):n.jsx("div",{className:`w6w-canvas-note-body ${K}`,"data-testid":"note-view",style:R?{cursor:"grab",touchAction:"none"}:void 0,onPointerDown:R?Q=>{E(C.id),T(Q,C,"note","move")}:void 0,onDoubleClick:R?()=>$(C.id):void 0,children:C.content.trim()?n.jsx(so,{content:Sf(C.content)}):R&&n.jsx("span",{className:"w6w-canvas-note-empty",children:"Double-click to write"})},"view"),R&&n.jsx("div",{className:`w6w-note-resize ${K}`,"data-testid":"note-resize",onPointerDown:Q=>T(Q,C,"note","resize")})]},C.id)})}),U&&n.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:Ar},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar w6w-section-toolbar ${K}`,role:"toolbar","aria-label":"Section","data-testid":"section-toolbar","data-section-toolbar":U.id,style:D(U,Er),onPointerDown:os,onMouseDown:ee,children:[n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-grip","aria-label":"Move section",title:"Drag to move","data-testid":"section-drag",onPointerDown:C=>T(C,U,"section","move"),children:n.jsx(le.Icon,{name:"grip"})}),n.jsx("input",{type:"text",className:"w6w-section-title-input","aria-label":"Section title",placeholder:"Untitled section","data-testid":"section-title",defaultValue:U.title,size:Math.max(8,Math.min(32,U.title.length+1)),onBlur:C=>{const H=C.currentTarget.value;H!==U.title&&O(U.id,{title:H})},onKeyDown:C=>{(C.key==="Enter"||C.key==="Escape")&&C.currentTarget.blur()}},`${U.id}:${U.title}`),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsxs("div",{className:"w6w-note-toolbar-group",children:[n.jsxs("button",{type:"button",className:`w6w-icon-btn${y==="color"?" active":""}`,"aria-label":"Section colour","aria-expanded":y==="color",title:"Colour","data-testid":"section-color",onClick:()=>g(y==="color"?null:"color"),children:[n.jsx("span",{className:"w6w-note-swatch"}),n.jsx(le.Icon,{name:"chevron-down",size:12})]}),y==="color"&&te(U.color,"section","section-color",C=>O(U.id,{color:C}))]}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-delete","aria-label":"Delete section",title:"Delete section","data-testid":"section-delete",onClick:()=>{g(null),l==null||l("section",U.id)},children:n.jsx(le.Icon,{name:"trash"})})]})}),ne&&n.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:Ar},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar ${K}`,role:"toolbar","aria-label":"Note","data-testid":"note-toolbar","data-note-toolbar":ne.id,style:z(ne),onPointerDown:os,onMouseDown:ee,children:[n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-grip","aria-label":"Move note",title:"Drag to move","data-testid":"note-drag",onPointerDown:C=>T(C,ne,"note","move"),children:n.jsx(le.Icon,{name:"grip"})}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsxs("div",{className:"w6w-note-toolbar-group",children:[n.jsxs("button",{type:"button",className:`w6w-icon-btn${y==="color"?" active":""}`,"aria-label":"Note colour","aria-expanded":y==="color",title:"Colour","data-testid":"note-color",onClick:()=>g(y==="color"?null:"color"),children:[n.jsx("span",{className:"w6w-note-swatch"}),n.jsx(le.Icon,{name:"chevron-down",size:12})]}),y==="color"&&te(ne.color,"note","note-color",C=>q(ne.id,{color:C}))]}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsxs("div",{className:"w6w-note-toolbar-group",children:[n.jsxs("button",{type:"button",className:`w6w-icon-btn w6w-note-size-btn${y==="size"?" active":""}`,"aria-label":"Text size","aria-expanded":y==="size",title:"Text size","data-testid":"note-size",onClick:()=>g(y==="size"?null:"size"),children:["Aa",n.jsx(le.Icon,{name:"chevron-down",size:12})]}),y==="size"&&n.jsx("div",{className:"w6w-note-menu w6w-note-menu-sizes",role:"menu",children:Tf.map(C=>n.jsx("button",{type:"button",role:"menuitem",className:`w6w-note-menu-item w6w-note-size-${C.level}`,"data-testid":`note-size-${C.level}`,onClick:()=>J(ne.id,"formatBlock",C.level?`<h${C.level}>`:"<div>"),children:C.label},C.level))})]}),n.jsx("button",{type:"button",className:"w6w-icon-btn","aria-label":"Bold",title:"Bold","data-testid":"note-bold",onClick:()=>J(ne.id,"bold"),children:n.jsx(le.Icon,{name:"bold"})}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-delete","aria-label":"Delete note",title:"Delete note","data-testid":"note-delete",onClick:()=>{g(null),l==null||l("note",ne.id)},children:n.jsx(le.Icon,{name:"trash"})})]})})]}),s)}function Pf(e){const t=rs.useStore(o=>{var r;return((r=o.domNode)==null?void 0:r.querySelector(".react-flow__viewport"))??null}),s=rs.useStore(o=>o.transform[2]);return n.jsx(Ui,{...e,zoom:e.zoom??s,viewport:t})}function Ff(e){return e.viewport!==void 0?n.jsx(Ui,{...e,viewport:e.viewport}):n.jsx(Pf,{...e})}function Lf({title:e,message:t,onConfirm:s,onClose:o,confirmLabel:r="Confirm",cancelLabel:a="Cancel",destructive:i=!0,pending:l=!1,autoFocusConfirm:c=!1,children:u}){const d=b.useRef(null);return b.useEffect(()=>{var f;c&&((f=d.current)==null||f.focus())},[c]),n.jsxs(Ee,{title:e,onClose:()=>{l||o()},children:[n.jsxs("div",{className:"w6w-modal-body",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:t}),u]}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:o,disabled:l,children:a}),n.jsx("button",{ref:d,type:"button",className:i?"w6w-btn w6w-btn-danger":"w6w-btn",onClick:s,disabled:l,children:r})]})]})}function sn(e){if(!e||typeof e!="object")return null;switch(e.type){case"string":return"";case"number":return 0;case"boolean":return!1;case"object":{const t={};for(const[s,o]of Object.entries(e.fields??{}))t[s]=sn(o);return t}case"array":return e.items?[sn(e.items)]:[];default:return null}}function Df(e){const t={};for(const s of e??[])s&&typeof s.nodeId=="string"&&s.nodeId!==""&&(t[s.nodeId]=s);return t}function zn(e){return e.sampleOmitted!==!0&&"sample"in e&&e.sample!==void 0}function Kn(e,t){if(!t)return!1;const s=Date.parse(e.updatedAt),o=Date.parse(t);return Number.isFinite(s)&&Number.isFinite(o)&&s>o}function Vi(e,t,s,o){const r=t[e],a=s[e];return r!==void 0&&(!a||!Kn(a,o==null?void 0:o[e]))||!a?r:zn(a)?a.sample:sn(a.shape)}function Mf(e,t,s){const o={};for(const r of new Set([...Object.keys(e),...Object.keys(t)])){const a=Vi(r,e,t,s);a!==void 0&&(o[r]=a)}return o}function Wf(e,t,s){const o={...e};for(const[r,a]of Object.entries(t))zn(a)&&(e[r]===void 0||Kn(a,s==null?void 0:s[r]))&&(o[r]=a.sample);return o}function qf(e,t,s){const o={...e},r={};for(const[a,i]of Object.entries(t))e[a]!==void 0&&!Kn(i,s==null?void 0:s[a])||(delete o[a],r[a]=zn(i)?i.sample:sn(i.shape));return{fresh:o,persisted:r}}function Bf(e,t,s){const o={...e},r={};for(const[a,i]of Object.entries(t))zn(i)&&(e[a]===void 0||Kn(i,s==null?void 0:s[a]))&&(delete o[a],r[a]=i.sample);return{fresh:o,persisted:r}}function Uf(e,t){if(e.app)return e.app;if(e.app!==null)return t.get(e.appId)}function Vf(e){const t=new Set;for(const s of e)s.app===void 0&&t.add(s.appId);return[...t]}exports.AddConnectionModal=Zs;exports.AnchoredFlyout=oi;exports.ApiCallsPanel=di;exports.AppConnectionForm=Uu;exports.AppIcon=Nt;exports.AppPicker=ot;exports.AuthFieldsForm=gn;exports.AuthGuide=ga;exports.CALL_APP=rn;exports.CHOICE_FIELD_TYPES=Ts;exports.CONDITION_OPS=$r;exports.CONTROL_APP=We;exports.CallTargetForm=Bi;exports.CanvasLayer=Ff;exports.CodeEditor=qs;exports.Combobox=Qe;exports.ConditionEditor=Bn;exports.ConfigViewToggle=Jn;exports.ConfirmModal=Lf;exports.CredentialPicker=va;exports.DATA_APP=Yt;exports.DataTable=Ba;exports.DelegationSteps=Xs;exports.DeleteButton=no;exports.EACH_SOURCE_HANDLE=_n;exports.EDITOR_THEME_SPEC=Ws;exports.ERROR_SOURCE_HANDLE=Rs;exports.EmptyState=pi;exports.EventbriteTriggerPicker=fi;exports.ExpressionEditorModal=an;exports.ExpressionInput=en;exports.ExpressionOptionsProvider=Zc;exports.FIELD_TYPE_LABELS=Pr;exports.FOREACH_DONE_ROUTE=yt;exports.FORM_APP=at;exports.HTML_PREVIEW_CSP=Ua;exports.HtmlPreview=Ha;exports.INTERNAL_NODES=it;exports.IconButton=Mn;exports.InternalIcon=Vn;exports.JsonEditor=Xe;exports.LastUsedNote=ti;exports.Markdown=so;exports.Modal=Ee;exports.NodeConfigForm=$a;exports.ParamCustomization=to;exports.ParamsForm=qe;exports.PropertyEntryForm=Ma;exports.PublisherBadge=Ur;exports.RACE_APP=Wt;exports.RACE_DESCRIPTION=Mr;exports.RESULT_RENDER_MAX_CHARS=js;exports.ROUTER_APP=Ze;exports.ResultViewer=Te;exports.RetryPolicyFields=Ia;exports.RouterEditor=Fa;exports.SCHEDULER_APP=$s;exports.SCRIPT_APP=Dr;exports.SecretJsonField=ba;exports.StepBuilderModal=ef;exports.StepFanOutControl=Pi;exports.StepNameEditor=La;exports.StepStateControl=Fi;exports.StepTestRun=Oo;exports.StopEditor=Da;exports.TEXT_FIELD_TYPES=Qi;exports.TRIGGER_APP=Mt;exports.TriggerFillForm=ni;exports.TriggerSampleButton=Wa;exports.W6WUIProvider=Kl;exports.WEBHOOK_APP=He;exports.WaitEditor=si;exports.WorkflowConnectionPicker=ui;exports.WorkflowConnectionsContext=ci;exports.WorkflowProjectProvider=Gl;exports.ancestorIds=ko;exports.applyConnect=Qd;exports.applyStepProblems=Od;exports.asFieldDefs=ro;exports.bindingFieldsFor=ja;exports.bridgeDeletedBodyStep=zd;exports.buildBinding=ka;exports.buildResolveScope=Bs;exports.callableTriggers=Co;exports.canConnect=vi;exports.centralizeConnections=ai;exports.coerceDefault=io;exports.conditionCombinatorLabel=Ju;exports.conditionOperatorLabel=Hu;exports.connectConflict=ep;exports.connectRefusal=tp;exports.connectionAppIdsToLookUp=Vf;exports.connectionExpressionSources=Fd;exports.connectionIdFor=Bt;exports.controlOwnedIds=fo;exports.convertCodeBindingsToReads=su;exports.customCssTemplate=rl;exports.dataVarRows=On;exports.declaredSamples=qp;exports.deepEqual=ps;exports.defaultConnectionFor=ii;exports.defaultFormDefinition=_r;exports.definitionLoops=bo;exports.deleteStepMessage=Zd;exports.detectResultFormat=Ka;exports.edgeLane=je;exports.edgeVisuals=on;exports.edgeWhenConflict=sp;exports.editConnectionResources=yn;exports.effectiveEdges=wo;exports.effectiveNodeOutput=Vi;exports.effectiveNodeOutputs=Mf;exports.eventbriteTriggerChoices=hi;exports.excludeSelfStep=Xc;exports.fanOutLabel=Gp;exports.fanOutState=zp;exports.fieldWidget=ao;exports.fieldsToParams=lo;exports.filterOptions=Gr;exports.findChainRoot=yp;exports.findChainTail=xp;exports.findCodeBindings=fa;exports.findTestInput=Xa;exports.flattenParams=Ft;exports.flowToWorkflow=wp;exports.foreachTestFixture=Ap;exports.foreachTestSample=Ep;exports.getTriggerDefs=qi;exports.hasParamCustomization=Un;exports.htmlPreviewSrcDoc=Va;exports.idClashMessage=ip;exports.ifPortLayout=xl;exports.indexNodeSamples=Df;exports.inferOutputFields=gt;exports.internalNodeDef=xt;exports.internalNodeDefaults=An;exports.internalNodeIcon=ql;exports.internalNodeLabel=Wl;exports.internalNodeParams=Wr;exports.isConnectionBlocked=$d;exports.isControlApp=$t;exports.isDollarPath=Us;exports.isEachLink=Rn;exports.isExprValue=et;exports.isFloatingDraft=Oi;exports.isForeachStep=Se;exports.isFormResolvedOptions=Fn;exports.isIfStep=Ls;exports.isInputField=Ir;exports.isInternalApp=st;exports.isParamVisible=ln;exports.isSecretValue=lt;exports.isTestRequired=Li;exports.isTriggerApp=Cn;exports.isTriggerStep=vl;exports.keyClientId=ya;exports.laneForSourceHandle=ul;exports.loopBody=ho;exports.loopItemText=Fp;exports.loopMembership=Je;exports.loopRefusal=yi;exports.loopRefusalMessage=Yd;exports.newField=al;exports.nextWorkflowConnectionName=uo;exports.nodeConfigSources=Up;exports.nodeConfigValues=Vp;exports.nodeMetaSampleValues=Jp;exports.nodeMetaValues=Hp;exports.nodePortsForStep=Xt;exports.normalizeInput=vo;exports.parseFormDefinition=il;exports.parseJsonFields=wa;exports.parseLoopSeed=Lp;exports.parseRootAnchoredTemplate=ct;exports.pickFormSubscription=oo;exports.pickWebhookSubscription=Ya;exports.previewCustomization=Pa;exports.previewNodeOutputs=Wf;exports.relaneRefusal=op;exports.relayoutNodes=mp;exports.rememberableInput=co;exports.renameStepInEdges=rp;exports.requiredParamsFilled=Dt;exports.resolveConnectionAppMeta=Uf;exports.resolveLoopItemsInState=Ai;exports.resolveOutputShape=wt;exports.resolveParamJson=Zt;exports.resolveParamValue=Hs;exports.resolveVarsJson=Sc;exports.resultCopyText=Ga;exports.routeFromHandle=wl;exports.routeHandle=qt;exports.routerPortLayout=yl;exports.routesForStep=Fs;exports.secretClipboard=xs;exports.seedValues=ks;exports.selectNodeConnection=_d;exports.setEdgeWhen=np;exports.shapeToSkeleton=sn;exports.shouldUseCombobox=Kr;exports.slugName=Fr;exports.slugifyLabel=gp;exports.splitFrontmatter=qa;exports.splitNodeOutputs=qf;exports.splitPreviewOutputs=Bf;exports.stampLoopOf=Xd;exports.startOAuthPopup=Na;exports.startStateFromSeeds=No;exports.stateWriteVisible=mi;exports.stepBuilderLoop=$p;exports.stepBuilderUpstreamSteps=Ip;exports.stepNameError=ji;exports.stepProblemTooltip=Id;exports.stepToJson=jo;exports.storedViewport=Ni;exports.stripBody=mo;exports.suggestStepId=vp;exports.testInputSavesSettled=Qa;exports.trackTestInputSave=Za;exports.uniqueName=Os;exports.upstreamSampleValueSources=Wp;exports.upstreamSampleValues=Mp;exports.upstreamStateSources=Rp;exports.useEffectiveTheme=Pn;exports.useEnterSubmit=Sa;exports.useExpressionOptions=tt;exports.useRememberedTestInput=ei;exports.useSeedSources=So;exports.useW6WApi=Ce;exports.useWorkflowConnections=po;exports.valueAtPath=zt;exports.varLabel=bt;exports.withConnectionRef=nn;exports.withViewport=bp;exports.workflowToFlow=hp;
29
+ //# sourceMappingURL=connection-app-meta-Dk6F3KEH.cjs.map