@if(!empty($builderTemplateIsImage))
@foreach($overlayFields as $field)
@php
$fieldName = trim((string) ($field['name'] ?? ''));
$fieldType = strtolower(trim((string) ($field['type'] ?? 'text')));
$rawValue = $builderSubmittedData[$fieldName] ?? null;
$position = is_array($field['position'] ?? null) ? $field['position'] : $field;
$x = is_numeric($position['x'] ?? null) ? (float) $position['x'] : 0.1;
$y = is_numeric($position['y'] ?? null) ? (float) $position['y'] : 0.1;
$w = is_numeric($position['width'] ?? null) ? (float) $position['width'] : 0.24;
$h = is_numeric($position['height'] ?? null) ? (float) $position['height'] : 0.07;
$x = max(0, min(0.95, $x));
$y = max(0, min(0.95, $y));
$w = max(0.06, min(0.85, $w));
$h = max(0.015, min(0.35, $h));
$savedFontSize = is_numeric(data_get($field, 'font_size')) ? (int) data_get($field, 'font_size') : null;
$computedFontSize = $savedFontSize ?: max(10, min(22, (int) round($h * 110)));
$isSignature = is_string($rawValue) && str_starts_with($rawValue, 'data:image/');
$displayValue = is_bool($rawValue)
? ($rawValue ? 'Yes' : 'No')
: (is_scalar($rawValue) ? (string) $rawValue : '');
if ($displayValue === '1' && !$isSignature) {
$displayValue = 'Yes';
} elseif ($displayValue === '0' && !$isSignature) {
$displayValue = 'No';
}
$shouldRenderText = in_array($fieldType, ['text', 'date', 'checkbox'], true) && $displayValue !== '';
@endphp
@if($isSignature)
@elseif($shouldRenderText)
{{ $displayValue }}
@endif
@endforeach
@elseif(!empty($builderTemplateUrl))
@else
{{ __('No template is available for this document type.') }}
@endif