assuremind 1.2.3 → 1.3.0

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.
@@ -886,7 +886,7 @@ to {
886
886
  * This source code is licensed under the ISC license.
887
887
  * See the LICENSE file in the root directory of this source tree.
888
888
  */const qe=I("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function Sy(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=Sy(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function P(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=Sy(e))&&(r&&(r+=" "),r+=t);return r}function Cy({size:e=40}){return s.jsx("img",{src:"/favicon.svg",alt:"Assuremind",width:e,height:e,style:{flexShrink:0,borderRadius:e*.22},draggable:!1})}function ww(){return s.jsxs("div",{className:"flex items-center gap-3 select-none min-w-0 px-1",children:[s.jsx(Cy,{size:46}),s.jsxs("div",{className:"flex flex-col justify-center leading-none min-w-0",children:[s.jsx("span",{className:"text-[20px] font-bold text-white truncate",style:{letterSpacing:"-0.02em"},children:"Assuremind"}),s.jsx("span",{className:"text-[9px] font-semibold text-slate-400 uppercase mt-1.5",style:{letterSpacing:"0.18em"},children:"Studio"})]})]})}function kw(){return s.jsxs("div",{className:"flex flex-col items-center gap-1 select-none",children:[s.jsx(Cy,{size:36}),s.jsx("span",{className:"text-[8px] font-bold text-white/70 whitespace-nowrap",style:{letterSpacing:"-0.01em"},children:"Assuremind"})]})}const Sw=[{to:"/",icon:X2,label:"Dashboard"},{to:"/story",icon:wt,label:"Smart Tests"},{to:"/tests",icon:dl,label:"Test Editor"},{to:"/run",icon:Dt,label:"Run Config"},{to:"/reports",icon:U2,label:"Reports"},{to:"/variables",icon:pw,label:"Variables"},{to:"/healing",icon:tc,label:"Self-Healing"},{to:"/git",icon:Lr,label:"Git Control Center"},{to:"/library",icon:Z2,label:"Step Library"},{to:"/ci-integration",icon:Ic,label:"CI/CD"},{to:"/docs",icon:cl,label:"Docs"},{to:"/settings",icon:nc,label:"Settings"}];function Cw({collapsed:e=!1,onToggle:t,mobileOpen:n=!1}){return s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-20 lg:hidden",onClick:t}),s.jsxs("aside",{className:P("fixed lg:relative z-30 flex flex-col h-full bg-sidebar text-white transition-all duration-300 ease-in-out flex-shrink-0",e?"w-[84px]":"w-[248px]",n?"translate-x-0":"-translate-x-full lg:translate-x-0"),children:[s.jsx("div",{className:P("flex items-center border-b border-white/[0.06] flex-shrink-0",e?"justify-center px-2 py-3":"px-3 py-4"),children:e?s.jsx(kw,{}):s.jsx(ww,{})}),s.jsx("nav",{className:P("flex-1 overflow-y-auto py-2 space-y-0.5 sidebar-nav-scroll",e?"px-2":"px-3"),style:{paddingTop:e?void 0:"0.75rem"},children:Sw.map(({to:r,icon:a,label:i})=>s.jsxs(Zj,{to:r,end:r==="/",className:({isActive:l})=>P("sidebar-item",l&&"active",e&&"justify-center !px-0"),title:e?i:void 0,children:[s.jsx(a,{size:18,className:"flex-shrink-0",strokeWidth:1.8}),!e&&s.jsx("span",{className:"truncate",children:i})]},r))}),s.jsx("button",{type:"button",onClick:t,className:P("hidden lg:flex items-center justify-center py-3.5","border-t border-white/[0.06] text-white/30 hover:text-white/70 transition-colors duration-200"),title:e?"Expand sidebar":"Collapse sidebar",children:e?s.jsx(Ht,{size:16}):s.jsx(B2,{size:16})})]})]})}function Ew(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1);return{collapsed:e,mobileOpen:n,toggle:()=>{t(i=>!i),r(i=>!i)}}}const Fm="/api",Pw=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,Ey=["chromium","firefox","webkit"],wd=e=>`assuremind:suppress:${e}`;let mi=null;const ux=new Set;function Op(){ux.forEach(e=>e())}const Rr={subscribe(e){return ux.add(e),()=>{ux.delete(e)}},getSnapshot(){return{activeModal:mi}},showModal(e){localStorage.getItem(wd(e))!=="1"&&(mi=e,Op())},dismiss(e){e&&mi&&localStorage.setItem(wd(mi),"1"),mi=null,Op()},isSuppressed(e){return localStorage.getItem(wd(e))==="1"}};function Rw(){const[e,t]=m.useState(Rr.getSnapshot);return m.useEffect(()=>Rr.subscribe(()=>t(Rr.getSnapshot())),[]),e}const zw=new Set(["AI_NOT_CONFIGURED","JIRA_NOT_CONFIGURED","XRAY_NOT_CONFIGURED"]);async function $(e,t){const n=(t==null?void 0:t.body)!==void 0,r=await fetch(`${Fm}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers},...t});if(!r.ok){const a=await r.text();if(r.status===422)try{const i=JSON.parse(a);if(i.featureHint&&zw.has(i.featureHint))throw Rr.showModal(i.featureHint),new Error("Configuration required — check the setup instructions in the dialog.")}catch(i){if(i instanceof Error&&i.message.startsWith("Configuration required"))throw i}throw new Error(`API ${(t==null?void 0:t.method)??"GET"} ${e} → ${r.status}: ${a}`)}if(r.status!==204)return r.json()}const Ga={get:()=>$("/config"),update:e=>$("/config",{method:"PUT",body:JSON.stringify(e)}),getAiProvider:()=>$("/ai-provider"),getMcpStatus:()=>$("/mcp/status")},Kr={list:e=>$(`/suites${e?`?type=${e}`:""}`),get:e=>$(`/suites/${e}`),create:e=>$("/suites",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>$(`/suites/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>$(`/suites/${e}`,{method:"DELETE"})},Wn={list:e=>$(`/suites/${e}/cases`),get:(e,t)=>$(`/suites/${e}/cases/${t}`),create:(e,t)=>$(`/suites/${e}/cases`,{method:"POST",body:JSON.stringify(t)}),update:(e,t,n)=>$(`/suites/${e}/cases/${t}`,{method:"PATCH",body:JSON.stringify(n)}),delete:(e,t)=>$(`/suites/${e}/cases/${t}`,{method:"DELETE"}),bulkDelete:(e,t)=>$(`/suites/${e}/cases/bulk-delete`,{method:"POST",body:JSON.stringify({ids:t})}),bulkMove:(e,t,n)=>$(`/suites/${e}/cases/bulk-move`,{method:"POST",body:JSON.stringify({ids:t,targetSuiteId:n})})},Wr={add:(e,t,n)=>$(`/suites/${e}/cases/${t}/steps`,{method:"POST",body:JSON.stringify(n)}),update:(e,t,n,r)=>$(`/suites/${e}/cases/${t}/steps/${n}`,{method:"PATCH",body:JSON.stringify(r)}),delete:(e,t,n)=>$(`/suites/${e}/cases/${t}/steps/${n}`,{method:"DELETE"}),generate:(e,t,n)=>$(`/suites/${e}/cases/${t}/steps/${n}/generate`,{method:"POST"}),generateAll:(e,t)=>$(`/suites/${e}/cases/${t}/steps/generate-all`,{method:"POST"}),reorder:(e,t,n)=>$(`/suites/${e}/cases/${t}/steps/reorder`,{method:"PATCH",body:JSON.stringify({stepIds:n})})},Vr={get:e=>$(`/suites/${e}/hooks`),addStep:(e,t,n)=>$(`/suites/${e}/hooks/${t}/steps`,{method:"POST",body:JSON.stringify(n)}),updateStep:(e,t,n,r)=>$(`/suites/${e}/hooks/${t}/steps/${n}`,{method:"PATCH",body:JSON.stringify(r)}),deleteStep:(e,t,n)=>$(`/suites/${e}/hooks/${t}/steps/${n}`,{method:"DELETE"}),reorderSteps:(e,t,n)=>$(`/suites/${e}/hooks/${t}/steps/reorder`,{method:"PATCH",body:JSON.stringify({stepIds:n})}),generateStep:(e,t,n)=>$(`/suites/${e}/hooks/${t}/steps/${n}/generate`,{method:"POST"}),generateAll:(e,t)=>$(`/suites/${e}/hooks/${t}/steps/generate-all`,{method:"POST"})},kd={getAll:()=>$("/variables"),getEnv:e=>$(`/variables/env/${e}`),set:(e,t)=>$(`/variables/${e}`,{method:"PUT",body:JSON.stringify({value:t})}),delete:e=>$(`/variables/${e}`,{method:"DELETE"})},Ws={list:()=>$("/healing"),pending:()=>$("/healing/pending"),stats:()=>$("/healing/stats"),accept:e=>$(`/healing/${e}/accept`,{method:"PATCH"}),reject:e=>$(`/healing/${e}/reject`,{method:"PATCH"}),acceptAll:()=>$("/healing/accept-all",{method:"POST"}),delete:e=>$(`/healing/${e}`,{method:"DELETE"}),deleteBulk:e=>$("/healing/delete-bulk",{method:"POST",body:JSON.stringify({ids:e})}),deleteAll:()=>$("/healing/clear-all",{method:"POST"})},Qa={start:e=>$("/run",{method:"POST",body:JSON.stringify(e)}),stop:()=>$("/run/stop",{method:"POST"}),list:e=>$(`/run${e!==void 0?`?limit=${e}`:""}`),get:e=>$(`/run/${e}`)},rc={list:e=>$(`/report${e!==void 0?`?limit=${e}`:""}`),get:e=>$(`/report/${e}`),delete:e=>$(`/report/${e}`,{method:"DELETE"})},Zr={generate:(e,t,n)=>$("/story/generate",{method:"POST",body:JSON.stringify({story:e,suiteName:t,jiraUrl:n})}),generateBulk:(e,t=3)=>$("/story/generate-bulk",{method:"POST",body:JSON.stringify({stories:e,concurrency:t})}),fetchJira:e=>$("/story/fetch-jira",{method:"POST",body:JSON.stringify({jiraUrl:e})}),swaggerPreview:e=>$("/story/swagger-preview",{method:"POST",body:JSON.stringify({specUrl:e})}),generateFromSwagger:(e,t,n,r)=>$("/story/generate-from-swagger",{method:"POST",body:JSON.stringify({specUrl:e,suiteName:t,tags:n,requirements:r||void 0})})},Gr={enabled:()=>$("/xray/enabled"),status:()=>$("/xray/status"),suiteStatus:e=>$(`/xray/status/${e}`),createAll:()=>$("/xray/create-all",{method:"POST"}),createSuite:e=>$(`/xray/create/suite/${e}`,{method:"POST"}),createCase:(e,t)=>$(`/xray/create/case/${e}/${t}`,{method:"POST"}),syncAll:()=>$("/xray/sync-all",{method:"POST"}),syncSuite:e=>$(`/xray/sync/suite/${e}`,{method:"POST"}),syncCase:(e,t)=>$(`/xray/sync/case/${e}/${t}`,{method:"POST"}),validate:()=>$("/xray/validate")},ea={list:()=>$("/data-files"),get:e=>$(`/data-files/${encodeURIComponent(e)}`),upload:(e,t)=>$("/data-files/upload",{method:"POST",body:JSON.stringify({filename:e,content:t})}),update:(e,t)=>$(`/data-files/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({content:t})}),delete:e=>$(`/data-files/${encodeURIComponent(e)}`,{method:"DELETE"})},Ve={status:()=>$("/git/status"),branches:()=>$("/git/branches"),checkout:e=>$("/git/checkout",{method:"POST",body:JSON.stringify({branch:e})}),commit:e=>$("/git/commit",{method:"POST",body:JSON.stringify({message:e})}),pull:e=>$("/git/pull",{method:"POST",body:JSON.stringify({rebase:e})}),push:()=>$("/git/push",{method:"POST"}),fullSync:e=>$("/git/full-sync",{method:"POST",body:JSON.stringify({message:e})}),log:e=>$(`/git/log${e?`?count=${e}`:""}`),diff:e=>$(`/git/diff${e?"?staged=true":""}`),conflictContent:e=>$(`/git/conflict-content/${encodeURIComponent(e)}`),resolveConflict:(e,t)=>$("/git/resolve-conflict",{method:"POST",body:JSON.stringify({filePath:e,content:t})}),continueRebase:()=>$("/git/continue-rebase",{method:"POST"}),abortRebase:()=>$("/git/abort-rebase",{method:"POST"}),generateCommitMessage:()=>$("/git/generate-commit-message",{method:"POST"}),resolveConflictAI:(e,t,n)=>$("/git/resolve-conflict-ai",{method:"POST",body:JSON.stringify({filePath:e,ours:t,theirs:n})}),impact:()=>$("/git/impact")};function ni(e,t){const n=t.replace(/\\/g,"/").split("/").pop()??t;return`${Fm}/results/${e}/${encodeURIComponent(n)}`}function Mw(e){return`${Fm}/results/baselines/${encodeURIComponent(e)}.png`}const Tw={search:e=>$(`/search?q=${encodeURIComponent(e)}`)},Aw={generate:e=>$("/ci-config",{method:"POST",body:JSON.stringify(e)})},Ow={list:()=>$("/templates")},Dw={get:(e,t)=>{const n=new URLSearchParams;return e&&n.set("suiteId",e),t&&n.set("caseId",t),$(`/flakiness?${n}`)}},dr={list:()=>$("/step-library"),create:e=>$("/step-library",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>$(`/step-library/${e}`,{method:"PATCH",body:JSON.stringify(t)}),delete:e=>$(`/step-library/${e}`,{method:"DELETE"}),generate:e=>$(`/step-library/${e}/generate`,{method:"POST"})},Dp={capture:(e,t)=>$(`/baselines/${e}/capture`,{method:"POST",body:JSON.stringify({screenshotPath:t})}),get:e=>$(`/baselines/${e}`)},Sd={start:(e,t)=>$("/recorder/start",{method:"POST",body:JSON.stringify({url:e,viewport:t})}),stop:()=>$("/recorder/stop",{method:"POST"}),status:()=>$("/recorder/status")};function Iw(e){const t=e.locator,n=e.dialogHandler?`page.once('dialog', dialog => dialog.${e.dialogHandler.type}());
889
- `:"";switch(e.action){case"navigate":return`await page.goto('${ar(e.url||"")}');`;case"click":return`${n}await page.${t}.click();`;case"fill":return`${n}await page.${t}.fill('${ar(e.value||"")}');`;case"select":return`await page.${t}.selectOption('${ar(e.value||"")}');`;case"check":return`await page.${t}.check();`;case"uncheck":return`await page.${t}.uncheck();`;case"press":return t?`await page.${t}.press('${ar(e.value||"")}');`:`await page.keyboard.press('${ar(e.value||"")}');`;case"hover":return`await page.${t}.click();`;case"assert":{const r=e.instruction,a=e.soft?"expect.soft":"expect";if(r.includes("current URL contains")){const i=r.match(/contains "(.+)"/),l=i?i[1]:"/";return`await ${a}(page).toHaveURL(/${Fw(l)}/);`}if(r.includes("page title is")){const i=r.match(/title is "(.+)"/),l=i?i[1]:"";return`await ${a}(page).toHaveTitle('${ar(l)}');`}if(r.includes("has value")){const i=r.match(/has value "(.+)"/),l=i?i[1]:"";return`await ${a}(page.${t}).toHaveValue('${ar(l)}');`}return r.includes("is checked")?`await ${a}(page.${t}).toBeChecked();`:r.includes("is unchecked")?`await ${a}(page.${t}).not.toBeChecked();`:t?`await ${a}(page.${t}).toBeVisible();`:`// TODO: ${r}`}default:return`// Unhandled action: ${e.action}`}}function ar(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function Fw(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}let hi=!1,Cd=null;const ta=[];let Ed=!1,Pd=[];const xx=new Set;function Is(){for(const e of xx)e()}const Re={subscribe(e){return xx.add(e),()=>{xx.delete(e)}},getSnapshot(){return{panelOpen:hi,operationInProgress:Cd,logSteps:[...ta],hasConflict:Ed,conflictFiles:[...Pd]}},togglePanel(){hi=!hi,Is()},openPanel(){hi=!0,Is()},closePanel(){hi=!1,Is()},startOperation(e){Cd=e,ta.length=0,Is()},finishOperation(){Cd=null,Is()},addLogStep(e){const t=ta.findIndex(n=>n.step===e.step&&n.status==="running");t>=0&&e.status!=="running"?ta[t]=e:t<0&&ta.push(e),Is()},clearLogs(){ta.length=0,Is()},setConflict(e){Ed=e.length>0,Pd=e,Is()},clearConflict(){Ed=!1,Pd=[],Is()}};function Uc(){const[e,t]=m.useState(()=>Re.getSnapshot());return m.useEffect(()=>Re.subscribe(()=>t(Re.getSnapshot())),[]),e}function Lm(){return pe({queryKey:["git","status"],queryFn:Ve.status,refetchInterval:5e3,retry:1})}function Py(){return pe({queryKey:["git","branches"],queryFn:Ve.branches,staleTime:3e4,retry:1})}function Ry(e){return pe({queryKey:["git","log",e],queryFn:()=>Ve.log(e),staleTime:1e4,retry:1})}function zy(){const e=ie();return V({mutationFn:t=>Ve.checkout(t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["git"]}),O.success(`Switched to ${n}`)},onError:t=>O.error(`Checkout failed: ${t.message}`)})}function My(){const e=ie();return V({mutationFn:t=>(Re.startOperation("commit"),Ve.commit(t)),onSuccess:t=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success(`Committed: ${t.hash}`)},onError:t=>{Re.finishOperation(),O.error(`Commit failed: ${t.message}`)}})}function Ty(){const e=ie();return V({mutationFn:t=>(Re.startOperation("pull"),Ve.pull(t)),onSuccess:()=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success("Pull successful")},onError:t=>{Re.finishOperation(),O.error(`Pull failed: ${t.message}`)}})}function Ay(){const e=ie();return V({mutationFn:()=>(Re.startOperation("push"),Ve.push()),onSuccess:()=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success("Pushed to remote")},onError:t=>{Re.finishOperation(),O.error(`Push failed: ${t.message}`)}})}function Oy(){const e=ie();return V({mutationFn:t=>(Re.startOperation("full-sync"),Ve.fullSync(t)),onSuccess:()=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success("Full sync complete")},onError:t=>{Re.finishOperation(),O.error(`Sync failed: ${t.message}`)}})}function Dy(){return V({mutationFn:()=>Ve.generateCommitMessage(),onError:e=>O.error(`AI generation failed: ${e.message}`)})}function Iy(){const e=ie();return V({mutationFn:({filePath:t,content:n})=>Ve.resolveConflict(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["git"]}),O.success("Conflict resolved")},onError:t=>O.error(`Resolve failed: ${t.message}`)})}function Fy(){return V({mutationFn:({filePath:e,ours:t,theirs:n})=>Ve.resolveConflictAI(e,t,n),onError:e=>O.error(`AI resolve failed: ${e.message}`)})}function Ly(){const e=ie();return V({mutationFn:()=>Ve.continueRebase(),onSuccess:()=>{Re.clearConflict(),e.invalidateQueries({queryKey:["git"]}),O.success("Rebase continued")},onError:t=>O.error(`Continue rebase failed: ${t.message}`)})}function _y(){const e=ie();return V({mutationFn:()=>Ve.abortRebase(),onSuccess:()=>{Re.clearConflict(),e.invalidateQueries({queryKey:["git"]}),O.success("Rebase aborted")},onError:t=>O.error(`Abort rebase failed: ${t.message}`)})}const $y="assuremind-theme";function Lw(){var t;const e=localStorage.getItem($y);return e==="dark"||e==="light"?e:(t=window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}let la=Lw();const mx=new Set;function Uy(e){const t=document.documentElement;e==="dark"?t.classList.add("dark"):t.classList.remove("dark")}Uy(la);function _w(){for(const e of mx)e()}const Rd={subscribe(e){return mx.add(e),()=>{mx.delete(e)}},getSnapshot(){return la},toggle(){la=la==="light"?"dark":"light",localStorage.setItem($y,la),Uy(la),_w()}};function $w(){return{theme:m.useSyncExternalStore(Rd.subscribe,Rd.getSnapshot),toggle:Rd.toggle}}const By=6048e5,Uw=864e5,Zl=43200,Ip=1440,Fp=Symbol.for("constructDateFrom");function rn(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Fp in e?e[Fp](t):e instanceof Date?new e.constructor(t):new Date(t)}function nt(e,t){return rn(t||e,e)}let Bw={};function Rl(){return Bw}function ul(e,t){var o,c,d,x;const n=Rl(),r=(t==null?void 0:t.weekStartsOn)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((x=(d=n.locale)==null?void 0:d.options)==null?void 0:x.weekStartsOn)??0,a=nt(e,t==null?void 0:t.in),i=a.getDay(),l=(i<r?7:0)+i-r;return a.setDate(a.getDate()-l),a.setHours(0,0,0,0),a}function ac(e,t){return ul(e,{...t,weekStartsOn:1})}function qy(e,t){const n=nt(e,t==null?void 0:t.in),r=n.getFullYear(),a=rn(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const i=ac(a),l=rn(n,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const o=ac(l);return n.getTime()>=i.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function ic(e){const t=nt(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Bc(e,...t){const n=rn.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function Lp(e,t){const n=nt(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function qw(e,t,n){const[r,a]=Bc(n==null?void 0:n.in,e,t),i=Lp(r),l=Lp(a),o=+i-ic(i),c=+l-ic(l);return Math.round((o-c)/Uw)}function Hw(e,t){const n=qy(e,t),r=rn(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),ac(r)}function ko(e,t){const n=+nt(e)-+nt(t);return n<0?-1:n>0?1:n}function Kw(e){return rn(e,Date.now())}function Ww(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Vw(e){return!(!Ww(e)&&typeof e!="number"||isNaN(+nt(e)))}function Gw(e,t,n){const[r,a]=Bc(n==null?void 0:n.in,e,t),i=r.getFullYear()-a.getFullYear(),l=r.getMonth()-a.getMonth();return i*12+l}function Qw(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Yw(e,t){return+nt(e)-+nt(t)}function Jw(e,t){const n=nt(e,t==null?void 0:t.in);return n.setHours(23,59,59,999),n}function Xw(e,t){const n=nt(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Zw(e,t){const n=nt(e,t==null?void 0:t.in);return+Jw(n,t)==+Xw(n,t)}function ek(e,t,n){const[r,a,i]=Bc(n==null?void 0:n.in,e,e,t),l=ko(a,i),o=Math.abs(Gw(a,i));if(o<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-l*o);let c=ko(a,i)===-l;Zw(r)&&o===1&&ko(r,i)===1&&(c=!1);const d=l*(o-+c);return d===0?0:d}function tk(e,t,n){const r=Yw(e,t)/1e3;return Qw(n==null?void 0:n.roundingMethod)(r)}function sk(e,t){const n=nt(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const nk={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},rk=(e,t,n)=>{let r;const a=nk[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function zd(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const ak={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ik={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},lk={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ok={date:zd({formats:ak,defaultWidth:"full"}),time:zd({formats:ik,defaultWidth:"full"}),dateTime:zd({formats:lk,defaultWidth:"full"})},ck={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},dk=(e,t,n,r)=>ck[e];function pi(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,o=n!=null&&n.width?String(n.width):l;a=e.formattingValues[o]||e.formattingValues[l]}else{const l=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[l]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const uk={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xk={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},mk={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},hk={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},pk={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},fk={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},gk=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},yk={ordinalNumber:gk,era:pi({values:uk,defaultWidth:"wide"}),quarter:pi({values:xk,defaultWidth:"wide",argumentCallback:e=>e-1}),month:pi({values:mk,defaultWidth:"wide"}),day:pi({values:hk,defaultWidth:"wide"}),dayPeriod:pi({values:pk,defaultWidth:"wide",formattingValues:fk,defaultFormattingWidth:"wide"})};function fi(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const l=i[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(o)?vk(o,p=>p.test(l)):bk(o,p=>p.test(l));let d;d=e.valueCallback?e.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const x=t.slice(l.length);return{value:d,rest:x}}}function bk(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function vk(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function jk(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],i=t.match(e.parsePattern);if(!i)return null;let l=e.valueCallback?e.valueCallback(i[0]):i[0];l=n.valueCallback?n.valueCallback(l):l;const o=t.slice(a.length);return{value:l,rest:o}}}const Nk=/^(\d+)(th|st|nd|rd)?/i,wk=/\d+/i,kk={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Sk={any:[/^b/i,/^(a|c)/i]},Ck={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ek={any:[/1/i,/2/i,/3/i,/4/i]},Pk={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Rk={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},zk={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Mk={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Tk={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ak={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ok={ordinalNumber:jk({matchPattern:Nk,parsePattern:wk,valueCallback:e=>parseInt(e,10)}),era:fi({matchPatterns:kk,defaultMatchWidth:"wide",parsePatterns:Sk,defaultParseWidth:"any"}),quarter:fi({matchPatterns:Ck,defaultMatchWidth:"wide",parsePatterns:Ek,defaultParseWidth:"any",valueCallback:e=>e+1}),month:fi({matchPatterns:Pk,defaultMatchWidth:"wide",parsePatterns:Rk,defaultParseWidth:"any"}),day:fi({matchPatterns:zk,defaultMatchWidth:"wide",parsePatterns:Mk,defaultParseWidth:"any"}),dayPeriod:fi({matchPatterns:Tk,defaultMatchWidth:"any",parsePatterns:Ak,defaultParseWidth:"any"})},Hy={code:"en-US",formatDistance:rk,formatLong:ok,formatRelative:dk,localize:yk,match:Ok,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Dk(e,t){const n=nt(e,t==null?void 0:t.in);return qw(n,sk(n))+1}function Ik(e,t){const n=nt(e,t==null?void 0:t.in),r=+ac(n)-+Hw(n);return Math.round(r/By)+1}function Ky(e,t){var x,p,y,b;const n=nt(e,t==null?void 0:t.in),r=n.getFullYear(),a=Rl(),i=(t==null?void 0:t.firstWeekContainsDate)??((p=(x=t==null?void 0:t.locale)==null?void 0:x.options)==null?void 0:p.firstWeekContainsDate)??a.firstWeekContainsDate??((b=(y=a.locale)==null?void 0:y.options)==null?void 0:b.firstWeekContainsDate)??1,l=rn((t==null?void 0:t.in)||e,0);l.setFullYear(r+1,0,i),l.setHours(0,0,0,0);const o=ul(l,t),c=rn((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,i),c.setHours(0,0,0,0);const d=ul(c,t);return+n>=+o?r+1:+n>=+d?r:r-1}function Fk(e,t){var o,c,d,x;const n=Rl(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((x=(d=n.locale)==null?void 0:d.options)==null?void 0:x.firstWeekContainsDate)??1,a=Ky(e,t),i=rn((t==null?void 0:t.in)||e,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),ul(i,t)}function Lk(e,t){const n=nt(e,t==null?void 0:t.in),r=+ul(n,t)-+Fk(n,t);return Math.round(r/By)+1}function Se(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const xn={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return Se(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):Se(n+1,2)},d(e,t){return Se(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return Se(e.getHours()%12||12,t.length)},H(e,t){return Se(e.getHours(),t.length)},m(e,t){return Se(e.getMinutes(),t.length)},s(e,t){return Se(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return Se(a,t.length)}},sa={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},_p={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return xn.y(e,t)},Y:function(e,t,n,r){const a=Ky(e,r),i=a>0?a:1-a;if(t==="YY"){const l=i%100;return Se(l,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):Se(i,t.length)},R:function(e,t){const n=qy(e);return Se(n,t.length)},u:function(e,t){const n=e.getFullYear();return Se(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return Se(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return Se(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return xn.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return Se(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=Lk(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):Se(a,t.length)},I:function(e,t,n){const r=Ik(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):Se(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):xn.d(e,t)},D:function(e,t,n){const r=Dk(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Se(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return Se(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return Se(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return Se(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=sa.noon:r===0?a=sa.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=sa.evening:r>=12?a=sa.afternoon:r>=4?a=sa.morning:a=sa.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return xn.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):xn.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Se(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):Se(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):xn.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):xn.s(e,t)},S:function(e,t){return xn.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Up(r);case"XXXX":case"XX":return cr(r);case"XXXXX":case"XXX":default:return cr(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Up(r);case"xxxx":case"xx":return cr(r);case"xxxxx":case"xxx":default:return cr(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+$p(r,":");case"OOOO":default:return"GMT"+cr(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+$p(r,":");case"zzzz":default:return"GMT"+cr(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return Se(r,t.length)},T:function(e,t,n){return Se(+e,t.length)}};function $p(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+Se(i,2)}function Up(e,t){return e%60===0?(e>0?"-":"+")+Se(Math.abs(e)/60,2):cr(e,t)}function cr(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Se(Math.trunc(r/60),2),i=Se(r%60,2);return n+a+t+i}const Bp=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},Wy=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},_k=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return Bp(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",Bp(r,t)).replace("{{time}}",Wy(a,t))},$k={p:Wy,P:_k},Uk=/^D+$/,Bk=/^Y+$/,qk=["D","DD","YY","YYYY"];function Hk(e){return Uk.test(e)}function Kk(e){return Bk.test(e)}function Wk(e,t,n){const r=Vk(e,t,n);if(console.warn(r),qk.includes(e))throw new RangeError(r)}function Vk(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Gk=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Qk=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Yk=/^'([^]*?)'?$/,Jk=/''/g,Xk=/[a-zA-Z]/;function Zk(e,t,n){var x,p,y,b;const r=Rl(),a=r.locale??Hy,i=r.firstWeekContainsDate??((p=(x=r.locale)==null?void 0:x.options)==null?void 0:p.firstWeekContainsDate)??1,l=r.weekStartsOn??((b=(y=r.locale)==null?void 0:y.options)==null?void 0:b.weekStartsOn)??0,o=nt(e,n==null?void 0:n.in);if(!Vw(o))throw new RangeError("Invalid time value");let c=t.match(Qk).map(f=>{const v=f[0];if(v==="p"||v==="P"){const w=$k[v];return w(f,a.formatLong)}return f}).join("").match(Gk).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const v=f[0];if(v==="'")return{isToken:!1,value:e5(f)};if(_p[v])return{isToken:!0,value:f};if(v.match(Xk))throw new RangeError("Format string contains an unescaped latin alphabet character `"+v+"`");return{isToken:!1,value:f}});a.localize.preprocessor&&(c=a.localize.preprocessor(o,c));const d={firstWeekContainsDate:i,weekStartsOn:l,locale:a};return c.map(f=>{if(!f.isToken)return f.value;const v=f.value;(Kk(v)||Hk(v))&&Wk(v,t,String(e));const w=_p[v[0]];return w(o,v,a.localize,d)}).join("")}function e5(e){const t=e.match(Yk);return t?t[1].replace(Jk,"'"):e}function t5(e,t,n){const r=Rl(),a=(n==null?void 0:n.locale)??r.locale??Hy,i=2520,l=ko(e,t);if(isNaN(l))throw new RangeError("Invalid time value");const o=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:l}),[c,d]=Bc(n==null?void 0:n.in,...l>0?[t,e]:[e,t]),x=tk(d,c),p=(ic(d)-ic(c))/1e3,y=Math.round((x-p)/60);let b;if(y<2)return n!=null&&n.includeSeconds?x<5?a.formatDistance("lessThanXSeconds",5,o):x<10?a.formatDistance("lessThanXSeconds",10,o):x<20?a.formatDistance("lessThanXSeconds",20,o):x<40?a.formatDistance("halfAMinute",0,o):x<60?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",1,o):y===0?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",y,o);if(y<45)return a.formatDistance("xMinutes",y,o);if(y<90)return a.formatDistance("aboutXHours",1,o);if(y<Ip){const f=Math.round(y/60);return a.formatDistance("aboutXHours",f,o)}else{if(y<i)return a.formatDistance("xDays",1,o);if(y<Zl){const f=Math.round(y/Ip);return a.formatDistance("xDays",f,o)}else if(y<Zl*2)return b=Math.round(y/Zl),a.formatDistance("aboutXMonths",b,o)}if(b=ek(d,c),b<12){const f=Math.round(y/Zl);return a.formatDistance("xMonths",f,o)}else{const f=b%12,v=Math.trunc(b/12);return f<3?a.formatDistance("aboutXYears",v,o):f<9?a.formatDistance("overXYears",v,o):a.formatDistance("almostXYears",v+1,o)}}function lc(e,t){return t5(e,Kw(e),t)}let ir=[];const hx=new Set;function Md(){hx.forEach(e=>e())}const zr={subscribe(e){return hx.add(e),()=>{hx.delete(e)}},getSnapshot(){return{notifications:ir,unreadCount:ir.filter(e=>!e.read).length}},push(e){ir=[e,...ir].slice(0,20),Md()},markAllRead(){ir=ir.map(e=>({...e,read:!0})),Md()},clear(){ir=[],Md()}};function s5(){const[e,t]=m.useState(()=>zr.getSnapshot());return m.useEffect(()=>zr.subscribe(()=>t(zr.getSnapshot())),[]),e}function n5({type:e}){switch(e){case"run-complete":return s.jsx(we,{size:13,className:"text-emerald-500 flex-shrink-0"});case"run-error":return s.jsx(tt,{size:13,className:"text-red-500 flex-shrink-0"});case"healing":return s.jsx(qe,{size:13,className:"text-amber-500 flex-shrink-0"});case"git":return s.jsx(Lr,{size:13,className:"text-blue-500 flex-shrink-0"});default:return s.jsx(ec,{size:13,className:"text-content-tertiary flex-shrink-0"})}}function r5(){const[e,t]=m.useState(!1),{notifications:n,unreadCount:r}=s5(),a=m.useRef(null),i=zs();return m.useEffect(()=>{if(!e)return;function l(o){a.current&&!a.current.contains(o.target)&&t(!1)}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[e]),s.jsxs("div",{className:"relative",ref:a,children:[s.jsxs("button",{type:"button",onClick:()=>t(l=>!l),className:P("relative p-2 rounded-lg transition-all duration-200",e?"bg-accent-muted text-accent":"text-content-tertiary hover:bg-surface-inset hover:text-content-secondary"),"aria-label":"Notifications",title:"Notifications",children:[s.jsx(ec,{size:16}),r>0&&s.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white text-[9px] font-bold flex items-center justify-center ring-2 ring-surface",children:r>9?"9+":r})]}),e&&s.jsxs("div",{className:"absolute right-0 top-full mt-2 w-80 bg-surface border border-border rounded-xl shadow-modal z-50 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-inset/50",children:[s.jsx("span",{className:"text-xs font-semibold text-content",children:"Notifications"}),s.jsxs("div",{className:"flex items-center gap-1",children:[r>0&&s.jsx("button",{type:"button",onClick:()=>zr.markAllRead(),className:"p-1 rounded text-content-tertiary hover:text-content hover:bg-surface-inset transition-colors",title:"Mark all read",children:s.jsx(cy,{size:12})}),s.jsx("button",{type:"button",onClick:()=>zr.clear(),className:"p-1 rounded text-content-tertiary hover:text-red-500 hover:bg-red-50 transition-colors",title:"Clear all",children:s.jsx(Kt,{size:12})})]})]}),s.jsx("div",{className:"max-h-80 overflow-y-auto divide-y divide-border/50",children:n.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-2",children:[s.jsx(ec,{size:20,className:"text-content-tertiary/40"}),s.jsx("p",{className:"text-xs text-content-tertiary",children:"No notifications"})]}):n.map(l=>s.jsxs("div",{className:P("flex items-start gap-2.5 px-3 py-2.5 transition-colors",!l.read&&"bg-accent-muted/20",l.link&&"cursor-pointer hover:bg-surface-inset/50"),onClick:()=>{l.link&&(t(!1),i(l.link))},children:[s.jsx("div",{className:"mt-0.5",children:s.jsx(n5,{type:l.type})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:P("text-xs leading-relaxed",l.read?"text-content-secondary":"text-content font-medium"),children:l.message}),s.jsx("p",{className:"text-[9px] text-content-tertiary mt-0.5",children:lc(new Date(l.timestamp),{addSuffix:!0})})]}),l.link&&s.jsx(si,{size:10,className:"text-content-tertiary/60 flex-shrink-0 mt-0.5"}),!l.read&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent flex-shrink-0 mt-1.5"})]},l.id))})]})]})}function a5(){const e=ie(),t=zs(),[n,r]=m.useState(!1),a=m.useRef(null),{data:i}=pe({queryKey:["config"],queryFn:()=>Ga.get(),staleTime:3e4}),l=V({mutationFn:d=>{var p;const x=(p=i==null?void 0:i.profiles)==null?void 0:p.find(y=>y.name===d);if(!x)throw new Error("Profile not found");return Ga.update({activeProfile:x.name,environment:x.environment,baseUrl:x.baseUrl,browsers:x.browsers,...x.headless!==void 0?{headless:x.headless}:{}})},onSuccess:()=>{e.invalidateQueries({queryKey:["config"]}),r(!1)}});m.useEffect(()=>{const d=x=>{a.current&&!a.current.contains(x.target)&&r(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]);const o=(i==null?void 0:i.profiles)??[];if(o.length===0)return null;const c=(i==null?void 0:i.activeProfile)??(i==null?void 0:i.environment)??"env";return s.jsxs("div",{ref:a,className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>r(d=>!d),className:"flex items-center gap-1.5 text-xs border border-border rounded-lg px-2.5 py-1.5 text-content-secondary hover:bg-surface-inset transition-colors",children:[s.jsx(nn,{size:12,className:"text-accent flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline max-w-[100px] truncate",children:c}),s.jsx(Nt,{size:11,className:"text-content-tertiary"})]}),n&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface border border-border rounded-xl shadow-elevated z-50 overflow-hidden",children:[s.jsx("div",{className:"px-3 py-2 border-b border-border",children:s.jsx("p",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Environment Profiles"})}),s.jsx("div",{className:"py-1",children:o.map(d=>s.jsxs("button",{type:"button",onClick:()=>l.mutate(d.name),className:P("w-full text-left px-3 py-2 text-xs hover:bg-surface-inset transition-colors flex items-center justify-between gap-2",(i==null?void 0:i.activeProfile)===d.name&&"text-accent font-semibold"),children:[s.jsx("span",{className:"truncate",children:d.name}),s.jsx("span",{className:"text-[9px] text-content-tertiary flex-shrink-0",children:d.environment})]},d.name))}),s.jsx("div",{className:"border-t border-border px-3 py-2",children:s.jsxs("button",{type:"button",onClick:()=>{r(!1),t("/settings#profiles")},className:"flex items-center gap-1 text-[10px] text-content-tertiary hover:text-accent transition-colors",children:[s.jsx(Va,{size:10})," Manage profiles"]})})]})]})}const i5={anthropic:"Anthropic",bedrock:"Bedrock",openai:"OpenAI",google:"Google","azure-openai":"Azure OpenAI",ollama:"Ollama",unknown:"AI"};function l5({title:e,onMenuClick:t}){const{data:n}=pe({queryKey:["ai-provider"],queryFn:()=>Ga.getAiProvider(),staleTime:6e4,retry:!1}),{panelOpen:r}=Uc(),{data:a}=Lm(),{theme:i,toggle:l}=$w(),o=i5[(n==null?void 0:n.provider)??""]??(n==null?void 0:n.provider)??"...",c=(n==null?void 0:n.model)??"...",d=((a==null?void 0:a.modified.length)??0)+((a==null?void 0:a.added.length)??0)+((a==null?void 0:a.deleted.length)??0)+((a==null?void 0:a.untracked.length)??0);return s.jsxs("header",{className:"h-14 bg-surface border-b border-border flex items-center px-5 gap-3 flex-shrink-0",children:[s.jsx("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-inset text-content-tertiary lg:hidden transition-colors","aria-label":"Toggle sidebar",children:s.jsx(nw,{size:18})}),s.jsx("h1",{className:"text-sm font-semibold text-content tracking-tight flex-1",children:e}),n&&s.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 text-xs bg-surface-inset border border-border rounded-lg px-3 py-1.5",children:[s.jsx(D2,{size:13,className:"text-accent flex-shrink-0"}),s.jsx("span",{className:"font-medium text-content-secondary",children:o}),s.jsx("span",{className:"text-content-tertiary/50",children:"/"}),s.jsx("span",{className:"text-content-tertiary truncate max-w-[140px]",children:c})]}),s.jsx(a5,{}),s.jsx(r5,{}),s.jsx("button",{type:"button",onClick:l,className:P("p-2 rounded-lg transition-all duration-200",i==="dark"?"bg-surface-inset text-amber-400 hover:bg-surface-overlay":"text-content-tertiary hover:bg-surface-inset hover:text-content-secondary"),"aria-label":i==="dark"?"Switch to light mode":"Switch to dark mode",title:i==="dark"?"Light mode":"Dark mode",children:i==="dark"?s.jsx(gw,{size:16}):s.jsx(aw,{size:16})}),s.jsxs("button",{type:"button",onClick:()=>Re.togglePanel(),className:P("relative flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200",r?"bg-accent-muted text-accent border border-accent/20":"text-content-tertiary hover:bg-surface-inset hover:text-content-secondary border border-transparent"),"aria-label":"Toggle Git panel",title:"Git Control Center",children:[s.jsx(Lr,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:"Git"}),d>0&&s.jsx("span",{className:"absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-amber-500 text-white text-[9px] font-bold flex items-center justify-center ring-2 ring-surface",children:d>9?"9+":d})]})]})}function te({variant:e="primary",size:t="md",loading:n=!1,children:r,className:a,disabled:i,...l}){return s.jsxs("button",{...l,disabled:i||n,className:P("inline-flex items-center justify-center gap-2 font-medium rounded-lg transition-all duration-150","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1",{"bg-gradient-to-b from-accent to-accent-dark text-white shadow-sm hover:shadow-md hover:brightness-110 focus-visible:ring-accent":e==="primary","bg-surface border border-border text-content-secondary hover:bg-surface-inset hover:text-content hover:border-border-strong focus-visible:ring-accent":e==="secondary","text-content-secondary hover:bg-surface-inset hover:text-content focus-visible:ring-accent/40":e==="ghost","bg-gradient-to-b from-red-500 to-red-600 text-white shadow-sm hover:shadow-md hover:brightness-110 focus-visible:ring-red-500":e==="danger","px-2.5 py-1.5 text-xs gap-1.5":t==="sm","px-4 py-2 text-sm":t==="md","px-5 py-2.5 text-sm":t==="lg","opacity-40 cursor-not-allowed pointer-events-none":i||n},a),children:[n&&s.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-20",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),s.jsx("path",{className:"opacity-80",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),r]})}function Qr(e){const t=m.useRef(null),n=m.useRef(e);n.current=e;const r=m.useCallback(()=>{var i;if(((i=t.current)==null?void 0:i.readyState)===WebSocket.OPEN)return;const a=new WebSocket(Pw);t.current=a,a.onmessage=l=>{try{const o=JSON.parse(l.data),c=n.current[o.event];c&&c(o.data)}catch{}},a.onclose=()=>{setTimeout(r,3e3)},a.onerror=()=>{a.close()}},[]);m.useEffect(()=>(r(),()=>{var a;(a=t.current)==null||a.close()}),[r])}let oc={isRunning:!1,runId:null,currentBrowser:null,currentCase:null,currentStep:null,completed:null,error:null,activeCases:new Map};const px=new Set;function Vy(){px.forEach(e=>e())}function na(e){oc=e(oc),Vy()}const Td={subscribe(e){return px.add(e),()=>{px.delete(e)}},getSnapshot(){return oc},reset(){oc={isRunning:!1,runId:null,currentBrowser:null,currentCase:null,currentStep:null,completed:null,error:null,activeCases:new Map},Vy()}};function _m(){const e=m.useSyncExternalStore(Td.subscribe,Td.getSnapshot),t=m.useCallback(c=>{const d=c;na(()=>({isRunning:!0,runId:d.runId,currentBrowser:null,currentCase:null,currentStep:null,completed:null,error:null,activeCases:new Map}))},[]),n=m.useCallback(c=>{const d=c;na(x=>{const p=new Map(x.activeCases);return p.set(d.caseId,d.caseName),{...x,isRunning:!0,currentBrowser:d.browser??x.currentBrowser,currentCase:d,currentStep:null,activeCases:p}})},[]),r=m.useCallback(c=>{na(d=>({...d,isRunning:!0,currentStep:c}))},[]),a=m.useCallback(c=>{na(d=>({...d,isRunning:!1,completed:c,currentCase:null,currentStep:null}))},[]),i=m.useCallback(c=>{const d=c;na(x=>({...x,isRunning:!1,error:d.error}))},[]),l=m.useCallback(()=>{na(c=>({...c,isRunning:!1,completed:c.completed??{runId:c.runId??"",passed:0,failed:0,skipped:0,duration:0},currentCase:null,currentStep:null}))},[]);Qr({"run:start":t,"run:case":n,"run:step":r,"run:complete":a,"run:error":i,"run:stopped":l});const o=m.useCallback(()=>{Td.reset()},[]);return{...e,reset:o}}function Ad(e,t){Qr({[e]:t})}function qp({data:e,maxHeight:t=32}){const n=Math.max(...e.map(r=>r.value),1);return s.jsx("div",{className:"flex items-end gap-[3px]",style:{height:t},children:e.map((r,a)=>s.jsx("div",{className:P("w-[6px] rounded-full transition-all duration-500",r.color),style:{height:`${Math.max(r.value/n*100,6)}%`}},a))})}function o5({rate:e,hasData:t=!1,size:n=80}){const a=(n-6)/2,i=2*Math.PI*a,l=i-e/100*i,o=t?"#ef4444":"var(--color-border)";return s.jsxs("div",{className:"relative",style:{width:n,height:n},children:[s.jsxs("svg",{width:n,height:n,className:"-rotate-90",children:[s.jsx("circle",{cx:n/2,cy:n/2,r:a,fill:"none",stroke:o,strokeWidth:6}),s.jsx("circle",{cx:n/2,cy:n/2,r:a,fill:"none",stroke:"#10b981",strokeWidth:6,strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:l,className:"transition-all duration-1000 ease-out"})]}),s.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:s.jsxs("span",{className:"text-lg font-bold text-content tabular-nums",children:[e,"%"]})})]})}function c5({status:e}){const t={passed:"bg-emerald-500",failed:"bg-red-500",partial:"bg-amber-500",running:"bg-blue-500 animate-pulse",skipped:"bg-slate-400"};return s.jsx("span",{className:P("w-2 h-2 rounded-full flex-shrink-0",t[e]??"bg-slate-400")})}function d5(e,t){return e.filter(n=>{var r;return(r=n.suiteIds)==null?void 0:r.includes(t)}).slice(-7).map(n=>({value:n.totalTests>0?Math.round(n.passed/n.totalTests*100):0,color:n.failed>0?"bg-red-400":"bg-emerald-400"}))}function u5(){const e=zs(),{data:t=[],isLoading:n}=pe({queryKey:["reports"],queryFn:()=>rc.list(20)}),{data:r=[],isLoading:a}=pe({queryKey:["suites"],queryFn:()=>Kr.list()}),{data:i}=pe({queryKey:["healing-stats"],queryFn:()=>Ws.stats(),staleTime:3e4,retry:!1}),l=_m(),o=n||a,c=t[0],d=r.reduce((k,N)=>k+(N.caseCount??0),0),x=r.filter(k=>(k.type??"ui")==="ui"),p=r.filter(k=>(k.type??"ui")==="api"),y=x.reduce((k,N)=>k+(N.caseCount??0),0),b=p.reduce((k,N)=>k+(N.caseCount??0),0),f=t.reduce((k,N)=>k+N.passed,0),v=t.reduce((k,N)=>k+N.failed,0),w=t.reduce((k,N)=>k+N.skipped,0),h=f+v>0?Math.round(f/(f+v)*100):0,u=f+v+w,g=t.filter(k=>k.duration).length>0?Math.round(t.filter(k=>k.duration).reduce((k,N)=>k+(N.duration??0),0)/t.filter(k=>k.duration).length/1e3):0,j=[...t].reverse().map(k=>({value:k.passed+k.failed+k.skipped,color:k.status==="passed"?"bg-emerald-400":k.status==="failed"?"bg-red-400":"bg-amber-400"}));return o?s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex-shrink-0 px-8 pt-6 pb-4",children:[s.jsx("div",{className:"h-7 w-48 rounded-lg skeleton-shimmer"}),s.jsx("div",{className:"h-4 w-72 rounded-lg skeleton-shimmer mt-2"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-8 pb-8",children:[s.jsx("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[1,2,3,4].map(k=>s.jsx("div",{className:"h-28 rounded-2xl skeleton-shimmer"},k))}),s.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(k=>s.jsx("div",{className:"h-64 rounded-2xl skeleton-shimmer"},k))})]})]}):s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex-shrink-0 px-8 pt-6 pb-4 flex items-end justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-content tracking-tight",children:"Dashboard"}),s.jsx("p",{className:"text-sm text-content-tertiary mt-0.5",children:"Test automation health at a glance"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(te,{size:"sm",variant:"secondary",onClick:()=>e("/run"),children:[s.jsx(Dt,{size:13})," Run Tests"]}),s.jsxs(te,{size:"sm",onClick:()=>e("/story"),children:[s.jsx(wt,{size:13})," Generate"]})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-8 pb-8 space-y-5",children:[l.isRunning&&s.jsx("div",{className:"rounded-2xl border border-accent/25 bg-gradient-to-r from-accent/[0.06] via-accent/[0.03] to-transparent p-4 animate-fade-in",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative w-8 h-8 flex-shrink-0",children:[s.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-accent/20"}),s.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm font-semibold text-content",children:"Run in progress..."}),l.currentCase&&s.jsxs("p",{className:"text-xs text-content-secondary truncate mt-0.5",children:[l.currentCase.caseName,l.currentStep&&` › ${l.currentStep.instruction}`]})]}),s.jsxs(te,{size:"sm",variant:"ghost",onClick:()=>e("/run"),children:["View ",s.jsx(fr,{size:12})]})]})}),l.completed&&!l.isRunning&&(()=>{const k=l.completed,N=k.failed===0&&k.passed>0,E=k.failed>0,R=N?{border:"border-emerald-200/50",bg:"bg-gradient-to-r from-emerald-50/80 to-transparent",icon:"text-emerald-500",title:"text-emerald-800",subtitle:"text-emerald-600",label:"All tests passed"}:E?{border:"border-red-200/50",bg:"bg-gradient-to-r from-red-50/80 to-transparent",icon:"text-red-500",title:"text-red-800",subtitle:"text-red-600",label:"Completed with failures"}:{border:"border-amber-200/50",bg:"bg-gradient-to-r from-amber-50/80 to-transparent",icon:"text-amber-500",title:"text-amber-800",subtitle:"text-amber-600",label:"Run completed"},L=N?we:E?tt:ts;return s.jsx("div",{className:P("rounded-2xl border p-4 animate-fade-in",R.border,R.bg),children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(L,{size:20,className:P(R.icon,"flex-shrink-0")}),s.jsxs("div",{children:[s.jsx("p",{className:P("text-sm font-semibold",R.title),children:R.label}),s.jsxs("p",{className:P("text-xs mt-0.5",R.subtitle),children:[k.passed," passed / ",k.failed," failed / ",k.skipped," skipped"]})]})]}),s.jsx(te,{variant:"secondary",size:"sm",onClick:()=>e("/reports"),children:"View Report"})]})})})(),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-indigo-50 border border-indigo-100 flex items-center justify-center",children:s.jsx(qr,{size:18,className:"text-indigo-500"})}),s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Coverage"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"text-3xl font-extrabold text-content tabular-nums tracking-tight",children:r.length}),s.jsx("p",{className:"text-xs text-content-tertiary mt-0.5",children:"test suites"})]}),s.jsxs("div",{className:"mt-3 pt-3 border-t border-border-muted flex items-center gap-4",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(gr,{size:11,className:"text-blue-500"}),s.jsxs("span",{className:"text-[11px] text-content-secondary font-medium",children:[x.length," UI"]}),s.jsxs("span",{className:"text-[10px] text-content-tertiary",children:["(",y,")"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(cw,{size:11,className:"text-purple-500"}),s.jsxs("span",{className:"text-[11px] text-content-secondary font-medium",children:[p.length," API"]}),s.jsxs("span",{className:"text-[10px] text-content-tertiary",children:["(",b,")"]})]})]})]}),s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col items-center justify-center",children:[s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider mb-3",children:"Pass Rate"}),s.jsx(o5,{rate:t.length>0?h:0,hasData:f+v>0}),s.jsx("p",{className:"text-[11px] text-content-tertiary mt-2",children:f+v>0?`${f} of ${f+v} cases passed`:"no runs yet"})]}),s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-50 border border-teal-100 flex items-center justify-center",children:s.jsx(M2,{size:18,className:"text-teal-500"})}),s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Execution"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"text-3xl font-extrabold text-content tabular-nums tracking-tight",children:u}),s.jsx("p",{className:"text-xs text-content-tertiary mt-0.5",children:"tests executed"})]}),s.jsxs("div",{className:"mt-3 pt-3 border-t border-border-muted grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(we,{size:10,className:"text-emerald-500"}),s.jsx("span",{className:"text-[11px] font-semibold text-emerald-600 tabular-nums",children:f})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(tt,{size:10,className:"text-red-500"}),s.jsx("span",{className:"text-[11px] font-semibold text-red-500 tabular-nums",children:v})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Lc,{size:10,className:"text-content-tertiary"}),s.jsx("span",{className:"text-[11px] font-semibold text-content-tertiary tabular-nums",children:w})]})]})]}),s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-50 border border-amber-100 flex items-center justify-center",children:s.jsx(qe,{size:18,className:"text-amber-500"})}),s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Insights"})]}),s.jsxs("div",{className:"mt-4 space-y-2.5",children:[s.jsx("div",{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Avg Duration"}),s.jsx("span",{className:"text-sm font-bold text-content tabular-nums",children:g>0?`${g}s`:"—"})]})}),s.jsx("div",{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Self-Healed"}),s.jsx("span",{className:"text-sm font-bold text-emerald-600 tabular-nums",children:(i==null?void 0:i.accepted)??0})]})}),s.jsx("div",{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Pending Review"}),s.jsx("span",{className:P("text-sm font-bold tabular-nums",((i==null?void 0:i.pending)??0)>0?"text-amber-500":"text-content-tertiary"),children:(i==null?void 0:i.pending)??0})]})})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2 rounded-2xl border border-border bg-surface overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-accent-muted flex items-center justify-center",children:s.jsx(vw,{size:14,className:"text-accent"})}),s.jsx("h2",{className:"text-sm font-semibold text-content",children:"Recent Runs"})]}),t.length>0&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(qp,{data:j,maxHeight:24}),s.jsxs("button",{onClick:()=>e("/reports"),className:"text-xs text-accent font-medium hover:underline flex items-center gap-0.5",children:["View all ",s.jsx(fr,{size:11})]})]})]}),t.length===0?s.jsxs("div",{className:"px-5 py-12 text-center",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-inset flex items-center justify-center mx-auto mb-3",children:s.jsx(hs,{size:20,className:"text-content-tertiary"})}),s.jsx("p",{className:"text-sm font-medium text-content-secondary",children:"No runs yet"}),s.jsx("p",{className:"text-xs text-content-tertiary mt-1 mb-4",children:"Execute your first test run to see results here"}),s.jsxs(te,{size:"sm",onClick:()=>e("/run"),children:[s.jsx(Dt,{size:12})," Start a Run"]})]}):s.jsxs("div",{className:"divide-y divide-border-muted",children:[s.jsxs("div",{className:"grid grid-cols-[1fr_100px_140px_80px_60px] px-5 py-2 text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:[s.jsx("span",{children:"Run ID"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"Results"}),s.jsx("span",{children:"Duration"}),s.jsx("span",{className:"text-right",children:"Time"})]}),t.slice(0,6).map(k=>{const N=k.passed+k.failed+k.skipped,E=N>0?Math.round(k.passed/N*100):0;return s.jsxs("div",{onClick:()=>e("/reports"),className:"grid grid-cols-[1fr_100px_140px_80px_60px] items-center px-5 py-3 hover:bg-surface-inset cursor-pointer transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(c5,{status:k.status}),s.jsx("span",{className:"text-xs font-mono text-content-secondary truncate",children:k.runId.slice(0,10)})]}),s.jsx("div",{children:s.jsx("span",{className:P("text-[10px] font-semibold px-2 py-0.5 rounded-md uppercase tracking-wide",k.status==="passed"?"bg-emerald-50 text-emerald-700":k.status==="failed"?"bg-red-50 text-red-700":"bg-amber-50 text-amber-700"),children:k.status})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-inset rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-emerald-400 rounded-full transition-all duration-500",style:{width:`${E}%`}})}),s.jsxs("span",{className:"text-[11px] text-content-secondary tabular-nums w-12 text-right",children:[k.passed,"/",N]})]}),s.jsx("span",{className:"text-[11px] text-content-tertiary tabular-nums",children:k.duration?`${(k.duration/1e3).toFixed(1)}s`:"—"}),s.jsx("span",{className:"text-[10px] text-content-tertiary text-right",children:lc(new Date(k.startedAt),{addSuffix:!1})})]},k.runId)})]})]}),s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"rounded-2xl border border-border bg-surface overflow-hidden flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-indigo-50 border border-indigo-100 flex items-center justify-center",children:s.jsx(dl,{size:14,className:"text-indigo-500"})}),s.jsx("h2",{className:"text-sm font-semibold text-content",children:"Test Suites"})]}),s.jsxs("span",{className:"text-[10px] font-semibold text-content-tertiary bg-surface-inset px-2 py-0.5 rounded-md",children:[d," cases"]})]}),r.length===0?s.jsxs("div",{className:"px-5 py-8 text-center",children:[s.jsx("p",{className:"text-sm text-content-tertiary mb-3",children:"No suites yet"}),s.jsx(te,{size:"sm",onClick:()=>e("/tests"),children:"Create Suite"})]}):s.jsx("ul",{className:"divide-y divide-border-muted max-h-[200px] overflow-y-auto",children:r.map(k=>s.jsxs("li",{onClick:()=>e("/tests"),className:"flex items-center justify-between px-5 py-2.5 hover:bg-surface-inset cursor-pointer transition-colors group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-sm text-content font-medium truncate",children:k.name}),s.jsx("span",{className:P("text-[9px] px-1.5 py-0.5 rounded font-bold uppercase flex-shrink-0",(k.type??"ui")==="api"?"bg-purple-50 text-purple-600":"bg-blue-50 text-blue-600"),children:(k.type??"ui").toUpperCase()})]}),s.jsxs("p",{className:"text-[11px] text-content-tertiary mt-0.5",children:[k.caseCount??0," cases"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(qp,{data:d5(t,k.id),maxHeight:24}),s.jsx(fr,{size:13,className:"text-content-tertiary opacity-0 group-hover:opacity-100 transition-opacity"})]})]},k.id))})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{label:"Smart Tests",icon:wt,to:"/story",gradient:"from-violet-500 to-indigo-600"},{label:"Self-Healing",icon:tc,to:"/healing",gradient:"from-rose-500 to-pink-600"},{label:"Variables",icon:Om,to:"/variables",gradient:"from-teal-500 to-cyan-600"},{label:"Reports",icon:hs,to:"/reports",gradient:"from-amber-500 to-orange-600"}].map(({label:k,icon:N,to:E,gradient:R})=>s.jsxs("button",{type:"button",onClick:()=>e(E),className:"group relative overflow-hidden rounded-xl border border-border bg-surface px-3.5 py-3 hover:border-border-strong hover:shadow-card transition-all duration-200 flex items-center gap-3",children:[s.jsx("div",{className:P("w-8 h-8 rounded-lg bg-gradient-to-br flex items-center justify-center flex-shrink-0",R),children:s.jsx(N,{size:14,className:"text-white"})}),s.jsx("p",{className:"text-xs font-semibold text-content group-hover:text-accent transition-colors",children:k})]},E))})]})]}),c&&s.jsx("div",{className:"rounded-2xl border border-border bg-surface px-6 py-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:P("w-10 h-10 rounded-xl flex items-center justify-center",c.status==="passed"?"bg-emerald-50 border border-emerald-100":c.status==="failed"?"bg-red-50 border border-red-100":"bg-amber-50 border border-amber-100"),children:c.status==="passed"?s.jsx(we,{size:18,className:"text-emerald-500"}):c.status==="failed"?s.jsx(ts,{size:18,className:"text-red-500"}):s.jsx(Ap,{size:18,className:"text-amber-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-semibold text-content-secondary uppercase tracking-wider",children:"Last Run"}),s.jsxs("p",{className:"text-sm font-bold text-content mt-0.5",children:[c.passed," passed, ",c.failed," failed",c.skipped>0&&`, ${c.skipped} skipped`]})]})]}),s.jsxs("div",{className:"flex items-center gap-6 text-xs text-content-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Br,{size:12}),s.jsx("span",{children:lc(new Date(c.startedAt),{addSuffix:!0})})]}),c.duration&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ap,{size:12}),s.jsxs("span",{children:[(c.duration/1e3).toFixed(1),"s"]})]}),s.jsx("div",{className:"flex items-center gap-1.5 font-mono",children:s.jsxs("span",{children:["#",c.runId.slice(0,8)]})}),s.jsxs(te,{size:"sm",variant:"ghost",onClick:()=>e("/reports"),children:["Details ",s.jsx(fr,{size:11})]})]})]})})]})]})}function Ms({open:e,title:t="Confirm Delete",message:n,confirmLabel:r="Delete",onConfirm:a,onCancel:i}){return m.useEffect(()=>{if(!e)return;const l=o=>{o.key==="Escape"&&i(),o.key==="Enter"&&(o.preventDefault(),a())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,i]),e?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-fade-in",children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),s.jsxs("div",{className:"relative bg-surface rounded-2xl shadow-modal w-full max-w-sm mx-4 p-6 animate-scale-in border border-border",children:[s.jsxs("div",{className:"flex items-start gap-3.5",children:[s.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-xl bg-red-50 border border-red-200/50 flex items-center justify-center",children:s.jsx(ts,{size:18,className:"text-red-500"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-content",children:t}),s.jsx("p",{className:"mt-1 text-sm text-content-secondary leading-relaxed",children:n})]})]}),s.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2.5",children:[s.jsx(te,{variant:"secondary",size:"sm",onClick:i,children:"Cancel"}),s.jsx(te,{variant:"danger",size:"sm",onClick:a,children:r})]})]})]}):null}function Ts(){const[e,t]=m.useState({open:!1,message:"",onConfirm:()=>{}}),n=m.useCallback((i,l)=>{t({open:!0,message:i,onConfirm:l})},[]),r=m.useCallback(()=>{t(i=>({...i,open:!1}))},[]),a=m.useCallback(()=>{e.onConfirm(),t(i=>({...i,open:!1}))},[e.onConfirm]);return{modalProps:{open:e.open,message:e.message,onConfirm:a,onCancel:r},confirmDelete:n}}const x5=[{id:"all",label:"All"},{id:"auth",label:"Auth"},{id:"crud",label:"CRUD"},{id:"navigation",label:"Navigation"},{id:"form",label:"Form"},{id:"api",label:"API"}],m5={auth:"bg-violet-50 text-violet-600",crud:"bg-blue-50 text-blue-600",navigation:"bg-teal-50 text-teal-600",form:"bg-orange-50 text-orange-600",api:"bg-purple-50 text-purple-600"};function h5({open:e,onClose:t,suiteId:n,onCreated:r}){const[a,i]=m.useState("all"),[l,o]=m.useState(null),{data:c=[],isLoading:d}=pe({queryKey:["templates"],queryFn:()=>Ow.list(),enabled:e}),x=V({mutationFn:b=>Wn.create(n,{name:b.name,description:b.description,steps:b.steps.map((f,v)=>({...f,id:crypto.randomUUID(),order:v+1}))}),onSuccess:()=>{O.success("Test case created from template"),r(),t()},onError:b=>{O.error(b.message),o(null)}}),p=b=>{o(b.id),x.mutate(b)},y=a==="all"?c:c.filter(b=>b.category===a);return e?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t,children:s.jsxs("div",{className:"bg-surface rounded-2xl border border-border shadow-modal w-full max-w-2xl mx-4 overflow-hidden flex flex-col max-h-[85vh]",onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border flex-shrink-0",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-bold text-content",children:"Test Case Templates"}),s.jsx("p",{className:"text-[11px] text-content-tertiary mt-0.5",children:"Start from a pre-built template"})]}),s.jsx("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg text-content-tertiary hover:bg-surface-inset hover:text-content transition-colors",children:s.jsx(be,{size:14})})]}),s.jsx("div",{className:"flex gap-1 px-5 py-2.5 border-b border-border flex-shrink-0 overflow-x-auto",children:x5.map(b=>s.jsx("button",{type:"button",onClick:()=>i(b.id),className:P("px-3 py-1.5 rounded-lg text-xs font-semibold transition-colors flex-shrink-0",a===b.id?"bg-accent text-white":"text-content-secondary hover:bg-surface-inset"),children:b.label},b.id))}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 min-h-0",children:d?s.jsx("div",{className:"grid grid-cols-2 gap-3",children:[1,2,3,4].map(b=>s.jsx("div",{className:"h-28 rounded-xl skeleton-shimmer"},b))}):y.length===0?s.jsx("div",{className:"py-12 text-center",children:s.jsx("p",{className:"text-sm text-content-tertiary",children:"No templates in this category"})}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:y.map(b=>s.jsxs("div",{className:"rounded-xl border border-border bg-surface p-4 flex flex-col gap-3 hover:border-border-strong hover:shadow-card transition-all",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-surface-inset flex items-center justify-center flex-shrink-0",children:s.jsx(Ps,{size:13,className:"text-content-secondary"})}),s.jsx("div",{className:"min-w-0",children:s.jsx("p",{className:"text-sm font-bold text-content truncate",children:b.name})})]}),s.jsx("span",{className:P("text-[9px] px-1.5 py-0.5 rounded font-bold uppercase flex-shrink-0",m5[b.category]??"bg-surface-inset text-content-tertiary"),children:b.category})]}),s.jsx("p",{className:"text-xs text-content-secondary leading-relaxed",children:b.description}),s.jsxs("div",{className:"flex items-center justify-between mt-auto",children:[s.jsxs("span",{className:"text-[10px] text-content-tertiary",children:[b.steps.length," step",b.steps.length!==1?"s":""]}),s.jsx("button",{type:"button",onClick:()=>p(b),disabled:x.isPending,className:P("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold transition-colors",l===b.id?"bg-emerald-50 text-emerald-600 border border-emerald-200":"bg-accent/10 text-accent hover:bg-accent/20",x.isPending&&"opacity-50 cursor-not-allowed"),children:l===b.id?s.jsxs(s.Fragment,{children:[s.jsx(we,{size:11})," Creating..."]}):"Use Template"})]})]},b.id))})})]})}):null}function Gy(){return pe({queryKey:["suites"],queryFn:()=>Kr.list()})}function p5(){const e=ie();return V({mutationFn:Kr.create,onSuccess:()=>{e.invalidateQueries({queryKey:["suites"]}),O.success("Suite created")},onError:t=>O.error(t.message)})}function Qy(){const e=ie();return V({mutationFn:({id:t,data:n})=>Kr.update(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["suites"]}),O.success("Suite updated")},onError:t=>O.error(t.message)})}function f5(){const e=ie();return V({mutationFn:Kr.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["suites"]}),O.success("Suite deleted")},onError:t=>O.error(t.message)})}function g5(e){return pe({queryKey:["cases",e],queryFn:()=>Wn.list(e),enabled:!!e})}function y5(e,t){return pe({queryKey:["cases",e,t],queryFn:()=>Wn.get(e,t),enabled:!!e&&!!t})}function Hp(e){const t=ie();return V({mutationFn:n=>Wn.create(e,n),onSuccess:()=>{t.invalidateQueries({queryKey:["cases",e]}),O.success("Test case created")},onError:n=>O.error(n.message)})}function b5(e){const t=ie();return V({mutationFn:({caseId:n,data:r})=>Wn.update(e,n,r),onSuccess:(n,{caseId:r})=>{t.invalidateQueries({queryKey:["cases",e]}),t.invalidateQueries({queryKey:["cases",e,r]}),O.success("Test case updated")},onError:n=>O.error(n.message)})}function v5(e){const t=ie();return V({mutationFn:n=>Wn.delete(e,n),onSuccess:()=>{t.invalidateQueries({queryKey:["cases",e]}),O.success("Test case deleted")},onError:n=>O.error(n.message)})}function j5(e,t){const n=ie();return V({mutationFn:r=>Wr.add(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function N5(e,t){const n=ie();return V({mutationFn:({stepId:r,instruction:a,timeout:i,stepType:l,retries:o,mockUrl:c,mockResponse:d,mockStatus:x,runAudit:p,soft:y,visualCheck:b})=>Wr.update(e,t,r,{instruction:a,timeout:i,stepType:l,retries:o,mockUrl:c,mockResponse:d,mockStatus:x,runAudit:p,soft:y,visualCheck:b}),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function w5(e,t){const n=ie();return V({mutationFn:r=>Wr.reorder(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function k5(e,t){const n=ie();return V({mutationFn:r=>Wr.delete(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function S5(e,t){const n=ie();return V({mutationFn:r=>Wr.generate(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]}),O.success("Code generated")},onError:r=>O.error(r.message)})}function C5(e,t){const n=ie();return V({mutationFn:()=>Wr.generateAll(e,t),onSuccess:r=>{n.invalidateQueries({queryKey:["cases",e,t]}),O.success(`Generated code for ${r.generated} step(s)`)},onError:r=>O.error(r.message)})}const xl=new Map,fx=new Set;function Yy(){for(const e of fx)e()}function Od(){return"all"}function Dd(e){return`suite:${e}`}function Id(e,t){return`case:${e}:${t}`}function Fd(e,t){xl.set(e,{op:t,startedAt:Date.now()}),Yy()}function Ld(e){xl.delete(e),Yy()}function _d(e){var t;return((t=xl.get(e))==null?void 0:t.op)??null}function E5(){const e=new Map,t=new Map;let n=null;for(const[r,a]of xl)r==="all"?n=a.op:r.startsWith("suite:")?e.set(r.slice(6),a.op):r.startsWith("case:")&&t.set(r.slice(5),a.op);return{allOp:n,busySuites:e,busyCases:t,activeCount:xl.size}}function P5(e){return fx.add(e),()=>{fx.delete(e)}}const st={startAll:e=>Fd(Od(),e),finishAll:()=>Ld(Od()),startSuite:(e,t)=>Fd(Dd(e),t),finishSuite:e=>Ld(Dd(e)),startCase:(e,t,n)=>Fd(Id(e,t),n),finishCase:(e,t)=>Ld(Id(e,t)),isAllBusy:()=>_d(Od()),isSuiteBusy:e=>_d(Dd(e)),isCaseBusy:(e,t)=>_d(Id(e,t)),getSnapshot:E5,subscribe:P5};function zl(e,t){var n;if(e.failed>0){const r=e.results.filter(a=>a.action==="failed");O.error(`${t}: ${e.failed} failed — ${((n=r[0])==null?void 0:n.error)??"Unknown error"}`)}else if(e.created>0||e.synced>0){const r=[];e.created>0&&r.push(`${e.created} created`),e.synced>0&&r.push(`${e.synced} synced`),e.skipped>0&&r.push(`${e.skipped} skipped`),O.success(`Xray: ${r.join(", ")}`)}else e.skipped>0&&O.success(`Xray: ${e.skipped} already up to date`)}function R5(){return pe({queryKey:["xray","status"],queryFn:()=>Gr.status(),retry:1,staleTime:1e4})}function Jy(e){return pe({queryKey:["xray","status",e],queryFn:()=>Gr.suiteStatus(e),enabled:!!e,retry:1,staleTime:1e4})}function z5(){const e=ie();return V({mutationFn:()=>(st.startAll("create"),Gr.createAll()),onSuccess:t=>{st.finishAll(),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Create in Xray")},onError:t=>{st.finishAll(),O.error(`Xray create failed: ${t.message}`)}})}function Xy(){const e=ie();return V({mutationFn:t=>(st.startSuite(t,"create"),Gr.createSuite(t)),onSuccess:(t,n)=>{st.finishSuite(n),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Create Suite")},onError:(t,n)=>{st.finishSuite(n),O.error(`Xray create failed: ${t.message}`)}})}function Zy(){const e=ie();return V({mutationFn:({suiteId:t,caseId:n})=>(st.startCase(t,n,"create"),Gr.createCase(t,n)),onSuccess:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Create Case")},onError:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),O.error(`Xray create failed: ${t.message}`)}})}function M5(){const e=ie();return V({mutationFn:t=>(st.startSuite(t,"sync"),Gr.syncSuite(t)),onSuccess:(t,n)=>{st.finishSuite(n),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Sync Suite")},onError:(t,n)=>{st.finishSuite(n),O.error(`Xray sync failed: ${t.message}`)}})}function eb(){const e=ie();return V({mutationFn:({suiteId:t,caseId:n})=>(st.startCase(t,n,"sync"),Gr.syncCase(t,n)),onSuccess:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Sync Case")},onError:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),O.error(`Xray sync failed: ${t.message}`)}})}function $m({code:e,maxLines:t,className:n}){const[r,a]=m.useState(!1),i=async()=>{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)},l=!e.trim();return s.jsxs("div",{className:P("relative rounded-xl bg-[#0d1117] text-slate-300 ring-1 ring-white/5 overflow-hidden",n),children:[!l&&s.jsx("button",{type:"button",onClick:()=>void i(),className:P("absolute top-2.5 right-2.5 p-1.5 rounded-md transition-all duration-150",r?"bg-emerald-500/20 text-emerald-400":"text-slate-500 hover:text-slate-300 hover:bg-white/10"),title:"Copy code",children:r?s.jsx(Oe,{size:13}):s.jsx(Rm,{size:13})}),s.jsx("pre",{className:P("p-4 text-xs font-mono leading-relaxed overflow-x-auto",t&&`line-clamp-${t}`),style:t?{maxHeight:`${t*1.5}rem`,overflow:"auto"}:void 0,children:s.jsx("code",{children:l?"// No code generated yet":e})})]})}const T5={"not-created":{bg:"bg-surface-inset",text:"text-content-tertiary",dot:"bg-content-tertiary",border:"border-border",label:"Not Created"},created:{bg:"bg-emerald-50",text:"text-emerald-700",dot:"bg-emerald-500",border:"border-emerald-200/60",label:"Created"},synced:{bg:"bg-emerald-50/60",text:"text-emerald-600",dot:"bg-emerald-400",border:"border-emerald-200/60",label:"Synced"},"update-pending":{bg:"bg-amber-50",text:"text-amber-700",dot:"bg-amber-500",border:"border-amber-200/60",label:"Update Pending"}};function Um({status:e,xrayKey:t}){const n=T5[e];return s.jsxs("span",{className:P("inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md text-[10px] font-semibold whitespace-nowrap border tracking-wide",n.bg,n.text,n.border),children:[s.jsx("span",{className:P("w-1.5 h-1.5 rounded-full flex-shrink-0",n.dot)}),n.label,t&&s.jsxs("span",{className:"text-[9px] opacity-60 truncate max-w-[80px]",title:t,children:["(",t,")"]})]})}const A5={"not-created":{icon:Dm,label:"Push to Xray",title:"Create in Xray",btnClass:"bg-gradient-to-b from-emerald-500 to-emerald-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-emerald-600",iconHover:"hover:bg-emerald-50"},"update-pending":{icon:Am,label:"Sync Xray",title:"Sync changes to Xray",btnClass:"bg-gradient-to-b from-amber-500 to-amber-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-amber-500",iconHover:"hover:bg-amber-50"},created:{icon:we,label:"Synced with Xray",title:"Up to date -- click to re-sync",btnClass:"bg-gradient-to-b from-emerald-500 to-emerald-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-emerald-500",iconHover:"hover:bg-emerald-50"},synced:{icon:we,label:"Synced with Xray",title:"Up to date -- click to re-sync",btnClass:"bg-gradient-to-b from-emerald-500 to-emerald-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-emerald-500",iconHover:"hover:bg-emerald-50"}};function ml({status:e,onClick:t,busy:n=!1,variant:r="full",label:a}){const i=A5[e],l=i.icon,o=a??i.label;return r==="icon"?s.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),t()},title:n?"Processing...":i.title,className:P("p-1.5 rounded-lg transition-all duration-150",n?"cursor-wait opacity-50":P(i.iconClass,i.iconHover)),children:n?s.jsx(ae,{size:14,className:"animate-spin text-accent"}):s.jsx(l,{size:14})}):s.jsxs("button",{type:"button",onClick:()=>t(),title:n?"Processing...":i.title,className:P("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-150",n?"bg-surface-inset text-content-tertiary cursor-wait":i.btnClass),children:[n?s.jsx(ae,{size:13,className:"animate-spin"}):s.jsx(l,{size:13}),n?"Processing...":o]})}function O5(e){return pe({queryKey:["hooks",e],queryFn:()=>Vr.get(e),enabled:!!e})}function D5(e){const t=ie();return V({mutationFn:({hookType:n,instruction:r,order:a})=>Vr.addStep(e,n,{instruction:r,order:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function I5(e){const t=ie();return V({mutationFn:({hookType:n,stepId:r,instruction:a,timeout:i})=>Vr.updateStep(e,n,r,{instruction:a,timeout:i}),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function F5(e){const t=ie();return V({mutationFn:({hookType:n,stepId:r})=>Vr.deleteStep(e,n,r),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function L5(e){const t=ie();return V({mutationFn:({hookType:n,stepIds:r})=>Vr.reorderSteps(e,n,r),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function _5(e){const t=ie();return V({mutationFn:({hookType:n,stepId:r})=>Vr.generateStep(e,n,r),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]}),O.success("Hook step code generated")},onError:n=>O.error(n.message)})}function $5(e){const t=ie();return V({mutationFn:n=>Vr.generateAll(e,n),onSuccess:n=>{t.invalidateQueries({queryKey:["hooks",e]}),O.success(`Generated code for ${n.generated} hook step(s)`)},onError:n=>O.error(n.message)})}const U5=[{type:"before_all",label:"Before All",desc:"Runs once before all test cases in the suite",icon:s.jsx(K2,{size:16}),color:"text-emerald-600"},{type:"before_each",label:"Before Each",desc:"Runs before every test case",icon:s.jsx(Lc,{size:16}),color:"text-blue-600"},{type:"after_each",label:"After Each",desc:"Runs after every test case",icon:s.jsx(hw,{size:16}),color:"text-amber-600"},{type:"after_all",label:"After All",desc:"Runs once after all test cases in the suite",icon:s.jsx(W2,{size:16}),color:"text-red-500"}];function B5({suiteId:e,open:t,onClose:n}){const{data:r,isLoading:a}=O5(e);return t?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:n}),s.jsxs("div",{className:"relative w-full max-w-3xl max-h-[85vh] bg-surface rounded-xl shadow-2xl flex flex-col overflow-hidden mx-4",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-gradient-to-r from-slate-50 to-white",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-bold text-content",children:"Suite Hooks"}),s.jsx("p",{className:"text-xs text-content-tertiary mt-0.5",children:"Lifecycle hooks run setup/teardown around your test cases (Playwright hooks)"})]}),s.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-surface-inset transition-colors text-content-tertiary hover:text-content-secondary",children:s.jsx(be,{size:18})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:a?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ae,{size:24,className:"animate-spin text-accent"})}):U5.map(i=>s.jsx(q5,{suiteId:e,hookType:i.type,label:i.label,description:i.desc,icon:i.icon,color:i.color,steps:(r==null?void 0:r[i.type])??[]},i.type))})]})]}):null}function q5({suiteId:e,hookType:t,label:n,description:r,icon:a,color:i,steps:l}){const[o,c]=m.useState(l.length>0),[d,x]=m.useState(""),[p,y]=m.useState(""),[b,f]=m.useState(null),[v,w]=m.useState(""),[h,u]=m.useState(new Set),[g,j]=m.useState(null),[k,N]=m.useState(null),E=D5(e),R=F5(e),{modalProps:L,confirmDelete:M}=Ts(),W=L5(e),G=I5(e),ne=_5(e),A=$5(e),Y=()=>{d.trim()&&(E.mutate({hookType:t,instruction:d.trim()}),x(""))},se=_=>{y(_),ne.mutate({hookType:t,stepId:_},{onSettled:()=>y("")})},le=()=>{A.mutate(t)},T=_=>{if(!g||g===_){j(null),N(null);return}const re=l.map(me=>me.id),U=re.indexOf(g),xe=re.indexOf(_);U<0||xe<0||(re.splice(U,1),re.splice(xe,0,g),W.mutate({hookType:t,stepIds:re}),j(null),N(null))},S=_=>{f(_.id),w(_.instruction)},z=_=>{var re;v.trim()&&v!==((re=l.find(U=>U.id===_))==null?void 0:re.instruction)&&G.mutate({hookType:t,stepId:_,instruction:v.trim()}),f(null)},q=l.filter(_=>{var re;return!((re=_.generatedCode)!=null&&re.trim())}).length;return s.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:()=>c(!o),className:"w-full flex items-center gap-3 px-4 py-3 bg-surface-inset hover:bg-surface-inset transition-colors text-left",children:[o?s.jsx(Nt,{size:14,className:"text-content-tertiary"}):s.jsx(Ht,{size:14,className:"text-content-tertiary"}),s.jsx("span",{className:P("flex-shrink-0",i),children:a}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm font-semibold text-content-secondary",children:n}),s.jsx("span",{className:"text-[10px] text-content-tertiary ml-2",children:r})]}),s.jsxs("span",{className:P("text-[10px] font-semibold px-2 py-0.5 rounded-full",l.length>0?"bg-accent/10 text-accent":"bg-slate-200 text-content-tertiary"),children:[l.length," step",l.length!==1?"s":""]})]}),o&&s.jsxs("div",{className:"border-t border-border bg-surface",children:[l.length===0?s.jsx("div",{className:"px-4 py-6 text-center",children:s.jsx("p",{className:"text-xs text-content-tertiary",children:"No steps yet — add one below"})}):s.jsx("div",{className:"divide-y divide-slate-100",children:l.map((_,re)=>s.jsxs("div",{draggable:!0,onDragStart:()=>j(_.id),onDragOver:U=>{U.preventDefault(),N(_.id)},onDragLeave:()=>N(null),onDrop:()=>T(_.id),onDragEnd:()=>{j(null),N(null)},className:P("flex items-start gap-2 px-4 py-2.5 group transition-colors",k===_.id&&"bg-accent/5 border-l-2 border-accent",g===_.id&&"opacity-40"),children:[s.jsx("div",{className:"pt-0.5 cursor-grab text-content-tertiary opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(Dc,{size:12})}),s.jsx("span",{className:"text-[10px] font-bold text-content-tertiary pt-0.5 w-4 flex-shrink-0",children:re+1}),s.jsxs("div",{className:"flex-1 min-w-0",children:[b===_.id?s.jsx("input",{autoFocus:!0,className:"w-full text-xs border border-accent rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-accent",value:v,onChange:U=>w(U.target.value),onBlur:()=>z(_.id),onKeyDown:U=>{U.key==="Enter"&&z(_.id),U.key==="Escape"&&f(null)}}):s.jsxs("p",{className:"text-xs text-content-secondary cursor-pointer hover:text-accent transition-colors flex items-center gap-1.5",onClick:()=>S(_),title:"Click to edit",children:[_.instruction,_.generatedCode&&!h.has(_.id)&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-green-400 flex-shrink-0",title:"Code generated"})]}),_.generatedCode&&h.has(_.id)&&s.jsx("div",{className:"mt-1",children:s.jsx($m,{code:_.generatedCode,maxLines:6})})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[_.generatedCode&&s.jsx("button",{title:h.has(_.id)?"Hide code":"Show code",onClick:()=>u(U=>{const xe=new Set(U);return xe.has(_.id)?xe.delete(_.id):xe.add(_.id),xe}),className:P("p-1 rounded transition-colors",h.has(_.id)?"text-content-secondary bg-slate-100":"text-content-tertiary hover:bg-surface-inset"),children:s.jsx(Pm,{size:12})}),s.jsx("button",{title:"Generate code",onClick:()=>se(_.id),disabled:p===_.id,className:"p-1 rounded hover:bg-purple-50 text-purple-500 transition-colors",children:p===_.id?s.jsx(ae,{size:12,className:"animate-spin"}):s.jsx(_r,{size:12})}),s.jsx("button",{title:"Delete step",onClick:()=>M("Delete this hook step? This cannot be undone.",()=>R.mutate({hookType:t,stepId:_.id})),className:"p-1 rounded hover:bg-red-50 text-red-400 transition-colors",children:s.jsx(Kt,{size:12})})]})]},_.id))}),s.jsxs("div",{className:"px-4 py-3 border-t border-slate-100 bg-surface-inset/50 flex items-center gap-2",children:[s.jsx("input",{className:"flex-1 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent placeholder:text-content-tertiary",value:d,onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&Y()},placeholder:"Add a step (e.g. Navigate to login page)"}),s.jsxs("button",{type:"button",onClick:Y,disabled:!d.trim()||E.isPending,className:P("inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors",d.trim()?"bg-accent text-white hover:bg-accent/90":"bg-slate-200 text-content-tertiary cursor-not-allowed"),children:[E.isPending?s.jsx(ae,{size:11,className:"animate-spin"}):s.jsx(Rs,{size:11}),"Add"]}),l.length>0&&q>0&&s.jsxs("button",{type:"button",onClick:le,disabled:A.isPending,className:"inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium bg-purple-600 text-white hover:bg-purple-700 transition-colors",children:[A.isPending?s.jsx(ae,{size:11,className:"animate-spin"}):s.jsx(_r,{size:11}),"Generate All (",q,")"]})]})]}),s.jsx(Ms,{...L})]})}const Kp={person:{icon:Im,label:"Person"},internet:{icon:nn,label:"Internet"},phone:{icon:ow,label:"Phone"},location:{icon:sw,label:"Location"},company:{icon:L2,label:"Company"},finance:{icon:A2,label:"Finance"},date:{icon:_2,label:"Date"},lorem:{icon:jw,label:"Lorem"},string:{icon:O2,label:"String"},number:{icon:zm,label:"Number"},datatype:{icon:yw,label:"Datatype"},image:{icon:Mm,label:"Image"},color:{icon:lw,label:"Color"},commerce:{icon:mw,label:"Commerce"},vehicle:{icon:$2,label:"Vehicle"},system:{icon:J2,label:"System"}},$d=[{name:"FIRST_NAME",example:"Alice"},{name:"LAST_NAME",example:"Smith"},{name:"AGE",example:"34"},{name:"EMAIL",example:"alice.smith123@example.com"},{name:"PHONE",example:"415-782-3901"},{name:"PASSWORD",example:"Xk9#mP2$qL"}];function zi(e,t){return e==="classic"?`{{FAKE_${t}}}`:`{{FAKE_${e}_${t}}}`.toUpperCase()}async function H5(){const e=await fetch("/api/faker/generators");if(!e.ok)throw new Error("Failed to load generators");return e.json()}function K5({onInsert:e}){var k;const[t,n]=m.useState(!1),[r,a]=m.useState("person"),[i,l]=m.useState(""),[o,c]=m.useState("6"),[d,x]=m.useState([]),{data:p=[],isLoading:y}=pe({queryKey:["faker-generators"],queryFn:H5,enabled:t,staleTime:1/0}),b=m.useMemo(()=>{if(!i.trim())return null;const N=i.toLowerCase(),E=[];for(const R of p)for(const L of R.methods){const M=`${R.category}_${L.name}`.toLowerCase();(L.name.toLowerCase().includes(N)||R.category.toLowerCase().includes(N)||M.includes(N)||L.example.toLowerCase().includes(N))&&E.push({category:R.category,method:L})}for(const R of $d)(R.name.toLowerCase().includes(N)||R.example.toLowerCase().includes(N))&&E.push({category:"classic",method:R});return E},[i,p]),f=m.useMemo(()=>{var N;return r==="classic"?null:((N=p.find(E=>E.category===r))==null?void 0:N.methods)??[]},[r,p]),v=m.useCallback((N,E)=>{const R=zi(N,E);x(L=>L.includes(R)?L.filter(M=>M!==R):[...L,R])},[]),w=m.useCallback(()=>{d.length>0&&e(d.join(", ")),x([]),n(!1),l("")},[d,e]),h=m.useCallback(()=>{d.length>0&&e(d.join(", ")),x([]),n(!1),l("")},[d,e]),u=m.useCallback(N=>{x(E=>E.filter(R=>R!==N))},[]),g=()=>{const E=`{{FAKE_NUMBER_${Math.max(1,Math.min(20,parseInt(o,10)||6))}}}`;x(R=>R.includes(E)?R:[...R,E])},j=m.useMemo(()=>[...p.map(E=>E.category),"classic"],[p]);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>n(!0),title:"Insert dynamic data token",className:P("inline-flex items-center justify-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium border transition-all duration-150 focus:outline-none","bg-gradient-to-b from-violet-500 to-violet-600 text-white border-violet-700 shadow-sm hover:brightness-110 hover:shadow-md"),children:[s.jsx(wt,{size:12}),s.jsx("span",{className:"hidden sm:inline",children:"Fake Data"}),s.jsx(Nt,{size:10})]}),t&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm animate-fade-in",onClick:N=>{N.target===N.currentTarget&&h()},children:s.jsxs("div",{className:"bg-surface rounded-2xl shadow-modal w-full max-w-2xl mx-4 overflow-hidden border border-border animate-scale-in flex flex-col",style:{maxHeight:"min(640px, 85vh)"},children:[s.jsxs("div",{className:"flex items-center gap-3 px-5 py-3.5 border-b border-border bg-gradient-to-r from-violet-50 to-indigo-50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(wt,{size:16,className:"text-violet-500"}),s.jsx("h2",{className:"text-sm font-bold text-violet-800",children:"Faker Data"}),s.jsxs("span",{className:"text-[10px] text-violet-500 bg-violet-100 px-2 py-0.5 rounded-full font-medium",children:[p.reduce((N,E)=>N+E.methods.length,0)+$d.length,"+ generators"]})]}),s.jsx("button",{type:"button",onClick:h,className:"p-1 rounded-lg hover:bg-violet-100 text-violet-400 hover:text-violet-600 transition-colors",children:s.jsx(be,{size:16})})]}),s.jsx("div",{className:"px-5 py-3 border-b border-border flex-shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2 bg-surface-inset rounded-xl px-3 py-2 border border-border focus-within:border-violet-300 focus-within:ring-2 focus-within:ring-violet-100 transition-all",children:[s.jsx(Kn,{size:14,className:"text-content-tertiary flex-shrink-0"}),s.jsx("input",{type:"text",value:i,onChange:N=>l(N.target.value),placeholder:"Search generators... (e.g. email, address, uuid)",className:"flex-1 bg-transparent outline-none text-sm text-content placeholder:text-content-tertiary",autoFocus:!0}),i&&s.jsx("button",{type:"button",onClick:()=>l(""),className:"text-content-tertiary hover:text-content transition-colors",children:s.jsx(be,{size:12})})]})}),s.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[s.jsx("div",{className:"w-40 flex-shrink-0 border-r border-border overflow-y-auto bg-surface-inset/40 py-2 px-2 space-y-0.5",children:y?s.jsx("div",{className:"space-y-2 px-1",children:Array.from({length:8}).map((N,E)=>s.jsx("div",{className:"h-7 rounded-lg bg-surface-inset animate-pulse"},E))}):j.map(N=>{const E=Kp[N]??{icon:qr,label:N.charAt(0).toUpperCase()+N.slice(1)},R=N==="classic"?wt:E.icon,L=N==="classic"?"Classic":E.label;return s.jsxs("button",{type:"button",onClick:()=>{a(N),l("")},className:P("w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-[11px] font-medium transition-all text-left",r===N&&!i?"bg-violet-100 text-violet-700 shadow-sm":"text-content-secondary hover:bg-surface-inset hover:text-content"),children:[s.jsx(R,{size:13,className:"flex-shrink-0"}),s.jsx("span",{className:"truncate",children:L})]},N)})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2 px-3",children:y?s.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((N,E)=>s.jsx("div",{className:"h-12 rounded-xl bg-surface-inset animate-pulse"},E))}):b?s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2",children:[b.length," result",b.length!==1?"s":"",' for "',i,'"']}),b.length===0?s.jsx("p",{className:"text-sm text-content-tertiary text-center py-8",children:"No generators found. Try a different search term."}):s.jsx("div",{className:"space-y-1",children:b.map(({category:N,method:E})=>s.jsx(Ud,{category:N,method:E,selected:d.includes(zi(N,E.name)),onToggle:v},`${N}-${E.name}`))})]}):r==="classic"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2",children:"Classic Tokens (backward-compatible)"}),s.jsx("div",{className:"space-y-1",children:$d.map(N=>s.jsx(Ud,{category:"classic",method:N,selected:d.includes(zi("classic",N.name)),onToggle:v},N.name))}),s.jsxs("div",{className:"mt-4 pt-3 border-t border-border",children:[s.jsxs("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2 flex items-center gap-1",children:[s.jsx(zm,{size:10})," Random Number"]}),s.jsxs("div",{className:"flex items-center gap-2 px-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-1 bg-surface-inset rounded-lg px-3 py-2 border border-border",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Digits:"}),s.jsx("input",{type:"number",min:1,max:20,value:o,onChange:N=>c(N.target.value),onKeyDown:N=>N.key==="Enter"&&g(),className:"w-12 text-sm bg-transparent outline-none text-content font-mono tabular-nums"})]}),s.jsx("button",{type:"button",onClick:g,className:"flex-shrink-0 px-3 py-2 rounded-lg bg-violet-600 hover:bg-violet-700 text-white text-[11px] font-semibold transition-colors",children:"+ Add"})]}),s.jsx("p",{className:"text-[10px] text-content-tertiary px-1 mt-2 font-mono",children:`→ {{FAKE_NUMBER_${Math.max(1,parseInt(o,10)||6)}}}`})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2",children:[((k=Kp[r])==null?void 0:k.label)??r," — ",(f==null?void 0:f.length)??0," generators"]}),s.jsx("div",{className:"space-y-1",children:(f??[]).map(N=>s.jsx(Ud,{category:r,method:N,selected:d.includes(zi(r,N.name)),onToggle:v},N.name))})]})})]}),d.length>0&&s.jsxs("div",{className:"px-5 py-2.5 border-t border-border bg-violet-50/50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsxs("span",{className:"text-[10px] font-bold text-violet-600 uppercase tracking-wider",children:["Selected (",d.length,")"]}),s.jsx("button",{type:"button",onClick:()=>x([]),className:"text-[10px] text-violet-400 hover:text-violet-600 transition-colors underline",children:"Clear all"})]}),s.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-16 overflow-y-auto",children:d.map(N=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-violet-100 text-violet-700 text-[10px] font-mono border border-violet-200",children:[N,s.jsx("button",{type:"button",onClick:()=>u(N),className:"text-violet-400 hover:text-violet-700 transition-colors",children:s.jsx(be,{size:10})})]},N))})]}),s.jsxs("div",{className:"px-5 py-2.5 bg-surface-inset/60 border-t border-border flex items-center justify-between flex-shrink-0",children:[s.jsxs("p",{className:"text-[10px] text-content-tertiary",children:["Click to select multiple tokens. They will be inserted ",s.jsx("strong",{children:"comma-separated"}),"."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{x([]),n(!1),l("")},className:"px-3 py-1.5 rounded-lg border border-border text-xs font-medium text-content-secondary hover:bg-surface-inset transition-colors",children:"Cancel"}),s.jsxs("button",{type:"button",onClick:w,disabled:d.length===0,className:P("px-4 py-1.5 rounded-lg text-xs font-semibold transition-all",d.length>0?"bg-violet-600 hover:bg-violet-700 text-white shadow-sm":"bg-violet-200 text-violet-400 cursor-not-allowed"),children:["Insert ",d.length>0?`${d.length} token${d.length>1?"s":""}`:""]})]})]})]})})]})}function Ud({category:e,method:t,selected:n,onToggle:r}){const a=zi(e,t.name);return s.jsxs("button",{type:"button",onClick:()=>r(e,t.name),className:P("w-full flex items-center justify-between gap-3 px-3 py-2 rounded-xl transition-colors group text-left",n?"bg-violet-100 border border-violet-200 shadow-sm":"hover:bg-violet-50 border border-transparent"),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("div",{className:P("flex-shrink-0 w-4 h-4 rounded flex items-center justify-center border transition-all",n?"bg-violet-600 border-violet-600":"border-gray-300 group-hover:border-violet-400"),children:n&&s.jsx(Oe,{size:10,className:"text-white",strokeWidth:3})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[e!=="classic"&&s.jsx("span",{className:P("text-[9px] px-1.5 py-0.5 rounded font-medium uppercase flex-shrink-0",n?"text-violet-600 bg-violet-200":"text-violet-400 bg-violet-50 group-hover:bg-violet-100"),children:e}),s.jsx("p",{className:P("text-[12px] font-medium truncate",n?"text-violet-700":"text-content group-hover:text-violet-700"),children:t.name})]}),s.jsx("p",{className:"text-[9px] text-content-tertiary font-mono truncate mt-0.5",children:a})]})]}),s.jsx("span",{className:"text-[10px] text-content-tertiary bg-surface-inset px-2 py-1 rounded-lg font-mono flex-shrink-0 max-w-[180px] truncate",children:t.example})]})}function W5({selectedIds:e,suiteId:t,suites:n,onClear:r,onDeleted:a,onMoved:i}){const l=ie(),{modalProps:o,confirmDelete:c}=Ts(),[d,x]=m.useState(""),p=V({mutationFn:()=>Wn.bulkDelete(t,Array.from(e)),onSuccess:v=>{O.success(`Deleted ${v.deleted} case${v.deleted!==1?"s":""}`),l.invalidateQueries({queryKey:["cases",t]}),a(),r()},onError:v=>O.error(v.message)}),y=V({mutationFn:v=>Wn.bulkMove(t,Array.from(e),v),onSuccess:v=>{O.success(`Moved ${v.moved} case${v.moved!==1?"s":""}`),l.invalidateQueries({queryKey:["cases",t]}),i(),r(),x("")},onError:v=>O.error(v.message)}),b=n.filter(v=>v.id!==t),f=e.size;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"fixed bottom-0 left-[248px] right-0 z-30 bg-surface border-t border-border shadow-elevated px-5 py-3 flex items-center gap-3",children:[s.jsxs("span",{className:"text-sm font-semibold text-content flex-shrink-0",children:[f," case",f!==1?"s":""," selected"]}),s.jsx("button",{type:"button",onClick:()=>O("Coming soon",{icon:"🔜"}),className:"inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-border text-content-secondary hover:bg-surface-inset transition-colors",children:"Run Selected"}),s.jsxs("button",{type:"button",onClick:()=>c(`Delete ${f} selected case${f!==1?"s":""}? This cannot be undone.`,()=>p.mutate()),disabled:p.isPending,className:"inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-red-200 text-red-600 bg-red-50 hover:bg-red-100 transition-colors disabled:opacity-50",children:[s.jsx(Kt,{size:12})," Delete Selected"]}),b.length>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(iw,{size:13,className:"text-content-tertiary flex-shrink-0"}),s.jsxs("select",{className:"text-xs border border-border rounded-lg px-2 py-1.5 bg-surface text-content-secondary focus:outline-none focus:ring-1 focus:ring-accent/30",value:d,onChange:v=>x(v.target.value),children:[s.jsx("option",{value:"",children:"Move to suite…"}),b.map(v=>s.jsx("option",{value:v.id,children:v.name},v.id))]}),d&&s.jsx("button",{type:"button",onClick:()=>y.mutate(d),disabled:y.isPending,className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:brightness-110 transition-colors disabled:opacity-50",children:"Move"})]}),s.jsx("div",{className:"flex-1"}),s.jsx("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg text-content-tertiary hover:bg-surface-inset transition-colors",children:s.jsx(be,{size:14})})]}),s.jsx(Ms,{...o})]})}function V5({passRate:e,runs:t,flaky:n}){if(!n||t<3||e===1)return null;const r=Math.round(e*100);return s.jsx("span",{title:`Flaky: ${r}% pass rate over ${t} runs`,className:"inline-flex items-center gap-0.5 text-[8px] font-semibold px-1.5 py-0.5 rounded bg-amber-50 text-amber-600 ring-1 ring-amber-200 flex-shrink-0",children:"~flaky"})}function G5({open:e,onClose:t,suiteId:n,caseId:r,onInserted:a}){const i=ie(),[l,o]=m.useState(""),[c,d]=m.useState(!1),[x,p]=m.useState(""),[y,b]=m.useState(""),{data:f=[]}=pe({queryKey:["step-library"],queryFn:()=>dr.list()}),v=V({mutationFn:u=>Wr.add(n,r,{instruction:u.instruction,...u.generatedCode?{generatedCode:u.generatedCode,strategy:"cache"}:{}}),onSuccess:()=>{i.invalidateQueries({queryKey:["cases",n,r]}),O.success("Step inserted"),a()},onError:u=>O.error(u.message)}),w=V({mutationFn:()=>dr.create({name:x,instruction:y}),onSuccess:()=>{i.invalidateQueries({queryKey:["step-library"]}),O.success("Step saved to library"),d(!1),p(""),b("")},onError:u=>O.error(u.message)}),h=f.filter(u=>!l||u.name.toLowerCase().includes(l.toLowerCase())||u.instruction.toLowerCase().includes(l.toLowerCase())||u.tags.some(g=>g.toLowerCase().includes(l.toLowerCase())));return e?s.jsxs("div",{className:"fixed right-0 top-0 bottom-0 w-80 bg-surface border-l border-border shadow-xl z-40 flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(cl,{size:14,className:"text-accent"}),s.jsx("span",{className:"text-sm font-semibold text-content",children:"Step Library"})]}),s.jsx("button",{type:"button",onClick:t,className:"p-1 rounded text-content-tertiary hover:text-content hover:bg-surface-inset",children:s.jsx(be,{size:14})})]}),s.jsx("div",{className:"px-3 py-2 border-b border-border flex-shrink-0",children:s.jsxs("div",{className:"relative",children:[s.jsx(Kn,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-content-tertiary"}),s.jsx("input",{type:"text",placeholder:"Search steps…",value:l,onChange:u=>o(u.target.value),className:"w-full pl-7 pr-3 py-1.5 text-xs border border-border rounded-lg bg-surface-inset focus:outline-none focus:ring-1 focus:ring-accent/30"})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto py-2 px-2 space-y-1",children:[h.length===0&&s.jsx("p",{className:"text-[11px] text-content-tertiary text-center py-6",children:f.length===0?"No steps in library yet":"No results"}),h.map(u=>s.jsx("div",{className:"border border-border rounded-lg p-2.5 hover:border-accent/30 hover:bg-surface-inset/50 transition-colors",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"text-xs font-semibold text-content truncate",children:u.name}),u.generatedCode?s.jsx("span",{className:"flex-shrink-0 text-[8px] px-1 py-px rounded bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-1 ring-emerald-200 dark:ring-emerald-800",children:"Ready"}):s.jsx("span",{className:"flex-shrink-0 text-[8px] px-1 py-px rounded bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-1 ring-amber-200 dark:ring-amber-800",children:"No code"})]}),s.jsx("p",{className:"text-[10px] text-content-tertiary mt-0.5 line-clamp-2",children:u.instruction}),u.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-0.5 mt-1",children:u.tags.map(g=>s.jsx("span",{className:"text-[8px] px-1 py-px rounded bg-accent/8 text-accent ring-1 ring-accent/15",children:g},g))})]}),s.jsx("button",{type:"button",onClick:()=>v.mutate({instruction:u.instruction,generatedCode:u.generatedCode}),disabled:v.isPending,className:"flex-shrink-0 text-[10px] px-2 py-1 rounded bg-accent text-white hover:brightness-110 transition-colors disabled:opacity-50",children:"Insert"})]})},u.id))]}),s.jsx("div",{className:"border-t border-border p-3 flex-shrink-0",children:c?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",placeholder:"Step name",value:x,onChange:u=>p(u.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded-lg focus:outline-none focus:ring-1 focus:ring-accent/30"}),s.jsx("textarea",{placeholder:"Step instruction",value:y,onChange:u=>b(u.target.value),rows:2,className:"w-full px-2 py-1.5 text-xs border border-border rounded-lg focus:outline-none focus:ring-1 focus:ring-accent/30 resize-none"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>w.mutate(),disabled:!x.trim()||!y.trim()||w.isPending,className:"flex-1 text-xs py-1.5 rounded-lg bg-accent text-white hover:brightness-110 transition-colors disabled:opacity-50",children:"Save"}),s.jsx("button",{type:"button",onClick:()=>d(!1),className:"text-xs px-3 py-1.5 rounded-lg border border-border text-content-secondary hover:bg-surface-inset",children:"Cancel"})]})]}):s.jsxs("button",{type:"button",onClick:()=>d(!0),className:"w-full flex items-center justify-center gap-1.5 text-xs py-2 rounded-lg border border-dashed border-border text-content-tertiary hover:text-content hover:border-accent/40 transition-colors",children:[s.jsx(Rs,{size:12})," Save current step to library"]})})]}):null}const gi=new Set,ra=new Map;let mn=null,yi=null,bi=null;const aa=new Map,vi=new Map,gx=new Set;function ia(){gx.forEach(e=>e())}const vt={subscribe(e){return gx.add(e),()=>gx.delete(e)},getSnapshot(){return{runningCaseIds:gi,runningSuiteId:mn,caseLastRun:aa,suiteLastRun:vi}},startCase(e){gi.add(e),ia()},startSuite(e){bi=e,mn=e,ia()},onRunStart(e){bi&&(yi=e,bi=null)},onCaseRunning(e,t){ra.has(e)||ra.set(e,t)},onCaseDone(e,t,n){const r=e===yi,a=aa.get(t),i=r?(a==null?void 0:a.allureRunId)??e:e;aa.set(t,{status:n,runId:e,allureRunId:i}),ia()},onComplete(e,t){const n=ra.get(e);n&&(gi.delete(n),ra.delete(e)),gi.clear(),ra.clear(),e===yi&&mn?vi.set(mn,{...t,runId:e}):mn&&vi.set(mn,{...t,runId:e}),mn=null,yi=null,bi=null,ia()},seedFromHistory(e){for(const t of e)for(const n of t.suites){vi.has(n.suiteId)||vi.set(n.suiteId,{passed:t.passed,failed:t.failed,skipped:t.skipped,runId:t.runId});const a=t.suites.reduce((i,l)=>i+l.cases.length,0)===1;for(const i of n.cases){const l=aa.get(i.caseId);l?a&&!l.allureRunId&&aa.set(i.caseId,{...l,allureRunId:t.runId}):aa.set(i.caseId,{status:i.status,runId:t.runId,allureRunId:t.runId})}}ia()},clear(){gi.clear(),ra.clear(),mn=null,yi=null,bi=null,ia()}};function qc(){const[e,t]=m.useState(()=>vt.getSnapshot());return m.useEffect(()=>vt.subscribe(()=>t(vt.getSnapshot())),[]),e}function Bm(){const[e,t]=m.useState(()=>st.getSnapshot());return m.useEffect(()=>st.subscribe(()=>t(st.getSnapshot())),[]),e}const tb=["critical","high","medium","low"],yx={critical:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-500/20 dark:ring-red-500/30",high:"bg-orange-50 dark:bg-orange-900/20 text-orange-600 dark:text-orange-400 ring-orange-500/20 dark:ring-orange-500/30",medium:"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-500/20 dark:ring-blue-500/30",low:"bg-surface-inset text-content-secondary ring-border"};function hl({tags:e,editable:t=!1,onAdd:n,onRemove:r}){const[a,i]=m.useState(""),l=()=>{const o=a.trim().toLowerCase().replace(/\s+/g,"-");if(!o||e.includes(o)){i("");return}n==null||n(o),i("")};return s.jsxs("div",{className:"flex flex-wrap gap-0.5 items-center",children:[e.map(o=>s.jsxs("span",{className:"inline-flex items-center gap-px px-1.5 py-px rounded bg-accent/8 text-accent text-[9px] font-medium ring-1 ring-accent/15 leading-tight",children:[o,t&&s.jsx("button",{type:"button",onClick:()=>r==null?void 0:r(o),children:s.jsx(be,{size:8,className:"hover:text-red-500"})})]},o)),t&&s.jsx("input",{className:"text-[9px] border border-dashed border-border rounded bg-transparent outline-none w-14 px-1.5 py-px placeholder-content-tertiary focus:border-accent focus:ring-1 focus:ring-accent/20 transition-colors",placeholder:"+ tag",value:a,onChange:o=>i(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),l())},onBlur:l}),!t&&e.length===0&&s.jsx("span",{className:"text-[10px] text-content-tertiary",children:"—"})]})}function Bd(){const e=Xn(),t=zs(),{suiteId:n="",caseId:r=""}=Sj(),a=r?"case-editor":n?"suite-detail":"suites",[i,l]=m.useState(""),[o,c]=m.useState("ui"),[d,x]=m.useState(""),{modalProps:p,confirmDelete:y}=Ts(),[b,f]=m.useState(""),[v,w]=m.useState(""),[h,u]=m.useState(""),{data:g=[],isLoading:j}=Gy();m.useEffect(()=>{var q;const z=(q=e.state)==null?void 0:q.openSuiteId;z&&g.length>0&&g.find(re=>re.id===z)&&t(`/tests/${z}`,{replace:!0})},[e.state,g]);const k=m.useMemo(()=>{const z=new Set;return g.forEach(q=>(q.tags??[]).forEach(_=>z.add(_))),Array.from(z).sort()},[g]),N=m.useMemo(()=>g.filter(z=>{const q=!b||z.name.toLowerCase().includes(b.toLowerCase())||(z.description??"").toLowerCase().includes(b.toLowerCase()),_=!v||(z.tags??[]).includes(v),re=z.type==="performance"?"audit":z.type??"ui";return q&&_&&(!h||re===h)}),[g,b,v,h]),E=g.find(z=>z.id===n),R=p5(),L=f5(),{data:M=[]}=R5(),W=z5(),G=Xy(),ne=Bm(),A=V({mutationFn:z=>Qa.start({test:z}),onError:z=>{vt.clear(),O.error(z.message)}}),Y=V({mutationFn:z=>Qa.start({suite:z}),onError:z=>{vt.clear(),O.error(z.message)}}),se=z=>{vt.startCase(z),A.mutate(z),t("/run")},le=z=>{vt.startSuite(z),Y.mutate(z),t("/run")},T=()=>{i.trim()&&(R.mutate({name:i,type:o}),l(""))};if(j)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ae,{size:20,className:"animate-spin text-accent"})});let S=null;if(a==="suites"){const z=g.filter(U=>(U.type??"ui")==="ui").length,q=g.filter(U=>(U.type??"ui")==="api").length,_=g.filter(U=>U.type==="audit"||U.type==="performance").length,re=g.reduce((U,xe)=>U+(xe.caseCount??0),0);S=s.jsx("div",{className:"flex flex-col h-full overflow-hidden bg-surface-inset/30",children:s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"max-w-5xl mx-auto px-5 py-4 space-y-3",children:[s.jsx("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:s.jsxs("div",{className:"px-5 py-3.5 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-violet-600 flex items-center justify-center shadow-sm shadow-indigo-500/20",children:s.jsx(dl,{size:18,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-base font-bold text-content tracking-tight",children:"Test Suites"}),s.jsx("p",{className:"text-[11px] text-content-tertiary mt-0.5",children:"Manage and organize your test automation"})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex items-center gap-3",children:[{label:"Suites",val:g.length,cls:"text-indigo-600 dark:text-indigo-400"},{label:"UI",val:z,cls:"text-blue-600 dark:text-blue-400"},{label:"API",val:q,cls:"text-violet-600 dark:text-violet-400"},..._>0?[{label:"Audit",val:_,cls:"text-amber-600 dark:text-amber-400"}]:[],{label:"Cases",val:re,cls:"text-emerald-600 dark:text-emerald-400"}].map(U=>s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:P("text-sm font-bold tabular-nums",U.cls),children:U.val}),s.jsx("p",{className:"text-[9px] text-content-tertiary font-medium",children:U.label})]},U.label))}),s.jsx("div",{className:"w-px h-8 bg-border"}),s.jsx(ml,{status:"not-created",variant:"full",label:"Sync All",onClick:()=>W.mutate(),busy:ne.allOp==="create"||ne.allOp==="sync"})]})]})}),s.jsxs("div",{className:"rounded-xl border border-border bg-surface px-4 py-2.5 flex items-center gap-3",children:[s.jsx("div",{className:"flex gap-0.5 flex-shrink-0 bg-surface-inset rounded-lg p-0.5",children:[["","All",g.length],["ui","UI",z],["api","API",q],..._>0?[["audit","Audit",_]]:[]].map(([U,xe,me])=>s.jsxs("button",{type:"button",onClick:()=>u(U),className:P("px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all",h===U?"bg-surface text-accent shadow-sm ring-1 ring-accent/20":"text-content-tertiary hover:text-content-secondary"),children:[xe," ",s.jsx("span",{className:"opacity-50 ml-0.5",children:me})]},U))}),s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(Kn,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-content-tertiary pointer-events-none"}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg pl-8 pr-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 focus:border-accent/40 bg-surface placeholder-content-tertiary",placeholder:"Search suites…",value:b,onChange:U=>f(U.target.value)})]}),k.length>0&&s.jsxs("select",{value:v,onChange:U=>w(U.target.value),className:"text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent bg-surface min-w-[100px]",children:[s.jsx("option",{value:"",children:"All Tags"}),k.map(U=>s.jsx("option",{value:U,children:U},U))]}),(b||v||h)&&s.jsx("button",{type:"button",onClick:()=>{f(""),w(""),u("")},className:"p-1.5 rounded-lg text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:12})}),s.jsx("div",{className:"w-px h-5 bg-border"}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx("div",{className:"flex gap-0 bg-surface-inset rounded-lg p-0.5 ring-1 ring-border",children:["ui","api","audit"].map(U=>s.jsx("button",{type:"button",onClick:()=>c(U),className:P("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all",o===U?U==="api"?"bg-violet-500 text-white shadow-sm":U==="audit"?"bg-amber-500 text-white shadow-sm":"bg-blue-500 text-white shadow-sm":"text-content-tertiary hover:text-content-secondary"),children:U==="audit"?"Audit":U},U))}),s.jsx("input",{className:"w-40 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"New suite name…",value:i,onChange:U=>l(U.target.value),onKeyDown:U=>U.key==="Enter"&&T()}),s.jsxs(te,{size:"sm",onClick:T,disabled:R.isPending,children:[s.jsx(Rs,{size:11})," Add"]})]})]}),g.length===0?s.jsxs("div",{className:"rounded-xl border-2 border-dashed border-border bg-surface flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl bg-gradient-to-br from-indigo-50 to-violet-50 dark:from-indigo-900/20 dark:to-violet-900/20 flex items-center justify-center ring-1 ring-border",children:s.jsx(qr,{size:22,className:"text-accent"})}),s.jsx("p",{className:"text-sm font-semibold text-content",children:"No suites yet"}),s.jsx("p",{className:"text-[11px] text-content-tertiary max-w-xs text-center",children:"Create your first test suite using the toolbar above — pick a type (UI, API, or Audit) and give it a name."})]}):N.length===0?s.jsxs("div",{className:"rounded-xl border-2 border-dashed border-border bg-surface flex flex-col items-center justify-center py-12 gap-2.5",children:[s.jsx(yy,{size:18,className:"text-content-tertiary"}),s.jsx("p",{className:"text-xs font-medium text-content-secondary",children:"No suites match your filters"}),s.jsx("button",{onClick:()=>{f(""),w(""),u("")},className:"text-[10px] font-medium text-accent hover:underline",children:"Clear all filters"})]}):s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:N.map(U=>{var xe,me;return s.jsx(Q5,{suite:U,xrayStatus:((xe=M.find(Ee=>Ee.suiteId===U.id))==null?void 0:xe.status)??"not-created",xrayKey:((me=M.find(Ee=>Ee.suiteId===U.id))==null?void 0:me.xrayTestSetId)??null,onOpen:()=>t(`/tests/${U.id}`),onRun:()=>le(U.id),onDelete:()=>y(`Delete suite "${U.name}"? All cases and steps will be lost.`,()=>L.mutate(U.id)),onXrayAction:()=>G.mutate(U.id),isXrayBusy:ne.busySuites.get(U.id)==="create"||ne.busySuites.get(U.id)==="sync"||ne.allOp==="create"||ne.allOp==="sync"},U.id)})})]})})})}return a==="suite-detail"&&n&&(S=s.jsx(Y5,{suiteId:n,suite:E,suites:g,newCaseName:d,onNewCaseNameChange:x,onOpenCase:z=>t(`/tests/${n}/cases/${z}`),onRunCase:z=>se(z),onRunSuite:()=>le(n),onBack:()=>t("/tests")})),a==="case-editor"&&n&&r&&(S=s.jsx(J5,{suiteId:n,caseId:r,suiteName:(E==null?void 0:E.name)??"",suiteType:(E==null?void 0:E.type)??"ui",onBack:()=>t(`/tests/${n}`),onRunCase:()=>se(r)})),s.jsxs("div",{className:"flex-1 overflow-hidden relative flex flex-col",children:[S,s.jsx(Ms,{...p})]})}function Q5({suite:e,onOpen:t,onRun:n,onDelete:r,xrayStatus:a="not-created",xrayKey:i=null,onXrayAction:l,isXrayBusy:o=!1}){const{runningCaseIds:c,runningSuiteId:d,suiteLastRun:x}=qc(),p=d===e.id,y=x.get(e.id),[b,f]=m.useState(!1),[v,w]=m.useState(e.name),[h,u]=m.useState(e.description??""),[g,j]=m.useState(e.tags??[]),[k,N]=m.useState(e.timeout?String(e.timeout):""),E=Qy(),R=m.useRef(null),L=(e.type??"ui")==="api",M=e.type==="audit"||e.type==="performance";m.useEffect(()=>{var S;b&&((S=R.current)==null||S.focus())},[b]);const W=S=>{S.stopPropagation(),f(!0)},G=S=>{S==null||S.stopPropagation(),w(e.name),u(e.description??""),j(e.tags??[]),N(e.timeout?String(e.timeout):""),f(!1)},ne=S=>{S==null||S.stopPropagation();const z=k?parseInt(k,10):void 0;E.mutate({id:e.id,data:{name:v.trim()||e.name,description:h,tags:g,timeout:z}},{onSuccess:()=>f(!1)})},A=S=>{S.key==="Enter"&&(S.preventDefault(),ne()),S.key==="Escape"&&G()};if(b)return s.jsxs("div",{className:"rounded-xl border-2 border-accent/30 bg-accent/[0.02] p-3.5 space-y-2.5",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:P("w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0",L?"bg-violet-100":"bg-blue-100"),children:s.jsx(Ps,{size:11,className:L?"text-violet-600":"text-blue-600"})}),s.jsx("input",{ref:R,className:"flex-1 text-xs font-semibold border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface",value:v,onChange:S=>w(S.target.value),onKeyDown:A,placeholder:"Suite name"})]}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:h,onChange:S=>u(S.target.value),onKeyDown:A,placeholder:"Description (optional)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:1e3,step:1e3,className:"w-32 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:k,onChange:S=>N(S.target.value),onKeyDown:A,placeholder:"Timeout (ms)"}),s.jsx("span",{className:"text-[10px] text-content-tertiary",children:"ms timeout"}),s.jsx("div",{className:"ml-auto",children:s.jsx(hl,{tags:g,editable:!0,onAdd:S=>j(z=>[...z,S]),onRemove:S=>j(z=>z.filter(q=>q!==S))})})]}),s.jsxs("div",{className:"flex gap-1.5 justify-end pt-0.5",children:[s.jsxs(te,{size:"sm",variant:"secondary",onClick:G,children:[s.jsx(be,{size:10})," Cancel"]}),s.jsxs(te,{size:"sm",onClick:ne,loading:E.isPending,children:[s.jsx(Oe,{size:10})," Save"]})]})]});const Y=L?"bg-gradient-to-b from-violet-500 to-purple-600":M?"bg-gradient-to-b from-amber-500 to-orange-600":"bg-gradient-to-b from-blue-500 to-indigo-600",se=L?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":M?"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800",le=M?"Audit":L?"API":"UI",T=e.caseCount??0;return s.jsxs("div",{className:"group rounded-xl border border-border bg-surface hover:border-accent/30 hover:shadow-md hover:shadow-accent/5 cursor-pointer transition-all flex overflow-hidden",onClick:t,children:[s.jsx("div",{className:P("w-1 flex-shrink-0 rounded-l-xl",Y)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"px-3.5 pt-3 pb-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[13px] font-bold text-content truncate flex-1",children:e.name}),s.jsxs("span",{className:P("text-[8px] px-1.5 py-0.5 rounded-md font-bold uppercase flex-shrink-0 ring-1 flex items-center gap-0.5",se),children:[M&&s.jsx(qe,{size:7})," ",le]}),s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",onClick:S=>S.stopPropagation(),children:[s.jsx("button",{type:"button",onClick:W,title:"Edit",className:"p-1.5 rounded-lg text-content-tertiary hover:text-accent hover:bg-accent/8 transition-colors",children:s.jsx(Hr,{size:12})}),s.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),r()},title:"Delete",className:"p-1.5 rounded-lg text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(Kt,{size:12})})]})]}),e.description&&s.jsx("p",{className:"text-[10px] text-content-tertiary truncate mt-1 leading-relaxed",children:e.description})]}),s.jsx("div",{className:"px-3.5 pb-2",children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-[9px] font-semibold text-content-secondary bg-surface-inset px-2 py-0.5 rounded-md ring-1 ring-border",children:[s.jsx(qr,{size:9,className:"opacity-50"}),T," case",T!==1?"s":""]}),y&&s.jsxs("span",{className:P("inline-flex items-center gap-1 text-[9px] font-semibold px-2 py-0.5 rounded-md ring-1",y.failed>0?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-200 dark:ring-red-800":"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-emerald-200 dark:ring-emerald-800"),children:[s.jsx(dy,{size:5,className:"fill-current"}),y.passed,"p / ",y.failed,"f"]}),s.jsxs("div",{className:"flex items-center gap-1",onClick:S=>S.stopPropagation(),children:[s.jsx(Um,{status:a,xrayKey:i}),s.jsx(ml,{variant:"icon",status:a,onClick:()=>l==null?void 0:l(),busy:o})]}),(e.tags??[]).length>0&&s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(hl,{tags:e.tags??[]})})]})}),s.jsxs("div",{className:"px-3.5 py-2 border-t border-border/40 bg-surface-inset/20 flex items-center gap-1.5",onClick:S=>S.stopPropagation(),children:[p?s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-teal-600 dark:text-teal-400 font-semibold",children:[s.jsx(ae,{size:11,className:"animate-spin"})," Running..."]}):s.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),n()},className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold text-teal-700 dark:text-teal-400 bg-teal-50 dark:bg-teal-900/20 hover:bg-teal-100 dark:hover:bg-teal-900/30 ring-1 ring-teal-200 dark:ring-teal-800 transition-colors",title:"Run suite",children:[s.jsx(Dt,{size:10,strokeWidth:2.5})," Run Suite"]}),s.jsxs("button",{type:"button",disabled:!y,onClick:S=>{S.stopPropagation(),y&&window.open(`/allure/${y.runId}`,"_blank")},title:y?`Report: ${y.passed}p / ${y.failed}f`:"No report",className:P("flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold transition-colors ring-1",y?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 hover:bg-blue-100 dark:hover:bg-blue-900/30 ring-blue-200 dark:ring-blue-800":"text-content-tertiary/40 bg-surface-inset ring-border cursor-not-allowed"),children:[s.jsx(hs,{size:10})," Report"]}),s.jsx("div",{className:"flex-1"}),s.jsx("span",{className:"text-[9px] text-content-tertiary",children:new Date(e.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}),s.jsx(Ht,{size:12,className:"text-content-tertiary/40 group-hover:text-accent transition-colors"})]})]})]})}function Y5({suiteId:e,suite:t,suites:n,newCaseName:r,onNewCaseNameChange:a,onOpenCase:i,onRunCase:l,onRunSuite:o,onBack:c}){const{runningCaseIds:d,runningSuiteId:x,caseLastRun:p}=qc(),y=x===e,{data:b=[],isLoading:f}=g5(e),v=Hp(e),w=v5(e),h=Hp(e),[u,g]=m.useState(!1),[j,k]=m.useState(!1),{modalProps:N,confirmDelete:E}=Ts(),[R,L]=m.useState(new Set),M=m.useRef(-1),{data:W}=pe({queryKey:["flakiness",e],queryFn:()=>Dw.get(e),staleTime:6e4});m.useEffect(()=>{L(new Set),M.current=-1},[e]);const{data:G}=Jy(e),ne=Xy(),A=Zy(),Y=M5(),se=eb(),le=Bm(),T=()=>{((G==null?void 0:G.status)??"not-created")==="not-created"?ne.mutate(e):Y.mutate(e)},S=H=>{var fe;(((fe=G==null?void 0:G.cases.find(De=>De.caseId===H))==null?void 0:fe.status)??"not-created")==="not-created"?A.mutate({suiteId:e,caseId:H}):se.mutate({suiteId:e,caseId:H})};m.useEffect(()=>{Qa.list(20).then(async H=>{const ue=await Promise.all(H.slice(0,10).map(fe=>Qa.get(fe.runId).catch(()=>null)));vt.seedFromHistory(ue.filter(fe=>fe!==null).map(fe=>({runId:fe.runId,passed:fe.passed,failed:fe.failed,skipped:fe.skipped,suites:fe.suites.map(De=>({suiteId:De.suiteId,cases:De.cases.map(lt=>({caseId:lt.caseId,status:lt.status}))}))})))}).catch(()=>{})},[e]);const[z,q]=m.useState(""),[_,re]=m.useState(new Set),[U,xe]=m.useState(""),me=_.size===0,Ee=m.useMemo(()=>{const H=new Set;return b.forEach(ue=>(ue.tags??[]).forEach(fe=>H.add(fe))),Array.from(H).sort()},[b]),ye=m.useMemo(()=>b.filter(H=>{const ue=!z||H.name.toLowerCase().includes(z.toLowerCase()),fe=_.size===0||(H.tags??[]).some(lt=>_.has(lt)),De=!U||H.priority===U;return ue&&fe&&De}),[b,z,_,U]),Te=!!(z||_.size>0||U),[pt,It]=m.useState(!1),[rs,He]=m.useState((t==null?void 0:t.name)??""),[Ct,K]=m.useState((t==null?void 0:t.description)??""),[Ke,as]=m.useState((t==null?void 0:t.tags)??[]),[er,tr]=m.useState(t!=null&&t.timeout?String(t.timeout):""),D=Qy();m.useEffect(()=>{He((t==null?void 0:t.name)??""),K((t==null?void 0:t.description)??""),as((t==null?void 0:t.tags)??[]),tr(t!=null&&t.timeout?String(t.timeout):"")},[t==null?void 0:t.id]);const X=()=>{const H=er?parseInt(er,10):void 0;D.mutate({id:e,data:{name:rs.trim()||(t==null?void 0:t.name),description:Ct,tags:Ke,timeout:H}},{onSuccess:()=>It(!1)})},je=H=>{H.key==="Enter"&&(H.preventDefault(),X()),H.key==="Escape"&&It(!1)},As=()=>{r.trim()&&(v.mutate({name:r}),a(""))},Et=H=>{h.mutate({name:`${H.name} (copy)`,description:H.description,priority:H.priority,tags:H.tags,steps:(H.steps??[]).map(ue=>({instruction:ue.instruction}))})},Os=H=>`TC-${((t==null?void 0:t.name)??"TC").replace(/[^a-zA-Z]/g,"").slice(0,3).toUpperCase()||"TC"}-${String(H+1).padStart(3,"0")}`,is=((t==null?void 0:t.type)??"ui")==="api",sr=(t==null?void 0:t.type)==="audit"||(t==null?void 0:t.type)==="performance";return s.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-inset/30",children:[s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"max-w-5xl mx-auto px-5 py-4 space-y-3",children:[s.jsxs("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:[s.jsx("div",{className:"px-4 py-1.5 bg-surface-inset/30 border-b border-border/50",children:s.jsxs("nav",{className:"flex items-center gap-1.5 text-[10px] text-content-tertiary",children:[s.jsxs("button",{onClick:c,className:"hover:text-accent transition-colors flex items-center gap-1",children:[s.jsx(by,{size:10})," Suites"]}),s.jsx(Ht,{size:9}),s.jsx("span",{className:"text-content-secondary font-semibold",children:t==null?void 0:t.name})]})}),pt?s.jsxs("div",{className:"px-4 py-3.5 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:P("w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",is?"bg-gradient-to-br from-violet-500 to-purple-600":"bg-gradient-to-br from-blue-500 to-indigo-600"),children:s.jsx(dl,{size:13,className:"text-white"})}),s.jsx("input",{className:"flex-1 text-sm font-bold border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface",value:rs,onChange:H=>He(H.target.value),onKeyDown:je,placeholder:"Suite name",autoFocus:!0})]}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:Ct,onChange:H=>K(H.target.value),onKeyDown:je,placeholder:"Description"}),s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Br,{size:10,className:"text-content-tertiary"}),s.jsx("input",{type:"number",min:1e3,step:1e3,className:"w-28 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:er,onChange:H=>tr(H.target.value),onKeyDown:je,placeholder:"Timeout ms"})]}),s.jsx("div",{className:"flex-1",children:s.jsx(hl,{tags:Ke,editable:!0,onAdd:H=>as(ue=>[...ue,H]),onRemove:H=>as(ue=>ue.filter(fe=>fe!==H))})}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs(te,{size:"sm",variant:"secondary",onClick:()=>It(!1),children:[s.jsx(be,{size:10})," Cancel"]}),s.jsxs(te,{size:"sm",onClick:X,loading:D.isPending,children:[s.jsx(Oe,{size:10})," Save"]})]})]})]}):s.jsxs("div",{className:"px-4 py-3 flex items-center gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[s.jsx("div",{className:P("w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0 shadow-sm",is?"bg-gradient-to-br from-violet-500 to-purple-600 shadow-violet-500/20":sr?"bg-gradient-to-br from-amber-500 to-orange-600 shadow-amber-500/20":"bg-gradient-to-br from-blue-500 to-indigo-600 shadow-blue-500/20"),children:s.jsx(dl,{size:16,className:"text-white"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("h1",{className:"text-sm font-bold text-content truncate",children:t==null?void 0:t.name}),sr?s.jsxs("span",{className:"text-[7px] px-1.5 py-px rounded font-bold flex items-center gap-0.5 ring-1 bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800",children:[s.jsx(qe,{size:7})," Audit"]}):s.jsx("button",{type:"button",onClick:H=>{H.stopPropagation();const ue=is?"ui":"api";D.mutate({id:e,data:{type:ue}})},title:"Toggle type",className:P("text-[7px] px-1.5 py-px rounded font-bold uppercase ring-1 cursor-pointer transition-colors",is?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800 hover:bg-violet-100 dark:hover:bg-violet-900/30":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800 hover:bg-blue-100 dark:hover:bg-blue-900/30"),children:is?"API":"UI"}),s.jsx("button",{type:"button",onClick:()=>It(!0),className:"p-0.5 rounded text-content-tertiary hover:text-accent transition-colors",children:s.jsx(Hr,{size:10})})]}),Ct&&s.jsx("p",{className:"text-[10px] text-content-tertiary truncate mt-0.5 leading-tight max-w-md",children:Ct})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[y?s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-teal-600 dark:text-teal-400 font-medium px-2 py-1 rounded-lg bg-teal-50 dark:bg-teal-900/20 ring-1 ring-teal-200 dark:ring-teal-800",children:[s.jsx(ae,{size:11,className:"animate-spin"})," Running…"]}):s.jsxs(te,{size:"sm",onClick:o,className:"bg-teal-600 hover:bg-teal-700 text-white border-teal-600",children:[s.jsx(Dt,{size:10})," Run Suite"]}),s.jsxs(te,{size:"sm",onClick:()=>g(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white border-indigo-600",children:[s.jsx(Va,{size:10})," Hooks"]}),s.jsx(ml,{variant:"full",status:(G==null?void 0:G.status)??"not-created",label:"Sync",onClick:T,busy:le.busySuites.get(e)==="create"||le.busySuites.get(e)==="sync"||le.allOp==="create"||le.allOp==="sync"})]})]}),Ee.length>0&&s.jsxs("div",{className:"px-4 py-1.5 border-t border-border/50 flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mr-0.5",children:"Tags"}),s.jsx("button",{type:"button",onClick:()=>re(new Set),className:P("text-[9px] px-2 py-0.5 rounded-md font-medium transition-all",me?"bg-accent text-white shadow-sm shadow-accent/20":"text-content-tertiary hover:text-content-secondary bg-surface-inset hover:bg-surface-inset/80 ring-1 ring-border"),children:"All"}),Ee.map(H=>{const ue=_.has(H);return s.jsx("button",{type:"button",onClick:()=>{re(fe=>{const De=new Set(fe);return ue?De.delete(H):De.add(H),De})},className:P("text-[9px] px-2 py-0.5 rounded-md font-medium transition-all",ue||me?"bg-accent/10 text-accent ring-1 ring-accent/30":"text-content-tertiary bg-surface-inset ring-1 ring-border hover:text-content-secondary"),children:H},H)})]}),s.jsxs("div",{className:"px-4 py-2 bg-surface-inset/40 border-t border-border flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-[120px]",children:[s.jsx(Kn,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-content-tertiary pointer-events-none"}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg pl-7 pr-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"Search tests…",value:z,onChange:H=>q(H.target.value)})]}),s.jsxs("select",{value:U,onChange:H=>xe(H.target.value),className:"text-xs border border-border rounded-lg px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent bg-surface min-w-[90px]",children:[s.jsx("option",{value:"",children:"All Priority"}),tb.map(H=>s.jsx("option",{value:H,className:"capitalize",children:H.charAt(0).toUpperCase()+H.slice(1)},H))]}),Te&&s.jsx("button",{type:"button",onClick:()=>{q(""),re(new Set),xe("")},className:"p-1 rounded-lg text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})}),s.jsx("div",{className:"w-px h-4 bg-border"}),s.jsx("input",{className:"w-36 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"New test case…",value:r,onChange:H=>a(H.target.value),onKeyDown:H=>H.key==="Enter"&&As()}),s.jsxs(te,{size:"sm",onClick:As,disabled:v.isPending,children:[s.jsx(Rs,{size:10})," Add"]}),s.jsx(te,{size:"sm",variant:"secondary",onClick:()=>k(!0),children:"From Template"}),s.jsx("span",{className:"text-[9px] text-content-tertiary ml-1 tabular-nums flex-shrink-0",children:Te?`${ye.length}/${b.length}`:`${b.length} test${b.length!==1?"s":""}`})]})]}),f?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ae,{size:18,className:"animate-spin text-accent"})}):b.length===0?s.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-surface flex flex-col items-center justify-center py-14 gap-2.5",children:[s.jsx("div",{className:"w-11 h-11 rounded-xl bg-surface-inset flex items-center justify-center",children:s.jsx(qr,{size:20,className:"text-content-tertiary"})}),s.jsx("p",{className:"text-xs font-medium text-content-secondary",children:"No test cases yet"}),s.jsx("p",{className:"text-[10px] text-content-tertiary",children:"Add your first test case using the toolbar above"})]}):ye.length===0?s.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-surface flex flex-col items-center justify-center py-10 gap-2",children:[s.jsx(yy,{size:16,className:"text-content-tertiary"}),s.jsx("p",{className:"text-xs text-content-tertiary",children:"No tests match filters"}),s.jsx("button",{onClick:()=>{q(""),re(new Set),xe("")},className:"text-[10px] text-accent hover:underline",children:"Clear filters"})]}):s.jsxs("div",{className:"space-y-1.5",children:[ye.length>0&&s.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-1",children:[s.jsx("input",{type:"checkbox",className:"rounded border-border text-accent cursor-pointer",checked:R.size===ye.length&&ye.length>0,onChange:H=>{H.target.checked?L(new Set(ye.map(ue=>ue.id))):L(new Set)}}),s.jsx("span",{className:"text-[9px] text-content-tertiary",children:"Select all"})]}),ye.map((H,ue)=>{const fe=H.steps.some(Ne=>Ne.stepType==="api"),De=p.get(H.id),lt=G==null?void 0:G.cases.find(Ne=>Ne.caseId===H.id),Yr=(lt==null?void 0:lt.status)??"not-created",Ml=le.busyCases.get(`${e}:${H.id}`)==="create"||le.busyCases.get(`${e}:${H.id}`)==="sync"||le.busySuites.get(e)==="create"||le.busySuites.get(e)==="sync"||le.allOp==="create"||le.allOp==="sync",ln=R.has(H.id),on=W==null?void 0:W.cases.find(Ne=>Ne.caseId===H.id);return s.jsx("div",{className:P("group rounded-xl border bg-surface hover:border-accent/30 hover:shadow-sm hover:shadow-accent/5 cursor-pointer transition-all",ln?"border-accent/40 bg-accent/[0.02]":"border-border"),onClick:()=>i(H.id),children:s.jsxs("div",{className:"px-3.5 py-2.5 flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",className:"rounded border-border text-accent cursor-pointer flex-shrink-0",checked:ln,onClick:Ne=>Ne.stopPropagation(),onChange:Ne=>{Ne.stopPropagation(),L(nr=>{const cn=new Set(nr);return Ne.target.checked?cn.add(H.id):cn.delete(H.id),M.current=ue,cn})},onClickCapture:Ne=>{if(Ne.shiftKey&&M.current>=0){Ne.preventDefault();const nr=Math.min(M.current,ue),cn=Math.max(M.current,ue);L(Jr=>{const rr=new Set(Jr);return ye.slice(nr,cn+1).forEach(ri=>rr.add(ri.id)),rr})}M.current=ue}}),s.jsx(Dc,{size:11,className:"text-content-tertiary/40 group-hover:text-content-tertiary cursor-grab flex-shrink-0 transition-colors"}),s.jsx("span",{className:"text-[9px] font-mono text-accent font-semibold bg-accent/5 px-1.5 py-0.5 rounded ring-1 ring-accent/10 flex-shrink-0 tabular-nums",children:Os(ue)}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs font-medium text-content truncate",children:H.name}),s.jsx("span",{className:P("text-[7px] px-1 py-px rounded font-bold uppercase flex-shrink-0 ring-1",fe?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":sr?"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800"),children:fe?"API":sr?"Audit":"UI"}),on&&s.jsx(V5,{passRate:on.passRate,runs:on.runs,flaky:on.flaky})]}),s.jsxs("span",{className:"text-[9px] text-content-tertiary tabular-nums flex-shrink-0",children:[H.steps.length," step",H.steps.length!==1?"s":""]}),s.jsx("span",{className:P("text-[8px] px-1.5 py-0.5 rounded capitalize ring-1 flex-shrink-0 font-medium",yx[H.priority]??yx.low),children:H.priority}),(H.tags??[]).length>0&&s.jsx("div",{className:"flex-shrink-0",onClick:Ne=>Ne.stopPropagation(),children:s.jsx(hl,{tags:H.tags})}),(()=>{if(!De)return s.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded ring-1 ring-border text-content-tertiary/60 flex-shrink-0",children:"Never"});const Ne={passed:"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-emerald-200 dark:ring-emerald-800",failed:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-200 dark:ring-red-800",skipped:"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800"};return s.jsx("span",{className:P("text-[8px] px-1.5 py-0.5 rounded capitalize ring-1 flex-shrink-0 font-medium",Ne[De.status]??"ring-border text-content-tertiary"),children:De.status})})(),s.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",onClick:Ne=>Ne.stopPropagation(),children:[s.jsx(Um,{status:Yr,xrayKey:lt==null?void 0:lt.xrayTestId}),s.jsx(ml,{variant:"icon",status:Yr,onClick:()=>S(H.id),busy:Ml})]}),s.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",onClick:Ne=>Ne.stopPropagation(),children:[d.has(H.id)?s.jsx(ae,{size:11,className:"animate-spin text-teal-600 dark:text-teal-400"}):s.jsx("button",{type:"button",onClick:()=>l(H.id),title:"Run",className:"p-1 rounded-md text-teal-600 dark:text-teal-400 hover:bg-teal-50 dark:hover:bg-teal-900/20 transition-colors",children:s.jsx(Dt,{size:11})}),s.jsx("button",{type:"button",disabled:!De,onClick:()=>{De&&window.open(`/allure/${De.allureRunId}`,"_blank")},title:"Report",className:P("p-1 rounded-md transition-colors",De?"text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20":"text-content-tertiary/40 cursor-not-allowed"),children:s.jsx(hs,{size:11})}),s.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),Et(H)},title:"Duplicate",className:"p-1 rounded-md text-content-tertiary hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors",children:s.jsx(Rm,{size:11})}),s.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),E(`Delete "${H.name}"?`,()=>w.mutate(H.id))},title:"Delete",className:"p-1 rounded-md text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(Kt,{size:10})})]}),s.jsx(Ht,{size:11,className:"text-content-tertiary/40 flex-shrink-0"})]})},H.id)})]})]})}),s.jsx(B5,{suiteId:e,open:u,onClose:()=>g(!1)}),s.jsx(h5,{open:j,onClose:()=>k(!1),suiteId:e,onCreated:()=>{}}),s.jsx(Ms,{...N}),R.size>0&&s.jsx(W5,{selectedIds:R,suiteId:e,suites:n,onClear:()=>L(new Set),onDeleted:()=>L(new Set),onMoved:()=>L(new Set)})]})}function J5({suiteId:e,caseId:t,suiteName:n,suiteType:r,onBack:a,onRunCase:i}){const{runningCaseIds:l,caseLastRun:o}=qc(),c=l.has(t),d=o.get(t),{data:x,isLoading:p}=y5(e,t),y=b5(e),b=j5(e,t),f=N5(e,t),v=k5(e,t),{modalProps:w,confirmDelete:h}=Ts(),u=w5(e,t),g=S5(e,t),j=C5(e,t),{data:k}=Jy(e),N=Zy(),E=eb(),R=k==null?void 0:k.cases.find(F=>F.caseId===t),L=Bm(),M=()=>{((R==null?void 0:R.status)??"not-created")==="not-created"?N.mutate({suiteId:e,caseId:t}):E.mutate({suiteId:e,caseId:t})},[W,G]=m.useState(""),[ne,A]=m.useState(!1),[Y,se]=m.useState(""),[le,T]=m.useState("medium"),[S,z]=m.useState([]),[q,_]=m.useState(""),[re,U]=m.useState("none"),[xe,me]=m.useState(""),[Ee,ye]=m.useState(""),[Te,pt]=m.useState(!1),[It,rs]=m.useState(!1),He=m.useRef(null),[Ct,K]=m.useState(!1),[Ke,as]=m.useState(""),[er,tr]=m.useState(""),D=m.useRef(null),[X,je]=m.useState(null),[As,Et]=m.useState(null),[Os,is]=m.useState("steps"),[sr,H]=m.useState(!1),[ue,fe]=m.useState([]),[De,lt]=m.useState([]),[Yr,Ml]=m.useState(["performance","accessibility","seo"]),[ln,on]=m.useState(""),[Ne,nr]=m.useState(""),[cn,Jr]=m.useState(!1),[rr,ri]=m.useState([]),[xb,Qm]=m.useState(!1),[mb,Ym]=m.useState(!1),Kc=m.useRef(null);Qr({"recorder:action":F=>{const oe=F;ri(ee=>[...ee,oe]),setTimeout(()=>{var ee;(ee=Kc.current)==null||ee.scrollTo({top:Kc.current.scrollHeight,behavior:"smooth"})},50)},"recorder:stopped":()=>{Jr(!1)}});const hb=async()=>{try{Qm(!0),ri([]),await Sd.start(),Jr(!0),O.success("Recording started — Shift+Click = assert element, Ctrl+Shift+U = assert URL",{duration:5e3})}catch(F){O.error((F==null?void 0:F.message)||"Failed to start recorder")}finally{Qm(!1)}},pb=async()=>{try{Ym(!0);const F=await Sd.stop();if(Jr(!1),F.actions.length>0){for(const oe of F.actions){const ee=Iw(oe);await b.mutateAsync({instruction:oe.instruction,generatedCode:ee,strategy:"recorder",...oe.soft?{soft:!0}:{}})}O.success(`Added ${F.actions.length} recorded steps with code`)}else O("No actions were recorded")}catch(F){O.error((F==null?void 0:F.message)||"Failed to stop recorder")}finally{Ym(!1)}};m.useEffect(()=>{Sd.status().then(F=>{F.recording&&(Jr(!0),ri(F.actions))}).catch(()=>{})},[]),m.useEffect(()=>{var oe,ee;if(!x)return;G(x.name),se(x.description??""),T(x.priority??"medium"),z([...x.tags]),_(x.timeout?String(x.timeout):"");const F=x.dataSource;F?(U(F.type??"none"),me(F.path??""),ye(F.data?JSON.stringify(F.data,null,2):"")):(U("none"),me(""),ye("")),fe(((oe=x.caseHooks)==null?void 0:oe.before.map(ce=>({id:ce.id,instruction:ce.instruction})))??[]),lt(((ee=x.caseHooks)==null?void 0:ee.after.map(ce=>({id:ce.id,instruction:ce.instruction})))??[]),Ml(x.lighthouseCategories??["performance","accessibility","seo"]),rs(!1),K(!1)},[x==null?void 0:x.id]);const ot=()=>{rs(!0),K(!1)},fb=F=>{F.key==="Enter"&&(F.preventDefault(),Tl())},gb=F=>{const oe=D.current;if(!oe){as(Wc=>Wc+F);return}const ee=oe.selectionStart??Ke.length,ce=oe.selectionEnd??Ke.length,Ft=Ke.slice(0,ee)+F+Ke.slice(ce);as(Ft),setTimeout(()=>{oe.focus(),oe.setSelectionRange(ee+F.length,ee+F.length)},0)},Tl=async()=>{const F=q?parseInt(q,10):void 0;let oe;if(re!=="none")if(oe={type:re},re==="inline")try{oe.data=JSON.parse(Ee)}catch{}else oe.path=xe;const ee={before:ue.map((ce,Ft)=>({...ce,order:Ft})),after:De.map((ce,Ft)=>({...ce,order:Ft}))};await y.mutateAsync({caseId:t,data:{name:W,description:Y,priority:le,tags:S,timeout:F,dataSource:oe,caseHooks:ee,lighthouseCategories:Yr}}),rs(!1),K(!0)},yb=async()=>{It&&await Tl(),i()},Jm=()=>{Ke.trim()&&(b.mutate({instruction:Ke}),as(""))},bb=async F=>{tr(F),await g.mutateAsync(F).finally(()=>tr(""))},Xm=x?`TC-${(x.name||"").replace(/[^a-zA-Z]/g,"").slice(0,3).toUpperCase()||"TST"}-001`:"…";if(p||!x)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ae,{size:18,className:"animate-spin text-accent"})});const dn=[...x.steps].sort((F,oe)=>F.order-oe.order),vb=dn.some(F=>F.stepType==="api"),Zm=r==="audit"||r==="performance";return s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex-shrink-0 bg-surface border-b border-border z-10",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-5 pt-2 pb-1 text-[10px] text-content-tertiary",children:[s.jsxs("button",{onClick:()=>window.location.assign("/tests"),className:"hover:text-accent flex items-center gap-1",children:[s.jsx(by,{size:10})," Suites"]}),s.jsx(Ht,{size:9}),s.jsx("button",{onClick:a,className:"hover:text-accent",children:n}),s.jsx(Ht,{size:9}),s.jsx("span",{className:"text-content-secondary font-semibold font-mono",children:Xm})]}),s.jsxs("div",{className:"px-5 pb-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:ne?s.jsx("input",{ref:He,className:"flex-1 text-sm font-bold text-content bg-transparent border-b-2 border-accent outline-none p-0 pb-px",value:W,onChange:F=>{G(F.target.value),ot()},onBlur:()=>A(!1),onKeyDown:F=>{F.key==="Enter"&&A(!1),F.key==="Escape"&&(G((x==null?void 0:x.name)??""),A(!1))},autoFocus:!0}):s.jsxs("div",{className:"flex items-center gap-1.5 group min-w-0",children:[s.jsx("h1",{className:"text-sm font-bold text-content truncate",children:W||"Untitled Test Case"}),s.jsx("button",{type:"button",onClick:()=>{A(!0),setTimeout(()=>{var F;return(F=He.current)==null?void 0:F.focus()},0)},className:"p-0.5 rounded text-content-tertiary opacity-0 group-hover:opacity-100 hover:bg-surface-inset transition-all",children:s.jsx(Hr,{size:10})})]})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(ml,{variant:"full",status:(R==null?void 0:R.status)??"not-created",onClick:M,busy:L.busyCases.get(`${e}:${t}`)==="create"||L.busyCases.get(`${e}:${t}`)==="sync"||L.busySuites.get(e)==="create"||L.busySuites.get(e)==="sync"||L.allOp==="create"||L.allOp==="sync"}),s.jsxs(te,{variant:"secondary",size:"sm",onClick:Tl,loading:y.isPending,disabled:!It,children:[s.jsx(dx,{size:10})," Save"]}),s.jsxs(te,{size:"sm",onClick:yb,loading:c,disabled:c,children:[!c&&s.jsx(Dt,{size:10})," ",c?"Running…":"Save & Run"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[s.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-mono font-bold bg-teal-50 dark:bg-teal-900/20 text-teal-700 dark:text-teal-400 ring-1 ring-teal-200 dark:ring-teal-800",children:Xm}),c?s.jsxs("span",{className:"flex items-center gap-1 text-[9px] text-teal-600 dark:text-teal-400 font-medium",children:[s.jsx(ae,{size:9,className:"animate-spin"})," Running"]}):(()=>{if(!d)return s.jsx("span",{className:"text-[8px] px-1.5 py-px rounded ring-1 ring-border text-content-tertiary",children:"Never run"});const F={passed:"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-emerald-200 dark:ring-emerald-800",failed:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-200 dark:ring-red-800",skipped:"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800"};return s.jsx("span",{className:P("text-[8px] px-1.5 py-px rounded capitalize ring-1",F[d.status]??"ring-border text-content-tertiary"),children:d.status})})(),s.jsx("button",{type:"button",disabled:!d,onClick:()=>{d&&window.open(`/allure/${d.allureRunId}`,"_blank")},className:P("p-0.5 rounded transition-colors",d?"text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20":"text-content-tertiary cursor-not-allowed"),children:s.jsx(hs,{size:11})}),s.jsx(Um,{status:(R==null?void 0:R.status)??"not-created",xrayKey:R==null?void 0:R.xrayTestId}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsx("div",{className:"flex items-center gap-1",children:tb.map(F=>s.jsx("button",{type:"button",onClick:()=>{T(F),ot()},className:P("px-1.5 py-px rounded text-[8px] capitalize font-bold transition-all ring-1",le===F?yx[F]:"ring-transparent text-content-tertiary hover:ring-border"),children:F},F))}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsx(hl,{tags:S,editable:!0,onAdd:F=>{z(oe=>[...oe,F]),ot()},onRemove:F=>{z(oe=>oe.filter(ee=>ee!==F)),ot()}}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Br,{size:9,className:"text-content-tertiary"}),s.jsx("input",{type:"number",min:1e3,step:1e3,className:"w-16 text-[9px] bg-transparent border-b border-dashed border-border px-1 py-px text-content-secondary placeholder:text-content-tertiary focus:outline-none focus:border-accent tabular-nums",placeholder:"30000",value:q,onChange:F=>{_(F.target.value),ot()},onKeyDown:fb}),s.jsx("span",{className:"text-[8px] text-content-tertiary",children:"ms"})]}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsxs("button",{type:"button",onClick:()=>pt(F=>!F),className:P("flex items-center gap-1 text-[9px] font-medium px-1.5 py-0.5 rounded transition-colors",Te?"text-accent bg-accent/5":"text-content-tertiary hover:text-content-secondary hover:bg-surface-inset"),children:[s.jsx(Va,{size:9})," ",Te?"Less":"More",s.jsx(Nt,{size:8,className:P("transition-transform",Te&&"rotate-180")})]}),It&&s.jsx("span",{className:"text-[8px] text-amber-500 dark:text-amber-400 font-bold ml-auto",children:"● Unsaved"}),Ct&&!It&&s.jsx("span",{className:"text-[8px] text-emerald-500 dark:text-emerald-400 font-bold ml-auto",children:"✓ Saved"})]})]}),Te&&s.jsxs("div",{className:"px-5 pb-3 pt-1 border-t border-border bg-surface-inset/30 animate-fade-in",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-1",children:"Description"}),s.jsx("textarea",{rows:2,className:"w-full text-xs text-content-secondary bg-surface rounded-lg border border-border outline-none resize-none focus:ring-2 focus:ring-accent/30 px-2.5 py-1.5",placeholder:"Add a description…",value:Y,onChange:F=>{se(F.target.value),ot()},onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),Tl())}})]}),s.jsx("div",{children:s.jsx(X5,{type:re,filePath:xe,inlineData:Ee,onTypeChange:F=>{U(F),ot()},onFilePathChange:F=>{me(F),ot()},onInlineChange:F=>{ye(F),ot()}})})]}),Zm&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-border/50",children:[s.jsxs("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-2 flex items-center gap-1.5",children:[s.jsx(qe,{size:9,className:"text-amber-500 dark:text-amber-400"})," Non-Functional Checks (Lighthouse)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[["performance","accessibility","seo"].map(F=>{const oe={performance:"⚡ Performance",accessibility:"♿ Accessibility",seo:"🔍 SEO"},ee=Yr.includes(F);return s.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:ee,onChange:()=>{Ml(ce=>ee?ce.filter(Ft=>Ft!==F):[...ce,F]),ot()},className:"w-3 h-3 rounded accent-amber-600 cursor-pointer"}),s.jsx("span",{className:"text-[10px] text-content-secondary",children:oe[F]})]},F)}),Yr.length===0&&s.jsx("span",{className:"text-[9px] text-amber-600",children:"⚠ No checks selected — Lighthouse will be skipped"})]})]})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center gap-1 px-5 pt-2 pb-0 border-b border-border bg-surface",children:[s.jsx("button",{type:"button",onClick:()=>is("steps"),className:P("px-3 py-1.5 text-xs font-semibold rounded-t-lg transition-colors border-b-2",Os==="steps"?"border-accent text-accent":"border-transparent text-content-tertiary hover:text-content-secondary"),children:"Steps"}),s.jsxs("button",{type:"button",onClick:()=>is("hooks"),className:P("px-3 py-1.5 text-xs font-semibold rounded-t-lg transition-colors border-b-2",Os==="hooks"?"border-accent text-accent":"border-transparent text-content-tertiary hover:text-content-secondary"),children:["Hooks",ue.length+De.length>0&&s.jsx("span",{className:"ml-1 text-[9px] bg-accent/10 text-accent rounded px-1",children:ue.length+De.length})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{type:"button",onClick:()=>H(!0),title:"Step Library",className:"flex items-center gap-1.5 text-[10px] text-content-tertiary hover:text-accent hover:bg-accent/5 px-2 py-1 rounded-lg transition-colors mb-1",children:[s.jsx(cl,{size:11})," Library"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto bg-surface-inset/20",children:s.jsxs("div",{className:"max-w-4xl mx-auto px-5 py-3",children:[Os==="hooks"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-2 border-b border-border bg-surface-inset/30",children:[s.jsx("h3",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest",children:"Before Hooks"}),s.jsx("p",{className:"text-[9px] text-content-tertiary mt-0.5",children:"Run before all steps"})]}),s.jsxs("div",{className:"p-3 space-y-1.5",children:[ue.map((F,oe)=>s.jsxs("div",{className:"flex items-center gap-2 text-xs bg-surface-inset/50 rounded-lg px-3 py-2 border border-border",children:[s.jsx("span",{className:"text-content-tertiary font-mono text-[9px] w-4",children:oe+1}),s.jsx("span",{className:"flex-1 text-content-secondary",children:F.instruction}),s.jsx("button",{type:"button",onClick:()=>{fe(ee=>ee.filter((ce,Ft)=>Ft!==oe)),ot()},className:"p-0.5 rounded text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})})]},F.id)),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("input",{className:"flex-1 text-xs border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"Add before-hook instruction…",value:ln,onChange:F=>on(F.target.value),onKeyDown:F=>{F.key==="Enter"&&ln.trim()&&(fe(oe=>[...oe,{id:crypto.randomUUID(),instruction:ln.trim()}]),on(""),ot())}}),s.jsxs(te,{size:"sm",onClick:()=>{ln.trim()&&(fe(F=>[...F,{id:crypto.randomUUID(),instruction:ln.trim()}]),on(""),ot())},children:[s.jsx(Rs,{size:11})," Add"]})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-2 border-b border-border bg-surface-inset/30",children:[s.jsx("h3",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest",children:"After Hooks"}),s.jsx("p",{className:"text-[9px] text-content-tertiary mt-0.5",children:"Run after all steps (always)"})]}),s.jsxs("div",{className:"p-3 space-y-1.5",children:[De.map((F,oe)=>s.jsxs("div",{className:"flex items-center gap-2 text-xs bg-surface-inset/50 rounded-lg px-3 py-2 border border-border",children:[s.jsx("span",{className:"text-content-tertiary font-mono text-[9px] w-4",children:oe+1}),s.jsx("span",{className:"flex-1 text-content-secondary",children:F.instruction}),s.jsx("button",{type:"button",onClick:()=>{lt(ee=>ee.filter((ce,Ft)=>Ft!==oe)),ot()},className:"p-0.5 rounded text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})})]},F.id)),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("input",{className:"flex-1 text-xs border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"Add after-hook instruction…",value:Ne,onChange:F=>nr(F.target.value),onKeyDown:F=>{F.key==="Enter"&&Ne.trim()&&(lt(oe=>[...oe,{id:crypto.randomUUID(),instruction:Ne.trim()}]),nr(""),ot())}}),s.jsxs(te,{size:"sm",onClick:()=>{Ne.trim()&&(lt(F=>[...F,{id:crypto.randomUUID(),instruction:Ne.trim()}]),nr(""),ot())},children:[s.jsx(Rs,{size:11})," Add"]})]})]})]})]}),Os==="steps"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(qe,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-accent/50 pointer-events-none"}),s.jsx("input",{ref:D,className:"w-full text-xs border border-border rounded-lg pl-8 pr-3 py-2 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary shadow-xs",placeholder:"Describe a step in plain English and press Enter…",value:Ke,onChange:F=>as(F.target.value),onKeyDown:F=>F.key==="Enter"&&Jm()})]}),s.jsx(K5,{onInsert:gb}),s.jsxs(te,{size:"sm",onClick:Jm,disabled:b.isPending,className:"border border-transparent",children:[s.jsx(Rs,{size:11})," Add Step"]}),r!=="api"&&(cn?s.jsxs(te,{size:"sm",loading:mb,onClick:pb,className:"border border-transparent bg-gradient-to-b from-red-500 to-red-600 text-white hover:brightness-110 shadow-sm hover:shadow-md focus-visible:ring-red-500 animate-pulse",children:[s.jsx(wy,{size:10,className:"fill-current"})," Stop Recording"]}):s.jsxs(te,{size:"sm",loading:xb,onClick:hb,className:"border border-transparent bg-gradient-to-b from-red-400 to-red-500 text-white hover:brightness-110 shadow-sm hover:shadow-md focus-visible:ring-red-500",children:[s.jsx(dy,{size:10,className:"fill-current"})," Record"]})),s.jsxs(te,{size:"sm",loading:j.isPending,onClick:()=>j.mutate(),className:"border border-transparent bg-gradient-to-b from-emerald-500 to-emerald-600 text-white hover:brightness-110 shadow-sm hover:shadow-md focus-visible:ring-emerald-500",children:[s.jsx(_r,{size:11})," Generate All"]})]}),r!=="api"&&cn&&rr.length>0&&s.jsxs("div",{className:"mb-3 border border-red-300 dark:border-red-700 rounded-xl overflow-hidden bg-red-50 dark:bg-red-950/30",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-red-100 dark:bg-red-900/40 border-b border-red-200 dark:border-red-800",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-red-500"})]}),s.jsxs("span",{className:"text-[11px] font-semibold text-red-700 dark:text-red-300",children:["Recording — ",rr.length," action",rr.length!==1?"s":""," captured"]})]}),s.jsx("span",{className:"text-[10px] text-red-500 dark:text-red-400",children:"Interact with the browser to record steps"})]}),s.jsx("div",{ref:Kc,className:"max-h-40 overflow-y-auto px-3 py-2 space-y-1",children:rr.map((F,oe)=>s.jsxs("div",{className:"flex items-start gap-2 text-[11px]",children:[s.jsx("span",{className:P("flex-shrink-0 w-5 h-5 rounded-full flex items-center justify-center font-mono font-bold text-[9px]",F.action==="assert"?"bg-emerald-200 dark:bg-emerald-800 text-emerald-700 dark:text-emerald-300":"bg-red-200 dark:bg-red-800 text-red-700 dark:text-red-300"),children:oe+1}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[F.action==="assert"&&s.jsx(Oe,{size:10,className:"text-emerald-500 flex-shrink-0"}),s.jsx("span",{className:P("text-content-secondary",F.action==="assert"&&"text-emerald-700 dark:text-emerald-300 font-medium"),children:F.instruction})]})]},F.id))})]}),s.jsx("div",{className:"space-y-1.5",children:dn.length===0?s.jsxs("div",{className:"border border-dashed border-border rounded-xl py-10 text-center bg-surface",children:[s.jsx(qe,{size:20,className:"mx-auto text-content-tertiary/40 mb-2"}),s.jsx("p",{className:"text-xs text-content-tertiary",children:"No steps yet — type an instruction above and press Enter"}),s.jsxs("p",{className:"text-[10px] text-content-tertiary mt-1",children:["Or click ",s.jsx("span",{className:"font-semibold",children:"Generate All"})," to let AI write all steps"]})]}):dn.map((F,oe)=>s.jsx(Z5,{step:F,index:oe,suiteId:e,caseId:t,caseIsApi:vb,suiteIsAudit:Zm,generating:er===F.id,isDragging:X===F.id,isDragOver:As===F.id,onDragStart:()=>je(F.id),onDragOver:()=>Et(F.id),onDrop:()=>{if(!X||X===F.id){je(null),Et(null);return}const ee=dn.map(Wc=>Wc.id),ce=ee.indexOf(X),Ft=ee.indexOf(F.id);ee.splice(ce,1),ee.splice(Ft,0,X),u.mutate(ee),je(null),Et(null)},onDragEnd:()=>{je(null),Et(null)},onDelete:ee=>h("Delete this step?",()=>v.mutate(ee)),onGenerate:ee=>void bb(ee),onSaveInstruction:(ee,ce)=>f.mutate({stepId:ee,instruction:ce}),onSaveTimeout:(ee,ce)=>f.mutate({stepId:ee,timeout:ce}),onSaveRetries:(ee,ce)=>f.mutate({stepId:ee,retries:ce??void 0}),onSaveStepType:(ee,ce)=>f.mutate({stepId:ee,stepType:ce}),onSaveMockUrl:(ee,ce)=>f.mutate({stepId:ee,mockUrl:ce}),onSaveMockResponse:(ee,ce)=>f.mutate({stepId:ee,mockResponse:ce}),onSaveMockStatus:(ee,ce)=>f.mutate({stepId:ee,mockStatus:ce}),onSaveRunAudit:(ee,ce)=>f.mutate({stepId:ee,runAudit:ce},{onSuccess:()=>O.success(ce?"⚡ Audit checkpoint set":"Audit checkpoint removed")}),onSaveSoft:(ee,ce)=>f.mutate({stepId:ee,soft:ce},{onSuccess:()=>O.success(ce?"Soft assertion — test continues on failure":"Hard assertion — test stops on failure")}),onSaveVisualCheck:(ee,ce)=>f.mutate({stepId:ee,visualCheck:ce},{onSuccess:()=>O.success(ce?"👁 Visual regression enabled for this step":"Visual regression disabled for this step")})},F.id))}),dn.length>0&&s.jsxs("p",{className:"text-[9px] text-content-tertiary text-center mt-3",children:[dn.length," step",dn.length!==1?"s":""," · ",dn.filter(F=>{var oe;return!!((oe=F.generatedCode)!=null&&oe.trim())}).length," with code"]})]})]})}),s.jsx(Ms,{...w}),s.jsx(G5,{open:sr,onClose:()=>H(!1),suiteId:e,caseId:t,onInserted:()=>H(!1)})]})}function X5({type:e,filePath:t,inlineData:n,onTypeChange:r,onFilePathChange:a,onInlineChange:i}){const[l,o]=m.useState([]),[c,d]=m.useState([]),[x,p]=m.useState(!1),[y,b]=m.useState(""),[f,v]=m.useState(!1),w=m.useRef(null);m.useEffect(()=>{ea.list().then(o).catch(()=>{})},[]),m.useEffect(()=>{if((e==="json-file"||e==="csv-file")&&t){const j=t.replace(/^data\//,"");ea.get(j).then(k=>{d(k.rows),b(k.raw)}).catch(()=>d([]))}else if(e==="inline"&&n)try{d(JSON.parse(n))}catch{d([])}else d([])},[e,t,n]);const h=async j=>{var N;const k=(N=j.target.files)==null?void 0:N[0];if(k){v(!0);try{const E=await k.text(),R=await ea.upload(k.name,E);a(R.path),r(k.name.endsWith(".csv")?"csv-file":"json-file");const L=await ea.list();o(L),O.success(`Uploaded ${k.name} (${R.rowCount} rows)`)}catch(E){O.error(E instanceof Error?E.message:"Upload failed")}finally{v(!1),j.target.value=""}}},u=async()=>{if((e==="json-file"||e==="csv-file")&&t){const j=t.replace(/^data\//,"");try{await ea.update(j,y);const k=await ea.get(j);d(k.rows),p(!1),O.success("Data file saved")}catch(k){O.error(k instanceof Error?k.message:"Save failed")}}else if(e==="inline"){i(y);try{d(JSON.parse(y))}catch{d([])}p(!1)}},g=c.length>0?Object.keys(c[0]):[];return s.jsxs("div",{children:[s.jsxs("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-1.5 flex items-center gap-1",children:[s.jsx(uy,{size:9})," Data-Driven"]}),s.jsxs("div",{className:"flex items-center gap-1.5 mb-2 flex-wrap",children:[["none","inline","json-file","csv-file"].map(j=>s.jsx("button",{type:"button",onClick:()=>r(j),className:P("px-2 py-0.5 rounded-md text-[9px] font-semibold transition-all ring-1",e===j?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":"ring-border text-content-tertiary hover:bg-surface-inset"),children:j==="none"?"Off":j==="inline"?"Inline":j==="json-file"?"JSON":"CSV"},j)),(e==="json-file"||e==="csv-file")&&s.jsxs("select",{className:"max-w-[160px] text-[10px] border border-border rounded-md px-1.5 py-0.5 focus:outline-none focus:ring-1 focus:ring-accent bg-surface-inset/50",value:t,onChange:j=>a(j.target.value),children:[s.jsx("option",{value:"",children:"Select file…"}),l.filter(j=>e==="csv-file"?j.type==="csv":j.type==="json").map(j=>s.jsx("option",{value:j.path,children:j.name},j.name))]}),e!=="none"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>{var j;return(j=w.current)==null?void 0:j.click()},className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md ring-1 ring-dashed ring-violet-300 dark:ring-violet-700 text-[9px] font-semibold text-violet-600 dark:text-violet-400 hover:bg-violet-50 dark:hover:bg-violet-900/20 transition-colors",children:[f?s.jsx(ae,{size:9,className:"animate-spin"}):s.jsx(Dm,{size:9})," Upload"]}),s.jsx("input",{ref:w,type:"file",accept:".json,.csv",onChange:h,className:"hidden"})]})]}),e==="inline"&&!x&&s.jsx("textarea",{className:"w-full h-14 text-[10px] font-mono border border-border rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 mb-2 bg-surface-inset/50",placeholder:'[{"email":"user1@test.com","password":"pass1"}]',value:n,onChange:j=>i(j.target.value)}),e!=="none"&&c.length>0&&!x&&s.jsxs("div",{className:"mb-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsxs("span",{className:"text-[9px] text-content-tertiary",children:[c.length," row",c.length!==1?"s":""]}),s.jsxs("button",{type:"button",onClick:()=>{e==="inline"&&b(n),p(!0)},className:"text-[9px] text-violet-600 dark:text-violet-400 hover:text-violet-800 dark:hover:text-violet-300 font-semibold flex items-center gap-0.5",children:[s.jsx(Hr,{size:8})," Edit"]})]}),s.jsx("div",{className:"overflow-x-auto border border-border rounded-lg",children:s.jsxs("table",{className:"w-full text-[10px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-surface-inset border-b border-border",children:[s.jsx("th",{className:"px-2 py-1 text-left font-bold text-content-tertiary w-6",children:"#"}),g.map(j=>s.jsx("th",{className:"px-2 py-1 text-left font-bold text-violet-600 dark:text-violet-400",children:`{{${j}}}`},j))]})}),s.jsxs("tbody",{children:[c.slice(0,8).map((j,k)=>s.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-surface-inset/50",children:[s.jsx("td",{className:"px-2 py-0.5 text-content-tertiary tabular-nums",children:k+1}),g.map(N=>s.jsx("td",{className:"px-2 py-0.5 text-content-secondary font-mono",children:j[N]},N))]},k)),c.length>8&&s.jsx("tr",{children:s.jsxs("td",{colSpan:g.length+1,className:"px-2 py-1 text-center text-content-tertiary text-[9px] italic",children:["+",c.length-8," more"]})})]})]})})]}),x&&s.jsxs("div",{className:"mb-2",children:[s.jsx("textarea",{className:"w-full h-32 text-[10px] font-mono border border-violet-300 dark:border-violet-700 rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-violet-300 dark:focus:ring-violet-700 bg-violet-50/20 dark:bg-violet-900/10 text-content",value:y,onChange:j=>b(j.target.value)}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[s.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-0.5 px-2.5 py-1 rounded-lg bg-violet-600 text-white text-[10px] font-semibold hover:bg-violet-700",children:[s.jsx(Oe,{size:10})," Save"]}),s.jsxs("button",{type:"button",onClick:()=>p(!1),className:"flex items-center gap-0.5 px-2.5 py-1 rounded-lg border border-border text-[10px] text-content-secondary hover:bg-surface-inset",children:[s.jsx(be,{size:10})," Cancel"]})]})]})]})}function Z5({step:e,index:t,caseIsApi:n,suiteIsAudit:r,generating:a,isDragging:i,isDragOver:l,onDragStart:o,onDragOver:c,onDrop:d,onDragEnd:x,onDelete:p,onGenerate:y,onSaveInstruction:b,onSaveTimeout:f,onSaveRetries:v,onSaveStepType:w,onSaveMockUrl:h,onSaveMockResponse:u,onSaveMockStatus:g,onSaveRunAudit:j,onSaveSoft:k,onSaveVisualCheck:N}){var Ct;const[E,R]=m.useState(!1),[L,M]=m.useState(!1),[W,G]=m.useState(e.instruction),[ne,A]=m.useState(e.timeout?String(e.timeout):""),[Y,se]=m.useState(e.retries!=null?String(e.retries):""),[le,T]=m.useState(e.mockUrl??""),[S,z]=m.useState(e.mockResponse??""),[q,_]=m.useState(e.mockStatus?String(e.mockStatus):"200"),re=m.useRef(null),[U,xe]=m.useState(void 0),me=!!((Ct=e.generatedCode)!=null&&Ct.trim()),Ee=e.stepType==="mock",ye=!!e.runAudit,Te=U!==void 0?U:ye,pt=U!==void 0&&U!==ye,It=()=>{U!==void 0&&(j==null||j(e.id,U),xe(void 0))},rs=()=>xe(void 0);m.useEffect(()=>{Ee&&R(!0)},[Ee]),m.useEffect(()=>{A(e.timeout?String(e.timeout):"")},[e.timeout]),m.useEffect(()=>{G(e.instruction)},[e.instruction]),m.useEffect(()=>{var K;L&&((K=re.current)==null||K.focus())},[L]);const He=()=>{const K=W.trim();K&&K!==e.instruction&&b(e.id,K),M(!1)};return s.jsxs("div",{draggable:!0,onDragStart:K=>{K.dataTransfer.effectAllowed="move",o()},onDragOver:K=>{K.preventDefault(),c()},onDrop:K=>{K.preventDefault(),d()},onDragEnd:x,className:P("rounded-lg overflow-hidden transition-all",i?"opacity-40 ring-2 ring-accent":"ring-1 ring-border",l?"ring-2 ring-accent shadow-sm":""),children:[s.jsxs("div",{className:"flex items-start gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 pt-0.5",children:[s.jsx(Dc,{size:11,className:"text-content-tertiary hover:text-content-secondary cursor-grab active:cursor-grabbing"}),s.jsx("span",{className:"w-5 h-5 rounded-md bg-gradient-to-br from-accent to-accent-dark text-white text-[9px] font-bold flex items-center justify-center",children:t+1})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-start gap-1.5 flex-wrap",children:[L?s.jsx("input",{ref:re,className:"flex-1 text-xs text-content border border-accent/40 rounded-md px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-accent/30 min-w-0 bg-surface-inset/50",value:W,onChange:K=>G(K.target.value),onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),He()),K.key==="Escape"&&(G(e.instruction),M(!1))},onBlur:He}):s.jsx("span",{className:"text-xs text-content font-medium flex-1",children:e.instruction}),s.jsx("span",{className:P("text-[8px] px-1 py-px rounded font-bold uppercase flex-shrink-0 ring-1",Ee?"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 ring-purple-200 dark:ring-purple-800":e.stepType==="api"||n?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":r?"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800"),children:Ee?"Mock":e.stepType==="api"||n?"API":r?"Audit":"UI"}),Te&&s.jsxs("span",{className:P("text-[8px] px-1 py-px rounded font-bold flex items-center gap-0.5 ring-1",pt?"bg-amber-50 dark:bg-amber-900/20 text-amber-500 dark:text-amber-400 ring-amber-200 dark:ring-amber-800 opacity-60":"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800"),children:[s.jsx(qe,{size:7}),pt?"Audit*":"Audit"]}),e.lastHealed&&s.jsx("span",{className:"text-[8px] px-1 py-px rounded bg-amber-50 text-amber-600 ring-1 ring-amber-200 font-bold",children:"healed"})]}),me&&!L&&s.jsx("p",{className:"text-[10px] text-content-tertiary mt-px",children:"Code generated ✓"})]}),s.jsxs("select",{value:e.stepType??"ui",onChange:K=>{K.target.value==="mock"&&R(!0),w==null||w(e.id,K.target.value)},className:"text-[10px] border border-border rounded-md px-1 py-0.5 bg-surface-inset/50 text-content-secondary focus:outline-none focus:border-accent flex-shrink-0",children:[s.jsx("option",{value:"ui",children:"UI"}),s.jsx("option",{value:"api",children:"API"}),s.jsx("option",{value:"mock",children:"Mock"})]}),s.jsx("input",{type:"number",min:0,max:5,step:1,className:"w-10 text-[10px] border border-border rounded-md px-1.5 py-0.5 text-content-secondary placeholder:text-content-tertiary focus:outline-none focus:border-accent flex-shrink-0 bg-surface-inset/50",placeholder:"×",title:"Retries",value:Y,onChange:K=>se(K.target.value),onBlur:()=>{const K=Y.trim()?parseInt(Y,10):null,Ke=e.retries??null;K!==Ke&&(v==null||v(e.id,K!=null&&K>=0?K:null))},onKeyDown:K=>{K.key==="Enter"&&K.target.blur()}}),s.jsx("input",{type:"number",min:100,step:100,className:"w-16 text-[10px] border border-border rounded-md px-1.5 py-0.5 text-content-secondary placeholder:text-content-tertiary focus:outline-none focus:border-accent flex-shrink-0 bg-surface-inset/50",placeholder:"ms",value:ne,onChange:K=>A(K.target.value),onBlur:()=>{const K=ne.trim()?parseInt(ne,10):null,Ke=e.timeout??null;K!==Ke&&f(e.id,K&&K>0?K:null)},onKeyDown:K=>{K.key==="Enter"&&K.target.blur()}}),s.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[L?s.jsx("button",{type:"button",onClick:He,className:"p-1 rounded-md text-emerald-500 hover:bg-emerald-50 dark:hover:bg-emerald-900/20 transition-colors",children:s.jsx(Oe,{size:12})}):s.jsx("button",{type:"button",onClick:()=>M(!0),className:"p-1 rounded-md text-content-tertiary hover:text-accent hover:bg-accent/5 transition-colors",children:s.jsx(Hr,{size:11})}),r&&!n&&e.stepType!=="api"&&e.stepType!=="mock"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",title:Te?"Remove Lighthouse audit checkpoint":"Mark as Lighthouse audit checkpoint",onClick:K=>{K.stopPropagation(),xe(!Te)},onMouseDown:K=>K.stopPropagation(),className:P("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[9px] font-bold transition-all cursor-pointer select-none",Te?"text-amber-700 dark:text-amber-400 bg-amber-100 dark:bg-amber-900/30 hover:bg-amber-200 dark:hover:bg-amber-900/40 ring-1 ring-amber-300 dark:ring-amber-700":"text-content-tertiary hover:text-amber-600 dark:hover:text-amber-400 hover:bg-amber-50 dark:hover:bg-amber-900/20 ring-1 ring-transparent hover:ring-amber-200 dark:hover:ring-amber-800"),children:[s.jsx(qe,{size:9}),s.jsx("span",{children:"Audit"})]}),pt&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",title:"Save audit change",onClick:K=>{K.stopPropagation(),It()},onMouseDown:K=>K.stopPropagation(),className:"p-1 rounded-md text-emerald-600 hover:bg-emerald-50 dark:hover:bg-emerald-900/20 transition-colors",children:s.jsx(Oe,{size:11})}),s.jsx("button",{type:"button",title:"Cancel",onClick:K=>{K.stopPropagation(),rs()},onMouseDown:K=>K.stopPropagation(),className:"p-1 rounded-md text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})})]})]}),/^(?:soft\s+)?(?:verify|check|assert|ensure|confirm)\b/i.test(e.instruction)&&s.jsx("button",{type:"button",title:e.soft?"Soft assertion (test continues on failure) — click to make hard":"Hard assertion (test stops on failure) — click to make soft",onClick:K=>{K.stopPropagation(),k==null||k(e.id,!e.soft)},onMouseDown:K=>K.stopPropagation(),className:P("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[9px] font-bold transition-all cursor-pointer select-none",e.soft?"text-blue-700 dark:text-blue-400 bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-200 dark:hover:bg-blue-900/40 ring-1 ring-blue-300 dark:ring-blue-700":"text-content-tertiary hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 ring-1 ring-transparent hover:ring-blue-200 dark:hover:ring-blue-800"),children:s.jsx("span",{children:e.soft?"Soft":"Hard"})}),e.stepType!=="api"&&s.jsx("button",{type:"button",title:e.visualCheck?"Visual regression enabled — click to disable":"Enable visual regression for this step",onClick:K=>{K.stopPropagation(),N==null||N(e.id,!e.visualCheck)},onMouseDown:K=>K.stopPropagation(),className:P("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[9px] font-bold transition-all cursor-pointer select-none",e.visualCheck?"text-emerald-700 dark:text-emerald-400 bg-emerald-100 dark:bg-emerald-900/30 hover:bg-emerald-200 dark:hover:bg-emerald-900/40 ring-1 ring-emerald-300 dark:ring-emerald-700":"text-content-tertiary hover:text-emerald-600 dark:hover:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20 ring-1 ring-transparent hover:ring-emerald-200 dark:hover:ring-emerald-800"),children:s.jsx(Pl,{size:12})}),s.jsx("button",{type:"button",onClick:()=>y(e.id),disabled:a,className:"p-1 rounded-md text-content-tertiary hover:text-accent hover:bg-accent/5 transition-colors disabled:opacity-40",children:a?s.jsx(ae,{size:12,className:"animate-spin"}):s.jsx(_r,{size:12})}),s.jsx("button",{type:"button",onClick:()=>p(e.id),className:"p-1 rounded-md text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(Kt,{size:11})}),s.jsx("button",{type:"button",onClick:()=>R(K=>!K),className:"p-1 rounded-md text-content-tertiary hover:text-content-secondary hover:bg-surface-inset transition-colors",children:E?s.jsx(Nt,{size:12}):s.jsx(Ht,{size:12})})]})]}),E&&s.jsxs("div",{className:"border-t border-border",children:[Ee&&s.jsxs("div",{className:"px-3 py-2.5 bg-violet-50/50 dark:bg-violet-900/10 space-y-1.5 border-b border-border",children:[s.jsx("p",{className:"text-[9px] font-bold text-violet-600 dark:text-violet-400 uppercase tracking-widest",children:"Mock Route"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("input",{className:"flex-1 text-[10px] border border-border rounded px-2 py-1 bg-surface focus:outline-none focus:border-violet-400",placeholder:"URL pattern, e.g. **/api/users",value:le,onChange:K=>T(K.target.value),onBlur:()=>{le!==(e.mockUrl??"")&&(h==null||h(e.id,le))}}),s.jsx("input",{type:"number",className:"w-16 text-[10px] border border-border rounded px-2 py-1 bg-surface focus:outline-none focus:border-violet-400",placeholder:"Status",value:q,onChange:K=>_(K.target.value),onBlur:()=>{const K=parseInt(q,10);!isNaN(K)&&K!==(e.mockStatus??200)&&(g==null||g(e.id,K))}})]}),s.jsx("textarea",{rows:3,className:"w-full text-[10px] border border-border rounded px-2 py-1 bg-surface focus:outline-none focus:border-violet-400 font-mono resize-none",placeholder:'{"key":"value"}',value:S,onChange:K=>z(K.target.value),onBlur:()=>{S!==(e.mockResponse??"")&&(u==null||u(e.id,S))}})]}),me?s.jsx($m,{code:e.generatedCode,maxLines:12,className:"rounded-none"}):s.jsxs("div",{className:"px-3 py-2.5 text-[10px] text-content-tertiary italic bg-surface-inset/30",children:["No code yet — click ",s.jsx(_r,{size:9,className:"inline mb-0.5"})," to generate"]})]})]})}let Gt=null,ji=!1;const bx=new Set;function Ni(){bx.forEach(e=>e())}const ms={subscribe(e){return bx.add(e),()=>{bx.delete(e)}},getSnapshot(){return{job:Gt,showPopup:ji}},start(e,t){const n=`gen-${Date.now()}`;return Gt={id:n,tab:e,label:t,status:"running",startedAt:Date.now()},ji=!1,Ni(),n},done(e,t){Gt&&(Gt={...Gt,status:"done",suiteId:e,suiteName:t},ji=!0,Ni())},error(e){Gt&&(Gt={...Gt,status:"error",error:e},Ni())},dismissPopup(){ji=!1,Ni()},clear(){Gt=null,ji=!1,Ni()},isRunning(){return(Gt==null?void 0:Gt.status)==="running"}};function sb(){const[e,t]=m.useState(()=>ms.getSnapshot());return m.useEffect(()=>ms.subscribe(()=>t(ms.getSnapshot())),[]),e}const eS=[{title:"Login Flow",story:"User logs in with valid credentials, navigates to the dashboard, and verifies that the welcome message is displayed."},{title:"E-Commerce Checkout",story:"User searches for a product, adds it to the cart, proceeds to checkout, and completes the purchase."},{title:"Admin Management",story:"Admin user creates a new account, assigns roles, and verifies the account appears in the user list."}],tS=/^(https?:\/\/.+\/(browse|issue)\/[A-Z][A-Z0-9_]+-\d+|https?:\/\/.+selectedIssue=[A-Z][A-Z0-9_]+-\d+|[A-Z][A-Z0-9_]+-\d+)$/i;function Wp(e){return e.trim()?tS.test(e.trim()):!0}function Vp(e){const t=e.trim();if(!t)return null;const n=t.match(/([A-Z][A-Z0-9_]+-\d+)/i);return n?n[1].toUpperCase():null}function sS(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const i=JSON.parse(t).map(l=>{if(typeof l=="string")return{story:l.trim()};if(typeof l=="object"&&l!==null&&"story"in l){const o=l;return{story:String(o.story).trim(),suiteName:o.suiteName,jiraUrl:o.jiraUrl}}return null}).filter(l=>l!==null&&l.story.length>=10);if(i.length>0)return i}catch{}const n=t.split(/\n\s*---+\s*\n/).map(a=>a.trim()).filter(Boolean);if(n.length>1)return n.map(a=>a.replace(/^\d+\.\s*/,"").trim()).filter(a=>a.length>=10).map(a=>({story:a}));const r=t.split(`
889
+ `:"";switch(e.action){case"navigate":return`await page.goto('${ar(e.url||"")}');`;case"click":return`${n}await page.${t}.click();`;case"fill":return`${n}await page.${t}.fill('${ar(e.value||"")}');`;case"select":return`await page.${t}.selectOption('${ar(e.value||"")}');`;case"check":return`await page.${t}.check();`;case"uncheck":return`await page.${t}.uncheck();`;case"press":return t?`await page.${t}.press('${ar(e.value||"")}');`:`await page.keyboard.press('${ar(e.value||"")}');`;case"hover":return`await page.${t}.click();`;case"assert":{const r=e.instruction,a=e.soft?"expect.soft":"expect";if(r.includes("current URL contains")){const i=r.match(/contains "(.+)"/),l=i?i[1]:"/";return`await ${a}(page).toHaveURL(/${Fw(l)}/);`}if(r.includes("page title is")){const i=r.match(/title is "(.+)"/),l=i?i[1]:"";return`await ${a}(page).toHaveTitle('${ar(l)}');`}if(r.includes("has value")){const i=r.match(/has value "(.+)"/),l=i?i[1]:"";return`await ${a}(page.${t}).toHaveValue('${ar(l)}');`}return r.includes("is checked")?`await ${a}(page.${t}).toBeChecked();`:r.includes("is unchecked")?`await ${a}(page.${t}).not.toBeChecked();`:t?`await ${a}(page.${t}).toBeVisible();`:`// TODO: ${r}`}default:return`// Unhandled action: ${e.action}`}}function ar(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function Fw(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}let hi=!1,Cd=null;const ta=[];let Ed=!1,Pd=[];const xx=new Set;function Is(){for(const e of xx)e()}const Re={subscribe(e){return xx.add(e),()=>{xx.delete(e)}},getSnapshot(){return{panelOpen:hi,operationInProgress:Cd,logSteps:[...ta],hasConflict:Ed,conflictFiles:[...Pd]}},togglePanel(){hi=!hi,Is()},openPanel(){hi=!0,Is()},closePanel(){hi=!1,Is()},startOperation(e){Cd=e,ta.length=0,Is()},finishOperation(){Cd=null,Is()},addLogStep(e){const t=ta.findIndex(n=>n.step===e.step&&n.status==="running");t>=0&&e.status!=="running"?ta[t]=e:t<0&&ta.push(e),Is()},clearLogs(){ta.length=0,Is()},setConflict(e){Ed=e.length>0,Pd=e,Is()},clearConflict(){Ed=!1,Pd=[],Is()}};function Uc(){const[e,t]=m.useState(()=>Re.getSnapshot());return m.useEffect(()=>Re.subscribe(()=>t(Re.getSnapshot())),[]),e}function Lm(){return pe({queryKey:["git","status"],queryFn:Ve.status,refetchInterval:5e3,retry:1})}function Py(){return pe({queryKey:["git","branches"],queryFn:Ve.branches,staleTime:3e4,retry:1})}function Ry(e){return pe({queryKey:["git","log",e],queryFn:()=>Ve.log(e),staleTime:1e4,retry:1})}function zy(){const e=ie();return V({mutationFn:t=>Ve.checkout(t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["git"]}),O.success(`Switched to ${n}`)},onError:t=>O.error(`Checkout failed: ${t.message}`)})}function My(){const e=ie();return V({mutationFn:t=>(Re.startOperation("commit"),Ve.commit(t)),onSuccess:t=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success(`Committed: ${t.hash}`)},onError:t=>{Re.finishOperation(),O.error(`Commit failed: ${t.message}`)}})}function Ty(){const e=ie();return V({mutationFn:t=>(Re.startOperation("pull"),Ve.pull(t)),onSuccess:()=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success("Pull successful")},onError:t=>{Re.finishOperation(),O.error(`Pull failed: ${t.message}`)}})}function Ay(){const e=ie();return V({mutationFn:()=>(Re.startOperation("push"),Ve.push()),onSuccess:()=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success("Pushed to remote")},onError:t=>{Re.finishOperation(),O.error(`Push failed: ${t.message}`)}})}function Oy(){const e=ie();return V({mutationFn:t=>(Re.startOperation("full-sync"),Ve.fullSync(t)),onSuccess:()=>{Re.finishOperation(),e.invalidateQueries({queryKey:["git"]}),O.success("Full sync complete")},onError:t=>{Re.finishOperation(),O.error(`Sync failed: ${t.message}`)}})}function Dy(){return V({mutationFn:()=>Ve.generateCommitMessage(),onError:e=>O.error(`AI generation failed: ${e.message}`)})}function Iy(){const e=ie();return V({mutationFn:({filePath:t,content:n})=>Ve.resolveConflict(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["git"]}),O.success("Conflict resolved")},onError:t=>O.error(`Resolve failed: ${t.message}`)})}function Fy(){return V({mutationFn:({filePath:e,ours:t,theirs:n})=>Ve.resolveConflictAI(e,t,n),onError:e=>O.error(`AI resolve failed: ${e.message}`)})}function Ly(){const e=ie();return V({mutationFn:()=>Ve.continueRebase(),onSuccess:()=>{Re.clearConflict(),e.invalidateQueries({queryKey:["git"]}),O.success("Rebase continued")},onError:t=>O.error(`Continue rebase failed: ${t.message}`)})}function _y(){const e=ie();return V({mutationFn:()=>Ve.abortRebase(),onSuccess:()=>{Re.clearConflict(),e.invalidateQueries({queryKey:["git"]}),O.success("Rebase aborted")},onError:t=>O.error(`Abort rebase failed: ${t.message}`)})}const $y="assuremind-theme";function Lw(){const e=localStorage.getItem($y);return e==="dark"||e==="light"?e:"light"}let la=Lw();const mx=new Set;function Uy(e){const t=document.documentElement;e==="dark"?t.classList.add("dark"):t.classList.remove("dark")}Uy(la);function _w(){for(const e of mx)e()}const Rd={subscribe(e){return mx.add(e),()=>{mx.delete(e)}},getSnapshot(){return la},toggle(){la=la==="light"?"dark":"light",localStorage.setItem($y,la),Uy(la),_w()}};function $w(){return{theme:m.useSyncExternalStore(Rd.subscribe,Rd.getSnapshot),toggle:Rd.toggle}}const By=6048e5,Uw=864e5,Zl=43200,Ip=1440,Fp=Symbol.for("constructDateFrom");function rn(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Fp in e?e[Fp](t):e instanceof Date?new e.constructor(t):new Date(t)}function nt(e,t){return rn(t||e,e)}let Bw={};function Rl(){return Bw}function ul(e,t){var o,c,d,x;const n=Rl(),r=(t==null?void 0:t.weekStartsOn)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((x=(d=n.locale)==null?void 0:d.options)==null?void 0:x.weekStartsOn)??0,a=nt(e,t==null?void 0:t.in),i=a.getDay(),l=(i<r?7:0)+i-r;return a.setDate(a.getDate()-l),a.setHours(0,0,0,0),a}function ac(e,t){return ul(e,{...t,weekStartsOn:1})}function qy(e,t){const n=nt(e,t==null?void 0:t.in),r=n.getFullYear(),a=rn(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const i=ac(a),l=rn(n,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const o=ac(l);return n.getTime()>=i.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function ic(e){const t=nt(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Bc(e,...t){const n=rn.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function Lp(e,t){const n=nt(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function qw(e,t,n){const[r,a]=Bc(n==null?void 0:n.in,e,t),i=Lp(r),l=Lp(a),o=+i-ic(i),c=+l-ic(l);return Math.round((o-c)/Uw)}function Hw(e,t){const n=qy(e,t),r=rn(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),ac(r)}function ko(e,t){const n=+nt(e)-+nt(t);return n<0?-1:n>0?1:n}function Kw(e){return rn(e,Date.now())}function Ww(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Vw(e){return!(!Ww(e)&&typeof e!="number"||isNaN(+nt(e)))}function Gw(e,t,n){const[r,a]=Bc(n==null?void 0:n.in,e,t),i=r.getFullYear()-a.getFullYear(),l=r.getMonth()-a.getMonth();return i*12+l}function Qw(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Yw(e,t){return+nt(e)-+nt(t)}function Jw(e,t){const n=nt(e,t==null?void 0:t.in);return n.setHours(23,59,59,999),n}function Xw(e,t){const n=nt(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Zw(e,t){const n=nt(e,t==null?void 0:t.in);return+Jw(n,t)==+Xw(n,t)}function ek(e,t,n){const[r,a,i]=Bc(n==null?void 0:n.in,e,e,t),l=ko(a,i),o=Math.abs(Gw(a,i));if(o<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-l*o);let c=ko(a,i)===-l;Zw(r)&&o===1&&ko(r,i)===1&&(c=!1);const d=l*(o-+c);return d===0?0:d}function tk(e,t,n){const r=Yw(e,t)/1e3;return Qw(n==null?void 0:n.roundingMethod)(r)}function sk(e,t){const n=nt(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const nk={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},rk=(e,t,n)=>{let r;const a=nk[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function zd(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const ak={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ik={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},lk={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ok={date:zd({formats:ak,defaultWidth:"full"}),time:zd({formats:ik,defaultWidth:"full"}),dateTime:zd({formats:lk,defaultWidth:"full"})},ck={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},dk=(e,t,n,r)=>ck[e];function pi(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,o=n!=null&&n.width?String(n.width):l;a=e.formattingValues[o]||e.formattingValues[l]}else{const l=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[l]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const uk={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xk={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},mk={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},hk={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},pk={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},fk={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},gk=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},yk={ordinalNumber:gk,era:pi({values:uk,defaultWidth:"wide"}),quarter:pi({values:xk,defaultWidth:"wide",argumentCallback:e=>e-1}),month:pi({values:mk,defaultWidth:"wide"}),day:pi({values:hk,defaultWidth:"wide"}),dayPeriod:pi({values:pk,defaultWidth:"wide",formattingValues:fk,defaultFormattingWidth:"wide"})};function fi(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const l=i[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(o)?vk(o,p=>p.test(l)):bk(o,p=>p.test(l));let d;d=e.valueCallback?e.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const x=t.slice(l.length);return{value:d,rest:x}}}function bk(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function vk(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function jk(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],i=t.match(e.parsePattern);if(!i)return null;let l=e.valueCallback?e.valueCallback(i[0]):i[0];l=n.valueCallback?n.valueCallback(l):l;const o=t.slice(a.length);return{value:l,rest:o}}}const Nk=/^(\d+)(th|st|nd|rd)?/i,wk=/\d+/i,kk={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Sk={any:[/^b/i,/^(a|c)/i]},Ck={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ek={any:[/1/i,/2/i,/3/i,/4/i]},Pk={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Rk={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},zk={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Mk={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Tk={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ak={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ok={ordinalNumber:jk({matchPattern:Nk,parsePattern:wk,valueCallback:e=>parseInt(e,10)}),era:fi({matchPatterns:kk,defaultMatchWidth:"wide",parsePatterns:Sk,defaultParseWidth:"any"}),quarter:fi({matchPatterns:Ck,defaultMatchWidth:"wide",parsePatterns:Ek,defaultParseWidth:"any",valueCallback:e=>e+1}),month:fi({matchPatterns:Pk,defaultMatchWidth:"wide",parsePatterns:Rk,defaultParseWidth:"any"}),day:fi({matchPatterns:zk,defaultMatchWidth:"wide",parsePatterns:Mk,defaultParseWidth:"any"}),dayPeriod:fi({matchPatterns:Tk,defaultMatchWidth:"any",parsePatterns:Ak,defaultParseWidth:"any"})},Hy={code:"en-US",formatDistance:rk,formatLong:ok,formatRelative:dk,localize:yk,match:Ok,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Dk(e,t){const n=nt(e,t==null?void 0:t.in);return qw(n,sk(n))+1}function Ik(e,t){const n=nt(e,t==null?void 0:t.in),r=+ac(n)-+Hw(n);return Math.round(r/By)+1}function Ky(e,t){var x,p,y,b;const n=nt(e,t==null?void 0:t.in),r=n.getFullYear(),a=Rl(),i=(t==null?void 0:t.firstWeekContainsDate)??((p=(x=t==null?void 0:t.locale)==null?void 0:x.options)==null?void 0:p.firstWeekContainsDate)??a.firstWeekContainsDate??((b=(y=a.locale)==null?void 0:y.options)==null?void 0:b.firstWeekContainsDate)??1,l=rn((t==null?void 0:t.in)||e,0);l.setFullYear(r+1,0,i),l.setHours(0,0,0,0);const o=ul(l,t),c=rn((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,i),c.setHours(0,0,0,0);const d=ul(c,t);return+n>=+o?r+1:+n>=+d?r:r-1}function Fk(e,t){var o,c,d,x;const n=Rl(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((x=(d=n.locale)==null?void 0:d.options)==null?void 0:x.firstWeekContainsDate)??1,a=Ky(e,t),i=rn((t==null?void 0:t.in)||e,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),ul(i,t)}function Lk(e,t){const n=nt(e,t==null?void 0:t.in),r=+ul(n,t)-+Fk(n,t);return Math.round(r/By)+1}function Se(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const xn={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return Se(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):Se(n+1,2)},d(e,t){return Se(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return Se(e.getHours()%12||12,t.length)},H(e,t){return Se(e.getHours(),t.length)},m(e,t){return Se(e.getMinutes(),t.length)},s(e,t){return Se(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return Se(a,t.length)}},sa={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},_p={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return xn.y(e,t)},Y:function(e,t,n,r){const a=Ky(e,r),i=a>0?a:1-a;if(t==="YY"){const l=i%100;return Se(l,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):Se(i,t.length)},R:function(e,t){const n=qy(e);return Se(n,t.length)},u:function(e,t){const n=e.getFullYear();return Se(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return Se(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return Se(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return xn.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return Se(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=Lk(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):Se(a,t.length)},I:function(e,t,n){const r=Ik(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):Se(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):xn.d(e,t)},D:function(e,t,n){const r=Dk(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Se(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return Se(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return Se(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return Se(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=sa.noon:r===0?a=sa.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=sa.evening:r>=12?a=sa.afternoon:r>=4?a=sa.morning:a=sa.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return xn.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):xn.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Se(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):Se(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):xn.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):xn.s(e,t)},S:function(e,t){return xn.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Up(r);case"XXXX":case"XX":return cr(r);case"XXXXX":case"XXX":default:return cr(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Up(r);case"xxxx":case"xx":return cr(r);case"xxxxx":case"xxx":default:return cr(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+$p(r,":");case"OOOO":default:return"GMT"+cr(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+$p(r,":");case"zzzz":default:return"GMT"+cr(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return Se(r,t.length)},T:function(e,t,n){return Se(+e,t.length)}};function $p(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+Se(i,2)}function Up(e,t){return e%60===0?(e>0?"-":"+")+Se(Math.abs(e)/60,2):cr(e,t)}function cr(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Se(Math.trunc(r/60),2),i=Se(r%60,2);return n+a+t+i}const Bp=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},Wy=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},_k=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return Bp(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",Bp(r,t)).replace("{{time}}",Wy(a,t))},$k={p:Wy,P:_k},Uk=/^D+$/,Bk=/^Y+$/,qk=["D","DD","YY","YYYY"];function Hk(e){return Uk.test(e)}function Kk(e){return Bk.test(e)}function Wk(e,t,n){const r=Vk(e,t,n);if(console.warn(r),qk.includes(e))throw new RangeError(r)}function Vk(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Gk=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Qk=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Yk=/^'([^]*?)'?$/,Jk=/''/g,Xk=/[a-zA-Z]/;function Zk(e,t,n){var x,p,y,b;const r=Rl(),a=r.locale??Hy,i=r.firstWeekContainsDate??((p=(x=r.locale)==null?void 0:x.options)==null?void 0:p.firstWeekContainsDate)??1,l=r.weekStartsOn??((b=(y=r.locale)==null?void 0:y.options)==null?void 0:b.weekStartsOn)??0,o=nt(e,n==null?void 0:n.in);if(!Vw(o))throw new RangeError("Invalid time value");let c=t.match(Qk).map(f=>{const v=f[0];if(v==="p"||v==="P"){const w=$k[v];return w(f,a.formatLong)}return f}).join("").match(Gk).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const v=f[0];if(v==="'")return{isToken:!1,value:e5(f)};if(_p[v])return{isToken:!0,value:f};if(v.match(Xk))throw new RangeError("Format string contains an unescaped latin alphabet character `"+v+"`");return{isToken:!1,value:f}});a.localize.preprocessor&&(c=a.localize.preprocessor(o,c));const d={firstWeekContainsDate:i,weekStartsOn:l,locale:a};return c.map(f=>{if(!f.isToken)return f.value;const v=f.value;(Kk(v)||Hk(v))&&Wk(v,t,String(e));const w=_p[v[0]];return w(o,v,a.localize,d)}).join("")}function e5(e){const t=e.match(Yk);return t?t[1].replace(Jk,"'"):e}function t5(e,t,n){const r=Rl(),a=(n==null?void 0:n.locale)??r.locale??Hy,i=2520,l=ko(e,t);if(isNaN(l))throw new RangeError("Invalid time value");const o=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:l}),[c,d]=Bc(n==null?void 0:n.in,...l>0?[t,e]:[e,t]),x=tk(d,c),p=(ic(d)-ic(c))/1e3,y=Math.round((x-p)/60);let b;if(y<2)return n!=null&&n.includeSeconds?x<5?a.formatDistance("lessThanXSeconds",5,o):x<10?a.formatDistance("lessThanXSeconds",10,o):x<20?a.formatDistance("lessThanXSeconds",20,o):x<40?a.formatDistance("halfAMinute",0,o):x<60?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",1,o):y===0?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",y,o);if(y<45)return a.formatDistance("xMinutes",y,o);if(y<90)return a.formatDistance("aboutXHours",1,o);if(y<Ip){const f=Math.round(y/60);return a.formatDistance("aboutXHours",f,o)}else{if(y<i)return a.formatDistance("xDays",1,o);if(y<Zl){const f=Math.round(y/Ip);return a.formatDistance("xDays",f,o)}else if(y<Zl*2)return b=Math.round(y/Zl),a.formatDistance("aboutXMonths",b,o)}if(b=ek(d,c),b<12){const f=Math.round(y/Zl);return a.formatDistance("xMonths",f,o)}else{const f=b%12,v=Math.trunc(b/12);return f<3?a.formatDistance("aboutXYears",v,o):f<9?a.formatDistance("overXYears",v,o):a.formatDistance("almostXYears",v+1,o)}}function lc(e,t){return t5(e,Kw(e),t)}let ir=[];const hx=new Set;function Md(){hx.forEach(e=>e())}const zr={subscribe(e){return hx.add(e),()=>{hx.delete(e)}},getSnapshot(){return{notifications:ir,unreadCount:ir.filter(e=>!e.read).length}},push(e){ir=[e,...ir].slice(0,20),Md()},markAllRead(){ir=ir.map(e=>({...e,read:!0})),Md()},clear(){ir=[],Md()}};function s5(){const[e,t]=m.useState(()=>zr.getSnapshot());return m.useEffect(()=>zr.subscribe(()=>t(zr.getSnapshot())),[]),e}function n5({type:e}){switch(e){case"run-complete":return s.jsx(we,{size:13,className:"text-emerald-500 flex-shrink-0"});case"run-error":return s.jsx(tt,{size:13,className:"text-red-500 flex-shrink-0"});case"healing":return s.jsx(qe,{size:13,className:"text-amber-500 flex-shrink-0"});case"git":return s.jsx(Lr,{size:13,className:"text-blue-500 flex-shrink-0"});default:return s.jsx(ec,{size:13,className:"text-content-tertiary flex-shrink-0"})}}function r5(){const[e,t]=m.useState(!1),{notifications:n,unreadCount:r}=s5(),a=m.useRef(null),i=zs();return m.useEffect(()=>{if(!e)return;function l(o){a.current&&!a.current.contains(o.target)&&t(!1)}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[e]),s.jsxs("div",{className:"relative",ref:a,children:[s.jsxs("button",{type:"button",onClick:()=>t(l=>!l),className:P("relative p-2 rounded-lg transition-all duration-200",e?"bg-accent-muted text-accent":"text-content-tertiary hover:bg-surface-inset hover:text-content-secondary"),"aria-label":"Notifications",title:"Notifications",children:[s.jsx(ec,{size:16}),r>0&&s.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white text-[9px] font-bold flex items-center justify-center ring-2 ring-surface",children:r>9?"9+":r})]}),e&&s.jsxs("div",{className:"absolute right-0 top-full mt-2 w-80 bg-surface border border-border rounded-xl shadow-modal z-50 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-inset/50",children:[s.jsx("span",{className:"text-xs font-semibold text-content",children:"Notifications"}),s.jsxs("div",{className:"flex items-center gap-1",children:[r>0&&s.jsx("button",{type:"button",onClick:()=>zr.markAllRead(),className:"p-1 rounded text-content-tertiary hover:text-content hover:bg-surface-inset transition-colors",title:"Mark all read",children:s.jsx(cy,{size:12})}),s.jsx("button",{type:"button",onClick:()=>zr.clear(),className:"p-1 rounded text-content-tertiary hover:text-red-500 hover:bg-red-50 transition-colors",title:"Clear all",children:s.jsx(Kt,{size:12})})]})]}),s.jsx("div",{className:"max-h-80 overflow-y-auto divide-y divide-border/50",children:n.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-2",children:[s.jsx(ec,{size:20,className:"text-content-tertiary/40"}),s.jsx("p",{className:"text-xs text-content-tertiary",children:"No notifications"})]}):n.map(l=>s.jsxs("div",{className:P("flex items-start gap-2.5 px-3 py-2.5 transition-colors",!l.read&&"bg-accent-muted/20",l.link&&"cursor-pointer hover:bg-surface-inset/50"),onClick:()=>{l.link&&(t(!1),i(l.link))},children:[s.jsx("div",{className:"mt-0.5",children:s.jsx(n5,{type:l.type})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:P("text-xs leading-relaxed",l.read?"text-content-secondary":"text-content font-medium"),children:l.message}),s.jsx("p",{className:"text-[9px] text-content-tertiary mt-0.5",children:lc(new Date(l.timestamp),{addSuffix:!0})})]}),l.link&&s.jsx(si,{size:10,className:"text-content-tertiary/60 flex-shrink-0 mt-0.5"}),!l.read&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent flex-shrink-0 mt-1.5"})]},l.id))})]})]})}function a5(){const e=ie(),t=zs(),[n,r]=m.useState(!1),a=m.useRef(null),{data:i}=pe({queryKey:["config"],queryFn:()=>Ga.get(),staleTime:3e4}),l=V({mutationFn:d=>{var p;const x=(p=i==null?void 0:i.profiles)==null?void 0:p.find(y=>y.name===d);if(!x)throw new Error("Profile not found");return Ga.update({activeProfile:x.name,environment:x.environment,baseUrl:x.baseUrl,browsers:x.browsers,...x.headless!==void 0?{headless:x.headless}:{}})},onSuccess:()=>{e.invalidateQueries({queryKey:["config"]}),r(!1)}});m.useEffect(()=>{const d=x=>{a.current&&!a.current.contains(x.target)&&r(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]);const o=(i==null?void 0:i.profiles)??[];if(o.length===0)return null;const c=(i==null?void 0:i.activeProfile)??(i==null?void 0:i.environment)??"env";return s.jsxs("div",{ref:a,className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>r(d=>!d),className:"flex items-center gap-1.5 text-xs border border-border rounded-lg px-2.5 py-1.5 text-content-secondary hover:bg-surface-inset transition-colors",children:[s.jsx(nn,{size:12,className:"text-accent flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline max-w-[100px] truncate",children:c}),s.jsx(Nt,{size:11,className:"text-content-tertiary"})]}),n&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface border border-border rounded-xl shadow-elevated z-50 overflow-hidden",children:[s.jsx("div",{className:"px-3 py-2 border-b border-border",children:s.jsx("p",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Environment Profiles"})}),s.jsx("div",{className:"py-1",children:o.map(d=>s.jsxs("button",{type:"button",onClick:()=>l.mutate(d.name),className:P("w-full text-left px-3 py-2 text-xs hover:bg-surface-inset transition-colors flex items-center justify-between gap-2",(i==null?void 0:i.activeProfile)===d.name&&"text-accent font-semibold"),children:[s.jsx("span",{className:"truncate",children:d.name}),s.jsx("span",{className:"text-[9px] text-content-tertiary flex-shrink-0",children:d.environment})]},d.name))}),s.jsx("div",{className:"border-t border-border px-3 py-2",children:s.jsxs("button",{type:"button",onClick:()=>{r(!1),t("/settings#profiles")},className:"flex items-center gap-1 text-[10px] text-content-tertiary hover:text-accent transition-colors",children:[s.jsx(Va,{size:10})," Manage profiles"]})})]})]})}const i5={anthropic:"Anthropic",bedrock:"Bedrock",openai:"OpenAI",google:"Google","azure-openai":"Azure OpenAI",ollama:"Ollama",unknown:"AI"};function l5({title:e,onMenuClick:t}){const{data:n}=pe({queryKey:["ai-provider"],queryFn:()=>Ga.getAiProvider(),staleTime:6e4,retry:!1}),{panelOpen:r}=Uc(),{data:a}=Lm(),{theme:i,toggle:l}=$w(),o=i5[(n==null?void 0:n.provider)??""]??(n==null?void 0:n.provider)??"...",c=(n==null?void 0:n.model)??"...",d=((a==null?void 0:a.modified.length)??0)+((a==null?void 0:a.added.length)??0)+((a==null?void 0:a.deleted.length)??0)+((a==null?void 0:a.untracked.length)??0);return s.jsxs("header",{className:"h-14 bg-surface border-b border-border flex items-center px-5 gap-3 flex-shrink-0",children:[s.jsx("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-inset text-content-tertiary lg:hidden transition-colors","aria-label":"Toggle sidebar",children:s.jsx(nw,{size:18})}),s.jsx("h1",{className:"text-sm font-semibold text-content tracking-tight flex-1",children:e}),n&&s.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 text-xs bg-surface-inset border border-border rounded-lg px-3 py-1.5",children:[s.jsx(D2,{size:13,className:"text-accent flex-shrink-0"}),s.jsx("span",{className:"font-medium text-content-secondary",children:o}),s.jsx("span",{className:"text-content-tertiary/50",children:"/"}),s.jsx("span",{className:"text-content-tertiary truncate max-w-[140px]",children:c})]}),s.jsx(a5,{}),s.jsx(r5,{}),s.jsx("button",{type:"button",onClick:l,className:P("p-2 rounded-lg transition-all duration-200",i==="dark"?"bg-surface-inset text-amber-400 hover:bg-surface-overlay":"text-content-tertiary hover:bg-surface-inset hover:text-content-secondary"),"aria-label":i==="dark"?"Switch to light mode":"Switch to dark mode",title:i==="dark"?"Light mode":"Dark mode",children:i==="dark"?s.jsx(gw,{size:16}):s.jsx(aw,{size:16})}),s.jsxs("button",{type:"button",onClick:()=>Re.togglePanel(),className:P("relative flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200",r?"bg-accent-muted text-accent border border-accent/20":"text-content-tertiary hover:bg-surface-inset hover:text-content-secondary border border-transparent"),"aria-label":"Toggle Git panel",title:"Git Control Center",children:[s.jsx(Lr,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:"Git"}),d>0&&s.jsx("span",{className:"absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-amber-500 text-white text-[9px] font-bold flex items-center justify-center ring-2 ring-surface",children:d>9?"9+":d})]})]})}function te({variant:e="primary",size:t="md",loading:n=!1,children:r,className:a,disabled:i,...l}){return s.jsxs("button",{...l,disabled:i||n,className:P("inline-flex items-center justify-center gap-2 font-medium rounded-lg transition-all duration-150","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1",{"bg-gradient-to-b from-accent to-accent-dark text-white shadow-sm hover:shadow-md hover:brightness-110 focus-visible:ring-accent":e==="primary","bg-surface border border-border text-content-secondary hover:bg-surface-inset hover:text-content hover:border-border-strong focus-visible:ring-accent":e==="secondary","text-content-secondary hover:bg-surface-inset hover:text-content focus-visible:ring-accent/40":e==="ghost","bg-gradient-to-b from-red-500 to-red-600 text-white shadow-sm hover:shadow-md hover:brightness-110 focus-visible:ring-red-500":e==="danger","px-2.5 py-1.5 text-xs gap-1.5":t==="sm","px-4 py-2 text-sm":t==="md","px-5 py-2.5 text-sm":t==="lg","opacity-40 cursor-not-allowed pointer-events-none":i||n},a),children:[n&&s.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-20",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),s.jsx("path",{className:"opacity-80",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),r]})}function Qr(e){const t=m.useRef(null),n=m.useRef(e);n.current=e;const r=m.useCallback(()=>{var i;if(((i=t.current)==null?void 0:i.readyState)===WebSocket.OPEN)return;const a=new WebSocket(Pw);t.current=a,a.onmessage=l=>{try{const o=JSON.parse(l.data),c=n.current[o.event];c&&c(o.data)}catch{}},a.onclose=()=>{setTimeout(r,3e3)},a.onerror=()=>{a.close()}},[]);m.useEffect(()=>(r(),()=>{var a;(a=t.current)==null||a.close()}),[r])}let oc={isRunning:!1,runId:null,currentBrowser:null,currentCase:null,currentStep:null,completed:null,error:null,activeCases:new Map};const px=new Set;function Vy(){px.forEach(e=>e())}function na(e){oc=e(oc),Vy()}const Td={subscribe(e){return px.add(e),()=>{px.delete(e)}},getSnapshot(){return oc},reset(){oc={isRunning:!1,runId:null,currentBrowser:null,currentCase:null,currentStep:null,completed:null,error:null,activeCases:new Map},Vy()}};function _m(){const e=m.useSyncExternalStore(Td.subscribe,Td.getSnapshot),t=m.useCallback(c=>{const d=c;na(()=>({isRunning:!0,runId:d.runId,currentBrowser:null,currentCase:null,currentStep:null,completed:null,error:null,activeCases:new Map}))},[]),n=m.useCallback(c=>{const d=c;na(x=>{const p=new Map(x.activeCases);return p.set(d.caseId,d.caseName),{...x,isRunning:!0,currentBrowser:d.browser??x.currentBrowser,currentCase:d,currentStep:null,activeCases:p}})},[]),r=m.useCallback(c=>{na(d=>({...d,isRunning:!0,currentStep:c}))},[]),a=m.useCallback(c=>{na(d=>({...d,isRunning:!1,completed:c,currentCase:null,currentStep:null}))},[]),i=m.useCallback(c=>{const d=c;na(x=>({...x,isRunning:!1,error:d.error}))},[]),l=m.useCallback(()=>{na(c=>({...c,isRunning:!1,completed:c.completed??{runId:c.runId??"",passed:0,failed:0,skipped:0,duration:0},currentCase:null,currentStep:null}))},[]);Qr({"run:start":t,"run:case":n,"run:step":r,"run:complete":a,"run:error":i,"run:stopped":l});const o=m.useCallback(()=>{Td.reset()},[]);return{...e,reset:o}}function Ad(e,t){Qr({[e]:t})}function qp({data:e,maxHeight:t=32}){const n=Math.max(...e.map(r=>r.value),1);return s.jsx("div",{className:"flex items-end gap-[3px]",style:{height:t},children:e.map((r,a)=>s.jsx("div",{className:P("w-[6px] rounded-full transition-all duration-500",r.color),style:{height:`${Math.max(r.value/n*100,6)}%`}},a))})}function o5({rate:e,hasData:t=!1,size:n=80}){const a=(n-6)/2,i=2*Math.PI*a,l=i-e/100*i,o=t?"#ef4444":"var(--color-border)";return s.jsxs("div",{className:"relative",style:{width:n,height:n},children:[s.jsxs("svg",{width:n,height:n,className:"-rotate-90",children:[s.jsx("circle",{cx:n/2,cy:n/2,r:a,fill:"none",stroke:o,strokeWidth:6}),s.jsx("circle",{cx:n/2,cy:n/2,r:a,fill:"none",stroke:"#10b981",strokeWidth:6,strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:l,className:"transition-all duration-1000 ease-out"})]}),s.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:s.jsxs("span",{className:"text-lg font-bold text-content tabular-nums",children:[e,"%"]})})]})}function c5({status:e}){const t={passed:"bg-emerald-500",failed:"bg-red-500",partial:"bg-amber-500",running:"bg-blue-500 animate-pulse",skipped:"bg-slate-400"};return s.jsx("span",{className:P("w-2 h-2 rounded-full flex-shrink-0",t[e]??"bg-slate-400")})}function d5(e,t){return e.filter(n=>{var r;return(r=n.suiteIds)==null?void 0:r.includes(t)}).slice(-7).map(n=>({value:n.totalTests>0?Math.round(n.passed/n.totalTests*100):0,color:n.failed>0?"bg-red-400":"bg-emerald-400"}))}function u5(){const e=zs(),{data:t=[],isLoading:n}=pe({queryKey:["reports"],queryFn:()=>rc.list(20)}),{data:r=[],isLoading:a}=pe({queryKey:["suites"],queryFn:()=>Kr.list()}),{data:i}=pe({queryKey:["healing-stats"],queryFn:()=>Ws.stats(),staleTime:3e4,retry:!1}),l=_m(),o=n||a,c=t[0],d=r.reduce((k,N)=>k+(N.caseCount??0),0),x=r.filter(k=>(k.type??"ui")==="ui"),p=r.filter(k=>(k.type??"ui")==="api"),y=x.reduce((k,N)=>k+(N.caseCount??0),0),b=p.reduce((k,N)=>k+(N.caseCount??0),0),f=t.reduce((k,N)=>k+N.passed,0),v=t.reduce((k,N)=>k+N.failed,0),w=t.reduce((k,N)=>k+N.skipped,0),h=f+v>0?Math.round(f/(f+v)*100):0,u=f+v+w,g=t.filter(k=>k.duration).length>0?Math.round(t.filter(k=>k.duration).reduce((k,N)=>k+(N.duration??0),0)/t.filter(k=>k.duration).length/1e3):0,j=[...t].reverse().map(k=>({value:k.passed+k.failed+k.skipped,color:k.status==="passed"?"bg-emerald-400":k.status==="failed"?"bg-red-400":"bg-amber-400"}));return o?s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex-shrink-0 px-8 pt-6 pb-4",children:[s.jsx("div",{className:"h-7 w-48 rounded-lg skeleton-shimmer"}),s.jsx("div",{className:"h-4 w-72 rounded-lg skeleton-shimmer mt-2"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-8 pb-8",children:[s.jsx("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[1,2,3,4].map(k=>s.jsx("div",{className:"h-28 rounded-2xl skeleton-shimmer"},k))}),s.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(k=>s.jsx("div",{className:"h-64 rounded-2xl skeleton-shimmer"},k))})]})]}):s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex-shrink-0 px-8 pt-6 pb-4 flex items-end justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-content tracking-tight",children:"Dashboard"}),s.jsx("p",{className:"text-sm text-content-tertiary mt-0.5",children:"Test automation health at a glance"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(te,{size:"sm",variant:"secondary",onClick:()=>e("/run"),children:[s.jsx(Dt,{size:13})," Run Tests"]}),s.jsxs(te,{size:"sm",onClick:()=>e("/story"),children:[s.jsx(wt,{size:13})," Generate"]})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-8 pb-8 space-y-5",children:[l.isRunning&&s.jsx("div",{className:"rounded-2xl border border-accent/25 bg-gradient-to-r from-accent/[0.06] via-accent/[0.03] to-transparent p-4 animate-fade-in",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative w-8 h-8 flex-shrink-0",children:[s.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-accent/20"}),s.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm font-semibold text-content",children:"Run in progress..."}),l.currentCase&&s.jsxs("p",{className:"text-xs text-content-secondary truncate mt-0.5",children:[l.currentCase.caseName,l.currentStep&&` › ${l.currentStep.instruction}`]})]}),s.jsxs(te,{size:"sm",variant:"ghost",onClick:()=>e("/run"),children:["View ",s.jsx(fr,{size:12})]})]})}),l.completed&&!l.isRunning&&(()=>{const k=l.completed,N=k.failed===0&&k.passed>0,E=k.failed>0,R=N?{border:"border-emerald-200/50",bg:"bg-gradient-to-r from-emerald-50/80 to-transparent",icon:"text-emerald-500",title:"text-emerald-800",subtitle:"text-emerald-600",label:"All tests passed"}:E?{border:"border-red-200/50",bg:"bg-gradient-to-r from-red-50/80 to-transparent",icon:"text-red-500",title:"text-red-800",subtitle:"text-red-600",label:"Completed with failures"}:{border:"border-amber-200/50",bg:"bg-gradient-to-r from-amber-50/80 to-transparent",icon:"text-amber-500",title:"text-amber-800",subtitle:"text-amber-600",label:"Run completed"},L=N?we:E?tt:ts;return s.jsx("div",{className:P("rounded-2xl border p-4 animate-fade-in",R.border,R.bg),children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(L,{size:20,className:P(R.icon,"flex-shrink-0")}),s.jsxs("div",{children:[s.jsx("p",{className:P("text-sm font-semibold",R.title),children:R.label}),s.jsxs("p",{className:P("text-xs mt-0.5",R.subtitle),children:[k.passed," passed / ",k.failed," failed / ",k.skipped," skipped"]})]})]}),s.jsx(te,{variant:"secondary",size:"sm",onClick:()=>e("/reports"),children:"View Report"})]})})})(),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-indigo-50 border border-indigo-100 flex items-center justify-center",children:s.jsx(qr,{size:18,className:"text-indigo-500"})}),s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Coverage"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"text-3xl font-extrabold text-content tabular-nums tracking-tight",children:r.length}),s.jsx("p",{className:"text-xs text-content-tertiary mt-0.5",children:"test suites"})]}),s.jsxs("div",{className:"mt-3 pt-3 border-t border-border-muted flex items-center gap-4",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(gr,{size:11,className:"text-blue-500"}),s.jsxs("span",{className:"text-[11px] text-content-secondary font-medium",children:[x.length," UI"]}),s.jsxs("span",{className:"text-[10px] text-content-tertiary",children:["(",y,")"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(cw,{size:11,className:"text-purple-500"}),s.jsxs("span",{className:"text-[11px] text-content-secondary font-medium",children:[p.length," API"]}),s.jsxs("span",{className:"text-[10px] text-content-tertiary",children:["(",b,")"]})]})]})]}),s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col items-center justify-center",children:[s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider mb-3",children:"Pass Rate"}),s.jsx(o5,{rate:t.length>0?h:0,hasData:f+v>0}),s.jsx("p",{className:"text-[11px] text-content-tertiary mt-2",children:f+v>0?`${f} of ${f+v} cases passed`:"no runs yet"})]}),s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-50 border border-teal-100 flex items-center justify-center",children:s.jsx(M2,{size:18,className:"text-teal-500"})}),s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Execution"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"text-3xl font-extrabold text-content tabular-nums tracking-tight",children:u}),s.jsx("p",{className:"text-xs text-content-tertiary mt-0.5",children:"tests executed"})]}),s.jsxs("div",{className:"mt-3 pt-3 border-t border-border-muted grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(we,{size:10,className:"text-emerald-500"}),s.jsx("span",{className:"text-[11px] font-semibold text-emerald-600 tabular-nums",children:f})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(tt,{size:10,className:"text-red-500"}),s.jsx("span",{className:"text-[11px] font-semibold text-red-500 tabular-nums",children:v})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Lc,{size:10,className:"text-content-tertiary"}),s.jsx("span",{className:"text-[11px] font-semibold text-content-tertiary tabular-nums",children:w})]})]})]}),s.jsxs("div",{className:"rounded-2xl border border-border bg-surface p-5 flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-50 border border-amber-100 flex items-center justify-center",children:s.jsx(qe,{size:18,className:"text-amber-500"})}),s.jsx("span",{className:"text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:"Insights"})]}),s.jsxs("div",{className:"mt-4 space-y-2.5",children:[s.jsx("div",{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Avg Duration"}),s.jsx("span",{className:"text-sm font-bold text-content tabular-nums",children:g>0?`${g}s`:"—"})]})}),s.jsx("div",{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Self-Healed"}),s.jsx("span",{className:"text-sm font-bold text-emerald-600 tabular-nums",children:(i==null?void 0:i.accepted)??0})]})}),s.jsx("div",{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Pending Review"}),s.jsx("span",{className:P("text-sm font-bold tabular-nums",((i==null?void 0:i.pending)??0)>0?"text-amber-500":"text-content-tertiary"),children:(i==null?void 0:i.pending)??0})]})})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2 rounded-2xl border border-border bg-surface overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-accent-muted flex items-center justify-center",children:s.jsx(vw,{size:14,className:"text-accent"})}),s.jsx("h2",{className:"text-sm font-semibold text-content",children:"Recent Runs"})]}),t.length>0&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(qp,{data:j,maxHeight:24}),s.jsxs("button",{onClick:()=>e("/reports"),className:"text-xs text-accent font-medium hover:underline flex items-center gap-0.5",children:["View all ",s.jsx(fr,{size:11})]})]})]}),t.length===0?s.jsxs("div",{className:"px-5 py-12 text-center",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-inset flex items-center justify-center mx-auto mb-3",children:s.jsx(hs,{size:20,className:"text-content-tertiary"})}),s.jsx("p",{className:"text-sm font-medium text-content-secondary",children:"No runs yet"}),s.jsx("p",{className:"text-xs text-content-tertiary mt-1 mb-4",children:"Execute your first test run to see results here"}),s.jsxs(te,{size:"sm",onClick:()=>e("/run"),children:[s.jsx(Dt,{size:12})," Start a Run"]})]}):s.jsxs("div",{className:"divide-y divide-border-muted",children:[s.jsxs("div",{className:"grid grid-cols-[1fr_100px_140px_80px_60px] px-5 py-2 text-[10px] font-semibold text-content-tertiary uppercase tracking-wider",children:[s.jsx("span",{children:"Run ID"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"Results"}),s.jsx("span",{children:"Duration"}),s.jsx("span",{className:"text-right",children:"Time"})]}),t.slice(0,6).map(k=>{const N=k.passed+k.failed+k.skipped,E=N>0?Math.round(k.passed/N*100):0;return s.jsxs("div",{onClick:()=>e("/reports"),className:"grid grid-cols-[1fr_100px_140px_80px_60px] items-center px-5 py-3 hover:bg-surface-inset cursor-pointer transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(c5,{status:k.status}),s.jsx("span",{className:"text-xs font-mono text-content-secondary truncate",children:k.runId.slice(0,10)})]}),s.jsx("div",{children:s.jsx("span",{className:P("text-[10px] font-semibold px-2 py-0.5 rounded-md uppercase tracking-wide",k.status==="passed"?"bg-emerald-50 text-emerald-700":k.status==="failed"?"bg-red-50 text-red-700":"bg-amber-50 text-amber-700"),children:k.status})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 h-1.5 bg-surface-inset rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-emerald-400 rounded-full transition-all duration-500",style:{width:`${E}%`}})}),s.jsxs("span",{className:"text-[11px] text-content-secondary tabular-nums w-12 text-right",children:[k.passed,"/",N]})]}),s.jsx("span",{className:"text-[11px] text-content-tertiary tabular-nums",children:k.duration?`${(k.duration/1e3).toFixed(1)}s`:"—"}),s.jsx("span",{className:"text-[10px] text-content-tertiary text-right",children:lc(new Date(k.startedAt),{addSuffix:!1})})]},k.runId)})]})]}),s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"rounded-2xl border border-border bg-surface overflow-hidden flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-indigo-50 border border-indigo-100 flex items-center justify-center",children:s.jsx(dl,{size:14,className:"text-indigo-500"})}),s.jsx("h2",{className:"text-sm font-semibold text-content",children:"Test Suites"})]}),s.jsxs("span",{className:"text-[10px] font-semibold text-content-tertiary bg-surface-inset px-2 py-0.5 rounded-md",children:[d," cases"]})]}),r.length===0?s.jsxs("div",{className:"px-5 py-8 text-center",children:[s.jsx("p",{className:"text-sm text-content-tertiary mb-3",children:"No suites yet"}),s.jsx(te,{size:"sm",onClick:()=>e("/tests"),children:"Create Suite"})]}):s.jsx("ul",{className:"divide-y divide-border-muted max-h-[200px] overflow-y-auto",children:r.map(k=>s.jsxs("li",{onClick:()=>e("/tests"),className:"flex items-center justify-between px-5 py-2.5 hover:bg-surface-inset cursor-pointer transition-colors group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-sm text-content font-medium truncate",children:k.name}),s.jsx("span",{className:P("text-[9px] px-1.5 py-0.5 rounded font-bold uppercase flex-shrink-0",(k.type??"ui")==="api"?"bg-purple-50 text-purple-600":"bg-blue-50 text-blue-600"),children:(k.type??"ui").toUpperCase()})]}),s.jsxs("p",{className:"text-[11px] text-content-tertiary mt-0.5",children:[k.caseCount??0," cases"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(qp,{data:d5(t,k.id),maxHeight:24}),s.jsx(fr,{size:13,className:"text-content-tertiary opacity-0 group-hover:opacity-100 transition-opacity"})]})]},k.id))})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{label:"Smart Tests",icon:wt,to:"/story",gradient:"from-violet-500 to-indigo-600"},{label:"Self-Healing",icon:tc,to:"/healing",gradient:"from-rose-500 to-pink-600"},{label:"Variables",icon:Om,to:"/variables",gradient:"from-teal-500 to-cyan-600"},{label:"Reports",icon:hs,to:"/reports",gradient:"from-amber-500 to-orange-600"}].map(({label:k,icon:N,to:E,gradient:R})=>s.jsxs("button",{type:"button",onClick:()=>e(E),className:"group relative overflow-hidden rounded-xl border border-border bg-surface px-3.5 py-3 hover:border-border-strong hover:shadow-card transition-all duration-200 flex items-center gap-3",children:[s.jsx("div",{className:P("w-8 h-8 rounded-lg bg-gradient-to-br flex items-center justify-center flex-shrink-0",R),children:s.jsx(N,{size:14,className:"text-white"})}),s.jsx("p",{className:"text-xs font-semibold text-content group-hover:text-accent transition-colors",children:k})]},E))})]})]}),c&&s.jsx("div",{className:"rounded-2xl border border-border bg-surface px-6 py-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:P("w-10 h-10 rounded-xl flex items-center justify-center",c.status==="passed"?"bg-emerald-50 border border-emerald-100":c.status==="failed"?"bg-red-50 border border-red-100":"bg-amber-50 border border-amber-100"),children:c.status==="passed"?s.jsx(we,{size:18,className:"text-emerald-500"}):c.status==="failed"?s.jsx(ts,{size:18,className:"text-red-500"}):s.jsx(Ap,{size:18,className:"text-amber-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-semibold text-content-secondary uppercase tracking-wider",children:"Last Run"}),s.jsxs("p",{className:"text-sm font-bold text-content mt-0.5",children:[c.passed," passed, ",c.failed," failed",c.skipped>0&&`, ${c.skipped} skipped`]})]})]}),s.jsxs("div",{className:"flex items-center gap-6 text-xs text-content-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Br,{size:12}),s.jsx("span",{children:lc(new Date(c.startedAt),{addSuffix:!0})})]}),c.duration&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ap,{size:12}),s.jsxs("span",{children:[(c.duration/1e3).toFixed(1),"s"]})]}),s.jsx("div",{className:"flex items-center gap-1.5 font-mono",children:s.jsxs("span",{children:["#",c.runId.slice(0,8)]})}),s.jsxs(te,{size:"sm",variant:"ghost",onClick:()=>e("/reports"),children:["Details ",s.jsx(fr,{size:11})]})]})]})})]})]})}function Ms({open:e,title:t="Confirm Delete",message:n,confirmLabel:r="Delete",onConfirm:a,onCancel:i}){return m.useEffect(()=>{if(!e)return;const l=o=>{o.key==="Escape"&&i(),o.key==="Enter"&&(o.preventDefault(),a())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,i]),e?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-fade-in",children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),s.jsxs("div",{className:"relative bg-surface rounded-2xl shadow-modal w-full max-w-sm mx-4 p-6 animate-scale-in border border-border",children:[s.jsxs("div",{className:"flex items-start gap-3.5",children:[s.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-xl bg-red-50 border border-red-200/50 flex items-center justify-center",children:s.jsx(ts,{size:18,className:"text-red-500"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-content",children:t}),s.jsx("p",{className:"mt-1 text-sm text-content-secondary leading-relaxed",children:n})]})]}),s.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2.5",children:[s.jsx(te,{variant:"secondary",size:"sm",onClick:i,children:"Cancel"}),s.jsx(te,{variant:"danger",size:"sm",onClick:a,children:r})]})]})]}):null}function Ts(){const[e,t]=m.useState({open:!1,message:"",onConfirm:()=>{}}),n=m.useCallback((i,l)=>{t({open:!0,message:i,onConfirm:l})},[]),r=m.useCallback(()=>{t(i=>({...i,open:!1}))},[]),a=m.useCallback(()=>{e.onConfirm(),t(i=>({...i,open:!1}))},[e.onConfirm]);return{modalProps:{open:e.open,message:e.message,onConfirm:a,onCancel:r},confirmDelete:n}}const x5=[{id:"all",label:"All"},{id:"auth",label:"Auth"},{id:"crud",label:"CRUD"},{id:"navigation",label:"Navigation"},{id:"form",label:"Form"},{id:"api",label:"API"}],m5={auth:"bg-violet-50 text-violet-600",crud:"bg-blue-50 text-blue-600",navigation:"bg-teal-50 text-teal-600",form:"bg-orange-50 text-orange-600",api:"bg-purple-50 text-purple-600"};function h5({open:e,onClose:t,suiteId:n,onCreated:r}){const[a,i]=m.useState("all"),[l,o]=m.useState(null),{data:c=[],isLoading:d}=pe({queryKey:["templates"],queryFn:()=>Ow.list(),enabled:e}),x=V({mutationFn:b=>Wn.create(n,{name:b.name,description:b.description,steps:b.steps.map((f,v)=>({...f,id:crypto.randomUUID(),order:v+1}))}),onSuccess:()=>{O.success("Test case created from template"),r(),t()},onError:b=>{O.error(b.message),o(null)}}),p=b=>{o(b.id),x.mutate(b)},y=a==="all"?c:c.filter(b=>b.category===a);return e?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t,children:s.jsxs("div",{className:"bg-surface rounded-2xl border border-border shadow-modal w-full max-w-2xl mx-4 overflow-hidden flex flex-col max-h-[85vh]",onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border flex-shrink-0",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-bold text-content",children:"Test Case Templates"}),s.jsx("p",{className:"text-[11px] text-content-tertiary mt-0.5",children:"Start from a pre-built template"})]}),s.jsx("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg text-content-tertiary hover:bg-surface-inset hover:text-content transition-colors",children:s.jsx(be,{size:14})})]}),s.jsx("div",{className:"flex gap-1 px-5 py-2.5 border-b border-border flex-shrink-0 overflow-x-auto",children:x5.map(b=>s.jsx("button",{type:"button",onClick:()=>i(b.id),className:P("px-3 py-1.5 rounded-lg text-xs font-semibold transition-colors flex-shrink-0",a===b.id?"bg-accent text-white":"text-content-secondary hover:bg-surface-inset"),children:b.label},b.id))}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 min-h-0",children:d?s.jsx("div",{className:"grid grid-cols-2 gap-3",children:[1,2,3,4].map(b=>s.jsx("div",{className:"h-28 rounded-xl skeleton-shimmer"},b))}):y.length===0?s.jsx("div",{className:"py-12 text-center",children:s.jsx("p",{className:"text-sm text-content-tertiary",children:"No templates in this category"})}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:y.map(b=>s.jsxs("div",{className:"rounded-xl border border-border bg-surface p-4 flex flex-col gap-3 hover:border-border-strong hover:shadow-card transition-all",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-surface-inset flex items-center justify-center flex-shrink-0",children:s.jsx(Ps,{size:13,className:"text-content-secondary"})}),s.jsx("div",{className:"min-w-0",children:s.jsx("p",{className:"text-sm font-bold text-content truncate",children:b.name})})]}),s.jsx("span",{className:P("text-[9px] px-1.5 py-0.5 rounded font-bold uppercase flex-shrink-0",m5[b.category]??"bg-surface-inset text-content-tertiary"),children:b.category})]}),s.jsx("p",{className:"text-xs text-content-secondary leading-relaxed",children:b.description}),s.jsxs("div",{className:"flex items-center justify-between mt-auto",children:[s.jsxs("span",{className:"text-[10px] text-content-tertiary",children:[b.steps.length," step",b.steps.length!==1?"s":""]}),s.jsx("button",{type:"button",onClick:()=>p(b),disabled:x.isPending,className:P("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold transition-colors",l===b.id?"bg-emerald-50 text-emerald-600 border border-emerald-200":"bg-accent/10 text-accent hover:bg-accent/20",x.isPending&&"opacity-50 cursor-not-allowed"),children:l===b.id?s.jsxs(s.Fragment,{children:[s.jsx(we,{size:11})," Creating..."]}):"Use Template"})]})]},b.id))})})]})}):null}function Gy(){return pe({queryKey:["suites"],queryFn:()=>Kr.list()})}function p5(){const e=ie();return V({mutationFn:Kr.create,onSuccess:()=>{e.invalidateQueries({queryKey:["suites"]}),O.success("Suite created")},onError:t=>O.error(t.message)})}function Qy(){const e=ie();return V({mutationFn:({id:t,data:n})=>Kr.update(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["suites"]}),O.success("Suite updated")},onError:t=>O.error(t.message)})}function f5(){const e=ie();return V({mutationFn:Kr.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["suites"]}),O.success("Suite deleted")},onError:t=>O.error(t.message)})}function g5(e){return pe({queryKey:["cases",e],queryFn:()=>Wn.list(e),enabled:!!e})}function y5(e,t){return pe({queryKey:["cases",e,t],queryFn:()=>Wn.get(e,t),enabled:!!e&&!!t})}function Hp(e){const t=ie();return V({mutationFn:n=>Wn.create(e,n),onSuccess:()=>{t.invalidateQueries({queryKey:["cases",e]}),O.success("Test case created")},onError:n=>O.error(n.message)})}function b5(e){const t=ie();return V({mutationFn:({caseId:n,data:r})=>Wn.update(e,n,r),onSuccess:(n,{caseId:r})=>{t.invalidateQueries({queryKey:["cases",e]}),t.invalidateQueries({queryKey:["cases",e,r]}),O.success("Test case updated")},onError:n=>O.error(n.message)})}function v5(e){const t=ie();return V({mutationFn:n=>Wn.delete(e,n),onSuccess:()=>{t.invalidateQueries({queryKey:["cases",e]}),O.success("Test case deleted")},onError:n=>O.error(n.message)})}function j5(e,t){const n=ie();return V({mutationFn:r=>Wr.add(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function N5(e,t){const n=ie();return V({mutationFn:({stepId:r,instruction:a,timeout:i,stepType:l,retries:o,mockUrl:c,mockResponse:d,mockStatus:x,runAudit:p,soft:y,visualCheck:b})=>Wr.update(e,t,r,{instruction:a,timeout:i,stepType:l,retries:o,mockUrl:c,mockResponse:d,mockStatus:x,runAudit:p,soft:y,visualCheck:b}),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function w5(e,t){const n=ie();return V({mutationFn:r=>Wr.reorder(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function k5(e,t){const n=ie();return V({mutationFn:r=>Wr.delete(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]})},onError:r=>O.error(r.message)})}function S5(e,t){const n=ie();return V({mutationFn:r=>Wr.generate(e,t,r),onSuccess:()=>{n.invalidateQueries({queryKey:["cases",e,t]}),O.success("Code generated")},onError:r=>O.error(r.message)})}function C5(e,t){const n=ie();return V({mutationFn:()=>Wr.generateAll(e,t),onSuccess:r=>{n.invalidateQueries({queryKey:["cases",e,t]}),O.success(`Generated code for ${r.generated} step(s)`)},onError:r=>O.error(r.message)})}const xl=new Map,fx=new Set;function Yy(){for(const e of fx)e()}function Od(){return"all"}function Dd(e){return`suite:${e}`}function Id(e,t){return`case:${e}:${t}`}function Fd(e,t){xl.set(e,{op:t,startedAt:Date.now()}),Yy()}function Ld(e){xl.delete(e),Yy()}function _d(e){var t;return((t=xl.get(e))==null?void 0:t.op)??null}function E5(){const e=new Map,t=new Map;let n=null;for(const[r,a]of xl)r==="all"?n=a.op:r.startsWith("suite:")?e.set(r.slice(6),a.op):r.startsWith("case:")&&t.set(r.slice(5),a.op);return{allOp:n,busySuites:e,busyCases:t,activeCount:xl.size}}function P5(e){return fx.add(e),()=>{fx.delete(e)}}const st={startAll:e=>Fd(Od(),e),finishAll:()=>Ld(Od()),startSuite:(e,t)=>Fd(Dd(e),t),finishSuite:e=>Ld(Dd(e)),startCase:(e,t,n)=>Fd(Id(e,t),n),finishCase:(e,t)=>Ld(Id(e,t)),isAllBusy:()=>_d(Od()),isSuiteBusy:e=>_d(Dd(e)),isCaseBusy:(e,t)=>_d(Id(e,t)),getSnapshot:E5,subscribe:P5};function zl(e,t){var n;if(e.failed>0){const r=e.results.filter(a=>a.action==="failed");O.error(`${t}: ${e.failed} failed — ${((n=r[0])==null?void 0:n.error)??"Unknown error"}`)}else if(e.created>0||e.synced>0){const r=[];e.created>0&&r.push(`${e.created} created`),e.synced>0&&r.push(`${e.synced} synced`),e.skipped>0&&r.push(`${e.skipped} skipped`),O.success(`Xray: ${r.join(", ")}`)}else e.skipped>0&&O.success(`Xray: ${e.skipped} already up to date`)}function R5(){return pe({queryKey:["xray","status"],queryFn:()=>Gr.status(),retry:1,staleTime:1e4})}function Jy(e){return pe({queryKey:["xray","status",e],queryFn:()=>Gr.suiteStatus(e),enabled:!!e,retry:1,staleTime:1e4})}function z5(){const e=ie();return V({mutationFn:()=>(st.startAll("create"),Gr.createAll()),onSuccess:t=>{st.finishAll(),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Create in Xray")},onError:t=>{st.finishAll(),O.error(`Xray create failed: ${t.message}`)}})}function Xy(){const e=ie();return V({mutationFn:t=>(st.startSuite(t,"create"),Gr.createSuite(t)),onSuccess:(t,n)=>{st.finishSuite(n),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Create Suite")},onError:(t,n)=>{st.finishSuite(n),O.error(`Xray create failed: ${t.message}`)}})}function Zy(){const e=ie();return V({mutationFn:({suiteId:t,caseId:n})=>(st.startCase(t,n,"create"),Gr.createCase(t,n)),onSuccess:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Create Case")},onError:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),O.error(`Xray create failed: ${t.message}`)}})}function M5(){const e=ie();return V({mutationFn:t=>(st.startSuite(t,"sync"),Gr.syncSuite(t)),onSuccess:(t,n)=>{st.finishSuite(n),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Sync Suite")},onError:(t,n)=>{st.finishSuite(n),O.error(`Xray sync failed: ${t.message}`)}})}function eb(){const e=ie();return V({mutationFn:({suiteId:t,caseId:n})=>(st.startCase(t,n,"sync"),Gr.syncCase(t,n)),onSuccess:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),e.invalidateQueries({queryKey:["xray"]}),zl(t,"Sync Case")},onError:(t,{suiteId:n,caseId:r})=>{st.finishCase(n,r),O.error(`Xray sync failed: ${t.message}`)}})}function $m({code:e,maxLines:t,className:n}){const[r,a]=m.useState(!1),i=async()=>{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)},l=!e.trim();return s.jsxs("div",{className:P("relative rounded-xl bg-[#0d1117] text-slate-300 ring-1 ring-white/5 overflow-hidden",n),children:[!l&&s.jsx("button",{type:"button",onClick:()=>void i(),className:P("absolute top-2.5 right-2.5 p-1.5 rounded-md transition-all duration-150",r?"bg-emerald-500/20 text-emerald-400":"text-slate-500 hover:text-slate-300 hover:bg-white/10"),title:"Copy code",children:r?s.jsx(Oe,{size:13}):s.jsx(Rm,{size:13})}),s.jsx("pre",{className:P("p-4 text-xs font-mono leading-relaxed overflow-x-auto",t&&`line-clamp-${t}`),style:t?{maxHeight:`${t*1.5}rem`,overflow:"auto"}:void 0,children:s.jsx("code",{children:l?"// No code generated yet":e})})]})}const T5={"not-created":{bg:"bg-surface-inset",text:"text-content-tertiary",dot:"bg-content-tertiary",border:"border-border",label:"Not Created"},created:{bg:"bg-emerald-50",text:"text-emerald-700",dot:"bg-emerald-500",border:"border-emerald-200/60",label:"Created"},synced:{bg:"bg-emerald-50/60",text:"text-emerald-600",dot:"bg-emerald-400",border:"border-emerald-200/60",label:"Synced"},"update-pending":{bg:"bg-amber-50",text:"text-amber-700",dot:"bg-amber-500",border:"border-amber-200/60",label:"Update Pending"}};function Um({status:e,xrayKey:t}){const n=T5[e];return s.jsxs("span",{className:P("inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md text-[10px] font-semibold whitespace-nowrap border tracking-wide",n.bg,n.text,n.border),children:[s.jsx("span",{className:P("w-1.5 h-1.5 rounded-full flex-shrink-0",n.dot)}),n.label,t&&s.jsxs("span",{className:"text-[9px] opacity-60 truncate max-w-[80px]",title:t,children:["(",t,")"]})]})}const A5={"not-created":{icon:Dm,label:"Push to Xray",title:"Create in Xray",btnClass:"bg-gradient-to-b from-emerald-500 to-emerald-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-emerald-600",iconHover:"hover:bg-emerald-50"},"update-pending":{icon:Am,label:"Sync Xray",title:"Sync changes to Xray",btnClass:"bg-gradient-to-b from-amber-500 to-amber-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-amber-500",iconHover:"hover:bg-amber-50"},created:{icon:we,label:"Synced with Xray",title:"Up to date -- click to re-sync",btnClass:"bg-gradient-to-b from-emerald-500 to-emerald-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-emerald-500",iconHover:"hover:bg-emerald-50"},synced:{icon:we,label:"Synced with Xray",title:"Up to date -- click to re-sync",btnClass:"bg-gradient-to-b from-emerald-500 to-emerald-600 hover:brightness-110 text-white shadow-sm",iconClass:"text-emerald-500",iconHover:"hover:bg-emerald-50"}};function ml({status:e,onClick:t,busy:n=!1,variant:r="full",label:a}){const i=A5[e],l=i.icon,o=a??i.label;return r==="icon"?s.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),t()},title:n?"Processing...":i.title,className:P("p-1.5 rounded-lg transition-all duration-150",n?"cursor-wait opacity-50":P(i.iconClass,i.iconHover)),children:n?s.jsx(ae,{size:14,className:"animate-spin text-accent"}):s.jsx(l,{size:14})}):s.jsxs("button",{type:"button",onClick:()=>t(),title:n?"Processing...":i.title,className:P("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-150",n?"bg-surface-inset text-content-tertiary cursor-wait":i.btnClass),children:[n?s.jsx(ae,{size:13,className:"animate-spin"}):s.jsx(l,{size:13}),n?"Processing...":o]})}function O5(e){return pe({queryKey:["hooks",e],queryFn:()=>Vr.get(e),enabled:!!e})}function D5(e){const t=ie();return V({mutationFn:({hookType:n,instruction:r,order:a})=>Vr.addStep(e,n,{instruction:r,order:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function I5(e){const t=ie();return V({mutationFn:({hookType:n,stepId:r,instruction:a,timeout:i})=>Vr.updateStep(e,n,r,{instruction:a,timeout:i}),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function F5(e){const t=ie();return V({mutationFn:({hookType:n,stepId:r})=>Vr.deleteStep(e,n,r),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function L5(e){const t=ie();return V({mutationFn:({hookType:n,stepIds:r})=>Vr.reorderSteps(e,n,r),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]})},onError:n=>O.error(n.message)})}function _5(e){const t=ie();return V({mutationFn:({hookType:n,stepId:r})=>Vr.generateStep(e,n,r),onSuccess:()=>{t.invalidateQueries({queryKey:["hooks",e]}),O.success("Hook step code generated")},onError:n=>O.error(n.message)})}function $5(e){const t=ie();return V({mutationFn:n=>Vr.generateAll(e,n),onSuccess:n=>{t.invalidateQueries({queryKey:["hooks",e]}),O.success(`Generated code for ${n.generated} hook step(s)`)},onError:n=>O.error(n.message)})}const U5=[{type:"before_all",label:"Before All",desc:"Runs once before all test cases in the suite",icon:s.jsx(K2,{size:16}),color:"text-emerald-600"},{type:"before_each",label:"Before Each",desc:"Runs before every test case",icon:s.jsx(Lc,{size:16}),color:"text-blue-600"},{type:"after_each",label:"After Each",desc:"Runs after every test case",icon:s.jsx(hw,{size:16}),color:"text-amber-600"},{type:"after_all",label:"After All",desc:"Runs once after all test cases in the suite",icon:s.jsx(W2,{size:16}),color:"text-red-500"}];function B5({suiteId:e,open:t,onClose:n}){const{data:r,isLoading:a}=O5(e);return t?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:n}),s.jsxs("div",{className:"relative w-full max-w-3xl max-h-[85vh] bg-surface rounded-xl shadow-2xl flex flex-col overflow-hidden mx-4",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-gradient-to-r from-slate-50 to-white",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-bold text-content",children:"Suite Hooks"}),s.jsx("p",{className:"text-xs text-content-tertiary mt-0.5",children:"Lifecycle hooks run setup/teardown around your test cases (Playwright hooks)"})]}),s.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-surface-inset transition-colors text-content-tertiary hover:text-content-secondary",children:s.jsx(be,{size:18})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:a?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ae,{size:24,className:"animate-spin text-accent"})}):U5.map(i=>s.jsx(q5,{suiteId:e,hookType:i.type,label:i.label,description:i.desc,icon:i.icon,color:i.color,steps:(r==null?void 0:r[i.type])??[]},i.type))})]})]}):null}function q5({suiteId:e,hookType:t,label:n,description:r,icon:a,color:i,steps:l}){const[o,c]=m.useState(l.length>0),[d,x]=m.useState(""),[p,y]=m.useState(""),[b,f]=m.useState(null),[v,w]=m.useState(""),[h,u]=m.useState(new Set),[g,j]=m.useState(null),[k,N]=m.useState(null),E=D5(e),R=F5(e),{modalProps:L,confirmDelete:M}=Ts(),W=L5(e),G=I5(e),ne=_5(e),A=$5(e),Y=()=>{d.trim()&&(E.mutate({hookType:t,instruction:d.trim()}),x(""))},se=_=>{y(_),ne.mutate({hookType:t,stepId:_},{onSettled:()=>y("")})},le=()=>{A.mutate(t)},T=_=>{if(!g||g===_){j(null),N(null);return}const re=l.map(me=>me.id),U=re.indexOf(g),xe=re.indexOf(_);U<0||xe<0||(re.splice(U,1),re.splice(xe,0,g),W.mutate({hookType:t,stepIds:re}),j(null),N(null))},S=_=>{f(_.id),w(_.instruction)},z=_=>{var re;v.trim()&&v!==((re=l.find(U=>U.id===_))==null?void 0:re.instruction)&&G.mutate({hookType:t,stepId:_,instruction:v.trim()}),f(null)},q=l.filter(_=>{var re;return!((re=_.generatedCode)!=null&&re.trim())}).length;return s.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:()=>c(!o),className:"w-full flex items-center gap-3 px-4 py-3 bg-surface-inset hover:bg-surface-inset transition-colors text-left",children:[o?s.jsx(Nt,{size:14,className:"text-content-tertiary"}):s.jsx(Ht,{size:14,className:"text-content-tertiary"}),s.jsx("span",{className:P("flex-shrink-0",i),children:a}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm font-semibold text-content-secondary",children:n}),s.jsx("span",{className:"text-[10px] text-content-tertiary ml-2",children:r})]}),s.jsxs("span",{className:P("text-[10px] font-semibold px-2 py-0.5 rounded-full",l.length>0?"bg-accent/10 text-accent":"bg-slate-200 text-content-tertiary"),children:[l.length," step",l.length!==1?"s":""]})]}),o&&s.jsxs("div",{className:"border-t border-border bg-surface",children:[l.length===0?s.jsx("div",{className:"px-4 py-6 text-center",children:s.jsx("p",{className:"text-xs text-content-tertiary",children:"No steps yet — add one below"})}):s.jsx("div",{className:"divide-y divide-slate-100",children:l.map((_,re)=>s.jsxs("div",{draggable:!0,onDragStart:()=>j(_.id),onDragOver:U=>{U.preventDefault(),N(_.id)},onDragLeave:()=>N(null),onDrop:()=>T(_.id),onDragEnd:()=>{j(null),N(null)},className:P("flex items-start gap-2 px-4 py-2.5 group transition-colors",k===_.id&&"bg-accent/5 border-l-2 border-accent",g===_.id&&"opacity-40"),children:[s.jsx("div",{className:"pt-0.5 cursor-grab text-content-tertiary opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(Dc,{size:12})}),s.jsx("span",{className:"text-[10px] font-bold text-content-tertiary pt-0.5 w-4 flex-shrink-0",children:re+1}),s.jsxs("div",{className:"flex-1 min-w-0",children:[b===_.id?s.jsx("input",{autoFocus:!0,className:"w-full text-xs border border-accent rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-accent",value:v,onChange:U=>w(U.target.value),onBlur:()=>z(_.id),onKeyDown:U=>{U.key==="Enter"&&z(_.id),U.key==="Escape"&&f(null)}}):s.jsxs("p",{className:"text-xs text-content-secondary cursor-pointer hover:text-accent transition-colors flex items-center gap-1.5",onClick:()=>S(_),title:"Click to edit",children:[_.instruction,_.generatedCode&&!h.has(_.id)&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-green-400 flex-shrink-0",title:"Code generated"})]}),_.generatedCode&&h.has(_.id)&&s.jsx("div",{className:"mt-1",children:s.jsx($m,{code:_.generatedCode,maxLines:6})})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[_.generatedCode&&s.jsx("button",{title:h.has(_.id)?"Hide code":"Show code",onClick:()=>u(U=>{const xe=new Set(U);return xe.has(_.id)?xe.delete(_.id):xe.add(_.id),xe}),className:P("p-1 rounded transition-colors",h.has(_.id)?"text-content-secondary bg-slate-100":"text-content-tertiary hover:bg-surface-inset"),children:s.jsx(Pm,{size:12})}),s.jsx("button",{title:"Generate code",onClick:()=>se(_.id),disabled:p===_.id,className:"p-1 rounded hover:bg-purple-50 text-purple-500 transition-colors",children:p===_.id?s.jsx(ae,{size:12,className:"animate-spin"}):s.jsx(_r,{size:12})}),s.jsx("button",{title:"Delete step",onClick:()=>M("Delete this hook step? This cannot be undone.",()=>R.mutate({hookType:t,stepId:_.id})),className:"p-1 rounded hover:bg-red-50 text-red-400 transition-colors",children:s.jsx(Kt,{size:12})})]})]},_.id))}),s.jsxs("div",{className:"px-4 py-3 border-t border-slate-100 bg-surface-inset/50 flex items-center gap-2",children:[s.jsx("input",{className:"flex-1 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent placeholder:text-content-tertiary",value:d,onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&Y()},placeholder:"Add a step (e.g. Navigate to login page)"}),s.jsxs("button",{type:"button",onClick:Y,disabled:!d.trim()||E.isPending,className:P("inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors",d.trim()?"bg-accent text-white hover:bg-accent/90":"bg-slate-200 text-content-tertiary cursor-not-allowed"),children:[E.isPending?s.jsx(ae,{size:11,className:"animate-spin"}):s.jsx(Rs,{size:11}),"Add"]}),l.length>0&&q>0&&s.jsxs("button",{type:"button",onClick:le,disabled:A.isPending,className:"inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium bg-purple-600 text-white hover:bg-purple-700 transition-colors",children:[A.isPending?s.jsx(ae,{size:11,className:"animate-spin"}):s.jsx(_r,{size:11}),"Generate All (",q,")"]})]})]}),s.jsx(Ms,{...L})]})}const Kp={person:{icon:Im,label:"Person"},internet:{icon:nn,label:"Internet"},phone:{icon:ow,label:"Phone"},location:{icon:sw,label:"Location"},company:{icon:L2,label:"Company"},finance:{icon:A2,label:"Finance"},date:{icon:_2,label:"Date"},lorem:{icon:jw,label:"Lorem"},string:{icon:O2,label:"String"},number:{icon:zm,label:"Number"},datatype:{icon:yw,label:"Datatype"},image:{icon:Mm,label:"Image"},color:{icon:lw,label:"Color"},commerce:{icon:mw,label:"Commerce"},vehicle:{icon:$2,label:"Vehicle"},system:{icon:J2,label:"System"}},$d=[{name:"FIRST_NAME",example:"Alice"},{name:"LAST_NAME",example:"Smith"},{name:"AGE",example:"34"},{name:"EMAIL",example:"alice.smith123@example.com"},{name:"PHONE",example:"415-782-3901"},{name:"PASSWORD",example:"Xk9#mP2$qL"}];function zi(e,t){return e==="classic"?`{{FAKE_${t}}}`:`{{FAKE_${e}_${t}}}`.toUpperCase()}async function H5(){const e=await fetch("/api/faker/generators");if(!e.ok)throw new Error("Failed to load generators");return e.json()}function K5({onInsert:e}){var k;const[t,n]=m.useState(!1),[r,a]=m.useState("person"),[i,l]=m.useState(""),[o,c]=m.useState("6"),[d,x]=m.useState([]),{data:p=[],isLoading:y}=pe({queryKey:["faker-generators"],queryFn:H5,enabled:t,staleTime:1/0}),b=m.useMemo(()=>{if(!i.trim())return null;const N=i.toLowerCase(),E=[];for(const R of p)for(const L of R.methods){const M=`${R.category}_${L.name}`.toLowerCase();(L.name.toLowerCase().includes(N)||R.category.toLowerCase().includes(N)||M.includes(N)||L.example.toLowerCase().includes(N))&&E.push({category:R.category,method:L})}for(const R of $d)(R.name.toLowerCase().includes(N)||R.example.toLowerCase().includes(N))&&E.push({category:"classic",method:R});return E},[i,p]),f=m.useMemo(()=>{var N;return r==="classic"?null:((N=p.find(E=>E.category===r))==null?void 0:N.methods)??[]},[r,p]),v=m.useCallback((N,E)=>{const R=zi(N,E);x(L=>L.includes(R)?L.filter(M=>M!==R):[...L,R])},[]),w=m.useCallback(()=>{d.length>0&&e(d.join(", ")),x([]),n(!1),l("")},[d,e]),h=m.useCallback(()=>{d.length>0&&e(d.join(", ")),x([]),n(!1),l("")},[d,e]),u=m.useCallback(N=>{x(E=>E.filter(R=>R!==N))},[]),g=()=>{const E=`{{FAKE_NUMBER_${Math.max(1,Math.min(20,parseInt(o,10)||6))}}}`;x(R=>R.includes(E)?R:[...R,E])},j=m.useMemo(()=>[...p.map(E=>E.category),"classic"],[p]);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>n(!0),title:"Insert dynamic data token",className:P("inline-flex items-center justify-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium border transition-all duration-150 focus:outline-none","bg-gradient-to-b from-violet-500 to-violet-600 text-white border-violet-700 shadow-sm hover:brightness-110 hover:shadow-md"),children:[s.jsx(wt,{size:12}),s.jsx("span",{className:"hidden sm:inline",children:"Fake Data"}),s.jsx(Nt,{size:10})]}),t&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm animate-fade-in",onClick:N=>{N.target===N.currentTarget&&h()},children:s.jsxs("div",{className:"bg-surface rounded-2xl shadow-modal w-full max-w-2xl mx-4 overflow-hidden border border-border animate-scale-in flex flex-col",style:{maxHeight:"min(640px, 85vh)"},children:[s.jsxs("div",{className:"flex items-center gap-3 px-5 py-3.5 border-b border-border bg-gradient-to-r from-violet-50 to-indigo-50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(wt,{size:16,className:"text-violet-500"}),s.jsx("h2",{className:"text-sm font-bold text-violet-800",children:"Faker Data"}),s.jsxs("span",{className:"text-[10px] text-violet-500 bg-violet-100 px-2 py-0.5 rounded-full font-medium",children:[p.reduce((N,E)=>N+E.methods.length,0)+$d.length,"+ generators"]})]}),s.jsx("button",{type:"button",onClick:h,className:"p-1 rounded-lg hover:bg-violet-100 text-violet-400 hover:text-violet-600 transition-colors",children:s.jsx(be,{size:16})})]}),s.jsx("div",{className:"px-5 py-3 border-b border-border flex-shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2 bg-surface-inset rounded-xl px-3 py-2 border border-border focus-within:border-violet-300 focus-within:ring-2 focus-within:ring-violet-100 transition-all",children:[s.jsx(Kn,{size:14,className:"text-content-tertiary flex-shrink-0"}),s.jsx("input",{type:"text",value:i,onChange:N=>l(N.target.value),placeholder:"Search generators... (e.g. email, address, uuid)",className:"flex-1 bg-transparent outline-none text-sm text-content placeholder:text-content-tertiary",autoFocus:!0}),i&&s.jsx("button",{type:"button",onClick:()=>l(""),className:"text-content-tertiary hover:text-content transition-colors",children:s.jsx(be,{size:12})})]})}),s.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[s.jsx("div",{className:"w-40 flex-shrink-0 border-r border-border overflow-y-auto bg-surface-inset/40 py-2 px-2 space-y-0.5",children:y?s.jsx("div",{className:"space-y-2 px-1",children:Array.from({length:8}).map((N,E)=>s.jsx("div",{className:"h-7 rounded-lg bg-surface-inset animate-pulse"},E))}):j.map(N=>{const E=Kp[N]??{icon:qr,label:N.charAt(0).toUpperCase()+N.slice(1)},R=N==="classic"?wt:E.icon,L=N==="classic"?"Classic":E.label;return s.jsxs("button",{type:"button",onClick:()=>{a(N),l("")},className:P("w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-[11px] font-medium transition-all text-left",r===N&&!i?"bg-violet-100 text-violet-700 shadow-sm":"text-content-secondary hover:bg-surface-inset hover:text-content"),children:[s.jsx(R,{size:13,className:"flex-shrink-0"}),s.jsx("span",{className:"truncate",children:L})]},N)})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2 px-3",children:y?s.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((N,E)=>s.jsx("div",{className:"h-12 rounded-xl bg-surface-inset animate-pulse"},E))}):b?s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2",children:[b.length," result",b.length!==1?"s":"",' for "',i,'"']}),b.length===0?s.jsx("p",{className:"text-sm text-content-tertiary text-center py-8",children:"No generators found. Try a different search term."}):s.jsx("div",{className:"space-y-1",children:b.map(({category:N,method:E})=>s.jsx(Ud,{category:N,method:E,selected:d.includes(zi(N,E.name)),onToggle:v},`${N}-${E.name}`))})]}):r==="classic"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2",children:"Classic Tokens (backward-compatible)"}),s.jsx("div",{className:"space-y-1",children:$d.map(N=>s.jsx(Ud,{category:"classic",method:N,selected:d.includes(zi("classic",N.name)),onToggle:v},N.name))}),s.jsxs("div",{className:"mt-4 pt-3 border-t border-border",children:[s.jsxs("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2 flex items-center gap-1",children:[s.jsx(zm,{size:10})," Random Number"]}),s.jsxs("div",{className:"flex items-center gap-2 px-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-1 bg-surface-inset rounded-lg px-3 py-2 border border-border",children:[s.jsx("span",{className:"text-[11px] text-content-tertiary",children:"Digits:"}),s.jsx("input",{type:"number",min:1,max:20,value:o,onChange:N=>c(N.target.value),onKeyDown:N=>N.key==="Enter"&&g(),className:"w-12 text-sm bg-transparent outline-none text-content font-mono tabular-nums"})]}),s.jsx("button",{type:"button",onClick:g,className:"flex-shrink-0 px-3 py-2 rounded-lg bg-violet-600 hover:bg-violet-700 text-white text-[11px] font-semibold transition-colors",children:"+ Add"})]}),s.jsx("p",{className:"text-[10px] text-content-tertiary px-1 mt-2 font-mono",children:`→ {{FAKE_NUMBER_${Math.max(1,parseInt(o,10)||6)}}}`})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest px-1 mb-2",children:[((k=Kp[r])==null?void 0:k.label)??r," — ",(f==null?void 0:f.length)??0," generators"]}),s.jsx("div",{className:"space-y-1",children:(f??[]).map(N=>s.jsx(Ud,{category:r,method:N,selected:d.includes(zi(r,N.name)),onToggle:v},N.name))})]})})]}),d.length>0&&s.jsxs("div",{className:"px-5 py-2.5 border-t border-border bg-violet-50/50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsxs("span",{className:"text-[10px] font-bold text-violet-600 uppercase tracking-wider",children:["Selected (",d.length,")"]}),s.jsx("button",{type:"button",onClick:()=>x([]),className:"text-[10px] text-violet-400 hover:text-violet-600 transition-colors underline",children:"Clear all"})]}),s.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-16 overflow-y-auto",children:d.map(N=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-violet-100 text-violet-700 text-[10px] font-mono border border-violet-200",children:[N,s.jsx("button",{type:"button",onClick:()=>u(N),className:"text-violet-400 hover:text-violet-700 transition-colors",children:s.jsx(be,{size:10})})]},N))})]}),s.jsxs("div",{className:"px-5 py-2.5 bg-surface-inset/60 border-t border-border flex items-center justify-between flex-shrink-0",children:[s.jsxs("p",{className:"text-[10px] text-content-tertiary",children:["Click to select multiple tokens. They will be inserted ",s.jsx("strong",{children:"comma-separated"}),"."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{x([]),n(!1),l("")},className:"px-3 py-1.5 rounded-lg border border-border text-xs font-medium text-content-secondary hover:bg-surface-inset transition-colors",children:"Cancel"}),s.jsxs("button",{type:"button",onClick:w,disabled:d.length===0,className:P("px-4 py-1.5 rounded-lg text-xs font-semibold transition-all",d.length>0?"bg-violet-600 hover:bg-violet-700 text-white shadow-sm":"bg-violet-200 text-violet-400 cursor-not-allowed"),children:["Insert ",d.length>0?`${d.length} token${d.length>1?"s":""}`:""]})]})]})]})})]})}function Ud({category:e,method:t,selected:n,onToggle:r}){const a=zi(e,t.name);return s.jsxs("button",{type:"button",onClick:()=>r(e,t.name),className:P("w-full flex items-center justify-between gap-3 px-3 py-2 rounded-xl transition-colors group text-left",n?"bg-violet-100 border border-violet-200 shadow-sm":"hover:bg-violet-50 border border-transparent"),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("div",{className:P("flex-shrink-0 w-4 h-4 rounded flex items-center justify-center border transition-all",n?"bg-violet-600 border-violet-600":"border-gray-300 group-hover:border-violet-400"),children:n&&s.jsx(Oe,{size:10,className:"text-white",strokeWidth:3})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[e!=="classic"&&s.jsx("span",{className:P("text-[9px] px-1.5 py-0.5 rounded font-medium uppercase flex-shrink-0",n?"text-violet-600 bg-violet-200":"text-violet-400 bg-violet-50 group-hover:bg-violet-100"),children:e}),s.jsx("p",{className:P("text-[12px] font-medium truncate",n?"text-violet-700":"text-content group-hover:text-violet-700"),children:t.name})]}),s.jsx("p",{className:"text-[9px] text-content-tertiary font-mono truncate mt-0.5",children:a})]})]}),s.jsx("span",{className:"text-[10px] text-content-tertiary bg-surface-inset px-2 py-1 rounded-lg font-mono flex-shrink-0 max-w-[180px] truncate",children:t.example})]})}function W5({selectedIds:e,suiteId:t,suites:n,onClear:r,onDeleted:a,onMoved:i}){const l=ie(),{modalProps:o,confirmDelete:c}=Ts(),[d,x]=m.useState(""),p=V({mutationFn:()=>Wn.bulkDelete(t,Array.from(e)),onSuccess:v=>{O.success(`Deleted ${v.deleted} case${v.deleted!==1?"s":""}`),l.invalidateQueries({queryKey:["cases",t]}),a(),r()},onError:v=>O.error(v.message)}),y=V({mutationFn:v=>Wn.bulkMove(t,Array.from(e),v),onSuccess:v=>{O.success(`Moved ${v.moved} case${v.moved!==1?"s":""}`),l.invalidateQueries({queryKey:["cases",t]}),i(),r(),x("")},onError:v=>O.error(v.message)}),b=n.filter(v=>v.id!==t),f=e.size;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"fixed bottom-0 left-[248px] right-0 z-30 bg-surface border-t border-border shadow-elevated px-5 py-3 flex items-center gap-3",children:[s.jsxs("span",{className:"text-sm font-semibold text-content flex-shrink-0",children:[f," case",f!==1?"s":""," selected"]}),s.jsx("button",{type:"button",onClick:()=>O("Coming soon",{icon:"🔜"}),className:"inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-border text-content-secondary hover:bg-surface-inset transition-colors",children:"Run Selected"}),s.jsxs("button",{type:"button",onClick:()=>c(`Delete ${f} selected case${f!==1?"s":""}? This cannot be undone.`,()=>p.mutate()),disabled:p.isPending,className:"inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border border-red-200 text-red-600 bg-red-50 hover:bg-red-100 transition-colors disabled:opacity-50",children:[s.jsx(Kt,{size:12})," Delete Selected"]}),b.length>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(iw,{size:13,className:"text-content-tertiary flex-shrink-0"}),s.jsxs("select",{className:"text-xs border border-border rounded-lg px-2 py-1.5 bg-surface text-content-secondary focus:outline-none focus:ring-1 focus:ring-accent/30",value:d,onChange:v=>x(v.target.value),children:[s.jsx("option",{value:"",children:"Move to suite…"}),b.map(v=>s.jsx("option",{value:v.id,children:v.name},v.id))]}),d&&s.jsx("button",{type:"button",onClick:()=>y.mutate(d),disabled:y.isPending,className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:brightness-110 transition-colors disabled:opacity-50",children:"Move"})]}),s.jsx("div",{className:"flex-1"}),s.jsx("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg text-content-tertiary hover:bg-surface-inset transition-colors",children:s.jsx(be,{size:14})})]}),s.jsx(Ms,{...o})]})}function V5({passRate:e,runs:t,flaky:n}){if(!n||t<3||e===1)return null;const r=Math.round(e*100);return s.jsx("span",{title:`Flaky: ${r}% pass rate over ${t} runs`,className:"inline-flex items-center gap-0.5 text-[8px] font-semibold px-1.5 py-0.5 rounded bg-amber-50 text-amber-600 ring-1 ring-amber-200 flex-shrink-0",children:"~flaky"})}function G5({open:e,onClose:t,suiteId:n,caseId:r,onInserted:a}){const i=ie(),[l,o]=m.useState(""),[c,d]=m.useState(!1),[x,p]=m.useState(""),[y,b]=m.useState(""),{data:f=[]}=pe({queryKey:["step-library"],queryFn:()=>dr.list()}),v=V({mutationFn:u=>Wr.add(n,r,{instruction:u.instruction,...u.generatedCode?{generatedCode:u.generatedCode,strategy:"cache"}:{}}),onSuccess:()=>{i.invalidateQueries({queryKey:["cases",n,r]}),O.success("Step inserted"),a()},onError:u=>O.error(u.message)}),w=V({mutationFn:()=>dr.create({name:x,instruction:y}),onSuccess:()=>{i.invalidateQueries({queryKey:["step-library"]}),O.success("Step saved to library"),d(!1),p(""),b("")},onError:u=>O.error(u.message)}),h=f.filter(u=>!l||u.name.toLowerCase().includes(l.toLowerCase())||u.instruction.toLowerCase().includes(l.toLowerCase())||u.tags.some(g=>g.toLowerCase().includes(l.toLowerCase())));return e?s.jsxs("div",{className:"fixed right-0 top-0 bottom-0 w-80 bg-surface border-l border-border shadow-xl z-40 flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(cl,{size:14,className:"text-accent"}),s.jsx("span",{className:"text-sm font-semibold text-content",children:"Step Library"})]}),s.jsx("button",{type:"button",onClick:t,className:"p-1 rounded text-content-tertiary hover:text-content hover:bg-surface-inset",children:s.jsx(be,{size:14})})]}),s.jsx("div",{className:"px-3 py-2 border-b border-border flex-shrink-0",children:s.jsxs("div",{className:"relative",children:[s.jsx(Kn,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-content-tertiary"}),s.jsx("input",{type:"text",placeholder:"Search steps…",value:l,onChange:u=>o(u.target.value),className:"w-full pl-7 pr-3 py-1.5 text-xs border border-border rounded-lg bg-surface-inset focus:outline-none focus:ring-1 focus:ring-accent/30"})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto py-2 px-2 space-y-1",children:[h.length===0&&s.jsx("p",{className:"text-[11px] text-content-tertiary text-center py-6",children:f.length===0?"No steps in library yet":"No results"}),h.map(u=>s.jsx("div",{className:"border border-border rounded-lg p-2.5 hover:border-accent/30 hover:bg-surface-inset/50 transition-colors",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"text-xs font-semibold text-content truncate",children:u.name}),u.generatedCode?s.jsx("span",{className:"flex-shrink-0 text-[8px] px-1 py-px rounded bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-1 ring-emerald-200 dark:ring-emerald-800",children:"Ready"}):s.jsx("span",{className:"flex-shrink-0 text-[8px] px-1 py-px rounded bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-1 ring-amber-200 dark:ring-amber-800",children:"No code"})]}),s.jsx("p",{className:"text-[10px] text-content-tertiary mt-0.5 line-clamp-2",children:u.instruction}),u.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-0.5 mt-1",children:u.tags.map(g=>s.jsx("span",{className:"text-[8px] px-1 py-px rounded bg-accent/8 text-accent ring-1 ring-accent/15",children:g},g))})]}),s.jsx("button",{type:"button",onClick:()=>v.mutate({instruction:u.instruction,generatedCode:u.generatedCode}),disabled:v.isPending,className:"flex-shrink-0 text-[10px] px-2 py-1 rounded bg-accent text-white hover:brightness-110 transition-colors disabled:opacity-50",children:"Insert"})]})},u.id))]}),s.jsx("div",{className:"border-t border-border p-3 flex-shrink-0",children:c?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",placeholder:"Step name",value:x,onChange:u=>p(u.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded-lg focus:outline-none focus:ring-1 focus:ring-accent/30"}),s.jsx("textarea",{placeholder:"Step instruction",value:y,onChange:u=>b(u.target.value),rows:2,className:"w-full px-2 py-1.5 text-xs border border-border rounded-lg focus:outline-none focus:ring-1 focus:ring-accent/30 resize-none"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>w.mutate(),disabled:!x.trim()||!y.trim()||w.isPending,className:"flex-1 text-xs py-1.5 rounded-lg bg-accent text-white hover:brightness-110 transition-colors disabled:opacity-50",children:"Save"}),s.jsx("button",{type:"button",onClick:()=>d(!1),className:"text-xs px-3 py-1.5 rounded-lg border border-border text-content-secondary hover:bg-surface-inset",children:"Cancel"})]})]}):s.jsxs("button",{type:"button",onClick:()=>d(!0),className:"w-full flex items-center justify-center gap-1.5 text-xs py-2 rounded-lg border border-dashed border-border text-content-tertiary hover:text-content hover:border-accent/40 transition-colors",children:[s.jsx(Rs,{size:12})," Save current step to library"]})})]}):null}const gi=new Set,ra=new Map;let mn=null,yi=null,bi=null;const aa=new Map,vi=new Map,gx=new Set;function ia(){gx.forEach(e=>e())}const vt={subscribe(e){return gx.add(e),()=>gx.delete(e)},getSnapshot(){return{runningCaseIds:gi,runningSuiteId:mn,caseLastRun:aa,suiteLastRun:vi}},startCase(e){gi.add(e),ia()},startSuite(e){bi=e,mn=e,ia()},onRunStart(e){bi&&(yi=e,bi=null)},onCaseRunning(e,t){ra.has(e)||ra.set(e,t)},onCaseDone(e,t,n){const r=e===yi,a=aa.get(t),i=r?(a==null?void 0:a.allureRunId)??e:e;aa.set(t,{status:n,runId:e,allureRunId:i}),ia()},onComplete(e,t){const n=ra.get(e);n&&(gi.delete(n),ra.delete(e)),gi.clear(),ra.clear(),e===yi&&mn?vi.set(mn,{...t,runId:e}):mn&&vi.set(mn,{...t,runId:e}),mn=null,yi=null,bi=null,ia()},seedFromHistory(e){for(const t of e)for(const n of t.suites){vi.has(n.suiteId)||vi.set(n.suiteId,{passed:t.passed,failed:t.failed,skipped:t.skipped,runId:t.runId});const a=t.suites.reduce((i,l)=>i+l.cases.length,0)===1;for(const i of n.cases){const l=aa.get(i.caseId);l?a&&!l.allureRunId&&aa.set(i.caseId,{...l,allureRunId:t.runId}):aa.set(i.caseId,{status:i.status,runId:t.runId,allureRunId:t.runId})}}ia()},clear(){gi.clear(),ra.clear(),mn=null,yi=null,bi=null,ia()}};function qc(){const[e,t]=m.useState(()=>vt.getSnapshot());return m.useEffect(()=>vt.subscribe(()=>t(vt.getSnapshot())),[]),e}function Bm(){const[e,t]=m.useState(()=>st.getSnapshot());return m.useEffect(()=>st.subscribe(()=>t(st.getSnapshot())),[]),e}const tb=["critical","high","medium","low"],yx={critical:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-500/20 dark:ring-red-500/30",high:"bg-orange-50 dark:bg-orange-900/20 text-orange-600 dark:text-orange-400 ring-orange-500/20 dark:ring-orange-500/30",medium:"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-500/20 dark:ring-blue-500/30",low:"bg-surface-inset text-content-secondary ring-border"};function hl({tags:e,editable:t=!1,onAdd:n,onRemove:r}){const[a,i]=m.useState(""),l=()=>{const o=a.trim().toLowerCase().replace(/\s+/g,"-");if(!o||e.includes(o)){i("");return}n==null||n(o),i("")};return s.jsxs("div",{className:"flex flex-wrap gap-0.5 items-center",children:[e.map(o=>s.jsxs("span",{className:"inline-flex items-center gap-px px-1.5 py-px rounded bg-accent/8 text-accent text-[9px] font-medium ring-1 ring-accent/15 leading-tight",children:[o,t&&s.jsx("button",{type:"button",onClick:()=>r==null?void 0:r(o),children:s.jsx(be,{size:8,className:"hover:text-red-500"})})]},o)),t&&s.jsx("input",{className:"text-[9px] border border-dashed border-border rounded bg-transparent outline-none w-14 px-1.5 py-px placeholder-content-tertiary focus:border-accent focus:ring-1 focus:ring-accent/20 transition-colors",placeholder:"+ tag",value:a,onChange:o=>i(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),l())},onBlur:l}),!t&&e.length===0&&s.jsx("span",{className:"text-[10px] text-content-tertiary",children:"—"})]})}function Bd(){const e=Xn(),t=zs(),{suiteId:n="",caseId:r=""}=Sj(),a=r?"case-editor":n?"suite-detail":"suites",[i,l]=m.useState(""),[o,c]=m.useState("ui"),[d,x]=m.useState(""),{modalProps:p,confirmDelete:y}=Ts(),[b,f]=m.useState(""),[v,w]=m.useState(""),[h,u]=m.useState(""),{data:g=[],isLoading:j}=Gy();m.useEffect(()=>{var q;const z=(q=e.state)==null?void 0:q.openSuiteId;z&&g.length>0&&g.find(re=>re.id===z)&&t(`/tests/${z}`,{replace:!0})},[e.state,g]);const k=m.useMemo(()=>{const z=new Set;return g.forEach(q=>(q.tags??[]).forEach(_=>z.add(_))),Array.from(z).sort()},[g]),N=m.useMemo(()=>g.filter(z=>{const q=!b||z.name.toLowerCase().includes(b.toLowerCase())||(z.description??"").toLowerCase().includes(b.toLowerCase()),_=!v||(z.tags??[]).includes(v),re=z.type==="performance"?"audit":z.type??"ui";return q&&_&&(!h||re===h)}),[g,b,v,h]),E=g.find(z=>z.id===n),R=p5(),L=f5(),{data:M=[]}=R5(),W=z5(),G=Xy(),ne=Bm(),A=V({mutationFn:z=>Qa.start({test:z}),onError:z=>{vt.clear(),O.error(z.message)}}),Y=V({mutationFn:z=>Qa.start({suite:z}),onError:z=>{vt.clear(),O.error(z.message)}}),se=z=>{vt.startCase(z),A.mutate(z),t("/run")},le=z=>{vt.startSuite(z),Y.mutate(z),t("/run")},T=()=>{i.trim()&&(R.mutate({name:i,type:o}),l(""))};if(j)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ae,{size:20,className:"animate-spin text-accent"})});let S=null;if(a==="suites"){const z=g.filter(U=>(U.type??"ui")==="ui").length,q=g.filter(U=>(U.type??"ui")==="api").length,_=g.filter(U=>U.type==="audit"||U.type==="performance").length,re=g.reduce((U,xe)=>U+(xe.caseCount??0),0);S=s.jsx("div",{className:"flex flex-col h-full overflow-hidden bg-surface-inset/30",children:s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"max-w-5xl mx-auto px-5 py-4 space-y-3",children:[s.jsx("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:s.jsxs("div",{className:"px-5 py-3.5 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-violet-600 flex items-center justify-center shadow-sm shadow-indigo-500/20",children:s.jsx(dl,{size:18,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-base font-bold text-content tracking-tight",children:"Test Suites"}),s.jsx("p",{className:"text-[11px] text-content-tertiary mt-0.5",children:"Manage and organize your test automation"})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex items-center gap-3",children:[{label:"Suites",val:g.length,cls:"text-indigo-600 dark:text-indigo-400"},{label:"UI",val:z,cls:"text-blue-600 dark:text-blue-400"},{label:"API",val:q,cls:"text-violet-600 dark:text-violet-400"},..._>0?[{label:"Audit",val:_,cls:"text-amber-600 dark:text-amber-400"}]:[],{label:"Cases",val:re,cls:"text-emerald-600 dark:text-emerald-400"}].map(U=>s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:P("text-sm font-bold tabular-nums",U.cls),children:U.val}),s.jsx("p",{className:"text-[9px] text-content-tertiary font-medium",children:U.label})]},U.label))}),s.jsx("div",{className:"w-px h-8 bg-border"}),s.jsx(ml,{status:"not-created",variant:"full",label:"Sync All",onClick:()=>W.mutate(),busy:ne.allOp==="create"||ne.allOp==="sync"})]})]})}),s.jsxs("div",{className:"rounded-xl border border-border bg-surface px-4 py-2.5 flex items-center gap-3",children:[s.jsx("div",{className:"flex gap-0.5 flex-shrink-0 bg-surface-inset rounded-lg p-0.5",children:[["","All",g.length],["ui","UI",z],["api","API",q],..._>0?[["audit","Audit",_]]:[]].map(([U,xe,me])=>s.jsxs("button",{type:"button",onClick:()=>u(U),className:P("px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all",h===U?"bg-surface text-accent shadow-sm ring-1 ring-accent/20":"text-content-tertiary hover:text-content-secondary"),children:[xe," ",s.jsx("span",{className:"opacity-50 ml-0.5",children:me})]},U))}),s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(Kn,{size:12,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-content-tertiary pointer-events-none"}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg pl-8 pr-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 focus:border-accent/40 bg-surface placeholder-content-tertiary",placeholder:"Search suites…",value:b,onChange:U=>f(U.target.value)})]}),k.length>0&&s.jsxs("select",{value:v,onChange:U=>w(U.target.value),className:"text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent bg-surface min-w-[100px]",children:[s.jsx("option",{value:"",children:"All Tags"}),k.map(U=>s.jsx("option",{value:U,children:U},U))]}),(b||v||h)&&s.jsx("button",{type:"button",onClick:()=>{f(""),w(""),u("")},className:"p-1.5 rounded-lg text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:12})}),s.jsx("div",{className:"w-px h-5 bg-border"}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx("div",{className:"flex gap-0 bg-surface-inset rounded-lg p-0.5 ring-1 ring-border",children:["ui","api","audit"].map(U=>s.jsx("button",{type:"button",onClick:()=>c(U),className:P("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all",o===U?U==="api"?"bg-violet-500 text-white shadow-sm":U==="audit"?"bg-amber-500 text-white shadow-sm":"bg-blue-500 text-white shadow-sm":"text-content-tertiary hover:text-content-secondary"),children:U==="audit"?"Audit":U},U))}),s.jsx("input",{className:"w-40 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"New suite name…",value:i,onChange:U=>l(U.target.value),onKeyDown:U=>U.key==="Enter"&&T()}),s.jsxs(te,{size:"sm",onClick:T,disabled:R.isPending,children:[s.jsx(Rs,{size:11})," Add"]})]})]}),g.length===0?s.jsxs("div",{className:"rounded-xl border-2 border-dashed border-border bg-surface flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl bg-gradient-to-br from-indigo-50 to-violet-50 dark:from-indigo-900/20 dark:to-violet-900/20 flex items-center justify-center ring-1 ring-border",children:s.jsx(qr,{size:22,className:"text-accent"})}),s.jsx("p",{className:"text-sm font-semibold text-content",children:"No suites yet"}),s.jsx("p",{className:"text-[11px] text-content-tertiary max-w-xs text-center",children:"Create your first test suite using the toolbar above — pick a type (UI, API, or Audit) and give it a name."})]}):N.length===0?s.jsxs("div",{className:"rounded-xl border-2 border-dashed border-border bg-surface flex flex-col items-center justify-center py-12 gap-2.5",children:[s.jsx(yy,{size:18,className:"text-content-tertiary"}),s.jsx("p",{className:"text-xs font-medium text-content-secondary",children:"No suites match your filters"}),s.jsx("button",{onClick:()=>{f(""),w(""),u("")},className:"text-[10px] font-medium text-accent hover:underline",children:"Clear all filters"})]}):s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:N.map(U=>{var xe,me;return s.jsx(Q5,{suite:U,xrayStatus:((xe=M.find(Ee=>Ee.suiteId===U.id))==null?void 0:xe.status)??"not-created",xrayKey:((me=M.find(Ee=>Ee.suiteId===U.id))==null?void 0:me.xrayTestSetId)??null,onOpen:()=>t(`/tests/${U.id}`),onRun:()=>le(U.id),onDelete:()=>y(`Delete suite "${U.name}"? All cases and steps will be lost.`,()=>L.mutate(U.id)),onXrayAction:()=>G.mutate(U.id),isXrayBusy:ne.busySuites.get(U.id)==="create"||ne.busySuites.get(U.id)==="sync"||ne.allOp==="create"||ne.allOp==="sync"},U.id)})})]})})})}return a==="suite-detail"&&n&&(S=s.jsx(Y5,{suiteId:n,suite:E,suites:g,newCaseName:d,onNewCaseNameChange:x,onOpenCase:z=>t(`/tests/${n}/cases/${z}`),onRunCase:z=>se(z),onRunSuite:()=>le(n),onBack:()=>t("/tests")})),a==="case-editor"&&n&&r&&(S=s.jsx(J5,{suiteId:n,caseId:r,suiteName:(E==null?void 0:E.name)??"",suiteType:(E==null?void 0:E.type)??"ui",onBack:()=>t(`/tests/${n}`),onRunCase:()=>se(r)})),s.jsxs("div",{className:"flex-1 overflow-hidden relative flex flex-col",children:[S,s.jsx(Ms,{...p})]})}function Q5({suite:e,onOpen:t,onRun:n,onDelete:r,xrayStatus:a="not-created",xrayKey:i=null,onXrayAction:l,isXrayBusy:o=!1}){const{runningCaseIds:c,runningSuiteId:d,suiteLastRun:x}=qc(),p=d===e.id,y=x.get(e.id),[b,f]=m.useState(!1),[v,w]=m.useState(e.name),[h,u]=m.useState(e.description??""),[g,j]=m.useState(e.tags??[]),[k,N]=m.useState(e.timeout?String(e.timeout):""),E=Qy(),R=m.useRef(null),L=(e.type??"ui")==="api",M=e.type==="audit"||e.type==="performance";m.useEffect(()=>{var S;b&&((S=R.current)==null||S.focus())},[b]);const W=S=>{S.stopPropagation(),f(!0)},G=S=>{S==null||S.stopPropagation(),w(e.name),u(e.description??""),j(e.tags??[]),N(e.timeout?String(e.timeout):""),f(!1)},ne=S=>{S==null||S.stopPropagation();const z=k?parseInt(k,10):void 0;E.mutate({id:e.id,data:{name:v.trim()||e.name,description:h,tags:g,timeout:z}},{onSuccess:()=>f(!1)})},A=S=>{S.key==="Enter"&&(S.preventDefault(),ne()),S.key==="Escape"&&G()};if(b)return s.jsxs("div",{className:"rounded-xl border-2 border-accent/30 bg-accent/[0.02] p-3.5 space-y-2.5",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:P("w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0",L?"bg-violet-100":"bg-blue-100"),children:s.jsx(Ps,{size:11,className:L?"text-violet-600":"text-blue-600"})}),s.jsx("input",{ref:R,className:"flex-1 text-xs font-semibold border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface",value:v,onChange:S=>w(S.target.value),onKeyDown:A,placeholder:"Suite name"})]}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:h,onChange:S=>u(S.target.value),onKeyDown:A,placeholder:"Description (optional)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:1e3,step:1e3,className:"w-32 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:k,onChange:S=>N(S.target.value),onKeyDown:A,placeholder:"Timeout (ms)"}),s.jsx("span",{className:"text-[10px] text-content-tertiary",children:"ms timeout"}),s.jsx("div",{className:"ml-auto",children:s.jsx(hl,{tags:g,editable:!0,onAdd:S=>j(z=>[...z,S]),onRemove:S=>j(z=>z.filter(q=>q!==S))})})]}),s.jsxs("div",{className:"flex gap-1.5 justify-end pt-0.5",children:[s.jsxs(te,{size:"sm",variant:"secondary",onClick:G,children:[s.jsx(be,{size:10})," Cancel"]}),s.jsxs(te,{size:"sm",onClick:ne,loading:E.isPending,children:[s.jsx(Oe,{size:10})," Save"]})]})]});const Y=L?"bg-gradient-to-b from-violet-500 to-purple-600":M?"bg-gradient-to-b from-amber-500 to-orange-600":"bg-gradient-to-b from-blue-500 to-indigo-600",se=L?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":M?"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800",le=M?"Audit":L?"API":"UI",T=e.caseCount??0;return s.jsxs("div",{className:"group rounded-xl border border-border bg-surface hover:border-accent/30 hover:shadow-md hover:shadow-accent/5 cursor-pointer transition-all flex overflow-hidden",onClick:t,children:[s.jsx("div",{className:P("w-1 flex-shrink-0 rounded-l-xl",Y)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"px-3.5 pt-3 pb-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[13px] font-bold text-content truncate flex-1",children:e.name}),s.jsxs("span",{className:P("text-[8px] px-1.5 py-0.5 rounded-md font-bold uppercase flex-shrink-0 ring-1 flex items-center gap-0.5",se),children:[M&&s.jsx(qe,{size:7})," ",le]}),s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",onClick:S=>S.stopPropagation(),children:[s.jsx("button",{type:"button",onClick:W,title:"Edit",className:"p-1.5 rounded-lg text-content-tertiary hover:text-accent hover:bg-accent/8 transition-colors",children:s.jsx(Hr,{size:12})}),s.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),r()},title:"Delete",className:"p-1.5 rounded-lg text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(Kt,{size:12})})]})]}),e.description&&s.jsx("p",{className:"text-[10px] text-content-tertiary truncate mt-1 leading-relaxed",children:e.description})]}),s.jsx("div",{className:"px-3.5 pb-2",children:s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-[9px] font-semibold text-content-secondary bg-surface-inset px-2 py-0.5 rounded-md ring-1 ring-border",children:[s.jsx(qr,{size:9,className:"opacity-50"}),T," case",T!==1?"s":""]}),y&&s.jsxs("span",{className:P("inline-flex items-center gap-1 text-[9px] font-semibold px-2 py-0.5 rounded-md ring-1",y.failed>0?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-200 dark:ring-red-800":"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-emerald-200 dark:ring-emerald-800"),children:[s.jsx(dy,{size:5,className:"fill-current"}),y.passed,"p / ",y.failed,"f"]}),s.jsxs("div",{className:"flex items-center gap-1",onClick:S=>S.stopPropagation(),children:[s.jsx(Um,{status:a,xrayKey:i}),s.jsx(ml,{variant:"icon",status:a,onClick:()=>l==null?void 0:l(),busy:o})]}),(e.tags??[]).length>0&&s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(hl,{tags:e.tags??[]})})]})}),s.jsxs("div",{className:"px-3.5 py-2 border-t border-border/40 bg-surface-inset/20 flex items-center gap-1.5",onClick:S=>S.stopPropagation(),children:[p?s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-teal-600 dark:text-teal-400 font-semibold",children:[s.jsx(ae,{size:11,className:"animate-spin"})," Running..."]}):s.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),n()},className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold text-teal-700 dark:text-teal-400 bg-teal-50 dark:bg-teal-900/20 hover:bg-teal-100 dark:hover:bg-teal-900/30 ring-1 ring-teal-200 dark:ring-teal-800 transition-colors",title:"Run suite",children:[s.jsx(Dt,{size:10,strokeWidth:2.5})," Run Suite"]}),s.jsxs("button",{type:"button",disabled:!y,onClick:S=>{S.stopPropagation(),y&&window.open(`/allure/${y.runId}`,"_blank")},title:y?`Report: ${y.passed}p / ${y.failed}f`:"No report",className:P("flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold transition-colors ring-1",y?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 hover:bg-blue-100 dark:hover:bg-blue-900/30 ring-blue-200 dark:ring-blue-800":"text-content-tertiary/40 bg-surface-inset ring-border cursor-not-allowed"),children:[s.jsx(hs,{size:10})," Report"]}),s.jsx("div",{className:"flex-1"}),s.jsx("span",{className:"text-[9px] text-content-tertiary",children:new Date(e.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}),s.jsx(Ht,{size:12,className:"text-content-tertiary/40 group-hover:text-accent transition-colors"})]})]})]})}function Y5({suiteId:e,suite:t,suites:n,newCaseName:r,onNewCaseNameChange:a,onOpenCase:i,onRunCase:l,onRunSuite:o,onBack:c}){const{runningCaseIds:d,runningSuiteId:x,caseLastRun:p}=qc(),y=x===e,{data:b=[],isLoading:f}=g5(e),v=Hp(e),w=v5(e),h=Hp(e),[u,g]=m.useState(!1),[j,k]=m.useState(!1),{modalProps:N,confirmDelete:E}=Ts(),[R,L]=m.useState(new Set),M=m.useRef(-1),{data:W}=pe({queryKey:["flakiness",e],queryFn:()=>Dw.get(e),staleTime:6e4});m.useEffect(()=>{L(new Set),M.current=-1},[e]);const{data:G}=Jy(e),ne=Xy(),A=Zy(),Y=M5(),se=eb(),le=Bm(),T=()=>{((G==null?void 0:G.status)??"not-created")==="not-created"?ne.mutate(e):Y.mutate(e)},S=H=>{var fe;(((fe=G==null?void 0:G.cases.find(De=>De.caseId===H))==null?void 0:fe.status)??"not-created")==="not-created"?A.mutate({suiteId:e,caseId:H}):se.mutate({suiteId:e,caseId:H})};m.useEffect(()=>{Qa.list(20).then(async H=>{const ue=await Promise.all(H.slice(0,10).map(fe=>Qa.get(fe.runId).catch(()=>null)));vt.seedFromHistory(ue.filter(fe=>fe!==null).map(fe=>({runId:fe.runId,passed:fe.passed,failed:fe.failed,skipped:fe.skipped,suites:fe.suites.map(De=>({suiteId:De.suiteId,cases:De.cases.map(lt=>({caseId:lt.caseId,status:lt.status}))}))})))}).catch(()=>{})},[e]);const[z,q]=m.useState(""),[_,re]=m.useState(new Set),[U,xe]=m.useState(""),me=_.size===0,Ee=m.useMemo(()=>{const H=new Set;return b.forEach(ue=>(ue.tags??[]).forEach(fe=>H.add(fe))),Array.from(H).sort()},[b]),ye=m.useMemo(()=>b.filter(H=>{const ue=!z||H.name.toLowerCase().includes(z.toLowerCase()),fe=_.size===0||(H.tags??[]).some(lt=>_.has(lt)),De=!U||H.priority===U;return ue&&fe&&De}),[b,z,_,U]),Te=!!(z||_.size>0||U),[pt,It]=m.useState(!1),[rs,He]=m.useState((t==null?void 0:t.name)??""),[Ct,K]=m.useState((t==null?void 0:t.description)??""),[Ke,as]=m.useState((t==null?void 0:t.tags)??[]),[er,tr]=m.useState(t!=null&&t.timeout?String(t.timeout):""),D=Qy();m.useEffect(()=>{He((t==null?void 0:t.name)??""),K((t==null?void 0:t.description)??""),as((t==null?void 0:t.tags)??[]),tr(t!=null&&t.timeout?String(t.timeout):"")},[t==null?void 0:t.id]);const X=()=>{const H=er?parseInt(er,10):void 0;D.mutate({id:e,data:{name:rs.trim()||(t==null?void 0:t.name),description:Ct,tags:Ke,timeout:H}},{onSuccess:()=>It(!1)})},je=H=>{H.key==="Enter"&&(H.preventDefault(),X()),H.key==="Escape"&&It(!1)},As=()=>{r.trim()&&(v.mutate({name:r}),a(""))},Et=H=>{h.mutate({name:`${H.name} (copy)`,description:H.description,priority:H.priority,tags:H.tags,steps:(H.steps??[]).map(ue=>({instruction:ue.instruction}))})},Os=H=>`TC-${((t==null?void 0:t.name)??"TC").replace(/[^a-zA-Z]/g,"").slice(0,3).toUpperCase()||"TC"}-${String(H+1).padStart(3,"0")}`,is=((t==null?void 0:t.type)??"ui")==="api",sr=(t==null?void 0:t.type)==="audit"||(t==null?void 0:t.type)==="performance";return s.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-inset/30",children:[s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"max-w-5xl mx-auto px-5 py-4 space-y-3",children:[s.jsxs("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:[s.jsx("div",{className:"px-4 py-1.5 bg-surface-inset/30 border-b border-border/50",children:s.jsxs("nav",{className:"flex items-center gap-1.5 text-[10px] text-content-tertiary",children:[s.jsxs("button",{onClick:c,className:"hover:text-accent transition-colors flex items-center gap-1",children:[s.jsx(by,{size:10})," Suites"]}),s.jsx(Ht,{size:9}),s.jsx("span",{className:"text-content-secondary font-semibold",children:t==null?void 0:t.name})]})}),pt?s.jsxs("div",{className:"px-4 py-3.5 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:P("w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",is?"bg-gradient-to-br from-violet-500 to-purple-600":"bg-gradient-to-br from-blue-500 to-indigo-600"),children:s.jsx(dl,{size:13,className:"text-white"})}),s.jsx("input",{className:"flex-1 text-sm font-bold border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface",value:rs,onChange:H=>He(H.target.value),onKeyDown:je,placeholder:"Suite name",autoFocus:!0})]}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:Ct,onChange:H=>K(H.target.value),onKeyDown:je,placeholder:"Description"}),s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Br,{size:10,className:"text-content-tertiary"}),s.jsx("input",{type:"number",min:1e3,step:1e3,className:"w-28 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/30 bg-surface",value:er,onChange:H=>tr(H.target.value),onKeyDown:je,placeholder:"Timeout ms"})]}),s.jsx("div",{className:"flex-1",children:s.jsx(hl,{tags:Ke,editable:!0,onAdd:H=>as(ue=>[...ue,H]),onRemove:H=>as(ue=>ue.filter(fe=>fe!==H))})}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs(te,{size:"sm",variant:"secondary",onClick:()=>It(!1),children:[s.jsx(be,{size:10})," Cancel"]}),s.jsxs(te,{size:"sm",onClick:X,loading:D.isPending,children:[s.jsx(Oe,{size:10})," Save"]})]})]})]}):s.jsxs("div",{className:"px-4 py-3 flex items-center gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[s.jsx("div",{className:P("w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0 shadow-sm",is?"bg-gradient-to-br from-violet-500 to-purple-600 shadow-violet-500/20":sr?"bg-gradient-to-br from-amber-500 to-orange-600 shadow-amber-500/20":"bg-gradient-to-br from-blue-500 to-indigo-600 shadow-blue-500/20"),children:s.jsx(dl,{size:16,className:"text-white"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("h1",{className:"text-sm font-bold text-content truncate",children:t==null?void 0:t.name}),sr?s.jsxs("span",{className:"text-[7px] px-1.5 py-px rounded font-bold flex items-center gap-0.5 ring-1 bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800",children:[s.jsx(qe,{size:7})," Audit"]}):s.jsx("button",{type:"button",onClick:H=>{H.stopPropagation();const ue=is?"ui":"api";D.mutate({id:e,data:{type:ue}})},title:"Toggle type",className:P("text-[7px] px-1.5 py-px rounded font-bold uppercase ring-1 cursor-pointer transition-colors",is?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800 hover:bg-violet-100 dark:hover:bg-violet-900/30":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800 hover:bg-blue-100 dark:hover:bg-blue-900/30"),children:is?"API":"UI"}),s.jsx("button",{type:"button",onClick:()=>It(!0),className:"p-0.5 rounded text-content-tertiary hover:text-accent transition-colors",children:s.jsx(Hr,{size:10})})]}),Ct&&s.jsx("p",{className:"text-[10px] text-content-tertiary truncate mt-0.5 leading-tight max-w-md",children:Ct})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[y?s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-teal-600 dark:text-teal-400 font-medium px-2 py-1 rounded-lg bg-teal-50 dark:bg-teal-900/20 ring-1 ring-teal-200 dark:ring-teal-800",children:[s.jsx(ae,{size:11,className:"animate-spin"})," Running…"]}):s.jsxs(te,{size:"sm",onClick:o,className:"bg-teal-600 hover:bg-teal-700 text-white border-teal-600",children:[s.jsx(Dt,{size:10})," Run Suite"]}),s.jsxs(te,{size:"sm",onClick:()=>g(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white border-indigo-600",children:[s.jsx(Va,{size:10})," Hooks"]}),s.jsx(ml,{variant:"full",status:(G==null?void 0:G.status)??"not-created",label:"Sync",onClick:T,busy:le.busySuites.get(e)==="create"||le.busySuites.get(e)==="sync"||le.allOp==="create"||le.allOp==="sync"})]})]}),Ee.length>0&&s.jsxs("div",{className:"px-4 py-1.5 border-t border-border/50 flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mr-0.5",children:"Tags"}),s.jsx("button",{type:"button",onClick:()=>re(new Set),className:P("text-[9px] px-2 py-0.5 rounded-md font-medium transition-all",me?"bg-accent text-white shadow-sm shadow-accent/20":"text-content-tertiary hover:text-content-secondary bg-surface-inset hover:bg-surface-inset/80 ring-1 ring-border"),children:"All"}),Ee.map(H=>{const ue=_.has(H);return s.jsx("button",{type:"button",onClick:()=>{re(fe=>{const De=new Set(fe);return ue?De.delete(H):De.add(H),De})},className:P("text-[9px] px-2 py-0.5 rounded-md font-medium transition-all",ue||me?"bg-accent/10 text-accent ring-1 ring-accent/30":"text-content-tertiary bg-surface-inset ring-1 ring-border hover:text-content-secondary"),children:H},H)})]}),s.jsxs("div",{className:"px-4 py-2 bg-surface-inset/40 border-t border-border flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-[120px]",children:[s.jsx(Kn,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-content-tertiary pointer-events-none"}),s.jsx("input",{className:"w-full text-xs border border-border rounded-lg pl-7 pr-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"Search tests…",value:z,onChange:H=>q(H.target.value)})]}),s.jsxs("select",{value:U,onChange:H=>xe(H.target.value),className:"text-xs border border-border rounded-lg px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent bg-surface min-w-[90px]",children:[s.jsx("option",{value:"",children:"All Priority"}),tb.map(H=>s.jsx("option",{value:H,className:"capitalize",children:H.charAt(0).toUpperCase()+H.slice(1)},H))]}),Te&&s.jsx("button",{type:"button",onClick:()=>{q(""),re(new Set),xe("")},className:"p-1 rounded-lg text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})}),s.jsx("div",{className:"w-px h-4 bg-border"}),s.jsx("input",{className:"w-36 text-xs border border-border rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"New test case…",value:r,onChange:H=>a(H.target.value),onKeyDown:H=>H.key==="Enter"&&As()}),s.jsxs(te,{size:"sm",onClick:As,disabled:v.isPending,children:[s.jsx(Rs,{size:10})," Add"]}),s.jsx(te,{size:"sm",variant:"secondary",onClick:()=>k(!0),children:"From Template"}),s.jsx("span",{className:"text-[9px] text-content-tertiary ml-1 tabular-nums flex-shrink-0",children:Te?`${ye.length}/${b.length}`:`${b.length} test${b.length!==1?"s":""}`})]})]}),f?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ae,{size:18,className:"animate-spin text-accent"})}):b.length===0?s.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-surface flex flex-col items-center justify-center py-14 gap-2.5",children:[s.jsx("div",{className:"w-11 h-11 rounded-xl bg-surface-inset flex items-center justify-center",children:s.jsx(qr,{size:20,className:"text-content-tertiary"})}),s.jsx("p",{className:"text-xs font-medium text-content-secondary",children:"No test cases yet"}),s.jsx("p",{className:"text-[10px] text-content-tertiary",children:"Add your first test case using the toolbar above"})]}):ye.length===0?s.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-surface flex flex-col items-center justify-center py-10 gap-2",children:[s.jsx(yy,{size:16,className:"text-content-tertiary"}),s.jsx("p",{className:"text-xs text-content-tertiary",children:"No tests match filters"}),s.jsx("button",{onClick:()=>{q(""),re(new Set),xe("")},className:"text-[10px] text-accent hover:underline",children:"Clear filters"})]}):s.jsxs("div",{className:"space-y-1.5",children:[ye.length>0&&s.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-1",children:[s.jsx("input",{type:"checkbox",className:"rounded border-border text-accent cursor-pointer",checked:R.size===ye.length&&ye.length>0,onChange:H=>{H.target.checked?L(new Set(ye.map(ue=>ue.id))):L(new Set)}}),s.jsx("span",{className:"text-[9px] text-content-tertiary",children:"Select all"})]}),ye.map((H,ue)=>{const fe=H.steps.some(Ne=>Ne.stepType==="api"),De=p.get(H.id),lt=G==null?void 0:G.cases.find(Ne=>Ne.caseId===H.id),Yr=(lt==null?void 0:lt.status)??"not-created",Ml=le.busyCases.get(`${e}:${H.id}`)==="create"||le.busyCases.get(`${e}:${H.id}`)==="sync"||le.busySuites.get(e)==="create"||le.busySuites.get(e)==="sync"||le.allOp==="create"||le.allOp==="sync",ln=R.has(H.id),on=W==null?void 0:W.cases.find(Ne=>Ne.caseId===H.id);return s.jsx("div",{className:P("group rounded-xl border bg-surface hover:border-accent/30 hover:shadow-sm hover:shadow-accent/5 cursor-pointer transition-all",ln?"border-accent/40 bg-accent/[0.02]":"border-border"),onClick:()=>i(H.id),children:s.jsxs("div",{className:"px-3.5 py-2.5 flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",className:"rounded border-border text-accent cursor-pointer flex-shrink-0",checked:ln,onClick:Ne=>Ne.stopPropagation(),onChange:Ne=>{Ne.stopPropagation(),L(nr=>{const cn=new Set(nr);return Ne.target.checked?cn.add(H.id):cn.delete(H.id),M.current=ue,cn})},onClickCapture:Ne=>{if(Ne.shiftKey&&M.current>=0){Ne.preventDefault();const nr=Math.min(M.current,ue),cn=Math.max(M.current,ue);L(Jr=>{const rr=new Set(Jr);return ye.slice(nr,cn+1).forEach(ri=>rr.add(ri.id)),rr})}M.current=ue}}),s.jsx(Dc,{size:11,className:"text-content-tertiary/40 group-hover:text-content-tertiary cursor-grab flex-shrink-0 transition-colors"}),s.jsx("span",{className:"text-[9px] font-mono text-accent font-semibold bg-accent/5 px-1.5 py-0.5 rounded ring-1 ring-accent/10 flex-shrink-0 tabular-nums",children:Os(ue)}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs font-medium text-content truncate",children:H.name}),s.jsx("span",{className:P("text-[7px] px-1 py-px rounded font-bold uppercase flex-shrink-0 ring-1",fe?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":sr?"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800"),children:fe?"API":sr?"Audit":"UI"}),on&&s.jsx(V5,{passRate:on.passRate,runs:on.runs,flaky:on.flaky})]}),s.jsxs("span",{className:"text-[9px] text-content-tertiary tabular-nums flex-shrink-0",children:[H.steps.length," step",H.steps.length!==1?"s":""]}),s.jsx("span",{className:P("text-[8px] px-1.5 py-0.5 rounded capitalize ring-1 flex-shrink-0 font-medium",yx[H.priority]??yx.low),children:H.priority}),(H.tags??[]).length>0&&s.jsx("div",{className:"flex-shrink-0",onClick:Ne=>Ne.stopPropagation(),children:s.jsx(hl,{tags:H.tags})}),(()=>{if(!De)return s.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded ring-1 ring-border text-content-tertiary/60 flex-shrink-0",children:"Never"});const Ne={passed:"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-emerald-200 dark:ring-emerald-800",failed:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-200 dark:ring-red-800",skipped:"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800"};return s.jsx("span",{className:P("text-[8px] px-1.5 py-0.5 rounded capitalize ring-1 flex-shrink-0 font-medium",Ne[De.status]??"ring-border text-content-tertiary"),children:De.status})})(),s.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",onClick:Ne=>Ne.stopPropagation(),children:[s.jsx(Um,{status:Yr,xrayKey:lt==null?void 0:lt.xrayTestId}),s.jsx(ml,{variant:"icon",status:Yr,onClick:()=>S(H.id),busy:Ml})]}),s.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",onClick:Ne=>Ne.stopPropagation(),children:[d.has(H.id)?s.jsx(ae,{size:11,className:"animate-spin text-teal-600 dark:text-teal-400"}):s.jsx("button",{type:"button",onClick:()=>l(H.id),title:"Run",className:"p-1 rounded-md text-teal-600 dark:text-teal-400 hover:bg-teal-50 dark:hover:bg-teal-900/20 transition-colors",children:s.jsx(Dt,{size:11})}),s.jsx("button",{type:"button",disabled:!De,onClick:()=>{De&&window.open(`/allure/${De.allureRunId}`,"_blank")},title:"Report",className:P("p-1 rounded-md transition-colors",De?"text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20":"text-content-tertiary/40 cursor-not-allowed"),children:s.jsx(hs,{size:11})}),s.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),Et(H)},title:"Duplicate",className:"p-1 rounded-md text-content-tertiary hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors",children:s.jsx(Rm,{size:11})}),s.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),E(`Delete "${H.name}"?`,()=>w.mutate(H.id))},title:"Delete",className:"p-1 rounded-md text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(Kt,{size:10})})]}),s.jsx(Ht,{size:11,className:"text-content-tertiary/40 flex-shrink-0"})]})},H.id)})]})]})}),s.jsx(B5,{suiteId:e,open:u,onClose:()=>g(!1)}),s.jsx(h5,{open:j,onClose:()=>k(!1),suiteId:e,onCreated:()=>{}}),s.jsx(Ms,{...N}),R.size>0&&s.jsx(W5,{selectedIds:R,suiteId:e,suites:n,onClear:()=>L(new Set),onDeleted:()=>L(new Set),onMoved:()=>L(new Set)})]})}function J5({suiteId:e,caseId:t,suiteName:n,suiteType:r,onBack:a,onRunCase:i}){const{runningCaseIds:l,caseLastRun:o}=qc(),c=l.has(t),d=o.get(t),{data:x,isLoading:p}=y5(e,t),y=b5(e),b=j5(e,t),f=N5(e,t),v=k5(e,t),{modalProps:w,confirmDelete:h}=Ts(),u=w5(e,t),g=S5(e,t),j=C5(e,t),{data:k}=Jy(e),N=Zy(),E=eb(),R=k==null?void 0:k.cases.find(F=>F.caseId===t),L=Bm(),M=()=>{((R==null?void 0:R.status)??"not-created")==="not-created"?N.mutate({suiteId:e,caseId:t}):E.mutate({suiteId:e,caseId:t})},[W,G]=m.useState(""),[ne,A]=m.useState(!1),[Y,se]=m.useState(""),[le,T]=m.useState("medium"),[S,z]=m.useState([]),[q,_]=m.useState(""),[re,U]=m.useState("none"),[xe,me]=m.useState(""),[Ee,ye]=m.useState(""),[Te,pt]=m.useState(!1),[It,rs]=m.useState(!1),He=m.useRef(null),[Ct,K]=m.useState(!1),[Ke,as]=m.useState(""),[er,tr]=m.useState(""),D=m.useRef(null),[X,je]=m.useState(null),[As,Et]=m.useState(null),[Os,is]=m.useState("steps"),[sr,H]=m.useState(!1),[ue,fe]=m.useState([]),[De,lt]=m.useState([]),[Yr,Ml]=m.useState(["performance","accessibility","seo"]),[ln,on]=m.useState(""),[Ne,nr]=m.useState(""),[cn,Jr]=m.useState(!1),[rr,ri]=m.useState([]),[xb,Qm]=m.useState(!1),[mb,Ym]=m.useState(!1),Kc=m.useRef(null);Qr({"recorder:action":F=>{const oe=F;ri(ee=>[...ee,oe]),setTimeout(()=>{var ee;(ee=Kc.current)==null||ee.scrollTo({top:Kc.current.scrollHeight,behavior:"smooth"})},50)},"recorder:stopped":()=>{Jr(!1)}});const hb=async()=>{try{Qm(!0),ri([]),await Sd.start(),Jr(!0),O.success("Recording started — Shift+Click = assert element, Ctrl+Shift+U = assert URL",{duration:5e3})}catch(F){O.error((F==null?void 0:F.message)||"Failed to start recorder")}finally{Qm(!1)}},pb=async()=>{try{Ym(!0);const F=await Sd.stop();if(Jr(!1),F.actions.length>0){for(const oe of F.actions){const ee=Iw(oe);await b.mutateAsync({instruction:oe.instruction,generatedCode:ee,strategy:"recorder",...oe.soft?{soft:!0}:{}})}O.success(`Added ${F.actions.length} recorded steps with code`)}else O("No actions were recorded")}catch(F){O.error((F==null?void 0:F.message)||"Failed to stop recorder")}finally{Ym(!1)}};m.useEffect(()=>{Sd.status().then(F=>{F.recording&&(Jr(!0),ri(F.actions))}).catch(()=>{})},[]),m.useEffect(()=>{var oe,ee;if(!x)return;G(x.name),se(x.description??""),T(x.priority??"medium"),z([...x.tags]),_(x.timeout?String(x.timeout):"");const F=x.dataSource;F?(U(F.type??"none"),me(F.path??""),ye(F.data?JSON.stringify(F.data,null,2):"")):(U("none"),me(""),ye("")),fe(((oe=x.caseHooks)==null?void 0:oe.before.map(ce=>({id:ce.id,instruction:ce.instruction})))??[]),lt(((ee=x.caseHooks)==null?void 0:ee.after.map(ce=>({id:ce.id,instruction:ce.instruction})))??[]),Ml(x.lighthouseCategories??["performance","accessibility","seo"]),rs(!1),K(!1)},[x==null?void 0:x.id]);const ot=()=>{rs(!0),K(!1)},fb=F=>{F.key==="Enter"&&(F.preventDefault(),Tl())},gb=F=>{const oe=D.current;if(!oe){as(Wc=>Wc+F);return}const ee=oe.selectionStart??Ke.length,ce=oe.selectionEnd??Ke.length,Ft=Ke.slice(0,ee)+F+Ke.slice(ce);as(Ft),setTimeout(()=>{oe.focus(),oe.setSelectionRange(ee+F.length,ee+F.length)},0)},Tl=async()=>{const F=q?parseInt(q,10):void 0;let oe;if(re!=="none")if(oe={type:re},re==="inline")try{oe.data=JSON.parse(Ee)}catch{}else oe.path=xe;const ee={before:ue.map((ce,Ft)=>({...ce,order:Ft})),after:De.map((ce,Ft)=>({...ce,order:Ft}))};await y.mutateAsync({caseId:t,data:{name:W,description:Y,priority:le,tags:S,timeout:F,dataSource:oe,caseHooks:ee,lighthouseCategories:Yr}}),rs(!1),K(!0)},yb=async()=>{It&&await Tl(),i()},Jm=()=>{Ke.trim()&&(b.mutate({instruction:Ke}),as(""))},bb=async F=>{tr(F),await g.mutateAsync(F).finally(()=>tr(""))},Xm=x?`TC-${(x.name||"").replace(/[^a-zA-Z]/g,"").slice(0,3).toUpperCase()||"TST"}-001`:"…";if(p||!x)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ae,{size:18,className:"animate-spin text-accent"})});const dn=[...x.steps].sort((F,oe)=>F.order-oe.order),vb=dn.some(F=>F.stepType==="api"),Zm=r==="audit"||r==="performance";return s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex-shrink-0 bg-surface border-b border-border z-10",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-5 pt-2 pb-1 text-[10px] text-content-tertiary",children:[s.jsxs("button",{onClick:()=>window.location.assign("/tests"),className:"hover:text-accent flex items-center gap-1",children:[s.jsx(by,{size:10})," Suites"]}),s.jsx(Ht,{size:9}),s.jsx("button",{onClick:a,className:"hover:text-accent",children:n}),s.jsx(Ht,{size:9}),s.jsx("span",{className:"text-content-secondary font-semibold font-mono",children:Xm})]}),s.jsxs("div",{className:"px-5 pb-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:ne?s.jsx("input",{ref:He,className:"flex-1 text-sm font-bold text-content bg-transparent border-b-2 border-accent outline-none p-0 pb-px",value:W,onChange:F=>{G(F.target.value),ot()},onBlur:()=>A(!1),onKeyDown:F=>{F.key==="Enter"&&A(!1),F.key==="Escape"&&(G((x==null?void 0:x.name)??""),A(!1))},autoFocus:!0}):s.jsxs("div",{className:"flex items-center gap-1.5 group min-w-0",children:[s.jsx("h1",{className:"text-sm font-bold text-content truncate",children:W||"Untitled Test Case"}),s.jsx("button",{type:"button",onClick:()=>{A(!0),setTimeout(()=>{var F;return(F=He.current)==null?void 0:F.focus()},0)},className:"p-0.5 rounded text-content-tertiary opacity-0 group-hover:opacity-100 hover:bg-surface-inset transition-all",children:s.jsx(Hr,{size:10})})]})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(ml,{variant:"full",status:(R==null?void 0:R.status)??"not-created",onClick:M,busy:L.busyCases.get(`${e}:${t}`)==="create"||L.busyCases.get(`${e}:${t}`)==="sync"||L.busySuites.get(e)==="create"||L.busySuites.get(e)==="sync"||L.allOp==="create"||L.allOp==="sync"}),s.jsxs(te,{variant:"secondary",size:"sm",onClick:Tl,loading:y.isPending,disabled:!It,children:[s.jsx(dx,{size:10})," Save"]}),s.jsxs(te,{size:"sm",onClick:yb,loading:c,disabled:c,children:[!c&&s.jsx(Dt,{size:10})," ",c?"Running…":"Save & Run"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[s.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-mono font-bold bg-teal-50 dark:bg-teal-900/20 text-teal-700 dark:text-teal-400 ring-1 ring-teal-200 dark:ring-teal-800",children:Xm}),c?s.jsxs("span",{className:"flex items-center gap-1 text-[9px] text-teal-600 dark:text-teal-400 font-medium",children:[s.jsx(ae,{size:9,className:"animate-spin"})," Running"]}):(()=>{if(!d)return s.jsx("span",{className:"text-[8px] px-1.5 py-px rounded ring-1 ring-border text-content-tertiary",children:"Never run"});const F={passed:"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 ring-emerald-200 dark:ring-emerald-800",failed:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 ring-red-200 dark:ring-red-800",skipped:"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800"};return s.jsx("span",{className:P("text-[8px] px-1.5 py-px rounded capitalize ring-1",F[d.status]??"ring-border text-content-tertiary"),children:d.status})})(),s.jsx("button",{type:"button",disabled:!d,onClick:()=>{d&&window.open(`/allure/${d.allureRunId}`,"_blank")},className:P("p-0.5 rounded transition-colors",d?"text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20":"text-content-tertiary cursor-not-allowed"),children:s.jsx(hs,{size:11})}),s.jsx(Um,{status:(R==null?void 0:R.status)??"not-created",xrayKey:R==null?void 0:R.xrayTestId}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsx("div",{className:"flex items-center gap-1",children:tb.map(F=>s.jsx("button",{type:"button",onClick:()=>{T(F),ot()},className:P("px-1.5 py-px rounded text-[8px] capitalize font-bold transition-all ring-1",le===F?yx[F]:"ring-transparent text-content-tertiary hover:ring-border"),children:F},F))}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsx(hl,{tags:S,editable:!0,onAdd:F=>{z(oe=>[...oe,F]),ot()},onRemove:F=>{z(oe=>oe.filter(ee=>ee!==F)),ot()}}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Br,{size:9,className:"text-content-tertiary"}),s.jsx("input",{type:"number",min:1e3,step:1e3,className:"w-16 text-[9px] bg-transparent border-b border-dashed border-border px-1 py-px text-content-secondary placeholder:text-content-tertiary focus:outline-none focus:border-accent tabular-nums",placeholder:"30000",value:q,onChange:F=>{_(F.target.value),ot()},onKeyDown:fb}),s.jsx("span",{className:"text-[8px] text-content-tertiary",children:"ms"})]}),s.jsx("div",{className:"w-px h-3.5 bg-border"}),s.jsxs("button",{type:"button",onClick:()=>pt(F=>!F),className:P("flex items-center gap-1 text-[9px] font-medium px-1.5 py-0.5 rounded transition-colors",Te?"text-accent bg-accent/5":"text-content-tertiary hover:text-content-secondary hover:bg-surface-inset"),children:[s.jsx(Va,{size:9})," ",Te?"Less":"More",s.jsx(Nt,{size:8,className:P("transition-transform",Te&&"rotate-180")})]}),It&&s.jsx("span",{className:"text-[8px] text-amber-500 dark:text-amber-400 font-bold ml-auto",children:"● Unsaved"}),Ct&&!It&&s.jsx("span",{className:"text-[8px] text-emerald-500 dark:text-emerald-400 font-bold ml-auto",children:"✓ Saved"})]})]}),Te&&s.jsxs("div",{className:"px-5 pb-3 pt-1 border-t border-border bg-surface-inset/30 animate-fade-in",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-1",children:"Description"}),s.jsx("textarea",{rows:2,className:"w-full text-xs text-content-secondary bg-surface rounded-lg border border-border outline-none resize-none focus:ring-2 focus:ring-accent/30 px-2.5 py-1.5",placeholder:"Add a description…",value:Y,onChange:F=>{se(F.target.value),ot()},onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),Tl())}})]}),s.jsx("div",{children:s.jsx(X5,{type:re,filePath:xe,inlineData:Ee,onTypeChange:F=>{U(F),ot()},onFilePathChange:F=>{me(F),ot()},onInlineChange:F=>{ye(F),ot()}})})]}),Zm&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-border/50",children:[s.jsxs("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-2 flex items-center gap-1.5",children:[s.jsx(qe,{size:9,className:"text-amber-500 dark:text-amber-400"})," Non-Functional Checks (Lighthouse)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[["performance","accessibility","seo"].map(F=>{const oe={performance:"⚡ Performance",accessibility:"♿ Accessibility",seo:"🔍 SEO"},ee=Yr.includes(F);return s.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:ee,onChange:()=>{Ml(ce=>ee?ce.filter(Ft=>Ft!==F):[...ce,F]),ot()},className:"w-3 h-3 rounded accent-amber-600 cursor-pointer"}),s.jsx("span",{className:"text-[10px] text-content-secondary",children:oe[F]})]},F)}),Yr.length===0&&s.jsx("span",{className:"text-[9px] text-amber-600",children:"⚠ No checks selected — Lighthouse will be skipped"})]})]})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center gap-1 px-5 pt-2 pb-0 border-b border-border bg-surface",children:[s.jsx("button",{type:"button",onClick:()=>is("steps"),className:P("px-3 py-1.5 text-xs font-semibold rounded-t-lg transition-colors border-b-2",Os==="steps"?"border-accent text-accent":"border-transparent text-content-tertiary hover:text-content-secondary"),children:"Steps"}),s.jsxs("button",{type:"button",onClick:()=>is("hooks"),className:P("px-3 py-1.5 text-xs font-semibold rounded-t-lg transition-colors border-b-2",Os==="hooks"?"border-accent text-accent":"border-transparent text-content-tertiary hover:text-content-secondary"),children:["Hooks",ue.length+De.length>0&&s.jsx("span",{className:"ml-1 text-[9px] bg-accent/10 text-accent rounded px-1",children:ue.length+De.length})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{type:"button",onClick:()=>H(!0),title:"Step Library",className:"flex items-center gap-1.5 text-[10px] text-content-tertiary hover:text-accent hover:bg-accent/5 px-2 py-1 rounded-lg transition-colors mb-1",children:[s.jsx(cl,{size:11})," Library"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto bg-surface-inset/20",children:s.jsxs("div",{className:"max-w-4xl mx-auto px-5 py-3",children:[Os==="hooks"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-2 border-b border-border bg-surface-inset/30",children:[s.jsx("h3",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest",children:"Before Hooks"}),s.jsx("p",{className:"text-[9px] text-content-tertiary mt-0.5",children:"Run before all steps"})]}),s.jsxs("div",{className:"p-3 space-y-1.5",children:[ue.map((F,oe)=>s.jsxs("div",{className:"flex items-center gap-2 text-xs bg-surface-inset/50 rounded-lg px-3 py-2 border border-border",children:[s.jsx("span",{className:"text-content-tertiary font-mono text-[9px] w-4",children:oe+1}),s.jsx("span",{className:"flex-1 text-content-secondary",children:F.instruction}),s.jsx("button",{type:"button",onClick:()=>{fe(ee=>ee.filter((ce,Ft)=>Ft!==oe)),ot()},className:"p-0.5 rounded text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})})]},F.id)),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("input",{className:"flex-1 text-xs border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"Add before-hook instruction…",value:ln,onChange:F=>on(F.target.value),onKeyDown:F=>{F.key==="Enter"&&ln.trim()&&(fe(oe=>[...oe,{id:crypto.randomUUID(),instruction:ln.trim()}]),on(""),ot())}}),s.jsxs(te,{size:"sm",onClick:()=>{ln.trim()&&(fe(F=>[...F,{id:crypto.randomUUID(),instruction:ln.trim()}]),on(""),ot())},children:[s.jsx(Rs,{size:11})," Add"]})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border bg-surface overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-2 border-b border-border bg-surface-inset/30",children:[s.jsx("h3",{className:"text-[10px] font-bold text-content-tertiary uppercase tracking-widest",children:"After Hooks"}),s.jsx("p",{className:"text-[9px] text-content-tertiary mt-0.5",children:"Run after all steps (always)"})]}),s.jsxs("div",{className:"p-3 space-y-1.5",children:[De.map((F,oe)=>s.jsxs("div",{className:"flex items-center gap-2 text-xs bg-surface-inset/50 rounded-lg px-3 py-2 border border-border",children:[s.jsx("span",{className:"text-content-tertiary font-mono text-[9px] w-4",children:oe+1}),s.jsx("span",{className:"flex-1 text-content-secondary",children:F.instruction}),s.jsx("button",{type:"button",onClick:()=>{lt(ee=>ee.filter((ce,Ft)=>Ft!==oe)),ot()},className:"p-0.5 rounded text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})})]},F.id)),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("input",{className:"flex-1 text-xs border border-border rounded-lg px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary",placeholder:"Add after-hook instruction…",value:Ne,onChange:F=>nr(F.target.value),onKeyDown:F=>{F.key==="Enter"&&Ne.trim()&&(lt(oe=>[...oe,{id:crypto.randomUUID(),instruction:Ne.trim()}]),nr(""),ot())}}),s.jsxs(te,{size:"sm",onClick:()=>{Ne.trim()&&(lt(F=>[...F,{id:crypto.randomUUID(),instruction:Ne.trim()}]),nr(""),ot())},children:[s.jsx(Rs,{size:11})," Add"]})]})]})]})]}),Os==="steps"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(qe,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-accent/50 pointer-events-none"}),s.jsx("input",{ref:D,className:"w-full text-xs border border-border rounded-lg pl-8 pr-3 py-2 focus:outline-none focus:ring-2 focus:ring-accent/30 bg-surface placeholder-content-tertiary shadow-xs",placeholder:"Describe a step in plain English and press Enter…",value:Ke,onChange:F=>as(F.target.value),onKeyDown:F=>F.key==="Enter"&&Jm()})]}),s.jsx(K5,{onInsert:gb}),s.jsxs(te,{size:"sm",onClick:Jm,disabled:b.isPending,className:"border border-transparent",children:[s.jsx(Rs,{size:11})," Add Step"]}),r!=="api"&&(cn?s.jsxs(te,{size:"sm",loading:mb,onClick:pb,className:"border border-transparent bg-gradient-to-b from-red-500 to-red-600 text-white hover:brightness-110 shadow-sm hover:shadow-md focus-visible:ring-red-500 animate-pulse",children:[s.jsx(wy,{size:10,className:"fill-current"})," Stop Recording"]}):s.jsxs(te,{size:"sm",loading:xb,onClick:hb,className:"border border-transparent bg-gradient-to-b from-red-400 to-red-500 text-white hover:brightness-110 shadow-sm hover:shadow-md focus-visible:ring-red-500",children:[s.jsx(dy,{size:10,className:"fill-current"})," Record"]})),s.jsxs(te,{size:"sm",loading:j.isPending,onClick:()=>j.mutate(),className:"border border-transparent bg-gradient-to-b from-emerald-500 to-emerald-600 text-white hover:brightness-110 shadow-sm hover:shadow-md focus-visible:ring-emerald-500",children:[s.jsx(_r,{size:11})," Generate All"]})]}),r!=="api"&&cn&&rr.length>0&&s.jsxs("div",{className:"mb-3 border border-red-300 dark:border-red-700 rounded-xl overflow-hidden bg-red-50 dark:bg-red-950/30",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-red-100 dark:bg-red-900/40 border-b border-red-200 dark:border-red-800",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-red-500"})]}),s.jsxs("span",{className:"text-[11px] font-semibold text-red-700 dark:text-red-300",children:["Recording — ",rr.length," action",rr.length!==1?"s":""," captured"]})]}),s.jsx("span",{className:"text-[10px] text-red-500 dark:text-red-400",children:"Interact with the browser to record steps"})]}),s.jsx("div",{ref:Kc,className:"max-h-40 overflow-y-auto px-3 py-2 space-y-1",children:rr.map((F,oe)=>s.jsxs("div",{className:"flex items-start gap-2 text-[11px]",children:[s.jsx("span",{className:P("flex-shrink-0 w-5 h-5 rounded-full flex items-center justify-center font-mono font-bold text-[9px]",F.action==="assert"?"bg-emerald-200 dark:bg-emerald-800 text-emerald-700 dark:text-emerald-300":"bg-red-200 dark:bg-red-800 text-red-700 dark:text-red-300"),children:oe+1}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[F.action==="assert"&&s.jsx(Oe,{size:10,className:"text-emerald-500 flex-shrink-0"}),s.jsx("span",{className:P("text-content-secondary",F.action==="assert"&&"text-emerald-700 dark:text-emerald-300 font-medium"),children:F.instruction})]})]},F.id))})]}),s.jsx("div",{className:"space-y-1.5",children:dn.length===0?s.jsxs("div",{className:"border border-dashed border-border rounded-xl py-10 text-center bg-surface",children:[s.jsx(qe,{size:20,className:"mx-auto text-content-tertiary/40 mb-2"}),s.jsx("p",{className:"text-xs text-content-tertiary",children:"No steps yet — type an instruction above and press Enter"}),s.jsxs("p",{className:"text-[10px] text-content-tertiary mt-1",children:["Or click ",s.jsx("span",{className:"font-semibold",children:"Generate All"})," to let AI write all steps"]})]}):dn.map((F,oe)=>s.jsx(Z5,{step:F,index:oe,suiteId:e,caseId:t,caseIsApi:vb,suiteIsAudit:Zm,generating:er===F.id,isDragging:X===F.id,isDragOver:As===F.id,onDragStart:()=>je(F.id),onDragOver:()=>Et(F.id),onDrop:()=>{if(!X||X===F.id){je(null),Et(null);return}const ee=dn.map(Wc=>Wc.id),ce=ee.indexOf(X),Ft=ee.indexOf(F.id);ee.splice(ce,1),ee.splice(Ft,0,X),u.mutate(ee),je(null),Et(null)},onDragEnd:()=>{je(null),Et(null)},onDelete:ee=>h("Delete this step?",()=>v.mutate(ee)),onGenerate:ee=>void bb(ee),onSaveInstruction:(ee,ce)=>f.mutate({stepId:ee,instruction:ce}),onSaveTimeout:(ee,ce)=>f.mutate({stepId:ee,timeout:ce}),onSaveRetries:(ee,ce)=>f.mutate({stepId:ee,retries:ce??void 0}),onSaveStepType:(ee,ce)=>f.mutate({stepId:ee,stepType:ce}),onSaveMockUrl:(ee,ce)=>f.mutate({stepId:ee,mockUrl:ce}),onSaveMockResponse:(ee,ce)=>f.mutate({stepId:ee,mockResponse:ce}),onSaveMockStatus:(ee,ce)=>f.mutate({stepId:ee,mockStatus:ce}),onSaveRunAudit:(ee,ce)=>f.mutate({stepId:ee,runAudit:ce},{onSuccess:()=>O.success(ce?"⚡ Audit checkpoint set":"Audit checkpoint removed")}),onSaveSoft:(ee,ce)=>f.mutate({stepId:ee,soft:ce},{onSuccess:()=>O.success(ce?"Soft assertion — test continues on failure":"Hard assertion — test stops on failure")}),onSaveVisualCheck:(ee,ce)=>f.mutate({stepId:ee,visualCheck:ce},{onSuccess:()=>O.success(ce?"👁 Visual regression enabled for this step":"Visual regression disabled for this step")})},F.id))}),dn.length>0&&s.jsxs("p",{className:"text-[9px] text-content-tertiary text-center mt-3",children:[dn.length," step",dn.length!==1?"s":""," · ",dn.filter(F=>{var oe;return!!((oe=F.generatedCode)!=null&&oe.trim())}).length," with code"]})]})]})}),s.jsx(Ms,{...w}),s.jsx(G5,{open:sr,onClose:()=>H(!1),suiteId:e,caseId:t,onInserted:()=>H(!1)})]})}function X5({type:e,filePath:t,inlineData:n,onTypeChange:r,onFilePathChange:a,onInlineChange:i}){const[l,o]=m.useState([]),[c,d]=m.useState([]),[x,p]=m.useState(!1),[y,b]=m.useState(""),[f,v]=m.useState(!1),w=m.useRef(null);m.useEffect(()=>{ea.list().then(o).catch(()=>{})},[]),m.useEffect(()=>{if((e==="json-file"||e==="csv-file")&&t){const j=t.replace(/^data\//,"");ea.get(j).then(k=>{d(k.rows),b(k.raw)}).catch(()=>d([]))}else if(e==="inline"&&n)try{d(JSON.parse(n))}catch{d([])}else d([])},[e,t,n]);const h=async j=>{var N;const k=(N=j.target.files)==null?void 0:N[0];if(k){v(!0);try{const E=await k.text(),R=await ea.upload(k.name,E);a(R.path),r(k.name.endsWith(".csv")?"csv-file":"json-file");const L=await ea.list();o(L),O.success(`Uploaded ${k.name} (${R.rowCount} rows)`)}catch(E){O.error(E instanceof Error?E.message:"Upload failed")}finally{v(!1),j.target.value=""}}},u=async()=>{if((e==="json-file"||e==="csv-file")&&t){const j=t.replace(/^data\//,"");try{await ea.update(j,y);const k=await ea.get(j);d(k.rows),p(!1),O.success("Data file saved")}catch(k){O.error(k instanceof Error?k.message:"Save failed")}}else if(e==="inline"){i(y);try{d(JSON.parse(y))}catch{d([])}p(!1)}},g=c.length>0?Object.keys(c[0]):[];return s.jsxs("div",{children:[s.jsxs("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-1.5 flex items-center gap-1",children:[s.jsx(uy,{size:9})," Data-Driven"]}),s.jsxs("div",{className:"flex items-center gap-1.5 mb-2 flex-wrap",children:[["none","inline","json-file","csv-file"].map(j=>s.jsx("button",{type:"button",onClick:()=>r(j),className:P("px-2 py-0.5 rounded-md text-[9px] font-semibold transition-all ring-1",e===j?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":"ring-border text-content-tertiary hover:bg-surface-inset"),children:j==="none"?"Off":j==="inline"?"Inline":j==="json-file"?"JSON":"CSV"},j)),(e==="json-file"||e==="csv-file")&&s.jsxs("select",{className:"max-w-[160px] text-[10px] border border-border rounded-md px-1.5 py-0.5 focus:outline-none focus:ring-1 focus:ring-accent bg-surface-inset/50",value:t,onChange:j=>a(j.target.value),children:[s.jsx("option",{value:"",children:"Select file…"}),l.filter(j=>e==="csv-file"?j.type==="csv":j.type==="json").map(j=>s.jsx("option",{value:j.path,children:j.name},j.name))]}),e!=="none"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>{var j;return(j=w.current)==null?void 0:j.click()},className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md ring-1 ring-dashed ring-violet-300 dark:ring-violet-700 text-[9px] font-semibold text-violet-600 dark:text-violet-400 hover:bg-violet-50 dark:hover:bg-violet-900/20 transition-colors",children:[f?s.jsx(ae,{size:9,className:"animate-spin"}):s.jsx(Dm,{size:9})," Upload"]}),s.jsx("input",{ref:w,type:"file",accept:".json,.csv",onChange:h,className:"hidden"})]})]}),e==="inline"&&!x&&s.jsx("textarea",{className:"w-full h-14 text-[10px] font-mono border border-border rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-accent/30 mb-2 bg-surface-inset/50",placeholder:'[{"email":"user1@test.com","password":"pass1"}]',value:n,onChange:j=>i(j.target.value)}),e!=="none"&&c.length>0&&!x&&s.jsxs("div",{className:"mb-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsxs("span",{className:"text-[9px] text-content-tertiary",children:[c.length," row",c.length!==1?"s":""]}),s.jsxs("button",{type:"button",onClick:()=>{e==="inline"&&b(n),p(!0)},className:"text-[9px] text-violet-600 dark:text-violet-400 hover:text-violet-800 dark:hover:text-violet-300 font-semibold flex items-center gap-0.5",children:[s.jsx(Hr,{size:8})," Edit"]})]}),s.jsx("div",{className:"overflow-x-auto border border-border rounded-lg",children:s.jsxs("table",{className:"w-full text-[10px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-surface-inset border-b border-border",children:[s.jsx("th",{className:"px-2 py-1 text-left font-bold text-content-tertiary w-6",children:"#"}),g.map(j=>s.jsx("th",{className:"px-2 py-1 text-left font-bold text-violet-600 dark:text-violet-400",children:`{{${j}}}`},j))]})}),s.jsxs("tbody",{children:[c.slice(0,8).map((j,k)=>s.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-surface-inset/50",children:[s.jsx("td",{className:"px-2 py-0.5 text-content-tertiary tabular-nums",children:k+1}),g.map(N=>s.jsx("td",{className:"px-2 py-0.5 text-content-secondary font-mono",children:j[N]},N))]},k)),c.length>8&&s.jsx("tr",{children:s.jsxs("td",{colSpan:g.length+1,className:"px-2 py-1 text-center text-content-tertiary text-[9px] italic",children:["+",c.length-8," more"]})})]})]})})]}),x&&s.jsxs("div",{className:"mb-2",children:[s.jsx("textarea",{className:"w-full h-32 text-[10px] font-mono border border-violet-300 dark:border-violet-700 rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-2 focus:ring-violet-300 dark:focus:ring-violet-700 bg-violet-50/20 dark:bg-violet-900/10 text-content",value:y,onChange:j=>b(j.target.value)}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[s.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-0.5 px-2.5 py-1 rounded-lg bg-violet-600 text-white text-[10px] font-semibold hover:bg-violet-700",children:[s.jsx(Oe,{size:10})," Save"]}),s.jsxs("button",{type:"button",onClick:()=>p(!1),className:"flex items-center gap-0.5 px-2.5 py-1 rounded-lg border border-border text-[10px] text-content-secondary hover:bg-surface-inset",children:[s.jsx(be,{size:10})," Cancel"]})]})]})]})}function Z5({step:e,index:t,caseIsApi:n,suiteIsAudit:r,generating:a,isDragging:i,isDragOver:l,onDragStart:o,onDragOver:c,onDrop:d,onDragEnd:x,onDelete:p,onGenerate:y,onSaveInstruction:b,onSaveTimeout:f,onSaveRetries:v,onSaveStepType:w,onSaveMockUrl:h,onSaveMockResponse:u,onSaveMockStatus:g,onSaveRunAudit:j,onSaveSoft:k,onSaveVisualCheck:N}){var Ct;const[E,R]=m.useState(!1),[L,M]=m.useState(!1),[W,G]=m.useState(e.instruction),[ne,A]=m.useState(e.timeout?String(e.timeout):""),[Y,se]=m.useState(e.retries!=null?String(e.retries):""),[le,T]=m.useState(e.mockUrl??""),[S,z]=m.useState(e.mockResponse??""),[q,_]=m.useState(e.mockStatus?String(e.mockStatus):"200"),re=m.useRef(null),[U,xe]=m.useState(void 0),me=!!((Ct=e.generatedCode)!=null&&Ct.trim()),Ee=e.stepType==="mock",ye=!!e.runAudit,Te=U!==void 0?U:ye,pt=U!==void 0&&U!==ye,It=()=>{U!==void 0&&(j==null||j(e.id,U),xe(void 0))},rs=()=>xe(void 0);m.useEffect(()=>{Ee&&R(!0)},[Ee]),m.useEffect(()=>{A(e.timeout?String(e.timeout):"")},[e.timeout]),m.useEffect(()=>{G(e.instruction)},[e.instruction]),m.useEffect(()=>{var K;L&&((K=re.current)==null||K.focus())},[L]);const He=()=>{const K=W.trim();K&&K!==e.instruction&&b(e.id,K),M(!1)};return s.jsxs("div",{draggable:!0,onDragStart:K=>{K.dataTransfer.effectAllowed="move",o()},onDragOver:K=>{K.preventDefault(),c()},onDrop:K=>{K.preventDefault(),d()},onDragEnd:x,className:P("rounded-lg overflow-hidden transition-all",i?"opacity-40 ring-2 ring-accent":"ring-1 ring-border",l?"ring-2 ring-accent shadow-sm":""),children:[s.jsxs("div",{className:"flex items-start gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 pt-0.5",children:[s.jsx(Dc,{size:11,className:"text-content-tertiary hover:text-content-secondary cursor-grab active:cursor-grabbing"}),s.jsx("span",{className:"w-5 h-5 rounded-md bg-gradient-to-br from-accent to-accent-dark text-white text-[9px] font-bold flex items-center justify-center",children:t+1})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-start gap-1.5 flex-wrap",children:[L?s.jsx("input",{ref:re,className:"flex-1 text-xs text-content border border-accent/40 rounded-md px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-accent/30 min-w-0 bg-surface-inset/50",value:W,onChange:K=>G(K.target.value),onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),He()),K.key==="Escape"&&(G(e.instruction),M(!1))},onBlur:He}):s.jsx("span",{className:"text-xs text-content font-medium flex-1",children:e.instruction}),s.jsx("span",{className:P("text-[8px] px-1 py-px rounded font-bold uppercase flex-shrink-0 ring-1",Ee?"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 ring-purple-200 dark:ring-purple-800":e.stepType==="api"||n?"bg-violet-50 dark:bg-violet-900/20 text-violet-600 dark:text-violet-400 ring-violet-200 dark:ring-violet-800":r?"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800":"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 ring-blue-200 dark:ring-blue-800"),children:Ee?"Mock":e.stepType==="api"||n?"API":r?"Audit":"UI"}),Te&&s.jsxs("span",{className:P("text-[8px] px-1 py-px rounded font-bold flex items-center gap-0.5 ring-1",pt?"bg-amber-50 dark:bg-amber-900/20 text-amber-500 dark:text-amber-400 ring-amber-200 dark:ring-amber-800 opacity-60":"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 ring-amber-200 dark:ring-amber-800"),children:[s.jsx(qe,{size:7}),pt?"Audit*":"Audit"]}),e.lastHealed&&s.jsx("span",{className:"text-[8px] px-1 py-px rounded bg-amber-50 text-amber-600 ring-1 ring-amber-200 font-bold",children:"healed"})]}),me&&!L&&s.jsx("p",{className:"text-[10px] text-content-tertiary mt-px",children:"Code generated ✓"})]}),s.jsxs("select",{value:e.stepType??"ui",onChange:K=>{K.target.value==="mock"&&R(!0),w==null||w(e.id,K.target.value)},className:"text-[10px] border border-border rounded-md px-1 py-0.5 bg-surface-inset/50 text-content-secondary focus:outline-none focus:border-accent flex-shrink-0",children:[s.jsx("option",{value:"ui",children:"UI"}),s.jsx("option",{value:"api",children:"API"}),s.jsx("option",{value:"mock",children:"Mock"})]}),s.jsx("input",{type:"number",min:0,max:5,step:1,className:"w-10 text-[10px] border border-border rounded-md px-1.5 py-0.5 text-content-secondary placeholder:text-content-tertiary focus:outline-none focus:border-accent flex-shrink-0 bg-surface-inset/50",placeholder:"×",title:"Retries",value:Y,onChange:K=>se(K.target.value),onBlur:()=>{const K=Y.trim()?parseInt(Y,10):null,Ke=e.retries??null;K!==Ke&&(v==null||v(e.id,K!=null&&K>=0?K:null))},onKeyDown:K=>{K.key==="Enter"&&K.target.blur()}}),s.jsx("input",{type:"number",min:100,step:100,className:"w-16 text-[10px] border border-border rounded-md px-1.5 py-0.5 text-content-secondary placeholder:text-content-tertiary focus:outline-none focus:border-accent flex-shrink-0 bg-surface-inset/50",placeholder:"ms",value:ne,onChange:K=>A(K.target.value),onBlur:()=>{const K=ne.trim()?parseInt(ne,10):null,Ke=e.timeout??null;K!==Ke&&f(e.id,K&&K>0?K:null)},onKeyDown:K=>{K.key==="Enter"&&K.target.blur()}}),s.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[L?s.jsx("button",{type:"button",onClick:He,className:"p-1 rounded-md text-emerald-500 hover:bg-emerald-50 dark:hover:bg-emerald-900/20 transition-colors",children:s.jsx(Oe,{size:12})}):s.jsx("button",{type:"button",onClick:()=>M(!0),className:"p-1 rounded-md text-content-tertiary hover:text-accent hover:bg-accent/5 transition-colors",children:s.jsx(Hr,{size:11})}),r&&!n&&e.stepType!=="api"&&e.stepType!=="mock"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",title:Te?"Remove Lighthouse audit checkpoint":"Mark as Lighthouse audit checkpoint",onClick:K=>{K.stopPropagation(),xe(!Te)},onMouseDown:K=>K.stopPropagation(),className:P("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[9px] font-bold transition-all cursor-pointer select-none",Te?"text-amber-700 dark:text-amber-400 bg-amber-100 dark:bg-amber-900/30 hover:bg-amber-200 dark:hover:bg-amber-900/40 ring-1 ring-amber-300 dark:ring-amber-700":"text-content-tertiary hover:text-amber-600 dark:hover:text-amber-400 hover:bg-amber-50 dark:hover:bg-amber-900/20 ring-1 ring-transparent hover:ring-amber-200 dark:hover:ring-amber-800"),children:[s.jsx(qe,{size:9}),s.jsx("span",{children:"Audit"})]}),pt&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",title:"Save audit change",onClick:K=>{K.stopPropagation(),It()},onMouseDown:K=>K.stopPropagation(),className:"p-1 rounded-md text-emerald-600 hover:bg-emerald-50 dark:hover:bg-emerald-900/20 transition-colors",children:s.jsx(Oe,{size:11})}),s.jsx("button",{type:"button",title:"Cancel",onClick:K=>{K.stopPropagation(),rs()},onMouseDown:K=>K.stopPropagation(),className:"p-1 rounded-md text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(be,{size:11})})]})]}),/^(?:soft\s+)?(?:verify|check|assert|ensure|confirm)\b/i.test(e.instruction)&&s.jsx("button",{type:"button",title:e.soft?"Soft assertion (test continues on failure) — click to make hard":"Hard assertion (test stops on failure) — click to make soft",onClick:K=>{K.stopPropagation(),k==null||k(e.id,!e.soft)},onMouseDown:K=>K.stopPropagation(),className:P("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[9px] font-bold transition-all cursor-pointer select-none",e.soft?"text-blue-700 dark:text-blue-400 bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-200 dark:hover:bg-blue-900/40 ring-1 ring-blue-300 dark:ring-blue-700":"text-content-tertiary hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 ring-1 ring-transparent hover:ring-blue-200 dark:hover:ring-blue-800"),children:s.jsx("span",{children:e.soft?"Soft":"Hard"})}),e.stepType!=="api"&&s.jsx("button",{type:"button",title:e.visualCheck?"Visual regression enabled — click to disable":"Enable visual regression for this step",onClick:K=>{K.stopPropagation(),N==null||N(e.id,!e.visualCheck)},onMouseDown:K=>K.stopPropagation(),className:P("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[9px] font-bold transition-all cursor-pointer select-none",e.visualCheck?"text-emerald-700 dark:text-emerald-400 bg-emerald-100 dark:bg-emerald-900/30 hover:bg-emerald-200 dark:hover:bg-emerald-900/40 ring-1 ring-emerald-300 dark:ring-emerald-700":"text-content-tertiary hover:text-emerald-600 dark:hover:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20 ring-1 ring-transparent hover:ring-emerald-200 dark:hover:ring-emerald-800"),children:s.jsx(Pl,{size:12})}),s.jsx("button",{type:"button",onClick:()=>y(e.id),disabled:a,className:"p-1 rounded-md text-content-tertiary hover:text-accent hover:bg-accent/5 transition-colors disabled:opacity-40",children:a?s.jsx(ae,{size:12,className:"animate-spin"}):s.jsx(_r,{size:12})}),s.jsx("button",{type:"button",onClick:()=>p(e.id),className:"p-1 rounded-md text-content-tertiary hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:s.jsx(Kt,{size:11})}),s.jsx("button",{type:"button",onClick:()=>R(K=>!K),className:"p-1 rounded-md text-content-tertiary hover:text-content-secondary hover:bg-surface-inset transition-colors",children:E?s.jsx(Nt,{size:12}):s.jsx(Ht,{size:12})})]})]}),E&&s.jsxs("div",{className:"border-t border-border",children:[Ee&&s.jsxs("div",{className:"px-3 py-2.5 bg-violet-50/50 dark:bg-violet-900/10 space-y-1.5 border-b border-border",children:[s.jsx("p",{className:"text-[9px] font-bold text-violet-600 dark:text-violet-400 uppercase tracking-widest",children:"Mock Route"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("input",{className:"flex-1 text-[10px] border border-border rounded px-2 py-1 bg-surface focus:outline-none focus:border-violet-400",placeholder:"URL pattern, e.g. **/api/users",value:le,onChange:K=>T(K.target.value),onBlur:()=>{le!==(e.mockUrl??"")&&(h==null||h(e.id,le))}}),s.jsx("input",{type:"number",className:"w-16 text-[10px] border border-border rounded px-2 py-1 bg-surface focus:outline-none focus:border-violet-400",placeholder:"Status",value:q,onChange:K=>_(K.target.value),onBlur:()=>{const K=parseInt(q,10);!isNaN(K)&&K!==(e.mockStatus??200)&&(g==null||g(e.id,K))}})]}),s.jsx("textarea",{rows:3,className:"w-full text-[10px] border border-border rounded px-2 py-1 bg-surface focus:outline-none focus:border-violet-400 font-mono resize-none",placeholder:'{"key":"value"}',value:S,onChange:K=>z(K.target.value),onBlur:()=>{S!==(e.mockResponse??"")&&(u==null||u(e.id,S))}})]}),me?s.jsx($m,{code:e.generatedCode,maxLines:12,className:"rounded-none"}):s.jsxs("div",{className:"px-3 py-2.5 text-[10px] text-content-tertiary italic bg-surface-inset/30",children:["No code yet — click ",s.jsx(_r,{size:9,className:"inline mb-0.5"})," to generate"]})]})]})}let Gt=null,ji=!1;const bx=new Set;function Ni(){bx.forEach(e=>e())}const ms={subscribe(e){return bx.add(e),()=>{bx.delete(e)}},getSnapshot(){return{job:Gt,showPopup:ji}},start(e,t){const n=`gen-${Date.now()}`;return Gt={id:n,tab:e,label:t,status:"running",startedAt:Date.now()},ji=!1,Ni(),n},done(e,t){Gt&&(Gt={...Gt,status:"done",suiteId:e,suiteName:t},ji=!0,Ni())},error(e){Gt&&(Gt={...Gt,status:"error",error:e},Ni())},dismissPopup(){ji=!1,Ni()},clear(){Gt=null,ji=!1,Ni()},isRunning(){return(Gt==null?void 0:Gt.status)==="running"}};function sb(){const[e,t]=m.useState(()=>ms.getSnapshot());return m.useEffect(()=>ms.subscribe(()=>t(ms.getSnapshot())),[]),e}const eS=[{title:"Login Flow",story:"User logs in with valid credentials, navigates to the dashboard, and verifies that the welcome message is displayed."},{title:"E-Commerce Checkout",story:"User searches for a product, adds it to the cart, proceeds to checkout, and completes the purchase."},{title:"Admin Management",story:"Admin user creates a new account, assigns roles, and verifies the account appears in the user list."}],tS=/^(https?:\/\/.+\/(browse|issue)\/[A-Z][A-Z0-9_]+-\d+|https?:\/\/.+selectedIssue=[A-Z][A-Z0-9_]+-\d+|[A-Z][A-Z0-9_]+-\d+)$/i;function Wp(e){return e.trim()?tS.test(e.trim()):!0}function Vp(e){const t=e.trim();if(!t)return null;const n=t.match(/([A-Z][A-Z0-9_]+-\d+)/i);return n?n[1].toUpperCase():null}function sS(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const i=JSON.parse(t).map(l=>{if(typeof l=="string")return{story:l.trim()};if(typeof l=="object"&&l!==null&&"story"in l){const o=l;return{story:String(o.story).trim(),suiteName:o.suiteName,jiraUrl:o.jiraUrl}}return null}).filter(l=>l!==null&&l.story.length>=10);if(i.length>0)return i}catch{}const n=t.split(/\n\s*---+\s*\n/).map(a=>a.trim()).filter(Boolean);if(n.length>1)return n.map(a=>a.replace(/^\d+\.\s*/,"").trim()).filter(a=>a.length>=10).map(a=>({story:a}));const r=t.split(`
890
890
  `).filter(a=>/^\d+[\.\)]\s/.test(a.trim()));return r.length>1?r.map(a=>a.replace(/^\d+[\.\)]\s*/,"").trim()).filter(a=>a.length>=10).map(a=>({story:a})):t.length>=10?[{story:t}]:[]}function qd({icon:e,title:t,desc:n,tag:r,active:a,gradient:i,onClick:l}){return s.jsxs("button",{type:"button",onClick:l,className:P("relative flex items-start gap-2.5 p-3 rounded-xl border-2 text-left transition-all duration-200 group flex-1 min-w-0",a?"border-accent bg-accent/[0.04] shadow-sm":"border-transparent bg-surface hover:bg-surface-inset/50 hover:border-border"),children:[a&&s.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 -translate-y-px w-8 h-[3px] rounded-full bg-gradient-to-r from-accent to-accent-light"}),s.jsx("div",{className:P("w-5 h-5 rounded flex items-center justify-center transition-all flex-shrink-0",a?i:"bg-surface-inset"),children:s.jsx(e,{size:14,className:a?"text-white":"text-content-tertiary",strokeWidth:1.8})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:P("text-xs font-semibold transition-colors",a?"text-content":"text-content-secondary"),children:t}),r&&s.jsx("span",{className:P("text-[8px] font-bold uppercase tracking-wider px-1 py-px rounded",a?"bg-accent/10 text-accent":"bg-surface-inset text-content-tertiary"),children:r})]}),s.jsx("p",{className:"text-[10px] text-content-tertiary mt-px leading-snug truncate",children:n})]})]})}function Gp({title:e,icon:t,children:n,defaultOpen:r=!1}){const[a,i]=m.useState(r);return s.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"w-full flex items-center justify-between px-4 py-3 bg-surface-inset/50 hover:bg-surface-inset transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(t,{size:13,className:"text-content-tertiary"}),s.jsx("span",{className:"text-xs font-semibold text-content-secondary",children:e})]}),s.jsx(Nt,{size:13,className:P("text-content-tertiary transition-transform duration-200",a&&"rotate-180")})]}),a&&s.jsx("div",{className:"px-4 py-3 border-t border-border bg-surface",children:n})]})}function nS({content:e,onClose:t}){const[n,r]=m.useState(!1);return s.jsxs("div",{className:P("rounded-xl border overflow-hidden transition-all animate-fade-in","border-indigo-200/50 bg-gradient-to-br from-indigo-50/40 via-surface to-violet-50/20"),children:[s.jsxs("div",{className:"px-3 pt-3 pb-1.5 space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-indigo-100/80 text-indigo-700 text-xs font-bold",children:[s.jsx(si,{size:11})," ",e.issueKey]}),s.jsx("span",{className:"px-2 py-0.5 rounded-md bg-surface-inset text-content-secondary text-[10px] font-semibold border border-border",children:e.issueType}),s.jsx("span",{className:"px-2 py-0.5 rounded-md bg-surface-inset text-content-secondary text-[10px] font-semibold border border-border",children:e.status}),s.jsx("span",{className:"px-2 py-0.5 rounded-md bg-amber-50 text-amber-700 text-[10px] font-semibold border border-amber-200/50",children:e.priority})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{type:"button",onClick:()=>r(a=>!a),className:"text-indigo-500 hover:text-indigo-700 text-[10px] font-semibold px-2 py-1 rounded-md hover:bg-indigo-50 transition-colors",children:n?"Less":"More"}),s.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-md text-content-tertiary hover:text-content-secondary hover:bg-surface-inset transition-colors",children:s.jsx(be,{size:13})})]})]}),s.jsx("p",{className:"font-semibold text-content text-xs leading-relaxed",children:e.summary})]}),s.jsxs("div",{className:P("px-3 pb-3 space-y-1.5",n?"overflow-y-auto max-h-[200px]":""),children:[e.description&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-1",children:"Description"}),s.jsx("p",{className:P("text-xs text-content-secondary leading-relaxed whitespace-pre-wrap",!n&&"line-clamp-3"),children:e.description})]}),e.acceptanceCriteria&&n&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-1",children:"Acceptance Criteria"}),s.jsx("p",{className:"text-xs text-content-secondary leading-relaxed whitespace-pre-wrap",children:e.acceptanceCriteria})]}),e.comments.length>0&&n&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-[9px] font-bold text-content-tertiary uppercase tracking-widest mb-1",children:["Comments (",e.comments.length,")"]}),e.comments.map((a,i)=>s.jsx("p",{className:"text-xs text-content-secondary italic mt-1 whitespace-pre-wrap",children:a},i))]}),e.labels.length>0&&s.jsx("div",{className:"flex items-center gap-1 flex-wrap pt-1",children:e.labels.map(a=>s.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-inset text-content-tertiary text-[9px] font-medium border border-border",children:a},a))})]})]})}function rS({pct:e,size:t=64,stroke:n=5}){const r=(t-n)/2,a=2*Math.PI*r,i=a-e/100*a;return s.jsxs("svg",{width:t,height:t,className:"-rotate-90",children:[s.jsx("circle",{cx:t/2,cy:t/2,r,fill:"none",stroke:"currentColor",strokeWidth:n,className:"text-surface-inset"}),s.jsx("circle",{cx:t/2,cy:t/2,r,fill:"none",stroke:"url(#prog-grad)",strokeWidth:n,strokeLinecap:"round",strokeDasharray:a,strokeDashoffset:i,className:"transition-all duration-700 ease-out"}),s.jsx("defs",{children:s.jsxs("linearGradient",{id:"prog-grad",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--color-accent)"}),s.jsx("stop",{offset:"100%",stopColor:"var(--color-accent-light, #818cf8)"})]})})]})}const aS={GET:"bg-blue-500/10 text-blue-600 ring-blue-500/20",POST:"bg-emerald-500/10 text-emerald-600 ring-emerald-500/20",PUT:"bg-amber-500/10 text-amber-600 ring-amber-500/20",DELETE:"bg-red-500/10 text-red-600 ring-red-500/20",PATCH:"bg-violet-500/10 text-violet-600 ring-violet-500/20"},iS=[{icon:jy,label:"--- separator",example:`Story one
891
891
  ---
892
892
  Story two`},{icon:ew,label:"Numbered",example:`1. Story one