<?php $__env->startSection('content'); ?>
    <div class="knowledge-layout">
        <div class="knowledge-layout-header">
            <div class="flex-align gap-3">
                <span class="knowledge-sidebar-toggle">
                    <i class="fa-solid fa-bars"></i>
                </span>
                <a href="<?php echo e(route('admin.knowledge.list')); ?>" class=" fs-14 text--dark">
                    <i class="fa-solid fa-arrow-left"></i>
                    <?php echo app('translator')->get('Back'); ?>
                </a>
            </div>
            <a href="<?php echo e(route('admin.knowledge.add')); ?>" class="link">
                <i class="las la-plus"></i>
                <span class="text"><?php echo app('translator')->get('Create New Article'); ?></span>
            </a>
        </div>

        <div class="knowledge-layout-wrapper">
            <div class="knowledge-layout-sidebar">
                <div class="knowledge-layout-sidebar-close">
                    <i class="fa-solid fa-xmark"></i>
                </div>

                <ul class="knowledge-setting-nav">
                    <li class="knowledge-setting-nav-item">
                        <a href="<?php echo e(route('admin.knowledge.analytics')); ?>" class="knowledge-setting-nav-link">
                            <?php echo $__env->make('admin.partials.svg.analytics', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            <span class="text"><?php echo app('translator')->get('Analytics'); ?></span>
                        </a>
                    </li>
                    <li class="knowledge-setting-nav-item has-dropdown">
                        <a href="<?php echo e(route('admin.knowledge.category.list')); ?>" class="knowledge-setting-nav-link active">
                            <?php echo $__env->make('admin.partials.svg.setting', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            <span class="text"><?php echo app('translator')->get('Knowledge Category'); ?></span>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="knowledge-layout-body">
                <div class="knowledge-setting-header">
                    <p class="fs-14 py-1">
                        <?php echo app('translator')->get('Category'); ?>
                    </p>
                </div>

                <div class="category-wrapper">

                    <?php if($activeCategory): ?>
                        <div class="category-card mb-4">
                            <div class="category-card-top">
                                <div class="category-card-thumb">
                                    <img src="<?php echo e(getImage(getFilePath('knowledgeCategory') . '/' . $activeCategory->image, getFileSize('knowledgeCategory'))); ?>" alt="Company" />
                                </div>
                                <div class="category-card-right">
                                    <div class="category-card-content">
                                        <p class="fw-medium text--dark"><?php echo e(__($activeCategory->name)); ?></p>
                                        <p class="fs-14"><?php echo app('translator')->get('Description'); ?></p>
                                        <p class="fs-14"><span class="text--dark fw-medium"></span><?php echo e(__($activeCategory->description)); ?></p>
                                    </div>
                                    <div class="category-card-action">
                                        <button class="link category-offcanvas-toggle editCategory" data-category="<?php echo e($activeCategory); ?>" data-image="<?php echo e(getImage(getFilePath('knowledgeCategory') . '/' . $activeCategory->image)); ?>" data-subcategory="0">
                                            <?php echo $__env->make('admin.partials.svg.edit', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                        </button>
                                        <button class="link confirmationBtn" data-action="<?php echo e(route('admin.knowledge.category.delete', $activeCategory->id)); ?>" data-question="<?php echo app('translator')->get('Are you sure to delete this category?'); ?>">
                                            <?php echo $__env->make('admin.partials.svg.delete', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div class="category-card-info">
                                <div class="category-card-info-item">
                                    <p class="title"><?php echo app('translator')->get('Created by'); ?></p>
                                    <p class="value"><?php echo e(__($activeCategory->admin->name)); ?></p>
                                </div>
                                <div class="category-card-info-divider"></div>
                                <div class="category-card-info-item">
                                    <p class="title"><?php echo app('translator')->get('Created at'); ?></p>
                                    <p class="value"><?php echo e(showDateTime($activeCategory->created_at, 'd-M-Y')); ?></p>
                                </div>
                                <div class="category-card-info-divider"></div>
                                <div class="category-card-info-item">
                                    <p class="title"><?php echo app('translator')->get('No. of Subcategory'); ?></p>
                                    <p class="value knowledge-category-value"><?php echo e(str_pad($activeCategory->subcategories->count(), 2, '0', STR_PAD_LEFT)); ?></p>
                                </div>
                                <div class="category-card-info-divider"></div>
                                <div class="category-card-info-item">
                                    <p class="title"><?php echo app('translator')->get('Total Articles'); ?></p>
                                    <p class="value knowledge-category-value"><?php echo e(str_pad($activeCategory->knowledge->count(), 2, '0', STR_PAD_LEFT)); ?></p>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>

                    <div class="category-view-wrapper">
                        <div class="category-view">
                            <div class="category-view-header">
                                <div class="flex-align gap-2">
                                    <span class="text--dark">
                                        <?php echo $__env->make('admin.partials.svg.knowledge_category', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </span>
                                    <span class="text--dark"><?php echo app('translator')->get('Category Name'); ?></span>
                                </div>

                                <button class="text--base category-offcanvas-toggle addCategory" data-subcategory="0"><?php echo app('translator')->get('Add'); ?></button>
                            </div>

                            <div class="category-view-list">
                                <?php $__empty_1 = true; $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <div class="category-view-item <?php echo e($category->id == $activeCategory->id ? 'active' : ''); ?>">
                                        <a href="<?php echo e(url()->current()); ?>?category=<?php echo e($category->id); ?>" class="category-view-item-content">
                                            <p class="title"><?php echo e(__($category->name)); ?></p>
                                            <p class="value"><?php echo e($category->knowledge_count); ?> <?php echo app('translator')->get('Articles'); ?></p>
                                        </a>
                                        <div class="category-view-item-action">
                                            <div class="form--switch sm-style">
                                                <input type="checkbox" class="form-check-input categoryStatus" data-id="<?php echo e($category->id); ?>" <?php if($category->status): echo 'checked'; endif; ?> />
                                            </div>
                                            <div class="dropdown action-dropdown">
                                                <button class="dropdown-btn" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                                    <span class="icon"><i class="fa-solid fa-ellipsis-vertical"></i></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <li class="dropdown-item">
                                                        <button class="dropdown-link category-offcanvas-toggle editCategory" data-category="<?php echo e($category); ?>" data-image="<?php echo e(getImage(getFilePath('knowledgeCategory') . '/' . $category->image)); ?>" data-subcategory="0">
                                                            <span class="icon">
                                                                <?php echo $__env->make('admin.partials.svg.edit', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                                            </span>
                                                            <span class="text"><?php echo app('translator')->get('Edit'); ?></span>
                                                        </button>
                                                    </li>
                                                    <li class="dropdown-item">
                                                        <button class="dropdown-link confirmationBtn" data-action="<?php echo e(route('admin.knowledge.category.delete', $category->id)); ?>" data-question="<?php echo app('translator')->get('Are you sure to delete this category?'); ?>">
                                                            <span class="icon">
                                                                <?php echo $__env->make('admin.partials.svg.delete', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                                            </span>
                                                            <span class="text"><?php echo app('translator')->get('Delete'); ?></span>
                                                        </button>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <?php if (isset($component)) { $__componentOriginal785b8965d65806a202a14875024d2012 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal785b8965d65806a202a14875024d2012 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.empty-message','data' => ['message' => 'No category found']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('empty-message'); ?>
<?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(['message' => 'No category found']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $attributes = $__attributesOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__attributesOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $component = $__componentOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__componentOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="category-view">
                            <div class="category-view-header">
                                <div class="flex-align gap-2">
                                    <span class="text--dark">
                                        <?php echo $__env->make('admin.partials.svg.knowledge_category', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </span>
                                    <span class="text--dark"><?php echo app('translator')->get('Subcategory'); ?></span>
                                </div>
                                <?php if($activeCategory): ?>
                                    <button class="text--base category-offcanvas-toggle addCategory" data-subcategory="1"><?php echo app('translator')->get('Add'); ?></button>
                                <?php endif; ?>
                            </div>

                            <div class="category-view-list">
                                <?php if($activeCategory): ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $activeCategory->subcategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subcategory): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                        <div class="category-view-item">
                                            <div class="category-view-item-content">
                                                <p class="title"><?php echo e(__($subcategory->name)); ?></p>
                                                <p class="value"><?php echo e($subcategory->subcategories_knowledge_count); ?> <?php echo app('translator')->get('Articles'); ?></p>
                                            </div>
                                            <div class="category-view-item-action">
                                                <div class="form--switch sm-style">
                                                    <input type="checkbox" class="form-check-input categoryStatus" data-id="<?php echo e($subcategory->id); ?>" <?php if($subcategory->status): echo 'checked'; endif; ?> />
                                                </div>
                                                <div class="dropdown action-dropdown">
                                                    <button class="dropdown-btn" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                                        <span class="icon"><i class="fa-solid fa-ellipsis-vertical"></i></span>
                                                    </button>
                                                    <ul class="dropdown-menu">
                                                        <li class="dropdown-item">
                                                            <button class="dropdown-link category-offcanvas-toggle editCategory" data-category="<?php echo e($subcategory); ?>" data-image="<?php echo e(getImage(getFilePath('knowledgeCategory') . '/' . $subcategory->image)); ?>" data-subcategory="1">
                                                                <span class="icon">
                                                                    <?php echo $__env->make('admin.partials.svg.edit', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                                                </span>
                                                                <span class="text"><?php echo app('translator')->get('Edit'); ?></span>
                                                            </button>
                                                        </li>
                                                        <li class="dropdown-item">
                                                            <button class="dropdown-link confirmationBtn" data-action="<?php echo e(route('admin.knowledge.category.delete', $category->id)); ?>" data-question="<?php echo app('translator')->get('Are you sure to delete this category?'); ?>">
                                                                <span class="icon">
                                                                    <?php echo $__env->make('admin.partials.svg.delete', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                                                </span>
                                                                <span class="text"><?php echo app('translator')->get('Delete'); ?></span>
                                                            </button>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <?php if (isset($component)) { $__componentOriginal785b8965d65806a202a14875024d2012 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal785b8965d65806a202a14875024d2012 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.empty-message','data' => ['message' => 'No subcategory found']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('empty-message'); ?>
<?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(['message' => 'No subcategory found']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $attributes = $__attributesOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__attributesOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $component = $__componentOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__componentOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
                                    <?php endif; ?>
                                <?php else: ?>
                                    <?php if (isset($component)) { $__componentOriginal785b8965d65806a202a14875024d2012 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal785b8965d65806a202a14875024d2012 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.empty-message','data' => ['message' => 'No subcategory found']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('empty-message'); ?>
<?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(['message' => 'No subcategory found']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $attributes = $__attributesOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__attributesOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $component = $__componentOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__componentOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
                                <?php endif; ?>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="add-category-offcanvas">
        <form class="categoryForm" method="POST" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <input type="hidden" name="category_id">
            <div class="flex-between mb-20">
                <h5 class="title fw-semibold formTitle"></h5>
                <button class="add-category-offcanvas-close">
                    <i class="las la-times fs-18"></i>
                </button>
            </div>
            <div class="mb-20">
                <div class="image-uploader imageUploader style-two">
                    <label class="image-uploader-preview">
                        <img src="" class="imagePreview" alt="<?php echo app('translator')->get('Preview'); ?>">
                        <span class="icon">
                            <i class="fa-solid fa-plus"></i>
                        </span>

                        <input type="file" name="image" class="imageInput d-none" accept=".png, .jpg, .jpeg">
                    </label>
                    <div class="image-uploader-content">
                        <p class="title"><?php echo app('translator')->get('Category Image'); ?></p>
                        <p class="note">
                            <?php echo app('translator')->get('Supported formats'); ?>: <?php echo app('translator')->get('PNG, JPG, JPEG.'); ?>
                        </p>
                    </div>
                </div>
            </div>
            <div class="mb-20">
                <div class="d-flex flex-wrap justify-content-between">
                    <label class="form--label style-two"><?php echo app('translator')->get('Name'); ?></label>
                    <a href="javascript:void(0)" class="buildSlug fs-14 fs-"><i class="las la-link"></i> <?php echo app('translator')->get('Make Slug'); ?></a>
                </div>
                <input type="text" class="form--control md-style" name="name" placeholder="<?php echo app('translator')->get('Category Name'); ?>" required />
            </div>
            <div class="mb-20">
                <label class="form--label style-two"><?php echo app('translator')->get('Slug'); ?></label>
                <input type="text" class="form--control md-style" name="slug" placeholder="<?php echo app('translator')->get('Category Slug'); ?>" required />
            </div>

            <div class="mb-20">
                <label class="form--label style-two"><?php echo app('translator')->get('Description'); ?></label>
                <textarea class="form--control sm-style" name="description" placeholder="<?php echo app('translator')->get('Description'); ?>" required></textarea>
            </div>

            <div class="mt-5">
                <div class="flex-align gap-2">
                    <button class="btn btn--sm btn--base"><?php echo app('translator')->get('Save'); ?></button>
                    <button class="btn btn--sm btn-outline--secondary add-category-offcanvas-close" type="button"><?php echo app('translator')->get('Cancel'); ?></button>
                </div>
            </div>
        </form>
    </div>

    <?php if (isset($component)) { $__componentOriginalbd5922df145d522b37bf664b524be380 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalbd5922df145d522b37bf664b524be380 = $attributes; } ?>
<?php $component = App\View\Components\ConfirmationModal::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('confirmation-modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\ConfirmationModal::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalbd5922df145d522b37bf664b524be380)): ?>
<?php $attributes = $__attributesOriginalbd5922df145d522b37bf664b524be380; ?>
<?php unset($__attributesOriginalbd5922df145d522b37bf664b524be380); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalbd5922df145d522b37bf664b524be380)): ?>
<?php $component = $__componentOriginalbd5922df145d522b37bf664b524be380; ?>
<?php unset($__componentOriginalbd5922df145d522b37bf664b524be380); ?>
<?php endif; ?>

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


<?php $__env->startPush('script'); ?>
    <?php echo $__env->make('admin.setting.status_change_script', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <script>
        (function($) {
            "use strict";

            let imagePreview;
            let categoryForm = $('.categoryForm');
            let action = `<?php echo e(route('admin.knowledge.category.save')); ?>`;

            $('.addCategory').on('click', function() {
                categoryForm[0].reset();
                categoryForm.attr('action', action);
                imagePreview = `<?php echo e(getImage(null, getFileSize('knowledgeCategory'))); ?>`;
                $('.imagePreview').attr('src', imagePreview);

                if ($(this).data('subcategory')) {
                    $('.formTitle').text(`<?php echo app('translator')->get('Add Subcategory of '); ?> <?php echo e($activeCategory->name ?? ''); ?>`);
                    $('[name=category_id]').val(`<?php echo e($activeCategory->id ?? 0); ?>`);
                } else {
                    $('.formTitle').text(`<?php echo app('translator')->get('Add Category'); ?>`);
                    $('[name=category_id]').val(0);
                }
                $('[name=slug]').val('');
            });

            $('.editCategory').on('click', function() {
                categoryForm[0].reset();

                let category = $(this).data('category');
                let image = $(this).data('image') || `<?php echo e(getImage(null, getFileSize('knowledgeCategory'))); ?>`;

                categoryForm.attr('action', action + '/' + category.id);
                $('[name=category_id]').val(category.id ?? 0);
                $('[name=name]').val(category.name ?? '');
                $('[name=slug]').val(category.slug ?? '');
                $('[name=description]').val(category.description ?? '');
                $('.imagePreview').attr('src', image);

                if ($(this).data('subcategory')) {
                    $('.formTitle').text(`<?php echo app('translator')->get('Update Subcategory'); ?>`);
                } else {
                    $('.formTitle').text(`<?php echo app('translator')->get('Update Category'); ?>`);
                }
            });

            $('.buildSlug').on('click', function() {
                let categoryName = $(this).closest('.categoryForm').find('[name=name]').val().trim();
                let slug = categoryName.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/-+/g, '-').replace(/^-+|-+$/g, '');
                $(this).closest('.categoryForm').find('[name=slug]').val(slug);
            });

            handleStatusToggle('.categoryStatus', `<?php echo e(route('admin.knowledge.category.status', '')); ?>`, 'category');

        })(jQuery);
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('admin.layouts.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\projects\custom_viserdesk\Files\core\resources\views/admin/knowledge_category/list.blade.php ENDPATH**/ ?>