<?php

return [
    'name' => 'Bms',

    /*
    |--------------------------------------------------------------------------
    | Service contract bindings (the anti-corruption layer)
    |--------------------------------------------------------------------------
    |
    | Every interaction between BMS and the ERP core passes through one of
    | these contracts. Exactly ONE implementation is bound per contract:
    | an ERP adapter (delegates to existing ERP functionality) or a BMS-native
    | implementation (when the ERP lacks the capability). Swapping a reuse-vs-
    | build decision is a one-line change here — ERP core files are never
    | modified, and the module stays portable.
    |
    */
    'bindings' => [
        \Modules\Bms\Services\Contracts\ContactServiceContract::class      => \Modules\Bms\Services\Adapters\Erp\ErpContactService::class,
        \Modules\Bms\Services\Contracts\MediaServiceContract::class        => \Modules\Bms\Services\Adapters\Media\SmartStorageMediaService::class,
        \Modules\Bms\Services\Contracts\NotificationServiceContract::class => \Modules\Bms\Services\Adapters\Erp\ErpNotificationService::class,
        \Modules\Bms\Services\Contracts\InvoiceServiceContract::class      => \Modules\Bms\Services\Adapters\Erp\ErpInvoiceService::class,
        \Modules\Bms\Services\Contracts\StockServiceContract::class        => \Modules\Bms\Services\Adapters\Erp\ErpStockService::class,
        \Modules\Bms\Services\Contracts\PurchaseServiceContract::class     => \Modules\Bms\Services\Adapters\Erp\ErpPurchaseService::class,
        \Modules\Bms\Services\Contracts\PaymentServiceContract::class      => \Modules\Bms\Services\Adapters\Erp\ErpPaymentService::class,
        \Modules\Bms\Services\Contracts\AssetServiceContract::class        => \Modules\Bms\Services\Adapters\Native\NativeAssetService::class,
        \Modules\Bms\Services\Contracts\PushServiceContract::class         => \Modules\Bms\Services\Notifications\PushService::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Web-push (VAPID) — BMS-native, built on minishlink/web-push
    |--------------------------------------------------------------------------
    | Generate a key pair with `php artisan bms:vapid-keys` and place the
    | values in .env. Push is inert until both keys are set.
    */
    'vapid' => [
        'public_key'  => env('BMS_VAPID_PUBLIC_KEY'),
        'private_key' => env('BMS_VAPID_PRIVATE_KEY'),
        'subject'     => env('BMS_VAPID_SUBJECT', 'mailto:admin@askargroup.example'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Matching engine defaults (overridable per business in P1 settings)
    |--------------------------------------------------------------------------
    |
    | Weighted scoring: score = Σ(weight × criterion match) normalized to 100%.
    | A hall renders as a match when its score >= threshold. Below-threshold
    | halls render last, each failed criterion shown as an explicit reason.
    |
    */
    'matching' => [
        'threshold' => 60,
        'weights' => [
            'capacity'     => 25,
            'fnb_level'    => 20,
            'venue_type'   => 15,
            'area'         => 15,
            'budget'       => 15,
            'availability' => 10,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Holds
    |--------------------------------------------------------------------------
    | Tentative holds on a hall-date expire after this many minutes unless
    | converted to a confirmed booking. A scheduled job releases stale holds.
    */
    'hold_ttl_minutes' => 1440,

    'currency' => env('BMS_DEFAULT_CURRENCY', 'EGP'),

    /*
    |--------------------------------------------------------------------------
    | Public funnel business (single-tenant default)
    |--------------------------------------------------------------------------
    | The business the client PWA's public endpoints resolve to. Null = first
    | business. An X-Bms-Business request header overrides it (future
    | multi-brand hosting).
    */
    'public_business_id' => env('BMS_PUBLIC_BUSINESS_ID'),

    // OTP for client verification (issued only at visit booking / portal access)
    'otp_ttl_minutes' => 10,

    /*
    |--------------------------------------------------------------------------
    | Client test sign-in (testing only)
    |--------------------------------------------------------------------------
    | When true (or APP_DEBUG), the client PWA exposes a one-tap "test sign-in"
    | that logs in as a seeded demo client — handy while testing without real
    | OTP/email delivery. NEVER leave enabled on a real production tenant.
    */
    'test_login' => env('BMS_TEST_LOGIN', false),

    /*
    |--------------------------------------------------------------------------
    | Booking finance & cancellation policy (overridable per business in P1)
    |--------------------------------------------------------------------------
    | These are the FALLBACK defaults. A business can override each via the
    | bms_settings keys 'cancellation_policy', 'payment_schedule_template' and
    | 'enforce_deposit_gate' from the P1 Booking Policy editor.
    */
    'payment_schedule_template' => [
        ['label' => 'Deposit', 'kind' => 'deposit',  'percent' => 50, 'offset_days' => -30],
        ['label' => 'Balance', 'kind' => 'balance',  'percent' => 50, 'offset_days' => -3],
    ],

    'enforce_deposit_gate' => env('BMS_ENFORCE_DEPOSIT_GATE', false),

    'cancellation_policy' => [
        'enabled'                 => true,
        'basis'                   => 'invoice_total', // booking total_amount
        'default_penalty_percent' => 0,               // outside every tier (e.g. > the largest days_before)
        'reschedule_uses_policy'  => true,            // a reschedule inside the window charges the same fee
        // Most-severe matching tier wins: pick the smallest days_before whose
        // window still contains daysToEvent (daysToEvent <= days_before).
        'tiers' => [
            ['days_before' => 7, 'penalty_percent' => 25],
            ['days_before' => 2, 'penalty_percent' => 100],
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Cancellation reasons (#9) — editable per business in the Booking Policy
    | editor (bms_settings key 'cancellation_reasons'). Each: code + EN/AR label.
    */
    'cancellation_reasons' => [
        ['code' => 'client_request',  'en' => 'Client changed plans',     'ar' => 'تغيّرت خطط العميل'],
        ['code' => 'date_conflict',   'en' => 'Date no longer available', 'ar' => 'التاريخ لم يعد متاحاً'],
        ['code' => 'budget',          'en' => 'Budget',                   'ar' => 'الميزانية'],
        ['code' => 'duplicate',       'en' => 'Duplicate / test booking', 'ar' => 'حجز مكرر/تجريبي'],
        ['code' => 'force_majeure',   'en' => 'Force majeure',            'ar' => 'ظروف قاهرة'],
        ['code' => 'other',           'en' => 'Other',                    'ar' => 'أخرى'],
    ],

    /*
    |--------------------------------------------------------------------------
    | QC failure reasons (#7) — selectable when a checklist item fails; editable
    | per business via bms_settings key 'qc_reasons'.
    */
    'qc_reasons' => [
        ['code' => 'not_ready',   'en' => 'Not ready in time',   'ar' => 'غير جاهز في الوقت'],
        ['code' => 'damaged',     'en' => 'Damaged / faulty',    'ar' => 'تالف/معطّل'],
        ['code' => 'dirty',       'en' => 'Cleanliness',         'ar' => 'النظافة'],
        ['code' => 'incomplete',  'en' => 'Incomplete / missing','ar' => 'ناقص'],
        ['code' => 'wrong_setup', 'en' => 'Wrong set-up',        'ar' => 'تجهيز خاطئ'],
        ['code' => 'other',       'en' => 'Other',               'ar' => 'أخرى'],
    ],
];
