/**
* `live-accept` corpus: argument paths, HTML and JSX accept/discard
* (carbonize output, param baking inputs), receipts, lock contention,
* generated-file fallback, buffer scrub, and the Svelte component path
* (wrap with the linked compiler, then accept/discard the stub variant).
*/
import fs from 'node:fs';
import path from 'node:path';
import {
LIVE_FILES, linkSvelte, lockPathFor, stageWrappedHtml, stageWrappedJsx, write, writeBuffer,
} from '../live-helpers.mjs';
const F = LIVE_FILES;
const HTML = [...F, 'index.html'];
const JSX = [...F, 'src/**'];
const A = (id, workspace, args, extra = {}) => ({ id, verb: 'live-accept', workspace, args, files: [...F, ...(extra.snap || [])], ...extra });
const ID = 'ab12cd34';
export default [
A('live-accept-help', 'live-html', ['--help']),
A('live-accept-missing-id', 'live-html', ['--variant', '1']),
A('live-accept-invalid-id', 'live-html', ['--id', '../etc', '--variant', '1']),
A('live-accept-need-mode', 'live-html', ['--id', ID]),
A('live-accept-invalid-variant', 'live-html', ['--id', ID, '--variant', '1a']),
A('live-accept-invalid-variant-regex', 'live-html', ['--id', ID, '--variant', '.*']),
A('live-accept-markers-not-found', 'live-html', ['--id', 'nothere1', '--variant', '1']),
A('live-accept-target-missing-value', 'live-html', ['--id', ID, '--variant', '1', '--target']),
// --- HTML source-preview accept / discard ---
A('live-accept-html-variant-1-range', 'live-html', ['--id', ID, '--variant', '1', '--param-values', '{"lightness":0.65}'], { snap: ['index.html'], setup: stageWrappedHtml }),
A('live-accept-html-variant-2-steps', 'live-html', ['--id', ID, '--variant', '2', '--param-values', '{"face":"serif"}'], { snap: ['index.html'], setup: stageWrappedHtml }),
A('live-accept-html-variant-3-toggle', 'live-html', ['--id', ID, '--variant', '3', '--param-values', '{"italic":true}'], { snap: ['index.html'], setup: stageWrappedHtml }),
A('live-accept-html-no-params', 'live-html', ['--id', ID, '--variant', '2'], { snap: ['index.html'], setup: stageWrappedHtml }),
A('live-accept-html-malformed-params', 'live-html', ['--id', ID, '--variant', '1', '--param-values', '{bad'], { snap: ['index.html'], setup: stageWrappedHtml }),
A('live-accept-html-variant-missing', 'live-html', ['--id', ID, '--variant', '9'], { snap: ['index.html'], setup: stageWrappedHtml }),
A('live-accept-html-discard', 'live-html', ['--id', ID, '--discard'], { snap: ['index.html'], setup: stageWrappedHtml }),
A('live-accept-html-receipt-replay', 'live-html', ['--id', ID, '--variant', '1'], { snap: ['index.html'], setup: stageWrappedHtml, steps: [{}, {}] }),
A('live-accept-html-receipt-conflict', 'live-html', [], { snap: ['index.html'], setup: stageWrappedHtml, steps: [{ args: ['--id', ID, '--variant', '1'] }, { args: ['--id', ID, '--variant', '2'] }, { args: ['--id', ID, '--discard'] }] }),
A('live-accept-html-discard-then-accept', 'live-html', [], { snap: ['index.html'], setup: stageWrappedHtml, steps: [{ args: ['--id', ID, '--discard'] }, { args: ['--id', ID, '--variant', '1'] }] }),
A('live-accept-html-no-css-block', 'live-html', ['--id', ID, '--variant', '2'], {
snap: ['index.html'],
setup: (ws) => {
stageWrappedHtml(ws);
const p = path.join(ws, 'index.html');
fs.writeFileSync(p, fs.readFileSync(p, 'utf8').replace(/ {8}\n');
fs.writeFileSync(path.join(dir, 'params.json'), JSON.stringify({ 2: [
{ id: 'lead', kind: 'range', min: 1, max: 2, step: 0.1, default: 1.2, label: 'Lead' },
{ id: 'density', kind: 'steps', default: 'airy', label: 'Density', options: [{ value: 'airy', label: 'Airy' }, { value: 'snug', label: 'Snug' }] },
] }, null, 2));
},
},
],
},
{
id: 'live-accept-svelte-component-discard', workspace: 'live-sveltekit', files: [...F, 'src/**'], setup: linkSvelte,
steps: [
{ verb: 'live-wrap', args: ['--id', ID, '--classes', 'expense-list', '--tag', 'ul'] },
{ verb: 'live-accept', args: ['--id', ID, '--discard'] },
{ verb: 'live-accept', args: ['--id', ID, '--discard'] },
],
},
{
id: 'live-accept-svelte-component-variant-missing', workspace: 'live-sveltekit', files: [...F, 'src/**'], setup: linkSvelte,
steps: [
{ verb: 'live-wrap', args: ['--id', ID, '--classes', 'hero-title', '--tag', 'h1'] },
{ verb: 'live-accept', args: ['--id', ID, '--variant', '7'] },
],
},
{
id: 'live-accept-svelte-insert-empty-variant', workspace: 'live-sveltekit', files: [...F, 'src/**'],
steps: [
{ verb: 'live-insert', args: ['--id', ID, '--position', 'after', '--element-id', 'features'] },
{ verb: 'live-accept', args: ['--id', ID, '--variant', '1'] },
],
},
{
id: 'live-accept-svelte-fallback-source-wrapper', workspace: 'live-sveltekit', files: [...F, 'src/**'],
// No compiler: wrap wrote a plain source wrapper into the .svelte route.
steps: [
{ verb: 'live-wrap', args: ['--id', ID, '--classes', 'hero-title', '--tag', 'h1'] },
{ verb: 'live-accept', args: ['--id', ID, '--discard'] },
],
},
];