import { c as A, p as O, h as C, f as w, i as S, b as h, d as L, u as M, r as G, s as I, D as J, o as W, n as X } from "./AssetItem-BxjLUzNd.js";
import { a as j } from "./index-client-C5PXnhDi.js";
import { t as R, n as H, D as U, m as B, v as K, o as N, p as Q, w as x, z as T, E as r, C as c, x as y, r as Y, l as k, y as V, A as Z, J as $, M as P, bW as ee, I as te, bX as D, V as se, bY as re } from "./index-BBXAtvZr.js";
import { i as oe } from "./validation-DaZvZUPL.js";
import { B as ae } from "./Button-CqLZSfSk.js";
var ie = w(`<div class="crtw-text-2xl crtw-font-bold crtw-font-['poppins'] crtw-mb-4"> </div>`), ne = w('<iframe id="videoProgressIframe" title="progress-video" frameborder="0" scrolling="no" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture;" allowfullscreen="" width="100%" style="min-height: 200px"></iframe>'), de = w('<video width="100%" controls="" autoplay=""><source/> Your browser does not support the video tag.</video>', 2), le = w('<div class="crtw-pt-4 crtw-w-full"><!></div>'), ce = w('<div class="crtw-w-full"><!> <!></div> <!>', 1);
function q(v, a) {
  if (new.target) return A({ component: q, ...v });
  R(a, !1);
  const s = B();
  let p = O(a, "isProgressFinished", 12), i = O(a, "options", 12), { text: n, onSetVideoEnded: u } = i();
  H(() => K(i()), () => {
    U(s, i().selected);
  }), N();
  var _ = {
    get isProgressFinished() {
      return p();
    },
    set isProgressFinished(e) {
      p(e), k();
    },
    get options() {
      return i();
    },
    set options(e) {
      i(e), k();
    },
    $set: M,
    $on: (e, t) => L(a, e, t)
  };
  C();
  var d = ce(), f = Q(d), l = x(f);
  {
    var b = (e) => {
      var t = ie(), m = x(t, !0);
      y(t), V(() => G(m, n)), h(e, t);
    };
    S(l, (e) => {
      n && e(b);
    });
  }
  var E = T(l, 2);
  {
    var F = (e) => {
      var t = ne();
      V(() => I(t, "src", (r(s), c(() => `${r(s).src}?autoplay=1&mute=1`)))), h(e, t);
    }, o = (e) => {
      var t = de();
      t.muted = !0;
      var m = x(t);
      Z(), y(t), V(() => I(m, "src", (r(s), c(() => r(s).src)))), h(e, t);
    };
    S(E, (e) => {
      r(s), c(() => r(s).embedded) ? e(F) : (r(s), c(() => r(s).src) && e(o, 1));
    });
  }
  y(f);
  var g = T(f, 2);
  {
    var z = (e) => {
      var t = le(), m = x(t);
      ae(m, {
        get onClick() {
          return u;
        },
        text: "Skip"
      }), y(t), h(e, t);
    };
    S(g, (e) => {
      p() && e(z);
    });
  }
  return h(v, d), Y(_);
}
function ve(v, a) {
  if (new.target) return A({ component: ve, ...v });
  R(a, !1);
  const s = () => W(P, "$pageOptsStore", p), [p, i] = X();
  var n, u, _, d;
  const f = ((n = $(P)) === null || n === void 0 ? void 0 : n.loaderText) || ee, l = ((u = $(P)) === null || u === void 0 ? void 0 : u.progressVideos) || ((d = (_ = $(te)) === null || _ === void 0 ? void 0 : _.content) === null || d === void 0 ? void 0 : d.progressVideos) || [D];
  let b = B(D);
  j(() => {
    const o = Math.floor(Math.random() * l.length);
    U(b, oe(l[o].src) ? l[o] : D);
  });
  var E = {
    $set: M,
    $on: (o, g) => L(a, o, g)
  };
  C();
  {
    let o = se(() => ({
      text: f,
      selected: r(b),
      onSetVideoEnded: re
    }));
    q(v, {
      get options() {
        return r(o);
      },
      get isProgressFinished() {
        return s().isProgressFinished;
      },
      set isProgressFinished(g) {
        J(P, c(s).isProgressFinished = g, c(s));
      },
      $$legacy: !0
    });
  }
  var F = Y(E);
  return i(), F;
}
export {
  ve as default
};
//# sourceMappingURL=ProgressVideo-CP6gx21o.js.map
