// engine/detectors/advanced-framework-hints.ts — SPEC-017b
// Contract hints generation from advanced framework detection results.
/**
 * Generate contract hints and criteria suggestions from advanced detection results.
 */
export function buildAdvancedFrameworkHints(detection) {
    const hints = {};
    const hintsWithArch = applyArchitectureHints(hints, detection);
    Object.assign(hints, hintsWithArch);
    if (detection.legacyFrameworks.length > 0) {
        hints.legacyRisks = buildLegacyRisks(detection.legacyFrameworks);
        hints.migrationCriteria =
            'Include a criterion for coexistence plan or incremental migration strategy.';
    }
    if (detection.stateManagement.length > 0) {
        hints.stateStrategyNotes = buildStateManagementNotes(detection.stateManagement);
    }
    if (detection.enterpriseDesignSystem) {
        hints.designSystemTokens = buildDesignSystemTokenHints(detection.enterpriseDesignSystem);
    }
    if (detection.cssInJS) {
        hints.cssPatterns = buildCSSInJSPatternHints(detection.cssInJS);
    }
    return hints;
}
function applyArchitectureHints(hints, detection) {
    const result = { ...hints };
    if (detection.architecture === 'islands') {
        result.architectureParadigm =
            'Islands Architecture: distinguish server-rendered (static HTML) from interactive islands';
        result.hydrationNotes =
            'Specify which islands require hydration and why. Prefer server-rendered for static content.';
        return result;
    }
    if (detection.architecture === 'htmx') {
        result.architectureParadigm =
            'HTMX: server-centric partial HTML exchange (hx-get, hx-post, hx-swap, hx-target)';
        result.hydrationNotes = 'No SPA client state. Server returns HTML fragments, not JSON.';
        return result;
    }
    if (detection.architecture === 'resumability') {
        result.architectureParadigm = 'Resumability (QwikCity): lazy execution by default';
        result.hydrationNotes =
            'Define which code runs on server vs client. Lazy load all event handlers.';
        return result;
    }
    if (detection.modernFramework === 'remix-v7') {
        result.architectureParadigm = 'Remix v7 / React Router v7: loader/action server-first paradigm';
        result.hydrationNotes = 'Specify what logic goes in loader vs action vs component.';
        return result;
    }
    if (detection.modernFramework === 'tanstack-start') {
        result.architectureParadigm =
            'TanStack Start: type-safe routing with Route.useParams() and Route.useLoaderData()';
        result.hydrationNotes = 'Use server functions and loader patterns for data fetching.';
        return result;
    }
    if (detection.modernFramework === 'solid-start') {
        result.architectureParadigm = 'SolidStart: fine-grained reactivity with Signals';
        result.hydrationNotes =
            'Use createSignal, createMemo, createEffect — distinguish reactive primitives from component state.';
    }
    return result;
}
function buildLegacyRisks(frameworks) {
    const riskMap = {
        jquery: 'jQuery: risk of event namespace collision and conflicts with jQuery plugins',
        backbone: 'Backbone.js: define plan for Views, Models, Collections coexistence',
        knockout: 'Knockout.js: ensure compatibility with existing ko.applyBindings',
        ember: 'Ember Octane: follow Glimmer components, tracked properties, modifiers',
        extjs: 'Ext JS: vendor lock-in risk + licensing cost — document explicitly',
        'angularjs-1': 'AngularJS 1.x: EOL since 2021 — security risk, migration plan required',
    };
    return frameworks.map((fw) => riskMap[fw]);
}
function buildStateManagementNotes(libs) {
    const notesMap = {
        'tanstack-query': 'TanStack Query: server state only (useQuery, useMutation). Define query key strategy and staleTime/gcTime.',
        zustand: 'Zustand: define store slice (actions, selectors, persisted state).',
        jotai: 'Jotai: define atoms (local vs global, derived atoms with atom()).',
        xstate: 'XState: define state machine (states, transitions, guards, actions, actors).',
        signals: 'Signals: use correct API per framework (Angular/Preact/Solid/Vue).',
        nanostores: 'Nanostores: define cross-island vs local atoms/maps/computed.',
    };
    return libs.map((lib) => notesMap[lib]).join(' | ');
}
function buildDesignSystemTokenHints(ds) {
    const tokenHints = {
        carbon: [
            'Use Carbon tokens: color $carbon--blue-60, spacing $spacing-05, type $productive-heading-03',
            'Specify Carbon theme: White, G10, G90, or G100',
        ],
        polaris: [
            'Use Polaris ActionList patterns and components',
            'Verify Polaris a11y compliance and Embedded App guidelines',
        ],
        'fluent-ui': [
            'Use Fluent tokens: colorNeutralBackground1, spacingHorizontalM',
            'Distinguish Fluent v8 (classic React) vs v9 (Web Components-based)',
        ],
        'radix-ui': [
            'Follow Radix composition: Root > Trigger > Content > Item pattern',
            'Radix provides built-in a11y — do NOT reimplement ARIA',
        ],
        'arco-design': [
            'Use Arco Design tokens and ConfigProvider for global theme',
            'Follow Arco component naming conventions',
        ],
        'ark-ui': [
            'Ark UI is headless: Root, Control, Label, Input pattern',
            'Project is responsible for styling layer — Ark handles behavior and a11y',
        ],
        'naive-ui': ['Use Naive UI theme tokens and n-config-provider for theming'],
        vuetify: ['Use Vuetify Material Design tokens and v-* props'],
        quasar: ['Use Quasar utility classes and q-* components'],
    };
    return tokenHints[ds];
}
function buildCSSInJSPatternHints(approach) {
    const patterns = {
        'vanilla-extract': [
            'Type-safe CSS in *.css.ts files using styleVariants() and recipe()',
            'Use createGlobalTheme() for design token contracts',
            'Zero-runtime — compiled to static CSS at build time',
        ],
        'panda-css': [
            'Use css(), cva() and tokens from panda.config.ts',
            'Define in which CSS layer: base, component, or recipe',
            'Static extraction at build time — no runtime overhead',
        ],
        stylex: [
            'Use stylex.create() for local styles, stylex.props() to apply',
            'Shared tokens via stylex.defineVars() — specify local vs shared',
            'Zero-runtime — compile-time CSS extraction',
        ],
        unocss: [
            'Use active preset (preset-uno, preset-wind, preset-mini)',
            'Check if attributify mode is enabled',
            'preset-wind: same utility classes as Tailwind CSS',
        ],
        'open-props': [
            'Use CSS custom properties: --blue-5, --size-3, --font-size-3',
            'Always use Open Props vars instead of hardcoded values',
        ],
        'css-layers': [
            'Define in which @layer new code belongs: base, components, or utilities',
            'Risk: unexpected specificity if styles placed in wrong layer',
        ],
    };
    return patterns[approach];
}
//# sourceMappingURL=advanced-framework-hints.js.map