<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Routing strategy
    |--------------------------------------------------------------------------
    |
    | "subdomain" — the original host-header tenancy: "<slug>.<app_domain>"
    | resolves the tenant, and the master-control panel is bound to a
    | dedicated host (central_domain). Sessions are isolated per host.
    |
    | "path" — tenant identification moves to the first URL segment:
    | "<app_domain>/<slug>/app/..." for tenants and "<app_domain>/<prefix>"
    | for the master-control panel. One host, one certificate. The
    | session cookie stays at path=/, so a browser holds a single tenant
    | session at a time (see docs/path-based-tenancy-plan.md).
    |
    | Route cache must be cleared whenever this value is flipped.
    |
    */

    'routing' => env('TENANCY_ROUTING', 'path'),

    /*
    |--------------------------------------------------------------------------
    | Central (landlord) domains
    |--------------------------------------------------------------------------
    |
    | Hosts served by the master-control panel and public onboarding, NOT by a
    | tenant. Requests to these hosts run in "central" context with tenant
    | scoping disabled. Everything else is treated as a tenant subdomain whose
    | first label is the tenant slug (e.g. "acme" in "acme.example.com").
    |
    | Only meaningful when tenancy.routing = "subdomain". In path mode the
    | central panel lives under the central_prefix path on the single host.
    |
    | Keep "localhost"/"127.0.0.1" here so local dev + the existing test suite
    | run unscoped (single-tenant) by default; use "<slug>.localhost" to exercise
    | a specific tenant locally.
    |
    */

    'central_domains' => array_filter(array_map('trim', explode(',', (string) env(
        'TENANCY_CENTRAL_DOMAINS',
        'admin.localhost,localhost,127.0.0.1'
    )))),

    /*
    |--------------------------------------------------------------------------
    | Master-control (landlord) domain
    |--------------------------------------------------------------------------
    |
    | The single host the master-control Filament panel is bound to (see
    | ->domain() in App\Providers\Filament\CentralPanelProvider). Must also
    | appear in central_domains above so IdentifyTenant treats it as central.
    | In production this is your admin subdomain, e.g. admin.yourdomain.com.
    |
    | Only meaningful when tenancy.routing = "subdomain".
    |
    */

    'central_domain' => env('TENANCY_CENTRAL_DOMAIN', 'admin.localhost'),

    /*
    |--------------------------------------------------------------------------
    | Master-control (landlord) path prefix
    |--------------------------------------------------------------------------
    |
    | The first URL segment that identifies the master-control panel in path
    | routing mode (e.g. "admin" in "yourdomain.com/admin/tenants"). Must be
    | included in reserved_slugs below so no tenant can ever claim it as a
    | slug/first segment.
    |
    */

    'central_prefix' => env('TENANCY_CENTRAL_PREFIX', 'admin'),

    /*
    |--------------------------------------------------------------------------
    | Tenant base domain
    |--------------------------------------------------------------------------
    |
    | Subdomains are built as "<tenant-slug>.<app_domain>". Used to construct
    | cross-domain links (e.g. landlord impersonation hand-off to a tenant).
    | With tenancy.routing = "path" this is a display host only; tenant URLs
    | are built as "/<slug>/app".
    |
    */

    'app_domain' => env('TENANCY_APP_DOMAIN', 'localhost'),

    /*
    |--------------------------------------------------------------------------
    | Reserved slugs
    |--------------------------------------------------------------------------
    |
    | First URL segments that must never belong to a tenant, in path routing
    | mode: top-level paths (the central prefix, Livewire's AJAX endpoints,
    | the dev/ops routes, real public/ directories). IdentityTenant passes
    | these through unresolved; the slug validation on the Master Control
    | forms rejects them at creation time (docs/path-based-tenancy-plan.md
    | Phase 5).
    |
    */

    'reserved_slugs' => array_filter(array_map('trim', explode(',', (string) env(
        'TENANCY_RESERVED_SLUGS',
        'admin,storage,build,up,impersonate,migrate,seed,pin-login,images,vendor,css,fonts,js'
    )))),

    /*
    |--------------------------------------------------------------------------
    | Storage path prefix
    |--------------------------------------------------------------------------
    |
    | Per-tenant uploaded assets are namespaced under this prefix on the public
    | disk: "<prefix>/<tenantId>/...". Inode-light (no per-tenant directory
    | machinery beyond the files themselves).
    |
    */

    'storage_prefix' => env('TENANCY_STORAGE_PREFIX', 'tenants'),
];
