@plattar/plattar-ar-adapter 1.154.2 → 1.155.1

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.
@@ -16,6 +16,14 @@ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _c
16
16
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
17
17
  function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
18
18
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
19
+ 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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
20
+ 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); } }
21
+ 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); }); }; }
22
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
24
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
25
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
26
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
27
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
20
28
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
29
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -23,11 +31,6 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
23
31
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
32
  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; } }
25
33
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
30
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
31
34
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
32
35
  (function (f) {
33
36
  if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
@@ -78,6 +81,261 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
78
81
  1: [function (require, module, exports) {
79
82
  "use strict";
80
83
 
84
+ var __importDefault = this && this.__importDefault || function (mod) {
85
+ return mod && mod.__esModule ? mod : {
86
+ "default": mod
87
+ };
88
+ };
89
+ Object.defineProperty(exports, "__esModule", {
90
+ value: true
91
+ });
92
+ exports.ConfiguratorAR = void 0;
93
+ var plattar_analytics_1 = require("@plattar/plattar-analytics");
94
+ var plattar_api_1 = require("@plattar/plattar-api");
95
+ var plattar_services_1 = require("@plattar/plattar-services");
96
+ var util_1 = require("../util/util");
97
+ var quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
98
+ var reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
99
+ var scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
100
+ var launcher_ar_1 = require("./launcher-ar");
101
+ var version_1 = __importDefault(require("../version"));
102
+ /**
103
+ * Performs AR functionality related to Plattar Scenes
104
+ */
105
+ var ConfiguratorAR = /*#__PURE__*/function (_launcher_ar_1$Launch) {
106
+ _inherits(ConfiguratorAR, _launcher_ar_1$Launch);
107
+ var _super = _createSuper(ConfiguratorAR);
108
+ function ConfiguratorAR(state) {
109
+ var _this;
110
+ _classCallCheck(this, ConfiguratorAR);
111
+ _this = _super.call(this);
112
+ // analytics instance
113
+ _this._analytics = null;
114
+ if (!state) {
115
+ throw new Error("ConfiguratorAR.constructor(state) - state must be defined");
116
+ }
117
+ _this._state = state;
118
+ _this._ar = null;
119
+ return _this;
120
+ }
121
+ _createClass(ConfiguratorAR, [{
122
+ key: "_SetupAnalytics",
123
+ value: function _SetupAnalytics() {
124
+ var scene = this._state.scene;
125
+ var analytics = null;
126
+ // setup scene stuff (if any)
127
+ if (scene) {
128
+ analytics = new plattar_analytics_1.Analytics(scene.attributes.application_id);
129
+ analytics.origin = plattar_api_1.Server.location().type;
130
+ this._analytics = analytics;
131
+ analytics.data.push("type", "scene-ar");
132
+ analytics.data.push("sdkVersion", version_1["default"]);
133
+ analytics.data.push("sceneId", scene.id);
134
+ analytics.data.push("sceneTitle", scene.attributes.title);
135
+ var application = scene.relationships.find(plattar_api_1.Project);
136
+ // setup application stuff (if any)
137
+ if (application) {
138
+ analytics.data.push("applicationId", application.id);
139
+ analytics.data.push("applicationTitle", application.attributes.title);
140
+ }
141
+ }
142
+ }
143
+ /**
144
+ * Composes a Scene into an AR Model (remote operation) that can be used to launch
145
+ * an AR File
146
+ */
147
+ }, {
148
+ key: "_Compose",
149
+ value: function () {
150
+ var _Compose2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(output) {
151
+ var objects, configurator, totalARObjectCount, results;
152
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
153
+ while (1) switch (_context.prev = _context.next) {
154
+ case 0:
155
+ objects = this._state.state.array();
156
+ if (!(objects.length <= 0)) {
157
+ _context.next = 3;
158
+ break;
159
+ }
160
+ throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain AR components");
161
+ case 3:
162
+ // define our configurator
163
+ configurator = new plattar_services_1.Configurator();
164
+ configurator.server = plattar_api_1.Server.location().type;
165
+ configurator.output = output;
166
+ totalARObjectCount = 0;
167
+ objects.forEach(function (object) {
168
+ if (object.meta_data.augment) {
169
+ if (object.meta_data.type === "scenemodel") {
170
+ configurator.addModel(object.scene_product_id);
171
+ } else {
172
+ configurator.addSceneProduct(object.scene_product_id, object.product_variation_id);
173
+ }
174
+ totalARObjectCount++;
175
+ }
176
+ });
177
+ if (!(totalARObjectCount <= 0)) {
178
+ _context.next = 10;
179
+ break;
180
+ }
181
+ throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain any enabled AR components");
182
+ case 10:
183
+ _context.next = 12;
184
+ return configurator.get();
185
+ case 12:
186
+ results = _context.sent;
187
+ return _context.abrupt("return", results.filename);
188
+ case 14:
189
+ case "end":
190
+ return _context.stop();
191
+ }
192
+ }, _callee, this);
193
+ }));
194
+ function _Compose(_x) {
195
+ return _Compose2.apply(this, arguments);
196
+ }
197
+ return _Compose;
198
+ }()
199
+ /**
200
+ * Initialise the SceneAR instance. This returns a Promise that resolves
201
+ * successfully if initialisation is successful, otherwise it will fail.
202
+ *
203
+ * filure can occur for a number of reasons but it generally means that AR
204
+ * cannot be performed.
205
+ */
206
+ }, {
207
+ key: "init",
208
+ value: function () {
209
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
210
+ var scene, sceneOpt, modelUrl, _modelUrl, _modelUrl2, arviewer;
211
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
212
+ while (1) switch (_context2.prev = _context2.next) {
213
+ case 0:
214
+ if (util_1.Util.canAugment()) {
215
+ _context2.next = 2;
216
+ break;
217
+ }
218
+ throw new Error("ConfiguratorAR.init() - cannot proceed as AR not available in context");
219
+ case 2:
220
+ scene = this._state.scene;
221
+ this._SetupAnalytics();
222
+ sceneOpt = scene.attributes.custom_json || {}; // we need to define our AR module here
223
+ // we are in Safari/Quicklook mode here
224
+ if (!(util_1.Util.isSafari() || util_1.Util.isChromeOnIOS())) {
225
+ _context2.next = 25;
226
+ break;
227
+ }
228
+ if (!(sceneOpt.anchor === "face")) {
229
+ _context2.next = 17;
230
+ break;
231
+ }
232
+ if (!util_1.Util.canRealityViewer()) {
233
+ _context2.next = 16;
234
+ break;
235
+ }
236
+ _context2.next = 10;
237
+ return this._Compose("vto");
238
+ case 10:
239
+ modelUrl = _context2.sent;
240
+ this._ar = new reality_viewer_1["default"]();
241
+ this._ar.modelUrl = modelUrl;
242
+ return _context2.abrupt("return", this);
243
+ case 16:
244
+ throw new Error("ConfiguratorAR.init() - cannot proceed as VTO AR requires Reality Viewer support");
245
+ case 17:
246
+ if (!util_1.Util.canQuicklook()) {
247
+ _context2.next = 24;
248
+ break;
249
+ }
250
+ _context2.next = 20;
251
+ return this._Compose("usdz");
252
+ case 20:
253
+ _modelUrl = _context2.sent;
254
+ this._ar = new quicklook_viewer_1["default"]();
255
+ this._ar.modelUrl = _modelUrl;
256
+ return _context2.abrupt("return", this);
257
+ case 24:
258
+ throw new Error("ConfiguratorAR.init() - cannot proceed as IOS device does not support AR Mode");
259
+ case 25:
260
+ if (!util_1.Util.canSceneViewer()) {
261
+ _context2.next = 35;
262
+ break;
263
+ }
264
+ _context2.next = 28;
265
+ return this._Compose("glb");
266
+ case 28:
267
+ _modelUrl2 = _context2.sent;
268
+ arviewer = new scene_viewer_1["default"]();
269
+ arviewer.modelUrl = _modelUrl2;
270
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
271
+ if (sceneOpt.anchor === "vertical") {
272
+ arviewer.isVertical = true;
273
+ }
274
+ this._ar = arviewer;
275
+ return _context2.abrupt("return", this);
276
+ case 35:
277
+ throw new Error("ConfiguratorAR.init() - could not initialise AR correctly, check values");
278
+ case 36:
279
+ case "end":
280
+ return _context2.stop();
281
+ }
282
+ }, _callee2, this);
283
+ }));
284
+ function init() {
285
+ return _init.apply(this, arguments);
286
+ }
287
+ return init;
288
+ }()
289
+ }, {
290
+ key: "start",
291
+ value: function start() {
292
+ if (!this._ar) {
293
+ throw new Error("SceneAR.start() - cannot proceed as AR instance is null");
294
+ }
295
+ var analytics = this._analytics;
296
+ if (analytics) {
297
+ analytics.data.push("device", this._ar.device);
298
+ analytics.data.push("eventCategory", this._ar.nodeType);
299
+ analytics.data.push("eventAction", "Start Scene Augment");
300
+ analytics.write();
301
+ analytics.startRecordEngagement();
302
+ }
303
+ // this was initialised via the init() function
304
+ this._ar.start();
305
+ }
306
+ }, {
307
+ key: "canQuicklook",
308
+ value: function canQuicklook() {
309
+ return this._ar && this._ar.nodeType === "Quick Look" ? true : false;
310
+ }
311
+ }, {
312
+ key: "canRealityViewer",
313
+ value: function canRealityViewer() {
314
+ return this._ar && this._ar.nodeType === "Reality Viewer" ? true : false;
315
+ }
316
+ }, {
317
+ key: "canSceneViewer",
318
+ value: function canSceneViewer() {
319
+ return this._ar && this._ar.nodeType === "Scene Viewer" ? true : false;
320
+ }
321
+ }]);
322
+ return ConfiguratorAR;
323
+ }(launcher_ar_1.LauncherAR);
324
+ exports.ConfiguratorAR = ConfiguratorAR;
325
+ }, {
326
+ "../util/util": 15,
327
+ "../version": 16,
328
+ "../viewers/quicklook-viewer": 18,
329
+ "../viewers/reality-viewer": 19,
330
+ "../viewers/scene-viewer": 20,
331
+ "./launcher-ar": 2,
332
+ "@plattar/plattar-analytics": 40,
333
+ "@plattar/plattar-api": 44,
334
+ "@plattar/plattar-services": 115
335
+ }],
336
+ 2: [function (require, module, exports) {
337
+ "use strict";
338
+
81
339
  Object.defineProperty(exports, "__esModule", {
82
340
  value: true
83
341
  });
@@ -95,15 +353,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
95
353
  */
96
354
  _createClass(LauncherAR, [{
97
355
  key: "launch",
98
- value: function launch() {
99
- var _this = this;
100
- return new Promise(function (accept, reject) {
101
- _this.init().then(function (value) {
102
- value.start();
103
- return accept();
104
- })["catch"](reject);
105
- });
106
- }
356
+ value: function () {
357
+ var _launch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
358
+ var value;
359
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
360
+ while (1) switch (_context3.prev = _context3.next) {
361
+ case 0:
362
+ _context3.next = 2;
363
+ return this.init();
364
+ case 2:
365
+ value = _context3.sent;
366
+ return _context3.abrupt("return", value.start());
367
+ case 4:
368
+ case "end":
369
+ return _context3.stop();
370
+ }
371
+ }, _callee3, this);
372
+ }));
373
+ function launch() {
374
+ return _launch.apply(this, arguments);
375
+ }
376
+ return launch;
377
+ }()
107
378
  /**
108
379
  * AR Options used for launching AR
109
380
  */
@@ -117,7 +388,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
117
388
  }();
118
389
  exports.LauncherAR = LauncherAR;
119
390
  }, {}],
120
- 2: [function (require, module, exports) {
391
+ 3: [function (require, module, exports) {
121
392
  "use strict";
122
393
 
123
394
  var __importDefault = this && this.__importDefault || function (mod) {
@@ -136,17 +407,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
136
407
  var reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
137
408
  var scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
138
409
  var launcher_ar_1 = require("./launcher-ar");
410
+ var version_1 = __importDefault(require("../version"));
139
411
  /**
140
412
  * Performs AT Functionality using Plattar FileModel types
141
413
  */
142
- var ModelAR = /*#__PURE__*/function (_launcher_ar_1$Launch) {
143
- _inherits(ModelAR, _launcher_ar_1$Launch);
144
- var _super = _createSuper(ModelAR);
414
+ var ModelAR = /*#__PURE__*/function (_launcher_ar_1$Launch2) {
415
+ _inherits(ModelAR, _launcher_ar_1$Launch2);
416
+ var _super2 = _createSuper(ModelAR);
145
417
  function ModelAR() {
146
418
  var _this2;
147
419
  var modelID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
148
420
  _classCallCheck(this, ModelAR);
149
- _this2 = _super.call(this);
421
+ _this2 = _super2.call(this);
150
422
  // analytics instance
151
423
  _this2._analytics = null;
152
424
  if (!modelID) {
@@ -171,6 +443,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
171
443
  analytics = new plattar_analytics_1.Analytics(project.id);
172
444
  analytics.origin = plattar_api_1.Server.location().type;
173
445
  analytics.data.push("type", "model-ar");
446
+ analytics.data.push("sdkVersion", version_1["default"]);
174
447
  analytics.data.push("applicationId", project.id);
175
448
  analytics.data.push("applicationTitle", project.attributes.title);
176
449
  analytics.data.push("modelId", model.id);
@@ -271,14 +544,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
271
544
  exports.ModelAR = ModelAR;
272
545
  }, {
273
546
  "../util/util": 15,
547
+ "../version": 16,
274
548
  "../viewers/quicklook-viewer": 18,
275
549
  "../viewers/reality-viewer": 19,
276
550
  "../viewers/scene-viewer": 20,
277
- "./launcher-ar": 1,
551
+ "./launcher-ar": 2,
278
552
  "@plattar/plattar-analytics": 40,
279
553
  "@plattar/plattar-api": 44
280
554
  }],
281
- 3: [function (require, module, exports) {
555
+ 4: [function (require, module, exports) {
282
556
  "use strict";
283
557
 
284
558
  var __importDefault = this && this.__importDefault || function (mod) {
@@ -297,19 +571,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
297
571
  var reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
298
572
  var scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
299
573
  var launcher_ar_1 = require("./launcher-ar");
574
+ var version_1 = __importDefault(require("../version"));
300
575
  /**
301
576
  * Performs AR functionality related to Plattar Products and Variation types
302
577
  */
303
- var ProductAR = /*#__PURE__*/function (_launcher_ar_1$Launch2) {
304
- _inherits(ProductAR, _launcher_ar_1$Launch2);
305
- var _super2 = _createSuper(ProductAR);
578
+ var ProductAR = /*#__PURE__*/function (_launcher_ar_1$Launch3) {
579
+ _inherits(ProductAR, _launcher_ar_1$Launch3);
580
+ var _super3 = _createSuper(ProductAR);
306
581
  function ProductAR() {
307
582
  var _this4;
308
583
  var productID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
309
584
  var variationID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
310
585
  var variationSKU = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
311
586
  _classCallCheck(this, ProductAR);
312
- _this4 = _super2.call(this);
587
+ _this4 = _super3.call(this);
313
588
  // analytics instance
314
589
  _this4._analytics = null;
315
590
  if (!productID) {
@@ -347,6 +622,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
347
622
  analytics.origin = plattar_api_1.Server.location().type;
348
623
  this._analytics = analytics;
349
624
  analytics.data.push("type", "product-ar");
625
+ analytics.data.push("sdkVersion", version_1["default"]);
350
626
  analytics.data.push("sceneId", scene.id);
351
627
  analytics.data.push("sceneTitle", scene.attributes.title);
352
628
  var application = scene.relationships.find(plattar_api_1.Project);
@@ -504,14 +780,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
504
780
  exports.ProductAR = ProductAR;
505
781
  }, {
506
782
  "../util/util": 15,
783
+ "../version": 16,
507
784
  "../viewers/quicklook-viewer": 18,
508
785
  "../viewers/reality-viewer": 19,
509
786
  "../viewers/scene-viewer": 20,
510
- "./launcher-ar": 1,
787
+ "./launcher-ar": 2,
511
788
  "@plattar/plattar-analytics": 40,
512
789
  "@plattar/plattar-api": 44
513
790
  }],
514
- 4: [function (require, module, exports) {
791
+ 5: [function (require, module, exports) {
515
792
  "use strict";
516
793
 
517
794
  var __importDefault = this && this.__importDefault || function (mod) {
@@ -530,18 +807,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
530
807
  var reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
531
808
  var scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
532
809
  var launcher_ar_1 = require("./launcher-ar");
810
+ var version_1 = __importDefault(require("../version"));
533
811
  /**
534
812
  * Allows launching AR Experiences provided a single remote 3D Model file
535
813
  */
536
- var RawAR = /*#__PURE__*/function (_launcher_ar_1$Launch3) {
537
- _inherits(RawAR, _launcher_ar_1$Launch3);
538
- var _super3 = _createSuper(RawAR);
814
+ var RawAR = /*#__PURE__*/function (_launcher_ar_1$Launch4) {
815
+ _inherits(RawAR, _launcher_ar_1$Launch4);
816
+ var _super4 = _createSuper(RawAR);
539
817
  function RawAR() {
540
818
  var _this6;
541
819
  var modelLocation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
542
820
  var sceneID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
543
821
  _classCallCheck(this, RawAR);
544
- _this6 = _super3.call(this);
822
+ _this6 = _super4.call(this);
545
823
  // analytics instance
546
824
  _this6._analytics = null;
547
825
  if (!modelLocation) {
@@ -578,6 +856,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
578
856
  analytics.origin = plattar_api_1.Server.location().type;
579
857
  _this7._analytics = analytics;
580
858
  analytics.data.push("type", "scene-ar");
859
+ analytics.data.push("sdkVersion", version_1["default"]);
581
860
  analytics.data.push("sceneId", scene.id);
582
861
  analytics.data.push("sceneTitle", scene.attributes.title);
583
862
  var application = scene.relationships.find(plattar_api_1.Project);
@@ -686,14 +965,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
686
965
  exports.RawAR = RawAR;
687
966
  }, {
688
967
  "../util/util": 15,
968
+ "../version": 16,
689
969
  "../viewers/quicklook-viewer": 18,
690
970
  "../viewers/reality-viewer": 19,
691
971
  "../viewers/scene-viewer": 20,
692
- "./launcher-ar": 1,
972
+ "./launcher-ar": 2,
693
973
  "@plattar/plattar-analytics": 40,
694
974
  "@plattar/plattar-api": 44
695
975
  }],
696
- 5: [function (require, module, exports) {
976
+ 6: [function (require, module, exports) {
697
977
  "use strict";
698
978
 
699
979
  var __importDefault = this && this.__importDefault || function (mod) {
@@ -713,18 +993,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
713
993
  var reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
714
994
  var scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
715
995
  var launcher_ar_1 = require("./launcher-ar");
996
+ var version_1 = __importDefault(require("../version"));
716
997
  /**
717
998
  * Performs AR functionality related to Plattar Scenes
718
999
  */
719
- var SceneAR = /*#__PURE__*/function (_launcher_ar_1$Launch4) {
720
- _inherits(SceneAR, _launcher_ar_1$Launch4);
721
- var _super4 = _createSuper(SceneAR);
1000
+ var SceneAR = /*#__PURE__*/function (_launcher_ar_1$Launch5) {
1001
+ _inherits(SceneAR, _launcher_ar_1$Launch5);
1002
+ var _super5 = _createSuper(SceneAR);
722
1003
  function SceneAR() {
723
1004
  var _this9;
724
1005
  var sceneID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
725
1006
  var variationSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
726
1007
  _classCallCheck(this, SceneAR);
727
- _this9 = _super4.call(this);
1008
+ _this9 = _super5.call(this);
728
1009
  // analytics instance
729
1010
  _this9._analytics = null;
730
1011
  if (!sceneID) {
@@ -750,6 +1031,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
750
1031
  analytics.origin = plattar_api_1.Server.location().type;
751
1032
  this._analytics = analytics;
752
1033
  analytics.data.push("type", "scene-ar");
1034
+ analytics.data.push("sdkVersion", version_1["default"]);
753
1035
  analytics.data.push("sceneId", scene.id);
754
1036
  analytics.data.push("sceneTitle", scene.attributes.title);
755
1037
  var application = scene.relationships.find(plattar_api_1.Project);
@@ -924,15 +1206,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
924
1206
  exports.SceneAR = SceneAR;
925
1207
  }, {
926
1208
  "../util/util": 15,
1209
+ "../version": 16,
927
1210
  "../viewers/quicklook-viewer": 18,
928
1211
  "../viewers/reality-viewer": 19,
929
1212
  "../viewers/scene-viewer": 20,
930
- "./launcher-ar": 1,
1213
+ "./launcher-ar": 2,
931
1214
  "@plattar/plattar-analytics": 40,
932
1215
  "@plattar/plattar-api": 44,
933
1216
  "@plattar/plattar-services": 115
934
1217
  }],
935
- 6: [function (require, module, exports) {
1218
+ 7: [function (require, module, exports) {
936
1219
  "use strict";
937
1220
 
938
1221
  Object.defineProperty(exports, "__esModule", {
@@ -948,14 +1231,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
948
1231
  */
949
1232
  var SceneProductAR = /*#__PURE__*/function (_product_ar_1$Product) {
950
1233
  _inherits(SceneProductAR, _product_ar_1$Product);
951
- var _super5 = _createSuper(SceneProductAR);
1234
+ var _super6 = _createSuper(SceneProductAR);
952
1235
  function SceneProductAR() {
953
1236
  var _this12;
954
1237
  var sceneProductID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
955
1238
  var variationID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
956
1239
  var variationSKU = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
957
1240
  _classCallCheck(this, SceneProductAR);
958
- _this12 = _super5.call(this, sceneProductID, variationID, variationSKU);
1241
+ _this12 = _super6.call(this, sceneProductID, variationID, variationSKU);
959
1242
  // this is evaluated in the init() function
960
1243
  _this12._attachedProductID = null;
961
1244
  if (!sceneProductID) {
@@ -1003,10 +1286,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1003
1286
  exports.SceneProductAR = SceneProductAR;
1004
1287
  }, {
1005
1288
  "../util/util": 15,
1006
- "./product-ar": 3,
1289
+ "./product-ar": 4,
1007
1290
  "@plattar/plattar-api": 44
1008
1291
  }],
1009
- 7: [function (require, module, exports) {
1292
+ 8: [function (require, module, exports) {
1010
1293
  "use strict";
1011
1294
 
1012
1295
  Object.defineProperty(exports, "__esModule", {
@@ -1014,238 +1297,406 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1014
1297
  });
1015
1298
  exports.ConfiguratorController = void 0;
1016
1299
  var plattar_api_1 = require("@plattar/plattar-api");
1017
- var plattar_services_1 = require("@plattar/plattar-services");
1018
- var raw_ar_1 = require("../../ar/raw-ar");
1019
- var scene_ar_1 = require("../../ar/scene-ar");
1020
1300
  var scene_product_ar_1 = require("../../ar/scene-product-ar");
1021
- var configurator_state_1 = require("../../util/configurator-state");
1022
1301
  var util_1 = require("../../util/util");
1023
1302
  var plattar_controller_1 = require("./plattar-controller");
1303
+ var configurator_ar_1 = require("../../ar/configurator-ar");
1024
1304
  /**
1025
1305
  * Manages an instance of the <plattar-configurator> HTML Element
1026
1306
  */
1027
1307
  var ConfiguratorController = /*#__PURE__*/function (_plattar_controller_) {
1028
1308
  _inherits(ConfiguratorController, _plattar_controller_);
1029
- var _super6 = _createSuper(ConfiguratorController);
1030
- function ConfiguratorController(parent) {
1309
+ var _super7 = _createSuper(ConfiguratorController);
1310
+ function ConfiguratorController() {
1311
+ var _this14;
1031
1312
  _classCallCheck(this, ConfiguratorController);
1032
- return _super6.call(this, parent);
1313
+ _this14 = _super7.apply(this, arguments);
1314
+ _this14._cachedConfigState = null;
1315
+ return _this14;
1033
1316
  }
1034
1317
  _createClass(ConfiguratorController, [{
1318
+ key: "getConfiguratorState",
1319
+ value: function () {
1320
+ var _getConfiguratorState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1321
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1322
+ while (1) switch (_context4.prev = _context4.next) {
1323
+ case 0:
1324
+ if (!this._cachedConfigState) {
1325
+ _context4.next = 2;
1326
+ break;
1327
+ }
1328
+ return _context4.abrupt("return", this._cachedConfigState);
1329
+ case 2:
1330
+ this._cachedConfigState = this.createConfiguratorState();
1331
+ return _context4.abrupt("return", this._cachedConfigState);
1332
+ case 4:
1333
+ case "end":
1334
+ return _context4.stop();
1335
+ }
1336
+ }, _callee4, this);
1337
+ }));
1338
+ function getConfiguratorState() {
1339
+ return _getConfiguratorState.apply(this, arguments);
1340
+ }
1341
+ return getConfiguratorState;
1342
+ }()
1343
+ }, {
1035
1344
  key: "onAttributesUpdated",
1036
- value: function onAttributesUpdated() {
1037
- var state = this._state;
1038
- // re-render the QR Code when attributes have changed
1039
- if (state === plattar_controller_1.ControllerState.QRCode) {
1040
- this.startQRCode(this._prevQROpt);
1041
- return;
1345
+ value: function () {
1346
+ var _onAttributesUpdated = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(attributeName) {
1347
+ var state, viewer, variationIDs, variationIDsList, variationSKUs, variationSKUList, configState, _variationIDs, _variationIDsList, _configState, _variationSKUs, _variationSKUList;
1348
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1349
+ while (1) switch (_context5.prev = _context5.next) {
1350
+ case 0:
1351
+ state = this._state;
1352
+ if (!(state === plattar_controller_1.ControllerState.Renderer)) {
1353
+ _context5.next = 17;
1354
+ break;
1355
+ }
1356
+ viewer = this.element;
1357
+ if (!viewer) {
1358
+ _context5.next = 16;
1359
+ break;
1360
+ }
1361
+ if (!(attributeName === "variation-id")) {
1362
+ _context5.next = 10;
1363
+ break;
1364
+ }
1365
+ variationIDs = this.getAttribute("variation-id");
1366
+ variationIDsList = variationIDs ? variationIDs.split(",") : [];
1367
+ if (!(variationIDsList.length > 0)) {
1368
+ _context5.next = 10;
1369
+ break;
1370
+ }
1371
+ _context5.next = 10;
1372
+ return viewer.messenger.selectVariationID(variationIDsList);
1373
+ case 10:
1374
+ if (!(attributeName === "variation-sku")) {
1375
+ _context5.next = 16;
1376
+ break;
1377
+ }
1378
+ variationSKUs = this.getAttribute("variation-sku");
1379
+ variationSKUList = variationSKUs ? variationSKUs.split(",") : [];
1380
+ if (!(variationSKUList.length > 0)) {
1381
+ _context5.next = 16;
1382
+ break;
1383
+ }
1384
+ _context5.next = 16;
1385
+ return viewer.messenger.selectVariationSKU(variationSKUList);
1386
+ case 16:
1387
+ return _context5.abrupt("return");
1388
+ case 17:
1389
+ if (!(state === plattar_controller_1.ControllerState.QRCode)) {
1390
+ _context5.next = 34;
1391
+ break;
1392
+ }
1393
+ if (!(attributeName === "variation-id")) {
1394
+ _context5.next = 25;
1395
+ break;
1396
+ }
1397
+ _context5.next = 21;
1398
+ return this.getConfiguratorState();
1399
+ case 21:
1400
+ configState = _context5.sent;
1401
+ _variationIDs = this.getAttribute("variation-id");
1402
+ _variationIDsList = _variationIDs ? _variationIDs.split(",") : [];
1403
+ _variationIDsList.forEach(function (variationID) {
1404
+ configState.state.setVariationID(variationID);
1405
+ });
1406
+ case 25:
1407
+ if (!(attributeName === "variation-sku")) {
1408
+ _context5.next = 32;
1409
+ break;
1410
+ }
1411
+ _context5.next = 28;
1412
+ return this.getConfiguratorState();
1413
+ case 28:
1414
+ _configState = _context5.sent;
1415
+ _variationSKUs = this.getAttribute("variation-sku");
1416
+ _variationSKUList = _variationSKUs ? _variationSKUs.split(",") : [];
1417
+ _variationSKUList.forEach(function (variationSKU) {
1418
+ _configState.state.setVariationSKU(variationSKU);
1419
+ });
1420
+ case 32:
1421
+ this.startQRCode(this._prevQROpt);
1422
+ return _context5.abrupt("return");
1423
+ case 34:
1424
+ case "end":
1425
+ return _context5.stop();
1426
+ }
1427
+ }, _callee5, this);
1428
+ }));
1429
+ function onAttributesUpdated(_x2) {
1430
+ return _onAttributesUpdated.apply(this, arguments);
1042
1431
  }
1043
- }
1432
+ return onAttributesUpdated;
1433
+ }()
1044
1434
  }, {
1045
1435
  key: "startViewerQRCode",
1046
- value: function startViewerQRCode(options) {
1047
- var _this14 = this;
1048
- return new Promise(function (accept, reject) {
1049
- // remove the old renderer instance if any
1050
- _this14.removeRenderer();
1051
- var sceneID = _this14.getAttribute("scene-id");
1052
- if (sceneID) {
1053
- var opt = options || _this14._GetDefaultQROptions();
1054
- var viewer = document.createElement("plattar-qrcode");
1055
- // required attributes with defaults for plattar-viewer node
1056
- var width = _this14.getAttribute("width") || "500px";
1057
- var height = _this14.getAttribute("height") || "500px";
1058
- viewer.setAttribute("width", width);
1059
- viewer.setAttribute("height", height);
1060
- if (opt.color) {
1061
- viewer.setAttribute("color", opt.color);
1062
- }
1063
- if (opt.margin) {
1064
- viewer.setAttribute("margin", "" + opt.margin);
1065
- }
1066
- if (opt.qrType) {
1067
- viewer.setAttribute("qr-type", opt.qrType);
1068
- }
1069
- viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
1070
- var dst = plattar_api_1.Server.location().base + "renderer/configurator.html?scene_id=" + sceneID;
1071
- // optional attributes
1072
- var configState = _this14.getAttribute("config-state");
1073
- var showAR = _this14.getAttribute("show-ar");
1074
- var showUI = _this14.getAttribute("show-ui");
1075
- if (showUI && showUI === "true") {
1076
- dst = plattar_api_1.Server.location().base + "configurator/dist/index.html?scene_id=" + sceneID;
1077
- }
1078
- if (configState) {
1079
- dst += "&config_state=" + configState;
1080
- }
1081
- if (showAR) {
1082
- dst += "&show_ar=" + showAR;
1436
+ value: function () {
1437
+ var _startViewerQRCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options) {
1438
+ var _this15 = this;
1439
+ var sceneID, opt, viewer, width, height, dst, configState, showAR, showUI;
1440
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1441
+ while (1) switch (_context6.prev = _context6.next) {
1442
+ case 0:
1443
+ // remove the old renderer instance if any
1444
+ this.removeRenderer();
1445
+ sceneID = this.getAttribute("scene-id");
1446
+ if (sceneID) {
1447
+ _context6.next = 4;
1448
+ break;
1449
+ }
1450
+ throw new Error("ConfiguratorController.startQRCode() - minimum required attributes not set, use scene-id as a minimum");
1451
+ case 4:
1452
+ opt = options || this._GetDefaultQROptions();
1453
+ viewer = document.createElement("plattar-qrcode");
1454
+ this._element = viewer;
1455
+ // required attributes with defaults for plattar-viewer node
1456
+ width = this.getAttribute("width") || "500px";
1457
+ height = this.getAttribute("height") || "500px";
1458
+ viewer.setAttribute("width", width);
1459
+ viewer.setAttribute("height", height);
1460
+ if (opt.color) {
1461
+ viewer.setAttribute("color", opt.color);
1462
+ }
1463
+ if (opt.margin) {
1464
+ viewer.setAttribute("margin", "" + opt.margin);
1465
+ }
1466
+ if (opt.qrType) {
1467
+ viewer.setAttribute("qr-type", opt.qrType);
1468
+ }
1469
+ viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
1470
+ dst = plattar_api_1.Server.location().base + "renderer/configurator.html?scene_id=" + sceneID; // optional attributes
1471
+ configState = null;
1472
+ showAR = this.getAttribute("show-ar");
1473
+ showUI = this.getAttribute("show-ui");
1474
+ _context6.prev = 19;
1475
+ _context6.next = 22;
1476
+ return this.getConfiguratorState();
1477
+ case 22:
1478
+ configState = _context6.sent.state.encode();
1479
+ _context6.next = 28;
1480
+ break;
1481
+ case 25:
1482
+ _context6.prev = 25;
1483
+ _context6.t0 = _context6["catch"](19);
1484
+ // config state is not available
1485
+ configState = null;
1486
+ case 28:
1487
+ if (showUI && showUI === "true") {
1488
+ dst = plattar_api_1.Server.location().base + "configurator/dist/index.html?scene_id=" + sceneID;
1489
+ }
1490
+ if (configState) {
1491
+ dst += "&config_state=" + configState;
1492
+ }
1493
+ if (showAR) {
1494
+ dst += "&show_ar=" + showAR;
1495
+ }
1496
+ viewer.setAttribute("url", opt.url || dst);
1497
+ this._state = plattar_controller_1.ControllerState.QRCode;
1498
+ this._prevQROpt = opt;
1499
+ return _context6.abrupt("return", new Promise(function (accept, reject) {
1500
+ viewer.onload = function () {
1501
+ return accept(viewer);
1502
+ };
1503
+ _this15.append(viewer);
1504
+ }));
1505
+ case 35:
1506
+ case "end":
1507
+ return _context6.stop();
1083
1508
  }
1084
- viewer.setAttribute("url", opt.url || dst);
1085
- viewer.onload = function () {
1086
- return accept(viewer);
1087
- };
1088
- _this14.append(viewer);
1089
- _this14._element = viewer;
1090
- _this14._state = plattar_controller_1.ControllerState.QRCode;
1091
- _this14._prevQROpt = opt;
1092
- return;
1093
- }
1094
- return reject(new Error("ConfiguratorController.startQRCode() - minimum required attributes not set, use scene-id as a minimum"));
1095
- });
1096
- }
1509
+ }, _callee6, this, [[19, 25]]);
1510
+ }));
1511
+ function startViewerQRCode(_x3) {
1512
+ return _startViewerQRCode.apply(this, arguments);
1513
+ }
1514
+ return startViewerQRCode;
1515
+ }()
1097
1516
  }, {
1098
1517
  key: "startRenderer",
1099
- value: function startRenderer() {
1100
- var _this15 = this;
1101
- return new Promise(function (accept, reject) {
1102
- // remove the old renderer instance if any
1103
- _this15.removeRenderer();
1104
- var sceneID = _this15.getAttribute("scene-id");
1105
- if (sceneID) {
1106
- // required attributes with defaults for plattar-configurator node
1107
- var width = _this15.getAttribute("width") || "500px";
1108
- var height = _this15.getAttribute("height") || "500px";
1109
- var server = _this15.getAttribute("server") || "production";
1110
- var viewer = document.createElement("plattar-configurator");
1111
- viewer.setAttribute("width", width);
1112
- viewer.setAttribute("height", height);
1113
- viewer.setAttribute("server", server);
1114
- viewer.setAttribute("scene-id", sceneID);
1115
- // optional attributes
1116
- var configState = _this15.getAttribute("config-state");
1117
- var showAR = _this15.getAttribute("show-ar");
1118
- var showUI = _this15.getAttribute("show-ui");
1119
- if (configState) {
1120
- viewer.setAttribute("config-state", configState);
1121
- }
1122
- if (showAR) {
1123
- viewer.setAttribute("show-ar", showAR);
1124
- }
1125
- if (showUI) {
1126
- viewer.setAttribute("show-ui", showUI);
1518
+ value: function () {
1519
+ var _startRenderer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1520
+ var _this16 = this;
1521
+ var sceneID, width, height, server, viewer, configState, showAR, showUI;
1522
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1523
+ while (1) switch (_context7.prev = _context7.next) {
1524
+ case 0:
1525
+ // remove the old renderer instance if any
1526
+ this.removeRenderer();
1527
+ sceneID = this.getAttribute("scene-id");
1528
+ if (sceneID) {
1529
+ _context7.next = 4;
1530
+ break;
1531
+ }
1532
+ throw new Error("ConfiguratorController.startRenderer() - minimum required attributes not set, use scene-id as a minimum");
1533
+ case 4:
1534
+ // required attributes with defaults for plattar-configurator node
1535
+ width = this.getAttribute("width") || "500px";
1536
+ height = this.getAttribute("height") || "500px";
1537
+ server = this.getAttribute("server") || "production";
1538
+ viewer = document.createElement("plattar-configurator");
1539
+ this._element = viewer;
1540
+ viewer.setAttribute("width", width);
1541
+ viewer.setAttribute("height", height);
1542
+ viewer.setAttribute("server", server);
1543
+ viewer.setAttribute("scene-id", sceneID);
1544
+ // optional attributes
1545
+ configState = null;
1546
+ _context7.prev = 14;
1547
+ _context7.next = 17;
1548
+ return this.getConfiguratorState();
1549
+ case 17:
1550
+ configState = _context7.sent;
1551
+ _context7.next = 23;
1552
+ break;
1553
+ case 20:
1554
+ _context7.prev = 20;
1555
+ _context7.t0 = _context7["catch"](14);
1556
+ // config state is not available
1557
+ configState = null;
1558
+ case 23:
1559
+ showAR = this.getAttribute("show-ar");
1560
+ showUI = this.getAttribute("show-ui");
1561
+ if (configState) {
1562
+ viewer.setAttribute("config-state", configState.state.encode());
1563
+ }
1564
+ if (showAR) {
1565
+ viewer.setAttribute("show-ar", showAR);
1566
+ }
1567
+ if (showUI) {
1568
+ viewer.setAttribute("show-ui", showUI);
1569
+ }
1570
+ this._state = plattar_controller_1.ControllerState.Renderer;
1571
+ return _context7.abrupt("return", new Promise(function (accept, reject) {
1572
+ _this16.append(viewer);
1573
+ if (configState) {
1574
+ _this16.setupMessengerObservers(viewer, configState);
1575
+ }
1576
+ return accept(viewer);
1577
+ }));
1578
+ case 30:
1579
+ case "end":
1580
+ return _context7.stop();
1127
1581
  }
1128
- viewer.onload = function () {
1129
- return accept(viewer);
1130
- };
1131
- _this15.append(viewer);
1132
- _this15._element = viewer;
1133
- _this15._state = plattar_controller_1.ControllerState.Renderer;
1134
- return;
1135
- }
1136
- return reject(new Error("ConfiguratorController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
1137
- });
1138
- }
1582
+ }, _callee7, this, [[14, 20]]);
1583
+ }));
1584
+ function startRenderer() {
1585
+ return _startRenderer.apply(this, arguments);
1586
+ }
1587
+ return startRenderer;
1588
+ }()
1139
1589
  }, {
1140
1590
  key: "initAR",
1141
- value: function initAR() {
1142
- var _this16 = this;
1143
- return new Promise(function (accept, reject) {
1144
- if (!util_1.Util.canAugment()) {
1145
- return reject(new Error("ConfiguratorController.initAR() - cannot proceed as AR not available in context"));
1146
- }
1147
- var arMode = _this16.getAttribute("ar-mode") || "generated";
1148
- switch (arMode.toLowerCase()) {
1149
- case "inherited":
1150
- _this16._InitARInherited(accept, reject);
1151
- return;
1152
- case "generated":
1153
- default:
1154
- _this16._InitARGenerated(accept, reject);
1155
- }
1156
- });
1157
- }
1591
+ value: function () {
1592
+ var _initAR = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1593
+ var arMode;
1594
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1595
+ while (1) switch (_context8.prev = _context8.next) {
1596
+ case 0:
1597
+ if (util_1.Util.canAugment()) {
1598
+ _context8.next = 2;
1599
+ break;
1600
+ }
1601
+ throw new Error("ConfiguratorController.initAR() - cannot proceed as AR not available in context");
1602
+ case 2:
1603
+ arMode = this.getAttribute("ar-mode") || "generated";
1604
+ _context8.t0 = arMode.toLowerCase();
1605
+ _context8.next = _context8.t0 === "inherited" ? 6 : _context8.t0 === "generated" ? 7 : 7;
1606
+ break;
1607
+ case 6:
1608
+ return _context8.abrupt("return", this._InitARInherited());
1609
+ case 7:
1610
+ return _context8.abrupt("return", this._InitARGenerated());
1611
+ case 8:
1612
+ case "end":
1613
+ return _context8.stop();
1614
+ }
1615
+ }, _callee8, this);
1616
+ }));
1617
+ function initAR() {
1618
+ return _initAR.apply(this, arguments);
1619
+ }
1620
+ return initAR;
1621
+ }()
1158
1622
  /**
1159
1623
  * Private Function - This launches the Static/Inherited AR Mode
1160
1624
  */
1161
1625
  }, {
1162
1626
  key: "_InitARInherited",
1163
- value: function _InitARInherited(accept, reject) {
1164
- var sceneID = this.getAttribute("scene-id");
1165
- var configState = this.getAttribute("config-state");
1166
- // use config-state if its available
1167
- if (sceneID && configState) {
1168
- var state = configurator_state_1.ConfiguratorState.decode(configState);
1169
- var first = state.first();
1170
- if (first) {
1171
- var sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
1172
- sceneProductAR.init().then(accept)["catch"](reject);
1173
- return;
1174
- }
1175
- return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
1176
- }
1177
- // otherwise fallback to using scene
1178
- if (sceneID) {
1179
- configurator_state_1.ConfiguratorState.decodeScene(sceneID).then(function (state) {
1180
- var first = state.first();
1181
- if (first) {
1182
- var _sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
1183
- return _sceneProductAR.init().then(accept)["catch"](reject);
1627
+ value: function () {
1628
+ var _InitARInherited2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1629
+ var sceneID, state, first, sceneProductAR;
1630
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1631
+ while (1) switch (_context9.prev = _context9.next) {
1632
+ case 0:
1633
+ sceneID = this.getAttribute("scene-id");
1634
+ if (sceneID) {
1635
+ _context9.next = 3;
1636
+ break;
1637
+ }
1638
+ throw new Error("ConfiguratorController.initAR() - inherited AR minimum required attributes not set, use scene-id as a minimum");
1639
+ case 3:
1640
+ _context9.next = 5;
1641
+ return this.getConfiguratorState();
1642
+ case 5:
1643
+ state = _context9.sent.state;
1644
+ first = state.first();
1645
+ if (!first) {
1646
+ _context9.next = 10;
1647
+ break;
1648
+ }
1649
+ sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
1650
+ return _context9.abrupt("return", sceneProductAR.init());
1651
+ case 10:
1652
+ throw new Error("ConfiguratorController.initAR() - invalid decoded config-state does not have any product states");
1653
+ case 11:
1654
+ case "end":
1655
+ return _context9.stop();
1184
1656
  }
1185
- return reject(new Error("ConfiguratorController.initAR() - invalid Scene does not have any product states"));
1186
- })["catch"](reject);
1187
- return;
1657
+ }, _callee9, this);
1658
+ }));
1659
+ function _InitARInherited() {
1660
+ return _InitARInherited2.apply(this, arguments);
1188
1661
  }
1189
- return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
1190
- }
1662
+ return _InitARInherited;
1663
+ }()
1191
1664
  /**
1192
1665
  * Private Function - This launches the Dynamic/Generated AR Mode
1193
1666
  */
1194
1667
  }, {
1195
1668
  key: "_InitARGenerated",
1196
- value: function _InitARGenerated(accept, reject) {
1197
- // if scene ID is available and the state is a configurator viewer
1198
- // we can use the real-time configurator state to launch the AR view
1199
- var viewer = this.element;
1200
- var sceneID = this.getAttribute("scene-id");
1201
- if (viewer && sceneID && viewer.messenger) {
1202
- var output = "glb";
1203
- if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
1204
- output = "usdz";
1205
- }
1206
- viewer.messenger.getARFile(output).then(function (result) {
1207
- var rawAR = new raw_ar_1.RawAR(result.filename, sceneID);
1208
- return rawAR.init().then(accept)["catch"](reject);
1209
- })["catch"](reject);
1210
- return;
1211
- }
1212
- var configState = this.getAttribute("config-state");
1213
- // otherwise scene ID is available to the viewer is not launched
1214
- // we can use the static configuration state to launch the AR view
1215
- if (sceneID && configState) {
1216
- var state = configurator_state_1.ConfiguratorState.decode(configState);
1217
- if (state.length > 0) {
1218
- var server = this.getAttribute("server") || "production";
1219
- var configurator = new plattar_services_1.Configurator();
1220
- configurator.server = server;
1221
- if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
1222
- configurator.output = "usdz";
1223
- }
1224
- if (util_1.Util.canSceneViewer()) {
1225
- configurator.output = "glb";
1669
+ value: function () {
1670
+ var _InitARGenerated2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1671
+ var sceneID, configAR;
1672
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1673
+ while (1) switch (_context10.prev = _context10.next) {
1674
+ case 0:
1675
+ sceneID = this.getAttribute("scene-id");
1676
+ if (sceneID) {
1677
+ _context10.next = 3;
1678
+ break;
1679
+ }
1680
+ throw new Error("VTOController.initAR() - generated AR minimum required attributes not set, use scene-id as a minimum");
1681
+ case 3:
1682
+ _context10.t0 = configurator_ar_1.ConfiguratorAR;
1683
+ _context10.next = 6;
1684
+ return this.getConfiguratorState();
1685
+ case 6:
1686
+ _context10.t1 = _context10.sent;
1687
+ configAR = new _context10.t0(_context10.t1);
1688
+ return _context10.abrupt("return", configAR.init());
1689
+ case 9:
1690
+ case "end":
1691
+ return _context10.stop();
1226
1692
  }
1227
- state.forEach(function (productState) {
1228
- if (productState.meta_data.augment === true) {
1229
- configurator.addSceneProduct(productState.scene_product_id, productState.product_variation_id);
1230
- }
1231
- });
1232
- configurator.get().then(function (result) {
1233
- var rawAR = new raw_ar_1.RawAR(result.filename, sceneID);
1234
- rawAR.init().then(accept)["catch"](reject);
1235
- })["catch"](reject);
1236
- return;
1237
- }
1238
- return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
1239
- }
1240
- // otherwise no config-state or viewer is active
1241
- // fallback to using default SceneAR implementation
1242
- if (sceneID) {
1243
- var sceneAR = new scene_ar_1.SceneAR(sceneID);
1244
- sceneAR.init().then(accept)["catch"](reject);
1245
- return;
1693
+ }, _callee10, this);
1694
+ }));
1695
+ function _InitARGenerated() {
1696
+ return _InitARGenerated2.apply(this, arguments);
1246
1697
  }
1247
- return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
1248
- }
1698
+ return _InitARGenerated;
1699
+ }()
1249
1700
  }, {
1250
1701
  key: "removeRenderer",
1251
1702
  value: function removeRenderer() {
@@ -1254,6 +1705,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1254
1705
  this._element = null;
1255
1706
  return true;
1256
1707
  }
1708
+ this.removeMessengerObservers();
1257
1709
  return false;
1258
1710
  }
1259
1711
  }, {
@@ -1266,16 +1718,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1266
1718
  }(plattar_controller_1.PlattarController);
1267
1719
  exports.ConfiguratorController = ConfiguratorController;
1268
1720
  }, {
1269
- "../../ar/raw-ar": 4,
1270
- "../../ar/scene-ar": 5,
1271
- "../../ar/scene-product-ar": 6,
1272
- "../../util/configurator-state": 14,
1721
+ "../../ar/configurator-ar": 1,
1722
+ "../../ar/scene-product-ar": 7,
1273
1723
  "../../util/util": 15,
1274
- "./plattar-controller": 8,
1275
- "@plattar/plattar-api": 44,
1276
- "@plattar/plattar-services": 115
1724
+ "./plattar-controller": 9,
1725
+ "@plattar/plattar-api": 44
1277
1726
  }],
1278
- 8: [function (require, module, exports) {
1727
+ 9: [function (require, module, exports) {
1279
1728
  "use strict";
1280
1729
 
1281
1730
  Object.defineProperty(exports, "__esModule", {
@@ -1283,6 +1732,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1283
1732
  });
1284
1733
  exports.PlattarController = exports.ControllerState = void 0;
1285
1734
  var plattar_api_1 = require("@plattar/plattar-api");
1735
+ var configurator_state_1 = require("../../util/configurator-state");
1286
1736
  var ControllerState;
1287
1737
  (function (ControllerState) {
1288
1738
  ControllerState[ControllerState["None"] = 0] = "None";
@@ -1298,10 +1748,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1298
1748
  this._state = ControllerState.None;
1299
1749
  this._element = null;
1300
1750
  this._prevQROpt = null;
1751
+ this._selectVariationObserver = null;
1752
+ this._selectVariationSKUObserver = null;
1301
1753
  this._parent = parent;
1302
1754
  }
1303
1755
  /**
1304
- * Initialise and start AR mode if available
1756
+ * Generates a brand new Configurator State from the provided SceneID or inputted Configurator State
1305
1757
  */
1306
1758
  _createClass(PlattarController, [{
1307
1759
  key: "_GetDefaultQROptions",
@@ -1318,16 +1770,131 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1318
1770
  };
1319
1771
  }
1320
1772
  }, {
1321
- key: "startAR",
1322
- value: function startAR() {
1323
- var _this17 = this;
1324
- return new Promise(function (accept, reject) {
1325
- _this17.initAR().then(function (launcher) {
1326
- launcher.start();
1327
- accept();
1328
- })["catch"](reject);
1773
+ key: "createConfiguratorState",
1774
+ value: function () {
1775
+ var _createConfiguratorState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1776
+ var sceneID, configState, variationIDs, variationSKUs, decodedState, variationIDList, variationSKUList;
1777
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1778
+ while (1) switch (_context11.prev = _context11.next) {
1779
+ case 0:
1780
+ // get our Scene ID
1781
+ sceneID = this.getAttribute("scene-id");
1782
+ if (sceneID) {
1783
+ _context11.next = 3;
1784
+ break;
1785
+ }
1786
+ throw new Error("PlattarController.createConfiguratorState() - cannot create as required attribute scene-id is not defined");
1787
+ case 3:
1788
+ configState = this.getAttribute("config-state"); // get a list of variation ID's to use for initialising
1789
+ variationIDs = this.getAttribute("variation-id"); // get a list of variation SKU's to use for initialising
1790
+ variationSKUs = this.getAttribute("variation-sku"); // generate the decoded configurator state
1791
+ if (!configState) {
1792
+ _context11.next = 12;
1793
+ break;
1794
+ }
1795
+ _context11.next = 9;
1796
+ return configurator_state_1.ConfiguratorState.decodeState(sceneID, configState);
1797
+ case 9:
1798
+ _context11.t0 = _context11.sent;
1799
+ _context11.next = 15;
1800
+ break;
1801
+ case 12:
1802
+ _context11.next = 14;
1803
+ return configurator_state_1.ConfiguratorState.decodeScene(sceneID);
1804
+ case 14:
1805
+ _context11.t0 = _context11.sent;
1806
+ case 15:
1807
+ decodedState = _context11.t0;
1808
+ // change the ID's and SKU's (if any) of the default configuration state
1809
+ variationIDList = variationIDs ? variationIDs.split(",") : [];
1810
+ variationSKUList = variationSKUs ? variationSKUs.split(",") : [];
1811
+ variationIDList.forEach(function (variationID) {
1812
+ decodedState.state.setVariationID(variationID);
1813
+ });
1814
+ variationSKUList.forEach(function (variationSKU) {
1815
+ decodedState.state.setVariationSKU(variationSKU);
1816
+ });
1817
+ // return fully modified configuration state
1818
+ return _context11.abrupt("return", decodedState);
1819
+ case 21:
1820
+ case "end":
1821
+ return _context11.stop();
1822
+ }
1823
+ }, _callee11, this);
1824
+ }));
1825
+ function createConfiguratorState() {
1826
+ return _createConfiguratorState.apply(this, arguments);
1827
+ }
1828
+ return createConfiguratorState;
1829
+ }()
1830
+ /**
1831
+ * Setup messenger observers to detect variation changes and apply to the internal
1832
+ * configuration state
1833
+ */
1834
+ }, {
1835
+ key: "setupMessengerObservers",
1836
+ value: function setupMessengerObservers(viewer, configState) {
1837
+ this._selectVariationObserver = viewer.messengerInstance.observer.subscribe("selectVariation", function (cd) {
1838
+ if (cd.type === "call") {
1839
+ var args = cd.data[0];
1840
+ var variations = args ? Array.isArray(args) ? args : [args] : [];
1841
+ variations.forEach(function (variationID) {
1842
+ configState.state.setVariationID(variationID);
1843
+ });
1844
+ }
1329
1845
  });
1846
+ this._selectVariationSKUObserver = viewer.messengerInstance.observer.subscribe("selectVariationSKU", function (cd) {
1847
+ if (cd.type === "call") {
1848
+ var args = cd.data[0];
1849
+ var variations = args ? Array.isArray(args) ? args : [args] : [];
1850
+ variations.forEach(function (variationSKU) {
1851
+ configState.state.setVariationSKU(variationSKU);
1852
+ });
1853
+ }
1854
+ });
1855
+ }
1856
+ /**
1857
+ * Remove all pre-existing observers
1858
+ */
1859
+ }, {
1860
+ key: "removeMessengerObservers",
1861
+ value: function removeMessengerObservers() {
1862
+ if (this._selectVariationObserver) {
1863
+ this._selectVariationObserver();
1864
+ this._selectVariationObserver = null;
1865
+ }
1866
+ if (this._selectVariationSKUObserver) {
1867
+ this._selectVariationSKUObserver();
1868
+ this._selectVariationSKUObserver = null;
1869
+ }
1330
1870
  }
1871
+ /**
1872
+ * Initialise and start AR mode if available
1873
+ */
1874
+ }, {
1875
+ key: "startAR",
1876
+ value: function () {
1877
+ var _startAR = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1878
+ var launcher;
1879
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1880
+ while (1) switch (_context12.prev = _context12.next) {
1881
+ case 0:
1882
+ _context12.next = 2;
1883
+ return this.initAR();
1884
+ case 2:
1885
+ launcher = _context12.sent;
1886
+ return _context12.abrupt("return", launcher.start());
1887
+ case 4:
1888
+ case "end":
1889
+ return _context12.stop();
1890
+ }
1891
+ }, _callee12, this);
1892
+ }));
1893
+ function startAR() {
1894
+ return _startAR.apply(this, arguments);
1895
+ }
1896
+ return startAR;
1897
+ }()
1331
1898
  /**
1332
1899
  * Decide which QR Code to render according to the qr-type attribute
1333
1900
  * @param options
@@ -1335,16 +1902,31 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1335
1902
  */
1336
1903
  }, {
1337
1904
  key: "startQRCode",
1338
- value: function startQRCode(options) {
1339
- var qrType = this.getAttribute("qr-type") || "viewer";
1340
- switch (qrType.toLowerCase()) {
1341
- case "ar":
1342
- return this.startARQRCode(options);
1343
- case "viewer":
1344
- default:
1345
- return this.startViewerQRCode(options);
1905
+ value: function () {
1906
+ var _startQRCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
1907
+ var qrType;
1908
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1909
+ while (1) switch (_context13.prev = _context13.next) {
1910
+ case 0:
1911
+ qrType = this.getAttribute("qr-type") || "viewer";
1912
+ _context13.t0 = qrType.toLowerCase();
1913
+ _context13.next = _context13.t0 === "ar" ? 4 : _context13.t0 === "viewer" ? 5 : 5;
1914
+ break;
1915
+ case 4:
1916
+ return _context13.abrupt("return", this.startARQRCode(options));
1917
+ case 5:
1918
+ return _context13.abrupt("return", this.startViewerQRCode(options));
1919
+ case 6:
1920
+ case "end":
1921
+ return _context13.stop();
1922
+ }
1923
+ }, _callee13, this);
1924
+ }));
1925
+ function startQRCode(_x4) {
1926
+ return _startQRCode.apply(this, arguments);
1346
1927
  }
1347
- }
1928
+ return startQRCode;
1929
+ }()
1348
1930
  /**
1349
1931
  * Displays a QR Code that sends the user direct to AR
1350
1932
  * @param options
@@ -1352,72 +1934,100 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1352
1934
  */
1353
1935
  }, {
1354
1936
  key: "startARQRCode",
1355
- value: function startARQRCode(options) {
1356
- var _this18 = this;
1357
- return new Promise(function (accept, reject) {
1358
- // remove the old renderer instance if any
1359
- _this18.removeRenderer();
1360
- var opt = options || _this18._GetDefaultQROptions();
1361
- var viewer = document.createElement("plattar-qrcode");
1362
- // required attributes with defaults for plattar-viewer node
1363
- var width = _this18.getAttribute("width") || "500px";
1364
- var height = _this18.getAttribute("height") || "500px";
1365
- viewer.setAttribute("width", width);
1366
- viewer.setAttribute("height", height);
1367
- if (opt.color) {
1368
- viewer.setAttribute("color", opt.color);
1369
- }
1370
- if (opt.margin) {
1371
- viewer.setAttribute("margin", "" + opt.margin);
1372
- }
1373
- if (opt.qrType) {
1374
- viewer.setAttribute("qr-type", opt.qrType);
1375
- }
1376
- viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
1377
- var qrOptions = btoa(JSON.stringify(opt));
1378
- var dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
1379
- var sceneID = _this18.getAttribute("scene-id");
1380
- var configState = _this18.getAttribute("config-state");
1381
- var embedType = _this18.getAttribute("embed-type");
1382
- var productID = _this18.getAttribute("product-id");
1383
- var sceneProductID = _this18.getAttribute("scene-product-id");
1384
- var variationID = _this18.getAttribute("variation-id");
1385
- var variationSKU = _this18.getAttribute("variation-sku");
1386
- var arMode = _this18.getAttribute("ar-mode");
1387
- if (configState) {
1388
- dst += "&config_state=" + configState;
1389
- }
1390
- if (embedType) {
1391
- dst += "&embed_type=" + embedType;
1392
- }
1393
- if (productID) {
1394
- dst += "&product_id=" + productID;
1395
- }
1396
- if (sceneProductID) {
1397
- dst += "&scene_product_id=" + sceneProductID;
1398
- }
1399
- if (variationID) {
1400
- dst += "&variation_id=" + variationID;
1401
- }
1402
- if (variationSKU) {
1403
- dst += "&variation_sku=" + variationSKU;
1404
- }
1405
- if (arMode) {
1406
- dst += "&ar_mode=" + arMode;
1407
- }
1408
- if (sceneID) {
1409
- dst += "&scene_id=" + sceneID;
1410
- }
1411
- viewer.setAttribute("url", opt.url || dst);
1412
- viewer.onload = function () {
1413
- return accept(viewer);
1414
- };
1415
- _this18._element = viewer;
1416
- _this18._state = ControllerState.QRCode;
1417
- _this18._prevQROpt = opt;
1418
- _this18.append(viewer);
1419
- });
1420
- }
1937
+ value: function () {
1938
+ var _startARQRCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(options) {
1939
+ var _this17 = this;
1940
+ var opt, viewer, width, height, qrOptions, dst, configState, sceneID, embedType, productID, sceneProductID, variationID, variationSKU, arMode;
1941
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1942
+ while (1) switch (_context14.prev = _context14.next) {
1943
+ case 0:
1944
+ // remove the old renderer instance if any
1945
+ this.removeRenderer();
1946
+ opt = options || this._GetDefaultQROptions();
1947
+ viewer = document.createElement("plattar-qrcode");
1948
+ this._element = viewer;
1949
+ // required attributes with defaults for plattar-viewer node
1950
+ width = this.getAttribute("width") || "500px";
1951
+ height = this.getAttribute("height") || "500px";
1952
+ viewer.setAttribute("width", width);
1953
+ viewer.setAttribute("height", height);
1954
+ if (opt.color) {
1955
+ viewer.setAttribute("color", opt.color);
1956
+ }
1957
+ if (opt.margin) {
1958
+ viewer.setAttribute("margin", "" + opt.margin);
1959
+ }
1960
+ if (opt.qrType) {
1961
+ viewer.setAttribute("qr-type", opt.qrType);
1962
+ }
1963
+ viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
1964
+ qrOptions = btoa(JSON.stringify(opt));
1965
+ dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
1966
+ configState = null;
1967
+ sceneID = this.getAttribute("scene-id");
1968
+ embedType = this.getAttribute("embed-type");
1969
+ productID = this.getAttribute("product-id");
1970
+ sceneProductID = this.getAttribute("scene-product-id");
1971
+ variationID = this.getAttribute("variation-id");
1972
+ variationSKU = this.getAttribute("variation-sku");
1973
+ arMode = this.getAttribute("ar-mode");
1974
+ _context14.prev = 22;
1975
+ _context14.next = 25;
1976
+ return this.getConfiguratorState();
1977
+ case 25:
1978
+ configState = _context14.sent.state.encode();
1979
+ _context14.next = 31;
1980
+ break;
1981
+ case 28:
1982
+ _context14.prev = 28;
1983
+ _context14.t0 = _context14["catch"](22);
1984
+ // config state not available for some reason
1985
+ configState = null;
1986
+ case 31:
1987
+ if (configState) {
1988
+ dst += "&config_state=" + configState;
1989
+ }
1990
+ if (embedType) {
1991
+ dst += "&embed_type=" + embedType;
1992
+ }
1993
+ if (productID) {
1994
+ dst += "&product_id=" + productID;
1995
+ }
1996
+ if (sceneProductID) {
1997
+ dst += "&scene_product_id=" + sceneProductID;
1998
+ }
1999
+ if (variationID) {
2000
+ dst += "&variation_id=" + variationID;
2001
+ }
2002
+ if (variationSKU) {
2003
+ dst += "&variation_sku=" + variationSKU;
2004
+ }
2005
+ if (arMode) {
2006
+ dst += "&ar_mode=" + arMode;
2007
+ }
2008
+ if (sceneID) {
2009
+ dst += "&scene_id=" + sceneID;
2010
+ }
2011
+ viewer.setAttribute("url", opt.url || dst);
2012
+ this._state = ControllerState.QRCode;
2013
+ this._prevQROpt = opt;
2014
+ return _context14.abrupt("return", new Promise(function (accept, reject) {
2015
+ _this17.append(viewer);
2016
+ viewer.onload = function () {
2017
+ return accept(viewer);
2018
+ };
2019
+ }));
2020
+ case 43:
2021
+ case "end":
2022
+ return _context14.stop();
2023
+ }
2024
+ }, _callee14, this, [[22, 28]]);
2025
+ }));
2026
+ function startARQRCode(_x5) {
2027
+ return _startARQRCode.apply(this, arguments);
2028
+ }
2029
+ return startARQRCode;
2030
+ }()
1421
2031
  /**
1422
2032
  * Returns the Parent Instance
1423
2033
  */
@@ -1453,9 +2063,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1453
2063
  }();
1454
2064
  exports.PlattarController = PlattarController;
1455
2065
  }, {
2066
+ "../../util/configurator-state": 14,
1456
2067
  "@plattar/plattar-api": 44
1457
2068
  }],
1458
- 9: [function (require, module, exports) {
2069
+ 10: [function (require, module, exports) {
1459
2070
  "use strict";
1460
2071
 
1461
2072
  Object.defineProperty(exports, "__esModule", {
@@ -1468,49 +2079,89 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1468
2079
  var plattar_controller_1 = require("./plattar-controller");
1469
2080
  /**
1470
2081
  * Manages an instance of the <plattar-product> HTML Element
2082
+ *
2083
+ * NOTE: As of 14th June 2023, this is now a legacy Controller and only used in legacy embeds
2084
+ * and should be deprecated from both documentation and previous integrations
1471
2085
  */
1472
2086
  var ProductController = /*#__PURE__*/function (_plattar_controller_2) {
1473
2087
  _inherits(ProductController, _plattar_controller_2);
1474
- var _super7 = _createSuper(ProductController);
2088
+ var _super8 = _createSuper(ProductController);
1475
2089
  function ProductController(parent) {
1476
2090
  _classCallCheck(this, ProductController);
1477
- return _super7.call(this, parent);
2091
+ // this is a hack against DecodedConfiguratorState that's now stored in PlattarController
2092
+ // this is not used in legacy mode
2093
+ return _super8.call(this, parent);
1478
2094
  }
1479
2095
  _createClass(ProductController, [{
1480
- key: "onAttributesUpdated",
1481
- value: function onAttributesUpdated() {
1482
- var state = this._state;
1483
- // re-render the QR Code when attributes have changed
1484
- if (state === plattar_controller_1.ControllerState.QRCode) {
1485
- this.startQRCode(this._prevQROpt);
1486
- return;
2096
+ key: "getConfiguratorState",
2097
+ value: function () {
2098
+ var _getConfiguratorState2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
2099
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2100
+ while (1) switch (_context15.prev = _context15.next) {
2101
+ case 0:
2102
+ throw new Error("ProductController.getConfiguratorState() - legacy embeds do not support configurator states");
2103
+ case 1:
2104
+ case "end":
2105
+ return _context15.stop();
2106
+ }
2107
+ }, _callee15);
2108
+ }));
2109
+ function getConfiguratorState() {
2110
+ return _getConfiguratorState2.apply(this, arguments);
1487
2111
  }
1488
- // use the messenger function to change variation when attributes have changed
1489
- if (state === plattar_controller_1.ControllerState.Renderer) {
1490
- var viewer = this._element;
1491
- if (viewer) {
1492
- var variationID = this.getAttribute("variation-id");
1493
- if (variationID && viewer.messenger) {
1494
- viewer.messenger.selectVariation(variationID);
2112
+ return getConfiguratorState;
2113
+ }()
2114
+ }, {
2115
+ key: "onAttributesUpdated",
2116
+ value: function () {
2117
+ var _onAttributesUpdated2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(attributeName) {
2118
+ var state, viewer, variationID;
2119
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2120
+ while (1) switch (_context16.prev = _context16.next) {
2121
+ case 0:
2122
+ state = this._state; // re-render the QR Code when attributes have changed
2123
+ if (!(state === plattar_controller_1.ControllerState.QRCode)) {
2124
+ _context16.next = 4;
2125
+ break;
2126
+ }
2127
+ this.startQRCode(this._prevQROpt);
2128
+ return _context16.abrupt("return");
2129
+ case 4:
2130
+ // use the messenger function to change variation when attributes have changed
2131
+ if (state === plattar_controller_1.ControllerState.Renderer) {
2132
+ viewer = this._element;
2133
+ if (viewer) {
2134
+ variationID = this.getAttribute("variation-id");
2135
+ if (variationID && viewer.messenger) {
2136
+ viewer.messenger.selectVariation(variationID);
2137
+ }
2138
+ }
2139
+ }
2140
+ case 5:
2141
+ case "end":
2142
+ return _context16.stop();
1495
2143
  }
1496
- }
1497
- return;
2144
+ }, _callee16, this);
2145
+ }));
2146
+ function onAttributesUpdated(_x6) {
2147
+ return _onAttributesUpdated2.apply(this, arguments);
1498
2148
  }
1499
- }
2149
+ return onAttributesUpdated;
2150
+ }()
1500
2151
  }, {
1501
2152
  key: "startViewerQRCode",
1502
2153
  value: function startViewerQRCode(options) {
1503
- var _this19 = this;
2154
+ var _this18 = this;
1504
2155
  return new Promise(function (accept, reject) {
1505
2156
  // remove the old renderer instance if any
1506
- _this19.removeRenderer();
1507
- var productID = _this19.getAttribute("product-id");
2157
+ _this18.removeRenderer();
2158
+ var productID = _this18.getAttribute("product-id");
1508
2159
  if (productID) {
1509
- var opt = options || _this19._GetDefaultQROptions();
2160
+ var opt = options || _this18._GetDefaultQROptions();
1510
2161
  var viewer = document.createElement("plattar-qrcode");
1511
2162
  // required attributes with defaults for plattar-viewer node
1512
- var width = _this19.getAttribute("width") || "500px";
1513
- var height = _this19.getAttribute("height") || "500px";
2163
+ var width = _this18.getAttribute("width") || "500px";
2164
+ var height = _this18.getAttribute("height") || "500px";
1514
2165
  viewer.setAttribute("width", width);
1515
2166
  viewer.setAttribute("height", height);
1516
2167
  if (opt.color) {
@@ -1524,9 +2175,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1524
2175
  }
1525
2176
  viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
1526
2177
  // optional attributes
1527
- var variationID = _this19.getAttribute("variation-id");
1528
- var variationSKU = _this19.getAttribute("variation-sku");
1529
- var showAR = _this19.getAttribute("show-ar");
2178
+ var variationID = _this18.getAttribute("variation-id");
2179
+ var variationSKU = _this18.getAttribute("variation-sku");
2180
+ var showAR = _this18.getAttribute("show-ar");
1530
2181
  var dst = plattar_api_1.Server.location().base + "renderer/product.html?product_id=" + productID;
1531
2182
  if (variationID) {
1532
2183
  dst += "&variationId=" + variationID;
@@ -1541,10 +2192,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1541
2192
  viewer.onload = function () {
1542
2193
  return accept(viewer);
1543
2194
  };
1544
- _this19.append(viewer);
1545
- _this19._element = viewer;
1546
- _this19._state = plattar_controller_1.ControllerState.QRCode;
1547
- _this19._prevQROpt = opt;
2195
+ _this18.append(viewer);
2196
+ _this18._element = viewer;
2197
+ _this18._state = plattar_controller_1.ControllerState.QRCode;
2198
+ _this18._prevQROpt = opt;
1548
2199
  return;
1549
2200
  }
1550
2201
  return reject(new Error("ProductController.startQRCode() - minimum required attributes not set, use product-id as a minimum"));
@@ -1553,25 +2204,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1553
2204
  }, {
1554
2205
  key: "startRenderer",
1555
2206
  value: function startRenderer() {
1556
- var _this20 = this;
2207
+ var _this19 = this;
1557
2208
  return new Promise(function (accept, reject) {
1558
2209
  // remove the old renderer instance if any
1559
- _this20.removeRenderer();
1560
- var productID = _this20.getAttribute("product-id");
2210
+ _this19.removeRenderer();
2211
+ var productID = _this19.getAttribute("product-id");
1561
2212
  if (productID) {
1562
2213
  // required attributes with defaults for plattar-product node
1563
- var width = _this20.getAttribute("width") || "500px";
1564
- var height = _this20.getAttribute("height") || "500px";
1565
- var server = _this20.getAttribute("server") || "production";
2214
+ var width = _this19.getAttribute("width") || "500px";
2215
+ var height = _this19.getAttribute("height") || "500px";
2216
+ var server = _this19.getAttribute("server") || "production";
1566
2217
  var viewer = document.createElement("plattar-product");
1567
2218
  viewer.setAttribute("width", width);
1568
2219
  viewer.setAttribute("height", height);
1569
2220
  viewer.setAttribute("server", server);
1570
2221
  viewer.setAttribute("product-id", productID);
1571
2222
  // optional attributes
1572
- var variationID = _this20.getAttribute("variation-id");
1573
- var variationSKU = _this20.getAttribute("variation-sku");
1574
- var showAR = _this20.getAttribute("show-ar");
2223
+ var variationID = _this19.getAttribute("variation-id");
2224
+ var variationSKU = _this19.getAttribute("variation-sku");
2225
+ var showAR = _this19.getAttribute("show-ar");
1575
2226
  if (variationID) {
1576
2227
  viewer.setAttribute("variation-id", variationID);
1577
2228
  }
@@ -1584,9 +2235,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1584
2235
  viewer.onload = function () {
1585
2236
  return accept(viewer);
1586
2237
  };
1587
- _this20.append(viewer);
1588
- _this20._element = viewer;
1589
- _this20._state = plattar_controller_1.ControllerState.Renderer;
2238
+ _this19.append(viewer);
2239
+ _this19._element = viewer;
2240
+ _this19._state = plattar_controller_1.ControllerState.Renderer;
1590
2241
  return;
1591
2242
  }
1592
2243
  return reject(new Error("ProductController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
@@ -1595,15 +2246,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1595
2246
  }, {
1596
2247
  key: "initAR",
1597
2248
  value: function initAR() {
1598
- var _this21 = this;
2249
+ var _this20 = this;
1599
2250
  return new Promise(function (accept, reject) {
1600
2251
  if (!util_1.Util.canAugment()) {
1601
2252
  return reject(new Error("ProductController.initAR() - cannot proceed as AR not available in context"));
1602
2253
  }
1603
- var productID = _this21.getAttribute("product-id");
2254
+ var productID = _this20.getAttribute("product-id");
1604
2255
  if (productID) {
1605
- var variationID = _this21.getAttribute("variation-id");
1606
- var variationSKU = _this21.getAttribute("variation-sku");
2256
+ var variationID = _this20.getAttribute("variation-id");
2257
+ var variationSKU = _this20.getAttribute("variation-sku");
1607
2258
  var product = new product_ar_1.ProductAR(productID, variationID, variationSKU);
1608
2259
  return product.init().then(accept)["catch"](reject);
1609
2260
  }
@@ -1630,235 +2281,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1630
2281
  }(plattar_controller_1.PlattarController);
1631
2282
  exports.ProductController = ProductController;
1632
2283
  }, {
1633
- "../../ar/product-ar": 3,
2284
+ "../../ar/product-ar": 4,
1634
2285
  "../../util/util": 15,
1635
- "./plattar-controller": 8,
1636
- "@plattar/plattar-api": 44
1637
- }],
1638
- 10: [function (require, module, exports) {
1639
- "use strict";
1640
-
1641
- Object.defineProperty(exports, "__esModule", {
1642
- value: true
1643
- });
1644
- exports.ViewerController = void 0;
1645
- var plattar_api_1 = require("@plattar/plattar-api");
1646
- var product_ar_1 = require("../../ar/product-ar");
1647
- var scene_ar_1 = require("../../ar/scene-ar");
1648
- var scene_product_ar_1 = require("../../ar/scene-product-ar");
1649
- var configurator_state_1 = require("../../util/configurator-state");
1650
- var util_1 = require("../../util/util");
1651
- var plattar_controller_1 = require("./plattar-controller");
1652
- /**
1653
- * Manages an instance of the <plattar-viewer> HTML Element
1654
- */
1655
- var ViewerController = /*#__PURE__*/function (_plattar_controller_3) {
1656
- _inherits(ViewerController, _plattar_controller_3);
1657
- var _super8 = _createSuper(ViewerController);
1658
- function ViewerController(parent) {
1659
- _classCallCheck(this, ViewerController);
1660
- return _super8.call(this, parent);
1661
- }
1662
- _createClass(ViewerController, [{
1663
- key: "onAttributesUpdated",
1664
- value: function onAttributesUpdated() {
1665
- var state = this._state;
1666
- // re-render the QR Code when attributes have changed
1667
- if (state === plattar_controller_1.ControllerState.QRCode) {
1668
- this.startQRCode(this._prevQROpt);
1669
- return;
1670
- }
1671
- // use the messenger function to change variation when attributes have changed
1672
- if (state === plattar_controller_1.ControllerState.Renderer) {
1673
- var viewer = this._element;
1674
- if (viewer) {
1675
- var productID = this.getAttribute("product-id") || this.getAttribute("scene-product-id");
1676
- var variationID = this.getAttribute("variation-id");
1677
- if (productID && variationID && viewer.messenger) {
1678
- viewer.messenger.selectVariation(productID, variationID);
1679
- }
1680
- }
1681
- return;
1682
- }
1683
- }
1684
- }, {
1685
- key: "startViewerQRCode",
1686
- value: function startViewerQRCode(options) {
1687
- var _this22 = this;
1688
- return new Promise(function (accept, reject) {
1689
- // remove the old renderer instance if any
1690
- _this22.removeRenderer();
1691
- var sceneID = _this22.getAttribute("scene-id");
1692
- if (sceneID) {
1693
- var opt = options || _this22._GetDefaultQROptions();
1694
- var viewer = document.createElement("plattar-qrcode");
1695
- // required attributes with defaults for plattar-viewer node
1696
- var width = _this22.getAttribute("width") || "500px";
1697
- var height = _this22.getAttribute("height") || "500px";
1698
- viewer.setAttribute("width", width);
1699
- viewer.setAttribute("height", height);
1700
- if (opt.color) {
1701
- viewer.setAttribute("color", opt.color);
1702
- }
1703
- if (opt.margin) {
1704
- viewer.setAttribute("margin", "" + opt.margin);
1705
- }
1706
- if (opt.qrType) {
1707
- viewer.setAttribute("qr-type", opt.qrType);
1708
- }
1709
- viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
1710
- var dst = plattar_api_1.Server.location().base + "renderer/viewer.html?scene_id=" + sceneID;
1711
- // optional attributes
1712
- var productID = _this22.getAttribute("product-id") || _this22.getAttribute("scene-product-id");
1713
- var variationID = _this22.getAttribute("variation-id");
1714
- var variationSKU = _this22.getAttribute("variation-sku");
1715
- var showAR = _this22.getAttribute("show-ar");
1716
- if (productID) {
1717
- dst += "&productId=" + productID;
1718
- }
1719
- if (variationID) {
1720
- dst += "&variationId=" + variationID;
1721
- }
1722
- if (variationSKU) {
1723
- dst += "&variationSku=" + variationSKU;
1724
- }
1725
- if (showAR) {
1726
- dst += "&show_ar=" + showAR;
1727
- }
1728
- viewer.setAttribute("url", opt.url || dst);
1729
- viewer.onload = function () {
1730
- return accept(viewer);
1731
- };
1732
- _this22.append(viewer);
1733
- _this22._element = viewer;
1734
- _this22._state = plattar_controller_1.ControllerState.QRCode;
1735
- _this22._prevQROpt = opt;
1736
- return;
1737
- }
1738
- return reject(new Error("ViewerController.startQRCode() - minimum required attributes not set, use scene-id as a minimum"));
1739
- });
1740
- }
1741
- }, {
1742
- key: "startRenderer",
1743
- value: function startRenderer() {
1744
- var _this23 = this;
1745
- return new Promise(function (accept, reject) {
1746
- // remove the old renderer instance if any
1747
- _this23.removeRenderer();
1748
- var sceneID = _this23.getAttribute("scene-id");
1749
- if (sceneID) {
1750
- // required attributes with defaults for plattar-viewer node
1751
- var width = _this23.getAttribute("width") || "500px";
1752
- var height = _this23.getAttribute("height") || "500px";
1753
- var server = _this23.getAttribute("server") || "production";
1754
- var viewer = document.createElement("plattar-viewer");
1755
- viewer.setAttribute("width", width);
1756
- viewer.setAttribute("height", height);
1757
- viewer.setAttribute("server", server);
1758
- viewer.setAttribute("scene-id", sceneID);
1759
- // optional attributes
1760
- var productID = _this23.getAttribute("product-id") || _this23.getAttribute("scene-product-id");
1761
- var variationID = _this23.getAttribute("variation-id");
1762
- var variationSKU = _this23.getAttribute("variation-sku");
1763
- var showAR = _this23.getAttribute("show-ar");
1764
- if (productID) {
1765
- viewer.setAttribute("product-id", productID);
1766
- }
1767
- if (variationID) {
1768
- viewer.setAttribute("variation-id", variationID);
1769
- }
1770
- if (variationSKU) {
1771
- viewer.setAttribute("variation-sku", variationSKU);
1772
- }
1773
- if (showAR) {
1774
- viewer.setAttribute("show-ar", showAR);
1775
- }
1776
- viewer.onload = function () {
1777
- return accept(viewer);
1778
- };
1779
- _this23.append(viewer);
1780
- _this23._element = viewer;
1781
- _this23._state = plattar_controller_1.ControllerState.Renderer;
1782
- return;
1783
- }
1784
- return reject(new Error("ViewerController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
1785
- });
1786
- }
1787
- }, {
1788
- key: "initAR",
1789
- value: function initAR() {
1790
- var _this24 = this;
1791
- return new Promise(function (accept, reject) {
1792
- if (!util_1.Util.canAugment()) {
1793
- return reject(new Error("ViewerController.initAR() - cannot proceed as AR not available in context"));
1794
- }
1795
- var productID = _this24.getAttribute("product-id");
1796
- // use product-id if available
1797
- if (productID) {
1798
- var variationID = _this24.getAttribute("variation-id");
1799
- var variationSKU = _this24.getAttribute("variation-sku");
1800
- var product = new product_ar_1.ProductAR(productID, variationID, variationSKU);
1801
- return product.init().then(accept)["catch"](reject);
1802
- }
1803
- var sceneProductID = _this24.getAttribute("scene-product-id");
1804
- // use scene-product-id if available
1805
- if (sceneProductID) {
1806
- var _variationID = _this24.getAttribute("variation-id");
1807
- var _variationSKU = _this24.getAttribute("variation-sku");
1808
- var _product = new scene_product_ar_1.SceneProductAR(sceneProductID, _variationID, _variationSKU);
1809
- return _product.init().then(accept)["catch"](reject);
1810
- }
1811
- var sceneID = _this24.getAttribute("scene-id");
1812
- // fallback to using default SceneAR implementation
1813
- if (sceneID) {
1814
- // special case - check if scene only has a single product, if so
1815
- // we need to use provided variation-id or variation-sku to override
1816
- var _variationID2 = _this24.getAttribute("variation-id");
1817
- var _variationSKU2 = _this24.getAttribute("variation-sku");
1818
- // just do scene-ar if variation ID and variation SKU is not set
1819
- if (!_variationID2 && !_variationSKU2) {
1820
- var sceneAR = new scene_ar_1.SceneAR(sceneID);
1821
- return sceneAR.init().then(accept)["catch"](reject);
1822
- }
1823
- // otherwise decode scene
1824
- return configurator_state_1.ConfiguratorState.decodeScene(sceneID).then(function (state) {
1825
- var firstProduct = state.first();
1826
- if (state.length > 1 || !firstProduct) {
1827
- return reject(new Error("ViewerController.initAR() - single product required to override variation-id or variation-sku"));
1828
- }
1829
- var product = new scene_product_ar_1.SceneProductAR(firstProduct.scene_product_id, _variationID2, _variationSKU2);
1830
- return product.init().then(accept)["catch"](reject);
1831
- })["catch"](reject);
1832
- }
1833
- return reject(new Error("ViewerController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
1834
- });
1835
- }
1836
- }, {
1837
- key: "removeRenderer",
1838
- value: function removeRenderer() {
1839
- if (this._element) {
1840
- this._element.remove();
1841
- this._element = null;
1842
- return true;
1843
- }
1844
- return false;
1845
- }
1846
- }, {
1847
- key: "element",
1848
- get: function get() {
1849
- return this._element;
1850
- }
1851
- }]);
1852
- return ViewerController;
1853
- }(plattar_controller_1.PlattarController);
1854
- exports.ViewerController = ViewerController;
1855
- }, {
1856
- "../../ar/product-ar": 3,
1857
- "../../ar/scene-ar": 5,
1858
- "../../ar/scene-product-ar": 6,
1859
- "../../util/configurator-state": 14,
1860
- "../../util/util": 15,
1861
- "./plattar-controller": 8,
2286
+ "./plattar-controller": 9,
1862
2287
  "@plattar/plattar-api": 44
1863
2288
  }],
1864
2289
  11: [function (require, module, exports) {
@@ -1869,253 +2294,428 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1869
2294
  });
1870
2295
  exports.VTOController = void 0;
1871
2296
  var plattar_api_1 = require("@plattar/plattar-api");
1872
- var plattar_services_1 = require("@plattar/plattar-services");
1873
2297
  var __1 = require("../..");
1874
- var raw_ar_1 = require("../../ar/raw-ar");
1875
2298
  var util_1 = require("../../util/util");
1876
2299
  var plattar_controller_1 = require("./plattar-controller");
2300
+ var configurator_ar_1 = require("../../ar/configurator-ar");
1877
2301
  /**
1878
2302
  * Manages an instance of the <plattar-configurator> HTML Element
1879
2303
  */
1880
- var VTOController = /*#__PURE__*/function (_plattar_controller_4) {
1881
- _inherits(VTOController, _plattar_controller_4);
2304
+ var VTOController = /*#__PURE__*/function (_plattar_controller_3) {
2305
+ _inherits(VTOController, _plattar_controller_3);
1882
2306
  var _super9 = _createSuper(VTOController);
1883
- function VTOController(parent) {
2307
+ function VTOController() {
2308
+ var _this21;
1884
2309
  _classCallCheck(this, VTOController);
1885
- return _super9.call(this, parent);
2310
+ _this21 = _super9.apply(this, arguments);
2311
+ _this21._cachedConfigState = null;
2312
+ return _this21;
1886
2313
  }
1887
2314
  _createClass(VTOController, [{
2315
+ key: "getConfiguratorState",
2316
+ value: function () {
2317
+ var _getConfiguratorState3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
2318
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2319
+ while (1) switch (_context17.prev = _context17.next) {
2320
+ case 0:
2321
+ if (!this._cachedConfigState) {
2322
+ _context17.next = 2;
2323
+ break;
2324
+ }
2325
+ return _context17.abrupt("return", this._cachedConfigState);
2326
+ case 2:
2327
+ this._cachedConfigState = this.createConfiguratorState();
2328
+ return _context17.abrupt("return", this._cachedConfigState);
2329
+ case 4:
2330
+ case "end":
2331
+ return _context17.stop();
2332
+ }
2333
+ }, _callee17, this);
2334
+ }));
2335
+ function getConfiguratorState() {
2336
+ return _getConfiguratorState3.apply(this, arguments);
2337
+ }
2338
+ return getConfiguratorState;
2339
+ }()
2340
+ }, {
1888
2341
  key: "onAttributesUpdated",
1889
- value: function onAttributesUpdated() {
1890
- var state = this._state;
1891
- // re-render the QR Code when attributes have changed
1892
- if (state === plattar_controller_1.ControllerState.QRCode) {
1893
- this.startQRCode(this._prevQROpt);
1894
- return;
2342
+ value: function () {
2343
+ var _onAttributesUpdated3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(attributeName) {
2344
+ var state, viewer, variationIDs, variationIDsList, variationSKUs, variationSKUList, configState, _variationIDs2, _variationIDsList2, _configState2, _variationSKUs2, _variationSKUList2;
2345
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2346
+ while (1) switch (_context18.prev = _context18.next) {
2347
+ case 0:
2348
+ state = this._state;
2349
+ if (!(state === plattar_controller_1.ControllerState.Renderer)) {
2350
+ _context18.next = 17;
2351
+ break;
2352
+ }
2353
+ viewer = this.element;
2354
+ if (!viewer) {
2355
+ _context18.next = 16;
2356
+ break;
2357
+ }
2358
+ if (!(attributeName === "variation-id")) {
2359
+ _context18.next = 10;
2360
+ break;
2361
+ }
2362
+ variationIDs = this.getAttribute("variation-id");
2363
+ variationIDsList = variationIDs ? variationIDs.split(",") : [];
2364
+ if (!(variationIDsList.length > 0)) {
2365
+ _context18.next = 10;
2366
+ break;
2367
+ }
2368
+ _context18.next = 10;
2369
+ return viewer.messenger.selectVariationID(variationIDsList);
2370
+ case 10:
2371
+ if (!(attributeName === "variation-sku")) {
2372
+ _context18.next = 16;
2373
+ break;
2374
+ }
2375
+ variationSKUs = this.getAttribute("variation-sku");
2376
+ variationSKUList = variationSKUs ? variationSKUs.split(",") : [];
2377
+ if (!(variationSKUList.length > 0)) {
2378
+ _context18.next = 16;
2379
+ break;
2380
+ }
2381
+ _context18.next = 16;
2382
+ return viewer.messenger.selectVariationSKU(variationSKUList);
2383
+ case 16:
2384
+ return _context18.abrupt("return");
2385
+ case 17:
2386
+ if (!(state === plattar_controller_1.ControllerState.QRCode)) {
2387
+ _context18.next = 34;
2388
+ break;
2389
+ }
2390
+ if (!(attributeName === "variation-id")) {
2391
+ _context18.next = 25;
2392
+ break;
2393
+ }
2394
+ _context18.next = 21;
2395
+ return this.getConfiguratorState();
2396
+ case 21:
2397
+ configState = _context18.sent;
2398
+ _variationIDs2 = this.getAttribute("variation-id");
2399
+ _variationIDsList2 = _variationIDs2 ? _variationIDs2.split(",") : [];
2400
+ _variationIDsList2.forEach(function (variationID) {
2401
+ configState.state.setVariationID(variationID);
2402
+ });
2403
+ case 25:
2404
+ if (!(attributeName === "variation-sku")) {
2405
+ _context18.next = 32;
2406
+ break;
2407
+ }
2408
+ _context18.next = 28;
2409
+ return this.getConfiguratorState();
2410
+ case 28:
2411
+ _configState2 = _context18.sent;
2412
+ _variationSKUs2 = this.getAttribute("variation-sku");
2413
+ _variationSKUList2 = _variationSKUs2 ? _variationSKUs2.split(",") : [];
2414
+ _variationSKUList2.forEach(function (variationSKU) {
2415
+ _configState2.state.setVariationSKU(variationSKU);
2416
+ });
2417
+ case 32:
2418
+ this.startQRCode(this._prevQROpt);
2419
+ return _context18.abrupt("return");
2420
+ case 34:
2421
+ case "end":
2422
+ return _context18.stop();
2423
+ }
2424
+ }, _callee18, this);
2425
+ }));
2426
+ function onAttributesUpdated(_x7) {
2427
+ return _onAttributesUpdated3.apply(this, arguments);
1895
2428
  }
1896
- }
2429
+ return onAttributesUpdated;
2430
+ }()
1897
2431
  }, {
1898
2432
  key: "startViewerQRCode",
1899
- value: function startViewerQRCode(options) {
1900
- var _this25 = this;
1901
- return new Promise(function (accept, reject) {
1902
- // remove the old renderer instance if any
1903
- _this25.removeRenderer();
1904
- var sceneID = _this25.getAttribute("scene-id");
1905
- if (sceneID) {
1906
- var opt = options || _this25._GetDefaultQROptions();
1907
- var viewer = document.createElement("plattar-qrcode");
1908
- // required attributes with defaults for plattar-viewer node
1909
- var width = _this25.getAttribute("width") || "500px";
1910
- var height = _this25.getAttribute("height") || "500px";
1911
- viewer.setAttribute("width", width);
1912
- viewer.setAttribute("height", height);
1913
- if (opt.color) {
1914
- viewer.setAttribute("color", opt.color);
1915
- }
1916
- if (opt.margin) {
1917
- viewer.setAttribute("margin", "" + opt.margin);
1918
- }
1919
- if (opt.qrType) {
1920
- viewer.setAttribute("qr-type", opt.qrType);
1921
- }
1922
- viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
1923
- var dst = plattar_api_1.Server.location().base + "renderer/facear.html?scene_id=" + sceneID;
1924
- // optional attributes
1925
- var configState = _this25.getAttribute("config-state");
1926
- var showAR = _this25.getAttribute("show-ar");
1927
- var productID = _this25.getAttribute("product-id");
1928
- var sceneProductID = _this25.getAttribute("scene-product-id");
1929
- var variationID = _this25.getAttribute("variation-id");
1930
- if (configState) {
1931
- dst += "&config_state=" + configState;
1932
- }
1933
- if (showAR) {
1934
- dst += "&show_ar=" + showAR;
1935
- }
1936
- if (productID) {
1937
- dst += "&product_id=" + productID;
1938
- }
1939
- if (sceneProductID) {
1940
- dst += "&scene_product_id=" + sceneProductID;
1941
- }
1942
- if (variationID) {
1943
- dst += "&variation_id=" + variationID;
2433
+ value: function () {
2434
+ var _startViewerQRCode2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(options) {
2435
+ var _this22 = this;
2436
+ var sceneID, opt, viewer, width, height, dst, configState, showAR, productID, sceneProductID, variationID;
2437
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2438
+ while (1) switch (_context19.prev = _context19.next) {
2439
+ case 0:
2440
+ // remove the old renderer instance if any
2441
+ this.removeRenderer();
2442
+ sceneID = this.getAttribute("scene-id");
2443
+ if (sceneID) {
2444
+ _context19.next = 4;
2445
+ break;
2446
+ }
2447
+ throw new Error("VTOController.startQRCode() - minimum required attributes not set, use scene-id as a minimum");
2448
+ case 4:
2449
+ opt = options || this._GetDefaultQROptions();
2450
+ viewer = document.createElement("plattar-qrcode");
2451
+ this._element = viewer;
2452
+ // required attributes with defaults for plattar-viewer node
2453
+ width = this.getAttribute("width") || "500px";
2454
+ height = this.getAttribute("height") || "500px";
2455
+ viewer.setAttribute("width", width);
2456
+ viewer.setAttribute("height", height);
2457
+ if (opt.color) {
2458
+ viewer.setAttribute("color", opt.color);
2459
+ }
2460
+ if (opt.margin) {
2461
+ viewer.setAttribute("margin", "" + opt.margin);
2462
+ }
2463
+ if (opt.qrType) {
2464
+ viewer.setAttribute("qr-type", opt.qrType);
2465
+ }
2466
+ viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
2467
+ dst = plattar_api_1.Server.location().base + "renderer/facear.html?scene_id=" + sceneID; // optional attributes
2468
+ configState = null;
2469
+ _context19.prev = 17;
2470
+ _context19.next = 20;
2471
+ return this.getConfiguratorState();
2472
+ case 20:
2473
+ configState = _context19.sent;
2474
+ _context19.next = 26;
2475
+ break;
2476
+ case 23:
2477
+ _context19.prev = 23;
2478
+ _context19.t0 = _context19["catch"](17);
2479
+ // config state is not available
2480
+ configState = null;
2481
+ case 26:
2482
+ showAR = this.getAttribute("show-ar");
2483
+ productID = this.getAttribute("product-id");
2484
+ sceneProductID = this.getAttribute("scene-product-id");
2485
+ variationID = this.getAttribute("variation-id");
2486
+ if (configState) {
2487
+ dst += "&config_state=" + configState.state.encode();
2488
+ }
2489
+ if (showAR) {
2490
+ dst += "&show_ar=" + showAR;
2491
+ }
2492
+ if (productID) {
2493
+ dst += "&product_id=" + productID;
2494
+ }
2495
+ if (sceneProductID) {
2496
+ dst += "&scene_product_id=" + sceneProductID;
2497
+ }
2498
+ if (variationID) {
2499
+ dst += "&variation_id=" + variationID;
2500
+ }
2501
+ viewer.setAttribute("url", opt.url || dst);
2502
+ this._state = plattar_controller_1.ControllerState.QRCode;
2503
+ this._prevQROpt = opt;
2504
+ return _context19.abrupt("return", new Promise(function (accept, reject) {
2505
+ viewer.onload = function () {
2506
+ return accept(viewer);
2507
+ };
2508
+ _this22.append(viewer);
2509
+ }));
2510
+ case 39:
2511
+ case "end":
2512
+ return _context19.stop();
1944
2513
  }
1945
- viewer.setAttribute("url", opt.url || dst);
1946
- viewer.onload = function () {
1947
- return accept(viewer);
1948
- };
1949
- _this25.append(viewer);
1950
- _this25._element = viewer;
1951
- _this25._state = plattar_controller_1.ControllerState.QRCode;
1952
- _this25._prevQROpt = opt;
1953
- return;
1954
- }
1955
- return reject(new Error("VTOController.startQRCode() - minimum required attributes not set, use scene-id as a minimum"));
1956
- });
1957
- }
2514
+ }, _callee19, this, [[17, 23]]);
2515
+ }));
2516
+ function startViewerQRCode(_x8) {
2517
+ return _startViewerQRCode2.apply(this, arguments);
2518
+ }
2519
+ return startViewerQRCode;
2520
+ }()
1958
2521
  }, {
1959
2522
  key: "startRenderer",
1960
- value: function startRenderer() {
1961
- var _this26 = this;
1962
- return new Promise(function (accept, reject) {
1963
- // remove the old renderer instance if any
1964
- _this26.removeRenderer();
1965
- var sceneID = _this26.getAttribute("scene-id");
1966
- if (sceneID) {
1967
- // required attributes with defaults for plattar-facear node
1968
- var width = _this26.getAttribute("width") || "500px";
1969
- var height = _this26.getAttribute("height") || "500px";
1970
- var server = _this26.getAttribute("server") || "production";
1971
- var viewer = document.createElement("plattar-facear");
1972
- viewer.setAttribute("width", width);
1973
- viewer.setAttribute("height", height);
1974
- viewer.setAttribute("server", server);
1975
- viewer.setAttribute("scene-id", sceneID);
1976
- // optional attributes
1977
- var configState = _this26.getAttribute("config-state");
1978
- var showAR = _this26.getAttribute("show-ar");
1979
- var productID = _this26.getAttribute("product-id");
1980
- var sceneProductID = _this26.getAttribute("scene-product-id");
1981
- var variationID = _this26.getAttribute("variation-id");
1982
- if (configState) {
1983
- viewer.setAttribute("config-state", configState);
1984
- }
1985
- if (showAR) {
1986
- viewer.setAttribute("show-ar", showAR);
1987
- }
1988
- if (productID) {
1989
- viewer.setAttribute("product-id", productID);
1990
- }
1991
- if (sceneProductID) {
1992
- viewer.setAttribute("scene-product-id", sceneProductID);
1993
- }
1994
- if (variationID) {
1995
- viewer.setAttribute("variation-id", variationID);
1996
- }
1997
- viewer.onload = function () {
1998
- return accept(viewer);
1999
- };
2000
- _this26.append(viewer);
2001
- _this26._element = viewer;
2002
- _this26._state = plattar_controller_1.ControllerState.Renderer;
2003
- return;
2004
- }
2005
- return reject(new Error("VTOController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
2006
- });
2007
- }
2523
+ value: function () {
2524
+ var _startRenderer2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2525
+ var _this23 = this;
2526
+ var sceneID, width, height, server, viewer, configState, showAR, productID, sceneProductID, variationID;
2527
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2528
+ while (1) switch (_context20.prev = _context20.next) {
2529
+ case 0:
2530
+ // remove the old renderer instance if any
2531
+ this.removeRenderer();
2532
+ sceneID = this.getAttribute("scene-id");
2533
+ if (sceneID) {
2534
+ _context20.next = 4;
2535
+ break;
2536
+ }
2537
+ throw new Error("VTOController.startRenderer() - minimum required attributes not set, use scene-id as a minimum");
2538
+ case 4:
2539
+ // required attributes with defaults for plattar-facear node
2540
+ width = this.getAttribute("width") || "500px";
2541
+ height = this.getAttribute("height") || "500px";
2542
+ server = this.getAttribute("server") || "production";
2543
+ viewer = document.createElement("plattar-facear");
2544
+ this._element = viewer;
2545
+ viewer.setAttribute("width", width);
2546
+ viewer.setAttribute("height", height);
2547
+ viewer.setAttribute("server", server);
2548
+ viewer.setAttribute("scene-id", sceneID);
2549
+ // optional attributes
2550
+ configState = null;
2551
+ _context20.prev = 14;
2552
+ _context20.next = 17;
2553
+ return this.getConfiguratorState();
2554
+ case 17:
2555
+ configState = _context20.sent;
2556
+ _context20.next = 23;
2557
+ break;
2558
+ case 20:
2559
+ _context20.prev = 20;
2560
+ _context20.t0 = _context20["catch"](14);
2561
+ // config state not available
2562
+ configState = null;
2563
+ case 23:
2564
+ showAR = this.getAttribute("show-ar");
2565
+ productID = this.getAttribute("product-id");
2566
+ sceneProductID = this.getAttribute("scene-product-id");
2567
+ variationID = this.getAttribute("variation-id");
2568
+ if (configState) {
2569
+ viewer.setAttribute("config-state", configState.state.encode());
2570
+ }
2571
+ if (showAR) {
2572
+ viewer.setAttribute("show-ar", showAR);
2573
+ }
2574
+ if (productID) {
2575
+ viewer.setAttribute("product-id", productID);
2576
+ }
2577
+ if (sceneProductID) {
2578
+ viewer.setAttribute("scene-product-id", sceneProductID);
2579
+ }
2580
+ if (variationID) {
2581
+ viewer.setAttribute("variation-id", variationID);
2582
+ }
2583
+ this._state = plattar_controller_1.ControllerState.Renderer;
2584
+ return _context20.abrupt("return", new Promise(function (accept, reject) {
2585
+ _this23.append(viewer);
2586
+ if (configState) {
2587
+ _this23.setupMessengerObservers(viewer, configState);
2588
+ }
2589
+ return accept(viewer);
2590
+ }));
2591
+ case 34:
2592
+ case "end":
2593
+ return _context20.stop();
2594
+ }
2595
+ }, _callee20, this, [[14, 20]]);
2596
+ }));
2597
+ function startRenderer() {
2598
+ return _startRenderer2.apply(this, arguments);
2599
+ }
2600
+ return startRenderer;
2601
+ }()
2008
2602
  }, {
2009
2603
  key: "initAR",
2010
- value: function initAR() {
2011
- var _this27 = this;
2012
- return new Promise(function (accept, reject) {
2013
- if (!util_1.Util.canAugment()) {
2014
- return reject(new Error("VTOController.initAR() - cannot proceed as VTO AR not available in context"));
2015
- }
2016
- if (!(util_1.Util.isSafari() || util_1.Util.isChromeOnIOS())) {
2017
- return reject(new Error("VTOController.initAR() - cannot proceed as VTO AR only available on IOS Mobile devices"));
2018
- }
2019
- var arMode = _this27.getAttribute("ar-mode") || "generated";
2020
- switch (arMode.toLowerCase()) {
2021
- case "inherited":
2022
- _this27._InitARInherited(accept, reject);
2023
- return;
2024
- case "generated":
2025
- default:
2026
- _this27._InitARGenerated(accept, reject);
2027
- }
2028
- });
2029
- }
2604
+ value: function () {
2605
+ var _initAR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2606
+ var arMode;
2607
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2608
+ while (1) switch (_context21.prev = _context21.next) {
2609
+ case 0:
2610
+ if (util_1.Util.canAugment()) {
2611
+ _context21.next = 2;
2612
+ break;
2613
+ }
2614
+ throw new Error("VTOController.initAR() - cannot proceed as VTO AR not available in context");
2615
+ case 2:
2616
+ if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
2617
+ _context21.next = 4;
2618
+ break;
2619
+ }
2620
+ throw new Error("VTOController.initAR() - cannot proceed as VTO AR only available on IOS Mobile devices");
2621
+ case 4:
2622
+ arMode = this.getAttribute("ar-mode") || "generated";
2623
+ _context21.t0 = arMode.toLowerCase();
2624
+ _context21.next = _context21.t0 === "inherited" ? 8 : _context21.t0 === "generated" ? 9 : 9;
2625
+ break;
2626
+ case 8:
2627
+ return _context21.abrupt("return", this._InitARInherited());
2628
+ case 9:
2629
+ return _context21.abrupt("return", this._InitARGenerated());
2630
+ case 10:
2631
+ case "end":
2632
+ return _context21.stop();
2633
+ }
2634
+ }, _callee21, this);
2635
+ }));
2636
+ function initAR() {
2637
+ return _initAR2.apply(this, arguments);
2638
+ }
2639
+ return initAR;
2640
+ }()
2030
2641
  /**
2031
2642
  * Private Function - This launches the Static/Inherited AR Mode
2032
2643
  */
2033
2644
  }, {
2034
2645
  key: "_InitARInherited",
2035
- value: function _InitARInherited(accept, reject) {
2036
- var sceneID = this.getAttribute("scene-id");
2037
- var configState = this.getAttribute("config-state");
2038
- // use config-state if its available
2039
- if (sceneID && configState) {
2040
- var state = __1.ConfiguratorState.decode(configState);
2041
- var first = state.first();
2042
- if (first) {
2043
- var sceneProductAR = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
2044
- sceneProductAR.init().then(accept)["catch"](reject);
2045
- return;
2046
- }
2047
- return reject(new Error("VTOController.initAR() - invalid config-state does not have any product states"));
2048
- }
2049
- // otherwise fallback to using scene
2050
- if (sceneID) {
2051
- __1.ConfiguratorState.decodeScene(sceneID).then(function (state) {
2052
- var first = state.first();
2053
- if (first) {
2054
- var _sceneProductAR2 = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
2055
- return _sceneProductAR2.init().then(accept)["catch"](reject);
2646
+ value: function () {
2647
+ var _InitARInherited3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2648
+ var sceneID, state, first, sceneProductAR;
2649
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2650
+ while (1) switch (_context22.prev = _context22.next) {
2651
+ case 0:
2652
+ sceneID = this.getAttribute("scene-id");
2653
+ if (sceneID) {
2654
+ _context22.next = 3;
2655
+ break;
2656
+ }
2657
+ throw new Error("VTOController.initAR() - inherited AR minimum required attributes not set, use scene-id as a minimum");
2658
+ case 3:
2659
+ _context22.next = 5;
2660
+ return this.getConfiguratorState();
2661
+ case 5:
2662
+ state = _context22.sent.state;
2663
+ first = state.first();
2664
+ if (!first) {
2665
+ _context22.next = 10;
2666
+ break;
2667
+ }
2668
+ sceneProductAR = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
2669
+ return _context22.abrupt("return", sceneProductAR.init());
2670
+ case 10:
2671
+ throw new Error("VTOController.initAR() - invalid decoded config-state does not have any product states");
2672
+ case 11:
2673
+ case "end":
2674
+ return _context22.stop();
2056
2675
  }
2057
- return reject(new Error("VTOController.initAR() - invalid Scene does not have any product states"));
2058
- })["catch"](reject);
2059
- return;
2676
+ }, _callee22, this);
2677
+ }));
2678
+ function _InitARInherited() {
2679
+ return _InitARInherited3.apply(this, arguments);
2060
2680
  }
2061
- return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
2062
- }
2681
+ return _InitARInherited;
2682
+ }()
2063
2683
  /**
2064
2684
  * Private Function - This launches the Dynamic/Generated AR Mode
2065
2685
  */
2066
2686
  }, {
2067
2687
  key: "_InitARGenerated",
2068
- value: function _InitARGenerated(accept, reject) {
2069
- // if scene ID is available and the state is a configurator viewer
2070
- // we can use the real-time configurator state to launch the AR view
2071
- var viewer = this.element;
2072
- var sceneID = this.getAttribute("scene-id");
2073
- if (viewer && sceneID && viewer.messenger) {
2074
- viewer.messenger.getARFile("vto").then(function (result) {
2075
- var rawAR = new raw_ar_1.RawAR(result.filename);
2076
- return rawAR.init().then(accept)["catch"](reject);
2077
- })["catch"](reject);
2078
- return;
2079
- }
2080
- var configState = this.getAttribute("config-state");
2081
- // otherwise scene ID is available to the viewer is not launched
2082
- // we can use the static configuration state to launch the AR view
2083
- if (sceneID && configState) {
2084
- var state = __1.ConfiguratorState.decode(configState);
2085
- if (state.length > 0) {
2086
- var server = this.getAttribute("server") || "production";
2087
- var configurator = new plattar_services_1.Configurator();
2088
- configurator.server = server;
2089
- configurator.output = "vto";
2090
- state.forEach(function (productState) {
2091
- if (productState.meta_data.augment === true) {
2092
- configurator.addSceneProduct(productState.scene_product_id, productState.product_variation_id);
2093
- }
2094
- });
2095
- configurator.get().then(function (result) {
2096
- var rawAR = new raw_ar_1.RawAR(result.filename);
2097
- rawAR.init().then(accept)["catch"](reject);
2098
- })["catch"](reject);
2099
- return;
2100
- }
2101
- return reject(new Error("VTOController.initAR() - invalid config-state does not have any product states"));
2102
- }
2103
- // otherwise no config-state or viewer is active
2104
- // fallback to using default SceneAR implementation
2105
- if (sceneID) {
2106
- var productID = this.getAttribute("product-id");
2107
- var sceneProductID = this.getAttribute("scene-product-id");
2108
- var variationID = this.getAttribute("variation-id");
2109
- var sceneAR = new __1.SceneAR(sceneID, {
2110
- productID: productID ? productID : undefined,
2111
- sceneProductID: sceneProductID ? sceneProductID : undefined,
2112
- variationID: variationID ? variationID : undefined
2113
- });
2114
- sceneAR.init().then(accept)["catch"](reject);
2115
- return;
2688
+ value: function () {
2689
+ var _InitARGenerated3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2690
+ var sceneID, configAR;
2691
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2692
+ while (1) switch (_context23.prev = _context23.next) {
2693
+ case 0:
2694
+ sceneID = this.getAttribute("scene-id");
2695
+ if (sceneID) {
2696
+ _context23.next = 3;
2697
+ break;
2698
+ }
2699
+ throw new Error("VTOController.initAR() - generated AR minimum required attributes not set, use scene-id as a minimum");
2700
+ case 3:
2701
+ _context23.t0 = configurator_ar_1.ConfiguratorAR;
2702
+ _context23.next = 6;
2703
+ return this.getConfiguratorState();
2704
+ case 6:
2705
+ _context23.t1 = _context23.sent;
2706
+ configAR = new _context23.t0(_context23.t1);
2707
+ return _context23.abrupt("return", configAR.init());
2708
+ case 9:
2709
+ case "end":
2710
+ return _context23.stop();
2711
+ }
2712
+ }, _callee23, this);
2713
+ }));
2714
+ function _InitARGenerated() {
2715
+ return _InitARGenerated3.apply(this, arguments);
2116
2716
  }
2117
- return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
2118
- }
2717
+ return _InitARGenerated;
2718
+ }()
2119
2719
  }, {
2120
2720
  key: "removeRenderer",
2121
2721
  value: function removeRenderer() {
@@ -2124,6 +2724,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2124
2724
  this._element = null;
2125
2725
  return true;
2126
2726
  }
2727
+ this.removeMessengerObservers();
2127
2728
  return false;
2128
2729
  }
2129
2730
  }, {
@@ -2137,11 +2738,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2137
2738
  exports.VTOController = VTOController;
2138
2739
  }, {
2139
2740
  "../..": 13,
2140
- "../../ar/raw-ar": 4,
2741
+ "../../ar/configurator-ar": 1,
2141
2742
  "../../util/util": 15,
2142
- "./plattar-controller": 8,
2143
- "@plattar/plattar-api": 44,
2144
- "@plattar/plattar-services": 115
2743
+ "./plattar-controller": 9,
2744
+ "@plattar/plattar-api": 44
2145
2745
  }],
2146
2746
  12: [function (require, module, exports) {
2147
2747
  "use strict";
@@ -2150,18 +2750,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2150
2750
  value: true
2151
2751
  });
2152
2752
  var plattar_api_1 = require("@plattar/plattar-api");
2153
- var product_controller_1 = require("./controllers/product-controller");
2154
- var viewer_controller_1 = require("./controllers/viewer-controller");
2155
2753
  var configurator_controller_1 = require("./controllers/configurator-controller");
2156
2754
  var vto_controller_1 = require("./controllers/vto-controller");
2755
+ var product_controller_1 = require("./controllers/product-controller");
2157
2756
  /**
2158
2757
  * This tracks the current embed type
2159
2758
  */
2160
2759
  var EmbedType;
2161
2760
  (function (EmbedType) {
2162
- EmbedType[EmbedType["Viewer"] = 0] = "Viewer";
2163
- EmbedType[EmbedType["Configurator"] = 1] = "Configurator";
2761
+ EmbedType[EmbedType["Configurator"] = 0] = "Configurator";
2762
+ EmbedType[EmbedType["Legacy"] = 1] = "Legacy";
2164
2763
  EmbedType[EmbedType["VTO"] = 2] = "VTO";
2764
+ EmbedType[EmbedType["None"] = 3] = "None";
2165
2765
  })(EmbedType || (EmbedType = {}));
2166
2766
  /**
2167
2767
  * This is the primary <plattar-embed /> node that allows easy embedding
@@ -2171,132 +2771,250 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2171
2771
  _inherits(PlattarEmbed, _HTMLElement);
2172
2772
  var _super10 = _createSuper(PlattarEmbed);
2173
2773
  function PlattarEmbed() {
2174
- var _this28;
2774
+ var _this24;
2175
2775
  _classCallCheck(this, PlattarEmbed);
2176
- _this28 = _super10.call(this);
2776
+ _this24 = _super10.call(this);
2177
2777
  // this is the current embed type, viewer by default
2178
- _this28._currentType = EmbedType.Viewer;
2179
- _this28._controller = null;
2180
- return _this28;
2778
+ _this24._currentType = EmbedType.None;
2779
+ _this24._controller = null;
2780
+ _this24._currentSceneID = null;
2781
+ _this24._observer = null;
2782
+ return _this24;
2181
2783
  }
2182
2784
  _createClass(PlattarEmbed, [{
2183
2785
  key: "viewer",
2184
2786
  get: function get() {
2185
2787
  return this._controller ? this._controller.element : null;
2186
2788
  }
2789
+ /**
2790
+ * Begin observing all changes to this DOM element
2791
+ */
2187
2792
  }, {
2188
2793
  key: "connectedCallback",
2189
2794
  value: function connectedCallback() {
2190
- var _this29 = this;
2191
- var embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "viewer";
2795
+ this.create();
2796
+ }
2797
+ /**
2798
+ * creates a brand new instance of this embed
2799
+ */
2800
+ }, {
2801
+ key: "create",
2802
+ value: function create() {
2803
+ var _this25 = this;
2804
+ // server cannot be changed once its set - defaults to production
2805
+ var server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
2806
+ plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
2807
+ if (!this._observer) {
2808
+ this._observer = new MutationObserver(function (mutations) {
2809
+ mutations.forEach(function (mutation) {
2810
+ if (mutation.type === "attributes") {
2811
+ var attributeName = mutation.attributeName ? mutation.attributeName : "none";
2812
+ if (_this25._currentType !== EmbedType.Legacy) {
2813
+ _this25._CreateEmbed(attributeName);
2814
+ } else {
2815
+ _this25._OnAttributesUpdated(attributeName);
2816
+ }
2817
+ }
2818
+ });
2819
+ });
2820
+ this._observer.observe(this, {
2821
+ attributes: true
2822
+ });
2823
+ }
2824
+ var sceneID = this.hasAttribute("scene-id") ? this.getAttribute("scene-id") : null;
2825
+ var productID = this.hasAttribute("product-id") ? this.getAttribute("product-id") : null;
2826
+ if (!sceneID && productID) {
2827
+ this._currentType = EmbedType.Legacy;
2828
+ this._CreateLegacyEmbed();
2829
+ return;
2830
+ }
2831
+ this._CreateEmbed("none");
2832
+ }
2833
+ /**
2834
+ * Destroys the active instance of this embed and resets internal state to default
2835
+ */
2836
+ }, {
2837
+ key: "destroy",
2838
+ value: function destroy() {
2839
+ if (this._controller) {
2840
+ this._controller.removeRenderer();
2841
+ this._controller = null;
2842
+ }
2843
+ this._currentType = EmbedType.None;
2844
+ }
2845
+ /**
2846
+ * this is only used for backwards-compatible legacy embed types typically
2847
+ * embedding products with variations (without a scene-id)
2848
+ */
2849
+ }, {
2850
+ key: "_CreateLegacyEmbed",
2851
+ value: function _CreateLegacyEmbed() {
2852
+ this._controller = new product_controller_1.ProductController(this);
2853
+ }
2854
+ /**
2855
+ * creates the embed
2856
+ * this can also be called when attributes/state changes so embeds can be re-loaded
2857
+ */
2858
+ }, {
2859
+ key: "_CreateEmbed",
2860
+ value: function _CreateEmbed(attributeName) {
2861
+ var embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "configurator";
2862
+ var currentEmbed = this._currentType;
2192
2863
  if (embedType) {
2193
2864
  switch (embedType.toLowerCase()) {
2194
- case "viewer":
2195
- this._currentType = EmbedType.Viewer;
2196
- break;
2197
2865
  case "vto":
2198
2866
  this._currentType = EmbedType.VTO;
2199
2867
  break;
2868
+ case "viewer":
2200
2869
  case "configurator":
2201
- this._currentType = EmbedType.Configurator;
2202
- break;
2203
2870
  default:
2204
- this._currentType = EmbedType.Viewer;
2871
+ this._currentType = EmbedType.Configurator;
2205
2872
  }
2206
2873
  }
2207
- var observer = new MutationObserver(function (mutations) {
2208
- mutations.forEach(function (mutation) {
2209
- if (mutation.type === "attributes") {
2210
- _this29._OnAttributesUpdated();
2211
- }
2212
- });
2213
- });
2214
- observer.observe(this, {
2215
- attributes: true
2216
- });
2217
- var server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
2218
- plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
2874
+ // check if the controller needs to be re-created
2875
+ if (currentEmbed !== this._currentType && this._controller) {
2876
+ this._controller.removeRenderer();
2877
+ this._controller = null;
2878
+ }
2219
2879
  var sceneID = this.hasAttribute("scene-id") ? this.getAttribute("scene-id") : null;
2220
- var productID = this.hasAttribute("product-id") ? this.getAttribute("product-id") : null;
2221
- // decide which controller to initialise
2222
- if (this._currentType === EmbedType.Viewer) {
2223
- // initialise product if scene-id is missing but product-id is defined
2224
- if (!sceneID && productID) {
2225
- this._controller = new product_controller_1.ProductController(this);
2226
- } else if (sceneID) {
2227
- this._controller = new viewer_controller_1.ViewerController(this);
2880
+ // if the provided SceneID doesn't match, we need to remove the controller
2881
+ if (sceneID !== this._currentSceneID && this._controller) {
2882
+ this._controller.removeRenderer();
2883
+ this._controller = null;
2884
+ }
2885
+ this._currentSceneID = sceneID;
2886
+ // scene-id is the absolute minimum in order to initialise the embeds
2887
+ if (!this._currentSceneID) {
2888
+ return;
2889
+ }
2890
+ // if the controller was removed due to state-change, we need to re-initialise it
2891
+ if (!this._controller) {
2892
+ switch (this._currentType) {
2893
+ case EmbedType.Configurator:
2894
+ this._controller = new configurator_controller_1.ConfiguratorController(this);
2895
+ break;
2896
+ case EmbedType.VTO:
2897
+ this._controller = new vto_controller_1.VTOController(this);
2898
+ break;
2228
2899
  }
2229
- } else if (this._currentType === EmbedType.Configurator) {
2230
- this._controller = new configurator_controller_1.ConfiguratorController(this);
2231
- } else if (this._currentType === EmbedType.VTO) {
2232
- this._controller = new vto_controller_1.VTOController(this);
2233
- }
2234
- var init = this.hasAttribute("init") ? this.getAttribute("init") : null;
2235
- if (init === "ar") {
2236
- this.startAR();
2237
- } else if (init === "viewer") {
2238
- this.startViewer();
2239
- } else if (init === "qrcode") {
2240
- this.startQRCode();
2241
- } else if (init === "ar-fallback-qrcode") {
2242
- this.startAR().then(function () {
2243
- // nothing to do, launched successfully
2244
- })["catch"](function (_err) {
2245
- _this29.startQRCode();
2246
- });
2247
- } else if (init === "ar-fallback-viewer") {
2248
- this.startAR().then(function () {
2249
- // nothing to do, launched successfully
2250
- })["catch"](function (_err) {
2251
- _this29.startViewer();
2252
- });
2900
+ if (this._controller) {
2901
+ var init = this.hasAttribute("init") ? this.getAttribute("init") : null;
2902
+ switch (init) {
2903
+ case "viewer":
2904
+ this.startViewer();
2905
+ break;
2906
+ case "qrcode":
2907
+ this.startQRCode();
2908
+ break;
2909
+ }
2910
+ }
2911
+ } else {
2912
+ this._OnAttributesUpdated(attributeName);
2253
2913
  }
2254
2914
  }
2255
2915
  }, {
2256
2916
  key: "initAR",
2257
- value: function initAR() {
2258
- var _this30 = this;
2259
- return new Promise(function (accept, reject) {
2260
- if (!_this30._controller) {
2261
- return reject(new Error("PlattarEmbed.initAR() - cannot execute as controller has not loaded yet"));
2262
- }
2263
- return _this30._controller.initAR().then(accept)["catch"](reject);
2264
- });
2265
- }
2917
+ value: function () {
2918
+ var _initAR3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2919
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2920
+ while (1) switch (_context24.prev = _context24.next) {
2921
+ case 0:
2922
+ if (this._controller) {
2923
+ _context24.next = 2;
2924
+ break;
2925
+ }
2926
+ throw new Error("PlattarEmbed.initAR() - cannot execute as controller has not loaded yet");
2927
+ case 2:
2928
+ return _context24.abrupt("return", this._controller.initAR());
2929
+ case 3:
2930
+ case "end":
2931
+ return _context24.stop();
2932
+ }
2933
+ }, _callee24, this);
2934
+ }));
2935
+ function initAR() {
2936
+ return _initAR3.apply(this, arguments);
2937
+ }
2938
+ return initAR;
2939
+ }()
2266
2940
  }, {
2267
2941
  key: "startAR",
2268
- value: function startAR() {
2269
- var _this31 = this;
2270
- return new Promise(function (accept, reject) {
2271
- if (!_this31._controller) {
2272
- return reject(new Error("PlattarEmbed.startAR() - cannot execute as controller has not loaded yet"));
2273
- }
2274
- return _this31._controller.startAR().then(accept)["catch"](reject);
2275
- });
2276
- }
2942
+ value: function () {
2943
+ var _startAR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2944
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2945
+ while (1) switch (_context25.prev = _context25.next) {
2946
+ case 0:
2947
+ if (this._controller) {
2948
+ _context25.next = 2;
2949
+ break;
2950
+ }
2951
+ throw new Error("PlattarEmbed.startAR() - cannot execute as controller has not loaded yet");
2952
+ case 2:
2953
+ return _context25.abrupt("return", this._controller.startAR());
2954
+ case 3:
2955
+ case "end":
2956
+ return _context25.stop();
2957
+ }
2958
+ }, _callee25, this);
2959
+ }));
2960
+ function startAR() {
2961
+ return _startAR2.apply(this, arguments);
2962
+ }
2963
+ return startAR;
2964
+ }()
2277
2965
  }, {
2278
2966
  key: "startViewer",
2279
- value: function startViewer() {
2280
- var _this32 = this;
2281
- return new Promise(function (accept, reject) {
2282
- if (!_this32._controller) {
2283
- return reject(new Error("PlattarEmbed.startViewer() - cannot execute as controller has not loaded yet"));
2284
- }
2285
- return _this32._controller.startRenderer().then(accept)["catch"](reject);
2286
- });
2287
- }
2967
+ value: function () {
2968
+ var _startViewer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2969
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2970
+ while (1) switch (_context26.prev = _context26.next) {
2971
+ case 0:
2972
+ if (this._controller) {
2973
+ _context26.next = 2;
2974
+ break;
2975
+ }
2976
+ throw new Error("PlattarEmbed.startViewer() - cannot execute as controller has not loaded yet");
2977
+ case 2:
2978
+ return _context26.abrupt("return", this._controller.startRenderer());
2979
+ case 3:
2980
+ case "end":
2981
+ return _context26.stop();
2982
+ }
2983
+ }, _callee26, this);
2984
+ }));
2985
+ function startViewer() {
2986
+ return _startViewer.apply(this, arguments);
2987
+ }
2988
+ return startViewer;
2989
+ }()
2288
2990
  }, {
2289
2991
  key: "startQRCode",
2290
- value: function startQRCode() {
2291
- var _this33 = this;
2292
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2293
- return new Promise(function (accept, reject) {
2294
- if (!_this33._controller) {
2295
- return reject(new Error("PlattarEmbed.startQRCode() - cannot execute as controller has not loaded yet"));
2296
- }
2297
- return _this33._controller.startQRCode(options).then(accept)["catch"](reject);
2298
- });
2299
- }
2992
+ value: function () {
2993
+ var _startQRCode2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2994
+ var options,
2995
+ _args27 = arguments;
2996
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2997
+ while (1) switch (_context27.prev = _context27.next) {
2998
+ case 0:
2999
+ options = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : null;
3000
+ if (this._controller) {
3001
+ _context27.next = 3;
3002
+ break;
3003
+ }
3004
+ throw new Error("PlattarEmbed.startQRCode() - cannot execute as controller has not loaded yet");
3005
+ case 3:
3006
+ return _context27.abrupt("return", this._controller.startQRCode(options));
3007
+ case 4:
3008
+ case "end":
3009
+ return _context27.stop();
3010
+ }
3011
+ }, _callee27, this);
3012
+ }));
3013
+ function startQRCode() {
3014
+ return _startQRCode2.apply(this, arguments);
3015
+ }
3016
+ return startQRCode;
3017
+ }()
2300
3018
  /**
2301
3019
  * This will remove the currently active Renderer
2302
3020
  *
@@ -2316,9 +3034,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2316
3034
  */
2317
3035
  }, {
2318
3036
  key: "_OnAttributesUpdated",
2319
- value: function _OnAttributesUpdated() {
3037
+ value: function _OnAttributesUpdated(attributeName) {
2320
3038
  if (this._controller) {
2321
- this._controller.onAttributesUpdated();
3039
+ this._controller.onAttributesUpdated(attributeName);
2322
3040
  }
2323
3041
  }
2324
3042
  }]);
@@ -2326,9 +3044,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2326
3044
  }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
2327
3045
  exports["default"] = PlattarEmbed;
2328
3046
  }, {
2329
- "./controllers/configurator-controller": 7,
2330
- "./controllers/product-controller": 9,
2331
- "./controllers/viewer-controller": 10,
3047
+ "./controllers/configurator-controller": 8,
3048
+ "./controllers/product-controller": 10,
2332
3049
  "./controllers/vto-controller": 11,
2333
3050
  "@plattar/plattar-api": 44
2334
3051
  }],
@@ -2443,12 +3160,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2443
3160
  }
2444
3161
  console.log("using @plattar/plattar-ar-adapter v" + version_1["default"]);
2445
3162
  }, {
2446
- "./ar/launcher-ar": 1,
2447
- "./ar/model-ar": 2,
2448
- "./ar/product-ar": 3,
2449
- "./ar/raw-ar": 4,
2450
- "./ar/scene-ar": 5,
2451
- "./ar/scene-product-ar": 6,
3163
+ "./ar/launcher-ar": 2,
3164
+ "./ar/model-ar": 3,
3165
+ "./ar/product-ar": 4,
3166
+ "./ar/raw-ar": 5,
3167
+ "./ar/scene-ar": 6,
3168
+ "./ar/scene-product-ar": 7,
2452
3169
  "./embed/plattar-embed": 12,
2453
3170
  "./util/configurator-state": 14,
2454
3171
  "./util/util": 15,
@@ -2464,13 +3181,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2464
3181
  });
2465
3182
  exports.ConfiguratorState = void 0;
2466
3183
  var plattar_api_1 = require("@plattar/plattar-api");
3184
+ /**
3185
+ * Manages a Configuration State of multiple Products with multiple Variations
3186
+ * Allows easily changing
3187
+ */
2467
3188
  var ConfiguratorState = /*#__PURE__*/function () {
2468
3189
  function ConfiguratorState() {
2469
3190
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2470
3191
  _classCallCheck(this, ConfiguratorState);
3192
+ this._mappedVariationIDValues = new Map();
3193
+ this._mappedVariationSKUValues = new Map();
2471
3194
  var defaultState = {
2472
3195
  meta: {
2473
3196
  scene_product_index: 0,
3197
+ scene_model_index: 0,
2474
3198
  product_variation_index: 1,
2475
3199
  meta_index: 2
2476
3200
  },
@@ -2483,6 +3207,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2483
3207
  // set the meta data
2484
3208
  if (parsedState.meta) {
2485
3209
  defaultState.meta.scene_product_index = parsedState.meta.scene_product_index || 0;
3210
+ defaultState.meta.scene_model_index = parsedState.meta.scene_model_index || 0;
2486
3211
  defaultState.meta.product_variation_index = parsedState.meta.product_variation_index || 1;
2487
3212
  defaultState.meta.meta_index = parsedState.meta.meta_index || 2;
2488
3213
  }
@@ -2495,18 +3220,79 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2495
3220
  this._state = defaultState;
2496
3221
  }
2497
3222
  /**
2498
- * Adds a new Scene Product/Variation combo with meta-data into the Configurator State
2499
- *
2500
- * @param sceneProductID - The Scene Product ID to be used (as defined in Plattar CMS)
2501
- * @param productVariationID - The Product Variation ID to be used (as defined in Plattar CMS)
2502
- * @param metaData - Arbitrary meta-data that can be used against certain operaions
3223
+ * Modifyes the SceneProduct that this Variation SKU belongs to and changes for
3224
+ * purposes of Configuration
2503
3225
  */
2504
3226
  _createClass(ConfiguratorState, [{
3227
+ key: "setVariationSKU",
3228
+ value: function setVariationSKU(productVariationSKU) {
3229
+ var variationID = this._mappedVariationSKUValues.get(productVariationSKU);
3230
+ if (!variationID) {
3231
+ console.warn("ConfiguratorState.setVariationSKU() - Variation SKU of " + productVariationSKU + " is not defined in any variations");
3232
+ return;
3233
+ }
3234
+ this.setVariationID(variationID);
3235
+ }
3236
+ /**
3237
+ * Modifyes the SceneProduct that this Variation belongs to and changes for
3238
+ * purposes of Configuration
3239
+ */
3240
+ }, {
3241
+ key: "setVariationID",
3242
+ value: function setVariationID(productVariationID) {
3243
+ var sceneProductID = this._mappedVariationIDValues.get(productVariationID);
3244
+ if (!sceneProductID) {
3245
+ console.warn("ConfiguratorState.setVariationID() - Variation ID of " + productVariationID + " is not defined in any products");
3246
+ return;
3247
+ }
3248
+ this.setSceneProduct(sceneProductID, productVariationID);
3249
+ }
3250
+ /**
3251
+ * Adds a new Scene Product/Variation combo with meta-data into the Configurator State
3252
+ *
3253
+ * @param sceneProductID - The Scene Product ID to be used (as defined in Plattar CMS)
3254
+ * @param productVariationID - The Product Variation ID to be used (as defined in Plattar CMS)
3255
+ * @param metaData - Arbitrary meta-data that can be used against certain operaions
3256
+ */
3257
+ }, {
2505
3258
  key: "setSceneProduct",
2506
3259
  value: function setSceneProduct(sceneProductID, productVariationID) {
2507
3260
  var metaData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2508
3261
  this.addSceneProduct(sceneProductID, productVariationID, metaData);
2509
3262
  }
3263
+ /**
3264
+ * Adds a new SceneModel with meta-data into the Configurator State. Note that the SceneProductDataMeta will
3265
+ * override the isSceneModel variable and assign to "true" automatically
3266
+ *
3267
+ * @param SceneModelID - The SceneModel ID to add
3268
+ * @param metaData - Arbitrary meta-data that can be used against certain operaions
3269
+ */
3270
+ }, {
3271
+ key: "setSceneModel",
3272
+ value: function setSceneModel(SceneModelID) {
3273
+ var metaData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
3274
+ if (SceneModelID) {
3275
+ metaData = metaData || {
3276
+ augment: true,
3277
+ type: "scenemodel"
3278
+ };
3279
+ metaData.type = "scenemodel";
3280
+ var states = this._state.states;
3281
+ var meta = this._state.meta;
3282
+ var newData = null;
3283
+ var existingData = this.findSceneProductIndex(SceneModelID);
3284
+ if (existingData) {
3285
+ newData = existingData;
3286
+ } else {
3287
+ newData = [];
3288
+ // push the new data into the stack
3289
+ states.push(newData);
3290
+ }
3291
+ newData[meta.scene_product_index] = SceneModelID;
3292
+ newData[meta.product_variation_index] = null;
3293
+ newData[meta.meta_index] = metaData;
3294
+ }
3295
+ }
2510
3296
  /**
2511
3297
  * Adds a new Scene Product/Variation combo with meta-data into the Configurator State
2512
3298
  *
@@ -2519,6 +3305,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2519
3305
  value: function addSceneProduct(sceneProductID, productVariationID) {
2520
3306
  var metaData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2521
3307
  if (sceneProductID && productVariationID) {
3308
+ metaData = metaData || {
3309
+ augment: true,
3310
+ type: "sceneproduct"
3311
+ };
3312
+ metaData.type = "sceneproduct";
2522
3313
  var states = this._state.states;
2523
3314
  var meta = this._state.meta;
2524
3315
  var newData = null;
@@ -2532,9 +3323,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2532
3323
  }
2533
3324
  newData[meta.scene_product_index] = sceneProductID;
2534
3325
  newData[meta.product_variation_index] = productVariationID;
2535
- if (metaData) {
2536
- newData[meta.meta_index] = metaData;
2537
- }
3326
+ newData[meta.meta_index] = metaData;
2538
3327
  }
2539
3328
  }
2540
3329
  /**
@@ -2570,12 +3359,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2570
3359
  scene_product_id: found[meta.scene_product_index],
2571
3360
  product_variation_id: found[meta.product_variation_index],
2572
3361
  meta_data: {
2573
- augment: true
3362
+ augment: true,
3363
+ type: "sceneproduct"
2574
3364
  }
2575
3365
  };
2576
3366
  // include the meta-data
2577
3367
  if (found.length === 3) {
2578
3368
  data.meta_data.augment = found[meta.meta_index].augment || true;
3369
+ data.meta_data.type = found[meta.meta_index].type || "sceneproduct";
2579
3370
  }
2580
3371
  return data;
2581
3372
  }
@@ -2596,7 +3387,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2596
3387
  scene_product_id: productState[meta.scene_product_index],
2597
3388
  product_variation_id: productState[meta.product_variation_index],
2598
3389
  meta_data: {
2599
- augment: true
3390
+ augment: true,
3391
+ type: "sceneproduct"
2600
3392
  }
2601
3393
  });
2602
3394
  } else if (productState.length === 3) {
@@ -2604,13 +3396,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2604
3396
  scene_product_id: productState[meta.scene_product_index],
2605
3397
  product_variation_id: productState[meta.product_variation_index],
2606
3398
  meta_data: {
2607
- augment: productState[meta.meta_index].augment || true
3399
+ augment: productState[meta.meta_index].augment || true,
3400
+ type: productState[meta.meta_index].type || "sceneproduct"
2608
3401
  }
2609
3402
  });
2610
3403
  }
2611
3404
  });
2612
3405
  }
2613
3406
  }
3407
+ /**
3408
+ * Compose and return an array of all internal objects
3409
+ */
3410
+ }, {
3411
+ key: "array",
3412
+ value: function array() {
3413
+ var array = new Array();
3414
+ this.forEach(function (object) {
3415
+ array.push(object);
3416
+ });
3417
+ return array;
3418
+ }
2614
3419
  /**
2615
3420
  * @returns Returns the first reference of data in the stack, otherwise returns null
2616
3421
  */
@@ -2632,12 +3437,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2632
3437
  scene_product_id: found[meta.scene_product_index],
2633
3438
  product_variation_id: found[meta.product_variation_index],
2634
3439
  meta_data: {
2635
- augment: true
3440
+ augment: true,
3441
+ type: "sceneproduct"
2636
3442
  }
2637
3443
  };
2638
3444
  // include the meta-data
2639
3445
  if (found.length === 3) {
2640
3446
  data.meta_data.augment = found[meta.meta_index].augment || true;
3447
+ data.meta_data.type = found[meta.meta_index].type || "sceneproduct";
2641
3448
  }
2642
3449
  return data;
2643
3450
  }
@@ -2669,6 +3476,58 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2669
3476
  value: function decode(state) {
2670
3477
  return new ConfiguratorState(state);
2671
3478
  }
3479
+ /**
3480
+ * Decodes a previously generated state
3481
+ * @param sceneID
3482
+ * @param state
3483
+ * @returns
3484
+ */
3485
+ }, {
3486
+ key: "decodeState",
3487
+ value: function () {
3488
+ var _decodeState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
3489
+ var sceneID,
3490
+ state,
3491
+ configState,
3492
+ fscene,
3493
+ scene,
3494
+ _args28 = arguments;
3495
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3496
+ while (1) switch (_context28.prev = _context28.next) {
3497
+ case 0:
3498
+ sceneID = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : null;
3499
+ state = _args28.length > 1 && _args28[1] !== undefined ? _args28[1] : null;
3500
+ if (!(!sceneID || !state)) {
3501
+ _context28.next = 4;
3502
+ break;
3503
+ }
3504
+ throw new Error("ConfiguratorState.decodeState(sceneID, state) - sceneID and state must be defined");
3505
+ case 4:
3506
+ configState = new ConfiguratorState(state);
3507
+ fscene = new plattar_api_1.Scene(sceneID);
3508
+ fscene.include(plattar_api_1.Project);
3509
+ fscene.include(plattar_api_1.SceneProduct);
3510
+ fscene.include(plattar_api_1.SceneModel);
3511
+ fscene.include(plattar_api_1.SceneProduct.include(plattar_api_1.Product.include(plattar_api_1.ProductVariation)));
3512
+ _context28.next = 12;
3513
+ return fscene.get();
3514
+ case 12:
3515
+ scene = _context28.sent;
3516
+ return _context28.abrupt("return", {
3517
+ scene: scene,
3518
+ state: configState
3519
+ });
3520
+ case 14:
3521
+ case "end":
3522
+ return _context28.stop();
3523
+ }
3524
+ }, _callee28);
3525
+ }));
3526
+ function decodeState() {
3527
+ return _decodeState.apply(this, arguments);
3528
+ }
3529
+ return decodeState;
3530
+ }()
2672
3531
  /**
2673
3532
  * Generates a new ConfiguratorState instance from all SceneProducts and default
2674
3533
  * variations from the provided Scene ID
@@ -2677,33 +3536,78 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2677
3536
  */
2678
3537
  }, {
2679
3538
  key: "decodeScene",
2680
- value: function decodeScene() {
2681
- var sceneID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2682
- return new Promise(function (accept, reject) {
2683
- var configState = new ConfiguratorState();
2684
- if (!sceneID) {
2685
- return reject(new Error("ConfiguratorState.decodeScene(sceneID) - sceneID must be defined"));
2686
- }
2687
- var scene = new plattar_api_1.Scene(sceneID);
2688
- scene.include(plattar_api_1.SceneProduct);
2689
- scene.include(plattar_api_1.SceneProduct.include(plattar_api_1.Product));
2690
- scene.get().then(function (scene) {
2691
- var sceneProducts = scene.relationships.filter(plattar_api_1.SceneProduct);
2692
- // nothing to do if no AR components can be found
2693
- if (sceneProducts.length <= 0) {
2694
- return accept(configState);
3539
+ value: function () {
3540
+ var _decodeScene = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
3541
+ var sceneID,
3542
+ configState,
3543
+ fscene,
3544
+ scene,
3545
+ sceneProducts,
3546
+ sceneModels,
3547
+ _args29 = arguments;
3548
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3549
+ while (1) switch (_context29.prev = _context29.next) {
3550
+ case 0:
3551
+ sceneID = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : null;
3552
+ if (sceneID) {
3553
+ _context29.next = 3;
3554
+ break;
3555
+ }
3556
+ throw new Error("ConfiguratorState.decodeScene(sceneID) - sceneID must be defined");
3557
+ case 3:
3558
+ configState = new ConfiguratorState();
3559
+ fscene = new plattar_api_1.Scene(sceneID);
3560
+ fscene.include(plattar_api_1.Project);
3561
+ fscene.include(plattar_api_1.SceneProduct);
3562
+ fscene.include(plattar_api_1.SceneModel);
3563
+ fscene.include(plattar_api_1.SceneProduct.include(plattar_api_1.Product.include(plattar_api_1.ProductVariation)));
3564
+ _context29.next = 11;
3565
+ return fscene.get();
3566
+ case 11:
3567
+ scene = _context29.sent;
3568
+ sceneProducts = scene.relationships.filter(plattar_api_1.SceneProduct);
3569
+ sceneModels = scene.relationships.filter(plattar_api_1.SceneModel); // add out scene models
3570
+ sceneModels.forEach(function (sceneModel) {
3571
+ configState.setSceneModel(sceneModel.id, {
3572
+ augment: sceneModel.attributes.include_in_augment,
3573
+ type: "scenemodel"
3574
+ });
3575
+ });
3576
+ // add out scene products
3577
+ sceneProducts.forEach(function (sceneProduct) {
3578
+ var product = sceneProduct.relationships.find(plattar_api_1.Product);
3579
+ if (product) {
3580
+ if (product.attributes.product_variation_id) {
3581
+ configState.setSceneProduct(sceneProduct.id, product.attributes.product_variation_id, {
3582
+ augment: sceneProduct.attributes.include_in_augment,
3583
+ type: "sceneproduct"
3584
+ });
3585
+ }
3586
+ // add the variation to an acceptible range of values
3587
+ var variations = product.relationships.filter(plattar_api_1.ProductVariation);
3588
+ variations.forEach(function (variation) {
3589
+ configState._mappedVariationIDValues.set(variation.id, sceneProduct.id);
3590
+ if (variation.attributes.sku) {
3591
+ configState._mappedVariationSKUValues.set(variation.attributes.sku, variation.id);
3592
+ }
3593
+ });
3594
+ }
3595
+ });
3596
+ return _context29.abrupt("return", {
3597
+ scene: scene,
3598
+ state: configState
3599
+ });
3600
+ case 17:
3601
+ case "end":
3602
+ return _context29.stop();
2695
3603
  }
2696
- // add out scene models
2697
- sceneProducts.forEach(function (sceneProduct) {
2698
- var product = sceneProduct.relationships.find(plattar_api_1.Product);
2699
- if (product && product.attributes.product_variation_id) {
2700
- configState.setSceneProduct(sceneProduct.id, product.attributes.product_variation_id);
2701
- }
2702
- });
2703
- accept(configState);
2704
- })["catch"](reject);
2705
- });
2706
- }
3604
+ }, _callee29);
3605
+ }));
3606
+ function decodeScene() {
3607
+ return _decodeScene.apply(this, arguments);
3608
+ }
3609
+ return decodeScene;
3610
+ }()
2707
3611
  }]);
2708
3612
  return ConfiguratorState;
2709
3613
  }();
@@ -2825,7 +3729,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2825
3729
  Object.defineProperty(exports, "__esModule", {
2826
3730
  value: true
2827
3731
  });
2828
- exports["default"] = "1.154.2";
3732
+ exports["default"] = "1.155.1";
2829
3733
  }, {}],
2830
3734
  17: [function (require, module, exports) {
2831
3735
  "use strict";
@@ -2856,13 +3760,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2856
3760
  _inherits(QuicklookViewer, _ar_viewer_1$default);
2857
3761
  var _super11 = _createSuper(QuicklookViewer);
2858
3762
  function QuicklookViewer() {
2859
- var _this34;
3763
+ var _this26;
2860
3764
  _classCallCheck(this, QuicklookViewer);
2861
- _this34 = _super11.call(this);
2862
- _this34.araction = null;
2863
- _this34.titleHTML = "&checkoutTitle=" + document.title + "&checkoutSubtitle=" + document.title;
2864
- _this34.arcallback = function () {};
2865
- return _this34;
3765
+ _this26 = _super11.call(this);
3766
+ _this26.araction = null;
3767
+ _this26.titleHTML = "&checkoutTitle=" + document.title + "&checkoutSubtitle=" + document.title;
3768
+ _this26.arcallback = function () {};
3769
+ return _this26;
2866
3770
  }
2867
3771
  _createClass(QuicklookViewer, [{
2868
3772
  key: "nodeType",
@@ -2877,7 +3781,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2877
3781
  }, {
2878
3782
  key: "start",
2879
3783
  value: function start() {
2880
- var _this35 = this;
3784
+ var _this27 = this;
2881
3785
  if (!this.modelUrl) {
2882
3786
  throw new Error("QuicklookViewer.start() - model url not set, use QuicklookViewer.modelUrl");
2883
3787
  }
@@ -2889,7 +3793,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2889
3793
  if (araction) {
2890
3794
  var handleQuicklook = function handleQuicklook(event) {
2891
3795
  if (event.data === "_apple_ar_quicklook_button_tapped") {
2892
- _this35.arcallback();
3796
+ _this27.arcallback();
2893
3797
  }
2894
3798
  document.body.removeChild(anchor);
2895
3799
  anchor.removeEventListener("message", handleQuicklook, false);
@@ -2975,14 +3879,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2975
3879
  _inherits(SceneViewer, _ar_viewer_1$default3);
2976
3880
  var _super13 = _createSuper(SceneViewer);
2977
3881
  function SceneViewer() {
2978
- var _this36;
3882
+ var _this28;
2979
3883
  _classCallCheck(this, SceneViewer);
2980
- _this36 = _super13.call(this);
2981
- _this36.araction = null;
2982
- _this36.isVertical = false;
2983
- _this36.titleHTML = "<b>" + document.title;
2984
- _this36.isVertical = false;
2985
- return _this36;
3884
+ _this28 = _super13.call(this);
3885
+ _this28.araction = null;
3886
+ _this28.isVertical = false;
3887
+ _this28.titleHTML = "<b>" + document.title;
3888
+ _this28.isVertical = false;
3889
+ return _this28;
2986
3890
  }
2987
3891
  _createClass(SceneViewer, [{
2988
3892
  key: "nodeType",
@@ -3079,16 +3983,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3079
3983
  */
3080
3984
  var Memory = /*#__PURE__*/function () {
3081
3985
  function Memory(messengerInstance) {
3082
- var _this37 = this;
3986
+ var _this29 = this;
3083
3987
  _classCallCheck(this, Memory);
3084
3988
  this._messenger = messengerInstance;
3085
3989
  this._tempMemory = new TemporaryMemory(messengerInstance);
3086
3990
  this._permMemory = new PermanentMemory(messengerInstance);
3087
3991
  this._messenger.self.__memory__set_temp_var = function (name, data) {
3088
- _this37._tempMemory[name] = data;
3992
+ _this29._tempMemory[name] = data;
3089
3993
  };
3090
3994
  this._messenger.self.__memory__set_perm_var = function (name, data) {
3091
- _this37._permMemory[name] = data;
3995
+ _this29._permMemory[name] = data;
3092
3996
  };
3093
3997
  }
3094
3998
  _createClass(Memory, [{
@@ -3535,17 +4439,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3535
4439
  }, {
3536
4440
  key: "exec",
3537
4441
  value: function exec() {
3538
- var _this38 = this;
4442
+ var _this30 = this;
3539
4443
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
3540
4444
  args[_key3] = arguments[_key3];
3541
4445
  }
3542
4446
  return new Promise(function (accept, reject) {
3543
- if (!_this38._value) {
3544
- return reject(new Error("WrappedLocalFunction.exec() function with name " + _this38._funcName + "() is not defined"));
4447
+ if (!_this30._value) {
4448
+ return reject(new Error("WrappedLocalFunction.exec() function with name " + _this30._funcName + "() is not defined"));
3545
4449
  }
3546
4450
  try {
3547
4451
  // otherwise execute the function
3548
- var rObject = _this38._execute.apply(_this38, args);
4452
+ var rObject = _this30._execute.apply(_this30, args);
3549
4453
 
3550
4454
  // we need to check if the returned object is a Promise, if so, handle it
3551
4455
  // differently. This can happen if the function wants to execute asyn
@@ -3611,7 +4515,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3611
4515
  _createClass(FunctionObserver, [{
3612
4516
  key: "subscribe",
3613
4517
  value: function subscribe(functionName, callback) {
3614
- var _this39 = this;
4518
+ var _this31 = this;
3615
4519
  if (!functionName || !Util.isFunction(callback)) {
3616
4520
  return function () {};
3617
4521
  }
@@ -3625,7 +4529,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3625
4529
  }
3626
4530
  list.push(callback);
3627
4531
  return function () {
3628
- return _this39.unsubscribe(functionName, callback);
4532
+ return _this31.unsubscribe(functionName, callback);
3629
4533
  };
3630
4534
  }
3631
4535
 
@@ -3692,7 +4596,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3692
4596
  */
3693
4597
  var GlobalEventHandler = /*#__PURE__*/function () {
3694
4598
  function GlobalEventHandler() {
3695
- var _this40 = this;
4599
+ var _this32 = this;
3696
4600
  _classCallCheck(this, GlobalEventHandler);
3697
4601
  this._eventListeners = {};
3698
4602
 
@@ -3712,11 +4616,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3712
4616
  // make sure the event is properly formatted
3713
4617
  if (jsonData && jsonData.event && jsonData.data) {
3714
4618
  // see if there are any listeners for this
3715
- if (_this40._eventListeners[jsonData.event]) {
4619
+ if (_this32._eventListeners[jsonData.event]) {
3716
4620
  var remoteInterface = new RemoteInterface(evt.source, evt.origin);
3717
4621
 
3718
4622
  // loop through and call all the event handlers
3719
- _this40._eventListeners[jsonData.event].forEach(function (callback) {
4623
+ _this32._eventListeners[jsonData.event].forEach(function (callback) {
3720
4624
  try {
3721
4625
  callback(remoteInterface, jsonData.data);
3722
4626
  } catch (e) {
@@ -3908,33 +4812,33 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3908
4812
  }, {
3909
4813
  key: "_registerListeners",
3910
4814
  value: function _registerListeners() {
3911
- var _this41 = this;
4815
+ var _this33 = this;
3912
4816
  GlobalEventHandler.instance().listen("__messenger__child_init", function (src, data) {
3913
4817
  var iframeID = src.id;
3914
4818
 
3915
4819
  // check reserved key list
3916
4820
  switch (iframeID) {
3917
4821
  case undefined:
3918
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID cannot be undefined");
4822
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID cannot be undefined");
3919
4823
  case "self":
3920
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
4824
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
3921
4825
  case "parent":
3922
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
4826
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
3923
4827
  case "id":
3924
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
4828
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
3925
4829
  case "onload":
3926
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
4830
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
3927
4831
  default:
3928
4832
  break;
3929
4833
  }
3930
4834
 
3931
4835
  // initialise the child iframe as a messenger pipe
3932
- _this41[iframeID] = new RemoteFunctionList(iframeID, _this41._functionObserver);
3933
- _this41[iframeID].setup(new RemoteInterface(src.source, src.origin));
4836
+ _this33[iframeID] = new RemoteFunctionList(iframeID, _this33._functionObserver);
4837
+ _this33[iframeID].setup(new RemoteInterface(src.source, src.origin));
3934
4838
 
3935
4839
  // add the interface to the broadcaster
3936
- _this41._broadcaster._push(iframeID);
3937
- var callbacks = _this41._callbacks;
4840
+ _this33._broadcaster._push(iframeID);
4841
+ var callbacks = _this33._callbacks;
3938
4842
 
3939
4843
  // we have registered callbacks, begin execution
3940
4844
  if (callbacks.has(iframeID)) {
@@ -3958,26 +4862,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3958
4862
  // check reserved key list
3959
4863
  switch (iframeID) {
3960
4864
  case undefined:
3961
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID cannot be undefined");
4865
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID cannot be undefined");
3962
4866
  case "self":
3963
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
4867
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
3964
4868
  case "parent":
3965
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
4869
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
3966
4870
  case "id":
3967
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
4871
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
3968
4872
  case "onload":
3969
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
4873
+ throw new Error("Messenger[" + _this33._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
3970
4874
  default:
3971
4875
  break;
3972
4876
  }
3973
4877
 
3974
4878
  // initialise the child iframe as a messenger pipe
3975
- _this41[iframeID] = new RemoteFunctionList(iframeID, _this41._functionObserver);
3976
- _this41[iframeID].setup(new RemoteInterface(src.source, src.origin));
4879
+ _this33[iframeID] = new RemoteFunctionList(iframeID, _this33._functionObserver);
4880
+ _this33[iframeID].setup(new RemoteInterface(src.source, src.origin));
3977
4881
 
3978
4882
  // add the interface to the broadcaster
3979
- _this41._broadcaster._push(iframeID);
3980
- var callbacks = _this41._callbacks;
4883
+ _this33._broadcaster._push(iframeID);
4884
+ var callbacks = _this33._callbacks;
3981
4885
 
3982
4886
  // we have registered callbacks, begin execution
3983
4887
  if (callbacks.has(iframeID)) {
@@ -3996,9 +4900,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3996
4900
  });
3997
4901
  GlobalEventHandler.instance().listen("__messenger__parent_init", function (src, data) {
3998
4902
  var iframeID = "parent";
3999
- _this41[iframeID] = new RemoteFunctionList(iframeID, _this41._functionObserver);
4000
- _this41[iframeID].setup(new RemoteInterface(src.source, src.origin));
4001
- var callbacks = _this41._callbacks;
4903
+ _this33[iframeID] = new RemoteFunctionList(iframeID, _this33._functionObserver);
4904
+ _this33[iframeID].setup(new RemoteInterface(src.source, src.origin));
4905
+ var callbacks = _this33._callbacks;
4002
4906
 
4003
4907
  // we have registered callbacks, begin execution
4004
4908
  if (callbacks.has(iframeID)) {
@@ -4022,9 +4926,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4022
4926
  */
4023
4927
  GlobalEventHandler.instance().listen("__messenger__parent_init_inv", function (src, data) {
4024
4928
  var iframeID = "parent";
4025
- _this41[iframeID] = new RemoteFunctionList(iframeID, _this41._functionObserver);
4026
- _this41[iframeID].setup(new RemoteInterface(src.source, src.origin));
4027
- var callbacks = _this41._callbacks;
4929
+ _this33[iframeID] = new RemoteFunctionList(iframeID, _this33._functionObserver);
4930
+ _this33[iframeID].setup(new RemoteInterface(src.source, src.origin));
4931
+ var callbacks = _this33._callbacks;
4028
4932
 
4029
4933
  // we have registered callbacks, begin execution
4030
4934
  if (callbacks.has(iframeID)) {
@@ -4246,7 +5150,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4246
5150
  */
4247
5151
  var WrappedRemoteFunction = /*#__PURE__*/function () {
4248
5152
  function WrappedRemoteFunction(funcName, remoteInterface, functionObserver) {
4249
- var _this42 = this;
5153
+ var _this34 = this;
4250
5154
  _classCallCheck(this, WrappedRemoteFunction);
4251
5155
  this._funcName = funcName;
4252
5156
  this._remoteInterface = remoteInterface;
@@ -4258,24 +5162,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4258
5162
  var instanceID = data.instance_id;
4259
5163
 
4260
5164
  // the function name must match
4261
- if (data.function_name !== _this42._funcName) {
5165
+ if (data.function_name !== _this34._funcName) {
4262
5166
  return;
4263
5167
  }
4264
5168
 
4265
5169
  // the instance ID must be found, otherwise this is a rogue execution
4266
5170
  // that can be ignored (should not happen)
4267
- if (!_this42._callInstances[instanceID]) {
5171
+ if (!_this34._callInstances[instanceID]) {
4268
5172
  return;
4269
5173
  }
4270
- var promise = _this42._callInstances[instanceID];
5174
+ var promise = _this34._callInstances[instanceID];
4271
5175
 
4272
5176
  // remove the old instance
4273
- delete _this42._callInstances[instanceID];
5177
+ delete _this34._callInstances[instanceID];
4274
5178
 
4275
5179
  // perform the promise callbacks
4276
5180
  if (data.function_status === "success") {
4277
5181
  // execute the observers
4278
- _this42._functionObserver.call(_this42._funcName, {
5182
+ _this34._functionObserver.call(_this34._funcName, {
4279
5183
  type: "return",
4280
5184
  state: "success",
4281
5185
  data: data.function_args
@@ -4283,7 +5187,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4283
5187
  promise.accept(data.function_args);
4284
5188
  } else {
4285
5189
  // execute the observers
4286
- _this42._functionObserver.call(_this42._funcName, {
5190
+ _this34._functionObserver.call(_this34._funcName, {
4287
5191
  type: "return",
4288
5192
  state: "exception",
4289
5193
  data: new Error(data.function_args)
@@ -4299,7 +5203,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4299
5203
  _createClass(WrappedRemoteFunction, [{
4300
5204
  key: "exec",
4301
5205
  value: function exec() {
4302
- var _this43 = this;
5206
+ var _this35 = this;
4303
5207
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
4304
5208
  args[_key4] = arguments[_key4];
4305
5209
  }
@@ -4318,20 +5222,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4318
5222
  // to be executed later
4319
5223
  return new Promise(function (accept, reject) {
4320
5224
  // save this promise to be executed later
4321
- _this43._callInstances[instanceID] = {
5225
+ _this35._callInstances[instanceID] = {
4322
5226
  accept: accept,
4323
5227
  reject: reject
4324
5228
  };
4325
5229
 
4326
5230
  // execute this event in another context
4327
- _this43._remoteInterface.send("__messenger__exec_fnc", {
5231
+ _this35._remoteInterface.send("__messenger__exec_fnc", {
4328
5232
  instance_id: instanceID,
4329
- function_name: _this43._funcName,
5233
+ function_name: _this35._funcName,
4330
5234
  function_args: args
4331
5235
  });
4332
5236
 
4333
5237
  // execute the observers
4334
- _this43._functionObserver.call(_this43._funcName, {
5238
+ _this35._functionObserver.call(_this35._funcName, {
4335
5239
  type: "call",
4336
5240
  state: "success",
4337
5241
  data: args
@@ -4480,7 +5384,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4480
5384
  var google_analytics_1 = require("./google/google-analytics");
4481
5385
  var Analytics = /*#__PURE__*/function () {
4482
5386
  function Analytics(applicationID) {
4483
- var _this44 = this;
5387
+ var _this36 = this;
4484
5388
  _classCallCheck(this, Analytics);
4485
5389
  this._pageTime = null;
4486
5390
  this.origin = "production";
@@ -4494,17 +5398,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4494
5398
  this._ga = new google_analytics_1.GoogleAnalytics();
4495
5399
  this._handlePageHide = function () {
4496
5400
  if (document.visibilityState === "hidden") {
4497
- _this44._pageTime = new Date();
4498
- } else if (_this44._pageTime) {
5401
+ _this36._pageTime = new Date();
5402
+ } else if (_this36._pageTime) {
4499
5403
  var time2 = new Date();
4500
- var diff = time2.getTime() - _this44._pageTime.getTime();
4501
- var data = _this44.data;
5404
+ var diff = time2.getTime() - _this36._pageTime.getTime();
5405
+ var data = _this36.data;
4502
5406
  data.push("eventAction", "View Time");
4503
5407
  data.push("viewTime", diff);
4504
5408
  data.push("eventLabel", diff);
4505
- _this44.write();
4506
- _this44._pageTime = null;
4507
- document.removeEventListener("visibilitychange", _this44._handlePageHide, false);
5409
+ _this36.write();
5410
+ _this36._pageTime = null;
5411
+ document.removeEventListener("visibilitychange", _this36._handlePageHide, false);
4508
5412
  }
4509
5413
  };
4510
5414
  }
@@ -4516,18 +5420,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4516
5420
  }, {
4517
5421
  key: "query",
4518
5422
  value: function query() {
4519
- var _this45 = this;
5423
+ var _this37 = this;
4520
5424
  var _query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
4521
5425
  return new Promise(function (accept, reject) {
4522
5426
  if (!_query) {
4523
5427
  return reject(new Error("Analytics.query() - provided query was null"));
4524
5428
  }
4525
- var url = _this45.origin === "dev" ? "https://localhost:3008/v3/read" : "https://analytics.plattar.com/v3/read";
5429
+ var url = _this37.origin === "dev" ? "https://localhost:3008/v3/read" : "https://analytics.plattar.com/v3/read";
4526
5430
  var data = {
4527
5431
  data: {
4528
5432
  attributes: {
4529
- application_id: _this45._applicationID,
4530
- event: _this45.event,
5433
+ application_id: _this37._applicationID,
5434
+ event: _this37.event,
4531
5435
  query: _query
4532
5436
  }
4533
5437
  }
@@ -4540,22 +5444,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4540
5444
  }, {
4541
5445
  key: "write",
4542
5446
  value: function write() {
4543
- var _this46 = this;
5447
+ var _this38 = this;
4544
5448
  return new Promise(function (accept, reject) {
4545
- var data = _this46._data;
4546
- var url = _this46.origin === "dev" ? "https://localhost:3008/v3/write" : "https://analytics.plattar.com/v3/write";
4547
- data.push("applicationId", _this46._applicationID);
5449
+ var data = _this38._data;
5450
+ var url = _this38.origin === "dev" ? "https://localhost:3008/v3/write" : "https://analytics.plattar.com/v3/write";
5451
+ data.push("applicationId", _this38._applicationID);
4548
5452
  var sendData = {
4549
5453
  data: {
4550
5454
  attributes: {
4551
- application_id: _this46._applicationID,
4552
- event: _this46.event,
4553
- origin: _this46.origin,
5455
+ application_id: _this38._applicationID,
5456
+ event: _this38.event,
5457
+ origin: _this38.origin,
4554
5458
  fields: data.data
4555
5459
  }
4556
5460
  }
4557
5461
  };
4558
- if (_this46.isBeacon === false) {
5462
+ if (_this38.isBeacon === false) {
4559
5463
  basic_http_1["default"].exec("POST", url, sendData).then(function (result) {
4560
5464
  accept(result ? result : {});
4561
5465
  })["catch"](reject);
@@ -4564,7 +5468,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4564
5468
  accept(result ? result : {});
4565
5469
  })["catch"](reject);
4566
5470
  }
4567
- _this46.googleAnalytics.write(_this46.event, _this46.data);
5471
+ _this38.googleAnalytics.write(_this38.event, _this38.data);
4568
5472
  });
4569
5473
  }
4570
5474
  }, {
@@ -5116,10 +6020,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5116
6020
  }, {
5117
6021
  key: "_get",
5118
6022
  value: function _get(opt) {
5119
- var _this47 = this;
6023
+ var _this39 = this;
5120
6024
  return new Promise(function (resolve, reject) {
5121
- var target = _this47.target;
5122
- var server = _this47.server;
6025
+ var target = _this39.target;
6026
+ var server = _this39.server;
5123
6027
 
5124
6028
  // we cannot perform a GET request without an ID
5125
6029
  if (!target.id) {
@@ -5144,15 +6048,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5144
6048
  var origin = server.originLocation.api_read;
5145
6049
  var auth = server.authToken;
5146
6050
  var headers = {
5147
- 'cookie': 'laravel_session=' + _this47.getCookie('laravel_session')
6051
+ 'cookie': 'laravel_session=' + _this39.getCookie('laravel_session')
5148
6052
  };
5149
6053
  Object.assign(headers, auth);
5150
6054
  var reqopts = {
5151
6055
  method: "GET",
5152
6056
  headers: headers
5153
6057
  };
5154
- var includeQuery = _this47._IncludeQuery;
5155
- var params = _this47._ParamFor("get");
6058
+ var includeQuery = _this39._IncludeQuery;
6059
+ var params = _this39._ParamFor("get");
5156
6060
  var endpoint = origin + target.type() + "/" + target.id;
5157
6061
  if (includeQuery) {
5158
6062
  endpoint = endpoint + "?include=" + includeQuery;
@@ -5187,10 +6091,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5187
6091
  }, {
5188
6092
  key: "_update",
5189
6093
  value: function _update() {
5190
- var _this48 = this;
6094
+ var _this40 = this;
5191
6095
  return new Promise(function (resolve, reject) {
5192
- var target = _this48.target;
5193
- var server = _this48.server;
6096
+ var target = _this40.target;
6097
+ var server = _this40.server;
5194
6098
 
5195
6099
  // we cannot perform a GET request without an ID
5196
6100
  if (!target.id) {
@@ -5204,7 +6108,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5204
6108
  var headers = {
5205
6109
  'Accept': 'application/json',
5206
6110
  'Content-Type': 'application/json',
5207
- 'cookie': 'laravel_session=' + _this48.getCookie('laravel_session')
6111
+ 'cookie': 'laravel_session=' + _this40.getCookie('laravel_session')
5208
6112
  };
5209
6113
  Object.assign(headers, auth);
5210
6114
  var reqopts = {
@@ -5218,7 +6122,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5218
6122
  meta: target.meta || {}
5219
6123
  })
5220
6124
  };
5221
- var params = _this48._ParamFor("update");
6125
+ var params = _this40._ParamFor("update");
5222
6126
  var endpoint = origin + target.type() + "/" + target.id;
5223
6127
  if (params) {
5224
6128
  var appender = "?";
@@ -5254,10 +6158,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5254
6158
  }, {
5255
6159
  key: "_create",
5256
6160
  value: function _create() {
5257
- var _this49 = this;
6161
+ var _this41 = this;
5258
6162
  return new Promise(function (resolve, reject) {
5259
- var target = _this49.target;
5260
- var server = _this49.server;
6163
+ var target = _this41.target;
6164
+ var server = _this41.server;
5261
6165
 
5262
6166
  // otherwise, proceed with the fetching op
5263
6167
  var origin = server.originLocation.api_write;
@@ -5265,7 +6169,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5265
6169
  var headers = {
5266
6170
  'Accept': 'application/json',
5267
6171
  'Content-Type': 'application/json',
5268
- 'cookie': 'laravel_session=' + _this49.getCookie('laravel_session')
6172
+ 'cookie': 'laravel_session=' + _this41.getCookie('laravel_session')
5269
6173
  };
5270
6174
  Object.assign(headers, auth);
5271
6175
  var reqopts = {
@@ -5278,7 +6182,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5278
6182
  meta: target.meta || {}
5279
6183
  })
5280
6184
  };
5281
- var params = _this49._ParamFor("create");
6185
+ var params = _this41._ParamFor("create");
5282
6186
  var endpoint = origin + target.type();
5283
6187
  if (params) {
5284
6188
  var appender = "?";
@@ -5315,10 +6219,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5315
6219
  }, {
5316
6220
  key: "_delete",
5317
6221
  value: function _delete() {
5318
- var _this50 = this;
6222
+ var _this42 = this;
5319
6223
  return new Promise(function (resolve, reject) {
5320
- var target = _this50.target;
5321
- var server = _this50.server;
6224
+ var target = _this42.target;
6225
+ var server = _this42.server;
5322
6226
 
5323
6227
  // we cannot perform a GET request without an ID
5324
6228
  if (!target.id) {
@@ -5332,7 +6236,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5332
6236
  var headers = {
5333
6237
  'Accept': 'application/json',
5334
6238
  'Content-Type': 'application/json',
5335
- 'cookie': 'laravel_session=' + _this50.getCookie('laravel_session')
6239
+ 'cookie': 'laravel_session=' + _this42.getCookie('laravel_session')
5336
6240
  };
5337
6241
  Object.assign(headers, auth);
5338
6242
  var reqopts = {
@@ -5346,7 +6250,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5346
6250
  meta: target.meta || {}
5347
6251
  })
5348
6252
  };
5349
- var params = _this50._ParamFor("delete");
6253
+ var params = _this42._ParamFor("delete");
5350
6254
  var endpoint = origin + target.type() + "/" + target.id;
5351
6255
  if (params) {
5352
6256
  var appender = "?";
@@ -5401,7 +6305,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5401
6305
  }, {
5402
6306
  key: "_include",
5403
6307
  value: function _include(args) {
5404
- var _this51 = this;
6308
+ var _this43 = this;
5405
6309
  if (!args || args.length <= 0) {
5406
6310
  return this;
5407
6311
  }
@@ -5411,20 +6315,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5411
6315
  if (Array.isArray(obj)) {
5412
6316
  obj.forEach(function (strObject) {
5413
6317
  if (typeof strObject === "string" || strObject instanceof String) {
5414
- _this51._getIncludeQuery.push(strObject);
6318
+ _this43._getIncludeQuery.push(strObject);
5415
6319
  } else {
5416
- throw new Error("PlattarQuery." + _this51.target.type() + ".include(...args) - argument of Array must only include Strings");
6320
+ throw new Error("PlattarQuery." + _this43.target.type() + ".include(...args) - argument of Array must only include Strings");
5417
6321
  }
5418
6322
  });
5419
6323
  } else if (PlattarUtil.isPlattarObject(obj)) {
5420
6324
  var type = obj.type();
5421
6325
  if (Array.isArray(type)) {
5422
- _this51._include(type);
6326
+ _this43._include(type);
5423
6327
  } else {
5424
- _this51._getIncludeQuery.push(type);
6328
+ _this43._getIncludeQuery.push(type);
5425
6329
  }
5426
6330
  } else {
5427
- throw new Error("PlattarQuery." + _this51.target.type() + ".include(...args) - argument must be of type PlattarObject or Array but was type=" + _typeof(obj) + " value=" + obj);
6331
+ throw new Error("PlattarQuery." + _this43.target.type() + ".include(...args) - argument must be of type PlattarObject or Array but was type=" + _typeof(obj) + " value=" + obj);
5428
6332
  }
5429
6333
  });
5430
6334
  return this;
@@ -5559,12 +6463,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5559
6463
  }, {
5560
6464
  key: "auth",
5561
6465
  value: function auth(token, opt) {
5562
- var _this52 = this;
6466
+ var _this44 = this;
5563
6467
  var copt = opt || {
5564
6468
  validate: false
5565
6469
  };
5566
6470
  return new Promise(function (resolve, reject) {
5567
- var server = _this52.originLocation.api_write;
6471
+ var server = _this44.originLocation.api_write;
5568
6472
  if (!server) {
5569
6473
  reject(new Error("Plattar.auth(token) - cannot authenticate as server not set via Plattar.origin(server)"));
5570
6474
  return;
@@ -5574,10 +6478,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5574
6478
  return;
5575
6479
  }
5576
6480
  if (!copt.validate) {
5577
- _this52._authToken = {
6481
+ _this44._authToken = {
5578
6482
  "plattar-auth-token": token
5579
6483
  };
5580
- resolve(_this52);
6484
+ resolve(_this44);
5581
6485
  return;
5582
6486
  }
5583
6487
  var endpoint = server + "plattaruser/xauth/validate";
@@ -5589,10 +6493,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5589
6493
  };
5590
6494
  fetch(endpoint, options).then(function (res) {
5591
6495
  if (res.ok) {
5592
- _this52._authToken = {
6496
+ _this44._authToken = {
5593
6497
  "plattar-auth-token": token
5594
6498
  };
5595
- resolve(_this52);
6499
+ resolve(_this44);
5596
6500
  } else {
5597
6501
  reject(new Error("Plattar.auth(token) - failed to validate authentication token at " + endpoint));
5598
6502
  }
@@ -5602,7 +6506,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5602
6506
  }, {
5603
6507
  key: "origin",
5604
6508
  value: function origin(server, opt) {
5605
- var _this53 = this;
6509
+ var _this45 = this;
5606
6510
  var copt = opt || {
5607
6511
  validate: false
5608
6512
  };
@@ -5612,8 +6516,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5612
6516
  return;
5613
6517
  }
5614
6518
  if (!copt.validate) {
5615
- _this53._serverLocation = server;
5616
- resolve(_this53);
6519
+ _this45._serverLocation = server;
6520
+ resolve(_this45);
5617
6521
  return;
5618
6522
  }
5619
6523
  var endpoint = server.api_read + "ping";
@@ -5622,8 +6526,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5622
6526
  };
5623
6527
  fetch(endpoint, options).then(function (res) {
5624
6528
  if (res.ok) {
5625
- _this53._serverLocation = server;
5626
- resolve(_this53);
6529
+ _this45._serverLocation = server;
6530
+ resolve(_this45);
5627
6531
  } else {
5628
6532
  reject(new Error("Plattar.origin(server) - failed to ping server at " + endpoint));
5629
6533
  }
@@ -5957,13 +6861,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5957
6861
  _inherits(FileBase, _PlattarBase11);
5958
6862
  var _super25 = _createSuper(FileBase);
5959
6863
  function FileBase(id, server) {
5960
- var _this54;
6864
+ var _this46;
5961
6865
  _classCallCheck(this, FileBase);
5962
- _this54 = _super25.call(this, id, server || Server["default"]());
5963
- if (_this54.constructor === FileBase) {
6866
+ _this46 = _super25.call(this, id, server || Server["default"]());
6867
+ if (_this46.constructor === FileBase) {
5964
6868
  throw new Error("FileBase is abstract and cannot be created");
5965
6869
  }
5966
- return _this54;
6870
+ return _this46;
5967
6871
  }
5968
6872
  _createClass(FileBase, [{
5969
6873
  key: "sourcePath",
@@ -6116,13 +7020,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6116
7020
  _inherits(PlattarBase, _PlattarObject);
6117
7021
  var _super30 = _createSuper(PlattarBase);
6118
7022
  function PlattarBase(id, server) {
6119
- var _this55;
7023
+ var _this47;
6120
7024
  _classCallCheck(this, PlattarBase);
6121
- _this55 = _super30.call(this, id, server || Server["default"]());
6122
- if (_this55.constructor === PlattarBase) {
7025
+ _this47 = _super30.call(this, id, server || Server["default"]());
7026
+ if (_this47.constructor === PlattarBase) {
6123
7027
  throw new Error("PlattarBase is abstract and cannot be created");
6124
7028
  }
6125
- return _this55;
7029
+ return _this47;
6126
7030
  }
6127
7031
  return _createClass(PlattarBase);
6128
7032
  }(PlattarObject);
@@ -6189,7 +7093,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6189
7093
  }, {
6190
7094
  key: "filter",
6191
7095
  value: function filter(obj, id) {
6192
- var _this56 = this;
7096
+ var _this48 = this;
6193
7097
  if (!obj) {
6194
7098
  return [];
6195
7099
  }
@@ -6205,7 +7109,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6205
7109
  if (Array.isArray(type)) {
6206
7110
  var compiledList = [];
6207
7111
  type.forEach(function (inObject) {
6208
- var retArray = _this56.filter(inObject, id);
7112
+ var retArray = _this48.filter(inObject, id);
6209
7113
  if (retArray.length > 0) {
6210
7114
  compiledList = compiledList.concat(retArray);
6211
7115
  }
@@ -6393,7 +7297,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6393
7297
  }, {
6394
7298
  key: "include",
6395
7299
  value: function include() {
6396
- var _this57 = this;
7300
+ var _this49 = this;
6397
7301
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
6398
7302
  args[_key6] = arguments[_key6];
6399
7303
  }
@@ -6406,15 +7310,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6406
7310
  if (Array.isArray(obj)) {
6407
7311
  obj.forEach(function (strObject) {
6408
7312
  if (typeof strObject === "string" || strObject instanceof String) {
6409
- includes.push("".concat(_this57.type(), ".").concat(strObject));
7313
+ includes.push("".concat(_this49.type(), ".").concat(strObject));
6410
7314
  } else {
6411
- throw new Error("PlattarObject." + _this57.type() + ".include(...args) - argument of Array must only include Strings");
7315
+ throw new Error("PlattarObject." + _this49.type() + ".include(...args) - argument of Array must only include Strings");
6412
7316
  }
6413
7317
  });
6414
7318
  } else if (obj.prototype instanceof PlattarObject) {
6415
- includes.push("".concat(_this57.type(), ".").concat(obj.type()));
7319
+ includes.push("".concat(_this49.type(), ".").concat(obj.type()));
6416
7320
  } else {
6417
- throw new Error("PlattarObject." + _this57.type() + ".include(...args) - argument must be of type PlattarObject or Array but was type=" + _typeof(obj) + " value=" + obj);
7321
+ throw new Error("PlattarObject." + _this49.type() + ".include(...args) - argument must be of type PlattarObject or Array but was type=" + _typeof(obj) + " value=" + obj);
6418
7322
  }
6419
7323
  });
6420
7324
  return includes;
@@ -6544,13 +7448,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6544
7448
  _inherits(CardBase, _PlattarBase17);
6545
7449
  var _super36 = _createSuper(CardBase);
6546
7450
  function CardBase(id, server) {
6547
- var _this58;
7451
+ var _this50;
6548
7452
  _classCallCheck(this, CardBase);
6549
- _this58 = _super36.call(this, id, server || Server["default"]());
6550
- if (_this58.constructor === CardBase) {
7453
+ _this50 = _super36.call(this, id, server || Server["default"]());
7454
+ if (_this50.constructor === CardBase) {
6551
7455
  throw new Error("CardBase is abstract and cannot be created");
6552
7456
  }
6553
- return _this58;
7457
+ return _this50;
6554
7458
  }
6555
7459
  _createClass(CardBase, null, [{
6556
7460
  key: "type",
@@ -6867,13 +7771,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6867
7771
  _inherits(ProductBase, _PlattarBase19);
6868
7772
  var _super50 = _createSuper(ProductBase);
6869
7773
  function ProductBase(id, server) {
6870
- var _this59;
7774
+ var _this51;
6871
7775
  _classCallCheck(this, ProductBase);
6872
- _this59 = _super50.call(this, id, server || Server["default"]());
6873
- if (_this59.constructor === ProductBase) {
7776
+ _this51 = _super50.call(this, id, server || Server["default"]());
7777
+ if (_this51.constructor === ProductBase) {
6874
7778
  throw new Error("ProductBase is abstract and cannot be created");
6875
7779
  }
6876
- return _this59;
7780
+ return _this51;
6877
7781
  }
6878
7782
  _createClass(ProductBase, null, [{
6879
7783
  key: "type",
@@ -6983,13 +7887,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6983
7887
  _inherits(SceneBase, _PlattarBase21);
6984
7888
  var _super55 = _createSuper(SceneBase);
6985
7889
  function SceneBase(id, server) {
6986
- var _this60;
7890
+ var _this52;
6987
7891
  _classCallCheck(this, SceneBase);
6988
- _this60 = _super55.call(this, id, server || Server["default"]());
6989
- if (_this60.constructor === SceneBase) {
7892
+ _this52 = _super55.call(this, id, server || Server["default"]());
7893
+ if (_this52.constructor === SceneBase) {
6990
7894
  throw new Error("SceneBase is abstract and cannot be created");
6991
7895
  }
6992
- return _this60;
7896
+ return _this52;
6993
7897
  }
6994
7898
  _createClass(SceneBase, null, [{
6995
7899
  key: "type",
@@ -7692,15 +8596,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7692
8596
  _createClass(BaseElement, [{
7693
8597
  key: "connectedCallback",
7694
8598
  value: function connectedCallback() {
7695
- var _this61 = this;
8599
+ var _this53 = this;
7696
8600
  if (this.hasAttribute("url")) {
7697
8601
  this.renderQRCode();
7698
8602
  }
7699
8603
  var observer = new MutationObserver(function (mutations) {
7700
8604
  mutations.forEach(function (mutation) {
7701
8605
  if (mutation.type === "attributes") {
7702
- if (_this61.hasAttribute("url")) {
7703
- _this61.renderQRCode();
8606
+ if (_this53.hasAttribute("url")) {
8607
+ _this53.renderQRCode();
7704
8608
  }
7705
8609
  }
7706
8610
  });
@@ -7723,7 +8627,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7723
8627
  }, {
7724
8628
  key: "renderQRCode",
7725
8629
  value: function renderQRCode() {
7726
- var _this62 = this;
8630
+ var _this54 = this;
7727
8631
  var url = this.hasAttribute("url") ? this.getAttribute("url") : undefined;
7728
8632
  if (!url) {
7729
8633
  console.warn("PlattarQR.renderQRCode() - required attribute \"url\" is missing or invalid, QR Code will not render");
@@ -7831,11 +8735,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7831
8735
  var shortenURL = this.hasAttribute("shorten") ? this.getAttribute("shorten") : "false";
7832
8736
  if (shortenURL && shortenURL.toLowerCase() === "true") {
7833
8737
  this._ShortenURL(url).then(function (newURL) {
7834
- _this62._GenerateQRCode(newURL, width, height);
8738
+ _this54._GenerateQRCode(newURL, width, height);
7835
8739
  })["catch"](function (_err) {
7836
8740
  console.warn(_err);
7837
8741
  // ignore error and just generate normal QR Code
7838
- _this62._GenerateQRCode(url, width, height);
8742
+ _this54._GenerateQRCode(url, width, height);
7839
8743
  });
7840
8744
  } else {
7841
8745
  this._GenerateQRCode(url, width, height);
@@ -7904,9 +8808,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7904
8808
  }, {
7905
8809
  key: "_ShortenURL",
7906
8810
  value: function _ShortenURL(url) {
7907
- var _this63 = this;
8811
+ var _this55 = this;
7908
8812
  return new Promise(function (accept, reject) {
7909
- if (!_this63._IsFetchAPISupported()) {
8813
+ if (!_this55._IsFetchAPISupported()) {
7910
8814
  return reject(new Error("PlattarQR._ShortenURL() - fetch api not supported, cannot proceed"));
7911
8815
  }
7912
8816
  try {
@@ -8099,10 +9003,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8099
9003
  }, {
8100
9004
  key: "get",
8101
9005
  value: function get() {
8102
- var _this64 = this;
9006
+ var _this56 = this;
8103
9007
  return new Promise(function (accept, reject) {
8104
- _this64._CalculateHash().then(function () {
8105
- remote_request_1.RemoteRequest.request(_this64._GetPayload(), _this64.retry < 0 ? 0 : _this64.retry).then(accept)["catch"](reject);
9008
+ _this56._CalculateHash().then(function () {
9009
+ remote_request_1.RemoteRequest.request(_this56._GetPayload(), _this56.retry < 0 ? 0 : _this56.retry).then(accept)["catch"](reject);
8106
9010
  })["catch"](function (_err) {
8107
9011
  reject(new Error("Configurator.get() - one of the objects does not exist in Plattar API"));
8108
9012
  });
@@ -8111,12 +9015,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8111
9015
  }, {
8112
9016
  key: "_CalculateHash",
8113
9017
  value: function _CalculateHash() {
8114
- var _this65 = this;
9018
+ var _this57 = this;
8115
9019
  return new Promise(function (accept, reject) {
8116
9020
  var promises = [];
8117
9021
  var oldOrigin = plattar_api_1.Server["default"]().originLocation.type;
8118
- plattar_api_1.Server.create(plattar_api_1.Server.match(_this65.server));
8119
- _this65._maps.forEach(function (map) {
9022
+ plattar_api_1.Server.create(plattar_api_1.Server.match(_this57.server));
9023
+ _this57._maps.forEach(function (map) {
8120
9024
  if (map.productvariation) {
8121
9025
  promises.push(new plattar_api_1.ProductVariation(map.productvariation).get());
8122
9026
  }
@@ -8132,7 +9036,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8132
9036
  });
8133
9037
  Promise.all(promises).then(function (values) {
8134
9038
  values.forEach(function (value) {
8135
- _this65._attrHash.push(value.attributes);
9039
+ _this57._attrHash.push(value.attributes);
8136
9040
  });
8137
9041
  // reset server back
8138
9042
  plattar_api_1.Server.create(plattar_api_1.Server.match(oldOrigin));
@@ -8219,12 +9123,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8219
9123
  }, {
8220
9124
  key: "get",
8221
9125
  value: function get() {
8222
- var _this66 = this;
9126
+ var _this58 = this;
8223
9127
  return new Promise(function (accept, reject) {
8224
- if (!_this66._model) {
9128
+ if (!_this58._model) {
8225
9129
  return reject(new Error("ModelConverter.get() - required .model attribute was not set"));
8226
9130
  }
8227
- remote_request_1.RemoteRequest.request(_this66._Payload, _this66.retry < 0 ? 0 : _this66.retry).then(accept)["catch"](reject);
9131
+ remote_request_1.RemoteRequest.request(_this58._Payload, _this58.retry < 0 ? 0 : _this58.retry).then(accept)["catch"](reject);
8228
9132
  });
8229
9133
  }
8230
9134
  }, {
@@ -9589,18 +10493,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9589
10493
  }, {
9590
10494
  key: "allMappedAttributes",
9591
10495
  get: function get() {
9592
- var _this67 = this;
10496
+ var _this59 = this;
9593
10497
  var map = new Map();
9594
10498
  var coreAttr = this.coreAttributes;
9595
10499
  var optAttr = this.optionalAttributes;
9596
10500
  coreAttr.forEach(function (ele) {
9597
- if (_this67.hasAttribute(ele.key)) {
9598
- map.set(ele.map, _this67.getAttribute(ele.key));
10501
+ if (_this59.hasAttribute(ele.key)) {
10502
+ map.set(ele.map, _this59.getAttribute(ele.key));
9599
10503
  }
9600
10504
  });
9601
10505
  optAttr.forEach(function (ele) {
9602
- if (_this67.hasAttribute(ele.key)) {
9603
- map.set(ele.map, _this67.getAttribute(ele.key));
10506
+ if (_this59.hasAttribute(ele.key)) {
10507
+ map.set(ele.map, _this59.getAttribute(ele.key));
9604
10508
  }
9605
10509
  });
9606
10510
  return map;
@@ -9700,7 +10604,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9700
10604
  var IFrameController = require("./iframe-controller.js");
9701
10605
  var ElementController = /*#__PURE__*/function () {
9702
10606
  function ElementController(element) {
9703
- var _this68 = this;
10607
+ var _this60 = this;
9704
10608
  _classCallCheck(this, ElementController);
9705
10609
  this._element = element;
9706
10610
 
@@ -9713,7 +10617,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9713
10617
  var mutation = _step8.value;
9714
10618
  if (mutation.type === 'attributes' && element.usesAttribute(mutation.attributeName)) {
9715
10619
  if (element.hasAllCoreAttributes) {
9716
- _this68._load();
10620
+ _this60._load();
9717
10621
  }
9718
10622
  }
9719
10623
  }
@@ -9808,7 +10712,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9808
10712
  var Util = require("../../util/util.js");
9809
10713
  var IFrameController = /*#__PURE__*/function () {
9810
10714
  function IFrameController(element, src, id) {
9811
- var _this69 = this;
10715
+ var _this61 = this;
9812
10716
  var onelemload = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
9813
10717
  _classCallCheck(this, IFrameController);
9814
10718
  this._iframe = document.createElement("iframe");
@@ -9818,7 +10722,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9818
10722
  if (!element.hasAttribute("sameorigin")) {
9819
10723
  this._iframe.onload = function () {
9820
10724
  if (onelemload) {
9821
- onelemload(_this69._iframe);
10725
+ onelemload(_this61._iframe);
9822
10726
  }
9823
10727
  };
9824
10728
  }
@@ -9935,13 +10839,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9935
10839
  _inherits(EWallElement, _BaseElement4);
9936
10840
  var _super76 = _createSuper(EWallElement);
9937
10841
  function EWallElement() {
9938
- var _this70;
10842
+ var _this62;
9939
10843
  _classCallCheck(this, EWallElement);
9940
- _this70 = _super76.call(this);
10844
+ _this62 = _super76.call(this);
9941
10845
  var tag = document.createElement("script");
9942
10846
  tag.src = "https://cdn.8thwall.com/web/iframe/iframe.js";
9943
10847
  tag.defer = true;
9944
- return _this70;
10848
+ return _this62;
9945
10849
  }
9946
10850
  _createClass(EWallElement, [{
9947
10851
  key: "connectedCallback",