"use strict";
cc._RF.push(module, '6acefvFAO9O7qvqEFnz5PJj', 'state_OP15');
// OP15/script/state_OP15.js

"use strict";

exports.__esModule = true;
exports.assign = o;
exports.createMachine = s;
exports.interpret = v;
exports.InterpreterStatus = void 0;

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function t(t, n) {
  var e = "function" == typeof Symbol && t[Symbol.iterator];
  if (!e) return t;
  var r,
      o,
      i = e.call(t),
      a = [];

  try {
    for (; (void 0 === n || n-- > 0) && !(r = i.next()).done;) {
      a.push(r.value);
    }
  } catch (t) {
    o = {
      error: t
    };
  } finally {
    try {
      r && !r.done && (e = i["return"]) && e.call(i);
    } finally {
      if (o) throw o.error;
    }
  }

  return a;
}

var n;
exports.InterpreterStatus = n;
!function (t) {
  t[t.NotStarted = 0] = "NotStarted", t[t.Running = 1] = "Running", t[t.Stopped = 2] = "Stopped";
}(n || (exports.InterpreterStatus = n = {}));
var e = {
  type: "xstate.init"
};

function r(t) {
  return void 0 === t ? [] : [].concat(t);
}

function o(t) {
  return {
    type: "xstate.assign",
    assignment: t
  };
}

function i(t, n) {
  return "string" == typeof (t = "string" == typeof t && n && n[t] ? n[t] : t) ? {
    type: t
  } : "function" == typeof t ? {
    type: t.name,
    exec: t
  } : t;
}

function a(t) {
  return function (n) {
    return t === n;
  };
}

function u(t) {
  return "string" == typeof t ? {
    type: t
  } : t;
}

function c(t, n) {
  return {
    value: t,
    context: n,
    actions: [],
    changed: !1,
    matches: a(t)
  };
}

function f(t, n, e) {
  var r = n,
      o = !1;
  return [t.filter(function (t) {
    if ("xstate.assign" === t.type) {
      o = !0;
      var n = Object.assign({}, r);
      return "function" == typeof t.assignment ? n = t.assignment(r, e) : Object.keys(t.assignment).forEach(function (o) {
        n[o] = "function" == typeof t.assignment[o] ? t.assignment[o](r, e) : t.assignment[o];
      }), r = n, !1;
    }

    return !0;
  }), r, o];
}

function s(n, o) {
  void 0 === o && (o = {});
  var s = t(f(r(n.states[n.initial].entry).map(function (t) {
    return i(t, o.actions);
  }), n.context, e), 2),
      l = s[0],
      v = s[1],
      y = {
    config: n,
    _options: o,
    initialState: {
      value: n.initial,
      actions: l,
      context: v,
      matches: a(n.initial)
    },
    transition: function transition(e, o) {
      var s,
          l,
          v = "string" == typeof e ? {
        value: e,
        context: n.context
      } : e,
          p = v.value,
          g = v.context,
          d = u(o),
          x = n.states[p];

      if (x.on) {
        var m = r(x.on[d.type]);

        try {
          for (var h = function (t) {
            var n = "function" == typeof Symbol && Symbol.iterator,
                e = n && t[n],
                r = 0;
            if (e) return e.call(t);
            if (t && "number" == typeof t.length) return {
              next: function next() {
                return t && r >= t.length && (t = void 0), {
                  value: t && t[r++],
                  done: !t
                };
              }
            };
            throw new TypeError(n ? "Object is not iterable." : "Symbol.iterator is not defined.");
          }(m), b = h.next(); !b.done; b = h.next()) {
            var S = b.value;
            if (void 0 === S) return c(p, g);

            var w = "string" == typeof S ? {
              target: S
            } : S,
                j = w.target,
                E = w.actions,
                R = void 0 === E ? [] : E,
                N = w.cond,
                O = void 0 === N ? function () {
              return !0;
            } : N,
                _ = void 0 === j,
                k = null != j ? j : p,
                T = n.states[k];

            if (O(g, d)) {
              var q = t(f((_ ? r(R) : [].concat(x.exit, R, T.entry).filter(function (t) {
                return t;
              })).map(function (t) {
                return i(t, y._options.actions);
              }), g, d), 3),
                  z = q[0],
                  A = q[1],
                  B = q[2],
                  C = null != j ? j : p;
              return {
                value: C,
                context: A,
                actions: z,
                changed: j !== p || z.length > 0 || B,
                matches: a(C)
              };
            }
          }
        } catch (t) {
          s = {
            error: t
          };
        } finally {
          try {
            b && !b.done && (l = h["return"]) && l.call(h);
          } finally {
            if (s) throw s.error;
          }
        }
      }

      return c(p, g);
    }
  };
  return y;
}

var l = function l(t, n) {
  return t.actions.forEach(function (e) {
    var r = e.exec;
    return r && r(t.context, n);
  });
};

function v(t) {
  var r = t.initialState,
      o = n.NotStarted,
      i = new Set(),
      c = {
    _machine: t,
    send: function send(e) {
      o === n.Running && (r = t.transition(r, e), l(r, u(e)), i.forEach(function (t) {
        return t(r);
      }));
    },
    subscribe: function subscribe(t) {
      return i.add(t), t(r), {
        unsubscribe: function unsubscribe() {
          return i["delete"](t);
        }
      };
    },
    start: function start(i) {
      if (i) {
        var u = "object" == typeof i ? i : {
          context: t.config.context,
          value: i
        };
        r = {
          value: u.value,
          actions: [],
          context: u.context,
          matches: a(u.value)
        };
      }

      return o = n.Running, l(r, e), c;
    },
    stop: function stop() {
      return o = n.Stopped, i.clear(), c;
    },

    get state() {
      return r;
    },

    get status() {
      return o;
    }

  };
  return c;
}

cc._RF.pop();