import { __require as requireUtils } from "./utils.js";
var patterns;
var hasRequiredPatterns;
function requirePatterns() {
  if (hasRequiredPatterns) return patterns;
  hasRequiredPatterns = 1;
  var __defProp = Object.defineProperty;
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  var __getOwnPropNames = Object.getOwnPropertyNames;
  var __hasOwnProp = Object.prototype.hasOwnProperty;
  var __export = (target, all) => {
    for (var name in all)
      __defProp(target, name, { get: all[name], enumerable: true });
  };
  var __copyProps = (to, from, except, desc) => {
    if (from && typeof from === "object" || typeof from === "function") {
      for (let key of __getOwnPropNames(from))
        if (!__hasOwnProp.call(to, key) && key !== except)
          __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
    }
    return to;
  };
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  var patterns_exports = {};
  __export(patterns_exports, {
    AUDIO_EXTENSIONS: () => AUDIO_EXTENSIONS,
    DASH_EXTENSIONS: () => DASH_EXTENSIONS,
    FLV_EXTENSIONS: () => FLV_EXTENSIONS,
    HLS_EXTENSIONS: () => HLS_EXTENSIONS,
    MATCH_URL_DAILYMOTION: () => MATCH_URL_DAILYMOTION,
    MATCH_URL_FACEBOOK: () => MATCH_URL_FACEBOOK,
    MATCH_URL_FACEBOOK_WATCH: () => MATCH_URL_FACEBOOK_WATCH,
    MATCH_URL_KALTURA: () => MATCH_URL_KALTURA,
    MATCH_URL_MIXCLOUD: () => MATCH_URL_MIXCLOUD,
    MATCH_URL_MUX: () => MATCH_URL_MUX,
    MATCH_URL_SOUNDCLOUD: () => MATCH_URL_SOUNDCLOUD,
    MATCH_URL_STREAMABLE: () => MATCH_URL_STREAMABLE,
    MATCH_URL_TWITCH_CHANNEL: () => MATCH_URL_TWITCH_CHANNEL,
    MATCH_URL_TWITCH_VIDEO: () => MATCH_URL_TWITCH_VIDEO,
    MATCH_URL_VIDYARD: () => MATCH_URL_VIDYARD,
    MATCH_URL_VIMEO: () => MATCH_URL_VIMEO,
    MATCH_URL_WISTIA: () => MATCH_URL_WISTIA,
    MATCH_URL_YOUTUBE: () => MATCH_URL_YOUTUBE,
    VIDEO_EXTENSIONS: () => VIDEO_EXTENSIONS,
    canPlay: () => canPlay
  });
  patterns = __toCommonJS(patterns_exports);
  var import_utils2 = /* @__PURE__ */ requireUtils();
  const MATCH_URL_YOUTUBE = /(?:youtu\.be\/|youtube(?:-nocookie|education)?\.com\/(?:embed\/|v\/|watch\/|watch\?v=|watch\?.+&v=|shorts\/|live\/))((\w|-){11})|youtube\.com\/playlist\?list=|youtube\.com\/user\//;
  const MATCH_URL_SOUNDCLOUD = /(?:soundcloud\.com|snd\.sc)\/[^.]+$/;
  const MATCH_URL_VIMEO = /vimeo\.com\/(?!progressive_redirect).+/;
  const MATCH_URL_MUX = /stream\.mux\.com\/(?!\w+\.m3u8)(\w+)/;
  const MATCH_URL_FACEBOOK = /^https?:\/\/(www\.)?facebook\.com.*\/(video(s)?|watch|story)(\.php?|\/).+$/;
  const MATCH_URL_FACEBOOK_WATCH = /^https?:\/\/fb\.watch\/.+$/;
  const MATCH_URL_STREAMABLE = /streamable\.com\/([a-z0-9]+)$/;
  const MATCH_URL_WISTIA = /(?:wistia\.(?:com|net)|wi\.st)\/(?:medias|embed)\/(?:iframe\/)?([^?]+)/;
  const MATCH_URL_TWITCH_VIDEO = /(?:www\.|go\.)?twitch\.tv\/videos\/(\d+)($|\?)/;
  const MATCH_URL_TWITCH_CHANNEL = /(?:www\.|go\.)?twitch\.tv\/([a-zA-Z0-9_]+)($|\?)/;
  const MATCH_URL_DAILYMOTION = /^(?:(?:https?):)?(?:\/\/)?(?:www\.)?(?:(?:dailymotion\.com(?:\/embed)?\/video)|dai\.ly)\/([a-zA-Z0-9]+)(?:_[\w_-]+)?(?:[\w.#_-]+)?/;
  const MATCH_URL_MIXCLOUD = /mixcloud\.com\/([^/]+\/[^/]+)/;
  const MATCH_URL_VIDYARD = /vidyard.com\/(?:watch\/)?([a-zA-Z0-9-_]+)/;
  const MATCH_URL_KALTURA = /^https?:\/\/[a-zA-Z]+\.kaltura.(com|org)\/p\/([0-9]+)\/sp\/([0-9]+)00\/embedIframeJs\/uiconf_id\/([0-9]+)\/partner_id\/([0-9]+)(.*)entry_id.([a-zA-Z0-9-_].*)$/;
  const AUDIO_EXTENSIONS = /\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i;
  const VIDEO_EXTENSIONS = /\.(mp4|og[gv]|webm|mov|m4v)(#t=[,\d+]+)?($|\?)/i;
  const HLS_EXTENSIONS = /\.(m3u8)($|\?)/i;
  const DASH_EXTENSIONS = /\.(mpd)($|\?)/i;
  const FLV_EXTENSIONS = /\.(flv)($|\?)/i;
  const canPlayFile = (url) => {
    if (url instanceof Array) {
      for (const item of url) {
        if (typeof item === "string" && canPlayFile(item)) {
          return true;
        }
        if (canPlayFile(item.src)) {
          return true;
        }
      }
      return false;
    }
    if ((0, import_utils2.isMediaStream)(url) || (0, import_utils2.isBlobUrl)(url)) {
      return true;
    }
    return AUDIO_EXTENSIONS.test(url) || VIDEO_EXTENSIONS.test(url) || HLS_EXTENSIONS.test(url) || DASH_EXTENSIONS.test(url) || FLV_EXTENSIONS.test(url);
  };
  const canPlay = {
    youtube: (url) => {
      if (url instanceof Array) {
        return url.every((item) => MATCH_URL_YOUTUBE.test(item));
      }
      return MATCH_URL_YOUTUBE.test(url);
    },
    soundcloud: (url) => MATCH_URL_SOUNDCLOUD.test(url) && !AUDIO_EXTENSIONS.test(url),
    vimeo: (url) => MATCH_URL_VIMEO.test(url) && !VIDEO_EXTENSIONS.test(url) && !HLS_EXTENSIONS.test(url),
    mux: (url) => MATCH_URL_MUX.test(url),
    facebook: (url) => MATCH_URL_FACEBOOK.test(url) || MATCH_URL_FACEBOOK_WATCH.test(url),
    streamable: (url) => MATCH_URL_STREAMABLE.test(url),
    wistia: (url) => MATCH_URL_WISTIA.test(url),
    twitch: (url) => MATCH_URL_TWITCH_VIDEO.test(url) || MATCH_URL_TWITCH_CHANNEL.test(url),
    dailymotion: (url) => MATCH_URL_DAILYMOTION.test(url),
    mixcloud: (url) => MATCH_URL_MIXCLOUD.test(url),
    vidyard: (url) => MATCH_URL_VIDYARD.test(url),
    kaltura: (url) => MATCH_URL_KALTURA.test(url),
    file: canPlayFile
  };
  return patterns;
}
export {
  requirePatterns as __require
};
//# sourceMappingURL=patterns.js.map
