@plattar/plattar-ar-adapter 1.154.2 → 1.155.2

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
+ }
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
+ }
1329
1854
  });
1330
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
+ }
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,15 +2192,88 @@ 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"));
1551
2202
  });
1552
2203
  }
2204
+ /**
2205
+ * Displays a QR Code that sends the user direct to AR
2206
+ * @param options
2207
+ * @returns
2208
+ */
2209
+ }, {
2210
+ key: "startARQRCode",
2211
+ value: function startARQRCode(options) {
2212
+ var _this19 = this;
2213
+ return new Promise(function (accept, reject) {
2214
+ // remove the old renderer instance if any
2215
+ _this19.removeRenderer();
2216
+ var opt = options || _this19._GetDefaultQROptions();
2217
+ var viewer = document.createElement("plattar-qrcode");
2218
+ // required attributes with defaults for plattar-viewer node
2219
+ var width = _this19.getAttribute("width") || "500px";
2220
+ var height = _this19.getAttribute("height") || "500px";
2221
+ viewer.setAttribute("width", width);
2222
+ viewer.setAttribute("height", height);
2223
+ if (opt.color) {
2224
+ viewer.setAttribute("color", opt.color);
2225
+ }
2226
+ if (opt.margin) {
2227
+ viewer.setAttribute("margin", "" + opt.margin);
2228
+ }
2229
+ if (opt.qrType) {
2230
+ viewer.setAttribute("qr-type", opt.qrType);
2231
+ }
2232
+ viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
2233
+ var qrOptions = btoa(JSON.stringify(opt));
2234
+ var dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
2235
+ var sceneID = _this19.getAttribute("scene-id");
2236
+ var configState = _this19.getAttribute("config-state");
2237
+ var embedType = _this19.getAttribute("embed-type");
2238
+ var productID = _this19.getAttribute("product-id");
2239
+ var sceneProductID = _this19.getAttribute("scene-product-id");
2240
+ var variationID = _this19.getAttribute("variation-id");
2241
+ var variationSKU = _this19.getAttribute("variation-sku");
2242
+ var arMode = _this19.getAttribute("ar-mode");
2243
+ if (configState) {
2244
+ dst += "&config_state=" + configState;
2245
+ }
2246
+ if (embedType) {
2247
+ dst += "&embed_type=" + embedType;
2248
+ }
2249
+ if (productID) {
2250
+ dst += "&product_id=" + productID;
2251
+ }
2252
+ if (sceneProductID) {
2253
+ dst += "&scene_product_id=" + sceneProductID;
2254
+ }
2255
+ if (variationID) {
2256
+ dst += "&variation_id=" + variationID;
2257
+ }
2258
+ if (variationSKU) {
2259
+ dst += "&variation_sku=" + variationSKU;
2260
+ }
2261
+ if (arMode) {
2262
+ dst += "&ar_mode=" + arMode;
2263
+ }
2264
+ if (sceneID) {
2265
+ dst += "&scene_id=" + sceneID;
2266
+ }
2267
+ viewer.setAttribute("url", opt.url || dst);
2268
+ viewer.onload = function () {
2269
+ return accept(viewer);
2270
+ };
2271
+ _this19._element = viewer;
2272
+ _this19._state = plattar_controller_1.ControllerState.QRCode;
2273
+ _this19._prevQROpt = opt;
2274
+ _this19.append(viewer);
2275
+ });
2276
+ }
1553
2277
  }, {
1554
2278
  key: "startRenderer",
1555
2279
  value: function startRenderer() {
@@ -1630,235 +2354,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1630
2354
  }(plattar_controller_1.PlattarController);
1631
2355
  exports.ProductController = ProductController;
1632
2356
  }, {
1633
- "../../ar/product-ar": 3,
2357
+ "../../ar/product-ar": 4,
1634
2358
  "../../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,
2359
+ "./plattar-controller": 9,
1862
2360
  "@plattar/plattar-api": 44
1863
2361
  }],
1864
2362
  11: [function (require, module, exports) {
@@ -1869,253 +2367,428 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
1869
2367
  });
1870
2368
  exports.VTOController = void 0;
1871
2369
  var plattar_api_1 = require("@plattar/plattar-api");
1872
- var plattar_services_1 = require("@plattar/plattar-services");
1873
2370
  var __1 = require("../..");
1874
- var raw_ar_1 = require("../../ar/raw-ar");
1875
2371
  var util_1 = require("../../util/util");
1876
2372
  var plattar_controller_1 = require("./plattar-controller");
2373
+ var configurator_ar_1 = require("../../ar/configurator-ar");
1877
2374
  /**
1878
2375
  * Manages an instance of the <plattar-configurator> HTML Element
1879
2376
  */
1880
- var VTOController = /*#__PURE__*/function (_plattar_controller_4) {
1881
- _inherits(VTOController, _plattar_controller_4);
2377
+ var VTOController = /*#__PURE__*/function (_plattar_controller_3) {
2378
+ _inherits(VTOController, _plattar_controller_3);
1882
2379
  var _super9 = _createSuper(VTOController);
1883
- function VTOController(parent) {
2380
+ function VTOController() {
2381
+ var _this22;
1884
2382
  _classCallCheck(this, VTOController);
1885
- return _super9.call(this, parent);
2383
+ _this22 = _super9.apply(this, arguments);
2384
+ _this22._cachedConfigState = null;
2385
+ return _this22;
1886
2386
  }
1887
2387
  _createClass(VTOController, [{
2388
+ key: "getConfiguratorState",
2389
+ value: function () {
2390
+ var _getConfiguratorState3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
2391
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2392
+ while (1) switch (_context17.prev = _context17.next) {
2393
+ case 0:
2394
+ if (!this._cachedConfigState) {
2395
+ _context17.next = 2;
2396
+ break;
2397
+ }
2398
+ return _context17.abrupt("return", this._cachedConfigState);
2399
+ case 2:
2400
+ this._cachedConfigState = this.createConfiguratorState();
2401
+ return _context17.abrupt("return", this._cachedConfigState);
2402
+ case 4:
2403
+ case "end":
2404
+ return _context17.stop();
2405
+ }
2406
+ }, _callee17, this);
2407
+ }));
2408
+ function getConfiguratorState() {
2409
+ return _getConfiguratorState3.apply(this, arguments);
2410
+ }
2411
+ return getConfiguratorState;
2412
+ }()
2413
+ }, {
1888
2414
  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;
2415
+ value: function () {
2416
+ var _onAttributesUpdated3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(attributeName) {
2417
+ var state, viewer, variationIDs, variationIDsList, variationSKUs, variationSKUList, configState, _variationIDs2, _variationIDsList2, _configState2, _variationSKUs2, _variationSKUList2;
2418
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2419
+ while (1) switch (_context18.prev = _context18.next) {
2420
+ case 0:
2421
+ state = this._state;
2422
+ if (!(state === plattar_controller_1.ControllerState.Renderer)) {
2423
+ _context18.next = 17;
2424
+ break;
2425
+ }
2426
+ viewer = this.element;
2427
+ if (!viewer) {
2428
+ _context18.next = 16;
2429
+ break;
2430
+ }
2431
+ if (!(attributeName === "variation-id")) {
2432
+ _context18.next = 10;
2433
+ break;
2434
+ }
2435
+ variationIDs = this.getAttribute("variation-id");
2436
+ variationIDsList = variationIDs ? variationIDs.split(",") : [];
2437
+ if (!(variationIDsList.length > 0)) {
2438
+ _context18.next = 10;
2439
+ break;
2440
+ }
2441
+ _context18.next = 10;
2442
+ return viewer.messenger.selectVariationID(variationIDsList);
2443
+ case 10:
2444
+ if (!(attributeName === "variation-sku")) {
2445
+ _context18.next = 16;
2446
+ break;
2447
+ }
2448
+ variationSKUs = this.getAttribute("variation-sku");
2449
+ variationSKUList = variationSKUs ? variationSKUs.split(",") : [];
2450
+ if (!(variationSKUList.length > 0)) {
2451
+ _context18.next = 16;
2452
+ break;
2453
+ }
2454
+ _context18.next = 16;
2455
+ return viewer.messenger.selectVariationSKU(variationSKUList);
2456
+ case 16:
2457
+ return _context18.abrupt("return");
2458
+ case 17:
2459
+ if (!(state === plattar_controller_1.ControllerState.QRCode)) {
2460
+ _context18.next = 34;
2461
+ break;
2462
+ }
2463
+ if (!(attributeName === "variation-id")) {
2464
+ _context18.next = 25;
2465
+ break;
2466
+ }
2467
+ _context18.next = 21;
2468
+ return this.getConfiguratorState();
2469
+ case 21:
2470
+ configState = _context18.sent;
2471
+ _variationIDs2 = this.getAttribute("variation-id");
2472
+ _variationIDsList2 = _variationIDs2 ? _variationIDs2.split(",") : [];
2473
+ _variationIDsList2.forEach(function (variationID) {
2474
+ configState.state.setVariationID(variationID);
2475
+ });
2476
+ case 25:
2477
+ if (!(attributeName === "variation-sku")) {
2478
+ _context18.next = 32;
2479
+ break;
2480
+ }
2481
+ _context18.next = 28;
2482
+ return this.getConfiguratorState();
2483
+ case 28:
2484
+ _configState2 = _context18.sent;
2485
+ _variationSKUs2 = this.getAttribute("variation-sku");
2486
+ _variationSKUList2 = _variationSKUs2 ? _variationSKUs2.split(",") : [];
2487
+ _variationSKUList2.forEach(function (variationSKU) {
2488
+ _configState2.state.setVariationSKU(variationSKU);
2489
+ });
2490
+ case 32:
2491
+ this.startQRCode(this._prevQROpt);
2492
+ return _context18.abrupt("return");
2493
+ case 34:
2494
+ case "end":
2495
+ return _context18.stop();
2496
+ }
2497
+ }, _callee18, this);
2498
+ }));
2499
+ function onAttributesUpdated(_x7) {
2500
+ return _onAttributesUpdated3.apply(this, arguments);
1895
2501
  }
1896
- }
2502
+ return onAttributesUpdated;
2503
+ }()
1897
2504
  }, {
1898
2505
  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;
2506
+ value: function () {
2507
+ var _startViewerQRCode2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(options) {
2508
+ var _this23 = this;
2509
+ var sceneID, opt, viewer, width, height, dst, configState, showAR, productID, sceneProductID, variationID;
2510
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2511
+ while (1) switch (_context19.prev = _context19.next) {
2512
+ case 0:
2513
+ // remove the old renderer instance if any
2514
+ this.removeRenderer();
2515
+ sceneID = this.getAttribute("scene-id");
2516
+ if (sceneID) {
2517
+ _context19.next = 4;
2518
+ break;
2519
+ }
2520
+ throw new Error("VTOController.startQRCode() - minimum required attributes not set, use scene-id as a minimum");
2521
+ case 4:
2522
+ opt = options || this._GetDefaultQROptions();
2523
+ viewer = document.createElement("plattar-qrcode");
2524
+ this._element = viewer;
2525
+ // required attributes with defaults for plattar-viewer node
2526
+ width = this.getAttribute("width") || "500px";
2527
+ height = this.getAttribute("height") || "500px";
2528
+ viewer.setAttribute("width", width);
2529
+ viewer.setAttribute("height", height);
2530
+ if (opt.color) {
2531
+ viewer.setAttribute("color", opt.color);
2532
+ }
2533
+ if (opt.margin) {
2534
+ viewer.setAttribute("margin", "" + opt.margin);
2535
+ }
2536
+ if (opt.qrType) {
2537
+ viewer.setAttribute("qr-type", opt.qrType);
2538
+ }
2539
+ viewer.setAttribute("shorten", opt.shorten && (opt.shorten === true || opt.shorten === "true") ? "true" : "false");
2540
+ dst = plattar_api_1.Server.location().base + "renderer/facear.html?scene_id=" + sceneID; // optional attributes
2541
+ configState = null;
2542
+ _context19.prev = 17;
2543
+ _context19.next = 20;
2544
+ return this.getConfiguratorState();
2545
+ case 20:
2546
+ configState = _context19.sent;
2547
+ _context19.next = 26;
2548
+ break;
2549
+ case 23:
2550
+ _context19.prev = 23;
2551
+ _context19.t0 = _context19["catch"](17);
2552
+ // config state is not available
2553
+ configState = null;
2554
+ case 26:
2555
+ showAR = this.getAttribute("show-ar");
2556
+ productID = this.getAttribute("product-id");
2557
+ sceneProductID = this.getAttribute("scene-product-id");
2558
+ variationID = this.getAttribute("variation-id");
2559
+ if (configState) {
2560
+ dst += "&config_state=" + configState.state.encode();
2561
+ }
2562
+ if (showAR) {
2563
+ dst += "&show_ar=" + showAR;
2564
+ }
2565
+ if (productID) {
2566
+ dst += "&product_id=" + productID;
2567
+ }
2568
+ if (sceneProductID) {
2569
+ dst += "&scene_product_id=" + sceneProductID;
2570
+ }
2571
+ if (variationID) {
2572
+ dst += "&variation_id=" + variationID;
2573
+ }
2574
+ viewer.setAttribute("url", opt.url || dst);
2575
+ this._state = plattar_controller_1.ControllerState.QRCode;
2576
+ this._prevQROpt = opt;
2577
+ return _context19.abrupt("return", new Promise(function (accept, reject) {
2578
+ viewer.onload = function () {
2579
+ return accept(viewer);
2580
+ };
2581
+ _this23.append(viewer);
2582
+ }));
2583
+ case 39:
2584
+ case "end":
2585
+ return _context19.stop();
1944
2586
  }
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
- }
2587
+ }, _callee19, this, [[17, 23]]);
2588
+ }));
2589
+ function startViewerQRCode(_x8) {
2590
+ return _startViewerQRCode2.apply(this, arguments);
2591
+ }
2592
+ return startViewerQRCode;
2593
+ }()
1958
2594
  }, {
1959
2595
  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
- }
2596
+ value: function () {
2597
+ var _startRenderer2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2598
+ var _this24 = this;
2599
+ var sceneID, width, height, server, viewer, configState, showAR, productID, sceneProductID, variationID;
2600
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2601
+ while (1) switch (_context20.prev = _context20.next) {
2602
+ case 0:
2603
+ // remove the old renderer instance if any
2604
+ this.removeRenderer();
2605
+ sceneID = this.getAttribute("scene-id");
2606
+ if (sceneID) {
2607
+ _context20.next = 4;
2608
+ break;
2609
+ }
2610
+ throw new Error("VTOController.startRenderer() - minimum required attributes not set, use scene-id as a minimum");
2611
+ case 4:
2612
+ // required attributes with defaults for plattar-facear node
2613
+ width = this.getAttribute("width") || "500px";
2614
+ height = this.getAttribute("height") || "500px";
2615
+ server = this.getAttribute("server") || "production";
2616
+ viewer = document.createElement("plattar-facear");
2617
+ this._element = viewer;
2618
+ viewer.setAttribute("width", width);
2619
+ viewer.setAttribute("height", height);
2620
+ viewer.setAttribute("server", server);
2621
+ viewer.setAttribute("scene-id", sceneID);
2622
+ // optional attributes
2623
+ configState = null;
2624
+ _context20.prev = 14;
2625
+ _context20.next = 17;
2626
+ return this.getConfiguratorState();
2627
+ case 17:
2628
+ configState = _context20.sent;
2629
+ _context20.next = 23;
2630
+ break;
2631
+ case 20:
2632
+ _context20.prev = 20;
2633
+ _context20.t0 = _context20["catch"](14);
2634
+ // config state not available
2635
+ configState = null;
2636
+ case 23:
2637
+ showAR = this.getAttribute("show-ar");
2638
+ productID = this.getAttribute("product-id");
2639
+ sceneProductID = this.getAttribute("scene-product-id");
2640
+ variationID = this.getAttribute("variation-id");
2641
+ if (configState) {
2642
+ viewer.setAttribute("config-state", configState.state.encode());
2643
+ }
2644
+ if (showAR) {
2645
+ viewer.setAttribute("show-ar", showAR);
2646
+ }
2647
+ if (productID) {
2648
+ viewer.setAttribute("product-id", productID);
2649
+ }
2650
+ if (sceneProductID) {
2651
+ viewer.setAttribute("scene-product-id", sceneProductID);
2652
+ }
2653
+ if (variationID) {
2654
+ viewer.setAttribute("variation-id", variationID);
2655
+ }
2656
+ this._state = plattar_controller_1.ControllerState.Renderer;
2657
+ return _context20.abrupt("return", new Promise(function (accept, reject) {
2658
+ _this24.append(viewer);
2659
+ if (configState) {
2660
+ _this24.setupMessengerObservers(viewer, configState);
2661
+ }
2662
+ return accept(viewer);
2663
+ }));
2664
+ case 34:
2665
+ case "end":
2666
+ return _context20.stop();
2667
+ }
2668
+ }, _callee20, this, [[14, 20]]);
2669
+ }));
2670
+ function startRenderer() {
2671
+ return _startRenderer2.apply(this, arguments);
2672
+ }
2673
+ return startRenderer;
2674
+ }()
2008
2675
  }, {
2009
2676
  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
- }
2677
+ value: function () {
2678
+ var _initAR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2679
+ var arMode;
2680
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2681
+ while (1) switch (_context21.prev = _context21.next) {
2682
+ case 0:
2683
+ if (util_1.Util.canAugment()) {
2684
+ _context21.next = 2;
2685
+ break;
2686
+ }
2687
+ throw new Error("VTOController.initAR() - cannot proceed as VTO AR not available in context");
2688
+ case 2:
2689
+ if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
2690
+ _context21.next = 4;
2691
+ break;
2692
+ }
2693
+ throw new Error("VTOController.initAR() - cannot proceed as VTO AR only available on IOS Mobile devices");
2694
+ case 4:
2695
+ arMode = this.getAttribute("ar-mode") || "generated";
2696
+ _context21.t0 = arMode.toLowerCase();
2697
+ _context21.next = _context21.t0 === "inherited" ? 8 : _context21.t0 === "generated" ? 9 : 9;
2698
+ break;
2699
+ case 8:
2700
+ return _context21.abrupt("return", this._InitARInherited());
2701
+ case 9:
2702
+ return _context21.abrupt("return", this._InitARGenerated());
2703
+ case 10:
2704
+ case "end":
2705
+ return _context21.stop();
2706
+ }
2707
+ }, _callee21, this);
2708
+ }));
2709
+ function initAR() {
2710
+ return _initAR2.apply(this, arguments);
2711
+ }
2712
+ return initAR;
2713
+ }()
2030
2714
  /**
2031
2715
  * Private Function - This launches the Static/Inherited AR Mode
2032
2716
  */
2033
2717
  }, {
2034
2718
  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);
2719
+ value: function () {
2720
+ var _InitARInherited3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2721
+ var sceneID, state, first, sceneProductAR;
2722
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2723
+ while (1) switch (_context22.prev = _context22.next) {
2724
+ case 0:
2725
+ sceneID = this.getAttribute("scene-id");
2726
+ if (sceneID) {
2727
+ _context22.next = 3;
2728
+ break;
2729
+ }
2730
+ throw new Error("VTOController.initAR() - inherited AR minimum required attributes not set, use scene-id as a minimum");
2731
+ case 3:
2732
+ _context22.next = 5;
2733
+ return this.getConfiguratorState();
2734
+ case 5:
2735
+ state = _context22.sent.state;
2736
+ first = state.first();
2737
+ if (!first) {
2738
+ _context22.next = 10;
2739
+ break;
2740
+ }
2741
+ sceneProductAR = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
2742
+ return _context22.abrupt("return", sceneProductAR.init());
2743
+ case 10:
2744
+ throw new Error("VTOController.initAR() - invalid decoded config-state does not have any product states");
2745
+ case 11:
2746
+ case "end":
2747
+ return _context22.stop();
2056
2748
  }
2057
- return reject(new Error("VTOController.initAR() - invalid Scene does not have any product states"));
2058
- })["catch"](reject);
2059
- return;
2749
+ }, _callee22, this);
2750
+ }));
2751
+ function _InitARInherited() {
2752
+ return _InitARInherited3.apply(this, arguments);
2060
2753
  }
2061
- return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
2062
- }
2754
+ return _InitARInherited;
2755
+ }()
2063
2756
  /**
2064
2757
  * Private Function - This launches the Dynamic/Generated AR Mode
2065
2758
  */
2066
2759
  }, {
2067
2760
  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;
2761
+ value: function () {
2762
+ var _InitARGenerated3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2763
+ var sceneID, configAR;
2764
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2765
+ while (1) switch (_context23.prev = _context23.next) {
2766
+ case 0:
2767
+ sceneID = this.getAttribute("scene-id");
2768
+ if (sceneID) {
2769
+ _context23.next = 3;
2770
+ break;
2771
+ }
2772
+ throw new Error("VTOController.initAR() - generated AR minimum required attributes not set, use scene-id as a minimum");
2773
+ case 3:
2774
+ _context23.t0 = configurator_ar_1.ConfiguratorAR;
2775
+ _context23.next = 6;
2776
+ return this.getConfiguratorState();
2777
+ case 6:
2778
+ _context23.t1 = _context23.sent;
2779
+ configAR = new _context23.t0(_context23.t1);
2780
+ return _context23.abrupt("return", configAR.init());
2781
+ case 9:
2782
+ case "end":
2783
+ return _context23.stop();
2784
+ }
2785
+ }, _callee23, this);
2786
+ }));
2787
+ function _InitARGenerated() {
2788
+ return _InitARGenerated3.apply(this, arguments);
2116
2789
  }
2117
- return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
2118
- }
2790
+ return _InitARGenerated;
2791
+ }()
2119
2792
  }, {
2120
2793
  key: "removeRenderer",
2121
2794
  value: function removeRenderer() {
@@ -2124,6 +2797,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2124
2797
  this._element = null;
2125
2798
  return true;
2126
2799
  }
2800
+ this.removeMessengerObservers();
2127
2801
  return false;
2128
2802
  }
2129
2803
  }, {
@@ -2137,11 +2811,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2137
2811
  exports.VTOController = VTOController;
2138
2812
  }, {
2139
2813
  "../..": 13,
2140
- "../../ar/raw-ar": 4,
2814
+ "../../ar/configurator-ar": 1,
2141
2815
  "../../util/util": 15,
2142
- "./plattar-controller": 8,
2143
- "@plattar/plattar-api": 44,
2144
- "@plattar/plattar-services": 115
2816
+ "./plattar-controller": 9,
2817
+ "@plattar/plattar-api": 44
2145
2818
  }],
2146
2819
  12: [function (require, module, exports) {
2147
2820
  "use strict";
@@ -2150,18 +2823,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2150
2823
  value: true
2151
2824
  });
2152
2825
  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
2826
  var configurator_controller_1 = require("./controllers/configurator-controller");
2156
2827
  var vto_controller_1 = require("./controllers/vto-controller");
2828
+ var product_controller_1 = require("./controllers/product-controller");
2157
2829
  /**
2158
2830
  * This tracks the current embed type
2159
2831
  */
2160
2832
  var EmbedType;
2161
2833
  (function (EmbedType) {
2162
- EmbedType[EmbedType["Viewer"] = 0] = "Viewer";
2163
- EmbedType[EmbedType["Configurator"] = 1] = "Configurator";
2834
+ EmbedType[EmbedType["Configurator"] = 0] = "Configurator";
2835
+ EmbedType[EmbedType["Legacy"] = 1] = "Legacy";
2164
2836
  EmbedType[EmbedType["VTO"] = 2] = "VTO";
2837
+ EmbedType[EmbedType["None"] = 3] = "None";
2165
2838
  })(EmbedType || (EmbedType = {}));
2166
2839
  /**
2167
2840
  * This is the primary <plattar-embed /> node that allows easy embedding
@@ -2171,132 +2844,258 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2171
2844
  _inherits(PlattarEmbed, _HTMLElement);
2172
2845
  var _super10 = _createSuper(PlattarEmbed);
2173
2846
  function PlattarEmbed() {
2174
- var _this28;
2847
+ var _this25;
2175
2848
  _classCallCheck(this, PlattarEmbed);
2176
- _this28 = _super10.call(this);
2849
+ _this25 = _super10.call(this);
2177
2850
  // this is the current embed type, viewer by default
2178
- _this28._currentType = EmbedType.Viewer;
2179
- _this28._controller = null;
2180
- return _this28;
2851
+ _this25._currentType = EmbedType.None;
2852
+ _this25._controller = null;
2853
+ _this25._currentSceneID = null;
2854
+ _this25._observer = null;
2855
+ return _this25;
2181
2856
  }
2182
2857
  _createClass(PlattarEmbed, [{
2183
2858
  key: "viewer",
2184
2859
  get: function get() {
2185
2860
  return this._controller ? this._controller.element : null;
2186
2861
  }
2862
+ /**
2863
+ * Begin observing all changes to this DOM element
2864
+ */
2187
2865
  }, {
2188
2866
  key: "connectedCallback",
2189
2867
  value: function connectedCallback() {
2190
- var _this29 = this;
2191
- var embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "viewer";
2868
+ this.create();
2869
+ }
2870
+ /**
2871
+ * creates a brand new instance of this embed
2872
+ */
2873
+ }, {
2874
+ key: "create",
2875
+ value: function create() {
2876
+ var _this26 = this;
2877
+ // server cannot be changed once its set - defaults to production
2878
+ var server = this.hasAttribute("server") ? this.getAttribute("server") : "production";
2879
+ plattar_api_1.Server.create(plattar_api_1.Server.match(server || "production"));
2880
+ if (!this._observer) {
2881
+ this._observer = new MutationObserver(function (mutations) {
2882
+ mutations.forEach(function (mutation) {
2883
+ if (mutation.type === "attributes") {
2884
+ var attributeName = mutation.attributeName ? mutation.attributeName : "none";
2885
+ if (_this26._currentType !== EmbedType.Legacy) {
2886
+ _this26._CreateEmbed(attributeName);
2887
+ } else {
2888
+ _this26._OnAttributesUpdated(attributeName);
2889
+ }
2890
+ }
2891
+ });
2892
+ });
2893
+ this._observer.observe(this, {
2894
+ attributes: true
2895
+ });
2896
+ }
2897
+ var productID = this.hasAttribute("product-id") ? this.getAttribute("product-id") : null;
2898
+ if (productID) {
2899
+ this._currentType = EmbedType.Legacy;
2900
+ this._CreateLegacyEmbed();
2901
+ return;
2902
+ }
2903
+ this._CreateEmbed("none");
2904
+ }
2905
+ /**
2906
+ * Destroys the active instance of this embed and resets internal state to default
2907
+ */
2908
+ }, {
2909
+ key: "destroy",
2910
+ value: function destroy() {
2911
+ if (this._controller) {
2912
+ this._controller.removeRenderer();
2913
+ this._controller = null;
2914
+ }
2915
+ this._currentType = EmbedType.None;
2916
+ }
2917
+ /**
2918
+ * this is only used for backwards-compatible legacy embed types typically
2919
+ * embedding products with variations (without a scene-id)
2920
+ */
2921
+ }, {
2922
+ key: "_CreateLegacyEmbed",
2923
+ value: function _CreateLegacyEmbed() {
2924
+ this._controller = new product_controller_1.ProductController(this);
2925
+ var init = this.hasAttribute("init") ? this.getAttribute("init") : null;
2926
+ switch (init) {
2927
+ case "viewer":
2928
+ this.startViewer();
2929
+ break;
2930
+ case "qrcode":
2931
+ this.startQRCode();
2932
+ break;
2933
+ }
2934
+ }
2935
+ /**
2936
+ * creates the embed
2937
+ * this can also be called when attributes/state changes so embeds can be re-loaded
2938
+ */
2939
+ }, {
2940
+ key: "_CreateEmbed",
2941
+ value: function _CreateEmbed(attributeName) {
2942
+ var embedType = this.hasAttribute("embed-type") ? this.getAttribute("embed-type") : "configurator";
2943
+ var currentEmbed = this._currentType;
2192
2944
  if (embedType) {
2193
2945
  switch (embedType.toLowerCase()) {
2194
- case "viewer":
2195
- this._currentType = EmbedType.Viewer;
2196
- break;
2197
2946
  case "vto":
2198
2947
  this._currentType = EmbedType.VTO;
2199
2948
  break;
2949
+ case "viewer":
2200
2950
  case "configurator":
2201
- this._currentType = EmbedType.Configurator;
2202
- break;
2203
2951
  default:
2204
- this._currentType = EmbedType.Viewer;
2952
+ this._currentType = EmbedType.Configurator;
2205
2953
  }
2206
2954
  }
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"));
2955
+ // check if the controller needs to be re-created
2956
+ if (currentEmbed !== this._currentType && this._controller) {
2957
+ this._controller.removeRenderer();
2958
+ this._controller = null;
2959
+ }
2219
2960
  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);
2228
- }
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);
2961
+ // if the provided SceneID doesn't match, we need to remove the controller
2962
+ if (sceneID !== this._currentSceneID && this._controller) {
2963
+ this._controller.removeRenderer();
2964
+ this._controller = null;
2965
+ }
2966
+ this._currentSceneID = sceneID;
2967
+ // scene-id is the absolute minimum in order to initialise the embeds
2968
+ if (!this._currentSceneID) {
2969
+ return;
2233
2970
  }
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
- });
2971
+ // if the controller was removed due to state-change, we need to re-initialise it
2972
+ if (!this._controller) {
2973
+ switch (this._currentType) {
2974
+ case EmbedType.Configurator:
2975
+ this._controller = new configurator_controller_1.ConfiguratorController(this);
2976
+ break;
2977
+ case EmbedType.VTO:
2978
+ this._controller = new vto_controller_1.VTOController(this);
2979
+ break;
2980
+ }
2981
+ if (this._controller) {
2982
+ var init = this.hasAttribute("init") ? this.getAttribute("init") : null;
2983
+ switch (init) {
2984
+ case "viewer":
2985
+ this.startViewer();
2986
+ break;
2987
+ case "qrcode":
2988
+ this.startQRCode();
2989
+ break;
2990
+ }
2991
+ }
2992
+ } else {
2993
+ this._OnAttributesUpdated(attributeName);
2253
2994
  }
2254
2995
  }
2255
2996
  }, {
2256
2997
  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
- }
2998
+ value: function () {
2999
+ var _initAR3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
3000
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3001
+ while (1) switch (_context24.prev = _context24.next) {
3002
+ case 0:
3003
+ if (this._controller) {
3004
+ _context24.next = 2;
3005
+ break;
3006
+ }
3007
+ throw new Error("PlattarEmbed.initAR() - cannot execute as controller has not loaded yet");
3008
+ case 2:
3009
+ return _context24.abrupt("return", this._controller.initAR());
3010
+ case 3:
3011
+ case "end":
3012
+ return _context24.stop();
3013
+ }
3014
+ }, _callee24, this);
3015
+ }));
3016
+ function initAR() {
3017
+ return _initAR3.apply(this, arguments);
3018
+ }
3019
+ return initAR;
3020
+ }()
2266
3021
  }, {
2267
3022
  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
- }
3023
+ value: function () {
3024
+ var _startAR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
3025
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3026
+ while (1) switch (_context25.prev = _context25.next) {
3027
+ case 0:
3028
+ if (this._controller) {
3029
+ _context25.next = 2;
3030
+ break;
3031
+ }
3032
+ throw new Error("PlattarEmbed.startAR() - cannot execute as controller has not loaded yet");
3033
+ case 2:
3034
+ return _context25.abrupt("return", this._controller.startAR());
3035
+ case 3:
3036
+ case "end":
3037
+ return _context25.stop();
3038
+ }
3039
+ }, _callee25, this);
3040
+ }));
3041
+ function startAR() {
3042
+ return _startAR2.apply(this, arguments);
3043
+ }
3044
+ return startAR;
3045
+ }()
2277
3046
  }, {
2278
3047
  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
- }
3048
+ value: function () {
3049
+ var _startViewer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
3050
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3051
+ while (1) switch (_context26.prev = _context26.next) {
3052
+ case 0:
3053
+ if (this._controller) {
3054
+ _context26.next = 2;
3055
+ break;
3056
+ }
3057
+ throw new Error("PlattarEmbed.startViewer() - cannot execute as controller has not loaded yet");
3058
+ case 2:
3059
+ return _context26.abrupt("return", this._controller.startRenderer());
3060
+ case 3:
3061
+ case "end":
3062
+ return _context26.stop();
3063
+ }
3064
+ }, _callee26, this);
3065
+ }));
3066
+ function startViewer() {
3067
+ return _startViewer.apply(this, arguments);
3068
+ }
3069
+ return startViewer;
3070
+ }()
2288
3071
  }, {
2289
3072
  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
- }
3073
+ value: function () {
3074
+ var _startQRCode2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
3075
+ var options,
3076
+ _args27 = arguments;
3077
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3078
+ while (1) switch (_context27.prev = _context27.next) {
3079
+ case 0:
3080
+ options = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : null;
3081
+ if (this._controller) {
3082
+ _context27.next = 3;
3083
+ break;
3084
+ }
3085
+ throw new Error("PlattarEmbed.startQRCode() - cannot execute as controller has not loaded yet");
3086
+ case 3:
3087
+ return _context27.abrupt("return", this._controller.startQRCode(options));
3088
+ case 4:
3089
+ case "end":
3090
+ return _context27.stop();
3091
+ }
3092
+ }, _callee27, this);
3093
+ }));
3094
+ function startQRCode() {
3095
+ return _startQRCode2.apply(this, arguments);
3096
+ }
3097
+ return startQRCode;
3098
+ }()
2300
3099
  /**
2301
3100
  * This will remove the currently active Renderer
2302
3101
  *
@@ -2316,9 +3115,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2316
3115
  */
2317
3116
  }, {
2318
3117
  key: "_OnAttributesUpdated",
2319
- value: function _OnAttributesUpdated() {
3118
+ value: function _OnAttributesUpdated(attributeName) {
2320
3119
  if (this._controller) {
2321
- this._controller.onAttributesUpdated();
3120
+ this._controller.onAttributesUpdated(attributeName);
2322
3121
  }
2323
3122
  }
2324
3123
  }]);
@@ -2326,9 +3125,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2326
3125
  }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
2327
3126
  exports["default"] = PlattarEmbed;
2328
3127
  }, {
2329
- "./controllers/configurator-controller": 7,
2330
- "./controllers/product-controller": 9,
2331
- "./controllers/viewer-controller": 10,
3128
+ "./controllers/configurator-controller": 8,
3129
+ "./controllers/product-controller": 10,
2332
3130
  "./controllers/vto-controller": 11,
2333
3131
  "@plattar/plattar-api": 44
2334
3132
  }],
@@ -2443,12 +3241,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2443
3241
  }
2444
3242
  console.log("using @plattar/plattar-ar-adapter v" + version_1["default"]);
2445
3243
  }, {
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,
3244
+ "./ar/launcher-ar": 2,
3245
+ "./ar/model-ar": 3,
3246
+ "./ar/product-ar": 4,
3247
+ "./ar/raw-ar": 5,
3248
+ "./ar/scene-ar": 6,
3249
+ "./ar/scene-product-ar": 7,
2452
3250
  "./embed/plattar-embed": 12,
2453
3251
  "./util/configurator-state": 14,
2454
3252
  "./util/util": 15,
@@ -2464,13 +3262,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2464
3262
  });
2465
3263
  exports.ConfiguratorState = void 0;
2466
3264
  var plattar_api_1 = require("@plattar/plattar-api");
3265
+ /**
3266
+ * Manages a Configuration State of multiple Products with multiple Variations
3267
+ * Allows easily changing
3268
+ */
2467
3269
  var ConfiguratorState = /*#__PURE__*/function () {
2468
3270
  function ConfiguratorState() {
2469
3271
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2470
3272
  _classCallCheck(this, ConfiguratorState);
3273
+ this._mappedVariationIDValues = new Map();
3274
+ this._mappedVariationSKUValues = new Map();
2471
3275
  var defaultState = {
2472
3276
  meta: {
2473
3277
  scene_product_index: 0,
3278
+ scene_model_index: 0,
2474
3279
  product_variation_index: 1,
2475
3280
  meta_index: 2
2476
3281
  },
@@ -2483,6 +3288,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2483
3288
  // set the meta data
2484
3289
  if (parsedState.meta) {
2485
3290
  defaultState.meta.scene_product_index = parsedState.meta.scene_product_index || 0;
3291
+ defaultState.meta.scene_model_index = parsedState.meta.scene_model_index || 0;
2486
3292
  defaultState.meta.product_variation_index = parsedState.meta.product_variation_index || 1;
2487
3293
  defaultState.meta.meta_index = parsedState.meta.meta_index || 2;
2488
3294
  }
@@ -2495,18 +3301,79 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2495
3301
  this._state = defaultState;
2496
3302
  }
2497
3303
  /**
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
3304
+ * Modifyes the SceneProduct that this Variation SKU belongs to and changes for
3305
+ * purposes of Configuration
2503
3306
  */
2504
3307
  _createClass(ConfiguratorState, [{
3308
+ key: "setVariationSKU",
3309
+ value: function setVariationSKU(productVariationSKU) {
3310
+ var variationID = this._mappedVariationSKUValues.get(productVariationSKU);
3311
+ if (!variationID) {
3312
+ console.warn("ConfiguratorState.setVariationSKU() - Variation SKU of " + productVariationSKU + " is not defined in any variations");
3313
+ return;
3314
+ }
3315
+ this.setVariationID(variationID);
3316
+ }
3317
+ /**
3318
+ * Modifyes the SceneProduct that this Variation belongs to and changes for
3319
+ * purposes of Configuration
3320
+ */
3321
+ }, {
3322
+ key: "setVariationID",
3323
+ value: function setVariationID(productVariationID) {
3324
+ var sceneProductID = this._mappedVariationIDValues.get(productVariationID);
3325
+ if (!sceneProductID) {
3326
+ console.warn("ConfiguratorState.setVariationID() - Variation ID of " + productVariationID + " is not defined in any products");
3327
+ return;
3328
+ }
3329
+ this.setSceneProduct(sceneProductID, productVariationID);
3330
+ }
3331
+ /**
3332
+ * Adds a new Scene Product/Variation combo with meta-data into the Configurator State
3333
+ *
3334
+ * @param sceneProductID - The Scene Product ID to be used (as defined in Plattar CMS)
3335
+ * @param productVariationID - The Product Variation ID to be used (as defined in Plattar CMS)
3336
+ * @param metaData - Arbitrary meta-data that can be used against certain operaions
3337
+ */
3338
+ }, {
2505
3339
  key: "setSceneProduct",
2506
3340
  value: function setSceneProduct(sceneProductID, productVariationID) {
2507
3341
  var metaData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2508
3342
  this.addSceneProduct(sceneProductID, productVariationID, metaData);
2509
3343
  }
3344
+ /**
3345
+ * Adds a new SceneModel with meta-data into the Configurator State. Note that the SceneProductDataMeta will
3346
+ * override the isSceneModel variable and assign to "true" automatically
3347
+ *
3348
+ * @param SceneModelID - The SceneModel ID to add
3349
+ * @param metaData - Arbitrary meta-data that can be used against certain operaions
3350
+ */
3351
+ }, {
3352
+ key: "setSceneModel",
3353
+ value: function setSceneModel(SceneModelID) {
3354
+ var metaData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
3355
+ if (SceneModelID) {
3356
+ metaData = metaData || {
3357
+ augment: true,
3358
+ type: "scenemodel"
3359
+ };
3360
+ metaData.type = "scenemodel";
3361
+ var states = this._state.states;
3362
+ var meta = this._state.meta;
3363
+ var newData = null;
3364
+ var existingData = this.findSceneProductIndex(SceneModelID);
3365
+ if (existingData) {
3366
+ newData = existingData;
3367
+ } else {
3368
+ newData = [];
3369
+ // push the new data into the stack
3370
+ states.push(newData);
3371
+ }
3372
+ newData[meta.scene_product_index] = SceneModelID;
3373
+ newData[meta.product_variation_index] = null;
3374
+ newData[meta.meta_index] = metaData;
3375
+ }
3376
+ }
2510
3377
  /**
2511
3378
  * Adds a new Scene Product/Variation combo with meta-data into the Configurator State
2512
3379
  *
@@ -2519,6 +3386,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2519
3386
  value: function addSceneProduct(sceneProductID, productVariationID) {
2520
3387
  var metaData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2521
3388
  if (sceneProductID && productVariationID) {
3389
+ metaData = metaData || {
3390
+ augment: true,
3391
+ type: "sceneproduct"
3392
+ };
3393
+ metaData.type = "sceneproduct";
2522
3394
  var states = this._state.states;
2523
3395
  var meta = this._state.meta;
2524
3396
  var newData = null;
@@ -2532,9 +3404,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2532
3404
  }
2533
3405
  newData[meta.scene_product_index] = sceneProductID;
2534
3406
  newData[meta.product_variation_index] = productVariationID;
2535
- if (metaData) {
2536
- newData[meta.meta_index] = metaData;
2537
- }
3407
+ newData[meta.meta_index] = metaData;
2538
3408
  }
2539
3409
  }
2540
3410
  /**
@@ -2570,12 +3440,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2570
3440
  scene_product_id: found[meta.scene_product_index],
2571
3441
  product_variation_id: found[meta.product_variation_index],
2572
3442
  meta_data: {
2573
- augment: true
3443
+ augment: true,
3444
+ type: "sceneproduct"
2574
3445
  }
2575
3446
  };
2576
3447
  // include the meta-data
2577
3448
  if (found.length === 3) {
2578
3449
  data.meta_data.augment = found[meta.meta_index].augment || true;
3450
+ data.meta_data.type = found[meta.meta_index].type || "sceneproduct";
2579
3451
  }
2580
3452
  return data;
2581
3453
  }
@@ -2596,7 +3468,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2596
3468
  scene_product_id: productState[meta.scene_product_index],
2597
3469
  product_variation_id: productState[meta.product_variation_index],
2598
3470
  meta_data: {
2599
- augment: true
3471
+ augment: true,
3472
+ type: "sceneproduct"
2600
3473
  }
2601
3474
  });
2602
3475
  } else if (productState.length === 3) {
@@ -2604,13 +3477,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2604
3477
  scene_product_id: productState[meta.scene_product_index],
2605
3478
  product_variation_id: productState[meta.product_variation_index],
2606
3479
  meta_data: {
2607
- augment: productState[meta.meta_index].augment || true
3480
+ augment: productState[meta.meta_index].augment || true,
3481
+ type: productState[meta.meta_index].type || "sceneproduct"
2608
3482
  }
2609
3483
  });
2610
3484
  }
2611
3485
  });
2612
3486
  }
2613
3487
  }
3488
+ /**
3489
+ * Compose and return an array of all internal objects
3490
+ */
3491
+ }, {
3492
+ key: "array",
3493
+ value: function array() {
3494
+ var array = new Array();
3495
+ this.forEach(function (object) {
3496
+ array.push(object);
3497
+ });
3498
+ return array;
3499
+ }
2614
3500
  /**
2615
3501
  * @returns Returns the first reference of data in the stack, otherwise returns null
2616
3502
  */
@@ -2632,12 +3518,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2632
3518
  scene_product_id: found[meta.scene_product_index],
2633
3519
  product_variation_id: found[meta.product_variation_index],
2634
3520
  meta_data: {
2635
- augment: true
3521
+ augment: true,
3522
+ type: "sceneproduct"
2636
3523
  }
2637
3524
  };
2638
3525
  // include the meta-data
2639
3526
  if (found.length === 3) {
2640
3527
  data.meta_data.augment = found[meta.meta_index].augment || true;
3528
+ data.meta_data.type = found[meta.meta_index].type || "sceneproduct";
2641
3529
  }
2642
3530
  return data;
2643
3531
  }
@@ -2669,6 +3557,58 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2669
3557
  value: function decode(state) {
2670
3558
  return new ConfiguratorState(state);
2671
3559
  }
3560
+ /**
3561
+ * Decodes a previously generated state
3562
+ * @param sceneID
3563
+ * @param state
3564
+ * @returns
3565
+ */
3566
+ }, {
3567
+ key: "decodeState",
3568
+ value: function () {
3569
+ var _decodeState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
3570
+ var sceneID,
3571
+ state,
3572
+ configState,
3573
+ fscene,
3574
+ scene,
3575
+ _args28 = arguments;
3576
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3577
+ while (1) switch (_context28.prev = _context28.next) {
3578
+ case 0:
3579
+ sceneID = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : null;
3580
+ state = _args28.length > 1 && _args28[1] !== undefined ? _args28[1] : null;
3581
+ if (!(!sceneID || !state)) {
3582
+ _context28.next = 4;
3583
+ break;
3584
+ }
3585
+ throw new Error("ConfiguratorState.decodeState(sceneID, state) - sceneID and state must be defined");
3586
+ case 4:
3587
+ configState = new ConfiguratorState(state);
3588
+ fscene = new plattar_api_1.Scene(sceneID);
3589
+ fscene.include(plattar_api_1.Project);
3590
+ fscene.include(plattar_api_1.SceneProduct);
3591
+ fscene.include(plattar_api_1.SceneModel);
3592
+ fscene.include(plattar_api_1.SceneProduct.include(plattar_api_1.Product.include(plattar_api_1.ProductVariation)));
3593
+ _context28.next = 12;
3594
+ return fscene.get();
3595
+ case 12:
3596
+ scene = _context28.sent;
3597
+ return _context28.abrupt("return", {
3598
+ scene: scene,
3599
+ state: configState
3600
+ });
3601
+ case 14:
3602
+ case "end":
3603
+ return _context28.stop();
3604
+ }
3605
+ }, _callee28);
3606
+ }));
3607
+ function decodeState() {
3608
+ return _decodeState.apply(this, arguments);
3609
+ }
3610
+ return decodeState;
3611
+ }()
2672
3612
  /**
2673
3613
  * Generates a new ConfiguratorState instance from all SceneProducts and default
2674
3614
  * variations from the provided Scene ID
@@ -2677,33 +3617,78 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2677
3617
  */
2678
3618
  }, {
2679
3619
  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);
3620
+ value: function () {
3621
+ var _decodeScene = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
3622
+ var sceneID,
3623
+ configState,
3624
+ fscene,
3625
+ scene,
3626
+ sceneProducts,
3627
+ sceneModels,
3628
+ _args29 = arguments;
3629
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3630
+ while (1) switch (_context29.prev = _context29.next) {
3631
+ case 0:
3632
+ sceneID = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : null;
3633
+ if (sceneID) {
3634
+ _context29.next = 3;
3635
+ break;
3636
+ }
3637
+ throw new Error("ConfiguratorState.decodeScene(sceneID) - sceneID must be defined");
3638
+ case 3:
3639
+ configState = new ConfiguratorState();
3640
+ fscene = new plattar_api_1.Scene(sceneID);
3641
+ fscene.include(plattar_api_1.Project);
3642
+ fscene.include(plattar_api_1.SceneProduct);
3643
+ fscene.include(plattar_api_1.SceneModel);
3644
+ fscene.include(plattar_api_1.SceneProduct.include(plattar_api_1.Product.include(plattar_api_1.ProductVariation)));
3645
+ _context29.next = 11;
3646
+ return fscene.get();
3647
+ case 11:
3648
+ scene = _context29.sent;
3649
+ sceneProducts = scene.relationships.filter(plattar_api_1.SceneProduct);
3650
+ sceneModels = scene.relationships.filter(plattar_api_1.SceneModel); // add out scene models
3651
+ sceneModels.forEach(function (sceneModel) {
3652
+ configState.setSceneModel(sceneModel.id, {
3653
+ augment: sceneModel.attributes.include_in_augment,
3654
+ type: "scenemodel"
3655
+ });
3656
+ });
3657
+ // add out scene products
3658
+ sceneProducts.forEach(function (sceneProduct) {
3659
+ var product = sceneProduct.relationships.find(plattar_api_1.Product);
3660
+ if (product) {
3661
+ if (product.attributes.product_variation_id) {
3662
+ configState.setSceneProduct(sceneProduct.id, product.attributes.product_variation_id, {
3663
+ augment: sceneProduct.attributes.include_in_augment,
3664
+ type: "sceneproduct"
3665
+ });
3666
+ }
3667
+ // add the variation to an acceptible range of values
3668
+ var variations = product.relationships.filter(plattar_api_1.ProductVariation);
3669
+ variations.forEach(function (variation) {
3670
+ configState._mappedVariationIDValues.set(variation.id, sceneProduct.id);
3671
+ if (variation.attributes.sku) {
3672
+ configState._mappedVariationSKUValues.set(variation.attributes.sku, variation.id);
3673
+ }
3674
+ });
3675
+ }
3676
+ });
3677
+ return _context29.abrupt("return", {
3678
+ scene: scene,
3679
+ state: configState
3680
+ });
3681
+ case 17:
3682
+ case "end":
3683
+ return _context29.stop();
2695
3684
  }
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
- }
3685
+ }, _callee29);
3686
+ }));
3687
+ function decodeScene() {
3688
+ return _decodeScene.apply(this, arguments);
3689
+ }
3690
+ return decodeScene;
3691
+ }()
2707
3692
  }]);
2708
3693
  return ConfiguratorState;
2709
3694
  }();
@@ -2825,7 +3810,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2825
3810
  Object.defineProperty(exports, "__esModule", {
2826
3811
  value: true
2827
3812
  });
2828
- exports["default"] = "1.154.2";
3813
+ exports["default"] = "1.155.2";
2829
3814
  }, {}],
2830
3815
  17: [function (require, module, exports) {
2831
3816
  "use strict";
@@ -2856,13 +3841,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2856
3841
  _inherits(QuicklookViewer, _ar_viewer_1$default);
2857
3842
  var _super11 = _createSuper(QuicklookViewer);
2858
3843
  function QuicklookViewer() {
2859
- var _this34;
3844
+ var _this27;
2860
3845
  _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;
3846
+ _this27 = _super11.call(this);
3847
+ _this27.araction = null;
3848
+ _this27.titleHTML = "&checkoutTitle=" + document.title + "&checkoutSubtitle=" + document.title;
3849
+ _this27.arcallback = function () {};
3850
+ return _this27;
2866
3851
  }
2867
3852
  _createClass(QuicklookViewer, [{
2868
3853
  key: "nodeType",
@@ -2877,7 +3862,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2877
3862
  }, {
2878
3863
  key: "start",
2879
3864
  value: function start() {
2880
- var _this35 = this;
3865
+ var _this28 = this;
2881
3866
  if (!this.modelUrl) {
2882
3867
  throw new Error("QuicklookViewer.start() - model url not set, use QuicklookViewer.modelUrl");
2883
3868
  }
@@ -2889,7 +3874,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2889
3874
  if (araction) {
2890
3875
  var handleQuicklook = function handleQuicklook(event) {
2891
3876
  if (event.data === "_apple_ar_quicklook_button_tapped") {
2892
- _this35.arcallback();
3877
+ _this28.arcallback();
2893
3878
  }
2894
3879
  document.body.removeChild(anchor);
2895
3880
  anchor.removeEventListener("message", handleQuicklook, false);
@@ -2975,14 +3960,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2975
3960
  _inherits(SceneViewer, _ar_viewer_1$default3);
2976
3961
  var _super13 = _createSuper(SceneViewer);
2977
3962
  function SceneViewer() {
2978
- var _this36;
3963
+ var _this29;
2979
3964
  _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;
3965
+ _this29 = _super13.call(this);
3966
+ _this29.araction = null;
3967
+ _this29.isVertical = false;
3968
+ _this29.titleHTML = "<b>" + document.title;
3969
+ _this29.isVertical = false;
3970
+ return _this29;
2986
3971
  }
2987
3972
  _createClass(SceneViewer, [{
2988
3973
  key: "nodeType",
@@ -3079,16 +4064,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3079
4064
  */
3080
4065
  var Memory = /*#__PURE__*/function () {
3081
4066
  function Memory(messengerInstance) {
3082
- var _this37 = this;
4067
+ var _this30 = this;
3083
4068
  _classCallCheck(this, Memory);
3084
4069
  this._messenger = messengerInstance;
3085
4070
  this._tempMemory = new TemporaryMemory(messengerInstance);
3086
4071
  this._permMemory = new PermanentMemory(messengerInstance);
3087
4072
  this._messenger.self.__memory__set_temp_var = function (name, data) {
3088
- _this37._tempMemory[name] = data;
4073
+ _this30._tempMemory[name] = data;
3089
4074
  };
3090
4075
  this._messenger.self.__memory__set_perm_var = function (name, data) {
3091
- _this37._permMemory[name] = data;
4076
+ _this30._permMemory[name] = data;
3092
4077
  };
3093
4078
  }
3094
4079
  _createClass(Memory, [{
@@ -3535,17 +4520,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3535
4520
  }, {
3536
4521
  key: "exec",
3537
4522
  value: function exec() {
3538
- var _this38 = this;
4523
+ var _this31 = this;
3539
4524
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
3540
4525
  args[_key3] = arguments[_key3];
3541
4526
  }
3542
4527
  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"));
4528
+ if (!_this31._value) {
4529
+ return reject(new Error("WrappedLocalFunction.exec() function with name " + _this31._funcName + "() is not defined"));
3545
4530
  }
3546
4531
  try {
3547
4532
  // otherwise execute the function
3548
- var rObject = _this38._execute.apply(_this38, args);
4533
+ var rObject = _this31._execute.apply(_this31, args);
3549
4534
 
3550
4535
  // we need to check if the returned object is a Promise, if so, handle it
3551
4536
  // differently. This can happen if the function wants to execute asyn
@@ -3611,7 +4596,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3611
4596
  _createClass(FunctionObserver, [{
3612
4597
  key: "subscribe",
3613
4598
  value: function subscribe(functionName, callback) {
3614
- var _this39 = this;
4599
+ var _this32 = this;
3615
4600
  if (!functionName || !Util.isFunction(callback)) {
3616
4601
  return function () {};
3617
4602
  }
@@ -3625,7 +4610,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3625
4610
  }
3626
4611
  list.push(callback);
3627
4612
  return function () {
3628
- return _this39.unsubscribe(functionName, callback);
4613
+ return _this32.unsubscribe(functionName, callback);
3629
4614
  };
3630
4615
  }
3631
4616
 
@@ -3692,7 +4677,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3692
4677
  */
3693
4678
  var GlobalEventHandler = /*#__PURE__*/function () {
3694
4679
  function GlobalEventHandler() {
3695
- var _this40 = this;
4680
+ var _this33 = this;
3696
4681
  _classCallCheck(this, GlobalEventHandler);
3697
4682
  this._eventListeners = {};
3698
4683
 
@@ -3712,11 +4697,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3712
4697
  // make sure the event is properly formatted
3713
4698
  if (jsonData && jsonData.event && jsonData.data) {
3714
4699
  // see if there are any listeners for this
3715
- if (_this40._eventListeners[jsonData.event]) {
4700
+ if (_this33._eventListeners[jsonData.event]) {
3716
4701
  var remoteInterface = new RemoteInterface(evt.source, evt.origin);
3717
4702
 
3718
4703
  // loop through and call all the event handlers
3719
- _this40._eventListeners[jsonData.event].forEach(function (callback) {
4704
+ _this33._eventListeners[jsonData.event].forEach(function (callback) {
3720
4705
  try {
3721
4706
  callback(remoteInterface, jsonData.data);
3722
4707
  } catch (e) {
@@ -3908,33 +4893,33 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3908
4893
  }, {
3909
4894
  key: "_registerListeners",
3910
4895
  value: function _registerListeners() {
3911
- var _this41 = this;
4896
+ var _this34 = this;
3912
4897
  GlobalEventHandler.instance().listen("__messenger__child_init", function (src, data) {
3913
4898
  var iframeID = src.id;
3914
4899
 
3915
4900
  // check reserved key list
3916
4901
  switch (iframeID) {
3917
4902
  case undefined:
3918
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID cannot be undefined");
4903
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID cannot be undefined");
3919
4904
  case "self":
3920
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
4905
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
3921
4906
  case "parent":
3922
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
4907
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
3923
4908
  case "id":
3924
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
4909
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
3925
4910
  case "onload":
3926
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
4911
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
3927
4912
  default:
3928
4913
  break;
3929
4914
  }
3930
4915
 
3931
4916
  // 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));
4917
+ _this34[iframeID] = new RemoteFunctionList(iframeID, _this34._functionObserver);
4918
+ _this34[iframeID].setup(new RemoteInterface(src.source, src.origin));
3934
4919
 
3935
4920
  // add the interface to the broadcaster
3936
- _this41._broadcaster._push(iframeID);
3937
- var callbacks = _this41._callbacks;
4921
+ _this34._broadcaster._push(iframeID);
4922
+ var callbacks = _this34._callbacks;
3938
4923
 
3939
4924
  // we have registered callbacks, begin execution
3940
4925
  if (callbacks.has(iframeID)) {
@@ -3958,26 +4943,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3958
4943
  // check reserved key list
3959
4944
  switch (iframeID) {
3960
4945
  case undefined:
3961
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID cannot be undefined");
4946
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID cannot be undefined");
3962
4947
  case "self":
3963
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
4948
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"self\" cannot be used as the keyword is reserved");
3964
4949
  case "parent":
3965
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
4950
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"parent\" cannot be used as the keyword is reserved");
3966
4951
  case "id":
3967
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
4952
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"id\" cannot be used as the keyword is reserved");
3968
4953
  case "onload":
3969
- throw new Error("Messenger[" + _this41._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
4954
+ throw new Error("Messenger[" + _this34._id + "].setup() Component ID of \"onload\" cannot be used as the keyword is reserved");
3970
4955
  default:
3971
4956
  break;
3972
4957
  }
3973
4958
 
3974
4959
  // 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));
4960
+ _this34[iframeID] = new RemoteFunctionList(iframeID, _this34._functionObserver);
4961
+ _this34[iframeID].setup(new RemoteInterface(src.source, src.origin));
3977
4962
 
3978
4963
  // add the interface to the broadcaster
3979
- _this41._broadcaster._push(iframeID);
3980
- var callbacks = _this41._callbacks;
4964
+ _this34._broadcaster._push(iframeID);
4965
+ var callbacks = _this34._callbacks;
3981
4966
 
3982
4967
  // we have registered callbacks, begin execution
3983
4968
  if (callbacks.has(iframeID)) {
@@ -3996,9 +4981,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3996
4981
  });
3997
4982
  GlobalEventHandler.instance().listen("__messenger__parent_init", function (src, data) {
3998
4983
  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;
4984
+ _this34[iframeID] = new RemoteFunctionList(iframeID, _this34._functionObserver);
4985
+ _this34[iframeID].setup(new RemoteInterface(src.source, src.origin));
4986
+ var callbacks = _this34._callbacks;
4002
4987
 
4003
4988
  // we have registered callbacks, begin execution
4004
4989
  if (callbacks.has(iframeID)) {
@@ -4022,9 +5007,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4022
5007
  */
4023
5008
  GlobalEventHandler.instance().listen("__messenger__parent_init_inv", function (src, data) {
4024
5009
  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;
5010
+ _this34[iframeID] = new RemoteFunctionList(iframeID, _this34._functionObserver);
5011
+ _this34[iframeID].setup(new RemoteInterface(src.source, src.origin));
5012
+ var callbacks = _this34._callbacks;
4028
5013
 
4029
5014
  // we have registered callbacks, begin execution
4030
5015
  if (callbacks.has(iframeID)) {
@@ -4246,7 +5231,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4246
5231
  */
4247
5232
  var WrappedRemoteFunction = /*#__PURE__*/function () {
4248
5233
  function WrappedRemoteFunction(funcName, remoteInterface, functionObserver) {
4249
- var _this42 = this;
5234
+ var _this35 = this;
4250
5235
  _classCallCheck(this, WrappedRemoteFunction);
4251
5236
  this._funcName = funcName;
4252
5237
  this._remoteInterface = remoteInterface;
@@ -4258,24 +5243,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4258
5243
  var instanceID = data.instance_id;
4259
5244
 
4260
5245
  // the function name must match
4261
- if (data.function_name !== _this42._funcName) {
5246
+ if (data.function_name !== _this35._funcName) {
4262
5247
  return;
4263
5248
  }
4264
5249
 
4265
5250
  // the instance ID must be found, otherwise this is a rogue execution
4266
5251
  // that can be ignored (should not happen)
4267
- if (!_this42._callInstances[instanceID]) {
5252
+ if (!_this35._callInstances[instanceID]) {
4268
5253
  return;
4269
5254
  }
4270
- var promise = _this42._callInstances[instanceID];
5255
+ var promise = _this35._callInstances[instanceID];
4271
5256
 
4272
5257
  // remove the old instance
4273
- delete _this42._callInstances[instanceID];
5258
+ delete _this35._callInstances[instanceID];
4274
5259
 
4275
5260
  // perform the promise callbacks
4276
5261
  if (data.function_status === "success") {
4277
5262
  // execute the observers
4278
- _this42._functionObserver.call(_this42._funcName, {
5263
+ _this35._functionObserver.call(_this35._funcName, {
4279
5264
  type: "return",
4280
5265
  state: "success",
4281
5266
  data: data.function_args
@@ -4283,7 +5268,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4283
5268
  promise.accept(data.function_args);
4284
5269
  } else {
4285
5270
  // execute the observers
4286
- _this42._functionObserver.call(_this42._funcName, {
5271
+ _this35._functionObserver.call(_this35._funcName, {
4287
5272
  type: "return",
4288
5273
  state: "exception",
4289
5274
  data: new Error(data.function_args)
@@ -4299,7 +5284,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4299
5284
  _createClass(WrappedRemoteFunction, [{
4300
5285
  key: "exec",
4301
5286
  value: function exec() {
4302
- var _this43 = this;
5287
+ var _this36 = this;
4303
5288
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
4304
5289
  args[_key4] = arguments[_key4];
4305
5290
  }
@@ -4318,20 +5303,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4318
5303
  // to be executed later
4319
5304
  return new Promise(function (accept, reject) {
4320
5305
  // save this promise to be executed later
4321
- _this43._callInstances[instanceID] = {
5306
+ _this36._callInstances[instanceID] = {
4322
5307
  accept: accept,
4323
5308
  reject: reject
4324
5309
  };
4325
5310
 
4326
5311
  // execute this event in another context
4327
- _this43._remoteInterface.send("__messenger__exec_fnc", {
5312
+ _this36._remoteInterface.send("__messenger__exec_fnc", {
4328
5313
  instance_id: instanceID,
4329
- function_name: _this43._funcName,
5314
+ function_name: _this36._funcName,
4330
5315
  function_args: args
4331
5316
  });
4332
5317
 
4333
5318
  // execute the observers
4334
- _this43._functionObserver.call(_this43._funcName, {
5319
+ _this36._functionObserver.call(_this36._funcName, {
4335
5320
  type: "call",
4336
5321
  state: "success",
4337
5322
  data: args
@@ -4480,7 +5465,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4480
5465
  var google_analytics_1 = require("./google/google-analytics");
4481
5466
  var Analytics = /*#__PURE__*/function () {
4482
5467
  function Analytics(applicationID) {
4483
- var _this44 = this;
5468
+ var _this37 = this;
4484
5469
  _classCallCheck(this, Analytics);
4485
5470
  this._pageTime = null;
4486
5471
  this.origin = "production";
@@ -4494,17 +5479,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4494
5479
  this._ga = new google_analytics_1.GoogleAnalytics();
4495
5480
  this._handlePageHide = function () {
4496
5481
  if (document.visibilityState === "hidden") {
4497
- _this44._pageTime = new Date();
4498
- } else if (_this44._pageTime) {
5482
+ _this37._pageTime = new Date();
5483
+ } else if (_this37._pageTime) {
4499
5484
  var time2 = new Date();
4500
- var diff = time2.getTime() - _this44._pageTime.getTime();
4501
- var data = _this44.data;
5485
+ var diff = time2.getTime() - _this37._pageTime.getTime();
5486
+ var data = _this37.data;
4502
5487
  data.push("eventAction", "View Time");
4503
5488
  data.push("viewTime", diff);
4504
5489
  data.push("eventLabel", diff);
4505
- _this44.write();
4506
- _this44._pageTime = null;
4507
- document.removeEventListener("visibilitychange", _this44._handlePageHide, false);
5490
+ _this37.write();
5491
+ _this37._pageTime = null;
5492
+ document.removeEventListener("visibilitychange", _this37._handlePageHide, false);
4508
5493
  }
4509
5494
  };
4510
5495
  }
@@ -4516,18 +5501,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4516
5501
  }, {
4517
5502
  key: "query",
4518
5503
  value: function query() {
4519
- var _this45 = this;
5504
+ var _this38 = this;
4520
5505
  var _query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
4521
5506
  return new Promise(function (accept, reject) {
4522
5507
  if (!_query) {
4523
5508
  return reject(new Error("Analytics.query() - provided query was null"));
4524
5509
  }
4525
- var url = _this45.origin === "dev" ? "https://localhost:3008/v3/read" : "https://analytics.plattar.com/v3/read";
5510
+ var url = _this38.origin === "dev" ? "https://localhost:3008/v3/read" : "https://analytics.plattar.com/v3/read";
4526
5511
  var data = {
4527
5512
  data: {
4528
5513
  attributes: {
4529
- application_id: _this45._applicationID,
4530
- event: _this45.event,
5514
+ application_id: _this38._applicationID,
5515
+ event: _this38.event,
4531
5516
  query: _query
4532
5517
  }
4533
5518
  }
@@ -4540,22 +5525,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4540
5525
  }, {
4541
5526
  key: "write",
4542
5527
  value: function write() {
4543
- var _this46 = this;
5528
+ var _this39 = this;
4544
5529
  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);
5530
+ var data = _this39._data;
5531
+ var url = _this39.origin === "dev" ? "https://localhost:3008/v3/write" : "https://analytics.plattar.com/v3/write";
5532
+ data.push("applicationId", _this39._applicationID);
4548
5533
  var sendData = {
4549
5534
  data: {
4550
5535
  attributes: {
4551
- application_id: _this46._applicationID,
4552
- event: _this46.event,
4553
- origin: _this46.origin,
5536
+ application_id: _this39._applicationID,
5537
+ event: _this39.event,
5538
+ origin: _this39.origin,
4554
5539
  fields: data.data
4555
5540
  }
4556
5541
  }
4557
5542
  };
4558
- if (_this46.isBeacon === false) {
5543
+ if (_this39.isBeacon === false) {
4559
5544
  basic_http_1["default"].exec("POST", url, sendData).then(function (result) {
4560
5545
  accept(result ? result : {});
4561
5546
  })["catch"](reject);
@@ -4564,7 +5549,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4564
5549
  accept(result ? result : {});
4565
5550
  })["catch"](reject);
4566
5551
  }
4567
- _this46.googleAnalytics.write(_this46.event, _this46.data);
5552
+ _this39.googleAnalytics.write(_this39.event, _this39.data);
4568
5553
  });
4569
5554
  }
4570
5555
  }, {
@@ -5116,10 +6101,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5116
6101
  }, {
5117
6102
  key: "_get",
5118
6103
  value: function _get(opt) {
5119
- var _this47 = this;
6104
+ var _this40 = this;
5120
6105
  return new Promise(function (resolve, reject) {
5121
- var target = _this47.target;
5122
- var server = _this47.server;
6106
+ var target = _this40.target;
6107
+ var server = _this40.server;
5123
6108
 
5124
6109
  // we cannot perform a GET request without an ID
5125
6110
  if (!target.id) {
@@ -5144,15 +6129,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5144
6129
  var origin = server.originLocation.api_read;
5145
6130
  var auth = server.authToken;
5146
6131
  var headers = {
5147
- 'cookie': 'laravel_session=' + _this47.getCookie('laravel_session')
6132
+ 'cookie': 'laravel_session=' + _this40.getCookie('laravel_session')
5148
6133
  };
5149
6134
  Object.assign(headers, auth);
5150
6135
  var reqopts = {
5151
6136
  method: "GET",
5152
6137
  headers: headers
5153
6138
  };
5154
- var includeQuery = _this47._IncludeQuery;
5155
- var params = _this47._ParamFor("get");
6139
+ var includeQuery = _this40._IncludeQuery;
6140
+ var params = _this40._ParamFor("get");
5156
6141
  var endpoint = origin + target.type() + "/" + target.id;
5157
6142
  if (includeQuery) {
5158
6143
  endpoint = endpoint + "?include=" + includeQuery;
@@ -5187,10 +6172,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5187
6172
  }, {
5188
6173
  key: "_update",
5189
6174
  value: function _update() {
5190
- var _this48 = this;
6175
+ var _this41 = this;
5191
6176
  return new Promise(function (resolve, reject) {
5192
- var target = _this48.target;
5193
- var server = _this48.server;
6177
+ var target = _this41.target;
6178
+ var server = _this41.server;
5194
6179
 
5195
6180
  // we cannot perform a GET request without an ID
5196
6181
  if (!target.id) {
@@ -5204,7 +6189,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5204
6189
  var headers = {
5205
6190
  'Accept': 'application/json',
5206
6191
  'Content-Type': 'application/json',
5207
- 'cookie': 'laravel_session=' + _this48.getCookie('laravel_session')
6192
+ 'cookie': 'laravel_session=' + _this41.getCookie('laravel_session')
5208
6193
  };
5209
6194
  Object.assign(headers, auth);
5210
6195
  var reqopts = {
@@ -5218,7 +6203,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5218
6203
  meta: target.meta || {}
5219
6204
  })
5220
6205
  };
5221
- var params = _this48._ParamFor("update");
6206
+ var params = _this41._ParamFor("update");
5222
6207
  var endpoint = origin + target.type() + "/" + target.id;
5223
6208
  if (params) {
5224
6209
  var appender = "?";
@@ -5254,10 +6239,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5254
6239
  }, {
5255
6240
  key: "_create",
5256
6241
  value: function _create() {
5257
- var _this49 = this;
6242
+ var _this42 = this;
5258
6243
  return new Promise(function (resolve, reject) {
5259
- var target = _this49.target;
5260
- var server = _this49.server;
6244
+ var target = _this42.target;
6245
+ var server = _this42.server;
5261
6246
 
5262
6247
  // otherwise, proceed with the fetching op
5263
6248
  var origin = server.originLocation.api_write;
@@ -5265,7 +6250,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5265
6250
  var headers = {
5266
6251
  'Accept': 'application/json',
5267
6252
  'Content-Type': 'application/json',
5268
- 'cookie': 'laravel_session=' + _this49.getCookie('laravel_session')
6253
+ 'cookie': 'laravel_session=' + _this42.getCookie('laravel_session')
5269
6254
  };
5270
6255
  Object.assign(headers, auth);
5271
6256
  var reqopts = {
@@ -5278,7 +6263,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5278
6263
  meta: target.meta || {}
5279
6264
  })
5280
6265
  };
5281
- var params = _this49._ParamFor("create");
6266
+ var params = _this42._ParamFor("create");
5282
6267
  var endpoint = origin + target.type();
5283
6268
  if (params) {
5284
6269
  var appender = "?";
@@ -5315,10 +6300,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5315
6300
  }, {
5316
6301
  key: "_delete",
5317
6302
  value: function _delete() {
5318
- var _this50 = this;
6303
+ var _this43 = this;
5319
6304
  return new Promise(function (resolve, reject) {
5320
- var target = _this50.target;
5321
- var server = _this50.server;
6305
+ var target = _this43.target;
6306
+ var server = _this43.server;
5322
6307
 
5323
6308
  // we cannot perform a GET request without an ID
5324
6309
  if (!target.id) {
@@ -5332,7 +6317,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5332
6317
  var headers = {
5333
6318
  'Accept': 'application/json',
5334
6319
  'Content-Type': 'application/json',
5335
- 'cookie': 'laravel_session=' + _this50.getCookie('laravel_session')
6320
+ 'cookie': 'laravel_session=' + _this43.getCookie('laravel_session')
5336
6321
  };
5337
6322
  Object.assign(headers, auth);
5338
6323
  var reqopts = {
@@ -5346,7 +6331,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5346
6331
  meta: target.meta || {}
5347
6332
  })
5348
6333
  };
5349
- var params = _this50._ParamFor("delete");
6334
+ var params = _this43._ParamFor("delete");
5350
6335
  var endpoint = origin + target.type() + "/" + target.id;
5351
6336
  if (params) {
5352
6337
  var appender = "?";
@@ -5401,7 +6386,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5401
6386
  }, {
5402
6387
  key: "_include",
5403
6388
  value: function _include(args) {
5404
- var _this51 = this;
6389
+ var _this44 = this;
5405
6390
  if (!args || args.length <= 0) {
5406
6391
  return this;
5407
6392
  }
@@ -5411,20 +6396,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5411
6396
  if (Array.isArray(obj)) {
5412
6397
  obj.forEach(function (strObject) {
5413
6398
  if (typeof strObject === "string" || strObject instanceof String) {
5414
- _this51._getIncludeQuery.push(strObject);
6399
+ _this44._getIncludeQuery.push(strObject);
5415
6400
  } else {
5416
- throw new Error("PlattarQuery." + _this51.target.type() + ".include(...args) - argument of Array must only include Strings");
6401
+ throw new Error("PlattarQuery." + _this44.target.type() + ".include(...args) - argument of Array must only include Strings");
5417
6402
  }
5418
6403
  });
5419
6404
  } else if (PlattarUtil.isPlattarObject(obj)) {
5420
6405
  var type = obj.type();
5421
6406
  if (Array.isArray(type)) {
5422
- _this51._include(type);
6407
+ _this44._include(type);
5423
6408
  } else {
5424
- _this51._getIncludeQuery.push(type);
6409
+ _this44._getIncludeQuery.push(type);
5425
6410
  }
5426
6411
  } 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);
6412
+ throw new Error("PlattarQuery." + _this44.target.type() + ".include(...args) - argument must be of type PlattarObject or Array but was type=" + _typeof(obj) + " value=" + obj);
5428
6413
  }
5429
6414
  });
5430
6415
  return this;
@@ -5559,12 +6544,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5559
6544
  }, {
5560
6545
  key: "auth",
5561
6546
  value: function auth(token, opt) {
5562
- var _this52 = this;
6547
+ var _this45 = this;
5563
6548
  var copt = opt || {
5564
6549
  validate: false
5565
6550
  };
5566
6551
  return new Promise(function (resolve, reject) {
5567
- var server = _this52.originLocation.api_write;
6552
+ var server = _this45.originLocation.api_write;
5568
6553
  if (!server) {
5569
6554
  reject(new Error("Plattar.auth(token) - cannot authenticate as server not set via Plattar.origin(server)"));
5570
6555
  return;
@@ -5574,10 +6559,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5574
6559
  return;
5575
6560
  }
5576
6561
  if (!copt.validate) {
5577
- _this52._authToken = {
6562
+ _this45._authToken = {
5578
6563
  "plattar-auth-token": token
5579
6564
  };
5580
- resolve(_this52);
6565
+ resolve(_this45);
5581
6566
  return;
5582
6567
  }
5583
6568
  var endpoint = server + "plattaruser/xauth/validate";
@@ -5589,10 +6574,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5589
6574
  };
5590
6575
  fetch(endpoint, options).then(function (res) {
5591
6576
  if (res.ok) {
5592
- _this52._authToken = {
6577
+ _this45._authToken = {
5593
6578
  "plattar-auth-token": token
5594
6579
  };
5595
- resolve(_this52);
6580
+ resolve(_this45);
5596
6581
  } else {
5597
6582
  reject(new Error("Plattar.auth(token) - failed to validate authentication token at " + endpoint));
5598
6583
  }
@@ -5602,7 +6587,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5602
6587
  }, {
5603
6588
  key: "origin",
5604
6589
  value: function origin(server, opt) {
5605
- var _this53 = this;
6590
+ var _this46 = this;
5606
6591
  var copt = opt || {
5607
6592
  validate: false
5608
6593
  };
@@ -5612,8 +6597,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5612
6597
  return;
5613
6598
  }
5614
6599
  if (!copt.validate) {
5615
- _this53._serverLocation = server;
5616
- resolve(_this53);
6600
+ _this46._serverLocation = server;
6601
+ resolve(_this46);
5617
6602
  return;
5618
6603
  }
5619
6604
  var endpoint = server.api_read + "ping";
@@ -5622,8 +6607,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5622
6607
  };
5623
6608
  fetch(endpoint, options).then(function (res) {
5624
6609
  if (res.ok) {
5625
- _this53._serverLocation = server;
5626
- resolve(_this53);
6610
+ _this46._serverLocation = server;
6611
+ resolve(_this46);
5627
6612
  } else {
5628
6613
  reject(new Error("Plattar.origin(server) - failed to ping server at " + endpoint));
5629
6614
  }
@@ -5957,13 +6942,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5957
6942
  _inherits(FileBase, _PlattarBase11);
5958
6943
  var _super25 = _createSuper(FileBase);
5959
6944
  function FileBase(id, server) {
5960
- var _this54;
6945
+ var _this47;
5961
6946
  _classCallCheck(this, FileBase);
5962
- _this54 = _super25.call(this, id, server || Server["default"]());
5963
- if (_this54.constructor === FileBase) {
6947
+ _this47 = _super25.call(this, id, server || Server["default"]());
6948
+ if (_this47.constructor === FileBase) {
5964
6949
  throw new Error("FileBase is abstract and cannot be created");
5965
6950
  }
5966
- return _this54;
6951
+ return _this47;
5967
6952
  }
5968
6953
  _createClass(FileBase, [{
5969
6954
  key: "sourcePath",
@@ -6116,13 +7101,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6116
7101
  _inherits(PlattarBase, _PlattarObject);
6117
7102
  var _super30 = _createSuper(PlattarBase);
6118
7103
  function PlattarBase(id, server) {
6119
- var _this55;
7104
+ var _this48;
6120
7105
  _classCallCheck(this, PlattarBase);
6121
- _this55 = _super30.call(this, id, server || Server["default"]());
6122
- if (_this55.constructor === PlattarBase) {
7106
+ _this48 = _super30.call(this, id, server || Server["default"]());
7107
+ if (_this48.constructor === PlattarBase) {
6123
7108
  throw new Error("PlattarBase is abstract and cannot be created");
6124
7109
  }
6125
- return _this55;
7110
+ return _this48;
6126
7111
  }
6127
7112
  return _createClass(PlattarBase);
6128
7113
  }(PlattarObject);
@@ -6189,7 +7174,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6189
7174
  }, {
6190
7175
  key: "filter",
6191
7176
  value: function filter(obj, id) {
6192
- var _this56 = this;
7177
+ var _this49 = this;
6193
7178
  if (!obj) {
6194
7179
  return [];
6195
7180
  }
@@ -6205,7 +7190,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6205
7190
  if (Array.isArray(type)) {
6206
7191
  var compiledList = [];
6207
7192
  type.forEach(function (inObject) {
6208
- var retArray = _this56.filter(inObject, id);
7193
+ var retArray = _this49.filter(inObject, id);
6209
7194
  if (retArray.length > 0) {
6210
7195
  compiledList = compiledList.concat(retArray);
6211
7196
  }
@@ -6393,7 +7378,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6393
7378
  }, {
6394
7379
  key: "include",
6395
7380
  value: function include() {
6396
- var _this57 = this;
7381
+ var _this50 = this;
6397
7382
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
6398
7383
  args[_key6] = arguments[_key6];
6399
7384
  }
@@ -6406,15 +7391,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6406
7391
  if (Array.isArray(obj)) {
6407
7392
  obj.forEach(function (strObject) {
6408
7393
  if (typeof strObject === "string" || strObject instanceof String) {
6409
- includes.push("".concat(_this57.type(), ".").concat(strObject));
7394
+ includes.push("".concat(_this50.type(), ".").concat(strObject));
6410
7395
  } else {
6411
- throw new Error("PlattarObject." + _this57.type() + ".include(...args) - argument of Array must only include Strings");
7396
+ throw new Error("PlattarObject." + _this50.type() + ".include(...args) - argument of Array must only include Strings");
6412
7397
  }
6413
7398
  });
6414
7399
  } else if (obj.prototype instanceof PlattarObject) {
6415
- includes.push("".concat(_this57.type(), ".").concat(obj.type()));
7400
+ includes.push("".concat(_this50.type(), ".").concat(obj.type()));
6416
7401
  } 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);
7402
+ throw new Error("PlattarObject." + _this50.type() + ".include(...args) - argument must be of type PlattarObject or Array but was type=" + _typeof(obj) + " value=" + obj);
6418
7403
  }
6419
7404
  });
6420
7405
  return includes;
@@ -6544,13 +7529,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6544
7529
  _inherits(CardBase, _PlattarBase17);
6545
7530
  var _super36 = _createSuper(CardBase);
6546
7531
  function CardBase(id, server) {
6547
- var _this58;
7532
+ var _this51;
6548
7533
  _classCallCheck(this, CardBase);
6549
- _this58 = _super36.call(this, id, server || Server["default"]());
6550
- if (_this58.constructor === CardBase) {
7534
+ _this51 = _super36.call(this, id, server || Server["default"]());
7535
+ if (_this51.constructor === CardBase) {
6551
7536
  throw new Error("CardBase is abstract and cannot be created");
6552
7537
  }
6553
- return _this58;
7538
+ return _this51;
6554
7539
  }
6555
7540
  _createClass(CardBase, null, [{
6556
7541
  key: "type",
@@ -6867,13 +7852,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6867
7852
  _inherits(ProductBase, _PlattarBase19);
6868
7853
  var _super50 = _createSuper(ProductBase);
6869
7854
  function ProductBase(id, server) {
6870
- var _this59;
7855
+ var _this52;
6871
7856
  _classCallCheck(this, ProductBase);
6872
- _this59 = _super50.call(this, id, server || Server["default"]());
6873
- if (_this59.constructor === ProductBase) {
7857
+ _this52 = _super50.call(this, id, server || Server["default"]());
7858
+ if (_this52.constructor === ProductBase) {
6874
7859
  throw new Error("ProductBase is abstract and cannot be created");
6875
7860
  }
6876
- return _this59;
7861
+ return _this52;
6877
7862
  }
6878
7863
  _createClass(ProductBase, null, [{
6879
7864
  key: "type",
@@ -6983,13 +7968,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
6983
7968
  _inherits(SceneBase, _PlattarBase21);
6984
7969
  var _super55 = _createSuper(SceneBase);
6985
7970
  function SceneBase(id, server) {
6986
- var _this60;
7971
+ var _this53;
6987
7972
  _classCallCheck(this, SceneBase);
6988
- _this60 = _super55.call(this, id, server || Server["default"]());
6989
- if (_this60.constructor === SceneBase) {
7973
+ _this53 = _super55.call(this, id, server || Server["default"]());
7974
+ if (_this53.constructor === SceneBase) {
6990
7975
  throw new Error("SceneBase is abstract and cannot be created");
6991
7976
  }
6992
- return _this60;
7977
+ return _this53;
6993
7978
  }
6994
7979
  _createClass(SceneBase, null, [{
6995
7980
  key: "type",
@@ -7692,15 +8677,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7692
8677
  _createClass(BaseElement, [{
7693
8678
  key: "connectedCallback",
7694
8679
  value: function connectedCallback() {
7695
- var _this61 = this;
8680
+ var _this54 = this;
7696
8681
  if (this.hasAttribute("url")) {
7697
8682
  this.renderQRCode();
7698
8683
  }
7699
8684
  var observer = new MutationObserver(function (mutations) {
7700
8685
  mutations.forEach(function (mutation) {
7701
8686
  if (mutation.type === "attributes") {
7702
- if (_this61.hasAttribute("url")) {
7703
- _this61.renderQRCode();
8687
+ if (_this54.hasAttribute("url")) {
8688
+ _this54.renderQRCode();
7704
8689
  }
7705
8690
  }
7706
8691
  });
@@ -7723,7 +8708,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7723
8708
  }, {
7724
8709
  key: "renderQRCode",
7725
8710
  value: function renderQRCode() {
7726
- var _this62 = this;
8711
+ var _this55 = this;
7727
8712
  var url = this.hasAttribute("url") ? this.getAttribute("url") : undefined;
7728
8713
  if (!url) {
7729
8714
  console.warn("PlattarQR.renderQRCode() - required attribute \"url\" is missing or invalid, QR Code will not render");
@@ -7831,11 +8816,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7831
8816
  var shortenURL = this.hasAttribute("shorten") ? this.getAttribute("shorten") : "false";
7832
8817
  if (shortenURL && shortenURL.toLowerCase() === "true") {
7833
8818
  this._ShortenURL(url).then(function (newURL) {
7834
- _this62._GenerateQRCode(newURL, width, height);
8819
+ _this55._GenerateQRCode(newURL, width, height);
7835
8820
  })["catch"](function (_err) {
7836
8821
  console.warn(_err);
7837
8822
  // ignore error and just generate normal QR Code
7838
- _this62._GenerateQRCode(url, width, height);
8823
+ _this55._GenerateQRCode(url, width, height);
7839
8824
  });
7840
8825
  } else {
7841
8826
  this._GenerateQRCode(url, width, height);
@@ -7904,9 +8889,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
7904
8889
  }, {
7905
8890
  key: "_ShortenURL",
7906
8891
  value: function _ShortenURL(url) {
7907
- var _this63 = this;
8892
+ var _this56 = this;
7908
8893
  return new Promise(function (accept, reject) {
7909
- if (!_this63._IsFetchAPISupported()) {
8894
+ if (!_this56._IsFetchAPISupported()) {
7910
8895
  return reject(new Error("PlattarQR._ShortenURL() - fetch api not supported, cannot proceed"));
7911
8896
  }
7912
8897
  try {
@@ -8099,10 +9084,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8099
9084
  }, {
8100
9085
  key: "get",
8101
9086
  value: function get() {
8102
- var _this64 = this;
9087
+ var _this57 = this;
8103
9088
  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);
9089
+ _this57._CalculateHash().then(function () {
9090
+ remote_request_1.RemoteRequest.request(_this57._GetPayload(), _this57.retry < 0 ? 0 : _this57.retry).then(accept)["catch"](reject);
8106
9091
  })["catch"](function (_err) {
8107
9092
  reject(new Error("Configurator.get() - one of the objects does not exist in Plattar API"));
8108
9093
  });
@@ -8111,12 +9096,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8111
9096
  }, {
8112
9097
  key: "_CalculateHash",
8113
9098
  value: function _CalculateHash() {
8114
- var _this65 = this;
9099
+ var _this58 = this;
8115
9100
  return new Promise(function (accept, reject) {
8116
9101
  var promises = [];
8117
9102
  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) {
9103
+ plattar_api_1.Server.create(plattar_api_1.Server.match(_this58.server));
9104
+ _this58._maps.forEach(function (map) {
8120
9105
  if (map.productvariation) {
8121
9106
  promises.push(new plattar_api_1.ProductVariation(map.productvariation).get());
8122
9107
  }
@@ -8132,7 +9117,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8132
9117
  });
8133
9118
  Promise.all(promises).then(function (values) {
8134
9119
  values.forEach(function (value) {
8135
- _this65._attrHash.push(value.attributes);
9120
+ _this58._attrHash.push(value.attributes);
8136
9121
  });
8137
9122
  // reset server back
8138
9123
  plattar_api_1.Server.create(plattar_api_1.Server.match(oldOrigin));
@@ -8219,12 +9204,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
8219
9204
  }, {
8220
9205
  key: "get",
8221
9206
  value: function get() {
8222
- var _this66 = this;
9207
+ var _this59 = this;
8223
9208
  return new Promise(function (accept, reject) {
8224
- if (!_this66._model) {
9209
+ if (!_this59._model) {
8225
9210
  return reject(new Error("ModelConverter.get() - required .model attribute was not set"));
8226
9211
  }
8227
- remote_request_1.RemoteRequest.request(_this66._Payload, _this66.retry < 0 ? 0 : _this66.retry).then(accept)["catch"](reject);
9212
+ remote_request_1.RemoteRequest.request(_this59._Payload, _this59.retry < 0 ? 0 : _this59.retry).then(accept)["catch"](reject);
8228
9213
  });
8229
9214
  }
8230
9215
  }, {
@@ -9589,18 +10574,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9589
10574
  }, {
9590
10575
  key: "allMappedAttributes",
9591
10576
  get: function get() {
9592
- var _this67 = this;
10577
+ var _this60 = this;
9593
10578
  var map = new Map();
9594
10579
  var coreAttr = this.coreAttributes;
9595
10580
  var optAttr = this.optionalAttributes;
9596
10581
  coreAttr.forEach(function (ele) {
9597
- if (_this67.hasAttribute(ele.key)) {
9598
- map.set(ele.map, _this67.getAttribute(ele.key));
10582
+ if (_this60.hasAttribute(ele.key)) {
10583
+ map.set(ele.map, _this60.getAttribute(ele.key));
9599
10584
  }
9600
10585
  });
9601
10586
  optAttr.forEach(function (ele) {
9602
- if (_this67.hasAttribute(ele.key)) {
9603
- map.set(ele.map, _this67.getAttribute(ele.key));
10587
+ if (_this60.hasAttribute(ele.key)) {
10588
+ map.set(ele.map, _this60.getAttribute(ele.key));
9604
10589
  }
9605
10590
  });
9606
10591
  return map;
@@ -9700,7 +10685,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9700
10685
  var IFrameController = require("./iframe-controller.js");
9701
10686
  var ElementController = /*#__PURE__*/function () {
9702
10687
  function ElementController(element) {
9703
- var _this68 = this;
10688
+ var _this61 = this;
9704
10689
  _classCallCheck(this, ElementController);
9705
10690
  this._element = element;
9706
10691
 
@@ -9713,7 +10698,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9713
10698
  var mutation = _step8.value;
9714
10699
  if (mutation.type === 'attributes' && element.usesAttribute(mutation.attributeName)) {
9715
10700
  if (element.hasAllCoreAttributes) {
9716
- _this68._load();
10701
+ _this61._load();
9717
10702
  }
9718
10703
  }
9719
10704
  }
@@ -9808,7 +10793,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9808
10793
  var Util = require("../../util/util.js");
9809
10794
  var IFrameController = /*#__PURE__*/function () {
9810
10795
  function IFrameController(element, src, id) {
9811
- var _this69 = this;
10796
+ var _this62 = this;
9812
10797
  var onelemload = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
9813
10798
  _classCallCheck(this, IFrameController);
9814
10799
  this._iframe = document.createElement("iframe");
@@ -9818,7 +10803,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9818
10803
  if (!element.hasAttribute("sameorigin")) {
9819
10804
  this._iframe.onload = function () {
9820
10805
  if (onelemload) {
9821
- onelemload(_this69._iframe);
10806
+ onelemload(_this62._iframe);
9822
10807
  }
9823
10808
  };
9824
10809
  }
@@ -9935,13 +10920,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
9935
10920
  _inherits(EWallElement, _BaseElement4);
9936
10921
  var _super76 = _createSuper(EWallElement);
9937
10922
  function EWallElement() {
9938
- var _this70;
10923
+ var _this63;
9939
10924
  _classCallCheck(this, EWallElement);
9940
- _this70 = _super76.call(this);
10925
+ _this63 = _super76.call(this);
9941
10926
  var tag = document.createElement("script");
9942
10927
  tag.src = "https://cdn.8thwall.com/web/iframe/iframe.js";
9943
10928
  tag.defer = true;
9944
- return _this70;
10929
+ return _this63;
9945
10930
  }
9946
10931
  _createClass(EWallElement, [{
9947
10932
  key: "connectedCallback",