<?xml version="1.0" encoding="UTF-8"?>
<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd">

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <!-- ===================================================================================================
         Session Configuration (managed by Undertow/Servlet, NOT Quarkus config)
         =================================================================================================== -->
    <session-config>
        <session-timeout>60</session-timeout>
        <cookie-config>
            <http-only>true</http-only>
            <secure>false</secure>
        </cookie-config>
        <tracking-mode>COOKIE</tracking-mode>
    </session-config>

    <!-- ===================================================================================================
         JSF/MyFaces Configuration Parameters (Jakarta namespace)
         These MUST be set as context-params, NOT as quarkus.myfaces.* keys.
         =================================================================================================== -->
    <context-param>
        <param-name>jakarta.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>

    <!-- MyFaces-specific configuration parameters -->
    <context-param>
        <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
        <param-value>50</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION</param-name>
        <param-value>10</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.CLIENT_VIEW_STATE_TIMEOUT</param-name>
        <param-value>3600000</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.VIEW_EXPIRED_EXCEPTION_HANDLER_REDIRECT_PAGE</param-name>
        <param-value>/</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.CHECK_ID_PRODUCTION_MODE</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.STRICT_XHTML_LINKS</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES</param-name>
        <param-value>604800000</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.RESOURCE_BUFFER_SIZE</param-name>
        <param-value>2048</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.AUTOMATIC_EXTENSIONLESS_MAPPING</param-name>
        <param-value>false</param-value>
    </context-param>

    <!-- ===================================================================================================
         PrimeFaces Configuration
         =================================================================================================== -->
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>none</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.FONT_AWESOME</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.MOVE_SCRIPTS_TO_BOTTOM</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.CSP</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.UPLOADER</param-name>
        <param-value>commons</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.AUTO_UPDATE</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.CACHE_PROVIDER</param-name>
        <param-value>org.primefaces.cache.DefaultCacheProvider</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.RESOURCE_HANDLER</param-name>
        <param-value>org.primefaces.application.resource.PrimeResourceHandler</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.LEGACY_WIDGET_NAMESPACE</param-name>
        <param-value>false</param-value>
    </context-param>

    <!-- ===================================================================================================
         OmniFaces Configuration
         =================================================================================================== -->
    <context-param>
        <param-name>org.omnifaces.CDN_RESOURCE_HANDLER_DISABLED</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.omnifaces.COMBINED_RESOURCE_HANDLER_DISABLED</param-name>
        <param-value>false</param-value>
    </context-param>

    <!-- Custom Taglibs -->
    <context-param>
        <param-name>jakarta.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/primefaces-freya.taglib.xml</param-value>
    </context-param>

    <!--
        REMOVED CONFLICTING LISTENERS:
        - org.apache.webbeans.servlet.WebBeansConfigurationListener (conflicts with Quarkus Arc)
        - com.sun.faces.config.ConfigureListener (conflicts with MyFaces)

        Quarkus PrimeFaces extension handles CDI and JSF initialization automatically
    -->

    <!-- CSP Nonce Filter - Génère des nonces pour Content Security Policy -->
    <filter>
        <filter-name>CSP Nonce Filter</filter-name>
        <filter-class>dev.lions.unionflow.client.security.CSPNonceFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>CSP Nonce Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- Character Encoding Filter — SUPPRIMÉ : la classe
         org.primefaces.freya.filter.CharacterEncodingFilter n'existe
         pas dans le JAR freya-theme-jakarta 5.0.0 ni dans le classpath.
         L'encodage UTF-8 est géré par Undertow via quarkus.http.body.* -->

    <!-- Faces Servlet (Jakarta namespace) -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <!-- Font MIME Types -->
    <mime-mapping>
        <extension>ttf</extension>
        <mime-type>application/font-sfnt</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff</extension>
        <mime-type>application/font-woff</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>woff2</extension>
        <mime-type>application/font-woff2</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>eot</extension>
        <mime-type>application/vnd.ms-fontobject</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>eot?#iefix</extension>
        <mime-type>application/vnd.ms-fontobject</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exosemibold</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exobolditalic</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exomedium</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#exoregular</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>svg#fontawesomeregular</extension>
        <mime-type>image/svg+xml</mime-type>
    </mime-mapping>
</web-app>
