PageSourceSearch

https://www.xn--j1adddg.xn--p1ai/bitrix/js/main/popup/dist/main.popup.bundle.js?1601381627103976

js xn--j1adddg.xn--p1ai collected 2026-10-02 20:16:37 UTC 103,976 bytes, 3,491 lines download raw bytes

1this.BX = this.BX || {};
2(function (exports,main_core_events,main_core) {
3	'use strict';
4
5	/**
6	 * @memberOf BX.Main.Popup
7	 * @deprecated use BX.UI.Button
8	 */
9	var Button = /*#__PURE__*/function () {
10	  function Button(params) {
11	    babelHelpers.classCallCheck(this, Button);
12	    this.popupWindow = null;
13	    this.params = params || {};
14	    this.text = this.params.text || '';
15	    this.id = this.params.id || '';
16	    this.className = this.params.className || '';
17	    this.events = this.params.events || {};
18	    this.contextEvents = {};
19
20	    for (var eventName in this.events) {
21	      if (main_core.Type.isFunction(this.events[eventName])) {
22	        this.contextEvents[eventName] = this.events[eventName].bind(this);
23	      }
24	    }
25
26	    this.buttonNode = main_core.Dom.create('span', {
27	      props: {
28	        className: 'popup-window-button' + (this.className.length > 0 ? ' ' + this.className : ''),
29	        id: this.id
30	      },
31	      events: this.contextEvents,
32	      text: this.text
33	    });
34	  }
35
36	  babelHelpers.createClass(Button, [{
37	    key: "render",
38	    value: function render() {
39	      return this.buttonNode;
40	    }
41	  }, {
42	    key: "getId",
43	    value: function getId() {
44	      return this.id;
45	    }
46	  }, {
47	    key: "getContainer",
48	    value: function getContainer() {
49	      return this.buttonNode;
50	    }
51	  }, {
52	    key: "getName",
53	    value: function getName() {
54	      return this.text;
55	    }
56	  }, {
57	    key: "setName",
58	    value: function setName(name) {
59	      this.text = name || '';
60
61	      if (this.buttonNode) {
62	        main_core.Dom.clean(this.buttonNode);
63	        main_core.Dom.adjust(this.buttonNode, {
64	          text: this.text
65	        });
66	      }
67	    }
68	  }, {
69	    key: "setClassName",
70	    value: function setClassName(className) {
71	      if (this.buttonNode) {
72	        if (main_core.Type.isString(this.className) && this.className !== '') {
73	          main_core.Dom.removeClass(this.buttonNode, this.className);
74	        }
75
76	        main_core.Dom.addClass(this.buttonNode, className);
77	      }
78
79	      this.className = className;
80	    }
81	  }, {
82	    key: "addClassName",
83	    value: function addClassName(className) {
84	      if (this.buttonNode) {
85	        main_core.Dom.addClass(this.buttonNode, className);
86	        this.className = this.buttonNode.className;
87	      }
88	    }
89	  }, {
90	    key: "removeClassName",
91	    value: function removeClassName(className) {
92	      if (this.buttonNode) {
93	        main_core.Dom.removeClass(this.buttonNode, className);
94	        this.className = this.buttonNode.className;
95	      }
96	    }
97	  }]);
98	  return Button;
99	}();
100
101	function _templateObject8() {
102	  var data = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div class=\"popup-window-overlay\" id=\"popup-window-overlay-", "\"></div>\n\t\t\t\t"]);
103
104	  _templateObject8 = function _templateObject8() {
105	    return data;
106	  };
107
108	  return data;
109	}
110
111	function _templateObject7() {
112	  var data = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div class=\"popup-window-resize\" onmousedown=\"", "\"></div>\n\t\t\t\t"]);
113
114	  _templateObject7 = function _templateObject7() {
115	    return data;
116	  };
117
118	  return data;
119	}
120
121	function _templateObject6() {
122	  var data = babelHelpers.taggedTemplateLiteral(["<div class=\"", " ", "-", "\"></div>"]);
123
124	  _templateObject6 = function _templateObject6() {
125	    return data;
126	  };
127
128	  return data;
129	}
130
131	function _templateObject5() {
132	  var data = babelHelpers.taggedTemplateLiteral(["<div class=\"popup-window-buttons\">", "</div>"]);
133
134	  _templateObject5 = function _templateObject5() {
135	    return data;
136	  };
137
138	  return data;
139	}
140
141	function _templateObject4() {
142	  var data = babelHelpers.taggedTemplateLiteral(["<div \n\t\t\t\tclass=\"", "\" \n\t\t\t\tid=\"", "\"\n\t\t\t\tstyle=\"display: none; position: absolute; left: 0; top: 0; z-index: ", "\"\n\t\t\t>", "</div>"]);
143
144	  _templateObject4 = function _templateObject4() {
145	    return data;
146	  };
147
148	  return data;
149	}
150
151	function _templateObject3() {
152	  var data = babelHelpers.taggedTemplateLiteral(["<div id=\"popup-window-content-", "\" class=\"popup-window-content\"></div>"]);
153
154	  _templateObject3 = function _templateObject3() {
155	    return data;
156	  };
157
158	  return data;
159	}
160
161	function _templateObject2() {
162	  var data = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<span class=\"", "\" onclick=\"", "\"></span>\n\t\t\t"]);
163
164	  _templateObject2 = function _templateObject2() {
165	    return data;
166	  };
167
168	  return data;
169	}
170
171	function _templateObject() {
172	  var data = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"popup-window-titlebar\" id=\"popup-window-titlebar-", "\"></div>\n\t\t\t"]);
173
174	  _templateObject = function _templateObject() {
175	    return data;
176	  };
177
178	  return data;
179	}
180	var aliases = {
181	  onPopupWindowInit: {
182	    namespace: 'BX.Main.Popup',
183	    eventName: 'onInit'
184	  },
185	  onPopupWindowIsInitialized: {
186	    namespace: 'BX.Main.Popup',
187	    eventName: 'onAfterInit'
188	  },
189	  onPopupFirstShow: {
190	    namespace: 'BX.Main.Popup',
191	    eventName: 'onFirstShow'
192	  },
193	  onPopupShow: {
194	    namespace: 'BX.Main.Popup',
195	    eventName: 'onShow'
196	  },
197	  onAfterPopupShow: {
198	    namespace: 'BX.Main.Popup',
199	    eventName: 'onAfterShow'
200	  },
201	  onPopupClose: {
202	    namespace: 'BX.Main.Popup',
203	    eventName: 'onClose'
204	  },
205	  onPopupAfterClose: {
206	    namespace: 'BX.Main.Popup',
207	    eventName: 'onAfterClose'
208	  },
209	  onPopupDestroy: {
210	    namespace: 'BX.Main.Popup',
211	    eventName: 'onDestroy'
212	  },
213	  onPopupFullscreenLeave: {
214	    namespace: 'BX.Main.Popup',
215	    eventName: 'onFullscreenLeave'
216	  },
217	  onPopupFullscreenEnter: {
218	    namespace: 'BX.Main.Popup',
219	    eventName: 'onFullscreenEnter'
220	  },
221	  onPopupDragStart: {
222	    namespace: 'BX.Main.Popup',
223	    eventName: 'onDragStart'
224	  },
225	  onPopupDrag: {
226	    namespace: 'BX.Main.Popup',
227	    eventName: 'onDrag'
228	  },
229	  onPopupDragEnd: {
230	    namespace: 'BX.Main.Popup',
231	    eventName: 'onDragEnd'
232	  },
233	  onPopupResizeStart: {
234	    namespace: 'BX.Main.Popup',
235	    eventName: 'onResizeStart'
236	  },
237	  onPopupResize: {
238	    namespace: 'BX.Main.Popup',
239	    eventName: 'onResize'
240	  },
241	  onPopupResizeEnd: {
242	    namespace: 'BX.Main.Popup',
243	    eventName: 'onResizeEnd'
244	  }
245	};
246	main_core_events.EventEmitter.registerAliases(aliases);
247	/**
248	 * @memberof BX.Main
249	 */
250
251	var Popup = /*#__PURE__*/function (_EventEmitter) {
252	  babelHelpers.inherits(Popup, _EventEmitter);
253	  babelHelpers.createClass(Popup, null, [{
254	    key: "setOptions",
255
256	    /**
257	     * @private
258	     */
259
260	    /**
261	     * @private
262	     */
263	    value: function setOptions(options) {
264	      if (!main_core.Type.isPlainObject(options)) {
265	        return;
266	      }
267
268	      for (var option in options) {
269	        this.options[option] = options[option];
270	      }
271	    }
272	  }, {
273	    key: "getOption",
274	    value: function getOption(option, defaultValue) {
275	      if (!main_core.Type.isUndefined(this.options[option])) {
276	        return this.options[option];
277	      } else if (!main_core.Type.isUndefined(defaultValue)) {
278	        return defaultValue;
279	      } else {
280	        return this.defaultOptions[option];
281	      }
282	    }
283	  }]);
284
285	  function Popup(options) {
286	    var _this;
287
288	    babelHelpers.classCallCheck(this, Popup);
289	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Popup).call(this));
290
291	    _this.setEventNamespace('BX.Main.Popup');
292
293	    var _arguments = Array.prototype.slice.call(arguments),
294	        popupId = _arguments[0],
295	        bindElement = _arguments[1],
296	        params = _arguments[2]; //compatible arguments
297
298
299	    _this.compatibleMode = params && main_core.Type.isBoolean(params.compatibleMode) ? params.compatibleMode : true;
300
301	    if (main_core.Type.isPlainObject(options) && !bindElement && !params) {
302	      params = options;
303	      popupId = options.id;
304	      bindElement = options.bindElement;
305	      _this.compatibleMode = false;
306	    }
307
308	    params = params || {};
309	    _this.params = params;
310
311	    if (!main_core.Type.isStringFilled(popupId)) {
312	      popupId = 'popup-window-' + main_core.Text.getRandom().toLowerCase();
313	    }
314
315	    _this.emit('onInit', new main_core_events.BaseEvent({
316	      compatData: [popupId, bindElement, params]
317	    }));
318	    /**
319	     * @private
320	     */
321
322
323	    _this.uniquePopupId = popupId;
324	    _this.params.zIndex = main_core.Type.isNumber(params.zIndex) ? parseInt(params.zIndex) : 0;
325	    _this.params.zIndexAbsolute = main_core.Type.isNumber(params.zIndexAbsolute) ? parseInt(params.zIndexAbsolute) : 0;
326	    _this.buttons = params.buttons && main_core.Type.isArray(params.buttons) ? params.buttons : [];
327	    _this.offsetTop = Popup.getOption('offsetTop');
328	    _this.offsetLeft = Popup.getOption('offsetLeft');
329	    _this.firstShow = false;
330	    _this.bordersWidth = 20;
331	    _this.bindElementPos = null;
332	    _this.closeIcon = null;
333	    _this.resizeIcon = null;
334	    _this.angle = null;
335	    _this.overlay = null;
336	    _this.titleBar = null;
337	    _this.bindOptions = babelHelpers.typeof(params.bindOptions) === 'object' ? params.bindOptions : {};
338	    _this.autoHide = params.autoHide === true;
339	    _this.autoHideHandler = main_core.Type.isFunction(params.autoHideHandler) ? params.autoHideHandler : null;
340	    _this.handleAutoHide = _this.handleAutoHide.bind(babelHelpers.assertThisInitialized(_this));
341	    _this.handleOverlayClick = _this.handleOverlayClick.bind(babelHelpers.assertThisInitialized(_this));
342	    _this.isAutoHideBinded = false;
343	    _this.closeByEsc = params.closeByEsc === true;
344	    _this.isCloseByEscBinded = false;
345	    _this.cacheable = true;
346	    _this.destroyed = false;
347	    _this.width = null;
348	    _this.height = null;
349	    _this.minWidth = null;
350	    _this.minHeight = null;
351	    _this.maxWidth = null;
352	    _this.maxHeight = null;
353	    _this.padding = null;
354	    _this.contentPadding = null;
355	    _this.background = null;
356	    _this.contentBackground = null;
357	    _this.appendContainer = document.body;
358	    _this.dragOptions = {
359	      cursor: '',
360	      callback: function callback() {},
361	      eventName: ''
362	    };
363	    _this.dragged = false;
364	    _this.dragPageX = 0;
365	    _this.dragPageY = 0;
366	    _this.animationShowClassName = null;
367	    _this.animationCloseClassName = null;
368	    _this.animationCloseEventType = null;
369	    _this.handleDocumentMouseMove = _this.handleDocumentMouseMove.bind(babelHelpers.assertThisInitialized(_this));
370	    _this.handleDocumentMouseUp = _this.handleDocumentMouseUp.bind(babelHelpers.assertThisInitialized(_this));
371	    _this.handleDocumentKeyUp = _this.handleDocumentKeyUp.bind(babelHelpers.assertThisInitialized(_this));
372	    _this.handleResizeWindow = _this.handleResizeWindow.bind(babelHelpers.assertThisInitialized(_this));
373	    _this.handleResize = _this.handleResize.bind(babelHelpers.assertThisInitialized(_this));
374	    _this.handleMove = _this.handleMove.bind(babelHelpers.assertThisInitialized(_this));
375	    _this.onTitleMouseDown = _this.onTitleMouseDown.bind(babelHelpers.assertThisInitialized(_this));
376	    _this.handleFullScreen = _this.handleFullScreen.bind(babelHelpers.assertThisInitialized(_this));
377
378	    _this.subscribeFromOptions(params.events);
379
380	    var popupClassName = 'popup-window';
381
382	    if (params.contentColor && main_core.Type.isStringFilled(params.contentColor)) {
383	      popupClassName += ' popup-window-content-' + params.contentColor;
384	    }
385
386	    if (params.titleBar) {
387	      popupClassName += ' popup-window-with-titlebar';
388	    }
389
390	    if (params.className && main_core.Type.isStringFilled(params.className)) {
391	      popupClassName += ' ' + params.className;
392	    }
393
394	    if (params.darkMode) {
395	      popupClassName += ' popup-window-dark';
396	    }
397
398	    if (params.titleBar) {
399	      _this.titleBar = main_core.Tag.render(_templateObject(), popupId);
400	    }
401
402	    if (params.closeIcon) {
403	      var className = 'popup-window-close-icon' + (params.titleBar ? ' popup-window-titlebar-close-icon' : '');
404	      _this.closeIcon = main_core.Tag.render(_templateObject2(), className, _this.handleCloseIconClick.bind(babelHelpers.assertThisInitialized(_this)));
405
406	      if (main_core.Type.isPlainObject(params.closeIcon)) {
407	        main_core.Dom.style(_this.closeIcon, params.closeIcon);
408	      }
409	    }
410	    /**
411	     * @private
412	     */
413
414
415	    _this.contentContainer = main_core.Tag.render(_templateObject3(), popupId);
416	    /**
417	     * @private
418	     */
419
420	    _this.popupContainer = main_core.Tag.render(_templateObject4(), popupClassName, popupId, _this.getZindex(), [_this.titleBar, _this.contentContainer, _this.closeIcon]);
421
422	    _this.appendContainer.appendChild(_this.popupContainer);
423
424	    _this.buttonsContainer = null;
425
426	    if (params.angle) {
427	      _this.setAngle(params.angle);
428	    }
429
430	    if (params.overlay) {
431	      _this.setOverlay(params.overlay);
432	    }
433
434	    _this.setOffset(params);
435
436	    _this.setBindElement(bindElement);
437
438	    _this.setTitleBar(params.titleBar);
439
440	    _this.setContent(params.content);
441
442	    _this.setButtons(params.buttons);
443
444	    _this.setWidth(params.width);
445
446	    _this.setHeight(params.height);
447
448	    _this.setMinWidth(params.minWidth);
449
450	    _this.setMinHeight(params.minHeight);
451
452	    _this.setMaxWidth(params.maxWidth);
453
454	    _this.setMaxHeight(params.maxHeight);
455
456	    _this.setResizeMode(params.resizable);
457
458	    _this.setPadding(params.padding);
459
460	    _this.setContentPadding(params.contentPadding);
461
462	    _this.setBackground(params.background);
463
464	    _this.setContentBackground(params.contentBackground);
465
466	    _this.setAnimation(params.animation);
467
468	    _this.setCacheable(params.cacheable); // Compatibility
469
470
471	    if (params.contentNoPaddings) {
472	      _this.setContentPadding(0);
473	    }
474
475	    if (params.noAllPaddings) {
476	      _this.setPadding(0);
477
478	      _this.setContentPadding(0);
479	    }
480
481	    if (params.bindOnResize !== false) {
482	      main_core.Event.bind(window, 'resize', _this.handleResizeWindow);
483	    }
484
485	    _this.emit('onAfterInit', new main_core_events.BaseEvent({
486	      compatData: [popupId, babelHelpers.assertThisInitialized(_this)]
487	    }));
488
489	    return _this;
490	  }
491	  /**
492	   * @private
493	   */
494
495
496	  babelHelpers.createClass(Popup, [{
497	    key: "subscribeFromOptions",
498	    value: function subscribeFromOptions(events) {
499	      babelHelpers.get(babelHelpers.getPrototypeOf(Popup.prototype), "subscribeFromOptions", this).call(this, events, aliases);
500	    }
501	  }, {
502	    key: "getId",
503	    value: function getId() {
504	      return this.uniquePopupId;
505	    }
506	  }, {
507	    key: "isCompatibleMode",
508	    value: function isCompatibleMode() {
509	      return this.compatibleMode;
510	    }
511	  }, {
512	    key: "setContent",
513	    value: function setContent(content) {
514	      if (!this.contentContainer || !content) {
515	        return;
516	      }
517
518	      if (main_core.Type.isElementNode(content)) {
519	        main_core.Dom.clean(this.contentContainer);
520	        var hasParent = main_core.Type.isDomNode(content.parentNode);
521	        this.contentContainer.appendChild(content);
522
523	        if (this.isCompatibleMode() || hasParent) {
524	          content.style.display = 'block';
525	        }
526	      } else if (main_core.Type.isString(content)) {
527	        this.contentContainer.innerHTML = content;
528	      } else {
529	        this.contentContainer.innerHTML = '&nbsp;';
530	      }
531	    }
532	  }, {
533	    key: "setButtons",
534	    value: function setButtons(buttons) {
535	      this.buttons = buttons && main_core.Type.isArray(buttons) ? buttons : [];
536
537	      if (this.buttonsContainer) {
538	        main_core.Dom.remove(this.buttonsContainer);
539	      }
540
541	      var ButtonClass = main_core.Reflection.getClass('BX.UI.Button');
542
543	      if (this.buttons.length > 0 && this.contentContainer) {
544	        var newButtons = [];
545
546	        for (var i = 0; i < this.buttons.length; i++) {
547	          var button = this.buttons[i];
548
549	          if (button instanceof Button) {
550	            button.popupWindow = this;
551	            newButtons.push(button.render());
552	          } else if (ButtonClass && button instanceof ButtonClass) {
553	            button.setContext(this);
554	            newButtons.push(button.render());
555	          }
556	        }
557
558	        this.buttonsContainer = this.contentContainer.parentNode.appendChild(main_core.Tag.render(_templateObject5(), newButtons));
559	      }
560	    }
561	  }, {
562	    key: "getButtons",
563	    value: function getButtons() {
564	      return this.buttons;
565	    }
566	  }, {
567	    key: "getButton",
568	    value: function getButton(id) {
569	      for (var i = 0; i < this.buttons.length; i++) {
570	        var button = this.buttons[i];
571
572	        if (button.getId() === id) {
573	          return button;
574	        }
575	      }
576
577	      return null;
578	    }
579	  }, {
580	    key: "setBindElement",
581	    value: function setBindElement(bindElement) {
582	      if (bindElement === null) {
583	        this.bindElement = null;
584	      } else if (babelHelpers.typeof(bindElement) === 'object') {
585	        if (main_core.Type.isDomNode(bindElement) || main_core.Type.isNumber(bindElement.top) && main_core.Type.isNumber(bindElement.left)) {
586	          this.bindElement = bindElement;
587	        } else if (main_core.Type.isNumber(bindElement.clientX) && main_core.Type.isNumber(bindElement.clientY)) {
588	          this.bindElement = {
589	            left: bindElement.pageX,
590	            top: bindElement.pageY,
591	            bottom: bindElement.pageY
592	          };
593	        }
594	      }
595	    }
596	    /**
597	     * @private
598	     */
599
600	  }, {
601	    key: "getBindElementPos",
602	    value: function getBindElementPos(bindElement) {
603	      if (main_core.Type.isDomNode(bindElement)) {
604	        return main_core.Dom.getPosition(bindElement);
605	      } else if (bindElement && babelHelpers.typeof(bindElement) === 'object') {
606	        if (!main_core.Type.isNumber(bindElement.bottom)) {
607	          bindElement.bottom = bindElement.top;
608	        }
609
610	        return bindElement;
611	      } else {
612	        var windowSize = {
613	          innerWidth: window.innerWidth,
614	          innerHeight: window.innerHeight
615	        };
616	        var windowScroll = {
617	          scrollLeft: window.pageXOffset,
618	          scrollTop: window.pageYOffset
619	        };
620	        var popupWidth = this.getPopupContainer().offsetWidth;
621	        var popupHeight = this.getPopupContainer().offsetHeight;
622	        this.bindOptions.forceTop = true;
623	        return {
624	          left: windowSize.innerWidth / 2 - popupWidth / 2 + windowScroll.scrollLeft,
625	          top: windowSize.innerHeight / 2 - popupHeight / 2 + windowScroll.scrollTop,
626	          bottom: windowSize.innerHeight / 2 - popupHeight / 2 + windowScroll.scrollTop,
627	          //for optimisation purposes
628	          windowSize: windowSize,
629	          windowScroll: windowScroll,
630	          popupWidth: popupWidth,
631	          popupHeight: popupHeight
632	        };
633	      }
634	    }
635	  }, {
636	    key: "setAngle",
637	    value: function setAngle(params) {
638	      if (params === false) {
639	        if (this.angle !== null) {
640	          main_core.Dom.remove(this.angle.element);
641	        }
642
643	        this.angle = null;
644	        return;
645	      }
646
647	      var className = 'popup-window-angly';
648
649	      if (this.angle === null) {
650	        var position = this.bindOptions.position && this.bindOptions.position === 'top' ? 'bottom' : 'top';
651	        var angleMinLeft = Popup.getOption(position === 'top' ? 'angleMinTop' : 'angleMinBottom');
652	        var defaultOffset = main_core.Type.isNumber(params.offset) ? params.offset : 0;
653	        var angleLeftOffset = Popup.getOption('angleLeftOffset', null);
654
655	        if (defaultOffset > 0 && main_core.Type.isNumber(angleLeftOffset)) {
656	          defaultOffset += angleLeftOffset - Popup.defaultOptions.angleLeftOffset;
657	        }
658
659	        this.angle = {
660	          element: main_core.Tag.render(_templateObject6(), className, className, position),
661	          position: position,
662	          offset: 0,
663	          defaultOffset: Math.max(defaultOffset, angleMinLeft) //Math.max(Type.isNumber(params.offset) ? params.offset : 0, angleMinLeft)
664
665	        };
666	        this.getPopupContainer().appendChild(this.angle.element);
667	      }
668
669	      if (babelHelpers.typeof(params) === 'object' && params.position && ['top', 'right', 'bottom', 'left', 'hide'].includes(params.position)) {
670	        main_core.Dom.removeClass(this.angle.element, className + '-' + this.angle.position);
671	        main_core.Dom.addClass(this.angle.element, className + '-' + params.position);
672	        this.angle.position = params.position;
673	      }
674
675	      if (babelHelpers.typeof(params) === 'object' && main_core.Type.isNumber(params.offset)) {
676	        var offset = params.offset;
677	        var minOffset, maxOffset;
678
679	        if (this.angle.position === 'top') {
680	          minOffset = Popup.getOption('angleMinTop');
681	          maxOffset = this.getPopupContainer().offsetWidth - Popup.getOption('angleMaxTop');
682	          maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset;
683	          this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset);
684	          this.angle.element.style.left = this.angle.offset + 'px';
685	          this.angle.element.style.marginLeft = 0;
686	          this.angle.element.style.removeProperty('top');
687	        } else if (this.angle.position === 'bottom') {
688	          minOffset = Popup.getOption('angleMinBottom');
689	          maxOffset = this.getPopupContainer().offsetWidth - Popup.getOption('angleMaxBottom');
690	          maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset;
691	          this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset);
692	          this.angle.element.style.marginLeft = this.angle.offset + 'px';
693	          this.angle.element.style.left = 0;
694	          this.angle.element.style.removeProperty('top');
695	        } else if (this.angle.position === 'right') {
696	          minOffset = Popup.getOption('angleMinRight');
697	          maxOffset = this.getPopupContainer().offsetHeight - Popup.getOption('angleMaxRight');
698	          maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset;
699	          this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset);
700	          this.angle.element.style.top = this.angle.offset + 'px';
701	          this.angle.element.style.removeProperty('left');
702	          this.angle.element.style.removeProperty('margin-left');
703	        } else if (this.angle.position === 'left') {
704	          minOffset = Popup.getOption('angleMinLeft');
705	          maxOffset = this.getPopupContainer().offsetHeight - Popup.getOption('angleMaxLeft');
706	          maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset;
707	          this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset);
708	          this.angle.element.style.top = this.angle.offset + 'px';
709	          this.angle.element.style.removeProperty('left');
710	          this.angle.element.style.removeProperty('margin-left');
711	        }
712	      }
713	    }
714	  }, {
715	    key: "getWidth",
716	    value: function getWidth() {
717	      return this.width;
718	    }
719	  }, {
720	    key: "setWidth",
721	    value: function setWidth(width) {
722	      this.setWidthProperty('width', width);
723	    }
724	  }, {
725	    key: "getHeight",
726	    value: function getHeight() {
727	      return this.height;
728	    }
729	  }, {
730	    key: "setHeight",
731	    value: function setHeight(height) {
732	      this.setHeightProperty('height', height);
733	    }
734	  }, {
735	    key: "getMinWidth",
736	    value: function getMinWidth() {
737	      return this.minWidth;
738	    }
739	  }, {
740	    key: "setMinWidth",
741	    value: function setMinWidth(width) {
742	      this.setWidthProperty('minWidth', width);
743	    }
744	  }, {
745	    key: "getMinHeight",
746	    value: function getMinHeight() {
747	      return this.minHeight;
748	    }
749	  }, {
750	    key: "setMinHeight",
751	    value: function setMinHeight(height) {
752	      this.setHeightProperty('minHeight', height);
753	    }
754	  }, {
755	    key: "getMaxWidth",
756	    value: function getMaxWidth() {
757	      return this.maxWidth;
758	    }
759	  }, {
760	    key: "setMaxWidth",
761	    value: function setMaxWidth(width) {
762	      this.setWidthProperty('maxWidth', width);
763	    }
764	  }, {
765	    key: "getMaxHeight",
766	    value: function getMaxHeight() {
767	      return this.maxHeight;
768	    }
769	  }, {
770	    key: "setMaxHeight",
771	    value: function setMaxHeight(height) {
772	      this.setHeightProperty('maxHeight', height);
773	    }
774	    /**
775	     * @private
776	     */
777
778	  }, {
779	    key: "setWidthProperty",
780	    value: function setWidthProperty(property, width) {
781	      var props = ['width', 'minWidth', 'maxWidth'];
782
783	      if (props.indexOf(property) === -1) {
784	        return;
785	      }
786
787	      if (main_core.Type.isNumber(width) && width >= 0) {
788	        this[property] = width;
789	        this.getResizableContainer().style[property] = width + 'px';
790	        this.getContentContainer().style.overflowX = 'auto';
791	        this.getPopupContainer().classList.add('popup-window-fixed-width');
792
793	        if (this.getTitleContainer() && main_core.Browser.isIE11()) {
794	          this.getTitleContainer().style[property] = width + 'px';
795	        }
796	      } else if (width === null || width === false) {
797	        this[property] = null;
798	        this.getResizableContainer().style.removeProperty(main_core.Text.toKebabCase(property));
799	        var hasOtherProps = props.some(function (prop) {
800	          return this.getResizableContainer().style.getPropertyValue(main_core.Text.toKebabCase(prop)) !== '';
801	        }, this);
802
803	        if (!hasOtherProps) {
804	          this.getContentContainer().style.removeProperty('overflow-x');
805	          this.getPopupContainer().classList.remove('popup-window-fixed-width');
806	        }
807
808	        if (this.getTitleContainer() && main_core.Browser.isIE11()) {
809	          this.getTitleContainer().style.removeProperty(main_core.Text.toKebabCase(property));
810	        }
811	      }
812	    }
813	    /**
814	     * @private
815	     */
816
817	  }, {
818	    key: "setHeightProperty",
819	    value: function setHeightProperty(property, height) {
820	      var props = ['height', 'minHeight', 'maxHeight'];
821
822	      if (props.indexOf(property) === -1) {
823	        return;
824	      }
825
826	      if (main_core.Type.isNumber(height) && height >= 0) {
827	        this[property] = height;
828	        this.getResizableContainer().style[property] = height + 'px';
829	        this.getContentContainer().style.overflowY = 'auto';
830	        this.getPopupContainer().classList.add('popup-window-fixed-height');
831	      } else if (height === null || height === false) {
832	        this[property] = null;
833	        this.getResizableContainer().style.removeProperty(main_core.Text.toKebabCase(property));
834	        var hasOtherProps = props.some(function (prop) {
835	          return this.getResizableContainer().style.getPropertyValue(main_core.Text.toKebabCase(prop)) !== '';
836	        }, this);
837
838	        if (!hasOtherProps) {
839	          this.getContentContainer().style.removeProperty('overflow-y');
840	          this.getPopupContainer().classList.remove('popup-window-fixed-height');
841	        }
842	      }
843	    }
844	  }, {
845	    key: "setPadding",
846	    value: function setPadding(padding) {
847	      if (main_core.Type.isNumber(padding) && padding >= 0) {
848	        this.padding = padding;
849	        this.getPopupContainer().style.padding = padding + 'px';
850	      } else if (padding === null) {
851	        this.padding = null;
852	        this.getPopupContainer().style.removeProperty('padding');
853	      }
854	    }
855	  }, {
856	    key: "getPadding",
857	    value: function getPadding() {
858	      return this.padding;
859	    }
860	  }, {
861	    key: "setContentPadding",
862	    value: function setContentPadding(padding) {
863	      if (main_core.Type.isNumber(padding) && padding >= 0) {
864	        this.contentPadding = padding;
865	        this.getContentContainer().style.padding = padding + 'px';
866	      } else if (padding === null) {
867	        this.contentPadding = null;
868	        this.getContentContainer().style.removeProperty('padding');
869	      }
870	    }
871	  }, {
872	    key: "getContentPadding",
873	    value: function getContentPadding() {
874	      return this.contentPadding;
875	    }
876	  }, {
877	    key: "setBackground",
878	    value: function setBackground(background) {
879	      if (main_core.Type.isStringFilled(background)) {
880	        this.background = background;
881	        this.getPopupContainer().style.background = background;
882	      } else if (background === null) {
883	        this.background = null;
884	        this.getPopupContainer().style.removeProperty('background');
885	      }
886	    }
887	  }, {
888	    key: "getBackground",
889	    value: function getBackground() {
890	      return this.background;
891	    }
892	  }, {
893	    key: "setContentBackground",
894	    value: function setContentBackground(background) {
895	      if (main_core.Type.isStringFilled(background)) {
896	        this.contentBackground = background;
897	        this.getContentContainer().style.background = background;
898	      } else if (background === null) {
899	        this.contentBackground = null;
900	        this.getContentContainer().style.removeProperty('background');
901	      }
902	    }
903	  }, {
904	    key: "getContentBackground",
905	    value: function getContentBackground() {
906	      return this.contentBackground;
907	    }
908	  }, {
909	    key: "isDestroyed",
910	    value: function isDestroyed() {
911	      return this.destroyed;
912	    }
913	  }, {
914	    key: "setCacheable",
915	    value: function setCacheable(cacheable) {
916	      this.cacheable = cacheable !== false;
917	    }
918	  }, {
919	    key: "isCacheable",
920	    value: function isCacheable() {
921	      return this.cacheable;
922	    }
923	  }, {
924	    key: "setResizeMode",
925	    value: function setResizeMode(mode) {
926	      if (mode === true || main_core.Type.isPlainObject(mode)) {
927	        if (!this.resizeIcon) {
928	          this.resizeIcon = main_core.Tag.render(_templateObject7(), this.handleResizeMouseDown.bind(this));
929	          this.getPopupContainer().appendChild(this.resizeIcon);
930	        } //Compatibility
931
932
933	        this.setMinWidth(mode.minWidth);
934	        this.setMinHeight(mode.minHeight);
935	      } else if (mode === false && this.resizeIcon) {
936	        main_core.Dom.remove(this.resizeIcon);
937	        this.resizeIcon = null;
938	      }
939	    }
940	  }, {
941	    key: "getPopupContainer",
942	    value: function getPopupContainer() {
943	      return this.popupContainer;
944	    }
945	  }, {
946	    key: "getContentContainer",
947	    value: function getContentContainer() {
948	      return this.contentContainer;
949	    }
950	  }, {
951	    key: "getResizableContainer",
952	    value: function getResizableContainer() {
953	      return main_core.Browser.isIE11() ? this.getContentContainer() : this.getPopupContainer();
954	    }
955	  }, {
956	    key: "getTitleContainer",
957	    value: function getTitleContainer() {
958	      return this.titleBar;
959	    }
960	    /**
961	     * @private
962	     */
963
964	  }, {
965	    key: "onTitleMouseDown",
966	    value: function onTitleMouseDown(event) {
967	      this._startDrag(event, {
968	        cursor: 'move',
969	        callback: this.handleMove,
970	        eventName: 'Drag'
971	      });
972	    }
973	    /**
974	     * @private
975	     */
976
977	  }, {
978	    key: "handleResizeMouseDown",
979	    value: function handleResizeMouseDown(event) {
980	      this._startDrag(event, {
981	        cursor: 'nwse-resize',
982	        eventName: 'Resize',
983	        callback: this.handleResize
984	      });
985
986	      this.resizeContentPos = main_core.Dom.getPosition(this.getResizableContainer());
987	      this.resizeContentOffset = this.resizeContentPos.left - main_core.Dom.getPosition(this.getPopupContainer()).left;
988	    }
989	    /**
990	     * @private
991	     */
992
993	  }, {
994	    key: "handleResize",
995	    value: function handleResize(offsetX, offsetY, pageX, pageY) {
996	      var width = pageX - this.resizeContentPos.left;
997	      var height = pageY - this.resizeContentPos.top;
998	      var scrollWidth = document.documentElement.scrollWidth;
999
1000	      if (this.resizeContentPos.left + width + this.resizeContentOffset >= scrollWidth) {
1001	        width = scrollWidth - this.resizeContentPos.left - this.resizeContentOffset;
1002	      }
1003
1004	      width = Math.max(width, this.getMinWidth());
1005	      height = Math.max(height, this.getMinHeight());
1006
1007	      if (this.getMaxWidth() !== null) {
1008	        width = Math.min(width, this.getMaxWidth());
1009	      }
1010
1011	      if (this.getMaxHeight() !== null) {
1012	        height = Math.min(height, this.getMaxHeight());
1013	      }
1014
1015	      this.setWidth(width);
1016	      this.setHeight(height);
1017	    }
1018	  }, {
1019	    key: "isTopAngle",
1020	    value: function isTopAngle() {
1021	      return this.angle !== null && this.angle.position === 'top';
1022	    }
1023	  }, {
1024	    key: "isBottomAngle",
1025	    value: function isBottomAngle() {
1026	      return this.angle !== null && this.angle.position === 'bottom';
1027	    }
1028	  }, {
1029	    key: "isTopOrBottomAngle",
1030	    value: function isTopOrBottomAngle() {
1031	      return this.angle !== null && (this.angle.position === 'top' || this.angle.position === 'bottom');
1032	    }
1033	    /**
1034	     * @private
1035	     */
1036
1037	  }, {
1038	    key: "getAngleHeight",
1039	    value: function getAngleHeight() {
1040	      return this.isTopOrBottomAngle() ? Popup.getOption('angleTopOffset') : 0;
1041	    }
1042	  }, {
1043	    key: "setOffset",
1044	    value: function setOffset(params) {
1045	      if (!main_core.Type.isPlainObject(params)) {
1046	        return;
1047	      }
1048
1049	      if (main_core.Type.isNumber(params.offsetLeft)) {
1050	        this.offsetLeft = params.offsetLeft + Popup.getOption('offsetLeft');
1051	      }
1052
1053	      if (main_core.Type.isNumber(params.offsetTop)) {
1054	        this.offsetTop = params.offsetTop + Popup.getOption('offsetTop');
1055	      }
1056	    }
1057	  }, {
1058	    key: "setTitleBar",
1059	    value: function setTitleBar(params) {
1060	      if (!this.titleBar) {
1061	        return;
1062	      }
1063
1064	      if (babelHelpers.typeof(params) === 'object' && main_core.Type.isDomNode(params.content)) {
1065	        this.titleBar.innerHTML = '';
1066	        this.titleBar.appendChild(params.content);
1067	      } else if (typeof params === 'string') {
1068	        this.titleBar.innerHTML = '';
1069	        this.titleBar.appendChild(main_core.Dom.create('span', {
1070	          props: {
1071	            className: 'popup-window-titlebar-text'
1072	          },
1073	          text: params
1074	        }));
1075	      }
1076
1077	      if (this.params.draggable) {
1078	        this.titleBar.style.cursor = 'move';
1079	        main_core.Event.bind(this.titleBar, 'mousedown', this.onTitleMouseDown);
1080	      }
1081	    }
1082	  }, {
1083	    key: "setClosingByEsc",
1084	    value: function setClosingByEsc(enable) {
1085	      enable = main_core.Type.isBoolean(enable) ? enable : true;
1086
1087	      if (enable) {
1088	        this.closeByEsc = true;
1089	        this.bindClosingByEsc();
1090	      } else {
1091	        this.closeByEsc = false;
1092	        this.unbindClosingByEsc();
1093	      }
1094	    }
1095	    /**
1096	     * @private
1097	     */
1098
1099	  }, {
1100	    key: "bindClosingByEsc",
1101	    value: function bindClosingByEsc() {
1102	      if (this.closeByEsc && !this.isCloseByEscBinded) {
1103	        main_core.Event.bind(document, 'keyup', this.handleDocumentKeyUp);
1104	        this.isCloseByEscBinded = true;
1105	      }
1106	    }
1107	    /**
1108	     * @private
1109	     */
1110
1111	  }, {
1112	    key: "unbindClosingByEsc",
1113	    value: function unbindClosingByEsc() {
1114	      if (this.isCloseByEscBinded) {
1115	        main_core.Event.unbind(document, 'keyup', this.handleDocumentKeyUp);
1116	        this.isCloseByEscBinded = false;
1117	      }
1118	    }
1119	  }, {
1120	    key: "setAutoHide",
1121	    value: function setAutoHide(enable) {
1122	      enable = main_core.Type.isBoolean(enable) ? enable : true;
1123
1124	      if (enable) {
1125	        this.autoHide = true;
1126	        this.bindAutoHide();
1127	      } else {
1128	        this.autoHide = false;
1129	        this.unbindAutoHide();
1130	      }
1131	    }
1132	    /**
1133	     * @private
1134	     */
1135
1136	  }, {
1137	    key: "bindAutoHide",
1138	    value: function bindAutoHide() {
1139	      if (this.autoHide && !this.isAutoHideBinded && this.isShown()) {
1140	        this.isAutoHideBinded = true;
1141
1142	        if (this.isCompatibleMode()) {
1143	          main_core.Event.bind(this.getPopupContainer(), 'click', this.handleContainerClick);
1144	        }
1145
1146	        if (this.overlay && this.overlay.element) {
1147	          main_core.Event.bind(this.overlay.element, 'click', this.handleOverlayClick);
1148	        } else {
1149	          if (this.isCompatibleMode()) {
1150	            main_core.Event.bind(document, 'click', this.handleAutoHide);
1151	          } else {
1152	            document.addEventListener('click', this.handleAutoHide, true);
1153	          }
1154	        }
1155	      }
1156	    }
1157	    /**
1158	     * @private
1159	     */
1160
1161	  }, {
1162	    key: "unbindAutoHide",
1163	    value: function unbindAutoHide() {
1164	      if (this.isAutoHideBinded) {
1165	        this.isAutoHideBinded = false;
1166
1167	        if (this.isCompatibleMode()) {
1168	          main_core.Event.unbind(this.getPopupContainer(), 'click', this.handleContainerClick);
1169	        }
1170
1171	        if (this.overlay && this.overlay.element) {
1172	          main_core.Event.unbind(this.overlay.element, 'click', this.handleOverlayClick);
1173	        } else {
1174	          if (this.isCompatibleMode()) {
1175	            main_core.Event.unbind(document, 'click', this.handleAutoHide);
1176	          } else {
1177	            document.removeEventListener('click', this.handleAutoHide, true);
1178	          }
1179	        }
1180	      }
1181	    }
1182	    /**
1183	     * @private
1184	     */
1185
1186	  }, {
1187	    key: "handleAutoHide",
1188	    value: function handleAutoHide(event) {
1189	      if (this.isDestroyed()) {
1190	        return;
1191	      }
1192
1193	      if (this.autoHideHandler !== null) {
1194	        if (this.autoHideHandler(event)) {
1195	          this._tryCloseByEvent(event);
1196	        }
1197	      } else if (event.target !== this.getPopupContainer() && !this.getPopupContainer().contains(event.target)) {
1198	        this._tryCloseByEvent(event);
1199	      }
1200	    }
1201	    /**
1202	     * @private
1203	     */
1204
1205	  }, {
1206	    key: "_tryCloseByEvent",
1207	    value: function _tryCloseByEvent(event) {
1208	      var _this2 = this;
1209
1210	      if (this.isCompatibleMode()) {
1211	        this.tryCloseByEvent(event);
1212	      } else {
1213	        setTimeout(function () {
1214	          _this2.tryCloseByEvent(event);
1215	        }, 0);
1216	      }
1217	    }
1218	    /**
1219	     * @private
1220	     */
1221
1222	  }, {
1223	    key: "tryCloseByEvent",
1224	    value: function tryCloseByEvent(event) {
1225	      if (event.button === 0) {
1226	        this.close();
1227	      }
1228	    }
1229	    /**
1230	     * @private
1231	     */
1232
1233	  }, {
1234	    key: "handleOverlayClick",
1235	    value: function handleOverlayClick(event) {
1236	      this.tryCloseByEvent(event);
1237	      event.stopPropagation();
1238	    }
1239	  }, {
1240	    key: "setOverlay",
1241	    value: function setOverlay(params) {
1242	      if (this.overlay === null) {
1243	        this.overlay = {
1244	          element: main_core.Tag.render(_templateObject8(), this.getId())
1245	        };
1246	        this.adjustOverlayZindex();
1247	        this.resizeOverlay();
1248	        this.appendContainer.appendChild(this.overlay.element);
1249	      }
1250
1251	      if (params && main_core.Type.isNumber(params.opacity) && params.opacity >= 0 && params.opacity <= 100) {
1252	        this.overlay.element.style.opacity = parseFloat(params.opacity / 100).toPrecision(3);
1253	      }
1254
1255	      if (params && params.backgroundColor) {
1256	        this.overlay.element.style.backgroundColor = params.backgroundColor;
1257	      }
1258	    }
1259	  }, {
1260	    key: "removeOverlay",
1261	    value: function removeOverlay() {
1262	      if (this.overlay !== null && this.overlay.element !== null) {
1263	        main_core.Dom.remove(this.overlay.element);
1264	      }
1265
1266	      if (this.overlayTimeout) {
1267	        clearInterval(this.overlayTimeout);
1268	        this.overlayTimeout = null;
1269	      }
1270
1271	      this.overlay = null;
1272	    }
1273	  }, {
1274	    key: "hideOverlay",
1275	    value: function hideOverlay() {
1276	      if (this.overlay !== null && this.overlay.element !== null) {
1277	        if (this.overlayTimeout) {
1278	          clearInterval(this.overlayTimeout);
1279	          this.overlayTimeout = null;
1280	        }
1281
1282	        this.overlay.element.style.display = 'none';
1283	      }
1284	    }
1285	  }, {
1286	    key: "showOverlay",
1287	    value: function showOverlay() {
1288	      var _this3 = this;
1289
1290	      if (this.overlay !== null && this.overlay.element !== null) {
1291	        this.overlay.element.style.display = 'block';
1292	        var popupHeight = this.getPopupContainer().offsetHeight;
1293	        this.overlayTimeout = setInterval(function () {
1294	          if (popupHeight !== _this3.getPopupContainer().offsetHeight) {
1295	            _this3.resizeOverlay();
1296
1297	            popupHeight = _this3.getPopupContainer().offsetHeight;
1298	          }
1299	        }, 1000);
1300	      }
1301	    }
1302	  }, {
1303	    key: "resizeOverlay",
1304	    value: function resizeOverlay() {
1305	      if (this.overlay !== null && this.overlay.element !== null) {
1306	        var scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight);
1307	        this.overlay.element.style.width = document.documentElement.scrollWidth + 'px';
1308	        this.overlay.element.style.height = scrollHeight + 'px';
1309	      }
1310	    }
1311	  }, {
1312	    key: "getZindex",
1313	    value: function getZindex() {
1314	      if (this.overlay !== null) {
1315	        return this.params.zIndexAbsolute > 0 ? this.params.zIndexAbsolute : Popup.getOption('popupOverlayZindex') + this.params.zIndex;
1316	      } else {
1317	        return this.params.zIndexAbsolute > 0 ? this.params.zIndexAbsolute : Popup.getOption('popupZindex') + this.params.zIndex;
1318	      }
1319	    }
1320	    /**
1321	     * @private
1322	     */
1323
1324	  }, {
1325	    key: "adjustOverlayZindex",
1326	    value: function adjustOverlayZindex() {
1327	      if (this.overlay !== null && this.overlay.element !== null) {
1328	        this.overlay.element.style.zIndex = parseInt(this.getPopupContainer().style.zIndex) - 1;
1329	      }
1330	    }
1331	  }, {
1332	    key: "show",
1333	    value: function show() {
1334	      var _this4 = this;
1335
1336	      if (this.isShown() || this.isDestroyed()) {
1337	        return;
1338	      }
1339
1340	      if (!this.firstShow) {
1341	        this.emit('onFirstShow', new main_core_events.BaseEvent({
1342	          compatData: [this]
1343	        }));
1344	        this.firstShow = true;
1345	      }
1346
1347	      this.emit('onShow', new main_core_events.BaseEvent({
1348	        compatData: [this]
1349	      }));
1350	      this.showOverlay();
1351	      this.getPopupContainer().style.display = 'block';
1352	      this.adjustPosition();
1353	      this.animateOpening(function () {
1354	        if (_this4.isDestroyed()) {
1355	          return;
1356	        }
1357
1358	        main_core.Dom.removeClass(_this4.getPopupContainer(), _this4.animationShowClassName);
1359
1360	        _this4.emit('onAfterShow', new main_core_events.BaseEvent({
1361	          compatData: [_this4]
1362	        }));
1363	      });
1364	      this.bindClosingByEsc();
1365
1366	      if (this.isCompatibleMode()) {
1367	        setTimeout(function () {
1368	          _this4.bindAutoHide();
1369	        }, 100);
1370	      } else {
1371	        this.bindAutoHide();
1372	      }
1373	    }
1374	  }, {
1375	    key: "close",
1376	    value: function close() {
1377	      var _this5 = this;
1378
1379	      if (this.isDestroyed() || !this.isShown()) {
1380	        return;
1381	      }
1382
1383	      this.emit('onClose', new main_core_events.BaseEvent({
1384	        compatData: [this]
1385	      }));
1386
1387	      if (this.isDestroyed()) {
1388	        return;
1389	      }
1390
1391	      this.animateClosing(function () {
1392	        if (_this5.isDestroyed()) {
1393	          return;
1394	        }
1395
1396	        _this5.hideOverlay();
1397
1398	        _this5.getPopupContainer().style.display = 'none';
1399	        main_core.Dom.removeClass(_this5.getPopupContainer(), _this5.animationCloseClassName);
1400
1401	        _this5.unbindClosingByEsc();
1402
1403	        if (_this5.isCompatibleMode()) {
1404	          setTimeout(function () {
1405	            _this5.unbindAutoHide();
1406	          }, 0);
1407	        } else {
1408	          _this5.unbindAutoHide();
1409	        }
1410
1411	        _this5.emit('onAfterClose', new main_core_events.BaseEvent({
1412	          compatData: [_this5]
1413	        }));
1414
1415	        if (!_this5.isCacheable()) {
1416	          _this5.destroy();
1417	        }
1418	      });
1419	    }
1420	  }, {
1421	    key: "toggle",
1422	    value: function toggle() {
1423	      this.isShown() ? this.close() : this.show();
1424	    }
1425	    /**
1426	     *
1427	     * @private
1428	     */
1429
1430	  }, {
1431	    key: "animateOpening",
1432	    value: function animateOpening(callback) {
1433	      main_core.Dom.removeClass(this.getPopupContainer(), this.animationCloseClassName);
1434
1435	      if (this.animationShowClassName !== null) {
1436	        main_core.Dom.addClass(this.getPopupContainer(), this.animationShowClassName);
1437
1438	        if (this.animationCloseEventType !== null) {
1439	          var eventName = this.animationCloseEventType + 'end';
1440	          this.getPopupContainer().addEventListener(eventName, function handleTransitionEnd() {
1441	            this.removeEventListener(eventName, handleTransitionEnd);
1442	            callback();
1443	          });
1444	        } else {
1445	          callback();
1446	        }
1447	      } else {
1448	        callback();
1449	      }
1450	    }
1451	    /**
1452	     * @private
1453	     */
1454
1455	  }, {
1456	    key: "animateClosing",
1457	    value: function animateClosing(callback) {
1458	      main_core.Dom.removeClass(this.getPopupContainer(), this.animationShowClassName);
1459
1460	      if (this.animationCloseClassName !== null) {
1461	        main_core.Dom.addClass(this.getPopupContainer(), this.animationCloseClassName);
1462
1463	        if (this.animationCloseEventType !== null) {
1464	          var eventName = this.animationCloseEventType + 'end';
1465	          this.getPopupContainer().addEventListener(eventName, function handleTransitionEnd() {
1466	            this.removeEventListener(eventName, handleTransitionEnd);
1467	            callback();
1468	          });
1469	        } else {
1470	          callback();
1471	        }
1472	      } else {
1473	        callback();
1474	      }
1475	    }
1476	  }, {
1477	    key: "setAnimation",
1478	    value: function setAnimation(options) {
1479	      if (main_core.Type.isPlainObject(options)) {
1480	        this.animationShowClassName = main_core.Type.isStringFilled(options.showClassName) ? options.showClassName : null;
1481	        this.animationCloseClassName = main_core.Type.isStringFilled(options.closeClassName) ? options.closeClassName : null;
1482	        this.animationCloseEventType = options.closeAnimationType === 'animation' || options.closeAnimationType === 'transition' ? options.closeAnimationType : null;
1483	      } else if (main_core.Type.isStringFilled(options)) {
1484	        var animationName = options;
1485
1486	        if (animationName === 'fading') {
1487	          this.animationShowClassName = 'popup-window-show-animation-opacity';
1488	          this.animationCloseClassName = 'popup-window-close-animation-opacity';
1489	          this.animationCloseEventType = 'animation';
1490	        } else if (animationName === 'fading-slide') {
1491	          this.animationShowClassName = 'popup-window-show-animation-opacity-transform';
1492	          this.animationCloseClassName = 'popup-window-close-animation-opacity';
1493	          this.animationCloseEventType = 'animation';
1494	        } else if (animationName === 'scale') {
1495	          this.animationShowClassName = 'popup-window-show-animation-scale';
1496	          this.animationCloseClassName = 'popup-window-close-animation-opacity';
1497	          this.animationCloseEventType = 'animation';
1498	        }
1499	      } else if (options === false || options === null) {
1500	        this.animationShowClassName = null;
1501	        this.animationCloseClassName = null;
1502	        this.animationCloseEventType = null;
1503	      }
1504	    }
1505	  }, {
1506	    key: "isShown",
1507	    value: function isShown() {
1508	      return !this.isDestroyed() && this.getPopupContainer().style.display === 'block';
1509	    }
1510	  }, {
1511	    key: "destroy",
1512	    value: function destroy() {
1513	      var _this6 = this;
1514
1515	      if (this.destroyed) {
1516	        return;
1517	      }
1518
1519	      this.destroyed = true;
1520	      this.emit('onDestroy', new main_core_events.BaseEvent({
1521	        compatData: [this]
1522	      }));
1523	      this.unbindClosingByEsc();
1524
1525	      if (this.isCompatibleMode()) {
1526	        setTimeout(function () {
1527	          _this6.unbindAutoHide();
1528	        }, 0);
1529	      } else {
1530	        this.unbindAutoHide();
1531	      }
1532
1533	      main_core.Event.unbindAll(this);
1534	      main_core.Event.unbind(document, 'mousemove', this.handleDocumentMouseMove);
1535	      main_core.Event.unbind(document, 'mouseup', this.handleDocumentMouseUp);
1536	      main_core.Event.unbind(window, 'resize', this.handleResizeWindow);
1537	      main_core.Dom.remove(this.popupContainer);
1538	      this.removeOverlay();
1539	      this.popupContainer = null;
1540	      this.contentContainer = null;
1541	      this.closeIcon = null;
1542	      this.titleBar = null;
1543	      this.buttonsContainer = null;
1544	      this.angle = null;
1545	      this.resizeIcon = null;
1546	    }
1547	  }, {
1548	    key: "adjustPosition",
1549	    value: function adjustPosition(bindOptions) {
1550	      if (bindOptions && babelHelpers.typeof(bindOptions) === 'object') {
1551	        this.bindOptions = bindOptions;
1552	      }
1553
1554	      var bindElementPos = this.getBindElementPos(this.bindElement);
1555
1556	      if (!this.bindOptions.forceBindPosition && this.bindElementPos !== null && bindElementPos.top === this.bindElementPos.top && bindElementPos.left === this.bindElementPos.left) {
1557	        return;
1558	      }
1559
1560	      this.bindElementPos = bindElementPos;
1561	      var windowSize = bindElementPos.windowSize ? bindElementPos.windowSize : {
1562	        innerWidth: window.innerWidth,
1563	        innerHeight: window.innerHeight
1564	      };
1565	      var windowScroll = bindElementPos.windowScroll ? bindElementPos.windowScroll : {
1566	        scrollLeft: window.pageXOffset,
1567	        scrollTop: window.pageYOffset
1568	      };
1569	      var popupWidth = bindElementPos.popupWidth ? bindElementPos.popupWidth : this.popupContainer.offsetWidth;
1570	      var popupHeight = bindElementPos.popupHeight ? bindElementPos.popupHeight : this.popupContainer.offsetHeight;
1571	      var angleTopOffset = Popup.getOption('angleTopOffset');
1572	      var left = this.bindElementPos.left + this.offsetLeft - (this.isTopOrBottomAngle() ? Popup.getOption('angleLeftOffset') : 0);
1573
1574	      if (!this.bindOptions.forceLeft && left + popupWidth + this.bordersWidth >= windowSize.innerWidth + windowScroll.scrollLeft && windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth > 0) {
1575	        var bindLeft = left;
1576	        left = windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth;
1577
1578	        if (this.isTopOrBottomAngle()) {
1579	          this.setAngle({
1580	            offset: bindLeft - left + this.angle.defaultOffset
1581	          });
1582	        }
1583	      } else if (this.isTopOrBottomAngle()) {
1584	        this.setAngle({
1585	          offset: this.angle.defaultOffset + (left < 0 ? left : 0)
1586	        });
1587	      }
1588
1589	      if (left < 0) {
1590	        left = 0;
1591	      }
1592
1593	      var top = 0;
1594
1595	      if (this.bindOptions.position && this.bindOptions.position === 'top') {
1596	        top = this.bindElementPos.top - popupHeight - this.offsetTop - (this.isBottomAngle() ? angleTopOffset : 0);
1597
1598	        if (top < 0 || !this.bindOptions.forceTop && top < windowScroll.scrollTop) {
1599	          top = this.bindElementPos.bottom + this.offsetTop;
1600
1601	          if (this.angle !== null) {
1602	            top += angleTopOffset;
1603	            this.setAngle({
1604	              position: 'top'
1605	            });
1606	          }
1607	        } else if (this.isTopAngle()) {
1608	          top = top - angleTopOffset + Popup.getOption('positionTopXOffset');
1609	          this.setAngle({
1610	            position: 'bottom'
1611	          });
1612	        } else {
1613	          top += Popup.getOption('positionTopXOffset');
1614	        }
1615	      } else {
1616	        top = this.bindElementPos.bottom + this.offsetTop + this.getAngleHeight();
1617
1618	        if (!this.bindOptions.forceTop && top + popupHeight >
1618 windowSize.innerHeight + windowScroll.scrollTop && this.bindElementPos.top - popupHeight - this.getAngleHeight() >= 0) //Can we place the PopupWindow above the bindElement?
1619	          {
1620	            //The PopupWindow doesn't place below the bindElement. We should place it above.
1621	            top = this.bindElementPos.top - popupHeight;
1622
1623	            if (this.isTopOrBottomAngle()) {
1624	              top -= angleTopOffset;
1625	              this.setAngle({
1626	                position: 'bottom'
1627	              });
1628	            }
1629
1630	            top += Popup.getOption('positionTopXOffset');
1631	          } else if (this.isBottomAngle()) {
1632	          top += angleTopOffset;
1633	          this.setAngle({
1634	            position: 'top'
1635	          });
1636	        }
1637	      }
1638
1639	      if (top < 0) {
1640	        top = 0;
1641	      }
1642
1643	      main_core.Dom.adjust(this.popupContainer, {
1644	        style: {
1645	          top: top + 'px',
1646	          left: left + 'px',
1647	          zIndex: this.getZindex()
1648	        }
1649	      });
1650	      this.adjustOverlayZindex();
1651	    }
1652	  }, {
1653	    key: "enterFullScreen",
1654	    value: function enterFullScreen() {
1655	      if (Popup.fullscreenStatus) {
1656	        if (document.cancelFullScreen) {
1657	          document.cancelFullScreen();
1658	        } else if (document.mozCancelFullScreen) {
1659	          document.mozCancelFullScreen();
1660	        } else if (document.webkitCancelFullScreen) {
1661	          document.webkitCancelFullScreen();
1662	        }
1663	      } else {
1664	        if (this.contentContainer.requestFullScreen) {
1665	          this.contentContainer.requestFullScreen();
1666	          main_core.Event.bind(window, 'fullscreenchange', this.handleFullScreen);
1667	        } else if (this.contentContainer.mozRequestFullScreen) {
1668	          this.contentContainer.mozRequestFullScreen();
1669	          main_core.Event.bind(window, 'mozfullscreenchange', this.handleFullScreen);
1670	        } else if (this.contentContainer.webkitRequestFullScreen) {
1671	          this.contentContainer.webkitRequestFullScreen();
1672	          main_core.Event.bind(window, 'webkitfullscreenchange', this.handleFullScreen);
1673	        } else {
1674	          console.log('fullscreen mode is not supported');
1675	        }
1676	      }
1677	    }
1678	    /**
1679	     * @private
1680	     */
1681
1682	  }, {
1683	    key: "handleFullScreen",
1684	    value: function handleFullScreen(event) {
1685	      if (Popup.fullscreenStatus) {
1686	        main_core.Event.unbind(window, 'fullscreenchange', this.handleFullScreen);
1687	        main_core.Event.unbind(window, 'webkitfullscreenchange', this.handleFullScreen);
1688	        main_core.Event.unbind(window, 'mozfullscreenchange', this.handleFullScreen);
1689	        Popup.fullscreenStatus = false;
1690
1691	        if (!this.isDestroyed()) {
1692	          main_core.Dom.removeClass(this.contentContainer, 'popup-window-fullscreen');
1693	          this.emit('onFullscreenLeave');
1694	          this.adjustPosition();
1695	        }
1696	      } else {
1697	        Popup.fullscreenStatus = true;
1698
1699	        if (!this.isDestroyed()) {
1700	          main_core.Dom.addClass(this.contentContainer, 'popup-window-fullscreen');
1701	          this.emit('onFullscreenEnter');
1702	          this.adjustPosition();
1703	        }
1704	      }
1705	    }
1706	    /**
1707	     * @private
1708	     */
1709
1710	  }, {
1711	    key: "handleCloseIconClick",
1712	    value: function handleCloseIconClick(event) {
1713	      this.tryCloseByEvent(event);
1714	      event.stopPropagation();
1715	    }
1716	    /**
1717	     * @private
1718	     */
1719
1720	  }, {
1721	    key: "handleContainerClick",
1722	    value: function handleContainerClick(event) {
1723	      event.stopPropagation();
1724	    }
1725	    /**
1726	     * @private
1727	     */
1728
1729	  }, {
1730	    key: "handleDocumentKeyUp",
1731	    value: function handleDocumentKeyUp(event) {
1732	      var _this7 = this;
1733
1734	      if (event.keyCode === 27) {
1735	        checkEscPressed(this.getZindex(), function () {
1736	          _this7.close();
1737	        });
1738	      }
1739	    }
1740	    /**
1741	     * @private
1742	     */
1743
1744	  }, {
1745	    key: "handleResizeWindow",
1746	    value: function handleResizeWindow() {
1747	      if (this.isShown()) {
1748	        this.adjustPosition();
1749
1750	        if (this.overlay !== null) {
1751	          this.resizeOverlay();
1752	        }
1753	      }
1754	    }
1755	    /**
1756	     * @private
1757	     */
1758
1759	  }, {
1760	    key: "handleMove",
1761	    value: function handleMove(offsetX, offsetY, pageX, pageY) {
1762	      var left = parseInt(this.popupContainer.style.left) + offsetX;
1763	      var top = parseInt(this.popupContainer.style.top) + offsetY;
1764
1765	      if (babelHelpers.typeof(this.params.draggable) === 'object' && this.params.draggable.restrict) {
1766	        //Left side
1767	        if (left < 0) {
1768	          left = 0;
1769	        } //Right side
1770
1771
1772	        var scrollWidth = document.documentElement.scrollWidth;
1773	        var scrollHeight = document.documentElement.scrollHeight;
1774	        var floatWidth = this.popupContainer.offsetWidth;
1775	        var floatHeight = this.popupContainer.offsetHeight;
1776
1777	        if (left > scrollWidth - floatWidth) {
1778	          left = scrollWidth - floatWidth;
1779	        }
1780
1781	        if (top > scrollHeight - floatHeight) {
1782	          top = scrollHeight - floatHeight;
1783	        } //Top side
1784
1785
1786	        if (top < 0) {
1787	          top = 0;
1788	        }
1789	      }
1790
1791	      this.popupContainer.style.left = left + 'px';
1792	      this.popupContainer.style.top = top + 'px';
1793	    }
1794	    /**
1795	     * @private
1796	     */
1797
1798	  }, {
1799	    key: "_startDrag",
1800	    value: function _startDrag(event, options) {
1801	      options = options || {};
1802
1803	      if (main_core.Type.isStringFilled(options.cursor)) {
1804	        this.dragOptions.cursor = options.cursor;
1805	      }
1806
1807	      if (main_core.Type.isStringFilled(options.eventName)) {
1808	        this.dragOptions.eventName = options.eventName;
1809	      }
1810
1811	      if (main_core.Type.isFunction(options.callback)) {
1812	        this.dragOptions.callback = options.callback;
1813	      }
1814
1815	      this.dragPageX = event.pageX;
1816	      this.dragPageY = event.pageY;
1817	      this.dragged = false;
1818	      main_core.Event.bind(document, 'mousemove', this.handleDocumentMouseMove);
1819	      main_core.Event.bind(document, 'mouseup', this.handleDocumentMouseUp);
1820
1821	      if (document.body.setCapture) {
1822	        document.body.setCapture();
1823	      }
1824
1825	      document.body.ondrag = function () {
1826	        return false;
1827	      };
1828
1829	      document.body.onselectstart = function () {
1830	        return false;
1831	      };
1832
1833	      document.body.style.cursor = this.dragOptions.cursor;
1834	      document.body.style.MozUserSelect = 'none';
1835	      this.popupContainer.style.MozUserSelect = 'none';
1836	      event.preventDefault();
1837	    }
1838	    /**
1839	     * @private
1840	     */
1841
1842	  }, {
1843	    key: "handleDocumentMouseMove",
1844	    value: function handleDocumentMouseMove(event) {
1845	      if (this.dragPageX === event.pageX && this.dragPageY === event.pageY) {
1846	        return;
1847	      }
1848
1849	      this.dragOptions.callback(event.pageX - this.dragPageX, event.pageY - this.dragPageY, event.pageX, event.pageY);
1850	      this.dragPageX = event.pageX;
1851	      this.dragPageY = event.pageY;
1852
1853	      if (!this.dragged) {
1854	        this.emit("on".concat(this.dragOptions.eventName, "Start"), new main_core_events.BaseEvent({
1855	          compatData: [this]
1856	        }));
1857	        this.dragged = true;
1858	      }
1859
1860	      this.emit("on".concat(this.dragOptions.eventName), new main_core_events.BaseEvent({
1861	        compatData: [this]
1862	      }));
1863	    }
1864	    /**
1865	     * @private
1866	     */
1867
1868	  }, {
1869	    key: "handleDocumentMouseUp",
1870	    value: function handleDocumentMouseUp(event) {
1871	      if (document.body.releaseCapture) {
1872	        document.body.releaseCapture();
1873	      }
1874
1875	      main_core.Event.unbind(document, 'mousemove', this.handleDocumentMouseMove);
1876	      main_core.Event.unbind(document, 'mouseup', this.handleDocumentMouseUp);
1877	      document.body.ondrag = null;
1878	      document.body.onselectstart = null;
1879	      document.body.style.cursor = '';
1880	      document.body.style.MozUserSelect = '';
1881	      this.popupContainer.style.MozUserSelect = '';
1882	      this.emit("on".concat(this.dragOptions.eventName, "End"), new main_core_events.BaseEvent({
1883	        compatData: [this]
1884	      }));
1885	      this.dragged = false;
1886	      event.preventDefault();
1887	    }
1888	  }]);
1889	  return Popup;
1890	}(main_core_events.EventEmitter);
1891
1892	babelHelpers.defineProperty(Popup, "options", {});
1893	babelHelpers.defineProperty(Popup, "defaultOptions", {
1894	  //left offset for popup about target
1895	  angleLeftOffset: 40,
1896	  //when popup position is 'top' offset distance between popup body and target node
1897	  positionTopXOffset: -11,
1898	  //offset distance between popup body and target node if use angle, sum with positionTopXOffset
1899	  angleTopOffset: 10,
1900	  popupZindex: 1000,
1901	  popupOverlayZindex: 1100,
1902	  angleMinLeft: 10,
1903	  angleMaxLeft: 30,
1904	  angleMinRight: 10,
1905	  angleMaxRight: 30,
1906	  angleMinBottom: 23,
1907	  angleMaxBottom: 25,
1908	  angleMinTop: 23,
1909	  angleMaxTop: 25,
1910	  offsetLeft: 0,
1911	  offsetTop: 0
1912	});
1913	var escCallbackIndex = -1;
1914	var escCallback = null;
1915
1916	function checkEscPressed(zIndex, callback) {
1917	  if (zIndex === false) {
1918	    if (escCallback && escCallback.length > 0) {
1919	      for (var i = 0; i < escCallback.length; i++) {
1920	        escCallback[i]();
1921	      }
1922
1923	      escCallback = null;
1924	      escCallbackIndex = -1;
1925	    }
1926	  } else {
1927	    if (escCallback === null) {
1928	      escCallback = [];
1929	      escCallbackIndex = -1;
1930	      setTimeout(function () {
1931	        checkEscPressed(false);
1932	      }, 10);
1933	    }
1934
1935	    if (zIndex > escCallbackIndex) {
1936	      escCallbackIndex = zIndex;
1937	      escCallback = [callback];
1938	    } else if (zIndex === escCallbackIndex) {
1939	      escCallback.push(callback);
1940	    }
1941	  }
1942	}
1943
1944	var PopupManager = /*#__PURE__*/function () {
1945	  function PopupManager() {
1946	    babelHelpers.classCallCheck(this, PopupManager);
1947	    throw new Error('You cannot make an instance of PopupManager.');
1948	  }
1949
1950	  babelHelpers.createClass(PopupManager, null, [{
1951	    key: "create",
1952	    value: function create(options) {
1953	      var _arguments = Array.prototype.slice.call(arguments),
1954	          popupId = _arguments[0],
1955	          bindElement = _arguments[1],
1956	          params = _arguments[2]; //compatible arguments
1957
1958
1959	      var id = popupId;
1960	      var compatMode = true;
1961
1962	      if (main_core.Type.isPlainObject(popupId) && !bindElement && !params) {
1963	        compatMode = false;
1964	        id = popupId.id;
1965
1966	        if (!main_core.Type.isStringFilled(id)) {
1967	          throw new Error('BX.Main.Popup.Manager: "id" parameter is required.');
1968	        }
1969	      }
1970
1971	      var popupWindow = this.getPopupById(id);
1972
1973	      if (popupWindow === null) {
1974	        popupWindow = compatMode ? new Popup(popupId, bindElement, params) : new Popup(options);
1975	        popupWindow.subscribe('onShow', this.handlePopupShow);
1976	        popupWindow.subscribe('onClose', this.handlePopupClose);
1977	      }
1978
1979	      return popupWindow;
1980	    }
1981	    /**
1982	     * @private
1983	     */
1984
1985	  }, {
1986	    key: "handleOnAfterInit",
1987	    value: function handleOnAfterInit(event) {
1988	      event.getTarget().subscribeOnce('onDestroy', this.handlePopupDestroy);
1989
1990	      this._popups.forEach(function (popup) {
1991	        if (popup.getId() === event.getTarget().getId()) {
1992	          console.error("Duplicate id (".concat(popup.getId(), ") for the BX.Main.Popup instance."));
1993	        }
1994	      });
1995
1996	      this._popups.push(event.getTarget());
1997	    }
1998	    /**
1999	     * @private
2000	     */
2001
2002	  }, {
2003	    key: "handlePopupDestroy",
2004	    value: function handlePopupDestroy(event) {
2005	      this._popups = this._popups.filter(function (popup) {
2006	        return popup !== event.getTarget();
2007	      });
2008	    }
2009	    /**
2010	     * @private
2011	     */
2012
2013	  }, {
2014	    key: "handlePopupShow",
2015	    value: function handlePopupShow(event) {
2016	      if (this._currentPopup !== null) {
2017	        this._currentPopup.close();
2018	      }
2019
2020	      this._currentPopup = event.getTarget();
2021	    }
2022	    /**
2023	     * @private
2024	     */
2025
2026	  }, {
2027	    key: "handlePopupClose",
2028	    value: function handlePopupClose() {
2029	      this._currentPopup = null;
2030	    }
2031	  }, {
2032	    key: "getCurrentPopup",
2033	    value: function getCurrentPopup() {
2034	      return this._currentPopup;
2035	    }
2036	  }, {
2037	    key: "isPopupExists",
2038	    value: function isPopupExists(id) {
2039	      return this.getPopupById(id) !== null;
2040	    }
2041	  }, {
2042	    key: "isAnyPopupShown",
2043	    value: function isAnyPopupShown() {
2044	      for (var i = 0, length = this._popups.length; i < length; i++) {
2045	        if (this._popups[i].isShown()) {
2046	          return true;
2047	        }
2048	      }
2049
2050	      return false;
2051	    }
2052	  }, {
2053	    key: "getPopupById",
2054	    value: function getPopupById(id) {
2055	      for (var i = 0; i < this._popups.length; i++) {
2056	        if (this._popups[i].getId() === id) {
2057	          return this._popups[i];
2058	        }
2059	      }
2060
2061	      return null;
2062	    }
2063	  }, {
2064	    key: "getMaxZIndex",
2065	    value: function getMaxZIndex() {
2066	      var zIndex = 0;
2067
2068	      for (var i = 0; i < this._popups.length; i++) {
2069	        zIndex = Math.max(zIndex, this._popups[i].params.zIndex);
2070	      }
2071
2072	      return zIndex;
2073	    }
2074	  }]);
2075	  return PopupManager;
2076	}();
2077
2078	babelHelpers.defineProperty(PopupManager, "_popups", []);
2079	babelHelpers.defineProperty(PopupManager, "_currentPopup", null);
2080	PopupManager.handlePopupDestroy = PopupManager.handlePopupDestroy.bind(PopupManager);
2081	PopupManager.handlePopupShow = PopupManager.handlePopupShow.bind(PopupManager);
2082	PopupManager.handlePopupClose = PopupManager.handlePopupClose.bind(PopupManager);
2083	PopupManager.handleOnAfterInit = PopupManager.handleOnAfterInit.bind(PopupManager);
2084	main_core_events.EventEmitter.subscribe('BX.Main.Popup:onAfterInit', PopupManager.handleOnAfterInit);
2085
2086	function _templateObject$1() {
2087	  var data = babelHelpers.taggedTemplateLiteral(["<span class=\"popup-window-delimiter\">"]);
2088
2089	  _templateObject$1 = function _templateObject() {
2090	    return data;
2091	  };
2092
2093	  return data;
2094	}
2095	var aliases$1 = {
2096	  onSubMenuShow: {
2097	    namespace: 'BX.Main.Menu.Item',
2098	    eventName: 'SubMenu:onShow'
2099	  },
2100	  onSubMenuClose: {
2101	    namespace: 'BX.Main.Menu.Item',
2102	    eventName: 'SubMenu:onClose'
2103	  }
2104	};
2105	main_core_events.EventEmitter.registerAliases(aliases$1);
2106
2107	var MenuItem = /*#__PURE__*/function (_EventEmitter) {
2108	  babelHelpers.inherits(MenuItem, _EventEmitter);
2109
2110	  function MenuItem(options) {
2111	    var _this;
2112
2113	    babelHelpers.classCallCheck(this, MenuItem);
2114	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MenuItem).call(this));
2115
2116	    _this.setEventNamespace('BX.Main.Menu.Item');
2117
2118	    options = options || {};
2119	    _this.options = options;
2120	    _this.id = options.id || main_core.Text.getRandom();
2121	    _this.text = main_core.Type.isStringFilled(options.text) ? options.text : '';
2122	    _this.title = main_core.Type.isStringFilled(options.title) ? options.title : '';
2123	    _this.delimiter = options.delimiter === true;
2124	    _this.href = main_core.Type.isStringFilled(options.href) ? options.href : null;
2125	    _this.target = main_core.Type.isStringFilled(options.target) ? options.target : null;
2126	    _this.dataset = main_core.Type.isPlainObject(options.dataset) ? options.dataset : null;
2127	    _this.className = main_core.Type.isStringFilled(options.className) ? options.className : null;
2128	    _this.menuShowDelay = main_core.Type.isNumber(options.menuShowDelay) ? options.menuShowDelay : 300;
2129	    _this.subMenuOffsetX = main_core.Type.isNumber(options.subMenuOffsetX) ? options.subMenuOffsetX : 4;
2130	    _this._items = main_core.Type.isArray(options.items) ? options.items : [];
2131	    _this.disabled = options.disabled === true;
2132	    _this.cacheable = options.cacheable === true;
2133	    /**
2134	     *
2135	     * @type {function|string}
2136	     */
2137
2138	    _this.onclick = main_core.Type.isStringFilled(options.onclick) || main_core.Type.isFunction(options.onclick) ? options.onclick : null;
2139
2140	    _this.subscribeFromOptions(options.events, aliases$1);
2141	    /**
2142	     *
2143	     * @type {Menu}
2144	     */
2145
2146
2147	    _this.menuWindow = null;
2148	    /**
2149	     *
2150	     * @type {Menu}
2151	     */
2152
2153	    _this.subMenuWindow = null;
2154	    /**
2155	     *
2156	     * @type {{item: Element, text: Element}}
2157	     */
2158
2159	    _this.layout = {
2160	      item: null,
2161	      text: null
2162	    };
2163
2164	    _this.getLayout(); //compatibility
2165	    //compatibility
2166	    //now use this.options
2167
2168
2169	    _this.events = {};
2170	    _this.items = [];
2171
2172	    for (var property in options) {
2173	      if (options.hasOwnProperty(property) && typeof _this[property] === 'undefined') {
2174	        _this[property] = options[property];
2175	      }
2176	    }
2177
2178	    return _this;
2179	  }
2180
2181	  babelHelpers.createClass(MenuItem, [{
2182	    key: "getLayout",
2183	    value: function getLayout() {
2184	      if (this.layout.item) {
2185	        return this.layout;
2186	      }
2187
2188	      if (this.delimiter) {
2189	        if (main_core.Type.isStringFilled(this.text)) {
2190	          this.layout.item = main_core.Dom.create('span', {
2191	            props: {
2192	              className: 'popup-window-delimiter-section'
2193	            },
2194	            children: [this.layout.text = main_core.Dom.create('span', {
2195	              props: {
2196	                className: 'popup-window-delimiter-text'
2197	              },
2198	              html: this.text
2199	            })]
2200	          });
2201	        } else {
2202	          this.layout.item = main_core.Tag.render(_templateObject$1());
2203	        }
2204	      } else {
2205	        this.layout.item = main_core.Dom.create(this.href ? 'a' : 'span', {
2206	          props: {
2207	            className: ['menu-popup-item', this.className ? this.className : 'menu-popup-no-icon', this.hasSubMenu() ? 'menu-popup-item-submenu' : ''].join(' ')
2208	          },
2209	          attrs: {
2210	            title: this.title,
2211	            onclick: main_core.Type.isString(this.onclick) ? this.onclick : '',
2212	            // compatibility
2213	            target: this.target ? this.target : ''
2214	          },
2215	          dataset: this.dataset,
2216	          events: main_core.Type.isFunction(this.onclick) ? {
2217	            click: this.onItemClick.bind(this)
2218	          } : null,
2219	          children: [main_core.Dom.create('span', {
2220	            props: {
2221	              className: 'menu-popup-item-icon'
2222	            }
2223	          }), this.layout.text = main_core.Dom.create('span', {
2224	            props: {
2225	              className: 'menu-popup-item-text'
2226	            },
2227	            html: this.text
2228	          })]
2229	        });
2230
2231	        if (this.href) {
2232	          this.layout.item.href = this.href;
2233	        }
2234
2235	        if (this.isDisabled()) {
2236	          this.disable();
2237	        }
2238
2239	        main_core.Event.bind(this.layout.item, 'mouseenter', this.onItemMouseEnter.bind(this));
2240	        main_core.Event.bind(this.layout.item, 'mouseleave', this.onItemMouseLeave.bind(this));
2241	      }
2242
2243	      return this.layout;
2244	    }
2245	  }, {
2246	    key: "getContainer",
2247	    value: function getContainer() {
2248	      return this.getLayout().item;
2249	    }
2250	  }, {
2251	    key: "getTextContainer",
2252	    value: function getTextContainer() {
2253	      return this.getLayout().text;
2254	    }
2255	  }, {
2256	    key: "getText",
2257	    value: function getText() {
2258	      return this.text;
2259	    }
2260	  }, {
2261	    key: "setText",
2262	    value: function setText(text) {
2263	      if (main_core.Type.isString(text)) {
2264	        this.text = text;
2265	        this.getTextContainer().innerHTML = text;
2266	      }
2267	    }
2268	  }, {
2269	    key: "hasSubMenu",
2270	    value: function hasSubMenu() {
2271	      return this.subMenuWindow !== null || this._items.length;
2272	    }
2273	  }, {
2274	    key: "showSubMenu",
2275	    value: function showSubMenu() {
2276	      this.addSubMenu(this._items);
2277
2278	      if (this.subMenuWindow) {
2279	        main_core.Dom.addClass(this.layout.item, 'menu-popup-item-open');
2280	        this.closeSiblings();
2281	        this.closeChildren();
2282	        var popupWindow = this.subMenuWindow.getPopupWindow();
2283
2284	        if (!popupWindow.isShown()) {
2285	          this.emit('SubMenu:onShow');
2286	          popupWindow.show();
2287	        }
2288
2289	        this.adjustSubMenu();
2290	      }
2291	    }
2292	  }, {
2293	    key: "addSubMenu",
2294	    value: function addSubMenu(items) {
2295	      if (this.subMenuWindow !== null || !main_core.Type.isArray(items) || !items.length) {
2296	        return;
2297	      }
2298
2299	      var rootMenuWindow = this.getMenuWindow().getRootMenuWindow() || this.getMenuWindow();
2300	      var options = rootMenuWindow.params; //Override root menu options
2301
2302	      options.autoHide = false;
2303	      options.menuShowDelay = this.menuShowDelay;
2304	      options.cacheable = this.isCacheable();
2305	      options.zIndexAbsolute = this.getMenuWindow().getPopupWindow().getZindex() + 2;
2306	      options.bindOptions = {
2307	        forceTop: true,
2308	        forceLeft: true,
2309	        forceBindPosition: true
2310	      };
2311	      delete options.zIndex;
2312	      delete options.events;
2313	      delete options.angle;
2314	      delete options.overlay;
2315	      this.subMenuWindow = new Menu('popup-submenu-' + this.id, this.layout.item, items, options);
2316	      this.subMenuWindow.setParentMenuWindow(this.getMenuWindow());
2317	      this.subMenuWindow.setParentMenuItem(this);
2318	      this.subMenuWindow.getPopupWindow().subscribe('onDestroy', this.handleSubMenuDestroy.bind(this));
2319	      main_core.Dom.addClass(this.layout.item, 'menu-popup-item-submenu');
2320	      return this.subMenuWindow;
2321	    }
2322	  }, {
2323	    key: "closeSubMenu",
2324	    value: function closeSubMenu() {
2325	      this.clearSubMenuTimeout();
2326
2327	      if (this.subMenuWindow) {
2328	        main_core.Dom.removeClass(this.layout.item, 'menu-popup-item-open');
2329	        this.closeChildren();
2330	        var popup = this.subMenuWindow.getPopupWindow();
2331
2332	        if (popup.isShown()) {
2333	          this.emit('SubMenu:onClose');
2334	        }
2335
2336	        this.subMenuWindow.close();
2337	      }
2338	    }
2339	  }, {
2340	    key: "closeSiblings",
2341	    value: function closeSiblings() {
2342	      var siblings = this.menuWindow.getMenuItems();
2343
2344	      for (var i = 0; i < siblings.length; i++) {
2345	        if (siblings[i] !== this) {
2346	          siblings[i].closeSubMenu();
2347	        }
2348	      }
2349	    }
2350	  }, {
2351	    key: "closeChildren",
2352	    value: function closeChildren() {
2353	      if (this.subMenuWindow) {
2354	        var children = this.subMenuWindow.getMenuItems();
2355
2356	        for (var i = 0; i < children.length; i++) {
2357	          children[i].closeSubMenu();
2358	        }
2359	      }
2360	    }
2361	  }, {
2362	    key: "destroySubMenu",
2363	    value: function destroySubMenu() {
2364	      if (this.subMenuWindow) {
2365	        main_core.Dom.removeClass(this.layout.item, 'menu-popup-item-open menu-popup-item-submenu');
2366	        this.destroyChildren();
2367	        this.subMenuWindow.destroy();
2368	        this.subMenuWindow = null;
2369	        this._items = [];
2370	      }
2371	    }
2372	  }, {
2373	    key: "destroyChildren",
2374	    value: function destroyChildren() {
2375	      if (this.subMenuWindow) {
2376	        var children = this.subMenuWindow.getMenuItems();
2377
2378	        for (var i = 0; i < children.length; i++) {
2379	          children[i].destroySubMenu();
2380	        }
2381	      }
2382	    }
2383	  }, {
2384	    key: "adjustSubMenu",
2385	    value: function adjustSubMenu() {
2386	      if (!this.subMenuWindow || !this.layout.item) {
2387	        return;
2388	      }
2389
2390	      var popupWindow = this.subMenuWindow.getPopupWindow();
2391	      var itemRect = this.layout.item.getBoundingClientRect();
2392	      var offsetLeft = itemRect.width + this.subMenuOffsetX;
2393	      var offsetTop = itemRect.height + this.getPopupPadding();
2394	      var angleOffset = itemRect.height / 2 - this.getPopupPadding();
2395	      var anglePosition = 'left';
2396	      var popupWidth = popupWindow.getPopupContainer().offsetWidth;
2397	      var popupHeight = popupWindow.getPopupContainer().offsetHeight;
2398	      var popupBottom = itemRect.top + popupHeight;
2399	      var clientWidth = document.documentElement.clientWidth;
2400	      var clientHeight = document.documentElement.clientHeight; // let's try to fit a submenu to the browser viewport
2401
2402	      var exceeded = popupBottom - clientHeight;
2403
2404	      if (exceeded > 0) {
2405	        var roundOffset = Math.ceil(exceeded / itemRect.height) * itemRect.height;
2406
2407	        if (roundOffset > itemRect.top) {
2408	          // it cannot be higher than the browser viewport.
2409	          roundOffset -= Math.ceil((roundOffset - itemRect.top) / itemRect.height) * itemRect.height;
2410	        }
2411
2412	        if (itemRect.bottom > popupBottom - roundOffset) {
2413	          // let's sync bottom boundaries.
2414	          roundOffset -= itemRect.bottom - (popupBottom - roundOffset) + this.getPopupPadding();
2415	        }
2416
2417	        offsetTop += roundOffset;
2418	        angleOffset += roundOffset;
2419	      }
2420
2421	      if (itemRect.left + offsetLeft + popupWidth > clientWidth) {
2422	        var left = itemRect.left - popupWidth - this.subMenuOffsetX;
2423
2424	        if (left > 0) {
2425	          offsetLeft = -popupWidth - this.subMenuOffsetX;
2426	          anglePosition = 'right';
2427	        }
2428	      }
2429
2430	      popupWindow.setBindElement(this.layout.item);
2431	      popupWindow.setOffset({
2432	        offsetLeft: offsetLeft,
2433	        offsetTop: -offsetTop
2434	      });
2435	      popupWindow.setAngle({
2436	        position: anglePosition,
2437	        offset: angleOffset
2438	      });
2439	      popupWindow.adjustPosition();
2440	    }
2441	  }, {
2442	    key: "getPopupPadding",
2443	    value: function getPopupPadding() {
2444	      if (!main_core.Type.isNumber(this.popupPadding)) {
2445	        if (this.subMenuWindow) {
2446	          var menuContainer = this.subMenuWindow.layout.menuContainer;
2447	          this.popupPadding = parseInt(main_core.Dom.style(menuContainer, 'paddingTop'), 10);
2448	        } else {
2449	          this.popupPadding = 0;
2450	        }
2451	      }
2452
2453	      return this.popupPadding;
2454	    }
2455	  }, {
2456	    key: "getSubMenu",
2457	    value: function getSubMenu() {
2458	      return this.subMenuWindow;
2459	    }
2460	  }, {
2461	    key: "getId",
2462	    value: function getId() {
2463	      return this.id;
2464	    }
2465	  }, {
2466	    key: "setMenuWindow",
2467	    value: function setMenuWindow(menu) {
2468	      this.menuWindow = menu;
2469	    }
2470	  }, {
2471	    key: "getMenuWindow",
2472	    value: function getMenuWindow() {
2473	      return this.menuWindow;
2474	    }
2475	  }, {
2476	    key: "getMenuShowDelay",
2477	    value: function getMenuShowDelay() {
2478	      return this.menuShowDelay;
2479	    }
2480	  }, {
2481	    key: "enable",
2482	    value: function enable() {
2483	      this.disabled = false;
2484	      this.getContainer().classList.remove('menu-popup-item-disabled');
2485	    }
2486	  }, {
2487	    key: "disable",
2488	    value: function disable() {
2489	      this.disabled = true;
2490	      this.closeSubMenu();
2491	      this.getContainer().classList.add('menu-popup-item-disabled');
2492	    }
2493	  }, {
2494	    key: "isDisabled",
2495	    value: function isDisabled() {
2496	      return this.disabled;
2497	    }
2498	  }, {
2499	    key: "setCacheable",
2500	    value: function setCacheable(cacheable) {
2501	      this.cacheable = cacheable !== false;
2502	    }
2503	  }, {
2504	    key: "isCacheable",
2505	    value: function isCacheable() {
2506	      return this.cacheable;
2507	    }
2508	    /**
2509	     * @private
2510	     */
2511
2512	  }, {
2513	    key: "onItemClick",
2514	    value: function onItemClick(event) {
2515	      this.onclick.call(this.menuWindow, event, this); //compatibility
2516	    }
2517	    /**
2518	     * @private
2519	     */
2520
2521	  }, {
2522	    key: "onItemMouseEnter",
2523	    value: function onItemMouseEnter(event) {
2524	      if (this.isDisabled()) {
2525	        return;
2526	      }
2527
2528	      main_core_events.EventEmitter.emit(this, 'onMouseEnter', undefined, {
2529	        thisArg: this
2530	      });
2531	      this.clearSubMenuTimeout();
2532
2533	      if (this.hasSubMenu()) {
2534	        this.subMenuTimeout = setTimeout(function () {
2535	          this.showSubMenu();
2536	        }.bind(this), this.menuShowDelay);
2537	      } else {
2538	        this.subMenuTimeout = setTimeout(function () {
2539	          this.closeSiblings();
2540	        }.bind(this), this.menuShowDelay);
2541	      }
2542	    }
2543	    /**
2544	     * @private
2545	     */
2546
2547	  }, {
2548	    key: "onItemMouseLeave",
2549	    value: function onItemMouseLeave(event) {
2550	      if (this.isDisabled()) {
2551	        return;
2552	      }
2553
2554	      main_core_events.EventEmitter.emit(this, 'onMouseLeave', undefined, {
2555	        thisArg: this
2556	      });
2557	      this.clearSubMenuTimeout();
2558	    }
2559	    /**
2560	     * @private
2561	     */
2562
2563	  }, {
2564	    key: "clearSubMenuTimeout",
2565	    value: function clearSubMenuTimeout() {
2566	      if (this.subMenuTimeout) {
2567	        clearTimeout(this.subMenuTimeout);
2568	      }
2569
2570	      this.subMenuTimeout = null;
2571	    }
2572	    /**
2573	     * @private
2574	     */
2575
2576	  }, {
2577	    key: "handleSubMenuDestroy",
2578	    value: function handleSubMenuDestroy() {
2579	      this.subMenuWindow = null;
2580	    }
2581	  }]);
2582	  return MenuItem;
2583	}(main_core_events.EventEmitter);
2584
2585	function _templateObject2$1() {
2586	  var data = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"menu-popup\">", "</div>\n\t\t"]);
2587
2588	  _templateObject2$1 = function _templateObject2() {
2589	    return data;
2590	  };
2591
2592	  return data;
2593	}
2594
2595	function _templateObject$2() {
2596	  var data = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"menu-popup-items\">", "</div>\n\t\t"]);
2597
2598	  _templateObject$2 = function _templateObject() {
2599	    return data;
2600	  };
2601
2602	  return data;
2603	}
2604
2605	/**
2606	 * @memberof BX.Main
2607	 */
2608	var Menu = /*#__PURE__*/function () {
2609	  function Menu(options) {
2610	    babelHelpers.classCallCheck(this, Menu);
2611
2612	    var _arguments = Array.prototype.slice.call(arguments),
2613	        id = _arguments[0],
2614	        bindElement = _arguments[1],
2615	        menuItems = _arguments[2],
2616	        params = _arguments[3];
2617
2618	    if (main_core.Type.isPlainObject(options) && !bindElement && !menuItems && !params) {
2619	      params = options;
2620	      params.compatibleMode = false;
2621	      id = options.id;
2622	      bindElement = options.bindElement;
2623	      menuItems = options.items;
2624
2625	      if (!main_core.Type.isStringFilled(id)) {
2626	        id = 'menu-popup-' + main_core.Text.getRandom();
2627	      }
2628	    }
2629
2630	    this.id = id;
2631	    this.bindElement = bindElement;
2632	    /**
2633	     *
2634	     * @type {MenuItem[]}
2635	     */
2636
2637	    this.menuItems = [];
2638	    this.itemsContainer = null;
2639	    this.params = params && babelHelpers.typeof(params) === 'object' ? params : {};
2640	    this.parentMenuWindow = null;
2641	    this.parentMenuItem = null;
2642
2643	    if (menuItems && main_core.Type.isArray(menuItems)) {
2644	      for (var i = 0; i < menuItems.length; i++) {
2645	        this.addMenuItemInternal(menuItems[i], null);
2646	      }
2647	    }
2648
2649	    this.layout = {
2650	      menuContainer: null,
2651	      itemsContainer: null
2652	    };
2653	    this.popupWindow = this.__createPopup();
2654	  }
2655	  /**
2656	   * @private
2657	   */
2658
2659
2660	  babelHelpers.createClass(Menu, [{
2661	    key: "__createPopup",
2662	    value: function __createPopup() {
2663	      var domItems = [];
2664
2665	      for (var i = 0; i < this.menuItems.length; i++) {
2666	        var item = this.menuItems[i];
2667	        var itemLayout = item.getLayout();
2668	        domItems.push(itemLayout.item);
2669	      }
2670
2671	      var defaults = {
2672	        closeByEsc: false,
2673	        angle: false,
2674	        autoHide: true,
2675	        offsetTop: 1,
2676	        offsetLeft: 0,
2677	        animation: 'fading'
2678	      };
2679	      var options = Object.assign(defaults, this.params); //Override user params
2680
2681	      options.noAllPaddings = true;
2682	      options.darkMode = false;
2683	      options.autoHideHandler = this.handleAutoHide.bind(this);
2684	      this.layout.itemsContainer = main_core.Tag.render(_templateObject$2(), domItems);
2685	      this.layout.menuContainer = main_core.Tag.render(_templateObject2$1(), this.layout.itemsContainer);
2686	      this.itemsContainer = this.layout.itemsContainer;
2687	      options.content = this.layout.menuContainer; //Make internal event handlers first in the queue.
2688
2689	      options.events = {
2690	        onClose: this.handlePopupClose.bind(this),
2691	        onDestroy: this.handlePopupDestroy.bind(this)
2692	      };
2693	      var id = options.compatibleMode === false ? this.getId() : 'menu-popup-' + this.getId();
2694	      var popup = new Popup(id, this.bindElement, options);
2695
2696	      if (this.params && this.params.events) {
2697	        popup.subscribeFromOptions(this.params.events);
2698	      }
2699
2700	      return popup;
2701	    }
2702	  }, {
2703	    key: "getPopupWindow",
2704	    value: function getPopupWindow() {
2705	      return this.popupWindow;
2706	    }
2707	  }, {
2708	    key: "show",
2709	    value: function show() {
2710	      this.getPopupWindow().show();
2711	    }
2712	  }, {
2713	    key: "close",
2714	    value: function close() {
2715	      this.getPopupWindow().close();
2716	    }
2717	  }, {
2718	    key: "destroy",
2719	    value: function destroy() {
2720	      this.getPopupWindow().destroy();
2721	    }
2722	  }, {
2723	    key: "toggle",
2724	    value: function toggle() {
2725	      if (this.getPopupWindow().isShown()) {
2726	        this.close();
2727	      } else {
2728	        this.show();
2729	      }
2730	    }
2731	  }, {
2732	    key: "getId",
2733	    value: function getId() {
2734	      return this.id;
2735	    }
2736	    /**
2737	     * @private
2738	     */
2739
2740	  }, {
2741	    key: "handlePopupClose",
2742	    value: function handlePopupClose() {
2743	      for (var i = 0; i < this.menuItems.length; i++) {
2744	        var item = this.menuItems[i];
2745	        item.closeSubMenu();
2746	      }
2747	    }
2748	    /**
2749	     * @private
2750	     */
2751
2752	  }, {
2753	    key: "handlePopupDestroy",
2754	    value: function handlePopupDestroy() {
2755	      for (var i = 0; i < this.menuItems.length; i++) {
2756	        var item = this.menuItems[i];
2757	        item.destroySubMenu();
2758	      }
2759	    }
2760	    /**
2761	     * @private
2762	     */
2763
2764	  }, {
2765	    key: "handleAutoHide",
2766	    value: function handleAutoHide(event) {
2767	      return !this.containsTarget(event.target);
2768	    }
2769	    /**
2770	     * @private
2771	     */
2772
2773	  }, {
2774	    key: "containsTarget",
2775	    value: function containsTarget(target) {
2776	      var el = this.getPopupWindow().getPopupContainer();
2777
2778	      if (this.getPopupWindow().isShown() && (target === el || el.contains(target))) {
2779	        return true;
2780	      }
2781
2782	      return this.getMenuItems().some(function (item) {
2783	        return item.getSubMenu() && item.getSubMenu().containsTarget(target);
2784	      });
2785	    }
2786	  }, {
2787	    key: "setParentMenuWindow",
2788	    value: function setParentMenuWindow(parentMenu) {
2789	      if (parentMenu instanceof Menu) {
2790	        this.parentMenuWindow = parentMenu;
2791	      }
2792	    }
2793	  }, {
2794	    key: "getParentMenuWindow",
2795	    value: function getParentMenuWindow() {
2796	      return this.parentMenuWindow;
2797	    }
2798	  }, {
2799	    key: "getRootMenuWindow",
2800	    value: function getRootMenuWindow() {
2801	      var root = null;
2802	      var parent = this.getParentMenuWindow();
2803
2804	      while (parent !== null) {
2805	        root = parent;
2806	        parent = parent.getParentMenuWindow();
2807	      }
2808
2809	      return root;
2810	    }
2811	  }, {
2812	    key: "setParentMenuItem",
2813	    value: function setParentMenuItem(parentItem) {
2814	      if (parentItem instanceof MenuItem) {
2815	        this.parentMenuItem = parentItem;
2816	      }
2817	    }
2818	  }, {
2819	    key: "getParentMenuItem",
2820	    value: function getParentMenuItem() {
2821	      return this.parentMenuItem;
2822	    }
2823	  }, {
2824	    key: "addMenuItem",
2825	    value: function addMenuItem(menuItemJson, targetItemId) {
2826	      var menuItem = this.addMenuItemInternal(menuItemJson, targetItemId);
2827
2828	      if (!menuItem) {
2829	        return null;
2830	      }
2831
2832	      var itemLayout = menuItem.getLayout();
2833	      var targetItem = this.getMenuItem(targetItemId);
2834
2835	      if (targetItem !== null) {
2836	        var targetLayout = targetItem.getLayout();
2837	        this.itemsContainer.insertBefore(itemLayout.item, targetLayout.item);
2838	      } else {
2839	        this.itemsContainer.appendChild(itemLayout.item);
2840	      }
2841
2842	      return menuItem;
2843	    }
2844	    /**
2845	     * @private
2846	     */
2847
2848	  }, {
2849	    key: "addMenuItemInternal",
2850	    value: function addMenuItemInternal(menuItemJson, targetItemId) {
2851	      if (!menuItemJson || !menuItemJson.delimiter && !main_core.Type.isStringFilled(menuItemJson.text) || menuItemJson.id && this.getMenuItem(menuItemJson.id) !== null) {
2852	        return null;
2853	      }
2854
2855	      if (main_core.Type.isNumber(this.params.menuShowDelay)) {
2856	        menuItemJson.menuShowDelay = this.params.menuShowDelay;
2857	      }
2858
2859	      var menuItem = new MenuItem(menuItemJson);
2860	      menuItem.setMenuWindow(this);
2861	      var position = this.getMenuItemPosition(targetItemId);
2862
2863	      if (position >= 0) {
2864	        this.menuItems.splice(position, 0, menuItem);
2865	      } else {
2866	        this.menuItems.push(menuItem);
2867	      }
2868
2869	      return menuItem;
2870	    }
2871	  }, {
2872	    key: "removeMenuItem",
2873	    value: function removeMenuItem(itemId) {
2874	      var item = this.getMenuItem(itemId);
2875
2876	      if (!item) {
2877	        return;
2878	      }
2879
2880	      for (var position = 0; position < this.menuItems.length; position++) {
2881	        if (this.menuItems[position] === item) {
2882	          item.destroySubMenu();
2883	          this.menuItems.splice(position, 1);
2884	          break;
2885	        }
2886	      }
2887
2888	      if (!this.menuItems.length) {
2889	        var menuWindow = item.getMenuWindow();
2890
2891	        if (menuWindow) {
2892	          var parentMenuItem = menuWindow.getParentMenuItem();
2893
2894	          if (parentMenuItem) {
2895	            parentMenuItem.destroySubMenu();
2896	          } else {
2897	            menuWindow.destroy();
2898	          }
2899	        }
2900	      }
2901
2902	      item.layout.item.parentNode.removeChild(item.layout.item);
2903	      item.layout = {
2904	        item: null,
2905	        text: null
2906	      };
2907	    }
2908	  }, {
2909	    key: "getMenuItem",
2910	    value: function getMenuItem(itemId) {
2911	      for (var i = 0; i < this.menuItems.length; i++) {
2912	        if (this.menuItems[i].id && this.menuItems[i].id === itemId) {
2913	          return this.menuItems[i];
2914	        }
2915	      }
2916
2917	      return null;
2918	    }
2919	  }, {
2920	    key: "getMenuItems",
2921	    value: function getMenuItems() {
2922	      return this.menuItems;
2923	    }
2924	  }, {
2925	    key: "getMenuItemPosition",
2926	    value: function getMenuItemPosition(itemId) {
2927	      if (itemId) {
2928	        for (var i = 0; i < this.menuItems.length; i++) {
2929	          if (this.menuItems[i].id && this.menuItems[i].id === itemId) {
2930	            return i;
2931	          }
2932	        }
2933	      }
2934
2935	      return -1;
2936	    }
2937	  }, {
2938	    key: "getMenuContainer",
2939	    value: function getMenuContainer() {
2940	      return this.getPopupWindow().getPopupContainer();
2941	    }
2942	  }]);
2943	  return Menu;
2944	}();
2945
2946	var MenuManager = /*#__PURE__*/function () {
2947	  /**
2948	   * @private
2949	   */
2950
2951	  /**
2952	   * @private
2953	   */
2954	  function MenuManager() {
2955	    babelHelpers.classCallCheck(this, MenuManager);
2956	    throw new Error('You cannot make an instance of MenuManager.');
2957	  }
2958
2959	  babelHelpers.createClass(MenuManager, null, [{
2960	    key: "show",
2961	    value: function show() {
2962	      if (this.currentItem !== null) {
2963	        this.currentItem.popupWindow.close();
2964	      }
2965
2966	      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2967	        args[_key] = arguments[_key];
2968	      }
2969
2970	      this.currentItem = this.create.apply(this, args);
2971	      this.currentItem.popupWindow.show();
2972	    }
2973	  }, {
2974	    key: "create",
2975	    value: function create(options) {
2976	      var menuId = null; //Compatibility
2977
2978	      var bindElement = arguments[1];
2979	      var menuItems = arguments[2];
2980	      var params = arguments[3];
2981
2982	      if (main_core.Type.isPlainObject(options) && !bindElement && !menuItems && !params) {
2983	        menuId = options.id;
2984
2985	        if (!main_core.Type.isStringFilled(menuId)) {
2986	          throw new Error('BX.Main.Menu.create: "id" parameter is required.');
2987	        }
2988	      } else {
2989	        menuId = options;
2990	      }
2991
2992	      if (!this.Data[menuId]) {
2993	        var menu = new Menu(options, bindElement, menuItems, params);
2994	        menu.getPopupWindow().subscribe('onDestroy', function () {
2995	          MenuManager.destroy(menuId);
2996	        });
2997	        this.Data[menuId] = menu;
2998	      }
2999
3000	      return this.Data[menuId];
3001	    }
3002	  }, {
3003	    key: "getCurrentMenu",
3004	    value: function getCurrentMenu() {
3005	      return this.currentItem;
3006	    }
3007	  }, {
3008	    key: "getMenuById",
3009	    value: function getMenuById(id) {
3010	      return this.Data[id] ? this.Data[id] : null;
3011	    }
3012	    /**
3013	     * compatibility
3014	     * @private
3015	     */
3016
3017	  }, {
3018	    key: "onPopupDestroy",
3019	    value: function onPopupDestroy(popupMenuWindow) {
3020	      this.destroy(popupMenuWindow.id);
3021	    }
3022	  }, {
3023	    key: "destroy",
3024	    value: function destroy(id) {
3025	      var menu = this.getMenuById(id);
3026
3027	      if (menu) {
3028	        if (this.currentItem === menu) {
3029	          this.currentItem = null;
3030	        }
3031
3032	        delete this.Data[id];
3033	        menu.getPopupWindow().destroy();
3034	      }
3035	    }
3036	  }]);
3037	  return MenuManager;
3038	}();
3039
3040	babelHelpers.defineProperty(MenuManager, "Data", {});
3041	babelHelpers.defineProperty(MenuManager, "currentItem", null);
3042
3043	/**
3044	 * @deprecated use Popup class instead: import { Popup } from 'main.popup'
3045	 */
3046
3047	var PopupWindow = /*#__PURE__*/function (_Popup) {
3048	  babelHelpers.inherits(PopupWindow, _Popup);
3049
3050	  function PopupWindow() {
3051	    babelHelpers.classCallCheck(this, PopupWindow);
3052	    return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindow).apply(this, arguments));
3053	  }
3054
3055	  return PopupWindow;
3056	}(Popup);
3057
3058	/**
3059	 * @deprecated use BX.UI.Button
3060	 */
3061
3062	var PopupWindowButton = /*#__PURE__*/function (_Button) {
3063	  babelHelpers.inherits(PopupWindowButton, _Button);
3064
3065	  function PopupWindowButton() {
3066	    babelHelpers.classCallCheck(this, PopupWindowButton);
3067	    return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowButton).apply(this, arguments));
3068	  }
3069
3070	  return PopupWindowButton;
3071	}(Button);
3072
3073	/**
3074	 * @deprecated use BX.UI.Button
3075	 */
3076
3077	var ButtonLink = /*#__PURE__*/function (_Button) {
3078	  babelHelpers.inherits(ButtonLink, _Button);
3079
3080	  function ButtonLink(params) {
3081	    var _this;
3082
3083	    babelHelpers.classCallCheck(this, ButtonLink);
3084	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ButtonLink).call(this, params));
3085	    _this.buttonNode = main_core.Dom.create('span', {
3086	      props: {
3087	        className: 'popup-window-button popup-window-button-link' + (_this.className.length > 0 ? ' ' + _this.className : ''),
3088	        id: _this.id
3089	      },
3090	      text: _this.text,
3091	      events: _this.contextEvents
3092	    });
3093	    return _this;
3094	  }
3095
3096	  return ButtonLink;
3097	}(Button);
3098
3099	/**
3100	 * @deprecated use BX.UI.Button
3101	 */
3102
3103	var PopupWindowButtonLink = /*#__PURE__*/function (_ButtonLink) {
3104	  babelHelpers.inherits(PopupWindowButtonLink, _ButtonLink);
3105
3106	  function PopupWindowButtonLink() {
3107	    babelHelpers.classCallCheck(this, PopupWindowButtonLink);
3108	    return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowButtonLink).apply(this, arguments));
3109	  }
3110
3111	  return PopupWindowButtonLink;
3112	}(ButtonLink);
3113
3114	/**
3115	 * @deprecated use BX.UI.Button
3116	 */
3117
3118	var CustomButton = /*#__PURE__*/function (_Button) {
3119	  babelHelpers.inherits(CustomButton, _Button);
3120
3121	  function CustomButton(params) {
3122	    var _this;
3123
3124	    babelHelpers.classCallCheck(this, CustomButton);
3125	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(CustomButton).call(this, params));
3126	    _this.buttonNode = main_core.Dom.create('span', {
3127	      props: {
3128	        className: _this.className.length > 0 ? _this.className : '',
3129	        id: _this.id
3130	      },
3131	      events: _this.contextEvents,
3132	      text: _this.text
3133	    });
3134	    return _this;
3135	  }
3136
3137	  return CustomButton;
3138	}(Button);
3139
3140	/**
3141	 * @deprecated use BX.UI.Button
3142	 */
3143
3144	var PopupWindowCustomButton = /*#__PURE__*/function (_CustomButton) {
3145	  babelHelpers.inherits(PopupWindowCustomButton, _CustomButton);
3146
3147	  function PopupWindowCustomButton() {
3148	    babelHelpers.classCallCheck(this, PopupWindowCustomButton);
3149	    return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowCustomButton).apply(this, arguments));
3150	  }
3151
3152	  return PopupWindowCustomButton;
3153	}(CustomButton);
3154
3155	/**
3156	 * @deprecated use Menu class instead: import { Menu } from 'main.popup'
3157	 */
3158
3159	var PopupMenuWindow = /*#__PURE__*/function (_Menu) {
3160	  babelHelpers.inherits(PopupMenuWindow, _Menu);
3161
3162	  function PopupMenuWindow() {
3163	    babelHelpers.classCallCheck(this, PopupMenuWindow);
3164	    return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupMenuWindow).apply(this, arguments));
3165	  }
3166
3167	  return PopupMenuWindow;
3168	}(Menu);
3169
3170	/**
3171	 * @deprecated use Menu.Item class instead: import { MenuItem } from 'main.popup'
3172	 */
3173
3174	var PopupMenuItem = /*#__PURE__*/function (_MenuItem) {
3175	  babelHelpers.inherits(PopupMenuItem, _MenuItem);
3176
3177	  function PopupMenuItem() {
3178	    babelHelpers.classCallCheck(this, PopupMenuItem);
3179	    return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupMenuItem).apply(this, arguments));
3180	  }
3181
3182	  return PopupMenuItem;
3183	}(MenuItem);
3184
3185	/**
3186	 * @deprecated
3187	 */
3188
3189	var InputPopup = /*#__PURE__*/function () {
3190	  function InputPopup(params) {
3191	    babelHelpers.classCallCheck(this, InputPopup);
3192	    this.id = params.id || 'bx-inp-popup-' + Math.round(Math.random() * 1000000);
3193	    this.handler = params.handler || false;
3194	    this.values = params.values || false;
3195	    this.pInput = params.input;
3196	    this.bValues = !!this.values;
3197	    this.defaultValue = params.defaultValue || '';
3198	    this.openTitle = params.openTitle || '';
3199	    this.className = params.className || '';
3200	    this.noMRclassName = params.noMRclassName || 'ec-no-rm';
3201	    this.emptyClassName = params.noMRclassName || 'ec-label';
3202
3203	    var _this = this;
3204
3205	    this.curInd = false;
3206
3207	    if (this.bValues) {
3208	      this.pInput.onfocus = this.pInput.onclick = function (e) {
3209	        if (this.value == _this.defaultValue) {
3210	          this.value = '';
3211	          this.className = _this.className;
3212	        }
3213
3214	        _this.ShowPopup();
3215
3216	        return e.preventDefault();
3217	      };
3218
3219	      this.pInput.onblur = function () {
3220	        if (_this.bShowed) {
3221	          setTimeout(function () {
3222	            _this.ClosePopup(true);
3223	          }, 200);
3224	        }
3225
3226	        _this.OnChange();
3227	      };
3228	    } else {
3229	      this.pInput.className = this.noMRclassName;
3230	      this.pInput.onblur = this.OnChange.bind(this);
3231	    }
3232	  }
3233
3234	  babelHelpers.createClass(InputPopup, [{
3235	    key: "ShowPopup",
3236	    value: function ShowPopup() {
3237	      if (this.bShowed) {
3238	        return;
3239	      }
3240
3241	      var _this = this;
3242
3243	      if (!this.oPopup) {
3244	        var pWnd = main_core.Dom.create('DIV', {
3245	          props: {
3246	            className: 'bxecpl-loc-popup ' + this.className
3247	          }
3248	        });
3249
3250	        for (var i = 0, l = this.values.length; i < l; i++) {
3251	          var pRow = pWnd.appendChild(main_core.Dom.create('DIV', {
3252	            props: {
3253	              id: 'bxecmr_' + i
3254	            },
3255	            text: this.values[i].NAME,
3256	            events: {
3257	              mouseover: function mouseover() {
3258	                main_core.Dom.addClass(this, 'bxecplloc-over');
3259	              },
3260	              mouseout: function mouseout() {
3261	                main_core.Dom.removeClass(this, 'bxecplloc-over');
3262	              },
3263	              click: function click() {
3264	                var ind = this.id.substr('bxecmr_'.length);
3265	                _this.pInput.value = _this.values[ind].NAME;
3266	                _this.curInd = ind;
3267
3268	                _this.OnChange();
3269
3270	                _this.ClosePopup(true);
3271	              }
3272	            }
3273	          }));
3274
3275	          if (this.values[i].DESCRIPTION) {
3276	            pRow.title = this.values[i].DESCRIPTION;
3277	          }
3278
3279	          if (this.values[i].CLASS_NAME) {
3280	            main_core.Dom.addClass(pRow, this.values[i].CLASS_NAME);
3281	          }
3282
3283	          if (this.values[i].URL) {
3284	            pRow.appendChild(main_core.Dom.create('a', {
3285	              props: {
3286	                href: this.values[i].URL,
3287	                className: 'bxecplloc-view',
3288	                target: '_blank',
3289	                title: this.openTitle
3290	              }
3291	            }));
3292	          }
3293	        }
3294
3295	        this.oPopup = new Popup(this.id, this.pInput, {
3296	          autoHide: true,
3297	          offsetTop: 1,
3298	          offsetLeft: 0,
3299	          lightShadow: true,
3300	          closeByEsc: true,
3301	          content: pWnd,
3302	          events: {
3303	            onClose: this.ClosePopup.bind(this)
3304	          }
3305	        });
3306	      }
3307
3308	      this.oPopup.show();
3309	      this.pInput.select();
3310	      this.bShowed = true;
3311	      main_core_events.EventEmitter.emit(this, 'onInputPopupShow', new main_core_events.BaseEvent({
3312	        compatData: [this]
3313	      }));
3314	    }
3315	  }, {
3316	    key: "ClosePopup",
3317	    value: function ClosePopup(bClosePopup) {
3318	      this.bShowed = false;
3319
3320	      if (this.pInput.value === '') {
3321	        this.OnChange();
3322	      }
3323
3324	      main_core_events.EventEmitter.emit(this, 'onInputPopupClose', new main_core_events.BaseEvent({
3325	        compatData: [this]
3326	      }));
3327
3328	      if (bClosePopup === true) {
3329	        this.oPopup.close();
3330	      }
3331	    }
3332	  }, {
3333	    key: "OnChange",
3334	    value: function OnChange() {
3335	      var val = this.pInput.value;
3336
3337	      if (this.bValues) {
3338	        if (this.pInput.value == '' || this.pInput.value == this.defaultValue) {
3339	          this.pInput.value = this.defaultValue;
3340	          this.pInput.className = this.emptyClassName;
3341	          val = '';
3342	        } else {
3343	          this.pInput.className = '';
3344	        }
3345	      }
3346
3347	      if (isNaN(parseInt(this.curInd)) || this.curInd !== false && val != this.values[this.curInd].NAME) {
3348	        this.curInd = false;
3349	      } else {
3350	        this.curInd = parseInt(this.curInd);
3351	      }
3352
3353	      main_core_events.EventEmitter.emit(this, 'onInputPopupChanged', new main_core_events.BaseEvent({
3354	        compatData: [this, this.curInd, val]
3355	      }));
3356
3357	      if (this.handler && typeof this.handler == 'function') {
3358	        this.handler({
3359	          ind: this.curInd,
3360	          value: val
3361	        });
3362	      }
3363	    }
3364	  }, {
3365	    key: "Set",
3366	    value: function Set(ind, val, bOnChange) {
3367	      this.curInd = ind;
3368
3369	      if (this.curInd !== false) {
3370	        this.pInput.value = this.values[this.curInd].NAME;
3371	      } else {
3372	        this.pInput.value = val;
3373	      }
3374
3375	      if (bOnChange !== false) {
3376	        this.OnChange();
3377	      }
3378	    }
3379	  }, {
3380	    key: "Get",
3381	    value: function Get(ind) {
3382	      var id = false;
3383
3384	      if (typeof ind == 'undefined') {
3385	        ind = this.curInd;
3386	      }
3387
3388	      if (ind !== false && this.values[ind]) {
3389	        id = this.values[ind].ID;
3390	      }
3391
3392	      return id;
3393	    }
3394	  }, {
3395	    key: "GetIndex",
3396	    value: function GetIndex(id) {
3397	      for (var i = 0, l = this.values.length; i < l; i++) {
3398	        if (this.values[i].ID == id) {
3399	          return i;
3400	        }
3401	      }
3402
3403	      return false;
3404	    }
3405	  }, {
3406	    key: "Deactivate",
3407	    value: function Deactivate(bDeactivate) {
3408	      if (this.pInput.value == '' || this.pInput.value == this.defaultValue) {
3409	        if (bDeactivate) {
3410	          this.pInput.value = '';
3411	          this.pInput.className = this.noMRclassName;
3412	        } else if (this.oEC.bUseMR) {
3413	          this.pInput.value = this.defaultValue;
3414	          this.pInput.className = this.emptyClassName;
3415	        }
3416	      }
3417
3418	      this.pInput.disabled = bDeactivate;
3419	    }
3420	  }]);
3421	  return InputPopup;
3422	}();
3423
3424	/*
3425
3426	//ES6
3427	import { Popup, PopupManager } from 'main.popup';
3428	const popup = new Popup();
3429	PopupManager.create();
3430
3431	//ES5
3432	var popup = new BX.Main.Popup();
3433	BX.Main.PopupManager.create();
3434
3435	//ES6
3436	import { Menu, MenuItem, MenuManager } from 'main.popup';
3437	const menu = new Menu();
3438	const item = new MenuItem();
3439	MenuManager.create();
3440
3441	//ES5
3442	var menu = new BX.Main.Menu();
3443	var item = new BX.Main.MenuItem();
3444	BX.Main.MenuManager.create();
3445
3446	 */
3447	var BX = main_core.Reflection.namespace('BX');
3448	/** @deprecated use BX.Main.Popup or import { Popup } from 'main.popup' */
3449
3450	BX.PopupWindow = Popup;
3451	/** @deprecated use BX.Main.PopupManager or import { PopupManager } from 'main.popup' */
3452
3453	BX.PopupWindowManager = PopupManager;
3454	/** @deprecated use BX.Main.Menu or import { Menu } from 'main.popup' */
3455
3456	BX.PopupMenuWindow = Menu;
3457	/** @deprecated use BX.Main.MenuManager or import { MenuManager } from 'main.popup' */
3458
3459	BX.PopupMenu = MenuManager;
3460	/** @deprecated use BX.Main.MenuItem or import { MenuItem } from 'main.popup' */
3461
3462	BX.PopupMenuItem = MenuItem;
3463	/** @deprecated use BX.UI.Button */
3464
3465	BX.PopupWindowButton = Button;
3466	/** @deprecated use BX.UI.Button */
3467
3468	BX.PopupWindowButtonLink = ButtonLink;
3469	/** @deprecated use BX.UI.Button */
3470
3471	BX.PopupWindowCustomButton = CustomButton;
3472	/** @deprecated use another API */
3473
3474	window.BXInputPopup = InputPopup;
3475
3476	exports.Popup = Popup;
3477	exports.Menu = Menu;
3478	exports.MenuItem = MenuItem;
3479	exports.PopupManager = PopupManager;
3480	exports.MenuManager = MenuManager;
3481	exports.PopupWindow = PopupWindow;
3482	exports.PopupMenuWindow = PopupMenuWindow;
3483	exports.PopupMenuItem = PopupMenuItem;
3484	exports.PopupWindowManager = PopupManager;
3485	exports.PopupMenu = MenuManager;
3486	exports.PopupWindowButton = PopupWindowButton;
3487	exports.PopupWindowButtonLink = PopupWindowButtonLink;
3488	exports.PopupWindowCustomButton = PopupWindowCustomButton;
3489
3490}((this.BX.Main = this.BX.Main || {}),BX.Event,BX));
3491//# sourceMappingURL=main.popup.bundle.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.