@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.
- package/layout-capture.mjs +14 -0
- package/package.json +3 -3
- package/studio-dist/assets/{AccountModal-BCsGPvx4.js → AccountModal-C415mM4f.js} +1 -1
- package/studio-dist/assets/{Connections-C9b3n4ss.js → Connections-BD_LstwM.js} +1 -1
- package/studio-dist/assets/Diagnostics-CuRX-uAp.js +10 -0
- package/studio-dist/assets/{Repositories-BPQd02x8.js → Repositories-DH7YyDwk.js} +1 -1
- package/studio-dist/assets/{ReviewStage-bicZ-iOy.js → ReviewStage-DJ1oRAkT.js} +1 -1
- package/studio-dist/assets/{Settings-CITjwtGY.js → Settings-8mMKFnYf.js} +1 -1
- package/studio-dist/assets/WorkflowVisualizer-CdwGjUIL.js +4 -0
- package/studio-dist/assets/{account-modal--3DWt5me.js → account-modal-Cm9Rsqyi.js} +1 -1
- package/studio-dist/assets/{index-KY1IHp8L.js → index-Dp8CdAV4.js} +27 -27
- package/studio-dist/assets/index-jTfIlhhN.css +1 -0
- package/studio-dist/index.html +2 -2
- package/studio-routes-projects.mjs +22 -5
- package/studio-server.mjs +31 -1
- package/studio-settings.mjs +83 -0
- package/ui-workflow-cli.mjs +37 -28
- package/windows-native.mjs +88 -9
- package/workflow-runner.mjs +33 -2
- package/studio-dist/assets/Diagnostics-D9o9AHSf.js +0 -10
- package/studio-dist/assets/WorkflowVisualizer-6llBlI2i.js +0 -4
- package/studio-dist/assets/index-Cv4BVYXJ.css +0 -1
package/layout-capture.mjs
CHANGED
|
@@ -195,6 +195,20 @@ export async function detectBrowserRuntime({
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
export function formatBrowserDoctorRemediation(pw) {
|
|
199
|
+
if (!pw || pw.available) return null;
|
|
200
|
+
const hasSystemBrowser = Boolean(pw.engine && pw.executable && !pw.packageAvailable);
|
|
201
|
+
return {
|
|
202
|
+
id: 'browser-runtime',
|
|
203
|
+
issue: hasSystemBrowser
|
|
204
|
+
? `System browser detected (${pw.engine}); install playwright to enable --render and visual diffs`
|
|
205
|
+
: 'No local browser engine found (required only for --render / --url browser checks).',
|
|
206
|
+
command:
|
|
207
|
+
pw.remediation ||
|
|
208
|
+
'Install Google Chrome or Microsoft Edge, set CHROME_PATH, or run: npx playwright install chromium',
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
198
212
|
export async function launchHeadlessBrowser({
|
|
199
213
|
headless = true,
|
|
200
214
|
env = process.env,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui-workflow/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Local-first UI visual diff, accessibility, WCAG contrast, layout, and frontend security CLI, MCP server, and Studio workbench.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"type": "module",
|
|
31
31
|
"bin": {
|
|
32
|
-
"ui-workflow-mcp": "
|
|
33
|
-
"ui-workflow": "
|
|
32
|
+
"ui-workflow-mcp": "mcp-server.mjs",
|
|
33
|
+
"ui-workflow": "ui-workflow-cli.mjs"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"prepack": "node ../../scripts/bundle-studio-dist.mjs prepare",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./react-vendor-CH5vucNG.js";import{f as n,l as r,p as i,u as a}from"./index-KY1IHp8L.js";import{a as o,n as s,t as ee}from"./account-modal--3DWt5me.js";var c=e(),l=t(),u=null;function d(){return typeof window>`u`?Promise.resolve(null):window.google?.accounts?.id?Promise.resolve(window.google.accounts.id):u||(u=new Promise(e=>{let t=document.querySelector(`script[src="https://accounts.google.com/gsi/client"]`);if(t){t.addEventListener(`load`,()=>e(window.google?.accounts?.id??null),{once:!0}),t.addEventListener(`error`,()=>e(null),{once:!0});return}let n=document.createElement(`script`);n.src=`https://accounts.google.com/gsi/client`,n.async=!0,n.defer=!0,n.onload=()=>e(window.google?.accounts?.id??null),n.onerror=()=>{u=null,e(null)},document.head.appendChild(n)}),u)}function f({open:e,auth:t,onClose:a,onUpdated:u}){let d=(0,c.useRef)(null),f=(0,c.useRef)(null),p=(0,c.useRef)(null),te=(0,c.useRef)(!1),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(!1),[v,y]=(0,c.useState)(`https://gitlab.com`),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(``),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1),[A,j]=(0,c.useState)(``),[M,N]=(0,c.useState)(``),[P,F]=(0,c.useState)(``),[I,L]=(0,c.useState)(null),[R,ne]=(0,c.useState)(``),[z,B]=(0,c.useState)(null),[re,V]=(0,c.useState)(null);te.current=g,(0,c.useEffect)(()=>{let n=d.current;n&&(e?(j(``),N(``),F(``),L(null),B(null),D(!1),C(!1),x(``),p.current&&(p.current.value=``),t?.providers.gitlab.baseUrl&&y(t.providers.gitlab.baseUrl),t?.secureStorage.available||_(!1),n.open||n.showModal()):n.open&&n.close())},[e,t?.providers.gitlab.baseUrl,t?.secureStorage.available]);let H=!!t?.account,U=t?.providers.google.clientId??``;if((0,c.useEffect)(()=>{if(!e||!H)return;let t=!0;return i(`/api/cloud-sync/status`).then(e=>{t&&V(e)}).catch(()=>{}),()=>{t=!1}},[e,H]),(0,c.useEffect)(()=>{if(!e||!I||H)return;let t=!0,n=Math.max(5e3,(I.intervalSeconds||5)*1e3),r=window.setInterval(()=>{t&&i(`/api/auth/github/device/poll`,{flowId:I.flowId}).then(async e=>{t&&e.status===`authenticated`&&(L(null),await u(),N(`Signed in via GitHub Device Flow.`))}).catch(()=>{})},n);return()=>{t=!1,window.clearInterval(r)}},[e,I,H,u]),(0,c.useEffect)(()=>{if(!e||!P||H)return;let t=!0,n=()=>{t&&!document.hidden&&u().catch(()=>{})},r=window.setInterval(n,1800);return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,n),()=>{t=!1,window.clearInterval(r),window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,n)}},[e,P,H,u]),!e)return null;async function W(e){k(!0),j(``),N(``);try{await e()}catch(e){j(e.message)}finally{k(!1)}}async function ie(){h(`google`),U&&await G(`google`)}async function G(e){h(e),F(``),await W(async()=>{let t=await i(`/api/auth/oauth/start`,{provider:e,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{},openBrowser:!0});F(t.authorizeUrl),N(t.browserOpened?`Opened ${o(e)} in your browser. Complete sign-in there—Studio updates automatically.`:`Open the authorization link below to finish ${o(e)} sign-in.`)})}async function K(e){await W(async()=>{await i(`/api/auth/connect-cli`,{provider:e,approved:!0,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{}}),await u(),N(`Signed in via ${e===`google`?`gcloud CLI`:e===`github`?`1-click GitHub OAuth / CLI`:`1-click GitLab OAuth / CLI`}.`)})}async function q(e){let t=b.trim(),n=p.current?.value??``;p.current&&(p.current.value=``),t?await W(async()=>{if(await i(`/api/auth/oauth/config`,{provider:e,clientId:t,clientSecret:n,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{}}),await u(),x(``),C(!1),e===`google`&&!n){N(`Saved Google Client ID! Reloading Studio to activate 1-click Google One Tap…`),window.setTimeout(()=>window.location.reload(),650);return}let r=await i(`/api/auth/oauth/start`,{provider:e,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{},openBrowser:!0});F(r.authorizeUrl),N(r.browserOpened?`Opened ${o(e)} SSO in your browser. Complete sign-in there—Studio updates automatically.`:`Open the authorization link below to finish ${o(e)} sign-in.`)}):j(`Paste your ${o(e)} OAuth Client ID first.`)}async function J(e,t){t&&(await navigator.clipboard?.writeText(t),T(e),window.setTimeout(()=>T(``),1800))}async function ae(e){let t=f.current?.value??``;f.current&&(f.current.value=``),t.trim()?await W(async()=>{await i(`/api/auth/connect-pat`,{provider:e,token:t,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{}}),await u(),D(!1),N(`Connected to ${o(e)} using a scoped access token.`)}):j(`Paste a scoped Personal Access Token first.`)}async function oe(){await W(async()=>{window.google?.accounts?.id?.cancel(),await i(`/api/auth/signout`,{}),await u(),h(null),F(``),L(null),N(`Signed out and cleared stored account session tokens.`)})}async function se(){await W(async()=>{let e=await i(`/api/auth/verify`,{});e.valid?N(`${e.detail}${e.scopes?.length?` · Scopes: ${e.scopes.join(`, `)}`:``}`):j(e.detail)})}async function Y(){let e=b.trim();await W(async()=>{let t=await i(`/api/auth/github/device/start`,{...e?{clientId:e}:{},remember:g,openBrowser:!0});e&&(x(``),await u()),L(t),N(`Enter code ${t.userCode} at ${t.verificationUri} — Studio will sign you in automatically once authorized.`)})}async function X(){R.trim()&&await W(async()=>{let e=await i(`/api/auth/oidc/discover`,{issuerUrl:R.trim()});B(e),N(`Verified OIDC discovery for ${e.issuer} (PKCE S256 ready).`)})}async function ce(e){await W(async()=>{let t=await i(`/api/cloud-sync/config`,{optIn:e});V(t),N(e?`Opt-in Cloud Firestore sync enabled (${t.firebaseProjectId}).`:`Cloud Firestore sync paused; Studio remains strictly local.`)})}async function le(){await W(async()=>{let e=await i(`/api/cloud-sync/push`,{}),t=await i(`/api/cloud-sync/status`);V(t),N(`Synced workflow preset, layout & ${e.syncedRunsCount} redacted run summary(ies) to Firestore (${e.workspaceId}).`)})}async function ue(){await W(async()=>{let e=await i(`/api/cloud-sync/pull`,{});await u();let t=await i(`/api/cloud-sync/status`);V(t),N(`Pulled cloud state (${e.hasCloudPreset?`preset restored`:`no saved preset`}, ${e.runs.length} redacted run(s)) and refreshed subscription entitlements.`)})}let Z=t?.account??null,Q=m?t?.providers[m]:null,$=t?.providers.google.jsOrigin||window.location.origin;return(0,l.jsxs)(`dialog`,{ref:d,className:`wb-account-dialog`,"aria-labelledby":`account-dialog-title`,closedBy:`any`,onCancel:e=>{e.preventDefault(),a()},onClick:e=>{if(e.target===e.currentTarget&&!(`closedBy`in HTMLDialogElement.prototype)){let t=e.currentTarget.getBoundingClientRect();t.top<=e.clientY&&e.clientY<=t.top+t.height&&t.left<=e.clientX&&e.clientX<=t.left+t.width||a()}},children:[(0,l.jsx)(`div`,{className:`wb-account-dialog-top`,children:(0,l.jsx)(`button`,{type:`button`,className:`icon-button wb-account-close`,"aria-label":`Close account dialog`,onClick:a,children:(0,l.jsx)(n,{name:`close`})})}),(0,l.jsxs)(`div`,{className:`wb-account-hero`,children:[(0,l.jsx)(`span`,{className:`wb-account-brand-mark`,"aria-hidden":`true`,children:(0,l.jsx)(r,{})}),(0,l.jsx)(`h2`,{id:`account-dialog-title`,children:Z?`Studio account`:`Sign in to Studio`}),(0,l.jsx)(`p`,{children:Z?`Manage your connected account and repository access.`:`Sign in with Google or connect GitHub and GitLab to open your repositories.`})]}),A&&(0,l.jsx)(`p`,{className:`error-box`,role:`alert`,children:A}),M&&(0,l.jsx)(`p`,{className:`connection-success`,role:`status`,children:M}),Z?(0,l.jsx)(ee,{account:Z,auth:t,cloudSync:re,busy:O,onClose:a,onVerifyConnection:se,onSignOut:oe,onToggleCloudSync:ce,onPushCloudSync:le,onPullCloudSync:ue}):(0,l.jsxs)(`div`,{className:`wb-account-providers`,children:[(0,l.jsxs)(`div`,{className:`wb-account-provider-list`,role:`group`,"aria-label":`Sign in providers`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`wb-provider-button wb-provider-google`+(m===`google`?` is-selected`:``),disabled:O,onClick:()=>{j(``),N(``),F(``),ie()},children:[(0,l.jsx)(`span`,{className:`wb-provider-badge`,"aria-hidden":`true`,children:(0,l.jsx)(s,{provider:`google`})}),(0,l.jsxs)(`span`,{className:`wb-provider-copy`,children:[(0,l.jsx)(`strong`,{children:`Continue with Google`}),(0,l.jsx)(`small`,{children:U?`Sign in with your Google account`:t?.providers.google.cliAvailable?`Browser sign-in or local Google session`:`Sign in with your Google account`})]}),(0,l.jsx)(`svg`,{className:`wb-provider-arrow`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:(0,l.jsx)(`path`,{d:`M7.5 5 12.5 10 7.5 15`})})]}),(0,l.jsx)(`div`,{className:`wb-account-divider`,role:`separator`,children:(0,l.jsx)(`span`,{children:`or connect Git`})}),[`github`,`gitlab`].map(e=>{let n=t?.providers[e];return(0,l.jsxs)(`button`,{type:`button`,className:`wb-provider-button`+(m===e?` is-selected`:``),disabled:O,onClick:()=>{j(``),N(``),F(``),h(e),n?.oauthConfigured?G(e):n?.cliAvailable&&K(e)},children:[(0,l.jsx)(`span`,{className:`wb-provider-badge`,"aria-hidden":`true`,children:(0,l.jsx)(s,{provider:e})}),(0,l.jsxs)(`span`,{className:`wb-provider-copy`,children:[(0,l.jsxs)(`strong`,{children:[`Continue with `,o(e)]}),(0,l.jsx)(`small`,{children:n?.oauthConfigured?`Sign in with your ${o(e)} account`:n?.cliAvailable?`Use your local ${o(e)} sign-in`:`Connect ${o(e)} via browser or token`})]}),(0,l.jsx)(`svg`,{className:`wb-provider-arrow`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:(0,l.jsx)(`path`,{d:`M7.5 5 12.5 10 7.5 15`})})]},e)})]}),(0,l.jsxs)(`label`,{className:`wb-account-remember-row`,children:[(0,l.jsxs)(`span`,{className:`wb-account-remember-copy`,children:[(0,l.jsx)(`strong`,{children:`Keep me signed in on this computer`}),(0,l.jsx)(`small`,{children:t?.secureStorage.available?`Saved securely by your operating system, never in browser storage.`:`Secure storage unavailable here — stays signed in for this session only.`})]}),(0,l.jsx)(`input`,{type:`checkbox`,role:`switch`,className:`settings-switch`,checked:g,disabled:!t?.secureStorage.available||O,onChange:e=>_(e.target.checked)})]}),m===`google`&&(0,l.jsxs)(`div`,{className:`wb-account-fallback`,role:`region`,"aria-label":`Google One Tap setup`,children:[(0,l.jsxs)(`div`,{className:`wb-account-fallback-actions`,children:[U&&(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>void G(`google`),children:`Open Google browser sign-in`}),Q?.cliAvailable&&(0,l.jsx)(`button`,{type:`button`,className:U?`button subtle`:`button primary`,disabled:O,onClick:()=>void K(`google`),children:`Connect via local gcloud CLI`}),U&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O,onClick:()=>C(e=>!e),children:S?`Hide Client ID settings`:`Change Client ID`})]}),(!U||S)&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-setup`,children:[t?.firebase?.defaultGoogleClientId&&(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>{x(t.firebase?.defaultGoogleClientId??``),W(async()=>{await i(`/api/auth/oauth/config`,{provider:`google`,clientId:t.firebase?.defaultGoogleClientId??``,clientSecret:``,remember:g}),await u(),C(!1),await G(`google`)})},children:`Use Firebase Google Sign-In (ui-design-studio-ab07b)`}),(0,l.jsxs)(`p`,{children:[`Or paste a custom `,(0,l.jsx)(`strong`,{children:`Google OAuth Web Client ID`}),` (no Client Secret required) to activate Chrome’s native `,(0,l.jsx)(`strong`,{children:`1-click One Tap`}),` account picker on this origin:`]}),(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,children:$}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`origin`,$),children:w===`origin`?`Copied`:`Copy origin`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-id`,children:[`Google OAuth Client ID`,(0,l.jsx)(`input`,{id:`account-oauth-client-id`,type:`text`,spellCheck:!1,value:b,disabled:O,onChange:e=>x(e.target.value),placeholder:`1234567890-abc….apps.googleusercontent.com`})]}),(0,l.jsxs)(`details`,{className:`wb-account-advanced-oauth`,children:[(0,l.jsx)(`summary`,{children:`Optional: full redirect OAuth fallback (Client Secret)`}),Q?.redirectUri&&(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,children:Q.redirectUri}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`redirect`,Q.redirectUri??``),children:w===`redirect`?`Copied`:`Copy URI`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-secret`,children:[`Client Secret (stored in OS vault / memory only)`,(0,l.jsx)(`input`,{ref:p,id:`account-oauth-client-secret`,type:`password`,autoComplete:`new-password`,spellCheck:!1,disabled:O,placeholder:`Optional — only needed for redirect fallback`})]})]}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O||!b.trim(),onClick:()=>void q(`google`),children:O?`Enabling Google One Tap…`:`Save & Sign in with Google`})]})]}),(m===`github`||m===`gitlab`)&&(0,l.jsxs)(`div`,{className:`wb-account-fallback`,role:`region`,"aria-label":`${o(m)} connection options`,children:[m===`gitlab`&&(0,l.jsxs)(`label`,{htmlFor:`account-gitlab-host`,className:`wb-account-host`,children:[`GitLab instance URL`,(0,l.jsx)(`input`,{id:`account-gitlab-host`,type:`url`,value:v,disabled:O,onChange:e=>y(e.target.value),placeholder:`https://gitlab.com`})]}),(0,l.jsxs)(`div`,{className:`wb-account-fallback-actions`,children:[Q?.oauthConfigured&&(0,l.jsxs)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>void G(m),children:[`Open `,o(m),` OAuth`]}),m===`github`&&Q?.oauthConfigured&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O,onClick:()=>void Y(),children:`GitHub Device Code (Zero-Secret)`}),(0,l.jsxs)(`button`,{type:`button`,className:Q?.oauthConfigured?`button subtle`:`button primary`,disabled:O,onClick:()=>void K(m),children:[`Connect via local `,m===`github`?`gh`:`glab`,` CLI`]}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-expanded":E,disabled:O,onClick:()=>{C(!1),D(e=>!e)},children:E?`Hide token form`:`Use Personal Access Token`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-expanded":S,disabled:O,onClick:()=>{D(!1),C(e=>!e)},children:S?`Hide OAuth app`:`Configure OAuth / SSO`})]}),m===`github`&&I&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-setup`,role:`status`,children:[(0,l.jsx)(`p`,{children:`Enter this one-time code on GitHub (Studio is polling automatically):`}),(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,style:{fontSize:`1.1rem`,fontWeight:700},children:I.userCode}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`device`,I.userCode),children:w===`device`?`Copied`:`Copy code`}),(0,l.jsx)(`a`,{className:`button primary`,href:I.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:`Open GitHub Device Activation`})]})]}),S&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-setup`,children:[(0,l.jsxs)(`p`,{children:[`Configure local `,(0,l.jsxs)(`strong`,{children:[o(m),` OAuth 2.0`]}),` `,`with Redirect URI:`]}),Q?.redirectUri&&(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,children:Q.redirectUri}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`redirect`,Q.redirectUri??``),children:w===`redirect`?`Copied`:`Copy URI`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-id`,children:[o(m),` OAuth Client ID`,(0,l.jsx)(`input`,{id:`account-oauth-client-id`,type:`text`,spellCheck:!1,value:b,disabled:O,onChange:e=>x(e.target.value),placeholder:`Paste OAuth Client ID`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-secret`,children:[`Client Secret (optional — stored in system vault or memory only)`,(0,l.jsx)(`input`,{ref:p,id:`account-oauth-client-secret`,type:`password`,autoComplete:`new-password`,spellCheck:!1,disabled:O,placeholder:`Optional OAuth Client Secret`})]}),(0,l.jsxs)(`div`,{className:`wb-account-fallback-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O||!b.trim(),onClick:()=>void q(m),children:O?`Opening OAuth…`:`Save & Sign in with ${o(m)}`}),m===`github`&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O||!b.trim(),onClick:()=>void Y(),children:`Save & Use GitHub Device Flow (No Secret)`})]}),(0,l.jsxs)(`details`,{className:`wb-account-advanced-oauth`,children:[(0,l.jsx)(`summary`,{children:`Test team SSO provider (WorkOS / Logto / Okta / Entra)`}),(0,l.jsxs)(`label`,{htmlFor:`account-oidc-issuer`,children:[`HTTPS OIDC Issuer URL`,(0,l.jsx)(`input`,{id:`account-oidc-issuer`,type:`url`,value:R,disabled:O,onChange:e=>ne(e.target.value),placeholder:`https://accounts.google.com or https://your-tenant.logto.app/oidc`})]}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O||!R.trim(),onClick:()=>void X(),children:`Verify /.well-known/openid-configuration`}),z&&(0,l.jsxs)(`p`,{className:`wb-wf-note`,children:[`Verified issuer `,(0,l.jsx)(`code`,{children:z.issuer}),` · PKCE S256:`,` `,(0,l.jsx)(`strong`,{children:z.pkceS256Supported?`Supported`:`No`})]})]})]}),E&&(0,l.jsxs)(`div`,{className:`wb-account-pat`,children:[(0,l.jsxs)(`label`,{htmlFor:`account-pat-input`,children:[`Scoped `,o(m),` Personal Access Token`,(0,l.jsx)(`input`,{ref:f,id:`account-pat-input`,type:`password`,autoComplete:`new-password`,spellCheck:!1,placeholder:m===`github`?`github_pat_… or ghp_…`:`glpat-…`})]}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>void ae(m),children:O?`Verifying…`:`Verify & connect`})]})]}),P&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-link`,children:[(0,l.jsxs)(`a`,{className:`button subtle`,href:P,target:`_blank`,rel:`noreferrer`,children:[`Open authorization page `,(0,l.jsx)(n,{name:`external`})]}),(0,l.jsx)(`button`,{type:`button`,className:`text-button`,disabled:O,onClick:()=>void W(u),children:`Check sign-in status`})]})]}),(0,l.jsx)(`p`,{className:`wb-account-boundary-note`,children:`Account sign-in stays separate from your AI model keys in Connections.`})]})}export{a as accountInitials,f as default,d as loadGoogleGsi};
|
|
1
|
+
import{i as e,t}from"./react-vendor-CH5vucNG.js";import{f as n,l as r,p as i,u as a}from"./index-Dp8CdAV4.js";import{a as o,n as s,t as ee}from"./account-modal-Cm9Rsqyi.js";var c=e(),l=t(),u=null;function d(){return typeof window>`u`?Promise.resolve(null):window.google?.accounts?.id?Promise.resolve(window.google.accounts.id):u||(u=new Promise(e=>{let t=document.querySelector(`script[src="https://accounts.google.com/gsi/client"]`);if(t){t.addEventListener(`load`,()=>e(window.google?.accounts?.id??null),{once:!0}),t.addEventListener(`error`,()=>e(null),{once:!0});return}let n=document.createElement(`script`);n.src=`https://accounts.google.com/gsi/client`,n.async=!0,n.defer=!0,n.onload=()=>e(window.google?.accounts?.id??null),n.onerror=()=>{u=null,e(null)},document.head.appendChild(n)}),u)}function f({open:e,auth:t,onClose:a,onUpdated:u}){let d=(0,c.useRef)(null),f=(0,c.useRef)(null),p=(0,c.useRef)(null),te=(0,c.useRef)(!1),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(!1),[v,y]=(0,c.useState)(`https://gitlab.com`),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(``),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1),[A,j]=(0,c.useState)(``),[M,N]=(0,c.useState)(``),[P,F]=(0,c.useState)(``),[I,L]=(0,c.useState)(null),[R,ne]=(0,c.useState)(``),[z,B]=(0,c.useState)(null),[re,V]=(0,c.useState)(null);te.current=g,(0,c.useEffect)(()=>{let n=d.current;n&&(e?(j(``),N(``),F(``),L(null),B(null),D(!1),C(!1),x(``),p.current&&(p.current.value=``),t?.providers.gitlab.baseUrl&&y(t.providers.gitlab.baseUrl),t?.secureStorage.available||_(!1),n.open||n.showModal()):n.open&&n.close())},[e,t?.providers.gitlab.baseUrl,t?.secureStorage.available]);let H=!!t?.account,U=t?.providers.google.clientId??``;if((0,c.useEffect)(()=>{if(!e||!H)return;let t=!0;return i(`/api/cloud-sync/status`).then(e=>{t&&V(e)}).catch(()=>{}),()=>{t=!1}},[e,H]),(0,c.useEffect)(()=>{if(!e||!I||H)return;let t=!0,n=Math.max(5e3,(I.intervalSeconds||5)*1e3),r=window.setInterval(()=>{t&&i(`/api/auth/github/device/poll`,{flowId:I.flowId}).then(async e=>{t&&e.status===`authenticated`&&(L(null),await u(),N(`Signed in via GitHub Device Flow.`))}).catch(()=>{})},n);return()=>{t=!1,window.clearInterval(r)}},[e,I,H,u]),(0,c.useEffect)(()=>{if(!e||!P||H)return;let t=!0,n=()=>{t&&!document.hidden&&u().catch(()=>{})},r=window.setInterval(n,1800);return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,n),()=>{t=!1,window.clearInterval(r),window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,n)}},[e,P,H,u]),!e)return null;async function W(e){k(!0),j(``),N(``);try{await e()}catch(e){j(e.message)}finally{k(!1)}}async function ie(){h(`google`),U&&await G(`google`)}async function G(e){h(e),F(``),await W(async()=>{let t=await i(`/api/auth/oauth/start`,{provider:e,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{},openBrowser:!0});F(t.authorizeUrl),N(t.browserOpened?`Opened ${o(e)} in your browser. Complete sign-in there—Studio updates automatically.`:`Open the authorization link below to finish ${o(e)} sign-in.`)})}async function K(e){await W(async()=>{await i(`/api/auth/connect-cli`,{provider:e,approved:!0,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{}}),await u(),N(`Signed in via ${e===`google`?`gcloud CLI`:e===`github`?`1-click GitHub OAuth / CLI`:`1-click GitLab OAuth / CLI`}.`)})}async function q(e){let t=b.trim(),n=p.current?.value??``;p.current&&(p.current.value=``),t?await W(async()=>{if(await i(`/api/auth/oauth/config`,{provider:e,clientId:t,clientSecret:n,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{}}),await u(),x(``),C(!1),e===`google`&&!n){N(`Saved Google Client ID! Reloading Studio to activate 1-click Google One Tap…`),window.setTimeout(()=>window.location.reload(),650);return}let r=await i(`/api/auth/oauth/start`,{provider:e,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{},openBrowser:!0});F(r.authorizeUrl),N(r.browserOpened?`Opened ${o(e)} SSO in your browser. Complete sign-in there—Studio updates automatically.`:`Open the authorization link below to finish ${o(e)} sign-in.`)}):j(`Paste your ${o(e)} OAuth Client ID first.`)}async function J(e,t){t&&(await navigator.clipboard?.writeText(t),T(e),window.setTimeout(()=>T(``),1800))}async function ae(e){let t=f.current?.value??``;f.current&&(f.current.value=``),t.trim()?await W(async()=>{await i(`/api/auth/connect-pat`,{provider:e,token:t,remember:g,...e===`gitlab`?{gitlabBaseUrl:v}:{}}),await u(),D(!1),N(`Connected to ${o(e)} using a scoped access token.`)}):j(`Paste a scoped Personal Access Token first.`)}async function oe(){await W(async()=>{window.google?.accounts?.id?.cancel(),await i(`/api/auth/signout`,{}),await u(),h(null),F(``),L(null),N(`Signed out and cleared stored account session tokens.`)})}async function se(){await W(async()=>{let e=await i(`/api/auth/verify`,{});e.valid?N(`${e.detail}${e.scopes?.length?` · Scopes: ${e.scopes.join(`, `)}`:``}`):j(e.detail)})}async function Y(){let e=b.trim();await W(async()=>{let t=await i(`/api/auth/github/device/start`,{...e?{clientId:e}:{},remember:g,openBrowser:!0});e&&(x(``),await u()),L(t),N(`Enter code ${t.userCode} at ${t.verificationUri} — Studio will sign you in automatically once authorized.`)})}async function X(){R.trim()&&await W(async()=>{let e=await i(`/api/auth/oidc/discover`,{issuerUrl:R.trim()});B(e),N(`Verified OIDC discovery for ${e.issuer} (PKCE S256 ready).`)})}async function ce(e){await W(async()=>{let t=await i(`/api/cloud-sync/config`,{optIn:e});V(t),N(e?`Opt-in Cloud Firestore sync enabled (${t.firebaseProjectId}).`:`Cloud Firestore sync paused; Studio remains strictly local.`)})}async function le(){await W(async()=>{let e=await i(`/api/cloud-sync/push`,{}),t=await i(`/api/cloud-sync/status`);V(t),N(`Synced workflow preset, layout & ${e.syncedRunsCount} redacted run summary(ies) to Firestore (${e.workspaceId}).`)})}async function ue(){await W(async()=>{let e=await i(`/api/cloud-sync/pull`,{});await u();let t=await i(`/api/cloud-sync/status`);V(t),N(`Pulled cloud state (${e.hasCloudPreset?`preset restored`:`no saved preset`}, ${e.runs.length} redacted run(s)) and refreshed subscription entitlements.`)})}let Z=t?.account??null,Q=m?t?.providers[m]:null,$=t?.providers.google.jsOrigin||window.location.origin;return(0,l.jsxs)(`dialog`,{ref:d,className:`wb-account-dialog`,"aria-labelledby":`account-dialog-title`,closedBy:`any`,onCancel:e=>{e.preventDefault(),a()},onClick:e=>{if(e.target===e.currentTarget&&!(`closedBy`in HTMLDialogElement.prototype)){let t=e.currentTarget.getBoundingClientRect();t.top<=e.clientY&&e.clientY<=t.top+t.height&&t.left<=e.clientX&&e.clientX<=t.left+t.width||a()}},children:[(0,l.jsx)(`div`,{className:`wb-account-dialog-top`,children:(0,l.jsx)(`button`,{type:`button`,className:`icon-button wb-account-close`,"aria-label":`Close account dialog`,onClick:a,children:(0,l.jsx)(n,{name:`close`})})}),(0,l.jsxs)(`div`,{className:`wb-account-hero`,children:[(0,l.jsx)(`span`,{className:`wb-account-brand-mark`,"aria-hidden":`true`,children:(0,l.jsx)(r,{})}),(0,l.jsx)(`h2`,{id:`account-dialog-title`,children:Z?`Studio account`:`Sign in to Studio`}),(0,l.jsx)(`p`,{children:Z?`Manage your connected account and repository access.`:`Sign in with Google or connect GitHub and GitLab to open your repositories.`})]}),A&&(0,l.jsx)(`p`,{className:`error-box`,role:`alert`,children:A}),M&&(0,l.jsx)(`p`,{className:`connection-success`,role:`status`,children:M}),Z?(0,l.jsx)(ee,{account:Z,auth:t,cloudSync:re,busy:O,onClose:a,onVerifyConnection:se,onSignOut:oe,onToggleCloudSync:ce,onPushCloudSync:le,onPullCloudSync:ue}):(0,l.jsxs)(`div`,{className:`wb-account-providers`,children:[(0,l.jsxs)(`div`,{className:`wb-account-provider-list`,role:`group`,"aria-label":`Sign in providers`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`wb-provider-button wb-provider-google`+(m===`google`?` is-selected`:``),disabled:O,onClick:()=>{j(``),N(``),F(``),ie()},children:[(0,l.jsx)(`span`,{className:`wb-provider-badge`,"aria-hidden":`true`,children:(0,l.jsx)(s,{provider:`google`})}),(0,l.jsxs)(`span`,{className:`wb-provider-copy`,children:[(0,l.jsx)(`strong`,{children:`Continue with Google`}),(0,l.jsx)(`small`,{children:U?`Sign in with your Google account`:t?.providers.google.cliAvailable?`Browser sign-in or local Google session`:`Sign in with your Google account`})]}),(0,l.jsx)(`svg`,{className:`wb-provider-arrow`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:(0,l.jsx)(`path`,{d:`M7.5 5 12.5 10 7.5 15`})})]}),(0,l.jsx)(`div`,{className:`wb-account-divider`,role:`separator`,children:(0,l.jsx)(`span`,{children:`or connect Git`})}),[`github`,`gitlab`].map(e=>{let n=t?.providers[e];return(0,l.jsxs)(`button`,{type:`button`,className:`wb-provider-button`+(m===e?` is-selected`:``),disabled:O,onClick:()=>{j(``),N(``),F(``),h(e),n?.oauthConfigured?G(e):n?.cliAvailable&&K(e)},children:[(0,l.jsx)(`span`,{className:`wb-provider-badge`,"aria-hidden":`true`,children:(0,l.jsx)(s,{provider:e})}),(0,l.jsxs)(`span`,{className:`wb-provider-copy`,children:[(0,l.jsxs)(`strong`,{children:[`Continue with `,o(e)]}),(0,l.jsx)(`small`,{children:n?.oauthConfigured?`Sign in with your ${o(e)} account`:n?.cliAvailable?`Use your local ${o(e)} sign-in`:`Connect ${o(e)} via browser or token`})]}),(0,l.jsx)(`svg`,{className:`wb-provider-arrow`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:(0,l.jsx)(`path`,{d:`M7.5 5 12.5 10 7.5 15`})})]},e)})]}),(0,l.jsxs)(`label`,{className:`wb-account-remember-row`,children:[(0,l.jsxs)(`span`,{className:`wb-account-remember-copy`,children:[(0,l.jsx)(`strong`,{children:`Keep me signed in on this computer`}),(0,l.jsx)(`small`,{children:t?.secureStorage.available?`Saved securely by your operating system, never in browser storage.`:`Secure storage unavailable here — stays signed in for this session only.`})]}),(0,l.jsx)(`input`,{type:`checkbox`,role:`switch`,className:`settings-switch`,checked:g,disabled:!t?.secureStorage.available||O,onChange:e=>_(e.target.checked)})]}),m===`google`&&(0,l.jsxs)(`div`,{className:`wb-account-fallback`,role:`region`,"aria-label":`Google One Tap setup`,children:[(0,l.jsxs)(`div`,{className:`wb-account-fallback-actions`,children:[U&&(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>void G(`google`),children:`Open Google browser sign-in`}),Q?.cliAvailable&&(0,l.jsx)(`button`,{type:`button`,className:U?`button subtle`:`button primary`,disabled:O,onClick:()=>void K(`google`),children:`Connect via local gcloud CLI`}),U&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O,onClick:()=>C(e=>!e),children:S?`Hide Client ID settings`:`Change Client ID`})]}),(!U||S)&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-setup`,children:[t?.firebase?.defaultGoogleClientId&&(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>{x(t.firebase?.defaultGoogleClientId??``),W(async()=>{await i(`/api/auth/oauth/config`,{provider:`google`,clientId:t.firebase?.defaultGoogleClientId??``,clientSecret:``,remember:g}),await u(),C(!1),await G(`google`)})},children:`Use Firebase Google Sign-In (ui-design-studio-ab07b)`}),(0,l.jsxs)(`p`,{children:[`Or paste a custom `,(0,l.jsx)(`strong`,{children:`Google OAuth Web Client ID`}),` (no Client Secret required) to activate Chrome’s native `,(0,l.jsx)(`strong`,{children:`1-click One Tap`}),` account picker on this origin:`]}),(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,children:$}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`origin`,$),children:w===`origin`?`Copied`:`Copy origin`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-id`,children:[`Google OAuth Client ID`,(0,l.jsx)(`input`,{id:`account-oauth-client-id`,type:`text`,spellCheck:!1,value:b,disabled:O,onChange:e=>x(e.target.value),placeholder:`1234567890-abc….apps.googleusercontent.com`})]}),(0,l.jsxs)(`details`,{className:`wb-account-advanced-oauth`,children:[(0,l.jsx)(`summary`,{children:`Optional: full redirect OAuth fallback (Client Secret)`}),Q?.redirectUri&&(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,children:Q.redirectUri}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`redirect`,Q.redirectUri??``),children:w===`redirect`?`Copied`:`Copy URI`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-secret`,children:[`Client Secret (stored in OS vault / memory only)`,(0,l.jsx)(`input`,{ref:p,id:`account-oauth-client-secret`,type:`password`,autoComplete:`new-password`,spellCheck:!1,disabled:O,placeholder:`Optional — only needed for redirect fallback`})]})]}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O||!b.trim(),onClick:()=>void q(`google`),children:O?`Enabling Google One Tap…`:`Save & Sign in with Google`})]})]}),(m===`github`||m===`gitlab`)&&(0,l.jsxs)(`div`,{className:`wb-account-fallback`,role:`region`,"aria-label":`${o(m)} connection options`,children:[m===`gitlab`&&(0,l.jsxs)(`label`,{htmlFor:`account-gitlab-host`,className:`wb-account-host`,children:[`GitLab instance URL`,(0,l.jsx)(`input`,{id:`account-gitlab-host`,type:`url`,value:v,disabled:O,onChange:e=>y(e.target.value),placeholder:`https://gitlab.com`})]}),(0,l.jsxs)(`div`,{className:`wb-account-fallback-actions`,children:[Q?.oauthConfigured&&(0,l.jsxs)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>void G(m),children:[`Open `,o(m),` OAuth`]}),m===`github`&&Q?.oauthConfigured&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O,onClick:()=>void Y(),children:`GitHub Device Code (Zero-Secret)`}),(0,l.jsxs)(`button`,{type:`button`,className:Q?.oauthConfigured?`button subtle`:`button primary`,disabled:O,onClick:()=>void K(m),children:[`Connect via local `,m===`github`?`gh`:`glab`,` CLI`]}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-expanded":E,disabled:O,onClick:()=>{C(!1),D(e=>!e)},children:E?`Hide token form`:`Use Personal Access Token`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,"aria-expanded":S,disabled:O,onClick:()=>{D(!1),C(e=>!e)},children:S?`Hide OAuth app`:`Configure OAuth / SSO`})]}),m===`github`&&I&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-setup`,role:`status`,children:[(0,l.jsx)(`p`,{children:`Enter this one-time code on GitHub (Studio is polling automatically):`}),(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,style:{fontSize:`1.1rem`,fontWeight:700},children:I.userCode}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`device`,I.userCode),children:w===`device`?`Copied`:`Copy code`}),(0,l.jsx)(`a`,{className:`button primary`,href:I.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:`Open GitHub Device Activation`})]})]}),S&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-setup`,children:[(0,l.jsxs)(`p`,{children:[`Configure local `,(0,l.jsxs)(`strong`,{children:[o(m),` OAuth 2.0`]}),` `,`with Redirect URI:`]}),Q?.redirectUri&&(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,children:Q.redirectUri}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void J(`redirect`,Q.redirectUri??``),children:w===`redirect`?`Copied`:`Copy URI`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-id`,children:[o(m),` OAuth Client ID`,(0,l.jsx)(`input`,{id:`account-oauth-client-id`,type:`text`,spellCheck:!1,value:b,disabled:O,onChange:e=>x(e.target.value),placeholder:`Paste OAuth Client ID`})]}),(0,l.jsxs)(`label`,{htmlFor:`account-oauth-client-secret`,children:[`Client Secret (optional — stored in system vault or memory only)`,(0,l.jsx)(`input`,{ref:p,id:`account-oauth-client-secret`,type:`password`,autoComplete:`new-password`,spellCheck:!1,disabled:O,placeholder:`Optional OAuth Client Secret`})]}),(0,l.jsxs)(`div`,{className:`wb-account-fallback-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O||!b.trim(),onClick:()=>void q(m),children:O?`Opening OAuth…`:`Save & Sign in with ${o(m)}`}),m===`github`&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O||!b.trim(),onClick:()=>void Y(),children:`Save & Use GitHub Device Flow (No Secret)`})]}),(0,l.jsxs)(`details`,{className:`wb-account-advanced-oauth`,children:[(0,l.jsx)(`summary`,{children:`Test team SSO provider (WorkOS / Logto / Okta / Entra)`}),(0,l.jsxs)(`label`,{htmlFor:`account-oidc-issuer`,children:[`HTTPS OIDC Issuer URL`,(0,l.jsx)(`input`,{id:`account-oidc-issuer`,type:`url`,value:R,disabled:O,onChange:e=>ne(e.target.value),placeholder:`https://accounts.google.com or https://your-tenant.logto.app/oidc`})]}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:O||!R.trim(),onClick:()=>void X(),children:`Verify /.well-known/openid-configuration`}),z&&(0,l.jsxs)(`p`,{className:`wb-wf-note`,children:[`Verified issuer `,(0,l.jsx)(`code`,{children:z.issuer}),` · PKCE S256:`,` `,(0,l.jsx)(`strong`,{children:z.pkceS256Supported?`Supported`:`No`})]})]})]}),E&&(0,l.jsxs)(`div`,{className:`wb-account-pat`,children:[(0,l.jsxs)(`label`,{htmlFor:`account-pat-input`,children:[`Scoped `,o(m),` Personal Access Token`,(0,l.jsx)(`input`,{ref:f,id:`account-pat-input`,type:`password`,autoComplete:`new-password`,spellCheck:!1,placeholder:m===`github`?`github_pat_… or ghp_…`:`glpat-…`})]}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:O,onClick:()=>void ae(m),children:O?`Verifying…`:`Verify & connect`})]})]}),P&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-link`,children:[(0,l.jsxs)(`a`,{className:`button subtle`,href:P,target:`_blank`,rel:`noreferrer`,children:[`Open authorization page `,(0,l.jsx)(n,{name:`external`})]}),(0,l.jsx)(`button`,{type:`button`,className:`text-button`,disabled:O,onClick:()=>void W(u),children:`Check sign-in status`})]})]}),(0,l.jsx)(`p`,{className:`wb-account-boundary-note`,children:`Account sign-in stays separate from your AI model keys in Connections.`})]})}export{a as accountInitials,f as default,d as loadGoogleGsi};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-4tVxZq34.js";import{i as t,t as n}from"./react-vendor-CH5vucNG.js";import{c as r,f as i,g as a,n as o,p as s}from"./index-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-4tVxZq34.js";import{i as t,t as n}from"./react-vendor-CH5vucNG.js";import{c as r,f as i,g as a,n as o,p as s}from"./index-Dp8CdAV4.js";var c=t(),l=n();function u({text:e,language:t=`json`,id:n,label:r=`MCP configuration`,copyLabel:i}){let[a,o]=(0,c.useState)(``);function s(e){if(t!==`json`)return e;let n=[],r=/"(?:\\.|[^"\\])*"|\b(?:true|false|null)\b|-?\b\d+(?:\.\d+)?\b|[{}\[\],:]/g,i=0;for(let t of e.matchAll(r)){let r=t.index;r>i&&n.push(e.slice(i,r));let a=t[0],o=a.startsWith(`"`)?/^\s*:/.test(e.slice(r+a.length))?`key`:`string`:/^[{}\[\],:]$/.test(a)?`punctuation`:`literal`;n.push((0,l.jsx)(`span`,{className:`syntax-`+o,children:a},r)),i=r+a.length}return i<e.length&&n.push(e.slice(i)),n}return(0,l.jsxs)(`div`,{className:`studio-code`,children:[(0,l.jsxs)(`div`,{className:`code-toolbar`,children:[(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,children:(0,l.jsx)(`path`,{d:`m6 5-4 5 4 5m8-10 4 5-4 5m-3-12-2 14`})}),t===`json`?`mcp.config.json`:t===`powershell`||t===`bash`?`Terminal`:`Text`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`span`,{role:`status`,className:`copy-status`,children:a}),(0,l.jsxs)(`button`,{type:`button`,"aria-label":i??(t===`json`?`Copy MCP JSON`:`Copy setup command`),onClick:async()=>{try{await navigator.clipboard.writeText(e),o(`Copied`)}catch{o(`Select text to copy`)}},children:[(0,l.jsxs)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[(0,l.jsx)(`rect`,{x:`7`,y:`3`,width:`10`,height:`11`,rx:`2`}),(0,l.jsx)(`path`,{d:`M12 17H5a2 2 0 0 1-2-2V8`})]}),`Copy`]})]})]}),(0,l.jsx)(`pre`,{id:n,"aria-label":r,children:(0,l.jsx)(`code`,{children:e.split(`
|
|
2
2
|
`).map((t,n)=>(0,l.jsxs)(`span`,{className:`code-line`,children:[(0,l.jsx)(`span`,{className:`line-number`,"aria-hidden":`true`,children:n+1}),(0,l.jsx)(`span`,{children:s(t)||` `}),n<e.split(`
|
|
3
3
|
`).length-1?`
|
|
4
4
|
`:null]},n))})})]})}function d(){return typeof navigator>`u`||(navigator.platform||navigator.userAgent||``).toLowerCase().includes(`win`)?`windows`:`posix`}var f=[`codex`,`claude`,`desktop`,`cursor`,`antigravity`],p=[`codex`,`claude`,`desktop`,`cursor`,`antigravity`];function m(e,t){let n=t?` so it loads the latest Studio tools`:``;return e===`antigravity`?`In Antigravity, open … → MCP Servers → Manage MCP Servers → Refresh (or restart Antigravity)${n}.`:e===`cursor`?`Reload MCP in Cursor Settings${n}.`:`Restart or start a new session in your client${n}.`}function h(){let[e,t]=(0,c.useState)(null),[n,i]=(0,c.useState)(!1),[a,o]=(0,c.useState)(``),[u,d]=(0,c.useState)(``);async function f(){try{let e=await s(`/api/clients/mcpb/mode`);t(e)}catch(e){d(e.message)}}(0,c.useEffect)(()=>{f()},[]);async function p(n,r){i(!0),d(``),o(``);try{let i=await s(`/api/clients/mcpb/mode`,{mode:n,...r===void 0?e?.clientId?{clientId:e.clientId}:{}:{clientId:r}});t(e=>({...i,activeClients:e?.activeClients??[]})),o(`Saved. Toggle UI Design Studio off/on in Claude Desktop Connectors (or restart Claude Desktop) to apply.`)}catch(e){d(e.message)}finally{i(!1)}}if(!e&&!u)return null;let m=e?.mode??`auto`,h=e?.activeClients??[],g=h.length>0,_={auto:g?`Uses live editing & draft checks when Studio is running; falls back smoothly to standalone when Studio is closed.`:`Runs standalone right now. As soon as you create a project connection, Claude Desktop will automatically attach for live editing when Studio is running.`,standalone:`Reviewed revisions only (preview, diff, 1-click Apply/Undo). Works across all projects even when Studio is closed.`,attach:`Always connects to your running Studio instance for live-edit batches and draft checks. Fails loudly if Studio is closed.`};return(0,l.jsxs)(`section`,{className:`mcp-extension-mode`,"aria-label":`Claude Desktop extension mode`,children:[(0,l.jsxs)(`div`,{className:`mcp-extension-mode-head`,children:[(0,l.jsx)(`h4`,{children:`Claude Desktop extension mode`}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":`ready`,children:m===`auto`?e?.clientId?`Auto · Live Edit ready`:`Auto · Standalone`:m===`attach`?`Live Edit (Strict)`:`Standalone`})]}),(0,l.jsx)(`div`,{className:`mcp-client-tabs`,role:`tablist`,"aria-label":`Choose Claude Desktop mode`,children:[{id:`auto`,label:`Auto (Recommended)`},{id:`standalone`,label:`Standalone`},{id:`attach`,label:`Live Edit (Strict)`}].map(e=>(0,l.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":m===e.id,disabled:n||e.id===`attach`&&!g,onClick:()=>void p(e.id),children:e.label},e.id))}),(0,l.jsx)(`p`,{className:`field-help`,children:_[m]}),m!==`standalone`&&g&&(0,l.jsxs)(`div`,{className:`mcp-extension-client-picker`,children:[(0,l.jsx)(`label`,{htmlFor:`mcpb-active-client`,children:`Live-edit connection`}),(0,l.jsx)(r,{id:`mcpb-active-client`,label:`Live-edit connection`,value:e?.clientId??``,disabled:n,onChange:e=>void p(m,e),options:[...m===`auto`?[{value:``,label:`None (standalone until selected)`}]:[],...h.map(e=>({value:e.clientId,label:e.project?`${e.clientName} · ${e.project.split(/[\\/]/).filter(Boolean).at(-1)??e.project}`:e.clientName}))]})]}),a&&(0,l.jsx)(`p`,{className:`mcp-install-status`,role:`status`,children:a}),u&&(0,l.jsx)(`p`,{className:`error-box`,role:`alert`,children:u})]})}function g({enrollmentClientId:e,primary:t=!1,onStatus:n}){let[r,i]=(0,c.useState)(!1);async function o(){i(!0),n?.(``,!1);try{let t=e?`/api/clients/mcpb?clientId=${encodeURIComponent(e)}`:`/api/clients/mcpb`;await a(t,e?`ui-design-studio-attached.mcpb`:`ui-design-studio.mcpb`),n?.(`Downloaded .mcpb bundle. Double-click it to install in Claude Desktop, or open Settings → Desktop app → Extensions → Manage.`,!1)}catch(e){n?.(e.message,!0)}finally{i(!1)}}return(0,l.jsx)(`button`,{type:`button`,className:t?`button primary`:`button subtle`,disabled:r,onClick:()=>void o(),children:r?`Preparing .mcpb…`:e?`Download .mcpb bundle`:`Download .mcpb extension`})}function _({clientId:e,clientName:t,enrollmentClientId:n,primary:r=!0,label:i,showMcpb:a=!1,onInstalled:o}){let[u,d]=(0,c.useState)(!1),[f,p]=(0,c.useState)(null),[h,_]=(0,c.useState)(``),[v,y]=(0,c.useState)(``);(0,c.useEffect)(()=>{p(null),_(``),y(``)},[e,n]);async function b(){d(!0),_(``);try{let t=await s(`/api/clients/install-config`,{clientType:e,...n?{clientId:n}:{mode:`standalone`},write:!0});p(t),o?.(t)}catch(e){_(e.message)}finally{d(!1)}}return(0,l.jsxs)(`div`,{className:`mcp-install-action`,children:[(0,l.jsxs)(`div`,{className:`mcp-install-row`,children:[(0,l.jsx)(`button`,{type:`button`,className:r?`button primary`:`button subtle`,disabled:u,onClick:()=>void b(),children:u?`Saving to ${t}…`:i??(n?`Save to ${t} config`:`Save standalone server to ${t}`)}),a&&(0,l.jsx)(g,{enrollmentClientId:n,primary:!r,onStatus:(e,t)=>{t?(_(e),y(``)):(_(``),y(e))}})]}),v&&(0,l.jsx)(`p`,{className:`mcp-install-status`,role:`status`,children:v}),h&&(0,l.jsx)(`p`,{className:`error-box`,role:`alert`,children:h}),f&&(0,l.jsxs)(`div`,{className:`mcp-install-status`,role:`status`,children:[(0,l.jsxs)(`p`,{children:[f.wrote?`Saved`:`Already configured`,` `,(0,l.jsx)(`code`,{translate:`no`,children:f.serverName}),` in `,(0,l.jsx)(`code`,{children:f.configPath}),`.`,f.backupPath&&(0,l.jsxs)(l.Fragment,{children:[` `,`Backup saved to `,(0,l.jsx)(`code`,{children:f.backupPath}),`.`]})]}),(0,l.jsx)(`p`,{className:`field-help`,children:m(e,f.mode===`attach`)})]})]})}function v({client:e,stateDir:t,enrollment:n}){let r=d(),i=e=>`'`+e.replaceAll(`'`,r===`windows`?`''`:`'"'"'`)+`'`,a=`ui-workflow connect ${e} ${n?.credentialFile?`--attach --client-file `+i(n.credentialFile):`--standalone`}${n?.serverName?` --server-name `+i(n.serverName):``}${t?` --state-dir `+i(t):``} --dry-run`;return(0,l.jsxs)(`details`,{className:`mcp-url-explainer mcp-connect-command`,children:[(0,l.jsx)(`summary`,{children:n?`Connect to this Studio task with the CLI`:`Connect with the CLI`}),(0,l.jsxs)(`p`,{children:[`With `,(0,l.jsx)(`code`,{children:`ui-workflow`}),` available in your terminal, run this command to preview the configuration diff. Replace `,(0,l.jsx)(`code`,{children:`--dry-run`}),` with `,(0,l.jsx)(`code`,{children:`--write`}),` when you want to save it. The CLI backs up an existing configuration before merging the server entry.`]}),(0,l.jsx)(u,{text:a,language:r===`windows`?`powershell`:`bash`,label:`Safe MCP connect command`,copyLabel:`Copy safe connect command`})]})}function y({client:e,task:t,stateDir:n,onClientConnected:i}){let[a,o]=(0,c.useState)([]),[h,g]=(0,c.useState)(`design-edit`),[y,b]=(0,c.useState)(null),[x,ee]=(0,c.useState)(!1),[S,C]=(0,c.useState)(``),[te,w]=(0,c.useState)(``);(0,c.useEffect)(()=>{let e=!0;return s(`/api/clients`).then(t=>{e&&o(t.clients)}).catch(t=>{e&&C(t.message)}),()=>{e=!1}},[]);async function T(){if(t&&e){ee(!0),C(``),w(``);try{let n=await s(`/api/clients/connect`,{runId:t.runId,clientType:e.id,clientName:e.name,profile:h});b(n),n.serverName&&i?.(n.serverName),o(e=>[...e.filter(e=>e.clientId!==n.clientId),n])}catch(e){C(e.message)}finally{ee(!1)}}}async function E(e){ee(!0),C(``),w(``);try{await s(`/api/clients/`+e+`/revoke`,{}),o(t=>t.map(t=>t.clientId===e?{...t,revoked:!0}:t)),y?.clientId===e&&b(null),w(`Connection revoked.`)}catch(e){C(e.message)}finally{ee(!1)}}let D=y?.setup;return(0,l.jsxs)(`section`,{"aria-labelledby":`client-enrollment-title`,className:`mcp-client-route mcp-enrollment`,children:[(0,l.jsx)(`h3`,{id:`client-enrollment-title`,children:`Connect a local client`}),t&&e?.setupFormat!==`instructions`?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`p`,{children:[`Share tasks you prepare in Studio for`,` `,(0,l.jsx)(`strong`,{title:t.project,children:t.project.split(/[\\/]/).filter(Boolean).at(-1)}),`. Access lasts 30 days and you can revoke it here.`]}),(0,l.jsx)(r,{id:`enrollment-profile`,label:`Allowed actions`,value:h,onChange:e=>{g(e),b(null)},options:[{value:`design-edit`,label:`Read, check and stage revisions`},{value:`design-review`,label:`Inspect context and checks`}]}),!D&&(0,l.jsx)(`button`,{className:`button primary`,type:`button`,disabled:x||!e,onClick:T,children:x?`Connecting…`:`Create connection`})]}):(0,l.jsx)(`p`,{children:t?`Choose a local client above to connect this project.`:`Prepare a client task from a project to create a connection.`}),S&&(0,l.jsx)(`p`,{className:`error-box`,role:`alert`,children:S}),te&&(0,l.jsx)(`p`,{role:`status`,children:te}),D&&(0,l.jsxs)(`div`,{className:`mcp-enrollment-setup`,children:[(0,l.jsxs)(`h3`,{children:[D.name,` setup`]}),e&&p.includes(e.id)&&y?.clientId&&!y.revoked&&(0,l.jsx)(_,{clientId:e.id,clientName:D.name,enrollmentClientId:y.clientId,showMcpb:e.id===`desktop`,onInstalled:e=>i?.(e.serverName)}),(0,l.jsx)(`p`,{children:D.setupFormat===`command`?`Or run this command once in your terminal, then reopen your client:`:`Or merge this entry manually into your client configuration, then reload the server:`}),D.configPath&&(0,l.jsx)(`p`,{children:(0,l.jsx)(`code`,{children:D.configPath})}),(0,l.jsx)(u,{text:D.setup,language:D.setupFormat===`command`?d()===`windows`?`powershell`:`bash`:`json`,label:`Project client setup`,copyLabel:`Copy project client setup`}),D.verify&&(0,l.jsx)(`p`,{className:`field-help`,children:D.verify}),e&&f.includes(e.id)&&y?.credentialFile&&!y.revoked&&(0,l.jsx)(v,{client:e.id,stateDir:n,enrollment:y})]}),a.some(e=>!e.revoked)&&(0,l.jsxs)(`details`,{className:`mcp-url-explainer mcp-manage-connections`,children:[(0,l.jsx)(`summary`,{children:`Manage connections`}),(0,l.jsx)(`ul`,{className:`mcp-steps`,children:a.filter(e=>!e.revoked).sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)).map(t=>{let n=!!t.credentialFile&&t.expiresAt>Date.now(),r=t.serverName??(t.project?`ui-design-workflow-`+t.clientId.slice(0,8):void 0);return(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`strong`,{children:t.clientName}),t.project&&` · `+t.project.split(/[\\/]/).at(-1),r&&(0,l.jsxs)(l.Fragment,{children:[` · `,(0,l.jsx)(`code`,{translate:`no`,children:r})]}),` · `,t.expiresAt<=Date.now()?`Expired`:t.profile===`design-edit`?`Design access`:`Review access`,(0,l.jsxs)(`span`,{className:`mcp-connection-actions`,children:[n&&e&&p.includes(e.id)&&(0,l.jsx)(_,{clientId:e.id,clientName:e.name,enrollmentClientId:t.clientId,primary:!1,label:`Save to ${e.name}`,onInstalled:t=>{w(`Saved ${t.serverName} to ${t.configPath}. ${m(e.id,!0)}`),i?.(t.serverName)}}),(0,l.jsx)(`button`,{className:`button subtle`,type:`button`,disabled:x,"aria-label":`Revoke ${t.clientName}`,onClick:()=>E(t.clientId),children:`Revoke`})]})]},t.clientId)})})]})]})}function b(){let[e,t]=(0,c.useState)(()=>d()),n=e===`windows`,r=n?`npm.cmd`:`npm`,a=n?`PowerShell`:`your terminal`,o=n?`powershell`:`bash`;return(0,l.jsxs)(`section`,{className:`mcp-setup media-settings-page`,id:`media-mcp-setup`,"aria-labelledby":`media-mcp-title`,children:[(0,l.jsxs)(`div`,{className:`settings-intro`,children:[(0,l.jsx)(`h2`,{id:`media-mcp-title`,children:`Media, decks & voice`}),(0,l.jsx)(`p`,{children:`Reference images and brief voice dictation work right inside Studio. Slide decks, motion video, and voiceovers run in separate optional workspaces so your website code stays isolated.`})]}),(0,l.jsxs)(`section`,{className:`media-builtin-section`,"aria-labelledby":`media-builtin-title`,children:[(0,l.jsxs)(`div`,{className:`media-section-head`,children:[(0,l.jsx)(`h3`,{id:`media-builtin-title`,children:`Built into Studio`}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":`ready`,children:`Ready locally`})]}),(0,l.jsxs)(`div`,{className:`media-capability-grid`,children:[(0,l.jsxs)(`article`,{className:`media-capability-card`,children:[(0,l.jsxs)(`div`,{className:`media-card-top`,children:[(0,l.jsx)(`span`,{className:`media-card-icon`,"aria-hidden":`true`,children:(0,l.jsx)(i,{name:`image`})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h4`,{children:`Visual references & project photos`}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":`ready`,children:`Ready locally`})]})]}),(0,l.jsxs)(`p`,{children:[`Attach up to 8 reference images or project photos per revision, select crop focus regions, and guide layout or photography placement from the composer’s`,` `,(0,l.jsx)(`strong`,{children:`References`}),` panel.`]})]}),(0,l.jsxs)(`article`,{className:`media-capability-card`,children:[(0,l.jsxs)(`div`,{className:`media-card-top`,children:[(0,l.jsx)(`span`,{className:`media-card-icon`,"aria-hidden":`true`,children:(0,l.jsx)(i,{name:`mic`})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h4`,{children:`Voice dictation & transcription`}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":`ready`,children:`Ready locally`})]})]}),(0,l.jsxs)(`p`,{children:[`Dictate briefs directly in the composer using browser speech recognition, with optional cloud transcription through your connected Groq or Google AI Studio key in`,` `,(0,l.jsx)(`strong`,{children:`Connections`}),`.`]})]})]})]}),(0,l.jsxs)(`section`,{className:`media-mcp-section`,"aria-labelledby":`media-workspaces-title`,children:[(0,l.jsxs)(`div`,{className:`media-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h3`,{id:`media-workspaces-title`,children:`Separate deck, video & audio workspaces`}),(0,l.jsxs)(`p`,{className:`field-help`,children:[`Run a setup command from the workspace folder in `,a,`, merge the printed JSON into your AI client settings, and restart it. If you already added`,` `,(0,l.jsx)(`code`,{translate:`no`,children:`ui-design-workflow`}),`, add the printed environment variable to that entry.`]})]}),(0,l.jsxs)(`div`,{className:`mcp-client-tabs media-platform-tabs`,role:`tablist`,"aria-label":`Setup platform`,children:[(0,l.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>t(`windows`),children:`Windows (PowerShell)`}),(0,l.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!n,onClick:()=>t(`posix`),children:`Linux / macOS (Terminal)`})]})]}),(0,l.jsxs)(`div`,{className:`media-workspace-list`,children:[(0,l.jsxs)(`section`,{className:`mcp-client-route media-workspace-card`,"aria-labelledby":`deck-mcp-title`,children:[(0,l.jsxs)(`div`,{className:`media-workspace-head`,children:[(0,l.jsx)(`h4`,{id:`deck-mcp-title`,children:`PowerPoint decks`}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":`ready`,children:`Local MCP`})]}),(0,l.jsxs)(`p`,{children:[`Build and iterate editable `,(0,l.jsx)(`code`,{children:`.pptx`}),` drafts via `,(0,l.jsx)(`code`,{children:`pptxgenjs`}),` in a private local workspace, separate from website code runs.`]}),(0,l.jsx)(u,{text:`${r} run deck:mcp:setup`,language:o,label:`PowerPoint setup command`,copyLabel:`Copy PowerPoint setup command`})]}),(0,l.jsxs)(`section`,{className:`mcp-client-route media-workspace-card`,"aria-labelledby":`video-mcp-title`,children:[(0,l.jsxs)(`div`,{className:`media-workspace-head`,children:[(0,l.jsx)(`h4`,{id:`video-mcp-title`,children:`Motion video & audio`}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":`ready`,children:`Local MCP`})]}),(0,l.jsxs)(`p`,{children:[`Preview and export MP4s with imported WAV/MP3 audio and built-in sounds. For programmatic Remotion or Manim video projects, load scoped video guidance via`,` `,(0,l.jsxs)(`code`,{translate:`no`,children:[r,` run hub:context -- --task video --engine remotion`]}),`.`]}),(0,l.jsx)(u,{text:`${r} run video:mcp:setup`,language:o,label:`Video setup command`,copyLabel:`Copy video setup command`})]}),(0,l.jsxs)(`section`,{className:`mcp-client-route media-workspace-card`,"aria-labelledby":`elevenlabs-mcp-title`,children:[(0,l.jsxs)(`div`,{className:`media-workspace-head`,children:[(0,l.jsx)(`h4`,{id:`elevenlabs-mcp-title`,children:`ElevenLabs voiceovers & SFX`}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":`local-intake`,children:`Optional external MCP`})]}),(0,l.jsx)(`p`,{children:`To generate voiceovers or sound effects, add this remote URL directly in a compatible MCP client and sign in with OAuth. Generations use your own ElevenLabs workspace credits; Studio never stores ElevenLabs credentials.`}),(0,l.jsx)(u,{text:`https://api.elevenlabs.io/v1/mcp`,language:`text`,label:`ElevenLabs MCP URL`,copyLabel:`Copy ElevenLabs MCP URL`}),(0,l.jsxs)(`a`,{href:`https://elevenlabs.io/docs/eleven-api/resources/mcp-server`,target:`_blank`,rel:`noreferrer`,children:[`Read ElevenLabs setup instructions `,(0,l.jsx)(i,{name:`external`})]})]})]})]})]})}var x=[{id:`codex`,name:`Codex`},{id:`claude`,name:`Claude Code`},{id:`desktop`,name:`Claude Desktop`},{id:`cursor`,name:`Cursor`},{id:`antigravity`,name:`Antigravity`},{id:`chatgpt`,name:`ChatGPT`}];function ee({task:e,onClientConnected:t}){let[n,r]=(0,c.useState)(null),[a,o]=(0,c.useState)(`codex`),[m,g]=(0,c.useState)(``),[b,ee]=(0,c.useState)(0),[C,te]=(0,c.useState)(!1),w=(0,c.useRef)(null),T=!!n?.attachment;(0,c.useEffect)(()=>{if(!T||!e)return;let t=requestAnimationFrame(()=>w.current?.querySelector(`[aria-selected="true"]`)?.focus());return()=>cancelAnimationFrame(t)},[T,e]),(0,c.useEffect)(()=>{let e=!0;return s(`/api/settings`).then(t=>{e&&r(t)}).catch(t=>{e&&g(t.message)}),()=>{e=!1}},[b]);let E=n?.clients??x,D=n?.clients.find(e=>e.id===a);return(0,l.jsxs)(`section`,{className:`mcp-setup`,"aria-labelledby":`mcp-setup-title`,children:[(0,l.jsxs)(`div`,{className:`mcp-section-heading`,children:[(0,l.jsx)(`span`,{className:`mcp-symbol`,children:(0,l.jsx)(i,{name:`mcp`})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{id:`mcp-setup-title`,children:e?`Choose your client`:`Work through your AI client`}),(0,l.jsx)(`p`,{children:e?`Connect once, then use the task prompt for each revision you share.`:`Choose AI client in the composer and prepare a revision to share it.`})]})]}),(0,l.jsx)(`div`,{className:`mcp-client-tabs`,ref:w,role:`tablist`,"aria-label":`MCP client`,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=E.findIndex(e=>e.id===a),n=e.key===`Home`?E[0]:e.key===`End`?E.at(-1):E[(t+(e.key===`ArrowRight`?1:E.length-1))%E.length];o(n.id),requestAnimationFrame(()=>document.getElementById(`mcp-client-`+n.id)?.focus())},children:E.map(e=>(0,l.jsxs)(`button`,{type:`button`,role:`tab`,tabIndex:a===e.id?0:-1,"aria-selected":a===e.id,"aria-controls":`mcp-client-instructions`,id:`mcp-client-`+e.id,onClick:()=>o(e.id),children:[(0,l.jsx)(i,{name:e.id===`codex`||e.id===`chatgpt`?`codex`:e.id===`claude`||e.id===`desktop`?`claude`:e.id===`cursor`?`cursor`:e.id===`antigravity`?`antigravity`:`mcp`}),e.name]},e.id))}),(0,l.jsxs)(`div`,{id:`mcp-client-instructions`,role:`tabpanel`,"aria-labelledby":`mcp-client-`+a,className:`mcp-client-body`,children:[m?(0,l.jsxs)(`div`,{className:`error-box`,role:`alert`,children:[(0,l.jsx)(`p`,{children:m}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>{g(``),ee(e=>e+1)},children:`Retry loading setup`})]}):D?e&&D.setupFormat!==`instructions`?(0,l.jsx)(y,{client:D,task:e,stateDir:n?.attachment?.args.at(-1),onClientConnected:t},a):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mcp-status-row`,children:[(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":D.setupFormat===`instructions`?`planned`:`ready`,children:D.setupFormat===`instructions`?`Planned · requires remote HTTPS`:`Ready locally (MCP)`}),D.id===`desktop`&&(0,l.jsx)(`span`,{className:`settings-type-label`,children:`Supports Windows MSIX Claude-Data & standard configs`}),(0,l.jsxs)(`span`,{className:`mcp-checked-date`,children:[`Checked `,(0,l.jsx)(`time`,{dateTime:D.checkedAt,children:D.checkedAt})]})]}),D.setupFormat===`instructions`?(0,l.jsxs)(l.Fragment,{children:[e&&(0,l.jsxs)(`div`,{className:`error-box`,role:`status`,children:[`ChatGPT cannot attach directly to a local project’s`,` `,(0,l.jsx)(`code`,{children:`STUDIO_CLIENT_FILE`}),` stdio server. Choose Codex, Claude Code, Claude Desktop, Cursor, or Antigravity above for this project task, or switch to Auto model connections.`]}),(0,l.jsxs)(`p`,{children:[D.next,` Studio does not expose a hosted MCP HTTP endpoint yet, and account eligibility is not verified here.`]}),D.routes?.map(e=>(0,l.jsxs)(`section`,{className:`mcp-client-route`,"aria-labelledby":`mcp-route-`+e.surface.toLowerCase(),children:[(0,l.jsx)(`h3`,{id:`mcp-route-`+e.surface.toLowerCase(),children:e.surface}),(0,l.jsx)(`p`,{children:e.description}),(0,l.jsxs)(`a`,{href:e.documentation,target:`_blank`,rel:`noreferrer`,children:[`Read `,e.surface,` setup requirements `,(0,l.jsx)(i,{name:`external`})]})]},e.surface))]}):(0,l.jsxs)(l.Fragment,{children:[D.configPath&&(0,l.jsxs)(`p`,{className:`field-help`,children:[`Config file: `,(0,l.jsx)(`code`,{children:D.configPath}),`. Merge into your active config instead of replacing existing servers.`]}),p.includes(D.id)&&(0,l.jsx)(S,{clientId:D.id}),D.steps?(0,l.jsx)(`ol`,{className:`mcp-steps`,children:D.steps.map(e=>(0,l.jsx)(`li`,{children:e},e))}):(0,l.jsxs)(`p`,{children:[`Run this registration command in`,` `,d()===`windows`?`PowerShell`:`your terminal`,`. It uses this Node installation and the existing local workflow server.`]}),(0,l.jsx)(`div`,{className:`mcp-code-heading`,children:D.setupFormat===`json`?`Merge this server into mcpServers`:`Registration command`}),p.includes(D.id)&&(0,l.jsxs)(l.Fragment,{children:[D.id===`desktop`&&(0,l.jsx)(h,{}),(0,l.jsx)(_,{clientId:D.id,clientName:D.name,primary:D.id!==`desktop`,showMcpb:D.id===`desktop`}),(0,l.jsx)(`p`,{className:`field-help`,children:D.id===`desktop`?`Recommended: install the .mcpb extension (double-click it, or open Claude Settings → Desktop app → Extensions → Manage). It includes the Studio icon, starter prompts, and automatic switching between live editing and standalone mode.`:`Standalone mode works for quick tasks without Studio running. Prepare a task in Studio and create a project connection when you need live editing or background draft checks.`})]}),(0,l.jsx)(u,{text:D.setup,language:D.setupFormat===`json`?`json`:d()===`windows`?`powershell`:`bash`,label:D.name+` MCP configuration`}),(0,l.jsx)(`p`,{children:D.next}),f.includes(D.id)&&(0,l.jsx)(v,{client:D.id,stateDir:n?.attachment?.args.at(-1)}),D.verify&&(0,l.jsx)(`p`,{className:`field-help`,children:D.verify}),D.documentation&&(0,l.jsx)(`p`,{children:(0,l.jsxs)(`a`,{href:D.documentation,target:`_blank`,rel:`noreferrer`,children:[`Read `,D.name,` connection requirements `,(0,l.jsx)(i,{name:`external`})]})})]}),(0,l.jsx)(`p`,{className:`field-help`,children:`Your AI client reads only the selected project files and submits staged proposals. Review and Apply changes in Studio. Usage and billing stay with your client.`}),(0,l.jsxs)(`details`,{className:`mcp-url-explainer`,children:[(0,l.jsx)(`summary`,{children:`Can I connect using a URL?`}),(0,l.jsx)(`p`,{children:n?.remote?.reason}),(0,l.jsx)(`p`,{children:`Today, all 5 local clients (Cursor, Antigravity, Claude Desktop, Claude Code, and Codex) connect locally on your machine. Remote URL connections are planned and not yet available.`})]})]}):(0,l.jsx)(`p`,{className:`field-help`,role:`status`,children:`Loading local configuration…`}),!m&&D&&(0,l.jsxs)(`details`,{className:`mcp-url-explainer`,children:[(0,l.jsx)(`summary`,{children:`Troubleshooting & CLI connect diagnostics`}),(0,l.jsxs)(`p`,{children:[(0,l.jsxs)(`strong`,{children:[(0,l.jsx)(`code`,{children:`STUDIO_AUTHORITY_INCOMPATIBLE`}),` (engine or protocol mismatch):`]}),` `,`Studio code was updated while an older Studio process was still running. Run`,` `,(0,l.jsx)(`code`,{children:`npm run studio -- --restart`}),` in your terminal, then reload your MCP client.`]}),(0,l.jsxs)(`p`,{children:[(0,l.jsx)(`strong`,{children:`5-client CLI setup (dry-run + backup on write):`}),` Run`,` `,(0,l.jsx)(`code`,{children:`ui-workflow connect <cursor|antigravity|desktop|claude|codex> --dry-run`}),` `,`to preview a secret-redacted config diff, then replace `,(0,l.jsx)(`code`,{children:`--dry-run`}),` with`,` `,(0,l.jsx)(`code`,{children:`--write`}),` (automatically saves a `,(0,l.jsx)(`code`,{children:`.bak`}),` backup).`]}),(0,l.jsxs)(`p`,{children:[(0,l.jsx)(`strong`,{children:`Core 3-step MCP flow:`}),` Call`,` `,(0,l.jsx)(`code`,{children:`get_run_context({ runId, compact: true })`}),` and`,` `,(0,l.jsx)(`code`,{children:`get_workflow`}),`, optionally run `,(0,l.jsx)(`code`,{children:`check_proposal`}),` /`,` `,(0,l.jsx)(`code`,{children:`validate_proposal`}),`, then finish with `,(0,l.jsx)(`code`,{children:`submit_revision`}),`. In live editing, pass `,(0,l.jsx)(`code`,{children:`openNextBatch: true`}),` to `,(0,l.jsx)(`code`,{children:`get_run_status`}),` after checks pass.`]}),(0,l.jsxs)(`p`,{children:[(0,l.jsx)(`strong`,{children:`Connection closed or owner unreachable:`}),` Keep Studio running (`,(0,l.jsx)(`code`,{children:`npm run studio`}),`) while your client is open, and confirm`,` `,(0,l.jsx)(`code`,{children:`STUDIO_CLIENT_FILE`}),` points to the active credential file created above. If revoked, create a fresh connection and reload your client.`]})]})]}),n?.attachment&&!e&&(0,l.jsxs)(`details`,{className:`mcp-url-explainer`,open:C,onToggle:e=>te(e.currentTarget.open),children:[(0,l.jsx)(`summary`,{children:`Local client connections`}),C&&(0,l.jsx)(y,{client:D,onClientConnected:t})]})]})}function S({clientId:e}){let[t,n]=(0,c.useState)(null),[r,a]=(0,c.useState)(``),[o,u]=(0,c.useState)(!1);(0,c.useEffect)(()=>{n(null),a(``)},[e]);async function d(){u(!0),a(``);try{let t=await s(`/api/clients/check-configs`,{});n(t.clients?.[e]??null)}catch(e){n(null),a(e.message)}finally{u(!1)}}return(0,l.jsxs)(`div`,{className:`mcp-config-check`,"data-client":e,children:[(0,l.jsxs)(`button`,{type:`button`,className:`button subtle`,disabled:o,onClick:()=>void d(),children:[(0,l.jsx)(i,{name:e===`cursor`?`cursor`:e===`antigravity`?`antigravity`:e===`codex`?`codex`:`claude`}),o?`Checking local MCP config…`:`Check local MCP config`]}),r&&(0,l.jsx)(`div`,{className:`mcp-config-check-result error`,role:`alert`,children:r}),t&&(0,l.jsx)(`div`,{className:`mcp-config-check-result`,role:`status`,children:t.files.length===0?(0,l.jsx)(`span`,{children:`No local MCP config file found at the standard locations yet.`}):(0,l.jsx)(`ul`,{children:t.files.map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`code`,{children:e.label}),`:`,` `,e.validJson?e.hasStudioServer?`Found ${e.studioServers.join(`, `)} (${e.serverCount} servers total)`:`Present (${e.serverCount} servers), ui-design-workflow not added yet`:e.error||`Invalid config syntax`]},e.label))})})]})}var C=[{id:`playwright`,name:`Playwright Visual & Interaction Engine`,icon:`capture`,detail:`320–1440px overflow, dark mode, reduced motion, rendered contrast & 1up/2up/diff slider.`,badge:`Ready locally`,tone:`ready`},{id:`storybook`,name:`Storybook`,icon:`component`,detail:`Auto-detects .storybook & *.stories.* components; audit story routes via .ui-workflow.json.`,badge:`Auto-detected`,tone:`ready`},{id:`vitest`,name:`Vitest & Testing Library`,icon:`check`,detail:`Auto-detects unit/component suites to preserve contracts alongside visual checks.`,badge:`Auto-detected`,tone:`ready`},{id:`cypress`,name:`Cypress`,icon:`shield`,detail:`Auto-detects Cypress configs and preserves data-cy / data-testid selectors.`,badge:`Auto-detected`,tone:`ready`},{id:`reference-library`,name:`Local Reference Library`,icon:`image`,detail:`Search curated boards and upload bounded inspiration crops without external credentials.`,badge:`Ready locally`,tone:`ready`}];function te({active:e,busy:t,securityToolchain:n,intakes:r,onMedia:a,perform:o,refresh:u,setMessage:d}){let[f,p]=(0,c.useState)(`github`),[m,h]=(0,c.useState)(``),[g,_]=(0,c.useState)(``),[v,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(``);return(0,l.jsxs)(`div`,{role:`tabpanel`,"aria-labelledby":`conn-tab-visual-testing`,hidden:!e,className:`wb-conn-panel`,children:[n&&(0,l.jsxs)(`section`,{className:`wb-security-toolchain`,"aria-label":`Security scanners and review skills`,children:[(0,l.jsx)(`h3`,{className:`wb-conn-subheading`,children:`Local Security & Context Scanners`}),(0,l.jsx)(`ul`,{className:`settings-directory-list`,"aria-label":`Security scanners`,children:n.scanners.map(e=>(0,l.jsxs)(`li`,{className:`settings-directory-row`,children:[(0,l.jsx)(`span`,{className:`settings-directory-icon`,children:(0,l.jsx)(i,{name:e.category===`context`?`mcp`:e.category===`sca`?`check`:`shield`})}),(0,l.jsxs)(`div`,{className:`settings-directory-copy`,children:[(0,l.jsxs)(`div`,{className:`settings-directory-name`,children:[(0,l.jsx)(`strong`,{children:e.name}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":e.status===`ready`?`ready`:`local-intake`,children:e.source===`built-in`?`Built-in active`:e.status===`ready`?`Installed locally`:`Optional CLI`}),(0,l.jsx)(`span`,{className:`wb-scanner-license`,children:e.license})]}),(0,l.jsxs)(`p`,{title:e.detail,children:[e.detail,e.status!==`ready`&&e.installCommand?(0,l.jsxs)(l.Fragment,{children:[` `,(0,l.jsx)(`code`,{children:e.installCommand})]}):null]})]})]},e.id))}),(0,l.jsx)(`h3`,{className:`wb-conn-subheading`,children:`Composable Security & Code Review Skills`}),(0,l.jsx)(`ul`,{className:`wb-skill-chip-list`,"aria-label":`Installed review and security skills`,children:n.skills.map(e=>(0,l.jsxs)(`li`,{"data-installed":e.installed?`true`:`false`,children:[(0,l.jsx)(`strong`,{children:e.name}),(0,l.jsx)(`span`,{children:e.license}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":e.installed?`ready`:`local-intake`,children:e.installed?`Installed`:`Not installed`})]},e.id))})]}),(0,l.jsx)(`h3`,{className:`wb-conn-subheading`,children:`Visual & Browser Testing Engines`}),(0,l.jsx)(`ul`,{className:`settings-directory-list`,"aria-label":`Visual and testing engines`,children:C.map(e=>(0,l.jsxs)(`li`,{className:`settings-directory-row`,children:[(0,l.jsx)(`span`,{className:`settings-directory-icon`,children:(0,l.jsx)(i,{name:e.icon})}),(0,l.jsxs)(`div`,{className:`settings-directory-copy`,children:[(0,l.jsxs)(`div`,{className:`settings-directory-name`,children:[(0,l.jsx)(`strong`,{children:e.name}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":e.tone,children:e.badge})]}),(0,l.jsx)(`p`,{title:e.detail,children:e.detail})]})]},e.id))}),a&&(0,l.jsxs)(`p`,{className:`field-help`,style:{marginTop:`14px`},children:[`Need deck or motion-video tools?`,` `,(0,l.jsx)(`button`,{type:`button`,className:`text-button`,onClick:a,children:`Open PowerPoint, video, and audio setup`})]}),(0,l.jsxs)(`details`,{className:`settings-quiet-disclosure connection-intake-disclosure`,children:[(0,l.jsx)(`summary`,{children:`Read-only local repo & design-token intake`}),(0,l.jsx)(`div`,{className:`settings-advanced-body`,children:(0,l.jsxs)(`div`,{className:`wb-connector-intake`,"aria-label":`Bounded read-only connector intake`,children:[(0,l.jsx)(`p`,{className:`field-help`,children:`Import a bounded snapshot from a local Git clone (never runs install/build scripts) or sanitize Figma JSON design tokens.`}),(0,l.jsxs)(`div`,{className:`wb-connector-intake-modes`,role:`group`,"aria-label":`Intake source type`,children:[(0,l.jsx)(`button`,{type:`button`,className:f===`github`?`button primary`:`button subtle`,disabled:t,onClick:()=>p(`github`),children:`Local Git repo`}),(0,l.jsx)(`button`,{type:`button`,className:f===`figma`?`button primary`:`button subtle`,disabled:t,onClick:()=>p(`figma`),children:`Design tokens JSON`})]}),(0,l.jsxs)(`div`,{className:`wb-connector-intake-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`connector-intake-source`,children:[f===`github`?`Local repository clone folder path`:`Design tokens JSON file or folder path`,(0,l.jsx)(`input`,{id:`connector-intake-source`,value:m,onChange:e=>h(e.target.value),placeholder:f===`github`?`C:\\path\\to\\local-repo-clone`:`C:\\path\\to\\tokens.json`})]}),f===`github`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`label`,{htmlFor:`connector-intake-target`,children:[`New folder name in work/`,(0,l.jsx)(`input`,{id:`connector-intake-target`,value:g,onChange:e=>_(e.target.value),placeholder:`repo-clean-snapshot`})]}),(0,l.jsxs)(`label`,{htmlFor:`connector-intake-ref`,children:[`Optional Git ref`,(0,l.jsx)(`input`,{id:`connector-intake-ref`,value:v,onChange:e=>y(e.target.value),placeholder:`HEAD`})]}),(0,l.jsxs)(`label`,{htmlFor:`connector-intake-rev`,children:[`Optional 40-hex commit SHA`,(0,l.jsx)(`input`,{id:`connector-intake-rev`,value:b,onChange:e=>x(e.target.value),placeholder:`Verified against rev-parse`})]})]})]}),(0,l.jsx)(`div`,{className:`wb-recovery-actions`,children:(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:t||!m.trim()||f===`github`&&!g.trim(),onClick:()=>void o(async()=>{let e=await s(`/api/connectors/intake`,{connectorId:f,kind:f===`figma`?`design-tokens`:`repo-snapshot`,sourcePath:m.trim(),targetName:g.trim(),ref:v.trim(),expectedRevision:b.trim(),approved:!0});await u(),d(e.kind===`design-tokens`?`Imported ${e.tokenCount??0} sanitized design tokens.`:`Imported clean ${e.adapter??`website`} snapshot to work/${e.projectName??g.trim()}.`)}),children:f===`figma`?`Import design tokens`:`Import clean repo snapshot`})}),r.length>0&&(0,l.jsx)(`ul`,{className:`wb-intake-history`,"aria-label":`Recent read-only intakes`,children:r.slice(0,5).map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`strong`,{children:e.connectorId}),` · `,e.sourceLabel,e.resolvedRevision?` @ ${e.resolvedRevision.slice(0,8)}`:``,` ·`,` `,e.kind===`design-tokens`?`${e.tokenCount??0} tokens`:`${e.copiedCount} files (${e.adapter})`]},e.intakeId))})]})})]})]})}var w=e({default:()=>D}),T={gemini:{label:`Google AI Studio`,icon:`google`,description:`Direct Google models`},openrouter:{label:`OpenRouter`,icon:`openrouter`,description:`Models across providers`},groq:{label:`Groq`,icon:`groq`,description:`Direct Groq models`}},E=[{id:`design-reference`,label:`Design`},{id:`code-deploy`,label:`Code & Hosting`},{id:`verify-security`,label:`Checks`},{id:`track-notify`,label:`Issues & Alerts`}];function D({project:e=``,initialTab:t=`overview`,initialTabRequestId:n=0,auth:a,clientSetupTask:d,showStarterSetup:f=!1,onStarterSelect:p,onDismissStarter:m,onClientConnected:h,onOpenAccount:g,onDone:_,onMedia:v}){let[y,b]=(0,c.useState)(()=>d||t===`mcp-clients`?`ai-clients`:t===`ai-models`?`api-keys`:`apps`),[x,S]=(0,c.useState)(()=>t===`visual-testing`?`verify-security`:`all`),[C,w]=(0,c.useState)(null),[D,ne]=(0,c.useState)(``),[O,k]=(0,c.useState)(!1),re=(0,c.useRef)(null),[A,j]=(0,c.useState)(null),[M,ie]=(0,c.useState)(`gemini`),[ae,oe]=(0,c.useState)(``),[se,ce]=(0,c.useState)(!1),[le,ue]=(0,c.useState)(!1),[N,de]=(0,c.useState)([]),[fe,pe]=(0,c.useState)(``),[me,P]=(0,c.useState)(``),[he,F]=(0,c.useState)(``),[I,ge]=(0,c.useState)(!1),[_e,ve]=(0,c.useState)(!1),[ye,be]=(0,c.useState)([]),[xe,Se]=(0,c.useState)(``),[Ce,we]=(0,c.useState)(``),[Te,Ee]=(0,c.useState)(!1),[De,L]=(0,c.useState)(``),[R,Oe]=(0,c.useState)(null),[ke,Ae]=(0,c.useState)(!1),[je,Me]=(0,c.useState)(``),[Ne,Pe]=(0,c.useState)(!0),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(!1),[z,B]=(0,c.useState)(``),[V,H]=(0,c.useState)(``),[U,ze]=(0,c.useState)(``),[Be,Ve]=(0,c.useState)(`/`),[He,Ue]=(0,c.useState)(!1),[W,We]=(0,c.useState)(null),[Ge,Ke]=(0,c.useState)(50),[qe,Je]=(0,c.useState)(null),[Ye,Xe]=(0,c.useState)(!1),[G,Ze]=(0,c.useState)(null),[Qe,$e]=(0,c.useState)(`#ui-alerts`),[et,tt]=(0,c.useState)(!0),nt=(0,c.useRef)(null),[K,rt]=(0,c.useState)(null),[it,at]=(0,c.useState)(null),[ot,st]=(0,c.useState)(``),[ct,lt]=(0,c.useState)(`mcp`),[ut,dt]=(0,c.useState)(`code-deploy`),[ft,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(``),[gt,_t]=(0,c.useState)(``),q=(0,c.useRef)(null),vt=(0,c.useRef)(null),yt=(0,c.useRef)(!0),bt=(0,c.useRef)(!1);(0,c.useEffect)(()=>{d||t===`mcp-clients`?(b(`ai-clients`),w(null),k(!1)):t===`ai-models`?(b(`api-keys`),w(null),k(!1)):t===`visual-testing`?(b(`apps`),w(null),S(`verify-security`),k(!1)):(b(`apps`),w(null),S(`all`),k(!1))},[d,t,n]),(0,c.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||document.querySelector(`dialog[open], .settings-page`))return;let t=!!e.target?.closest(`input, textarea, select, [contenteditable="true"]`);e.key===`Escape`&&y===`apps`?O?(e.preventDefault(),k(!1)):C?(e.preventDefault(),w(null)):D&&(e.preventDefault(),ne(``)):e.key!==`/`||t||e.ctrlKey||e.metaKey||e.altKey||y!==`apps`||C||O||(e.preventDefault(),re.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[O,D,C,y]),(0,c.useEffect)(()=>(yt.current=!0,xt().catch(e=>P(e.message)),()=>{yt.current=!1,q.current&&(q.current.value=``),vt.current&&(vt.current.value=``)}),[]);async function xt(){let[e,t,n,r]=await Promise.all([s(`/api/connections`),s(`/api/connectors/intakes`).catch(()=>({intakes:[]})),s(`/api/connectors/figma/sso`).catch(()=>null),s(`/api/connectors/slack/webhook`).catch(()=>null)]);if(yt.current){j(e),be(t.intakes??[]),Oe(n),Ze(r),r?.channelLabel&&$e(r.channelLabel),r&&!r.secureStorage.available&&tt(!1),n?.clientId&&Me(n.clientId),n&&!n.secureStorage.available&&Pe(!1);let i=e.externalConnectors?.find(e=>e.id===`figma`);i&&(Se(i.accountLabel??``),we(i.endpointUrl??``),Ee(i.status===`configured`&&!i.endpointUrl)),bt.current||(bt.current=!0,ie(e.preferences.providerId)),e.secureStorage.available||ce(!1)}}async function J(e){ge(!0),P(``),F(``);try{await e()}catch(e){yt.current&&P(e.message)}finally{yt.current&&ge(!1)}}async function St(e){let t=await s(`/api/connections/models?provider=${e}`),n=t.models.filter(e=>e.supportsTools);return de(n),pe(t.catalogueCheckedAt),ve(!0),n}async function Ct(){let e=q.current?.value??``,t=le,n=M;q.current&&(q.current.value=``),await J(async()=>{await s(`/api/connections`,{providerId:n,apiKey:e,label:ae,remember:se,fallback:t}),oe(``),await xt(),t||await St(n).catch(()=>{}),F(se?`API key saved in your system credential vault.`:`API key added for this Studio session.`)})}async function wt(e){if(!A||I)return;let t=A.preferences,n={...t,...e};j(e=>e&&{...e,preferences:n}),await J(async()=>{try{let e=await s(`/api/workspace/preferences`,n);j(t=>t&&{...t,preferences:e.preferences}),F(`Model settings saved.`)}catch(e){throw j(e=>e&&{...e,preferences:t}),e}})}async function Tt(){await J(async()=>{if(de([]),pe(``),!(await St(M)).length)throw Error(`No compatible tool models were returned for this key.`);F(`Models loaded. Pick a default model below.`)})}function Et(e){let t=N.find(t=>t.id===e);t&&wt({providerId:M,model:e,keyId:``,...M===`openrouter`?{openrouterFreeOnly:t.freeUse?.availability===`catalogue-zero`||(X?.openrouterFreeOnly??!1)}:{},maxOutputTokens:Math.min(X?.maxOutputTokens??16384,t.maxCompletionTokens??1e6)})}function Dt(e){e!==M&&(ie(e),de([]),pe(``),q.current&&(q.current.value=``))}function Y(e,t){let n=t?.enabled??e.status!==`configured`,r=t?.accountLabel??(n?e.accountLabel||e.id+`-workspace`:``),i=t?.endpointUrl??(n&&e.endpointUrl||``),a=t?.baseUrl??(n&&e.baseUrl||``);return J(async()=>{let t=await s(`/api/settings/connectors`,{id:e.id,enabled:n,accountLabel:r,endpointUrl:i,baseUrl:a});if(j(e=>e&&{...e,...t}),e.id===`figma`){let e=t.externalConnectors?.find(e=>e.id===`figma`);Se(e?.accountLabel??``),we(e?.endpointUrl??``)}F(n?`${e.name} saved.`:`${e.name} disconnected.`)})}async function Ot(){let e=nt.current?.value?.trim()??``;e?(nt.current&&(nt.current.value=``),await J(async()=>{let t=await s(`/api/connectors/slack/webhook`,{webhookUrl:e,channelLabel:Qe.trim()||`#ui-alerts`,remember:et});Ze(t.slack),j(e=>e&&{...e,externalConnectors:t.externalConnectors,customConnectors:t.customConnectors,authBoundaries:t.authBoundaries}),F(`Slack webhook saved for ${t.slack.channelLabel}.`)})):P(`Paste a Slack Incoming Webhook URL first.`)}async function kt(){await J(async()=>{let e=await s(`/api/connectors/slack/send`,{test:!0});F(`Test alert sent to Slack (${e.channelLabel}).`)})}async function At(){await J(async()=>{let e=await s(`/api/connectors/slack/webhook/remove`,{});Ze(e.slack),j(t=>t&&{...t,externalConnectors:e.externalConnectors,customConnectors:e.customConnectors,authBoundaries:e.authBoundaries}),F(`Slack webhook removed.`)})}async function jt(e){await J(async()=>{let t=(e??V)||z,n=t?`?repo=${encodeURIComponent(t)}`:``,r=await s(`/api/connectors/github-issues/status${n}`);rt(r),r.repo&&!z&&B(r.repo),F(r.valid?r.directCreateAvailable?`Ready for ${r.repo} — 1-click issue creation is enabled.`:`Ready for ${r.repo} — opens pre-filled issues in GitHub (sign in with GitHub for 1-click creation).`:`Enter a GitHub repo like owner/repo or https://github.com/owner/repo.`)})}async function Mt(e){await J(async()=>{let t=V.trim()||z.trim(),n=await s(`/api/connectors/github-issues/create`,{repo:t,title:`UI Design Studio — Test Connection Issue`,bodyText:`This test issue confirms UI Design Studio is connected to this repository for visual and accessibility checks.`,submitDirectly:e});at(n),n.created&&n.issueUrl?F(`Created GitHub issue #${n.issueNumber} in ${n.repo}.`):n.openInBrowserUrl&&(window.open(n.openInBrowserUrl,`_blank`,`noopener,noreferrer`),F(n.hint||`Opened pre-filled GitHub issue form for ${n.repo}.`))})}async function Nt(e){if(!V.trim()||!U.trim())P(`Enter both a Preview URL and a Live / Production URL to compare.`);else{Ue(!0),P(``),F(``);try{await s(`/api/settings/connectors`,{id:e.id,enabled:!0,accountLabel:z.trim()||e.name,endpointUrl:V.trim(),baseUrl:U.trim()});let t=await s(`/api/visual-diff/compare`,{mode:`urls`,url:V.trim(),baseUrl:U.trim(),routes:Be.trim()||`/`,render:!0});We(t),Ke(50),await xt(),F(`Compared preview vs live · Score ${t.delta.afterScore}/100 · ${t.visualDiff.maxMismatchPercentage}% max pixel shift.`)}catch(e){P(e.message)}finally{Ue(!1)}}}async function Pt(){await J(async()=>{let e=await s(`/api/settings/connectors/custom`,{name:ot.trim(),kind:ct,group:ut,endpointUrl:ft.trim(),command:mt.trim(),summary:gt.trim()});j(t=>t&&{...t,...e}),st(``),pt(``),ht(``),_t(``),k(!1),F(`Custom connector added locally (secrets redacted).`)})}async function Ft(e){await J(async()=>{let t=await s(`/api/settings/connectors/custom/${encodeURIComponent(e)}/remove`,{});j(e=>e&&{...e,...t}),w(null),F(`Custom connector removed.`)})}async function It(){L(``),Ie(``),await J(async()=>{let e=await s(`/api/connectors/figma/oauth/start`,{remember:Ne,openBrowser:!0});Ie(e.authorizeUrl),F(`Figma sign-in opened in your browser.`)})}async function Lt(){let e=je.trim();if(!e){L(`Enter your Figma OAuth Client ID before signing in.`);return}let t=vt.current?.value??``;vt.current&&(vt.current.value=``),L(``),await J(async()=>{await s(`/api/connectors/figma/oauth/config`,{clientId:e,clientSecret:t,remember:Ne});let n=await s(`/api/connectors/figma/oauth/start`,{remember:Ne,openBrowser:!0});Ie(n.authorizeUrl),Ae(!1),await xt(),F(`Figma sign-in opened in your browser.`)})}async function Rt(){await J(async()=>{await s(`/api/connectors/figma/sso/disconnect`,{}),Ie(``),await xt(),F(`Signed out of Figma.`)})}let zt=A?.keys.filter(e=>e.providerId===M)??[],X=A?.preferences,Bt=zt.some(e=>!e.fallback),Vt=!!X&&A?.keys.some(e=>e.providerId===X.providerId&&!e.fallback),Ht=!X||X.providerId===`openrouter`||(X.providerId===`gemini`?X.freeTierConfirmed:X.groqFreeTierConfirmed),Ut=!!X?.model&&!!Vt&&Ht,Z=(0,c.useMemo)(()=>new Map((A?.externalConnectors??[]).map(e=>[e.id,e])),[A?.externalConnectors]),Wt=(0,c.useMemo)(()=>new Map((A?.securityToolchain?.scanners??[]).map(e=>[e.id,e])),[A?.securityToolchain?.scanners]),Q=(0,c.useMemo)(()=>{let e=e=>Z.get(e)?.status===`configured`,t=a?.authenticated&&a.account?.provider===`github`,n=a?.authenticated&&a.account?.provider===`gitlab`,r=!!(R?.connected||e(`figma`)),i=Wt.get(`gitleaks`)?.status===`ready`,o=Wt.get(`osv-scanner`)?.status===`ready`,s=[{id:`figma`,name:`Figma`,group:`design-reference`,groupLabel:`Design`,icon:`figma`,summary:`Import colors, spacing, and design frames.`,statusLabel:R?.connected?`Connected · ${R.accountLabel}`:r?`Connected`:`Not set up`,statusTone:r?`ready`:`local-intake`,enabled:r,primaryAction:r?`Manage`:`Connect`,permissionsNote:`Read-only frame links, tokens, or Figma sign-in stored locally.`,docsNote:`Also used by the Match Figma Design workflow.`,keywords:`figma design frames tokens sso oauth`,externalId:`figma`},{id:`storybook`,name:`Storybook`,group:`design-reference`,groupLabel:`Design`,icon:`storybook`,summary:`Check UI components on your local preview URL.`,statusLabel:e(`storybook`)?`Connected`:`Ready`,statusTone:`ready`,enabled:!0,primaryAction:`Configure`,permissionsNote:`Reads your local preview URL only; never edits story files.`,docsNote:`Detected automatically when Storybook is installed in your project.`,keywords:`storybook stories components ui catalog`,externalId:`storybook`},{id:`reference-library`,name:`Reference Board`,group:`design-reference`,groupLabel:`Design`,icon:`image`,summary:`Attach local screenshots to guide visual updates.`,statusLabel:`Ready`,statusTone:`ready`,enabled:!0,primaryAction:`Open`,permissionsNote:`Saved on your machine only; never uploaded without your action.`,docsNote:`Used in Workspace → References.`,keywords:`references inspiration images moodboard local screenshots`,externalId:`reference-library`},{id:`github`,name:`GitHub`,group:`code-deploy`,groupLabel:`Code & Hosting`,icon:`github`,summary:`Open repos, compare branches, and post PR checks.`,statusLabel:t?`Connected · @${a?.account?.username}`:e(`github`)?`Connected`:`Not set up`,statusTone:t||e(`github`)?`ready`:`local-intake`,enabled:!!(t||e(`github`)),primaryAction:t?`Manage`:`Connect`,permissionsNote:`Read-only locally; never pushes code without your action.`,docsNote:`Works with Repositories, Branch Visual Diff, and GitHub Actions.`,keywords:`github git repo pr pull request actions ci branch`,externalId:`github`},{id:`gitlab`,name:`GitLab`,group:`code-deploy`,groupLabel:`Code & Hosting`,icon:`gitlab`,summary:`Open repos and check merge requests locally.`,statusLabel:n?`Connected · @${a?.account?.username}`:e(`gitlab`)?`Connected`:`Not set up`,statusTone:n||e(`gitlab`)?`ready`:`local-intake`,enabled:!!(n||e(`gitlab`)),primaryAction:n?`Manage`:`Connect`,permissionsNote:`Read-only locally; edits stay untouched until you click Apply.`,docsNote:`Works with GitLab.com and self-hosted GitLab.`,keywords:`gitlab git repo merge request ci`,externalId:`gitlab`},{id:`vercel`,name:`Vercel`,group:`code-deploy`,groupLabel:`Code & Hosting`,icon:`vercel`,summary:`Compare preview links against your live site.`,statusLabel:e(`vercel`)?`Connected`:`Not set up`,statusTone:e(`vercel`)?`ready`:`local-intake`,enabled:e(`vercel`),primaryAction:e(`vercel`)?`Edit URL`:`Connect`,permissionsNote:`Saves preview and live URLs only; no account tokens needed.`,docsNote:`CLI: ui-workflow diff --url <preview> --base-url <live>`,keywords:`vercel preview deploy url nextjs hosting diff`,externalId:`vercel`},{id:`cloudflare`,name:`Cloudflare Pages`,group:`code-deploy`,groupLabel:`Code & Hosting`,icon:`cloudflare`,summary:`Check preview deployments before you ship.`,statusLabel:e(`cloudflare`)?`Connected`:`Not set up`,statusTone:e(`cloudflare`)?`ready`:`local-intake`,enabled:e(`cloudflare`),primaryAction:e(`cloudflare`)?`Edit URL`:`Connect`,permissionsNote:`Saves HTTPS preview URLs only; no API tokens required.`,docsNote:`Works with *.pages.dev preview links.`,keywords:`cloudflare pages workers preview url deploy diff`,externalId:`cloudflare`},{id:`netlify`,name:`Netlify`,group:`code-deploy`,groupLabel:`Code & Hosting`,icon:`netlify`,summary:`Compare deploy previews side by side.`,statusLabel:e(`netlify`)?`Connected`:`Not set up`,statusTone:e(`netlify`)?`ready`:`local-intake`,enabled:e(`netlify`),primaryAction:e(`netlify`)?`Edit URL`:`Connect`,permissionsNote:`Saves HTTPS preview URLs only; no login needed.`,docsNote:`Works with deploy-preview-*.netlify.app URLs.`,keywords:`netlify deploy preview url hosting diff`,externalId:`netlify`},{id:`playwright-browser`,name:`Playwright`,group:`verify-security`,groupLabel:`Checks`,icon:`playwright`,summary:`Take desktop, mobile, and dark-mode screenshots.`,statusLabel:`Ready`,statusTone:`ready`,enabled:!0,primaryAction:`Details`,permissionsNote:`Runs locally using Playwright, Chrome, or Edge.`,docsNote:`Checks layout overflow, contrast, and broken scripts.`,keywords:`playwright chrome edge browser screenshot visual qa contrast`},{id:`gitleaks`,name:`Secret Scanner`,group:`verify-security`,groupLabel:`Checks`,icon:`gitleaks`,summary:`Catch leaked keys and tokens before you push.`,statusLabel:i?`Ready`:`Built-in`,statusTone:`ready`,enabled:!0,primaryAction:`Details`,permissionsNote:`Read-only local scan; secrets never leave your machine.`,docsNote:`Powered by built-in rules plus optional Gitleaks CLI.`,keywords:`gitleaks secrets security scan api keys tokens`},{id:`osv-scanner`,name:`Package Scanner`,group:`verify-security`,groupLabel:`Checks`,icon:`osv`,summary:`Check npm packages for known security bugs.`,statusLabel:o?`Ready`:`Built-in`,statusTone:`ready`,enabled:!0,primaryAction:`Details`,permissionsNote:`Reads lockfiles only; never runs package scripts.`,docsNote:`Powered by built-in checks plus optional Google OSV-Scanner.`,keywords:`osv scanner vulnerability dependency lockfile npm security`},{id:`linear`,name:`Linear`,group:`track-notify`,groupLabel:`Issues & Alerts`,icon:`linear`,summary:`Link your workspace to track UI bugs.`,statusLabel:e(`linear`)?`Connected`:`Not set up`,statusTone:e(`linear`)?`ready`:`local-intake`,enabled:e(`linear`),primaryAction:e(`linear`)?`Manage`:`Connect`,permissionsNote:`Stores only your workspace name and link locally.`,docsNote:`Shows up in workflow delivery summaries.`,keywords:`linear issues tracker tickets notify triage`,externalId:`linear`},{id:`github-issues`,name:`GitHub Issues`,group:`track-notify`,groupLabel:`Issues & Alerts`,icon:`github`,summary:`Send UI findings straight to your Issues board.`,statusLabel:e(`github-issues`)?`Connected`:`Not set up`,statusTone:e(`github-issues`)?`ready`:`local-intake`,enabled:e(`github-issues`),primaryAction:e(`github-issues`)?`Manage`:`Connect`,permissionsNote:`Never opens public issues without your confirmation.`,docsNote:`Pairs with PR summaries and audit checklists.`,keywords:`github issues bugs tracking triage alerts`,externalId:`github-issues`},{id:`slack`,name:`Slack`,group:`track-notify`,groupLabel:`Issues & Alerts`,icon:`slack`,summary:`Post visual check summaries to a team channel.`,statusLabel:G?.configured?`Connected · ${G.channelLabel}`:e(`slack`)?`Connected`:`Not set up`,statusTone:G?.configured||e(`slack`)?`ready`:`local-intake`,enabled:!!(G?.configured||e(`slack`)),primaryAction:G?.configured||e(`slack`)?`Manage`:`Connect`,permissionsNote:`Webhook URL is stored in your OS vault or session memory — never in Git.`,docsNote:`Send test alerts here or post findings directly from Workflow Studio.`,keywords:`slack webhook alerts notify channel messages`,externalId:`slack`}],c=(A?.customConnectors??[]).map(e=>({id:e.id,name:e.name,group:e.group,groupLabel:E.find(t=>t.id===e.group)?.label??`Custom`,icon:e.kind===`webhook`?`external`:`mcp`,summary:e.summary||`Custom local ${e.kind===`webhook`?`webhook`:`tool`}.`,statusLabel:e.enabled?`Connected`:`Paused`,statusTone:e.enabled?`ready`:`local-intake`,enabled:e.enabled,primaryAction:`Manage`,permissionsNote:`Saved locally in Studio; secret-like tokens are blocked.`,docsNote:e.endpointUrl||e.command||`Custom local integration`,keywords:`custom ${e.name} ${e.kind} ${e.summary}`.toLowerCase(),custom:e}));return[...s,...c]},[a,Z,R,Wt,A?.customConnectors]),Gt=(0,c.useMemo)(()=>Q.filter(e=>e.enabled).length,[Q]),Kt=(0,c.useMemo)(()=>{let e=D.trim().toLowerCase();return Q.filter(t=>e&&!`${t.name} ${t.summary} ${t.groupLabel} ${t.keywords}`.toLowerCase().includes(e)?!1:x===`all`?!0:x===`enabled`?t.enabled:t.group===x)},[Q,D,x]),qt=/\b(cursor|claude|codex|antigravity|opencode|mcp|ide|editor)\b/i.test(D),Jt=/\b(api|key|gemini|google|openai|openrouter|groq|model|llm)\b/i.test(D),$=(0,c.useMemo)(()=>Q.find(e=>e.id===C)??null,[Q,C]);function Yt(t){if(w(t.id),k(!1),P(``),F(``),We(null),at(null),t.externalId){let e=Z.get(t.externalId);B(e?.accountLabel??``),H(e?.endpointUrl??``),ze(e?.baseUrl??``)}if(t.id===`github-issues`||t.id===`vercel`){let n=e?`?project=${encodeURIComponent(e)}`:``;s(`/api/project/autodetect${n}`).then(e=>{if(Je(e),t.id===`github-issues`&&e?.github?.fullName){let t=Z.get(`github-issues`);!t?.accountLabel&&!t?.endpointUrl&&(B(e.github.fullName),H(e.github.webUrl))}}).catch(()=>{})}if(t.id===`github-issues`){let e=Z.get(`github-issues`),t=e?.endpointUrl||e?.accountLabel||``;s(`/api/connectors/github-issues/status${t?`?repo=${encodeURIComponent(t)}`:``}`).then(t=>{rt(t),t.repo&&!e?.accountLabel&&!e?.endpointUrl&&(B(t.repo),H(`https://github.com/${t.repo}`))}).catch(()=>{})}}let Xt=A?.externalConnectors?.find(e=>e.id===`figma`),Zt=Xt?.status===`configured`,Qt=[`apps`,`ai-clients`,`api-keys`];function $t(e){b(e),w(null),k(!1),P(``),F(``)}return(0,l.jsxs)(`div`,{className:`wb-connections-root`,children:[(0,l.jsxs)(`div`,{className:`settings-intro`,children:[(0,l.jsx)(`h2`,{className:`page-reveal page-reveal--title`,children:`Connections`}),(0,l.jsx)(`p`,{className:`page-reveal page-reveal--support`,children:`Link your design tools, hosting previews, AI coding editors, or optional model API keys.`})]}),(0,l.jsxs)(`div`,{className:`wb-conn-tabs`,role:`tablist`,"aria-label":`Connection sections`,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Qt.indexOf(y),n=e.key===`Home`?0:e.key===`End`?Qt.length-1:(t+(e.key===`ArrowRight`?1:-1)+Qt.length)%Qt.length;$t(Qt[n]),e.currentTarget.querySelectorAll(`[role="tab"]`)[n]?.focus()},children:[(0,l.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":y===`apps`,tabIndex:y===`apps`?0:-1,className:`wb-conn-tab`,onClick:()=>$t(`apps`),children:[(0,l.jsx)(i,{name:`component`}),(0,l.jsx)(`span`,{children:`Apps & Tools`}),(0,l.jsx)(`span`,{className:`wb-conn-tab-badge`,children:Gt})]}),(0,l.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":y===`ai-clients`,tabIndex:y===`ai-clients`?0:-1,className:`wb-conn-tab`,onClick:()=>$t(`ai-clients`),children:[(0,l.jsx)(i,{name:`mcp`}),(0,l.jsx)(`span`,{children:`AI Clients`})]}),(0,l.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":y===`api-keys`,tabIndex:y===`api-keys`?0:-1,className:`wb-conn-tab`,onClick:()=>$t(`api-keys`),children:[(0,l.jsx)(i,{name:`google`}),(0,l.jsx)(`span`,{children:`API Keys`}),Ut&&(0,l.jsx)(`span`,{className:`wb-conn-tab-badge`,children:`Ready`})]})]}),me&&(0,l.jsx)(`p`,{className:`error-box`,role:`alert`,children:me}),he&&(0,l.jsx)(`p`,{className:`connection-success`,role:`status`,children:he}),y===`ai-clients`?(0,l.jsx)(`div`,{className:`wb-conn-standalone page-reveal page-reveal--content`,children:(0,l.jsx)(ee,{task:d,onClientConnected:h})}):y===`api-keys`?(0,l.jsx)(`div`,{className:`wb-conn-standalone page-reveal page-reveal--content`,children:(0,l.jsxs)(`div`,{className:`wb-conn-panel`,children:[(0,l.jsxs)(`div`,{className:`connection-setup-header`,children:[(0,l.jsx)(`h3`,{children:`Model API Keys (Optional)`}),(0,l.jsx)(`div`,{className:`field-help`,role:`status`,children:A&&(0,l.jsxs)(l.Fragment,{children:[Ut&&X?`Ready · ${T[X.providerId].label} · ${X.model}`:!Bt&&!Vt?`Optional — only needed if you want Studio itself to write code edits.`:X?.model?`Confirm your provider’s free-tier setting below.`:`API key saved. Pick a default model below.`,Ut&&_&&(0,l.jsx)(`button`,{type:`button`,className:`text-button`,onClick:_,children:`Return to workspace`})]})})]}),(0,l.jsx)(`div`,{className:`connection-providers`,role:`group`,"aria-label":`Model provider`,children:[`gemini`,`openrouter`,`groq`].map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`button subtle`,"aria-pressed":M===e,"aria-label":T[e].label,disabled:I,onClick:()=>Dt(e),children:[(0,l.jsx)(i,{name:T[e].icon}),(0,l.jsxs)(`span`,{className:`connection-provider-copy`,children:[(0,l.jsx)(`strong`,{children:T[e].label}),(0,l.jsx)(`small`,{"aria-hidden":`true`,children:T[e].description})]}),M===e&&(0,l.jsx)(i,{name:`check`,className:`connection-provider-selected`})]},e))}),zt.length>0&&(0,l.jsx)(`div`,{className:`saved-connections`,children:zt.map(e=>(0,l.jsxs)(`div`,{className:`saved-connection`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`strong`,{children:[(0,l.jsx)(`span`,{className:`saved-connection-dot`,"data-role":e.fallback?`backup`:`primary`,"aria-hidden":`true`}),e.label]}),(0,l.jsxs)(`small`,{children:[e.fallback?`Backup`:`Primary`,` ·`,` `,e.remember?`System vault`:`This session`]})]}),(0,l.jsxs)(`button`,{type:`button`,className:`text-button`,disabled:I,onClick:()=>void J(async()=>{await s(`/api/connections/${e.id}/remove`,{}),await xt(),F(`API key removed.`)}),children:[`Remove`,(0,l.jsxs)(`span`,{className:`sr-only`,children:[` `,e.label]})]})]},e.id))}),(0,l.jsxs)(`section`,{className:`connection-form`,"aria-label":`API key setup`,children:[(0,l.jsx)(`h4`,{children:M===`gemini`?`Google Gemini API`:`${T[M].label} API`}),(0,l.jsxs)(`div`,{className:`connection-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`connection-label`,children:[`Connection name`,(0,l.jsx)(`input`,{id:`connection-label`,name:`connection-label`,value:ae,autoComplete:`off`,placeholder:`e.g. personal dev key…`,onChange:e=>oe(e.target.value)})]}),(0,l.jsxs)(`label`,{htmlFor:`connection-secret`,children:[`API key`,(0,l.jsx)(`input`,{ref:q,id:`connection-secret`,name:`connection-secret`,type:`password`,autoComplete:`new-password`,spellCheck:!1,placeholder:`Paste your key here…`})]})]}),(0,l.jsxs)(`div`,{className:`connection-form-actions`,children:[(0,l.jsxs)(`details`,{className:`connection-key-options`,children:[(0,l.jsxs)(`summary`,{children:[(0,l.jsx)(`span`,{children:`Key storage & backup options`}),(0,l.jsx)(i,{name:`chevron`})]}),(0,l.jsxs)(`div`,{className:`connection-key-options-body`,children:[(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{name:`backup-key`,type:`checkbox`,checked:le,onChange:e=>ue(e.target.checked)}),(0,l.jsx)(`span`,{children:`Add as a backup key`})]}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{name:`remember-key`,type:`checkbox`,checked:se,disabled:!A?.secureStorage.available,onChange:e=>ce(e.target.checked)}),(0,l.jsxs)(`span`,{children:[`Remember in system credential vault`,(0,l.jsx)(`small`,{children:A?.secureStorage.available?`Protected by your OS account.`:`Session-only on this machine.`})]})]})]})]}),(0,l.jsx)(`button`,{className:`button primary`,type:`button`,disabled:I,onClick:Ct,children:I?`Saving…`:`Add connection`})]})]}),(0,l.jsxs)(`section`,{className:`settings-section`,children:[(0,l.jsx)(`h4`,{children:`Default model for Auto mode`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:!zt.some(e=>!e.fallback)||I,onClick:Tt,children:I?`Loading…`:`Load available models`}),(0,l.jsxs)(`label`,{htmlFor:`default-model`,children:[`Default model`,(0,l.jsx)(r,{id:`default-model`,label:`Default model`,searchable:!0,disabled:!N.length||I,value:X?.providerId===M?X.model:``,onChange:Et,options:[{value:``,label:N.length?`Choose a model`:`Load models to choose…`,disabled:!0},...X?.providerId===M&&X.model&&!N.some(e=>e.id===X.model)?[{value:X.model,label:X.model}]:[],...N.map(e=>({value:e.id,label:e.name,description:`${e.id}${M===`openrouter`?e.freeUse?.availability===`catalogue-zero`?` · Zero catalogue price`:` · Metered or unknown price`:` · Account quota required`}`,icon:(0,l.jsx)(i,{name:T[M].icon})}))]})]}),fe&&N.some(e=>e.freeUse?.recommended)&&(0,l.jsxs)(`section`,{className:`free-model-guide`,"aria-label":`Recommended for free use`,children:[(0,l.jsx)(`h4`,{children:`Recommended for free use`}),N.filter(e=>e.freeUse?.recommended).map(e=>(0,l.jsxs)(`div`,{className:`free-model-row`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:e.name}),(0,l.jsx)(`small`,{children:e.freeUse.observation.summary})]}),(0,l.jsxs)(`button`,{type:`button`,className:`button subtle`,disabled:I,onClick:()=>Et(e.id),children:[`Choose `,e.name]})]},e.id))]}),M===`gemini`&&(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{id:`google-free-tier`,type:`checkbox`,disabled:I,checked:X?.freeTierConfirmed??!1,onChange:e=>void wt({freeTierConfirmed:e.target.checked})}),(0,l.jsx)(`span`,{children:`I confirmed this Google project has free-tier quota and billing is disabled.`})]}),M===`groq`&&(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:I||!X,checked:X?.groqFreeTierConfirmed??!1,onChange:e=>void wt({groqFreeTierConfirmed:e.target.checked})}),(0,l.jsx)(`span`,{children:`I confirmed this Groq account uses the Free plan.`})]}),M===`openrouter`&&(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:I||!X,checked:X?.openrouterFreeOnly??!1,onChange:e=>void wt({openrouterFreeOnly:e.target.checked})}),(0,l.jsx)(`span`,{children:`Only zero-priced OpenRouter routes`})]}),(0,l.jsxs)(`details`,{className:`settings-advanced-disclosure`,open:_e,onToggle:e=>ve(e.currentTarget.open),children:[(0,l.jsxs)(`summary`,{children:[(0,l.jsx)(i,{name:`settings`}),(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`strong`,{children:`Run limits & caps`}),(0,l.jsxs)(`small`,{children:[X?.maxModelTurns??64,` turns · `,X?.timeoutMinutes??45,` min limit`]})]}),(0,l.jsx)(i,{name:`chevron`})]}),(0,l.jsxs)(`div`,{className:`settings-advanced-body`,children:[(0,l.jsxs)(`div`,{className:`two-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`connection-budget`,hidden:M!==`openrouter`,children:[`OpenRouter run budget (USD)`,(0,l.jsx)(`input`,{id:`connection-budget`,type:`number`,min:`0.000001`,max:`10000`,step:`any`,disabled:I||!X,defaultValue:X?.budgetUsd??2,onBlur:e=>{Number(e.target.value)!==X?.budgetUsd&&wt({budgetUsd:Number(e.target.value)})}},X?.budgetUsd)]}),(0,l.jsxs)(`label`,{htmlFor:`connection-output`,children:[`Output limit per turn`,(0,l.jsx)(`input`,{id:`connection-output`,type:`number`,min:`256`,max:`1000000`,step:`1`,disabled:I||!X,defaultValue:X?.maxOutputTokens??16384,onBlur:e=>{Number(e.target.value)!==X?.maxOutputTokens&&wt({maxOutputTokens:Number(e.target.value)})}},X?.maxOutputTokens)]})]}),(0,l.jsx)(`div`,{className:`two-fields`,children:[[`maxModelTurns`,`Model turns`,64,1,1e3],[`maxTools`,`Auto tool calls per run`,256,1,1e4],[`maxToolCallsPerTurn`,`Tool calls per turn`,16,1,128],[`maxDraftChecks`,`Draft checks`,12,1,1e3],[`timeoutMinutes`,`Auto run time (minutes)`,45,1,1440],[`mcpTimeoutMinutes`,`MCP access window (minutes)`,180,1,1440],[`mcpMaxTools`,`Live edit tool allowance`,512,1,1e4],[`maxTotalTokens`,`Total tokens (0 = no cap)`,0,0,1e8]].map(([e,t,n,r,i])=>(0,l.jsxs)(`label`,{htmlFor:`limit-${e}`,children:[t,(0,l.jsx)(`input`,{id:`limit-${e}`,name:e,type:`number`,min:r,max:i,step:`1`,disabled:I||!X,defaultValue:X?.[e]??n,onBlur:t=>{Number(t.target.value)!==X?.[e]&&wt({[e]:Number(t.target.value)})}},X?.[e])]},e))})]})]}),(0,l.jsxs)(`details`,{className:`settings-quiet-disclosure`,children:[(0,l.jsx)(`summary`,{children:`Planned: Managed AI credits (Pro / Team)`}),(0,l.jsx)(`p`,{className:`field-help`,children:`Local audits, Branch Visual Diff, AI Clients, and your own API keys stay free on your machine. An optional Managed AI credits option is planned later so teams can skip separate API keys.`})]})]})]})}):(0,l.jsxs)(`div`,{className:`wb-conn-dir page-reveal page-reveal--content`,children:[(0,l.jsxs)(`aside`,{className:`wb-conn-sidebar`,"aria-label":`Connector categories`,children:[(0,l.jsxs)(`div`,{className:`wb-conn-nav-group`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`wb-conn-nav-btn`,"aria-current":!$&&!O&&x===`all`?`true`:void 0,onClick:()=>{S(`all`),w(null),k(!1)},children:[(0,l.jsx)(`span`,{children:`All apps`}),(0,l.jsx)(`span`,{className:`wb-conn-nav-count`,children:Q.length})]}),(0,l.jsxs)(`button`,{type:`button`,className:`wb-conn-nav-btn`,"aria-current":!$&&!O&&x===`enabled`?`true`:void 0,onClick:()=>{S(`enabled`),w(null),k(!1)},children:[(0,l.jsx)(`span`,{children:`Connected`}),(0,l.jsx)(`span`,{className:`wb-conn-nav-count`,children:Gt})]})]}),(0,l.jsxs)(`div`,{className:`wb-conn-nav-group`,children:[(0,l.jsx)(`span`,{className:`wb-conn-nav-label`,children:`Categories`}),E.map(e=>{let t=Q.filter(t=>t.group===e.id).length;return(0,l.jsxs)(`button`,{type:`button`,className:`wb-conn-nav-btn`,"aria-current":!$&&!O&&x===e.id?`true`:void 0,onClick:()=>{S(e.id),w(null),k(!1)},children:[(0,l.jsx)(`span`,{children:e.label}),(0,l.jsx)(`span`,{className:`wb-conn-nav-count`,children:t})]},e.id)})]}),(0,l.jsx)(`div`,{className:`wb-conn-add-custom`,children:(0,l.jsxs)(`button`,{type:`button`,className:`button subtle`,"aria-pressed":O,onClick:()=>{k(e=>!e),w(null)},children:[(0,l.jsx)(i,{name:`plus`}),`Add custom`]})})]}),(0,l.jsx)(`div`,{className:`wb-conn-main`,children:O?(0,l.jsxs)(`section`,{className:`wb-conn-custom-form`,"aria-label":`Add custom connector`,children:[(0,l.jsxs)(`div`,{className:`wb-conn-detail-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h3`,{children:`Add custom local connector`}),(0,l.jsx)(`p`,{className:`field-help`,children:`Save a local MCP server entry or HTTPS/localhost webhook URL. Secret-like tokens are blocked automatically.`})]}),(0,l.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>k(!1),children:`Cancel`})]}),(0,l.jsxs)(`div`,{className:`wb-conn-custom-grid`,children:[(0,l.jsxs)(`label`,{htmlFor:`custom-conn-name`,children:[`Connector name`,(0,l.jsx)(`input`,{id:`custom-conn-name`,type:`text`,value:ot,onChange:e=>st(e.target.value),placeholder:`e.g. Local Design Token MCP`})]}),(0,l.jsxs)(`label`,{htmlFor:`custom-conn-kind`,children:[`Type`,(0,l.jsxs)(`select`,{id:`custom-conn-kind`,value:ct,onChange:e=>lt(e.target.value===`webhook`?`webhook`:`mcp`),children:[(0,l.jsx)(`option`,{value:`mcp`,children:`Local MCP Server`}),(0,l.jsx)(`option`,{value:`webhook`,children:`Webhook Endpoint`})]})]}),(0,l.jsxs)(`label`,{htmlFor:`custom-conn-group`,children:[`Outcome group`,(0,l.jsx)(`select`,{id:`custom-conn-group`,value:ut,onChange:e=>dt(e.target.value),children:E.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,l.jsxs)(`label`,{htmlFor:`custom-conn-url`,children:[`Endpoint URL (HTTPS or localhost)`,(0,l.jsx)(`input`,{id:`custom-conn-url`,type:`url`,value:ft,onChange:e=>pt(e.target.value),placeholder:`https://example.com/mcp or http://127.0.0.1:4100`})]}),ct===`mcp`&&(0,l.jsxs)(`label`,{htmlFor:`custom-conn-command`,children:[`Or stdio command label (optional)`,(0,l.jsx)(`input`,{id:`custom-conn-command`,type:`text`,value:mt,onChange:e=>ht(e.target.value),placeholder:`npx my-mcp-server`})]}),(0,l.jsxs)(`label`,{htmlFor:`custom-conn-summary`,children:[`Short description (optional)`,(0,l.jsx)(`input`,{id:`custom-conn-summary`,type:`text`,value:gt,onChange:e=>_t(e.target.value),placeholder:`What this connector helps you check or automate`})]})]}),(0,l.jsx)(`div`,{className:`wb-recovery-actions`,children:(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:I||!ot.trim()||!ft.trim()&&!mt.trim(),onClick:()=>void Pt(),children:I?`Saving…`:`Save custom connector`})})]}):$?(0,l.jsxs)(`section`,{className:`wb-conn-detail`,"aria-label":`${$.name} connector details`,children:[(0,l.jsx)(`div`,{children:(0,l.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>w(null),children:`← Back to directory`})}),(0,l.jsxs)(`div`,{className:`wb-conn-detail-head`,children:[(0,l.jsxs)(`div`,{className:`wb-conn-detail-id`,children:[(0,l.jsx)(`span`,{className:`wb-conn-card-icon`,children:(0,l.jsx)(i,{name:$.icon})}),(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`settings-directory-name`,children:[(0,l.jsx)(`h3`,{children:$.name}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":$.statusTone,children:$.statusLabel})]}),(0,l.jsx)(`p`,{children:$.summary})]})]}),(0,l.jsxs)(`div`,{className:`wb-conn-detail-actions`,children:[($.id===`github`||$.id===`gitlab`)&&g&&(0,l.jsx)(`button`,{type:`button`,className:`button primary`,onClick:g,children:a?.authenticated?`Manage account`:`Sign in with ${$.name}`}),$.custom&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I,onClick:()=>void Ft($.custom.id),children:`Remove custom connector`})]})]}),$.id===`figma`&&Xt&&(0,l.jsxs)(`div`,{className:`settings-connector-panel wb-figma-mcp-box`,children:[(0,l.jsxs)(`div`,{className:`wb-figma-sso-card`,children:[(0,l.jsxs)(`div`,{className:`wb-figma-sso-head`,children:[(0,l.jsxs)(`div`,{className:`wb-figma-sso-title`,children:[(0,l.jsx)(i,{name:`figma`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Figma Sign-In`}),(0,l.jsx)(`small`,{children:R?.connected?`Signed in as ${R.accountLabel}${R.email?` (${R.email})`:``}`:`Connect your Figma account directly — saved securely on your machine.`})]})]}),R?.connected?(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I,onClick:()=>void Rt(),children:`Sign out`}):(0,l.jsxs)(`button`,{type:`button`,className:`button primary wb-figma-sso-btn`,disabled:I,onClick:()=>{L(``),R?.oauthConfigured?It():Ae(e=>!e)},children:[(0,l.jsx)(i,{name:`figma`}),(0,l.jsx)(`span`,{children:`Sign in with Figma`})]})]}),ke&&!R?.connected&&(0,l.jsxs)(`div`,{className:`wb-account-oauth-setup`,children:[R?.redirectUri&&(0,l.jsxs)(`div`,{className:`wb-oauth-redirect-row`,children:[(0,l.jsx)(`code`,{translate:`no`,children:R.redirectUri}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{navigator.clipboard?.writeText(R.redirectUri).then(()=>{Re(!0),window.setTimeout(()=>Re(!1),1600)}).catch(()=>{})},children:Le?`Copied`:`Copy URI`})]}),(0,l.jsxs)(`div`,{className:`settings-connector-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`figma-oauth-client-id`,children:[`Figma OAuth Client ID`,(0,l.jsx)(`input`,{id:`figma-oauth-client-id`,type:`text`,value:je,disabled:I,onChange:e=>Me(e.target.value),placeholder:`Paste Figma OAuth Client ID`})]}),(0,l.jsxs)(`label`,{htmlFor:`figma-oauth-client-secret`,children:[`Client Secret (optional)`,(0,l.jsx)(`input`,{ref:vt,id:`figma-oauth-client-secret`,type:`password`,autoComplete:`new-password`,disabled:I,placeholder:`Stored in OS vault or memory only`})]})]}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:I||!je.trim(),onClick:()=>void Lt(),children:`Save & sign in with Figma`})]}),Fe&&(0,l.jsx)(`div`,{className:`wb-account-oauth-link`,children:(0,l.jsxs)(`a`,{className:`button subtle`,href:Fe,target:`_blank`,rel:`noopener noreferrer`,children:[`Open Figma sign-in page `,(0,l.jsx)(i,{name:`external`})]})})]}),(0,l.jsx)(u,{text:`https://mcp.figma.com/mcp`,language:`text`,label:`Official Figma MCP server URL`,copyLabel:`Copy Figma MCP URL`}),(0,l.jsxs)(`div`,{className:`settings-connector-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`figma-account-label`,children:[`Workspace or file label (optional)`,(0,l.jsx)(`input`,{id:`figma-account-label`,value:xe,onChange:e=>{Se(e.target.value),L(``)},placeholder:`Design system`})]}),(0,l.jsxs)(`label`,{htmlFor:`figma-endpoint-url`,children:[`Figma frame or file URL`,(0,l.jsx)(`input`,{id:`figma-endpoint-url`,type:`url`,value:Ce,onChange:e=>{we(e.target.value),L(``)},placeholder:`https://www.figma.com/design/...`})]})]}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{id:`figma-client-connected`,type:`checkbox`,checked:Te,onChange:e=>{Ee(e.target.checked),L(``)}}),(0,l.jsxs)(`span`,{children:[`I already connected `,(0,l.jsx)(`code`,{children:`https://mcp.figma.com/mcp`}),` in my AI client`]})]}),De&&(0,l.jsx)(`p`,{className:`error-box`,role:`alert`,children:De}),(0,l.jsxs)(`div`,{className:`wb-recovery-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:I,onClick:()=>{let e=Ce.trim();if(!e&&!Te)L(`Enter a valid https:// Figma URL or check the AI client box above.`);else{if(e)try{if(new URL(e).protocol!==`https:`){L(`Figma URL must start with https://.`);return}}catch{L(`Enter a valid https:// Figma URL.`);return}L(``),Y(Xt,{enabled:!0,accountLabel:xe.trim()||`figma-workspace`,endpointUrl:e})}},children:`Save Figma link`}),Zt&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I,onClick:()=>{L(``),Ee(!1),Y(Xt,{enabled:!1})},children:`Clear link`})]})]}),$.id===`slack`&&(0,l.jsxs)(`div`,{className:`settings-connector-panel`,children:[(0,l.jsxs)(`div`,{className:`settings-connector-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`slack-channel-label`,children:[`Channel name`,(0,l.jsx)(`input`,{id:`slack-channel-label`,value:Qe,onChange:e=>$e(e.target.value),placeholder:`#ui-alerts`})]}),(0,l.jsxs)(`label`,{htmlFor:`slack-webhook-url`,children:[`Slack Incoming Webhook URL`,(0,l.jsx)(`input`,{ref:nt,id:`slack-webhook-url`,type:`password`,autoComplete:`new-password`,spellCheck:!1,placeholder:G?.configured?`Saved securely — paste a new URL to replace`:`https://hooks.slack.com/services/T.../B.../...`})]})]}),(0,l.jsxs)(`label`,{className:`check-row`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:et,disabled:!G?.secureStorage.available,onChange:e=>tt(e.target.checked)}),(0,l.jsx)(`span`,{children:`Remember webhook in system credential vault (never written to plain JSON or Git)`})]}),(0,l.jsxs)(`div`,{className:`wb-recovery-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:I,onClick:()=>void Ot(),children:I?`Saving…`:`Save Slack webhook`}),G?.configured&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I,onClick:()=>void kt(),children:`Send test alert`}),(0,l.jsx)(`button`,{type:`button`,className:`text-button`,disabled:I,onClick:()=>void At(),children:`Disconnect`})]})]})]}),$.id===`github-issues`&&Z.get(`github-issues`)&&(0,l.jsxs)(`div`,{className:`settings-connector-panel`,children:[(0,l.jsx)(`div`,{className:`settings-connector-fields`,children:(0,l.jsxs)(`label`,{htmlFor:`gh-issues-repo`,children:[`GitHub repository (owner/repo or URL)`,(0,l.jsx)(`input`,{id:`gh-issues-repo`,value:V||z,onChange:e=>{H(e.target.value),B(e.target.value)},placeholder:`owner/repo or https://github.com/owner/repo`})]})}),K&&(0,l.jsx)(`p`,{className:`field-help`,children:K.valid?K.directCreateAvailable?`Connected to ${K.repo} · 1-click GitHub API issue creation ready.`:`Repository ${K.repo} ready · opens pre-filled issues in your browser (sign in with GitHub for 1-click API creation).`:`Enter a GitHub repository name like acme/web-app.`}),(0,l.jsxs)(`div`,{className:`wb-recovery-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:I||!(V.trim()||z.trim()),onClick:()=>{let e=Z.get(`github-issues`);if(!e)return;let t=(V||z).trim(),n=/^https?:\/\//i.test(t)?t:`https://github.com/${t.replace(/^\/+/,``)}`;Y(e,{enabled:!0,accountLabel:t.replace(/^https?:\/\/github\.com\//i,``),endpointUrl:n}).then(()=>jt(n))},children:`Save repository`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I||!(V.trim()||z.trim()),onClick:()=>void Mt(!!K?.directCreateAvailable),children:K?.directCreateAvailable?`Create test issue`:`Open test issue in GitHub`}),Z.get(`github-issues`)?.status===`configured`&&(0,l.jsx)(`button`,{type:`button`,className:`text-button`,disabled:I,onClick:()=>{let e=Z.get(`github-issues`);e&&(B(``),H(``),rt(null),Y(e,{enabled:!1}))},children:`Disconnect`})]}),it?.issueUrl&&(0,l.jsxs)(`p`,{className:`field-help`,children:[`Created issue #`,it.issueNumber,`:`,` `,(0,l.jsx)(`a`,{href:it.issueUrl,target:`_blank`,rel:`noopener noreferrer`,children:it.issueUrl})]})]}),[`vercel`,`cloudflare`,`netlify`].includes($.id)&&Z.get($.id)&&(0,l.jsxs)(`div`,{className:`settings-connector-panel`,children:[(0,l.jsxs)(`div`,{className:`settings-connector-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`preview-after-url`,children:[`Preview URL (PR / branch deployment)`,(0,l.jsx)(`input`,{id:`preview-after-url`,type:`url`,value:V,onChange:e=>H(e.target.value),placeholder:$.id===`vercel`?`https://my-app-git-feature.vercel.app`:$.id===`cloudflare`?`https://branch.my-app.pages.dev`:`https://deploy-preview-42--my-app.netlify.app`})]}),(0,l.jsxs)(`label`,{htmlFor:`preview-base-url`,children:[`Live / Production URL (to compare against)`,(0,l.jsx)(`input`,{id:`preview-base-url`,type:`url`,value:U,onChange:e=>ze(e.target.value),placeholder:$.id===`vercel`?`https://my-app.vercel.app`:$.id===`cloudflare`?`https://my-app.pages.dev`:`https://my-app.netlify.app`})]}),(0,l.jsxs)(`label`,{htmlFor:`preview-routes`,children:[`Pages to compare`,(0,l.jsx)(`input`,{id:`preview-routes`,type:`text`,value:Be,onChange:e=>Ve(e.target.value),placeholder:`/, /pricing`})]})]}),$.id===`vercel`&&(qe?.vercel?.linked||qe?.vercel?.cliInstalled)&&(0,l.jsx)(`p`,{className:`field-help`,children:qe.vercel.projectName?`Detected linked Vercel project: ${qe.vercel.projectName}.`:`Vercel CLI detected on this machine.`}),(0,l.jsxs)(`div`,{className:`wb-recovery-actions`,children:[$.id===`vercel`&&qe?.vercel?.cliInstalled&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I||He||Ye,onClick:()=>{Xe(!0),P(``),F(``),s(`/api/project/autodetect/vercel-preview`,{project:e,approved:!0}).then(e=>{e.latestPreviewUrl?(H(e.latestPreviewUrl),e.productionCandidateUrl&&!U&&ze(e.productionCandidateUrl),F(`Found latest Vercel preview: ${e.latestPreviewUrl}`)):F(e.message)}).catch(e=>P(e.message)).finally(()=>Xe(!1))},children:Ye?`Finding preview…`:`Find latest Vercel preview`}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:I||He||!V.trim()||!U.trim(),onClick:()=>void Nt(Z.get($.id)),children:He?`Comparing preview vs live…`:`Compare Preview vs Live`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I||He,onClick:()=>{let e=Z.get($.id);e&&Y(e,{enabled:!0,accountLabel:z.trim()||$.name,endpointUrl:V.trim(),baseUrl:U.trim()})},children:`Save URLs`}),Z.get($.id)?.status===`configured`&&(0,l.jsx)(`button`,{type:`button`,className:`text-button`,disabled:I,onClick:()=>{let e=Z.get($.id);e&&(B(``),H(``),ze(``),We(null),Y(e,{enabled:!1}))},children:`Disconnect`})]}),W&&(0,l.jsxs)(`div`,{className:`wb-bdiff-results`,style:{marginTop:`12px`},children:[(0,l.jsxs)(`div`,{className:`wb-bdiff-summary-row`,children:[(0,l.jsxs)(`span`,{className:`wb-bdiff-stat`,children:[(0,l.jsx)(`strong`,{children:`Score:`}),` `,W.delta.afterScore,`/100 (`,W.delta.scoreDelta>=0?`+`:``,W.delta.scoreDelta,`)`]}),(0,l.jsxs)(`span`,{className:`wb-bdiff-stat`,children:[(0,l.jsx)(`strong`,{children:`Max visual change:`}),` `,W.visualDiff.maxMismatchPercentage,`%`]}),(0,l.jsxs)(`span`,{className:`wb-bdiff-stat`,children:[(0,l.jsx)(`strong`,{children:`New issues:`}),` `,W.delta.introducedCount]}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{navigator.clipboard?.writeText(W.prProofMarkdown).catch(()=>{}),F(`Copied PR visual proof summary.`)},children:`Copy PR Proof`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>{navigator.clipboard?.writeText(W.aiFixPrompt).catch(()=>{}),F(`Copied fix prompt for your AI editor.`)},children:`Copy AI fix prompt`})]}),W.visualDiff.viewports[0]?.beforeUrl&&W.visualDiff.viewports[0]?.afterUrl&&(0,l.jsx)(`div`,{className:`wb-bdiff-stage`,children:(0,l.jsxs)(`div`,{className:`wb-bdiff-slider-box`,children:[(0,l.jsx)(`img`,{src:W.visualDiff.viewports[0].afterUrl,alt:`Preview deployment`,className:`wb-bdiff-img`}),(0,l.jsx)(`div`,{className:`wb-bdiff-before-clip`,style:{width:`${Ge}%`},children:(0,l.jsx)(`img`,{src:W.visualDiff.viewports[0].beforeUrl,alt:`Live site`,className:`wb-bdiff-img`})}),(0,l.jsx)(`div`,{className:`wb-bdiff-divider`,style:{left:`${Ge}%`}}),(0,l.jsx)(`input`,{type:`range`,min:0,max:100,value:Ge,"aria-label":`Compare live and preview screenshot`,className:`wb-bdiff-range`,onChange:e=>Ke(Number(e.target.value))})]})})]})]}),$.externalId&&![`figma`,`reference-library`,`slack`,`github-issues`,`vercel`,`cloudflare`,`netlify`].includes($.id)&&Z.get($.externalId)&&(0,l.jsxs)(`div`,{className:`settings-connector-panel`,children:[(0,l.jsxs)(`div`,{className:`settings-connector-fields`,children:[(0,l.jsxs)(`label`,{htmlFor:`ext-conn-label`,children:[`Workspace or project name`,(0,l.jsx)(`input`,{id:`ext-conn-label`,value:z,onChange:e=>B(e.target.value),placeholder:$.id===`linear`?`Frontend Team`:`${$.name} project`})]}),(0,l.jsxs)(`label`,{htmlFor:`ext-conn-url`,children:[$.id===`storybook`?`Local Storybook URL`:`Workspace or repository URL (optional)`,(0,l.jsx)(`input`,{id:`ext-conn-url`,type:`url`,value:V,onChange:e=>H(e.target.value),placeholder:$.id===`storybook`?`http://127.0.0.1:6006`:`https://...`})]})]}),(0,l.jsxs)(`div`,{className:`wb-recovery-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:I,onClick:()=>{let e=Z.get($.externalId);e&&Y(e,{enabled:!0,accountLabel:z.trim()||`${$.id}-workspace`,endpointUrl:V.trim()})},children:`Save connection`}),Z.get($.externalId)?.status===`configured`&&(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:I,onClick:()=>{let e=Z.get($.externalId);e&&(B(``),H(``),Y(e,{enabled:!1}))},children:`Disconnect`})]})]}),($.group===`verify-security`||$.id===`reference-library`)&&(0,l.jsx)(te,{active:!0,busy:I,securityToolchain:A?.securityToolchain,intakes:ye,onMedia:v,perform:J,refresh:xt,setMessage:F}),$.custom&&(0,l.jsxs)(`div`,{className:`wb-wf-info-callout`,children:[(0,l.jsx)(`strong`,{children:`Type:`}),` `,$.custom.kind===`webhook`?`Webhook URL`:`Local MCP tool`,$.custom.endpointUrl?(0,l.jsxs)(l.Fragment,{children:[` `,`· `,(0,l.jsx)(`code`,{children:$.custom.endpointUrl})]}):null,$.custom.command?(0,l.jsxs)(l.Fragment,{children:[` `,`· `,(0,l.jsx)(`code`,{children:$.custom.command})]}):null]}),(0,l.jsxs)(`footer`,{className:`wb-conn-detail-footer`,children:[(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`strong`,{children:`Permissions:`}),` `,$.permissionsNote]}),(0,l.jsx)(`span`,{children:$.docsNote})]})]}):(0,l.jsxs)(l.Fragment,{children:[x===`all`&&f&&m&&(0,l.jsx)(o,{surface:`connections`,disabled:I,onSelect:e=>{e===`mcp`?$t(`ai-clients`):p?p(e):e===`audit`&&S(`verify-security`)},onDismiss:m}),(0,l.jsx)(`div`,{className:`wb-conn-search-bar`,children:(0,l.jsxs)(`div`,{className:`wb-conn-search-input-wrap`,children:[(0,l.jsx)(i,{name:`search`}),(0,l.jsx)(`input`,{ref:re,type:`search`,"aria-label":`Search apps and tools`,value:D,onChange:e=>ne(e.target.value),placeholder:`Search Figma, GitHub, Vercel, Playwright, Slack…`}),!D&&(0,l.jsx)(`kbd`,{className:`wb-conn-search-kbd`,"aria-hidden":`true`,children:`/`})]})}),(qt||Jt)&&(0,l.jsxs)(`div`,{className:`wb-conn-search-jump`,children:[(0,l.jsx)(`span`,{children:`Looking for editors or model keys?`}),qt&&(0,l.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>$t(`ai-clients`),children:[(0,l.jsx)(i,{name:`mcp`}),`Open AI Clients →`]}),Jt&&(0,l.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>$t(`api-keys`),children:[(0,l.jsx)(i,{name:`google`}),`Open API Keys →`]})]}),(0,l.jsxs)(`div`,{className:`wb-conn-section-head`,children:[(0,l.jsx)(`h3`,{children:x===`all`?`Apps & Tools`:x===`enabled`?`Connected (${Gt})`:E.find(e=>e.id===x)?.label??`Apps`}),(0,l.jsxs)(`span`,{children:[Kt.length,` `,Kt.length===1?`app`:`apps`]})]}),Kt.length>0?(0,l.jsx)(`div`,{className:`wb-conn-card-grid`,role:`list`,"aria-label":`Apps and tools directory`,children:Kt.map(e=>(0,l.jsxs)(`button`,{type:`button`,role:`listitem`,className:`wb-conn-card`,onClick:()=>Yt(e),children:[(0,l.jsxs)(`div`,{className:`wb-conn-card-top`,children:[(0,l.jsx)(`span`,{className:`wb-conn-card-icon`,children:(0,l.jsx)(i,{name:e.icon})}),(0,l.jsx)(`span`,{className:`settings-availability-badge`,"data-availability":e.statusTone,children:e.statusLabel})]}),(0,l.jsx)(`h4`,{children:e.name}),(0,l.jsx)(`p`,{children:e.summary}),(0,l.jsxs)(`div`,{className:`wb-conn-card-foot`,children:[(0,l.jsx)(`span`,{children:e.groupLabel}),(0,l.jsxs)(`strong`,{children:[e.primaryAction,` →`]})]})]},e.id))}):(0,l.jsxs)(`p`,{className:`field-help`,children:[`No app matched “`,D.trim(),`”. Try another search or click`,` `,(0,l.jsx)(`strong`,{children:`+ Add custom`}),` in the sidebar.`]}),!!A?.authBoundaries?.length&&(0,l.jsxs)(`details`,{className:`settings-quiet-disclosure`,children:[(0,l.jsx)(`summary`,{children:`Permissions & security`}),(0,l.jsx)(`dl`,{children:A.authBoundaries.map(e=>(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`dt`,{children:[e.title,` `,(0,l.jsx)(`span`,{className:`settings-type-label`,children:e.status})]}),(0,l.jsx)(`dd`,{children:e.rule})]},e.id))})]})]})})]})]})}export{w as n,b as r,D as t};
|
|
@@ -0,0 +1,10 @@
|
|
|
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-Dp8CdAV4.js";import te from"./Settings-8mMKFnYf.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),[O,k]=(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)||O>=3)return;let e=!0,t=setTimeout(()=>{o(`/api/providers/attempts/${_.id}`).then(async t=>{e&&(S(``),k(0),v(t),t.status===`completed`&&await E.current())}).catch(t=>{e&&(S(t.message+` Refresh generation status if the connection remains unavailable.`),k(e=>e+1))})},document.hidden?1500:500);return()=>{e=!1,clearTimeout(t)}},[_,O]);let A=_?.status===`running`||_?.status===`preparing`;function j(){m(null),g(!1),S(``),w.current&&(w.current.value=``)}async function M(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 N(){await M(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 P(){await M(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 F(){if(!p||!h||!w.current)return;let e=w.current.value;w.current.value=``,await M(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 re(){_&&await M(async()=>{let e=await o(`/api/providers/attempts/${_.id}`);T.current&&(k(0),v(e),e.status===`completed`&&await E.current())})}return(0,l.jsxs)(`details`,{className:`provider-panel`,open:C||A,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&&!A&&(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:N,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),j()}})]}),(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),j()}})]}),(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),j()}})]})]}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:y||!r.some(e=>e.id===a),onClick:P,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:F,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??(A?`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`]}),A&&(0,l.jsxs)(`div`,{className:`run-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:y,onClick:re,children:`Refresh generation status`}),(0,l.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:()=>M(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:()=>M(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),ne=(0,c.useRef)(null);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 w(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 T(){if(r)return;let n=e.project;a(!0),v(``),g(`Folder picker is open. Choose a folder or cancel there.`);try{let e=await o(`/api/select-folder`,{initialPath:n.trim()});if(!C.current)return;if(e.fallbackRequired){g(e.reason||`No graphical folder picker is available on this host. Paste your project folder path here.`),ne.current?.focus();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 E=m(e.editable),D=m(e.creates),O=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`,{ref:ne,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:T,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:()=>w(),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:[E.length?`${E.length} existing ${E.length===1?`file`:`files`} selected`:`Choose files before starting`,D.length?` · ${D.length} new ${D.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:E.includes(e),onChange:n=>t({editable:(n.target.checked?[...E,e]:E.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:()=>w(),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:O?`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:O?`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:[E.length,` existing · `,D.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`,N===`settings`?`prepare`:N),history.replaceState(null,``,e),(m.current??document.getElementById(`show-settings`))?.focus()}let[T,O]=(0,c.useState)(null),[k,A]=(0,c.useState)(v),[j,M]=(0,c.useState)(()=>n.get(`studio-theme`)??`system`),[N,P]=(0,c.useState)(`prepare`),[F,re]=(0,c.useState)(`preview`),[ie,ae]=(0,c.useState)([]),[I,oe]=(0,c.useState)(null),[se,ce]=(0,c.useState)(null),[L,R]=(0,c.useState)(null),[z,le]=(0,c.useState)(!1),[ue,de]=(0,c.useState)({text:``,error:!1}),[B,fe]=(0,c.useState)(!1),[V,pe]=(0,c.useState)(null),[H,me]=(0,c.useState)(null),[he,ge]=(0,c.useState)(``),[_e,U]=(0,c.useState)(!1),[ve,ye]=(0,c.useState)(``),[be,xe]=(0,c.useState)(``),[Se,Ce]=(0,c.useState)(`after`),[we,Te]=(0,c.useState)(``),[W,Ee]=(0,c.useState)(()=>n.get(`studio-workspace-motion-v2`)!==!1),[De,Oe]=(0,c.useState)([]),[ke,Ae]=(0,c.useState)(``),[je,Me]=(0,c.useState)(``),Ne=(0,c.useRef)(null),G=(0,c.useRef)(0),Pe=(0,c.useRef)(!1),K=(0,c.useRef)(!0),q=(0,c.useRef)(k),Fe=(0,c.useRef)(null),J=(0,c.useRef)(null);q.current=k,J.current=I,Fe.current=V,(0,c.useEffect)(()=>{document.documentElement.dataset.motion=W?`on`:`off`,n.set(`studio-workspace-motion-v2`,W)},[W]),(0,c.useEffect)(()=>{document.documentElement.dataset.view=N;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)}},[N]);function Y(e,t=!1){de({text:e,error:t})}function X(e){A(t=>({...t,...e,draftKey:null})),R(null),fe(!0)}function Z(e,t=I){P(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 Ie(){let e=await o(`/api/runs`);K.current&&ae(e.runs)}async function Q(e,t){let n=++G.current,r=await o(`/api/runs/`+e);if(n===G.current&&K.current&&(oe(r),J.current=r,ce(null),xe(``),fe(!1),Z(t??(r.exportDirectory&&r.status!==`invalidated`?`review`:`run`),r),await Ie(),n===G.current&&r.requestPath)){let t=await o(`/api/runs/${e}/content`);if(n!==G.current)return;ce(t),Te(t.proposal?.changes[0]?.path??``)}}async function $(e){if(!Pe.current){Pe.current=!0,le(!0),Y(``);try{await e()}catch(e){let t=e;if(t.code===`PREFLIGHT_CHANGED`&&R(null),Y(t.message,!0),t.runId)try{await Q(t.runId,`run`)}catch{}}finally{Pe.current=!1,K.current&&le(!1)}}}async function Le(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),P(`run`);![`completed`,`failed`,`cancelled`].includes(t.status)&&K.current;)pe(t),Fe.current=t,await new Promise(e=>setTimeout(e,250)),t=await o(`/api/jobs/`+t.id);if(K.current){if(pe(null),Fe.current=null,n.set(`studio-pending-job`,null),t.runAvailable?await Q(t.runId,t.status===`completed`?void 0:`run`):(R(null),Z(`prepare`)),t.status===`failed`)throw Error(t.error??`Local job failed. Check the project again.`);t.status===`cancelled`&&Y(`Local work cancelled. Committed outputs were retained.`)}}async function Re(e=!1){let t=q.current.project.trim();if(!t)return;let n=await o(`/api/memory?project=`+encodeURIComponent(t));q.current.project.trim()===t&&(me({...n,project:t}),ge(n.content),q.current.useMemory&&q.current.memoryVersion!==n.version&&A(e=>({...e,useMemory:!1})),e||Y(n.version?`Saved project instructions loaded.`:`No saved instructions yet.`))}async function ze(){let e=await o(`/api/jobs?`+new URLSearchParams({query:ke,status:je}));Oe(e.jobs)}(0,c.useEffect)(()=>{n.set(`studio-draft`,{...k,version:2})},[k]),(0,c.useEffect)(()=>{[`system`,`light`,`dark`].includes(j)&&(document.documentElement.dataset.theme=j,n.set(`studio-theme`,j))},[j]),(0,c.useEffect)(()=>{let e=e=>{B&&(e.preventDefault(),e.returnValue=``)};return addEventListener(`beforeunload`,e),()=>removeEventListener(`beforeunload`,e)},[B]),(0,c.useEffect)(()=>{_e?Ne.current?.showModal():Ne.current?.close()},[_e]),(0,c.useEffect)(()=>{if(N!==`jobs`)return;ze().catch(e=>Y(e.message,!0));let e=setInterval(()=>{document.hidden||ze().catch(()=>{})},2e3);return()=>clearInterval(e)},[N,ke,je]),(0,c.useEffect)(()=>{K.current=!0,(async()=>{await a();let[e,t]=await Promise.all([o(`/api/context`),o(`/api/runs`)]);if(!K.current)return;O(e),ae(t.runs),q.current.project&&await Re(!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 $(async()=>Le(await o(`/api/jobs/`+i))):r.get(`run`)?await Q(r.get(`run`),r.get(`view`)===`run`?`run`:void 0):r.get(`view`)===`jobs`?P(`jobs`):r.get(`view`)===`settings`&&P(`prepare`),[`preview`,`changes`,`checks`].includes(r.get(`tab`)??``)&&re(r.get(`tab`))})().catch(e=>Y(`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`)?Q(e.get(`run`),e.get(`view`)===`run`?`run`:void 0).catch(e=>Y(e.message,!0)):P(e.get(`view`)===`jobs`?`jobs`:`prepare`)};return addEventListener(`popstate`,e),()=>{K.current=!1,G.current++,removeEventListener(`popstate`,e)}},[]);function Be(e=!1){z||(!B||confirm(`Discard the unsaved brief? Existing runs and project files stay intact.`))&&(G.current++,A({..._(),...e&&I?{project:I.project,brief:I.brief,preserve:I.mustPreserve.join(`
|
|
5
|
+
`),adapter:I.capabilities.adapter}:{}}),oe(null),J.current=null,ce(null),xe(``),R(null),me(null),ge(``),fe(!1),Y(``),Z(`prepare`,null),setTimeout(()=>document.getElementById(`project`)?.focus(),0))}function Ve(){let e=k.draftKey??`revision-${crypto.randomUUID()}`;return k.draftKey||A(t=>({...t,draftKey:e})),{version:1,requestKey:e,workflowProfile:k.workflowProfile,adapter:k.adapter,project:k.project.trim(),brief:k.brief.trim(),mustPreserve:x(k.preserve),mode:k.adapter===`react-vite-v1`?`manual`:k.mode,references:k.selected.map(e=>({selectionId:e,attach:k.attach})),guidance:[],...k.adapter===`react-vite-v1`?{projectPolicy:{editablePaths:x(k.editable),createPaths:x(k.creates)}}:{},limits:{maxAttempts:3,packetBytes:8e5}}}function He(e){e.preventDefault(),$(async()=>{let e=Ve(),t=k.useMemory&&H?.project===e.project?H.version:0;if(!L){R(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:L.inputHash});fe(!1),R(null),await Le(n)})}function Ue(){(!B||confirm(`Replace the current draft with the sample setup?`))&&X({..._(),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 B&&!confirm(`Replace the current draft with the Focus Board pilot setup? Your saved runs remain available.`)?!1:(X({..._(),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=k.selected.includes(e)?k.selected.filter(t=>t!==e):k.selected.length<8?[...k.selected,e]:k.selected;t===k.selected?Y(`Choose up to eight reference images.`,!0):X({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});O(e=>e&&{...e,references:[...e.references,n]}),k.selected.length<8&&X({selected:[...k.selected,n.id]}),Y(`Image saved locally. Verify its rights before production reuse.`)}async function qe(e){e.preventDefault(),$(async()=>{if(!ve.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(ve)))].map(e=>e.toString(16).padStart(2,`0`)).join(``).slice(0,24);await Le(await o(`/api/jobs`,{kind:`resume`,operationId:`response:${I.id}:${e}`,runId:I.id,responseText:ve}))})}async function Je(){confirm(`Cancel this local work? Its outputs stay available, but a cancelled run cannot resume.`)&&(Fe.current?await o(`/api/jobs/${Fe.current.id}/cancel`,{}):J.current&&(await o(`/api/runs/${J.current.id}/cancel`,{}),await Q(J.current.id,`run`)))}function Ye(e,t=!1){re(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":k.selected.includes(e.id),disabled:!e.available||z,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=>k.selected.includes(e.id))??[],Qe=[...Ze,...T?.references.filter(e=>!k.selected.includes(e.id)&&[`refero-figma`,`refero-raycast`,`bold-portfolio`,`creative-portfolio`].includes(e.id))??[]].slice(0,4),$e=!!I?.acceptance?.decision,et=I?S.includes(I.status):!1,tt=se?.proposal?.changes.find(e=>e.path===we);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:z,children:[(0,l.jsx)(C,{}),`New revision`]}),(0,l.jsxs)(`button`,{className:`rail-link`,id:`show-jobs`,"aria-current":N===`jobs`?`page`:void 0,onClick:()=>Z(`jobs`),children:[(0,l.jsx)(C,{}),`Jobs`,` `,(0,l.jsx)(`span`,{id:`queued-count`,children:De.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:ie.filter(e=>e.category===`project`).length?ie.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":I?.id===e.id?`page`:void 0,onClick:t=>{t.ctrlKey||t.metaKey||(t.preventDefault(),(!B||confirm(`Leave the unsaved brief?`))&&Q(e.id).catch(e=>Y(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:j,onChange:e=>M(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:N===`prepare`?`New revision`:N===`run`?`Run progress`:N===`review`?`Review revision`:N===`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":z,children:[(0,l.jsx)(`nav`,{className:`step-nav`,"aria-label":`Revision steps`,hidden:N===`jobs`||N===`settings`,children:[`prepare`,`run`,`review`].map((e,t)=>(0,l.jsxs)(`button`,{"data-step":e,"aria-current":N===e?`step`:void 0,disabled:e===`run`?!I&&!V:e===`review`&&!I?.revisionId,onClick:()=>Z(e),children:[(0,l.jsx)(`span`,{children:t+1}),e[0].toUpperCase()+e.slice(1)]},e))}),(0,l.jsx)(`div`,{id:`notice`,className:`notice ${ue.error?`error`:``}`,role:`status`,"aria-live":`polite`,hidden:!ue.text,children:ue.text}),(0,l.jsxs)(`section`,{id:`prepare-view`,className:`view`,hidden:N!==`prepare`,children:[(0,l.jsx)(`div`,{className:`welcome-aura`,"aria-hidden":`true`}),(0,l.jsx)(s,{motion:W,active:N===`prepare`&&!i}),(0,l.jsxs)(`form`,{id:`prepare-form`,onSubmit:He,inert:z,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:k.brief,onChange:e=>X({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:()=>U(!0),children:(0,l.jsx)(C,{})}),(0,l.jsx)(`span`,{id:`composer-mode`,children:k.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:k,onPicking:t,onChange:e=>{X(e),e.project!==void 0&&me(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(k.preserve).length+1)),value:k.preserve,onChange:e=>X({preserve:e.target.value}),placeholder:`Navigation, keyboard focus, existing content…`}),(0,l.jsx)(ee,{value:k.preserve,onChange:e=>X({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 ·`,` `,k.workflowProfile===`auto`?`From your brief`:k.workflowProfile===`ai-search`?`AI search`:k.workflowProfile===`seo-ai-search`?`SEO + AI search`:k.workflowProfile===`architecture`?`Project map`:k.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:k.workflowProfile,onChange:e=>X({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:H?H.version?`Saved v${H.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:he,onChange:e=>ge(e.target.value)}),(0,l.jsxs)(`div`,{className:`memory-actions`,children:[(0,l.jsx)(w,{onClick:()=>$(()=>Re()),children:`Load saved`}),(0,l.jsx)(w,{onClick:()=>$(async()=>{let e=k.project.trim(),t=await o(`/api/memory`,{project:e,content:he,expectedVersion:H?.project===e?H.version:0});me(t),X({useMemory:!0,memoryVersion:t.version}),Y(`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:k.useMemory,onChange:e=>X({useMemory:e.target.checked,memoryVersion:H?.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:k.mode===`mock`?`You’re trying a sample`:`Works with your AI client`}),k.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&&$(()=>Ke(t)),e.target.value=``}}),(0,l.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>U(!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:k.selected.length?`${k.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:k.attach,onChange:e=>X({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))})]})]}),L&&(0,l.jsxs)(`div`,{id:`preflight`,className:`preflight`,children:[(0,l.jsx)(`h3`,{children:`Ready to start`}),(0,l.jsxs)(`p`,{children:[L.files,` supported files · `,L.references,` references ·`,` `,k.mode===`mock`?`Labelled sample fixture`:`Manual handoff`]}),(0,l.jsxs)(`p`,{children:[(L.contextBytes/1024).toFixed(1),` KiB context`,L.memoryVersion?` · Project memory v${L.memoryVersion}`:``,` · `,L.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||z||e,children:e?`Choose a folder…`:z?`Working…`:L?`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:N!==`run`,children:[(0,l.jsxs)(`div`,{className:`page-heading`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{id:`run-heading`,children:V?V.status===`queued`?`Queued on this machine.`:`Working on your revision.`:I?.status===`waiting-external-response`?`Your handoff is ready.`:I?.status===`awaiting-human-review`?`Ready for your review.`:`${b(I?.status??`ready`)}.`}),(0,l.jsx)(`p`,{id:`run-description`,children:I?.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:!I||z,onClick:()=>$(()=>Q(I.id,`run`)),children:`Refresh status`})]}),(0,l.jsx)(`div`,{id:`run-error`,className:`error-box`,role:`alert`,hidden:!I?.error,children:I?.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:(V?[{stage:V.kind===`start`?`Prepare revision`:`Resume revision`,status:V.status}]:I?.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:!I&&!V||et,onClick:()=>Je().catch(e=>Y(e.message,!0)),children:`Cancel run`}),I?.exportDirectory&&(0,l.jsx)(w,{primary:!0,id:`go-review`,onClick:()=>Z(`review`),children:`Review revision`}),I&&[`failed`,`ready`].includes(I.status)&&(0,l.jsx)(w,{id:`retry-run`,onClick:()=>$(async()=>Le(await o(`/api/jobs`,{kind:`resume`,operationId:`resume:${I.id}:${I.attempts.length}`,runId:I.id}))),children:`Resume run`})]}),I&&(0,l.jsx)(f,{runId:I.id,waiting:I.status===`waiting-external-response`,onReady:()=>Q(I.id,`review`)},I.id)]}),I?.mode===`manual`&&I.requestPath&&!I.revisionId&&!et&&!V&&(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:()=>$(()=>r(I.id,`handoff`)),children:`Download handoff .zip`}),(0,l.jsx)(E,{run:I,task:$,refresh:()=>Q(I.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:ve,onChange:e=>ye(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&&$(async()=>{if(t.size>524288)throw Error(`Response exceeds 512 KiB`);ye(await t.text())})}}),(0,l.jsx)(`button`,{className:`button primary`,disabled:z,children:`Import & resume`})]})]})]})]}),(0,l.jsx)(`div`,{children:I?.requestPath&&(0,l.jsx)(p,{run:I,task:$},I.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:I?.id??V?.id,Revision:I?.revisionId??`Not created`,Project:I?.project,Integrity:I?.integrity,Output:I?.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:N!==`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 ${I?.acceptance?.decision}.`:`Review the revision.`}),(0,l.jsx)(`p`,{id:`review-summary`,children:se?.proposal?.summary??I?.brief}),I?.providerAttempts?.filter(e=>e.revisionId===I.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:!I?.exportDirectory||I.status===`invalidated`||z,onClick:()=>$(()=>r(I.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":F===e,tabIndex:F===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:F!==`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":Se===e,onClick:()=>{Ce(e),xe(``)},children:e===`before`?`Original`:`Revision`},e))}),(0,l.jsx)(`span`,{children:`Restricted local preview`})]}),!be&&(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:I?.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:()=>$(async()=>{let e=await o(`/api/runs/${I.id}/preview`,{variant:Se});xe(e.url)}),children:`Open trusted preview`})]}),(0,l.jsx)(`iframe`,{id:`preview-frame`,title:`Project revision preview`,sandbox:I?.capabilities.adapter===`react-vite-v1`?`allow-scripts allow-same-origin`:`allow-scripts`,referrerPolicy:`no-referrer`,src:be||void 0,hidden:!be}),(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:F!==`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:we,onChange:e=>Te(e.target.value),children:se?.proposal?.changes.map(e=>(0,l.jsx)(`option`,{children:e.path},e.path))}),(0,l.jsx)(`button`,{className:`text-button`,onClick:()=>$(()=>r(I.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:se?.request.files.find(e=>e.path===we)?.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:F!==`checks`,children:[(0,l.jsx)(`div`,{id:`checks-list`,className:`checks-list`,children:Object.entries(I?.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))}),I?.capabilities.adapter===`react-vite-v1`&&(0,l.jsx)(D,{run:I,task:$,refresh:()=>Q(I.id,`review`)},I.id+`:`+I.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));$(async()=>{await o(`/api/runs/${I.id}/evidence`,{...t,revisionId:I.revisionId,reportText:JSON.stringify({origin:`operator-report`,...t})}),await Q(I.id,`review`),Y(`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:z||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:I?.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;$(async()=>{await o(`/api/runs/${I.id}/decision`,{revisionId:I.revisionId,decision:n.value,reason:t.get(`reason`)}),await Q(I.id,`review`),Y(`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:z,children:`Accept revision`}),(0,l.jsx)(`button`,{className:`button subtle`,name:`decision`,value:`rejected`,disabled:z,children:`Reject revision`})]})]}),(0,l.jsxs)(`div`,{id:`decision-result`,hidden:!$e,children:[(0,l.jsx)(`p`,{className:`state-label `+I?.acceptance?.decision,children:b(I?.acceptance?.decision??``)}),(0,l.jsx)(`p`,{children:I?.acceptance?.reason})]}),I&&(0,l.jsx)(E,{run:I,task:$,refresh:()=>Q(I.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:j,onTheme:M,motion:W,onMotion:Ee,onPilot:()=>{We()&&(y(),Z(`prepare`))}}),(0,l.jsxs)(`section`,{id:`jobs-view`,className:`view`,hidden:N!==`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:()=>$(ze),children:`Refresh jobs`})]}),(0,l.jsxs)(`form`,{id:`job-query`,className:`job-query`,onSubmit:e=>{e.preventDefault(),$(ze)},children:[(0,l.jsxs)(`label`,{htmlFor:`job-search`,children:[`Find a job`,(0,l.jsx)(`input`,{type:`search`,id:`job-search`,value:ke,onChange:e=>Ae(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:je,onChange:e=>Me(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:De.length?De.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:()=>Q(e.runId).catch(e=>Y(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.`)&&$(async()=>{await o(`/api/jobs/${e.id}/cancel`,{}),await ze()})},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:Ne,onCancel:()=>U(!1),onClose:()=>U(!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:()=>U(!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:()=>U(!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 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./react-vendor-CH5vucNG.js";import{f as n,p as r,t as i}from"./index-KY1IHp8L.js";var a=e(),o=t();function s({auth:e,activeProject:t,onOpenAccount:s,onBrowseLocal:c,onTrySample:l,onOpenProject:u}){let[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(``),[h,g]=(0,a.useState)(`all`),[_,v]=(0,a.useState)(1),[y,b]=(0,a.useState)(10),[x,S]=(0,a.useState)(!0),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(null),[D,O]=(0,a.useState)(null),[k,A]=(0,a.useState)(!1),[j,M]=(0,a.useState)(``),[N,P]=(0,a.useState)(``),[F,I]=(0,a.useState)(``),[L,R]=(0,a.useState)(null),[z,B]=(0,a.useState)(null),V=(0,a.useCallback)(async e=>{let t=e?.targetPage??_,n=e?.targetPerPage??y,i=e?.q??p,a=new URLSearchParams({page:String(t),perPage:String(n)});i.trim()&&a.set(`q`,i.trim()),e?.forceSync&&a.set(`sync`,`1`),e?.forceSync?w(!0):S(!0),P(``);try{let t=await r(`/api/repos?${a.toString()}`);f(t),e?.forceSync&&I(t.canListRemote?`Synced ${t.pagination.total} ${t.accountProvider===`gitlab`?`GitLab`:`GitHub`} repositories.`:`Refreshed local workspace folders.`)}catch(e){P(e.message)}finally{S(!1),w(!1)}},[_,y,p]);(0,a.useEffect)(()=>{if(!p.trim()){V();return}let e=window.setTimeout(()=>{V()},150);return()=>window.clearTimeout(e)},[V,p,e?.authenticated,e?.account?.id]);async function H(e){E(e.id),P(``),I(``);try{let t=await r(`/api/repos/clone`,{provider:e.provider,owner:e.owner,repo:e.name,branch:e.defaultBranch,cloneUrl:e.cloneUrl,approved:!0});I(`${t.action===`cloned`?`Cloned`:`Pulled`} ${e.fullName} cleanly (no scripts executed).`),await u(t.localPath,t.inspection)}catch(e){P(e.message)}finally{E(null)}}async function U(){if(j.trim()){E(`add-url`),P(``),I(``);try{let e=await r(`/api/repos/add-url`,{url:j.trim(),approved:!0});M(``),A(!1),I(`${e.action===`cloned`?`Cloned`:`Pulled`} ${e.fullName}.`),await u(e.localPath,e.inspection)}catch(e){P(e.message)}finally{E(null)}}}async function W(e){O(e.id),P(``),I(``);try{let t=e.localPath;if(!t&&e.remote&&(t=(await r(`/api/repos/clone`,{provider:e.remote.provider,owner:e.remote.owner,repo:e.remote.name,branch:e.remote.defaultBranch,cloneUrl:e.remote.cloneUrl,approved:!0})).localPath),!t)throw Error(`Select a local or cloned repository for Quick QA.`);let n=await r(`/api/repos/quick-qa`,{project:t});R(n),V()}catch(e){P(e.message)}finally{O(null)}}let G=(d?.remoteRepos??[]).map(e=>({id:e.id,kind:`remote`,provider:e.provider,title:e.fullName,subtitle:e.description||e.htmlUrl,branch:e.defaultBranch,statusLabel:e.localStatus===`synced`?`Synced locally`:`Remote only`,statusTone:e.localStatus===`synced`?`synced`:`remote`,privateRepo:e.private,localPath:e.localPath,remote:e})),K=e=>e.trim().toLowerCase().replace(/(?:[-_\s]+studio[-_\s]?copy|[-_\s]+copy|\s*\(copy\)|[-_\s]+worktree)(?:[-_\s]*\d+)?$/i,``).trim(),q=new Set(G.map(e=>e.localPath?.toLowerCase()).filter(Boolean)),J=new Set(G.flatMap(e=>[e.title.toLowerCase(),K(e.remote?.name??e.title.split(`/`).at(-1)??``)])),Y=(d?.localProjects??[]).filter(e=>{if(q.has(e.path.toLowerCase()))return!1;let t=e.name.trim().toLowerCase(),n=K(e.name);return!(J.has(t)||n!==t&&J.has(n))}).map(e=>({id:e.id,kind:`local`,provider:e.provider,title:e.name,subtitle:e.path,branch:e.defaultBranch,statusLabel:e.localStatus===`synced`?`Cloned locally`:`Local folder`,statusTone:e.localStatus===`synced`?`synced`:`local`,localPath:e.path})),X=h===`remote`?G:h===`local`?Y:[...G,...Y],Z=e?.account,Q=d?d.canListRemote:!(!Z||Z.provider!==`github`&&Z.provider!==`gitlab`);return(0,o.jsxs)(`section`,{className:`wb-repos-page`,"aria-labelledby":`repositories-heading`,children:[(0,o.jsxs)(`header`,{className:`wb-repos-header`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h1`,{id:`repositories-heading`,className:`page-reveal page-reveal--title`,children:`Repositories`}),(0,o.jsx)(`p`,{className:`wb-repos-subtitle page-reveal page-reveal--support`,children:Z&&(Z.provider===`github`||Z.provider===`gitlab`)?`Connected to ${Z.provider===`github`?`GitHub`:`GitLab`} as @${Z.username}. Clone or open projects with zero automatic script execution.`:`Open local folders, paste a GitHub/GitLab URL, or sign in to pull your repositories in one click.`})]}),(0,o.jsxs)(`div`,{className:`wb-repos-header-actions page-reveal page-reveal--controls`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`button subtle`,disabled:C||x,onClick:()=>void V({forceSync:!0}),children:[(0,o.jsx)(n,{name:`auto`}),C?`Syncing…`:`Sync Repositories`]}),(0,o.jsxs)(`button`,{type:`button`,className:`button primary`,"aria-expanded":k,onClick:()=>A(e=>!e),children:[(0,o.jsx)(n,{name:`plus`}),`Add Repository`]})]})]}),k&&(0,o.jsxs)(`section`,{className:`wb-repos-add-panel`,"aria-label":`Add repository or local folder`,children:[(0,o.jsxs)(`div`,{className:`wb-repos-add-url`,children:[(0,o.jsxs)(`label`,{htmlFor:`add-repo-url`,children:[`Clone from GitHub or GitLab HTTPS URL`,(0,o.jsx)(`input`,{id:`add-repo-url`,type:`url`,value:j,disabled:T===`add-url`,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),U())},placeholder:`https://github.com/owner/repository`})]}),(0,o.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!j.trim()||T===`add-url`,onClick:()=>void U(),children:T===`add-url`?`Cloning…`:`Clone & open`})]}),(0,o.jsxs)(`div`,{className:`wb-repos-add-alt`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void c(),children:[(0,o.jsx)(n,{name:`folder`}),`Browse local folder`]}),(0,o.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void l(),children:[(0,o.jsx)(n,{name:`website`}),`Try sample project`]}),(0,o.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>A(!1),children:`Cancel`})]}),(0,o.jsxs)(`p`,{className:`field-help`,children:[`Clones shallowly into ignored `,(0,o.jsx)(`code`,{children:`work/repos/`}),` with Git hooks disabled (`,(0,o.jsx)(`code`,{children:`core.hooksPath=/dev/null`}),`) and never runs `,(0,o.jsx)(`code`,{children:`npm install`}),` or build scripts automatically.`]})]}),!Q&&(0,o.jsxs)(`div`,{className:`wb-repos-signin-banner`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`Connect GitHub or GitLab for 1-click repository pull`}),(0,o.jsxs)(`p`,{children:[`Sign in with browser OAuth, local `,(0,o.jsx)(`code`,{children:`gh`}),`/`,(0,o.jsx)(`code`,{children:`glab`}),` CLI, or an access token. Your local projects below remain ready without signing in.`]})]}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:s,children:Z?`Switch account`:`Sign in`})]}),(N||d?.remoteError)&&(0,o.jsx)(`p`,{className:`error-box`,role:`alert`,children:N||d?.remoteError}),F&&(0,o.jsx)(`p`,{className:`connection-success`,role:`status`,children:F}),z&&(0,o.jsx)(i,{project:z,onClose:()=>B(null)}),L&&(0,o.jsxs)(`section`,{className:`wb-quick-qa-card page-reveal page-reveal--content`,"aria-label":`Quick QA audit summary`,children:[(0,o.jsxs)(`div`,{className:`wb-quick-qa-head`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`h2`,{children:[`Quick Security & UI QA ·`,` `,L.project.split(/[/\\]/).filter(Boolean).at(-1),` ·`,` `,(0,o.jsxs)(`span`,{children:[L.score,`/100`]})]}),(0,o.jsxs)(`p`,{children:[L.summary.securityFindings,` security, `,L.summary.craftFindings,` UI findings · Scanners:`,` `,(0,o.jsx)(`strong`,{children:(L.summary.scannersRun??[`builtin-sast-secrets`]).join(`, `)}),` `,`(read-only, zero scripts executed).`]})]}),(0,o.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>R(null),children:`Dismiss`})]}),L.summary.escalationRequired&&(0,o.jsxs)(`div`,{className:`wb-security-escalation`,role:`alert`,children:[(0,o.jsx)(`strong`,{children:`Escalation required:`}),` Critical or high security issues detected. Open in Studio to review and remediate before shipping.`]}),L.stages&&L.stages.length>0&&(0,o.jsx)(`ul`,{className:`wb-quick-qa-stages`,"aria-label":`4-stage security pipeline`,children:L.stages.map(e=>(0,o.jsxs)(`li`,{"data-status":e.status,children:[(0,o.jsxs)(`span`,{children:[e.order,`. `,e.label]}),(0,o.jsx)(`strong`,{children:e.status.replaceAll(`-`,` `)})]},e.id))}),L.signals&&(0,o.jsx)(`ul`,{className:`wb-qa-signal-strip`,"aria-label":`Quick QA signals`,children:Object.entries(L.signals).map(([e,t])=>{let n=typeof t==`string`?t:t?.status??`not-run`;return(0,o.jsxs)(`li`,{"data-status":n,children:[(0,o.jsx)(`span`,{children:e}),(0,o.jsx)(`strong`,{children:n.replaceAll(`-`,` `)})]},e)})}),L.repairHints.length>0&&(0,o.jsx)(`ul`,{className:`wb-quick-qa-hints`,children:L.repairHints.slice(0,5).map((e,t)=>(0,o.jsxs)(`li`,{"data-severity":e.severity,children:[(0,o.jsx)(`code`,{children:e.code}),e.path&&(0,o.jsxs)(`code`,{translate:`no`,children:[e.path,e.line?`:${e.line}`:``]}),(0,o.jsx)(`span`,{children:e.hint})]},`${e.code}-${t}`))})]}),(0,o.jsxs)(`div`,{className:`wb-repos-toolbar page-reveal page-reveal--controls`,children:[(0,o.jsxs)(`label`,{className:`wb-repos-search`,children:[(0,o.jsx)(n,{name:`search`}),(0,o.jsx)(`input`,{type:`search`,"aria-label":`Search repositories`,placeholder:`Search repositories…`,value:p,onChange:e=>{m(e.target.value),v(1)}})]}),(0,o.jsx)(`div`,{className:`wb-repos-filters`,role:`group`,"aria-label":`Filter repository source`,children:[`all`,`remote`,`local`].map(e=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>g(e),children:e===`all`?`All`:e===`remote`?`Remote`:`Local`},e))})]}),(0,o.jsx)(`div`,{className:`wb-repo-table-wrap page-reveal page-reveal--content`,tabIndex:0,role:`region`,"aria-label":`Repositories table`,children:(0,o.jsxs)(`table`,{className:`wb-repo-table`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`th`,{scope:`col`,children:`Repository`}),(0,o.jsx)(`th`,{scope:`col`,children:`Branch`}),(0,o.jsx)(`th`,{scope:`col`,children:`Local status`}),(0,o.jsx)(`th`,{scope:`col`,children:`Actions`})]})}),(0,o.jsxs)(`tbody`,{children:[X.map(e=>{let n=!!t&&!!e.localPath&&t.toLowerCase()===e.localPath.toLowerCase(),r=T===e.id,i=D===e.id;return(0,o.jsxs)(`tr`,{className:n?`is-active`:void 0,children:[(0,o.jsxs)(`th`,{scope:`row`,children:[(0,o.jsxs)(`div`,{className:`wb-repo-cell-main`,children:[(0,o.jsx)(`span`,{className:`wb-repo-name`,children:e.title}),(0,o.jsx)(`span`,{className:`wb-repo-provider-pill`,children:e.provider}),e.privateRepo&&(0,o.jsx)(`span`,{className:`wb-repo-private-pill`,children:`Private`}),n&&(0,o.jsx)(`span`,{className:`wb-repo-active-pill`,children:`Active`})]}),(0,o.jsx)(`small`,{className:`wb-repo-sub`,title:e.subtitle,children:e.subtitle})]}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`code`,{className:`wb-repo-branch`,children:e.branch})}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`span`,{className:`wb-repo-status`,"data-tone":e.statusTone,children:e.statusLabel})}),(0,o.jsxs)(`td`,{className:`wb-repo-actions`,children:[(0,o.jsx)(`button`,{type:`button`,className:`button primary`,disabled:r||i,onClick:()=>{e.remote?H(e.remote):e.localPath&&u(e.localPath)},children:r?`Pulling…`:`Open in Studio`}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:r||i,onClick:()=>void W(e),children:i?`Auditing…`:`Quick QA`}),e.localPath&&(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:r||i,onClick:()=>B(t=>t===e.localPath?null:e.localPath),children:z===e.localPath?`Close Diff`:`Visual Diff`})]})]},e.id)}),!x&&X.length===0&&(0,o.jsx)(`tr`,{children:(0,o.jsxs)(`td`,{colSpan:4,className:`wb-repo-empty`,children:[`No repositories found. Click `,(0,o.jsx)(`strong`,{children:`Add Repository`}),` to clone a URL, browse a local folder, or try the sample project.`]})})]})]})}),Q&&(d?.pagination.total??0)>0&&(0,o.jsxs)(`footer`,{className:`wb-repos-pagination`,children:[(0,o.jsxs)(`span`,{children:[`Showing page `,d.pagination.page,` of `,d.pagination.totalPages,` (`,d.pagination.total,` remote)`]}),(0,o.jsxs)(`div`,{className:`wb-repos-pagination-controls`,children:[(0,o.jsxs)(`label`,{htmlFor:`repo-page-size`,children:[`Per page`,(0,o.jsxs)(`select`,{id:`repo-page-size`,value:y,onChange:e=>{let t=Number(e.target.value);b(t),v(1)},children:[(0,o.jsx)(`option`,{value:10,children:`10`}),(0,o.jsx)(`option`,{value:25,children:`25`}),(0,o.jsx)(`option`,{value:50,children:`50`})]})]}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:_<=1||x,onClick:()=>v(e=>Math.max(1,e-1)),children:`Previous`}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:_>=(d?.pagination.totalPages??1)||x,onClick:()=>v(e=>e+1),children:`Next`})]})]})]})}export{s as default};
|
|
1
|
+
import{i as e,t}from"./react-vendor-CH5vucNG.js";import{f as n,p as r,t as i}from"./index-Dp8CdAV4.js";var a=e(),o=t();function s({auth:e,activeProject:t,onOpenAccount:s,onBrowseLocal:c,onTrySample:l,onOpenProject:u}){let[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(``),[h,g]=(0,a.useState)(`all`),[_,v]=(0,a.useState)(1),[y,b]=(0,a.useState)(10),[x,S]=(0,a.useState)(!0),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(null),[D,O]=(0,a.useState)(null),[k,A]=(0,a.useState)(!1),[j,M]=(0,a.useState)(``),[N,P]=(0,a.useState)(``),[F,I]=(0,a.useState)(``),[L,R]=(0,a.useState)(null),[z,B]=(0,a.useState)(null),V=(0,a.useCallback)(async e=>{let t=e?.targetPage??_,n=e?.targetPerPage??y,i=e?.q??p,a=new URLSearchParams({page:String(t),perPage:String(n)});i.trim()&&a.set(`q`,i.trim()),e?.forceSync&&a.set(`sync`,`1`),e?.forceSync?w(!0):S(!0),P(``);try{let t=await r(`/api/repos?${a.toString()}`);f(t),e?.forceSync&&I(t.canListRemote?`Synced ${t.pagination.total} ${t.accountProvider===`gitlab`?`GitLab`:`GitHub`} repositories.`:`Refreshed local workspace folders.`)}catch(e){P(e.message)}finally{S(!1),w(!1)}},[_,y,p]);(0,a.useEffect)(()=>{if(!p.trim()){V();return}let e=window.setTimeout(()=>{V()},150);return()=>window.clearTimeout(e)},[V,p,e?.authenticated,e?.account?.id]);async function H(e){E(e.id),P(``),I(``);try{let t=await r(`/api/repos/clone`,{provider:e.provider,owner:e.owner,repo:e.name,branch:e.defaultBranch,cloneUrl:e.cloneUrl,approved:!0});I(`${t.action===`cloned`?`Cloned`:`Pulled`} ${e.fullName} cleanly (no scripts executed).`),await u(t.localPath,t.inspection)}catch(e){P(e.message)}finally{E(null)}}async function U(){if(j.trim()){E(`add-url`),P(``),I(``);try{let e=await r(`/api/repos/add-url`,{url:j.trim(),approved:!0});M(``),A(!1),I(`${e.action===`cloned`?`Cloned`:`Pulled`} ${e.fullName}.`),await u(e.localPath,e.inspection)}catch(e){P(e.message)}finally{E(null)}}}async function W(e){O(e.id),P(``),I(``);try{let t=e.localPath;if(!t&&e.remote&&(t=(await r(`/api/repos/clone`,{provider:e.remote.provider,owner:e.remote.owner,repo:e.remote.name,branch:e.remote.defaultBranch,cloneUrl:e.remote.cloneUrl,approved:!0})).localPath),!t)throw Error(`Select a local or cloned repository for Quick QA.`);let n=await r(`/api/repos/quick-qa`,{project:t});R(n),V()}catch(e){P(e.message)}finally{O(null)}}let G=(d?.remoteRepos??[]).map(e=>({id:e.id,kind:`remote`,provider:e.provider,title:e.fullName,subtitle:e.description||e.htmlUrl,branch:e.defaultBranch,statusLabel:e.localStatus===`synced`?`Synced locally`:`Remote only`,statusTone:e.localStatus===`synced`?`synced`:`remote`,privateRepo:e.private,localPath:e.localPath,remote:e})),K=e=>e.trim().toLowerCase().replace(/(?:[-_\s]+studio[-_\s]?copy|[-_\s]+copy|\s*\(copy\)|[-_\s]+worktree)(?:[-_\s]*\d+)?$/i,``).trim(),q=new Set(G.map(e=>e.localPath?.toLowerCase()).filter(Boolean)),J=new Set(G.flatMap(e=>[e.title.toLowerCase(),K(e.remote?.name??e.title.split(`/`).at(-1)??``)])),Y=(d?.localProjects??[]).filter(e=>{if(q.has(e.path.toLowerCase()))return!1;let t=e.name.trim().toLowerCase(),n=K(e.name);return!(J.has(t)||n!==t&&J.has(n))}).map(e=>({id:e.id,kind:`local`,provider:e.provider,title:e.name,subtitle:e.path,branch:e.defaultBranch,statusLabel:e.localStatus===`synced`?`Cloned locally`:`Local folder`,statusTone:e.localStatus===`synced`?`synced`:`local`,localPath:e.path})),X=h===`remote`?G:h===`local`?Y:[...G,...Y],Z=e?.account,Q=d?d.canListRemote:!(!Z||Z.provider!==`github`&&Z.provider!==`gitlab`);return(0,o.jsxs)(`section`,{className:`wb-repos-page`,"aria-labelledby":`repositories-heading`,children:[(0,o.jsxs)(`header`,{className:`wb-repos-header`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h1`,{id:`repositories-heading`,className:`page-reveal page-reveal--title`,children:`Repositories`}),(0,o.jsx)(`p`,{className:`wb-repos-subtitle page-reveal page-reveal--support`,children:Z&&(Z.provider===`github`||Z.provider===`gitlab`)?`Connected to ${Z.provider===`github`?`GitHub`:`GitLab`} as @${Z.username}. Clone or open projects with zero automatic script execution.`:`Open local folders, paste a GitHub/GitLab URL, or sign in to pull your repositories in one click.`})]}),(0,o.jsxs)(`div`,{className:`wb-repos-header-actions page-reveal page-reveal--controls`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`button subtle`,disabled:C||x,onClick:()=>void V({forceSync:!0}),children:[(0,o.jsx)(n,{name:`auto`}),C?`Syncing…`:`Sync Repositories`]}),(0,o.jsxs)(`button`,{type:`button`,className:`button primary`,"aria-expanded":k,onClick:()=>A(e=>!e),children:[(0,o.jsx)(n,{name:`plus`}),`Add Repository`]})]})]}),k&&(0,o.jsxs)(`section`,{className:`wb-repos-add-panel`,"aria-label":`Add repository or local folder`,children:[(0,o.jsxs)(`div`,{className:`wb-repos-add-url`,children:[(0,o.jsxs)(`label`,{htmlFor:`add-repo-url`,children:[`Clone from GitHub or GitLab HTTPS URL`,(0,o.jsx)(`input`,{id:`add-repo-url`,type:`url`,value:j,disabled:T===`add-url`,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),U())},placeholder:`https://github.com/owner/repository`})]}),(0,o.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!j.trim()||T===`add-url`,onClick:()=>void U(),children:T===`add-url`?`Cloning…`:`Clone & open`})]}),(0,o.jsxs)(`div`,{className:`wb-repos-add-alt`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void c(),children:[(0,o.jsx)(n,{name:`folder`}),`Browse local folder`]}),(0,o.jsxs)(`button`,{type:`button`,className:`button subtle`,onClick:()=>void l(),children:[(0,o.jsx)(n,{name:`website`}),`Try sample project`]}),(0,o.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>A(!1),children:`Cancel`})]}),(0,o.jsxs)(`p`,{className:`field-help`,children:[`Clones shallowly into ignored `,(0,o.jsx)(`code`,{children:`work/repos/`}),` with Git hooks disabled (`,(0,o.jsx)(`code`,{children:`core.hooksPath=/dev/null`}),`) and never runs `,(0,o.jsx)(`code`,{children:`npm install`}),` or build scripts automatically.`]})]}),!Q&&(0,o.jsxs)(`div`,{className:`wb-repos-signin-banner`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`Connect GitHub or GitLab for 1-click repository pull`}),(0,o.jsxs)(`p`,{children:[`Sign in with browser OAuth, local `,(0,o.jsx)(`code`,{children:`gh`}),`/`,(0,o.jsx)(`code`,{children:`glab`}),` CLI, or an access token. Your local projects below remain ready without signing in.`]})]}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,onClick:s,children:Z?`Switch account`:`Sign in`})]}),(N||d?.remoteError)&&(0,o.jsx)(`p`,{className:`error-box`,role:`alert`,children:N||d?.remoteError}),F&&(0,o.jsx)(`p`,{className:`connection-success`,role:`status`,children:F}),z&&(0,o.jsx)(i,{project:z,onClose:()=>B(null)}),L&&(0,o.jsxs)(`section`,{className:`wb-quick-qa-card page-reveal page-reveal--content`,"aria-label":`Quick QA audit summary`,children:[(0,o.jsxs)(`div`,{className:`wb-quick-qa-head`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`h2`,{children:[`Quick Security & UI QA ·`,` `,L.project.split(/[/\\]/).filter(Boolean).at(-1),` ·`,` `,(0,o.jsxs)(`span`,{children:[L.score,`/100`]})]}),(0,o.jsxs)(`p`,{children:[L.summary.securityFindings,` security, `,L.summary.craftFindings,` UI findings · Scanners:`,` `,(0,o.jsx)(`strong`,{children:(L.summary.scannersRun??[`builtin-sast-secrets`]).join(`, `)}),` `,`(read-only, zero scripts executed).`]})]}),(0,o.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>R(null),children:`Dismiss`})]}),L.summary.escalationRequired&&(0,o.jsxs)(`div`,{className:`wb-security-escalation`,role:`alert`,children:[(0,o.jsx)(`strong`,{children:`Escalation required:`}),` Critical or high security issues detected. Open in Studio to review and remediate before shipping.`]}),L.stages&&L.stages.length>0&&(0,o.jsx)(`ul`,{className:`wb-quick-qa-stages`,"aria-label":`4-stage security pipeline`,children:L.stages.map(e=>(0,o.jsxs)(`li`,{"data-status":e.status,children:[(0,o.jsxs)(`span`,{children:[e.order,`. `,e.label]}),(0,o.jsx)(`strong`,{children:e.status.replaceAll(`-`,` `)})]},e.id))}),L.signals&&(0,o.jsx)(`ul`,{className:`wb-qa-signal-strip`,"aria-label":`Quick QA signals`,children:Object.entries(L.signals).map(([e,t])=>{let n=typeof t==`string`?t:t?.status??`not-run`;return(0,o.jsxs)(`li`,{"data-status":n,children:[(0,o.jsx)(`span`,{children:e}),(0,o.jsx)(`strong`,{children:n.replaceAll(`-`,` `)})]},e)})}),L.repairHints.length>0&&(0,o.jsx)(`ul`,{className:`wb-quick-qa-hints`,children:L.repairHints.slice(0,5).map((e,t)=>(0,o.jsxs)(`li`,{"data-severity":e.severity,children:[(0,o.jsx)(`code`,{children:e.code}),e.path&&(0,o.jsxs)(`code`,{translate:`no`,children:[e.path,e.line?`:${e.line}`:``]}),(0,o.jsx)(`span`,{children:e.hint})]},`${e.code}-${t}`))})]}),(0,o.jsxs)(`div`,{className:`wb-repos-toolbar page-reveal page-reveal--controls`,children:[(0,o.jsxs)(`label`,{className:`wb-repos-search`,children:[(0,o.jsx)(n,{name:`search`}),(0,o.jsx)(`input`,{type:`search`,"aria-label":`Search repositories`,placeholder:`Search repositories…`,value:p,onChange:e=>{m(e.target.value),v(1)}})]}),(0,o.jsx)(`div`,{className:`wb-repos-filters`,role:`group`,"aria-label":`Filter repository source`,children:[`all`,`remote`,`local`].map(e=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>g(e),children:e===`all`?`All`:e===`remote`?`Remote`:`Local`},e))})]}),(0,o.jsx)(`div`,{className:`wb-repo-table-wrap page-reveal page-reveal--content`,tabIndex:0,role:`region`,"aria-label":`Repositories table`,children:(0,o.jsxs)(`table`,{className:`wb-repo-table`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`th`,{scope:`col`,children:`Repository`}),(0,o.jsx)(`th`,{scope:`col`,children:`Branch`}),(0,o.jsx)(`th`,{scope:`col`,children:`Local status`}),(0,o.jsx)(`th`,{scope:`col`,children:`Actions`})]})}),(0,o.jsxs)(`tbody`,{children:[X.map(e=>{let n=!!t&&!!e.localPath&&t.toLowerCase()===e.localPath.toLowerCase(),r=T===e.id,i=D===e.id;return(0,o.jsxs)(`tr`,{className:n?`is-active`:void 0,children:[(0,o.jsxs)(`th`,{scope:`row`,children:[(0,o.jsxs)(`div`,{className:`wb-repo-cell-main`,children:[(0,o.jsx)(`span`,{className:`wb-repo-name`,children:e.title}),(0,o.jsx)(`span`,{className:`wb-repo-provider-pill`,children:e.provider}),e.privateRepo&&(0,o.jsx)(`span`,{className:`wb-repo-private-pill`,children:`Private`}),n&&(0,o.jsx)(`span`,{className:`wb-repo-active-pill`,children:`Active`})]}),(0,o.jsx)(`small`,{className:`wb-repo-sub`,title:e.subtitle,children:e.subtitle})]}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`code`,{className:`wb-repo-branch`,children:e.branch})}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`span`,{className:`wb-repo-status`,"data-tone":e.statusTone,children:e.statusLabel})}),(0,o.jsxs)(`td`,{className:`wb-repo-actions`,children:[(0,o.jsx)(`button`,{type:`button`,className:`button primary`,disabled:r||i,onClick:()=>{e.remote?H(e.remote):e.localPath&&u(e.localPath)},children:r?`Pulling…`:`Open in Studio`}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:r||i,onClick:()=>void W(e),children:i?`Auditing…`:`Quick QA`}),e.localPath&&(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:r||i,onClick:()=>B(t=>t===e.localPath?null:e.localPath),children:z===e.localPath?`Close Diff`:`Visual Diff`})]})]},e.id)}),!x&&X.length===0&&(0,o.jsx)(`tr`,{children:(0,o.jsxs)(`td`,{colSpan:4,className:`wb-repo-empty`,children:[`No repositories found. Click `,(0,o.jsx)(`strong`,{children:`Add Repository`}),` to clone a URL, browse a local folder, or try the sample project.`]})})]})]})}),Q&&(d?.pagination.total??0)>0&&(0,o.jsxs)(`footer`,{className:`wb-repos-pagination`,children:[(0,o.jsxs)(`span`,{children:[`Showing page `,d.pagination.page,` of `,d.pagination.totalPages,` (`,d.pagination.total,` remote)`]}),(0,o.jsxs)(`div`,{className:`wb-repos-pagination-controls`,children:[(0,o.jsxs)(`label`,{htmlFor:`repo-page-size`,children:[`Per page`,(0,o.jsxs)(`select`,{id:`repo-page-size`,value:y,onChange:e=>{let t=Number(e.target.value);b(t),v(1)},children:[(0,o.jsx)(`option`,{value:10,children:`10`}),(0,o.jsx)(`option`,{value:25,children:`25`}),(0,o.jsx)(`option`,{value:50,children:`50`})]})]}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:_<=1||x,onClick:()=>v(e=>Math.max(1,e-1)),children:`Previous`}),(0,o.jsx)(`button`,{type:`button`,className:`button subtle`,disabled:_>=(d?.pagination.totalPages??1)||x,onClick:()=>v(e=>e+1),children:`Next`})]})]})]})}export{s as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,t}from"./react-vendor-CH5vucNG.js";import{c as n,f as r,p as i}from"./index-
|
|
1
|
+
import{i as e,t}from"./react-vendor-CH5vucNG.js";import{c as n,f as r,p as i}from"./index-Dp8CdAV4.js";/* empty css */var a=e();function o(e,t){let n=e.split(`
|
|
2
2
|
`),r=t.split(`
|
|
3
3
|
`),i=[];function a(e,t,o,s,c){for(;e<t&&o<s&&n[e]===r[o];)i.push({kind:`same`,text:n[e++]}),o++;let l=0;for(;e<t-l&&o<s-l&&n[t-1-l]===r[s-1-l];)l++;let u=t-l,d=s-l,f=new Map,p=new Map;for(let t=e;t<u;t++)f.set(n[t],[...(f.get(n[t])??[]).slice(0,1),t]);for(let e=o;e<d;e++)p.set(r[e],[...(p.get(r[e])??[]).slice(0,1),e]);let m=[];for(let t=e;t<u;t++){let e=f.get(n[t]),r=p.get(n[t]);e?.length===1&&r?.length===1&&m.push([t,r[0]])}let h=[],g=Array(m.length).fill(-1);for(let e=0;e<m.length;e++){let t=0,n=h.length;for(;t<n;){let r=t+n>>1;m[h[r]][1]<m[e][1]?t=r+1:n=r}t&&(g[e]=h[t-1]),h[t]=e}let _=[];for(let e=h.at(-1)??-1;e>=0;e=g[e])_.unshift(m[e]);if(_.length&&c<24){for(let[t,r]of _)a(e,t,o,r,c+1),i.push({kind:`same`,text:n[t]}),e=t+1,o=r+1;a(e,u,o,d,c+1)}else{for(let t=e;t<u;t++)i.push({kind:`remove`,text:n[t]});for(let e=o;e<d;e++)i.push({kind:`add`,text:r[e]})}for(let e=0;e<l;e++)i.push({kind:`same`,text:n[t-l+e]})}a(0,n.length,0,r.length,0);let o=0,s=0;return i.map(e=>({...e,oldLine:e.kind===`add`?null:++o,newLine:e.kind===`remove`?null:++s}))}function s(e,t=3){let n=new Set;for(let r=0;r<e.length;r++)if(e[r].kind!==`same`)for(let i=Math.max(0,r-t);i<=Math.min(e.length-1,r+t);i++)n.add(i);let r=[],i=0;for(let t=0;t<e.length;t++)n.has(t)?(i&&=(r.push({kind:`skip`,count:i}),0),r.push(e[t])):i++;return i&&r.push({kind:`skip`,count:i}),r}var c=t(),l=24576;function u(e,t){let n=o(e,t),r=s(n),i=0,a=0;for(let e of n)e.kind===`add`?i++:e.kind===`remove`&&a++;return{lines:n,visibleLines:r,added:i,removed:a}}var d=/(?:\/\/.*|\/\*.*?\*\/|<!--.*?-->|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|<\/?[A-Za-z][\w.-]*|\b(?:const|let|var|function|return|import|export|from|default|class|extends|new|if|else|for|while|async|await|throw|try|catch|interface|type|void|true|false|null|undefined)\b|\b\d+(?:\.\d+)?\b|\b[A-Za-z_$][\w$]*(?=\s*\())/g;function f(e){let t=[],n=0;for(let r of e.matchAll(d)){let i=r[0],a=r.index;t.push(e.slice(n,a));let o=`function`;/^(?:\/\/|\/\*|<!--)/.test(i)?o=`comment`:/^["'`]/.test(i)?o=`string`:/^</.test(i)?o=`tag`:/^\d/.test(i)?o=`number`:/^(?:const|let|var|function|return|import|export|from|default|class|extends|new|if|else|for|while|async|await|throw|try|catch|interface|type|void|true|false|null|undefined)$/.test(i)&&(o=`keyword`),t.push((0,c.jsx)(`span`,{className:`syntax-`+o,children:i},a)),n=a+i.length}return t.push(e.slice(n)),t}function p(e){return e.replace(/^(?:CRAFT|SEC|A11Y)_/i,``).replaceAll(`_`,` `).toLowerCase().replace(/\b(?:tw4|tailwind v4)\b/gi,`Tailwind v4`).replace(/\b(?:css|html|aria|dom|xss|svg|url|api|csp)\b/gi,e=>e.toUpperCase()).replace(/^\w/,e=>e.toUpperCase())}function m(e){let t=e.totalAdded+e.totalRemoved,n=e.files.reduce((e,t)=>e+t.findings.length,0),r=1;(e.fileCount>=2||t>=40)&&(r=2),(e.fileCount>=4||t>=150||e.riskLevel===`medium`)&&(r=3),(e.fileCount>=7||t>=350||n>=3)&&(r=4),(e.riskLevel===`high`||t>=700||n>=6)&&(r=5);let i=Math.max(1,Math.min(20,Math.round(e.fileCount*.7+t/85+n*.8)));return{score:r,minutes:i}}function h({content:e,active:t,onFixFinding:i}){let[o,s]=(0,a.useState)(``),[d,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(null),[v,ee]=(0,a.useState)(`all`),y=(0,a.useMemo)(()=>e.proposal?.changes??[],[e.proposal]),b=y.find(e=>e.path===o)??y[0],te=b?y.findIndex(e=>e.path===b.path)+1:0,x=b?e.request.files.find(e=>e.path===b.path)?.content??``:``,S=b?b.encoding===`base64`?`Binary asset`:b.content:``,C=!!b&&x.length+S.length>=l&&typeof Worker<`u`,w=(0,a.useMemo)(()=>!b||C?{lines:[],visibleLines:[],added:0,removed:0}:u(x,S),[b,C,x,S]),[T,E]=(0,a.useState)(null),D=(0,a.useRef)(null),ne=(0,a.useRef)(0),O=b?`${b.path}:${x.length}:${S.length}`:``;(0,a.useEffect)(()=>()=>{D.current?.terminate(),D.current=null},[]),(0,a.useEffect)(()=>{if(!C||!b)return;let e=!1,t=++ne.current;try{D.current||=new Worker(new URL(`/assets/line-diff.worker-DCByNTSg.js`,``+import.meta.url),{type:`module`});let n=D.current,r=n=>{e||n.data.id!==t||E({key:O,visibleLines:n.data.visibleLines,added:n.data.added,removed:n.data.removed})},i=()=>{if(e)return;let t=u(x,S);E({key:O,visibleLines:t.visibleLines,added:t.added,removed:t.removed})};return n.addEventListener(`message`,r),n.addEventListener(`error`,i),n.postMessage({id:t,before:x,after:S}),()=>{e=!0,n.removeEventListener(`message`,r),n.removeEventListener(`error`,i)}}catch{let e=u(x,S);E({key:O,visibleLines:e.visibleLines,added:e.added,removed:e.removed})}},[C,b,O,x,S]);let k=!C||T?.key===O,A=C?T?.key===O?T.visibleLines:[]:w.visibleLines,j=C?T?.key===O?T.added:0:w.added,M=C?T?.key===O?T.removed:0:w.removed,N=(0,a.useMemo)(()=>k?A.map((e,t)=>e.kind===`skip`?(0,c.jsxs)(`div`,{className:`wb-diff-skip`,children:[e.count,` unchanged `,e.count===1?`line`:`lines`]},t):(0,c.jsxs)(`div`,{className:`wb-diff-line `+e.kind,children:[(0,c.jsx)(`span`,{className:`wb-line-number`,"aria-hidden":`true`,children:e.oldLine}),(0,c.jsx)(`span`,{className:`wb-line-number`,"aria-hidden":`true`,children:e.newLine}),(0,c.jsx)(`span`,{className:`wb-line-sign`,"aria-hidden":`true`,children:e.kind===`add`?`+`:e.kind===`remove`?`−`:` `}),(0,c.jsx)(`code`,{children:e.text?f(e.text):` `})]},t)):(0,c.jsx)(`div`,{className:`wb-diff-skip`,children:`Computing large file diff…`}),[k,A]),P=y.length>1,F=j+M,I=F?Math.round(j/F*5):0,L=Array.from({length:5},(e,t)=>F?t<I?`add`:`remove`:`none`);function R(e){if(!P||!b)return;let t=y.findIndex(e=>e.path===b.path);s(y[(t+e+y.length)%y.length].path)}if((0,a.useEffect)(()=>{if(!t||!P||!b)return;let e=b.path;function n(t){if(t.key!==`[`&&t.key!==`]`||t.metaKey||t.ctrlKey||t.altKey||t.defaultPrevented||t.target?.closest(`input, textarea, select, [contenteditable="true"], [role="listbox"]`)||document.querySelector(`dialog[open]`))return;t.preventDefault();let n=y.findIndex(t=>t.path===e),r=t.key===`]`?1:-1;s(y[(n+r+y.length)%y.length].path)}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,P,b?.path,y]),!b)return(0,c.jsx)(`p`,{children:`No source changes are available.`});async function z(){let e=A.map(e=>e.kind===`skip`?`@@ ... ${e.count} unchanged lines ... @@`:`${e.kind===`add`?`+`:e.kind===`remove`?`-`:` `} ${e.text}`).join(`
|
|
4
4
|
`);await navigator.clipboard?.writeText(`--- a/${b.path}\n+++ b/${b.path}\n${e}`),h(!0),window.setTimeout(()=>h(!1),1800)}let B=e.reviewSummary??null,V=(0,a.useMemo)(()=>B?m(B):null,[B]),H=B?.files.find(e=>e.path===b.path)??null,U=(0,a.useMemo)(()=>{let e=H?.findings??[];return v===`security`?e.filter(e=>e.category===`security`):v===`craft`?e.filter(e=>e.category!==`security`):e},[H,v]);function re(e,t){let n=t.line?`${e}:${t.line}`:e;return`Fix [${t.code}] (${t.severity}) in ${n}: ${t.action}`}async function ie(e,t){await navigator.clipboard?.writeText(t).catch(()=>{}),_(e),window.setTimeout(()=>_(t=>t===e?null:t),1800)}return(0,c.jsxs)(`div`,{className:`wb-diff`,children:[B&&(0,c.jsxs)(`section`,{className:`wb-review-summary`,"aria-label":`Change explanation`,children:[(0,c.jsxs)(`div`,{className:`wb-review-summary-head`,children:[(0,c.jsxs)(`div`,{className:`wb-review-summary-title`,children:[(0,c.jsx)(`strong`,{children:`Walkthrough & diff review`}),(0,c.jsxs)(`span`,{className:`wb-diff-badge`,children:[B.fileCount,` `,B.fileCount===1?`file`:`files`,` · +`,B.totalAdded,` / −`,B.totalRemoved]}),V&&(0,c.jsxs)(`span`,{className:`wb-diff-badge wb-effort-badge`,title:`Estimated human review effort based on files, changed lines, and detected issues`,children:[`Effort `,V.score,`/5 · ~`,V.minutes,`m`]}),(0,c.jsx)(`span`,{className:`wb-review-risk`,"data-risk":B.riskLevel,children:B.riskLevel===`high`?`High risk`:B.riskLevel===`medium`?`Review notes`:`Low risk`}),B.audit&&(0,c.jsxs)(`span`,{className:`wb-diff-badge`,children:[`QA `,B.audit.score,`/100 · `,B.audit.securityFindings,` `,`security`]})]}),B.summary&&(0,c.jsx)(`p`,{children:B.summary})]}),B.files.length>1&&(0,c.jsx)(`div`,{className:`wb-review-file-chips`,role:`group`,"aria-label":`Jump to file walkthrough`,children:B.files.map(e=>(0,c.jsxs)(`button`,{type:`button`,className:`wb-review-file-chip`,"aria-pressed":e.path===b.path,onClick:()=>s(e.path),children:[(0,c.jsx)(`span`,{className:`wb-chip-risk-dot`,"data-risk":e.riskLevel,"aria-hidden":`true`}),(0,c.jsx)(`span`,{children:e.path}),(0,c.jsxs)(`span`,{className:`wb-review-chip-role`,children:[`+`,e.added,`/−`,e.removed]})]},e.path))}),H&&(0,c.jsxs)(`div`,{className:`wb-review-file-card`,children:[(0,c.jsxs)(`div`,{className:`wb-review-file-meta`,children:[(0,c.jsx)(`code`,{translate:`no`,children:H.path}),(0,c.jsx)(`span`,{className:`wb-diff-badge`,children:H.role}),(0,c.jsx)(`span`,{className:`wb-review-risk`,"data-risk":H.riskLevel,children:H.findings.length?`${H.findings.length} ${H.findings.length===1?`issue`:`issues`}`:`No issues found`}),U.length>0&&(0,c.jsx)(`button`,{type:`button`,className:`text-button wb-copy-all-prompts`,onClick:()=>void ie(`all-file`,[`Fix these ${U.length} issue${U.length===1?``:`s`} in ${H.path}:`,...U.map((e,t)=>`${t+1}. ${re(H.path,e)}`)].join(`
|