@w6w/ui 0.1.0 → 0.1.1
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 +20 -0
- package/README.md +18 -3
- package/dist/ConfirmModal-8avl9Nv8.cjs +11 -0
- package/dist/ConfirmModal-8avl9Nv8.cjs.map +1 -0
- package/dist/{ConfirmModal-sY1tzkBO.js → ConfirmModal-CD-P8mhN.js} +3822 -3822
- package/dist/ConfirmModal-CD-P8mhN.js.map +1 -0
- package/dist/code.cjs +1 -1
- package/dist/code.mjs +1 -0
- package/dist/code.mjs.map +1 -1
- package/dist/flow.cjs +1 -1
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.d.ts +3 -1
- package/dist/flow.mjs +50 -49
- package/dist/flow.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/provider.d.ts +2 -1
- package/package.json +2 -1
- package/src/code.css +23 -4
- package/src/styles/_flow.scss +4 -4
- package/src/styles/_tokens.scss +23 -4
- package/src/styles.css +695 -9
- package/dist/ConfirmModal-DJPYXE9t.cjs +0 -11
- package/dist/ConfirmModal-DJPYXE9t.cjs.map +0 -1
- package/dist/ConfirmModal-sY1tzkBO.js.map +0 -1
- package/dist/ui.css +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var $s=Object.defineProperty;var Cs=(s,t,n)=>t in s?$s(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var V=(s,t,n)=>Cs(s,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./ConfirmModal-DJPYXE9t.cjs"),e=require("react/jsx-runtime"),m=require("react"),X=require("./CodeBlock-CZu4TFSi.cjs"),Os=require("@codemirror/lang-yaml"),Rs=require("@codemirror/view"),Es=require("@uiw/react-codemirror"),b=require("./Copyable-CYZU1o4X.cjs");class z extends Error{constructor(n,l,c,a){super(c);V(this,"status");V(this,"code");V(this,"body");this.name="ApiError",this.status=n,this.code=l,this.body=a}}function Ts(s){const t=s.baseUrl.replace(/\/$/,""),n=s.fetch??globalThis.fetch,l=async()=>typeof s.token=="function"?await s.token():s.token;async function c(r,o){const d=new Headers(o==null?void 0:o.headers),u=await l();u&&d.set("authorization",`Bearer ${u}`),o!=null&&o.body&&!d.has("content-type")&&d.set("content-type","application/json");let h;try{h=await n(`${t}${r}`,{...o,headers:d})}catch(j){throw new z(0,"network_error",`Could not reach the w6w server (${(o==null?void 0:o.method)??"GET"} ${t}${r}). It may be down or unreachable. (${j.message})`)}const p=await h.text();let x=null;if(p)try{x=JSON.parse(p)}catch{if(!h.ok)throw new z(h.status,"bad_response",`Server returned a non-JSON ${h.status} response: ${p.slice(0,200)}`)}if(!h.ok){const j=(x==null?void 0:x.error)??{};throw new z(h.status,j.code??"error",j.message??h.statusText,x)}return{status:h.status,data:x}}async function a(r,o){const{data:d}=await c(r,o);return d}return{listApps:async()=>{const r=[];let o;for(let d=0;d<20;d++){const u=new URLSearchParams({limit:"200"});o&&u.set("cursor",o);const h=await a(`/apps?${u}`);if(r.push(...h.apps),!h.nextCursor)break;o=h.nextCursor}return r},listAppsByIds:async r=>{const o=Array.from(new Set(r)),d=[];for(let u=0;u<o.length;u+=100){const p=o.slice(u,u+100).map(encodeURIComponent).join(","),x=await a(`/apps?ids=${p}`);d.push(...x.apps)}return d},getAppAuth:async r=>(await a(`/apps/${encodeURIComponent(r)}/auths`)).auths??[],createConnection:(r,o)=>a(`/apps/${encodeURIComponent(r)}/connections`,{method:"POST",body:JSON.stringify(o)}).then(d=>d.connection),startAppOAuthFlow:(r,o,d)=>a(`/apps/${encodeURIComponent(r)}/oauth-config/${encodeURIComponent(o)}/authorize-url`,{method:"POST",body:JSON.stringify(d)}),getAppActions:r=>a(`/apps/${encodeURIComponent(r)}`).then(o=>o.actions??[]),listConnectionsForApp:r=>a(`/apps/${encodeURIComponent(r)}/connections`).then(o=>o.connections??[]),listConnections:()=>a("/connections").then(r=>r.connections??[]),invokeAction:(r,o,d,u={})=>a(`/apps/${encodeURIComponent(r)}/actions/${encodeURIComponent(o)}/invoke`,{method:"POST",body:JSON.stringify({params:d,connectionId:u.connectionId,project:u.project,state:u.state})}),listSavedTests:r=>a(`/connections/${encodeURIComponent(r)}/saved-tests`).then(o=>o.savedTests??[]),createSavedTest:(r,o)=>a(`/connections/${encodeURIComponent(r)}/saved-tests`,{method:"POST",body:JSON.stringify(o)}).then(d=>d.savedTest),updateSavedTest:(r,o,d)=>a(`/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(o)}`,{method:"PATCH",body:JSON.stringify(d)}).then(u=>u.savedTest),deleteSavedTest:(r,o)=>a(`/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(o)}`,{method:"DELETE"}).then(()=>{}),recordTestRun:(r,o)=>a(`/connections/${encodeURIComponent(r)}/test-runs`,{method:"POST",body:JSON.stringify(o)}).then(()=>{}),listTestRuns:r=>a(`/connections/${encodeURIComponent(r)}/test-runs`).then(o=>o.runs??[]),saveStepTest:(r,o,d)=>a(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/tests`,{method:"POST",body:JSON.stringify(d)}).then(u=>u.stepTest),listStepTests:(r,o)=>a(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/tests`).then(d=>d.stepTests??[]),recordStepTestRun:(r,o,d)=>a(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/test-runs`,{method:"POST",body:JSON.stringify(d)}).then(()=>{}),listFunctions:()=>a("/functions").then(r=>r.functions??[]),getFunction:r=>a(`/functions/${encodeURIComponent(r)}`).then(o=>({...o.function,valid:o.valid})),invokeFunction:(r,o)=>a(`/functions/${encodeURIComponent(r)}/invoke`,{method:"POST",body:JSON.stringify({inputs:o})}).then(d=>d.output),listWorkflows:()=>a("/workflows").then(r=>r.workflows??[]),getWorkflow:r=>a(`/workflows/${encodeURIComponent(r)}`).then(o=>o.workflow),runWorkflow:(r,o={})=>c(`/workflows/${encodeURIComponent(r)}/run?wait=true`,{method:"POST",body:JSON.stringify({variables:o.variables,input:o.input})}).then(({status:d,data:u})=>({...u??{},terminal:d===200}))}}function qe(s){if(!s)return"";try{return JSON.stringify(JSON.parse(s),null,2)}catch{return s}}function As(s,t){return`${s.method}-${s.url??s.host}-${t}`}function Ge({calls:s,defaultOpen:t,keyOf:n,title:l}){if(s.length===0)return null;const c=n??As;return e.jsxs("div",{className:"w6w-stack",style:{gap:4},children:[l!==!1&&e.jsx("strong",{className:"w6w-small",children:l??e.jsxs(e.Fragment,{children:["API ",s.length===1?"call":"calls"," (",s.length,")"]})}),s.map((a,r)=>e.jsxs("details",{open:t,className:"w6w-result",style:{padding:8},children:[e.jsx("summary",{style:{cursor:"pointer"},children:e.jsxs("span",{className:"w6w-small",children:[a.method," ",a.url??a.host," →"," ",e.jsx("strong",{children:a.error?"failed":a.status}),a.durationMs!==void 0&&e.jsxs("span",{className:"w6w-muted",children:[" · ",a.durationMs,"ms"]})]})}),e.jsxs("div",{className:"w6w-stack",style:{gap:6,marginTop:8},children:[a.error&&e.jsx("div",{className:"w6w-error w6w-small",children:a.error}),e.jsx("div",{className:"w6w-muted w6w-small",children:"Request headers"}),e.jsx("pre",{className:"w6w-result",children:JSON.stringify(a.requestHeaders??{},null,2)}),a.requestBody&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-muted w6w-small",children:"Request body"}),e.jsx("pre",{className:"w6w-result",children:qe(a.requestBody)})]}),e.jsx("div",{className:"w6w-muted w6w-small",children:"Response headers"}),e.jsx("pre",{className:"w6w-result",children:JSON.stringify(a.responseHeaders??{},null,2)}),a.responseBody&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-muted w6w-small",children:"Response body"}),e.jsx("pre",{className:"w6w-result",children:qe(a.responseBody)})]}),a.truncated&&e.jsx("div",{className:"w6w-muted w6w-small",children:"A captured body exceeded the size cap and was truncated."})]})]},c(a,r)))]})}function Q({title:s,subtitle:t,icon:n,trailing:l,active:c=!1,onClick:a,ariaLabel:r}){const o=e.jsxs(e.Fragment,{children:[n!=null&&e.jsx("span",{className:"w6w-list-item-icon",children:n}),e.jsxs("span",{className:"w6w-list-item-body",children:[e.jsx("span",{className:"w6w-list-item-title",children:s}),t!=null&&e.jsx("span",{className:"w6w-list-item-subtitle",children:t})]}),l!=null&&e.jsx("span",{className:"w6w-list-item-trailing",children:l})]}),d=`w6w-list-item${c?" active":""}`;return a?e.jsx("button",{type:"button",className:d,"aria-pressed":c,"aria-label":r,onClick:a,children:o}):e.jsx("div",{className:d,"aria-label":r,children:o})}function ue(s){const t=Date.parse(s);if(Number.isNaN(t))return"";const n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<45)return"just now";const l=Math.round(n/60);if(l<60)return`${l}m ago`;const c=Math.round(l/60);if(c<24)return`${c}h ago`;const a=Math.round(c/24);return a<7?`${a}d ago`:new Date(t).toLocaleDateString()}function We(s){const t={};for(const n of(s==null?void 0:s.params)??[])n.key&&n.default!==void 0&&(t[n.key]=n.default);return t}function Ms(s){var n,l,c;const t=s.indexOf("{");if(t>=0)try{const a=JSON.parse(s.slice(t)),r=((l=(n=a==null?void 0:a.errors)==null?void 0:n[0])==null?void 0:l.message)??(typeof(a==null?void 0:a.error)=="object"?(c=a.error)==null?void 0:c.message:a==null?void 0:a.error)??(a==null?void 0:a.message);if(typeof r=="string"&&r.trim()){const o=s.slice(0,t).replace(/[:\s]+$/,"");return o?`${o}: ${r.trim()}`:r.trim()}}catch{}return s}function Ye(s){return typeof s=="object"&&s!==null&&typeof s.status=="number"&&typeof s.code=="string"}function Ps(s){if(!Ye(s))return{headline:(s==null?void 0:s.message)??"The action failed to run."};const t=Ms(s.message??""),n=`${s.status} ${s.code} ${s.message??""}`.toLowerCase();return s.status===401||s.status===403||/\b(401|403)\b|forbidden|unauthorized|not authorized|permission|scope|access denied|invalid api key|invalid credential/.test(n)?{headline:"Permission denied by the provider — this is a credential/scope problem, not a w6w error.",hint:"The connection's API key is missing the permissions this action needs. Fix it at the provider — e.g. SendGrid → Settings → API Keys → give the key the required scopes (or Full Access), or create a new key — then update this connection's credential and try again.",detail:t}:{headline:"The action returned an error.",detail:t}}function Is(s){const t=Ye(s)?s.body??s.raw:null;return(t==null?void 0:t.apiCalls)??[]}function we(){const[s,t]=m.useState(""),[n,l]=m.useState(void 0),[c,a]=m.useState(!1);return{text:s,value:n,invalid:c,onChange:o=>{t(o);const d=o.trim();if(d===""){a(!1);return}try{const u=JSON.parse(d);u!==null&&typeof u=="object"&&!Array.isArray(u)?(l(u),a(!1)):a(!0)}catch{a(!0)}}}}function Fs({appId:s,actions:t,connectionId:n,action:l,seedValues:c,onSavedTestsChanged:a,seedTestId:r,onDirtyChange:o,onTestSaved:d,onDeleted:u,embedded:h=!1}){var Le;const p=w.useW6WApi(),x=m.useMemo(()=>{const i=[...t];return i.sort((f,y)=>(f.title||f.key).localeCompare(y.title||y.key)),i},[t]),[j,te]=m.useState((l==null?void 0:l.key)??""),v=l??t.find(i=>i.key===j)??null,[ge,be]=m.useState(!1),[E,M]=m.useState(null),[Se,P]=m.useState(void 0),[es,T]=m.useState([]),$=we(),C=we(),O=we(),[ne,ss]=m.useState(""),[ae,ts]=m.useState(""),ke=$.invalid||C.invalid||O.invalid,ns=()=>{const i={};return $.text.trim()!==""&&$.value!==void 0&&(i.body=$.value),C.text.trim()!==""&&C.value!==void 0&&(i.query=C.value),O.text.trim()!==""&&O.value!==void 0&&(i.headers=O.value),ne&&(i.target=ne),ae.trim()!==""&&(i.match=ae.trim()),Object.keys(i).length>0?i:void 0},[I,re]=m.useState("form"),[as,$e]=m.useState(""),[rs,Ce]=m.useState(!1),[R,Oe]=m.useState(!1),N=(v==null?void 0:v.key)??null,Re=c?{...c}:We(v),[Ee,J]=m.useState(()=>({key:N,values:Re})),[g,F]=m.useState(r??null),[Te,D]=m.useState(Re);if(Ee.key!==N){const i=We(v);J({key:N,values:i}),D(i),F(r??null),M(null),P(void 0),T([])}const[ls,is]=m.useState(r);r!==ls&&(is(r),F(r??null));const[Ae,os]=m.useState(c);if(c!==Ae){const i=JSON.stringify(c??null)!==JSON.stringify(Ae??null);if(os(c),c&&i){const f={...c};J({key:N,values:f}),D(f),M(null),P(void 0),T([])}}const S=Ee.values,Me=i=>J({key:N,values:i}),Pe=m.useMemo(()=>JSON.stringify(S)!==JSON.stringify(Te),[S,Te]);m.useEffect(()=>{o==null||o(Pe)},[Pe]);const cs=()=>{$e(JSON.stringify(S,null,2)),Ce(!1),re("json")},ds=async i=>{if(!v||ke)return;const f=v.key;be(!0),M(null),P(void 0),T([]);let y;const Je=ns();try{const A=await p.invokeAction(s,f,i,{connectionId:n,...Je?{overrides:Je}:{}});P(A.value),T(A.apiCalls??[]),y={ok:!0,summary:"OK",result:A.value}}catch(A){const De=Ps(A);M(De),T(Is(A)),y={ok:!1,summary:De.headline}}finally{be(!1)}if(n)try{await p.recordTestRun(n,{savedTestId:g??null,actionKey:f,ok:y.ok,summary:y.summary.slice(0,200),result:y.result}),ce(),js(),a==null||a()}catch{}},us=()=>ds(S),[q,Ie]=m.useState(null),[W,_]=m.useState(null),[ws,ms]=m.useState(0),[ps,H]=m.useState(!1),[le,ie]=m.useState(""),[hs,oe]=m.useState(!1),ce=()=>ms(i=>i+1);m.useEffect(()=>{if(!n){Ie(null);return}let i=!1;return _(null),p.listSavedTests(n).then(f=>!i&&Ie(f)).catch(f=>!i&&_(f.message)),()=>{i=!0}},[p,n,ws]);const Fe=N?(q??[]).filter(i=>i.actionKey===N):[],[xs,de]=m.useState(null),[fs,vs]=m.useState(0),js=()=>vs(i=>i+1);m.useEffect(()=>{const i=p.listTestRuns;if(!n||!i){de(null);return}let f=!1;return i(n).then(y=>!f&&de(y)).catch(()=>!f&&de(null)),()=>{f=!0}},[p,n,fs]);const _e=N?(xs??[]).filter(i=>i.actionKey===N).slice().sort((i,f)=>Date.parse(f.occurredAt)-Date.parse(i.occurredAt)):[],ys=()=>{!n||!v||(ie(""),_(null),H(!0))},Ns=()=>{!n||!v||(g?Be():ys())},Be=async()=>{if(!(!n||!v))try{let i;if(g)i=await p.updateSavedTest(n,g,{values:S});else{const f=le.trim();if(!f)return;i=await p.createSavedTest(n,{actionKey:v.key,name:f,values:S}),F(i.id)}D({...S}),H(!1),ie(""),ce(),a==null||a(),d==null||d(i)}catch(i){_(i.message)}},gs=i=>{const f={...i.values};J({key:N,values:f}),D(f),F(i.id),re("form"),M(null),P(void 0),T([])},bs=async()=>{if(!n||!g)return;const i=g;try{await p.deleteSavedTest(n,i),F(null),ce(),a==null||a(),u==null||u(i)}catch(f){_(f.message)}},Ss=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsxs("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"Parameters"}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-1)"},children:[e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${I==="form"?" active":""}`,"aria-pressed":I==="form",onClick:()=>re("form"),children:"Form"}),e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${I==="json"?" active":""}`,"aria-pressed":I==="json",onClick:cs,children:"JSON"}),!h&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-sm w6w-btn-ghost","aria-pressed":R,title:R?"Collapse the params editor":"Open the params editor in a larger view","aria-label":R?"Collapse the params editor":"Open the params editor in a larger view",onClick:()=>Oe(i=>!i),children:R?"⤡":"⤢"})]})]}),I==="form"?e.jsx(w.ParamsForm,{params:(v==null?void 0:v.params)??[],values:S,onChange:Me}):e.jsxs(e.Fragment,{children:[e.jsx(w.JsonEditor,{value:as,onChange:$e,minHeight:R?"50vh":"200px","aria-label":"Params JSON",onValidChange:i=>{i!==null&&typeof i=="object"&&!Array.isArray(i)&&Me(i)},onValidityChange:({valid:i})=>Ce(!i)}),rs&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]}),ks=e.jsxs("details",{className:"w6w-section","data-testid":"overrides-region",children:[e.jsxs("summary",{className:"w6w-section-summary",children:[e.jsx("span",{className:"w6w-section-title",children:"Overrides"}),e.jsx("span",{className:"w6w-section-subtitle",children:"Reach a vendor field this action's own params don't declare"})]}),e.jsxs("div",{className:"w6w-stack w6w-section-body",style:{gap:"var(--w6w-sp-2)"},children:[e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Body"}),e.jsx(w.JsonEditor,{value:$.text,onChange:$.onChange,minHeight:"80px","aria-label":"Overrides body (JSON)"}),$.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Query"}),e.jsx(w.JsonEditor,{value:C.text,onChange:C.onChange,minHeight:"80px","aria-label":"Overrides query (JSON)"}),C.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Headers"}),e.jsx(w.JsonEditor,{value:O.text,onChange:O.onChange,minHeight:"80px","aria-label":"Overrides headers (JSON)"}),O.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Target"}),e.jsxs("select",{"aria-label":"Overrides target",value:ne,onChange:i=>ss(i.target.value),children:[e.jsx("option",{value:"",children:"— default (first) —"}),e.jsx("option",{value:"first",children:"first"}),e.jsx("option",{value:"first-write",children:"first-write"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Match"}),e.jsx("input",{type:"text","aria-label":"Overrides match",value:ae,placeholder:"Restrict to requests whose URL contains…",onChange:i=>ts(i.target.value)})]}),e.jsx("span",{className:"w6w-hint",children:"Merged onto the outbound request at the wire, never into the params above — name a field the way the vendor's own API documents it."})]})]}),K=n?e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Saved tests"})}),W&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:W}),Fe.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"No saved tests for this action yet."}):e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:Fe.map(i=>e.jsx("li",{children:e.jsx(Q,{title:i.name,subtitle:i.lastRunAt?e.jsxs("span",{children:[e.jsx("span",{style:{color:i.lastRunOk?"var(--w6w-success)":"var(--w6w-danger)"},children:i.lastRunOk?"✓":"✗"})," ",i.lastRunSummary?`${i.lastRunSummary} · `:"",ue(i.lastRunAt)]}):`saved ${ue(i.updatedAt)}`,active:i.id===g,onClick:()=>gs(i)})},i.id))}),p.listTestRuns&&_e.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Recent runs"})}),e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:_e.map(i=>e.jsx("li",{children:e.jsx(Q,{title:e.jsxs("span",{children:[e.jsx("span",{style:{color:i.ok?"var(--w6w-success)":"var(--w6w-danger)"},children:i.ok?"✓":"✗"})," ",i.actionKey]}),subtitle:e.jsxs("span",{children:[i.summary?`${i.summary} · `:"",ue(i.occurredAt)]})})},i.id))})]})]}):null,Ue=(Le=q==null?void 0:q.find(i=>i.id===g))==null?void 0:Le.name;return e.jsxs("div",{className:`w6w-stack${h?" w6w-tester-embedded-root":""}`,children:[!l&&(t.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"This app exposes no actions."}):e.jsxs("label",{className:"w6w-field",children:[e.jsxs("span",{children:["Action",N?"":" *"]}),e.jsx(w.Combobox,{value:j,placeholder:"— pick an action —",onChange:te,options:x.map(i=>({value:i.key,label:`${i.title??i.key} (${i.key})`}))})]})),v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[v.title??v.key," ",e.jsx("code",{className:"w6w-muted",children:v.key})]}),v.description&&e.jsx("p",{className:"w6w-muted w6w-small",style:{margin:"var(--w6w-sp-0-5) 0 0"},children:v.description})]}),(()=>{const i=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[Ss,ks,E&&e.jsxs("div",{className:"w6w-result w6w-error",children:[e.jsx("strong",{children:E.headline}),E.hint&&e.jsx("div",{style:{marginTop:"var(--w6w-sp-1-5)"},children:E.hint}),E.detail&&e.jsx("div",{className:"w6w-muted w6w-small",style:{marginTop:"var(--w6w-sp-1-5)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:E.detail})]}),Se!==void 0&&e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1)"},children:[e.jsx("strong",{className:"w6w-small",children:"Result"}),e.jsx("pre",{className:"w6w-result",children:JSON.stringify(Se,null,2)})]}),e.jsx(Ge,{calls:es})]}),f=e.jsxs("div",{className:`w6w-tester-actions${h||R?" w6w-tester-actions-footer":""}`,style:{display:"flex",gap:"var(--w6w-sp-2)"},children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:ge||ke,onClick:us,children:ge?"Running…":"Run action"}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:Ns,children:"Save test"}),n&&g&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",style:{marginLeft:"auto",color:"var(--w6w-danger)"},onClick:()=>oe(!0),children:"Delete"})]}),y=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[i,f]});return h?e.jsxs("div",{className:"w6w-tester-embedded",children:[e.jsx("div",{className:"w6w-tester-embedded-scroll",children:K?e.jsxs("div",{className:"w6w-tester-embedded-cols",children:[e.jsx("div",{className:"w6w-tester-embedded-main",children:i}),e.jsx("div",{className:"w6w-tester-embedded-rail",children:K})]}):i}),f]}):R?e.jsx(w.Modal,{title:`Edit params — ${v.title??v.key}`,onClose:()=>Oe(!1),size:"full",children:e.jsxs("div",{className:"w6w-tester-popout",children:[e.jsx("div",{className:"w6w-tester-popout-scroll",children:K?e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-4)",alignItems:"flex-start"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:i}),e.jsx("div",{style:{width:260,flexShrink:0},children:K})]}):i}),f]})}):y})(),ps&&e.jsx(w.Modal,{title:"Save test",onClose:()=>H(!1),children:e.jsxs("form",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},onSubmit:i=>{i.preventDefault(),Be()},children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Name this saved test"}),e.jsx("input",{type:"text",value:le,placeholder:"e.g. valid sender",onChange:i=>ie(i.target.value)})]}),W&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:W}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-2)",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>H(!1),children:"Cancel"}),e.jsx("button",{type:"submit",className:"w6w-btn",disabled:!le.trim(),children:"Save"})]})]})}),hs&&e.jsx(w.ConfirmModal,{title:"Delete saved test",message:Ue?`Delete "${Ue}"? This cannot be undone.`:"Delete this saved test? This cannot be undone.",confirmLabel:"Delete",onConfirm:()=>{oe(!1),bs()},onClose:()=>oe(!1)})]}):!l&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action above to test it."})]})}function _s(s){const t=w.useEffectiveTheme(s.theme),{copied:n,copy:l}=b.useCopyToClipboard(s.value),c=m.useMemo(()=>[Os.yaml(),Rs.EditorView.theme({"&":{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:"2px solid 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"}})],[]);function a(r){s.onChange(r)}return e.jsxs("div",{className:"w6w-yaml-editor","aria-label":s["aria-label"]??"YAML editor",children:[e.jsx(Es,{value:s.value,onChange:a,extensions:c,placeholder:s.placeholder,readOnly:s.readOnly,editable:!s.readOnly,theme:t,height:s.height,minHeight:s.minHeight??"240px",maxHeight:s.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!s.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),s.copyable&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${n?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void l(),children:n?e.jsx(b.CheckGlyph,{}):e.jsx(b.CopyGlyph,{})}),e.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:n?"Copied":""})]})]})}const me="…";function Qe(s,t,n="end"){if(t===void 0||t<1||t>=s.length)return s;if(n==="start")return`${me}${s.slice(s.length-t)}`;if(n==="end")return`${s.slice(0,t)}${me}`;const l=Math.ceil(t/2),c=t-l;return`${s.slice(0,l)}${me}${s.slice(s.length-c)}`}function Bs(s){const{value:t,chars:n,crop:l="end",label:c,className:a,copiedMs:r}=s,o=Qe(t,n,l),d=["w6w-copyable--bare",a].filter(Boolean).join(" ");return e.jsx(b.Copyable,{value:t,readOnly:!0,label:c,className:d,copiedMs:r,children:e.jsx("span",{children:o})})}const Us={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Ls({state:s,label:t,ariaLabel:n}){const l=t??Us[s];return e.jsxs("span",{className:`w6w-health-pill w6w-health-pill-${s}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-health-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-health-pill-label",children:l})]})}const Js={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Ds({days:s,ariaLabel:t}){return s.length===0?null:e.jsx("div",{className:"w6w-uptime-strip",role:"img","aria-label":t??`${s.length}-day status`,children:s.map((n,l)=>e.jsx("span",{className:`w6w-uptime-cell w6w-uptime-cell-${n.state}`,title:n.label??`${n.day} — ${Js[n.state]}`},`${n.day}-${l}`))})}const Ze="—",He=["B","KiB","MiB","GiB","TiB","PiB"];function qs(s){if(s===null||!Number.isFinite(s))return Ze;if(s<1024)return`${Math.round(s)} B`;let t=s,n=0;for(;t>=1024&&n<He.length-1;)t/=1024,n+=1;return`${t.toFixed(1)} ${He[n]}`}function k(s){return s===null||!Number.isFinite(s)?Ze:`${Math.round(s*100)}%`}function U(s){if(s===void 0||s.load1===null)return null;const t=s.cpuLimit??s.cpus;return t===null||t<=0?null:s.load1/t}function L(s){if(s===void 0)return null;const{memoryTotal:t,memoryAvailable:n}=s;return t===null||n===null||t<=0?null:(t-n)/t}function Ws(s,t,n){return s<t?t:s>n?n:s}function Hs(s,t,n,l){const c=s.length;if(c<2)return"";const a=[];for(let r=0;r<c;r++){const o=s[r];if(o===null)continue;const d=r/(c-1)*t,u=l<=0?n:n-Ws(o,0,l)/l*n;a.push(`${Number(d.toFixed(2))},${Number(u.toFixed(2))}`)}return a.join(" ")}const Ks="—",Ke=100,Ve=24;function je({values:s,max:t,className:n}){const l=Hs(s,Ke,Ve,t);return l===""?null:e.jsx("svg",{className:n,viewBox:`0 0 ${Ke} ${Ve}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:e.jsx("polyline",{points:l,fill:"none",stroke:"var(--w6w-accent)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})})}function pe(s){return s===null?Ks:s.toFixed(2)}function Z(s){let t=1;for(const n of s)n!==null&&n>t&&(t=n);return t}function G({label:s,value:t,values:n,max:l}){return e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:s}),e.jsx("span",{className:"w6w-server-resources__value",children:t}),e.jsx(je,{className:"w6w-server-resources__spark",values:n,max:l})]})}function Ne(s){const t=s[s.length-1],n=s.map(a=>U(a)),l=s.map(a=>L(a)),c=s.map(a=>a.processRss);return{last:t,cpuValues:n,memoryValues:l,rssValues:c}}function Vs({samples:s,title:t="Server resources",intervalMs:n}){const{last:l,cpuValues:c,memoryValues:a,rssValues:r}=Ne(s);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--card","aria-label":t,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:t}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(G,{label:"CPU",value:k(U(l)),values:c,max:Z(c)}),e.jsx(G,{label:"Memory",value:k(L(l)),values:a,max:1}),e.jsx(G,{label:"Process",value:qs((l==null?void 0:l.processRss)??null),values:r,max:Z(r)})]}),e.jsx("p",{className:"w6w-server-resources__meta",children:`Load ${pe((l==null?void 0:l.load1)??null)} / ${pe((l==null?void 0:l.load5)??null)} / ${pe((l==null?void 0:l.load15)??null)}`}),n!==void 0&&e.jsx("p",{className:"w6w-server-resources__meta",children:`Sampled every ${n/1e3}s`})]})}function zs({samples:s,title:t="Server"}){const{last:n,cpuValues:l}=Ne(s);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--small","aria-label":t,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:t}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(G,{label:"CPU",value:k(U(n)),values:l,max:Z(l)}),e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"Memory"}),e.jsx("span",{className:"w6w-server-resources__value",children:k(L(n))})]})]})]})}function Gs({samples:s,onExpand:t}){const{last:n,cpuValues:l,memoryValues:c}=Ne(s);return e.jsxs("aside",{className:"w6w-server-resources w6w-server-resources--rail",children:[e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"CPU"}),e.jsx("span",{className:"w6w-server-resources__value",children:k(U(n))}),e.jsx(je,{className:"w6w-server-resources__spark",values:l,max:Z(l)})]}),e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"MEM"}),e.jsx("span",{className:"w6w-server-resources__value",children:k(L(n))}),e.jsx(je,{className:"w6w-server-resources__spark",values:c,max:1})]}),t!==void 0&&e.jsx("button",{type:"button",className:"w6w-server-resources__expand","aria-label":"Show server resources",onClick:t,children:"Details"})]})}function Ys({samples:s}){const t=s[s.length-1],n=k(U(t)),l=k(L(t));return e.jsx("span",{className:"w6w-server-resources w6w-server-resources--badge",children:`CPU ${n} · MEM ${l}`})}const Qs=1,Zs=1440*60*1e3;function Xs(s,t,n){const l=t.startedAt??t.updatedAt;if(l===void 0)return null;const c=Date.parse(l),a=t.resolvedAt!==void 0?Date.parse(t.resolvedAt):t.startedAt!==void 0?n:c,r=Date.parse(`${s.from}T00:00:00.000Z`),o=Date.parse(`${s.to}T00:00:00.000Z`)+Zs,d=o-r;if(a<r||c>=o)return null;const u=c<r,h=a>o,p=Math.max(c,r),x=Math.min(a,o),j=(p-r)/d*100,te=(x-p)/d*100,v=Math.max(te,Qs);return{leftPct:j,widthPct:v,clippedStart:u,clippedEnd:h}}const et={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"},st="This vendor publishes no incident history.",tt="No incidents in this window.";function nt(s){const t=s.startedAt??s.updatedAt,n=[s.title];return s.components!==void 0&&s.components.length>0&&n.push(`(${s.components.join(", ")})`),t!==void 0&&n.push(s.resolvedAt!==void 0?`${t} – ${s.resolvedAt}`:`${t} – ongoing`),n.join(" ")}function at({window:s,days:t,incidents:n,vendorEmptyLabel:l,nowMs:c=Date.now(),ariaLabel:a}){const r=t.length,o=r>0?100/r:0,d=n===void 0?l??st:n.length===0?l??tt:null;return e.jsx("div",{className:"w6w-history-timeline",role:"img","aria-label":a??`${r}-day history`,children:e.jsxs("div",{className:"w6w-history-plot",children:[e.jsx("div",{className:"w6w-history-lane w6w-history-lane-execution",children:t.map((u,h)=>e.jsx("span",{className:`w6w-history-cell w6w-history-cell-${u.state}`,style:{left:`${h*o}%`,width:`${o}%`},title:u.label??`${u.day} — ${et[u.state]}`},`${u.day}-${h}`))}),e.jsx("div",{className:"w6w-history-lane w6w-history-lane-vendor",children:d!==null?e.jsx("span",{className:"w6w-history-empty",title:d,children:d}):n==null?void 0:n.map((u,h)=>{const p=Xs(s,u,c);if(p===null)return null;const x=[p.clippedStart?"w6w-history-bar-clip-start":"",p.clippedEnd?"w6w-history-bar-clip-end":""].filter(Boolean).join(" ");return e.jsx("span",{className:`w6w-history-bar w6w-history-bar-${u.state}${x?` ${x}`:""}`,style:{left:`${p.leftPct}%`,width:`${p.widthPct}%`},title:nt(u)},u.id??`${u.title}-${h}`)})}),e.jsxs("div",{className:"w6w-history-axis",children:[e.jsx("span",{className:"w6w-history-tick w6w-history-tick-start",style:{left:"0%"},children:s.from}),e.jsx("span",{className:"w6w-history-tick w6w-history-tick-end",style:{left:"100%"},children:s.to})]})]})})}function rt({label:s,children:t,className:n}){const[l,c]=m.useState(!1),a=m.useId();return e.jsxs("span",{className:["w6w-info-tip",n??""].filter(Boolean).join(" "),children:[e.jsx(w.IconButton,{label:s,icon:"info","aria-expanded":l,"aria-controls":a,onClick:()=>c(r=>!r)}),l&&e.jsx("span",{id:a,className:"w6w-info-tip-body w6w-muted w6w-small",children:t})]})}function lt(s){const{label:t,onClick:n,disabled:l,className:c,...a}=s;return e.jsx(w.IconButton,{label:t,onClick:n,disabled:l,className:c,icon:"edit","data-testid":a["data-testid"]})}function it(s){const{label:t,onClick:n,disabled:l,className:c,...a}=s;return e.jsx(w.IconButton,{label:t,onClick:n,disabled:l,className:c,danger:!0,icon:"delete","data-testid":a["data-testid"]})}function ot(s){const{branch:t,shortSha:n,lastSyncLabel:l,onSyncNow:c,syncing:a,className:r,...o}=s,[d,u]=m.useState(!1),h=m.useRef(null);return m.useEffect(()=>{if(!d)return;const p=j=>{h.current&&!h.current.contains(j.target)&&u(!1)},x=j=>j.key==="Escape"&&u(!1);return document.addEventListener("mousedown",p),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",x)}},[d]),e.jsxs("div",{className:`w6w-repo-sync${r?` ${r}`:""}`,ref:h,"data-testid":o["data-testid"],children:[e.jsxs("button",{type:"button",className:"w6w-repo-sync-trigger","aria-haspopup":"menu","aria-expanded":d,"aria-busy":a,onClick:()=>u(p=>!p),children:[e.jsxs("span",{className:"w6w-repo-sync-icon",children:[e.jsx(b.Icon,{name:"github"}),a&&e.jsx(b.Icon,{name:"sync",size:10,className:"w6w-repo-sync-spin"})]}),e.jsx("span",{className:"w6w-repo-sync-branch",children:t}),n!=null&&e.jsx("code",{className:"w6w-repo-sync-sha",children:n})]}),d&&e.jsxs("div",{className:"w6w-repo-sync-menu",role:"menu",children:[e.jsxs("div",{className:"w6w-repo-sync-detail",children:[e.jsx("span",{children:t}),n!=null&&e.jsx("code",{children:n}),l!=null&&e.jsx("span",{children:l})]}),e.jsx("button",{type:"button",role:"menuitem",className:"w6w-repo-sync-item","data-testid":"repo-sync-now",disabled:a,onClick:c,children:a?"Syncing…":"Sync now"})]})]})}const ct={pending:"Pending",running:"Running",succeeded:"Succeeded",failed:"Failed",skipped:"Skipped",queued:"Queued",canceled:"Canceled"};function ee({state:s,label:t,ariaLabel:n}){const l=t??ct[s];return e.jsxs("span",{className:`w6w-step-pill w6w-step-pill-${s}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-step-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-step-pill-label",children:l})]})}const dt="—",he=1e3,xe=6e4;function se(s){return s==null||!Number.isFinite(s)||s<0?dt:s<he?`${Math.round(s)} ms`:s<xe?`${(s/he).toFixed(1)} s`:`${Math.floor(s/xe)}m ${Math.round(s%xe/he)}s`}function B(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}const ut={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function wt({items:s,selectedId:t=null,onSelect:n,showCallable:l=!1,loading:c=!1,emptyLabel:a,hasPrev:r,hasNext:o,onPrev:d,onNext:u}){const h=d||u?e.jsxs("div",{className:"w6w-execution-list-pager",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-prev",disabled:!r,onClick:d,children:"Previous"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-next",disabled:!o,onClick:u,children:"Next"})]}):null;let p;return c&&s.length===0?p=e.jsx("p",{"data-testid":"execution-list-loading",children:"Loading…"}):s.length===0?p=e.jsx("p",{"data-testid":"execution-list-empty",children:a??"No executions yet."}):p=e.jsx("ul",{className:"w6w-execution-list-rows",children:s.map(x=>e.jsx("li",{"data-testid":"execution-row","data-execution-id":x.id,children:e.jsx(Q,{icon:e.jsx(ee,{state:x.status}),title:l?x.callableName:B(x.startedAt),subtitle:l?`${ut[x.kind]} · ${B(x.startedAt)}`:x.id,trailing:se(x.durationMs),active:x.id===t,onClick:n?()=>n(x.id):void 0})},x.id))}),e.jsxs("div",{className:"w6w-execution-list","data-testid":"execution-list",children:[p,h]})}function Xe({steps:s,emptyLabel:t,onDismiss:n,runError:l,stepErrors:c}){const a=n?e.jsx("div",{className:"w6w-execution-log-head",children:e.jsx(w.IconButton,{label:"Dismiss run log","data-testid":"execution-log-dismiss",onClick:n,children:"×"})}):null,r=c??[],o=l||r.length>0?e.jsxs("div",{className:"w6w-execution-log-errors w6w-stack",children:[l&&e.jsx(ye,{error:l}),r.map((d,u)=>e.jsx(ye,{label:d.label??d.stepId,error:d.error},`${d.stepId}:${u}`))]}):null;return s.length===0?e.jsxs(e.Fragment,{children:[a,o,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:t??"No steps have run yet."})})]}):e.jsxs(e.Fragment,{children:[a,o,e.jsx("ol",{className:"w6w-execution-log",children:s.map(d=>e.jsx(mt,{step:d},d.id))})]})}function mt({step:s}){const[t,n]=m.useState(!1),l=e.jsxs("div",{className:"w6w-execution-log-row-header",children:[e.jsx(ee,{state:s.status}),e.jsx("span",{className:"w6w-execution-log-row-label",children:s.label??s.id}),e.jsx(pt,{startedAt:s.startedAt,finishedAt:s.finishedAt})]}),c=s.error?e.jsx(ye,{error:s.error}):null;return s.input===void 0&&s.output===void 0&&!s.meta?e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsx("div",{className:"w6w-section",children:l}),c]}):e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsxs("details",{className:"w6w-section",open:t,onToggle:a=>n(a.currentTarget.open),children:[e.jsx("summary",{className:"w6w-section-summary",children:l}),t&&e.jsxs("div",{className:"w6w-execution-log-row-body w6w-section-body w6w-stack",children:[e.jsx(ze,{title:"Input",value:s.input}),e.jsx(ze,{title:"Output",value:s.output}),s.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(X.CodeBlock,{code:JSON.stringify(s.meta,null,2),language:"json"})]})]})]}),c]})}function ye({error:s,label:t}){return e.jsxs("div",{className:"w6w-result w6w-error",children:[t!==void 0&&e.jsx("strong",{className:"w6w-execution-log-error-label",children:t}),s.code&&e.jsx("div",{className:"w6w-small w6w-execution-log-error-code",children:e.jsx("code",{children:s.code})}),s.message]})}function pt({startedAt:s,finishedAt:t}){if(s&&t){const n=ht(s,t);return e.jsxs("span",{className:"w6w-execution-log-timing",children:[s," → ",t,n&&e.jsxs("span",{children:[" (",n,")"]})]})}return s?e.jsxs("span",{className:"w6w-execution-log-timing",children:["Started ",s]}):e.jsx("span",{className:"w6w-execution-log-timing",children:"—"})}function ht(s,t){const n=Date.parse(s),l=Date.parse(t);if(!Number.isFinite(n)||!Number.isFinite(l)||l<n)return null;const c=l-n;if(c<1e3)return`${c}ms`;const a=c/1e3;if(a<60)return`${a.toFixed(1)}s`;const r=Math.floor(a/60),o=Math.round(a%60);return`${r}m ${o}s`}function ze({title:s,value:t}){return e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:s}),t===void 0?e.jsx("p",{className:"w6w-muted w6w-small",children:"Not available."}):e.jsx(X.CodeBlock,{code:JSON.stringify(t,null,2),language:"json"})]})}const xt={status:"",kind:"",from:"",to:"",q:""},ft=[{value:"",label:"Any status"},{value:"queued",label:"Queued"},{value:"running",label:"Running"},{value:"succeeded",label:"Succeeded"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}],vt=[{value:"",label:"Any type"},{value:"function",label:"Function"},{value:"endpoint",label:"Endpoint"},{value:"workflow",label:"Workflow"}];function jt({value:s,onChange:t,showKind:n=!1,searchPlaceholder:l="Search by id or name",disabled:c=!1}){const a=s.status!==""||s.kind!==""||s.from!==""||s.to!==""||s.q!=="";return e.jsxs("div",{className:"w6w-execution-filters","data-testid":"execution-filters",children:[e.jsx("input",{type:"search",className:"w6w-execution-filters-search","data-testid":"execution-filter-q","aria-label":"Search executions",placeholder:l,value:s.q,disabled:c,onChange:r=>t({...s,q:r.target.value})}),e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-status","aria-label":"Status",value:s.status,disabled:c,onChange:r=>t({...s,status:r.target.value}),children:ft.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),n&&e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-kind","aria-label":"Type",value:s.kind,disabled:c,onChange:r=>t({...s,kind:r.target.value}),children:vt.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-from","aria-label":"From date",value:s.from,disabled:c,onChange:r=>t({...s,from:r.target.value})}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-to","aria-label":"To date",value:s.to,disabled:c,onChange:r=>t({...s,to:r.target.value})}),a&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-execution-filters-clear","data-testid":"execution-filter-clear",disabled:c,onClick:()=>t({...xt}),children:"Clear"})]})}const Y="—";function yt({stats:s,label:t}){const n=[{testid:"execution-stat-total",label:"Executions",value:s?String(s.total):Y},{testid:"execution-stat-success-rate",label:"Success rate",value:Nt(s==null?void 0:s.successRate)},{testid:"execution-stat-failed",label:"Failed",value:s?String(s.failed):Y},{testid:"execution-stat-avg-duration",label:"Avg duration",value:s?se(s.avgDurationMs):Y}];return s&&s.inFlight>0&&n.push({testid:"execution-stat-in-flight",label:"In flight",value:String(s.inFlight)}),e.jsxs("section",{className:"w6w-execution-stats","data-testid":"execution-stats",children:[t!=null&&e.jsx("p",{className:"w6w-execution-stats-label",children:t}),e.jsx("div",{className:"w6w-execution-stats-cards",children:n.map(l=>e.jsxs("div",{className:"w6w-execution-stat","data-testid":l.testid,children:[e.jsx("span",{className:"w6w-execution-stat-value","data-stat-value":l.value,children:l.value}),e.jsx("span",{className:"w6w-execution-stat-label",children:l.label})]},l.testid))})]})}function Nt(s){return s==null||!Number.isFinite(s)?Y:`${Math.round(s*100)}%`}const gt={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function bt(s){return JSON.stringify(s,null,2)??"null"}function St({execution:s,loading:t=!1,errorMessage:n,onClose:l,onOpenInEditor:c}){return e.jsxs("section",{className:"w6w-execution-detail w6w-stack","data-testid":"execution-detail",children:[n!=null&&e.jsx("p",{role:"alert",className:"w6w-execution-detail-error-message","data-testid":"execution-detail-error-message",children:n}),s?e.jsx(kt,{execution:s,onClose:l,onOpenInEditor:c}):t?e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-loading",children:"Loading…"}):e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-empty",children:"No execution selected."})]})}function kt({execution:s,onClose:t,onOpenInEditor:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w6w-execution-detail-head",children:[e.jsxs("div",{className:"w6w-execution-detail-title",children:[e.jsx("h3",{className:"w6w-execution-detail-name",children:s.callableName}),e.jsxs("div",{className:"w6w-execution-detail-meta",children:[e.jsx(ee,{state:s.status}),e.jsx("span",{className:"w6w-execution-detail-kind w6w-muted w6w-small",children:gt[s.kind]})]})]}),(n||t)&&e.jsxs("div",{className:"w6w-execution-detail-actions",children:[n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-open-editor",onClick:n,children:"Open in visual editor"}),t&&e.jsx(w.IconButton,{label:"Close","data-testid":"execution-detail-close",onClick:t,children:"×"})]})]}),e.jsx("p",{className:"w6w-execution-detail-id-line",children:e.jsx("code",{className:"w6w-execution-detail-id","data-testid":"execution-detail-id",children:s.id})}),e.jsxs("dl",{className:"w6w-execution-detail-timing",children:[e.jsx(fe,{label:"Started",value:B(s.startedAt)}),e.jsx(fe,{label:"Finished",value:s.finishedAt?B(s.finishedAt):"—"}),e.jsx(fe,{label:"Duration",value:se(s.durationMs)})]}),s.steps!==void 0&&e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":"execution-detail-steps",children:[e.jsx("strong",{className:"w6w-small",children:"Steps"}),e.jsx(Xe,{steps:s.steps,emptyLabel:"No steps ran."})]}),s.input!==void 0&&e.jsx(ve,{title:"Input",testid:"execution-detail-input",value:s.input}),s.output!==void 0&&e.jsx(ve,{title:"Output",testid:"execution-detail-output",value:s.output}),s.error!=null&&e.jsx(ve,{title:"Error",testid:"execution-detail-error",value:s.error})]})}function fe({label:s,value:t}){return e.jsxs("div",{className:"w6w-execution-detail-timing-item",children:[e.jsx("dt",{children:s}),e.jsx("dd",{children:t})]})}function ve({title:s,testid:t,value:n}){return e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":t,children:[e.jsx("strong",{className:"w6w-small",children:s}),e.jsx(X.CodeBlock,{code:bt(n),language:"json"})]})}exports.AddConnectionModal=w.AddConnectionModal;exports.AppIcon=w.AppIcon;exports.AppPicker=w.AppPicker;exports.AuthFieldsForm=w.AuthFieldsForm;exports.CodeEditor=w.CodeEditor;exports.Combobox=w.Combobox;exports.ConfirmModal=w.ConfirmModal;exports.ExpressionInput=w.ExpressionInput;exports.ExpressionOptionsProvider=w.ExpressionOptionsProvider;exports.IconButton=w.IconButton;exports.JsonEditor=w.JsonEditor;exports.Modal=w.Modal;exports.NodeConfigForm=w.NodeConfigForm;exports.ParamsForm=w.ParamsForm;exports.PropertyEntryForm=w.PropertyEntryForm;exports.RetryPolicyFields=w.RetryPolicyFields;exports.StepBuilderModal=w.StepBuilderModal;exports.W6WUIProvider=w.W6WUIProvider;exports.filterOptions=w.filterOptions;exports.isExprValue=w.isExprValue;exports.isSecretValue=w.isSecretValue;exports.isTestRequired=w.isTestRequired;exports.requiredParamsFilled=w.requiredParamsFilled;exports.shouldUseCombobox=w.shouldUseCombobox;exports.startOAuthPopup=w.startOAuthPopup;exports.useEnterSubmit=w.useEnterSubmit;exports.useExpressionOptions=w.useExpressionOptions;exports.useW6WApi=w.useW6WApi;exports.CodeBlock=X.CodeBlock;exports.Copyable=b.Copyable;exports.Icon=b.Icon;exports.iconNames=b.iconNames;exports.ActionTestForm=Fs;exports.ApiCallsPanel=Ge;exports.ApiError=z;exports.CopyableText=Bs;exports.DeleteButton=it;exports.EditButton=lt;exports.ExecutionDetail=St;exports.ExecutionFilters=jt;exports.ExecutionList=wt;exports.ExecutionLogPanel=Xe;exports.ExecutionStats=yt;exports.HealthStatusPill=Ls;exports.HistoryTimeline=at;exports.InfoTip=rt;exports.ListItem=Q;exports.RepoSyncIndicator=ot;exports.ServerResourcesBadge=Ys;exports.ServerResourcesCard=Vs;exports.ServerResourcesCardSmall=zs;exports.ServerResourcesRail=Gs;exports.StepStatusPill=ee;exports.UptimeStrip=Ds;exports.YamlEditor=_s;exports.createW6WApi=Ts;exports.cropText=Qe;exports.formatDurationMs=se;exports.formatExecutionTime=B;
|
|
1
|
+
"use client";"use strict";var $s=Object.defineProperty;var Cs=(s,t,n)=>t in s?$s(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var V=(s,t,n)=>Cs(s,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./ConfirmModal-8avl9Nv8.cjs"),e=require("react/jsx-runtime"),m=require("react"),X=require("./CodeBlock-CZu4TFSi.cjs"),Os=require("@codemirror/lang-yaml"),Rs=require("@codemirror/view"),Es=require("@uiw/react-codemirror"),b=require("./Copyable-CYZU1o4X.cjs");class z extends Error{constructor(n,l,c,a){super(c);V(this,"status");V(this,"code");V(this,"body");this.name="ApiError",this.status=n,this.code=l,this.body=a}}function Ts(s){const t=s.baseUrl.replace(/\/$/,""),n=s.fetch??globalThis.fetch,l=async()=>typeof s.token=="function"?await s.token():s.token;async function c(r,o){const d=new Headers(o==null?void 0:o.headers),u=await l();u&&d.set("authorization",`Bearer ${u}`),o!=null&&o.body&&!d.has("content-type")&&d.set("content-type","application/json");let h;try{h=await n(`${t}${r}`,{...o,headers:d})}catch(j){throw new z(0,"network_error",`Could not reach the w6w server (${(o==null?void 0:o.method)??"GET"} ${t}${r}). It may be down or unreachable. (${j.message})`)}const p=await h.text();let x=null;if(p)try{x=JSON.parse(p)}catch{if(!h.ok)throw new z(h.status,"bad_response",`Server returned a non-JSON ${h.status} response: ${p.slice(0,200)}`)}if(!h.ok){const j=(x==null?void 0:x.error)??{};throw new z(h.status,j.code??"error",j.message??h.statusText,x)}return{status:h.status,data:x}}async function a(r,o){const{data:d}=await c(r,o);return d}return{listApps:async()=>{const r=[];let o;for(let d=0;d<20;d++){const u=new URLSearchParams({limit:"200"});o&&u.set("cursor",o);const h=await a(`/apps?${u}`);if(r.push(...h.apps),!h.nextCursor)break;o=h.nextCursor}return r},listAppsByIds:async r=>{const o=Array.from(new Set(r)),d=[];for(let u=0;u<o.length;u+=100){const p=o.slice(u,u+100).map(encodeURIComponent).join(","),x=await a(`/apps?ids=${p}`);d.push(...x.apps)}return d},getAppAuth:async r=>(await a(`/apps/${encodeURIComponent(r)}/auths`)).auths??[],createConnection:(r,o)=>a(`/apps/${encodeURIComponent(r)}/connections`,{method:"POST",body:JSON.stringify(o)}).then(d=>d.connection),startAppOAuthFlow:(r,o,d)=>a(`/apps/${encodeURIComponent(r)}/oauth-config/${encodeURIComponent(o)}/authorize-url`,{method:"POST",body:JSON.stringify(d)}),getAppActions:r=>a(`/apps/${encodeURIComponent(r)}`).then(o=>o.actions??[]),listConnectionsForApp:r=>a(`/apps/${encodeURIComponent(r)}/connections`).then(o=>o.connections??[]),listConnections:()=>a("/connections").then(r=>r.connections??[]),invokeAction:(r,o,d,u={})=>a(`/apps/${encodeURIComponent(r)}/actions/${encodeURIComponent(o)}/invoke`,{method:"POST",body:JSON.stringify({params:d,connectionId:u.connectionId,project:u.project,state:u.state})}),listSavedTests:r=>a(`/connections/${encodeURIComponent(r)}/saved-tests`).then(o=>o.savedTests??[]),createSavedTest:(r,o)=>a(`/connections/${encodeURIComponent(r)}/saved-tests`,{method:"POST",body:JSON.stringify(o)}).then(d=>d.savedTest),updateSavedTest:(r,o,d)=>a(`/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(o)}`,{method:"PATCH",body:JSON.stringify(d)}).then(u=>u.savedTest),deleteSavedTest:(r,o)=>a(`/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(o)}`,{method:"DELETE"}).then(()=>{}),recordTestRun:(r,o)=>a(`/connections/${encodeURIComponent(r)}/test-runs`,{method:"POST",body:JSON.stringify(o)}).then(()=>{}),listTestRuns:r=>a(`/connections/${encodeURIComponent(r)}/test-runs`).then(o=>o.runs??[]),saveStepTest:(r,o,d)=>a(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/tests`,{method:"POST",body:JSON.stringify(d)}).then(u=>u.stepTest),listStepTests:(r,o)=>a(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/tests`).then(d=>d.stepTests??[]),recordStepTestRun:(r,o,d)=>a(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/test-runs`,{method:"POST",body:JSON.stringify(d)}).then(()=>{}),listFunctions:()=>a("/functions").then(r=>r.functions??[]),getFunction:r=>a(`/functions/${encodeURIComponent(r)}`).then(o=>({...o.function,valid:o.valid})),invokeFunction:(r,o)=>a(`/functions/${encodeURIComponent(r)}/invoke`,{method:"POST",body:JSON.stringify({inputs:o})}).then(d=>d.output),listWorkflows:()=>a("/workflows").then(r=>r.workflows??[]),getWorkflow:r=>a(`/workflows/${encodeURIComponent(r)}`).then(o=>o.workflow),runWorkflow:(r,o={})=>c(`/workflows/${encodeURIComponent(r)}/run?wait=true`,{method:"POST",body:JSON.stringify({variables:o.variables,input:o.input})}).then(({status:d,data:u})=>({...u??{},terminal:d===200}))}}function qe(s){if(!s)return"";try{return JSON.stringify(JSON.parse(s),null,2)}catch{return s}}function As(s,t){return`${s.method}-${s.url??s.host}-${t}`}function Ge({calls:s,defaultOpen:t,keyOf:n,title:l}){if(s.length===0)return null;const c=n??As;return e.jsxs("div",{className:"w6w-stack",style:{gap:4},children:[l!==!1&&e.jsx("strong",{className:"w6w-small",children:l??e.jsxs(e.Fragment,{children:["API ",s.length===1?"call":"calls"," (",s.length,")"]})}),s.map((a,r)=>e.jsxs("details",{open:t,className:"w6w-result",style:{padding:8},children:[e.jsx("summary",{style:{cursor:"pointer"},children:e.jsxs("span",{className:"w6w-small",children:[a.method," ",a.url??a.host," →"," ",e.jsx("strong",{children:a.error?"failed":a.status}),a.durationMs!==void 0&&e.jsxs("span",{className:"w6w-muted",children:[" · ",a.durationMs,"ms"]})]})}),e.jsxs("div",{className:"w6w-stack",style:{gap:6,marginTop:8},children:[a.error&&e.jsx("div",{className:"w6w-error w6w-small",children:a.error}),e.jsx("div",{className:"w6w-muted w6w-small",children:"Request headers"}),e.jsx("pre",{className:"w6w-result",children:JSON.stringify(a.requestHeaders??{},null,2)}),a.requestBody&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-muted w6w-small",children:"Request body"}),e.jsx("pre",{className:"w6w-result",children:qe(a.requestBody)})]}),e.jsx("div",{className:"w6w-muted w6w-small",children:"Response headers"}),e.jsx("pre",{className:"w6w-result",children:JSON.stringify(a.responseHeaders??{},null,2)}),a.responseBody&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-muted w6w-small",children:"Response body"}),e.jsx("pre",{className:"w6w-result",children:qe(a.responseBody)})]}),a.truncated&&e.jsx("div",{className:"w6w-muted w6w-small",children:"A captured body exceeded the size cap and was truncated."})]})]},c(a,r)))]})}function Q({title:s,subtitle:t,icon:n,trailing:l,active:c=!1,onClick:a,ariaLabel:r}){const o=e.jsxs(e.Fragment,{children:[n!=null&&e.jsx("span",{className:"w6w-list-item-icon",children:n}),e.jsxs("span",{className:"w6w-list-item-body",children:[e.jsx("span",{className:"w6w-list-item-title",children:s}),t!=null&&e.jsx("span",{className:"w6w-list-item-subtitle",children:t})]}),l!=null&&e.jsx("span",{className:"w6w-list-item-trailing",children:l})]}),d=`w6w-list-item${c?" active":""}`;return a?e.jsx("button",{type:"button",className:d,"aria-pressed":c,"aria-label":r,onClick:a,children:o}):e.jsx("div",{className:d,"aria-label":r,children:o})}function ue(s){const t=Date.parse(s);if(Number.isNaN(t))return"";const n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<45)return"just now";const l=Math.round(n/60);if(l<60)return`${l}m ago`;const c=Math.round(l/60);if(c<24)return`${c}h ago`;const a=Math.round(c/24);return a<7?`${a}d ago`:new Date(t).toLocaleDateString()}function We(s){const t={};for(const n of(s==null?void 0:s.params)??[])n.key&&n.default!==void 0&&(t[n.key]=n.default);return t}function Ms(s){var n,l,c;const t=s.indexOf("{");if(t>=0)try{const a=JSON.parse(s.slice(t)),r=((l=(n=a==null?void 0:a.errors)==null?void 0:n[0])==null?void 0:l.message)??(typeof(a==null?void 0:a.error)=="object"?(c=a.error)==null?void 0:c.message:a==null?void 0:a.error)??(a==null?void 0:a.message);if(typeof r=="string"&&r.trim()){const o=s.slice(0,t).replace(/[:\s]+$/,"");return o?`${o}: ${r.trim()}`:r.trim()}}catch{}return s}function Ye(s){return typeof s=="object"&&s!==null&&typeof s.status=="number"&&typeof s.code=="string"}function Ps(s){if(!Ye(s))return{headline:(s==null?void 0:s.message)??"The action failed to run."};const t=Ms(s.message??""),n=`${s.status} ${s.code} ${s.message??""}`.toLowerCase();return s.status===401||s.status===403||/\b(401|403)\b|forbidden|unauthorized|not authorized|permission|scope|access denied|invalid api key|invalid credential/.test(n)?{headline:"Permission denied by the provider — this is a credential/scope problem, not a w6w error.",hint:"The connection's API key is missing the permissions this action needs. Fix it at the provider — e.g. SendGrid → Settings → API Keys → give the key the required scopes (or Full Access), or create a new key — then update this connection's credential and try again.",detail:t}:{headline:"The action returned an error.",detail:t}}function Is(s){const t=Ye(s)?s.body??s.raw:null;return(t==null?void 0:t.apiCalls)??[]}function we(){const[s,t]=m.useState(""),[n,l]=m.useState(void 0),[c,a]=m.useState(!1);return{text:s,value:n,invalid:c,onChange:o=>{t(o);const d=o.trim();if(d===""){a(!1);return}try{const u=JSON.parse(d);u!==null&&typeof u=="object"&&!Array.isArray(u)?(l(u),a(!1)):a(!0)}catch{a(!0)}}}}function Fs({appId:s,actions:t,connectionId:n,action:l,seedValues:c,onSavedTestsChanged:a,seedTestId:r,onDirtyChange:o,onTestSaved:d,onDeleted:u,embedded:h=!1}){var Le;const p=w.useW6WApi(),x=m.useMemo(()=>{const i=[...t];return i.sort((f,y)=>(f.title||f.key).localeCompare(y.title||y.key)),i},[t]),[j,te]=m.useState((l==null?void 0:l.key)??""),v=l??t.find(i=>i.key===j)??null,[ge,be]=m.useState(!1),[E,M]=m.useState(null),[Se,P]=m.useState(void 0),[es,T]=m.useState([]),$=we(),C=we(),O=we(),[ne,ss]=m.useState(""),[ae,ts]=m.useState(""),ke=$.invalid||C.invalid||O.invalid,ns=()=>{const i={};return $.text.trim()!==""&&$.value!==void 0&&(i.body=$.value),C.text.trim()!==""&&C.value!==void 0&&(i.query=C.value),O.text.trim()!==""&&O.value!==void 0&&(i.headers=O.value),ne&&(i.target=ne),ae.trim()!==""&&(i.match=ae.trim()),Object.keys(i).length>0?i:void 0},[I,re]=m.useState("form"),[as,$e]=m.useState(""),[rs,Ce]=m.useState(!1),[R,Oe]=m.useState(!1),N=(v==null?void 0:v.key)??null,Re=c?{...c}:We(v),[Ee,J]=m.useState(()=>({key:N,values:Re})),[g,F]=m.useState(r??null),[Te,D]=m.useState(Re);if(Ee.key!==N){const i=We(v);J({key:N,values:i}),D(i),F(r??null),M(null),P(void 0),T([])}const[ls,is]=m.useState(r);r!==ls&&(is(r),F(r??null));const[Ae,os]=m.useState(c);if(c!==Ae){const i=JSON.stringify(c??null)!==JSON.stringify(Ae??null);if(os(c),c&&i){const f={...c};J({key:N,values:f}),D(f),M(null),P(void 0),T([])}}const S=Ee.values,Me=i=>J({key:N,values:i}),Pe=m.useMemo(()=>JSON.stringify(S)!==JSON.stringify(Te),[S,Te]);m.useEffect(()=>{o==null||o(Pe)},[Pe]);const cs=()=>{$e(JSON.stringify(S,null,2)),Ce(!1),re("json")},ds=async i=>{if(!v||ke)return;const f=v.key;be(!0),M(null),P(void 0),T([]);let y;const Je=ns();try{const A=await p.invokeAction(s,f,i,{connectionId:n,...Je?{overrides:Je}:{}});P(A.value),T(A.apiCalls??[]),y={ok:!0,summary:"OK",result:A.value}}catch(A){const De=Ps(A);M(De),T(Is(A)),y={ok:!1,summary:De.headline}}finally{be(!1)}if(n)try{await p.recordTestRun(n,{savedTestId:g??null,actionKey:f,ok:y.ok,summary:y.summary.slice(0,200),result:y.result}),ce(),js(),a==null||a()}catch{}},us=()=>ds(S),[q,Ie]=m.useState(null),[W,_]=m.useState(null),[ws,ms]=m.useState(0),[ps,H]=m.useState(!1),[le,ie]=m.useState(""),[hs,oe]=m.useState(!1),ce=()=>ms(i=>i+1);m.useEffect(()=>{if(!n){Ie(null);return}let i=!1;return _(null),p.listSavedTests(n).then(f=>!i&&Ie(f)).catch(f=>!i&&_(f.message)),()=>{i=!0}},[p,n,ws]);const Fe=N?(q??[]).filter(i=>i.actionKey===N):[],[xs,de]=m.useState(null),[fs,vs]=m.useState(0),js=()=>vs(i=>i+1);m.useEffect(()=>{const i=p.listTestRuns;if(!n||!i){de(null);return}let f=!1;return i(n).then(y=>!f&&de(y)).catch(()=>!f&&de(null)),()=>{f=!0}},[p,n,fs]);const _e=N?(xs??[]).filter(i=>i.actionKey===N).slice().sort((i,f)=>Date.parse(f.occurredAt)-Date.parse(i.occurredAt)):[],ys=()=>{!n||!v||(ie(""),_(null),H(!0))},Ns=()=>{!n||!v||(g?Be():ys())},Be=async()=>{if(!(!n||!v))try{let i;if(g)i=await p.updateSavedTest(n,g,{values:S});else{const f=le.trim();if(!f)return;i=await p.createSavedTest(n,{actionKey:v.key,name:f,values:S}),F(i.id)}D({...S}),H(!1),ie(""),ce(),a==null||a(),d==null||d(i)}catch(i){_(i.message)}},gs=i=>{const f={...i.values};J({key:N,values:f}),D(f),F(i.id),re("form"),M(null),P(void 0),T([])},bs=async()=>{if(!n||!g)return;const i=g;try{await p.deleteSavedTest(n,i),F(null),ce(),a==null||a(),u==null||u(i)}catch(f){_(f.message)}},Ss=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsxs("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"Parameters"}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-1)"},children:[e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${I==="form"?" active":""}`,"aria-pressed":I==="form",onClick:()=>re("form"),children:"Form"}),e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${I==="json"?" active":""}`,"aria-pressed":I==="json",onClick:cs,children:"JSON"}),!h&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-sm w6w-btn-ghost","aria-pressed":R,title:R?"Collapse the params editor":"Open the params editor in a larger view","aria-label":R?"Collapse the params editor":"Open the params editor in a larger view",onClick:()=>Oe(i=>!i),children:R?"⤡":"⤢"})]})]}),I==="form"?e.jsx(w.ParamsForm,{params:(v==null?void 0:v.params)??[],values:S,onChange:Me}):e.jsxs(e.Fragment,{children:[e.jsx(w.JsonEditor,{value:as,onChange:$e,minHeight:R?"50vh":"200px","aria-label":"Params JSON",onValidChange:i=>{i!==null&&typeof i=="object"&&!Array.isArray(i)&&Me(i)},onValidityChange:({valid:i})=>Ce(!i)}),rs&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]}),ks=e.jsxs("details",{className:"w6w-section","data-testid":"overrides-region",children:[e.jsxs("summary",{className:"w6w-section-summary",children:[e.jsx("span",{className:"w6w-section-title",children:"Overrides"}),e.jsx("span",{className:"w6w-section-subtitle",children:"Reach a vendor field this action's own params don't declare"})]}),e.jsxs("div",{className:"w6w-stack w6w-section-body",style:{gap:"var(--w6w-sp-2)"},children:[e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Body"}),e.jsx(w.JsonEditor,{value:$.text,onChange:$.onChange,minHeight:"80px","aria-label":"Overrides body (JSON)"}),$.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Query"}),e.jsx(w.JsonEditor,{value:C.text,onChange:C.onChange,minHeight:"80px","aria-label":"Overrides query (JSON)"}),C.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("div",{className:"w6w-field",children:[e.jsx("span",{children:"Headers"}),e.jsx(w.JsonEditor,{value:O.text,onChange:O.onChange,minHeight:"80px","aria-label":"Overrides headers (JSON)"}),O.invalid&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Target"}),e.jsxs("select",{"aria-label":"Overrides target",value:ne,onChange:i=>ss(i.target.value),children:[e.jsx("option",{value:"",children:"— default (first) —"}),e.jsx("option",{value:"first",children:"first"}),e.jsx("option",{value:"first-write",children:"first-write"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Match"}),e.jsx("input",{type:"text","aria-label":"Overrides match",value:ae,placeholder:"Restrict to requests whose URL contains…",onChange:i=>ts(i.target.value)})]}),e.jsx("span",{className:"w6w-hint",children:"Merged onto the outbound request at the wire, never into the params above — name a field the way the vendor's own API documents it."})]})]}),K=n?e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1-5)"},children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Saved tests"})}),W&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:W}),Fe.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"No saved tests for this action yet."}):e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:Fe.map(i=>e.jsx("li",{children:e.jsx(Q,{title:i.name,subtitle:i.lastRunAt?e.jsxs("span",{children:[e.jsx("span",{style:{color:i.lastRunOk?"var(--w6w-success)":"var(--w6w-danger)"},children:i.lastRunOk?"✓":"✗"})," ",i.lastRunSummary?`${i.lastRunSummary} · `:"",ue(i.lastRunAt)]}):`saved ${ue(i.updatedAt)}`,active:i.id===g,onClick:()=>gs(i)})},i.id))}),p.listTestRuns&&_e.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w6w-field-labelrow",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:e.jsx("span",{className:"w6w-muted w6w-small",children:"Recent runs"})}),e.jsx("ul",{className:"w6w-stack",style:{listStyle:"none",margin:0,padding:0,gap:"var(--w6w-sp-1-5)"},children:_e.map(i=>e.jsx("li",{children:e.jsx(Q,{title:e.jsxs("span",{children:[e.jsx("span",{style:{color:i.ok?"var(--w6w-success)":"var(--w6w-danger)"},children:i.ok?"✓":"✗"})," ",i.actionKey]}),subtitle:e.jsxs("span",{children:[i.summary?`${i.summary} · `:"",ue(i.occurredAt)]})})},i.id))})]})]}):null,Ue=(Le=q==null?void 0:q.find(i=>i.id===g))==null?void 0:Le.name;return e.jsxs("div",{className:`w6w-stack${h?" w6w-tester-embedded-root":""}`,children:[!l&&(t.length===0?e.jsx("p",{className:"w6w-muted w6w-small",children:"This app exposes no actions."}):e.jsxs("label",{className:"w6w-field",children:[e.jsxs("span",{children:["Action",N?"":" *"]}),e.jsx(w.Combobox,{value:j,placeholder:"— pick an action —",onChange:te,options:x.map(i=>({value:i.key,label:`${i.title??i.key} (${i.key})`}))})]})),v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[v.title??v.key," ",e.jsx("code",{className:"w6w-muted",children:v.key})]}),v.description&&e.jsx("p",{className:"w6w-muted w6w-small",style:{margin:"var(--w6w-sp-0-5) 0 0"},children:v.description})]}),(()=>{const i=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[Ss,ks,E&&e.jsxs("div",{className:"w6w-result w6w-error",children:[e.jsx("strong",{children:E.headline}),E.hint&&e.jsx("div",{style:{marginTop:"var(--w6w-sp-1-5)"},children:E.hint}),E.detail&&e.jsx("div",{className:"w6w-muted w6w-small",style:{marginTop:"var(--w6w-sp-1-5)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:E.detail})]}),Se!==void 0&&e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-1)"},children:[e.jsx("strong",{className:"w6w-small",children:"Result"}),e.jsx("pre",{className:"w6w-result",children:JSON.stringify(Se,null,2)})]}),e.jsx(Ge,{calls:es})]}),f=e.jsxs("div",{className:`w6w-tester-actions${h||R?" w6w-tester-actions-footer":""}`,style:{display:"flex",gap:"var(--w6w-sp-2)"},children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:ge||ke,onClick:us,children:ge?"Running…":"Run action"}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:Ns,children:"Save test"}),n&&g&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",style:{marginLeft:"auto",color:"var(--w6w-danger)"},onClick:()=>oe(!0),children:"Delete"})]}),y=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[i,f]});return h?e.jsxs("div",{className:"w6w-tester-embedded",children:[e.jsx("div",{className:"w6w-tester-embedded-scroll",children:K?e.jsxs("div",{className:"w6w-tester-embedded-cols",children:[e.jsx("div",{className:"w6w-tester-embedded-main",children:i}),e.jsx("div",{className:"w6w-tester-embedded-rail",children:K})]}):i}),f]}):R?e.jsx(w.Modal,{title:`Edit params — ${v.title??v.key}`,onClose:()=>Oe(!1),size:"full",children:e.jsxs("div",{className:"w6w-tester-popout",children:[e.jsx("div",{className:"w6w-tester-popout-scroll",children:K?e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-4)",alignItems:"flex-start"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:i}),e.jsx("div",{style:{width:260,flexShrink:0},children:K})]}):i}),f]})}):y})(),ps&&e.jsx(w.Modal,{title:"Save test",onClose:()=>H(!1),children:e.jsxs("form",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},onSubmit:i=>{i.preventDefault(),Be()},children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Name this saved test"}),e.jsx("input",{type:"text",value:le,placeholder:"e.g. valid sender",onChange:i=>ie(i.target.value)})]}),W&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:W}),e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-2)",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>H(!1),children:"Cancel"}),e.jsx("button",{type:"submit",className:"w6w-btn",disabled:!le.trim(),children:"Save"})]})]})}),hs&&e.jsx(w.ConfirmModal,{title:"Delete saved test",message:Ue?`Delete "${Ue}"? This cannot be undone.`:"Delete this saved test? This cannot be undone.",confirmLabel:"Delete",onConfirm:()=>{oe(!1),bs()},onClose:()=>oe(!1)})]}):!l&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action above to test it."})]})}function _s(s){const t=w.useEffectiveTheme(s.theme),{copied:n,copy:l}=b.useCopyToClipboard(s.value),c=m.useMemo(()=>[Os.yaml(),Rs.EditorView.theme({"&":{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:"2px solid 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"}})],[]);function a(r){s.onChange(r)}return e.jsxs("div",{className:"w6w-yaml-editor","aria-label":s["aria-label"]??"YAML editor",children:[e.jsx(Es,{value:s.value,onChange:a,extensions:c,placeholder:s.placeholder,readOnly:s.readOnly,editable:!s.readOnly,theme:t,height:s.height,minHeight:s.minHeight??"240px",maxHeight:s.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!s.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),s.copyable&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${n?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void l(),children:n?e.jsx(b.CheckGlyph,{}):e.jsx(b.CopyGlyph,{})}),e.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:n?"Copied":""})]})]})}const me="…";function Qe(s,t,n="end"){if(t===void 0||t<1||t>=s.length)return s;if(n==="start")return`${me}${s.slice(s.length-t)}`;if(n==="end")return`${s.slice(0,t)}${me}`;const l=Math.ceil(t/2),c=t-l;return`${s.slice(0,l)}${me}${s.slice(s.length-c)}`}function Bs(s){const{value:t,chars:n,crop:l="end",label:c,className:a,copiedMs:r}=s,o=Qe(t,n,l),d=["w6w-copyable--bare",a].filter(Boolean).join(" ");return e.jsx(b.Copyable,{value:t,readOnly:!0,label:c,className:d,copiedMs:r,children:e.jsx("span",{children:o})})}const Us={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Ls({state:s,label:t,ariaLabel:n}){const l=t??Us[s];return e.jsxs("span",{className:`w6w-health-pill w6w-health-pill-${s}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-health-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-health-pill-label",children:l})]})}const Js={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Ds({days:s,ariaLabel:t}){return s.length===0?null:e.jsx("div",{className:"w6w-uptime-strip",role:"img","aria-label":t??`${s.length}-day status`,children:s.map((n,l)=>e.jsx("span",{className:`w6w-uptime-cell w6w-uptime-cell-${n.state}`,title:n.label??`${n.day} — ${Js[n.state]}`},`${n.day}-${l}`))})}const Ze="—",He=["B","KiB","MiB","GiB","TiB","PiB"];function qs(s){if(s===null||!Number.isFinite(s))return Ze;if(s<1024)return`${Math.round(s)} B`;let t=s,n=0;for(;t>=1024&&n<He.length-1;)t/=1024,n+=1;return`${t.toFixed(1)} ${He[n]}`}function k(s){return s===null||!Number.isFinite(s)?Ze:`${Math.round(s*100)}%`}function U(s){if(s===void 0||s.load1===null)return null;const t=s.cpuLimit??s.cpus;return t===null||t<=0?null:s.load1/t}function L(s){if(s===void 0)return null;const{memoryTotal:t,memoryAvailable:n}=s;return t===null||n===null||t<=0?null:(t-n)/t}function Ws(s,t,n){return s<t?t:s>n?n:s}function Hs(s,t,n,l){const c=s.length;if(c<2)return"";const a=[];for(let r=0;r<c;r++){const o=s[r];if(o===null)continue;const d=r/(c-1)*t,u=l<=0?n:n-Ws(o,0,l)/l*n;a.push(`${Number(d.toFixed(2))},${Number(u.toFixed(2))}`)}return a.join(" ")}const Ks="—",Ke=100,Ve=24;function je({values:s,max:t,className:n}){const l=Hs(s,Ke,Ve,t);return l===""?null:e.jsx("svg",{className:n,viewBox:`0 0 ${Ke} ${Ve}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:e.jsx("polyline",{points:l,fill:"none",stroke:"var(--w6w-accent)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})})}function pe(s){return s===null?Ks:s.toFixed(2)}function Z(s){let t=1;for(const n of s)n!==null&&n>t&&(t=n);return t}function G({label:s,value:t,values:n,max:l}){return e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:s}),e.jsx("span",{className:"w6w-server-resources__value",children:t}),e.jsx(je,{className:"w6w-server-resources__spark",values:n,max:l})]})}function Ne(s){const t=s[s.length-1],n=s.map(a=>U(a)),l=s.map(a=>L(a)),c=s.map(a=>a.processRss);return{last:t,cpuValues:n,memoryValues:l,rssValues:c}}function Vs({samples:s,title:t="Server resources",intervalMs:n}){const{last:l,cpuValues:c,memoryValues:a,rssValues:r}=Ne(s);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--card","aria-label":t,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:t}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(G,{label:"CPU",value:k(U(l)),values:c,max:Z(c)}),e.jsx(G,{label:"Memory",value:k(L(l)),values:a,max:1}),e.jsx(G,{label:"Process",value:qs((l==null?void 0:l.processRss)??null),values:r,max:Z(r)})]}),e.jsx("p",{className:"w6w-server-resources__meta",children:`Load ${pe((l==null?void 0:l.load1)??null)} / ${pe((l==null?void 0:l.load5)??null)} / ${pe((l==null?void 0:l.load15)??null)}`}),n!==void 0&&e.jsx("p",{className:"w6w-server-resources__meta",children:`Sampled every ${n/1e3}s`})]})}function zs({samples:s,title:t="Server"}){const{last:n,cpuValues:l}=Ne(s);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--small","aria-label":t,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:t}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(G,{label:"CPU",value:k(U(n)),values:l,max:Z(l)}),e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"Memory"}),e.jsx("span",{className:"w6w-server-resources__value",children:k(L(n))})]})]})]})}function Gs({samples:s,onExpand:t}){const{last:n,cpuValues:l,memoryValues:c}=Ne(s);return e.jsxs("aside",{className:"w6w-server-resources w6w-server-resources--rail",children:[e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"CPU"}),e.jsx("span",{className:"w6w-server-resources__value",children:k(U(n))}),e.jsx(je,{className:"w6w-server-resources__spark",values:l,max:Z(l)})]}),e.jsxs("div",{className:"w6w-server-resources__rail-row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:"MEM"}),e.jsx("span",{className:"w6w-server-resources__value",children:k(L(n))}),e.jsx(je,{className:"w6w-server-resources__spark",values:c,max:1})]}),t!==void 0&&e.jsx("button",{type:"button",className:"w6w-server-resources__expand","aria-label":"Show server resources",onClick:t,children:"Details"})]})}function Ys({samples:s}){const t=s[s.length-1],n=k(U(t)),l=k(L(t));return e.jsx("span",{className:"w6w-server-resources w6w-server-resources--badge",children:`CPU ${n} · MEM ${l}`})}const Qs=1,Zs=1440*60*1e3;function Xs(s,t,n){const l=t.startedAt??t.updatedAt;if(l===void 0)return null;const c=Date.parse(l),a=t.resolvedAt!==void 0?Date.parse(t.resolvedAt):t.startedAt!==void 0?n:c,r=Date.parse(`${s.from}T00:00:00.000Z`),o=Date.parse(`${s.to}T00:00:00.000Z`)+Zs,d=o-r;if(a<r||c>=o)return null;const u=c<r,h=a>o,p=Math.max(c,r),x=Math.min(a,o),j=(p-r)/d*100,te=(x-p)/d*100,v=Math.max(te,Qs);return{leftPct:j,widthPct:v,clippedStart:u,clippedEnd:h}}const et={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"},st="This vendor publishes no incident history.",tt="No incidents in this window.";function nt(s){const t=s.startedAt??s.updatedAt,n=[s.title];return s.components!==void 0&&s.components.length>0&&n.push(`(${s.components.join(", ")})`),t!==void 0&&n.push(s.resolvedAt!==void 0?`${t} – ${s.resolvedAt}`:`${t} – ongoing`),n.join(" ")}function at({window:s,days:t,incidents:n,vendorEmptyLabel:l,nowMs:c=Date.now(),ariaLabel:a}){const r=t.length,o=r>0?100/r:0,d=n===void 0?l??st:n.length===0?l??tt:null;return e.jsx("div",{className:"w6w-history-timeline",role:"img","aria-label":a??`${r}-day history`,children:e.jsxs("div",{className:"w6w-history-plot",children:[e.jsx("div",{className:"w6w-history-lane w6w-history-lane-execution",children:t.map((u,h)=>e.jsx("span",{className:`w6w-history-cell w6w-history-cell-${u.state}`,style:{left:`${h*o}%`,width:`${o}%`},title:u.label??`${u.day} — ${et[u.state]}`},`${u.day}-${h}`))}),e.jsx("div",{className:"w6w-history-lane w6w-history-lane-vendor",children:d!==null?e.jsx("span",{className:"w6w-history-empty",title:d,children:d}):n==null?void 0:n.map((u,h)=>{const p=Xs(s,u,c);if(p===null)return null;const x=[p.clippedStart?"w6w-history-bar-clip-start":"",p.clippedEnd?"w6w-history-bar-clip-end":""].filter(Boolean).join(" ");return e.jsx("span",{className:`w6w-history-bar w6w-history-bar-${u.state}${x?` ${x}`:""}`,style:{left:`${p.leftPct}%`,width:`${p.widthPct}%`},title:nt(u)},u.id??`${u.title}-${h}`)})}),e.jsxs("div",{className:"w6w-history-axis",children:[e.jsx("span",{className:"w6w-history-tick w6w-history-tick-start",style:{left:"0%"},children:s.from}),e.jsx("span",{className:"w6w-history-tick w6w-history-tick-end",style:{left:"100%"},children:s.to})]})]})})}function rt({label:s,children:t,className:n}){const[l,c]=m.useState(!1),a=m.useId();return e.jsxs("span",{className:["w6w-info-tip",n??""].filter(Boolean).join(" "),children:[e.jsx(w.IconButton,{label:s,icon:"info","aria-expanded":l,"aria-controls":a,onClick:()=>c(r=>!r)}),l&&e.jsx("span",{id:a,className:"w6w-info-tip-body w6w-muted w6w-small",children:t})]})}function lt(s){const{label:t,onClick:n,disabled:l,className:c,...a}=s;return e.jsx(w.IconButton,{label:t,onClick:n,disabled:l,className:c,icon:"edit","data-testid":a["data-testid"]})}function it(s){const{label:t,onClick:n,disabled:l,className:c,...a}=s;return e.jsx(w.IconButton,{label:t,onClick:n,disabled:l,className:c,danger:!0,icon:"delete","data-testid":a["data-testid"]})}function ot(s){const{branch:t,shortSha:n,lastSyncLabel:l,onSyncNow:c,syncing:a,className:r,...o}=s,[d,u]=m.useState(!1),h=m.useRef(null);return m.useEffect(()=>{if(!d)return;const p=j=>{h.current&&!h.current.contains(j.target)&&u(!1)},x=j=>j.key==="Escape"&&u(!1);return document.addEventListener("mousedown",p),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",x)}},[d]),e.jsxs("div",{className:`w6w-repo-sync${r?` ${r}`:""}`,ref:h,"data-testid":o["data-testid"],children:[e.jsxs("button",{type:"button",className:"w6w-repo-sync-trigger","aria-haspopup":"menu","aria-expanded":d,"aria-busy":a,onClick:()=>u(p=>!p),children:[e.jsxs("span",{className:"w6w-repo-sync-icon",children:[e.jsx(b.Icon,{name:"github"}),a&&e.jsx(b.Icon,{name:"sync",size:10,className:"w6w-repo-sync-spin"})]}),e.jsx("span",{className:"w6w-repo-sync-branch",children:t}),n!=null&&e.jsx("code",{className:"w6w-repo-sync-sha",children:n})]}),d&&e.jsxs("div",{className:"w6w-repo-sync-menu",role:"menu",children:[e.jsxs("div",{className:"w6w-repo-sync-detail",children:[e.jsx("span",{children:t}),n!=null&&e.jsx("code",{children:n}),l!=null&&e.jsx("span",{children:l})]}),e.jsx("button",{type:"button",role:"menuitem",className:"w6w-repo-sync-item","data-testid":"repo-sync-now",disabled:a,onClick:c,children:a?"Syncing…":"Sync now"})]})]})}const ct={pending:"Pending",running:"Running",succeeded:"Succeeded",failed:"Failed",skipped:"Skipped",queued:"Queued",canceled:"Canceled"};function ee({state:s,label:t,ariaLabel:n}){const l=t??ct[s];return e.jsxs("span",{className:`w6w-step-pill w6w-step-pill-${s}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-step-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-step-pill-label",children:l})]})}const dt="—",he=1e3,xe=6e4;function se(s){return s==null||!Number.isFinite(s)||s<0?dt:s<he?`${Math.round(s)} ms`:s<xe?`${(s/he).toFixed(1)} s`:`${Math.floor(s/xe)}m ${Math.round(s%xe/he)}s`}function B(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}const ut={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function wt({items:s,selectedId:t=null,onSelect:n,showCallable:l=!1,loading:c=!1,emptyLabel:a,hasPrev:r,hasNext:o,onPrev:d,onNext:u}){const h=d||u?e.jsxs("div",{className:"w6w-execution-list-pager",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-prev",disabled:!r,onClick:d,children:"Previous"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-next",disabled:!o,onClick:u,children:"Next"})]}):null;let p;return c&&s.length===0?p=e.jsx("p",{"data-testid":"execution-list-loading",children:"Loading…"}):s.length===0?p=e.jsx("p",{"data-testid":"execution-list-empty",children:a??"No executions yet."}):p=e.jsx("ul",{className:"w6w-execution-list-rows",children:s.map(x=>e.jsx("li",{"data-testid":"execution-row","data-execution-id":x.id,children:e.jsx(Q,{icon:e.jsx(ee,{state:x.status}),title:l?x.callableName:B(x.startedAt),subtitle:l?`${ut[x.kind]} · ${B(x.startedAt)}`:x.id,trailing:se(x.durationMs),active:x.id===t,onClick:n?()=>n(x.id):void 0})},x.id))}),e.jsxs("div",{className:"w6w-execution-list","data-testid":"execution-list",children:[p,h]})}function Xe({steps:s,emptyLabel:t,onDismiss:n,runError:l,stepErrors:c}){const a=n?e.jsx("div",{className:"w6w-execution-log-head",children:e.jsx(w.IconButton,{label:"Dismiss run log","data-testid":"execution-log-dismiss",onClick:n,children:"×"})}):null,r=c??[],o=l||r.length>0?e.jsxs("div",{className:"w6w-execution-log-errors w6w-stack",children:[l&&e.jsx(ye,{error:l}),r.map((d,u)=>e.jsx(ye,{label:d.label??d.stepId,error:d.error},`${d.stepId}:${u}`))]}):null;return s.length===0?e.jsxs(e.Fragment,{children:[a,o,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:t??"No steps have run yet."})})]}):e.jsxs(e.Fragment,{children:[a,o,e.jsx("ol",{className:"w6w-execution-log",children:s.map(d=>e.jsx(mt,{step:d},d.id))})]})}function mt({step:s}){const[t,n]=m.useState(!1),l=e.jsxs("div",{className:"w6w-execution-log-row-header",children:[e.jsx(ee,{state:s.status}),e.jsx("span",{className:"w6w-execution-log-row-label",children:s.label??s.id}),e.jsx(pt,{startedAt:s.startedAt,finishedAt:s.finishedAt})]}),c=s.error?e.jsx(ye,{error:s.error}):null;return s.input===void 0&&s.output===void 0&&!s.meta?e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsx("div",{className:"w6w-section",children:l}),c]}):e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsxs("details",{className:"w6w-section",open:t,onToggle:a=>n(a.currentTarget.open),children:[e.jsx("summary",{className:"w6w-section-summary",children:l}),t&&e.jsxs("div",{className:"w6w-execution-log-row-body w6w-section-body w6w-stack",children:[e.jsx(ze,{title:"Input",value:s.input}),e.jsx(ze,{title:"Output",value:s.output}),s.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(X.CodeBlock,{code:JSON.stringify(s.meta,null,2),language:"json"})]})]})]}),c]})}function ye({error:s,label:t}){return e.jsxs("div",{className:"w6w-result w6w-error",children:[t!==void 0&&e.jsx("strong",{className:"w6w-execution-log-error-label",children:t}),s.code&&e.jsx("div",{className:"w6w-small w6w-execution-log-error-code",children:e.jsx("code",{children:s.code})}),s.message]})}function pt({startedAt:s,finishedAt:t}){if(s&&t){const n=ht(s,t);return e.jsxs("span",{className:"w6w-execution-log-timing",children:[s," → ",t,n&&e.jsxs("span",{children:[" (",n,")"]})]})}return s?e.jsxs("span",{className:"w6w-execution-log-timing",children:["Started ",s]}):e.jsx("span",{className:"w6w-execution-log-timing",children:"—"})}function ht(s,t){const n=Date.parse(s),l=Date.parse(t);if(!Number.isFinite(n)||!Number.isFinite(l)||l<n)return null;const c=l-n;if(c<1e3)return`${c}ms`;const a=c/1e3;if(a<60)return`${a.toFixed(1)}s`;const r=Math.floor(a/60),o=Math.round(a%60);return`${r}m ${o}s`}function ze({title:s,value:t}){return e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:s}),t===void 0?e.jsx("p",{className:"w6w-muted w6w-small",children:"Not available."}):e.jsx(X.CodeBlock,{code:JSON.stringify(t,null,2),language:"json"})]})}const xt={status:"",kind:"",from:"",to:"",q:""},ft=[{value:"",label:"Any status"},{value:"queued",label:"Queued"},{value:"running",label:"Running"},{value:"succeeded",label:"Succeeded"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}],vt=[{value:"",label:"Any type"},{value:"function",label:"Function"},{value:"endpoint",label:"Endpoint"},{value:"workflow",label:"Workflow"}];function jt({value:s,onChange:t,showKind:n=!1,searchPlaceholder:l="Search by id or name",disabled:c=!1}){const a=s.status!==""||s.kind!==""||s.from!==""||s.to!==""||s.q!=="";return e.jsxs("div",{className:"w6w-execution-filters","data-testid":"execution-filters",children:[e.jsx("input",{type:"search",className:"w6w-execution-filters-search","data-testid":"execution-filter-q","aria-label":"Search executions",placeholder:l,value:s.q,disabled:c,onChange:r=>t({...s,q:r.target.value})}),e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-status","aria-label":"Status",value:s.status,disabled:c,onChange:r=>t({...s,status:r.target.value}),children:ft.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),n&&e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-kind","aria-label":"Type",value:s.kind,disabled:c,onChange:r=>t({...s,kind:r.target.value}),children:vt.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-from","aria-label":"From date",value:s.from,disabled:c,onChange:r=>t({...s,from:r.target.value})}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-to","aria-label":"To date",value:s.to,disabled:c,onChange:r=>t({...s,to:r.target.value})}),a&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-execution-filters-clear","data-testid":"execution-filter-clear",disabled:c,onClick:()=>t({...xt}),children:"Clear"})]})}const Y="—";function yt({stats:s,label:t}){const n=[{testid:"execution-stat-total",label:"Executions",value:s?String(s.total):Y},{testid:"execution-stat-success-rate",label:"Success rate",value:Nt(s==null?void 0:s.successRate)},{testid:"execution-stat-failed",label:"Failed",value:s?String(s.failed):Y},{testid:"execution-stat-avg-duration",label:"Avg duration",value:s?se(s.avgDurationMs):Y}];return s&&s.inFlight>0&&n.push({testid:"execution-stat-in-flight",label:"In flight",value:String(s.inFlight)}),e.jsxs("section",{className:"w6w-execution-stats","data-testid":"execution-stats",children:[t!=null&&e.jsx("p",{className:"w6w-execution-stats-label",children:t}),e.jsx("div",{className:"w6w-execution-stats-cards",children:n.map(l=>e.jsxs("div",{className:"w6w-execution-stat","data-testid":l.testid,children:[e.jsx("span",{className:"w6w-execution-stat-value","data-stat-value":l.value,children:l.value}),e.jsx("span",{className:"w6w-execution-stat-label",children:l.label})]},l.testid))})]})}function Nt(s){return s==null||!Number.isFinite(s)?Y:`${Math.round(s*100)}%`}const gt={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function bt(s){return JSON.stringify(s,null,2)??"null"}function St({execution:s,loading:t=!1,errorMessage:n,onClose:l,onOpenInEditor:c}){return e.jsxs("section",{className:"w6w-execution-detail w6w-stack","data-testid":"execution-detail",children:[n!=null&&e.jsx("p",{role:"alert",className:"w6w-execution-detail-error-message","data-testid":"execution-detail-error-message",children:n}),s?e.jsx(kt,{execution:s,onClose:l,onOpenInEditor:c}):t?e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-loading",children:"Loading…"}):e.jsx("p",{className:"w6w-muted","data-testid":"execution-detail-empty",children:"No execution selected."})]})}function kt({execution:s,onClose:t,onOpenInEditor:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w6w-execution-detail-head",children:[e.jsxs("div",{className:"w6w-execution-detail-title",children:[e.jsx("h3",{className:"w6w-execution-detail-name",children:s.callableName}),e.jsxs("div",{className:"w6w-execution-detail-meta",children:[e.jsx(ee,{state:s.status}),e.jsx("span",{className:"w6w-execution-detail-kind w6w-muted w6w-small",children:gt[s.kind]})]})]}),(n||t)&&e.jsxs("div",{className:"w6w-execution-detail-actions",children:[n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-open-editor",onClick:n,children:"Open in visual editor"}),t&&e.jsx(w.IconButton,{label:"Close","data-testid":"execution-detail-close",onClick:t,children:"×"})]})]}),e.jsx("p",{className:"w6w-execution-detail-id-line",children:e.jsx("code",{className:"w6w-execution-detail-id","data-testid":"execution-detail-id",children:s.id})}),e.jsxs("dl",{className:"w6w-execution-detail-timing",children:[e.jsx(fe,{label:"Started",value:B(s.startedAt)}),e.jsx(fe,{label:"Finished",value:s.finishedAt?B(s.finishedAt):"—"}),e.jsx(fe,{label:"Duration",value:se(s.durationMs)})]}),s.steps!==void 0&&e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":"execution-detail-steps",children:[e.jsx("strong",{className:"w6w-small",children:"Steps"}),e.jsx(Xe,{steps:s.steps,emptyLabel:"No steps ran."})]}),s.input!==void 0&&e.jsx(ve,{title:"Input",testid:"execution-detail-input",value:s.input}),s.output!==void 0&&e.jsx(ve,{title:"Output",testid:"execution-detail-output",value:s.output}),s.error!=null&&e.jsx(ve,{title:"Error",testid:"execution-detail-error",value:s.error})]})}function fe({label:s,value:t}){return e.jsxs("div",{className:"w6w-execution-detail-timing-item",children:[e.jsx("dt",{children:s}),e.jsx("dd",{children:t})]})}function ve({title:s,testid:t,value:n}){return e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":t,children:[e.jsx("strong",{className:"w6w-small",children:s}),e.jsx(X.CodeBlock,{code:bt(n),language:"json"})]})}exports.AddConnectionModal=w.AddConnectionModal;exports.AppIcon=w.AppIcon;exports.AppPicker=w.AppPicker;exports.AuthFieldsForm=w.AuthFieldsForm;exports.CodeEditor=w.CodeEditor;exports.Combobox=w.Combobox;exports.ConfirmModal=w.ConfirmModal;exports.ExpressionInput=w.ExpressionInput;exports.ExpressionOptionsProvider=w.ExpressionOptionsProvider;exports.IconButton=w.IconButton;exports.JsonEditor=w.JsonEditor;exports.Modal=w.Modal;exports.NodeConfigForm=w.NodeConfigForm;exports.ParamsForm=w.ParamsForm;exports.PropertyEntryForm=w.PropertyEntryForm;exports.RetryPolicyFields=w.RetryPolicyFields;exports.StepBuilderModal=w.StepBuilderModal;exports.W6WUIProvider=w.W6WUIProvider;exports.filterOptions=w.filterOptions;exports.isExprValue=w.isExprValue;exports.isSecretValue=w.isSecretValue;exports.isTestRequired=w.isTestRequired;exports.requiredParamsFilled=w.requiredParamsFilled;exports.shouldUseCombobox=w.shouldUseCombobox;exports.startOAuthPopup=w.startOAuthPopup;exports.useEnterSubmit=w.useEnterSubmit;exports.useExpressionOptions=w.useExpressionOptions;exports.useW6WApi=w.useW6WApi;exports.CodeBlock=X.CodeBlock;exports.Copyable=b.Copyable;exports.Icon=b.Icon;exports.iconNames=b.iconNames;exports.ActionTestForm=Fs;exports.ApiCallsPanel=Ge;exports.ApiError=z;exports.CopyableText=Bs;exports.DeleteButton=it;exports.EditButton=lt;exports.ExecutionDetail=St;exports.ExecutionFilters=jt;exports.ExecutionList=wt;exports.ExecutionLogPanel=Xe;exports.ExecutionStats=yt;exports.HealthStatusPill=Ls;exports.HistoryTimeline=at;exports.InfoTip=rt;exports.ListItem=Q;exports.RepoSyncIndicator=ot;exports.ServerResourcesBadge=Ys;exports.ServerResourcesCard=Vs;exports.ServerResourcesCardSmall=zs;exports.ServerResourcesRail=Gs;exports.StepStatusPill=ee;exports.UptimeStrip=Ds;exports.YamlEditor=_s;exports.createW6WApi=Ts;exports.cropText=Qe;exports.formatDurationMs=se;exports.formatExecutionTime=B;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|