"use client"; import { ActionBlock, AddActionPanel, AlertRuleSourceFields, AlertRuleTriggerFields } from "@app/components/alert-rule-editor/AlertRuleFields"; import { SettingsContainer } from "@app/components/Settings"; import { Button } from "@app/components/ui/button"; import { Card, CardContent } from "@app/components/ui/card"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@app/components/ui/form"; import { Input } from "@app/components/ui/input"; import { toast } from "@app/hooks/useToast"; import { buildFormSchema, defaultFormValues, formValuesToApiPayload, type AlertRuleFormValues } from "@app/lib/alertRuleForm"; import { createApiClient, formatAxiosError } from "@app/lib/api"; import { useEnvContext } from "@app/hooks/useEnvContext"; import type { CreateAlertRuleResponse } from "@server/routers/alertRule/types"; import type { AxiosResponse } from "axios"; import { zodResolver } from "@hookform/resolvers/zod"; import { ChevronLeft, Cog, Flag, Zap } from "lucide-react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useMemo, useState, type ReactNode } from "react"; import { useFieldArray, useForm, type Resolver } from "react-hook-form"; import { useTranslations } from "next-intl"; import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert"; import { SwitchInput } from "@app/components/SwitchInput"; import { tierMatrix } from "@server/lib/billing/tierMatrix"; import { Badge } from "../ui/badge"; const FORM_ID = "alert-rule-form"; type StepAccent = { labelClass: string; icon: typeof Flag; }; type AlertRuleGraphEditorProps = { orgId: string; alertRuleId?: number; initialValues: AlertRuleFormValues; isNew: boolean; disabled?: boolean; }; function VerticalRuleStep({ stepNumber, isLast, title, accent, children }: { stepNumber: number; isLast: boolean; title: string; accent: StepAccent; children: ReactNode; }) { const Icon = accent.icon; return (