import { z } from 'zod'

export const ORGANIZATION_MODEL_ICON_TOKENS = [
  // Navigation / app areas
  'dashboard',
  'calendar',
  'sales',
  'crm',
  'lead-gen',
  'projects',
  'clients',
  'operations',
  'monitoring',
  'knowledge',
  'settings',
  'admin',
  'archive',
  'business',
  'finance',
  'platform',
  'seo',

  // Knowledge kinds
  'playbook',
  'strategy',
  'reference',

  // Resource kinds
  'agent',
  'workflow',
  'integration',
  'database',
  'user',
  'team',

  // Integration specifics
  'gmail',
  'google-sheets',
  'attio',

  // Surface / UI views
  'overview',
  'command-view',
  'command-queue',
  'pipeline',
  'lists',
  'resources',

  // Actions
  'approve',
  'reject',
  'retry',
  'edit',
  'view',
  'launch',
  'message',
  'message-plus',
  'escalate',
  'promote',
  'submit',
  'email',

  // Status
  'success',
  'error',
  'warning',
  'info',
  'pending',

  // OM / UI group icons
  'bolt',
  'building',
  'briefcase',
  'apps',
  'graph',
  'shield',
  'users',
  'chart-bar',
  'search'
] as const

const CustomIconTokenSchema = z
  .string()
  .trim()
  .max(80)
  .regex(
    /^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
    'Custom icon tokens must start with "custom." followed by lowercase alphanumeric segments'
  )

export const OrganizationModelBuiltinIconTokenSchema = z.enum(ORGANIZATION_MODEL_ICON_TOKENS)

export const OrganizationModelIconTokenSchema = z.union([
  OrganizationModelBuiltinIconTokenSchema,
  CustomIconTokenSchema
])

export type OrganizationModelBuiltinIconToken = (typeof ORGANIZATION_MODEL_ICON_TOKENS)[number]
export type OrganizationModelIconToken = z.infer<typeof OrganizationModelIconTokenSchema>
