use std::collections::HashMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InteractiveElement {
pub tag: String,
pub text: String,
#[serde(rename = "type")]
pub input_type: String,
pub name: String,
pub value: String,
pub placeholder: String,
pub href: String,
pub is_visible: bool,
pub rect: Rect,
pub attributes: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Rect {
pub x: f64,
pub y: f64,
pub w: f64,
pub h: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FormField {
pub name: String,
#[serde(rename = "type")]
pub field_type: String,
#[serde(default)]
pub label: String,
#[serde(default)]
pub value: String,
#[serde(default)]
pub required: bool,
#[serde(default)]
pub options: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FormInfo {
pub action: String,
pub method: String,
pub fields: Vec<FormField>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LinkInfo {
pub text: String,
pub href: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PageSummary {
pub url: String,
pub title: String,
#[serde(default)]
pub description: Option<String>,
pub links: Vec<LinkInfo>,
pub forms: Vec<FormInfo>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PageSnapshot {
pub url: String,
pub title: String,
pub viewport_size: String,
pub scroll_position: String,
pub interactive_elements: Vec<InteractiveElement>,
pub visible_text: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActionAttempt {
pub success: bool,
pub error: Option<String>,
pub before_url: String,
pub after_url: String,
}