import { type NextMiddleware, NextResponse } from "next/server"

import { Lang } from "@/constants/languages"

import { getDefaultRequestHeaders } from "./utils"

import type { MiddlewareMatcher } from "@/types/middleware"

export const middleware: NextMiddleware = async (request) => {
  const headers = getDefaultRequestHeaders(request)
  return NextResponse.next({
    request: {
      headers,
    },
  })
}

export const matcher: MiddlewareMatcher = (request) => {
  return !!request.nextUrl.pathname.match(
    new RegExp(`^/(${Object.values(Lang).join("|")})/(sas-x-scandic)/.+`)
  )
}
