<?php

return [
    'name' => 'Core',

    /**
     * Should we consider the core_user.email field the username field?
     * If not, we'll use the core_user.username field.
     */
    'use_email_as_username' => true,

    'google' => [
        'analytics' => [
            // the older universal analytics tracking code like UA-111111111-4
            'tracking' => env('GOOGLE_ANALYTICS_TRACKING_ID', ''),
            // the new GA4 tracking code like G-1A2B3C4D5E
            'tracking_ga4' => env('GOOGLE_ANALYTICS4_TRACKING_ID', ''),
            // a UA View ID, preferably one that filters our the office IP
            'view' => env('GOOGLE_ANALYTICS_VIEW_ID', env('GOOGLE_ANALYTICS_CODE', '')),
            // the GA4 Property ID
            'property' => env('GOOGLE_ANALYTICS4_PROPERTY_ID', env('GOOGLE_ANALYTICS_PROPERTY_ID', '')),
            'key_file' => base_path(env('GOOGLE_KEY_FILE', 'vendor/ignite/modules/Core/resources/services/ignite-platform-3-4fcc58082a35.json')),
        ],
    ],

    // The program type determines the content and features displayed to the
    // participant on certain pages. Currently, the recognized/understood
    // types are: redemption, payout. Otherwise default to redemption.
    'program_type' => 'redemption',

    // Singular|plural label used when displaying point amounts in UI copy.
    'points' => 'Point|Points',

    'theming' => [
        // Set the active theme preset. Explicit options below override the preset values.
        'preset' => env('APP_THEME_PRESET', 'default'),
        // Explicit per-install overrides that win over the selected preset.
        'options' => [],
        // Named preset defaults. Resolved values are exposed on core.theming.* at boot.
        'presets' => [
            'default' => [
                // Ignite 4.1 uses grouped top navigation by default.
                'scaffolding_method' => 'modern',
                'top_navigation_grouped' => true,
                'enable_home_as_guest' => false,
                'default_submission_page' => true,
            ],
            '4.0' => [
                'scaffolding_method' => 'legacy',
                // false = legacy flat top navigation, true = grouped top navigation
                'top_navigation_grouped' => false,
                'enable_home_as_guest' => true,
                'default_submission_page' => false,
            ],
        ],
    ],

    'navigation' => [
        // 'enroll' => [
        //     'label' => 'Enroll',
        //     'position' => 2,
        // ],
        'overview' => [
            'label' => 'Overview',
            'position' => 20,
        ],
        'sign_in' => [
            'label' => 'Sign In',
            'position' => 90,
        ],
        'help' => [
            'label' => 'Help',
            'position' => 100,
        ],
        // ----------
        'program' => [
            'label' => 'Program',
            'footer_position' => 10,
        ],
        'account' => [
            'label' => 'Account',
            'position' => 90,
            'footer_position' => 20,
        ],
        'support' => [
            'label' => 'Support',
            'footer_position' => 30,
        ],
        'legal' => [
            'label' => 'Legal',
            'footer_position' => 40,
        ],
        // ----------
        'eligibility' => [
            // 'label' => 'Eligibility',
            // 'position' => 2,
            'footer_position' => 10,
        ],
        // ----------
        'profile' => [
            'label' => 'Profile',
            'position' => 10,
            'user_position' => 10,
            'footer_position' => 20,
        ],
        'transactions' => [
            'label' => 'Transactions',
            'position' => 90,
            'user_position' => 90,
            'footer_position' => 90,
        ],
        'admin' => [
            'label' => 'Admin',
            'position' => 100,
            'user_position' => 100,
        ],
        'logout' => [
            'label' => 'Sign Out',
            'position' => 110,
            'user_position' => 110,
        ],
        // ----------
        'faq' => [
            // 'label' => 'FAQ',
            // 'position' => 50,
            'footer_position' => 50,
        ],
        'contact' => [
            // 'label' => 'Contact',
            // 'position' => 60,
            'footer_position' => 60,
        ],
        'terms' => [
            // 'label' => 'Terms',
            // 'position' => 10,
            'footer_position' => 10,
        ],
        'privacy' => [
            // 'label' => 'Privacy Policy',
            // 'position' => 20,
            'footer_position' => 20,
        ],
    ],

    'locale' => [
        'money' => 'en_US.UTF-8',
        'currency' => 'USD',
    ],

    'auth' => [
        'drivers' => [
            env('APP_AUTH_SSO_DEFAULT', null),
        ],
    ],

    // Ignite 3 Core supports "demo mode" where the system will generate some
    // sample demoable data for participants, claims and catalog. The next
    // step is to move the code from Core to a dedicated Demo module.
    'demo' => [
        'allow_events_in_console' => false,
    ],

    // The Ignite 3 admin account is added during the seeding process via the
    // command line. In order to dynamically change the admin credentials
    // at install time, you can set the following via environment vars.
    'admin' => [
        'email' => env('ADMIN_EMAIL', 'it@brightspot.email'),
        'password' => env('ADMIN_PASSWORD', 'br1ght3r1d34s!'),
    ],

    /**
     * Source models implement the Source interface and provide a toDropdown method which can be used to
     * retrieve select dropdown values in a polymorphic way for use in forms.
     *
     * @see Ignite\Core\Contracts\Source
     */
    'source' => [
        'models' => [
            'countries' => Ignite\Core\Models\Options\Countries::class,
            'states' => Ignite\Core\Models\Options\States::class,
            'canada_states' => Ignite\Core\Models\Options\CanadaStates::class,
            'user_states' => Ignite\Core\Models\Options\UserStates::class,
            'participant_types' => Ignite\Core\Models\Options\ParticipantTypes::class,
            'user_statuses' => Ignite\Core\Models\Options\UserStatuses::class,
            'user_types' => Ignite\Core\Models\Options\UserTypes::class,
        ],
    ],

    // At certain points in the Ignite, HTML is saved to the database,
    // in order to protect our sites from XSS attacks we purify the html
    // before storing it, so we are safe to render it to the template.
    'html' => [
        // HTML Purifier Options - http://htmlpurifier.org/live/configdoc/plain.html
        'options' => [
            'Core.Encoding' => 'UTF-8',
            'HTML.Doctype' => 'XHTML 1.0 Transitional',
            // Permissive content profile:
            // - Allows nearly all HTML tags and attributes for maximum developer flexibility.
            // - Common data-* style attributes are explicitly allowlisted (HTMLPurifier has no safe data-* wildcard in HTML.Allowed).
            // - Script execution surfaces (script tags, on* handlers, javascript: URIs) remain blocked by HTMLPurifier core.
            'HTML.AllowedElements' => [
                'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
                'p', 'div', 'span', 'section', 'article', 'details', 'summary', 'header', 'footer', 'main', 'aside', 'nav',
                'blockquote', 'ul', 'ol', 'li',
                'table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td',
                'br', 'hr', 'img', 'a', 'button',
                'b', 'strong', 'i', 'em', 'code', 'pre',
            ],
            'HTML.AllowedAttributes' => [
                // Element-specific attributes
                'a.href', 'a.target', 'a.rel',
                'img.src',
                'td.colspan', 'td.rowspan',
                'th.colspan', 'th.rowspan', 'th.scope',
            ],
            'HTML.ForbiddenElements' => ['form', 'input', 'textarea', 'select', 'optgroup', 'option', 'fieldset', 'legend', 'label'],
            // Explicitly allow id attributes on HTML nodes.
            'Attr.EnableID' => true,
            // Suppress HTMLPurifier warnings about unsupported attributes - we're defining our own flexible set
            'Attr.AllowedRev' => [],
            'HTML.MaxImgLength' => null,
            'URI.AllowedSchemes' => ['http' => true, 'https' => true, 'mailto' => true, 'tel' => true],
            'CSS.MaxImgLength' => null,
            // Broad CSS support for developer-authored page content.
            'CSS.AllowedProperties' => [],
            'CSS.Trusted' => true,
            'CSS.AllowTricky' => true,
            'AutoFormat.AutoParagraph' => true,
            'AutoFormat.RemoveEmpty' => false,
            'AutoFormat.RemoveSpansWithoutAttributes' => true,
        ],
        // Our custom configuration (not part of HTMLPurifier)
        'options_custom' => [
            'HTML.GlobalAttributes' => [
                // Core presentation
                'class', 'id', 'style',
                // Bootstrap 4/5
                'data-toggle', 'data-target', 'data-dismiss', 'data-bs-toggle', 'data-bs-target', 'data-bs-dismiss', 'data-bs-placement',
                // Custom data attributes
                'data-value', 'data-id', 'data-section', 'data-module', 'data-url', 'data-method', 'data-confirm', 'data-disable-with', 'data-loading', 'data-loaded', 'data-type', 'data-format', 'data-endpoint', 'data-search', 'data-sort', 'data-filter', 'data-page', 'data-limit',
                // Alpine.js
                'x-data', 'x-if', 'x-for', 'x-show', 'x-on', 'x-bind', 'x-init', 'x-text', 'x-html', 'x-model',
                // Image & media optimization
                'alt', 'title', 'loading', 'decoding', 'srcset', 'sizes', 'crossorigin', 'referrerpolicy',
                // Accessibility
                'role', 'aria-label', 'aria-hidden', 'aria-describedby', 'aria-expanded', 'aria-controls', 'aria-pressed', 'aria-live', 'aria-atomic', 'aria-busy', 'aria-disabled', 'aria-invalid', 'aria-required', 'aria-readonly',
                // Dimensions
                'width', 'height',
                // Navigation & localization
                'tabindex', 'lang', 'dir',
            ],
        ],
    ],

    'participant' => [
        'enrollment' => [
            // set to true by default. it sends email when participant is created in the backend.
            'email_on_backend' => env('PARTICIPANT_ENROLLMENT_EMAIL_ON_BACKEND', true),
            // set to true by default. it sends email when participant is created via importer.
            'email_on_import' => env('PARTICIPANT_ENROLLMENT_EMAIL_ON_IMPORT', true),
            // set to true by default. it assigns security group as 'participant', if not defined in the env file.
            'default_security_group' => env('PARTICIPANT_ENROLLMENT_DEFAULT_SECURITY_GROUP', 'participant'),
            'default_status' => Ignite\Core\Entities\User::STAT_PENDING,
        ],
        'states' => [
            'map' => [
                'US' => Ignite\Core\Models\Options\States::class,
                'CA' => Ignite\Core\Models\Options\CanadaStates::class,
            ],
            'default' => Ignite\Core\Models\Options\States::class,
        ],

        'types' => [
            'Account Executive' => 'Account Executive',
            // 'Sales Engineer' => 'Sales Engineer',
            // 'Sales Manager' => 'Sales Manager',
            // 'Sales Engineer Manager' => 'Sales Engineer Manager',
        ],

        'factory' => [
            'strategy' => Ignite\Core\Services\Participant\Strategy\DefaultStrategy::class,
        ],

        'emails' => [
            'enrollment' => [
                'active' => true,
                'template' => 'emails.auth.registered',
                'subject' => 'Activate your Registration - Enrollment Confirmation',
            ],
        ],
    ],

    'dashboard' => [
        'default' => 'Core',
        'autolocate' => false,
        'setupFilename' => 'settings',
        'startCurrentOffsetDays' => 7,
        'endCurrentOffsetDays' => 0,
        'startPreviousOffsetDays' => 14,
        'endPreviousOffsetDays' => 7,
        'comparison' => 'range',
        'showComparison' => false,
    ],

    'cms' => [
        'disk' => env('CMS_STORAGE_DISK', 'public'),
        'folder' => env('CMS_STORAGE_FOLDER', 'uploads'),
        'templates' => [
            'default' => 'Default',
        ],
        // this should eventually by in the core_page table.
        'headers' => [
            'enroll' => 'Enroll',
            'eligibility' => 'Overview',
            'terms' => 'Overview',
            'faq' => 'Help',
            'contact' => 'Help',
            'privacy' => 'Help',
        ],
    ],

    'transaction' => [
        'resource' => [
            'identifier' => 'email',
            'resolvers' => [
                'user' => Ignite\Core\Models\Import\Resolvers\UserResolver::class,
            ],
        ],
    ],

    'report' => [
        'filters' => [
            Ignite\Core\Models\Report\EnrollmentReport::class => [
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'participant.created_at',
                    'label' => 'Sign Up Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'participant.approved_at',
                    'label' => 'Enroll Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.country',
                    'scope' => Ignite\Core\Models\Grid\Scopes\CountryScope::class,
                    'request' => ['field', 'value'],
                    'label' => 'Country',
                    'field' => 'participant.country',
                    'options' => ['US' => 'US', 'CA' => 'Canada'],
                ],
            ],
            Ignite\Core\Models\Report\TaxReport::class => [
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'tax_date',
                    'label' => 'Tax Dates (Inclusive)',
                ],
                [
                    'view' => 'Core::admin.report.filters.country',
                    'scope' => Ignite\Core\Models\Grid\Scopes\CountryScope::class,
                    'request' => ['field', 'value'],
                    'field' => 'participant.country',
                    'label' => 'Country',
                    'options' => ['US' => 'US', 'CA' => 'Canada'],
                ],
            ],
            Ignite\Core\Models\Report\TotalEarnedReport::class => [
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'transaction.transaction_date',
                    'label' => 'Transaction Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'participant.created_at',
                    'label' => 'Enrolled Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.country',
                    'scope' => Ignite\Core\Models\Grid\Scopes\CountryScope::class,
                    'request' => ['field', 'value'],
                    'field' => 'participant.country',
                    'label' => 'Country',
                    'options' => ['US' => 'US', 'CA' => 'Canada'],
                ],
            ],
            Ignite\Core\Models\Report\TotalRedeemedReport::class => [
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'transaction.transaction_date',
                    'label' => 'Transaction Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'participant.created_at',
                    'label' => 'Enrolled Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.country',
                    'scope' => Ignite\Core\Models\Grid\Scopes\CountryScope::class,
                    'request' => ['field', 'value'],
                    'field' => 'participant.country',
                    'label' => 'Country',
                    'options' => ['US' => 'US', 'CA' => 'Canada'],
                ],
            ],
            Ignite\Core\Models\Report\TotalBalanceReport::class => [
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'transaction.transaction_date',
                    'label' => 'Transaction Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.daterange',
                    'scope' => Ignite\Core\Models\Grid\Scopes\DateScope::class,
                    'request' => ['field', 'value', 'startDate', 'endDate'],
                    'field' => 'participant.created_at',
                    'label' => 'Enrolled Date',
                ],
                [
                    'view' => 'Core::admin.report.filters.country',
                    'scope' => Ignite\Core\Models\Grid\Scopes\CountryScope::class,
                    'request' => ['field', 'value'],
                    'field' => 'participant.country',
                    'label' => 'Country',
                    'options' => ['US' => 'US', 'CA' => 'Canada'],
                ],
            ],
        ],
        // Uncomment and update the Participant Type to be used in Dashboard Reporting/Widgets
        // 'participant-types' => ['Participant'],
        'tax-report' => [
            // -- these are the recommended default values
            // -- however, please adjust for your program!
            // 'transaction_type_filters_earned' => [
            //     Ignite\Core\Entities\Transaction::EARNED,
            //     Ignite\Core\Entities\Transaction::MANUAL_RECEIVE,
            // ],
            // 'transaction_type_filters_redeemed' => [
            //     Ignite\Core\Entities\Transaction::REDEEMED,
            //     Ignite\Core\Entities\Transaction::CANCELLED,
            //     Ignite\Core\Entities\Transaction::MANUAL_REDEEM,
            //     Ignite\Core\Entities\Transaction::RETURN,
            // ],
        ],
    ],

    'seeder' => [
        // the path to your seeder files, like 'modules/Program/database/data'
        // if left null, usually defaults to 'vendor/ignite/modules/Core/database/data'
        'path' => 'modules/Program/database/data',
    ],

    'import' => [
        'queue' => true,

        // if your imports needs more time, you should set this to 'long-running'
        // and create configurations for it in config/horizon.php (timeout parameter)
        // and in config/queue.php (retry_after parameter)
        'queue_connection' => '',

        'timeout' => 300,

        // Where import files and logs will be stored.
        'directory' => 'imports',
        'disk' => 'local',

        'reader' => [
            'pattern' => '/\[(?P<date>.*)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>.+) (?P<context>[\[\{].*[\]\}]) (?P<extra>[\[\{].*[\]\}])/',
        ],

        'types' => [
            'participant' => [
                'class' => Ignite\Core\Services\Importers\Participants::class,
                'label' => 'Participant',
            ],
            'transaction' => [
                'class' => Ignite\Core\Services\Importers\Transactions::class,
                'label' => 'Transaction',
            ],
        ],
    ],

    'file_encryption' => [
        'default' => 'pgp',

        'providers' => [
            'pgp' => [
                'driver' => \Ignite\Core\Files\Encryption\PGPFileEncrypter::class,
                // Some help on gpg: https://itsfoss.com/gpg-encrypt-files-basic/
                // Using a key server might be useful: https://www.privex.io/articles/what-is-gpg
                'decryption' => [
                    // The passphrase for the key you're decrypting with.
                    'passphrase' => env('PGP_DECRYPTION_PASSPHRASE'),
                ],
                'encryption' => [
                    // The recipient is used to determine which public key to use for encryption. This can be either
                    // the recipient's name or email (see gpg --list-keys)
                    'recipient' => env('PGP_ENCRYPTION_RECIPIENT'),
                ],
            ],
        ],
    ],

    'query_filters' => [
        // This is a mapping from permission to query permission filter class. Not all of our user permissions are
        // defined here. You're not limited to those defined here. In your program application, only define those
        // you need for that program. (assigning to null and not including the permission in this array are
        // equivalent).
        //
        // Many of these are setup so that when you add a filter class for a program, it will start filtering things
        // in Core without having to override classes. Some in this list will still need some work done in Core to
        // cover all possible places we could filter, however.
        'permissions' => [
            // You can extend \Ignite\Activity\Entities\Filters\ActivitySubmissionPermissionFilter::class for these permissions.
            'activity.submission.all.browse' => null,
            'activity.submission.all.delete' => null,
            'activity.submission.all.update' => null,
            'activity.submission.claims.browse' => null,
            'activity.submission.claims.delete' => null,
            'activity.submission.claims.update' => null,

            // You can extend \Ignite\Catalog\Entities\Filters\OrderPermissionFilter for this permission.
            'catalog.order.browse' => null,

            // Implement depending on how you've implemented your claims tables (e.g. Avaya's \Program\Entities\Filters\ClaimPermissionFilter).
            'claim.all.browse' => null,
            'claim.browse' => null,
            'claim.create' => null,
            'claim.approved.browse' => null,
            'claim.cancelled.browse' => null,
            'claim.declined.browse' => null,
            'claim.issued.browse' => null,
            'claim.issued.view' => null,
            'claim.pending.browse' => null,
            'claim.process.view' => null,
            'claim.trashed.browse' => null,

            // You can extend \Ignite\Activity\Entities\Filters\OfferPermissionFilter for this permission.
            'claim.offer.offer.browse' => null,

            // You can extend \Ignite\Core\Entities\Filters\ReportPermissionFilter for these permissions.
            'core.report.browse' => null,
            'core.report.export' => null,
            'core.report.view' => null,

            // You can extend \Ignite\Core\Entities\Filters\WaitingTransactionPermissionFilter for these permissions.
            'core.transactions.waiting.assign' => null,
            'core.transactions.waiting.browse' => null,
            'core.transactions.waiting.delete' => null,

            // You can extend \Ignite\Core\Entities\Filters\TransactionPermissionFilter for these permissions.
            'core.user.transaction.browse' => null,

            // You can extend \Ignite\Core\Entities\Filters\UserPermissionFilter for these permissions.
            'core.user.browse' => null,
            'core.user.impersonate' => null,
            'core.user.internal.browse' => null,
            'core.user.trashed.browse' => null,
            'core.user.trashed.restore' => null,
            'core.user.trashed.shred' => null,

            // You can extend \Ignite\Core\Entities\Filters\ParticipantPermissionFilter for these permissions.
            'core.user.participant.browse' => null,
            'core.user.participant.delete' => null,
            'core.user.participant.update' => null,
        ],
    ],

    /* HTTP Headers
     * -------------------------------------------------- //
     * Default configuration for HTTP headers.
     * Our current nginx configuration has the following
     * already configured, so we hide them by default
     * because for some unknown reason, they aren't being
     * removed automatically. Technically, we could
     * remove them from our configuration and update this
     * file to automatically configure them:
     *
     * X-Frame-Options "SAMEORIGIN"
     * X-XSS-Protection "1; mode=block"
     * X-Content-Type-Options "nosniff"
     *
     * Last, but not least, make sure to add the
     * following middleware to the application's
     * App\Http\Kernel $middleware property. It may be
     * changed to be auto-loaded in the future, but as
     * of right now, it is not:
     *
     * \Ignite\Core\Http\Middleware\SecureHeadersMiddleware::class,
     * -------------------------------------------------- */
    'secure_headers' => [
        'show_content_security_policy' => env('HEADER_SHOW_CONTENT_SECURITY_POLICY', true),
        'show_referrer_policy' => env('HEADER_SHOW_REFERRER_POLICY', true),
        'show_strict_transport_security' => env('HEADER_SHOW_STRICT_TRANSPORT_SECURITY', true),
        'show_x_content_type_options' => env('HEADER_SHOW_X_CONTENT_TYPE_OPTIONS', false),
        'show_x_frame_options' => env('HEADER_SHOW_X_FRAME_OPTIONS', false),
        'show_x_xss_protection' => env('HEADER_SHOW_X_XSS_PROTECTION', false),
    ],
];
