import type {Meta, StoryObj} from '@storybook/angular';
import {moduleMetadata} from '@storybook/angular';
import {NewInput} from './new-input';
import {CommonModule} from '@angular/common';
import {PromptInput} from '../prompt-input/prompt-input';
import {ToolsOptions} from '../tools-options/tools-options';
import {Store, StoreModule} from '@ngrx/store';
import {reducers} from '../../reducers';
import {HttpClientModule} from '@angular/common/http';
import {ApiService} from '../../services/api-service';
import {FormsModule} from '@angular/forms';

const appReducer = reducers.app;

const meta: Meta<NewInput> = {
  title: 'Chatbot/Input/NewInput',
  component: NewInput,
  tags: ['autodocs'],
  decorators: [
    moduleMetadata({
      imports: [
        CommonModule,
        FormsModule,
        PromptInput,
        ToolsOptions,
        HttpClientModule,
        StoreModule.forRoot({app: appReducer as any})
      ],
      providers: [
        ApiService,
        Store
      ]
    })
  ],
  parameters: {
    backgrounds: {
      default: 'light',
      values: [
        {name: 'light', value: '#f5f5f5'},
        {name: 'dark', value: '#333'},
      ],
    },
  }
};

export default meta;
type Story = StoryObj<NewInput>;

export const Default: Story = {
  args: {
    // Propriétés par défaut
  }
};

export const DarkTheme: Story = {
  args: {
    // Propriétés par défaut
  },
  parameters: {
    backgrounds: {default: 'dark'},
    store: {
      init: (store: Store) => {
        store.dispatch({
          type: 'UPDATE_APP',
          payload: {
            theme: 'dark'
          }
        });
      }
    }
  }
};
