<?php $__env->startSection('content'); ?>
<div>

    <?php if($package->service()->hasPackageConfig($package)): ?>
    <form action="<?php echo e(route('package.update-service', $package->id)); ?>" method="POST">
        <?php echo csrf_field(); ?>
        <div class="row">
            <?php $__currentLoopData = $package->service()->getPackageConfig($package)->all() ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $name => $field): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if($field['type'] == 'content'): ?>
                    <div class="container w-100">
                        <div class="row justify-content-md-center">
                            <h4 class="text-center"><?php echo $field['label']; ?></h4>
                        </div>
                        <div class="row justify-content-md-center">
                            <p class="text-bold"><?php echo $field['description']; ?></p>
                        </div>
                    </div>
                    <?php continue; ?>
                <?php endif; ?>
            <div class="form-group <?php if(isset($field['col'])): ?> <?php echo e($field['col']); ?> <?php else: ?> col-6 <?php endif; ?>" style="display: flex;flex-direction: column;">
                <label><?php echo $field['name']; ?></label>
                <?php if($field['type'] == 'select'): ?>
                <select class="form-control select2 select2-hidden-accessible" tabindex="-1" aria-hidden="true"
                name="<?php echo e($field['key']); ?>"
                id="<?php echo e($field['key']); ?>"
                <?php if(isset($field['save_on_change']) AND $field['save_on_change']): ?> onchange="saveServiceSettings()" <?php endif; ?>
                <?php if(isset($field['multiple']) AND $field['multiple']): ?> multiple <?php endif; ?>
                >
                    <?php $__currentLoopData = $field['options'] ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $option): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($key); ?>"
                    <?php if(in_array($key, (array) getValueByKey($field['key'], $package->data, $field['default_value'] ?? ''))): ?> selected <?php endif; ?>
                    ><?php echo e(is_string($option) ? $option : $option['name']); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <?php elseif($field['type'] == 'bool'): ?>
                <label class="custom-switch mt-2">
                    <input type="hidden" name="<?php echo e($field['key']); ?>" value="0">
                    <input type="checkbox" name="<?php echo e($field['key']); ?>" <?php if(isset($field['save_on_change']) AND $field['save_on_change']): ?> onchange="saveServiceSettings()" <?php endif; ?> value="1" class="custom-switch-input" <?php if(getValueByKey($field['key'], $package->data, $field['default_value'] ?? '')): ?> checked <?php endif; ?>>
                    <span class="custom-switch-indicator"></span>
                </label>
                <?php elseif($field['type'] == 'textarea'): ?>
                    <textarea class="form-control" name="<?php echo e($field['key']); ?>" id="<?php echo e($field['key']); ?>"><?php echo e(getValueByKey($field['key'], $package->data, $field['default_value'] ?? '')); ?></textarea>
                <?php else: ?>
                <input class="form-control"
                type="<?php echo e($field['type']); ?>"
                name="<?php echo e($field['key']); ?>"
                id="<?php echo e($field['key']); ?>"
                <?php if(isset($field['min'])): ?> min="<?php echo e($field['min']); ?>" <?php endif; ?>
                <?php if(isset($field['max'])): ?> max="<?php echo e($field['max']); ?>" <?php endif; ?>
                <?php if(isset($field['save_on_change']) AND $field['save_on_change']): ?> onchange="saveServiceSettings()" <?php endif; ?>
                value="<?php echo e(getValueByKey($field['key'], $package->data, $field['default_value'] ?? '')); ?>"
                placeholder="<?php if(isset($field['placeholder'])): ?><?php echo e($field['placeholder']); ?> <?php else: ?><?php echo e($field['name']); ?> <?php endif; ?>"
                <?php if(in_array('required', $field['rules'])): ?> required="" <?php endif; ?>>
                <?php endif; ?>
                <small class="form-text text-muted">
                    <?php echo $field['description']; ?>

                </small>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <div class="col-12">
                <div class="text-right">
                    <button class="btn btn-success" id="service-settings-submit" type="submit">Update</button>
                </div>
            </div>
        </div>
    </form>
    <?php else: ?>
        <?php if ($__env->exists(AdminTheme::serviceView($package->service, 'params'))) echo $__env->make(AdminTheme::serviceView($package->service, 'params'), \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php endif; ?>

    <script>
        function saveServiceSettings()
        {
            document.getElementById('service-settings-submit').click();
        }
    </script>

</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make(AdminTheme::path('packages/edit/master'), ['title' => 'Package Service', 'tab' => 'service'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/wemx/resources/themes/admin/default/packages/edit/service.blade.php ENDPATH**/ ?>