@alipay/ams-checkout 2.0.22 → 2.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,12 @@
1
1
  var _excluded = ["onStatusChange"],
2
2
  _excluded2 = ["onBeforeConfirm"];
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
4
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
8
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
9
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
10
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
12
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -24,15 +21,20 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
24
21
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
22
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
23
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
25
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
26
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
27
27
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
29
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
30
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
31
31
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
32
- import { openModal, showToast, sdkQuery, getLocaleFromRenderData, getDevReqConfig, getMetaData, buildPageUrl, debugError, debug, MessageType, request, parseHostSign, SDKBridge, parseTrackerId, oneAccountQuery, OpenSDKError, awaitWrap, themeColorMap, ApplePayHostService, buildRecurringPaymentRequest, checkSessionData, sdkTracker } from "../../../../modern/tools";
32
+ import { openModal, showToast, sdkQuery, getLocaleFromRenderData, getDevReqConfig, getMetaData, buildPageUrl, debugError, debug, MessageType, request, parseHostSign, SDKBridge, parseTrackerId, oneAccountQuery, OpenSDKError, awaitWrap, themeColorMap, ApplePayHostService, buildRecurringPaymentRequest, checkSessionData, sdkTracker, ModalPort } from "../../../../modern/tools";
33
+ import { shouldQueryOneAccount } from "../../../utils/connectConfig";
33
34
  import { device } from "../../../../util";
34
35
  import { EventCallbackCode } from "../type";
35
36
  import { adaptSubmitResult, adaptAppearance } from "./adapter";
37
+ import { safeParse } from "../util";
36
38
  import { v4 as uuid } from 'uuid';
37
39
 
38
40
  // ============================================================
@@ -43,18 +45,45 @@ import { v4 as uuid } from 'uuid';
43
45
  // ============================================================
44
46
 
45
47
  var TRACK_CODE_PREFIX = '7982';
48
+
49
+ // 缓存解析出的 merchantId,供埋点 helper 在任意阶段统一带上
50
+ var _merchantId = '';
46
51
  var track = function track(phase, msg) {
47
52
  var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
48
53
  try {
49
54
  var code = "".concat(TRACK_CODE_PREFIX).concat(phase === 'error' ? '' : phase);
55
+ // LogItem 类型未暴露 merchant_id 字段,但运行时 tracker 会透传,
56
+ // 故用断言保留该字段名供下游埋点消费
50
57
  sdkTracker.log(_objectSpread({
51
58
  code: code,
52
- msg: msg
59
+ msg: msg,
60
+ merchant_id: _merchantId
53
61
  }, extra));
54
62
  } catch (_unused) {
55
63
  /* 埋点失败绝不影响主流程 */
56
64
  }
57
65
  };
66
+
67
+ /**
68
+ * 优先取 sessionData 解析出的 clientId;
69
+ * 缺失时从容错角度回落到 extendInfo 中的 merchantId(URL 编码需解码)。
70
+ * 全程容错:任一步骤缺失/解析失败都返回空串,绝不抛异常。
71
+ */
72
+ var resolveMerchantId = function resolveMerchantId(parseData) {
73
+ if (parseData !== null && parseData !== void 0 && parseData.clientId) {
74
+ return parseData.clientId;
75
+ }
76
+ try {
77
+ var info = safeParse(parseData === null || parseData === void 0 ? void 0 : parseData.extendInfo, {});
78
+ var merchantId = info === null || info === void 0 ? void 0 : info.merchantId;
79
+ if (!merchantId || typeof merchantId !== 'string') {
80
+ return '';
81
+ }
82
+ return decodeURIComponent(merchantId);
83
+ } catch (_unused2) {
84
+ return '';
85
+ }
86
+ };
58
87
  var trackMount = function trackMount(msg) {
59
88
  var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
60
89
  return track('mount', msg, extra);
@@ -71,6 +100,81 @@ var trackError = function trackError(msg) {
71
100
  var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
72
101
  return track('error', msg, extra);
73
102
  };
103
+ // ============================================================
104
+ // 统一 API 终态上报(7982api):在 mount/submitPayment/validateFields
105
+ // 每个出口(成功/失败/中断)捕获「返回给商户的完整结果」,一处包裹覆盖全部分支。
106
+ // 与分散的 trackXxx 互补、不替换;merchantId 为关键字段,必带。
107
+ // _merchantId 在 setup() 解析后填充,mount 首次调用在 resolve 时已就绪。
108
+ // ============================================================
109
+ var reportApiEnd = function reportApiEnd(api, durationMs) {
110
+ var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
111
+ try {
112
+ sdkTracker.log(_objectSpread({
113
+ code: "".concat(TRACK_CODE_PREFIX, "api"),
114
+ msg: api,
115
+ m1: durationMs,
116
+ merchant_id: _merchantId
117
+ }, extra));
118
+ } catch (_unused3) {
119
+ /* 埋点失败绝不影响主流程 */
120
+ }
121
+ };
122
+
123
+ // 将返回给商户的结果对象归一为埋点维度:d1 状态/成败、d2 error.code、d3 traceId、d4 扩展
124
+ var normalizeApiResult = function normalizeApiResult(api, result) {
125
+ var acc = {};
126
+ if (api === 'submitPayment') {
127
+ var _result$error, _result$error2;
128
+ acc.d1 = (result === null || result === void 0 ? void 0 : result.status) || '';
129
+ acc.d2 = (result === null || result === void 0 || (_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.code) || '';
130
+ if (result !== null && result !== void 0 && (_result$error2 = result.error) !== null && _result$error2 !== void 0 && _result$error2.traceId) acc.d3 = result.error.traceId;
131
+ // d4 固定留给 paymentMethodType(与 submit_reply 链 d4 口径一致,便于跨链关联)
132
+ if (result !== null && result !== void 0 && result.userCanceled3D) acc.d5 = 'true';
133
+ } else if (api === 'mount') {
134
+ var _result$error3, _result$error4;
135
+ acc.d1 = result !== null && result !== void 0 && result.error ? 'fail' : 'success';
136
+ acc.d2 = (result === null || result === void 0 || (_result$error3 = result.error) === null || _result$error3 === void 0 ? void 0 : _result$error3.code) || '';
137
+ if (result !== null && result !== void 0 && (_result$error4 = result.error) !== null && _result$error4 !== void 0 && _result$error4.traceId) acc.d3 = result.error.traceId;
138
+ } else if (api === 'validateFields') {
139
+ acc.d1 = result !== null && result !== void 0 && result.isValid ? 'valid' : 'invalid';
140
+ }
141
+ return acc;
142
+ };
143
+
144
+ // 统一包裹:捕获终态(resolve/reject)后上报,原值/原异常原样透传,不影响任何已有逻辑。
145
+ // extraBuilder 供调用方注入实例上下文字段(如 paymentMethodType),其值覆盖 normalizeApiResult 结果。
146
+ var runApi = /*#__PURE__*/function () {
147
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, fn, extraBuilder) {
148
+ var startedAt, result;
149
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
150
+ while (1) switch (_context.prev = _context.next) {
151
+ case 0:
152
+ startedAt = Date.now();
153
+ _context.prev = 1;
154
+ _context.next = 4;
155
+ return fn();
156
+ case 4:
157
+ result = _context.sent;
158
+ reportApiEnd(api, Date.now() - startedAt, _objectSpread(_objectSpread({}, normalizeApiResult(api, result)), extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(false)));
159
+ return _context.abrupt("return", result);
160
+ case 9:
161
+ _context.prev = 9;
162
+ _context.t0 = _context["catch"](1);
163
+ reportApiEnd(api, Date.now() - startedAt, _objectSpread({
164
+ d1: 'error',
165
+ d2: (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.code) || 'UNKNOWN'
166
+ }, extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(true)));
167
+ throw _context.t0;
168
+ case 13:
169
+ case "end":
170
+ return _context.stop();
171
+ }
172
+ }, _callee, null, [[1, 9]]);
173
+ }));
174
+ return function runApi(_x, _x2, _x3) {
175
+ return _ref.apply(this, arguments);
176
+ };
177
+ }();
74
178
  import CallApp from "../../../../util/intl-callapp/es/main";
75
179
  import { getApplePayPaymentSession } from "../../../../service";
76
180
  import { BusManager, BusMessage } from "../../../bus";
@@ -175,9 +279,9 @@ var AMSMessageType = {
175
279
  * 7. ready 后发送缓存的消息
176
280
  */
177
281
  export var ModernElementController = /*#__PURE__*/function () {
178
- function ModernElementController(_ref) {
179
- var onStatusChange = _ref.onStatusChange,
180
- options = _objectWithoutProperties(_ref, _excluded);
282
+ function ModernElementController(_ref2) {
283
+ var onStatusChange = _ref2.onStatusChange,
284
+ options = _objectWithoutProperties(_ref2, _excluded);
181
285
  _classCallCheck(this, ModernElementController);
182
286
  _defineProperty(this, "options", void 0);
183
287
  _defineProperty(this, "onStatusChange", void 0);
@@ -190,7 +294,6 @@ export var ModernElementController = /*#__PURE__*/function () {
190
294
  _defineProperty(this, "modalBridge", null);
191
295
  _defineProperty(this, "modalDestroy", null);
192
296
  _defineProperty(this, "modalIframe", null);
193
- _defineProperty(this, "_closeConfirmResolve", null);
194
297
  _defineProperty(this, "notRedirectAfterComplete", false);
195
298
  _defineProperty(this, "_sdkInitTime", Date.now());
196
299
  _defineProperty(this, "_mountStartTime", 0);
@@ -227,11 +330,33 @@ export var ModernElementController = /*#__PURE__*/function () {
227
330
  _createClass(ModernElementController, [{
228
331
  key: "mount",
229
332
  value: function () {
230
- var _mount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(renderOptions, sdkSelector) {
333
+ var _mount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderOptions, sdkSelector) {
334
+ var _this = this;
335
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
336
+ while (1) switch (_context2.prev = _context2.next) {
337
+ case 0:
338
+ return _context2.abrupt("return", runApi('mount', function () {
339
+ return _this.doMount(renderOptions, sdkSelector);
340
+ }));
341
+ case 1:
342
+ case "end":
343
+ return _context2.stop();
344
+ }
345
+ }, _callee2);
346
+ }));
347
+ function mount(_x4, _x5) {
348
+ return _mount.apply(this, arguments);
349
+ }
350
+ return mount;
351
+ }()
352
+ }, {
353
+ key: "doMount",
354
+ value: function () {
355
+ var _doMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(renderOptions, sdkSelector) {
231
356
  var _this$options$loading, _this$options$loading2;
232
357
  var container, _this$options, _this$options$onEvent, _this$options$loading3, _this$options$loading4, iframeUrl, iframeOrigin, readyHandshakePromise, _yield$Promise$all, _yield$Promise$all2, setupConfig, dataStructError, _this$options$loading5, _this$options$loading6, _this$options2, _this$options2$onEven, errorResult;
233
- return _regeneratorRuntime().wrap(function _callee$(_context) {
234
- while (1) switch (_context.prev = _context.next) {
358
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
359
+ while (1) switch (_context3.prev = _context3.next) {
235
360
  case 0:
236
361
  trackMount('mount_start', {
237
362
  d1: sdkSelector,
@@ -239,7 +364,7 @@ export var ModernElementController = /*#__PURE__*/function () {
239
364
  });
240
365
  container = document.querySelector(sdkSelector);
241
366
  if (container) {
242
- _context.next = 6;
367
+ _context3.next = 6;
243
368
  break;
244
369
  }
245
370
  trackError('selector_not_found', {
@@ -249,7 +374,7 @@ export var ModernElementController = /*#__PURE__*/function () {
249
374
  code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
250
375
  message: "Element with selector ".concat(sdkSelector, " not found.")
251
376
  });
252
- return _context.abrupt("return", {
377
+ return _context3.abrupt("return", {
253
378
  error: {
254
379
  code: 'PARAM_INVALID',
255
380
  message: "selector not found"
@@ -258,7 +383,7 @@ export var ModernElementController = /*#__PURE__*/function () {
258
383
  case 6:
259
384
  (_this$options$loading = this.options.loading) === null || _this$options$loading === void 0 || (_this$options$loading2 = _this$options$loading.onStartLoading) === null || _this$options$loading2 === void 0 || _this$options$loading2.call(_this$options$loading);
260
385
  this.setStatus('mounting');
261
- _context.prev = 8;
386
+ _context3.prev = 8;
262
387
  // 1. 创建 iframe(先不设置 src,避免提前触发加载)
263
388
  iframeUrl = this.buildIframeUrl();
264
389
  this.iframe = document.createElement('iframe');
@@ -273,7 +398,7 @@ export var ModernElementController = /*#__PURE__*/function () {
273
398
  if (iframeOrigin && iframeOrigin !== 'null') {
274
399
  this.bridge.setOrigin(iframeOrigin);
275
400
  }
276
- } catch (_unused2) {
401
+ } catch (_unused4) {
277
402
  // URL 解析失败时保持默认 origin
278
403
  }
279
404
  } else {
@@ -291,14 +416,14 @@ export var ModernElementController = /*#__PURE__*/function () {
291
416
  });
292
417
 
293
418
  // 3. setup()(网络请求)与 waitForReadyHandshake()(等待 iframe 加载)并行执行
294
- _context.next = 24;
419
+ _context3.next = 24;
295
420
  return Promise.all([this.setup(renderOptions), readyHandshakePromise]);
296
421
  case 24:
297
- _yield$Promise$all = _context.sent;
422
+ _yield$Promise$all = _context3.sent;
298
423
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 1);
299
424
  setupConfig = _yield$Promise$all2[0];
300
425
  if (!(this.status === 'destroyed')) {
301
- _context.next = 29;
426
+ _context3.next = 29;
302
427
  break;
303
428
  }
304
429
  throw getDestroyedError();
@@ -317,59 +442,59 @@ export var ModernElementController = /*#__PURE__*/function () {
317
442
  this.sendHandshake(setupConfig);
318
443
 
319
444
  // 5. 等待 HANDSHAKE_ACK
320
- _context.next = 35;
445
+ _context3.next = 35;
321
446
  return this.waitForHandshakeAck();
322
447
  case 35:
323
448
  this.setStatus('ready');
324
449
  this.flushCachedMessages();
325
450
  (_this$options$loading3 = this.options.loading) === null || _this$options$loading3 === void 0 || (_this$options$loading4 = _this$options$loading3.onEndLoading) === null || _this$options$loading4 === void 0 || _this$options$loading4.call(_this$options$loading3);
326
451
  if (!dataStructError) {
327
- _context.next = 40;
452
+ _context3.next = 40;
328
453
  break;
329
454
  }
330
- return _context.abrupt("return", {
455
+ return _context3.abrupt("return", {
331
456
  error: dataStructError
332
457
  });
333
458
  case 40:
334
459
  trackMount('mount_success', {
335
460
  m1: this._mountStartTime ? Date.now() - this._mountStartTime : 0
336
461
  });
337
- return _context.abrupt("return", {});
462
+ return _context3.abrupt("return", {});
338
463
  case 44:
339
- _context.prev = 44;
340
- _context.t0 = _context["catch"](8);
464
+ _context3.prev = 44;
465
+ _context3.t0 = _context3["catch"](8);
341
466
  (_this$options$loading5 = this.options.loading) === null || _this$options$loading5 === void 0 || (_this$options$loading6 = _this$options$loading5.onEndLoading) === null || _this$options$loading6 === void 0 || _this$options$loading6.call(_this$options$loading5);
342
- if (!isDestroyedError(_context.t0)) {
343
- _context.next = 49;
467
+ if (!isDestroyedError(_context3.t0)) {
468
+ _context3.next = 49;
344
469
  break;
345
470
  }
346
- return _context.abrupt("return", {
347
- error: _context.t0
471
+ return _context3.abrupt("return", {
472
+ error: _context3.t0
348
473
  });
349
474
  case 49:
350
475
  trackError('mount_error', {
351
- d1: (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.code) || 'UNKNOWN',
352
- d2: (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || ''
476
+ d1: (_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.code) || 'UNKNOWN',
477
+ d2: (_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.message) || ''
353
478
  });
354
479
  this.cleanup();
355
480
  errorResult = {
356
- code: _context.t0.code || 'UNKNOWN',
357
- message: _context.t0.message || ''
481
+ code: _context3.t0.code || 'UNKNOWN',
482
+ message: _context3.t0.message || ''
358
483
  };
359
484
  (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2$onEven = _this$options2.onEventCallback) === null || _this$options2$onEven === void 0 || _this$options2$onEven.call(_this$options2, errorResult);
360
- return _context.abrupt("return", {
485
+ return _context3.abrupt("return", {
361
486
  error: errorResult
362
487
  });
363
488
  case 54:
364
489
  case "end":
365
- return _context.stop();
490
+ return _context3.stop();
366
491
  }
367
- }, _callee, this, [[8, 44]]);
492
+ }, _callee3, this, [[8, 44]]);
368
493
  }));
369
- function mount(_x, _x2) {
370
- return _mount.apply(this, arguments);
494
+ function doMount(_x6, _x7) {
495
+ return _doMount.apply(this, arguments);
371
496
  }
372
- return mount;
497
+ return doMount;
373
498
  }()
374
499
  /**
375
500
  * setup() — 解析 sessionData 获取 metaData,发起 sdkQuery 获取渲染数据,准备 HANDSHAKE 配置
@@ -384,14 +509,14 @@ export var ModernElementController = /*#__PURE__*/function () {
384
509
  }, {
385
510
  key: "setup",
386
511
  value: (function () {
387
- var _setup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderOptions) {
512
+ var _setup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(renderOptions) {
388
513
  var _parseData$connectFac,
389
- _this = this,
514
+ _this2 = this,
390
515
  _parseData$paymentMet,
391
516
  _sdkQueryResult$data;
392
- var sessionData, parseData, lastEnv, isConnect, paymentSessionConfig, genSdkQueryPromise, genOneAccountQueryPromise, promises, cancelDestroyCallback, destroyPromise, queryPromise, _yield$Promise$race$f, _yield$Promise$race$f2, sdkQueryResult, oneAccountQueryResult, _sdkQueryResult$error, _sdkQueryResult$error2, _oneAccountQueryResul, _oneAccountQueryResul2, preferredLocale, locale, renderDataError;
393
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
394
- while (1) switch (_context2.prev = _context2.next) {
517
+ var sessionData, parseData, lastEnv, isConnect, shouldQueryOneAccountFlag, paymentSessionConfig, genSdkQueryPromise, genOneAccountQueryPromise, promises, cancelDestroyCallback, destroyPromise, queryPromise, _yield$Promise$race$f, _yield$Promise$race$f2, sdkQueryResult, oneAccountQueryResult, _sdkQueryResult$error, _sdkQueryResult$error2, _oneAccountQueryResul, _oneAccountQueryResul2, preferredLocale, locale, renderDataError;
518
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
519
+ while (1) switch (_context4.prev = _context4.next) {
395
520
  case 0:
396
521
  this._mountStartTime = Date.now();
397
522
  trackMount('setup_start');
@@ -402,6 +527,10 @@ export var ModernElementController = /*#__PURE__*/function () {
402
527
  parseData = checkSessionData(sessionData, 'ELEMENT_PAYMENT');
403
528
  lastEnv = this.options.environment === 'sandbox' ? 'sandbox' : 'prod';
404
529
  this.options.environment;
530
+ // 解析 merchantId(优先 clientId,缺失时容错回落到 extendInfo.merchantId),
531
+ // 缓存到模块级变量,使后续所有 trackXxx 埋点统一带上
532
+ _merchantId = resolveMerchantId(parseData);
533
+
405
534
  // 初始化 request 全局配置,使 sdkQuery 能正确发起请求
406
535
  // tracker: sdkTracker —— 接入 HTTP 层自动埋点(B 套),上报每个请求的成败/RTT/错误码
407
536
  // 与 antom.ts 入口对齐;不传则 sdkQuery/submitPay/inquiry 等网络细节不可观测
@@ -409,10 +538,11 @@ export var ModernElementController = /*#__PURE__*/function () {
409
538
  hostSign: parseHostSign(sessionData),
410
539
  env: lastEnv
411
540
  }, getDevReqConfig()), {}, {
412
- sdkVersion: "2.0.22" || '',
541
+ sdkVersion: "2.0.24" || '',
413
542
  tracker: sdkTracker
414
543
  }));
415
544
  isConnect = !!(parseData !== null && parseData !== void 0 && (_parseData$connectFac = parseData.connectFactor) !== null && _parseData$connectFac !== void 0 && _parseData$connectFac.enableConnect);
545
+ shouldQueryOneAccountFlag = shouldQueryOneAccount(isConnect, parseData === null || parseData === void 0 ? void 0 : parseData.extendInfo);
416
546
  paymentSessionConfig = parseData === null || parseData === void 0 ? void 0 : parseData.paymentSessionConfig;
417
547
  genSdkQueryPromise = function genSdkQueryPromise() {
418
548
  var _renderOptions$mercha;
@@ -421,14 +551,14 @@ export var ModernElementController = /*#__PURE__*/function () {
421
551
  isUserPreferredLocale: true
422
552
  },
423
553
  merchantAppointParam: (_renderOptions$mercha = renderOptions.merchantAppointParam) !== null && _renderOptions$mercha !== void 0 && _renderOptions$mercha.storedCard ? renderOptions.merchantAppointParam : undefined,
424
- notRedirectAfterComplete: _this.notRedirectAfterComplete,
554
+ notRedirectAfterComplete: _this2.notRedirectAfterComplete,
425
555
  // sdk需要传入该字段
426
556
  paymentSessionConfig: parseData === null || parseData === void 0 ? void 0 : parseData.paymentSessionConfig,
427
557
  paymentSessionData: sessionData
428
558
  }, {
429
559
  // 传商户初始化的 locale,服务端据此返回对应语言(缺失则回落用户偏好/en_US)
430
560
  envInfo: {
431
- locale: _this.options.locale
561
+ locale: _this2.options.locale
432
562
  }
433
563
  }).catch(recoverSdkQueryBusinessResponse));
434
564
  };
@@ -441,18 +571,18 @@ export var ModernElementController = /*#__PURE__*/function () {
441
571
  }
442
572
  }));
443
573
  };
444
- promises = isConnect ? [genSdkQueryPromise(), genOneAccountQueryPromise()] : [genSdkQueryPromise(), undefined];
574
+ promises = shouldQueryOneAccountFlag ? [genSdkQueryPromise(), genOneAccountQueryPromise()] : [genSdkQueryPromise(), undefined];
445
575
  cancelDestroyCallback = function cancelDestroyCallback() {};
446
576
  destroyPromise = new Promise(function (_, reject) {
447
- cancelDestroyCallback = _this.onDestroy(function () {
577
+ cancelDestroyCallback = _this2.onDestroy(function () {
448
578
  return reject(getDestroyedError());
449
579
  });
450
580
  });
451
581
  queryPromise = Promise.all(promises);
452
- _context2.next = 18;
582
+ _context4.next = 20;
453
583
  return Promise.race([queryPromise, destroyPromise]).finally(cancelDestroyCallback);
454
- case 18:
455
- _yield$Promise$race$f = _context2.sent;
584
+ case 20:
585
+ _yield$Promise$race$f = _context4.sent;
456
586
  _yield$Promise$race$f2 = _slicedToArray(_yield$Promise$race$f, 2);
457
587
  sdkQueryResult = _yield$Promise$race$f2[0];
458
588
  oneAccountQueryResult = _yield$Promise$race$f2[1];
@@ -462,7 +592,7 @@ export var ModernElementController = /*#__PURE__*/function () {
462
592
  d2: ((_sdkQueryResult$error2 = sdkQueryResult.error) === null || _sdkQueryResult$error2 === void 0 ? void 0 : _sdkQueryResult$error2.message) || ''
463
593
  });
464
594
  }
465
- if (isConnect && oneAccountQueryResult !== null && oneAccountQueryResult !== void 0 && oneAccountQueryResult.error) {
595
+ if (shouldQueryOneAccountFlag && oneAccountQueryResult !== null && oneAccountQueryResult !== void 0 && oneAccountQueryResult.error) {
466
596
  trackHandshake('one_account_query_failed', {
467
597
  d1: ((_oneAccountQueryResul = oneAccountQueryResult.error) === null || _oneAccountQueryResul === void 0 ? void 0 : _oneAccountQueryResul.code) || '',
468
598
  d2: ((_oneAccountQueryResul2 = oneAccountQueryResult.error) === null || _oneAccountQueryResul2 === void 0 ? void 0 : _oneAccountQueryResul2.message) || ''
@@ -473,7 +603,7 @@ export var ModernElementController = /*#__PURE__*/function () {
473
603
  preferredLocale = getLocaleFromRenderData(sdkQueryResult.data);
474
604
  locale = preferredLocale || this.options.locale; // 优先使用请求错误,其次使用数据结构校验错误
475
605
  renderDataError = sdkQueryResult.error || (oneAccountQueryResult === null || oneAccountQueryResult === void 0 ? void 0 : oneAccountQueryResult.error);
476
- return _context2.abrupt("return", {
606
+ return _context4.abrupt("return", {
477
607
  sdkTiming: {
478
608
  sdkInitTime: this._sdkInitTime,
479
609
  mountStartTime: this._mountStartTime
@@ -498,7 +628,7 @@ export var ModernElementController = /*#__PURE__*/function () {
498
628
  paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
499
629
  productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
500
630
  trackId: parseTrackerId(sessionData),
501
- merchantId: parseData === null || parseData === void 0 ? void 0 : parseData.clientId,
631
+ merchantId: _merchantId,
502
632
  paymentMethodType: parseData === null || parseData === void 0 || (_parseData$paymentMet = parseData.paymentMethodInfoView) === null || _parseData$paymentMet === void 0 ? void 0 : _parseData$paymentMet.paymentMethodType
503
633
  },
504
634
  // 原老字段
@@ -506,7 +636,7 @@ export var ModernElementController = /*#__PURE__*/function () {
506
636
  // 新sdk字段
507
637
  locale: locale,
508
638
  // 新sdk字段
509
- sdkVersion: "2.0.22" || '',
639
+ sdkVersion: "2.0.24" || '',
510
640
  // 新sdk字段
511
641
  merchantId: (sdkQueryResult === null || sdkQueryResult === void 0 || (_sdkQueryResult$data = sdkQueryResult.data) === null || _sdkQueryResult$data === void 0 ? void 0 : _sdkQueryResult$data.merchantId) || '',
512
642
  // 新sdk字段
@@ -516,13 +646,13 @@ export var ModernElementController = /*#__PURE__*/function () {
516
646
  env: lastEnv
517
647
  }, getDevReqConfig())
518
648
  });
519
- case 28:
649
+ case 30:
520
650
  case "end":
521
- return _context2.stop();
651
+ return _context4.stop();
522
652
  }
523
- }, _callee2, this);
653
+ }, _callee4, this);
524
654
  }));
525
- function setup(_x3) {
655
+ function setup(_x8) {
526
656
  return _setup.apply(this, arguments);
527
657
  }
528
658
  return setup;
@@ -588,10 +718,10 @@ export var ModernElementController = /*#__PURE__*/function () {
588
718
  // 金额存在性校验
589
719
  var hasAmountViews = !!orderAmountView && !!paymentAmountView;
590
720
  if (!success) {
591
- var _ref2 = renderData,
592
- traceId = _ref2.traceId,
593
- errorCode = _ref2.errorCode,
594
- errorMessage = _ref2.errorMessage;
721
+ var _ref3 = renderData,
722
+ traceId = _ref3.traceId,
723
+ errorCode = _ref3.errorCode,
724
+ errorMessage = _ref3.errorMessage;
595
725
  return this.getLegacySdkQueryError({
596
726
  errorCode: errorCode,
597
727
  errorMessage: errorMessage,
@@ -619,20 +749,20 @@ export var ModernElementController = /*#__PURE__*/function () {
619
749
  }, {
620
750
  key: "bindBridgeEvents",
621
751
  value: function bindBridgeEvents() {
622
- var _this2 = this;
752
+ var _this3 = this;
623
753
  this.bridge.on(MessageType.HEIGHT_UPDATE, function (height) {
624
- if (_this2.iframe) _this2.iframe.style.height = "".concat(height, "px");
754
+ if (_this3.iframe) _this3.iframe.style.height = "".concat(height, "px");
625
755
  });
626
756
  this.bridge.on(AMSMessageType.SHOWTOAST, function (payload, _ports, meta) {
627
- var _this2$iframe, _this2$modalIframe;
628
- if (meta && meta.source !== ((_this2$iframe = _this2.iframe) === null || _this2$iframe === void 0 ? void 0 : _this2$iframe.contentWindow) && meta.source !== ((_this2$modalIframe = _this2.modalIframe) === null || _this2$modalIframe === void 0 ? void 0 : _this2$modalIframe.contentWindow)) {
757
+ var _this3$iframe, _this3$modalIframe;
758
+ if (meta && meta.source !== ((_this3$iframe = _this3.iframe) === null || _this3$iframe === void 0 ? void 0 : _this3$iframe.contentWindow) && meta.source !== ((_this3$modalIframe = _this3.modalIframe) === null || _this3$modalIframe === void 0 ? void 0 : _this3$modalIframe.contentWindow)) {
629
759
  return;
630
760
  }
631
761
  showToast(payload);
632
762
  });
633
763
  this.bridge.on(MessageType.REDIRECT, function (payload, _ports, meta) {
634
- var _this2$iframe2, _this2$modalIframe2;
635
- if (meta && meta.source !== ((_this2$iframe2 = _this2.iframe) === null || _this2$iframe2 === void 0 ? void 0 : _this2$iframe2.contentWindow) && meta.source !== ((_this2$modalIframe2 = _this2.modalIframe) === null || _this2$modalIframe2 === void 0 ? void 0 : _this2$modalIframe2.contentWindow)) {
764
+ var _this3$iframe2, _this3$modalIframe2;
765
+ if (meta && meta.source !== ((_this3$iframe2 = _this3.iframe) === null || _this3$iframe2 === void 0 ? void 0 : _this3$iframe2.contentWindow) && meta.source !== ((_this3$modalIframe2 = _this3.modalIframe) === null || _this3$modalIframe2 === void 0 ? void 0 : _this3$modalIframe2.contentWindow)) {
636
766
  return;
637
767
  }
638
768
  var url = payload.url,
@@ -650,7 +780,7 @@ export var ModernElementController = /*#__PURE__*/function () {
650
780
  d6: destroy ? '1' : '0'
651
781
  });
652
782
  if (destroy) {
653
- _this2.destroy();
783
+ _this3.destroy();
654
784
  }
655
785
  function fallbackJump() {
656
786
  if (mode === 'replace') {
@@ -688,34 +818,34 @@ export var ModernElementController = /*#__PURE__*/function () {
688
818
  }
689
819
  });
690
820
  this.bridge.on(MessageType.OPEN_MODAL, function (payload, _ports, meta) {
691
- var _this2$iframe3;
692
- if (meta && meta.source !== ((_this2$iframe3 = _this2.iframe) === null || _this2$iframe3 === void 0 ? void 0 : _this2$iframe3.contentWindow)) {
821
+ var _this3$iframe3;
822
+ if (meta && meta.source !== ((_this3$iframe3 = _this3.iframe) === null || _this3$iframe3 === void 0 ? void 0 : _this3$iframe3.contentWindow)) {
693
823
  return;
694
824
  }
695
- _this2.handleOpenModal(payload);
696
- _this2.bridge.once(MessageType.CLOSE_MODAL, function () {
697
- _this2.handleCloseModal();
825
+ _this3.handleOpenModal(payload);
826
+ _this3.bridge.once(MessageType.CLOSE_MODAL, function () {
827
+ _this3.handleCloseModal();
698
828
  });
699
829
  });
700
830
  this.bridge.on(MessageType.DESTROY_ELEMENT, function (_payload, _ports, meta) {
701
- var _this2$iframe4;
702
- if (meta && meta.source !== ((_this2$iframe4 = _this2.iframe) === null || _this2$iframe4 === void 0 ? void 0 : _this2$iframe4.contentWindow)) {
831
+ var _this3$iframe4;
832
+ if (meta && meta.source !== ((_this3$iframe4 = _this3.iframe) === null || _this3$iframe4 === void 0 ? void 0 : _this3$iframe4.contentWindow)) {
703
833
  return;
704
834
  }
705
- _this2.destroy();
835
+ _this3.destroy();
706
836
  });
707
837
 
708
838
  // skipRenderPaymentMethod 场景:webapp 委托 SDK 全权拉起 ApplePay,fire-and-forget
709
839
  // 走 plugin/applepay 标准链路(onEventCallback 自动通知商户)
710
840
  this.bridge.on(AMSMessageType.HANDLE_PAYMENT, function () {
711
- _this2.handleHandlePayment();
841
+ _this3.handleHandlePayment();
712
842
  });
713
843
 
714
844
  // Apple Pay beforeConfirm:在 submitPayment 内通过 bridge.once 监听,此处不再注册
715
845
 
716
846
  // 支付方式变化:iframe 通知 SDK 当前选中的支付方式类型
717
847
  this.bridge.on(AMSMessageType.PAYMENT_METHOD_CHANGED, function (payload) {
718
- _this2.currentPaymentMethodType = (payload === null || payload === void 0 ? void 0 : payload.type) || '';
848
+ _this3.currentPaymentMethodType = (payload === null || payload === void 0 ? void 0 : payload.type) || '';
719
849
  });
720
850
  }
721
851
 
@@ -727,12 +857,12 @@ export var ModernElementController = /*#__PURE__*/function () {
727
857
  }, {
728
858
  key: "handleGetApplePayToken",
729
859
  value: (function () {
730
- var _handleGetApplePayToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(payload, onBeforeConfirm) {
860
+ var _handleGetApplePayToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(payload, onBeforeConfirm) {
731
861
  var _paymentMethod,
732
- _this3 = this;
862
+ _this4 = this;
733
863
  var sessionData, applePayProps, paymentRequest, merchantCapabilities, merchantInfo, paymentAmount, supportedNetworks, version, requiredBillingContactFields, requiredShippingContactFields, finalAmount, finalCurrency, capturedResult, recurringRequest, service, _capturedResult, errCode;
734
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
735
- while (1) switch (_context5.prev = _context5.next) {
864
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
865
+ while (1) switch (_context7.prev = _context7.next) {
736
866
  case 0:
737
867
  sessionData = this.options.sessionData;
738
868
  applePayProps = payload === null || payload === void 0 || (_paymentMethod = payload.paymentMethod) === null || _paymentMethod === void 0 || (_paymentMethod = _paymentMethod.paymentMethodDetail) === null || _paymentMethod === void 0 ? void 0 : _paymentMethod.applePayProps;
@@ -741,7 +871,7 @@ export var ModernElementController = /*#__PURE__*/function () {
741
871
  d1: paymentRequest ? 'has_payment_request' : 'no_payment_request'
742
872
  });
743
873
  if (paymentRequest) {
744
- _context5.next = 8;
874
+ _context7.next = 8;
745
875
  break;
746
876
  }
747
877
  trackError('applepay_token_missing_data', {
@@ -753,7 +883,7 @@ export var ModernElementController = /*#__PURE__*/function () {
753
883
  errorCode: 'APPLE_PAY_MISSING_DATA'
754
884
  }
755
885
  });
756
- return _context5.abrupt("return");
886
+ return _context7.abrupt("return");
757
887
  case 8:
758
888
  merchantCapabilities = paymentRequest.merchantCapabilities, merchantInfo = paymentRequest.merchantInfo, paymentAmount = paymentRequest.paymentAmount, supportedNetworks = paymentRequest.supportedNetworks, version = paymentRequest.version, requiredBillingContactFields = paymentRequest.requiredBillingContactFields, requiredShippingContactFields = paymentRequest.requiredShippingContactFields;
759
889
  finalAmount = (paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.formattedValue) || (paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value);
@@ -796,35 +926,35 @@ export var ModernElementController = /*#__PURE__*/function () {
796
926
  enableModalCloseListener: true,
797
927
  callbacks: {
798
928
  validateMerchant: function () {
799
- var _validateMerchant = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(validationURL) {
929
+ var _validateMerchant = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(validationURL) {
800
930
  var res;
801
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
802
- while (1) switch (_context3.prev = _context3.next) {
931
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
932
+ while (1) switch (_context5.prev = _context5.next) {
803
933
  case 0:
804
934
  trackElement('applepay_validate_start', {
805
935
  d1: 'merchant_validate'
806
936
  });
807
- _context3.next = 3;
937
+ _context5.next = 3;
808
938
  return getApplePayPaymentSession(sessionData, {
809
939
  validateUrl: validationURL,
810
940
  paymentSessionData: sessionData,
811
941
  merchantDomain: window.location.hostname
812
942
  }, {
813
- env: _this3.options.environment,
943
+ env: _this4.options.environment,
814
944
  envInfo: {
815
945
  deviceId: ''
816
946
  }
817
947
  }, logger);
818
948
  case 3:
819
- res = _context3.sent;
949
+ res = _context5.sent;
820
950
  if (!(res !== null && res !== void 0 && res.success && res.merchantSessionObject)) {
821
- _context3.next = 7;
951
+ _context5.next = 7;
822
952
  break;
823
953
  }
824
954
  trackElement('applepay_validate_success', {
825
955
  d1: 'got_session'
826
956
  });
827
- return _context3.abrupt("return", typeof res.merchantSessionObject === 'string' ? JSON.parse(res.merchantSessionObject) : res.merchantSessionObject);
957
+ return _context5.abrupt("return", typeof res.merchantSessionObject === 'string' ? JSON.parse(res.merchantSessionObject) : res.merchantSessionObject);
828
958
  case 7:
829
959
  trackError('applepay_merchant_validate_failed', {
830
960
  d1: 'VALIDATION_FAILED',
@@ -835,34 +965,34 @@ export var ModernElementController = /*#__PURE__*/function () {
835
965
  };
836
966
  case 9:
837
967
  case "end":
838
- return _context3.stop();
968
+ return _context5.stop();
839
969
  }
840
- }, _callee3);
970
+ }, _callee5);
841
971
  }));
842
- function validateMerchant(_x6) {
972
+ function validateMerchant(_x11) {
843
973
  return _validateMerchant.apply(this, arguments);
844
974
  }
845
975
  return validateMerchant;
846
976
  }(),
847
977
  onAuthorized: function () {
848
- var _onAuthorized = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref3) {
978
+ var _onAuthorized = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref4) {
849
979
  var token, billingContact, shippingContact, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue;
850
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
851
- while (1) switch (_context4.prev = _context4.next) {
980
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
981
+ while (1) switch (_context6.prev = _context6.next) {
852
982
  case 0:
853
- token = _ref3.token, billingContact = _ref3.billingContact, shippingContact = _ref3.shippingContact;
983
+ token = _ref4.token, billingContact = _ref4.billingContact, shippingContact = _ref4.shippingContact;
854
984
  if (!onBeforeConfirm) {
855
- _context4.next = 18;
985
+ _context6.next = 18;
856
986
  break;
857
987
  }
858
- _context4.prev = 2;
988
+ _context6.prev = 2;
859
989
  startTime = Date.now();
860
- _context4.next = 6;
990
+ _context6.next = 6;
861
991
  return executeWithTimeout(function () {
862
992
  return onBeforeConfirm();
863
993
  });
864
994
  case 6:
865
- _yield$executeWithTim = _context4.sent;
995
+ _yield$executeWithTim = _context6.sent;
866
996
  rawResult = _yield$executeWithTim.result;
867
997
  timedOut = _yield$executeWithTim.timedOut;
868
998
  // 双重校验:timedOut(Promise race)+ startTime(实际时间差),与老 ElementController 对齐
@@ -873,20 +1003,20 @@ export var ModernElementController = /*#__PURE__*/function () {
873
1003
  });
874
1004
  }
875
1005
  if (shouldContinue) {
876
- _context4.next = 13;
1006
+ _context6.next = 13;
877
1007
  break;
878
1008
  }
879
- return _context4.abrupt("return", {
1009
+ return _context6.abrupt("return", {
880
1010
  success: false,
881
1011
  errorCode: 'MERCHANT_CONFIRM_ABORT'
882
1012
  });
883
1013
  case 13:
884
- _context4.next = 18;
1014
+ _context6.next = 18;
885
1015
  break;
886
1016
  case 15:
887
- _context4.prev = 15;
888
- _context4.t0 = _context4["catch"](2);
889
- return _context4.abrupt("return", {
1017
+ _context6.prev = 15;
1018
+ _context6.t0 = _context6["catch"](2);
1019
+ return _context6.abrupt("return", {
890
1020
  success: false,
891
1021
  errorCode: 'MERCHANT_CONFIRM_ABORT'
892
1022
  });
@@ -899,25 +1029,25 @@ export var ModernElementController = /*#__PURE__*/function () {
899
1029
  trackElement('applepay_authorized', {
900
1030
  d1: token ? 'has_token' : 'no_token'
901
1031
  });
902
- return _context4.abrupt("return", {
1032
+ return _context6.abrupt("return", {
903
1033
  success: true,
904
1034
  result: capturedResult
905
1035
  });
906
1036
  case 21:
907
1037
  case "end":
908
- return _context4.stop();
1038
+ return _context6.stop();
909
1039
  }
910
- }, _callee4, null, [[2, 15]]);
1040
+ }, _callee6, null, [[2, 15]]);
911
1041
  }));
912
- function onAuthorized(_x7) {
1042
+ function onAuthorized(_x12) {
913
1043
  return _onAuthorized.apply(this, arguments);
914
1044
  }
915
1045
  return onAuthorized;
916
1046
  }()
917
1047
  }
918
1048
  });
919
- _context5.prev = 15;
920
- _context5.next = 18;
1049
+ _context7.prev = 15;
1050
+ _context7.next = 18;
921
1051
  return service.startPay();
922
1052
  case 18:
923
1053
  trackElement('applepay_token_success', {
@@ -927,14 +1057,14 @@ export var ModernElementController = /*#__PURE__*/function () {
927
1057
  success: true,
928
1058
  result: capturedResult
929
1059
  });
930
- _context5.next = 26;
1060
+ _context7.next = 26;
931
1061
  break;
932
1062
  case 22:
933
- _context5.prev = 22;
934
- _context5.t0 = _context5["catch"](15);
1063
+ _context7.prev = 22;
1064
+ _context7.t0 = _context7["catch"](15);
935
1065
  // 商户验证失败已在 validateMerchant 内单独埋点(applepay_merchant_validate_failed),此处跳过避免重复
936
- if ((_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.errorCode) !== 'APPLE_PAY_PAYMENT_SESSION_REQUEST_FAILED') {
937
- errCode = (_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.errorCode) || 'APPLE_PAY_NOT_SUPPORTED'; // 用户主动取消单独标记,便于区分取消与真实失败
1066
+ if ((_context7.t0 === null || _context7.t0 === void 0 ? void 0 : _context7.t0.errorCode) !== 'APPLE_PAY_PAYMENT_SESSION_REQUEST_FAILED') {
1067
+ errCode = (_context7.t0 === null || _context7.t0 === void 0 ? void 0 : _context7.t0.errorCode) || 'APPLE_PAY_NOT_SUPPORTED'; // 用户主动取消单独标记,便于区分取消与真实失败
938
1068
  if (errCode === 'APPLE_PAY_CANCEL') {
939
1069
  trackElement('applepay_cancel', {
940
1070
  d1: 'user_cancel'
@@ -942,23 +1072,23 @@ export var ModernElementController = /*#__PURE__*/function () {
942
1072
  } else {
943
1073
  trackError('applepay_token_failed', {
944
1074
  d1: errCode,
945
- d2: (_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.errorMessage) || ''
1075
+ d2: (_context7.t0 === null || _context7.t0 === void 0 ? void 0 : _context7.t0.errorMessage) || ''
946
1076
  });
947
1077
  }
948
1078
  }
949
1079
  this.bridge.send(AMSMessageType.GET_APPLE_PAY_TOKEN_REPLY, {
950
1080
  success: false,
951
1081
  result: {
952
- errorCode: (_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.errorCode) || 'APPLE_PAY_NOT_SUPPORTED'
1082
+ errorCode: (_context7.t0 === null || _context7.t0 === void 0 ? void 0 : _context7.t0.errorCode) || 'APPLE_PAY_NOT_SUPPORTED'
953
1083
  }
954
1084
  });
955
1085
  case 26:
956
1086
  case "end":
957
- return _context5.stop();
1087
+ return _context7.stop();
958
1088
  }
959
- }, _callee5, this, [[15, 22]]);
1089
+ }, _callee7, this, [[15, 22]]);
960
1090
  }));
961
- function handleGetApplePayToken(_x4, _x5) {
1091
+ function handleGetApplePayToken(_x9, _x10) {
962
1092
  return _handleGetApplePayToken.apply(this, arguments);
963
1093
  }
964
1094
  return handleGetApplePayToken;
@@ -983,7 +1113,7 @@ export var ModernElementController = /*#__PURE__*/function () {
983
1113
  key: "handleGetGooglePayToken",
984
1114
  value: function handleGetGooglePayToken(payload) {
985
1115
  var _data$paymentMethodDe,
986
- _this4 = this,
1116
+ _this5 = this,
987
1117
  _google;
988
1118
  var data = payload === null || payload === void 0 ? void 0 : payload.data;
989
1119
  var googlePayProps = data === null || data === void 0 || (_data$paymentMethodDe = data.paymentMethodDetail) === null || _data$paymentMethodDe === void 0 ? void 0 : _data$paymentMethodDe.googlePayProps;
@@ -1030,7 +1160,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1030
1160
  trackElement('googlepay_token_success', {
1031
1161
  d1: 'has_token'
1032
1162
  });
1033
- _this4.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1163
+ _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1034
1164
  success: true,
1035
1165
  result: paymentData
1036
1166
  });
@@ -1047,7 +1177,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1047
1177
  d2: (err === null || err === void 0 ? void 0 : err.statusMessage) || ''
1048
1178
  });
1049
1179
  }
1050
- _this4.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1180
+ _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1051
1181
  success: false,
1052
1182
  err: _objectSpread({
1053
1183
  statusCode: statusCode
@@ -1082,7 +1212,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1082
1212
  trackError('googlepay_script_load_failed', {
1083
1213
  d1: 'script_error'
1084
1214
  });
1085
- _this4.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1215
+ _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1086
1216
  success: false,
1087
1217
  err: {
1088
1218
  statusCode: 'GOOGLE_PAY_NOT_SUPPORTED'
@@ -1131,7 +1261,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1131
1261
  }, {
1132
1262
  key: "handleBeforeConfirmInternal",
1133
1263
  value: function handleBeforeConfirmInternal(onBeforeConfirm) {
1134
- var _this5 = this;
1264
+ var _this6 = this;
1135
1265
  if (!onBeforeConfirm) {
1136
1266
  logger.logInfo({
1137
1267
  title: 'sdk_before_confirm_skip'
@@ -1152,9 +1282,9 @@ export var ModernElementController = /*#__PURE__*/function () {
1152
1282
  var startTime = Date.now();
1153
1283
  executeWithTimeout(function () {
1154
1284
  return onBeforeConfirm();
1155
- }).then(function (_ref4) {
1156
- var rawResult = _ref4.result,
1157
- timedOut = _ref4.timedOut;
1285
+ }).then(function (_ref5) {
1286
+ var rawResult = _ref5.result,
1287
+ timedOut = _ref5.timedOut;
1158
1288
  // 双重校验:timedOut(Promise race)+ startTime(实际时间差),与老 ElementController 对齐
1159
1289
  var shouldContinue = !timedOut && !!rawResult && Date.now() - startTime < BEFORE_CONFIRM_TIMEOUT_MS;
1160
1290
  if (timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
@@ -1167,7 +1297,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1167
1297
  }, {
1168
1298
  shouldContinue: shouldContinue
1169
1299
  });
1170
- _this5.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1300
+ _this6.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1171
1301
  success: true,
1172
1302
  result: !!shouldContinue
1173
1303
  });
@@ -1178,7 +1308,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1178
1308
  errorMessage: String((error === null || error === void 0 ? void 0 : error.message) || error).slice(0, 200),
1179
1309
  path: 'modernController_bridge'
1180
1310
  });
1181
- _this5.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1311
+ _this6.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1182
1312
  success: false,
1183
1313
  result: false
1184
1314
  });
@@ -1192,7 +1322,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1192
1322
  }, {
1193
1323
  key: "waitForReadyHandshake",
1194
1324
  value: function waitForReadyHandshake() {
1195
- var _this6 = this;
1325
+ var _this7 = this;
1196
1326
  return new Promise(function (resolve, reject) {
1197
1327
  var cancelDestroyCallback = function cancelDestroyCallback() {};
1198
1328
  var timer = setTimeout(function () {
@@ -1205,15 +1335,15 @@ export var ModernElementController = /*#__PURE__*/function () {
1205
1335
  message: 'An error occurred; the transaction cannot be initiated.'
1206
1336
  });
1207
1337
  }, MOUNT_TIMEOUT);
1208
- cancelDestroyCallback = _this6.onDestroy(function () {
1338
+ cancelDestroyCallback = _this7.onDestroy(function () {
1209
1339
  clearTimeout(timer);
1210
1340
  reject(getDestroyedError());
1211
1341
  });
1212
- _this6.bridge.once(MessageType.READY_HANDSHAKE, function () {
1213
- var _this6$iframe;
1342
+ _this7.bridge.once(MessageType.READY_HANDSHAKE, function () {
1343
+ var _this7$iframe;
1214
1344
  clearTimeout(timer);
1215
1345
  cancelDestroyCallback();
1216
- if (!((_this6$iframe = _this6.iframe) !== null && _this6$iframe !== void 0 && _this6$iframe.contentWindow)) {
1346
+ if (!((_this7$iframe = _this7.iframe) !== null && _this7$iframe !== void 0 && _this7$iframe.contentWindow)) {
1217
1347
  trackError('iframe_contentwindow_unavailable', {
1218
1348
  d1: 'after_ready_handshake'
1219
1349
  });
@@ -1223,9 +1353,9 @@ export var ModernElementController = /*#__PURE__*/function () {
1223
1353
  });
1224
1354
  return;
1225
1355
  }
1226
- _this6.bridge.setTarget(_this6.iframe.contentWindow);
1356
+ _this7.bridge.setTarget(_this7.iframe.contentWindow);
1227
1357
  trackHandshake('ready_handshake_received', {
1228
- m1: _this6._mountStartTime ? Date.now() - _this6._mountStartTime : 0
1358
+ m1: _this7._mountStartTime ? Date.now() - _this7._mountStartTime : 0
1229
1359
  });
1230
1360
  resolve();
1231
1361
  });
@@ -1250,7 +1380,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1250
1380
  }, {
1251
1381
  key: "waitForHandshakeAck",
1252
1382
  value: function waitForHandshakeAck() {
1253
- var _this7 = this;
1383
+ var _this8 = this;
1254
1384
  return new Promise(function (resolve, reject) {
1255
1385
  var cancelDestroyCallback = function cancelDestroyCallback() {};
1256
1386
  var timer = setTimeout(function () {
@@ -1263,15 +1393,15 @@ export var ModernElementController = /*#__PURE__*/function () {
1263
1393
  message: 'An error occurred; the transaction cannot be initiated.'
1264
1394
  });
1265
1395
  }, MOUNT_TIMEOUT);
1266
- cancelDestroyCallback = _this7.onDestroy(function () {
1396
+ cancelDestroyCallback = _this8.onDestroy(function () {
1267
1397
  clearTimeout(timer);
1268
1398
  reject(getDestroyedError());
1269
1399
  });
1270
- _this7.bridge.once(MessageType.HANDSHAKE_ACK, function () {
1400
+ _this8.bridge.once(MessageType.HANDSHAKE_ACK, function () {
1271
1401
  clearTimeout(timer);
1272
1402
  cancelDestroyCallback();
1273
1403
  trackHandshake('handshake_ack_received', {
1274
- m1: _this7._mountStartTime ? Date.now() - _this7._mountStartTime : 0
1404
+ m1: _this8._mountStartTime ? Date.now() - _this8._mountStartTime : 0
1275
1405
  });
1276
1406
  resolve();
1277
1407
  });
@@ -1280,20 +1410,46 @@ export var ModernElementController = /*#__PURE__*/function () {
1280
1410
  }, {
1281
1411
  key: "submitPayment",
1282
1412
  value: function () {
1283
- var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
1284
- var _this8 = this;
1285
- var _this$options$loading7, _this$options$loading8, isApplePay, _ref5, onBeforeConfirm, serializableParams, startTime, _yield$executeWithTim2, shouldContinue, timedOut, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, cleanups, _result$error, resultPromise, result, _this$options$loading9, _this$options$loading10;
1286
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1287
- while (1) switch (_context6.prev = _context6.next) {
1413
+ var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
1414
+ var _this9 = this;
1415
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1416
+ while (1) switch (_context8.prev = _context8.next) {
1417
+ case 0:
1418
+ return _context8.abrupt("return", runApi('submitPayment', function () {
1419
+ return _this9.doSubmitPayment(params);
1420
+ }, function () {
1421
+ return _this9.currentPaymentMethodType ? {
1422
+ d4: _this9.currentPaymentMethodType
1423
+ } : {};
1424
+ }));
1425
+ case 1:
1426
+ case "end":
1427
+ return _context8.stop();
1428
+ }
1429
+ }, _callee8);
1430
+ }));
1431
+ function submitPayment(_x13) {
1432
+ return _submitPayment.apply(this, arguments);
1433
+ }
1434
+ return submitPayment;
1435
+ }()
1436
+ }, {
1437
+ key: "doSubmitPayment",
1438
+ value: function () {
1439
+ var _doSubmitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
1440
+ var _this10 = this;
1441
+ var _this$options$loading7, _this$options$loading8, isApplePay, _ref6, onBeforeConfirm, serializableParams, startTime, _yield$executeWithTim2, shouldContinue, timedOut, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, cleanups, _result$error5, resultPromise, result, _this$options$loading9, _this$options$loading10;
1442
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1443
+ while (1) switch (_context9.prev = _context9.next) {
1288
1444
  case 0:
1289
1445
  if (!(this.status !== 'ready')) {
1290
- _context6.next = 3;
1446
+ _context9.next = 3;
1291
1447
  break;
1292
1448
  }
1293
1449
  trackError('submit_not_ready', {
1294
1450
  d1: this.status
1295
1451
  });
1296
- return _context6.abrupt("return", {
1452
+ return _context9.abrupt("return", {
1297
1453
  status: 'FAIL',
1298
1454
  error: {
1299
1455
  code: 'UI_STATE_ERROR',
@@ -1302,11 +1458,11 @@ export var ModernElementController = /*#__PURE__*/function () {
1302
1458
  });
1303
1459
  case 3:
1304
1460
  if (!this.isSubmitting) {
1305
- _context6.next = 6;
1461
+ _context9.next = 6;
1306
1462
  break;
1307
1463
  }
1308
1464
  trackError('submit_in_progress', {});
1309
- return _context6.abrupt("return", {
1465
+ return _context9.abrupt("return", {
1310
1466
  status: 'FAIL',
1311
1467
  error: {
1312
1468
  code: 'UI_STATE_ERROR',
@@ -1315,11 +1471,11 @@ export var ModernElementController = /*#__PURE__*/function () {
1315
1471
  });
1316
1472
  case 6:
1317
1473
  this.isSubmitting = true;
1318
- _context6.prev = 7;
1474
+ _context9.prev = 7;
1319
1475
  isApplePay = this.currentPaymentMethodType === 'APPLEPAY'; // 剥除 onBeforeConfirm 函数,避免 postMessage 序列化报错
1320
- _ref5 = params || {}, onBeforeConfirm = _ref5.onBeforeConfirm, serializableParams = _objectWithoutProperties(_ref5, _excluded2); // ── 非 Apple Pay:同步执行 onBeforeConfirm(submit 前拦截,对齐老 ElementController) ──
1476
+ _ref6 = params || {}, onBeforeConfirm = _ref6.onBeforeConfirm, serializableParams = _objectWithoutProperties(_ref6, _excluded2); // ── 非 Apple Pay:同步执行 onBeforeConfirm(submit 前拦截,对齐老 ElementController) ──
1321
1477
  if (!(onBeforeConfirm && !isApplePay)) {
1322
- _context6.next = 31;
1478
+ _context9.next = 31;
1323
1479
  break;
1324
1480
  }
1325
1481
  logger.logInfo({
@@ -1328,18 +1484,18 @@ export var ModernElementController = /*#__PURE__*/function () {
1328
1484
  paymentMethodType: this.currentPaymentMethodType || 'UNKNOWN',
1329
1485
  path: 'nonApplePay_sync'
1330
1486
  });
1331
- _context6.prev = 12;
1487
+ _context9.prev = 12;
1332
1488
  startTime = Date.now();
1333
- _context6.next = 16;
1489
+ _context9.next = 16;
1334
1490
  return executeWithTimeout(function () {
1335
1491
  return onBeforeConfirm();
1336
1492
  });
1337
1493
  case 16:
1338
- _yield$executeWithTim2 = _context6.sent;
1494
+ _yield$executeWithTim2 = _context9.sent;
1339
1495
  shouldContinue = _yield$executeWithTim2.result;
1340
1496
  timedOut = _yield$executeWithTim2.timedOut;
1341
1497
  if (!(timedOut || !shouldContinue || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS)) {
1342
- _context6.next = 22;
1498
+ _context9.next = 22;
1343
1499
  break;
1344
1500
  }
1345
1501
  if (timedOut) {
@@ -1357,7 +1513,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1357
1513
  path: 'nonApplePay_sync'
1358
1514
  });
1359
1515
  }
1360
- return _context6.abrupt("return", {
1516
+ return _context9.abrupt("return", {
1361
1517
  status: 'FAIL',
1362
1518
  error: {
1363
1519
  code: 'MERCHANT_CONFIRM_ABORT',
@@ -1371,19 +1527,19 @@ export var ModernElementController = /*#__PURE__*/function () {
1371
1527
  paymentMethodType: this.currentPaymentMethodType || 'UNKNOWN',
1372
1528
  path: 'nonApplePay_sync'
1373
1529
  });
1374
- _context6.next = 29;
1530
+ _context9.next = 29;
1375
1531
  break;
1376
1532
  case 25:
1377
- _context6.prev = 25;
1378
- _context6.t0 = _context6["catch"](12);
1533
+ _context9.prev = 25;
1534
+ _context9.t0 = _context9["catch"](12);
1379
1535
  logger.logError({
1380
1536
  title: 'sdk_before_confirm_error'
1381
1537
  }, {
1382
1538
  paymentMethodType: this.currentPaymentMethodType || 'UNKNOWN',
1383
- errorMessage: String((_context6.t0 === null || _context6.t0 === void 0 ? void 0 : _context6.t0.message) || _context6.t0).slice(0, 200),
1539
+ errorMessage: String((_context9.t0 === null || _context9.t0 === void 0 ? void 0 : _context9.t0.message) || _context9.t0).slice(0, 200),
1384
1540
  path: 'nonApplePay_sync'
1385
1541
  });
1386
- return _context6.abrupt("return", {
1542
+ return _context9.abrupt("return", {
1387
1543
  status: 'FAIL',
1388
1544
  error: {
1389
1545
  code: 'MERCHANT_CONFIRM_ABORT',
@@ -1391,7 +1547,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1391
1547
  }
1392
1548
  });
1393
1549
  case 29:
1394
- _context6.next = 32;
1550
+ _context9.next = 32;
1395
1551
  break;
1396
1552
  case 31:
1397
1553
  if (!onBeforeConfirm) {
@@ -1426,24 +1582,24 @@ export var ModernElementController = /*#__PURE__*/function () {
1426
1582
  // 未命中的 once wrapper 绑着旧闭包(旧 onBeforeConfirm / 旧 resolve)会残留并串扰后续提交,
1427
1583
  // 在 submit 终态统一释放(二次 off 幂等,已命中的 once 已自行 off)。
1428
1584
  cleanups = [];
1429
- _context6.prev = 41;
1585
+ _context9.prev = 41;
1430
1586
  resultPromise = new Promise(function (resolve) {
1431
1587
  // 先注册事件监听,再发送 SUBMIT,避免 webapp 快速响应导致消息丢失
1432
1588
  // PC 非 Safari:webapp 委托 SDK 拉起 Apple Pay 拿 token
1433
- cleanups.push(_this8.bridge.once(AMSMessageType.GET_APPLE_PAY_TOKEN, function (payload) {
1434
- _this8.handleGetApplePayToken(payload, onBeforeConfirm).then(function () {
1589
+ cleanups.push(_this10.bridge.once(AMSMessageType.GET_APPLE_PAY_TOKEN, function (payload) {
1590
+ _this10.handleGetApplePayToken(payload, onBeforeConfirm).then(function () {
1435
1591
  // token 已回传 webapp,继续等 SUBMIT_REPLY
1436
1592
  });
1437
1593
  }));
1438
1594
  // Web element GP:webapp 委托 SDK/父 frame 调 loadPaymentData 拿 token
1439
- cleanups.push(_this8.bridge.once(AMSMessageType.GET_GOOGLE_PAY_TOKEN, function (payload) {
1440
- _this8.handleGetGooglePayToken(payload);
1595
+ cleanups.push(_this10.bridge.once(AMSMessageType.GET_GOOGLE_PAY_TOKEN, function (payload) {
1596
+ _this10.handleGetGooglePayToken(payload);
1441
1597
  }));
1442
1598
  // Safari:webapp 请求执行商户 onBeforeConfirm 回调
1443
- cleanups.push(_this8.bridge.once(AMSMessageType.BEFORE_CONFIRM, function () {
1444
- _this8.handleBeforeConfirmInternal(onBeforeConfirm || null);
1599
+ cleanups.push(_this10.bridge.once(AMSMessageType.BEFORE_CONFIRM, function () {
1600
+ _this10.handleBeforeConfirmInternal(onBeforeConfirm || null);
1445
1601
  }));
1446
- cleanups.push(_this8.bridge.once(MessageType.SUBMIT_REPLY, resolve));
1602
+ cleanups.push(_this10.bridge.once(MessageType.SUBMIT_REPLY, resolve));
1447
1603
  }); // 监听注册完成后再发送 SUBMIT,确保不会遗漏快速响应
1448
1604
  this.send(MessageType.SUBMIT, _objectSpread(_objectSpread({}, serializableParams), {}, {
1449
1605
  redirect: this.notRedirectAfterComplete ? 'if_required' : 'always',
@@ -1452,70 +1608,92 @@ export var ModernElementController = /*#__PURE__*/function () {
1452
1608
  amount: serializableParams.amount,
1453
1609
  currency: serializableParams.currency
1454
1610
  } : {}));
1455
- _context6.next = 46;
1611
+ _context9.next = 46;
1456
1612
  return resultPromise;
1457
1613
  case 46:
1458
- result = _context6.sent;
1614
+ result = _context9.sent;
1459
1615
  trackElement('submit_reply', {
1460
1616
  d1: (result === null || result === void 0 ? void 0 : result.status) || '',
1461
- d2: (result === null || result === void 0 || (_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.code) || ''
1617
+ d2: (result === null || result === void 0 || (_result$error5 = result.error) === null || _result$error5 === void 0 ? void 0 : _result$error5.code) || ''
1462
1618
  });
1463
- return _context6.abrupt("return", adaptSubmitResult(result));
1619
+ return _context9.abrupt("return", adaptSubmitResult(result));
1464
1620
  case 51:
1465
- _context6.prev = 51;
1466
- _context6.t1 = _context6["catch"](41);
1621
+ _context9.prev = 51;
1622
+ _context9.t1 = _context9["catch"](41);
1467
1623
  trackError('submit_error', {
1468
- d1: (_context6.t1 === null || _context6.t1 === void 0 ? void 0 : _context6.t1.code) || 'UNKNOWN',
1469
- d2: (_context6.t1 === null || _context6.t1 === void 0 ? void 0 : _context6.t1.message) || ''
1624
+ d1: (_context9.t1 === null || _context9.t1 === void 0 ? void 0 : _context9.t1.code) || 'UNKNOWN',
1625
+ d2: (_context9.t1 === null || _context9.t1 === void 0 ? void 0 : _context9.t1.message) || ''
1470
1626
  });
1471
- throw _context6.t1;
1627
+ throw _context9.t1;
1472
1628
  case 55:
1473
- _context6.prev = 55;
1629
+ _context9.prev = 55;
1474
1630
  cleanups.forEach(function (fn) {
1475
1631
  try {
1476
1632
  fn();
1477
- } catch (_unused4) {
1633
+ } catch (_unused6) {
1478
1634
  /* ignore cleanup error */
1479
1635
  }
1480
1636
  });
1481
1637
  (_this$options$loading9 = this.options.loading) === null || _this$options$loading9 === void 0 || (_this$options$loading10 = _this$options$loading9.onEndLoading) === null || _this$options$loading10 === void 0 || _this$options$loading10.call(_this$options$loading9);
1482
- return _context6.finish(55);
1638
+ return _context9.finish(55);
1483
1639
  case 59:
1484
- _context6.prev = 59;
1640
+ _context9.prev = 59;
1485
1641
  this.isSubmitting = false;
1486
- return _context6.finish(59);
1642
+ return _context9.finish(59);
1487
1643
  case 62:
1488
1644
  case "end":
1489
- return _context6.stop();
1645
+ return _context9.stop();
1490
1646
  }
1491
- }, _callee6, this, [[7,, 59, 62], [12, 25], [41, 51, 55, 59]]);
1647
+ }, _callee9, this, [[7,, 59, 62], [12, 25], [41, 51, 55, 59]]);
1492
1648
  }));
1493
- function submitPayment(_x8) {
1494
- return _submitPayment.apply(this, arguments);
1649
+ function doSubmitPayment(_x14) {
1650
+ return _doSubmitPayment.apply(this, arguments);
1495
1651
  }
1496
- return submitPayment;
1652
+ return doSubmitPayment;
1497
1653
  }()
1498
1654
  }, {
1499
1655
  key: "validateFields",
1500
1656
  value: function () {
1501
- var _validateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1502
- var _this9 = this;
1503
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1504
- while (1) switch (_context7.prev = _context7.next) {
1657
+ var _validateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1658
+ var _this11 = this;
1659
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1660
+ while (1) switch (_context10.prev = _context10.next) {
1661
+ case 0:
1662
+ return _context10.abrupt("return", runApi('validateFields', function () {
1663
+ return _this11.doValidateFields();
1664
+ }));
1665
+ case 1:
1666
+ case "end":
1667
+ return _context10.stop();
1668
+ }
1669
+ }, _callee10);
1670
+ }));
1671
+ function validateFields() {
1672
+ return _validateFields.apply(this, arguments);
1673
+ }
1674
+ return validateFields;
1675
+ }()
1676
+ }, {
1677
+ key: "doValidateFields",
1678
+ value: function () {
1679
+ var _doValidateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1680
+ var _this12 = this;
1681
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1682
+ while (1) switch (_context11.prev = _context11.next) {
1505
1683
  case 0:
1506
1684
  if (!(this.status !== 'ready')) {
1507
- _context7.next = 3;
1685
+ _context11.next = 3;
1508
1686
  break;
1509
1687
  }
1510
1688
  trackError('validate_not_ready', {
1511
1689
  d1: this.status
1512
1690
  });
1513
- return _context7.abrupt("return", {
1691
+ return _context11.abrupt("return", {
1514
1692
  isValid: false
1515
1693
  });
1516
1694
  case 3:
1517
1695
  this.send(AMSMessageType.VALIDATE);
1518
- return _context7.abrupt("return", new Promise(function (resolve) {
1696
+ return _context11.abrupt("return", new Promise(function (resolve) {
1519
1697
  var timer = setTimeout(function () {
1520
1698
  trackError('validate_fields_timeout', {
1521
1699
  d1: '15000'
@@ -1524,7 +1702,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1524
1702
  isValid: false
1525
1703
  });
1526
1704
  }, 15000);
1527
- _this9.bridge.once(AMSMessageType.VALIDATE_REPLY, function (payload) {
1705
+ _this12.bridge.once(AMSMessageType.VALIDATE_REPLY, function (payload) {
1528
1706
  clearTimeout(timer);
1529
1707
  var isValid = !!(payload !== null && payload !== void 0 && payload.isValid);
1530
1708
  trackElement('validate_result', {
@@ -1537,30 +1715,30 @@ export var ModernElementController = /*#__PURE__*/function () {
1537
1715
  }));
1538
1716
  case 5:
1539
1717
  case "end":
1540
- return _context7.stop();
1718
+ return _context11.stop();
1541
1719
  }
1542
- }, _callee7, this);
1720
+ }, _callee11, this);
1543
1721
  }));
1544
- function validateFields() {
1545
- return _validateFields.apply(this, arguments);
1722
+ function doValidateFields() {
1723
+ return _doValidateFields.apply(this, arguments);
1546
1724
  }
1547
- return validateFields;
1725
+ return doValidateFields;
1548
1726
  }() // eslint-disable-next-line @typescript-eslint/no-unused-vars
1549
1727
  }, {
1550
1728
  key: "updatePayment",
1551
1729
  value: function () {
1552
- var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(paymentSessionData) {
1553
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1554
- while (1) switch (_context8.prev = _context8.next) {
1730
+ var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(paymentSessionData) {
1731
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1732
+ while (1) switch (_context12.prev = _context12.next) {
1555
1733
  case 0:
1556
- return _context8.abrupt("return", false);
1734
+ return _context12.abrupt("return", false);
1557
1735
  case 1:
1558
1736
  case "end":
1559
- return _context8.stop();
1737
+ return _context12.stop();
1560
1738
  }
1561
- }, _callee8);
1739
+ }, _callee12);
1562
1740
  }));
1563
- function updatePayment(_x9) {
1741
+ function updatePayment(_x15) {
1564
1742
  return _updatePayment.apply(this, arguments);
1565
1743
  }
1566
1744
  return updatePayment;
@@ -1610,7 +1788,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1610
1788
  }, {
1611
1789
  key: "onDestroy",
1612
1790
  value: function onDestroy(callback) {
1613
- var _this10 = this;
1791
+ var _this13 = this;
1614
1792
  if (this.status === 'destroyed') {
1615
1793
  callback();
1616
1794
  return function () {
@@ -1619,7 +1797,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1619
1797
  }
1620
1798
  this.destroyCallbacks.push(callback);
1621
1799
  return function () {
1622
- _this10.destroyCallbacks = _this10.destroyCallbacks.filter(function (item) {
1800
+ _this13.destroyCallbacks = _this13.destroyCallbacks.filter(function (item) {
1623
1801
  return item !== callback;
1624
1802
  });
1625
1803
  };
@@ -1659,12 +1837,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1659
1837
  }, {
1660
1838
  key: "flushCachedMessages",
1661
1839
  value: function flushCachedMessages() {
1662
- var _this11 = this;
1840
+ var _this14 = this;
1663
1841
  if (this.cachedSend.length > 0) {
1664
- this.cachedSend.forEach(function (_ref6) {
1665
- var type = _ref6.type,
1666
- payload = _ref6.payload;
1667
- _this11.bridge.send(type, payload);
1842
+ this.cachedSend.forEach(function (_ref7) {
1843
+ var type = _ref7.type,
1844
+ payload = _ref7.payload;
1845
+ _this14.bridge.send(type, payload);
1668
1846
  });
1669
1847
  this.cachedSend = [];
1670
1848
  }
@@ -1687,7 +1865,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1687
1865
  var _payload$appearance,
1688
1866
  _themeColorMap$appear,
1689
1867
  _payload$appearance2,
1690
- _this12 = this;
1868
+ _this15 = this;
1691
1869
  // 清理已存在的 modal
1692
1870
  this.handleCloseModal();
1693
1871
  var mode = device.isMobile ? 'mobile' : 'desktop';
@@ -1730,17 +1908,18 @@ export var ModernElementController = /*#__PURE__*/function () {
1730
1908
  var _openModal = openModal(_objectSpread(_objectSpread({}, payload), {}, {
1731
1909
  mode: mode,
1732
1910
  loadingConfig: loadingConfig,
1733
- onClose: payload.closeConfirm ? function () {
1734
- return new Promise(function (resolve) {
1735
- // closeConfirm 时等待确认关闭(由 CLOSE_MODAL 消息触发 resolve)
1736
- _this12._closeConfirmResolve = resolve;
1737
- });
1738
- } : undefined
1911
+ onClose: function onClose() {
1912
+ if (payload.closeConfirm) {
1913
+ // 这里提前关闭了
1914
+ var modalPort = new ModalPort(payload.modalId, messageChannel.port2);
1915
+ return modalPort.close(true);
1916
+ }
1917
+ }
1739
1918
  })),
1740
1919
  iframe = _openModal.iframe,
1741
1920
  destroy = _openModal.destroy;
1742
- var handler = function handler() {
1743
- iframe.removeEventListener('load', handler);
1921
+ var offReady = modalBridge.once(MessageType.MODAL_TRANSFER_READY, function (_payload, _ports, meta) {
1922
+ if (meta && meta.source !== iframe.contentWindow) return;
1744
1923
  trackElement('modal_loaded', {
1745
1924
  d1: payload.url
1746
1925
  });
@@ -1752,7 +1931,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1752
1931
  if (iframeOrigin && iframeOrigin !== 'null') {
1753
1932
  modalBridge.setOrigin(iframeOrigin);
1754
1933
  }
1755
- } catch (_unused5) {
1934
+ } catch (_unused7) {
1756
1935
  // URL 解析失败时保持默认 origin
1757
1936
  }
1758
1937
  // 如果 payload 有 appearance,通过 TRANSFER_MODAL_APPEARANCE 消息发送给 modal
@@ -1766,16 +1945,18 @@ export var ModernElementController = /*#__PURE__*/function () {
1766
1945
  // 发送 port2 给 modal
1767
1946
  modalBridge.send(MessageType.TRANSFER_MODAL_PORT, payload.modalId, [messageChannel.port2]);
1768
1947
  }
1769
- };
1948
+ });
1770
1949
  this.modalIframe = iframe;
1771
1950
  this.modalDestroy = function () {
1951
+ if (payload.closeConfirm) {
1952
+ trackElement('modal_close_confirm', {
1953
+ d1: 'confirm_resolved'
1954
+ });
1955
+ }
1772
1956
  destroy();
1773
- iframe.removeEventListener('load', handler);
1774
- _this12.modalIframe = null;
1957
+ offReady();
1958
+ _this15.modalIframe = null;
1775
1959
  };
1776
-
1777
- // 监听 modal 的 iframe load 事件
1778
- iframe.addEventListener('load', handler);
1779
1960
  }
1780
1961
 
1781
1962
  /**
@@ -1785,13 +1966,6 @@ export var ModernElementController = /*#__PURE__*/function () {
1785
1966
  key: "handleCloseModal",
1786
1967
  value: function handleCloseModal() {
1787
1968
  // 如果有等待中的 closeConfirm,resolve 它
1788
- if (this._closeConfirmResolve) {
1789
- trackElement('modal_close_confirm', {
1790
- d1: 'confirm_resolved'
1791
- });
1792
- this._closeConfirmResolve();
1793
- this._closeConfirmResolve = null;
1794
- }
1795
1969
  trackElement('modal_closed', {
1796
1970
  d1: this.modalBridge ? 'with_bridge' : 'no_bridge'
1797
1971
  });