<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames(([
    'type' => 'text',
    'name',
    'label',
    'help' => null,
    'required' => false,
    'disabled' => false,
    'value' => null,
    'options' => [],
    'placeholder' => null,
    'rows' => 4,
    'checked' => false,
    'error' => null,
]));

foreach ($attributes->all() as $__key => $__value) {
    if (in_array($__key, $__propNames)) {
        $$__key = $$__key ?? $__value;
    } else {
        $__newAttributes[$__key] = $__value;
    }
}

$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);

unset($__propNames);
unset($__newAttributes);

foreach (array_filter(([
    'type' => 'text',
    'name',
    'label',
    'help' => null,
    'required' => false,
    'disabled' => false,
    'value' => null,
    'options' => [],
    'placeholder' => null,
    'rows' => 4,
    'checked' => false,
    'error' => null,
]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
}

$__defined_vars = get_defined_vars();

foreach ($attributes->all() as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
}

unset($__defined_vars, $__key, $__value); ?>

<?php
    $fieldId = 'field-' . str_replace(['[', ']', '.'], '-', $name);
?>

<?php if(in_array($type, ['checkbox', 'switch'])): ?>
    <div <?php echo e($attributes->merge(['class' => 'flex items-start gap-3'])); ?>>
        <?php if($type === 'switch'): ?>
            <label for="<?php echo e($fieldId); ?>" class="admin-switch" data-checked="<?php echo e($checked ? 'true' : 'false'); ?>">
                <input
                    type="checkbox"
                    id="<?php echo e($fieldId); ?>"
                    name="<?php echo e($name); ?>"
                    value="1"
                    <?php if($checked): echo 'checked'; endif; ?>
                    <?php if($disabled): echo 'disabled'; endif; ?>
                    class="sr-only"
                >
                <span class="admin-switch__thumb" aria-hidden="true"></span>
            </label>
        <?php else: ?>
            <input
                type="checkbox"
                id="<?php echo e($fieldId); ?>"
                name="<?php echo e($name); ?>"
                value="1"
                <?php if($checked): echo 'checked'; endif; ?>
                <?php if($disabled): echo 'disabled'; endif; ?>
                class="mt-0.5 h-4 w-4 rounded border-brand-border text-brand-primary focus-visible:outline-2 focus-visible:outline-brand-primary"
            >
        <?php endif; ?>
        <label for="<?php echo e($fieldId); ?>" class="text-sm text-brand-ink">
            <?php echo e($label); ?>

            <?php if($help): ?>
                <span class="block text-xs font-normal text-brand-muted"><?php echo e($help); ?></span>
            <?php endif; ?>
        </label>
    </div>
<?php else: ?>
    <div <?php echo e($attributes->merge(['class' => 'flex flex-col gap-1.5'])); ?>>
        <label for="<?php echo e($fieldId); ?>" class="flex items-baseline justify-between text-sm font-medium text-brand-ink">
            <span><?php echo e($label); ?> <?php if($required): ?><span class="text-admin-danger">*</span><?php else: ?> <span class="font-normal text-brand-muted">(facultatif)</span><?php endif; ?></span>
        </label>

        <?php switch($type):
            case ('textarea'): ?>
                <textarea
                    id="<?php echo e($fieldId); ?>"
                    name="<?php echo e($name); ?>"
                    rows="<?php echo e($rows); ?>"
                    placeholder="<?php echo e($placeholder); ?>"
                    <?php if($disabled): echo 'disabled'; endif; ?>
                    <?php if($error): ?> aria-invalid="true" <?php endif; ?>
                    class="admin-field-input"
                ><?php echo e($value); ?></textarea>
                <?php break; ?>

            <?php case ('select'): ?>
                <select id="<?php echo e($fieldId); ?>" name="<?php echo e($name); ?>" <?php if($disabled): echo 'disabled'; endif; ?> class="admin-field-input">
                    <?php $__currentLoopData = $options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $optValue => $optLabel): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($optValue); ?>" <?php if((string) $value === (string) $optValue): echo 'selected'; endif; ?>><?php echo e($optLabel); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <?php break; ?>

            <?php default: ?>
                <input
                    type="<?php echo e($type); ?>"
                    id="<?php echo e($fieldId); ?>"
                    name="<?php echo e($name); ?>"
                    value="<?php echo e($value); ?>"
                    placeholder="<?php echo e($placeholder); ?>"
                    <?php if($disabled): echo 'disabled'; endif; ?>
                    <?php if($error): ?> aria-invalid="true" <?php endif; ?>
                    class="admin-field-input"
                >
        <?php endswitch; ?>

        <?php if($help): ?>
            <p class="text-xs text-brand-muted"><?php echo e($help); ?></p>
        <?php endif; ?>

        <?php if($error): ?>
            <p class="text-xs font-medium text-admin-danger"><?php echo e($error); ?></p>
        <?php endif; ?>
    </div>
<?php endif; ?>
<?php /**PATH C:\wamp64\www\nh-trans\resources\views/components/admin/field.blade.php ENDPATH**/ ?>