@w6w/ui 0.2.66 → 0.2.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +5 -3
  3. package/dist/FormBuilder.d.ts +19 -0
  4. package/dist/ManualWebhookPanel.d.ts +34 -0
  5. package/dist/TriggerFillForm.d.ts +3 -0
  6. package/dist/WebhookListenPanel.d.ts +8 -1
  7. package/dist/components/AuthFieldsForm.d.ts +10 -0
  8. package/dist/components/AuthGuide.d.ts +19 -1
  9. package/dist/components/CallableList.d.ts +30 -4
  10. package/dist/components/Combobox.d.ts +5 -0
  11. package/dist/components/ExpressionOptions.d.ts +22 -0
  12. package/dist/{connection-app-meta-CKBbgN7e.js → connection-app-meta-DEC0n4PA.js} +4894 -4211
  13. package/dist/connection-app-meta-DEC0n4PA.js.map +1 -0
  14. package/dist/connection-app-meta-Dk6F3KEH.cjs +29 -0
  15. package/dist/connection-app-meta-Dk6F3KEH.cjs.map +1 -0
  16. package/dist/dynamic-fields.d.ts +3 -0
  17. package/dist/flow-types.d.ts +2 -0
  18. package/dist/flow.cjs +6 -5
  19. package/dist/flow.cjs.map +1 -1
  20. package/dist/flow.mjs +3515 -2436
  21. package/dist/flow.mjs.map +1 -1
  22. package/dist/form-schema.d.ts +236 -0
  23. package/dist/form-trigger.d.ts +8 -0
  24. package/dist/index.cjs +2 -2
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +4 -4
  27. package/dist/index.mjs +1325 -1272
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/provider.d.ts +12 -0
  30. package/dist/resolve-params.d.ts +2 -0
  31. package/dist/types.d.ts +17 -1
  32. package/dist/workflow-connections.d.ts +11 -0
  33. package/package.json +2 -2
  34. package/src/styles/_callable-list.scss +37 -3
  35. package/src/styles/_connections.scss +29 -0
  36. package/src/styles/_expression-modal.scss +7 -0
  37. package/src/styles/_form-builder.scss +232 -0
  38. package/src/styles/_sections.scss +29 -0
  39. package/src/styles.css +386 -3
  40. package/src/styles.scss +1 -0
  41. package/dist/connection-app-meta-CKBbgN7e.js.map +0 -1
  42. package/dist/connection-app-meta-DfA6Yqhh.cjs +0 -28
  43. package/dist/connection-app-meta-DfA6Yqhh.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use client";"use strict";var Gs=Object.defineProperty;var Xs=(t,s,n)=>s in t?Gs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var we=(t,s,n)=>Xs(t,typeof s!="symbol"?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./connection-app-meta-DfA6Yqhh.cjs"),g=require("react"),e=require("react/jsx-runtime"),M=require("./CodeBlock-C1IC5_6O.cjs"),Zs=require("@codemirror/lang-yaml"),Qs=require("@codemirror/view"),en=require("@uiw/react-codemirror"),tn=require("react-dom");class pe extends Error{constructor(n,a,i,l){super(i);we(this,"status");we(this,"code");we(this,"body");this.name="ApiError",this.status=n,this.code=a,this.body=l}}function sn(t){const s=t.baseUrl.replace(/\/$/,""),n=t.fetch??globalThis.fetch,a=async()=>typeof t.token=="function"?await t.token():t.token;async function i(r,o){const c=new Headers(o==null?void 0:o.headers),d=await a();d&&c.set("authorization",`Bearer ${d}`),o!=null&&o.body&&!c.has("content-type")&&c.set("content-type","application/json");let m;try{m=await n(`${s}${r}`,{...o,headers:c})}catch(w){throw new pe(0,"network_error",`Could not reach the w6w server (${(o==null?void 0:o.method)??"GET"} ${s}${r}). It may be down or unreachable. (${w.message})`)}const x=await m.text();let b=null;if(x)try{b=JSON.parse(x)}catch{if(!m.ok)throw new pe(m.status,"bad_response",`Server returned a non-JSON ${m.status} response: ${x.slice(0,200)}`)}if(!m.ok){const w=(b==null?void 0:b.error)??{};throw new pe(m.status,w.code??"error",w.message??m.statusText,b)}return{status:m.status,data:b}}async function l(r,o){const{data:c}=await i(r,o);return c}return{listApps:async()=>{const r=async()=>{const o=[];let c;for(;;){const d=new URLSearchParams({limit:"200"});c&&d.set("cursor",c);const m=await l(`/apps?${d}`);if(o.push(...m.apps),!m.nextCursor||m.nextCursor===c)return o;c=m.nextCursor}};try{return await r()}catch(o){if(o instanceof pe&&(o.code==="snapshot_expired"||o.code==="unknown_snapshot"))return await r();throw o}},listAppsByIds:async r=>{const o=Array.from(new Set(r)),c=[];for(let d=0;d<o.length;d+=100){const x=o.slice(d,d+100).map(encodeURIComponent).join(","),b=await l(`/apps?ids=${x}`);c.push(...b.apps)}return c},getAppAuth:async r=>(await l(`/apps/${encodeURIComponent(r)}/auths`)).auths??[],createConnection:(r,o)=>l(`/apps/${encodeURIComponent(r)}/connections`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.connection),updateConnection:(r,o)=>l(`/connections/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(o)}).then(c=>c.connection),listCredentials:r=>{const o=new URLSearchParams;(r==null?void 0:r.contract)!==void 0&&o.set("contract",r.contract),(r==null?void 0:r.appId)!==void 0&&o.set("appId",r.appId),(r==null?void 0:r.authKey)!==void 0&&o.set("authKey",r.authKey);const c=o.toString();return l(`/credentials${c?`?${c}`:""}`).then(d=>d.credentials??[])},createCredential:r=>l("/credentials",{method:"POST",body:JSON.stringify(r)}).then(o=>o.credential),getCredential:r=>l(`/credentials/${encodeURIComponent(r)}`).then(o=>o.credential),rotateCredential:(r,o)=>l(`/credentials/${encodeURIComponent(r)}/rotate`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.credential),setCredentialStatus:(r,o)=>l(`/credentials/${encodeURIComponent(r)}/${o==="disabled"?"disable":"enable"}`,{method:"POST"}).then(c=>c.credential),testCredential:r=>l(`/credentials/${encodeURIComponent(r)}/test`,{method:"POST"}),credentialDependents:r=>l(`/credentials/${encodeURIComponent(r)}/dependents`).then(o=>o.dependents),deleteCredential:async r=>{await l(`/credentials/${encodeURIComponent(r)}`,{method:"DELETE"})},startAppOAuthFlow:(r,o,c)=>l(`/apps/${encodeURIComponent(r)}/oauth-config/${encodeURIComponent(o)}/authorize-url`,{method:"POST",body:JSON.stringify(c)}),getAppActions:r=>l(`/apps/${encodeURIComponent(r)}`).then(o=>o.actions??[]),listConnectionsForApp:r=>l(`/apps/${encodeURIComponent(r)}/connections`).then(o=>o.connections??[]),listConnections:()=>l("/connections").then(r=>r.connections??[]),invokeAction:(r,o,c,d={})=>l(`/apps/${encodeURIComponent(r)}/actions/${encodeURIComponent(o)}/invoke`,{method:"POST",body:JSON.stringify({params:c,connectionId:d.connectionId,project:d.project,state:d.state,workflowId:d.workflowId})}),listSavedTests:r=>l(`/connections/${encodeURIComponent(r)}/saved-tests`).then(o=>o.savedTests??[]),createSavedTest:(r,o)=>l(`/connections/${encodeURIComponent(r)}/saved-tests`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.savedTest),updateSavedTest:(r,o,c)=>l(`/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(o)}`,{method:"PATCH",body:JSON.stringify(c)}).then(d=>d.savedTest),deleteSavedTest:(r,o)=>l(`/connections/${encodeURIComponent(r)}/saved-tests/${encodeURIComponent(o)}`,{method:"DELETE"}).then(()=>{}),recordTestRun:(r,o)=>l(`/connections/${encodeURIComponent(r)}/test-runs`,{method:"POST",body:JSON.stringify(o)}).then(()=>{}),listTestRuns:r=>l(`/connections/${encodeURIComponent(r)}/test-runs`).then(o=>o.runs??[]),saveStepTest:(r,o,c)=>l(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/tests`,{method:"POST",body:JSON.stringify(c)}).then(d=>d.stepTest),listStepTests:(r,o)=>l(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/tests`).then(c=>c.stepTests??[]),loadNodeSamples:r=>l(`/workflows/${encodeURIComponent(r)}/node-samples`).then(o=>o.nodeSamples??[]),loadTestInputs:r=>l(`/workflows/${encodeURIComponent(r)}/test-inputs`).then(o=>o.testInputs??[]),saveTestInput:(r,o,c)=>l(`/workflows/${encodeURIComponent(r)}/nodes/${encodeURIComponent(o)}/test-input`,{method:"PUT",body:JSON.stringify({input:c})}).then(()=>{}),recordStepTestRun:(r,o,c)=>l(`/workflows/${encodeURIComponent(r)}/steps/${encodeURIComponent(o)}/test-runs`,{method:"POST",body:JSON.stringify(c)}).then(()=>{}),listFunctions:()=>l("/functions").then(r=>r.functions??[]),getFunction:r=>l(`/functions/${encodeURIComponent(r)}`).then(o=>({...o.function,valid:o.valid})),invokeFunction:(r,o)=>l(`/functions/${encodeURIComponent(r)}/invoke`,{method:"POST",body:JSON.stringify({inputs:o})}).then(c=>c.output),listWorkflows:()=>l("/workflows").then(r=>r.workflows??[]),getWorkflow:r=>l(`/workflows/${encodeURIComponent(r)}`).then(o=>o.workflow),runWorkflow:(r,o={})=>i(`/workflows/${encodeURIComponent(r)}/run?wait=true`,{method:"POST",body:JSON.stringify({variables:o.variables,input:o.input,entry:o.entry})}).then(({status:c,data:d})=>({...d??{},terminal:c===200}))}}const nn=g.createContext(void 0);function Te({title:t,subtitle:s,icon:n,trailing:a,active:i=!1,onClick:l,href:r,ariaLabel:o}){const c=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:t}),s!=null&&e.jsx("span",{className:"w6w-list-item-subtitle",children:s})]}),a!=null&&e.jsx("span",{className:"w6w-list-item-trailing",children:a})]}),d=`w6w-list-item${i?" active":""}`;return r!==void 0?e.jsx("a",{className:d,href:r,"aria-current":i?"true":void 0,"aria-label":o,onClick:l,children:c}):l?e.jsx("button",{type:"button",className:d,"aria-pressed":i,"aria-label":o,onClick:l,children:c}):e.jsx("div",{className:d,"aria-label":o,children:c})}function Ve(t){const s=Date.parse(t);if(Number.isNaN(s))return"";const n=Math.max(0,Math.round((Date.now()-s)/1e3));if(n<45)return"just now";const a=Math.round(n/60);if(a<60)return`${a}m ago`;const i=Math.round(a/60);if(i<24)return`${i}h ago`;const l=Math.round(i/24);return l<7?`${l}d ago`:new Date(s).toLocaleDateString()}function Ct(t){const s={};for(const n of(t==null?void 0:t.params)??[])n.key&&n.default!==void 0&&(s[n.key]=n.default);return s}function an(t){var n,a,i;const s=t.indexOf("{");if(s>=0)try{const l=JSON.parse(t.slice(s)),r=((a=(n=l==null?void 0:l.errors)==null?void 0:n[0])==null?void 0:a.message)??(typeof(l==null?void 0:l.error)=="object"?(i=l.error)==null?void 0:i.message:l==null?void 0:l.error)??(l==null?void 0:l.message);if(typeof r=="string"&&r.trim()){const o=t.slice(0,s).replace(/[:\s]+$/,"");return o?`${o}: ${r.trim()}`:r.trim()}}catch{}return t}function qt(t){return typeof t=="object"&&t!==null&&typeof t.status=="number"&&typeof t.code=="string"}function rn(t){if(!qt(t))return{headline:(t==null?void 0:t.message)??"The action failed to run."};const s=an(t.message??""),n=`${t.status} ${t.code} ${t.message??""}`.toLowerCase();return t.status===401||t.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:s}:{headline:"The action returned an error.",detail:s}}function ln(t){const s=qt(t)?t.body??t.raw:null;return(s==null?void 0:s.apiCalls)??[]}function Ke(){const[t,s]=g.useState(""),[n,a]=g.useState(void 0),[i,l]=g.useState(!1);return{text:t,value:n,invalid:i,onChange:o=>{s(o);const c=o.trim();if(c===""){l(!1);return}try{const d=JSON.parse(c);d!==null&&typeof d=="object"&&!Array.isArray(d)?(a(d),l(!1)):l(!0)}catch{l(!0)}}}}function on({appId:t,actions:s,connectionId:n,action:a,seedValues:i,onSavedTestsChanged:l,seedTestId:r,onDirtyChange:o,onTestSaved:c,onDeleted:d,embedded:m=!1}){var kt;const x=h.useW6WApi(),b=g.useMemo(()=>{const j=[...s];return j.sort((_,J)=>(_.title||_.key).localeCompare(J.title||J.key)),j},[s]),[w,p]=g.useState((a==null?void 0:a.key)??""),v=a??s.find(j=>j.key===w)??null,[u,f]=g.useState(!1),[y,N]=g.useState(null),[S,k]=g.useState(void 0),[E,C]=g.useState([]),P=Ke(),I=Ke(),W=Ke(),[T,Y]=g.useState(""),[O,H]=g.useState(""),R=P.invalid||I.invalid||W.invalid,D=()=>{const j={};return P.text.trim()!==""&&P.value!==void 0&&(j.body=P.value),I.text.trim()!==""&&I.value!==void 0&&(j.query=I.value),W.text.trim()!==""&&W.value!==void 0&&(j.headers=W.value),T&&(j.target=T),O.trim()!==""&&(j.match=O.trim()),Object.keys(j).length>0?j:void 0},[L,B]=g.useState("form"),[ce,G]=g.useState(""),[X,de]=g.useState(!1),[z,ve]=g.useState(!1),V=(v==null?void 0:v.key)??null,je=i?{...i}:Ct(v),[ne,A]=g.useState(()=>({key:V,values:je})),[$,F]=g.useState(r??null),[K,ae]=g.useState(je);if(ne.key!==V){const j=Ct(v);A({key:V,values:j}),ae(j),F(r??null),N(null),k(void 0),C([])}const[U,re]=g.useState(r);r!==U&&(re(r),F(r??null));const[ht,Os]=g.useState(i);if(i!==ht){const j=JSON.stringify(i??null)!==JSON.stringify(ht??null);if(Os(i),i&&j){const _={...i};A({key:V,values:_}),ae(_),N(null),k(void 0),C([])}}const Q=ne.values,pt=j=>A({key:V,values:j}),ft=g.useMemo(()=>JSON.stringify(Q)!==JSON.stringify(K),[Q,K]);g.useEffect(()=>{o==null||o(ft)},[ft]);const Ls=()=>{G(JSON.stringify(Q,null,2)),de(!1),B("json")},Ps=async j=>{if(!v||R)return;const _=v.key;f(!0),N(null),k(void 0),C([]);let J;const le=D();try{const ee=await x.invokeAction(t,_,j,{connectionId:n,...le?{overrides:le}:{}});k(ee.value),C(ee.apiCalls??[]),J={ok:!0,summary:"OK",result:ee.value}}catch(ee){const St=rn(ee);N(St),C(ln(ee)),J={ok:!1,summary:St.headline}}finally{f(!1)}if(n)try{await x.recordTestRun(n,{savedTestId:$??null,actionKey:_,ok:J.ok,summary:J.summary.slice(0,200),result:J.result}),Ue(),Js(),l==null||l()}catch{}},Ms=()=>Ps(Q),[be,xt]=g.useState(null),[ye,ue]=g.useState(null),[Ds,Fs]=g.useState(0),[Bs,Ne]=g.useState(!1),[De,Fe]=g.useState(""),[Us,Be]=g.useState(!1),Ue=()=>Fs(j=>j+1);g.useEffect(()=>{if(!n){xt(null);return}let j=!1;return ue(null),x.listSavedTests(n).then(_=>!j&&xt(_)).catch(_=>!j&&ue(_.message)),()=>{j=!0}},[x,n,Ds]);const gt=V?(be??[]).filter(j=>j.actionKey===V):[],[Ws,We]=g.useState(null),[Vs,Ks]=g.useState(0),Js=()=>Ks(j=>j+1);g.useEffect(()=>{const j=x.listTestRuns;if(!n||!j){We(null);return}let _=!1;return j(n).then(J=>!_&&We(J)).catch(()=>!_&&We(null)),()=>{_=!0}},[x,n,Vs]);const vt=V?(Ws??[]).filter(j=>j.actionKey===V).slice().sort((j,_)=>Date.parse(_.occurredAt)-Date.parse(j.occurredAt)):[],qs=()=>{!n||!v||(Fe(""),ue(null),Ne(!0))},Hs=()=>{!n||!v||($?jt():qs())},jt=async()=>{if(!(!n||!v))try{let j;if($)j=await x.updateSavedTest(n,$,{values:Q});else{const _=De.trim();if(!_)return;j=await x.createSavedTest(n,{actionKey:v.key,name:_,values:Q}),F(j.id)}ae({...Q}),Ne(!1),Fe(""),Ue(),l==null||l(),c==null||c(j)}catch(j){ue(j.message)}},Ys=j=>{const _={...j.values};A({key:V,values:_}),ae(_),F(j.id),B("form"),N(null),k(void 0),C([])},zs=async()=>{if(!n||!$)return;const j=$;try{await x.deleteSavedTest(n,j),F(null),Ue(),l==null||l(),d==null||d(j)}catch(_){ue(_.message)}},bt=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${L==="form"?" active":""}`,"aria-pressed":L==="form",onClick:()=>B("form"),children:"Form"}),e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${L==="json"?" active":""}`,"aria-pressed":L==="json",onClick:Ls,children:"JSON"}),!m&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-sm w6w-btn-ghost","aria-pressed":z,title:z?"Collapse the params editor":"Open the params editor in a larger view","aria-label":z?"Collapse the params editor":"Open the params editor in a larger view",onClick:()=>ve(j=>!j),children:z?"⤡":"⤢"})]})]}),L==="form"?e.jsx(h.ParamsForm,{params:(v==null?void 0:v.params)??[],values:Q,onChange:pt,dynamic:v?{appId:t,actionKey:v.key,connectionId:n}:void 0}):e.jsxs(e.Fragment,{children:[e.jsx(h.JsonEditor,{value:ce,onChange:G,minHeight:z?"50vh":"200px","aria-label":"Params JSON",onValidChange:j=>{j!==null&&typeof j=="object"&&!Array.isArray(j)&&pt(j)},onValidityChange:({valid:j})=>de(!j)}),X&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]}),yt=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(h.JsonEditor,{value:P.text,onChange:P.onChange,minHeight:"80px","aria-label":"Overrides body (JSON)"}),P.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(h.JsonEditor,{value:I.text,onChange:I.onChange,minHeight:"80px","aria-label":"Overrides query (JSON)"}),I.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(h.JsonEditor,{value:W.text,onChange:W.onChange,minHeight:"80px","aria-label":"Overrides headers (JSON)"}),W.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:T,onChange:j=>Y(j.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:O,placeholder:"Restrict to requests whose URL contains…",onChange:j=>H(j.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."})]})]}),ke=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"})}),ye&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:ye}),gt.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:gt.map(j=>e.jsx("li",{children:e.jsx(Te,{title:j.name,subtitle:j.lastRunAt?e.jsxs("span",{children:[e.jsx("span",{style:{color:j.lastRunOk?"var(--w6w-success)":"var(--w6w-danger)"},children:j.lastRunOk?"✓":"✗"})," ",j.lastRunSummary?`${j.lastRunSummary} · `:"",Ve(j.lastRunAt)]}):`saved ${Ve(j.updatedAt)}`,active:j.id===$,onClick:()=>Ys(j)})},j.id))}),x.listTestRuns&&vt.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:vt.map(j=>e.jsx("li",{children:e.jsx(Te,{title:e.jsxs("span",{children:[e.jsx("span",{style:{color:j.ok?"var(--w6w-success)":"var(--w6w-danger)"},children:j.ok?"✓":"✗"})," ",j.actionKey]}),subtitle:e.jsxs("span",{children:[j.summary?`${j.summary} · `:"",Ve(j.occurredAt)]})})},j.id))})]})]}):null,Nt=(kt=be==null?void 0:be.find(j=>j.id===$))==null?void 0:kt.name;return e.jsxs("div",{className:`w6w-stack${m?" w6w-tester-embedded-root":""}`,children:[!a&&(s.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",V?"":" *"]}),e.jsx(h.Combobox,{value:w,placeholder:"— pick an action —",onChange:p,options:b.map(j=>({value:j.key,label:`${j.title??j.key} (${j.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 j=y?e.jsxs("div",{className:"w6w-result w6w-error",children:[e.jsx("strong",{children:y.headline}),y.hint&&e.jsx("div",{style:{marginTop:"var(--w6w-sp-1-5)"},children:y.hint}),y.detail&&e.jsx("div",{className:"w6w-muted w6w-small",style:{marginTop:"var(--w6w-sp-1-5)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:y.detail})]}):null,_=S!==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(h.ResultViewer,{value:S})]}):null,J=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[bt,yt,j,_,e.jsx(h.ApiCallsPanel,{calls:E})]}),le=e.jsxs("div",{className:`w6w-tester-actions${m||z?" w6w-tester-actions-footer":""}`,style:{display:"flex",gap:"var(--w6w-sp-2)"},children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:u||R,onClick:Ms,children:u?"Running…":"Run action"}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:Hs,children:"Save test"}),n&&$&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",style:{marginLeft:"auto",color:"var(--w6w-danger)"},onClick:()=>Be(!0),children:"Delete"})]}),ee=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[J,le]});return m?e.jsxs("div",{className:"w6w-tester-embedded",children:[e.jsx("div",{className:"w6w-tester-embedded-scroll",children:e.jsxs("div",{className:"w6w-card-stack",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Parameters"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[bt,yt,j]})]}),(_||E.length>0)&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Result"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[S!==void 0&&e.jsx(h.ResultViewer,{value:S}),e.jsx(h.ApiCallsPanel,{calls:E})]})]}),ke&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Saved tests and history"})}),ke]})]})}),le]}):z?e.jsx(h.Modal,{title:`Edit params — ${v.title??v.key}`,onClose:()=>ve(!1),size:"full",children:e.jsxs("div",{className:"w6w-tester-popout",children:[e.jsx("div",{className:"w6w-tester-popout-scroll",children:ke?e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-4)",alignItems:"flex-start"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:J}),e.jsx("div",{style:{width:260,flexShrink:0},children:ke})]}):J}),le]})}):ee})(),Bs&&e.jsx(h.Modal,{title:"Save test",onClose:()=>Ne(!1),children:e.jsxs("form",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},onSubmit:j=>{j.preventDefault(),jt()},children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Name this saved test"}),e.jsx("input",{type:"text",value:De,placeholder:"e.g. valid sender",onChange:j=>Fe(j.target.value)})]}),ye&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:ye}),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:()=>Ne(!1),children:"Cancel"}),e.jsx("button",{type:"submit",className:"w6w-btn",disabled:!De.trim(),children:"Save"})]})]})}),Us&&e.jsx(h.ConfirmModal,{title:"Delete saved test",message:Nt?`Delete "${Nt}"? This cannot be undone.`:"Delete this saved test? This cannot be undone.",confirmLabel:"Delete",onConfirm:()=>{Be(!1),zs()},onClose:()=>Be(!1)})]}):!a&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action above to test it."})]})}function cn(t){const s=h.useEffectiveTheme(t.theme),{copied:n,copy:a}=M.useCopyToClipboard(t.value),i=g.useMemo(()=>[Zs.yaml(),Qs.EditorView.theme(h.EDITOR_THEME_SPEC)],[]);function l(r){t.onChange(r)}return e.jsxs("div",{className:"w6w-yaml-editor","aria-label":t["aria-label"]??"YAML editor",children:[e.jsx(en,{value:t.value,onChange:l,extensions:i,placeholder:t.placeholder,readOnly:t.readOnly,editable:!t.readOnly,theme:s,height:t.height,minHeight:t.minHeight??"240px",maxHeight:t.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!t.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),t.copyable!==!1&&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 a(),children:n?e.jsx(M.CheckGlyph,{}):e.jsx(M.CopyGlyph,{})}),e.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:n?"Copied":""})]})]})}const Je="…";function Ht(t,s,n="end"){if(s===void 0||s<1||s>=t.length)return t;if(n==="start")return`${Je}${t.slice(t.length-s)}`;if(n==="end")return`${t.slice(0,s)}${Je}`;const a=Math.ceil(s/2),i=s-a;return`${t.slice(0,a)}${Je}${t.slice(t.length-i)}`}function Yt(t){const{value:s,chars:n,crop:a="end",label:i,className:l,copiedMs:r}=t,o=Ht(s,n,a),c=["w6w-copyable--bare",l].filter(Boolean).join(" ");return e.jsx(M.Copyable,{value:s,readOnly:!0,label:i,className:c,copiedMs:r,children:e.jsx("span",{children:o})})}const dn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Ie({state:t,label:s,ariaLabel:n}){const a=s??dn[t];return e.jsxs("span",{className:`w6w-health-pill w6w-health-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-health-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-health-pill-label",children:a})]})}const un={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function zt({days:t,ariaLabel:s}){return t.length===0?null:e.jsx("div",{className:"w6w-uptime-strip",role:"img","aria-label":s??`${t.length}-day status`,children:t.map((n,a)=>e.jsx("span",{className:`w6w-uptime-cell w6w-uptime-cell-${n.state}`,title:n.label??`${n.day} — ${un[n.state]}`},`${n.day}-${a}`))})}const Gt="—",Et=["B","KiB","MiB","GiB","TiB","PiB"];function Xt(t){if(t===null||!Number.isFinite(t))return Gt;if(t<1024)return`${Math.round(t)} B`;let s=t,n=0;for(;s>=1024&&n<Et.length-1;)s/=1024,n+=1;return`${s.toFixed(1)} ${Et[n]}`}function se(t){return t===null||!Number.isFinite(t)?Gt:`${Math.round(t*100)}%`}function xe(t){if(t===void 0||t.load1===null)return null;const s=t.cpuLimit??t.cpus;return s===null||s<=0?null:t.load1/s}function ge(t){if(t===void 0)return null;const{memoryTotal:s,memoryAvailable:n}=t;return s===null||n===null||s<=0?null:(s-n)/s}function wn(t,s,n){return t<s?s:t>n?n:t}function mn(t,s,n,a){const i=t.length;if(i<2)return"";const l=[];for(let r=0;r<i;r++){const o=t[r];if(o===null)continue;const c=r/(i-1)*s,d=a<=0?n:n-wn(o,0,a)/a*n;l.push(`${Number(c.toFixed(2))},${Number(d.toFixed(2))}`)}return l.join(" ")}const hn="—",Rt=100,At=24;function Xe({values:t,max:s,className:n}){const a=mn(t,Rt,At,s);return a===""?null:e.jsx("svg",{className:n,viewBox:`0 0 ${Rt} ${At}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:e.jsx("polyline",{points:a,fill:"none",stroke:"var(--w6w-accent)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})})}function qe(t){return t===null?hn:t.toFixed(2)}function $e(t){let s=1;for(const n of t)n!==null&&n>s&&(s=n);return s}function Re({label:t,value:s,values:n,max:a}){return e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:t}),e.jsx("span",{className:"w6w-server-resources__value",children:s}),e.jsx(Xe,{className:"w6w-server-resources__spark",values:n,max:a})]})}function nt(t){const s=t[t.length-1],n=t.map(l=>xe(l)),a=t.map(l=>ge(l)),i=t.map(l=>l.processRss);return{last:s,cpuValues:n,memoryValues:a,rssValues:i}}function pn({samples:t,title:s="Server resources",intervalMs:n}){const{last:a,cpuValues:i,memoryValues:l,rssValues:r}=nt(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--card","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(Re,{label:"CPU",value:se(xe(a)),values:i,max:$e(i)}),e.jsx(Re,{label:"Memory",value:se(ge(a)),values:l,max:1}),e.jsx(Re,{label:"Process",value:Xt((a==null?void 0:a.processRss)??null),values:r,max:$e(r)})]}),e.jsx("p",{className:"w6w-server-resources__meta",children:`Load ${qe((a==null?void 0:a.load1)??null)} / ${qe((a==null?void 0:a.load5)??null)} / ${qe((a==null?void 0:a.load15)??null)}`}),n!==void 0&&e.jsx("p",{className:"w6w-server-resources__meta",children:`Sampled every ${n/1e3}s`})]})}function fn({samples:t,title:s="Server"}){const{last:n,cpuValues:a}=nt(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--small","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(Re,{label:"CPU",value:se(xe(n)),values:a,max:$e(a)}),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:se(ge(n))})]})]})]})}function xn({samples:t,onExpand:s}){const{last:n,cpuValues:a,memoryValues:i}=nt(t);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:se(xe(n))}),e.jsx(Xe,{className:"w6w-server-resources__spark",values:a,max:$e(a)})]}),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:se(ge(n))}),e.jsx(Xe,{className:"w6w-server-resources__spark",values:i,max:1})]}),s!==void 0&&e.jsx("button",{type:"button",className:"w6w-server-resources__expand","aria-label":"Show server resources",onClick:s,children:"Details"})]})}function gn({samples:t}){const s=t[t.length-1],n=se(xe(s)),a=se(ge(s));return e.jsx("span",{className:"w6w-server-resources w6w-server-resources--badge",children:`CPU ${n} · MEM ${a}`})}const vn=1,jn=1440*60*1e3;function bn(t,s,n){const a=s.startedAt??s.updatedAt;if(a===void 0)return null;const i=Date.parse(a),l=s.resolvedAt!==void 0?Date.parse(s.resolvedAt):s.startedAt!==void 0?n:i,r=Date.parse(`${t.from}T00:00:00.000Z`),o=Date.parse(`${t.to}T00:00:00.000Z`)+jn,c=o-r;if(l<r||i>=o)return null;const d=i<r,m=l>o,x=Math.max(i,r),b=Math.min(l,o),w=(x-r)/c*100,p=(b-x)/c*100,v=Math.max(p,vn);return{leftPct:w,widthPct:v,clippedStart:d,clippedEnd:m}}const yn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"},Nn="This vendor publishes no incident history.",kn="No incidents in this window.";function Sn(t){const s=t.startedAt??t.updatedAt,n=[t.title];return t.components!==void 0&&t.components.length>0&&n.push(`(${t.components.join(", ")})`),s!==void 0&&n.push(t.resolvedAt!==void 0?`${s} – ${t.resolvedAt}`:`${s} – ongoing`),n.join(" ")}function Cn({window:t,days:s,incidents:n,vendorEmptyLabel:a,nowMs:i=Date.now(),ariaLabel:l}){const r=s.length,o=r>0?100/r:0,c=n===void 0?a??Nn:n.length===0?a??kn:null;return e.jsx("div",{className:"w6w-history-timeline",role:"img","aria-label":l??`${r}-day history`,children:e.jsxs("div",{className:"w6w-history-plot",children:[e.jsx("div",{className:"w6w-history-lane w6w-history-lane-execution",children:s.map((d,m)=>e.jsx("span",{className:`w6w-history-cell w6w-history-cell-${d.state}`,style:{left:`${m*o}%`,width:`${o}%`},title:d.label??`${d.day} — ${yn[d.state]}`},`${d.day}-${m}`))}),e.jsx("div",{className:"w6w-history-lane w6w-history-lane-vendor",children:c!==null?e.jsx("span",{className:"w6w-history-empty",title:c,children:c}):n==null?void 0:n.map((d,m)=>{const x=bn(t,d,i);if(x===null)return null;const b=[x.clippedStart?"w6w-history-bar-clip-start":"",x.clippedEnd?"w6w-history-bar-clip-end":""].filter(Boolean).join(" ");return e.jsx("span",{className:`w6w-history-bar w6w-history-bar-${d.state}${b?` ${b}`:""}`,style:{left:`${x.leftPct}%`,width:`${x.widthPct}%`},title:Sn(d)},d.id??`${d.title}-${m}`)})}),e.jsxs("div",{className:"w6w-history-axis",children:[e.jsx("span",{className:"w6w-history-tick w6w-history-tick-start",style:{left:"0%"},children:t.from}),e.jsx("span",{className:"w6w-history-tick w6w-history-tick-end",style:{left:"100%"},children:t.to})]})]})})}function En({label:t,children:s,className:n}){const[a,i]=g.useState(!1),l=g.useId();return e.jsxs("span",{className:["w6w-info-tip",n??""].filter(Boolean).join(" "),children:[e.jsx(h.IconButton,{label:t,icon:"info","aria-expanded":a,"aria-controls":l,onClick:()=>i(r=>!r)}),a&&e.jsx("span",{id:l,className:"w6w-info-tip-body w6w-muted w6w-small",children:s})]})}function Rn(t){const{label:s,onClick:n,disabled:a,className:i,...l}=t;return e.jsx(h.IconButton,{label:s,onClick:n,disabled:a,className:i,icon:"edit","data-testid":l["data-testid"]})}const Se=4;function at({actions:t,label:s="Actions",disabled:n,"data-testid":a}){const i=t.filter(f=>!!f),l=g.useRef(null),r=g.useRef(null),o=g.useId(),[c,d]=g.useState(!1),[m,x]=g.useState(null),[b,w]=g.useState(null),p=g.useCallback(f=>{var y;d(!1),w(null),f&&((y=l.current)==null||y.focus({preventScroll:!0}))},[]);if(g.useLayoutEffect(()=>{if(!c)return;const f=l.current,y=r.current;if(!f||!y)return;const N=f.getBoundingClientRect(),S=y.offsetWidth,k=y.offsetHeight,E=window.innerHeight||document.documentElement.clientHeight,C=N.bottom+Se,P=C+k>E&&N.top-Se-k>=0?N.top-Se-k:C;w({top:P,left:Math.max(Se,N.right-S)})},[c]),g.useEffect(()=>{var f,y;!c||!b||(y=(f=r.current)==null?void 0:f.querySelector("[role=menuitem]"))==null||y.focus({preventScroll:!0})},[c,b]),g.useEffect(()=>{if(!c)return;const f=k=>{var E,C;return k instanceof Node&&((E=r.current)==null?void 0:E.contains(k))||k instanceof Node&&((C=l.current)==null?void 0:C.contains(k))},y=k=>{f(k.target)||p(!1)},N=k=>{var E;k.target instanceof Node&&((E=r.current)!=null&&E.contains(k.target))||p(!1)},S=()=>p(!1);return document.addEventListener("pointerdown",y,!0),document.addEventListener("mousedown",y,!0),document.addEventListener("scroll",N,!0),window.addEventListener("resize",S),window.addEventListener("blur",S),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("mousedown",y,!0),document.removeEventListener("scroll",N,!0),window.removeEventListener("resize",S),window.removeEventListener("blur",S)}},[c,p]),i.length===0)return null;const v=f=>{f.disabled||(p(!0),f.onSelect())},u=()=>{var f;if(c){p(!1);return}x(((f=l.current)==null?void 0:f.closest("dialog"))??document.body),d(!0)};return e.jsxs("span",{className:"w6w-row-actions",onClick:f=>f.stopPropagation(),children:[e.jsx(h.IconButton,{ref:l,label:s,icon:"more-horizontal",onClick:u,disabled:n,className:"w6w-row-actions-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?o:void 0,"data-testid":a}),c&&m&&tn.createPortal(e.jsx("div",{ref:r,id:o,className:"w6w-row-menu",role:"menu","aria-label":s,style:b?{top:b.top,left:b.left}:{top:0,left:0,visibility:"hidden"},onClick:f=>f.stopPropagation(),onKeyDown:f=>{var k;f.stopPropagation();const y=[...((k=r.current)==null?void 0:k.querySelectorAll("[role=menuitem]"))??[]],N=y.indexOf(document.activeElement),S=E=>{var C;return(C=y[(E+y.length)%y.length])==null?void 0:C.focus()};if(f.key==="ArrowDown")S(N+1);else if(f.key==="ArrowUp")S(N<0?-1:N-1);else if(f.key==="Home")S(0);else if(f.key==="End")S(-1);else if(f.key==="Escape")p(!0);else if(f.key==="Tab")p(!1);else if(f.key==="Enter"||f.key===" ")N>=0&&v(i[N]);else return;f.preventDefault()},children:i.map(f=>e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,"aria-disabled":f.disabled||void 0,className:`w6w-row-menu-item${f.danger?" w6w-row-menu-item-danger":""}`,"data-testid":f["data-testid"],onClick:()=>v(f),children:[f.icon&&e.jsx(M.Icon,{name:f.icon,size:14}),e.jsx("span",{children:f.label})]},f.label))}),m)]})}function An(t){const{branch:s,shortSha:n,lastSyncLabel:a,onSyncNow:i,syncing:l,className:r,...o}=t,[c,d]=g.useState(!1),m=g.useRef(null);return g.useEffect(()=>{if(!c)return;const x=w=>{m.current&&!m.current.contains(w.target)&&d(!1)},b=w=>w.key==="Escape"&&d(!1);return document.addEventListener("mousedown",x),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",b)}},[c]),e.jsxs("div",{className:`w6w-repo-sync${r?` ${r}`:""}`,ref:m,"data-testid":o["data-testid"],children:[e.jsxs("button",{type:"button",className:"w6w-repo-sync-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-busy":l,onClick:()=>d(x=>!x),children:[e.jsxs("span",{className:"w6w-repo-sync-icon",children:[e.jsx(M.Icon,{name:"github"}),l&&e.jsx(M.Icon,{name:"sync",size:10,className:"w6w-repo-sync-spin"})]}),e.jsx("span",{className:"w6w-repo-sync-branch",children:s}),n!=null&&e.jsx("code",{className:"w6w-repo-sync-sha",children:n})]}),c&&e.jsxs("div",{className:"w6w-repo-sync-menu",role:"menu",children:[e.jsxs("div",{className:"w6w-repo-sync-detail",children:[e.jsx("span",{children:s}),n!=null&&e.jsx("code",{children:n}),a!=null&&e.jsx("span",{children:a})]}),e.jsx("button",{type:"button",role:"menuitem",className:"w6w-repo-sync-item","data-testid":"repo-sync-now",disabled:l,onClick:i,children:l?"Syncing…":"Sync now"})]})]})}const Tn={pending:"Pending",running:"Running",succeeded:"Succeeded",failed:"Failed",skipped:"Skipped",queued:"Queued",canceled:"Canceled"};function Oe({state:t,label:s,ariaLabel:n}){const a=s??Tn[t];return e.jsxs("span",{className:`w6w-step-pill w6w-step-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-step-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-step-pill-label",children:a})]})}const $n="—",He=1e3,Ye=6e4;function Le(t){return t==null||!Number.isFinite(t)||t<0?$n:t<He?`${Math.round(t)} ms`:t<Ye?`${(t/He).toFixed(1)} s`:`${Math.floor(t/Ye)}m ${Math.round(t%Ye/He)}s`}function fe(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}const _n={function:"Function",endpoint:"Endpoint",workflow:"Workflow"},In={manual:"Manual",schedule:"Schedule",webhook:"Webhook",event:"Event",replay:"Replay"};function Tt(t){if(!t.trigger)return null;const s=In[t.trigger]??t.trigger;return t.triggerNodeId?`${s} · ${t.triggerNodeId}`:s}function On({items:t,selectedId:s=null,onSelect:n,showCallable:a=!1,loading:i=!1,emptyLabel:l,hasPrev:r,hasNext:o,onPrev:c,onNext:d,onRerun:m,rerunningId:x=null}){const b=c||d?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:c,children:"Previous"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-next",disabled:!o,onClick:d,children:"Next"})]}):null;let w;return i&&t.length===0?w=e.jsx("p",{"data-testid":"execution-list-loading",children:"Loading…"}):t.length===0?w=e.jsx("p",{"data-testid":"execution-list-empty",children:l??"No executions yet."}):w=e.jsx("ul",{className:"w6w-execution-list-rows",children:t.map(p=>e.jsxs("li",{"data-testid":"execution-row","data-execution-id":p.id,children:[e.jsx(Te,{icon:e.jsx(Oe,{state:p.status}),title:e.jsxs(e.Fragment,{children:[a?p.callableName:fe(p.startedAt),p.rerunOf&&e.jsx("span",{className:"w6w-execution-rerun-tag","data-testid":"execution-row-rerun-tag",title:`Re-run of ${p.rerunOf}`,children:"Re-run"})]}),subtitle:e.jsxs(e.Fragment,{children:[a?`${_n[p.kind]} · ${fe(p.startedAt)}`:p.id,Tt(p)&&e.jsx("span",{className:"w6w-execution-trigger","data-testid":"execution-row-trigger",children:` · ${Tt(p)}`}),p.inputPreview&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{className:"w6w-execution-input-preview","data-testid":"execution-row-input",title:p.inputPreview,children:p.inputPreview})]})]}),trailing:Le(p.durationMs),active:p.id===s,onClick:n?()=>n(p.id):void 0}),m&&e.jsx(h.IconButton,{icon:"sync",label:"Re-run",title:p.id===x?"Re-running…":"Re-run with the same input",className:"w6w-execution-list-rerun","data-testid":"execution-row-rerun",disabled:x!==null,onClick:()=>m(p.id)})]},p.id))}),e.jsxs("div",{className:"w6w-execution-list","data-testid":"execution-list",children:[w,b]})}function Ln(t){const s=h.internalNodeDef(t.app,t.action);return{trigger:t.trigger===!0||(s==null?void 0:s.group)==="trigger",appName:t.appName??(s==null?void 0:s.displayName)??t.app,actionName:t.actionName??(s==null?void 0:s.label)??t.action}}function Zt(t){const s=n=>{for(const a of[n.startedAt,n.finishedAt]){const i=Date.parse(a??"");if(Number.isFinite(i))return i}return Number.POSITIVE_INFINITY};return t.map(n=>({step:n,time:s(n)})).sort((n,a)=>n.time===a.time?0:n.time-a.time).map(({step:n})=>n)}function Qt({steps:t,emptyLabel:s,onDismiss:n,runError:a,stepErrors:i}){const l=n?e.jsx("div",{className:"w6w-execution-log-head",children:e.jsx(h.IconButton,{label:"Dismiss run log","data-testid":"execution-log-dismiss",onClick:n,children:"×"})}):null,r=i??[],o=a||r.length>0?e.jsxs("div",{className:"w6w-execution-log-errors w6w-stack",children:[a&&e.jsx(Ze,{error:a}),r.map((x,b)=>e.jsx(Ze,{label:x.label??x.stepId,error:x.error},`${x.stepId}:${b}`))]}):null,c=Zt(t.filter(x=>!$t(x))),d=t.filter($t),m=d.length>0?e.jsx(Mn,{steps:d}):null;return c.length===0?e.jsxs(e.Fragment,{children:[l,o,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:s??"No nodes have run yet."})}),m]}):e.jsxs(e.Fragment,{children:[l,o,e.jsx("ol",{className:"w6w-execution-log",children:c.map(x=>e.jsx(es,{step:x},x.id))}),m]})}const $t=t=>t.status==="skipped"&&t.skipReason==="not_on_path",Pn={condition:"condition false",stopped:"run stopped",disabled:"disabled"};function Mn({steps:t}){const s=t.length;return e.jsxs("details",{className:"w6w-execution-log-off-path","data-testid":"execution-log-off-path",children:[e.jsx("summary",{className:"w6w-muted w6w-small",children:`${s} ${s===1?"step":"steps"} on other paths, not part of this run`}),e.jsx("ul",{className:"w6w-muted w6w-small",children:t.map(n=>e.jsx("li",{children:n.label??n.id},n.id))})]})}function es({step:t,defaultOpen:s=!1}){var d,m;const[n,a]=g.useState(s),i=t.node?Ln(t.node):null,l=e.jsxs("div",{className:"w6w-execution-log-row-header",children:[e.jsx(Oe,{state:t.status}),i&&e.jsx("span",{className:`w6w-execution-log-kind${i.trigger?" w6w-execution-log-kind-trigger":""}`,"data-testid":"execution-log-kind",children:i.trigger?"Trigger":"Node"}),e.jsxs("span",{className:"w6w-execution-log-row-title",children:[e.jsx("span",{className:"w6w-execution-log-row-label",children:t.label??t.id}),i&&e.jsx("span",{className:"w6w-execution-log-row-uses","data-testid":"execution-log-uses",children:i.appName===i.actionName?i.appName:`${i.appName} · ${i.actionName}`})]}),t.status==="skipped"&&t.skipReason&&t.skipReason!=="not_on_path"&&e.jsx("span",{className:"w6w-execution-log-skip-reason","data-testid":"execution-log-skip-reason",children:Pn[t.skipReason]}),e.jsx(Bn,{startedAt:t.startedAt,finishedAt:t.finishedAt})]}),r=t.error?e.jsx(Ze,{error:t.error}):null,o=Array.isArray(t.iterations)?e.jsx(Dn,{step:t}):null,c=Kn(t)?e.jsx(Jn,{step:t}):null;return t.input===void 0&&t.output===void 0&&!t.meta&&!c&&!((d=t.logs)!=null&&d.length)?e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsx("div",{className:"w6w-section",children:l}),r,o]}):e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsxs("details",{className:"w6w-section",open:n,onToggle:x=>a(x.currentTarget.open),children:[e.jsx("summary",{className:"w6w-section-summary",children:l}),n&&e.jsxs("div",{className:"w6w-execution-log-row-body w6w-section-body w6w-stack",children:[e.jsx(Wn,{input:t.input}),e.jsx(_t,{title:"Input",value:t.input,defaultOpen:s}),e.jsx(_t,{title:"Output",value:t.output,defaultOpen:s}),!!((m=t.logs)!=null&&m.length)&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Console"}),e.jsx(M.CodeBlock,{code:t.logs.join(`
2
- `),language:"plaintext"})]}),t.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(M.CodeBlock,{code:JSON.stringify(t.meta,null,2),language:"json"})]}),c]})]}),r,o]})}function Dn({step:t}){var p,v;const s=[...t.iterations??[]].sort((u,f)=>u.index-f.index),n=t.iterationsTotal??s.length,a=t.iterationsFailed??s.filter(u=>u.status==="failed").length,i=s.find(u=>u.status==="failed"),l=(i==null?void 0:i.index)??((p=s[s.length-1])==null?void 0:p.index),[r,o]=g.useState(l),[c,d]=g.useState(!1),m=s.find(u=>u.index===r),x=[],b=new Map;for(const u of Zt(s.flatMap(f=>f.steps)))b.has(u.id)||(x.push(u.id),b.set(u.id,u.label??u.id));const w=(i==null?void 0:i.failedNodeId)??((v=i==null?void 0:i.steps.find(u=>u.status==="failed"))==null?void 0:v.id);return e.jsxs("div",{className:"w6w-execution-log-foreach w6w-stack",children:[e.jsxs("div",{className:"w6w-small","data-testid":"execution-log-foreach-summary",children:[e.jsxs("span",{children:[n===1?"1 item":`${n} items`,a>0?` · ${a} failed`:""]}),i&&w!==void 0&&e.jsxs("div",{children:[b.get(w)??w," failed in iteration ",i.index]}),t.iterationsTruncated===!0&&e.jsx("div",{className:"w6w-muted",children:`showing ${s.length} of ${n}`})]}),e.jsx("div",{className:"w6w-execution-log-iteration-chips",children:s.map(u=>e.jsxs("button",{type:"button",className:`w6w-execution-log-iteration-chip w6w-execution-log-iteration-chip-${u.status}`,"data-testid":"execution-log-iteration-chip","data-status":u.status,"aria-pressed":r===u.index,title:`Show iteration ${u.index}'s input and output`,onClick:()=>{o(u.index),d(!0)},children:[u.index," · ",u.status]},u.index))}),m&&e.jsx("div",{className:"w6w-small w6w-muted","data-testid":"execution-log-iteration-current",children:`Iteration ${m.index} · ${m.status}`}),e.jsx("ul",{className:"w6w-execution-log-subrows",children:x.map(u=>e.jsx(Fn,{id:u,label:b.get(u)??u,iterations:s,selected:r,open:c,onSelect:o},u))})]})}function Fn({id:t,label:s,iterations:n,selected:a,open:i,onSelect:l}){var o;const r=(o=n.find(c=>c.index===a))==null?void 0:o.steps.find(c=>c.id===t);return e.jsxs("li",{className:"w6w-execution-log-subrow w6w-stack",children:[e.jsxs("div",{className:"w6w-execution-log-subrow-head",children:[e.jsx("strong",{className:"w6w-small",children:s}),e.jsx("select",{className:"w6w-select","aria-label":`Iteration for ${s}`,"data-testid":"execution-log-iteration-select",value:a===void 0?"":String(a),onChange:c=>l(Number(c.currentTarget.value)),children:n.map(c=>e.jsx("option",{value:String(c.index),children:`iteration ${c.index} (${c.status})`},c.index))})]}),r?e.jsx("ol",{className:"w6w-execution-log",children:e.jsx(es,{step:r,defaultOpen:i},`${a}:${i}`)}):e.jsx("p",{className:"w6w-muted w6w-small",children:"Did not run in this iteration."})]})}function Ze({error:t,label:s}){return e.jsxs("div",{className:"w6w-result w6w-error",children:[s!==void 0&&e.jsx("strong",{className:"w6w-execution-log-error-label",children:s}),t.code&&e.jsx("div",{className:"w6w-small w6w-execution-log-error-code",children:e.jsx("code",{children:t.code})}),t.message]})}function Bn({startedAt:t,finishedAt:s}){if(t&&s){const n=Un(t,s);return e.jsxs("span",{className:"w6w-execution-log-timing",children:[t," → ",s,n&&e.jsxs("span",{children:[" (",n,")"]})]})}return t?e.jsxs("span",{className:"w6w-execution-log-timing",children:["Started ",t]}):e.jsx("span",{className:"w6w-execution-log-timing",children:"—"})}function Un(t,s){const n=Date.parse(t),a=Date.parse(s);if(!Number.isFinite(n)||!Number.isFinite(a)||a<n)return null;const i=a-n;if(i<1e3)return`${i}ms`;const l=i/1e3;if(l<60)return`${l.toFixed(1)}s`;const r=Math.floor(l/60),o=Math.round(l%60);return`${r}m ${o}s`}function _t({title:t,value:s,defaultOpen:n=!1}){const[a,i]=g.useState(n);return s===void 0?e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Not available."})]}):e.jsxs("details",{className:"w6w-execution-log-json",open:a,onToggle:l=>{l.target===l.currentTarget&&i(l.currentTarget.open)},children:[e.jsx("summary",{children:e.jsx("strong",{className:"w6w-small",children:t})}),a&&e.jsx(h.ResultViewer,{value:s,format:"json"})]})}const _e=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function It(t){if(!_e(t)||!Array.isArray(t.conditions))return;const s=t.conditions.filter(n=>_e(n)&&typeof n.op=="string"&&"result"in n);if(s.length!==0)return{rows:s,combinator:typeof t.combinator=="string"?t.combinator:void 0,result:typeof t.condition=="boolean"?t.condition:void 0}}function Wn({input:t}){const s=[],n=It(t);if(n&&s.push({trace:n}),_e(t)&&Array.isArray(t.routes))for(const a of t.routes){const i=It(a);!i||!_e(a)||s.push({title:String(a.label??a.id??"Route"),trace:i})}return s.length===0?null:e.jsxs("div",{className:"w6w-execution-log-json w6w-stack","data-testid":"execution-log-conditions",children:[e.jsx("strong",{className:"w6w-small",children:"Condition"}),s.map(({title:a,trace:i},l)=>e.jsxs("div",{className:"w6w-stack",children:[a&&e.jsx("span",{className:"w6w-small w6w-muted",children:a}),(i.combinator&&i.rows.length>1||i.result!==void 0)&&e.jsxs("span",{className:"w6w-small w6w-muted","data-testid":"execution-log-condition-summary",children:[i.combinator&&i.rows.length>1&&h.conditionCombinatorLabel(i.combinator),i.combinator&&i.rows.length>1&&i.result!==void 0&&" · ",i.result!==void 0&&e.jsxs(e.Fragment,{children:["Result:"," ",e.jsx("span",{className:i.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:i.result?"true":"false"})]})]}),e.jsx("div",{className:"w6w-data-table-frame",children:e.jsxs("table",{className:"w6w-data-table w6w-execution-log-conditions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Left"}),e.jsx("th",{children:"Operator"}),e.jsx("th",{children:"Right"}),e.jsx("th",{children:"Result"})]})}),e.jsx("tbody",{children:i.rows.map((r,o)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{children:Ot(r.left)})}),e.jsx("td",{children:h.conditionOperatorLabel(r.op)}),e.jsx("td",{children:e.jsx("code",{children:Ot(r.right)})}),e.jsx("td",{className:r.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:r.result?"true":"false"})]},o))})]})})]},a??l))]})}function Ot(t){return JSON.stringify(t)??"undefined"}const Lt={not_object:"Not written — the output isn't an object, so it can't be merged at the root",missing_source:"Not written — the output has no value at that field",null_append:"Not appended — the value was null",append_not_array:"Not appended — the existing value isn't a list",write_too_large:"Not written — the value is too large",run_too_large:"Not written — the run's state would grow past its size limit",too_deep:"Not written — the value is nested too deeply",key_too_long:"Not written — a key in the value is too long",forbidden_key:"Not written — the value uses a reserved key name",log_truncated:"Later state changes aren't shown — the run's state log reached its limit"};function Vn(t){return Object.hasOwn(Lt,t)?Lt[t]:t}function Kn(t){const s=Array.isArray(t.stateWrites)&&t.stateWrites.length>0,n=t.stateAfter;return s||typeof n=="object"&&n!==null&&Object.keys(n).length>0}const Pt=120;function Mt(t){if(t===void 0)return"(not set)";const s=JSON.stringify(t)??String(t);return s.length>Pt?`${s.slice(0,Pt)}…`:s}function Jn({step:t}){const s=Array.isArray(t.stateWrites)?t.stateWrites:[],n=t.stateAfter;return e.jsxs("div",{className:"w6w-execution-log-state w6w-stack","data-testid":"execution-log-state",children:[e.jsx("strong",{className:"w6w-small",children:"State"}),s.length>0&&e.jsx("ul",{className:"w6w-execution-log-state-writes",children:s.map((a,i)=>{const l=Array.isArray(a.path)?a.path:[],r=`state${l.length?`.${l.join(".")}`:""}${a.item!==void 0?` (item ${a.item})`:""}`;return a.warning!==void 0?e.jsx("li",{className:"w6w-execution-log-state-write w6w-execution-log-state-warning w6w-small","data-testid":"execution-log-state-write","data-warning":a.warning,children:`${r}: ${Vn(a.warning)}`},i):e.jsx("li",{className:"w6w-execution-log-state-write w6w-small","data-testid":"execution-log-state-write",children:`${r}: ${Mt(a.old)} → ${Mt(a.new)}`},i)})}),typeof n=="object"&&n!==null&&e.jsxs("div",{className:"w6w-stack","data-testid":"execution-log-state-after",children:[e.jsx("span",{className:"w6w-small w6w-muted",children:"State after this step"}),e.jsx(M.CodeBlock,{code:JSON.stringify(n,null,2),language:"json"})]})]})}const qn={status:"",kind:"",from:"",to:"",q:""},Hn=[{value:"",label:"Any status"},{value:"queued",label:"Queued"},{value:"running",label:"Running"},{value:"succeeded",label:"Succeeded"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}],Yn=[{value:"",label:"Any type"},{value:"function",label:"Function"},{value:"endpoint",label:"Endpoint"},{value:"workflow",label:"Workflow"}];function zn({value:t,onChange:s,showKind:n=!1,searchPlaceholder:a="Search by id or name",disabled:i=!1}){const l=t.status!==""||t.kind!==""||t.from!==""||t.to!==""||t.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:a,value:t.q,disabled:i,onChange:r=>s({...t,q:r.target.value})}),e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-status","aria-label":"Status",value:t.status,disabled:i,onChange:r=>s({...t,status:r.target.value}),children:Hn.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:t.kind,disabled:i,onChange:r=>s({...t,kind:r.target.value}),children:Yn.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:t.from,disabled:i,onChange:r=>s({...t,from:r.target.value})}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-to","aria-label":"To date",value:t.to,disabled:i,onChange:r=>s({...t,to:r.target.value})}),l&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-execution-filters-clear","data-testid":"execution-filter-clear",disabled:i,onClick:()=>s({...qn}),children:"Clear"})]})}const Ae="—";function Gn({stats:t,label:s}){const n=[{testid:"execution-stat-total",label:"Executions",value:t?String(t.total):Ae},{testid:"execution-stat-success-rate",label:"Success rate",value:Xn(t==null?void 0:t.successRate)},{testid:"execution-stat-failed",label:"Failed",value:t?String(t.failed):Ae},{testid:"execution-stat-avg-duration",label:"Avg duration",value:t?Le(t.avgDurationMs):Ae}];return t&&t.inFlight>0&&n.push({testid:"execution-stat-in-flight",label:"In flight",value:String(t.inFlight)}),e.jsxs("section",{className:"w6w-execution-stats","data-testid":"execution-stats",children:[s!=null&&e.jsx("p",{className:"w6w-execution-stats-label",children:s}),e.jsx("div",{className:"w6w-execution-stats-cards",children:n.map(a=>e.jsxs("div",{className:"w6w-execution-stat","data-testid":a.testid,children:[e.jsx("span",{className:"w6w-execution-stat-value","data-stat-value":a.value,children:a.value}),e.jsx("span",{className:"w6w-execution-stat-label",children:a.label})]},a.testid))})]})}function Xn(t){return t==null||!Number.isFinite(t)?Ae:`${Math.round(t*100)}%`}const Zn={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function Qn(t){return JSON.stringify(t,null,2)??"null"}function ea({execution:t,loading:s=!1,errorMessage:n,onClose:a,onOpenInEditor:i,onBack:l,onRerun:r,rerunning:o=!1,onOpenExecution:c}){return e.jsxs("section",{className:"w6w-execution-detail w6w-stack","data-testid":"execution-detail",children:[l&&e.jsx("div",{className:"w6w-execution-detail-back",children:e.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-back",onClick:l,children:[e.jsx("span",{"aria-hidden":"true",children:"←"})," Back"]})}),n!=null&&e.jsx("p",{role:"alert",className:"w6w-execution-detail-error-message","data-testid":"execution-detail-error-message",children:n}),t?e.jsx(ta,{execution:t,onClose:a,onOpenInEditor:i,onRerun:r,rerunning:o,onOpenExecution:c}):s?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 ta({execution:t,onClose:s,onOpenInEditor:n,onRerun:a,rerunning:i,onOpenExecution:l}){const r=t.rerunOf;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:t.callableName}),e.jsxs("div",{className:"w6w-execution-detail-meta",children:[e.jsx(Oe,{state:t.status}),e.jsx("span",{className:"w6w-execution-detail-kind w6w-muted w6w-small",children:Zn[t.kind]})]})]}),(a||n||s)&&e.jsxs("div",{className:"w6w-execution-detail-actions",children:[a&&e.jsxs("button",{type:"button",className:"w6w-btn w6w-execution-detail-rerun","data-testid":"execution-detail-rerun",title:"Run it again with the same input",disabled:i,onClick:a,children:[e.jsx(M.Icon,{name:"sync",size:14})," ",i?"Re-running…":"Re-run"]}),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"}),s&&e.jsx(h.IconButton,{label:"Close","data-testid":"execution-detail-close",onClick:s,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:t.id})}),r&&e.jsxs("p",{className:"w6w-execution-detail-rerun-of","data-testid":"execution-detail-rerun-of",children:[e.jsx("span",{className:"w6w-execution-rerun-tag",children:"Re-run"}),e.jsx("span",{className:"w6w-muted w6w-small",children:"of"}),l?e.jsx("button",{type:"button",className:"w6w-execution-detail-rerun-of-link","data-testid":"execution-detail-rerun-of-link",onClick:()=>l(r),children:e.jsx("code",{children:r})}):e.jsx("code",{children:r})]}),e.jsxs("dl",{className:"w6w-execution-detail-timing",children:[e.jsx(ze,{label:"Started",value:fe(t.startedAt)}),e.jsx(ze,{label:"Finished",value:t.finishedAt?fe(t.finishedAt):"—"}),e.jsx(ze,{label:"Duration",value:Le(t.durationMs)})]}),t.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:"Nodes"}),e.jsx(Qt,{steps:t.steps,emptyLabel:"No nodes ran."})]}),t.input!==void 0&&e.jsx(Ge,{title:"Input",testid:"execution-detail-input",value:t.input}),t.output!==void 0&&e.jsx(Ge,{title:"Output",testid:"execution-detail-output",value:t.output}),t.error!=null&&e.jsx(Ge,{title:"Error",testid:"execution-detail-error",value:t.error})]})}function ze({label:t,value:s}){return e.jsxs("div",{className:"w6w-execution-detail-timing-item",children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ge({title:t,testid:s,value:n}){return e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":s,children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx(M.CodeBlock,{code:Qn(n),language:"json"})]})}function ts(t){const s=[];for(const n of t)n.p95Ms!==null&&s.push({appId:n.appId,displayName:n.displayName,calls:n.calls,p95Ms:n.p95Ms,state:n.state,errorCount:n.errors.e4xx+n.errors.e429+n.errors.eAuth+n.errors.e5xx});return s}function sa(t){return t.attention==="now"||t.attention==="recent"}function ss(t){const s={now:[],recent:[],clear:[]};for(const n of t)n.attention==="now"?s.now.push(n):n.attention==="recent"?s.recent.push(n):s.clear.push(n);return s}function ns(t){return t.uptime.map(s=>({day:s.day,state:s.state}))}const Qe=3,as=5;function is(t,s={}){const n=s.compact??!1,{now:a,recent:i}=ss(t),l=a.length+i.length,r=n?a.slice(0,Qe):a,o=n?i.slice(0,Math.max(0,Qe-r.length)):i,c=n?t.slice(0,s.limit??as):[...t];return{attentionCount:l,shownNow:r,shownRecent:o,hiddenAttentionCount:l-r.length-o.length,shownTable:c,hiddenTableCount:t.length-c.length}}const Ce=640,me=340,q={top:16,right:24,bottom:40,left:56};function Dt(t){if(t<=0)return 1;const s=10**Math.floor(Math.log10(t)),n=[1,2,5,10];for(const a of n)if(t<=a*s)return a*s;return 10*s}function Ft(t,s=5){return Array.from({length:s+1},(n,a)=>Math.round(t*a/s))}function rs({services:t,getHref:s,onOpen:n}){const a=ts(t);if(a.length===0)return e.jsx("p",{className:"w6w-muted w6w-small",children:"No timed calls in this window yet."});const i=Dt(Math.max(...a.map(u=>u.calls))),l=Dt(Math.max(...a.map(u=>u.p95Ms))),r=Math.max(1,...a.map(u=>u.errorCount)),o=Ce-q.left-q.right,c=me-q.top-q.bottom,d=u=>q.left+u/i*o,m=u=>q.top+u/l*c,x=u=>16+u/r*14,b=Ft(i),w=Ft(l),p=18,v=q.top+c/2;return e.jsxs("div",{className:"w6w-rel-scatter",children:[e.jsxs("svg",{viewBox:`0 0 ${Ce} ${me}`,style:{aspectRatio:`${Ce} / ${me}`},role:"img","aria-label":"API performance: calls versus p95 latency, one point per API",children:[e.jsx("rect",{x:q.left,y:q.top,width:o,height:c,className:"w6w-rel-scatter-plot-bg"}),w.map(u=>e.jsxs("g",{children:[e.jsx("line",{x1:q.left,x2:Ce-q.right,y1:m(u),y2:m(u),className:"w6w-rel-scatter-grid"}),e.jsx("text",{x:q.left-8,y:m(u),className:"w6w-rel-scatter-axis-label",textAnchor:"end",children:u})]},`y-${u}`)),b.map(u=>e.jsx("text",{x:d(u),y:me-q.bottom+18,className:"w6w-rel-scatter-axis-label",textAnchor:"middle",children:u},`x-${u}`)),e.jsx("text",{x:p,y:v,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",transform:`rotate(-90, ${p}, ${v})`,children:"p95 (ms)"}),e.jsx("text",{x:q.left+o/2,y:me-4,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",children:"calls in this window"}),a.map(u=>{const f=x(u.errorCount),y=d(u.calls),N=m(u.p95Ms),S=e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:y,cy:N,r:f/2+2.5,className:`w6w-rel-scatter-ring w6w-rel-scatter-ring-${u.state}`,children:e.jsxs("title",{children:[u.displayName," — ",u.calls," calls, ",u.p95Ms," ms p95, ",u.errorCount," errors"]})}),e.jsx("circle",{cx:y,cy:N,r:f/2,className:`w6w-rel-scatter-point w6w-rel-scatter-point-${u.state}`})]});return s?e.jsx("a",{href:s(u.appId),className:"w6w-rel-scatter-point-link",onClick:n?k=>n(u.appId,k):void 0,children:S},u.appId):n?e.jsx("g",{role:"button",tabIndex:0,className:"w6w-rel-scatter-point-link",onClick:k=>n(u.appId,k),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.currentTarget.dispatchEvent(new MouseEvent("click",{bubbles:!0})))},children:S},u.appId):e.jsx("g",{children:S},u.appId)})]}),e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-scatter-note",children:"Up is faster, right is more calls — top-right is the best outcome. Icon size is the error count in this window; ring colour is exec status."})]})}function Bt(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ls({appId:t,className:s,title:n,getHref:a,onOpen:i,children:l}){return a?e.jsx("a",{className:s,href:a(t),title:n,onClick:i?r=>i(t,r):void 0,children:l}):i?e.jsx("button",{type:"button",className:s,title:n,onClick:r=>i(t,r),children:l}):e.jsx("div",{className:s,title:n,children:l})}function os({service:t}){return e.jsxs("span",{className:"w6w-rel-signal",children:[e.jsx(Ie,{state:t.state}),t.ongoingOutageId&&e.jsx("span",{className:"w6w-rel-tag",children:"outage open"}),t.calls===0&&e.jsx("span",{className:"w6w-muted w6w-small",children:"no calls"})]})}function cs({vendor:t}){if(!t)return e.jsx("span",{className:"w6w-muted w6w-small",children:"not published"});const s=t.state==="unknown";return e.jsxs("span",{className:"w6w-rel-signal",title:t.message??void 0,children:[e.jsx(Ie,{state:t.state,label:s?"Unavailable":void 0}),!s&&t.message&&e.jsx("span",{className:"w6w-rel-vendor-msg w6w-small",children:t.message})]})}function na({service:t,getHref:s,onOpen:n}){return e.jsxs(ls,{appId:t.appId,className:"w6w-rel-issue-card",title:`${t.displayName} — open service detail`,getHref:s,onOpen:n,children:[e.jsxs("span",{className:"w6w-rel-issue-head",children:[e.jsx(h.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:24}),e.jsxs("span",{className:"w6w-rel-issue-head-text",children:[e.jsx("strong",{children:t.displayName}),t.attention==="recent"&&e.jsx("span",{className:"w6w-muted w6w-small",children:"trouble earlier in this window"})]})]}),e.jsxs("span",{className:"w6w-rel-issue-signals",children:[e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"w6w exec"}),e.jsx(os,{service:t})]}),e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"API status"}),e.jsx(cs,{vendor:t.vendorStatus})]})]})]})}function aa({service:t,getHref:s,onOpen:n}){const a=t.calls===0;return e.jsxs("tr",{className:`w6w-rel-tr${t.attention!=="none"?" w6w-rel-attention":""}`,"data-attention":t.attention==="none"?void 0:t.attention,children:[e.jsx("td",{className:"w6w-rel-td-service",children:e.jsxs(ls,{appId:t.appId,className:"w6w-rel-open",getHref:s,onOpen:n,children:[e.jsx(h.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:28}),e.jsxs("span",{className:"w6w-rel-td-service-text",children:[e.jsx("strong",{children:t.displayName}),e.jsx("code",{className:"w6w-muted w6w-small",children:t.appId})]})]})}),e.jsxs("td",{className:"w6w-rel-td-status",children:[e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"Ops"}),e.jsx(os,{service:t})]}),e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"API"}),e.jsx(cs,{vendor:t.vendorStatus})]})]}),e.jsx("td",{className:"w6w-rel-td-uptime",children:a?e.jsx("span",{className:"w6w-rel-idle-note",children:"No calls in this window"}):e.jsxs(e.Fragment,{children:[e.jsx(zt,{days:ns(t),ariaLabel:`${t.displayName}, ${t.uptime.length}-day status, oldest day first`}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[t.calls," calls"]})]})}),e.jsx("td",{className:"w6w-rel-td-p95",children:t.p95Ms===null?"—":`${t.p95Ms} ms`})]})}function ia({services:t,window:s,days:n,compact:a=!1,showChart:i,limit:l,getHref:r,onOpen:o,showAllHref:c,onShowAll:d,slots:m}){const x=n??(s==null?void 0:s.days)??30,b=t.length>0&&t.every(E=>E.calls>0&&E.state==="ok"),{attentionCount:w,shownNow:p,shownRecent:v,hiddenAttentionCount:u,shownTable:f,hiddenTableCount:y}=is(t,{compact:a,limit:l}),N=i??!a,S=c!==void 0||d!==void 0,k=E=>{const C=E.startsWith("Show")?"w6w-muted w6w-small":void 0;return c!==void 0?e.jsx("a",{href:c,className:C,onClick:d,children:E}):d?e.jsx("button",{type:"button",className:`w6w-rel-show-all${C?` ${C}`:""}`,onClick:d,children:E}):null};return e.jsxs("section",{className:"w6w-rel-section",children:[e.jsxs("h3",{className:"w6w-rel-heading",children:[e.jsxs("span",{children:[(m==null?void 0:m.header)??"Service reliability"," ",s&&e.jsxs("span",{className:"w6w-muted w6w-small",children:[Bt(s.from)," – ",Bt(s.to)," · ",s.days," days"]})]}),a&&k("Show all services →"),m==null?void 0:m.actions]}),e.jsxs("div",{className:a?"w6w-rel-card":void 0,children:[e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-intro",children:"Connected services across your account. Performance for the selected project."}),b&&e.jsxs("div",{className:a?"w6w-rel-allclear":"w6w-rel-card w6w-rel-allclear",children:[e.jsx("h4",{children:"All clear"}),e.jsxs("p",{children:["Every service you called in the last ",x," days came back"," ",e.jsx(Ie,{state:"ok"})," — no degraded stretches, no outages."]})]}),t.length===0&&((m==null?void 0:m.empty)??e.jsx("div",{className:a?void 0:"w6w-rel-card",children:e.jsx("p",{className:"w6w-muted",children:"No services yet — connect an integration or use a service in this project."})})),t.length>0&&e.jsxs(e.Fragment,{children:[w>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:["Needs attention"," ",e.jsxs("span",{className:"w6w-muted w6w-small",children:[p.length+v.length," of ",w]})]}),e.jsx("div",{className:"w6w-rel-issues",children:[...p,...v].map(E=>e.jsx(na,{service:E,getHref:r,onOpen:o},E.appId))}),u>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[u," more ",u===1?"needs":"need"," ","attention",S&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]}),N&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsx("h4",{className:"w6w-rel-group-head",children:"Performance across your APIs"}),e.jsx(rs,{services:t,getHref:r,onOpen:o})]}),f.length>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:[a?"Services":"All services"," ",e.jsx("span",{className:"w6w-muted w6w-small",children:a?`${f.length} of ${t.length}`:t.length})]}),e.jsx("div",{className:"w6w-rel-table-wrap",children:e.jsxs("table",{className:"w6w-rel-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Service"}),e.jsx("th",{children:"Status"}),e.jsxs("th",{children:["Last ",x," days"]}),e.jsx("th",{children:"Latency"})]})}),e.jsx("tbody",{children:f.map(E=>e.jsx(aa,{service:E,getHref:r,onOpen:o},E.appId))})]})}),y>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[y," more",S&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]})]})]})]})}function ra({tone:t="muted",title:s,children:n,"data-testid":a}){return e.jsx("span",{className:`w6w-callable-list-status w6w-callable-list-status-${t}`,title:s,"data-testid":a,children:n})}function la({rows:t,title:s,icon:n,description:a,emptyCopy:i,newLabel:l="New",openRowTitle:r,testIds:o,loading:c,error:d,onCreate:m,creating:x,onImport:b,onOpen:w,getHref:p,showArchived:v,onShowArchivedChange:u,slots:f}){const[y,N]=g.useState(!1),S=v!==void 0,k=S?v:y,E=k?t:t.filter(T=>!T.archived),C=w!==void 0||p!==void 0,P=T=>{S||N(T),u==null||u(T)},I=[{key:"main",header:"Name",render:T=>{const Y=T.icon!==void 0?T.icon:n?e.jsx(M.Icon,{name:n,size:16}):null,O=e.jsxs("span",{className:"w6w-callable-list-cell",title:C?r:void 0,children:[Y!=null&&e.jsx("span",{className:"w6w-callable-list-icon","aria-hidden":"true",children:Y}),e.jsxs("span",{className:"w6w-callable-list-main",children:[e.jsxs("span",{className:"w6w-callable-list-title-line",children:[e.jsx("span",{className:"w6w-callable-list-name",children:T.title}),T.status]}),T.description!=null&&T.description!==""&&e.jsx("span",{className:"w6w-muted w6w-small w6w-callable-list-row-desc",children:T.description}),T.meta!=null&&e.jsx("span",{className:"w6w-muted w6w-callable-list-meta",children:T.meta})]})]});return w&&!p?e.jsx("button",{type:"button",className:"w6w-callable-list-open",children:O}):O}},{key:"trail",header:"",align:"right",width:"1%",render:T=>T.archived||T.badges!=null||T.trailing!=null?e.jsxs("span",{className:"w6w-callable-list-trail",children:[T.badges,T.archived&&e.jsx("span",{className:"w6w-callable-list-badge","data-testid":o==null?void 0:o.archivedBadge,children:"archived"}),T.trailing]}):null}];E.some(T=>T.menu!=null)&&I.push({key:"menu",header:"",align:"right",link:!1,actions:!0,render:T=>T.menu??null});const W=t.length>0&&E.length===0;return e.jsxs("section",{className:"w6w-callable-list",children:[e.jsxs("div",{className:"w6w-callable-list-head",children:[e.jsxs("div",{className:"w6w-callable-list-heading",children:[(f==null?void 0:f.header)??e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"w6w-callable-list-title",children:s}),a!=null&&e.jsx("p",{className:"w6w-muted w6w-small w6w-callable-list-description",children:a})]}),e.jsxs("label",{className:"w6w-muted w6w-small w6w-callable-list-toggle",children:[e.jsx("input",{type:"checkbox",checked:k,"data-testid":o==null?void 0:o.showArchived,onChange:T=>P(T.target.checked)}),"Show archived"]})]}),e.jsxs("div",{className:"w6w-callable-list-actions",children:[f==null?void 0:f.actions,b&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":o==null?void 0:o.importOpen,onClick:b,children:"Import"}),m&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:x,onClick:m,children:x?"Creating…":l})]})]}),d&&e.jsx("div",{className:"w6w-error",children:d}),e.jsxs("div",{className:"w6w-callable-list-body",children:[c&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),E.length===0&&!c?W?e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",action:e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>P(!0),children:"Show archived"}),children:t.length===1?"The only item is archived.":`All ${t.length} items are archived.`}):e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",children:(f==null?void 0:f.empty)??i}):e.jsx(h.DataTable,{columns:I,rows:E,rowKey:T=>T.id,className:"w6w-data-table-rows",loading:c,getRowHref:p?T=>p(T.id):void 0,onRowClick:w?(T,Y)=>w(T.id,Y):void 0})]})]})}function oa({connections:t,appsById:s,loading:n,error:a,onOpen:i,getHref:l,onEdit:r,onDelete:o,busy:c,slots:d}){const m=s??new Map,x=r!==void 0||o!==void 0,b=[{key:"name",header:"Name",render:w=>{const p=h.resolveConnectionAppMeta(w,m),v=w.displayName||w.id;return e.jsxs("span",{className:"w6w-connection-cell-name",children:[e.jsx(h.AppIcon,{src:p==null?void 0:p.iconSvg,srcDark:p==null?void 0:p.iconSvgDark,brandColor:p==null?void 0:p.brandColor,name:(p==null?void 0:p.displayName)??w.appId}),e.jsxs("span",{className:"w6w-connection-cell-text",children:[e.jsxs("span",{className:"w6w-connection-cell-title",children:[e.jsx("strong",{className:"w6w-connection-name",title:v,children:v}),e.jsx("span",{className:`w6w-connection-status${w.state==="connected"?"":" w6w-connection-status-warn"}`,title:w.state,children:w.state}),w.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-status w6w-connection-status-danger",title:"Last test failed — update or re-test.",children:"invalid"})]}),e.jsx("span",{className:"w6w-connection-app w6w-muted",children:(p==null?void 0:p.displayName)??w.appId})]})]})}}];return x&&b.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>w.builtIn===!0?null:e.jsx(at,{label:`Actions for ${w.displayName||w.id}`,"data-testid":`connection-actions-${w.id}`,actions:[r&&{label:"Edit",icon:"edit",onSelect:()=>r(w),"data-testid":`connection-edit-${w.id}`},o&&{label:"Delete",icon:"delete",danger:!0,disabled:c,onSelect:()=>o(w),"data-testid":`connection-delete-${w.id}`}]})}),e.jsxs("section",{className:"w6w-connection-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-connection-list-head",children:[e.jsx("div",{className:"w6w-connection-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-connection-list-actions",children:d==null?void 0:d.actions})]}),a&&e.jsx("div",{className:"w6w-error",children:a}),n&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!n?e.jsx(h.EmptyState,{testId:"w6w-connection-list-empty",children:(d==null?void 0:d.empty)??"No connections yet."}):e.jsx(h.DataTable,{columns:b,rows:t,rowKey:w=>w.id,loading:n,getRowHref:l?w=>w.builtIn===!0?void 0:l(w.id):void 0,onRowClick:i?(w,p)=>w.builtIn===!0?void 0:i(w.id,p):void 0})]})}function ca({connection:t,onClose:s,onSaved:n}){const a=h.useW6WApi(),i=a.updateConnection,l=t.builtIn===!0,r=!l&&typeof i=="function",[o,c]=g.useState(t.displayName??""),[d,m]=g.useState(t.authKey),[x,b]=g.useState({}),[w,p]=g.useState(null),[v,u]=g.useState(null),[f,y]=g.useState(!1),[N,S]=g.useState({}),[k,E]=g.useState(null),[C,P]=g.useState(null),[I,W]=g.useState(null),[T,Y]=g.useState(null);g.useEffect(()=>{if(!r)return;let A=!1;return p(null),a.getAppAuth(t.appId).then($=>!A&&p($)).catch($=>!A&&u($.message)),()=>{A=!0}},[a,r,t.appId]);const O=w==null?void 0:w.find(A=>A.key===d),H=d!==t.authKey,R=(w==null?void 0:w.filter(A=>A.key===t.authKey||A.available!==!1&&!A.autoSatisfied&&["apiKey","bearer","basic","custom"].includes(A.type)))??[],D=(O==null?void 0:O.type)==="oauth2",L=D?[]:(O==null?void 0:O.fields)??[],B=t.credentialId,ce=!H&&!!B&&typeof a.rotateCredential=="function"&&(C!==null?!C.startsWith("legacy:"):(O==null?void 0:O.type)==="serviceAccount")&&I!==!0&&!D,G=ce&&I===!1&&O!==void 0&&!O.serviceAccount,X=ce&&!G,de=!H&&!D&&!!B&&typeof a.getCredential=="function"&&I===null,z=X&&(O!=null&&O.serviceAccount)?h.bindingFieldsFor(O.serviceAccount):[];g.useEffect(()=>{if(!r||H||D||!B||typeof a.getCredential!="function")return;let A=!1;return a.getCredential(B).then($=>{A||(E($.connectionCount),P($.contract),W($.private===!0))}).catch(()=>{}),()=>{A=!0}},[a,r,H,D,B]);function ve(){if(G)return o!==(t.displayName??"")?{displayName:o}:null;if(X){const F={};o!==(t.displayName??"")&&(F.displayName=o);const K=h.buildBinding(z,N);return K&&(F.binding=K),F.displayName===void 0&&F.binding===void 0?null:F}const A={};for(const F of G?[]:L){const K=x[F.key];K!==void 0&&K!==""&&(A[F.key]=K)}const $={};return H&&($.authKey=d,$.credential=A),o!==(t.displayName??"")&&($.displayName=o),Object.keys(A).length>0&&($.credential=A),$.displayName===void 0&&$.credential===void 0?null:$}async function V(){if(!r||!i||f)return;u(null);const A=ve(),$=Object.fromEntries((G?[]:L).filter(U=>x[U.key]!==void 0&&x[U.key]!=="").map(U=>[U.key,x[U.key]])),F=Object.keys($).length>0;if(!A&&!F){u("Nothing to update — change the name or a credential or binding field.");return}if(H||X&&F){const U=L.filter(re=>re.required&&!(re.key in $));if(U.length>0){u(`Enter the full new credential: ${U.map(re=>re.label).join(", ")}.`);return}}const K=h.parseJsonFields(L,$);if("error"in K){u(K.error);return}y(!0);let ae=!1;try{X&&F&&B&&a.rotateCredential?(await a.rotateCredential(B,{source:K.values}),ae=!0,b({}),Y(null)):A!=null&&A.credential&&(A.credential=K.values);const U=A?await i.call(a,t.id,A):t;b({}),n(U)}catch(U){u(ae?`The credential was saved, but the other changes failed. Click Save to retry them. ${U.message}`:U.message)}finally{y(!1)}}async function je(){if(!(!B||!a.testCredential)){u(null);try{Y(await a.testCredential(B))}catch(A){u(A.message)}}}const ne=h.useEnterSubmit(V,{enabled:r&&!f});return e.jsx(h.Modal,{title:"Edit connection",onClose:s,children:e.jsxs("div",{className:"w6w-stepconfig",children:[e.jsx("div",{className:"w6w-modal-body",children:e.jsxs("div",{className:"w6w-stack",children:[l&&e.jsx("p",{className:"w6w-muted w6w-small",children:"This connection is built in — it has no stored credential to edit."}),!l&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"connection-ownership",children:t.accessScope==="user"?"Only me":"This account"}),!l&&!r&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Editing connections is not available here."}),r&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{type:"text",value:o,onChange:A=>c(A.target.value),placeholder:"Connection name",maxLength:80,name:"w6w-connection-label",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...ne})]}),R.some(A=>A.key!==t.authKey)&&e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Authentication method"}),e.jsxs("select",{name:"w6w-connection-auth",value:d,disabled:f,onChange:A=>{m(A.target.value),b({}),S({}),Y(null),u(null)},children:[!R.some(A=>A.key===t.authKey)&&e.jsx("option",{value:t.authKey,children:t.authKey}),R.map(A=>e.jsx("option",{value:A.key,children:A.displayName??A.key},A.key))]})]}),H&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Enter the new credential and click Save. This connection stays linked to your existing workflows."}),w===null&&!v&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Loading auth fields…"}),O&&e.jsx(h.AuthGuide,{auth:O}),D&&e.jsx("p",{className:"w6w-muted w6w-small",children:R.some(A=>A.key!==t.authKey)?"This connection uses OAuth. Choose another authentication method above to use a key or token.":"This is an OAuth connection. You can rename it here; its credential is renewed by re-authorizing it."}),X&&z.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a binding field blank to keep it unchanged."}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:z,values:N,onChange:S,enterSubmitProps:ne})]}),ce&&e.jsxs("div",{className:"w6w-stack","data-w6w":"credential-section",children:[typeof a.testCredential=="function"&&e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:je,children:"Test credential"}),T&&e.jsxs("p",{className:"w6w-small","data-w6w":"credential-health",children:["Credential health: ",T.ok?"ok":T.code??"failed"]})]}),e.jsxs("p",{className:"w6w-small","data-w6w":"app-access",children:["App access:"," ",t.lastTestOk===!0?"passed":t.lastTestOk===!1?"failed":"never tested"]}),X&&!de&&L.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Leave the credential blank to keep it unchanged. To replace it, enter the full new credential and click Save.",k!==null&&k>1&&` This credential is used by ${k} connections; saving a new credential updates all of them.`]}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:L,values:x,onChange:b,enterSubmitProps:ne})]}),G&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"shared-credential-note",children:"Uses a shared credential. Rotate it in Settings → Credentials."})]}),!X&&!G&&!de&&L.length>0&&e.jsxs(e.Fragment,{children:[!H&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a field blank to keep it unchanged. Filled fields replace the stored credential."}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:L,values:x,onChange:b,enterSubmitProps:ne})]})]}),v&&e.jsx("div",{className:"w6w-result w6w-error",children:v})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),r&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:f,onClick:V,children:f?"Saving…":"Save"})]})]})})}function da({conn:t,app:s,children:n}){return e.jsxs("div",{className:"w6w-connection-header","data-testid":"connection-header",children:[e.jsx(h.AppIcon,{src:s==null?void 0:s.iconSvg,srcDark:s==null?void 0:s.iconSvgDark,brandColor:s==null?void 0:s.brandColor,name:(s==null?void 0:s.displayName)??t.appId,size:56}),e.jsxs("div",{className:"w6w-connection-header-main",children:[e.jsx("h2",{className:"w6w-connection-header-title",children:t.displayName||t.id}),e.jsxs("p",{className:"w6w-muted w6w-small w6w-connection-header-meta",children:[e.jsx(Yt,{value:t.id,className:"w6w-connection-id-copy"})," · App"," ",e.jsx("code",{children:t.appId})," · Auth ",e.jsx("code",{children:t.authKey})," ·"," ",e.jsx("span",{className:`w6w-connection-tag${t.state==="connected"?"":" w6w-connection-tag-warn"}`,children:t.state}),t.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-tag w6w-connection-tag-danger",title:"Last test failed — update or re-test.",children:"invalid"})]})]}),n&&e.jsx("div",{className:"w6w-connection-header-actions",children:n})]})}function ds(t,s=Date.now()){const n=new Date(t).getTime();if(Number.isNaN(n))return"recently";const a=Math.max(0,Math.round((s-n)/1e3));if(a<45)return"just now";const i=Math.round(a/60);if(i<60)return`${i}m ago`;const l=Math.round(i/60);if(l<24)return`${l}h ago`;const r=Math.round(l/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function ua({conn:t,refreshable:s,onChanged:n,className:a}){const i=h.useW6WApi(),[l,r]=g.useState(s??null),[o,c]=g.useState(t.autoRefresh!==!1),[d,m]=g.useState(!1),[x,b]=g.useState(null);if(g.useEffect(()=>c(t.autoRefresh!==!1),[t.autoRefresh]),g.useEffect(()=>{if(s!==void 0){r(s);return}let v=!1;return i.getAppAuth(t.appId).then(u=>{var f;return!v&&r(((f=u.find(y=>y.key===t.authKey))==null?void 0:f.refreshable)===!0)}).catch(()=>!v&&r(!1)),()=>{v=!0}},[i,t.appId,t.authKey,s]),t.builtIn||l!==!0)return null;const w=i.updateConnection;async function p(v){if(w){b(null),m(!0),c(v);try{const u=await w.call(i,t.id,{autoRefresh:v});n==null||n(u)}catch(u){c(!v),b(u.message)}finally{m(!1)}}}return e.jsxs("section",{className:`w6w-keepalive${a?` ${a}`:""}`,"data-testid":"connection-keepalive",children:[e.jsx("h3",{children:"Token refresh"}),e.jsxs("label",{className:"w6w-checkbox",children:[e.jsx("input",{type:"checkbox",name:"w6w-connection-keepalive",checked:o,disabled:!w||d,onChange:v=>p(v.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Keep connected"}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[" ",o?"Refresh the token automatically, even when nothing uses this connection.":"Off: the token is refreshed only when something uses this connection, so an idle one may need reconnecting."]})]})]}),t.lastRefreshedAt&&e.jsxs("p",{className:"w6w-muted w6w-small","data-testid":"connection-last-refreshed",children:["Last refreshed"," ",e.jsx("time",{dateTime:t.lastRefreshedAt,title:t.lastRefreshedAt,children:ds(t.lastRefreshedAt)})]}),t.refreshFailingSince&&e.jsxs("p",{className:"w6w-keepalive-warning","data-testid":"connection-refresh-failing",children:["Token refresh failing since"," ",e.jsx("time",{dateTime:t.refreshFailingSince,children:new Date(t.refreshFailingSince).toLocaleDateString()})," ","— reconnect if this persists"]}),x&&e.jsx("div",{className:"w6w-result w6w-error",children:x})]})}const wa=t=>String(t);function Ut(t){const s=Math.min(100,Math.max(0,t));return Number(s.toFixed(4))}function ma({label:t,used:s,limit:n,reserved:a=0,format:i,className:l,testId:r}){const o=i??wa,c=Number.isFinite(a)&&a>0,d=n>0?Ut(s/n*100):100,m=c&&n>0?Ut(Math.min(100-d,a/n*100)):0,x=s>=n,b=`${o(s)} / ${o(n)}`,w=["w6w-budget-meter"];return x&&w.push("w6w-budget-meter-over"),l&&w.push(l),e.jsxs("div",{role:"meter",className:w.join(" "),"aria-label":t,"aria-valuemin":0,"aria-valuenow":s,"aria-valuemax":n,"aria-valuetext":b,"data-testid":r,children:[e.jsxs("div",{className:"w6w-budget-meter-head",children:[e.jsx("span",{className:"w6w-budget-meter-label",children:t}),e.jsx("span",{className:"w6w-budget-meter-value",children:b})]}),e.jsxs("div",{className:"w6w-budget-meter-track",children:[e.jsx("div",{className:"w6w-budget-meter-used",style:{width:`${d}%`}}),c&&e.jsx("div",{className:"w6w-budget-meter-reserved",style:{width:`${m}%`}})]})]})}const us={kv:"Key-value",doc:"Document",table:"Table"},ha=["kv","doc","table"],it=["string","number","integer","boolean","date","datetime"],ws=5242880;function pa(t){var n;const s=(n=t.schema)==null?void 0:n.valueType;return typeof s=="string"&&it.includes(s)?s:"string"}function fa(t){var a,i;if(t.kind!=="table")return null;const s=(a=t.schema)==null?void 0:a.columns;if(!Array.isArray(s))return null;const n=(i=t.schema)==null?void 0:i.key;return typeof n=="string"?{columns:s,key:n}:{columns:s}}function xa(t,s){const n=t==null?void 0:t.match(/filename="([^"]*)"/),a=n==null?void 0:n[1];return a!==void 0&&a!==""?a:`${s}.csv`}const ms={required:"Required.",not_a_number:"Enter a number.",not_an_integer:"Enter a whole number.",not_a_boolean:"Enter true or false.",not_a_date:"Enter a date as YYYY-MM-DD.",not_a_datetime:"Enter a date-time like 2026-01-31T09:30:00Z."},ga=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,va=/^-?(0|[1-9]\d*)$/,ja=/^\d{4}-\d{2}-\d{2}$/,ba=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function ya(t,s){return s===2?t%4===0&&t%100!==0||t%400===0?29:28:[31,0,31,30,31,30,31,31,30,31,30,31][s-1]}function rt(t){if(!ja.test(t))return null;const s=Number(t.slice(0,4)),n=Number(t.slice(5,7)),a=Number(t.slice(8,10));return n<1||n>12||a<1||a>ya(s,n)?null:{year:s,month:n,day:a}}function te(t){return{ok:!1,problem:t,message:ms[t]}}function Pe(t,s,n){const a=s.trim();if(a==="")return n?te("required"):{ok:!0,value:void 0};switch(t){case"string":return{ok:!0,value:s};case"number":{if(!ga.test(a))return te("not_a_number");const i=Number(a);return Number.isFinite(i)?{ok:!0,value:i}:te("not_a_number")}case"integer":{if(!va.test(a))return te("not_an_integer");const i=Number(a);return Number.isSafeInteger(i)?{ok:!0,value:i}:te("not_an_integer")}case"boolean":return a==="true"?{ok:!0,value:!0}:a==="false"?{ok:!0,value:!1}:te("not_a_boolean");case"date":return rt(a)===null?te("not_a_date"):{ok:!0,value:a};case"datetime":return hs(a)?{ok:!0,value:a}:te("not_a_datetime")}}function hs(t){if(!ba.test(t)||rt(t.slice(0,10))===null)return!1;const s=Number(t.slice(11,13)),n=Number(t.slice(14,16)),a=Number(t.slice(17,19));if(s>23||n>59||a>59)return!1;const l=t.slice(19).match(/(Z|([+-])(\d{2}):(\d{2}))$/);return l===null||l[1]==="Z"?!0:Number(l[3])<=23&&Number(l[4])<=59}function Me(t,s){if(s==null)return"";if((t==="string"||t==="date"||t==="datetime")&&typeof s=="string")return s;if((t==="number"||t==="integer")&&typeof s=="number"&&Number.isFinite(s))return String(s);if(t==="boolean"&&typeof s=="boolean")return s?"true":"false";const n=JSON.stringify(s);return n===void 0?"":n}function Na(t,s){switch(t){case"string":return typeof s=="string";case"number":return typeof s=="number"&&Number.isFinite(s);case"integer":return Number.isSafeInteger(s);case"boolean":return typeof s=="boolean";case"date":return typeof s=="string"&&rt(s)!==null;case"datetime":return typeof s=="string"&&hs(s)}}const oe="The request failed.",ps="Could not reach the server.";function ie(t){return typeof t=="string"&&t.length>0?t:void 0}function fs(t){return Number.isInteger(t)&&t>=0?t:void 0}function xs(t,s,n){const a={message:oe};typeof n=="number"&&(a.status=n);const i=t!==null&&typeof t=="object"?t.error:void 0;if(i!==null&&typeof i=="object"){const l=i,r=ie(l.code);r!==void 0&&(a.code=r);const o=ie(l.field);o!==void 0&&(a.field=o);const c=ie(l.column);c!==void 0&&(a.column=c);const d=fs(l.row);d!==void 0&&(a.row=d);const m=ie(l.message);m!==void 0&&(a.message=m)}if(a.message===oe)for(const l of s){const r=ie(l);if(r!==void 0){a.message=r;break}}return a}function ka(t){try{const s=t!==null&&typeof t=="object"?t:void 0,n=s==null?void 0:s.raw,a=s==null?void 0:s.message;return xs(n,[a],s==null?void 0:s.status)}catch{return{message:oe}}}function gs(t){try{if(t.status===0)return{status:0,code:"network_error",message:ps};let s;try{s=JSON.parse(t.text)}catch{return{status:t.status,message:oe}}return xs(s,[],t.status)}catch{return{message:oe}}}function vs(t){const s=ie(t.column);if(s!==void 0){const a=fs(t.row);return a===void 0?{kind:"cell",column:s}:{kind:"cell",column:s,row:a}}const n=ie(t.field);return n!==void 0?{kind:"field",field:n}:{kind:"form"}}function et(t){return t+2}const lt="\0new",ot="Changed by someone else since you loaded it.",tt="Enter a JSON object or array.",js="The file is larger than 5 MB.";function bs(t){const s=t.value;return s!==null&&typeof s=="object"&&!Array.isArray(s)?s:{}}function Sa(t,s){const n=bs(t),a={};for(const i of s)a[i.name]=Me(i.type,n[i.name]);return{id:t.key,version:t.version,cells:a}}function Ca(t){const s={};for(const n of t)s[n.name]=n.default===void 0?"":Me(n.type,n.default);return{id:lt,version:null,cells:s}}function Ea(t,s,n){const a=[];for(const i of n)(t.cells[i.name]??"")!==(s.cells[i.name]??"")&&a.push(i.name);return a}function Ra(t,s){const n={},a={};for(const i of s){const l=Pe(i.type,t.cells[i.name]??"",i.required);l.ok?l.value!==void 0&&(n[i.name]=l.value):a[i.name]=l.message}return Object.keys(a).length>0?{ok:!1,errors:a}:{ok:!0,value:n}}function Aa(t,s){if(t===null)return;const n=Date.parse(t);if(!Number.isFinite(n))return;const a=Math.ceil((n-s)/1e3);return a>0?a:void 0}function Ta(t,s,n){if(t.id===lt)return n===void 0?{kind:"insert",value:s}:{kind:"insert",value:s,ttlSeconds:n};const a={kind:"put",key:t.id,value:s,ifVersion:t.version??0};return n===void 0?a:{...a,ttlSeconds:n}}function $a(t,s){const n=vs(t);return n.kind!=="cell"||!s.some(a=>a.name===n.column)?null:{[n.column]:t.message}}function _a(t){return t.status===409&&t.code==="version_conflict"}function ys(t){let s;try{s=JSON.parse(t)}catch{return{ok:!1,message:tt}}return s===null||typeof s!="object"?{ok:!1,message:tt}:{ok:!0,value:s}}function Ia(t,s){if(t==="string")return{ok:!0,value:s};const n=Pe(t,s,!0);return n.ok?{ok:!0,value:n.value}:{ok:!1,message:n.message}}function Oa(t){if(t.status===200){let a=0;try{const i=JSON.parse(t.text);typeof i.imported=="number"&&Number.isFinite(i.imported)&&(a=i.imported)}catch{a=0}return{ok:!0,message:`Imported ${a} row${a===1?"":"s"}.`}}const s=gs(t);return s.row===void 0?{ok:!1,message:s.message}:{ok:!1,message:`${s.column?`Line ${et(s.row)}, column ${s.column}`:`Line ${et(s.row)}`}: ${s.message}`}}function La({stores:t,loading:s,error:n,onOpen:a,getHref:i,onEdit:l,onArchive:r,busy:o,formatSize:c,slots:d}){const m=c??Xt,x=l!==void 0||r!==void 0,b=[{key:"name",header:"Name",render:w=>e.jsx("strong",{children:w.name})},{key:"kind",header:"Kind",render:w=>us[w.kind]},{key:"entries",header:"Entries",align:"right",render:w=>String(w.entryCount)},{key:"size",header:"Size",align:"right",render:w=>m(w.sizeBytes)}];return x&&b.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>e.jsx(at,{label:`Actions for ${w.name||w.id}`,"data-testid":`data-store-actions-${w.id}`,actions:[l&&{label:"Edit",icon:"edit",onSelect:()=>l(w),"data-testid":`data-store-edit-${w.id}`},r&&{label:"Archive",icon:"archive",danger:!0,disabled:o,onSelect:()=>r(w),"data-testid":`data-store-archive-${w.id}`}]})}),e.jsxs("section",{className:"w6w-data-store-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-data-store-list-head",children:[e.jsx("div",{className:"w6w-data-store-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-data-store-list-actions",children:d==null?void 0:d.actions})]}),n&&e.jsx("div",{className:"w6w-error",children:n}),s&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!s?e.jsx(h.EmptyState,{testId:"w6w-data-store-list-empty",children:(d==null?void 0:d.empty)??"No data stores yet."}):e.jsx(h.DataTable,{columns:b,rows:t,rowKey:w=>w.id,loading:s,getRowHref:i?w=>i(w.id):void 0,onRowClick:a?(w,p)=>a(w.id,p):void 0})]})}function Pa(t){return t.name!==""&&t.required===!0&&(t.type==="string"||t.type==="integer")}function Ma(t,s){const{default:n,...a}=t,i=Pe(t.type,s,!1);return i.ok?i.value===void 0?{column:a}:{column:{...a,default:i.value}}:{column:a,error:i.message}}function Da(t){const{columns:s,onChange:n,keyColumn:a,onKeyColumnChange:i,columnErrors:l}=t,[r,o]=g.useState({}),c=s.filter(Pa),d=c.some(p=>p.name===a)?a:"";g.useEffect(()=>{a!==""&&d===""&&i("")},[a,d,i]);function m(){n([...s,{name:"",type:"string",required:!1}])}function x(p,v){n(s.map((u,f)=>f===p?{...u,...v}:u))}function b(p,v,u,f){const y={...s[p],...f,type:v},{column:N,error:S}=Ma(y,u);o(k=>({...k,[p]:S===void 0?{text:u}:{text:u,error:S}})),n(s.map((k,E)=>E===p?N:k))}function w(p){o(v=>{const u={};for(const[f,y]of Object.entries(v)){const N=Number(f);N<p?u[N]=y:N>p&&(u[N-1]=y)}return u}),n(s.filter((v,u)=>u!==p))}return e.jsxs("div",{className:"w6w-data-columns",children:[e.jsxs("div",{className:"w6w-data-columns-head",children:[e.jsx("h3",{children:"Columns"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:m,children:"+ Add column"})]}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Each column has a name, a scalar type, whether it must be set, and an optional default."}),s.length===0&&e.jsx("p",{className:"w6w-muted w6w-small",children:"No columns yet."}),s.length>0&&e.jsxs("div",{className:"w6w-data-columns-row w6w-data-columns-colhead","aria-hidden":"true",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"}),e.jsx("span",{}),e.jsx("span",{children:"Default"}),e.jsx("span",{})]}),e.jsx("ul",{className:"w6w-data-columns-list","data-testid":"data-columns",children:s.map((p,v)=>{const u=r[v],f=(u==null?void 0:u.text)??Me(p.type,p.default);return e.jsxs("li",{className:"w6w-data-columns-row",children:[e.jsx("input",{type:"text",value:p.name,placeholder:"name","aria-label":"Column name",onChange:y=>x(v,{name:y.target.value})}),e.jsx("select",{value:p.type,"aria-label":"Column type",onChange:y=>b(v,y.target.value,f),children:it.map(y=>e.jsx("option",{value:y,children:y},y))}),e.jsxs("label",{className:"w6w-data-columns-required",children:[e.jsx("input",{type:"checkbox",checked:p.required,"aria-label":"Required",onChange:y=>x(v,{required:y.target.checked})}),e.jsx("span",{className:"w6w-muted w6w-small",children:"required"})]}),e.jsx("input",{type:"text",value:f,placeholder:"default","aria-label":"Column default",onChange:y=>b(v,p.type,y.target.value)}),e.jsx(h.DeleteButton,{label:`Remove column ${p.name||v+1}`,onClick:()=>w(v)}),(u==null?void 0:u.error)!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-default-error-${v}`,children:u.error}),p.name!==""&&l[p.name]!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-error-${p.name}`,children:l[p.name]})]},v)})}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key column"}),e.jsxs("select",{value:d,onChange:p=>i(p.target.value),children:[e.jsx("option",{value:"",children:"(none — rows get generated keys)"}),c.map(p=>e.jsx("option",{value:p.name,children:p.name},p.name))]}),e.jsx("span",{className:"w6w-hint",children:"Only a required, string or integer column can name a row's key."})]})]})}function Fa({result:t,busy:s,onImport:n,onRefuse:a,onExport:i}){function l(r){var d;const o=r.target,c=(d=o.files)==null?void 0:d[0];if(c!==void 0){if(o.value="",c.size>ws){a(js);return}n(c)}}return e.jsxs("div",{className:"w6w-data-csv-panel","data-testid":"csv-panel",children:[e.jsxs("div",{className:"w6w-data-csv-panel-actions",children:[e.jsx("input",{type:"file",accept:".csv,text/csv","data-testid":"csv-file","aria-label":"Import CSV",onChange:l}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"csv-export",disabled:s,onClick:i,children:"Export CSV"})]}),t!==null&&e.jsx("div",{className:t.ok?"w6w-result":"w6w-result w6w-error","data-testid":"csv-result",children:t.message})]})}function Ba({rows:t,empty:s,loading:n,searchValue:a,hasMore:i,onOpen:l,onSearch:r,onNew:o,onLoadMore:c}){const[d,m]=g.useState(a??""),x=w=>{w.preventDefault(),r(d)},b=[{key:"key",header:"Key",width:"26%",render:w=>e.jsx("button",{type:"button",className:"w6w-data-entry-key",title:w.key,"data-testid":"entry-key",onClick:p=>{p.stopPropagation(),l(w.key)},children:w.key})},{key:"value",header:"Value",render:w=>w.copyText!==void 0?e.jsx(M.Copyable,{value:w.copyText,label:"Copy value",className:"w6w-copyable--bare",children:e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}):e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}];return e.jsxs("div",{children:[e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:x,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:d,placeholder:"Key prefix","aria-label":"Key prefix",onChange:w=>m(w.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-data-entry-new",type:"button","data-testid":"entry-new",onClick:o,children:"+ New entry"})]}),e.jsx(h.DataTable,{className:"w6w-data-entry-list",onRowClick:w=>l(w.key),columns:b,rows:t,rowKey:w=>w.key,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:n?"Loading…":s??"No entries match this key prefix."})}),i&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:c,children:"Load more"})]})}function Ua({kind:t,isNew:s,entryKey:n,newKey:a,expiresAt:i,text:l,error:r,conflict:o,saving:c,onTextChange:d,onKeyChange:m,onDelete:x,onSave:b,onCancel:w,onReload:p}){const[v,u]=g.useState(s),[f,y]=g.useState(!1),N=g.useRef(null);g.useEffect(()=>{var I;s||(I=N.current)==null||I.focus()},[s]);const S=t==="doc"?"document":"entry",k=t==="doc"?ys(l):void 0,E=k!==void 0&&!k.ok,C=r||(f&&k&&!k.ok?k.message:null),P=e.jsxs(e.Fragment,{children:[s?e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key"}),e.jsx("input",{"data-testid":"entry-new-key",value:a??"",placeholder:"Key","aria-label":"Key",onChange:I=>m(I.target.value)})]}):i?e.jsxs("p",{className:"w6w-muted w6w-small",children:["Expires ",i]}):null,t==="doc"?e.jsx(h.JsonEditor,{value:l,readOnly:!v,onChange:I=>{y(!1),d(I)},onFocus:()=>y(!1),onBlur:()=>y(!0),showDiagnostics:f,minHeight:"min(50vh, 400px)",maxHeight:"60vh"}):e.jsx(M.Copyable,{value:l,label:"Copy value",children:e.jsx("input",{type:"text","data-testid":"entry-value",value:l,"aria-label":"Value",readOnly:!v,onChange:I=>d(I.target.value)})}),C&&e.jsx("div",{className:"w6w-field-error",role:"alert","data-testid":"entry-value-error",children:C}),o&&e.jsxs("div",{className:"w6w-error","data-testid":"entry-conflict",children:[ot," ",e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entry-reload",onClick:p,children:"Reload"})]})]});return e.jsxs(h.Modal,{title:s?`New ${S}`:v?`Edit ${S}`:t==="doc"?"Document":"Entry",subtitle:s?void 0:n,size:t==="doc"?"wide":"default",onClose:c?()=>{}:w,children:[e.jsx("div",{className:"w6w-modal-body","data-testid":"entry-editor",children:P}),e.jsxs("div",{className:"w6w-modal-actions",children:[!s&&x&&e.jsx(h.DeleteButton,{label:"Delete entry",className:"w6w-data-entry-delete",disabled:c,onClick:x}),e.jsx("button",{ref:N,className:"w6w-btn w6w-btn-ghost",type:"button",disabled:c,onClick:w,children:v?"Cancel":"Close"}),v?e.jsx("button",{className:"w6w-btn",type:"button","data-testid":"entry-save",disabled:!!o||!!c||E||s&&!(a!=null&&a.trim()),onClick:b,children:"Save"}):e.jsx("button",{className:"w6w-btn",type:"button",disabled:c,onClick:()=>u(!0),children:"Edit"})]})]})}const Ee=t=>t.isNew?"new":t.id;function Wa({columns:t,keyColumn:s,rows:n,error:a,loading:i,empty:l,searchValue:r,hasMore:o,onCellChange:c,onSave:d,onDelete:m,onReload:x,onAddRow:b,onLoadMore:w,onSearch:p}){const[v,u]=g.useState(r??""),f=N=>{N.preventDefault(),p(v)},y=[...t.map(N=>({key:N.name,header:e.jsxs(e.Fragment,{children:[N.name," ",e.jsx("span",{className:"w6w-muted w6w-small",children:N.type})]}),render:S=>{var E;const k=(E=S.cellErrors)==null?void 0:E[N.name];return e.jsxs("div",{className:"w6w-data-cell",children:[e.jsx("input",{"data-row":Ee(S),"data-column":N.name,value:S.cells[N.name]??"",readOnly:N.name===s&&!S.isNew,"aria-label":`${N.name} (${N.type})`,onChange:C=>c(S.id,N.name,C.target.value)}),k!==void 0&&e.jsx("div",{className:"w6w-data-cell-error","data-row":Ee(S),"data-column":N.name,children:k})]})}})),{key:"actions",header:"",actions:!0,render:N=>e.jsxs("div",{className:"w6w-data-row-actions",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:N.version===null?"":`v${N.version}`}),e.jsx(h.IconButton,{icon:"check",label:"Save row","data-row":Ee(N),"data-testid":"row-save",disabled:!N.isNew&&!N.dirty||!!N.conflict,onClick:()=>d(N.id)}),e.jsx(h.DeleteButton,{label:"Delete entry",onClick:()=>m(N.id)}),N.conflict&&e.jsxs("div",{className:"w6w-error","data-row":Ee(N),"data-testid":"row-conflict",children:[ot," ",e.jsx(h.IconButton,{icon:"sync",label:"Reload row","data-testid":"row-reload",onClick:()=>x(N.id)})]})]})}];return e.jsxs("div",{children:[a!=null&&a!==""&&e.jsx("div",{className:"w6w-error","data-testid":"grid-error",children:a}),e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:f,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:v,placeholder:"Key prefix","aria-label":"Key prefix",onChange:N=>u(N.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"grid-add-row",onClick:b,children:"Add row"})]}),e.jsx("div",{className:"w6w-data-grid-scroll","data-testid":"data-grid-scroll",children:e.jsx(h.DataTable,{columns:y,rows:n,rowKey:N=>N.id,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:i?"Loading…":l??"No rows match this key prefix."})})}),o&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:w,children:"Load more"})]})}class Z extends Error{constructor(n,a){super(a);we(this,"code");this.name="CallableRunError",this.code=n}}function Ns(t,s){const n=s==null?void 0:s.trim();if(n)return n;const a=t.split(".").filter(i=>i!=="");return a[a.length-1]??t}function ks(t,s,n="send_confirmation"){const a=`${s}.${n}`;return t.find(i=>i.tags.includes(a))??null}function ct(t){return h.callableTriggers(t).map(s=>{var n;return{id:s.id,fields:h.asFieldDefs((n=s.with)==null?void 0:n.fields)}})}function Va(t){return"callableId"in t}function Ss(t,s,n,a){if(Va(t)){const l={kind:t.kind,id:t.callableId,input:{[t.field]:s}};return t.kind==="workflow"&&(l.entry=t.entry),l}const i={kind:t.kind,id:t.id,input:{[n]:s}};if(t.kind==="workflow"){const l=a?ct(a)[0]:void 0;if(!l)throw new Z("no-trigger",`Workflow ${t.name} has no manual trigger.`);i.entry=l.id}return i}async function Cs(t,s){if(s.kind==="workflow"){const n=await t.runWorkflow(s.id,{entry:s.entry,input:s.input});if(n.error||n.status==="failed"||n.status==="error"){const a=n.error;throw new Z("failed",typeof a=="string"?a:a?JSON.stringify(a):`Workflow ${n.status}`)}return n.output}if(s.kind==="function")return t.invokeFunction(s.id,s.input);if(!t.invokeEndpoint)throw new Z("unsupported","This host does not support running endpoints.");return t.invokeEndpoint(s.id,s.input)}async function dt(t,s,n,a,i){const l=s.kind==="workflow"?await t.getWorkflow(s.id):void 0,r=Ss(s,n,a,l);return Cs(t,i?{...r,input:{...r.input,...i}}:r)}async function Ka(t,s){if(s.kind==="workflow"){let n;try{n=await t.getWorkflow(s.callableId)}catch{return`Workflow ${s.callableId} no longer exists.`}return!s.entry||!ct(n).some(a=>a.id===s.entry)?`Step ${s.entry??"(none)"} is no longer a manual trigger of ${s.callableId}.`:null}if(s.kind==="function")try{await t.getFunction(s.callableId)}catch{return`Function ${s.callableId} no longer exists.`}return null}async function Es(t,s,n){if(!t.getCallableBinding)throw new Z("unsupported","This host does not support callable bindings.");const a=await t.getCallableBinding(s);if(!a)throw new Z("unbound",`No callable is bound to ${s}.`);const i=await Ka(t,a);if(i)throw new Z("stale",i);return Cs(t,Ss(a,n,a.field))}function Rs(t){return t instanceof Error?t:new Error(String(t))}function ut({onResult:t,onError:s}){const[n,a]=g.useState({status:"idle"}),i=g.useRef(!0);g.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const l=g.useRef({onResult:t,onError:s});l.current={onResult:t,onError:s};const r=g.useCallback(async o=>{var c,d,m,x;a({status:"loading"});try{const b=await o();i.current&&a({status:"success",output:b}),(d=(c=l.current).onResult)==null||d.call(c,b)}catch(b){const w=Rs(b);i.current&&a({status:"error",error:w}),(x=(m=l.current).onError)==null||x.call(m,w)}},[]);return{state:n,run:r}}function As(t){const s=h.useW6WApi(),[n,a]=g.useState({status:"loading"});return g.useEffect(()=>{let i=!0;if(!s.listCallables){a({status:"error",error:new Z("unsupported","This host does not support listing callables.")});return}return a({status:"loading"}),s.listCallables({tag:t}).then(l=>i&&a({status:"ready",refs:l})).catch(l=>i&&a({status:"error",error:Rs(l)})),()=>{i=!1}},[s,t]),n}function wt({error:t,onSetup:s}){const n=t instanceof Z&&(t.code==="stale"||t.code==="unbound");return e.jsxs("div",{className:"w6w-error w6w-small",role:"alert",children:[t.message,n&&s&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Set up"})]})]})}function mt({callable:t,bindingKey:s,data:n,prop:a="data",onClose:i,onSetup:l,onResult:r,onError:o,title:c}){const d=h.useW6WApi(),{state:m,run:x}=ut({onResult:r,onError:o}),[b,w]=g.useState(""),[p,v]=g.useState(null),u=s||((t==null?void 0:t.name)??"callable"),f=()=>{let y;if(b.trim())try{const N=JSON.parse(b);if(!N||typeof N!="object"||Array.isArray(N))throw new Error("not an object");y=N}catch{v("Additional inputs must be a JSON object.");return}v(null),s?x(()=>Es(d,s,n)):t&&x(()=>dt(d,t,n,a,y))};return e.jsxs(h.Modal,{title:c??`Run ${u}`,onClose:i,children:[e.jsx("div",{className:"w6w-modal-body",children:m.status==="success"?e.jsx(h.ResultViewer,{value:m.output}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Run ",u," with this data?"]}),e.jsx("pre",{className:"w6w-small",children:JSON.stringify(n,null,2)}),e.jsxs("label",{className:"w6w-small",children:["Additional inputs (JSON, optional)",e.jsx("textarea",{"aria-label":"Additional inputs",value:b,disabled:m.status==="loading",onChange:y=>w(y.target.value)})]}),p&&e.jsx("div",{className:"w6w-error w6w-small",children:p}),m.status==="error"&&e.jsx(wt,{error:m.error,onSetup:l})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:m.status==="success"?"Close":"Cancel"}),m.status!=="success"&&e.jsx("button",{type:"button",className:"w6w-btn",onClick:f,disabled:m.status==="loading",children:m.status==="loading"?"Running…":"Run"})]})]})}function Ja({tag:t="",bindingKey:s,defaultAction:n,data:a,as:i,confirm:l=!1,label:r="Run",onSetup:o,onResult:c,onError:d}){const m=h.useW6WApi(),x=As(s?"":t),{state:b,run:w}=ut({onResult:c,onError:d}),[p,v]=g.useState(!1),u=Ns(t,i),f=x.status==="ready"?ks(x.refs,t,n):null;let y=b.status==="loading",N=b.status==="loading"?"Running…":r;s||(x.status==="loading"?(y=!0,N="Loading…"):x.status==="ready"&&!f?(y=!0,N="No default action"):x.status==="error"&&(y=!0));const S=()=>{if(l)return v(!0);s?w(()=>Es(m,s,a)):f&&w(()=>dt(m,f,a,u))},E=(!s&&x.status==="error"?x.error:null)??(b.status==="error"?b.error:null);return e.jsxs("span",{className:"w6w-run-callable",children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:y,onClick:S,children:N}),b.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),E&&e.jsx(wt,{error:E,onSetup:o}),p&&e.jsx(mt,{callable:f??void 0,bindingKey:s,data:a,prop:u,onSetup:o,onClose:()=>v(!1),onResult:c,onError:d})]})}function qa({tag:t,defaultAction:s,data:n,as:a,confirm:i=!1,label:l="Run",onResult:r,onError:o}){const c=h.useW6WApi(),d=As(t),{state:m,run:x}=ut({onResult:r,onError:o}),[b,w]=g.useState(null),[p,v]=g.useState(!1),u=Ns(t,a),f=d.status==="ready"?d.refs:[],y=ks(f,t,s),N=b??(y==null?void 0:y.id)??"",S=f.find(C=>C.id===N)??null,k=()=>{if(S){if(i)return v(!0);x(()=>dt(c,S,n,u))}},E=d.status==="error"?d.error:m.status==="error"?m.error:null;return e.jsxs("span",{className:"w6w-run-callables",children:[e.jsxs("select",{"aria-label":"Callable",value:N,disabled:d.status!=="ready"||m.status==="loading",onChange:C=>w(C.target.value),children:[d.status==="loading"&&e.jsx("option",{value:"",children:"Loading…"}),d.status==="ready"&&!S&&e.jsx("option",{value:"",disabled:!0,children:f.length===0?"Nothing to run":"Choose…"}),f.map(C=>e.jsx("option",{value:C.id,children:C.name},C.id))]})," ",e.jsx("button",{type:"button",className:"w6w-btn",disabled:!S||m.status==="loading",onClick:k,children:m.status==="loading"?"Running…":l}),m.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),E&&e.jsx(wt,{error:E}),p&&S&&e.jsx(mt,{callable:S,data:n,prop:u,onClose:()=>v(!1),onResult:r,onError:o})]})}const Wt=t=>t instanceof Error?t:new Error(String(t));function Ha({hostKey:t,tag:s="",onSaved:n,onError:a}){var H;const i=h.useW6WApi(),[l,r]=g.useState(null),[o,c]=g.useState(null),[d,m]=g.useState(""),[x,b]=g.useState({status:"idle"}),[w,p]=g.useState(""),[v,u]=g.useState(""),[f,y]=g.useState(!1),[N,S]=g.useState(!1),k=g.useRef(a);k.current=a;const E=g.useRef(R=>{var L;const D=Wt(R);c(D),(L=k.current)==null||L.call(k,D)}).current;g.useEffect(()=>{let R=!0;if(!i.listCallables||!i.saveCallableBinding){E(new Z("unsupported","This host does not support callable bindings."));return}return i.listCallables({tag:s}).then(D=>R&&r(D)).catch(D=>R&&E(D)),()=>{R=!1}},[i,s,E]);const C=(l==null?void 0:l.find(R=>R.id===d))??null;g.useEffect(()=>{if(p(""),u(""),S(!1),!C)return b({status:"idle"});let R=!0;return b({status:"loading"}),(async()=>{if(C.kind==="workflow"){const L=ct(await i.getWorkflow(C.id));return L.length===0?{status:"error",message:"This workflow has no manual trigger."}:{status:"ready",triggers:L,fields:[]}}if(C.kind==="function"){const L=await i.getFunction(C.id);return{status:"ready",triggers:[],fields:L.inputs.map(B=>B.key)}}return{status:"ready",triggers:[],fields:[]}})().then(L=>R&&b(L)).catch(L=>R&&b({status:"error",message:Wt(L).message})),()=>{R=!1}},[i,C]);const P=x.status==="ready"?x.triggers:[],I=P.length===1?P[0].id:w,W=(C==null?void 0:C.kind)==="workflow"?((H=P.find(R=>R.id===I))==null?void 0:H.fields.map(R=>R.key).filter(R=>!!R))??[]:x.status==="ready"?x.fields:[],T=(C==null?void 0:C.kind)==="workflow",Y=!!C&&!!v&&(!T||!!I)&&!f,O=async()=>{if(!C||!i.saveCallableBinding)return;const R={kind:C.kind,callableId:C.id,field:v,...T?{entry:I}:{}};y(!0);try{await i.saveCallableBinding(t,R),S(!0),n==null||n(R)}catch(D){E(D)}finally{y(!1)}};return o&&!l?e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:o.message}):e.jsxs("div",{className:"w6w-callable-binding-setup",children:[e.jsxs("label",{className:"w6w-small",children:["Callable",e.jsxs("select",{"aria-label":"Callable",value:d,disabled:!l,onChange:R=>m(R.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:l?"Choose…":"Loading…"}),(l??[]).map(R=>e.jsxs("option",{value:R.id,children:[R.name," (",R.kind,")"]},R.id))]})]}),x.status==="error"&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:x.message}),P.length>1&&e.jsxs("label",{className:"w6w-small",children:["Trigger",e.jsxs("select",{"aria-label":"Trigger",value:w,onChange:R=>{p(R.target.value),u("")},children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),P.map(R=>e.jsx("option",{value:R.id,children:R.id},R.id))]})]}),x.status==="ready"&&(!T||I)&&e.jsxs("div",{className:"w6w-small",children:["Field",W.length>0?e.jsxs("select",{"aria-label":"Field",value:v,onChange:R=>u(R.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),W.map(R=>e.jsx("option",{value:R,children:R},R))]}):e.jsx("input",{"aria-label":"Field",value:v,placeholder:"input name",onChange:R=>u(R.target.value)})]}),e.jsx("button",{type:"button",className:"w6w-btn",disabled:!Y,onClick:O,children:f?"Saving…":"Save binding"}),N&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Saved"}),o&&l&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:o.message})]})}const Ya={pending:"Pending",verified:"Verified",revoked:"Revoked",suspended:"Suspended"};function Ts({status:t,className:s,testId:n}){return e.jsx("span",{className:["w6w-publisher-badge",`w6w-publisher-badge-${t}`,s].filter(Boolean).join(" "),"data-status":t,"data-testid":n,children:Ya[t]})}function he({label:t,value:s,id:n}){return e.jsxs("div",{className:"w6w-verification-row","data-testid":`verification-${n}`,children:[e.jsx("span",{className:"w6w-verification-label",children:t}),e.jsx("code",{className:"w6w-verification-value",children:s}),e.jsx(M.Copyable,{value:s,label:`Copy ${t}`,children:e.jsx("span",{children:"Copy"})})]})}function $s({instructions:t,className:s,testId:n}){const{dns:a,wellKnown:i,domain:l}=t;return e.jsxs("div",{className:["w6w-verification",s].filter(Boolean).join(" "),"data-testid":n,children:[e.jsxs("p",{children:["Prove you control ",l," with either method:"]}),e.jsx("h4",{children:"DNS record"}),e.jsx(he,{label:"Type",value:a.type,id:"dns-type"}),e.jsx(he,{label:"Name",value:a.name,id:"dns-name"}),e.jsx(he,{label:"Value",value:a.value,id:"dns-value"}),e.jsx("h4",{children:"Well-known file"}),e.jsx(he,{label:"URL",value:i.url,id:"wk-url"}),e.jsx(he,{label:"Body",value:i.body,id:"wk-body"})]})}function za({namespaces:t,onVerify:s,onRevoke:n,detail:a,busyPrefix:i,canManage:l=!0,className:r,testId:o}){return t.length===0?e.jsx("p",{className:r,"data-testid":o,children:"No namespaces claimed yet."}):e.jsx("ul",{className:["w6w-namespace-list",r].filter(Boolean).join(" "),"data-testid":o,children:t.map(c=>e.jsxs("li",{"data-testid":`namespace-${c.prefix}`,children:[e.jsx("strong",{children:c.prefix})," ",e.jsx("span",{children:c.domain})," ",e.jsx(Ts,{status:c.status}),c.status==="pending"?e.jsxs(e.Fragment,{children:[e.jsx($s,{instructions:c.instructions}),e.jsx("button",{type:"button","data-testid":`verify-${c.prefix}`,disabled:i===c.prefix,onClick:()=>s(c.prefix),children:"Verify"}),a!=null&&a[c.prefix]?e.jsx("p",{role:"alert","data-testid":`detail-${c.prefix}`,children:a[c.prefix]}):null]}):null,c.status!=="revoked"?e.jsx("button",{type:"button","data-testid":`revoke-${c.prefix}`,disabled:!l,onClick:()=>n(c.prefix),children:"Revoke"}):null]},c.prefix))})}function Ga({members:t,canManage:s,onAdd:n,onRemove:a,className:i,testId:l}){const[r,o]=g.useState(""),[c,d]=g.useState("developer");return e.jsxs("div",{className:["w6w-publisher-members",i].filter(Boolean).join(" "),"data-testid":l,children:[e.jsx("ul",{className:"w6w-publisher-member-list",children:t.map(m=>e.jsxs("li",{"data-testid":`member-${m.subject}`,children:[e.jsx("span",{children:m.subject})," ",e.jsx("span",{children:m.role}),e.jsx("button",{type:"button","data-testid":`remove-${m.subject}`,disabled:!s,onClick:()=>a(m.subject),children:"Remove"})]},m.subject))}),e.jsxs("form",{className:"w6w-publisher-member-add",onSubmit:m=>{m.preventDefault();const x=r.trim();!x||!s||(n(x,c),o(""))},children:[e.jsx("input",{"aria-label":"Member subject","data-testid":"member-subject",value:r,disabled:!s,onChange:m=>o(m.target.value)}),e.jsxs("select",{"aria-label":"Member role","data-testid":"member-role",value:c,disabled:!s,onChange:m=>d(m.target.value),children:[e.jsx("option",{value:"developer",children:"developer"}),e.jsx("option",{value:"owner",children:"owner"})]}),e.jsx("button",{type:"submit","data-testid":"member-add",disabled:!s||!r.trim(),children:"Add member"})]})]})}function Xa({onCreate:t,busy:s,error:n,className:a,testId:i}){const[l,r]=g.useState(""),[o,c]=g.useState(""),d=l.trim()!==""&&o.trim()!=="";return e.jsxs("form",{className:["w6w-publisher-form",a].filter(Boolean).join(" "),"data-testid":i,onSubmit:m=>{m.preventDefault(),d&&!s&&t({slug:l.trim(),displayName:o.trim()})},children:[e.jsx("h3",{children:"Become a publisher"}),e.jsx("p",{children:"Create a publisher to claim namespaces and publish apps."}),e.jsx("input",{"aria-label":"Publisher slug","data-testid":"publisher-slug",value:l,onChange:m=>r(m.target.value)}),e.jsx("input",{"aria-label":"Display name","data-testid":"publisher-display-name",value:o,onChange:m=>c(m.target.value)}),e.jsx("button",{type:"submit","data-testid":"publisher-create",disabled:!d||s,children:"Become a publisher"}),n?e.jsx("p",{role:"alert",children:n}):null]})}const Za={private:"Not submitted",submitted:"Submitted for review",in_review:"In review",changes_requested:"Changes requested",listed:"Listed",rejected:"Rejected",suspended:"Suspended",delisted:"Delisted"},Qa={submitted:"Submitted",in_review:"In review",changes_requested:"Changes requested",approved:"Approved",rejected:"Rejected",auto_approved:"Auto-approved",superseded:"Superseded"},ei={validator:"Validator",digest:"Digest",sandbox_describe:"Sandbox describe",auth_test_hook:"Auth test hook",health_check:"Health check",network_wildcard:"Network wildcard",listing_copy:"Listing copy",capability_summary:"Capability summary",reviewer_notes:"Reviewer notes"};function ti({listing:t,submissions:s,className:n,testId:a}){return!t&&s.length===0?null:e.jsxs("div",{className:["w6w-listing-status",n].filter(Boolean).join(" "),"data-testid":a,children:[t?e.jsx("span",{className:"w6w-listing-state","data-listing-state":t.state,children:Za[t.state]??t.state}):null,t!=null&&t.listedVersion?e.jsxs("span",{className:"w6w-listing-listed-version",children:["v",t.listedVersion]}):null,s.length>0?e.jsx("ol",{className:"w6w-listing-submissions",children:s.map(i=>e.jsxs("li",{className:"w6w-listing-submission","data-submission-id":i.id,"data-submission-status":i.status,children:[e.jsxs("div",{className:"w6w-listing-submission-head",children:[e.jsx("span",{className:"w6w-listing-submission-status",children:Qa[i.status]??i.status}),e.jsxs("span",{className:"w6w-listing-submission-version",children:["v",i.version]}),e.jsx("time",{className:"w6w-listing-submission-when",dateTime:i.createdAt,children:i.createdAt})]}),i.checks.length>0?e.jsx("ul",{className:"w6w-listing-checks",children:i.checks.map(l=>e.jsxs("li",{className:"w6w-listing-check","data-check-key":l.key,"data-check-outcome":l.outcome,children:[e.jsx("span",{className:"w6w-listing-check-key",children:ei[l.key]??l.key}),e.jsx("span",{className:"w6w-listing-check-outcome",children:l.outcome}),e.jsx("span",{className:"w6w-listing-check-message",children:l.message})]},l.key))}):null,i.reasons?e.jsx("p",{className:"w6w-listing-reasons",children:i.reasons}):null,i.hasReviewerNotes?e.jsx("span",{className:"w6w-listing-notes-sent",children:"Reviewer notes sent"}):null]},i.id))}):null]})}const si={invalid_body:"Some of these listing details aren't valid. Fix the highlighted fields and try again.",namespace_owned:"Another publisher already owns one of this app's namespaces.",namespace_reserved:"One of this app's namespaces is reserved by W6W.",publisher_suspended:"Your publisher account is suspended, so it can't submit apps for listing.",not_publisher_tier:"This publisher's plan doesn't include submitting apps for listing.",unknown_version:"That version doesn't exist for this app. Deploy it first, then submit.",submission_pending:"This app already has a submission waiting for a decision. Submit again once it's decided.",listing_delisted:"This app's listing was delisted. Ask W6W to review it again before submitting.",invalid_transition:"This listing can't go back to submitted from where it is now.",stale_submission:"A reviewer already decided on an older submission. Reload to see the current state.",app_delisted:"This app was delisted, so it can't be submitted for listing.",app_suspended:"This app is suspended. It can't take new connections or submissions until it's reinstated.",not_found:"We couldn't find that app on this publisher account."},ni="Something went wrong submitting this listing. Try again in a moment.";function _s(t){return si[t]??ni}const st=280,Vt=5,Kt=4e3;function Jt(t){if(!/^https:\/\//i.test(t))return!1;try{return new URL(t).hostname!==""}catch{return!1}}function ai(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Is(t){const s=[],{version:n,listing:a}=t;n.trim()===""&&s.push({field:"version",message:"Choose the app version to submit."});const i=a.summary.trim();i===""?s.push({field:"summary",message:"Add a one-line summary of what the app does."}):i.length>st&&s.push({field:"summary",message:`Keep the summary to ${st} characters or fewer (it's ${i.length}).`}),a.categories.length>Vt&&s.push({field:"categories",message:`Pick at most ${Vt} categories (you picked ${a.categories.length}).`});const l=a.supportUrl.trim();l===""?s.push({field:"supportUrl",message:"Add an https support URL reviewers can open."}):Jt(l)||s.push({field:"supportUrl",message:"The support URL must start with https://."});const r=(a.privacyUrl??"").trim();r!==""&&!Jt(r)&&s.push({field:"privacyUrl",message:"The privacy URL must start with https://."});const o=a.contactEmail.trim();o===""?s.push({field:"contactEmail",message:"Add a contact email so reviewers can reach you."}):ai(o)||s.push({field:"contactEmail",message:"That contact email doesn't look like an email address."});const c=(a.reviewerNotes??"").trim();return c.length>Kt&&s.push({field:"reviewerNotes",message:`Keep reviewer notes to ${Kt} characters or fewer (they're ${c.length}).`}),s}function ii(t){const s=t.listing.summary.trim(),n=(t.listing.iconRef??"").trim(),a=(t.listing.privacyUrl??"").trim(),i=(t.listing.reviewerNotes??"").trim(),l=t.listing.categories.map(r=>r.trim()).filter(Boolean);return{version:t.version.trim(),listing:{summary:s,...n?{iconRef:n}:{},categories:l,supportUrl:t.listing.supportUrl.trim(),...a?{privacyUrl:a}:{},contactEmail:t.listing.contactEmail.trim(),...i?{reviewerNotes:i}:{}}}}const ri={version:"",summary:"",iconRef:"",categories:"",supportUrl:"",privacyUrl:"",contactEmail:"",reviewerNotes:""};function li({appId:t,versions:s,onSubmit:n,busy:a,errorCode:i,className:l,testId:r}){const[o,c]=g.useState(ri),[d,m]=g.useState([]),x=u=>f=>c(y=>({...y,[u]:f})),b={version:o.version,listing:{summary:o.summary,iconRef:o.iconRef,categories:o.categories.split(",").map(u=>u.trim()).filter(Boolean).filter((u,f,y)=>y.indexOf(u)===f),supportUrl:o.supportUrl,privacyUrl:o.privacyUrl,contactEmail:o.contactEmail,reviewerNotes:o.reviewerNotes}},w=u=>`listing-${u.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`)}`,p=u=>{var f;return((f=d.find(y=>y.field===u))==null?void 0:f.message)??""},v=(u,f,y,N)=>e.jsxs("label",{className:"w6w-listing-form-field","data-field":y,children:[e.jsx("span",{className:"w6w-listing-form-label",children:f}),e.jsx("input",{"aria-label":f,"aria-invalid":p(y)!==""||void 0,"data-testid":w(u),value:o[u],onChange:S=>x(u)(S.target.value)}),N?e.jsx("span",{className:"w6w-listing-form-hint",children:N}):null,p(y)?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":y,children:p(y)}):null]});return e.jsxs("form",{className:["w6w-listing-form",l].filter(Boolean).join(" "),"data-testid":r,"data-app-id":t,noValidate:!0,onSubmit:u=>{u.preventDefault();const f=Is(b);m(f),f.length===0&&!a&&n(ii(b))},children:[e.jsx("h3",{children:"Submit for listing"}),e.jsx("p",{children:"Reviewers check this version, then W6W lists it in the catalog."}),e.jsxs("label",{className:"w6w-listing-form-field","data-field":"version",children:[e.jsx("span",{className:"w6w-listing-form-label",children:"Version"}),e.jsx("input",{"aria-label":"Version",list:"listing-versions","aria-invalid":p("version")!==""||void 0,"data-testid":"listing-version",value:o.version,onChange:u=>x("version")(u.target.value)}),e.jsx("datalist",{id:"listing-versions",children:(s??[]).map(u=>e.jsx("option",{value:u},u))}),p("version")?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":"version",children:p("version")}):null]}),v("summary","Summary","summary",`Up to ${st} characters.`),v("iconRef","Icon reference","iconRef"),v("categories","Categories","categories","Comma-separated, up to five."),v("supportUrl","Support URL","supportUrl","https:// only."),v("privacyUrl","Privacy URL","privacyUrl","Optional, https:// only."),v("contactEmail","Contact email","contactEmail","Where reviewers reach you."),v("reviewerNotes","Notes for the reviewer","reviewerNotes","Optional, up to 4000 characters."),e.jsx("button",{type:"submit","data-testid":"listing-submit",disabled:a,children:"Submit for listing"}),i?e.jsx("p",{className:"w6w-listing-error",role:"alert",children:_s(i)}):null]})}exports.AddConnectionModal=h.AddConnectionModal;exports.ApiCallsPanel=h.ApiCallsPanel;exports.AppConnectionForm=h.AppConnectionForm;exports.AppIcon=h.AppIcon;exports.AppPicker=h.AppPicker;exports.AuthFieldsForm=h.AuthFieldsForm;exports.AuthGuide=h.AuthGuide;exports.CanvasLayer=h.CanvasLayer;exports.CodeEditor=h.CodeEditor;exports.Combobox=h.Combobox;exports.ConfirmModal=h.ConfirmModal;exports.CredentialPicker=h.CredentialPicker;exports.DataTable=h.DataTable;exports.DeleteButton=h.DeleteButton;exports.EmptyState=h.EmptyState;exports.ExpressionEditorModal=h.ExpressionEditorModal;exports.ExpressionInput=h.ExpressionInput;exports.ExpressionOptionsProvider=h.ExpressionOptionsProvider;exports.HTML_PREVIEW_CSP=h.HTML_PREVIEW_CSP;exports.HtmlPreview=h.HtmlPreview;exports.IconButton=h.IconButton;exports.JsonEditor=h.JsonEditor;exports.LastUsedNote=h.LastUsedNote;exports.Markdown=h.Markdown;exports.Modal=h.Modal;exports.NodeConfigForm=h.NodeConfigForm;exports.ParamsForm=h.ParamsForm;exports.PropertyEntryForm=h.PropertyEntryForm;exports.PublisherBadge=h.PublisherBadge;exports.RESULT_RENDER_MAX_CHARS=h.RESULT_RENDER_MAX_CHARS;exports.ResultViewer=h.ResultViewer;exports.RetryPolicyFields=h.RetryPolicyFields;exports.StepBuilderModal=h.StepBuilderModal;exports.W6WUIProvider=h.W6WUIProvider;exports.connectionAppIdsToLookUp=h.connectionAppIdsToLookUp;exports.detectResultFormat=h.detectResultFormat;exports.effectiveNodeOutput=h.effectiveNodeOutput;exports.effectiveNodeOutputs=h.effectiveNodeOutputs;exports.filterOptions=h.filterOptions;exports.findTestInput=h.findTestInput;exports.htmlPreviewSrcDoc=h.htmlPreviewSrcDoc;exports.indexNodeSamples=h.indexNodeSamples;exports.isExprValue=h.isExprValue;exports.isFormResolvedOptions=h.isFormResolvedOptions;exports.isSecretValue=h.isSecretValue;exports.isTestRequired=h.isTestRequired;exports.previewNodeOutputs=h.previewNodeOutputs;exports.rememberableInput=h.rememberableInput;exports.requiredParamsFilled=h.requiredParamsFilled;exports.resolveConnectionAppMeta=h.resolveConnectionAppMeta;exports.resultCopyText=h.resultCopyText;exports.secretClipboard=h.secretClipboard;exports.shapeToSkeleton=h.shapeToSkeleton;exports.shouldUseCombobox=h.shouldUseCombobox;exports.splitFrontmatter=h.splitFrontmatter;exports.startOAuthPopup=h.startOAuthPopup;exports.testInputSavesSettled=h.testInputSavesSettled;exports.trackTestInputSave=h.trackTestInputSave;exports.useEnterSubmit=h.useEnterSubmit;exports.useExpressionOptions=h.useExpressionOptions;exports.useRememberedTestInput=h.useRememberedTestInput;exports.useW6WApi=h.useW6WApi;exports.CodeBlock=M.CodeBlock;exports.Copyable=M.Copyable;exports.Icon=M.Icon;exports.iconNames=M.iconNames;exports.ATTENTION_DISPLAY_CAP=Qe;exports.ActionTestForm=on;exports.ApiError=pe;exports.BudgetMeter=ma;exports.CELL_PROBLEM_COPY=ms;exports.CSV_MAX_BYTES=ws;exports.CSV_TOO_LARGE_COPY=js;exports.CallableBindingSetup=Ha;exports.CallableList=la;exports.CallableListStatus=ra;exports.ColumnsEditor=Da;exports.ConnectionHeader=da;exports.ConnectionKeepAlive=ua;exports.ConnectionList=oa;exports.CopyableText=Yt;exports.CreatePublisherForm=Xa;exports.CreateSharedCredentialContext=nn;exports.CsvPanel=Fa;exports.DATA_STORE_ERROR_FALLBACK=oe;exports.DATA_STORE_KINDS=ha;exports.DATA_STORE_KIND_LABEL=us;exports.DATA_STORE_NETWORK_ERROR=ps;exports.DOC_VALUE_COPY=tt;exports.DataEntryEditor=Ua;exports.DataEntryList=Ba;exports.DataStoreList=La;exports.DataTableGrid=Wa;exports.EditButton=Rn;exports.EditConnectionModal=ca;exports.ExecutionDetail=ea;exports.ExecutionFilters=zn;exports.ExecutionList=On;exports.ExecutionLogPanel=Qt;exports.ExecutionStats=Gn;exports.HealthStatusPill=Ie;exports.HistoryTimeline=Cn;exports.InfoTip=En;exports.ListItem=Te;exports.ListingStatus=ti;exports.NEW_ROW_ID=lt;exports.NamespaceList=za;exports.PublisherMembers=Ga;exports.PublisherStatusBadge=Ts;exports.RECENT_DISPLAY_CAP=as;exports.ReliabilityChart=rs;exports.ReliabilityList=ia;exports.RepoSyncIndicator=An;exports.RowActionsMenu=at;exports.RunCallableButton=Ja;exports.RunCallableModal=mt;exports.RunCallables=qa;exports.SCALAR_TYPES=it;exports.ServerResourcesBadge=gn;exports.ServerResourcesCard=pn;exports.ServerResourcesCardSmall=fn;exports.ServerResourcesRail=xn;exports.StepStatusPill=Oe;exports.SubmitListingForm=li;exports.UptimeStrip=zt;exports.VERSION_CONFLICT_COPY=ot;exports.VerificationInstructionsBlock=$s;exports.YamlEditor=cn;exports.buildRowValue=Ra;exports.cellErrorsOf=$a;exports.createW6WApi=sn;exports.cropText=Ht;exports.csvFilenameOf=xa;exports.csvImportMessage=Oa;exports.csvLineOf=et;exports.dirtyColumns=Ea;exports.displayBoard=is;exports.draftFromEntry=Sa;exports.errorPlacement=vs;exports.formatDurationMs=Le;exports.formatExecutionTime=fe;exports.isCellValue=Na;exports.isVersionConflict=_a;exports.kvValueOf=Ia;exports.kvValueTypeOf=pa;exports.listingErrorCopy=_s;exports.locateDataStoreError=ka;exports.locateRawResponseError=gs;exports.needsAttention=sa;exports.newRowDraft=Ca;exports.parseCell=Pe;exports.parseDocText=ys;exports.partitionBoard=ss;exports.performancePoints=ts;exports.refreshRelativeTime=ds;exports.remainingTtlSeconds=Aa;exports.rowValueOf=bs;exports.rowWriteOf=Ta;exports.serializeCell=Me;exports.tableSchemaOf=fa;exports.uptimeDays=ns;exports.validateListingInput=Is;
1
+ "use client";"use strict";var Zs=Object.defineProperty;var Qs=(t,s,n)=>s in t?Zs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var fe=(t,s,n)=>Qs(t,typeof s!="symbol"?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./connection-app-meta-Dk6F3KEH.cjs"),g=require("react"),e=require("react/jsx-runtime"),B=require("./CodeBlock-C1IC5_6O.cjs"),en=require("@codemirror/lang-yaml"),tn=require("@codemirror/view"),sn=require("@uiw/react-codemirror"),nn=require("react-dom");class ve extends Error{constructor(n,a,i,r){super(i);fe(this,"status");fe(this,"code");fe(this,"body");this.name="ApiError",this.status=n,this.code=a,this.body=r}}function an(t){const s=t.baseUrl.replace(/\/$/,""),n=t.fetch??globalThis.fetch,a=async()=>typeof t.token=="function"?await t.token():t.token;async function i(l,o){const c=new Headers(o==null?void 0:o.headers),d=await a();d&&c.set("authorization",`Bearer ${d}`),o!=null&&o.body&&!c.has("content-type")&&c.set("content-type","application/json");let m;try{m=await n(`${s}${l}`,{...o,headers:c})}catch(w){throw new ve(0,"network_error",`Could not reach the w6w server (${(o==null?void 0:o.method)??"GET"} ${s}${l}). It may be down or unreachable. (${w.message})`)}const f=await m.text();let b=null;if(f)try{b=JSON.parse(f)}catch{if(!m.ok)throw new ve(m.status,"bad_response",`Server returned a non-JSON ${m.status} response: ${f.slice(0,200)}`)}if(!m.ok){const w=(b==null?void 0:b.error)??{};throw new ve(m.status,w.code??"error",w.message??m.statusText,b)}return{status:m.status,data:b}}async function r(l,o){const{data:c}=await i(l,o);return c}return{listApps:async()=>{const l=async()=>{const o=[];let c;for(;;){const d=new URLSearchParams({limit:"200"});c&&d.set("cursor",c);const m=await r(`/apps?${d}`);if(o.push(...m.apps),!m.nextCursor||m.nextCursor===c)return o;c=m.nextCursor}};try{return await l()}catch(o){if(o instanceof ve&&(o.code==="snapshot_expired"||o.code==="unknown_snapshot"))return await l();throw o}},listAppsByIds:async l=>{const o=Array.from(new Set(l)),c=[];for(let d=0;d<o.length;d+=100){const f=o.slice(d,d+100).map(encodeURIComponent).join(","),b=await r(`/apps?ids=${f}`);c.push(...b.apps)}return c},getAppAuth:async l=>(await r(`/apps/${encodeURIComponent(l)}/auths`)).auths??[],createConnection:(l,o)=>r(`/apps/${encodeURIComponent(l)}/connections`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.connection),updateConnection:(l,o)=>r(`/connections/${encodeURIComponent(l)}`,{method:"PATCH",body:JSON.stringify(o)}).then(c=>c.connection),listCredentials:l=>{const o=new URLSearchParams;(l==null?void 0:l.contract)!==void 0&&o.set("contract",l.contract),(l==null?void 0:l.appId)!==void 0&&o.set("appId",l.appId),(l==null?void 0:l.authKey)!==void 0&&o.set("authKey",l.authKey);const c=o.toString();return r(`/credentials${c?`?${c}`:""}`).then(d=>d.credentials??[])},createCredential:l=>r("/credentials",{method:"POST",body:JSON.stringify(l)}).then(o=>o.credential),getCredential:l=>r(`/credentials/${encodeURIComponent(l)}`).then(o=>o.credential),rotateCredential:(l,o)=>r(`/credentials/${encodeURIComponent(l)}/rotate`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.credential),setCredentialStatus:(l,o)=>r(`/credentials/${encodeURIComponent(l)}/${o==="disabled"?"disable":"enable"}`,{method:"POST"}).then(c=>c.credential),testCredential:l=>r(`/credentials/${encodeURIComponent(l)}/test`,{method:"POST"}),credentialDependents:l=>r(`/credentials/${encodeURIComponent(l)}/dependents`).then(o=>o.dependents),deleteCredential:async l=>{await r(`/credentials/${encodeURIComponent(l)}`,{method:"DELETE"})},startAppOAuthFlow:(l,o,c)=>r(`/apps/${encodeURIComponent(l)}/oauth-config/${encodeURIComponent(o)}/authorize-url`,{method:"POST",body:JSON.stringify(c)}),getAppActions:l=>r(`/apps/${encodeURIComponent(l)}`).then(o=>o.actions??[]),listConnectionsForApp:l=>r(`/apps/${encodeURIComponent(l)}/connections`).then(o=>o.connections??[]),listConnections:()=>r("/connections").then(l=>l.connections??[]),invokeAction:(l,o,c,d={})=>r(`/apps/${encodeURIComponent(l)}/actions/${encodeURIComponent(o)}/invoke`,{method:"POST",body:JSON.stringify({params:c,connectionId:d.connectionId,project:d.project,state:d.state,workflowId:d.workflowId})}),listSavedTests:l=>r(`/connections/${encodeURIComponent(l)}/saved-tests`).then(o=>o.savedTests??[]),createSavedTest:(l,o)=>r(`/connections/${encodeURIComponent(l)}/saved-tests`,{method:"POST",body:JSON.stringify(o)}).then(c=>c.savedTest),updateSavedTest:(l,o,c)=>r(`/connections/${encodeURIComponent(l)}/saved-tests/${encodeURIComponent(o)}`,{method:"PATCH",body:JSON.stringify(c)}).then(d=>d.savedTest),deleteSavedTest:(l,o)=>r(`/connections/${encodeURIComponent(l)}/saved-tests/${encodeURIComponent(o)}`,{method:"DELETE"}).then(()=>{}),recordTestRun:(l,o)=>r(`/connections/${encodeURIComponent(l)}/test-runs`,{method:"POST",body:JSON.stringify(o)}).then(()=>{}),listTestRuns:l=>r(`/connections/${encodeURIComponent(l)}/test-runs`).then(o=>o.runs??[]),saveStepTest:(l,o,c)=>r(`/workflows/${encodeURIComponent(l)}/steps/${encodeURIComponent(o)}/tests`,{method:"POST",body:JSON.stringify(c)}).then(d=>d.stepTest),listStepTests:(l,o)=>r(`/workflows/${encodeURIComponent(l)}/steps/${encodeURIComponent(o)}/tests`).then(c=>c.stepTests??[]),loadNodeSamples:l=>r(`/workflows/${encodeURIComponent(l)}/node-samples`).then(o=>o.nodeSamples??[]),loadTestInputs:l=>r(`/workflows/${encodeURIComponent(l)}/test-inputs`).then(o=>o.testInputs??[]),saveTestInput:(l,o,c)=>r(`/workflows/${encodeURIComponent(l)}/nodes/${encodeURIComponent(o)}/test-input`,{method:"PUT",body:JSON.stringify({input:c})}).then(()=>{}),recordStepTestRun:(l,o,c)=>r(`/workflows/${encodeURIComponent(l)}/steps/${encodeURIComponent(o)}/test-runs`,{method:"POST",body:JSON.stringify(c)}).then(()=>{}),listFunctions:()=>r("/functions").then(l=>l.functions??[]),getFunction:l=>r(`/functions/${encodeURIComponent(l)}`).then(o=>({...o.function,valid:o.valid})),invokeFunction:(l,o)=>r(`/functions/${encodeURIComponent(l)}/invoke`,{method:"POST",body:JSON.stringify({inputs:o})}).then(c=>c.output),listWorkflows:()=>r("/workflows").then(l=>l.workflows??[]),getWorkflow:l=>r(`/workflows/${encodeURIComponent(l)}`).then(o=>o.workflow),runWorkflow:(l,o={})=>i(`/workflows/${encodeURIComponent(l)}/run?wait=true`,{method:"POST",body:JSON.stringify({variables:o.variables,input:o.input,entry:o.entry})}).then(({status:c,data:d})=>({...d??{},terminal:c===200}))}}const ln=g.createContext(void 0);function _e({title:t,subtitle:s,icon:n,trailing:a,active:i=!1,onClick:r,href:l,ariaLabel:o}){const c=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:t}),s!=null&&e.jsx("span",{className:"w6w-list-item-subtitle",children:s})]}),a!=null&&e.jsx("span",{className:"w6w-list-item-trailing",children:a})]}),d=`w6w-list-item${i?" active":""}`;return l!==void 0?e.jsx("a",{className:d,href:l,"aria-current":i?"true":void 0,"aria-label":o,onClick:r,children:c}):r?e.jsx("button",{type:"button",className:d,"aria-pressed":i,"aria-label":o,onClick:r,children:c}):e.jsx("div",{className:d,"aria-label":o,children:c})}function Je(t){const s=Date.parse(t);if(Number.isNaN(s))return"";const n=Math.max(0,Math.round((Date.now()-s)/1e3));if(n<45)return"just now";const a=Math.round(n/60);if(a<60)return`${a}m ago`;const i=Math.round(a/60);if(i<24)return`${i}h ago`;const r=Math.round(i/24);return r<7?`${r}d ago`:new Date(s).toLocaleDateString()}function Rt(t){const s={};for(const n of(t==null?void 0:t.params)??[])n.key&&n.default!==void 0&&(s[n.key]=n.default);return s}function rn(t){var n,a,i;const s=t.indexOf("{");if(s>=0)try{const r=JSON.parse(t.slice(s)),l=((a=(n=r==null?void 0:r.errors)==null?void 0:n[0])==null?void 0:a.message)??(typeof(r==null?void 0:r.error)=="object"?(i=r.error)==null?void 0:i.message:r==null?void 0:r.error)??(r==null?void 0:r.message);if(typeof l=="string"&&l.trim()){const o=t.slice(0,s).replace(/[:\s]+$/,"");return o?`${o}: ${l.trim()}`:l.trim()}}catch{}return t}function Yt(t){return typeof t=="object"&&t!==null&&typeof t.status=="number"&&typeof t.code=="string"}function on(t){if(!Yt(t))return{headline:(t==null?void 0:t.message)??"The action failed to run."};const s=rn(t.message??""),n=`${t.status} ${t.code} ${t.message??""}`.toLowerCase();return t.status===401||t.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:s}:{headline:"The action returned an error.",detail:s}}function cn(t){const s=Yt(t)?t.body??t.raw:null;return(s==null?void 0:s.apiCalls)??[]}function qe(){const[t,s]=g.useState(""),[n,a]=g.useState(void 0),[i,r]=g.useState(!1);return{text:t,value:n,invalid:i,onChange:o=>{s(o);const c=o.trim();if(c===""){r(!1);return}try{const d=JSON.parse(c);d!==null&&typeof d=="object"&&!Array.isArray(d)?(a(d),r(!1)):r(!0)}catch{r(!0)}}}}function dn({appId:t,actions:s,connectionId:n,action:a,seedValues:i,onSavedTestsChanged:r,seedTestId:l,onDirtyChange:o,onTestSaved:c,onDeleted:d,embedded:m=!1}){var Ct;const f=h.useW6WApi(),b=g.useMemo(()=>{const j=[...s];return j.sort((O,Y)=>(O.title||O.key).localeCompare(Y.title||Y.key)),j},[s]),[w,p]=g.useState((a==null?void 0:a.key)??""),v=a??s.find(j=>j.key===w)??null,[u,x]=g.useState(!1),[y,N]=g.useState(null),[C,k]=g.useState(void 0),[A,E]=g.useState([]),P=qe(),I=qe(),V=qe(),[D,X]=g.useState(""),[L,K]=g.useState(""),R=P.invalid||I.invalid||V.invalid,M=()=>{const j={};return P.text.trim()!==""&&P.value!==void 0&&(j.body=P.value),I.text.trim()!==""&&I.value!==void 0&&(j.query=I.value),V.text.trim()!==""&&V.value!==void 0&&(j.headers=V.value),D&&(j.target=D),L.trim()!==""&&(j.match=L.trim()),Object.keys(j).length>0?j:void 0},[$,U]=g.useState("form"),[ee,Z]=g.useState(""),[G,le]=g.useState(!1),[q,S]=g.useState(!1),F=(v==null?void 0:v.key)??null,re=i?{...i}:Rt(v),[oe,T]=g.useState(()=>({key:F,values:re})),[_,W]=g.useState(l??null),[H,ce]=g.useState(re);if(oe.key!==F){const j=Rt(v);T({key:F,values:j}),ce(j),W(l??null),N(null),k(void 0),E([])}const[J,ue]=g.useState(l);l!==J&&(ue(l),W(l??null));const[ft,Ps]=g.useState(i);if(i!==ft){const j=JSON.stringify(i??null)!==JSON.stringify(ft??null);if(Ps(i),i&&j){const O={...i};T({key:F,values:O}),ce(O),N(null),k(void 0),E([])}}const te=oe.values,xt=j=>T({key:F,values:j}),gt=g.useMemo(()=>JSON.stringify(te)!==JSON.stringify(H),[te,H]);g.useEffect(()=>{o==null||o(gt)},[gt]);const Ms=()=>{Z(JSON.stringify(te,null,2)),le(!1),U("json")},Ds=async j=>{if(!v||R)return;const O=v.key;x(!0),N(null),k(void 0),E([]);let Y;const we=M();try{const se=await f.invokeAction(t,O,j,{connectionId:n,...we?{overrides:we}:{}});k(se.value),E(se.apiCalls??[]),Y={ok:!0,summary:"OK",result:se.value}}catch(se){const Et=on(se);N(Et),E(cn(se)),Y={ok:!1,summary:Et.headline}}finally{x(!1)}if(n)try{await f.recordTestRun(n,{savedTestId:_??null,actionKey:O,ok:Y.ok,summary:Y.summary.slice(0,200),result:Y.result}),Ve(),Hs(),r==null||r()}catch{}},Fs=()=>Ds(te),[Ne,vt]=g.useState(null),[ke,pe]=g.useState(null),[Bs,Us]=g.useState(0),[Ws,Se]=g.useState(!1),[Be,Ue]=g.useState(""),[Vs,We]=g.useState(!1),Ve=()=>Us(j=>j+1);g.useEffect(()=>{if(!n){vt(null);return}let j=!1;return pe(null),f.listSavedTests(n).then(O=>!j&&vt(O)).catch(O=>!j&&pe(O.message)),()=>{j=!0}},[f,n,Bs]);const jt=F?(Ne??[]).filter(j=>j.actionKey===F):[],[Ks,Ke]=g.useState(null),[Js,qs]=g.useState(0),Hs=()=>qs(j=>j+1);g.useEffect(()=>{const j=f.listTestRuns;if(!n||!j){Ke(null);return}let O=!1;return j(n).then(Y=>!O&&Ke(Y)).catch(()=>!O&&Ke(null)),()=>{O=!0}},[f,n,Js]);const bt=F?(Ks??[]).filter(j=>j.actionKey===F).slice().sort((j,O)=>Date.parse(O.occurredAt)-Date.parse(j.occurredAt)):[],Ys=()=>{!n||!v||(Ue(""),pe(null),Se(!0))},zs=()=>{!n||!v||(_?yt():Ys())},yt=async()=>{if(!(!n||!v))try{let j;if(_)j=await f.updateSavedTest(n,_,{values:te});else{const O=Be.trim();if(!O)return;j=await f.createSavedTest(n,{actionKey:v.key,name:O,values:te}),W(j.id)}ce({...te}),Se(!1),Ue(""),Ve(),r==null||r(),c==null||c(j)}catch(j){pe(j.message)}},Gs=j=>{const O={...j.values};T({key:F,values:O}),ce(O),W(j.id),U("form"),N(null),k(void 0),E([])},Xs=async()=>{if(!n||!_)return;const j=_;try{await f.deleteSavedTest(n,j),W(null),Ve(),r==null||r(),d==null||d(j)}catch(O){pe(O.message)}},Nt=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${$==="form"?" active":""}`,"aria-pressed":$==="form",onClick:()=>U("form"),children:"Form"}),e.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${$==="json"?" active":""}`,"aria-pressed":$==="json",onClick:Ms,children:"JSON"}),!m&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-sm w6w-btn-ghost","aria-pressed":q,title:q?"Collapse the params editor":"Open the params editor in a larger view","aria-label":q?"Collapse the params editor":"Open the params editor in a larger view",onClick:()=>S(j=>!j),children:q?"⤡":"⤢"})]})]}),$==="form"?e.jsx(h.ParamsForm,{params:(v==null?void 0:v.params)??[],values:te,onChange:xt,dynamic:v?{appId:t,actionKey:v.key,connectionId:n}:void 0}):e.jsxs(e.Fragment,{children:[e.jsx(h.JsonEditor,{value:ee,onChange:Z,minHeight:q?"50vh":"200px","aria-label":"Params JSON",onValidChange:j=>{j!==null&&typeof j=="object"&&!Array.isArray(j)&&xt(j)},onValidityChange:({valid:j})=>le(!j)}),G&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]}),kt=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(h.JsonEditor,{value:P.text,onChange:P.onChange,minHeight:"80px","aria-label":"Overrides body (JSON)"}),P.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(h.JsonEditor,{value:I.text,onChange:I.onChange,minHeight:"80px","aria-label":"Overrides query (JSON)"}),I.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(h.JsonEditor,{value:V.text,onChange:V.onChange,minHeight:"80px","aria-label":"Overrides headers (JSON)"}),V.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:D,onChange:j=>X(j.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:L,placeholder:"Restrict to requests whose URL contains…",onChange:j=>K(j.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."})]})]}),Ce=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"})}),ke&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:ke}),jt.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:jt.map(j=>e.jsx("li",{children:e.jsx(_e,{title:j.name,subtitle:j.lastRunAt?e.jsxs("span",{children:[e.jsx("span",{style:{color:j.lastRunOk?"var(--w6w-success)":"var(--w6w-danger)"},children:j.lastRunOk?"✓":"✗"})," ",j.lastRunSummary?`${j.lastRunSummary} · `:"",Je(j.lastRunAt)]}):`saved ${Je(j.updatedAt)}`,active:j.id===_,onClick:()=>Gs(j)})},j.id))}),f.listTestRuns&&bt.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:bt.map(j=>e.jsx("li",{children:e.jsx(_e,{title:e.jsxs("span",{children:[e.jsx("span",{style:{color:j.ok?"var(--w6w-success)":"var(--w6w-danger)"},children:j.ok?"✓":"✗"})," ",j.actionKey]}),subtitle:e.jsxs("span",{children:[j.summary?`${j.summary} · `:"",Je(j.occurredAt)]})})},j.id))})]})]}):null,St=(Ct=Ne==null?void 0:Ne.find(j=>j.id===_))==null?void 0:Ct.name;return e.jsxs("div",{className:`w6w-stack${m?" w6w-tester-embedded-root":""}`,children:[!a&&(s.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",F?"":" *"]}),e.jsx(h.Combobox,{value:w,placeholder:"— pick an action —",onChange:p,options:b.map(j=>({value:j.key,label:`${j.title??j.key} (${j.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 j=y?e.jsxs("div",{className:"w6w-result w6w-error",children:[e.jsx("strong",{children:y.headline}),y.hint&&e.jsx("div",{style:{marginTop:"var(--w6w-sp-1-5)"},children:y.hint}),y.detail&&e.jsx("div",{className:"w6w-muted w6w-small",style:{marginTop:"var(--w6w-sp-1-5)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:y.detail})]}):null,O=C!==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(h.ResultViewer,{value:C})]}):null,Y=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[Nt,kt,j,O,e.jsx(h.ApiCallsPanel,{calls:A})]}),we=e.jsxs("div",{className:`w6w-tester-actions${m||q?" w6w-tester-actions-footer":""}`,style:{display:"flex",gap:"var(--w6w-sp-2)"},children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:u||R,onClick:Fs,children:u?"Running…":"Run action"}),n&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:zs,children:"Save test"}),n&&_&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",style:{marginLeft:"auto",color:"var(--w6w-danger)"},onClick:()=>We(!0),children:"Delete"})]}),se=e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[Y,we]});return m?e.jsxs("div",{className:"w6w-tester-embedded",children:[e.jsx("div",{className:"w6w-tester-embedded-scroll",children:e.jsxs("div",{className:"w6w-card-stack",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Parameters"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[Nt,kt,j]})]}),(O||A.length>0)&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Result"})}),e.jsxs("div",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},children:[C!==void 0&&e.jsx(h.ResultViewer,{value:C}),e.jsx(h.ApiCallsPanel,{calls:A})]})]}),Ce&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-head",children:e.jsx("h3",{children:"Saved tests and history"})}),Ce]})]})}),we]}):q?e.jsx(h.Modal,{title:`Edit params — ${v.title??v.key}`,onClose:()=>S(!1),size:"full",children:e.jsxs("div",{className:"w6w-tester-popout",children:[e.jsx("div",{className:"w6w-tester-popout-scroll",children:Ce?e.jsxs("div",{style:{display:"flex",gap:"var(--w6w-sp-4)",alignItems:"flex-start"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:Y}),e.jsx("div",{style:{width:260,flexShrink:0},children:Ce})]}):Y}),we]})}):se})(),Ws&&e.jsx(h.Modal,{title:"Save test",onClose:()=>Se(!1),children:e.jsxs("form",{className:"w6w-stack",style:{gap:"var(--w6w-sp-3)"},onSubmit:j=>{j.preventDefault(),yt()},children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Name this saved test"}),e.jsx("input",{type:"text",value:Be,placeholder:"e.g. valid sender",onChange:j=>Ue(j.target.value)})]}),ke&&e.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:ke}),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:()=>Se(!1),children:"Cancel"}),e.jsx("button",{type:"submit",className:"w6w-btn",disabled:!Be.trim(),children:"Save"})]})]})}),Vs&&e.jsx(h.ConfirmModal,{title:"Delete saved test",message:St?`Delete "${St}"? This cannot be undone.`:"Delete this saved test? This cannot be undone.",confirmLabel:"Delete",onConfirm:()=>{We(!1),Xs()},onClose:()=>We(!1)})]}):!a&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action above to test it."})]})}function un(t){const s=h.useEffectiveTheme(t.theme),{copied:n,copy:a}=B.useCopyToClipboard(t.value),i=g.useMemo(()=>[en.yaml(),tn.EditorView.theme(h.EDITOR_THEME_SPEC)],[]);function r(l){t.onChange(l)}return e.jsxs("div",{className:"w6w-yaml-editor","aria-label":t["aria-label"]??"YAML editor",children:[e.jsx(sn,{value:t.value,onChange:r,extensions:i,placeholder:t.placeholder,readOnly:t.readOnly,editable:!t.readOnly,theme:s,height:t.height,minHeight:t.minHeight??"240px",maxHeight:t.maxHeight,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!t.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),t.copyable!==!1&&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 a(),children:n?e.jsx(B.CheckGlyph,{}):e.jsx(B.CopyGlyph,{})}),e.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:n?"Copied":""})]})]})}const He="…";function zt(t,s,n="end"){if(s===void 0||s<1||s>=t.length)return t;if(n==="start")return`${He}${t.slice(t.length-s)}`;if(n==="end")return`${t.slice(0,s)}${He}`;const a=Math.ceil(s/2),i=s-a;return`${t.slice(0,a)}${He}${t.slice(t.length-i)}`}function Gt(t){const{value:s,chars:n,crop:a="end",label:i,className:r,copiedMs:l}=t,o=zt(s,n,a),c=["w6w-copyable--bare",r].filter(Boolean).join(" ");return e.jsx(B.Copyable,{value:s,readOnly:!0,label:i,className:c,copiedMs:l,children:e.jsx("span",{children:o})})}const wn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Le({state:t,label:s,ariaLabel:n}){const a=s??wn[t];return e.jsxs("span",{className:`w6w-health-pill w6w-health-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-health-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-health-pill-label",children:a})]})}const mn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"};function Xt({days:t,ariaLabel:s}){return t.length===0?null:e.jsx("div",{className:"w6w-uptime-strip",role:"img","aria-label":s??`${t.length}-day status`,children:t.map((n,a)=>e.jsx("span",{className:`w6w-uptime-cell w6w-uptime-cell-${n.state}`,title:n.label??`${n.day} — ${mn[n.state]}`},`${n.day}-${a}`))})}const Zt="—",At=["B","KiB","MiB","GiB","TiB","PiB"];function Qt(t){if(t===null||!Number.isFinite(t))return Zt;if(t<1024)return`${Math.round(t)} B`;let s=t,n=0;for(;s>=1024&&n<At.length-1;)s/=1024,n+=1;return`${s.toFixed(1)} ${At[n]}`}function ie(t){return t===null||!Number.isFinite(t)?Zt:`${Math.round(t*100)}%`}function be(t){if(t===void 0||t.load1===null)return null;const s=t.cpuLimit??t.cpus;return s===null||s<=0?null:t.load1/s}function ye(t){if(t===void 0)return null;const{memoryTotal:s,memoryAvailable:n}=t;return s===null||n===null||s<=0?null:(s-n)/s}function hn(t,s,n){return t<s?s:t>n?n:t}function pn(t,s,n,a){const i=t.length;if(i<2)return"";const r=[];for(let l=0;l<i;l++){const o=t[l];if(o===null)continue;const c=l/(i-1)*s,d=a<=0?n:n-hn(o,0,a)/a*n;r.push(`${Number(c.toFixed(2))},${Number(d.toFixed(2))}`)}return r.join(" ")}const fn="—",Tt=100,$t=24;function Qe({values:t,max:s,className:n}){const a=pn(t,Tt,$t,s);return a===""?null:e.jsx("svg",{className:n,viewBox:`0 0 ${Tt} ${$t}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:e.jsx("polyline",{points:a,fill:"none",stroke:"var(--w6w-accent)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})})}function Ye(t){return t===null?fn:t.toFixed(2)}function Oe(t){let s=1;for(const n of t)n!==null&&n>s&&(s=n);return s}function Te({label:t,value:s,values:n,max:a}){return e.jsxs("li",{className:"w6w-server-resources__row",children:[e.jsx("span",{className:"w6w-server-resources__label",children:t}),e.jsx("span",{className:"w6w-server-resources__value",children:s}),e.jsx(Qe,{className:"w6w-server-resources__spark",values:n,max:a})]})}function it(t){const s=t[t.length-1],n=t.map(r=>be(r)),a=t.map(r=>ye(r)),i=t.map(r=>r.processRss);return{last:s,cpuValues:n,memoryValues:a,rssValues:i}}function xn({samples:t,title:s="Server resources",intervalMs:n}){const{last:a,cpuValues:i,memoryValues:r,rssValues:l}=it(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--card","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(Te,{label:"CPU",value:ie(be(a)),values:i,max:Oe(i)}),e.jsx(Te,{label:"Memory",value:ie(ye(a)),values:r,max:1}),e.jsx(Te,{label:"Process",value:Qt((a==null?void 0:a.processRss)??null),values:l,max:Oe(l)})]}),e.jsx("p",{className:"w6w-server-resources__meta",children:`Load ${Ye((a==null?void 0:a.load1)??null)} / ${Ye((a==null?void 0:a.load5)??null)} / ${Ye((a==null?void 0:a.load15)??null)}`}),n!==void 0&&e.jsx("p",{className:"w6w-server-resources__meta",children:`Sampled every ${n/1e3}s`})]})}function gn({samples:t,title:s="Server"}){const{last:n,cpuValues:a}=it(t);return e.jsxs("section",{className:"w6w-server-resources w6w-server-resources--small","aria-label":s,children:[e.jsx("h3",{className:"w6w-server-resources__title",children:s}),e.jsxs("ul",{className:"w6w-server-resources__rows",children:[e.jsx(Te,{label:"CPU",value:ie(be(n)),values:a,max:Oe(a)}),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:ie(ye(n))})]})]})]})}function vn({samples:t,onExpand:s}){const{last:n,cpuValues:a,memoryValues:i}=it(t);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:ie(be(n))}),e.jsx(Qe,{className:"w6w-server-resources__spark",values:a,max:Oe(a)})]}),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:ie(ye(n))}),e.jsx(Qe,{className:"w6w-server-resources__spark",values:i,max:1})]}),s!==void 0&&e.jsx("button",{type:"button",className:"w6w-server-resources__expand","aria-label":"Show server resources",onClick:s,children:"Details"})]})}function jn({samples:t}){const s=t[t.length-1],n=ie(be(s)),a=ie(ye(s));return e.jsx("span",{className:"w6w-server-resources w6w-server-resources--badge",children:`CPU ${n} · MEM ${a}`})}const bn=1,yn=1440*60*1e3;function Nn(t,s,n){const a=s.startedAt??s.updatedAt;if(a===void 0)return null;const i=Date.parse(a),r=s.resolvedAt!==void 0?Date.parse(s.resolvedAt):s.startedAt!==void 0?n:i,l=Date.parse(`${t.from}T00:00:00.000Z`),o=Date.parse(`${t.to}T00:00:00.000Z`)+yn,c=o-l;if(r<l||i>=o)return null;const d=i<l,m=r>o,f=Math.max(i,l),b=Math.min(r,o),w=(f-l)/c*100,p=(b-f)/c*100,v=Math.max(p,bn);return{leftPct:w,widthPct:v,clippedStart:d,clippedEnd:m}}const kn={ok:"Operational",degraded:"Degraded",down:"Down",unknown:"Unknown"},Sn="This vendor publishes no incident history.",Cn="No incidents in this window.";function En(t){const s=t.startedAt??t.updatedAt,n=[t.title];return t.components!==void 0&&t.components.length>0&&n.push(`(${t.components.join(", ")})`),s!==void 0&&n.push(t.resolvedAt!==void 0?`${s} – ${t.resolvedAt}`:`${s} – ongoing`),n.join(" ")}function Rn({window:t,days:s,incidents:n,vendorEmptyLabel:a,nowMs:i=Date.now(),ariaLabel:r}){const l=s.length,o=l>0?100/l:0,c=n===void 0?a??Sn:n.length===0?a??Cn:null;return e.jsx("div",{className:"w6w-history-timeline",role:"img","aria-label":r??`${l}-day history`,children:e.jsxs("div",{className:"w6w-history-plot",children:[e.jsx("div",{className:"w6w-history-lane w6w-history-lane-execution",children:s.map((d,m)=>e.jsx("span",{className:`w6w-history-cell w6w-history-cell-${d.state}`,style:{left:`${m*o}%`,width:`${o}%`},title:d.label??`${d.day} — ${kn[d.state]}`},`${d.day}-${m}`))}),e.jsx("div",{className:"w6w-history-lane w6w-history-lane-vendor",children:c!==null?e.jsx("span",{className:"w6w-history-empty",title:c,children:c}):n==null?void 0:n.map((d,m)=>{const f=Nn(t,d,i);if(f===null)return null;const b=[f.clippedStart?"w6w-history-bar-clip-start":"",f.clippedEnd?"w6w-history-bar-clip-end":""].filter(Boolean).join(" ");return e.jsx("span",{className:`w6w-history-bar w6w-history-bar-${d.state}${b?` ${b}`:""}`,style:{left:`${f.leftPct}%`,width:`${f.widthPct}%`},title:En(d)},d.id??`${d.title}-${m}`)})}),e.jsxs("div",{className:"w6w-history-axis",children:[e.jsx("span",{className:"w6w-history-tick w6w-history-tick-start",style:{left:"0%"},children:t.from}),e.jsx("span",{className:"w6w-history-tick w6w-history-tick-end",style:{left:"100%"},children:t.to})]})]})})}function An({label:t,children:s,className:n}){const[a,i]=g.useState(!1),r=g.useId();return e.jsxs("span",{className:["w6w-info-tip",n??""].filter(Boolean).join(" "),children:[e.jsx(h.IconButton,{label:t,icon:"info","aria-expanded":a,"aria-controls":r,onClick:()=>i(l=>!l)}),a&&e.jsx("span",{id:r,className:"w6w-info-tip-body w6w-muted w6w-small",children:s})]})}function Tn(t){const{label:s,onClick:n,disabled:a,className:i,...r}=t;return e.jsx(h.IconButton,{label:s,onClick:n,disabled:a,className:i,icon:"edit","data-testid":r["data-testid"]})}const Ee=4;function lt({actions:t,label:s="Actions",disabled:n,"data-testid":a}){const i=t.filter(x=>!!x),r=g.useRef(null),l=g.useRef(null),o=g.useId(),[c,d]=g.useState(!1),[m,f]=g.useState(null),[b,w]=g.useState(null),p=g.useCallback(x=>{var y;d(!1),w(null),x&&((y=r.current)==null||y.focus({preventScroll:!0}))},[]);if(g.useLayoutEffect(()=>{if(!c)return;const x=r.current,y=l.current;if(!x||!y)return;const N=x.getBoundingClientRect(),C=y.offsetWidth,k=y.offsetHeight,A=window.innerHeight||document.documentElement.clientHeight,E=N.bottom+Ee,P=E+k>A&&N.top-Ee-k>=0?N.top-Ee-k:E;w({top:P,left:Math.max(Ee,N.right-C)})},[c]),g.useEffect(()=>{var x,y;!c||!b||(y=(x=l.current)==null?void 0:x.querySelector("[role=menuitem]"))==null||y.focus({preventScroll:!0})},[c,b]),g.useEffect(()=>{if(!c)return;const x=k=>{var A,E;return k instanceof Node&&((A=l.current)==null?void 0:A.contains(k))||k instanceof Node&&((E=r.current)==null?void 0:E.contains(k))},y=k=>{x(k.target)||p(!1)},N=k=>{var A;k.target instanceof Node&&((A=l.current)!=null&&A.contains(k.target))||p(!1)},C=()=>p(!1);return document.addEventListener("pointerdown",y,!0),document.addEventListener("mousedown",y,!0),document.addEventListener("scroll",N,!0),window.addEventListener("resize",C),window.addEventListener("blur",C),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("mousedown",y,!0),document.removeEventListener("scroll",N,!0),window.removeEventListener("resize",C),window.removeEventListener("blur",C)}},[c,p]),i.length===0)return null;const v=x=>{x.disabled||(p(!0),x.onSelect())},u=()=>{var x;if(c){p(!1);return}f(((x=r.current)==null?void 0:x.closest("dialog"))??document.body),d(!0)};return e.jsxs("span",{className:"w6w-row-actions",onClick:x=>x.stopPropagation(),children:[e.jsx(h.IconButton,{ref:r,label:s,icon:"more-horizontal",onClick:u,disabled:n,className:"w6w-row-actions-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?o:void 0,"data-testid":a}),c&&m&&nn.createPortal(e.jsx("div",{ref:l,id:o,className:"w6w-row-menu",role:"menu","aria-label":s,style:b?{top:b.top,left:b.left}:{top:0,left:0,visibility:"hidden"},onClick:x=>x.stopPropagation(),onKeyDown:x=>{var k;x.stopPropagation();const y=[...((k=l.current)==null?void 0:k.querySelectorAll("[role=menuitem]"))??[]],N=y.indexOf(document.activeElement),C=A=>{var E;return(E=y[(A+y.length)%y.length])==null?void 0:E.focus()};if(x.key==="ArrowDown")C(N+1);else if(x.key==="ArrowUp")C(N<0?-1:N-1);else if(x.key==="Home")C(0);else if(x.key==="End")C(-1);else if(x.key==="Escape")p(!0);else if(x.key==="Tab")p(!1);else if(x.key==="Enter"||x.key===" ")N>=0&&v(i[N]);else return;x.preventDefault()},children:i.map(x=>e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,"aria-disabled":x.disabled||void 0,className:`w6w-row-menu-item${x.danger?" w6w-row-menu-item-danger":""}`,"data-testid":x["data-testid"],onClick:()=>v(x),children:[x.icon&&e.jsx(B.Icon,{name:x.icon,size:14}),e.jsx("span",{children:x.label})]},x.label))}),m)]})}function $n(t){const{branch:s,shortSha:n,lastSyncLabel:a,onSyncNow:i,syncing:r,className:l,...o}=t,[c,d]=g.useState(!1),m=g.useRef(null);return g.useEffect(()=>{if(!c)return;const f=w=>{m.current&&!m.current.contains(w.target)&&d(!1)},b=w=>w.key==="Escape"&&d(!1);return document.addEventListener("mousedown",f),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",b)}},[c]),e.jsxs("div",{className:`w6w-repo-sync${l?` ${l}`:""}`,ref:m,"data-testid":o["data-testid"],children:[e.jsxs("button",{type:"button",className:"w6w-repo-sync-trigger","aria-haspopup":"menu","aria-expanded":c,"aria-busy":r,onClick:()=>d(f=>!f),children:[e.jsxs("span",{className:"w6w-repo-sync-icon",children:[e.jsx(B.Icon,{name:"github"}),r&&e.jsx(B.Icon,{name:"sync",size:10,className:"w6w-repo-sync-spin"})]}),e.jsx("span",{className:"w6w-repo-sync-branch",children:s}),n!=null&&e.jsx("code",{className:"w6w-repo-sync-sha",children:n})]}),c&&e.jsxs("div",{className:"w6w-repo-sync-menu",role:"menu",children:[e.jsxs("div",{className:"w6w-repo-sync-detail",children:[e.jsx("span",{children:s}),n!=null&&e.jsx("code",{children:n}),a!=null&&e.jsx("span",{children:a})]}),e.jsx("button",{type:"button",role:"menuitem",className:"w6w-repo-sync-item","data-testid":"repo-sync-now",disabled:r,onClick:i,children:r?"Syncing…":"Sync now"})]})]})}const _n={pending:"Pending",running:"Running",succeeded:"Succeeded",failed:"Failed",skipped:"Skipped",queued:"Queued",canceled:"Canceled"};function Pe({state:t,label:s,ariaLabel:n}){const a=s??_n[t];return e.jsxs("span",{className:`w6w-step-pill w6w-step-pill-${t}`,"aria-label":n,children:[e.jsx("span",{className:"w6w-step-pill-dot","aria-hidden":"true"}),e.jsx("span",{className:"w6w-step-pill-label",children:a})]})}const On="—",ze=1e3,Ge=6e4;function Me(t){return t==null||!Number.isFinite(t)||t<0?On:t<ze?`${Math.round(t)} ms`:t<Ge?`${(t/ze).toFixed(1)} s`:`${Math.floor(t/Ge)}m ${Math.round(t%Ge/ze)}s`}function je(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}const In={function:"Function",endpoint:"Endpoint",workflow:"Workflow"},Ln={manual:"Manual",schedule:"Schedule",webhook:"Webhook",event:"Event",replay:"Replay"};function _t(t){if(!t.trigger)return null;const s=Ln[t.trigger]??t.trigger;return t.triggerNodeId?`${s} · ${t.triggerNodeId}`:s}function Pn({items:t,selectedId:s=null,onSelect:n,showCallable:a=!1,loading:i=!1,emptyLabel:r,hasPrev:l,hasNext:o,onPrev:c,onNext:d,onRerun:m,rerunningId:f=null}){const b=c||d?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:!l,onClick:c,children:"Previous"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-list-next",disabled:!o,onClick:d,children:"Next"})]}):null;let w;return i&&t.length===0?w=e.jsx("p",{"data-testid":"execution-list-loading",children:"Loading…"}):t.length===0?w=e.jsx("p",{"data-testid":"execution-list-empty",children:r??"No executions yet."}):w=e.jsx("ul",{className:"w6w-execution-list-rows",children:t.map(p=>e.jsxs("li",{"data-testid":"execution-row","data-execution-id":p.id,children:[e.jsx(_e,{icon:e.jsx(Pe,{state:p.status}),title:e.jsxs(e.Fragment,{children:[a?p.callableName:je(p.startedAt),p.rerunOf&&e.jsx("span",{className:"w6w-execution-rerun-tag","data-testid":"execution-row-rerun-tag",title:`Re-run of ${p.rerunOf}`,children:"Re-run"})]}),subtitle:e.jsxs(e.Fragment,{children:[a?`${In[p.kind]} · ${je(p.startedAt)}`:p.id,_t(p)&&e.jsx("span",{className:"w6w-execution-trigger","data-testid":"execution-row-trigger",children:` · ${_t(p)}`}),p.inputPreview&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{className:"w6w-execution-input-preview","data-testid":"execution-row-input",title:p.inputPreview,children:p.inputPreview})]})]}),trailing:Me(p.durationMs),active:p.id===s,onClick:n?()=>n(p.id):void 0}),m&&e.jsx(h.IconButton,{icon:"sync",label:"Re-run",title:p.id===f?"Re-running…":"Re-run with the same input",className:"w6w-execution-list-rerun","data-testid":"execution-row-rerun",disabled:f!==null,onClick:()=>m(p.id)})]},p.id))}),e.jsxs("div",{className:"w6w-execution-list","data-testid":"execution-list",children:[w,b]})}function Mn(t){const s=h.internalNodeDef(t.app,t.action);return{trigger:t.trigger===!0||(s==null?void 0:s.group)==="trigger",appName:t.appName??(s==null?void 0:s.displayName)??t.app,actionName:t.actionName??(s==null?void 0:s.label)??t.action}}function es(t){const s=n=>{for(const a of[n.startedAt,n.finishedAt]){const i=Date.parse(a??"");if(Number.isFinite(i))return i}return Number.POSITIVE_INFINITY};return t.map(n=>({step:n,time:s(n)})).sort((n,a)=>n.time===a.time?0:n.time-a.time).map(({step:n})=>n)}function ts({steps:t,emptyLabel:s,onDismiss:n,runError:a,stepErrors:i}){const r=n?e.jsx("div",{className:"w6w-execution-log-head",children:e.jsx(h.IconButton,{label:"Dismiss run log","data-testid":"execution-log-dismiss",onClick:n,children:"×"})}):null,l=i??[],o=a||l.length>0?e.jsxs("div",{className:"w6w-execution-log-errors w6w-stack",children:[a&&e.jsx(et,{error:a}),l.map((f,b)=>e.jsx(et,{label:f.label??f.stepId,error:f.error},`${f.stepId}:${b}`))]}):null,c=es(t.filter(f=>!Ot(f))),d=t.filter(Ot),m=d.length>0?e.jsx(Fn,{steps:d}):null;return c.length===0?e.jsxs(e.Fragment,{children:[r,o,e.jsx("div",{className:"w6w-execution-log-empty",children:e.jsx("p",{className:"w6w-muted w6w-small",children:s??"No nodes have run yet."})}),m]}):e.jsxs(e.Fragment,{children:[r,o,e.jsx("ol",{className:"w6w-execution-log",children:c.map(f=>e.jsx(ss,{step:f},f.id))}),m]})}const Ot=t=>t.status==="skipped"&&t.skipReason==="not_on_path",Dn={condition:"condition false",stopped:"run stopped",disabled:"disabled"};function Fn({steps:t}){const s=t.length;return e.jsxs("details",{className:"w6w-execution-log-off-path","data-testid":"execution-log-off-path",children:[e.jsx("summary",{className:"w6w-muted w6w-small",children:`${s} ${s===1?"step":"steps"} on other paths, not part of this run`}),e.jsx("ul",{className:"w6w-muted w6w-small",children:t.map(n=>e.jsx("li",{children:n.label??n.id},n.id))})]})}function ss({step:t,defaultOpen:s=!1}){var d,m;const[n,a]=g.useState(s),i=t.node?Mn(t.node):null,r=e.jsxs("div",{className:"w6w-execution-log-row-header",children:[e.jsx(Pe,{state:t.status}),i&&e.jsx("span",{className:`w6w-execution-log-kind${i.trigger?" w6w-execution-log-kind-trigger":""}`,"data-testid":"execution-log-kind",children:i.trigger?"Trigger":"Node"}),e.jsxs("span",{className:"w6w-execution-log-row-title",children:[e.jsx("span",{className:"w6w-execution-log-row-label",children:t.label??t.id}),i&&e.jsx("span",{className:"w6w-execution-log-row-uses","data-testid":"execution-log-uses",children:i.appName===i.actionName?i.appName:`${i.appName} · ${i.actionName}`})]}),t.status==="skipped"&&t.skipReason&&t.skipReason!=="not_on_path"&&e.jsx("span",{className:"w6w-execution-log-skip-reason","data-testid":"execution-log-skip-reason",children:Dn[t.skipReason]}),e.jsx(Wn,{startedAt:t.startedAt,finishedAt:t.finishedAt})]}),l=t.error?e.jsx(et,{error:t.error}):null,o=Array.isArray(t.iterations)?e.jsx(Bn,{step:t}):null,c=qn(t)?e.jsx(Hn,{step:t}):null;return t.input===void 0&&t.output===void 0&&!t.meta&&!c&&!((d=t.logs)!=null&&d.length)?e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsx("div",{className:"w6w-section",children:r}),l,o]}):e.jsxs("li",{className:"w6w-execution-log-row",children:[e.jsxs("details",{className:"w6w-section",open:n,onToggle:f=>a(f.currentTarget.open),children:[e.jsx("summary",{className:"w6w-section-summary",children:r}),n&&e.jsxs("div",{className:"w6w-execution-log-row-body w6w-section-body w6w-stack",children:[e.jsx(Kn,{input:t.input}),e.jsx(It,{title:"Input",value:t.input,defaultOpen:s}),e.jsx(It,{title:"Output",value:t.output,defaultOpen:s}),!!((m=t.logs)!=null&&m.length)&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Console"}),e.jsx(B.CodeBlock,{code:t.logs.join(`
2
+ `),language:"plaintext"})]}),t.meta&&e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:"Metadata"}),e.jsx(B.CodeBlock,{code:JSON.stringify(t.meta,null,2),language:"json"})]}),c]})]}),l,o]})}function Bn({step:t}){var p,v;const s=[...t.iterations??[]].sort((u,x)=>u.index-x.index),n=t.iterationsTotal??s.length,a=t.iterationsFailed??s.filter(u=>u.status==="failed").length,i=s.find(u=>u.status==="failed"),r=(i==null?void 0:i.index)??((p=s[s.length-1])==null?void 0:p.index),[l,o]=g.useState(r),[c,d]=g.useState(!1),m=s.find(u=>u.index===l),f=[],b=new Map;for(const u of es(s.flatMap(x=>x.steps)))b.has(u.id)||(f.push(u.id),b.set(u.id,u.label??u.id));const w=(i==null?void 0:i.failedNodeId)??((v=i==null?void 0:i.steps.find(u=>u.status==="failed"))==null?void 0:v.id);return e.jsxs("div",{className:"w6w-execution-log-foreach w6w-stack",children:[e.jsxs("div",{className:"w6w-small","data-testid":"execution-log-foreach-summary",children:[e.jsxs("span",{children:[n===1?"1 item":`${n} items`,a>0?` · ${a} failed`:""]}),i&&w!==void 0&&e.jsxs("div",{children:[b.get(w)??w," failed in iteration ",i.index]}),t.iterationsTruncated===!0&&e.jsx("div",{className:"w6w-muted",children:`showing ${s.length} of ${n}`})]}),e.jsx("div",{className:"w6w-execution-log-iteration-chips",children:s.map(u=>e.jsxs("button",{type:"button",className:`w6w-execution-log-iteration-chip w6w-execution-log-iteration-chip-${u.status}`,"data-testid":"execution-log-iteration-chip","data-status":u.status,"aria-pressed":l===u.index,title:`Show iteration ${u.index}'s input and output`,onClick:()=>{o(u.index),d(!0)},children:[u.index," · ",u.status]},u.index))}),m&&e.jsx("div",{className:"w6w-small w6w-muted","data-testid":"execution-log-iteration-current",children:`Iteration ${m.index} · ${m.status}`}),e.jsx("ul",{className:"w6w-execution-log-subrows",children:f.map(u=>e.jsx(Un,{id:u,label:b.get(u)??u,iterations:s,selected:l,open:c,onSelect:o},u))})]})}function Un({id:t,label:s,iterations:n,selected:a,open:i,onSelect:r}){var o;const l=(o=n.find(c=>c.index===a))==null?void 0:o.steps.find(c=>c.id===t);return e.jsxs("li",{className:"w6w-execution-log-subrow w6w-stack",children:[e.jsxs("div",{className:"w6w-execution-log-subrow-head",children:[e.jsx("strong",{className:"w6w-small",children:s}),e.jsx("select",{className:"w6w-select","aria-label":`Iteration for ${s}`,"data-testid":"execution-log-iteration-select",value:a===void 0?"":String(a),onChange:c=>r(Number(c.currentTarget.value)),children:n.map(c=>e.jsx("option",{value:String(c.index),children:`iteration ${c.index} (${c.status})`},c.index))})]}),l?e.jsx("ol",{className:"w6w-execution-log",children:e.jsx(ss,{step:l,defaultOpen:i},`${a}:${i}`)}):e.jsx("p",{className:"w6w-muted w6w-small",children:"Did not run in this iteration."})]})}function et({error:t,label:s}){return e.jsxs("div",{className:"w6w-result w6w-error",children:[s!==void 0&&e.jsx("strong",{className:"w6w-execution-log-error-label",children:s}),t.code&&e.jsx("div",{className:"w6w-small w6w-execution-log-error-code",children:e.jsx("code",{children:t.code})}),t.message]})}function Wn({startedAt:t,finishedAt:s}){if(t&&s){const n=Vn(t,s);return e.jsxs("span",{className:"w6w-execution-log-timing",children:[t," → ",s,n&&e.jsxs("span",{children:[" (",n,")"]})]})}return t?e.jsxs("span",{className:"w6w-execution-log-timing",children:["Started ",t]}):e.jsx("span",{className:"w6w-execution-log-timing",children:"—"})}function Vn(t,s){const n=Date.parse(t),a=Date.parse(s);if(!Number.isFinite(n)||!Number.isFinite(a)||a<n)return null;const i=a-n;if(i<1e3)return`${i}ms`;const r=i/1e3;if(r<60)return`${r.toFixed(1)}s`;const l=Math.floor(r/60),o=Math.round(r%60);return`${l}m ${o}s`}function It({title:t,value:s,defaultOpen:n=!1}){const[a,i]=g.useState(n);return s===void 0?e.jsxs("div",{className:"w6w-execution-log-json w6w-stack",children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Not available."})]}):e.jsxs("details",{className:"w6w-execution-log-json",open:a,onToggle:r=>{r.target===r.currentTarget&&i(r.currentTarget.open)},children:[e.jsx("summary",{children:e.jsx("strong",{className:"w6w-small",children:t})}),a&&e.jsx(h.ResultViewer,{value:s,format:"json"})]})}const Ie=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function Lt(t){if(!Ie(t)||!Array.isArray(t.conditions))return;const s=t.conditions.filter(n=>Ie(n)&&typeof n.op=="string"&&"result"in n);if(s.length!==0)return{rows:s,combinator:typeof t.combinator=="string"?t.combinator:void 0,result:typeof t.condition=="boolean"?t.condition:void 0}}function Kn({input:t}){const s=[],n=Lt(t);if(n&&s.push({trace:n}),Ie(t)&&Array.isArray(t.routes))for(const a of t.routes){const i=Lt(a);!i||!Ie(a)||s.push({title:String(a.label??a.id??"Route"),trace:i})}return s.length===0?null:e.jsxs("div",{className:"w6w-execution-log-json w6w-stack","data-testid":"execution-log-conditions",children:[e.jsx("strong",{className:"w6w-small",children:"Condition"}),s.map(({title:a,trace:i},r)=>e.jsxs("div",{className:"w6w-stack",children:[a&&e.jsx("span",{className:"w6w-small w6w-muted",children:a}),(i.combinator&&i.rows.length>1||i.result!==void 0)&&e.jsxs("span",{className:"w6w-small w6w-muted","data-testid":"execution-log-condition-summary",children:[i.combinator&&i.rows.length>1&&h.conditionCombinatorLabel(i.combinator),i.combinator&&i.rows.length>1&&i.result!==void 0&&" · ",i.result!==void 0&&e.jsxs(e.Fragment,{children:["Result:"," ",e.jsx("span",{className:i.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:i.result?"true":"false"})]})]}),e.jsx("div",{className:"w6w-data-table-frame",children:e.jsxs("table",{className:"w6w-data-table w6w-execution-log-conditions",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Left"}),e.jsx("th",{children:"Operator"}),e.jsx("th",{children:"Right"}),e.jsx("th",{children:"Result"})]})}),e.jsx("tbody",{children:i.rows.map((l,o)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{children:Pt(l.left)})}),e.jsx("td",{children:h.conditionOperatorLabel(l.op)}),e.jsx("td",{children:e.jsx("code",{children:Pt(l.right)})}),e.jsx("td",{className:l.result?"w6w-execution-log-condition-true":"w6w-execution-log-condition-false",children:l.result?"true":"false"})]},o))})]})})]},a??r))]})}function Pt(t){return JSON.stringify(t)??"undefined"}const Mt={not_object:"Not written — the output isn't an object, so it can't be merged at the root",missing_source:"Not written — the output has no value at that field",null_append:"Not appended — the value was null",append_not_array:"Not appended — the existing value isn't a list",write_too_large:"Not written — the value is too large",run_too_large:"Not written — the run's state would grow past its size limit",too_deep:"Not written — the value is nested too deeply",key_too_long:"Not written — a key in the value is too long",forbidden_key:"Not written — the value uses a reserved key name",log_truncated:"Later state changes aren't shown — the run's state log reached its limit"};function Jn(t){return Object.hasOwn(Mt,t)?Mt[t]:t}function qn(t){const s=Array.isArray(t.stateWrites)&&t.stateWrites.length>0,n=t.stateAfter;return s||typeof n=="object"&&n!==null&&Object.keys(n).length>0}const Dt=120;function Ft(t){if(t===void 0)return"(not set)";const s=JSON.stringify(t)??String(t);return s.length>Dt?`${s.slice(0,Dt)}…`:s}function Hn({step:t}){const s=Array.isArray(t.stateWrites)?t.stateWrites:[],n=t.stateAfter;return e.jsxs("div",{className:"w6w-execution-log-state w6w-stack","data-testid":"execution-log-state",children:[e.jsx("strong",{className:"w6w-small",children:"State"}),s.length>0&&e.jsx("ul",{className:"w6w-execution-log-state-writes",children:s.map((a,i)=>{const r=Array.isArray(a.path)?a.path:[],l=`state${r.length?`.${r.join(".")}`:""}${a.item!==void 0?` (item ${a.item})`:""}`;return a.warning!==void 0?e.jsx("li",{className:"w6w-execution-log-state-write w6w-execution-log-state-warning w6w-small","data-testid":"execution-log-state-write","data-warning":a.warning,children:`${l}: ${Jn(a.warning)}`},i):e.jsx("li",{className:"w6w-execution-log-state-write w6w-small","data-testid":"execution-log-state-write",children:`${l}: ${Ft(a.old)} → ${Ft(a.new)}`},i)})}),typeof n=="object"&&n!==null&&e.jsxs("div",{className:"w6w-stack","data-testid":"execution-log-state-after",children:[e.jsx("span",{className:"w6w-small w6w-muted",children:"State after this step"}),e.jsx(B.CodeBlock,{code:JSON.stringify(n,null,2),language:"json"})]})]})}const Yn={status:"",kind:"",from:"",to:"",q:""},zn=[{value:"",label:"Any status"},{value:"queued",label:"Queued"},{value:"running",label:"Running"},{value:"succeeded",label:"Succeeded"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}],Gn=[{value:"",label:"Any type"},{value:"function",label:"Function"},{value:"endpoint",label:"Endpoint"},{value:"workflow",label:"Workflow"}];function Xn({value:t,onChange:s,showKind:n=!1,searchPlaceholder:a="Search by id or name",disabled:i=!1}){const r=t.status!==""||t.kind!==""||t.from!==""||t.to!==""||t.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:a,value:t.q,disabled:i,onChange:l=>s({...t,q:l.target.value})}),e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-status","aria-label":"Status",value:t.status,disabled:i,onChange:l=>s({...t,status:l.target.value}),children:zn.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))}),n&&e.jsx("select",{className:"w6w-execution-filters-select","data-testid":"execution-filter-kind","aria-label":"Type",value:t.kind,disabled:i,onChange:l=>s({...t,kind:l.target.value}),children:Gn.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-from","aria-label":"From date",value:t.from,disabled:i,onChange:l=>s({...t,from:l.target.value})}),e.jsx("input",{type:"date",className:"w6w-execution-filters-date","data-testid":"execution-filter-to","aria-label":"To date",value:t.to,disabled:i,onChange:l=>s({...t,to:l.target.value})}),r&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-execution-filters-clear","data-testid":"execution-filter-clear",disabled:i,onClick:()=>s({...Yn}),children:"Clear"})]})}const $e="—";function Zn({stats:t,label:s}){const n=[{testid:"execution-stat-total",label:"Executions",value:t?String(t.total):$e},{testid:"execution-stat-success-rate",label:"Success rate",value:Qn(t==null?void 0:t.successRate)},{testid:"execution-stat-failed",label:"Failed",value:t?String(t.failed):$e},{testid:"execution-stat-avg-duration",label:"Avg duration",value:t?Me(t.avgDurationMs):$e}];return t&&t.inFlight>0&&n.push({testid:"execution-stat-in-flight",label:"In flight",value:String(t.inFlight)}),e.jsxs("section",{className:"w6w-execution-stats","data-testid":"execution-stats",children:[s!=null&&e.jsx("p",{className:"w6w-execution-stats-label",children:s}),e.jsx("div",{className:"w6w-execution-stats-cards",children:n.map(a=>e.jsxs("div",{className:"w6w-execution-stat","data-testid":a.testid,children:[e.jsx("span",{className:"w6w-execution-stat-value","data-stat-value":a.value,children:a.value}),e.jsx("span",{className:"w6w-execution-stat-label",children:a.label})]},a.testid))})]})}function Qn(t){return t==null||!Number.isFinite(t)?$e:`${Math.round(t*100)}%`}const ea={function:"Function",endpoint:"Endpoint",workflow:"Workflow"};function ta(t){return JSON.stringify(t,null,2)??"null"}function sa({execution:t,loading:s=!1,errorMessage:n,onClose:a,onOpenInEditor:i,onBack:r,onRerun:l,rerunning:o=!1,onOpenExecution:c}){return e.jsxs("section",{className:"w6w-execution-detail w6w-stack","data-testid":"execution-detail",children:[r&&e.jsx("div",{className:"w6w-execution-detail-back",children:e.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"execution-detail-back",onClick:r,children:[e.jsx("span",{"aria-hidden":"true",children:"←"})," Back"]})}),n!=null&&e.jsx("p",{role:"alert",className:"w6w-execution-detail-error-message","data-testid":"execution-detail-error-message",children:n}),t?e.jsx(na,{execution:t,onClose:a,onOpenInEditor:i,onRerun:l,rerunning:o,onOpenExecution:c}):s?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 na({execution:t,onClose:s,onOpenInEditor:n,onRerun:a,rerunning:i,onOpenExecution:r}){const l=t.rerunOf;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:t.callableName}),e.jsxs("div",{className:"w6w-execution-detail-meta",children:[e.jsx(Pe,{state:t.status}),e.jsx("span",{className:"w6w-execution-detail-kind w6w-muted w6w-small",children:ea[t.kind]})]})]}),(a||n||s)&&e.jsxs("div",{className:"w6w-execution-detail-actions",children:[a&&e.jsxs("button",{type:"button",className:"w6w-btn w6w-execution-detail-rerun","data-testid":"execution-detail-rerun",title:"Run it again with the same input",disabled:i,onClick:a,children:[e.jsx(B.Icon,{name:"sync",size:14})," ",i?"Re-running…":"Re-run"]}),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"}),s&&e.jsx(h.IconButton,{label:"Close","data-testid":"execution-detail-close",onClick:s,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:t.id})}),l&&e.jsxs("p",{className:"w6w-execution-detail-rerun-of","data-testid":"execution-detail-rerun-of",children:[e.jsx("span",{className:"w6w-execution-rerun-tag",children:"Re-run"}),e.jsx("span",{className:"w6w-muted w6w-small",children:"of"}),r?e.jsx("button",{type:"button",className:"w6w-execution-detail-rerun-of-link","data-testid":"execution-detail-rerun-of-link",onClick:()=>r(l),children:e.jsx("code",{children:l})}):e.jsx("code",{children:l})]}),e.jsxs("dl",{className:"w6w-execution-detail-timing",children:[e.jsx(Xe,{label:"Started",value:je(t.startedAt)}),e.jsx(Xe,{label:"Finished",value:t.finishedAt?je(t.finishedAt):"—"}),e.jsx(Xe,{label:"Duration",value:Me(t.durationMs)})]}),t.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:"Nodes"}),e.jsx(ts,{steps:t.steps,emptyLabel:"No nodes ran."})]}),t.input!==void 0&&e.jsx(Ze,{title:"Input",testid:"execution-detail-input",value:t.input}),t.output!==void 0&&e.jsx(Ze,{title:"Output",testid:"execution-detail-output",value:t.output}),t.error!=null&&e.jsx(Ze,{title:"Error",testid:"execution-detail-error",value:t.error})]})}function Xe({label:t,value:s}){return e.jsxs("div",{className:"w6w-execution-detail-timing-item",children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ze({title:t,testid:s,value:n}){return e.jsxs("section",{className:"w6w-execution-detail-section w6w-stack","data-testid":s,children:[e.jsx("strong",{className:"w6w-small",children:t}),e.jsx(B.CodeBlock,{code:ta(n),language:"json"})]})}function ns(t){const s=[];for(const n of t)n.p95Ms!==null&&s.push({appId:n.appId,displayName:n.displayName,calls:n.calls,p95Ms:n.p95Ms,state:n.state,errorCount:n.errors.e4xx+n.errors.e429+n.errors.eAuth+n.errors.e5xx});return s}function aa(t){return t.attention==="now"||t.attention==="recent"}function as(t){const s={now:[],recent:[],clear:[]};for(const n of t)n.attention==="now"?s.now.push(n):n.attention==="recent"?s.recent.push(n):s.clear.push(n);return s}function is(t){return t.uptime.map(s=>({day:s.day,state:s.state}))}const tt=3,ls=5;function rs(t,s={}){const n=s.compact??!1,{now:a,recent:i}=as(t),r=a.length+i.length,l=n?a.slice(0,tt):a,o=n?i.slice(0,Math.max(0,tt-l.length)):i,c=n?t.slice(0,s.limit??ls):[...t];return{attentionCount:r,shownNow:l,shownRecent:o,hiddenAttentionCount:r-l.length-o.length,shownTable:c,hiddenTableCount:t.length-c.length}}const Re=640,xe=340,z={top:16,right:24,bottom:40,left:56};function Bt(t){if(t<=0)return 1;const s=10**Math.floor(Math.log10(t)),n=[1,2,5,10];for(const a of n)if(t<=a*s)return a*s;return 10*s}function Ut(t,s=5){return Array.from({length:s+1},(n,a)=>Math.round(t*a/s))}function os({services:t,getHref:s,onOpen:n}){const a=ns(t);if(a.length===0)return e.jsx("p",{className:"w6w-muted w6w-small",children:"No timed calls in this window yet."});const i=Bt(Math.max(...a.map(u=>u.calls))),r=Bt(Math.max(...a.map(u=>u.p95Ms))),l=Math.max(1,...a.map(u=>u.errorCount)),o=Re-z.left-z.right,c=xe-z.top-z.bottom,d=u=>z.left+u/i*o,m=u=>z.top+u/r*c,f=u=>16+u/l*14,b=Ut(i),w=Ut(r),p=18,v=z.top+c/2;return e.jsxs("div",{className:"w6w-rel-scatter",children:[e.jsxs("svg",{viewBox:`0 0 ${Re} ${xe}`,style:{aspectRatio:`${Re} / ${xe}`},role:"img","aria-label":"API performance: calls versus p95 latency, one point per API",children:[e.jsx("rect",{x:z.left,y:z.top,width:o,height:c,className:"w6w-rel-scatter-plot-bg"}),w.map(u=>e.jsxs("g",{children:[e.jsx("line",{x1:z.left,x2:Re-z.right,y1:m(u),y2:m(u),className:"w6w-rel-scatter-grid"}),e.jsx("text",{x:z.left-8,y:m(u),className:"w6w-rel-scatter-axis-label",textAnchor:"end",children:u})]},`y-${u}`)),b.map(u=>e.jsx("text",{x:d(u),y:xe-z.bottom+18,className:"w6w-rel-scatter-axis-label",textAnchor:"middle",children:u},`x-${u}`)),e.jsx("text",{x:p,y:v,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",transform:`rotate(-90, ${p}, ${v})`,children:"p95 (ms)"}),e.jsx("text",{x:z.left+o/2,y:xe-4,className:"w6w-rel-scatter-axis-title",textAnchor:"middle",children:"calls in this window"}),a.map(u=>{const x=f(u.errorCount),y=d(u.calls),N=m(u.p95Ms),C=e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:y,cy:N,r:x/2+2.5,className:`w6w-rel-scatter-ring w6w-rel-scatter-ring-${u.state}`,children:e.jsxs("title",{children:[u.displayName," — ",u.calls," calls, ",u.p95Ms," ms p95, ",u.errorCount," errors"]})}),e.jsx("circle",{cx:y,cy:N,r:x/2,className:`w6w-rel-scatter-point w6w-rel-scatter-point-${u.state}`})]});return s?e.jsx("a",{href:s(u.appId),className:"w6w-rel-scatter-point-link",onClick:n?k=>n(u.appId,k):void 0,children:C},u.appId):n?e.jsx("g",{role:"button",tabIndex:0,className:"w6w-rel-scatter-point-link",onClick:k=>n(u.appId,k),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.currentTarget.dispatchEvent(new MouseEvent("click",{bubbles:!0})))},children:C},u.appId):e.jsx("g",{children:C},u.appId)})]}),e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-scatter-note",children:"Up is faster, right is more calls — top-right is the best outcome. Icon size is the error count in this window; ring colour is exec status."})]})}function Wt(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function cs({appId:t,className:s,title:n,getHref:a,onOpen:i,children:r}){return a?e.jsx("a",{className:s,href:a(t),title:n,onClick:i?l=>i(t,l):void 0,children:r}):i?e.jsx("button",{type:"button",className:s,title:n,onClick:l=>i(t,l),children:r}):e.jsx("div",{className:s,title:n,children:r})}function ds({service:t}){return e.jsxs("span",{className:"w6w-rel-signal",children:[e.jsx(Le,{state:t.state}),t.ongoingOutageId&&e.jsx("span",{className:"w6w-rel-tag",children:"outage open"}),t.calls===0&&e.jsx("span",{className:"w6w-muted w6w-small",children:"no calls"})]})}function us({vendor:t}){if(!t)return e.jsx("span",{className:"w6w-muted w6w-small",children:"not published"});const s=t.state==="unknown";return e.jsxs("span",{className:"w6w-rel-signal",title:t.message??void 0,children:[e.jsx(Le,{state:t.state,label:s?"Unavailable":void 0}),!s&&t.message&&e.jsx("span",{className:"w6w-rel-vendor-msg w6w-small",children:t.message})]})}function ia({service:t,getHref:s,onOpen:n}){return e.jsxs(cs,{appId:t.appId,className:"w6w-rel-issue-card",title:`${t.displayName} — open service detail`,getHref:s,onOpen:n,children:[e.jsxs("span",{className:"w6w-rel-issue-head",children:[e.jsx(h.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:24}),e.jsxs("span",{className:"w6w-rel-issue-head-text",children:[e.jsx("strong",{children:t.displayName}),t.attention==="recent"&&e.jsx("span",{className:"w6w-muted w6w-small",children:"trouble earlier in this window"})]})]}),e.jsxs("span",{className:"w6w-rel-issue-signals",children:[e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"w6w exec"}),e.jsx(ds,{service:t})]}),e.jsxs("span",{className:"w6w-rel-issue-signal",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:"API status"}),e.jsx(us,{vendor:t.vendorStatus})]})]})]})}function la({service:t,getHref:s,onOpen:n}){const a=t.calls===0;return e.jsxs("tr",{className:`w6w-rel-tr${t.attention!=="none"?" w6w-rel-attention":""}`,"data-attention":t.attention==="none"?void 0:t.attention,children:[e.jsx("td",{className:"w6w-rel-td-service",children:e.jsxs(cs,{appId:t.appId,className:"w6w-rel-open",getHref:s,onOpen:n,children:[e.jsx(h.AppIcon,{src:t.iconSrc,srcDark:t.iconSrcDark,brandColor:t.brandColor,name:t.displayName,size:28}),e.jsxs("span",{className:"w6w-rel-td-service-text",children:[e.jsx("strong",{children:t.displayName}),e.jsx("code",{className:"w6w-muted w6w-small",children:t.appId})]})]})}),e.jsxs("td",{className:"w6w-rel-td-status",children:[e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"Ops"}),e.jsx(ds,{service:t})]}),e.jsxs("span",{className:"w6w-rel-status-row",children:[e.jsx("span",{className:"w6w-rel-status-label w6w-muted w6w-small",children:"API"}),e.jsx(us,{vendor:t.vendorStatus})]})]}),e.jsx("td",{className:"w6w-rel-td-uptime",children:a?e.jsx("span",{className:"w6w-rel-idle-note",children:"No calls in this window"}):e.jsxs(e.Fragment,{children:[e.jsx(Xt,{days:is(t),ariaLabel:`${t.displayName}, ${t.uptime.length}-day status, oldest day first`}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[t.calls," calls"]})]})}),e.jsx("td",{className:"w6w-rel-td-p95",children:t.p95Ms===null?"—":`${t.p95Ms} ms`})]})}function ra({services:t,window:s,days:n,compact:a=!1,showChart:i,limit:r,getHref:l,onOpen:o,showAllHref:c,onShowAll:d,slots:m}){const f=n??(s==null?void 0:s.days)??30,b=t.length>0&&t.every(A=>A.calls>0&&A.state==="ok"),{attentionCount:w,shownNow:p,shownRecent:v,hiddenAttentionCount:u,shownTable:x,hiddenTableCount:y}=rs(t,{compact:a,limit:r}),N=i??!a,C=c!==void 0||d!==void 0,k=A=>{const E=A.startsWith("Show")?"w6w-muted w6w-small":void 0;return c!==void 0?e.jsx("a",{href:c,className:E,onClick:d,children:A}):d?e.jsx("button",{type:"button",className:`w6w-rel-show-all${E?` ${E}`:""}`,onClick:d,children:A}):null};return e.jsxs("section",{className:"w6w-rel-section",children:[e.jsxs("h3",{className:"w6w-rel-heading",children:[e.jsxs("span",{children:[(m==null?void 0:m.header)??"Service reliability"," ",s&&e.jsxs("span",{className:"w6w-muted w6w-small",children:[Wt(s.from)," – ",Wt(s.to)," · ",s.days," days"]})]}),a&&k("Show all services →"),m==null?void 0:m.actions]}),e.jsxs("div",{className:a?"w6w-rel-card":void 0,children:[e.jsx("p",{className:"w6w-muted w6w-small w6w-rel-intro",children:"Connected services across your account. Performance for the selected project."}),b&&e.jsxs("div",{className:a?"w6w-rel-allclear":"w6w-rel-card w6w-rel-allclear",children:[e.jsx("h4",{children:"All clear"}),e.jsxs("p",{children:["Every service you called in the last ",f," days came back"," ",e.jsx(Le,{state:"ok"})," — no degraded stretches, no outages."]})]}),t.length===0&&((m==null?void 0:m.empty)??e.jsx("div",{className:a?void 0:"w6w-rel-card",children:e.jsx("p",{className:"w6w-muted",children:"No services yet — connect an integration or use a service in this project."})})),t.length>0&&e.jsxs(e.Fragment,{children:[w>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:["Needs attention"," ",e.jsxs("span",{className:"w6w-muted w6w-small",children:[p.length+v.length," of ",w]})]}),e.jsx("div",{className:"w6w-rel-issues",children:[...p,...v].map(A=>e.jsx(ia,{service:A,getHref:l,onOpen:o},A.appId))}),u>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[u," more ",u===1?"needs":"need"," ","attention",C&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]}),N&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsx("h4",{className:"w6w-rel-group-head",children:"Performance across your APIs"}),e.jsx(os,{services:t,getHref:l,onOpen:o})]}),x.length>0&&e.jsxs("div",{className:"w6w-rel-group",children:[e.jsxs("h4",{className:"w6w-rel-group-head",children:[a?"Services":"All services"," ",e.jsx("span",{className:"w6w-muted w6w-small",children:a?`${x.length} of ${t.length}`:t.length})]}),e.jsx("div",{className:"w6w-rel-table-wrap",children:e.jsxs("table",{className:"w6w-rel-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Service"}),e.jsx("th",{children:"Status"}),e.jsxs("th",{children:["Last ",f," days"]}),e.jsx("th",{children:"Latency"})]})}),e.jsx("tbody",{children:x.map(A=>e.jsx(la,{service:A,getHref:l,onOpen:o},A.appId))})]})}),y>0&&e.jsxs("p",{className:"w6w-muted w6w-small w6w-rel-more-note",children:[y," more",C&&e.jsxs(e.Fragment,{children:[" — ",k("view all →")]})]})]})]})]})]})}function oa({tone:t="muted",title:s,children:n,"data-testid":a}){return e.jsx("span",{className:`w6w-callable-list-status w6w-callable-list-status-${t}`,title:s,"data-testid":a,children:n})}const me="all",ne="archived";function ca(t,s){return s===""?!0:[t.id,t.searchText,typeof t.title=="string"?t.title:void 0,typeof t.description=="string"?t.description:void 0].some(a=>a==null?void 0:a.toLowerCase().includes(s))}function da({rows:t,title:s,icon:n,description:a,emptyCopy:i,newLabel:r="New",openRowTitle:l,testIds:o,loading:c,error:d,onCreate:m,creating:f,onImport:b,onOpen:w,getHref:p,groups:v=[],filter:u,onFilterChange:x,showArchived:y,onShowArchivedChange:N,searchPlaceholder:C="Search by name",slots:k}){var q;const[A,E]=g.useState(me),[P,I]=g.useState(""),V=u??(y===void 0?void 0:y?ne:me),D=V??A,X=S=>{V===void 0&&E(S),x==null||x(S),S===ne!=(D===ne)&&(N==null||N(S===ne))},L=t.filter(S=>!S.archived),K=t.length-L.length,R=S=>D===ne?S.archived:!S.archived&&(D===me||S.group===D),M=P.trim().toLowerCase(),$=t.filter(S=>R(S)&&ca(S,M)),U=[{key:me,label:"All",count:L.length},...v.map(S=>({...S,count:L.filter(F=>F.group===S.key).length})),{key:ne,label:"Archived",count:K}],ee=((q=U.find(S=>S.key===D))==null?void 0:q.label)??D,Z=w!==void 0||p!==void 0,G=[{key:"main",header:"Name",render:S=>{const F=S.icon!==void 0?S.icon:n?e.jsx(B.Icon,{name:n,size:16}):null,re=e.jsxs("span",{className:"w6w-callable-list-cell",title:Z?l:void 0,children:[F!=null&&e.jsx("span",{className:"w6w-callable-list-icon","aria-hidden":"true",children:F}),e.jsxs("span",{className:"w6w-callable-list-main",children:[e.jsxs("span",{className:"w6w-callable-list-title-line",children:[e.jsx("span",{className:"w6w-callable-list-name",children:S.title}),S.status]}),S.description!=null&&S.description!==""&&e.jsx("span",{className:"w6w-muted w6w-small w6w-callable-list-row-desc",children:S.description}),S.meta!=null&&e.jsx("span",{className:"w6w-muted w6w-callable-list-meta",children:S.meta})]})]});return w&&!p?e.jsx("button",{type:"button",className:"w6w-callable-list-open",children:re}):re}},{key:"trail",header:"",align:"right",width:"1%",render:S=>S.archived||S.badges!=null||S.trailing!=null?e.jsxs("span",{className:"w6w-callable-list-trail",children:[S.badges,S.archived&&e.jsx("span",{className:"w6w-callable-list-badge","data-testid":o==null?void 0:o.archivedBadge,children:"archived"}),S.trailing]}):null}];$.some(S=>S.menu!=null)&&G.push({key:"menu",header:"",align:"right",link:!1,actions:!0,render:S=>S.menu??null});const le=D===me&&M===""&&t.length>0&&L.length===0;return e.jsxs("section",{className:"w6w-callable-list",children:[e.jsxs("div",{className:"w6w-callable-list-head",children:[e.jsx("div",{className:"w6w-callable-list-heading",children:(k==null?void 0:k.header)??e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"w6w-callable-list-title",children:s}),a!=null&&e.jsx("p",{className:"w6w-muted w6w-small w6w-callable-list-description",children:a})]})}),e.jsxs("div",{className:"w6w-callable-list-actions",children:[k==null?void 0:k.actions,b&&e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":o==null?void 0:o.importOpen,onClick:b,children:"Import"}),m&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:f,onClick:m,children:f?"Creating…":r})]})]}),t.length>0&&e.jsxs("div",{className:"w6w-callable-list-filters",children:[e.jsx("fieldset",{className:"w6w-subtabs w6w-callable-list-tabs","aria-label":"Filter by status",children:U.map(S=>e.jsxs("button",{type:"button",className:`w6w-subtab${D===S.key?" active":""}`,"aria-pressed":D===S.key,"data-testid":S.key===ne&&(o!=null&&o.showArchived)?o.showArchived:o!=null&&o.filterTab?`${o.filterTab}-${S.key}`:void 0,onClick:()=>X(S.key),children:[S.label,e.jsx("span",{className:"w6w-callable-list-count",children:S.count})]},S.key))}),e.jsx("input",{type:"search",className:"w6w-callable-list-search",placeholder:C,"aria-label":C,value:P,"data-testid":o==null?void 0:o.search,onChange:S=>I(S.target.value)})]}),d&&e.jsx("div",{className:"w6w-error",children:d}),e.jsxs("div",{className:"w6w-callable-list-body",children:[c&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),$.length===0&&!c?le?e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",action:e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>X(ne),children:"Show archived"}),children:t.length===1?"The only item is archived.":`All ${t.length} items are archived.`}):t.length>0?e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",action:e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{I(""),X(me)},children:"Show all"}),children:M!==""?`Nothing in ${ee} matches "${P.trim()}".`:`Nothing in ${ee}.`}):e.jsx(h.EmptyState,{testId:"w6w-callable-list-empty",children:(k==null?void 0:k.empty)??i}):e.jsx(h.DataTable,{columns:G,rows:$,rowKey:S=>S.id,className:"w6w-data-table-rows",loading:c,getRowHref:p?S=>p(S.id):void 0,onRowClick:w?(S,F)=>w(S.id,F):void 0})]})]})}function ua({connections:t,appsById:s,loading:n,error:a,onOpen:i,getHref:r,onEdit:l,onDelete:o,busy:c,slots:d}){const m=s??new Map,f=l!==void 0||o!==void 0,b=[{key:"name",header:"Name",render:w=>{const p=h.resolveConnectionAppMeta(w,m),v=w.displayName||w.id;return e.jsxs("span",{className:"w6w-connection-cell-name",children:[e.jsx(h.AppIcon,{src:p==null?void 0:p.iconSvg,srcDark:p==null?void 0:p.iconSvgDark,brandColor:p==null?void 0:p.brandColor,name:(p==null?void 0:p.displayName)??w.appId}),e.jsxs("span",{className:"w6w-connection-cell-text",children:[e.jsxs("span",{className:"w6w-connection-cell-title",children:[e.jsx("strong",{className:"w6w-connection-name",title:v,children:v}),e.jsx("span",{className:`w6w-connection-status${w.state==="connected"?"":" w6w-connection-status-warn"}`,title:w.state,children:w.state}),w.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-status w6w-connection-status-danger",title:"Last test failed — update or re-test.",children:"invalid"})]}),e.jsx("span",{className:"w6w-connection-app w6w-muted",children:(p==null?void 0:p.displayName)??w.appId})]})]})}}];return f&&b.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>w.builtIn===!0?null:e.jsx(lt,{label:`Actions for ${w.displayName||w.id}`,"data-testid":`connection-actions-${w.id}`,actions:[l&&{label:"Edit",icon:"edit",onSelect:()=>l(w),"data-testid":`connection-edit-${w.id}`},o&&{label:"Delete",icon:"delete",danger:!0,disabled:c,onSelect:()=>o(w),"data-testid":`connection-delete-${w.id}`}]})}),e.jsxs("section",{className:"w6w-connection-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-connection-list-head",children:[e.jsx("div",{className:"w6w-connection-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-connection-list-actions",children:d==null?void 0:d.actions})]}),a&&e.jsx("div",{className:"w6w-error",children:a}),n&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!n?e.jsx(h.EmptyState,{testId:"w6w-connection-list-empty",children:(d==null?void 0:d.empty)??"No connections yet."}):e.jsx(h.DataTable,{columns:b,rows:t,rowKey:w=>w.id,loading:n,getRowHref:r?w=>w.builtIn===!0?void 0:r(w.id):void 0,onRowClick:i?(w,p)=>w.builtIn===!0?void 0:i(w.id,p):void 0})]})}function wa({connection:t,onClose:s,onSaved:n}){const a=h.useW6WApi(),i=a.updateConnection,r=t.builtIn===!0,l=!r&&typeof i=="function",[o,c]=g.useState(t.displayName??""),[d,m]=g.useState(t.authKey),[f,b]=g.useState({}),[w,p]=g.useState(null),[v,u]=g.useState(null),[x,y]=g.useState(!1),[N,C]=g.useState({}),[k,A]=g.useState(null),[E,P]=g.useState(null),[I,V]=g.useState(null),[D,X]=g.useState(null);g.useEffect(()=>{if(!l)return;let T=!1;return p(null),a.getAppAuth(t.appId).then(_=>!T&&p(_)).catch(_=>!T&&u(_.message)),()=>{T=!0}},[a,l,t.appId]);const L=w==null?void 0:w.find(T=>T.key===d),K=d!==t.authKey,R=(w==null?void 0:w.filter(T=>T.key===t.authKey||T.available!==!1&&!T.autoSatisfied&&["apiKey","bearer","basic","custom"].includes(T.type)))??[],M=(L==null?void 0:L.type)==="oauth2",$=M?[]:(L==null?void 0:L.fields)??[],U=t.credentialId,ee=!K&&!!U&&typeof a.rotateCredential=="function"&&(E!==null?!E.startsWith("legacy:"):(L==null?void 0:L.type)==="serviceAccount")&&I!==!0&&!M,Z=ee&&I===!1&&L!==void 0&&!L.serviceAccount,G=ee&&!Z,le=!K&&!M&&!!U&&typeof a.getCredential=="function"&&I===null,q=G&&(L!=null&&L.serviceAccount)?h.bindingFieldsFor(L.serviceAccount):[];g.useEffect(()=>{if(!l||K||M||!U||typeof a.getCredential!="function")return;let T=!1;return a.getCredential(U).then(_=>{T||(A(_.connectionCount),P(_.contract),V(_.private===!0))}).catch(()=>{}),()=>{T=!0}},[a,l,K,M,U]);function S(){if(Z)return o!==(t.displayName??"")?{displayName:o}:null;if(G){const W={};o!==(t.displayName??"")&&(W.displayName=o);const H=h.buildBinding(q,N);return H&&(W.binding=H),W.displayName===void 0&&W.binding===void 0?null:W}const T={};for(const W of Z?[]:$){const H=f[W.key];H!==void 0&&H!==""&&(T[W.key]=H)}const _={};return K&&(_.authKey=d,_.credential=T),o!==(t.displayName??"")&&(_.displayName=o),Object.keys(T).length>0&&(_.credential=T),_.displayName===void 0&&_.credential===void 0?null:_}async function F(){if(!l||!i||x)return;u(null);const T=S(),_=Object.fromEntries((Z?[]:$).filter(J=>f[J.key]!==void 0&&f[J.key]!=="").map(J=>[J.key,f[J.key]])),W=Object.keys(_).length>0;if(!T&&!W){u("Nothing to update — change the name or a credential or binding field.");return}if(K||G&&W){const J=$.filter(ue=>ue.required&&!(ue.key in _));if(J.length>0){u(`Enter the full new credential: ${J.map(ue=>ue.label).join(", ")}.`);return}}const H=h.parseJsonFields($,_);if("error"in H){u(H.error);return}y(!0);let ce=!1;try{G&&W&&U&&a.rotateCredential?(await a.rotateCredential(U,{source:H.values}),ce=!0,b({}),X(null)):T!=null&&T.credential&&(T.credential=H.values);const J=T?await i.call(a,t.id,T):t;b({}),n(J)}catch(J){u(ce?`The credential was saved, but the other changes failed. Click Save to retry them. ${J.message}`:J.message)}finally{y(!1)}}async function re(){if(!(!U||!a.testCredential)){u(null);try{X(await a.testCredential(U))}catch(T){u(T.message)}}}const oe=h.useEnterSubmit(F,{enabled:l&&!x});return e.jsx(h.Modal,{title:"Edit connection",onClose:s,children:e.jsxs("div",{className:"w6w-stepconfig",children:[e.jsx("div",{className:"w6w-modal-body",children:e.jsxs("div",{className:"w6w-stack",children:[r&&e.jsx("p",{className:"w6w-muted w6w-small",children:"This connection is built in — it has no stored credential to edit."}),!r&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"connection-ownership",children:t.accessScope==="user"?"Only me":"This account"}),!r&&!l&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Editing connections is not available here."}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{type:"text",value:o,onChange:T=>c(T.target.value),placeholder:"Connection name",maxLength:80,name:"w6w-connection-label",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...oe})]}),R.some(T=>T.key!==t.authKey)&&e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Authentication method"}),e.jsxs("select",{name:"w6w-connection-auth",value:d,disabled:x,onChange:T=>{m(T.target.value),b({}),C({}),X(null),u(null)},children:[!R.some(T=>T.key===t.authKey)&&e.jsx("option",{value:t.authKey,children:t.authKey}),R.map(T=>e.jsx("option",{value:T.key,children:T.displayName??T.key},T.key))]})]}),K&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Enter the new credential and click Save. This connection stays linked to your existing workflows."}),w===null&&!v&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Loading auth fields…"}),L&&e.jsx(h.AuthGuide,{auth:L}),M&&e.jsx("p",{className:"w6w-muted w6w-small",children:R.some(T=>T.key!==t.authKey)?"This connection uses OAuth. Choose another authentication method above to use a key or token.":"This is an OAuth connection. You can rename it here; its credential is renewed by re-authorizing it."}),G&&q.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a binding field blank to keep it unchanged."}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:q,values:N,onChange:C,enterSubmitProps:oe})]}),ee&&e.jsxs("div",{className:"w6w-stack","data-w6w":"credential-section",children:[typeof a.testCredential=="function"&&e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:re,children:"Test credential"}),D&&e.jsxs("p",{className:"w6w-small","data-w6w":"credential-health",children:["Credential health: ",D.ok?"ok":D.code??"failed"]})]}),e.jsxs("p",{className:"w6w-small","data-w6w":"app-access",children:["App access:"," ",t.lastTestOk===!0?"passed":t.lastTestOk===!1?"failed":"never tested"]}),G&&!le&&$.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Leave the credential blank to keep it unchanged. To replace it, enter the full new credential and click Save.",k!==null&&k>1&&` This credential is used by ${k} connections; saving a new credential updates all of them.`]}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:$,values:f,onChange:b,enterSubmitProps:oe})]}),Z&&e.jsx("p",{className:"w6w-muted w6w-small","data-w6w":"shared-credential-note",children:"Uses a shared credential. Rotate it in Settings → Credentials."})]}),!G&&!Z&&!le&&$.length>0&&e.jsxs(e.Fragment,{children:[!K&&e.jsx("p",{className:"w6w-muted w6w-small",children:"Leave a field blank to keep it unchanged. Filled fields replace the stored credential."}),e.jsx(h.AuthFieldsForm,{mode:"edit",fields:$,values:f,onChange:b,enterSubmitProps:oe})]})]}),v&&e.jsx("div",{className:"w6w-result w6w-error",children:v})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),l&&e.jsx("button",{type:"button",className:"w6w-btn",disabled:x,onClick:F,children:x?"Saving…":"Save"})]})]})})}function ma({conn:t,app:s,children:n}){return e.jsxs("div",{className:"w6w-connection-header","data-testid":"connection-header",children:[e.jsx(h.AppIcon,{src:s==null?void 0:s.iconSvg,srcDark:s==null?void 0:s.iconSvgDark,brandColor:s==null?void 0:s.brandColor,name:(s==null?void 0:s.displayName)??t.appId,size:56}),e.jsxs("div",{className:"w6w-connection-header-main",children:[e.jsx("h2",{className:"w6w-connection-header-title",children:t.displayName||t.id}),e.jsxs("div",{className:"w6w-muted w6w-small w6w-connection-header-meta",children:[e.jsx(Gt,{value:t.id,className:"w6w-connection-id-copy"})," · App"," ",e.jsx("code",{children:t.appId})," · Auth ",e.jsx("code",{children:t.authKey})," ·"," ",e.jsx("span",{className:`w6w-connection-tag${t.state==="connected"?"":" w6w-connection-tag-warn"}`,children:t.state}),t.lastTestOk===!1&&e.jsx("span",{className:"w6w-connection-tag w6w-connection-tag-danger",title:"Last test failed — update or re-test.",children:"invalid"})]})]}),n&&e.jsx("div",{className:"w6w-connection-header-actions",children:n})]})}function ws(t,s=Date.now()){const n=new Date(t).getTime();if(Number.isNaN(n))return"recently";const a=Math.max(0,Math.round((s-n)/1e3));if(a<45)return"just now";const i=Math.round(a/60);if(i<60)return`${i}m ago`;const r=Math.round(i/60);if(r<24)return`${r}h ago`;const l=Math.round(r/24);return l<30?`${l}d ago`:new Date(t).toLocaleDateString()}function ha({conn:t,refreshable:s,onChanged:n,className:a}){const i=h.useW6WApi(),[r,l]=g.useState(s??null),[o,c]=g.useState(t.autoRefresh!==!1),[d,m]=g.useState(!1),[f,b]=g.useState(null);if(g.useEffect(()=>c(t.autoRefresh!==!1),[t.autoRefresh]),g.useEffect(()=>{if(s!==void 0){l(s);return}let v=!1;return i.getAppAuth(t.appId).then(u=>{var x;return!v&&l(((x=u.find(y=>y.key===t.authKey))==null?void 0:x.refreshable)===!0)}).catch(()=>!v&&l(!1)),()=>{v=!0}},[i,t.appId,t.authKey,s]),t.builtIn||r!==!0)return null;const w=i.updateConnection;async function p(v){if(w){b(null),m(!0),c(v);try{const u=await w.call(i,t.id,{autoRefresh:v});n==null||n(u)}catch(u){c(!v),b(u.message)}finally{m(!1)}}}return e.jsxs("section",{className:`w6w-keepalive${a?` ${a}`:""}`,"data-testid":"connection-keepalive",children:[e.jsx("h3",{children:"Token refresh"}),e.jsxs("label",{className:"w6w-checkbox",children:[e.jsx("input",{type:"checkbox",name:"w6w-connection-keepalive",checked:o,disabled:!w||d,onChange:v=>p(v.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Keep connected"}),e.jsxs("span",{className:"w6w-muted w6w-small",children:[" ",o?"Refresh the token automatically, even when nothing uses this connection.":"Off: the token is refreshed only when something uses this connection, so an idle one may need reconnecting."]})]})]}),t.lastRefreshedAt&&e.jsxs("p",{className:"w6w-muted w6w-small","data-testid":"connection-last-refreshed",children:["Last refreshed"," ",e.jsx("time",{dateTime:t.lastRefreshedAt,title:t.lastRefreshedAt,children:ws(t.lastRefreshedAt)})]}),t.refreshFailingSince&&e.jsxs("p",{className:"w6w-keepalive-warning","data-testid":"connection-refresh-failing",children:["Token refresh failing since"," ",e.jsx("time",{dateTime:t.refreshFailingSince,children:new Date(t.refreshFailingSince).toLocaleDateString()})," ","— reconnect if this persists"]}),f&&e.jsx("div",{className:"w6w-result w6w-error",children:f})]})}const pa=t=>String(t);function Vt(t){const s=Math.min(100,Math.max(0,t));return Number(s.toFixed(4))}function fa({label:t,used:s,limit:n,reserved:a=0,format:i,className:r,testId:l}){const o=i??pa,c=Number.isFinite(a)&&a>0,d=n>0?Vt(s/n*100):100,m=c&&n>0?Vt(Math.min(100-d,a/n*100)):0,f=s>=n,b=`${o(s)} / ${o(n)}`,w=["w6w-budget-meter"];return f&&w.push("w6w-budget-meter-over"),r&&w.push(r),e.jsxs("div",{role:"meter",className:w.join(" "),"aria-label":t,"aria-valuemin":0,"aria-valuenow":s,"aria-valuemax":n,"aria-valuetext":b,"data-testid":l,children:[e.jsxs("div",{className:"w6w-budget-meter-head",children:[e.jsx("span",{className:"w6w-budget-meter-label",children:t}),e.jsx("span",{className:"w6w-budget-meter-value",children:b})]}),e.jsxs("div",{className:"w6w-budget-meter-track",children:[e.jsx("div",{className:"w6w-budget-meter-used",style:{width:`${d}%`}}),c&&e.jsx("div",{className:"w6w-budget-meter-reserved",style:{width:`${m}%`}})]})]})}const ms={kv:"Key-value",doc:"Document",table:"Table"},xa=["kv","doc","table"],rt=["string","number","integer","boolean","date","datetime"],hs=5242880;function ga(t){var n;const s=(n=t.schema)==null?void 0:n.valueType;return typeof s=="string"&&rt.includes(s)?s:"string"}function va(t){var a,i;if(t.kind!=="table")return null;const s=(a=t.schema)==null?void 0:a.columns;if(!Array.isArray(s))return null;const n=(i=t.schema)==null?void 0:i.key;return typeof n=="string"?{columns:s,key:n}:{columns:s}}function ja(t,s){const n=t==null?void 0:t.match(/filename="([^"]*)"/),a=n==null?void 0:n[1];return a!==void 0&&a!==""?a:`${s}.csv`}const ps={required:"Required.",not_a_number:"Enter a number.",not_an_integer:"Enter a whole number.",not_a_boolean:"Enter true or false.",not_a_date:"Enter a date as YYYY-MM-DD.",not_a_datetime:"Enter a date-time like 2026-01-31T09:30:00Z."},ba=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,ya=/^-?(0|[1-9]\d*)$/,Na=/^\d{4}-\d{2}-\d{2}$/,ka=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function Sa(t,s){return s===2?t%4===0&&t%100!==0||t%400===0?29:28:[31,0,31,30,31,30,31,31,30,31,30,31][s-1]}function ot(t){if(!Na.test(t))return null;const s=Number(t.slice(0,4)),n=Number(t.slice(5,7)),a=Number(t.slice(8,10));return n<1||n>12||a<1||a>Sa(s,n)?null:{year:s,month:n,day:a}}function ae(t){return{ok:!1,problem:t,message:ps[t]}}function De(t,s,n){const a=s.trim();if(a==="")return n?ae("required"):{ok:!0,value:void 0};switch(t){case"string":return{ok:!0,value:s};case"number":{if(!ba.test(a))return ae("not_a_number");const i=Number(a);return Number.isFinite(i)?{ok:!0,value:i}:ae("not_a_number")}case"integer":{if(!ya.test(a))return ae("not_an_integer");const i=Number(a);return Number.isSafeInteger(i)?{ok:!0,value:i}:ae("not_an_integer")}case"boolean":return a==="true"?{ok:!0,value:!0}:a==="false"?{ok:!0,value:!1}:ae("not_a_boolean");case"date":return ot(a)===null?ae("not_a_date"):{ok:!0,value:a};case"datetime":return fs(a)?{ok:!0,value:a}:ae("not_a_datetime")}}function fs(t){if(!ka.test(t)||ot(t.slice(0,10))===null)return!1;const s=Number(t.slice(11,13)),n=Number(t.slice(14,16)),a=Number(t.slice(17,19));if(s>23||n>59||a>59)return!1;const r=t.slice(19).match(/(Z|([+-])(\d{2}):(\d{2}))$/);return r===null||r[1]==="Z"?!0:Number(r[3])<=23&&Number(r[4])<=59}function Fe(t,s){if(s==null)return"";if((t==="string"||t==="date"||t==="datetime")&&typeof s=="string")return s;if((t==="number"||t==="integer")&&typeof s=="number"&&Number.isFinite(s))return String(s);if(t==="boolean"&&typeof s=="boolean")return s?"true":"false";const n=JSON.stringify(s);return n===void 0?"":n}function Ca(t,s){switch(t){case"string":return typeof s=="string";case"number":return typeof s=="number"&&Number.isFinite(s);case"integer":return Number.isSafeInteger(s);case"boolean":return typeof s=="boolean";case"date":return typeof s=="string"&&ot(s)!==null;case"datetime":return typeof s=="string"&&fs(s)}}const he="The request failed.",xs="Could not reach the server.";function de(t){return typeof t=="string"&&t.length>0?t:void 0}function gs(t){return Number.isInteger(t)&&t>=0?t:void 0}function vs(t,s,n){const a={message:he};typeof n=="number"&&(a.status=n);const i=t!==null&&typeof t=="object"?t.error:void 0;if(i!==null&&typeof i=="object"){const r=i,l=de(r.code);l!==void 0&&(a.code=l);const o=de(r.field);o!==void 0&&(a.field=o);const c=de(r.column);c!==void 0&&(a.column=c);const d=gs(r.row);d!==void 0&&(a.row=d);const m=de(r.message);m!==void 0&&(a.message=m)}if(a.message===he)for(const r of s){const l=de(r);if(l!==void 0){a.message=l;break}}return a}function Ea(t){try{const s=t!==null&&typeof t=="object"?t:void 0,n=s==null?void 0:s.raw,a=s==null?void 0:s.message;return vs(n,[a],s==null?void 0:s.status)}catch{return{message:he}}}function js(t){try{if(t.status===0)return{status:0,code:"network_error",message:xs};let s;try{s=JSON.parse(t.text)}catch{return{status:t.status,message:he}}return vs(s,[],t.status)}catch{return{message:he}}}function bs(t){const s=de(t.column);if(s!==void 0){const a=gs(t.row);return a===void 0?{kind:"cell",column:s}:{kind:"cell",column:s,row:a}}const n=de(t.field);return n!==void 0?{kind:"field",field:n}:{kind:"form"}}function st(t){return t+2}const ct="\0new",dt="Changed by someone else since you loaded it.",nt="Enter a JSON object or array.",ys="The file is larger than 5 MB.";function Ns(t){const s=t.value;return s!==null&&typeof s=="object"&&!Array.isArray(s)?s:{}}function Ra(t,s){const n=Ns(t),a={};for(const i of s)a[i.name]=Fe(i.type,n[i.name]);return{id:t.key,version:t.version,cells:a}}function Aa(t){const s={};for(const n of t)s[n.name]=n.default===void 0?"":Fe(n.type,n.default);return{id:ct,version:null,cells:s}}function Ta(t,s,n){const a=[];for(const i of n)(t.cells[i.name]??"")!==(s.cells[i.name]??"")&&a.push(i.name);return a}function $a(t,s){const n={},a={};for(const i of s){const r=De(i.type,t.cells[i.name]??"",i.required);r.ok?r.value!==void 0&&(n[i.name]=r.value):a[i.name]=r.message}return Object.keys(a).length>0?{ok:!1,errors:a}:{ok:!0,value:n}}function _a(t,s){if(t===null)return;const n=Date.parse(t);if(!Number.isFinite(n))return;const a=Math.ceil((n-s)/1e3);return a>0?a:void 0}function Oa(t,s,n){if(t.id===ct)return n===void 0?{kind:"insert",value:s}:{kind:"insert",value:s,ttlSeconds:n};const a={kind:"put",key:t.id,value:s,ifVersion:t.version??0};return n===void 0?a:{...a,ttlSeconds:n}}function Ia(t,s){const n=bs(t);return n.kind!=="cell"||!s.some(a=>a.name===n.column)?null:{[n.column]:t.message}}function La(t){return t.status===409&&t.code==="version_conflict"}function ks(t){let s;try{s=JSON.parse(t)}catch{return{ok:!1,message:nt}}return s===null||typeof s!="object"?{ok:!1,message:nt}:{ok:!0,value:s}}function Pa(t,s){if(t==="string")return{ok:!0,value:s};const n=De(t,s,!0);return n.ok?{ok:!0,value:n.value}:{ok:!1,message:n.message}}function Ma(t){if(t.status===200){let a=0;try{const i=JSON.parse(t.text);typeof i.imported=="number"&&Number.isFinite(i.imported)&&(a=i.imported)}catch{a=0}return{ok:!0,message:`Imported ${a} row${a===1?"":"s"}.`}}const s=js(t);return s.row===void 0?{ok:!1,message:s.message}:{ok:!1,message:`${s.column?`Line ${st(s.row)}, column ${s.column}`:`Line ${st(s.row)}`}: ${s.message}`}}function Da({stores:t,loading:s,error:n,onOpen:a,getHref:i,onEdit:r,onArchive:l,busy:o,formatSize:c,slots:d}){const m=c??Qt,f=r!==void 0||l!==void 0,b=[{key:"name",header:"Name",render:w=>e.jsx("strong",{children:w.name})},{key:"kind",header:"Kind",render:w=>ms[w.kind]},{key:"entries",header:"Entries",align:"right",render:w=>String(w.entryCount)},{key:"size",header:"Size",align:"right",render:w=>m(w.sizeBytes)}];return f&&b.push({key:"actions",header:"",align:"right",link:!1,actions:!0,render:w=>e.jsx(lt,{label:`Actions for ${w.name||w.id}`,"data-testid":`data-store-actions-${w.id}`,actions:[r&&{label:"Edit",icon:"edit",onSelect:()=>r(w),"data-testid":`data-store-edit-${w.id}`},l&&{label:"Archive",icon:"archive",danger:!0,disabled:o,onSelect:()=>l(w),"data-testid":`data-store-archive-${w.id}`}]})}),e.jsxs("section",{className:"w6w-data-store-list",children:[((d==null?void 0:d.header)!=null||(d==null?void 0:d.actions)!=null)&&e.jsxs("div",{className:"w6w-data-store-list-head",children:[e.jsx("div",{className:"w6w-data-store-list-heading",children:d==null?void 0:d.header}),e.jsx("div",{className:"w6w-data-store-list-actions",children:d==null?void 0:d.actions})]}),n&&e.jsx("div",{className:"w6w-error",children:n}),s&&e.jsx("p",{className:"w6w-muted",children:"Loading…"}),t.length===0&&!s?e.jsx(h.EmptyState,{testId:"w6w-data-store-list-empty",children:(d==null?void 0:d.empty)??"No data stores yet."}):e.jsx(h.DataTable,{columns:b,rows:t,rowKey:w=>w.id,loading:s,getRowHref:i?w=>i(w.id):void 0,onRowClick:a?(w,p)=>a(w.id,p):void 0})]})}function Fa(t){return t.name!==""&&t.required===!0&&(t.type==="string"||t.type==="integer")}function Ba(t,s){const{default:n,...a}=t,i=De(t.type,s,!1);return i.ok?i.value===void 0?{column:a}:{column:{...a,default:i.value}}:{column:a,error:i.message}}function Ua(t){const{columns:s,onChange:n,keyColumn:a,onKeyColumnChange:i,columnErrors:r}=t,[l,o]=g.useState({}),c=s.filter(Fa),d=c.some(p=>p.name===a)?a:"";g.useEffect(()=>{a!==""&&d===""&&i("")},[a,d,i]);function m(){n([...s,{name:"",type:"string",required:!1}])}function f(p,v){n(s.map((u,x)=>x===p?{...u,...v}:u))}function b(p,v,u,x){const y={...s[p],...x,type:v},{column:N,error:C}=Ba(y,u);o(k=>({...k,[p]:C===void 0?{text:u}:{text:u,error:C}})),n(s.map((k,A)=>A===p?N:k))}function w(p){o(v=>{const u={};for(const[x,y]of Object.entries(v)){const N=Number(x);N<p?u[N]=y:N>p&&(u[N-1]=y)}return u}),n(s.filter((v,u)=>u!==p))}return e.jsxs("div",{className:"w6w-data-columns",children:[e.jsxs("div",{className:"w6w-data-columns-head",children:[e.jsx("h3",{children:"Columns"}),e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:m,children:"+ Add column"})]}),e.jsx("p",{className:"w6w-muted w6w-small",children:"Each column has a name, a scalar type, whether it must be set, and an optional default."}),s.length===0&&e.jsx("p",{className:"w6w-muted w6w-small",children:"No columns yet."}),s.length>0&&e.jsxs("div",{className:"w6w-data-columns-row w6w-data-columns-colhead","aria-hidden":"true",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"}),e.jsx("span",{}),e.jsx("span",{children:"Default"}),e.jsx("span",{})]}),e.jsx("ul",{className:"w6w-data-columns-list","data-testid":"data-columns",children:s.map((p,v)=>{const u=l[v],x=(u==null?void 0:u.text)??Fe(p.type,p.default);return e.jsxs("li",{className:"w6w-data-columns-row",children:[e.jsx("input",{type:"text",value:p.name,placeholder:"name","aria-label":"Column name",onChange:y=>f(v,{name:y.target.value})}),e.jsx("select",{value:p.type,"aria-label":"Column type",onChange:y=>b(v,y.target.value,x),children:rt.map(y=>e.jsx("option",{value:y,children:y},y))}),e.jsxs("label",{className:"w6w-data-columns-required",children:[e.jsx("input",{type:"checkbox",checked:p.required,"aria-label":"Required",onChange:y=>f(v,{required:y.target.checked})}),e.jsx("span",{className:"w6w-muted w6w-small",children:"required"})]}),e.jsx("input",{type:"text",value:x,placeholder:"default","aria-label":"Column default",onChange:y=>b(v,p.type,y.target.value)}),e.jsx(h.DeleteButton,{label:`Remove column ${p.name||v+1}`,onClick:()=>w(v)}),(u==null?void 0:u.error)!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-default-error-${v}`,children:u.error}),p.name!==""&&r[p.name]!==void 0&&e.jsx("div",{className:"w6w-result w6w-error w6w-data-columns-error","data-testid":`data-store-column-error-${p.name}`,children:r[p.name]})]},v)})}),e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key column"}),e.jsxs("select",{value:d,onChange:p=>i(p.target.value),children:[e.jsx("option",{value:"",children:"(none — rows get generated keys)"}),c.map(p=>e.jsx("option",{value:p.name,children:p.name},p.name))]}),e.jsx("span",{className:"w6w-hint",children:"Only a required, string or integer column can name a row's key."})]})]})}function Wa({result:t,busy:s,onImport:n,onRefuse:a,onExport:i}){function r(l){var d;const o=l.target,c=(d=o.files)==null?void 0:d[0];if(c!==void 0){if(o.value="",c.size>hs){a(ys);return}n(c)}}return e.jsxs("div",{className:"w6w-data-csv-panel","data-testid":"csv-panel",children:[e.jsxs("div",{className:"w6w-data-csv-panel-actions",children:[e.jsx("input",{type:"file",accept:".csv,text/csv","data-testid":"csv-file","aria-label":"Import CSV",onChange:r}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"csv-export",disabled:s,onClick:i,children:"Export CSV"})]}),t!==null&&e.jsx("div",{className:t.ok?"w6w-result":"w6w-result w6w-error","data-testid":"csv-result",children:t.message})]})}function Va({rows:t,empty:s,loading:n,searchValue:a,hasMore:i,onOpen:r,onSearch:l,onNew:o,onLoadMore:c}){const[d,m]=g.useState(a??""),f=w=>{w.preventDefault(),l(d)},b=[{key:"key",header:"Key",width:"26%",render:w=>e.jsx("button",{type:"button",className:"w6w-data-entry-key",title:w.key,"data-testid":"entry-key",onClick:p=>{p.stopPropagation(),r(w.key)},children:w.key})},{key:"value",header:"Value",render:w=>w.copyText!==void 0?e.jsx(B.Copyable,{value:w.copyText,label:"Copy value",className:"w6w-copyable--bare",children:e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}):e.jsx("span",{className:"w6w-data-entry-preview",children:w.preview})}];return e.jsxs("div",{children:[e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:f,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:d,placeholder:"Key prefix","aria-label":"Key prefix",onChange:w=>m(w.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-data-entry-new",type:"button","data-testid":"entry-new",onClick:o,children:"+ New entry"})]}),e.jsx(h.DataTable,{className:"w6w-data-entry-list",onRowClick:w=>r(w.key),columns:b,rows:t,rowKey:w=>w.key,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:n?"Loading…":s??"No entries match this key prefix."})}),i&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:c,children:"Load more"})]})}function Ka({kind:t,isNew:s,entryKey:n,newKey:a,expiresAt:i,text:r,error:l,conflict:o,saving:c,onTextChange:d,onKeyChange:m,onDelete:f,onSave:b,onCancel:w,onReload:p}){const[v,u]=g.useState(s),[x,y]=g.useState(!1),N=g.useRef(null);g.useEffect(()=>{var I;s||(I=N.current)==null||I.focus()},[s]);const C=t==="doc"?"document":"entry",k=t==="doc"?ks(r):void 0,A=k!==void 0&&!k.ok,E=l||(x&&k&&!k.ok?k.message:null),P=e.jsxs(e.Fragment,{children:[s?e.jsxs("label",{className:"w6w-field",children:[e.jsx("span",{children:"Key"}),e.jsx("input",{"data-testid":"entry-new-key",value:a??"",placeholder:"Key","aria-label":"Key",onChange:I=>m(I.target.value)})]}):i?e.jsxs("p",{className:"w6w-muted w6w-small",children:["Expires ",i]}):null,t==="doc"?e.jsx(h.JsonEditor,{value:r,readOnly:!v,onChange:I=>{y(!1),d(I)},onFocus:()=>y(!1),onBlur:()=>y(!0),showDiagnostics:x,minHeight:"min(50vh, 400px)",maxHeight:"60vh"}):e.jsx(B.Copyable,{value:r,label:"Copy value",children:e.jsx("input",{type:"text","data-testid":"entry-value",value:r,"aria-label":"Value",readOnly:!v,onChange:I=>d(I.target.value)})}),E&&e.jsx("div",{className:"w6w-field-error",role:"alert","data-testid":"entry-value-error",children:E}),o&&e.jsxs("div",{className:"w6w-error","data-testid":"entry-conflict",children:[dt," ",e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entry-reload",onClick:p,children:"Reload"})]})]});return e.jsxs(h.Modal,{title:s?`New ${C}`:v?`Edit ${C}`:t==="doc"?"Document":"Entry",subtitle:s?void 0:n,size:t==="doc"?"wide":"default",onClose:c?()=>{}:w,children:[e.jsx("div",{className:"w6w-modal-body","data-testid":"entry-editor",children:P}),e.jsxs("div",{className:"w6w-modal-actions",children:[!s&&f&&e.jsx(h.DeleteButton,{label:"Delete entry",className:"w6w-data-entry-delete",disabled:c,onClick:f}),e.jsx("button",{ref:N,className:"w6w-btn w6w-btn-ghost",type:"button",disabled:c,onClick:w,children:v?"Cancel":"Close"}),v?e.jsx("button",{className:"w6w-btn",type:"button","data-testid":"entry-save",disabled:!!o||!!c||A||s&&!(a!=null&&a.trim()),onClick:b,children:"Save"}):e.jsx("button",{className:"w6w-btn",type:"button",disabled:c,onClick:()=>u(!0),children:"Edit"})]})]})}const Ae=t=>t.isNew?"new":t.id;function Ja({columns:t,keyColumn:s,rows:n,error:a,loading:i,empty:r,searchValue:l,hasMore:o,onCellChange:c,onSave:d,onDelete:m,onReload:f,onAddRow:b,onLoadMore:w,onSearch:p}){const[v,u]=g.useState(l??""),x=N=>{N.preventDefault(),p(v)},y=[...t.map(N=>({key:N.name,header:e.jsxs(e.Fragment,{children:[N.name," ",e.jsx("span",{className:"w6w-muted w6w-small",children:N.type})]}),render:C=>{var A;const k=(A=C.cellErrors)==null?void 0:A[N.name];return e.jsxs("div",{className:"w6w-data-cell",children:[e.jsx("input",{"data-row":Ae(C),"data-column":N.name,value:C.cells[N.name]??"",readOnly:N.name===s&&!C.isNew,"aria-label":`${N.name} (${N.type})`,onChange:E=>c(C.id,N.name,E.target.value)}),k!==void 0&&e.jsx("div",{className:"w6w-data-cell-error","data-row":Ae(C),"data-column":N.name,children:k})]})}})),{key:"actions",header:"",actions:!0,render:N=>e.jsxs("div",{className:"w6w-data-row-actions",children:[e.jsx("span",{className:"w6w-muted w6w-small",children:N.version===null?"":`v${N.version}`}),e.jsx(h.IconButton,{icon:"check",label:"Save row","data-row":Ae(N),"data-testid":"row-save",disabled:!N.isNew&&!N.dirty||!!N.conflict,onClick:()=>d(N.id)}),e.jsx(h.DeleteButton,{label:"Delete entry",onClick:()=>m(N.id)}),N.conflict&&e.jsxs("div",{className:"w6w-error","data-row":Ae(N),"data-testid":"row-conflict",children:[dt," ",e.jsx(h.IconButton,{icon:"sync",label:"Reload row","data-testid":"row-reload",onClick:()=>f(N.id)})]})]})}];return e.jsxs("div",{children:[a!=null&&a!==""&&e.jsx("div",{className:"w6w-error","data-testid":"grid-error",children:a}),e.jsxs("form",{className:"w6w-data-entries-toolbar","data-testid":"entry-search",onSubmit:x,children:[e.jsx("input",{type:"search","data-testid":"entry-prefix",value:v,placeholder:"Key prefix","aria-label":"Key prefix",onChange:N=>u(N.target.value)}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"submit",children:"Search"}),e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"grid-add-row",onClick:b,children:"Add row"})]}),e.jsx("div",{className:"w6w-data-grid-scroll","data-testid":"data-grid-scroll",children:e.jsx(h.DataTable,{columns:y,rows:n,rowKey:N=>N.id,empty:e.jsx("div",{className:"w6w-muted w6w-small",children:i?"Loading…":r??"No rows match this key prefix."})})}),o&&e.jsx("button",{className:"w6w-btn w6w-btn-ghost",type:"button","data-testid":"entries-load-more",onClick:w,children:"Load more"})]})}class Q extends Error{constructor(n,a){super(a);fe(this,"code");this.name="CallableRunError",this.code=n}}function Ss(t,s){const n=s==null?void 0:s.trim();if(n)return n;const a=t.split(".").filter(i=>i!=="");return a[a.length-1]??t}function Cs(t,s,n="send_confirmation"){const a=`${s}.${n}`;return t.find(i=>i.tags.includes(a))??null}function ut(t){return h.callableTriggers(t).map(s=>{var n;return{id:s.id,fields:h.asFieldDefs((n=s.with)==null?void 0:n.fields)}})}function qa(t){return"callableId"in t}function Es(t,s,n,a){if(qa(t)){const r={kind:t.kind,id:t.callableId,input:{[t.field]:s}};return t.kind==="workflow"&&(r.entry=t.entry),r}const i={kind:t.kind,id:t.id,input:{[n]:s}};if(t.kind==="workflow"){const r=a?ut(a)[0]:void 0;if(!r)throw new Q("no-trigger",`Workflow ${t.name} has no manual trigger.`);i.entry=r.id}return i}async function Rs(t,s){if(s.kind==="workflow"){const n=await t.runWorkflow(s.id,{entry:s.entry,input:s.input});if(n.error||n.status==="failed"||n.status==="error"){const a=n.error;throw new Q("failed",typeof a=="string"?a:a?JSON.stringify(a):`Workflow ${n.status}`)}return n.output}if(s.kind==="function")return t.invokeFunction(s.id,s.input);if(!t.invokeEndpoint)throw new Q("unsupported","This host does not support running endpoints.");return t.invokeEndpoint(s.id,s.input)}async function wt(t,s,n,a,i){const r=s.kind==="workflow"?await t.getWorkflow(s.id):void 0,l=Es(s,n,a,r);return Rs(t,i?{...l,input:{...l.input,...i}}:l)}async function Ha(t,s){if(s.kind==="workflow"){let n;try{n=await t.getWorkflow(s.callableId)}catch{return`Workflow ${s.callableId} no longer exists.`}return!s.entry||!ut(n).some(a=>a.id===s.entry)?`Step ${s.entry??"(none)"} is no longer a manual trigger of ${s.callableId}.`:null}if(s.kind==="function")try{await t.getFunction(s.callableId)}catch{return`Function ${s.callableId} no longer exists.`}return null}async function As(t,s,n){if(!t.getCallableBinding)throw new Q("unsupported","This host does not support callable bindings.");const a=await t.getCallableBinding(s);if(!a)throw new Q("unbound",`No callable is bound to ${s}.`);const i=await Ha(t,a);if(i)throw new Q("stale",i);return Rs(t,Es(a,n,a.field))}function Ts(t){return t instanceof Error?t:new Error(String(t))}function mt({onResult:t,onError:s}){const[n,a]=g.useState({status:"idle"}),i=g.useRef(!0);g.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const r=g.useRef({onResult:t,onError:s});r.current={onResult:t,onError:s};const l=g.useCallback(async o=>{var c,d,m,f;a({status:"loading"});try{const b=await o();i.current&&a({status:"success",output:b}),(d=(c=r.current).onResult)==null||d.call(c,b)}catch(b){const w=Ts(b);i.current&&a({status:"error",error:w}),(f=(m=r.current).onError)==null||f.call(m,w)}},[]);return{state:n,run:l}}function $s(t){const s=h.useW6WApi(),[n,a]=g.useState({status:"loading"});return g.useEffect(()=>{let i=!0;if(!s.listCallables){a({status:"error",error:new Q("unsupported","This host does not support listing callables.")});return}return a({status:"loading"}),s.listCallables({tag:t}).then(r=>i&&a({status:"ready",refs:r})).catch(r=>i&&a({status:"error",error:Ts(r)})),()=>{i=!1}},[s,t]),n}function ht({error:t,onSetup:s}){const n=t instanceof Q&&(t.code==="stale"||t.code==="unbound");return e.jsxs("div",{className:"w6w-error w6w-small",role:"alert",children:[t.message,n&&s&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Set up"})]})]})}function pt({callable:t,bindingKey:s,data:n,prop:a="data",onClose:i,onSetup:r,onResult:l,onError:o,title:c}){const d=h.useW6WApi(),{state:m,run:f}=mt({onResult:l,onError:o}),[b,w]=g.useState(""),[p,v]=g.useState(null),u=s||((t==null?void 0:t.name)??"callable"),x=()=>{let y;if(b.trim())try{const N=JSON.parse(b);if(!N||typeof N!="object"||Array.isArray(N))throw new Error("not an object");y=N}catch{v("Additional inputs must be a JSON object.");return}v(null),s?f(()=>As(d,s,n)):t&&f(()=>wt(d,t,n,a,y))};return e.jsxs(h.Modal,{title:c??`Run ${u}`,onClose:i,children:[e.jsx("div",{className:"w6w-modal-body",children:m.status==="success"?e.jsx(h.ResultViewer,{value:m.output}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"w6w-muted w6w-small",children:["Run ",u," with this data?"]}),e.jsx("pre",{className:"w6w-small",children:JSON.stringify(n,null,2)}),e.jsxs("label",{className:"w6w-small",children:["Additional inputs (JSON, optional)",e.jsx("textarea",{"aria-label":"Additional inputs",value:b,disabled:m.status==="loading",onChange:y=>w(y.target.value)})]}),p&&e.jsx("div",{className:"w6w-error w6w-small",children:p}),m.status==="error"&&e.jsx(ht,{error:m.error,onSetup:r})]})}),e.jsxs("div",{className:"w6w-modal-actions",children:[e.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:m.status==="success"?"Close":"Cancel"}),m.status!=="success"&&e.jsx("button",{type:"button",className:"w6w-btn",onClick:x,disabled:m.status==="loading",children:m.status==="loading"?"Running…":"Run"})]})]})}function Ya({tag:t="",bindingKey:s,defaultAction:n,data:a,as:i,confirm:r=!1,label:l="Run",onSetup:o,onResult:c,onError:d}){const m=h.useW6WApi(),f=$s(s?"":t),{state:b,run:w}=mt({onResult:c,onError:d}),[p,v]=g.useState(!1),u=Ss(t,i),x=f.status==="ready"?Cs(f.refs,t,n):null;let y=b.status==="loading",N=b.status==="loading"?"Running…":l;s||(f.status==="loading"?(y=!0,N="Loading…"):f.status==="ready"&&!x?(y=!0,N="No default action"):f.status==="error"&&(y=!0));const C=()=>{if(r)return v(!0);s?w(()=>As(m,s,a)):x&&w(()=>wt(m,x,a,u))},A=(!s&&f.status==="error"?f.error:null)??(b.status==="error"?b.error:null);return e.jsxs("span",{className:"w6w-run-callable",children:[e.jsx("button",{type:"button",className:"w6w-btn",disabled:y,onClick:C,children:N}),b.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),A&&e.jsx(ht,{error:A,onSetup:o}),p&&e.jsx(pt,{callable:x??void 0,bindingKey:s,data:a,prop:u,onSetup:o,onClose:()=>v(!1),onResult:c,onError:d})]})}function za({tag:t,defaultAction:s,data:n,as:a,confirm:i=!1,label:r="Run",onResult:l,onError:o}){const c=h.useW6WApi(),d=$s(t),{state:m,run:f}=mt({onResult:l,onError:o}),[b,w]=g.useState(null),[p,v]=g.useState(!1),u=Ss(t,a),x=d.status==="ready"?d.refs:[],y=Cs(x,t,s),N=b??(y==null?void 0:y.id)??"",C=x.find(E=>E.id===N)??null,k=()=>{if(C){if(i)return v(!0);f(()=>wt(c,C,n,u))}},A=d.status==="error"?d.error:m.status==="error"?m.error:null;return e.jsxs("span",{className:"w6w-run-callables",children:[e.jsxs("select",{"aria-label":"Callable",value:N,disabled:d.status!=="ready"||m.status==="loading",onChange:E=>w(E.target.value),children:[d.status==="loading"&&e.jsx("option",{value:"",children:"Loading…"}),d.status==="ready"&&!C&&e.jsx("option",{value:"",disabled:!0,children:x.length===0?"Nothing to run":"Choose…"}),x.map(E=>e.jsx("option",{value:E.id,children:E.name},E.id))]})," ",e.jsx("button",{type:"button",className:"w6w-btn",disabled:!C||m.status==="loading",onClick:k,children:m.status==="loading"?"Running…":r}),m.status==="success"&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Done"}),A&&e.jsx(ht,{error:A}),p&&C&&e.jsx(pt,{callable:C,data:n,prop:u,onClose:()=>v(!1),onResult:l,onError:o})]})}const Kt=t=>t instanceof Error?t:new Error(String(t));function Ga({hostKey:t,tag:s="",onSaved:n,onError:a}){var K;const i=h.useW6WApi(),[r,l]=g.useState(null),[o,c]=g.useState(null),[d,m]=g.useState(""),[f,b]=g.useState({status:"idle"}),[w,p]=g.useState(""),[v,u]=g.useState(""),[x,y]=g.useState(!1),[N,C]=g.useState(!1),k=g.useRef(a);k.current=a;const A=g.useRef(R=>{var $;const M=Kt(R);c(M),($=k.current)==null||$.call(k,M)}).current;g.useEffect(()=>{let R=!0;if(!i.listCallables||!i.saveCallableBinding){A(new Q("unsupported","This host does not support callable bindings."));return}return i.listCallables({tag:s}).then(M=>R&&l(M)).catch(M=>R&&A(M)),()=>{R=!1}},[i,s,A]);const E=(r==null?void 0:r.find(R=>R.id===d))??null;g.useEffect(()=>{if(p(""),u(""),C(!1),!E)return b({status:"idle"});let R=!0;return b({status:"loading"}),(async()=>{if(E.kind==="workflow"){const $=ut(await i.getWorkflow(E.id));return $.length===0?{status:"error",message:"This workflow has no manual trigger."}:{status:"ready",triggers:$,fields:[]}}if(E.kind==="function"){const $=await i.getFunction(E.id);return{status:"ready",triggers:[],fields:$.inputs.map(U=>U.key)}}return{status:"ready",triggers:[],fields:[]}})().then($=>R&&b($)).catch($=>R&&b({status:"error",message:Kt($).message})),()=>{R=!1}},[i,E]);const P=f.status==="ready"?f.triggers:[],I=P.length===1?P[0].id:w,V=(E==null?void 0:E.kind)==="workflow"?((K=P.find(R=>R.id===I))==null?void 0:K.fields.map(R=>R.key).filter(R=>!!R))??[]:f.status==="ready"?f.fields:[],D=(E==null?void 0:E.kind)==="workflow",X=!!E&&!!v&&(!D||!!I)&&!x,L=async()=>{if(!E||!i.saveCallableBinding)return;const R={kind:E.kind,callableId:E.id,field:v,...D?{entry:I}:{}};y(!0);try{await i.saveCallableBinding(t,R),C(!0),n==null||n(R)}catch(M){A(M)}finally{y(!1)}};return o&&!r?e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:o.message}):e.jsxs("div",{className:"w6w-callable-binding-setup",children:[e.jsxs("label",{className:"w6w-small",children:["Callable",e.jsxs("select",{"aria-label":"Callable",value:d,disabled:!r,onChange:R=>m(R.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:r?"Choose…":"Loading…"}),(r??[]).map(R=>e.jsxs("option",{value:R.id,children:[R.name," (",R.kind,")"]},R.id))]})]}),f.status==="error"&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:f.message}),P.length>1&&e.jsxs("label",{className:"w6w-small",children:["Trigger",e.jsxs("select",{"aria-label":"Trigger",value:w,onChange:R=>{p(R.target.value),u("")},children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),P.map(R=>e.jsx("option",{value:R.id,children:R.id},R.id))]})]}),f.status==="ready"&&(!D||I)&&e.jsxs("div",{className:"w6w-small",children:["Field",V.length>0?e.jsxs("select",{"aria-label":"Field",value:v,onChange:R=>u(R.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:"Choose…"}),V.map(R=>e.jsx("option",{value:R,children:R},R))]}):e.jsx("input",{"aria-label":"Field",value:v,placeholder:"input name",onChange:R=>u(R.target.value)})]}),e.jsx("button",{type:"button",className:"w6w-btn",disabled:!X,onClick:L,children:x?"Saving…":"Save binding"}),N&&e.jsx("span",{className:"w6w-muted w6w-small",children:" Saved"}),o&&r&&e.jsx("div",{className:"w6w-error w6w-small",role:"alert",children:o.message})]})}const Xa={pending:"Pending",verified:"Verified",revoked:"Revoked",suspended:"Suspended"};function _s({status:t,className:s,testId:n}){return e.jsx("span",{className:["w6w-publisher-badge",`w6w-publisher-badge-${t}`,s].filter(Boolean).join(" "),"data-status":t,"data-testid":n,children:Xa[t]})}function ge({label:t,value:s,id:n}){return e.jsxs("div",{className:"w6w-verification-row","data-testid":`verification-${n}`,children:[e.jsx("span",{className:"w6w-verification-label",children:t}),e.jsx("code",{className:"w6w-verification-value",children:s}),e.jsx(B.Copyable,{value:s,label:`Copy ${t}`,children:e.jsx("span",{children:"Copy"})})]})}function Os({instructions:t,className:s,testId:n}){const{dns:a,wellKnown:i,domain:r}=t;return e.jsxs("div",{className:["w6w-verification",s].filter(Boolean).join(" "),"data-testid":n,children:[e.jsxs("p",{children:["Prove you control ",r," with either method:"]}),e.jsx("h4",{children:"DNS record"}),e.jsx(ge,{label:"Type",value:a.type,id:"dns-type"}),e.jsx(ge,{label:"Name",value:a.name,id:"dns-name"}),e.jsx(ge,{label:"Value",value:a.value,id:"dns-value"}),e.jsx("h4",{children:"Well-known file"}),e.jsx(ge,{label:"URL",value:i.url,id:"wk-url"}),e.jsx(ge,{label:"Body",value:i.body,id:"wk-body"})]})}function Za({namespaces:t,onVerify:s,onRevoke:n,detail:a,busyPrefix:i,canManage:r=!0,className:l,testId:o}){return t.length===0?e.jsx("p",{className:l,"data-testid":o,children:"No namespaces claimed yet."}):e.jsx("ul",{className:["w6w-namespace-list",l].filter(Boolean).join(" "),"data-testid":o,children:t.map(c=>e.jsxs("li",{"data-testid":`namespace-${c.prefix}`,children:[e.jsx("strong",{children:c.prefix})," ",e.jsx("span",{children:c.domain})," ",e.jsx(_s,{status:c.status}),c.status==="pending"?e.jsxs(e.Fragment,{children:[e.jsx(Os,{instructions:c.instructions}),e.jsx("button",{type:"button","data-testid":`verify-${c.prefix}`,disabled:i===c.prefix,onClick:()=>s(c.prefix),children:"Verify"}),a!=null&&a[c.prefix]?e.jsx("p",{role:"alert","data-testid":`detail-${c.prefix}`,children:a[c.prefix]}):null]}):null,c.status!=="revoked"?e.jsx("button",{type:"button","data-testid":`revoke-${c.prefix}`,disabled:!r,onClick:()=>n(c.prefix),children:"Revoke"}):null]},c.prefix))})}function Qa({members:t,canManage:s,onAdd:n,onRemove:a,className:i,testId:r}){const[l,o]=g.useState(""),[c,d]=g.useState("developer");return e.jsxs("div",{className:["w6w-publisher-members",i].filter(Boolean).join(" "),"data-testid":r,children:[e.jsx("ul",{className:"w6w-publisher-member-list",children:t.map(m=>e.jsxs("li",{"data-testid":`member-${m.subject}`,children:[e.jsx("span",{children:m.subject})," ",e.jsx("span",{children:m.role}),e.jsx("button",{type:"button","data-testid":`remove-${m.subject}`,disabled:!s,onClick:()=>a(m.subject),children:"Remove"})]},m.subject))}),e.jsxs("form",{className:"w6w-publisher-member-add",onSubmit:m=>{m.preventDefault();const f=l.trim();!f||!s||(n(f,c),o(""))},children:[e.jsx("input",{"aria-label":"Member subject","data-testid":"member-subject",value:l,disabled:!s,onChange:m=>o(m.target.value)}),e.jsxs("select",{"aria-label":"Member role","data-testid":"member-role",value:c,disabled:!s,onChange:m=>d(m.target.value),children:[e.jsx("option",{value:"developer",children:"developer"}),e.jsx("option",{value:"owner",children:"owner"})]}),e.jsx("button",{type:"submit","data-testid":"member-add",disabled:!s||!l.trim(),children:"Add member"})]})]})}function ei({onCreate:t,busy:s,error:n,className:a,testId:i}){const[r,l]=g.useState(""),[o,c]=g.useState(""),d=r.trim()!==""&&o.trim()!=="";return e.jsxs("form",{className:["w6w-publisher-form",a].filter(Boolean).join(" "),"data-testid":i,onSubmit:m=>{m.preventDefault(),d&&!s&&t({slug:r.trim(),displayName:o.trim()})},children:[e.jsx("h3",{children:"Become a publisher"}),e.jsx("p",{children:"Create a publisher to claim namespaces and publish apps."}),e.jsx("input",{"aria-label":"Publisher slug","data-testid":"publisher-slug",value:r,onChange:m=>l(m.target.value)}),e.jsx("input",{"aria-label":"Display name","data-testid":"publisher-display-name",value:o,onChange:m=>c(m.target.value)}),e.jsx("button",{type:"submit","data-testid":"publisher-create",disabled:!d||s,children:"Become a publisher"}),n?e.jsx("p",{role:"alert",children:n}):null]})}const ti={private:"Not submitted",submitted:"Submitted for review",in_review:"In review",changes_requested:"Changes requested",listed:"Listed",rejected:"Rejected",suspended:"Suspended",delisted:"Delisted"},si={submitted:"Submitted",in_review:"In review",changes_requested:"Changes requested",approved:"Approved",rejected:"Rejected",auto_approved:"Auto-approved",superseded:"Superseded"},ni={validator:"Validator",digest:"Digest",sandbox_describe:"Sandbox describe",auth_test_hook:"Auth test hook",health_check:"Health check",network_wildcard:"Network wildcard",listing_copy:"Listing copy",capability_summary:"Capability summary",reviewer_notes:"Reviewer notes"};function ai({listing:t,submissions:s,className:n,testId:a}){return!t&&s.length===0?null:e.jsxs("div",{className:["w6w-listing-status",n].filter(Boolean).join(" "),"data-testid":a,children:[t?e.jsx("span",{className:"w6w-listing-state","data-listing-state":t.state,children:ti[t.state]??t.state}):null,t!=null&&t.listedVersion?e.jsxs("span",{className:"w6w-listing-listed-version",children:["v",t.listedVersion]}):null,s.length>0?e.jsx("ol",{className:"w6w-listing-submissions",children:s.map(i=>e.jsxs("li",{className:"w6w-listing-submission","data-submission-id":i.id,"data-submission-status":i.status,children:[e.jsxs("div",{className:"w6w-listing-submission-head",children:[e.jsx("span",{className:"w6w-listing-submission-status",children:si[i.status]??i.status}),e.jsxs("span",{className:"w6w-listing-submission-version",children:["v",i.version]}),e.jsx("time",{className:"w6w-listing-submission-when",dateTime:i.createdAt,children:i.createdAt})]}),i.checks.length>0?e.jsx("ul",{className:"w6w-listing-checks",children:i.checks.map(r=>e.jsxs("li",{className:"w6w-listing-check","data-check-key":r.key,"data-check-outcome":r.outcome,children:[e.jsx("span",{className:"w6w-listing-check-key",children:ni[r.key]??r.key}),e.jsx("span",{className:"w6w-listing-check-outcome",children:r.outcome}),e.jsx("span",{className:"w6w-listing-check-message",children:r.message})]},r.key))}):null,i.reasons?e.jsx("p",{className:"w6w-listing-reasons",children:i.reasons}):null,i.hasReviewerNotes?e.jsx("span",{className:"w6w-listing-notes-sent",children:"Reviewer notes sent"}):null]},i.id))}):null]})}const ii={invalid_body:"Some of these listing details aren't valid. Fix the highlighted fields and try again.",namespace_owned:"Another publisher already owns one of this app's namespaces.",namespace_reserved:"One of this app's namespaces is reserved by W6W.",publisher_suspended:"Your publisher account is suspended, so it can't submit apps for listing.",not_publisher_tier:"This publisher's plan doesn't include submitting apps for listing.",unknown_version:"That version doesn't exist for this app. Deploy it first, then submit.",submission_pending:"This app already has a submission waiting for a decision. Submit again once it's decided.",listing_delisted:"This app's listing was delisted. Ask W6W to review it again before submitting.",invalid_transition:"This listing can't go back to submitted from where it is now.",stale_submission:"A reviewer already decided on an older submission. Reload to see the current state.",app_delisted:"This app was delisted, so it can't be submitted for listing.",app_suspended:"This app is suspended. It can't take new connections or submissions until it's reinstated.",not_found:"We couldn't find that app on this publisher account."},li="Something went wrong submitting this listing. Try again in a moment.";function Is(t){return ii[t]??li}const at=280,Jt=5,qt=4e3;function Ht(t){if(!/^https:\/\//i.test(t))return!1;try{return new URL(t).hostname!==""}catch{return!1}}function ri(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Ls(t){const s=[],{version:n,listing:a}=t;n.trim()===""&&s.push({field:"version",message:"Choose the app version to submit."});const i=a.summary.trim();i===""?s.push({field:"summary",message:"Add a one-line summary of what the app does."}):i.length>at&&s.push({field:"summary",message:`Keep the summary to ${at} characters or fewer (it's ${i.length}).`}),a.categories.length>Jt&&s.push({field:"categories",message:`Pick at most ${Jt} categories (you picked ${a.categories.length}).`});const r=a.supportUrl.trim();r===""?s.push({field:"supportUrl",message:"Add an https support URL reviewers can open."}):Ht(r)||s.push({field:"supportUrl",message:"The support URL must start with https://."});const l=(a.privacyUrl??"").trim();l!==""&&!Ht(l)&&s.push({field:"privacyUrl",message:"The privacy URL must start with https://."});const o=a.contactEmail.trim();o===""?s.push({field:"contactEmail",message:"Add a contact email so reviewers can reach you."}):ri(o)||s.push({field:"contactEmail",message:"That contact email doesn't look like an email address."});const c=(a.reviewerNotes??"").trim();return c.length>qt&&s.push({field:"reviewerNotes",message:`Keep reviewer notes to ${qt} characters or fewer (they're ${c.length}).`}),s}function oi(t){const s=t.listing.summary.trim(),n=(t.listing.iconRef??"").trim(),a=(t.listing.privacyUrl??"").trim(),i=(t.listing.reviewerNotes??"").trim(),r=t.listing.categories.map(l=>l.trim()).filter(Boolean);return{version:t.version.trim(),listing:{summary:s,...n?{iconRef:n}:{},categories:r,supportUrl:t.listing.supportUrl.trim(),...a?{privacyUrl:a}:{},contactEmail:t.listing.contactEmail.trim(),...i?{reviewerNotes:i}:{}}}}const ci={version:"",summary:"",iconRef:"",categories:"",supportUrl:"",privacyUrl:"",contactEmail:"",reviewerNotes:""};function di({appId:t,versions:s,onSubmit:n,busy:a,errorCode:i,className:r,testId:l}){const[o,c]=g.useState(ci),[d,m]=g.useState([]),f=u=>x=>c(y=>({...y,[u]:x})),b={version:o.version,listing:{summary:o.summary,iconRef:o.iconRef,categories:o.categories.split(",").map(u=>u.trim()).filter(Boolean).filter((u,x,y)=>y.indexOf(u)===x),supportUrl:o.supportUrl,privacyUrl:o.privacyUrl,contactEmail:o.contactEmail,reviewerNotes:o.reviewerNotes}},w=u=>`listing-${u.replace(/[A-Z]/g,x=>`-${x.toLowerCase()}`)}`,p=u=>{var x;return((x=d.find(y=>y.field===u))==null?void 0:x.message)??""},v=(u,x,y,N)=>e.jsxs("label",{className:"w6w-listing-form-field","data-field":y,children:[e.jsx("span",{className:"w6w-listing-form-label",children:x}),e.jsx("input",{"aria-label":x,"aria-invalid":p(y)!==""||void 0,"data-testid":w(u),value:o[u],onChange:C=>f(u)(C.target.value)}),N?e.jsx("span",{className:"w6w-listing-form-hint",children:N}):null,p(y)?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":y,children:p(y)}):null]});return e.jsxs("form",{className:["w6w-listing-form",r].filter(Boolean).join(" "),"data-testid":l,"data-app-id":t,noValidate:!0,onSubmit:u=>{u.preventDefault();const x=Ls(b);m(x),x.length===0&&!a&&n(oi(b))},children:[e.jsx("h3",{children:"Submit for listing"}),e.jsx("p",{children:"Reviewers check this version, then W6W lists it in the catalog."}),e.jsxs("label",{className:"w6w-listing-form-field","data-field":"version",children:[e.jsx("span",{className:"w6w-listing-form-label",children:"Version"}),e.jsx("input",{"aria-label":"Version",list:"listing-versions","aria-invalid":p("version")!==""||void 0,"data-testid":"listing-version",value:o.version,onChange:u=>f("version")(u.target.value)}),e.jsx("datalist",{id:"listing-versions",children:(s??[]).map(u=>e.jsx("option",{value:u},u))}),p("version")?e.jsx("span",{className:"w6w-listing-form-error",role:"alert","data-field-error":"version",children:p("version")}):null]}),v("summary","Summary","summary",`Up to ${at} characters.`),v("iconRef","Icon reference","iconRef"),v("categories","Categories","categories","Comma-separated, up to five."),v("supportUrl","Support URL","supportUrl","https:// only."),v("privacyUrl","Privacy URL","privacyUrl","Optional, https:// only."),v("contactEmail","Contact email","contactEmail","Where reviewers reach you."),v("reviewerNotes","Notes for the reviewer","reviewerNotes","Optional, up to 4000 characters."),e.jsx("button",{type:"submit","data-testid":"listing-submit",disabled:a,children:"Submit for listing"}),i?e.jsx("p",{className:"w6w-listing-error",role:"alert",children:Is(i)}):null]})}exports.AddConnectionModal=h.AddConnectionModal;exports.ApiCallsPanel=h.ApiCallsPanel;exports.AppConnectionForm=h.AppConnectionForm;exports.AppIcon=h.AppIcon;exports.AppPicker=h.AppPicker;exports.AuthFieldsForm=h.AuthFieldsForm;exports.AuthGuide=h.AuthGuide;exports.CanvasLayer=h.CanvasLayer;exports.CodeEditor=h.CodeEditor;exports.Combobox=h.Combobox;exports.ConfirmModal=h.ConfirmModal;exports.CredentialPicker=h.CredentialPicker;exports.DataTable=h.DataTable;exports.DelegationSteps=h.DelegationSteps;exports.DeleteButton=h.DeleteButton;exports.EmptyState=h.EmptyState;exports.ExpressionEditorModal=h.ExpressionEditorModal;exports.ExpressionInput=h.ExpressionInput;exports.ExpressionOptionsProvider=h.ExpressionOptionsProvider;exports.HTML_PREVIEW_CSP=h.HTML_PREVIEW_CSP;exports.HtmlPreview=h.HtmlPreview;exports.IconButton=h.IconButton;exports.JsonEditor=h.JsonEditor;exports.LastUsedNote=h.LastUsedNote;exports.Markdown=h.Markdown;exports.Modal=h.Modal;exports.NodeConfigForm=h.NodeConfigForm;exports.ParamsForm=h.ParamsForm;exports.PropertyEntryForm=h.PropertyEntryForm;exports.PublisherBadge=h.PublisherBadge;exports.RESULT_RENDER_MAX_CHARS=h.RESULT_RENDER_MAX_CHARS;exports.ResultViewer=h.ResultViewer;exports.RetryPolicyFields=h.RetryPolicyFields;exports.SecretJsonField=h.SecretJsonField;exports.StepBuilderModal=h.StepBuilderModal;exports.W6WUIProvider=h.W6WUIProvider;exports.connectionAppIdsToLookUp=h.connectionAppIdsToLookUp;exports.detectResultFormat=h.detectResultFormat;exports.effectiveNodeOutput=h.effectiveNodeOutput;exports.effectiveNodeOutputs=h.effectiveNodeOutputs;exports.filterOptions=h.filterOptions;exports.findTestInput=h.findTestInput;exports.htmlPreviewSrcDoc=h.htmlPreviewSrcDoc;exports.indexNodeSamples=h.indexNodeSamples;exports.isExprValue=h.isExprValue;exports.isFormResolvedOptions=h.isFormResolvedOptions;exports.isSecretValue=h.isSecretValue;exports.isTestRequired=h.isTestRequired;exports.keyClientId=h.keyClientId;exports.previewNodeOutputs=h.previewNodeOutputs;exports.rememberableInput=h.rememberableInput;exports.requiredParamsFilled=h.requiredParamsFilled;exports.resolveConnectionAppMeta=h.resolveConnectionAppMeta;exports.resultCopyText=h.resultCopyText;exports.secretClipboard=h.secretClipboard;exports.shapeToSkeleton=h.shapeToSkeleton;exports.shouldUseCombobox=h.shouldUseCombobox;exports.splitFrontmatter=h.splitFrontmatter;exports.startOAuthPopup=h.startOAuthPopup;exports.testInputSavesSettled=h.testInputSavesSettled;exports.trackTestInputSave=h.trackTestInputSave;exports.useEnterSubmit=h.useEnterSubmit;exports.useExpressionOptions=h.useExpressionOptions;exports.useRememberedTestInput=h.useRememberedTestInput;exports.useW6WApi=h.useW6WApi;exports.CodeBlock=B.CodeBlock;exports.Copyable=B.Copyable;exports.Icon=B.Icon;exports.iconNames=B.iconNames;exports.ATTENTION_DISPLAY_CAP=tt;exports.ActionTestForm=dn;exports.ApiError=ve;exports.BudgetMeter=fa;exports.CELL_PROBLEM_COPY=ps;exports.CSV_MAX_BYTES=hs;exports.CSV_TOO_LARGE_COPY=ys;exports.CallableBindingSetup=Ga;exports.CallableList=da;exports.CallableListStatus=oa;exports.ColumnsEditor=Ua;exports.ConnectionHeader=ma;exports.ConnectionKeepAlive=ha;exports.ConnectionList=ua;exports.CopyableText=Gt;exports.CreatePublisherForm=ei;exports.CreateSharedCredentialContext=ln;exports.CsvPanel=Wa;exports.DATA_STORE_ERROR_FALLBACK=he;exports.DATA_STORE_KINDS=xa;exports.DATA_STORE_KIND_LABEL=ms;exports.DATA_STORE_NETWORK_ERROR=xs;exports.DOC_VALUE_COPY=nt;exports.DataEntryEditor=Ka;exports.DataEntryList=Va;exports.DataStoreList=Da;exports.DataTableGrid=Ja;exports.EditButton=Tn;exports.EditConnectionModal=wa;exports.ExecutionDetail=sa;exports.ExecutionFilters=Xn;exports.ExecutionList=Pn;exports.ExecutionLogPanel=ts;exports.ExecutionStats=Zn;exports.HealthStatusPill=Le;exports.HistoryTimeline=Rn;exports.InfoTip=An;exports.ListItem=_e;exports.ListingStatus=ai;exports.NEW_ROW_ID=ct;exports.NamespaceList=Za;exports.PublisherMembers=Qa;exports.PublisherStatusBadge=_s;exports.RECENT_DISPLAY_CAP=ls;exports.ReliabilityChart=os;exports.ReliabilityList=ra;exports.RepoSyncIndicator=$n;exports.RowActionsMenu=lt;exports.RunCallableButton=Ya;exports.RunCallableModal=pt;exports.RunCallables=za;exports.SCALAR_TYPES=rt;exports.ServerResourcesBadge=jn;exports.ServerResourcesCard=xn;exports.ServerResourcesCardSmall=gn;exports.ServerResourcesRail=vn;exports.StepStatusPill=Pe;exports.SubmitListingForm=di;exports.UptimeStrip=Xt;exports.VERSION_CONFLICT_COPY=dt;exports.VerificationInstructionsBlock=Os;exports.YamlEditor=un;exports.buildRowValue=$a;exports.cellErrorsOf=Ia;exports.createW6WApi=an;exports.cropText=zt;exports.csvFilenameOf=ja;exports.csvImportMessage=Ma;exports.csvLineOf=st;exports.dirtyColumns=Ta;exports.displayBoard=rs;exports.draftFromEntry=Ra;exports.errorPlacement=bs;exports.formatDurationMs=Me;exports.formatExecutionTime=je;exports.isCellValue=Ca;exports.isVersionConflict=La;exports.kvValueOf=Pa;exports.kvValueTypeOf=ga;exports.listingErrorCopy=Is;exports.locateDataStoreError=Ea;exports.locateRawResponseError=js;exports.needsAttention=aa;exports.newRowDraft=Aa;exports.parseCell=De;exports.parseDocText=ks;exports.partitionBoard=as;exports.performancePoints=ns;exports.refreshRelativeTime=ws;exports.remainingTtlSeconds=_a;exports.rowValueOf=Ns;exports.rowWriteOf=Oa;exports.serializeCell=Fe;exports.tableSchemaOf=va;exports.uptimeDays=is;exports.validateListingInput=Ls;
3
3
  //# sourceMappingURL=index.cjs.map