@ui-workflow/core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +0,0 @@
1
- import{i as e,t}from"./react-vendor-CH5vucNG.js";import{_ as n,h as r,i,m as a,p as o,r as ee,s}from"./index-KY1IHp8L.js";import te from"./Settings-CITjwtGY.js";var c=e(),l=t(),u=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:6,maximumFractionDigits:6}),d=e=>e==null?`Unknown`:u.format(e);function f({runId:e,waiting:t,onReady:n}){let[r,i]=(0,c.useState)([]),[a,ee]=(0,c.useState)(``),[s,te]=(0,c.useState)(4096),[u,f]=(0,c.useState)(`0.05`),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[_,v]=(0,c.useState)(null),[y,b]=(0,c.useState)(!1),[x,S]=(0,c.useState)(``),[C,ne]=(0,c.useState)(!1),w=(0,c.useRef)(null),T=(0,c.useRef)(!0),E=(0,c.useRef)(n),D=(0,c.useRef)(!1),[re,O]=(0,c.useState)(0);(0,c.useEffect)(()=>{E.current=n},[n]),(0,c.useEffect)(()=>(T.current=!0,o(`/api/providers/attempts?run=${e}`).then(e=>{T.current&&v(e.attempts[0]??null)}).catch(e=>{T.current&&S(e.message)}),()=>{T.current=!1,w.current&&(w.current.value=``)}),[e]),(0,c.useEffect)(()=>{if(!_||![`preparing`,`running`].includes(_.status)||re>=3)return;let e=!0,t=setTimeout(()=>{o(`/api/providers/attempts/${_.id}`).then(async t=>{e&&(S(``),O(0),v(t),t.status===`completed`&&await E.current())}).catch(t=>{e&&(S(t.message+` Refresh generation status if the connection remains unavailable.`),O(e=>e+1))})},document.hidden?1500:500);return()=>{e=!1,clearTimeout(t)}},[_,re]);let k=_?.status===`running`||_?.status===`preparing`;function A(){m(null),g(!1),S(``),w.current&&(w.current.value=``)}async function j(e){b(!0),S(``);try{await e()}catch(e){T.current&&S(e instanceof Error?e.message:`The local operation failed. Review status before retrying.`)}finally{T.current&&b(!1)}}async function M(){await j(async()=>{let e=await o(`/api/providers/models?provider=openrouter`);if(!e.models.length)throw Error(`No compatible text models were returned. Reload the catalogue, or use MCP/manual handoff.`);T.current&&(i(e.models),D.current=!0)})}async function N(){await j(async()=>{let t=await o(`/api/providers/preview`,{runId:e,providerId:`openrouter`,model:a,maxOutputTokens:s,maxCostUsd:Number(u)});T.current&&(m(t),g(!1))})}async function P(){if(!p||!h||!w.current)return;let e=w.current.value;w.current.value=``,await j(async()=>{let t=await o(`/api/providers/start`,{consentId:p.consentId,apiKey:e,approved:!0});T.current&&(v(t),m(null),g(!1))})}async function ie(){_&&await j(async()=>{let e=await o(`/api/providers/attempts/${_.id}`);T.current&&(O(0),v(e),e.status===`completed`&&await E.current())})}return(0,l.jsxs)(`details`,{className:`provider-panel`,open:C||k,onToggle:e=>ne(e.currentTarget.open),children:[(0,l.jsxs)(`summary`,{children:[`Direct generation `,(0,l.jsx)(`span`,{children:`OpenRouter · text only`})]}),(0,l.jsxs)(`div`,{className:`provider-body`,children:[(0,l.jsx)(`h2`,{children:`Generate a staged revision`}),(0,l.jsx)(`p`,{children:`Use a model through OpenRouter, then review its changes here. Your project is sent only after you inspect and approve the request.`}),x&&(0,l.jsx)(`p`,{role:`alert`,className:`error-box`,children:x}),t&&!k&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`provider-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`direct-provider`,children:[`Provider`,(0,l.jsx)(`select`,{id:`direct-provider`,name:`direct-provider`,disabled:!0,children:(0,l.jsx)(`option`,{children:`OpenRouter`})})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`span`,{className:`provider-label`,children:`Model catalogue`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:y,onClick:M,children:y?`Working…`:r.length?`Reload models`:`Load models`})]})]}),(0,l.jsx)(`p`,{className:`field-help`,children:`Loading models contacts OpenRouter without sending project content or a key. Model compatibility is unverified until a real request succeeds. Gemini and Groq are planned.`}),(0,l.jsxs)(`label`,{htmlFor:`direct-model`,children:[`Model`,(0,l.jsx)(`input`,{id:`direct-model`,name:`direct-model`,list:`direct-models`,spellCheck:!1,autoComplete:`off`,value:a,placeholder:D.current?`Choose or type a listed model ID`:`Load the current catalogue first`,disabled:y||!r.length,onChange:e=>{ee(e.target.value),A()}})]}),(0,l.jsx)(`datalist`,{id:`direct-models`,children:r.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,l.jsxs)(`div`,{className:`provider-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`direct-output`,children:[`Maximum output tokens`,(0,l.jsx)(`input`,{id:`direct-output`,name:`direct-output`,type:`number`,min:`256`,max:`16000`,step:`256`,value:s,disabled:y,onChange:e=>{te(e.target.valueAsNumber),A()}})]}),(0,l.jsxs)(`label`,{htmlFor:`direct-budget`,children:[`Request budget (USD)`,(0,l.jsx)(`input`,{id:`direct-budget`,name:`direct-budget`,type:`number`,min:`0.000001`,max:`10`,step:`any`,value:u,disabled:y,onChange:e=>{f(e.target.value),A()}})]})]}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:y||!r.some(e=>e.id===a),onClick:N,children:`Review outgoing request`}),p&&(0,l.jsxs)(`section`,{className:`provider-consent`,"aria-labelledby":`outgoing-title`,children:[(0,l.jsx)(`h3`,{id:`outgoing-title`,children:`What will be sent`}),(0,l.jsxs)(`p`,{children:[(0,l.jsx)(`strong`,{children:p.model}),` through OpenRouter. Includes the selected source text, brief, preservation requirements, guidance and any opted-in project memory.`]}),(0,l.jsxs)(`p`,{className:`provider-estimate`,children:[`Conservative estimate: `,d(p.estimatedCeilingUsd),` ·`,` `,p.bytes.toLocaleString(),` bytes ·`,` `,p.maxOutputTokens.toLocaleString(),` output tokens maximum`]}),(0,l.jsxs)(`p`,{className:`field-help`,children:[p.note,` Keys are retained only for the request. Use a provider-side key limit to enforce a hard spending cap.`,` `,p.requireZdr?`Routing requires an endpoint declaring zero data retention, which may be unavailable for this model.`:`Your provider account’s data-retention policy applies.`]}),(0,l.jsxs)(`details`,{children:[(0,l.jsx)(`summary`,{children:`Inspect exact request content`}),(0,l.jsx)(`pre`,{tabIndex:0,"aria-label":`Exact outgoing request`,children:p.payloadText})]}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{id:`direct-approve`,name:`direct-approve`,type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),disabled:y}),(0,l.jsx)(`span`,{children:`I reviewed this content, model and limits and authorize this one request.`})]}),(0,l.jsxs)(`label`,{htmlFor:`direct-key`,children:[`OpenRouter API key`,(0,l.jsx)(`input`,{ref:w,id:`direct-key`,name:`direct-key`,type:`password`,autoComplete:`off`,spellCheck:!1,disabled:y,placeholder:`Used once; never saved`})]}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:y||!h,onClick:P,children:`Send approved request`})]})]}),_&&(0,l.jsxs)(`section`,{className:`provider-attempt`,"aria-label":`Provider request status`,children:[(0,l.jsx)(`h3`,{children:_.status===`completed`?`Revision ready for review`:_.status===`running`?`Generating your revision…`:`Request ${_.status}`}),(0,l.jsx)(`p`,{role:`status`,children:_.error??(k?`One bounded request is running. You can cancel it here.`:`The original project is unchanged.`)}),(0,l.jsxs)(`p`,{children:[_.usage?.costUsd==null?`Usage and cost unknown until reported by the provider.`:`Provider-reported cost: `+d(_.usage.costUsd),_.usage?.promptTokens==null?``:` · ${_.usage.promptTokens.toLocaleString()} input tokens`,_.usage?.cachedTokens==null?``:` · ${_.usage.cachedTokens.toLocaleString()} cached input`,_.usage?.completionTokens==null?``:` · ${_.usage.completionTokens.toLocaleString()} output tokens`]}),k&&(0,l.jsxs)(`div`,{className:`run-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:y,onClick:ie,children:`Refresh generation status`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>j(async()=>{v(await o(`/api/providers/attempts/${_.id}/cancel`,{}))}),children:`Cancel generation`})]}),_.status===`interrupted`&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:y,onClick:()=>j(async()=>{v(await o(`/api/providers/attempts/${_.id}/recover`,{})),S(`Interrupted lock released. Check upstream activity, then review a new request before retrying.`)}),children:`Release ended request`})]}),(0,l.jsx)(`p`,{className:`field-help`,children:`Three attempts per run. No automatic retries, model fallback or source application. Selected image attachments require the MCP or manual path in this beta.`})]})]})}function p({run:e,task:t}){let[n,r]=(0,c.useState)(null);return(0,l.jsxs)(`details`,{className:`technical analysis-panel`,children:[(0,l.jsx)(`summary`,{children:`Project map & impact analysis`}),(0,l.jsx)(`p`,{children:`See relative imports from this snapshot, or run local Graphify AST analysis over a separate copy of its text files. No model, hooks or project scripts run. This does not expand the file grant or adapter limits.`}),(0,l.jsxs)(`div`,{className:`row-actions`,children:[(0,l.jsx)(`button`,{className:`button subtle`,onClick:()=>t(async()=>r(await o(`/api/runs/${e.id}/project-map`))),children:`Inspect import map`}),(0,l.jsx)(`button`,{className:`button subtle`,disabled:![`waiting-external-response`,`awaiting-human-review`].includes(e.status),onClick:()=>t(async()=>r(await o(`/api/runs/${e.id}/analysis`,{expectedInputHash:e.inputHash}))),children:`Analyze snapshot with Graphify`})]}),n&&(0,l.jsxs)(`div`,{role:`status`,children:[(0,l.jsxs)(`p`,{children:[(0,l.jsx)(`strong`,{children:n.engine===`graphify-code-only`?`Graphify code graph`:`Snapshot import map`}),` `,`· `,n.nodes.length,` nodes · `,n.edges.length,` relationships`]}),(0,l.jsx)(`ul`,{children:n.limits.map((e,t)=>(0,l.jsx)(`li`,{children:e},t))}),(0,l.jsx)(`p`,{children:`Your connected client can read a bounded portion with get_project_map and this run’s grant.`})]})]})}var m=e=>e.split(`
2
- `).map(e=>e.trim()).filter(Boolean);function h(e){if(e.adapter===`static-public-v1`)return`Static website`;let t=e.detectedModules?.framework;return t===`nextjs-app`?`Next.js App Router`:t===`nextjs-pages`?`Next.js Pages Router`:`React / Vite`}function g({value:e,onChange:t,onPicking:n}){let[r,a]=(0,c.useState)(!1),[ee,s]=(0,c.useState)(!1),[te,u]=(0,c.useState)([]),[d,f]=(0,c.useState)(null),[p,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(``),[y,b]=(0,c.useState)(!1),x=(0,c.useRef)(e.project),S=(0,c.useRef)(0),C=(0,c.useRef)(!0);x.current=e.project,(0,c.useEffect)(()=>()=>{C.current=!1,S.current++},[]),(0,c.useEffect)(()=>(n(r),()=>n(!1)),[r,n]),(0,c.useEffect)(()=>{u([]),f(null),v(``),S.current++},[e.project]);async function ne(n=e.project){let r=++S.current;s(!0),v(``);try{let e=await o(`/api/inspect-project`,{project:n});if(!C.current||r!==S.current||x.current.trim()!==n.trim())return;u(e.files),f(e),t({adapter:e.adapter,mode:`manual`});let i=e.detectedLabel||h(e),a=e.adapter===`react-vite-v1`?e.scoping?.autoScoped&&e.scoping.totalCandidates?`${e.files.length} scoped files (of ${e.scoping.totalCandidates})`:`${e.files.length} changeable ${e.files.length===1?`file`:`files`}`:typeof e.fileCount==`number`?`${e.fileCount} ${e.fileCount===1?`file`:`files`}`:`HTML, CSS & JS`;g(`${i} detected · ${a}`)}catch(e){C.current&&r===S.current&&v(e.message)}finally{C.current&&s(!1)}}async function w(){if(r)return;let n=e.project;a(!0),v(``),g(`The Windows folder window is open. Choose a folder or cancel there.`);try{let e=await o(`/api/select-folder`,{initialPath:n.trim()});if(!C.current)return;if(x.current!==n){g(`The typed path was kept. Browse again to choose another folder.`);return}if(e.cancelled||!e.path){g(`Folder selection cancelled. Your project is unchanged.`);return}let r=e.path;x.current=r,t({project:r,mode:`manual`,useMemory:!1,...r===n?{}:{editable:``,creates:``}}),u([]),f(null),g(`Folder selected. Detect its type and files to continue.`)}catch(e){C.current&&(g(``),v(e.message))}finally{C.current&&a(!1)}}let T=m(e.editable),E=m(e.creates),D=d?.detectedModules?.framework?.startsWith(`nextjs`)??!1;return(0,l.jsxs)(`div`,{className:`project-setup`,children:[(0,l.jsxs)(`label`,{htmlFor:`project`,children:[`Project folder `,(0,l.jsx)(`span`,{className:`required`,children:`Required`})]}),(0,l.jsxs)(`div`,{className:`folder-entry`,children:[(0,l.jsx)(`input`,{id:`project`,name:`project`,autoComplete:`off`,spellCheck:!1,required:!0,value:e.project,placeholder:`Paste a folder path, or browse…`,onChange:e=>{g(``),t({project:e.target.value,editable:``,creates:``,useMemory:!1,mode:`manual`})}}),(0,l.jsxs)(`button`,{type:`button`,id:`browse-project`,className:`button subtle`,disabled:r,onClick:w,children:[(0,l.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,l.jsx)(`path`,{d:`M3 7V5h6l2 2h10v13H3z`})}),r?`Folder window open…`:`Browse folders…`]})]}),(0,l.jsx)(`div`,{className:`folder-status`,"aria-live":`polite`,children:r?p:_?(0,l.jsx)(`span`,{className:`folder-error`,children:_}):p}),d&&!_&&!r&&(0,l.jsxs)(`ul`,{className:`project-stack-badges`,"aria-label":`Detected project stack`,children:[(0,l.jsx)(`li`,{className:`stack-badge is-primary`,children:h(d)}),d.detectedModules?.tailwind?.enabled&&(0,l.jsxs)(`li`,{className:`stack-badge`,children:[`Tailwind `,d.detectedModules.tailwind.version??`CSS`]}),d.detectedModules?.shadcnUi?.enabled&&(0,l.jsx)(`li`,{className:`stack-badge`,children:`shadcn/ui`}),d.detectedModules?.testing?.storybook&&(0,l.jsx)(`li`,{className:`stack-badge`,children:`Storybook`}),d.detectedModules?.testing?.vitest&&(0,l.jsx)(`li`,{className:`stack-badge`,children:`Vitest`}),d.detectedModules?.testing?.playwright&&(0,l.jsx)(`li`,{className:`stack-badge`,children:`Playwright`}),d.detectedModules?.testing?.cypress&&(0,l.jsx)(`li`,{className:`stack-badge`,children:`Cypress`}),d.projectRules&&(0,l.jsx)(`li`,{className:`stack-badge is-rules`,children:(0,l.jsx)(`code`,{translate:`no`,children:`.ui-workflow.json`})}),d.adapter===`react-vite-v1`&&(0,l.jsx)(`li`,{className:`stack-badge`,children:d.scoping?.autoScoped&&d.scoping.totalCandidates?`${d.files.length} / ${d.scoping.totalCandidates} scoped files`:`${d.files.length} scoped ${d.files.length===1?`file`:`files`}`}),d.adapter===`static-public-v1`&&typeof d.fileCount==`number`&&(0,l.jsxs)(`li`,{className:`stack-badge`,children:[d.fileCount,` `,d.fileCount===1?`file`:`files`]})]}),(0,l.jsxs)(`div`,{className:`detect-row`,children:[(0,l.jsx)(`button`,{type:`button`,className:`text-button`,disabled:!e.project.trim()||ee||r,onClick:()=>ne(),children:ee?`Checking project…`:`Detect type & files`}),(0,l.jsx)(`span`,{children:`Reads supported files. Runs no project code.`})]}),(0,l.jsx)(`label`,{id:`project-type-label`,children:`Project type`}),(0,l.jsx)(i,{value:e.adapter,onChange:e=>{t({adapter:e,mode:`manual`}),u([]),f(null)}}),e.adapter===`react-vite-v1`?(0,l.jsxs)(`details`,{className:`change-scope`,open:y,onToggle:e=>b(e.currentTarget.open),children:[(0,l.jsx)(`summary`,{children:(0,l.jsxs)(`span`,{children:[`Change permissions`,(0,l.jsxs)(`small`,{children:[T.length?`${T.length} existing ${T.length===1?`file`:`files`} selected`:`Choose files before starting`,E.length?` · ${E.length} new ${E.length===1?`file`:`files`}`:``]})]})}),(0,l.jsxs)(`div`,{className:`scope-content`,children:[(0,l.jsx)(`p`,{children:`Choose what this revision may change in its review copy. Your original files stay intact.`}),te.length?(0,l.jsxs)(`fieldset`,{className:`scope-files`,children:[(0,l.jsx)(`legend`,{children:`Files AI may update`}),te.map(e=>(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:T.includes(e),onChange:n=>t({editable:(n.target.checked?[...T,e]:T.filter(t=>t!==e)).join(`
3
- `)})}),(0,l.jsx)(`code`,{children:e})]},e))]}):(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:!e.project.trim()||ee,onClick:()=>ne(),children:`Load project files`}),(0,l.jsxs)(`details`,{className:`exact-paths`,children:[(0,l.jsx)(`summary`,{children:`Enter exact file paths`}),(0,l.jsx)(`label`,{htmlFor:`editable-paths`,children:`Existing files AI may update`}),(0,l.jsx)(`textarea`,{id:`editable-paths`,rows:3,value:e.editable,onChange:e=>t({editable:e.target.value}),placeholder:D?`app/page.tsx`:`src/main.tsx`}),(0,l.jsx)(`p`,{className:`field-help`,children:`Paths relative to your project, one per line.`})]}),(0,l.jsxs)(`label`,{htmlFor:`create-paths`,children:[`New files AI may add `,(0,l.jsx)(`span`,{className:`optional-label`,children:`Optional`})]}),(0,l.jsx)(`textarea`,{id:`create-paths`,rows:2,value:e.creates,onChange:e=>t({creates:e.target.value}),placeholder:D?`For example: components/TaskSummary.tsx`:`For example: src/TaskSummary.tsx`}),(0,l.jsx)(`p`,{className:`field-help`,children:`One exact path per line. Dependencies, configuration and deletion are outside this revision.`}),(0,l.jsxs)(`div`,{className:`scope-summary`,children:[(0,l.jsxs)(`strong`,{children:[T.length,` existing · `,E.length,` new`]}),(0,l.jsx)(`span`,{children:`Only these paths can be changed.`})]})]})]}):(0,l.jsx)(`p`,{className:`field-help project-support`,children:`Select the public site folder containing index.html.`})]})}var _=()=>({workflowProfile:`auto`,project:``,brief:``,preserve:``,mode:`manual`,adapter:`static-public-v1`,editable:``,creates:``,selected:[],attach:!0,draftKey:null,useMemory:!1,memoryVersion:0});function v(){let e=n.get(`studio-draft`);if(!e||typeof e!=`object`)return _();let t={..._(),...e};for(let e of[`project`,`brief`,`preserve`,`editable`,`creates`])typeof t[e]!=`string`&&(t[e]=``);return t.selected=Array.isArray(t.selected)?t.selected.filter(e=>typeof e==`string`).slice(0,8):[],t.adapter=t.adapter===`react-vite-v1`?`react-vite-v1`:`static-public-v1`,t.mode=t.mode===`mock`?`mock`:`manual`,t}var y={ready:`Ready to resume`,queued:`Queued`,completed:`Completed`,running:`Running`,cancelling:`Cancelling`,cancelled:`Cancelled`,"waiting-external-response":`Waiting for response`,"awaiting-human-review":`Ready for review`,accepted:`Accepted`,rejected:`Rejected`,invalidated:`Needs a fresh revision`,failed:`Needs attention`,passed:`Passed`,"not-run":`Not run`,"not-reviewed":`Not reviewed`,interrupted:`Interrupted`},b=e=>y[e]??e,x=e=>e.split(`
4
- `).map(e=>e.trim()).filter(Boolean),S=[`accepted`,`rejected`,`cancelled`,`invalidated`];function C({kind:e=`plus`}){return(0,l.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,l.jsx)(`path`,{d:e===`settings`?`M9 3h6l1 4 4 2v6l-4 2-1 4H9l-1-4-4-2V9l4-2zM9 12a3 3 0 1 0 6 0 3 3 0 1 0-6 0`:e===`folder`?`M3 7V5h6l2 2h10v13H3z`:e===`arrow`?`M12 19V5m-6 6 6-6 6 6`:e===`play`?`m9 5 10 7-10 7z`:e===`close`?`m6 6 12 12M6 18 18 6`:e===`check`?`m5 12 4 4 10-11`:`M12 5v14M5 12h14`})})}function ne(){return(0,l.jsxs)(`svg`,{viewBox:`0 0 32 32`,"aria-hidden":`true`,children:[(0,l.jsx)(`defs`,{children:(0,l.jsxs)(`linearGradient`,{id:`studio-mark`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,l.jsx)(`stop`,{stopColor:`#ff704d`}),(0,l.jsx)(`stop`,{offset:`.5`,stopColor:`#e862b7`}),(0,l.jsx)(`stop`,{offset:`1`,stopColor:`#6577ef`})]})}),(0,l.jsx)(`path`,{fill:`url(#studio-mark)`,d:`M5 6a3 3 0 0 1 3-3h9c6 0 10 5 10 10v3H16C10 16 5 12 5 6Zm0 9h11c6 0 11 4 11 10a4 4 0 0 1-4 4H5Z`})]})}function w({children:e,onClick:t,id:n,primary:r=!1,disabled:i=!1}){return(0,l.jsx)(`button`,{type:`button`,id:n,className:`button ${r?`primary`:`subtle`}`,onClick:t,disabled:i,children:e})}function T(){let[e,t]=(0,c.useState)(!1),[i,u]=(0,c.useState)(!1),m=(0,c.useRef)(null);function h(){m.current=document.getElementById(`show-settings`),u(!0);let e=new URL(location.href);e.searchParams.set(`panel`,`settings`),e.searchParams.has(`settings`)||e.searchParams.set(`settings`,`connections`),history.replaceState(null,``,e)}function y(){u(!1);let e=new URL(location.href);e.searchParams.delete(`panel`),e.searchParams.delete(`settings`),e.searchParams.set(`view`,M===`settings`?`prepare`:M),history.replaceState(null,``,e),(m.current??document.getElementById(`show-settings`))?.focus()}let[T,re]=(0,c.useState)(null),[O,k]=(0,c.useState)(v),[A,j]=(0,c.useState)(()=>n.get(`studio-theme`)??`system`),[M,N]=(0,c.useState)(`prepare`),[P,ie]=(0,c.useState)(`preview`),[ae,oe]=(0,c.useState)([]),[F,se]=(0,c.useState)(null),[ce,le]=(0,c.useState)(null),[I,L]=(0,c.useState)(null),[R,ue]=(0,c.useState)(!1),[de,fe]=(0,c.useState)({text:``,error:!1}),[z,pe]=(0,c.useState)(!1),[B,me]=(0,c.useState)(null),[V,he]=(0,c.useState)(null),[ge,_e]=(0,c.useState)(``),[ve,H]=(0,c.useState)(!1),[ye,be]=(0,c.useState)(``),[xe,Se]=(0,c.useState)(``),[Ce,we]=(0,c.useState)(`after`),[Te,Ee]=(0,c.useState)(``),[U,De]=(0,c.useState)(()=>n.get(`studio-workspace-motion-v2`)!==!1),[Oe,ke]=(0,c.useState)([]),[Ae,je]=(0,c.useState)(``),[Me,Ne]=(0,c.useState)(``),Pe=(0,c.useRef)(null),W=(0,c.useRef)(0),Fe=(0,c.useRef)(!1),G=(0,c.useRef)(!0),K=(0,c.useRef)(O),Ie=(0,c.useRef)(null),q=(0,c.useRef)(null);K.current=O,q.current=F,Ie.current=B,(0,c.useEffect)(()=>{document.documentElement.dataset.motion=U?`on`:`off`,n.set(`studio-workspace-motion-v2`,U)},[U]),(0,c.useEffect)(()=>{document.documentElement.dataset.view=M;let e=()=>{document.documentElement.dataset.pageHidden=String(document.hidden)};e(),document.addEventListener(`visibilitychange`,e);let t=new IntersectionObserver(e=>{document.documentElement.dataset.auraVisible=String(e[0]?.isIntersecting??!1)}),n=document.querySelector(`.welcome-aura`);return n&&t.observe(n),()=>{t.disconnect(),document.removeEventListener(`visibilitychange`,e)}},[M]);function J(e,t=!1){fe({text:e,error:t})}function Y(e){k(t=>({...t,...e,draftKey:null})),L(null),pe(!0)}function X(e,t=F){N(e);let n=new URL(location.href);n.searchParams.set(`view`,e),n.searchParams.delete(`job`),t&&[`run`,`review`].includes(e)?n.searchParams.set(`run`,t.id):n.searchParams.delete(`run`),history.replaceState(null,``,n)}async function Le(){let e=await o(`/api/runs`);G.current&&oe(e.runs)}async function Z(e,t){let n=++W.current,r=await o(`/api/runs/`+e);if(n===W.current&&G.current&&(se(r),q.current=r,le(null),Se(``),pe(!1),X(t??(r.exportDirectory&&r.status!==`invalidated`?`review`:`run`),r),await Le(),n===W.current&&r.requestPath)){let t=await o(`/api/runs/${e}/content`);if(n!==W.current)return;le(t),Ee(t.proposal?.changes[0]?.path??``)}}async function Q(e){if(!Fe.current){Fe.current=!0,ue(!0),J(``);try{await e()}catch(e){let t=e;if(t.code===`PREFLIGHT_CHANGED`&&L(null),J(t.message,!0),t.runId)try{await Z(t.runId,`run`)}catch{}}finally{Fe.current=!1,G.current&&ue(!1)}}}async function Re(e){let t=e;n.set(`studio-pending-job`,t.id);let r=new URL(location.href);for(r.searchParams.set(`job`,t.id),r.searchParams.set(`view`,`run`),history.replaceState(null,``,r),N(`run`);![`completed`,`failed`,`cancelled`].includes(t.status)&&G.current;)me(t),Ie.current=t,await new Promise(e=>setTimeout(e,250)),t=await o(`/api/jobs/`+t.id);if(G.current){if(me(null),Ie.current=null,n.set(`studio-pending-job`,null),t.runAvailable?await Z(t.runId,t.status===`completed`?void 0:`run`):(L(null),X(`prepare`)),t.status===`failed`)throw Error(t.error??`Local job failed. Check the project again.`);t.status===`cancelled`&&J(`Local work cancelled. Committed outputs were retained.`)}}async function ze(e=!1){let t=K.current.project.trim();if(!t)return;let n=await o(`/api/memory?project=`+encodeURIComponent(t));K.current.project.trim()===t&&(he({...n,project:t}),_e(n.content),K.current.useMemory&&K.current.memoryVersion!==n.version&&k(e=>({...e,useMemory:!1})),e||J(n.version?`Saved project instructions loaded.`:`No saved instructions yet.`))}async function $(){let e=await o(`/api/jobs?`+new URLSearchParams({query:Ae,status:Me}));ke(e.jobs)}(0,c.useEffect)(()=>{n.set(`studio-draft`,{...O,version:2})},[O]),(0,c.useEffect)(()=>{[`system`,`light`,`dark`].includes(A)&&(document.documentElement.dataset.theme=A,n.set(`studio-theme`,A))},[A]),(0,c.useEffect)(()=>{let e=e=>{z&&(e.preventDefault(),e.returnValue=``)};return addEventListener(`beforeunload`,e),()=>removeEventListener(`beforeunload`,e)},[z]),(0,c.useEffect)(()=>{ve?Pe.current?.showModal():Pe.current?.close()},[ve]),(0,c.useEffect)(()=>{if(M!==`jobs`)return;$().catch(e=>J(e.message,!0));let e=setInterval(()=>{document.hidden||$().catch(()=>{})},2e3);return()=>clearInterval(e)},[M,Ae,Me]),(0,c.useEffect)(()=>{G.current=!0,(async()=>{await a();let[e,t]=await Promise.all([o(`/api/context`),o(`/api/runs`)]);if(!G.current)return;re(e),oe(t.runs),K.current.project&&await ze(!0).catch(()=>{});let r=new URLSearchParams(location.search);(r.get(`view`)===`settings`||r.get(`panel`)===`settings`)&&u(!0);let i=r.get(`job`)??n.get(`studio-pending-job`);i?await Q(async()=>Re(await o(`/api/jobs/`+i))):r.get(`run`)?await Z(r.get(`run`),r.get(`view`)===`run`?`run`:void 0):r.get(`view`)===`jobs`?N(`jobs`):r.get(`view`)===`settings`&&N(`prepare`),[`preview`,`changes`,`checks`].includes(r.get(`tab`)??``)&&ie(r.get(`tab`))})().catch(e=>J(`Studio could not connect: ${e.message}. Refresh the local workspace.`,!0));let e=()=>{let e=new URLSearchParams(location.search);u(e.get(`panel`)===`settings`||e.get(`view`)===`settings`),e.get(`run`)?Z(e.get(`run`),e.get(`view`)===`run`?`run`:void 0).catch(e=>J(e.message,!0)):N(e.get(`view`)===`jobs`?`jobs`:`prepare`)};return addEventListener(`popstate`,e),()=>{G.current=!1,W.current++,removeEventListener(`popstate`,e)}},[]);function Be(e=!1){R||(!z||confirm(`Discard the unsaved brief? Existing runs and project files stay intact.`))&&(W.current++,k({..._(),...e&&F?{project:F.project,brief:F.brief,preserve:F.mustPreserve.join(`
5
- `),adapter:F.capabilities.adapter}:{}}),se(null),q.current=null,le(null),Se(``),L(null),he(null),_e(``),pe(!1),J(``),X(`prepare`,null),setTimeout(()=>document.getElementById(`project`)?.focus(),0))}function Ve(){let e=O.draftKey??`revision-${crypto.randomUUID()}`;return O.draftKey||k(t=>({...t,draftKey:e})),{version:1,requestKey:e,workflowProfile:O.workflowProfile,adapter:O.adapter,project:O.project.trim(),brief:O.brief.trim(),mustPreserve:x(O.preserve),mode:O.adapter===`react-vite-v1`?`manual`:O.mode,references:O.selected.map(e=>({selectionId:e,attach:O.attach})),guidance:[],...O.adapter===`react-vite-v1`?{projectPolicy:{editablePaths:x(O.editable),createPaths:x(O.creates)}}:{},limits:{maxAttempts:3,packetBytes:8e5}}}function He(e){e.preventDefault(),Q(async()=>{let e=Ve(),t=O.useMemory&&V?.project===e.project?V.version:0;if(!I){L(await o(`/api/preflight`,{spec:e,memoryVersion:t}));return}let n=await o(`/api/jobs`,{kind:`start`,operationId:`start:${e.requestKey}`,spec:e,memoryVersion:t,expectedInputHash:I.inputHash});pe(!1),L(null),await Re(n)})}function Ue(){(!z||confirm(`Replace the current draft with the sample setup?`))&&Y({..._(),project:T?.demoProject??``,brief:`Change the sample accent while preserving its content and Details link. This is a labelled workflow fixture.`,preserve:`Details link reaches the existing details section
6
- Existing page content stays available`,mode:`mock`})}function We(){return z&&!confirm(`Replace the current draft with the Focus Board pilot setup? Your saved runs remain available.`)?!1:(Y({..._(),project:T?.pilotProject??`C:/Users/ANC/Documents/Me/programming/Web UI/focus-board-pilot`,adapter:`react-vite-v1`,brief:`Improve the task overview with a reusable summary component. Preserve existing task behavior and saved state.`,preserve:`Add, complete and remove tasks
7
- Filters and URL state
8
- Reload persistence and keyboard controls
9
- Mobile layout and storage-unavailable fallback`,editable:`src/main.tsx
10
- src/styles.css`,creates:`src/TaskSummary.tsx`}),!0)}function Ge(e){let t=O.selected.includes(e)?O.selected.filter(t=>t!==e):O.selected.length<8?[...O.selected,e]:O.selected;t===O.selected?J(`Choose up to eight reference images.`,!0):Y({selected:t})}async function Ke(e){if(e.size>12582912)throw Error(`Choose an image up to 12 MiB.`);let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).split(`,`)[1]),r.onerror=()=>n(Error(`Image could not be read`)),r.readAsDataURL(e)}),n=await o(`/api/references`,{name:e.name,base64:t});re(e=>e&&{...e,references:[...e.references,n]}),O.selected.length<8&&Y({selected:[...O.selected,n.id]}),J(`Image saved locally. Verify its rights before production reuse.`)}async function qe(e){e.preventDefault(),Q(async()=>{if(!ye.trim())throw Error(`Paste a model response or choose a JSON file.`);let e=[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(ye)))].map(e=>e.toString(16).padStart(2,`0`)).join(``).slice(0,24);await Re(await o(`/api/jobs`,{kind:`resume`,operationId:`response:${F.id}:${e}`,runId:F.id,responseText:ye}))})}async function Je(){confirm(`Cancel this local work? Its outputs stay available, but a cancelled run cannot resume.`)&&(Ie.current?await o(`/api/jobs/${Ie.current.id}/cancel`,{}):q.current&&(await o(`/api/runs/${q.current.id}/cancel`,{}),await Z(q.current.id,`run`)))}function Ye(e,t=!1){ie(e);let n=new URL(location.href);n.searchParams.set(`tab`,e),history.replaceState(null,``,n),t&&document.getElementById(`tab-`+e)?.focus()}function Xe(e){return(0,l.jsxs)(`button`,{className:`reference-item`,type:`button`,"data-reference":e.id,"aria-pressed":O.selected.includes(e.id),disabled:!e.available||R,title:e.title,onClick:()=>Ge(e.id),children:[(0,l.jsx)(`img`,{src:e.imageURL,alt:e.title,width:e.width,height:e.height,loading:`lazy`}),(0,l.jsx)(`span`,{children:e.title.replace(/ via Refero:.*/,``)})]},e.id)}let Ze=T?.references.filter(e=>O.selected.includes(e.id))??[],Qe=[...Ze,...T?.references.filter(e=>!O.selected.includes(e.id)&&[`refero-figma`,`refero-raycast`,`bold-portfolio`,`creative-portfolio`].includes(e.id))??[]].slice(0,4),$e=!!F?.acceptance?.decision,et=F?S.includes(F.status):!1,tt=ce?.proposal?.changes.find(e=>e.path===Te);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`a`,{className:`skip`,href:`#workspace`,children:`Skip to workspace`}),(0,l.jsxs)(`div`,{className:`shell`,children:[(0,l.jsxs)(`aside`,{className:`sidebar`,"aria-label":`Workspace navigation`,children:[(0,l.jsxs)(`a`,{className:`brand`,href:`/`,id:`brand`,onClick:e=>{e.preventDefault(),Be()},children:[(0,l.jsx)(ne,{}),(0,l.jsxs)(`span`,{children:[`Studio`,(0,l.jsx)(`span`,{className:`brand-sub`,children:`Your design workspace`})]})]}),(0,l.jsxs)(`button`,{className:`new-button`,id:`new-run`,onClick:()=>Be(),disabled:R,children:[(0,l.jsx)(C,{}),`New revision`]}),(0,l.jsxs)(`button`,{className:`rail-link`,id:`show-jobs`,"aria-current":M===`jobs`?`page`:void 0,onClick:()=>X(`jobs`),children:[(0,l.jsx)(C,{}),`Jobs`,` `,(0,l.jsx)(`span`,{id:`queued-count`,children:Oe.filter(e=>[`queued`,`running`].includes(e.status)).length||``})]}),(0,l.jsxs)(`button`,{className:`rail-link`,id:`show-settings`,"aria-current":i?`page`:void 0,onClick:h,children:[(0,l.jsx)(C,{kind:`settings`}),`Settings`]}),(0,l.jsxs)(`details`,{className:`recent`,children:[(0,l.jsx)(`summary`,{children:`History`}),(0,l.jsx)(`nav`,{id:`recent-runs`,"aria-label":`Recent revisions`,children:ae.filter(e=>e.category===`project`).length?ae.filter(e=>e.category===`project`).slice(0,4).map(e=>(0,l.jsxs)(`a`,{href:`/?run=${e.id}&view=review`,"data-run":e.id,"aria-current":F?.id===e.id?`page`:void 0,onClick:t=>{t.ctrlKey||t.metaKey||(t.preventDefault(),(!z||confirm(`Leave the unsaved brief?`))&&Z(e.id).catch(e=>J(e.message,!0)))},children:[(0,l.jsx)(`strong`,{children:e.title??e.requestKey}),(0,l.jsxs)(`small`,{children:[b(e.status),` ·`,` `,new Date(e.updatedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`})]})]},e.id)):(0,l.jsx)(`p`,{className:`rail-empty`,children:`Your local revisions will appear here.`})})]}),(0,l.jsxs)(`div`,{className:`rail-bottom`,children:[(0,l.jsxs)(`span`,{className:`local-mark`,children:[(0,l.jsx)(`span`,{className:`status-dot`}),`Local workspace`]}),(0,l.jsxs)(`p`,{children:[`Source is shared only with your approval.`,(0,l.jsx)(`br`,{}),`AI requests require your approval.`]}),(0,l.jsx)(`label`,{htmlFor:`theme`,children:`Appearance`}),(0,l.jsxs)(`select`,{id:`theme`,value:A,onChange:e=>j(e.target.value),children:[(0,l.jsx)(`option`,{value:`system`,children:`System`}),(0,l.jsx)(`option`,{value:`light`,children:`Light`}),(0,l.jsx)(`option`,{value:`dark`,children:`Dark`})]})]})]}),(0,l.jsxs)(`div`,{className:`main-shell`,children:[(0,l.jsxs)(`header`,{className:`topbar`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`span`,{children:`Workspace`}),(0,l.jsx)(`span`,{className:`slash`,children:`/`}),(0,l.jsx)(`strong`,{id:`crumb`,children:M===`prepare`?`New revision`:M===`run`?`Run progress`:M===`review`?`Review revision`:M===`settings`?`Settings`:`Local jobs`})]}),(0,l.jsx)(`div`,{className:`topbar-actions`,children:(0,l.jsx)(`span`,{className:`prototype`,children:`Local prototype`})})]}),(0,l.jsxs)(`main`,{id:`workspace`,tabIndex:-1,"aria-busy":R,children:[(0,l.jsx)(`nav`,{className:`step-nav`,"aria-label":`Revision steps`,hidden:M===`jobs`||M===`settings`,children:[`prepare`,`run`,`review`].map((e,t)=>(0,l.jsxs)(`button`,{"data-step":e,"aria-current":M===e?`step`:void 0,disabled:e===`run`?!F&&!B:e===`review`&&!F?.revisionId,onClick:()=>X(e),children:[(0,l.jsx)(`span`,{children:t+1}),e[0].toUpperCase()+e.slice(1)]},e))}),(0,l.jsx)(`div`,{id:`notice`,className:`notice ${de.error?`error`:``}`,role:`status`,"aria-live":`polite`,hidden:!de.text,children:de.text}),(0,l.jsxs)(`section`,{id:`prepare-view`,className:`view`,hidden:M!==`prepare`,children:[(0,l.jsx)(`div`,{className:`welcome-aura`,"aria-hidden":`true`}),(0,l.jsx)(s,{motion:U,active:M===`prepare`&&!i}),(0,l.jsxs)(`form`,{id:`prepare-form`,onSubmit:He,inert:R,children:[(0,l.jsxs)(`div`,{className:`brief-composer`,children:[(0,l.jsx)(`label`,{className:`sr-only`,htmlFor:`brief`,children:`What would you like to change?`}),(0,l.jsx)(`textarea`,{id:`brief`,name:`brief`,required:!0,maxLength:12e3,rows:3,value:O.brief,onChange:e=>Y({brief:e.target.value}),placeholder:`Describe the interface you have in mind…`}),(0,l.jsxs)(`div`,{className:`composer-tools`,children:[(0,l.jsx)(`button`,{type:`button`,className:`composer-add`,"aria-label":`Add visual references`,onClick:()=>H(!0),children:(0,l.jsx)(C,{})}),(0,l.jsx)(`span`,{id:`composer-mode`,children:O.mode===`mock`?`Sample revision`:`Codex or Claude · Your choice`}),(0,l.jsx)(`span`,{className:`composer-local`,children:`Local only`}),(0,l.jsx)(`button`,{type:`button`,className:`composer-next`,"aria-label":`Review project setup`,onClick:()=>document.getElementById(`project`)?.focus(),children:(0,l.jsx)(C,{kind:`arrow`})})]})]}),(0,l.jsxs)(`div`,{className:`quick-actions`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`quick-action`,onClick:()=>document.getElementById(`project`)?.focus(),children:[(0,l.jsx)(C,{kind:`folder`}),`Choose a project`]}),(0,l.jsxs)(`button`,{type:`button`,className:`quick-action`,id:`use-sample`,onClick:Ue,children:[(0,l.jsx)(C,{kind:`play`}),`Try the sample`]}),(0,l.jsx)(`button`,{type:`button`,className:`quick-action`,id:`use-pilot`,onClick:We,children:`Open React pilot`}),(0,l.jsx)(`button`,{type:`button`,className:`quick-action`,onClick:()=>{let e=document.getElementById(`memory-details`);e.open=!0,document.getElementById(`memory-text`)?.focus()},children:`Project memory`})]}),(0,l.jsxs)(`div`,{className:`prepare-grid`,children:[(0,l.jsxs)(`div`,{className:`editor-panel`,children:[(0,l.jsxs)(`section`,{className:`form-section`,children:[(0,l.jsxs)(`div`,{className:`section-heading`,children:[(0,l.jsx)(`h2`,{children:`Your project`}),(0,l.jsx)(`span`,{className:`quiet-label`,children:`Originals stay intact`})]}),(0,l.jsx)(g,{value:O,onPicking:t,onChange:e=>{Y(e),e.project!==void 0&&he(null)}}),(0,l.jsxs)(`div`,{className:`preserve-section`,children:[(0,l.jsx)(`label`,{htmlFor:`preserve`,children:`What must keep working?`}),(0,l.jsx)(`p`,{children:`Keep the essentials intact. Choose a suggestion or describe anything specific.`}),(0,l.jsx)(`textarea`,{id:`preserve`,name:`preserve`,rows:Math.min(8,Math.max(4,x(O.preserve).length+1)),value:O.preserve,onChange:e=>Y({preserve:e.target.value}),placeholder:`Navigation, keyboard focus, existing content…`}),(0,l.jsx)(ee,{value:O.preserve,onChange:e=>Y({preserve:e})}),(0,l.jsx)(`p`,{className:`field-help`,children:`One item per line.`})]})]}),(0,l.jsxs)(`details`,{className:`workflow-options`,children:[(0,l.jsxs)(`summary`,{children:[`Workflow focus ·`,` `,O.workflowProfile===`auto`?`From your brief`:O.workflowProfile===`ai-search`?`AI search`:O.workflowProfile===`seo-ai-search`?`SEO + AI search`:O.workflowProfile===`architecture`?`Project map`:O.workflowProfile===`seo`?`SEO`:`Interface & behavior`]}),(0,l.jsxs)(`div`,{className:`workflow-select`,children:[(0,l.jsx)(`label`,{htmlFor:`workflow-profile`,children:`Workflow`}),(0,l.jsxs)(`select`,{id:`workflow-profile`,value:O.workflowProfile,onChange:e=>Y({workflowProfile:e.target.value}),children:[(0,l.jsx)(`option`,{value:`auto`,children:`Choose from my brief`}),(0,l.jsx)(`option`,{value:`ui`,children:`Interface & behavior`}),(0,l.jsx)(`option`,{value:`seo`,children:`SEO`}),(0,l.jsx)(`option`,{value:`ai-search`,children:`AI search / AEO / GEO`}),(0,l.jsx)(`option`,{value:`seo-ai-search`,children:`SEO + AI search`}),(0,l.jsx)(`option`,{value:`architecture`,children:`Project map & impact analysis`})]})]})]}),(0,l.jsxs)(`details`,{id:`memory-details`,className:`memory-details`,children:[(0,l.jsxs)(`summary`,{children:[(0,l.jsx)(`span`,{children:`Project memory`}),(0,l.jsx)(`span`,{id:`memory-state`,children:V?V.version?`Saved v${V.version}`:`No saved instructions`:`Not loaded`})]}),(0,l.jsx)(`p`,{children:`Explicit project instructions, saved locally and selected by version.`}),(0,l.jsx)(`label`,{htmlFor:`memory-text`,children:`Project instructions`}),(0,l.jsx)(`textarea`,{id:`memory-text`,rows:4,maxLength:8e3,value:ge,onChange:e=>_e(e.target.value)}),(0,l.jsxs)(`div`,{className:`memory-actions`,children:[(0,l.jsx)(w,{onClick:()=>Q(()=>ze()),children:`Load saved`}),(0,l.jsx)(w,{onClick:()=>Q(async()=>{let e=O.project.trim(),t=await o(`/api/memory`,{project:e,content:ge,expectedVersion:V?.project===e?V.version:0});he(t),Y({useMemory:!0,memoryVersion:t.version}),J(`Project instructions saved locally.`)}),children:`Save instructions`})]}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{id:`use-memory`,type:`checkbox`,checked:O.useMemory,onChange:e=>Y({useMemory:e.target.checked,memoryVersion:V?.version??0})}),(0,l.jsx)(`span`,{children:`Include the saved version in this handoff`})]}),(0,l.jsx)(`p`,{className:`field-help`,children:`Unsaved edits aren’t included.`})]}),(0,l.jsxs)(`div`,{className:`handoff-explainer`,children:[(0,l.jsx)(`strong`,{children:O.mode===`mock`?`You’re trying a sample`:`Works with your AI client`}),O.mode===`mock`?`A sample response shows the review flow. Choose your own folder to work on a real project.`:`After setup, send the handoff to Codex or Claude, then review the returned changes here.`]})]}),(0,l.jsxs)(`aside`,{className:`reference-panel`,children:[(0,l.jsxs)(`div`,{className:`section-heading`,children:[(0,l.jsx)(`h2`,{children:`Visual references`}),(0,l.jsx)(`span`,{className:`quiet-label`,children:`Optional`})]}),(0,l.jsx)(`p`,{children:`Borrow a direction, bring your own, or start with words.`}),(0,l.jsxs)(`div`,{className:`reference-toolbar`,children:[(0,l.jsx)(`label`,{className:`upload-button`,htmlFor:`reference-upload`,children:`Upload image`}),(0,l.jsx)(`input`,{id:`reference-upload`,className:`file-input`,type:`file`,accept:`image/png,image/jpeg,image/webp,image/avif`,onChange:e=>{let t=e.target.files?.[0];t&&Q(()=>Ke(t)),e.target.value=``}}),(0,l.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>H(!0),children:`Browse library`})]}),(0,l.jsx)(`div`,{id:`reference-grid`,className:`reference-grid`,children:Qe.map(Xe)}),(0,l.jsx)(`p`,{id:`selection-count`,children:O.selected.length?`${O.selected.length} references selected`:`No references selected`}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{id:`attach-images`,type:`checkbox`,checked:O.attach,onChange:e=>Y({attach:e.target.checked})}),(0,l.jsx)(`span`,{children:`Include selected images in the local handoff`})]}),(0,l.jsx)(`p`,{className:`field-help`,children:`Private inspiration only. Verify rights before production reuse.`}),(0,l.jsx)(`ul`,{id:`selected-provenance`,hidden:!Ze.length,children:Ze.map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`strong`,{children:e.title}),(0,l.jsxs)(`details`,{children:[(0,l.jsx)(`summary`,{children:`Source & rights`}),(0,l.jsx)(`p`,{children:e.provenance}),(0,l.jsx)(`p`,{children:e.reuse})]})]},e.id))})]})]}),I&&(0,l.jsxs)(`div`,{id:`preflight`,className:`preflight`,children:[(0,l.jsx)(`h3`,{children:`Ready to start`}),(0,l.jsxs)(`p`,{children:[I.files,` supported files · `,I.references,` references ·`,` `,O.mode===`mock`?`Labelled sample fixture`:`Manual handoff`]}),(0,l.jsxs)(`p`,{children:[(I.contextBytes/1024).toFixed(1),` KiB context`,I.memoryVersion?` · Project memory v${I.memoryVersion}`:``,` · `,I.adapter]})]}),(0,l.jsxs)(`footer`,{className:`form-footer`,children:[(0,l.jsx)(`p`,{children:`A separate review copy. A decision you control.`}),(0,l.jsx)(`button`,{className:`button primary`,id:`prepare-submit`,type:`submit`,disabled:!T||R||e,children:e?`Choose a folder…`:R?`Working…`:I?`Start local run`:`Check project`})]})]}),(0,l.jsxs)(`div`,{className:`support-note`,children:[(0,l.jsx)(`strong`,{children:`Static sites and scoped React/Vite revisions.`}),(0,l.jsx)(`span`,{children:`New source/assets stay in a separate export. No original-file application. MCP access is external-client driven.`})]})]}),(0,l.jsxs)(`section`,{id:`run-view`,className:`view`,hidden:M!==`run`,children:[(0,l.jsxs)(`div`,{className:`page-heading`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{id:`run-heading`,children:B?B.status===`queued`?`Queued on this machine.`:`Working on your revision.`:F?.status===`waiting-external-response`?`Your handoff is ready.`:F?.status===`awaiting-human-review`?`Ready for your review.`:`${b(F?.status??`ready`)}.`}),(0,l.jsx)(`p`,{id:`run-description`,children:F?.mode===`mock`?`Sample fixture · deterministic change, no AI generation.`:`Staged workflow · direct generation, an MCP client or a manual response.`})]}),(0,l.jsx)(w,{id:`refresh-run`,disabled:!F||R,onClick:()=>Q(()=>Z(F.id,`run`)),children:`Refresh status`})]}),(0,l.jsx)(`div`,{id:`run-error`,className:`error-box`,role:`alert`,hidden:!F?.error,children:F?.error}),(0,l.jsxs)(`div`,{className:`run-layout`,children:[(0,l.jsxs)(`section`,{className:`stage-panel`,children:[(0,l.jsx)(`h2`,{children:`Run progress`}),(0,l.jsx)(`ol`,{id:`stage-list`,className:`stage-list`,children:(B?[{stage:B.kind===`start`?`Prepare revision`:`Resume revision`,status:B.status}]:F?.stages??[]).map((e,t)=>(0,l.jsxs)(`li`,{"data-status":e.status,children:[(0,l.jsx)(`span`,{children:e.status===`passed`?(0,l.jsx)(C,{kind:`check`}):t+1}),(0,l.jsx)(`strong`,{children:{packet:`Project & context`,proposal:`Change proposal`,review:`Separate review copy`,export:`Portable export`}[e.stage]??e.stage}),(0,l.jsx)(`span`,{className:`state-label ${e.status}`,children:b(e.status)})]},e.stage))}),(0,l.jsx)(`p`,{className:`field-help`,children:`Committed stages are separate from checks and design approval.`}),(0,l.jsxs)(`div`,{className:`run-actions`,children:[(0,l.jsx)(w,{id:`cancel-run`,disabled:!F&&!B||et,onClick:()=>Je().catch(e=>J(e.message,!0)),children:`Cancel run`}),F?.exportDirectory&&(0,l.jsx)(w,{primary:!0,id:`go-review`,onClick:()=>X(`review`),children:`Review revision`}),F&&[`failed`,`ready`].includes(F.status)&&(0,l.jsx)(w,{id:`retry-run`,onClick:()=>Q(async()=>Re(await o(`/api/jobs`,{kind:`resume`,operationId:`resume:${F.id}:${F.attempts.length}`,runId:F.id}))),children:`Resume run`})]}),F&&(0,l.jsx)(f,{runId:F.id,waiting:F.status===`waiting-external-response`,onReady:()=>Z(F.id,`review`)},F.id)]}),F?.mode===`manual`&&F.requestPath&&!F.revisionId&&!et&&!B&&(0,l.jsxs)(`section`,{className:`handoff-panel`,id:`handoff-panel`,children:[(0,l.jsxs)(`div`,{className:`section-heading`,children:[(0,l.jsx)(`h2`,{children:`Continue with your model`}),(0,l.jsx)(`span`,{className:`mode-badge`,children:`MCP or manual`})]}),(0,l.jsx)(`p`,{children:`Inspect the private context, share only approved content, and return the structured response. A Studio run does not start Codex’s model.`}),(0,l.jsx)(w,{primary:!0,onClick:()=>Q(()=>r(F.id,`handoff`)),children:`Download handoff .zip`}),(0,l.jsx)(E,{run:F,task:Q,refresh:()=>Z(F.id,`run`)}),(0,l.jsxs)(`form`,{id:`response-form`,onSubmit:qe,children:[(0,l.jsx)(`label`,{htmlFor:`response-text`,children:`Model response`}),(0,l.jsx)(`textarea`,{id:`response-text`,rows:6,spellCheck:!1,value:ye,onChange:e=>be(e.target.value),placeholder:`Paste the structured JSON response…`}),(0,l.jsxs)(`div`,{className:`response-actions`,children:[(0,l.jsx)(`label`,{className:`upload-button`,htmlFor:`response-file`,children:`Choose JSON file`}),(0,l.jsx)(`input`,{id:`response-file`,className:`file-input`,type:`file`,accept:`application/json,.json`,onChange:e=>{let t=e.target.files?.[0];t&&Q(async()=>{if(t.size>524288)throw Error(`Response exceeds 512 KiB`);be(await t.text())})}}),(0,l.jsx)(`button`,{className:`button primary`,disabled:R,children:`Import & resume`})]})]})]})]}),(0,l.jsx)(`div`,{children:F?.requestPath&&(0,l.jsx)(p,{run:F,task:Q},F.id)}),(0,l.jsxs)(`details`,{className:`technical`,children:[(0,l.jsx)(`summary`,{children:`Run details`}),(0,l.jsx)(`dl`,{id:`run-details`,children:Object.entries({Run:F?.id??B?.id,Revision:F?.revisionId??`Not created`,Project:F?.project,Integrity:F?.integrity,Output:F?.exportDirectory??`Not yet exported`}).map(([e,t])=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`dt`,{children:e}),(0,l.jsx)(`dd`,{children:t})]},e))})]})]}),(0,l.jsxs)(`section`,{id:`review-view`,className:`view`,hidden:M!==`review`,children:[(0,l.jsxs)(`div`,{className:`page-heading`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{id:`review-heading`,children:$e?`Revision ${F?.acceptance?.decision}.`:`Review the revision.`}),(0,l.jsx)(`p`,{id:`review-summary`,children:ce?.proposal?.summary??F?.brief}),F?.providerAttempts?.filter(e=>e.revisionId===F.revisionId&&e.status===`completed`).map(e=>(0,l.jsxs)(`p`,{className:`field-help`,children:[`Generated through OpenRouter · `,e.model,` ·`,` `,e.usage?.costUsd==null?`Usage and cost unknown`:`Provider-reported cost: `+d(e.usage.costUsd),e.usage?.cachedTokens==null?``:` · ${e.usage.cachedTokens.toLocaleString()} cached input tokens`]},e.id))]}),(0,l.jsx)(w,{id:`download-export`,disabled:!F?.exportDirectory||F.status===`invalidated`||R,onClick:()=>Q(()=>r(F.id,`export`)),children:`Download review export`})]}),(0,l.jsxs)(`div`,{className:`review-layout`,children:[(0,l.jsxs)(`section`,{className:`comparison`,children:[(0,l.jsx)(`div`,{className:`tabbar`,role:`tablist`,"aria-label":`Review view`,children:[`preview`,`changes`,`checks`].map((e,t)=>(0,l.jsx)(`button`,{role:`tab`,id:`tab-`+e,"aria-controls":`panel-`+e,"aria-selected":P===e,tabIndex:P===e?0:-1,onClick:()=>Ye(e),onKeyDown:e=>{[`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key)&&(e.preventDefault(),Ye([`preview`,`changes`,`checks`][e.key===`Home`?0:e.key===`End`?2:(t+(e.key===`ArrowRight`?1:2))%3],!0))},children:e[0].toUpperCase()+e.slice(1)},e))}),(0,l.jsxs)(`div`,{role:`tabpanel`,id:`panel-preview`,"aria-labelledby":`tab-preview`,hidden:P!==`preview`,children:[(0,l.jsxs)(`div`,{className:`preview-toolbar`,children:[(0,l.jsx)(`div`,{className:`segmented`,children:[`before`,`after`].map(e=>(0,l.jsx)(`button`,{"aria-pressed":Ce===e,onClick:()=>{we(e),Se(``)},children:e===`before`?`Original`:`Revision`},e))}),(0,l.jsx)(`span`,{children:`Restricted local preview`})]}),!xe&&(0,l.jsxs)(`div`,{id:`preview-placeholder`,className:`preview-placeholder`,children:[(0,l.jsx)(`h2`,{children:`Open a project you trust.`}),(0,l.jsx)(`p`,{children:F?.capabilities.adapter===`react-vite-v1`?`Framework sources need a reviewed build. Export and inspect the built output after checks.`:`Preview runs scripts with network, storage and forms restricted. Some behavior may differ.`}),(0,l.jsx)(w,{primary:!0,id:`open-preview`,onClick:()=>Q(async()=>{let e=await o(`/api/runs/${F.id}/preview`,{variant:Ce});Se(e.url)}),children:`Open trusted preview`})]}),(0,l.jsx)(`iframe`,{id:`preview-frame`,title:`Project revision preview`,sandbox:F?.capabilities.adapter===`react-vite-v1`?`allow-scripts allow-same-origin`:`allow-scripts`,referrerPolicy:`no-referrer`,src:xe||void 0,hidden:!xe}),(0,l.jsx)(`p`,{className:`preview-caption`,children:`An inspection aid, not a behavior or security certificate.`})]}),(0,l.jsxs)(`div`,{role:`tabpanel`,id:`panel-changes`,"aria-labelledby":`tab-changes`,hidden:P!==`changes`,children:[(0,l.jsxs)(`div`,{className:`changes-toolbar`,children:[(0,l.jsx)(`label`,{htmlFor:`change-file`,children:`Changed file`}),(0,l.jsx)(`select`,{id:`change-file`,value:Te,onChange:e=>Ee(e.target.value),children:ce?.proposal?.changes.map(e=>(0,l.jsx)(`option`,{children:e.path},e.path))}),(0,l.jsx)(`button`,{className:`text-button`,onClick:()=>Q(()=>r(F.id,`diff`)),children:`Download patch`})]}),(0,l.jsxs)(`div`,{className:`code-comparison`,children:[(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`h2`,{children:`Original`}),(0,l.jsx)(`pre`,{children:(0,l.jsx)(`code`,{id:`before-code`,children:ce?.request.files.find(e=>e.path===Te)?.content??(tt?.operation===`create`?`New file`:`Binary asset`)})})]}),(0,l.jsxs)(`section`,{children:[(0,l.jsx)(`h2`,{children:`Revision`}),(0,l.jsx)(`pre`,{children:(0,l.jsx)(`code`,{id:`after-code`,children:tt?.encoding===`base64`?`Binary asset — exact bytes are included in the export.`:tt?.content})})]})]})]}),(0,l.jsxs)(`div`,{role:`tabpanel`,id:`panel-checks`,"aria-labelledby":`tab-checks`,hidden:P!==`checks`,children:[(0,l.jsx)(`div`,{id:`checks-list`,className:`checks-list`,children:Object.entries(F?.checks??{}).map(([e,t])=>(0,l.jsxs)(`section`,{className:`check-item`,children:[(0,l.jsxs)(`header`,{children:[(0,l.jsx)(`span`,{children:{structural:`Structural validation`,browser:`Browser review`,functional:`Preserved behavior`,design:`Design review`,build:`Build and type check`}[e]??e}),(0,l.jsx)(`span`,{className:`state-label ${t.status}`,children:b(t.status)})]}),(0,l.jsxs)(`p`,{children:[t.note??t.reason??`Response contract and source identities only.`,t.origin===`operator-import`?` Operator report; not engine-certified.`:``]})]},e))}),F?.capabilities.adapter===`react-vite-v1`&&(0,l.jsx)(D,{run:F,task:Q,refresh:()=>Z(F.id,`review`)},F.id+`:`+F.revisionId),(0,l.jsxs)(`details`,{className:`evidence-details`,children:[(0,l.jsx)(`summary`,{children:`Record an external check`}),(0,l.jsx)(`p`,{children:`Record what you actually checked. This is an operator report.`}),(0,l.jsxs)(`form`,{id:`evidence-form`,onSubmit:e=>{e.preventDefault();let t=Object.fromEntries(new FormData(e.currentTarget));Q(async()=>{await o(`/api/runs/${F.id}/evidence`,{...t,revisionId:F.revisionId,reportText:JSON.stringify({origin:`operator-report`,...t})}),await Z(F.id,`review`),J(`External check recorded for this revision.`)})},children:[(0,l.jsxs)(`div`,{className:`two-fields`,children:[(0,l.jsxs)(`label`,{children:[`Check`,(0,l.jsxs)(`select`,{name:`kind`,children:[(0,l.jsx)(`option`,{value:`browser`,children:`Browser`}),(0,l.jsx)(`option`,{value:`functional`,children:`Behavior`}),(0,l.jsx)(`option`,{value:`design`,children:`Design`})]})]}),(0,l.jsxs)(`label`,{children:[`Result`,(0,l.jsxs)(`select`,{name:`outcome`,children:[(0,l.jsx)(`option`,{value:`passed`,children:`Passed`}),(0,l.jsx)(`option`,{value:`failed`,children:`Failed`})]})]})]}),(0,l.jsx)(`label`,{htmlFor:`evidence-note`,children:`What did you check?`}),(0,l.jsx)(`textarea`,{id:`evidence-note`,name:`note`,required:!0,maxLength:2e3}),(0,l.jsx)(`button`,{className:`button subtle`,disabled:R||et,children:`Record check`})]})]})]})]}),(0,l.jsxs)(`aside`,{className:`decision-panel`,children:[(0,l.jsxs)(`div`,{className:`section-heading`,children:[(0,l.jsx)(`h2`,{children:`Your decision`}),(0,l.jsx)(`span`,{className:`mode-badge`,children:F?.mode===`mock`?`Sample fixture`:`Staged revision`})]}),(0,l.jsx)(`p`,{children:`Inspect the revision and the checks before deciding.`}),(0,l.jsxs)(`form`,{id:`decision-form`,hidden:et,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),n=e.nativeEvent.submitter;Q(async()=>{await o(`/api/runs/${F.id}/decision`,{revisionId:F.revisionId,decision:n.value,reason:t.get(`reason`)}),await Z(F.id,`review`),J(`Decision recorded. Your original project is unchanged.`)})},children:[(0,l.jsx)(`label`,{htmlFor:`decision-reason`,children:`Review note`}),(0,l.jsx)(`textarea`,{id:`decision-reason`,name:`reason`,rows:4,required:!0,maxLength:2e3,placeholder:`What you reviewed, and why this revision is ready or needs another pass…`}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{type:`checkbox`,id:`decision-confirm`,required:!0}),(0,l.jsx)(`span`,{children:`I reviewed this exact revision, including checks still marked not run.`})]}),(0,l.jsxs)(`div`,{className:`decision-actions`,children:[(0,l.jsx)(`button`,{className:`button primary`,name:`decision`,value:`accepted`,disabled:R,children:`Accept revision`}),(0,l.jsx)(`button`,{className:`button subtle`,name:`decision`,value:`rejected`,disabled:R,children:`Reject revision`})]})]}),(0,l.jsxs)(`div`,{id:`decision-result`,hidden:!$e,children:[(0,l.jsx)(`p`,{className:`state-label `+F?.acceptance?.decision,children:b(F?.acceptance?.decision??``)}),(0,l.jsx)(`p`,{children:F?.acceptance?.reason})]}),F&&(0,l.jsx)(E,{run:F,task:Q,refresh:()=>Z(F.id,`review`)}),(0,l.jsx)(`div`,{className:`original-note`,children:(0,l.jsxs)(`p`,{children:[`Your original stays untouched.`,(0,l.jsx)(`small`,{children:`Acceptance records your decision. Applying to source is unavailable.`})]})}),(0,l.jsx)(`button`,{className:`text-button`,id:`iterate`,onClick:()=>Be(!0),children:`Start another revision`})]})]})]}),i&&(0,l.jsx)(te,{showConnections:!0,modal:!0,onClose:y,theme:A,onTheme:j,motion:U,onMotion:De,onPilot:()=>{We()&&(y(),X(`prepare`))}}),(0,l.jsxs)(`section`,{id:`jobs-view`,className:`view`,hidden:M!==`jobs`,children:[(0,l.jsxs)(`div`,{className:`page-heading`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{children:`Local jobs`}),(0,l.jsx)(`p`,{children:`Queued work, current activity and recoverable history on this machine.`})]}),(0,l.jsx)(w,{onClick:()=>Q($),children:`Refresh jobs`})]}),(0,l.jsxs)(`form`,{id:`job-query`,className:`job-query`,onSubmit:e=>{e.preventDefault(),Q($)},children:[(0,l.jsxs)(`label`,{htmlFor:`job-search`,children:[`Find a job`,(0,l.jsx)(`input`,{type:`search`,id:`job-search`,value:Ae,onChange:e=>je(e.target.value),placeholder:`Search by run or operation…`})]}),(0,l.jsxs)(`label`,{htmlFor:`job-filter`,children:[`Status`,(0,l.jsxs)(`select`,{id:`job-filter`,value:Me,onChange:e=>Ne(e.target.value),children:[(0,l.jsx)(`option`,{value:``,children:`All jobs`}),[`queued`,`running`,`completed`,`failed`,`cancelled`].map(e=>(0,l.jsx)(`option`,{children:e},e))]})]}),(0,l.jsx)(`button`,{className:`button primary`,children:`Find jobs`})]}),(0,l.jsx)(`div`,{id:`jobs-list`,className:`jobs-list`,children:Oe.length?Oe.map(e=>(0,l.jsxs)(`article`,{className:`job-row`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`h2`,{children:[e.kind===`start`?`Start revision`:`Resume revision`,(0,l.jsx)(`span`,{className:`job-state `+e.status,children:b(e.status)})]}),(0,l.jsx)(`p`,{children:e.runStatus?b(e.runStatus):`Waiting for a local worker`}),e.error&&(0,l.jsx)(`p`,{children:e.error}),(0,l.jsxs)(`p`,{className:`job-meta`,children:[new Date(e.updatedAt).toLocaleString(),` · `,e.attempts,` attempts`]}),(0,l.jsxs)(`details`,{children:[(0,l.jsx)(`summary`,{children:`Operation details`}),(0,l.jsx)(`p`,{children:e.idempotencyKey}),(0,l.jsxs)(`p`,{children:[`Job `,e.id]})]})]}),(0,l.jsxs)(`div`,{className:`row-actions`,children:[e.runAvailable&&(0,l.jsx)(`button`,{className:`text-button`,"data-job-run":e.runId,onClick:()=>Z(e.runId).catch(e=>J(e.message,!0)),children:`Open run`}),[`queued`,`running`].includes(e.status)&&(0,l.jsx)(`button`,{className:`text-button`,onClick:()=>{confirm(`Cancel this local job? Committed outputs stay available.`)&&Q(async()=>{await o(`/api/jobs/${e.id}/cancel`,{}),await $()})},children:`Cancel job`})]})]},e.id)):(0,l.jsx)(`p`,{className:`job-empty`,children:`No jobs match this view. Start a revision, or change the search.`})})]})]}),(0,l.jsxs)(`footer`,{className:`app-footer`,children:[(0,l.jsx)(`span`,{children:`UI Design Studio`}),(0,l.jsx)(`span`,{children:`React workspace · Local review and scoped handoff`})]})]})]}),(0,l.jsxs)(`dialog`,{id:`library-dialog`,ref:Pe,onCancel:()=>H(!1),onClose:()=>H(!1),children:[(0,l.jsxs)(`div`,{className:`dialog-heading`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{children:`Reference library`}),(0,l.jsx)(`p`,{children:`Choose up to eight images for private inspiration.`})]}),(0,l.jsx)(`button`,{className:`icon-button`,"aria-label":`Close reference library`,onClick:()=>H(!1),children:(0,l.jsx)(C,{kind:`close`})})]}),(0,l.jsx)(`div`,{id:`library-grid`,className:`library-grid`,children:T?.references.map(Xe)}),(0,l.jsx)(`p`,{className:`rights-note`,children:`Selecting a reference prepares local context. It does not send images or grant production reuse rights.`}),(0,l.jsx)(w,{primary:!0,onClick:()=>H(!1),children:`Use selected references`})]})]})}function E({run:e,task:t,refresh:n}){return(0,l.jsxs)(`details`,{className:`technical`,children:[(0,l.jsx)(`summary`,{children:`Scoped AI / MCP access`}),(0,l.jsx)(`p`,{children:`A grant shares this run’s selected context with the local MCP client. It permits bounded reads and staged proposal submission, expires after one hour, and cannot accept or apply changes. The client starts its own model; usage and cost are unknown to Studio.`}),(0,l.jsx)(w,{disabled:e.status!==`waiting-external-response`,onClick:()=>t(async()=>{await o(`/api/runs/${e.id}/grants`,{expectedInputHash:e.inputHash}),await n()}),children:`Grant this context for one hour`}),e.grants?.map(r=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`code`,{children:r.id}),(0,l.jsx)(`p`,{children:r.revoked?`Revoked`:`Expires ${new Date(r.expiresAt).toLocaleTimeString()}`}),!r.revoked&&(0,l.jsx)(w,{onClick:()=>t(async()=>{await o(`/api/runs/${e.id}/revoke`,{runId:e.id}),await n()}),children:`Revoke access`})]},r.id))]})}function D({run:e,task:t,refresh:n}){let[r,i]=(0,c.useState)(!1);return(0,l.jsxs)(`div`,{className:`evidence-details`,children:[(0,l.jsx)(`h2`,{children:`Declared local checks`}),(0,l.jsx)(`p`,{children:`Run the reviewed TypeScript compiler and Vite build in a separate source copy using this project’s installed dependencies. Code executes locally; this is not an isolated service for untrusted projects.`}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),(0,l.jsx)(`span`,{children:`I trust this project and its installed dependencies and permit these checks.`})]}),(0,l.jsx)(w,{disabled:!r||e.status!==`awaiting-human-review`,onClick:()=>t(async()=>{await o(`/api/runs/${e.id}/check`,{revisionId:e.revisionId,approved:!0}),await n()}),children:`Run reviewed build checks`})]})}export{T as default};
@@ -1,4 +0,0 @@
1
- import{i as e,t}from"./react-vendor-CH5vucNG.js";import{f as n,o as r,p as i}from"./index-KY1IHp8L.js";/* empty css */var a=e(),o={"node-intake":{x:32,y:204},"node-context":{x:316,y:78},"node-scope":{x:316,y:330},"node-engine":{x:600,y:204},"node-visual-qa":{x:884,y:78},"node-security-gate":{x:884,y:330},"node-delivery":{x:1168,y:204}},s=1440;function c(e,t){let n=String(e??``).trim().toLowerCase();return!n||n===`auto`?t&&t.trim()?t.trim():`Auto-detect`:n===`static-html`?`Static HTML`:n===`react-vite`?`React / Vite`:n===`nextjs-app`?`Next.js App`:n===`nextjs-pages`?`Next.js Pages`:e}var l=[{kind:`figma`,group:`connectors`,title:`Figma Design`,desc:`Pull a Figma frame URL & design tokens into your UI redesign.`,stage:`before-ai`,connectorId:`figma`,moduleId:`figmasync`,defaultConfig:{figmaUrl:``,figmaMode:`Colors & Layout`}},{kind:`git`,group:`connectors`,title:`GitHub / GitLab`,desc:`Set PR branch naming and connect repo delivery.`,stage:`delivery`,connectorId:`github`,defaultConfig:{branchPrefix:`studio/`}},{kind:`references`,group:`connectors`,title:`Style & References`,desc:`Pin visual reference boards and color palettes for UI work.`,stage:`before-ai`,connectorId:`reference-library`,defaultConfig:{notes:`Match layout rhythm and typography contrast.`}},{kind:`playwright`,group:`modules`,title:`Playwright Browser`,desc:`Capture desktop, mobile & dark screenshots and test clicks.`,stage:`after-ai`,moduleId:`playwright`,defaultConfig:{viewports:[`desktop`,`mobile`,`dark`]}},{kind:`a11y`,group:`modules`,title:`Accessibility Check`,desc:`Check WCAG contrast, keyboard focus rings, and native buttons.`,stage:`after-ai`,defaultConfig:{notes:`Enforce AA contrast >= 4.5:1 and keyboard navigation.`}},{kind:`seo`,group:`modules`,title:`SEO & AI Search`,desc:`Audit page titles, meta descriptions, headings & structured data.`,stage:`after-ai`,defaultConfig:{}},{kind:`graphify`,group:`modules`,title:`Project Map (Graphify)`,desc:`Map component imports and file impact before editing.`,stage:`after-ai`,moduleId:`graphify`,defaultConfig:{}}],u=[{id:`default`,name:`Default UI Pipeline`,profile:`ui`,hiddenCoreNodes:[],customNodes:[]},{id:`tpl-figma-redesign`,name:`Figma → UI Redesign`,profile:`ui`,hiddenCoreNodes:[],customNodes:[{id:`mod-figma-1`,kind:`figma`,stage:`before-ai`,title:`Figma Design`,subtitle:`Frame & tokens`,enabled:!0,connectorId:`figma`,moduleId:`figmasync`,config:{figmaUrl:``,figmaMode:`Colors & Layout`}},{id:`mod-playwright-1`,kind:`playwright`,stage:`after-ai`,title:`Playwright Browser`,subtitle:`Desktop, mobile & dark`,enabled:!0,moduleId:`playwright`,config:{viewports:[`desktop`,`mobile`,`dark`]}}]},{id:`tpl-playwright-audit`,name:`Playwright & Audit QA`,profile:`audit`,hiddenCoreNodes:[`node-context`],customNodes:[{id:`mod-playwright-qa`,kind:`playwright`,stage:`after-ai`,title:`Playwright Browser`,subtitle:`Desktop & mobile checks`,enabled:!0,moduleId:`playwright`,config:{viewports:[`desktop`,`mobile`]}},{id:`mod-a11y-qa`,kind:`a11y`,stage:`after-ai`,title:`Accessibility Check`,subtitle:`Contrast & keyboard`,enabled:!0,config:{}}]},{id:`tpl-seo-map`,name:`SEO & Project Map`,profile:`seo`,hiddenCoreNodes:[`node-context`,`node-visual-qa`],customNodes:[{id:`mod-seo-1`,kind:`seo`,stage:`after-ai`,title:`SEO & AI Search`,subtitle:`Metadata & headings`,enabled:!0,config:{}},{id:`mod-graphify-1`,kind:`graphify`,stage:`after-ai`,title:`Project Map (Graphify)`,subtitle:`Imports & impact`,enabled:!0,moduleId:`graphify`,config:{}}]}],d=new Set([`node-context`,`node-scope`,`node-visual-qa`,`node-security-gate`]),f={"node-intake":`Picks the project folder, framework, and pages Studio checks.`,"node-context":`Sets the visual design style when redesigning UI. Automatically skipped for Audit, SEO, and Project Map.`,"node-scope":`Controls which folders Studio reads and which features must stay working.`,"node-engine":`Sets size and cost limits when an AI model generates edits.`,"node-visual-qa":`Checks layout shifts, Before/After screenshots, and reusable components.`,"node-security-gate":`Scans code locally for security issues, accessibility bugs, and weak tests. No API key needed.`,"node-delivery":`Stages every change for review first, with 1-click Undo if you apply.`},p=[`Main navigation`,`Keyboard focus`,`Saved login state`,`Dark mode toggle`],m=[{id:`node-intake`,type:`trigger`,category:`Step 1`,title:`Project`,subtitle:`Auto-detect · UI Redesign`,position:o[`node-intake`],enabled:!0,locked:!0,status:`ready`,metrics:[],config:{}},{id:`node-context`,type:`context`,category:`Step 2`,title:`Design Style`,subtitle:`Modern default · 3 guides`,position:o[`node-context`],enabled:!0,locked:!1,status:`ready`,metrics:[],config:{}},{id:`node-scope`,type:`guardrail`,category:`Step 3`,title:`Files & Rules`,subtitle:`3 folders · 3 items kept`,position:o[`node-scope`],enabled:!0,locked:!1,status:`ready`,metrics:[],config:{}},{id:`node-engine`,type:`agent`,category:`Step 4`,title:`AI Helper`,subtitle:`Balanced · $0.25 cap`,position:o[`node-engine`],enabled:!0,locked:!0,status:`ready`,metrics:[],config:{}},{id:`node-visual-qa`,type:`verification`,category:`Step 5`,title:`Visual Check`,subtitle:`Normal diff · Standard`,position:o[`node-visual-qa`],enabled:!0,locked:!1,status:`ready`,metrics:[],config:{}},{id:`node-security-gate`,type:`security`,category:`Step 6`,title:`Security & Code Audit`,subtitle:`Local checks · Pass at 72`,position:o[`node-security-gate`],enabled:!0,locked:!1,status:`ready`,metrics:[],config:{}},{id:`node-delivery`,type:`output`,category:`Step 7`,title:`Review & Apply`,subtitle:`Preview first · 1-click Undo`,position:o[`node-delivery`],enabled:!0,locked:!0,status:`ready`,metrics:[],config:{}}];function h(e,t){if(t)switch(t){case`figma`:return`#1e1e24`;case`playwright`:return`#16a34a`;case`seo`:return`#0891b2`;case`graphify`:return`#6366f1`;case`a11y`:return`#0d9488`;case`git`:return`#475569`;case`references`:return`#ec4899`;default:return`#d97706`}switch(e){case`trigger`:return`#2563eb`;case`context`:return`#7c3aed`;case`guardrail`:return`#0284c7`;case`agent`:return`#d97706`;case`verification`:return`#059669`;case`security`:return`#db2777`;case`output`:return`#4f46e5`;default:return`#2563eb`}}function g(e,t){if(t)switch(t){case`figma`:return`figma`;case`playwright`:return`playwright`;case`seo`:return`search`;case`graphify`:return`graph`;case`a11y`:return`shield`;case`git`:return`github`;case`references`:return`image`;default:return`auto`}switch(e){case`trigger`:return`folder`;case`context`:return`palette`;case`guardrail`:return`assets`;case`agent`:return`auto`;case`verification`:return`capture`;case`security`:return`shield`;case`output`:return`check`;default:return`graph`}}function _(e){switch(e){case`audit`:return`Quick Audit`;case`seo`:case`ai-search`:return`SEO & AI`;case`architecture`:return`Project Map`;default:return`UI Redesign`}}function ee(e){return/security/i.test(e)?`Security`:/test/i.test(e)?`Test Quality`:/ui|craft|a11y/i.test(e)?`UI & Accessibility`:/verification|depth/i.test(e)?`Verification`:e}function v(e){return/gitleaks/i.test(e)?`Gitleaks (extra secret scan)`:/osv/i.test(e)?`OSV Vulnerability Check`:/semgrep/i.test(e)?`Semgrep Security Scan`:/context7/i.test(e)?`Context7 Library Docs`:/tautolog|test/i.test(e)?`Test Quality Check`:/sca|depend/i.test(e)?`Dependency Check`:/sast|secret/i.test(e)?`UI & Security Scan`:e}function y(e,t,n){return Math.max(t,Math.min(n,e))}function b(e,t){let n=new Set(e),r={...o},i=[...n.has(`node-context`)?[]:[`node-context`],...n.has(`node-scope`)?[]:[`node-scope`],...t.filter(e=>e.stage===`before-ai`).map(e=>e.id)],a=[...n.has(`node-visual-qa`)?[]:[`node-visual-qa`],...n.has(`node-security-gate`)?[]:[`node-security-gate`],...t.filter(e=>e.stage===`after-ai`).map(e=>e.id)],s=[`node-delivery`,...t.filter(e=>e.stage===`delivery`).map(e=>e.id)],c=(e,t)=>{let n=(e.length-1)*142+114,i=Math.max(30,Math.round((580-n)/2));e.forEach((e,n)=>{r[e]={x:t,y:y(i+n*142,24,442)}})};return r[`node-intake`]={x:32,y:233},c(i,316),r[`node-engine`]={x:600,y:233},c(a,884),c(s,1168),r}var te=[{id:`pr-visual-proof`,name:`Check a Pull Request`,shortDesc:`Scan changed UI files, check layout and contrast, and post one clean PR summary.`,trigger:`On pull requests`,outcome:`One PR summary + pass/fail check`,profile:`audit`,minScoreThreshold:75,connectors:[`github`,`playwright`,`gitleaks`,`osv`],cliCommand:`ui-workflow run pr-visual-proof`,steps:[`node-intake`,`node-scope`,`node-visual-qa`,`node-security-gate`,`node-delivery`]},{id:`branch-visual-diff`,name:`Compare Branch Changes`,shortDesc:`See before-and-after screenshots against main without touching your Git files.`,trigger:`Before opening a PR`,outcome:`Interactive diff slider + layout summary`,profile:`audit`,minScoreThreshold:72,connectors:[`github`,`playwright`],cliCommand:`ui-workflow run branch-visual-diff`,steps:[`node-intake`,`node-visual-qa`,`node-security-gate`,`node-delivery`]},{id:`pre-push-guardrail`,name:`Quick Check Before Push`,shortDesc:`Catch leaked keys, broken links, and accessibility bugs in under 2 seconds.`,trigger:`Before git push`,outcome:`Fast local pass/fail check`,profile:`audit`,minScoreThreshold:80,connectors:[`gitleaks`,`osv`,`github`],cliCommand:`ui-workflow run pre-push-guardrail`,steps:[`node-intake`,`node-scope`,`node-visual-qa`,`node-security-gate`,`node-delivery`]},{id:`multi-route-dev-audit`,name:`Check Running App`,shortDesc:`Finds your local dev server and checks desktop, mobile, and dark mode pages.`,trigger:`While your app runs locally`,outcome:`Screenshots & checks across pages`,profile:`audit`,minScoreThreshold:72,connectors:[`playwright`,`vercel`,`netlify`,`cloudflare`],cliCommand:`ui-workflow run multi-route-dev-audit`,steps:[`node-intake`,`node-scope`,`node-visual-qa`,`node-security-gate`,`node-delivery`]},{id:`figma-to-code-check`,name:`Match Figma Design`,shortDesc:`Compare your code against a Figma link or local design tokens.`,trigger:`After building a screen`,outcome:`Token match + contrast report`,profile:`ui`,minScoreThreshold:75,connectors:[`figma`,`storybook`,`reference-library`],cliCommand:`ui-workflow run figma-to-code-check`,steps:[`node-intake`,`node-context`,`node-scope`,`node-visual-qa`,`node-security-gate`,`node-delivery`]},{id:`ai-fix-loop`,name:`Prepare AI Fix List`,shortDesc:`Find UI bugs and copy a ready-to-paste fix prompt for Cursor, Claude, or Codex.`,trigger:`When fixing issues with AI`,outcome:`Ready-to-paste fix prompt`,profile:`audit`,minScoreThreshold:75,connectors:[`ide-mcp`,`github`,`linear`,`slack`],cliCommand:`ui-workflow run ai-fix-loop`,steps:[`node-intake`,`node-scope`,`node-engine`,`node-visual-qa`,`node-security-gate`,`node-delivery`]}],ne={"pr-visual-proof":{icon:`github`,tag:`Pull Request`},"branch-visual-diff":{icon:`capture`,tag:`Branch Diff`},"pre-push-guardrail":{icon:`gitleaks`,tag:`Fast · 2s`},"multi-route-dev-audit":{icon:`playwright`,tag:`Live App`},"figma-to-code-check":{icon:`figma`,tag:`Design`},"ai-fix-loop":{icon:`mcp`,tag:`AI Editor`}},x=t();function re({viewportRef:e,isPanning:t,pan:i,zoom:o,setZoom:c,addPanelOpen:u,setAddPanelOpen:d,addStageHint:f,setAddStageHint:p,onOpenAddForStage:m,hiddenCoreNodes:_,newStepTitle:ee,setNewStepTitle:v,newStepStage:b,setNewStepStage:te,newStepNotes:ne,setNewStepNotes:re,integrationStatusFor:S,addModuleNode:C,restoreCoreNode:ie,addCustomStepNode:w,edges:T,liveNodes:E,selectedNode:ae,selectedNodeId:D,setSelectedNodeId:O,setInspectorOpen:k,draggingNodeId:oe,activeExecNode:A,executing:se,executionResult:j,profile:ce,onViewportPointerDown:le,onViewportPointerMove:ue,onViewportPointerUp:de,onViewportWheel:fe,onNodePointerDown:pe,onNodePointerMove:me,onNodePointerUp:he,executeWorkflowPipeline:ge,updateCustomNode:M,toggleCoreNodeEnabled:_e,removeNode:N,fitCanvasToView:P,tidyLayout:F,centerOnNode:I}){let[L,R]=(0,a.useState)(``),[z,B]=(0,a.useState)(`all`),V=(0,a.useRef)(null);(0,a.useEffect)(()=>{u&&(R(``),B(`all`),requestAnimationFrame(()=>V.current?.focus()))},[u]);let H=L.trim().toLowerCase(),U=(0,a.useMemo)(()=>l.filter(e=>z===`connectors`&&e.group!==`connectors`||z===`modules`&&e.group!==`modules`||z===`custom`?!1:!H||`${e.title} ${e.desc} ${e.kind}`.toLowerCase().includes(H)),[H,z]),ve=U.filter(e=>e.group===`connectors`),ye=U.filter(e=>e.group===`modules`);function be(e,t){return t.id===`node-delivery`||t.custom?.stage===`delivery`?`delivery`:e.id===`node-ai`||e.id===`node-visual-qa`||e.id===`node-security-gate`||e.custom?.stage===`after-ai`?`after-ai`:`before-ai`}function xe(e){return e.id===`node-visual-qa`||e.id===`node-security-gate`?`delivery`:e.id===`node-ai`||e.custom?.stage===`after-ai`?`after-ai`:`before-ai`}let Se=e=>e===`before-ai`?`Before AI Helper`:e===`after-ai`?`After AI (QA & Audit)`:e===`delivery`?`At Delivery`:`Auto stage`,Ce=(0,a.useMemo)(()=>{let e=new Set,t=[];for(let n of T){let r=E.find(e=>e.id===n.source),i=E.find(e=>e.id===n.target);if(!r||!i||!r.enabled||!i.enabled)continue;let a=r.position.x+216,o=r.position.y+57,s=i.position.x,c=i.position.y+57,l=(a+s)/2,u=(o+c)/2,d=`${Math.round(l/36)}:${Math.round(u/36)}`;e.has(d)||(e.add(d),t.push({id:n.id,x:l,y:u,stage:be(r,i),label:`Insert step between ${r.title} and ${i.title}`}))}return t},[T,E]);return(0,x.jsxs)(`div`,{ref:e,className:`wb-wf-canvas-viewport ${t?`is-panning`:``}`,onPointerDown:le,onPointerMove:ue,onPointerUp:de,onWheel:fe,children:[(0,x.jsx)(r,{motion:!0,variant:`canvas`,spacing:22,offsetX:i.x,offsetY:i.y}),u&&(0,x.jsxs)(`div`,{className:`wb-wf-add-drawer`,role:`region`,"aria-label":`Add step to workflow`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),d(!1))},children:[(0,x.jsxs)(`div`,{className:`wb-wf-add-drawer-head`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-add-drawer-title`,children:[(0,x.jsx)(`strong`,{children:`Add step`}),(0,x.jsx)(`span`,{className:`wb-wf-stage-badge`,children:Se(f)})]}),(0,x.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>{p(null),d(!1)},children:`Close`})]}),(0,x.jsx)(`div`,{className:`wb-wf-stage-picker`,role:`group`,"aria-label":`Insertion stage`,children:[{id:null,label:`Auto`},{id:`before-ai`,label:`Before AI`},{id:`after-ai`,label:`After AI`},{id:`delivery`,label:`Delivery`}].map(e=>(0,x.jsx)(`button`,{type:`button`,className:`wb-wf-stage-chip`,"aria-pressed":f===e.id,onClick:()=>{p(e.id),e.id&&te(e.id)},children:e.label},e.id??`auto`))}),(0,x.jsxs)(`div`,{className:`wb-wf-add-search-row`,children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`wf-add-step-search`,children:`Search workflow steps`}),(0,x.jsx)(`input`,{ref:V,id:`wf-add-step-search`,type:`search`,className:`wb-wf-add-search`,value:L,placeholder:`Search connectors, checks, or modules… (Enter adds top match)`,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`&&U.length>0&&(e.preventDefault(),C(U[0]))}}),(0,x.jsx)(`div`,{className:`wb-wf-add-tabs`,role:`group`,"aria-label":`Step category`,children:[{id:`all`,label:`All`},{id:`connectors`,label:`Connectors`},{id:`modules`,label:`Checks`},{id:`custom`,label:`Custom`}].map(e=>(0,x.jsx)(`button`,{type:`button`,className:`wb-focus-pill`,"aria-pressed":z===e.id,onClick:()=>B(e.id),children:e.label},e.id))})]}),ve.length>0&&(0,x.jsxs)(`div`,{className:`wb-wf-add-section`,children:[(0,x.jsx)(`span`,{children:`Connectors & Design`}),(0,x.jsx)(`div`,{className:`wb-wf-add-grid`,children:ve.map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`wb-wf-add-card`,onClick:()=>C(e),children:[(0,x.jsx)(`span`,{className:`wb-n8n-icon-tile is-sm`,style:{backgroundColor:h(`context`,e.kind)},children:(0,x.jsx)(n,{name:g(`context`,e.kind)})}),(0,x.jsxs)(`div`,{className:`wb-wf-add-card-body`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-add-card-top`,children:[(0,x.jsx)(`strong`,{children:e.title}),(0,x.jsx)(`span`,{className:`wb-wf-add-status`,children:S(e)})]}),(0,x.jsx)(`small`,{children:e.desc})]})]},e.kind))})]}),ye.length>0&&(0,x.jsxs)(`div`,{className:`wb-wf-add-section`,children:[(0,x.jsx)(`span`,{children:`Modules & Checks`}),(0,x.jsx)(`div`,{className:`wb-wf-add-grid`,children:ye.map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`wb-wf-add-card`,onClick:()=>C(e),children:[(0,x.jsx)(`span`,{className:`wb-n8n-icon-tile is-sm`,style:{backgroundColor:h(`verification`,e.kind)},children:(0,x.jsx)(n,{name:g(`verification`,e.kind)})}),(0,x.jsxs)(`div`,{className:`wb-wf-add-card-body`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-add-card-top`,children:[(0,x.jsx)(`strong`,{children:e.title}),(0,x.jsx)(`span`,{className:`wb-wf-add-status`,children:S(e)})]}),(0,x.jsx)(`small`,{children:e.desc})]})]},e.kind))})]}),z!==`custom`&&U.length===0&&(0,x.jsxs)(`p`,{className:`wb-wf-add-empty`,children:[`No built-in step matches “`,L.trim(),`”. Create a custom step below.`]}),_.length>0&&z!==`custom`&&(0,x.jsxs)(`div`,{className:`wb-wf-add-section`,children:[(0,x.jsx)(`span`,{children:`Restore Removed Built-in Steps`}),(0,x.jsx)(`div`,{className:`wb-wf-quick-chips`,children:_.map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`wb-focus-pill`,onClick:()=>ie(e),children:[`+ `,e===`node-context`?`Design Style`:e===`node-scope`?`Files & Rules`:e===`node-visual-qa`?`Visual Check`:`Security & Code Audit`]},e))})]}),(z===`all`||z===`custom`||U.length===0)&&(0,x.jsxs)(`div`,{className:`wb-wf-add-section`,children:[(0,x.jsx)(`span`,{children:`Create Custom Step`}),(0,x.jsxs)(`div`,{className:`wb-wf-custom-creator`,children:[(0,x.jsx)(`input`,{type:`text`,value:ee,placeholder:`Step name (e.g. Brand Copy Review)`,onChange:e=>v(e.target.value)}),(0,x.jsxs)(`select`,{value:b,onChange:e=>te(e.target.value),children:[(0,x.jsx)(`option`,{value:`before-ai`,children:`Runs before AI Helper`}),(0,x.jsx)(`option`,{value:`after-ai`,children:`Runs after AI Helper (QA / Check)`}),(0,x.jsx)(`option`,{value:`delivery`,children:`Runs at Delivery`})]}),(0,x.jsx)(`input`,{type:`text`,value:ne,placeholder:`Short instruction or note (optional)`,onChange:e=>re(e.target.value)}),(0,x.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!ee.trim(),onClick:w,children:`Add Custom Step`})]})]})]}),(0,x.jsxs)(`div`,{className:`wb-wf-canvas-stage`,style:{transform:`translate(${i.x}px, ${i.y}px) scale(${o})`,transformOrigin:`0 0`,width:`${s}px`,height:`580px`},children:[(0,x.jsxs)(`svg`,{className:`wb-wf-edges-svg`,viewBox:`0 0 ${s} 580`,width:s,height:580,"aria-hidden":`true`,children:[(0,x.jsx)(`defs`,{children:(0,x.jsx)(`marker`,{id:`wf-arrow`,viewBox:`0 0 10 10`,refX:`7`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,x.jsx)(`path`,{d:`M 0 1 L 8 5 L 0 9 z`,fill:`currentColor`})})}),T.map(e=>{let t=E.find(t=>t.id===e.source),n=E.find(t=>t.id===e.target);if(!t||!n)return null;let r=t.position.x+216,i=t.position.y+57,a=n.position.x,o=n.position.y+57,s=Math.max(46,Math.abs(a-r)*.45),c=`M ${r} ${i} C ${r+s} ${i}, ${a-s} ${o}, ${a} ${o}`,l=(r+a)/2,u=(i+o)/2-9,d=j?.nodeResults?.[n.id],f=!t.enabled||!n.enabled,p=!f&&(se||D===e.source||D===e.target||!!d),m=f?``:d?.status===`passed`?`tone-passed`:d?.status===`warning`?`tone-warning`:d?.status===`failed`?`tone-failed`:``;return(0,x.jsxs)(`g`,{className:`wb-wf-edge-group ${p?`is-active`:``} ${f?`is-disabled`:``} ${m}`,children:[(0,x.jsx)(`path`,{className:`wb-wf-edge-bg`,d:c}),(0,x.jsx)(`path`,{className:`wb-wf-edge-line ${se&&!f?`is-animating`:``}`,d:c,markerEnd:`url(#wf-arrow)`}),(0,x.jsx)(`rect`,{x:l-28,y:u-9,width:`56`,height:`17`,rx:`8.5`,className:`wb-wf-edge-pill`}),(0,x.jsx)(`text`,{x:l,y:u+2.5,textAnchor:`middle`,className:`wb-wf-edge-label`,children:e.label})]},e.id)})]}),Ce.map(e=>(0,x.jsx)(`button`,{type:`button`,className:`wb-wf-edge-add`,style:{left:`${e.x}px`,top:`${e.y+14}px`},title:e.label,"aria-label":e.label,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),m(e.stage)},children:(0,x.jsx)(n,{name:`plus`})},`ins-${e.id}`)),E.map(e=>{let t=h(e.type,e.custom?.kind),r=ae?.id===e.id,i=oe===e.id,a=j?.nodeResults?.[e.id],o=A===e.id?`Running…`:e.enabled?a?a.status===`passed`?`✓ ${a.durationMs}ms`:a.status===`warning`?`! Check`:`× Issue`:``:`Skipped`;return(0,x.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.title} workflow node`,"aria-pressed":r,className:`wb-wf-node-card wb-n8n-node ${r?`is-selected`:``} ${i?`is-dragging`:``} ${e.enabled?``:`is-disabled`} status-${e.status}`,style:{left:`${e.position.x}px`,top:`${e.position.y}px`,width:`216px`,minHeight:`114px`,"--wf-node-accent":t},onPointerDown:t=>pe(t,e),onPointerMove:me,onPointerUp:he,onDoubleClick:()=>{O(e.id),k(!0)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),O(e.id),k(!0))},children:[e.type!==`trigger`&&(0,x.jsx)(`span`,{className:`wb-wf-port wb-wf-port-in`,"aria-hidden":`true`}),(0,x.jsxs)(`div`,{className:`wb-n8n-hover-bar`,children:[(0,x.jsx)(`button`,{type:`button`,title:`Run & inspect ${e.title}`,"aria-label":`Run and inspect ${e.title}`,disabled:se,onClick:t=>{t.stopPropagation(),ge(e.id)},children:`▶`}),!e.locked&&(e.id!==`node-context`||ce===`ui`)&&(0,x.jsx)(`button`,{type:`button`,title:e.enabled?`Skip ${e.title}`:`Enable ${e.title}`,onClick:t=>{t.stopPropagation(),e.custom?M(e.id,{enabled:!e.enabled}):_e(e.id)},children:e.enabled?`On`:`Off`}),e.removable&&(0,x.jsx)(`button`,{type:`button`,className:`is-danger`,title:`Remove ${e.title}`,"aria-label":`Remove ${e.title}`,onClick:t=>{t.stopPropagation(),N(e.id)},children:`×`})]}),(0,x.jsxs)(`div`,{className:`wb-n8n-node-row`,children:[(0,x.jsx)(`span`,{className:`wb-n8n-icon-tile`,style:{backgroundColor:t},"aria-hidden":`true`,children:(0,x.jsx)(n,{name:g(e.type,e.custom?.kind)})}),(0,x.jsxs)(`div`,{className:`wb-n8n-node-body`,children:[(0,x.jsx)(`span`,{className:`wb-n8n-node-step`,children:e.category}),(0,x.jsx)(`strong`,{className:`wb-wf-node-title`,children:e.title})]})]}),(0,x.jsx)(`p`,{className:`wb-wf-node-sub`,children:a?a.summary:e.subtitle}),o&&(0,x.jsx)(`span`,{className:`wb-n8n-corner-badge status-${e.enabled?e.status:`skipped`}`,children:o}),e.id!==`node-delivery`&&e.custom?.stage!==`delivery`&&(0,x.jsx)(`button`,{type:`button`,className:`wb-wf-port wb-wf-port-out wb-wf-port-add`,title:`Add step after ${e.title}`,"aria-label":`Add step after ${e.title}`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),m(xe(e))},children:(0,x.jsx)(n,{name:`plus`})})]},e.id)})]}),(0,x.jsxs)(`div`,{className:`wb-wf-dock`,role:`toolbar`,"aria-label":`Canvas controls`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`wb-wf-dock-add`,"aria-pressed":u,onClick:()=>{p(null),d(e=>!e)},title:`Add step to workflow (A)`,children:[(0,x.jsx)(n,{name:`plus`}),`Add step`]}),(0,x.jsx)(`span`,{className:`wb-wf-dock-sep`,"aria-hidden":`true`}),(0,x.jsx)(`button`,{type:`button`,onClick:P,title:`Fit all steps in view (0)`,children:`Fit`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>c(e=>y(Number((e-.1).toFixed(2)),.34,1.5)),"aria-label":`Zoom out`,title:`Zoom out (-)`,children:`−`}),(0,x.jsxs)(`span`,{className:`wb-wf-dock-pct`,children:[Math.round(o*100),`%`]}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>c(e=>y(Number((e+.1).toFixed(2)),.34,1.5)),"aria-label":`Zoom in`,title:`Zoom in (+)`,children:`+`}),(0,x.jsx)(`button`,{type:`button`,onClick:F,title:`Line up steps neatly`,children:`Tidy`})]}),(0,x.jsx)(`div`,{className:`wb-wf-minimap`,"aria-label":`Workflow mini-map`,children:(0,x.jsxs)(`svg`,{viewBox:`0 0 ${s} 580`,width:`164`,height:`58`,children:[T.map(e=>{let t=E.find(t=>t.id===e.source),n=E.find(t=>t.id===e.target);return!t||!n?null:(0,x.jsx)(`line`,{x1:t.position.x+216,y1:t.position.y+57,x2:n.position.x,y2:n.position.y+57,stroke:`currentColor`,strokeWidth:`9`,opacity:!t.enabled||!n.enabled?.2:.45},e.id)}),E.map(e=>{let t=ae?.id===e.id,n=e.enabled?e.status===`failed`?`#ef4444`:e.status===`warning`?`#f59e0b`:e.status===`passed`?`#10b981`:h(e.type,e.custom?.kind):`#94a3b8`;return(0,x.jsx)(`rect`,{x:e.position.x,y:e.position.y,width:216,height:114,rx:`22`,fill:n,opacity:e.enabled?.92:.35,stroke:t?`#ffffff`:`none`,strokeWidth:t?`24`:`0`,style:{cursor:`pointer`},onClick:()=>I(e)},e.id)})]})})]})}function S({selectedNode:e,inspectorTab:t,setInspectorTab:r,executing:i,executionResult:a,graph:o,rules:s,setRules:c,profile:u,setProfile:d,minScoreThreshold:m,setMinScoreThreshold:y,maxOutputTokens:b,setMaxOutputTokens:te,maxCostUsd:ne,setMaxCostUsd:re,strictDesignSystem:S,setStrictDesignSystem:C,visualDiffThreshold:ie,setVisualDiffThreshold:w,showDiffBoxes:T,setShowDiffBoxes:E,activeDiffViewport:ae,setActiveDiffViewport:D,diffImageLayer:O,setDiffImageLayer:k,newRouteInput:oe,setNewRouteInput:A,newDirInput:se,setNewDirInput:j,newPreserveInput:ce,setNewPreserveInput:le,newInteractionInput:ue,setNewInteractionInput:de,newIgnoreCheckInput:fe,setNewIgnoreCheckInput:pe,setError:me,removeNode:he,updateCustomNode:ge,updateCustomNodeConfig:M,moveCustomNodeStage:_e,toggleSkill:N,toggleKeepItem:P,executeWorkflowPipeline:F,onOpenComposer:I}){let L=a?.securityReport,R=L?.scoreBreakdown,z=L?.testIntegrity,B=a?.designSystemLock,V=a?.visualDiff,H=V?.viewports?.find(e=>e.name===ae)??V?.viewports?.[0]??null,U=a?.nodeResults?.[e.id];return(0,x.jsxs)(`aside`,{className:`wb-wf-inspector`,"aria-label":`Selected workflow node inspector`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-inspector-head`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-inspector-top-row`,children:[(0,x.jsx)(`span`,{className:`wb-n8n-icon-tile is-sm`,style:{backgroundColor:h(e.type,e.custom?.kind)},"aria-hidden":`true`,children:(0,x.jsx)(n,{name:g(e.type,e.custom?.kind)})}),(0,x.jsxs)(`div`,{className:`wb-wf-inspector-title-wrap`,children:[(0,x.jsx)(`span`,{className:`wb-wf-inspector-badge`,style:{color:h(e.type,e.custom?.kind)},children:e.category}),(0,x.jsx)(`h3`,{children:e.title})]}),e.removable&&(0,x.jsx)(`button`,{type:`button`,className:`text-button wb-wf-remove-inline`,onClick:()=>he(e.id),children:`Remove`})]}),(0,x.jsx)(`p`,{className:`wb-wf-step-desc`,children:e.custom?l.find(t=>t.kind===e.custom?.kind)?.desc??`Custom step in your workflow.`:f[e.id]??e.subtitle}),(0,x.jsxs)(`div`,{className:`wb-wf-inspector-tabs`,role:`tablist`,"aria-label":`Step details`,children:[(0,x.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`settings`,onClick:()=>r(`settings`),children:`Settings`}),(0,x.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`output`,onClick:()=>r(`output`),children:[`Output`,a?` · Ready`:``]})]})]}),t===`output`&&(0,x.jsx)(`div`,{className:`wb-wf-inspector-form`,children:a?(0,x.jsxs)(x.Fragment,{children:[U&&(0,x.jsxs)(`div`,{className:`wb-wf-step-output-card status-${U.status}`,children:[(0,x.jsxs)(`div`,{className:`wb-vdiff-lock-head`,children:[(0,x.jsx)(`strong`,{className:`wb-wf-status-cap`,children:U.status}),(0,x.jsxs)(`div`,{className:`wb-wf-node-metrics`,children:[U.source&&(0,x.jsx)(`span`,{className:`wb-wf-metric-chip`,children:U.source===`live`?`Live check`:U.source===`fallback`?`Setup needed`:`Static check`}),(0,x.jsxs)(`span`,{className:`wb-wf-metric-chip`,children:[U.durationMs,`ms`]})]})]}),(0,x.jsx)(`p`,{className:`wb-wf-note`,children:U.summary}),U.details&&U.details.length>0&&(0,x.jsx)(`ul`,{className:`wb-wf-step-detail-list`,children:U.details.map((e,t)=>(0,x.jsx)(`li`,{children:e},t))}),U.fallbackHint&&(0,x.jsx)(`p`,{className:`wb-wf-info-callout`,children:U.fallbackHint})]}),L&&(0,x.jsxs)(`div`,{className:`wb-wf-kpi-grid`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-kpi-tile`,children:[(0,x.jsx)(`small`,{children:`Score`}),(0,x.jsxs)(`strong`,{children:[L.score,`/100`]})]}),(0,x.jsxs)(`div`,{className:`wb-wf-kpi-tile`,children:[(0,x.jsx)(`small`,{children:`Files`}),(0,x.jsx)(`strong`,{children:L.filesAudited})]}),(0,x.jsxs)(`div`,{className:`wb-wf-kpi-tile`,children:[(0,x.jsx)(`small`,{children:`Issues`}),(0,x.jsx)(`strong`,{children:L.findings.length})]}),(0,x.jsxs)(`div`,{className:`wb-wf-kpi-tile`,children:[(0,x.jsx)(`small`,{children:`Time`}),(0,x.jsxs)(`strong`,{children:[a.totalDurationMs,`ms`]})]})]}),e.id===`node-security-gate`&&R&&(0,x.jsxs)(`div`,{className:`wb-wf-rubric-box`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-rubric-head`,children:[(0,x.jsx)(`strong`,{children:`Audit Score Breakdown`}),(0,x.jsxs)(`span`,{className:`wb-wf-total-score`,children:[L?.score,`/100`]})]}),[R.securitySurface,R.testIntegrity,R.uiCraftAndA11y,R.verificationDepth].map(e=>(0,x.jsxs)(`div`,{className:`wb-wf-pillar-row`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-pillar-top`,children:[(0,x.jsx)(`span`,{children:ee(e.label)}),(0,x.jsxs)(`strong`,{children:[e.score,`/`,e.max]})]}),(0,x.jsx)(`div`,{className:`wb-wf-pillar-track`,children:(0,x.jsx)(`div`,{className:`wb-wf-pillar-fill`,style:{width:`${Math.round(e.score/e.max*100)}%`}})})]},e.label)),z&&(0,x.jsxs)(`div`,{className:`wb-wf-ti-summary`,children:[(0,x.jsxs)(`span`,{children:[`Tests: `,(0,x.jsx)(`strong`,{children:z.testFilesCount})]}),(0,x.jsxs)(`span`,{children:[`Checks: `,(0,x.jsx)(`strong`,{children:z.totalAssertions})]}),(0,x.jsxs)(`span`,{children:[`Empty Tests: `,(0,x.jsx)(`strong`,{children:z.tautologyCount})]})]})]}),e.id===`node-visual-qa`&&B&&(0,x.jsxs)(`div`,{className:`wb-vdiff-lock-box ${B.compliant?`is-clean`:`is-drift`}`,role:`region`,"aria-label":`Component check report`,children:[(0,x.jsxs)(`div`,{className:`wb-vdiff-lock-head`,children:[(0,x.jsx)(`strong`,{children:`Component Check`}),(0,x.jsx)(`span`,{className:`wb-wf-scanner-pill ${B.compliant?`status-ready`:`status-optional`}`,children:B.compliant?`Clean (${B.filesScanned??0} files)`:`${B.violationCount} issue(s)`})]}),(0,x.jsx)(`p`,{className:`wb-wf-note`,children:B.recommendation}),B.violations.length>0&&(0,x.jsx)(`ul`,{className:`wb-vdiff-violation-list`,children:B.violations.slice(0,6).map((e,t)=>(0,x.jsxs)(`li`,{children:[e.path&&(0,x.jsxs)(`code`,{translate:`no`,children:[e.path,e.line?`:${e.line}`:``]}),(0,x.jsx)(`span`,{children:e.message})]},`${e.rule}-${e.path??t}-${t}`))})]}),(e.id===`node-visual-qa`||e.custom?.kind===`playwright`)&&V&&(0,x.jsxs)(`div`,{className:`wb-vdiff-panel`,role:`region`,"aria-label":`Visual diff preview`,children:[(0,x.jsxs)(`div`,{className:`wb-vdiff-lock-head`,children:[(0,x.jsx)(`strong`,{children:`Visual Diff`}),(0,x.jsx)(`span`,{className:`wb-wf-metric-chip`,children:V.viewports.length>0?`${V.maxMismatchPercentage}% · ${V.totalBoundingBoxes} region(s)`:`No screenshots yet`})]}),(0,x.jsx)(`p`,{className:`wb-wf-note`,children:V.summary}),H&&(0,x.jsxs)(`div`,{className:`wb-vdiff-stage-wrap`,children:[(0,x.jsxs)(`div`,{className:`wb-vdiff-toolbar`,children:[(0,x.jsx)(`div`,{className:`wb-vdiff-vp-tabs`,role:`group`,"aria-label":`Viewport`,children:V.viewports.map(e=>(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-pressed":H.name===e.name,onClick:()=>D(e.name),children:e.name},e.name))}),(0,x.jsxs)(`div`,{className:`wb-vdiff-layer-controls`,children:[(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-pressed":O===`before`,onClick:()=>k(`before`),children:`Before`}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-pressed":O===`after`,onClick:()=>k(`after`),children:`After`}),(0,x.jsxs)(`label`,{className:`wb-vdiff-toggle`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>E(e.target.checked)}),`Boxes (`,H.boundingBoxes.length,`)`]})]})]}),(0,x.jsxs)(`div`,{className:`wb-vdiff-canvas`,children:[(0,x.jsx)(`img`,{src:O===`before`?H.beforeUrl:H.afterUrl,alt:`${O===`before`?`Before`:`After`} ${H.name} capture`}),T&&H.width>0&&H.height>0&&H.boundingBoxes.map((e,t)=>(0,x.jsx)(`div`,{className:`wb-vdiff-bbox`,title:`Region #${t+1}: ${e.width}×${e.height}px`,style:{left:`${e.x/H.width*100}%`,top:`${e.y/H.height*100}%`,width:`${Math.max(1.5,e.width/H.width*100)}%`,height:`${Math.max(1.5,e.height/H.height*100)}%`},children:(0,x.jsxs)(`span`,{children:[`#`,t+1]})},`${e.x}-${e.y}-${t}`))]})]})]}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:i,onClick:()=>void F(e.id),children:i?`Running…`:`Re-run Audit`})]}):(0,x.jsxs)(`div`,{className:`wb-wf-empty-output`,children:[(0,x.jsx)(`p`,{children:`Run a local audit to see live results for this step.`}),(0,x.jsx)(`button`,{type:`button`,className:`button primary`,disabled:i,onClick:()=>void F(e.id),children:i?`Running…`:`Run Audit`})]})}),t===`settings`&&(0,x.jsxs)(x.Fragment,{children:[e.custom&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[(0,x.jsxs)(`label`,{children:[`Step Name`,(0,x.jsx)(`input`,{type:`text`,value:e.custom.title,onChange:t=>ge(e.id,{title:t.target.value})})]}),(0,x.jsxs)(`label`,{children:[`Run Order`,(0,x.jsxs)(`select`,{value:e.custom.stage,onChange:t=>_e(e.id,t.target.value),children:[(0,x.jsx)(`option`,{value:`before-ai`,children:`Before AI edits (Context & Design)`}),(0,x.jsx)(`option`,{value:`after-ai`,children:`After AI edits (Checks & QA)`}),(0,x.jsx)(`option`,{value:`delivery`,children:`At Delivery (Git & Export)`})]})]}),e.custom.kind===`figma`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`label`,{children:[`Figma Frame or File URL`,(0,x.jsx)(`input`,{type:`text`,value:e.custom.config.figmaUrl??``,placeholder:`https://www.figma.com/design/...`,onChange:t=>M(e.id,{figmaUrl:t.target.value})})]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`What to Pull from Figma`}),(0,x.jsx)(`div`,{className:`wb-wf-choice-grid`,children:[`Colors & Layout`,`Tokens Only`,`Full Frame`].map(t=>(0,x.jsx)(`button`,{type:`button`,className:`wb-wf-choice-card`,"aria-pressed":(e.custom?.config.figmaMode??`Colors & Layout`)===t,onClick:()=>M(e.id,{figmaMode:t}),children:(0,x.jsx)(`strong`,{children:t})},t))})]})]}),e.custom.kind===`playwright`&&(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Viewports to Capture`}),(0,x.jsx)(`div`,{className:`wb-wf-quick-chips`,children:[`desktop`,`mobile`,`dark`,`motion`].map(t=>{let n=e.custom?.config.viewports??[`desktop`,`mobile`],r=n.includes(t);return(0,x.jsxs)(`button`,{type:`button`,className:`wb-focus-pill`,"aria-pressed":r,onClick:()=>{let i=r?n.filter(e=>e!==t):[...n,t];M(e.id,{viewports:i.length?i:[`desktop`]})},children:[r?`✓ `:`+ `,t]},t)})})]}),e.custom.kind===`git`&&(0,x.jsxs)(`label`,{children:[`Export Branch Prefix`,(0,x.jsx)(`input`,{type:`text`,value:e.custom.config.branchPrefix??`studio/`,placeholder:`studio/`,onChange:t=>M(e.id,{branchPrefix:t.target.value})})]}),(0,x.jsxs)(`label`,{children:[`Step Notes / Instructions`,(0,x.jsx)(`input`,{type:`text`,value:e.custom.config.notes??``,placeholder:`Optional guidance for this step…`,onChange:t=>M(e.id,{notes:t.target.value})})]}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:i,onClick:()=>void F(e.id),children:i?`Running…`:`Test This Step`})]}),!e.custom&&e.id===`node-intake`&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[(0,x.jsxs)(`label`,{children:[`Project Type`,(0,x.jsxs)(`select`,{value:s.framework??`auto`,onChange:e=>c(t=>({...t,framework:e.target.value})),children:[(0,x.jsx)(`option`,{value:`auto`,children:`Auto-detect`}),(0,x.jsx)(`option`,{value:`static-html`,children:`Static HTML / CSS`}),(0,x.jsx)(`option`,{value:`react-vite`,children:`React + Vite`}),(0,x.jsx)(`option`,{value:`nextjs-app`,children:`Next.js (App Router)`}),(0,x.jsx)(`option`,{value:`nextjs-pages`,children:`Next.js (Pages Router)`})]})]}),(0,x.jsxs)(`label`,{children:[`Task Focus`,(0,x.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),children:[(0,x.jsx)(`option`,{value:`ui`,children:`UI Redesign`}),(0,x.jsx)(`option`,{value:`audit`,children:`Quick Audit`}),(0,x.jsx)(`option`,{value:`seo`,children:`SEO & Page Structure`}),(0,x.jsx)(`option`,{value:`ai-search`,children:`AI Search Readiness`}),(0,x.jsx)(`option`,{value:`architecture`,children:`Project Map`})]})]}),(0,x.jsxs)(`label`,{children:[`Local Dev Command`,(0,x.jsxs)(`select`,{value:s.previewCommand??``,onChange:e=>c(t=>({...t,...e.target.value?{previewCommand:e.target.value}:{previewCommand:void 0}})),children:[(0,x.jsx)(`option`,{value:``,children:`Auto-detect build`}),(0,x.jsx)(`option`,{value:`npm run dev`,children:`npm run dev`}),(0,x.jsx)(`option`,{value:`npm run preview`,children:`npm run preview`}),(0,x.jsx)(`option`,{value:`npm run start`,children:`npm run start`}),(0,x.jsx)(`option`,{value:`npx vite`,children:`npx vite`}),(0,x.jsx)(`option`,{value:`npx next dev`,children:`npx next dev`})]})]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Pages to Check`}),(0,x.jsx)(`div`,{className:`wb-wf-tag-list`,children:(s.routes??[`/`]).map(e=>(0,x.jsxs)(`span`,{className:`wb-wf-tag`,children:[(0,x.jsx)(`code`,{children:e}),(s.routes?.length??0)>1&&(0,x.jsx)(`button`,{type:`button`,"aria-label":`Remove page ${e}`,onClick:()=>c(t=>({...t,routes:(t.routes??[`/`]).filter(t=>t!==e)})),children:`×`})]},e))}),(0,x.jsxs)(`div`,{className:`wb-wf-inline-add`,children:[(0,x.jsx)(`input`,{type:`text`,value:oe,placeholder:`/pricing`,onChange:e=>A(e.target.value)}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{let e=oe.trim();e.startsWith(`/`)&&(c(t=>({...t,routes:Array.from(new Set([...t.routes??[`/`],e])).slice(0,8)})),A(``))},children:`Add`})]})]})]}),!e.custom&&e.id===`node-context`&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[u!==`ui`&&(0,x.jsxs)(`div`,{className:`wb-wf-info-callout`,children:[`Skipped in `,(0,x.jsx)(`strong`,{children:_(u)}),` mode. Switch to`,` `,(0,x.jsx)(`strong`,{children:`UI Redesign`}),` above to use design styles.`]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Visual Direction`}),(0,x.jsx)(`div`,{className:`wb-wf-choice-grid`,role:`group`,"aria-label":`Design guide`,children:[{id:`impeccable`,title:`Modern`,desc:`Clean, balanced UI`},{id:`hallmark`,title:`Editorial`,desc:`Bold & reference-led`},{id:`project`,title:`Keep Mine`,desc:`Match current styles`}].map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`wb-wf-choice-card`,"aria-pressed":(s.designGuide??`impeccable`)===e.id,onClick:()=>c(t=>({...t,designGuide:e.id})),children:[(0,x.jsx)(`strong`,{children:e.title}),(0,x.jsx)(`small`,{children:e.desc})]},e.id))})]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Active Guides`}),(0,x.jsx)(`div`,{className:`wb-wf-skill-checklist`,children:(o?.hubCatalog.skills??[]).map(e=>{let t=(s.pinnedSkills??[]).includes(e.id);return(0,x.jsxs)(`label`,{className:`wb-wf-skill-check`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>N(e.id)}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`strong`,{children:e.label}),(0,x.jsx)(`small`,{children:e.category})]})]},e.id)})})]})]}),!e.custom&&e.id===`node-scope`&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Folders to Include`}),(0,x.jsx)(`div`,{className:`wb-wf-tag-list`,children:(s.includeDirs??[]).map(e=>(0,x.jsxs)(`span`,{className:`wb-wf-tag`,children:[(0,x.jsx)(`code`,{children:e}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Remove folder ${e}`,onClick:()=>c(t=>({...t,includeDirs:(t.includeDirs??[]).filter(t=>t!==e)})),children:`×`})]},e))}),(0,x.jsxs)(`div`,{className:`wb-wf-inline-add`,children:[(0,x.jsx)(`input`,{type:`text`,value:se,placeholder:`src/components`,onChange:e=>j(e.target.value)}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{let e=se.trim().replace(/^\/+|\/+$/g,``);e&&(c(t=>({...t,includeDirs:Array.from(new Set([...t.includeDirs??[],e])).slice(0,16)})),j(``))},children:`Add`})]})]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Must Keep Working`}),(0,x.jsx)(`div`,{className:`wb-wf-quick-chips`,children:p.map(e=>{let t=(s.mustPreserve??[]).includes(e);return(0,x.jsxs)(`button`,{type:`button`,className:`wb-focus-pill`,"aria-pressed":t,onClick:()=>P(e),children:[t?`✓ `:`+ `,e]},e)})}),(0,x.jsx)(`div`,{className:`wb-wf-tag-list`,children:(s.mustPreserve??[]).filter(e=>!p.includes(e)).map(e=>(0,x.jsxs)(`span`,{className:`wb-wf-tag`,children:[(0,x.jsx)(`span`,{children:e}),(0,x.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>P(e),children:`×`})]},e))}),(0,x.jsxs)(`div`,{className:`wb-wf-inline-add`,children:[(0,x.jsx)(`input`,{type:`text`,value:ce,placeholder:`Custom item or #selector`,onChange:e=>le(e.target.value)}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{let e=ce.trim();e&&(c(t=>({...t,mustPreserve:Array.from(new Set([...t.mustPreserve??[],e])).slice(0,16)})),le(``))},children:`Add`})]})]})]}),!e.custom&&e.id===`node-engine`&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`AI Run Size`}),(0,x.jsx)(`div`,{className:`wb-wf-choice-grid`,role:`group`,"aria-label":`AI size`,children:[{id:`light`,title:`Light`,desc:`8k · $0.10`,tok:8192,cost:.1},{id:`balanced`,title:`Balanced`,desc:`16k · $0.25`,tok:16384,cost:.25},{id:`deep`,title:`Deep`,desc:`32k · $0.75`,tok:32768,cost:.75}].map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`wb-wf-choice-card`,"aria-pressed":b===e.tok&&ne===e.cost,onClick:()=>{te(e.tok),re(e.cost)},children:[(0,x.jsx)(`strong`,{children:e.title}),(0,x.jsx)(`small`,{children:e.desc})]},e.id))})]}),(0,x.jsxs)(`details`,{className:`wb-wf-subdetails`,children:[(0,x.jsx)(`summary`,{children:`Custom limits`}),(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,style:{marginTop:`8px`},children:[(0,x.jsxs)(`label`,{children:[`Max Output (`,(b/1024).toFixed(0),`k tokens)`,(0,x.jsx)(`input`,{type:`range`,min:4096,max:65536,step:2048,value:b,onChange:e=>te(Number(e.target.value))})]}),(0,x.jsxs)(`label`,{children:[`Cost Cap ($`,ne.toFixed(2),`)`,(0,x.jsx)(`input`,{type:`number`,min:.01,max:10,step:.05,value:ne,onChange:e=>re(Number(e.target.value)||.25)})]})]})]}),(0,x.jsx)(`p`,{className:`wb-wf-note`,children:`Only applies to AI edits. Local audits use zero API credits.`})]}),!e.custom&&e.id===`node-visual-qa`&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[(0,x.jsxs)(`label`,{className:`wb-wf-skill-check`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`strong`,{children:`Strict Component Check`}),(0,x.jsxs)(`small`,{children:[`Warn on raw `,(0,x.jsx)(`code`,{children:`<button>`}),` tags or inline hex colors when your project uses reusable components.`]})]})]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Pixel Change Tolerance`}),(0,x.jsx)(`div`,{className:`wb-wf-choice-grid`,role:`group`,"aria-label":`Diff sensitivity`,children:[{label:`Strict`,val:.05,desc:`5% pixel`},{label:`Normal`,val:.1,desc:`10% pixel`},{label:`Relaxed`,val:.2,desc:`20% pixel`}].map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`wb-wf-choice-card`,"aria-pressed":Math.abs(ie-e.val)<.02,onClick:()=>w(e.val),children:[(0,x.jsx)(`strong`,{children:e.label}),(0,x.jsx)(`small`,{children:e.desc})]},e.label))})]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,children:[(0,x.jsx)(`span`,{children:`Click & Keyboard Checks`}),(0,x.jsx)(`ul`,{className:`wb-wf-step-list`,children:(s.interactions??[]).map((e,t)=>(0,x.jsxs)(`li`,{children:[(0,x.jsxs)(`span`,{children:[(0,x.jsxs)(`strong`,{children:[t+1,`.`]}),` `,e]}),(0,x.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>c(t=>({...t,interactions:(t.interactions??[]).filter(t=>t!==e)})),children:`Remove`})]},e))}),(0,x.jsxs)(`div`,{className:`wb-wf-inline-add`,children:[(0,x.jsx)(`input`,{type:`text`,value:ue,placeholder:`Click main button and check dialog`,onChange:e=>de(e.target.value)}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{let e=ue.trim();e&&(c(t=>({...t,interactions:Array.from(new Set([...t.interactions??[],e])).slice(0,16)})),de(``))},children:`Add`})]})]}),(0,x.jsxs)(`details`,{className:`wb-wf-subdetails`,children:[(0,x.jsxs)(`summary`,{children:[`Muted non-critical warnings (`,(s.ignoreChecks??[]).length,`)`]}),(0,x.jsxs)(`div`,{className:`wb-wf-list-editor`,style:{marginTop:`8px`},children:[(0,x.jsx)(`div`,{className:`wb-wf-tag-list`,children:(s.ignoreChecks??[]).map(e=>(0,x.jsxs)(`span`,{className:`wb-wf-tag`,children:[(0,x.jsx)(`code`,{children:e}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>c(t=>({...t,ignoreChecks:(t.ignoreChecks??[]).filter(t=>t!==e)})),children:`×`})]},e))}),(0,x.jsxs)(`div`,{className:`wb-wf-inline-add`,children:[(0,x.jsx)(`input`,{type:`text`,value:fe,placeholder:`MISSING_REDUCED_MOTION_SUPPORT`,onChange:e=>pe(e.target.value)}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{let e=fe.trim().toUpperCase();e&&(o?.hubCatalog.nonIgnorableChecks.includes(e)?me(`Security rule ${e} cannot be ignored.`):(c(t=>({...t,ignoreChecks:Array.from(new Set([...t.ignoreChecks??[],e])).slice(0,16)})),pe(``)))},children:`Ignore`})]})]})]})]}),!e.custom&&e.id===`node-security-gate`&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[(0,x.jsxs)(`label`,{children:[`Passing Score (`,m,` / 100)`,(0,x.jsx)(`input`,{type:`range`,min:45,max:95,step:1,value:m,onChange:e=>y(Number(e.target.value))})]}),(0,x.jsxs)(`div`,{className:`wb-wf-scanners-box`,children:[(0,x.jsx)(`span`,{children:`Built-in Checks`}),(0,x.jsx)(`ul`,{children:(o?.toolchain.scanners??[]).map(e=>(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:v(e.name)}),(0,x.jsx)(`span`,{className:`wb-wf-scanner-pill status-${e.status}`,children:e.status===`ready`?`Ready`:`Optional`})]},e.id))})]}),R&&(0,x.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>r(`output`),children:[`View Score Breakdown (`,L?.score,`/100)`]})]}),!e.custom&&e.id===`node-delivery`&&(0,x.jsxs)(`div`,{className:`wb-wf-inspector-form`,children:[(0,x.jsxs)(`ol`,{className:`wb-wf-simple-steps`,children:[(0,x.jsx)(`li`,{children:`Preview changes side-by-side before touching your project.`}),(0,x.jsx)(`li`,{children:`Apply only the files you approve.`}),(0,x.jsx)(`li`,{children:`Use 1-click Undo anytime to restore originals.`})]}),I&&(0,x.jsx)(`button`,{type:`button`,className:`button primary`,onClick:I,children:`Open in Workspace`})]})]})]})}var C={version:1,pinnedSkills:[],designGuide:null,framework:`auto`,routes:[`/`,`/pricing`],includeDirs:[`src`,`app`,`components`],mustPreserve:[`Primary navigation`,`Keyboard focus rings`,`Responsive mobile menu`],ignoreChecks:[]};function ie({resultsRef:e,executionResult:t,severityFilter:r,setSeverityFilter:i,copiedChecklist:o,copyFindingsChecklist:s,onFixFindings:c,onSendToSlack:l,onCreateGitHubIssue:u,slackSending:d=!1,ghIssueSending:f=!1,showRawJson:p,rules:m,isDemoFallback:h=!1,savingRules:g=!1,onSaveRawRules:_}){let[ee,v]=(0,a.useState)(null),[y,b]=(0,a.useState)(!1),[te,ne]=(0,a.useState)(()=>JSON.stringify(m,null,2)),[re,S]=(0,a.useState)(``),[ie,w]=(0,a.useState)(!1);(0,a.useEffect)(()=>{ne(JSON.stringify(m,null,2)),S(``)},[m]);let T=t?.securityReport,E=t?.designSystemLock,ae=(()=>{let e=T?.findings??[];return r===`all`?e:r===`high`?e.filter(e=>e.severity===`critical`||e.severity===`high`):e.filter(e=>e.severity===r)})();function D(){if(!T)return;let e=[`Fix the following UI and security findings (current score: ${T.score}/100):`,``,...T.findings.length>0?T.findings.slice(0,15).map((e,t)=>{let n=e.path?`${e.path}${e.line?`:${e.line}`:``}`:`project`;return`${t+1}. [${e.severity.toUpperCase()}] ${n} — ${e.message}${e.action?` (Fix: ${e.action})`:``}`}):[`No issues found.`],``,`Keep existing layouts, keyboard navigation, and component boundaries intact.`];navigator.clipboard?.writeText(e.join(`
2
- `)).catch(()=>{}),b(!0),window.setTimeout(()=>b(!1),1800)}async function O(){S(``);let e;try{e=JSON.parse(te)}catch(e){S(`Invalid JSON: ${e.message}`);return}!e||typeof e!=`object`||Array.isArray(e)?S(`Rules must be a JSON object (for example { "version": 1, "routes": ["/"] }).`):_&&await _(e)}return(0,x.jsxs)(x.Fragment,{children:[t&&T&&(0,x.jsxs)(`section`,{ref:e,className:`wb-wf-audit-results`,"aria-label":`Workflow audit results`,children:[(0,x.jsxs)(`div`,{className:`wb-quick-audit-head`,children:[(0,x.jsxs)(`div`,{className:`wb-quick-audit-title`,children:[(0,x.jsxs)(`h3`,{children:[`Audit Results · `,T.score,`/100`]}),(0,x.jsx)(`span`,{className:`wb-wf-scanner-pill ${t.gatePassed?`status-ready`:`status-optional`}`,children:t.gatePassed?`Passed`:`Needs fixes`}),(0,x.jsxs)(`span`,{className:`wb-quick-audit-meta`,children:[T.filesAudited,` files · `,t.totalDurationMs,`ms`]})]}),(0,x.jsxs)(`div`,{className:`wb-quick-audit-actions`,children:[(0,x.jsx)(`div`,{className:`wb-wf-sev-filters`,role:`group`,"aria-label":`Filter issues`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,x.jsx)(`button`,{type:`button`,className:`wb-focus-pill`,"aria-pressed":r===e,onClick:()=>i(e),children:e===`all`?`All (${T.findings.length})`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:D,children:y?`Copied prompt`:`Copy AI fix prompt`}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void s(),children:o?`Copied!`:`Copy checklist`}),l&&(0,x.jsxs)(`button`,{type:`button`,className:`button subtle`,disabled:d,onClick:()=>void l(),children:[(0,x.jsx)(n,{name:`slack`}),d?`Sending…`:`Send to Slack`]}),u&&(0,x.jsxs)(`button`,{type:`button`,className:`button subtle`,disabled:f,onClick:()=>void u(),children:[(0,x.jsx)(n,{name:`github`}),f?`Creating…`:`GitHub Issue`]}),c&&(T.findings.length>0||(E?.violationCount??0)>0)&&(0,x.jsx)(`button`,{type:`button`,className:`button primary`,onClick:()=>c(t),children:`Fix in Workspace`})]})]}),ae.length>0?(0,x.jsx)(`ul`,{className:`wb-quick-audit-list`,children:ae.slice(0,14).map((e,n)=>{let r=`${e.code}-${e.path??n}-${n}`,i=e.path?`${e.path}${e.line?`:${e.line}`:``}`:`project`,a=`Fix [${e.code}] (${e.severity}) in ${i}: ${e.message}.${e.action?` Recommended fix: ${e.action}`:``}`;return(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`span`,{className:`wb-sev-badge sev-${e.severity}`,children:e.severity}),(0,x.jsxs)(`div`,{className:`wb-quick-audit-item-body`,children:[(0,x.jsx)(`strong`,{children:e.message}),(0,x.jsxs)(`small`,{children:[e.path?(0,x.jsxs)(`code`,{translate:`no`,children:[e.path,e.line?`:${e.line}`:``]}):null,e.path&&e.action?` · `:``,e.action]})]}),(0,x.jsxs)(`div`,{className:`wb-quick-audit-item-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>{navigator.clipboard?.writeText(a).catch(()=>{}),v(r),window.setTimeout(()=>v(e=>e===r?null:e),1800)},children:ee===r?`Copied`:`Copy AI prompt`}),c&&(0,x.jsx)(`button`,{type:`button`,className:`button subtle wb-fix-one-btn`,onClick:()=>c({...t,securityReport:{...T,findings:[e]}}),children:`Fix`})]})]},r)})}):(0,x.jsx)(`p`,{className:`wb-quick-audit-clean`,children:T.findings.length===0?`No security or accessibility issues found.`:`No ${r} issues found.`})]}),p&&(0,x.jsxs)(`section`,{className:`wb-wf-json-drawer`,"aria-label":`Edit .ui-workflow.json`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-json-head`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`strong`,{children:`.ui-workflow.json`}),(0,x.jsx)(`span`,{className:`wb-wf-focus-note`,children:`Controls which pages, folders, and rules Studio and the CLI check.`})]}),(0,x.jsxs)(`div`,{className:`wb-wf-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>{ne(JSON.stringify(C,null,2)),S(``)},children:`Use starter rules`}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{try{let e=JSON.parse(te);ne(JSON.stringify(e,null,2)),S(``)}catch(e){S(`Invalid JSON: ${e.message}`)}},children:`Format`}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{navigator.clipboard?.writeText(te).catch(()=>{}),w(!0),window.setTimeout(()=>w(!1),1600)},children:ie?`Copied`:`Copy`}),_&&(0,x.jsx)(`button`,{type:`button`,className:`button primary`,disabled:g,onClick:()=>void O(),children:g?`Saving…`:h?`Apply rules`:`Save to .ui-workflow.json`})]})]}),re&&(0,x.jsx)(`p`,{className:`error-box`,role:`alert`,children:re}),(0,x.jsx)(`textarea`,{className:`wb-wf-json-editor`,"aria-label":`Edit .ui-workflow.json rules`,spellCheck:!1,rows:12,value:te,onChange:e=>{ne(e.target.value),re&&S(``)}})]})]})}function w({project:e,picking:t,onBrowse:r,onOpenRepositories:l,onOpenComposer:f,onFixFindings:p,onRulesSaved:h}){let[g,ee]=(0,a.useState)(null),[v,C]=(0,a.useState)({version:1,pinnedSkills:[`impeccable`,`security-review`,`coderabbit-code-review`],mustPreserve:[`Main navigation`,`Keyboard focus`],designGuide:`impeccable`,includeDirs:[`src`,`app`,`components`],routes:[`/`],framework:`auto`,ignoreChecks:[],ignoreSelectors:[],interactions:[`Check main button click and keyboard focus`]}),[w,T]=(0,a.useState)(`ui`),[E,ae]=(0,a.useState)(72),[D,O]=(0,a.useState)(16384),[k,oe]=(0,a.useState)(.25),[A,se]=(0,a.useState)(!1),[j,ce]=(0,a.useState)(.1),[le,ue]=(0,a.useState)(!0),[de,fe]=(0,a.useState)(`desktop`),[pe,me]=(0,a.useState)(`after`),[he,ge]=(0,a.useState)(null),[M,_e]=(0,a.useState)(!1),[N,P]=(0,a.useState)([]),[F,I]=(0,a.useState)([]),[L,R]=(0,a.useState)(`default`),[z,B]=(0,a.useState)([]),[V,H]=(0,a.useState)(!1),[U,ve]=(0,a.useState)(``),[ye,be]=(0,a.useState)(`after-ai`),[xe,Se]=(0,a.useState)(``),[Ce,we]=(0,a.useState)(!1),[Te,Ee]=(0,a.useState)(``),[De,W]=(0,a.useState)(o),G=(0,a.useRef)(De);G.current=De;let[Oe,ke]=(0,a.useState)({}),[Ae,K]=(0,a.useState)(`node-security-gate`),[je,Me]=(0,a.useState)(!0),[Ne,Pe]=(0,a.useState)(`settings`),[q,Fe]=(0,a.useState)(!1),[Ie,Le]=(0,a.useState)(.8),[Re,ze]=(0,a.useState)({x:16,y:20}),[Be,Ve]=(0,a.useState)(!1),[He,Ue]=(0,a.useState)(null),[We,Ge]=(0,a.useState)(!1),[Ke,qe]=(0,a.useState)(`all`),[Je,Ye]=(0,a.useState)(!1),[Xe,Ze]=(0,a.useState)(!1),[Qe,$e]=(0,a.useState)(!1),[J,et]=(0,a.useState)(`recipes`),[tt,nt]=(0,a.useState)(null),[rt,it]=(0,a.useState)(null),[at,ot]=(0,a.useState)(null),[st,ct]=(0,a.useState)(!1),[lt,ut]=(0,a.useState)(!1),[dt,ft]=(0,a.useState)([]),[pt,mt]=(0,a.useState)(null),[ht,gt]=(0,a.useState)(!0),[_t,vt]=(0,a.useState)(!1),[yt,bt]=(0,a.useState)(!1),[xt,St]=(0,a.useState)(null),[Y,Ct]=(0,a.useState)(null),[wt,X]=(0,a.useState)(``),[Tt,Z]=(0,a.useState)(``),[Et,Dt]=(0,a.useState)(``),[Ot,kt]=(0,a.useState)(``),[At,jt]=(0,a.useState)(``),[Mt,Nt]=(0,a.useState)(``),[Pt,Ft]=(0,a.useState)(``),It=(0,a.useRef)(null),Lt=(0,a.useRef)(null),Rt=(0,a.useRef)(null),zt=(0,a.useRef)(null),Bt=(0,a.useRef)(!1),Vt=(0,a.useRef)([]),Q=(0,a.useCallback)((e,t)=>{let n=It.current;if(!n)return;let r=n.getBoundingClientRect();if(!r.width||!r.height)return;let i=e??G.current,a=t??(Vt.current.length?Vt.current:null),o=a?a.map(e=>i[e]).filter(e=>!!e):Object.values(i);if(!o.length)return;let s=Math.min(...o.map(e=>e.x))-10,c=Math.min(...o.map(e=>e.y))-16,l=Math.max(...o.map(e=>e.x+216+16)),u=Math.max(...o.map(e=>e.y+114+24)),d=Math.max(420,l-s),f=Math.max(240,u-c),p=y(Math.min((r.width-44)/d,(r.height-44)/f),.3,1.05),m=Math.floor(p*100)/100,h=d*m,g=f*m,_=h+44>r.width?Math.round(22-s*m):Math.round((r.width-h)/2-s*m),ee=g+44>r.height?Math.round(22-c*m):Math.round((r.height-g)/2-c*m);Le(m),ze({x:_,y:ee})},[]),Ht=(0,a.useCallback)(async()=>{gt(!0),Z(``);try{let t=e?`?project=${encodeURIComponent(e)}`:``,n=await i(`/api/workflow-graph${t}`);ee(n),C(n.rules),ft(n.runHistory??[]),mt(n.runTrend??null),T(n.canvasState.profile||`ui`),ae(n.canvasState.minScoreThreshold||72),O(n.canvasState.maxOutputTokens||16384),oe(n.canvasState.maxCostUsd||.25),se(!!n.canvasState.strictDesignSystem),ce(typeof n.canvasState.visualDiffThreshold==`number`?n.canvasState.visualDiffThreshold:.1);let r=n.canvasState.customNodes??[],a=n.canvasState.hiddenCoreNodes??[];P(r),I(a),R(n.canvasState.activeWorkflowId||`default`),B(n.canvasState.savedWorkflows??[]),ke(n.canvasState.enabledNodes??{});let o=b(a,r),c=n.canvasState.positions??{},l=c[`node-delivery`]?.x,u=c[`node-visual-qa`]?.x,d=typeof l==`number`&&typeof u==`number`&&l-u<285,f={...o};if(!d)for(let[e,t]of Object.entries(c))t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&(f[e]={x:y(Math.round(t.x),12,s-216-12),y:y(Math.round(t.y),12,454)});G.current=f,W(f),i(`/api/cloud-sync/status`).then(ge).catch(()=>{}),requestAnimationFrame(()=>Q(f))}catch(e){Z(e.message)}finally{gt(!1)}},[e,Q]);(0,a.useEffect)(()=>{Ht()},[Ht]),(0,a.useEffect)(()=>{if(J!==`graph`)return;let e=window.setTimeout(()=>Q(),70);return()=>window.clearTimeout(e)},[J,q,je,V,Q]),(0,a.useEffect)(()=>{if(J!==`graph`)return;let e=It.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>Q())});return n.observe(e),()=>{cancelAnimationFrame(t),n.disconnect()}},[J,Q]),(0,a.useEffect)(()=>{if(!q){delete document.documentElement.dataset.wfFullscreen;return}document.documentElement.dataset.wfFullscreen=`true`;let e=document.documentElement.style.overflow;document.documentElement.style.overflow=`hidden`;let t=e=>{e.key===`Escape`&&Fe(!1)};return window.addEventListener(`keydown`,t),()=>{delete document.documentElement.dataset.wfFullscreen,document.documentElement.style.overflow=e,window.removeEventListener(`keydown`,t)}},[q]);let $=(0,a.useMemo)(()=>{let e=new Set(F),t=(g?.nodes?.length?g.nodes:m).filter(t=>!e.has(t.id)),n=g?.toolchain.scanners?g.toolchain.scanners.filter(e=>e.status===`ready`).length:3,r=w!==`ui`,i=w===`audit`,a=t.map(e=>{let t=De[e.id]??o[e.id]??{x:48,y:204},a=e.id===`node-context`&&r?!1:e.locked?!0:Oe[e.id]!==!1,s=xt===e.id?`running`:Y?.nodeResults?.[e.id]?.status??`ready`,l=d.has(e.id);if(e.id===`node-intake`)return{...e,category:`Step 1`,title:`Project`,position:t,enabled:a,status:s,removable:!1,subtitle:`${c(v.framework,g?.detectedStack)} · ${_(w)}`};if(e.id===`node-context`){let n=v.designGuide===`hallmark`?`Editorial`:v.designGuide===`project`?`Keep mine`:`Modern default`;return{...e,category:`Step 2`,title:`Design Style`,position:t,enabled:a,status:s,removable:l,subtitle:r?`Skipped for ${_(w)}`:`${n} · ${(v.pinnedSkills??[]).length} guides`}}if(e.id===`node-scope`)return{...e,category:`Step 3`,title:`Files & Rules`,position:t,enabled:a,status:s,removable:l,subtitle:`${(v.includeDirs??[]).length||`All`} folders · ${(v.mustPreserve??[]).length} kept`};if(e.id===`node-engine`){let n=D<=8192?`Light`:D>=32768?`Deep`:`Balanced`;return{...e,category:`Step 4`,title:`AI Helper`,position:t,enabled:a,status:s,removable:!1,subtitle:i?`Skipped during local audit`:`${n} · $${k.toFixed(2)} cap`}}if(e.id===`node-visual-qa`){let n=Y?.designSystemLock,r=Y?.visualDiff,i=j<=.06?`Strict`:j>=.16?`Relaxed`:`Normal`;return{...e,category:`Step 5`,title:`Visual Check`,position:t,enabled:a,status:s,removable:l,subtitle:n?`${n.compliant?`Components clean`:`${n.violationCount} component issue(s)`}${r?.viewports?.length?` · ${r.maxMismatchPercentage}% diff`:``}`:`${i} diff · ${A?`Strict`:`Standard`}`}}if(e.id===`node-security-gate`){let r=Y?.securityReport?.score;return{...e,category:`Step 6`,title:`Security & Code Audit`,position:t,enabled:a,status:s,removable:l,subtitle:r===void 0?`${n} local checks · Pass at ${E}`:`Score ${r}/100 · ${Y?.securityReport.findings.length??0} issue(s)`}}return{...e,category:`Step 7`,title:`Review & Apply`,position:t,enabled:a,status:s,removable:!1,subtitle:`Preview first · 1-click Undo`}}),s=N.map(e=>{let t=De[e.id]??{x:e.stage===`before-ai`?360:e.stage===`delivery`?1296:984,y:448},n=xt===e.id?`running`:Y?.nodeResults?.[e.id]?.status??`ready`,r=e.kind===`figma`?e.config.figmaUrl?`Linked · ${e.config.figmaMode||`Tokens`}`:`Add Figma link in settings`:e.kind===`playwright`?`${(e.config.viewports??[`desktop`,`mobile`]).join(`, `)}`:e.kind===`git`?`Branch "${e.config.branchPrefix||`studio/`}"`:e.subtitle||e.config.notes||`Ready`;return{id:e.id,type:e.stage===`before-ai`?`context`:e.stage===`delivery`?`output`:`verification`,category:e.kind===`figma`||e.kind===`git`||e.kind===`references`?`Connector`:e.kind===`custom`?`Custom`:`Module`,title:e.title,subtitle:r,position:t,enabled:e.enabled,locked:!1,status:n,metrics:[],config:e.config,custom:e,removable:!0}});return[...a,...s]},[g,F,N,De,Oe,xt,Y,v,w,D,k,E,A,j]);Vt.current=$.map(e=>e.id);let Ut=(0,a.useMemo)(()=>{let e=new Set($.map(e=>e.id)),t=[],n=$.filter(e=>e.id===`node-context`||e.id===`node-scope`||e.custom?.stage===`before-ai`),r=$.filter(e=>e.id===`node-visual-qa`||e.id===`node-security-gate`||e.custom?.stage===`after-ai`),i=$.filter(e=>e.custom?.stage===`delivery`);if(n.length>0)for(let e of n){let n=e.id===`node-context`?`style`:e.id===`node-scope`?`files`:e.custom?.kind===`figma`?`figma`:`input`;t.push({id:`e-in-${e.id}`,source:`node-intake`,target:e.id,label:n}),t.push({id:`e-${e.id}-ai`,source:e.id,target:`node-engine`,label:`guide`})}else e.has(`node-intake`)&&e.has(`node-engine`)&&t.push({id:`e-in-ai`,source:`node-intake`,target:`node-engine`,label:`files`});if(r.length>0)for(let e of r){let n=e.id===`node-visual-qa`?`preview`:e.id===`node-security-gate`?`code`:e.custom?.kind===`playwright`?`browser`:e.custom?.kind===`seo`?`seo`:e.custom?.kind===`graphify`?`map`:`check`;t.push({id:`e-ai-${e.id}`,source:`node-engine`,target:e.id,label:n}),t.push({id:`e-${e.id}-del`,source:e.id,target:`node-delivery`,label:e.id===`node-security-gate`?`audit`:`pass`})}else e.has(`node-engine`)&&e.has(`node-delivery`)&&t.push({id:`e-ai-del`,source:`node-engine`,target:`node-delivery`,label:`diff`});for(let e of i)t.push({id:`e-del-${e.id}`,source:`node-delivery`,target:e.id,label:e.custom?.kind===`git`?`branch`:`next`});return t.filter(t=>e.has(t.source)&&e.has(t.target))},[$]),Wt=$.find(e=>e.id===Ae)??$[0]??null;(0,a.useEffect)(()=>{let e=e=>e instanceof HTMLElement&&!!e.closest(`input, textarea, select, [contenteditable="true"]`),t=e=>e instanceof HTMLElement&&!!e.closest(`button, a, [role="button"], [role="tab"]`),n=n=>{if(!(n.defaultPrevented||document.querySelector(`dialog[open], .settings-page`))){if(n.key===`Escape`){if(at){n.preventDefault(),ot(null);return}if(V){n.preventDefault(),H(!1);return}if(We){n.preventDefault(),Ge(!1);return}q&&(n.preventDefault(),Fe(!1))}else J===`graph`&&(n.key===` `&&!e(n.target)&&!t(n.target)?(n.preventDefault(),Bt.current=!0):e(n.target)||((n.ctrlKey||n.metaKey)&&(n.key===`0`||n.code===`Numpad0`)?(n.preventDefault(),Q()):n.metaKey||n.ctrlKey||n.altKey||(n.key===`0`||n.code===`Numpad0`?(n.preventDefault(),Q()):n.key===`+`||n.key===`=`||n.code===`NumpadAdd`?(n.preventDefault(),Le(e=>y(Number((e+.1).toFixed(2)),.3,1.5))):n.key===`-`||n.key===`_`||n.code===`NumpadSubtract`?(n.preventDefault(),Le(e=>y(Number((e-.1).toFixed(2)),.3,1.5))):n.key.toLowerCase()===`a`?(n.preventDefault(),H(e=>!e)):(n.key===`Delete`||n.key===`Backspace`)&&Wt?.removable&&(n.preventDefault(),Zt(Wt.id)))))}},r=e=>{e.key===` `&&(Bt.current=!1)},i=()=>{Bt.current=!1};return window.addEventListener(`keydown`,n),window.addEventListener(`keyup`,r),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`keyup`,r),window.removeEventListener(`blur`,i)}},[V,at,Q,q,Wt,We,J,F,N]);let[Gt,Kt]=(0,a.useState)(null);function qt(e){Kt(e),be(e),H(!0)}function Jt(e,t){let n=`mod-${e.kind}-${Date.now().toString(36).slice(-4)}`,r=t??Gt??e.stage,i={id:n,kind:e.kind,stage:r,title:e.title,subtitle:e.desc.slice(0,48),enabled:!0,connectorId:e.connectorId,moduleId:e.moduleId,config:{...e.defaultConfig}},a=[...N,i],o=b(F,a);P(a),G.current=o,W(o),K(n),Me(!0),Pe(`settings`),H(!1),Kt(null),X(`Added "${e.title}" to your workflow.`),requestAnimationFrame(()=>Q(o))}function Yt(){let e=U.trim();if(!e)return;let t=`custom-${Date.now().toString(36).slice(-5)}`,n={id:t,kind:`custom`,stage:ye,title:e.slice(0,48),subtitle:xe.trim().slice(0,60)||`Custom workflow step`,enabled:!0,config:{notes:xe.trim()}},r=[...N,n],i=b(F,r);P(r),G.current=i,W(i),K(t),Me(!0),Pe(`settings`),ve(``),Se(``),H(!1),X(`Created custom step "${n.title}".`),requestAnimationFrame(()=>Q(i))}function Xt(e){let t=F.filter(t=>t!==e),n=b(t,N);I(t),G.current=n,W(n),K(e),H(!1),requestAnimationFrame(()=>Q(n))}function Zt(e){if(d.has(e)){let t=Array.from(new Set([...F,e])),n=b(t,N);I(t),G.current=n,W(n),Ae===e&&K(`node-intake`),X(`Removed step from workflow (you can add it back anytime from + Add Step).`),requestAnimationFrame(()=>Q(n));return}let t=N.find(t=>t.id===e);if(!t)return;let n=N.filter(t=>t.id!==e),r=b(F,n);P(n),G.current=r,W(r),Ae===e&&K(`node-security-gate`),X(`Removed "${t.title}" from workflow.`),requestAnimationFrame(()=>Q(r))}function Qt(e,t){P(n=>n.map(n=>n.id===e?{...n,...t}:n))}function $t(e,t){P(n=>n.map(n=>n.id===e?{...n,config:{...n.config,...t}}:n))}function en(e,t){let n=N.map(n=>n.id===e?{...n,stage:t}:n),r=b(F,n);P(n),G.current=r,W(r),requestAnimationFrame(()=>Q(r))}function tn(e){let t=u.find(t=>t.id===e);if(t){let e=b(t.hiddenCoreNodes,t.customNodes);R(t.id),T(t.profile),I(t.hiddenCoreNodes),P(t.customNodes),G.current=e,W(e),Ct(null),X(`Loaded "${t.name}" workflow.`),requestAnimationFrame(()=>Q(e));return}let n=z.find(t=>t.id===e);if(n){let e={...b(n.hiddenCoreNodes,n.customNodes),...n.positions??{}};R(n.id),T(n.profile),I(n.hiddenCoreNodes),P(n.customNodes),ke(n.enabledNodes??{}),G.current=e,W(e),Ct(null),X(`Switched to "${n.name}".`),requestAnimationFrame(()=>Q(e))}}async function nn(){let e=Te.trim();if(!e)return;let t=`wf-${Date.now().toString(36).slice(-5)}`,n={id:t,name:e.slice(0,48),profile:w,customNodes:N,hiddenCoreNodes:F,enabledNodes:Oe,positions:G.current,updatedAt:new Date().toISOString()},r=[...z,n].slice(-12);B(r),R(t),Ee(``),we(!1),await hn(!1,{activeWorkflowId:t,savedWorkflows:r}),X(`Created and saved workflow "${n.name}".`)}async function rn(){let e=z.find(e=>e.id===L)?.name??u.find(e=>e.id===L)?.name??`Workflow`,t=`wf-${Date.now().toString(36).slice(-5)}`,n={id:t,name:`${e} (Copy)`.slice(0,48),profile:w,customNodes:N.map(e=>({...e,config:{...e.config}})),hiddenCoreNodes:[...F],enabledNodes:{...Oe},positions:{...G.current},updatedAt:new Date().toISOString()},r=[...z,n].slice(-12);B(r),R(t),await hn(!1,{activeWorkflowId:t,savedWorkflows:r}),X(`Duplicated workflow as "${n.name}".`)}async function an(){let e=z.find(e=>e.id===L);if(!e)return;let t=z.filter(t=>t.id!==e.id),n=u[0],r=b(n.hiddenCoreNodes,n.customNodes);B(t),R(n.id),T(n.profile),I(n.hiddenCoreNodes),P(n.customNodes),ke({}),G.current=r,W(r),Ct(null),await hn(!1,{activeWorkflowId:n.id,savedWorkflows:t}),X(`Deleted workflow "${e.name}".`),requestAnimationFrame(()=>Q(r))}function on(e,t){e.button!==0||Bt.current||e.target.closest(`button, input, label`)||(e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),K(t.id),Ue(t.id),Rt.current={nodeId:t.id,startX:e.clientX,startY:e.clientY,origX:t.position.x,origY:t.position.y,zoomAtStart:Ie})}function sn(e){let t=Rt.current;if(!t)return;let n=(e.clientX-t.startX)/t.zoomAtStart,r=(e.clientY-t.startY)/t.zoomAtStart,i=y(Math.round(t.origX+n),12,s-216-12),a=y(Math.round(t.origY+r),12,454);W(e=>({...e,[t.nodeId]:{x:i,y:a}}))}function cn(e){Rt.current&&(e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),Rt.current=null,Ue(null))}function ln(e){let t=e.button===1,n=e.button===0&&Bt.current;(e.button===0||t)&&(t||n||!e.target.closest(`.wb-wf-node-card, .wb-wf-dock, .wb-wf-minimap, .wb-wf-add-drawer`))&&(t&&e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),Ve(!0),zt.current={startX:e.clientX,startY:e.clientY,origX:Re.x,origY:Re.y})}function un(e){let t=zt.current;t&&ze({x:y(Math.round(t.origX+(e.clientX-t.startX)),-s+180,740),y:y(Math.round(t.origY+(e.clientY-t.startY)),-440,440)})}function dn(e){zt.current&&(e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),zt.current=null,Ve(!1))}function fn(e){if(e.ctrlKey||e.metaKey){e.preventDefault();let t=e.deltaY>0?-.08:.08,n=y(Number((Ie+t).toFixed(2)),.34,1.5);if(n===Ie)return;let r=It.current;if(r){let t=r.getBoundingClientRect(),i=e.clientX-t.left,a=e.clientY-t.top,o=(i-Re.x)/Ie,c=(a-Re.y)/Ie;ze({x:y(Math.round(i-o*n),-s+180,740),y:y(Math.round(a-c*n),-440,440)})}Le(n)}else if(e.shiftKey||Math.abs(e.deltaX)>2){e.preventDefault();let t=e.shiftKey&&Math.abs(e.deltaX)<2?e.deltaY:e.deltaX,n=e.shiftKey&&Math.abs(e.deltaX)<2?0:e.deltaY;ze(e=>({x:y(Math.round(e.x-t),-s+180,740),y:y(Math.round(e.y-n),-440,440)}))}}function pn(e){K(e.id),Me(!0);let t=It.current;if(!t)return;let n=t.getBoundingClientRect();ze({x:Math.round(n.width/2-(e.position.x+108)*Ie),y:Math.round(n.height/2-(e.position.y+57)*Ie)})}function mn(){let e=b(F,N);G.current=e,W(e),requestAnimationFrame(()=>Q(e))}async function hn(t,n){vt(!0),Z(``),X(``);try{let r=n?.rules??v,a=n?.activeWorkflowId??L,o=(n?.savedWorkflows??z).map(e=>e.id===a?{...e,profile:w,customNodes:N,hiddenCoreNodes:F,enabledNodes:Oe,positions:G.current,updatedAt:new Date().toISOString()}:e),s=await i(`/api/workflow-graph`,{project:e||g?.project||``,writeToProject:t,rules:r,canvasState:{profile:w,minScoreThreshold:E,maxOutputTokens:D,maxCostUsd:k,strictDesignSystem:A,visualDiffThreshold:j,positions:G.current,enabledNodes:Oe,customNodes:N,hiddenCoreNodes:F,activeWorkflowId:a,savedWorkflows:o}});ee(s),C(s.rules),B(s.canvasState.savedWorkflows??o),h?.(s.rules),X(s.wroteProjectFile?`Saved rules to .ui-workflow.json.`:`Saved workflow rules.`)}catch(e){Z(e.message)}finally{vt(!1)}}async function gn(t,n){bt(!0),n&&nt(n.id),Z(``),X(``);let r=$.filter(e=>e.enabled).map(e=>e.id);try{for(let e of r.slice(0,3))St(e),await new Promise(e=>window.setTimeout(e,50));St(t||`node-security-gate`);let a=await i(`/api/workflow-graph/execute`,{project:e||g?.project||``,recipeId:n?.id,profile:n?.profile??w,minScoreThreshold:n?.minScoreThreshold??E,strictDesignSystem:typeof n?.strictDesignSystem==`boolean`?n.strictDesignSystem:A,visualDiffThreshold:j,enableExternalScanners:!0,enabledNodes:Oe,hiddenCoreNodes:F,customNodes:N,routes:v.routes});Ct(a),a.runHistory&&ft(a.runHistory),a.runTrend!==void 0&&mt(a.runTrend??null),St(null),a.visualDiff?.viewports?.length&&fe(a.visualDiff.viewports[0].name);let o=$.some(e=>e.id===`node-security-gate`)?`node-security-gate`:$[0]?.id??`node-intake`;K(t||o),Me(!0),Pe(`output`),X(`${a.recipeName||`Workflow`} finished in ${a.totalDurationMs}ms · Score ${a.securityReport.score}/100 · ${a.securityReport.findings.length} ${a.securityReport.findings.length===1?`issue`:`issues`}.`)}catch(e){St(null),Z(e.message)}finally{bt(!1),nt(null)}}async function _n(t,n=!1){ct(!0),Z(``),X(``);try{let r=await i(`/api/workflow-graph/export-yaml`,{project:e||g?.project||``,recipeId:t,minScoreThreshold:E,routes:v.routes,writeToProject:n,approved:n});ot(r),r.wrotePath&&X(`Saved GitHub Action to ${r.relativePath}.`)}catch(e){Z(e.message)}finally{ct(!1)}}function vn(e){C(t=>{let n=t.pinnedSkills??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e].slice(0,12);return{...t,pinnedSkills:r}})}function yn(e){C(t=>{let n=t.mustPreserve??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e].slice(0,16);return{...t,mustPreserve:r}})}async function bn(t){_e(!0),Z(``),X(``);try{if(t===`push`){let t=await i(`/api/cloud-sync/push`,{project:e||g?.project||``,rules:v,canvasState:{profile:w,minScoreThreshold:E,maxOutputTokens:D,maxCostUsd:k,strictDesignSystem:A,visualDiffThreshold:j,positions:G.current,enabledNodes:Oe,customNodes:N,hiddenCoreNodes:F,activeWorkflowId:L,savedWorkflows:z}});X(`Synced workflow and ${t.syncedRunsCount} run ${t.syncedRunsCount===1?`summary`:`summaries`} to cloud.`)}else{let t=await i(`/api/cloud-sync/pull`,{project:e||g?.project||``});await Ht(),X(t.hasCloudPreset?`Pulled latest workflow settings from cloud.`:`Connected to cloud sync (no saved workflow yet).`)}let n=await i(`/api/cloud-sync/status`);ge(n)}catch(e){Z(e.message)}finally{_e(!1)}}async function xn(){let e=Y?.securityReport;if(!e)return;let t=[`# Audit Checklist — Score ${e.score}/100 (${e.filesAudited} files)`,``,...e.findings.length?e.findings.map(e=>`- [ ] [${e.severity.toUpperCase()}] ${e.path?`\`${e.path}${e.line?`:${e.line}`:``}\` — `:``}${e.message}${e.action?` (${e.action})`:``}`):[`- [x] No issues found.`]];await navigator.clipboard?.writeText(t.join(`
3
- `)).catch(()=>{}),Ye(!0),window.setTimeout(()=>Ye(!1),1800)}async function Sn(){let e=Y?.securityReport;if(e){Ze(!0),Z(``),X(``);try{let t=await i(`/api/connectors/slack/send`,{title:`${Y.recipeName||`UI Check`} — ${En}`,project:En,score:e.score,findingsCount:e.findings.length,summary:Y.gatePassed?`All enabled checks passed.`:`Action required before shipping.`,findings:e.findings.slice(0,5)});X(`Sent audit summary to Slack (${t.channelLabel}).`)}catch(e){Z(e.message)}finally{Ze(!1)}}}async function Cn(){let t=Y?.securityReport;if(t){$e(!0),Z(``),X(``);try{let n=[`## UI Design Studio Audit — ${En}`,`- **Score:** ${t.score}/100 (${Y.gatePassed?`Passed`:`Needs fixes`})`,`- **Files checked:** ${t.filesAudited}`,``,`### Findings`,...t.findings.length>0?t.findings.slice(0,12).map(e=>{let t=e.path?`\`${e.path}${e.line?`:${e.line}`:``}\` — `:``;return`- [ ] **[${e.severity.toUpperCase()}]** ${t}${e.message}${e.action?` (${e.action})`:``}`}):[`- [x] No issues found.`]].join(`
4
- `),r=await i(`/api/connectors/github-issues/status${e||g?.project?`?project=${encodeURIComponent(e||g?.project||``)}`:``}`),a=await i(`/api/connectors/github-issues/create`,{project:e||g?.project||``,title:`UI Audit (${t.score}/100) — ${t.findings.length} issue${t.findings.length===1?``:`s`} in ${En}`,bodyText:n,submitDirectly:!!r.directCreateAvailable});a.created&&a.issueUrl?(X(`Created GitHub issue #${a.issueNumber} in ${a.repo}.`),window.open(a.issueUrl,`_blank`,`noopener,noreferrer`)):a.openInBrowserUrl&&(window.open(a.openInBrowserUrl,`_blank`,`noopener,noreferrer`),X(a.hint||`Opened pre-filled GitHub issue for ${a.repo}.`))}catch(e){Z(e.message)}finally{$e(!1)}}}let wn=e=>{let t=e.moduleId?g?.integrations?.modules.find(t=>t.id===e.moduleId):void 0,n=e.connectorId?g?.integrations?.connectors.find(t=>t.id===e.connectorId):void 0;return n?.status===`connected`||n?.status===`configured`?`Connected`:t?.installed?`Installed`:!e.moduleId&&!e.connectorId?`Built-in`:`Available`},Tn=Y?.securityReport,En=g?.isDemoFallback?`Sample project`:g?.project?.split(/[\\/]/).pop()??`Project`,Dn=g?.recipes?.length?g.recipes:te;return(0,x.jsxs)(`section`,{className:`wb-workflow-visualizer ${q?`is-fullscreen`:``}`,"aria-label":`Workflow Studio`,children:[(0,x.jsxs)(`header`,{className:`wb-wf-header`,children:[(0,x.jsx)(`div`,{className:`wb-wf-title-block`,children:(0,x.jsxs)(`div`,{className:`wb-wf-title-row`,children:[(0,x.jsx)(`h2`,{className:`page-reveal page-reveal--title`,children:`Workflow Studio`}),(0,x.jsxs)(`div`,{className:`wb-wf-mode-switch`,role:`group`,"aria-label":`Workflow Studio view`,children:[(0,x.jsx)(`button`,{type:`button`,"aria-pressed":J===`recipes`,onClick:()=>et(`recipes`),children:`Automations`}),(0,x.jsx)(`button`,{type:`button`,"aria-pressed":J===`graph`,onClick:()=>{et(`graph`),requestAnimationFrame(()=>Q())},children:`Visual Editor`})]}),(0,x.jsxs)(`span`,{className:`wb-wf-target-pill`,title:g?.project??``,children:[(0,x.jsx)(n,{name:`folder`}),En]}),r&&(0,x.jsx)(`button`,{type:`button`,className:`button subtle wb-pill-btn`,disabled:t||yt,onClick:()=>void r(),children:t?`Opening…`:`Browse`}),l&&(0,x.jsx)(`button`,{type:`button`,className:`text-button wb-pill-text-btn`,disabled:t||yt,onClick:l,children:`Repositories`})]})}),(0,x.jsxs)(`div`,{className:`wb-wf-actions page-reveal page-reveal--controls`,children:[J===`graph`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`button`,{type:`button`,className:`button subtle`,"aria-pressed":V,onClick:()=>{Kt(null),H(e=>!e)},children:[(0,x.jsx)(n,{name:`plus`}),`Add Step`]}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-pressed":je,onClick:()=>Me(e=>!e),children:je?`Hide Panel`:`Edit Step`})]}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:_t||ht,onClick:()=>void hn(!g?.isDemoFallback),children:_t?`Saving…`:g?.isDemoFallback?`Save Preset`:`Save Rules`}),he?.active&&(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:M||ht,onClick:()=>void bn(`push`),children:M?`Syncing…`:`Cloud Sync`}),q&&Tn&&(0,x.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>Lt.current?.scrollIntoView({behavior:`smooth`,block:`start`}),children:[`↓ Results (`,Tn.findings.length,`)`]}),(0,x.jsx)(`button`,{type:`button`,className:`button primary`,disabled:yt||ht,onClick:()=>void gn(),children:yt?`Running…`:`Run Audit`}),(0,x.jsxs)(`button`,{type:`button`,className:`button subtle wb-wf-fullscreen-action`,"aria-pressed":q,onClick:()=>Fe(e=>!e),title:q?`Exit Fullscreen (Esc)`:`Fullscreen`,children:[(0,x.jsx)(n,{name:q?`close`:`external`}),q?`Exit Fullscreen`:`Fullscreen`]})]})]}),Tt&&(0,x.jsx)(`p`,{className:`error-box`,role:`alert`,children:Tt}),wt&&(0,x.jsx)(`p`,{className:`connection-success`,role:`status`,children:wt}),J===`recipes`&&(0,x.jsxs)(`div`,{className:`wb-wf-recipes-layout page-reveal page-reveal--content`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-recipes-intro`,children:[(0,x.jsx)(`p`,{children:`Ready-to-run checks for pull requests, branches, and live pages. Runs locally with no API key needed.`}),(0,x.jsx)(`div`,{className:`wb-wf-connector-strip`,"aria-label":`Workflow options`,children:(0,x.jsx)(`button`,{type:`button`,className:`text-button`,"aria-pressed":We,onClick:()=>Ge(e=>!e),children:We?`Hide project rules`:`Edit project rules`})})]}),(0,x.jsx)(`div`,{className:`wb-wf-recipes-grid`,role:`list`,"aria-label":`Workflow automations`,children:Dn.map(e=>{let t=tt===e.id,r=ne[e.id]??{icon:`graph`,tag:`Check`};return(0,x.jsxs)(`article`,{role:`listitem`,className:`wb-wf-recipe-card ${t?`is-running`:``}`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-recipe-top`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-recipe-head`,children:[(0,x.jsx)(`span`,{className:`wb-wf-recipe-icon`,"aria-hidden":`true`,children:(0,x.jsx)(n,{name:r.icon})}),(0,x.jsx)(`span`,{className:`wb-wf-metric-chip`,children:r.tag})]}),(0,x.jsx)(`h3`,{className:`wb-wf-recipe-title`,children:e.name}),(0,x.jsx)(`p`,{className:`wb-wf-recipe-desc`,children:e.shortDesc}),(0,x.jsxs)(`p`,{className:`wb-wf-recipe-meta`,children:[(0,x.jsx)(`span`,{children:e.trigger}),(0,x.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,x.jsx)(`span`,{children:e.outcome})]})]}),(0,x.jsxs)(`div`,{className:`wb-wf-recipe-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`button primary`,disabled:yt||ht,onClick:()=>void gn(void 0,e),children:t?`Running…`:`Run now`}),(0,x.jsxs)(`div`,{className:`wb-wf-recipe-secondary`,children:[(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{navigator.clipboard?.writeText(e.cliCommand).catch(()=>{}),it(e.id),X(`Copied: ${e.cliCommand}`),window.setTimeout(()=>it(t=>t===e.id?null:t),1800)},children:rt===e.id?`Copied`:`Copy CLI`}),(0,x.jsx)(`button`,{type:`button`,className:`text-button`,disabled:st,onClick:()=>void _n(e.id,!1),children:`GitHub YAML`})]})]})]},e.id)})}),Y?.steps&&Y.steps.length>0&&(0,x.jsxs)(`div`,{className:`wb-wf-history-card`,"aria-label":`Last workflow run steps`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-history-head`,children:[(0,x.jsxs)(`h3`,{children:[`Last Run · `,Y.recipeName||`Check`,` (`,Y.totalDurationMs,`ms)`]}),(0,x.jsx)(`span`,{className:`wb-wf-scanner-pill ${Y.gatePassed?`status-ready`:`status-optional`}`,children:Y.gatePassed?`Passed`:`Needs fixes`})]}),(0,x.jsx)(`div`,{className:`wb-wf-step-summary-bar`,children:Y.steps.filter(e=>e.status!==`skipped`).map(e=>(0,x.jsxs)(`span`,{className:`wb-wf-step-pill status-${e.status}`,title:e.summary,children:[e.status===`passed`?`✓`:e.status===`failed`?`×`:`!`,` `,e.title,` (`,e.durationMs,`ms)`]},e.id))})]}),at&&(0,x.jsxs)(`section`,{className:`wb-wf-yaml-drawer`,"aria-label":`Exported GitHub Actions workflow`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-yaml-head`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`strong`,{children:at.relativePath}),at.wrotePath&&(0,x.jsx)(`span`,{className:`wb-wf-focus-note`,children:`Saved to project`})]}),(0,x.jsxs)(`div`,{className:`wb-wf-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{navigator.clipboard?.writeText(at.yaml).catch(()=>{}),ut(!0),window.setTimeout(()=>ut(!1),1800)},children:lt?`Copied YAML`:`Copy YAML`}),!g?.isDemoFallback&&(0,x.jsx)(`button`,{type:`button`,className:`button primary`,disabled:st,onClick:()=>void _n(at.recipeId,!0),children:`Save to project`}),(0,x.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>ot(null),children:`Close`})]})]}),(0,x.jsx)(`pre`,{translate:`no`,children:at.yaml})]}),dt.length>0&&(0,x.jsxs)(`section`,{className:`wb-wf-history-card`,"aria-label":`Recent workflow runs`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-history-head`,children:[(0,x.jsx)(`h3`,{children:`Recent Runs & Score Trend`}),pt&&(0,x.jsxs)(`div`,{className:`wb-wf-trend-stats`,children:[(0,x.jsxs)(`span`,{children:[`Latest: `,(0,x.jsxs)(`strong`,{children:[pt.latestScore,`/100`]}),pt.scoreDelta===0?``:` (${pt.scoreDelta>0?`+`:``}${pt.scoreDelta})`]}),(0,x.jsxs)(`span`,{children:[`Pass rate: `,(0,x.jsxs)(`strong`,{children:[pt.passRate,`%`]})]}),(0,x.jsxs)(`span`,{children:[`Avg time: `,(0,x.jsxs)(`strong`,{children:[pt.avgDurationMs,`ms`]})]}),(0,x.jsxs)(`span`,{children:[`Runs: `,(0,x.jsx)(`strong`,{children:pt.runCount})]})]})]}),(0,x.jsx)(`ul`,{className:`wb-wf-history-list`,children:dt.slice(0,6).map(e=>(0,x.jsxs)(`li`,{children:[(0,x.jsxs)(`div`,{className:`wb-wf-history-main`,children:[(0,x.jsx)(`span`,{className:`wb-wf-scanner-pill ${e.gatePassed?`status-ready`:`status-optional`}`,children:e.gatePassed?`Passed`:`Review`}),(0,x.jsx)(`strong`,{children:e.recipeName}),(0,x.jsxs)(`span`,{children:[`Score `,e.score,`/100`,e.scoreDelta===0?``:` (${e.scoreDelta>0?`+`:``}${e.scoreDelta})`]})]}),(0,x.jsxs)(`div`,{className:`wb-wf-history-meta`,children:[(0,x.jsxs)(`span`,{children:[e.findingsCount,` issue`,e.findingsCount===1?``:`s`]}),(0,x.jsxs)(`span`,{children:[e.durationMs,`ms`]}),(0,x.jsx)(`span`,{children:new Date(e.executedAt).toLocaleTimeString()})]})]},e.id))})]})]}),J===`graph`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`wb-wf-toolbar page-reveal page-reveal--controls`,children:[(0,x.jsxs)(`div`,{className:`wb-wf-preset-picker`,children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`wf-preset-select`,children:`Active workflow`}),(0,x.jsxs)(`select`,{id:`wf-preset-select`,className:`wb-wf-preset-select`,value:L,onChange:e=>tn(e.target.value),children:[(0,x.jsx)(`optgroup`,{label:`Starter Workflows`,children:u.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))}),z.length>0&&(0,x.jsx)(`optgroup`,{label:`Your Saved Workflows`,children:z.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,x.jsx)(`button`,{type:`button`,className:`button subtle wb-pill-btn`,onClick:()=>we(e=>!e),children:`+ New`}),(0,x.jsx)(`button`,{type:`button`,className:`text-button wb-pill-text-btn`,disabled:_t||ht,onClick:()=>void rn(),title:`Save a copy of the current workflow`,children:`Duplicate`}),z.some(e=>e.id===L)&&(0,x.jsx)(`button`,{type:`button`,className:`text-button wb-pill-text-btn wb-wf-delete-btn`,disabled:_t||ht,onClick:()=>void an(),title:`Delete this saved workflow`,children:`Delete`})]}),(0,x.jsx)(`div`,{className:`wb-wf-focus-segmented`,role:`group`,"aria-label":`Workflow focus`,children:[{id:`ui`,label:`UI Redesign`},{id:`audit`,label:`Quick Audit`},{id:`seo`,label:`SEO & AI`},{id:`architecture`,label:`Project Map`}].map(e=>{let t=e.id===`seo`?w===`seo`||w===`ai-search`:w===e.id;return(0,x.jsx)(`button`,{type:`button`,className:`wb-focus-pill`,"aria-pressed":t,onClick:()=>T(e.id),children:e.label},e.id)})}),(0,x.jsxs)(`div`,{className:`wb-wf-quiet-tools`,children:[(0,x.jsx)(`button`,{type:`button`,className:`text-button`,"aria-pressed":We,onClick:()=>Ge(e=>!e),children:We?`Hide JSON`:`Rules JSON`}),he?.active&&(0,x.jsx)(`button`,{type:`button`,className:`text-button`,disabled:M||ht,onClick:()=>void bn(`pull`),children:`Pull cloud`})]})]}),Ce&&(0,x.jsxs)(`div`,{className:`wb-wf-new-bar`,role:`region`,"aria-label":`Create new workflow`,children:[(0,x.jsx)(`input`,{type:`text`,value:Te,placeholder:`Name your new workflow (e.g. Figma + Playwright QA)…`,onChange:e=>Ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&nn()}}),(0,x.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!Te.trim()||_t,onClick:()=>void nn(),children:`Create Workflow`}),(0,x.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>we(!1),children:`Cancel`})]}),(0,x.jsxs)(`div`,{className:`wb-wf-split ${je&&Wt?`has-inspector`:``} page-reveal page-reveal--content`,children:[(0,x.jsx)(re,{viewportRef:It,isPanning:Be,pan:Re,zoom:Ie,setZoom:Le,addPanelOpen:V,setAddPanelOpen:H,addStageHint:Gt,setAddStageHint:Kt,onOpenAddForStage:qt,hiddenCoreNodes:F,newStepTitle:U,setNewStepTitle:ve,newStepStage:ye,setNewStepStage:be,newStepNotes:xe,setNewStepNotes:Se,integrationStatusFor:wn,addModuleNode:Jt,restoreCoreNode:Xt,addCustomStepNode:Yt,edges:Ut,liveNodes:$,selectedNode:Wt,selectedNodeId:Ae,setSelectedNodeId:K,setInspectorOpen:Me,draggingNodeId:He,activeExecNode:xt,executing:yt,executionResult:Y,profile:w,onViewportPointerDown:ln,onViewportPointerMove:un,onViewportPointerUp:dn,onViewportWheel:fn,onNodePointerDown:on,onNodePointerMove:sn,onNodePointerUp:cn,executeWorkflowPipeline:gn,updateCustomNode:Qt,toggleCoreNodeEnabled:e=>ke(t=>({...t,[e]:t[e]===!1})),removeNode:Zt,fitCanvasToView:()=>Q(),tidyLayout:mn,centerOnNode:pn}),je&&Wt&&(0,x.jsx)(`div`,{className:`wb-wf-inspector-side`,children:(0,x.jsx)(S,{selectedNode:Wt,inspectorTab:Ne,setInspectorTab:Pe,executing:yt,executionResult:Y,graph:g,rules:v,setRules:C,profile:w,setProfile:T,minScoreThreshold:E,setMinScoreThreshold:ae,maxOutputTokens:D,setMaxOutputTokens:O,maxCostUsd:k,setMaxCostUsd:oe,strictDesignSystem:A,setStrictDesignSystem:se,visualDiffThreshold:j,setVisualDiffThreshold:ce,showDiffBoxes:le,setShowDiffBoxes:ue,activeDiffViewport:de,setActiveDiffViewport:fe,diffImageLayer:pe,setDiffImageLayer:me,newRouteInput:Et,setNewRouteInput:Dt,newDirInput:Ot,setNewDirInput:kt,newPreserveInput:At,setNewPreserveInput:jt,newInteractionInput:Mt,setNewInteractionInput:Nt,newIgnoreCheckInput:Pt,setNewIgnoreCheckInput:Ft,setError:Z,removeNode:Zt,updateCustomNode:Qt,updateCustomNodeConfig:$t,moveCustomNodeStage:en,toggleSkill:vn,toggleKeepItem:yn,executeWorkflowPipeline:gn,onOpenComposer:f})})]})]}),(0,x.jsx)(ie,{resultsRef:Lt,executionResult:Y,severityFilter:Ke,setSeverityFilter:qe,copiedChecklist:Je,copyFindingsChecklist:xn,onFixFindings:p,onSendToSlack:Sn,onCreateGitHubIssue:Cn,slackSending:Xe,ghIssueSending:Qe,showRawJson:We,rules:v,isDemoFallback:!!g?.isDemoFallback,savingRules:_t,onSaveRawRules:e=>hn(!g?.isDemoFallback,{rules:e})})]})}export{w as default};