@w6w/ui 0.2.0 → 0.2.11
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 +7 -0
- package/dist/AppPicker.d.ts +47 -2
- package/dist/CanvasLayer.d.ts +38 -0
- package/dist/{CodeBlock-Dot3Pd7P.js → CodeBlock-BqXDA35P.js} +2 -2
- package/dist/{CodeBlock-Dot3Pd7P.js.map → CodeBlock-BqXDA35P.js.map} +1 -1
- package/dist/{CodeBlock-CZu4TFSi.cjs → CodeBlock-CulfbnZD.cjs} +2 -2
- package/dist/{CodeBlock-CZu4TFSi.cjs.map → CodeBlock-CulfbnZD.cjs.map} +1 -1
- package/dist/ConfirmModal-Ln99S9NT.js +7919 -0
- package/dist/ConfirmModal-Ln99S9NT.js.map +1 -0
- package/dist/ConfirmModal-fjHW5rN-.cjs +14 -0
- package/dist/ConfirmModal-fjHW5rN-.cjs.map +1 -0
- package/dist/Copyable-DA6eiU7w.cjs +2 -0
- package/dist/Copyable-DA6eiU7w.cjs.map +1 -0
- package/dist/{Copyable-1niV9gUa.js → Copyable-F4NTaG77.js} +91 -15
- package/dist/Copyable-F4NTaG77.js.map +1 -0
- package/dist/EditConnectionModal.d.ts +6 -1
- package/dist/JsonEditor.d.ts +8 -0
- package/dist/Markdown.d.ts +25 -0
- package/dist/ParamsForm.d.ts +7 -1
- package/dist/StepBuilderModal.d.ts +23 -5
- package/dist/WorkflowFlowEditor.d.ts +14 -3
- package/dist/app-pages.d.ts +2 -0
- package/dist/canvas-types.d.ts +36 -0
- package/dist/canvas-utils.d.ts +44 -0
- package/dist/code.cjs +1 -1
- package/dist/code.mjs +2 -2
- package/dist/components/AuthFieldsForm.d.ts +11 -0
- package/dist/components/BudgetMeter.d.ts +15 -0
- package/dist/components/CallableList.d.ts +3 -2
- package/dist/components/Combobox.d.ts +8 -1
- package/dist/components/ConnectionList.d.ts +2 -3
- package/dist/components/CredentialPicker.d.ts +35 -0
- package/dist/components/DataTable.d.ts +27 -0
- package/dist/components/EmptyState.d.ts +9 -0
- package/dist/components/icons.d.ts +1 -1
- package/dist/dynamic-fields.d.ts +60 -0
- package/dist/editor-theme.d.ts +24 -0
- package/dist/flow-fanout.d.ts +2 -2
- package/dist/flow-types.d.ts +18 -1
- package/dist/flow-utils.d.ts +10 -3
- package/dist/flow.cjs +2 -2
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.d.ts +9 -0
- package/dist/flow.mjs +1519 -1138
- package/dist/flow.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.mjs +1362 -1123
- package/dist/index.mjs.map +1 -1
- package/dist/note-markdown.d.ts +22 -0
- package/dist/provider.d.ts +56 -7
- package/dist/resolve-params.d.ts +5 -0
- package/dist/run-visuals.d.ts +4 -1
- package/dist/step-problems.d.ts +34 -0
- package/dist/types.d.ts +109 -3
- package/dist/use-dynamic-fields.d.ts +23 -0
- package/package.json +4 -2
- package/src/styles/_budget-meter.scss +46 -0
- package/src/styles/_callable-list.scss +15 -6
- package/src/styles/_canvas.scss +318 -0
- package/src/styles/_connections.scss +2 -14
- package/src/styles/_data-table.scss +55 -0
- package/src/styles/_empty-state.scss +21 -0
- package/src/styles/_flow.scss +11 -0
- package/src/styles/_fx.scss +23 -0
- package/src/styles/_layout.scss +10 -0
- package/src/styles/_markdown.scss +20 -0
- package/src/styles/_tester.scss +1 -14
- package/src/styles.css +572 -39
- package/src/styles.scss +5 -0
- package/dist/ConfirmModal-ChoiGy2K.cjs +0 -11
- package/dist/ConfirmModal-ChoiGy2K.cjs.map +0 -1
- package/dist/ConfirmModal-Wx3i8F1n.js +0 -6359
- package/dist/ConfirmModal-Wx3i8F1n.js.map +0 -1
- package/dist/Copyable-1niV9gUa.js.map +0 -1
- package/dist/Copyable-CYZU1o4X.cjs +0 -2
- package/dist/Copyable-CYZU1o4X.cjs.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),un=require("@xyflow/react"),d=require("react"),Fs=require("react-dom"),Ls=require("react-markdown"),ie=require("./Copyable-DA6eiU7w.cjs"),Mn=require("@codemirror/lang-json"),pn=require("@codemirror/lint"),Fn=require("@codemirror/view"),Ln=require("@uiw/react-codemirror"),Ds=require("@codemirror/lang-javascript"),_s=require("@codemirror/lang-python"),fe=require("@w6w/expr"),qs={ai:"AI",cms:"CMS",crm:"CRM",hr:"HR",devops:"DevOps"};function Hs(e){if(typeof e!="string"||e.trim()==="")return"";const n=qs[e];return n||e.split(/[-_\s]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function Vs(e){const n=new Map;for(const s of e)for(const r of s.categories??[])n.set(r,(n.get(r)??0)+1);return[...n.entries()].map(([s,r])=>({slug:s,label:Hs(s),count:r})).sort((s,r)=>r.count-s.count||s.label.localeCompare(r.label,void 0,{sensitivity:"base"}))}function Ws(e,n){if(n.length===0)return!0;const s=e.categories??[];return n.some(r=>s.includes(r))}function Dn(e,n){const s=e==="error"?{className:"w6w-edge-error",label:"on error"}:{};if(!n)return s;const r=n==="taken"?"w6w-edge-taken":"w6w-edge-skipped";return{className:s.className?`${s.className} ${r}`:r,...s.label?{label:s.label}:{}}}const Dt="out-error";function _n(e){return e==="error"?Dt:void 0}function Bs(e){return e===Dt?"error":"success"}const Us="@w6w/",ge="@w6w/control",qn="@w6w/script",Ze="@w6w/data",Qe="@w6w/trigger",zs="@w6w/http",_t="@w6w/webhook",qt="@w6w/scheduler",Js="@w6w/respond",et="@w6w/call",Gs="@w6w/document",gt="@w6w/model",Ks="@w6w/template";function ke(e){return e.startsWith(Us)}function We(e){return e===ge}function ze(e){return e===Qe||e===_t||e===qt}const wn={in:1,out:Number.POSITIVE_INFINITY};function hn(e){return e==="many"?Number.POSITIVE_INFINITY:typeof e=="number"?e:void 0}function Ys(...e){let n,s;for(const r of e)n??(n=hn(r==null?void 0:r.in)),s??(s=hn(r==null?void 0:r.out));return{in:n??wn.in,out:s??wn.out}}function Xs(e,n){var o;const{app:s,action:r}=e.uses;return Ys(e.ports,n==null?void 0:n(s,r),(o=Ce(s,r))==null?void 0:o.ports)}const Zs='<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',Qs='<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" />',er='<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" />',tr='<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" />',nr='<circle cx="12" cy="12" r="9" /><polyline points="12 7 12 12 15 14" />',sr='<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" />',rr='<polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" />',or='<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" />',ar='<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" />',ir='<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" />',lr='<polyline points="9 17 4 12 9 7" /><path d="M20 18v-2a4 4 0 0 0-4-4H4" />',fn='<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',cr='<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" />',dr='<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" />',bt='<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" />',ur='<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" />',Ie=[{app:Qe,action:"manual",label:"Manual trigger",displayName:"Manual trigger",group:"trigger",icon:Zs,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 {"$": "steps.<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"},{key:"required",label:"Required",type:"boolean",default:!1}]}}]},{app:_t,action:"webhook",label:"Webhook",displayName:"Webhook",group:"trigger",icon:ir,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 = { "message": "Workflow was started" }.',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:qt,action:"schedule",label:"Schedule",displayName:"Scheduler",group:"trigger",icon:sr,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:ge,action:"if",label:"If",displayName:"If",group:"control",icon:Qs,params:[{key:"condition",type:"json",label:"Condition",required:!0,default:!0,hint:'A boolean, or an expression binding like { "$": "steps.x.output.ok" }.'}]},{app:ge,action:"foreach",label:"For each",displayName:"For each",group:"control",icon:er,params:[{key:"items",type:"json",label:"Items",required:!0,default:[],hint:"An array to iterate, or an expression binding to one."}]},{app:ge,action:"parallel",label:"Parallel",displayName:"Parallel",group:"control",icon:tr,params:[]},{app:ge,action:"wait",label:"Wait",displayName:"Wait",group:"control",icon:nr,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:qn,action:"run",label:"Run script",displayName:"Run script",group:"compute",icon:rr,params:[{key:"language",label:"Language",type:"select",default:"javascript",options:[{value:"javascript",label:"JavaScript"},{value:"python",label:"Python"}],hint:"Execution language for this step's code. Python runs CPython-on-WASM with no network."},{key:"code",type:"code",label:"Script",required:!0,default:`// Runs as a function body. Return the step's output.
|
|
2
|
+
return input;`,hint:"Function body; return the step's output."}]},{app:Ks,action:"render",label:"Render template",displayName:"Template",group:"compute",icon:ur,output:[{key:"result"}],params:[{key:"template",label:"Template",type:"text",required:!0,hint:"Handlebars template. Placeholder names are workflow-agnostic — bind them below. {{name}} is HTML-escaped; use {{{name}}} for raw output."},{key:"values",label:"Values",type:"vars",required:!0,default:[],hint:'A typed key/value array: [{ "key": "data", "type": "json", "value": ... }]. Each key becomes a top-level placeholder root.'}]},{app:Ze,action:"set",label:"Data",displayName:"Data set",group:"compute",icon:or,params:[{key:"vars",type:"vars",label:"Variables",required:!0,default:[],hint:"Typed key/value variables for downstream steps to reference."}]},{app:zs,action:"request",label:"HTTP request",displayName:"HTTP",group:"request",icon:ar,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:Js,action:"respond",label:"Respond to Webhook",displayName:"Respond to Webhook",group:"request",icon:lr,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:ge,action:"aggregate",label:"Aggregate",displayName:"Aggregate",group:"control",icon:fn,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:ge,action:"merge",label:"Merge",displayName:"Merge",group:"control",icon:fn,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:et,action:"call",label:"Call workflow",displayName:"Call",group:"compute",icon:cr,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:"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:Gs,action:"get",label:"Get document",displayName:"Document",group:"compute",icon:dr,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:gt,action:"complete",label:"Complete with model",displayName:"Model",group:"compute",icon:bt,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:gt,action:"list-models",label:"List models",displayName:"Model",group:"compute",icon:bt,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:gt,action:"allowance",label:"Model allowance",displayName:"Model",group:"compute",icon:bt,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."}]}];function Ce(e,n){return Ie.find(s=>s.app===e&&s.action===n)}function pr(e,n){var s;return((s=Ce(e,n))==null?void 0:s.label)??n}function wr(e,n){var s;return((s=Ce(e,n))==null?void 0:s.icon)??""}function Hn(e,n){var s;return((s=Ce(e,n))==null?void 0:s.params)??[]}function Vn(e,n){const s={};for(const r of Hn(e,n))r.default!==void 0&&(s[r.key]=r.default);return s}function hr(e,n){return e.q===n.q&&(e.category??"")===(n.category??"")&&(e.ids??[]).join(",")===(n.ids??[]).join(",")}function Wn(e,n=0){return{query:e,generation:n,status:"loading",apps:[],hasMore:!1}}function fr(e,n){const s=new Set(e.map(o=>o.id)),r=[];for(const o of n)s.has(o.id)||(s.add(o.id),r.push(o));return r.length===0?e:[...e,...r]}function mr(e,n){switch(n.type){case"query-changed":return n.generation===e.generation&&hr(n.query,e.query)?e:Wn(n.query,n.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(n.generation!==e.generation)return e;const s=fr(e.apps,n.apps),r=n.nextCursor!==void 0&&n.nextCursor===n.requestedCursor,o=!!n.nextCursor&&!r;return{...e,status:"ready",apps:s,cursor:o?n.nextCursor:void 0,hasMore:o,total:typeof n.total=="number"?n.total:e.total,error:void 0}}case"page-failed":return n.generation!==e.generation?e:{...e,status:"error",error:n.error};default:return e}}function gr(e){return e.filter(n=>!ke(n.id))}function xt(e,n,s){if(s<=0)return[];const r=[];for(const o of e)if(!n.has(o)&&(r.push(o),r.length>=s))break;return r}function br(e,n){const s=[];for(const r of e){const o=n.get(r);o&&s.push(o)}return s}const Bn=d.createContext(void 0);function mn(e,n){var r;if(e)return e;if(n)return n;if(typeof document>"u")return"light";const s=document.documentElement.getAttribute("data-theme");return s==="dark"||s==="light"?s:(r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function tt(e){const n=d.useContext(Bn),[s,r]=d.useState(()=>mn(e,n));return d.useEffect(()=>{if(e){r(e);return}if(n){r(n);return}if(typeof window>"u")return;const o=()=>r(mn(void 0,n)),a=window.matchMedia("(prefers-color-scheme: dark)");a.addEventListener("change",o);const i=new MutationObserver(o);return i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),o(),()=>{a.removeEventListener("change",o),i.disconnect()}},[e,n]),s}function je({src:e,srcDark:n,brandColor:s,name:r,size:o=32,theme:a}){const l=tt(a)==="dark"?n??e:e,[c,u]=d.useState(void 0);if(l&&l!==c)return t.jsx("img",{src:l,width:o,height:o,alt:"",onError:()=>u(l),style:{width:o,height:o,borderRadius:6,flexShrink:0,objectFit:"contain",padding:Math.max(1,Math.round(o*.06)),boxSizing:"border-box",background:"var(--w6w-icon-swatch, var(--w6w-panel-2))"}});const p=(r??"?").split(/\s+/).slice(0,2).map(w=>{var f;return((f=w[0])==null?void 0:f.toUpperCase())??""}).join("");return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o,height:o,borderRadius:6,background:s??"var(--w6w-accent)",color:"#fff",fontWeight:700,fontSize:Math.round(o*.42),flexShrink:0},children:p})}const Ht=d.createContext(null);function xr({api:e,theme:n,children:s}){const r=t.jsx(Ht.Provider,{value:e,children:t.jsx(Bn.Provider,{value:n,children:s})});return n?t.jsx("div",{"data-theme":n,style:{display:"contents"},children:r}):r}function re(){const e=d.useContext(Ht);if(!e)throw new Error("useW6WApi must be used inside <W6WUIProvider>. Wrap your app root with <W6WUIProvider api={api}>...</W6WUIProvider>.");return e}function Un(){return d.useContext(Ht)??void 0}const zn=d.createContext(void 0);function yr({project:e,children:n}){return t.jsx(zn.Provider,{value:e,children:n})}function Vt(){return d.useContext(zn)}const yt=8,vr=60,jr=300;function gn(e){const n=e.modelProvider;return!n||typeof n!="object"?null:n}function Nr(e){if(!e)return null;if(e.supported)return{text:"Bridge supported",title:"Bridge supported"};const n=typeof e.reason=="string"?e.reason.trim():"";return{text:n===""?"unsupported":`unsupported — ${n}`,title:n===""?"Bridge not supported":n}}function Se({onSelectApp:e,theme:n,filter:s,searchPlaceholder:r,emptyMessage:o,search:a=!0,emptyAction:i,apps:l,categoryFilter:c=!1,providerFilter:u=!1,bridgeSupport:p,category:w,ids:f,pageLimit:h=vr,loadPage:g}){const x=re(),k=l!==void 0,O=f&&f.length>0?f.join(","):"",N=!k&&(g!==void 0||typeof x.listAppsPage=="function"),M=d.useRef(g);M.current=g;const[y,S]=d.useState(null),[b,P]=d.useState(null);d.useEffect(()=>{if(k||N)return;const q=x.listApps;if(typeof q!="function"){S([]);return}let ee=!1;return q().then(se=>!ee&&S(se)).catch(se=>!ee&&P(se.message)),()=>{ee=!0}},[x,k,N]);const[A,z]=d.useReducer(mr,Wn({q:"",category:w,ids:f},0)),[$,_]=d.useState(""),[j,H]=d.useState(""),U=d.useRef(0),F=d.useRef(null),B=d.useCallback((q,ee,se)=>{var ln;const ht=M.current,an=x.listAppsPage;if(!ht&&!an)return;(ln=F.current)==null||ln.abort();const ft=new AbortController;F.current=ft;let mt;try{mt=ht?ht({q:q.q||void 0,cursor:se,limit:h,...q.ids?{ids:q.ids}:{},signal:ft.signal}):an({q:q.q||void 0,category:q.category,...q.ids?{ids:q.ids}:{},cursor:se,limit:h,compact:!0,signal:ft.signal})}catch(ae){mt=Promise.reject(ae)}mt.then(ae=>{if(U.current===ee){if(!ae||!Array.isArray(ae.apps)){z({type:"page-failed",generation:ee,error:"The server returned a malformed apps page."});return}z({type:"page-loaded",generation:ee,apps:ae.apps,nextCursor:ae.nextCursor,requestedCursor:se,total:typeof ae.total=="number"?ae.total:void 0})}}).catch(ae=>{if(U.current!==ee||ae instanceof Error&&ae.name==="AbortError")return;const cn=ae==null?void 0:ae.code;if(se!==void 0&&(cn==="snapshot_expired"||cn==="unknown_snapshot")){const dn=++U.current;z({type:"query-changed",query:q,generation:dn}),B(q,dn,void 0);return}z({type:"page-failed",generation:ee,error:ae.message})})},[x,h]);d.useEffect(()=>{if(!N)return;const q=setTimeout(()=>H($.trim()),jr);return()=>clearTimeout(q)},[$,N]),d.useEffect(()=>{if(!N)return;const q=++U.current,ee={q:j,category:w,...O?{ids:O.split(",")}:{}};return z({type:"query-changed",query:ee,generation:q}),B(ee,q,void 0),()=>{var se;(se=F.current)==null||se.abort()}},[N,j,w,O,B]),d.useEffect(()=>{if(N)return()=>{var q;return(q=F.current)==null?void 0:q.abort()}},[N]);const Y=()=>{if(!N||A.status!=="ready"||!A.hasMore)return;const q=U.current;z({type:"load-more"}),B(A.query,q,A.cursor)},K=()=>{!N||A.status!=="error"||(z({type:"retry"}),B(A.query,U.current,A.cursor))},[X,Z]=d.useState([]),[Q,V]=d.useState(!1),[G,J]=d.useState(!1),v=q=>t.jsx("div",{className:"w6w-apppicker-host",children:q});let C,T=null,L=!1,m=!1,R=null,I=!1;if(k?C=l??null:N?(C=A.apps,I=A.status==="loading",L=A.status==="loading-more",m=A.hasMore,A.status==="error"&&(A.apps.length===0?T=A.error??"Failed to load apps.":R=A.error??"Failed to load apps.")):(C=y,T=b),!N&&T)return v(t.jsx("div",{className:"w6w-result w6w-error",children:T}));if(!N&&C===null)return v(t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}));C??(C=[]);const E=gr(C),D=s?E.filter(s):E;if(!N&&D.length===0)return v(t.jsxs("div",{className:"w6w-stack",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:o??"No apps registered yet. Register one from the Apps page first."}),i]}));const te=c?Vs(D):[],le=te.slice(0,yt),oe=te.slice(yt).filter(q=>X.includes(q.slug)),ue=[...le,...oe],Re=te.length-ue.length,pe=Q?te:ue,me=q=>Z(ee=>ee.includes(q)?ee.filter(se=>se!==q):[...ee,q]),ut=()=>Z([]),ce=D.filter(q=>gn(q)!==null).length,Pe=u&&ce>0,he=Pe&&G,Ne=he?D.filter(q=>gn(q)!==null):D,we=c&&X.length>0?Ne.filter(q=>Ws(q,X)):Ne,He=N?we:[...we].sort((q,ee)=>q.displayName.localeCompare(ee.displayName,void 0,{sensitivity:"base"})),Oe=N?"":$.trim().toLowerCase(),W=$.trim().length>0,ne=Oe?He.filter(q=>q.displayName.toLowerCase().includes(Oe)||q.id.toLowerCase().includes(Oe)):He,ye=s!==void 0&&D.length!==E.length||he&&Ne.length!==D.length||c&&X.length>0&&we.length!==Ne.length,pt=(c&&X.length>0||he)&&ne.length===0,on=he&&X.length===0,wt=()=>{Z([]),J(!1),_("")};return v(t.jsxs("div",{className:"w6w-stepbuilder-apps",children:[a&&t.jsx("input",{type:"text",className:"w6w-stepbuilder-search",placeholder:r??"Search apps…",value:$,onChange:q=>_(q.target.value),"aria-label":"Search apps"}),(Pe||c&&te.length>0)&&t.jsxs("div",{className:"w6w-apppicker-cats",children:[Pe&&t.jsxs("button",{type:"button",className:"w6w-apppicker-chip w6w-apppicker-provider-toggle","aria-pressed":G,"aria-label":"Filter to model providers",onClick:()=>J(q=>!q),children:["Model providers ",t.jsxs("span",{className:"w6w-muted",children:["(",ce,")"]})]}),c&&te.length>0&&t.jsxs(t.Fragment,{children:[pe.map(q=>t.jsxs("button",{type:"button",className:"w6w-apppicker-chip","aria-pressed":X.includes(q.slug),"aria-label":`Filter by ${q.label}`,onClick:()=>me(q.slug),children:[q.label," ",t.jsxs("span",{className:"w6w-muted",children:["(",q.count,")"]})]},q.slug)),!Q&&Re>0&&t.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>V(!0),children:["+",Re," more"]}),Q&&te.length>yt&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>V(!1),children:"Show less"}),X.length>0&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:ut,children:"Clear"})]})]}),N&&I?t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}):N&&T?t.jsxs("div",{className:"w6w-result w6w-error",children:[T," ",t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:K,children:"Retry"})]}):ne.length===0&&!m?pt?t.jsxs("div",{className:"w6w-stack",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:on?W?`No model providers match “${$}”.`:"No apps declare a model provider.":W?`No apps match “${$}” in the selected categories.`:"No apps match the selected categories."}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:wt,children:"Clear filters"})]}):N?t.jsxs("div",{className:"w6w-stack",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:W?`No apps match “${$}”.`:o??"No apps registered yet. Register one from the Apps page first."}),!W&&i]}):t.jsxs("p",{className:"w6w-muted w6w-small",children:["No apps match “",$,"”."]}):t.jsxs(t.Fragment,{children:[ne.length===0&&m?t.jsx("p",{className:"w6w-muted w6w-small",children:"No matching apps on this page yet — try “Load more”."}):t.jsx("div",{className:"w6w-stepbuilder-list w6w-apppicker-grid w6w-stepbuilder-scroll",children:ne.map(q=>{const ee=p==null?void 0:p.get(q.id),se=Nr(ee);return t.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-apppicker-card",onClick:()=>e(q),children:[t.jsx(je,{src:q.iconSvg,srcDark:q.iconSvgDark,brandColor:q.brandColor,name:q.displayName,theme:n,size:24}),t.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[t.jsx("strong",{children:q.displayName}),t.jsx("code",{className:"w6w-apppicker-card-id",children:q.id}),q.version&&t.jsxs("span",{className:"w6w-apppicker-card-version",children:["v",q.version]}),se&&t.jsx("span",{className:ee!=null&&ee.supported?"w6w-chip w6w-apppicker-card-bridge":"w6w-chip w6w-apppicker-card-bridge w6w-apppicker-card-bridge-unsupported",title:se.title,children:se.text})]})]},q.id)})}),N&&typeof A.total=="number"&&t.jsx("div",{className:"w6w-small w6w-apppicker-count",children:ye?`${ne.length} ${ne.length===1?"app":"apps"}`:`${A.apps.length} of ${A.total}`}),N&&R&&t.jsxs("div",{className:"w6w-result w6w-error w6w-small",children:[R," ",t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:K,children:"Retry"})]}),N&&m&&!R&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-apppicker-load-more",onClick:Y,disabled:L,children:L?"Loading more…":"Load more"})]})]}))}function kt(e,n){const s={...n};for(const r of e){const o=n[r.key];if(!(r.type!=="json"||typeof o!="string"||o.trim()===""))try{s[r.key]=JSON.parse(o)}catch{return{error:`${r.label} is not valid JSON. Check it and try again.`}}}return{values:s}}function Be({fields:e,values:n,onChange:s,enterSubmitProps:r,mode:o="create"}){const a=(i,l)=>s({...n,[i]:l});return t.jsxs("div",{className:"w6w-stack",children:[e.length===0&&t.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=o==="edit",c=n[i.key]??(l?void 0:i.default)??"";if(i.type==="boolean")return t.jsxs("label",{className:"w6w-field",children:[t.jsxs("span",{children:[t.jsx("input",{type:"checkbox",checked:!!c,onChange:w=>a(i.key,w.target.checked),...r}),i.label,i.required?" *":""]}),i.hint&&t.jsx("span",{className:"w6w-hint",children:i.hint})]},i.key);const u=i.type==="secret"||i.secret===!0;if(i.type==="json"||i.type==="text")return t.jsxs("label",{className:"w6w-field",children:[t.jsxs("span",{children:[i.label,i.required?" *":""]}),t.jsx("textarea",{className:u?"w6w-secret-input":void 0,rows:i.type==="json"?6:3,value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:w=>a(i.key,w.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&&t.jsx("span",{className:"w6w-hint",children:i.hint})]},i.key);const p=i.type==="number"?"number":"text";return t.jsxs("label",{className:"w6w-field",children:[t.jsxs("span",{children:[i.label,i.required?" *":""]}),t.jsx("input",{type:p,className:u?"w6w-secret-input":void 0,value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:w=>a(i.key,i.type==="number"&&!(l&&w.target.value==="")?Number(w.target.value):w.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",...r}),i.hint&&t.jsx("span",{className:"w6w-hint",children:i.hint})]},i.key)})]})}function Jn({credentials:e,mode:n,onModeChange:s,selectedId:r,onSelect:o,canUseExisting:a=!0,contract:i}){const l=c=>{const u=Object.values(c.display??{}).filter(Boolean);return u.length>0?`${c.name} (${u.join(", ")})`:c.name};return t.jsxs("div",{className:"w6w-stack",children:[a&&t.jsxs("div",{className:"w6w-field",role:"radiogroup","aria-label":"Credential",children:[t.jsxs("span",{children:["Credential",i?` (${i})`:""]}),t.jsxs("label",{children:[t.jsx("input",{type:"radio",name:"w6w-credential-mode",checked:n==="existing",onChange:()=>s("existing")})," ","Use existing"]}),t.jsxs("label",{children:[t.jsx("input",{type:"radio",name:"w6w-credential-mode",checked:n==="new",onChange:()=>s("new")})," ","Create new"]})]}),a&&n==="existing"&&t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Stored credential"}),t.jsx("select",{name:"w6w-credential-id",value:r,onChange:c=>o(c.target.value),children:e.map(c=>t.jsx("option",{value:c.id,children:l(c)},c.id))})]})]})}function Gn(e){const n=(e.bindingFields??[]).filter(o=>o.key!=="delegatedUser");return e.impersonation==="none"?n:[{...(e.bindingFields??[]).find(o=>o.key==="delegatedUser")??{type:"string"},key:"delegatedUser",label:"Impersonated user",type:"string",required:e.impersonation==="required"},...n]}function Kn(e,n){const s={},r={};for(const o of e){const a=n[o.key];a==null||a===""||(o.key==="delegatedUser"?s.delegatedUser=String(a):r[o.key]=a)}return Object.keys(r).length>0&&(s.settings=r),Object.keys(s).length>0?s:void 0}const kr={default:"",wide:" w6w-modal-wide",xl:" w6w-modal-xl",full:" w6w-modal-full",fullscreen:" w6w-modal-fullscreen"};function de({title:e,ariaLabel:n,onClose:s,children:r,size:o="default",titleIcon:a,subtitle:i,headerRight:l}){const c=d.useRef(null);return d.useEffect(()=>{const u=c.current;if(!u)return;u.open||u.showModal();const p=f=>{f.preventDefault(),s()},w=f=>{if(f.target!==u)return;const h=u.getBoundingClientRect();(f.clientX<h.left||f.clientX>h.right||f.clientY<h.top||f.clientY>h.bottom)&&s()};return u.addEventListener("cancel",p),u.addEventListener("click",w),()=>{u.removeEventListener("cancel",p),u.removeEventListener("click",w)}},[s]),t.jsx("div",{className:"w6w-modal-backdrop",children:t.jsxs("dialog",{ref:c,className:`w6w-modal${kr[o]}`,"aria-label":n??(typeof e=="string"?e:void 0),children:[t.jsxs("div",{className:"w6w-modal-header",children:[t.jsxs("h3",{className:"w6w-modal-title",children:[a,t.jsx("span",{children:e}),i&&t.jsx("span",{className:"w6w-modal-subtitle",children:i})]}),l]}),r]})})}const Cr="width=560,height=720,menubar=no,toolbar=no,location=no";function Yn(e){return new Promise((n,s)=>{const r=window.open(e,"w6w-oauth",Cr);if(!r){s(new Error("Popup blocked — allow popups for this site and try again."));return}let o=!1;const a=()=>{o=!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{r.close()}catch{}u.ok&&typeof u.connectionId=="string"?n({connectionId:u.connectionId}):s(new Error(u.error??"OAuth flow failed."))}};window.addEventListener("message",i);const l=window.setInterval(()=>{o||r.closed&&(a(),s(new Error("OAuth popup was closed before the flow completed.")))},500)})}const Sr=new Set(["checkbox","radio","button","submit","reset","file","range","color","image","hidden","date","datetime-local","month","week","time"]);function Ar(e){return e.closest('[contenteditable]:not([contenteditable="false"])')!==null}function Xn(e,n){return{onKeyDown:s=>{if((n==null?void 0:n.enabled)===!1||s.key!=="Enter"||s.shiftKey||s.altKey||s.ctrlKey||s.metaKey||s.nativeEvent.isComposing)return;const r=s.target;r.tagName!=="TEXTAREA"&&(Ar(r)||r.tagName==="INPUT"&&Sr.has(r.type)||(s.preventDefault(),e()))}}}function Wt(e){const n=re(),[s,r]=d.useState(null),[o,a]=d.useState(!!e.initialAppId);return d.useEffect(()=>{const i=e.initialAppId;if(!i)return;let l=!1;const c=w=>{l||(r(w),a(!1))},u=n.listAppsByIds;if(u)return u([i]).then(w=>c(w.find(f=>f.id===i)??null)).catch(()=>c(null)),()=>{l=!0};const p=n.listApps;return typeof p=="function"?p().then(w=>c(w.find(f=>f.id===i)??null)).catch(()=>c(null)):c(null),()=>{l=!0}},[n,e.initialAppId]),s?t.jsx(de,{title:s.displayName,subtitle:t.jsxs(t.Fragment,{children:[t.jsx("code",{children:s.id}),s.version&&` · v${s.version}`]}),onClose:e.onClose,size:"xl",titleIcon:t.jsx(je,{src:s.iconSvg,srcDark:s.iconSvgDark,brandColor:s.brandColor,name:s.displayName,theme:e.theme,size:22}),headerRight:e.initialAppId?void 0:t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>r(null),children:"← Apps"}),children:t.jsx(Er,{app:s,onCreated:e.onCreated,onClose:e.onClose})}):o?t.jsx(de,{title:"Add connection",onClose:e.onClose,size:"xl",children:t.jsx("div",{className:"w6w-stepbuilder-content",children:t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"})})}):t.jsx(de,{title:"Add connection",onClose:e.onClose,size:"xl",children:t.jsx("div",{className:"w6w-stepbuilder-content",children:t.jsx(Se,{onSelectApp:r,theme:e.theme,searchPlaceholder:"Search apps to connect…",categoryFilter:!0})})})}function Er({app:e,onCreated:n,onClose:s}){var R,I;const r=re(),[o,a]=d.useState(null),[i,l]=d.useState(""),[c,u]=d.useState(""),[p,w]=d.useState({}),[f,h]=d.useState(null),[g,x]=d.useState(!1),[k,O]=d.useState(null),[N,M]=d.useState(null),[y,S]=d.useState(""),[b,P]=d.useState(""),[A,z]=d.useState({}),$=d.useRef(null);d.useEffect(()=>{let E=!1;return a(null),r.getAppAuth(e.id).then(D=>!E&&a(D.filter(te=>te.available!==!1))).catch(D=>!E&&h(D.message)),()=>{E=!0}},[r,e.id]);const _=o??[],j=_.find(E=>E.key===i)??_.find(E=>E.default===!0)??_[0],H=(j==null?void 0:j.fields)??[],U=(j==null?void 0:j.type)==="oauth2",F=j==null?void 0:j.serviceAccount,B=r.listCredentials,Y=r.createCredential,K=!U&&!!F&&typeof B=="function"&&typeof Y=="function",X=((R=F==null?void 0:F.accepts)==null?void 0:R[0])??"",Z=(k??[]).filter(E=>E.contract===X&&E.status==="active"),Q=Z.length===0?"new":N??"existing",V=Z.some(E=>E.id===y)?y:((I=Z[0])==null?void 0:I.id)??"",G=K&&F?Gn(F):[];d.useEffect(()=>{if(!K||!B)return;let E=!1;return O(null),M(null),$.current=null,B.call(r,{contract:X}).then(D=>!E&&O(D)).catch(()=>!E&&O([])),()=>{E=!0}},[r,K,X,B]);const J=(j==null?void 0:j.key)==="zero-credential",v=E=>E===void 0||E==="",C=!U&&!J&&(K?k===null||G.some(E=>E.required&&v(A[E.key]))||(Q==="existing"?V==="":b.trim()===""||H.some(E=>E.required&&v(p[E.key]))):H.some(E=>E.required&&v(p[E.key]))),T=!j||!U&&!J&&C||g;async function L(){if(j){h(null),x(!0);try{if(J)n({connectionId:`zerocred:${e.id}`});else if(U){const{authorizationUrl:E}=await r.startAppOAuthFlow(e.id,j.key,{displayName:c||void 0}),{connectionId:D}=await Yn(E);n({connectionId:D})}else if(K&&Y){let E=Q==="existing"?V:$.current;if(E===null){const oe=kt(H,p);if("error"in oe){h(oe.error);return}const ue=await Y.call(r,{name:b.trim(),contract:X,source:oe.values});$.current=ue.id,E=ue.id}const D=Kn(G,A),te={authKey:j.key,credentialId:E,...D?{binding:D}:{},...c?{displayName:c}:{}},le=await r.createConnection(e.id,te);n({connectionId:le.id})}else{const E=kt(H,p);if("error"in E){h(E.error);return}const D=await r.createConnection(e.id,{authKey:j.key,credential:E.values,displayName:c||void 0});n({connectionId:D.id})}}catch(E){h(E.message)}finally{x(!1)}}}const m=Xn(L,{enabled:!T});return t.jsxs("div",{className:"w6w-stepconfig",children:[t.jsx("div",{className:"w6w-modal-body",children:t.jsxs("div",{className:"w6w-stack",children:[o===null&&t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading auth methods…"}),o!==null&&_.length===0&&t.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."}),_.length>1&&t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Auth method"}),t.jsx("select",{value:(j==null?void 0:j.key)??"",onChange:E=>{l(E.target.value),w({}),z({}),$.current=null,h(null)},children:_.map(E=>t.jsxs("option",{value:E.key,children:[E.displayName??E.key," (",E.type,")"]},E.key))})]}),j&&t.jsxs(t.Fragment,{children:[!J&&t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Display name"}),t.jsx("input",{type:"text",value:c,onChange:E=>u(E.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",...m})]}),j.description&&t.jsx("p",{className:"w6w-muted w6w-small",children:j.description}),J?null:U?t.jsxs("p",{className:"w6w-muted w6w-small",children:["You'll be redirected to ",t.jsx("strong",{children:j.displayName??j.key})," to authorize this connection."]}):K&&F?t.jsxs(t.Fragment,{children:[t.jsx(Jn,{credentials:Z,mode:Q,onModeChange:E=>{M(E),$.current=null},selectedId:V,onSelect:S,canUseExisting:Z.length>0,contract:X}),F.scopes.length>0&&t.jsxs("p",{className:"w6w-muted w6w-small",children:["Scopes: ",t.jsx("code",{children:F.scopes.join(" ")})]}),G.length>0&&t.jsx(Be,{fields:G,values:A,onChange:z,enterSubmitProps:m}),Q==="new"&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Credential name *"}),t.jsx("input",{type:"text",value:b,onChange:E=>P(E.target.value),placeholder:"e.g. Workspace automation",maxLength:80,name:"w6w-credential-name",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...m})]}),t.jsx(Be,{fields:H,values:p,onChange:w,enterSubmitProps:m})]})]}):t.jsx(Be,{fields:H,values:p,onChange:w,enterSubmitProps:m})]}),f&&t.jsx("div",{className:"w6w-result w6w-error",children:f})]})}),t.jsxs("div",{className:"w6w-modal-actions",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),t.jsx("button",{type:"button",className:"w6w-btn",disabled:T,onClick:L,children:g?J?"Saving…":U?"Waiting for authorization…":"Saving…":J?"Use this":U?`Sign in with ${(j==null?void 0:j.displayName)??(j==null?void 0:j.key)??"provider"}`:"Save connection"})]})]})}const Tr=new Set(["http:","https:","mailto:"]);function Ir(e){try{return Tr.has(new URL(e).protocol)?e:""}catch{return""}}const Rr=["img"];function Pr({node:e,href:n,children:s,...r}){return t.jsx("a",{...r,href:n||void 0,target:"_blank",rel:"noopener noreferrer nofollow",children:s})}function Zn(e){const n=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return n?{frontmatter:n[1],body:e.slice(n[0].length)}:{frontmatter:null,body:e}}function Or({yaml:e}){return t.jsxs("details",{className:"w6w-md-frontmatter","data-testid":"md-frontmatter",children:[t.jsx("summary",{children:"Frontmatter"}),t.jsx("pre",{children:t.jsx("code",{children:e})})]})}function Qn({content:e,className:n}){const{frontmatter:s,body:r}=Zn(e);return t.jsxs("div",{className:n,children:[(s==null?void 0:s.trim())&&t.jsx(Or,{yaml:s}),t.jsx(Ls,{skipHtml:!0,urlTransform:Ir,disallowedElements:Rr,unwrapDisallowed:!0,components:{a:Pr},children:r})]})}const $r=/^(#{1,6})\s+(.*)$/,Mr=new RegExp("\\*\\*(?=\\S)(.+?)(?<=\\S)\\*\\*","g");function Fr(e,n){const s=e.ownerDocument;e.replaceChildren();for(const r of n.split(`
|
|
3
|
+
`)){const o=$r.exec(r),a=s.createElement(o?`h${o[1].length}`:"div"),i=o?o[2]:r;let l=0;for(const c of i.matchAll(Mr)){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 Lr(e){var r;const n=(r=e.style)==null?void 0:r.fontWeight;if(!n)return;if(n==="bold"||n==="bolder")return!0;const s=Number(n);return Number.isFinite(s)?s>=600:!1}function Dr(e){const n=[];for(const s of e){const r=n[n.length-1];r&&r.bold===s.bold?r.text+=s.text:n.push({...s})}return n.map(({text:s,bold:r})=>{const o=s.trim();if(!r||!o)return s;const a=s.slice(0,s.indexOf(o)),i=s.slice(a.length+o.length);return`${a}**${o}**${i}`}).join("")}function _r(e){const n=[];let s=null;const r=i=>(s={level:i,runs:[]},n.push(s),s),o=(i,l,c)=>{if(i.nodeType===3){const x=(i.textContent??"").replace(/ /g," ").replace(/\n/g,"");x&&(s??r(l)).runs.push({text:x,bold:c});return}if(i.nodeType!==1)return;const u=i,p=u.tagName.toLowerCase();if(p==="br"){s||r(l),s=null;return}const w=/^h([1-6])$/.exec(p),f=w||["div","p","li","ul","ol","blockquote","pre"].includes(p);f&&(s=null);const h=w?Number(w[1]):l,g=p==="b"||p==="strong"?!0:Lr(u)??c;for(const x of u.childNodes)o(x,h,g);f&&(s=null)};for(const i of e.childNodes)o(i,0,!1);const a=n.map(i=>{const l=Dr(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(`
|
|
4
|
+
`)}function qr(e){return e.replace(/([^\n])\n(?=[^\n])/g,`$1
|
|
5
|
+
`)}const Hr=-2,Vr=-1,bn=1e3,Wr=["#facc15","#fb923c","#f87171","#f472b6","#a78bfa","#60a5fa","#2dd4bf","#4ade80","#9ca3af"],Br=[{level:1,label:"Title"},{level:2,label:"Heading"},{level:3,label:"Subheading"},{level:0,label:"Body"}],Ur=80,zr=48,xn=10,Jr=4,vt=e=>e.stopPropagation();function Gr(e){const n=e.ownerDocument.getSelection();if(!n)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),n.removeAllRanges(),n.addRange(s)}function Kr(e){const n=e.ownerDocument.getSelection();if(!n)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),s.collapse(!1),n.removeAllRanges(),n.addRange(s)}function es({canvas:e,className:n,viewport:s,readOnly:r,zoom:o=1,onChange:a,onSectionDrop:i,onRequestDelete:l}){const[c,u]=d.useState({}),[p,w]=d.useState(null),[f,h]=d.useState(null),[g,x]=d.useState(null),[k,O]=d.useState(null),N=d.useRef(null),M=d.useRef(null),y=d.useRef(null);if(d.useEffect(()=>{if(!p&&!f)return;const m=p?`[data-note-id="${p}"], [data-note-toolbar="${p}"]`:`[data-section-label="${f}"], [data-section-toolbar="${f}"]`,R=I=>{var te,le;const E=I.target;if((te=E==null?void 0:E.closest)!=null&&te.call(E,m))return;const D=document.activeElement;(le=D==null?void 0:D.closest)!=null&&le.call(D,"[data-section-toolbar]")&&D.blur(),w(null),h(null),O(null)};return window.addEventListener("pointerdown",R,!0),()=>window.removeEventListener("pointerdown",R,!0)},[p,f]),!s)return null;const S=!r&&!!a,b=e.sections??[],P=e.notes??[],A=m=>c[m.id]??{x:m.position.x,y:m.position.y,w:m.size.width,h:m.size.height},z=m=>{const R=A(m);return{left:R.x,top:R.y,width:R.w,height:R.h,"--w6w-canvas-color":m.color}},$=(m,R)=>a==null?void 0:a({...e,notes:P.map(I=>I.id===m?{...I,...R}:I)}),_=(m,R)=>a==null?void 0:a({...e,sections:b.map(I=>I.id===m?{...I,...R}:I)}),j=m=>{const R=M.current,I=P.find(D=>D.id===m);if(!(R!=null&&R.isConnected)||!I)return;const E=_r(R);E!==I.content&&$(m,{content:E})},H=m=>{h(null),w(m)},U=m=>{w(null),h(m)},F=(m,R)=>{y.current=R??null,H(m),x(m),O(null)},B=m=>R=>{if(!R||R.dataset.ready==="1")return;R.dataset.ready="1",M.current=R,Fr(R,m.content),R.focus();const I=y.current;y.current=null,I?(Gr(R),I(),j(m.id)):Kr(R)},Y=(m,R,I)=>{var D;O(null);const E=()=>document.execCommand(R,!1,I);g===m&&((D=M.current)!=null&&D.isConnected)?(E(),j(m)):F(m,E)},K=m=>m.mode==="move"?{...m.base,x:m.base.x+m.dx,y:m.base.y+m.dy}:{...m.base,w:Math.max(Ur,m.base.w+m.dx),h:Math.max(zr,m.base.h+m.dy)},X=(m,R,I,E)=>{if(!S||m.button!==0)return;m.stopPropagation(),m.preventDefault();const D={kind:I,id:R.id,mode:E,sx:m.clientX,sy:m.clientY,base:A(R),dx:0,dy:0};N.current=D;const te=oe=>{D.dx=(oe.clientX-D.sx)/(o||1),D.dy=(oe.clientY-D.sy)/(o||1),u(ue=>({...ue,[D.id]:K(D)}))},le=()=>{if(window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",le),N.current=null,u(Re=>{const{[D.id]:pe,...me}=Re;return me}),D.dx===0&&D.dy===0)return;const oe=K(D),ue={position:{x:oe.x,y:oe.y},size:{width:oe.w,height:oe.h}};D.kind==="section"&&D.mode==="move"&&i?i(D.id,{dx:D.dx,dy:D.dy}):D.kind==="note"?$(D.id,ue):_(D.id,ue)};window.addEventListener("pointermove",te),window.addEventListener("pointerup",le)},Z=n?` ${n}`:"",Q="nopan nodrag nowheel",V=S?P.find(m=>m.id===p):void 0,G=S?b.find(m=>m.id===f):void 0,J=o||1,v=m=>{const R=A(m);return{left:R.x+R.w/2,top:R.y,transform:`translate(-50%, calc(-100% - ${xn/J}px)) scale(${1/J})`,transformOrigin:"50% 100%","--w6w-canvas-color":m.color}},C=(m,R)=>{const I=A(m);return{left:I.x,top:I.y,transform:`translate(0, calc(-100% - ${R/J}px)) scale(${1/J})`,transformOrigin:"0 100%","--w6w-canvas-color":m.color}},T=(m,R,I,E)=>t.jsxs("div",{className:"w6w-note-menu w6w-note-menu-colors",role:"menu",children:[Wr.map(D=>t.jsx("button",{type:"button",role:"menuitemradio","aria-checked":D===m,"aria-label":`Colour ${D}`,title:D,className:`w6w-note-swatch-btn${D===m?" active":""}`,style:{"--w6w-canvas-color":D},"data-testid":`${I}-option`,"data-color":D,onClick:()=>{O(null),D!==m&&E(D)}},D)),t.jsx("label",{className:"w6w-note-swatch-btn w6w-note-swatch-custom",title:"Custom",children:t.jsx("input",{type:"color","aria-label":`Custom ${R} colour`,"data-testid":`${I}-input`,value:m,onChange:D=>E(D.currentTarget.value)})})]}),L=m=>{m.target.closest("input")||m.preventDefault()};return Fs.createPortal(t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`w6w-canvas-layer w6w-canvas-sections${Z}`,style:{zIndex:Hr},"data-testid":"w6w-canvas-sections",children:[b.map(m=>t.jsx("div",{className:`w6w-canvas-section${f===m.id?" selected":""}`,style:z(m),"data-section-id":m.id,"data-testid":"section",children:S&&t.jsx("div",{className:`w6w-note-resize ${Q}`,"data-testid":"section-resize",onPointerDown:R=>X(R,m,"section","resize")})},m.id)),b.map(m=>(G==null?void 0:G.id)===m.id?null:t.jsx("div",{className:`w6w-canvas-section-title${S?` editable ${Q}`:""}`,style:C(m,Jr),"data-section-label":m.id,"data-testid":"section-label",title:S?"Click to edit · drag to move":void 0,onPointerDown:S?R=>{U(m.id),X(R,m,"section","move")}:void 0,children:m.title||(S?"Untitled section":"")},m.id))]}),t.jsx("div",{className:`w6w-canvas-layer w6w-canvas-notes${Z}`,style:{zIndex:Vr},"data-testid":"w6w-canvas-notes",children:P.map(m=>{const R=S&&g===m.id;return t.jsxs("div",{className:`w6w-canvas-note${p===m.id?" selected":""}`,style:z(m),"data-note-id":m.id,"data-testid":"note",children:[R?t.jsx("div",{ref:B(m),className:`w6w-canvas-note-body w6w-canvas-note-editor ${Q}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":"true","aria-label":"Note content","data-testid":"note-content",onPointerDown:vt,onBlur:()=>{j(m.id),M.current=null,x(null)},onKeyDown:I=>{I.key==="Escape"&&I.currentTarget.blur()},onPaste:I=>{I.preventDefault(),document.execCommand("insertText",!1,I.clipboardData.getData("text/plain"))}},"editor"):t.jsx("div",{className:`w6w-canvas-note-body ${Q}`,"data-testid":"note-view",style:S?{cursor:"grab",touchAction:"none"}:void 0,onPointerDown:S?I=>{H(m.id),X(I,m,"note","move")}:void 0,onDoubleClick:S?()=>F(m.id):void 0,children:m.content.trim()?t.jsx(Qn,{content:qr(m.content)}):S&&t.jsx("span",{className:"w6w-canvas-note-empty",children:"Double-click to write"})},"view"),S&&t.jsx("div",{className:`w6w-note-resize ${Q}`,"data-testid":"note-resize",onPointerDown:I=>X(I,m,"note","resize")})]},m.id)})}),G&&t.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:bn},"data-testid":"w6w-canvas-overlay",children:t.jsxs("div",{className:`w6w-note-toolbar w6w-section-toolbar ${Q}`,role:"toolbar","aria-label":"Section","data-testid":"section-toolbar","data-section-toolbar":G.id,style:C(G,xn),onPointerDown:vt,onMouseDown:L,children:[t.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-grip","aria-label":"Move section",title:"Drag to move","data-testid":"section-drag",onPointerDown:m=>X(m,G,"section","move"),children:t.jsx(ie.Icon,{name:"grip"})}),t.jsx("input",{type:"text",className:"w6w-section-title-input","aria-label":"Section title",placeholder:"Untitled section","data-testid":"section-title",defaultValue:G.title,size:Math.max(8,Math.min(32,G.title.length+1)),onBlur:m=>{const R=m.currentTarget.value;R!==G.title&&_(G.id,{title:R})},onKeyDown:m=>{(m.key==="Enter"||m.key==="Escape")&&m.currentTarget.blur()}},`${G.id}:${G.title}`),t.jsx("span",{className:"w6w-note-toolbar-sep"}),t.jsxs("div",{className:"w6w-note-toolbar-group",children:[t.jsxs("button",{type:"button",className:`w6w-icon-btn${k==="color"?" active":""}`,"aria-label":"Section colour","aria-expanded":k==="color",title:"Colour","data-testid":"section-color",onClick:()=>O(k==="color"?null:"color"),children:[t.jsx("span",{className:"w6w-note-swatch"}),t.jsx(ie.Icon,{name:"chevron-down",size:12})]}),k==="color"&&T(G.color,"section","section-color",m=>_(G.id,{color:m}))]}),t.jsx("span",{className:"w6w-note-toolbar-sep"}),t.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-delete","aria-label":"Delete section",title:"Delete section","data-testid":"section-delete",onClick:()=>{O(null),l==null||l("section",G.id)},children:t.jsx(ie.Icon,{name:"trash"})})]})}),V&&t.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:bn},"data-testid":"w6w-canvas-overlay",children:t.jsxs("div",{className:`w6w-note-toolbar ${Q}`,role:"toolbar","aria-label":"Note","data-testid":"note-toolbar","data-note-toolbar":V.id,style:v(V),onPointerDown:vt,onMouseDown:L,children:[t.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-grip","aria-label":"Move note",title:"Drag to move","data-testid":"note-drag",onPointerDown:m=>X(m,V,"note","move"),children:t.jsx(ie.Icon,{name:"grip"})}),t.jsx("span",{className:"w6w-note-toolbar-sep"}),t.jsxs("div",{className:"w6w-note-toolbar-group",children:[t.jsxs("button",{type:"button",className:`w6w-icon-btn${k==="color"?" active":""}`,"aria-label":"Note colour","aria-expanded":k==="color",title:"Colour","data-testid":"note-color",onClick:()=>O(k==="color"?null:"color"),children:[t.jsx("span",{className:"w6w-note-swatch"}),t.jsx(ie.Icon,{name:"chevron-down",size:12})]}),k==="color"&&T(V.color,"note","note-color",m=>$(V.id,{color:m}))]}),t.jsx("span",{className:"w6w-note-toolbar-sep"}),t.jsxs("div",{className:"w6w-note-toolbar-group",children:[t.jsxs("button",{type:"button",className:`w6w-icon-btn w6w-note-size-btn${k==="size"?" active":""}`,"aria-label":"Text size","aria-expanded":k==="size",title:"Text size","data-testid":"note-size",onClick:()=>O(k==="size"?null:"size"),children:["Aa",t.jsx(ie.Icon,{name:"chevron-down",size:12})]}),k==="size"&&t.jsx("div",{className:"w6w-note-menu w6w-note-menu-sizes",role:"menu",children:Br.map(m=>t.jsx("button",{type:"button",role:"menuitem",className:`w6w-note-menu-item w6w-note-size-${m.level}`,"data-testid":`note-size-${m.level}`,onClick:()=>Y(V.id,"formatBlock",m.level?`<h${m.level}>`:"<div>"),children:m.label},m.level))})]}),t.jsx("button",{type:"button",className:"w6w-icon-btn","aria-label":"Bold",title:"Bold","data-testid":"note-bold",onClick:()=>Y(V.id,"bold"),children:t.jsx(ie.Icon,{name:"bold"})}),t.jsx("span",{className:"w6w-note-toolbar-sep"}),t.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-delete","aria-label":"Delete note",title:"Delete note","data-testid":"note-delete",onClick:()=>{O(null),l==null||l("note",V.id)},children:t.jsx(ie.Icon,{name:"trash"})})]})})]}),s)}function Yr(e){const n=un.useStore(r=>{var o;return((o=r.domNode)==null?void 0:o.querySelector(".react-flow__viewport"))??null}),s=un.useStore(r=>r.transform[2]);return t.jsx(es,{...e,zoom:e.zoom??s,viewport:n})}function Xr(e){return e.viewport!==void 0?t.jsx(es,{...e,viewport:e.viewport}):t.jsx(Yr,{...e})}const Bt={"&":{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 Zr(){const e=Mn.jsonParseLinter();return n=>n.state.doc.toString().trim()===""?[]:e(n)}function xe(e){const n=tt(e.theme),{copied:s,copy:r}=ie.useCopyToClipboard(e.value),o=d.useMemo(()=>[Mn.json(),pn.linter(Zr()),pn.lintGutter(),Fn.EditorView.theme(Bt)],[]);function a(i){var l,c,u,p;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 w=JSON.parse(i);(c=e.onValidChange)==null||c.call(e,w),(u=e.onValidityChange)==null||u.call(e,{valid:!0})}catch(w){(p=e.onValidityChange)==null||p.call(e,{valid:!1,error:w.message})}}}return t.jsxs("div",{className:"w6w-json-editor","aria-label":e["aria-label"]??"JSON editor",children:[t.jsx(Ln,{value:e.value,onChange:a,extensions:o,placeholder:e.placeholder,readOnly:e.readOnly,editable:!e.readOnly,theme:n,height:e.height,minHeight:e.minHeight??"240px",maxHeight:e.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!e.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),e.overlay,e.copyable&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${s?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void r(),children:s?t.jsx(ie.CheckGlyph,{}):t.jsx(ie.CopyGlyph,{})}),t.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}const Qr={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 ts({value:e,onChange:n,readOnly:s,target:r="step"}){const o=!!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=>n({maxAttempts:a,delayMs:i,backoff:l,...e,...u});return t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"w6w-field",children:[t.jsxs("span",{children:[t.jsx("input",{type:"checkbox",checked:o,disabled:s,onChange:u=>n(u.target.checked?{maxAttempts:a,delayMs:i,backoff:l}:void 0)})," ","Retry on failure"]}),t.jsx("span",{className:"w6w-hint",children:Qr[r]})]}),o&&t.jsxs("div",{className:"w6w-field-row",children:[t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Attempts"}),t.jsx("input",{type:"number",min:1,value:a,readOnly:s,onChange:u=>c({maxAttempts:Math.max(1,Number(u.target.value)||1)})})]}),t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Delay (ms)"}),t.jsx("input",{type:"number",min:0,value:i,readOnly:s,onChange:u=>c({delayMs:Math.max(0,Number(u.target.value)||0)})})]}),t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Backoff"}),t.jsxs("select",{value:l,disabled:s,onChange:u=>c({backoff:u.target.value}),children:[t.jsx("option",{value:"fixed",children:"Fixed"}),t.jsx("option",{value:"exponential",children:"Exponential"})]})]})]})]})}function Ut({config:e,onChange:n,readOnly:s,hasGraph:r=!0,failureHandling:o=!0,retryControls:a=!0,reroute:i}){const l=e.onError??"fail";return t.jsxs("div",{className:"w6w-stack",children:[o&&t.jsxs(t.Fragment,{children:[a&&t.jsx(ts,{value:e.retry,onChange:c=>n({...e,retry:c}),readOnly:s}),t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"On error"}),t.jsxs("select",{value:l,disabled:s,onChange:c=>{const u=c.target.value;n({...e,onError:u==="fail"?void 0:u})},children:[t.jsx("option",{value:"fail",children:"Stop the run (default)"}),t.jsx("option",{value:"continue",children:"Continue to the next step"}),r&&t.jsx("option",{value:"continue-record",children:"Continue to the next step & record the error"})]}),r?t.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, ",t.jsx("strong",{children:"Continue"})," and"," ",t.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"," ",t.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."]}):t.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 ",t.jsx("strong",{children:"reroute"})," target below to send a failure somewhere else instead of stopping."]})]})]}),i&&t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:"Reroute on failure"}),t.jsxs("div",{className:"w6w-field-row",children:[i.picker,i.value&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:s,onClick:()=>i.onChange(void 0),children:"Clear"})]}),t.jsx("span",{className:"w6w-hint",children:"Invoked once, after retry is exhausted, if this step still fails; its output becomes this step's output."})]}),t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Notes"}),t.jsx("textarea",{rows:3,value:e.notes??"",readOnly:s,placeholder:"A short description — shown under this step on the canvas. Not executed.",onChange:c=>n({...e,notes:c.target.value||void 0})})]})]})}function eo(e){switch(e){case"javascript":return Ds.javascript();case"python":return _s.python()}}function ns(e){const n=tt(e.theme),s=d.useMemo(()=>[...e.language?[eo(e.language)]:[],Fn.EditorView.theme(Bt)],[e.language]);return t.jsx("div",{className:"w6w-code-editor","aria-label":e["aria-label"]??"Code editor",children:t.jsx(Ln,{value:e.value,onChange:e.onChange,extensions:s,placeholder:e.placeholder,readOnly:e.readOnly,theme:n,height:e.height,minHeight:e.minHeight??"160px",maxHeight:e.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLine:!e.readOnly,bracketMatching:!0,closeBrackets:!0}})})}function ss(e,n,s){return e*n>.6*s}function rs(e,n){const s=n.trim().toLowerCase();return s?e.filter(r=>r.label.toLowerCase().includes(s)||r.value.toLowerCase().includes(s)):e}const to=240,no={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 nt({options:e,value:n,onChange:s,placeholder:r,disabled:o,"aria-label":a,mode:i="auto",forceSelection:l=!0,optionHeight:c=32,listMaxHeight:u=to,className:p}){var U;const w=i==="combobox"||i==="auto"&&ss(e.length,c,typeof window>"u"?0:window.innerHeight),f=d.useId(),h=((U=e.find(F=>F.value===n))==null?void 0:U.label)??(l?"":n),[g,x]=d.useState(h),[k,O]=d.useState(!1),[N,M]=d.useState(!1),[y,S]=d.useState(0),b=d.useRef(null);d.useEffect(()=>{x(h)},[h]);const P=d.useMemo(()=>N?rs(e,g):e,[e,g,N]),A=d.useMemo(()=>({...no,maxHeight:u}),[u]);if(!w)return t.jsxs("select",{className:p,value:n,disabled:o,"aria-label":a,onChange:F=>s(F.target.value),children:[r!==void 0&&n===""&&t.jsx("option",{value:"",disabled:!0,children:r}),e.map(F=>t.jsx("option",{value:F.value,children:F.label},F.value))]});const z=F=>`${f}-opt-${F}`,$=()=>{O(!1),M(!1)},_=F=>{x(F.label),s(F.value),$()},j=F=>{F.key==="ArrowDown"?(F.preventDefault(),k?S(B=>Math.min(B+1,P.length-1)):O(!0)):F.key==="ArrowUp"?(F.preventDefault(),k?S(B=>Math.max(B-1,0)):O(!0)):F.key==="Enter"?k&&P[y]?(F.preventDefault(),_(P[y])):l||(g!==h&&s(g),$()):F.key==="Escape"&&(k&&F.stopPropagation(),x(h),$())},H=()=>{l?x(h):g!==h&&s(g),$()};return t.jsxs("div",{ref:b,style:{position:"relative"},children:[t.jsx("input",{type:"text",role:"combobox",className:p,value:g,disabled:o,placeholder:r,"aria-label":a,"aria-expanded":k,"aria-controls":`${f}-list`,"aria-autocomplete":"list","aria-activedescendant":k&&P[y]?z(y):void 0,autoComplete:"off",onFocus:()=>O(!0),onChange:F=>{x(F.target.value),M(!0),S(0),O(!0)},onKeyDown:j,onBlur:H}),k&&t.jsxs("div",{id:`${f}-list`,role:"listbox",tabIndex:-1,"aria-label":a,style:A,children:[P.map((F,B)=>t.jsx("div",{id:z(B),role:"option",tabIndex:-1,"aria-selected":F.value===n,style:{padding:"6px 8px",cursor:"pointer",borderRadius:4,background:B===y?"var(--w6w-panel-2)":void 0},onMouseDown:Y=>{Y.preventDefault(),_(F)},onMouseEnter:()=>S(B),children:F.label},F.value)),P.length===0&&t.jsx("div",{role:"presentation",style:{padding:"6px 8px",opacity:.6},children:"No matches"})]})]})}const zt=d.forwardRef(function(n,s){const{label:r,children:o,icon:a,iconSize:i,title:l,onClick:c,disabled:u,className:p,danger:w,...f}=n,h=o??(a?t.jsx(ie.Icon,{name:a,size:i??16}):null);return t.jsx("button",{ref:s,type:"button",className:["w6w-icon-button",w?"w6w-icon-button-danger":"",p??""].filter(Boolean).join(" "),title:l??r,"aria-label":r,"aria-pressed":f["aria-pressed"],"aria-expanded":f["aria-expanded"],"aria-controls":f["aria-controls"],disabled:u,onClick:c,"data-testid":f["data-testid"],children:h})});zt.displayName="IconButton";function st(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.source==="resolveFields"}function _e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.type==="expr"&&Array.isArray(e.parts)}function rt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.type==="secret"&&typeof e.ciphertext=="string"&&typeof e.iv=="string"}function so(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 Fe(e){const n=e.filter(s=>s.kind!=="text"||(s.value??"")!=="");return n.length===0?"":n.length===1&&n[0].kind==="text"?n[0].value??"":{type:"expr",parts:n.map(so)}}const os={vars:!0,steps:!0,nodes:!0,trigger:!0,foreach:!0,inputs:!0,output:!0,secrets:!0,documents:!0};Object.freeze(Object.keys(os));const yn=e=>Object.prototype.hasOwnProperty.call(os,e);function vn(e){const n=e.indexOf(".");return n===-1?e:e.slice(0,n)}function Je(e){const n=fe.parseTemplate(e);return n.every(r=>{if(r.kind==="var"){const o=r.ref??"";return!fe.hasRefusedChainToken(o)&&yn(vn(o))}if(r.kind==="expr"){const o=fe.coalesceOperandRefs(r.expr);return o===null?!0:o.every(a=>yn(vn(a)))}return!0})?n:[{kind:"text",value:e}]}function Ct(e){if(rt(e))return{parts:[],sealed:e};if(_e(e))return{parts:e.parts.map(s=>({...s})),sealed:null};const n=typeof e=="string"?e:"";return{parts:n?Je(n):[],sealed:null}}function ro(e,n){let s="";for(const r of e)switch(r.kind){case"text":s+=r.value??"";break;case"var":case"render":{const o=r.ref??"";s+=o in n?n[o]:"";break}case"secret":s+="•••";break;case"expr":s+=fe.serializeTemplate([r]);break}return s}const oo=/^(?:nodes|steps)\.([^.]+)\.output(?:\.(.+))?$/,ao=/^(?:nodes|steps)\.([^.]+)\.meta\.(app|version|action|connectionId)$/,Ae=e=>{if(e.startsWith("vars."))return e.slice(5);const n=oo.exec(e);if(n)return n[2]?`${n[1]}.${n[2]}`:n[1];const s=ao.exec(e);return s?`${s[1]} meta · ${s[2]}`:e};function io(e){if(e===null||typeof e!="object"||Array.isArray(e))return;const n=Object.keys(e);if(n.length!==1||n[0]!=="var")return;const s=e.var;return typeof s=="string"?s:void 0}function lo(e){const n=e.op==="or"?"||":"??",s=e.operands.map(r=>{const o=io(r);return o!==void 0?Ae(o):JSON.stringify(r)}).join(` ${n} `);return s.length>40?`${s.slice(0,40)}…`:s}const co=/[.{}]/;function St(e){return e===""||e!==e.trim()?!1:!co.test(e)}function uo(e){return e.split(".").every(St)}function Le(e,n,{renderToggle:s}={}){const r=e.createElement("span");r.contentEditable="false",r.className=`w6w-expr-chip w6w-expr-chip-${n.kind}`,r.setAttribute("data-kind",n.kind);const o=e.createElement("span");o.className="w6w-expr-chip-sigil";const a=e.createElement("span");if(a.className="w6w-expr-chip-label",n.kind==="var")r.setAttribute("data-ref",n.ref??""),o.textContent="◆",a.textContent=Ae(n.ref??""),r.title=`Variable: ${n.ref??""}`;else if(n.kind==="render")r.setAttribute("data-ref",n.ref??""),o.textContent="▤",a.textContent=Ae(n.ref??""),r.title=`Render as template: ${n.ref??""}`;else if(n.kind==="secret")r.setAttribute("data-ref",n.ref??""),o.textContent="🔒",a.textContent=n.ref??"",r.title=`Secret: ${n.ref??""}`;else{const l=typeof n.expr=="string"?n.expr:JSON.stringify(n.expr??"");r.setAttribute("data-expr",l),o.textContent="ƒ";const c=fe.parseCoalesceChain(n.expr);c?(a.textContent=lo(c),r.title=`Expression: ${fe.serializeTemplate([n])}`):(a.textContent=l.length>24?`${l.slice(0,24)}…`:l||"expr",r.title=`Expression: ${l}`)}if(r.append(o,a),(n.kind==="var"||n.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=n.kind==="render"?"Stop rendering as a template":"Render this as a template";l.setAttribute("aria-label",c),l.title=c,l.textContent="⇄",r.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="×",r.append(i),r}const as=new Set(["div","p"]);function is(e){const n=e.getAttribute("data-kind");if(n==="var"||n==="secret"||n==="render")return{kind:n,ref:e.getAttribute("data-ref")??""};if(n==="expr"){const s=e.getAttribute("data-expr")??"";let r=s;try{r=JSON.parse(s)}catch{r=s}return{kind:"expr",expr:r}}return null}function $e(e){const n=[],s=a=>{if(!a)return;const i=n[n.length-1];i&&i.kind==="text"?i.value=(i.value??"")+a:n.push({kind:"text",value:a})},r=(a,i)=>{if(a.nodeType===Node.TEXT_NODE){s(a.textContent??"");return}if(a.nodeType!==Node.ELEMENT_NODE)return;const l=a,c=is(l);if(c){n.push(c);return}const u=(l.tagName??"").toLowerCase();if(u==="br"){i||s(`
|
|
6
|
+
`);return}const p=as.has(u);p&&n.length>0&&s(`
|
|
7
|
+
`),o(l,p)},o=(a,i)=>{const l=Array.from(a.childNodes);l.forEach((c,u)=>r(c,i&&u===l.length-1))};return o(e,!0),n}const ls=e=>!!e&&(e.tagName??"").toLowerCase()==="br";function cs(e){ls(e.lastChild)||e.appendChild(e.ownerDocument.createElement("br"))}function po(e){const n=e.ownerDocument.getSelection(),s=n!=null&&n.rangeCount?n.getRangeAt(0):null;if(!s||!e.contains(s.endContainer))return e;let r=s.endContainer;for(;r&&r!==e;){if(r.nodeType===Node.ELEMENT_NODE){const o=r;if(as.has((o.tagName??"").toLowerCase()))return o}r=r.parentNode}return e}function ds(e){cs(po(e))}const wo=e=>e.getAttribute("aria-multiline")!=="false";function us(e,n,s){var a;const r=e.ownerDocument;e.textContent="";for(const i of n)i.kind==="text"?i.value&&e.appendChild(r.createTextNode(i.value)):e.appendChild(Le(r,i,s));const o=n[n.length-1];(o==null?void 0:o.kind)==="text"&&((a=o.value)!=null&&a.endsWith(`
|
|
8
|
+
`))&&wo(e)&&cs(e)}function Jt(e){const n=e.ownerDocument.getSelection();if(!n)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),s.collapse(!1),n.removeAllRanges(),n.addRange(s)}function Me(e,n){const s=e.ownerDocument,r=s.getSelection(),o=r!=null&&r.rangeCount?r.getRangeAt(0):null;if(o&&e.contains(o.commonAncestorContainer)){o.deleteContents(),o.insertNode(n);const a=s.createRange();a.setStartAfter(n),a.collapse(!0),r==null||r.removeAllRanges(),r==null||r.addRange(a)}else ls(e.lastChild)?e.insertBefore(n,e.lastChild):e.appendChild(n),Jt(e);e.focus()}function ps(e,n={}){const s=e.ownerDocument,r=s.getSelection();if(!r||r.rangeCount===0||!r.isCollapsed)return!1;const o=r.getRangeAt(0),a=o.startContainer;if(a.nodeType!==Node.TEXT_NODE||!e.contains(a))return!1;const i=o.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),p=Je(u);if(p.length!==1||p[0].kind==="text")return!1;const w=s.createRange();w.setStart(a,c),w.setEnd(a,i),w.deleteContents();const f=Le(s,p[0],n);w.insertNode(f);const h=s.createRange();return h.setStartAfter(f),h.collapse(!0),r.removeAllRanges(),r.addRange(h),!0}function ws(e){const n=is(e);if(!n)return null;const s=e.ownerDocument.createTextNode(fe.serializeTemplate([n]));return e.replaceWith(s),s}function Gt({value:e,masked:n,multiline:s,options:r,fieldLabel:o,onSave:a,onClose:i,mode:l,onBind:c}){const u=l==="json-binding",[p,w]=d.useState(()=>Ct(e).parts),[f,h]=d.useState(0),g=d.useRef(null),x=d.useRef(!1),[k,O]=d.useState({}),[N,M]=d.useState(null),[y,S]=d.useState(()=>new Set),b=v=>{S(C=>{const T=new Set(C);return T.has(v)?T.delete(v):T.add(v),T})};d.useLayoutEffect(()=>{const v=g.current;v&&(us(v,p,{renderToggle:!0}),x.current&&(x.current=!1,Jt(v),v.focus()))},[f]);const P=()=>{const v=g.current;v&&w($e(v))},A=v=>{const C=g.current;C&&(Me(C,Le(C.ownerDocument,v,{renderToggle:!0})),w($e(C)))},z=p.some(v=>v.kind==="render"),$=(v,{restoreFocus:C})=>{w(Je(v)),h(T=>T+1)},_=()=>{const v=g.current;a==null||a(Fe(v?$e(v):p)),i()},j=v=>{u?c==null||c({$:v.ref??""}):a==null||a(Fe([v])),i()},H=()=>{M(null),x.current=!0,h(v=>v+1)},U=r.vars??[],F=r.secrets??[],B=r.inputs??[],Y=r.documents??[],K=r.steps??[],X=K.length>0||!!r.hasTrigger,Z=fe.serializeTemplate(p),Q=d.useMemo(()=>{const v={};for(const[C,T]of Object.entries(r.sampleValues??{}))v[C]=typeof T=="string"?T:JSON.stringify(T);return{...v,...k}},[r.sampleValues,k]),V=d.useMemo(()=>{const v=new Set,C=[];for(const T of p)(T.kind==="var"||T.kind==="render")&&T.ref&&!v.has(T.ref)&&(v.add(T.ref),C.push(T.ref));return C},[p]),G=d.useMemo(()=>{try{return ro(p,Q)}catch{return Z}},[p,Q,Z]),J=(v,C,T,L,m=!1,R)=>t.jsxs("div",{className:"w6w-exprmodal-item",style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[t.jsxs("button",{type:"button",className:`w6w-exprmodal-source ${T}`,style:{flex:1,minWidth:0},title:m?`Insert ${v}`:`Use ${v}`,"aria-label":R,onClick:()=>m?A(C):j(C),children:[L!==null&&t.jsx("span",{className:"w6w-expr-chip-sigil",children:L}),t.jsx("span",{className:"w6w-exprmodal-source-label",children:v})]}),!u&&t.jsx(zt,{icon:"copy",iconSize:14,label:"Copy to expression editor","data-testid":"expr-copy-to-editor",onClick:()=>A(C)})]},`${C.kind}:${C.ref??v}`);return t.jsxs(de,{title:u?"Bind to a step output":"Edit expression",subtitle:o?t.jsx("code",{children:o}):void 0,onClose:i,size:"full",headerRight:u?t.jsx("div",{className:"w6w-exprmodal-actions",children:t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:"Cancel"})}):t.jsxs("div",{className:"w6w-exprmodal-actions",children:[!n&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:z,title:z?"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(fe.serializeTemplate(p)),i()},children:"Use a plain value"}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:"Cancel"}),t.jsx("button",{type:"button",className:"w6w-btn",onClick:_,children:"Save"})]}),children:[t.jsxs("div",{className:"w6w-exprmodal",style:u?{gridTemplateColumns:"1fr"}:void 0,children:[t.jsxs("aside",{className:"w6w-exprmodal-sources",children:[u&&!X&&t.jsx("span",{className:"w6w-expr-menu-empty",children:"No upstream steps"}),X&&t.jsxs("div",{className:"w6w-exprmodal-group",children:[t.jsx("span",{className:"w6w-exprmodal-group-label",children:"Workflow state"}),r.hasTrigger&&J("trigger.event",{kind:"var",ref:"trigger.event"},"w6w-expr-chip-var","⚡"),K.map(v=>{const C=I=>{const E=y.has(`meta:${I}`);return t.jsxs("button",{type:"button",className:"w6w-exprmodal-toggle-btn","data-testid":"expr-meta-toggle","aria-expanded":E,title:E?"Hide metadata":"Show metadata",onClick:()=>b(`meta:${I}`),children:["Metadata ",E?"⌄":"›"]})},T=(v.outputs??[]).filter(I=>I.path?uo(I.key):St(I.key)),L=`step:${v.id}`,m=y.has(L),R=J(v.label??v.id,{kind:"var",ref:`nodes.${v.id}.output`},"w6w-expr-chip-var",T.length>0?null:"▸",T.length>0);return u?t.jsxs(d.Fragment,{children:[t.jsx("span",{className:"w6w-exprmodal-shape-note",children:v.label??v.id}),J("Entire output",{kind:"var",ref:`nodes.${v.id}.output`},"w6w-expr-chip-var","▸",!1,`Entire output of ${v.label??v.id}`),v.needsTest&&t.jsx("div",{className:"w6w-exprmodal-subsources",children:t.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-needs-test",children:"Run a test of this step to see its fields"})}),T.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w6w-exprmodal-source-row",children:[t.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-caret-fields","aria-expanded":m,"aria-label":m?"Hide fields":"Show fields",title:m?"Hide fields":"Show fields",onClick:()=>b(L),children:m?"▾":"▸"}),t.jsx(jt,{count:T.length,open:m,onToggle:()=>b(L)})]}),m&&t.jsx("div",{className:"w6w-exprmodal-subsources",children:T.map(I=>{const E=`nodes.${v.id}.output.${I.key}`;return J(Ae(E),{kind:"var",ref:E},"w6w-expr-chip-var","·")})})]})]},v.id):t.jsxs(d.Fragment,{children:[T.length>0?t.jsxs("div",{className:"w6w-exprmodal-source-row",children:[t.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-caret-fields","aria-expanded":m,"aria-label":m?"Hide fields":"Show fields",title:m?"Hide fields":"Show fields",onClick:()=>b(L),children:m?"▾":"▸"}),R,t.jsxs("div",{className:"w6w-exprmodal-toggle-stack",children:[t.jsx(jt,{count:T.length,open:m,onToggle:()=>b(L)}),v.hasMeta===!0&&C(v.id)]})]}):R,v.needsTest&&t.jsx("div",{className:"w6w-exprmodal-subsources",children:t.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-needs-test",children:"Run a test of this step to see its fields"})}),T.length>0&&m&&t.jsxs("div",{className:"w6w-exprmodal-subsources",children:[v.outputsFrom==="test"&&t.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-fields-from-test",children:"Fields from the last test run"}),T.map(I=>{const E=`nodes.${v.id}.output.${I.key}`;return J(Ae(E),{kind:"var",ref:E},"w6w-expr-chip-var","·")})]}),v.hasMeta===!0&&t.jsxs(t.Fragment,{children:[T.length===0&&t.jsx("div",{className:"w6w-exprmodal-source-row w6w-exprmodal-meta-row",children:C(v.id)}),y.has(`meta:${v.id}`)&&t.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-meta-fields",children:ho.map(([I,E])=>J(E,{kind:"var",ref:`nodes.${v.id}.meta.${I}`},"w6w-expr-chip-var","·"))})]})]},v.id)})]}),!u&&t.jsxs(t.Fragment,{children:[r.inputs!==void 0&&t.jsxs("div",{className:"w6w-exprmodal-group",children:[t.jsx("span",{className:"w6w-exprmodal-group-label",children:"Inputs"}),B.length===0&&t.jsx("span",{className:"w6w-expr-menu-empty",children:"No inputs"}),B.map(v=>J(v,{kind:"var",ref:`inputs.${v}`},"w6w-expr-chip-var","⇥"))]}),t.jsxs("div",{className:"w6w-exprmodal-group",children:[t.jsxs("div",{className:"w6w-field-labelrow",children:[t.jsx("span",{className:"w6w-exprmodal-group-label",children:"Variables"}),r.createVar&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-var",onClick:()=>M("var"),children:"+ Add"})]}),U.length===0&&t.jsx("span",{className:"w6w-expr-menu-empty",children:"No variables"}),U.map(v=>J(v,{kind:"var",ref:`vars.${v}`},"w6w-expr-chip-var","◆"))]}),t.jsxs("div",{className:"w6w-exprmodal-group",children:[t.jsx("span",{className:"w6w-exprmodal-group-label",children:"Documents"}),Y.length===0&&t.jsx("span",{className:"w6w-expr-menu-empty",children:"No documents"}),Y.map(v=>{const C=(v.fields??[]).filter(R=>St(R.key)),T=`doc:${v.key}`,L=y.has(T),m=J(v.key,{kind:"var",ref:`documents.${v.key}`},"w6w-expr-chip-var","▦",C.length>0);return t.jsxs(d.Fragment,{children:[C.length>0?t.jsxs("div",{className:"w6w-exprmodal-source-row",children:[m,t.jsx(jt,{count:C.length,open:L,onToggle:()=>b(T)})]}):m,C.length>0&&L&&t.jsx("div",{className:"w6w-exprmodal-subsources",children:C.map(R=>{const I=`documents.${v.key}.${R.key}`;return t.jsxs("div",{className:"w6w-exprmodal-subsource-row",children:[J(R.key,{kind:"var",ref:I},"w6w-expr-chip-var","·"),t.jsx("button",{type:"button",className:"w6w-exprmodal-render-btn","data-testid":"expr-insert-render",title:`Insert ${I} and render its {{ }} placeholders`,"aria-label":`Insert ${I} and render its {{ }} placeholders`,onClick:()=>A({kind:"render",ref:I}),children:"▤"})]},I)})})]},v.key)})]}),t.jsxs("div",{className:"w6w-exprmodal-group",children:[t.jsxs("div",{className:"w6w-field-labelrow",children:[t.jsx("span",{className:"w6w-exprmodal-group-label",children:"Secrets"}),r.createSecret&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-secret",onClick:()=>M("secret"),children:"+ Add"})]}),F.length===0&&t.jsx("span",{className:"w6w-expr-menu-empty",children:"No secrets"}),F.map(v=>J(v,{kind:"secret",ref:v},"w6w-expr-chip-secret","🔒"))]})]})]}),!u&&t.jsxs("div",{className:"w6w-exprmodal-main",children:[t.jsxs("div",{className:"w6w-exprmodal-editor",children:[t.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Expression",t.jsx("span",{className:"w6w-muted w6w-small",children:" — click a source on the left, or type"})]}),t.jsx("div",{ref:g,className:`w6w-exprmodal-chips${n?" is-masked":""}${p.length===0?" is-empty":""}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":s?"true":"false","aria-label":"Expression","data-placeholder":"Type text and insert {x} variables, 🔒 secrets, or ▸ step outputs…",spellCheck:!1,onInput:()=>{const v=g.current;v&&ps(v,{renderToggle:!0}),P()},onDoubleClick:v=>{const C=v.target;if(C.closest("[data-x]")||C.closest("[data-render-toggle]"))return;const T=C.closest(".w6w-expr-chip");if(!T)return;v.preventDefault();const L=ws(T);if(L){const m=L.ownerDocument,R=m.createRange();R.setStartAfter(L),R.collapse(!0);const I=m.getSelection();I==null||I.removeAllRanges(),I==null||I.addRange(R)}P()},onBlur:()=>{const v=g.current;v&&$(fe.serializeTemplate($e(v)),{restoreFocus:!1})},onPaste:v=>{var L;v.preventDefault();const C=g.current;if(!C)return;const T=((L=v.clipboardData)==null?void 0:L.getData("text/plain"))??"";for(const m of Je(T))m.kind==="text"?Me(C,C.ownerDocument.createTextNode(m.value??"")):Me(C,Le(C.ownerDocument,m,{renderToggle:!0}));P()},onClick:v=>{var m;const C=v.target,T=C.closest("[data-x]");if(T){v.preventDefault(),(m=T.closest(".w6w-expr-chip"))==null||m.remove(),P();return}const L=C.closest("[data-render-toggle]");if(L){v.preventDefault();const R=L.closest(".w6w-expr-chip");if(R){const I=R.getAttribute("data-ref")??"",E=R.getAttribute("data-kind")==="render"?"var":"render";R.replaceWith(Le(R.ownerDocument,{kind:E,ref:I},{renderToggle:!0}))}P()}},onKeyDown:v=>{if(v.key!=="Enter"||(v.preventDefault(),!s))return;const C=g.current;C&&(Me(C,C.ownerDocument.createTextNode(`
|
|
9
|
+
`)),ds(C),P())}})]}),V.length>0&&t.jsxs("div",{className:"w6w-exprmodal-preview",children:[t.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Sample values",t.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— try the expression against example data"]})]}),V.map(v=>t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:v}),t.jsx("input",{type:"text",value:k[v]??"",placeholder:"sample value",onChange:C=>O(T=>({...T,[v]:C.target.value}))})]},v))]}),t.jsxs("div",{className:"w6w-exprmodal-preview w6w-exprmodal-result-pane",children:[t.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Result",t.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— live preview against the sample values"]})]}),t.jsx(ie.Copyable,{value:G,readOnly:!0,children:t.jsx("pre",{className:"w6w-exprmodal-result",children:G||" "})})]})]})]}),N==="var"&&r.createVar&&t.jsx(jn,{kind:"var",onCreate:r.createVar,onClose:H}),N==="secret"&&r.createSecret&&t.jsx(jn,{kind:"secret",onCreate:r.createSecret,onClose:H})]})}function jt({count:e,open:n,onToggle:s}){return t.jsxs("button",{type:"button",className:"w6w-exprmodal-toggle-btn","data-testid":"expr-toggle-fields","aria-expanded":n,title:n?"Hide fields":"Show fields",onClick:s,children:[e," ",e===1?"field":"fields"," ",n?"⌄":"›"]})}const ho=[["app","App"],["version","App version"],["action","Action"],["connectionId","Connection ID"]];function jn({kind:e,onCreate:n,onClose:s}){const[r,o]=d.useState(""),[a,i]=d.useState(""),[l,c]=d.useState(""),[u,p]=d.useState(null),[w,f]=d.useState(!1),h=e==="var"?"variable":"secret";async function g(){p(null),f(!0);try{await n({name:r,value:a,description:l||void 0}),s()}catch(x){p(x.message)}finally{f(!1)}}return t.jsxs(de,{title:`Add ${h}`,onClose:s,children:[t.jsx("div",{className:"w6w-modal-body",children:t.jsxs("div",{className:"w6w-stack",children:[t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Name"}),t.jsx("input",{type:"text",value:r,onChange:x=>o(x.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}),t.jsx("span",{className:"w6w-muted w6w-small",children:"Letters, digits, and underscores. Must start with a letter or underscore. Case-sensitive."})]}),t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Value"}),t.jsx("input",{type:e==="secret"?"password":"text",value:a,onChange:x=>i(x.target.value),autoComplete:"off","data-testid":"expr-add-value-value"}),e==="secret"&&t.jsx("span",{className:"w6w-muted w6w-small",children:"Stored encrypted at rest. Once saved, it is not readable through the UI."})]}),t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Description"}),t.jsx("input",{type:"text",value:l,onChange:x=>c(x.target.value),placeholder:"Optional",autoComplete:"off"})]}),u&&t.jsx("div",{className:"w6w-result w6w-error",children:u})]})}),t.jsxs("div",{className:"w6w-modal-actions",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"expr-add-value-cancel",onClick:s,children:"Cancel"}),t.jsx("button",{type:"button",className:"w6w-btn","data-testid":"expr-add-value-save",disabled:!r||!a||w,onClick:g,children:w?"Saving…":"Save"})]})]})}function fo(e,n){return n?e.filter(s=>s.id!==n):e}const At=d.createContext({});function mo({value:e,children:n}){const s=d.useContext(At),r=d.useMemo(()=>({...s,...e}),[s,e]);return t.jsx(At.Provider,{value:r,children:n})}function ot(){return d.useContext(At)}function Kt({value:e,onChange:n,placeholder:s,masked:r,multiline:o,readOnly:a,options:i,"aria-label":l}){const[c,u]=d.useState(()=>Ct(e)),{parts:p,sealed:w}=c,[f,h]=d.useState(0),[g,x]=d.useState(!1),[k,O]=d.useState(!1),N=d.useRef(!1),M=d.useRef(null),y=d.useRef(null),S=ot(),b={...S,...i??{}},P=S.sealSecret;d.useLayoutEffect(()=>{const j=M.current;!j||w||(us(j,p),(N.current||j.ownerDocument.activeElement===j)&&(j.focus(),Jt(j),N.current=!1))},[f,w]);const A=()=>{const j=M.current;if(!j)return;const H=$e(j);u(U=>({...U,parts:H})),n(Fe(H))},z=async j=>{if(!P)return!1;x(!0);try{const H=await P(j);return N.current=!1,u({parts:[],sealed:H}),h(U=>U+1),n(H),!0}catch{return!1}finally{x(!1)}},$=j=>{var F;if(k||!r||a||g)return;const H=j.relatedTarget;if(H&&((F=y.current)!=null&&F.contains(H)))return;const U=Fe(p);typeof U=="string"&&U!==""&&z(U)},_=j=>{if(r&&typeof j=="string"&&j.trim()!==""){z(j);return}N.current=!1,u(Ct(j)),h(H=>H+1),n(j)};return w?t.jsxs("div",{className:`w6w-expr-sealed${a?" is-readonly":""}`,"aria-label":l,children:[t.jsxs("span",{className:"w6w-expr-chip w6w-expr-chip-secret",title:"Encrypted secret",children:[t.jsx("span",{className:"w6w-expr-chip-sigil",children:"🔒"}),t.jsx("span",{className:"w6w-expr-chip-label",children:"••••••"})]}),!a&&t.jsx("button",{type:"button",className:"w6w-expr-replace",onClick:()=>{N.current=!0,u({parts:[],sealed:null}),h(j=>j+1),n("")},children:"Replace"})]}):t.jsxs("div",{className:"w6w-expr",ref:y,onBlur:$,children:[t.jsxs("div",{className:"w6w-expr-field",children:[t.jsx("div",{ref:M,className:`w6w-expr-editor${r?" is-masked":""}${p.length===0?" is-empty":""}${a?" is-readonly":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox",tabIndex:a?-1:0,"aria-multiline":o?"true":"false","aria-label":l,"data-placeholder":s??"",spellCheck:!1,onInput:()=>{const j=M.current;j&&ps(j),A()},onClick:j=>{var U;const H=j.target.closest("[data-x]");H&&(j.preventDefault(),(U=H.closest(".w6w-expr-chip"))==null||U.remove(),A())},onDoubleClick:j=>{const H=j.target;if(H.closest("[data-x]"))return;const U=H.closest(".w6w-expr-chip");if(!U)return;j.preventDefault();const F=ws(U);if(F){const B=F.ownerDocument,Y=B.createRange();Y.setStartAfter(F),Y.collapse(!0);const K=B.getSelection();K==null||K.removeAllRanges(),K==null||K.addRange(Y)}A()},onKeyDown:j=>{if(j.key!=="Enter"||(j.preventDefault(),!o))return;const H=M.current;H&&(Me(H,H.ownerDocument.createTextNode(`
|
|
10
|
+
`)),ds(H),A())}}),!a&&t.jsx("button",{type:"button",className:"w6w-expr-edit",title:"Edit expression — browse variables, secrets & step outputs","aria-label":"Edit expression",onClick:()=>O(!0),children:"ƒx"})]}),k&&t.jsx(Gt,{value:Fe(p),masked:r,multiline:o,options:b,fieldLabel:l,onSave:_,onClose:()=>O(!1)})]})}function at(e){const n=[];for(const s of e)n.push(s),s.type==="section"&&s.children&&n.push(...at(s.children));return n}function hs(e){return _e(e)||rt(e)?!0:typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"$")}function Ge(e){var n;return((n=e.config)==null?void 0:n.allowCustom)===!0}function Et(e){return at(e).filter(n=>st(n.options))}function Yt(e){return st(e.options)?e.options.refreshOn??[]:[]}function Tt(e,n){const s={},r=[];for(const o of at(e)){if(o.type==="section")continue;const a=n[o.key]!==void 0?n[o.key]:o.default;a!==void 0&&(hs(a)?r.push(o.key):s[o.key]=a)}return{form:s,unresolved:r}}function go(e,n,s,r,o){const{form:a,unresolved:i}=Tt(e,n),l=new Set(i),c=Et(e).filter(p=>{const w=Yt(p);return s==="change"&&!(r??[]).some(f=>w.includes(f))?!1:w.every(f=>!l.has(f))}).map(p=>p.key);if(c.length===0)return null;const u={reason:s,form:a,fields:c,unresolved:i};return s==="change"&&(u.changed=[...r??[]],u.previous=Tt(e,o??{}).form),u}function Nn(e,n,s){return JSON.stringify([e.appId,e.version??null,e.actionKey,e.connectionId??null,n.key,Yt(n).map(r=>s[r]??null)])}function kn(e){return!(st(e.options)&&e.options.cache==="none")}function bo(e,n){return e.some(s=>n.includes(s))}function xo(e,n,s,r){var l;if(!r.connectionId)return{reason:"no-connection",hint:"Connect an account to load choices"};const o=new Set(Tt(n,s).unresolved),a=Yt(e).find(c=>o.has(c));return a===void 0?null:{reason:"unresolved-dependency",hint:`Options unavailable while ${((l=at(n).find(c=>c.key===a))==null?void 0:l.label)??a} is an expression`}}function Cn(e,n,s){return e==null||e===""?{action:"keep"}:hs(e)?{action:"keep"}:n.some(r=>r.value===e||String(r.value)===String(e))?{action:"keep"}:s.reason==="change"&&!s.allowCustom?{action:"clear"}:{action:"flag",message:`Not in the list returned by ${s.appLabel}`}}const It="vars.",Rt="documents.";function fs(e,n){const s={},r={};for(const[a,i]of Object.entries(e??{}))a.startsWith(It)?s[a.slice(It.length)]=i:a.startsWith(Rt)&&(r[a.slice(Rt.length)]=i);const o=(n==null?void 0:n.steps)??{};return{vars:s,documents:r,steps:o,nodes:o,trigger:(n==null?void 0:n.trigger)??{},flat:e??{}}}function yo(e,n){const s=n.split(".");let r=e;for(const o of s){if(r===null||typeof r!="object")return{present:!1,value:void 0};if(!(o in r))return{present:!1,value:void 0};r=r[o]}return{present:!0,value:r}}function ms(e,n){if(n.flat&&(e.startsWith(It)||e.startsWith(Rt))&&Object.hasOwn(n.flat,e))return{status:"resolved",ref:e,value:n.flat[e]};const s=n,r=yo(e.startsWith("nodes.")&&!n.nodes?{...s,nodes:n.steps}:s,e);return r.present?{status:"resolved",ref:e,value:r.value}:{status:"unresolved",ref:e}}function vo(e,n){switch(e.kind){case"text":return{status:"resolved",value:e.value??""};case"var":return ms(e.ref??"",n);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 gs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$"in e}function jo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$expr"in e}function bs(e,n){return rt(e)?[{status:"masked"}]:_e(e)?e.parts.map(s=>vo(s,n)):gs(e)?[ms(String(e.$),n)]:jo(e)?[{status:"not-evaluated"}]:[{status:"resolved",value:e}]}function Pt(e,n){if(e===n)return!0;if(typeof e!=typeof n||e===null||n===null||typeof e!="object")return!1;const s=Array.isArray(e),r=Array.isArray(n);if(s!==r)return!1;if(s){const c=e,u=n;return c.length===u.length&&c.every((p,w)=>Pt(p,u[w]))}const o=e,a=n,i=Object.keys(o),l=Object.keys(a);return i.length===l.length&&i.every(c=>c in a&&Pt(o[c],a[c]))}function xs(e){switch(e.status){case"resolved":return e.value===void 0?"<not set>":e.value;case"unresolved":return`<unresolved: ${e.ref}>`;case"not-evaluated":return"<not evaluated>";case"masked":return e.ref?`<masked: ${e.ref}>`:"<masked>"}}function No(e){return e.status==="resolved"&&e.value!==void 0?typeof e.value=="string"?e.value:JSON.stringify(e.value):String(xs(e))}function ko(e){return e.length===1?xs(e[0]):e.map(No).join("")}function Xt(e,n){return ko(bs(e,n))}function Co(e,n){const s={};for(const r of e)s[r.key||"(no key)"]=Xt(r.value,n);return s}function So(e,n,s,r){var M;const o=(M=Un())==null?void 0:M.resolveActionFields,a=!!(s&&o),[i,l]=d.useState({}),c=d.useRef({params:e,values:n,dynamic:s,onChange:r,resolve:o});c.current={params:e,values:n,dynamic:s,onChange:r,resolve:o};const u=d.useRef(new Map),p=d.useRef([]),w=d.useCallback((y,S,b,P,A)=>{const{params:z,values:$,dynamic:_,resolve:j}=c.current,H=A??$;if(!_||!j||!_.connectionId)return;const U=go(z,H,y,S,b);if(!U)return;const F=new Map(Et(z).map(C=>[C.key,C])),B=[],Y={},K=[],X=_.appName??_.appId,Z=(C,T)=>{const L=F.get(C);if(!L)return;Cn(H[C],T,{allowCustom:Ge(L),reason:y,appLabel:X}).action==="clear"&&B.push(C)};for(const C of U.fields){if(P!==void 0&&C!==P)continue;const T=F.get(C);if(!T)continue;const L=P===void 0&&kn(T)?u.current.get(Nn(_,T,U.form)):void 0;L?(Y[C]={options:L,loading:!1},Z(C,L)):K.push(C)}const Q=(C=!1)=>{if(B.length===0)return;const T={...C?H:c.current.values};for(const L of B)delete T[L];c.current.onChange(T)};if(Object.keys(Y).length>0&&l(C=>({...C,...Y})),K.length===0){Q(!0);return}for(const C of p.current)bo(C.fields,K)&&C.controller.abort();const V=new AbortController,G={fields:K,controller:V};p.current=[...p.current.filter(C=>!C.controller.signal.aborted),G],l(C=>{var L;const T={...C};for(const m of K)T[m]={options:(L=C[m])==null?void 0:L.options,loading:!0};return T});const J={...U,fields:K,connectionId:_.connectionId,..._.version!==void 0?{version:_.version}:{}},v=C=>{p.current=p.current.filter(T=>T!==G),l(T=>({...T,...C}))};Promise.resolve().then(()=>j(_.appId,_.actionKey,J,{signal:V.signal})).then(C=>{var L;if(V.signal.aborted)return;const T={};for(const m of K){const R=(L=C==null?void 0:C.fields)==null?void 0:L[m],I=F.get(m);if(!R||!I)T[m]={loading:!1};else if(R.error)T[m]={loading:!1,error:R.error};else{const E=Array.isArray(R.options)?R.options:[];T[m]={loading:!1,options:E},kn(I)&&u.current.set(Nn(_,I,U.form),E),Z(m,E)}}v(T),Q()}).catch(C=>{if(V.signal.aborted)return;const T=C instanceof Error?C.message:String(C),L={};for(const m of K)L[m]={loading:!1,error:T||"Request failed"};v(L)})},[]),f=s?JSON.stringify([s.appId,s.actionKey,s.version,s.connectionId]):"";d.useEffect(()=>{if(a)return l({}),w("init"),()=>{for(const y of p.current)y.controller.abort();p.current=[]}},[f,a,w]);const h=d.useRef(new Map),g=d.useCallback((y,S)=>{const b=h.current.get(y)??c.current.values;h.current.delete(y),w("change",[y],b,void 0,{...c.current.values,[y]:S})},[w]),x=d.useCallback(y=>{h.current.has(y)||h.current.set(y,c.current.values)},[]),k=d.useCallback(y=>{const S=h.current.get(y);if(h.current.delete(y),!S)return;const b=c.current.values;JSON.stringify(S[y])!==JSON.stringify(b[y])&&w("change",[y],S)},[w]),O=d.useCallback(y=>w("init",void 0,void 0,y),[w]);return{fields:d.useMemo(()=>{const y={};if(!a||!s)return y;const S=s.appName??s.appId;for(const b of Et(e)){const P=xo(b,e,n,s);if(P){y[b.key]={loading:!1,hint:P.hint};continue}const A=i[b.key]??{loading:!0},z={...A};if(A.options){const $=Cn(n[b.key],A.options,{allowCustom:Ge(b),reason:"init",appLabel:S});$.action==="flag"&&(z.notInList=$.message)}y[b.key]=z}return y},[a,s,e,n,i]),commit:g,focus:x,blur:k,retry:O}}function qe(e,n){const s=e.showIf;if(!s)return!0;const r=n(s.field);return s.equals!==void 0?r===s.equals:s.in?s.in.some(o=>o===r):s.notIn?!s.notIn.some(o=>o===r):s.truthy!==void 0?s.truthy?!!r:!r:!0}function Ee(e){const n=[];for(const s of e)n.push(s),s.type==="section"&&s.children&&n.push(...Ee(s.children));return n}function De(e,n){const s=[];for(let r=0;r<e.length;){const o=e[r].row;if(o){const a=[];for(;r<e.length&&e[r].row===o;)a.push(e[r++]);s.push(t.jsx("div",{className:"w6w-field-row",children:a.map(n)},`row:${o}`))}else s.push(n(e[r])),r++}return s}function ys(e,n,s,r){const o=a=>a.type==="section"?t.jsx(Ao,{param:a,effective:s,renderOne:o},a.key):a.repeat&&a.type!=="array"?t.jsx(Ro,{param:a,value:e[a.key],onChange:n,readOnly:r},a.key):a.type==="group"&&a.children&&a.children.length>0?t.jsx(Io,{param:a,value:e[a.key],onChange:n,effective:s,readOnly:r},a.key):t.jsx(Po,{param:a,value:e[a.key],onChange:n,effective:s,readOnly:r},a.key);return o}const it=d.createContext(null);function ve({params:e,values:n,onChange:s,readOnly:r,dynamic:o}){const a=So(e,n,o,s),i=Ee(e),l=h=>{var g;return n[h]!==void 0?n[h]:(g=i.find(x=>x.key===h))==null?void 0:g.default},c=e.filter(h=>qe(h,l)),u=c.filter(h=>h.required||!h.advanced),p=c.filter(h=>!h.required&&h.advanced),w=(h,g)=>{if(h==="language"){const x={...n,[h]:g};for(const k of i){if(k.type!=="code")continue;const O=n[k.key];(O===void 0||O===k.default||O===Ot)&&(x[k.key]=g==="python"?Ot:k.default)}s(x);return}s({...n,[h]:g})};if(e.length===0)return t.jsx("p",{className:"w6w-muted w6w-small",children:"This action takes no parameters."});const f=ys(n,w,l,r);return t.jsx(it.Provider,{value:a,children:t.jsxs("div",{className:"w6w-stack",children:[De(u,f),p.length>0&&t.jsxs("details",{className:"w6w-params-optional",children:[t.jsxs("summary",{className:"w6w-muted w6w-small",children:["Additional parameters (",p.length,")"]}),t.jsx("div",{className:"w6w-stack",style:{marginTop:8},children:De(p,f)})]})]})})}function Ao({param:e,effective:n,renderOne:s}){const r=(e.children??[]).filter(o=>qe(o,n));return e.section==="collapsible"?t.jsxs("details",{className:"w6w-section",open:e.collapsed===!1,children:[t.jsxs("summary",{className:"w6w-section-summary",children:[t.jsx("span",{className:"w6w-section-title",children:e.title??e.label??e.key}),e.subtitle&&t.jsx("span",{className:"w6w-section-subtitle",children:e.subtitle})]}),t.jsx("div",{className:"w6w-stack w6w-section-body",children:De(r,s)})]}):e.layout==="row"?t.jsx("div",{className:"w6w-field-row",children:r.map(s)}):t.jsx("div",{className:"w6w-stack",children:De(r,s)})}const Eo=new Set(["string","text","number","boolean","select"]);function To(e){return e.length>0&&e.every(n=>Eo.has(n.type)&&!n.children)}function Io({param:e,value:n,onChange:s,effective:r,readOnly:o}){const a=e.children??[],i=n??{},l=(f,h)=>s(e.key,{...i,[f]:h}),c=Ee(a),u=f=>{const h=c.find(g=>g.key===f);return h?i[f]!==void 0?i[f]:h.default:r(f)},p=a.filter(f=>qe(f,u)),w=ys(i,l,u,o);return t.jsx(it.Provider,{value:null,children:t.jsxs("div",{className:"w6w-stack",children:[t.jsx("span",{className:"w6w-section-title",children:e.label??e.key}),t.jsx("div",{className:"w6w-stack w6w-section-body",children:De(p,w)})]})})}function Ro({param:e,value:n,onChange:s,readOnly:r}){if(e.type==="group"){const a=e.children??[];if(!To(a))return t.jsx(vs,{param:e,value:n,onChange:s,readOnly:r});const i={...e,item:{type:"object",fields:a}};return t.jsx($t,{param:i,value:n,onChange:s,readOnly:r})}const o={...e,item:{type:e.type,options:Array.isArray(e.options)?e.options:void 0}};return t.jsx($t,{param:o,value:n,onChange:s,readOnly:r})}const Ot=`# Runs as a function body. Return the step's output.
|
|
11
|
+
return input`;function Po(e){const n=d.useContext(it),s=e.param.key;return t.jsx("div",{style:{display:"contents"},onFocusCapture:n?()=>n.focus(s):void 0,onBlurCapture:n?()=>n.blur(s):void 0,children:t.jsx(Oo,{...e})})}function Oo({param:e,value:n,onChange:s,effective:r,readOnly:o}){var O,N,M;const a=(O=Un())==null?void 0:O.listModelRoutes,i=Vt(),l=d.useContext(it),c=l==null?void 0:l.fields[e.key],u=(y,S)=>{s(y,S),l==null||l.commit(y,S)},p=s,w=e.label??e.key,f=e.required&&e.type!=="boolean"?" *":"",h=d.useId();if(e.type==="boolean"){const y=!!(n??e.default??!1);return t.jsx(be,{param:e,value:n,onChange:p,readOnly:o,label:w,req:f,variant:"inline",controlId:h,children:t.jsx("input",{id:h,type:"checkbox",checked:y,disabled:o,onChange:S=>u(e.key,S.target.checked)})})}if(e.type==="json"||e.type==="group")return t.jsx(vs,{param:e,value:n,onChange:p,readOnly:o});if(e.type==="code"){const y=r==null?void 0:r("language"),S=y==="python"?"python":y==="javascript"?"javascript":void 0,b=S==="python"?Ot:e.default,P=n??b??"";return t.jsxs("div",{className:"w6w-field",children:[t.jsxs("span",{children:[w,f]}),t.jsx(ns,{value:String(P),readOnly:o,minHeight:"180px",language:S,"aria-label":`${e.key} code`,onChange:A=>p(e.key,A)}),e.hint&&t.jsx("span",{className:"w6w-hint",children:e.hint})]})}if(e.type==="model-route"&&a)return t.jsx($o,{param:e,value:n,onChange:p,readOnly:o,label:w,req:f,listModelRoutes:a,project:i});if(e.type==="vars")return t.jsx(Do,{param:e,value:n,onChange:p,readOnly:o});if(e.type==="text"||(N=e.config)!=null&&N.multiline){const y=n??e.default??"";return t.jsx(be,{param:e,value:n,onChange:p,readOnly:o,label:w,req:f,children:t.jsx("textarea",{rows:3,value:String(y),readOnly:o,"aria-label":w,onChange:S=>p(e.key,S.target.value)})})}if(e.type==="multiselect")return t.jsx(Mo,{param:e,value:n,onChange:u,readOnly:o});if(e.type==="array")return t.jsx($t,{param:e,value:n,onChange:p,readOnly:o});if(l&&c&&!c.hint)return t.jsx(Sn,{param:e,value:n,onChange:u,readOnly:o,label:w,req:f,state:c,retry:()=>l.retry(e.key)});if(Array.isArray(e.options)&&e.options.length>0&&Ge(e))return t.jsx(Sn,{param:e,value:n,onChange:u,readOnly:o,label:w,req:f,state:{loading:!1,options:e.options}});if(Array.isArray(e.options)&&e.options.length>0){const y=!e.required&&e.default===void 0&&typeof e.placeholder=="string"&&e.placeholder?e.placeholder:void 0,S=n??e.default??(y!==void 0?"":(M=e.options[0])==null?void 0:M.value)??"",b=e.type==="number";return t.jsx(be,{param:e,value:n,onChange:p,readOnly:o,label:w,req:f,children:t.jsxs("select",{value:String(S),disabled:o,"aria-label":w,onChange:P=>{const A=P.target.value;y!==void 0&&A===""?u(e.key,void 0):u(e.key,b?Number(A):A)},children:[y!==void 0&&t.jsx("option",{value:"",children:y}),e.options.map(P=>t.jsx("option",{value:String(P.value),children:P.label},String(P.value)))]})})}if(e.type==="secret"){const y=n??e.default;return t.jsxs("div",{className:"w6w-field",children:[t.jsxs("span",{children:[w,f]}),t.jsx(Kt,{value:y,masked:!0,readOnly:o,"aria-label":w,onChange:S=>p(e.key,S)}),e.hint&&t.jsx("span",{className:"w6w-hint",children:e.hint})]})}const g=e.type==="number"?"number":"text",x=n??e.default??"",k=typeof x=="object"&&x!==null?JSON.stringify(x):String(x??"");return t.jsxs(be,{param:e,value:n,onChange:p,readOnly:o,label:w,req:f,children:[t.jsx("input",{type:g,value:k,readOnly:o,"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:y=>p(e.key,e.type==="number"?Number(y.target.value):y.target.value)}),(c==null?void 0:c.hint)&&t.jsx("span",{className:"w6w-hint",children:c.hint})]})}function Sn({param:e,value:n,onChange:s,readOnly:r,label:o,req:a,state:i,retry:l}){const c=n??e.default??"",u=typeof c=="string"||typeof c=="number"?String(c):"";return t.jsxs(be,{param:e,value:n,onChange:s,readOnly:r,label:o,req:a,children:[t.jsx("div",{"aria-busy":i.loading?"true":"false",children:t.jsx(nt,{mode:"combobox",forceSelection:!Ge(e),"aria-label":o,disabled:r,value:u,placeholder:i.loading?"Loading…":e.placeholder,options:(i.options??[]).map(p=>({value:String(p.value),label:p.label})),onChange:p=>s(e.key,p)})}),i.notInList&&t.jsx("span",{className:"w6w-hint",children:i.notInList}),i.error&&t.jsxs("span",{role:"alert",className:"w6w-hint",children:[i.error,l&&t.jsx("button",{type:"button",onClick:l,children:"Retry"})]})]})}function $o({param:e,value:n,onChange:s,readOnly:r,label:o,req:a,listModelRoutes:i,project:l}){const[c,u]=d.useState([]);d.useEffect(()=>{let f=!0;return Promise.resolve().then(()=>i(l)).then(h=>f&&u(Array.isArray(h)?h:[])).catch(()=>f&&u([])),()=>{f=!1}},[i,l]);const p=n??e.default??"",w=typeof p=="string"?p:"";return t.jsx(be,{param:e,value:n,onChange:s,readOnly:r,label:o,req:a,children:t.jsx(nt,{mode:"combobox",forceSelection:!1,"aria-label":o,disabled:r,value:w,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 be({param:e,value:n,onChange:s,readOnly:r,label:o,req:a,bare:i,variant:l="boxed",controlId:c,children:u}){var O;const p=_e(n),w=e.type==="text"||!!((O=e.config)!=null&&O.multiline),[f,h]=d.useState(!1),g=ot(),x=l==="inline"&&!p,k=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:x?"w6w-fx-inline":`w6w-fx-wrap${p?" is-fx":""}`,children:p?t.jsx(Kt,{value:n,multiline:w,readOnly:r,"aria-label":o,onChange:N=>s(e.key,N)}):t.jsxs(t.Fragment,{children:[u,!r&&t.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Use an expression","aria-label":`Use an expression for ${o}`,onClick:()=>h(!0),children:"ƒx"}),x&&t.jsxs("label",{className:"w6w-fx-inline-label",htmlFor:c,children:[o,a]})]})}),f&&t.jsx(Gt,{value:n,multiline:w,options:g,fieldLabel:o,onSave:N=>s(e.key,N),onClose:()=>h(!1)})]});return i?k:t.jsxs("div",{className:"w6w-field",children:[!x&&t.jsxs("span",{children:[o,a]}),k,e.hint&&t.jsx("span",{className:"w6w-hint",children:e.hint})]})}function vs({param:e,value:n,onChange:s,readOnly:r}){const o=gs(n)&&typeof n.$=="string",a=o?String(n.$):"",i=n??e.default,[l,c]=d.useState(()=>o||i===void 0?"":JSON.stringify(i,null,2)),[u,p]=d.useState(!1),[w,f]=d.useState(!1),[h,g]=d.useState(!1),x=ot();d.useEffect(()=>{if(o)return;let b;try{b=l.trim()===""?void 0:JSON.parse(l)}catch{b=void 0}JSON.stringify(b)!==JSON.stringify(i)&&(c(i===void 0?"":JSON.stringify(i,null,2)),p(!1))},[i,e.key,o]);const k=b=>{c(b)},O=b=>{p(!1),s(e.key,b)},N=({valid:b,error:P})=>{if(!b&&P==="Empty"){p(!1),s(e.key,void 0);return}p(!b)},M=e.label??e.key,y=()=>{let b;try{b=l.trim()===""?void 0:JSON.parse(l)}catch{b=void 0}s(e.key,b)},S=(()=>{if(!o)return"";const b={};for(const[P,A]of Object.entries(x.sampleValues??{})){const z=/^steps\.([^.]+)\.output$/.exec(P);z&&(b[z[1]]={output:A})}return JSON.stringify(Xt(n,fs(void 0,{steps:b})),null,2)})();return t.jsxs("div",{className:"w6w-field",children:[t.jsxs("span",{className:"w6w-field-labelrow",children:[t.jsxs("span",{children:[M,e.required?" *":""]}),!o&&t.jsx("button",{type:"button",className:"w6w-icon-btn w6w-btn-sm",title:"Open in full view","aria-label":`Open ${M} in full view`,onClick:()=>f(!0),children:t.jsx(ie.Icon,{name:"maximize",size:14})})]}),o?t.jsxs("div",{className:"w6w-json-binding",children:[t.jsxs("div",{className:"w6w-fx-wrap is-fx",children:[t.jsx("code",{children:a}),!r&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>g(!0),children:"Edit"}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:y,children:"Clear"})]})]}),t.jsx("pre",{className:"w6w-json-binding-preview","data-testid":"json-binding-preview",style:{margin:0,maxHeight:260,overflow:"auto",fontSize:"0.85em"},children:S})]}):t.jsx(xe,{value:l,onChange:k,readOnly:r,minHeight:"34px",maxHeight:"260px","aria-label":`${e.key} JSON`,onValidChange:O,onValidityChange:N,overlay:r?void 0:t.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Use an expression","aria-label":`Use an expression for ${M}`,onClick:()=>g(!0),children:"ƒx"})}),h&&t.jsx(Gt,{mode:"json-binding",value:void 0,options:x,fieldLabel:M,onBind:b=>s(e.key,b),onClose:()=>g(!1)}),!o&&u&&t.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"}),e.hint&&t.jsx("span",{className:"w6w-hint",children:e.hint}),w&&!o&&t.jsxs(de,{title:M,subtitle:t.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>f(!1),children:[t.jsx("div",{className:"w6w-json-fullview",children:t.jsx(xe,{value:l,onChange:k,readOnly:r,height:"100%",minHeight:"360px","aria-label":`${e.key} JSON (full view)`,onValidChange:O,onValidityChange:N})}),u&&t.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]})}function Mo({param:e,value:n,onChange:s,readOnly:r}){const o=Array.isArray(e.options)?e.options:[],a=Array.isArray(n)?n:Array.isArray(e.default)?e.default:[],i=new Set(a.map(String)),l=o.filter(g=>!i.has(String(g.value))),c=g=>{var x;return((x=o.find(k=>String(k.value)===String(g)))==null?void 0:x.label)??String(g)},u=g=>{if(!g||i.has(g))return;const x=o.find(k=>String(k.value)===g);s(e.key,[...a,x?x.value:g])},p=g=>s(e.key,a.filter(x=>String(x)!==String(g))),w=typeof e.placeholder=="string"&&e.placeholder?e.placeholder:"Select…",f=e.label??e.key,h=e.required?" *":"";return t.jsx(be,{param:e,value:n,onChange:s,readOnly:r,label:f,req:h,children:t.jsxs("div",{className:`w6w-multiselect${r?" is-readonly":""}`,children:[a.map(g=>t.jsxs("span",{className:"w6w-chip",children:[c(g),!r&&t.jsx("button",{type:"button",className:"w6w-chip-x","aria-label":`Remove ${c(g)}`,title:"Remove",onClick:()=>p(g),children:"×"})]},String(g))),!r&&t.jsxs("select",{className:"w6w-multiselect-add",value:"",disabled:l.length===0,"aria-label":`Add to ${e.label??e.key}`,onChange:g=>u(g.target.value),children:[t.jsx("option",{value:"",children:l.length>0?a.length?"Add more…":w:"All selected"}),l.map(g=>t.jsx("option",{value:String(g.value),children:g.label},String(g.value)))]})]})})}function Fo({field:e,value:n,onChange:s,readOnly:r}){var i;const o=e.placeholder??e.label??e.key;if(Array.isArray(e.options)&&e.options.length>0)return t.jsx("select",{className:"w6w-array-input",value:String(n??e.default??((i=e.options[0])==null?void 0:i.value)??""),disabled:r,"aria-label":e.label??e.key,onChange:l=>s(l.target.value),children:e.options.map(l=>t.jsx("option",{value:String(l.value),children:l.label},String(l.value)))});if(e.type==="boolean")return t.jsxs("label",{className:"w6w-array-check",title:e.label??e.key,children:[t.jsx("input",{type:"checkbox",checked:!!(n??e.default??!1),disabled:r,"aria-label":e.label??e.key,onChange:l=>s(l.target.checked)}),t.jsx("span",{children:e.label??e.key})]});const a=e.type==="number";return t.jsx("input",{className:"w6w-array-input",type:a?"number":"text",value:String(n??e.default??""),placeholder:o,"aria-label":e.label??e.key,readOnly:r,onChange:l=>s(a?Number(l.target.value):l.target.value)})}function $t({param:e,value:n,onChange:s,readOnly:r}){const o=e.item??{type:"string"},a=o.type==="object",i=Array.isArray(n)?n:Array.isArray(e.default)?e.default:[],l=p=>s(e.key,p),c=()=>a?Object.fromEntries((o.fields??[]).map(p=>[p.key,p.default??""])):o.type==="number"?0:"",u=(p,w)=>l(i.map((f,h)=>h===p?w:f));return t.jsxs("div",{className:"w6w-field",children:[t.jsxs("span",{children:[e.label??e.key,e.required?" *":""]}),t.jsxs("div",{className:"w6w-array",children:[i.length===0&&t.jsx("p",{className:"w6w-muted w6w-small",children:"None yet — add one below."}),i.map((p,w)=>t.jsxs("div",{className:"w6w-array-row",children:[a?t.jsx("div",{className:"w6w-array-cells",children:(o.fields??[]).map(f=>t.jsx(Fo,{field:f,value:p==null?void 0:p[f.key],readOnly:r,onChange:h=>u(w,{...p??{},[f.key]:h})},f.key))}):t.jsx("input",{className:"w6w-array-input",type:o.type==="number"?"number":"text",value:String(p??""),placeholder:o.placeholder,readOnly:r,onChange:f=>u(w,o.type==="number"?Number(f.target.value):f.target.value)}),!r&&t.jsx("button",{type:"button",className:"w6w-array-x","aria-label":"Remove item",title:"Remove",onClick:()=>l(i.filter((f,h)=>h!==w)),children:"×"})]},w)),!r&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-array-add",onClick:()=>l([...i,c()]),children:"+ Add"})]}),e.hint&&t.jsx("span",{className:"w6w-hint",children:e.hint})]})}const Lo=["string","number","boolean","json"];function An(e,n){if(e==="number"){if(n.trim()==="")return"";const s=Number(n);return Number.isNaN(s)?n:s}if(e==="boolean")return n==="true";if(e==="json")try{return JSON.parse(n)}catch{return n}return n}function En(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Do({param:e,value:n,onChange:s,readOnly:r}){const o=Array.isArray(n)?n:Array.isArray(e.default)?e.default:[],a=l=>s(e.key,l),i=(l,c)=>a(o.map((u,p)=>p===l?{...u,...c}:u));return t.jsxs("div",{className:"w6w-field",children:[t.jsxs("span",{children:[e.label??e.key,e.required?" *":""]}),t.jsxs("div",{className:"w6w-stack",children:[o.length===0&&t.jsx("p",{className:"w6w-muted w6w-small",children:"No variables yet — add one below."}),o.map((l,c)=>t.jsxs("div",{className:"w6w-datavar-row",children:[t.jsx("input",{type:"text",placeholder:"key",value:l.key,readOnly:r,onChange:u=>i(c,{key:u.target.value})}),t.jsx("select",{value:l.type,disabled:r,onChange:u=>{const p=u.target.value;i(c,{type:p,value:An(p,En(l.value))})},children:Lo.map(u=>t.jsx("option",{value:u,children:u},u))}),t.jsx(be,{bare:!0,param:e,value:l.value,onChange:(u,p)=>i(c,{value:p}),readOnly:r,label:l.key||"value",req:"",children:l.type==="boolean"?t.jsxs("select",{value:l.value===!0?"true":"false",disabled:r,onChange:u=>i(c,{value:u.target.value==="true"}),children:[t.jsx("option",{value:"true",children:"true"}),t.jsx("option",{value:"false",children:"false"})]}):t.jsx("input",{type:l.type==="number"?"number":"text",placeholder:"value",value:En(l.value),readOnly:r,onChange:u=>i(c,{value:An(l.type,u.target.value)})})}),!r&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","aria-label":`Remove variable ${l.key||c+1}`,title:"Remove",onClick:()=>a(o.filter((u,p)=>p!==c)),children:"×"})]},c)),!r&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>a([...o,{key:"",type:"string",value:""}]),children:"+ Add variable"})]}),e.hint&&t.jsx("span",{className:"w6w-hint",children:e.hint})]})}function Zt(e){return Array.isArray(e)?e:[]}function js(e){return e==="object"||e==="array"?"json":e==="number"||e==="boolean"||e==="json"?e:"string"}function Ns(e,n){if(!(n==null||n==="")){if(typeof n=="object")return n;if(e==="number"){const s=Number(n);return Number.isFinite(s)?s:void 0}if(e==="boolean")return n===!0||n==="true";if(e==="json")try{return JSON.parse(String(n))}catch{return}return String(n)}}function Qt(e){return e.filter(n=>typeof n.key=="string"&&n.key.trim()!=="").map(n=>({key:n.key,label:n.key,type:js(n.type),required:!!n.required}))}function ks(e){const n={};for(const s of e){if(typeof s.key!="string"||s.key.trim()==="")continue;const r=Ns(s.type,s.default);r!==void 0&&(n[s.key]=r)}return n}function Cs({app:e,action:n,fields:s,persist:r}){const o=re(),a=Vt(),i=d.useMemo(()=>Zt(s),[s]),l=d.useMemo(()=>Qt(i),[i]),c=l.length>0,[u,p]=d.useState(()=>ks(i)),[w,f]=d.useState(null),h=r==null?void 0:r.workflowId,g=r==null?void 0:r.stepId,[x,k]=d.useState(!h||!g);d.useEffect(()=>{if(!h||!g){k(!0);return}let b=!1;return o.listStepTests(h,g).then(P=>{if(b)return;const A=P.length?P[P.length-1]:null;A!=null&&A.with&&p(z=>({...z,...A.with})),k(!0)}).catch(()=>{b||k(!0)}),()=>{b=!0}},[o,h,g]);const[O,N]=d.useState(!0),M=O&&Te(l,u),y=async()=>{f({status:"running"});let b;try{const P=await o.invokeAction(e,n,{input:u},{project:a});b={status:"done",value:P.value,logs:P.logs}}catch(P){const A=P;b={status:"error",error:A.message??String(P),errorCode:A.code,logs:A.logs}}if(f(b),r)try{const P=await o.saveStepTest(r.workflowId,r.stepId,{input:r.input,with:u});await o.recordStepTestRun(r.workflowId,r.stepId,{stepTestId:P.id,status:b.status==="done"?"succeeded":"failed",input:r.input,output:b.status==="done"?b.value:void 0,error:b.status==="error"?b.error:void 0})}catch(P){console.error("step test persist failed",P)}},S=w&&w.status!=="running"?w.logs:void 0;return t.jsxs("div",{className:"w6w-stack",children:[x?t.jsxs(t.Fragment,{children:[t.jsx(Ms,{params:l,values:u,onChange:p,onValidityChange:N}),!c&&t.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 (",t.jsx("code",{children:"input"}),")."]})]}):t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading saved values…"}),t.jsxs("div",{className:"w6w-steptest",children:[t.jsxs("div",{className:"w6w-steptest-bar",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!x||!M||(w==null?void 0:w.status)==="running",onClick:y,children:(w==null?void 0:w.status)==="running"?"Running…":"▶ Test run"}),x&&!M&&t.jsx("span",{className:"w6w-muted w6w-small",children:O?"Fill the required fields to test.":"The payload must be a JSON object to test."})]}),(w==null?void 0:w.status)==="error"&&t.jsxs("div",{className:"w6w-result w6w-error",children:[w.errorCode&&t.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:t.jsx("code",{children:w.errorCode})}),w.error]}),(w==null?void 0:w.status)==="done"&&t.jsxs("div",{className:"w6w-testout",children:[t.jsx("div",{className:"w6w-testout-label",children:"Output state (filled values)"}),t.jsx("pre",{className:"w6w-result",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(w.value,null,2)})]}),S&&S.length>0&&t.jsxs("div",{className:"w6w-testout",children:[t.jsx("div",{className:"w6w-testout-label",children:"Console output"}),t.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:S.join(`
|
|
12
|
+
`)})]})]})]})}const _o=[["s","Seconds"],["m","Minutes"],["h","Hours"],["d","Days"],["w","Weeks"]],qo=/^(?=\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 Ss({values:e,onChange:n,readOnly:s}){const r=e.duration??"1s",o=typeof r=="string"?r.match(/^(\d+(?:\.\d+)?)([smhdw])$/i):null,[a,i]=d.useState("s"),[l,c]=d.useState("text"),[u,p]=d.useState(e.until?"until":"duration"),w=typeof r=="string"&&(!qo.test(r.trim())||/^P$/i.test(r.trim()));return t.jsxs("div",{className:"w6w-params-form",children:[t.jsxs("label",{children:["Wait for",t.jsxs("select",{"aria-label":"Wait for",disabled:s,value:u,onChange:f=>{const h=f.target.value;p(h),n({...e,duration:h==="duration"?"1s":"",until:""})},children:[t.jsx("option",{value:"duration",children:"A duration"}),t.jsx("option",{value:"until",children:"Until a timestamp"})]})]}),u==="until"?t.jsx(ve,{params:[{key:"until",label:"Until",type:"string",hint:"ISO-8601 timestamp, e.g. 2026-10-08T09:00:00Z."}],values:e,onChange:n,readOnly:s}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{children:["Duration input",t.jsxs("select",{"aria-label":"Duration input",disabled:s,value:l,onChange:f=>{o&&i((o==null?void 0:o[2].toLowerCase())??a),c(f.target.value)},children:[t.jsx("option",{value:"text",children:"Shorthand"}),t.jsx("option",{value:"value",disabled:!o,children:"Value and unit"})]})]}),l==="value"?t.jsxs("div",{className:"w6w-field-row",children:[t.jsxs("label",{children:["Value",t.jsx("input",{"aria-label":"Duration value",type:"number",min:"0",step:((o==null?void 0:o[2].toLowerCase())??a)==="s"?"any":"1",disabled:s,value:(o==null?void 0:o[1])??"",onChange:f=>n({...e,duration:`${f.target.value}${(o==null?void 0:o[2].toLowerCase())??a}`})})]}),t.jsxs("label",{children:["Unit",t.jsx("select",{"aria-label":"Duration unit",disabled:s,value:(o==null?void 0:o[2].toLowerCase())??a,onChange:f=>{i(f.target.value),n({...e,duration:`${(o==null?void 0:o[1])??""}${f.target.value}`})},children:_o.map(([f,h])=>t.jsx("option",{value:f,children:h},f))})]})]}):t.jsx(ve,{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:n,readOnly:s}),w&&t.jsx("p",{role:"alert",children:"Enter a duration such as 30s or 1h30m30s, using units w, d, h, m, s in order."})]})]})}function Tn(e){if(!e)return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Ho(e,n){return`${e.method}-${e.url??e.host}-${n}`}function As({calls:e,defaultOpen:n,keyOf:s,title:r}){if(e.length===0)return null;const o=s??Ho;return t.jsxs("div",{className:"w6w-stack",style:{gap:4},children:[r!==!1&&t.jsx("strong",{className:"w6w-small",children:r??t.jsxs(t.Fragment,{children:["API ",e.length===1?"call":"calls"," (",e.length,")"]})}),e.map((a,i)=>t.jsxs("details",{open:n,className:"w6w-result",style:{padding:8},children:[t.jsx("summary",{style:{cursor:"pointer"},children:t.jsxs("span",{className:"w6w-small",children:[a.method," ",a.url??a.host," →"," ",t.jsx("strong",{children:a.error?"failed":a.status}),a.durationMs!==void 0&&t.jsxs("span",{className:"w6w-muted",children:[" · ",a.durationMs,"ms"]})]})}),t.jsxs("div",{className:"w6w-stack",style:{gap:6,marginTop:8},children:[a.error&&t.jsx("div",{className:"w6w-error w6w-small",children:a.error}),t.jsx("div",{className:"w6w-muted w6w-small",children:"Request headers"}),t.jsx("pre",{className:"w6w-result",children:JSON.stringify(a.requestHeaders??{},null,2)}),a.requestBody&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w6w-muted w6w-small",children:"Request body"}),t.jsx("pre",{className:"w6w-result",children:Tn(a.requestBody)})]}),t.jsx("div",{className:"w6w-muted w6w-small",children:"Response headers"}),t.jsx("pre",{className:"w6w-result",children:JSON.stringify(a.responseHeaders??{},null,2)}),a.responseBody&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w6w-muted w6w-small",children:"Response body"}),t.jsx("pre",{className:"w6w-result",children:Tn(a.responseBody)})]}),a.truncated&&t.jsx("div",{className:"w6w-muted w6w-small",children:"A captured body exceeded the size cap and was truncated."})]})]},o(a,i)))]})}function lt({icon:e,size:n=28}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:n,height:n,borderRadius:6,flexShrink:0,background:"var(--w6w-icon-swatch, var(--w6w-panel-2))",color:"var(--w6w-accent)"},children:t.jsx("svg",{width:Math.round(n*.6),height:Math.round(n*.6),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",dangerouslySetInnerHTML:{__html:e}})})}function Ke(e,n,s){return s==="error"?`${e}->${n}:error`:`${e}->${n}`}function Vo(e){return e.includes(".")?"A step id can't contain a dot (.).":null}function Wo(e,n,s){const r=(w,f)=>!w||!f?void 0:Ke(w,f)===n?"success":Ke(w,f,"error")===n?"error":void 0,o=r(s[0],s[1]),a=r(s[2],s[3]),i=o!==void 0&&o===a,l=o!==void 0&&a!==void 0&&o!==a,c=o==="success"?s[1]:s[3],u=i?s.find(w=>!!w&&w.includes("->")):l&&(c!=null&&c.endsWith(":error"))?c:void 0,p=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 “${n}” is already taken by another edge. ${p}`}const Bo=240,Uo=100,zo=40,Jo=40;function Es(e,n){return{x:zo+e*Bo,y:Jo+n*Uo}}function Ts(e,n){var l;const s=new Map,r=new Map;for(const c of e)s.set(c.id,0),r.set(c.id,[]);for(const c of n)(l=r.get(c.to))==null||l.push(c.from);const o=e.length+1;let a=0,i=!0;for(;i&&a<o;){a++,i=!1;for(const c of e){const u=r.get(c.id)??[];if(u.length===0)continue;const p=u.reduce((w,f)=>Math.max(w,(s.get(f)??0)+1),0);(s.get(c.id)??0)<p&&(s.set(c.id,p),i=!0)}}if(i){const c=Math.max(0,e.length-1);for(const[u,p]of s)p>c&&s.set(u,c)}return s}function Go(e){const n=e.position;if(!(!n||!Number.isFinite(n.x)||!Number.isFinite(n.y)))return{x:n.x,y:n.y}}function Is(e){const n=e;if(n.nodes!==void 0&&n.steps!==void 0)throw new Error("workflow carries both nodes and steps");const{steps:s,...r}=e;return{...r,nodes:n.nodes??n.steps??[]}}function Ko(e){const n=Is(e),s=n.nodes,r=n.edges??Qo(s),o=Ts(s,r),a=new Map,i=s.map(c=>{const u=ke(c.uses.app),p=o.get(c.id)??0,w=a.get(p)??0;return a.set(p,w+1),{id:c.id,type:u?"control":"step",position:Go(c)??Es(p,w),data:{step:c,isInternal:u}}}),l=r.map(c=>{const u=c.when??"success";return{id:Ke(c.from,c.to,u),source:c.from,target:c.to,sourceHandle:_n(u),animated:!1,data:{when:u},...Dn(u,void 0)}});return{nodes:i,edges:l}}function Yo(e,n){const s=e.map(a=>({...a.data.step,id:a.id})),r=Ts(s,n.map(a=>({from:a.source,to:a.target}))),o=new Map;return e.map(a=>{const i=r.get(a.id)??0,l=o.get(i)??0;return o.set(i,l+1),{...a,position:Es(i,l)}})}function Xo(e,n,s){var w,f;const r=Is(e),o=((w=r.settings)==null?void 0:w.savePosition)!==!1,a=new Map(n.map(h=>[h.id,h])),i=h=>{var x;if(!o)return h;const g=(x=a.get(h.id))==null?void 0:x.position;return!g||!Number.isFinite(g.x)||!Number.isFinite(g.y)?h:{...h,position:{x:Math.round(g.x),y:Math.round(g.y)}}},l=new Map;for(const h of r.nodes)l.set(h.id,h);for(const h of n)(f=h.data)!=null&&f.step&&l.set(h.id,h.data.step);const c=[],u=new Set;for(const h of r.nodes){const g=l.get(h.id);g&&n.some(x=>x.id===h.id)&&(c.push(i(g)),u.add(h.id))}for(const h of n){if(u.has(h.id))continue;const g=l.get(h.id);g&&c.push(i(g))}const p=s.map(h=>{var x;const g=(x=h.data)==null?void 0:x.when;return g==="error"?{from:h.source,to:h.target,when:g}:{from:h.source,to:h.target}});return{...r,nodes:c,edges:p}}function Rs(e){var s;const n=(s=e.settings)==null?void 0:s.viewport;if(!(!n||!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(n.zoom)))return{x:n.x,y:n.y,zoom:n.zoom}}function Zo(e,n){var i;if(!(((i=e.settings)==null?void 0:i.savePosition)!==!1)||!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(n.zoom))return e;const r={x:Math.round(n.x),y:Math.round(n.y),zoom:Math.round(n.zoom*1e3)/1e3},o=Rs(e);if(o&&o.x===r.x&&o.y===r.y&&o.zoom===r.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:r}}}function Qo(e){const n=[];for(let s=0;s<e.length-1;s++)n.push({from:e[s].id,to:e[s+1].id});return n}function ea(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"step"}function ta(e,n){const s=new Set(n.map(r=>r.target));return e.find(r=>!s.has(r.id))}function na(e,n){const s=new Set(n.map(r=>r.source));for(let r=e.length-1;r>=0;r--)if(!s.has(e[r].id))return e[r]}function sa(e,n="step"){const s=new Set(e);for(let r=1;r<1e3;r++){const o=`${n}_${r}`;if(!s.has(o))return o}return`${n}_${crypto.randomUUID().slice(0,8)}`}function en(e){return JSON.stringify(e,null,2)}function tn(e){return JSON.stringify(e.with??{},null,2)}const ra=3,oa=100;function Ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function aa(e){if(!Array.isArray(e))return;const n=[];for(const s of e){if(!Ye(s)||typeof s.key!="string"||s.key==="")continue;const r=typeof s.label=="string"&&s.label!==""?s.label:void 0;n.push(r?{key:s.key,label:r,path:!0}:{key:s.key,path:!0})}return n.length>0?n:void 0}function Mt(e){if(!Ye(e))return;const n=[],s=(r,o,a)=>{for(const[i,l]of Object.entries(r)){if(n.length>=oa)return;const c=o?`${o}.${i}`:i;n.push({key:c,path:!0}),Ye(l)&&a<ra&&s(l,c,a+1)}};return s(e,"",1),n.length>0?n:void 0}function ia(e,n){let s=e;for(const r of n.split(".")){if(!Ye(s)||!(r in s))return;s=s[r]}return s}function la(e,n){const s=aa(e==null?void 0:e.output);if(s)return{fields:s,from:"declared"};const r=Mt(e==null?void 0:e.sample);if(r)return{fields:r,from:"sample"};const o=Mt(n);if(o)return{fields:o,from:"test"}}function Ps(e,n){const s=new Map;for(const a of n){const i=s.get(a.target)??[];i.push(a.source),s.set(a.target,i)}const r=new Set,o=[e];for(;o.length;){const a=o.pop();for(const i of s.get(a)??[])r.has(i)||(r.add(i),o.push(i))}return r}function Os(e,n,s={}){var a,i,l,c,u;const r=[];let o=!1;for(const p of n){if(!e.has(p.id))continue;const w=p.data.step,f=((a=Ce(w.uses.app,w.uses.action))==null?void 0:a.group)==="trigger";f&&(o=!0);const g=f&&w.uses.app===Qe?Qt(Zt((i=w.with)==null?void 0:i.fields)).map(y=>({key:y.key,label:y.label})):((l=Ce(w.uses.app,w.uses.action))==null?void 0:l.output)??[],x={id:w.id,label:w.id};if(g.length>0){r.push({...x,outputs:g});continue}if(f){r.push(x);continue}const k=(c=s.testOutputs)==null?void 0:c[w.id];if(ke(w.uses.app)){const y=Mt(k);r.push(y?{...x,outputs:y,outputsFrom:"test"}:x);continue}const O=(u=s.actionDef)==null?void 0:u.call(s,w.uses.app,w.uses.action),N=la(O,k),M=w.uses.app.trim()!==""?{hasMeta:!0}:{};N?r.push({...x,outputs:N.fields,outputsFrom:N.from,...M}):r.push(O?{...x,needsTest:!0,...M}:{...x,...M})}return{steps:r,hasTrigger:o}}function ca(e,n,s,r){const o=e?Ps(e,s):new Set(n.map(a=>a.id));return Os(o,n,r)}function da(e,n,s,r){if(!e||e.handleType==="target")return[];const o=Ps(e.nodeId,s);return o.add(e.nodeId),Os(o,n,r).steps}async function ua(e,n){return(await Promise.all(n.map(async r=>{try{const o=await e(r.id),a=o.length?o[o.length-1]:null;return a?{stepId:r.id,label:r.label??r.id,test:a}:null}catch{return null}}))).filter(r=>r!==null)}function nn(e){const n={};for(const s of e){const r=s.test.lastRunOutput,o=r!=null;if(!o&&s.test.lastRunStatus!=="succeeded")continue;const a=s.test.lastRunMeta;n[s.stepId]={output:o?r:null,...a?{meta:a}:{}}}return Object.keys(n).length>0?{steps:n}:void 0}function pa(e,n){if(!n)return{};const s=`steps.${e}.meta`;return{[`${s}.app`]:n.app,[`${s}.version`]:n.version,[`${s}.action`]:n.action,[`${s}.connectionId`]:n.connectionId}}function sn(e,n,s){const r=re(),[o,a]=d.useState([]),i=JSON.stringify(n.map(l=>[l.id,l.label]));return d.useEffect(()=>{const l=JSON.parse(i);if(!s||l.length===0){a([]);return}let c=!1;return ua(u=>r.listStepTests(e,u),l.map(([u,p])=>({id:u,label:p}))).then(u=>{c||a(u)}),()=>{c=!0}},[r,e,i,s]),o}const wa=["function","workflow"],ha={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"/>'},Nt={props:{label:"Form",icon:"form"},code:{label:"JSON",icon:"code"},"params-code":{label:"Params JSON",icon:"braces"},config:{label:"Node settings",icon:"settings-2"}},fa=["props","code","params-code","config"];function ct({view:e,onChange:n,disabled:s,views:r=fa}){const o=a=>t.jsx("button",{type:"button",title:Nt[a].label,"aria-label":Nt[a].label,"aria-pressed":e===a,disabled:s,className:`w6w-icon-btn${e===a&&!s?" active":""}`,onClick:()=>n(a),children:t.jsx(ie.Icon,{name:Nt[a].icon,size:15})},a);return t.jsx("div",{className:"w6w-view-toggle",children:r.map(o)})}function ma({onClose:e,onAdd:n,onDraftChange:s,theme:r,appsOnly:o,callables:a=wa,initialTab:i,title:l,workflowId:c,stepId:u,upstreamSteps:p=[],initialApp:w,initialAction:f,initialConnection:h,initialWith:g,appsFilter:x,appsIds:k,connectionOnly:O,onConnected:N,excludeCallableIds:M}){const[y,S]=d.useState(i??"connected"),[b,P]=d.useState(w??null),[A,z]=d.useState(null),[$,_]=d.useState(null),j=!!k&&k.length>0,H=Pa(a,x,M,k),U=H.state!=="empty";return d.useEffect(()=>{!U&&y==="connected"&&S("apps")},[U,y]),$?t.jsx(de,{title:$.label,subtitle:t.jsx("code",{children:$.id}),onClose:e,size:"xl",headerRight:t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>_(null),children:"← Back"}),children:t.jsx("div",{className:"w6w-stepbuilder-config",children:t.jsx(Aa,{family:$.family,targetId:$.id,targetLabel:$.label,onAdd:n,onClose:e,onDraftChange:s})})}):A?t.jsx(de,{title:A.label,titleIcon:t.jsx(lt,{icon:A.icon,size:22}),subtitle:t.jsxs("code",{children:[A.app," · ",A.action]}),onClose:e,size:"xl",headerRight:t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>z(null),children:"← Back"}),children:t.jsx("div",{className:"w6w-stepbuilder-config",children:t.jsx(ka,{node:A,onAdd:n,onClose:e,onDraftChange:s,workflowId:c,upstreamSteps:p})})}):b?t.jsx(de,{title:b.displayName,subtitle:t.jsxs(t.Fragment,{children:[t.jsx("code",{children:b.id}),b.version&&` · v${b.version}`]}),onClose:e,size:"xl",titleIcon:t.jsx(je,{src:b.iconSvg,srcDark:b.iconSvgDark,brandColor:b.brandColor,name:b.displayName,theme:r,size:22}),children:t.jsx("div",{className:"w6w-stepbuilder-config",children:O?t.jsx(Ma,{appId:b.id,app:b,onClose:e,onChangeApp:()=>P(null),theme:r,initialConnection:h,onConnected:(F,B)=>N==null?void 0:N(F,B)}):t.jsx($a,{appId:b.id,app:b,onAdd:n,onClose:e,onDraftChange:s,onChangeApp:()=>P(null),theme:r,workflowId:c,stepId:u,upstreamSteps:p,initialAction:f,initialConnection:h,initialWith:g})})}):t.jsx(de,{title:l??"Add a node",onClose:e,size:"xl",children:t.jsxs("div",{className:"w6w-stepbuilder",children:[t.jsxs("nav",{className:"w6w-stepbuilder-sidebar",children:[U&&t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="connected"?" active":""}`,onClick:()=>S("connected"),children:"Ready to use"}),t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="apps"?" active":""}`,onClick:()=>S("apps"),children:"Apps"}),t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="ai"?" active":""}`,onClick:()=>S("ai"),children:"AI"}),a.includes("workflow")&&t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="workflows"?" active":""}`,onClick:()=>S("workflows"),children:"Workflows"}),a.includes("function")&&t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="functions"?" active":""}`,onClick:()=>S("functions"),children:"Functions"}),!o&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="triggers"?" active":""}`,onClick:()=>S("triggers"),children:"Triggers"}),t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="controls"?" active":""}`,onClick:()=>S("controls"),children:"Controls"}),t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="utilities"?" active":""}`,onClick:()=>S("utilities"),children:"Utilities"}),t.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${y==="data"?" active":""}`,onClick:()=>S("data"),children:"Data"})]})]}),t.jsx("div",{className:"w6w-stepbuilder-content",children:y==="connected"?t.jsx(Oa,{data:H,onSelectApp:P,onSelectCallable:_,theme:r}):y==="functions"?t.jsx(In,{family:"function",excludeIds:M,onSelect:F=>_({family:"function",...F})}):y==="workflows"?t.jsx(In,{family:"workflow",excludeIds:M,onSelect:F=>_({family:"workflow",...F})}):y==="apps"?t.jsx(Se,{onSelectApp:P,theme:r,filter:x,ids:k}):y==="ai"?t.jsx(Se,{onSelectApp:P,theme:r,category:j?void 0:"ai",ids:k,filter:F=>{var B;return((x==null?void 0:x(F))??!0)&&(j||(((B=F.categories)==null?void 0:B.includes("ai"))??!1))},searchPlaceholder:"Search AI apps…",emptyMessage:"No AI apps registered yet."}):y==="triggers"?t.jsx(ga,{onSelect:z,workflowId:c,onClose:e}):y==="controls"?t.jsx(va,{onSelect:z}):y==="data"?t.jsx(Na,{onSelect:z}):t.jsx(ja,{onSelect:z})})]})})}function dt({nodes:e,onSelect:n}){return t.jsx("div",{className:"w6w-stepbuilder-list",children:e.map(s=>t.jsxs("button",{type:"button",className:"w6w-stepbuilder-item",onClick:()=>n(s),children:[t.jsx(lt,{icon:s.icon,size:24}),t.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[t.jsx("strong",{children:s.label}),t.jsxs("code",{className:"w6w-muted w6w-small",children:[s.app," · ",s.action]})]})]},`${s.app}:${s.action}`))})}function ga({onSelect:e,workflowId:n,onClose:s}){const r=Ie.filter(a=>a.group==="trigger"),o=re();return t.jsxs("div",{className:"w6w-stack",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:"Triggers start a workflow — run it manually or on an inbound webhook."}),t.jsx(dt,{nodes:r,onSelect:e}),n&&o.listTriggerApps&&t.jsx(xa,{workflowId:n,onClose:s})]})}function ba(e){return(e.triggerCount??0)>0}function xa({workflowId:e,onClose:n}){const s=re(),r=typeof s.listAppsPage=="function",[o,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null);return d.useEffect(()=>{if(r)return;const p=s.listTriggerApps;if(!p)return;let w=!1;return p().then(f=>!w&&a(f)).catch(f=>!w&&l(f.message)),()=>{w=!0}},[s,r]),!r&&!s.listTriggerApps?null:t.jsxs("div",{className:"w6w-stack",children:[t.jsxs("p",{className:"w6w-muted w6w-small",children:[t.jsx("strong",{children:"App triggers"})," — bind one of these apps' declared triggers to this workflow."]}),c?t.jsx(ya,{app:c,workflowId:e,onBack:()=>u(null),onClose:n}):r?t.jsx(Se,{onSelectApp:u,filter:ba,search:!0,searchPlaceholder:"Search apps with triggers…",emptyMessage:"No apps declare triggers yet."}):i?t.jsx("div",{className:"w6w-result w6w-error",children:i}):t.jsx(Se,{apps:o,onSelectApp:u,search:!1,emptyMessage:"No apps declare triggers yet."})]})}function ya({app:e,workflowId:n,onBack:s,onClose:r}){const o=re(),[a,i]=d.useState(null),[l,c]=d.useState(null),[u,p]=d.useState(!1),[w,f]=d.useState(null),[h,g]=d.useState("5");d.useEffect(()=>{const N=o.getAppTriggers;if(!N)return;let M=!1;return N(e.id).then(y=>!M&&i(y)).catch(y=>!M&&c(y.message)),()=>{M=!0}},[o,e.id]);const x=N=>Math.max(1,Math.ceil((N.minIntervalMs??0)/6e4)),k=N=>{if(N.type!=="poll")return O(N.key);c(null),f(N),g(String(Math.max(5,Math.ceil((N.minIntervalMs??0)/6e4))))},O=(N,M)=>{const y=o.createSubscription;y&&(c(null),p(!0),y(e.id,N,{workflowId:n,connectionId:null,params:{},...M===void 0?{}:{intervalMs:M}}).then(()=>r()).catch(S=>{p(!1),c(S instanceof Error?S.message:String(S))}))};return t.jsxs("div",{className:"w6w-stack",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:s,children:"← Back"}),t.jsx("strong",{children:e.displayName}),l&&t.jsx("div",{className:"w6w-result w6w-error",children:l}),a===null?t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading triggers…"}):a.length===0?t.jsx("p",{className:"w6w-muted w6w-small",children:"This app declares no triggers."}):t.jsx("div",{className:"w6w-stepbuilder-list",children:a.map(N=>t.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:u,onClick:()=>k(N),children:t.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[t.jsx("strong",{children:N.title}),t.jsx("code",{className:"w6w-muted w6w-small",children:N.key}),N.description&&t.jsx("span",{className:"w6w-muted w6w-small",children:N.description})]})},N.key))}),w&&t.jsxs("div",{className:"w6w-stack",children:[t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Check every … minutes"}),t.jsx("input",{type:"number",min:x(w),step:1,value:h,disabled:u,onChange:N=>g(N.target.value),onBlur:()=>g(String(On(h,x(w))))})]}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-primary w6w-btn-sm",disabled:u,onClick:()=>O(w.key,On(h,x(w))*6e4),children:"Add trigger"})]})]})}function va({onSelect:e}){const n=Ie.filter(s=>s.group==="control"&&!s.hidden);return t.jsxs("div",{className:"w6w-stack",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:"Flow-control nodes branch, loop, parallelize, or pause the run."}),t.jsx(dt,{nodes:n,onSelect:e})]})}function ja({onSelect:e}){const n=Ie.filter(s=>s.group!=="control"&&s.group!=="trigger"&&s.app!==Ze&&!s.hidden);return t.jsxs("div",{className:"w6w-stack",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:"Utilities run a script, call an HTTP(S) endpoint, or respond to a webhook."}),t.jsx(dt,{nodes:n,onSelect:e})]})}function Na({onSelect:e}){const n=Ie.filter(s=>s.app===Ze);return t.jsxs("div",{className:"w6w-stack",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:"Declare typed key/value variables for downstream steps to reference."}),t.jsx(dt,{nodes:n,onSelect:e})]})}function ka({node:e,onAdd:n,onClose:s,onDraftChange:r,workflowId:o,upstreamSteps:a=[]}){const[i,l]=d.useState(()=>Vn(e.app,e.action)),c=!We(e.app),u=sn(o??"",a,c&&!!o),p=nn(u),[w,f]=d.useState("configure"),[h,g]=d.useState("props"),[x,k]=d.useState("{}"),[O,N]=d.useState("{}"),[M,y]=d.useState({}),S=Te(e.params,i),[b,P]=d.useState(null),A=()=>({uses:{app:e.app,action:e.action},with:i,...M});d.useEffect(()=>{if(!r)return;const _=n(A());_&&P(_)},[]),d.useEffect(()=>{!r||b===null||r(b,A())},[b,i,M]);const z=_=>{_==="code"?k(en(A())):_==="params-code"&&N(tn(A())),g(_)},$=()=>n(A());return t.jsxs("div",{className:"w6w-stepconfig",children:[t.jsxs("div",{className:"w6w-tabsbar",children:[t.jsxs("div",{className:"w6w-subtabs",children:[t.jsx("button",{type:"button",className:`w6w-subtab${w==="configure"?" active":""}`,onClick:()=>f("configure"),children:"Configure"}),c&&t.jsx("button",{type:"button",disabled:!S,title:S?void 0:"Fill the required fields first",className:`w6w-subtab${w==="test"?" active":""}`,onClick:()=>S&&f("test"),children:"Test"})]}),t.jsx(ct,{view:h,onChange:z,disabled:w!=="configure"})]}),t.jsxs("div",{className:"w6w-stepconfig-body",children:[w==="configure"&&(h==="props"?e.action==="wait"&&We(e.app)?t.jsx(Ss,{values:i,onChange:l}):t.jsx(ve,{params:e.params,values:i,onChange:l}):h==="code"?t.jsx(xe,{value:x,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):h==="params-code"?t.jsx(xe,{value:O,onChange:N,minHeight:"240px",height:"100%","aria-label":"Parameters JSON",copyable:!0,onValidChange:_=>_&&typeof _=="object"&&!Array.isArray(_)&&l(_)}):t.jsx(Ut,{config:M,onChange:y,failureHandling:!ze(e.app),retryControls:!We(e.app)&&e.app!==et})),w==="test"&&c&&(ze(e.app)?t.jsx(Cs,{app:e.app,action:e.action,fields:i.fields}):t.jsx(rn,{app:e.app,action:e.action,values:i,canRun:S,state:p}))]}),t.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),w==="configure"&&c?t.jsx("button",{type:"button",className:"w6w-btn",disabled:!S,onClick:()=>f("test"),children:"Next →"}):t.jsx("button",{type:"button",className:"w6w-btn",onClick:b!==null?s:$,children:b!==null?"Done":"Add node"})]})]})}function In({family:e,excludeIds:n,onSelect:s}){const r=re(),[o,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(""),p=e==="function"?"Functions":"Workflows";d.useEffect(()=>{let k=!1;return(e==="function"?r.listFunctions():r.listWorkflows()).then(N=>!k&&a(N)).catch(N=>!k&&l(N.message)),()=>{k=!0}},[r,e]);const w=k=>t.jsx("div",{className:"w6w-apppicker-host",children:k});if(i)return w(t.jsx("div",{className:"w6w-result w6w-error",children:i}));if(o===null)return w(t.jsxs("p",{className:"w6w-muted w6w-small",children:["Loading ",p.toLowerCase(),"…"]}));if(o.length===0)return w(t.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",p.toLowerCase()," registered yet."]}));const f=Xe,h=c.trim().toLowerCase(),g=Ft(o,n).sort(Ue(f)),x=h?g.filter(k=>f(k).toLowerCase().includes(h)||k.id.toLowerCase().includes(h)):g;return w(t.jsxs("div",{className:"w6w-stepbuilder-apps",children:[t.jsx("input",{type:"text",className:"w6w-stepbuilder-search",placeholder:`Search ${p.toLowerCase()}…`,value:c,onChange:k=>u(k.target.value),"aria-label":`Search ${p.toLowerCase()}`}),x.length===0?t.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",p.toLowerCase()," match “",c,"”."]}):t.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:x.map(k=>t.jsx(Lt,{family:e,item:k,onSelect:s},k.id))})]}))}const Ca=["string","number","boolean","json"];function Sa(e){var o;const n=(e.nodes??e.steps??[]).find(a=>ze(a.uses.app)),s=(o=n==null?void 0:n.with)==null?void 0:o.fields;if(!Array.isArray(s))return[];const r=[];for(const a of s){if(typeof a!="object"||a===null)continue;const i=a,l=typeof i.key=="string"?i.key:"";if(!l)continue;const c=typeof i.type=="string"?i.type:"string";r.push({key:l,label:l,type:Ca.includes(c)?c:"string",default:i.default,required:!!i.required})}return r}function Aa({family:e,targetId:n,targetLabel:s,onAdd:r,onClose:o,onDraftChange:a}){const i=re(),[l,c]=d.useState(null),[u,p]=d.useState(null),[w,f]=d.useState({}),[h,g]=d.useState(!0),[x,k]=d.useState("configure"),[O,N]=d.useState(null);d.useEffect(()=>{let b=!1;return c(null),p(null),(e==="function"?i.getFunction(n).then(A=>A.inputs):i.getWorkflow(n).then(Sa)).then(A=>!b&&c(A)).catch(A=>!b&&p(A.message)),()=>{b=!0}},[i,e,n]);const M=l!==null&&Te(l,w),y=()=>({uses:{app:et,action:"call"},with:{targetKind:e,targetId:n,inputs:w,wait:h}});d.useEffect(()=>{if(!a)return;const b=r(y());b&&N(b)},[]),d.useEffect(()=>{!a||O===null||a(O,y())},[O,w,h]);const S=()=>r(y());return t.jsxs("div",{className:"w6w-stepconfig",children:[t.jsx("div",{className:"w6w-tabsbar",children:t.jsxs("div",{className:"w6w-subtabs",children:[t.jsx("button",{type:"button",className:`w6w-subtab${x==="configure"?" active":""}`,onClick:()=>k("configure"),children:"Configure"}),t.jsx("button",{type:"button",disabled:!M,title:M?void 0:"Fill the required fields first",className:`w6w-subtab${x==="test"?" active":""}`,onClick:()=>M&&k("test"),children:"Test"})]})}),t.jsx("div",{className:"w6w-stepconfig-body",children:x==="configure"?t.jsxs("div",{className:"w6w-stack",children:[u?t.jsx("div",{className:"w6w-result w6w-error",children:u}):l===null?t.jsxs("p",{className:"w6w-muted w6w-small",children:["Loading ",s,"’s inputs…"]}):l.length===0?t.jsxs("p",{className:"w6w-muted w6w-small",children:[s," declares no inputs — it can be called as-is."]}):t.jsx(ve,{params:l,values:w,onChange:f}),t.jsxs("label",{className:"w6w-field",children:[t.jsxs("span",{children:[t.jsx("input",{type:"checkbox",checked:h,onChange:b=>g(b.target.checked)})," ","Wait for completion"]}),t.jsx("span",{className:"w6w-hint",children:"On: block until the sub-run finishes and expose its output. Off: return a run handle and continue."})]})]}):t.jsx(Ea,{family:e,targetId:n,inputs:w,canRun:M})}),t.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:o,children:"Cancel"}),x==="configure"?t.jsx("button",{type:"button",className:"w6w-btn",disabled:!M,onClick:()=>k("test"),children:"Next →"}):t.jsx("button",{type:"button",className:"w6w-btn",onClick:O!==null?o:S,children:O!==null?"Done":"Add node"})]})]})}function Ea({family:e,targetId:n,inputs:s,canRun:r}){const o=re(),[a,i]=d.useState(null),l=async()=>{if(!(!r||(a==null?void 0:a.status)==="running")){i({status:"running"});try{if(e==="function"){const c=await o.invokeFunction(n,s);i({status:"done",output:c,terminal:!0})}else{const c=await o.runWorkflow(n,{input:s});i({status:"done",output:c.output,runId:c.runId,terminal:c.terminal,error:c.error})}}catch(c){i({status:"error",error:c.message??String(c)})}}};return t.jsxs("div",{className:"w6w-steptest",children:[t.jsxs("div",{className:"w6w-steptest-bar",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!r||(a==null?void 0:a.status)==="running",onClick:l,children:(a==null?void 0:a.status)==="running"?"Running…":"▶ Test run"}),!r&&t.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),(a==null?void 0:a.status)==="error"&&t.jsx("div",{className:"w6w-result w6w-error",children:a.error}),(a==null?void 0:a.status)==="done"&&!a.terminal&&t.jsxs("div",{className:"w6w-testout",children:[t.jsx("div",{className:"w6w-testout-label",children:"Still running"}),t.jsxs("div",{className:"w6w-result",children:["Run ",t.jsx("code",{children:a.runId})," has not finished yet — check its status from the workflow's run history."]})]}),(a==null?void 0:a.status)==="done"&&a.terminal&&a.error!==void 0&&t.jsxs("div",{className:"w6w-testout",children:[t.jsx("div",{className:"w6w-testout-label",children:"Run failed"}),t.jsx("pre",{className:"w6w-result w6w-error",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(a.error,null,2)})]}),(a==null?void 0:a.status)==="done"&&a.terminal&&a.error===void 0&&t.jsxs("div",{className:"w6w-testout",children:[t.jsx("div",{className:"w6w-testout-label",children:"Result"}),t.jsx("pre",{className:"w6w-result",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(a.output,null,2)})]})]})}function Te(e,n){const s=Ee(e),r=a=>{var i;return n[a]!==void 0?n[a]:(i=s.find(l=>l.key===a))==null?void 0:i.default},o=(a,i,l)=>a.every(c=>{if(c.type==="section")return o(c.children??[],i,l);if(c.type==="group"){const p=c.children??[],w=Ee(p),f=g=>x=>{const k=w.find(O=>O.key===x);return k?g[x]!==void 0?g[x]:k.default:l(x)};if(c.repeat){const g=Array.isArray(i[c.key])?i[c.key]:[];return g.length===0?!c.required:g.every(x=>{const k=x??{};return o(p,k,f(k))})}const h=i[c.key]??{};return o(p,h,f(h))}if(!c.required||!qe(c,l))return!0;const u=i[c.key]??c.default;return u==null?!1:typeof u=="string"?u.trim()!=="":!0});return o(e,n,r)}function $s(e){const n=e==null?void 0:e.testRequired;return typeof n=="boolean"?n:!0}function Ta(e){const n=e;return(n==null?void 0:n.body)??(n==null?void 0:n.raw)??{error:n==null?void 0:n.code,message:(n==null?void 0:n.message)??String(e)}}function Ia(e){const n=e==null?void 0:e.apiCalls;return Array.isArray(n)?n:[]}const Rn={whiteSpace:"pre-wrap",maxHeight:320,overflow:"auto",margin:0};function Ra({log:e,onClose:n}){return t.jsx(de,{title:"Test run log",subtitle:e.startedAt,size:"wide",onClose:n,children:t.jsxs("div",{className:"w6w-modal-body w6w-stack",style:{gap:12},children:[t.jsxs("div",{className:"w6w-testout",children:[t.jsxs("div",{className:"w6w-testout-label",children:["Request to w6w · ",e.request.method," ",e.request.path]}),t.jsx("pre",{className:"w6w-result",style:Rn,children:JSON.stringify(e.request.body,null,2)})]}),t.jsxs("div",{className:"w6w-testout",children:[t.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"]}),t.jsx("pre",{className:"w6w-result",style:Rn,children:JSON.stringify(e.response.body,null,2)})]}),t.jsxs("div",{className:"w6w-testout",children:[t.jsxs("div",{className:"w6w-testout-label",children:["Outbound API calls (",e.apiCalls.length,")"]}),e.apiCalls.length>0?t.jsx(As,{calls:e.apiCalls,title:!1,defaultOpen:!0}):t.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","."]})]})]})})}const rn=d.forwardRef(function({app:n,action:s,connectionId:r,values:o,canRun:a,hideRunButton:i,persist:l,state:c,onBusyChange:u,onResult:p},w){const f=re(),h=Vt(),[g,x]=d.useState(null),[k,O]=d.useState(null),[N,M]=d.useState(!1),y=async()=>{if(!a||(g==null?void 0:g.status)==="running")return;x({status:"running"}),u==null||u(!0);let b;const P=new Date,A={method:"POST",path:`/apps/${encodeURIComponent(n)}/actions/${encodeURIComponent(s)}/invoke`,body:{params:o,...r?{connectionId:r}:{},...h?{project:h}:{},...c?{state:c}:{}}},z=$=>O({startedAt:P.toLocaleString(),durationMs:Date.now()-P.getTime(),request:A,response:$,apiCalls:Ia($.body)});try{const $=await f.invokeAction(n,s,o,{...r?{connectionId:r}:{},project:h,...c?{state:c}:{}});z({ok:!0,body:$}),b={status:"done",value:$.value,logs:$.logs,...$.meta?{meta:$.meta}:{}}}catch($){const _=$;z({ok:!1,...typeof _.status=="number"?{status:_.status}:{},body:Ta($)}),b={status:"error",error:_.message??String($),errorCode:_.code,logs:_.logs}}if(x(b),p==null||p(b.status==="done"),l)try{const $=await f.saveStepTest(l.workflowId,l.stepId,{input:l.input,with:o});await f.recordStepTestRun(l.workflowId,l.stepId,{stepTestId:$.id,status:b.status==="done"?"succeeded":"failed",input:l.input,output:b.status==="done"?b.value:void 0,error:b.status==="error"?b.error:void 0,...b.status==="done"&&b.meta?{meta:b.meta}:{}})}catch($){console.error("step test persist failed",$)}u==null||u(!1)};d.useImperativeHandle(w,()=>({run:y}));const S=g&&g.status!=="running"?g.logs:void 0;return t.jsxs("div",{className:"w6w-steptest",children:[(!i||k)&&t.jsxs("div",{className:"w6w-steptest-bar",children:[!i&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!a||(g==null?void 0:g.status)==="running",onClick:y,children:(g==null?void 0:g.status)==="running"?"Running…":"▶ Test run"}),k&&(g==null?void 0:g.status)!=="running"&&t.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>M(!0),title:"The full request and response of the last test run",children:["Log",k.apiCalls.length>0?` (${k.apiCalls.length})`:""]}),!i&&!a&&t.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),N&&k&&t.jsx(Ra,{log:k,onClose:()=>M(!1)}),(g==null?void 0:g.status)==="error"&&t.jsxs("div",{className:"w6w-result w6w-error",children:[g.errorCode&&t.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:t.jsx("code",{children:g.errorCode})}),g.error]}),(g==null?void 0:g.status)==="done"&&t.jsxs("div",{className:"w6w-testout",children:[t.jsx("div",{className:"w6w-testout-label",children:"Result (return value)"}),t.jsx("pre",{className:"w6w-result",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(g.value,null,2)}),g.meta&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),t.jsx("pre",{className:"w6w-result",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(g.meta,null,2)})]})]}),S&&S.length>0&&t.jsxs("div",{className:"w6w-testout",children:[t.jsx("div",{className:"w6w-testout-label",children:"Console output"}),t.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:S.join(`
|
|
13
|
+
`)})]})]})}),Pn=12,Ve=new Set;function On(e,n){const s=Number(e.trim());return e.trim()===""||!Number.isFinite(s)||s<n?n:Math.max(n,Math.round(s))}function Pa(e,n,s,r){const o=r&&r.length>0?new Set(r):null,a=V=>(o?o.has(V.id):!0)&&((n==null?void 0:n(V))??!0),i=re(),[l,c]=d.useState(null),[u,p]=d.useState(null),[w,f]=d.useState(null),[h,g]=d.useState(null),[x,k]=d.useState(null),[O,N]=d.useState(()=>new Map),[M,y]=d.useState(()=>new Set),[S,b]=d.useState(Ve),P=d.useRef(Ve),A=d.useCallback(V=>{P.current=V,b(V)},[]),z=d.useRef(Ve),$=e.includes("function"),_=e.includes("workflow"),j=typeof i.listAppsByIds=="function";d.useEffect(()=>{let V=!1;const G=J=>!V&&k(J.message);return i.listConnections().then(J=>{if(V)return;const v=[],C=new Set,T=new Map;for(const L of J)ke(L.appId)||(j&&L.app&&!T.has(L.appId)&&T.set(L.appId,{...L.app,id:L.appId}),!C.has(L.appId)&&(C.add(L.appId),v.push(L.appId)));T.size>0&&(z.current=new Set(T.keys()),N(L=>new Map([...L,...T])),y(L=>new Set([...L,...T.keys()]))),c(v)}).catch(G),$?i.listFunctions().then(J=>!V&&f(J)).catch(G):f([]),_?i.listWorkflows().then(J=>!V&&g(J)).catch(G):g([]),()=>{V=!0}},[i,j,$,_]),d.useEffect(()=>{if(j)return;const V=i.listApps;if(typeof V!="function"){p([]);return}let G=!1;return V().then(J=>!G&&p(J)).catch(J=>!G&&k(J.message)),()=>{G=!0}},[i,j]);const H=d.useRef(!0);d.useEffect(()=>()=>{H.current=!1},[]);const U=d.useCallback(V=>{const G=i.listAppsByIds;!G||V.length===0||P.current.size>0||(A(new Set(V)),G(V).then(J=>{H.current&&(A(Ve),N(v=>{const C=new Map(v);for(const T of J)C.set(T.id,T);return C}),y(v=>new Set([...v,...V])))}).catch(J=>H.current&&k(J.message)))},[i,A]),F=d.useRef(!1);d.useEffect(()=>{if(!j||l===null||F.current)return;const V=xt(l,z.current,Pn);V.length!==0&&(F.current=!0,U(V))},[j,l,U]);const B=()=>{if(!j||l===null||P.current.size>0)return;const V=new Set([...M,...P.current]);U(xt(l,V,Pn))};if(x)return{state:"error",error:x,apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:B};if(w===null||h===null)return{state:"loading",apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:B};const Y=Ft(w,s),K=Ft(h,s);if(j){if(l===null)return{state:"loading",apps:[],fns:Y,wfs:K,moreApps:!1,loadMoreApps:B};if(l.length>0&&M.size===0)return{state:"loading",apps:[],fns:Y,wfs:K,moreApps:!1,loadMoreApps:B};const V=br(l,O).filter(a),G=S.size===0&&xt(l,new Set([...M,...S]),1).length>0;return{state:V.length===0&&Y.length===0&&K.length===0&&!G?"empty":"ready",apps:V,fns:Y,wfs:K,moreApps:G,loadMoreApps:B}}if(u===null)return{state:"loading",apps:[],fns:Y,wfs:K,moreApps:!1,loadMoreApps:B};const X=new Set(l??[]),Z=u.filter(V=>!ke(V.id)&&a(V)&&(X.has(V.id)||V.zeroCredential===!0));return{state:Z.length===0&&Y.length===0&&K.length===0?"empty":"ready",apps:Z,fns:Y,wfs:K,moreApps:!1,loadMoreApps:B}}function Ft(e,n){return n&&n.length>0?e.filter(s=>!n.includes(s.id)):[...e]}function Ue(e){return(n,s)=>e(n).localeCompare(e(s),void 0,{sensitivity:"base"})}function Xe(e){const n=e.displayName;return n!=null&&n.trim()?n:"name"in e?e.name:e.id}function Lt({family:e,item:n,onSelect:s}){const r=Xe(n);return t.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-stepbuilder-item--callable","data-kind":e,onClick:()=>s({id:n.id,label:r}),children:[t.jsx(lt,{icon:ha[e],size:24}),t.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[t.jsx("strong",{children:r}),t.jsx("code",{className:"w6w-muted w6w-small",children:n.id})]})]})}function Oa({data:e,onSelectApp:n,onSelectCallable:s,theme:r}){const o=h=>t.jsx("div",{className:"w6w-apppicker-host",children:h});if(e.state==="error")return o(t.jsx("div",{className:"w6w-result w6w-error",children:e.error}));if(e.state==="loading")return o(t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}));const a=[...e.apps].sort(Ue(h=>h.displayName)),i=[...e.fns].sort(Ue(Xe)),l=[...e.wfs].sort(Ue(Xe)),c=(h,g)=>g.length===0?null:t.jsxs("section",{className:"w6w-readytouse-col",children:[t.jsx("h4",{className:"w6w-readytouse-heading",children:h}),t.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:g})]},h),u=a.map(h=>t.jsxs("button",{type:"button",className:"w6w-stepbuilder-item","data-kind":"app",onClick:()=>n(h),children:[t.jsx(je,{src:h.iconSvg,srcDark:h.iconSvgDark,brandColor:h.brandColor,name:h.displayName,theme:r,size:24}),t.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[t.jsx("strong",{children:h.displayName}),t.jsx("code",{className:"w6w-muted w6w-small",children:h.id})]})]},h.id));e.moreApps&&u.push(t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:e.loadMoreApps,children:"Load more"},"__load_more_apps"));const p=c("Connected apps",u),w=[c("Functions",i.map(h=>t.jsx(Lt,{family:"function",item:h,onSelect:g=>s({family:"function",...g})},h.id))),c("Workflows",l.map(h=>t.jsx(Lt,{family:"workflow",item:h,onSelect:g=>s({family:"workflow",...g})},h.id)))].filter(Boolean),f=(p?1:0)+(w.length>0?1:0);return o(t.jsxs("div",{className:"w6w-readytouse","data-cols":f,children:[p,w.length>0&&t.jsx("div",{className:"w6w-readytouse-stack",children:w})]}))}function $a({appId:e,app:n,onAdd:s,onClose:r,onDraftChange:o,onChangeApp:a,theme:i,workflowId:l,stepId:c,upstreamSteps:u=[],initialAction:p,initialConnection:w,initialWith:f}){const h=re(),[g,x]=d.useState(null),[k,O]=d.useState(null),[N,M]=d.useState(null),[y,S]=d.useState(null),[b,P]=d.useState(w??""),[A,z]=d.useState(p??""),[$,_]=d.useState(f??{}),[j,H]=d.useState(!1),[U,F]=d.useState(!1),[B,Y]=d.useState(p&&f?"configure":"setup"),[K,X]=d.useState("props"),[Z,Q]=d.useState("{}"),[V,G]=d.useState("{}"),[J,v]=d.useState({});d.useEffect(()=>{let W=!1;return S(null),Promise.all([h.getAppAuth(e),h.listConnectionsForApp(e),h.getAppActions(e)]).then(([ne,ye,pt])=>{if(W)return;x(ne),O(ye),M(pt),!(ne??[]).some(wt=>wt.autoSatisfied===!0)&&ye.length>0&&P(ye[0].id)}).catch(ne=>!W&&S(ne.message)),()=>{W=!0}},[h,e]);const C=async()=>{const W=await h.listConnectionsForApp(e);O(W),W.length>0&&P(ne=>ne||W[0].id)},T=(g??[]).filter(W=>W.available!==!1),L=T.some(W=>W.autoSatisfied===!0&&(W.type==="tenantAuth"||W.type==="jit")),m=T.length>0&&!L,R=(k??[]).length>0,I=(N??[]).find(W=>W.key===A),E=[...N??[]].sort((W,ne)=>(W.title??W.key).localeCompare(ne.title??ne.key,void 0,{sensitivity:"base"})),D=$s(n),[te,le]=d.useState(!1);d.useEffect(()=>{if(!D||!l||!c)return;let W=!1;return h.listStepTests(l,c).then(ne=>{!W&&ne.some(ye=>ye.lastRunStatus==="succeeded")&&le(!0)}).catch(()=>{}),()=>{W=!0}},[h,D,l,c]);const oe=sn(l??"",u,!!l),ue=nn(oe),pe=!!A&&(!m||R&&!!b),me=pe&&!!I&&Te(I.params??[],$),ut=pe,ce=(k??[]).find(W=>W.id===b),Pe=U||!b;function he(){return{uses:{app:e,action:(I==null?void 0:I.key)??A,...(m||L)&&b?{connection:b}:{}},with:$,...J}}function Ne(){I&&s(he())}const[we,He]=d.useState(null);d.useEffect(()=>{if(!o||we!==null||!pe)return;const W=s(he());W&&He(W)},[o,we,pe]),d.useEffect(()=>{!o||we===null||o(we,he())},[we,$,J,b]);const Oe=W=>{W==="code"?Q(en(he())):W==="params-code"&&G(tn(he())),X(W)};return t.jsxs("div",{className:"w6w-stepconfig",children:[t.jsxs("div",{className:"w6w-tabsbar",children:[t.jsxs("div",{className:"w6w-subtabs",children:[t.jsx("button",{type:"button",className:`w6w-subtab${B==="setup"?" active":""}`,onClick:()=>Y("setup"),children:"Setup"}),t.jsx("button",{type:"button",disabled:!pe,title:pe?void 0:"Complete Setup first",className:`w6w-subtab${B==="configure"?" active":""}`,onClick:()=>pe&&Y("configure"),children:"Configure"}),t.jsx("button",{type:"button",disabled:!me,title:me?void 0:"Fill the required fields first",className:`w6w-subtab${B==="test"?" active":""}`,onClick:()=>me&&Y("test"),children:"Test"})]}),t.jsx(ct,{view:K,onChange:Oe,disabled:B!=="configure"})]}),t.jsxs("div",{className:"w6w-stepconfig-body",children:[B==="setup"&&t.jsxs("div",{className:"w6w-stack",children:[y&&t.jsx("div",{className:"w6w-result w6w-error",children:y}),g===null&&!y&&t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}),t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:"App"}),t.jsxs("div",{className:"w6w-conn-label",children:[n&&t.jsx(je,{src:n.iconSvg,srcDark:n.iconSvgDark,brandColor:n.brandColor,name:n.displayName,theme:i,size:20}),t.jsx("span",{className:"w6w-conn-label-name",children:(n==null?void 0:n.displayName)??e}),a&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:a,children:"Change"})]})]}),g!==null&&L&&t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:"Connection"}),t.jsxs("div",{className:"w6w-conn-label",children:[t.jsx("span",{className:"w6w-conn-label-name",children:"Connected automatically — this app needs no connection for your organization."}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>H(!0),children:"Create connection"})]}),t.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.'})]}),g!==null&&m&&(R?Pe?t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Connection"}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("select",{value:b,onChange:W=>{P(W.target.value),F(!1)},style:{flex:1},children:(k??[]).map(W=>t.jsxs("option",{value:W.id,children:[W.displayName||W.id," ",W.state?`(${W.state})`:""]},W.id))}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>H(!0),children:"+ New"})]})]}):t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:"Connection"}),t.jsxs("div",{className:"w6w-conn-label",children:[t.jsxs("span",{className:"w6w-conn-label-name",children:[(ce==null?void 0:ce.displayName)||(ce==null?void 0:ce.id)||b,ce!=null&&ce.state?` (${ce.state})`:""]}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>F(!0),children:"Change"}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>H(!0),children:"+ New"})]})]}):t.jsxs("div",{className:"w6w-result w6w-stepconfig-conn-empty",children:[t.jsx("div",{style:{marginBottom:8},children:"This app needs a connection before its actions can run."}),t.jsx("button",{type:"button",className:"w6w-btn",onClick:()=>H(!0),children:"Create connection"})]})),N!==null&&(N.length===0?t.jsx("p",{className:"w6w-muted w6w-small",children:"This app exposes no actions."}):t.jsxs("label",{className:"w6w-field",children:[t.jsxs("span",{children:["Action",A?"":" *"]}),t.jsx(nt,{value:A,placeholder:"— pick an action —",mode:"combobox",listMaxHeight:200,onChange:W=>{z(W),_({}),le(!1)},options:E.map(W=>({value:W.key,label:`${W.title??W.key} (${W.key})`}))}),(I==null?void 0:I.description)&&t.jsx("span",{className:"w6w-hint",children:I.description})]}))]}),B==="configure"&&(I?K==="props"?t.jsx(ve,{params:I.params??[],values:$,onChange:_,dynamic:{appId:e,actionKey:I.key,connectionId:b||void 0,appName:n==null?void 0:n.displayName}}):K==="code"?t.jsx(xe,{value:Z,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):K==="params-code"?t.jsx(xe,{value:V,onChange:G,minHeight:"240px",height:"100%","aria-label":"Parameters JSON",copyable:!0,onValidChange:W=>W&&typeof W=="object"&&!Array.isArray(W)&&_(W)}):t.jsx(Ut,{config:J,onChange:v}):t.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action in Setup first."})),B==="test"&&(I?t.jsx(rn,{app:e,action:I.key,connectionId:(m||L)&&b?b:void 0,values:$,canRun:pe&&Te(I.params??[],$),state:ue,onResult:le}):t.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action in Setup first."}))]}),B==="test"&&t.jsx("div",{className:"w6w-stepconfig-testnote",children:D&&!te&&t.jsx("span",{className:"w6w-muted w6w-small",children:"Not yet tested — a passing test is required before this step can be published."})}),t.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:r,children:"Cancel"}),B==="test"?t.jsx("button",{type:"button",className:"w6w-btn",disabled:we===null&&!ut,onClick:we!==null?r:Ne,children:we!==null?"Done":"Add node"}):t.jsx("button",{type:"button",className:"w6w-btn",disabled:B==="setup"?!pe:!me,onClick:()=>Y(B==="setup"?"configure":"test"),children:"Next →"})]}),j&&t.jsx(Wt,{theme:i,initialAppId:e,onClose:()=>H(!1),onCreated:async({connectionId:W})=>{H(!1),P(W),F(!1),await C()}})]})}function Ma({appId:e,app:n,onClose:s,onChangeApp:r,theme:o,initialConnection:a,onConnected:i}){const l=re(),[c,u]=d.useState(null),[p,w]=d.useState(null),[f,h]=d.useState(null),[g,x]=d.useState(a??""),[k,O]=d.useState(!1),[N,M]=d.useState(!1);d.useEffect(()=>{let j=!1;return h(null),Promise.all([l.getAppAuth(e),l.listConnectionsForApp(e)]).then(([H,U])=>{if(j)return;u(H),w(U),!(H??[]).some(B=>B.autoSatisfied===!0)&&U.length>0&&x(U[0].id)}).catch(H=>!j&&h(H.message)),()=>{j=!0}},[l,e]);const y=async()=>{const j=await l.listConnectionsForApp(e);w(j),j.length>0&&x(H=>H||j[0].id)},S=(c??[]).filter(j=>j.available!==!1),b=S.some(j=>j.autoSatisfied===!0&&(j.type==="tenantAuth"||j.type==="jit")),P=S.length>0&&!b,A=(p??[]).length>0,z=!P||A&&!!g,$=(p??[]).find(j=>j.id===g),_=N||!g;return t.jsxs("div",{className:"w6w-stepconfig",children:[t.jsx("div",{className:"w6w-stepconfig-body",children:t.jsxs("div",{className:"w6w-stack",children:[f&&t.jsx("div",{className:"w6w-result w6w-error",children:f}),c===null&&!f&&t.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}),t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:"App"}),t.jsxs("div",{className:"w6w-conn-label",children:[n&&t.jsx(je,{src:n.iconSvg,srcDark:n.iconSvgDark,brandColor:n.brandColor,name:n.displayName,theme:o,size:20}),t.jsx("span",{className:"w6w-conn-label-name",children:(n==null?void 0:n.displayName)??e}),r&&t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:r,children:"Change"})]})]}),c!==null&&b&&t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:"Connection"}),t.jsxs("div",{className:"w6w-conn-label",children:[t.jsx("span",{className:"w6w-conn-label-name",children:"Connected automatically — this app needs no connection for your organization."}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>O(!0),children:"Create connection"})]}),t.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&&P&&(A?_?t.jsxs("label",{className:"w6w-field",children:[t.jsx("span",{children:"Connection"}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("select",{value:g,onChange:j=>{x(j.target.value),M(!1)},style:{flex:1},children:(p??[]).map(j=>t.jsxs("option",{value:j.id,children:[j.displayName||j.id," ",j.state?`(${j.state})`:""]},j.id))}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>O(!0),children:"+ New"})]})]}):t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:"Connection"}),t.jsxs("div",{className:"w6w-conn-label",children:[t.jsxs("span",{className:"w6w-conn-label-name",children:[($==null?void 0:$.displayName)||($==null?void 0:$.id)||g,$!=null&&$.state?` (${$.state})`:""]}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>M(!0),children:"Change"}),t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>O(!0),children:"+ New"})]})]}):t.jsxs("div",{className:"w6w-result w6w-stepconfig-conn-empty",children:[t.jsx("div",{style:{marginBottom:8},children:"This app needs a connection before its actions can run."}),t.jsx("button",{type:"button",className:"w6w-btn",onClick:()=>O(!0),children:"Create connection"})]}))]})}),t.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),t.jsx("button",{type:"button",className:"w6w-btn",disabled:!z||!n,onClick:()=>n&&i(g,n),children:"Next →"})]}),k&&t.jsx(Wt,{theme:o,initialAppId:e,onClose:()=>O(!1),onCreated:async({connectionId:j})=>{O(!1),x(j),M(!1),await y()}})]})}const Fa=["props","code"];function La(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ms({params:e,values:n,onChange:s,onValidityChange:r,readOnly:o,initialView:a="props"}){const i=e.length>0,[l,c]=d.useState(a),u=!i||l==="code",[p,w]=d.useState(()=>$n(n)),[f,h]=d.useState(!0),g=d.useRef(!0),x=N=>{N!==g.current&&(g.current=N,h(N),r==null||r(N))},k=N=>{N==="code"&&w($n(n)),x(!0),c(N)},O=i?"Values (JSON)":"Payload";return t.jsxs("div",{className:"w6w-stack",children:[i&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx(ct,{view:l,views:[...Fa],onChange:N=>k(N)})}),u?t.jsxs("div",{className:"w6w-field",children:[t.jsx("span",{children:O}),t.jsx(xe,{value:p,onChange:w,readOnly:o,minHeight:"140px","aria-label":`${O} JSON`,onValidChange:N=>{const M=La(N);x(M),M&&s(N)},onValidityChange:N=>{N.valid||x(!1)}}),!f&&t.jsx("span",{className:"w6w-hint",children:"This draft isn’t a JSON object yet — the collected values are unchanged until it is."})]}):t.jsx(ve,{params:e,values:n,onChange:s,readOnly:o})]})}function $n(e){return JSON.stringify(e??{},null,2)}function Da({title:e,message:n,onConfirm:s,onClose:r,confirmLabel:o="Confirm",cancelLabel:a="Cancel",destructive:i=!0,children:l}){return t.jsxs(de,{title:e,onClose:r,children:[t.jsxs("div",{className:"w6w-modal-body",children:[t.jsx("p",{className:"w6w-muted w6w-small",children:n}),l]}),t.jsxs("div",{className:"w6w-modal-actions",children:[t.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:r,children:a}),t.jsx("button",{type:"button",className:i?"w6w-btn w6w-btn-danger":"w6w-btn",onClick:s,children:o})]})]})}exports.AddConnectionModal=Wt;exports.ApiCallsPanel=As;exports.AppIcon=je;exports.AppPicker=Se;exports.AuthFieldsForm=Be;exports.CALL_APP=et;exports.CONTROL_APP=ge;exports.CanvasLayer=Xr;exports.CodeEditor=ns;exports.Combobox=nt;exports.ConfigViewToggle=ct;exports.ConfirmModal=Da;exports.CredentialPicker=Jn;exports.DATA_APP=Ze;exports.EDITOR_THEME_SPEC=Bt;exports.ERROR_SOURCE_HANDLE=Dt;exports.ExpressionInput=Kt;exports.ExpressionOptionsProvider=mo;exports.INTERNAL_NODES=Ie;exports.IconButton=zt;exports.InternalIcon=lt;exports.JsonEditor=xe;exports.Markdown=Qn;exports.Modal=de;exports.NodeConfigForm=Ut;exports.ParamsForm=ve;exports.PropertyEntryForm=Ms;exports.RetryPolicyFields=ts;exports.SCHEDULER_APP=qt;exports.SCRIPT_APP=qn;exports.StepBuilderModal=ma;exports.StepTestRun=rn;exports.TRIGGER_APP=Qe;exports.TriggerFillForm=Cs;exports.W6WUIProvider=xr;exports.WEBHOOK_APP=_t;exports.WaitEditor=Ss;exports.WorkflowProjectProvider=yr;exports.asFieldDefs=Zt;exports.bindingFieldsFor=Gn;exports.buildBinding=Kn;exports.buildResolveScope=fs;exports.coerceDefault=Ns;exports.deepEqual=Pt;exports.edgeVisuals=Dn;exports.excludeSelfStep=fo;exports.fieldWidget=js;exports.fieldsToParams=Qt;exports.filterOptions=rs;exports.findChainRoot=ta;exports.findChainTail=na;exports.flattenParams=Ee;exports.flowEdgeId=Ke;exports.flowToWorkflow=Xo;exports.idClashMessage=Wo;exports.internalNodeDefaults=Vn;exports.internalNodeIcon=wr;exports.internalNodeLabel=pr;exports.internalNodeParams=Hn;exports.isControlApp=We;exports.isExprValue=_e;exports.isFormResolvedOptions=st;exports.isInternalApp=ke;exports.isParamVisible=qe;exports.isSecretValue=rt;exports.isTestRequired=$s;exports.isTriggerApp=ze;exports.laneForSourceHandle=Bs;exports.nodePortsForStep=Xs;exports.paramsToJson=tn;exports.parseJsonFields=kt;exports.relayoutNodes=Yo;exports.requiredParamsFilled=Te;exports.resolveParamJson=Xt;exports.resolveParamValue=bs;exports.resolveVarsJson=Co;exports.seedValues=ks;exports.shouldUseCombobox=ss;exports.slugifyLabel=ea;exports.sourceHandleForLane=_n;exports.splitFrontmatter=Zn;exports.startOAuthPopup=Yn;exports.startStateFromSeeds=nn;exports.stepBuilderUpstreamSteps=da;exports.stepIdError=Vo;exports.stepMetaSampleValues=pa;exports.stepToJson=en;exports.storedViewport=Rs;exports.suggestStepId=sa;exports.upstreamStateSources=ca;exports.useEffectiveTheme=tt;exports.useEnterSubmit=Xn;exports.useExpressionOptions=ot;exports.useSeedSources=sn;exports.useW6WApi=re;exports.valueAtPath=ia;exports.varLabel=Ae;exports.withViewport=Zo;exports.workflowToFlow=Ko;
|
|
14
|
+
//# sourceMappingURL=ConfirmModal-fjHW5rN-.cjs.map
|