import type {Preview} from '@storybook/react';
import {themes} from 'storybook/theming';
import {wd} from 'paths.macro';

const preview: Preview = {
  parameters: {
    // a11y overrides (unchanged)
    a11y: {
      config: {
        rules: [
          {id: 'landmark-one-main', enabled: false},
          {id: 'meta-viewport', enabled: false},
          {id: 'page-has-heading-one', enabled: false},
        ],
      },
    },
    controls: {disableSaveFromUI: true},
    backgrounds: {
      values: [
        {name: 'Dark', value: '#000'},
        {name: 'Light', value: '#fff'},
      ],
    },
    docs: {
      theme: themes.light,
      codePanel: true as any, // SB typing doesn't include this flag; keep behavior
    },
    Canvas: {
      theme: themes.light,
    },
    storySource: {
      repository: 'https://github.com/Spaced-Out/ui-design-system',
      workingDir: wd,
      branch: 'master',
    } as any, // non-standard param your addon reads; keep with loose typing
    options: {
      storySort: {
        method: 'alphabetical',
        order: [
          'Introduction',
          'Changelog',
          'Usage',
          'Contribution',
          'Design Tokens',
          'Tokens',
          'Components',
          'Form Components',
          '*',
        ],
        locales: 'en-US',
      },
    },
  },
  globalTypes: {
    theme: {
      name: 'Theme',
      description: 'Global theme for components',
      defaultValue: 'dark',
      toolbar: {
        icon: 'circlehollow',
        items: ['light', 'dark'],
      },
    },
  },
};

export default preview;
