import type { Meta, StoryObj } from '../../story.types';
import { HlmPasswordStrength } from './hlm-password-strength.component';

type Story = StoryObj<HlmPasswordStrength>;

const fullRules = {
  minLength: 8,
  digit: true,
  specialCharacter: true,
  lowerCase: true,
  upperCase: true,
};

const meta: Meta<HlmPasswordStrength> = {
  title: '@aurora/components/hlm-password-strength',
  component: HlmPasswordStrength,
  tags: ['autodocs'],
  argTypes: {
    password: {
      control: 'text',
      description:
        'Candidate password being evaluated. Empty string is allowed and renders all rules as pending.',
    },
    rules: {
      control: 'object',
      description:
        'Active rules. Only rules with truthy entries are displayed. `minLength` is the only rule that takes a numeric threshold; others are boolean activations.',
    },
  },
  args: {
    password: '',
    rules: fullRules,
  },
  parameters: {
    aurora: {
      category: 'form',
      when: 'Visualize how many active password rules a candidate password satisfies. Pair with `passwordRulesValidator` from `@aurora/validators` (which produces matching error keys).',
      whenNot:
        'Not a validator itself — UI-only. Real validation belongs to the form control (`Validators.minLength`, `passwordRulesValidator`).',
    },
  },
};

export default meta;

export const Empty: Story = {
  args: {
    password: '',
    rules: fullRules,
  },
  name: 'Empty (0% — pending)',
};

export const Partial25: Story = {
  args: {
    password: 'abc',
    rules: fullRules,
  },
  name: 'Partial 25% (only lowercase)',
};

export const Partial60: Story = {
  args: {
    password: 'abcAbc12',
    rules: fullRules,
  },
  name: 'Partial 60% (no special character)',
};

export const Complete: Story = {
  args: {
    password: 'Abc12345!',
    rules: fullRules,
  },
  name: 'Complete (100% — all rules satisfied)',
};

export const CustomRules: Story = {
  args: {
    password: 'simplepass',
    rules: { minLength: 6, lowerCase: true },
  },
  name: 'Custom rules subset',
};
