import { commonjsGlobal as A } from "./index-95aeca36.js";
function Ke(Q, R) {
  for (var oe = 0; oe < R.length; oe++) {
    const ee = R[oe];
    if (typeof ee != "string" && !Array.isArray(ee)) {
      for (const K in ee)
        if (K !== "default" && !(K in Q)) {
          const se = Object.getOwnPropertyDescriptor(ee, K);
          se && Object.defineProperty(Q, K, se.get ? se : {
            enumerable: !0,
            get: () => ee[K]
          });
        }
    }
  }
  return Object.freeze(Object.defineProperty(Q, Symbol.toStringTag, { value: "Module" }));
}
var ye = {}, Je = {
  get exports() {
    return ye;
  },
  set exports(Q) {
    ye = Q;
  }
};
(function(Q) {
  function R(i, e) {
    if (!i)
      throw "First parameter is required.";
    e = e || {
      type: "video"
    }, e = new oe(i, e);
    var t = this;
    function a(o) {
      return e.disableLogs || console.log("RecordRTC version: ", t.version), o && (e = new oe(i, o)), e.disableLogs || console.log("started recording " + e.type + " stream."), c ? (c.clearRecordedData(), c.record(), g("recording"), t.recordingDuration && l(), t) : (s(function() {
        t.recordingDuration && l();
      }), t);
    }
    function s(o) {
      o && (e.initCallback = function() {
        o(), o = e.initCallback = null;
      });
      var m = new ee(i, e);
      c = new m(i, e), c.record(), g("recording"), e.disableLogs || console.log("Initialized recorderType:", c.constructor.name, "for output-type:", e.type);
    }
    function d(o) {
      if (o = o || function() {
      }, !c) {
        v();
        return;
      }
      if (t.state === "paused") {
        t.resumeRecording(), setTimeout(function() {
          d(o);
        }, 1);
        return;
      }
      t.state !== "recording" && !e.disableLogs && console.warn('Recording state should be: "recording", however current state is: ', t.state), e.disableLogs || console.log("Stopped recording " + e.type + " stream."), e.type !== "gif" ? c.stop(m) : (c.stop(), m()), g("stopped");
      function m(C) {
        if (!c) {
          typeof o.call == "function" ? o.call(t, "") : o("");
          return;
        }
        Object.keys(c).forEach(function(w) {
          typeof c[w] != "function" && (t[w] = c[w]);
        });
        var n = c.blob;
        if (!n)
          if (C)
            c.blob = n = C;
          else
            throw "Recording failed.";
        if (n && !e.disableLogs && console.log(n.type, "->", Se(n.size)), o) {
          var u;
          try {
            u = U.createObjectURL(n);
          } catch {
          }
          typeof o.call == "function" ? o.call(t, u) : o(u);
        }
        !e.autoWriteToDisk || b(function(w) {
          var y = {};
          y[e.type + "Blob"] = w, G.Store(y);
        });
      }
    }
    function f() {
      if (!c) {
        v();
        return;
      }
      if (t.state !== "recording") {
        e.disableLogs || console.warn("Unable to pause the recording. Recording state: ", t.state);
        return;
      }
      g("paused"), c.pause(), e.disableLogs || console.log("Paused recording.");
    }
    function r() {
      if (!c) {
        v();
        return;
      }
      if (t.state !== "paused") {
        e.disableLogs || console.warn("Unable to resume the recording. Recording state: ", t.state);
        return;
      }
      g("recording"), c.resume(), e.disableLogs || console.log("Resumed recording.");
    }
    function h(o) {
      postMessage(new FileReaderSync().readAsDataURL(o));
    }
    function b(o, m) {
      if (!o)
        throw "Pass a callback function over getDataURL.";
      var C = m ? m.blob : (c || {}).blob;
      if (!C) {
        e.disableLogs || console.warn("Blob encoder did not finish its job yet."), setTimeout(function() {
          b(o, m);
        }, 1e3);
        return;
      }
      if (typeof Worker < "u" && !navigator.mozGetUserMedia) {
        var n = w(h);
        n.onmessage = function(y) {
          o(y.data);
        }, n.postMessage(C);
      } else {
        var u = new FileReader();
        u.readAsDataURL(C), u.onload = function(y) {
          o(y.target.result);
        };
      }
      function w(y) {
        try {
          var L = U.createObjectURL(new Blob([
            y.toString(),
            "this.onmessage =  function (eee) {" + y.name + "(eee.data);}"
          ], {
            type: "application/javascript"
          })), k = new Worker(L);
          return U.revokeObjectURL(L), k;
        } catch {
        }
      }
    }
    function l(o) {
      if (o = o || 0, t.state === "paused") {
        setTimeout(function() {
          l(o);
        }, 1e3);
        return;
      }
      if (t.state !== "stopped") {
        if (o >= t.recordingDuration) {
          d(t.onRecordingStopped);
          return;
        }
        o += 1e3, setTimeout(function() {
          l(o);
        }, 1e3);
      }
    }
    function g(o) {
      !t || (t.state = o, typeof t.onStateChanged.call == "function" ? t.onStateChanged.call(t, o) : t.onStateChanged(o));
    }
    var p = 'It seems that recorder is destroyed or "startRecording" is not invoked for ' + e.type + " recorder.";
    function v() {
      e.disableLogs !== !0 && console.warn(p);
    }
    var c, S = {
      startRecording: a,
      stopRecording: d,
      pauseRecording: f,
      resumeRecording: r,
      initRecorder: s,
      setRecordingDuration: function(o, m) {
        if (typeof o > "u")
          throw "recordingDuration is required.";
        if (typeof o != "number")
          throw "recordingDuration must be a number.";
        return t.recordingDuration = o, t.onRecordingStopped = m || function() {
        }, {
          onRecordingStopped: function(C) {
            t.onRecordingStopped = C;
          }
        };
      },
      clearRecordedData: function() {
        if (!c) {
          v();
          return;
        }
        c.clearRecordedData(), e.disableLogs || console.log("Cleared old recorded data.");
      },
      getBlob: function() {
        if (!c) {
          v();
          return;
        }
        return c.blob;
      },
      getDataURL: b,
      toURL: function() {
        if (!c) {
          v();
          return;
        }
        return U.createObjectURL(c.blob);
      },
      getInternalRecorder: function() {
        return c;
      },
      save: function(o) {
        if (!c) {
          v();
          return;
        }
        Be(c.blob, o);
      },
      getFromDisk: function(o) {
        if (!c) {
          v();
          return;
        }
        R.getFromDisk(e.type, o);
      },
      setAdvertisementArray: function(o) {
        e.advertisement = [];
        for (var m = o.length, C = 0; C < m; C++)
          e.advertisement.push({
            duration: C,
            image: o[C]
          });
      },
      blob: null,
      bufferSize: 0,
      sampleRate: 0,
      buffer: null,
      reset: function() {
        t.state === "recording" && !e.disableLogs && console.warn("Stop an active recorder."), c && typeof c.clearRecordedData == "function" && c.clearRecordedData(), c = null, g("inactive"), t.blob = null;
      },
      onStateChanged: function(o) {
        e.disableLogs || console.log("Recorder state changed:", o);
      },
      state: "inactive",
      getState: function() {
        return t.state;
      },
      destroy: function() {
        var o = e.disableLogs;
        e = {
          disableLogs: !0
        }, t.reset(), g("destroyed"), S = t = null, ae.AudioContextConstructor && (ae.AudioContextConstructor.close(), ae.AudioContextConstructor = null), e.disableLogs = o, e.disableLogs || console.log("RecordRTC is destroyed.");
      },
      version: "5.6.2"
    };
    if (!this)
      return t = S, S;
    for (var T in S)
      this[T] = S[T];
    return t = this, S;
  }
  R.version = "5.6.2", Q.exports = R, R.getFromDisk = function(i, e) {
    if (!e)
      throw "callback is mandatory.";
    console.log("Getting recorded " + (i === "all" ? "blobs" : i + " blob ") + " from disk!"), G.Fetch(function(t, a) {
      i !== "all" && a === i + "Blob" && e && e(t), i === "all" && e && e(t, a.replace("Blob", ""));
    });
  }, R.writeToDisk = function(i) {
    console.log("Writing recorded blob(s) to disk!"), i = i || {}, i.audio && i.video && i.gif ? i.audio.getDataURL(function(e) {
      i.video.getDataURL(function(t) {
        i.gif.getDataURL(function(a) {
          G.Store({
            audioBlob: e,
            videoBlob: t,
            gifBlob: a
          });
        });
      });
    }) : i.audio && i.video ? i.audio.getDataURL(function(e) {
      i.video.getDataURL(function(t) {
        G.Store({
          audioBlob: e,
          videoBlob: t
        });
      });
    }) : i.audio && i.gif ? i.audio.getDataURL(function(e) {
      i.gif.getDataURL(function(t) {
        G.Store({
          audioBlob: e,
          gifBlob: t
        });
      });
    }) : i.video && i.gif ? i.video.getDataURL(function(e) {
      i.gif.getDataURL(function(t) {
        G.Store({
          videoBlob: e,
          gifBlob: t
        });
      });
    }) : i.audio ? i.audio.getDataURL(function(e) {
      G.Store({
        audioBlob: e
      });
    }) : i.video ? i.video.getDataURL(function(e) {
      G.Store({
        videoBlob: e
      });
    }) : i.gif && i.gif.getDataURL(function(e) {
      G.Store({
        gifBlob: e
      });
    });
  };
  function oe(i, e) {
    return !e.recorderType && !e.type && (!!e.audio && !!e.video ? e.type = "video" : !!e.audio && !e.video && (e.type = "audio")), e.recorderType && !e.type && (e.recorderType === me || e.recorderType === pe || typeof fe < "u" && e.recorderType === fe ? e.type = "video" : e.recorderType === ve ? e.type = "gif" : e.recorderType === he ? e.type = "audio" : e.recorderType === j && (x(i, "audio").length && x(i, "video").length || !x(i, "audio").length && x(i, "video").length ? e.type = "video" : x(i, "audio").length && !x(i, "video").length && (e.type = "audio"))), typeof j < "u" && typeof MediaRecorder < "u" && "requestData" in MediaRecorder.prototype && (e.mimeType || (e.mimeType = "video/webm"), e.type || (e.type = e.mimeType.split("/")[0]), e.bitsPerSecond), e.type || (e.mimeType && (e.type = e.mimeType.split("/")[0]), e.type || (e.type = "audio")), e;
  }
  function ee(i, e) {
    var t;
    return (X || Re || ce) && (t = he), typeof MediaRecorder < "u" && "requestData" in MediaRecorder.prototype && !X && (t = j), e.type === "video" && (X || ce) && (t = me, typeof fe < "u" && typeof ReadableStream < "u" && (t = fe)), e.type === "gif" && (t = ve), e.type === "canvas" && (t = pe), ie() && t !== pe && t !== ve && typeof MediaRecorder < "u" && "requestData" in MediaRecorder.prototype && (x(i, "video").length || x(i, "audio").length) && (e.type === "audio" ? typeof MediaRecorder.isTypeSupported == "function" && MediaRecorder.isTypeSupported("audio/webm") && (t = j) : typeof MediaRecorder.isTypeSupported == "function" && MediaRecorder.isTypeSupported("video/webm") && (t = j)), i instanceof Array && i.length && (t = Oe), e.recorderType && (t = e.recorderType), !e.disableLogs && !!t && !!t.name && console.log("Using recorderType:", t.name || t.constructor.name), !t && le && (t = j), t;
  }
  function K(i) {
    this.addStream = function(e) {
      e && (i = e);
    }, this.mediaType = {
      audio: !0,
      video: !0
    }, this.startRecording = function() {
      var e = this.mediaType, t, a = this.mimeType || {
        audio: null,
        video: null,
        gif: null
      };
      if (typeof e.audio != "function" && ie() && !x(i, "audio").length && (e.audio = !1), typeof e.video != "function" && ie() && !x(i, "video").length && (e.video = !1), typeof e.gif != "function" && ie() && !x(i, "video").length && (e.gif = !1), !e.audio && !e.video && !e.gif)
        throw "MediaStream must have either audio or video tracks.";
      if (e.audio && (t = null, typeof e.audio == "function" && (t = e.audio), this.audioRecorder = new R(i, {
        type: "audio",
        bufferSize: this.bufferSize,
        sampleRate: this.sampleRate,
        numberOfAudioChannels: this.numberOfAudioChannels || 2,
        disableLogs: this.disableLogs,
        recorderType: t,
        mimeType: a.audio,
        timeSlice: this.timeSlice,
        onTimeStamp: this.onTimeStamp
      }), e.video || this.audioRecorder.startRecording()), e.video) {
        t = null, typeof e.video == "function" && (t = e.video);
        var s = i;
        if (ie() && !!e.audio && typeof e.audio == "function") {
          var d = x(i, "video")[0];
          De ? (s = new N(), s.addTrack(d), t && t === me && (t = j)) : (s = new N(), s.addTrack(d));
        }
        this.videoRecorder = new R(s, {
          type: "video",
          video: this.video,
          canvas: this.canvas,
          frameInterval: this.frameInterval || 10,
          disableLogs: this.disableLogs,
          recorderType: t,
          mimeType: a.video,
          timeSlice: this.timeSlice,
          onTimeStamp: this.onTimeStamp,
          workerPath: this.workerPath,
          webAssemblyPath: this.webAssemblyPath,
          frameRate: this.frameRate,
          bitrate: this.bitrate
        }), e.audio || this.videoRecorder.startRecording();
      }
      if (!!e.audio && !!e.video) {
        var f = this, r = ie() === !0;
        (e.audio instanceof he && !!e.video || e.audio !== !0 && e.video !== !0 && e.audio !== e.video) && (r = !1), r === !0 ? (f.audioRecorder = null, f.videoRecorder.startRecording()) : f.videoRecorder.initRecorder(function() {
          f.audioRecorder.initRecorder(function() {
            f.videoRecorder.startRecording(), f.audioRecorder.startRecording();
          });
        });
      }
      e.gif && (t = null, typeof e.gif == "function" && (t = e.gif), this.gifRecorder = new R(i, {
        type: "gif",
        frameRate: this.frameRate || 200,
        quality: this.quality || 10,
        disableLogs: this.disableLogs,
        recorderType: t,
        mimeType: a.gif
      }), this.gifRecorder.startRecording());
    }, this.stopRecording = function(e) {
      e = e || function() {
      }, this.audioRecorder && this.audioRecorder.stopRecording(function(t) {
        e(t, "audio");
      }), this.videoRecorder && this.videoRecorder.stopRecording(function(t) {
        e(t, "video");
      }), this.gifRecorder && this.gifRecorder.stopRecording(function(t) {
        e(t, "gif");
      });
    }, this.pauseRecording = function() {
      this.audioRecorder && this.audioRecorder.pauseRecording(), this.videoRecorder && this.videoRecorder.pauseRecording(), this.gifRecorder && this.gifRecorder.pauseRecording();
    }, this.resumeRecording = function() {
      this.audioRecorder && this.audioRecorder.resumeRecording(), this.videoRecorder && this.videoRecorder.resumeRecording(), this.gifRecorder && this.gifRecorder.resumeRecording();
    }, this.getBlob = function(e) {
      var t = {};
      return this.audioRecorder && (t.audio = this.audioRecorder.getBlob()), this.videoRecorder && (t.video = this.videoRecorder.getBlob()), this.gifRecorder && (t.gif = this.gifRecorder.getBlob()), e && e(t), t;
    }, this.destroy = function() {
      this.audioRecorder && (this.audioRecorder.destroy(), this.audioRecorder = null), this.videoRecorder && (this.videoRecorder.destroy(), this.videoRecorder = null), this.gifRecorder && (this.gifRecorder.destroy(), this.gifRecorder = null);
    }, this.getDataURL = function(e) {
      this.getBlob(function(s) {
        s.audio && s.video ? t(s.audio, function(d) {
          t(s.video, function(f) {
            e({
              audio: d,
              video: f
            });
          });
        }) : s.audio ? t(s.audio, function(d) {
          e({
            audio: d
          });
        }) : s.video && t(s.video, function(d) {
          e({
            video: d
          });
        });
      });
      function t(s, d) {
        if (typeof Worker < "u") {
          var f = a(function(b) {
            postMessage(new FileReaderSync().readAsDataURL(b));
          });
          f.onmessage = function(h) {
            d(h.data);
          }, f.postMessage(s);
        } else {
          var r = new FileReader();
          r.readAsDataURL(s), r.onload = function(h) {
            d(h.target.result);
          };
        }
      }
      function a(s) {
        var d = U.createObjectURL(new Blob([
          s.toString(),
          "this.onmessage =  function (eee) {" + s.name + "(eee.data);}"
        ], {
          type: "application/javascript"
        })), f = new Worker(d), r;
        if (typeof U < "u")
          r = U;
        else if (typeof webkitURL < "u")
          r = webkitURL;
        else
          throw "Neither URL nor webkitURL detected.";
        return r.revokeObjectURL(d), f;
      }
    }, this.writeToDisk = function() {
      R.writeToDisk({
        audio: this.audioRecorder,
        video: this.videoRecorder,
        gif: this.gifRecorder
      });
    }, this.save = function(e) {
      e = e || {
        audio: !0,
        video: !0,
        gif: !0
      }, !!e.audio && this.audioRecorder && this.audioRecorder.save(typeof e.audio == "string" ? e.audio : ""), !!e.video && this.videoRecorder && this.videoRecorder.save(typeof e.video == "string" ? e.video : ""), !!e.gif && this.gifRecorder && this.gifRecorder.save(typeof e.gif == "string" ? e.gif : "");
    };
  }
  K.getFromDisk = R.getFromDisk, K.writeToDisk = R.writeToDisk, typeof R < "u" && (R.MRecordRTC = K);
  var se = "Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";
  (function(i) {
    !i || typeof window < "u" || typeof A > "u" || (A.navigator = {
      userAgent: se,
      getUserMedia: function() {
      }
    }, A.console || (A.console = {}), (typeof A.console.log > "u" || typeof A.console.error > "u") && (A.console.error = A.console.log = A.console.log || function() {
      console.log(arguments);
    }), typeof document > "u" && (i.document = {
      documentElement: {
        appendChild: function() {
          return "";
        }
      }
    }, document.createElement = document.captureStream = document.mozCaptureStream = function() {
      var e = {
        getContext: function() {
          return e;
        },
        play: function() {
        },
        pause: function() {
        },
        drawImage: function() {
        },
        toDataURL: function() {
          return "";
        },
        style: {}
      };
      return e;
    }, i.HTMLVideoElement = function() {
    }), typeof location > "u" && (i.location = {
      protocol: "file:",
      href: "",
      hash: ""
    }), typeof screen > "u" && (i.screen = {
      width: 0,
      height: 0
    }), typeof U > "u" && (i.URL = {
      createObjectURL: function() {
        return "";
      },
      revokeObjectURL: function() {
        return "";
      }
    }), i.window = A);
  })(typeof A < "u" ? A : null);
  var $ = window.requestAnimationFrame;
  if (typeof $ > "u") {
    if (typeof webkitRequestAnimationFrame < "u")
      $ = webkitRequestAnimationFrame;
    else if (typeof mozRequestAnimationFrame < "u")
      $ = mozRequestAnimationFrame;
    else if (typeof msRequestAnimationFrame < "u")
      $ = msRequestAnimationFrame;
    else if (typeof $ > "u") {
      var Me = 0;
      $ = function(i, e) {
        var t = new Date().getTime(), a = Math.max(0, 16 - (t - Me)), s = setTimeout(function() {
          i(t + a);
        }, a);
        return Me = t + a, s;
      };
    }
  }
  var te = window.cancelAnimationFrame;
  typeof te > "u" && (typeof webkitCancelAnimationFrame < "u" ? te = webkitCancelAnimationFrame : typeof mozCancelAnimationFrame < "u" ? te = mozCancelAnimationFrame : typeof msCancelAnimationFrame < "u" ? te = msCancelAnimationFrame : typeof te > "u" && (te = function(i) {
    clearTimeout(i);
  }));
  var ue = window.AudioContext;
  typeof ue > "u" && (typeof webkitAudioContext < "u" && (ue = webkitAudioContext), typeof mozAudioContext < "u" && (ue = mozAudioContext));
  var U = window.URL;
  typeof U > "u" && typeof webkitURL < "u" && (U = webkitURL), typeof navigator < "u" && typeof navigator.getUserMedia > "u" && (typeof navigator.webkitGetUserMedia < "u" && (navigator.getUserMedia = navigator.webkitGetUserMedia), typeof navigator.mozGetUserMedia < "u" && (navigator.getUserMedia = navigator.mozGetUserMedia));
  var Re = navigator.userAgent.indexOf("Edge") !== -1 && (!!navigator.msSaveBlob || !!navigator.msSaveOrOpenBlob), ce = !!window.opera || navigator.userAgent.indexOf("OPR/") !== -1, De = navigator.userAgent.toLowerCase().indexOf("firefox") > -1 && "netscape" in window && / rv:/.test(navigator.userAgent), X = !ce && !Re && !!navigator.webkitGetUserMedia || Ue() || navigator.userAgent.toLowerCase().indexOf("chrome/") !== -1, le = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  le && !X && navigator.userAgent.indexOf("CriOS") !== -1 && (le = !1, X = !0);
  var N = window.MediaStream;
  typeof N > "u" && typeof webkitMediaStream < "u" && (N = webkitMediaStream), typeof N < "u" && typeof N.prototype.stop > "u" && (N.prototype.stop = function() {
    this.getTracks().forEach(function(i) {
      i.stop();
    });
  });
  function Se(i) {
    var e = 1e3, t = ["Bytes", "KB", "MB", "GB", "TB"];
    if (i === 0)
      return "0 Bytes";
    var a = parseInt(Math.floor(Math.log(i) / Math.log(e)), 10);
    return (i / Math.pow(e, a)).toPrecision(3) + " " + t[a];
  }
  function Be(i, e) {
    if (!i)
      throw "Blob object is required.";
    if (!i.type)
      try {
        i.type = "video/webm";
      } catch {
      }
    var t = (i.type || "video/webm").split("/")[1];
    if (t.indexOf(";") !== -1 && (t = t.split(";")[0]), e && e.indexOf(".") !== -1) {
      var a = e.split(".");
      e = a[0], t = a[1];
    }
    var s = (e || Math.round(Math.random() * 9999999999) + 888888888) + "." + t;
    if (typeof navigator.msSaveOrOpenBlob < "u")
      return navigator.msSaveOrOpenBlob(i, s);
    if (typeof navigator.msSaveBlob < "u")
      return navigator.msSaveBlob(i, s);
    var d = document.createElement("a");
    d.href = U.createObjectURL(i), d.download = s, d.style = "display:none;opacity:0;color:transparent;", (document.body || document.documentElement).appendChild(d), typeof d.click == "function" ? d.click() : (d.target = "_blank", d.dispatchEvent(new MouseEvent("click", {
      view: window,
      bubbles: !0,
      cancelable: !0
    }))), U.revokeObjectURL(d.href);
  }
  function Ue() {
    return typeof window < "u" && typeof window.process == "object" && window.process.type === "renderer" || typeof process < "u" && typeof process.versions == "object" && !!process.versions.electron || typeof navigator == "object" && typeof navigator.userAgent == "string" && navigator.userAgent.indexOf("Electron") >= 0;
  }
  function x(i, e) {
    return !i || !i.getTracks ? [] : i.getTracks().filter(function(t) {
      return t.kind === (e || "audio");
    });
  }
  function Fe(i, e) {
    "srcObject" in e ? e.srcObject = i : "mozSrcObject" in e ? e.mozSrcObject = i : e.srcObject = i;
  }
  function je(i, e) {
    if (typeof EBML > "u")
      throw new Error("Please link: https://www.webrtc-experiment.com/EBML.js");
    var t = new EBML.Reader(), a = new EBML.Decoder(), s = EBML.tools, d = new FileReader();
    d.onload = function(f) {
      var r = a.decode(this.result);
      r.forEach(function(g) {
        t.read(g);
      }), t.stop();
      var h = s.makeMetadataSeekable(t.metadatas, t.duration, t.cues), b = this.result.slice(t.metadataSize), l = new Blob([h, b], {
        type: "video/webm"
      });
      e(l);
    }, d.readAsArrayBuffer(i);
  }
  typeof R < "u" && (R.invokeSaveAsDialog = Be, R.getTracks = x, R.getSeekableBlob = je, R.bytesToSize = Se, R.isElectron = Ue);
  var ae = {};
  typeof ue < "u" ? ae.AudioContext = ue : typeof webkitAudioContext < "u" && (ae.AudioContext = webkitAudioContext), typeof R < "u" && (R.Storage = ae);
  function ie() {
    if (De || le || Re)
      return !0;
    var i = navigator.userAgent, e = "" + parseFloat(navigator.appVersion), t = parseInt(navigator.appVersion, 10), a, s;
    return (X || ce) && (a = i.indexOf("Chrome"), e = i.substring(a + 7)), (s = e.indexOf(";")) !== -1 && (e = e.substring(0, s)), (s = e.indexOf(" ")) !== -1 && (e = e.substring(0, s)), t = parseInt("" + e, 10), isNaN(t) && (e = "" + parseFloat(navigator.appVersion), t = parseInt(navigator.appVersion, 10)), t >= 49;
  }
  function j(i, e) {
    var l = this;
    if (typeof i > "u")
      throw 'First argument "MediaStream" is required.';
    if (typeof MediaRecorder > "u")
      throw "Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.";
    if (e = e || {
      mimeType: "video/webm"
    }, e.type === "audio") {
      if (x(i, "video").length && x(i, "audio").length) {
        var t;
        navigator.mozGetUserMedia ? (t = new N(), t.addTrack(x(i, "audio")[0])) : t = new N(x(i, "audio")), i = t;
      }
      (!e.mimeType || e.mimeType.toString().toLowerCase().indexOf("audio") === -1) && (e.mimeType = X ? "audio/webm" : "audio/ogg"), e.mimeType && e.mimeType.toString().toLowerCase() !== "audio/ogg" && !!navigator.mozGetUserMedia && (e.mimeType = "audio/ogg");
    }
    var a = [];
    this.getArrayOfBlobs = function() {
      return a;
    }, this.record = function() {
      l.blob = null, l.clearRecordedData(), l.timestamps = [], b = [], a = [];
      var g = e;
      e.disableLogs || console.log("Passing following config over MediaRecorder API.", g), r && (r = null), X && !ie() && (g = "video/vp8"), typeof MediaRecorder.isTypeSupported == "function" && g.mimeType && (MediaRecorder.isTypeSupported(g.mimeType) || (e.disableLogs || console.warn("MediaRecorder API seems unable to record mimeType:", g.mimeType), g.mimeType = e.type === "audio" ? "audio/webm" : "video/webm"));
      try {
        r = new MediaRecorder(i, g), e.mimeType = g.mimeType;
      } catch {
        r = new MediaRecorder(i);
      }
      g.mimeType && !MediaRecorder.isTypeSupported && "canRecordMimeType" in r && r.canRecordMimeType(g.mimeType) === !1 && (e.disableLogs || console.warn("MediaRecorder API seems unable to record mimeType:", g.mimeType)), r.ondataavailable = function(p) {
        if (p.data && b.push("ondataavailable: " + Se(p.data.size)), typeof e.timeSlice == "number") {
          if (p.data && p.data.size && (a.push(p.data), s(), typeof e.ondataavailable == "function")) {
            var v = e.getNativeBlob ? p.data : new Blob([p.data], {
              type: d(g)
            });
            e.ondataavailable(v);
          }
          return;
        }
        if (!p.data || !p.data.size || p.data.size < 100 || l.blob) {
          l.recordingCallback && (l.recordingCallback(new Blob([], {
            type: d(g)
          })), l.recordingCallback = null);
          return;
        }
        l.blob = e.getNativeBlob ? p.data : new Blob([p.data], {
          type: d(g)
        }), l.recordingCallback && (l.recordingCallback(l.blob), l.recordingCallback = null);
      }, r.onstart = function() {
        b.push("started");
      }, r.onpause = function() {
        b.push("paused");
      }, r.onresume = function() {
        b.push("resumed");
      }, r.onstop = function() {
        b.push("stopped");
      }, r.onerror = function(p) {
        !p || (p.name || (p.name = "UnknownError"), b.push("error: " + p), e.disableLogs || (p.name.toString().toLowerCase().indexOf("invalidstate") !== -1 ? console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.", p) : p.name.toString().toLowerCase().indexOf("notsupported") !== -1 ? console.error("MIME type (", g.mimeType, ") is not supported.", p) : p.name.toString().toLowerCase().indexOf("security") !== -1 ? console.error("MediaRecorder security error", p) : p.name === "OutOfMemory" ? console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.", p) : p.name === "IllegalStreamModification" ? console.error("A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.", p) : p.name === "OtherRecordingError" ? console.error("Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.", p) : p.name === "GenericError" ? console.error("The UA cannot provide the codec or recording option that has been requested.", p) : console.error("MediaRecorder Error", p)), function(v) {
          if (!l.manuallyStopped && r && r.state === "inactive") {
            delete e.timeslice, r.start(10 * 60 * 1e3);
            return;
          }
          setTimeout(v, 1e3);
        }(), r.state !== "inactive" && r.state !== "stopped" && r.stop());
      }, typeof e.timeSlice == "number" ? (s(), r.start(e.timeSlice)) : r.start(36e5), e.initCallback && e.initCallback();
    }, this.timestamps = [];
    function s() {
      l.timestamps.push(new Date().getTime()), typeof e.onTimeStamp == "function" && e.onTimeStamp(l.timestamps[l.timestamps.length - 1], l.timestamps);
    }
    function d(g) {
      return r && r.mimeType ? r.mimeType : g.mimeType || "video/webm";
    }
    this.stop = function(g) {
      g = g || function() {
      }, l.manuallyStopped = !0, r && (this.recordingCallback = g, r.state === "recording" && r.stop(), typeof e.timeSlice == "number" && setTimeout(function() {
        l.blob = new Blob(a, {
          type: d(e)
        }), l.recordingCallback(l.blob);
      }, 100));
    }, this.pause = function() {
      !r || r.state === "recording" && r.pause();
    }, this.resume = function() {
      !r || r.state === "paused" && r.resume();
    }, this.clearRecordedData = function() {
      r && r.state === "recording" && l.stop(f), f();
    };
    function f() {
      a = [], r = null, l.timestamps = [];
    }
    var r;
    this.getInternalRecorder = function() {
      return r;
    };
    function h() {
      if ("active" in i) {
        if (!i.active)
          return !1;
      } else if ("ended" in i && i.ended)
        return !1;
      return !0;
    }
    this.blob = null, this.getState = function() {
      return r && r.state || "inactive";
    };
    var b = [];
    this.getAllStates = function() {
      return b;
    }, typeof e.checkForInactiveTracks > "u" && (e.checkForInactiveTracks = !1);
    var l = this;
    (function g() {
      if (!(!r || e.checkForInactiveTracks === !1)) {
        if (h() === !1) {
          e.disableLogs || console.log("MediaStream seems stopped."), l.stop();
          return;
        }
        setTimeout(g, 1e3);
      }
    })(), this.name = "MediaStreamRecorder", this.toString = function() {
      return this.name;
    };
  }
  typeof R < "u" && (R.MediaStreamRecorder = j);
  function he(i, e) {
    if (!x(i, "audio").length)
      throw "Your stream has no audio tracks.";
    e = e || {};
    var t = this, a = [], s = [], d = !1, f = 0, r, h = 2, b = e.desiredSampRate;
    e.leftChannel === !0 && (h = 1), e.numberOfAudioChannels === 1 && (h = 1), (!h || h < 1) && (h = 2), e.disableLogs || console.log("StereoAudioRecorder is set to record number of channels: " + h), typeof e.checkForInactiveTracks > "u" && (e.checkForInactiveTracks = !0);
    function l() {
      if (e.checkForInactiveTracks === !1)
        return !0;
      if ("active" in i) {
        if (!i.active)
          return !1;
      } else if ("ended" in i && i.ended)
        return !1;
      return !0;
    }
    this.record = function() {
      if (l() === !1)
        throw "Please make sure MediaStream is active.";
      C(), u = m = !1, d = !0, typeof e.timeSlice < "u" && L();
    };
    function g(k, I) {
      function M(D, de) {
        var V = D.numberOfAudioChannels, E = D.leftBuffers.slice(0), _ = D.rightBuffers.slice(0), q = D.sampleRate, J = D.internalInterleavedLength, P = D.desiredSampRate;
        V === 2 && (E = ke(E, J), _ = ke(_, J), P && (E = re(E, P, q), _ = re(_, P, q))), V === 1 && (E = ke(E, J), P && (E = re(E, P, q))), P && (q = P);
        function re(B, H, z) {
          var W = Math.round(B.length * (H / z)), O = [], Y = Number((B.length - 1) / (W - 1));
          O[0] = B[0];
          for (var ne = 1; ne < W - 1; ne++) {
            var xe = ne * Y, Pe = Number(Math.floor(xe)).toFixed(), qe = Number(Math.ceil(xe)).toFixed(), He = xe - Pe;
            O[ne] = Te(B[Pe], B[qe], He);
          }
          return O[W - 1] = B[B.length - 1], O;
        }
        function Te(B, H, z) {
          return B + (H - B) * z;
        }
        function ke(B, H) {
          for (var z = new Float64Array(H), W = 0, O = B.length, Y = 0; Y < O; Y++) {
            var ne = B[Y];
            z.set(ne, W), W += ne.length;
          }
          return z;
        }
        function We(B, H) {
          for (var z = B.length + H.length, W = new Float64Array(z), O = 0, Y = 0; Y < z; )
            W[Y++] = B[O], W[Y++] = H[O], O++;
          return W;
        }
        function ge(B, H, z) {
          for (var W = z.length, O = 0; O < W; O++)
            B.setUint8(H + O, z.charCodeAt(O));
        }
        var be;
        V === 2 && (be = We(E, _)), V === 1 && (be = E);
        var we = be.length, Ne = 44 + we * 2, Le = new ArrayBuffer(Ne), F = new DataView(Le);
        ge(F, 0, "RIFF"), F.setUint32(4, 36 + we * 2, !0), ge(F, 8, "WAVE"), ge(F, 12, "fmt "), F.setUint32(16, 16, !0), F.setUint16(20, 1, !0), F.setUint16(22, V, !0), F.setUint32(24, q, !0), F.setUint32(28, q * V * 2, !0), F.setUint16(32, V * 2, !0), F.setUint16(34, 16, !0), ge(F, 36, "data"), F.setUint32(40, we * 2, !0);
        for (var Ge = we, Ee = 44, Ve = 1, Ae = 0; Ae < Ge; Ae++)
          F.setInt16(Ee, be[Ae] * (32767 * Ve), !0), Ee += 2;
        if (de)
          return de({
            buffer: Le,
            view: F
          });
        postMessage({
          buffer: Le,
          view: F
        });
      }
      if (k.noWorker) {
        M(k, function(D) {
          I(D.buffer, D.view);
        });
        return;
      }
      var Z = p(M);
      Z.onmessage = function(D) {
        I(D.data.buffer, D.data.view), U.revokeObjectURL(Z.workerURL), Z.terminate();
      }, Z.postMessage(k);
    }
    function p(k) {
      var I = U.createObjectURL(new Blob([
        k.toString(),
        ";this.onmessage =  function (eee) {" + k.name + "(eee.data);}"
      ], {
        type: "application/javascript"
      })), M = new Worker(I);
      return M.workerURL = I, M;
    }
    this.stop = function(k) {
      k = k || function() {
      }, d = !1, g({
        desiredSampRate: b,
        sampleRate: o,
        numberOfAudioChannels: h,
        internalInterleavedLength: f,
        leftBuffers: a,
        rightBuffers: h === 1 ? [] : s,
        noWorker: e.noWorker
      }, function(I, M) {
        t.blob = new Blob([M], {
          type: "audio/wav"
        }), t.buffer = new ArrayBuffer(M.buffer.byteLength), t.view = M, t.sampleRate = b || o, t.bufferSize = T, t.length = f, u = !1, k && k(t.blob);
      });
    }, typeof R.Storage > "u" && (R.Storage = {
      AudioContextConstructor: null,
      AudioContext: window.AudioContext || window.webkitAudioContext
    }), (!R.Storage.AudioContextConstructor || R.Storage.AudioContextConstructor.state === "closed") && (R.Storage.AudioContextConstructor = new R.Storage.AudioContext());
    var v = R.Storage.AudioContextConstructor, c = v.createMediaStreamSource(i), S = [0, 256, 512, 1024, 2048, 4096, 8192, 16384], T = typeof e.bufferSize > "u" ? 4096 : e.bufferSize;
    if (S.indexOf(T) === -1 && (e.disableLogs || console.log("Legal values for buffer-size are " + JSON.stringify(S, null, "	"))), v.createJavaScriptNode)
      r = v.createJavaScriptNode(T, h, h);
    else if (v.createScriptProcessor)
      r = v.createScriptProcessor(T, h, h);
    else
      throw "WebAudio API has no support on this browser.";
    c.connect(r), e.bufferSize || (T = r.bufferSize);
    var o = typeof e.sampleRate < "u" ? e.sampleRate : v.sampleRate || 44100;
    (o < 22050 || o > 96e3) && (e.disableLogs || console.log("sample-rate must be under range 22050 and 96000.")), e.disableLogs || e.desiredSampRate && console.log("Desired sample-rate: " + e.desiredSampRate);
    var m = !1;
    this.pause = function() {
      m = !0;
    }, this.resume = function() {
      if (l() === !1)
        throw "Please make sure MediaStream is active.";
      if (!d) {
        e.disableLogs || console.log("Seems recording has been restarted."), this.record();
        return;
      }
      m = !1;
    }, this.clearRecordedData = function() {
      e.checkForInactiveTracks = !1, d && this.stop(n), n();
    };
    function C() {
      a = [], s = [], f = 0, u = !1, d = !1, m = !1, v = null, t.leftchannel = a, t.rightchannel = s, t.numberOfAudioChannels = h, t.desiredSampRate = b, t.sampleRate = o, t.recordingLength = f, y = {
        left: [],
        right: [],
        recordingLength: 0
      };
    }
    function n() {
      r && (r.onaudioprocess = null, r.disconnect(), r = null), c && (c.disconnect(), c = null), C();
    }
    this.name = "StereoAudioRecorder", this.toString = function() {
      return this.name;
    };
    var u = !1;
    function w(k) {
      if (!m) {
        if (l() === !1 && (e.disableLogs || console.log("MediaStream seems stopped."), r.disconnect(), d = !1), !d) {
          c && (c.disconnect(), c = null);
          return;
        }
        u || (u = !0, e.onAudioProcessStarted && e.onAudioProcessStarted(), e.initCallback && e.initCallback());
        var I = k.inputBuffer.getChannelData(0), M = new Float32Array(I);
        if (a.push(M), h === 2) {
          var Z = k.inputBuffer.getChannelData(1), D = new Float32Array(Z);
          s.push(D);
        }
        f += T, t.recordingLength = f, typeof e.timeSlice < "u" && (y.recordingLength += T, y.left.push(M), h === 2 && y.right.push(D));
      }
    }
    r.onaudioprocess = w, v.createMediaStreamDestination ? r.connect(v.createMediaStreamDestination()) : r.connect(v.destination), this.leftchannel = a, this.rightchannel = s, this.numberOfAudioChannels = h, this.desiredSampRate = b, this.sampleRate = o, t.recordingLength = f;
    var y = {
      left: [],
      right: [],
      recordingLength: 0
    };
    function L() {
      !d || typeof e.ondataavailable != "function" || typeof e.timeSlice > "u" || (y.left.length ? (g({
        desiredSampRate: b,
        sampleRate: o,
        numberOfAudioChannels: h,
        internalInterleavedLength: y.recordingLength,
        leftBuffers: y.left,
        rightBuffers: h === 1 ? [] : y.right
      }, function(k, I) {
        var M = new Blob([I], {
          type: "audio/wav"
        });
        e.ondataavailable(M), setTimeout(L, e.timeSlice);
      }), y = {
        left: [],
        right: [],
        recordingLength: 0
      }) : setTimeout(L, e.timeSlice));
    }
  }
  typeof R < "u" && (R.StereoAudioRecorder = he);
  function pe(i, e) {
    if (typeof html2canvas > "u")
      throw "Please link: https://www.webrtc-experiment.com/screenshot.js";
    e = e || {}, e.frameInterval || (e.frameInterval = 10);
    var t = !1;
    ["captureStream", "mozCaptureStream", "webkitCaptureStream"].forEach(function(S) {
      S in document.createElement("canvas") && (t = !0);
    });
    var a = (!!window.webkitRTCPeerConnection || !!window.webkitGetUserMedia) && !!window.chrome, s = 50, d = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
    a && d && d[2] && (s = parseInt(d[2], 10)), a && s < 52 && (t = !1), e.useWhammyRecorder && (t = !1);
    var f, r;
    if (t)
      if (e.disableLogs || console.log("Your browser supports both MediRecorder API and canvas.captureStream!"), i instanceof HTMLCanvasElement)
        f = i;
      else if (i instanceof CanvasRenderingContext2D)
        f = i.canvas;
      else
        throw "Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";
    else
      navigator.mozGetUserMedia && (e.disableLogs || console.error("Canvas recording is NOT supported in Firefox."));
    var h;
    this.record = function() {
      if (h = !0, t && !e.useWhammyRecorder) {
        var S;
        "captureStream" in f ? S = f.captureStream(25) : "mozCaptureStream" in f ? S = f.mozCaptureStream(25) : "webkitCaptureStream" in f && (S = f.webkitCaptureStream(25));
        try {
          var T = new N();
          T.addTrack(x(S, "video")[0]), S = T;
        } catch {
        }
        if (!S)
          throw "captureStream API are NOT available.";
        r = new j(S, {
          mimeType: e.mimeType || "video/webm"
        }), r.record();
      } else
        c.frames = [], v = new Date().getTime(), p();
      e.initCallback && e.initCallback();
    }, this.getWebPImages = function(S) {
      if (i.nodeName.toLowerCase() !== "canvas") {
        S();
        return;
      }
      var T = c.frames.length;
      c.frames.forEach(function(o, m) {
        var C = T - m;
        e.disableLogs || console.log(C + "/" + T + " frames remaining"), e.onEncodingCallback && e.onEncodingCallback(C, T);
        var n = o.image.toDataURL("image/webp", 1);
        c.frames[m].image = n;
      }), e.disableLogs || console.log("Generating WebM"), S();
    }, this.stop = function(S) {
      h = !1;
      var T = this;
      if (t && r) {
        r.stop(S);
        return;
      }
      this.getWebPImages(function() {
        c.compile(function(o) {
          e.disableLogs || console.log("Recording finished!"), T.blob = o, T.blob.forEach && (T.blob = new Blob([], {
            type: "video/webm"
          })), S && S(T.blob), c.frames = [];
        });
      });
    };
    var b = !1;
    this.pause = function() {
      if (b = !0, r instanceof j) {
        r.pause();
        return;
      }
    }, this.resume = function() {
      if (b = !1, r instanceof j) {
        r.resume();
        return;
      }
      h || this.record();
    }, this.clearRecordedData = function() {
      h && this.stop(l), l();
    };
    function l() {
      c.frames = [], h = !1, b = !1;
    }
    this.name = "CanvasRecorder", this.toString = function() {
      return this.name;
    };
    function g() {
      var S = document.createElement("canvas"), T = S.getContext("2d");
      return S.width = i.width, S.height = i.height, T.drawImage(i, 0, 0), S;
    }
    function p() {
      if (b)
        return v = new Date().getTime(), setTimeout(p, 500);
      if (i.nodeName.toLowerCase() === "canvas") {
        var S = new Date().getTime() - v;
        v = new Date().getTime(), c.frames.push({
          image: g(),
          duration: S
        }), h && setTimeout(p, e.frameInterval);
        return;
      }
      html2canvas(i, {
        grabMouse: typeof e.showMousePointer > "u" || e.showMousePointer,
        onrendered: function(T) {
          var o = new Date().getTime() - v;
          if (!o)
            return setTimeout(p, e.frameInterval);
          v = new Date().getTime(), c.frames.push({
            image: T.toDataURL("image/webp", 1),
            duration: o
          }), h && setTimeout(p, e.frameInterval);
        }
      });
    }
    var v = new Date().getTime(), c = new Ce.Video(100);
  }
  typeof R < "u" && (R.CanvasRecorder = pe);
  function me(i, e) {
    e = e || {}, e.frameInterval || (e.frameInterval = 10), e.disableLogs || console.log("Using frames-interval:", e.frameInterval), this.record = function() {
      e.width || (e.width = 320), e.height || (e.height = 240), e.video || (e.video = {
        width: e.width,
        height: e.height
      }), e.canvas || (e.canvas = {
        width: e.width,
        height: e.height
      }), h.width = e.canvas.width || 320, h.height = e.canvas.height || 240, b = h.getContext("2d"), e.video && e.video instanceof HTMLVideoElement ? (l = e.video.cloneNode(), e.initCallback && e.initCallback()) : (l = document.createElement("video"), Fe(i, l), l.onloadedmetadata = function() {
        e.initCallback && e.initCallback();
      }, l.width = e.video.width, l.height = e.video.height), l.muted = !0, l.play(), g = new Date().getTime(), p = new Ce.Video(), e.disableLogs || (console.log("canvas resolutions", h.width, "*", h.height), console.log("video width/height", l.width || h.width, "*", l.height || h.height)), t(e.frameInterval);
    };
    function t(v) {
      v = typeof v < "u" ? v : 10;
      var c = new Date().getTime() - g;
      if (!c)
        return setTimeout(t, v, v);
      if (f)
        return g = new Date().getTime(), setTimeout(t, 100);
      g = new Date().getTime(), l.paused && l.play(), b.drawImage(l, 0, 0, h.width, h.height), p.frames.push({
        duration: c,
        image: h.toDataURL("image/webp")
      }), d || setTimeout(t, v, v);
    }
    function a(v) {
      var c = -1, S = v.length;
      (function T() {
        if (c++, c === S) {
          v.callback();
          return;
        }
        setTimeout(function() {
          v.functionToLoop(T, c);
        }, 1);
      })();
    }
    function s(v, c, S, T, o) {
      var m = document.createElement("canvas");
      m.width = h.width, m.height = h.height;
      var C = m.getContext("2d"), n = [], u = c === -1, w = c && c > 0 && c <= v.length ? c : v.length, y = {
        r: 0,
        g: 0,
        b: 0
      }, L = Math.sqrt(
        Math.pow(255, 2) + Math.pow(255, 2) + Math.pow(255, 2)
      ), k = S && S >= 0 && S <= 1 ? S : 0, I = T && T >= 0 && T <= 1 ? T : 0, M = !1;
      a({
        length: w,
        functionToLoop: function(Z, D) {
          var de, V, E, _ = function() {
            !M && E - de <= E * I || (u && (M = !0), n.push(v[D])), Z();
          };
          if (M)
            _();
          else {
            var q = new Image();
            q.onload = function() {
              C.drawImage(q, 0, 0, h.width, h.height);
              var J = C.getImageData(0, 0, h.width, h.height);
              de = 0, V = J.data.length, E = J.data.length / 4;
              for (var P = 0; P < V; P += 4) {
                var re = {
                  r: J.data[P],
                  g: J.data[P + 1],
                  b: J.data[P + 2]
                }, Te = Math.sqrt(
                  Math.pow(re.r - y.r, 2) + Math.pow(re.g - y.g, 2) + Math.pow(re.b - y.b, 2)
                );
                Te <= L * k && de++;
              }
              _();
            }, q.src = v[D].image;
          }
        },
        callback: function() {
          n = n.concat(v.slice(w)), n.length <= 0 && n.push(v[v.length - 1]), o(n);
        }
      });
    }
    var d = !1;
    this.stop = function(v) {
      v = v || function() {
      }, d = !0;
      var c = this;
      setTimeout(function() {
        s(p.frames, -1, null, null, function(S) {
          p.frames = S, e.advertisement && e.advertisement.length && (p.frames = e.advertisement.concat(p.frames)), p.compile(function(T) {
            c.blob = T, c.blob.forEach && (c.blob = new Blob([], {
              type: "video/webm"
            })), v && v(c.blob);
          });
        });
      }, 10);
    };
    var f = !1;
    this.pause = function() {
      f = !0;
    }, this.resume = function() {
      f = !1, d && this.record();
    }, this.clearRecordedData = function() {
      d || this.stop(r), r();
    };
    function r() {
      p.frames = [], d = !0, f = !1;
    }
    this.name = "WhammyRecorder", this.toString = function() {
      return this.name;
    };
    var h = document.createElement("canvas"), b = h.getContext("2d"), l, g, p;
  }
  typeof R < "u" && (R.WhammyRecorder = me);
  var Ce = function() {
    function i(a) {
      this.frames = [], this.duration = a || 1, this.quality = 0.8;
    }
    i.prototype.add = function(a, s) {
      if ("canvas" in a && (a = a.canvas), "toDataURL" in a && (a = a.toDataURL("image/webp", this.quality)), !/^data:image\/webp;base64,/ig.test(a))
        throw "Input must be formatted properly as a base64 encoded DataURI of type image/webp";
      this.frames.push({
        image: a,
        duration: s || this.duration
      });
    };
    function e(a) {
      var s = U.createObjectURL(new Blob([
        a.toString(),
        "this.onmessage =  function (eee) {" + a.name + "(eee.data);}"
      ], {
        type: "application/javascript"
      })), d = new Worker(s);
      return U.revokeObjectURL(s), d;
    }
    function t(a) {
      function s(o) {
        var m = f(o);
        if (!m)
          return [];
        for (var C = 3e4, n = [{
          id: 440786851,
          data: [{
            data: 1,
            id: 17030
          }, {
            data: 1,
            id: 17143
          }, {
            data: 4,
            id: 17138
          }, {
            data: 8,
            id: 17139
          }, {
            data: "webm",
            id: 17026
          }, {
            data: 2,
            id: 17031
          }, {
            data: 2,
            id: 17029
          }]
        }, {
          id: 408125543,
          data: [{
            id: 357149030,
            data: [{
              data: 1e6,
              id: 2807729
            }, {
              data: "whammy",
              id: 19840
            }, {
              data: "whammy",
              id: 22337
            }, {
              data: S(m.duration),
              id: 17545
            }]
          }, {
            id: 374648427,
            data: [{
              id: 174,
              data: [{
                data: 1,
                id: 215
              }, {
                data: 1,
                id: 29637
              }, {
                data: 0,
                id: 156
              }, {
                data: "und",
                id: 2274716
              }, {
                data: "V_VP8",
                id: 134
              }, {
                data: "VP8",
                id: 2459272
              }, {
                data: 1,
                id: 131
              }, {
                id: 224,
                data: [{
                  data: m.width,
                  id: 176
                }, {
                  data: m.height,
                  id: 186
                }]
              }]
            }]
          }]
        }], u = 0, w = 0; u < o.length; ) {
          var y = [], L = 0;
          do
            y.push(o[u]), L += o[u].duration, u++;
          while (u < o.length && L < C);
          var k = 0, I = {
            id: 524531317,
            data: d(w, k, y)
          };
          n[1].data.push(I), w += L;
        }
        return l(n);
      }
      function d(o, m, C) {
        return [{
          data: o,
          id: 231
        }].concat(C.map(function(n) {
          var u = g({
            discardable: 0,
            frame: n.data.slice(4),
            invisible: 0,
            keyframe: 1,
            lacing: 0,
            trackNum: 1,
            timecode: Math.round(m)
          });
          return m += n.duration, {
            data: u,
            id: 163
          };
        }));
      }
      function f(o) {
        if (!o[0]) {
          postMessage({
            error: "Something went wrong. Maybe WebP format is not supported in the current browser."
          });
          return;
        }
        for (var m = o[0].width, C = o[0].height, n = o[0].duration, u = 1; u < o.length; u++)
          n += o[u].duration;
        return {
          duration: n,
          width: m,
          height: C
        };
      }
      function r(o) {
        for (var m = []; o > 0; )
          m.push(o & 255), o = o >> 8;
        return new Uint8Array(m.reverse());
      }
      function h(o) {
        return new Uint8Array(o.split("").map(function(m) {
          return m.charCodeAt(0);
        }));
      }
      function b(o) {
        var m = [], C = o.length % 8 ? new Array(9 - o.length % 8).join("0") : "";
        o = C + o;
        for (var n = 0; n < o.length; n += 8)
          m.push(parseInt(o.substr(n, 8), 2));
        return new Uint8Array(m);
      }
      function l(o) {
        for (var m = [], C = 0; C < o.length; C++) {
          var n = o[C].data;
          typeof n == "object" && (n = l(n)), typeof n == "number" && (n = b(n.toString(2))), typeof n == "string" && (n = h(n));
          var u = n.size || n.byteLength || n.length, w = Math.ceil(Math.ceil(Math.log(u) / Math.log(2)) / 8), y = u.toString(2), L = new Array(w * 7 + 7 + 1 - y.length).join("0") + y, k = new Array(w).join("0") + "1" + L;
          m.push(r(o[C].id)), m.push(b(k)), m.push(n);
        }
        return new Blob(m, {
          type: "video/webm"
        });
      }
      function g(o) {
        var m = 0;
        if (o.keyframe && (m |= 128), o.invisible && (m |= 8), o.lacing && (m |= o.lacing << 1), o.discardable && (m |= 1), o.trackNum > 127)
          throw "TrackNumber > 127 not supported";
        var C = [o.trackNum | 128, o.timecode >> 8, o.timecode & 255, m].map(function(n) {
          return String.fromCharCode(n);
        }).join("") + o.frame;
        return C;
      }
      function p(o) {
        for (var m = o.RIFF[0].WEBP[0], C = m.indexOf("*"), n = 0, u = []; n < 4; n++)
          u[n] = m.charCodeAt(C + 3 + n);
        var w, y, L;
        return L = u[1] << 8 | u[0], w = L & 16383, L = u[3] << 8 | u[2], y = L & 16383, {
          width: w,
          height: y,
          data: m,
          riff: o
        };
      }
      function v(o, m) {
        return parseInt(o.substr(m + 4, 4).split("").map(function(C) {
          var n = C.charCodeAt(0).toString(2);
          return new Array(8 - n.length + 1).join("0") + n;
        }).join(""), 2);
      }
      function c(o) {
        for (var m = 0, C = {}; m < o.length; ) {
          var n = o.substr(m, 4), u = v(o, m), w = o.substr(m + 4 + 4, u);
          m += 4 + 4 + u, C[n] = C[n] || [], n === "RIFF" || n === "LIST" ? C[n].push(c(w)) : C[n].push(w);
        }
        return C;
      }
      function S(o) {
        return [].slice.call(
          new Uint8Array(new Float64Array([o]).buffer),
          0
        ).map(function(m) {
          return String.fromCharCode(m);
        }).reverse().join("");
      }
      var T = new s(a.map(function(o) {
        var m = p(c(atob(o.image.slice(23))));
        return m.duration = o.duration, m;
      }));
      postMessage(T);
    }
    return i.prototype.compile = function(a) {
      var s = e(t);
      s.onmessage = function(d) {
        if (d.data.error) {
          console.error(d.data.error);
          return;
        }
        a(d.data);
      }, s.postMessage(this.frames);
    }, {
      Video: i
    };
  }();
  typeof R < "u" && (R.Whammy = Ce);
  var G = {
    init: function() {
      var i = this;
      if (typeof indexedDB > "u" || typeof indexedDB.open > "u") {
        console.error("IndexedDB API are not available in this browser.");
        return;
      }
      var e = 1, t = this.dbName || location.href.replace(/\/|:|#|%|\.|\[|\]/g, ""), a, s = indexedDB.open(t, e);
      function d(r) {
        r.createObjectStore(i.dataStoreName);
      }
      function f() {
        var r = a.transaction([i.dataStoreName], "readwrite");
        i.videoBlob && r.objectStore(i.dataStoreName).put(i.videoBlob, "videoBlob"), i.gifBlob && r.objectStore(i.dataStoreName).put(i.gifBlob, "gifBlob"), i.audioBlob && r.objectStore(i.dataStoreName).put(i.audioBlob, "audioBlob");
        function h(b) {
          r.objectStore(i.dataStoreName).get(b).onsuccess = function(l) {
            i.callback && i.callback(l.target.result, b);
          };
        }
        h("audioBlob"), h("videoBlob"), h("gifBlob");
      }
      s.onerror = i.onError, s.onsuccess = function() {
        if (a = s.result, a.onerror = i.onError, a.setVersion)
          if (a.version !== e) {
            var r = a.setVersion(e);
            r.onsuccess = function() {
              d(a), f();
            };
          } else
            f();
        else
          f();
      }, s.onupgradeneeded = function(r) {
        d(r.target.result);
      };
    },
    Fetch: function(i) {
      return this.callback = i, this.init(), this;
    },
    Store: function(i) {
      return this.audioBlob = i.audioBlob, this.videoBlob = i.videoBlob, this.gifBlob = i.gifBlob, this.init(), this;
    },
    onError: function(i) {
      console.error(JSON.stringify(i, null, "	"));
    },
    dataStoreName: "recordRTC",
    dbName: null
  };
  typeof R < "u" && (R.DiskStorage = G);
  function ve(i, e) {
    if (typeof GIFEncoder > "u") {
      var t = document.createElement("script");
      t.src = "https://www.webrtc-experiment.com/gif-recorder.js", (document.body || document.documentElement).appendChild(t);
    }
    e = e || {};
    var a = i instanceof CanvasRenderingContext2D || i instanceof HTMLCanvasElement;
    this.record = function() {
      if (typeof GIFEncoder > "u") {
        setTimeout(v.record, 1e3);
        return;
      }
      if (!h) {
        setTimeout(v.record, 1e3);
        return;
      }
      a || (e.width || (e.width = b.offsetWidth || 320), e.height || (e.height = b.offsetHeight || 240), e.video || (e.video = {
        width: e.width,
        height: e.height
      }), e.canvas || (e.canvas = {
        width: e.width,
        height: e.height
      }), f.width = e.canvas.width || 320, f.height = e.canvas.height || 240, b.width = e.video.width || 320, b.height = e.video.height || 240), p = new GIFEncoder(), p.setRepeat(0), p.setDelay(e.frameRate || 200), p.setQuality(e.quality || 10), p.start(), typeof e.onGifRecordingStarted == "function" && e.onGifRecordingStarted();
      function c(S) {
        if (v.clearedRecordedData !== !0) {
          if (s)
            return setTimeout(function() {
              c(S);
            }, 100);
          l = $(c), typeof g === void 0 && (g = S), !(S - g < 90) && (!a && b.paused && b.play(), a || r.drawImage(b, 0, 0, f.width, f.height), e.onGifPreview && e.onGifPreview(f.toDataURL("image/png")), p.addFrame(r), g = S);
        }
      }
      l = $(c), e.initCallback && e.initCallback();
    }, this.stop = function(c) {
      c = c || function() {
      }, l && te(l), this.blob = new Blob([new Uint8Array(p.stream().bin)], {
        type: "image/gif"
      }), c(this.blob), p.stream().bin = [];
    };
    var s = !1;
    this.pause = function() {
      s = !0;
    }, this.resume = function() {
      s = !1;
    }, this.clearRecordedData = function() {
      v.clearedRecordedData = !0, d();
    };
    function d() {
      p && (p.stream().bin = []);
    }
    this.name = "GifRecorder", this.toString = function() {
      return this.name;
    };
    var f = document.createElement("canvas"), r = f.getContext("2d");
    a && (i instanceof CanvasRenderingContext2D ? (r = i, f = r.canvas) : i instanceof HTMLCanvasElement && (r = i.getContext("2d"), f = i));
    var h = !0;
    if (!a) {
      var b = document.createElement("video");
      b.muted = !0, b.autoplay = !0, b.playsInline = !0, h = !1, b.onloadedmetadata = function() {
        h = !0;
      }, Fe(i, b), b.play();
    }
    var l = null, g, p, v = this;
  }
  typeof R < "u" && (R.GifRecorder = ve);
  function Ie(i, e) {
    var t = "Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";
    (function(n) {
      typeof R < "u" || !n || typeof window < "u" || typeof A > "u" || (A.navigator = {
        userAgent: t,
        getUserMedia: function() {
        }
      }, A.console || (A.console = {}), (typeof A.console.log > "u" || typeof A.console.error > "u") && (A.console.error = A.console.log = A.console.log || function() {
        console.log(arguments);
      }), typeof document > "u" && (n.document = {
        documentElement: {
          appendChild: function() {
            return "";
          }
        }
      }, document.createElement = document.captureStream = document.mozCaptureStream = function() {
        var u = {
          getContext: function() {
            return u;
          },
          play: function() {
          },
          pause: function() {
          },
          drawImage: function() {
          },
          toDataURL: function() {
            return "";
          },
          style: {}
        };
        return u;
      }, n.HTMLVideoElement = function() {
      }), typeof location > "u" && (n.location = {
        protocol: "file:",
        href: "",
        hash: ""
      }), typeof screen > "u" && (n.screen = {
        width: 0,
        height: 0
      }), typeof b > "u" && (n.URL = {
        createObjectURL: function() {
          return "";
        },
        revokeObjectURL: function() {
          return "";
        }
      }), n.window = A);
    })(typeof A < "u" ? A : null), e = e || "multi-streams-mixer";
    var a = [], s = !1, d = document.createElement("canvas"), f = d.getContext("2d");
    d.style.opacity = 0, d.style.position = "absolute", d.style.zIndex = -1, d.style.top = "-1000em", d.style.left = "-1000em", d.className = e, (document.body || document.documentElement).appendChild(d), this.disableLogs = !1, this.frameInterval = 10, this.width = 360, this.height = 240, this.useGainNode = !0;
    var r = this, h = window.AudioContext;
    typeof h > "u" && (typeof webkitAudioContext < "u" && (h = webkitAudioContext), typeof mozAudioContext < "u" && (h = mozAudioContext));
    var b = window.URL;
    typeof b > "u" && typeof webkitURL < "u" && (b = webkitURL), typeof navigator < "u" && typeof navigator.getUserMedia > "u" && (typeof navigator.webkitGetUserMedia < "u" && (navigator.getUserMedia = navigator.webkitGetUserMedia), typeof navigator.mozGetUserMedia < "u" && (navigator.getUserMedia = navigator.mozGetUserMedia));
    var l = window.MediaStream;
    typeof l > "u" && typeof webkitMediaStream < "u" && (l = webkitMediaStream), typeof l < "u" && typeof l.prototype.stop > "u" && (l.prototype.stop = function() {
      this.getTracks().forEach(function(n) {
        n.stop();
      });
    });
    var g = {};
    typeof h < "u" ? g.AudioContext = h : typeof webkitAudioContext < "u" && (g.AudioContext = webkitAudioContext);
    function p(n, u) {
      "srcObject" in u ? u.srcObject = n : "mozSrcObject" in u ? u.mozSrcObject = n : u.srcObject = n;
    }
    this.startDrawingFrames = function() {
      v();
    };
    function v() {
      if (!s) {
        var n = a.length, u = !1, w = [];
        if (a.forEach(function(L) {
          L.stream || (L.stream = {}), L.stream.fullcanvas ? u = L : w.push(L);
        }), u)
          d.width = u.stream.width, d.height = u.stream.height;
        else if (w.length) {
          d.width = n > 1 ? w[0].width * 2 : w[0].width;
          var y = 1;
          (n === 3 || n === 4) && (y = 2), (n === 5 || n === 6) && (y = 3), (n === 7 || n === 8) && (y = 4), (n === 9 || n === 10) && (y = 5), d.height = w[0].height * y;
        } else
          d.width = r.width || 360, d.height = r.height || 240;
        u && u instanceof HTMLVideoElement && c(u), w.forEach(function(L, k) {
          c(L, k);
        }), setTimeout(v, r.frameInterval);
      }
    }
    function c(n, u) {
      if (!s) {
        var w = 0, y = 0, L = n.width, k = n.height;
        u === 1 && (w = n.width), u === 2 && (y = n.height), u === 3 && (w = n.width, y = n.height), u === 4 && (y = n.height * 2), u === 5 && (w = n.width, y = n.height * 2), u === 6 && (y = n.height * 3), u === 7 && (w = n.width, y = n.height * 3), typeof n.stream.left < "u" && (w = n.stream.left), typeof n.stream.top < "u" && (y = n.stream.top), typeof n.stream.width < "u" && (L = n.stream.width), typeof n.stream.height < "u" && (k = n.stream.height), f.drawImage(n, w, y, L, k), typeof n.stream.onRender == "function" && n.stream.onRender(f, w, y, L, k, u);
      }
    }
    function S() {
      s = !1;
      var n = T(), u = o();
      return u && u.getTracks().filter(function(w) {
        return w.kind === "audio";
      }).forEach(function(w) {
        n.addTrack(w);
      }), i.forEach(function(w) {
        w.fullcanvas;
      }), n;
    }
    function T() {
      C();
      var n;
      "captureStream" in d ? n = d.captureStream() : "mozCaptureStream" in d ? n = d.mozCaptureStream() : r.disableLogs || console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");
      var u = new l();
      return n.getTracks().filter(function(w) {
        return w.kind === "video";
      }).forEach(function(w) {
        u.addTrack(w);
      }), d.stream = u, u;
    }
    function o() {
      g.AudioContextConstructor || (g.AudioContextConstructor = new g.AudioContext()), r.audioContext = g.AudioContextConstructor, r.audioSources = [], r.useGainNode === !0 && (r.gainNode = r.audioContext.createGain(), r.gainNode.connect(r.audioContext.destination), r.gainNode.gain.value = 0);
      var n = 0;
      if (i.forEach(function(u) {
        if (!!u.getTracks().filter(function(y) {
          return y.kind === "audio";
        }).length) {
          n++;
          var w = r.audioContext.createMediaStreamSource(u);
          r.useGainNode === !0 && w.connect(r.gainNode), r.audioSources.push(w);
        }
      }), !!n)
        return r.audioDestination = r.audioContext.createMediaStreamDestination(), r.audioSources.forEach(function(u) {
          u.connect(r.audioDestination);
        }), r.audioDestination.stream;
    }
    function m(n) {
      var u = document.createElement("video");
      return p(n, u), u.className = e, u.muted = !0, u.volume = 0, u.width = n.width || r.width || 360, u.height = n.height || r.height || 240, u.play(), u;
    }
    this.appendStreams = function(n) {
      if (!n)
        throw "First parameter is required.";
      n instanceof Array || (n = [n]), n.forEach(function(u) {
        var w = new l();
        if (u.getTracks().filter(function(k) {
          return k.kind === "video";
        }).length) {
          var y = m(u);
          y.stream = u, a.push(y), w.addTrack(u.getTracks().filter(function(k) {
            return k.kind === "video";
          })[0]);
        }
        if (u.getTracks().filter(function(k) {
          return k.kind === "audio";
        }).length) {
          var L = r.audioContext.createMediaStreamSource(u);
          r.audioDestination = r.audioContext.createMediaStreamDestination(), L.connect(r.audioDestination), w.addTrack(r.audioDestination.stream.getTracks().filter(function(k) {
            return k.kind === "audio";
          })[0]);
        }
        i.push(w);
      });
    }, this.releaseStreams = function() {
      a = [], s = !0, r.gainNode && (r.gainNode.disconnect(), r.gainNode = null), r.audioSources.length && (r.audioSources.forEach(function(n) {
        n.disconnect();
      }), r.audioSources = []), r.audioDestination && (r.audioDestination.disconnect(), r.audioDestination = null), r.audioContext && r.audioContext.close(), r.audioContext = null, f.clearRect(0, 0, d.width, d.height), d.stream && (d.stream.stop(), d.stream = null);
    }, this.resetVideoStreams = function(n) {
      n && !(n instanceof Array) && (n = [n]), C(n);
    };
    function C(n) {
      a = [], n = n || i, n.forEach(function(u) {
        if (!!u.getTracks().filter(function(y) {
          return y.kind === "video";
        }).length) {
          var w = m(u);
          w.stream = u, a.push(w);
        }
      });
    }
    this.name = "MultiStreamsMixer", this.toString = function() {
      return this.name;
    }, this.getMixedStream = S;
  }
  typeof R > "u" && (Q.exports = Ie);
  function Oe(i, e) {
    i = i || [];
    var t = this, a, s;
    e = e || {
      elementClass: "multi-streams-mixer",
      mimeType: "video/webm",
      video: {
        width: 360,
        height: 240
      }
    }, e.frameInterval || (e.frameInterval = 10), e.video || (e.video = {}), e.video.width || (e.video.width = 360), e.video.height || (e.video.height = 240), this.record = function() {
      a = new Ie(i, e.elementClass || "multi-streams-mixer"), d().length && (a.frameInterval = e.frameInterval || 10, a.width = e.video.width || 360, a.height = e.video.height || 240, a.startDrawingFrames()), e.previewStream && typeof e.previewStream == "function" && e.previewStream(a.getMixedStream()), s = new j(a.getMixedStream(), e), s.record();
    };
    function d() {
      var f = [];
      return i.forEach(function(r) {
        x(r, "video").forEach(function(h) {
          f.push(h);
        });
      }), f;
    }
    this.stop = function(f) {
      !s || s.stop(function(r) {
        t.blob = r, f(r), t.clearRecordedData();
      });
    }, this.pause = function() {
      s && s.pause();
    }, this.resume = function() {
      s && s.resume();
    }, this.clearRecordedData = function() {
      s && (s.clearRecordedData(), s = null), a && (a.releaseStreams(), a = null);
    }, this.addStreams = function(f) {
      if (!f)
        throw "First parameter is required.";
      f instanceof Array || (f = [f]), i.concat(f), !(!s || !a) && (a.appendStreams(f), e.previewStream && typeof e.previewStream == "function" && e.previewStream(a.getMixedStream()));
    }, this.resetVideoStreams = function(f) {
      !a || (f && !(f instanceof Array) && (f = [f]), a.resetVideoStreams(f));
    }, this.getMixer = function() {
      return a;
    }, this.name = "MultiStreamRecorder", this.toString = function() {
      return this.name;
    };
  }
  typeof R < "u" && (R.MultiStreamRecorder = Oe);
  function ze(i, e) {
    if (!this)
      throw 'Use "new RecordRTCPromisesHandler()"';
    if (typeof i > "u")
      throw 'First argument "MediaStream" is required.';
    var t = this;
    t.recordRTC = new R(i, e), this.startRecording = function() {
      return new Promise(function(a, s) {
        try {
          t.recordRTC.startRecording(), a();
        } catch (d) {
          s(d);
        }
      });
    }, this.stopRecording = function() {
      return new Promise(function(a, s) {
        try {
          t.recordRTC.stopRecording(function(d) {
            if (t.blob = t.recordRTC.getBlob(), !t.blob || !t.blob.size) {
              s("Empty blob.", t.blob);
              return;
            }
            a(d);
          });
        } catch (d) {
          s(d);
        }
      });
    }, this.pauseRecording = function() {
      return new Promise(function(a, s) {
        try {
          t.recordRTC.pauseRecording(), a();
        } catch (d) {
          s(d);
        }
      });
    }, this.resumeRecording = function() {
      return new Promise(function(a, s) {
        try {
          t.recordRTC.resumeRecording(), a();
        } catch (d) {
          s(d);
        }
      });
    }, this.getDataURL = function(a) {
      return new Promise(function(s, d) {
        try {
          t.recordRTC.getDataURL(function(f) {
            s(f);
          });
        } catch (f) {
          d(f);
        }
      });
    }, this.getBlob = function() {
      return new Promise(function(a, s) {
        try {
          a(t.recordRTC.getBlob());
        } catch (d) {
          s(d);
        }
      });
    }, this.getInternalRecorder = function() {
      return new Promise(function(a, s) {
        try {
          a(t.recordRTC.getInternalRecorder());
        } catch (d) {
          s(d);
        }
      });
    }, this.reset = function() {
      return new Promise(function(a, s) {
        try {
          a(t.recordRTC.reset());
        } catch (d) {
          s(d);
        }
      });
    }, this.destroy = function() {
      return new Promise(function(a, s) {
        try {
          a(t.recordRTC.destroy());
        } catch (d) {
          s(d);
        }
      });
    }, this.getState = function() {
      return new Promise(function(a, s) {
        try {
          a(t.recordRTC.getState());
        } catch (d) {
          s(d);
        }
      });
    }, this.blob = null, this.version = "5.6.2";
  }
  typeof R < "u" && (R.RecordRTCPromisesHandler = ze);
  function fe(i, e) {
    (typeof ReadableStream > "u" || typeof WritableStream > "u") && console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"), e = e || {}, e.width = e.width || 640, e.height = e.height || 480, e.frameRate = e.frameRate || 30, e.bitrate = e.bitrate || 1200, e.realtime = e.realtime || !0;
    var t;
    function a() {
      return new ReadableStream({
        start: function(b) {
          var l = document.createElement("canvas"), g = document.createElement("video"), p = !0;
          g.srcObject = i, g.muted = !0, g.height = e.height, g.width = e.width, g.volume = 0, g.onplaying = function() {
            l.width = e.width, l.height = e.height;
            var v = l.getContext("2d"), c = 1e3 / e.frameRate, S = setInterval(function() {
              if (t && (clearInterval(S), b.close()), p && (p = !1, e.onVideoProcessStarted && e.onVideoProcessStarted()), v.drawImage(g, 0, 0), b._controlledReadableStream.state !== "closed")
                try {
                  b.enqueue(
                    v.getImageData(0, 0, e.width, e.height)
                  );
                } catch {
                }
            }, c);
          }, g.play();
        }
      });
    }
    var s;
    function d(b, l) {
      if (!e.workerPath && !l) {
        t = !1, fetch(
          "https://unpkg.com/webm-wasm@latest/dist/webm-worker.js"
        ).then(function(p) {
          p.arrayBuffer().then(function(v) {
            d(b, v);
          });
        });
        return;
      }
      if (!e.workerPath && l instanceof ArrayBuffer) {
        var g = new Blob([l], {
          type: "text/javascript"
        });
        e.workerPath = U.createObjectURL(g);
      }
      e.workerPath || console.error("workerPath parameter is missing."), s = new Worker(e.workerPath), s.postMessage(e.webAssemblyPath || "https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"), s.addEventListener("message", function(p) {
        p.data === "READY" ? (s.postMessage({
          width: e.width,
          height: e.height,
          bitrate: e.bitrate || 1200,
          timebaseDen: e.frameRate || 30,
          realtime: e.realtime
        }), a().pipeTo(new WritableStream({
          write: function(v) {
            if (t) {
              console.error("Got image, but recorder is finished!");
              return;
            }
            s.postMessage(v.data.buffer, [v.data.buffer]);
          }
        }))) : p.data && (f || h.push(p.data));
      });
    }
    this.record = function() {
      h = [], f = !1, this.blob = null, d(i), typeof e.initCallback == "function" && e.initCallback();
    };
    var f;
    this.pause = function() {
      f = !0;
    }, this.resume = function() {
      f = !1;
    };
    function r(b) {
      if (!s) {
        b && b();
        return;
      }
      s.addEventListener("message", function(l) {
        l.data === null && (s.terminate(), s = null, b && b());
      }), s.postMessage(null);
    }
    var h = [];
    this.stop = function(b) {
      t = !0;
      var l = this;
      r(function() {
        l.blob = new Blob(h, {
          type: "video/webm"
        }), b(l.blob);
      });
    }, this.name = "WebAssemblyRecorder", this.toString = function() {
      return this.name;
    }, this.clearRecordedData = function() {
      h = [], f = !1, this.blob = null;
    }, this.blob = null;
  }
  typeof R < "u" && (R.WebAssemblyRecorder = fe);
})(Je);
const Ye = ye, $e = /* @__PURE__ */ Ke({
  __proto__: null,
  default: Ye
}, [ye]);
export {
  $e as RecordRTC
};
//# sourceMappingURL=RecordRTC-446cdea8.js.map
