<?php

declare(strict_types=1);

return [
    'control_branch' => strtolower(trim((string)env('DDB_ACL_CONTROL_BRANCH', 'njch'))),
    'enforcement_mode' => strtolower(trim((string)env('DDB_ACL_ENFORCEMENT_MODE', 'hybrid'))),
    'business_categories' => ['business', 'reporting', 'workflow'],
    'protected_roles' => [
        'SITE_ADMIN' => [
            'name_en' => 'Site Administrator',
            'name_ar' => 'مدير الموقع',
            'policy_mode' => 'ALL',
            'auto_include_new' => true,
            'all_branches' => true,
            'is_protected' => true,
            'is_editable' => false,
        ],
        'GENERAL_MANAGER' => [
            'name_en' => 'General Manager / Owner',
            'name_ar' => 'المدير العام / صاحب العمل',
            'policy_mode' => 'ALL_BUSINESS',
            'auto_include_new' => true,
            'all_branches' => true,
            'is_protected' => true,
            'is_editable' => true,
        ],
    ],
    'permissions' => [
        'overview.view' => ['category' => 'business', 'page' => 'dashboard', 'name_en' => 'Overview', 'name_ar' => 'نظرة عامة'],
        'revenue.view' => ['category' => 'business', 'page' => 'revenue', 'name_en' => 'Revenue', 'name_ar' => 'الإيرادات'],
        'daily_inpatient_revenue.view' => ['category' => 'business', 'page' => 'inpatient-daily-revenue', 'name_en' => 'Daily Inpatient Revenue', 'name_ar' => 'الإيراد اليومي للمنومين'],
        'daily_inpatient_revenue.export' => ['category' => 'reporting', 'page' => 'inpatient-daily-revenue', 'name_en' => 'Export Daily Revenue', 'name_ar' => 'تصدير الإيراد اليومي'],
        'daily_revenue_settings.view' => ['category' => 'settings', 'page' => 'inpatient-daily-revenue-settings', 'name_en' => 'Daily Revenue Settings', 'name_ar' => 'إعدادات الإيراد اليومي'],
        'daily_revenue_settings.manage' => ['category' => 'settings', 'page' => 'inpatient-daily-revenue-settings', 'name_en' => 'Change Daily Revenue Settings', 'name_ar' => 'تعديل إعدادات الإيراد اليومي'],
        'specialty_finance.view' => ['category' => 'business', 'page' => 'specialty-finance', 'name_en' => 'Specialty Finance', 'name_ar' => 'المالية حسب التخصص'],
        'visits.view' => ['category' => 'business', 'page' => 'visits', 'name_en' => 'Visits', 'name_ar' => 'الزيارات'],
        'doctors.view' => ['category' => 'business', 'page' => 'doctors', 'name_en' => 'Doctors', 'name_ar' => 'الأطباء'],
        'beds.view' => ['category' => 'business', 'page' => 'beds', 'name_en' => 'Beds & Capacity', 'name_ar' => 'الأسرة والسعة'],
        'operations.view' => ['category' => 'business', 'page' => 'operations', 'name_en' => 'Operations', 'name_ar' => 'العمليات'],
        'lab_radiology.view' => ['category' => 'business', 'page' => 'lab', 'name_en' => 'Lab & Radiology', 'name_ar' => 'المختبر والأشعة'],
        'branch_comparison.view' => ['category' => 'business', 'page' => 'branch-comparison', 'name_en' => 'Branch Comparison', 'name_ar' => 'مقارنة الفروع'],
        'leadership_huddle.view' => ['category' => 'business', 'page' => 'leadership-huddle', 'name_en' => 'Daily Huddle', 'name_ar' => 'الاجتماع اليومي'],
        'action_center.view' => ['category' => 'workflow', 'page' => 'action-center', 'name_en' => 'Action Center', 'name_ar' => 'مركز الإجراءات'],
        'action_center.review' => ['category' => 'workflow', 'page' => 'action-review', 'name_en' => 'Review and Update Actions', 'name_ar' => 'مراجعة وتحديث الإجراءات'],
        'branch.switch' => ['category' => 'business', 'page' => 'switch-hospital', 'name_en' => 'Change Active Branch', 'name_ar' => 'تغيير الفرع النشط'],
        'security.access_control.manage' => ['category' => 'security', 'page' => 'access-control', 'name_en' => 'Users, Roles & Permissions', 'name_ar' => 'المستخدمون والأدوار والصلاحيات'],
        'diar.view' => ['category' => 'business', 'page' => 'diar', 'name_en' => 'Drug Inventory Risk', 'name_ar' => 'مخاطر مخزون الأدوية'],
        'diar.rules.view' => ['category' => 'settings', 'page' => 'diar-rules', 'name_en' => 'DIAR Rules & Settings', 'name_ar' => 'قواعد وإعدادات مخاطر الأدوية'],
        'diar.rules.manage' => ['category' => 'settings', 'page' => 'diar-rules', 'name_en' => 'Edit DIAR Rules', 'name_ar' => 'تعديل قواعد مخاطر الأدوية'],
        'diar.rules.dry_run' => ['category' => 'workflow', 'page' => 'diar-rules', 'name_en' => 'Run DIAR Rule Simulation', 'name_ar' => 'تشغيل محاكاة قواعد مخاطر الأدوية'],
        'diar.rules.approve' => ['category' => 'security', 'page' => 'diar-rules', 'name_en' => 'Approve DIAR Rule Version', 'name_ar' => 'اعتماد إصدار قواعد مخاطر الأدوية'],
        'diar.rules.activate' => ['category' => 'security', 'page' => 'diar-rules', 'name_en' => 'Activate DIAR Rule Version', 'name_ar' => 'تفعيل إصدار قواعد مخاطر الأدوية'],
        // DIAR4B_INVESTIGATION_PERMISSIONS_V1
        'diar.investigation.view' => ['category' => 'workflow', 'page' => 'diar-investigations', 'name_en' => 'View Drug Risk Investigations', 'name_ar' => 'عرض تحقيقات مخاطر الأدوية'],
        'diar.investigation.assign' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Assign Drug Risk Cases', 'name_ar' => 'تعيين قضايا مخاطر الأدوية'],
        'diar.investigation.review' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Review Drug Risk Cases', 'name_ar' => 'مراجعة قضايا مخاطر الأدوية'],
        'diar.investigation.evidence' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Record Investigation Evidence', 'name_ar' => 'تسجيل أدلة التحقيق'],
        'diar.investigation.escalate' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Escalate Drug Risk Cases', 'name_ar' => 'تصعيد قضايا مخاطر الأدوية'],
        'diar.investigation.close' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Close Drug Risk Cases', 'name_ar' => 'إغلاق قضايا مخاطر الأدوية'],
        // DIAR6B4_CONTROLLED_WORKFLOW_PERMISSIONS_V1
        'diar.investigation.request_information' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Request or Record Investigation Information', 'name_ar' => 'طلب أو تسجيل معلومات التحقيق'],
        'diar.investigation.finding.propose' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Propose Investigation Findings', 'name_ar' => 'اقتراح نتائج التحقيق'],
        'diar.investigation.supervisor_review' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Review Investigation Findings as Supervisor', 'name_ar' => 'مراجعة نتائج التحقيق كمشرف'],
        'diar.investigation.management_approve' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Approve Investigation Findings as Management', 'name_ar' => 'اعتماد نتائج التحقيق إداريًا'],
        'diar.investigation.corrective_action' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Manage Investigation Corrective Actions', 'name_ar' => 'إدارة الإجراءات التصحيحية للتحقيق'],
        'diar.investigation.reopen' => ['category' => 'workflow', 'page' => 'diar-investigation', 'name_en' => 'Reopen Closed Investigation Cases', 'name_ar' => 'إعادة فتح قضايا التحقيق المغلقة'],
        // DIAR_6B_5_R2_7_1_EXPLICIT_ROLE_BOUNDARY
        'diar.developer.full_access' => ['category' => 'technical', 'page' => 'diar-portal', 'name_en' => 'Medication Risk Intelligence Developer Full Visibility', 'name_ar' => 'الرؤية الكاملة لمطور منصة DIAR'],
        'diar.investigation.assigned.view' => ['category' => 'workflow', 'page' => 'diar-investigations', 'name_en' => 'View Assigned DIAR Cases', 'name_ar' => 'عرض قضايا DIAR المسندة'],
        'diar.case_evidence.assigned.view' => ['category' => 'workflow', 'page' => 'diar-case-evidence', 'name_en' => 'View Evidence for Assigned DIAR Cases', 'name_ar' => 'عرض أدلة قضايا DIAR المسندة'],        // DIAR_6B_2_R2_PERMISSIONS
        'diar.portal.view' => ['category' => 'business', 'page' => 'diar-portal', 'name_en' => 'Open DIAR Platform', 'name_ar' => 'فتح منصة DIAR'],
        'diar.executive.view' => ['category' => 'business', 'page' => 'diar-executive-overview', 'name_en' => 'DIAR Executive Views', 'name_ar' => 'العروض التنفيذية لـDIAR'],
        'diar.statistics.view' => ['category' => 'analytics', 'page' => 'diar-statistics', 'name_en' => 'DIAR Annual Statistics', 'name_ar' => 'إحصاءات DIAR السنوية'],
        'diar.cases.view' => ['category' => 'workflow', 'page' => 'diar-cases', 'name_en' => 'View Suspicious Cases', 'name_ar' => 'عرض الحالات المشتبه بها'],
        'diar.reports.view' => ['category' => 'reporting', 'page' => 'diar-reports', 'name_en' => 'DIAR Reports & Excel', 'name_ar' => 'تقارير DIAR وExcel'],
        'diar.governance.view' => ['category' => 'settings', 'page' => 'diar-governance', 'name_en' => 'DIAR Settings & Governance', 'name_ar' => 'إعدادات وحوكمة DIAR'],
        // DIAR_UI1_READ_ONLY_PERMISSIONS_V1
        'diar.command.view' => ['category' => 'analytics', 'page' => 'diar-command-center', 'name_en' => 'View DIAR Command Center', 'name_ar' => 'عرض مركز متابعة مخاطر الأدوية'],
        'diar.engine_runs.view' => ['category' => 'analytics', 'page' => 'diar-engine-runs', 'name_en' => 'View DIAR Engine Runs', 'name_ar' => 'عرض تشغيلات محرك مخاطر الأدوية'],
        'diar.movement_dictionary.view' => ['category' => 'analytics', 'page' => 'diar-movement-dictionary', 'name_en' => 'View DIAR Movement Dictionary', 'name_ar' => 'عرض قاموس حركات الأدوية'],
        'diar.daily_fact.view' => ['category' => 'analytics', 'page' => 'diar-daily-facts', 'name_en' => 'View DIAR Daily Facts', 'name_ar' => 'عرض الحقائق اليومية لحركات الأدوية'],
        'security.audit.view' => ['category' => 'security', 'page' => 'access-control', 'name_en' => 'Security Audit', 'name_ar' => 'سجل تدقيق الصلاحيات'],
        'technical.evidence.view' => ['category' => 'technical', 'page' => '', 'name_en' => 'Technical Evidence', 'name_ar' => 'الأدلة الفنية'],
    ],
    'route_permissions' => [
        'dashboard' => ['*' => 'overview.view'],
        'revenue' => ['*' => 'revenue.view'],
        'revenue-performance-beacon' => ['*' => 'revenue.view'],
        'inpatient-daily-revenue' => ['*' => 'daily_inpatient_revenue.view'],
        'inpatient-daily-revenue-export' => ['*' => 'daily_inpatient_revenue.export'],
        'inpatient-daily-revenue-powerbi-export' => ['*' => 'daily_inpatient_revenue.export'],
        'inpatient-daily-revenue-powerpoint-export' => ['*' => 'daily_inpatient_revenue.export'],
        'inpatient-daily-revenue-settings' => ['GET' => 'daily_revenue_settings.view', 'POST' => 'daily_revenue_settings.manage'],
        'specialty-finance' => ['*' => 'specialty_finance.view'],
        'visits' => ['*' => 'visits.view'],
        'doctors' => ['*' => 'doctors.view'],
        'beds' => ['*' => 'beds.view'],
        'operations' => ['*' => 'operations.view'],
        'lab' => ['*' => 'lab_radiology.view'],
        'branch-comparison' => ['*' => 'branch_comparison.view'],
        'leadership-huddle' => ['*' => 'leadership_huddle.view'],
        'action-center' => ['*' => 'action_center.view'],
        'action-review' => ['GET' => 'action_center.review', 'POST' => 'action_center.review'],
        'action-review-dashboard' => ['*' => 'action_center.review'],
        'action-governance-dashboard' => ['*' => 'action_center.review'],
        'action-governance-update' => ['POST' => 'action_center.review'],
        'switch-hospital' => ['POST' => 'branch.switch'],
        'access-control' => ['GET' => 'security.access_control.manage', 'POST' => 'security.access_control.manage'],
        'diar-rules' => ['GET' => 'diar.rules.view', 'POST' => 'diar.rules.view'],
        // DIAR_6B_5_R2_7_1_EXPLICIT_ROUTES
        'diar-portal' => ['GET' => 'diar.portal.view'],
        'diar-executive-overview' => ['GET' => 'diar.portal.view'],
        'diar-statistics' => ['GET' => 'diar.portal.view'],
        'diar-cases' => ['GET' => 'diar.portal.view'],
        'diar-case-evidence' => ['GET' => 'diar.portal.view'],
        'diar-investigation-workspace' => ['GET' => 'diar.portal.view'],
        'diar-reports' => ['GET' => 'diar.portal.view'],
        'diar-report-excel' => ['GET' => 'diar.portal.view'],
        'diar-report-powerpoint' => ['GET' => 'diar.portal.view'],
        'diar-report-download' => ['GET' => 'diar.portal.view'],
        'diar-governance' => ['GET' => 'diar.portal.view'],
        // DIAR4B_INVESTIGATION_ROUTES_V1
        'diar-investigations' => ['GET' => 'diar.portal.view'],
        'diar-investigation' => ['GET' => 'diar.portal.view', 'POST' => 'diar.portal.view'],
        // DIAR_UI1_READ_ONLY_ROUTES_V1
        'diar-command-center' => ['GET' => 'diar.command.view'],
        'diar-engine-runs' => ['GET' => 'diar.engine_runs.view'],
        'diar-movement-dictionary' => ['GET' => 'diar.movement_dictionary.view'],
        'diar-daily-facts' => ['GET' => 'diar.daily_fact.view'],
        // DIAR_UI3_READ_ONLY_WORKSPACE_ROUTES_V1
        'diar-statistical-profiles' => ['GET' => 'diar.statistics.view'],
        'diar-anomaly-candidates' => ['GET' => 'diar.cases.view'],
    ],
];
