<?php

declare(strict_types=1);

namespace App\Services;

/**
 * 菜单级权限（NAV_*）与升级前「旧入口条件」的对应关系，供迁移与双轨鉴权共用。
 */
final class DberpNavigationPermissionDefinition
{
    /**
     * @return array<string, list<string>> nav_code => legacy permission codes（任一则视为曾能进该菜单）
     */
    public static function navCodeToLegacyPermissionCodes(): array
    {
        return [
            DberpPermissionService::NAV_SALES_ANALYSIS => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PURCHASE_ANALYSIS => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_INVENTORY_ANALYSIS => [
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_INVENTORY_EXCEPTION,
                DberpPermissionService::VIEW_STOCKTAKE_DIFFERENCE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SETTLEMENT_ANALYSIS => [
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_COMPREHENSIVE_SUMMARY_ANALYSIS => [
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_INVENTORY_ALERT,
            ],
            DberpPermissionService::NAV_INVENTORY_SUMMARY => [
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_INVENTORY_EXCEPTION,
                DberpPermissionService::VIEW_STOCKTAKE_DIFFERENCE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SETTLEMENT_AGING_ANALYSIS => [
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_DOCUMENT_QUERY => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_INVENTORY_TRANSACTION_QUERY => [
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_INVENTORY_EXCEPTION,
                DberpPermissionService::VIEW_STOCKTAKE_DIFFERENCE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SALES_STATISTICS => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_PRICE_RULE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PURCHASE_STATISTICS => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_CUSTOMER_SALES_RANKING => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_PRICE_RULE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SUPPLIER_PURCHASE_RANKING => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PRODUCT_SALES_RANKING => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_PRICE_RULE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PRODUCT_PURCHASE_RANKING => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PRODUCT_BUSINESS_QUERY => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_RECEIPT_PAYMENT_QUERY => [
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
                DberpPermissionService::CREATE_RECEIPT_ORDER,
                DberpPermissionService::CREATE_PAYMENT_ORDER,
                DberpPermissionService::CONFIRM_RECEIPT_PAYMENT,
                DberpPermissionService::WRITE_OFF,
            ],
            DberpPermissionService::NAV_PURCHASE_INQUIRY_COMPARISON => [
                DberpPermissionService::VIEW_PURCHASE_INQUIRY_QUOTE,
                DberpPermissionService::VIEW_PURCHASE_REQUEST,
            ],
        ];
    }
}
