UNPKG

256 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
5 define("app-bridge", [], factory);
6 else if(typeof exports === 'object')
7 exports["app-bridge"] = factory();
8 else
9 root["app-bridge"] = factory();
10})(window, function() {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14/******/
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17/******/
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId]) {
20/******/ return installedModules[moduleId].exports;
21/******/ }
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ i: moduleId,
25/******/ l: false,
26/******/ exports: {}
27/******/ };
28/******/
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31/******/
32/******/ // Flag the module as loaded
33/******/ module.l = true;
34/******/
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38/******/
39/******/
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42/******/
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45/******/
46/******/ // define getter function for harmony exports
47/******/ __webpack_require__.d = function(exports, name, getter) {
48/******/ if(!__webpack_require__.o(exports, name)) {
49/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50/******/ }
51/******/ };
52/******/
53/******/ // define __esModule on exports
54/******/ __webpack_require__.r = function(exports) {
55/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57/******/ }
58/******/ Object.defineProperty(exports, '__esModule', { value: true });
59/******/ };
60/******/
61/******/ // create a fake namespace object
62/******/ // mode & 1: value is a module id, require it
63/******/ // mode & 2: merge all properties of value into the ns
64/******/ // mode & 4: return value when already ns object
65/******/ // mode & 8|1: behave like require
66/******/ __webpack_require__.t = function(value, mode) {
67/******/ if(mode & 1) value = __webpack_require__(value);
68/******/ if(mode & 8) return value;
69/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70/******/ var ns = Object.create(null);
71/******/ __webpack_require__.r(ns);
72/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74/******/ return ns;
75/******/ };
76/******/
77/******/ // getDefaultExport function for compatibility with non-harmony modules
78/******/ __webpack_require__.n = function(module) {
79/******/ var getter = module && module.__esModule ?
80/******/ function getDefault() { return module['default']; } :
81/******/ function getModuleExports() { return module; };
82/******/ __webpack_require__.d(getter, 'a', getter);
83/******/ return getter;
84/******/ };
85/******/
86/******/ // Object.prototype.hasOwnProperty.call
87/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88/******/
89/******/ // __webpack_public_path__
90/******/ __webpack_require__.p = "";
91/******/
92/******/
93/******/ // Load entry module and return exports
94/******/ return __webpack_require__(__webpack_require__.s = 41);
95/******/ })
96/************************************************************************/
97/******/ ([
98/* 0 */
99/***/ (function(module, exports, __webpack_require__) {
100
101"use strict";
102
103var __extends = (this && this.__extends) || (function () {
104 var extendStatics = function (d, b) {
105 extendStatics = Object.setPrototypeOf ||
106 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
107 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
108 return extendStatics(d, b);
109 };
110 return function (d, b) {
111 extendStatics(d, b);
112 function __() { this.constructor = d; }
113 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
114 };
115})();
116var __assign = (this && this.__assign) || function () {
117 __assign = Object.assign || function(t) {
118 for (var s, i = 1, n = arguments.length; i < n; i++) {
119 s = arguments[i];
120 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
121 t[p] = s[p];
122 }
123 return t;
124 };
125 return __assign.apply(this, arguments);
126};
127var __spreadArrays = (this && this.__spreadArrays) || function () {
128 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
129 for (var r = Array(s), k = 0, i = 0; i < il; i++)
130 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
131 r[k] = a[j];
132 return r;
133};
134var __importDefault = (this && this.__importDefault) || function (mod) {
135 return (mod && mod.__esModule) ? mod : { "default": mod };
136};
137Object.defineProperty(exports, "__esModule", { value: true });
138exports.NonSnakeCaseGroup = exports.findMatchInEnum = exports.forEachInEnum = exports.getMergedProps = exports.updateActionFromPayload = exports.ActionSetWithChildren = exports.ActionSet = exports.isValidOptionalString = exports.isValidOptionalNumber = exports.getEventNameSpace = exports.getVersion = exports.actionWrapper = void 0;
139var types_1 = __webpack_require__(6);
140var collection_1 = __webpack_require__(12);
141var Error_1 = __webpack_require__(5);
142var constants_1 = __webpack_require__(17);
143var merge_1 = __importDefault(__webpack_require__(44));
144var types_2 = __webpack_require__(1);
145var uuid_1 = __importDefault(__webpack_require__(45));
146var packageJson = __webpack_require__(46);
147function actionWrapper(action) {
148 return __assign(__assign({}, action), { version: getVersion(), clientInterface: {
149 name: packageJson.name,
150 version: getVersion(),
151 } });
152}
153exports.actionWrapper = actionWrapper;
154function getVersion() {
155 return packageJson.version;
156}
157exports.getVersion = getVersion;
158/**
159 * Returns full event name with prefix, group, subgroups and type formatted with separators
160 * @internal
161 * */
162function getEventNameSpace(group, eventName, component) {
163 if (eventName.startsWith("" + constants_1.PREFIX + constants_1.SEPARATOR)) {
164 return eventName;
165 }
166 var eventNameSpace = groupToEventNameSpace(group);
167 if (component) {
168 var subgroups_1 = component.subgroups, type = component.type;
169 if (subgroups_1 && subgroups_1.length > 0) {
170 eventNameSpace += eventNameSpace.length > 0 ? constants_1.SEPARATOR : '';
171 subgroups_1.forEach(function (subgroup, index) {
172 eventNameSpace += "" + subgroup.toUpperCase() + (index < subgroups_1.length - 1 ? constants_1.SEPARATOR : '');
173 });
174 }
175 if (type !== group && type) {
176 eventNameSpace += "" + (eventNameSpace.length > 0 ? constants_1.SEPARATOR : '') + type.toUpperCase();
177 }
178 }
179 if (eventNameSpace) {
180 eventNameSpace += "" + (eventNameSpace.length > 0 ? constants_1.SEPARATOR : '') + eventName.toUpperCase();
181 }
182 return "" + constants_1.PREFIX + constants_1.SEPARATOR + eventNameSpace;
183}
184exports.getEventNameSpace = getEventNameSpace;
185function isValidOptionalNumber(value) {
186 return value === null || value === undefined || typeof value === 'number';
187}
188exports.isValidOptionalNumber = isValidOptionalNumber;
189function isValidOptionalString(value) {
190 return value === null || value === undefined || typeof value === 'string';
191}
192exports.isValidOptionalString = isValidOptionalString;
193var ActionSet = /** @class */ (function () {
194 function ActionSet(app, type, group, id) {
195 var _this = this;
196 this.app = app;
197 this.type = type;
198 this.group = group;
199 this.subgroups = [];
200 this.subscriptions = [];
201 if (!app) {
202 Error_1.throwError(Error_1.Action.INVALID_ACTION, 'Missing required `app`');
203 }
204 this.id = id || uuid_1.default();
205 this.defaultGroup = group;
206 var defaultSet = this.set;
207 this.set = function () {
208 var _a;
209 var args = [];
210 for (var _i = 0; _i < arguments.length; _i++) {
211 args[_i] = arguments[_i];
212 }
213 if (!_this.app.hooks) {
214 return defaultSet.apply(_this, args);
215 }
216 return (_a = _this.app.hooks).run.apply(_a, __spreadArrays([types_1.LifecycleHook.UpdateAction, defaultSet, _this], args));
217 };
218 }
219 ActionSet.prototype.set = function () {
220 var _ = [];
221 for (var _i = 0; _i < arguments.length; _i++) {
222 _[_i] = arguments[_i];
223 }
224 };
225 Object.defineProperty(ActionSet.prototype, "component", {
226 get: function () {
227 return {
228 id: this.id,
229 subgroups: this.subgroups,
230 type: this.type,
231 };
232 },
233 enumerable: false,
234 configurable: true
235 });
236 ActionSet.prototype.updateSubscription = function (subscriptionToRemove, group, subgroups) {
237 var eventType = subscriptionToRemove.eventType, callback = subscriptionToRemove.callback, component = subscriptionToRemove.component;
238 var currentIndex;
239 currentIndex = this.subscriptions.findIndex(function (subscription) { return subscription === subscriptionToRemove; });
240 if (currentIndex >= 0) {
241 this.subscriptions[currentIndex].unsubscribe();
242 }
243 else {
244 currentIndex = undefined;
245 }
246 this.group = group;
247 this.subgroups = subgroups;
248 Object.assign(component, { subgroups: this.subgroups });
249 return this.subscribe(eventType, callback, component, currentIndex);
250 };
251 ActionSet.prototype.error = function (callback) {
252 var _this = this;
253 var subscriptionIndices = [];
254 forEachInEnum(Error_1.Action, function (eventNameSpace) {
255 // Keep track of subscription index so we can call unsubscribe later
256 // This ensure it will continue to work even when the subscription has been updated
257 subscriptionIndices.push(_this.subscriptions.length);
258 _this.subscribe(eventNameSpace, callback);
259 });
260 return function () {
261 var subscriptionsToRemove = subscriptionIndices.map(function (index) { return _this.subscriptions[index]; });
262 subscriptionsToRemove.forEach(function (toRemove) {
263 collection_1.removeFromCollection(_this.subscriptions, toRemove, function (removed) {
264 removed.unsubscribe();
265 });
266 });
267 };
268 };
269 ActionSet.prototype.subscribe = function (eventName, callback, component, currentIndex) {
270 var _this = this;
271 var eventComponent = component || this.component;
272 var eventType = eventName.toUpperCase();
273 var boundedCallback = typeof currentIndex === 'number' ? callback : callback.bind(this);
274 var eventNameSpace;
275 if (Error_1.isErrorEventName(eventName)) {
276 eventNameSpace = getEventNameSpace(types_2.Group.Error, eventName, __assign(__assign({}, eventComponent), { type: '' }));
277 }
278 else {
279 eventNameSpace = getEventNameSpace(this.group, eventName, eventComponent);
280 }
281 var unsubscribe = this.app.subscribe(eventNameSpace, boundedCallback, component ? component.id : this.id);
282 var subscription = {
283 eventType: eventType,
284 unsubscribe: unsubscribe,
285 callback: boundedCallback,
286 component: eventComponent,
287 updateSubscribe: function (group, subgroups) {
288 return _this.updateSubscription.call(_this, subscription, group, subgroups);
289 },
290 };
291 if (typeof currentIndex === 'number' &&
292 currentIndex >= 0 &&
293 currentIndex < this.subscriptions.length) {
294 this.subscriptions[currentIndex] = subscription;
295 }
296 else {
297 this.subscriptions.push(subscription);
298 }
299 return unsubscribe;
300 };
301 ActionSet.prototype.unsubscribe = function (resetOnly) {
302 if (resetOnly === void 0) { resetOnly = false; }
303 unsubscribeActions(this.subscriptions, this.defaultGroup, resetOnly);
304 return this;
305 };
306 return ActionSet;
307}());
308exports.ActionSet = ActionSet;
309var ActionSetWithChildren = /** @class */ (function (_super) {
310 __extends(ActionSetWithChildren, _super);
311 function ActionSetWithChildren() {
312 var _this = _super !== null && _super.apply(this, arguments) || this;
313 _this.children = [];
314 return _this;
315 }
316 ActionSetWithChildren.prototype.unsubscribe = function (unsubscribeChildren, resetParentOnly) {
317 if (unsubscribeChildren === void 0) { unsubscribeChildren = true; }
318 if (resetParentOnly === void 0) { resetParentOnly = false; }
319 unsubscribeActions(this.subscriptions, this.defaultGroup, resetParentOnly);
320 this.children.forEach(function (child) {
321 if (ActionSetWithChildren.prototype.isPrototypeOf(child)) {
322 child.unsubscribe(unsubscribeChildren, !unsubscribeChildren);
323 }
324 else {
325 child.unsubscribe(!unsubscribeChildren);
326 }
327 });
328 return this;
329 };
330 ActionSetWithChildren.prototype.getChild = function (id) {
331 var childIndex = this.children.findIndex(function (child) { return child.id === id; });
332 return childIndex >= 0 ? this.children[childIndex] : undefined;
333 };
334 ActionSetWithChildren.prototype.getChildIndex = function (id) {
335 return this.children.findIndex(function (child) { return child.id === id; });
336 };
337 ActionSetWithChildren.prototype.getChildSubscriptions = function (id, eventType) {
338 return this.subscriptions.filter(function (sub) { return sub.component.id === id && (!eventType || eventType === sub.eventType); });
339 };
340 ActionSetWithChildren.prototype.addChild = function (child, group, subgroups) {
341 var _this = this;
342 var subscriptions = child.subscriptions;
343 var existingChild = this.getChild(child.id);
344 // Add child if it doesn't already exist
345 if (!existingChild) {
346 this.children.push(child);
347 }
348 if (!subscriptions || (group === child.group && subgroups === child.subgroups)) {
349 return this;
350 }
351 subscriptions.forEach(function (subscription) {
352 var updateSubscribe = subscription.updateSubscribe;
353 updateSubscribe(group, subgroups);
354 });
355 // Update child's group and subgroups
356 Object.assign(child, { group: group, subgroups: subgroups });
357 // Update child's children subscriptions
358 if (ActionSetWithChildren.prototype.isPrototypeOf(child)) {
359 child.children.forEach(function (c) { return _this.addChild(c, group, subgroups); });
360 }
361 return this;
362 };
363 ActionSetWithChildren.prototype.removeChild = function (id) {
364 var _this = this;
365 collection_1.removeFromCollection(this.children, this.getChild(id), function () {
366 var toBeRemoved = _this.subscriptions.filter(function (subs) { return subs.component.id === id; });
367 toBeRemoved.forEach(function (toRemove) {
368 collection_1.removeFromCollection(_this.subscriptions, toRemove, function (removed) {
369 removed.unsubscribe();
370 });
371 });
372 });
373 return this;
374 };
375 ActionSetWithChildren.prototype.subscribeToChild = function (child, eventName, callback) {
376 var _this = this;
377 var boundedCallback = callback.bind(this);
378 if (eventName instanceof Array) {
379 eventName.forEach(function (e) { return _this.subscribeToChild(child, e, callback); });
380 return this;
381 }
382 if (typeof eventName !== 'string') {
383 return this;
384 }
385 var eventType = eventName.toUpperCase();
386 var currentSubscriptions = this.getChildSubscriptions(child.id, eventType);
387 if (currentSubscriptions.length > 0) {
388 // Subscription is already there, simply update it
389 currentSubscriptions.forEach(function (subs) { return subs.updateSubscribe(_this.group, child.subgroups); });
390 }
391 else {
392 var childComponent = {
393 id: child.id,
394 subgroups: child.subgroups,
395 type: child.type,
396 };
397 this.subscribe(eventType, boundedCallback, childComponent);
398 }
399 return this;
400 };
401 ActionSetWithChildren.prototype.getUpdatedChildActions = function (newActions, currentActions) {
402 if (newActions.length === 0) {
403 while (currentActions.length > 0) {
404 var action = currentActions.pop();
405 if (!action) {
406 break;
407 }
408 this.removeChild(action.id);
409 }
410 return undefined;
411 }
412 // Only allow unique actions
413 var uniqueActions = newActions.filter(function (action, index, actionsArr) { return index === actionsArr.indexOf(action); });
414 var newActionIds = uniqueActions.map(function (action) { return action.id; });
415 // Remove unused actions
416 var unusedActions = currentActions.filter(function (action) {
417 return newActionIds.indexOf(action.id) < 0;
418 });
419 while (unusedActions.length > 0) {
420 var action = unusedActions.pop();
421 if (!action) {
422 break;
423 }
424 this.removeChild(action.id);
425 }
426 return uniqueActions;
427 };
428 return ActionSetWithChildren;
429}(ActionSet));
430exports.ActionSetWithChildren = ActionSetWithChildren;
431function unsubscribeActions(subscriptions, defaultGroup, reassign) {
432 if (reassign === void 0) { reassign = false; }
433 subscriptions.forEach(function (subscription) {
434 if (reassign) {
435 var updateSubscribe = subscription.updateSubscribe;
436 // TODO: Support cases where we don't wipe out group and subgroups to defaults
437 updateSubscribe(defaultGroup, []);
438 }
439 else {
440 var unsubscribe = subscription.unsubscribe;
441 unsubscribe();
442 }
443 });
444 if (!reassign) {
445 subscriptions.length = 0;
446 }
447}
448function updateActionFromPayload(action, newProps) {
449 var id = action.id;
450 if (id === newProps.id) {
451 // Merge new properties
452 Object.assign(action, getMergedProps(action, newProps));
453 return true;
454 }
455 return false;
456}
457exports.updateActionFromPayload = updateActionFromPayload;
458function getMergedProps(props, newProps) {
459 var merged = merge_1.default(props, newProps);
460 if (!merged) {
461 // tslint:disable-next-line:prefer-object-spread
462 var cloned = Object.assign(props, newProps);
463 return cloned;
464 }
465 return merged;
466}
467exports.getMergedProps = getMergedProps;
468function forEachInEnum(types, callback) {
469 Object.keys(types).forEach(function (key) {
470 callback(types[key]);
471 });
472}
473exports.forEachInEnum = forEachInEnum;
474function findMatchInEnum(types, lookup) {
475 var match = Object.keys(types).find(function (key) {
476 return lookup === types[key];
477 });
478 return match ? types[match] : undefined;
479}
480exports.findMatchInEnum = findMatchInEnum;
481function camelCaseToSnakeCase(value) {
482 return value.replace(/([A-Z])/g, function (matcher, _val, index) {
483 return "" + (index !== 0 ? '_' : '') + matcher[0].toLowerCase();
484 });
485}
486exports.NonSnakeCaseGroup = [
487 types_2.Group.AuthCode,
488 types_2.Group.Button,
489 types_2.Group.ButtonGroup,
490 types_2.Group.Cart,
491 types_2.Group.Error,
492 types_2.Group.Features,
493 types_2.Group.Fullscreen,
494 types_2.Group.Link,
495 types_2.Group.Loading,
496 types_2.Group.Menu,
497 types_2.Group.Modal,
498 types_2.Group.Navigation,
499 types_2.Group.Pos,
500 types_2.Group.Print,
501 types_2.Group.ResourcePicker,
502 types_2.Group.Scanner,
503 types_2.Group.SessionToken,
504 types_2.Group.Share,
505 types_2.Group.TitleBar,
506 types_2.Group.Toast,
507];
508/**
509 * Maps the group name to its event name
510 * @internal
511 * @remarks - This method is necessary for the new pattern of using snake case
512 * which makes it more readable and easier to reconstruct the group from an event name.
513 * Example: `ContextualSaveBar` becomes `CONTEXTUAL_SAVE_BAR`
514 * */
515function groupToEventNameSpace(group) {
516 if (exports.NonSnakeCaseGroup.includes(group)) {
517 return group.toUpperCase();
518 }
519 return camelCaseToSnakeCase(group).toUpperCase();
520}
521
522
523/***/ }),
524/* 1 */
525/***/ (function(module, exports, __webpack_require__) {
526
527"use strict";
528
529Object.defineProperty(exports, "__esModule", { value: true });
530exports.ComponentType = exports.Group = void 0;
531/**
532 * Various action groups.
533 * @public
534 */
535var Group;
536(function (Group) {
537 Group["AuthCode"] = "AuthCode";
538 Group["Button"] = "Button";
539 Group["ButtonGroup"] = "ButtonGroup";
540 Group["Cart"] = "Cart";
541 Group["Client"] = "Client";
542 Group["ContextualSaveBar"] = "ContextualSaveBar";
543 Group["Error"] = "Error";
544 Group["Features"] = "Features";
545 Group["FeedbackModal"] = "FeedbackModal";
546 Group["Fullscreen"] = "Fullscreen";
547 Group["LeaveConfirmation"] = "LeaveConfirmation";
548 Group["Link"] = "Link";
549 Group["Loading"] = "Loading";
550 Group["Menu"] = "Menu";
551 Group["Modal"] = "Modal";
552 Group["Navigation"] = "Navigation";
553 Group["Performance"] = "Performance";
554 Group["Pos"] = "Pos";
555 Group["Print"] = "Print";
556 Group["ResourcePicker"] = "Resource_Picker";
557 Group["Scanner"] = "Scanner";
558 Group["SessionToken"] = "SessionToken";
559 Group["Share"] = "Share";
560 Group["TitleBar"] = "TitleBar";
561 Group["Toast"] = "Toast";
562 Group["MarketingExternalActivityTopBar"] = "MarketingExternalActivityTopBar";
563})(Group = exports.Group || (exports.Group = {}));
564/**
565 * @internal
566 */
567var ComponentType;
568(function (ComponentType) {
569 ComponentType["Button"] = "Button";
570 ComponentType["ButtonGroup"] = "ButtonGroup";
571})(ComponentType = exports.ComponentType || (exports.ComponentType = {}));
572
573
574/***/ }),
575/* 2 */
576/***/ (function(module, exports, __webpack_require__) {
577
578"use strict";
579
580var __assign = (this && this.__assign) || function () {
581 __assign = Object.assign || function(t) {
582 for (var s, i = 1, n = arguments.length; i < n; i++) {
583 s = arguments[i];
584 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
585 t[p] = s[p];
586 }
587 return t;
588 };
589 return __assign.apply(this, arguments);
590};
591var __spreadArrays = (this && this.__spreadArrays) || function () {
592 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
593 for (var r = Array(s), k = 0, i = 0; i < il; i++)
594 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
595 r[k] = a[j];
596 return r;
597};
598Object.defineProperty(exports, "__esModule", { value: true });
599exports.validate = exports.composeSchemas = exports.makeOptional = exports.oneOf = exports.matchesObject = exports.matchesArray = exports.matchesEnum = exports.matchesPositiveNumber = exports.matchesPositiveInteger = exports.matchesString = exports.matchesBoolean = void 0;
600var TYPE_ERROR = 'type_error_expected';
601function constructErrors(value, error, options) {
602 if (options === void 0) { options = { message: undefined }; }
603 return [
604 {
605 value: value,
606 error: error,
607 message: typeof options.message === 'function' ? options.message(error, value) : options.message,
608 },
609 ];
610}
611function getErrors(obj, validator, key) {
612 var value = key ? obj[key] : obj;
613 var path = key ? "['" + key + "']" : undefined;
614 var error = validator(value);
615 if (!error) {
616 return;
617 }
618 return error.map(function (o) { return (__assign(__assign({}, o), { path: "" + (path || '') + (o.path || '') || undefined })); });
619}
620function matchesBoolean(options) {
621 return function (value) {
622 return typeof value === 'boolean'
623 ? undefined
624 : constructErrors(value, TYPE_ERROR + "_boolean", options);
625 };
626}
627exports.matchesBoolean = matchesBoolean;
628function matchesString(options) {
629 return function (value) {
630 return typeof value === 'string' ? undefined : constructErrors(value, TYPE_ERROR + "_string", options);
631 };
632}
633exports.matchesString = matchesString;
634function matchesPositiveInteger(options) {
635 return function (value) {
636 return !Number.isInteger(value) || value < 0
637 ? constructErrors(value, TYPE_ERROR + "_integer", options)
638 : undefined;
639 };
640}
641exports.matchesPositiveInteger = matchesPositiveInteger;
642function matchesPositiveNumber(options) {
643 return function (value) {
644 return Number.isNaN(value) || !Number.isFinite(value) || value < 0
645 ? constructErrors(value, TYPE_ERROR + "_number", options)
646 : undefined;
647 };
648}
649exports.matchesPositiveNumber = matchesPositiveNumber;
650/**
651 * Returns a validator that matches values in the given enum
652 * @param type - enum to use for match values
653 * @public
654 */
655function matchesEnum(types, options) {
656 return function (value) {
657 var values = Object.keys(types).map(function (key) { return types[key]; });
658 var message = (options && options.message) || "expected:" + values.map(function (val) { return "`" + val + "`"; }).join(' or ');
659 return values.includes(value)
660 ? undefined
661 : constructErrors(value, 'invalid_enum_value', __assign(__assign({}, options), { message: message }));
662 };
663}
664exports.matchesEnum = matchesEnum;
665function matchesArray(validator, options) {
666 return function (value) {
667 if (!Array.isArray(value)) {
668 return constructErrors(value, TYPE_ERROR + "_array", options);
669 }
670 if (!validator) {
671 return;
672 }
673 var errors = [];
674 value.forEach(function (val, key) {
675 var objectError = validator(val);
676 if (objectError) {
677 errors = errors.concat(objectError.map(function (error) { return (__assign(__assign({}, error), { path: "['" + key + "']" + (error.path || '') })); }));
678 }
679 });
680 return errors.length ? errors : undefined;
681 };
682}
683exports.matchesArray = matchesArray;
684function matchesObject(schema, options) {
685 return function (val) {
686 if (typeof val !== 'object' || !val || Array.isArray(val)) {
687 return constructErrors(val, TYPE_ERROR + "_object", options);
688 }
689 var flattened = Object.keys(schema).reduce(function (acc, key) {
690 return __spreadArrays(acc, (getErrors(val, schema[key], key) || []));
691 }, []);
692 return flattened.length ? flattened : undefined;
693 };
694}
695exports.matchesObject = matchesObject;
696function oneOf() {
697 var validators = [];
698 for (var _i = 0; _i < arguments.length; _i++) {
699 validators[_i] = arguments[_i];
700 }
701 return function (val) {
702 var errors = [];
703 for (var _i = 0, validators_1 = validators; _i < validators_1.length; _i++) {
704 var validator = validators_1[_i];
705 var result = validator(val);
706 if (result == null)
707 return result;
708 errors.push.apply(errors, result);
709 }
710 return errors;
711 };
712}
713exports.oneOf = oneOf;
714function makeOptional(validator) {
715 return function (value) {
716 if (value === undefined || value === null) {
717 return undefined;
718 }
719 return validator(value);
720 };
721}
722exports.makeOptional = makeOptional;
723function composeSchemas() {
724 var validators = [];
725 for (var _i = 0; _i < arguments.length; _i++) {
726 validators[_i] = arguments[_i];
727 }
728 return function (val) {
729 var error;
730 var i = 0;
731 var len = validators.length;
732 while (!error && i < len) {
733 error = validators[i](val);
734 if (error) {
735 return error;
736 }
737 i++;
738 }
739 };
740}
741exports.composeSchemas = composeSchemas;
742function validate(obj, validator) {
743 return getErrors(obj, validator);
744}
745exports.validate = validate;
746
747
748/***/ }),
749/* 3 */
750/***/ (function(module, exports, __webpack_require__) {
751
752"use strict";
753
754Object.defineProperty(exports, "__esModule", { value: true });
755exports.mixedAppClientCheck = exports.relativePathSchema = exports.relativeUrlSchema = exports.isValidRelativePath = exports.actionMessage = exports.createActionValidator = void 0;
756var type_validate_1 = __webpack_require__(2);
757function createActionValidator(type, payloadSchema, payloadRequired, idRequired) {
758 if (payloadSchema === void 0) { payloadSchema = undefined; }
759 if (payloadRequired === void 0) { payloadRequired = false; }
760 if (idRequired === void 0) { idRequired = false; }
761 var idSchema = type_validate_1.matchesObject({
762 id: idRequired ? type_validate_1.matchesString() : type_validate_1.makeOptional(type_validate_1.matchesString()),
763 });
764 var schema = payloadSchema ? type_validate_1.composeSchemas(idSchema, payloadSchema) : idSchema;
765 return type_validate_1.matchesObject({
766 type: type_validate_1.matchesEnum(type, {
767 message: function (_, val) { return "The action type `" + val + "` is invalid or unsupported"; },
768 }),
769 payload: payloadRequired ? schema : type_validate_1.makeOptional(schema),
770 });
771}
772exports.createActionValidator = createActionValidator;
773function actionMessage(errors) {
774 return errors
775 .map(function (err) {
776 var path = err.path, error = err.error, message = err.message, value = err.value;
777 var valueStr = typeof value === 'object' ? JSON.stringify(value) : value;
778 return "`" + error + "` thrown for" + (path ? " path: " + path + " and" : '') + " value: `" + valueStr + "`" + (message ? " with message: " + message : '');
779 })
780 .join(' | ');
781}
782exports.actionMessage = actionMessage;
783function isValidRelativePath(path) {
784 return typeof path === 'string' && (path === '' || path.startsWith('/'));
785}
786exports.isValidRelativePath = isValidRelativePath;
787exports.relativeUrlSchema = type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) {
788 return isValidRelativePath(value)
789 ? undefined
790 : [{ error: 'invalid_relative_path', value: value, message: 'expected string to start with `/`' }];
791});
792exports.relativePathSchema = type_validate_1.matchesObject({
793 path: exports.relativeUrlSchema,
794});
795function mixedAppClientCheck(window) {
796 window.addEventListener('DOMContentLoaded', function () {
797 if (!window.hasOwnProperty('ShopifyApp')) {
798 return;
799 }
800 console.error("%cException Detected \uD83D\uDEAB\n\n%cAn instance of the EASDK client was detected while initializing Shopify App Bridge. Using Shopify App Bridge and the EASDK simultaneously is not supported.\n\nIf you're migrating an existing app that was built with the shopify_app gem, then the EASDK client might have been included in the home page view template. In this case, remove it from your app before initializing Shopify App Bridge again.", 'font-size: large;', 'font-size: normal;');
801 }, { once: true });
802}
803exports.mixedAppClientCheck = mixedAppClientCheck;
804
805
806/***/ }),
807/* 4 */
808/***/ (function(module, exports, __webpack_require__) {
809
810"use strict";
811
812var __extends = (this && this.__extends) || (function () {
813 var extendStatics = function (d, b) {
814 extendStatics = Object.setPrototypeOf ||
815 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
816 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
817 return extendStatics(d, b);
818 };
819 return function (d, b) {
820 extendStatics(d, b);
821 function __() { this.constructor = d; }
822 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
823 };
824})();
825var __assign = (this && this.__assign) || function () {
826 __assign = Object.assign || function(t) {
827 for (var s, i = 1, n = arguments.length; i < n; i++) {
828 s = arguments[i];
829 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
830 t[p] = s[p];
831 }
832 return t;
833 };
834 return __assign.apply(this, arguments);
835};
836Object.defineProperty(exports, "__esModule", { value: true });
837exports.create = exports.Button = exports.isValidButtonProps = exports.update = exports.clickButton = exports.Style = exports.Icon = exports.Action = void 0;
838var helper_1 = __webpack_require__(0);
839var types_1 = __webpack_require__(1);
840var Action;
841(function (Action) {
842 Action["CLICK"] = "CLICK";
843 Action["UPDATE"] = "UPDATE";
844})(Action = exports.Action || (exports.Action = {}));
845var Icon;
846(function (Icon) {
847 Icon["Print"] = "print";
848})(Icon = exports.Icon || (exports.Icon = {}));
849var Style;
850(function (Style) {
851 Style["Danger"] = "danger";
852})(Style = exports.Style || (exports.Style = {}));
853function clickButton(group, component, payload) {
854 var id = component.id;
855 var action = helper_1.getEventNameSpace(group, Action.CLICK, component);
856 var buttonPayload = {
857 id: id,
858 payload: payload,
859 };
860 return helper_1.actionWrapper({ type: action, group: group, payload: buttonPayload });
861}
862exports.clickButton = clickButton;
863function update(group, component, props) {
864 var id = component.id;
865 var label = props.label;
866 var action = helper_1.getEventNameSpace(group, Action.UPDATE, component);
867 var buttonPayload = __assign(__assign({}, props), { id: id,
868 label: label });
869 return helper_1.actionWrapper({ type: action, group: group, payload: buttonPayload });
870}
871exports.update = update;
872function isValidButtonProps(button) {
873 return typeof button.id === 'string' && typeof button.label === 'string';
874}
875exports.isValidButtonProps = isValidButtonProps;
876var Button = /** @class */ (function (_super) {
877 __extends(Button, _super);
878 function Button(app, options) {
879 var _this = _super.call(this, app, types_1.ComponentType.Button, types_1.Group.Button) || this;
880 _this.disabled = false;
881 _this.loading = false;
882 _this.set(options, false);
883 return _this;
884 }
885 Object.defineProperty(Button.prototype, "options", {
886 get: function () {
887 return {
888 disabled: this.disabled,
889 icon: this.icon,
890 label: this.label,
891 style: this.style,
892 loading: this.loading,
893 };
894 },
895 enumerable: false,
896 configurable: true
897 });
898 Object.defineProperty(Button.prototype, "payload", {
899 get: function () {
900 return __assign(__assign({}, this.options), { id: this.id });
901 },
902 enumerable: false,
903 configurable: true
904 });
905 Button.prototype.set = function (options, shouldUpdate) {
906 if (shouldUpdate === void 0) { shouldUpdate = true; }
907 var mergedOptions = helper_1.getMergedProps(this.options, options);
908 var label = mergedOptions.label, disabled = mergedOptions.disabled, icon = mergedOptions.icon, style = mergedOptions.style, loading = mergedOptions.loading;
909 this.label = label;
910 this.disabled = Boolean(disabled);
911 this.icon = icon;
912 this.style = style;
913 this.loading = Boolean(loading);
914 if (shouldUpdate) {
915 this.dispatch(Action.UPDATE);
916 }
917 return this;
918 };
919 Button.prototype.dispatch = function (action, payload) {
920 switch (action) {
921 case Action.CLICK:
922 this.app.dispatch(clickButton(this.group, this.component, payload));
923 break;
924 case Action.UPDATE:
925 var updateAction = update(this.group, this.component, this.payload);
926 this.app.dispatch(updateAction);
927 break;
928 }
929 return this;
930 };
931 return Button;
932}(helper_1.ActionSet));
933exports.Button = Button;
934function create(app, options) {
935 return new Button(app, options);
936}
937exports.create = create;
938
939
940/***/ }),
941/* 5 */
942/***/ (function(module, exports, __webpack_require__) {
943
944"use strict";
945
946Object.defineProperty(exports, "__esModule", { value: true });
947exports.throwError = exports.fromAction = exports.AppBridgeError = exports.invalidOriginAction = exports.isErrorEventName = exports.permissionAction = exports.networkAction = exports.persistenceAction = exports.unsupportedOperationAction = exports.unexpectedAction = exports.invalidAction = exports.invalidActionType = exports.invalidPayload = exports.Message = exports.AppActionType = exports.Action = void 0;
948var helper_1 = __webpack_require__(0);
949var types_1 = __webpack_require__(1);
950// Errors triggered in response to an action
951var Action;
952(function (Action) {
953 Action["INVALID_ACTION"] = "APP::ERROR::INVALID_ACTION";
954 Action["INVALID_ACTION_TYPE"] = "APP::ERROR::INVALID_ACTION_TYPE";
955 Action["INVALID_PAYLOAD"] = "APP::ERROR::INVALID_PAYLOAD";
956 Action["INVALID_OPTIONS"] = "APP::ERROR::INVALID_OPTIONS";
957 Action["UNEXPECTED_ACTION"] = "APP::ERROR::UNEXPECTED_ACTION";
958 Action["PERSISTENCE"] = "APP::ERROR::PERSISTENCE";
959 Action["UNSUPPORTED_OPERATION"] = "APP::ERROR::UNSUPPORTED_OPERATION";
960 Action["NETWORK"] = "APP::ERROR::NETWORK";
961 Action["PERMISSION"] = "APP::ERROR::PERMISSION";
962 Action["FAILED_AUTHENTICATION"] = "APP::ERROR::FAILED_AUTHENTICATION";
963 Action["INVALID_ORIGIN"] = "APP::ERROR::INVALID_ORIGIN";
964})(Action = exports.Action || (exports.Action = {}));
965// Errors thrown in response to app setup
966var AppActionType;
967(function (AppActionType) {
968 AppActionType["INVALID_CONFIG"] = "APP::ERROR::INVALID_CONFIG";
969 AppActionType["MISSING_CONFIG"] = "APP::APP_ERROR::MISSING_CONFIG";
970 AppActionType["MISSING_APP_BRIDGE_MIDDLEWARE"] = "APP::APP_ERROR::MISSING_APP_BRIDGE_MIDDLEWARE";
971 AppActionType["WINDOW_UNDEFINED"] = "APP::APP_ERROR::WINDOW_UNDEFINED";
972 AppActionType["MISSING_LOCAL_ORIGIN"] = "APP::APP_ERROR::MISSING_LOCAL_ORIGIN";
973 AppActionType["MISSING_HOST_PROVIDER"] = "APP::APP_ERROR::MISSING_HOST_PROVIDER";
974 AppActionType["MISSING_ROUTER_CONTEXT"] = "APP::APP_ERROR::MISSING_ROUTER_CONTEXT";
975 AppActionType["MISSING_HISTORY_BLOCK"] = "APP::APP_ERROR::MISSING_HISTORY_BLOCK";
976})(AppActionType = exports.AppActionType || (exports.AppActionType = {}));
977function errorActionWrapperWithId(type, action, message) {
978 var castPayload = action.payload;
979 return helper_1.actionWrapper({
980 type: type,
981 group: types_1.Group.Error,
982 payload: {
983 action: action,
984 message: message,
985 type: type,
986 id: castPayload && castPayload.id ? castPayload.id : undefined,
987 },
988 });
989}
990var Message;
991(function (Message) {
992 Message["MISSING_PAYLOAD"] = "Missing payload";
993 Message["INVALID_PAYLOAD_ID"] = "Id in payload is missing or invalid";
994})(Message = exports.Message || (exports.Message = {}));
995function invalidPayload(action, message) {
996 return errorActionWrapperWithId(Action.INVALID_PAYLOAD, action, message || "The action's payload is missing required properties or has invalid properties");
997}
998exports.invalidPayload = invalidPayload;
999function invalidActionType(action, message) {
1000 return helper_1.actionWrapper({
1001 group: types_1.Group.Error,
1002 payload: {
1003 action: action,
1004 message: message || 'The action type is invalid or unsupported',
1005 type: Action.INVALID_ACTION_TYPE,
1006 },
1007 type: Action.INVALID_ACTION_TYPE,
1008 });
1009}
1010exports.invalidActionType = invalidActionType;
1011function invalidAction(action, message) {
1012 return helper_1.actionWrapper({
1013 group: types_1.Group.Error,
1014 payload: {
1015 action: action,
1016 message: message || "The action's has missing/invalid values for `group`, `type` or `version`",
1017 type: Action.INVALID_ACTION,
1018 },
1019 type: Action.INVALID_ACTION,
1020 });
1021}
1022exports.invalidAction = invalidAction;
1023function unexpectedAction(action, message) {
1024 return helper_1.actionWrapper({
1025 group: types_1.Group.Error,
1026 payload: {
1027 action: action,
1028 message: message || 'Action cannot be called at this time',
1029 type: Action.UNEXPECTED_ACTION,
1030 },
1031 type: Action.UNEXPECTED_ACTION,
1032 });
1033}
1034exports.unexpectedAction = unexpectedAction;
1035function unsupportedOperationAction(action, message) {
1036 return errorActionWrapperWithId(Action.UNSUPPORTED_OPERATION, action, message || 'The action type is unsupported');
1037}
1038exports.unsupportedOperationAction = unsupportedOperationAction;
1039function persistenceAction(action, message) {
1040 return errorActionWrapperWithId(Action.PERSISTENCE, action, message || 'Action cannot be persisted on server');
1041}
1042exports.persistenceAction = persistenceAction;
1043function networkAction(action, message) {
1044 return errorActionWrapperWithId(Action.NETWORK, action, message || 'Network error');
1045}
1046exports.networkAction = networkAction;
1047function permissionAction(action, message) {
1048 return errorActionWrapperWithId(Action.PERMISSION, action, message || 'Action is not permitted');
1049}
1050exports.permissionAction = permissionAction;
1051function isErrorEventName(eventName) {
1052 var match = helper_1.findMatchInEnum(Action, eventName);
1053 return typeof match === 'string';
1054}
1055exports.isErrorEventName = isErrorEventName;
1056function invalidOriginAction(message) {
1057 return helper_1.actionWrapper({
1058 group: types_1.Group.Error,
1059 payload: {
1060 message: message,
1061 type: Action.INVALID_ORIGIN,
1062 },
1063 type: Action.INVALID_ORIGIN,
1064 });
1065}
1066exports.invalidOriginAction = invalidOriginAction;
1067var AppBridgeError = /** @class */ (function () {
1068 function AppBridgeError(message) {
1069 this.name = 'AppBridgeError';
1070 this.message = message;
1071 if (typeof Error.captureStackTrace === 'function') {
1072 Error.captureStackTrace(this, this.constructor);
1073 }
1074 else {
1075 this.stack = new Error(this.message).stack;
1076 }
1077 }
1078 return AppBridgeError;
1079}());
1080exports.AppBridgeError = AppBridgeError;
1081AppBridgeError.prototype = Object.create(Error.prototype);
1082function fromAction(message, type, action) {
1083 var errorMessage = message ? type + ": " + message : type;
1084 var error = new AppBridgeError(errorMessage);
1085 error.action = action;
1086 error.type = type;
1087 return error;
1088}
1089exports.fromAction = fromAction;
1090function throwError() {
1091 var type = arguments[0];
1092 var message;
1093 var action;
1094 if (typeof arguments[1] === 'string') {
1095 message = arguments[1];
1096 }
1097 else {
1098 action = arguments[1];
1099 message = arguments[2] || '';
1100 }
1101 throw fromAction(message, type, action);
1102}
1103exports.throwError = throwError;
1104
1105
1106/***/ }),
1107/* 6 */
1108/***/ (function(module, exports, __webpack_require__) {
1109
1110"use strict";
1111
1112Object.defineProperty(exports, "__esModule", { value: true });
1113exports.LifecycleHook = exports.MessageType = exports.PermissionType = void 0;
1114/**
1115 * @internal
1116 */
1117var PermissionType;
1118(function (PermissionType) {
1119 PermissionType["Dispatch"] = "Dispatch";
1120 PermissionType["Subscribe"] = "Subscribe";
1121})(PermissionType = exports.PermissionType || (exports.PermissionType = {}));
1122/**
1123 * @internal
1124 */
1125var MessageType;
1126(function (MessageType) {
1127 MessageType["GetState"] = "getState";
1128 MessageType["Dispatch"] = "dispatch";
1129 MessageType["Subscribe"] = "subscribe";
1130 MessageType["Unsubscribe"] = "unsubscribe";
1131})(MessageType = exports.MessageType || (exports.MessageType = {}));
1132/**
1133 *
1134 * There are two types of hooks: `LifecycleHook.DispatchAction` and `LifecycleHook.UpdateAction`.
1135 *
1136 * @remarks
1137 * `DispatchAction` hooks are run when an action is dispatched with the `.dispatch()` function:
1138 *
1139 * ```js
1140 * const toastNotice = Toast.create(app, {message: 'Product saved'});
1141 * toastNotice.dispatch(Toast.Action.SHOW);
1142 * ```
1143 *
1144 * `UpdateAction` hooks are run when an action is updated, using the `.set()` function:
1145 *
1146 * ```js
1147 * toastNotice.set({message: 'Product could not be saved', isError: true});
1148 * ```
1149 *
1150 * @public
1151 */
1152var LifecycleHook;
1153(function (LifecycleHook) {
1154 LifecycleHook["UpdateAction"] = "UpdateAction";
1155 LifecycleHook["DispatchAction"] = "DispatchAction";
1156})(LifecycleHook = exports.LifecycleHook || (exports.LifecycleHook = {}));
1157
1158
1159/***/ }),
1160/* 7 */
1161/***/ (function(module, exports, __webpack_require__) {
1162
1163"use strict";
1164
1165var __extends = (this && this.__extends) || (function () {
1166 var extendStatics = function (d, b) {
1167 extendStatics = Object.setPrototypeOf ||
1168 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1169 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1170 return extendStatics(d, b);
1171 };
1172 return function (d, b) {
1173 extendStatics(d, b);
1174 function __() { this.constructor = d; }
1175 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1176 };
1177})();
1178var __assign = (this && this.__assign) || function () {
1179 __assign = Object.assign || function(t) {
1180 for (var s, i = 1, n = arguments.length; i < n; i++) {
1181 s = arguments[i];
1182 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1183 t[p] = s[p];
1184 }
1185 return t;
1186 };
1187 return __assign.apply(this, arguments);
1188};
1189Object.defineProperty(exports, "__esModule", { value: true });
1190exports.create = exports.ButtonGroup = exports.isGroupedButtonPayload = exports.isGroupedButton = exports.update = exports.Action = void 0;
1191var buttonHelper_1 = __webpack_require__(8);
1192var helper_1 = __webpack_require__(0);
1193var types_1 = __webpack_require__(1);
1194var Action;
1195(function (Action) {
1196 Action["UPDATE"] = "UPDATE";
1197})(Action = exports.Action || (exports.Action = {}));
1198function update(group, component, props) {
1199 return buttonActionWrapper(group, component, Action.UPDATE, props);
1200}
1201exports.update = update;
1202function isGroupedButton(options) {
1203 var castOptions = options;
1204 return castOptions.buttons && castOptions.buttons.length > 0 && castOptions.label !== undefined;
1205}
1206exports.isGroupedButton = isGroupedButton;
1207function isGroupedButtonPayload(payload) {
1208 var castOptions = payload;
1209 return (Array.isArray(castOptions.buttons) &&
1210 typeof castOptions.id === 'string' &&
1211 typeof castOptions.label === 'string');
1212}
1213exports.isGroupedButtonPayload = isGroupedButtonPayload;
1214var ButtonGroup = /** @class */ (function (_super) {
1215 __extends(ButtonGroup, _super);
1216 function ButtonGroup(app, options) {
1217 var _this = _super.call(this, app, types_1.ComponentType.ButtonGroup, types_1.Group.ButtonGroup) || this;
1218 _this.disabled = false;
1219 _this.buttonsOptions = [];
1220 _this.buttons = [];
1221 _this.set(options, false);
1222 return _this;
1223 }
1224 Object.defineProperty(ButtonGroup.prototype, "options", {
1225 get: function () {
1226 return {
1227 buttons: this.buttonsOptions,
1228 disabled: this.disabled,
1229 label: this.label,
1230 };
1231 },
1232 enumerable: false,
1233 configurable: true
1234 });
1235 Object.defineProperty(ButtonGroup.prototype, "payload", {
1236 get: function () {
1237 return __assign(__assign({}, this.options), { buttons: this.buttons, id: this.id });
1238 },
1239 enumerable: false,
1240 configurable: true
1241 });
1242 ButtonGroup.prototype.set = function (options, shouldUpdate) {
1243 if (shouldUpdate === void 0) { shouldUpdate = true; }
1244 var mergedOptions = helper_1.getMergedProps(this.options, options);
1245 var label = mergedOptions.label, disabled = mergedOptions.disabled, buttons = mergedOptions.buttons;
1246 this.label = label;
1247 this.disabled = Boolean(disabled);
1248 this.buttons = this.getButtons(buttons);
1249 if (shouldUpdate) {
1250 this.dispatch(Action.UPDATE);
1251 }
1252 return this;
1253 };
1254 ButtonGroup.prototype.dispatch = function (action) {
1255 switch (action) {
1256 case Action.UPDATE:
1257 var updateAction = update(this.group, this.component, this.payload);
1258 this.app.dispatch(updateAction);
1259 break;
1260 }
1261 return this;
1262 };
1263 ButtonGroup.prototype.updateButtons = function (newPayload) {
1264 if (!this.buttons || this.buttons.length === 0) {
1265 return;
1266 }
1267 var updated;
1268 for (var _i = 0, _a = this.buttons; _i < _a.length; _i++) {
1269 var action = _a[_i];
1270 updated = helper_1.updateActionFromPayload(action, newPayload);
1271 if (updated) {
1272 break;
1273 }
1274 }
1275 if (updated) {
1276 this.dispatch(Action.UPDATE);
1277 }
1278 };
1279 ButtonGroup.prototype.getSingleButton = function (button) {
1280 return buttonHelper_1.getSingleButton(this, button, this.subgroups, this.updateButtons);
1281 };
1282 ButtonGroup.prototype.getButtons = function (buttonOptions) {
1283 var _this = this;
1284 var buttons = [];
1285 if (!buttonOptions) {
1286 return [];
1287 }
1288 buttonOptions.forEach(function (button) {
1289 var singleButton = buttonHelper_1.getSingleButton(_this, button, _this.subgroups, _this.updateButtons);
1290 buttons.push(singleButton);
1291 });
1292 this.buttonsOptions = buttonOptions;
1293 return buttons;
1294 };
1295 return ButtonGroup;
1296}(helper_1.ActionSetWithChildren));
1297exports.ButtonGroup = ButtonGroup;
1298function create(app, options) {
1299 return new ButtonGroup(app, options);
1300}
1301exports.create = create;
1302function buttonActionWrapper(group, component, eventName, props, payload) {
1303 var id = component.id;
1304 var label = props.label;
1305 var action = helper_1.getEventNameSpace(group, eventName, component);
1306 var buttonPayload = __assign(__assign({}, props), { id: id,
1307 label: label,
1308 payload: payload });
1309 return helper_1.actionWrapper({ type: action, group: group, payload: buttonPayload });
1310}
1311
1312
1313/***/ }),
1314/* 8 */
1315/***/ (function(module, exports, __webpack_require__) {
1316
1317"use strict";
1318
1319Object.defineProperty(exports, "__esModule", { value: true });
1320exports.getSingleButton = void 0;
1321var Button_1 = __webpack_require__(4);
1322function getSingleButton(action, button, subgroups, updateCb) {
1323 action.addChild(button, action.group, subgroups);
1324 action.subscribeToChild(button, Button_1.Action.UPDATE, updateCb);
1325 return button.payload;
1326}
1327exports.getSingleButton = getSingleButton;
1328
1329
1330/***/ }),
1331/* 9 */
1332/***/ (function(module, exports, __webpack_require__) {
1333
1334"use strict";
1335
1336var __extends = (this && this.__extends) || (function () {
1337 var extendStatics = function (d, b) {
1338 extendStatics = Object.setPrototypeOf ||
1339 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1340 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1341 return extendStatics(d, b);
1342 };
1343 return function (d, b) {
1344 extendStatics(d, b);
1345 function __() { this.constructor = d; }
1346 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1347 };
1348})();
1349var __assign = (this && this.__assign) || function () {
1350 __assign = Object.assign || function(t) {
1351 for (var s, i = 1, n = arguments.length; i < n; i++) {
1352 s = arguments[i];
1353 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1354 t[p] = s[p];
1355 }
1356 return t;
1357 };
1358 return __assign.apply(this, arguments);
1359};
1360Object.defineProperty(exports, "__esModule", { value: true });
1361exports.create = exports.Toast = exports.clear = exports.show = exports.Action = void 0;
1362var helper_1 = __webpack_require__(0);
1363var types_1 = __webpack_require__(1);
1364var Action;
1365(function (Action) {
1366 Action["SHOW"] = "APP::TOAST::SHOW";
1367 Action["CLEAR"] = "APP::TOAST::CLEAR";
1368})(Action = exports.Action || (exports.Action = {}));
1369function show(toastMessage) {
1370 return helper_1.actionWrapper({
1371 group: types_1.Group.Toast,
1372 payload: toastMessage,
1373 type: Action.SHOW,
1374 });
1375}
1376exports.show = show;
1377function clear(payload) {
1378 return helper_1.actionWrapper({
1379 payload: payload,
1380 group: types_1.Group.Toast,
1381 type: Action.CLEAR,
1382 });
1383}
1384exports.clear = clear;
1385var Toast = /** @class */ (function (_super) {
1386 __extends(Toast, _super);
1387 function Toast(app, options) {
1388 var _this = _super.call(this, app, types_1.Group.Toast, types_1.Group.Toast) || this;
1389 _this.message = '';
1390 _this.duration = 5000;
1391 _this.set(options);
1392 return _this;
1393 }
1394 Object.defineProperty(Toast.prototype, "options", {
1395 get: function () {
1396 return {
1397 duration: this.duration,
1398 isError: this.isError,
1399 message: this.message,
1400 };
1401 },
1402 enumerable: false,
1403 configurable: true
1404 });
1405 Object.defineProperty(Toast.prototype, "payload", {
1406 get: function () {
1407 return __assign({ id: this.id }, this.options);
1408 },
1409 enumerable: false,
1410 configurable: true
1411 });
1412 Toast.prototype.set = function (options) {
1413 var mergedOptions = helper_1.getMergedProps(this.options, options);
1414 var message = mergedOptions.message, duration = mergedOptions.duration, isError = mergedOptions.isError;
1415 this.message = message;
1416 this.duration = duration;
1417 this.isError = isError;
1418 return this;
1419 };
1420 Toast.prototype.dispatch = function (action) {
1421 switch (action) {
1422 case Action.SHOW:
1423 var openAction = show(this.payload);
1424 this.app.dispatch(openAction);
1425 break;
1426 case Action.CLEAR:
1427 this.app.dispatch(clear({ id: this.id }));
1428 break;
1429 }
1430 return this;
1431 };
1432 return Toast;
1433}(helper_1.ActionSet));
1434exports.Toast = Toast;
1435function create(app, options) {
1436 return new Toast(app, options);
1437}
1438exports.create = create;
1439
1440
1441/***/ }),
1442/* 10 */
1443/***/ (function(module, exports, __webpack_require__) {
1444
1445"use strict";
1446
1447var __extends = (this && this.__extends) || (function () {
1448 var extendStatics = function (d, b) {
1449 extendStatics = Object.setPrototypeOf ||
1450 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1451 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1452 return extendStatics(d, b);
1453 };
1454 return function (d, b) {
1455 extendStatics(d, b);
1456 function __() { this.constructor = d; }
1457 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1458 };
1459})();
1460var __assign = (this && this.__assign) || function () {
1461 __assign = Object.assign || function(t) {
1462 for (var s, i = 1, n = arguments.length; i < n; i++) {
1463 s = arguments[i];
1464 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1465 t[p] = s[p];
1466 }
1467 return t;
1468 };
1469 return __assign.apply(this, arguments);
1470};
1471Object.defineProperty(exports, "__esModule", { value: true });
1472exports.create = exports.AppLink = exports.update = exports.Action = void 0;
1473var helper_1 = __webpack_require__(0);
1474var types_1 = __webpack_require__(1);
1475var Redirect_1 = __webpack_require__(13);
1476var Action;
1477(function (Action) {
1478 Action["UPDATE"] = "UPDATE";
1479})(Action = exports.Action || (exports.Action = {}));
1480function update(group, component, updatePayload) {
1481 var id = component.id;
1482 var label = updatePayload.label, destination = updatePayload.destination;
1483 var linkPayload = __assign(__assign({}, updatePayload), { id: id,
1484 label: label,
1485 destination: destination });
1486 return helper_1.actionWrapper({
1487 group: group,
1488 type: helper_1.getEventNameSpace(group, Action.UPDATE, component),
1489 payload: linkPayload,
1490 });
1491}
1492exports.update = update;
1493var AppLink = /** @class */ (function (_super) {
1494 __extends(AppLink, _super);
1495 function AppLink(app, options) {
1496 var _this = _super.call(this, app, types_1.Group.Link, types_1.Group.Link) || this;
1497 _this.label = '';
1498 _this.destination = '';
1499 _this.set(options, false);
1500 return _this;
1501 }
1502 Object.defineProperty(AppLink.prototype, "options", {
1503 get: function () {
1504 var _a = this, label = _a.label, destination = _a.destination;
1505 return {
1506 label: label,
1507 destination: destination,
1508 redirectType: Redirect_1.Action.APP,
1509 };
1510 },
1511 enumerable: false,
1512 configurable: true
1513 });
1514 Object.defineProperty(AppLink.prototype, "payload", {
1515 get: function () {
1516 var _a = this.options, label = _a.label, destination = _a.destination, redirectType = _a.redirectType;
1517 var path = destination;
1518 return {
1519 id: this.id,
1520 label: label,
1521 destination: { path: path },
1522 redirectType: redirectType,
1523 };
1524 },
1525 enumerable: false,
1526 configurable: true
1527 });
1528 AppLink.prototype.set = function (options, shouldUpdate) {
1529 if (shouldUpdate === void 0) { shouldUpdate = true; }
1530 var _a = helper_1.getMergedProps(this.options, options), label = _a.label, destination = _a.destination;
1531 this.label = label;
1532 this.destination = destination;
1533 if (shouldUpdate) {
1534 this.dispatch(Action.UPDATE);
1535 }
1536 return this;
1537 };
1538 AppLink.prototype.dispatch = function (action) {
1539 switch (action) {
1540 case Action.UPDATE:
1541 var updateAction = update(this.group, this.component, this.payload);
1542 this.app.dispatch(updateAction);
1543 break;
1544 }
1545 return this;
1546 };
1547 return AppLink;
1548}(helper_1.ActionSet));
1549exports.AppLink = AppLink;
1550function create(app, options) {
1551 return new AppLink(app, options);
1552}
1553exports.create = create;
1554
1555
1556/***/ }),
1557/* 11 */
1558/***/ (function(module, exports, __webpack_require__) {
1559
1560"use strict";
1561
1562Object.defineProperty(exports, "__esModule", { value: true });
1563exports.Action = exports.validateAction = exports.validateProps = exports.buttonSchemaWithId = exports.buttonSchema = void 0;
1564var Button_1 = __webpack_require__(4);
1565Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Button_1.Action; } });
1566var type_validate_1 = __webpack_require__(2);
1567var utils_1 = __webpack_require__(3);
1568exports.buttonSchema = type_validate_1.matchesObject({
1569 disabled: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
1570 label: type_validate_1.matchesString(),
1571 style: type_validate_1.makeOptional(type_validate_1.matchesEnum(Button_1.Style)),
1572 icon: type_validate_1.makeOptional(type_validate_1.matchesEnum(Button_1.Icon)),
1573 loading: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
1574});
1575exports.buttonSchemaWithId = type_validate_1.composeSchemas(type_validate_1.matchesObject({
1576 id: type_validate_1.matchesString(),
1577}), exports.buttonSchema);
1578function validateProps(props) {
1579 return type_validate_1.validate(props, exports.buttonSchema);
1580}
1581exports.validateProps = validateProps;
1582function validateAction(action) {
1583 var validator = utils_1.createActionValidator(Button_1.Action, action.type === Button_1.Action.UPDATE ? exports.buttonSchema : undefined, true, true);
1584 return type_validate_1.validate(action, validator);
1585}
1586exports.validateAction = validateAction;
1587
1588
1589/***/ }),
1590/* 12 */
1591/***/ (function(module, exports, __webpack_require__) {
1592
1593"use strict";
1594
1595Object.defineProperty(exports, "__esModule", { value: true });
1596exports.removeFromCollection = exports.addAndRemoveFromCollection = void 0;
1597/**
1598 * Add an item to a collection, return a function that can then be used to
1599 * remove the item from the collection. Optionally accepting a callback that is
1600 * invoked when the item is removed from the collection.
1601 *
1602 * @internal
1603 */
1604function addAndRemoveFromCollection(collection, item, then) {
1605 collection.push(item);
1606 return function () {
1607 return removeFromCollection(collection, item, then);
1608 };
1609}
1610exports.addAndRemoveFromCollection = addAndRemoveFromCollection;
1611/**
1612 * Remove the item from the collection. Optionally accepting a callback that is
1613 * invoked when the item is removed from the collection.
1614 *
1615 * @internal
1616 */
1617function removeFromCollection(collection, item, then) {
1618 var idx = collection.findIndex(function (i) { return i === item; });
1619 if (idx >= 0) {
1620 collection.splice(idx, 1);
1621 if (then) {
1622 then(item);
1623 }
1624 return true;
1625 }
1626 return false;
1627}
1628exports.removeFromCollection = removeFromCollection;
1629
1630
1631/***/ }),
1632/* 13 */
1633/***/ (function(module, exports, __webpack_require__) {
1634
1635"use strict";
1636
1637var __extends = (this && this.__extends) || (function () {
1638 var extendStatics = function (d, b) {
1639 extendStatics = Object.setPrototypeOf ||
1640 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1641 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1642 return extendStatics(d, b);
1643 };
1644 return function (d, b) {
1645 extendStatics(d, b);
1646 function __() { this.constructor = d; }
1647 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1648 };
1649})();
1650var __assign = (this && this.__assign) || function () {
1651 __assign = Object.assign || function(t) {
1652 for (var s, i = 1, n = arguments.length; i < n; i++) {
1653 s = arguments[i];
1654 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1655 t[p] = s[p];
1656 }
1657 return t;
1658 };
1659 return __assign.apply(this, arguments);
1660};
1661Object.defineProperty(exports, "__esModule", { value: true });
1662exports.create = exports.Redirect = exports.isRemotePayload = exports.isAdminSectionPayload = exports.isAdminPathPayload = exports.isAppPayload = exports.toDestination = exports.toApp = exports.toRemote = exports.toAdminSection = exports.toAdminPath = exports.isProductVariantCreateResourcePayload = exports.isProductVariantResourcePayload = exports.isCreateResourcePayload = exports.isResourcePayload = exports.ResourceType = exports.Action = void 0;
1663var helper_1 = __webpack_require__(0);
1664var types_1 = __webpack_require__(1);
1665var Action;
1666(function (Action) {
1667 Action["ADMIN_SECTION"] = "APP::NAVIGATION::REDIRECT::ADMIN::SECTION";
1668 Action["ADMIN_PATH"] = "APP::NAVIGATION::REDIRECT::ADMIN::PATH";
1669 Action["REMOTE"] = "APP::NAVIGATION::REDIRECT::REMOTE";
1670 Action["APP"] = "APP::NAVIGATION::REDIRECT::APP";
1671})(Action = exports.Action || (exports.Action = {}));
1672var ResourceType;
1673(function (ResourceType) {
1674 ResourceType["Product"] = "products";
1675 ResourceType["Collection"] = "collections";
1676 ResourceType["Order"] = "orders";
1677 ResourceType["Customer"] = "customers";
1678 ResourceType["Discount"] = "discounts";
1679})(ResourceType = exports.ResourceType || (exports.ResourceType = {}));
1680function isResourcePayload(resource) {
1681 // tslint:disable-next-line:no-boolean-literal-compare
1682 return typeof resource.id === 'string';
1683}
1684exports.isResourcePayload = isResourcePayload;
1685function isCreateResourcePayload(resource) {
1686 // tslint:disable-next-line:no-boolean-literal-compare
1687 return resource.create === true;
1688}
1689exports.isCreateResourcePayload = isCreateResourcePayload;
1690function isProductVariantResourcePayload(resource) {
1691 var castResource = resource;
1692 // tslint:disable-next-line:no-boolean-literal-compare
1693 return castResource.id !== undefined && castResource.variant !== undefined;
1694}
1695exports.isProductVariantResourcePayload = isProductVariantResourcePayload;
1696function isProductVariantCreateResourcePayload(resource) {
1697 if (!isProductVariantResourcePayload(resource)) {
1698 return false;
1699 }
1700 return isCreateResourcePayload(resource.variant);
1701}
1702exports.isProductVariantCreateResourcePayload = isProductVariantCreateResourcePayload;
1703function toAdminPath(payload) {
1704 return helper_1.actionWrapper({
1705 payload: payload,
1706 group: types_1.Group.Navigation,
1707 type: Action.ADMIN_PATH,
1708 });
1709}
1710exports.toAdminPath = toAdminPath;
1711function toAdminSection(payload) {
1712 return helper_1.actionWrapper({
1713 payload: payload,
1714 group: types_1.Group.Navigation,
1715 type: Action.ADMIN_SECTION,
1716 });
1717}
1718exports.toAdminSection = toAdminSection;
1719function toRemote(payload) {
1720 return helper_1.actionWrapper({
1721 payload: payload,
1722 group: types_1.Group.Navigation,
1723 type: Action.REMOTE,
1724 });
1725}
1726exports.toRemote = toRemote;
1727function toApp(payload) {
1728 return helper_1.actionWrapper({
1729 payload: payload,
1730 group: types_1.Group.Navigation,
1731 type: Action.APP,
1732 });
1733}
1734exports.toApp = toApp;
1735function toDestination(action, payload, id) {
1736 switch (action) {
1737 case Action.APP:
1738 var appPayload = isAppPayload(payload) ? payload : { path: payload };
1739 return toApp(__assign({ id: id }, appPayload));
1740 case Action.ADMIN_PATH:
1741 var adminPathPayload = isAdminPathPayload(payload) ? payload : { path: payload };
1742 return toAdminPath(__assign({ id: id }, adminPathPayload));
1743 case Action.ADMIN_SECTION:
1744 var adminSectionPayload = isAdminSectionPayload(payload)
1745 ? payload
1746 : { section: payload };
1747 return toAdminSection(__assign({ id: id }, adminSectionPayload));
1748 case Action.REMOTE:
1749 var remotePayload = isRemotePayload(payload) ? payload : { url: payload };
1750 return toRemote(__assign({ id: id }, remotePayload));
1751 }
1752}
1753exports.toDestination = toDestination;
1754function isAppPayload(payload) {
1755 return typeof payload === 'object' && payload.hasOwnProperty('path');
1756}
1757exports.isAppPayload = isAppPayload;
1758function isAdminPathPayload(payload) {
1759 return typeof payload === 'object' && payload.hasOwnProperty('path');
1760}
1761exports.isAdminPathPayload = isAdminPathPayload;
1762function isAdminSectionPayload(payload) {
1763 return (typeof payload === 'object' &&
1764 typeof payload.section === 'object' &&
1765 payload.section.hasOwnProperty('name'));
1766}
1767exports.isAdminSectionPayload = isAdminSectionPayload;
1768function isRemotePayload(payload) {
1769 return typeof payload === 'object' && payload.hasOwnProperty('url');
1770}
1771exports.isRemotePayload = isRemotePayload;
1772var Redirect = /** @class */ (function (_super) {
1773 __extends(Redirect, _super);
1774 function Redirect(app) {
1775 return _super.call(this, app, 'Redirect', types_1.Group.Navigation) || this;
1776 }
1777 Object.defineProperty(Redirect.prototype, "payload", {
1778 get: function () {
1779 return { id: this.id };
1780 },
1781 enumerable: false,
1782 configurable: true
1783 });
1784 Redirect.prototype.dispatch = function (action, payload) {
1785 var redirectAction = toDestination(action, payload, this.payload.id);
1786 this.app.dispatch(redirectAction);
1787 return this;
1788 };
1789 return Redirect;
1790}(helper_1.ActionSet));
1791exports.Redirect = Redirect;
1792function create(app) {
1793 return new Redirect(app);
1794}
1795exports.create = create;
1796
1797
1798/***/ }),
1799/* 14 */
1800/***/ (function(module, exports, __webpack_require__) {
1801
1802"use strict";
1803
1804Object.defineProperty(exports, "__esModule", { value: true });
1805exports.app = exports.Action = void 0;
1806var helper_1 = __webpack_require__(0);
1807var types_1 = __webpack_require__(1);
1808var Action;
1809(function (Action) {
1810 Action["APP"] = "APP::PRINT::APP";
1811})(Action = exports.Action || (exports.Action = {}));
1812function app() {
1813 return helper_1.actionWrapper({
1814 group: types_1.Group.Print,
1815 type: Action.APP,
1816 });
1817}
1818exports.app = app;
1819
1820
1821/***/ }),
1822/* 15 */
1823/***/ (function(module, exports, __webpack_require__) {
1824
1825"use strict";
1826
1827var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1828 if (k2 === undefined) k2 = k;
1829 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1830}) : (function(o, m, k, k2) {
1831 if (k2 === undefined) k2 = k;
1832 o[k2] = m[k];
1833}));
1834var __exportStar = (this && this.__exportStar) || function(m, exports) {
1835 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
1836};
1837Object.defineProperty(exports, "__esModule", { value: true });
1838var Client_1 = __webpack_require__(35);
1839__exportStar(__webpack_require__(6), exports);
1840__exportStar(__webpack_require__(35), exports);
1841exports.default = Client_1.createClientApp;
1842
1843
1844/***/ }),
1845/* 16 */
1846/***/ (function(module, exports, __webpack_require__) {
1847
1848"use strict";
1849
1850Object.defineProperty(exports, "__esModule", { value: true });
1851exports.getWindow = exports.getLocation = exports.redirect = exports.shouldRedirect = void 0;
1852function shouldRedirect(frame) {
1853 return frame === window;
1854}
1855exports.shouldRedirect = shouldRedirect;
1856function redirect(url) {
1857 var location = getLocation();
1858 if (!location) {
1859 return;
1860 }
1861 location.assign(url);
1862}
1863exports.redirect = redirect;
1864function getLocation() {
1865 return hasWindow() ? window.location : undefined;
1866}
1867exports.getLocation = getLocation;
1868function getWindow() {
1869 return hasWindow() ? window : undefined;
1870}
1871exports.getWindow = getWindow;
1872function hasWindow() {
1873 return typeof window !== 'undefined';
1874}
1875
1876
1877/***/ }),
1878/* 17 */
1879/***/ (function(module, exports, __webpack_require__) {
1880
1881"use strict";
1882
1883Object.defineProperty(exports, "__esModule", { value: true });
1884exports.SEPARATOR = exports.PREFIX = void 0;
1885exports.PREFIX = 'APP';
1886exports.SEPARATOR = '::';
1887
1888
1889/***/ }),
1890/* 18 */
1891/***/ (function(module, exports, __webpack_require__) {
1892
1893"use strict";
1894
1895var __extends = (this && this.__extends) || (function () {
1896 var extendStatics = function (d, b) {
1897 extendStatics = Object.setPrototypeOf ||
1898 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1899 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1900 return extendStatics(d, b);
1901 };
1902 return function (d, b) {
1903 extendStatics(d, b);
1904 function __() { this.constructor = d; }
1905 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1906 };
1907})();
1908var __assign = (this && this.__assign) || function () {
1909 __assign = Object.assign || function(t) {
1910 for (var s, i = 1, n = arguments.length; i < n; i++) {
1911 s = arguments[i];
1912 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1913 t[p] = s[p];
1914 }
1915 return t;
1916 };
1917 return __assign.apply(this, arguments);
1918};
1919Object.defineProperty(exports, "__esModule", { value: true });
1920exports.create = exports.Cart = exports.setLineItemProperties = exports.removeLineItemDiscount = exports.setLineItemDiscount = exports.removeLineItem = exports.updateLineItem = exports.addLineItem = exports.removeProperties = exports.setProperties = exports.setDiscount = exports.updateCustomerAddress = exports.addCustomerAddress = exports.setCustomer = exports.update = exports.fetch = exports.Action = void 0;
1921var helper_1 = __webpack_require__(0);
1922var types_1 = __webpack_require__(1);
1923var Action;
1924(function (Action) {
1925 Action["FETCH"] = "APP::CART::FETCH";
1926 Action["UPDATE"] = "APP::CART::UPDATE";
1927 Action["SET_CUSTOMER"] = "APP::CART::SET_CUSTOMER";
1928 Action["REMOVE_CUSTOMER"] = "APP::CART::REMOVE_CUSTOMER";
1929 Action["ADD_CUSTOMER_ADDRESS"] = "APP::CART::ADD_CUSTOMER_ADDRESS";
1930 Action["UPDATE_CUSTOMER_ADDRESS"] = "APP::CART::UPDATE_CUSTOMER_ADDRESS";
1931 Action["SET_DISCOUNT"] = "APP::CART::SET_DISCOUNT";
1932 Action["REMOVE_DISCOUNT"] = "APP::CART::REMOVE_DISCOUNT";
1933 Action["SET_PROPERTIES"] = "APP::CART::SET_PROPERTIES";
1934 Action["REMOVE_PROPERTIES"] = "APP::CART::REMOVE_PROPERTIES";
1935 Action["CLEAR"] = "APP::CART::CLEAR";
1936 Action["ADD_LINE_ITEM"] = "APP::CART::ADD_LINE_ITEM";
1937 Action["UPDATE_LINE_ITEM"] = "APP::CART::UPDATE_LINE_ITEM";
1938 Action["REMOVE_LINE_ITEM"] = "APP::CART::REMOVE_LINE_ITEM";
1939 Action["SET_LINE_ITEM_DISCOUNT"] = "APP::CART::SET_LINE_ITEM_DISCOUNT";
1940 Action["REMOVE_LINE_ITEM_DISCOUNT"] = "APP::CART::REMOVE_LINE_ITEM_DISCOUNT";
1941 Action["SET_LINE_ITEM_PROPERTIES"] = "APP::CART::SET_LINE_ITEM_PROPERTIES";
1942 Action["REMOVE_LINE_ITEM_PROPERTIES"] = "APP::CART::REMOVE_LINE_ITEM_PROPERTIES";
1943})(Action = exports.Action || (exports.Action = {}));
1944/**
1945 * Cart action
1946 * @internal
1947 */
1948function createCartAction(type, payload) {
1949 if (payload === void 0) { payload = {}; }
1950 return helper_1.actionWrapper({
1951 group: types_1.Group.Cart,
1952 type: type,
1953 payload: payload,
1954 });
1955}
1956function fetch() {
1957 return createCartAction(Action.FETCH);
1958}
1959exports.fetch = fetch;
1960function update(payload) {
1961 return createCartAction(Action.UPDATE, payload);
1962}
1963exports.update = update;
1964function setCustomer(payload) {
1965 return createCartAction(Action.SET_CUSTOMER, payload);
1966}
1967exports.setCustomer = setCustomer;
1968function addCustomerAddress(payload) {
1969 return createCartAction(Action.ADD_CUSTOMER_ADDRESS, payload);
1970}
1971exports.addCustomerAddress = addCustomerAddress;
1972function updateCustomerAddress(payload) {
1973 return createCartAction(Action.UPDATE_CUSTOMER_ADDRESS, payload);
1974}
1975exports.updateCustomerAddress = updateCustomerAddress;
1976function setDiscount(payload) {
1977 return createCartAction(Action.SET_DISCOUNT, payload);
1978}
1979exports.setDiscount = setDiscount;
1980function setProperties(payload) {
1981 return createCartAction(Action.SET_PROPERTIES, payload);
1982}
1983exports.setProperties = setProperties;
1984function removeProperties(payload) {
1985 return createCartAction(Action.REMOVE_PROPERTIES, payload);
1986}
1987exports.removeProperties = removeProperties;
1988function addLineItem(payload) {
1989 return createCartAction(Action.ADD_LINE_ITEM, payload);
1990}
1991exports.addLineItem = addLineItem;
1992function updateLineItem(payload) {
1993 return createCartAction(Action.UPDATE_LINE_ITEM, payload);
1994}
1995exports.updateLineItem = updateLineItem;
1996function removeLineItem(payload) {
1997 return createCartAction(Action.REMOVE_LINE_ITEM, payload);
1998}
1999exports.removeLineItem = removeLineItem;
2000function setLineItemDiscount(payload) {
2001 return createCartAction(Action.SET_LINE_ITEM_DISCOUNT, payload);
2002}
2003exports.setLineItemDiscount = setLineItemDiscount;
2004function removeLineItemDiscount(payload) {
2005 return createCartAction(Action.REMOVE_LINE_ITEM_DISCOUNT, payload);
2006}
2007exports.removeLineItemDiscount = removeLineItemDiscount;
2008function setLineItemProperties(payload) {
2009 return createCartAction(Action.SET_LINE_ITEM_PROPERTIES, payload);
2010}
2011exports.setLineItemProperties = setLineItemProperties;
2012/**
2013 * Cart
2014 */
2015var Cart = /** @class */ (function (_super) {
2016 __extends(Cart, _super);
2017 function Cart(app, options) {
2018 return _super.call(this, app, types_1.Group.Cart, types_1.Group.Cart, options ? options.id : undefined) || this;
2019 }
2020 Cart.prototype.dispatch = function (action, payload) {
2021 switch (action) {
2022 case Action.FETCH:
2023 this.dispatchCartAction(Action.FETCH);
2024 break;
2025 case Action.UPDATE:
2026 this.dispatchCartAction(Action.UPDATE, payload);
2027 break;
2028 case Action.SET_CUSTOMER:
2029 this.dispatchCartAction(Action.SET_CUSTOMER, payload);
2030 break;
2031 case Action.REMOVE_CUSTOMER:
2032 this.dispatchCartAction(Action.REMOVE_CUSTOMER, payload);
2033 break;
2034 case Action.ADD_CUSTOMER_ADDRESS:
2035 this.dispatchCartAction(Action.ADD_CUSTOMER_ADDRESS, payload);
2036 break;
2037 case Action.UPDATE_CUSTOMER_ADDRESS:
2038 this.dispatchCartAction(Action.UPDATE_CUSTOMER_ADDRESS, payload);
2039 break;
2040 case Action.SET_DISCOUNT:
2041 this.dispatchCartAction(Action.SET_DISCOUNT, payload);
2042 break;
2043 case Action.REMOVE_DISCOUNT:
2044 this.dispatchCartAction(Action.REMOVE_DISCOUNT, payload);
2045 break;
2046 case Action.SET_PROPERTIES:
2047 this.dispatchCartAction(Action.SET_PROPERTIES, payload);
2048 break;
2049 case Action.REMOVE_PROPERTIES:
2050 this.dispatchCartAction(Action.REMOVE_PROPERTIES, payload);
2051 break;
2052 case Action.CLEAR:
2053 this.dispatchCartAction(Action.CLEAR, payload);
2054 break;
2055 case Action.ADD_LINE_ITEM:
2056 this.dispatchCartAction(Action.ADD_LINE_ITEM, payload);
2057 break;
2058 case Action.UPDATE_LINE_ITEM:
2059 this.dispatchCartAction(Action.UPDATE_LINE_ITEM, payload);
2060 break;
2061 case Action.REMOVE_LINE_ITEM:
2062 this.dispatchCartAction(Action.REMOVE_LINE_ITEM, payload);
2063 break;
2064 case Action.SET_LINE_ITEM_DISCOUNT:
2065 this.dispatchCartAction(Action.SET_LINE_ITEM_DISCOUNT, payload);
2066 break;
2067 case Action.REMOVE_LINE_ITEM_DISCOUNT:
2068 this.dispatchCartAction(Action.REMOVE_LINE_ITEM_DISCOUNT, payload);
2069 break;
2070 case Action.SET_LINE_ITEM_PROPERTIES:
2071 this.dispatchCartAction(Action.SET_LINE_ITEM_PROPERTIES, payload);
2072 break;
2073 case Action.REMOVE_LINE_ITEM_PROPERTIES:
2074 this.dispatchCartAction(Action.REMOVE_LINE_ITEM_PROPERTIES, payload);
2075 break;
2076 }
2077 return this;
2078 };
2079 Cart.prototype.dispatchCartAction = function (type, payload) {
2080 this.app.dispatch(createCartAction(type, __assign(__assign({}, payload), { id: this.id })));
2081 };
2082 return Cart;
2083}(helper_1.ActionSet));
2084exports.Cart = Cart;
2085function create(app, options) {
2086 return new Cart(app, options);
2087}
2088exports.create = create;
2089
2090
2091/***/ }),
2092/* 19 */
2093/***/ (function(module, exports, __webpack_require__) {
2094
2095"use strict";
2096
2097Object.defineProperty(exports, "__esModule", { value: true });
2098exports.initialize = exports.ActionType = exports.Action = void 0;
2099var types_1 = __webpack_require__(1);
2100var helper_1 = __webpack_require__(0);
2101var Action;
2102(function (Action) {
2103 Action["INITIALIZE"] = "APP::CLIENT::INITIALIZE";
2104})(Action = exports.Action || (exports.Action = {}));
2105var ActionType;
2106(function (ActionType) {
2107 ActionType["INITIALIZE"] = "APP::CLIENT::INITIALIZE";
2108})(ActionType = exports.ActionType || (exports.ActionType = {}));
2109function initialize() {
2110 return helper_1.actionWrapper({
2111 group: types_1.Group.Client,
2112 type: Action.INITIALIZE,
2113 });
2114}
2115exports.initialize = initialize;
2116
2117
2118/***/ }),
2119/* 20 */
2120/***/ (function(module, exports, __webpack_require__) {
2121
2122"use strict";
2123
2124Object.defineProperty(exports, "__esModule", { value: true });
2125exports.Action = void 0;
2126/**
2127 * Action Types for the Features group
2128 * @public
2129 */
2130var Action;
2131(function (Action) {
2132 Action["UPDATE"] = "APP::FEATURES::UPDATE";
2133 Action["REQUEST"] = "APP::FEATURES::REQUEST";
2134 Action["REQUEST_UPDATE"] = "APP::FEATURES::REQUEST::UPDATE";
2135})(Action = exports.Action || (exports.Action = {}));
2136
2137
2138/***/ }),
2139/* 21 */
2140/***/ (function(module, exports, __webpack_require__) {
2141
2142"use strict";
2143
2144var __extends = (this && this.__extends) || (function () {
2145 var extendStatics = function (d, b) {
2146 extendStatics = Object.setPrototypeOf ||
2147 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2148 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
2149 return extendStatics(d, b);
2150 };
2151 return function (d, b) {
2152 extendStatics(d, b);
2153 function __() { this.constructor = d; }
2154 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2155 };
2156})();
2157var __assign = (this && this.__assign) || function () {
2158 __assign = Object.assign || function(t) {
2159 for (var s, i = 1, n = arguments.length; i < n; i++) {
2160 s = arguments[i];
2161 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2162 t[p] = s[p];
2163 }
2164 return t;
2165 };
2166 return __assign.apply(this, arguments);
2167};
2168Object.defineProperty(exports, "__esModule", { value: true });
2169exports.create = exports.FeedbackModal = exports.close = exports.open = exports.Action = void 0;
2170var helper_1 = __webpack_require__(0);
2171var types_1 = __webpack_require__(1);
2172/**
2173 * Action for the Feedback Modal group
2174 * @public
2175 */
2176var Action;
2177(function (Action) {
2178 Action["OPEN"] = "APP::FEEDBACK_MODAL::OPEN";
2179 Action["CLOSE"] = "APP::FEEDBACK_MODAL::CLOSE";
2180})(Action = exports.Action || (exports.Action = {}));
2181function open(payload) {
2182 return helper_1.actionWrapper({
2183 group: types_1.Group.FeedbackModal,
2184 payload: payload,
2185 type: Action.OPEN,
2186 });
2187}
2188exports.open = open;
2189function close(payload) {
2190 return helper_1.actionWrapper({
2191 group: types_1.Group.FeedbackModal,
2192 payload: payload,
2193 type: Action.CLOSE,
2194 });
2195}
2196exports.close = close;
2197/**
2198 * FeedbackModal action set
2199 */
2200var FeedbackModal = /** @class */ (function (_super) {
2201 __extends(FeedbackModal, _super);
2202 /**
2203 * Returns a new instance of a FeedbackModal action set
2204 * @param app the client application
2205 */
2206 function FeedbackModal(app, options) {
2207 var _this = _super.call(this, app, types_1.Group.FeedbackModal, types_1.Group.FeedbackModal) || this;
2208 _this.options = options;
2209 _this.set(options);
2210 return _this;
2211 }
2212 Object.defineProperty(FeedbackModal.prototype, "payload", {
2213 /**
2214 * Returns the action set payload
2215 */
2216 get: function () {
2217 return __assign({ id: this.id }, this.options);
2218 },
2219 enumerable: false,
2220 configurable: true
2221 });
2222 FeedbackModal.prototype.set = function (options) {
2223 this.options = helper_1.getMergedProps(this.options, options);
2224 return this;
2225 };
2226 /**
2227 * Dispatches a given action with the action set payload
2228 * @param action the action enum
2229 * @returns the action set instance
2230 */
2231 FeedbackModal.prototype.dispatch = function (action) {
2232 switch (action) {
2233 case Action.OPEN:
2234 var openAction = open(this.payload);
2235 this.app.dispatch(openAction);
2236 break;
2237 case Action.CLOSE:
2238 var closeAction = close(this.payload);
2239 this.app.dispatch(closeAction);
2240 break;
2241 }
2242 return this;
2243 };
2244 return FeedbackModal;
2245}(helper_1.ActionSet));
2246exports.FeedbackModal = FeedbackModal;
2247/**
2248 * Returns a new instance of a FeedbackModal action set
2249 * @param app the client application
2250 */
2251function create(app, options) {
2252 return new FeedbackModal(app, options);
2253}
2254exports.create = create;
2255
2256
2257/***/ }),
2258/* 22 */
2259/***/ (function(module, exports, __webpack_require__) {
2260
2261"use strict";
2262
2263var __extends = (this && this.__extends) || (function () {
2264 var extendStatics = function (d, b) {
2265 extendStatics = Object.setPrototypeOf ||
2266 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2267 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
2268 return extendStatics(d, b);
2269 };
2270 return function (d, b) {
2271 extendStatics(d, b);
2272 function __() { this.constructor = d; }
2273 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2274 };
2275})();
2276Object.defineProperty(exports, "__esModule", { value: true });
2277exports.create = exports.Fullscreen = exports.exit = exports.enter = exports.Action = void 0;
2278var helper_1 = __webpack_require__(0);
2279var types_1 = __webpack_require__(1);
2280/**
2281 * Fullscreen action type enum
2282 * @remarks includes the action prefix and group
2283 *
2284 * @beta
2285 */
2286var Action;
2287(function (Action) {
2288 Action["ENTER"] = "APP::FULLSCREEN::ENTER";
2289 Action["EXIT"] = "APP::FULLSCREEN::EXIT";
2290})(Action = exports.Action || (exports.Action = {}));
2291function enter() {
2292 return helper_1.actionWrapper({
2293 group: types_1.Group.Fullscreen,
2294 type: Action.ENTER,
2295 });
2296}
2297exports.enter = enter;
2298function exit() {
2299 return helper_1.actionWrapper({
2300 group: types_1.Group.Fullscreen,
2301 type: Action.EXIT,
2302 });
2303}
2304exports.exit = exit;
2305/**
2306 * Fullscreen action set
2307 * @beta
2308 */
2309var Fullscreen = /** @class */ (function (_super) {
2310 __extends(Fullscreen, _super);
2311 /**
2312 * Returns a new instance of a Fullscreen action set
2313 * @param app the client application
2314 */
2315 function Fullscreen(app) {
2316 return _super.call(this, app, types_1.Group.Fullscreen, types_1.Group.Fullscreen) || this;
2317 }
2318 Object.defineProperty(Fullscreen.prototype, "payload", {
2319 /**
2320 * Returns the action set payload
2321 */
2322 get: function () {
2323 return { id: this.id };
2324 },
2325 enumerable: false,
2326 configurable: true
2327 });
2328 /**
2329 * Dispatches a given action with the action set payload
2330 * @param action the action enum
2331 * @returns the action set instance
2332 */
2333 Fullscreen.prototype.dispatch = function (action) {
2334 this.app.dispatch(helper_1.actionWrapper({
2335 group: this.group,
2336 type: action,
2337 payload: this.payload,
2338 }));
2339 return this;
2340 };
2341 return Fullscreen;
2342}(helper_1.ActionSet));
2343exports.Fullscreen = Fullscreen;
2344/**
2345 * Returns a new instance of a Fullscreen action set
2346 * @param app the client application
2347 *
2348 * @beta
2349 */
2350function create(app) {
2351 return new Fullscreen(app);
2352}
2353exports.create = create;
2354
2355
2356/***/ }),
2357/* 23 */
2358/***/ (function(module, exports, __webpack_require__) {
2359
2360"use strict";
2361
2362var __extends = (this && this.__extends) || (function () {
2363 var extendStatics = function (d, b) {
2364 extendStatics = Object.setPrototypeOf ||
2365 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2366 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
2367 return extendStatics(d, b);
2368 };
2369 return function (d, b) {
2370 extendStatics(d, b);
2371 function __() { this.constructor = d; }
2372 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2373 };
2374})();
2375var __assign = (this && this.__assign) || function () {
2376 __assign = Object.assign || function(t) {
2377 for (var s, i = 1, n = arguments.length; i < n; i++) {
2378 s = arguments[i];
2379 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2380 t[p] = s[p];
2381 }
2382 return t;
2383 };
2384 return __assign.apply(this, arguments);
2385};
2386Object.defineProperty(exports, "__esModule", { value: true });
2387exports.create = exports.LeaveConfirmation = exports.confirm = exports.disable = exports.enable = exports.Action = void 0;
2388var helper_1 = __webpack_require__(0);
2389var types_1 = __webpack_require__(1);
2390/**
2391 * Action for the Leave Confirmation group
2392 * @public
2393 */
2394var Action;
2395(function (Action) {
2396 Action["ENABLE"] = "APP::LEAVE_CONFIRMATION::ENABLE";
2397 Action["DISABLE"] = "APP::LEAVE_CONFIRMATION::DISABLE";
2398 Action["CONFIRM"] = "APP::LEAVE_CONFIRMATION::CONFIRM";
2399})(Action = exports.Action || (exports.Action = {}));
2400function enable(payload) {
2401 if (payload === void 0) { payload = {}; }
2402 return helper_1.actionWrapper({
2403 group: types_1.Group.LeaveConfirmation,
2404 payload: payload,
2405 type: Action.ENABLE,
2406 });
2407}
2408exports.enable = enable;
2409function disable(payload) {
2410 if (payload === void 0) { payload = {}; }
2411 return helper_1.actionWrapper({
2412 group: types_1.Group.LeaveConfirmation,
2413 payload: payload,
2414 type: Action.DISABLE,
2415 });
2416}
2417exports.disable = disable;
2418function confirm(payload) {
2419 if (payload === void 0) { payload = {}; }
2420 return helper_1.actionWrapper({
2421 group: types_1.Group.LeaveConfirmation,
2422 payload: payload,
2423 type: Action.CONFIRM,
2424 });
2425}
2426exports.confirm = confirm;
2427/**
2428 * Leave Confirmation action set
2429 */
2430var LeaveConfirmation = /** @class */ (function (_super) {
2431 __extends(LeaveConfirmation, _super);
2432 /**
2433 * Returns a new instance of a Leave Confirmation action set
2434 * @param app the client application
2435 */
2436 function LeaveConfirmation(app, options) {
2437 if (options === void 0) { options = {}; }
2438 var _this = _super.call(this, app, types_1.Group.LeaveConfirmation, types_1.Group.LeaveConfirmation) || this;
2439 _this.options = options;
2440 _this.set(options);
2441 return _this;
2442 }
2443 Object.defineProperty(LeaveConfirmation.prototype, "payload", {
2444 /**
2445 * Returns the action set payload
2446 */
2447 get: function () {
2448 return __assign({ id: this.id }, this.options);
2449 },
2450 enumerable: false,
2451 configurable: true
2452 });
2453 LeaveConfirmation.prototype.set = function (options) {
2454 this.options = helper_1.getMergedProps(this.options, options);
2455 return this;
2456 };
2457 /**
2458 * Dispatches a given action with the action set payload
2459 * @param action the action enum
2460 * @returns the action set instance
2461 */
2462 LeaveConfirmation.prototype.dispatch = function (action) {
2463 switch (action) {
2464 case Action.ENABLE:
2465 var enableAction = enable(this.payload);
2466 this.app.dispatch(enableAction);
2467 break;
2468 case Action.DISABLE:
2469 var disableAction = disable(this.payload);
2470 this.app.dispatch(disableAction);
2471 break;
2472 case Action.CONFIRM:
2473 var confirmAction = confirm(this.payload);
2474 this.app.dispatch(confirmAction);
2475 break;
2476 }
2477 return this;
2478 };
2479 return LeaveConfirmation;
2480}(helper_1.ActionSet));
2481exports.LeaveConfirmation = LeaveConfirmation;
2482/**
2483 * Returns a new instance of a Leave Confirmation action set
2484 * @param app the client application
2485 */
2486function create(app, options) {
2487 if (options === void 0) { options = {}; }
2488 return new LeaveConfirmation(app, options);
2489}
2490exports.create = create;
2491
2492
2493/***/ }),
2494/* 24 */
2495/***/ (function(module, exports, __webpack_require__) {
2496
2497"use strict";
2498
2499var __extends = (this && this.__extends) || (function () {
2500 var extendStatics = function (d, b) {
2501 extendStatics = Object.setPrototypeOf ||
2502 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2503 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
2504 return extendStatics(d, b);
2505 };
2506 return function (d, b) {
2507 extendStatics(d, b);
2508 function __() { this.constructor = d; }
2509 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2510 };
2511})();
2512Object.defineProperty(exports, "__esModule", { value: true });
2513exports.create = exports.Loading = exports.stop = exports.start = exports.Action = void 0;
2514var helper_1 = __webpack_require__(0);
2515var types_1 = __webpack_require__(1);
2516var Action;
2517(function (Action) {
2518 Action["START"] = "APP::LOADING::START";
2519 Action["STOP"] = "APP::LOADING::STOP";
2520})(Action = exports.Action || (exports.Action = {}));
2521function start(payload) {
2522 return helper_1.actionWrapper({
2523 payload: payload,
2524 group: types_1.Group.Loading,
2525 type: Action.START,
2526 });
2527}
2528exports.start = start;
2529function stop(payload) {
2530 return helper_1.actionWrapper({
2531 payload: payload,
2532 group: types_1.Group.Loading,
2533 type: Action.STOP,
2534 });
2535}
2536exports.stop = stop;
2537var Loading = /** @class */ (function (_super) {
2538 __extends(Loading, _super);
2539 function Loading(app) {
2540 return _super.call(this, app, types_1.Group.Loading, types_1.Group.Loading) || this;
2541 }
2542 Object.defineProperty(Loading.prototype, "payload", {
2543 get: function () {
2544 return { id: this.id };
2545 },
2546 enumerable: false,
2547 configurable: true
2548 });
2549 Loading.prototype.dispatch = function (action) {
2550 switch (action) {
2551 case Action.START:
2552 this.app.dispatch(start(this.payload));
2553 break;
2554 case Action.STOP:
2555 this.app.dispatch(stop(this.payload));
2556 break;
2557 }
2558 return this;
2559 };
2560 return Loading;
2561}(helper_1.ActionSet));
2562exports.Loading = Loading;
2563function create(app) {
2564 return new Loading(app);
2565}
2566exports.create = create;
2567
2568
2569/***/ }),
2570/* 25 */
2571/***/ (function(module, exports, __webpack_require__) {
2572
2573"use strict";
2574
2575var __extends = (this && this.__extends) || (function () {
2576 var extendStatics = function (d, b) {
2577 extendStatics = Object.setPrototypeOf ||
2578 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2579 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
2580 return extendStatics(d, b);
2581 };
2582 return function (d, b) {
2583 extendStatics(d, b);
2584 function __() { this.constructor = d; }
2585 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2586 };
2587})();
2588var __assign = (this && this.__assign) || function () {
2589 __assign = Object.assign || function(t) {
2590 for (var s, i = 1, n = arguments.length; i < n; i++) {
2591 s = arguments[i];
2592 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2593 t[p] = s[p];
2594 }
2595 return t;
2596 };
2597 return __assign.apply(this, arguments);
2598};
2599Object.defineProperty(exports, "__esModule", { value: true });
2600exports.create = exports.ModalIframe = exports.ModalMessage = exports.Modal = exports.isMessageModal = exports.isIframeModal = exports.data = exports.update = exports.clickFooterButton = exports.updateModalSize = exports.closeModal = exports.openModal = exports.Size = exports.Action = void 0;
2601var buttonHelper_1 = __webpack_require__(8);
2602var helper_1 = __webpack_require__(0);
2603var types_1 = __webpack_require__(1);
2604var Button_1 = __webpack_require__(4);
2605var Action;
2606(function (Action) {
2607 Action["OPEN"] = "APP::MODAL::OPEN";
2608 Action["CLOSE"] = "APP::MODAL::CLOSE";
2609 Action["UPDATE"] = "APP::MODAL::UPDATE";
2610 Action["FOOTER_BUTTON_CLICK"] = "APP::MODAL::FOOTER::BUTTON::CLICK";
2611 Action["FOOTER_BUTTON_UPDATE"] = "APP::MODAL::FOOTER::BUTTON::UPDATE";
2612 Action["UPDATE_SIZE"] = "APP::MODAL::UPDATE_SIZE";
2613 Action["DATA"] = "APP::MODAL::DATA";
2614})(Action = exports.Action || (exports.Action = {}));
2615/**
2616 * Options available to the Modal `size` param
2617 * @public
2618 */
2619var Size;
2620(function (Size) {
2621 /** Small modal size */
2622 Size["Small"] = "small";
2623 /** Medium modal size */
2624 Size["Medium"] = "medium";
2625 /** Large modal size (wider than medium) */
2626 Size["Large"] = "large";
2627 /** @deprecated as of 1.6.5 */
2628 Size["Full"] = "full";
2629 /**
2630 * @deprecated as of 1.12.x
2631 * @remarks
2632 * This option has been removed in favour of the `setUpModalAutoSizing` utility.
2633 * See `app-bridge-utils` package for more information
2634 */
2635 Size["Auto"] = "auto";
2636})(Size = exports.Size || (exports.Size = {}));
2637var FOOTER_BUTTON_PROPS = {
2638 group: types_1.Group.Modal,
2639 subgroups: ['Footer'],
2640 type: types_1.ComponentType.Button,
2641};
2642function openModal(modalPayload) {
2643 return helper_1.actionWrapper({
2644 group: types_1.Group.Modal,
2645 payload: modalPayload,
2646 type: Action.OPEN,
2647 });
2648}
2649exports.openModal = openModal;
2650function closeModal(modalClosePayload) {
2651 return helper_1.actionWrapper({
2652 group: types_1.Group.Modal,
2653 payload: modalClosePayload,
2654 type: Action.CLOSE,
2655 });
2656}
2657exports.closeModal = closeModal;
2658/**
2659 * Action creator for modal update size action
2660 * @internal
2661 */
2662function updateModalSize(updateSizePayload) {
2663 return helper_1.actionWrapper({
2664 group: types_1.Group.Modal,
2665 payload: updateSizePayload,
2666 type: Action.UPDATE_SIZE,
2667 });
2668}
2669exports.updateModalSize = updateModalSize;
2670function clickFooterButton(id, payload) {
2671 var component = __assign({ id: id }, FOOTER_BUTTON_PROPS);
2672 return Button_1.clickButton(types_1.Group.Modal, component, payload);
2673}
2674exports.clickFooterButton = clickFooterButton;
2675function update(payload) {
2676 return helper_1.actionWrapper({
2677 payload: payload,
2678 group: types_1.Group.Modal,
2679 type: Action.UPDATE,
2680 });
2681}
2682exports.update = update;
2683function data(payload) {
2684 return helper_1.actionWrapper({
2685 payload: payload,
2686 group: types_1.Group.Modal,
2687 type: Action.DATA,
2688 });
2689}
2690exports.data = data;
2691function isIframeModal(options) {
2692 return (typeof options.url === 'string' ||
2693 typeof options.path === 'string');
2694}
2695exports.isIframeModal = isIframeModal;
2696function isMessageModal(options) {
2697 return typeof options.message === 'string';
2698}
2699exports.isMessageModal = isMessageModal;
2700var Modal = /** @class */ (function (_super) {
2701 __extends(Modal, _super);
2702 function Modal() {
2703 var _this = _super !== null && _super.apply(this, arguments) || this;
2704 _this.size = Size.Small;
2705 return _this;
2706 }
2707 Object.defineProperty(Modal.prototype, "footer", {
2708 get: function () {
2709 if (!this.footerPrimary && !this.footerSecondary) {
2710 return undefined;
2711 }
2712 return {
2713 buttons: {
2714 primary: this.footerPrimary,
2715 secondary: this.footerSecondary,
2716 },
2717 };
2718 },
2719 enumerable: false,
2720 configurable: true
2721 });
2722 Object.defineProperty(Modal.prototype, "footerOptions", {
2723 get: function () {
2724 if (!this.footerPrimaryOptions && !this.footerSecondaryOptions) {
2725 return undefined;
2726 }
2727 return {
2728 buttons: {
2729 primary: this.footerPrimaryOptions,
2730 secondary: this.footerSecondaryOptions,
2731 },
2732 };
2733 },
2734 enumerable: false,
2735 configurable: true
2736 });
2737 Modal.prototype.close = function () {
2738 this.app.dispatch(closeModal({ id: this.id }));
2739 };
2740 Modal.prototype.setFooterPrimaryButton = function (newOptions, updateCb) {
2741 var _this = this;
2742 var subgroups = FOOTER_BUTTON_PROPS.subgroups;
2743 this.footerPrimaryOptions = this.getChildButton(newOptions, this.footerPrimaryOptions);
2744 this.footerPrimary = this.footerPrimaryOptions
2745 ? buttonHelper_1.getSingleButton(this, this.footerPrimaryOptions, subgroups, function (newPayload) {
2746 _this.updatePrimaryFooterButton(newPayload, updateCb);
2747 })
2748 : undefined;
2749 };
2750 Modal.prototype.setFooterSecondaryButtons = function (newOptions, updateCb) {
2751 var _this = this;
2752 var subgroups = FOOTER_BUTTON_PROPS.subgroups;
2753 var newButtons = newOptions || [];
2754 var currentOptions = (this.footerOptions && this.footerOptions.buttons.secondary) || [];
2755 this.footerSecondaryOptions = this.getUpdatedChildActions(newButtons, currentOptions);
2756 this.footerSecondary = this.footerSecondaryOptions
2757 ? this.footerSecondaryOptions.map(function (action) {
2758 return buttonHelper_1.getSingleButton(_this, action, subgroups, function (newPayload) {
2759 _this.updateSecondaryFooterButton(newPayload, updateCb);
2760 });
2761 })
2762 : undefined;
2763 };
2764 Modal.prototype.getChildButton = function (newAction, currentAction) {
2765 var newButtons = newAction ? [newAction] : [];
2766 var currentButtons = currentAction ? [currentAction] : [];
2767 var updatedButton = this.getUpdatedChildActions(newButtons, currentButtons);
2768 return updatedButton ? updatedButton[0] : undefined;
2769 };
2770 Modal.prototype.updatePrimaryFooterButton = function (newPayload, updateCb) {
2771 if (!this.footer || !this.footer.buttons.primary) {
2772 return;
2773 }
2774 if (helper_1.updateActionFromPayload(this.footer.buttons.primary, newPayload)) {
2775 updateCb();
2776 }
2777 };
2778 Modal.prototype.updateSecondaryFooterButton = function (newPayload, updateCb) {
2779 if (!this.footer || !this.footer.buttons || !this.footer.buttons.secondary) {
2780 return;
2781 }
2782 var updated;
2783 for (var _i = 0, _a = this.footer.buttons.secondary; _i < _a.length; _i++) {
2784 var action = _a[_i];
2785 updated = helper_1.updateActionFromPayload(action, newPayload);
2786 if (updated) {
2787 break;
2788 }
2789 }
2790 if (updated) {
2791 updateCb();
2792 }
2793 };
2794 return Modal;
2795}(helper_1.ActionSetWithChildren));
2796exports.Modal = Modal;
2797var ModalMessage = /** @class */ (function (_super) {
2798 __extends(ModalMessage, _super);
2799 function ModalMessage(app, options) {
2800 var _this = _super.call(this, app, types_1.Group.Modal, types_1.Group.Modal) || this;
2801 _this.set(options, false);
2802 return _this;
2803 }
2804 Object.defineProperty(ModalMessage.prototype, "payload", {
2805 get: function () {
2806 return __assign(__assign({}, this.options), { footer: this.footer, id: this.id });
2807 },
2808 enumerable: false,
2809 configurable: true
2810 });
2811 Object.defineProperty(ModalMessage.prototype, "options", {
2812 get: function () {
2813 return {
2814 footer: this.footerOptions,
2815 message: this.message,
2816 size: this.size,
2817 title: this.title,
2818 };
2819 },
2820 enumerable: false,
2821 configurable: true
2822 });
2823 ModalMessage.prototype.set = function (options, shouldUpdate) {
2824 var _this = this;
2825 if (shouldUpdate === void 0) { shouldUpdate = true; }
2826 var mergedOptions = helper_1.getMergedProps(this.options, options);
2827 var title = mergedOptions.title, footer = mergedOptions.footer, message = mergedOptions.message, size = mergedOptions.size;
2828 this.title = title;
2829 this.message = message;
2830 this.size = size;
2831 this.setFooterPrimaryButton(footer ? footer.buttons.primary : undefined, function () {
2832 _this.dispatch(Action.UPDATE);
2833 });
2834 this.setFooterSecondaryButtons(footer ? footer.buttons.secondary : undefined, function () {
2835 _this.dispatch(Action.UPDATE);
2836 });
2837 if (shouldUpdate) {
2838 this.dispatch(Action.UPDATE);
2839 }
2840 return this;
2841 };
2842 ModalMessage.prototype.dispatch = function (action) {
2843 switch (action) {
2844 case Action.OPEN:
2845 this.app.dispatch(openModal(this.payload));
2846 break;
2847 case Action.CLOSE:
2848 this.close();
2849 break;
2850 case Action.UPDATE:
2851 this.app.dispatch(update(this.payload));
2852 break;
2853 }
2854 return this;
2855 };
2856 return ModalMessage;
2857}(Modal));
2858exports.ModalMessage = ModalMessage;
2859var ModalIframe = /** @class */ (function (_super) {
2860 __extends(ModalIframe, _super);
2861 function ModalIframe(app, options) {
2862 var _this = _super.call(this, app, types_1.Group.Modal, types_1.Group.Modal) || this;
2863 _this.set(options, false);
2864 return _this;
2865 }
2866 Object.defineProperty(ModalIframe.prototype, "payload", {
2867 get: function () {
2868 return __assign(__assign({}, this.options), { footer: this.footer, id: this.id });
2869 },
2870 enumerable: false,
2871 configurable: true
2872 });
2873 Object.defineProperty(ModalIframe.prototype, "options", {
2874 get: function () {
2875 return {
2876 footer: this.footerOptions,
2877 path: this.path,
2878 size: this.size,
2879 title: this.title,
2880 url: this.url,
2881 };
2882 },
2883 enumerable: false,
2884 configurable: true
2885 });
2886 ModalIframe.prototype.set = function (options, shouldUpdate) {
2887 var _this = this;
2888 if (shouldUpdate === void 0) { shouldUpdate = true; }
2889 var mergedOptions = helper_1.getMergedProps(this.options, options);
2890 var title = mergedOptions.title, footer = mergedOptions.footer, path = mergedOptions.path, url = mergedOptions.url, size = mergedOptions.size;
2891 this.title = title;
2892 this.url = url;
2893 this.path = path;
2894 this.size = size;
2895 this.setFooterPrimaryButton(footer ? footer.buttons.primary : undefined, function () {
2896 _this.dispatch(Action.UPDATE);
2897 });
2898 this.setFooterSecondaryButtons(footer ? footer.buttons.secondary : undefined, function () {
2899 _this.dispatch(Action.UPDATE);
2900 });
2901 if (shouldUpdate) {
2902 this.dispatch(Action.UPDATE);
2903 }
2904 return this;
2905 };
2906 ModalIframe.prototype.dispatch = function (action, payload) {
2907 switch (action) {
2908 case Action.OPEN:
2909 this.app.dispatch(openModal(this.payload));
2910 break;
2911 case Action.CLOSE:
2912 this.close();
2913 break;
2914 case Action.UPDATE:
2915 this.app.dispatch(update(this.payload));
2916 break;
2917 case Action.DATA:
2918 this.app.dispatch(data(payload || {}));
2919 break;
2920 }
2921 return this;
2922 };
2923 return ModalIframe;
2924}(Modal));
2925exports.ModalIframe = ModalIframe;
2926exports.create = function (app, options) {
2927 if (isIframeModal(options)) {
2928 return new ModalIframe(app, options);
2929 }
2930 return new ModalMessage(app, options);
2931};
2932
2933
2934/***/ }),
2935/* 26 */
2936/***/ (function(module, exports, __webpack_require__) {
2937
2938"use strict";
2939
2940var __extends = (this && this.__extends) || (function () {
2941 var extendStatics = function (d, b) {
2942 extendStatics = Object.setPrototypeOf ||
2943 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2944 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
2945 return extendStatics(d, b);
2946 };
2947 return function (d, b) {
2948 extendStatics(d, b);
2949 function __() { this.constructor = d; }
2950 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2951 };
2952})();
2953var __assign = (this && this.__assign) || function () {
2954 __assign = Object.assign || function(t) {
2955 for (var s, i = 1, n = arguments.length; i < n; i++) {
2956 s = arguments[i];
2957 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2958 t[p] = s[p];
2959 }
2960 return t;
2961 };
2962 return __assign.apply(this, arguments);
2963};
2964Object.defineProperty(exports, "__esModule", { value: true });
2965exports.create = exports.History = exports.replace = exports.push = exports.Action = void 0;
2966var helper_1 = __webpack_require__(0);
2967var types_1 = __webpack_require__(1);
2968var Action;
2969(function (Action) {
2970 Action["PUSH"] = "APP::NAVIGATION::HISTORY::PUSH";
2971 Action["REPLACE"] = "APP::NAVIGATION::HISTORY::REPLACE";
2972})(Action = exports.Action || (exports.Action = {}));
2973function push(payload) {
2974 return helper_1.actionWrapper({
2975 payload: payload,
2976 group: types_1.Group.Navigation,
2977 type: Action.PUSH,
2978 });
2979}
2980exports.push = push;
2981function replace(payload) {
2982 return helper_1.actionWrapper({
2983 payload: payload,
2984 group: types_1.Group.Navigation,
2985 type: Action.REPLACE,
2986 });
2987}
2988exports.replace = replace;
2989var History = /** @class */ (function (_super) {
2990 __extends(History, _super);
2991 function History(app) {
2992 return _super.call(this, app, 'History', types_1.Group.Navigation) || this;
2993 }
2994 Object.defineProperty(History.prototype, "payload", {
2995 get: function () {
2996 return { id: this.id };
2997 },
2998 enumerable: false,
2999 configurable: true
3000 });
3001 History.prototype.dispatch = function (type, path) {
3002 var payload = __assign(__assign({}, this.payload), { path: path });
3003 switch (type) {
3004 case Action.PUSH:
3005 this.app.dispatch(push(payload));
3006 break;
3007 case Action.REPLACE:
3008 this.app.dispatch(replace(payload));
3009 break;
3010 }
3011 return this;
3012 };
3013 return History;
3014}(helper_1.ActionSet));
3015exports.History = History;
3016function create(app) {
3017 return new History(app);
3018}
3019exports.create = create;
3020
3021
3022/***/ }),
3023/* 27 */
3024/***/ (function(module, exports, __webpack_require__) {
3025
3026"use strict";
3027
3028var __extends = (this && this.__extends) || (function () {
3029 var extendStatics = function (d, b) {
3030 extendStatics = Object.setPrototypeOf ||
3031 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3032 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3033 return extendStatics(d, b);
3034 };
3035 return function (d, b) {
3036 extendStatics(d, b);
3037 function __() { this.constructor = d; }
3038 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3039 };
3040})();
3041var __assign = (this && this.__assign) || function () {
3042 __assign = Object.assign || function(t) {
3043 for (var s, i = 1, n = arguments.length; i < n; i++) {
3044 s = arguments[i];
3045 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3046 t[p] = s[p];
3047 }
3048 return t;
3049 };
3050 return __assign.apply(this, arguments);
3051};
3052Object.defineProperty(exports, "__esModule", { value: true });
3053exports.create = exports.ResourcePicker = exports.update = exports.close = exports.cancel = exports.open = exports.select = exports.ActionVerb = exports.ResourceType = exports.ProductStatus = exports.ProductVariantInventoryManagement = exports.ProductVariantInventoryPolicy = exports.WeightUnit = exports.FulfillmentServiceType = exports.CollectionSortOrder = exports.Action = void 0;
3054var helper_1 = __webpack_require__(0);
3055var types_1 = __webpack_require__(1);
3056var Action;
3057(function (Action) {
3058 Action["OPEN"] = "APP::RESOURCE_PICKER::OPEN";
3059 Action["SELECT"] = "APP::RESOURCE_PICKER::SELECT";
3060 Action["CLOSE"] = "APP::RESOURCE_PICKER::CLOSE";
3061 Action["UPDATE"] = "APP::RESOURCE_PICKER::UPDATE";
3062 Action["CANCEL"] = "APP::RESOURCE_PICKER::CANCEL";
3063})(Action = exports.Action || (exports.Action = {}));
3064var CollectionSortOrder;
3065(function (CollectionSortOrder) {
3066 CollectionSortOrder["Manual"] = "MANUAL";
3067 CollectionSortOrder["BestSelling"] = "BEST_SELLING";
3068 CollectionSortOrder["AlphaAsc"] = "ALPHA_ASC";
3069 CollectionSortOrder["AlphaDesc"] = "ALPHA_DESC";
3070 CollectionSortOrder["PriceDesc"] = "PRICE_DESC";
3071 CollectionSortOrder["PriceAsc"] = "PRICE_ASC";
3072 CollectionSortOrder["CreatedDesc"] = "CREATED_DESC";
3073 CollectionSortOrder["Created"] = "CREATED";
3074})(CollectionSortOrder = exports.CollectionSortOrder || (exports.CollectionSortOrder = {}));
3075var FulfillmentServiceType;
3076(function (FulfillmentServiceType) {
3077 FulfillmentServiceType["GiftCard"] = "GIFT_CARD";
3078 FulfillmentServiceType["Manual"] = "MANUAL";
3079 FulfillmentServiceType["ThirdParty"] = "THIRD_PARTY";
3080})(FulfillmentServiceType = exports.FulfillmentServiceType || (exports.FulfillmentServiceType = {}));
3081var WeightUnit;
3082(function (WeightUnit) {
3083 WeightUnit["Kilograms"] = "KILOGRAMS";
3084 WeightUnit["Grams"] = "GRAMS";
3085 WeightUnit["Pounds"] = "POUNDS";
3086 WeightUnit["Ounces"] = "OUNCES";
3087})(WeightUnit = exports.WeightUnit || (exports.WeightUnit = {}));
3088var ProductVariantInventoryPolicy;
3089(function (ProductVariantInventoryPolicy) {
3090 ProductVariantInventoryPolicy["Deny"] = "DENY";
3091 ProductVariantInventoryPolicy["Continue"] = "CONTINUE";
3092})(ProductVariantInventoryPolicy = exports.ProductVariantInventoryPolicy || (exports.ProductVariantInventoryPolicy = {}));
3093var ProductVariantInventoryManagement;
3094(function (ProductVariantInventoryManagement) {
3095 ProductVariantInventoryManagement["Shopify"] = "SHOPIFY";
3096 ProductVariantInventoryManagement["NotManaged"] = "NOT_MANAGED";
3097 ProductVariantInventoryManagement["FulfillmentService"] = "FULFILLMENT_SERVICE";
3098})(ProductVariantInventoryManagement = exports.ProductVariantInventoryManagement || (exports.ProductVariantInventoryManagement = {}));
3099var ProductStatus;
3100(function (ProductStatus) {
3101 ProductStatus["Active"] = "ACTIVE";
3102 ProductStatus["Archived"] = "ARCHIVED";
3103 ProductStatus["Draft"] = "DRAFT";
3104})(ProductStatus = exports.ProductStatus || (exports.ProductStatus = {}));
3105var ResourceType;
3106(function (ResourceType) {
3107 ResourceType["Product"] = "product";
3108 ResourceType["ProductVariant"] = "variant";
3109 ResourceType["Collection"] = "collection";
3110})(ResourceType = exports.ResourceType || (exports.ResourceType = {}));
3111var ActionVerb;
3112(function (ActionVerb) {
3113 ActionVerb["Add"] = "add";
3114 ActionVerb["Select"] = "select";
3115})(ActionVerb = exports.ActionVerb || (exports.ActionVerb = {}));
3116function select(payload) {
3117 return helper_1.actionWrapper({
3118 payload: payload,
3119 group: types_1.Group.ResourcePicker,
3120 type: Action.SELECT,
3121 });
3122}
3123exports.select = select;
3124function open(payload) {
3125 return helper_1.actionWrapper({
3126 payload: payload,
3127 group: types_1.Group.ResourcePicker,
3128 type: Action.OPEN,
3129 });
3130}
3131exports.open = open;
3132function cancel(payload) {
3133 return helper_1.actionWrapper({
3134 payload: payload,
3135 group: types_1.Group.ResourcePicker,
3136 type: Action.CANCEL,
3137 });
3138}
3139exports.cancel = cancel;
3140function close(payload) {
3141 return helper_1.actionWrapper({
3142 payload: payload,
3143 group: types_1.Group.ResourcePicker,
3144 type: Action.CANCEL,
3145 });
3146}
3147exports.close = close;
3148function update(payload) {
3149 return helper_1.actionWrapper({
3150 payload: payload,
3151 group: types_1.Group.ResourcePicker,
3152 type: Action.UPDATE,
3153 });
3154}
3155exports.update = update;
3156var ResourcePicker = /** @class */ (function (_super) {
3157 __extends(ResourcePicker, _super);
3158 function ResourcePicker(app, options, resourceType) {
3159 var _this = _super.call(this, app, types_1.Group.ResourcePicker, types_1.Group.ResourcePicker) || this;
3160 _this.initialSelectionIds = [];
3161 _this.selection = [];
3162 _this.resourceType = resourceType;
3163 _this.set(options, false);
3164 return _this;
3165 }
3166 Object.defineProperty(ResourcePicker.prototype, "payload", {
3167 get: function () {
3168 return __assign(__assign({}, this.options), { id: this.id, resourceType: this.resourceType });
3169 },
3170 enumerable: false,
3171 configurable: true
3172 });
3173 Object.defineProperty(ResourcePicker.prototype, "options", {
3174 get: function () {
3175 var options = {
3176 initialQuery: this.initialQuery,
3177 selectMultiple: this.selectMultiple,
3178 initialSelectionIds: this.initialSelectionIds,
3179 showHidden: this.showHidden,
3180 actionVerb: this.actionVerb,
3181 };
3182 if (this.resourceType === ResourceType.Product) {
3183 var productOptions = __assign(__assign({}, options), { showVariants: this.showVariants, showDraft: this.showDraft, showArchived: this.showArchived, showDraftBadge: this.showDraftBadge, showArchivedBadge: this.showArchivedBadge });
3184 return productOptions;
3185 }
3186 return options;
3187 },
3188 enumerable: false,
3189 configurable: true
3190 });
3191 ResourcePicker.prototype.set = function (options, shouldUpdate) {
3192 if (shouldUpdate === void 0) { shouldUpdate = true; }
3193 var mergedOptions = helper_1.getMergedProps(this.options, options);
3194 var initialQuery = mergedOptions.initialQuery, _a = mergedOptions.initialSelectionIds, initialSelectionIds = _a === void 0 ? [] : _a, _b = mergedOptions.showHidden, showHidden = _b === void 0 ? true : _b, _c = mergedOptions.showVariants, showVariants = _c === void 0 ? true : _c, _d = mergedOptions.showDraft, showDraft = _d === void 0 ? true : _d, _e = mergedOptions.showArchived, showArchived = _e === void 0 ? true : _e, _f = mergedOptions.showDraftBadge, showDraftBadge = _f === void 0 ? false : _f, _g = mergedOptions.showArchivedBadge, showArchivedBadge = _g === void 0 ? false : _g, _h = mergedOptions.selectMultiple, selectMultiple = _h === void 0 ? true : _h, _j = mergedOptions.actionVerb, actionVerb = _j === void 0 ? ActionVerb.Add : _j;
3195 this.initialQuery = initialQuery;
3196 this.initialSelectionIds = initialSelectionIds;
3197 this.showHidden = showHidden;
3198 this.showVariants = showVariants;
3199 this.showDraft = showDraft;
3200 this.showArchived = showArchived;
3201 this.showDraftBadge = showDraftBadge;
3202 this.showArchivedBadge = showArchivedBadge;
3203 this.selectMultiple = selectMultiple;
3204 this.actionVerb = actionVerb;
3205 if (shouldUpdate) {
3206 this.update();
3207 }
3208 return this;
3209 };
3210 ResourcePicker.prototype.dispatch = function (action, selection) {
3211 if (action === Action.OPEN) {
3212 this.open();
3213 }
3214 else if (action === Action.UPDATE) {
3215 this.update();
3216 }
3217 else if (action === Action.CLOSE || action === Action.CANCEL) {
3218 this.cancel();
3219 }
3220 else if (action === Action.SELECT) {
3221 this.selection = selection;
3222 this.app.dispatch(select({ id: this.id, selection: this.selection }));
3223 }
3224 return this;
3225 };
3226 ResourcePicker.prototype.update = function () {
3227 this.app.dispatch(update(this.payload));
3228 };
3229 ResourcePicker.prototype.open = function () {
3230 this.app.dispatch(open(this.payload));
3231 };
3232 ResourcePicker.prototype.cancel = function () {
3233 this.app.dispatch(cancel({ id: this.id }));
3234 };
3235 ResourcePicker.prototype.close = function () {
3236 this.cancel();
3237 };
3238 return ResourcePicker;
3239}(helper_1.ActionSet));
3240exports.ResourcePicker = ResourcePicker;
3241exports.create = function (app, baseOptions) {
3242 var resourceType = baseOptions.resourceType, _a = baseOptions.options, options = _a === void 0 ? {} : _a;
3243 return new ResourcePicker(app, options, resourceType);
3244};
3245
3246
3247/***/ }),
3248/* 28 */
3249/***/ (function(module, exports, __webpack_require__) {
3250
3251"use strict";
3252
3253var __extends = (this && this.__extends) || (function () {
3254 var extendStatics = function (d, b) {
3255 extendStatics = Object.setPrototypeOf ||
3256 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3257 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3258 return extendStatics(d, b);
3259 };
3260 return function (d, b) {
3261 extendStatics(d, b);
3262 function __() { this.constructor = d; }
3263 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3264 };
3265})();
3266Object.defineProperty(exports, "__esModule", { value: true });
3267exports.create = exports.Scanner = exports.Action = void 0;
3268var helper_1 = __webpack_require__(0);
3269var types_1 = __webpack_require__(1);
3270/**
3271 * Action Types for the Features group
3272 * @public
3273 */
3274var Action;
3275(function (Action) {
3276 Action["OPEN_CAMERA"] = "APP::SCANNER::OPEN::CAMERA";
3277 Action["CAPTURE"] = "APP::SCANNER::CAPTURE";
3278})(Action = exports.Action || (exports.Action = {}));
3279/**
3280 * A set of Actions for displaying a Camera Scanner component
3281 * @public
3282 */
3283var Scanner = /** @class */ (function (_super) {
3284 __extends(Scanner, _super);
3285 function Scanner(app, options) {
3286 return _super.call(this, app, types_1.Group.Scanner, types_1.Group.Scanner, options ? options.id : undefined) || this;
3287 }
3288 /**
3289 * @public
3290 */
3291 Scanner.prototype.dispatch = function (action) {
3292 switch (action) {
3293 case Action.OPEN_CAMERA:
3294 this.dispatchScannerAction(Action.OPEN_CAMERA);
3295 break;
3296 }
3297 return this;
3298 };
3299 /**
3300 * @internal
3301 */
3302 Scanner.prototype.dispatchScannerAction = function (type) {
3303 this.app.dispatch(helper_1.actionWrapper({
3304 type: type,
3305 group: types_1.Group.Scanner,
3306 payload: {
3307 id: this.id,
3308 },
3309 }));
3310 };
3311 return Scanner;
3312}(helper_1.ActionSet));
3313exports.Scanner = Scanner;
3314/**
3315 * @public
3316 */
3317function create(app, options) {
3318 return new Scanner(app, options);
3319}
3320exports.create = create;
3321
3322
3323/***/ }),
3324/* 29 */
3325/***/ (function(module, exports, __webpack_require__) {
3326
3327"use strict";
3328
3329var __extends = (this && this.__extends) || (function () {
3330 var extendStatics = function (d, b) {
3331 extendStatics = Object.setPrototypeOf ||
3332 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3333 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3334 return extendStatics(d, b);
3335 };
3336 return function (d, b) {
3337 extendStatics(d, b);
3338 function __() { this.constructor = d; }
3339 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3340 };
3341})();
3342var __assign = (this && this.__assign) || function () {
3343 __assign = Object.assign || function(t) {
3344 for (var s, i = 1, n = arguments.length; i < n; i++) {
3345 s = arguments[i];
3346 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3347 t[p] = s[p];
3348 }
3349 return t;
3350 };
3351 return __assign.apply(this, arguments);
3352};
3353Object.defineProperty(exports, "__esModule", { value: true });
3354exports.create = exports.TitleBar = exports.update = exports.clickBreadcrumb = exports.clickActionButton = exports.Action = void 0;
3355var Button_1 = __webpack_require__(4);
3356var ButtonGroup_1 = __webpack_require__(7);
3357var buttonGroupHelper_1 = __webpack_require__(52);
3358var buttonHelper_1 = __webpack_require__(8);
3359var helper_1 = __webpack_require__(0);
3360var types_1 = __webpack_require__(1);
3361var Action;
3362(function (Action) {
3363 Action["UPDATE"] = "APP::TITLEBAR::UPDATE";
3364 Action["BUTTON_CLICK"] = "APP::TITLEBAR::BUTTONS::BUTTON::CLICK";
3365 Action["BUTTON_UPDATE"] = "APP::TITLEBAR::BUTTONS::BUTTON::UPDATE";
3366 Action["BUTTON_GROUP_UPDATE"] = "APP::TITLEBAR::BUTTONS::BUTTONGROUP::UPDATE";
3367 Action["BREADCRUMBS_CLICK"] = "APP::TITLEBAR::BREADCRUMBS::BUTTON::CLICK";
3368 Action["BREADCRUMBS_UPDATE"] = "APP::TITLEBAR::BREADCRUMBS::BUTTON::UPDATE";
3369})(Action = exports.Action || (exports.Action = {}));
3370var TITLEBAR_BUTTON_PROPS = {
3371 group: types_1.Group.TitleBar,
3372 subgroups: ['Buttons'],
3373};
3374var BREADCRUMB_BUTTON_PROPS = {
3375 group: types_1.Group.TitleBar,
3376 subgroups: ['Breadcrumbs'],
3377 type: types_1.ComponentType.Button,
3378};
3379function clickActionButton(id, payload) {
3380 var type = types_1.ComponentType.Button;
3381 var component = __assign({ id: id, type: type }, TITLEBAR_BUTTON_PROPS);
3382 return Button_1.clickButton(types_1.Group.TitleBar, component, payload);
3383}
3384exports.clickActionButton = clickActionButton;
3385function clickBreadcrumb(id, payload) {
3386 var component = __assign({ id: id }, BREADCRUMB_BUTTON_PROPS);
3387 return Button_1.clickButton(types_1.Group.TitleBar, component, payload);
3388}
3389exports.clickBreadcrumb = clickBreadcrumb;
3390function update(payload) {
3391 return helper_1.actionWrapper({
3392 payload: payload,
3393 group: types_1.Group.TitleBar,
3394 type: Action.UPDATE,
3395 });
3396}
3397exports.update = update;
3398var TitleBar = /** @class */ (function (_super) {
3399 __extends(TitleBar, _super);
3400 function TitleBar(app, options) {
3401 var _this = _super.call(this, app, types_1.Group.TitleBar, types_1.Group.TitleBar) || this;
3402 // Trigger 'update' on creation
3403 _this.set(options);
3404 return _this;
3405 }
3406 Object.defineProperty(TitleBar.prototype, "buttons", {
3407 get: function () {
3408 if (!this.primary && !this.secondary) {
3409 return undefined;
3410 }
3411 return {
3412 primary: this.primary,
3413 secondary: this.secondary,
3414 };
3415 },
3416 enumerable: false,
3417 configurable: true
3418 });
3419 Object.defineProperty(TitleBar.prototype, "buttonsOptions", {
3420 get: function () {
3421 if (!this.primaryOptions && !this.secondaryOptions) {
3422 return undefined;
3423 }
3424 return {
3425 primary: this.primaryOptions,
3426 secondary: this.secondaryOptions,
3427 };
3428 },
3429 enumerable: false,
3430 configurable: true
3431 });
3432 Object.defineProperty(TitleBar.prototype, "options", {
3433 get: function () {
3434 return {
3435 breadcrumbs: this.breadcrumbsOption,
3436 buttons: this.buttonsOptions,
3437 title: this.title,
3438 };
3439 },
3440 enumerable: false,
3441 configurable: true
3442 });
3443 Object.defineProperty(TitleBar.prototype, "payload", {
3444 get: function () {
3445 return __assign(__assign({}, this.options), { breadcrumbs: this.breadcrumb, buttons: this.buttons, id: this.id });
3446 },
3447 enumerable: false,
3448 configurable: true
3449 });
3450 TitleBar.prototype.set = function (options, shouldUpdate) {
3451 if (shouldUpdate === void 0) { shouldUpdate = true; }
3452 var mergedOptions = helper_1.getMergedProps(this.options, options);
3453 var title = mergedOptions.title, buttons = mergedOptions.buttons, breadcrumbs = mergedOptions.breadcrumbs;
3454 this.title = title;
3455 this.setBreadcrumbs(breadcrumbs);
3456 this.setPrimaryButton(buttons ? buttons.primary : undefined);
3457 this.setSecondaryButton(buttons ? buttons.secondary : undefined);
3458 if (shouldUpdate) {
3459 this.dispatch(Action.UPDATE);
3460 }
3461 return this;
3462 };
3463 TitleBar.prototype.dispatch = function (action) {
3464 switch (action) {
3465 case Action.UPDATE:
3466 this.app.dispatch(update(this.payload));
3467 break;
3468 }
3469 return this;
3470 };
3471 TitleBar.prototype.getButton = function (button, subgroups, updateCb) {
3472 if (button instanceof ButtonGroup_1.ButtonGroup) {
3473 return buttonGroupHelper_1.getGroupedButton(this, button, subgroups, updateCb);
3474 }
3475 return buttonHelper_1.getSingleButton(this, button, subgroups, updateCb);
3476 };
3477 TitleBar.prototype.updatePrimaryButton = function (newPayload) {
3478 if (!this.primary) {
3479 return;
3480 }
3481 if (helper_1.updateActionFromPayload(this.primary, newPayload)) {
3482 this.dispatch(Action.UPDATE);
3483 }
3484 };
3485 TitleBar.prototype.updateSecondaryButtons = function (newPayload) {
3486 if (!this.secondary) {
3487 return;
3488 }
3489 var buttonToUpdate = this.secondary.find(function (action) { return action.id === newPayload.id; });
3490 if (!buttonToUpdate) {
3491 return;
3492 }
3493 var updated = false;
3494 if (ButtonGroup_1.isGroupedButtonPayload(newPayload)) {
3495 updated = helper_1.updateActionFromPayload(buttonToUpdate, newPayload);
3496 }
3497 else {
3498 updated = helper_1.updateActionFromPayload(buttonToUpdate, newPayload);
3499 }
3500 if (updated) {
3501 this.dispatch(Action.UPDATE);
3502 }
3503 };
3504 TitleBar.prototype.updateBreadcrumbButton = function (newPayload) {
3505 if (!this.breadcrumb) {
3506 return;
3507 }
3508 if (helper_1.updateActionFromPayload(this.breadcrumb, newPayload)) {
3509 this.dispatch(Action.UPDATE);
3510 }
3511 };
3512 TitleBar.prototype.setPrimaryButton = function (newOptions) {
3513 this.primaryOptions = this.getChildButton(newOptions, this.primaryOptions);
3514 this.primary = this.primaryOptions
3515 ? this.getButton(this.primaryOptions, TITLEBAR_BUTTON_PROPS.subgroups, this.updatePrimaryButton)
3516 : undefined;
3517 };
3518 TitleBar.prototype.setSecondaryButton = function (newOptions) {
3519 var _this = this;
3520 var newButtons = newOptions || [];
3521 var currentButtons = this.secondaryOptions || [];
3522 this.secondaryOptions = this.getUpdatedChildActions(newButtons, currentButtons);
3523 this.secondary = this.secondaryOptions
3524 ? this.secondaryOptions.map(function (action) {
3525 return _this.getButton(action, TITLEBAR_BUTTON_PROPS.subgroups, _this.updateSecondaryButtons);
3526 })
3527 : undefined;
3528 };
3529 TitleBar.prototype.setBreadcrumbs = function (breadcrumb) {
3530 this.breadcrumbsOption = this.getChildButton(breadcrumb, this.breadcrumbsOption);
3531 this.breadcrumb = this.breadcrumbsOption
3532 ? this.getButton(this.breadcrumbsOption, BREADCRUMB_BUTTON_PROPS.subgroups, this.updateBreadcrumbButton)
3533 : undefined;
3534 };
3535 TitleBar.prototype.getChildButton = function (newAction, currentAction) {
3536 var newButtons = newAction ? [newAction] : [];
3537 var currentButtons = currentAction ? [currentAction] : [];
3538 var updatedButton = this.getUpdatedChildActions(newButtons, currentButtons);
3539 return updatedButton ? updatedButton[0] : undefined;
3540 };
3541 return TitleBar;
3542}(helper_1.ActionSetWithChildren));
3543exports.TitleBar = TitleBar;
3544function create(app, options) {
3545 return new TitleBar(app, options);
3546}
3547exports.create = create;
3548
3549
3550/***/ }),
3551/* 30 */
3552/***/ (function(module, exports, __webpack_require__) {
3553
3554"use strict";
3555
3556var __extends = (this && this.__extends) || (function () {
3557 var extendStatics = function (d, b) {
3558 extendStatics = Object.setPrototypeOf ||
3559 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3560 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3561 return extendStatics(d, b);
3562 };
3563 return function (d, b) {
3564 extendStatics(d, b);
3565 function __() { this.constructor = d; }
3566 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3567 };
3568})();
3569var __assign = (this && this.__assign) || function () {
3570 __assign = Object.assign || function(t) {
3571 for (var s, i = 1, n = arguments.length; i < n; i++) {
3572 s = arguments[i];
3573 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3574 t[p] = s[p];
3575 }
3576 return t;
3577 };
3578 return __assign.apply(this, arguments);
3579};
3580Object.defineProperty(exports, "__esModule", { value: true });
3581exports.create = exports.ContextualSaveBar = exports.discard = exports.save = exports.hide = exports.show = exports.Action = void 0;
3582var helper_1 = __webpack_require__(0);
3583var types_1 = __webpack_require__(1);
3584/**
3585 * ContextualSaveBar action enum
3586 */
3587var Action;
3588(function (Action) {
3589 Action["DISCARD"] = "APP::CONTEXTUAL_SAVE_BAR::DISCARD";
3590 Action["SAVE"] = "APP::CONTEXTUAL_SAVE_BAR::SAVE";
3591 Action["SHOW"] = "APP::CONTEXTUAL_SAVE_BAR::SHOW";
3592 Action["HIDE"] = "APP::CONTEXTUAL_SAVE_BAR::HIDE";
3593 Action["UPDATE"] = "APP::CONTEXTUAL_SAVE_BAR::UPDATE";
3594})(Action = exports.Action || (exports.Action = {}));
3595function createContextBarAction(action, payload) {
3596 return helper_1.actionWrapper({
3597 group: types_1.Group.ContextualSaveBar,
3598 type: action,
3599 payload: payload,
3600 });
3601}
3602function show(payload) {
3603 return createContextBarAction(Action.SHOW, payload);
3604}
3605exports.show = show;
3606function hide(payload) {
3607 return createContextBarAction(Action.HIDE, payload);
3608}
3609exports.hide = hide;
3610function save(payload) {
3611 return createContextBarAction(Action.SAVE, payload);
3612}
3613exports.save = save;
3614function discard(payload) {
3615 return createContextBarAction(Action.DISCARD, payload);
3616}
3617exports.discard = discard;
3618/**
3619 * ContextualSaveBar action set
3620 */
3621var ContextualSaveBar = /** @class */ (function (_super) {
3622 __extends(ContextualSaveBar, _super);
3623 /**
3624 * Returns a new instance of a ContextualSaveBar action set
3625 * @param app the client application
3626 */
3627 function ContextualSaveBar(app, options) {
3628 if (options === void 0) { options = {}; }
3629 var _this = _super.call(this, app, types_1.Group.ContextualSaveBar, types_1.Group.ContextualSaveBar) || this;
3630 _this.options = options;
3631 _this.set(options, false);
3632 return _this;
3633 }
3634 Object.defineProperty(ContextualSaveBar.prototype, "payload", {
3635 /**
3636 * Returns the action set payload
3637 */
3638 get: function () {
3639 return __assign({ id: this.id }, this.options);
3640 },
3641 enumerable: false,
3642 configurable: true
3643 });
3644 ContextualSaveBar.prototype.set = function (options, shouldUpdate) {
3645 if (shouldUpdate === void 0) { shouldUpdate = true; }
3646 var mergedOptions = helper_1.getMergedProps(this.options, options);
3647 this.options = mergedOptions;
3648 if (shouldUpdate) {
3649 this.dispatch(Action.UPDATE);
3650 }
3651 return this;
3652 };
3653 /**
3654 * Dispatches a given action with the action set payload
3655 * @param action the action enum
3656 * @returns the action set instance
3657 */
3658 ContextualSaveBar.prototype.dispatch = function (action) {
3659 this.app.dispatch(createContextBarAction(action, this.payload));
3660 return this;
3661 };
3662 return ContextualSaveBar;
3663}(helper_1.ActionSet));
3664exports.ContextualSaveBar = ContextualSaveBar;
3665/**
3666 * Returns a new instance of a ContextualSaveBar action set
3667 * @param app the client application
3668 *
3669 */
3670function create(app, options) {
3671 return new ContextualSaveBar(app, options);
3672}
3673exports.create = create;
3674
3675
3676/***/ }),
3677/* 31 */
3678/***/ (function(module, exports, __webpack_require__) {
3679
3680"use strict";
3681
3682var __extends = (this && this.__extends) || (function () {
3683 var extendStatics = function (d, b) {
3684 extendStatics = Object.setPrototypeOf ||
3685 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3686 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3687 return extendStatics(d, b);
3688 };
3689 return function (d, b) {
3690 extendStatics(d, b);
3691 function __() { this.constructor = d; }
3692 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3693 };
3694})();
3695var __assign = (this && this.__assign) || function () {
3696 __assign = Object.assign || function(t) {
3697 for (var s, i = 1, n = arguments.length; i < n; i++) {
3698 s = arguments[i];
3699 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3700 t[p] = s[p];
3701 }
3702 return t;
3703 };
3704 return __assign.apply(this, arguments);
3705};
3706Object.defineProperty(exports, "__esModule", { value: true });
3707exports.create = exports.NavigationMenu = exports.update = exports.Action = void 0;
3708var AppLink_1 = __webpack_require__(10);
3709var helper_1 = __webpack_require__(0);
3710var types_1 = __webpack_require__(1);
3711var SUBGROUPS = ['Navigation_Menu'];
3712var Action;
3713(function (Action) {
3714 Action["UPDATE"] = "APP::MENU::NAVIGATION_MENU::UPDATE";
3715 Action["LINK_UPDATE"] = "APP::MENU::NAVIGATION_MENU::LINK::UPDATE";
3716})(Action = exports.Action || (exports.Action = {}));
3717function update(payload) {
3718 return helper_1.actionWrapper({
3719 payload: payload,
3720 group: types_1.Group.Menu,
3721 type: Action.UPDATE,
3722 });
3723}
3724exports.update = update;
3725var NavigationMenu = /** @class */ (function (_super) {
3726 __extends(NavigationMenu, _super);
3727 function NavigationMenu(app, options) {
3728 var _this = _super.call(this, app, 'Navigation_Menu', types_1.Group.Menu) || this;
3729 _this.items = [];
3730 // Trigger 'update' on creation
3731 _this.set(options);
3732 return _this;
3733 }
3734 Object.defineProperty(NavigationMenu.prototype, "options", {
3735 get: function () {
3736 return {
3737 items: this.itemsOptions,
3738 active: this.activeOptions,
3739 };
3740 },
3741 enumerable: false,
3742 configurable: true
3743 });
3744 Object.defineProperty(NavigationMenu.prototype, "payload", {
3745 get: function () {
3746 return __assign(__assign({}, this.options), { active: this.active, items: this.items, id: this.id });
3747 },
3748 enumerable: false,
3749 configurable: true
3750 });
3751 NavigationMenu.prototype.set = function (options, shouldUpdate) {
3752 if (shouldUpdate === void 0) { shouldUpdate = true; }
3753 var mergedOptions = helper_1.getMergedProps(this.options, options);
3754 var items = mergedOptions.items, active = mergedOptions.active;
3755 this.setItems(items);
3756 this.activeOptions = active;
3757 this.active = active && active.id;
3758 if (shouldUpdate) {
3759 this.dispatch(Action.UPDATE);
3760 }
3761 return this;
3762 };
3763 NavigationMenu.prototype.dispatch = function (action) {
3764 switch (action) {
3765 case Action.UPDATE:
3766 this.app.dispatch(update(this.payload));
3767 break;
3768 }
3769 return this;
3770 };
3771 NavigationMenu.prototype.updateItem = function (newPayload) {
3772 if (!this.items) {
3773 return;
3774 }
3775 var itemToUpdate = this.items.find(function (action) { return action.id === newPayload.id; });
3776 if (!itemToUpdate) {
3777 return;
3778 }
3779 if (helper_1.updateActionFromPayload(itemToUpdate, newPayload)) {
3780 this.dispatch(Action.UPDATE);
3781 }
3782 };
3783 NavigationMenu.prototype.setItems = function (newOptions) {
3784 var _this = this;
3785 var newItems = newOptions || [];
3786 var currentItems = this.itemsOptions || [];
3787 this.itemsOptions = this.getUpdatedChildActions(newItems, currentItems);
3788 this.items = this.itemsOptions
3789 ? this.itemsOptions.map(function (action) {
3790 _this.addChild(action, _this.group, SUBGROUPS);
3791 _this.subscribeToChild(action, AppLink_1.Action.UPDATE, _this.updateItem);
3792 return action.payload;
3793 })
3794 : [];
3795 };
3796 return NavigationMenu;
3797}(helper_1.ActionSetWithChildren));
3798exports.NavigationMenu = NavigationMenu;
3799function create(app, options) {
3800 return new NavigationMenu(app, options);
3801}
3802exports.create = create;
3803
3804
3805/***/ }),
3806/* 32 */
3807/***/ (function(module, exports, __webpack_require__) {
3808
3809"use strict";
3810
3811var __extends = (this && this.__extends) || (function () {
3812 var extendStatics = function (d, b) {
3813 extendStatics = Object.setPrototypeOf ||
3814 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3815 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
3816 return extendStatics(d, b);
3817 };
3818 return function (d, b) {
3819 extendStatics(d, b);
3820 function __() { this.constructor = d; }
3821 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3822 };
3823})();
3824var __assign = (this && this.__assign) || function () {
3825 __assign = Object.assign || function(t) {
3826 for (var s, i = 1, n = arguments.length; i < n; i++) {
3827 s = arguments[i];
3828 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3829 t[p] = s[p];
3830 }
3831 return t;
3832 };
3833 return __assign.apply(this, arguments);
3834};
3835Object.defineProperty(exports, "__esModule", { value: true });
3836exports.create = exports.ChannelMenu = exports.update = exports.Action = void 0;
3837var AppLink_1 = __webpack_require__(10);
3838var helper_1 = __webpack_require__(0);
3839var types_1 = __webpack_require__(1);
3840var SUBGROUPS = ['Channel_Menu'];
3841var Action;
3842(function (Action) {
3843 Action["UPDATE"] = "APP::MENU::CHANNEL_MENU::UPDATE";
3844 Action["LINK_UPDATE"] = "APP::MENU::CHANNEL_MENU::LINK::UPDATE";
3845})(Action = exports.Action || (exports.Action = {}));
3846function update(payload) {
3847 return helper_1.actionWrapper({
3848 payload: payload,
3849 group: types_1.Group.Menu,
3850 type: Action.UPDATE,
3851 });
3852}
3853exports.update = update;
3854var ChannelMenu = /** @class */ (function (_super) {
3855 __extends(ChannelMenu, _super);
3856 function ChannelMenu(app, options) {
3857 var _this = _super.call(this, app, 'Channel_Menu', types_1.Group.Menu) || this;
3858 _this.items = [];
3859 // Trigger 'update' on creation
3860 _this.set(options);
3861 return _this;
3862 }
3863 Object.defineProperty(ChannelMenu.prototype, "options", {
3864 get: function () {
3865 return {
3866 items: this.itemsOptions,
3867 active: this.activeOptions,
3868 };
3869 },
3870 enumerable: false,
3871 configurable: true
3872 });
3873 Object.defineProperty(ChannelMenu.prototype, "payload", {
3874 get: function () {
3875 return __assign(__assign({}, this.options), { active: this.active, items: this.items, id: this.id });
3876 },
3877 enumerable: false,
3878 configurable: true
3879 });
3880 ChannelMenu.prototype.set = function (options, shouldUpdate) {
3881 if (shouldUpdate === void 0) { shouldUpdate = true; }
3882 var mergedOptions = helper_1.getMergedProps(this.options, options);
3883 var items = mergedOptions.items, active = mergedOptions.active;
3884 this.setItems(items);
3885 this.activeOptions = active;
3886 this.active = active && active.id;
3887 if (shouldUpdate) {
3888 this.dispatch(Action.UPDATE);
3889 }
3890 return this;
3891 };
3892 ChannelMenu.prototype.dispatch = function (action) {
3893 switch (action) {
3894 case Action.UPDATE:
3895 this.app.dispatch(update(this.payload));
3896 break;
3897 }
3898 return this;
3899 };
3900 ChannelMenu.prototype.updateItem = function (newPayload) {
3901 if (!this.items) {
3902 return;
3903 }
3904 var itemToUpdate = this.items.find(function (action) { return action.id === newPayload.id; });
3905 if (!itemToUpdate) {
3906 return;
3907 }
3908 if (helper_1.updateActionFromPayload(itemToUpdate, newPayload)) {
3909 this.dispatch(Action.UPDATE);
3910 }
3911 };
3912 ChannelMenu.prototype.setItems = function (newOptions) {
3913 var _this = this;
3914 var newItems = newOptions || [];
3915 var currentItems = this.itemsOptions || [];
3916 this.itemsOptions = this.getUpdatedChildActions(newItems, currentItems);
3917 this.items = this.itemsOptions
3918 ? this.itemsOptions.map(function (action) {
3919 _this.addChild(action, _this.group, SUBGROUPS);
3920 _this.subscribeToChild(action, AppLink_1.Action.UPDATE, _this.updateItem);
3921 return action.payload;
3922 })
3923 : [];
3924 };
3925 return ChannelMenu;
3926}(helper_1.ActionSetWithChildren));
3927exports.ChannelMenu = ChannelMenu;
3928function create(app, options) {
3929 return new ChannelMenu(app, options);
3930}
3931exports.create = create;
3932
3933
3934/***/ }),
3935/* 33 */
3936/***/ (function(module, exports, __webpack_require__) {
3937
3938"use strict";
3939
3940Object.defineProperty(exports, "__esModule", { value: true });
3941exports.isAppMessage = exports.isPermitted = exports.getPermissionKey = exports.isFromApp = exports.isAppBridgeAction = void 0;
3942var types_1 = __webpack_require__(6);
3943var constants_1 = __webpack_require__(17);
3944var helper_1 = __webpack_require__(0);
3945/**
3946 * Predicate to determine if an action is an App Bridge action.
3947 * @public
3948 */
3949function isAppBridgeAction(action) {
3950 return (action instanceof Object &&
3951 action.hasOwnProperty('type') &&
3952 action.type.toString().startsWith(constants_1.PREFIX));
3953}
3954exports.isAppBridgeAction = isAppBridgeAction;
3955/**
3956 * Predicate to determine if an action originated from an application.
3957 * @internal
3958 */
3959function isFromApp(action) {
3960 if (typeof action !== 'object' || typeof action.source !== 'object') {
3961 return false;
3962 }
3963 return typeof action.source.apiKey === 'string';
3964}
3965exports.isFromApp = isFromApp;
3966/**
3967 * Returns the action type without the prefix and group
3968 * @internal
3969 */
3970function getPermissionKey(type) {
3971 return type.replace(new RegExp("^" + constants_1.PREFIX + constants_1.SEPARATOR + "\\w+" + constants_1.SEPARATOR), '');
3972}
3973exports.getPermissionKey = getPermissionKey;
3974/**
3975 * Predicate to determine if an action is permitted
3976 * @internal
3977 */
3978function isPermitted(features, _a, permissionType) {
3979 var group = _a.group, type = _a.type;
3980 if (!group || !features.hasOwnProperty(group)) {
3981 return false;
3982 }
3983 var feature = features[group];
3984 if (!feature) {
3985 return false;
3986 }
3987 var actionType = getPermissionKey(type);
3988 return feature[actionType] ? feature[actionType][permissionType] === true : false;
3989}
3990exports.isPermitted = isPermitted;
3991/**
3992 * Predicate to determine if an event originated from an application.
3993 * @internal
3994 */
3995function isAppMessage(event) {
3996 if (typeof event !== 'object' || !event.data || typeof event.data !== 'object') {
3997 return false;
3998 }
3999 var data = event.data;
4000 return data.hasOwnProperty('type') && helper_1.findMatchInEnum(types_1.MessageType, data.type) !== undefined;
4001}
4002exports.isAppMessage = isAppMessage;
4003
4004
4005/***/ }),
4006/* 34 */
4007/***/ (function(module, exports, __webpack_require__) {
4008
4009"use strict";
4010
4011var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4012 if (k2 === undefined) k2 = k;
4013 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4014}) : (function(o, m, k, k2) {
4015 if (k2 === undefined) k2 = k;
4016 o[k2] = m[k];
4017}));
4018var __exportStar = (this && this.__exportStar) || function(m, exports) {
4019 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
4020};
4021var __importDefault = (this && this.__importDefault) || function (mod) {
4022 return (mod && mod.__esModule) ? mod : { "default": mod };
4023};
4024Object.defineProperty(exports, "__esModule", { value: true });
4025exports.createApp = void 0;
4026var validate_1 = __importDefault(__webpack_require__(57));
4027var utils_1 = __webpack_require__(3);
4028var redirect_1 = __webpack_require__(16);
4029var client_1 = __webpack_require__(15);
4030var shared_1 = __webpack_require__(38);
4031/**
4032 * Creates your application instance with validator middleware.
4033 * @param config - `apiKey` and `host` are both required.
4034 * @remarks
4035 * Please note that `forceRedirect` only works in production environment (`shopname.myshopify.com/admin`).
4036 * You will need to store `host` during the authentication process and then retrieve it for the code to
4037 * work properly. To learn more about this process, see
4038 * {@link https://help.shopify.com/api/embedded-apps/shop-origin | Getting and storing the shop origin}.
4039 * @public
4040 */
4041function createApp(config) {
4042 var currentWindow = redirect_1.getWindow();
4043 if (!currentWindow) {
4044 return shared_1.serverAppBridge;
4045 }
4046 utils_1.mixedAppClientCheck(currentWindow);
4047 return client_1.createAppWrapper(currentWindow.top, currentWindow.location.origin, [validate_1.default])(config);
4048}
4049exports.createApp = createApp;
4050exports.default = createApp;
4051__exportStar(__webpack_require__(36), exports);
4052__exportStar(__webpack_require__(15), exports);
4053
4054
4055/***/ }),
4056/* 35 */
4057/***/ (function(module, exports, __webpack_require__) {
4058
4059"use strict";
4060
4061var __assign = (this && this.__assign) || function () {
4062 __assign = Object.assign || function(t) {
4063 for (var s, i = 1, n = arguments.length; i < n; i++) {
4064 s = arguments[i];
4065 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4066 t[p] = s[p];
4067 }
4068 return t;
4069 };
4070 return __assign.apply(this, arguments);
4071};
4072var __importDefault = (this && this.__importDefault) || function (mod) {
4073 return (mod && mod.__esModule) ? mod : { "default": mod };
4074};
4075Object.defineProperty(exports, "__esModule", { value: true });
4076exports.createApp = exports.createAppWrapper = exports.createClientApp = exports.WINDOW_UNDEFINED_MESSAGE = void 0;
4077var helper_1 = __webpack_require__(0);
4078var Print_1 = __webpack_require__(14);
4079var Error_1 = __webpack_require__(5);
4080var MessageTransport_1 = __webpack_require__(36);
4081var shared_1 = __webpack_require__(38);
4082var env_1 = __webpack_require__(37);
4083var Client_1 = __webpack_require__(19);
4084var print_1 = __webpack_require__(60);
4085var redirect_1 = __webpack_require__(16);
4086var types_1 = __webpack_require__(6);
4087var Hooks_1 = __importDefault(__webpack_require__(61));
4088exports.WINDOW_UNDEFINED_MESSAGE = 'window is not defined. Running an app outside a browser is not supported';
4089function redirectHandler(hostFrame, config) {
4090 var apiKey = config.apiKey, host = config.host, _a = config.forceRedirect, forceRedirect = _a === void 0 ? !env_1.isDevelopmentClient : _a;
4091 var location = redirect_1.getLocation();
4092 if (env_1.isFrameless ||
4093 !location ||
4094 !apiKey ||
4095 !host ||
4096 !forceRedirect ||
4097 !redirect_1.shouldRedirect(hostFrame)) {
4098 return;
4099 }
4100 var url = "https://" + host + "/apps/" + apiKey + location.pathname + (location.search || '');
4101 redirect_1.redirect(url);
4102}
4103function appSetUp(app) {
4104 app.subscribe(Print_1.Action.APP, print_1.handleAppPrint);
4105 app.dispatch(Client_1.initialize());
4106}
4107/**
4108 * @internal
4109 */
4110exports.createClientApp = function (transport, middlewares) {
4111 if (middlewares === void 0) { middlewares = []; }
4112 var getStateListeners = [];
4113 var transportListener = MessageTransport_1.createTransportListener();
4114 var handler = function (event) {
4115 var message = event.data;
4116 var type = message.type, payload = message.payload;
4117 switch (type) {
4118 case 'getState':
4119 var resolvers = getStateListeners.splice(0);
4120 resolvers.forEach(function (resolver) { return resolver(payload); });
4121 break;
4122 case 'dispatch':
4123 transportListener.handleMessage(payload);
4124 var hasCallback = transportListener.handleActionDispatch(payload);
4125 if (hasCallback) {
4126 return;
4127 }
4128 // Throw an error if there are no subscriptions to this error
4129 var errorType = helper_1.findMatchInEnum(Error_1.Action, payload.type);
4130 if (errorType) {
4131 Error_1.throwError(errorType, payload);
4132 }
4133 break;
4134 default:
4135 // Silently swallow unknown actions
4136 }
4137 };
4138 transport.subscribe(handler);
4139 return function (config) {
4140 if (!config.host) {
4141 throw Error_1.fromAction('host must be provided', Error_1.AppActionType.INVALID_CONFIG);
4142 }
4143 if (!config.apiKey) {
4144 throw Error_1.fromAction('apiKey must be provided', Error_1.AppActionType.INVALID_CONFIG);
4145 }
4146 var decodedConfig;
4147 try {
4148 decodedConfig = decodeConfig(config);
4149 }
4150 catch (_a) {
4151 var message = "not a valid host, please use the value provided by Shopify";
4152 throw Error_1.fromAction(message, Error_1.AppActionType.INVALID_CONFIG);
4153 }
4154 var dispatcher = createDispatcher(transport, decodedConfig);
4155 var subscribe = transportListener.createSubscribeHandler(dispatcher);
4156 // It is possible to initialize an app multiple times
4157 // Therefore we need to clear subscriptions to be safe
4158 dispatcher(types_1.MessageType.Unsubscribe);
4159 function dispatch(action) {
4160 dispatcher(types_1.MessageType.Dispatch, action);
4161 return action;
4162 }
4163 redirectHandler(transport.hostFrame, decodedConfig);
4164 var hooks = new Hooks_1.default();
4165 var app = {
4166 localOrigin: transport.localOrigin,
4167 hooks: hooks,
4168 dispatch: function (action) {
4169 if (!app.hooks) {
4170 return dispatch(action);
4171 }
4172 return app.hooks.run(types_1.LifecycleHook.DispatchAction, dispatch, app, action);
4173 },
4174 featuresAvailable: function (features) {
4175 return app.getState('features').then(function (state) {
4176 if (features) {
4177 Object.keys(state).forEach(function (feature) {
4178 if (!features.includes(feature)) {
4179 delete state[feature];
4180 }
4181 });
4182 }
4183 return state;
4184 });
4185 },
4186 getState: function (query) {
4187 return new Promise(function (resolve) {
4188 getStateListeners.push(resolve);
4189 dispatcher(types_1.MessageType.GetState);
4190 }).then(function (state) {
4191 if (query) {
4192 return query.split('.').reduce(function (value, key) {
4193 if (typeof state !== 'object' || Array.isArray(state)) {
4194 return undefined;
4195 }
4196 value = state[key];
4197 state = value;
4198 return value;
4199 }, undefined);
4200 }
4201 return state;
4202 });
4203 },
4204 subscribe: subscribe,
4205 error: function (listener, id) {
4206 var unsubscribeCb = [];
4207 helper_1.forEachInEnum(Error_1.Action, function (eventNameSpace) {
4208 unsubscribeCb.push(subscribe(eventNameSpace, listener, id));
4209 });
4210 return function () {
4211 unsubscribeCb.forEach(function (unsubscribe) { return unsubscribe(); });
4212 };
4213 },
4214 };
4215 for (var _i = 0, middlewares_1 = middlewares; _i < middlewares_1.length; _i++) {
4216 var middleware = middlewares_1[_i];
4217 middleware(hooks, app);
4218 }
4219 appSetUp(app);
4220 return app;
4221 };
4222};
4223/**
4224 * @internal
4225 */
4226function decodeConfig(config) {
4227 var _a;
4228 return __assign(__assign({}, config), { host: atob((_a = config.host) === null || _a === void 0 ? void 0 : _a.replace(/_/g, '/').replace(/-/g, '+')) });
4229}
4230/**
4231 * @public
4232 */
4233function createAppWrapper(frame, localOrigin, middleware) {
4234 if (middleware === void 0) { middleware = []; }
4235 if (!frame) {
4236 throw Error_1.fromAction(exports.WINDOW_UNDEFINED_MESSAGE, Error_1.AppActionType.WINDOW_UNDEFINED);
4237 }
4238 var location = redirect_1.getLocation();
4239 var origin = localOrigin || (location && location.origin);
4240 if (!origin) {
4241 throw Error_1.fromAction('local origin cannot be blank', Error_1.AppActionType.MISSING_LOCAL_ORIGIN);
4242 }
4243 var transport = MessageTransport_1.fromWindow(frame, origin);
4244 var appCreator = exports.createClientApp(transport, middleware);
4245 return appCreator;
4246}
4247exports.createAppWrapper = createAppWrapper;
4248/**
4249 * Creates your application instance.
4250 * @param config - `apiKey` and `host` are both required.
4251 * @remarks
4252 * You will need to store `host` during the authentication process and then retrieve it for the code to work properly. To learn more about this process, see {@link https://help.shopify.com/api/embedded-apps/shop-origin | Getting and storing the shop origin}.
4253 * @public
4254 */
4255function createApp(config) {
4256 var currentWindow = redirect_1.getWindow();
4257 if (!currentWindow) {
4258 return shared_1.serverAppBridge;
4259 }
4260 return createAppWrapper(currentWindow.top)(config);
4261}
4262exports.createApp = createApp;
4263function createDispatcher(transport, config) {
4264 return function (type, payload) {
4265 transport.dispatch({
4266 payload: payload,
4267 source: config,
4268 type: type,
4269 });
4270 };
4271}
4272/**
4273 * {@inheritdocs createApp}
4274 * @public
4275 */
4276exports.default = createApp;
4277
4278
4279/***/ }),
4280/* 36 */
4281/***/ (function(module, exports, __webpack_require__) {
4282
4283"use strict";
4284
4285Object.defineProperty(exports, "__esModule", { value: true });
4286exports.createTransportListener = exports.fromWindow = exports.fromFrame = exports.Context = void 0;
4287var Error_1 = __webpack_require__(5);
4288var validator_1 = __webpack_require__(33);
4289var types_1 = __webpack_require__(6);
4290var collection_1 = __webpack_require__(12);
4291var env_1 = __webpack_require__(37);
4292var Context;
4293(function (Context) {
4294 Context["Modal"] = "Modal";
4295 Context["Main"] = "Main";
4296})(Context = exports.Context || (exports.Context = {}));
4297/**
4298 * Create a MessageTransport from an IFrame.
4299 * @remarks
4300 * Used on the host-side to create a postMessage MessageTransport.
4301 * @beta
4302 */
4303function fromFrame(frame, localOrigin, context) {
4304 var handlers = [];
4305 if (typeof frame === 'undefined' || !frame.ownerDocument || !frame.ownerDocument.defaultView) {
4306 throw Error_1.fromAction('App frame is undefined', Error_1.AppActionType.WINDOW_UNDEFINED);
4307 }
4308 var parent = frame.ownerDocument.defaultView;
4309 parent.addEventListener('message', function (event) {
4310 if (!validator_1.isAppMessage(event)) {
4311 return;
4312 }
4313 if (event.origin !== localOrigin) {
4314 var contentWindow = frame.contentWindow;
4315 if (contentWindow) {
4316 var errorMessage = "Message origin '" + event.origin + "' does not match app origin '" + localOrigin + "'.";
4317 var payload = Error_1.invalidOriginAction(errorMessage);
4318 var message = {
4319 type: 'dispatch',
4320 payload: payload,
4321 };
4322 contentWindow.postMessage(message, event.origin);
4323 }
4324 return;
4325 }
4326 for (var _i = 0, handlers_1 = handlers; _i < handlers_1.length; _i++) {
4327 var handler = handlers_1[_i];
4328 handler(event);
4329 }
4330 });
4331 return {
4332 context: context,
4333 localOrigin: localOrigin,
4334 frameWindow: frame.contentWindow,
4335 hostFrame: parent,
4336 dispatch: function (message) {
4337 var contentWindow = frame.contentWindow;
4338 if (contentWindow) {
4339 contentWindow.postMessage(message, localOrigin);
4340 }
4341 },
4342 subscribe: function (handler) {
4343 return collection_1.addAndRemoveFromCollection(handlers, handler);
4344 },
4345 };
4346}
4347exports.fromFrame = fromFrame;
4348/**
4349 * Create a MessageTransport from a parent window.
4350 * @remarks
4351 * Used on the client-side to create a postMessage MessageTransport.
4352 * @internalremarks
4353 * In frameless mode, message should be dispatched via SmartWebView.handleMessage instead of postMessage.
4354 * @beta
4355 */
4356function fromWindow(contentWindow, localOrigin) {
4357 var handlers = [];
4358 if (typeof window !== undefined) {
4359 window.addEventListener('message', function (event) {
4360 if ((window === contentWindow && !env_1.isFrameless) ||
4361 event.source !== contentWindow ||
4362 !(validator_1.isAppBridgeAction(event.data.payload) || validator_1.isAppMessage(event))) {
4363 return;
4364 }
4365 for (var _i = 0, handlers_2 = handlers; _i < handlers_2.length; _i++) {
4366 var handler = handlers_2[_i];
4367 handler(event);
4368 }
4369 });
4370 }
4371 return {
4372 localOrigin: localOrigin,
4373 hostFrame: contentWindow,
4374 dispatch: function (message) {
4375 var _a;
4376 if (!((_a = message.source) === null || _a === void 0 ? void 0 : _a.host)) {
4377 return;
4378 }
4379 if (env_1.isFrameless && window && window.SmartWebView) {
4380 window.SmartWebView.handleMessage('frameless://fromClient', JSON.stringify(message));
4381 return;
4382 }
4383 var messageOrigin = new URL("https://" + message.source.host).origin;
4384 contentWindow.postMessage(message, messageOrigin);
4385 },
4386 subscribe: function (handler) {
4387 return collection_1.addAndRemoveFromCollection(handlers, handler);
4388 },
4389 };
4390}
4391exports.fromWindow = fromWindow;
4392function createTransportListener() {
4393 var listeners = [];
4394 var actionListeners = {};
4395 function createSubscribeHandler(dispatcher) {
4396 function subscribe() {
4397 if (arguments.length < 2) {
4398 // eslint-disable-next-line prefer-rest-params
4399 return collection_1.addAndRemoveFromCollection(listeners, { callback: arguments[0] });
4400 }
4401 // eslint-disable-next-line prefer-rest-params
4402 var _a = Array.from(arguments), type = _a[0], callback = _a[1], id = _a[2];
4403 var actionCallback = { callback: callback, id: id };
4404 var payload = { type: type, id: id };
4405 if (!Object.prototype.hasOwnProperty.call(actionListeners, type)) {
4406 actionListeners[type] = [];
4407 }
4408 if (dispatcher) {
4409 dispatcher(types_1.MessageType.Subscribe, payload);
4410 }
4411 return collection_1.addAndRemoveFromCollection(actionListeners[type], actionCallback, function () {
4412 if (dispatcher) {
4413 dispatcher(types_1.MessageType.Unsubscribe, payload);
4414 }
4415 });
4416 }
4417 return subscribe;
4418 }
4419 return {
4420 createSubscribeHandler: createSubscribeHandler,
4421 handleMessage: function (message) {
4422 listeners.forEach(function (listener) { return listener.callback(message); });
4423 },
4424 handleActionDispatch: function (_a) {
4425 var type = _a.type, payload = _a.payload;
4426 var hasCallback = false;
4427 if (Object.prototype.hasOwnProperty.call(actionListeners, type)) {
4428 for (var _i = 0, _b = actionListeners[type]; _i < _b.length; _i++) {
4429 var listener = _b[_i];
4430 var id = listener.id, callback = listener.callback;
4431 var matchId = payload && payload.id === id;
4432 if (matchId || !id) {
4433 callback(payload);
4434 hasCallback = true;
4435 }
4436 }
4437 }
4438 return hasCallback;
4439 },
4440 };
4441}
4442exports.createTransportListener = createTransportListener;
4443
4444
4445/***/ }),
4446/* 37 */
4447/***/ (function(module, exports, __webpack_require__) {
4448
4449"use strict";
4450/* WEBPACK VAR INJECTION */(function(process) {
4451var _a, _b;
4452Object.defineProperty(exports, "__esModule", { value: true });
4453exports.isFrameless = exports.isDevelopmentClient = exports.isProduction = exports.isDevelopment = exports.isClient = exports.isServer = void 0;
4454exports.isServer = typeof window === 'undefined';
4455exports.isClient = !exports.isServer;
4456exports.isDevelopment = typeof process !== 'undefined' && process.env && "production" === 'development';
4457exports.isProduction = !exports.isDevelopment;
4458exports.isDevelopmentClient = exports.isDevelopment && exports.isClient;
4459exports.isFrameless = exports.isClient && ((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.indexOf(' Frameless ')) > 0;
4460
4461/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(59)))
4462
4463/***/ }),
4464/* 38 */
4465/***/ (function(module, exports, __webpack_require__) {
4466
4467"use strict";
4468
4469Object.defineProperty(exports, "__esModule", { value: true });
4470exports.serverAppBridge = void 0;
4471var Error_1 = __webpack_require__(5);
4472var noop = function () { };
4473/**
4474 * @internal
4475 */
4476exports.serverAppBridge = {
4477 dispatch: function () {
4478 return {};
4479 },
4480 error: function () {
4481 return noop;
4482 },
4483 featuresAvailable: function () {
4484 return Promise.reject(Error_1.fromAction('Feature detection is only available on the client side.', Error_1.AppActionType.WINDOW_UNDEFINED));
4485 },
4486 getState: function () {
4487 return Promise.reject(Error_1.fromAction('State is only available on the client side.', Error_1.AppActionType.WINDOW_UNDEFINED));
4488 },
4489 localOrigin: '',
4490 subscribe: function () {
4491 return noop;
4492 },
4493};
4494
4495
4496/***/ }),
4497/* 39 */
4498/***/ (function(module, exports, __webpack_require__) {
4499
4500"use strict";
4501
4502Object.defineProperty(exports, "__esModule", { value: true });
4503exports.Action = exports.validateAction = exports.validateProps = exports.buttonGroupSchema = void 0;
4504var ButtonGroup_1 = __webpack_require__(7);
4505Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return ButtonGroup_1.Action; } });
4506var type_validate_1 = __webpack_require__(2);
4507var utils_1 = __webpack_require__(3);
4508var button_1 = __webpack_require__(11);
4509exports.buttonGroupSchema = type_validate_1.composeSchemas(button_1.buttonSchema, type_validate_1.matchesObject({
4510 buttons: type_validate_1.matchesArray(type_validate_1.makeOptional(button_1.buttonSchemaWithId)),
4511}));
4512function validateProps(props) {
4513 return type_validate_1.validate(props, exports.buttonGroupSchema);
4514}
4515exports.validateProps = validateProps;
4516function validateAction(action) {
4517 var validator = utils_1.createActionValidator(ButtonGroup_1.Action, exports.buttonGroupSchema, true, true);
4518 return type_validate_1.validate(action, validator);
4519}
4520exports.validateAction = validateAction;
4521
4522
4523/***/ }),
4524/* 40 */
4525/***/ (function(module, exports, __webpack_require__) {
4526
4527"use strict";
4528
4529Object.defineProperty(exports, "__esModule", { value: true });
4530exports.Action = exports.validateAction = exports.validateProps = exports.linkActionSchema = exports.linkPropsSchema = void 0;
4531var type_validate_1 = __webpack_require__(2);
4532var utils_1 = __webpack_require__(3);
4533var AppLink_1 = __webpack_require__(10);
4534Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return AppLink_1.Action; } });
4535var allowedRedirectTypes;
4536(function (allowedRedirectTypes) {
4537 allowedRedirectTypes["APP"] = "APP::NAVIGATION::REDIRECT::APP";
4538 allowedRedirectTypes["LEGACY_APP"] = "APP";
4539})(allowedRedirectTypes || (allowedRedirectTypes = {}));
4540exports.linkPropsSchema = type_validate_1.matchesObject({
4541 label: type_validate_1.matchesString(),
4542 destination: utils_1.relativeUrlSchema,
4543 redirectType: type_validate_1.matchesEnum(allowedRedirectTypes),
4544});
4545exports.linkActionSchema = type_validate_1.matchesObject({
4546 label: type_validate_1.matchesString(),
4547 destination: utils_1.relativePathSchema,
4548 redirectType: type_validate_1.matchesEnum(allowedRedirectTypes),
4549});
4550function validateProps(props) {
4551 return type_validate_1.validate(props, exports.linkPropsSchema);
4552}
4553exports.validateProps = validateProps;
4554function validateAction(action) {
4555 return type_validate_1.validate(action, utils_1.createActionValidator(AppLink_1.Action, exports.linkActionSchema, true, true));
4556}
4557exports.validateAction = validateAction;
4558
4559
4560/***/ }),
4561/* 41 */
4562/***/ (function(module, exports, __webpack_require__) {
4563
4564"use strict";
4565
4566var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4567 if (k2 === undefined) k2 = k;
4568 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4569}) : (function(o, m, k, k2) {
4570 if (k2 === undefined) k2 = k;
4571 o[k2] = m[k];
4572}));
4573var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
4574 Object.defineProperty(o, "default", { enumerable: true, value: v });
4575}) : function(o, v) {
4576 o["default"] = v;
4577});
4578var __importStar = (this && this.__importStar) || function (mod) {
4579 if (mod && mod.__esModule) return mod;
4580 var result = {};
4581 if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4582 __setModuleDefault(result, mod);
4583 return result;
4584};
4585var __exportStar = (this && this.__exportStar) || function(m, exports) {
4586 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
4587};
4588Object.defineProperty(exports, "__esModule", { value: true });
4589exports.actions = void 0;
4590var actions = __importStar(__webpack_require__(42));
4591exports.actions = actions;
4592__exportStar(__webpack_require__(34), exports);
4593var development_1 = __webpack_require__(34);
4594Object.defineProperty(exports, "default", { enumerable: true, get: function () { return development_1.createApp; } });
4595
4596
4597/***/ }),
4598/* 42 */
4599/***/ (function(module, exports, __webpack_require__) {
4600
4601"use strict";
4602
4603var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4604 if (k2 === undefined) k2 = k;
4605 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4606}) : (function(o, m, k, k2) {
4607 if (k2 === undefined) k2 = k;
4608 o[k2] = m[k];
4609}));
4610var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
4611 Object.defineProperty(o, "default", { enumerable: true, value: v });
4612}) : function(o, v) {
4613 o["default"] = v;
4614});
4615var __importStar = (this && this.__importStar) || function (mod) {
4616 if (mod && mod.__esModule) return mod;
4617 var result = {};
4618 if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4619 __setModuleDefault(result, mod);
4620 return result;
4621};
4622var __exportStar = (this && this.__exportStar) || function(m, exports) {
4623 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
4624};
4625Object.defineProperty(exports, "__esModule", { value: true });
4626exports.Performance = exports.Pos = exports.AppLink = exports.ChannelMenu = exports.NavigationMenu = exports.Share = exports.ContextualSaveBar = exports.MarketingExternalActivityTopBar = exports.TitleBar = exports.SessionToken = exports.ResourcePicker = exports.Redirect = exports.Print = exports.Modal = exports.Loading = exports.LeaveConfirmation = exports.History = exports.Toast = exports.Fullscreen = exports.FeedbackModal = exports.Features = exports.Flash = exports.Error = exports.Client = exports.Cart = exports.Scanner = exports.ButtonGroup = exports.Button = exports.AuthCode = void 0;
4627var AuthCode = __importStar(__webpack_require__(43));
4628exports.AuthCode = AuthCode;
4629var Button = __importStar(__webpack_require__(4));
4630exports.Button = Button;
4631var ButtonGroup = __importStar(__webpack_require__(7));
4632exports.ButtonGroup = ButtonGroup;
4633var Cart = __importStar(__webpack_require__(18));
4634exports.Cart = Cart;
4635var Client = __importStar(__webpack_require__(19));
4636exports.Client = Client;
4637var Error = __importStar(__webpack_require__(5));
4638exports.Error = Error;
4639var Flash = __importStar(__webpack_require__(47));
4640exports.Flash = Flash;
4641var Features = __importStar(__webpack_require__(49));
4642exports.Features = Features;
4643var FeedbackModal = __importStar(__webpack_require__(21));
4644exports.FeedbackModal = FeedbackModal;
4645var Fullscreen = __importStar(__webpack_require__(22));
4646exports.Fullscreen = Fullscreen;
4647var LeaveConfirmation = __importStar(__webpack_require__(23));
4648exports.LeaveConfirmation = LeaveConfirmation;
4649var Loading = __importStar(__webpack_require__(24));
4650exports.Loading = Loading;
4651var Modal = __importStar(__webpack_require__(25));
4652exports.Modal = Modal;
4653var History = __importStar(__webpack_require__(26));
4654exports.History = History;
4655var Redirect = __importStar(__webpack_require__(13));
4656exports.Redirect = Redirect;
4657var Print = __importStar(__webpack_require__(14));
4658exports.Print = Print;
4659var ResourcePicker = __importStar(__webpack_require__(27));
4660exports.ResourcePicker = ResourcePicker;
4661var Scanner = __importStar(__webpack_require__(28));
4662exports.Scanner = Scanner;
4663var SessionToken = __importStar(__webpack_require__(51));
4664exports.SessionToken = SessionToken;
4665var TitleBar = __importStar(__webpack_require__(29));
4666exports.TitleBar = TitleBar;
4667var Toast = __importStar(__webpack_require__(9));
4668exports.Toast = Toast;
4669var ContextualSaveBar = __importStar(__webpack_require__(30));
4670exports.ContextualSaveBar = ContextualSaveBar;
4671var Share = __importStar(__webpack_require__(53));
4672exports.Share = Share;
4673var NavigationMenu = __importStar(__webpack_require__(31));
4674exports.NavigationMenu = NavigationMenu;
4675var ChannelMenu = __importStar(__webpack_require__(32));
4676exports.ChannelMenu = ChannelMenu;
4677var AppLink = __importStar(__webpack_require__(10));
4678exports.AppLink = AppLink;
4679var Pos = __importStar(__webpack_require__(54));
4680exports.Pos = Pos;
4681var MarketingExternalActivityTopBar = __importStar(__webpack_require__(55));
4682exports.MarketingExternalActivityTopBar = MarketingExternalActivityTopBar;
4683var Performance = __importStar(__webpack_require__(56));
4684exports.Performance = Performance;
4685var validator_1 = __webpack_require__(33);
4686Object.defineProperty(exports, "isAppBridgeAction", { enumerable: true, get: function () { return validator_1.isAppBridgeAction; } });
4687__exportStar(__webpack_require__(1), exports);
4688
4689
4690/***/ }),
4691/* 43 */
4692/***/ (function(module, exports, __webpack_require__) {
4693
4694"use strict";
4695
4696Object.defineProperty(exports, "__esModule", { value: true });
4697exports.respond = exports.request = exports.Action = void 0;
4698var helper_1 = __webpack_require__(0);
4699var types_1 = __webpack_require__(1);
4700var Action;
4701(function (Action) {
4702 Action["REQUEST"] = "APP::AUTH_CODE::REQUEST";
4703 Action["RESPOND"] = "APP::AUTH_CODE::RESPOND";
4704})(Action = exports.Action || (exports.Action = {}));
4705function request(id) {
4706 return helper_1.actionWrapper({
4707 group: types_1.Group.AuthCode,
4708 type: Action.REQUEST,
4709 payload: { id: id },
4710 });
4711}
4712exports.request = request;
4713function respond(payload) {
4714 return helper_1.actionWrapper({
4715 payload: payload,
4716 group: types_1.Group.AuthCode,
4717 type: Action.RESPOND,
4718 });
4719}
4720exports.respond = respond;
4721
4722
4723/***/ }),
4724/* 44 */
4725/***/ (function(module, exports, __webpack_require__) {
4726
4727"use strict";
4728
4729Object.defineProperty(exports, "__esModule", { value: true });
4730/**
4731 * Returns a deeply merged object with properties from the 2 provided objects
4732 * @remarks - Only deeply merge objects. The second argument overrides the
4733 * first if it is provided as `null`, `undefined` or an array.
4734 * @public
4735 * */
4736function mergeProps(obj, newObj) {
4737 if (newObj == null) {
4738 return newObj;
4739 }
4740 // If setting to a different prototype or a non-object or non-array, don't merge any props
4741 if (typeof obj === 'undefined' ||
4742 !Object.getPrototypeOf(obj).isPrototypeOf(newObj) ||
4743 (newObj.constructor.name !== 'Object' && newObj.constructor.name !== 'Array')) {
4744 return newObj;
4745 }
4746 var clone = {};
4747 Object.keys(newObj).forEach(function (key) {
4748 var exists = obj.hasOwnProperty(key);
4749 if (!exists) {
4750 clone[key] = newObj[key];
4751 }
4752 else if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
4753 clone[key] = mergeProps(obj[key], newObj[key]);
4754 }
4755 else {
4756 clone[key] = newObj[key];
4757 }
4758 });
4759 // Copy old props that are not present in new object only if this is a simple object
4760 Object.keys(obj).forEach(function (key) {
4761 var exists = newObj.hasOwnProperty(key);
4762 if (!exists) {
4763 clone[key] = obj[key];
4764 }
4765 });
4766 // Set prototype of cloned object to match original
4767 Object.setPrototypeOf(clone, Object.getPrototypeOf(obj));
4768 return clone;
4769}
4770exports.default = mergeProps;
4771
4772
4773/***/ }),
4774/* 45 */
4775/***/ (function(module, exports, __webpack_require__) {
4776
4777"use strict";
4778
4779Object.defineProperty(exports, "__esModule", { value: true });
4780exports.generateUuid = void 0;
4781/**
4782 * Convert a number or array of integers to a string of padded hex octets.
4783 */
4784function asHex(value) {
4785 return Array.from(value)
4786 .map(function (i) { return ("00" + i.toString(16)).slice(-2); })
4787 .join('');
4788}
4789/**
4790 * Attempt to securely generate random bytes/
4791 */
4792function getRandomBytes(size) {
4793 // SPRNG
4794 if (typeof Uint8Array === 'function' && typeof window === 'object' && window.crypto) {
4795 var buffer = new Uint8Array(size);
4796 var randomValues = window.crypto.getRandomValues(buffer);
4797 if (randomValues) {
4798 return randomValues;
4799 }
4800 }
4801 // Insecure random
4802 return Array.from(new Array(size), function () { return (Math.random() * 255) | 0; });
4803}
4804/**
4805 * Generate a RFC4122-compliant v4 UUID.
4806 *
4807 * @see http://www.ietf.org/rfc/rfc4122.txt
4808 */
4809function generateUuid() {
4810 var version = 64;
4811 var clockSeqHiAndReserved = getRandomBytes(1);
4812 var timeHiAndVersion = getRandomBytes(2);
4813 clockSeqHiAndReserved[0] &= 63 | 128;
4814 // tslint:disable-next-line:binary-expression-operand-order
4815 timeHiAndVersion[0] &= 15 | version;
4816 return [
4817 asHex(getRandomBytes(4)),
4818 '-',
4819 asHex(getRandomBytes(2)),
4820 '-',
4821 asHex(timeHiAndVersion),
4822 '-',
4823 asHex(clockSeqHiAndReserved),
4824 asHex(getRandomBytes(1)),
4825 '-',
4826 asHex(getRandomBytes(6)),
4827 ].join('');
4828}
4829exports.generateUuid = generateUuid;
4830// Default
4831exports.default = generateUuid;
4832
4833
4834/***/ }),
4835/* 46 */
4836/***/ (function(module) {
4837
4838module.exports = JSON.parse("{\"name\":\"@shopify/app-bridge\",\"version\":\"2.0.0\",\"types\":\"index.d.ts\",\"main\":\"index.js\",\"unpkg\":\"umd/index.js\",\"jsdelivr\":\"umd/index.js\",\"files\":[\"/actions/\",\"/client/\",\"/umd/\",\"/util/\",\"/validate/\",\"/development.d.ts\",\"/development.js\",\"/index.d.ts\",\"/index.js\",\"/MessageTransport.d.ts\",\"/MessageTransport.js\",\"/production.d.ts\",\"/production.js\"],\"private\":false,\"publishConfig\":{\"access\":\"public\",\"@shopify:registry\":\"https://registry.npmjs.org\"},\"repository\":\"git@github.com:Shopify/app-bridge.git\",\"homepage\":\"https://shopify.dev/tools/app-bridge\",\"author\":\"Shopify Inc.\",\"license\":\"MIT\",\"scripts\":{\"build\":\"yarn build:tsc && yarn build:npm && yarn build:umd\",\"build:tsc\":\"NODE_ENV=production tsc\",\"build:umd\":\"NODE_ENV=production webpack -p\",\"build:npm\":\"shx cp -r ./npm/index.js ./index.js\",\"check\":\"tsc\",\"clean\":\"cat package.json | node -pe \\\"JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).files.map(f => './'+f).join(' ')\\\" | xargs rm -rf\",\"pack\":\"yarn pack\",\"size\":\"size-limit\"},\"sideEffects\":false,\"size-limit\":[{\"limit\":\"17 KB\",\"path\":\"production.js\"}],\"devDependencies\":{\"@types/node\":\"^10.12.5\",\"shx\":\"^0.3.3\"}}");
4839
4840/***/ }),
4841/* 47 */
4842/***/ (function(module, exports, __webpack_require__) {
4843
4844"use strict";
4845
4846var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4847 if (k2 === undefined) k2 = k;
4848 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4849}) : (function(o, m, k, k2) {
4850 if (k2 === undefined) k2 = k;
4851 o[k2] = m[k];
4852}));
4853var __exportStar = (this && this.__exportStar) || function(m, exports) {
4854 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
4855};
4856Object.defineProperty(exports, "__esModule", { value: true });
4857__exportStar(__webpack_require__(48), exports);
4858
4859
4860/***/ }),
4861/* 48 */
4862/***/ (function(module, exports, __webpack_require__) {
4863
4864"use strict";
4865
4866var __extends = (this && this.__extends) || (function () {
4867 var extendStatics = function (d, b) {
4868 extendStatics = Object.setPrototypeOf ||
4869 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4870 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4871 return extendStatics(d, b);
4872 };
4873 return function (d, b) {
4874 extendStatics(d, b);
4875 function __() { this.constructor = d; }
4876 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4877 };
4878})();
4879Object.defineProperty(exports, "__esModule", { value: true });
4880exports.create = exports.Flash = void 0;
4881var Toast_1 = __webpack_require__(9);
4882var Toast_2 = __webpack_require__(9);
4883Object.defineProperty(exports, "ActionBase", { enumerable: true, get: function () { return Toast_2.ActionBase; } });
4884Object.defineProperty(exports, "clear", { enumerable: true, get: function () { return Toast_2.clear; } });
4885Object.defineProperty(exports, "ClearAction", { enumerable: true, get: function () { return Toast_2.ClearAction; } });
4886Object.defineProperty(exports, "show", { enumerable: true, get: function () { return Toast_2.show; } });
4887Object.defineProperty(exports, "ShowAction", { enumerable: true, get: function () { return Toast_2.ShowAction; } });
4888Object.defineProperty(exports, "FlashAction", { enumerable: true, get: function () { return Toast_2.ToastAction; } });
4889var Flash = /** @class */ (function (_super) {
4890 __extends(Flash, _super);
4891 function Flash() {
4892 return _super !== null && _super.apply(this, arguments) || this;
4893 }
4894 return Flash;
4895}(Toast_1.Toast));
4896exports.Flash = Flash;
4897function create(app, options) {
4898 return new Flash(app, options);
4899}
4900exports.create = create;
4901
4902
4903/***/ }),
4904/* 49 */
4905/***/ (function(module, exports, __webpack_require__) {
4906
4907"use strict";
4908
4909var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4910 if (k2 === undefined) k2 = k;
4911 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4912}) : (function(o, m, k, k2) {
4913 if (k2 === undefined) k2 = k;
4914 o[k2] = m[k];
4915}));
4916var __exportStar = (this && this.__exportStar) || function(m, exports) {
4917 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
4918};
4919Object.defineProperty(exports, "__esModule", { value: true });
4920__exportStar(__webpack_require__(50), exports);
4921__exportStar(__webpack_require__(20), exports);
4922
4923
4924/***/ }),
4925/* 50 */
4926/***/ (function(module, exports, __webpack_require__) {
4927
4928"use strict";
4929
4930var __extends = (this && this.__extends) || (function () {
4931 var extendStatics = function (d, b) {
4932 extendStatics = Object.setPrototypeOf ||
4933 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4934 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4935 return extendStatics(d, b);
4936 };
4937 return function (d, b) {
4938 extendStatics(d, b);
4939 function __() { this.constructor = d; }
4940 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4941 };
4942})();
4943var __assign = (this && this.__assign) || function () {
4944 __assign = Object.assign || function(t) {
4945 for (var s, i = 1, n = arguments.length; i < n; i++) {
4946 s = arguments[i];
4947 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4948 t[p] = s[p];
4949 }
4950 return t;
4951 };
4952 return __assign.apply(this, arguments);
4953};
4954Object.defineProperty(exports, "__esModule", { value: true });
4955exports.create = exports.Features = void 0;
4956var helper_1 = __webpack_require__(0);
4957var types_1 = __webpack_require__(1);
4958var types_2 = __webpack_require__(20);
4959/**
4960 * A set of Actions for Updating, Requesting Features of AppBridge
4961 * @public
4962 */
4963var Features = /** @class */ (function (_super) {
4964 __extends(Features, _super);
4965 function Features(app, options) {
4966 return _super.call(this, app, types_1.Group.Features, types_1.Group.Features, options ? options.id : undefined) || this;
4967 }
4968 /**
4969 * @public
4970 */
4971 Features.prototype.dispatch = function (action, payload) {
4972 switch (action) {
4973 case types_2.Action.REQUEST:
4974 this.dispatchFeaturesAction(types_2.Action.REQUEST, payload);
4975 break;
4976 }
4977 return this;
4978 };
4979 /**
4980 * @internal
4981 */
4982 Features.prototype.dispatchFeaturesAction = function (type, payload) {
4983 this.app.dispatch(helper_1.actionWrapper({
4984 group: types_1.Group.Features,
4985 type: type,
4986 payload: __assign(__assign({}, (payload || {})), { id: this.id }),
4987 }));
4988 };
4989 return Features;
4990}(helper_1.ActionSet));
4991exports.Features = Features;
4992/**
4993 * @public
4994 */
4995function create(app, options) {
4996 return new Features(app, options);
4997}
4998exports.create = create;
4999
5000
5001/***/ }),
5002/* 51 */
5003/***/ (function(module, exports, __webpack_require__) {
5004
5005"use strict";
5006
5007Object.defineProperty(exports, "__esModule", { value: true });
5008exports.respond = exports.request = exports.Action = void 0;
5009var helper_1 = __webpack_require__(0);
5010var types_1 = __webpack_require__(1);
5011var Action;
5012(function (Action) {
5013 Action["REQUEST"] = "APP::SESSION_TOKEN::REQUEST";
5014 Action["RESPOND"] = "APP::SESSION_TOKEN::RESPOND";
5015})(Action = exports.Action || (exports.Action = {}));
5016function request() {
5017 return helper_1.actionWrapper({
5018 group: types_1.Group.SessionToken,
5019 type: Action.REQUEST,
5020 });
5021}
5022exports.request = request;
5023function respond(sessionToken) {
5024 return helper_1.actionWrapper({
5025 payload: sessionToken,
5026 group: types_1.Group.SessionToken,
5027 type: Action.RESPOND,
5028 });
5029}
5030exports.respond = respond;
5031
5032
5033/***/ }),
5034/* 52 */
5035/***/ (function(module, exports, __webpack_require__) {
5036
5037"use strict";
5038
5039Object.defineProperty(exports, "__esModule", { value: true });
5040exports.getGroupedButton = void 0;
5041var ButtonGroup_1 = __webpack_require__(7);
5042function getGroupedButton(action, button, subgroups, updateCb) {
5043 action.addChild(button, action.group, subgroups);
5044 var id = button.id, label = button.label, disabled = button.disabled, buttons = button.buttons;
5045 action.subscribeToChild(button, ButtonGroup_1.Action.UPDATE, updateCb);
5046 return { id: id, label: label, buttons: buttons, disabled: disabled };
5047}
5048exports.getGroupedButton = getGroupedButton;
5049
5050
5051/***/ }),
5052/* 53 */
5053/***/ (function(module, exports, __webpack_require__) {
5054
5055"use strict";
5056
5057var __extends = (this && this.__extends) || (function () {
5058 var extendStatics = function (d, b) {
5059 extendStatics = Object.setPrototypeOf ||
5060 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5061 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5062 return extendStatics(d, b);
5063 };
5064 return function (d, b) {
5065 extendStatics(d, b);
5066 function __() { this.constructor = d; }
5067 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5068 };
5069})();
5070var __assign = (this && this.__assign) || function () {
5071 __assign = Object.assign || function(t) {
5072 for (var s, i = 1, n = arguments.length; i < n; i++) {
5073 s = arguments[i];
5074 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
5075 t[p] = s[p];
5076 }
5077 return t;
5078 };
5079 return __assign.apply(this, arguments);
5080};
5081Object.defineProperty(exports, "__esModule", { value: true });
5082exports.create = exports.Share = exports.Action = void 0;
5083var types_1 = __webpack_require__(1);
5084var helper_1 = __webpack_require__(0);
5085/**
5086 * Types
5087 */
5088/**
5089 * @public
5090 */
5091var Action;
5092(function (Action) {
5093 Action["SHOW"] = "APP::SHARE::SHOW";
5094 Action["CLOSE"] = "APP::SHARE::CLOSE";
5095})(Action = exports.Action || (exports.Action = {}));
5096/**
5097 * Action
5098 */
5099/**
5100 * A set of actions for displaying a Share Sheet component
5101 * @public
5102 */
5103var Share = /** @class */ (function (_super) {
5104 __extends(Share, _super);
5105 function Share(app) {
5106 return _super.call(this, app, types_1.Group.Share, types_1.Group.Share) || this;
5107 }
5108 /**
5109 * @public
5110 */
5111 Share.prototype.dispatch = function (action, payload) {
5112 switch (action) {
5113 case Action.SHOW:
5114 this.dispatchShareAction(Action.SHOW, payload);
5115 break;
5116 default:
5117 throw "Action: " + action + " not supported";
5118 }
5119 return this;
5120 };
5121 /**
5122 * @internal
5123 */
5124 Share.prototype.dispatchShareAction = function (actionType, payload) {
5125 this.app.dispatch(helper_1.actionWrapper({
5126 type: actionType,
5127 group: types_1.Group.Share,
5128 payload: __assign({ id: this.id }, payload),
5129 }));
5130 };
5131 return Share;
5132}(helper_1.ActionSet));
5133exports.Share = Share;
5134/**
5135 * @public
5136 */
5137function create(app) {
5138 return new Share(app);
5139}
5140exports.create = create;
5141
5142
5143/***/ }),
5144/* 54 */
5145/***/ (function(module, exports, __webpack_require__) {
5146
5147"use strict";
5148
5149var __extends = (this && this.__extends) || (function () {
5150 var extendStatics = function (d, b) {
5151 extendStatics = Object.setPrototypeOf ||
5152 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5153 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5154 return extendStatics(d, b);
5155 };
5156 return function (d, b) {
5157 extendStatics(d, b);
5158 function __() { this.constructor = d; }
5159 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5160 };
5161})();
5162Object.defineProperty(exports, "__esModule", { value: true });
5163exports.create = exports.Pos = exports.close = exports.Action = void 0;
5164var helper_1 = __webpack_require__(0);
5165var types_1 = __webpack_require__(1);
5166/**
5167 * Pos action type enum
5168 * @remarks includes the action prefix and group
5169 *
5170 */
5171var Action;
5172(function (Action) {
5173 Action["CLOSE"] = "APP::POS::CLOSE";
5174 Action["LOCATION_UPDATE"] = "APP::POS::LOCATION::UPDATE";
5175 Action["USER_UPDATE"] = "APP::POS::USER::UPDATE";
5176 Action["DEVICE_UPDATE"] = "APP::POS::DEVICE::UPDATE";
5177})(Action = exports.Action || (exports.Action = {}));
5178function close() {
5179 return helper_1.actionWrapper({
5180 group: types_1.Group.Pos,
5181 type: Action.CLOSE,
5182 });
5183}
5184exports.close = close;
5185var Pos = /** @class */ (function (_super) {
5186 __extends(Pos, _super);
5187 function Pos(app) {
5188 return _super.call(this, app, types_1.Group.Pos, types_1.Group.Pos) || this;
5189 }
5190 Pos.prototype.dispatch = function (action) {
5191 switch (action) {
5192 case Action.CLOSE:
5193 this.app.dispatch(close());
5194 break;
5195 }
5196 return this;
5197 };
5198 return Pos;
5199}(helper_1.ActionSet));
5200exports.Pos = Pos;
5201function create(app) {
5202 return new Pos(app);
5203}
5204exports.create = create;
5205
5206
5207/***/ }),
5208/* 55 */
5209/***/ (function(module, exports, __webpack_require__) {
5210
5211"use strict";
5212
5213var __extends = (this && this.__extends) || (function () {
5214 var extendStatics = function (d, b) {
5215 extendStatics = Object.setPrototypeOf ||
5216 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5217 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5218 return extendStatics(d, b);
5219 };
5220 return function (d, b) {
5221 extendStatics(d, b);
5222 function __() { this.constructor = d; }
5223 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5224 };
5225})();
5226var __assign = (this && this.__assign) || function () {
5227 __assign = Object.assign || function(t) {
5228 for (var s, i = 1, n = arguments.length; i < n; i++) {
5229 s = arguments[i];
5230 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
5231 t[p] = s[p];
5232 }
5233 return t;
5234 };
5235 return __assign.apply(this, arguments);
5236};
5237Object.defineProperty(exports, "__esModule", { value: true });
5238exports.create = exports.MarketingExternalActivityTopBar = exports.update = exports.clickActionButton = exports.MarketingActivityStatusBadgeType = exports.Action = void 0;
5239var Button_1 = __webpack_require__(4);
5240var buttonHelper_1 = __webpack_require__(8);
5241var helper_1 = __webpack_require__(0);
5242var types_1 = __webpack_require__(1);
5243var Action;
5244(function (Action) {
5245 Action["UPDATE"] = "APP::MARKETING_EXTERNAL_ACTIVITY_TOP_BAR::UPDATE";
5246 Action["BUTTON_CLICK"] = "APP::MARKETING_EXTERNAL_ACTIVITY_TOP_BAR::BUTTONS::BUTTON::CLICK";
5247 Action["BUTTON_UPDATE"] = "APP::MARKETING_EXTERNAL_ACTIVITY_TOP_BAR::BUTTONS::BUTTON::UPDATE";
5248})(Action = exports.Action || (exports.Action = {}));
5249var MarketingActivityStatusBadgeType;
5250(function (MarketingActivityStatusBadgeType) {
5251 MarketingActivityStatusBadgeType["Default"] = "DEFAULT";
5252 MarketingActivityStatusBadgeType["Success"] = "SUCCESS";
5253 MarketingActivityStatusBadgeType["Attention"] = "ATTENTION";
5254 MarketingActivityStatusBadgeType["Warning"] = "WARNING";
5255 MarketingActivityStatusBadgeType["Info"] = "INFO";
5256})(MarketingActivityStatusBadgeType = exports.MarketingActivityStatusBadgeType || (exports.MarketingActivityStatusBadgeType = {}));
5257var MARKETING_ACTIVITY_TOPBAR_BUTTON_PROPS = {
5258 group: types_1.Group.MarketingExternalActivityTopBar,
5259 subgroups: ['Buttons'],
5260};
5261function clickActionButton(id, payload) {
5262 var type = types_1.ComponentType.Button;
5263 var component = __assign({ id: id, type: type }, MARKETING_ACTIVITY_TOPBAR_BUTTON_PROPS);
5264 return Button_1.clickButton(types_1.Group.MarketingExternalActivityTopBar, component, payload);
5265}
5266exports.clickActionButton = clickActionButton;
5267function update(payload) {
5268 return helper_1.actionWrapper({
5269 payload: payload,
5270 group: types_1.Group.MarketingExternalActivityTopBar,
5271 type: Action.UPDATE,
5272 });
5273}
5274exports.update = update;
5275var MarketingExternalActivityTopBar = /** @class */ (function (_super) {
5276 __extends(MarketingExternalActivityTopBar, _super);
5277 function MarketingExternalActivityTopBar(app, options) {
5278 var _this = _super.call(this, app, types_1.Group.MarketingExternalActivityTopBar, types_1.Group.MarketingExternalActivityTopBar) || this;
5279 // Trigger 'update' on creation
5280 _this.set(options);
5281 return _this;
5282 }
5283 Object.defineProperty(MarketingExternalActivityTopBar.prototype, "buttons", {
5284 get: function () {
5285 if (!this.primary && !this.secondary) {
5286 return undefined;
5287 }
5288 return {
5289 primary: this.primary,
5290 secondary: this.secondary,
5291 };
5292 },
5293 enumerable: false,
5294 configurable: true
5295 });
5296 Object.defineProperty(MarketingExternalActivityTopBar.prototype, "buttonsOptions", {
5297 get: function () {
5298 if (!this.primaryOptions && !this.secondaryOptions) {
5299 return undefined;
5300 }
5301 return {
5302 primary: this.primaryOptions,
5303 secondary: this.secondaryOptions,
5304 };
5305 },
5306 enumerable: false,
5307 configurable: true
5308 });
5309 Object.defineProperty(MarketingExternalActivityTopBar.prototype, "options", {
5310 get: function () {
5311 return {
5312 title: this.title,
5313 status: this.status,
5314 saving: this.saving,
5315 saved: this.saved,
5316 buttons: this.buttonsOptions,
5317 };
5318 },
5319 enumerable: false,
5320 configurable: true
5321 });
5322 Object.defineProperty(MarketingExternalActivityTopBar.prototype, "payload", {
5323 get: function () {
5324 return __assign(__assign({}, this.options), { buttons: this.buttons, id: this.id });
5325 },
5326 enumerable: false,
5327 configurable: true
5328 });
5329 MarketingExternalActivityTopBar.prototype.set = function (options, shouldUpdate) {
5330 if (shouldUpdate === void 0) { shouldUpdate = true; }
5331 var mergedOptions = helper_1.getMergedProps(this.options, options);
5332 var title = mergedOptions.title, buttons = mergedOptions.buttons, saved = mergedOptions.saved, saving = mergedOptions.saving, status = mergedOptions.status;
5333 this.title = title;
5334 this.saving = saving;
5335 this.saved = saved;
5336 this.status = status;
5337 this.setPrimaryButton(buttons ? buttons.primary : undefined);
5338 this.setSecondaryButtons(buttons ? buttons.secondary : undefined);
5339 if (shouldUpdate) {
5340 this.dispatch(Action.UPDATE);
5341 }
5342 return this;
5343 };
5344 MarketingExternalActivityTopBar.prototype.dispatch = function (action) {
5345 switch (action) {
5346 case Action.UPDATE:
5347 this.app.dispatch(update(this.payload));
5348 break;
5349 }
5350 return this;
5351 };
5352 MarketingExternalActivityTopBar.prototype.getButton = function (button, subgroups, updateCb) {
5353 return buttonHelper_1.getSingleButton(this, button, subgroups, updateCb);
5354 };
5355 MarketingExternalActivityTopBar.prototype.updatePrimaryButton = function (newPayload) {
5356 if (!this.primary) {
5357 return;
5358 }
5359 if (helper_1.updateActionFromPayload(this.primary, newPayload)) {
5360 this.dispatch(Action.UPDATE);
5361 }
5362 };
5363 MarketingExternalActivityTopBar.prototype.updateSecondaryButtons = function (newPayload) {
5364 if (!this.secondary) {
5365 return;
5366 }
5367 var buttonToUpdate = this.secondary.find(function (action) { return action.id === newPayload.id; });
5368 if (!buttonToUpdate) {
5369 return;
5370 }
5371 var updated = helper_1.updateActionFromPayload(buttonToUpdate, newPayload);
5372 if (updated) {
5373 this.dispatch(Action.UPDATE);
5374 }
5375 };
5376 MarketingExternalActivityTopBar.prototype.setPrimaryButton = function (newOptions) {
5377 this.primaryOptions = this.getChildButton(newOptions, this.primaryOptions);
5378 this.primary = this.primaryOptions
5379 ? this.getButton(this.primaryOptions, MARKETING_ACTIVITY_TOPBAR_BUTTON_PROPS.subgroups, this.updatePrimaryButton)
5380 : undefined;
5381 };
5382 MarketingExternalActivityTopBar.prototype.setSecondaryButtons = function (newOptions) {
5383 var _this = this;
5384 var newButtons = newOptions || [];
5385 var currentButtons = this.secondaryOptions || [];
5386 this.secondaryOptions = this.getUpdatedChildActions(newButtons, currentButtons);
5387 this.secondary = this.secondaryOptions
5388 ? this.secondaryOptions.map(function (action) {
5389 return _this.getButton(action, MARKETING_ACTIVITY_TOPBAR_BUTTON_PROPS.subgroups, _this.updateSecondaryButtons);
5390 })
5391 : undefined;
5392 };
5393 MarketingExternalActivityTopBar.prototype.updateSaving = function (saving) {
5394 this.saving = saving;
5395 this.dispatch(Action.UPDATE);
5396 };
5397 MarketingExternalActivityTopBar.prototype.updateSaved = function (saved) {
5398 this.saved = saved;
5399 this.dispatch(Action.UPDATE);
5400 };
5401 MarketingExternalActivityTopBar.prototype.updateStatus = function (newPayload) {
5402 this.status = newPayload;
5403 this.dispatch(Action.UPDATE);
5404 };
5405 MarketingExternalActivityTopBar.prototype.getChildButton = function (newAction, currentAction) {
5406 var newButtons = newAction ? [newAction] : [];
5407 var currentButtons = currentAction ? [currentAction] : [];
5408 var updatedButton = this.getUpdatedChildActions(newButtons, currentButtons);
5409 return updatedButton ? updatedButton[0] : undefined;
5410 };
5411 return MarketingExternalActivityTopBar;
5412}(helper_1.ActionSetWithChildren));
5413exports.MarketingExternalActivityTopBar = MarketingExternalActivityTopBar;
5414function create(app, options) {
5415 return new MarketingExternalActivityTopBar(app, options);
5416}
5417exports.create = create;
5418
5419
5420/***/ }),
5421/* 56 */
5422/***/ (function(module, exports, __webpack_require__) {
5423
5424"use strict";
5425
5426Object.defineProperty(exports, "__esModule", { value: true });
5427exports.fullPageLoad = exports.skeletonPageLoad = exports.Action = void 0;
5428var types_1 = __webpack_require__(1);
5429var helper_1 = __webpack_require__(0);
5430var Action;
5431(function (Action) {
5432 Action["SKELETON_PAGE_LOAD"] = "APP::PERFORMANCE::SKELETON_PAGE_LOAD";
5433 Action["FULL_PAGE_LOAD"] = "APP::PERFORMANCE::FULL_PAGE_LOAD";
5434})(Action = exports.Action || (exports.Action = {}));
5435function skeletonPageLoad() {
5436 return helper_1.actionWrapper({
5437 group: types_1.Group.Performance,
5438 type: Action.SKELETON_PAGE_LOAD,
5439 });
5440}
5441exports.skeletonPageLoad = skeletonPageLoad;
5442function fullPageLoad() {
5443 return helper_1.actionWrapper({
5444 group: types_1.Group.Performance,
5445 type: Action.FULL_PAGE_LOAD,
5446 });
5447}
5448exports.fullPageLoad = fullPageLoad;
5449
5450
5451/***/ }),
5452/* 57 */
5453/***/ (function(module, exports, __webpack_require__) {
5454
5455"use strict";
5456
5457Object.defineProperty(exports, "__esModule", { value: true });
5458var validator_1 = __webpack_require__(58);
5459exports.default = validator_1.validatorMiddleware;
5460
5461
5462/***/ }),
5463/* 58 */
5464/***/ (function(module, exports, __webpack_require__) {
5465
5466"use strict";
5467
5468var __spreadArrays = (this && this.__spreadArrays) || function () {
5469 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
5470 for (var r = Array(s), k = 0, i = 0; i < il; i++)
5471 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
5472 r[k] = a[j];
5473 return r;
5474};
5475Object.defineProperty(exports, "__esModule", { value: true });
5476exports.validatorMiddleware = exports.connectValidatorToDispatchHook = exports.connectValidatorToUpdateHook = void 0;
5477var client_1 = __webpack_require__(15);
5478var types_1 = __webpack_require__(1);
5479var Error_1 = __webpack_require__(5);
5480var helper_1 = __webpack_require__(0);
5481var actions_1 = __webpack_require__(62);
5482var type_validate_1 = __webpack_require__(2);
5483var utils_1 = __webpack_require__(3);
5484function updateValidator(localOrigin, group, options) {
5485 switch (group) {
5486 case types_1.Group.Button:
5487 return actions_1.Button.validateProps(options);
5488 case types_1.Group.ButtonGroup:
5489 return actions_1.ButtonGroup.validateProps(options);
5490 case types_1.Group.Modal:
5491 return actions_1.Modal.validateProps(options, localOrigin);
5492 case types_1.Group.Menu:
5493 return actions_1.Menu.validateProps(options);
5494 case types_1.Group.Link:
5495 return actions_1.Link.validateProps(options);
5496 case types_1.Group.TitleBar:
5497 return actions_1.TitleBar.validateProps(options);
5498 case types_1.Group.ResourcePicker:
5499 return actions_1.ResourcePicker.validateProps(options);
5500 case types_1.Group.Toast:
5501 return actions_1.Toast.validateProps(options);
5502 case types_1.Group.ContextualSaveBar:
5503 return actions_1.ContextualSaveBar.validateProps(options);
5504 }
5505}
5506function dispatchPayloadValidator(action, localOrigin) {
5507 switch (action.group) {
5508 case types_1.Group.Button:
5509 return actions_1.Button.validateAction(action);
5510 case types_1.Group.ButtonGroup:
5511 return actions_1.ButtonGroup.validateAction(action);
5512 case types_1.Group.Modal:
5513 return actions_1.Modal.validateAction(action, localOrigin);
5514 case types_1.Group.Menu:
5515 return actions_1.Menu.validateAction(action);
5516 case types_1.Group.TitleBar:
5517 return actions_1.TitleBar.validateAction(action);
5518 case types_1.Group.ResourcePicker:
5519 return actions_1.ResourcePicker.validateAction(action);
5520 case types_1.Group.Loading:
5521 return actions_1.Loading.validateAction(action);
5522 case types_1.Group.Toast:
5523 return actions_1.Toast.validateAction(action);
5524 case types_1.Group.Cart:
5525 return actions_1.Cart.validateAction(action);
5526 case types_1.Group.Navigation:
5527 return actions_1.Navigation.validateAction(action);
5528 case types_1.Group.Print:
5529 return actions_1.Print.validateAction(action);
5530 case types_1.Group.Scanner:
5531 return actions_1.Scanner.validateAction(action);
5532 case types_1.Group.Fullscreen:
5533 return actions_1.Fullscreen.validateAction(action);
5534 case types_1.Group.ContextualSaveBar:
5535 return actions_1.ContextualSaveBar.validateAction(action);
5536 case types_1.Group.Link:
5537 return actions_1.Link.validateAction(action);
5538 }
5539}
5540function dispatchValidator(action, origin) {
5541 var errors = type_validate_1.validate(action, type_validate_1.matchesObject({
5542 group: type_validate_1.matchesEnum(types_1.Group, {
5543 message: function (_, value) { return "Unknown or unsupported action group `" + value + "`"; },
5544 }),
5545 version: type_validate_1.matchesString(),
5546 }));
5547 if (errors) {
5548 return Error_1.invalidAction(action, utils_1.actionMessage(errors));
5549 }
5550 var payloadErrors = dispatchPayloadValidator(action, origin);
5551 return payloadErrors ? Error_1.invalidPayload(action, utils_1.actionMessage(payloadErrors)) : action;
5552}
5553exports.connectValidatorToUpdateHook = function (next) {
5554 return function (options) {
5555 var args = [];
5556 for (var _i = 1; _i < arguments.length; _i++) {
5557 args[_i - 1] = arguments[_i];
5558 }
5559 // The group should be statically set to the default initial group as certain components
5560 // (ex. Button and ButtonGroup) can be dynamically grouped under a new group (ex. TitleBar)
5561 // We accept partial options so the validator should be called on merged new and old options
5562 var mergedOptions = helper_1.getMergedProps(this.options, options);
5563 var errors = updateValidator(this.app.localOrigin, this.defaultGroup, mergedOptions);
5564 if (errors) {
5565 throw Error_1.fromAction(utils_1.actionMessage(errors), Error_1.Action.INVALID_OPTIONS);
5566 }
5567 return next.apply(void 0, __spreadArrays([options], args));
5568 };
5569};
5570exports.connectValidatorToDispatchHook = function (next) {
5571 return function (action) {
5572 var finalAction = dispatchValidator(action, this.localOrigin);
5573 return next(finalAction);
5574 };
5575};
5576exports.validatorMiddleware = function (hooks) {
5577 hooks.set(client_1.LifecycleHook.UpdateAction, exports.connectValidatorToUpdateHook);
5578 hooks.set(client_1.LifecycleHook.DispatchAction, exports.connectValidatorToDispatchHook);
5579};
5580
5581
5582/***/ }),
5583/* 59 */
5584/***/ (function(module, exports) {
5585
5586// shim for using process in browser
5587var process = module.exports = {};
5588
5589// cached from whatever global is present so that test runners that stub it
5590// don't break things. But we need to wrap it in a try catch in case it is
5591// wrapped in strict mode code which doesn't define any globals. It's inside a
5592// function because try/catches deoptimize in certain engines.
5593
5594var cachedSetTimeout;
5595var cachedClearTimeout;
5596
5597function defaultSetTimout() {
5598 throw new Error('setTimeout has not been defined');
5599}
5600function defaultClearTimeout () {
5601 throw new Error('clearTimeout has not been defined');
5602}
5603(function () {
5604 try {
5605 if (typeof setTimeout === 'function') {
5606 cachedSetTimeout = setTimeout;
5607 } else {
5608 cachedSetTimeout = defaultSetTimout;
5609 }
5610 } catch (e) {
5611 cachedSetTimeout = defaultSetTimout;
5612 }
5613 try {
5614 if (typeof clearTimeout === 'function') {
5615 cachedClearTimeout = clearTimeout;
5616 } else {
5617 cachedClearTimeout = defaultClearTimeout;
5618 }
5619 } catch (e) {
5620 cachedClearTimeout = defaultClearTimeout;
5621 }
5622} ())
5623function runTimeout(fun) {
5624 if (cachedSetTimeout === setTimeout) {
5625 //normal enviroments in sane situations
5626 return setTimeout(fun, 0);
5627 }
5628 // if setTimeout wasn't available but was latter defined
5629 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
5630 cachedSetTimeout = setTimeout;
5631 return setTimeout(fun, 0);
5632 }
5633 try {
5634 // when when somebody has screwed with setTimeout but no I.E. maddness
5635 return cachedSetTimeout(fun, 0);
5636 } catch(e){
5637 try {
5638 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
5639 return cachedSetTimeout.call(null, fun, 0);
5640 } catch(e){
5641 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
5642 return cachedSetTimeout.call(this, fun, 0);
5643 }
5644 }
5645
5646
5647}
5648function runClearTimeout(marker) {
5649 if (cachedClearTimeout === clearTimeout) {
5650 //normal enviroments in sane situations
5651 return clearTimeout(marker);
5652 }
5653 // if clearTimeout wasn't available but was latter defined
5654 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
5655 cachedClearTimeout = clearTimeout;
5656 return clearTimeout(marker);
5657 }
5658 try {
5659 // when when somebody has screwed with setTimeout but no I.E. maddness
5660 return cachedClearTimeout(marker);
5661 } catch (e){
5662 try {
5663 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
5664 return cachedClearTimeout.call(null, marker);
5665 } catch (e){
5666 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
5667 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
5668 return cachedClearTimeout.call(this, marker);
5669 }
5670 }
5671
5672
5673
5674}
5675var queue = [];
5676var draining = false;
5677var currentQueue;
5678var queueIndex = -1;
5679
5680function cleanUpNextTick() {
5681 if (!draining || !currentQueue) {
5682 return;
5683 }
5684 draining = false;
5685 if (currentQueue.length) {
5686 queue = currentQueue.concat(queue);
5687 } else {
5688 queueIndex = -1;
5689 }
5690 if (queue.length) {
5691 drainQueue();
5692 }
5693}
5694
5695function drainQueue() {
5696 if (draining) {
5697 return;
5698 }
5699 var timeout = runTimeout(cleanUpNextTick);
5700 draining = true;
5701
5702 var len = queue.length;
5703 while(len) {
5704 currentQueue = queue;
5705 queue = [];
5706 while (++queueIndex < len) {
5707 if (currentQueue) {
5708 currentQueue[queueIndex].run();
5709 }
5710 }
5711 queueIndex = -1;
5712 len = queue.length;
5713 }
5714 currentQueue = null;
5715 draining = false;
5716 runClearTimeout(timeout);
5717}
5718
5719process.nextTick = function (fun) {
5720 var args = new Array(arguments.length - 1);
5721 if (arguments.length > 1) {
5722 for (var i = 1; i < arguments.length; i++) {
5723 args[i - 1] = arguments[i];
5724 }
5725 }
5726 queue.push(new Item(fun, args));
5727 if (queue.length === 1 && !draining) {
5728 runTimeout(drainQueue);
5729 }
5730};
5731
5732// v8 likes predictible objects
5733function Item(fun, array) {
5734 this.fun = fun;
5735 this.array = array;
5736}
5737Item.prototype.run = function () {
5738 this.fun.apply(null, this.array);
5739};
5740process.title = 'browser';
5741process.browser = true;
5742process.env = {};
5743process.argv = [];
5744process.version = ''; // empty string to avoid regexp issues
5745process.versions = {};
5746
5747function noop() {}
5748
5749process.on = noop;
5750process.addListener = noop;
5751process.once = noop;
5752process.off = noop;
5753process.removeListener = noop;
5754process.removeAllListeners = noop;
5755process.emit = noop;
5756process.prependListener = noop;
5757process.prependOnceListener = noop;
5758
5759process.listeners = function (name) { return [] }
5760
5761process.binding = function (name) {
5762 throw new Error('process.binding is not supported');
5763};
5764
5765process.cwd = function () { return '/' };
5766process.chdir = function (dir) {
5767 throw new Error('process.chdir is not supported');
5768};
5769process.umask = function() { return 0; };
5770
5771
5772/***/ }),
5773/* 60 */
5774/***/ (function(module, exports, __webpack_require__) {
5775
5776"use strict";
5777
5778Object.defineProperty(exports, "__esModule", { value: true });
5779exports.handleAppPrint = void 0;
5780var redirect_1 = __webpack_require__(16);
5781function isRunningOniOS() {
5782 return navigator.userAgent.indexOf('iOS') >= 0;
5783}
5784function createHiddenInput() {
5785 var currentWindow = redirect_1.getWindow();
5786 if (!currentWindow || !currentWindow.document || !currentWindow.document.body) {
5787 return;
5788 }
5789 var inputElement = window.document.createElement('input');
5790 inputElement.style.display = 'none';
5791 window.document.body.appendChild(inputElement);
5792 return inputElement;
5793}
5794function printWindow() {
5795 if (!redirect_1.getWindow()) {
5796 return;
5797 }
5798 // @ts-ignore: Fixed in TypeScript 2.8.2
5799 window.print();
5800}
5801function handleMobileAppPrint() {
5802 var input = createHiddenInput();
5803 if (!input) {
5804 return;
5805 }
5806 input.select();
5807 printWindow();
5808 input.remove();
5809}
5810function handleAppPrint() {
5811 if (isRunningOniOS()) {
5812 handleMobileAppPrint();
5813 }
5814 else {
5815 printWindow();
5816 }
5817}
5818exports.handleAppPrint = handleAppPrint;
5819
5820
5821/***/ }),
5822/* 61 */
5823/***/ (function(module, exports, __webpack_require__) {
5824
5825"use strict";
5826
5827Object.defineProperty(exports, "__esModule", { value: true });
5828var collection_1 = __webpack_require__(12);
5829/**
5830 * Shopify App Bridge can be extended with hooks, which run when actions are dispatched and updated.
5831 * Hooks are middleware functions that can modify or cancel actions.
5832 *
5833 * The [validation middleware](../validate/README.md) is implemented using hooks.
5834 *
5835 * @remarks
5836 * Here’s an example hook that modifies all Toast show actions to have a duration of five seconds.
5837 *
5838 * ```ts
5839 * import createApp, {LifecycleHook, DispatchActionHook} from '@shopify/app-bridge';
5840 * import {Toast} from '@shopify/app-bridge/actions'
5841 *
5842 * const app = createApp({apiKey: API_KEY, host: HOST});
5843 *
5844 * function makeToastsFiveSeconds: DispatchActionHook(next) {
5845 * return function(action){
5846 * if(action.type === Toast.Action.SHOW) {
5847 * const modifiedAction = {
5848 * ...action,
5849 * payload: {
5850 * ...action.payload,
5851 * duration: 5000,
5852 * },
5853 * };
5854 * return next(modifiedAction);
5855 * } else {
5856 * // don’t modify non-Toast actions
5857 * return next(action);
5858 * }
5859 * }
5860 * }
5861 *
5862 * app.hooks.set(LifecycleHook.DispatchAction, makeToastsFiveSeconds);
5863 * ```
5864 *
5865 * The hook function `makeToastsFiveSeconds()` takes a `next()` function as its argument.
5866 * The hook function returns an anonymous function, which takes the action being dispatched as its argument.
5867 *
5868 * To modify an action, call `next()` with the modified action, as in the example.
5869 * To cancel an action, don’t call `next()`, and the action will not be dispatched.
5870 */
5871var Hooks = /** @class */ (function () {
5872 function Hooks() {
5873 this.map = {};
5874 }
5875 Hooks.prototype.set = function (hook, handler) {
5876 if (!this.map.hasOwnProperty(hook)) {
5877 this.map[hook] = [];
5878 }
5879 var value = { handler: handler, remove: function () { } };
5880 var remove = collection_1.addAndRemoveFromCollection(this.map[hook], value);
5881 value = { handler: handler, remove: remove };
5882 return remove;
5883 };
5884 Hooks.prototype.get = function (hook) {
5885 var value = this.map[hook];
5886 return value ? value.map(function (val) { return val.handler; }) : undefined;
5887 };
5888 Hooks.prototype.run = function (hook, final, context) {
5889 var initialArgs = [];
5890 for (var _i = 3; _i < arguments.length; _i++) {
5891 initialArgs[_i - 3] = arguments[_i];
5892 }
5893 var index = 0;
5894 var handlers = this.get(hook) || [];
5895 function handler() {
5896 var args = [];
5897 for (var _i = 0; _i < arguments.length; _i++) {
5898 args[_i] = arguments[_i];
5899 }
5900 var childHandler = handlers[index++];
5901 if (childHandler) {
5902 return childHandler(handler).apply(context, args);
5903 }
5904 return final.apply(context, args);
5905 }
5906 return handler.apply(context, initialArgs);
5907 };
5908 return Hooks;
5909}());
5910exports.default = Hooks;
5911
5912
5913/***/ }),
5914/* 62 */
5915/***/ (function(module, exports, __webpack_require__) {
5916
5917"use strict";
5918
5919var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5920 if (k2 === undefined) k2 = k;
5921 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5922}) : (function(o, m, k, k2) {
5923 if (k2 === undefined) k2 = k;
5924 o[k2] = m[k];
5925}));
5926var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
5927 Object.defineProperty(o, "default", { enumerable: true, value: v });
5928}) : function(o, v) {
5929 o["default"] = v;
5930});
5931var __importStar = (this && this.__importStar) || function (mod) {
5932 if (mod && mod.__esModule) return mod;
5933 var result = {};
5934 if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
5935 __setModuleDefault(result, mod);
5936 return result;
5937};
5938Object.defineProperty(exports, "__esModule", { value: true });
5939exports.Link = exports.Menu = exports.TitleBar = exports.Toast = exports.ResourcePicker = exports.Print = exports.Navigation = exports.Modal = exports.Loading = exports.LeaveConfirmation = exports.Fullscreen = exports.FeedbackModal = exports.ContextualSaveBar = exports.Cart = exports.Scanner = exports.ButtonGroup = exports.Button = void 0;
5940var Button = __importStar(__webpack_require__(11));
5941exports.Button = Button;
5942var Scanner = __importStar(__webpack_require__(63));
5943exports.Scanner = Scanner;
5944var Cart = __importStar(__webpack_require__(64));
5945exports.Cart = Cart;
5946var ContextualSaveBar = __importStar(__webpack_require__(65));
5947exports.ContextualSaveBar = ContextualSaveBar;
5948var FeedbackModal = __importStar(__webpack_require__(66));
5949exports.FeedbackModal = FeedbackModal;
5950var Fullscreen = __importStar(__webpack_require__(67));
5951exports.Fullscreen = Fullscreen;
5952var LeaveConfirmation = __importStar(__webpack_require__(68));
5953exports.LeaveConfirmation = LeaveConfirmation;
5954var Loading = __importStar(__webpack_require__(69));
5955exports.Loading = Loading;
5956var Modal = __importStar(__webpack_require__(70));
5957exports.Modal = Modal;
5958var Navigation = __importStar(__webpack_require__(72));
5959exports.Navigation = Navigation;
5960var Print = __importStar(__webpack_require__(73));
5961exports.Print = Print;
5962var ButtonGroup = __importStar(__webpack_require__(39));
5963exports.ButtonGroup = ButtonGroup;
5964var ResourcePicker = __importStar(__webpack_require__(74));
5965exports.ResourcePicker = ResourcePicker;
5966var Toast = __importStar(__webpack_require__(75));
5967exports.Toast = Toast;
5968var TitleBar = __importStar(__webpack_require__(76));
5969exports.TitleBar = TitleBar;
5970var Menu = __importStar(__webpack_require__(77));
5971exports.Menu = Menu;
5972var Link = __importStar(__webpack_require__(40));
5973exports.Link = Link;
5974
5975
5976/***/ }),
5977/* 63 */
5978/***/ (function(module, exports, __webpack_require__) {
5979
5980"use strict";
5981
5982Object.defineProperty(exports, "__esModule", { value: true });
5983exports.Action = exports.validateAction = void 0;
5984var Scanner_1 = __webpack_require__(28);
5985Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Scanner_1.Action; } });
5986var type_validate_1 = __webpack_require__(2);
5987var utils_1 = __webpack_require__(3);
5988function validateAction(action) {
5989 return type_validate_1.validate(action, utils_1.createActionValidator(Scanner_1.Action));
5990}
5991exports.validateAction = validateAction;
5992
5993
5994/***/ }),
5995/* 64 */
5996/***/ (function(module, exports, __webpack_require__) {
5997
5998"use strict";
5999
6000Object.defineProperty(exports, "__esModule", { value: true });
6001exports.Action = exports.validateAction = void 0;
6002var Cart_1 = __webpack_require__(18);
6003Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Cart_1.Action; } });
6004var type_validate_1 = __webpack_require__(2);
6005var utils_1 = __webpack_require__(3);
6006var addressSchema = type_validate_1.matchesObject({
6007 address1: type_validate_1.makeOptional(type_validate_1.matchesString()),
6008 address2: type_validate_1.makeOptional(type_validate_1.matchesString()),
6009 city: type_validate_1.makeOptional(type_validate_1.matchesString()),
6010 company: type_validate_1.makeOptional(type_validate_1.matchesString()),
6011 firstName: type_validate_1.makeOptional(type_validate_1.matchesString()),
6012 lastName: type_validate_1.makeOptional(type_validate_1.matchesString()),
6013 phone: type_validate_1.makeOptional(type_validate_1.matchesString()),
6014 province: type_validate_1.makeOptional(type_validate_1.matchesString()),
6015 country: type_validate_1.makeOptional(type_validate_1.matchesString()),
6016 zip: type_validate_1.makeOptional(type_validate_1.matchesString()),
6017 name: type_validate_1.makeOptional(type_validate_1.matchesString()),
6018 provinceCode: type_validate_1.makeOptional(type_validate_1.matchesString()),
6019 countryCode: type_validate_1.makeOptional(type_validate_1.matchesString()),
6020});
6021var discountSchema = type_validate_1.matchesObject({
6022 amount: type_validate_1.makeOptional(type_validate_1.matchesPositiveInteger()),
6023 discountDescription: type_validate_1.makeOptional(type_validate_1.matchesString()),
6024 type: type_validate_1.makeOptional(type_validate_1.matchesString()),
6025 discountCode: type_validate_1.makeOptional(type_validate_1.matchesString()),
6026});
6027var discountAmount = type_validate_1.matchesObject({
6028 amount: type_validate_1.matchesPositiveNumber(),
6029 discountDescription: type_validate_1.makeOptional(type_validate_1.matchesString()),
6030 type: type_validate_1.makeOptional(type_validate_1.matchesString()),
6031});
6032var discountCode = type_validate_1.matchesObject({
6033 discountCode: type_validate_1.matchesString(),
6034});
6035var lineItemSchema = type_validate_1.matchesObject({
6036 price: type_validate_1.makeOptional(type_validate_1.matchesPositiveNumber()),
6037 quantity: type_validate_1.makeOptional(type_validate_1.matchesPositiveInteger()),
6038 title: type_validate_1.makeOptional(type_validate_1.matchesString()),
6039 variantId: type_validate_1.makeOptional(type_validate_1.matchesPositiveInteger()),
6040 discount: type_validate_1.makeOptional(discountAmount),
6041});
6042var updateLineItemSchema = type_validate_1.matchesObject({
6043 quantity: type_validate_1.matchesPositiveInteger(),
6044});
6045var customerSchema = type_validate_1.matchesObject({
6046 id: type_validate_1.makeOptional(type_validate_1.matchesPositiveInteger()),
6047 email: type_validate_1.makeOptional(type_validate_1.matchesString()),
6048 firstName: type_validate_1.makeOptional(type_validate_1.matchesString()),
6049 lastName: type_validate_1.makeOptional(type_validate_1.matchesString()),
6050 note: type_validate_1.makeOptional(type_validate_1.matchesString()),
6051 addresses: type_validate_1.makeOptional(type_validate_1.matchesArray(addressSchema)),
6052});
6053var noteSchema = type_validate_1.matchesObject({
6054 name: type_validate_1.matchesString(),
6055 value: type_validate_1.matchesString(),
6056});
6057var cartSchema = type_validate_1.matchesObject({
6058 cartDiscount: type_validate_1.makeOptional(discountSchema),
6059 customer: type_validate_1.makeOptional(customerSchema),
6060 grandTotal: type_validate_1.makeOptional(type_validate_1.matchesString()),
6061 lineItems: type_validate_1.makeOptional(type_validate_1.matchesArray(lineItemSchema)),
6062 noteAttributes: type_validate_1.makeOptional(type_validate_1.matchesArray(noteSchema)),
6063 subTotal: type_validate_1.makeOptional(type_validate_1.matchesString()),
6064 taxTotal: type_validate_1.makeOptional(type_validate_1.matchesString()),
6065});
6066var propertiesSchema = type_validate_1.composeSchemas(type_validate_1.matchesObject({}), function (value) {
6067 var validator = type_validate_1.matchesString();
6068 var schema = Object.keys(value).reduce(function (acc, key) {
6069 acc[key] = validator;
6070 return acc;
6071 }, {});
6072 return type_validate_1.validate(value, type_validate_1.matchesObject(schema));
6073});
6074var matchesStringArray = type_validate_1.matchesArray(type_validate_1.matchesString());
6075function createDataValidator(data) {
6076 return utils_1.createActionValidator(Cart_1.Action, data ? type_validate_1.matchesObject({ data: data }) : undefined, true, true);
6077}
6078function createDataValidatorWithIndex(data) {
6079 var indexSchema = type_validate_1.matchesObject({ index: type_validate_1.matchesPositiveInteger() });
6080 if (data) {
6081 var dataSchema = type_validate_1.matchesObject({ data: data });
6082 return utils_1.createActionValidator(Cart_1.Action, type_validate_1.composeSchemas(indexSchema, dataSchema), true, true);
6083 }
6084 return utils_1.createActionValidator(Cart_1.Action, indexSchema, true, true);
6085}
6086function getDiscountSchema(data) {
6087 if (data.amount) {
6088 return discountAmount;
6089 }
6090 return discountCode;
6091}
6092function validateAction(action) {
6093 switch (action.type) {
6094 case Cart_1.Action.UPDATE:
6095 return type_validate_1.validate(action, createDataValidator(cartSchema));
6096 case Cart_1.Action.SET_CUSTOMER:
6097 return type_validate_1.validate(action, createDataValidator(customerSchema));
6098 case Cart_1.Action.ADD_CUSTOMER_ADDRESS:
6099 return type_validate_1.validate(action, createDataValidator(addressSchema));
6100 case Cart_1.Action.UPDATE_CUSTOMER_ADDRESS:
6101 return type_validate_1.validate(action, createDataValidatorWithIndex(addressSchema));
6102 case Cart_1.Action.SET_DISCOUNT:
6103 return type_validate_1.validate(action, createDataValidator(getDiscountSchema(action.payload.data)));
6104 case Cart_1.Action.SET_PROPERTIES:
6105 return type_validate_1.validate(action, createDataValidator(propertiesSchema));
6106 case Cart_1.Action.REMOVE_PROPERTIES:
6107 return type_validate_1.validate(action, createDataValidator(matchesStringArray));
6108 case Cart_1.Action.ADD_LINE_ITEM:
6109 return type_validate_1.validate(action, createDataValidator(lineItemSchema));
6110 case Cart_1.Action.UPDATE_LINE_ITEM:
6111 return type_validate_1.validate(action, createDataValidatorWithIndex(updateLineItemSchema));
6112 case Cart_1.Action.REMOVE_LINE_ITEM:
6113 return type_validate_1.validate(action, createDataValidatorWithIndex());
6114 case Cart_1.Action.SET_LINE_ITEM_DISCOUNT:
6115 return type_validate_1.validate(action, createDataValidatorWithIndex(discountAmount));
6116 case Cart_1.Action.REMOVE_LINE_ITEM_DISCOUNT:
6117 return type_validate_1.validate(action, createDataValidatorWithIndex());
6118 case Cart_1.Action.SET_LINE_ITEM_PROPERTIES:
6119 return type_validate_1.validate(action, createDataValidatorWithIndex(propertiesSchema));
6120 case Cart_1.Action.REMOVE_LINE_ITEM_PROPERTIES:
6121 return type_validate_1.validate(action, createDataValidatorWithIndex(matchesStringArray));
6122 case Cart_1.Action.FETCH:
6123 case Cart_1.Action.REMOVE_CUSTOMER:
6124 case Cart_1.Action.REMOVE_DISCOUNT:
6125 case Cart_1.Action.CLEAR:
6126 default:
6127 return type_validate_1.validate(action, utils_1.createActionValidator(Cart_1.Action, undefined, false, true));
6128 }
6129}
6130exports.validateAction = validateAction;
6131
6132
6133/***/ }),
6134/* 65 */
6135/***/ (function(module, exports, __webpack_require__) {
6136
6137"use strict";
6138
6139Object.defineProperty(exports, "__esModule", { value: true });
6140exports.Action = exports.validateAction = exports.validateProps = exports.contextSaveBarSchema = void 0;
6141var type_validate_1 = __webpack_require__(2);
6142var ContextualSaveBar_1 = __webpack_require__(30);
6143Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return ContextualSaveBar_1.Action; } });
6144var utils_1 = __webpack_require__(3);
6145exports.contextSaveBarSchema = type_validate_1.makeOptional(type_validate_1.matchesObject({
6146 fullWidth: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6147 discardAction: type_validate_1.makeOptional(type_validate_1.matchesObject({
6148 disabled: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6149 discardConfirmationModal: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6150 })),
6151 saveAction: type_validate_1.makeOptional(type_validate_1.matchesObject({
6152 disabled: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6153 })),
6154 leaveConfirmationDisable: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6155}));
6156function validateProps(props) {
6157 return type_validate_1.validate(props, exports.contextSaveBarSchema);
6158}
6159exports.validateProps = validateProps;
6160function validateAction(action) {
6161 var validator = utils_1.createActionValidator(ContextualSaveBar_1.Action, exports.contextSaveBarSchema);
6162 return type_validate_1.validate(action, validator);
6163}
6164exports.validateAction = validateAction;
6165
6166
6167/***/ }),
6168/* 66 */
6169/***/ (function(module, exports, __webpack_require__) {
6170
6171"use strict";
6172
6173Object.defineProperty(exports, "__esModule", { value: true });
6174exports.Action = exports.validateAction = exports.validateProps = exports.feedbackModalSchema = void 0;
6175var FeedbackModal_1 = __webpack_require__(21);
6176Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return FeedbackModal_1.Action; } });
6177var type_validate_1 = __webpack_require__(2);
6178var utils_1 = __webpack_require__(3);
6179exports.feedbackModalSchema = type_validate_1.matchesObject({
6180 formId: type_validate_1.matchesPositiveInteger(),
6181});
6182function validateProps(props) {
6183 return type_validate_1.validate(props, exports.feedbackModalSchema);
6184}
6185exports.validateProps = validateProps;
6186function validateAction(action) {
6187 switch (action.type) {
6188 case FeedbackModal_1.Action.OPEN:
6189 return type_validate_1.validate(action, utils_1.createActionValidator(FeedbackModal_1.Action, exports.feedbackModalSchema, true));
6190 case FeedbackModal_1.Action.CLOSE:
6191 default:
6192 return type_validate_1.validate(action, utils_1.createActionValidator(FeedbackModal_1.Action));
6193 }
6194}
6195exports.validateAction = validateAction;
6196
6197
6198/***/ }),
6199/* 67 */
6200/***/ (function(module, exports, __webpack_require__) {
6201
6202"use strict";
6203
6204Object.defineProperty(exports, "__esModule", { value: true });
6205exports.Action = exports.validateAction = void 0;
6206var Fullscreen_1 = __webpack_require__(22);
6207Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Fullscreen_1.Action; } });
6208var type_validate_1 = __webpack_require__(2);
6209var utils_1 = __webpack_require__(3);
6210/**
6211 * Performs validation for an fullscreen action
6212 * @param action the action being dispatched
6213 * @returns undefined or an array of validation errors
6214 *
6215 * @beta
6216 */
6217function validateAction(action) {
6218 var validator = utils_1.createActionValidator(Fullscreen_1.Action);
6219 return type_validate_1.validate(action, validator);
6220}
6221exports.validateAction = validateAction;
6222
6223
6224/***/ }),
6225/* 68 */
6226/***/ (function(module, exports, __webpack_require__) {
6227
6228"use strict";
6229
6230Object.defineProperty(exports, "__esModule", { value: true });
6231exports.Action = exports.validateAction = void 0;
6232var LeaveConfirmation_1 = __webpack_require__(23);
6233Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return LeaveConfirmation_1.Action; } });
6234var type_validate_1 = __webpack_require__(2);
6235var utils_1 = __webpack_require__(3);
6236function validateAction(action) {
6237 var validator = utils_1.createActionValidator(LeaveConfirmation_1.Action);
6238 return type_validate_1.validate(action, validator);
6239}
6240exports.validateAction = validateAction;
6241
6242
6243/***/ }),
6244/* 69 */
6245/***/ (function(module, exports, __webpack_require__) {
6246
6247"use strict";
6248
6249Object.defineProperty(exports, "__esModule", { value: true });
6250exports.Action = exports.validateAction = void 0;
6251var Loading_1 = __webpack_require__(24);
6252Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Loading_1.Action; } });
6253var type_validate_1 = __webpack_require__(2);
6254var utils_1 = __webpack_require__(3);
6255function validateAction(action) {
6256 var validator = utils_1.createActionValidator(Loading_1.Action);
6257 return type_validate_1.validate(action, validator);
6258}
6259exports.validateAction = validateAction;
6260
6261
6262/***/ }),
6263/* 70 */
6264/***/ (function(module, exports, __webpack_require__) {
6265
6266"use strict";
6267
6268var __assign = (this && this.__assign) || function () {
6269 __assign = Object.assign || function(t) {
6270 for (var s, i = 1, n = arguments.length; i < n; i++) {
6271 s = arguments[i];
6272 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6273 t[p] = s[p];
6274 }
6275 return t;
6276 };
6277 return __assign.apply(this, arguments);
6278};
6279Object.defineProperty(exports, "__esModule", { value: true });
6280exports.Action = exports.validateAction = exports.validateProps = void 0;
6281var type_validate_1 = __webpack_require__(2);
6282var utils_1 = __webpack_require__(3);
6283var Modal_1 = __webpack_require__(25);
6284Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Modal_1.Action; } });
6285var Button_1 = __webpack_require__(4);
6286var safe_redirect_1 = __webpack_require__(71);
6287var button_1 = __webpack_require__(11);
6288function matchesSafeOrigin(value, localOrigin) {
6289 var hostName;
6290 try {
6291 hostName = new URL(localOrigin).hostname;
6292 }
6293 catch (error) {
6294 return [
6295 {
6296 error: 'invalid_app_origin',
6297 value: localOrigin,
6298 message: "Provided value for app origin: `" + localOrigin + "` is invalid",
6299 },
6300 ];
6301 }
6302 var isSafeSrc = safe_redirect_1.isSafe(value, {
6303 requireAbsolute: true,
6304 requireSSL: true,
6305 allowedDomains: [hostName],
6306 });
6307 if (!isSafeSrc) {
6308 return [
6309 {
6310 error: 'not_matching_app_origin',
6311 value: value,
6312 message: "Provided URL origin does not match app origin `" + hostName + "`",
6313 },
6314 ];
6315 }
6316}
6317function matchesSize() {
6318 return function (value) {
6319 var values = [Modal_1.Size.Small, Modal_1.Size.Medium, Modal_1.Size.Large];
6320 if (values.includes(value)) {
6321 return;
6322 }
6323 var message = "expected:" + values.map(function (val) { return "`" + val + "`"; }).join(' or ');
6324 if (value === Modal_1.Size.Full) {
6325 message += ". Size `" + value + "` is deprecated as of version 1.6.5 and will fall back to size `medium`";
6326 }
6327 if (value === Modal_1.Size.Auto) {
6328 message += ". Size `" + value + "` is deprecated as of version 1.12.x and will fall back to size `medium`. Use the `setUpModalAutoSizing` utility from `app-bridge-utils` instead";
6329 }
6330 return [
6331 {
6332 error: 'invalid_enum_value',
6333 value: value,
6334 message: message,
6335 },
6336 ];
6337 };
6338}
6339function getModalSchema(props, localOrigin) {
6340 if (props === void 0) { props = {}; }
6341 var baseModalSchema = type_validate_1.matchesObject({
6342 title: type_validate_1.makeOptional(type_validate_1.matchesString()),
6343 footer: type_validate_1.makeOptional(type_validate_1.matchesObject({
6344 buttons: type_validate_1.matchesObject({
6345 primary: type_validate_1.makeOptional(button_1.buttonSchemaWithId),
6346 secondary: type_validate_1.makeOptional(type_validate_1.matchesArray(button_1.buttonSchemaWithId)),
6347 }),
6348 })),
6349 size: type_validate_1.makeOptional(matchesSize()),
6350 });
6351 if (Modal_1.isIframeModal(props)) {
6352 if (props.url) {
6353 var urlSchema = type_validate_1.matchesObject({
6354 url: type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) {
6355 return value.startsWith('https://')
6356 ? undefined
6357 : [
6358 {
6359 error: 'invalid_secure_url',
6360 value: value,
6361 message: 'expected string to start with `https://`',
6362 },
6363 ];
6364 }, function (value) { return (localOrigin ? matchesSafeOrigin(value, localOrigin) : undefined); }),
6365 });
6366 return type_validate_1.composeSchemas(baseModalSchema, urlSchema);
6367 }
6368 return type_validate_1.composeSchemas(baseModalSchema, utils_1.relativePathSchema);
6369 }
6370 return type_validate_1.composeSchemas(baseModalSchema, type_validate_1.matchesObject({ message: type_validate_1.matchesString() }));
6371}
6372function validateProps(props, localOrigin) {
6373 return type_validate_1.validate(props, getModalSchema(props, localOrigin));
6374}
6375exports.validateProps = validateProps;
6376function validateAction(action, localOrigin) {
6377 var schema = getModalSchema(action.payload, localOrigin);
6378 switch (action.type) {
6379 case Modal_1.Action.OPEN:
6380 case Modal_1.Action.UPDATE:
6381 return type_validate_1.validate(action, utils_1.createActionValidator(Modal_1.Action, schema, true, action.type === Modal_1.Action.UPDATE));
6382 case Modal_1.Action.FOOTER_BUTTON_CLICK:
6383 return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.CLICK }));
6384 case Modal_1.Action.FOOTER_BUTTON_UPDATE:
6385 return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.UPDATE }));
6386 case Modal_1.Action.CLOSE:
6387 default:
6388 return type_validate_1.validate(action, utils_1.createActionValidator(Modal_1.Action));
6389 }
6390}
6391exports.validateAction = validateAction;
6392
6393
6394/***/ }),
6395/* 71 */
6396/***/ (function(module, exports, __webpack_require__) {
6397
6398"use strict";
6399
6400Object.defineProperty(exports, "__esModule", { value: true });
6401exports.makeSafe = exports.isSafe = void 0;
6402var FILE_URI_MATCH = /\/\/\//;
6403var INVALID_RELATIVE_URL = /[/\\][/\\]/;
6404var VALID_PROTOCOLS = ['https:', 'http:'];
6405var DUMMY_HOSTNAME = 'http://test.com';
6406function isSafe(redirectUrl, _a) {
6407 var _b = _a === void 0 ? {} : _a, _c = _b.allowedDomains, allowedDomains = _c === void 0 ? [] : _c, _d = _b.subdomains, subdomains = _d === void 0 ? [] : _d, matchPath = _b.matchPath, requireAbsolute = _b.requireAbsolute, requireSSL = _b.requireSSL;
6408 if (FILE_URI_MATCH.test(redirectUrl)) {
6409 return false;
6410 }
6411 if (redirectUrl.startsWith('/')) {
6412 if (allowedDomains.length > 0 || subdomains.length > 0 || requireAbsolute || requireSSL) {
6413 return false;
6414 }
6415 if (matchPath) {
6416 // Creating a new URL expands the pathname in case of things like `/a/../b`
6417 return pathMatches(new URL(redirectUrl, DUMMY_HOSTNAME), redirectUrl, matchPath);
6418 }
6419 return !INVALID_RELATIVE_URL.test(redirectUrl);
6420 }
6421 var url;
6422 try {
6423 url = new URL(redirectUrl);
6424 }
6425 catch (error) {
6426 return false;
6427 }
6428 if (!VALID_PROTOCOLS.includes(url.protocol)) {
6429 return false;
6430 }
6431 if (requireSSL && url.protocol !== 'https:') {
6432 return false;
6433 }
6434 if (url.username || url.password) {
6435 return false;
6436 }
6437 if (matchPath && !pathMatches(url, redirectUrl, matchPath)) {
6438 return false;
6439 }
6440 if (!hostIsValid(url, allowedDomains, subdomains)) {
6441 return false;
6442 }
6443 return true;
6444}
6445exports.isSafe = isSafe;
6446function hostIsValid(url, allowedDomains, subdomains) {
6447 if (!subdomains.every(function (subdomain) { return subdomain.startsWith('.'); })) {
6448 throw new TypeError('Subdomains must begin with .');
6449 }
6450 var hostname = url.hostname;
6451 return ((allowedDomains.length === 0 && subdomains.length === 0) ||
6452 allowedDomains.includes(hostname) ||
6453 subdomains.some(function (subdomain) { return hostname.endsWith(subdomain); }));
6454}
6455function pathMatches(url, originalUrl, matcher) {
6456 var pathname = url.pathname;
6457 // Gets just the unresolve pathname, i.e., `http://foo.com/a/../b => /a/../b
6458 var originalPathname = originalUrl.replace(url.origin, '').split('?')[0];
6459 return typeof matcher === 'string'
6460 ? pathname === matcher && originalPathname === matcher
6461 : matcher.test(pathname) && matcher.test(originalPathname);
6462}
6463function makeSafe(url, fallback, options) {
6464 return isSafe(url, options) ? encodeURI(url) : fallback;
6465}
6466exports.makeSafe = makeSafe;
6467
6468
6469/***/ }),
6470/* 72 */
6471/***/ (function(module, exports, __webpack_require__) {
6472
6473"use strict";
6474
6475var __assign = (this && this.__assign) || function () {
6476 __assign = Object.assign || function(t) {
6477 for (var s, i = 1, n = arguments.length; i < n; i++) {
6478 s = arguments[i];
6479 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6480 t[p] = s[p];
6481 }
6482 return t;
6483 };
6484 return __assign.apply(this, arguments);
6485};
6486var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6487 if (k2 === undefined) k2 = k;
6488 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6489}) : (function(o, m, k, k2) {
6490 if (k2 === undefined) k2 = k;
6491 o[k2] = m[k];
6492}));
6493var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
6494 Object.defineProperty(o, "default", { enumerable: true, value: v });
6495}) : function(o, v) {
6496 o["default"] = v;
6497});
6498var __importStar = (this && this.__importStar) || function (mod) {
6499 if (mod && mod.__esModule) return mod;
6500 var result = {};
6501 if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
6502 __setModuleDefault(result, mod);
6503 return result;
6504};
6505Object.defineProperty(exports, "__esModule", { value: true });
6506exports.validateAction = exports.getSectionSchema = exports.matchesAbsolutePath = void 0;
6507var History = __importStar(__webpack_require__(26));
6508var Redirect = __importStar(__webpack_require__(13));
6509var type_validate_1 = __webpack_require__(2);
6510var utils_1 = __webpack_require__(3);
6511function matchesAbsolutePath(value) {
6512 return value.match('^https?://')
6513 ? undefined
6514 : [
6515 {
6516 value: value,
6517 error: 'invalid_absolute_url',
6518 message: 'expected string to start with `https://` or `http://`',
6519 },
6520 ];
6521}
6522exports.matchesAbsolutePath = matchesAbsolutePath;
6523function getSectionSchema(payload) {
6524 var isProductVariant = payload &&
6525 payload.section &&
6526 payload.section.resource &&
6527 payload.section.name === Redirect.ResourceType.Product;
6528 var resourceSchema = {
6529 create: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6530 id: type_validate_1.makeOptional(type_validate_1.matchesString()),
6531 };
6532 var productVariantSchema = __assign(__assign({}, resourceSchema), { variant: type_validate_1.makeOptional(type_validate_1.matchesObject(resourceSchema)) });
6533 return type_validate_1.matchesObject({
6534 section: type_validate_1.matchesObject({
6535 name: type_validate_1.matchesEnum(Redirect.ResourceType),
6536 resource: type_validate_1.makeOptional(type_validate_1.matchesObject(isProductVariant ? productVariantSchema : resourceSchema)),
6537 }),
6538 });
6539}
6540exports.getSectionSchema = getSectionSchema;
6541function validateAction(action) {
6542 var newContextSchema = type_validate_1.matchesObject({ newContext: type_validate_1.makeOptional(type_validate_1.matchesBoolean()) });
6543 var actionType = Redirect.Action;
6544 var schema;
6545 switch (action.type) {
6546 case History.Action.PUSH:
6547 case History.Action.REPLACE:
6548 actionType = History.Action;
6549 schema = utils_1.relativePathSchema;
6550 break;
6551 case Redirect.Action.APP:
6552 schema = utils_1.relativePathSchema;
6553 break;
6554 case Redirect.Action.REMOTE:
6555 schema = type_validate_1.composeSchemas(type_validate_1.matchesObject({
6556 url: type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) { return matchesAbsolutePath(value); }),
6557 }), newContextSchema);
6558 break;
6559 case Redirect.Action.ADMIN_PATH:
6560 schema = type_validate_1.composeSchemas(utils_1.relativePathSchema, newContextSchema);
6561 break;
6562 case Redirect.Action.ADMIN_SECTION:
6563 schema = type_validate_1.composeSchemas(getSectionSchema(action.payload), newContextSchema);
6564 break;
6565 }
6566 return type_validate_1.validate(action, utils_1.createActionValidator(actionType, schema));
6567}
6568exports.validateAction = validateAction;
6569
6570
6571/***/ }),
6572/* 73 */
6573/***/ (function(module, exports, __webpack_require__) {
6574
6575"use strict";
6576
6577Object.defineProperty(exports, "__esModule", { value: true });
6578exports.Action = exports.validateAction = void 0;
6579var Print_1 = __webpack_require__(14);
6580Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Print_1.Action; } });
6581var type_validate_1 = __webpack_require__(2);
6582var utils_1 = __webpack_require__(3);
6583function validateAction(action) {
6584 return type_validate_1.validate(action, utils_1.createActionValidator(Print_1.Action));
6585}
6586exports.validateAction = validateAction;
6587
6588
6589/***/ }),
6590/* 74 */
6591/***/ (function(module, exports, __webpack_require__) {
6592
6593"use strict";
6594
6595Object.defineProperty(exports, "__esModule", { value: true });
6596exports.Action = exports.validateAction = exports.validateProps = void 0;
6597var ResourcePicker_1 = __webpack_require__(27);
6598Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return ResourcePicker_1.Action; } });
6599var type_validate_1 = __webpack_require__(2);
6600var utils_1 = __webpack_require__(3);
6601var resourceSelectionSchema = type_validate_1.matchesArray(type_validate_1.matchesObject({
6602 id: type_validate_1.matchesString(),
6603}));
6604var resourcePickerOptions = type_validate_1.matchesObject({
6605 initialQuery: type_validate_1.makeOptional(type_validate_1.matchesString()),
6606 initialSelectionIds: type_validate_1.makeOptional(resourceSelectionSchema),
6607 selectMultiple: type_validate_1.makeOptional(type_validate_1.oneOf(type_validate_1.matchesBoolean(), type_validate_1.matchesPositiveInteger())),
6608 showHidden: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6609 showVariants: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6610 showDraft: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6611 showArchived: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6612 showDraftBadge: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6613 showArchivedBadge: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6614 actionVerb: type_validate_1.makeOptional(type_validate_1.matchesEnum(ResourcePicker_1.ActionVerb)),
6615});
6616var resourcePickerActionSchema = type_validate_1.matchesObject({
6617 resourceType: type_validate_1.matchesEnum(ResourcePicker_1.ResourceType),
6618 options: type_validate_1.makeOptional(resourcePickerOptions),
6619});
6620var selectionSchema = type_validate_1.matchesObject({
6621 selection: resourceSelectionSchema,
6622});
6623function validateProps(props) {
6624 return type_validate_1.validate(props, resourcePickerOptions);
6625}
6626exports.validateProps = validateProps;
6627function validateAction(action) {
6628 switch (action.type) {
6629 case ResourcePicker_1.Action.UPDATE:
6630 case ResourcePicker_1.Action.OPEN:
6631 return type_validate_1.validate(action, utils_1.createActionValidator(ResourcePicker_1.Action, resourcePickerActionSchema, false, true));
6632 case ResourcePicker_1.Action.SELECT:
6633 return type_validate_1.validate(action, utils_1.createActionValidator(ResourcePicker_1.Action, selectionSchema, true, true));
6634 case ResourcePicker_1.Action.CANCEL:
6635 case ResourcePicker_1.Action.CLOSE:
6636 default:
6637 return type_validate_1.validate(action, utils_1.createActionValidator(ResourcePicker_1.Action));
6638 }
6639}
6640exports.validateAction = validateAction;
6641
6642
6643/***/ }),
6644/* 75 */
6645/***/ (function(module, exports, __webpack_require__) {
6646
6647"use strict";
6648
6649Object.defineProperty(exports, "__esModule", { value: true });
6650exports.Action = exports.validateAction = exports.validateProps = exports.toastSchema = void 0;
6651var Toast_1 = __webpack_require__(9);
6652Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Toast_1.Action; } });
6653var type_validate_1 = __webpack_require__(2);
6654var utils_1 = __webpack_require__(3);
6655exports.toastSchema = type_validate_1.matchesObject({
6656 message: type_validate_1.matchesString(),
6657 duration: type_validate_1.matchesPositiveInteger(),
6658 isError: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
6659});
6660function validateProps(props) {
6661 return type_validate_1.validate(props, exports.toastSchema);
6662}
6663exports.validateProps = validateProps;
6664function validateAction(action) {
6665 switch (action.type) {
6666 case Toast_1.Action.SHOW:
6667 return type_validate_1.validate(action, utils_1.createActionValidator(Toast_1.Action, exports.toastSchema, true));
6668 default:
6669 return type_validate_1.validate(action, utils_1.createActionValidator(Toast_1.Action));
6670 }
6671}
6672exports.validateAction = validateAction;
6673
6674
6675/***/ }),
6676/* 76 */
6677/***/ (function(module, exports, __webpack_require__) {
6678
6679"use strict";
6680
6681var __assign = (this && this.__assign) || function () {
6682 __assign = Object.assign || function(t) {
6683 for (var s, i = 1, n = arguments.length; i < n; i++) {
6684 s = arguments[i];
6685 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6686 t[p] = s[p];
6687 }
6688 return t;
6689 };
6690 return __assign.apply(this, arguments);
6691};
6692Object.defineProperty(exports, "__esModule", { value: true });
6693exports.Action = exports.validateAction = exports.validateProps = exports.titleBarSchema = void 0;
6694var TitleBar_1 = __webpack_require__(29);
6695Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return TitleBar_1.Action; } });
6696var Button_1 = __webpack_require__(4);
6697var ButtonGroup_1 = __webpack_require__(7);
6698var type_validate_1 = __webpack_require__(2);
6699var utils_1 = __webpack_require__(3);
6700var button_1 = __webpack_require__(11);
6701var buttonGroup_1 = __webpack_require__(39);
6702var buttonSchemaWithId = type_validate_1.composeSchemas(button_1.buttonSchema, type_validate_1.matchesObject({
6703 id: type_validate_1.matchesString(),
6704}));
6705exports.titleBarSchema = type_validate_1.matchesObject({
6706 breadcrumbs: type_validate_1.makeOptional(button_1.buttonSchema),
6707 title: type_validate_1.makeOptional(type_validate_1.matchesString()),
6708 buttons: type_validate_1.makeOptional(type_validate_1.matchesObject({
6709 primary: type_validate_1.makeOptional(buttonSchemaWithId),
6710 secondary: type_validate_1.makeOptional(type_validate_1.matchesArray(type_validate_1.composeSchemas(buttonSchemaWithId, type_validate_1.matchesObject({
6711 buttons: type_validate_1.makeOptional(type_validate_1.matchesArray(buttonSchemaWithId)),
6712 })))),
6713 })),
6714});
6715function validateProps(props) {
6716 return type_validate_1.validate(props, exports.titleBarSchema);
6717}
6718exports.validateProps = validateProps;
6719function validateAction(action) {
6720 switch (action.type) {
6721 default:
6722 case TitleBar_1.Action.UPDATE:
6723 return type_validate_1.validate(action, utils_1.createActionValidator(TitleBar_1.Action, exports.titleBarSchema, true, false));
6724 case TitleBar_1.Action.BUTTON_CLICK:
6725 case TitleBar_1.Action.BREADCRUMBS_CLICK:
6726 return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.CLICK }));
6727 case TitleBar_1.Action.BUTTON_UPDATE:
6728 case TitleBar_1.Action.BREADCRUMBS_UPDATE:
6729 return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.UPDATE }));
6730 case TitleBar_1.Action.BUTTON_GROUP_UPDATE:
6731 return buttonGroup_1.validateAction(__assign(__assign({}, action), { type: ButtonGroup_1.Action.UPDATE }));
6732 }
6733}
6734exports.validateAction = validateAction;
6735
6736
6737/***/ }),
6738/* 77 */
6739/***/ (function(module, exports, __webpack_require__) {
6740
6741"use strict";
6742
6743Object.defineProperty(exports, "__esModule", { value: true });
6744exports.validateAction = exports.validateProps = void 0;
6745var NavigationMenu_1 = __webpack_require__(31);
6746var ChannelMenu_1 = __webpack_require__(32);
6747var type_validate_1 = __webpack_require__(2);
6748var utils_1 = __webpack_require__(3);
6749var helper_1 = __webpack_require__(0);
6750var link_1 = __webpack_require__(40);
6751var linkOptionsValidator = type_validate_1.matchesObject({ id: type_validate_1.matchesString(), options: link_1.linkPropsSchema });
6752function activeLinkError(value) {
6753 return [
6754 {
6755 error: 'invalid_active_item',
6756 value: value,
6757 message: 'expected active item to exist in menu items',
6758 },
6759 ];
6760}
6761function getOptionsSchema(options) {
6762 var baseSchema = type_validate_1.matchesObject({
6763 items: type_validate_1.makeOptional(type_validate_1.matchesArray(linkOptionsValidator)),
6764 active: type_validate_1.makeOptional(linkOptionsValidator),
6765 });
6766 var items = options.items, active = options.active;
6767 if (items && active) {
6768 var activeItemSchema = type_validate_1.matchesObject({
6769 active: type_validate_1.composeSchemas(linkOptionsValidator, function (value) {
6770 return items.find(function (item) { return item.id === value.id; }) ? undefined : activeLinkError(value);
6771 }),
6772 });
6773 return type_validate_1.composeSchemas(baseSchema, activeItemSchema);
6774 }
6775 return baseSchema;
6776}
6777function getPayloadSchema(payload) {
6778 var baseSchema = type_validate_1.matchesObject({
6779 items: type_validate_1.makeOptional(type_validate_1.matchesArray(link_1.linkActionSchema)),
6780 active: type_validate_1.makeOptional(type_validate_1.matchesString()),
6781 });
6782 var items = payload.items, active = payload.active;
6783 if (items && active) {
6784 var activeItemSchema = type_validate_1.matchesObject({
6785 active: type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) {
6786 return items.find(function (item) { return item.id === value; })
6787 ? undefined
6788 : activeLinkError(value);
6789 }),
6790 });
6791 return type_validate_1.composeSchemas(baseSchema, activeItemSchema);
6792 }
6793 return baseSchema;
6794}
6795function validateProps(props) {
6796 var result = type_validate_1.validate(props, getOptionsSchema(props));
6797 return result;
6798}
6799exports.validateProps = validateProps;
6800function validateAction(action) {
6801 var actionType = NavigationMenu_1.Action;
6802 if (helper_1.findMatchInEnum(ChannelMenu_1.Action, action.type)) {
6803 actionType = ChannelMenu_1.Action;
6804 }
6805 return type_validate_1.validate(action, utils_1.createActionValidator(actionType, getPayloadSchema(action.payload), true, false));
6806}
6807exports.validateAction = validateAction;
6808
6809
6810/***/ })
6811/******/ ]);
6812});
\No newline at end of file