



<?php $__env->startSection('title', 'Marketplace'); ?>

<?php $__env->startSection('page_class', 'page-marketplace'); ?>



<?php $__env->startPush('styles'); ?>

<link href="<?php echo e(asset('assets/css/marketplace.css')); ?>" rel="stylesheet">

<?php $__env->stopPush(); ?>



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

    <div class="page-header">

        <div>

            <h1 class="page-title">Marketplace</h1>

            <nav class="breadcrumb">

                <a href="<?php echo e(route('dashboard')); ?>" class="breadcrumb-item">Home</a>

                <span class="breadcrumb-item active">Marketplace</span>

            </nav>

        </div>

    </div>



    <?php if($platformNotice ?? null): ?>

        <?php if (isset($component)) { $__componentOriginalaaaa43f3131e74c9e05cf94572c12d21 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'eliteadmin::components.alert','data' => ['type' => 'info','message' => $platformNotice,'class' => 'mb-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('eliteadmin::alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'info','message' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($platformNotice),'class' => 'mb-4']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21)): ?>
<?php $attributes = $__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21; ?>
<?php unset($__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalaaaa43f3131e74c9e05cf94572c12d21)): ?>
<?php $component = $__componentOriginalaaaa43f3131e74c9e05cf94572c12d21; ?>
<?php unset($__componentOriginalaaaa43f3131e74c9e05cf94572c12d21); ?>
<?php endif; ?>

    <?php endif; ?>



    <?php if($registrationWarning ?? null): ?>

        <?php if (isset($component)) { $__componentOriginalaaaa43f3131e74c9e05cf94572c12d21 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'eliteadmin::components.alert','data' => ['type' => 'warning','message' => $registrationWarning,'class' => 'mb-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('eliteadmin::alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'warning','message' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($registrationWarning),'class' => 'mb-4']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21)): ?>
<?php $attributes = $__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21; ?>
<?php unset($__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalaaaa43f3131e74c9e05cf94572c12d21)): ?>
<?php $component = $__componentOriginalaaaa43f3131e74c9e05cf94572c12d21; ?>
<?php unset($__componentOriginalaaaa43f3131e74c9e05cf94572c12d21); ?>
<?php endif; ?>

    <?php endif; ?>



    <?php if($catalogNotice ?? null): ?>

        <?php if (isset($component)) { $__componentOriginalaaaa43f3131e74c9e05cf94572c12d21 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'eliteadmin::components.alert','data' => ['type' => 'warning','message' => $catalogNotice,'class' => 'mb-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('eliteadmin::alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'warning','message' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($catalogNotice),'class' => 'mb-4']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21)): ?>
<?php $attributes = $__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21; ?>
<?php unset($__attributesOriginalaaaa43f3131e74c9e05cf94572c12d21); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalaaaa43f3131e74c9e05cf94572c12d21)): ?>
<?php $component = $__componentOriginalaaaa43f3131e74c9e05cf94572c12d21; ?>
<?php unset($__componentOriginalaaaa43f3131e74c9e05cf94572c12d21); ?>
<?php endif; ?>

    <?php endif; ?>



    <div class="card mb-4">

        <div class="card-body">

            <form action="<?php echo e(route('marketplace.index')); ?>" method="GET" class="row g-3 align-items-end">

                <div class="col-md-6 col-lg-5">

                    <label for="search" class="form-label">Search Modules</label>

                    <input type="search" name="search" id="search" class="form-control"

                           placeholder="Search by name or description..." value="<?php echo e(request('search')); ?>">

                </div>

                <div class="col-md-4 col-lg-3">

                    <label for="category" class="form-label">Category</label>

                    <select name="category" id="category" class="form-select">

                        <option value="">All Categories</option>

                        <?php $__currentLoopData = $categories ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $categoryName): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                            <option value="<?php echo e($categoryName); ?>" <?php if(request('category') === $categoryName): echo 'selected'; endif; ?>>

                                <?php echo e($categoryName); ?>


                            </option>

                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </select>

                </div>

                <div class="col-md-2 col-lg-2">

                    <button type="submit" class="btn btn-primary w-100">Filter</button>

                </div>

            </form>

        </div>

    </div>



    <h2 class="marketplace-section-title">Available Modules</h2>



    <div class="marketplace-module-grid mb-4">

        <?php $__empty_1 = true; $__currentLoopData = $modules ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $module): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

            <?php

                $uuid = (string) ($module['uuid'] ?? '');

                $name = (string) ($module['name'] ?? 'Module');

                $description = (string) ($module['description'] ?? '');

                $specs = \App\Support\RichTextSanitizer::clean($module['specs'] ?? null);

                $category = (string) ($module['category'] ?? '');

                $type = (string) ($module['pricing_type'] ?? 'free');

                $price = (float) ($module['price'] ?? 0);

                $currency = $module['currency'] ?? null;

                $version = (string) ($module['version'] ?? '1.0');

                $isInstalled = in_array($uuid, $installedUuids ?? [], true);

                $isPaid = $type !== 'free' && $price > 0;

                $modalId = 'module-specs-'.Str::slug($uuid ?: $loop->index);

            ?>



            <article class="marketplace-module-card">

                <div class="marketplace-module-card__header">

                    <div class="marketplace-module-card__icon" aria-hidden="true">

                        <i class="bi bi-puzzle"></i>

                    </div>

                    <div class="marketplace-module-card__actions-top">

                        <?php if($specs): ?>

                            <button

                                type="button"

                                class="btn btn-light marketplace-specs-btn"

                                data-bs-toggle="modal"

                                data-bs-target="#<?php echo e($modalId); ?>"

                                title="View specifications"

                                aria-label="View specifications for <?php echo e($name); ?>"

                            >

                                <i class="bi bi-eye"></i>

                            </button>

                        <?php endif; ?>

                        <span class="badge bg-<?php echo e($type === 'free' ? 'success' : 'primary'); ?>">

                            <?php echo e(ucfirst(str_replace('_', ' ', $type))); ?>


                        </span>

                        <?php if($isInstalled): ?>

                            <span class="badge bg-success">Installed</span>

                        <?php endif; ?>

                    </div>

                </div>



                <div class="marketplace-module-card__body">

                    <h3 class="marketplace-module-card__title"><?php echo e($name); ?></h3>



                    <?php if($category !== ''): ?>

                        <div class="marketplace-module-card__category">

                            <i class="bi bi-tag"></i>

                            <span><?php echo e($category); ?></span>

                        </div>

                    <?php endif; ?>



                    <p class="marketplace-module-card__description">

                        <?php echo e($description !== '' ? Str::limit($description, 120) : 'No short description provided.'); ?>


                    </p>



                    <div class="marketplace-module-card__meta">

                        <span class="small text-muted">Version <?php echo e($version); ?></span>

                        <?php if($isPaid && ! $isInstalled): ?>

                            <span class="marketplace-module-card__price"><?php echo e(platform_money($price, $currency)); ?></span>

                        <?php elseif($type === 'free' || $price <= 0): ?>

                            <span class="badge bg-light text-success border">Free</span>

                        <?php endif; ?>

                    </div>



                    <div class="marketplace-module-card__footer">

                        <?php if($isInstalled): ?>

                            <div class="d-grid gap-2">

                                <a href="<?php echo e(route('modules.index')); ?>" class="btn btn-outline-primary">

                                    <i class="bi bi-gear me-1"></i> Manage

                                </a>

                                <?php

                                    $installedModule = ($installedModules ?? collect())->firstWhere('module_uuid', $uuid);

                                ?>

                                <?php if($installedModule): ?>

                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('uninstall', $installedModule)): ?>

                                        <form

                                            action="<?php echo e(route('modules.destroy', $installedModule)); ?>"

                                            method="POST"

                                            onsubmit="return confirm('Uninstall <?php echo e($installedModule->name); ?>? Users will lose access until it is reinstalled.');"

                                        >

                                            <?php echo csrf_field(); ?>

                                            <?php echo method_field('DELETE'); ?>

                                            <button type="submit" class="btn btn-outline-danger w-100">

                                                <i class="bi bi-trash me-1"></i> Uninstall

                                            </button>

                                        </form>

                                    <?php endif; ?>

                                <?php endif; ?>

                            </div>

                        <?php else: ?>

                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('install', \App\Http\Controllers\Marketplace\MarketplaceController::class)): ?>

                                <form action="<?php echo e(route('marketplace.install', $uuid)); ?>" method="POST" onsubmit="return confirm('Install this module? Paid modules will debit your platform wallet.');">

                                    <?php echo csrf_field(); ?>

                                    <button type="submit" class="btn btn-primary w-100">

                                        <?php if(! $isPaid): ?>

                                            <i class="bi bi-download me-1"></i> Install Free

                                        <?php else: ?>

                                            <i class="bi bi-cart-plus me-1"></i> Buy & Install — <?php echo e(platform_money($price, $currency)); ?>


                                        <?php endif; ?>

                                    </button>

                                </form>

                            <?php endif; ?>

                        <?php endif; ?>

                    </div>

                </div>

            </article>



            <?php if($specs): ?>

                <div class="modal fade module-specs-modal" id="<?php echo e($modalId); ?>" tabindex="-1" aria-labelledby="<?php echo e($modalId); ?>-label" aria-hidden="true">

                    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">

                        <div class="modal-content">

                            <div class="modal-header">

                                <div>

                                    <h5 class="modal-title" id="<?php echo e($modalId); ?>-label"><?php echo e($name); ?></h5>

                                    <?php if($category !== ''): ?>

                                        <div class="text-muted small"><?php echo e($category); ?> · v<?php echo e($version); ?></div>

                                    <?php else: ?>

                                        <div class="text-muted small">Version <?php echo e($version); ?></div>

                                    <?php endif; ?>

                                </div>

                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>

                            </div>

                            <div class="modal-body">

                                <div class="module-specs-content">

                                    <?php echo $specs; ?>


                                </div>

                            </div>

                            <div class="modal-footer flex-wrap gap-2">

                                <?php if($isInstalled): ?>

                                    <a href="<?php echo e(route('modules.index')); ?>" class="btn btn-outline-primary">Manage Module</a>

                                <?php elseif(auth()->user()?->can('install', \App\Http\Controllers\Marketplace\MarketplaceController::class)): ?>

                                    <form action="<?php echo e(route('marketplace.install', $uuid)); ?>" method="POST" class="ms-auto" onsubmit="return confirm('Install this module? Paid modules will debit your platform wallet.');">

                                        <?php echo csrf_field(); ?>

                                        <button type="submit" class="btn btn-primary">

                                            <?php if(! $isPaid): ?>

                                                Install Free

                                            <?php else: ?>

                                                Buy & Install — <?php echo e(platform_money($price, $currency)); ?>


                                            <?php endif; ?>

                                        </button>

                                    </form>

                                <?php endif; ?>

                                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>

                            </div>

                        </div>

                    </div>

                </div>

            <?php endif; ?>

        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

            <div class="col-12">

                <div class="card">

                    <div class="card-body text-center text-muted py-5">

                        <i class="bi bi-shop display-4 d-block mb-3"></i>

                        <p class="mb-0">No modules found. Connect to the Product Owner Platform to browse available modules.</p>

                    </div>

                </div>

            </div>

        <?php endif; ?>

    </div>



    <?php if(isset($modules) && is_object($modules) && method_exists($modules, 'links')): ?>

        <div class="mt-4">

            <?php echo e($modules->links()); ?>


        </div>

    <?php endif; ?>

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



<?php echo $__env->make('eliteadmin::layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\RABI\rabi\module-laravel-platform\apps\admin\resources\views/marketplace/index.blade.php ENDPATH**/ ?>