import type { RuntimeCookieTargeting } from 'types/runtime';

export const matchCookieTargeting = (cookie: string, cookieTargeting: RuntimeCookieTargeting[]) => {
  if (!cookieTargeting || cookieTargeting.length === 0) return true;
  if (!cookie) return false;

  for (let targeting of cookieTargeting) {
    for (let cookieValue of targeting.cookieValues) {
      if (cookie.includes(cookieValue)) {
        return true;
      }
    }
  }

  return false;
};
