var _a, _b, _c;
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
import { styles } from './main.styles';
// CSS is not otherwise unit-tested in this package, so this covers the two
// properties of the BLOCKED BANNER that are cheap to assert from the generated
// text and that a reviewer had to catch by eye:
//
//   1. Design-system tokens are consumed UNFALLBACKED, as every other rule in the
//      file does. A `var(--token, fallback)` here is dead code at best — both
//      tokens below ship with defaults — and actively wrong at worst: the blocked
//      banner's old `var(--neutral-layer-2, transparent)` would, if it ever fired,
//      have produced a banner with no surface at all.
//   2. The blocked banner's visual treatment hangs off `.is-visible`, not the bare
//      class, because the container stays mounted while unblocked so that its
//      `role="status"` region is registered before the text arrives (see
//      main.template.ts). Collapsing the empty container would undo that.
//
// Scope: the banner's own rules, and nothing else. Both negative assertions were
// written for one component, but an earlier version grepped the WHOLE stylesheet
// — quietly turning a banner test into a global style policy nobody agreed to, so
// any future rule anywhere in an 800-line sheet that legitimately wanted a
// fallback on either token would have failed a test named after the banner.
const suite = createLogicSuite('main.styles blocked-banner rules');
/**
 * The generated stylesheet text. `css` composes nested `ElementStyles` (this file
 * builds the sheet from several partials), so flatten recursively rather than
 * only reading the top level — a shallow read silently returns almost nothing,
 * which would make every `assert.not.ok` below pass vacuously. The first test
 * guards exactly that.
 */
const flatten = (value) => {
    if (typeof value === 'string')
        return value;
    if (Array.isArray(value))
        return value.map(flatten).join('\n');
    const nested = value === null || value === void 0 ? void 0 : value.styles;
    return nested ? flatten(nested) : '';
};
const cssText = flatten(styles);
/**
 * Every declaration block whose selector mentions `.blocked-banner`, joined.
 *
 * Deliberately crude — one regex over the generated text, no CSS parser — but
 * enough to keep these assertions about the banner rather than about the whole
 * sheet, which was the only thing wrong with them. It matches
 * `<selector> { <declarations> }` for any selector containing `.blocked-banner`,
 * so it picks up the bare class, the `.is-visible` / `.is-partial` modifiers, the
 * shared composer-width group and the copy inside the container query alike.
 */
const bannerRules = ((_a = cssText.match(/[^{}]*\.blocked-banner[^{}]*\{[^}]*\}/g)) !== null && _a !== void 0 ? _a : []).join('\n');
/** Declarations of the bare-class rule — the one that applies while empty. */
const emptyStateRule = (_c = (_b = cssText.match(/[\s{}](\.blocked-banner)\s*\{([^}]*)\}/)) === null || _b === void 0 ? void 0 : _b[2]) !== null && _c !== void 0 ? _c : '';
suite('the banner rules were extracted as text (guards the assertions below)', () => {
    assert.ok(cssText.includes('.blocked-banner'), 'the banner rules are in the sheet');
    assert.ok(bannerRules.includes('.is-visible'), 'the extraction found the modifier rules');
    assert.ok(emptyStateRule.length > 0, 'and isolated the bare-class rule');
});
suite('the banner consumes design-system tokens without dead fallbacks', () => {
    assert.not.ok(bannerRules.includes('var(--neutral-layer-2,'), '--neutral-layer-2 has a DS default and is used unfallbacked everywhere else here');
    assert.not.ok(bannerRules.includes('var(--warning-color,'), '--warning-color has a DS default and is used unfallbacked by toast/badge styles');
});
suite('the blocked banner keeps its unblocked container visually inert', () => {
    // `::part(blocked-banner)` matches at all times, so the empty state must set
    // nothing that reserves space — and must not remove the container from the
    // accessibility tree, which is where the `role="status"` region is registered.
    //
    // Asserted against the bare-class rule's own declarations rather than by
    // grepping for a `:empty` selector nobody wrote: this catches the mistake as it
    // would actually be made — a padding or border creeping onto the always-present
    // container — instead of one specific spelling of it.
    //
    // `margin-block` rather than `margin`: the shared composer-width group sets
    // `margin-inline: auto` on the banner along with the rest of the composer
    // column, which centres it and reserves nothing.
    assert.ok(cssText.includes('.blocked-banner.is-visible'), 'visuals hang off is-visible');
    for (const property of ['display: none', 'padding', 'border', 'background', 'margin-block']) {
        assert.not.ok(emptyStateRule.includes(property), `the always-present container must not set ${property} — that is .is-visible's job`);
    }
});
suite('the visible banner hands its end margin to the resize handle', () => {
    // Reviewer's manual-testing note: the banner's block-end margin plus the 7px
    // handle stacked into a gap the hover pill was NOT centred in (it centres in
    // the handle alone). The adjacency rule collapses the two so the handle IS
    // the gap. What gets pinned is the INVARIANT, not the selector's existence:
    // both rules must read the ONE shared token, because the cancellation only
    // works while the banner's margin and the handle's pull are equal-and-
    // opposite — two hand-kept magnitudes ~80 lines apart regress silently, and
    // an existence-only assertion stayed green while they did.
    assert.ok(/:host\s*\{[^}]*--blocked-banner-gap:/.test(cssText), 'the shared gap token is declared on the host (a sibling cannot read one on the banner)');
    assert.ok(/\.blocked-banner\.is-visible\s*\{[^}]*margin-block:\s*var\(--blocked-banner-gap\)/.test(cssText), "the banner's block margin IS the token");
    assert.ok(/\.blocked-banner\.is-visible \+ \.composer-resize-handle\s*\{[^}]*margin-block-start:\s*calc\(var\(--blocked-banner-gap\) \* -1\)/.test(cssText), 'and the handle pulls up by exactly that token, negated — equal and opposite by construction');
});
suite('partial exhaustion has its own modifier, layered on the visible state', () => {
    // `.is-visible` carries the layout and surface for BOTH states; `.is-partial`
    // only softens it. Additive, never a replacement — so host CSS keyed on the
    // visible state needs to know nothing about partial exhaustion.
    assert.ok(cssText.includes('.blocked-banner.is-partial'), 'the partial modifier exists');
});
suite.run();
