<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <verbs>
          <add verb="TRACE" allowed="false" />
        </verbs>
      </requestFiltering>
    </security>
    <rewrite>
      <rules>
        <rule name="Well-Known Files" stopProcessing="true">
          <match url="^\.well-known/.*" />
          <action type="None" />
        </rule>
        <rule name="Share Page Proxy" stopProcessing="true">
          <match url="^Ads$" />
          <action type="Rewrite" url="https://api.insouq.com/Ads" appendQueryString="true" />
        </rule>
        <rule name="Social Bot Ad Share Proxy" stopProcessing="true">
          <match url="^(ads|electonic-ads|service-ads|buisness-ads|classified-ads|number-ads|job-ads)/(\d+)/(\d+)/(\d+)$" />
          <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_USER_AGENT}" pattern="WhatsApp" />
            <add input="{HTTP_USER_AGENT}" pattern="facebookexternalhit" />
            <add input="{HTTP_USER_AGENT}" pattern="Facebot" />
            <add input="{HTTP_USER_AGENT}" pattern="Twitterbot" />
            <add input="{HTTP_USER_AGENT}" pattern="LinkedInBot" />
            <add input="{HTTP_USER_AGENT}" pattern="Slackbot" />
          </conditions>
          <action type="Rewrite" url="https://api.insouq.com/Ads?typeId={R:2}&amp;categoryId={R:3}&amp;adId={R:4}" appendQueryString="false" />
        </rule>
        <rule name="Angular Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.html" />
        </rule>
      </rules>
    </rewrite>
    <staticContent>
      <mimeMap fileExtension="." mimeType="application/json" />
      <remove fileExtension=".json" />
      <mimeMap fileExtension=".json" mimeType="application/json" />
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
      <remove fileExtension=".svg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <remove fileExtension=".mp4" />
      <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
    </staticContent>
    <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
        <add name="X-Content-Type-Options" value="nosniff" />
        <add name="X-Frame-Options" value="DENY" />
        <add name="X-XSS-Protection" value="1; mode=block" />
        <add name="Referrer-Policy" value="strict-origin-when-cross-origin" />
        <add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" />
        <add name="Permissions-Policy" value="geolocation=(), microphone=(), camera=()" />
        <add name="Content-Security-Policy" value="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://accounts.google.com https://maps.googleapis.com https://connect.facebook.net https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com data:; img-src 'self' data: https: blob:; connect-src 'self' https://*.insouq.com https://accounts.google.com https://maps.googleapis.com https://cloudflareinsights.com; frame-src https://accounts.google.com; object-src 'none'; base-uri 'self';" />
      </customHeaders>
    </httpProtocol>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
    <defaultDocument>
      <files>
        <clear />
        <add value="index.html" />
      </files>
    </defaultDocument>
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" path="/index.html" responseMode="ExecuteURL" />
    </httpErrors>
  </system.webServer>
</configuration>
