<?php
    Theme::asset()->container('footer')->usePath()->add('nouislider', 'js/nouislider.min.js');
    Theme::asset()->container('footer')->usePath()->add('wnumb', 'js/wNumb.min.js');
    Theme::asset()->container('footer')->usePath()->add('nice-select', 'js/jquery.nice-select.min.js');

    $style ??= 1;
    $noLeftRound ??= false;
    $centeredTabs ??= false;

    $projectsSearchEnabled = (bool) ($shortcode->projects_search_enabled ?? true);

    $selectedTabs = explode(',', $shortcode->tabs ?: 'project,rent,sale');

    $defaultSearchType = $shortcode->default_search_type ?: 'project';
    $tabs = collect(['project' => __('Project'), 'rent' => __('For Rent'), 'sale' => __('For Sale')])
        ->when(! RealEstateHelper::isEnabledProjects() || ! $projectsSearchEnabled, function ($tabs) use (&$projectsSearchEnabled) {
            $projectsSearchEnabled = false;

            return $tabs->forget('project');
        })
        ->reject(fn ($tab, $key) => $key !== 'project' && ! in_array($key, RealEstateHelper::enabledPropertyTypes()))
        ->reject(fn ($tab, $key) => ! in_array($key, $selectedTabs))
        ->sortBy(fn ($tab, $key) => array_search($key, $selectedTabs));

    if ($defaultSearchType === 'project' && ! in_array('project', $tabs->keys()->toArray())) {
        $defaultSearchType = $tabs->keys()->first();
    }

    $propertyMaxPrice = get_max_properties_price();
    $maxPrice = ($projectsSearchEnabled || $defaultSearchType === 'project') ? get_max_projects_price() : $propertyMaxPrice;

    if ($maxPrice < $propertyMaxPrice) {
        $maxPrice = $propertyMaxPrice;
    }
?>

<?php if($tabs->isNotEmpty()): ?>
    <div class="flat-tab flat-tab-form">
        <?php if(count($tabs) > 1): ?>
            <ul class="<?php echo \Illuminate\Support\Arr::toCssClasses(['nav-tab-form', 'style-1' => $style === 1, 'style-2' => in_array($style, [2, 3]), 'style-3' => $style === 4, 'justify-content-center' => $centeredTabs]); ?>" role="tablist">
                <?php $__currentLoopData = $tabs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $tab): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li class="nav-tab-item" role="presentation">
                        <a
                            href="javascript:void(0);"
                            class="<?php echo \Illuminate\Support\Arr::toCssClasses(['nav-link-item', 'active' => $key === $defaultSearchType]); ?>"
                            data-bs-toggle="tab"
                            data-bb-toggle="change-search-type"
                            data-value="<?php echo e($key); ?>"
                            data-url="<?php echo e($key === 'project' ? RealEstateHelper::getProjectsListPageUrl() : RealEstateHelper::getPropertiesListPageUrl()); ?>"
                        >
                            <?php echo e($tab); ?>

                        </a>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        <?php endif; ?>

        <div class="tab-content">
            <div class="tab-pane fade active show" role="tabpanel">
                <form
                    class="<?php echo \Illuminate\Support\Arr::toCssClasses(['form-sl', 'flat-filter-form' => $style === 3]); ?>"
                    <?php if($projectsSearchEnabled && $defaultSearchType === 'project'): ?>
                        action="<?php echo e(RealEstateHelper::getProjectsListPageUrl()); ?>"
                    <?php else: ?>
                        action="<?php echo e(RealEstateHelper::getPropertiesListPageUrl()); ?>"
                    <?php endif; ?>
                    method="get"
                    id="hero-search-form"
                >

                    <input
                        name="type"
                        type="hidden"
                        <?php if($projectsSearchEnabled && $defaultSearchType === 'project'): ?>
                            value="project"
                        <?php else: ?>
                            value="<?php echo e($defaultSearchType); ?>"
                        <?php endif; ?>
                    >
                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.base'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

                    <?php if(theme_option('real_estate_enable_advanced_search', 'yes') == 'yes'): ?>
                        <?php if($projectsSearchEnabled): ?>
                            <div class="wd-search-form project-search-form">
                                <div class="grid-2 group-box group-price">
                                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.price', ['maxPrice' => $maxPrice]), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.flat'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                                <div class="group-box">
                                    <div class="group-select grid-3">
                                        <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.floor'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                        <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.block'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </div>
                                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.features'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                            </div>
                        <?php endif; ?>
                        <div class="wd-search-form property-search-form" style="<?php echo \Illuminate\Support\Arr::toCssStyles(['display: none;' => $projectsSearchEnabled && $defaultSearchType === 'project']) ?>">
                            <div class="grid-2 group-box group-price">
                                <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.price'), ['maxPrice' => $maxPrice], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.square'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            </div>
                            <div class="group-box">
                                <div class="group-select grid-3">
                                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.bathroom'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.bedroom'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.floor'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.projects'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                            </div>
                            <?php echo $__env->make(Theme::getThemeNamespace('views.real-estate.partials.filters.features'), array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                        </div>
                    <?php endif; ?>
                </form>
            </div>
        </div>
    </div>
<?php endif; ?>
<?php /**PATH /home/agriwurd/capitalpropertiesandresidence.com/platform/themes/homzen/views/real-estate/partials/search-box.blade.php ENDPATH**/ ?>