<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

if ( ! class_exists( 'SftcyWordformFormtemplates' ) ) {
	/**
	 * Central registry for builder starter templates.
	 *
	 * Templates intentionally use the same structured form definition format
	 * as the drag-drop builder so future updates stay aligned with the core
	 * builder architecture and edit-mode reconstruction flow.
	 */
	class SftcyWordformFormtemplates {
		public static function get_template_categories() {
			return array(
				'all'                 => array(
					'label'       => __( 'All Templates', 'wordform-pro' ),
					'description' => __( 'Browse every starter form.', 'wordform-pro' ),
				),
				'contact-lead'        => array(
					'label'       => __( 'Contact & Lead', 'wordform-pro' ),
					'description' => __( 'Lead capture and basic contact forms.', 'wordform-pro' ),
				),
				'marketing'           => array(
					'label'       => __( 'Marketing', 'wordform-pro' ),
					'description' => __( 'Campaign, newsletter, and webinar forms.', 'wordform-pro' ),
				),
				'registration'        => array(
					'label'       => __( 'Registration', 'wordform-pro' ),
					'description' => __( 'Signups, applications, and enrollment forms.', 'wordform-pro' ),
				),
				'survey-feedback'     => array(
					'label'       => __( 'Survey & Feedback', 'wordform-pro' ),
					'description' => __( 'Opinion, satisfaction, and review forms.', 'wordform-pro' ),
				),
				'payments-orders'     => array(
					'label'       => __( 'Payments & Orders', 'wordform-pro' ),
					'description' => __( 'Checkout, donation, and payment forms.', 'wordform-pro' ),
				),
				'booking-appointment' => array(
					'label'       => __( 'Booking & Appointment', 'wordform-pro' ),
					'description' => __( 'Consultation, booking, and request forms.', 'wordform-pro' ),
				),
				'support-internal'    => array(
					'label'       => __( 'Support & Internal', 'wordform-pro' ),
					'description' => __( 'Support, upload, and internal workflow forms.', 'wordform-pro' ),
				),
			);
		}

		public static function get_form_templates_registry() {
			$templates = array(
				self::make_template(
					'contact_form',
					__( 'Contact Form', 'wordform-pro' ),
					'contact-lead',
					__( 'A clean contact form with name, email, subject, and message.', 'wordform-pro' ),
					array( 'basic', 'contact', 'lead' ),
					array(
						self::form_name( __( 'Contact Form', 'wordform-pro' ) ),
						self::single_name( __( 'Your Name', 'wordform-pro' ), __( 'Enter your name', 'wordform-pro' ) ),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'name@example.com', 'wordform-pro' ) ),
						self::text_field( __( 'Subject', 'wordform-pro' ), __( 'How can we help?', 'wordform-pro' ) ),
						self::textarea( __( 'Message', 'wordform-pro' ), __( 'Write your message', 'wordform-pro' ) ),
						self::submit_button( __( 'Send Message', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'lead_capture_form',
					__( 'Lead Capture Form', 'wordform-pro' ),
					'contact-lead',
					__( 'Capture name, email, phone, and interest for sales follow-up.', 'wordform-pro' ),
					array( 'lead', 'sales', 'simple' ),
					array(
						self::form_name( __( 'Lead Capture Form', 'wordform-pro' ) ),
						self::single_name( __( 'Full Name', 'wordform-pro' ), __( 'Prospect name', 'wordform-pro' ) ),
						self::email( __( 'Work Email', 'wordform-pro' ), __( 'name@company.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Enter phone number', 'wordform-pro' ) ),
						self::select(
							__( 'Interested In', 'wordform-pro' ),
							array( __( 'Website', 'wordform-pro' ), __( 'SEO', 'wordform-pro' ), __( 'Marketing Automation', 'wordform-pro' ) )
						),
						self::textarea( __( 'Project Notes', 'wordform-pro' ), __( 'Tell us about your project', 'wordform-pro' ), false ),
						self::submit_button( __( 'Request Consultation', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'newsletter_signup',
					__( 'Newsletter Signup', 'wordform-pro' ),
					'marketing',
					__( 'A compact form for email list growth and content preferences.', 'wordform-pro' ),
					array( 'newsletter', 'marketing', 'email' ),
					array(
						self::form_name( __( 'Newsletter Signup', 'wordform-pro' ) ),
						self::single_name( __( 'Name', 'wordform-pro' ), __( 'Your name', 'wordform-pro' ) ),
						self::email( __( 'Email', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::checkbox(
							__( 'Topics You Want', 'wordform-pro' ),
							array( __( 'Product Updates', 'wordform-pro' ), __( 'Tutorials', 'wordform-pro' ), __( 'Promotions', 'wordform-pro' ) )
						),
						self::submit_button( __( 'Subscribe', 'wordform-pro' ), 'center' ),
					)
				),
				self::make_template(
					'request_quote',
					__( 'Request a Quote', 'wordform-pro' ),
					'contact-lead',
					__( 'Collect project requirements before preparing a quote.', 'wordform-pro' ),
					array( 'quote', 'sales', 'service' ),
					array(
						self::form_name( __( 'Request a Quote', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Business Email', 'wordform-pro' ), __( 'name@business.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone', 'wordform-pro' ), __( 'Best contact number', 'wordform-pro' ), false ),
						self::select(
							__( 'Budget Range', 'wordform-pro' ),
							array( __( '$500 - $1,000', 'wordform-pro' ), __( '$1,000 - $5,000', 'wordform-pro' ), __( '$5,000+', 'wordform-pro' ) )
						),
						self::textarea( __( 'Project Details', 'wordform-pro' ), __( 'Describe what you need', 'wordform-pro' ) ),
						self::submit_button( __( 'Request Quote', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'webinar_registration',
					__( 'Webinar Registration', 'wordform-pro' ),
					'marketing',
					__( 'A fast registration form for campaigns and webinars.', 'wordform-pro' ),
					array( 'event', 'webinar', 'marketing' ),
					array(
						self::form_name( __( 'Webinar Registration', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::select(
							__( 'Job Role', 'wordform-pro' ),
							array( __( 'Founder', 'wordform-pro' ), __( 'Marketing Manager', 'wordform-pro' ), __( 'Sales', 'wordform-pro' ), __( 'Developer', 'wordform-pro' ) ),
							false
						),
						self::checkbox(
							__( 'Communication Preferences', 'wordform-pro' ),
							array( __( 'Webinar reminders', 'wordform-pro' ), __( 'Future event updates', 'wordform-pro' ) ),
							false
						),
						self::submit_button( __( 'Reserve My Seat', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'event_registration',
					__( 'Event Registration', 'wordform-pro' ),
					'registration',
					__( 'Collect attendee details, ticket choice, and comments.', 'wordform-pro' ),
					array( 'event', 'registration', 'attendance' ),
					array(
						self::form_name( __( 'Event Registration', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Email', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone', 'wordform-pro' ), __( 'Mobile number', 'wordform-pro' ), false ),
						self::radio(
							__( 'Ticket Type', 'wordform-pro' ),
							array( __( 'Standard', 'wordform-pro' ), __( 'VIP', 'wordform-pro' ), __( 'Student', 'wordform-pro' ) )
						),
						self::textarea( __( 'Notes', 'wordform-pro' ), __( 'Dietary or access requirements', 'wordform-pro' ), false ),
						self::submit_button( __( 'Register Now', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'job_application',
					__( 'Job Application', 'wordform-pro' ),
					'registration',
					__( 'Collect applicant info, role, resume, and cover note.', 'wordform-pro' ),
					array( 'job', 'application', 'upload' ),
					array(
						self::form_name( __( 'Job Application', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'name@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Enter phone number', 'wordform-pro' ) ),
						self::select(
							__( 'Applying For', 'wordform-pro' ),
							array( __( 'Marketing Executive', 'wordform-pro' ), __( 'Designer', 'wordform-pro' ), __( 'Developer', 'wordform-pro' ) )
						),
						self::upload( __( 'Resume / CV', 'wordform-pro' ), __( 'Upload Resume', 'wordform-pro' ) ),
						self::textarea( __( 'Cover Letter', 'wordform-pro' ), __( 'Share why you are a fit', 'wordform-pro' ) ),
						self::submit_button( __( 'Submit Application', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'customer_feedback',
					__( 'Customer Feedback', 'wordform-pro' ),
					'survey-feedback',
					__( 'Gather satisfaction, service quality, and comments.', 'wordform-pro' ),
					array( 'feedback', 'customer', 'service' ),
					array(
						self::form_name( __( 'Customer Feedback', 'wordform-pro' ) ),
						self::single_name( __( 'Name', 'wordform-pro' ), __( 'Optional name', 'wordform-pro' ), false ),
						self::email( __( 'Email', 'wordform-pro' ), __( 'Optional email', 'wordform-pro' ), false ),
						self::radio(
							__( 'How satisfied are you?', 'wordform-pro' ),
							array( __( 'Very satisfied', 'wordform-pro' ), __( 'Satisfied', 'wordform-pro' ), __( 'Neutral', 'wordform-pro' ), __( 'Unsatisfied', 'wordform-pro' ) )
						),
						self::textarea( __( 'Feedback', 'wordform-pro' ), __( 'Tell us what worked and what can improve', 'wordform-pro' ) ),
						self::submit_button( __( 'Send Feedback', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'nps_survey',
					__( 'NPS Survey', 'wordform-pro' ),
					'survey-feedback',
					__( 'A simple Net Promoter Score style feedback form.', 'wordform-pro' ),
					array( 'survey', 'nps', 'customer' ),
					array(
						self::form_name( __( 'NPS Survey', 'wordform-pro' ) ),
						self::email( __( 'Email', 'wordform-pro' ), __( 'Optional email', 'wordform-pro' ), false ),
						self::radio(
							__( 'How likely are you to recommend us?', 'wordform-pro' ),
							array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' )
						),
						self::textarea( __( 'What is the main reason for your score?', 'wordform-pro' ), __( 'Tell us more', 'wordform-pro' ), false ),
						self::submit_button( __( 'Submit Response', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'product_survey',
					__( 'Product Survey', 'wordform-pro' ),
					'survey-feedback',
					__( 'Collect product usage, rating, and suggestions.', 'wordform-pro' ),
					array( 'product', 'survey', 'feedback' ),
					array(
						self::form_name( __( 'Product Survey', 'wordform-pro' ) ),
						self::single_name( __( 'Name', 'wordform-pro' ), __( 'Your name', 'wordform-pro' ), false ),
						self::email( __( 'Email', 'wordform-pro' ), __( 'Optional email', 'wordform-pro' ), false ),
						self::select(
							__( 'Which plan do you use?', 'wordform-pro' ),
							array( __( 'Starter', 'wordform-pro' ), __( 'Business', 'wordform-pro' ), __( 'Enterprise', 'wordform-pro' ) )
						),
						self::range( __( 'Overall Satisfaction', 'wordform-pro' ), 1, 10, 8, 1 ),
						self::textarea( __( 'Feature Requests', 'wordform-pro' ), __( 'What should we improve next?', 'wordform-pro' ), false ),
						self::submit_button( __( 'Send Survey', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'donation_form',
					__( 'Donation Form', 'wordform-pro' ),
					'payments-orders',
					__( 'Flexible donation form with multiple payment methods.', 'wordform-pro' ),
					array( 'payment', 'donation', 'multi-gateway' ),
					array(
						self::form_name( __( 'Donation Form', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::payment_custom_amount( __( 'Donation Amount', 'wordform-pro' ), __( 'Enter your donation amount', 'wordform-pro' ), '25.00', '1.00' ),
						self::payment_summary( __( 'Donation Summary', 'wordform-pro' ), __( 'Donation total will appear here', 'wordform-pro' ) ),
						self::payment_method(),
						self::stripe_gateway(),
						self::paypal_gateway(),
						self::submit_button( __( 'Complete Donation', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'simple_payment_form',
					__( 'Simple Payment Form', 'wordform-pro' ),
					'payments-orders',
					__( 'A quick fixed-price payment form for one service or invoice.', 'wordform-pro' ),
					array( 'payment', 'checkout', 'fixed-price' ),
					array(
						self::form_name( __( 'Simple Payment Form', 'wordform-pro' ) ),
						self::single_name( __( 'Customer Name', 'wordform-pro' ), __( 'Enter your name', 'wordform-pro' ) ),
						self::email( __( 'Email', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::payment_item( __( 'Service Fee', 'wordform-pro' ), '99.00', __( 'One-time service payment', 'wordform-pro' ) ),
						self::payment_summary(),
						self::payment_method(),
						self::stripe_gateway(),
						self::paypal_gateway(),
						self::submit_button( __( 'Pay Now', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'product_order_form',
					__( 'Product Order Form', 'wordform-pro' ),
					'payments-orders',
					__( 'A simple order form with quantity, total, and payment methods.', 'wordform-pro' ),
					array( 'order', 'payment', 'product' ),
					array(
						self::form_name( __( 'Product Order Form', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::payment_item( __( 'Product Price', 'wordform-pro' ), '49.00', __( 'Single item price', 'wordform-pro' ) ),
						self::payment_quantity( __( 'Quantity', 'wordform-pro' ), '1', '1', '10' ),
						self::payment_summary( __( 'Order Summary', 'wordform-pro' ), __( 'Your total will appear here', 'wordform-pro' ) ),
						self::payment_method(),
						self::stripe_gateway(),
						self::paypal_gateway(),
						self::terms(),
						self::submit_button( __( 'Place Order', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'delivery_order_checkout',
					__( 'Delivery Order Checkout', 'wordform-pro' ),
					'payments-orders',
					__( 'A product checkout form with delivery address, coupon support, and multi-gateway payment.', 'wordform-pro' ),
					array( 'checkout', 'address', 'coupon', 'payment' ),
					array(
						self::form_name( __( 'Delivery Order Checkout', 'wordform-pro' ) ),
						self::section_html(
							__( 'Delivery Details', 'wordform-pro' ),
							__( 'Enter your contact and delivery information before completing payment.', 'wordform-pro' )
						),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Best number for delivery updates', 'wordform-pro' ) ),
						self::address_field( __( 'Delivery Address', 'wordform-pro' ) ),
						self::payment_item( __( 'Order Amount', 'wordform-pro' ), '65.00', __( 'Order subtotal before coupon.', 'wordform-pro' ) ),
						self::payment_quantity( __( 'Quantity', 'wordform-pro' ), '1', '1', '10' ),
						self::payment_coupon(),
						self::payment_summary( __( 'Order Summary', 'wordform-pro' ), __( 'Delivery total will appear here', 'wordform-pro' ) ),
						self::payment_method(),
						self::stripe_gateway(),
						self::paypal_gateway(),
						self::terms(),
						self::submit_button( __( 'Complete Order', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'consultation_deposit_booking',
					__( 'Consultation Deposit Booking', 'wordform-pro' ),
					'booking-appointment',
					__( 'Collect booking details, address, and a small upfront deposit for appointments.', 'wordform-pro' ),
					array( 'booking', 'deposit', 'address', 'payment' ),
					array(
						self::form_name( __( 'Consultation Deposit Booking', 'wordform-pro' ) ),
						self::section_html(
							__( 'Before You Book', 'wordform-pro' ),
							__( 'Share your details and pay the booking deposit to reserve your consultation slot.', 'wordform-pro' )
						),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Best number to reach you', 'wordform-pro' ) ),
						self::address_field( __( 'Your Address', 'wordform-pro' ), false ),
						self::date_field( __( 'Preferred Date', 'wordform-pro' ), __( 'Choose a date', 'wordform-pro' ) ),
						self::select(
							__( 'Preferred Time Slot', 'wordform-pro' ),
							array( __( 'Morning', 'wordform-pro' ), __( 'Afternoon', 'wordform-pro' ), __( 'Evening', 'wordform-pro' ) )
						),
						self::payment_item( __( 'Booking Deposit', 'wordform-pro' ), '20.00', __( 'Deposit required to confirm your appointment.', 'wordform-pro' ) ),
						self::payment_summary( __( 'Booking Summary', 'wordform-pro' ), __( 'Deposit total will appear here', 'wordform-pro' ) ),
						self::payment_method(),
						self::stripe_gateway(),
						self::paypal_gateway(),
						self::submit_button( __( 'Reserve Appointment', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'appointment_booking',
					__( 'Appointment Booking', 'wordform-pro' ),
					'booking-appointment',
					__( 'Collect appointment requests and preferred schedule.', 'wordform-pro' ),
					array( 'booking', 'appointment', 'service' ),
					array(
						self::form_name( __( 'Appointment Booking', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Best number to reach you', 'wordform-pro' ) ),
						self::date_field( __( 'Preferred Date', 'wordform-pro' ), __( 'Choose a date', 'wordform-pro' ) ),
						self::select(
							__( 'Preferred Time Slot', 'wordform-pro' ),
							array( __( 'Morning', 'wordform-pro' ), __( 'Afternoon', 'wordform-pro' ), __( 'Evening', 'wordform-pro' ) )
						),
						self::textarea( __( 'Reason for Appointment', 'wordform-pro' ), __( 'Share a short summary', 'wordform-pro' ) ),
						self::submit_button( __( 'Request Appointment', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'checkin_checkout_reservation',
					__( 'Check-In / Check-Out Reservation', 'wordform-pro' ),
					'booking-appointment',
					__( 'Collect reservation dates, arrival time, room choice, and guest details.', 'wordform-pro' ),
					array( 'hotel', 'reservation', 'check-in', 'check-out' ),
					array(
						self::form_name( __( 'Check-In / Check-Out Reservation', 'wordform-pro' ) ),
						self::section_html(
							__( 'Reservation Details', 'wordform-pro' ),
							__( 'Use this form to request a stay and share your preferred arrival details.', 'wordform-pro' )
						),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Best number for reservation updates', 'wordform-pro' ) ),
						self::date_field( __( 'Check-In Date', 'wordform-pro' ), __( 'Choose check-in date', 'wordform-pro' ) ),
						self::date_field( __( 'Check-Out Date', 'wordform-pro' ), __( 'Choose check-out date', 'wordform-pro' ) ),
						self::time_field( __( 'Expected Arrival Time', 'wordform-pro' ), __( 'Select arrival time', 'wordform-pro' ), false, '12h' ),
						self::select(
							__( 'Room Type', 'wordform-pro' ),
							array( __( 'Standard Room', 'wordform-pro' ), __( 'Deluxe Room', 'wordform-pro' ), __( 'Suite', 'wordform-pro' ) )
						),
						self::select(
							__( 'Number of Guests', 'wordform-pro' ),
							array( __( '1 Guest', 'wordform-pro' ), __( '2 Guests', 'wordform-pro' ), __( '3 Guests', 'wordform-pro' ), __( '4 Guests', 'wordform-pro' ) )
						),
						self::textarea( __( 'Special Requests', 'wordform-pro' ), __( 'Share any check-in notes or room requests', 'wordform-pro' ), false ),
						self::gdpr_field( true ),
						self::submit_button( __( 'Request Reservation', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'warranty_registration',
					__( 'Warranty Registration', 'wordform-pro' ),
					'registration',
					__( 'Register a product with serial number, purchase details, and customer address.', 'wordform-pro' ),
					array( 'registration', 'address', 'mask', 'product' ),
					array(
						self::form_name( __( 'Warranty Registration', 'wordform-pro' ) ),
						self::section_html(
							__( 'Product Registration', 'wordform-pro' ),
							__( 'Complete this form to activate your product warranty and support coverage.', 'wordform-pro' )
						),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::address_field( __( 'Customer Address', 'wordform-pro' ) ),
						self::mask_input( __( 'Product Serial Number', 'wordform-pro' ), __( 'AB-12345', 'wordform-pro' ), '^[A-Z]{2}-[0-9]{5}$' ),
						self::date_field( __( 'Purchase Date', 'wordform-pro' ), __( 'Choose purchase date', 'wordform-pro' ) ),
						self::hidden_field( __( 'Registration Source', 'wordform-pro' ), 'warranty_portal' ),
						self::submit_button( __( 'Register Product', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'ticket_purchase_checkout',
					__( 'Ticket Purchase Checkout', 'wordform-pro' ),
					'payments-orders',
					__( 'Sell event tickets with quantity, coupon support, and payment collection.', 'wordform-pro' ),
					array( 'ticket', 'event', 'checkout', 'payment' ),
					array(
						self::form_name( __( 'Ticket Purchase Checkout', 'wordform-pro' ) ),
						self::section_html(
							__( 'Ticket Details', 'wordform-pro' ),
							__( 'Choose your ticket type, quantity, and complete payment to confirm your booking.', 'wordform-pro' )
						),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Best number for updates', 'wordform-pro' ), false ),
						self::select(
							__( 'Ticket Type', 'wordform-pro' ),
							array( __( 'General Admission', 'wordform-pro' ), __( 'VIP Pass', 'wordform-pro' ), __( 'Backstage Pass', 'wordform-pro' ) )
						),
						self::payment_item( __( 'Ticket Price', 'wordform-pro' ), '79.00', __( 'Per-ticket event access fee.', 'wordform-pro' ) ),
						self::payment_quantity( __( 'Number of Tickets', 'wordform-pro' ), '1', '1', '10' ),
						self::payment_coupon(),
						self::payment_summary( __( 'Ticket Summary', 'wordform-pro' ), __( 'Ticket total will appear here', 'wordform-pro' ) ),
						self::payment_method(),
						self::stripe_gateway(),
						self::paypal_gateway(),
						self::gdpr_field( true ),
						self::submit_button( __( 'Complete Ticket Order', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'support_request',
					__( 'Support Request', 'wordform-pro' ),
					'support-internal',
					__( 'Collect support issues, urgency, and attachments.', 'wordform-pro' ),
					array( 'support', 'ticket', 'upload' ),
					array(
						self::form_name( __( 'Support Request', 'wordform-pro' ) ),
						self::single_name( __( 'Name', 'wordform-pro' ), __( 'Your name', 'wordform-pro' ) ),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::select(
							__( 'Priority', 'wordform-pro' ),
							array( __( 'Low', 'wordform-pro' ), __( 'Normal', 'wordform-pro' ), __( 'High', 'wordform-pro' ) )
						),
						self::textarea( __( 'Issue Details', 'wordform-pro' ), __( 'Describe the problem clearly', 'wordform-pro' ) ),
						self::upload( __( 'Attachment', 'wordform-pro' ), __( 'Attach screenshot or file', 'wordform-pro' ), false ),
						self::submit_button( __( 'Submit Request', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'file_upload_request',
					__( 'File Upload Request', 'wordform-pro' ),
					'support-internal',
					__( 'Collect files with uploader identity and notes.', 'wordform-pro' ),
					array( 'upload', 'documents', 'request' ),
					array(
						self::form_name( __( 'File Upload Request', 'wordform-pro' ) ),
						self::single_name( __( 'Name', 'wordform-pro' ), __( 'Your name', 'wordform-pro' ) ),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::upload( __( 'Upload Files', 'wordform-pro' ), __( 'Select Files', 'wordform-pro' ) ),
						self::textarea( __( 'Notes', 'wordform-pro' ), __( 'Add file details or instructions', 'wordform-pro' ), false ),
						self::submit_button( __( 'Send Files', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'customer_experience_survey',
					__( 'Customer Experience Survey', 'wordform-pro' ),
					'survey-feedback',
					__( 'Use rating, matrix feedback, and long-form comments in one survey.', 'wordform-pro' ),
					array( 'survey', 'rating', 'likert', 'feedback' ),
					array(
						self::form_name( __( 'Customer Experience Survey', 'wordform-pro' ) ),
						self::single_name( __( 'Name', 'wordform-pro' ), __( 'Optional name', 'wordform-pro' ), false ),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'Optional email', 'wordform-pro' ), false ),
						self::rating_field( __( 'Overall Experience', 'wordform-pro' ), 5, __( 'Poor', 'wordform-pro' ), __( 'Excellent', 'wordform-pro' ), true ),
						self::likert_field(
							__( 'Service Quality Review', 'wordform-pro' ),
							array( __( 'Communication', 'wordform-pro' ), __( 'Response Speed', 'wordform-pro' ), __( 'Resolution Quality', 'wordform-pro' ) ),
							array( __( 'Strongly Disagree', 'wordform-pro' ), __( 'Disagree', 'wordform-pro' ), __( 'Neutral', 'wordform-pro' ), __( 'Agree', 'wordform-pro' ), __( 'Strongly Agree', 'wordform-pro' ) ),
							true
						),
						self::rich_editor_field( __( 'Tell Us More', 'wordform-pro' ), __( 'Share details, praise, or suggestions...', 'wordform-pro' ), false, 190 ),
						self::submit_button( __( 'Submit Survey', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'insurance_claim_report',
					__( 'Insurance Claim Report', 'wordform-pro' ),
					'support-internal',
					__( 'Collect claimant details, policy number, incident address, and supporting files.', 'wordform-pro' ),
					array( 'claim', 'address', 'upload', 'mask' ),
					array(
						self::form_name( __( 'Insurance Claim Report', 'wordform-pro' ) ),
						self::section_html(
							__( 'Incident Information', 'wordform-pro' ),
							__( 'Provide the claim details and upload any related documents or photos.', 'wordform-pro' )
						),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Best number for claim updates', 'wordform-pro' ) ),
						self::mask_input( __( 'Policy Number', 'wordform-pro' ), __( 'AB-12345', 'wordform-pro' ), '^[A-Z]{2}-[0-9]{5}$' ),
						self::address_field( __( 'Incident Address', 'wordform-pro' ) ),
						self::textarea( __( 'Incident Details', 'wordform-pro' ), __( 'Describe what happened', 'wordform-pro' ) ),
						self::upload( __( 'Supporting Documents', 'wordform-pro' ), __( 'Upload Files', 'wordform-pro' ), false ),
						self::hidden_field( __( 'Claim Source', 'wordform-pro' ), 'claim_portal' ),
						self::submit_button( __( 'Submit Claim', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'vendor_registration',
					__( 'Vendor Registration', 'wordform-pro' ),
					'support-internal',
					__( 'Collect business details, tax ID, address, and required vendor documents.', 'wordform-pro' ),
					array( 'vendor', 'address', 'mask', 'upload' ),
					array(
						self::form_name( __( 'Vendor Registration', 'wordform-pro' ) ),
						self::section_html(
							__( 'Company Details', 'wordform-pro' ),
							__( 'Submit your business details and compliance documents to be added as a vendor.', 'wordform-pro' )
						),
						self::text_field( __( 'Company Name', 'wordform-pro' ), __( 'Business legal name', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Business Email', 'wordform-pro' ), __( 'name@company.com', 'wordform-pro' ) ),
						self::tel( __( 'Business Phone', 'wordform-pro' ), __( 'Enter company phone number', 'wordform-pro' ) ),
						self::address_field( __( 'Business Address', 'wordform-pro' ) ),
						self::mask_input( __( 'Tax ID / Registration Number', 'wordform-pro' ), __( 'AB-12345', 'wordform-pro' ), '^[A-Z0-9\\-]{5,20}$' ),
						self::upload( __( 'Compliance Documents', 'wordform-pro' ), __( 'Upload Documents', 'wordform-pro' ), false ),
						self::submit_button( __( 'Submit Registration', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'service_completion_signoff',
					__( 'Service Completion Sign-Off', 'wordform-pro' ),
					'support-internal',
					__( 'Capture final notes, signature, and explicit consent when a service is completed.', 'wordform-pro' ),
					array( 'signature', 'completion', 'acknowledgement', 'gdpr' ),
					array(
						self::form_name( __( 'Service Completion Sign-Off', 'wordform-pro' ) ),
						self::section_html(
							__( 'Completion Acknowledgement', 'wordform-pro' ),
							__( 'Review the completion details, add notes if needed, and sign to confirm acceptance.', 'wordform-pro' )
						),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::datetime_field( __( 'Signed At', 'wordform-pro' ), __( 'Select date & time', 'wordform-pro' ), true, 'yy-mm-dd hh:mm TT', '12h', true ),
						self::rich_editor_field( __( 'Completion Notes', 'wordform-pro' ), __( 'Add any final notes or handover details...', 'wordform-pro' ), false, 160 ),
						self::signature_field( true, __( 'Clear Signature', 'wordform-pro' ), 180 ),
						self::gdpr_field( true, __( 'I confirm the information above is accurate and consent to storing this sign-off record.', 'wordform-pro' ) ),
						self::submit_button( __( 'Submit Sign-Off', 'wordform-pro' ) ),
					)
				),
				self::make_template(
					'multi_step_registration',
					__( 'Multi-Step Registration', 'wordform-pro' ),
					'registration',
					__( 'A structured multi-step registration form using page breaks.', 'wordform-pro' ),
					array( 'multi-step', 'registration', 'page-break' ),
					array(
						self::form_name( __( 'Multi-Step Registration', 'wordform-pro' ) ),
						self::first_last_name(),
						self::email( __( 'Email Address', 'wordform-pro' ), __( 'you@example.com', 'wordform-pro' ) ),
						self::tel( __( 'Phone Number', 'wordform-pro' ), __( 'Enter phone number', 'wordform-pro' ) ),
						self::page_break( __( 'Registration Details', 'wordform-pro' ) ),
						self::select(
							__( 'Registration Type', 'wordform-pro' ),
							array( __( 'Individual', 'wordform-pro' ), __( 'Team', 'wordform-pro' ), __( 'Company', 'wordform-pro' ) )
						),
						self::textarea( __( 'Additional Notes', 'wordform-pro' ), __( 'Anything else we should know?', 'wordform-pro' ), false ),
						self::submit_button( __( 'Complete Registration', 'wordform-pro' ) ),
					)
				),
			);

			$supported_template_ids = class_exists( 'SftcyWordformFeatures' ) ? SftcyWordformFeatures::wordform_get_supported_template_ids() : array();
			if ( ! empty( $supported_template_ids ) ) {
				$templates = array_values(
					array_filter(
						$templates,
						static function( $template ) use ( $supported_template_ids ) {
							$template_id = isset( $template['template_id'] ) ? sanitize_key( $template['template_id'] ) : '';
							return in_array( $template_id, $supported_template_ids, true );
						}
					)
				);
			}

			return array_values( $templates );
		}

		private static function make_template( $id, $name, $category, $description, $tags, $form_definition ) {
			$categories     = self::get_template_categories();
			$category_label = isset( $categories[ $category ]['label'] ) ? $categories[ $category ]['label'] : $category;

			return array(
				'template_id'     => $id,
				'name'            => $name,
				'category'        => $category,
				'category_label'  => $category_label,
				'description'     => $description,
				'tags'            => $tags,
				'form_name'       => $name,
				'form_definition' => $form_definition,
			);
		}

		private static function form_name( $label ) {
			return array(
				'type'        => 'form-name',
				'label'       => $label,
				'align'       => 'center',
				'hide'        => false,
				'formClasses' => '',
			);
		}

		private static function submit_button( $label = 'Submit', $align = 'left', $full_width = false ) {
			return array(
				'type'            => 'submit-button',
				'label'           => $label,
				'align'           => $align,
				'buttonFullWidth' => $full_width,
			);
		}

		private static function single_name( $label, $placeholder, $required = true ) {
			return array(
				'type'            => 'text',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'required'        => $required,
			);
		}

		private static function first_last_name() {
			return array(
				'type'                 => 'firstlastname',
				'labelFirst'           => __( 'First Name', 'wordform-pro' ),
				'labelLast'            => __( 'Last Name', 'wordform-pro' ),
				'placeholderShow'      => true,
				'placeholderTextFirst' => __( 'First Name', 'wordform-pro' ),
				'placeholderTextLast'  => __( 'Last Name', 'wordform-pro' ),
				'required'             => true,
			);
		}

		private static function text_field( $label, $placeholder, $required = true ) {
			return array(
				'type'            => 'text',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'required'        => $required,
			);
		}

		private static function email( $label, $placeholder, $required = true ) {
			return array(
				'type'            => 'email',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'required'        => $required,
			);
		}

		private static function tel( $label, $placeholder, $required = true ) {
			return array(
				'type'            => 'tel',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'minlength'       => 6,
				'maxlength'       => 14,
				'pattern'         => '^\\+?[0-9]{6,14}$',
				'required'        => $required,
			);
		}

		private static function textarea( $label, $placeholder, $required = true ) {
			return array(
				'type'            => 'textarea',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'required'        => $required,
			);
		}

		private static function select( $label, $options, $required = true ) {
			$multi_option = array();
			foreach ( $options as $index => $option_label ) {
				$multi_option[] = array(
					'optionText'  => $option_label,
					'checkStatus' => 0 === $index,
				);
			}

			return array(
				'type'        => 'select',
				'label'       => $label,
				'multiOption' => $multi_option,
				'required'    => $required,
			);
		}

		private static function radio( $label, $options, $required = true ) {
			$multi_option = array();
			foreach ( $options as $index => $option_label ) {
				$multi_option[] = array(
					'optionText'  => $option_label,
					'checkStatus' => 0 === $index,
				);
			}

			return array(
				'type'        => 'radio',
				'label'       => $label,
				'multiOption' => $multi_option,
				'required'    => $required,
			);
		}

		private static function checkbox( $label, $options, $required = false ) {
			$multi_option = array();
			foreach ( $options as $option_label ) {
				$multi_option[] = array(
					'optionText'  => $option_label,
					'checkStatus' => false,
				);
			}

			return array(
				'type'        => 'checkbox',
				'label'       => $label,
				'multiOption' => $multi_option,
				'required'    => $required,
			);
		}

		private static function range( $label, $min, $max, $default, $step ) {
			return array(
				'type'     => 'range',
				'label'    => $label,
				'min'      => $min,
				'max'      => $max,
				'default'  => $default,
				'step'     => $step,
				'required' => true,
			);
		}

		private static function date_field( $label, $placeholder ) {
			return array(
				'type'            => 'date',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'defaultDateFormat' => 'yy-mm-dd',
				'required'        => true,
			);
		}

		private static function time_field( $label, $placeholder, $required = true, $display_mode = '24h' ) {
			return array(
				'type'            => 'time',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'defaultTime'     => '',
				'timeDisplayMode' => '12h' === $display_mode ? '12h' : '24h',
				'required'        => $required,
			);
		}

		private static function datetime_field( $label, $placeholder, $required = true, $display_format = 'yy-mm-dd HH:mm', $display_mode = '24h', $show_hint = true ) {
			return array(
				'type'                   => 'datetime',
				'label'                  => $label,
				'placeholderShow'        => true,
				'placeholderText'        => $placeholder,
				'displayFormatHint'      => $show_hint,
				'defaultDateTime'        => '',
				'defaultDateTimeSetting' => 'none',
				'defaultDateTimeFormat'  => $display_format,
				'timeDisplayMode'        => '12h' === $display_mode ? '12h' : '24h',
				'required'               => $required,
			);
		}

		private static function upload( $label, $select_file_label, $required = true ) {
			return array(
				'type'            => 'upload',
				'label'           => $label,
				'selectFileLabel' => $select_file_label,
				'multiple'        => false,
				'required'        => $required,
			);
		}

		private static function section_html( $title, $content ) {
			return array(
				'type'    => 'sectionhtml',
				'label'   => $title,
				'content' => $content,
			);
		}

		private static function rich_editor_field( $label, $placeholder, $required = false, $min_height = 180 ) {
			return array(
				'type'            => 'richeditor',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'minHeight'       => $min_height,
				'required'        => $required,
			);
		}

		private static function address_field( $label = '', $required = true ) {
			return array(
				'type'               => 'address',
				'label'              => ! empty( $label ) ? $label : __( 'Address', 'wordform-pro' ),
				'placeholderShow'    => true,
				'placeholderStreet'  => __( 'Street Address', 'wordform-pro' ),
				'placeholderCity'    => __( 'City', 'wordform-pro' ),
				'placeholderState'   => __( 'State / Region', 'wordform-pro' ),
				'placeholderZip'     => __( 'ZIP / Postal Code', 'wordform-pro' ),
				'placeholderCountry' => __( 'Country', 'wordform-pro' ),
				'required'           => $required,
			);
		}

		private static function mask_input( $label, $placeholder, $pattern, $required = true ) {
			return array(
				'type'            => 'maskinput',
				'label'           => $label,
				'placeholderShow' => true,
				'placeholderText' => $placeholder,
				'pattern'         => $pattern,
				'required'        => $required,
			);
		}

		private static function hidden_field( $label, $value ) {
			return array(
				'type'         => 'hidden',
				'label'        => $label,
				'defaultValue' => $value,
			);
		}

		private static function page_break( $step_title ) {
			return array(
				'type'                => 'pagebreak',
				'stepTitle'           => $step_title,
				'nextButtonText'      => __( 'Next', 'wordform-pro' ),
				'previousButtonText'  => __( 'Back', 'wordform-pro' ),
				'nextButtonAlign'     => 'right',
				'previousButtonAlign' => 'left',
			);
		}

		private static function rating_field( $label, $scale = 5, $low_text = '', $high_text = '', $required = true ) {
			return array(
				'type'      => 'rating',
				'label'     => $label,
				'scale'     => max( 3, min( 10, (int) $scale ) ),
				'lowText'   => ! empty( $low_text ) ? $low_text : __( 'Poor', 'wordform-pro' ),
				'highText'  => ! empty( $high_text ) ? $high_text : __( 'Excellent', 'wordform-pro' ),
				'required'  => $required,
			);
		}

		private static function likert_field( $label, $rows = array(), $columns = array(), $required = true ) {
			return array(
				'type'         => 'likert',
				'label'        => $label,
				'rowLabels'    => array_values( array_filter( array_map( 'strval', (array) $rows ) ) ),
				'columnLabels' => array_values( array_filter( array_map( 'strval', (array) $columns ) ) ),
				'required'     => $required,
			);
		}

		private static function signature_field( $required = true, $clear_button_text = '', $canvas_height = 180 ) {
			return array(
				'type'            => 'signature',
				'label'           => __( 'Signature', 'wordform-pro' ),
				'clearButtonText' => ! empty( $clear_button_text ) ? $clear_button_text : __( 'Clear Signature', 'wordform-pro' ),
				'canvasHeight'    => max( 120, min( 360, (int) $canvas_height ) ),
				'required'        => $required,
			);
		}

		private static function payment_method() {
			return array(
				'type'           => 'payment_method',
				'label'          => __( 'Payment Method', 'wordform-pro' ),
				'helperText'     => __( 'Choose how you want to pay.', 'wordform-pro' ),
				'defaultGateway' => 'stripe',
				'required'       => true,
			);
		}

		private static function payment_item( $label, $amount, $description = '' ) {
			return array(
				'type'        => 'payment_item',
				'label'       => $label,
				'amount'      => $amount,
				'description' => $description,
				'required'    => true,
			);
		}

		private static function payment_coupon( $label = '', $placeholder = '', $apply_text = '', $remove_text = '' ) {
			return array(
				'type'             => 'payment_coupon',
				'label'            => ! empty( $label ) ? $label : __( 'Coupon Code', 'wordform-pro' ),
				'placeholderText'  => ! empty( $placeholder ) ? $placeholder : __( 'Enter coupon code', 'wordform-pro' ),
				'applyButtonText'  => ! empty( $apply_text ) ? $apply_text : __( 'Apply Coupon', 'wordform-pro' ),
				'removeButtonText' => ! empty( $remove_text ) ? $remove_text : __( 'Remove Coupon', 'wordform-pro' ),
				'invalidMessage'   => __( 'Coupon code is not valid.', 'wordform-pro' ),
				'appliedMessage'   => __( 'Coupon applied successfully.', 'wordform-pro' ),
			);
		}

		private static function payment_custom_amount( $label, $placeholder, $default_amount, $min_amount ) {
			return array(
				'type'            => 'payment_custom_amount',
				'label'           => $label,
				'placeholderText' => $placeholder,
				'defaultAmount'   => $default_amount,
				'minAmount'       => $min_amount,
				'required'        => true,
			);
		}

		private static function payment_quantity( $label, $default_quantity, $min_quantity, $max_quantity ) {
			return array(
				'type'            => 'payment_quantity',
				'label'           => $label,
				'defaultQuantity' => $default_quantity,
				'minQuantity'     => $min_quantity,
				'maxQuantity'     => $max_quantity,
				'required'        => true,
			);
		}

		private static function payment_summary( $label = '', $empty_text = '' ) {
			return array(
				'type'      => 'payment_summary',
				'label'     => ! empty( $label ) ? $label : __( 'Payment Summary', 'wordform-pro' ),
				'emptyText' => ! empty( $empty_text ) ? $empty_text : __( 'Amounts will appear here', 'wordform-pro' ),
			);
		}

		private static function stripe_gateway() {
			return array(
				'type'        => 'stripe',
				'label'       => __( 'Stripe Payment', 'wordform-pro' ),
				'buttonText'  => __( 'Pay with Card', 'wordform-pro' ),
				'description' => __( 'Secure card payment via Stripe.', 'wordform-pro' ),
			);
		}

		private static function paypal_gateway() {
			return array(
				'type'        => 'paypal',
				'label'       => __( 'PayPal Payment', 'wordform-pro' ),
				'buttonText'  => __( 'Pay with PayPal', 'wordform-pro' ),
				'description' => __( 'Checkout with your PayPal account.', 'wordform-pro' ),
			);
		}

		private static function terms() {
			return array(
				'type'                         => 'terms',
				'label'                        => __( 'Terms & Conditions', 'wordform-pro' ),
				'termsConditionsText'          => __( 'I agree to the terms and conditions', 'wordform-pro' ),
				'termsConditionsTextClickable' => true,
				'termsConditionsUrl'           => 'https://example.com/terms',
				'required'                     => true,
			);
		}

		private static function gdpr_field( $required = true, $consent_text = '', $policy_url = 'https://example.com/privacy-policy' ) {
			return array(
				'type'                      => 'gdpr',
				'label'                     => __( 'GDPR Consent', 'wordform-pro' ),
				'gdprConsentText'           => ! empty( $consent_text ) ? $consent_text : __( 'I agree to the privacy policy and consent to data processing.', 'wordform-pro' ),
				'gdprPolicyUrl'             => $policy_url,
				'gdprConsentTextClickable'  => true,
				'required'                  => $required,
			);
		}
	}
}
