@w6w/ui 0.2.66 → 0.2.68
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.
- package/CHANGELOG.md +19 -1
- package/README.md +5 -3
- package/dist/{CodeBlock-C1IC5_6O.cjs → CodeBlock-85y9qvE3.cjs} +4 -4
- package/dist/{CodeBlock-C1IC5_6O.cjs.map → CodeBlock-85y9qvE3.cjs.map} +1 -1
- package/dist/{CodeBlock-CsdRXzb0.js → CodeBlock-a5QVaIGk.js} +158 -131
- package/dist/{CodeBlock-CsdRXzb0.js.map → CodeBlock-a5QVaIGk.js.map} +1 -1
- package/dist/FormBuilder.d.ts +19 -0
- package/dist/ManualWebhookPanel.d.ts +34 -0
- package/dist/NodeConfigForm.d.ts +8 -2
- package/dist/StepBuilderModal.d.ts +2 -0
- package/dist/TriggerFillForm.d.ts +3 -0
- package/dist/WebhookListenPanel.d.ts +8 -1
- package/dist/code.cjs +1 -1
- package/dist/code.mjs +1 -1
- package/dist/components/AuthFieldsForm.d.ts +10 -0
- package/dist/components/AuthGuide.d.ts +19 -1
- package/dist/components/CallableList.d.ts +30 -4
- package/dist/components/Combobox.d.ts +5 -0
- package/dist/components/ExecutionLogDock.d.ts +44 -0
- package/dist/components/ExecutionLogPanel.d.ts +66 -0
- package/dist/components/ExecutionLogView.d.ts +30 -0
- package/dist/components/ExpressionOptions.d.ts +22 -0
- package/dist/components/icons.d.ts +1 -1
- package/dist/connection-app-meta-DID4zDg-.cjs +29 -0
- package/dist/connection-app-meta-DID4zDg-.cjs.map +1 -0
- package/dist/{connection-app-meta-CKBbgN7e.js → connection-app-meta-mmyKM3H9.js} +5725 -4161
- package/dist/connection-app-meta-mmyKM3H9.js.map +1 -0
- package/dist/dynamic-fields.d.ts +3 -0
- package/dist/flow-types.d.ts +27 -1
- package/dist/flow.cjs +8 -5
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.mjs +3681 -2463
- package/dist/flow.mjs.map +1 -1
- package/dist/form-schema.d.ts +270 -0
- package/dist/form-trigger.d.ts +8 -0
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.mjs +1766 -1343
- package/dist/index.mjs.map +1 -1
- package/dist/provider.d.ts +14 -0
- package/dist/resolve-params.d.ts +2 -0
- package/dist/types.d.ts +17 -1
- package/dist/workflow-connections.d.ts +11 -0
- package/package.json +2 -2
- package/src/styles/_callable-list.scss +37 -3
- package/src/styles/_connections.scss +29 -0
- package/src/styles/_execution-log-view.scss +322 -0
- package/src/styles/_expression-modal.scss +7 -0
- package/src/styles/_form-builder.scss +245 -0
- package/src/styles/_sections.scss +29 -0
- package/src/styles.css +725 -7
- package/src/styles.scss +2 -0
- package/dist/connection-app-meta-CKBbgN7e.js.map +0 -1
- package/dist/connection-app-meta-DfA6Yqhh.cjs +0 -28
- package/dist/connection-app-meta-DfA6Yqhh.cjs.map +0 -1
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),b=require("react"),ie=require("@w6w/expr"),gn=require("@codemirror/lang-javascript"),yr=require("@codemirror/lang-python"),Ns=require("@codemirror/view"),gr=require("@uiw/react-codemirror"),ue=require("./CodeBlock-C1IC5_6O.cjs"),xr=require("@codemirror/lang-json"),jo=require("@codemirror/lint"),xn=require("react-dom"),es=require("@xyflow/react"),Ci=require("react-markdown");var Jn=typeof document<"u"?document.currentScript:null;const Ai={ai:"AI",cms:"CMS",crm:"CRM",hr:"HR",devops:"DevOps"};function Ei(e){if(typeof e!="string"||e.trim()==="")return"";const t=Ai[e];return t||e.split(/[-_\s]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function Ti(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:Ei(s),count:o})).sort((s,o)=>o.count-s.count||s.label.localeCompare(o.label,void 0,{sensitivity:"base"}))}function Ri(e,t){if(t.length===0)return!0;const s=e.categories??[];return t.some(o=>s.includes(o))}function en(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 ks="out-error",Rn="out-each",yt="done",vr="each";function Ss(e){return e==="error"?ks:e==="each"?Rn:void 0}function Oi(e){return e===ks?"error":e===Rn?"each":"success"}const Ii="@w6w/",Le="@w6w/control",jr="@w6w/script",Jt="@w6w/data",Pt="@w6w/trigger",$i="@w6w/http",Be="@w6w/webhook",Cs="@w6w/scheduler",Pi="@w6w/respond",tn="@w6w/call",As="@w6w/document",an="@w6w/model",_i="@w6w/template",ln="@w6w/regex",ze="@w6w/store",Ct="@w6w/csv",Fi="@w6w/files",Es="@w6w/stop",Ge="@w6w/router",_t="@w6w/race",Nr="Continue once with the first arriving path’s output. Later arrivals are ignored for this run. Other paths keep running.";function Ts(e){var t;return e.uses.app!==Ge||!Array.isArray((t=e.with)==null?void 0:t.routes)?[]:e.with.routes.filter(s=>!!s&&typeof s=="object"&&typeof s.id=="string")}const Ft=e=>`route:${e}`,Li=e=>e!=null&&e.startsWith("route:")?e.slice(6):void 0,Mi=3,Di=16;function Wi(e){const t=e.find(r=>r.default),s=r=>({id:r.id,handleId:Ft(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>Mi?{minHeight:o.length*Di}:{}}}const vn="false";function Rs(e){return e.uses.app===Le&&e.uses.action==="if"}function Bi(){return{right:[{id:"true",label:"True",top:"50%"}],bottom:{id:vn,handleId:Ft(vn),label:"False"}}}function ot(e){return e.startsWith(Ii)}function Et(e){return e===Le||e===_t}function jn(e){return e===Pt||e===Be||e===Cs}function qi(e){return jn(e.app)||e.trigger===!0}const No={in:1,out:Number.POSITIVE_INFINITY};function ko(e){return e==="many"?Number.POSITIVE_INFINITY:typeof e=="number"?e:void 0}function Ui(...e){let t,s;for(const o of e)t??(t=ko(o==null?void 0:o.in)),s??(s=ko(o==null?void 0:o.out));return{in:t??No.in,out:s??No.out}}function zt(e,t){var a;if(e.uses.app===Ge)return{in:1,out:Ts(e).length};const{app:s,action:o}=e.uses,r=e.uses.trigger?{in:0,out:1}:void 0;return Ui(e.ports,t==null?void 0:t(s,o),((a=gt(s,o))==null?void 0:a.ports)??r)}const Vi='<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',So='<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" />',Hi='<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" />',Ji='<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" />',zi='<circle cx="12" cy="12" r="9" /><polyline points="12 7 12 12 15 14" />',Ki='<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" />',Gi='<polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" />',Co='<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" />',Yi='<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" />',Xi='<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" />',Zi='<polyline points="9 17 4 12 9 7" /><path d="M20 18v-2a4 4 0 0 0-4-4H4" />',Ao='<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',Qi='<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" />',el='<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" />',tl='<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" />',nl='<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" />',ht='<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" />',At='<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" />',sl='<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" />',ol=[{app:ln,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:ln,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:ln,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:ln,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"}]}],rl=[{app:Ct,action:"from-json",label:"From JSON",displayName:"CSV",groupActions:!0,group:"compute",icon:At,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:Ct,action:"create",label:"Create table",displayName:"CSV",groupActions:!0,group:"compute",icon:At,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:Ct,action:"add-rows",label:"Add rows",displayName:"CSV",groupActions:!0,group:"compute",icon:At,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:Ct,action:"remove-rows",label:"Remove rows",displayName:"CSV",groupActions:!0,group:"compute",icon:At,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:Ct,action:"to-text",label:"To CSV text",displayName:"CSV",groupActions:!0,group:"compute",icon:At,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:Ct,action:"parse",label:"Parse CSV",displayName:"CSV",groupActions:!0,group:"compute",icon:At,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=[...ol,...rl,{app:_t,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:Ge,action:"route",label:"Router",displayName:"Router",group:"control",icon:So,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:Es,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:Pt,action:"manual",label:"Manual trigger",displayName:"Manual trigger",group:"trigger",icon:Vi,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:Be,action:"webhook",label:"Webhook",displayName:"Webhook",group:"trigger",icon:Xi,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:Cs,action:"schedule",label:"Schedule",displayName:"Scheduler",group:"trigger",icon:Ki,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:Le,action:"if",label:"If",displayName:"If",group:"control",icon:So,params:[{key:"condition",type:"json",label:"Condition",required:!0,default:!0,hint:"A boolean, or an expression like {{ nodes.x.output.ok }}."}]},{app:Le,action:"foreach",label:"For each",displayName:"For each",group:"control",icon:Hi,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:Le,action:"parallel",label:"Parallel",displayName:"Parallel",group:"control",icon:Ji,params:[]},{app:Le,action:"wait",label:"Wait",displayName:"Wait",group:"control",icon:zi,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:jr,action:"run",label:"Run script",displayName:"Run script",group:"compute",icon:Gi,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.
|
|
2
|
-
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:_i,action:"render",label:"Render template",displayName:"Template",group:"compute",icon:nl,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:Jt,action:"set",label:"Data",displayName:"Data set",group:"compute",icon:Co,params:[{key:"vars",type:"vars",label:"Variables",required:!0,default:[],hint:"Set values for downstream steps using individual fields or a JSON object."}]},{app:Jt,action:"update",label:"Update object",displayName:"Update object",group:"compute",icon:Co,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:$i,action:"request",label:"HTTP request",displayName:"HTTP",group:"request",icon:Yi,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:Pi,action:"respond",label:"Respond to Webhook",displayName:"Respond to Webhook",group:"request",icon:Zi,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:Le,action:"aggregate",label:"Aggregate",displayName:"Aggregate",group:"control",icon:Ao,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:Le,action:"merge",label:"Merge",displayName:"Merge",group:"control",icon:Ao,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:tn,action:"call",label:"Call workflow",displayName:"Call",group:"compute",icon:Qi,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:As,action:"get",label:"Get document",displayName:"Document",group:"compute",icon:el,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:an,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:an,action:"agent",label:"Run agent",displayName:"Agent",group:"compute",icon:tl,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:an,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:an,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:ze,action:"get",label:"Get entry",displayName:"Store",group:"compute",icon:ht,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:ze,action:"set",label:"Set entry",displayName:"Store",group:"compute",icon:ht,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:ze,action:"delete",label:"Delete entry",displayName:"Store",group:"compute",icon:ht,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:ze,action:"increment",label:"Increment counter",displayName:"Store",group:"compute",icon:ht,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:ze,action:"list",label:"List entries",displayName:"Store",group:"compute",icon:ht,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:ze,action:"query",label:"Query rows",displayName:"Store",group:"compute",icon:ht,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:ze,action:"insert",label:"Insert row",displayName:"Store",group:"compute",icon:ht,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:Fi,action:"save",label:"Save file",displayName:"Files",group:"compute",icon:sl,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 gt(e,t){return it.find(s=>s.app===e&&s.action===t)}function al(e,t){var s;return((s=gt(e,t))==null?void 0:s.label)??t}function il(e,t){var s;return((s=gt(e,t))==null?void 0:s.icon)??""}function kr(e,t){var s;return((s=gt(e,t))==null?void 0:s.params)??[]}function Nn(e,t){const s={};for(const o of kr(e,t))o.default!==void 0&&(s[o.key]=o.default);return s}function ll(e,t){return e.q===t.q&&(e.category??"")===(t.category??"")&&(e.ids??[]).join(",")===(t.ids??[]).join(",")}function Sr(e,t=0){return{query:e,generation:t,status:"loading",apps:[],hasMore:!1}}function cl(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 ul(e,t){switch(t.type){case"query-changed":return t.generation===e.generation&&ll(t.query,e.query)?e:Sr(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=cl(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 dl(e){return e.filter(t=>!ot(t.id))}function Kn(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 pl(e,t){const s=[];for(const o of e){const r=t.get(o);r&&s.push(r)}return s}const Cr=b.createContext(void 0);function Eo(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 On(e){const t=b.useContext(Cr),[s,o]=b.useState(()=>Eo(e,t));return b.useEffect(()=>{if(e){o(e);return}if(t){o(t);return}if(typeof window>"u")return;const r=()=>o(Eo(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=On(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(p=>{var f;return((f=p[0])==null?void 0:f.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 fl={w6w:"by W6W",verified:"Verified publisher"};function Ar({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:fl[o]}),o==="w6w"?null:n.jsx("span",{className:"w6w-publisher-app-badge-name",children:e.displayName})]})}const Os=b.createContext(null);function hl({api:e,theme:t,children:s}){const o=n.jsx(Os.Provider,{value:e,children:n.jsx(Cr.Provider,{value:t,children:s})});return t?n.jsx("div",{"data-theme":t,style:{display:"contents"},children:o}):o}function ke(){const e=b.useContext(Os);if(!e)throw new Error("useW6WApi must be used inside <W6WUIProvider>. Wrap your app root with <W6WUIProvider api={api}>...</W6WUIProvider>.");return e}function Dt(){return b.useContext(Os)??void 0}const Er=b.createContext(void 0),Tr=b.createContext(void 0);function ml({project:e,workflowId:t,children:s}){return n.jsx(Er.Provider,{value:e,children:n.jsx(Tr.Provider,{value:t,children:s})})}function Is(){return b.useContext(Er)}function wl(){return b.useContext(Tr)}const Gn=8,bl=60,yl=300;function To(e){const t=e.modelProvider;return!t||typeof t!="object"?null:t}function gl(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 rt({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:p=!1,bridgeSupport:f,category:m,hasTriggers:w,publisher:h,publisherFilter:g=!1,onPublisherChange:y,ids:x,pageLimit:S=bl,loadPage:A}){const R=ke(),j=u!==void 0,k=x&&x.length>0?x.join(","):"",N=!j&&(A!==void 0||typeof R.listAppsPage=="function"),F=b.useRef(A);F.current=A;const[U,O]=b.useState(null),[_,E]=b.useState(null);b.useEffect(()=>{if(j||N)return;const D=R.listApps;if(typeof D!="function"){O([]);return}let v=!1;return D().then(P=>!v&&O(P)).catch(P=>!v&&E(P.message)),()=>{v=!0}},[R,j,N]);const[I,$]=b.useReducer(ul,Sr({q:"",category:m,ids:x},0)),[V,H]=b.useState(""),L=i??V,T=D=>{i===void 0&&H(D),l==null||l(D)},[Z,Y]=b.useState(L.trim()),te=b.useRef(0),B=b.useRef(null),[G,z]=b.useState(void 0),M=h!==void 0?h:G,ee=D=>{h===void 0&&z(D),y==null||y(D)},Q=b.useCallback((D,v,P)=>{var oe;const W=F.current,se=R.listAppsPage;if(!W&&!se)return;(oe=B.current)==null||oe.abort();const be=new AbortController;B.current=be;let fe;try{fe=W?W({q:D.q||void 0,cursor:P,limit:S,...D.ids?{ids:D.ids}:{},signal:be.signal}):se({q:D.q||void 0,category:D.category,...w?{hasTriggers:!0}:{},...M?{publisher:M}:{},...D.ids?{ids:D.ids}:{},cursor:P,limit:S,compact:!0,signal:be.signal})}catch(pe){fe=Promise.reject(pe)}fe.then(pe=>{if(te.current===v){if(!pe||!Array.isArray(pe.apps)){$({type:"page-failed",generation:v,error:"The server returned a malformed apps page."});return}$({type:"page-loaded",generation:v,apps:pe.apps,nextCursor:pe.nextCursor,requestedCursor:P,total:typeof pe.total=="number"?pe.total:void 0})}}).catch(pe=>{if(te.current!==v||pe instanceof Error&&pe.name==="AbortError")return;const ft=pe==null?void 0:pe.code;if(P!==void 0&&(ft==="snapshot_expired"||ft==="unknown_snapshot")){const rn=++te.current;$({type:"query-changed",query:D,generation:rn}),Q(D,rn,void 0);return}$({type:"page-failed",generation:v,error:pe.message})})},[R,S,w,M]);b.useEffect(()=>{if(!N)return;const D=setTimeout(()=>Y(L.trim()),yl);return()=>clearTimeout(D)},[L,N]),b.useEffect(()=>{if(!N)return;const D=++te.current,v={q:Z,category:m,...k?{ids:k.split(",")}:{}};return $({type:"query-changed",query:v,generation:D}),Q(v,D,void 0),()=>{var P;(P=B.current)==null||P.abort()}},[N,Z,m,k,Q]),b.useEffect(()=>{if(N)return()=>{var D;return(D=B.current)==null?void 0:D.abort()}},[N]);const C=()=>{if(!N||I.status!=="ready"||!I.hasMore)return;const D=te.current;$({type:"load-more"}),Q(I.query,D,I.cursor)},q=()=>{!N||I.status!=="error"||($({type:"retry"}),Q(I.query,te.current,I.cursor))},[K,le]=b.useState([]),[X,xe]=b.useState(!1),[he,we]=b.useState(!1),ge=D=>n.jsx("div",{className:"w6w-apppicker-host",children:D});let J,re=null,ae=!1,ce=!1,ye=null,Oe=!1;if(j?J=u??null:N?(J=I.apps,Oe=I.status==="loading",ae=I.status==="loading-more",ce=I.hasMore,I.status==="error"&&(I.apps.length===0?re=I.error??"Failed to load apps.":ye=I.error??"Failed to load apps.")):(J=U,re=_),!N&&re)return ge(n.jsx("div",{className:"w6w-result w6w-error",children:re}));if(!N&&J===null)return ge(n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}));J??(J=[]);const dt=dl(J),Te=s?dt.filter(s):dt;if(!N&&Te.length===0)return ge(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?Ti(Te):[],De=de.slice(0,Gn),pt=de.slice(Gn).filter(D=>K.includes(D.slug)),Qe=[...De,...pt],et=de.length-Qe.length,Ue=X?de:Qe,kt=D=>le(v=>v.includes(D)?v.filter(P=>P!==D):[...v,D]),St=()=>le([]),Re=Te.filter(D=>To(D)!==null).length,Ve=p&&Re>0,je=Ve&&he,_e=je?Te.filter(D=>To(D)!==null):Te,He=(()=>{const D=new Map;for(const v of Te){const P=v.publisher;P&&typeof P.slug=="string"&&P.slug!==""&&!D.has(P.slug)&&D.set(P.slug,P.displayName||P.slug)}return M&&!D.has(M)&&D.set(M,M),[...D].map(([v,P])=>({slug:v,label:P}))})(),We=g&&He.length>0,Fe=We&&M!==void 0,me=d&&K.length>0?_e.filter(D=>Ri(D,K)):_e,Ae=N?me:[...me].sort((D,v)=>D.displayName.localeCompare(v.displayName,void 0,{sensitivity:"base"})),tt=N?"":L.trim().toLowerCase(),Je=L.trim().length>0,Ie=tt?Ae.filter(D=>D.displayName.toLowerCase().includes(tt)||D.id.toLowerCase().includes(tt)):Ae,nt=s!==void 0&&Te.length!==dt.length||je&&_e.length!==Te.length||d&&K.length>0&&me.length!==_e.length,ne=(d&&K.length>0||je||Fe)&&Ie.length===0,Se=je&&K.length===0,$e=()=>{le([]),we(!1),M!==void 0&&ee(void 0),T("")};return ge(n.jsxs("div",{className:"w6w-stepbuilder-apps",children:[a&&n.jsx("input",{type:"text",className:"w6w-stepbuilder-search",placeholder:o??"Search apps…",value:L,onChange:D=>T(D.target.value),"aria-label":"Search apps"}),(Ve||d&&de.length>0||We)&&n.jsxs("div",{className:"w6w-apppicker-cats",children:[We&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Publisher"}),He.map(D=>n.jsx("button",{type:"button",className:"w6w-apppicker-chip","aria-pressed":M===D.slug,"aria-label":`Filter by ${D.label}`,onClick:()=>ee(M===D.slug?void 0:D.slug),children:D.label},D.slug))]}),Ve&&n.jsxs("button",{type:"button",className:"w6w-apppicker-chip w6w-apppicker-provider-toggle","aria-pressed":he,"aria-label":"Filter to model providers",onClick:()=>we(D=>!D),children:["Model providers ",n.jsxs("span",{className:"w6w-muted",children:["(",Re,")"]})]}),d&&de.length>0&&n.jsxs(n.Fragment,{children:[Ue.map(D=>n.jsxs("button",{type:"button",className:"w6w-apppicker-chip","aria-pressed":K.includes(D.slug),"aria-label":`Filter by ${D.label}`,onClick:()=>kt(D.slug),children:[D.label," ",n.jsxs("span",{className:"w6w-muted",children:["(",D.count,")"]})]},D.slug)),!X&&et>0&&n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>xe(!0),children:["+",et," more"]}),X&&de.length>Gn&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>xe(!1),children:"Show less"}),K.length>0&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:St,children:"Clear"})]})]}),N&&Oe?n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}):N&&re?n.jsxs("div",{className:"w6w-result w6w-error",children:[re," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:q,children:"Retry"})]}):Ie.length===0&&!ce?ne?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:Fe?Je?`No apps from this publisher match “${L}”.`:"No apps from this publisher.":Se?Je?`No model providers match “${L}”.`:"No apps declare a model provider.":Je?`No apps match “${L}” 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"})]}):N?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:Je?`No apps match “${L}”.`:r??"No apps registered yet. Register one from the Apps page first."}),!Je&&c]}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No apps match “",L,"”."]}):n.jsxs(n.Fragment,{children:[Ie.length===0&&ce?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:Ie.map(D=>{const v=f==null?void 0:f.get(D.id),P=gl(v);return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-apppicker-card",onClick:()=>e(D),children:[n.jsx(Nt,{src:D.iconSvg,srcDark:D.iconSvgDark,brandColor:D.brandColor,name:D.displayName,theme:t,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:D.displayName}),n.jsx("code",{className:"w6w-apppicker-card-id",children:D.id}),D.version&&n.jsxs("span",{className:"w6w-apppicker-card-version",children:["v",D.version]}),D.publisher&&n.jsx(Ar,{publisher:D.publisher,testId:`apppicker-publisher-${D.id}`}),P&&n.jsx("span",{className:v!=null&&v.supported?"w6w-chip w6w-apppicker-card-bridge":"w6w-chip w6w-apppicker-card-bridge w6w-apppicker-card-bridge-unsupported",title:P.title,children:P.text})]})]},D.id)})}),N&&typeof I.total=="number"&&n.jsx("div",{className:"w6w-small w6w-apppicker-count",children:nt?`${Ie.length} ${Ie.length===1?"app":"apps"}`:`${I.apps.length} of ${I.total}`}),N&&ye&&n.jsxs("div",{className:"w6w-result w6w-error w6w-small",children:[ye," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:q,children:"Retry"})]}),N&&ce&&!ye&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-apppicker-load-more",onClick:C,disabled:ae,children:ae?"Loading more…":"Load more"})]})]}))}const $s={"&":{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 Ro(e){return{children:Object.create(null),detail:e}}function ts(e,t){return Object.hasOwn(e.children,t)?e.children[t]:void 0}function Rr(e={}){var r;const t=Ro(),s=(a,i)=>{var c;let l=t;for(const u of a)l=(c=l.children)[u]??(c[u]=Ro());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 xl=`(?:"(?:[^"\\\\]|\\\\.)*"|'(?:[^'\\\\]|\\\\.)*')`,xt=`(?:${xl}|\\d+)`,vl=`(?:\\s*\\.\\s*[A-Za-z_$][\\w$]*|\\s*\\[\\s*${xt}\\s*\\])`,jl="(?:\\$|ctx|run|state|vars|consts)",Nl=`(?:\\$|ctx)\\.get\\(\\s*${xt}(?:\\s*,\\s*${xt})*\\s*\\)`,kl=`(?:${Nl}|${jl})${vl}*`,Oo=new RegExp(`(?<![\\w$.])(${kl})\\s*$`),Sl=new RegExp(`\\.\\s*([A-Za-z_$][\\w$]*)|\\[\\s*(${xt})\\s*\\]`,"g");function ns(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:`
|
|
3
|
-
`,r:"\r",t:" ",b:"\b",f:"\f"}[s]??s)}function Or(e,t){let s=e;for(const o of t)s=s&&ts(s,o);return s}function Io(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(xt,"g"))??[];r=Or(t,c.map(ns)),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=ts(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(Sl)){if(s&&c[1]&&!i)return;r=r&&ts(r,c[1]??ns(c[2])),i=!1}return r}function Cl(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,p=!1;const f=new RegExp(`(?<![\\w$.])(?:${o?"ctx":"\\$"})\\.get\\(\\s*((?:${xt}\\s*,\\s*)*)(["']?)([^"'\\\\,\\n]*)$`).exec(r),m=/\[\s*(["']?)([^"'\\\]\n]*)$/.exec(r),w=/\.([\w$]*)$/.exec(r);try{if(f)i=Or(t,(f[1].match(new RegExp(xt,"g"))??[]).map(ns)),c=f[2],l=e.pos-f[3].length-c.length;else if(m){const y=Oo.exec(r.slice(0,m.index));if(!y)return null;i=Io(y[1],t,o),c=m[1],u=!0,l=e.pos-m[2].length-c.length}else if(w){const y=Oo.exec(r.slice(0,w.index));if(!y||o&&y[1]!=="ctx")return null;i=Io(y[1],t,o),p=y[1]===(o?"ctx":"$"),d=w.index,l=w.index+1}else if(o&&!a){const y=e.matchBefore(/\w*/);return!y||!e.explicit&&y.from===y.to?null:{from:y.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 y=e.state.sliceDoc(e.pos),x=c?new RegExp(`^[^${c}\\\\
|
|
4
|
-
]*${c}`).exec(y):null;x&&(h+=x[0].length),u&&e.state.sliceDoc(h,h+1)==="]"&&h++}const g=Object.entries(i.children).map(([y,x])=>{const S=JSON.stringify(y);return{label:y,type:"property",detail:x.detail,apply:c!==void 0?`${S}${u?"]":""}`:/^[A-Za-z_$][\w$]*$/.test(y)?y:(A,R,j,k)=>{const N=d??j;A.dispatch({changes:{from:N,to:k,insert:`[${S}]`},selection:{anchor:N+S.length+2}})}}});if(p&&g.push({label:"get",type:"function",detail:`Read a path; missing values return ${o?"None":"undefined"}`}),c!==void 0){const y=e.state.sliceDoc(l+c.length,e.pos).trimStart().toLowerCase();return{from:l,to:h,filter:!1,options:g.filter(x=>x.label.toLowerCase().startsWith(y))}}return g.length?{from:l,to:h,options:g}:null}function Al(e="javascript",t=Rr()){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=Cl(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:Jn&&Jn.tagName.toUpperCase()==="SCRIPT"&&Jn.src||new URL("connection-app-meta-DfA6Yqhh.cjs",document.baseURI).href),{type:"module"}),s.onmessage=f=>{var m;(m=a.get(f.data.id))==null||m(f.data.options),a.delete(f.data.id)},s.onerror=i);const p=await new Promise(f=>{const m=++o;a.set(m,f),c.addEventListener("abort",()=>{a.delete(m),f([])},{onDocChange:!0}),s==null||s.postMessage({id:m,code:c.state.doc.toString(),position:c.pos,scope:t})});return c.aborted||!p.length?null:{from:d.from,options:p}};return[(e==="python"?yr.pythonLanguage:e==="typescript"?gn.typescriptLanguage:gn.javascriptLanguage).data.of({autocomplete:l}),Ns.ViewPlugin.define(()=>(r=!1,{destroy(){r=!0,i()}}))]}function El(e){switch(e){case"javascript":return gn.javascript();case"typescript":return gn.javascript({typescript:!0});case"python":return yr.python()}}function Ps(e){const t=On(e.theme),{copied:s,copy:o}=ue.useCopyToClipboard(e.value),r=b.useMemo(()=>[...e.language?[El(e.language)]:[],...e.language?[Al(e.language,e.scriptScope)]:[],Ns.EditorView.theme($s)],[e.language,e.scriptScope]);return n.jsxs("div",{className:"w6w-code-editor","aria-label":e["aria-label"]??"Code editor",children:[n.jsx(gr,{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(ue.CheckGlyph,{}):n.jsx(ue.CopyGlyph,{})}),n.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}function Tl(){const e=xr.jsonParseLinter();return t=>t.state.doc.toString().trim()===""?[]:e(t)}function Ke(e){const t=On(e.theme),{copied:s,copy:o}=ue.useCopyToClipboard(e.value),r=b.useMemo(()=>[xr.json(),...e.showDiagnostics===!1?[]:[jo.linter(Tl()),jo.lintGutter()],Ns.EditorView.theme($s)],[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 p=JSON.parse(i);(c=e.onValidChange)==null||c.call(e,p),(u=e.onValidityChange)==null||u.call(e,{valid:!0})}catch(p){(d=e.onValidityChange)==null||d.call(e,{valid:!1,error:p.message})}}}return n.jsxs("div",{className:"w6w-json-editor","aria-label":e["aria-label"]??"JSON editor",children:[n.jsx(gr,{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(ue.CheckGlyph,{}):n.jsx(ue.CopyGlyph,{})}),n.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}function Ir(e,t,s){return e*t>.6*s}function $r(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 $o={display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"none",width:"1.25em",height:"1.25em",overflow:"hidden"},Rl=240,Po={display:"block",fontSize:"0.85em",opacity:.65,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Ol={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 Ye({options:e,value:t,onChange:s,placeholder:o,disabled:r,"aria-label":a,mode:i="auto",forceSelection:l=!0,optionHeight:c=32,listMaxHeight:u=Rl,className:d,onInputChange:p,emptyText:f="No matches",footer:m}){const w=i==="combobox"||i==="auto"&&Ir(e.length,c,typeof window>"u"?0:window.innerHeight),h=b.useId(),g=e.find(L=>L.value===t),y=(g==null?void 0:g.label)??(l?"":t),[x,S]=b.useState(y),[A,R]=b.useState(!1),[j,k]=b.useState(!1),[N,F]=b.useState(0),U=b.useRef(null);b.useEffect(()=>{S(y)},[y]);const O=b.useMemo(()=>j?$r(e,x):e,[e,x,j]),_=b.useMemo(()=>({...Ol,maxHeight:u}),[u]);if(!w)return n.jsxs("select",{className:d,value:t,disabled:r,"aria-label":a,onChange:L=>s(L.target.value),children:[o!==void 0&&t===""&&n.jsx("option",{value:"",disabled:!0,children:o}),e.map(L=>n.jsx("option",{value:L.value,children:L.label},L.value))]});const E=L=>`${h}-opt-${L}`,I=()=>{R(!1),k(!1)},$=L=>{S(L.label),s(L.value),I()},V=L=>{L.key==="ArrowDown"?(L.preventDefault(),A?F(T=>Math.min(T+1,O.length-1)):R(!0)):L.key==="ArrowUp"?(L.preventDefault(),A?F(T=>Math.max(T-1,0)):R(!0)):L.key==="Enter"?A&&O[N]?(L.preventDefault(),$(O[N])):l||(x!==y&&s(x),I()):L.key==="Escape"&&(A&&L.stopPropagation(),S(y),I())},H=()=>{l?S(y):x!==y&&s(x),I()};return n.jsxs("div",{ref:U,className:"w6w-combobox",style:{position:"relative"},children:[(g==null?void 0:g.icon)!==void 0&&!j&&n.jsx("span",{"aria-hidden":"true",className:"w6w-combobox-icon",style:{...$o,position:"absolute",left:"0.6em",top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:g.icon}),n.jsx("input",{type:"text",role:"combobox",className:d,style:(g==null?void 0:g.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[N]?E(N):void 0,autoComplete:"off",onFocus:()=>R(!0),onChange:L=>{S(L.target.value),p==null||p(L.target.value),k(!0),F(0),R(!0)},onKeyDown:V,onBlur:H}),A&&n.jsxs("div",{id:`${h}-list`,role:"listbox",tabIndex:-1,"aria-label":a,style:_,children:[O.map((L,T)=>n.jsx("div",{id:E(T),role:"option",tabIndex:-1,"aria-selected":L.value===t,style:{padding:"6px 8px",cursor:"pointer",borderRadius:4,background:T===N?"var(--w6w-panel-2)":void 0},onMouseDown:Z=>{Z.preventDefault(),$(L)},onMouseEnter:()=>F(T),children:L.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:$o,children:L.icon}),n.jsxs("span",{style:{minWidth:0,flex:1},children:[L.label,L.detail!==void 0&&n.jsx("span",{className:"w6w-combobox-detail",style:Po,children:L.detail})]})]}):n.jsxs(n.Fragment,{children:[L.label,L.detail!==void 0&&n.jsx("span",{className:"w6w-combobox-detail",style:Po,children:L.detail})]})},L.value)),O.length===0&&n.jsx("div",{role:"presentation",style:{padding:"6px 8px",opacity:.6},children:f}),m!==void 0&&n.jsx("div",{role:"presentation",className:"w6w-combobox-footer",style:{padding:"6px 8px",opacity:.6,fontSize:"0.85em"},children:m})]})]})}function In(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.source==="resolveFields"}function Xe(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 _o(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 dn(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(_o)};let s="";for(const o of t){if(o.kind==="text"){s+=o.value??"";continue}Il(s)%2===1&&(s+="\\"),s+=ie.serializeTemplate([_o(o)])}return s}function Il(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t+=1;return t}const Pr={var:!0,vars:!0,state:!0,steps:!0,nodes:!0,trigger:!0,foreach:!0,inputs:!0,output:!0,secrets:!0,documents:!0,const:!0};Object.freeze(Object.keys(Pr));const Fo=e=>Object.prototype.hasOwnProperty.call(Pr,e),Lo=["state","var","vars"];function _r(e){for(const t of Lo)if(e===t||e.startsWith(`${t}.`)){const s=e.slice(t.length);return[...new Set([e,...Lo.map(o=>o+s)])]}return[e]}function Mo(e){const t=e.indexOf(".");return t===-1?e:e.slice(0,t)}function ct(e){const t=ie.parseTemplate(e,"editor",$l);return t.every($n)?t:[{kind:"text",value:e}]}function $n(e){if(e.kind==="var"){const t=e.ref??"";return!ie.hasRefusedChainToken(t)&&Fo(Mo(t))}if(e.kind==="expr"){const t=ie.coalesceOperandRefs(e.expr);return t===null?!0:t.every(s=>Fo(Mo(s)))}return!0}const $l={isOurs:$n,backslash:"keep"},Fr={isOurs:$n,backslash:"strip"};function at(e){return Xe(e)?!0:typeof e=="string"&&e.includes("{{")&&ct(e).some(t=>t.kind!=="text")}function Pn(e){if(!e.includes("{{"))return null;const t=ie.parseTemplate(e,"editor",Fr);return t.every($n)&&(t.some(s=>s.kind!=="text")||t.map(s=>s.value??"").join("")!==e)?t:null}function Pl(e){return e.includes("{{")?ie.parseTemplate(e,"editor",Fr).map(t=>t.kind==="text"?t.value??"":ie.serializeTemplate([t])).join(""):e}function ss(e){if(lt(e))return{parts:[],sealed:e};if(Xe(e))return{parts:e.parts.map(s=>({...s})),sealed:null};const t=typeof e=="string"?e:"";return{parts:t?ct(t):[],sealed:null}}function _l(e,t){let s="";for(const o of e)switch(o.kind){case"text":s+=Pl(o.value??"");break;case"var":case"render":{const r=_r(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 Rt="var.",Do="vars.",os="documents.",rs="const.",as="state.";function Lr(e){return e==="state"||e==="vars"?"var":e.startsWith(Do)?Rt+e.slice(Do.length):e.startsWith(as)?Rt+e.slice(as.length):e}function Fl(e){return e.startsWith(as)?3:e.startsWith(Rt)?2:1}function Mr(e){return e.rank>0?e.value:Object.fromEntries(Array.from(e.children,([t,s])=>[t,Mr(s)]))}function _s(e,t,s,o){const r={children:new Map,rank:0},a={},i={};for(const[w,h]of Object.entries(e??{})){const g=Lr(w);if(g.startsWith(Rt)){const y=g.slice(Rt.length),x=Fl(w);let S=r;for(const A of y.split(".")){let R=S.children.get(A);R||(R={children:new Map,rank:0},S.children.set(A,R)),S=R}x>=S.rank&&(S.value=h,S.rank=x)}else g.startsWith(os)?a[g.slice(os.length)]=h:g.startsWith(rs)&&(i[g.slice(rs.length)]=h)}const l=Mr(r),c=(t==null?void 0:t.steps)??{},u=e??{},d=Object.hasOwn(u,"foreach.item"),p=typeof u["foreach.index"]=="number",f=t==null?void 0:t.foreach,m=f?{...f}:d||p?{...d?{item:u["foreach.item"]}:{},...p?{index:u["foreach.index"]}:{}}:void 0;return{...m?{foreach:m}:{},vars:l,state:l,documents:a,constants:i,steps:c,nodes:c,trigger:(t==null?void 0:t.trigger)??{},flat:e??{},...s?{config:s}:{},...o?{meta:o}:{}}}function Ll(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 Ml=/^(?:nodes|steps)\.[^.]+\.(?:meta\.)?config(?:\.|$)/,Dl=/^(?:nodes|steps)\.([^.]+)\.meta(?:\.|$)/;function Wl(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 Dr(e,t){var f;const s=Lr(e);if(t.flat&&(s.startsWith(Rt)||s.startsWith(os)||s.startsWith(rs))){const m=_r(e).find(w=>Object.hasOwn(t.flat,w));if(m!==void 0)return{status:"resolved",ref:e,value:t.flat[m]}}const{vars:o,constants:r,config:a,meta:i,...l}=t,c=Wl(t.nodes??t.steps,a,i),u={...l,var:o,...r?{const:r}:{},nodes:c,steps:c},d=Ll(u,s);if(d.present)return{status:"resolved",ref:e,value:d.value};if(Ml.test(s))return{status:"at-run",ref:e};const p=(f=Dl.exec(s))==null?void 0:f[1];return p!==void 0&&(i!=null&&i[p])?{status:"at-run",ref:e}:{status:"unresolved",ref:e}}function Wo(e,t){switch(e.kind){case"text":return{status:"resolved",value:e.value??""};case"var":return Dr(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 Fs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$"in e}function Ls(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$expr"in e}function Ms(e,t){if(lt(e))return[{status:"masked"}];if(Xe(e))return e.parts.map(s=>Wo(s,t));if(typeof e=="string"){const s=Pn(e);if(s)return s.map(o=>Wo(o,t))}return Fs(e)?[Dr(String(e.$),t)]:Ls(e)?[{status:"not-evaluated"}]:[{status:"resolved",value:e}]}function is(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,p)=>is(d,u[p]))}const r=e,a=t,i=Object.keys(r),l=Object.keys(a);return i.length===l.length&&i.every(c=>c in a&&is(r[c],a[c]))}function Wr(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 Bl(e){return e.status==="resolved"&&e.value!==void 0?typeof e.value=="string"?e.value:JSON.stringify(e.value):String(Wr(e))}function ql(e){return e.length===1?Wr(e[0]):e.map(Bl).join("")}function Kt(e,t){return ql(Ms(e,t))}function Ul(e,t){const s={};for(const o of e)s[o.key||"(no key)"]=Kt(o.value,t);return s}const _n=b.forwardRef(function(t,s){const{label:o,children:r,icon:a,iconSize:i,title:l,onClick:c,disabled:u,className:d,danger:p,...f}=t,m=r??(a?n.jsx(ue.Icon,{name:a,size:i??16}):null),w=Object.fromEntries(Object.entries(f).filter(([h])=>h.startsWith("data-")));return n.jsx("button",{ref:s,type:"button",className:["w6w-icon-button",p?"w6w-icon-button-danger":"",d??""].filter(Boolean).join(" "),title:l??o,"aria-label":o,"aria-pressed":f["aria-pressed"],"aria-expanded":f["aria-expanded"],"aria-controls":f["aria-controls"],"aria-haspopup":f["aria-haspopup"],disabled:u,onClick:c,...w,children:m})});_n.displayName="IconButton";const Vl={default:"",wide:" w6w-modal-wide",xl:" w6w-modal-xl",full:" w6w-modal-full",fullscreen:" w6w-modal-fullscreen"};function Ce({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 p=m=>{m.preventDefault(),s()},f=m=>{if(m.target!==d)return;const w=d.getBoundingClientRect();(m.clientX<w.left||m.clientX>w.right||m.clientY<w.top||m.clientY>w.bottom)&&s()};return d.addEventListener("cancel",p),d.addEventListener("click",f),()=>{d.removeEventListener("cancel",p),d.removeEventListener("click",f)}},[s]),n.jsx("div",{className:"w6w-modal-backdrop",children:n.jsxs("dialog",{ref:c,className:`w6w-modal${Vl[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 Ds=new Set(["nodes","steps","state","var","vars","const","inputs","output","trigger","foreach","documents"]),Hl=/[=<>]|!=|&&|\|\||\?\?/,pn=e=>Hl.test(e)||/^\s*\(*\s*!/.test(e),ls=e=>ie.expressionReferences(e).some(pn);function Jl(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(Ds.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 Wt(e,t){var u,d,p,f,m;const s={parts:e,error:null},o=e.flatMap(w=>w.kind==="text"?ct(w.value??""):[w]);if(o.some(w=>w.kind==="render"))return s;if(o.some(Br))return{parts:o,error:zl};if(o.some(Kl))return s;if(o.length===1&&o[0].kind==="expr"&&!ls(o[0].expr))return{parts:o,error:null};let r=o.map(w=>{if(w.kind==="text")return w.value??"";if(w.kind==="secret")return`{{ secrets.${w.ref??""} }}`;if(w.kind==="expr"){if(ls(w.expr)){const g=ie.serializeTemplate([w]);if(!g.startsWith("{{ ="))return`(${g.slice(2,-2).trim()})`}const h=ie.formatReadableExpression(w.expr);return h===null?ie.serializeTemplate([w]):`(${h})`}return pn(w.ref??"")?w.ref??"":`{{ ${w.ref??""} }}`}).join("").trim();if(!pn(r))return s;const a=/^\{\{([^{}]+)\}\}$/.exec(r);a&&pn(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&&(Ds.has(l)||l==="secrets"||((d=t.steps)==null?void 0:d.some(w=>w.id===l))||((p=t.vars)==null?void 0:p.includes(l))||((f=t.constants)==null?void 0:f.includes(l)));if(!c&&!/^(?:["']|-?\d|true\b|false\b|null\b)/.test(i))return s;if(c&&!/^\s*\(*\s*!/.test(r)){const w=(m=/^(?:\{\{[^{}]+\}\}|[A-Za-z_$][\w$-]*(?:\.[\w$-]+)*)/.exec(i))==null?void 0:m[0];if(w){const h=i.slice(w.length).replace(/^[\s)]+/,"");if(!/^(?:[=<>(]|!=|&&|\|\||\?\?)/.test(h)||/^<\/?[A-Za-z][^>]*>/.test(h))return s}}try{return{parts:[{kind:"expr",expr:ie.parseReadableExpression(r,h=>Jl(h,t))}],error:null}}catch(w){return{parts:o,error:w instanceof Error?w.message:"Check the expression."}}}const zl="The JSONLogic after “=” is not valid JSON. Check its quotes, brackets and commas.";function Br(e){return e.kind==="expr"&&typeof e.expr=="string"}function Kl(e){return e.kind==="expr"&&e.expr!==null&&typeof e.expr=="object"&&!ls(e.expr)&&ie.formatReadableExpression(e.expr)===null}function Gl(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 Yl(e){return e.replace(/^(?:vars|state)(?=\.|$)/,"var").replace(/^steps(?=\.|$)/,"nodes")}function Xl(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=Yl(s).split(".");if(!Ds.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 Zl(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=Xl(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"||Br(i))return _l([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 Ql=/^(?:nodes|steps)\.([^.]+)\.output(?:\.(.+))?$/,ec=/^(?:nodes|steps)\.([^.]+)\.meta\.(app|version|action|connectionId)$/,wt=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=Ql.exec(e);if(t)return t[2]?`${t[1]}.${t[2]}`:t[1];const s=ec.exec(e);return s?`${s[1]} meta · ${s[2]}`:e};function tc(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 nc(e){const t=e.op==="or"?"||":"??",s=e.operands.map(o=>{const r=tc(o);return r!==void 0?wt(r):JSON.stringify(o)}).join(` ${t} `);return s.length>40?`${s.slice(0,40)}…`:s}const sc=/[.{}]/;function Bt(e){return e===""||e!==e.trim()?!1:!sc.test(e)}function Yn(e){return e.split(".").every(Bt)}function oc(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 Bo(e,t){const s=oc(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 Gt(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=wt(t.ref??""),o.title=`Variable: ${t.ref??""}`;else if(t.kind==="render")o.setAttribute("data-ref",t.ref??""),r.textContent="▤",a.textContent=wt(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=nc(c),o.title=`Expression: ${ie.serializeTemplate([t])}`;else{const u=ie.formatReadableExpression(t.expr,wt);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 qr=new Set(["div","p"]);function Ur(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 qt(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=Ur(l);if(c){t.push(c);return}const u=(l.tagName??"").toLowerCase();if(u==="br"){i||s(`
|
|
5
|
-
`);return}const d=qr.has(u);d&&t.length>0&&s(`
|
|
6
|
-
`),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 Vr=e=>!!e&&(e.tagName??"").toLowerCase()==="br";function Hr(e){Vr(e.lastChild)||e.appendChild(e.ownerDocument.createElement("br"))}function rc(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(qr.has((r.tagName??"").toLowerCase()))return r}o=o.parentNode}return e}function Ws(e){Hr(rc(e))}const Jr=e=>e.getAttribute("aria-multiline")!=="false";function zr(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(Gt(o,i,s));const r=t[t.length-1];(r==null?void 0:r.kind)==="text"&&((a=r.value)!=null&&a.endsWith(`
|
|
7
|
-
`))&&Jr(e)&&Hr(e)}function Bs(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 kn(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 Vr(e.lastChild)?e.insertBefore(t,e.lastChild):e.appendChild(t),Bs(e);e.focus()}function Kr(e,t,s={}){const o=Jr(e),r=o?t.replace(/\r\n?/g,`
|
|
8
|
-
`):t.replace(/\r\n?|\n/g,"");if(!r)return;const a=e.ownerDocument;for(const i of ct(r))kn(e,i.kind==="text"?a.createTextNode(i.value??""):Gt(a,i,s));o&&r.endsWith(`
|
|
9
|
-
`)&&Ws(e)}function Gr(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 p=0;for(;c-1-p>=0&&l[c-1-p]==="\\";)p+=1;if(p%2===1)return!1;const f=s.createRange();f.setStart(a,c),f.setEnd(a,i),f.deleteContents();const m=Gt(s,d[0],t);f.insertNode(m);const w=s.createRange();return w.setStartAfter(m),w.collapse(!0),o.removeAllRanges(),o.addRange(w),!0}function Yr(e){const t=Ur(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 ac(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 ic(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 lc(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 cc(e,t){if(!e||!Object.hasOwn(e,t))return t;let s=2;for(;Object.hasOwn(e,`${t}_${s}`);)s++;return`${t}_${s}`}function qo(e,t,s,o){var g;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=(y,x)=>({text:e.slice(0,y)+x+e.slice(y),caret:y+x.length});if(ac(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,p=()=>`${JSON.stringify(cc(d,ic(s)))}: ${i}`,f=e.slice(0,t).trimEnd(),m=f[f.length-1],w=e.slice(t).trimStart()[0],h=lc(e,t);if(m===":"||m==="["||m===","&&h==="[")return l(t,i+(m!==":"&&w!==void 0&&w!=="]"?", ":""));if(m==="{"||m===","&&h==="{"){const y=w!==void 0&&w!=="}"?", ":"";return l(t,(m===","?" ":"")+p()+y)}if(u&&(d||Array.isArray(c))){const y=e.lastIndexOf(d?"}":"]"),x=e.slice(0,y).trimEnd(),S=x.endsWith(d?"{":"["),A=d?p():i,R=e.slice(x.length,y);if(R.includes(`
|
|
10
|
-
`)){const N=S?`${R.slice(R.lastIndexOf(`
|
|
11
|
-
`)+1)} `:((g=/^\s*/.exec(x.slice(x.lastIndexOf(`
|
|
12
|
-
`)+1)))==null?void 0:g[0])??"",F=`${S?"":","}
|
|
13
|
-
${N}${A}`;return{text:x+F+e.slice(x.length),caret:x.length+F.length}}const j=`${S?"":","} ${A} `,k=x.length;return{text:e.slice(0,k)+j+e.slice(y),caret:k+j.length-1}}return l(t,i)}const uc=/^\{\{\s*((?:var|vars|const|steps|nodes|trigger|foreach|inputs|output|documents)(?:\.[^\s{}]+)?)\s*\}\}$/;function dc(e){const t=uc.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 pc(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 cs(e,t){if(typeof e=="string"){const s=Pn(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=>cs(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,cs(r,t)]))}return e}function nn({value:e,masked:t,multiline:s,options:o,fieldLabel:r,onSave:a,onClose:i,mode:l,jsonValue:c,onSaveJson:u,whole:d,startingState:p,jsonProblem:f,title:m}){var D;const w=l==="json-binding",h=w&&p===!0,[g,y]=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]),k=h?(f==null?void 0:f(x))??null:null,N=h?(x.trim()===""||j.ok)&&k===null:j.ok,F=()=>_s(o.sampleValues,pc(o.sampleValues),o.nodeConfig,o.nodeMeta),U=w?j.ok?JSON.stringify(cs(j.value,v=>Kt(v,F())),null,2):x.trim()===""?"":"Invalid JSON":"",O=v=>{const P=A.current,W=P?P.state.doc.toString():x;if(h){const pe=g==="value"?{value:Kt(`{{ ${v} }}`,F())??null}:void 0,ft=W.trim()===""?"{}":W,rn=R.current&&P?P.state.selection.main.head:ft.length,Hn=qo(ft,rn,v,pe);if(!P){S(Hn.text);return}P.dispatch({changes:{from:0,to:W.length,insert:Hn.text},selection:{anchor:Hn.caret}}),P.focus();return}let se=null;try{se=W.trim()===""?null:ut(JSON.parse(W))}catch{se=null}let be=!1;if(d)try{const pe=JSON.parse(W);be=Array.isArray(pe)?pe.length===0:typeof pe=="object"&&pe!==null&&Object.keys(pe).length===0}catch{be=!1}if(W.trim()===""||se!==null||be){u==null||u(`{{ ${v} }}`),i();return}if(!P)return;const fe=R.current?P.state.selection.main.head:W.length,oe=qo(W,fe,v);P.dispatch({changes:{from:0,to:W.length,insert:oe.text},selection:{anchor:oe.caret}}),P.focus()},[_,E]=b.useState(()=>Wt(ss(e).parts,o).parts),I=b.useMemo(()=>Wt(_,o),[_,o]),[$,V]=b.useState(0),H=b.useRef(null),L=b.useRef(!1),[T,Z]=b.useState({}),[Y,te]=b.useState(null),[B,G]=b.useState(()=>new Set),z=v=>{G(P=>{const W=new Set(P);return W.has(v)?W.delete(v):W.add(v),W})},[M,ee]=b.useState("auto");b.useLayoutEffect(()=>{const v=H.current;v&&(zr(v,_,{renderToggle:!0}),L.current&&(L.current=!1,Bs(v),v.focus()))},[$]);const Q=()=>{const v=H.current;v&&E(qt(v))},C=v=>{const P=H.current;P&&(kn(P,Gt(P.ownerDocument,v,{renderToggle:!0})),E(qt(P)))},q=_.some(v=>v.kind==="render"),K=(v,{restoreFocus:P})=>{E(Wt(ct(v),o).parts),V(W=>W+1)},le=()=>{const v=H.current,P=Wt(v?qt(v):_,o);P.error||(a==null||a(dn(P.parts)),i())},X=()=>{te(null),L.current=!0,V(v=>v+1)},xe=o.vars??[],he=o.constants??[],we=o.secrets??[],ge=o.inputs??[],J=o.documents??[],re=o.steps??[],ae=o.nodeConfigs??[],ce=o.loop,ye=new Map(ae.map(v=>[v.id,v.keys.filter(Bt)]).filter(([,v])=>v.length>0)),Oe=o.nodeMeta??{},dt=v=>fc.filter(([P])=>hc.has(P)?de(v):Object.hasOwn(Oe[v]??{},P)),Te=re.filter(v=>v.hasMeta===!0).map(v=>v.id),de=v=>{var W;if(Te.includes(v))return!0;const P=(W=Oe[v])==null?void 0:W.app;return typeof P=="string"&&!ot(P)},De=v=>dt(v).map(([P,W])=>me(W,{kind:"var",ref:`nodes.${v}.meta.${P}`},"w6w-exprmodal-field",null)),pt=[...new Set([...Object.keys(Oe),...Te,...ye.keys()])],Qe=re.length>0,et=!h&&(Qe||!!ce),Ue=h?[]:(((D=o.stateShape)==null?void 0:D.fields)??[]).filter(v=>Yn(v.key)),kt=[...et?["state"]:[],...Ue.length>0?["runstate"]:[],...pt.length>0?["meta"]:[],...o.inputs!==void 0?["inputs"]:[],"vars",...he.length>0?["consts"]:[],...!w||h?["docs"]:[],...w?[]:["secrets"]],St=M==="auto"||M!==null&&!kt.includes(M)?kt.find(v=>v!=="meta")??null:M,Re=v=>({open:St===v,onToggle:()=>ee(St===v?null:v)}),Ve=((ce==null?void 0:ce.itemOutputs)??[]).filter(v=>v.path?Yn(v.key):Bt(v.key)),je=ie.serializeTemplate(I.parts),_e=b.useMemo(()=>{const v={};for(const[P,W]of Object.entries(o.sampleValues??{}))v[P]=typeof W=="string"?W:JSON.stringify(W);return{...v,...T}},[o.sampleValues,T]),He=b.useMemo(()=>Gl(I.parts),[I.parts]),We=b.useMemo(()=>{if(I.error)return"";try{return Zl(I.parts,o.sampleValues,T)}catch{return je}},[I,o.sampleValues,T,je]),Fe=b.useMemo(()=>{var P;const v=new Set;for(const W of He){if(T[W]!==void 0)continue;const se=(P=o.valueSources)==null?void 0:P[W];se==="sample"?v.add("example from the app"):se==="persisted"&&v.add("from last test")}return[...v]},[He,T,o.valueSources]),me=(v,P,W,se,be=!1,fe,oe)=>n.jsxs("div",{className:"w6w-exprmodal-item",style:{display:"flex",alignItems:"center",gap:4,minWidth:0,...oe&&oe.depth>0?{paddingLeft:oe.depth*14}:{}},children:[n.jsxs("button",{type:"button",className:`w6w-exprmodal-source ${W}${oe!=null&&oe.declaredOnly?" is-declared-only":""}`,style:{flex:1,minWidth:0,...oe!=null&&oe.declaredOnly?{opacity:.6}:{}},title:`Insert ${(oe==null?void 0:oe.name)??v}`,"aria-label":fe,onClick:()=>w?P.kind==="var"&&O(P.ref??""):C(P),children:[se!==null&&n.jsx("span",{className:"w6w-expr-chip-sigil",children:se}),n.jsx("span",{className:"w6w-exprmodal-source-label",children:v}),(oe==null?void 0:oe.declaredOnly)&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-declared-only",style:{marginLeft:6},children:"declared by the app"}),(oe==null?void 0:oe.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"})]}),oe==null?void 0:oe.toggle,!w&&n.jsx(_n,{icon:"copy",iconSize:14,label:"Copy to expression editor","data-testid":"expr-copy-to-editor",onClick:()=>C(P)})]},`${P.kind}:${P.ref??v}`),Ae=B.has("loop:item"),tt=me("Current item",{kind:"var",ref:"foreach.item"},"w6w-expr-chip-var","↻"),Je=(v,P)=>{if(P.length===0)return null;const W=B.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":W,title:W?"Hide config":"Show config",onClick:()=>z(`mcfg:${v}`),children:[n.jsx("span",{className:"w6w-exprmodal-tree-caret","aria-hidden":"true",children:W?"▾":"▸"}),"config"]})}),W&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-config-fields",children:P.map(se=>me(se,{kind:"var",ref:`nodes.${v}.meta.config.${se}`},"w6w-exprmodal-field",null))})]})},Ie=(v,P,W=`nodes.${v}.output`)=>ne(P,W,se=>({declaredOnly:se.declaredOnly===!0})),nt=v=>Bo(v,()=>!1).length,ne=(v,P,W=()=>({}))=>Bo(v,se=>B.has(`tree:${P}.${se}`)).map(({field:se,depth:be,name:fe,children:oe})=>{const pe=`${P}.${se.key}`,ft=B.has(`tree:${pe}`);return me(fe,{kind:"var",ref:pe},"w6w-exprmodal-field",null,!1,void 0,{name:wt(pe),depth:be,...W(se),toggle:oe>0?n.jsx(Mt,{count:oe,open:ft,onToggle:()=>z(`tree:${pe}`)}):void 0})}),Se=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,$e=v=>{const P=`mnode:${v}`,W=B.has(P);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":W,"aria-label":W?`Hide ${v} metadata`:`Show ${v} metadata`,title:W?"Hide metadata":"Show metadata",onClick:()=>z(P),children:W?"▾":"▸"}),me(v,{kind:"var",ref:`nodes.${v}.meta`},"w6w-expr-chip-var w6w-exprmodal-node",null,!0)]}),W&&n.jsxs("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-metadata-fields",children:[De(v),Je(v,ye.get(v)??[])]})]},P)};return n.jsxs(Ce,{title:m??(w?"Edit JSON value":"Edit expression"),subtitle:r?n.jsx("code",{children:r}):void 0,onClose:i,size:"full",headerRight:w?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:!N,title:N?"Save the composed JSON":k??"Compose valid JSON to save",onClick:()=>{N&&(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:q,title:q?"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(_)),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:le,"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,P,W])=>n.jsx("button",{type:"button","aria-pressed":g===v,"data-testid":`expr-insert-as-${v}`,title:W,className:`w6w-btn w6w-btn-sm${g===v?"":" w6w-btn-ghost"}`,onClick:()=>y(v),children:P},v))]}),w&&!h&&!et&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No upstream steps"}),et&&n.jsxs(st,{label:"Previous steps",...Re("state"),children:[ce&&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:[tt,n.jsx(Mt,{count:nt(Ve),open:Ae,onToggle:()=>z("loop:item")})]}):tt,Ve.length>0&&Ae&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-loop-fields",children:ne(Ve,"foreach.item")}),me("Index",{kind:"var",ref:"foreach.index"},"w6w-expr-chip-var","#"),(ce.outer??[]).map(v=>{const P=v.name??v.foreachId,W=`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:P}),me(`${P} item`,{kind:"var",ref:`${W}.item`},"w6w-expr-chip-var","↻"),me(`${P} index`,{kind:"var",ref:`${W}.index`},"w6w-expr-chip-var","#")]},v.foreachId)})]}),re.map(v=>{const P=(v.outputs??[]).filter(fe=>fe.path?Yn(fe.key):Bt(fe.key)),W=`step:${v.id}`,se=B.has(W),be=me(v.label??v.id,{kind:"var",ref:`nodes.${v.id}.output`},"w6w-expr-chip-var w6w-exprmodal-node",v.trigger?"⚡":null,P.length>0);return w?n.jsxs(b.Fragment,{children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:v.label??v.id}),me("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"})}),P.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":se,"aria-label":se?"Hide fields":"Show fields",title:se?"Hide fields":"Show fields",onClick:()=>z(W),children:se?"▾":"▸"}),n.jsx(Mt,{count:nt(P),open:se,onToggle:()=>z(W)})]}),se&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[Se(v.outputsFrom),Ie(v.id,P)]})]})]},v.id):n.jsxs(b.Fragment,{children:[P.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":se,"aria-label":se?"Hide fields":"Show fields",title:se?"Hide fields":"Show fields",onClick:()=>z(W),children:se?"▾":"▸"}),be,n.jsx(Mt,{count:nt(P),open:se,onToggle:()=>z(W)})]}):n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("span",{className:"w6w-exprmodal-caret-spacer","aria-hidden":"true"}),be]}),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"})}),P.length>0&&se&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[Se(v.outputsFrom),Ie(v.id,P)]})]},v.id)})]}),Ue.length>0&&n.jsxs(st,{label:"State",testId:"expr-state-group",...Re("runstate"),children:[me("state",{kind:"var",ref:"state"},"w6w-expr-chip-var","◇",!0),n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-state-fields",children:ne(Ue,"state",v=>({somePaths:v.paths==="some"}))})]}),pt.length>0&&n.jsx(st,{label:"Metadata",testId:"expr-metadata-group",...Re("meta"),children:pt.map(v=>$e(v))}),n.jsxs(n.Fragment,{children:[o.inputs!==void 0&&n.jsxs(st,{label:"Inputs",...Re("inputs"),children:[ge.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No inputs"}),ge.map(v=>me(v,{kind:"var",ref:`inputs.${v}`},"w6w-expr-chip-var","⇥"))]}),n.jsxs(st,{label:"Variables",...Re("vars"),action:o.createVar&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-var",onClick:()=>te("var"),children:"+ Add"}),children:[xe.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No variables"}),xe.map(v=>me(v,{kind:"var",ref:`var.${v}`},"w6w-expr-chip-var","◆"))]}),he.length>0&&n.jsx(st,{label:"Constants",testId:"expr-constants-group",...Re("consts"),children:he.map(v=>me(v,{kind:"var",ref:`const.${v}`},"w6w-expr-chip-var","◈"))})]}),(!w||h)&&n.jsxs(st,{label:"Documents",...Re("docs"),children:[J.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No documents"}),J.map(v=>{const P=(v.fields??[]).filter(fe=>Bt(fe.key)),W=`doc:${v.key}`,se=B.has(W),be=me(v.key,{kind:"var",ref:`documents.${v.key}`},"w6w-expr-chip-var","▦",P.length>0);return n.jsxs(b.Fragment,{children:[P.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[be,n.jsx(Mt,{count:P.length,open:se,onToggle:()=>z(W)})]}):be,P.length>0&&se&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:P.map(fe=>{const oe=`documents.${v.key}.${fe.key}`;return n.jsxs("div",{className:"w6w-exprmodal-subsource-row",children:[me(fe.key,{kind:"var",ref:oe},"w6w-expr-chip-var","·"),!w&&n.jsx("button",{type:"button",className:"w6w-exprmodal-render-btn","data-testid":"expr-insert-render",title:`Insert ${oe} and render its {{ }} placeholders`,"aria-label":`Insert ${oe} and render its {{ }} placeholders`,onClick:()=>C({kind:"render",ref:oe}),children:"▤"})]},oe)})})]},v.key)})]}),!w&&n.jsxs(st,{label:"Secrets",...Re("secrets"),action:o.createSecret&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-secret",onClick:()=>te("secret"),children:"+ Add"}),children:[we.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No secrets"}),we.map(v=>me(v,{kind:"secret",ref:v},"w6w-expr-chip-secret","🔒"))]})]}),w&&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(Ke,{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"]})]}),k&&n.jsx("span",{className:"w6w-muted w6w-small",role:"alert","data-testid":"expr-json-problem",children:k}),n.jsx(ue.Copyable,{value:U??"",label:"Copy result",children:n.jsx("pre",{className:"w6w-exprmodal-result","data-testid":"expr-json-result",children:U})})]})]}),!w&&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:H,className:`w6w-exprmodal-chips${t?" is-masked":""}${_.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=H.current;v&&Gr(v,{renderToggle:!0}),Q()},onDoubleClick:v=>{const P=v.target;if(P.closest("[data-x]")||P.closest("[data-render-toggle]"))return;const W=P.closest(".w6w-expr-chip");if(!W)return;v.preventDefault();const se=Yr(W);if(se){const be=se.ownerDocument,fe=be.createRange();fe.setStartAfter(se),fe.collapse(!0);const oe=be.getSelection();oe==null||oe.removeAllRanges(),oe==null||oe.addRange(fe)}Q()},onBlur:()=>{const v=H.current;v&&K(ie.serializeTemplate(qt(v)),{restoreFocus:!1})},onPaste:v=>{var W;v.preventDefault();const P=H.current;P&&(Kr(P,((W=v.clipboardData)==null?void 0:W.getData("text/plain"))??"",{renderToggle:!0}),Q())},onClick:v=>{var be;const P=v.target,W=P.closest("[data-x]");if(W){v.preventDefault(),(be=W.closest(".w6w-expr-chip"))==null||be.remove(),Q();return}const se=P.closest("[data-render-toggle]");if(se){v.preventDefault();const fe=se.closest(".w6w-expr-chip");if(fe){const oe=fe.getAttribute("data-ref")??"",pe=fe.getAttribute("data-kind")==="render"?"var":"render";fe.replaceWith(Gt(fe.ownerDocument,{kind:pe,ref:oe},{renderToggle:!0}))}Q()}},onKeyDown:v=>{if(v.key!=="Enter"||(v.preventDefault(),!s))return;const P=H.current;P&&(kn(P,P.ownerDocument.createTextNode(`
|
|
14
|
-
`)),Ws(P),Q())}}),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})]}),He.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"]})]}),He.map(v=>n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:v}),n.jsx("input",{type:"text",value:T[v]??_e[v]??"",placeholder:"sample value",onChange:P=>Z(W=>({...W,[v]:P.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(ue.Copyable,{value:We,readOnly:!0,children:n.jsx("pre",{className:"w6w-exprmodal-result",children:We||" "})}),Fe.length>0&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-result-source",children:Fe.join(" · ")})]})]})]}),Y==="var"&&o.createVar&&n.jsx(Uo,{kind:"var",onCreate:o.createVar,onClose:X}),Y==="secret"&&o.createSecret&&n.jsx(Uo,{kind:"secret",onCreate:o.createSecret,onClose:X})]})}function st({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 Mt({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 fc=[["app","App"],["version","App version"],["action","Action"],["connectionId","Connection ID"],["subscriptionId","Subscription ID"],["url","Webhook URL"]],hc=new Set(["app","version","action","connectionId"]);function Uo({kind:e,onCreate:t,onClose:s}){const[o,r]=b.useState(""),[a,i]=b.useState(""),[l,c]=b.useState(""),[u,d]=b.useState(null),[p,f]=b.useState(!1),m=e==="var"?"variable":"secret";async function w(){d(null),f(!0);try{await t({name:o,value:a,description:l||void 0}),s()}catch(h){d(h.message)}finally{f(!1)}}return n.jsxs(Ce,{title:`Add ${m}`,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||p,onClick:w,children:p?"Saving…":"Save"})]})]})}function mc(e,t){return t?e.filter(s=>s.id!==t):e}const us=b.createContext({});function wc({value:e,children:t}){const s=b.useContext(us),o=b.useMemo(()=>({...s,...e}),[s,e]);return n.jsx(us.Provider,{value:o,children:t})}function Ze(){return b.useContext(us)}function Yt({value:e,onChange:t,placeholder:s,masked:o,multiline:r,readOnly:a,options:i,"aria-label":l}){const[c,u]=b.useState(()=>ss(e)),{parts:d,sealed:p}=c,[f,m]=b.useState(0),[w,h]=b.useState(!1),[g,y]=b.useState(!1),x=b.useRef(!1),S=b.useRef(null),A=b.useRef(null),R=Ze(),j={...R,...i??{}},k=R.sealSecret;b.useLayoutEffect(()=>{const _=S.current;!_||p||(zr(_,d),(x.current||_.ownerDocument.activeElement===_)&&(_.focus(),Bs(_),x.current=!1))},[f,p]);const N=()=>{const _=S.current;if(!_)return;const E=qt(_);u($=>({...$,parts:E}));const I=Wt(E,j);t(dn(I.parts))},F=async _=>{if(!k)return!1;h(!0);try{const E=await k(_);return x.current=!1,u({parts:[],sealed:E}),m(I=>I+1),t(E),!0}catch{return!1}finally{h(!1)}},U=_=>{var $;if(g||!o||a||w)return;const E=_.relatedTarget;if(E&&(($=A.current)!=null&&$.contains(E)))return;const I=dn(d);typeof I=="string"&&I!==""&&!at(I)&&F(I)},O=_=>{if(o&&typeof _=="string"&&_.trim()!==""&&!at(_)){F(_);return}x.current=!1,u(ss(_)),m(E=>E+1),t(_)};return p?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}),m(_=>_+1),t("")},children:"Replace"})]}):n.jsxs("div",{className:"w6w-expr",ref:A,onBlur:U,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 _=S.current;_&&Gr(_),N()},onPaste:_=>{var I;_.preventDefault();const E=S.current;E&&(Kr(E,((I=_.clipboardData)==null?void 0:I.getData("text/plain"))??""),N())},onClick:_=>{var I;const E=_.target.closest("[data-x]");E&&(_.preventDefault(),(I=E.closest(".w6w-expr-chip"))==null||I.remove(),N())},onDoubleClick:_=>{const E=_.target;if(E.closest("[data-x]"))return;const I=E.closest(".w6w-expr-chip");if(!I)return;_.preventDefault();const $=Yr(I);if($){const V=$.ownerDocument,H=V.createRange();H.setStartAfter($),H.collapse(!0);const L=V.getSelection();L==null||L.removeAllRanges(),L==null||L.addRange(H)}N()},onKeyDown:_=>{if(_.key!=="Enter"||(_.preventDefault(),!r))return;const E=S.current;E&&(kn(E,E.ownerDocument.createTextNode(`
|
|
15
|
-
`)),Ws(E),N())}}),!a&&n.jsx("button",{type:"button",className:"w6w-expr-edit",title:"Edit expression — browse variables, secrets & step outputs","aria-label":"Edit expression",onClick:()=>y(!0),children:"ƒx"})]}),g&&n.jsx(nn,{value:dn(d),masked:o,multiline:r,options:j,fieldLabel:l,onSave:O,onClose:()=>y(!1)})]})}const bc=/\{\{\s*([^{}]*?)\s*\}\}/g;function Xr(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(`
|
|
16
|
-
`,a),p=d===-1?e.length:d;r.push({start:a,end:p}),a=p}else if(!s&&c==="/*"){const d=e.indexOf("*/",a+2),p=d===-1?e.length:d+2;r.push({start:a,end:p}),a=p}else if(s&&(u==='"""'||u==="'''")){const d=e.indexOf(u,a+3),p=d===-1?e.length:d+3;o.push({start:a,end:p,quote:u}),a=p}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]===`
|
|
17
|
-
`)break;d++}const p=Math.min(d+1,e.length);o.push({start:a,end:p,quote:l}),a=p}else a++}const i=[];for(const l of e.matchAll(bc)){const c=l.index??0,u=c+l[0].length;if(r.some(p=>c>=p.start&&c<p.end))continue;const d=o.find(p=>c>p.start&&c<p.end);i.push({start:c,end:u,ref:l[1],context:d?{kind:"string",...d}:{kind:"code"}})}return i}const yc=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$-]*|\[\d+\]|\["[^"\\]*"\]|\['[^'\\]*'\])*$/,gc=/\.([A-Za-z_$][\w$-]*)|\[(\d+)\]|\["([^"\\]*)"\]|\['([^'\\]*)'\]/g,xc={nodes:["run","nodes"],steps:["run","nodes"],trigger:["run","trigger"],foreach:["run","foreach"],state:["state"],var:["state"],vars:["state"],const:["consts"],consts:["consts"]};function fn(e,t="javascript"){var c;const s=e.trim();if(!yc.test(s))return null;const o=((c=/^[A-Za-z_$][\w$]*/.exec(s))==null?void 0:c[0])??"",r=xc[o];if(!r)return null;const a=[...r.slice(1)];for(const u of s.slice(o.length).matchAll(gc))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 vc(e,t="javascript"){const s=t==="python";let o="",r=0,a=0,i=0;for(const l of Xr(e,t)){const c=fn(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,p=l.start===u.start+d.length,f=l.end===u.end-d.length;if(p&&f)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 m=s?`str(${c})`:c;o+=p?`${e.slice(r,u.start)}${m} + ${d}`:`${e.slice(r,l.start)}${d} + ${m}`,f?r=u.end:(p||(o+=` + ${d}`),r=l.end),a++}else i++}return o+=e.slice(r),{code:o,converted:a,left:i}}function jc({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=Ze(),p=b.useMemo(()=>Rr(d),[d]),f=d.steps??[],m=s==="python",w=j=>{const k=l.current;if(!k){i(t+j);return}k.dispatch(k.state.replaceSelection(j)),k.focus()},h=j=>{const k=ut(j);if(k!==null){const N=fn(k,s);N&&w(N);return}j===void 0||j===""||w(JSON.stringify(j,null,2).replace(/"\{\{\s*([^{}"]*?)\s*\}\}"/g,(N,F)=>fn(F,s)??N))},g=((R=f[0])==null?void 0:R.id)??"<step-id>",y=m?"ctx":"$",x=[[`${y}.get("nodes", ${JSON.stringify(g)}, "output")`,"a step's output"],[`${y}.get("state", "region")`,"a workflow state value"],[`${y}.get("consts", "api_base")`,"a constant"]],S=Math.max(...x.map(([j])=>j.length)),A=m?"#":"//";return n.jsxs("div",{className:"w6w-field w6w-script-code",children:[n.jsxs("span",{children:[o,r]}),n.jsx(Ps,{value:t,readOnly:a,minHeight:"180px",language:s,scriptScope:p,"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"}),f.map(j=>{const k=fn(`nodes[${JSON.stringify(j.id)}].output`,s)??"";return n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Insert ${k}`,onClick:()=>w(k),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,k])=>`${j.padEnd(S)} ${A} ${k}`).join(`
|
|
18
|
-
`)}),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:m?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(nn,{mode:"json-binding",value:void 0,jsonValue:void 0,options:d,fieldLabel:o,whole:!0,onSaveJson:h,onClose:()=>u(!1)})]})}function Fn(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...Fn(s.children));return t}function Zr(e){return at(e)||lt(e)?!0:typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"$")}function Sn(e){var t;return((t=e.config)==null?void 0:t.allowCustom)===!0}function ds(e){return Fn(e).filter(t=>In(t.options))}function qs(e){return In(e.options)?e.options.refreshOn??[]:[]}function ps(e,t){const s={},o=[];for(const r of Fn(e)){if(r.type==="section")continue;const a=t[r.key]!==void 0?t[r.key]:r.default;a!==void 0&&(Zr(a)?o.push(r.key):s[r.key]=a)}return{form:s,unresolved:o}}function Nc(e,t,s,o,r){const{form:a,unresolved:i}=ps(e,t),l=new Set(i),c=ds(e).filter(d=>{const p=qs(d);return s==="change"&&!(o??[]).some(f=>p.includes(f))?!1:p.every(f=>!l.has(f))}).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=ps(e,r??{}).form),u}function Vo(e,t,s){return JSON.stringify([e.appId,e.version??null,e.actionKey,e.connectionId??null,t.key,qs(t).map(o=>s[o]??null)])}function Ho(e){return!(In(e.options)&&e.options.cache==="none")}function kc(e,t){return e.some(s=>t.includes(s))}function Sc(e,t,s,o){var l;if(!o.connectionId)return{reason:"no-connection",hint:"Connect an account to load choices"};const r=new Set(ps(t,s).unresolved),a=qs(e).find(c=>r.has(c));return a===void 0?null:{reason:"unresolved-dependency",hint:`Options unavailable while ${((l=Fn(t).find(c=>c.key===a))==null?void 0:l.label)??a} is an expression`}}function Jo(e,t,s){return e==null||e===""?{action:"keep"}:Zr(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 Cc(e,t,s,o){var S;const r=(S=Dt())==null?void 0:S.resolveActionFields,a=!!(s&&r),[i,l]=b.useState({}),c=b.useRef({params:e,values:t,dynamic:s,onChange:o,resolve:r});c.current={params:e,values:t,dynamic:s,onChange:o,resolve:r};const u=b.useRef(new Map),d=b.useRef([]),p=b.useCallback((A,R,j,k,N)=>{const{params:F,values:U,dynamic:O,resolve:_}=c.current,E=N??U;if(!O||!_||!O.connectionId)return;const I=Nc(F,E,A,R,j);if(!I)return;const $=new Map(ds(F).map(M=>[M.key,M])),V=[],H={},L=[],T=O.appName??O.appId,Z=(M,ee)=>{const Q=$.get(M);if(!Q)return;Jo(E[M],ee,{allowCustom:Sn(Q),reason:A,appLabel:T}).action==="clear"&&V.push(M)};for(const M of I.fields){if(k!==void 0&&M!==k)continue;const ee=$.get(M);if(!ee)continue;const Q=k===void 0&&Ho(ee)?u.current.get(Vo(O,ee,I.form)):void 0;Q?(H[M]={options:Q,loading:!1},Z(M,Q)):L.push(M)}const Y=(M=!1)=>{if(V.length===0)return;const ee={...M?E:c.current.values};for(const Q of V)delete ee[Q];c.current.onChange(ee)};if(Object.keys(H).length>0&&l(M=>({...M,...H})),L.length===0){Y(!0);return}for(const M of d.current)kc(M.fields,L)&&M.controller.abort();const te=new AbortController,B={fields:L,controller:te};d.current=[...d.current.filter(M=>!M.controller.signal.aborted),B],l(M=>{var Q;const ee={...M};for(const C of L)ee[C]={options:(Q=M[C])==null?void 0:Q.options,loading:!0};return ee});const G={...I,fields:L,connectionId:O.connectionId,...O.version!==void 0?{version:O.version}:{}},z=M=>{d.current=d.current.filter(ee=>ee!==B),l(ee=>({...ee,...M}))};Promise.resolve().then(()=>_(O.appId,O.actionKey,G,{signal:te.signal})).then(M=>{var Q;if(te.signal.aborted)return;const ee={};for(const C of L){const q=(Q=M==null?void 0:M.fields)==null?void 0:Q[C],K=$.get(C);if(!q||!K)ee[C]={loading:!1};else if(q.error)ee[C]={loading:!1,error:q.error};else{const le=Array.isArray(q.options)?q.options:[];ee[C]={loading:!1,options:le},Ho(K)&&u.current.set(Vo(O,K,I.form),le),Z(C,le)}}z(ee),Y()}).catch(M=>{if(te.signal.aborted)return;const ee=M instanceof Error?M.message:String(M),Q={};for(const C of L)Q[C]={loading:!1,error:ee||"Request failed"};z(Q)})},[]),f=s?JSON.stringify([s.appId,s.actionKey,s.version,s.connectionId]):"";b.useEffect(()=>{if(a)return l({}),p("init"),()=>{for(const A of d.current)A.controller.abort();d.current=[]}},[f,a,p]);const m=b.useRef(new Map),w=b.useCallback((A,R)=>{const j=m.current.get(A)??c.current.values;m.current.delete(A),p("change",[A],j,void 0,{...c.current.values,[A]:R})},[p]),h=b.useCallback(A=>{m.current.has(A)||m.current.set(A,c.current.values)},[]),g=b.useCallback(A=>{const R=m.current.get(A);if(m.current.delete(A),!R)return;const j=c.current.values;JSON.stringify(R[A])!==JSON.stringify(j[A])&&p("change",[A],R)},[p]),y=b.useCallback(A=>p("init",void 0,void 0,A),[p]);return{fields:b.useMemo(()=>{const A={};if(!a||!s)return A;const R=s.appName??s.appId;for(const j of ds(e)){const k=Sc(j,e,t,s);if(k){A[j.key]={loading:!1,hint:k.hint};continue}const N=i[j.key]??{loading:!0},F={...N};if(N.options){const U=Jo(t[j.key],N.options,{allowCustom:Sn(j),reason:"init",appLabel:R});U.action==="flag"&&(F.notInList=U.message)}A[j.key]=F}return A},[a,s,e,t,i]),commit:w,focus:h,blur:g,retry:y}}function sn(e,t){return e.hidden===!0?!1:e.showIf?ie.matchesParamCondition(e.showIf,t):!0}function Ot(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...Ot(s.children));return t}function Xt(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 Qr(e,t,s,o){const r=a=>a.type==="section"?n.jsx(Ac,{param:a,effective:s,renderOne:r},a.key):a.repeat&&a.type!=="array"?n.jsx(Oc,{param:a,value:e[a.key],onChange:t,readOnly:o},a.key):a.type==="group"&&a.children&&a.children.length>0?n.jsx(Rc,{param:a,value:e[a.key],onChange:t,effective:s,readOnly:o},a.key):n.jsx($c,{param:a,value:e[a.key],onChange:t,effective:s,readOnly:o},a.key);return r}const Ln=b.createContext(null);function Me({params:e,values:t,onChange:s,readOnly:o,dynamic:r}){const a=Cc(e,t,r,s),i=Ot(e),l=m=>{var w;return t[m]!==void 0?t[m]:(w=i.find(h=>h.key===m))==null?void 0:w.default},c=e.filter(m=>sn(m,l)).map(m=>ie.effectiveParam(m,l)),u=c.filter(m=>m.required||!m.advanced),d=c.filter(m=>!m.required&&m.advanced),p=(m,w)=>{if(m==="language"){const h={...t,[m]:w};for(const g of i){if(g.type!=="code")continue;const y=t[g.key];(y===void 0||y===g.default||y===fs||Ic.includes(y))&&(h[g.key]=w==="python"?fs:g.default)}s(h);return}s({...t,[m]:w})};if(e.length===0)return n.jsx("p",{className:"w6w-muted w6w-small",children:"This action takes no parameters."});const f=Qr(t,p,l,o);return n.jsx(Ln.Provider,{value:a,children:n.jsxs("div",{className:"w6w-stack",children:[Xt(u,f),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:Xt(d,f)})]})]})})}function Ac({param:e,effective:t,renderOne:s}){const o=(e.children??[]).filter(r=>sn(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:Xt(o,s)})]}):e.layout==="row"?n.jsx("div",{className:"w6w-field-row",children:o.map(s)}):n.jsx("div",{className:"w6w-stack",children:Xt(o,s)})}const Ec=new Set(["string","text","number","boolean","select"]);function Tc(e){return e.length>0&&e.every(t=>Ec.has(t.type)&&!t.children)}function Rc({param:e,value:t,onChange:s,effective:o,readOnly:r}){const a=e.children??[],i=t??{},l=(f,m)=>s(e.key,{...i,[f]:m}),c=Ot(a),u=f=>{const m=c.find(w=>w.key===f);return m?i[f]!==void 0?i[f]:m.default:o(f)},d=a.filter(f=>sn(f,u)).map(f=>ie.effectiveParam(f,u)),p=Qr(i,l,u,r);return n.jsx(Ln.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:Xt(d,p)})]})})}function Oc({param:e,value:t,onChange:s,readOnly:o}){if(e.type==="group"){const a=e.children??[];if(!Tc(a))return n.jsx(Us,{param:e,value:t,onChange:s,readOnly:o});const i={...e,item:{type:"object",fields:a}};return n.jsx(hs,{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(hs,{param:r,value:t,onChange:s,readOnly:o})}const fs=`# Runs as a function body. Return the step's output.
|
|
19
|
-
return input`,Ic=["// 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 $c(e){const t=b.useContext(Ln),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(Pc,{...e})})}function Pc({param:e,value:t,onChange:s,effective:o,readOnly:r}){var R,j,k,N,F,U;const a=(R=Dt())==null?void 0:R.listModelRoutes,i=(j=Dt())==null?void 0:j.listDataStores,l=(k=Dt())==null?void 0:k.listAgents,c=(N=Dt())==null?void 0:N.listDataStoreEntries,u=Is(),d=b.useContext(Ln),p=d==null?void 0:d.fields[e.key],f=(O,_)=>{s(O,_),d==null||d.commit(O,_)},m=s,w=e.label??e.key,h=e.required&&e.type!=="boolean"?" *":"",g=b.useId();if(e.type==="boolean"){const O=!!(t??e.default??!1);return n.jsx(Pe,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,variant:"inline",controlId:g,children:n.jsx("input",{id:g,type:"checkbox",checked:O,disabled:r,onChange:_=>f(e.key,_.target.checked)})})}if(e.type==="json"||e.type==="group")return n.jsx(Us,{param:e,value:t,onChange:m,readOnly:r});if(e.type==="code"){const O=o==null?void 0:o("language"),_=O==="python"||O==="javascript"||O==="typescript"?O:void 0,E=_==="python"?fs:e.default,I=t??E??"";return e.scriptReads?n.jsx(jc,{param:e,value:String(I),language:O==="python"?"python":"javascript",label:w,req:h,readOnly:r,onChange:$=>m(e.key,$)}):n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[w,h]}),n.jsx(Ps,{value:String(I),readOnly:r,minHeight:"180px",language:_,"aria-label":`${e.key} code`,onChange:$=>m(e.key,$)}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}if(e.type==="model-route"&&a)return n.jsx(_c,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,listModelRoutes:a,project:u});if(e.type==="agent"&&l)return n.jsx(Fc,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,listAgents:l});if(e.type==="data-store"&&i)return n.jsx(Lc,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,listDataStores:i,project:u});const y=o==null?void 0:o("store");if(e.type==="data-store-key"&&c&&typeof y=="string"&&y.trim()!=="")return n.jsx(Bc,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,store:y,listDataStoreEntries:c,project:u});if(e.type==="vars")return n.jsx(Yc,{param:e,value:t,onChange:m,readOnly:r});if(e.type==="text"||(F=e.config)!=null&&F.multiline){const O=t??e.default??"";return n.jsx(Pe,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,children:n.jsx("textarea",{rows:3,value:String(O),readOnly:r,"aria-label":w,onChange:_=>m(e.key,_.target.value)})})}if(e.type==="multiselect")return n.jsx(qc,{param:e,value:t,onChange:f,readOnly:r});if(e.type==="array")return n.jsx(hs,{param:e,value:t,onChange:m,readOnly:r});if(d&&p&&!p.hint)return n.jsx(zo,{param:e,value:t,onChange:f,readOnly:r,label:w,req:h,state:p,retry:()=>d.retry(e.key)});if(Array.isArray(e.options)&&e.options.length>0&&Sn(e))return n.jsx(zo,{param:e,value:t,onChange:f,readOnly:r,label:w,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,_=t??e.default??(O!==void 0?"":(U=e.options[0])==null?void 0:U.value)??"",E=e.type==="number";return n.jsx(Pe,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,children:n.jsxs("select",{value:String(_),disabled:r,"aria-label":w,onChange:I=>{const $=I.target.value;O!==void 0&&$===""?f(e.key,void 0):f(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:[w,h]}),n.jsx(Yt,{value:O,masked:!0,readOnly:r,"aria-label":w,onChange:_=>m(e.key,_)}),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(Pe,{param:e,value:t,onChange:m,readOnly:r,label:w,req:h,children:[n.jsx("input",{type:x,value:A,readOnly:r,"aria-label":w,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",onChange:O=>m(e.key,e.type==="number"?Number(O.target.value):O.target.value)}),(p==null?void 0:p.hint)&&n.jsx("span",{className:"w6w-hint",children:p.hint})]})}function zo({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(Pe,{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(Ye,{mode:"combobox",forceSelection:!Sn(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 _c({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,listModelRoutes:i,project:l}){const[c,u]=b.useState([]);b.useEffect(()=>{let f=!0;return Promise.resolve().then(()=>i(l)).then(m=>f&&u(Array.isArray(m)?m:[])).catch(()=>f&&u([])),()=>{f=!1}},[i,l]);const d=t??e.default??"",p=typeof d=="string"?d:"";return n.jsx(Pe,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Ye,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:p,placeholder:"Select a route…",options:c.map(f=>({value:f.name,label:f.status==="broken"?`${f.name} (broken)`:f.name})),onChange:f=>s(e.key,f)})})}function Fc({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(g=>h&&c(Array.isArray(g)?g:[])).catch(()=>h&&c([])),()=>{h=!1}},[i]);const u=t??e.default??"",d=typeof u=="string"?u:"",p=l??[],f=p.find(h=>h.id===d),m=p.map(h=>({value:h.id,label:h.name||h.id}));d&&!f&&l!==null&&m.unshift({value:d,label:`${d} (not found)`});const w=l!==null&&p.length===0?n.jsx("span",{className:"w6w-muted w6w-small",children:"Create an agent in the Agents dashboard first."}):f!=null&&f.href?n.jsxs("a",{className:"w6w-small",href:f.href,target:"_blank",rel:"noreferrer",children:["Open ",f.name||f.id," in the Agents dashboard ↗"]}):null;return n.jsxs("div",{className:"w6w-agent-field",children:[n.jsx(Pe,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Ye,{mode:"combobox","aria-label":r,disabled:o,value:d,placeholder:l===null?"Loading agents…":p.length===0?"No agents yet":"Select an agent…",options:m,onChange:h=>s(e.key,h)})}),w]})}function Lc({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,listDataStores:i,project:l}){const[c,u]=b.useState([]);b.useEffect(()=>{let f=!0;return Promise.resolve().then(()=>i(l)).then(m=>f&&u(Array.isArray(m)?m:[])).catch(()=>f&&u([])),()=>{f=!1}},[i,l]);const d=t??e.default??"",p=typeof d=="string"?d:"";return n.jsx(Pe,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Ye,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:p,placeholder:"Select a store…",options:c.map(f=>({value:f.name,label:`${f.name} (${f.kind})`})),onChange:f=>s(e.key,f)})})}const Mc=25,Dc=200,Ko=60;function Wc(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>Ko&&(t=`${t.slice(0,Ko-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 Bc({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,store:i,listDataStoreEntries:l,project:c}){const[u,d]=b.useState(""),[p,f]=b.useState({items:[]}),[m,w]=b.useState(!0);b.useEffect(()=>{const x=new AbortController;w(!0);const S=u.trim(),A=setTimeout(()=>{Promise.resolve().then(()=>l(i,{project:c,prefix:S===""?void 0:S,limit:Mc,signal:x.signal})).then(R=>{x.signal.aborted||(f(R&&Array.isArray(R.items)?R:{items:[]}),w(!1))}).catch(()=>{x.signal.aborted||(f({items:[]}),w(!1))})},S===""?0:Dc);return()=>{clearTimeout(A),x.abort()}},[l,i,c,u]);const h=t??e.default??"",g=typeof h=="string"?h:"",y=u.trim();return n.jsx(Pe,{param:e,value:t,onChange:s,readOnly:o,label:r,req:a,children:n.jsx(Ye,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:g,placeholder:"Search entries or type a key…",options:p.items.map(x=>({value:x.key,label:x.key,detail:Wc(x)||void 0})),onInputChange:d,emptyText:m?"Searching…":y!==""?`No key starts with "${y}" — Enter keeps it as typed`:"No entries in this store",footer:p.more?"More entries — type to narrow by key":void 0,onChange:x=>s(e.key,x)})})}function Pe({param:e,value:t,onChange:s,readOnly:o,label:r,req:a,bare:i,variant:l="boxed",controlId:c,children:u}){var y;const d=at(t),p=e.type==="text"||!!((y=e.config)!=null&&y.multiline),[f,m]=b.useState(!1),w=Ze(),h=l==="inline"&&!d,g=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:h?"w6w-fx-inline":`w6w-fx-wrap${d?" is-fx":""}`,children:d?n.jsx(Yt,{value:t,multiline:p,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:()=>m(!0),children:"ƒx"}),h&&n.jsxs("label",{className:"w6w-fx-inline-label",htmlFor:c,children:[r,a]})]})}),f&&n.jsx(nn,{value:t,multiline:p,options:w,fieldLabel:r,onSave:x=>s(e.key,x),onClose:()=>m(!1)})]});return i?g:n.jsxs("div",{className:"w6w-field",children:[!h&&n.jsxs("span",{children:[r,a]}),g,e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}function Us({param:e,value:t,onChange:s,readOnly:o,headerActions:r,onValidityChange:a}){var U;const i=ut(t)??"",l=i!=="",c=t??e.default,[u,d]=b.useState(()=>l||c===void 0?"":JSON.stringify(c,null,2)),[p,f]=b.useState(!1),[m,w]=b.useState(!1),[h,g]=b.useState(!1),y=Ze(),x=y.steps??[],S=(((U=y.stateShape)==null?void 0:U.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)),f(!1))},[c,e.key,l]);const A=O=>{d(O)},R=O=>{f(!1),a==null||a(!0),s(e.key,O)},j=({valid:O,error:_})=>{if(a==null||a(O||_==="Empty"),!O&&_==="Empty"){f(!1),s(e.key,void 0);return}f(!O)},k=()=>{const O=dc(u);O&&(f(!1),s(e.key,O))},N=e.label??e.key,F=()=>{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:[N,e.required?" *":""]}),r,!l&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-btn-sm",title:"Open in full view","aria-label":`Open ${N} in full view`,onClick:()=>w(!0),children:n.jsx(ue.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:wt(i)}),!o&&n.jsx("button",{type:"button",className:"w6w-expr-chip-x","aria-label":`Remove the reference from ${N}`,style:{border:0,padding:0,font:"inherit"},onClick:F,children:"×"})]})}),!o&&n.jsx("button",{type:"button",className:"w6w-expr-edit",title:"Edit expression — browse step outputs, metadata & variables","aria-label":`Edit expression for ${N}`,onClick:()=>g(!0),children:"ƒx"})]})})}):n.jsx(Ke,{value:u,onChange:A,onBlur:k,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 ${N}`,onClick:()=>g(!0),children:"ƒx"})}),h&&n.jsx(nn,{mode:"json-binding",value:void 0,jsonValue:t,options:y,fieldLabel:N,whole:e.whole,onSaveJson:O=>s(e.key,O),onClose:()=>g(!1)}),!l&&p&&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 ${N} 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 ${N} 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}),m&&!l&&n.jsxs(Ce,{title:N,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>w(!1),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Ke,{value:u,onChange:A,readOnly:o,height:"100%",minHeight:"360px","aria-label":`${e.key} JSON (full view)`,onValidChange:R,onValidityChange:j})}),p&&n.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]})}function qc({param:e,value:t,onChange:s,readOnly:o}){var y;const r=Array.isArray(e.options)?e.options:[],a=((y=e.config)==null?void 0:y.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)},p=x=>s(e.key,a?x.join(","):x),f=x=>{if(!x||c.has(x))return;const S=r.find(A=>String(A.value)===x);p([...l,S?S.value:x])},m=x=>p(l.filter(S=>String(S)!==String(x))),w=typeof e.placeholder=="string"&&e.placeholder?e.placeholder:"Select…",h=e.label??e.key,g=e.required?" *":"";return n.jsx(Pe,{param:e,value:t,onChange:s,readOnly:o,label:h,req:g,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:()=>p([...l,...u.map(x=>x.value)]),children:"Select all"}),n.jsx("button",{type:"button",className:"w6w-linkbtn",disabled:l.length===0,onClick:()=>p([]),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?f(String(x.value)):m(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:()=>m(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=>f(x.target.value),children:[n.jsx("option",{value:"",children:u.length>0?l.length?"Add more…":w:"All selected"}),u.map(x=>n.jsx("option",{value:String(x.value),children:x.label},String(x.value)))]})]})})})}function Uc(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 Vc({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(ue.Icon,{name:"maximize",size:14})}),a!==null&&n.jsxs(Ce,{title:e,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>i(null),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Ke,{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 Hc({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 p=String((s==null?void 0:s[i])??"string");if(p==="boolean"){const f=t===!0||t==="true"?"true":t===!1||t==="false"?"false":"";return n.jsxs("select",{className:"w6w-array-input",value:f,disabled:r,"aria-label":l,onChange:m=>o(m.target.value),children:[n.jsx("option",{value:"",children:"(none)"}),n.jsx("option",{value:"true",children:"true"}),n.jsx("option",{value:"false",children:"false"})]})}if(p==="json")return n.jsx(Vc,{label:l,value:t,onChange:o,readOnly:r});if(p==="number")return n.jsx("input",{className:"w6w-array-input",type:"number",value:t==null?"":String(t),placeholder:a,"aria-label":l,readOnly:r,onChange:f=>o(f.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:p=>o(p.target.value),children:e.options.map(p=>n.jsx("option",{value:String(p.value),children:p.label},String(p.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:p=>o(p.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:p=>o(c?Number(p.target.value):p.target.value)})}function hs({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=f=>s(e.key,f),c=()=>a?Object.fromEntries((r.fields??[]).map(f=>{var m;return[f.key,f.default??(f.type==="boolean"&&!((m=f.config)!=null&&m.valueTypeFrom)?!1:"")]})):r.type==="number"?0:r.type==="boolean"?!1:"",u=(f,m)=>l(i.map((w,h)=>h===f?m:w)),d=f=>{const w={...f??{}};for(const h of r.fields??[])w[h.key]===void 0&&(w[h.key]=h.default);return w},p=(f,m,w)=>{var g;const h={...f??{},[m]:w};for(const y of r.fields??[])((g=y.config)==null?void 0:g.valueTypeFrom)===m&&!Uc(String(w??""),h[y.key])&&(h[y.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(f=>f.type==="boolean"&&!(Array.isArray(f.options)&&f.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:f.label??f.key})]},f.key):n.jsxs("span",{className:"w6w-array-head-cell",children:[f.label??f.key,f.required?" *":""]},f.key))}),!o&&n.jsx("span",{className:"w6w-array-x w6w-array-head-ghost"})]}),i.map((f,m)=>n.jsxs("div",{className:"w6w-array-row",children:[a?n.jsx("div",{className:"w6w-array-cells",children:(r.fields??[]).map(w=>n.jsx(Hc,{field:w,value:f==null?void 0:f[w.key],row:d(f),readOnly:o,onChange:h=>u(m,p(f,w.key,h))},w.key))}):n.jsx("input",{className:"w6w-array-input",type:r.type==="number"?"number":"text",value:String(f??""),placeholder:r.placeholder,readOnly:o,onChange:w=>u(m,r.type==="number"?Number(w.target.value):w.target.value)}),!o&&n.jsx("button",{type:"button",className:"w6w-array-x","aria-label":"Remove item",title:"Remove",onClick:()=>l(i.filter((w,h)=>h!==m)),children:"×"})]},m)),!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 Jc=["string","number","boolean","json"],zc=[];function Cn(e,t=[]){return Array.isArray(e)?e.every(s=>s&&typeof s=="object"&&typeof s.key=="string")?e:null:!e||typeof e!="object"||at(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 Kc(e){const t=Array.isArray(e)?Cn(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 Go(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 Yo(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Xo(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 Gc({param:e,value:t,label:s,onChange:o,readOnly:r}){const[a,i]=b.useState(null),l=()=>i(Xo(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(Pe,{bare:!0,param:e,value:t,onChange:(d,p)=>o(p),readOnly:r,label:s,req:"",children:[n.jsx("input",{type:"text",className:"w6w-datavar-json-preview",value:Xo(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(ue.Icon,{name:"maximize",size:14})})]}),a!==null&&n.jsxs(Ce,{title:s,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>i(null),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Ke,{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 Yc({param:e,value:t,onChange:s,readOnly:o}){const r=t??e.default??zc,a=b.useMemo(()=>Kc(r),[r]),[i,l]=b.useState(()=>Array.isArray(r)?"fields":"json"),c=b.useRef([]),[u,d]=b.useState(!1),[p,f]=b.useState(null),m=Cn(r,c.current),w=m??[],h=i==="json"||m===null,g=e.label??e.key,y=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 ${g} as fields`,"aria-pressed":!h,disabled:u||!!p||m===null,title:m===null?"Use a literal JSON object to edit individual fields":"Edit individual fields",onClick:()=>{!o&&!Array.isArray(r)&&s(e.key,w),l("fields")},children:"Fields"}),n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${h?" active":""}`,"aria-label":`Edit ${g} as JSON`,"aria-pressed":h,onClick:()=>{c.current=w,l("json")},children:"JSON"})]});if(h)return n.jsxs("div",{className:"w6w-datavar-json",children:[n.jsx(Us,{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:y,onValidityChange:A=>d(!A),onChange:(A,R)=>{if(R!==void 0&&Cn(R)===null&&!ut(R)&&!at(R)&&!(R&&typeof R=="object"&&"$expr"in R)){f("Use a JSON object, a typed key/value array, or an object binding.");return}f(null),d(!1),s(A,R)}}),p&&n.jsx("span",{className:"w6w-hint w6w-datavar-error","aria-live":"polite",children:p})]});const x=A=>s(e.key,A),S=(A,R)=>x(w.map((j,k)=>k===A?{...j,...R}:j));return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{className:"w6w-field-labelrow",children:[n.jsxs("span",{children:[g,e.required?" *":""]}),y]}),n.jsxs("div",{className:"w6w-stack",children:[w.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No variables yet — add one below."}),w.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",{})]}),w.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 k=j.target.value;S(R,{type:k,value:Go(k,Yo(A.value))})},children:Jc.map(j=>n.jsx("option",{value:j,children:j},j))}),A.type==="json"?n.jsx(Gc,{param:e,value:A.value,label:A.key||"value",onChange:j=>S(R,{value:j}),readOnly:o}):n.jsx(Pe,{bare:!0,param:e,value:A.value,onChange:(j,k)=>S(R,{value:k}),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:Yo(A.value),readOnly:o,onChange:j=>S(R,{value:Go(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(w.filter((j,k)=>k!==R)),children:"×"})]},R)),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>x([...w,{key:"",type:"string",value:""}]),children:"+ Add variable"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const ms={onCopy:e=>{Zo(e)},onCut:e=>{const t=Zo(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 Zo(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 ea(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 hn({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:p=>a(i.key,p.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(eu,{field:i,value:String(c??""),onChange:p=>a(i.key,p)},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?"w6w-secret-input":void 0,...u?ms:{},rows:i.type==="json"?6:3,value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:p=>a(i.key,p.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?ms:{},value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:p=>a(i.key,i.type==="number"&&!(l&&p.target.value==="")?Number(p.target.value):p.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 Xc=/(^|_)(private_key|secret|password|token)$/i,Qo=["client_email","client_id","project_id","private_key_id","private_key"],Zc=["type","universe_domain"];function Qc(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=Qo.indexOf(o);return r===-1?Qo.length:r};return Object.entries(t).filter(([o,r])=>typeof r=="string"&&r!==""&&!/^https?:\/\//.test(r)&&!Zc.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:Xc.test(o)}))}function eu({field:e,value:t,onChange:s}){const o=b.useRef(null),r=t.trim()===""?null:Qc(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 ta({auth:e,scopes:t=!0}){const s=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(tu,{steps:e.setup}):null,t&&s&&s.scopes.length>0&&n.jsx(na,{scopes:s.scopes})]})}function tu({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))})]})}function na({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 sa({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 oa(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 ra(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 nu="width=560,height=720,menubar=no,toolbar=no,location=no";function aa(e){return new Promise((t,s)=>{const o=window.open(e,"w6w-oauth",nu);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 su=new Set(["checkbox","radio","button","submit","reset","file","range","color","image","hidden","date","datetime-local","month","week","time"]);function ou(e){return e.closest('[contenteditable]:not([contenteditable="false"])')!==null}function ia(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"&&(ou(o)||o.tagName==="INPUT"&&su.has(o.type)||(s.preventDefault(),e()))}}}function Vs(e){const t=ke(),[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=p=>{l||(o(p),a(!1))},u=t.listAppsByIds;if(u)return u([i]).then(p=>c(p.find(f=>f.id===i)??null)).catch(()=>c(null)),()=>{l=!0};const d=t.listApps;return typeof d=="function"?d().then(p=>c(p.find(f=>f.id===i)??null)).catch(()=>c(null)):c(null),()=>{l=!0}},[t,e.initialAppId]),s?n.jsx(Ce,{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(la,{app:s,onCreated:e.onCreated,onClose:e.onClose})}):r?n.jsx(Ce,{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(Ce,{title:"Add connection",onClose:e.onClose,size:"xl",children:n.jsx("div",{className:"w6w-stepbuilder-content",children:n.jsx(rt,{onSelectApp:o,theme:e.theme,searchPlaceholder:"Search apps to connect…",categoryFilter:!0})})})}function la({app:e,onCreated:t,onClose:s}){var ge;const o=ke(),[r,a]=b.useState(null),[i,l]=b.useState(""),[c,u]=b.useState(""),[d,p]=b.useState({}),[f,m]=b.useState(null),[w,h]=b.useState(!1),[g,y]=b.useState(null),[x,S]=b.useState(null),[A,R]=b.useState(""),[j,k]=b.useState({}),[N,F]=b.useState("account"),[U,O]=b.useState(!0),[_,E]=b.useState(!1);b.useEffect(()=>{let J=!1;return a(null),o.getAppAuth(e.id).then(re=>!J&&a(re.filter(ae=>ae.available!==!1))).catch(re=>!J&&m(re.message)),()=>{J=!0}},[o,e.id]);const I=r??[],$=I.find(J=>J.key===i)??I.find(J=>J.default===!0)??I[0],V=($==null?void 0:$.fields)??[],H=($==null?void 0:$.type)==="oauth2",L=$==null?void 0:$.serviceAccount,T=($==null?void 0:$.accepts)??(L==null?void 0:L.accepts)??[],Z=o.listCredentials,Y=!H&&T.length>0&&typeof Z=="function",te=(g??[]).filter(J=>J.status==="active"&&!J.private&&J.accessScope!=="user"&&T.includes(J.contract)),B=($==null?void 0:$.userScope)===!0&&!H&&($==null?void 0:$.key)!=="zero-credential",G=B&&N==="user",z=($==null?void 0:$.refreshable)===!0&&($==null?void 0:$.key)!=="zero-credential",M=z&&!U,ee=G||te.length===0?"new":x??"existing",Q=te.some(J=>J.id===A)?A:((ge=te[0])==null?void 0:ge.id)??"",C=Y&&L?oa(L):[],q=($==null?void 0:$.key)??"";b.useEffect(()=>{if(!Y||!Z)return;let J=!1;return y(null),S(null),Z.call(o,{appId:e.id,authKey:q}).then(re=>!J&&y(re)).catch(()=>!J&&y([])),()=>{J=!0}},[o,e.id,Y,q,Z]);const K=($==null?void 0:$.key)==="zero-credential",le=J=>J===void 0||J==="",X=!H&&!K&&(Y?g===null||C.some(J=>J.required&&le(j[J.key]))||(ee==="existing"?Q==="":V.some(J=>J.required&&le(d[J.key]))):V.some(J=>J.required&&le(d[J.key]))),xe=!$||!H&&!K&&X||w;async function he(){if($){m(null),h(!0);try{if(K)t({connectionId:`zerocred:${e.id}`});else if(H){const{authorizationUrl:J}=await o.startAppOAuthFlow(e.id,$.key,{displayName:c||void 0,...M?{autoRefresh:!1}:{}}),{connectionId:re}=await aa(J);t({connectionId:re})}else if(Y&&ee==="existing"){const J=ra(C,j),re={authKey:$.key,credentialId:Q,...J?{binding:J}:{},...c?{displayName:c}:{},...M?{autoRefresh:!1}:{}},ae=await o.createConnection(e.id,re);t({connectionId:ae.id})}else{const J=ea(V,d);if("error"in J){m(J.error);return}let re=J.values;if(L){re={};for(const ce of C){const ye=j[ce.key];ye==null||ye===""||(re[ce.key]=ce.key==="delegatedUser"?String(ye):ye)}Object.assign(re,d)}const ae=await o.createConnection(e.id,{authKey:$.key,credential:re,displayName:c||void 0,...G?{accessScope:"user"}:{},...M?{autoRefresh:!1}:{}});t({connectionId:ae.id})}}catch(J){m(J.message)}finally{h(!1)}}}const we=ia(he,{enabled:!xe});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:J=>{l(J.target.value),p({}),k({}),S(null),F("account"),O(!0),m(null)},children:I.map(J=>n.jsxs("option",{value:J.key,children:[J.displayName??J.key," (",J.type,")"]},J.key))})]}),$&&n.jsxs(n.Fragment,{children:[!K&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Display name"}),n.jsx("input",{type:"text",value:c,onChange:J=>u(J.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",...we})]}),n.jsx(ta,{auth:$,scopes:!1}),K?null:H?n.jsxs("p",{className:"w6w-muted w6w-small",children:["You'll be redirected to ",n.jsx("strong",{children:$.displayName??$.key})," to authorize this connection."]}):Y?n.jsxs(n.Fragment,{children:[g===null&&!G&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading credentials…"}),!G&&n.jsx(sa,{credentials:te,mode:ee,onModeChange:S,selectedId:Q,onSelect:R}),ee==="existing"&&te.length>0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Reusable credential · This account"}),L&&L.scopes.length>0&&n.jsx(na,{scopes:L.scopes}),C.length>0&&n.jsx(hn,{fields:C,values:j,onChange:k,enterSubmitProps:we}),ee==="new"&&(g!==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(hn,{fields:V,values:d,onChange:p,enterSubmitProps:we})]})]}):n.jsx(hn,{fields:V,values:d,onChange:p,enterSubmitProps:we})]}),(B||z)&&n.jsx(au,{open:_,onToggle:()=>E(J=>!J),owner:B?{value:N,onChange:F}:void 0,keepConnected:z?{value:U,onChange:O}:void 0}),f&&n.jsx("div",{className:"w6w-result w6w-error",children:f})]})}),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:xe,onClick:he,children:w?K?"Saving…":H?"Waiting for authorization…":"Saving…":K?"Use this":H?`Sign in with ${($==null?void 0:$.displayName)??($==null?void 0:$.key)??"provider"}`:"Save connection"})]})]})}const ru=[{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 au({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"}),ru.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 iu=la,It=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Hs=[["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)"]],cn={"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."},ca=new Set(Hs.map(([e])=>e)),ua=new Set(["is-true","is-false","has-value","is-empty"]),lu=new Set(["and","or","xor","!","!!","==","!=",...ca]);function er(e){if(!It(e))return!0;const t=Object.keys(e);return!(t.length===1&&lu.has(t[0]))}function tr(e){return ua.has(e)}const nr={...Object.fromEntries(Hs),"==":"equals","!=":"does not equal",in:"is in"};function cu(e){return e.startsWith("not:")?`Not (${nr[e.slice(4)]??e.slice(4)})`:nr[e]??e}const da=[["and","All of (AND)"],["or","Any of (OR)"],["xor","Exactly one of (XOR)"]],pa=Object.fromEntries(da);function uu(e){return pa[e]??e}function Js(e,t=!0){if(!It(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&&er(r[0]))return{left:r[0],operator:"has-value",right:!0};if(o==="!"&&Array.isArray(r)&&r.length===1){const a=Js(r[0],!1);return a?t&&!a.negated?{...a,negated:!0}:void 0:er(r[0])?{left:r[0],operator:"is-empty",right:!0}:void 0}if(!(!ca.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(!ua.has(o))return{left:r[0],operator:o,right:r[1]}}}function du(e){if(!(!It(e)||Object.keys(e).length!==1))return Js(e.$expr)}function pu(e){const t=du(e);if(t)return{combinator:"and",rows:[t]};if(!It(e)||Object.keys(e).length!==1||!It(e.$expr))return;const s=Object.entries(e.$expr);if(s.length!==1)return;const[o,r]=s[0];if(!Object.hasOwn(pa,o)||!Array.isArray(r)||r.length===0)return;const a=r.map(i=>Js(i));if(!a.some(i=>i===void 0))return{combinator:o,rows:a}}function sr(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 ws(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"?Pn(e):Xe(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 or(e){return typeof e=="string"?ws(e)===e?e:JSON.stringify(e):It(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 fa={left:"",operator:"is-true",right:!0},rr={combinator:"and",rows:[fa]},fu=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Mn({values:e,onChange:t,readOnly:s,purpose:o="if"}){const r=Ze(),a=e.condition===void 0?!0:e.condition,i=pu(a),[l,c]=b.useState(!1),[u,d]=b.useState(i??rr),p=b.useRef(0),[f,m]=b.useState(()=>u.rows.map(()=>p.current++)),w=i!==void 0||typeof a=="boolean",h=fu(sr(u),a)?u:i??rr,g=h.rows.map((j,k)=>f[k]??-1-k),y=(j,k=g)=>{d(j),m(k),t({...e,condition:sr(j)})},x=(j,k)=>y({...h,rows:h.rows.map((N,F)=>F===j?{...N,...k}:N)}),S=()=>y({...h,rows:[...h.rows,fa]},[...g,p.current++]),A=j=>y({...h,rows:h.rows.filter((k,N)=>N!==j)},g.filter((k,N)=>N!==j)),R=h.rows.length>1;return n.jsxs("div",{className:"w6w-condition-editor",children:[l||!w?n.jsx(Me,{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=>y({...h,combinator:j.target.value}),children:da.map(([j,k])=>n.jsx("option",{value:j,children:k},j))}),h.rows.map((j,k)=>{const N=tr(j.operator);return n.jsxs("div",{className:`w6w-condition-row${R?" w6w-condition-row-removable":""}${N?" 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 ${k+1}`,checked:j.negated??!1,disabled:s,onChange:F=>x(k,{negated:F.target.checked})}),"Not"]}),n.jsx(Yt,{value:or(j.left),"aria-label":"Condition field",placeholder:"Field or expression",readOnly:s,onChange:F=>x(k,{left:ws(F)})}),n.jsx("select",{className:"w6w-condition-comparison","aria-label":"Condition comparison",title:cn[j.operator],disabled:s,value:j.operator,onChange:F=>x(k,{operator:F.target.value,right:F.target.value==="is-true"?!0:F.target.value==="is-false"?!1:tr(F.target.value)?!0:N?"":j.right}),children:Hs.map(([F,U])=>n.jsx("option",{value:F,title:cn[F],children:U},F))}),!N&&n.jsx(Yt,{value:or(j.right),"aria-label":"Condition value",placeholder:"Value or expression",readOnly:s,onChange:F=>x(k,{right:ws(F)})}),R&&!s&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-condition-remove",title:"Remove condition","aria-label":`Remove condition ${k+1}`,onClick:()=>A(k),children:n.jsx(ue.Icon,{name:"trash",size:14})})]},g[k])}),!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=>cn[j]?n.jsx("p",{className:"w6w-muted w6w-small",children:cn[j]},j):null)]}),w&&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(ue.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 hu={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 ha({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:hu[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 ma({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(ha,{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 Dn(e){return e.$merge!==void 0}function wa(e){const t=e.$merge;if(t===void 0)return e;if(!(ut(t)||Xe(t)||Ls(t)||typeof t=="string"&&Pn(t)))return t&&typeof t=="object"&&!Array.isArray(t)&&!lt(t)&&!("$merge"in t)?{...e,...t}:null}function ba(e,t,s=[]){if(Xe(e)||lt(e)||Fs(e)||Ls(e)||e===null||typeof e!="object")return Kt(e,t);const o=r=>ba(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 zs({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(Me,{params:[{key:"$merge",label:"JSON customization",type:"json",required:!0,default:{},whole:!0}],values:e,onChange:t,readOnly:s}),wa(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&&Dn(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 Ks(e){const{label:t,onClick:s,disabled:o,className:r,...a}=e;return n.jsx(_n,{label:t,onClick:s,disabled:o,className:r,danger:!0,icon:"delete","data-testid":a["data-testid"]})}function ya({values:e,onChange:t,readOnly:s}){const o=Array.isArray(e.routes)?e.routes:Nn(Ge,"route").routes,r=o.filter(y=>!y.default),[a,i]=b.useState(null),[l,c]=b.useState(null),[u,d]=b.useState(null),[p,f]=b.useState(""),m=y=>t({...e,routes:[...y,...o.filter(x=>x.default)]}),w=(y,x)=>m(r.map(S=>S.id===y?{...S,...x}:S)),h=(y,x)=>{const S=r.findIndex(j=>j.id===y);if(S<0||x<0||x>=r.length||S===x)return;const A=[...r],[R]=A.splice(S,1);A.splice(x,0,R),m(A)},g=y=>{p.trim()&&w(y.id,{label:p.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((y,x)=>n.jsxs("div",{className:`w6w-router-route${a===y.id?" is-dragging":""}${l===y.id?" is-drop-target":""}`,"data-route-id":y.id,onDragOver:S=>{s||!a||a===y.id||(S.preventDefault(),S.dataTransfer.dropEffect="move",c(y.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 ${y.label||y.id}`,title:"Drag to reorder · arrow keys to move",onDragStart:S=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",y.id);const A=S.currentTarget.closest(".w6w-router-route");A&&S.dataTransfer.setDragImage(A,16,16),i(y.id)},onDragEnd:()=>{i(null),c(null)},onKeyDown:S=>{S.key!=="ArrowUp"&&S.key!=="ArrowDown"||(S.preventDefault(),h(y.id,x+(S.key==="ArrowUp"?-1:1)))},children:n.jsx(ue.Icon,{name:"grip",size:14})}),n.jsx("span",{className:"w6w-step-rename",children:u===y.id&&!s?n.jsx("input",{autoFocus:!0,"aria-label":"Route name",value:p,onChange:S=>f(S.target.value),onBlur:()=>g(y),onKeyDown:S=>{S.key==="Enter"&&g(y),S.key==="Escape"&&d(null)}}):n.jsxs("button",{type:"button",className:"w6w-router-route-name",disabled:s,"aria-label":`Rename ${y.label||y.id}`,onClick:()=>{f(y.label||y.id),d(y.id)},children:[y.label||y.id,!s&&n.jsx(ue.Icon,{name:"edit",size:12})]})}),n.jsx(Ks,{label:`Remove ${y.label||y.id}`,disabled:s,onClick:()=>m(r.filter(S=>S.id!==y.id))})]}),n.jsx(Mn,{values:{condition:y.condition??!1},onChange:S=>w(y.id,{condition:S.condition}),readOnly:s,purpose:"router"})]},y.id))}),n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-router-add",disabled:s,onClick:()=>{let y=1;for(;o.some(x=>x.id===`route_${y}`);)y++;m([...r,{id:`route_${y}`,label:`Route ${y}`,condition:!1}])},children:[n.jsx("span",{"aria-hidden":"true",children:"+"})," Add route"]})]})}function ga({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(),p=d&&d!==e?t(d):null;if(p){c(p);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(ue.Icon,{name:"edit",size:15})})]}),l&&n.jsx("span",{className:"w6w-hint",role:"alert",style:{color:"var(--w6w-danger)"},children:l})]})}function xa({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(Mn,{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 mu=["props","code"];function wu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function va({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,p]=b.useState(()=>ar(t)),[f,m]=b.useState(!0),w=b.useRef(!0),h=x=>{x!==w.current&&(w.current=x,m(x),o==null||o(x))},g=x=>{x==="code"&&p(ar(t)),h(!0),c(x)},y=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(qn,{view:l,views:[...mu],onChange:x=>g(x)})}),u?n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:y}),n.jsx(Ke,{value:d,onChange:p,readOnly:r,minHeight:"140px","aria-label":`${y} JSON`,onValidChange:x=>{const S=wu(x);h(S),S&&s(x)},onValidityChange:x=>{x.valid||h(!1)}}),!f&&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(Me,{params:e,values:t,onChange:s,readOnly:r})]})}function ar(e){return JSON.stringify(e??{},null,2)}function bu(e){return e===null||typeof e!="object"||Array.isArray(e)?null:e}function ja({app:e,trigger:t,onUse:s}){const o=ke(),[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(bu((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 yu=new Set(["http:","https:","mailto:"]);function gu(e){try{return yu.has(new URL(e).protocol)?e:""}catch{return""}}const xu=["img"];function vu({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 Na(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 ju({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 Gs({content:e,className:t,copyable:s=!0}){const{frontmatter:o,body:r}=Na(e),a=n.jsxs("div",{className:t,children:[(o==null?void 0:o.trim())&&n.jsx(ju,{yaml:o}),n.jsx(Ci,{skipHtml:!0,urlTransform:gu,disallowedElements:xu,unwrapDisallowed:!0,components:{a:vu},children:r})]});return s?n.jsx(ue.Copyable,{value:e,label:"Copy Markdown",className:"w6w-copyable--document",children:a}):a}const ir="w6w-data-table-actions";function Nu(e,t){return e.render?e.render(t):String(t[e.key]??"")}function ka(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?ir:void 0,style:{width:d.width,textAlign:d.align},scope:"col",children:d.header},d.key))})}),n.jsx("tbody",{children:s.map(d=>{var f;const p=a==null?void 0:a(d);return n.jsx("tr",{"data-testid":(f=e.rowTestId)==null?void 0:f.call(e,d),className:r?"w6w-data-table-row-clickable":void 0,onClick:r?m=>r(d,m):void 0,children:t.map(m=>{const w=Nu(m,d);return n.jsx("td",{className:m.actions?ir:void 0,style:{textAlign:m.align},children:p!==void 0&&m.link!==!1?n.jsx("a",{className:"w6w-data-table-link",href:p,children:w}):m.actions&&w!==null&&w!==void 0?n.jsx("div",{className:"w6w-data-table-actions-row",children:w}):w},m.key)})},o(d))})})]})})}const Sa="default-src 'none'; style-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'";function Ca(e){return`<!doctype html><meta http-equiv="Content-Security-Policy" content="${Sa}">${e}`}function Aa({html:e}){return n.jsx("iframe",{title:"HTML preview",className:"w6w-html-preview",sandbox:"",referrerPolicy:"no-referrer",srcDoc:Ca(e)})}function Ea(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":"null"}function ku(e){return Ea(e)==="string"?JSON.stringify(e):String(e)}function Su(e){return typeof e=="object"&&e!==null}function Cu(e,t){return`${t} ${e?"item":"key"}${t===1?"":"s"}`}function Au({value:e,expandDepth:t=2}){return n.jsx(Ta,{label:void 0,value:e,depth:0,expandDepth:t})}function Ta(e){const{label:t,value:s,depth:o,expandDepth:r}=e,a=Su(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:Cu(i,l.length)})]}),n.jsx("div",{className:"w6w-json-children",children:l.map(([u,d])=>n.jsx(Ta,{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":Ea(s)}`,children:a?i?"[]":"{}":ku(s)})]})}const bs=262144,Eu=/^#{1,6}\s+\S/,Tu=/^```/,Ru=/^\s*(?:[-*+]|\d+\.)\s+\S/,Ou=/\[[^\]\n]+\]\(https?:\/\/[^)\s]+\)/;function Ra(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(`
|
|
20
|
-
`);return s.some(o=>Eu.test(o)||Tu.test(o))||s.filter(o=>Ru.test(o)).length>=2||Ou.test(t)?{format:"markdown",text:e}:{format:"text",text:e}}function Oa(e){return e.format==="json"?JSON.stringify(e.data,null,2)??"":e.text}function lr(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Iu(e){if(!lr(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(lr)}function $u(e){try{return JSON.stringify(e).length}catch{return Number.POSITIVE_INFINITY}}function Pu(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 _u=65536;function Xn(e,t){return e.length>_u?n.jsx("pre",{className:"w6w-result-viewer-text",children:e}):n.jsx(ue.CodeBlock,{code:e,language:t,copyable:!1,wrap:!0})}function Ee(e){const{value:t,format:s="auto",maxHeight:o=320,className:r}=e,a=b.useMemo(()=>s==="json"?{format:"json",data:t}:Ra(t),[t,s]),[i,l]=b.useState("rendered"),[c,u]=b.useState("table"),[d,p]=b.useState(2),[f,m]=b.useState(0),w=a.format==="json"?"":a.text,h=a.format==="html"||a.format==="markdown",g=h&&w.length>bs,y=b.useMemo(()=>a.format!=="json"||!Iu(a.data)?null:{table:a.data,tooLarge:$u(a.data)>bs},[a]),x=y!==null&&!y.tooLarge&&c==="table",S=b.useMemo(()=>((y==null?void 0:y.table.columns)??[]).map((N,F)=>({key:`${F}:${N}`,header:N,render:({row:U})=>Pu(U[N])})),[y]),A=b.useMemo(()=>((y==null?void 0:y.table.rows)??[]).map((N,F)=>({i:F,row:N})),[y]),R=b.useMemo(()=>{try{return Oa(a)}catch{return typeof t=="string"?t:String(t)}},[a,t]);let j;if(a.format==="json"){const N=n.jsx(Au,{value:a.data,expandDepth:d},f);x?j=n.jsx(ka,{columns:S,rows:A,rowKey:F=>String(F.i),className:"w6w-result-viewer-table",testId:"result-viewer-table"}):y!=null&&y.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."}),N]}):j=N}else if(a.format==="xml")j=Xn(a.text,"markup");else if(a.format==="text")j=n.jsx("pre",{className:"w6w-result-viewer-text",children:a.text});else{const N=a.format==="html"?"markup":"markdown";g?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."}),Xn(a.text,N)]}):i==="source"?j=Xn(a.text,N):a.format==="html"?j=n.jsx(Aa,{html:a.text}):j=n.jsx(Gs,{content:a.text,copyable:!1})}let k=null;if(a.format==="json"){const N=y!==null&&!y.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;k=n.jsxs("div",{className:"w6w-result-viewer-bar",children:[N,x?null:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{p(Number.POSITIVE_INFINITY),m(F=>F+1)},children:"Expand all"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{p(1),m(F=>F+1)},children:"Collapse all"})]})]})}else h&&!g&&(k=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:[k,n.jsx(ue.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 Ia(e,t){const s=e.filter(o=>o.appId===Be);return s.find(o=>o.nodeId===t)??s.find(o=>!o.nodeId)??s[0]??null}const Fu=/auth|token|secret|passw|cookie|api[-_]?key|signature|session/i,Lu="••••••";function Mu(e){const t={};for(const[s,o]of Object.entries(e))t[s]=Fu.test(s)?Lu:o;return t}const Du=20;function Wu({workflowId:e,stepId:t,stepWith:s,readOnly:o,onUse:r,using:a}){const i=ke(),[l,c]=b.useState(void 0),[u,d]=b.useState(!1),[p,f]=b.useState({phase:"idle"}),[m,w]=b.useState(()=>Date.now()),h=b.useRef(null);b.useEffect(()=>{const j=i.listSubscriptionsForWorkflow;if(!j)return;let k=!1;return j(e).then(N=>!k&&c(Ia(N,t))).catch(N=>!k&&f({phase:"error",message:N.message})),()=>{k=!0}},[i,e,t]);const g=b.useCallback(j=>{var N;const k=h.current;h.current=null,k&&(k.abort.abort(),j&&((N=i.stopWebhookListen)==null||N.call(i,k.subId,k.sessionId).catch(()=>{})))},[i]);b.useEffect(()=>()=>g(!0),[g]),b.useEffect(()=>{if(p.phase!=="waiting")return;const j=setInterval(()=>w(Date.now()),1e3);return()=>clearInterval(j)},[p.phase]);const y=()=>{const j=i.createSubscription;j&&(d(!0),j(Be,"webhook",{workflowId:e,connectionId:null,params:s??{}}).then(k=>c(k)).catch(k=>f({phase:"error",message:k.message})).finally(()=>d(!1)))},x=async()=>{var O;const j=i.startWebhookListen,k=i.pollWebhookListen;if(!l||!j||!k)return;g(!0),f({phase:"starting"});let N;try{N=(await j(l.id)).session}catch(_){f({phase:"error",message:_.message});return}const F=new AbortController,U={subId:l.id,sessionId:N.id,abort:F};for(h.current=U,w(Date.now()),f({phase:"waiting",session:N});;){let _;try{_=await k(l.id,N.id,{waitSeconds:Du,signal:F.signal})}catch(E){if(h.current!==U)return;h.current=null,f({phase:"error",message:E.message});return}if(h.current!==U)return;if(_.status==="captured"&&_.request){h.current=null,f({phase:"captured",session:_,request:_.request});return}if(_.status==="expired"){h.current=null,(O=i.stopWebhookListen)==null||O.call(i,l.id,N.id).catch(()=>{}),f({phase:"expired"});return}}},S=()=>{g(!0),f({phase:"idle"})};if(!i.startWebhookListen||!i.pollWebhookListen)return null;const A=l==null?void 0:l.webhookUrl,R=p.phase==="waiting"?Math.max(0,Math.ceil((Date.parse(p.session.expiresAt)-m)/1e3)):0;return n.jsxs("div",{className:"w6w-stack w6w-listen","data-testid":"webhook-listen",children:[l===void 0?n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}):A?n.jsxs(n.Fragment,{children:[n.jsx(ue.Copyable,{value:A,readOnly:!0,children:n.jsx("input",{type:"text",readOnly:!0,value:A,"aria-label":"Webhook URL"})}),p.phase==="waiting"||p.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:["Waiting for a request to ",n.jsx("code",{children:A}),"…",p.phase==="waiting"&&n.jsxs("span",{className:"w6w-muted",children:[" ",Bu(R)," left"]})]}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:S,children:"Stop"})]}):n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn",disabled:o,onClick:()=>void x(),children:p.phase==="captured"?"Listen again":"Listen for test event"}),p.phase==="idle"&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Send a request to this URL — it works before you publish, and starts no run."})]})]}):n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"This webhook has no URL yet. Create one, then listen for a test request."}),!o&&i.createSubscription&&n.jsx("button",{type:"button",className:"w6w-btn",disabled:u,onClick:y,children:u?"Creating…":"Create webhook URL"})]}),p.phase==="expired"&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No request arrived in time. Listen again, then send the request."}),p.phase==="error"&&n.jsx("div",{className:"w6w-result w6w-error",children:p.message}),p.phase==="captured"&&n.jsx(qu,{request:p.request,receivedAt:p.session.receivedAt,readOnly:o,using:a,onUse:()=>r(p.request),stepId:t})]})}function Bu(e){const t=Math.floor(e/60);return t>0?`${t}:${String(e%60).padStart(2,"0")}`:`${e}s`}function qu({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(Ee,{value:e.query,maxHeight:120})]}),n.jsx("div",{className:"w6w-testout-label",children:"Headers"}),n.jsx(Ee,{value:Mu(e.headers??{}),maxHeight:160}),n.jsx("div",{className:"w6w-testout-label",children:"Body"}),n.jsx(Ee,{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 Ys(e){return Array.isArray(e)?e:[]}function Xs(e){return e==="object"||e==="array"?"json":e==="number"||e==="boolean"||e==="json"?e:"string"}function Zs(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 Qs(e){return e.filter(t=>typeof t.key=="string"&&t.key.trim()!=="").map(t=>({key:t.key,label:t.key,type:Xs(t.type),required:!!t.required}))}function ys(e){const t={};for(const s of e){if(typeof s.key!="string"||s.key.trim()==="")continue;const o=Zs(s.type,s.default);o!==void 0&&(t[s.key]=o)}return t}function $a(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 Uu(e){return Xe(e)||typeof e=="string"&&e.includes("{{")}function eo(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)&&!Uu(a)||(o[r]=a);return o}const gs=new Set;function Pa(e){const t=e.then(()=>{},()=>{});return gs.add(t),t.then(()=>gs.delete(t)),e}async function _a(){await Promise.all([...gs])}function Fa(e,t){const s=ke(),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 p=!1;return a(!1),_a().then(()=>{var f;return((f=s.loadTestInputs)==null?void 0:f.call(s,e))??[]}).then(f=>{p||(l($a(f,t)),a(!0))}).catch(()=>{p||a(!0)}),()=>{p=!0}},[s,o,e,t]);const c=b.useCallback(p=>{l(p),!(!e||!t||typeof s.saveTestInput!="function")&&Pa(s.saveTestInput(e,t,p)).catch(f=>{console.error("test input save failed",f)})},[s,e,t]),u=b.useCallback((p,f)=>c(eo(p,f)),[c]),d=b.useCallback(()=>c({}),[c]);return{loaded:r,supported:o,input:i,save:u,clear:d}}function La({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 Vu=600;function Ma({app:e,action:t,fields:s,persist:o,listen:r,appTrigger:a=!1}){const i=ke(),l=Is(),c=b.useMemo(()=>Ys(s),[s]),u=b.useMemo(()=>Qs(c),[c]),d=u.length>0,[p,f]=b.useState(()=>ys(c)),[m,w]=b.useState(null),h=o==null?void 0:o.workflowId,g=o==null?void 0:o.stepId,y=Fa(h,g),[x,S]=b.useState(!1),[A,R]=b.useState(!1),[j,k]=b.useState(!h||!g);b.useEffect(()=>{if(!h||!g){k(!0);return}if(!y.loaded)return;if(y.input!==void 0){const z=y.input;Object.keys(z).length>0&&(f(M=>({...M,...z})),S(!0),R(!0)),k(!0);return}let G=!1;return i.listStepTests(h,g).then(z=>{if(G)return;const M=z.length?z[z.length-1]:null;M!=null&&M.with&&(f(ee=>({...ee,...M.with})),Object.keys(M.with).length>0&&R(!0)),k(!0)}).catch(()=>{G||k(!0)}),()=>{G=!0}},[i,h,g,y.loaded]);const[N,F]=b.useState(0),U=()=>{clearTimeout(_.current),O.current=null,y.clear(),S(!1),f(ys(c)),F(G=>G+1)},O=b.useRef(null),_=b.useRef(void 0),E=b.useRef(()=>{});E.current=()=>{clearTimeout(_.current);const G=O.current;O.current=null,G&&y.save(G,u)},b.useEffect(()=>()=>E.current(),[]);const I=G=>{f(G),!(!h||!g||!j)&&(O.current=G,clearTimeout(_.current),_.current=setTimeout(()=>E.current(),Vu))},[$,V]=b.useState(!0),H=$&&$t(u,p),L=async G=>{const z=G??p;clearTimeout(_.current),O.current=null,o&&y.save(z,u),w({status:"running"});let M;if(a)M={status:"done",value:z};else try{const ee=await i.invokeAction(e,t,{input:z},{project:l});M={status:"done",value:ee.value,logs:ee.logs}}catch(ee){const Q=ee;M={status:"error",error:Q.message??String(ee),errorCode:Q.code,logs:Q.logs}}if(w(M),o)try{const ee=await i.saveStepTest(o.workflowId,o.stepId,{input:o.input,with:z});await i.recordStepTestRun(o.workflowId,o.stepId,{stepTestId:ee.id,status:M.status==="done"?"succeeded":"failed",input:o.input,output:M.status==="done"?M.value:void 0,error:M.status==="error"?M.error:void 0})}catch(ee){console.error("step test persist failed",ee)}},T=m&&m.status!=="running"?m.logs:void 0,Z=G=>{const z={...G};f(z),L(z)},Y=r&&o&&n.jsx(Wu,{workflowId:o.workflowId,stepId:o.stepId,stepWith:r.stepWith,readOnly:r.readOnly,onUse:Z,using:(m==null?void 0:m.status)==="running"});return n.jsxs("div",{className:"w6w-stack",children:[Y,Y?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"}),te()]}):te(),B()]});function te(){return n.jsxs("div",{className:"w6w-stack",children:[j?n.jsxs(n.Fragment,{children:[x&&n.jsx(La,{onClear:U}),n.jsx(va,{params:u,values:p,onChange:I,onValidityChange:V},N),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(ja,{app:e,trigger:t,onUse:G=>{I(G),F(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||!H||(m==null?void 0:m.status)==="running",onClick:()=>void L(),children:(m==null?void 0:m.status)==="running"?"Running…":"▶ Test run"}),j&&!H&&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 B(){return n.jsxs("div",{className:"w6w-steptest",children:[(m==null?void 0:m.status)==="error"&&n.jsxs("div",{className:"w6w-result w6w-error",children:[m.errorCode&&n.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:n.jsx("code",{children:m.errorCode})}),m.error]}),(m==null?void 0:m.status)==="done"&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Output state (filled values)"}),n.jsx(Ee,{value:m.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(ue.Copyable,{value:T.join(`
|
|
21
|
-
`),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(`
|
|
22
|
-
`)})})]})]})}}const Hu=[["s","Seconds"],["m","Minutes"],["h","Hours"],["d","Days"],["w","Weeks"]],Ju=/^(?=\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 Da({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"),p=typeof o=="string"&&(!Ju.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:f=>{const m=f.target.value;d(m),t({...e,duration:m==="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(Me,{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:f=>{r&&i((r==null?void 0:r[2].toLowerCase())??a),c(f.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:f=>t({...e,duration:`${f.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:f=>{i(f.target.value),t({...e,duration:`${(r==null?void 0:r[1])??""}${f.target.value}`})},children:Hu.map(([f,m])=>n.jsx("option",{value:f,children:m},f))})]})]}):n.jsx(Me,{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}),p&&n.jsx("p",{role:"alert",children:"Enter a duration such as 30s or 1h30m30s, using units w, d, h, m, s in order."})]})]})}function Wa({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 f,m;const p=d.target;(f=o.current)!=null&&f.contains(p)||(m=e.current)!=null&&m.contains(p)||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:xn.createPortal(n.jsx("div",{ref:o,className:"w6w-flyout",style:{top:r.top,left:r.left,width:r.width},children:s}),i)}function Ba(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)&&Ba(e[r],t[r]))}function zu(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&&Ba(r,o)?s:{...s,data:{...s.data,stepProblems:structuredClone(o)}}})}const Ku={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 Gu(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=Ku[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 Yu(e,t){return(t==null?void 0:t.some(s=>s.code==="unknown_connection"&&e.uses.connection===s.connection))??!1}function cr(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 mn(e,t,s){if(s.type==="update"){const r=mn(e,t,{type:"rename",ref:s.ref,name:s.name}),a=s.name.trim(),i=mn(r.nodes,r.connections,{type:"replace",ref:a,connection:s.connection});return s.nodeIds?mn(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?Zt(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)?Zt(a,s.ref):a)}}}}function Lt(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 to(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 qa(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:to(r.uses.app,t);return t={...t,[i]:{app:r.uses.app,connection:r.uses.connection}},s=!0,Zt(r,i)});return s?{...e,nodes:o,connections:t}:e}function Zt(e,t){const{connection:s,...o}=e.uses;return{...e,uses:{...o,connectionRef:t}}}function Xu(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:to(e.uses.app,o);return{step:Zt(e,i),connections:{...o,[i]:{app:e.uses.app,connection:t}}}}function wn(e,t,s,o){return t?s.filter(r=>r.uses.app===e&&Lt(r,o)===t):[]}function Ua(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=Lt(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 ur(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 Zu(e,t,s,o,r){const a=new Set(wn(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]))}const Va=b.createContext(null);function no(){return b.useContext(Va)}function Ha({step:e,conns:t,failed:s=!1,readOnly:o,open:r,onOpenChange:a,anchorRef:i,onChangeConnection:l,onChangeConnectionRef:c,onConnectionCreated:u,createSignal:d}){var U,O,_;const p=no(),f=o||(p==null?void 0:p.readOnly),m=(p==null?void 0:p.connections)??{},w=(p==null?void 0:p.nodes)??[],h=(t??[]).map(E=>({conn:E,users:wn(e.uses.app,E.id,w,m)})).sort((E,I)=>+(I.users.length>0)-+(E.users.length>0)),g=Lt(e,m)??(e.uses.connectionRef===void 0?(U=t==null?void 0:t.find(E=>E.builtIn&&E.appId===e.uses.app))==null?void 0:U.id:void 0),y=wn(e.uses.app,g,w,m).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 k=x||A?((_=(O=i.current)==null?void 0:O.closest("dialog"))==null?void 0:_.parentElement)??document.body:null,N=(E,I)=>{if(!f){if(I&&p&&g){p.setConnections(Zu(e.uses.app,g,E,w,m));const $=w.find(V=>V.id===e.id)??e;$.uses.connectionRef?c($.uses.connectionRef):l(E)}else{const $=wn(e.uses.app,E,w,m).filter(H=>H.id!==e.id&&H.uses.connectionRef).at(-1),V=Object.entries(m).find(([,H])=>H.app===e.uses.app&&H.connection===E);$!=null&&$.uses.connectionRef?c($.uses.connectionRef):V?c(V[0]):l(E)}S(null),a(!1)}},F=E=>{f||(a(!1),E!==g&&(y.length>0&&w.some(I=>I.id===e.id)?S(E):N(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:f||t===null&&!s,onClick:()=>a(!r),children:n.jsx("span",{className:"w6w-conn-label-name",children:t===null&&!s&&!g?"Loading connections…":cr(g,t,s)})}),r&&n.jsx(Wa,{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(m).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(m).filter(([,E])=>E.app===e.uses.app).map(([E,I])=>n.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:f||!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:cr(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:f,"aria-pressed":E.id===g,"data-connection-id":E.id,onClick:()=>F(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:f,onClick:()=>{a(!1),R(!0)},children:"+ New connection"})]})}),A&&k&&xn.createPortal(n.jsx(Vs,{initialAppId:e.uses.app,onClose:()=>R(!1),onCreated:({connectionId:E})=>{R(!1),u(),F(E)}}),k),x&&k&&xn.createPortal(n.jsxs(Ce,{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"}),y.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:f,onClick:()=>N(x,!0),children:["All ",y.length+1," nodes"]}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:f,onClick:()=>N(x,!1),children:"Only this node"})]})]}),k)]})}function Qu(e,t){return`${e.method}-${e.url??e.host}-${t}`}function Ja({calls:e,defaultOpen:t,keyOf:s,title:o}){if(e.length===0)return null;const r=s??Qu;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(Ee,{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(Ee,{value:a.requestBody,maxHeight:240})]}),n.jsx("div",{className:"w6w-muted w6w-small",children:"Response headers"}),n.jsx(Ee,{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(Ee,{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 za({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 Ka({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 Wn({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 Ga(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 f;const d=String(u.value),p=d.replace(/[._]/g,"-");return{value:d,label:((f=t==null?void 0:t.find(m=>m.key===p))==null?void 0:f.title)??u.label,triggerKey:p}}),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 ed=["off","root","key","pick","append"],td={off:"Off",root:"Merge at root",key:"Under a key",pick:"Pick fields",append:"Append"};function nd(e){return ie.effectiveStateConfig(e.uses.app,e.uses.action,e.state)}function sd(e,t){return JSON.stringify(e)===JSON.stringify(t)}function od(e,t){const{state:s,...o}=e,r=ie.effectiveStateConfig(e.uses.app,e.uses.action,void 0);return sd(t,r)?o:{...o,state:t}}function rd(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 Ya(e){return!Et(e.uses.app)}function Ne(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===Le&&e.uses.action==="foreach"}function Xa(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===Le}function xs(e){var s,o;if((e==null?void 0:e.uses.app)===Ge)return!0;if((e==null?void 0:e.uses.app)===_t)return!1;if(!Xa(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 so(e){if(!Xa(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 ad(e){const t=new Set;for(const s of e)for(const o of so(s))t.add(o);return t}function bn(e,t,s,o){return{id:vt(e,t,"each",o),source:e,target:t,sourceHandle:o!==void 0?Ft(o):s?Rn:void 0,animated:!1,data:{when:"each",...o===void 0?{}:{route:o}},...en("each",void 0)}}const on=e=>{var t;return typeof((t=e.data)==null?void 0:t.route)=="string"?e.data.route:void 0};function oo(e,t,s,o){const r=new Set(t.map(h=>h.id)),a=new Set(t.filter(h=>{var g;return Ne((g=h.data)==null?void 0:g.step)}).map(h=>h.id)),i=s.filter(h=>ve(h)==="each"&&!(h.source!==e&&a.has(h.source)&&on(h)===void 0)),l=new Set([e]),c=[],u=[e];for(let h=0;h<u.length;h++)for(const g of i)g.source===u[h]&&(!r.has(g.target)||l.has(g.target)||o!=null&&o.has(g.target)||(l.add(g.target),c.push(g.target),u.push(g.target)));const d=new Map(c.map((h,g)=>[h,g])),p=i.filter(h=>h.source!==e&&d.has(h.source)&&d.has(h.target)),f=new Map(c.map(h=>[h,0]));for(const h of p)f.set(h.target,(f.get(h.target)??0)+1);const m=[],w=new Set;for(;;){const h=c.find(g=>!w.has(g)&&f.get(g)===0);if(h===void 0)break;w.add(h),m.push(h);for(const g of p)g.source===h&&f.set(g.target,(f.get(g.target)??0)-1)}for(const h of c)w.has(h)||m.push(h);return m}function Za(e,t){const s=new Set(e);return t.filter(o=>ve(o)==="each"&&s.has(o.source)&&s.has(o.target))}function id(e,t){const s=Za(e,t),o=new Set;for(const r of s){if(on(r)!==void 0||o.has(r.source))return!1;o.add(r.source)}return!0}function ld(e,t){const s=[];for(const o of Bn(e,t).values())if(!id(o,t))for(const r of Za(o,t)){const a=on(r);s.push({from:r.source,to:r.target,...a===void 0?{}:{route:a}})}return s}function Bn(e,t){var r;const s=new Map,o=new Set;for(const a of e){if(!Ne((r=a.data)==null?void 0:r.step))continue;const i=oo(a.id,e,t,o);for(const l of i)o.add(l);s.set(a.id,i)}return s}function qe(e,t){const s={};for(const[o,r]of Bn(e,t))for(const a of r)s[a]=o;return s}function Qa(e,t,s){const o=qe(t,s),r=[];let a=o[e];for(;a!==void 0&&!r.includes(a);)r.unshift(a),a=o[a];return r}function cd(e,t,s){const o=h=>h.source===e||h.target===e,r=s.filter(h=>!o(h)),i=Ne((h=>{var g,y;return(y=(g=t.find(x=>x.id===h))==null?void 0:g.data)==null?void 0:y.step})(e)),l=qe(t,s),c=new Set(i?Object.keys(l).filter(h=>l[h]===e):[]),u=i?r.filter(h=>!(ve(h)==="each"&&(h.source===e||c.has(h.source))&&c.has(h.target))):r,d=l[e];if(d===void 0)return u;const p=s.filter(h=>h.target===e&&ve(h)==="each"),f=s.filter(h=>h.source===e&&ve(h)==="each"&&!c.has(h.target));if(p.length!==1||f.length!==1)return u;const m=p[0].source,w=f[0].target;return u.some(h=>h.source===m&&h.target===w&&ve(h)==="each")?u:[...u,bn(m,w,m===d,on(p[0]))]}function ro(e){if(!Ne(e)||!e.with||!("body"in e.with))return e;const{body:t,...s}=e.with;return{...e,with:s}}function ei(e,t,s,o,r,a){const i=qe(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=p=>{var f,m;return(m=(f=o.find(w=>w.id===p))==null?void 0:f.data)==null?void 0:m.step},u=Ne(l(e))&&(a===void 0||i[e]===void 0)?e:i[e];if(u===void 0)return null;if(t===u||Qa(u,o,r).includes(t))return"loop_cycle";const d=()=>e!==u||!r.some(p=>p.source===e&&ve(p)==="each"&&on(p)===void 0);return i[t]===u?e===u||ud(t,e,r)?"loop_cycle":d()?null:"body_branch":i[t]!==void 0?"already_in_loop":xs(l(t))?d()?r.some(p=>p.source===t||p.target===t)?"body_exit":null:"body_branch":"control_in_body"}function ud(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||ve(i)!=="each"||o.has(i.target)||(o.add(i.target),r.push(i.target))}return!1}const dd={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 pd(e){return dd[e]}function fd(e,t){const s=qe(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 hd(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(!Ne(r))return o;const a=oo(e,t,s);return a.length===0?o:`${o} Its loop body steps ${a.map(c=>`"${c}"`).join(", ")} stay as standalone steps.`}function ao(e){if(e.edges)return e.edges;const t=ad(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 yn=e=>(e.when??"success")==="success",An=e=>e.route===vr&&yn(e);function io(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 so(u)){const p=s.get(d)??new Set;p.add(u.id),s.set(d,p)}const o=ao(e),r=e.edges??[],a={};for(const u of e.nodes){if(!Ne(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 p=(g,y)=>({invalid:y===void 0?{reason:g}:{reason:g,stepId:y}});if(!Array.isArray(d)||d.some(g=>typeof g!="string"))return p("body_not_literal");const f=d,m=new Set(f),w=new Set;for(const g of f){if(!t.has(g))return p("body_unknown_step",g);if(g===u)return p("body_self",g);if(w.has(g))return p("body_duplicate",g);if(w.add(g),!xs(t.get(g)))return p("body_contains_control",g);const y=s.get(g);if(y&&[...y].some(x=>x!==u))return p("body_claimed_twice",g)}const h=[];for(const g of r){if(An(g)&&g.from===u&&g.to===f[0]||An(g)&&m.has(g.from)&&!m.has(g.to)&&l(g.from,g.to)||!(m.has(g.from)||m.has(g.to)))continue;if(!(m.has(g.from)&&m.has(g.to)&&yn(g)&&g.to!==f[0]))return p("body_step_has_edges",m.has(g.from)?g.from:g.to);h.push(g)}return h.length>0?{body:f,source:"body",edges:h}:{body:f,source:"body"}}function l(u,d){var f,m;const p=(m=(f=t.get(u))==null?void 0:f.with)==null?void 0:m.body;return Ne(t.get(u))&&Array.isArray(p)&&p[0]===d}function c(u){var g;const d=o.filter(y=>y.from===u&&yn(y)&&y.route===void 0);if(d.length===0)return{body:[],source:"body"};const p=y=>({invalid:{reason:"legacy_not_linear",stepId:y}});if(d.length>1)return p(u);const f=[],m=new Set([u]);let w=u,h=d[0].to;for(;h!==void 0;){const y=h,x=t.get(y);if(!x||m.has(y)||!xs(x)||s.has(y))return p(y);const S=o.filter(R=>R.to===y);if(S.length!==1||S[0].from!==w)return p(y);const A=o.filter(R=>R.from===y);if(A.length>1||A.length===1&&!yn(A[0]))return p(y);m.add(y),f.push(y),w=y,h=(g=A[0])==null?void 0:g.to}return{body:f,source:"legacy"}}}function ve(e){var s;const t=(s=e.data)==null?void 0:s.when;return t==="error"?"error":t==="each"?"each":"success"}function ti(e,t){var s;return((s=e.find(o=>o.id===t))==null?void 0:s.id)??null}function ni(e,t,s,o,r,a){var d,p;if(!e||!t||e===t||o.some(f=>{var m;return f.source===e&&f.target===t&&((m=f.data)==null?void 0:m.route)===a}))return!1;const i=(d=s.find(f=>f.id===e))==null?void 0:d.data.step,l=(p=s.find(f=>f.id===t))==null?void 0:p.data.step;if(!i||!l)return!1;const c=zt(i,r),u=zt(l,r);return c.out>=1&&u.in>=1}function lo(e,t,s,o,r,a,i){var R,j,k;const l=r==="success"&&Ne((R=s.find(N=>N.id===e))==null?void 0:R.data.step),c=l&&i===void 0?yt:i;if(!ni(e,t,s,o,a,c)||!e||!t)return null;const u=(j=s.find(N=>N.id===e))==null?void 0:j.data.step,d=(k=s.find(N=>N.id===t))==null?void 0:k.data.step;if(!u||!d)return null;const p=Rs(u);if(l){if(c!==yt)return null}else if(u.uses.app===Ge&&r==="success"){if(!Ts(u).some(N=>N.id===c))return null}else if(p&&r==="success"){if(c!==void 0&&c!==vn)return null}else if(c!==void 0)return null;const f=qe(s,o)[e]!==void 0,m=r==="success"&&f?"each":r;if(m==="each"&&!f&&!Ne(u))return null;const w=ei(e,t,m,s,o,c);if(w)return{next:o,conflict:null,refusal:{refused:"loop",reason:w}};const h=zt(u,a),g=o,y=g.filter(N=>{var F;return N.source===e&&ve(N)===m&&((F=N.data)==null?void 0:F.route)===c}),x=c===void 0||p||l?h.out:1;if(y.length>=x)return{next:o,conflict:null,refusal:{refused:"out_cap",cap:x}};const S=vt(e,t,m,c),A=m==="each"&&f&&!Ne(u)?void 0:Ss(m);return{next:es.addEdge({source:e,target:t,id:S,sourceHandle:c===void 0?A:Ft(c),data:{when:m,...c===void 0?{}:{route:c}},...en(m,void 0)},g),conflict:ti(g,S),refusal:null}}function md(e,t,s,o,r="success",a,i){const l=lo(e,t,s,o,r,a,i);return!l||l.conflict||l.refusal?null:l.next}function wd(e,t,s,o,r="success",a,i){var l;return((l=lo(e,t,s,o,r,a,i))==null?void 0:l.conflict)??null}function bd(e,t,s,o,r="success",a,i){var l;return((l=lo(e,t,s,o,r,a,i))==null?void 0:l.refusal)??null}function co(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(ve(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===Ge||l.uses.app===_t)return null;const c=zt(l,r).out,u=e.filter(S=>S.id!==t);if((ve(i)===s?[]:u.filter(S=>S.source===i.source&&ve(S)===s)).length>=c)return{next:e,conflict:null,refusal:{refused:"out_cap",cap:c}};const p=en(s,void 0),f=Ne(l),m=f&&s==="success"?yt:void 0,{route:w,...h}=i.data??{},g={...i,id:vt(i.source,i.target,s,m),data:f?{...h,when:s,...m?{route:m}:{}}:{...i.data,when:s},className:p.className,label:p.label,sourceHandle:m?Ft(m):Ss(s)},y=ti(u,g.id);return{next:e.map(S=>S.id===t?g:S),conflict:y,refusal:null}}function yd(e,t,s,o,r){const a=co(e,t,s,o,r);return!a||a.conflict||a.refusal?null:a.next}function gd(e,t,s,o,r){var a;return((a=co(e,t,s,o,r))==null?void 0:a.conflict)??null}function xd(e,t,s,o,r){var a;return((a=co(e,t,s,o,r))==null?void 0:a.refusal)??null}function vd(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:vt(r,a,ve(o),typeof((i=o.data)==null?void 0:i.route)=="string"?o.data.route:void 0)}})}function vt(e,t,s,o){const r=s==="error"?`${e}->${t}:error`:`${e}->${t}`;return o===void 0?r:`${r}:route:${encodeURIComponent(o)}`}function jd(e){return e.includes(".")?"A step id can't contain a dot (.).":null}function si(e,t){const s=jd(e);if(s)return s;for(const o of t)if(o===e)return`A step named "${e}" already exists.`;return null}function Nd(e,t,s){const o=(p,f)=>!p||!f?void 0:vt(p,f)===t?"success":vt(p,f,"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(p=>!!p&&p.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 kd=240,Sd=100,Cd=40,Ad=40;function uo(e,t){return{x:Cd+e*kd,y:Ad+t*Sd}}function Ed(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((p,f)=>Math.max(p,(s.get(f)??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 oi(e,t){var c;const s=Ed(e,t),o=new Map(e.map((u,d)=>[u.id,d])),r=new Map;for(const{from:u,to:d}of t){const p=s.get(u),f=s.get(d);if(p===void 0||f===void 0||p>=f)continue;const m=r.get(d);(m===void 0||p<(s.get(m)??0)||p===s.get(m)&&(o.get(u)??0)<(o.get(m)??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,p)=>(s.get(p)??0)-(s.get(d)??0)||(o.get(d)??0)-(o.get(p)??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 p=d.pop();if(p===void 0)continue;i.set(p,uo(s.get(p)??0,l));const f=a.get(p)??[];if(f.length===0)l++;else for(let m=f.length-1;m>=0;m--)d.push(f[m])}}return i}function Td(e){const t=e.position;if(!(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)))return{x:t.x,y:t.y}}function po(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 Rd(e){const t=po(e),s=t.nodes;let o=ao(t);const r=[],a=new Set(s.filter(Ne).map(w=>w.id)),i=new Map,l=new Set,c=new Set;for(const[w,h]of Object.entries(io(t))){if("invalid"in h)continue;let g=w;if(h.edges&&h.body.length>0){r.push(bn(w,h.body[0],!0));for(const y of h.edges)c.add(y),r.push(bn(y.from,y.to,!1,y.route));for(const y of h.body)i.set(y,w);continue}for(const y of h.body){if(h.source==="legacy"){const x=o.find(S=>S.from===g&&S.to===y&&(S.when??"success")==="success");x&&c.add(x)}r.push(bn(g,y,g===w,g!==w&&a.has(g)?yt:void 0)),i.set(y,w),g=y}h.source==="legacy"&&l.add(w)}const u=new Set(s.filter(Ne).map(w=>w.id));for(const w of o)u.has(w.from)&&An(w)&&c.add(w);c.size>0&&(o=o.filter(w=>!c.has(w)));const d=oi(s,[...o,...r.map(w=>({from:w.source,to:w.target}))]),p=s.map(w=>{const h=ot(w.uses.app);return{id:w.id,type:h?"control":"step",position:Td(w)??d.get(w.id)??uo(0,0),data:{step:w,isInternal:h,...i.has(w.id)?{loopOf:i.get(w.id)}:{},...l.has(w.id)?{legacyLoop:!0}:{}}}}),f=new Set(s.filter(Rs).map(w=>w.id)),m=o.map(w=>{const h=w.when==="error"&&w.route===void 0&&f.has(w.from)?{from:w.from,to:w.to,route:vn}:u.has(w.from)&&w.route===void 0&&w.when!=="error"?{...w,route:yt}:w,g=h.when??"success";return{id:vt(h.from,h.to,g,h.route),source:h.from,target:h.to,sourceHandle:h.route===void 0?Ss(g):`route:${h.route}`,animated:!1,data:{when:g,...h.route===void 0?{}:{route:h.route}},...en(g,void 0)}});return{nodes:p,edges:[...m,...r]}}function Od(e,t){const s=e.map(r=>({...r.data.step,id:r.id})),o=oi(s,t.map(r=>({from:r.source,to:r.target})));return e.map(r=>({...r,position:o.get(r.id)??uo(0,0)}))}function Id(e,t,s){var R,j;const o=po(e),r=((R=o.settings)==null?void 0:R.savePosition)!==!1,a=new Map(t.map(k=>[k.id,k])),i=k=>{var F;if(!r)return k;const N=(F=a.get(k.id))==null?void 0:F.position;return!N||!Number.isFinite(N.x)||!Number.isFinite(N.y)?k:{...k,position:{x:Math.round(N.x),y:Math.round(N.y)}}},l=new Map;for(const k of o.nodes)l.set(k.id,k);for(const k of t)(j=k.data)!=null&&j.step&&l.set(k.id,k.data.step);const c=Bn(t,s),u=io(o),d=new Map(o.nodes.map(k=>[k.id,k])),p=new Set;for(const k of s)ve(k)==="success"&&p.add(k.source);const f=k=>{if(!Ne(k))return k;const N=c.get(k.id)??[],F=d.get(k.id),U=u[k.id];let O;N.length>0?O={value:N}:U&&"invalid"in U&&U.invalid.reason!=="legacy_not_linear"?O=F!=null&&F.with&&"body"in F.with?{value:F.with.body}:null:U&&"invalid"in U?O=null:p.has(k.id)||F!=null&&F.with&&"body"in F.with?O={value:[]}:O=null;const _=k.with??{};return O===null?"body"in _?ro(k):k:{...k,with:{..._,body:O.value}}},m=k=>i(f(k)),w=[],h=new Set;for(const k of o.nodes){const N=l.get(k.id);N&&t.some(F=>F.id===k.id)&&(w.push(m(N)),h.add(k.id))}for(const k of t){if(h.has(k.id))continue;const N=l.get(k.id);N&&w.push(m(N))}const g=new Set;for(const k of c.values())for(const N of k)g.add(N);const y=new Set(t.filter(k=>{var N;return Ne((N=k.data)==null?void 0:N.step)}).map(k=>k.id)),x=s.filter(k=>ve(k)!=="each"&&!g.has(k.source)&&!g.has(k.target)).map(k=>{var F;const N=typeof((F=k.data)==null?void 0:F.route)=="string"?k.data.route:y.has(k.source)&&ve(k)==="success"?yt:void 0;return{from:k.source,to:k.target,...ve(k)==="error"?{when:"error"}:{},...N===void 0?{}:{route:N}}}),S=[];for(const[k,N]of c)N.length>0&&S.push({from:k,to:N[0],route:vr});const A=[...x,...S,...ld(t,s)];return qa({...o,nodes:w,edges:A})}function ri(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 $d(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=ri(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 Pd(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"step"}function _d(e,t){const s=new Set(t.map(o=>o.target));return e.find(o=>!s.has(o.id))}function Fd(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 Ld(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 fo(e){return JSON.stringify(ro(e),null,2)}const Md=3,Dd=100;function jt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ai(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(!jt(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(!jt(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 Wd(e,t){var o;if(!Array.isArray(e))return;const s=e.find(r=>jt(r)&&r.key===t);if(!(!jt(s)||!Array.isArray(s.items)))return(o=ai([{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 bt(e){if(!jt(e))return;const t=[],s=(o,r,a)=>{for(const[i,l]of Object.entries(o)){if(t.length>=Dd)return;const c=r?`${r}.${i}`:i;t.push({key:c,path:!0}),jt(l)&&a<Md&&s(l,c,a+1)}};return s(e,"",1),t.length>0?t:void 0}function Ut(e,t){let s=e;for(const o of t.split(".")){if(!jt(s)||!(o in s))return;s=s[o]}return s}function mt(e,t,s){const o=ai(e==null?void 0:e.output),r=bt(t),a=r??bt(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 p=l.get(d.key);return p!=null&&p.label?{...d,label:p.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=bt(e==null?void 0:e.sample);if(i)return{fields:i,from:"sample"}}function ho(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 ii(e,t,s={}){var i,l,c,u,d,p,f;const o=[];let r=!1,a;for(const m of t){if(!e.has(m.id))continue;const w=m.data.step;if(w.uses.app===Es)continue;const h=((i=gt(w.uses.app,w.uses.action))==null?void 0:i.group)==="trigger",g=(l=s.testOutputs)==null?void 0:l[w.id],y=(c=s.persistedOutputs)==null?void 0:c[w.id];if(w.uses.trigger===!0){r=!0;const N=mt((u=s.triggerDef)==null?void 0:u.call(s,w.uses.app,w.uses.action),g,y);if(a??(a=N),N){o.push({id:w.id,label:w.id,outputs:N.fields,outputsFrom:N.from,trigger:!0});continue}}h&&(r=!0);const x=h&&w.uses.app===Pt,S=x?Qs(Ys((d=w.with)==null?void 0:d.fields)).map(N=>({key:N.key,label:N.label})):((p=gt(w.uses.app,w.uses.action))==null?void 0:p.output)??[],A={id:w.id,label:w.id,...w.uses.trigger===!0?{trigger:!0}:{}};if(S.length>0){o.push({...A,outputs:S});continue}if(h){const N=mt(void 0,g,y);N&&!x&&(a??(a=N)),o.push(N?{...A,outputs:N.fields,outputsFrom:N.from}:A);continue}if(ot(w.uses.app)){const N=mt(void 0,g,y);o.push(N?{...A,outputs:N.fields,outputsFrom:N.from}:A);continue}const R=(f=s.actionDef)==null?void 0:f.call(s,w.uses.app,w.uses.action),j=mt(R,g,y),k=w.uses.app.trim()!==""?{hasMeta:!0}:{};j?o.push({...A,outputs:j.fields,outputsFrom:j.from,...k}):o.push(R?{...A,needsTest:!0,...k}:{...A,...k})}return{steps:o,hasTrigger:r,...a?{eventOutputs:a.fields,eventOutputsFrom:a.from}:{}}}function Bd(e,t){const s={};for(const[o,r]of Object.entries(t))s[o]={output:r};return li(e,{steps:s})}function li(e,t){if(ut(e)!==null){const s=Ms(e,_s(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 qd=10;function Ud(e,t){return{input:t,with:{items:e.slice(0,qd),itemCount:e.length}}}function Vd(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 ci(e,t,s,o,r={}){const a=qe(s,o),i=new Set;for(const p of e){if(p===t)continue;const f=a[p];f!==void 0&&f!==t||i.add(p)}const l=ii(i,s,r),c=Bn(s,o),u=[];return{steps:l.steps.map(p=>{var x,S,A;const f=c.get(p.id);if(!f||f.length===0)return p;const m=f[f.length-1],w=(x=s.find(R=>R.id===m))==null?void 0:x.data.step,h=r.testOutputs??{},g=w?mt((S=r.actionDef)==null?void 0:S.call(r,w.uses.app,w.uses.action),h[m],(A=r.persistedOutputs)==null?void 0:A[m]):void 0;u.includes(m)||u.push(m);const y=((g==null?void 0:g.fields)??[]).map(R=>({key:`items.0.${R.key}`,path:!0,...R.declaredOnly?{declaredOnly:!0}:{}}));return{id:p.id,label:p.label,outputs:[{key:"items",path:!0},...y],...g?{outputsFrom:g.from}:{}}}),hasTrigger:l.hasTrigger,extraSampleIds:u,...l.eventOutputs?{eventOutputs:l.eventOutputs,eventOutputsFrom:l.eventOutputsFrom}:{}}}function Hd(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 Jd(e,t,s){var p,f;const o=ut(e),r=o?Hd(o):void 0,a=r?(p=t.find(m=>m.id===r.id))==null?void 0:p.data.step:void 0;if(!r||!a)return;const i=(f=s.actionDef)==null?void 0:f.call(s,a.uses.app,a.uses.action),l=Ut(i==null?void 0:i.sample,r.path),c=Array.isArray(l)&&l.length>0?l[0]:void 0,d=Wd(i==null?void 0:i.output,r.path)??bt(c);if(!(c===void 0&&!d))return{...c!==void 0?{itemSample:c}:{},...d?{itemOutputs:d}:{}}}function ui(e,t,s={},o=[]){const r=dr(e,t,s),a=Qa(e,t,o);return a.length===0?r:{...r,outer:a.map(i=>({...dr(i,t,s),name:i}))}}function dr(e,t,s={}){var u,d,p;const o={foreachId:e},r=(d=(u=t.find(f=>f.id===e))==null?void 0:u.data.step.with)==null?void 0:d.items,a={...s.persistedOutputs??{},...s.testOutputs??{}},i=Bd(r,a),l=i&&i.length>0?i:(p=s.loopSamples)==null?void 0:p[e];if(l&&l.length>0){o.itemSample=l[0];const f=bt(l[0]);return f&&(o.itemOutputs=f),o}const c=Jd(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 di(e,t,s,o){return!e&&!!t&&!o.some(r=>r.target===t)&&qe(s,o)[t]===void 0}function zd(e,t,s,o,r){let a=e;if(!a&&r&&!di(e,r,t,s)&&(a=r),!a)return ii(new Set(t.map(c=>c.id)),t,o);const i=qe(t,s)[a],l=ci(ho(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:ui(i,t,o,s)}:{},...l.extraSampleIds.length>0?{extraSampleIds:l.extraSampleIds}:{}}}function Kd(e,t,s,o){if(!e||e.handleType==="target")return[];const r=ho(e.nodeId,s);r.add(e.nodeId);const a=pi(e,t,s);return ci(r,a,t,s,o).steps}function pi(e,t,s){const o=t.find(r=>r.id===e.nodeId);return e.lane==="each"&&Ne(o==null?void 0:o.data.step)?e.nodeId:qe(t,s)[e.nodeId]}function Gd(e,t,s,o){if(!e||e.handleType==="target")return;const r=pi(e,t,s);return r?ui(r,t,o,s):void 0}async function Yd(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 mo(e,t,s){const o=Xd(e,t);return!s||Object.keys(s).length===0?o:{...o??{},state:s}}function Xd(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 fi(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 Zd(e){return!e||!("itemSample"in e)?"":JSON.stringify(e.itemSample,null,2)??""}function Qd(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 ep(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 tp(e,t,s,o,r){return hi(e,t,s,o,r).values}function np(e,t,s,o,r){return hi(e,t,s,o,r).sources}function sp(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 p=(a=(r=t.triggerDef)==null?void 0:r.call(t,u.app,u.action))==null?void 0:a.sample;o===void 0&&p!==void 0&&(o=p);continue}if(ot(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 hi(e,t,s,o,r={}){var l,c;const a={},i={};for(const u of e){Object.assign(a,ep(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[p,f]of d){if(f===void 0)continue;const m=(w,h)=>{for(const g of["nodes","steps"])a[`${g}.${w}`]=h,i[`${g}.${w}`]=p};if(m(`${u.id}.output`,f),typeof f=="object"&&f!==null&&!Array.isArray(f))for(const[w,h]of Object.entries(f))m(`${u.id}.output.${w}`,h);for(const w of u.outputs??[]){if(!w.path||!w.key.includes("."))continue;const h=Ut(f,w.key);h!==void 0&&m(`${u.id}.output.${w.key}`,h)}}}if(r.event!==void 0){const u=(d,p)=>{a[d]=p,i[d]="sample"};if(u("trigger.event",r.event),typeof r.event=="object"&&r.event!==null&&!Array.isArray(r.event))for(const[d,p]of Object.entries(r.event))u(`trigger.event.${d}`,p);for(const d of bt(r.event)??[]){const p=Ut(r.event,d.key);p!==void 0&&u(`trigger.event.${d.key}`,p)}}if(o&&"itemSample"in o){a["foreach.item"]=o.itemSample;for(const u of o.itemOutputs??[]){const d=Ut(o.itemSample,u.key);d!==void 0&&(a[`foreach.item.${u.key}`]=d)}a["foreach.index"]=0}return{values:a,sources:i}}function op(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 rp(e){const t=[];for(const s of e){const o=s.data.step,r=Object.entries(o.with??{}).filter(([,i])=>i!==void 0&&!op(i)).map(([i])=>i);(o.uses.app===Be||o.uses.trigger===!0)&&!r.includes("url")&&r.unshift("url"),r.length>0&&t.push({id:o.id,keys:r})}return t}function vs(e){if(!(Xe(e)||lt(e))){if(Array.isArray(e))return e.map(vs).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=vs(a);i!==void 0&&(o[r]=i)}return o}return e}}function ap(e,t){const s={};for(const o of e){const r=o.data.step,a={...vs(r.with??{})??{}},i=mi(r,t);i!=null&&i.webhookUrl&&(a.url=i.webhookUrl),Object.keys(a).length>0&&(s[r.id]=a)}return s}function mi(e,t){if(!(e.uses.app!==Be&&e.uses.trigger!==!0))return t.find(s=>s.nodeId===e.id)??(e.uses.app===Be?t.find(s=>s.appId===Be):void 0)}function ip(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:Lt(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=mi(l,t);d&&(c.subscriptionId=d.id),d!=null&&d.webhookUrl&&(c.url=d.webhookUrl),r[l.id]=c}return r}function lp(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 cp(e,t){const s={success:0,error:0};for(const r of t){if(r.source!==e)continue;const a=ve(r);a!=="each"&&s[a]++}const o=Math.max(s.success,s.error);return{enabled:o>=2,count:o}}function up(e,t){const{fanOut:s,...o}=e;return t==="parallel"?{...o,fanOut:"parallel"}:o}function dp(e,t){return`Runs these ${e} nodes in ${t==="parallel"?"parallel":"sequence"}`}function wi({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(up(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 pr({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 fr(){return n.jsx("span",{className:"w6w-state-map-arrow","aria-hidden":"true",children:"→"})}function hr({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(Ye,{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 bi({step:e,inLoop:t,outputFields:s,readOnly:o,onChange:r}){const a=nd(e),i=ie.validateStateConfig(a),l=p=>r(od(e,p)),c=a.mode==="pick"&&Array.isArray(a.map)?a.map:[],u=(p,f)=>l({mode:"pick",map:c.map((m,w)=>w===p?{...m,...f}:m)}),d=p=>{if(a.mode!=="append")return;const f=p.path??a.path,m="from"in p?p.from:a.from;l({mode:"append",path:f,...m?{from:m}:{}})};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:p=>l(rd(e,p.target.value)),children:ed.map(p=>n.jsx("option",{value:p,children:td[p]},p))})]}),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:p=>l({mode:"key",key:p.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(pr,{to:"To state key"}),c.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No fields yet — add one below."}),c.map((p,f)=>n.jsxs("div",{className:"w6w-datavar-row w6w-state-map-row",children:[n.jsx(hr,{label:"From output field",fields:s,value:p.from,readOnly:o,onChange:m=>u(f,{from:m})}),n.jsx(fr,{}),n.jsx("input",{type:"text","aria-label":"To state path",placeholder:"e.g. order",value:p.to,disabled:o,onChange:m=>u(f,{to:m.target.value})}),!o&&n.jsx(Ks,{label:"Remove field",onClick:()=>l({mode:"pick",map:c.filter((m,w)=>w!==f)})})]},f)),!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(pr,{to:"Append to state list"}),n.jsxs("div",{className:"w6w-datavar-row w6w-state-map-row",children:[n.jsx(hr,{label:"Output field to append",fields:s,value:a.from??"",readOnly:o,onChange:p=>d({from:p})}),n.jsx(fr,{}),n.jsx("input",{type:"text","aria-label":"Append to state path",placeholder:"e.g. orders",value:a.path,disabled:o,onChange:p=>d({path:p.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(p=>n.jsx("div",{children:p.message},`${p.code}:${p.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 wo(e,t,s){const o=ke(),[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 Yd(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 bo(e){return(e.nodes??e.steps??[]).filter(t=>t.uses.app===Pt&&t.uses.action==="manual")}function pp(e,t){var a;const s=bo(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:Xs(i.type),default:Zs(i.type,i.default),required:!!i.required}]):[]}const fp=["function","workflow"],hp={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"/>'},Zn={props:{label:"Form",icon:"form"},code:{label:"JSON",icon:"code"},"params-code":{label:"Params JSON",icon:"braces"},config:{label:"Node settings",icon:"settings-2"}},mp=["props","code","params-code","config"];function qn({view:e,onChange:t,disabled:s,views:o=mp,customized:r=!1}){const a=i=>n.jsx("button",{type:"button",title:Zn[i].label,"aria-label":Zn[i].label,"aria-pressed":e===i,disabled:s,className:`w6w-icon-btn${e===i&&!s?" active":""}`,onClick:()=>t(i),children:n.jsx(ue.Icon,{name:Zn[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 wp({onClose:e,onDone:t,onAdd:s,onDraftChange:o,theme:r,appsOnly:a,callables:i=fp,initialTab:l,title:c,workflowId:u,stepId:d,upstreamSteps:p=[],loop:f,initialApp:m,initialAction:w,initialConnection:h,initialWith:g,appsFilter:y,appsIds:x,connectionOnly:S,setupOnly:A,addLabel:R,onConnected:j,excludeCallableIds:k,onOpenStep:N,stepIds:F=[]}){const[U,O]=b.useState(null),[_,E]=b.useState(null),I=b.useRef(null),$=ae=>{const ce=s(ae);return typeof ce=="string"&&(I.current=ae,O(ce),E(null)),ce},V=o?(ae,ce)=>{I.current=ce,o(ae,ce)}:void 0,H=()=>{U&&_&&_!==U&&V&&I.current&&V(U,{...I.current,id:_}),(t??e)()},L=ae=>U&&o?n.jsxs("span",{className:"w6w-stepbuilder-title",children:[ae,n.jsx(ga,{value:_??U,onCommit:ce=>{const ye=si(ce,F.filter(Oe=>Oe!==U));return ye||E(ce),ye}})]}):ae,[T,Z]=b.useState(l??"connected"),[Y,te]=b.useState(""),[B,G]=b.useState(!1),z=Y.trim()!==""&&!B,M=ae=>{Z(ae),G(!0)},[ee,Q]=b.useState(m??null),[C,q]=b.useState(null),[K,le]=b.useState(null),[X,xe]=b.useState(null),he=ae=>{if(!A)return xe(ae);s({uses:{app:tn,action:"call"},with:{targetKind:ae.family,targetId:ae.id}})},we=!!x&&x.length>0,ge=xi(i,y,k,x),J=ge.state!=="empty";if(b.useEffect(()=>{!J&&T==="connected"&&Z("apps")},[J,T]),X)return n.jsx(Ce,{title:L(X.label),ariaLabel:X.label,subtitle:n.jsx("code",{children:X.id}),onClose:e,size:"xl",headerRight:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>xe(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(Np,{family:X.family,targetId:X.id,targetLabel:X.label,onAdd:$,onClose:e,onDone:H,onDraftChange:V})})});if(C)return n.jsx(Ce,{title:L(C.groupActions?C.displayName:C.label),ariaLabel:C.groupActions?C.displayName:C.label,titleIcon:n.jsx(Wn,{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:()=>q(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(jp,{node:C,onAdd:$,onClose:e,onDone:H,onDraftChange:V,onOpenStep:N,workflowId:u,upstreamSteps:p,loop:f})})});const re=K??ee;if(re){const ae=K?"trigger":"action",ce=()=>{Q(null),le(null)};return n.jsx(Ce,{title:L(re.displayName),ariaLabel:re.displayName,subtitle:n.jsxs(n.Fragment,{children:[n.jsx("code",{children:re.id}),re.version&&` · v${re.version}`]}),onClose:e,size:"xl",titleIcon:n.jsx(Nt,{src:re.iconSvg,srcDark:re.iconSvgDark,brandColor:re.brandColor,name:re.displayName,theme:r,size:22}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:S&&ae==="action"?n.jsx($p,{appId:re.id,app:re,onClose:e,onChangeApp:ce,theme:r,initialConnection:h,onConnected:(ye,Oe)=>j==null?void 0:j(ye,Oe)}):n.jsx(Ip,{kind:ae,onOpenStep:N,appId:re.id,app:re,onAdd:$,onClose:e,onDone:H,onDraftChange:V,onChangeApp:ce,theme:r,workflowId:u,stepId:d,upstreamSteps:p,loop:f,...ae==="action"?{initialAction:w,initialConnection:h,initialWith:g}:{},setupOnly:A&&ae==="action",addLabel:R})})})}return n.jsx(Ce,{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:Y,onChange:ae=>{te(ae.target.value),G(!1)}}),n.jsxs("div",{className:"w6w-stepbuilder",children:[n.jsxs("nav",{className:"w6w-stepbuilder-sidebar",children:[J&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="connected"?" active":""}`,onClick:()=>M("connected"),children:"Ready to use"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="apps"?" active":""}`,onClick:()=>M("apps"),children:"Apps"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="ai"?" active":""}`,onClick:()=>M("ai"),children:"AI"}),i.includes("workflow")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="workflows"?" active":""}`,onClick:()=>M("workflows"),children:"Workflows"}),i.includes("function")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="functions"?" active":""}`,onClick:()=>M("functions"),children:"Functions"}),!a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="triggers"?" active":""}`,onClick:()=>M("triggers"),children:"Triggers"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="controls"?" active":""}`,onClick:()=>M("controls"),children:"Controls"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="utilities"?" active":""}`,onClick:()=>M("utilities"),children:"Utilities"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${!z&&T==="data"?" active":""}`,onClick:()=>M("data"),children:"Data"})]})]}),n.jsx("div",{className:"w6w-stepbuilder-content",children:z?n.jsx(bp,{query:Y,builtIns:!a,callables:i,excludeCallableIds:k,appsFilter:y,appsIds:x,theme:r,onSelectNode:q,onSelectApp:Q,onSelectCallable:he}):T==="connected"?n.jsx(Rp,{data:ge,query:Y,appsFilter:y,onSelectApp:Q,onSelectCallable:he,theme:r}):T==="functions"?n.jsx(En,{family:"function",query:Y,excludeIds:k,onSelect:ae=>he({family:"function",...ae})}):T==="workflows"?n.jsx(En,{family:"workflow",query:Y,excludeIds:k,onSelect:ae=>he({family:"workflow",...ae})}):T==="apps"?n.jsx(rt,{search:!1,searchValue:Y,onSelectApp:Q,theme:r,filter:y,ids:x}):T==="ai"?n.jsx(rt,{search:!1,searchValue:Y,onSelectApp:Q,theme:r,category:we?void 0:"ai",ids:x,filter:ae=>{var ce;return((y==null?void 0:y(ae))??!0)&&(we||(((ce=ae.categories)==null?void 0:ce.includes("ai"))??!1))},emptyMessage:"No AI apps registered yet."}):T==="triggers"?n.jsx(yp,{query:Y,onSelect:q,onSelectApp:le,theme:r,appsFilter:y,appsIds:x}):T==="controls"?n.jsx(gp,{query:Y,onSelect:q}):T==="data"?n.jsx(vp,{query:Y,onSelect:q}):n.jsx(xp,{query:Y,onSelect:q})})]})]})})}function Vt(e,...t){const s=t.filter(Boolean).join(" ").toLowerCase();return e.trim().toLowerCase().split(/\s+/).every(o=>s.includes(o))}function yo(e,t){return Vt(t,e.label,e.displayName,e.app,e.action)}function bp({query:e,builtIns:t,callables:s,excludeCallableIds:o,appsFilter:r,appsIds:a,theme:i,onSelectNode:l,onSelectApp:c,onSelectCallable:u}){const d=new Set,p=t?it.filter(f=>f.hidden||!yo(f,e)?!1:f.groupActions?d.has(f.app)?!1:(d.add(f.app),!0):!0):[];return n.jsxs("div",{className:"w6w-stepbuilder-results","data-testid":"stepbuilder-search-all",children:[p.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:p.map(f=>n.jsx(xo,{node:f,onSelect:l},`${f.app}:${f.action}`))})]}):null,n.jsxs("section",{className:"w6w-stepbuilder-results-section",children:[n.jsx("h4",{children:"Apps"}),n.jsx(rt,{search:!1,searchValue:e,onSelectApp:c,theme:i,filter:r,ids:a})]}),s.includes("workflow")?n.jsx(En,{section:!0,family:"workflow",query:e,excludeIds:o,onSelect:f=>u({family:"workflow",...f})}):null,s.includes("function")?n.jsx(En,{section:!0,family:"function",query:e,excludeIds:o,onSelect:f=>u({family:"function",...f})}):null]})}function go({nodes:e,onSelect:t,query:s}){const o=new Set,r=e.filter(a=>yo(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(xo,{node:a,onSelect:t},`${a.app}:${a.action}`))}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No nodes match “",s,"”."]})}function xo({node:e,onSelect:t}){return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item",onClick:()=>t(e),children:[n.jsx(Wn,{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 yp({query:e,onSelect:t,onSelectApp:s,theme:o,appsFilter:r,appsIds:a}){var w;const i=ke(),l=it.filter(h=>h.group==="trigger"&&yo(h,e)),[c,u]=b.useState(!1),d=xi([],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(rt,{onSelectApp:s,theme:o,filter:r,ids:a?[...a]:void 0,hasTriggers:!0,search:!1,searchValue:e,emptyMessage:"No apps declare triggers yet."})]});const f=d.apps.filter(h=>(h.triggerCount??0)>0&&Vt(e,h.displayName,h.id)).sort(Ht(h=>h.displayName)).map(h=>n.jsx(vi,{app:h,theme:o,onSelect:s},h.id));d.moreApps&&f.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 m;return d.state==="error"?m=n.jsx("div",{className:"w6w-result w6w-error",children:d.error}):d.state==="loading"?m=n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}):e.trim()&&((w=d.appIds)!=null&&w.length)&&typeof i.listAppsPage=="function"?m=n.jsx(rt,{search:!1,searchValue:e,ids:d.appIds,hasTriggers:!0,filter:r,onSelectApp:s,theme:o}):f.length===0?m=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"})]}):m=n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:f}),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"}),m]}),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(xo,{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 gp({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(go,{nodes:s,onSelect:e,query:t})]})}function xp({onSelect:e,query:t}){const s=it.filter(o=>o.group!=="control"&&o.group!=="trigger"&&o.app!==Jt&&o.app!==As&&o.app!==ze&&!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(go,{nodes:s,onSelect:e,query:t})]})}function vp({onSelect:e,query:t}){const s=it.filter(o=>(o.app===Jt||o.app===ze||o.app===As)&&!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(go,{nodes:s,onSelect:e,query:t})]})}function jp({node:e,onAdd:t,onClose:s,onDone:o,onDraftChange:r,onOpenStep:a,workflowId:i,upstreamSteps:l=[],loop:c}){var H,L;const[u,d]=b.useState(e),p=e.groupActions?it.filter(T=>T.app===e.app&&!T.hidden):[],[f,m]=b.useState(()=>Nn(u.app,u.action)),w=!Et(u.app),h=wo(i??"",l,w&&!!i),g=(H=Ze().stateShape)==null?void 0:H.written,y=mo(h,fi(c),g),[x,S]=b.useState("configure"),[A,R]=b.useState("props"),[j,k]=b.useState("{}"),[N,F]=b.useState({}),U=$t(u.params,f),[O,_]=b.useState(null),E=()=>({uses:{app:u.app,action:u.action},with:f,...N});b.useEffect(()=>{if(!r)return;const T=t(E());T&&_(T),T&&u.app===Be&&(a==null||a(T))},[]),b.useEffect(()=>{!r||O===null||r(O,E())},[O,f,N,u]);const I=T=>{T==="code"&&k(fo(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"}),w&&n.jsx("button",{type:"button",disabled:!U,title:U?void 0:"Fill the required fields first",className:`w6w-subtab${x==="test"?" active":""}`,onClick:()=>U&&S("test"),children:"Test"})]}),n.jsx(qn,{view:A,customized:Dn(f),onChange:I,disabled:x!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[x==="configure"&&A==="props"&&p.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=p.find(te=>te.action===T.target.value);if(!Z)return;const Y=Nn(Z.app,Z.action);m(Object.fromEntries(Z.params.flatMap(te=>te.key in f?[[te.key,f[te.key]]]:te.key in Y?[[te.key,Y[te.key]]]:[]))),d(Z)},children:p.map(T=>n.jsx("option",{value:T.action,children:T.label},T.action))})]}),x==="configure"&&(A==="props"?u.app===_t?n.jsx("p",{className:"w6w-muted w6w-small",children:Nr}):u.action==="wait"&&Et(u.app)?n.jsx(Da,{values:f,onChange:m}):u.action==="if"&&Et(u.app)?n.jsx(Mn,{values:f,onChange:m}):u.app===Es?n.jsx(xa,{values:f,onChange:m}):u.app===Ge?n.jsx(ya,{values:f,onChange:m}):n.jsx(Me,{params:u.params,values:f,onChange:m}):A==="code"?n.jsx(Ke,{value:j,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):A==="params-code"?n.jsx(zs,{values:f,onChange:m}):n.jsx(gi,{step:{id:O??"",...E()},config:N,onChange:F,inLoop:c!==void 0,outputFields:(L=u.output)==null?void 0:L.map(T=>T.key),failureHandling:!jn(u.app),retryControls:!Et(u.app)&&u.app!==tn})),x==="test"&&w&&(jn(u.app)?n.jsx(Ma,{app:u.app,action:u.action,fields:f.fields,persist:V},(V==null?void 0:V.stepId)??""):n.jsx(vo,{app:u.app,action:u.action,values:f,canRun:U,state:y,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"&&w?n.jsx("button",{type:"button",className:"w6w-btn",disabled:!U,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 En({family:e,query:t,excludeIds:s,onSelect:o,section:r=!1}){const a=ke(),[i,l]=b.useState(null),[c,u]=b.useState(null),d=e==="function"?"Functions":"Workflows";b.useEffect(()=>{let g=!1;return(e==="function"?a.listFunctions():a.listWorkflows()).then(x=>!g&&l(x)).catch(x=>!g&&u(x.message)),()=>{g=!0}},[a,e]);const p=g=>n.jsx("div",{className:"w6w-apppicker-host",children:g});if(r&&(c||i===null||i.length===0))return null;if(c)return p(n.jsx("div",{className:"w6w-result w6w-error",children:c}));if(i===null)return p(n.jsxs("p",{className:"w6w-muted w6w-small",children:["Loading ",d.toLowerCase(),"…"]}));if(i.length===0)return p(n.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",d.toLowerCase()," registered yet."]}));const f=Tt,m=t.trim().toLowerCase(),w=js(i,s).sort(Ht(f)),h=m?w.filter(g=>f(g).toLowerCase().includes(m)||g.id.toLowerCase().includes(m)):w;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(g=>n.jsx(Tn,{family:e,item:g,onSelect:o},g.id))})]}):p(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(g=>n.jsx(Tn,{family:e,item:g,onSelect:o},g.id))})}))}function Np({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),[p,f]=b.useState("configure"),[m,w]=b.useState(null),h=()=>({uses:{app:tn,action:"call"},with:l});b.useEffect(()=>{if(!i)return;const y=o(h());y&&w(y)},[]),b.useEffect(()=>{!i||m===null||i(m,h())},[m,l]);const g=()=>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${p==="configure"?" active":""}`,onClick:()=>f("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!u,title:u?void 0:"Fill the required fields first",className:`w6w-subtab${p==="test"?" active":""}`,onClick:()=>u&&f("test"),children:"Test"})]})}),n.jsx("div",{className:"w6w-stepconfig-body",children:p==="configure"?n.jsx(Ni,{fixedTarget:!0,values:l,onChange:c,onValidityChange:d,targetLabel:s}):n.jsx(kp,{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"}),p==="configure"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:!u,onClick:()=>f("test"),children:"Next →"}):n.jsx("button",{type:"button",className:"w6w-btn",onClick:m!==null?a??r:g,children:m!==null?"Done":"Add node"})]})]})}function kp({family:e,targetId:t,inputs:s,entry:o,canRun:r}){const a=ke(),[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(ue.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(Ee,{value:i.output,maxHeight:220})]})]})}function Sp(e){const t={};for(const s of e)at(s.default)&&(t[s.key]=s.default);return t}function $t(e,t){const s=wa(t);if(s===null)return!1;if(s===void 0)return!0;const o=Ot(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 f=d.children??[],m=Ot(f),w=g=>y=>{const x=m.find(S=>S.key===y);return x?g[y]!==void 0?g[y]:x.default:c(y)};if(d.repeat){const g=Array.isArray(l[d.key])?l[d.key]:[];return g.length===0?!d.required:g.every(y=>{const x=y??{};return a(f,x,w(x))})}const h=l[d.key]??{};return a(f,h,w(h))}if(!d.required||!sn(u,c))return!0;const p=l[d.key]??d.default;return p==null?!1:typeof p=="string"?p.trim()!=="":!0});return a(e,s,r)}function yi(e){const t=e==null?void 0:e.testRequired;return typeof t=="boolean"?t:!0}function Cp(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 Ap(e){const t=e==null?void 0:e.apiCalls;return Array.isArray(t)?t:[]}function Ep({log:e,onClose:t}){return n.jsx(Ce,{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(Ee,{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(Ee,{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(Ja,{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 gi({step:e,config:t,onChange:s,inLoop:o,outputFields:r,failureHandling:a,retryControls:i}){const l=c=>{const{state:u,fanOut:d,...p}=t;s({...p,...c.state!==void 0?{state:c.state}:{},...c.fanOut!==void 0?{fanOut:c.fanOut}:{}})};return n.jsxs("div",{className:"w6w-stack",children:[n.jsx(ma,{config:t,onChange:c=>s({...t,...c}),failureHandling:a,retryControls:i}),n.jsx(wi,{step:e,count:0,onChange:l}),Ya(e)&&n.jsx(bi,{step:e,inLoop:o,outputFields:r,onChange:l})]})}const vo=b.forwardRef(function({app:t,action:s,connectionId:o,values:r,canRun:a,hideRunButton:i,persist:l,state:c,onBusyChange:u,onResult:d},p){const f=ke(),m=Is(),w=wl(),[h,g]=b.useState(null),[y,x]=b.useState(null),[S,A]=b.useState(!1),R=b.useRef(!1),[j,k]=b.useState(null),N=l==null?void 0:l.workflowId,F=l==null?void 0:l.stepId,U=Ze().nodeMeta,O=F?U==null?void 0:U[F]:void 0;b.useEffect(()=>{if(!N||!F)return;let I=!1;return f.listStepTests(N,F).then($=>{let V;for(const H of $)!H.lastRunAt||!H.lastRunStatus||(!V||Date.parse(H.lastRunAt)>Date.parse(V.lastRunAt))&&(V=H);!V||!V.lastRunAt||I||R.current||(V.lastRunStatus==="succeeded"?g({status:"done",value:V.lastRunOutput,...V.lastRunMeta?{meta:V.lastRunMeta}:{}}):g({status:"error",error:typeof V.lastRunError=="string"?V.lastRunError:V.lastRunError==null?"Test failed":JSON.stringify(V.lastRunError)}),k(V.lastRunAt))}).catch(()=>{}),()=>{I=!0}},[f,N,F]);const _=async()=>{var L;if(!a||(h==null?void 0:h.status)==="running")return;R.current=!0,k(null),g({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}:{},...m?{project:m}:{},...c?{state:c}:{},...w?{workflowId:w}:{}}},H=T=>x({startedAt:$.toLocaleString(),durationMs:Date.now()-$.getTime(),request:V,response:T,apiCalls:Ap(T.body)});try{const T=await f.invokeAction(t,s,r,{...o?{connectionId:o}:{},project:m,...c?{state:c}:{},...w?{workflowId:w}:{}});H({ok:!0,body:T}),I={status:"done",value:T.value,logs:T.logs,...T.meta?{meta:T.meta}:{}}}catch(T){const Z=T;H({ok:!1,...typeof Z.status=="number"?{status:Z.status}:{},body:Cp(T)}),I={status:"error",error:Z.message??String(T),errorCode:Z.code,logs:Z.logs}}if(g(I),d==null||d(I.status==="done"),l){(L=f.saveTestInput)==null||L.call(f,l.workflowId,l.stepId,eo(l.input)).catch(T=>console.error("test input save failed",T));try{const T=await f.saveStepTest(l.workflowId,l.stepId,{input:l.input,with:r});await f.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(p,()=>({run:_}));const E=h&&h.status!=="running"?h.logs:void 0;return n.jsxs("div",{className:"w6w-steptest",children:[(!i||y)&&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:_,children:(h==null?void 0:h.status)==="running"?"Running…":"▶ Test run"}),y&&(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",y.apiCalls.length>0?` (${y.apiCalls.length})`:""]}),!i&&!a&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),S&&y&&n.jsx(Ep,{log:y,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(Ee,{value:h.value,maxHeight:220}),(h.meta||O)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),n.jsx(Ee,{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(Ee,{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(ue.Copyable,{value:E.join(`
|
|
23
|
-
`),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(`
|
|
24
|
-
`)})})]})]})}),mr=12,un=new Set;function xi(e,t,s,o,r){const a=o&&o.length>0?new Set(o):null,i=B=>(a?a.has(B.id):!0)&&((t==null?void 0:t(B))??!0),l=ke(),[c,u]=b.useState(null),[d,p]=b.useState(null),[f,m]=b.useState(null),[w,h]=b.useState(null),[g,y]=b.useState(null),[x,S]=b.useState(()=>new Map),[A,R]=b.useState(()=>new Set),[j,k]=b.useState(un),N=b.useRef(un),F=b.useCallback(B=>{N.current=B,k(B)},[]),U=b.useRef(un),O=e.includes("function"),_=e.includes("workflow"),E=typeof l.listAppsByIds=="function";b.useEffect(()=>{let B=!1;const G=z=>!B&&y(z.message);return l.listConnections().then(z=>{if(B)return;const M=[],ee=new Set,Q=new Map;for(const C of z)ot(C.appId)||(E&&!(r!=null&&r.resolveInline)&&C.app&&!Q.has(C.appId)&&Q.set(C.appId,{...C.app,id:C.appId}),!ee.has(C.appId)&&(ee.add(C.appId),M.push(C.appId)));Q.size>0&&(U.current=new Set(Q.keys()),S(C=>new Map([...C,...Q])),R(C=>new Set([...C,...Q.keys()]))),u(M)}).catch(G),O?l.listFunctions().then(z=>!B&&m(z)).catch(G):m([]),_?l.listWorkflows().then(z=>!B&&h(z)).catch(G):h([]),()=>{B=!0}},[l,E,O,_,r==null?void 0:r.resolveInline]),b.useEffect(()=>{if(E)return;const B=l.listApps;if(typeof B!="function"){p([]);return}let G=!1;return B().then(z=>!G&&p(z)).catch(z=>!G&&y(z.message)),()=>{G=!0}},[l,E]);const I=b.useRef(!0);b.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const $=b.useCallback(B=>{const G=l.listAppsByIds;!G||B.length===0||N.current.size>0||(F(new Set(B)),G(B).then(z=>{I.current&&(F(un),S(M=>{const ee=new Map(M);for(const Q of z)ee.set(Q.id,Q);return ee}),R(M=>new Set([...M,...B])))}).catch(z=>I.current&&y(z.message)))},[l,F]),V=b.useRef(!1);b.useEffect(()=>{if(!E||c===null||V.current)return;const B=Kn(c,U.current,mr);B.length!==0&&(V.current=!0,$(B))},[E,c,$]);const H=()=>{if(!E||c===null||N.current.size>0)return;const B=new Set([...A,...N.current]);$(Kn(c,B,mr))};if(g)return{state:"error",error:g,apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:H};if(f===null||w===null)return{state:"loading",apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:H};const L=js(f,s),T=js(w,s);if(E){if(c===null)return{state:"loading",apps:[],fns:L,wfs:T,moreApps:!1,loadMoreApps:H};if(c.length>0&&A.size===0)return{state:"loading",apps:[],fns:L,wfs:T,moreApps:!1,loadMoreApps:H};const B=pl(c,x).filter(i),G=j.size===0&&Kn(c,new Set([...A,...j]),1).length>0;return{state:B.length===0&&L.length===0&&T.length===0&&!G?"empty":"ready",apps:B,appIds:c.filter(M=>!a||a.has(M)),fns:L,wfs:T,moreApps:G,loadMoreApps:H}}if(d===null)return{state:"loading",apps:[],fns:L,wfs:T,moreApps:!1,loadMoreApps:H};const Z=new Set(c??[]),Y=d.filter(B=>!ot(B.id)&&i(B)&&(Z.has(B.id)||B.zeroCredential===!0));return{state:Y.length===0&&L.length===0&&T.length===0?"empty":"ready",apps:Y,fns:L,wfs:T,moreApps:!1,loadMoreApps:H}}function js(e,t){return t&&t.length>0?e.filter(s=>!t.includes(s.id)):[...e]}function Ht(e){return(t,s)=>e(t).localeCompare(e(s),void 0,{sensitivity:"base"})}function Tt(e){const t=e.displayName;return t!=null&&t.trim()?t:"name"in e?e.name:e.id}function Tn({family:e,item:t,onSelect:s}){const o=Tt(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(Wn,{icon:hp[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 Tp(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 vi({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 Rp({data:e,query:t,appsFilter:s,onSelectApp:o,onSelectCallable:r,theme:a}){var g;const i=ke(),l=y=>n.jsx("div",{className:"w6w-apppicker-host",children:y});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(y=>Vt(t,y.displayName,y.id)).sort(Ht(y=>y.displayName)),u=e.fns.filter(y=>Vt(t,Tt(y),y.id)).sort(Ht(Tt)),d=e.wfs.filter(y=>Vt(t,Tt(y),y.id)).sort(Ht(Tt)),p=Tp,f=c.map(y=>n.jsx(vi,{app:y,theme:a,onSelect:o},y.id));e.moreApps&&f.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 m=t.trim()&&((g=e.appIds)!=null&&g.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(rt,{search:!1,searchValue:t,ids:e.appIds,filter:s,onSelectApp:o,theme:a})]}):p("Connected apps",f),w=[p("Functions",u.map(y=>n.jsx(Tn,{family:"function",item:y,onSelect:x=>r({family:"function",...x})},y.id))),p("Workflows",d.map(y=>n.jsx(Tn,{family:"workflow",item:y,onSelect:x=>r({family:"workflow",...x})},y.id)))].filter(Boolean),h=(m?1:0)+(w.length>0?1:0);return l(h?n.jsxs("div",{className:"w6w-readytouse","data-cols":h,children:[m,w.length>0&&n.jsx("div",{className:"w6w-readytouse-stack",children:w})]}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["Nothing ready to use matches “",t,"”."]}))}function ji(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??[]})))}function Op({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 Ip({kind:e="action",onOpenStep:t,appId:s,app:o,onAdd:r,onClose:a,onDone:i,onDraftChange:l,onChangeApp:c,theme:u,workflowId:d,stepId:p,upstreamSteps:f=[],loop:m,initialAction:w,initialConnection:h,initialWith:g,setupOnly:y=!1,addLabel:x="Add"}){var Ie,nt;const S=ke(),A=e==="trigger",R=A?"a trigger":"an action",[j,k]=b.useState(null),[N,F]=b.useState(null),[U,O]=b.useState(null),[_,E]=b.useState(null),[I,$]=b.useState(h??""),[V,H]=b.useState(),L=no(),T=b.useRef(L);T.current=L;const Z=V?Lt({uses:{app:s,action:"",connectionRef:V}},L==null?void 0:L.connections)??"":I,Y=b.useCallback(ne=>{H(void 0),$(ne)},[]),[te,B]=b.useState(w??""),[G,z]=b.useState(g??{}),M=b.useRef(null),[ee,Q]=b.useState(!1),[C,q]=b.useState(!y&&w&&g?"configure":"setup"),[K,le]=b.useState("props"),[X,xe]=b.useState("{}"),[he,we]=b.useState({});b.useEffect(()=>{let ne=!1;E(null);const Se=A?ji(S,s):S.getAppActions(s);return Promise.all([S.getAppAuth(s),S.listConnectionsForApp(s),Se]).then(([$e,D,v])=>{if(ne)return;const P=ur(s,$e,D);k($e),F(P),O(v);const W=T.current,se=Ua({id:p??"",uses:{app:s,action:""}},P,(W==null?void 0:W.nodes)??[],(W==null?void 0:W.connections)??{},h);se.connectionRef?H(se.connectionRef):Y(se.connection??"")}).catch($e=>!ne&&E($e.message)),()=>{ne=!0}},[S,s,A,Y,h,p]);const ge=async()=>{const ne=await S.listConnectionsForApp(s);F(ur(s,j??[],ne))},J=(j??[]).filter(ne=>ne.available!==!1),re=J.some(ne=>ne.autoSatisfied===!0&&(ne.type==="tenantAuth"||ne.type==="jit")),ae=re&&!J.some(ne=>ne.autoSatisfied===!0&&ne.type==="tenantAuth"),ce=J.length>0&&!re,ye=(N??[]).length>0,Oe=j!==null&&N!==null&&ce&&!ye,[dt,Te]=b.useState(0),de=(U??[]).find(ne=>ne.key===te),De=A?Ga(s,U,te,G):null,pt=[...U??[]].sort((ne,Se)=>(ne.title??ne.key).localeCompare(Se.title??Se.key,void 0,{sensitivity:"base"})),Qe=yi(o),[et,Ue]=b.useState(!1);b.useEffect(()=>{if(!Qe||!d||!p)return;let ne=!1;return S.listStepTests(d,p).then(Se=>{!ne&&Se.some($e=>$e.lastRunStatus==="succeeded")&&Ue(!0)}).catch(()=>{}),()=>{ne=!0}},[S,Qe,d,p]);const kt=wo(d??"",f,!!d),St=(Ie=Ze().stateShape)==null?void 0:Ie.written,Re=mo(kt,fi(m),St),je=!!te&&(!ce||ye&&!!Z)&&(!De||De.selected.length>0),_e=je&&!!de&&$t(de.params??[],G),He=je,We=(N??[]).find(ne=>ne.id===Z);function Fe(){return{uses:{app:s,action:(de==null?void 0:de.key)??te,...V?{connectionRef:V}:Z?{connection:Z}:{},...A?{trigger:!0}:{}},with:G,...he}}function me(){de&&r(Fe())}const[Ae,tt]=b.useState(null);b.useEffect(()=>{if(!l||Ae!==null||!je||De&&C==="setup")return;const ne=r(Fe());ne&&tt(ne),ne&&A&&(t==null||t(ne))},[l,Ae,je,C]),b.useEffect(()=>{!l||Ae===null||l(Ae,Fe())},[Ae,G,he,Z,V]);const Je=ne=>{ne==="code"&&xe(fo(Fe())),le(ne)};return n.jsxs("div",{className:"w6w-stepconfig",children:[!y&&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:()=>q("setup"),children:"Setup"}),n.jsx("button",{type:"button",disabled:!je,title:je?void 0:"Complete Setup first",className:`w6w-subtab${C==="configure"?" active":""}`,onClick:()=>je&&q("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!_e,title:_e?void 0:"Fill the required fields first",className:`w6w-subtab${C==="test"?" active":""}`,onClick:()=>_e&&q("test"),children:"Test"})]}),n.jsx(qn,{view:K,customized:Dn(G),onChange:Je,disabled:C!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[C==="setup"&&n.jsxs("div",{className:"w6w-stack",children:[_&&n.jsx("div",{className:"w6w-result w6w-error",children:_}),j===null&&!_&&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:M,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(Ha,{step:{id:Ae??p??"",uses:{app:s,action:te,...V?{connectionRef:V}:{connection:Z||void 0}}},conns:N,failed:!!_,open:ee,onOpenChange:Q,anchorRef:M,onChangeConnection:Y,onChangeConnectionRef:H,onConnectionCreated:()=>{ge()},createSignal:dt})]}),ae&&(We==null?void 0:We.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(za,{testId:"step-needs-connection",className:"w6w-sb-connect-gate",action:n.jsxs("button",{type:"button",className:"w6w-btn",onClick:()=>Te(ne=>ne+1),children:["Connect ",(o==null?void 0:o.displayName)??s]}),children:["Connect ",(o==null?void 0:o.displayName)??s," to choose ",R,"."]}):U!==null&&(U.length===0?n.jsx("p",{className:"w6w-muted w6w-small",children:A?"This app declares no triggers.":"This app exposes no actions."}):De?n.jsx(Ka,{choices:De,onChange:ne=>{B(De.triggerKey),z(Se=>({...Se,actions:ne}))}}):n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[A?"Trigger":"Action",te?"":" *"]}),n.jsx(Ye,{value:te,placeholder:`— pick ${R} —`,mode:"combobox",listMaxHeight:200,onChange:ne=>{var Se;B(ne),z(Sp(((Se=(U??[]).find($e=>$e.key===ne))==null?void 0:Se.params)??[])),Ue(!1)},options:pt.map(ne=>({value:ne.key,label:`${ne.title??ne.key} (${ne.key})`}))}),(de==null?void 0:de.description)&&n.jsx("span",{className:"w6w-hint",children:de.description})]}))]}),C==="configure"&&(de?K==="props"?n.jsx(Me,{params:de.params??[],values:G,onChange:z,dynamic:{appId:s,actionKey:de.key,connectionId:Z||void 0,appName:o==null?void 0:o.displayName}}):K==="code"?n.jsx(Ke,{value:X,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):K==="params-code"?n.jsx(zs,{values:G,onChange:z}):n.jsx(gi,{step:{id:p??"",...Fe()},config:he,onChange:we,inLoop:m!==void 0,outputFields:(nt=mt(de,void 0))==null?void 0:nt.fields.map(ne=>ne.key),failureHandling:!A}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["Pick ",R," in Setup first."]})),C==="test"&&(de&&A?n.jsx(Op,{title:de.title??de.key,app:(o==null?void 0:o.displayName)??s}):de?n.jsx(vo,{app:s,action:de.key,connectionId:Z||void 0,values:G,canRun:je&&$t(de.params??[],G),state:Re,onResult:Ue}):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:Qe&&!et&&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"}),y?n.jsx("button",{type:"button",className:"w6w-btn","data-testid":"stepbuilder-setup-add",disabled:!je,onClick:me,children:x}):C==="test"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:Ae===null&&!He,onClick:Ae!==null?i??a:me,children:Ae!==null?"Done":"Add node"}):n.jsx("button",{type:"button",className:"w6w-btn",disabled:C==="setup"?!je:!_e,onClick:()=>q(C==="setup"?"configure":"test"),children:"Next →"})]})]})}function $p({appId:e,app:t,onClose:s,onChangeApp:o,theme:r,initialConnection:a,onConnected:i}){const l=ke(),[c,u]=b.useState(null),[d,p]=b.useState(null),[f,m]=b.useState(null),[w,h]=b.useState(a??""),[g,y]=b.useState(!1),[x,S]=b.useState(!1);b.useEffect(()=>{let E=!1;return m(null),Promise.all([l.getAppAuth(e),l.listConnectionsForApp(e)]).then(([I,$])=>{if(E)return;u(I),p($),!(I??[]).some(H=>H.autoSatisfied===!0)&&$.length>0&&h($[0].id)}).catch(I=>!E&&m(I.message)),()=>{E=!0}},[l,e]);const A=async()=>{const E=await l.listConnectionsForApp(e);p(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")),k=j&&!R.some(E=>E.autoSatisfied===!0&&E.type==="tenantAuth"),N=R.length>0&&!j,F=(d??[]).length>0,U=!N||F&&!!w,O=(d??[]).find(E=>E.id===w),_=x||!w;return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsx("div",{className:"w6w-stepconfig-body",children:n.jsxs("div",{className:"w6w-stack",children:[f&&n.jsx("div",{className:"w6w-result w6w-error",children:f}),c===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-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:()=>y(!0),children:"Create connection"})]}),k&&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&&N&&(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:w,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:()=>y(!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)||w,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:()=>y(!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:()=>y(!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:!U||!t,onClick:()=>t&&i(w,t),children:"Next →"})]}),g&&n.jsx(Vs,{theme:r,initialAppId:e,onClose:()=>y(!1),onCreated:async({connectionId:E})=>{y(!1),h(E),S(!1),await A()}})]})}function Ni({values:e,onChange:t,readOnly:s,setupOnly:o,onValidityChange:r,targetLabel:a,fixedTarget:i}){var H,L;const l=ke(),c=e.targetKind==="function"?"function":"workflow",u=typeof e.targetId=="string"?e.targetId:"",d=typeof e.entry=="string"?e.entry:void 0,p=e.inputs&&typeof e.inputs=="object"&&!Array.isArray(e.inputs)?e.inputs:{},f=at(e.inputs)||typeof p.$=="string",[m,w]=b.useState([]),[h,g]=b.useState(),[y,x]=b.useState(),[S,A]=b.useState(),R=`${c}:${u}`;b.useEffect(()=>{if(i)return;let T=!1;return w([]),g(void 0),(c==="workflow"?l.listWorkflows():l.listFunctions()).then(Z=>{T||w(Z)}).catch(Z=>{T||g(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(Y=>({key:R,workflow:Y,fields:[],label:Y.displayName||Y.name||u})):l.getFunction(u).then(Y=>({key:R,fields:Y.inputs,label:Y.displayName||Y.id}))).then(Y=>{T||x(Y)}).catch(Y=>{T||A(String(Y.message??Y))}),()=>{T=!0}):void 0},[l,u,c,R]);const j=(y==null?void 0:y.key)===R?y:void 0,k=j!=null&&j.workflow?bo(j.workflow):[],N=d??((H=k[0])==null?void 0:H.id),F=j!=null&&j.workflow?pp(j.workflow,N):(j==null?void 0:j.fields)??[],O={...Object.fromEntries(F.filter(T=>T.default!==void 0).map(T=>[T.key,T.default])),...p},_=c==="function"||!d||k.some(T=>T.id===d),E=!!j&&_&&(f||$t(F,O));b.useEffect(()=>{r==null||r(E)},[E,r]),b.useEffect(()=>{if(!j||s||o)return;const T=!f&&F.some(Z=>Z.default!==void 0&&!(Z.key in p));(!d&&N||T)&&t({...e,...N?{entry:N}:{},inputs:f?e.inputs:O})});const I=m.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?(L=l.callableHref)==null?void 0:L.call(l,c,u):void 0,V=(T,Z)=>{const{target:Y,entry:te,...B}=e;t({...B,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(Ye,{"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"&&k.length>0&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Trigger"}),n.jsxs("select",{className:"w6w-input","aria-label":"Trigger",value:N,disabled:s,onChange:T=>t({...e,entry:T.target.value,inputs:{}}),children:[d&&!_&&n.jsxs("option",{value:d,children:[d," (unavailable)"]}),k.map(T=>n.jsxs("option",{value:T.id,children:[T.id," (",T.uses.app===Pt?"Manual":T.uses.action,")"]},T.id))]})]}),!_&&n.jsx("div",{className:"w6w-result w6w-error",children:"The selected trigger is unavailable. Choose another trigger."}),c==="workflow"&&k.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"}),F.length>0&&!f?n.jsx(Me,{params:F,values:O,readOnly:s,onChange:T=>t({...e,inputs:T})}):n.jsx(Me,{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(Me,{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 Pp=/^(#{1,6})\s+(.*)$/,_p=new RegExp("\\*\\*(?=\\S)(.+?)(?<=\\S)\\*\\*","g");function Fp(e,t){const s=e.ownerDocument;e.replaceChildren();for(const o of t.split(`
|
|
25
|
-
`)){const r=Pp.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(_p)){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 Lp(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 Mp(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 Dp(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 p=/^h([1-6])$/.exec(d),f=p||["div","p","li","ul","ol","blockquote","pre"].includes(d);f&&(s=null);const m=p?Number(p[1]):l,w=d==="b"||d==="strong"?!0:Lp(u)??c;for(const h of u.childNodes)r(h,m,w);f&&(s=null)};for(const i of e.childNodes)r(i,0,!1);const a=t.map(i=>{const l=Mp(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(`
|
|
26
|
-
`)}function Wp(e){return e.replace(/([^\n])\n(?=[^\n])/g,`$1
|
|
27
|
-
`)}const Bp=-2,qp=-1,wr=1e3,Up=["#facc15","#fb923c","#f87171","#f472b6","#a78bfa","#60a5fa","#2dd4bf","#4ade80","#9ca3af"],Vp=[{level:1,label:"Title"},{level:2,label:"Heading"},{level:3,label:"Subheading"},{level:0,label:"Body"}],Hp=80,Jp=48,br=10,zp=4,Qn=e=>e.stopPropagation();function Kp(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),t.removeAllRanges(),t.addRange(s)}function Gp(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 ki({canvas:e,className:t,viewport:s,readOnly:o,zoom:r=1,onChange:a,onSectionDrop:i,onRequestDelete:l}){const[c,u]=b.useState({}),[d,p]=b.useState(null),[f,m]=b.useState(null),[w,h]=b.useState(null),[g,y]=b.useState(null),x=b.useRef(null),S=b.useRef(null),A=b.useRef(null);if(b.useEffect(()=>{if(!d&&!f)return;const C=d?`[data-note-id="${d}"], [data-note-toolbar="${d}"]`:`[data-section-label="${f}"], [data-section-toolbar="${f}"]`,q=K=>{var xe,he;const le=K.target;if((xe=le==null?void 0:le.closest)!=null&&xe.call(le,C))return;const X=document.activeElement;(he=X==null?void 0:X.closest)!=null&&he.call(X,"[data-section-toolbar]")&&X.blur(),p(null),m(null),y(null)};return window.addEventListener("pointerdown",q,!0),()=>window.removeEventListener("pointerdown",q,!0)},[d,f]),!s)return null;const R=!o&&!!a,j=e.sections??[],k=e.notes??[],N=C=>c[C.id]??{x:C.position.x,y:C.position.y,w:C.size.width,h:C.size.height},F=C=>{const q=N(C);return{left:q.x,top:q.y,width:q.w,height:q.h,"--w6w-canvas-color":C.color}},U=(C,q)=>a==null?void 0:a({...e,notes:k.map(K=>K.id===C?{...K,...q}:K)}),O=(C,q)=>a==null?void 0:a({...e,sections:j.map(K=>K.id===C?{...K,...q}:K)}),_=C=>{const q=S.current,K=k.find(X=>X.id===C);if(!(q!=null&&q.isConnected)||!K)return;const le=Dp(q);le!==K.content&&U(C,{content:le})},E=C=>{m(null),p(C)},I=C=>{p(null),m(C)},$=(C,q)=>{A.current=q??null,E(C),h(C),y(null)},V=C=>q=>{if(!q||q.dataset.ready==="1")return;q.dataset.ready="1",S.current=q,Fp(q,C.content),q.focus();const K=A.current;A.current=null,K?(Kp(q),K(),_(C.id)):Gp(q)},H=(C,q,K)=>{var X;y(null);const le=()=>document.execCommand(q,!1,K);w===C&&((X=S.current)!=null&&X.isConnected)?(le(),_(C)):$(C,le)},L=C=>C.mode==="move"?{...C.base,x:C.base.x+C.dx,y:C.base.y+C.dy}:{...C.base,w:Math.max(Hp,C.base.w+C.dx),h:Math.max(Jp,C.base.h+C.dy)},T=(C,q,K,le)=>{if(!R||C.button!==0)return;C.stopPropagation(),C.preventDefault();const X={kind:K,id:q.id,mode:le,sx:C.clientX,sy:C.clientY,base:N(q),dx:0,dy:0};x.current=X;const xe=we=>{X.dx=(we.clientX-X.sx)/(r||1),X.dy=(we.clientY-X.sy)/(r||1),u(ge=>({...ge,[X.id]:L(X)}))},he=()=>{if(window.removeEventListener("pointermove",xe),window.removeEventListener("pointerup",he),x.current=null,u(J=>{const{[X.id]:re,...ae}=J;return ae}),X.dx===0&&X.dy===0)return;const we=L(X),ge={position:{x:we.x,y:we.y},size:{width:we.w,height:we.h}};X.kind==="section"&&X.mode==="move"&&i?i(X.id,{dx:X.dx,dy:X.dy}):X.kind==="note"?U(X.id,ge):O(X.id,ge)};window.addEventListener("pointermove",xe),window.addEventListener("pointerup",he)},Z=t?` ${t}`:"",Y="nopan nodrag nowheel",te=R?k.find(C=>C.id===d):void 0,B=R?j.find(C=>C.id===f):void 0,G=r||1,z=C=>{const q=N(C);return{left:q.x+q.w/2,top:q.y,transform:`translate(-50%, calc(-100% - ${br/G}px)) scale(${1/G})`,transformOrigin:"50% 100%","--w6w-canvas-color":C.color}},M=(C,q)=>{const K=N(C);return{left:K.x,top:K.y,transform:`translate(0, calc(-100% - ${q/G}px)) scale(${1/G})`,transformOrigin:"0 100%","--w6w-canvas-color":C.color}},ee=(C,q,K,le)=>n.jsxs("div",{className:"w6w-note-menu w6w-note-menu-colors",role:"menu",children:[Up.map(X=>n.jsx("button",{type:"button",role:"menuitemradio","aria-checked":X===C,"aria-label":`Colour ${X}`,title:X,className:`w6w-note-swatch-btn${X===C?" active":""}`,style:{"--w6w-canvas-color":X},"data-testid":`${K}-option`,"data-color":X,onClick:()=>{y(null),X!==C&&le(X)}},X)),n.jsx("label",{className:"w6w-note-swatch-btn w6w-note-swatch-custom",title:"Custom",children:n.jsx("input",{type:"color","aria-label":`Custom ${q} colour`,"data-testid":`${K}-input`,value:C,onChange:X=>le(X.currentTarget.value)})})]}),Q=C=>{C.target.closest("input")||C.preventDefault()};return xn.createPortal(n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`w6w-canvas-layer w6w-canvas-sections${Z}`,style:{zIndex:Bp},"data-testid":"w6w-canvas-sections",children:[j.map(C=>n.jsx("div",{className:`w6w-canvas-section${f===C.id?" selected":""}`,style:F(C),"data-section-id":C.id,"data-testid":"section",children:R&&n.jsx("div",{className:`w6w-note-resize ${Y}`,"data-testid":"section-resize",onPointerDown:q=>T(q,C,"section","resize")})},C.id)),j.map(C=>(B==null?void 0:B.id)===C.id?null:n.jsx("div",{className:`w6w-canvas-section-title${R?` editable ${Y}`:""}`,style:M(C,zp),"data-section-label":C.id,"data-testid":"section-label",title:R?"Click to edit · drag to move":void 0,onPointerDown:R?q=>{I(C.id),T(q,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:qp},"data-testid":"w6w-canvas-notes",children:k.map(C=>{const q=R&&w===C.id;return n.jsxs("div",{className:`w6w-canvas-note${d===C.id?" selected":""}`,style:F(C),"data-note-id":C.id,"data-testid":"note",children:[q?n.jsx("div",{ref:V(C),className:`w6w-canvas-note-body w6w-canvas-note-editor ${Y}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":"true","aria-label":"Note content","data-testid":"note-content",onPointerDown:Qn,onBlur:()=>{_(C.id),S.current=null,h(null)},onKeyDown:K=>{K.key==="Escape"&&K.currentTarget.blur()},onPaste:K=>{K.preventDefault(),document.execCommand("insertText",!1,K.clipboardData.getData("text/plain"))}},"editor"):n.jsx("div",{className:`w6w-canvas-note-body ${Y}`,"data-testid":"note-view",style:R?{cursor:"grab",touchAction:"none"}:void 0,onPointerDown:R?K=>{E(C.id),T(K,C,"note","move")}:void 0,onDoubleClick:R?()=>$(C.id):void 0,children:C.content.trim()?n.jsx(Gs,{content:Wp(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 ${Y}`,"data-testid":"note-resize",onPointerDown:K=>T(K,C,"note","resize")})]},C.id)})}),B&&n.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:wr},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar w6w-section-toolbar ${Y}`,role:"toolbar","aria-label":"Section","data-testid":"section-toolbar","data-section-toolbar":B.id,style:M(B,br),onPointerDown:Qn,onMouseDown:Q,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,B,"section","move"),children:n.jsx(ue.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:B.title,size:Math.max(8,Math.min(32,B.title.length+1)),onBlur:C=>{const q=C.currentTarget.value;q!==B.title&&O(B.id,{title:q})},onKeyDown:C=>{(C.key==="Enter"||C.key==="Escape")&&C.currentTarget.blur()}},`${B.id}:${B.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${g==="color"?" active":""}`,"aria-label":"Section colour","aria-expanded":g==="color",title:"Colour","data-testid":"section-color",onClick:()=>y(g==="color"?null:"color"),children:[n.jsx("span",{className:"w6w-note-swatch"}),n.jsx(ue.Icon,{name:"chevron-down",size:12})]}),g==="color"&&ee(B.color,"section","section-color",C=>O(B.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:()=>{y(null),l==null||l("section",B.id)},children:n.jsx(ue.Icon,{name:"trash"})})]})}),te&&n.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:wr},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar ${Y}`,role:"toolbar","aria-label":"Note","data-testid":"note-toolbar","data-note-toolbar":te.id,style:z(te),onPointerDown:Qn,onMouseDown:Q,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,te,"note","move"),children:n.jsx(ue.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${g==="color"?" active":""}`,"aria-label":"Note colour","aria-expanded":g==="color",title:"Colour","data-testid":"note-color",onClick:()=>y(g==="color"?null:"color"),children:[n.jsx("span",{className:"w6w-note-swatch"}),n.jsx(ue.Icon,{name:"chevron-down",size:12})]}),g==="color"&&ee(te.color,"note","note-color",C=>U(te.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${g==="size"?" active":""}`,"aria-label":"Text size","aria-expanded":g==="size",title:"Text size","data-testid":"note-size",onClick:()=>y(g==="size"?null:"size"),children:["Aa",n.jsx(ue.Icon,{name:"chevron-down",size:12})]}),g==="size"&&n.jsx("div",{className:"w6w-note-menu w6w-note-menu-sizes",role:"menu",children:Vp.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:()=>H(te.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:()=>H(te.id,"bold"),children:n.jsx(ue.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:()=>{y(null),l==null||l("note",te.id)},children:n.jsx(ue.Icon,{name:"trash"})})]})})]}),s)}function Yp(e){const t=es.useStore(o=>{var r;return((r=o.domNode)==null?void 0:r.querySelector(".react-flow__viewport"))??null}),s=es.useStore(o=>o.transform[2]);return n.jsx(ki,{...e,zoom:e.zoom??s,viewport:t})}function Xp(e){return e.viewport!==void 0?n.jsx(ki,{...e,viewport:e.viewport}):n.jsx(Yp,{...e})}function Zp({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 p;c&&((p=d.current)==null||p.focus())},[c]),n.jsxs(Ce,{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 Qt(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]=Qt(o);return t}case"array":return e.items?[Qt(e.items)]:[];default:return null}}function Qp(e){const t={};for(const s of e??[])s&&typeof s.nodeId=="string"&&s.nodeId!==""&&(t[s.nodeId]=s);return t}function Un(e){return e.sampleOmitted!==!0&&"sample"in e&&e.sample!==void 0}function Vn(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 Si(e,t,s,o){const r=t[e],a=s[e];return r!==void 0&&(!a||!Vn(a,o==null?void 0:o[e]))||!a?r:Un(a)?a.sample:Qt(a.shape)}function ef(e,t,s){const o={};for(const r of new Set([...Object.keys(e),...Object.keys(t)])){const a=Si(r,e,t,s);a!==void 0&&(o[r]=a)}return o}function tf(e,t,s){const o={...e};for(const[r,a]of Object.entries(t))Un(a)&&(e[r]===void 0||Vn(a,s==null?void 0:s[r]))&&(o[r]=a.sample);return o}function nf(e,t,s){const o={...e},r={};for(const[a,i]of Object.entries(t))e[a]!==void 0&&!Vn(i,s==null?void 0:s[a])||(delete o[a],r[a]=Un(i)?i.sample:Qt(i.shape));return{fresh:o,persisted:r}}function sf(e,t,s){const o={...e},r={};for(const[a,i]of Object.entries(t))Un(i)&&(e[a]===void 0||Vn(i,s==null?void 0:s[a]))&&(delete o[a],r[a]=i.sample);return{fresh:o,persisted:r}}function of(e,t){if(e.app)return e.app;if(e.app!==null)return t.get(e.appId)}function rf(e){const t=new Set;for(const s of e)s.app===void 0&&t.add(s.appId);return[...t]}exports.AddConnectionModal=Vs;exports.AnchoredFlyout=Wa;exports.ApiCallsPanel=Ja;exports.AppConnectionForm=iu;exports.AppIcon=Nt;exports.AppPicker=rt;exports.AuthFieldsForm=hn;exports.AuthGuide=ta;exports.CALL_APP=tn;exports.CONTROL_APP=Le;exports.CallTargetForm=Ni;exports.CanvasLayer=Xp;exports.CodeEditor=Ps;exports.Combobox=Ye;exports.ConditionEditor=Mn;exports.ConfigViewToggle=qn;exports.ConfirmModal=Zp;exports.CredentialPicker=sa;exports.DATA_APP=Jt;exports.DataTable=ka;exports.DeleteButton=Ks;exports.EACH_SOURCE_HANDLE=Rn;exports.EDITOR_THEME_SPEC=$s;exports.ERROR_SOURCE_HANDLE=ks;exports.EmptyState=za;exports.EventbriteTriggerPicker=Ka;exports.ExpressionEditorModal=nn;exports.ExpressionInput=Yt;exports.ExpressionOptionsProvider=wc;exports.FOREACH_DONE_ROUTE=yt;exports.HTML_PREVIEW_CSP=Sa;exports.HtmlPreview=Aa;exports.INTERNAL_NODES=it;exports.IconButton=_n;exports.InternalIcon=Wn;exports.JsonEditor=Ke;exports.LastUsedNote=La;exports.Markdown=Gs;exports.Modal=Ce;exports.NodeConfigForm=ma;exports.ParamCustomization=zs;exports.ParamsForm=Me;exports.PropertyEntryForm=va;exports.PublisherBadge=Ar;exports.RACE_APP=_t;exports.RACE_DESCRIPTION=Nr;exports.RESULT_RENDER_MAX_CHARS=bs;exports.ROUTER_APP=Ge;exports.ResultViewer=Ee;exports.RetryPolicyFields=ha;exports.RouterEditor=ya;exports.SCHEDULER_APP=Cs;exports.SCRIPT_APP=jr;exports.StepBuilderModal=wp;exports.StepFanOutControl=wi;exports.StepNameEditor=ga;exports.StepStateControl=bi;exports.StepTestRun=vo;exports.StopEditor=xa;exports.TRIGGER_APP=Pt;exports.TriggerFillForm=Ma;exports.TriggerSampleButton=ja;exports.W6WUIProvider=hl;exports.WEBHOOK_APP=Be;exports.WaitEditor=Da;exports.WorkflowConnectionPicker=Ha;exports.WorkflowConnectionsContext=Va;exports.WorkflowProjectProvider=ml;exports.ancestorIds=ho;exports.applyConnect=md;exports.applyStepProblems=zu;exports.asFieldDefs=Ys;exports.bindingFieldsFor=oa;exports.bridgeDeletedBodyStep=cd;exports.buildBinding=ra;exports.buildResolveScope=_s;exports.callableTriggers=bo;exports.canConnect=ni;exports.centralizeConnections=qa;exports.coerceDefault=Zs;exports.conditionCombinatorLabel=uu;exports.conditionOperatorLabel=cu;exports.connectConflict=wd;exports.connectRefusal=bd;exports.connectionAppIdsToLookUp=rf;exports.connectionIdFor=Lt;exports.controlOwnedIds=so;exports.convertCodeBindingsToReads=vc;exports.dataVarRows=Cn;exports.declaredSamples=sp;exports.deepEqual=is;exports.defaultConnectionFor=Ua;exports.definitionLoops=io;exports.deleteStepMessage=hd;exports.detectResultFormat=Ra;exports.edgeLane=ve;exports.edgeVisuals=en;exports.edgeWhenConflict=gd;exports.editConnectionResources=mn;exports.effectiveEdges=ao;exports.effectiveNodeOutput=Si;exports.effectiveNodeOutputs=ef;exports.eventbriteTriggerChoices=Ga;exports.excludeSelfStep=mc;exports.fanOutLabel=dp;exports.fanOutState=cp;exports.fieldWidget=Xs;exports.fieldsToParams=Qs;exports.filterOptions=$r;exports.findChainRoot=_d;exports.findChainTail=Fd;exports.findCodeBindings=Xr;exports.findTestInput=$a;exports.flattenParams=Ot;exports.flowToWorkflow=Id;exports.foreachTestFixture=Ud;exports.foreachTestSample=Vd;exports.getTriggerDefs=ji;exports.hasParamCustomization=Dn;exports.htmlPreviewSrcDoc=Ca;exports.idClashMessage=Nd;exports.ifPortLayout=Bi;exports.indexNodeSamples=Qp;exports.inferOutputFields=bt;exports.internalNodeDef=gt;exports.internalNodeDefaults=Nn;exports.internalNodeIcon=il;exports.internalNodeLabel=al;exports.internalNodeParams=kr;exports.isConnectionBlocked=Yu;exports.isControlApp=Et;exports.isDollarPath=Fs;exports.isEachLink=An;exports.isExprValue=Xe;exports.isFloatingDraft=di;exports.isForeachStep=Ne;exports.isFormResolvedOptions=In;exports.isIfStep=Rs;exports.isInternalApp=ot;exports.isParamVisible=sn;exports.isSecretValue=lt;exports.isTestRequired=yi;exports.isTriggerApp=jn;exports.isTriggerStep=qi;exports.laneForSourceHandle=Oi;exports.loopBody=oo;exports.loopItemText=Zd;exports.loopMembership=qe;exports.loopRefusal=ei;exports.loopRefusalMessage=pd;exports.nextWorkflowConnectionName=to;exports.nodeConfigSources=rp;exports.nodeConfigValues=ap;exports.nodeMetaSampleValues=lp;exports.nodeMetaValues=ip;exports.nodePortsForStep=zt;exports.normalizeInput=po;exports.parseJsonFields=ea;exports.parseLoopSeed=Qd;exports.parseRootAnchoredTemplate=ct;exports.pickWebhookSubscription=Ia;exports.previewCustomization=ba;exports.previewNodeOutputs=tf;exports.relaneRefusal=xd;exports.relayoutNodes=Od;exports.rememberableInput=eo;exports.renameStepInEdges=vd;exports.requiredParamsFilled=$t;exports.resolveConnectionAppMeta=of;exports.resolveLoopItemsInState=li;exports.resolveOutputShape=mt;exports.resolveParamJson=Kt;exports.resolveParamValue=Ms;exports.resolveVarsJson=Ul;exports.resultCopyText=Oa;exports.routeFromHandle=Li;exports.routeHandle=Ft;exports.routerPortLayout=Wi;exports.routesForStep=Ts;exports.secretClipboard=ms;exports.seedValues=ys;exports.selectNodeConnection=Xu;exports.setEdgeWhen=yd;exports.shapeToSkeleton=Qt;exports.shouldUseCombobox=Ir;exports.slugifyLabel=Pd;exports.splitFrontmatter=Na;exports.splitNodeOutputs=nf;exports.splitPreviewOutputs=sf;exports.stampLoopOf=fd;exports.startOAuthPopup=aa;exports.startStateFromSeeds=mo;exports.stateWriteVisible=Ya;exports.stepBuilderLoop=Gd;exports.stepBuilderUpstreamSteps=Kd;exports.stepNameError=si;exports.stepProblemTooltip=Gu;exports.stepToJson=fo;exports.storedViewport=ri;exports.stripBody=ro;exports.suggestStepId=Ld;exports.testInputSavesSettled=_a;exports.trackTestInputSave=Pa;exports.upstreamSampleValueSources=np;exports.upstreamSampleValues=tp;exports.upstreamStateSources=zd;exports.useEffectiveTheme=On;exports.useEnterSubmit=ia;exports.useExpressionOptions=Ze;exports.useRememberedTestInput=Fa;exports.useSeedSources=wo;exports.useW6WApi=ke;exports.useWorkflowConnections=no;exports.valueAtPath=Ut;exports.varLabel=wt;exports.withConnectionRef=Zt;exports.withViewport=$d;exports.workflowToFlow=Rd;
|
|
28
|
-
//# sourceMappingURL=connection-app-meta-DfA6Yqhh.cjs.map
|