<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
include_once SFTCY_WORDFORM_PLUGIN_DIR . 'admin/views/pages-header-template.php';

$wordform_builder_hidden_elements = array();
$wordform_upgrade_url = class_exists( 'SftcyWordformFeatures' ) ? SftcyWordformFeatures::wordform_get_upgrade_url() : 'https://softcoy.com/products/wordform-pro/checkout';
if ( class_exists( 'SftcyWordformFeatures' ) ) {
	foreach ( SftcyWordformFeatures::wordform_get_builder_element_feature_map() as $element_type => $feature_key ) {
		if ( ! SftcyWordformFeatures::wordform_is_feature_available( $feature_key ) ) {
			$wordform_builder_hidden_elements[] = sanitize_key( $element_type );
		}
	}
}

if ( isset( $wordform_id ) && ! empty( $wordform_id ) ) {
	// Edit Created Forms
	// print_r($query_results );
	include_once SFTCY_WORDFORM_PLUGIN_DIR . 'admin/views/create_forms_edit_page.php';
} else {
	// Create New Forms
	?>
	<div class="wordform-fullscreen-wrapper">
		<!-- Start wordform build Top information & action buttons bar-->
		<div class="wordform-build-top-information-action-buttons-wrapper">
		  	<div class="wordform-draggable-elements-info-wrapper"></div>

			<div class="wordform-build-canvas-info-wrapper">
					<!-- Actions Update Info -->
					<p class="wordform-message-info"></p>
			</div>

			<!-- Start Save Form, Preview & Test, Full Screen Buttons -->
			<div class="wordform-build-form-options-customization-info-wrapper">
				<!-- Action Buttons -->
				<div class="wordform-form-action-buttons-wrapper">
					<!-- Save Button -->
					<button type="button" class="button button-primary button-large wordform-save-btn">						
						<i class="fa-solid fa-file-circle-check"></i>
						<?php esc_html_e( 'Save Form', 'wordform-pro' ); ?>
					</button>

					<button type="button" class="button button-secondary button-large wordform-form-templates-btn">
						<i class="fa-solid fa-layer-group"></i>
						<?php esc_html_e( 'Form Templates', 'wordform-pro' ); ?>
					</button>

					<!-- Preview & Test Button -->
					<a type="button" class="button button-primary button-large wordform-preview-btn disabled" href="#" target="_blank">
						<span class="dashicons dashicons-welcome-view-site"></span> 
						<?php esc_html_e( 'Preview & Test', 'wordform-pro' ); ?>
					</a>

					<!-- Full Screen Button -->
					<button type="button" class="button button-primary button-large wordform-fullscreen-btn">
						<i class="fa-solid fa-expand"></i>
						<?php esc_html_e( 'Full Screen', 'wordform-pro' ); ?>
					</button>
				</div>			
			</div>
			<!-- End Save Form, Preview & Test, Full Screen Buttons -->

		</div><!-- /.wordform-build-top-information-action-buttons-wrapper -->
		<?php include SFTCY_WORDFORM_PLUGIN_DIR . 'admin/views/create-form-templates-modal.php'; ?>
		<input type="hidden" class="wordform-tier-hidden-builder-elements" value="<?php echo esc_attr( wp_json_encode( array_values( array_unique( $wordform_builder_hidden_elements ) ) ) ); ?>" />
		<input type="hidden" class="wordform-upgrade-url" value="<?php echo esc_url( $wordform_upgrade_url ); ?>" />

		<!-- Start Main Form builder divs -->
		<div class="wordform-div-wrapper">	
			 
			<!-- Start Draggable Input Elements - Left Sidebar -->      
			<div class="wordform-draggable-elements-div-wrapper">

				<h4 class="wordform-builder-section-toggle is-open" data-wordform-builder-target="standard">
					<span class="wordform-builder-section-heading">
						<i class="fa-solid fa-circle-chevron-down wordform-standard-elements-collapse-icon"></i>
						<span class="wordform-builder-section-title"><?php esc_html_e( 'Standard Elements', 'wordform-pro' ); ?></span>
					</span>
					<small class="wordform-builder-section-subtitle"><?php esc_html_e( 'Core form fields', 'wordform-pro' ); ?></small>
				</h4>
				<div class="wordform-build-draggable-standard-fields open" data-wordform-builder-group="standard">					
					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-singletext button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="singletext" type="button" >
						<i class="fa-sharp fa-regular fa-user"></i>
						<?php esc_html_e( 'Single Name', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-firstlastname button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="firstlastname" type="button" >
						<i class="fa-sharp fa-regular fa-address-card"></i>
						<?php esc_html_e( 'First & Last Name', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-address button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="address" type="button" >
						<i class="fa-solid fa-location-dot"></i>
						<?php esc_html_e( 'Address', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-singlenumber button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="singlenumber" type="button" >
						<i class="fa-sharp fa-solid fa-arrow-up-1-9"></i>
						<?php esc_html_e( 'Number', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-multitext button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="multitext" type="button" >
						<i class="fa-sharp fa-solid fa-text-width"></i>
						<?php esc_html_e( 'Description', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-sectionhtml button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="sectionhtml" type="button" >
						<i class="fa-solid fa-rectangle-list"></i>
						<?php esc_html_e( 'Section / HTML', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-select button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="select" type="button" >
						<i class="fa-sharp fa-solid fa-square-caret-down"></i>
						<?php esc_html_e( 'Dropdown Options', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-checkbox button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="checkbox" type="button" >
						<i class="fa-sharp fa-solid fa-square-check"></i>
						<?php esc_html_e( 'Checkboxes', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-radio button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="radio" type="button" >
						<i class="fa-sharp fa-regular fa-circle-dot"></i>
						<?php esc_html_e( 'Multiple Choice', 'wordform-pro' ); ?></button>
					</div>

				</div><!-- /.wordform-build-draggable-standard-fields -->

				<h4 class="wordform-builder-section-toggle" data-wordform-builder-target="advanced">
					<span class="wordform-builder-section-heading">
						<i class="fa-solid fa-circle-chevron-down wordform-advance-elements-collapse-icon"></i>
						<span class="wordform-builder-section-title"><?php esc_html_e( 'Advanced Elements', 'wordform-pro' ); ?></span>
					</span>
					<small class="wordform-builder-section-subtitle"><?php esc_html_e( 'Validation, upload, date, captcha', 'wordform-pro' ); ?></small>
				</h4>
				<div class="wordform-build-draggable-advanced-fields" data-wordform-builder-group="advanced">
					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-range button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="range" type="button" >
						<i class="fa-solid fa-sliders"></i>
						<?php esc_html_e( 'Range Slider', 'wordform-pro' ); ?></button>
					</div>
					
					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-url button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="url" type="button" >
						<i class="fa-solid fa-link"></i>
						<?php esc_html_e( 'URL', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-date button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="date" type="button" >
						<i class="fa fa-calendar"></i>
						<?php esc_html_e( 'Date', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-time button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="time" type="button" >
						<i class="fa-regular fa-clock"></i>
						<?php esc_html_e( 'Time', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-datetime button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="datetime" type="button" >
						<i class="fa-regular fa-clock"></i>
						<?php esc_html_e( 'Datetime', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-tel button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="tel" type="button" >
						<i class="fa fa-phone"></i>
						<?php esc_html_e( 'Tel', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-email button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="email" type="button" >
						<i class="fa-sharp fa-solid fa-at"></i>
						<?php esc_html_e( 'Email', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-upload button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="upload" type="button" >
						<i class="fa-solid fa-upload"></i>
						<?php esc_html_e( 'Upload', 'wordform-pro' ); ?></button>	
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-rating button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="rating" type="button" >
							<i class="fa-solid fa-star"></i>
						<?php esc_html_e( 'Rating', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-likert button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="likert" type="button" >
							<i class="fa-solid fa-table-list"></i>
						<?php esc_html_e( 'Likert / Matrix', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-signature button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="signature" type="button" >
							<i class="fa-solid fa-signature"></i>
						<?php esc_html_e( 'Signature', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-richeditor button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="richeditor" type="button" >
							<i class="fa-solid fa-pen-to-square"></i>
						<?php esc_html_e( 'Rich Text Editor', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-maskinput button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="maskinput" type="button" >
						<i class="fa-regular fa-keyboard"></i>
						<?php esc_html_e( 'Mask Input', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-hidden button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="hidden" type="button" >
						<i class="fa-solid fa-eye-slash"></i>
						<?php esc_html_e( 'Hidden Field', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-pagebreak button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="pagebreak" type="button" >
						<i class="fa-solid fa-forward-step"></i>
						<?php esc_html_e( 'Page Break', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<?php if ( SftcyWordformCaptcha::wordform_gd_library_available() ) { ?>
						<button class="draggable-element wordform-type-captcha button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="captcha" type="button" >
						<i class="fa-solid fa-shield"></i>
							<?php esc_html_e( 'Numeric Captcha', 'wordform-pro' ); ?></button>				   				   				   
						<?php } ?>	
					</div>
					
					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-gcaptcha button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="gcaptcha" type="button" >						
						<i class="fa-brands fa-google"></i>
						<?php esc_html_e( 'Google reCaptcha', 'wordform-pro' ); ?></button>				   				   				   					
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-hcaptcha button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="hcaptcha" type="button" >
						<i class="fa-solid fa-shield-halved"></i>
						<?php esc_html_e( 'hCaptcha', 'wordform-pro' ); ?></button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-terms button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="terms" type="button">
							<i class="fa-regular fa-file-lines"></i>
							<?php esc_html_e( 'Terms & Conditions', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-gdpr button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="gdpr" type="button">
							<i class="fa-solid fa-shield-heart"></i>
							<?php esc_html_e( 'GDPR Consent', 'wordform-pro' ); ?>
						</button>
					</div>


				</div><!-- /.wordform-build-draggable-advanced-fields -->				

				<h4 class="wordform-builder-section-toggle" data-wordform-builder-target="payment">
					<span class="wordform-builder-section-heading">
						<i class="fa-solid fa-circle-chevron-down wordform-payment-elements-collapse-icon"></i>
						<span class="wordform-builder-section-title"><?php esc_html_e( 'Payment Elements', 'wordform-pro' ); ?></span>
					</span>
					<small class="wordform-builder-section-subtitle"><?php esc_html_e( 'Checkout, totals, gateways', 'wordform-pro' ); ?></small>
				</h4>
				<div class="wordform-build-draggable-payment-fields" data-wordform-builder-group="payment">
					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-payment-method button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="payment_method" type="button">
							<i class="fa-solid fa-credit-card"></i>
							<?php esc_html_e( 'Payment Method', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-payment-item button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="payment_item" type="button">
							<i class="fa-solid fa-tag"></i>
							<?php esc_html_e( 'Payment Item', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-payment-custom-amount button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="payment_custom_amount" type="button">
							<i class="fa-solid fa-money-bill-wave"></i>
							<?php esc_html_e( 'Custom Amount', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-payment-quantity button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="payment_quantity" type="button">
							<i class="fa-solid fa-hashtag"></i>
							<?php esc_html_e( 'Quantity', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-payment-summary button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="payment_summary" type="button">
							<i class="fa-solid fa-receipt"></i>
							<?php esc_html_e( 'Payment Summary', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-payment-coupon button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="payment_coupon" type="button">
							<i class="fa-solid fa-ticket"></i>
							<?php esc_html_e( 'Coupon', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-stripe button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="stripe" type="button">
							<i class="fa-brands fa-stripe"></i>
							<?php esc_html_e( 'Stripe', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-paypal button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="paypal" type="button">
							<i class="fa-brands fa-paypal"></i>
							<?php esc_html_e( 'PayPal', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-square button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="square" type="button">
							<i class="fa-solid fa-square"></i>
							<?php esc_html_e( 'Square', 'wordform-pro' ); ?>
						</button>
					</div>

					<div class="draggable-form-element-wrapper">
						<button class="draggable-element wordform-type-authorizenet button button-secondary button-large wordform-drag-elements-button" data-wordform-element-name="authorizenet" type="button">
							<i class="fa-solid fa-building-columns"></i>
							<?php esc_html_e( 'Authorize.Net', 'wordform-pro' ); ?>
						</button>
					</div>
				</div><!-- /.wordform-build-draggable-payment-fields -->

			</div> <!-- /.wordform-draggable-elements-div-wrapper -->

			<!-- End Draggable Input Elements - Left Sidebar -->      


			<!-- Start Form Builder Zone - Center Column -->
			<div class="wordform-builder-div-wrapper">
				
				<!-- Element: FORM Name -->
				<div id="wordformElement-1" class="wordform-input-element-div-wrapper wordform-input-element-div-wrapper-form-name center wordform-create-form-name-label-title" data-input-element-type="form-name" data-element-index="1" >
					<span><?php esc_html_e( 'New Form', 'wordform-pro' ); ?></span>
				</div>
								
				<!-- Elements DropZone -->				
				<div id="wordform-sortable" class="wordform-dropzone-div-wrapper"></div>

				<!--Element: Submit Button  -->
				<div id="wordformElement-2" class="wordform-input-element-div-wrapper wordform-input-element-div-wrapper-submit-button left" data-input-element-type="submit-button" data-element-index="2">
					<button class="button button-primary button-large wordform-admin-create-form-submit-button"><?php esc_html_e( 'Submit', 'wordform-pro' ); ?></button>
				</div>

		
				<input type="hidden" class="wordform-form-builder-element-number" value="2" />
				<input type="hidden" class="wordform-form-saved" value="false" />
				<input type="hidden" class="wordform-created-form-id" value="" />    
		
			</div><!-- /.wordform-builder-div-wrapper -->

			<!-- End Form Builder Zone - Center Column  -->

			<!-- Start Input Element Field Options Customization - Right Sidebar -->
			<div class="wordform-builder-form-options-div-wrapper">
				<div class="wordform-builder-active-element-header" aria-live="polite">
					<div class="wordform-builder-active-element-icon">
						<i class="fa-solid fa-heading" aria-hidden="true"></i>
					</div>
					<div class="wordform-builder-active-element-copy">
						<span class="wordform-builder-active-element-eyebrow"><?php esc_html_e( 'Active Element', 'wordform-pro' ); ?></span>
						<h4 class="wordform-builder-active-element-title"><?php esc_html_e( 'Form Name', 'wordform-pro' ); ?></h4>
						<p class="wordform-builder-active-element-subtitle"><?php esc_html_e( 'Form-level settings', 'wordform-pro' ); ?></p>
						<p class="wordform-builder-active-element-hint is-hidden">
							<span class="dashicons dashicons-info-outline" aria-hidden="true"></span>
							<span class="wordform-builder-active-element-hint-text"></span>
						</p>
					</div>
				</div>
				<?php include_once SFTCY_WORDFORM_PLUGIN_INC . 'elements/form-name.php'; ?>
				<?php include_once SFTCY_WORDFORM_PLUGIN_INC . 'elements/submit-button.php'; ?>
			</div><!-- /.wordform-builder-form-options-div-wrapper -->
			<!-- End Input Element Field Options Customization - Right Sidebar -->

			  
		</div><!-- ./wordform-div-wrapper -->
	<?php
}
?>
</div><!-- /.wordform-fullscreen-wrapper ->
