<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="geo_ip" showInDefault="1" showInWebsite="1" showInStore="1" type="text" translate="label">
            <label>IP Geolocation Redirect</label>
            <tab>mirasvit</tab>
            <resource>Mirasvit_GeoIp::system</resource>

            <group id="general" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="5">
                <label>General settings</label>

                <field id="is_enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1">
                    <label>Enable module</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="popup_type" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Display popup with redirect notice</label>
                    <source_model>Mirasvit\GeoIp\Model\Source\PopupTypeSource</source_model>
                    <comment>Choose whether to display a popup notice when redirecting users, with options for confirmation or simple notification.</comment>
                </field>

                <field id="redirect_destination" translate="label comment" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Redirect destination</label>
                    <source_model>Mirasvit\GeoIp\Model\Source\RedirectDestinationSource</source_model>
                    <comment>Home Page: always redirect to the target store home page. Same Page: resolve the equivalent page on the target store, with automatic fallback to the home page when no match is found.</comment>
                </field>

                <field id="popup_text" translate="label comment" type="textarea" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Popup text</label>
                    <depends>
                        <field id="popup_type" separator=",">notification,confirmation</field>
                    </depends>
                    <comment>Customize the message shown in the redirect popup.</comment>
                </field>

                <field id="ajax_mode" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1">
                    <label>Ajax mode</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <backend_model>Mirasvit\GeoIp\Model\Config\Backend\Notification</backend_model>
                    <comment>Recommended to enable if varnish cache is used</comment>
                </field>

                <field id="data_storage" translate="label comment" type="select" sortOrder="45" showInDefault="1" showInWebsite="1">
                    <label>Redirect data storage</label>
                    <source_model>Mirasvit\GeoIp\Model\Source\RedirectDataStorage</source_model>
                    <comment>Specifies the storage location for redirect data: session or cookies. Use "Cookies" for better compatibility with Full Page Cache when popup is enabled and Ajax mode is disabled.</comment>
                </field>

                <field id="storage_lifetime" translate="label comment" type="text" sortOrder="50" showInDefault="1" showInWebsite="1">
                    <label>Storage lifetime</label>
                    <backend_model>Magento\Cookie\Model\Config\Backend\Lifetime</backend_model>
                    <comment>Enter the lifetime of stored data in seconds or leave empty to use a default value.</comment>
                    <validate>validate-number</validate>
                </field>

                <field id="remote_ip_key" translate="label" type="select" sortOrder="55" showInDefault="1" showInWebsite="1">
                    <label>Remote IP key</label>
                    <source_model>Mirasvit\GeoIp\Model\Source\RemoteIpSource</source_model>
                </field>
            </group>

            <group id="lookup" showInDefault="1" showInWebsite="1" sortOrder="5">
                <label>Country lookup</label>

                <field id="source" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1">
                    <label>The lookup source</label>
                    <source_model>Mirasvit\GeoIp\Model\Source\CountryLookupSource</source_model>
                    <comment>Specifies the data source for IP-based location lookups.</comment>
                </field>

                <field id="is_debug" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1">
                    <label>Debug mode</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment>Enables debug mode, letting users replace their IP address to test redirects from different locations.</comment>
                </field>

                <field id="debug_client_ip" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1">
                    <label>Debug client IP</label>
                    <depends>
                        <field id="is_debug">1</field>
                    </depends>
                    <comment>Apply debugging to requests from this IP</comment>
                </field>

                <field id="debug_ip" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1">
                    <label>IP to debug</label>
                    <depends>
                        <field id="is_debug">1</field>
                    </depends>

                    <comment><![CDATA[64.20.55.251 - USA <br> 80.70.47.234 - France <br> 78.77.22.112 - Sweden <br> 90.77.22.112 - Spain <br> 122.160.97.235 - India <br> 93.244.173.229 - German]]></comment>
                </field>
            </group>

            <group id="limitations" showInDefault="1" showInWebsite="1" sortOrder="10">
                <label>Limitations</label>

                <field id="ignored_ip" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1">
                    <label>Ignored IPs</label>
                    <comment>List of IPs that will be ignored and excluded from redirect handling.</comment>
                </field>
                <field id="ignored_agent" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1">
                    <label>Ignored user agent</label>
                    <comment>Specify user agents that should be ignored and excluded from the redirect process.</comment>
                </field>
                <field id="allow_redirect_by_parameter" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1">
                    <label>Allow redirect by parameter</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment>Requests containing this parameter will not be affected by the Ignored IPs and Ignored User Agent settings.</comment>
                </field>
                <field id="redirect_parameter_name" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1">
                    <label>Parameter name</label>
                    <depends>
                        <field id="geo_ip/limitations/allow_redirect_by_parameter">1</field>
                    </depends>
                    <validate>required-entry</validate>
                </field>
                <field id="redirect_parameter_value" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1">
                    <label>Parameter value</label>
                    <depends>
                        <field id="geo_ip/limitations/allow_redirect_by_parameter">1</field>
                    </depends>
                </field>

                <field id="process_first_visit" translate="label comment" type="select" sortOrder="70" showInDefault="1" showInWebsite="1">
                    <label>Process actions only on the first visit</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment>When enabled, redirects will occur only on the first visit, not on subsequent ones.</comment>
                </field>

                <field id="excluded_urls" translate="label comment" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1">
                    <label>Excluded URLs</label>
                    <backend_model>Mirasvit\GeoIp\Model\Config\Backend\ExcludedUrls</backend_model>
                    <comment>URL path patterns to exclude from all geo processing, one per line. Use * as a wildcard; enter a path, not a full URL. Example: /contact or /promo/*. Include a store code to scope a pattern to that store view only, e.g. /en_us/contact; without one, e.g. /contact, the pattern matches every store view of the website.</comment>
                </field>
            </group>
        </section>
    </system>
</config>
