@capagents/forgeqe 3.4.3 → 3.4.4

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 (70) hide show
  1. package/dist/forgeqe.js +1979 -1971
  2. package/dist/web/assets/{3d-force-graph-ChNz5Yhx.js → 3d-force-graph-DwblDu4y.js} +1 -1
  3. package/dist/web/assets/{Agent-CTRFDu9M.js → Agent-C8WdS1HB.js} +1 -1
  4. package/dist/web/assets/{AgentWork-D1c_w9rM.js → AgentWork-C1Qa_Ftb.js} +1 -1
  5. package/dist/web/assets/{ApiTests-CHKwMgxN.js → ApiTests-u4tzlJaD.js} +1 -1
  6. package/dist/web/assets/{Browse-CcKh43L5.js → Browse-B0ZTvpo2.js} +1 -1
  7. package/dist/web/assets/{Chat-CooI13qi.js → Chat-B73XMxdf.js} +1 -1
  8. package/dist/web/assets/{CommandPalette-D8AtIocY.js → CommandPalette-D7ld-tbJ.js} +1 -1
  9. package/dist/web/assets/{Compare-DPX2G5oF.js → Compare-CxGjAZW0.js} +1 -1
  10. package/dist/web/assets/{Cost-CBGk_xKN.js → Cost-BeVu3Z6g.js} +1 -1
  11. package/dist/web/assets/{Data-CW95KX9u.js → Data-BPyCT0eP.js} +1 -1
  12. package/dist/web/assets/{Desktop-C6-h0ExO.js → Desktop-qPGc2OWb.js} +1 -1
  13. package/dist/web/assets/{DesktopReview-C02n70Wx.js → DesktopReview-CVoC6bQY.js} +1 -1
  14. package/dist/web/assets/{Evidence-DqTx1TS1.js → Evidence-CtUiUCa6.js} +1 -1
  15. package/dist/web/assets/{Explore-DgaugrDO.js → Explore-BvjAhqyo.js} +1 -1
  16. package/dist/web/assets/{Features-DYr-izEt.js → Features-CmQCxEJX.js} +1 -1
  17. package/dist/web/assets/{Flags-DL-G7YWK.js → Flags-asj8tiKy.js} +1 -1
  18. package/dist/web/assets/{Flaky-DOxneo4i.js → Flaky-ChYK151U.js} +1 -1
  19. package/dist/web/assets/{Impact-BuHHY2_3.js → Impact-B1-B2oHr.js} +1 -1
  20. package/dist/web/assets/{Jobs-DEc49gwq.js → Jobs-CZ2k5hGk.js} +1 -1
  21. package/dist/web/assets/{KindPage-DuLav-l5.js → KindPage-CDfvpDXP.js} +1 -1
  22. package/dist/web/assets/{LiveDevice-PsN5gnXw.js → LiveDevice-B33XU61P.js} +1 -1
  23. package/dist/web/assets/{Migration-BcxL5Okw.js → Migration-BBM_Sce0.js} +1 -1
  24. package/dist/web/assets/{Mobile-CBDmyoL5.js → Mobile-BzufjlBb.js} +1 -1
  25. package/dist/web/assets/{Observability-Cqjko62E.js → Observability-qcx5vrNO.js} +1 -1
  26. package/dist/web/assets/{OwnItems-DXS-CMiC.js → OwnItems-BkoHG_xw.js} +1 -1
  27. package/dist/web/assets/{PageAgent-BzDuRR-t.js → PageAgent-Do62EBze.js} +1 -1
  28. package/dist/web/assets/{Product-BKIKhNp3.js → Product-9ImZUA2B.js} +2 -2
  29. package/dist/web/assets/{Production-DKKynWrp.js → Production-B6uigaYJ.js} +1 -1
  30. package/dist/web/assets/{Quality-Dsh07yXp.js → Quality-Cw6qhXyl.js} +1 -1
  31. package/dist/web/assets/{Readiness-BbjzvgVB.js → Readiness-D8WMgQmd.js} +1 -1
  32. package/dist/web/assets/Record-DCcHfH7u.js +1 -0
  33. package/dist/web/assets/{Regression-DeQnXoZ4.js → Regression-BLlXnCW2.js} +1 -1
  34. package/dist/web/assets/{RelationGraph-C7M_Zcx-.js → RelationGraph-BxJgWpp6.js} +1 -1
  35. package/dist/web/assets/{Reports-DsWA9Q7H.js → Reports-ZNS4Vjz8.js} +1 -1
  36. package/dist/web/assets/{Requirements-B-8D5JFY.js → Requirements-CtQLSXK2.js} +1 -1
  37. package/dist/web/assets/{Responsive-Dl4CLUoF.js → Responsive-KaTTxiwX.js} +1 -1
  38. package/dist/web/assets/{RunDiff-C2knd045.js → RunDiff-CpvrxBX1.js} +1 -1
  39. package/dist/web/assets/{Settings-Cmac0LZa.js → Settings-C5CTbhlT.js} +3 -3
  40. package/dist/web/assets/{SiteScan-D2WMUVcw.js → SiteScan-CUMCTEY9.js} +1 -1
  41. package/dist/web/assets/{Steps-DeZhIdc1.js → Steps-C440M1Y_.js} +1 -1
  42. package/dist/web/assets/{TestData-CDOvUmVT.js → TestData-7rivojlz.js} +1 -1
  43. package/dist/web/assets/{TestManagement-9CTQonHe.js → TestManagement-Dj5JHPIU.js} +1 -1
  44. package/dist/web/assets/{WhatsNew-BotUU9UF.js → WhatsNew-xAi2Rzo3.js} +1 -1
  45. package/dist/web/assets/{agentSettingsSheet-BEVtvrGk.js → agentSettingsSheet-D12LwTAe.js} +1 -1
  46. package/dist/web/assets/api-CorvgyDj.js +1 -0
  47. package/dist/web/assets/{dataParts-C5w2uvJZ.js → dataParts-CVXmPBpU.js} +1 -1
  48. package/dist/web/assets/{desktopAppPath-BN4vYVi4.js → desktopAppPath-D_PfQisd.js} +1 -1
  49. package/dist/web/assets/{flowTheme-dXvSLQHO.js → flowTheme-bdKXfQiL.js} +1 -1
  50. package/dist/web/assets/{frame-BANehQdX.js → frame-BC1vOowF.js} +3 -3
  51. package/dist/web/assets/{index-Db_tsLSf.js → index-BoFziUZw.js} +4 -4
  52. package/dist/web/assets/{nav-f8SqayfG.js → nav--1SY7-OO.js} +1 -1
  53. package/dist/web/assets/{pageBack-DU3mApVL.js → pageBack-DDAAmq4R.js} +1 -1
  54. package/dist/web/assets/{palette-D8aKJo_q.js → palette-C8W4Fd5n.js} +1 -1
  55. package/dist/web/assets/{parts-B0PK7ewd.js → parts-uc6us_OU.js} +1 -1
  56. package/dist/web/assets/{productParts-bcAIT4Ca.js → productParts-CAgJEF8_.js} +1 -1
  57. package/dist/web/assets/{qualityParts-C2Y38oFp.js → qualityParts-BF3Yb7Zl.js} +1 -1
  58. package/dist/web/assets/{recordTest-Cn4qoyRB.js → recordTest-KjXCSP7c.js} +1 -1
  59. package/dist/web/assets/{stepper-CEFz82T4.js → stepper-CZL9ueYn.js} +1 -1
  60. package/dist/web/assets/{wizardParts-CGHmp8or.js → wizardParts-Pzx0nTZ0.js} +1 -1
  61. package/dist/web/index.html +6 -6
  62. package/package.json +1 -1
  63. package/py/forgeqe_engine/capture.py +36 -8
  64. package/py/forgeqe_engine/d365.py +263 -3
  65. package/py/forgeqe_engine/recordsession.py +2 -1
  66. package/py/forgeqe_engine/webrecord.py +3 -0
  67. package/py/forgeqe_engine/webrecord_page.py +34 -5
  68. package/skills/dynamics-365-automation/SKILL.md +12 -0
  69. package/dist/web/assets/Record-BIa-SPuU.js +0 -1
  70. package/dist/web/assets/api-DS8XP38R.js +0 -1
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-9BkoTWUE.js";import{I as r,P as i,c as a,i as o,z as s}from"./surface-c1kG1KPS.js";import{n as c,t as l}from"./utils-DJRAScIl.js";import{t as u}from"./jsx-runtime-LKYXHABd.js";import{W as d}from"./palette-D8aKJo_q.js";import{T as f,X as p,b as m}from"./api-DS8XP38R.js";import{A as h,F as g,L as _,O as v,T as y,d as b,i as x,k as S}from"./pageBack-DU3mApVL.js";import{Cr as ee,Gr as C,Hr as w,In as te,Lr as ne,N as T,Rn as E,Sn as D,Vn as O,Wr as re,Wt as k,a as A,f as j,ln as ie,lt as M,tt as ae,vn as oe,w as N,z as se}from"./line-icons-Cwj9OmCz.js";import{Ht as ce,J as le,On as ue,Vt as de,Y as fe,Z as pe}from"./frame-BANehQdX.js";import{J as P,Y as me}from"./index-Db_tsLSf.js";import{o as he}from"./dataParts-C5w2uvJZ.js";var F=e(t(),1),I=u(),ge={click:[`target`,`timeout`,`note`],double_click:[`target`,`timeout`,`note`],type:[`target`,`text`,`timeout`,`note`],select:[`target`,`value`,`timeout`,`note`],keys:[`keys`,`note`],expect:[`target`,`text`,`timeout`,`note`],wait:[`seconds`,`note`],wait_for:[`target`,`text`,`timeout`,`note`],launch:[`timeout`,`note`],close:[`note`],expect_image:[`timeout`,`note`]};function _e({p:e}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:e.summary.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,I.jsx)(`pre`,{className:l(b,`m-0 max-h-[200px]`),children:e.diff.map((e,t)=>(0,I.jsx)(`span`,{className:l(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function L({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-body-sm font-medium`,children:[e,t]})}function ve({workflow:e,step:t,mode:n,onDone:r,onCancel:a}){let s=ge[t.op]??[`note`],c=t.fields??{},[u,d]=(0,F.useState)({automation_id:c.target?.automation_id??``,name:c.target?.name??``,control_type:c.target?.control_type??``}),[p,m]=(0,F.useState)(c.text??``),[h,v]=(0,F.useState)(c.value??``),[y,b]=(0,F.useState)(c.keys??``),[x,S]=(0,F.useState)(c.seconds===void 0?``:String(c.seconds)),[w,ne]=(0,F.useState)(c.timeout===void 0?``:String(c.timeout)),[T,E]=(0,F.useState)(c.note??``),[D,O]=(0,F.useState)(null),[re,k]=(0,F.useState)(``),[A,j]=(0,F.useState)(!1),ie=()=>{let e={};return s.includes(`target`)&&(u.automation_id!==(c.target?.automation_id??``)||u.name!==(c.target?.name??``)||u.control_type!==(c.target?.control_type??``))&&(e.target=u),s.includes(`text`)&&p!==(c.text??``)&&(e.text=p),s.includes(`value`)&&h!==(c.value??``)&&(e.value=h),s.includes(`keys`)&&y!==(c.keys??``)&&(e.keys=y),s.includes(`seconds`)&&x!==(c.seconds===void 0?``:String(c.seconds))&&(e.seconds=Number(x)),s.includes(`timeout`)&&w!==(c.timeout===void 0?``:String(c.timeout))&&w.trim()&&(e.timeout=Number(w)),s.includes(`note`)&&T!==(c.note??``)&&(e.note=T),e},M=async i=>{j(!0),k(``);try{let a=await f.editStep({workflow:e,step:t.n,action:n,...n===`edit`?{fields:ie()}:{},...i?{version:i}:{}});a.written?r():O(a)}catch(e){k(e.message)}finally{j(!1)}};(0,F.useEffect)(()=>{n===`remove`&&M()},[]);let ae=()=>O(null);return(0,I.jsxs)(`div`,{className:l(o,`mb-2 ml-10 flex flex-col gap-4`),children:[n===`edit`&&!D&&(0,I.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2`,children:[s.includes(`target`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{label:`Control's name`,children:(0,I.jsx)(i,{size:`sm`,value:u.name,maxLength:300,onChange:e=>(d({...u,name:e.target.value}),ae())})}),(0,I.jsx)(L,{label:`Automation id`,children:(0,I.jsx)(i,{size:`sm`,value:u.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...u,automation_id:e.target.value}),ae()),className:`font-mono text-body-sm`})}),(0,I.jsx)(L,{label:`Control type`,children:(0,I.jsx)(i,{size:`sm`,value:u.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...u,control_type:e.target.value}),ae())})})]}),s.includes(`text`)&&(0,I.jsx)(L,{label:t.op===`type`?`Text to type`:`Text it shows`,children:(0,I.jsx)(i,{size:`sm`,value:p,maxLength:500,onChange:e=>m(e.target.value)})}),s.includes(`value`)&&(0,I.jsx)(L,{label:`Item to choose`,children:(0,I.jsx)(i,{size:`sm`,value:h,maxLength:500,onChange:e=>v(e.target.value)})}),s.includes(`keys`)&&(0,I.jsx)(L,{label:`Keys`,children:(0,I.jsx)(i,{size:`sm`,value:y,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>b(e.target.value),className:`font-mono text-body-sm`})}),s.includes(`seconds`)&&(0,I.jsx)(L,{label:`Wait (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:x,onChange:e=>S(e.target.value)})}),s.includes(`timeout`)&&(0,I.jsx)(L,{label:`Timeout (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:w,placeholder:`default`,onChange:e=>ne(e.target.value)})}),s.includes(`note`)&&(0,I.jsx)(L,{label:`Note`,children:(0,I.jsx)(i,{size:`sm`,value:T,maxLength:200,onChange:e=>E(e.target.value)})})]}),n===`remove`&&!D&&!re&&(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Working out the change…`}),D&&(0,I.jsx)(_e,{p:D}),re&&(0,I.jsx)(`p`,{role:`alert`,className:l(_.fail,`m-0`),children:re}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[D?(0,I.jsxs)(g,{busy:A,size:`sm`,variant:n===`remove`?`destructive`:`primary`,disabled:A,onClick:()=>void M(D.version),children:[n===`remove`?(0,I.jsx)(ee,{"aria-hidden":`true`}):(0,I.jsx)(N,{"aria-hidden":`true`}),A?`Saving…`:n===`remove`?`Delete step ${t.n}`:`Save the change`]}):n===`edit`&&(0,I.jsx)(g,{busy:A,size:`sm`,variant:`primary`,disabled:A||!Object.keys(ie()).length,onClick:()=>void M(),children:A?`Checking…`:`Preview the change`}),D&&n===`edit`&&(0,I.jsxs)(g,{size:`sm`,onClick:()=>O(null),children:[(0,I.jsx)(te,{"aria-hidden":`true`}),`Change it more`]}),(0,I.jsxs)(g,{size:`sm`,variant:`outline`,onClick:a,children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Cancel`]})]})]})}function R(e,t){let n={values:{},secrets:{}};for(let r of e?.inputs??[])r.kind!==`data`&&r.env&&t.includes(r.env)&&(n.secrets[r.name]=r.env);return n}function z(e,t){return(e?.inputs??[]).every(e=>e.kind===`data`?e.default!==void 0||!!t.values[e.name]?.trim():!!t.secrets[e.name])}function B(e){return{values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e.trim())),secrets:e.secrets}}function V({block:e,secrets:t,use:n,onChange:a,disabled:o,unset:s=[]}){return e.inputs.length?(0,I.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-2 border-0 p-0`,children:[(0,I.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-ink-2`,children:`What the block types`}),e.inputs.map(e=>{let c=e.label||e.name;return e.kind===`data`?(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsx)(`span`,{className:`text-muted`,children:`(test data)`}),(0,I.jsx)(i,{value:n.values[e.name]??``,maxLength:300,disabled:o,placeholder:e.default===void 0?`A value`:e.default||`(empty)`,onChange:t=>a({...n,values:{...n.values,[e.name]:t.target.value}})})]},e.name):(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.kind===`totp`?`authenticator secret`:`secret`,`)`]}),(0,I.jsxs)(r,{value:n.secrets[e.name]??``,disabled:o||!t.length,onChange:t=>a({...n,secrets:{...n.secrets,[e.name]:t.target.value}}),children:[(0,I.jsx)(`option`,{value:``,children:t.length?`Pick a saved secret`:`No saved secrets yet`}),t.map(e=>(0,I.jsxs)(`option`,{value:e,children:[e,s.includes(e)?` (no value here)`:``]},e))]}),n.secrets[e.name]&&s.includes(n.secrets[e.name])&&(0,I.jsxs)(`span`,{className:`text-warn`,children:[n.secrets[e.name],` has no value on this computer: save it in Settings › Secrets, or the step that types it fails.`]}),!t.length&&(0,I.jsx)(`span`,{className:`text-muted`,children:`Save one in Settings › Secrets, then come back.`}),e.env&&!t.includes(e.env)&&(0,I.jsxs)(`span`,{className:`text-muted`,children:[`The block was made with `,e.env,`, which has no saved value here.`]})]},e.name)})]}):null}function ye({block:e}){return e.lines.length?(0,I.jsxs)(`details`,{className:`text-body-sm text-ink-2`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer select-none text-muted`,children:[`See its `,e.steps,` `,e.steps===1?`step`:`steps`]}),(0,I.jsxs)(`ol`,{className:`m-0 mt-1 flex list-decimal flex-col gap-1 pl-6`,children:[e.lines.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t)),e.steps>e.lines.length&&(0,I.jsxs)(`li`,{className:`list-none text-muted`,children:[`and `,e.steps-e.lines.length,` more`]})]})]}):null}var be=[`steps`,`data`,`run`],xe=[{id:`typed`,label:`As typed`,note:`The workflow types exactly this.`},{id:`data`,label:`Test data`,note:`A named value the replay fills in: its own value, a row of a data file, or one you give when it runs.`},{id:`secret`,label:`Secret`,note:`Read from an environment variable when it replays; what was typed leaves the workflow.`},{id:`unique`,label:`New on each run`,note:`A fresh value each time, like this one: for an email or a name that must not repeat.`},{id:`date`,label:`A date from today`,note:`Counted from today, the same number of days ahead on each replay, so a day that has passed is never clicked.`},{id:`any`,label:`Any free one`,note:`Each replay clicks the first control of this kind there that is not greyed out (an open slot); later checks compare with what it picked.`}],H={label:`As clicked`,note:`The workflow clicks exactly this one.`},U={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function W(e){let t=await f.editStep(e);await f.editStep({...e,version:t.version})}var Se=[{id:`check_text`,label:`Check a control shows a text`,control:!0,text:`need`},{id:`check_present`,label:`Check a control is there`,control:!0},{id:`wait_for`,label:`Wait for a control`,control:!0,text:`may`},{id:`wait_gone`,label:`Wait until a control is gone`,control:!0},{id:`wait`,label:`Wait some seconds`,control:!1},{id:`keys`,label:`Press keys`,control:!1}];function Ce({step:e,blocks:t,secrets:n,unset:i,onAdd:a}){let[o,s]=(0,F.useState)(t[0]?.id??``),c=t.find(e=>e.id===o)??t[0],[l,u]=(0,F.useState)(()=>R(c,n)),[d,f]=(0,F.useState)(!1);return c?d?(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 border-t border-line-soft p-4`,onSubmit:e=>{e.preventDefault(),z(c,l)&&a(c.id,B(l))},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`Or put in a block after step `,e.n]}),(0,I.jsx)(r,{size:`sm`,"aria-label":`The block to put in after step ${e.n}`,value:c.id,onChange:e=>{s(e.target.value),u(R(t.find(t=>t.id===e.target.value),n))},children:t.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.section?`${e.section} › `:``,e.name,` · `,e.steps,` `,e.steps===1?`step`:`steps`]},e.id))}),(0,I.jsx)(ye,{block:c}),(0,I.jsx)(V,{block:c,secrets:n,use:l,onChange:u,unset:i}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Its steps go in after this one, marked as the block's; its test data become variables of this workflow.`}),(0,I.jsxs)(g,{type:`submit`,size:`sm`,variant:`accent`,disabled:!z(c,l),className:`self-start`,"data-tip":`Put the block in after this step`,children:[(0,I.jsx)(O,{"aria-hidden":`true`}),`Add`]})]}):(0,I.jsx)(`div`,{className:`border-t border-line-soft px-4 py-2`,children:(0,I.jsxs)(g,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),"data-tip":`Put a saved block of this app in after step ${e.n}`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Put in a block instead`]})}):null}function we({f:e,block:t,secrets:n,unset:r,busy:i,onUpdate:a}){let[o,s]=(0,F.useState)(!1),[c,u]=(0,F.useState)({values:{},secrets:{}});return(0,I.jsxs)(`div`,{role:`status`,className:l(_.info,`flex flex-col gap-2`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` are `,e.version?`version ${e.version}`:`an older version`,` of the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),`; version `,e.latest,` is saved now.`]}),(0,I.jsxs)(g,{size:`sm`,disabled:i,onClick:()=>void a(o?B(c):void 0).then(e=>{!e&&t?.inputs.length&&s(!0)}),"data-tip":`Put the saved version in their place, with the same values`,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),o?`Update with these`:`Update`]})]}),o&&t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Not every value of the old copy could be found: give the ones it needs. Empty ones keep the old copy's or the block's own.`}),(0,I.jsx)(V,{block:t,secrets:n,use:c,onChange:u,disabled:i,unset:r})]})]})}function Te({blocks:e,busy:t,act:n}){let[r,o]=(0,F.useState)(null),[s,u]=(0,F.useState)(null);return e.length?(0,I.jsx)(P,{level:3,icon:j,title:`Blocks of this app`,className:`gap-2`,children:(0,I.jsx)(`ul`,{className:l(a,`m-0 flex list-none flex-col p-0`),children:e.map((e,a)=>(0,I.jsxs)(`li`,{className:l(`flex flex-col gap-2 px-4 py-2`,a>0&&`border-t border-line-soft`),children:[r?.id===e.id?(0,I.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:t=>{t.preventDefault(),n(async()=>(await p.updateBlock(e.id,{name:r.name,section:r.section}),o(null),`The block "${r.name}" is saved as a new version.`))},children:[(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Name`,(0,I.jsx)(i,{size:`sm`,value:r.name,maxLength:80,onChange:e=>o({...r,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Section`,(0,I.jsx)(i,{size:`sm`,value:r.section,maxLength:40,onChange:e=>o({...r,section:e.target.value})})]}),(0,I.jsxs)(g,{type:`submit`,size:`sm`,variant:`primary`,disabled:t||!r.name.trim(),"data-tip":`Save the block as a new version`,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),`Save`]}),(0,I.jsxs)(g,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>o(null),children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Cancel`]})]}):(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col`,children:[(0,I.jsxs)(`span`,{className:`text-body-sm font-medium text-ink [overflow-wrap:anywhere]`,children:[e.section?`${e.section} › `:``,e.name,` `,(0,I.jsxs)(`span`,{className:`font-normal text-muted`,children:[`v`,e.version,` · `,c(e.steps,`step`)]})]}),e.inputs.length>0&&(0,I.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Takes `,e.inputs.map(e=>`${e.label||e.name}${e.kind===`data`?``:` (secret)`}`).join(`, `)]}),(0,I.jsx)(ye,{block:e})]}),(0,I.jsx)(g,{size:`icon`,variant:`icon`,disabled:t,"aria-label":`Change the block ${e.name}`,"data-tip":`Change the block ${e.name}`,onClick:()=>o({id:e.id,name:e.name,section:e.section??``}),className:`size-8`,children:(0,I.jsx)(te,{"aria-hidden":`true`})}),(0,I.jsx)(g,{size:`icon`,variant:`icon`,disabled:t,"aria-label":s?.id===e.id?`Delete the block ${e.name} anyway`:`Delete the block ${e.name}`,"data-tip":s?.id===e.id?`Delete it anyway`:`Delete the block ${e.name}`,onClick:()=>n(async()=>{try{await p.deleteBlock(e.id,s?.id===e.id)}catch(t){let n=t;if(n.status!==409)throw n;u({id:e.id,why:n.message});return}return u(null),`The block "${e.name}" is deleted; the steps workflows have of it stay.`}),className:`size-8`,children:(0,I.jsx)(ee,{"aria-hidden":`true`})})]}),s?.id===e.id&&(0,I.jsxs)(`p`,{className:l(_.warn,`m-0`),children:[s.why,` Click delete again to delete it anyway.`]})]},e.id))})}):null}function Ee({history:e,busy:t,onPreview:n,onBack:r}){let[i,o]=(0,F.useState)(null);return e.length?(0,I.jsxs)(P,{level:3,icon:k,title:`Earlier versions`,className:`gap-2`,children:[(0,I.jsx)(`ol`,{className:l(a,`m-0 flex list-none flex-col p-0`),children:e.slice(0,10).map((e,r)=>(0,I.jsxs)(`li`,{className:l(`flex items-center gap-4 px-4 py-2`,r>0&&`border-t border-line-soft`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 text-body-sm text-ink-2`,children:[`Before the change of `,pe(e.at)||e.name.slice(0,19)]}),(0,I.jsxs)(g,{size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void n(e.name).then(t=>t&&o({name:e.name,...t})),"data-tip":`See what going back to this version changes`,children:[(0,I.jsx)(M,{"aria-hidden":`true`}),`Go back`]})]},e.name))}),i&&(0,I.jsxs)(`div`,{role:`status`,className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`flex flex-col gap-2`),children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm font-medium`,children:`Going back changes this:`}),(0,I.jsx)(`pre`,{className:l(`overflow-auto rounded-base bg-surface-muted p-4 font-mono text-body-sm leading-relaxed whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,`m-0 max-h-[240px]`),children:i.diff.join(`
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-9BkoTWUE.js";import{I as r,P as i,c as a,i as o,z as s}from"./surface-c1kG1KPS.js";import{n as c,t as l}from"./utils-DJRAScIl.js";import{t as u}from"./jsx-runtime-LKYXHABd.js";import{W as d}from"./palette-C8W4Fd5n.js";import{T as f,X as p,b as m}from"./api-CorvgyDj.js";import{A as h,F as g,L as _,O as v,T as y,d as b,i as x,k as S}from"./pageBack-DDAAmq4R.js";import{Cr as ee,Gr as C,Hr as w,In as te,Lr as ne,N as T,Rn as E,Sn as D,Vn as O,Wr as re,Wt as k,a as A,f as j,ln as ie,lt as M,tt as ae,vn as oe,w as N,z as se}from"./line-icons-Cwj9OmCz.js";import{Ht as ce,J as le,On as ue,Vt as de,Y as fe,Z as pe}from"./frame-BC1vOowF.js";import{J as P,Y as me}from"./index-BoFziUZw.js";import{o as he}from"./dataParts-CVXmPBpU.js";var F=e(t(),1),I=u(),ge={click:[`target`,`timeout`,`note`],double_click:[`target`,`timeout`,`note`],type:[`target`,`text`,`timeout`,`note`],select:[`target`,`value`,`timeout`,`note`],keys:[`keys`,`note`],expect:[`target`,`text`,`timeout`,`note`],wait:[`seconds`,`note`],wait_for:[`target`,`text`,`timeout`,`note`],launch:[`timeout`,`note`],close:[`note`],expect_image:[`timeout`,`note`]};function _e({p:e}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:e.summary.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,I.jsx)(`pre`,{className:l(b,`m-0 max-h-[200px]`),children:e.diff.map((e,t)=>(0,I.jsx)(`span`,{className:l(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function L({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-body-sm font-medium`,children:[e,t]})}function ve({workflow:e,step:t,mode:n,onDone:r,onCancel:a}){let s=ge[t.op]??[`note`],c=t.fields??{},[u,d]=(0,F.useState)({automation_id:c.target?.automation_id??``,name:c.target?.name??``,control_type:c.target?.control_type??``}),[p,m]=(0,F.useState)(c.text??``),[h,v]=(0,F.useState)(c.value??``),[y,b]=(0,F.useState)(c.keys??``),[x,S]=(0,F.useState)(c.seconds===void 0?``:String(c.seconds)),[w,ne]=(0,F.useState)(c.timeout===void 0?``:String(c.timeout)),[T,E]=(0,F.useState)(c.note??``),[D,O]=(0,F.useState)(null),[re,k]=(0,F.useState)(``),[A,j]=(0,F.useState)(!1),ie=()=>{let e={};return s.includes(`target`)&&(u.automation_id!==(c.target?.automation_id??``)||u.name!==(c.target?.name??``)||u.control_type!==(c.target?.control_type??``))&&(e.target=u),s.includes(`text`)&&p!==(c.text??``)&&(e.text=p),s.includes(`value`)&&h!==(c.value??``)&&(e.value=h),s.includes(`keys`)&&y!==(c.keys??``)&&(e.keys=y),s.includes(`seconds`)&&x!==(c.seconds===void 0?``:String(c.seconds))&&(e.seconds=Number(x)),s.includes(`timeout`)&&w!==(c.timeout===void 0?``:String(c.timeout))&&w.trim()&&(e.timeout=Number(w)),s.includes(`note`)&&T!==(c.note??``)&&(e.note=T),e},M=async i=>{j(!0),k(``);try{let a=await f.editStep({workflow:e,step:t.n,action:n,...n===`edit`?{fields:ie()}:{},...i?{version:i}:{}});a.written?r():O(a)}catch(e){k(e.message)}finally{j(!1)}};(0,F.useEffect)(()=>{n===`remove`&&M()},[]);let ae=()=>O(null);return(0,I.jsxs)(`div`,{className:l(o,`mb-2 ml-10 flex flex-col gap-4`),children:[n===`edit`&&!D&&(0,I.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2`,children:[s.includes(`target`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{label:`Control's name`,children:(0,I.jsx)(i,{size:`sm`,value:u.name,maxLength:300,onChange:e=>(d({...u,name:e.target.value}),ae())})}),(0,I.jsx)(L,{label:`Automation id`,children:(0,I.jsx)(i,{size:`sm`,value:u.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...u,automation_id:e.target.value}),ae()),className:`font-mono text-body-sm`})}),(0,I.jsx)(L,{label:`Control type`,children:(0,I.jsx)(i,{size:`sm`,value:u.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...u,control_type:e.target.value}),ae())})})]}),s.includes(`text`)&&(0,I.jsx)(L,{label:t.op===`type`?`Text to type`:`Text it shows`,children:(0,I.jsx)(i,{size:`sm`,value:p,maxLength:500,onChange:e=>m(e.target.value)})}),s.includes(`value`)&&(0,I.jsx)(L,{label:`Item to choose`,children:(0,I.jsx)(i,{size:`sm`,value:h,maxLength:500,onChange:e=>v(e.target.value)})}),s.includes(`keys`)&&(0,I.jsx)(L,{label:`Keys`,children:(0,I.jsx)(i,{size:`sm`,value:y,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>b(e.target.value),className:`font-mono text-body-sm`})}),s.includes(`seconds`)&&(0,I.jsx)(L,{label:`Wait (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:x,onChange:e=>S(e.target.value)})}),s.includes(`timeout`)&&(0,I.jsx)(L,{label:`Timeout (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:w,placeholder:`default`,onChange:e=>ne(e.target.value)})}),s.includes(`note`)&&(0,I.jsx)(L,{label:`Note`,children:(0,I.jsx)(i,{size:`sm`,value:T,maxLength:200,onChange:e=>E(e.target.value)})})]}),n===`remove`&&!D&&!re&&(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Working out the change…`}),D&&(0,I.jsx)(_e,{p:D}),re&&(0,I.jsx)(`p`,{role:`alert`,className:l(_.fail,`m-0`),children:re}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[D?(0,I.jsxs)(g,{busy:A,size:`sm`,variant:n===`remove`?`destructive`:`primary`,disabled:A,onClick:()=>void M(D.version),children:[n===`remove`?(0,I.jsx)(ee,{"aria-hidden":`true`}):(0,I.jsx)(N,{"aria-hidden":`true`}),A?`Saving…`:n===`remove`?`Delete step ${t.n}`:`Save the change`]}):n===`edit`&&(0,I.jsx)(g,{busy:A,size:`sm`,variant:`primary`,disabled:A||!Object.keys(ie()).length,onClick:()=>void M(),children:A?`Checking…`:`Preview the change`}),D&&n===`edit`&&(0,I.jsxs)(g,{size:`sm`,onClick:()=>O(null),children:[(0,I.jsx)(te,{"aria-hidden":`true`}),`Change it more`]}),(0,I.jsxs)(g,{size:`sm`,variant:`outline`,onClick:a,children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Cancel`]})]})]})}function R(e,t){let n={values:{},secrets:{}};for(let r of e?.inputs??[])r.kind!==`data`&&r.env&&t.includes(r.env)&&(n.secrets[r.name]=r.env);return n}function z(e,t){return(e?.inputs??[]).every(e=>e.kind===`data`?e.default!==void 0||!!t.values[e.name]?.trim():!!t.secrets[e.name])}function B(e){return{values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e.trim())),secrets:e.secrets}}function V({block:e,secrets:t,use:n,onChange:a,disabled:o,unset:s=[]}){return e.inputs.length?(0,I.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-2 border-0 p-0`,children:[(0,I.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-ink-2`,children:`What the block types`}),e.inputs.map(e=>{let c=e.label||e.name;return e.kind===`data`?(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsx)(`span`,{className:`text-muted`,children:`(test data)`}),(0,I.jsx)(i,{value:n.values[e.name]??``,maxLength:300,disabled:o,placeholder:e.default===void 0?`A value`:e.default||`(empty)`,onChange:t=>a({...n,values:{...n.values,[e.name]:t.target.value}})})]},e.name):(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.kind===`totp`?`authenticator secret`:`secret`,`)`]}),(0,I.jsxs)(r,{value:n.secrets[e.name]??``,disabled:o||!t.length,onChange:t=>a({...n,secrets:{...n.secrets,[e.name]:t.target.value}}),children:[(0,I.jsx)(`option`,{value:``,children:t.length?`Pick a saved secret`:`No saved secrets yet`}),t.map(e=>(0,I.jsxs)(`option`,{value:e,children:[e,s.includes(e)?` (no value here)`:``]},e))]}),n.secrets[e.name]&&s.includes(n.secrets[e.name])&&(0,I.jsxs)(`span`,{className:`text-warn`,children:[n.secrets[e.name],` has no value on this computer: save it in Settings › Secrets, or the step that types it fails.`]}),!t.length&&(0,I.jsx)(`span`,{className:`text-muted`,children:`Save one in Settings › Secrets, then come back.`}),e.env&&!t.includes(e.env)&&(0,I.jsxs)(`span`,{className:`text-muted`,children:[`The block was made with `,e.env,`, which has no saved value here.`]})]},e.name)})]}):null}function ye({block:e}){return e.lines.length?(0,I.jsxs)(`details`,{className:`text-body-sm text-ink-2`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer select-none text-muted`,children:[`See its `,e.steps,` `,e.steps===1?`step`:`steps`]}),(0,I.jsxs)(`ol`,{className:`m-0 mt-1 flex list-decimal flex-col gap-1 pl-6`,children:[e.lines.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t)),e.steps>e.lines.length&&(0,I.jsxs)(`li`,{className:`list-none text-muted`,children:[`and `,e.steps-e.lines.length,` more`]})]})]}):null}var be=[`steps`,`data`,`run`],xe=[{id:`typed`,label:`As typed`,note:`The workflow types exactly this.`},{id:`data`,label:`Test data`,note:`A named value the replay fills in: its own value, a row of a data file, or one you give when it runs.`},{id:`secret`,label:`Secret`,note:`Read from an environment variable when it replays; what was typed leaves the workflow.`},{id:`unique`,label:`New on each run`,note:`A fresh value each time, like this one: for an email or a name that must not repeat.`},{id:`date`,label:`A date from today`,note:`Counted from today, the same number of days ahead on each replay, so a day that has passed is never clicked.`},{id:`any`,label:`Any free one`,note:`Each replay clicks the first control of this kind there that is not greyed out (an open slot); later checks compare with what it picked.`}],H={label:`As clicked`,note:`The workflow clicks exactly this one.`},U={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function W(e){let t=await f.editStep(e);await f.editStep({...e,version:t.version})}var Se=[{id:`check_text`,label:`Check a control shows a text`,control:!0,text:`need`},{id:`check_present`,label:`Check a control is there`,control:!0},{id:`wait_for`,label:`Wait for a control`,control:!0,text:`may`},{id:`wait_gone`,label:`Wait until a control is gone`,control:!0},{id:`wait`,label:`Wait some seconds`,control:!1},{id:`keys`,label:`Press keys`,control:!1}];function Ce({step:e,blocks:t,secrets:n,unset:i,onAdd:a}){let[o,s]=(0,F.useState)(t[0]?.id??``),c=t.find(e=>e.id===o)??t[0],[l,u]=(0,F.useState)(()=>R(c,n)),[d,f]=(0,F.useState)(!1);return c?d?(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 border-t border-line-soft p-4`,onSubmit:e=>{e.preventDefault(),z(c,l)&&a(c.id,B(l))},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`Or put in a block after step `,e.n]}),(0,I.jsx)(r,{size:`sm`,"aria-label":`The block to put in after step ${e.n}`,value:c.id,onChange:e=>{s(e.target.value),u(R(t.find(t=>t.id===e.target.value),n))},children:t.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.section?`${e.section} › `:``,e.name,` · `,e.steps,` `,e.steps===1?`step`:`steps`]},e.id))}),(0,I.jsx)(ye,{block:c}),(0,I.jsx)(V,{block:c,secrets:n,use:l,onChange:u,unset:i}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Its steps go in after this one, marked as the block's; its test data become variables of this workflow.`}),(0,I.jsxs)(g,{type:`submit`,size:`sm`,variant:`accent`,disabled:!z(c,l),className:`self-start`,"data-tip":`Put the block in after this step`,children:[(0,I.jsx)(O,{"aria-hidden":`true`}),`Add`]})]}):(0,I.jsx)(`div`,{className:`border-t border-line-soft px-4 py-2`,children:(0,I.jsxs)(g,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),"data-tip":`Put a saved block of this app in after step ${e.n}`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Put in a block instead`]})}):null}function we({f:e,block:t,secrets:n,unset:r,busy:i,onUpdate:a}){let[o,s]=(0,F.useState)(!1),[c,u]=(0,F.useState)({values:{},secrets:{}});return(0,I.jsxs)(`div`,{role:`status`,className:l(_.info,`flex flex-col gap-2`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` are `,e.version?`version ${e.version}`:`an older version`,` of the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),`; version `,e.latest,` is saved now.`]}),(0,I.jsxs)(g,{size:`sm`,disabled:i,onClick:()=>void a(o?B(c):void 0).then(e=>{!e&&t?.inputs.length&&s(!0)}),"data-tip":`Put the saved version in their place, with the same values`,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),o?`Update with these`:`Update`]})]}),o&&t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Not every value of the old copy could be found: give the ones it needs. Empty ones keep the old copy's or the block's own.`}),(0,I.jsx)(V,{block:t,secrets:n,use:c,onChange:u,disabled:i,unset:r})]})]})}function Te({blocks:e,busy:t,act:n}){let[r,o]=(0,F.useState)(null),[s,u]=(0,F.useState)(null);return e.length?(0,I.jsx)(P,{level:3,icon:j,title:`Blocks of this app`,className:`gap-2`,children:(0,I.jsx)(`ul`,{className:l(a,`m-0 flex list-none flex-col p-0`),children:e.map((e,a)=>(0,I.jsxs)(`li`,{className:l(`flex flex-col gap-2 px-4 py-2`,a>0&&`border-t border-line-soft`),children:[r?.id===e.id?(0,I.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:t=>{t.preventDefault(),n(async()=>(await p.updateBlock(e.id,{name:r.name,section:r.section}),o(null),`The block "${r.name}" is saved as a new version.`))},children:[(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Name`,(0,I.jsx)(i,{size:`sm`,value:r.name,maxLength:80,onChange:e=>o({...r,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Section`,(0,I.jsx)(i,{size:`sm`,value:r.section,maxLength:40,onChange:e=>o({...r,section:e.target.value})})]}),(0,I.jsxs)(g,{type:`submit`,size:`sm`,variant:`primary`,disabled:t||!r.name.trim(),"data-tip":`Save the block as a new version`,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),`Save`]}),(0,I.jsxs)(g,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>o(null),children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Cancel`]})]}):(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col`,children:[(0,I.jsxs)(`span`,{className:`text-body-sm font-medium text-ink [overflow-wrap:anywhere]`,children:[e.section?`${e.section} › `:``,e.name,` `,(0,I.jsxs)(`span`,{className:`font-normal text-muted`,children:[`v`,e.version,` · `,c(e.steps,`step`)]})]}),e.inputs.length>0&&(0,I.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Takes `,e.inputs.map(e=>`${e.label||e.name}${e.kind===`data`?``:` (secret)`}`).join(`, `)]}),(0,I.jsx)(ye,{block:e})]}),(0,I.jsx)(g,{size:`icon`,variant:`icon`,disabled:t,"aria-label":`Change the block ${e.name}`,"data-tip":`Change the block ${e.name}`,onClick:()=>o({id:e.id,name:e.name,section:e.section??``}),className:`size-8`,children:(0,I.jsx)(te,{"aria-hidden":`true`})}),(0,I.jsx)(g,{size:`icon`,variant:`icon`,disabled:t,"aria-label":s?.id===e.id?`Delete the block ${e.name} anyway`:`Delete the block ${e.name}`,"data-tip":s?.id===e.id?`Delete it anyway`:`Delete the block ${e.name}`,onClick:()=>n(async()=>{try{await p.deleteBlock(e.id,s?.id===e.id)}catch(t){let n=t;if(n.status!==409)throw n;u({id:e.id,why:n.message});return}return u(null),`The block "${e.name}" is deleted; the steps workflows have of it stay.`}),className:`size-8`,children:(0,I.jsx)(ee,{"aria-hidden":`true`})})]}),s?.id===e.id&&(0,I.jsxs)(`p`,{className:l(_.warn,`m-0`),children:[s.why,` Click delete again to delete it anyway.`]})]},e.id))})}):null}function Ee({history:e,busy:t,onPreview:n,onBack:r}){let[i,o]=(0,F.useState)(null);return e.length?(0,I.jsxs)(P,{level:3,icon:k,title:`Earlier versions`,className:`gap-2`,children:[(0,I.jsx)(`ol`,{className:l(a,`m-0 flex list-none flex-col p-0`),children:e.slice(0,10).map((e,r)=>(0,I.jsxs)(`li`,{className:l(`flex items-center gap-4 px-4 py-2`,r>0&&`border-t border-line-soft`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 text-body-sm text-ink-2`,children:[`Before the change of `,pe(e.at)||e.name.slice(0,19)]}),(0,I.jsxs)(g,{size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void n(e.name).then(t=>t&&o({name:e.name,...t})),"data-tip":`See what going back to this version changes`,children:[(0,I.jsx)(M,{"aria-hidden":`true`}),`Go back`]})]},e.name))}),i&&(0,I.jsxs)(`div`,{role:`status`,className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`flex flex-col gap-2`),children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm font-medium`,children:`Going back changes this:`}),(0,I.jsx)(`pre`,{className:l(`overflow-auto rounded-base bg-surface-muted p-4 font-mono text-body-sm leading-relaxed whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,`m-0 max-h-[240px]`),children:i.diff.join(`
2
2
  `)||`Nothing: the workflow is already that version.`}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(g,{size:`sm`,variant:`primary`,disabled:t,onClick:()=>(r(i.name,i.version),o(null)),"data-tip":`Write the workflow back at this version`,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),`Go back to it`]}),(0,I.jsxs)(g,{size:`sm`,variant:`outline`,onClick:()=>o(null),children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Cancel`]})]})]})]}):null}function De({steps:e,busy:t,onKeep:n}){let[o,s]=(0,F.useState)(2),[c,u]=(0,F.useState)(2),[d,f]=(0,F.useState)(``),[p,m]=(0,F.useState)(``),h=e.filter(e=>e.n>1);if(!h.length)return null;let _=h[h.length-1].n,v=Math.min(Math.max(o,2),_),y=Math.min(Math.max(c,v),_);return(0,I.jsxs)(`form`,{"aria-label":`Keep steps as a block`,className:l(a,`flex flex-wrap items-end gap-2`),onSubmit:e=>{e.preventDefault(),d.trim()&&n(v,y,d.trim(),p.trim()).then(e=>{e&&f(``)})},children:[(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Keep steps`,(0,I.jsx)(r,{value:v,onChange:e=>(s(Number(e.target.value)),u(Math.max(y,Number(e.target.value)))),className:`w-[84px]`,children:h.map(e=>(0,I.jsx)(`option`,{value:e.n,children:e.n},e.n))})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`to`,(0,I.jsx)(r,{value:y,onChange:e=>u(Number(e.target.value)),className:`w-[84px]`,children:h.filter(e=>e.n>=v).map(e=>(0,I.jsx)(`option`,{value:e.n,children:e.n},e.n))})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`as the block`,(0,I.jsx)(i,{value:d,maxLength:80,placeholder:`Sign in`,onChange:e=>f(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`in the section`,(0,I.jsx)(i,{value:p,maxLength:40,placeholder:`Account`,onChange:e=>m(e.target.value)})]}),(0,I.jsxs)(g,{type:`submit`,disabled:t||!d.trim(),"data-tip":`Keep these steps as a block of this app`,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),`Keep`]}),(0,I.jsx)(`span`,{className:`basis-full text-body-sm text-muted`,children:`Put it into other workflows of this app from a step's +. What it types becomes its inputs: test data, or a secret picked each time.`})]})}function Oe({step:e,onAdd:t}){let[n,a]=(0,F.useState)(`check_text`),o=e.fields?.target,[s,c]=(0,F.useState)({name:o?.name??``,automation_id:o?.automation_id??``,control_type:o?.control_type??``}),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(`2`),[p,m]=(0,F.useState)(``),h=Se.find(e=>e.id===n),_=h.control?!!(s.name.trim()||s.automation_id.trim())&&(h.text!==`need`||!!l.trim()):n===`wait`?Number(d)>0:!!p.trim();return(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 p-4`,onSubmit:e=>{e.preventDefault(),_&&t({kind:n,...h.control?{target:s}:{},...h.text&&l.trim()?{text:l}:{},...n===`wait`?{seconds:Number(d)}:{},...n===`keys`?{keys:p}:{}})},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`After step `,e.n]}),(0,I.jsx)(r,{size:`sm`,"aria-label":`What to add`,value:n,onChange:e=>a(e.target.value),children:Se.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))}),h.control&&(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Control's name`,(0,I.jsx)(i,{size:`sm`,value:s.name,maxLength:300,onChange:e=>c({...s,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Automation id`,(0,I.jsx)(i,{size:`sm`,value:s.automation_id,maxLength:300,spellCheck:!1,onChange:e=>c({...s,automation_id:e.target.value}),className:`font-mono text-body-sm`})]})]}),h.text&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[h.text===`need`?`The text it shows`:`Showing the text (optional)`,(0,I.jsx)(i,{size:`sm`,value:l,maxLength:500,placeholder:`Invoice saved`,onChange:e=>u(e.target.value)})]}),n===`wait`&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Seconds`,(0,I.jsx)(i,{size:`sm`,type:`number`,min:1,max:600,value:d,onChange:e=>f(e.target.value)})]}),n===`keys`&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Keys`,(0,I.jsx)(i,{size:`sm`,value:p,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>m(e.target.value),className:`font-mono text-body-sm`})]}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`The control is filled from this step's; change it for another. A wait for a control is better than a fixed wait.`}),(0,I.jsxs)(g,{type:`submit`,size:`sm`,variant:`accent`,disabled:!_,className:`self-start`,children:[(0,I.jsx)(O,{"aria-hidden":`true`}),`Add`]})]})}var G=e=>e.name||e.automation_id||`the control`;function ke({pictures:e,step:t,busy:n,onPick:r}){let[i,a]=(0,F.useState)(0),o=e[Math.min(i,e.length-1)],[s,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(``),[p,m]=(0,F.useState)(null);(0,F.useEffect)(()=>{let e=!1;return c(``),d(``),m(null),f.shot(o.run,o.n).then(t=>!e&&c(t),t=>!e&&d(t.message)),f.controls(o.run,o.n).then(t=>!e&&m(t),()=>{}),()=>{e=!0}},[o.run,o.n]);let h=(e,t)=>`${Math.max(0,Math.min(100,e/t*100))}%`,[g,_]=(0,F.useState)(!1),v=p&&p.w>0?p.controls.toSorted((e,t)=>t.w*t.h-e.w*e.h):[];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 pr-4 pb-4 pl-4 sm:pl-20`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.length>1&&(0,I.jsx)(le,{label:`Pictures of step ${t}`,value:String(i),onChange:e=>a(Number(e)),options:e.map((e,t)=>({id:String(t),label:e.label}))}),(0,I.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[o.note,v.length>0?` Click a control to check that it shows its text, or that it is there.`:``]})]}),u&&(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:u}),!s&&!u&&(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Loading the picture…`}),s&&(0,I.jsxs)(`div`,{className:l(`rounded-base bg-surface-muted object-cover`,`relative w-full overflow-hidden`,g?`max-w-[360px]`:`max-w-[720px]`),style:v.length?{aspectRatio:`${p.w} / ${p.h}`}:void 0,children:[(0,I.jsx)(`img`,{src:s,alt:`The app after step ${t}, ${o.label.toLowerCase()}`,onLoad:e=>_(e.currentTarget.naturalHeight>e.currentTarget.naturalWidth),className:v.length?`absolute inset-0 size-full object-fill`:`block w-full`}),v.map((e,t)=>{let i=e.text?`Check ${G(e)} shows "${e.text}"`:`Check ${G(e)} is there`;return(0,I.jsx)(`button`,{type:`button`,disabled:n,"aria-label":i,"data-tip":i,onClick:()=>r({target:{...e.automation_id?{automation_id:e.automation_id}:{},...e.name?{name:e.name}:{},...e.control_type?{control_type:e.control_type}:{}},...e.text?{text:e.text}:{}}),className:`absolute cursor-pointer rounded-[3px] border-0 bg-transparent p-0 outline-none hover:bg-accent/15 hover:ring-2 hover:ring-accent focus-visible:bg-accent/15 focus-visible:ring-2 focus-visible:ring-accent`,style:{left:h(e.x,p.w),top:h(e.y,p.h),width:h(e.w,p.w),height:h(e.h,p.h)}},`${t}-${e.automation_id||e.name}`)})]})]})}function Ae({v:e,secrets:t,onSave:n,busy:a,mobile:o=!1}){let[s,c]=(0,F.useState)(e.as),[l,u]=(0,F.useState)(e.name??``),[d,f]=(0,F.useState)(e.value??``);(0,F.useEffect)(()=>{c(e.as),u(e.name??``),f(e.value??``)},[e]);let p=[`click`,`double_click`,`tap`,`double_tap`].includes(e.op),m=xe.filter(t=>e.choices?e.choices.includes(t.id):t.id!==`date`&&t.id!==`any`&&t.id!==`unique`&&(e.op===`type`||t.id!==`secret`)),h=s===`data`||s===`secret`||p&&s!==`typed`,_=s!==e.as||h&&l!==(e.name??``)||!p&&d!==(e.value??``),v=h?s===`secret`?/^[A-Z_][A-Z0-9_]{0,63}$/.test(l):/^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(l):s===`typed`||p||d.trim()!==``,y=e=>p&&e===`typed`?H.label:xe.find(t=>t.id===e)?.label,b=p&&s===`typed`?H.note:xe.find(e=>e.id===s)?.note;return(0,I.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 border-t border-line-soft px-4 py-2 first:border-t-0`,children:[(0,I.jsx)(`span`,{className:`w-6 flex-none pt-2 text-right font-mono text-body-sm text-muted tabular-nums`,children:e.n}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col pt-2`,children:[(0,I.jsx)(`span`,{className:`text-body-sm text-ink [overflow-wrap:anywhere]`,children:e.line}),(0,I.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:b})]}),(0,I.jsxs)(`span`,{className:`flex flex-[1_1_360px] flex-wrap items-center gap-2`,children:[(0,I.jsx)(r,{"aria-label":`Where the value of step ${e.n} comes from`,value:s,disabled:a,onChange:e=>c(e.target.value),className:`w-[150px] flex-none`,children:m.map(e=>(0,I.jsx)(`option`,{value:e.id,children:y(e.id)},e.id))}),h&&(0,I.jsx)(i,{"aria-label":s===`secret`?`The secret's environment variable`:`The test data's name`,value:l,maxLength:64,spellCheck:!1,list:s===`secret`?`desktop-secrets`:void 0,placeholder:s===`secret`?`BILLING_PASSWORD`:p?s===`date`?`date`:`slot`:`customer`,onChange:e=>u(s===`secret`?e.target.value.toUpperCase():e.target.value),className:`w-[170px] flex-none font-mono text-body-sm`}),s!==`secret`&&!p&&(0,I.jsx)(i,{"aria-label":s===`data`?`Its value`:s===`date`?`The date (counted from today)`:`The value`,value:d,maxLength:500,onChange:e=>f(e.target.value),className:`min-w-[140px] flex-1`}),s===`secret`&&!t.includes(l)&&l&&(0,I.jsxs)(`span`,{className:`text-body-sm text-warn`,children:[`Not in `,o?`mobile.secrets`:`desktop.secrets`,` yet`]}),(0,I.jsxs)(g,{size:`sm`,variant:`primary`,disabled:a||!_||!v,onClick:()=>n(s,h?l:void 0,s===`secret`||p?void 0:d),children:[(0,I.jsx)(N,{"aria-hidden":`true`}),`Save`]})]}),(0,I.jsx)(`datalist`,{id:`desktop-secrets`,children:t.map(e=>(0,I.jsx)(`option`,{value:e},e))})]})}function je({view:e,job:t,rows:n,onRun:o,busy:s,heal:u}){let[d,p]=(0,F.useState)(()=>Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),[m,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(u),[b,ee]=(0,F.useState)(!1),C=e.lastRun,w=m.startsWith(`file:`)?{file:m.slice(5)}:m.startsWith(`request:`)?{request:m.slice(8)}:void 0,te=t&&t.kind===`replay`&&t.target===e.workflow.path;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Replay plays the steps in the app with no model, as a scheduled run or CI will, and takes over the mouse and keyboard while it runs: use a test machine and a test account.`}),(0,I.jsxs)(`form`,{className:l(a,`flex flex-col gap-4`),onSubmit:e=>{e.preventDefault(),o({variables:d,...w?{rows:w}:{},heal:v,updateBaselines:b})},children:[e.variables.length>0&&(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-4`,children:e.variables.map(e=>(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[e.name,(0,I.jsx)(i,{value:d[e.name]??``,onChange:t=>p({...d,[e.name]:t.target.value})})]},e.name))}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,I.jsxs)(`label`,{className:`flex min-w-[220px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Test data`,(0,I.jsxs)(r,{value:m,onChange:e=>_(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`Once, with the values above`}),n.files.map(e=>(0,I.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),n.requests.map(e=>(0,I.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})]}),(0,I.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-body-sm text-ink-2`,children:[(0,I.jsx)(ue,{checked:v,onChange:y,label:`Heal a step whose control moved`}),`Heal a moved control`]}),(0,I.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-body-sm text-ink-2`,children:[(0,I.jsx)(ue,{checked:b,onChange:ee,label:`Take new image baselines`}),`New image baselines`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(g,{type:`submit`,variant:`primary`,disabled:s,children:[(0,I.jsx)(E,{"aria-hidden":`true`}),`Replay`]})]})]}),te&&(0,I.jsx)(he,{job:t,onStop:()=>void f.stop(),words:U}),C?(0,I.jsx)(P,{id:`desktop-last-run`,level:3,icon:E,title:`Last replay`,className:`gap-2`,children:(0,I.jsxs)(`div`,{className:l(a,`flex flex-wrap items-center gap-4 text-body-sm`),children:[(0,I.jsx)(S,{tone:C.ok?`pass`:`fail`,children:C.many?`${C.many.passed} of ${C.many.total} passed`:C.ok?`Passed`:`Failed`}),(0,I.jsxs)(`span`,{className:`text-muted`,children:[pe(C.at),` · `,c(e.replays,`replay`),` in all`]}),C.failed&&(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px] text-body-sm text-fail [overflow-wrap:anywhere]`,children:[`Step `,C.failed.index,`: `,C.failed.error]}),(0,I.jsx)(`span`,{className:`flex-1`}),C.report&&(0,I.jsx)(x,{path:C.report,children:`Report`})]})}):(0,I.jsx)(h,{className:`py-4`,children:`Not replayed yet.`})]})}function K({workflow:e,onClose:t,backLabel:r=`Back`,notices:i,tab:a,onTab:o}){let[u,p]=(0,F.useState)(null),[b,x]=(0,F.useState)(``),[k,le]=(0,F.useState)(!1),[ue,pe]=(0,F.useState)(`steps`),P=o?be.includes(a??``)?a:`steps`:ue,he=e=>o?o(e):pe(e),[ge,_e]=(0,F.useState)(``),[L,R]=(0,F.useState)(`all`),[z,B]=(0,F.useState)(null),[V,xe]=(0,F.useState)(null),[H,U]=(0,F.useState)(null),[Se,G]=(0,F.useState)(``),[K,Me]=(0,F.useState)(null),[Ne,Pe]=(0,F.useState)({files:[],requests:[]}),[Fe,Ie]=(0,F.useState)(!0),q=(0,F.useCallback)(()=>{f.review(e).then(e=>{p(e),x(``)},e=>x(e.message))},[e]);(0,F.useEffect)(q,[q]);let J=(0,F.useCallback)(()=>{f.view().then(e=>{Me(e.job),Pe(e.rows),Ie(e.heal)},()=>{})},[]);(0,F.useEffect)(J,[J]);let Y=!!K?.running;(0,F.useEffect)(()=>{if(!Y)return;let e=ce(J,1e3);return()=>de(e)},[Y,J]);let Le=K&&!K.running?K.endedAt:``;(0,F.useEffect)(()=>{Le&&q()},[Le,q]);let X=async(e,t)=>{le(!0),x(``),G(``);try{await e(),q(),t&&G(t)}catch(e){x(e.message)}finally{le(!1)}},Re=e=>void m.start(e,{}).then(({id:e})=>location.hash=n(`chats`,e),e=>x(e.message));if(!u)return b?(0,I.jsx)(`p`,{role:`alert`,className:l(_.fail,`m-0`),children:b}):(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Opening the workflow…`});let Z=u.workflow.kind===`mobile`,Q=u.lastRun,ze=new Map((Q?.results??[]).map(e=>[e.n,e])),Be=!!Q&&Date.parse(u.workflow.modified)>Date.parse(Q.at),Ve=u.steps.filter(e=>e.op.startsWith(`expect`)).length,$=Q&&!Q.ok?Q.failed?.index??0:0,He=$?u.steps[$-1]:void 0,Ue=(Q?.results??[]).filter(e=>!e.ok).length,We=ge.toLowerCase().split(/\s+/).filter(Boolean),Ge=u.steps.filter(e=>We.every(t=>`${e.n} ${e.text} ${e.fields?.note||``}`.toLowerCase().includes(t))&&(L===`all`||(L===`checks`?e.op.startsWith(`expect`):ze.get(e.n)?.ok===!1))),Ke=e=>{he(`steps`),R(`all`),_e(``);let t=n=>requestAnimationFrame(()=>{let r=document.getElementById(`dstep-${e}`);r?r.scrollIntoView({block:`center`,behavior:s()}):n>0&&t(n-1)});t(30)},qe=e=>void X(async()=>{await f.replay({workflow:u.workflow.path,...e}),J()},Z?`Replaying on the device: a device cloud can take a minute or two to start it.`:`Replaying: the app opens on this computer.`),Je=[{id:`steps`,label:`Steps`,icon:ie,n:u.steps.length},{id:`data`,label:`Test data`,icon:ae,n:u.values.length},{id:`run`,label:`Last run`,icon:E}];return(0,I.jsxs)(`section`,{"aria-labelledby":`dreview-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-1 flex flex-col gap-4 border-b border-line bg-canvas px-1 py-4`,children:[t&&(0,I.jsx)(`div`,{children:(0,I.jsxs)(g,{size:`sm`,variant:`ghost`,onClick:t,className:`-ml-2 text-ink-2`,children:[(0,I.jsx)(A,{"aria-hidden":`true`}),r]})}),(0,I.jsx)(me,{id:`dreview-title`,icon:w,title:(0,I.jsx)(`span`,{"data-tip":u.workflow.name,children:u.workflow.name}),description:(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(`span`,{children:[u.workflow.app||`no app`,` · `,c(u.steps.length,`step`),` · `,c(Ve,`check`)]}),Y&&K?.target===u.workflow.path?(0,I.jsx)(S,{tone:`running`,children:`Replaying…`}):Q?(0,I.jsx)(S,{tone:Q.ok?`pass`:`fail`,children:Q.ok?`Last replay passed`:$?`Last replay failed at step ${$}`:`Last replay did not get through`}):(0,I.jsx)(S,{tone:`neutral`,icon:!1,children:`Not replayed yet`}),Be&&(0,I.jsx)(`span`,{children:`· you changed it since`})]}),actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(g,{onClick:()=>Re(`${Z?`Look at the mobile workflow`:`DeskPilot: look at the desktop workflow`} ${u.workflow.path} and tell me what to fix or add (a wait, a timeout, a dialog to dismiss, checks of the outcome); change it with desktop_edit_workflow only after showing me the change.`),"data-tip":Z?`Ask the agent to improve it`:`Ask DeskPilot to improve it`,children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Improve`]}),(0,I.jsxs)(g,{variant:`primary`,disabled:Y,onClick:()=>he(`run`),"data-tip":Y?`A replay is going`:`Replay it with no model`,children:[(0,I.jsx)(E,{"aria-hidden":`true`}),`Replay`]})]})})]}),i,b&&(0,I.jsx)(`p`,{role:`alert`,className:l(_.fail,`m-0`),children:b}),Se&&(0,I.jsx)(`p`,{role:`status`,className:l(_.pass,`m-0`),children:Se}),Q&&!Q.ok&&(0,I.jsxs)(`div`,{role:`alert`,className:l(_.fail,`flex flex-col gap-2`),children:[(0,I.jsxs)(`p`,{className:`m-0 font-medium text-fail`,children:[$?`Step ${$} failed`:`The replay did not get through`,Be&&(0,I.jsx)(`span`,{className:`font-normal text-ink-2`,children:` · before your last change`})]}),He&&(0,I.jsx)(`p`,{className:`m-0 font-medium text-ink [overflow-wrap:anywhere]`,children:He.text}),(0,I.jsx)(`p`,{className:`m-0 line-clamp-3 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:Q.failed?.error||Q.error||`It failed.`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[He&&(0,I.jsxs)(g,{size:`sm`,onClick:()=>Ke($),children:[(0,I.jsx)(M,{"aria-hidden":`true`}),`Show`]}),He&&$>1&&(0,I.jsxs)(g,{size:`sm`,onClick:()=>(Ke($),U({n:$,mode:`edit`})),"data-tip":`Change the failed step: its control, text or timeout`,children:[(0,I.jsx)(te,{"aria-hidden":`true`}),`Change`]}),(0,I.jsxs)(g,{size:`sm`,variant:`ghost`,onClick:()=>Re(`${Z?`The`:`DeskPilot: the`} last replay of ${u.workflow.path} failed${$?` at step ${$}`:``}. Read its report (${Q.dir}), tell me why, and offer a fix.`),children:[(0,I.jsx)(oe,{"aria-hidden":`true`}),`Ask why`]})]})]}),Q&&Q.ok&&Q.heals>0&&!Q.healsAccepted&&(0,I.jsxs)(`div`,{role:`status`,className:l(_.info,`flex flex-wrap items-center gap-4`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`The last replay found `,c(Q.heals,`moved control`),` and healed `,Q.heals===1?`it`:`them`,`: write the new locators into the workflow?`]}),(0,I.jsxs)(g,{size:`sm`,disabled:k,onClick:()=>void X(()=>f.acceptHeals(Q.dir),`The healed locators are in the workflow.`),children:[(0,I.jsx)(re,{"aria-hidden":`true`}),`Accept`]})]}),u.blocksStale?.map(e=>(0,I.jsx)(we,{f:e,block:u.blocks?.find(t=>t.id===e.block),secrets:u.blockSecrets??[],unset:u.unsetSecrets??[],busy:k,onUpdate:async t=>{let n=!1;return await X(async()=>{await W({workflow:u.workflow.path,step:e.from,action:`refresh_block`,block:e.block,...t||{}}),n=!0},`Steps ${e.from} to ${e.to} are version ${e.latest} of "${e.name}" now.`),n}},`stale-${e.block}-${e.from}`)),u.blocksFound?.map(e=>(0,I.jsxs)(`div`,{role:`status`,className:l(_.info,`flex flex-wrap items-center gap-4`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` do what the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),` does: mark them as the block's, and this workflow hears of its newer versions.`]}),(e=>e?(0,I.jsx)(`span`,{className:`basis-full`,children:(0,I.jsx)(ye,{block:e})}):null)(u.blocks?.find(t=>t.id===e.block)),(0,I.jsxs)(g,{size:`sm`,disabled:k,onClick:()=>void X(()=>W({workflow:u.workflow.path,step:e.from,action:`use_block`,block:e.block}),`Steps ${e.from} to ${e.to} are the block "${e.name}" now.`),"data-tip":`Mark these steps as the block's`,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),`Use`]})]},`found-${e.block}-${e.from}`)),(0,I.jsx)(fe,{prefix:`dreview`,label:`This workflow`,className:`mb-0`,current:P,onPick:he,tabs:Je.map(e=>({id:e.id,label:e.label,...e.n===void 0?{}:{n:e.n},...e.id===`run`&&Q?{n:Q.ok?(0,I.jsx)(T,{size:12,role:`img`,"aria-label":`passed`,className:`text-pass`}):(0,I.jsx)(se,{size:12,role:`img`,"aria-label":`failed`,className:`text-fail`})}:{}}))}),(0,I.jsxs)(`div`,{role:`tabpanel`,id:`dreview-panel-${P}`,"aria-labelledby":`dreview-${P}`,className:`flex min-w-0 flex-col gap-4`,children:[P===`steps`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(v,{id:`dreview-step-search`,label:`Find a step`,value:ge,onChange:_e}),(0,I.jsx)(y,{items:[{id:`all`,label:`All`,n:u.steps.length},{id:`checks`,label:`Checks`,n:Ve},...Ue?[{id:`failed`,label:`Failed`,n:Ue,alert:!0}]:[]],value:L,onChange:R})]}),Ve===0&&(0,I.jsx)(`p`,{className:l(_.warn,`m-0`),children:`No checks of the outcome: a replay passes when its steps run. Add one with + after the step whose result matters.`}),Ge.length===0?(0,I.jsx)(`p`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 text-body-sm text-muted`),children:`No step matches.`}):(0,I.jsx)(`ol`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0 [&>li:first-child]:rounded-t-base [&>li:last-child]:rounded-b-base`),children:Ge.map((e,t)=>{let n=ze.get(e.n),r=e.op.startsWith(`expect`),i=u.recorded?.shots[e.n],a=[...i&&u.recorded?[{label:`When recorded`,run:u.recorded.run,n:i,note:`The app after step ${e.n} as you recorded it.`}]:[],...n?.shot&&Q?[{label:`Last replay`,run:Q.dir,n:e.n,note:`The app after step ${e.n} on the last replay${Be?`, before your last change`:``}.`}]:[]];return(0,I.jsxs)(`li`,{id:`dstep-${e.n}`,className:l(`flex scroll-mt-48 flex-col`,t>0&&`border-t border-line-soft`,n&&!n.ok&&`bg-fail-soft`),children:[(0,I.jsxs)(`div`,{className:`group flex min-h-11 items-start gap-4 px-4 py-2`,children:[(0,I.jsx)(`span`,{className:`w-6 flex-none pt-1 text-right font-mono text-body-sm text-muted tabular-nums`,children:e.n}),(0,I.jsx)(`span`,{className:`flex w-4 flex-none justify-center pt-1`,children:n?n.ok?(0,I.jsx)(N,{size:14,strokeWidth:2.5,"aria-label":`Passed on the last replay`,className:`text-pass`}):(0,I.jsx)(C,{size:14,strokeWidth:2.5,"aria-label":`Failed on the last replay`,className:`text-fail`}):Q?(0,I.jsx)(D,{size:14,"aria-label":`Not replayed`,className:`text-muted`}):r?(0,I.jsx)(T,{size:14,"aria-hidden":`true`,className:`text-pass`}):(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1 size-1.5 rounded-full bg-line-strong`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[r&&(0,I.jsx)(S,{tone:`pass`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Check`}),e.op.startsWith(`wait`)&&(0,I.jsx)(S,{tone:`neutral`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Wait`}),(0,I.jsx)(`span`,{className:`min-w-0 text-body-sm text-ink [overflow-wrap:anywhere]`,children:e.text}),e.block&&(0,I.jsxs)(S,{tone:`neutral`,icon:!1,children:[(0,I.jsx)(j,{"aria-hidden":`true`,className:`size-[11px]`}),u.blocks?.find(t=>t.id===e.block)?.name||e.block]}),n?.healed&&(0,I.jsx)(S,{tone:`warn`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Healed`})]}),e.fields?.note&&(0,I.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Note: `,e.fields.note]}),n&&!n.ok&&n.error&&(0,I.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-fail [overflow-wrap:anywhere]`,"data-tip":n.error,children:n.error})]}),(0,I.jsxs)(`span`,{className:`relative flex flex-none items-center gap-1`,children:[(0,I.jsx)(g,{size:`icon`,variant:`icon`,disabled:k,"aria-haspopup":`dialog`,"aria-expanded":z===e.n,"aria-label":`Add a check, wait${u.blocks?.length?` or block`:``} after step ${e.n}`,"data-tip":`Add a check, wait${u.blocks?.length?` or block`:``} after step ${e.n}`,onClick:()=>B(z===e.n?null:e.n),className:`size-8`,children:(0,I.jsx)(O,{"aria-hidden":`true`})}),(0,I.jsxs)(d,{open:z===e.n,onClose:()=>B(null),label:`Add after step ${e.n}`,role:`dialog`,align:`end`,className:`w-[min(360px,calc(100vw-48px))]`,children:[(0,I.jsx)(Oe,{step:e,onAdd:t=>{B(null),X(()=>W({workflow:u.workflow.path,step:e.n,action:`insert`,...t}),`Added after step ${e.n}.`)}}),(u.blocks?.length??0)>0&&(0,I.jsx)(Ce,{step:e,blocks:u.blocks??[],secrets:u.blockSecrets??[],unset:u.unsetSecrets??[],onAdd:(t,n)=>{B(null),X(()=>W({workflow:u.workflow.path,step:e.n,action:`block`,block:t,...n}),`Put in the block after step ${e.n}.`)}})]}),a.length>0&&(0,I.jsx)(g,{size:`icon`,variant:`icon`,"aria-label":`See the app after step ${e.n}`,"aria-expanded":V===e.n,"data-tip":`See the app after step ${e.n}`,onClick:()=>xe(V===e.n?null:e.n),className:`size-8`,children:(0,I.jsx)(M,{"aria-hidden":`true`})}),(0,I.jsx)(g,{size:`icon`,variant:`icon`,"aria-label":`Change step ${e.n}`,"data-tip":`Change step ${e.n}`,onClick:()=>U({n:e.n,mode:`edit`}),className:`size-8`,children:(0,I.jsx)(te,{"aria-hidden":`true`})}),e.n>1&&(0,I.jsx)(g,{size:`icon`,variant:`icon`,"aria-label":`Drop step ${e.n}`,"data-tip":`Drop step ${e.n}`,onClick:()=>U({n:e.n,mode:`remove`}),className:`size-8`,children:(0,I.jsx)(ee,{"aria-hidden":`true`})})]})]}),H&&H.n===e.n&&(0,I.jsx)(`div`,{className:`pr-4`,children:(0,I.jsx)(ve,{workflow:u.workflow.path,step:e,mode:H.mode,onCancel:()=>U(null),onDone:()=>{G(H.mode===`remove`?`Step ${e.n} dropped.`:`Step ${e.n} changed.`),U(null),q()}},`${e.n}-${H.mode}`)}),V===e.n&&a.length>0&&(0,I.jsx)(ke,{pictures:a,step:e.n,busy:k,onPick:t=>void X(()=>W({workflow:u.workflow.path,step:e.n,action:`insert`,kind:t.text?`check_text`:`check_present`,target:t.target,...t.text?{text:t.text}:{}}),t.text?`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} shows "${t.text}".`:`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} is there.`)})]},`${e.n}-${e.text}`)})}),(0,I.jsx)(De,{steps:u.steps,busy:k,onKeep:async(e,t,n,r)=>{let i=!1;return await X(async()=>{await f.saveBlock(u.workflow.path,e,t,n,r),i=!0},`Kept steps ${e} to ${t} as the block "${n}": put it into other workflows of ${u.workflow.app} from a step's +.`),i}}),(0,I.jsx)(Te,{blocks:u.blocks??[],busy:k,act:e=>{let t;X(async()=>{t=await e()}).then(()=>t&&G(t))}}),(0,I.jsx)(Ee,{history:u.history??[],busy:k,onPreview:async e=>{x(``);try{let t=await f.restore(u.workflow.path,e);return{diff:t.diff,version:t.version}}catch(e){return x(e.message),null}},onBack:(e,t)=>void X(()=>f.restore(u.workflow.path,e,t),`The workflow is back at that version: the version before going back is kept too.`)})]}),P===`data`&&(u.values.length===0?(0,I.jsx)(h,{className:`py-4`,children:`Nothing is typed, chosen or clicked as data in this workflow, so it has no test data.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Where each value typed, chosen or clicked comes from when it replays. A slot or a day that cannot be used twice can be any free one or a date from today. Test data can come from a data file's rows on the Last run tab.`}),(0,I.jsx)(`ul`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0`),children:u.values.map(e=>(0,I.jsx)(Ae,{v:e,secrets:u.secrets,mobile:Z,busy:k,onSave:(t,n,r)=>void X(()=>W({workflow:u.workflow.path,step:e.n,action:`data`,as:t,...n===void 0?{}:{name:n},...r===void 0?{}:{value:r}}),t===`secret`?`Step ${e.n} types the secret ${n}; what was typed left the workflow.`:`Step ${e.n} saved.`)},e.n))})]})),P===`run`&&(0,I.jsx)(je,{view:u,job:K,rows:Z?{...Ne,requests:[]}:Ne,heal:Fe,busy:k||Y,onRun:qe})]})]})}export{z as a,R as i,V as n,B as o,ye as r,K as t};